diff options
Diffstat (limited to 'arch/arm/mach-davinci/psc.c')
-rw-r--r-- | arch/arm/mach-davinci/psc.c | 98 |
1 files changed, 30 insertions, 68 deletions
diff --git a/arch/arm/mach-davinci/psc.c b/arch/arm/mach-davinci/psc.c index 58754f066d5b..84171abf5f7b 100644 --- a/arch/arm/mach-davinci/psc.c +++ b/arch/arm/mach-davinci/psc.c | |||
@@ -23,10 +23,13 @@ | |||
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/io.h> | 24 | #include <linux/io.h> |
25 | 25 | ||
26 | #include <mach/cputype.h> | ||
26 | #include <mach/hardware.h> | 27 | #include <mach/hardware.h> |
27 | #include <mach/psc.h> | 28 | #include <mach/psc.h> |
28 | #include <mach/mux.h> | 29 | #include <mach/mux.h> |
29 | 30 | ||
31 | #define DAVINCI_PWR_SLEEP_CNTRL_BASE 0x01C41000 | ||
32 | |||
30 | /* PSC register offsets */ | 33 | /* PSC register offsets */ |
31 | #define EPCPR 0x070 | 34 | #define EPCPR 0x070 |
32 | #define PTCMD 0x120 | 35 | #define PTCMD 0x120 |
@@ -36,102 +39,61 @@ | |||
36 | #define MDSTAT 0x800 | 39 | #define MDSTAT 0x800 |
37 | #define MDCTL 0xA00 | 40 | #define MDCTL 0xA00 |
38 | 41 | ||
39 | /* System control register offsets */ | 42 | #define MDSTAT_STATE_MASK 0x1f |
40 | #define VDD3P3V_PWDN 0x48 | ||
41 | 43 | ||
42 | static void davinci_psc_mux(unsigned int id) | 44 | /* Return nonzero iff the domain's clock is active */ |
45 | int __init davinci_psc_is_clk_active(unsigned int id) | ||
43 | { | 46 | { |
44 | switch (id) { | 47 | void __iomem *psc_base = IO_ADDRESS(DAVINCI_PWR_SLEEP_CNTRL_BASE); |
45 | case DAVINCI_LPSC_ATA: | 48 | u32 mdstat = __raw_readl(psc_base + MDSTAT + 4 * id); |
46 | davinci_mux_peripheral(DAVINCI_MUX_HDIREN, 1); | 49 | |
47 | davinci_mux_peripheral(DAVINCI_MUX_ATAEN, 1); | 50 | /* if clocked, state can be "Enable" or "SyncReset" */ |
48 | break; | 51 | return mdstat & BIT(12); |
49 | case DAVINCI_LPSC_MMC_SD: | ||
50 | /* VDD power manupulations are done in U-Boot for CPMAC | ||
51 | * so applies to MMC as well | ||
52 | */ | ||
53 | /*Set up the pull regiter for MMC */ | ||
54 | davinci_writel(0, DAVINCI_SYSTEM_MODULE_BASE + VDD3P3V_PWDN); | ||
55 | davinci_mux_peripheral(DAVINCI_MUX_MSTK, 0); | ||
56 | break; | ||
57 | case DAVINCI_LPSC_I2C: | ||
58 | davinci_mux_peripheral(DAVINCI_MUX_I2C, 1); | ||
59 | break; | ||
60 | case DAVINCI_LPSC_McBSP: | ||
61 | davinci_mux_peripheral(DAVINCI_MUX_ASP, 1); | ||
62 | break; | ||
63 | default: | ||
64 | break; | ||
65 | } | ||
66 | } | 52 | } |
67 | 53 | ||
68 | /* Enable or disable a PSC domain */ | 54 | /* Enable or disable a PSC domain */ |
69 | void davinci_psc_config(unsigned int domain, unsigned int id, char enable) | 55 | void davinci_psc_config(unsigned int domain, unsigned int id, char enable) |
70 | { | 56 | { |
71 | u32 epcpr, ptcmd, ptstat, pdstat, pdctl1, mdstat, mdctl, mdstat_mask; | 57 | u32 epcpr, ptcmd, ptstat, pdstat, pdctl1, mdstat, mdctl; |
58 | void __iomem *psc_base = IO_ADDRESS(DAVINCI_PWR_SLEEP_CNTRL_BASE); | ||
59 | u32 next_state = enable ? 0x3 : 0x2; /* 0x3 enables, 0x2 disables */ | ||
72 | 60 | ||
73 | mdctl = davinci_readl(DAVINCI_PWR_SLEEP_CNTRL_BASE + MDCTL + 4 * id); | 61 | mdctl = __raw_readl(psc_base + MDCTL + 4 * id); |
74 | if (enable) | 62 | mdctl &= ~MDSTAT_STATE_MASK; |
75 | mdctl |= 0x00000003; /* Enable Module */ | 63 | mdctl |= next_state; |
76 | else | 64 | __raw_writel(mdctl, psc_base + MDCTL + 4 * id); |
77 | mdctl &= 0xFFFFFFF2; /* Disable Module */ | ||
78 | davinci_writel(mdctl, DAVINCI_PWR_SLEEP_CNTRL_BASE + MDCTL + 4 * id); | ||
79 | 65 | ||
80 | pdstat = davinci_readl(DAVINCI_PWR_SLEEP_CNTRL_BASE + PDSTAT); | 66 | pdstat = __raw_readl(psc_base + PDSTAT); |
81 | if ((pdstat & 0x00000001) == 0) { | 67 | if ((pdstat & 0x00000001) == 0) { |
82 | pdctl1 = davinci_readl(DAVINCI_PWR_SLEEP_CNTRL_BASE + PDCTL1); | 68 | pdctl1 = __raw_readl(psc_base + PDCTL1); |
83 | pdctl1 |= 0x1; | 69 | pdctl1 |= 0x1; |
84 | davinci_writel(pdctl1, DAVINCI_PWR_SLEEP_CNTRL_BASE + PDCTL1); | 70 | __raw_writel(pdctl1, psc_base + PDCTL1); |
85 | 71 | ||
86 | ptcmd = 1 << domain; | 72 | ptcmd = 1 << domain; |
87 | davinci_writel(ptcmd, DAVINCI_PWR_SLEEP_CNTRL_BASE + PTCMD); | 73 | __raw_writel(ptcmd, psc_base + PTCMD); |
88 | 74 | ||
89 | do { | 75 | do { |
90 | epcpr = davinci_readl(DAVINCI_PWR_SLEEP_CNTRL_BASE + | 76 | epcpr = __raw_readl(psc_base + EPCPR); |
91 | EPCPR); | ||
92 | } while ((((epcpr >> domain) & 1) == 0)); | 77 | } while ((((epcpr >> domain) & 1) == 0)); |
93 | 78 | ||
94 | pdctl1 = davinci_readl(DAVINCI_PWR_SLEEP_CNTRL_BASE + PDCTL1); | 79 | pdctl1 = __raw_readl(psc_base + PDCTL1); |
95 | pdctl1 |= 0x100; | 80 | pdctl1 |= 0x100; |
96 | davinci_writel(pdctl1, DAVINCI_PWR_SLEEP_CNTRL_BASE + PDCTL1); | 81 | __raw_writel(pdctl1, psc_base + PDCTL1); |
97 | 82 | ||
98 | do { | 83 | do { |
99 | ptstat = davinci_readl(DAVINCI_PWR_SLEEP_CNTRL_BASE + | 84 | ptstat = __raw_readl(psc_base + |
100 | PTSTAT); | 85 | PTSTAT); |
101 | } while (!(((ptstat >> domain) & 1) == 0)); | 86 | } while (!(((ptstat >> domain) & 1) == 0)); |
102 | } else { | 87 | } else { |
103 | ptcmd = 1 << domain; | 88 | ptcmd = 1 << domain; |
104 | davinci_writel(ptcmd, DAVINCI_PWR_SLEEP_CNTRL_BASE + PTCMD); | 89 | __raw_writel(ptcmd, psc_base + PTCMD); |
105 | 90 | ||
106 | do { | 91 | do { |
107 | ptstat = davinci_readl(DAVINCI_PWR_SLEEP_CNTRL_BASE + | 92 | ptstat = __raw_readl(psc_base + PTSTAT); |
108 | PTSTAT); | ||
109 | } while (!(((ptstat >> domain) & 1) == 0)); | 93 | } while (!(((ptstat >> domain) & 1) == 0)); |
110 | } | 94 | } |
111 | 95 | ||
112 | if (enable) | ||
113 | mdstat_mask = 0x3; | ||
114 | else | ||
115 | mdstat_mask = 0x2; | ||
116 | |||
117 | do { | 96 | do { |
118 | mdstat = davinci_readl(DAVINCI_PWR_SLEEP_CNTRL_BASE + | 97 | mdstat = __raw_readl(psc_base + MDSTAT + 4 * id); |
119 | MDSTAT + 4 * id); | 98 | } while (!((mdstat & MDSTAT_STATE_MASK) == next_state)); |
120 | } while (!((mdstat & 0x0000001F) == mdstat_mask)); | ||
121 | |||
122 | if (enable) | ||
123 | davinci_psc_mux(id); | ||
124 | } | ||
125 | |||
126 | void __init davinci_psc_init(void) | ||
127 | { | ||
128 | davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_VPSSMSTR, 1); | ||
129 | davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_VPSSSLV, 1); | ||
130 | davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_TPCC, 1); | ||
131 | davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_TPTC0, 1); | ||
132 | davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_TPTC1, 1); | ||
133 | davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_GPIO, 1); | ||
134 | |||
135 | /* Turn on WatchDog timer LPSC. Needed for RESET to work */ | ||
136 | davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_TIMER2, 1); | ||
137 | } | 99 | } |