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()
7 With more SoCs being added the list of helper functions like these would
8 grow. To mitigate this problem we remove the existing helpers and change
9 the code to test against the pmic type stored inside the pmic specific
10 datastructure that our context structure points at. There is one usage of
11 pwrap_is_mt8135() that is ambiguous as the test should not be dependent on
12 mt8135, but rather on the existence of a bridge. Add a new element to
13 pmic_wrapper_type to indicate if a bridge is present and use this where
16 Signed-off-by: John Crispin <blogic@openwrt.org>
18 drivers/soc/mediatek/mtk-pmic-wrap.c | 28 ++++++++++++----------------
19 1 file changed, 12 insertions(+), 16 deletions(-)
21 --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
22 +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
23 @@ -374,20 +374,11 @@ struct pmic_wrapper_type {
28 int (*init_reg_clock)(struct pmic_wrapper *wrp);
29 int (*init_soc_specific)(struct pmic_wrapper *wrp);
32 -static inline int pwrap_is_mt8135(struct pmic_wrapper *wrp)
34 - return wrp->master->type == PWRAP_MT8135;
37 -static inline int pwrap_is_mt8173(struct pmic_wrapper *wrp)
39 - return wrp->master->type == PWRAP_MT8173;
42 static u32 pwrap_readl(struct pmic_wrapper *wrp, enum pwrap_regs reg)
44 return readl(wrp->base + wrp->master->regs[reg]);
45 @@ -619,11 +610,14 @@ static int pwrap_init_cipher(struct pmic
46 pwrap_writel(wrp, 0x1, PWRAP_CIPHER_KEY_SEL);
47 pwrap_writel(wrp, 0x2, PWRAP_CIPHER_IV_SEL);
49 - if (pwrap_is_mt8135(wrp)) {
50 + switch (wrp->master->type) {
52 pwrap_writel(wrp, 1, PWRAP_CIPHER_LOAD);
53 pwrap_writel(wrp, 1, PWRAP_CIPHER_START);
57 pwrap_writel(wrp, 1, PWRAP_CIPHER_EN);
61 /* Config cipher mode @PMIC */
62 @@ -713,7 +707,7 @@ static int pwrap_init(struct pmic_wrappe
64 reset_control_reset(wrp->rstc_bridge);
66 - if (pwrap_is_mt8173(wrp)) {
67 + if (wrp->master->type == PWRAP_MT8173) {
69 pwrap_writel(wrp, 3, PWRAP_DCM_EN);
70 pwrap_writel(wrp, 0, PWRAP_DCM_DBC_PRD);
71 @@ -773,7 +767,7 @@ static int pwrap_init(struct pmic_wrappe
72 pwrap_writel(wrp, PWRAP_DEW_CRC_VAL, PWRAP_SIG_ADR);
73 pwrap_writel(wrp, wrp->master->arb_en_all, PWRAP_HIPRIO_ARB_EN);
75 - if (pwrap_is_mt8135(wrp))
76 + if (wrp->master->type == PWRAP_MT8135)
77 pwrap_writel(wrp, 0x7, PWRAP_RRARB_EN);
79 pwrap_writel(wrp, 0x1, PWRAP_WACS0_EN);
80 @@ -793,7 +787,7 @@ static int pwrap_init(struct pmic_wrappe
81 pwrap_writel(wrp, 1, PWRAP_INIT_DONE0);
82 pwrap_writel(wrp, 1, PWRAP_INIT_DONE1);
84 - if (pwrap_is_mt8135(wrp)) {
85 + if (wrp->master->has_bridge) {
86 writel(1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_INIT_DONE3);
87 writel(1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_INIT_DONE4);
89 @@ -831,6 +825,7 @@ static struct pmic_wrapper_type pwrap_mt
90 .int_en_all = ~(BIT(31) | BIT(1)),
91 .spi_w = PWRAP_MAN_CMD_SPI_WRITE,
92 .wdt_src = PWRAP_WDT_SRC_MASK_ALL,
94 .init_reg_clock = pwrap_mt8135_init_reg_clock,
95 .init_soc_specific = pwrap_mt8135_init_soc_specific,
97 @@ -842,6 +837,7 @@ static struct pmic_wrapper_type pwrap_mt
98 .int_en_all = ~(BIT(31) | BIT(1)),
99 .spi_w = PWRAP_MAN_CMD_SPI_WRITE,
100 .wdt_src = PWRAP_WDT_SRC_MASK_NO_STAUPD,
102 .init_reg_clock = pwrap_mt8173_init_reg_clock,
103 .init_soc_specific = pwrap_mt8173_init_soc_specific,
105 @@ -889,7 +885,7 @@ static int pwrap_probe(struct platform_d
109 - if (pwrap_is_mt8135(wrp)) {
110 + if (wrp->master->has_bridge) {
111 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
113 wrp->bridge_base = devm_ioremap_resource(wrp->dev, res);