diff options
-rw-r--r-- | Documentation/devicetree/bindings/soc/mediatek/pwrap.txt | 1 | ||||
-rw-r--r-- | drivers/soc/mediatek/mtk-pmic-wrap.c | 81 |
2 files changed, 80 insertions, 2 deletions
diff --git a/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt b/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt index bf80e3f96f8c..f9987c30f0d5 100644 --- a/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt +++ b/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt | |||
@@ -19,6 +19,7 @@ IP Pairing | |||
19 | Required properties in pwrap device node. | 19 | Required properties in pwrap device node. |
20 | - compatible: | 20 | - compatible: |
21 | "mediatek,mt2701-pwrap" for MT2701/7623 SoCs | 21 | "mediatek,mt2701-pwrap" for MT2701/7623 SoCs |
22 | "mediatek,mt6797-pwrap" for MT6797 SoCs | ||
22 | "mediatek,mt7622-pwrap" for MT7622 SoCs | 23 | "mediatek,mt7622-pwrap" for MT7622 SoCs |
23 | "mediatek,mt8135-pwrap" for MT8135 SoCs | 24 | "mediatek,mt8135-pwrap" for MT8135 SoCs |
24 | "mediatek,mt8173-pwrap" for MT8173 SoCs | 25 | "mediatek,mt8173-pwrap" for MT8173 SoCs |
diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c index 2afae64061d8..4e931fdf4d09 100644 --- a/drivers/soc/mediatek/mtk-pmic-wrap.c +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c | |||
@@ -146,6 +146,21 @@ static const u32 mt6397_regs[] = { | |||
146 | [PWRAP_DEW_CIPHER_SWRST] = 0xbc24, | 146 | [PWRAP_DEW_CIPHER_SWRST] = 0xbc24, |
147 | }; | 147 | }; |
148 | 148 | ||
149 | static const u32 mt6351_regs[] = { | ||
150 | [PWRAP_DEW_DIO_EN] = 0x02F2, | ||
151 | [PWRAP_DEW_READ_TEST] = 0x02F4, | ||
152 | [PWRAP_DEW_WRITE_TEST] = 0x02F6, | ||
153 | [PWRAP_DEW_CRC_EN] = 0x02FA, | ||
154 | [PWRAP_DEW_CRC_VAL] = 0x02FC, | ||
155 | [PWRAP_DEW_CIPHER_KEY_SEL] = 0x0300, | ||
156 | [PWRAP_DEW_CIPHER_IV_SEL] = 0x0302, | ||
157 | [PWRAP_DEW_CIPHER_EN] = 0x0304, | ||
158 | [PWRAP_DEW_CIPHER_RDY] = 0x0306, | ||
159 | [PWRAP_DEW_CIPHER_MODE] = 0x0308, | ||
160 | [PWRAP_DEW_CIPHER_SWRST] = 0x030A, | ||
161 | [PWRAP_DEW_RDDMY_NO] = 0x030C, | ||
162 | }; | ||
163 | |||
149 | enum pwrap_regs { | 164 | enum pwrap_regs { |
150 | PWRAP_MUX_SEL, | 165 | PWRAP_MUX_SEL, |
151 | PWRAP_WRAP_EN, | 166 | PWRAP_WRAP_EN, |
@@ -366,6 +381,39 @@ static int mt2701_regs[] = { | |||
366 | [PWRAP_ADC_RDATA_ADDR2] = 0x154, | 381 | [PWRAP_ADC_RDATA_ADDR2] = 0x154, |
367 | }; | 382 | }; |
368 | 383 | ||
384 | static int mt6797_regs[] = { | ||
385 | [PWRAP_MUX_SEL] = 0x0, | ||
386 | [PWRAP_WRAP_EN] = 0x4, | ||
387 | [PWRAP_DIO_EN] = 0x8, | ||
388 | [PWRAP_SIDLY] = 0xC, | ||
389 | [PWRAP_RDDMY] = 0x10, | ||
390 | [PWRAP_CSHEXT_WRITE] = 0x18, | ||
391 | [PWRAP_CSHEXT_READ] = 0x1C, | ||
392 | [PWRAP_CSLEXT_START] = 0x20, | ||
393 | [PWRAP_CSLEXT_END] = 0x24, | ||
394 | [PWRAP_STAUPD_PRD] = 0x28, | ||
395 | [PWRAP_HARB_HPRIO] = 0x50, | ||
396 | [PWRAP_HIPRIO_ARB_EN] = 0x54, | ||
397 | [PWRAP_MAN_EN] = 0x60, | ||
398 | [PWRAP_MAN_CMD] = 0x64, | ||
399 | [PWRAP_WACS0_EN] = 0x70, | ||
400 | [PWRAP_WACS1_EN] = 0x84, | ||
401 | [PWRAP_WACS2_EN] = 0x98, | ||
402 | [PWRAP_INIT_DONE2] = 0x9C, | ||
403 | [PWRAP_WACS2_CMD] = 0xA0, | ||
404 | [PWRAP_WACS2_RDATA] = 0xA4, | ||
405 | [PWRAP_WACS2_VLDCLR] = 0xA8, | ||
406 | [PWRAP_INT_EN] = 0xC0, | ||
407 | [PWRAP_INT_FLG_RAW] = 0xC4, | ||
408 | [PWRAP_INT_FLG] = 0xC8, | ||
409 | [PWRAP_INT_CLR] = 0xCC, | ||
410 | [PWRAP_TIMER_EN] = 0xF4, | ||
411 | [PWRAP_WDT_UNIT] = 0xFC, | ||
412 | [PWRAP_WDT_SRC_EN] = 0x100, | ||
413 | [PWRAP_DCM_EN] = 0x1CC, | ||
414 | [PWRAP_DCM_DBC_PRD] = 0x1D4, | ||
415 | }; | ||
416 | |||
369 | static int mt7622_regs[] = { | 417 | static int mt7622_regs[] = { |
370 | [PWRAP_MUX_SEL] = 0x0, | 418 | [PWRAP_MUX_SEL] = 0x0, |
371 | [PWRAP_WRAP_EN] = 0x4, | 419 | [PWRAP_WRAP_EN] = 0x4, |
@@ -635,12 +683,14 @@ static int mt8135_regs[] = { | |||
635 | 683 | ||
636 | enum pmic_type { | 684 | enum pmic_type { |
637 | PMIC_MT6323, | 685 | PMIC_MT6323, |
686 | PMIC_MT6351, | ||
638 | PMIC_MT6380, | 687 | PMIC_MT6380, |
639 | PMIC_MT6397, | 688 | PMIC_MT6397, |
640 | }; | 689 | }; |
641 | 690 | ||
642 | enum pwrap_type { | 691 | enum pwrap_type { |
643 | PWRAP_MT2701, | 692 | PWRAP_MT2701, |
693 | PWRAP_MT6797, | ||
644 | PWRAP_MT7622, | 694 | PWRAP_MT7622, |
645 | PWRAP_MT8135, | 695 | PWRAP_MT8135, |
646 | PWRAP_MT8173, | 696 | PWRAP_MT8173, |
@@ -1067,6 +1117,7 @@ static int pwrap_init_cipher(struct pmic_wrapper *wrp) | |||
1067 | pwrap_writel(wrp, 1, PWRAP_CIPHER_START); | 1117 | pwrap_writel(wrp, 1, PWRAP_CIPHER_START); |
1068 | break; | 1118 | break; |
1069 | case PWRAP_MT2701: | 1119 | case PWRAP_MT2701: |
1120 | case PWRAP_MT6797: | ||
1070 | case PWRAP_MT8173: | 1121 | case PWRAP_MT8173: |
1071 | pwrap_writel(wrp, 1, PWRAP_CIPHER_EN); | 1122 | pwrap_writel(wrp, 1, PWRAP_CIPHER_EN); |
1072 | break; | 1123 | break; |
@@ -1080,8 +1131,6 @@ static int pwrap_init_cipher(struct pmic_wrapper *wrp) | |||
1080 | pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_SWRST], 0x0); | 1131 | pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_SWRST], 0x0); |
1081 | pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_KEY_SEL], 0x1); | 1132 | pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_KEY_SEL], 0x1); |
1082 | pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_IV_SEL], 0x2); | 1133 | pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_IV_SEL], 0x2); |
1083 | pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_LOAD], 0x1); | ||
1084 | pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_START], 0x1); | ||
1085 | 1134 | ||
1086 | switch (wrp->slave->type) { | 1135 | switch (wrp->slave->type) { |
1087 | case PMIC_MT6397: | 1136 | case PMIC_MT6397: |
@@ -1091,6 +1140,7 @@ static int pwrap_init_cipher(struct pmic_wrapper *wrp) | |||
1091 | 0x1); | 1140 | 0x1); |
1092 | break; | 1141 | break; |
1093 | case PMIC_MT6323: | 1142 | case PMIC_MT6323: |
1143 | case PMIC_MT6351: | ||
1094 | pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_EN], | 1144 | pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_EN], |
1095 | 0x1); | 1145 | 0x1); |
1096 | break; | 1146 | break; |
@@ -1367,6 +1417,15 @@ static const struct pwrap_slv_type pmic_mt6397 = { | |||
1367 | .pwrap_write = pwrap_write16, | 1417 | .pwrap_write = pwrap_write16, |
1368 | }; | 1418 | }; |
1369 | 1419 | ||
1420 | static const struct pwrap_slv_type pmic_mt6351 = { | ||
1421 | .dew_regs = mt6351_regs, | ||
1422 | .type = PMIC_MT6351, | ||
1423 | .regmap = &pwrap_regmap_config16, | ||
1424 | .caps = 0, | ||
1425 | .pwrap_read = pwrap_read16, | ||
1426 | .pwrap_write = pwrap_write16, | ||
1427 | }; | ||
1428 | |||
1370 | static const struct of_device_id of_slave_match_tbl[] = { | 1429 | static const struct of_device_id of_slave_match_tbl[] = { |
1371 | { | 1430 | { |
1372 | .compatible = "mediatek,mt6323", | 1431 | .compatible = "mediatek,mt6323", |
@@ -1381,6 +1440,9 @@ static const struct of_device_id of_slave_match_tbl[] = { | |||
1381 | .compatible = "mediatek,mt6397", | 1440 | .compatible = "mediatek,mt6397", |
1382 | .data = &pmic_mt6397, | 1441 | .data = &pmic_mt6397, |
1383 | }, { | 1442 | }, { |
1443 | .compatible = "mediatek,mt6351", | ||
1444 | .data = &pmic_mt6351, | ||
1445 | }, { | ||
1384 | /* sentinel */ | 1446 | /* sentinel */ |
1385 | } | 1447 | } |
1386 | }; | 1448 | }; |
@@ -1398,6 +1460,18 @@ static const struct pmic_wrapper_type pwrap_mt2701 = { | |||
1398 | .init_soc_specific = pwrap_mt2701_init_soc_specific, | 1460 | .init_soc_specific = pwrap_mt2701_init_soc_specific, |
1399 | }; | 1461 | }; |
1400 | 1462 | ||
1463 | static const struct pmic_wrapper_type pwrap_mt6797 = { | ||
1464 | .regs = mt6797_regs, | ||
1465 | .type = PWRAP_MT6797, | ||
1466 | .arb_en_all = 0x01fff, | ||
1467 | .int_en_all = 0xffffffc6, | ||
1468 | .spi_w = PWRAP_MAN_CMD_SPI_WRITE, | ||
1469 | .wdt_src = PWRAP_WDT_SRC_MASK_ALL, | ||
1470 | .has_bridge = 0, | ||
1471 | .init_reg_clock = pwrap_common_init_reg_clock, | ||
1472 | .init_soc_specific = NULL, | ||
1473 | }; | ||
1474 | |||
1401 | static const struct pmic_wrapper_type pwrap_mt7622 = { | 1475 | static const struct pmic_wrapper_type pwrap_mt7622 = { |
1402 | .regs = mt7622_regs, | 1476 | .regs = mt7622_regs, |
1403 | .type = PWRAP_MT7622, | 1477 | .type = PWRAP_MT7622, |
@@ -1439,6 +1513,9 @@ static const struct of_device_id of_pwrap_match_tbl[] = { | |||
1439 | .compatible = "mediatek,mt2701-pwrap", | 1513 | .compatible = "mediatek,mt2701-pwrap", |
1440 | .data = &pwrap_mt2701, | 1514 | .data = &pwrap_mt2701, |
1441 | }, { | 1515 | }, { |
1516 | .compatible = "mediatek,mt6797-pwrap", | ||
1517 | .data = &pwrap_mt6797, | ||
1518 | }, { | ||
1442 | .compatible = "mediatek,mt7622-pwrap", | 1519 | .compatible = "mediatek,mt7622-pwrap", |
1443 | .data = &pwrap_mt7622, | 1520 | .data = &pwrap_mt7622, |
1444 | }, { | 1521 | }, { |