0034-soc-mediatek-PMIC-wrap-split-SoC-specific-init-into-.patch 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. From b3cc9f4c4b1164ac6a0700920eca84dff81d13d7 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <[email protected]>
  3. Date: Wed, 20 Jan 2016 10:12:00 +0100
  4. Subject: [PATCH 34/53] soc: mediatek: PMIC wrap: split SoC specific init into
  5. callback
  6. This patch moves the SoC specific wrapper init code into separate callback
  7. to avoid pwrap_init() getting too large. This is done by adding a new
  8. element called init_special to pmic_wrapper_type. Each currently supported
  9. SoC gets its own version of the callback and we copy the code that was
  10. previously inside pwrap_init() to these new callbacks. Finally we point the
  11. 2 instances of pmic_wrapper_type at the 2 new functions.
  12. Signed-off-by: John Crispin <[email protected]>
  13. ---
  14. drivers/soc/mediatek/mtk-pmic-wrap.c | 67 +++++++++++++++++++++-------------
  15. 1 file changed, 42 insertions(+), 25 deletions(-)
  16. diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
  17. index b22b664..22c89e9 100644
  18. --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
  19. +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
  20. @@ -372,6 +372,7 @@ struct pmic_wrapper_type {
  21. enum pwrap_type type;
  22. u32 arb_en_all;
  23. int (*init_reg_clock)(struct pmic_wrapper *wrp);
  24. + int (*init_soc_specific)(struct pmic_wrapper *wrp);
  25. };
  26. static inline int pwrap_is_mt8135(struct pmic_wrapper *wrp)
  27. @@ -665,6 +666,41 @@ static int pwrap_init_cipher(struct pmic_wrapper *wrp)
  28. return 0;
  29. }
  30. +static int pwrap_mt8135_init_soc_specific(struct pmic_wrapper *wrp)
  31. +{
  32. + /* enable pwrap events and pwrap bridge in AP side */
  33. + pwrap_writel(wrp, 0x1, PWRAP_EVENT_IN_EN);
  34. + pwrap_writel(wrp, 0xffff, PWRAP_EVENT_DST_EN);
  35. + writel(0x7f, wrp->bridge_base + PWRAP_MT8135_BRIDGE_IORD_ARB_EN);
  36. + writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WACS3_EN);
  37. + writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WACS4_EN);
  38. + writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WDT_UNIT);
  39. + writel(0xffff, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WDT_SRC_EN);
  40. + writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_TIMER_EN);
  41. + writel(0x7ff, wrp->bridge_base + PWRAP_MT8135_BRIDGE_INT_EN);
  42. +
  43. + /* enable PMIC event out and sources */
  44. + if (pwrap_write(wrp, PWRAP_DEW_EVENT_OUT_EN, 0x1) ||
  45. + pwrap_write(wrp, PWRAP_DEW_EVENT_SRC_EN, 0xffff)) {
  46. + dev_err(wrp->dev, "enable dewrap fail\n");
  47. + return -EFAULT;
  48. + }
  49. +
  50. + return 0;
  51. +}
  52. +
  53. +static int pwrap_mt8173_init_soc_specific(struct pmic_wrapper *wrp)
  54. +{
  55. + /* PMIC_DEWRAP enables */
  56. + if (pwrap_write(wrp, PWRAP_DEW_EVENT_OUT_EN, 0x1) ||
  57. + pwrap_write(wrp, PWRAP_DEW_EVENT_SRC_EN, 0xffff)) {
  58. + dev_err(wrp->dev, "enable dewrap fail\n");
  59. + return -EFAULT;
  60. + }
  61. +
  62. + return 0;
  63. +}
  64. +
  65. static int pwrap_init(struct pmic_wrapper *wrp)
  66. {
  67. int ret;
  68. @@ -743,31 +779,10 @@ static int pwrap_init(struct pmic_wrapper *wrp)
  69. pwrap_writel(wrp, 0x5, PWRAP_STAUPD_PRD);
  70. pwrap_writel(wrp, 0xff, PWRAP_STAUPD_GRPEN);
  71. - if (pwrap_is_mt8135(wrp)) {
  72. - /* enable pwrap events and pwrap bridge in AP side */
  73. - pwrap_writel(wrp, 0x1, PWRAP_EVENT_IN_EN);
  74. - pwrap_writel(wrp, 0xffff, PWRAP_EVENT_DST_EN);
  75. - writel(0x7f, wrp->bridge_base + PWRAP_MT8135_BRIDGE_IORD_ARB_EN);
  76. - writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WACS3_EN);
  77. - writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WACS4_EN);
  78. - writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WDT_UNIT);
  79. - writel(0xffff, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WDT_SRC_EN);
  80. - writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_TIMER_EN);
  81. - writel(0x7ff, wrp->bridge_base + PWRAP_MT8135_BRIDGE_INT_EN);
  82. -
  83. - /* enable PMIC event out and sources */
  84. - if (pwrap_write(wrp, PWRAP_DEW_EVENT_OUT_EN, 0x1) ||
  85. - pwrap_write(wrp, PWRAP_DEW_EVENT_SRC_EN, 0xffff)) {
  86. - dev_err(wrp->dev, "enable dewrap fail\n");
  87. - return -EFAULT;
  88. - }
  89. - } else {
  90. - /* PMIC_DEWRAP enables */
  91. - if (pwrap_write(wrp, PWRAP_DEW_EVENT_OUT_EN, 0x1) ||
  92. - pwrap_write(wrp, PWRAP_DEW_EVENT_SRC_EN, 0xffff)) {
  93. - dev_err(wrp->dev, "enable dewrap fail\n");
  94. - return -EFAULT;
  95. - }
  96. + if (wrp->master->init_soc_specific) {
  97. + ret = wrp->master->init_soc_specific(wrp);
  98. + if (ret)
  99. + return ret;
  100. }
  101. /* Setup the init done registers */
  102. @@ -811,6 +826,7 @@ static struct pmic_wrapper_type pwrap_mt8135 = {
  103. .type = PWRAP_MT8135,
  104. .arb_en_all = 0x1ff,
  105. .init_reg_clock = pwrap_mt8135_init_reg_clock,
  106. + .init_soc_specific = pwrap_mt8135_init_soc_specific,
  107. };
  108. static struct pmic_wrapper_type pwrap_mt8173 = {
  109. @@ -818,6 +834,7 @@ static struct pmic_wrapper_type pwrap_mt8173 = {
  110. .type = PWRAP_MT8173,
  111. .arb_en_all = 0x3f,
  112. .init_reg_clock = pwrap_mt8173_init_reg_clock,
  113. + .init_soc_specific = pwrap_mt8173_init_soc_specific,
  114. };
  115. static struct of_device_id of_pwrap_match_tbl[] = {
  116. --
  117. 1.7.10.4