kernel: bump 4.14 to 4.14.52 for 18.06
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.14 / 0120-soc-mediatek-pwrap-add-MediaTek-MT6380-as-one-slave-.patch
1 From 81c54afc5bc918ea3ed65cc356236b302b1f21ca Mon Sep 17 00:00:00 2001
2 From: Sean Wang <sean.wang@mediatek.com>
3 Date: Wed, 18 Oct 2017 16:28:46 +0800
4 Subject: [PATCH 120/224] soc: mediatek: pwrap: add MediaTek MT6380 as one
5 slave of pwrap
6
7 Add MediaTek MT6380 regulator becoming one of PMIC wrapper slave
8 and also add extra new regmap_config of 32-bit mode for MT6380
9 since old regmap_config of 16-bit mode can't be fit into the need.
10
11 Signed-off-by: Chenglin Xu <chenglin.xu@mediatek.com>
12 Signed-off-by: Chen Zhong <chen.zhong@mediatek.com>
13 Signed-off-by: Sean Wang <sean.wang@mediatek.com>
14 Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
15 ---
16 drivers/soc/mediatek/mtk-pmic-wrap.c | 24 +++++++++++++++++++++---
17 1 file changed, 21 insertions(+), 3 deletions(-)
18
19 --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
20 +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
21 @@ -507,6 +507,7 @@ struct pmic_wrapper;
22 struct pwrap_slv_type {
23 const u32 *dew_regs;
24 enum pmic_type type;
25 + const struct regmap_config *regmap;
26 /* Flags indicating the capability for the target slave */
27 u32 caps;
28 /*
29 @@ -1149,7 +1150,7 @@ static irqreturn_t pwrap_interrupt(int i
30 return IRQ_HANDLED;
31 }
32
33 -static const struct regmap_config pwrap_regmap_config = {
34 +static const struct regmap_config pwrap_regmap_config16 = {
35 .reg_bits = 16,
36 .val_bits = 16,
37 .reg_stride = 2,
38 @@ -1158,9 +1159,19 @@ static const struct regmap_config pwrap_
39 .max_register = 0xffff,
40 };
41
42 +static const struct regmap_config pwrap_regmap_config32 = {
43 + .reg_bits = 32,
44 + .val_bits = 32,
45 + .reg_stride = 4,
46 + .reg_read = pwrap_regmap_read,
47 + .reg_write = pwrap_regmap_write,
48 + .max_register = 0xffff,
49 +};
50 +
51 static const struct pwrap_slv_type pmic_mt6323 = {
52 .dew_regs = mt6323_regs,
53 .type = PMIC_MT6323,
54 + .regmap = &pwrap_regmap_config16,
55 .caps = PWRAP_SLV_CAP_SPI | PWRAP_SLV_CAP_DUALIO |
56 PWRAP_SLV_CAP_SECURITY,
57 .pwrap_read = pwrap_read16,
58 @@ -1170,6 +1181,7 @@ static const struct pwrap_slv_type pmic_
59 static const struct pwrap_slv_type pmic_mt6380 = {
60 .dew_regs = NULL,
61 .type = PMIC_MT6380,
62 + .regmap = &pwrap_regmap_config32,
63 .caps = 0,
64 .pwrap_read = pwrap_read32,
65 .pwrap_write = pwrap_write32,
66 @@ -1178,6 +1190,7 @@ static const struct pwrap_slv_type pmic_
67 static const struct pwrap_slv_type pmic_mt6397 = {
68 .dew_regs = mt6397_regs,
69 .type = PMIC_MT6397,
70 + .regmap = &pwrap_regmap_config16,
71 .caps = PWRAP_SLV_CAP_SPI | PWRAP_SLV_CAP_DUALIO |
72 PWRAP_SLV_CAP_SECURITY,
73 .pwrap_read = pwrap_read16,
74 @@ -1189,9 +1202,14 @@ static const struct of_device_id of_slav
75 .compatible = "mediatek,mt6323",
76 .data = &pmic_mt6323,
77 }, {
78 + /* The MT6380 PMIC only implements a regulator, so we bind it
79 + * directly instead of using a MFD.
80 + */
81 + .compatible = "mediatek,mt6380-regulator",
82 + .data = &pmic_mt6380,
83 + }, {
84 .compatible = "mediatek,mt6397",
85 .data = &pmic_mt6397,
86 - }, {
87 /* sentinel */
88 }
89 };
90 @@ -1372,7 +1390,7 @@ static int pwrap_probe(struct platform_d
91 if (ret)
92 goto err_out2;
93
94 - wrp->regmap = devm_regmap_init(wrp->dev, NULL, wrp, &pwrap_regmap_config);
95 + wrp->regmap = devm_regmap_init(wrp->dev, NULL, wrp, wrp->slave->regmap);
96 if (IS_ERR(wrp->regmap)) {
97 ret = PTR_ERR(wrp->regmap);
98 goto err_out2;