mediatek: update patches
[openwrt/svn-archive/archive.git] / target / linux / mediatek / patches-4.4 / 0040-soc-mediatek-PMIC-wrap-add-mt6323-slave-support.patch
1 From 2ff8338c16c86856fc6e3f636cf0df9a2562bc95 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 diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
15 index bcc841e..0e4ebb8 100644
16 --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
17 +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
18 @@ -93,6 +93,27 @@ enum dew_regs {
19 PWRAP_DEW_EVENT_TEST,
20 PWRAP_DEW_CIPHER_LOAD,
21 PWRAP_DEW_CIPHER_START,
22 +
23 + /* MT6323 only regs */
24 + PWRAP_DEW_CIPHER_EN,
25 + PWRAP_DEW_RDDMY_NO,
26 +};
27 +
28 +static const u32 mt6323_regs[] = {
29 + [PWRAP_DEW_BASE] = 0x0000,
30 + [PWRAP_DEW_DIO_EN] = 0x018a,
31 + [PWRAP_DEW_READ_TEST] = 0x018c,
32 + [PWRAP_DEW_WRITE_TEST] = 0x018e,
33 + [PWRAP_DEW_CRC_EN] = 0x0192,
34 + [PWRAP_DEW_CRC_VAL] = 0x0194,
35 + [PWRAP_DEW_MON_GRP_SEL] = 0x0196,
36 + [PWRAP_DEW_CIPHER_KEY_SEL] = 0x0198,
37 + [PWRAP_DEW_CIPHER_IV_SEL] = 0x019a,
38 + [PWRAP_DEW_CIPHER_EN] = 0x019c,
39 + [PWRAP_DEW_CIPHER_RDY] = 0x019e,
40 + [PWRAP_DEW_CIPHER_MODE] = 0x01a0,
41 + [PWRAP_DEW_CIPHER_SWRST] = 0x01a2,
42 + [PWRAP_DEW_RDDMY_NO] = 0x01a4,
43 };
44
45 static const u32 mt6397_regs[] = {
46 @@ -371,6 +392,7 @@ static int mt8135_regs[] = {
47 };
48
49 enum pmic_type {
50 + PMIC_MT6323,
51 PMIC_MT6397,
52 };
53
54 @@ -661,6 +683,19 @@ static int pwrap_init_cipher(struct pmic_wrapper *wrp)
55 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_LOAD], 0x1);
56 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_START], 0x1);
57
58 + switch (wrp->slave->type) {
59 + case PMIC_MT6397:
60 + pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_LOAD],
61 + 0x1);
62 + pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_START],
63 + 0x1);
64 + break;
65 + case PMIC_MT6323:
66 + pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_EN],
67 + 0x1);
68 + break;
69 + }
70 +
71 /* wait for cipher data ready@AP */
72 ret = pwrap_wait_for_state(wrp, pwrap_is_cipher_ready);
73 if (ret) {
74 @@ -858,6 +893,11 @@ static const struct regmap_config pwrap_regmap_config = {
75 .max_register = 0xffff,
76 };
77
78 +static const struct pwrap_slv_type pmic_mt6323 = {
79 + .dew_regs = mt6323_regs,
80 + .type = PMIC_MT6323,
81 +};
82 +
83 static const struct pwrap_slv_type pmic_mt6397 = {
84 .dew_regs = mt6397_regs,
85 .type = PMIC_MT6397,
86 @@ -865,6 +905,9 @@ static const struct pwrap_slv_type pmic_mt6397 = {
87
88 static const struct of_device_id of_slave_match_tbl[] = {
89 {
90 + .compatible = "mediatek,mt6323",
91 + .data = &pmic_mt6323,
92 + }, {
93 .compatible = "mediatek,mt6397",
94 .data = &pmic_mt6397,
95 }, {
96 --
97 1.7.10.4
98