diff options
author | Arnd Bergmann <arnd@arndb.de> | 2017-11-02 11:29:56 -0400 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2017-11-02 11:29:56 -0400 |
commit | 9855b3db5121a3900f43e9392285b44b71247adc (patch) | |
tree | 65e25ba0a7ee0783893045bb3fdb5dcd3113d604 | |
parent | 84cbda2fec8813fc40b33e6d8e0f2476ab43d5ce (diff) | |
parent | f32fbbadaf4470e8bac27f6d87bd27441df7167f (diff) |
Merge tag 'v4.14-next-soc' of https://github.com/mbgg/linux-mediatek into next/drivers
Pull "Mediatek: soc driver updates for v4.15" from Matthias Brugger:
- add 32 bit read/write support to pwrap
- add mt7622 support to pwrap
- test build all mediatek soc drivers
- fix compiler issues
- clean up Kconfig description
* tag 'v4.14-next-soc' of https://github.com/mbgg/linux-mediatek:
soc: mediatek: pwrap: fix fatal compiler error
soc: mediatek: pwrap: fix compiler errors
arm64: mediatek: cleanup message for platform selection
soc: Allow test-building of MediaTek drivers
soc: mediatek: place Kconfig for all SoC drivers under menu
soc: mediatek: pwrap: add support for MT7622 SoC
soc: mediatek: pwrap: add common way for setup CS timing extenstion
soc: mediatek: pwrap: add MediaTek MT6380 as one slave of pwrap
soc: mediatek: pwrap: refactor pwrap_init for the various PMIC types
soc: mediatek: pwrap: add pwrap_write32 for writing in 32-bit mode
soc: mediatek: pwrap: add pwrap_read32 for reading in 32-bit mode
dt-bindings: arm: mediatek: add MT7622 string to the PMIC wrapper doc
ARM: mediatek: Cocci spatch "of_table"
soc: mediatek: pwrap: fixup warnings from coding style
-rw-r--r-- | Documentation/devicetree/bindings/soc/mediatek/pwrap.txt | 6 | ||||
-rw-r--r-- | arch/arm/mach-mediatek/platsmp.c | 2 | ||||
-rw-r--r-- | arch/arm64/Kconfig.platforms | 5 | ||||
-rw-r--r-- | drivers/soc/Makefile | 2 | ||||
-rw-r--r-- | drivers/soc/mediatek/Kconfig | 8 | ||||
-rw-r--r-- | drivers/soc/mediatek/mtk-pmic-wrap.c | 511 |
6 files changed, 447 insertions, 87 deletions
diff --git a/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt b/Documentation/devicetree/bindings/soc/mediatek/pwrap.txt index 107700d00df4..bf80e3f96f8c 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,mt7622-pwrap" for MT7622 SoCs | ||
22 | "mediatek,mt8135-pwrap" for MT8135 SoCs | 23 | "mediatek,mt8135-pwrap" for MT8135 SoCs |
23 | "mediatek,mt8173-pwrap" for MT8173 SoCs | 24 | "mediatek,mt8173-pwrap" for MT8173 SoCs |
24 | - interrupts: IRQ for pwrap in SOC | 25 | - interrupts: IRQ for pwrap in SOC |
@@ -36,9 +37,12 @@ Required properties in pwrap device node. | |||
36 | - clocks: Must contain an entry for each entry in clock-names. | 37 | - clocks: Must contain an entry for each entry in clock-names. |
37 | 38 | ||
38 | Optional properities: | 39 | Optional properities: |
39 | - pmic: Mediatek PMIC MFD is the child device of pwrap | 40 | - pmic: Using either MediaTek PMIC MFD as the child device of pwrap |
40 | See the following for child node definitions: | 41 | See the following for child node definitions: |
41 | Documentation/devicetree/bindings/mfd/mt6397.txt | 42 | Documentation/devicetree/bindings/mfd/mt6397.txt |
43 | or the regulator-only device as the child device of pwrap, such as MT6380. | ||
44 | See the following definitions for such kinds of devices. | ||
45 | Documentation/devicetree/bindings/regulator/mt6380-regulator.txt | ||
42 | 46 | ||
43 | Example: | 47 | Example: |
44 | pwrap: pwrap@1000f000 { | 48 | pwrap: pwrap@1000f000 { |
diff --git a/arch/arm/mach-mediatek/platsmp.c b/arch/arm/mach-mediatek/platsmp.c index 27d78c945caf..6882ff07aaa6 100644 --- a/arch/arm/mach-mediatek/platsmp.c +++ b/arch/arm/mach-mediatek/platsmp.c | |||
@@ -54,12 +54,14 @@ static const struct of_device_id mtk_tz_smp_boot_infos[] __initconst = { | |||
54 | { .compatible = "mediatek,mt8135", .data = &mtk_mt8135_tz_boot }, | 54 | { .compatible = "mediatek,mt8135", .data = &mtk_mt8135_tz_boot }, |
55 | { .compatible = "mediatek,mt8127", .data = &mtk_mt8135_tz_boot }, | 55 | { .compatible = "mediatek,mt8127", .data = &mtk_mt8135_tz_boot }, |
56 | { .compatible = "mediatek,mt2701", .data = &mtk_mt8135_tz_boot }, | 56 | { .compatible = "mediatek,mt2701", .data = &mtk_mt8135_tz_boot }, |
57 | {}, | ||
57 | }; | 58 | }; |
58 | 59 | ||
59 | static const struct of_device_id mtk_smp_boot_infos[] __initconst = { | 60 | static const struct of_device_id mtk_smp_boot_infos[] __initconst = { |
60 | { .compatible = "mediatek,mt6589", .data = &mtk_mt6589_boot }, | 61 | { .compatible = "mediatek,mt6589", .data = &mtk_mt6589_boot }, |
61 | { .compatible = "mediatek,mt7623", .data = &mtk_mt7623_boot }, | 62 | { .compatible = "mediatek,mt7623", .data = &mtk_mt7623_boot }, |
62 | { .compatible = "mediatek,mt7623a", .data = &mtk_mt7623_boot }, | 63 | { .compatible = "mediatek,mt7623a", .data = &mtk_mt7623_boot }, |
64 | {}, | ||
63 | }; | 65 | }; |
64 | 66 | ||
65 | static void __iomem *mtk_smp_base; | 67 | static void __iomem *mtk_smp_base; |
diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms index 6b54ee8c1262..ab69f5fce261 100644 --- a/arch/arm64/Kconfig.platforms +++ b/arch/arm64/Kconfig.platforms | |||
@@ -91,12 +91,13 @@ config ARCH_HISI | |||
91 | This enables support for Hisilicon ARMv8 SoC family | 91 | This enables support for Hisilicon ARMv8 SoC family |
92 | 92 | ||
93 | config ARCH_MEDIATEK | 93 | config ARCH_MEDIATEK |
94 | bool "Mediatek MT65xx & MT81xx ARMv8 SoC" | 94 | bool "MediaTek SoC Family" |
95 | select ARM_GIC | 95 | select ARM_GIC |
96 | select PINCTRL | 96 | select PINCTRL |
97 | select MTK_TIMER | 97 | select MTK_TIMER |
98 | help | 98 | help |
99 | Support for Mediatek MT65xx & MT81xx ARMv8 SoCs | 99 | This enables support for MediaTek MT27xx, MT65xx, MT76xx |
100 | & MT81xx ARMv8 SoCs | ||
100 | 101 | ||
101 | config ARCH_MESON | 102 | config ARCH_MESON |
102 | bool "Amlogic Platforms" | 103 | bool "Amlogic Platforms" |
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 2fcaff864584..1d920a9e94d0 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile | |||
@@ -10,7 +10,7 @@ obj-$(CONFIG_MACH_DOVE) += dove/ | |||
10 | obj-y += fsl/ | 10 | obj-y += fsl/ |
11 | obj-$(CONFIG_ARCH_MXC) += imx/ | 11 | obj-$(CONFIG_ARCH_MXC) += imx/ |
12 | obj-$(CONFIG_SOC_XWAY) += lantiq/ | 12 | obj-$(CONFIG_SOC_XWAY) += lantiq/ |
13 | obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/ | 13 | obj-y += mediatek/ |
14 | obj-$(CONFIG_ARCH_MESON) += amlogic/ | 14 | obj-$(CONFIG_ARCH_MESON) += amlogic/ |
15 | obj-$(CONFIG_ARCH_QCOM) += qcom/ | 15 | obj-$(CONFIG_ARCH_QCOM) += qcom/ |
16 | obj-y += renesas/ | 16 | obj-y += renesas/ |
diff --git a/drivers/soc/mediatek/Kconfig b/drivers/soc/mediatek/Kconfig index 609bb3424c14..a7d0667338f2 100644 --- a/drivers/soc/mediatek/Kconfig +++ b/drivers/soc/mediatek/Kconfig | |||
@@ -1,9 +1,11 @@ | |||
1 | # | 1 | # |
2 | # MediaTek SoC drivers | 2 | # MediaTek SoC drivers |
3 | # | 3 | # |
4 | menu "MediaTek SoC drivers" | ||
5 | depends on ARCH_MEDIATEK || COMPILE_TEST | ||
6 | |||
4 | config MTK_INFRACFG | 7 | config MTK_INFRACFG |
5 | bool "MediaTek INFRACFG Support" | 8 | bool "MediaTek INFRACFG Support" |
6 | depends on ARCH_MEDIATEK || COMPILE_TEST | ||
7 | select REGMAP | 9 | select REGMAP |
8 | help | 10 | help |
9 | Say yes here to add support for the MediaTek INFRACFG controller. The | 11 | Say yes here to add support for the MediaTek INFRACFG controller. The |
@@ -12,7 +14,6 @@ config MTK_INFRACFG | |||
12 | 14 | ||
13 | config MTK_PMIC_WRAP | 15 | config MTK_PMIC_WRAP |
14 | tristate "MediaTek PMIC Wrapper Support" | 16 | tristate "MediaTek PMIC Wrapper Support" |
15 | depends on ARCH_MEDIATEK | ||
16 | depends on RESET_CONTROLLER | 17 | depends on RESET_CONTROLLER |
17 | select REGMAP | 18 | select REGMAP |
18 | help | 19 | help |
@@ -22,7 +23,6 @@ config MTK_PMIC_WRAP | |||
22 | 23 | ||
23 | config MTK_SCPSYS | 24 | config MTK_SCPSYS |
24 | bool "MediaTek SCPSYS Support" | 25 | bool "MediaTek SCPSYS Support" |
25 | depends on ARCH_MEDIATEK || COMPILE_TEST | ||
26 | default ARCH_MEDIATEK | 26 | default ARCH_MEDIATEK |
27 | select REGMAP | 27 | select REGMAP |
28 | select MTK_INFRACFG | 28 | select MTK_INFRACFG |
@@ -30,3 +30,5 @@ config MTK_SCPSYS | |||
30 | help | 30 | help |
31 | Say yes here to add support for the MediaTek SCPSYS power domain | 31 | Say yes here to add support for the MediaTek SCPSYS power domain |
32 | driver. | 32 | driver. |
33 | |||
34 | endmenu | ||
diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c index c2048382830f..e9e054a15b7d 100644 --- a/drivers/soc/mediatek/mtk-pmic-wrap.c +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c | |||
@@ -70,6 +70,12 @@ | |||
70 | PWRAP_WDT_SRC_EN_HARB_STAUPD_DLE | \ | 70 | PWRAP_WDT_SRC_EN_HARB_STAUPD_DLE | \ |
71 | PWRAP_WDT_SRC_EN_HARB_STAUPD_ALE) | 71 | PWRAP_WDT_SRC_EN_HARB_STAUPD_ALE) |
72 | 72 | ||
73 | /* Group of bits used for shown slave capability */ | ||
74 | #define PWRAP_SLV_CAP_SPI BIT(0) | ||
75 | #define PWRAP_SLV_CAP_DUALIO BIT(1) | ||
76 | #define PWRAP_SLV_CAP_SECURITY BIT(2) | ||
77 | #define HAS_CAP(_c, _x) (((_c) & (_x)) == (_x)) | ||
78 | |||
73 | /* defines for slave device wrapper registers */ | 79 | /* defines for slave device wrapper registers */ |
74 | enum dew_regs { | 80 | enum dew_regs { |
75 | PWRAP_DEW_BASE, | 81 | PWRAP_DEW_BASE, |
@@ -208,6 +214,36 @@ enum pwrap_regs { | |||
208 | PWRAP_ADC_RDATA_ADDR1, | 214 | PWRAP_ADC_RDATA_ADDR1, |
209 | PWRAP_ADC_RDATA_ADDR2, | 215 | PWRAP_ADC_RDATA_ADDR2, |
210 | 216 | ||
217 | /* MT7622 only regs */ | ||
218 | PWRAP_EINT_STA0_ADR, | ||
219 | PWRAP_EINT_STA1_ADR, | ||
220 | PWRAP_STA, | ||
221 | PWRAP_CLR, | ||
222 | PWRAP_DVFS_ADR8, | ||
223 | PWRAP_DVFS_WDATA8, | ||
224 | PWRAP_DVFS_ADR9, | ||
225 | PWRAP_DVFS_WDATA9, | ||
226 | PWRAP_DVFS_ADR10, | ||
227 | PWRAP_DVFS_WDATA10, | ||
228 | PWRAP_DVFS_ADR11, | ||
229 | PWRAP_DVFS_WDATA11, | ||
230 | PWRAP_DVFS_ADR12, | ||
231 | PWRAP_DVFS_WDATA12, | ||
232 | PWRAP_DVFS_ADR13, | ||
233 | PWRAP_DVFS_WDATA13, | ||
234 | PWRAP_DVFS_ADR14, | ||
235 | PWRAP_DVFS_WDATA14, | ||
236 | PWRAP_DVFS_ADR15, | ||
237 | PWRAP_DVFS_WDATA15, | ||
238 | PWRAP_EXT_CK, | ||
239 | PWRAP_ADC_RDATA_ADDR, | ||
240 | PWRAP_GPS_STA, | ||
241 | PWRAP_SW_RST, | ||
242 | PWRAP_DVFS_STEP_CTRL0, | ||
243 | PWRAP_DVFS_STEP_CTRL1, | ||
244 | PWRAP_DVFS_STEP_CTRL2, | ||
245 | PWRAP_SPI2_CTRL, | ||
246 | |||
211 | /* MT8135 only regs */ | 247 | /* MT8135 only regs */ |
212 | PWRAP_CSHEXT, | 248 | PWRAP_CSHEXT, |
213 | PWRAP_EVENT_IN_EN, | 249 | PWRAP_EVENT_IN_EN, |
@@ -330,6 +366,118 @@ static int mt2701_regs[] = { | |||
330 | [PWRAP_ADC_RDATA_ADDR2] = 0x154, | 366 | [PWRAP_ADC_RDATA_ADDR2] = 0x154, |
331 | }; | 367 | }; |
332 | 368 | ||
369 | static int mt7622_regs[] = { | ||
370 | [PWRAP_MUX_SEL] = 0x0, | ||
371 | [PWRAP_WRAP_EN] = 0x4, | ||
372 | [PWRAP_DIO_EN] = 0x8, | ||
373 | [PWRAP_SIDLY] = 0xC, | ||
374 | [PWRAP_RDDMY] = 0x10, | ||
375 | [PWRAP_SI_CK_CON] = 0x14, | ||
376 | [PWRAP_CSHEXT_WRITE] = 0x18, | ||
377 | [PWRAP_CSHEXT_READ] = 0x1C, | ||
378 | [PWRAP_CSLEXT_START] = 0x20, | ||
379 | [PWRAP_CSLEXT_END] = 0x24, | ||
380 | [PWRAP_STAUPD_PRD] = 0x28, | ||
381 | [PWRAP_STAUPD_GRPEN] = 0x2C, | ||
382 | [PWRAP_EINT_STA0_ADR] = 0x30, | ||
383 | [PWRAP_EINT_STA1_ADR] = 0x34, | ||
384 | [PWRAP_STA] = 0x38, | ||
385 | [PWRAP_CLR] = 0x3C, | ||
386 | [PWRAP_STAUPD_MAN_TRIG] = 0x40, | ||
387 | [PWRAP_STAUPD_STA] = 0x44, | ||
388 | [PWRAP_WRAP_STA] = 0x48, | ||
389 | [PWRAP_HARB_INIT] = 0x4C, | ||
390 | [PWRAP_HARB_HPRIO] = 0x50, | ||
391 | [PWRAP_HIPRIO_ARB_EN] = 0x54, | ||
392 | [PWRAP_HARB_STA0] = 0x58, | ||
393 | [PWRAP_HARB_STA1] = 0x5C, | ||
394 | [PWRAP_MAN_EN] = 0x60, | ||
395 | [PWRAP_MAN_CMD] = 0x64, | ||
396 | [PWRAP_MAN_RDATA] = 0x68, | ||
397 | [PWRAP_MAN_VLDCLR] = 0x6C, | ||
398 | [PWRAP_WACS0_EN] = 0x70, | ||
399 | [PWRAP_INIT_DONE0] = 0x74, | ||
400 | [PWRAP_WACS0_CMD] = 0x78, | ||
401 | [PWRAP_WACS0_RDATA] = 0x7C, | ||
402 | [PWRAP_WACS0_VLDCLR] = 0x80, | ||
403 | [PWRAP_WACS1_EN] = 0x84, | ||
404 | [PWRAP_INIT_DONE1] = 0x88, | ||
405 | [PWRAP_WACS1_CMD] = 0x8C, | ||
406 | [PWRAP_WACS1_RDATA] = 0x90, | ||
407 | [PWRAP_WACS1_VLDCLR] = 0x94, | ||
408 | [PWRAP_WACS2_EN] = 0x98, | ||
409 | [PWRAP_INIT_DONE2] = 0x9C, | ||
410 | [PWRAP_WACS2_CMD] = 0xA0, | ||
411 | [PWRAP_WACS2_RDATA] = 0xA4, | ||
412 | [PWRAP_WACS2_VLDCLR] = 0xA8, | ||
413 | [PWRAP_INT_EN] = 0xAC, | ||
414 | [PWRAP_INT_FLG_RAW] = 0xB0, | ||
415 | [PWRAP_INT_FLG] = 0xB4, | ||
416 | [PWRAP_INT_CLR] = 0xB8, | ||
417 | [PWRAP_SIG_ADR] = 0xBC, | ||
418 | [PWRAP_SIG_MODE] = 0xC0, | ||
419 | [PWRAP_SIG_VALUE] = 0xC4, | ||
420 | [PWRAP_SIG_ERRVAL] = 0xC8, | ||
421 | [PWRAP_CRC_EN] = 0xCC, | ||
422 | [PWRAP_TIMER_EN] = 0xD0, | ||
423 | [PWRAP_TIMER_STA] = 0xD4, | ||
424 | [PWRAP_WDT_UNIT] = 0xD8, | ||
425 | [PWRAP_WDT_SRC_EN] = 0xDC, | ||
426 | [PWRAP_WDT_FLG] = 0xE0, | ||
427 | [PWRAP_DEBUG_INT_SEL] = 0xE4, | ||
428 | [PWRAP_DVFS_ADR0] = 0xE8, | ||
429 | [PWRAP_DVFS_WDATA0] = 0xEC, | ||
430 | [PWRAP_DVFS_ADR1] = 0xF0, | ||
431 | [PWRAP_DVFS_WDATA1] = 0xF4, | ||
432 | [PWRAP_DVFS_ADR2] = 0xF8, | ||
433 | [PWRAP_DVFS_WDATA2] = 0xFC, | ||
434 | [PWRAP_DVFS_ADR3] = 0x100, | ||
435 | [PWRAP_DVFS_WDATA3] = 0x104, | ||
436 | [PWRAP_DVFS_ADR4] = 0x108, | ||
437 | [PWRAP_DVFS_WDATA4] = 0x10C, | ||
438 | [PWRAP_DVFS_ADR5] = 0x110, | ||
439 | [PWRAP_DVFS_WDATA5] = 0x114, | ||
440 | [PWRAP_DVFS_ADR6] = 0x118, | ||
441 | [PWRAP_DVFS_WDATA6] = 0x11C, | ||
442 | [PWRAP_DVFS_ADR7] = 0x120, | ||
443 | [PWRAP_DVFS_WDATA7] = 0x124, | ||
444 | [PWRAP_DVFS_ADR8] = 0x128, | ||
445 | [PWRAP_DVFS_WDATA8] = 0x12C, | ||
446 | [PWRAP_DVFS_ADR9] = 0x130, | ||
447 | [PWRAP_DVFS_WDATA9] = 0x134, | ||
448 | [PWRAP_DVFS_ADR10] = 0x138, | ||
449 | [PWRAP_DVFS_WDATA10] = 0x13C, | ||
450 | [PWRAP_DVFS_ADR11] = 0x140, | ||
451 | [PWRAP_DVFS_WDATA11] = 0x144, | ||
452 | [PWRAP_DVFS_ADR12] = 0x148, | ||
453 | [PWRAP_DVFS_WDATA12] = 0x14C, | ||
454 | [PWRAP_DVFS_ADR13] = 0x150, | ||
455 | [PWRAP_DVFS_WDATA13] = 0x154, | ||
456 | [PWRAP_DVFS_ADR14] = 0x158, | ||
457 | [PWRAP_DVFS_WDATA14] = 0x15C, | ||
458 | [PWRAP_DVFS_ADR15] = 0x160, | ||
459 | [PWRAP_DVFS_WDATA15] = 0x164, | ||
460 | [PWRAP_SPMINF_STA] = 0x168, | ||
461 | [PWRAP_CIPHER_KEY_SEL] = 0x16C, | ||
462 | [PWRAP_CIPHER_IV_SEL] = 0x170, | ||
463 | [PWRAP_CIPHER_EN] = 0x174, | ||
464 | [PWRAP_CIPHER_RDY] = 0x178, | ||
465 | [PWRAP_CIPHER_MODE] = 0x17C, | ||
466 | [PWRAP_CIPHER_SWRST] = 0x180, | ||
467 | [PWRAP_DCM_EN] = 0x184, | ||
468 | [PWRAP_DCM_DBC_PRD] = 0x188, | ||
469 | [PWRAP_EXT_CK] = 0x18C, | ||
470 | [PWRAP_ADC_CMD_ADDR] = 0x190, | ||
471 | [PWRAP_PWRAP_ADC_CMD] = 0x194, | ||
472 | [PWRAP_ADC_RDATA_ADDR] = 0x198, | ||
473 | [PWRAP_GPS_STA] = 0x19C, | ||
474 | [PWRAP_SW_RST] = 0x1A0, | ||
475 | [PWRAP_DVFS_STEP_CTRL0] = 0x238, | ||
476 | [PWRAP_DVFS_STEP_CTRL1] = 0x23C, | ||
477 | [PWRAP_DVFS_STEP_CTRL2] = 0x240, | ||
478 | [PWRAP_SPI2_CTRL] = 0x244, | ||
479 | }; | ||
480 | |||
333 | static int mt8173_regs[] = { | 481 | static int mt8173_regs[] = { |
334 | [PWRAP_MUX_SEL] = 0x0, | 482 | [PWRAP_MUX_SEL] = 0x0, |
335 | [PWRAP_WRAP_EN] = 0x4, | 483 | [PWRAP_WRAP_EN] = 0x4, |
@@ -487,18 +635,31 @@ static int mt8135_regs[] = { | |||
487 | 635 | ||
488 | enum pmic_type { | 636 | enum pmic_type { |
489 | PMIC_MT6323, | 637 | PMIC_MT6323, |
638 | PMIC_MT6380, | ||
490 | PMIC_MT6397, | 639 | PMIC_MT6397, |
491 | }; | 640 | }; |
492 | 641 | ||
493 | enum pwrap_type { | 642 | enum pwrap_type { |
494 | PWRAP_MT2701, | 643 | PWRAP_MT2701, |
644 | PWRAP_MT7622, | ||
495 | PWRAP_MT8135, | 645 | PWRAP_MT8135, |
496 | PWRAP_MT8173, | 646 | PWRAP_MT8173, |
497 | }; | 647 | }; |
498 | 648 | ||
649 | struct pmic_wrapper; | ||
499 | struct pwrap_slv_type { | 650 | struct pwrap_slv_type { |
500 | const u32 *dew_regs; | 651 | const u32 *dew_regs; |
501 | enum pmic_type type; | 652 | enum pmic_type type; |
653 | const struct regmap_config *regmap; | ||
654 | /* Flags indicating the capability for the target slave */ | ||
655 | u32 caps; | ||
656 | /* | ||
657 | * pwrap operations are highly associated with the PMIC types, | ||
658 | * so the pointers added increases flexibility allowing determination | ||
659 | * which type is used by the detection through device tree. | ||
660 | */ | ||
661 | int (*pwrap_read)(struct pmic_wrapper *wrp, u32 adr, u32 *rdata); | ||
662 | int (*pwrap_write)(struct pmic_wrapper *wrp, u32 adr, u32 wdata); | ||
502 | }; | 663 | }; |
503 | 664 | ||
504 | struct pmic_wrapper { | 665 | struct pmic_wrapper { |
@@ -522,7 +683,7 @@ struct pmic_wrapper_type { | |||
522 | u32 int_en_all; | 683 | u32 int_en_all; |
523 | u32 spi_w; | 684 | u32 spi_w; |
524 | u32 wdt_src; | 685 | u32 wdt_src; |
525 | int has_bridge:1; | 686 | unsigned int has_bridge:1; |
526 | int (*init_reg_clock)(struct pmic_wrapper *wrp); | 687 | int (*init_reg_clock)(struct pmic_wrapper *wrp); |
527 | int (*init_soc_specific)(struct pmic_wrapper *wrp); | 688 | int (*init_soc_specific)(struct pmic_wrapper *wrp); |
528 | }; | 689 | }; |
@@ -593,7 +754,7 @@ static int pwrap_wait_for_state(struct pmic_wrapper *wrp, | |||
593 | } while (1); | 754 | } while (1); |
594 | } | 755 | } |
595 | 756 | ||
596 | static int pwrap_write(struct pmic_wrapper *wrp, u32 adr, u32 wdata) | 757 | static int pwrap_read16(struct pmic_wrapper *wrp, u32 adr, u32 *rdata) |
597 | { | 758 | { |
598 | int ret; | 759 | int ret; |
599 | 760 | ||
@@ -603,14 +764,54 @@ static int pwrap_write(struct pmic_wrapper *wrp, u32 adr, u32 wdata) | |||
603 | return ret; | 764 | return ret; |
604 | } | 765 | } |
605 | 766 | ||
606 | pwrap_writel(wrp, (1 << 31) | ((adr >> 1) << 16) | wdata, | 767 | pwrap_writel(wrp, (adr >> 1) << 16, PWRAP_WACS2_CMD); |
607 | PWRAP_WACS2_CMD); | 768 | |
769 | ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_vldclr); | ||
770 | if (ret) | ||
771 | return ret; | ||
772 | |||
773 | *rdata = PWRAP_GET_WACS_RDATA(pwrap_readl(wrp, PWRAP_WACS2_RDATA)); | ||
774 | |||
775 | pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR); | ||
776 | |||
777 | return 0; | ||
778 | } | ||
779 | |||
780 | static int pwrap_read32(struct pmic_wrapper *wrp, u32 adr, u32 *rdata) | ||
781 | { | ||
782 | int ret, msb; | ||
783 | |||
784 | *rdata = 0; | ||
785 | for (msb = 0; msb < 2; msb++) { | ||
786 | ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle); | ||
787 | if (ret) { | ||
788 | pwrap_leave_fsm_vldclr(wrp); | ||
789 | return ret; | ||
790 | } | ||
791 | |||
792 | pwrap_writel(wrp, ((msb << 30) | (adr << 16)), | ||
793 | PWRAP_WACS2_CMD); | ||
794 | |||
795 | ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_vldclr); | ||
796 | if (ret) | ||
797 | return ret; | ||
798 | |||
799 | *rdata += (PWRAP_GET_WACS_RDATA(pwrap_readl(wrp, | ||
800 | PWRAP_WACS2_RDATA)) << (16 * msb)); | ||
801 | |||
802 | pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR); | ||
803 | } | ||
608 | 804 | ||
609 | return 0; | 805 | return 0; |
610 | } | 806 | } |
611 | 807 | ||
612 | static int pwrap_read(struct pmic_wrapper *wrp, u32 adr, u32 *rdata) | 808 | static int pwrap_read(struct pmic_wrapper *wrp, u32 adr, u32 *rdata) |
613 | { | 809 | { |
810 | return wrp->slave->pwrap_read(wrp, adr, rdata); | ||
811 | } | ||
812 | |||
813 | static int pwrap_write16(struct pmic_wrapper *wrp, u32 adr, u32 wdata) | ||
814 | { | ||
614 | int ret; | 815 | int ret; |
615 | 816 | ||
616 | ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle); | 817 | ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle); |
@@ -619,19 +820,46 @@ static int pwrap_read(struct pmic_wrapper *wrp, u32 adr, u32 *rdata) | |||
619 | return ret; | 820 | return ret; |
620 | } | 821 | } |
621 | 822 | ||
622 | pwrap_writel(wrp, (adr >> 1) << 16, PWRAP_WACS2_CMD); | 823 | pwrap_writel(wrp, (1 << 31) | ((adr >> 1) << 16) | wdata, |
824 | PWRAP_WACS2_CMD); | ||
623 | 825 | ||
624 | ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_vldclr); | 826 | return 0; |
625 | if (ret) | 827 | } |
626 | return ret; | ||
627 | 828 | ||
628 | *rdata = PWRAP_GET_WACS_RDATA(pwrap_readl(wrp, PWRAP_WACS2_RDATA)); | 829 | static int pwrap_write32(struct pmic_wrapper *wrp, u32 adr, u32 wdata) |
830 | { | ||
831 | int ret, msb, rdata; | ||
629 | 832 | ||
630 | pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR); | 833 | for (msb = 0; msb < 2; msb++) { |
834 | ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle); | ||
835 | if (ret) { | ||
836 | pwrap_leave_fsm_vldclr(wrp); | ||
837 | return ret; | ||
838 | } | ||
839 | |||
840 | pwrap_writel(wrp, (1 << 31) | (msb << 30) | (adr << 16) | | ||
841 | ((wdata >> (msb * 16)) & 0xffff), | ||
842 | PWRAP_WACS2_CMD); | ||
843 | |||
844 | /* | ||
845 | * The pwrap_read operation is the requirement of hardware used | ||
846 | * for the synchronization between two successive 16-bit | ||
847 | * pwrap_writel operations composing one 32-bit bus writing. | ||
848 | * Otherwise, we'll find the result fails on the lower 16-bit | ||
849 | * pwrap writing. | ||
850 | */ | ||
851 | if (!msb) | ||
852 | pwrap_read(wrp, adr, &rdata); | ||
853 | } | ||
631 | 854 | ||
632 | return 0; | 855 | return 0; |
633 | } | 856 | } |
634 | 857 | ||
858 | static int pwrap_write(struct pmic_wrapper *wrp, u32 adr, u32 wdata) | ||
859 | { | ||
860 | return wrp->slave->pwrap_write(wrp, adr, wdata); | ||
861 | } | ||
862 | |||
635 | static int pwrap_regmap_read(void *context, u32 adr, u32 *rdata) | 863 | static int pwrap_regmap_read(void *context, u32 adr, u32 *rdata) |
636 | { | 864 | { |
637 | return pwrap_read(context, adr, rdata); | 865 | return pwrap_read(context, adr, rdata); |
@@ -711,23 +939,75 @@ static int pwrap_init_sidly(struct pmic_wrapper *wrp) | |||
711 | return 0; | 939 | return 0; |
712 | } | 940 | } |
713 | 941 | ||
714 | static int pwrap_mt8135_init_reg_clock(struct pmic_wrapper *wrp) | 942 | static int pwrap_init_dual_io(struct pmic_wrapper *wrp) |
715 | { | 943 | { |
716 | pwrap_writel(wrp, 0x4, PWRAP_CSHEXT); | 944 | int ret; |
717 | pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_WRITE); | 945 | u32 rdata; |
718 | pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_READ); | 946 | |
719 | pwrap_writel(wrp, 0x0, PWRAP_CSLEXT_START); | 947 | /* Enable dual IO mode */ |
720 | pwrap_writel(wrp, 0x0, PWRAP_CSLEXT_END); | 948 | pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_DIO_EN], 1); |
949 | |||
950 | /* Check IDLE & INIT_DONE in advance */ | ||
951 | ret = pwrap_wait_for_state(wrp, | ||
952 | pwrap_is_fsm_idle_and_sync_idle); | ||
953 | if (ret) { | ||
954 | dev_err(wrp->dev, "%s fail, ret=%d\n", __func__, ret); | ||
955 | return ret; | ||
956 | } | ||
957 | |||
958 | pwrap_writel(wrp, 1, PWRAP_DIO_EN); | ||
959 | |||
960 | /* Read Test */ | ||
961 | pwrap_read(wrp, | ||
962 | wrp->slave->dew_regs[PWRAP_DEW_READ_TEST], &rdata); | ||
963 | if (rdata != PWRAP_DEW_READ_TEST_VAL) { | ||
964 | dev_err(wrp->dev, | ||
965 | "Read failed on DIO mode: 0x%04x!=0x%04x\n", | ||
966 | PWRAP_DEW_READ_TEST_VAL, rdata); | ||
967 | return -EFAULT; | ||
968 | } | ||
721 | 969 | ||
722 | return 0; | 970 | return 0; |
723 | } | 971 | } |
724 | 972 | ||
725 | static int pwrap_mt8173_init_reg_clock(struct pmic_wrapper *wrp) | 973 | /* |
974 | * pwrap_init_chip_select_ext is used to configure CS extension time for each | ||
975 | * phase during data transactions on the pwrap bus. | ||
976 | */ | ||
977 | static void pwrap_init_chip_select_ext(struct pmic_wrapper *wrp, u8 hext_write, | ||
978 | u8 hext_read, u8 lext_start, | ||
979 | u8 lext_end) | ||
726 | { | 980 | { |
727 | pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_WRITE); | 981 | /* |
728 | pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_READ); | 982 | * After finishing a write and read transaction, extends CS high time |
729 | pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_START); | 983 | * to be at least xT of BUS CLK as hext_write and hext_read specifies |
730 | pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_END); | 984 | * respectively. |
985 | */ | ||
986 | pwrap_writel(wrp, hext_write, PWRAP_CSHEXT_WRITE); | ||
987 | pwrap_writel(wrp, hext_read, PWRAP_CSHEXT_READ); | ||
988 | |||
989 | /* | ||
990 | * Extends CS low time after CSL and before CSH command to be at | ||
991 | * least xT of BUS CLK as lext_start and lext_end specifies | ||
992 | * respectively. | ||
993 | */ | ||
994 | pwrap_writel(wrp, lext_start, PWRAP_CSLEXT_START); | ||
995 | pwrap_writel(wrp, lext_end, PWRAP_CSLEXT_END); | ||
996 | } | ||
997 | |||
998 | static int pwrap_common_init_reg_clock(struct pmic_wrapper *wrp) | ||
999 | { | ||
1000 | switch (wrp->master->type) { | ||
1001 | case PWRAP_MT8173: | ||
1002 | pwrap_init_chip_select_ext(wrp, 0, 4, 2, 2); | ||
1003 | break; | ||
1004 | case PWRAP_MT8135: | ||
1005 | pwrap_writel(wrp, 0x4, PWRAP_CSHEXT); | ||
1006 | pwrap_init_chip_select_ext(wrp, 0, 4, 0, 0); | ||
1007 | break; | ||
1008 | default: | ||
1009 | break; | ||
1010 | } | ||
731 | 1011 | ||
732 | return 0; | 1012 | return 0; |
733 | } | 1013 | } |
@@ -737,20 +1017,16 @@ static int pwrap_mt2701_init_reg_clock(struct pmic_wrapper *wrp) | |||
737 | switch (wrp->slave->type) { | 1017 | switch (wrp->slave->type) { |
738 | case PMIC_MT6397: | 1018 | case PMIC_MT6397: |
739 | pwrap_writel(wrp, 0xc, PWRAP_RDDMY); | 1019 | pwrap_writel(wrp, 0xc, PWRAP_RDDMY); |
740 | pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_WRITE); | 1020 | pwrap_init_chip_select_ext(wrp, 4, 0, 2, 2); |
741 | pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_READ); | ||
742 | pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_START); | ||
743 | pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_END); | ||
744 | break; | 1021 | break; |
745 | 1022 | ||
746 | case PMIC_MT6323: | 1023 | case PMIC_MT6323: |
747 | pwrap_writel(wrp, 0x8, PWRAP_RDDMY); | 1024 | pwrap_writel(wrp, 0x8, PWRAP_RDDMY); |
748 | pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_RDDMY_NO], | 1025 | pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_RDDMY_NO], |
749 | 0x8); | 1026 | 0x8); |
750 | pwrap_writel(wrp, 0x5, PWRAP_CSHEXT_WRITE); | 1027 | pwrap_init_chip_select_ext(wrp, 5, 0, 2, 2); |
751 | pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_READ); | 1028 | break; |
752 | pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_START); | 1029 | default: |
753 | pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_END); | ||
754 | break; | 1030 | break; |
755 | } | 1031 | } |
756 | 1032 | ||
@@ -794,6 +1070,9 @@ static int pwrap_init_cipher(struct pmic_wrapper *wrp) | |||
794 | case PWRAP_MT8173: | 1070 | case PWRAP_MT8173: |
795 | pwrap_writel(wrp, 1, PWRAP_CIPHER_EN); | 1071 | pwrap_writel(wrp, 1, PWRAP_CIPHER_EN); |
796 | break; | 1072 | break; |
1073 | case PWRAP_MT7622: | ||
1074 | pwrap_writel(wrp, 0, PWRAP_CIPHER_EN); | ||
1075 | break; | ||
797 | } | 1076 | } |
798 | 1077 | ||
799 | /* Config cipher mode @PMIC */ | 1078 | /* Config cipher mode @PMIC */ |
@@ -815,6 +1094,8 @@ static int pwrap_init_cipher(struct pmic_wrapper *wrp) | |||
815 | pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_EN], | 1094 | pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_EN], |
816 | 0x1); | 1095 | 0x1); |
817 | break; | 1096 | break; |
1097 | default: | ||
1098 | break; | ||
818 | } | 1099 | } |
819 | 1100 | ||
820 | /* wait for cipher data ready@AP */ | 1101 | /* wait for cipher data ready@AP */ |
@@ -827,7 +1108,8 @@ static int pwrap_init_cipher(struct pmic_wrapper *wrp) | |||
827 | /* wait for cipher data ready@PMIC */ | 1108 | /* wait for cipher data ready@PMIC */ |
828 | ret = pwrap_wait_for_state(wrp, pwrap_is_pmic_cipher_ready); | 1109 | ret = pwrap_wait_for_state(wrp, pwrap_is_pmic_cipher_ready); |
829 | if (ret) { | 1110 | if (ret) { |
830 | dev_err(wrp->dev, "timeout waiting for cipher data ready@PMIC\n"); | 1111 | dev_err(wrp->dev, |
1112 | "timeout waiting for cipher data ready@PMIC\n"); | ||
831 | return ret; | 1113 | return ret; |
832 | } | 1114 | } |
833 | 1115 | ||
@@ -854,6 +1136,30 @@ static int pwrap_init_cipher(struct pmic_wrapper *wrp) | |||
854 | return 0; | 1136 | return 0; |
855 | } | 1137 | } |
856 | 1138 | ||
1139 | static int pwrap_init_security(struct pmic_wrapper *wrp) | ||
1140 | { | ||
1141 | int ret; | ||
1142 | |||
1143 | /* Enable encryption */ | ||
1144 | ret = pwrap_init_cipher(wrp); | ||
1145 | if (ret) | ||
1146 | return ret; | ||
1147 | |||
1148 | /* Signature checking - using CRC */ | ||
1149 | if (pwrap_write(wrp, | ||
1150 | wrp->slave->dew_regs[PWRAP_DEW_CRC_EN], 0x1)) | ||
1151 | return -EFAULT; | ||
1152 | |||
1153 | pwrap_writel(wrp, 0x1, PWRAP_CRC_EN); | ||
1154 | pwrap_writel(wrp, 0x0, PWRAP_SIG_MODE); | ||
1155 | pwrap_writel(wrp, wrp->slave->dew_regs[PWRAP_DEW_CRC_VAL], | ||
1156 | PWRAP_SIG_ADR); | ||
1157 | pwrap_writel(wrp, | ||
1158 | wrp->master->arb_en_all, PWRAP_HIPRIO_ARB_EN); | ||
1159 | |||
1160 | return 0; | ||
1161 | } | ||
1162 | |||
857 | static int pwrap_mt8135_init_soc_specific(struct pmic_wrapper *wrp) | 1163 | static int pwrap_mt8135_init_soc_specific(struct pmic_wrapper *wrp) |
858 | { | 1164 | { |
859 | /* enable pwrap events and pwrap bridge in AP side */ | 1165 | /* enable pwrap events and pwrap bridge in AP side */ |
@@ -911,10 +1217,18 @@ static int pwrap_mt2701_init_soc_specific(struct pmic_wrapper *wrp) | |||
911 | return 0; | 1217 | return 0; |
912 | } | 1218 | } |
913 | 1219 | ||
1220 | static int pwrap_mt7622_init_soc_specific(struct pmic_wrapper *wrp) | ||
1221 | { | ||
1222 | pwrap_writel(wrp, 0, PWRAP_STAUPD_PRD); | ||
1223 | /* enable 2wire SPI master */ | ||
1224 | pwrap_writel(wrp, 0x8000000, PWRAP_SPI2_CTRL); | ||
1225 | |||
1226 | return 0; | ||
1227 | } | ||
1228 | |||
914 | static int pwrap_init(struct pmic_wrapper *wrp) | 1229 | static int pwrap_init(struct pmic_wrapper *wrp) |
915 | { | 1230 | { |
916 | int ret; | 1231 | int ret; |
917 | u32 rdata; | ||
918 | 1232 | ||
919 | reset_control_reset(wrp->rstc); | 1233 | reset_control_reset(wrp->rstc); |
920 | if (wrp->rstc_bridge) | 1234 | if (wrp->rstc_bridge) |
@@ -926,10 +1240,12 @@ static int pwrap_init(struct pmic_wrapper *wrp) | |||
926 | pwrap_writel(wrp, 0, PWRAP_DCM_DBC_PRD); | 1240 | pwrap_writel(wrp, 0, PWRAP_DCM_DBC_PRD); |
927 | } | 1241 | } |
928 | 1242 | ||
929 | /* Reset SPI slave */ | 1243 | if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_SPI)) { |
930 | ret = pwrap_reset_spislave(wrp); | 1244 | /* Reset SPI slave */ |
931 | if (ret) | 1245 | ret = pwrap_reset_spislave(wrp); |
932 | return ret; | 1246 | if (ret) |
1247 | return ret; | ||
1248 | } | ||
933 | 1249 | ||
934 | pwrap_writel(wrp, 1, PWRAP_WRAP_EN); | 1250 | pwrap_writel(wrp, 1, PWRAP_WRAP_EN); |
935 | 1251 | ||
@@ -941,45 +1257,26 @@ static int pwrap_init(struct pmic_wrapper *wrp) | |||
941 | if (ret) | 1257 | if (ret) |
942 | return ret; | 1258 | return ret; |
943 | 1259 | ||
944 | /* Setup serial input delay */ | 1260 | if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_SPI)) { |
945 | ret = pwrap_init_sidly(wrp); | 1261 | /* Setup serial input delay */ |
946 | if (ret) | 1262 | ret = pwrap_init_sidly(wrp); |
947 | return ret; | 1263 | if (ret) |
948 | 1264 | return ret; | |
949 | /* Enable dual IO mode */ | ||
950 | pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_DIO_EN], 1); | ||
951 | |||
952 | /* Check IDLE & INIT_DONE in advance */ | ||
953 | ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle_and_sync_idle); | ||
954 | if (ret) { | ||
955 | dev_err(wrp->dev, "%s fail, ret=%d\n", __func__, ret); | ||
956 | return ret; | ||
957 | } | 1265 | } |
958 | 1266 | ||
959 | pwrap_writel(wrp, 1, PWRAP_DIO_EN); | 1267 | if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_DUALIO)) { |
960 | 1268 | /* Enable dual I/O mode */ | |
961 | /* Read Test */ | 1269 | ret = pwrap_init_dual_io(wrp); |
962 | pwrap_read(wrp, wrp->slave->dew_regs[PWRAP_DEW_READ_TEST], &rdata); | 1270 | if (ret) |
963 | if (rdata != PWRAP_DEW_READ_TEST_VAL) { | 1271 | return ret; |
964 | dev_err(wrp->dev, "Read test failed after switch to DIO mode: 0x%04x != 0x%04x\n", | ||
965 | PWRAP_DEW_READ_TEST_VAL, rdata); | ||
966 | return -EFAULT; | ||
967 | } | 1272 | } |
968 | 1273 | ||
969 | /* Enable encryption */ | 1274 | if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_SECURITY)) { |
970 | ret = pwrap_init_cipher(wrp); | 1275 | /* Enable security on bus */ |
971 | if (ret) | 1276 | ret = pwrap_init_security(wrp); |
972 | return ret; | 1277 | if (ret) |
973 | 1278 | return ret; | |
974 | /* Signature checking - using CRC */ | 1279 | } |
975 | if (pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CRC_EN], 0x1)) | ||
976 | return -EFAULT; | ||
977 | |||
978 | pwrap_writel(wrp, 0x1, PWRAP_CRC_EN); | ||
979 | pwrap_writel(wrp, 0x0, PWRAP_SIG_MODE); | ||
980 | pwrap_writel(wrp, wrp->slave->dew_regs[PWRAP_DEW_CRC_VAL], | ||
981 | PWRAP_SIG_ADR); | ||
982 | pwrap_writel(wrp, wrp->master->arb_en_all, PWRAP_HIPRIO_ARB_EN); | ||
983 | 1280 | ||
984 | if (wrp->master->type == PWRAP_MT8135) | 1281 | if (wrp->master->type == PWRAP_MT8135) |
985 | pwrap_writel(wrp, 0x7, PWRAP_RRARB_EN); | 1282 | pwrap_writel(wrp, 0x7, PWRAP_RRARB_EN); |
@@ -1023,7 +1320,7 @@ static irqreturn_t pwrap_interrupt(int irqno, void *dev_id) | |||
1023 | return IRQ_HANDLED; | 1320 | return IRQ_HANDLED; |
1024 | } | 1321 | } |
1025 | 1322 | ||
1026 | static const struct regmap_config pwrap_regmap_config = { | 1323 | static const struct regmap_config pwrap_regmap_config16 = { |
1027 | .reg_bits = 16, | 1324 | .reg_bits = 16, |
1028 | .val_bits = 16, | 1325 | .val_bits = 16, |
1029 | .reg_stride = 2, | 1326 | .reg_stride = 2, |
@@ -1032,14 +1329,42 @@ static const struct regmap_config pwrap_regmap_config = { | |||
1032 | .max_register = 0xffff, | 1329 | .max_register = 0xffff, |
1033 | }; | 1330 | }; |
1034 | 1331 | ||
1332 | static const struct regmap_config pwrap_regmap_config32 = { | ||
1333 | .reg_bits = 32, | ||
1334 | .val_bits = 32, | ||
1335 | .reg_stride = 4, | ||
1336 | .reg_read = pwrap_regmap_read, | ||
1337 | .reg_write = pwrap_regmap_write, | ||
1338 | .max_register = 0xffff, | ||
1339 | }; | ||
1340 | |||
1035 | static const struct pwrap_slv_type pmic_mt6323 = { | 1341 | static const struct pwrap_slv_type pmic_mt6323 = { |
1036 | .dew_regs = mt6323_regs, | 1342 | .dew_regs = mt6323_regs, |
1037 | .type = PMIC_MT6323, | 1343 | .type = PMIC_MT6323, |
1344 | .regmap = &pwrap_regmap_config16, | ||
1345 | .caps = PWRAP_SLV_CAP_SPI | PWRAP_SLV_CAP_DUALIO | | ||
1346 | PWRAP_SLV_CAP_SECURITY, | ||
1347 | .pwrap_read = pwrap_read16, | ||
1348 | .pwrap_write = pwrap_write16, | ||
1349 | }; | ||
1350 | |||
1351 | static const struct pwrap_slv_type pmic_mt6380 = { | ||
1352 | .dew_regs = NULL, | ||
1353 | .type = PMIC_MT6380, | ||
1354 | .regmap = &pwrap_regmap_config32, | ||
1355 | .caps = 0, | ||
1356 | .pwrap_read = pwrap_read32, | ||
1357 | .pwrap_write = pwrap_write32, | ||
1038 | }; | 1358 | }; |
1039 | 1359 | ||
1040 | static const struct pwrap_slv_type pmic_mt6397 = { | 1360 | static const struct pwrap_slv_type pmic_mt6397 = { |
1041 | .dew_regs = mt6397_regs, | 1361 | .dew_regs = mt6397_regs, |
1042 | .type = PMIC_MT6397, | 1362 | .type = PMIC_MT6397, |
1363 | .regmap = &pwrap_regmap_config16, | ||
1364 | .caps = PWRAP_SLV_CAP_SPI | PWRAP_SLV_CAP_DUALIO | | ||
1365 | PWRAP_SLV_CAP_SECURITY, | ||
1366 | .pwrap_read = pwrap_read16, | ||
1367 | .pwrap_write = pwrap_write16, | ||
1043 | }; | 1368 | }; |
1044 | 1369 | ||
1045 | static const struct of_device_id of_slave_match_tbl[] = { | 1370 | static const struct of_device_id of_slave_match_tbl[] = { |
@@ -1047,6 +1372,12 @@ static const struct of_device_id of_slave_match_tbl[] = { | |||
1047 | .compatible = "mediatek,mt6323", | 1372 | .compatible = "mediatek,mt6323", |
1048 | .data = &pmic_mt6323, | 1373 | .data = &pmic_mt6323, |
1049 | }, { | 1374 | }, { |
1375 | /* The MT6380 PMIC only implements a regulator, so we bind it | ||
1376 | * directly instead of using a MFD. | ||
1377 | */ | ||
1378 | .compatible = "mediatek,mt6380-regulator", | ||
1379 | .data = &pmic_mt6380, | ||
1380 | }, { | ||
1050 | .compatible = "mediatek,mt6397", | 1381 | .compatible = "mediatek,mt6397", |
1051 | .data = &pmic_mt6397, | 1382 | .data = &pmic_mt6397, |
1052 | }, { | 1383 | }, { |
@@ -1067,6 +1398,18 @@ static const struct pmic_wrapper_type pwrap_mt2701 = { | |||
1067 | .init_soc_specific = pwrap_mt2701_init_soc_specific, | 1398 | .init_soc_specific = pwrap_mt2701_init_soc_specific, |
1068 | }; | 1399 | }; |
1069 | 1400 | ||
1401 | static const struct pmic_wrapper_type pwrap_mt7622 = { | ||
1402 | .regs = mt7622_regs, | ||
1403 | .type = PWRAP_MT7622, | ||
1404 | .arb_en_all = 0xff, | ||
1405 | .int_en_all = ~(u32)BIT(31), | ||
1406 | .spi_w = PWRAP_MAN_CMD_SPI_WRITE, | ||
1407 | .wdt_src = PWRAP_WDT_SRC_MASK_ALL, | ||
1408 | .has_bridge = 0, | ||
1409 | .init_reg_clock = pwrap_common_init_reg_clock, | ||
1410 | .init_soc_specific = pwrap_mt7622_init_soc_specific, | ||
1411 | }; | ||
1412 | |||
1070 | static const struct pmic_wrapper_type pwrap_mt8135 = { | 1413 | static const struct pmic_wrapper_type pwrap_mt8135 = { |
1071 | .regs = mt8135_regs, | 1414 | .regs = mt8135_regs, |
1072 | .type = PWRAP_MT8135, | 1415 | .type = PWRAP_MT8135, |
@@ -1075,7 +1418,7 @@ static const struct pmic_wrapper_type pwrap_mt8135 = { | |||
1075 | .spi_w = PWRAP_MAN_CMD_SPI_WRITE, | 1418 | .spi_w = PWRAP_MAN_CMD_SPI_WRITE, |
1076 | .wdt_src = PWRAP_WDT_SRC_MASK_ALL, | 1419 | .wdt_src = PWRAP_WDT_SRC_MASK_ALL, |
1077 | .has_bridge = 1, | 1420 | .has_bridge = 1, |
1078 | .init_reg_clock = pwrap_mt8135_init_reg_clock, | 1421 | .init_reg_clock = pwrap_common_init_reg_clock, |
1079 | .init_soc_specific = pwrap_mt8135_init_soc_specific, | 1422 | .init_soc_specific = pwrap_mt8135_init_soc_specific, |
1080 | }; | 1423 | }; |
1081 | 1424 | ||
@@ -1087,7 +1430,7 @@ static const struct pmic_wrapper_type pwrap_mt8173 = { | |||
1087 | .spi_w = PWRAP_MAN_CMD_SPI_WRITE, | 1430 | .spi_w = PWRAP_MAN_CMD_SPI_WRITE, |
1088 | .wdt_src = PWRAP_WDT_SRC_MASK_NO_STAUPD, | 1431 | .wdt_src = PWRAP_WDT_SRC_MASK_NO_STAUPD, |
1089 | .has_bridge = 0, | 1432 | .has_bridge = 0, |
1090 | .init_reg_clock = pwrap_mt8173_init_reg_clock, | 1433 | .init_reg_clock = pwrap_common_init_reg_clock, |
1091 | .init_soc_specific = pwrap_mt8173_init_soc_specific, | 1434 | .init_soc_specific = pwrap_mt8173_init_soc_specific, |
1092 | }; | 1435 | }; |
1093 | 1436 | ||
@@ -1096,6 +1439,9 @@ static const struct of_device_id of_pwrap_match_tbl[] = { | |||
1096 | .compatible = "mediatek,mt2701-pwrap", | 1439 | .compatible = "mediatek,mt2701-pwrap", |
1097 | .data = &pwrap_mt2701, | 1440 | .data = &pwrap_mt2701, |
1098 | }, { | 1441 | }, { |
1442 | .compatible = "mediatek,mt7622-pwrap", | ||
1443 | .data = &pwrap_mt7622, | ||
1444 | }, { | ||
1099 | .compatible = "mediatek,mt8135-pwrap", | 1445 | .compatible = "mediatek,mt8135-pwrap", |
1100 | .data = &pwrap_mt8135, | 1446 | .data = &pwrap_mt8135, |
1101 | }, { | 1447 | }, { |
@@ -1159,23 +1505,27 @@ static int pwrap_probe(struct platform_device *pdev) | |||
1159 | if (IS_ERR(wrp->bridge_base)) | 1505 | if (IS_ERR(wrp->bridge_base)) |
1160 | return PTR_ERR(wrp->bridge_base); | 1506 | return PTR_ERR(wrp->bridge_base); |
1161 | 1507 | ||
1162 | wrp->rstc_bridge = devm_reset_control_get(wrp->dev, "pwrap-bridge"); | 1508 | wrp->rstc_bridge = devm_reset_control_get(wrp->dev, |
1509 | "pwrap-bridge"); | ||
1163 | if (IS_ERR(wrp->rstc_bridge)) { | 1510 | if (IS_ERR(wrp->rstc_bridge)) { |
1164 | ret = PTR_ERR(wrp->rstc_bridge); | 1511 | ret = PTR_ERR(wrp->rstc_bridge); |
1165 | dev_dbg(wrp->dev, "cannot get pwrap-bridge reset: %d\n", ret); | 1512 | dev_dbg(wrp->dev, |
1513 | "cannot get pwrap-bridge reset: %d\n", ret); | ||
1166 | return ret; | 1514 | return ret; |
1167 | } | 1515 | } |
1168 | } | 1516 | } |
1169 | 1517 | ||
1170 | wrp->clk_spi = devm_clk_get(wrp->dev, "spi"); | 1518 | wrp->clk_spi = devm_clk_get(wrp->dev, "spi"); |
1171 | if (IS_ERR(wrp->clk_spi)) { | 1519 | if (IS_ERR(wrp->clk_spi)) { |
1172 | dev_dbg(wrp->dev, "failed to get clock: %ld\n", PTR_ERR(wrp->clk_spi)); | 1520 | dev_dbg(wrp->dev, "failed to get clock: %ld\n", |
1521 | PTR_ERR(wrp->clk_spi)); | ||
1173 | return PTR_ERR(wrp->clk_spi); | 1522 | return PTR_ERR(wrp->clk_spi); |
1174 | } | 1523 | } |
1175 | 1524 | ||
1176 | wrp->clk_wrap = devm_clk_get(wrp->dev, "wrap"); | 1525 | wrp->clk_wrap = devm_clk_get(wrp->dev, "wrap"); |
1177 | if (IS_ERR(wrp->clk_wrap)) { | 1526 | if (IS_ERR(wrp->clk_wrap)) { |
1178 | dev_dbg(wrp->dev, "failed to get clock: %ld\n", PTR_ERR(wrp->clk_wrap)); | 1527 | dev_dbg(wrp->dev, "failed to get clock: %ld\n", |
1528 | PTR_ERR(wrp->clk_wrap)); | ||
1179 | return PTR_ERR(wrp->clk_wrap); | 1529 | return PTR_ERR(wrp->clk_wrap); |
1180 | } | 1530 | } |
1181 | 1531 | ||
@@ -1220,12 +1570,13 @@ static int pwrap_probe(struct platform_device *pdev) | |||
1220 | pwrap_writel(wrp, wrp->master->int_en_all, PWRAP_INT_EN); | 1570 | pwrap_writel(wrp, wrp->master->int_en_all, PWRAP_INT_EN); |
1221 | 1571 | ||
1222 | irq = platform_get_irq(pdev, 0); | 1572 | irq = platform_get_irq(pdev, 0); |
1223 | ret = devm_request_irq(wrp->dev, irq, pwrap_interrupt, IRQF_TRIGGER_HIGH, | 1573 | ret = devm_request_irq(wrp->dev, irq, pwrap_interrupt, |
1224 | "mt-pmic-pwrap", wrp); | 1574 | IRQF_TRIGGER_HIGH, |
1575 | "mt-pmic-pwrap", wrp); | ||
1225 | if (ret) | 1576 | if (ret) |
1226 | goto err_out2; | 1577 | goto err_out2; |
1227 | 1578 | ||
1228 | wrp->regmap = devm_regmap_init(wrp->dev, NULL, wrp, &pwrap_regmap_config); | 1579 | wrp->regmap = devm_regmap_init(wrp->dev, NULL, wrp, wrp->slave->regmap); |
1229 | if (IS_ERR(wrp->regmap)) { | 1580 | if (IS_ERR(wrp->regmap)) { |
1230 | ret = PTR_ERR(wrp->regmap); | 1581 | ret = PTR_ERR(wrp->regmap); |
1231 | goto err_out2; | 1582 | goto err_out2; |