diff options
| -rw-r--r-- | Documentation/devicetree/bindings/soc/mediatek/pwrap.txt | 1 | ||||
| -rw-r--r-- | drivers/soc/mediatek/mtk-pmic-wrap.c | 111 |
2 files changed, 110 insertions, 2 deletions
diff --git a/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt b/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt index 5a2ef1726e2a..7a32404c6114 100644 --- a/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt +++ b/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt | |||
| @@ -25,6 +25,7 @@ Required properties in pwrap device node. | |||
| 25 | "mediatek,mt8135-pwrap" for MT8135 SoCs | 25 | "mediatek,mt8135-pwrap" for MT8135 SoCs |
| 26 | "mediatek,mt8173-pwrap" for MT8173 SoCs | 26 | "mediatek,mt8173-pwrap" for MT8173 SoCs |
| 27 | "mediatek,mt8183-pwrap" for MT8183 SoCs | 27 | "mediatek,mt8183-pwrap" for MT8183 SoCs |
| 28 | "mediatek,mt8516-pwrap" for MT8516 SoCs | ||
| 28 | - interrupts: IRQ for pwrap in SOC | 29 | - interrupts: IRQ for pwrap in SOC |
| 29 | - reg-names: Must include the following entries: | 30 | - reg-names: Must include the following entries: |
| 30 | "pwrap": Main registers base | 31 | "pwrap": Main registers base |
diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c index 8236a6c87e19..c4449a163991 100644 --- a/drivers/soc/mediatek/mtk-pmic-wrap.c +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c | |||
| @@ -381,6 +381,10 @@ enum pwrap_regs { | |||
| 381 | PWRAP_EXT_GPS_AUXADC_RDATA_ADDR, | 381 | PWRAP_EXT_GPS_AUXADC_RDATA_ADDR, |
| 382 | PWRAP_GPSINF_0_STA, | 382 | PWRAP_GPSINF_0_STA, |
| 383 | PWRAP_GPSINF_1_STA, | 383 | PWRAP_GPSINF_1_STA, |
| 384 | |||
| 385 | /* MT8516 only regs */ | ||
| 386 | PWRAP_OP_TYPE, | ||
| 387 | PWRAP_MSB_FIRST, | ||
| 384 | }; | 388 | }; |
| 385 | 389 | ||
| 386 | static int mt2701_regs[] = { | 390 | static int mt2701_regs[] = { |
| @@ -852,6 +856,91 @@ static int mt8183_regs[] = { | |||
| 852 | [PWRAP_WACS2_VLDCLR] = 0xC28, | 856 | [PWRAP_WACS2_VLDCLR] = 0xC28, |
| 853 | }; | 857 | }; |
| 854 | 858 | ||
| 859 | static int mt8516_regs[] = { | ||
| 860 | [PWRAP_MUX_SEL] = 0x0, | ||
| 861 | [PWRAP_WRAP_EN] = 0x4, | ||
| 862 | [PWRAP_DIO_EN] = 0x8, | ||
| 863 | [PWRAP_SIDLY] = 0xc, | ||
| 864 | [PWRAP_RDDMY] = 0x10, | ||
| 865 | [PWRAP_SI_CK_CON] = 0x14, | ||
| 866 | [PWRAP_CSHEXT_WRITE] = 0x18, | ||
| 867 | [PWRAP_CSHEXT_READ] = 0x1c, | ||
| 868 | [PWRAP_CSLEXT_START] = 0x20, | ||
| 869 | [PWRAP_CSLEXT_END] = 0x24, | ||
| 870 | [PWRAP_STAUPD_PRD] = 0x28, | ||
| 871 | [PWRAP_STAUPD_GRPEN] = 0x2c, | ||
| 872 | [PWRAP_STAUPD_MAN_TRIG] = 0x40, | ||
| 873 | [PWRAP_STAUPD_STA] = 0x44, | ||
| 874 | [PWRAP_WRAP_STA] = 0x48, | ||
| 875 | [PWRAP_HARB_INIT] = 0x4c, | ||
| 876 | [PWRAP_HARB_HPRIO] = 0x50, | ||
| 877 | [PWRAP_HIPRIO_ARB_EN] = 0x54, | ||
| 878 | [PWRAP_HARB_STA0] = 0x58, | ||
| 879 | [PWRAP_HARB_STA1] = 0x5c, | ||
| 880 | [PWRAP_MAN_EN] = 0x60, | ||
| 881 | [PWRAP_MAN_CMD] = 0x64, | ||
| 882 | [PWRAP_MAN_RDATA] = 0x68, | ||
| 883 | [PWRAP_MAN_VLDCLR] = 0x6c, | ||
| 884 | [PWRAP_WACS0_EN] = 0x70, | ||
| 885 | [PWRAP_INIT_DONE0] = 0x74, | ||
| 886 | [PWRAP_WACS0_CMD] = 0x78, | ||
| 887 | [PWRAP_WACS0_RDATA] = 0x7c, | ||
| 888 | [PWRAP_WACS0_VLDCLR] = 0x80, | ||
| 889 | [PWRAP_WACS1_EN] = 0x84, | ||
| 890 | [PWRAP_INIT_DONE1] = 0x88, | ||
| 891 | [PWRAP_WACS1_CMD] = 0x8c, | ||
| 892 | [PWRAP_WACS1_RDATA] = 0x90, | ||
| 893 | [PWRAP_WACS1_VLDCLR] = 0x94, | ||
| 894 | [PWRAP_WACS2_EN] = 0x98, | ||
| 895 | [PWRAP_INIT_DONE2] = 0x9c, | ||
| 896 | [PWRAP_WACS2_CMD] = 0xa0, | ||
| 897 | [PWRAP_WACS2_RDATA] = 0xa4, | ||
| 898 | [PWRAP_WACS2_VLDCLR] = 0xa8, | ||
| 899 | [PWRAP_INT_EN] = 0xac, | ||
| 900 | [PWRAP_INT_FLG_RAW] = 0xb0, | ||
| 901 | [PWRAP_INT_FLG] = 0xb4, | ||
| 902 | [PWRAP_INT_CLR] = 0xb8, | ||
| 903 | [PWRAP_SIG_ADR] = 0xbc, | ||
| 904 | [PWRAP_SIG_MODE] = 0xc0, | ||
| 905 | [PWRAP_SIG_VALUE] = 0xc4, | ||
| 906 | [PWRAP_SIG_ERRVAL] = 0xc8, | ||
| 907 | [PWRAP_CRC_EN] = 0xcc, | ||
| 908 | [PWRAP_TIMER_EN] = 0xd0, | ||
| 909 | [PWRAP_TIMER_STA] = 0xd4, | ||
| 910 | [PWRAP_WDT_UNIT] = 0xd8, | ||
| 911 | [PWRAP_WDT_SRC_EN] = 0xdc, | ||
| 912 | [PWRAP_WDT_FLG] = 0xe0, | ||
| 913 | [PWRAP_DEBUG_INT_SEL] = 0xe4, | ||
| 914 | [PWRAP_DVFS_ADR0] = 0xe8, | ||
| 915 | [PWRAP_DVFS_WDATA0] = 0xec, | ||
| 916 | [PWRAP_DVFS_ADR1] = 0xf0, | ||
| 917 | [PWRAP_DVFS_WDATA1] = 0xf4, | ||
| 918 | [PWRAP_DVFS_ADR2] = 0xf8, | ||
| 919 | [PWRAP_DVFS_WDATA2] = 0xfc, | ||
| 920 | [PWRAP_DVFS_ADR3] = 0x100, | ||
| 921 | [PWRAP_DVFS_WDATA3] = 0x104, | ||
| 922 | [PWRAP_DVFS_ADR4] = 0x108, | ||
| 923 | [PWRAP_DVFS_WDATA4] = 0x10c, | ||
| 924 | [PWRAP_DVFS_ADR5] = 0x110, | ||
| 925 | [PWRAP_DVFS_WDATA5] = 0x114, | ||
| 926 | [PWRAP_DVFS_ADR6] = 0x118, | ||
| 927 | [PWRAP_DVFS_WDATA6] = 0x11c, | ||
| 928 | [PWRAP_DVFS_ADR7] = 0x120, | ||
| 929 | [PWRAP_DVFS_WDATA7] = 0x124, | ||
| 930 | [PWRAP_SPMINF_STA] = 0x128, | ||
| 931 | [PWRAP_CIPHER_KEY_SEL] = 0x12c, | ||
| 932 | [PWRAP_CIPHER_IV_SEL] = 0x130, | ||
| 933 | [PWRAP_CIPHER_EN] = 0x134, | ||
| 934 | [PWRAP_CIPHER_RDY] = 0x138, | ||
| 935 | [PWRAP_CIPHER_MODE] = 0x13c, | ||
| 936 | [PWRAP_CIPHER_SWRST] = 0x140, | ||
| 937 | [PWRAP_DCM_EN] = 0x144, | ||
| 938 | [PWRAP_DCM_DBC_PRD] = 0x148, | ||
| 939 | [PWRAP_SW_RST] = 0x168, | ||
| 940 | [PWRAP_OP_TYPE] = 0x16c, | ||
| 941 | [PWRAP_MSB_FIRST] = 0x170, | ||
| 942 | }; | ||
| 943 | |||
| 855 | enum pmic_type { | 944 | enum pmic_type { |
| 856 | PMIC_MT6323, | 945 | PMIC_MT6323, |
| 857 | PMIC_MT6351, | 946 | PMIC_MT6351, |
| @@ -869,6 +958,7 @@ enum pwrap_type { | |||
| 869 | PWRAP_MT8135, | 958 | PWRAP_MT8135, |
| 870 | PWRAP_MT8173, | 959 | PWRAP_MT8173, |
| 871 | PWRAP_MT8183, | 960 | PWRAP_MT8183, |
| 961 | PWRAP_MT8516, | ||
| 872 | }; | 962 | }; |
| 873 | 963 | ||
| 874 | struct pmic_wrapper; | 964 | struct pmic_wrapper; |
| @@ -1281,7 +1371,7 @@ static bool pwrap_is_pmic_cipher_ready(struct pmic_wrapper *wrp) | |||
| 1281 | static int pwrap_init_cipher(struct pmic_wrapper *wrp) | 1371 | static int pwrap_init_cipher(struct pmic_wrapper *wrp) |
| 1282 | { | 1372 | { |
| 1283 | int ret; | 1373 | int ret; |
| 1284 | u32 rdata; | 1374 | u32 rdata = 0; |
| 1285 | 1375 | ||
| 1286 | pwrap_writel(wrp, 0x1, PWRAP_CIPHER_SWRST); | 1376 | pwrap_writel(wrp, 0x1, PWRAP_CIPHER_SWRST); |
| 1287 | pwrap_writel(wrp, 0x0, PWRAP_CIPHER_SWRST); | 1377 | pwrap_writel(wrp, 0x0, PWRAP_CIPHER_SWRST); |
| @@ -1297,6 +1387,7 @@ static int pwrap_init_cipher(struct pmic_wrapper *wrp) | |||
| 1297 | case PWRAP_MT6765: | 1387 | case PWRAP_MT6765: |
| 1298 | case PWRAP_MT6797: | 1388 | case PWRAP_MT6797: |
| 1299 | case PWRAP_MT8173: | 1389 | case PWRAP_MT8173: |
| 1390 | case PWRAP_MT8516: | ||
| 1300 | pwrap_writel(wrp, 1, PWRAP_CIPHER_EN); | 1391 | pwrap_writel(wrp, 1, PWRAP_CIPHER_EN); |
| 1301 | break; | 1392 | break; |
| 1302 | case PWRAP_MT7622: | 1393 | case PWRAP_MT7622: |
| @@ -1478,7 +1569,8 @@ static int pwrap_init(struct pmic_wrapper *wrp) | |||
| 1478 | { | 1569 | { |
| 1479 | int ret; | 1570 | int ret; |
| 1480 | 1571 | ||
| 1481 | reset_control_reset(wrp->rstc); | 1572 | if (wrp->rstc) |
| 1573 | reset_control_reset(wrp->rstc); | ||
| 1482 | if (wrp->rstc_bridge) | 1574 | if (wrp->rstc_bridge) |
| 1483 | reset_control_reset(wrp->rstc_bridge); | 1575 | reset_control_reset(wrp->rstc_bridge); |
| 1484 | 1576 | ||
| @@ -1764,6 +1856,18 @@ static const struct pmic_wrapper_type pwrap_mt8183 = { | |||
| 1764 | .init_soc_specific = pwrap_mt8183_init_soc_specific, | 1856 | .init_soc_specific = pwrap_mt8183_init_soc_specific, |
| 1765 | }; | 1857 | }; |
| 1766 | 1858 | ||
| 1859 | static struct pmic_wrapper_type pwrap_mt8516 = { | ||
| 1860 | .regs = mt8516_regs, | ||
| 1861 | .type = PWRAP_MT8516, | ||
| 1862 | .arb_en_all = 0xff, | ||
| 1863 | .int_en_all = ~(u32)(BIT(31) | BIT(2)), | ||
| 1864 | .spi_w = PWRAP_MAN_CMD_SPI_WRITE, | ||
| 1865 | .wdt_src = PWRAP_WDT_SRC_MASK_ALL, | ||
| 1866 | .caps = PWRAP_CAP_DCM, | ||
| 1867 | .init_reg_clock = pwrap_mt2701_init_reg_clock, | ||
| 1868 | .init_soc_specific = NULL, | ||
| 1869 | }; | ||
| 1870 | |||
| 1767 | static const struct of_device_id of_pwrap_match_tbl[] = { | 1871 | static const struct of_device_id of_pwrap_match_tbl[] = { |
| 1768 | { | 1872 | { |
| 1769 | .compatible = "mediatek,mt2701-pwrap", | 1873 | .compatible = "mediatek,mt2701-pwrap", |
| @@ -1787,6 +1891,9 @@ static const struct of_device_id of_pwrap_match_tbl[] = { | |||
| 1787 | .compatible = "mediatek,mt8183-pwrap", | 1891 | .compatible = "mediatek,mt8183-pwrap", |
| 1788 | .data = &pwrap_mt8183, | 1892 | .data = &pwrap_mt8183, |
| 1789 | }, { | 1893 | }, { |
| 1894 | .compatible = "mediatek,mt8516-pwrap", | ||
| 1895 | .data = &pwrap_mt8516, | ||
| 1896 | }, { | ||
| 1790 | /* sentinel */ | 1897 | /* sentinel */ |
| 1791 | } | 1898 | } |
| 1792 | }; | 1899 | }; |
