mediatek: update the ethernet compat string
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.4 / 0038-soc-mediatek-PMIC-wrap-remove-pwrap_is_mt8135-and-pw.patch
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
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
14 appropriate.
15
16 Signed-off-by: John Crispin <blogic@openwrt.org>
17 ---
18 drivers/soc/mediatek/mtk-pmic-wrap.c | 28 ++++++++++++----------------
19 1 file changed, 12 insertions(+), 16 deletions(-)
20
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 {
24 u32 int_en_all;
25 u32 spi_w;
26 u32 wdt_src;
27 + int has_bridge:1;
28 int (*init_reg_clock)(struct pmic_wrapper *wrp);
29 int (*init_soc_specific)(struct pmic_wrapper *wrp);
30 };
31
32 -static inline int pwrap_is_mt8135(struct pmic_wrapper *wrp)
33 -{
34 - return wrp->master->type == PWRAP_MT8135;
35 -}
36 -
37 -static inline int pwrap_is_mt8173(struct pmic_wrapper *wrp)
38 -{
39 - return wrp->master->type == PWRAP_MT8173;
40 -}
41 -
42 static u32 pwrap_readl(struct pmic_wrapper *wrp, enum pwrap_regs reg)
43 {
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);
48
49 - if (pwrap_is_mt8135(wrp)) {
50 + switch (wrp->master->type) {
51 + case PWRAP_MT8135:
52 pwrap_writel(wrp, 1, PWRAP_CIPHER_LOAD);
53 pwrap_writel(wrp, 1, PWRAP_CIPHER_START);
54 - } else {
55 + break;
56 + case PWRAP_MT8173:
57 pwrap_writel(wrp, 1, PWRAP_CIPHER_EN);
58 + break;
59 }
60
61 /* Config cipher mode @PMIC */
62 @@ -713,7 +707,7 @@ static int pwrap_init(struct pmic_wrappe
63 if (wrp->rstc_bridge)
64 reset_control_reset(wrp->rstc_bridge);
65
66 - if (pwrap_is_mt8173(wrp)) {
67 + if (wrp->master->type == PWRAP_MT8173) {
68 /* Enable DCM */
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);
74
75 - if (pwrap_is_mt8135(wrp))
76 + if (wrp->master->type == PWRAP_MT8135)
77 pwrap_writel(wrp, 0x7, PWRAP_RRARB_EN);
78
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);
83
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);
88 }
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,
93 + .has_bridge = 1,
94 .init_reg_clock = pwrap_mt8135_init_reg_clock,
95 .init_soc_specific = pwrap_mt8135_init_soc_specific,
96 };
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,
101 + .has_bridge = 0,
102 .init_reg_clock = pwrap_mt8173_init_reg_clock,
103 .init_soc_specific = pwrap_mt8173_init_soc_specific,
104 };
105 @@ -889,7 +885,7 @@ static int pwrap_probe(struct platform_d
106 return ret;
107 }
108
109 - if (pwrap_is_mt8135(wrp)) {
110 + if (wrp->master->has_bridge) {
111 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
112 "pwrap-bridge");
113 wrp->bridge_base = devm_ioremap_resource(wrp->dev, res);