aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-06-08 16:21:58 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-06-08 16:21:58 -0400
commit40b985fbe9bca5b06d34c30af4b89c2fdbe72d49 (patch)
treed8aa6fd6156e5ef9b07d1fb6ce7758db11c2c1fa
parent181e505952c5e4b4beb287d0022ea3cd20f23e74 (diff)
parent0a68c6bc7ce9d4855f3130f9eff8ff774b597531 (diff)
Merge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull ARM SoC fixes from Kevin Hilman: "About 10 days worth of small bug fixes, and the (hopefully) final round fixes for from arm-soc land for the -rc cycle. Nothing special to note, but here's a brief summary of fixes by SoC type: - OMAP: small set of misc DT fixes; boot fix for THUMB2 kernel - mediatek: PMIC fixes; DT fix for model name - exynos: wakeup interupt fixes for 3250 - mvebu: revert mbus patch which broke DMA masters * tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: ARM: dts: am335x-boneblack: disable RTC-only sleep to avoid hardware damage ARM: dts: AM35xx: fix system control module clocks arm64: dts: mt8173-evb: fix model name ARM: exynos: Fix wake-up interrupts for Exynos3250 ARM: dts: Fix n900 dts file to work around 4.1 touchscreen regression on n900 ARM: dts: Fix dm816x to use right compatible flag for MUSB ARM: OMAP3: Fix booting with thumb2 kernel Revert "bus: mvebu-mbus: make sure SDRAM CS for DMA don't overlap the MBus bridge window" bus: mvebu-mbus: do not set WIN_CTRL_SYNCBARRIER on non io-coherent platforms. ARM: mvebu: armada-xp-linksys-mamba: Disable internal RTC soc: mediatek: Add compile dependency to pmic-wrapper soc: mediatek: PMIC wrap: Fix register state machine handling soc: mediatek: PMIC wrap: Fix clock rate handling
-rw-r--r--Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt4
-rw-r--r--arch/arm/boot/dts/am335x-bone-common.dtsi19
-rw-r--r--arch/arm/boot/dts/am35xx-clocks.dtsi14
-rw-r--r--arch/arm/boot/dts/armada-xp-linksys-mamba.dts5
-rw-r--r--arch/arm/boot/dts/dm816x.dtsi4
-rw-r--r--arch/arm/boot/dts/omap3-n900.dts4
-rw-r--r--arch/arm/mach-exynos/suspend.c4
-rw-r--r--arch/arm/mach-omap2/sleep34xx.S22
-rw-r--r--arch/arm64/boot/dts/mediatek/mt8173-evb.dts3
-rw-r--r--drivers/bus/mvebu-mbus.c109
-rw-r--r--drivers/soc/mediatek/Kconfig1
-rw-r--r--drivers/soc/mediatek/mtk-pmic-wrap.c54
12 files changed, 72 insertions, 171 deletions
diff --git a/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt b/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
index 4b641c7bf1c2..09089a6d69ed 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/tsc2005.txt
@@ -32,8 +32,8 @@ Example:
32 touchscreen-fuzz-x = <4>; 32 touchscreen-fuzz-x = <4>;
33 touchscreen-fuzz-y = <7>; 33 touchscreen-fuzz-y = <7>;
34 touchscreen-fuzz-pressure = <2>; 34 touchscreen-fuzz-pressure = <2>;
35 touchscreen-max-x = <4096>; 35 touchscreen-size-x = <4096>;
36 touchscreen-max-y = <4096>; 36 touchscreen-size-y = <4096>;
37 touchscreen-max-pressure = <2048>; 37 touchscreen-max-pressure = <2048>;
38 38
39 ti,x-plate-ohms = <280>; 39 ti,x-plate-ohms = <280>;
diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi
index c3255e0c90aa..dbb3f4d2bf84 100644
--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
@@ -223,6 +223,25 @@
223/include/ "tps65217.dtsi" 223/include/ "tps65217.dtsi"
224 224
225&tps { 225&tps {
226 /*
227 * Configure pmic to enter OFF-state instead of SLEEP-state ("RTC-only
228 * mode") at poweroff. Most BeagleBone versions do not support RTC-only
229 * mode and risk hardware damage if this mode is entered.
230 *
231 * For details, see linux-omap mailing list May 2015 thread
232 * [PATCH] ARM: dts: am335x-bone* enable pmic-shutdown-controller
233 * In particular, messages:
234 * http://www.spinics.net/lists/linux-omap/msg118585.html
235 * http://www.spinics.net/lists/linux-omap/msg118615.html
236 *
237 * You can override this later with
238 * &tps { /delete-property/ ti,pmic-shutdown-controller; }
239 * if you want to use RTC-only mode and made sure you are not affected
240 * by the hardware problems. (Tip: double-check by performing a current
241 * measurement after shutdown: it should be less than 1 mA.)
242 */
243 ti,pmic-shutdown-controller;
244
226 regulators { 245 regulators {
227 dcdc1_reg: regulator@0 { 246 dcdc1_reg: regulator@0 {
228 regulator-name = "vdds_dpr"; 247 regulator-name = "vdds_dpr";
diff --git a/arch/arm/boot/dts/am35xx-clocks.dtsi b/arch/arm/boot/dts/am35xx-clocks.dtsi
index 518b8fde88b0..18cc826e9db5 100644
--- a/arch/arm/boot/dts/am35xx-clocks.dtsi
+++ b/arch/arm/boot/dts/am35xx-clocks.dtsi
@@ -12,7 +12,7 @@
12 #clock-cells = <0>; 12 #clock-cells = <0>;
13 compatible = "ti,am35xx-gate-clock"; 13 compatible = "ti,am35xx-gate-clock";
14 clocks = <&ipss_ick>; 14 clocks = <&ipss_ick>;
15 reg = <0x059c>; 15 reg = <0x032c>;
16 ti,bit-shift = <1>; 16 ti,bit-shift = <1>;
17 }; 17 };
18 18
@@ -20,7 +20,7 @@
20 #clock-cells = <0>; 20 #clock-cells = <0>;
21 compatible = "ti,gate-clock"; 21 compatible = "ti,gate-clock";
22 clocks = <&rmii_ck>; 22 clocks = <&rmii_ck>;
23 reg = <0x059c>; 23 reg = <0x032c>;
24 ti,bit-shift = <9>; 24 ti,bit-shift = <9>;
25 }; 25 };
26 26
@@ -28,7 +28,7 @@
28 #clock-cells = <0>; 28 #clock-cells = <0>;
29 compatible = "ti,am35xx-gate-clock"; 29 compatible = "ti,am35xx-gate-clock";
30 clocks = <&ipss_ick>; 30 clocks = <&ipss_ick>;
31 reg = <0x059c>; 31 reg = <0x032c>;
32 ti,bit-shift = <2>; 32 ti,bit-shift = <2>;
33 }; 33 };
34 34
@@ -36,7 +36,7 @@
36 #clock-cells = <0>; 36 #clock-cells = <0>;
37 compatible = "ti,gate-clock"; 37 compatible = "ti,gate-clock";
38 clocks = <&pclk_ck>; 38 clocks = <&pclk_ck>;
39 reg = <0x059c>; 39 reg = <0x032c>;
40 ti,bit-shift = <10>; 40 ti,bit-shift = <10>;
41 }; 41 };
42 42
@@ -44,7 +44,7 @@
44 #clock-cells = <0>; 44 #clock-cells = <0>;
45 compatible = "ti,am35xx-gate-clock"; 45 compatible = "ti,am35xx-gate-clock";
46 clocks = <&ipss_ick>; 46 clocks = <&ipss_ick>;
47 reg = <0x059c>; 47 reg = <0x032c>;
48 ti,bit-shift = <0>; 48 ti,bit-shift = <0>;
49 }; 49 };
50 50
@@ -52,7 +52,7 @@
52 #clock-cells = <0>; 52 #clock-cells = <0>;
53 compatible = "ti,gate-clock"; 53 compatible = "ti,gate-clock";
54 clocks = <&sys_ck>; 54 clocks = <&sys_ck>;
55 reg = <0x059c>; 55 reg = <0x032c>;
56 ti,bit-shift = <8>; 56 ti,bit-shift = <8>;
57 }; 57 };
58 58
@@ -60,7 +60,7 @@
60 #clock-cells = <0>; 60 #clock-cells = <0>;
61 compatible = "ti,am35xx-gate-clock"; 61 compatible = "ti,am35xx-gate-clock";
62 clocks = <&sys_ck>; 62 clocks = <&sys_ck>;
63 reg = <0x059c>; 63 reg = <0x032c>;
64 ti,bit-shift = <3>; 64 ti,bit-shift = <3>;
65 }; 65 };
66}; 66};
diff --git a/arch/arm/boot/dts/armada-xp-linksys-mamba.dts b/arch/arm/boot/dts/armada-xp-linksys-mamba.dts
index a2cf2154dcdb..fdd187c55aa5 100644
--- a/arch/arm/boot/dts/armada-xp-linksys-mamba.dts
+++ b/arch/arm/boot/dts/armada-xp-linksys-mamba.dts
@@ -95,6 +95,11 @@
95 95
96 internal-regs { 96 internal-regs {
97 97
98 rtc@10300 {
99 /* No crystal connected to the internal RTC */
100 status = "disabled";
101 };
102
98 /* J10: VCC, NC, RX, NC, TX, GND */ 103 /* J10: VCC, NC, RX, NC, TX, GND */
99 serial@12000 { 104 serial@12000 {
100 status = "okay"; 105 status = "okay";
diff --git a/arch/arm/boot/dts/dm816x.dtsi b/arch/arm/boot/dts/dm816x.dtsi
index de8427be830a..289806adb343 100644
--- a/arch/arm/boot/dts/dm816x.dtsi
+++ b/arch/arm/boot/dts/dm816x.dtsi
@@ -382,7 +382,7 @@
382 ti,hwmods = "usb_otg_hs"; 382 ti,hwmods = "usb_otg_hs";
383 383
384 usb0: usb@47401000 { 384 usb0: usb@47401000 {
385 compatible = "ti,musb-am33xx"; 385 compatible = "ti,musb-dm816";
386 reg = <0x47401400 0x400 386 reg = <0x47401400 0x400
387 0x47401000 0x200>; 387 0x47401000 0x200>;
388 reg-names = "mc", "control"; 388 reg-names = "mc", "control";
@@ -422,7 +422,7 @@
422 }; 422 };
423 423
424 usb1: usb@47401800 { 424 usb1: usb@47401800 {
425 compatible = "ti,musb-am33xx"; 425 compatible = "ti,musb-dm816";
426 reg = <0x47401c00 0x400 426 reg = <0x47401c00 0x400
427 0x47401800 0x200>; 427 0x47401800 0x200>;
428 reg-names = "mc", "control"; 428 reg-names = "mc", "control";
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index 5c16145920ea..5f5e0f3d5b64 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -832,8 +832,8 @@
832 touchscreen-fuzz-x = <4>; 832 touchscreen-fuzz-x = <4>;
833 touchscreen-fuzz-y = <7>; 833 touchscreen-fuzz-y = <7>;
834 touchscreen-fuzz-pressure = <2>; 834 touchscreen-fuzz-pressure = <2>;
835 touchscreen-max-x = <4096>; 835 touchscreen-size-x = <4096>;
836 touchscreen-max-y = <4096>; 836 touchscreen-size-y = <4096>;
837 touchscreen-max-pressure = <2048>; 837 touchscreen-max-pressure = <2048>;
838 838
839 ti,x-plate-ohms = <280>; 839 ti,x-plate-ohms = <280>;
diff --git a/arch/arm/mach-exynos/suspend.c b/arch/arm/mach-exynos/suspend.c
index c0b6dccbf7bd..7d23ce04cad5 100644
--- a/arch/arm/mach-exynos/suspend.c
+++ b/arch/arm/mach-exynos/suspend.c
@@ -87,8 +87,8 @@ static unsigned int exynos_pmu_spare3;
87static u32 exynos_irqwake_intmask = 0xffffffff; 87static u32 exynos_irqwake_intmask = 0xffffffff;
88 88
89static const struct exynos_wkup_irq exynos3250_wkup_irq[] = { 89static const struct exynos_wkup_irq exynos3250_wkup_irq[] = {
90 { 105, BIT(1) }, /* RTC alarm */ 90 { 73, BIT(1) }, /* RTC alarm */
91 { 106, BIT(2) }, /* RTC tick */ 91 { 74, BIT(2) }, /* RTC tick */
92 { /* sentinel */ }, 92 { /* sentinel */ },
93}; 93};
94 94
diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S
index d1dedc8195ed..eafd120b53f1 100644
--- a/arch/arm/mach-omap2/sleep34xx.S
+++ b/arch/arm/mach-omap2/sleep34xx.S
@@ -203,23 +203,8 @@ save_context_wfi:
203 */ 203 */
204 ldr r1, kernel_flush 204 ldr r1, kernel_flush
205 blx r1 205 blx r1
206 /*
207 * The kernel doesn't interwork: v7_flush_dcache_all in particluar will
208 * always return in Thumb state when CONFIG_THUMB2_KERNEL is enabled.
209 * This sequence switches back to ARM. Note that .align may insert a
210 * nop: bx pc needs to be word-aligned in order to work.
211 */
212 THUMB( .thumb )
213 THUMB( .align )
214 THUMB( bx pc )
215 THUMB( nop )
216 .arm
217
218 b omap3_do_wfi 206 b omap3_do_wfi
219 207ENDPROC(omap34xx_cpu_suspend)
220/*
221 * Local variables
222 */
223omap3_do_wfi_sram_addr: 208omap3_do_wfi_sram_addr:
224 .word omap3_do_wfi_sram 209 .word omap3_do_wfi_sram
225kernel_flush: 210kernel_flush:
@@ -364,10 +349,7 @@ exit_nonoff_modes:
364 * =================================== 349 * ===================================
365 */ 350 */
366 ldmfd sp!, {r4 - r11, pc} @ restore regs and return 351 ldmfd sp!, {r4 - r11, pc} @ restore regs and return
367 352ENDPROC(omap3_do_wfi)
368/*
369 * Local variables
370 */
371sdrc_power: 353sdrc_power:
372 .word SDRC_POWER_V 354 .word SDRC_POWER_V
373cm_idlest1_core: 355cm_idlest1_core:
diff --git a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
index 43d54017b779..d0ab012fa379 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
@@ -16,7 +16,8 @@
16#include "mt8173.dtsi" 16#include "mt8173.dtsi"
17 17
18/ { 18/ {
19 model = "mediatek,mt8173-evb"; 19 model = "MediaTek MT8173 evaluation board";
20 compatible = "mediatek,mt8173-evb", "mediatek,mt8173";
20 21
21 aliases { 22 aliases {
22 serial0 = &uart0; 23 serial0 = &uart0;
diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c
index fb9ec6221730..6f047dcb94c2 100644
--- a/drivers/bus/mvebu-mbus.c
+++ b/drivers/bus/mvebu-mbus.c
@@ -58,7 +58,6 @@
58#include <linux/debugfs.h> 58#include <linux/debugfs.h>
59#include <linux/log2.h> 59#include <linux/log2.h>
60#include <linux/syscore_ops.h> 60#include <linux/syscore_ops.h>
61#include <linux/memblock.h>
62 61
63/* 62/*
64 * DDR target is the same on all platforms. 63 * DDR target is the same on all platforms.
@@ -70,6 +69,7 @@
70 */ 69 */
71#define WIN_CTRL_OFF 0x0000 70#define WIN_CTRL_OFF 0x0000
72#define WIN_CTRL_ENABLE BIT(0) 71#define WIN_CTRL_ENABLE BIT(0)
72/* Only on HW I/O coherency capable platforms */
73#define WIN_CTRL_SYNCBARRIER BIT(1) 73#define WIN_CTRL_SYNCBARRIER BIT(1)
74#define WIN_CTRL_TGT_MASK 0xf0 74#define WIN_CTRL_TGT_MASK 0xf0
75#define WIN_CTRL_TGT_SHIFT 4 75#define WIN_CTRL_TGT_SHIFT 4
@@ -102,9 +102,7 @@
102 102
103/* Relative to mbusbridge_base */ 103/* Relative to mbusbridge_base */
104#define MBUS_BRIDGE_CTRL_OFF 0x0 104#define MBUS_BRIDGE_CTRL_OFF 0x0
105#define MBUS_BRIDGE_SIZE_MASK 0xffff0000
106#define MBUS_BRIDGE_BASE_OFF 0x4 105#define MBUS_BRIDGE_BASE_OFF 0x4
107#define MBUS_BRIDGE_BASE_MASK 0xffff0000
108 106
109/* Maximum number of windows, for all known platforms */ 107/* Maximum number of windows, for all known platforms */
110#define MBUS_WINS_MAX 20 108#define MBUS_WINS_MAX 20
@@ -323,8 +321,9 @@ static int mvebu_mbus_setup_window(struct mvebu_mbus_state *mbus,
323 ctrl = ((size - 1) & WIN_CTRL_SIZE_MASK) | 321 ctrl = ((size - 1) & WIN_CTRL_SIZE_MASK) |
324 (attr << WIN_CTRL_ATTR_SHIFT) | 322 (attr << WIN_CTRL_ATTR_SHIFT) |
325 (target << WIN_CTRL_TGT_SHIFT) | 323 (target << WIN_CTRL_TGT_SHIFT) |
326 WIN_CTRL_SYNCBARRIER |
327 WIN_CTRL_ENABLE; 324 WIN_CTRL_ENABLE;
325 if (mbus->hw_io_coherency)
326 ctrl |= WIN_CTRL_SYNCBARRIER;
328 327
329 writel(base & WIN_BASE_LOW, addr + WIN_BASE_OFF); 328 writel(base & WIN_BASE_LOW, addr + WIN_BASE_OFF);
330 writel(ctrl, addr + WIN_CTRL_OFF); 329 writel(ctrl, addr + WIN_CTRL_OFF);
@@ -577,106 +576,36 @@ static unsigned int armada_xp_mbus_win_remap_offset(int win)
577 return MVEBU_MBUS_NO_REMAP; 576 return MVEBU_MBUS_NO_REMAP;
578} 577}
579 578
580/*
581 * Use the memblock information to find the MBus bridge hole in the
582 * physical address space.
583 */
584static void __init
585mvebu_mbus_find_bridge_hole(uint64_t *start, uint64_t *end)
586{
587 struct memblock_region *r;
588 uint64_t s = 0;
589
590 for_each_memblock(memory, r) {
591 /*
592 * This part of the memory is above 4 GB, so we don't
593 * care for the MBus bridge hole.
594 */
595 if (r->base >= 0x100000000)
596 continue;
597
598 /*
599 * The MBus bridge hole is at the end of the RAM under
600 * the 4 GB limit.
601 */
602 if (r->base + r->size > s)
603 s = r->base + r->size;
604 }
605
606 *start = s;
607 *end = 0x100000000;
608}
609
610static void __init 579static void __init
611mvebu_mbus_default_setup_cpu_target(struct mvebu_mbus_state *mbus) 580mvebu_mbus_default_setup_cpu_target(struct mvebu_mbus_state *mbus)
612{ 581{
613 int i; 582 int i;
614 int cs; 583 int cs;
615 uint64_t mbus_bridge_base, mbus_bridge_end;
616 584
617 mvebu_mbus_dram_info.mbus_dram_target_id = TARGET_DDR; 585 mvebu_mbus_dram_info.mbus_dram_target_id = TARGET_DDR;
618 586
619 mvebu_mbus_find_bridge_hole(&mbus_bridge_base, &mbus_bridge_end);
620
621 for (i = 0, cs = 0; i < 4; i++) { 587 for (i = 0, cs = 0; i < 4; i++) {
622 u64 base = readl(mbus->sdramwins_base + DDR_BASE_CS_OFF(i)); 588 u32 base = readl(mbus->sdramwins_base + DDR_BASE_CS_OFF(i));
623 u64 size = readl(mbus->sdramwins_base + DDR_SIZE_CS_OFF(i)); 589 u32 size = readl(mbus->sdramwins_base + DDR_SIZE_CS_OFF(i));
624 u64 end;
625 struct mbus_dram_window *w;
626
627 /* Ignore entries that are not enabled */
628 if (!(size & DDR_SIZE_ENABLED))
629 continue;
630
631 /*
632 * Ignore entries whose base address is above 2^32,
633 * since devices cannot DMA to such high addresses
634 */
635 if (base & DDR_BASE_CS_HIGH_MASK)
636 continue;
637
638 base = base & DDR_BASE_CS_LOW_MASK;
639 size = (size | ~DDR_SIZE_MASK) + 1;
640 end = base + size;
641
642 /*
643 * Adjust base/size of the current CS to make sure it
644 * doesn't overlap with the MBus bridge hole. This is
645 * particularly important for devices that do DMA from
646 * DRAM to a SRAM mapped in a MBus window, such as the
647 * CESA cryptographic engine.
648 */
649 590
650 /* 591 /*
651 * The CS is fully enclosed inside the MBus bridge 592 * We only take care of entries for which the chip
652 * area, so ignore it. 593 * select is enabled, and that don't have high base
594 * address bits set (devices can only access the first
595 * 32 bits of the memory).
653 */ 596 */
654 if (base >= mbus_bridge_base && end <= mbus_bridge_end) 597 if ((size & DDR_SIZE_ENABLED) &&
655 continue; 598 !(base & DDR_BASE_CS_HIGH_MASK)) {
599 struct mbus_dram_window *w;
656 600
657 /* 601 w = &mvebu_mbus_dram_info.cs[cs++];
658 * Beginning of CS overlaps with end of MBus, raise CS 602 w->cs_index = i;
659 * base address, and shrink its size. 603 w->mbus_attr = 0xf & ~(1 << i);
660 */ 604 if (mbus->hw_io_coherency)
661 if (base >= mbus_bridge_base && end > mbus_bridge_end) { 605 w->mbus_attr |= ATTR_HW_COHERENCY;
662 size -= mbus_bridge_end - base; 606 w->base = base & DDR_BASE_CS_LOW_MASK;
663 base = mbus_bridge_end; 607 w->size = (size | ~DDR_SIZE_MASK) + 1;
664 } 608 }
665
666 /*
667 * End of CS overlaps with beginning of MBus, shrink
668 * CS size.
669 */
670 if (base < mbus_bridge_base && end > mbus_bridge_base)
671 size -= end - mbus_bridge_base;
672
673 w = &mvebu_mbus_dram_info.cs[cs++];
674 w->cs_index = i;
675 w->mbus_attr = 0xf & ~(1 << i);
676 if (mbus->hw_io_coherency)
677 w->mbus_attr |= ATTR_HW_COHERENCY;
678 w->base = base;
679 w->size = size;
680 } 609 }
681 mvebu_mbus_dram_info.num_cs = cs; 610 mvebu_mbus_dram_info.num_cs = cs;
682} 611}
diff --git a/drivers/soc/mediatek/Kconfig b/drivers/soc/mediatek/Kconfig
index bcdb22d5e215..3c1850332a90 100644
--- a/drivers/soc/mediatek/Kconfig
+++ b/drivers/soc/mediatek/Kconfig
@@ -4,6 +4,7 @@
4config MTK_PMIC_WRAP 4config MTK_PMIC_WRAP
5 tristate "MediaTek PMIC Wrapper Support" 5 tristate "MediaTek PMIC Wrapper Support"
6 depends on ARCH_MEDIATEK 6 depends on ARCH_MEDIATEK
7 depends on RESET_CONTROLLER
7 select REGMAP 8 select REGMAP
8 help 9 help
9 Say yes here to add support for MediaTek PMIC Wrapper found 10 Say yes here to add support for MediaTek PMIC Wrapper found
diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
index db5be1eec54c..f432291feee9 100644
--- a/drivers/soc/mediatek/mtk-pmic-wrap.c
+++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
@@ -443,11 +443,6 @@ static int pwrap_wait_for_state(struct pmic_wrapper *wrp,
443static int pwrap_write(struct pmic_wrapper *wrp, u32 adr, u32 wdata) 443static int pwrap_write(struct pmic_wrapper *wrp, u32 adr, u32 wdata)
444{ 444{
445 int ret; 445 int ret;
446 u32 val;
447
448 val = pwrap_readl(wrp, PWRAP_WACS2_RDATA);
449 if (PWRAP_GET_WACS_FSM(val) == PWRAP_WACS_FSM_WFVLDCLR)
450 pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR);
451 446
452 ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle); 447 ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle);
453 if (ret) 448 if (ret)
@@ -462,11 +457,6 @@ static int pwrap_write(struct pmic_wrapper *wrp, u32 adr, u32 wdata)
462static int pwrap_read(struct pmic_wrapper *wrp, u32 adr, u32 *rdata) 457static int pwrap_read(struct pmic_wrapper *wrp, u32 adr, u32 *rdata)
463{ 458{
464 int ret; 459 int ret;
465 u32 val;
466
467 val = pwrap_readl(wrp, PWRAP_WACS2_RDATA);
468 if (PWRAP_GET_WACS_FSM(val) == PWRAP_WACS_FSM_WFVLDCLR)
469 pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR);
470 460
471 ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle); 461 ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle);
472 if (ret) 462 if (ret)
@@ -480,6 +470,8 @@ static int pwrap_read(struct pmic_wrapper *wrp, u32 adr, u32 *rdata)
480 470
481 *rdata = PWRAP_GET_WACS_RDATA(pwrap_readl(wrp, PWRAP_WACS2_RDATA)); 471 *rdata = PWRAP_GET_WACS_RDATA(pwrap_readl(wrp, PWRAP_WACS2_RDATA));
482 472
473 pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR);
474
483 return 0; 475 return 0;
484} 476}
485 477
@@ -563,45 +555,17 @@ static int pwrap_init_sidly(struct pmic_wrapper *wrp)
563 555
564static int pwrap_init_reg_clock(struct pmic_wrapper *wrp) 556static int pwrap_init_reg_clock(struct pmic_wrapper *wrp)
565{ 557{
566 unsigned long rate_spi; 558 if (pwrap_is_mt8135(wrp)) {
567 int ck_mhz; 559 pwrap_writel(wrp, 0x4, PWRAP_CSHEXT);
568
569 rate_spi = clk_get_rate(wrp->clk_spi);
570
571 if (rate_spi > 26000000)
572 ck_mhz = 26;
573 else if (rate_spi > 18000000)
574 ck_mhz = 18;
575 else
576 ck_mhz = 0;
577
578 switch (ck_mhz) {
579 case 18:
580 if (pwrap_is_mt8135(wrp))
581 pwrap_writel(wrp, 0xc, PWRAP_CSHEXT);
582 pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_WRITE);
583 pwrap_writel(wrp, 0xc, PWRAP_CSHEXT_READ);
584 pwrap_writel(wrp, 0x0, PWRAP_CSLEXT_START);
585 pwrap_writel(wrp, 0x0, PWRAP_CSLEXT_END);
586 break;
587 case 26:
588 if (pwrap_is_mt8135(wrp))
589 pwrap_writel(wrp, 0x4, PWRAP_CSHEXT);
590 pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_WRITE); 560 pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_WRITE);
591 pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_READ); 561 pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_READ);
592 pwrap_writel(wrp, 0x0, PWRAP_CSLEXT_START); 562 pwrap_writel(wrp, 0x0, PWRAP_CSLEXT_START);
593 pwrap_writel(wrp, 0x0, PWRAP_CSLEXT_END); 563 pwrap_writel(wrp, 0x0, PWRAP_CSLEXT_END);
594 break; 564 } else {
595 case 0: 565 pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_WRITE);
596 if (pwrap_is_mt8135(wrp)) 566 pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_READ);
597 pwrap_writel(wrp, 0xf, PWRAP_CSHEXT); 567 pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_START);
598 pwrap_writel(wrp, 0xf, PWRAP_CSHEXT_WRITE); 568 pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_END);
599 pwrap_writel(wrp, 0xf, PWRAP_CSHEXT_READ);
600 pwrap_writel(wrp, 0xf, PWRAP_CSLEXT_START);
601 pwrap_writel(wrp, 0xf, PWRAP_CSLEXT_END);
602 break;
603 default:
604 return -EINVAL;
605 } 569 }
606 570
607 return 0; 571 return 0;