0032-soc-mediatek-PMIC-wrap-don-t-duplicate-the-wrapper-d.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. From 64e8091be39c3f0a7bf4651bd2045b8c86429d55 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <blogic@openwrt.org>
  3. Date: Wed, 20 Jan 2016 06:42:01 +0100
  4. Subject: [PATCH 032/102] soc: mediatek: PMIC wrap: don't duplicate the
  5. wrapper data
  6. As we add support for more devices struct pmic_wrapper_type will grow and
  7. we do not really want to start duplicating all the elements in
  8. struct pmic_wrapper.
  9. Signed-off-by: John Crispin <blogic@openwrt.org>
  10. ---
  11. drivers/soc/mediatek/mtk-pmic-wrap.c | 22 ++++++++--------------
  12. 1 file changed, 8 insertions(+), 14 deletions(-)
  13. --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
  14. +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
  15. @@ -376,9 +376,7 @@ struct pmic_wrapper {
  16. struct device *dev;
  17. void __iomem *base;
  18. struct regmap *regmap;
  19. - int *regs;
  20. - enum pwrap_type type;
  21. - u32 arb_en_all;
  22. + const struct pmic_wrapper_type *master;
  23. struct clk *clk_spi;
  24. struct clk *clk_wrap;
  25. struct reset_control *rstc;
  26. @@ -389,22 +387,22 @@ struct pmic_wrapper {
  27. static inline int pwrap_is_mt8135(struct pmic_wrapper *wrp)
  28. {
  29. - return wrp->type == PWRAP_MT8135;
  30. + return wrp->master->type == PWRAP_MT8135;
  31. }
  32. static inline int pwrap_is_mt8173(struct pmic_wrapper *wrp)
  33. {
  34. - return wrp->type == PWRAP_MT8173;
  35. + return wrp->master->type == PWRAP_MT8173;
  36. }
  37. static u32 pwrap_readl(struct pmic_wrapper *wrp, enum pwrap_regs reg)
  38. {
  39. - return readl(wrp->base + wrp->regs[reg]);
  40. + return readl(wrp->base + wrp->master->regs[reg]);
  41. }
  42. static void pwrap_writel(struct pmic_wrapper *wrp, u32 val, enum pwrap_regs reg)
  43. {
  44. - writel(val, wrp->base + wrp->regs[reg]);
  45. + writel(val, wrp->base + wrp->master->regs[reg]);
  46. }
  47. static bool pwrap_is_fsm_idle(struct pmic_wrapper *wrp)
  48. @@ -697,7 +695,7 @@ static int pwrap_init(struct pmic_wrappe
  49. pwrap_writel(wrp, 1, PWRAP_WRAP_EN);
  50. - pwrap_writel(wrp, wrp->arb_en_all, PWRAP_HIPRIO_ARB_EN);
  51. + pwrap_writel(wrp, wrp->master->arb_en_all, PWRAP_HIPRIO_ARB_EN);
  52. pwrap_writel(wrp, 1, PWRAP_WACS2_EN);
  53. @@ -742,7 +740,7 @@ static int pwrap_init(struct pmic_wrappe
  54. pwrap_writel(wrp, 0x1, PWRAP_CRC_EN);
  55. pwrap_writel(wrp, 0x0, PWRAP_SIG_MODE);
  56. pwrap_writel(wrp, PWRAP_DEW_CRC_VAL, PWRAP_SIG_ADR);
  57. - pwrap_writel(wrp, wrp->arb_en_all, PWRAP_HIPRIO_ARB_EN);
  58. + pwrap_writel(wrp, wrp->master->arb_en_all, PWRAP_HIPRIO_ARB_EN);
  59. if (pwrap_is_mt8135(wrp))
  60. pwrap_writel(wrp, 0x7, PWRAP_RRARB_EN);
  61. @@ -836,7 +834,6 @@ static int pwrap_probe(struct platform_d
  62. struct device_node *np = pdev->dev.of_node;
  63. const struct of_device_id *of_id =
  64. of_match_device(of_pwrap_match_tbl, &pdev->dev);
  65. - const struct pmic_wrapper_type *type;
  66. struct resource *res;
  67. wrp = devm_kzalloc(&pdev->dev, sizeof(*wrp), GFP_KERNEL);
  68. @@ -845,10 +842,7 @@ static int pwrap_probe(struct platform_d
  69. platform_set_drvdata(pdev, wrp);
  70. - type = of_id->data;
  71. - wrp->regs = type->regs;
  72. - wrp->type = type->type;
  73. - wrp->arb_en_all = type->arb_en_all;
  74. + wrp->master = of_id->data;
  75. wrp->dev = &pdev->dev;
  76. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwrap");