f4111f1354b064c8c34a8c67f033c9f6d4e27cba
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.4 / 0040-soc-mediatek-PMIC-wrap-add-mt6323-slave-support.patch
1 From 15143b59a26a06e890e2ba3c9944b3f751ce39bd Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Wed, 20 Jan 2016 11:40:43 +0100
4 Subject: [PATCH 40/91] soc: mediatek: PMIC wrap: add mt6323 slave support
5
6 Add support for MT6323 slaves. This PMIC can be found on MT2701 and MT7623
7 EVB. The only function that we need to touch is pwrap_init_cipher().
8
9 Signed-off-by: John Crispin <blogic@openwrt.org>
10 ---
11 drivers/soc/mediatek/mtk-pmic-wrap.c | 43 ++++++++++++++++++++++++++++++++++
12 1 file changed, 43 insertions(+)
13
14 --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
15 +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
16 @@ -93,6 +93,27 @@ enum dew_regs {
17 PWRAP_DEW_EVENT_TEST,
18 PWRAP_DEW_CIPHER_LOAD,
19 PWRAP_DEW_CIPHER_START,
20 +
21 + /* MT6323 only regs */
22 + PWRAP_DEW_CIPHER_EN,
23 + PWRAP_DEW_RDDMY_NO,
24 +};
25 +
26 +static const u32 mt6323_regs[] = {
27 + [PWRAP_DEW_BASE] = 0x0000,
28 + [PWRAP_DEW_DIO_EN] = 0x018a,
29 + [PWRAP_DEW_READ_TEST] = 0x018c,
30 + [PWRAP_DEW_WRITE_TEST] = 0x018e,
31 + [PWRAP_DEW_CRC_EN] = 0x0192,
32 + [PWRAP_DEW_CRC_VAL] = 0x0194,
33 + [PWRAP_DEW_MON_GRP_SEL] = 0x0196,
34 + [PWRAP_DEW_CIPHER_KEY_SEL] = 0x0198,
35 + [PWRAP_DEW_CIPHER_IV_SEL] = 0x019a,
36 + [PWRAP_DEW_CIPHER_EN] = 0x019c,
37 + [PWRAP_DEW_CIPHER_RDY] = 0x019e,
38 + [PWRAP_DEW_CIPHER_MODE] = 0x01a0,
39 + [PWRAP_DEW_CIPHER_SWRST] = 0x01a2,
40 + [PWRAP_DEW_RDDMY_NO] = 0x01a4,
41 };
42
43 static const u32 mt6397_regs[] = {
44 @@ -371,6 +392,7 @@ static int mt8135_regs[] = {
45 };
46
47 enum pmic_type {
48 + PMIC_MT6323,
49 PMIC_MT6397,
50 };
51
52 @@ -661,6 +683,19 @@ static int pwrap_init_cipher(struct pmic
53 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_LOAD], 0x1);
54 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_START], 0x1);
55
56 + switch (wrp->slave->type) {
57 + case PMIC_MT6397:
58 + pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_LOAD],
59 + 0x1);
60 + pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_START],
61 + 0x1);
62 + break;
63 + case PMIC_MT6323:
64 + pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_EN],
65 + 0x1);
66 + break;
67 + }
68 +
69 /* wait for cipher data ready@AP */
70 ret = pwrap_wait_for_state(wrp, pwrap_is_cipher_ready);
71 if (ret) {
72 @@ -858,6 +893,11 @@ static const struct regmap_config pwrap_
73 .max_register = 0xffff,
74 };
75
76 +static const struct pwrap_slv_type pmic_mt6323 = {
77 + .dew_regs = mt6323_regs,
78 + .type = PMIC_MT6323,
79 +};
80 +
81 static const struct pwrap_slv_type pmic_mt6397 = {
82 .dew_regs = mt6397_regs,
83 .type = PMIC_MT6397,
84 @@ -865,6 +905,9 @@ static const struct pwrap_slv_type pmic_
85
86 static const struct of_device_id of_slave_match_tbl[] = {
87 {
88 + .compatible = "mediatek,mt6323",
89 + .data = &pmic_mt6323,
90 + }, {
91 .compatible = "mediatek,mt6397",
92 .data = &pmic_mt6397,
93 }, {