050-0002-mtd-nand-qcom-add-command-elements-in-BAM-transactio.patch 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. From 8c4cdce8b1ab044a2ee1d86d5a086f67e32b3c10 Mon Sep 17 00:00:00 2001
  2. From: Abhishek Sahu <[email protected]>
  3. Date: Mon, 25 Sep 2017 13:21:25 +0530
  4. Subject: [PATCH 2/7] mtd: nand: qcom: add command elements in BAM transaction
  5. All the QPIC register read/write through BAM DMA requires
  6. command descriptor which contains the array of command elements.
  7. Reviewed-by: Archit Taneja <[email protected]>
  8. Signed-off-by: Abhishek Sahu <[email protected]>
  9. Signed-off-by: Boris Brezillon <[email protected]>
  10. ---
  11. drivers/mtd/nand/qcom_nandc.c | 19 ++++++++++++++++++-
  12. 1 file changed, 18 insertions(+), 1 deletion(-)
  13. --- a/drivers/mtd/nand/qcom_nandc.c
  14. +++ b/drivers/mtd/nand/qcom_nandc.c
  15. @@ -22,6 +22,7 @@
  16. #include <linux/of.h>
  17. #include <linux/of_device.h>
  18. #include <linux/delay.h>
  19. +#include <linux/dma/qcom_bam_dma.h>
  20. /* NANDc reg offsets */
  21. #define NAND_FLASH_CMD 0x00
  22. @@ -199,6 +200,7 @@ nandc_set_reg(nandc, NAND_READ_LOCATION_
  23. */
  24. #define dev_cmd_reg_addr(nandc, reg) ((nandc)->props->dev_cmd_reg_start + (reg))
  25. +#define QPIC_PER_CW_CMD_ELEMENTS 32
  26. #define QPIC_PER_CW_CMD_SGL 32
  27. #define QPIC_PER_CW_DATA_SGL 8
  28. @@ -221,8 +223,13 @@ nandc_set_reg(nandc, NAND_READ_LOCATION_
  29. /*
  30. * This data type corresponds to the BAM transaction which will be used for all
  31. * NAND transfers.
  32. + * @bam_ce - the array of BAM command elements
  33. * @cmd_sgl - sgl for NAND BAM command pipe
  34. * @data_sgl - sgl for NAND BAM consumer/producer pipe
  35. + * @bam_ce_pos - the index in bam_ce which is available for next sgl
  36. + * @bam_ce_start - the index in bam_ce which marks the start position ce
  37. + * for current sgl. It will be used for size calculation
  38. + * for current sgl
  39. * @cmd_sgl_pos - current index in command sgl.
  40. * @cmd_sgl_start - start index in command sgl.
  41. * @tx_sgl_pos - current index in data sgl for tx.
  42. @@ -231,8 +238,11 @@ nandc_set_reg(nandc, NAND_READ_LOCATION_
  43. * @rx_sgl_start - start index in data sgl for rx.
  44. */
  45. struct bam_transaction {
  46. + struct bam_cmd_element *bam_ce;
  47. struct scatterlist *cmd_sgl;
  48. struct scatterlist *data_sgl;
  49. + u32 bam_ce_pos;
  50. + u32 bam_ce_start;
  51. u32 cmd_sgl_pos;
  52. u32 cmd_sgl_start;
  53. u32 tx_sgl_pos;
  54. @@ -462,7 +472,8 @@ alloc_bam_transaction(struct qcom_nand_c
  55. bam_txn_size =
  56. sizeof(*bam_txn) + num_cw *
  57. - ((sizeof(*bam_txn->cmd_sgl) * QPIC_PER_CW_CMD_SGL) +
  58. + ((sizeof(*bam_txn->bam_ce) * QPIC_PER_CW_CMD_ELEMENTS) +
  59. + (sizeof(*bam_txn->cmd_sgl) * QPIC_PER_CW_CMD_SGL) +
  60. (sizeof(*bam_txn->data_sgl) * QPIC_PER_CW_DATA_SGL));
  61. bam_txn_buf = devm_kzalloc(nandc->dev, bam_txn_size, GFP_KERNEL);
  62. @@ -472,6 +483,10 @@ alloc_bam_transaction(struct qcom_nand_c
  63. bam_txn = bam_txn_buf;
  64. bam_txn_buf += sizeof(*bam_txn);
  65. + bam_txn->bam_ce = bam_txn_buf;
  66. + bam_txn_buf +=
  67. + sizeof(*bam_txn->bam_ce) * QPIC_PER_CW_CMD_ELEMENTS * num_cw;
  68. +
  69. bam_txn->cmd_sgl = bam_txn_buf;
  70. bam_txn_buf +=
  71. sizeof(*bam_txn->cmd_sgl) * QPIC_PER_CW_CMD_SGL * num_cw;
  72. @@ -489,6 +504,8 @@ static void clear_bam_transaction(struct
  73. if (!nandc->props->is_bam)
  74. return;
  75. + bam_txn->bam_ce_pos = 0;
  76. + bam_txn->bam_ce_start = 0;
  77. bam_txn->cmd_sgl_pos = 0;
  78. bam_txn->cmd_sgl_start = 0;
  79. bam_txn->tx_sgl_pos = 0;