0038-soc-mediatek-PMIC-wrap-remove-pwrap_is_mt8135-and-pw.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. From da09b34ad22e8f065a02af114668f7d86357244a Mon Sep 17 00:00:00 2001
  2. From: John Crispin <blogic@openwrt.org>
  3. Date: Wed, 20 Jan 2016 10:54:18 +0100
  4. Subject: [PATCH 038/102] soc: mediatek: PMIC wrap: remove pwrap_is_mt8135()
  5. and pwrap_is_mt8173()
  6. With more SoCs being added the list of helper functions like these would
  7. grow. To mitigate this problem we remove the existing helpers and change
  8. the code to test against the pmic type stored inside the pmic specific
  9. datastructure that our context structure points at. There is one usage of
  10. pwrap_is_mt8135() that is ambiguous as the test should not be dependent on
  11. mt8135, but rather on the existence of a bridge. Add a new element to
  12. pmic_wrapper_type to indicate if a bridge is present and use this where
  13. appropriate.
  14. Signed-off-by: John Crispin <blogic@openwrt.org>
  15. ---
  16. drivers/soc/mediatek/mtk-pmic-wrap.c | 28 ++++++++++++----------------
  17. 1 file changed, 12 insertions(+), 16 deletions(-)
  18. --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
  19. +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
  20. @@ -374,20 +374,11 @@ struct pmic_wrapper_type {
  21. u32 int_en_all;
  22. u32 spi_w;
  23. u32 wdt_src;
  24. + int has_bridge:1;
  25. int (*init_reg_clock)(struct pmic_wrapper *wrp);
  26. int (*init_soc_specific)(struct pmic_wrapper *wrp);
  27. };
  28. -static inline int pwrap_is_mt8135(struct pmic_wrapper *wrp)
  29. -{
  30. - return wrp->master->type == PWRAP_MT8135;
  31. -}
  32. -
  33. -static inline int pwrap_is_mt8173(struct pmic_wrapper *wrp)
  34. -{
  35. - return wrp->master->type == PWRAP_MT8173;
  36. -}
  37. -
  38. static u32 pwrap_readl(struct pmic_wrapper *wrp, enum pwrap_regs reg)
  39. {
  40. return readl(wrp->base + wrp->master->regs[reg]);
  41. @@ -619,11 +610,14 @@ static int pwrap_init_cipher(struct pmic
  42. pwrap_writel(wrp, 0x1, PWRAP_CIPHER_KEY_SEL);
  43. pwrap_writel(wrp, 0x2, PWRAP_CIPHER_IV_SEL);
  44. - if (pwrap_is_mt8135(wrp)) {
  45. + switch (wrp->master->type) {
  46. + case PWRAP_MT8135:
  47. pwrap_writel(wrp, 1, PWRAP_CIPHER_LOAD);
  48. pwrap_writel(wrp, 1, PWRAP_CIPHER_START);
  49. - } else {
  50. + break;
  51. + case PWRAP_MT8173:
  52. pwrap_writel(wrp, 1, PWRAP_CIPHER_EN);
  53. + break;
  54. }
  55. /* Config cipher mode @PMIC */
  56. @@ -713,7 +707,7 @@ static int pwrap_init(struct pmic_wrappe
  57. if (wrp->rstc_bridge)
  58. reset_control_reset(wrp->rstc_bridge);
  59. - if (pwrap_is_mt8173(wrp)) {
  60. + if (wrp->master->type == PWRAP_MT8173) {
  61. /* Enable DCM */
  62. pwrap_writel(wrp, 3, PWRAP_DCM_EN);
  63. pwrap_writel(wrp, 0, PWRAP_DCM_DBC_PRD);
  64. @@ -773,7 +767,7 @@ static int pwrap_init(struct pmic_wrappe
  65. pwrap_writel(wrp, PWRAP_DEW_CRC_VAL, PWRAP_SIG_ADR);
  66. pwrap_writel(wrp, wrp->master->arb_en_all, PWRAP_HIPRIO_ARB_EN);
  67. - if (pwrap_is_mt8135(wrp))
  68. + if (wrp->master->type == PWRAP_MT8135)
  69. pwrap_writel(wrp, 0x7, PWRAP_RRARB_EN);
  70. pwrap_writel(wrp, 0x1, PWRAP_WACS0_EN);
  71. @@ -793,7 +787,7 @@ static int pwrap_init(struct pmic_wrappe
  72. pwrap_writel(wrp, 1, PWRAP_INIT_DONE0);
  73. pwrap_writel(wrp, 1, PWRAP_INIT_DONE1);
  74. - if (pwrap_is_mt8135(wrp)) {
  75. + if (wrp->master->has_bridge) {
  76. writel(1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_INIT_DONE3);
  77. writel(1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_INIT_DONE4);
  78. }
  79. @@ -831,6 +825,7 @@ static struct pmic_wrapper_type pwrap_mt
  80. .int_en_all = ~(BIT(31) | BIT(1)),
  81. .spi_w = PWRAP_MAN_CMD_SPI_WRITE,
  82. .wdt_src = PWRAP_WDT_SRC_MASK_ALL,
  83. + .has_bridge = 1,
  84. .init_reg_clock = pwrap_mt8135_init_reg_clock,
  85. .init_soc_specific = pwrap_mt8135_init_soc_specific,
  86. };
  87. @@ -842,6 +837,7 @@ static struct pmic_wrapper_type pwrap_mt
  88. .int_en_all = ~(BIT(31) | BIT(1)),
  89. .spi_w = PWRAP_MAN_CMD_SPI_WRITE,
  90. .wdt_src = PWRAP_WDT_SRC_MASK_NO_STAUPD,
  91. + .has_bridge = 0,
  92. .init_reg_clock = pwrap_mt8173_init_reg_clock,
  93. .init_soc_specific = pwrap_mt8173_init_soc_specific,
  94. };
  95. @@ -889,7 +885,7 @@ static int pwrap_probe(struct platform_d
  96. return ret;
  97. }
  98. - if (pwrap_is_mt8135(wrp)) {
  99. + if (wrp->master->has_bridge) {
  100. res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
  101. "pwrap-bridge");
  102. wrp->bridge_base = devm_ioremap_resource(wrp->dev, res);