0121-soc-mediatek-pwrap-add-common-way-for-setup-CS-timin.patch 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. From 442c890727e0f585154662b0908fbe3a7986052a Mon Sep 17 00:00:00 2001
  2. From: Sean Wang <[email protected]>
  3. Date: Wed, 18 Oct 2017 16:28:47 +0800
  4. Subject: [PATCH 121/224] soc: mediatek: pwrap: add common way for setup CS
  5. timing extenstion
  6. Multiple platforms would always use their own way handling CS timing
  7. extension on the bus which leads to a little bit code duplication.
  8. Therefore, the patch groups the similar logic to handle CS timing
  9. extension into the common function which allows the following SoCs
  10. have more reusability for configing CS timing.
  11. Signed-off-by: Chenglin Xu <[email protected]>
  12. Signed-off-by: Sean Wang <[email protected]>
  13. Signed-off-by: Matthias Brugger <[email protected]>
  14. ---
  15. drivers/soc/mediatek/mtk-pmic-wrap.c | 59 ++++++++++++++++++++++--------------
  16. 1 file changed, 37 insertions(+), 22 deletions(-)
  17. --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
  18. +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
  19. @@ -827,23 +827,44 @@ static int pwrap_init_dual_io(struct pmi
  20. return 0;
  21. }
  22. -static int pwrap_mt8135_init_reg_clock(struct pmic_wrapper *wrp)
  23. -{
  24. - pwrap_writel(wrp, 0x4, PWRAP_CSHEXT);
  25. - pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_WRITE);
  26. - pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_READ);
  27. - pwrap_writel(wrp, 0x0, PWRAP_CSLEXT_START);
  28. - pwrap_writel(wrp, 0x0, PWRAP_CSLEXT_END);
  29. -
  30. - return 0;
  31. +/*
  32. + * pwrap_init_chip_select_ext is used to configure CS extension time for each
  33. + * phase during data transactions on the pwrap bus.
  34. + */
  35. +static void pwrap_init_chip_select_ext(struct pmic_wrapper *wrp, u8 hext_write,
  36. + u8 hext_read, u8 lext_start,
  37. + u8 lext_end)
  38. +{
  39. + /*
  40. + * After finishing a write and read transaction, extends CS high time
  41. + * to be at least xT of BUS CLK as hext_write and hext_read specifies
  42. + * respectively.
  43. + */
  44. + pwrap_writel(wrp, hext_write, PWRAP_CSHEXT_WRITE);
  45. + pwrap_writel(wrp, hext_read, PWRAP_CSHEXT_READ);
  46. +
  47. + /*
  48. + * Extends CS low time after CSL and before CSH command to be at
  49. + * least xT of BUS CLK as lext_start and lext_end specifies
  50. + * respectively.
  51. + */
  52. + pwrap_writel(wrp, lext_start, PWRAP_CSLEXT_START);
  53. + pwrap_writel(wrp, lext_end, PWRAP_CSLEXT_END);
  54. }
  55. -static int pwrap_mt8173_init_reg_clock(struct pmic_wrapper *wrp)
  56. +static int pwrap_common_init_reg_clock(struct pmic_wrapper *wrp)
  57. {
  58. - pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_WRITE);
  59. - pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_READ);
  60. - pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_START);
  61. - pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_END);
  62. + switch (wrp->master->type) {
  63. + case PWRAP_MT8173:
  64. + pwrap_init_chip_select_ext(wrp, 0, 4, 2, 2);
  65. + break;
  66. + case PWRAP_MT8135:
  67. + pwrap_writel(wrp, 0x4, PWRAP_CSHEXT);
  68. + pwrap_init_chip_select_ext(wrp, 0, 4, 0, 0);
  69. + break;
  70. + default:
  71. + break;
  72. + }
  73. return 0;
  74. }
  75. @@ -853,20 +874,14 @@ static int pwrap_mt2701_init_reg_clock(s
  76. switch (wrp->slave->type) {
  77. case PMIC_MT6397:
  78. pwrap_writel(wrp, 0xc, PWRAP_RDDMY);
  79. - pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_WRITE);
  80. - pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_READ);
  81. - pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_START);
  82. - pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_END);
  83. + pwrap_init_chip_select_ext(wrp, 4, 0, 2, 2);
  84. break;
  85. case PMIC_MT6323:
  86. pwrap_writel(wrp, 0x8, PWRAP_RDDMY);
  87. pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_RDDMY_NO],
  88. 0x8);
  89. - pwrap_writel(wrp, 0x5, PWRAP_CSHEXT_WRITE);
  90. - pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_READ);
  91. - pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_START);
  92. - pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_END);
  93. + pwrap_init_chip_select_ext(wrp, 5, 0, 2, 2);
  94. break;
  95. default:
  96. break;
  97. @@ -1235,7 +1250,7 @@ static const struct pmic_wrapper_type pw
  98. .spi_w = PWRAP_MAN_CMD_SPI_WRITE,
  99. .wdt_src = PWRAP_WDT_SRC_MASK_ALL,
  100. .has_bridge = 1,
  101. - .init_reg_clock = pwrap_mt8135_init_reg_clock,
  102. + .init_reg_clock = pwrap_common_init_reg_clock,
  103. .init_soc_specific = pwrap_mt8135_init_soc_specific,
  104. };
  105. @@ -1247,7 +1262,7 @@ static const struct pmic_wrapper_type pw
  106. .spi_w = PWRAP_MAN_CMD_SPI_WRITE,
  107. .wdt_src = PWRAP_WDT_SRC_MASK_NO_STAUPD,
  108. .has_bridge = 0,
  109. - .init_reg_clock = pwrap_mt8173_init_reg_clock,
  110. + .init_reg_clock = pwrap_common_init_reg_clock,
  111. .init_soc_specific = pwrap_mt8173_init_soc_specific,
  112. };