diff options
Diffstat (limited to 'arch')
228 files changed, 7321 insertions, 16808 deletions
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index 56a4df952fb0..22e58a99f38b 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig | |||
@@ -477,7 +477,7 @@ config ALPHA_BROKEN_IRQ_MASK | |||
477 | 477 | ||
478 | config VGA_HOSE | 478 | config VGA_HOSE |
479 | bool | 479 | bool |
480 | depends on ALPHA_GENERIC || ALPHA_TITAN || ALPHA_MARVEL || ALPHA_TSUNAMI | 480 | depends on VGA_CONSOLE && (ALPHA_GENERIC || ALPHA_TITAN || ALPHA_MARVEL || ALPHA_TSUNAMI) |
481 | default y | 481 | default y |
482 | help | 482 | help |
483 | Support VGA on an arbitrary hose; needed for several platforms | 483 | Support VGA on an arbitrary hose; needed for several platforms |
diff --git a/arch/alpha/include/asm/rtc.h b/arch/alpha/include/asm/rtc.h index 1f7fba671ae6..d70408d36677 100644 --- a/arch/alpha/include/asm/rtc.h +++ b/arch/alpha/include/asm/rtc.h | |||
@@ -1,14 +1,10 @@ | |||
1 | #ifndef _ALPHA_RTC_H | 1 | #ifndef _ALPHA_RTC_H |
2 | #define _ALPHA_RTC_H | 2 | #define _ALPHA_RTC_H |
3 | 3 | ||
4 | #if defined(CONFIG_ALPHA_GENERIC) | 4 | #if defined(CONFIG_ALPHA_MARVEL) && defined(CONFIG_SMP) \ |
5 | || defined(CONFIG_ALPHA_GENERIC) | ||
5 | # define get_rtc_time alpha_mv.rtc_get_time | 6 | # define get_rtc_time alpha_mv.rtc_get_time |
6 | # define set_rtc_time alpha_mv.rtc_set_time | 7 | # define set_rtc_time alpha_mv.rtc_set_time |
7 | #else | ||
8 | # if defined(CONFIG_ALPHA_MARVEL) && defined(CONFIG_SMP) | ||
9 | # define get_rtc_time marvel_get_rtc_time | ||
10 | # define set_rtc_time marvel_set_rtc_time | ||
11 | # endif | ||
12 | #endif | 8 | #endif |
13 | 9 | ||
14 | #include <asm-generic/rtc.h> | 10 | #include <asm-generic/rtc.h> |
diff --git a/arch/alpha/kernel/core_tsunami.c b/arch/alpha/kernel/core_tsunami.c index 5e7c28f92f19..61893d7bdda5 100644 --- a/arch/alpha/kernel/core_tsunami.c +++ b/arch/alpha/kernel/core_tsunami.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <asm/core_tsunami.h> | 11 | #include <asm/core_tsunami.h> |
12 | #undef __EXTERN_INLINE | 12 | #undef __EXTERN_INLINE |
13 | 13 | ||
14 | #include <linux/module.h> | ||
14 | #include <linux/types.h> | 15 | #include <linux/types.h> |
15 | #include <linux/pci.h> | 16 | #include <linux/pci.h> |
16 | #include <linux/sched.h> | 17 | #include <linux/sched.h> |
diff --git a/arch/alpha/kernel/sys_marvel.c b/arch/alpha/kernel/sys_marvel.c index 14a4b6a7cf59..407accc80877 100644 --- a/arch/alpha/kernel/sys_marvel.c +++ b/arch/alpha/kernel/sys_marvel.c | |||
@@ -317,7 +317,7 @@ marvel_init_irq(void) | |||
317 | } | 317 | } |
318 | 318 | ||
319 | static int | 319 | static int |
320 | marvel_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | 320 | marvel_map_irq(struct pci_dev *dev, u8 slot, u8 pin) |
321 | { | 321 | { |
322 | struct pci_controller *hose = dev->sysdata; | 322 | struct pci_controller *hose = dev->sysdata; |
323 | struct io7_port *io7_port = hose->sysdata; | 323 | struct io7_port *io7_port = hose->sysdata; |
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 9be624af131f..0a166b52600d 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -468,7 +468,9 @@ config ARCH_MXS | |||
468 | select ARCH_REQUIRE_GPIOLIB | 468 | select ARCH_REQUIRE_GPIOLIB |
469 | select CLKDEV_LOOKUP | 469 | select CLKDEV_LOOKUP |
470 | select CLKSRC_MMIO | 470 | select CLKSRC_MMIO |
471 | select COMMON_CLK | ||
471 | select HAVE_CLK_PREPARE | 472 | select HAVE_CLK_PREPARE |
473 | select PINCTRL | ||
472 | help | 474 | help |
473 | Support for Freescale MXS-based family of processors | 475 | Support for Freescale MXS-based family of processors |
474 | 476 | ||
@@ -980,6 +982,7 @@ config PLAT_SPEAR | |||
980 | select ARM_AMBA | 982 | select ARM_AMBA |
981 | select ARCH_REQUIRE_GPIOLIB | 983 | select ARCH_REQUIRE_GPIOLIB |
982 | select CLKDEV_LOOKUP | 984 | select CLKDEV_LOOKUP |
985 | select COMMON_CLK | ||
983 | select CLKSRC_MMIO | 986 | select CLKSRC_MMIO |
984 | select GENERIC_CLOCKEVENTS | 987 | select GENERIC_CLOCKEVENTS |
985 | select HAVE_CLK | 988 | select HAVE_CLK |
@@ -1187,6 +1190,15 @@ if !MMU | |||
1187 | source "arch/arm/Kconfig-nommu" | 1190 | source "arch/arm/Kconfig-nommu" |
1188 | endif | 1191 | endif |
1189 | 1192 | ||
1193 | config ARM_ERRATA_326103 | ||
1194 | bool "ARM errata: FSR write bit incorrect on a SWP to read-only memory" | ||
1195 | depends on CPU_V6 | ||
1196 | help | ||
1197 | Executing a SWP instruction to read-only memory does not set bit 11 | ||
1198 | of the FSR on the ARM 1136 prior to r1p0. This causes the kernel to | ||
1199 | treat the access as a read, preventing a COW from occurring and | ||
1200 | causing the faulting task to livelock. | ||
1201 | |||
1190 | config ARM_ERRATA_411920 | 1202 | config ARM_ERRATA_411920 |
1191 | bool "ARM errata: Invalidation of the Instruction Cache operation can fail" | 1203 | bool "ARM errata: Invalidation of the Instruction Cache operation can fail" |
1192 | depends on CPU_V6 || CPU_V6K | 1204 | depends on CPU_V6 || CPU_V6K |
diff --git a/arch/arm/boot/dts/msm8660-surf.dts b/arch/arm/boot/dts/msm8660-surf.dts index 15ded0deaa79..45bc4bb04e57 100644 --- a/arch/arm/boot/dts/msm8660-surf.dts +++ b/arch/arm/boot/dts/msm8660-surf.dts | |||
@@ -10,7 +10,7 @@ | |||
10 | intc: interrupt-controller@02080000 { | 10 | intc: interrupt-controller@02080000 { |
11 | compatible = "qcom,msm-8660-qgic"; | 11 | compatible = "qcom,msm-8660-qgic"; |
12 | interrupt-controller; | 12 | interrupt-controller; |
13 | #interrupt-cells = <1>; | 13 | #interrupt-cells = <3>; |
14 | reg = < 0x02080000 0x1000 >, | 14 | reg = < 0x02080000 0x1000 >, |
15 | < 0x02081000 0x1000 >; | 15 | < 0x02081000 0x1000 >; |
16 | }; | 16 | }; |
@@ -19,6 +19,6 @@ | |||
19 | compatible = "qcom,msm-hsuart", "qcom,msm-uart"; | 19 | compatible = "qcom,msm-hsuart", "qcom,msm-uart"; |
20 | reg = <0x19c40000 0x1000>, | 20 | reg = <0x19c40000 0x1000>, |
21 | <0x19c00000 0x1000>; | 21 | <0x19c00000 0x1000>; |
22 | interrupts = <195>; | 22 | interrupts = <0 195 0x0>; |
23 | }; | 23 | }; |
24 | }; | 24 | }; |
diff --git a/arch/arm/boot/dts/spear300-evb.dts b/arch/arm/boot/dts/spear300-evb.dts new file mode 100644 index 000000000000..fc82b1a26458 --- /dev/null +++ b/arch/arm/boot/dts/spear300-evb.dts | |||
@@ -0,0 +1,246 @@ | |||
1 | /* | ||
2 | * DTS file for SPEAr300 Evaluation Baord | ||
3 | * | ||
4 | * Copyright 2012 Viresh Kumar <viresh.kumar@st.com> | ||
5 | * | ||
6 | * The code contained herein is licensed under the GNU General Public | ||
7 | * License. You may obtain a copy of the GNU General Public License | ||
8 | * Version 2 or later at the following locations: | ||
9 | * | ||
10 | * http://www.opensource.org/licenses/gpl-license.html | ||
11 | * http://www.gnu.org/copyleft/gpl.html | ||
12 | */ | ||
13 | |||
14 | /dts-v1/; | ||
15 | /include/ "spear300.dtsi" | ||
16 | |||
17 | / { | ||
18 | model = "ST SPEAr300 Evaluation Board"; | ||
19 | compatible = "st,spear300-evb", "st,spear300"; | ||
20 | #address-cells = <1>; | ||
21 | #size-cells = <1>; | ||
22 | |||
23 | memory { | ||
24 | reg = <0 0x40000000>; | ||
25 | }; | ||
26 | |||
27 | ahb { | ||
28 | pinmux@99000000 { | ||
29 | st,pinmux-mode = <2>; | ||
30 | pinctrl-names = "default"; | ||
31 | pinctrl-0 = <&state_default>; | ||
32 | |||
33 | state_default: pinmux { | ||
34 | i2c0 { | ||
35 | st,pins = "i2c0_grp"; | ||
36 | st,function = "i2c0"; | ||
37 | }; | ||
38 | ssp0 { | ||
39 | st,pins = "ssp0_grp"; | ||
40 | st,function = "ssp0"; | ||
41 | }; | ||
42 | mii0 { | ||
43 | st,pins = "mii0_grp"; | ||
44 | st,function = "mii0"; | ||
45 | }; | ||
46 | uart0 { | ||
47 | st,pins = "uart0_grp"; | ||
48 | st,function = "uart0"; | ||
49 | }; | ||
50 | clcd { | ||
51 | st,pins = "clcd_pfmode_grp"; | ||
52 | st,function = "clcd"; | ||
53 | }; | ||
54 | sdhci { | ||
55 | st,pins = "sdhci_4bit_grp"; | ||
56 | st,function = "sdhci"; | ||
57 | }; | ||
58 | gpio1 { | ||
59 | st,pins = "gpio1_4_to_7_grp", | ||
60 | "gpio1_0_to_3_grp"; | ||
61 | st,function = "gpio1"; | ||
62 | }; | ||
63 | }; | ||
64 | }; | ||
65 | |||
66 | clcd@60000000 { | ||
67 | status = "okay"; | ||
68 | }; | ||
69 | |||
70 | dma@fc400000 { | ||
71 | status = "okay"; | ||
72 | }; | ||
73 | |||
74 | fsmc: flash@94000000 { | ||
75 | status = "okay"; | ||
76 | }; | ||
77 | |||
78 | gmac: eth@e0800000 { | ||
79 | status = "okay"; | ||
80 | }; | ||
81 | |||
82 | sdhci@70000000 { | ||
83 | int-gpio = <&gpio1 0 0>; | ||
84 | power-gpio = <&gpio1 2 1>; | ||
85 | status = "okay"; | ||
86 | }; | ||
87 | |||
88 | smi: flash@fc000000 { | ||
89 | status = "okay"; | ||
90 | clock-rate=<50000000>; | ||
91 | |||
92 | flash@f8000000 { | ||
93 | #address-cells = <1>; | ||
94 | #size-cells = <1>; | ||
95 | reg = <0xf8000000 0x800000>; | ||
96 | st,smi-fast-mode; | ||
97 | |||
98 | partition@0 { | ||
99 | label = "xloader"; | ||
100 | reg = <0x0 0x10000>; | ||
101 | }; | ||
102 | partition@10000 { | ||
103 | label = "u-boot"; | ||
104 | reg = <0x10000 0x40000>; | ||
105 | }; | ||
106 | partition@50000 { | ||
107 | label = "linux"; | ||
108 | reg = <0x50000 0x2c0000>; | ||
109 | }; | ||
110 | partition@310000 { | ||
111 | label = "rootfs"; | ||
112 | reg = <0x310000 0x4f0000>; | ||
113 | }; | ||
114 | }; | ||
115 | }; | ||
116 | |||
117 | spi0: spi@d0100000 { | ||
118 | status = "okay"; | ||
119 | }; | ||
120 | |||
121 | ehci@e1800000 { | ||
122 | status = "okay"; | ||
123 | }; | ||
124 | |||
125 | ohci@e1900000 { | ||
126 | status = "okay"; | ||
127 | }; | ||
128 | |||
129 | ohci@e2100000 { | ||
130 | status = "okay"; | ||
131 | }; | ||
132 | |||
133 | apb { | ||
134 | gpio0: gpio@fc980000 { | ||
135 | status = "okay"; | ||
136 | }; | ||
137 | |||
138 | gpio1: gpio@a9000000 { | ||
139 | status = "okay"; | ||
140 | }; | ||
141 | |||
142 | i2c0: i2c@d0180000 { | ||
143 | status = "okay"; | ||
144 | }; | ||
145 | |||
146 | kbd@a0000000 { | ||
147 | linux,keymap = < 0x00000001 | ||
148 | 0x00010002 | ||
149 | 0x00020003 | ||
150 | 0x00030004 | ||
151 | 0x00040005 | ||
152 | 0x00050006 | ||
153 | 0x00060007 | ||
154 | 0x00070008 | ||
155 | 0x00080009 | ||
156 | 0x0100000a | ||
157 | 0x0101000c | ||
158 | 0x0102000d | ||
159 | 0x0103000e | ||
160 | 0x0104000f | ||
161 | 0x01050010 | ||
162 | 0x01060011 | ||
163 | 0x01070012 | ||
164 | 0x01080013 | ||
165 | 0x02000014 | ||
166 | 0x02010015 | ||
167 | 0x02020016 | ||
168 | 0x02030017 | ||
169 | 0x02040018 | ||
170 | 0x02050019 | ||
171 | 0x0206001a | ||
172 | 0x0207001b | ||
173 | 0x0208001c | ||
174 | 0x0300001d | ||
175 | 0x0301001e | ||
176 | 0x0302001f | ||
177 | 0x03030020 | ||
178 | 0x03040021 | ||
179 | 0x03050022 | ||
180 | 0x03060023 | ||
181 | 0x03070024 | ||
182 | 0x03080025 | ||
183 | 0x04000026 | ||
184 | 0x04010027 | ||
185 | 0x04020028 | ||
186 | 0x04030029 | ||
187 | 0x0404002a | ||
188 | 0x0405002b | ||
189 | 0x0406002c | ||
190 | 0x0407002d | ||
191 | 0x0408002e | ||
192 | 0x0500002f | ||
193 | 0x05010030 | ||
194 | 0x05020031 | ||
195 | 0x05030032 | ||
196 | 0x05040033 | ||
197 | 0x05050034 | ||
198 | 0x05060035 | ||
199 | 0x05070036 | ||
200 | 0x05080037 | ||
201 | 0x06000038 | ||
202 | 0x06010039 | ||
203 | 0x0602003a | ||
204 | 0x0603003b | ||
205 | 0x0604003c | ||
206 | 0x0605003d | ||
207 | 0x0606003e | ||
208 | 0x0607003f | ||
209 | 0x06080040 | ||
210 | 0x07000041 | ||
211 | 0x07010042 | ||
212 | 0x07020043 | ||
213 | 0x07030044 | ||
214 | 0x07040045 | ||
215 | 0x07050046 | ||
216 | 0x07060047 | ||
217 | 0x07070048 | ||
218 | 0x07080049 | ||
219 | 0x0800004a | ||
220 | 0x0801004b | ||
221 | 0x0802004c | ||
222 | 0x0803004d | ||
223 | 0x0804004e | ||
224 | 0x0805004f | ||
225 | 0x08060050 | ||
226 | 0x08070051 | ||
227 | 0x08080052 >; | ||
228 | autorepeat; | ||
229 | st,mode = <0>; | ||
230 | status = "okay"; | ||
231 | }; | ||
232 | |||
233 | rtc@fc900000 { | ||
234 | status = "okay"; | ||
235 | }; | ||
236 | |||
237 | serial@d0000000 { | ||
238 | status = "okay"; | ||
239 | }; | ||
240 | |||
241 | wdt@fc880000 { | ||
242 | status = "okay"; | ||
243 | }; | ||
244 | }; | ||
245 | }; | ||
246 | }; | ||
diff --git a/arch/arm/boot/dts/spear300.dtsi b/arch/arm/boot/dts/spear300.dtsi new file mode 100644 index 000000000000..01c5e358fdb2 --- /dev/null +++ b/arch/arm/boot/dts/spear300.dtsi | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | * DTS file for SPEAr300 SoC | ||
3 | * | ||
4 | * Copyright 2012 Viresh Kumar <viresh.kumar@st.com> | ||
5 | * | ||
6 | * The code contained herein is licensed under the GNU General Public | ||
7 | * License. You may obtain a copy of the GNU General Public License | ||
8 | * Version 2 or later at the following locations: | ||
9 | * | ||
10 | * http://www.opensource.org/licenses/gpl-license.html | ||
11 | * http://www.gnu.org/copyleft/gpl.html | ||
12 | */ | ||
13 | |||
14 | /include/ "spear3xx.dtsi" | ||
15 | |||
16 | / { | ||
17 | ahb { | ||
18 | #address-cells = <1>; | ||
19 | #size-cells = <1>; | ||
20 | compatible = "simple-bus"; | ||
21 | ranges = <0x60000000 0x60000000 0x50000000 | ||
22 | 0xd0000000 0xd0000000 0x30000000>; | ||
23 | |||
24 | pinmux@99000000 { | ||
25 | compatible = "st,spear300-pinmux"; | ||
26 | reg = <0x99000000 0x1000>; | ||
27 | }; | ||
28 | |||
29 | clcd@60000000 { | ||
30 | compatible = "arm,clcd-pl110", "arm,primecell"; | ||
31 | reg = <0x60000000 0x1000>; | ||
32 | interrupts = <30>; | ||
33 | status = "disabled"; | ||
34 | }; | ||
35 | |||
36 | fsmc: flash@94000000 { | ||
37 | compatible = "st,spear600-fsmc-nand"; | ||
38 | #address-cells = <1>; | ||
39 | #size-cells = <1>; | ||
40 | reg = <0x94000000 0x1000 /* FSMC Register */ | ||
41 | 0x80000000 0x0010>; /* NAND Base */ | ||
42 | reg-names = "fsmc_regs", "nand_data"; | ||
43 | st,ale-off = <0x20000>; | ||
44 | st,cle-off = <0x10000>; | ||
45 | status = "disabled"; | ||
46 | }; | ||
47 | |||
48 | sdhci@70000000 { | ||
49 | compatible = "st,sdhci-spear"; | ||
50 | reg = <0x70000000 0x100>; | ||
51 | interrupts = <1>; | ||
52 | status = "disabled"; | ||
53 | }; | ||
54 | |||
55 | apb { | ||
56 | #address-cells = <1>; | ||
57 | #size-cells = <1>; | ||
58 | compatible = "simple-bus"; | ||
59 | ranges = <0xa0000000 0xa0000000 0x10000000 | ||
60 | 0xd0000000 0xd0000000 0x30000000>; | ||
61 | |||
62 | gpio1: gpio@a9000000 { | ||
63 | #gpio-cells = <2>; | ||
64 | compatible = "arm,pl061", "arm,primecell"; | ||
65 | gpio-controller; | ||
66 | reg = <0xa9000000 0x1000>; | ||
67 | status = "disabled"; | ||
68 | }; | ||
69 | |||
70 | kbd@a0000000 { | ||
71 | compatible = "st,spear300-kbd"; | ||
72 | reg = <0xa0000000 0x1000>; | ||
73 | status = "disabled"; | ||
74 | }; | ||
75 | }; | ||
76 | }; | ||
77 | }; | ||
diff --git a/arch/arm/boot/dts/spear310-evb.dts b/arch/arm/boot/dts/spear310-evb.dts new file mode 100644 index 000000000000..dc5e2d445a93 --- /dev/null +++ b/arch/arm/boot/dts/spear310-evb.dts | |||
@@ -0,0 +1,188 @@ | |||
1 | /* | ||
2 | * DTS file for SPEAr310 Evaluation Baord | ||
3 | * | ||
4 | * Copyright 2012 Viresh Kumar <viresh.kumar@st.com> | ||
5 | * | ||
6 | * The code contained herein is licensed under the GNU General Public | ||
7 | * License. You may obtain a copy of the GNU General Public License | ||
8 | * Version 2 or later at the following locations: | ||
9 | * | ||
10 | * http://www.opensource.org/licenses/gpl-license.html | ||
11 | * http://www.gnu.org/copyleft/gpl.html | ||
12 | */ | ||
13 | |||
14 | /dts-v1/; | ||
15 | /include/ "spear310.dtsi" | ||
16 | |||
17 | / { | ||
18 | model = "ST SPEAr310 Evaluation Board"; | ||
19 | compatible = "st,spear310-evb", "st,spear310"; | ||
20 | #address-cells = <1>; | ||
21 | #size-cells = <1>; | ||
22 | |||
23 | memory { | ||
24 | reg = <0 0x40000000>; | ||
25 | }; | ||
26 | |||
27 | ahb { | ||
28 | pinmux@b4000000 { | ||
29 | pinctrl-names = "default"; | ||
30 | pinctrl-0 = <&state_default>; | ||
31 | |||
32 | state_default: pinmux { | ||
33 | gpio0 { | ||
34 | st,pins = "gpio0_pin0_grp", | ||
35 | "gpio0_pin1_grp", | ||
36 | "gpio0_pin2_grp", | ||
37 | "gpio0_pin3_grp", | ||
38 | "gpio0_pin4_grp", | ||
39 | "gpio0_pin5_grp"; | ||
40 | st,function = "gpio0"; | ||
41 | }; | ||
42 | i2c0 { | ||
43 | st,pins = "i2c0_grp"; | ||
44 | st,function = "i2c0"; | ||
45 | }; | ||
46 | mii0 { | ||
47 | st,pins = "mii0_grp"; | ||
48 | st,function = "mii0"; | ||
49 | }; | ||
50 | ssp0 { | ||
51 | st,pins = "ssp0_grp"; | ||
52 | st,function = "ssp0"; | ||
53 | }; | ||
54 | uart0 { | ||
55 | st,pins = "uart0_grp"; | ||
56 | st,function = "uart0"; | ||
57 | }; | ||
58 | emi { | ||
59 | st,pins = "emi_cs_0_to_5_grp"; | ||
60 | st,function = "emi"; | ||
61 | }; | ||
62 | fsmc { | ||
63 | st,pins = "fsmc_grp"; | ||
64 | st,function = "fsmc"; | ||
65 | }; | ||
66 | uart1 { | ||
67 | st,pins = "uart1_grp"; | ||
68 | st,function = "uart1"; | ||
69 | }; | ||
70 | uart2 { | ||
71 | st,pins = "uart2_grp"; | ||
72 | st,function = "uart2"; | ||
73 | }; | ||
74 | uart3 { | ||
75 | st,pins = "uart3_grp"; | ||
76 | st,function = "uart3"; | ||
77 | }; | ||
78 | uart4 { | ||
79 | st,pins = "uart4_grp"; | ||
80 | st,function = "uart4"; | ||
81 | }; | ||
82 | uart5 { | ||
83 | st,pins = "uart5_grp"; | ||
84 | st,function = "uart5"; | ||
85 | }; | ||
86 | }; | ||
87 | }; | ||
88 | |||
89 | dma@fc400000 { | ||
90 | status = "okay"; | ||
91 | }; | ||
92 | |||
93 | fsmc: flash@44000000 { | ||
94 | status = "okay"; | ||
95 | }; | ||
96 | |||
97 | gmac: eth@e0800000 { | ||
98 | status = "okay"; | ||
99 | }; | ||
100 | |||
101 | smi: flash@fc000000 { | ||
102 | status = "okay"; | ||
103 | clock-rate=<50000000>; | ||
104 | |||
105 | flash@f8000000 { | ||
106 | #address-cells = <1>; | ||
107 | #size-cells = <1>; | ||
108 | reg = <0xf8000000 0x800000>; | ||
109 | st,smi-fast-mode; | ||
110 | |||
111 | partition@0 { | ||
112 | label = "xloader"; | ||
113 | reg = <0x0 0x10000>; | ||
114 | }; | ||
115 | partition@10000 { | ||
116 | label = "u-boot"; | ||
117 | reg = <0x10000 0x40000>; | ||
118 | }; | ||
119 | partition@50000 { | ||
120 | label = "linux"; | ||
121 | reg = <0x50000 0x2c0000>; | ||
122 | }; | ||
123 | partition@310000 { | ||
124 | label = "rootfs"; | ||
125 | reg = <0x310000 0x4f0000>; | ||
126 | }; | ||
127 | }; | ||
128 | }; | ||
129 | |||
130 | spi0: spi@d0100000 { | ||
131 | status = "okay"; | ||
132 | }; | ||
133 | |||
134 | ehci@e1800000 { | ||
135 | status = "okay"; | ||
136 | }; | ||
137 | |||
138 | ohci@e1900000 { | ||
139 | status = "okay"; | ||
140 | }; | ||
141 | |||
142 | ohci@e2100000 { | ||
143 | status = "okay"; | ||
144 | }; | ||
145 | |||
146 | apb { | ||
147 | gpio0: gpio@fc980000 { | ||
148 | status = "okay"; | ||
149 | }; | ||
150 | |||
151 | i2c0: i2c@d0180000 { | ||
152 | status = "okay"; | ||
153 | }; | ||
154 | |||
155 | rtc@fc900000 { | ||
156 | status = "okay"; | ||
157 | }; | ||
158 | |||
159 | serial@d0000000 { | ||
160 | status = "okay"; | ||
161 | }; | ||
162 | |||
163 | serial@b2000000 { | ||
164 | status = "okay"; | ||
165 | }; | ||
166 | |||
167 | serial@b2080000 { | ||
168 | status = "okay"; | ||
169 | }; | ||
170 | |||
171 | serial@b2100000 { | ||
172 | status = "okay"; | ||
173 | }; | ||
174 | |||
175 | serial@b2180000 { | ||
176 | status = "okay"; | ||
177 | }; | ||
178 | |||
179 | serial@b2200000 { | ||
180 | status = "okay"; | ||
181 | }; | ||
182 | |||
183 | wdt@fc880000 { | ||
184 | status = "okay"; | ||
185 | }; | ||
186 | }; | ||
187 | }; | ||
188 | }; | ||
diff --git a/arch/arm/boot/dts/spear310.dtsi b/arch/arm/boot/dts/spear310.dtsi new file mode 100644 index 000000000000..e47081c494d9 --- /dev/null +++ b/arch/arm/boot/dts/spear310.dtsi | |||
@@ -0,0 +1,80 @@ | |||
1 | /* | ||
2 | * DTS file for SPEAr310 SoC | ||
3 | * | ||
4 | * Copyright 2012 Viresh Kumar <viresh.kumar@st.com> | ||
5 | * | ||
6 | * The code contained herein is licensed under the GNU General Public | ||
7 | * License. You may obtain a copy of the GNU General Public License | ||
8 | * Version 2 or later at the following locations: | ||
9 | * | ||
10 | * http://www.opensource.org/licenses/gpl-license.html | ||
11 | * http://www.gnu.org/copyleft/gpl.html | ||
12 | */ | ||
13 | |||
14 | /include/ "spear3xx.dtsi" | ||
15 | |||
16 | / { | ||
17 | ahb { | ||
18 | #address-cells = <1>; | ||
19 | #size-cells = <1>; | ||
20 | compatible = "simple-bus"; | ||
21 | ranges = <0x40000000 0x40000000 0x10000000 | ||
22 | 0xb0000000 0xb0000000 0x10000000 | ||
23 | 0xd0000000 0xd0000000 0x30000000>; | ||
24 | |||
25 | pinmux@b4000000 { | ||
26 | compatible = "st,spear310-pinmux"; | ||
27 | reg = <0xb4000000 0x1000>; | ||
28 | }; | ||
29 | |||
30 | fsmc: flash@44000000 { | ||
31 | compatible = "st,spear600-fsmc-nand"; | ||
32 | #address-cells = <1>; | ||
33 | #size-cells = <1>; | ||
34 | reg = <0x44000000 0x1000 /* FSMC Register */ | ||
35 | 0x40000000 0x0010>; /* NAND Base */ | ||
36 | reg-names = "fsmc_regs", "nand_data"; | ||
37 | st,ale-off = <0x10000>; | ||
38 | st,cle-off = <0x20000>; | ||
39 | status = "disabled"; | ||
40 | }; | ||
41 | |||
42 | apb { | ||
43 | #address-cells = <1>; | ||
44 | #size-cells = <1>; | ||
45 | compatible = "simple-bus"; | ||
46 | ranges = <0xb0000000 0xb0000000 0x10000000 | ||
47 | 0xd0000000 0xd0000000 0x30000000>; | ||
48 | |||
49 | serial@b2000000 { | ||
50 | compatible = "arm,pl011", "arm,primecell"; | ||
51 | reg = <0xb2000000 0x1000>; | ||
52 | status = "disabled"; | ||
53 | }; | ||
54 | |||
55 | serial@b2080000 { | ||
56 | compatible = "arm,pl011", "arm,primecell"; | ||
57 | reg = <0xb2080000 0x1000>; | ||
58 | status = "disabled"; | ||
59 | }; | ||
60 | |||
61 | serial@b2100000 { | ||
62 | compatible = "arm,pl011", "arm,primecell"; | ||
63 | reg = <0xb2100000 0x1000>; | ||
64 | status = "disabled"; | ||
65 | }; | ||
66 | |||
67 | serial@b2180000 { | ||
68 | compatible = "arm,pl011", "arm,primecell"; | ||
69 | reg = <0xb2180000 0x1000>; | ||
70 | status = "disabled"; | ||
71 | }; | ||
72 | |||
73 | serial@b2200000 { | ||
74 | compatible = "arm,pl011", "arm,primecell"; | ||
75 | reg = <0xb2200000 0x1000>; | ||
76 | status = "disabled"; | ||
77 | }; | ||
78 | }; | ||
79 | }; | ||
80 | }; | ||
diff --git a/arch/arm/boot/dts/spear320-evb.dts b/arch/arm/boot/dts/spear320-evb.dts new file mode 100644 index 000000000000..6308fa3bec1e --- /dev/null +++ b/arch/arm/boot/dts/spear320-evb.dts | |||
@@ -0,0 +1,198 @@ | |||
1 | /* | ||
2 | * DTS file for SPEAr320 Evaluation Baord | ||
3 | * | ||
4 | * Copyright 2012 Viresh Kumar <viresh.kumar@st.com> | ||
5 | * | ||
6 | * The code contained herein is licensed under the GNU General Public | ||
7 | * License. You may obtain a copy of the GNU General Public License | ||
8 | * Version 2 or later at the following locations: | ||
9 | * | ||
10 | * http://www.opensource.org/licenses/gpl-license.html | ||
11 | * http://www.gnu.org/copyleft/gpl.html | ||
12 | */ | ||
13 | |||
14 | /dts-v1/; | ||
15 | /include/ "spear320.dtsi" | ||
16 | |||
17 | / { | ||
18 | model = "ST SPEAr300 Evaluation Board"; | ||
19 | compatible = "st,spear300-evb", "st,spear300"; | ||
20 | #address-cells = <1>; | ||
21 | #size-cells = <1>; | ||
22 | |||
23 | memory { | ||
24 | reg = <0 0x40000000>; | ||
25 | }; | ||
26 | |||
27 | ahb { | ||
28 | pinmux@b3000000 { | ||
29 | st,pinmux-mode = <3>; | ||
30 | pinctrl-names = "default"; | ||
31 | pinctrl-0 = <&state_default>; | ||
32 | |||
33 | state_default: pinmux { | ||
34 | i2c0 { | ||
35 | st,pins = "i2c0_grp"; | ||
36 | st,function = "i2c0"; | ||
37 | }; | ||
38 | mii0 { | ||
39 | st,pins = "mii0_grp"; | ||
40 | st,function = "mii0"; | ||
41 | }; | ||
42 | ssp0 { | ||
43 | st,pins = "ssp0_grp"; | ||
44 | st,function = "ssp0"; | ||
45 | }; | ||
46 | uart0 { | ||
47 | st,pins = "uart0_grp"; | ||
48 | st,function = "uart0"; | ||
49 | }; | ||
50 | sdhci { | ||
51 | st,pins = "sdhci_cd_51_grp"; | ||
52 | st,function = "sdhci"; | ||
53 | }; | ||
54 | i2s { | ||
55 | st,pins = "i2s_grp"; | ||
56 | st,function = "i2s"; | ||
57 | }; | ||
58 | uart1 { | ||
59 | st,pins = "uart1_grp"; | ||
60 | st,function = "uart1"; | ||
61 | }; | ||
62 | uart2 { | ||
63 | st,pins = "uart2_grp"; | ||
64 | st,function = "uart2"; | ||
65 | }; | ||
66 | can0 { | ||
67 | st,pins = "can0_grp"; | ||
68 | st,function = "can0"; | ||
69 | }; | ||
70 | can1 { | ||
71 | st,pins = "can1_grp"; | ||
72 | st,function = "can1"; | ||
73 | }; | ||
74 | mii2 { | ||
75 | st,pins = "mii2_grp"; | ||
76 | st,function = "mii2"; | ||
77 | }; | ||
78 | pwm0_1 { | ||
79 | st,pins = "pwm0_1_pin_14_15_grp"; | ||
80 | st,function = "pwm0_1"; | ||
81 | }; | ||
82 | pwm2 { | ||
83 | st,pins = "pwm2_pin_13_grp"; | ||
84 | st,function = "pwm2"; | ||
85 | }; | ||
86 | }; | ||
87 | }; | ||
88 | |||
89 | clcd@90000000 { | ||
90 | status = "okay"; | ||
91 | }; | ||
92 | |||
93 | dma@fc400000 { | ||
94 | status = "okay"; | ||
95 | }; | ||
96 | |||
97 | fsmc: flash@4c000000 { | ||
98 | status = "okay"; | ||
99 | }; | ||
100 | |||
101 | gmac: eth@e0800000 { | ||
102 | status = "okay"; | ||
103 | }; | ||
104 | |||
105 | sdhci@70000000 { | ||
106 | power-gpio = <&gpio0 2 1>; | ||
107 | power_always_enb; | ||
108 | status = "okay"; | ||
109 | }; | ||
110 | |||
111 | smi: flash@fc000000 { | ||
112 | status = "okay"; | ||
113 | clock-rate=<50000000>; | ||
114 | |||
115 | flash@f8000000 { | ||
116 | #address-cells = <1>; | ||
117 | #size-cells = <1>; | ||
118 | reg = <0xf8000000 0x800000>; | ||
119 | st,smi-fast-mode; | ||
120 | |||
121 | partition@0 { | ||
122 | label = "xloader"; | ||
123 | reg = <0x0 0x10000>; | ||
124 | }; | ||
125 | partition@10000 { | ||
126 | label = "u-boot"; | ||
127 | reg = <0x10000 0x40000>; | ||
128 | }; | ||
129 | partition@50000 { | ||
130 | label = "linux"; | ||
131 | reg = <0x50000 0x2c0000>; | ||
132 | }; | ||
133 | partition@310000 { | ||
134 | label = "rootfs"; | ||
135 | reg = <0x310000 0x4f0000>; | ||
136 | }; | ||
137 | }; | ||
138 | }; | ||
139 | |||
140 | spi0: spi@d0100000 { | ||
141 | status = "okay"; | ||
142 | }; | ||
143 | |||
144 | spi1: spi@a5000000 { | ||
145 | status = "okay"; | ||
146 | }; | ||
147 | |||
148 | spi2: spi@a6000000 { | ||
149 | status = "okay"; | ||
150 | }; | ||
151 | |||
152 | ehci@e1800000 { | ||
153 | status = "okay"; | ||
154 | }; | ||
155 | |||
156 | ohci@e1900000 { | ||
157 | status = "okay"; | ||
158 | }; | ||
159 | |||
160 | ohci@e2100000 { | ||
161 | status = "okay"; | ||
162 | }; | ||
163 | |||
164 | apb { | ||
165 | gpio0: gpio@fc980000 { | ||
166 | status = "okay"; | ||
167 | }; | ||
168 | |||
169 | i2c0: i2c@d0180000 { | ||
170 | status = "okay"; | ||
171 | }; | ||
172 | |||
173 | i2c1: i2c@a7000000 { | ||
174 | status = "okay"; | ||
175 | }; | ||
176 | |||
177 | rtc@fc900000 { | ||
178 | status = "okay"; | ||
179 | }; | ||
180 | |||
181 | serial@d0000000 { | ||
182 | status = "okay"; | ||
183 | }; | ||
184 | |||
185 | serial@a3000000 { | ||
186 | status = "okay"; | ||
187 | }; | ||
188 | |||
189 | serial@a4000000 { | ||
190 | status = "okay"; | ||
191 | }; | ||
192 | |||
193 | wdt@fc880000 { | ||
194 | status = "okay"; | ||
195 | }; | ||
196 | }; | ||
197 | }; | ||
198 | }; | ||
diff --git a/arch/arm/boot/dts/spear320.dtsi b/arch/arm/boot/dts/spear320.dtsi new file mode 100644 index 000000000000..5372ca399b1f --- /dev/null +++ b/arch/arm/boot/dts/spear320.dtsi | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | * DTS file for SPEAr320 SoC | ||
3 | * | ||
4 | * Copyright 2012 Viresh Kumar <viresh.kumar@st.com> | ||
5 | * | ||
6 | * The code contained herein is licensed under the GNU General Public | ||
7 | * License. You may obtain a copy of the GNU General Public License | ||
8 | * Version 2 or later at the following locations: | ||
9 | * | ||
10 | * http://www.opensource.org/licenses/gpl-license.html | ||
11 | * http://www.gnu.org/copyleft/gpl.html | ||
12 | */ | ||
13 | |||
14 | /include/ "spear3xx.dtsi" | ||
15 | |||
16 | / { | ||
17 | ahb { | ||
18 | #address-cells = <1>; | ||
19 | #size-cells = <1>; | ||
20 | compatible = "simple-bus"; | ||
21 | ranges = <0x40000000 0x40000000 0x80000000 | ||
22 | 0xd0000000 0xd0000000 0x30000000>; | ||
23 | |||
24 | pinmux@b3000000 { | ||
25 | compatible = "st,spear320-pinmux"; | ||
26 | reg = <0xb3000000 0x1000>; | ||
27 | }; | ||
28 | |||
29 | clcd@90000000 { | ||
30 | compatible = "arm,clcd-pl110", "arm,primecell"; | ||
31 | reg = <0x90000000 0x1000>; | ||
32 | interrupts = <33>; | ||
33 | status = "disabled"; | ||
34 | }; | ||
35 | |||
36 | fsmc: flash@4c000000 { | ||
37 | compatible = "st,spear600-fsmc-nand"; | ||
38 | #address-cells = <1>; | ||
39 | #size-cells = <1>; | ||
40 | reg = <0x4c000000 0x1000 /* FSMC Register */ | ||
41 | 0x50000000 0x0010>; /* NAND Base */ | ||
42 | reg-names = "fsmc_regs", "nand_data"; | ||
43 | st,ale-off = <0x20000>; | ||
44 | st,cle-off = <0x10000>; | ||
45 | status = "disabled"; | ||
46 | }; | ||
47 | |||
48 | sdhci@70000000 { | ||
49 | compatible = "st,sdhci-spear"; | ||
50 | reg = <0x70000000 0x100>; | ||
51 | interrupts = <29>; | ||
52 | status = "disabled"; | ||
53 | }; | ||
54 | |||
55 | spi1: spi@a5000000 { | ||
56 | compatible = "arm,pl022", "arm,primecell"; | ||
57 | reg = <0xa5000000 0x1000>; | ||
58 | status = "disabled"; | ||
59 | }; | ||
60 | |||
61 | spi2: spi@a6000000 { | ||
62 | compatible = "arm,pl022", "arm,primecell"; | ||
63 | reg = <0xa6000000 0x1000>; | ||
64 | status = "disabled"; | ||
65 | }; | ||
66 | |||
67 | apb { | ||
68 | #address-cells = <1>; | ||
69 | #size-cells = <1>; | ||
70 | compatible = "simple-bus"; | ||
71 | ranges = <0xa0000000 0xa0000000 0x10000000 | ||
72 | 0xd0000000 0xd0000000 0x30000000>; | ||
73 | |||
74 | i2c1: i2c@a7000000 { | ||
75 | #address-cells = <1>; | ||
76 | #size-cells = <0>; | ||
77 | compatible = "snps,designware-i2c"; | ||
78 | reg = <0xa7000000 0x1000>; | ||
79 | status = "disabled"; | ||
80 | }; | ||
81 | |||
82 | serial@a3000000 { | ||
83 | compatible = "arm,pl011", "arm,primecell"; | ||
84 | reg = <0xa3000000 0x1000>; | ||
85 | status = "disabled"; | ||
86 | }; | ||
87 | |||
88 | serial@a4000000 { | ||
89 | compatible = "arm,pl011", "arm,primecell"; | ||
90 | reg = <0xa4000000 0x1000>; | ||
91 | status = "disabled"; | ||
92 | }; | ||
93 | }; | ||
94 | }; | ||
95 | }; | ||
diff --git a/arch/arm/boot/dts/spear3xx.dtsi b/arch/arm/boot/dts/spear3xx.dtsi new file mode 100644 index 000000000000..91072553963f --- /dev/null +++ b/arch/arm/boot/dts/spear3xx.dtsi | |||
@@ -0,0 +1,150 @@ | |||
1 | /* | ||
2 | * DTS file for all SPEAr3xx SoCs | ||
3 | * | ||
4 | * Copyright 2012 Viresh Kumar <viresh.kumar@st.com> | ||
5 | * | ||
6 | * The code contained herein is licensed under the GNU General Public | ||
7 | * License. You may obtain a copy of the GNU General Public License | ||
8 | * Version 2 or later at the following locations: | ||
9 | * | ||
10 | * http://www.opensource.org/licenses/gpl-license.html | ||
11 | * http://www.gnu.org/copyleft/gpl.html | ||
12 | */ | ||
13 | |||
14 | /include/ "skeleton.dtsi" | ||
15 | |||
16 | / { | ||
17 | interrupt-parent = <&vic>; | ||
18 | |||
19 | cpus { | ||
20 | cpu@0 { | ||
21 | compatible = "arm,arm926ejs"; | ||
22 | }; | ||
23 | }; | ||
24 | |||
25 | memory { | ||
26 | device_type = "memory"; | ||
27 | reg = <0 0x40000000>; | ||
28 | }; | ||
29 | |||
30 | ahb { | ||
31 | #address-cells = <1>; | ||
32 | #size-cells = <1>; | ||
33 | compatible = "simple-bus"; | ||
34 | ranges = <0xd0000000 0xd0000000 0x30000000>; | ||
35 | |||
36 | vic: interrupt-controller@f1100000 { | ||
37 | compatible = "arm,pl190-vic"; | ||
38 | interrupt-controller; | ||
39 | reg = <0xf1100000 0x1000>; | ||
40 | #interrupt-cells = <1>; | ||
41 | }; | ||
42 | |||
43 | dma@fc400000 { | ||
44 | compatible = "arm,pl080", "arm,primecell"; | ||
45 | reg = <0xfc400000 0x1000>; | ||
46 | interrupt-parent = <&vic>; | ||
47 | interrupts = <8>; | ||
48 | status = "disabled"; | ||
49 | }; | ||
50 | |||
51 | gmac: eth@e0800000 { | ||
52 | compatible = "st,spear600-gmac"; | ||
53 | reg = <0xe0800000 0x8000>; | ||
54 | interrupts = <23 22>; | ||
55 | interrupt-names = "macirq", "eth_wake_irq"; | ||
56 | status = "disabled"; | ||
57 | }; | ||
58 | |||
59 | smi: flash@fc000000 { | ||
60 | compatible = "st,spear600-smi"; | ||
61 | #address-cells = <1>; | ||
62 | #size-cells = <1>; | ||
63 | reg = <0xfc000000 0x1000>; | ||
64 | interrupts = <9>; | ||
65 | status = "disabled"; | ||
66 | }; | ||
67 | |||
68 | spi0: spi@d0100000 { | ||
69 | compatible = "arm,pl022", "arm,primecell"; | ||
70 | reg = <0xd0100000 0x1000>; | ||
71 | interrupts = <20>; | ||
72 | status = "disabled"; | ||
73 | }; | ||
74 | |||
75 | ehci@e1800000 { | ||
76 | compatible = "st,spear600-ehci", "usb-ehci"; | ||
77 | reg = <0xe1800000 0x1000>; | ||
78 | interrupts = <26>; | ||
79 | status = "disabled"; | ||
80 | }; | ||
81 | |||
82 | ohci@e1900000 { | ||
83 | compatible = "st,spear600-ohci", "usb-ohci"; | ||
84 | reg = <0xe1900000 0x1000>; | ||
85 | interrupts = <25>; | ||
86 | status = "disabled"; | ||
87 | }; | ||
88 | |||
89 | ohci@e2100000 { | ||
90 | compatible = "st,spear600-ohci", "usb-ohci"; | ||
91 | reg = <0xe2100000 0x1000>; | ||
92 | interrupts = <27>; | ||
93 | status = "disabled"; | ||
94 | }; | ||
95 | |||
96 | apb { | ||
97 | #address-cells = <1>; | ||
98 | #size-cells = <1>; | ||
99 | compatible = "simple-bus"; | ||
100 | ranges = <0xd0000000 0xd0000000 0x30000000>; | ||
101 | |||
102 | gpio0: gpio@fc980000 { | ||
103 | compatible = "arm,pl061", "arm,primecell"; | ||
104 | reg = <0xfc980000 0x1000>; | ||
105 | interrupts = <11>; | ||
106 | gpio-controller; | ||
107 | #gpio-cells = <2>; | ||
108 | interrupt-controller; | ||
109 | #interrupt-cells = <2>; | ||
110 | status = "disabled"; | ||
111 | }; | ||
112 | |||
113 | i2c0: i2c@d0180000 { | ||
114 | #address-cells = <1>; | ||
115 | #size-cells = <0>; | ||
116 | compatible = "snps,designware-i2c"; | ||
117 | reg = <0xd0180000 0x1000>; | ||
118 | interrupts = <21>; | ||
119 | status = "disabled"; | ||
120 | }; | ||
121 | |||
122 | rtc@fc900000 { | ||
123 | compatible = "st,spear-rtc"; | ||
124 | reg = <0xfc900000 0x1000>; | ||
125 | interrupts = <10>; | ||
126 | status = "disabled"; | ||
127 | }; | ||
128 | |||
129 | serial@d0000000 { | ||
130 | compatible = "arm,pl011", "arm,primecell"; | ||
131 | reg = <0xd0000000 0x1000>; | ||
132 | interrupts = <19>; | ||
133 | status = "disabled"; | ||
134 | }; | ||
135 | |||
136 | wdt@fc880000 { | ||
137 | compatible = "arm,sp805", "arm,primecell"; | ||
138 | reg = <0xfc880000 0x1000>; | ||
139 | interrupts = <12>; | ||
140 | status = "disabled"; | ||
141 | }; | ||
142 | |||
143 | timer@f0000000 { | ||
144 | compatible = "st,spear-timer"; | ||
145 | reg = <0xf0000000 0x400>; | ||
146 | interrupts = <2>; | ||
147 | }; | ||
148 | }; | ||
149 | }; | ||
150 | }; | ||
diff --git a/arch/arm/boot/dts/spear600-evb.dts b/arch/arm/boot/dts/spear600-evb.dts index 636292e18c90..1119c22c9a82 100644 --- a/arch/arm/boot/dts/spear600-evb.dts +++ b/arch/arm/boot/dts/spear600-evb.dts | |||
@@ -24,11 +24,44 @@ | |||
24 | }; | 24 | }; |
25 | 25 | ||
26 | ahb { | 26 | ahb { |
27 | dma@fc400000 { | ||
28 | status = "okay"; | ||
29 | }; | ||
30 | |||
27 | gmac: ethernet@e0800000 { | 31 | gmac: ethernet@e0800000 { |
28 | phy-mode = "gmii"; | 32 | phy-mode = "gmii"; |
29 | status = "okay"; | 33 | status = "okay"; |
30 | }; | 34 | }; |
31 | 35 | ||
36 | smi: flash@fc000000 { | ||
37 | status = "okay"; | ||
38 | clock-rate=<50000000>; | ||
39 | |||
40 | flash@f8000000 { | ||
41 | #address-cells = <1>; | ||
42 | #size-cells = <1>; | ||
43 | reg = <0xf8000000 0x800000>; | ||
44 | st,smi-fast-mode; | ||
45 | |||
46 | partition@0 { | ||
47 | label = "xloader"; | ||
48 | reg = <0x0 0x10000>; | ||
49 | }; | ||
50 | partition@10000 { | ||
51 | label = "u-boot"; | ||
52 | reg = <0x10000 0x40000>; | ||
53 | }; | ||
54 | partition@50000 { | ||
55 | label = "linux"; | ||
56 | reg = <0x50000 0x2c0000>; | ||
57 | }; | ||
58 | partition@310000 { | ||
59 | label = "rootfs"; | ||
60 | reg = <0x310000 0x4f0000>; | ||
61 | }; | ||
62 | }; | ||
63 | }; | ||
64 | |||
32 | apb { | 65 | apb { |
33 | serial@d0000000 { | 66 | serial@d0000000 { |
34 | status = "okay"; | 67 | status = "okay"; |
diff --git a/arch/arm/boot/dts/spear600.dtsi b/arch/arm/boot/dts/spear600.dtsi index ebe0885a2b98..089f0a42c50e 100644 --- a/arch/arm/boot/dts/spear600.dtsi +++ b/arch/arm/boot/dts/spear600.dtsi | |||
@@ -45,6 +45,14 @@ | |||
45 | #interrupt-cells = <1>; | 45 | #interrupt-cells = <1>; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | dma@fc400000 { | ||
49 | compatible = "arm,pl080", "arm,primecell"; | ||
50 | reg = <0xfc400000 0x1000>; | ||
51 | interrupt-parent = <&vic1>; | ||
52 | interrupts = <10>; | ||
53 | status = "disabled"; | ||
54 | }; | ||
55 | |||
48 | gmac: ethernet@e0800000 { | 56 | gmac: ethernet@e0800000 { |
49 | compatible = "st,spear600-gmac"; | 57 | compatible = "st,spear600-gmac"; |
50 | reg = <0xe0800000 0x8000>; | 58 | reg = <0xe0800000 0x8000>; |
@@ -169,6 +177,12 @@ | |||
169 | interrupts = <28>; | 177 | interrupts = <28>; |
170 | status = "disabled"; | 178 | status = "disabled"; |
171 | }; | 179 | }; |
180 | |||
181 | timer@f0000000 { | ||
182 | compatible = "st,spear-timer"; | ||
183 | reg = <0xf0000000 0x400>; | ||
184 | interrupts = <16>; | ||
185 | }; | ||
172 | }; | 186 | }; |
173 | }; | 187 | }; |
174 | }; | 188 | }; |
diff --git a/arch/arm/boot/dts/versatile-ab.dts b/arch/arm/boot/dts/versatile-ab.dts index 0b32925f2147..e2fe3195c0d1 100644 --- a/arch/arm/boot/dts/versatile-ab.dts +++ b/arch/arm/boot/dts/versatile-ab.dts | |||
@@ -173,7 +173,7 @@ | |||
173 | mmc@5000 { | 173 | mmc@5000 { |
174 | compatible = "arm,primecell"; | 174 | compatible = "arm,primecell"; |
175 | reg = < 0x5000 0x1000>; | 175 | reg = < 0x5000 0x1000>; |
176 | interrupts = <22>; | 176 | interrupts = <22 34>; |
177 | }; | 177 | }; |
178 | kmi@6000 { | 178 | kmi@6000 { |
179 | compatible = "arm,pl050", "arm,primecell"; | 179 | compatible = "arm,pl050", "arm,primecell"; |
diff --git a/arch/arm/boot/dts/versatile-pb.dts b/arch/arm/boot/dts/versatile-pb.dts index 166461073b78..7e8175269064 100644 --- a/arch/arm/boot/dts/versatile-pb.dts +++ b/arch/arm/boot/dts/versatile-pb.dts | |||
@@ -41,7 +41,7 @@ | |||
41 | mmc@b000 { | 41 | mmc@b000 { |
42 | compatible = "arm,primecell"; | 42 | compatible = "arm,primecell"; |
43 | reg = <0xb000 0x1000>; | 43 | reg = <0xb000 0x1000>; |
44 | interrupts = <23>; | 44 | interrupts = <23 34>; |
45 | }; | 45 | }; |
46 | }; | 46 | }; |
47 | }; | 47 | }; |
diff --git a/arch/arm/configs/mini2440_defconfig b/arch/arm/configs/mini2440_defconfig index 42da9183acc8..082175c54e7c 100644 --- a/arch/arm/configs/mini2440_defconfig +++ b/arch/arm/configs/mini2440_defconfig | |||
@@ -14,6 +14,8 @@ CONFIG_MODULE_FORCE_UNLOAD=y | |||
14 | # CONFIG_BLK_DEV_BSG is not set | 14 | # CONFIG_BLK_DEV_BSG is not set |
15 | CONFIG_BLK_DEV_INTEGRITY=y | 15 | CONFIG_BLK_DEV_INTEGRITY=y |
16 | CONFIG_ARCH_S3C24XX=y | 16 | CONFIG_ARCH_S3C24XX=y |
17 | # CONFIG_CPU_S3C2410 is not set | ||
18 | CONFIG_CPU_S3C2440=y | ||
17 | CONFIG_S3C_ADC=y | 19 | CONFIG_S3C_ADC=y |
18 | CONFIG_S3C24XX_PWM=y | 20 | CONFIG_S3C24XX_PWM=y |
19 | CONFIG_MACH_MINI2440=y | 21 | CONFIG_MACH_MINI2440=y |
diff --git a/arch/arm/configs/spear3xx_defconfig b/arch/arm/configs/spear3xx_defconfig index fea7e1f026a3..865980c5f212 100644 --- a/arch/arm/configs/spear3xx_defconfig +++ b/arch/arm/configs/spear3xx_defconfig | |||
@@ -2,33 +2,70 @@ CONFIG_EXPERIMENTAL=y | |||
2 | CONFIG_SYSVIPC=y | 2 | CONFIG_SYSVIPC=y |
3 | CONFIG_BSD_PROCESS_ACCT=y | 3 | CONFIG_BSD_PROCESS_ACCT=y |
4 | CONFIG_BLK_DEV_INITRD=y | 4 | CONFIG_BLK_DEV_INITRD=y |
5 | CONFIG_KALLSYMS_EXTRA_PASS=y | ||
6 | CONFIG_MODULES=y | 5 | CONFIG_MODULES=y |
7 | CONFIG_MODULE_UNLOAD=y | 6 | CONFIG_MODULE_UNLOAD=y |
8 | CONFIG_MODVERSIONS=y | 7 | CONFIG_MODVERSIONS=y |
8 | CONFIG_PARTITION_ADVANCED=y | ||
9 | CONFIG_PLAT_SPEAR=y | 9 | CONFIG_PLAT_SPEAR=y |
10 | CONFIG_BOARD_SPEAR300_EVB=y | 10 | CONFIG_MACH_SPEAR300=y |
11 | CONFIG_BOARD_SPEAR310_EVB=y | 11 | CONFIG_MACH_SPEAR310=y |
12 | CONFIG_BOARD_SPEAR320_EVB=y | 12 | CONFIG_MACH_SPEAR320=y |
13 | CONFIG_BINFMT_MISC=y | 13 | CONFIG_BINFMT_MISC=y |
14 | CONFIG_NET=y | ||
14 | CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" | 15 | CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" |
16 | CONFIG_MTD=y | ||
17 | CONFIG_MTD_OF_PARTS=y | ||
18 | CONFIG_MTD_CHAR=y | ||
19 | CONFIG_MTD_BLOCK=y | ||
20 | CONFIG_MTD_NAND=y | ||
21 | CONFIG_MTD_NAND_FSMC=y | ||
15 | CONFIG_BLK_DEV_RAM=y | 22 | CONFIG_BLK_DEV_RAM=y |
16 | CONFIG_BLK_DEV_RAM_SIZE=16384 | 23 | CONFIG_BLK_DEV_RAM_SIZE=16384 |
24 | CONFIG_NETDEVICES=y | ||
25 | # CONFIG_NET_VENDOR_BROADCOM is not set | ||
26 | # CONFIG_NET_VENDOR_CIRRUS is not set | ||
27 | # CONFIG_NET_VENDOR_FARADAY is not set | ||
28 | # CONFIG_NET_VENDOR_INTEL is not set | ||
29 | # CONFIG_NET_VENDOR_MICREL is not set | ||
30 | # CONFIG_NET_VENDOR_NATSEMI is not set | ||
31 | # CONFIG_NET_VENDOR_SEEQ is not set | ||
32 | # CONFIG_NET_VENDOR_SMSC is not set | ||
33 | CONFIG_STMMAC_ETH=y | ||
34 | # CONFIG_WLAN is not set | ||
17 | CONFIG_INPUT_FF_MEMLESS=y | 35 | CONFIG_INPUT_FF_MEMLESS=y |
18 | # CONFIG_INPUT_MOUSEDEV_PSAUX is not set | 36 | # CONFIG_INPUT_MOUSEDEV_PSAUX is not set |
19 | # CONFIG_INPUT_KEYBOARD is not set | 37 | # CONFIG_KEYBOARD_ATKBD is not set |
38 | CONFIG_KEYBOARD_SPEAR=y | ||
20 | # CONFIG_INPUT_MOUSE is not set | 39 | # CONFIG_INPUT_MOUSE is not set |
40 | # CONFIG_LEGACY_PTYS is not set | ||
21 | CONFIG_SERIAL_AMBA_PL011=y | 41 | CONFIG_SERIAL_AMBA_PL011=y |
22 | CONFIG_SERIAL_AMBA_PL011_CONSOLE=y | 42 | CONFIG_SERIAL_AMBA_PL011_CONSOLE=y |
23 | # CONFIG_LEGACY_PTYS is not set | ||
24 | # CONFIG_HW_RANDOM is not set | 43 | # CONFIG_HW_RANDOM is not set |
25 | CONFIG_RAW_DRIVER=y | 44 | CONFIG_RAW_DRIVER=y |
26 | CONFIG_MAX_RAW_DEVS=8192 | 45 | CONFIG_MAX_RAW_DEVS=8192 |
46 | CONFIG_I2C=y | ||
47 | CONFIG_I2C_DESIGNWARE_PLATFORM=y | ||
48 | CONFIG_SPI=y | ||
49 | CONFIG_SPI_PL022=y | ||
27 | CONFIG_GPIO_SYSFS=y | 50 | CONFIG_GPIO_SYSFS=y |
28 | CONFIG_GPIO_PL061=y | 51 | CONFIG_GPIO_PL061=y |
29 | # CONFIG_HWMON is not set | 52 | # CONFIG_HWMON is not set |
53 | CONFIG_WATCHDOG=y | ||
54 | CONFIG_ARM_SP805_WATCHDOG=y | ||
55 | CONFIG_FB=y | ||
56 | CONFIG_FB_ARMCLCD=y | ||
30 | # CONFIG_HID_SUPPORT is not set | 57 | # CONFIG_HID_SUPPORT is not set |
31 | # CONFIG_USB_SUPPORT is not set | 58 | CONFIG_USB=y |
59 | # CONFIG_USB_DEVICE_CLASS is not set | ||
60 | CONFIG_USB_EHCI_HCD=y | ||
61 | CONFIG_USB_OHCI_HCD=y | ||
62 | CONFIG_MMC=y | ||
63 | CONFIG_MMC_SDHCI=y | ||
64 | CONFIG_MMC_SDHCI_SPEAR=y | ||
65 | CONFIG_RTC_CLASS=y | ||
66 | CONFIG_DMADEVICES=y | ||
67 | CONFIG_AMBA_PL08X=y | ||
68 | CONFIG_DMATEST=m | ||
32 | CONFIG_EXT2_FS=y | 69 | CONFIG_EXT2_FS=y |
33 | CONFIG_EXT2_FS_XATTR=y | 70 | CONFIG_EXT2_FS_XATTR=y |
34 | CONFIG_EXT2_FS_SECURITY=y | 71 | CONFIG_EXT2_FS_SECURITY=y |
@@ -39,8 +76,7 @@ CONFIG_MSDOS_FS=m | |||
39 | CONFIG_VFAT_FS=m | 76 | CONFIG_VFAT_FS=m |
40 | CONFIG_FAT_DEFAULT_IOCHARSET="ascii" | 77 | CONFIG_FAT_DEFAULT_IOCHARSET="ascii" |
41 | CONFIG_TMPFS=y | 78 | CONFIG_TMPFS=y |
42 | CONFIG_PARTITION_ADVANCED=y | 79 | CONFIG_JFFS2_FS=y |
43 | CONFIG_NLS=y | ||
44 | CONFIG_NLS_DEFAULT="utf8" | 80 | CONFIG_NLS_DEFAULT="utf8" |
45 | CONFIG_NLS_CODEPAGE_437=y | 81 | CONFIG_NLS_CODEPAGE_437=y |
46 | CONFIG_NLS_ASCII=m | 82 | CONFIG_NLS_ASCII=m |
@@ -48,6 +84,4 @@ CONFIG_MAGIC_SYSRQ=y | |||
48 | CONFIG_DEBUG_FS=y | 84 | CONFIG_DEBUG_FS=y |
49 | CONFIG_DEBUG_KERNEL=y | 85 | CONFIG_DEBUG_KERNEL=y |
50 | CONFIG_DEBUG_SPINLOCK=y | 86 | CONFIG_DEBUG_SPINLOCK=y |
51 | CONFIG_DEBUG_SPINLOCK_SLEEP=y | ||
52 | CONFIG_DEBUG_INFO=y | 87 | CONFIG_DEBUG_INFO=y |
53 | # CONFIG_CRC32 is not set | ||
diff --git a/arch/arm/configs/spear6xx_defconfig b/arch/arm/configs/spear6xx_defconfig index cef2e836afd2..a2a1265f86b6 100644 --- a/arch/arm/configs/spear6xx_defconfig +++ b/arch/arm/configs/spear6xx_defconfig | |||
@@ -2,29 +2,60 @@ CONFIG_EXPERIMENTAL=y | |||
2 | CONFIG_SYSVIPC=y | 2 | CONFIG_SYSVIPC=y |
3 | CONFIG_BSD_PROCESS_ACCT=y | 3 | CONFIG_BSD_PROCESS_ACCT=y |
4 | CONFIG_BLK_DEV_INITRD=y | 4 | CONFIG_BLK_DEV_INITRD=y |
5 | CONFIG_KALLSYMS_EXTRA_PASS=y | ||
6 | CONFIG_MODULES=y | 5 | CONFIG_MODULES=y |
7 | CONFIG_MODULE_UNLOAD=y | 6 | CONFIG_MODULE_UNLOAD=y |
8 | CONFIG_MODVERSIONS=y | 7 | CONFIG_MODVERSIONS=y |
8 | CONFIG_PARTITION_ADVANCED=y | ||
9 | CONFIG_PLAT_SPEAR=y | 9 | CONFIG_PLAT_SPEAR=y |
10 | CONFIG_ARCH_SPEAR6XX=y | 10 | CONFIG_ARCH_SPEAR6XX=y |
11 | CONFIG_BOARD_SPEAR600_EVB=y | ||
12 | CONFIG_BINFMT_MISC=y | 11 | CONFIG_BINFMT_MISC=y |
12 | CONFIG_NET=y | ||
13 | CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" | 13 | CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" |
14 | CONFIG_MTD=y | ||
15 | CONFIG_MTD_OF_PARTS=y | ||
16 | CONFIG_MTD_CHAR=y | ||
17 | CONFIG_MTD_BLOCK=y | ||
18 | CONFIG_MTD_NAND=y | ||
19 | CONFIG_MTD_NAND_FSMC=y | ||
14 | CONFIG_BLK_DEV_RAM=y | 20 | CONFIG_BLK_DEV_RAM=y |
15 | CONFIG_BLK_DEV_RAM_SIZE=16384 | 21 | CONFIG_BLK_DEV_RAM_SIZE=16384 |
22 | CONFIG_NETDEVICES=y | ||
23 | # CONFIG_NET_VENDOR_BROADCOM is not set | ||
24 | # CONFIG_NET_VENDOR_CIRRUS is not set | ||
25 | # CONFIG_NET_VENDOR_FARADAY is not set | ||
26 | # CONFIG_NET_VENDOR_INTEL is not set | ||
27 | # CONFIG_NET_VENDOR_MICREL is not set | ||
28 | # CONFIG_NET_VENDOR_NATSEMI is not set | ||
29 | # CONFIG_NET_VENDOR_SEEQ is not set | ||
30 | # CONFIG_NET_VENDOR_SMSC is not set | ||
31 | CONFIG_STMMAC_ETH=y | ||
32 | # CONFIG_WLAN is not set | ||
16 | CONFIG_INPUT_FF_MEMLESS=y | 33 | CONFIG_INPUT_FF_MEMLESS=y |
17 | # CONFIG_INPUT_MOUSEDEV_PSAUX is not set | 34 | # CONFIG_INPUT_MOUSEDEV_PSAUX is not set |
35 | # CONFIG_INPUT_KEYBOARD is not set | ||
36 | # CONFIG_INPUT_MOUSE is not set | ||
37 | # CONFIG_LEGACY_PTYS is not set | ||
18 | CONFIG_SERIAL_AMBA_PL011=y | 38 | CONFIG_SERIAL_AMBA_PL011=y |
19 | CONFIG_SERIAL_AMBA_PL011_CONSOLE=y | 39 | CONFIG_SERIAL_AMBA_PL011_CONSOLE=y |
20 | # CONFIG_LEGACY_PTYS is not set | ||
21 | CONFIG_RAW_DRIVER=y | 40 | CONFIG_RAW_DRIVER=y |
22 | CONFIG_MAX_RAW_DEVS=8192 | 41 | CONFIG_MAX_RAW_DEVS=8192 |
42 | CONFIG_I2C=y | ||
43 | CONFIG_I2C_DESIGNWARE_PLATFORM=y | ||
44 | CONFIG_SPI=y | ||
45 | CONFIG_SPI_PL022=y | ||
23 | CONFIG_GPIO_SYSFS=y | 46 | CONFIG_GPIO_SYSFS=y |
24 | CONFIG_GPIO_PL061=y | 47 | CONFIG_GPIO_PL061=y |
25 | # CONFIG_HWMON is not set | 48 | # CONFIG_HWMON is not set |
49 | CONFIG_WATCHDOG=y | ||
50 | CONFIG_ARM_SP805_WATCHDOG=y | ||
26 | # CONFIG_HID_SUPPORT is not set | 51 | # CONFIG_HID_SUPPORT is not set |
27 | # CONFIG_USB_SUPPORT is not set | 52 | CONFIG_USB=y |
53 | CONFIG_USB_EHCI_HCD=y | ||
54 | CONFIG_USB_OHCI_HCD=y | ||
55 | CONFIG_RTC_CLASS=y | ||
56 | CONFIG_DMADEVICES=y | ||
57 | CONFIG_AMBA_PL08X=y | ||
58 | CONFIG_DMATEST=m | ||
28 | CONFIG_EXT2_FS=y | 59 | CONFIG_EXT2_FS=y |
29 | CONFIG_EXT2_FS_XATTR=y | 60 | CONFIG_EXT2_FS_XATTR=y |
30 | CONFIG_EXT2_FS_SECURITY=y | 61 | CONFIG_EXT2_FS_SECURITY=y |
@@ -35,8 +66,7 @@ CONFIG_MSDOS_FS=m | |||
35 | CONFIG_VFAT_FS=m | 66 | CONFIG_VFAT_FS=m |
36 | CONFIG_FAT_DEFAULT_IOCHARSET="ascii" | 67 | CONFIG_FAT_DEFAULT_IOCHARSET="ascii" |
37 | CONFIG_TMPFS=y | 68 | CONFIG_TMPFS=y |
38 | CONFIG_PARTITION_ADVANCED=y | 69 | CONFIG_JFFS2_FS=y |
39 | CONFIG_NLS=y | ||
40 | CONFIG_NLS_DEFAULT="utf8" | 70 | CONFIG_NLS_DEFAULT="utf8" |
41 | CONFIG_NLS_CODEPAGE_437=y | 71 | CONFIG_NLS_CODEPAGE_437=y |
42 | CONFIG_NLS_ASCII=m | 72 | CONFIG_NLS_ASCII=m |
@@ -44,6 +74,4 @@ CONFIG_MAGIC_SYSRQ=y | |||
44 | CONFIG_DEBUG_FS=y | 74 | CONFIG_DEBUG_FS=y |
45 | CONFIG_DEBUG_KERNEL=y | 75 | CONFIG_DEBUG_KERNEL=y |
46 | CONFIG_DEBUG_SPINLOCK=y | 76 | CONFIG_DEBUG_SPINLOCK=y |
47 | CONFIG_DEBUG_SPINLOCK_SLEEP=y | ||
48 | CONFIG_DEBUG_INFO=y | 77 | CONFIG_DEBUG_INFO=y |
49 | # CONFIG_CRC32 is not set | ||
diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h index d4c24d412a8d..0f04d84582e1 100644 --- a/arch/arm/include/asm/thread_info.h +++ b/arch/arm/include/asm/thread_info.h | |||
@@ -118,6 +118,13 @@ extern void iwmmxt_task_switch(struct thread_info *); | |||
118 | extern void vfp_sync_hwstate(struct thread_info *); | 118 | extern void vfp_sync_hwstate(struct thread_info *); |
119 | extern void vfp_flush_hwstate(struct thread_info *); | 119 | extern void vfp_flush_hwstate(struct thread_info *); |
120 | 120 | ||
121 | struct user_vfp; | ||
122 | struct user_vfp_exc; | ||
123 | |||
124 | extern int vfp_preserve_user_clear_hwstate(struct user_vfp __user *, | ||
125 | struct user_vfp_exc __user *); | ||
126 | extern int vfp_restore_user_hwstate(struct user_vfp __user *, | ||
127 | struct user_vfp_exc __user *); | ||
121 | #endif | 128 | #endif |
122 | 129 | ||
123 | /* | 130 | /* |
diff --git a/arch/arm/include/asm/tls.h b/arch/arm/include/asm/tls.h index 60843eb0f61c..73409e6c0251 100644 --- a/arch/arm/include/asm/tls.h +++ b/arch/arm/include/asm/tls.h | |||
@@ -7,6 +7,8 @@ | |||
7 | 7 | ||
8 | .macro set_tls_v6k, tp, tmp1, tmp2 | 8 | .macro set_tls_v6k, tp, tmp1, tmp2 |
9 | mcr p15, 0, \tp, c13, c0, 3 @ set TLS register | 9 | mcr p15, 0, \tp, c13, c0, 3 @ set TLS register |
10 | mov \tmp1, #0 | ||
11 | mcr p15, 0, \tmp1, c13, c0, 2 @ clear user r/w TLS register | ||
10 | .endm | 12 | .endm |
11 | 13 | ||
12 | .macro set_tls_v6, tp, tmp1, tmp2 | 14 | .macro set_tls_v6, tp, tmp1, tmp2 |
@@ -15,6 +17,8 @@ | |||
15 | mov \tmp2, #0xffff0fff | 17 | mov \tmp2, #0xffff0fff |
16 | tst \tmp1, #HWCAP_TLS @ hardware TLS available? | 18 | tst \tmp1, #HWCAP_TLS @ hardware TLS available? |
17 | mcrne p15, 0, \tp, c13, c0, 3 @ yes, set TLS register | 19 | mcrne p15, 0, \tp, c13, c0, 3 @ yes, set TLS register |
20 | movne \tmp1, #0 | ||
21 | mcrne p15, 0, \tmp1, c13, c0, 2 @ clear user r/w TLS register | ||
18 | streq \tp, [\tmp2, #-15] @ set TLS value at 0xffff0ff0 | 22 | streq \tp, [\tmp2, #-15] @ set TLS value at 0xffff0ff0 |
19 | .endm | 23 | .endm |
20 | 24 | ||
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c index 71ccdbfed662..8349d4e97e2b 100644 --- a/arch/arm/kernel/irq.c +++ b/arch/arm/kernel/irq.c | |||
@@ -155,10 +155,10 @@ static bool migrate_one_irq(struct irq_desc *desc) | |||
155 | } | 155 | } |
156 | 156 | ||
157 | c = irq_data_get_irq_chip(d); | 157 | c = irq_data_get_irq_chip(d); |
158 | if (c->irq_set_affinity) | 158 | if (!c->irq_set_affinity) |
159 | c->irq_set_affinity(d, affinity, true); | ||
160 | else | ||
161 | pr_debug("IRQ%u: unable to set affinity\n", d->irq); | 159 | pr_debug("IRQ%u: unable to set affinity\n", d->irq); |
160 | else if (c->irq_set_affinity(d, affinity, true) == IRQ_SET_MASK_OK && ret) | ||
161 | cpumask_copy(d->affinity, affinity); | ||
162 | 162 | ||
163 | return ret; | 163 | return ret; |
164 | } | 164 | } |
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index 7cb532fc8aa4..d68d1b694680 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c | |||
@@ -180,44 +180,23 @@ static int restore_iwmmxt_context(struct iwmmxt_sigframe *frame) | |||
180 | 180 | ||
181 | static int preserve_vfp_context(struct vfp_sigframe __user *frame) | 181 | static int preserve_vfp_context(struct vfp_sigframe __user *frame) |
182 | { | 182 | { |
183 | struct thread_info *thread = current_thread_info(); | ||
184 | struct vfp_hard_struct *h = &thread->vfpstate.hard; | ||
185 | const unsigned long magic = VFP_MAGIC; | 183 | const unsigned long magic = VFP_MAGIC; |
186 | const unsigned long size = VFP_STORAGE_SIZE; | 184 | const unsigned long size = VFP_STORAGE_SIZE; |
187 | int err = 0; | 185 | int err = 0; |
188 | 186 | ||
189 | vfp_sync_hwstate(thread); | ||
190 | __put_user_error(magic, &frame->magic, err); | 187 | __put_user_error(magic, &frame->magic, err); |
191 | __put_user_error(size, &frame->size, err); | 188 | __put_user_error(size, &frame->size, err); |
192 | 189 | ||
193 | /* | 190 | if (err) |
194 | * Copy the floating point registers. There can be unused | 191 | return -EFAULT; |
195 | * registers see asm/hwcap.h for details. | ||
196 | */ | ||
197 | err |= __copy_to_user(&frame->ufp.fpregs, &h->fpregs, | ||
198 | sizeof(h->fpregs)); | ||
199 | /* | ||
200 | * Copy the status and control register. | ||
201 | */ | ||
202 | __put_user_error(h->fpscr, &frame->ufp.fpscr, err); | ||
203 | |||
204 | /* | ||
205 | * Copy the exception registers. | ||
206 | */ | ||
207 | __put_user_error(h->fpexc, &frame->ufp_exc.fpexc, err); | ||
208 | __put_user_error(h->fpinst, &frame->ufp_exc.fpinst, err); | ||
209 | __put_user_error(h->fpinst2, &frame->ufp_exc.fpinst2, err); | ||
210 | 192 | ||
211 | return err ? -EFAULT : 0; | 193 | return vfp_preserve_user_clear_hwstate(&frame->ufp, &frame->ufp_exc); |
212 | } | 194 | } |
213 | 195 | ||
214 | static int restore_vfp_context(struct vfp_sigframe __user *frame) | 196 | static int restore_vfp_context(struct vfp_sigframe __user *frame) |
215 | { | 197 | { |
216 | struct thread_info *thread = current_thread_info(); | ||
217 | struct vfp_hard_struct *h = &thread->vfpstate.hard; | ||
218 | unsigned long magic; | 198 | unsigned long magic; |
219 | unsigned long size; | 199 | unsigned long size; |
220 | unsigned long fpexc; | ||
221 | int err = 0; | 200 | int err = 0; |
222 | 201 | ||
223 | __get_user_error(magic, &frame->magic, err); | 202 | __get_user_error(magic, &frame->magic, err); |
@@ -228,33 +207,7 @@ static int restore_vfp_context(struct vfp_sigframe __user *frame) | |||
228 | if (magic != VFP_MAGIC || size != VFP_STORAGE_SIZE) | 207 | if (magic != VFP_MAGIC || size != VFP_STORAGE_SIZE) |
229 | return -EINVAL; | 208 | return -EINVAL; |
230 | 209 | ||
231 | vfp_flush_hwstate(thread); | 210 | return vfp_restore_user_hwstate(&frame->ufp, &frame->ufp_exc); |
232 | |||
233 | /* | ||
234 | * Copy the floating point registers. There can be unused | ||
235 | * registers see asm/hwcap.h for details. | ||
236 | */ | ||
237 | err |= __copy_from_user(&h->fpregs, &frame->ufp.fpregs, | ||
238 | sizeof(h->fpregs)); | ||
239 | /* | ||
240 | * Copy the status and control register. | ||
241 | */ | ||
242 | __get_user_error(h->fpscr, &frame->ufp.fpscr, err); | ||
243 | |||
244 | /* | ||
245 | * Sanitise and restore the exception registers. | ||
246 | */ | ||
247 | __get_user_error(fpexc, &frame->ufp_exc.fpexc, err); | ||
248 | /* Ensure the VFP is enabled. */ | ||
249 | fpexc |= FPEXC_EN; | ||
250 | /* Ensure FPINST2 is invalid and the exception flag is cleared. */ | ||
251 | fpexc &= ~(FPEXC_EX | FPEXC_FP2V); | ||
252 | h->fpexc = fpexc; | ||
253 | |||
254 | __get_user_error(h->fpinst, &frame->ufp_exc.fpinst, err); | ||
255 | __get_user_error(h->fpinst2, &frame->ufp_exc.fpinst2, err); | ||
256 | |||
257 | return err ? -EFAULT : 0; | ||
258 | } | 211 | } |
259 | 212 | ||
260 | #endif | 213 | #endif |
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index addbbe8028c2..f6a4d32b0421 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c | |||
@@ -510,10 +510,6 @@ static void ipi_cpu_stop(unsigned int cpu) | |||
510 | local_fiq_disable(); | 510 | local_fiq_disable(); |
511 | local_irq_disable(); | 511 | local_irq_disable(); |
512 | 512 | ||
513 | #ifdef CONFIG_HOTPLUG_CPU | ||
514 | platform_cpu_kill(cpu); | ||
515 | #endif | ||
516 | |||
517 | while (1) | 513 | while (1) |
518 | cpu_relax(); | 514 | cpu_relax(); |
519 | } | 515 | } |
@@ -576,17 +572,25 @@ void smp_send_reschedule(int cpu) | |||
576 | smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE); | 572 | smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE); |
577 | } | 573 | } |
578 | 574 | ||
575 | #ifdef CONFIG_HOTPLUG_CPU | ||
576 | static void smp_kill_cpus(cpumask_t *mask) | ||
577 | { | ||
578 | unsigned int cpu; | ||
579 | for_each_cpu(cpu, mask) | ||
580 | platform_cpu_kill(cpu); | ||
581 | } | ||
582 | #else | ||
583 | static void smp_kill_cpus(cpumask_t *mask) { } | ||
584 | #endif | ||
585 | |||
579 | void smp_send_stop(void) | 586 | void smp_send_stop(void) |
580 | { | 587 | { |
581 | unsigned long timeout; | 588 | unsigned long timeout; |
589 | struct cpumask mask; | ||
582 | 590 | ||
583 | if (num_online_cpus() > 1) { | 591 | cpumask_copy(&mask, cpu_online_mask); |
584 | struct cpumask mask; | 592 | cpumask_clear_cpu(smp_processor_id(), &mask); |
585 | cpumask_copy(&mask, cpu_online_mask); | 593 | smp_cross_call(&mask, IPI_CPU_STOP); |
586 | cpumask_clear_cpu(smp_processor_id(), &mask); | ||
587 | |||
588 | smp_cross_call(&mask, IPI_CPU_STOP); | ||
589 | } | ||
590 | 594 | ||
591 | /* Wait up to one second for other CPUs to stop */ | 595 | /* Wait up to one second for other CPUs to stop */ |
592 | timeout = USEC_PER_SEC; | 596 | timeout = USEC_PER_SEC; |
@@ -595,6 +599,8 @@ void smp_send_stop(void) | |||
595 | 599 | ||
596 | if (num_online_cpus() > 1) | 600 | if (num_online_cpus() > 1) |
597 | pr_warning("SMP: failed to stop secondary CPUs\n"); | 601 | pr_warning("SMP: failed to stop secondary CPUs\n"); |
602 | |||
603 | smp_kill_cpus(&mask); | ||
598 | } | 604 | } |
599 | 605 | ||
600 | /* | 606 | /* |
diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c index 5b150afb995b..fef42b21cecb 100644 --- a/arch/arm/kernel/smp_twd.c +++ b/arch/arm/kernel/smp_twd.c | |||
@@ -118,14 +118,10 @@ static int twd_cpufreq_transition(struct notifier_block *nb, | |||
118 | * The twd clock events must be reprogrammed to account for the new | 118 | * The twd clock events must be reprogrammed to account for the new |
119 | * frequency. The timer is local to a cpu, so cross-call to the | 119 | * frequency. The timer is local to a cpu, so cross-call to the |
120 | * changing cpu. | 120 | * changing cpu. |
121 | * | ||
122 | * Only wait for it to finish, if the cpu is active to avoid | ||
123 | * deadlock when cpu1 is spinning on while(!cpu_active(cpu1)) during | ||
124 | * booting of that cpu. | ||
125 | */ | 121 | */ |
126 | if (state == CPUFREQ_POSTCHANGE || state == CPUFREQ_RESUMECHANGE) | 122 | if (state == CPUFREQ_POSTCHANGE || state == CPUFREQ_RESUMECHANGE) |
127 | smp_call_function_single(freqs->cpu, twd_update_frequency, | 123 | smp_call_function_single(freqs->cpu, twd_update_frequency, |
128 | NULL, cpu_active(freqs->cpu)); | 124 | NULL, 1); |
129 | 125 | ||
130 | return NOTIFY_OK; | 126 | return NOTIFY_OK; |
131 | } | 127 | } |
diff --git a/arch/arm/mach-exynos/clock-exynos4.c b/arch/arm/mach-exynos/clock-exynos4.c index df54c2a92225..6efd1e5919fd 100644 --- a/arch/arm/mach-exynos/clock-exynos4.c +++ b/arch/arm/mach-exynos/clock-exynos4.c | |||
@@ -497,25 +497,25 @@ static struct clk exynos4_init_clocks_off[] = { | |||
497 | .ctrlbit = (1 << 3), | 497 | .ctrlbit = (1 << 3), |
498 | }, { | 498 | }, { |
499 | .name = "hsmmc", | 499 | .name = "hsmmc", |
500 | .devname = "s3c-sdhci.0", | 500 | .devname = "exynos4-sdhci.0", |
501 | .parent = &exynos4_clk_aclk_133.clk, | 501 | .parent = &exynos4_clk_aclk_133.clk, |
502 | .enable = exynos4_clk_ip_fsys_ctrl, | 502 | .enable = exynos4_clk_ip_fsys_ctrl, |
503 | .ctrlbit = (1 << 5), | 503 | .ctrlbit = (1 << 5), |
504 | }, { | 504 | }, { |
505 | .name = "hsmmc", | 505 | .name = "hsmmc", |
506 | .devname = "s3c-sdhci.1", | 506 | .devname = "exynos4-sdhci.1", |
507 | .parent = &exynos4_clk_aclk_133.clk, | 507 | .parent = &exynos4_clk_aclk_133.clk, |
508 | .enable = exynos4_clk_ip_fsys_ctrl, | 508 | .enable = exynos4_clk_ip_fsys_ctrl, |
509 | .ctrlbit = (1 << 6), | 509 | .ctrlbit = (1 << 6), |
510 | }, { | 510 | }, { |
511 | .name = "hsmmc", | 511 | .name = "hsmmc", |
512 | .devname = "s3c-sdhci.2", | 512 | .devname = "exynos4-sdhci.2", |
513 | .parent = &exynos4_clk_aclk_133.clk, | 513 | .parent = &exynos4_clk_aclk_133.clk, |
514 | .enable = exynos4_clk_ip_fsys_ctrl, | 514 | .enable = exynos4_clk_ip_fsys_ctrl, |
515 | .ctrlbit = (1 << 7), | 515 | .ctrlbit = (1 << 7), |
516 | }, { | 516 | }, { |
517 | .name = "hsmmc", | 517 | .name = "hsmmc", |
518 | .devname = "s3c-sdhci.3", | 518 | .devname = "exynos4-sdhci.3", |
519 | .parent = &exynos4_clk_aclk_133.clk, | 519 | .parent = &exynos4_clk_aclk_133.clk, |
520 | .enable = exynos4_clk_ip_fsys_ctrl, | 520 | .enable = exynos4_clk_ip_fsys_ctrl, |
521 | .ctrlbit = (1 << 8), | 521 | .ctrlbit = (1 << 8), |
@@ -1202,7 +1202,7 @@ static struct clksrc_clk exynos4_clk_sclk_uart3 = { | |||
1202 | static struct clksrc_clk exynos4_clk_sclk_mmc0 = { | 1202 | static struct clksrc_clk exynos4_clk_sclk_mmc0 = { |
1203 | .clk = { | 1203 | .clk = { |
1204 | .name = "sclk_mmc", | 1204 | .name = "sclk_mmc", |
1205 | .devname = "s3c-sdhci.0", | 1205 | .devname = "exynos4-sdhci.0", |
1206 | .parent = &exynos4_clk_dout_mmc0.clk, | 1206 | .parent = &exynos4_clk_dout_mmc0.clk, |
1207 | .enable = exynos4_clksrc_mask_fsys_ctrl, | 1207 | .enable = exynos4_clksrc_mask_fsys_ctrl, |
1208 | .ctrlbit = (1 << 0), | 1208 | .ctrlbit = (1 << 0), |
@@ -1213,7 +1213,7 @@ static struct clksrc_clk exynos4_clk_sclk_mmc0 = { | |||
1213 | static struct clksrc_clk exynos4_clk_sclk_mmc1 = { | 1213 | static struct clksrc_clk exynos4_clk_sclk_mmc1 = { |
1214 | .clk = { | 1214 | .clk = { |
1215 | .name = "sclk_mmc", | 1215 | .name = "sclk_mmc", |
1216 | .devname = "s3c-sdhci.1", | 1216 | .devname = "exynos4-sdhci.1", |
1217 | .parent = &exynos4_clk_dout_mmc1.clk, | 1217 | .parent = &exynos4_clk_dout_mmc1.clk, |
1218 | .enable = exynos4_clksrc_mask_fsys_ctrl, | 1218 | .enable = exynos4_clksrc_mask_fsys_ctrl, |
1219 | .ctrlbit = (1 << 4), | 1219 | .ctrlbit = (1 << 4), |
@@ -1224,7 +1224,7 @@ static struct clksrc_clk exynos4_clk_sclk_mmc1 = { | |||
1224 | static struct clksrc_clk exynos4_clk_sclk_mmc2 = { | 1224 | static struct clksrc_clk exynos4_clk_sclk_mmc2 = { |
1225 | .clk = { | 1225 | .clk = { |
1226 | .name = "sclk_mmc", | 1226 | .name = "sclk_mmc", |
1227 | .devname = "s3c-sdhci.2", | 1227 | .devname = "exynos4-sdhci.2", |
1228 | .parent = &exynos4_clk_dout_mmc2.clk, | 1228 | .parent = &exynos4_clk_dout_mmc2.clk, |
1229 | .enable = exynos4_clksrc_mask_fsys_ctrl, | 1229 | .enable = exynos4_clksrc_mask_fsys_ctrl, |
1230 | .ctrlbit = (1 << 8), | 1230 | .ctrlbit = (1 << 8), |
@@ -1235,7 +1235,7 @@ static struct clksrc_clk exynos4_clk_sclk_mmc2 = { | |||
1235 | static struct clksrc_clk exynos4_clk_sclk_mmc3 = { | 1235 | static struct clksrc_clk exynos4_clk_sclk_mmc3 = { |
1236 | .clk = { | 1236 | .clk = { |
1237 | .name = "sclk_mmc", | 1237 | .name = "sclk_mmc", |
1238 | .devname = "s3c-sdhci.3", | 1238 | .devname = "exynos4-sdhci.3", |
1239 | .parent = &exynos4_clk_dout_mmc3.clk, | 1239 | .parent = &exynos4_clk_dout_mmc3.clk, |
1240 | .enable = exynos4_clksrc_mask_fsys_ctrl, | 1240 | .enable = exynos4_clksrc_mask_fsys_ctrl, |
1241 | .ctrlbit = (1 << 12), | 1241 | .ctrlbit = (1 << 12), |
@@ -1340,10 +1340,10 @@ static struct clk_lookup exynos4_clk_lookup[] = { | |||
1340 | CLKDEV_INIT("exynos4210-uart.1", "clk_uart_baud0", &exynos4_clk_sclk_uart1.clk), | 1340 | CLKDEV_INIT("exynos4210-uart.1", "clk_uart_baud0", &exynos4_clk_sclk_uart1.clk), |
1341 | CLKDEV_INIT("exynos4210-uart.2", "clk_uart_baud0", &exynos4_clk_sclk_uart2.clk), | 1341 | CLKDEV_INIT("exynos4210-uart.2", "clk_uart_baud0", &exynos4_clk_sclk_uart2.clk), |
1342 | CLKDEV_INIT("exynos4210-uart.3", "clk_uart_baud0", &exynos4_clk_sclk_uart3.clk), | 1342 | CLKDEV_INIT("exynos4210-uart.3", "clk_uart_baud0", &exynos4_clk_sclk_uart3.clk), |
1343 | CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &exynos4_clk_sclk_mmc0.clk), | 1343 | CLKDEV_INIT("exynos4-sdhci.0", "mmc_busclk.2", &exynos4_clk_sclk_mmc0.clk), |
1344 | CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &exynos4_clk_sclk_mmc1.clk), | 1344 | CLKDEV_INIT("exynos4-sdhci.1", "mmc_busclk.2", &exynos4_clk_sclk_mmc1.clk), |
1345 | CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &exynos4_clk_sclk_mmc2.clk), | 1345 | CLKDEV_INIT("exynos4-sdhci.2", "mmc_busclk.2", &exynos4_clk_sclk_mmc2.clk), |
1346 | CLKDEV_INIT("s3c-sdhci.3", "mmc_busclk.2", &exynos4_clk_sclk_mmc3.clk), | 1346 | CLKDEV_INIT("exynos4-sdhci.3", "mmc_busclk.2", &exynos4_clk_sclk_mmc3.clk), |
1347 | CLKDEV_INIT("exynos4-fb.0", "lcd", &exynos4_clk_fimd0), | 1347 | CLKDEV_INIT("exynos4-fb.0", "lcd", &exynos4_clk_fimd0), |
1348 | CLKDEV_INIT("dma-pl330.0", "apb_pclk", &exynos4_clk_pdma0), | 1348 | CLKDEV_INIT("dma-pl330.0", "apb_pclk", &exynos4_clk_pdma0), |
1349 | CLKDEV_INIT("dma-pl330.1", "apb_pclk", &exynos4_clk_pdma1), | 1349 | CLKDEV_INIT("dma-pl330.1", "apb_pclk", &exynos4_clk_pdma1), |
diff --git a/arch/arm/mach-exynos/clock-exynos5.c b/arch/arm/mach-exynos/clock-exynos5.c index d013982d0f8e..5cd7a8b8868c 100644 --- a/arch/arm/mach-exynos/clock-exynos5.c +++ b/arch/arm/mach-exynos/clock-exynos5.c | |||
@@ -455,25 +455,25 @@ static struct clk exynos5_init_clocks_off[] = { | |||
455 | .ctrlbit = (1 << 20), | 455 | .ctrlbit = (1 << 20), |
456 | }, { | 456 | }, { |
457 | .name = "hsmmc", | 457 | .name = "hsmmc", |
458 | .devname = "s3c-sdhci.0", | 458 | .devname = "exynos4-sdhci.0", |
459 | .parent = &exynos5_clk_aclk_200.clk, | 459 | .parent = &exynos5_clk_aclk_200.clk, |
460 | .enable = exynos5_clk_ip_fsys_ctrl, | 460 | .enable = exynos5_clk_ip_fsys_ctrl, |
461 | .ctrlbit = (1 << 12), | 461 | .ctrlbit = (1 << 12), |
462 | }, { | 462 | }, { |
463 | .name = "hsmmc", | 463 | .name = "hsmmc", |
464 | .devname = "s3c-sdhci.1", | 464 | .devname = "exynos4-sdhci.1", |
465 | .parent = &exynos5_clk_aclk_200.clk, | 465 | .parent = &exynos5_clk_aclk_200.clk, |
466 | .enable = exynos5_clk_ip_fsys_ctrl, | 466 | .enable = exynos5_clk_ip_fsys_ctrl, |
467 | .ctrlbit = (1 << 13), | 467 | .ctrlbit = (1 << 13), |
468 | }, { | 468 | }, { |
469 | .name = "hsmmc", | 469 | .name = "hsmmc", |
470 | .devname = "s3c-sdhci.2", | 470 | .devname = "exynos4-sdhci.2", |
471 | .parent = &exynos5_clk_aclk_200.clk, | 471 | .parent = &exynos5_clk_aclk_200.clk, |
472 | .enable = exynos5_clk_ip_fsys_ctrl, | 472 | .enable = exynos5_clk_ip_fsys_ctrl, |
473 | .ctrlbit = (1 << 14), | 473 | .ctrlbit = (1 << 14), |
474 | }, { | 474 | }, { |
475 | .name = "hsmmc", | 475 | .name = "hsmmc", |
476 | .devname = "s3c-sdhci.3", | 476 | .devname = "exynos4-sdhci.3", |
477 | .parent = &exynos5_clk_aclk_200.clk, | 477 | .parent = &exynos5_clk_aclk_200.clk, |
478 | .enable = exynos5_clk_ip_fsys_ctrl, | 478 | .enable = exynos5_clk_ip_fsys_ctrl, |
479 | .ctrlbit = (1 << 15), | 479 | .ctrlbit = (1 << 15), |
@@ -813,7 +813,7 @@ static struct clksrc_clk exynos5_clk_sclk_uart3 = { | |||
813 | static struct clksrc_clk exynos5_clk_sclk_mmc0 = { | 813 | static struct clksrc_clk exynos5_clk_sclk_mmc0 = { |
814 | .clk = { | 814 | .clk = { |
815 | .name = "sclk_mmc", | 815 | .name = "sclk_mmc", |
816 | .devname = "s3c-sdhci.0", | 816 | .devname = "exynos4-sdhci.0", |
817 | .parent = &exynos5_clk_dout_mmc0.clk, | 817 | .parent = &exynos5_clk_dout_mmc0.clk, |
818 | .enable = exynos5_clksrc_mask_fsys_ctrl, | 818 | .enable = exynos5_clksrc_mask_fsys_ctrl, |
819 | .ctrlbit = (1 << 0), | 819 | .ctrlbit = (1 << 0), |
@@ -824,7 +824,7 @@ static struct clksrc_clk exynos5_clk_sclk_mmc0 = { | |||
824 | static struct clksrc_clk exynos5_clk_sclk_mmc1 = { | 824 | static struct clksrc_clk exynos5_clk_sclk_mmc1 = { |
825 | .clk = { | 825 | .clk = { |
826 | .name = "sclk_mmc", | 826 | .name = "sclk_mmc", |
827 | .devname = "s3c-sdhci.1", | 827 | .devname = "exynos4-sdhci.1", |
828 | .parent = &exynos5_clk_dout_mmc1.clk, | 828 | .parent = &exynos5_clk_dout_mmc1.clk, |
829 | .enable = exynos5_clksrc_mask_fsys_ctrl, | 829 | .enable = exynos5_clksrc_mask_fsys_ctrl, |
830 | .ctrlbit = (1 << 4), | 830 | .ctrlbit = (1 << 4), |
@@ -835,7 +835,7 @@ static struct clksrc_clk exynos5_clk_sclk_mmc1 = { | |||
835 | static struct clksrc_clk exynos5_clk_sclk_mmc2 = { | 835 | static struct clksrc_clk exynos5_clk_sclk_mmc2 = { |
836 | .clk = { | 836 | .clk = { |
837 | .name = "sclk_mmc", | 837 | .name = "sclk_mmc", |
838 | .devname = "s3c-sdhci.2", | 838 | .devname = "exynos4-sdhci.2", |
839 | .parent = &exynos5_clk_dout_mmc2.clk, | 839 | .parent = &exynos5_clk_dout_mmc2.clk, |
840 | .enable = exynos5_clksrc_mask_fsys_ctrl, | 840 | .enable = exynos5_clksrc_mask_fsys_ctrl, |
841 | .ctrlbit = (1 << 8), | 841 | .ctrlbit = (1 << 8), |
@@ -846,7 +846,7 @@ static struct clksrc_clk exynos5_clk_sclk_mmc2 = { | |||
846 | static struct clksrc_clk exynos5_clk_sclk_mmc3 = { | 846 | static struct clksrc_clk exynos5_clk_sclk_mmc3 = { |
847 | .clk = { | 847 | .clk = { |
848 | .name = "sclk_mmc", | 848 | .name = "sclk_mmc", |
849 | .devname = "s3c-sdhci.3", | 849 | .devname = "exynos4-sdhci.3", |
850 | .parent = &exynos5_clk_dout_mmc3.clk, | 850 | .parent = &exynos5_clk_dout_mmc3.clk, |
851 | .enable = exynos5_clksrc_mask_fsys_ctrl, | 851 | .enable = exynos5_clksrc_mask_fsys_ctrl, |
852 | .ctrlbit = (1 << 12), | 852 | .ctrlbit = (1 << 12), |
@@ -990,10 +990,10 @@ static struct clk_lookup exynos5_clk_lookup[] = { | |||
990 | CLKDEV_INIT("exynos4210-uart.1", "clk_uart_baud0", &exynos5_clk_sclk_uart1.clk), | 990 | CLKDEV_INIT("exynos4210-uart.1", "clk_uart_baud0", &exynos5_clk_sclk_uart1.clk), |
991 | CLKDEV_INIT("exynos4210-uart.2", "clk_uart_baud0", &exynos5_clk_sclk_uart2.clk), | 991 | CLKDEV_INIT("exynos4210-uart.2", "clk_uart_baud0", &exynos5_clk_sclk_uart2.clk), |
992 | CLKDEV_INIT("exynos4210-uart.3", "clk_uart_baud0", &exynos5_clk_sclk_uart3.clk), | 992 | CLKDEV_INIT("exynos4210-uart.3", "clk_uart_baud0", &exynos5_clk_sclk_uart3.clk), |
993 | CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &exynos5_clk_sclk_mmc0.clk), | 993 | CLKDEV_INIT("exynos4-sdhci.0", "mmc_busclk.2", &exynos5_clk_sclk_mmc0.clk), |
994 | CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &exynos5_clk_sclk_mmc1.clk), | 994 | CLKDEV_INIT("exynos4-sdhci.1", "mmc_busclk.2", &exynos5_clk_sclk_mmc1.clk), |
995 | CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &exynos5_clk_sclk_mmc2.clk), | 995 | CLKDEV_INIT("exynos4-sdhci.2", "mmc_busclk.2", &exynos5_clk_sclk_mmc2.clk), |
996 | CLKDEV_INIT("s3c-sdhci.3", "mmc_busclk.2", &exynos5_clk_sclk_mmc3.clk), | 996 | CLKDEV_INIT("exynos4-sdhci.3", "mmc_busclk.2", &exynos5_clk_sclk_mmc3.clk), |
997 | CLKDEV_INIT("dma-pl330.0", "apb_pclk", &exynos5_clk_pdma0), | 997 | CLKDEV_INIT("dma-pl330.0", "apb_pclk", &exynos5_clk_pdma0), |
998 | CLKDEV_INIT("dma-pl330.1", "apb_pclk", &exynos5_clk_pdma1), | 998 | CLKDEV_INIT("dma-pl330.1", "apb_pclk", &exynos5_clk_pdma1), |
999 | CLKDEV_INIT("dma-pl330.2", "apb_pclk", &exynos5_clk_mdma1), | 999 | CLKDEV_INIT("dma-pl330.2", "apb_pclk", &exynos5_clk_mdma1), |
diff --git a/arch/arm/mach-exynos/common.c b/arch/arm/mach-exynos/common.c index 8614aab47cc0..5ccd6e80a607 100644 --- a/arch/arm/mach-exynos/common.c +++ b/arch/arm/mach-exynos/common.c | |||
@@ -326,6 +326,11 @@ static void __init exynos4_map_io(void) | |||
326 | s3c_fimc_setname(2, "exynos4-fimc"); | 326 | s3c_fimc_setname(2, "exynos4-fimc"); |
327 | s3c_fimc_setname(3, "exynos4-fimc"); | 327 | s3c_fimc_setname(3, "exynos4-fimc"); |
328 | 328 | ||
329 | s3c_sdhci_setname(0, "exynos4-sdhci"); | ||
330 | s3c_sdhci_setname(1, "exynos4-sdhci"); | ||
331 | s3c_sdhci_setname(2, "exynos4-sdhci"); | ||
332 | s3c_sdhci_setname(3, "exynos4-sdhci"); | ||
333 | |||
329 | /* The I2C bus controllers are directly compatible with s3c2440 */ | 334 | /* The I2C bus controllers are directly compatible with s3c2440 */ |
330 | s3c_i2c0_setname("s3c2440-i2c"); | 335 | s3c_i2c0_setname("s3c2440-i2c"); |
331 | s3c_i2c1_setname("s3c2440-i2c"); | 336 | s3c_i2c1_setname("s3c2440-i2c"); |
@@ -344,6 +349,11 @@ static void __init exynos5_map_io(void) | |||
344 | s3c_device_i2c0.resource[1].start = EXYNOS5_IRQ_IIC; | 349 | s3c_device_i2c0.resource[1].start = EXYNOS5_IRQ_IIC; |
345 | s3c_device_i2c0.resource[1].end = EXYNOS5_IRQ_IIC; | 350 | s3c_device_i2c0.resource[1].end = EXYNOS5_IRQ_IIC; |
346 | 351 | ||
352 | s3c_sdhci_setname(0, "exynos4-sdhci"); | ||
353 | s3c_sdhci_setname(1, "exynos4-sdhci"); | ||
354 | s3c_sdhci_setname(2, "exynos4-sdhci"); | ||
355 | s3c_sdhci_setname(3, "exynos4-sdhci"); | ||
356 | |||
347 | /* The I2C bus controllers are directly compatible with s3c2440 */ | 357 | /* The I2C bus controllers are directly compatible with s3c2440 */ |
348 | s3c_i2c0_setname("s3c2440-i2c"); | 358 | s3c_i2c0_setname("s3c2440-i2c"); |
349 | s3c_i2c1_setname("s3c2440-i2c"); | 359 | s3c_i2c1_setname("s3c2440-i2c"); |
@@ -537,7 +547,9 @@ void __init exynos5_init_irq(void) | |||
537 | { | 547 | { |
538 | int irq; | 548 | int irq; |
539 | 549 | ||
540 | gic_init(0, IRQ_PPI(0), S5P_VA_GIC_DIST, S5P_VA_GIC_CPU); | 550 | #ifdef CONFIG_OF |
551 | of_irq_init(exynos4_dt_irq_match); | ||
552 | #endif | ||
541 | 553 | ||
542 | for (irq = 0; irq < EXYNOS5_MAX_COMBINER_NR; irq++) { | 554 | for (irq = 0; irq < EXYNOS5_MAX_COMBINER_NR; irq++) { |
543 | combiner_init(irq, (void __iomem *)S5P_VA_COMBINER(irq), | 555 | combiner_init(irq, (void __iomem *)S5P_VA_COMBINER(irq), |
diff --git a/arch/arm/mach-exynos/dev-dwmci.c b/arch/arm/mach-exynos/dev-dwmci.c index b025db4bf602..79035018fb74 100644 --- a/arch/arm/mach-exynos/dev-dwmci.c +++ b/arch/arm/mach-exynos/dev-dwmci.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/dma-mapping.h> | 16 | #include <linux/dma-mapping.h> |
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | #include <linux/ioport.h> | ||
19 | #include <linux/mmc/dw_mmc.h> | 20 | #include <linux/mmc/dw_mmc.h> |
20 | 21 | ||
21 | #include <plat/devs.h> | 22 | #include <plat/devs.h> |
@@ -33,16 +34,8 @@ static int exynos4_dwmci_init(u32 slot_id, irq_handler_t handler, void *data) | |||
33 | } | 34 | } |
34 | 35 | ||
35 | static struct resource exynos4_dwmci_resource[] = { | 36 | static struct resource exynos4_dwmci_resource[] = { |
36 | [0] = { | 37 | [0] = DEFINE_RES_MEM(EXYNOS4_PA_DWMCI, SZ_4K), |
37 | .start = EXYNOS4_PA_DWMCI, | 38 | [1] = DEFINE_RES_IRQ(EXYNOS4_IRQ_DWMCI), |
38 | .end = EXYNOS4_PA_DWMCI + SZ_4K - 1, | ||
39 | .flags = IORESOURCE_MEM, | ||
40 | }, | ||
41 | [1] = { | ||
42 | .start = IRQ_DWMCI, | ||
43 | .end = IRQ_DWMCI, | ||
44 | .flags = IORESOURCE_IRQ, | ||
45 | } | ||
46 | }; | 39 | }; |
47 | 40 | ||
48 | static struct dw_mci_board exynos4_dwci_pdata = { | 41 | static struct dw_mci_board exynos4_dwci_pdata = { |
diff --git a/arch/arm/mach-exynos/mach-nuri.c b/arch/arm/mach-exynos/mach-nuri.c index b4f1f902ce6d..ed90aef404c3 100644 --- a/arch/arm/mach-exynos/mach-nuri.c +++ b/arch/arm/mach-exynos/mach-nuri.c | |||
@@ -112,6 +112,7 @@ static struct s3c_sdhci_platdata nuri_hsmmc0_data __initdata = { | |||
112 | .host_caps = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA | | 112 | .host_caps = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA | |
113 | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED | | 113 | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED | |
114 | MMC_CAP_ERASE), | 114 | MMC_CAP_ERASE), |
115 | .host_caps2 = MMC_CAP2_BROKEN_VOLTAGE, | ||
115 | .cd_type = S3C_SDHCI_CD_PERMANENT, | 116 | .cd_type = S3C_SDHCI_CD_PERMANENT, |
116 | .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL, | 117 | .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL, |
117 | }; | 118 | }; |
diff --git a/arch/arm/mach-exynos/mach-universal_c210.c b/arch/arm/mach-exynos/mach-universal_c210.c index 7ebf79c2ab34..cb2b027f09a6 100644 --- a/arch/arm/mach-exynos/mach-universal_c210.c +++ b/arch/arm/mach-exynos/mach-universal_c210.c | |||
@@ -747,6 +747,7 @@ static struct s3c_sdhci_platdata universal_hsmmc0_data __initdata = { | |||
747 | .max_width = 8, | 747 | .max_width = 8, |
748 | .host_caps = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA | | 748 | .host_caps = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA | |
749 | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED), | 749 | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED), |
750 | .host_caps2 = MMC_CAP2_BROKEN_VOLTAGE, | ||
750 | .cd_type = S3C_SDHCI_CD_PERMANENT, | 751 | .cd_type = S3C_SDHCI_CD_PERMANENT, |
751 | .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL, | 752 | .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL, |
752 | }; | 753 | }; |
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index 7561eca131b0..a57a8ecfd93f 100644 --- a/arch/arm/mach-imx/Kconfig +++ b/arch/arm/mach-imx/Kconfig | |||
@@ -34,6 +34,7 @@ config ARCH_MX53 | |||
34 | config SOC_IMX1 | 34 | config SOC_IMX1 |
35 | bool | 35 | bool |
36 | select ARCH_MX1 | 36 | select ARCH_MX1 |
37 | select COMMON_CLK | ||
37 | select CPU_ARM920T | 38 | select CPU_ARM920T |
38 | select IMX_HAVE_IOMUX_V1 | 39 | select IMX_HAVE_IOMUX_V1 |
39 | select MXC_AVIC | 40 | select MXC_AVIC |
@@ -42,12 +43,14 @@ config SOC_IMX21 | |||
42 | bool | 43 | bool |
43 | select MACH_MX21 | 44 | select MACH_MX21 |
44 | select CPU_ARM926T | 45 | select CPU_ARM926T |
46 | select COMMON_CLK | ||
45 | select IMX_HAVE_IOMUX_V1 | 47 | select IMX_HAVE_IOMUX_V1 |
46 | select MXC_AVIC | 48 | select MXC_AVIC |
47 | 49 | ||
48 | config SOC_IMX25 | 50 | config SOC_IMX25 |
49 | bool | 51 | bool |
50 | select ARCH_MX25 | 52 | select ARCH_MX25 |
53 | select COMMON_CLK | ||
51 | select CPU_ARM926T | 54 | select CPU_ARM926T |
52 | select ARCH_MXC_IOMUX_V3 | 55 | select ARCH_MXC_IOMUX_V3 |
53 | select MXC_AVIC | 56 | select MXC_AVIC |
@@ -56,6 +59,7 @@ config SOC_IMX27 | |||
56 | bool | 59 | bool |
57 | select MACH_MX27 | 60 | select MACH_MX27 |
58 | select CPU_ARM926T | 61 | select CPU_ARM926T |
62 | select COMMON_CLK | ||
59 | select IMX_HAVE_IOMUX_V1 | 63 | select IMX_HAVE_IOMUX_V1 |
60 | select MXC_AVIC | 64 | select MXC_AVIC |
61 | 65 | ||
@@ -64,12 +68,14 @@ config SOC_IMX31 | |||
64 | select CPU_V6 | 68 | select CPU_V6 |
65 | select IMX_HAVE_PLATFORM_MXC_RNGA | 69 | select IMX_HAVE_PLATFORM_MXC_RNGA |
66 | select MXC_AVIC | 70 | select MXC_AVIC |
71 | select COMMON_CLK | ||
67 | select SMP_ON_UP if SMP | 72 | select SMP_ON_UP if SMP |
68 | 73 | ||
69 | config SOC_IMX35 | 74 | config SOC_IMX35 |
70 | bool | 75 | bool |
71 | select CPU_V6 | 76 | select CPU_V6 |
72 | select ARCH_MXC_IOMUX_V3 | 77 | select ARCH_MXC_IOMUX_V3 |
78 | select COMMON_CLK | ||
73 | select HAVE_EPIT | 79 | select HAVE_EPIT |
74 | select MXC_AVIC | 80 | select MXC_AVIC |
75 | select SMP_ON_UP if SMP | 81 | select SMP_ON_UP if SMP |
@@ -77,6 +83,7 @@ config SOC_IMX35 | |||
77 | config SOC_IMX5 | 83 | config SOC_IMX5 |
78 | select CPU_V7 | 84 | select CPU_V7 |
79 | select MXC_TZIC | 85 | select MXC_TZIC |
86 | select COMMON_CLK | ||
80 | select ARCH_MXC_IOMUX_V3 | 87 | select ARCH_MXC_IOMUX_V3 |
81 | select ARCH_HAS_CPUFREQ | 88 | select ARCH_HAS_CPUFREQ |
82 | select ARCH_MX5 | 89 | select ARCH_MX5 |
@@ -836,12 +843,15 @@ config SOC_IMX6Q | |||
836 | bool "i.MX6 Quad support" | 843 | bool "i.MX6 Quad support" |
837 | select ARM_CPU_SUSPEND if PM | 844 | select ARM_CPU_SUSPEND if PM |
838 | select ARM_GIC | 845 | select ARM_GIC |
846 | select COMMON_CLK | ||
839 | select CPU_V7 | 847 | select CPU_V7 |
840 | select HAVE_ARM_SCU | 848 | select HAVE_ARM_SCU |
841 | select HAVE_IMX_GPC | 849 | select HAVE_IMX_GPC |
842 | select HAVE_IMX_MMDC | 850 | select HAVE_IMX_MMDC |
843 | select HAVE_IMX_SRC | 851 | select HAVE_IMX_SRC |
844 | select HAVE_SMP | 852 | select HAVE_SMP |
853 | select PINCTRL | ||
854 | select PINCTRL_IMX6Q | ||
845 | select USE_OF | 855 | select USE_OF |
846 | 856 | ||
847 | help | 857 | help |
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index ab939c5046c3..629a3394feac 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile | |||
@@ -1,15 +1,18 @@ | |||
1 | obj-$(CONFIG_SOC_IMX1) += clock-imx1.o mm-imx1.o | 1 | obj-$(CONFIG_SOC_IMX1) += clk-imx1.o mm-imx1.o |
2 | obj-$(CONFIG_SOC_IMX21) += clock-imx21.o mm-imx21.o | 2 | obj-$(CONFIG_SOC_IMX21) += clk-imx21.o mm-imx21.o |
3 | 3 | ||
4 | obj-$(CONFIG_SOC_IMX25) += clock-imx25.o mm-imx25.o ehci-imx25.o cpu-imx25.o | 4 | obj-$(CONFIG_SOC_IMX25) += clk-imx25.o mm-imx25.o ehci-imx25.o cpu-imx25.o |
5 | 5 | ||
6 | obj-$(CONFIG_SOC_IMX27) += cpu-imx27.o pm-imx27.o | 6 | obj-$(CONFIG_SOC_IMX27) += cpu-imx27.o pm-imx27.o |
7 | obj-$(CONFIG_SOC_IMX27) += clock-imx27.o mm-imx27.o ehci-imx27.o | 7 | obj-$(CONFIG_SOC_IMX27) += clk-imx27.o mm-imx27.o ehci-imx27.o |
8 | 8 | ||
9 | obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clock-imx31.o iomux-imx31.o ehci-imx31.o pm-imx3.o | 9 | obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clk-imx31.o iomux-imx31.o ehci-imx31.o pm-imx3.o |
10 | obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clock-imx35.o ehci-imx35.o pm-imx3.o | 10 | obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clk-imx35.o ehci-imx35.o pm-imx3.o |
11 | 11 | ||
12 | obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o mm-imx5.o clock-mx51-mx53.o ehci-imx5.o pm-imx5.o cpu_op-mx51.o | 12 | obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o mm-imx5.o clk-imx51-imx53.o ehci-imx5.o pm-imx5.o cpu_op-mx51.o |
13 | |||
14 | obj-$(CONFIG_COMMON_CLK) += clk-pllv1.o clk-pllv2.o clk-pllv3.o clk-gate2.o \ | ||
15 | clk-pfd.o clk-busy.o | ||
13 | 16 | ||
14 | # Support for CMOS sensor interface | 17 | # Support for CMOS sensor interface |
15 | obj-$(CONFIG_MX1_VIDEO) += mx1-camera-fiq.o mx1-camera-fiq-ksym.o | 18 | obj-$(CONFIG_MX1_VIDEO) += mx1-camera-fiq.o mx1-camera-fiq-ksym.o |
@@ -70,7 +73,7 @@ obj-$(CONFIG_CPU_V7) += head-v7.o | |||
70 | AFLAGS_head-v7.o :=-Wa,-march=armv7-a | 73 | AFLAGS_head-v7.o :=-Wa,-march=armv7-a |
71 | obj-$(CONFIG_SMP) += platsmp.o | 74 | obj-$(CONFIG_SMP) += platsmp.o |
72 | obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o | 75 | obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o |
73 | obj-$(CONFIG_SOC_IMX6Q) += clock-imx6q.o mach-imx6q.o | 76 | obj-$(CONFIG_SOC_IMX6Q) += clk-imx6q.o mach-imx6q.o |
74 | 77 | ||
75 | ifeq ($(CONFIG_PM),y) | 78 | ifeq ($(CONFIG_PM),y) |
76 | obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o | 79 | obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o |
diff --git a/arch/arm/mach-imx/clk-busy.c b/arch/arm/mach-imx/clk-busy.c new file mode 100644 index 000000000000..1a7a8dd045a1 --- /dev/null +++ b/arch/arm/mach-imx/clk-busy.c | |||
@@ -0,0 +1,189 @@ | |||
1 | /* | ||
2 | * Copyright 2012 Freescale Semiconductor, Inc. | ||
3 | * Copyright 2012 Linaro Ltd. | ||
4 | * | ||
5 | * The code contained herein is licensed under the GNU General Public | ||
6 | * License. You may obtain a copy of the GNU General Public License | ||
7 | * Version 2 or later at the following locations: | ||
8 | * | ||
9 | * http://www.opensource.org/licenses/gpl-license.html | ||
10 | * http://www.gnu.org/copyleft/gpl.html | ||
11 | */ | ||
12 | |||
13 | #include <linux/clk.h> | ||
14 | #include <linux/clk-provider.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/slab.h> | ||
17 | #include <linux/jiffies.h> | ||
18 | #include <linux/err.h> | ||
19 | #include "clk.h" | ||
20 | |||
21 | static int clk_busy_wait(void __iomem *reg, u8 shift) | ||
22 | { | ||
23 | unsigned long timeout = jiffies + msecs_to_jiffies(10); | ||
24 | |||
25 | while (readl_relaxed(reg) & (1 << shift)) | ||
26 | if (time_after(jiffies, timeout)) | ||
27 | return -ETIMEDOUT; | ||
28 | |||
29 | return 0; | ||
30 | } | ||
31 | |||
32 | struct clk_busy_divider { | ||
33 | struct clk_divider div; | ||
34 | const struct clk_ops *div_ops; | ||
35 | void __iomem *reg; | ||
36 | u8 shift; | ||
37 | }; | ||
38 | |||
39 | static inline struct clk_busy_divider *to_clk_busy_divider(struct clk_hw *hw) | ||
40 | { | ||
41 | struct clk_divider *div = container_of(hw, struct clk_divider, hw); | ||
42 | |||
43 | return container_of(div, struct clk_busy_divider, div); | ||
44 | } | ||
45 | |||
46 | static unsigned long clk_busy_divider_recalc_rate(struct clk_hw *hw, | ||
47 | unsigned long parent_rate) | ||
48 | { | ||
49 | struct clk_busy_divider *busy = to_clk_busy_divider(hw); | ||
50 | |||
51 | return busy->div_ops->recalc_rate(&busy->div.hw, parent_rate); | ||
52 | } | ||
53 | |||
54 | static long clk_busy_divider_round_rate(struct clk_hw *hw, unsigned long rate, | ||
55 | unsigned long *prate) | ||
56 | { | ||
57 | struct clk_busy_divider *busy = to_clk_busy_divider(hw); | ||
58 | |||
59 | return busy->div_ops->round_rate(&busy->div.hw, rate, prate); | ||
60 | } | ||
61 | |||
62 | static int clk_busy_divider_set_rate(struct clk_hw *hw, unsigned long rate, | ||
63 | unsigned long parent_rate) | ||
64 | { | ||
65 | struct clk_busy_divider *busy = to_clk_busy_divider(hw); | ||
66 | int ret; | ||
67 | |||
68 | ret = busy->div_ops->set_rate(&busy->div.hw, rate, parent_rate); | ||
69 | if (!ret) | ||
70 | ret = clk_busy_wait(busy->reg, busy->shift); | ||
71 | |||
72 | return ret; | ||
73 | } | ||
74 | |||
75 | static struct clk_ops clk_busy_divider_ops = { | ||
76 | .recalc_rate = clk_busy_divider_recalc_rate, | ||
77 | .round_rate = clk_busy_divider_round_rate, | ||
78 | .set_rate = clk_busy_divider_set_rate, | ||
79 | }; | ||
80 | |||
81 | struct clk *imx_clk_busy_divider(const char *name, const char *parent_name, | ||
82 | void __iomem *reg, u8 shift, u8 width, | ||
83 | void __iomem *busy_reg, u8 busy_shift) | ||
84 | { | ||
85 | struct clk_busy_divider *busy; | ||
86 | struct clk *clk; | ||
87 | struct clk_init_data init; | ||
88 | |||
89 | busy = kzalloc(sizeof(*busy), GFP_KERNEL); | ||
90 | if (!busy) | ||
91 | return ERR_PTR(-ENOMEM); | ||
92 | |||
93 | busy->reg = busy_reg; | ||
94 | busy->shift = busy_shift; | ||
95 | |||
96 | busy->div.reg = reg; | ||
97 | busy->div.shift = shift; | ||
98 | busy->div.width = width; | ||
99 | busy->div.lock = &imx_ccm_lock; | ||
100 | busy->div_ops = &clk_divider_ops; | ||
101 | |||
102 | init.name = name; | ||
103 | init.ops = &clk_busy_divider_ops; | ||
104 | init.flags = CLK_SET_RATE_PARENT; | ||
105 | init.parent_names = &parent_name; | ||
106 | init.num_parents = 1; | ||
107 | |||
108 | busy->div.hw.init = &init; | ||
109 | |||
110 | clk = clk_register(NULL, &busy->div.hw); | ||
111 | if (!clk) | ||
112 | kfree(busy); | ||
113 | |||
114 | return clk; | ||
115 | } | ||
116 | |||
117 | struct clk_busy_mux { | ||
118 | struct clk_mux mux; | ||
119 | const struct clk_ops *mux_ops; | ||
120 | void __iomem *reg; | ||
121 | u8 shift; | ||
122 | }; | ||
123 | |||
124 | static inline struct clk_busy_mux *to_clk_busy_mux(struct clk_hw *hw) | ||
125 | { | ||
126 | struct clk_mux *mux = container_of(hw, struct clk_mux, hw); | ||
127 | |||
128 | return container_of(mux, struct clk_busy_mux, mux); | ||
129 | } | ||
130 | |||
131 | static u8 clk_busy_mux_get_parent(struct clk_hw *hw) | ||
132 | { | ||
133 | struct clk_busy_mux *busy = to_clk_busy_mux(hw); | ||
134 | |||
135 | return busy->mux_ops->get_parent(&busy->mux.hw); | ||
136 | } | ||
137 | |||
138 | static int clk_busy_mux_set_parent(struct clk_hw *hw, u8 index) | ||
139 | { | ||
140 | struct clk_busy_mux *busy = to_clk_busy_mux(hw); | ||
141 | int ret; | ||
142 | |||
143 | ret = busy->mux_ops->set_parent(&busy->mux.hw, index); | ||
144 | if (!ret) | ||
145 | ret = clk_busy_wait(busy->reg, busy->shift); | ||
146 | |||
147 | return ret; | ||
148 | } | ||
149 | |||
150 | struct clk_ops clk_busy_mux_ops = { | ||
151 | .get_parent = clk_busy_mux_get_parent, | ||
152 | .set_parent = clk_busy_mux_set_parent, | ||
153 | }; | ||
154 | |||
155 | struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift, | ||
156 | u8 width, void __iomem *busy_reg, u8 busy_shift, | ||
157 | const char **parent_names, int num_parents) | ||
158 | { | ||
159 | struct clk_busy_mux *busy; | ||
160 | struct clk *clk; | ||
161 | struct clk_init_data init; | ||
162 | |||
163 | busy = kzalloc(sizeof(*busy), GFP_KERNEL); | ||
164 | if (!busy) | ||
165 | return ERR_PTR(-ENOMEM); | ||
166 | |||
167 | busy->reg = busy_reg; | ||
168 | busy->shift = busy_shift; | ||
169 | |||
170 | busy->mux.reg = reg; | ||
171 | busy->mux.shift = shift; | ||
172 | busy->mux.width = width; | ||
173 | busy->mux.lock = &imx_ccm_lock; | ||
174 | busy->mux_ops = &clk_mux_ops; | ||
175 | |||
176 | init.name = name; | ||
177 | init.ops = &clk_busy_mux_ops; | ||
178 | init.flags = 0; | ||
179 | init.parent_names = parent_names; | ||
180 | init.num_parents = num_parents; | ||
181 | |||
182 | busy->mux.hw.init = &init; | ||
183 | |||
184 | clk = clk_register(NULL, &busy->mux.hw); | ||
185 | if (IS_ERR(clk)) | ||
186 | kfree(busy); | ||
187 | |||
188 | return clk; | ||
189 | } | ||
diff --git a/arch/arm/mach-imx/clk-gate2.c b/arch/arm/mach-imx/clk-gate2.c new file mode 100644 index 000000000000..3c1b8ff9a0a6 --- /dev/null +++ b/arch/arm/mach-imx/clk-gate2.c | |||
@@ -0,0 +1,118 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2010-2011 Canonical Ltd <jeremy.kerr@canonical.com> | ||
3 | * Copyright (C) 2011-2012 Mike Turquette, Linaro Ltd <mturquette@linaro.org> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License version 2 as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * Gated clock implementation | ||
10 | */ | ||
11 | |||
12 | #include <linux/clk-provider.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/slab.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/err.h> | ||
17 | #include <linux/string.h> | ||
18 | |||
19 | /** | ||
20 | * DOC: basic gatable clock which can gate and ungate it's ouput | ||
21 | * | ||
22 | * Traits of this clock: | ||
23 | * prepare - clk_(un)prepare only ensures parent is (un)prepared | ||
24 | * enable - clk_enable and clk_disable are functional & control gating | ||
25 | * rate - inherits rate from parent. No clk_set_rate support | ||
26 | * parent - fixed parent. No clk_set_parent support | ||
27 | */ | ||
28 | |||
29 | #define to_clk_gate(_hw) container_of(_hw, struct clk_gate, hw) | ||
30 | |||
31 | static int clk_gate2_enable(struct clk_hw *hw) | ||
32 | { | ||
33 | struct clk_gate *gate = to_clk_gate(hw); | ||
34 | u32 reg; | ||
35 | unsigned long flags = 0; | ||
36 | |||
37 | if (gate->lock) | ||
38 | spin_lock_irqsave(gate->lock, flags); | ||
39 | |||
40 | reg = readl(gate->reg); | ||
41 | reg |= 3 << gate->bit_idx; | ||
42 | writel(reg, gate->reg); | ||
43 | |||
44 | if (gate->lock) | ||
45 | spin_unlock_irqrestore(gate->lock, flags); | ||
46 | |||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | static void clk_gate2_disable(struct clk_hw *hw) | ||
51 | { | ||
52 | struct clk_gate *gate = to_clk_gate(hw); | ||
53 | u32 reg; | ||
54 | unsigned long flags = 0; | ||
55 | |||
56 | if (gate->lock) | ||
57 | spin_lock_irqsave(gate->lock, flags); | ||
58 | |||
59 | reg = readl(gate->reg); | ||
60 | reg &= ~(3 << gate->bit_idx); | ||
61 | writel(reg, gate->reg); | ||
62 | |||
63 | if (gate->lock) | ||
64 | spin_unlock_irqrestore(gate->lock, flags); | ||
65 | } | ||
66 | |||
67 | static int clk_gate2_is_enabled(struct clk_hw *hw) | ||
68 | { | ||
69 | u32 reg; | ||
70 | struct clk_gate *gate = to_clk_gate(hw); | ||
71 | |||
72 | reg = readl(gate->reg); | ||
73 | |||
74 | if (((reg >> gate->bit_idx) & 3) == 3) | ||
75 | return 1; | ||
76 | |||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | static struct clk_ops clk_gate2_ops = { | ||
81 | .enable = clk_gate2_enable, | ||
82 | .disable = clk_gate2_disable, | ||
83 | .is_enabled = clk_gate2_is_enabled, | ||
84 | }; | ||
85 | |||
86 | struct clk *clk_register_gate2(struct device *dev, const char *name, | ||
87 | const char *parent_name, unsigned long flags, | ||
88 | void __iomem *reg, u8 bit_idx, | ||
89 | u8 clk_gate2_flags, spinlock_t *lock) | ||
90 | { | ||
91 | struct clk_gate *gate; | ||
92 | struct clk *clk; | ||
93 | struct clk_init_data init; | ||
94 | |||
95 | gate = kzalloc(sizeof(struct clk_gate), GFP_KERNEL); | ||
96 | if (!gate) | ||
97 | return ERR_PTR(-ENOMEM); | ||
98 | |||
99 | /* struct clk_gate assignments */ | ||
100 | gate->reg = reg; | ||
101 | gate->bit_idx = bit_idx; | ||
102 | gate->flags = clk_gate2_flags; | ||
103 | gate->lock = lock; | ||
104 | |||
105 | init.name = name; | ||
106 | init.ops = &clk_gate2_ops; | ||
107 | init.flags = flags; | ||
108 | init.parent_names = parent_name ? &parent_name : NULL; | ||
109 | init.num_parents = parent_name ? 1 : 0; | ||
110 | |||
111 | gate->hw.init = &init; | ||
112 | |||
113 | clk = clk_register(dev, &gate->hw); | ||
114 | if (IS_ERR(clk)) | ||
115 | kfree(clk); | ||
116 | |||
117 | return clk; | ||
118 | } | ||
diff --git a/arch/arm/mach-imx/clk-imx1.c b/arch/arm/mach-imx/clk-imx1.c new file mode 100644 index 000000000000..0f0beb580b73 --- /dev/null +++ b/arch/arm/mach-imx/clk-imx1.c | |||
@@ -0,0 +1,115 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2008 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License along | ||
14 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
15 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | ||
16 | */ | ||
17 | |||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/clk.h> | ||
21 | #include <linux/io.h> | ||
22 | #include <linux/clkdev.h> | ||
23 | #include <linux/err.h> | ||
24 | |||
25 | #include <mach/hardware.h> | ||
26 | #include <mach/common.h> | ||
27 | #include "clk.h" | ||
28 | |||
29 | /* CCM register addresses */ | ||
30 | #define IO_ADDR_CCM(off) (MX1_IO_ADDRESS(MX1_CCM_BASE_ADDR + (off))) | ||
31 | |||
32 | #define CCM_CSCR IO_ADDR_CCM(0x0) | ||
33 | #define CCM_MPCTL0 IO_ADDR_CCM(0x4) | ||
34 | #define CCM_SPCTL0 IO_ADDR_CCM(0xc) | ||
35 | #define CCM_PCDR IO_ADDR_CCM(0x20) | ||
36 | |||
37 | /* SCM register addresses */ | ||
38 | #define IO_ADDR_SCM(off) (MX1_IO_ADDRESS(MX1_SCM_BASE_ADDR + (off))) | ||
39 | |||
40 | #define SCM_GCCR IO_ADDR_SCM(0xc) | ||
41 | |||
42 | static const char *prem_sel_clks[] = { "clk32_premult", "clk16m", }; | ||
43 | static const char *clko_sel_clks[] = { "per1", "hclk", "clk48m", "clk16m", "prem", | ||
44 | "fclk", }; | ||
45 | enum imx1_clks { | ||
46 | dummy, clk32, clk16m_ext, clk16m, clk32_premult, prem, mpll, spll, mcu, | ||
47 | fclk, hclk, clk48m, per1, per2, per3, clko, dma_gate, csi_gate, | ||
48 | mma_gate, usbd_gate, clk_max | ||
49 | }; | ||
50 | |||
51 | static struct clk *clk[clk_max]; | ||
52 | |||
53 | int __init mx1_clocks_init(unsigned long fref) | ||
54 | { | ||
55 | int i; | ||
56 | |||
57 | clk[dummy] = imx_clk_fixed("dummy", 0); | ||
58 | clk[clk32] = imx_clk_fixed("clk32", fref); | ||
59 | clk[clk16m_ext] = imx_clk_fixed("clk16m_ext", 16000000); | ||
60 | clk[clk16m] = imx_clk_gate("clk16m", "clk16m_ext", CCM_CSCR, 17); | ||
61 | clk[clk32_premult] = imx_clk_fixed_factor("clk32_premult", "clk32", 512, 1); | ||
62 | clk[prem] = imx_clk_mux("prem", CCM_CSCR, 16, 1, prem_sel_clks, | ||
63 | ARRAY_SIZE(prem_sel_clks)); | ||
64 | clk[mpll] = imx_clk_pllv1("mpll", "clk32_premult", CCM_MPCTL0); | ||
65 | clk[spll] = imx_clk_pllv1("spll", "prem", CCM_SPCTL0); | ||
66 | clk[mcu] = imx_clk_divider("mcu", "clk32_premult", CCM_CSCR, 15, 1); | ||
67 | clk[fclk] = imx_clk_divider("fclk", "mpll", CCM_CSCR, 15, 1); | ||
68 | clk[hclk] = imx_clk_divider("hclk", "spll", CCM_CSCR, 10, 4); | ||
69 | clk[clk48m] = imx_clk_divider("clk48m", "spll", CCM_CSCR, 26, 3); | ||
70 | clk[per1] = imx_clk_divider("per1", "spll", CCM_PCDR, 0, 4); | ||
71 | clk[per2] = imx_clk_divider("per2", "spll", CCM_PCDR, 4, 4); | ||
72 | clk[per3] = imx_clk_divider("per3", "spll", CCM_PCDR, 16, 7); | ||
73 | clk[clko] = imx_clk_mux("clko", CCM_CSCR, 29, 3, clko_sel_clks, | ||
74 | ARRAY_SIZE(clko_sel_clks)); | ||
75 | clk[dma_gate] = imx_clk_gate("dma_gate", "hclk", SCM_GCCR, 4); | ||
76 | clk[csi_gate] = imx_clk_gate("csi_gate", "hclk", SCM_GCCR, 2); | ||
77 | clk[mma_gate] = imx_clk_gate("mma_gate", "hclk", SCM_GCCR, 1); | ||
78 | clk[usbd_gate] = imx_clk_gate("usbd_gate", "clk48m", SCM_GCCR, 0); | ||
79 | |||
80 | for (i = 0; i < ARRAY_SIZE(clk); i++) | ||
81 | if (IS_ERR(clk[i])) | ||
82 | pr_err("imx1 clk %d: register failed with %ld\n", | ||
83 | i, PTR_ERR(clk[i])); | ||
84 | |||
85 | clk_register_clkdev(clk[dma_gate], "ahb", "imx-dma"); | ||
86 | clk_register_clkdev(clk[csi_gate], NULL, "mx1-camera.0"); | ||
87 | clk_register_clkdev(clk[mma_gate], "mma", NULL); | ||
88 | clk_register_clkdev(clk[usbd_gate], NULL, "imx_udc.0"); | ||
89 | clk_register_clkdev(clk[per1], "per", "imx-gpt.0"); | ||
90 | clk_register_clkdev(clk[hclk], "ipg", "imx-gpt.0"); | ||
91 | clk_register_clkdev(clk[per1], "per", "imx1-uart.0"); | ||
92 | clk_register_clkdev(clk[hclk], "ipg", "imx1-uart.0"); | ||
93 | clk_register_clkdev(clk[per1], "per", "imx1-uart.1"); | ||
94 | clk_register_clkdev(clk[hclk], "ipg", "imx1-uart.1"); | ||
95 | clk_register_clkdev(clk[per1], "per", "imx1-uart.2"); | ||
96 | clk_register_clkdev(clk[hclk], "ipg", "imx1-uart.2"); | ||
97 | clk_register_clkdev(clk[hclk], NULL, "imx-i2c.0"); | ||
98 | clk_register_clkdev(clk[per2], "per", "imx1-cspi.0"); | ||
99 | clk_register_clkdev(clk[dummy], "ipg", "imx1-cspi.0"); | ||
100 | clk_register_clkdev(clk[per2], "per", "imx1-cspi.1"); | ||
101 | clk_register_clkdev(clk[dummy], "ipg", "imx1-cspi.1"); | ||
102 | clk_register_clkdev(clk[per2], NULL, "imx-mmc.0"); | ||
103 | clk_register_clkdev(clk[per2], "per", "imx-fb.0"); | ||
104 | clk_register_clkdev(clk[dummy], "ipg", "imx-fb.0"); | ||
105 | clk_register_clkdev(clk[dummy], "ahb", "imx-fb.0"); | ||
106 | clk_register_clkdev(clk[hclk], "mshc", NULL); | ||
107 | clk_register_clkdev(clk[per3], "ssi", NULL); | ||
108 | clk_register_clkdev(clk[clk32], NULL, "mxc_rtc.0"); | ||
109 | clk_register_clkdev(clk[clko], "clko", NULL); | ||
110 | |||
111 | mxc_timer_init(NULL, MX1_IO_ADDRESS(MX1_TIM1_BASE_ADDR), | ||
112 | MX1_TIM1_INT); | ||
113 | |||
114 | return 0; | ||
115 | } | ||
diff --git a/arch/arm/mach-imx/clk-imx21.c b/arch/arm/mach-imx/clk-imx21.c new file mode 100644 index 000000000000..4e4f384ee8dd --- /dev/null +++ b/arch/arm/mach-imx/clk-imx21.c | |||
@@ -0,0 +1,186 @@ | |||
1 | /* | ||
2 | * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. | ||
3 | * Copyright 2008 Juergen Beisert, kernel@pengutronix.de | ||
4 | * Copyright 2008 Martin Fuzzey, mfuzzey@gmail.com | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version 2 | ||
9 | * of the License, or (at your option) any later version. | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
18 | * MA 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/clk.h> | ||
22 | #include <linux/clkdev.h> | ||
23 | #include <linux/clk-provider.h> | ||
24 | #include <linux/io.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/clkdev.h> | ||
27 | #include <linux/err.h> | ||
28 | |||
29 | #include <mach/hardware.h> | ||
30 | #include <mach/common.h> | ||
31 | #include "clk.h" | ||
32 | |||
33 | #define IO_ADDR_CCM(off) (MX21_IO_ADDRESS(MX21_CCM_BASE_ADDR + (off))) | ||
34 | |||
35 | /* Register offsets */ | ||
36 | #define CCM_CSCR IO_ADDR_CCM(0x0) | ||
37 | #define CCM_MPCTL0 IO_ADDR_CCM(0x4) | ||
38 | #define CCM_MPCTL1 IO_ADDR_CCM(0x8) | ||
39 | #define CCM_SPCTL0 IO_ADDR_CCM(0xc) | ||
40 | #define CCM_SPCTL1 IO_ADDR_CCM(0x10) | ||
41 | #define CCM_OSC26MCTL IO_ADDR_CCM(0x14) | ||
42 | #define CCM_PCDR0 IO_ADDR_CCM(0x18) | ||
43 | #define CCM_PCDR1 IO_ADDR_CCM(0x1c) | ||
44 | #define CCM_PCCR0 IO_ADDR_CCM(0x20) | ||
45 | #define CCM_PCCR1 IO_ADDR_CCM(0x24) | ||
46 | #define CCM_CCSR IO_ADDR_CCM(0x28) | ||
47 | #define CCM_PMCTL IO_ADDR_CCM(0x2c) | ||
48 | #define CCM_PMCOUNT IO_ADDR_CCM(0x30) | ||
49 | #define CCM_WKGDCTL IO_ADDR_CCM(0x34) | ||
50 | |||
51 | static const char *mpll_sel_clks[] = { "fpm", "ckih", }; | ||
52 | static const char *spll_sel_clks[] = { "fpm", "ckih", }; | ||
53 | |||
54 | enum imx21_clks { | ||
55 | ckil, ckih, fpm, mpll_sel, spll_sel, mpll, spll, fclk, hclk, ipg, per1, | ||
56 | per2, per3, per4, uart1_ipg_gate, uart2_ipg_gate, uart3_ipg_gate, | ||
57 | uart4_ipg_gate, gpt1_ipg_gate, gpt2_ipg_gate, gpt3_ipg_gate, | ||
58 | pwm_ipg_gate, sdhc1_ipg_gate, sdhc2_ipg_gate, lcdc_ipg_gate, | ||
59 | lcdc_hclk_gate, cspi3_ipg_gate, cspi2_ipg_gate, cspi1_ipg_gate, | ||
60 | per4_gate, csi_hclk_gate, usb_div, usb_gate, usb_hclk_gate, ssi1_gate, | ||
61 | ssi2_gate, nfc_div, nfc_gate, dma_gate, dma_hclk_gate, brom_gate, | ||
62 | emma_gate, emma_hclk_gate, slcdc_gate, slcdc_hclk_gate, wdog_gate, | ||
63 | gpio_gate, i2c_gate, kpp_gate, owire_gate, rtc_gate, clk_max | ||
64 | }; | ||
65 | |||
66 | static struct clk *clk[clk_max]; | ||
67 | |||
68 | /* | ||
69 | * must be called very early to get information about the | ||
70 | * available clock rate when the timer framework starts | ||
71 | */ | ||
72 | int __init mx21_clocks_init(unsigned long lref, unsigned long href) | ||
73 | { | ||
74 | int i; | ||
75 | |||
76 | clk[ckil] = imx_clk_fixed("ckil", lref); | ||
77 | clk[ckih] = imx_clk_fixed("ckih", href); | ||
78 | clk[fpm] = imx_clk_fixed_factor("fpm", "ckil", 512, 1); | ||
79 | clk[mpll_sel] = imx_clk_mux("mpll_sel", CCM_CSCR, 16, 1, mpll_sel_clks, | ||
80 | ARRAY_SIZE(mpll_sel_clks)); | ||
81 | clk[spll_sel] = imx_clk_mux("spll_sel", CCM_CSCR, 17, 1, spll_sel_clks, | ||
82 | ARRAY_SIZE(spll_sel_clks)); | ||
83 | clk[mpll] = imx_clk_pllv1("mpll", "mpll_sel", CCM_MPCTL0); | ||
84 | clk[spll] = imx_clk_pllv1("spll", "spll_sel", CCM_SPCTL0); | ||
85 | clk[fclk] = imx_clk_divider("fclk", "mpll", CCM_CSCR, 29, 3); | ||
86 | clk[hclk] = imx_clk_divider("hclk", "fclk", CCM_CSCR, 10, 4); | ||
87 | clk[ipg] = imx_clk_divider("ipg", "hclk", CCM_CSCR, 9, 1); | ||
88 | clk[per1] = imx_clk_divider("per1", "mpll", CCM_PCDR1, 0, 6); | ||
89 | clk[per2] = imx_clk_divider("per2", "mpll", CCM_PCDR1, 8, 6); | ||
90 | clk[per3] = imx_clk_divider("per3", "mpll", CCM_PCDR1, 16, 6); | ||
91 | clk[per4] = imx_clk_divider("per4", "mpll", CCM_PCDR1, 24, 6); | ||
92 | clk[uart1_ipg_gate] = imx_clk_gate("uart1_ipg_gate", "ipg", CCM_PCCR0, 0); | ||
93 | clk[uart2_ipg_gate] = imx_clk_gate("uart2_ipg_gate", "ipg", CCM_PCCR0, 1); | ||
94 | clk[uart3_ipg_gate] = imx_clk_gate("uart3_ipg_gate", "ipg", CCM_PCCR0, 2); | ||
95 | clk[uart4_ipg_gate] = imx_clk_gate("uart4_ipg_gate", "ipg", CCM_PCCR0, 3); | ||
96 | clk[gpt1_ipg_gate] = imx_clk_gate("gpt1_ipg_gate", "ipg", CCM_PCCR1, 25); | ||
97 | clk[gpt2_ipg_gate] = imx_clk_gate("gpt2_ipg_gate", "ipg", CCM_PCCR1, 26); | ||
98 | clk[gpt3_ipg_gate] = imx_clk_gate("gpt3_ipg_gate", "ipg", CCM_PCCR1, 27); | ||
99 | clk[pwm_ipg_gate] = imx_clk_gate("pwm_ipg_gate", "ipg", CCM_PCCR1, 28); | ||
100 | clk[sdhc1_ipg_gate] = imx_clk_gate("sdhc1_ipg_gate", "ipg", CCM_PCCR0, 9); | ||
101 | clk[sdhc2_ipg_gate] = imx_clk_gate("sdhc2_ipg_gate", "ipg", CCM_PCCR0, 10); | ||
102 | clk[lcdc_ipg_gate] = imx_clk_gate("lcdc_ipg_gate", "ipg", CCM_PCCR0, 18); | ||
103 | clk[lcdc_hclk_gate] = imx_clk_gate("lcdc_hclk_gate", "hclk", CCM_PCCR0, 26); | ||
104 | clk[cspi3_ipg_gate] = imx_clk_gate("cspi3_ipg_gate", "ipg", CCM_PCCR1, 23); | ||
105 | clk[cspi2_ipg_gate] = imx_clk_gate("cspi2_ipg_gate", "ipg", CCM_PCCR0, 5); | ||
106 | clk[cspi1_ipg_gate] = imx_clk_gate("cspi1_ipg_gate", "ipg", CCM_PCCR0, 4); | ||
107 | clk[per4_gate] = imx_clk_gate("per4_gate", "per4", CCM_PCCR0, 22); | ||
108 | clk[csi_hclk_gate] = imx_clk_gate("csi_hclk_gate", "hclk", CCM_PCCR0, 31); | ||
109 | clk[usb_div] = imx_clk_divider("usb_div", "spll", CCM_CSCR, 26, 3); | ||
110 | clk[usb_gate] = imx_clk_gate("usb_gate", "usb_div", CCM_PCCR0, 14); | ||
111 | clk[usb_hclk_gate] = imx_clk_gate("usb_hclk_gate", "hclk", CCM_PCCR0, 24); | ||
112 | clk[ssi1_gate] = imx_clk_gate("ssi1_gate", "ipg", CCM_PCCR0, 6); | ||
113 | clk[ssi2_gate] = imx_clk_gate("ssi2_gate", "ipg", CCM_PCCR0, 7); | ||
114 | clk[nfc_div] = imx_clk_divider("nfc_div", "ipg", CCM_PCDR0, 12, 4); | ||
115 | clk[nfc_gate] = imx_clk_gate("nfc_gate", "nfc_div", CCM_PCCR0, 19); | ||
116 | clk[dma_gate] = imx_clk_gate("dma_gate", "ipg", CCM_PCCR0, 13); | ||
117 | clk[dma_hclk_gate] = imx_clk_gate("dma_hclk_gate", "hclk", CCM_PCCR0, 30); | ||
118 | clk[brom_gate] = imx_clk_gate("brom_gate", "hclk", CCM_PCCR0, 28); | ||
119 | clk[emma_gate] = imx_clk_gate("emma_gate", "ipg", CCM_PCCR0, 15); | ||
120 | clk[emma_hclk_gate] = imx_clk_gate("emma_hclk_gate", "hclk", CCM_PCCR0, 27); | ||
121 | clk[slcdc_gate] = imx_clk_gate("slcdc_gate", "ipg", CCM_PCCR0, 25); | ||
122 | clk[slcdc_hclk_gate] = imx_clk_gate("slcdc_hclk_gate", "hclk", CCM_PCCR0, 21); | ||
123 | clk[wdog_gate] = imx_clk_gate("wdog_gate", "ipg", CCM_PCCR1, 24); | ||
124 | clk[gpio_gate] = imx_clk_gate("gpio_gate", "ipg", CCM_PCCR0, 11); | ||
125 | clk[i2c_gate] = imx_clk_gate("i2c_gate", "ipg", CCM_PCCR0, 12); | ||
126 | clk[kpp_gate] = imx_clk_gate("kpp_gate", "ipg", CCM_PCCR1, 30); | ||
127 | clk[owire_gate] = imx_clk_gate("owire_gate", "ipg", CCM_PCCR1, 31); | ||
128 | clk[rtc_gate] = imx_clk_gate("rtc_gate", "ipg", CCM_PCCR1, 29); | ||
129 | |||
130 | for (i = 0; i < ARRAY_SIZE(clk); i++) | ||
131 | if (IS_ERR(clk[i])) | ||
132 | pr_err("i.MX21 clk %d: register failed with %ld\n", | ||
133 | i, PTR_ERR(clk[i])); | ||
134 | |||
135 | clk_register_clkdev(clk[per1], "per1", NULL); | ||
136 | clk_register_clkdev(clk[per2], "per2", NULL); | ||
137 | clk_register_clkdev(clk[per3], "per3", NULL); | ||
138 | clk_register_clkdev(clk[per4], "per4", NULL); | ||
139 | clk_register_clkdev(clk[per1], "per", "imx21-uart.0"); | ||
140 | clk_register_clkdev(clk[uart1_ipg_gate], "ipg", "imx21-uart.0"); | ||
141 | clk_register_clkdev(clk[per1], "per", "imx21-uart.1"); | ||
142 | clk_register_clkdev(clk[uart2_ipg_gate], "ipg", "imx21-uart.1"); | ||
143 | clk_register_clkdev(clk[per1], "per", "imx21-uart.2"); | ||
144 | clk_register_clkdev(clk[uart3_ipg_gate], "ipg", "imx21-uart.2"); | ||
145 | clk_register_clkdev(clk[per1], "per", "imx21-uart.3"); | ||
146 | clk_register_clkdev(clk[uart4_ipg_gate], "ipg", "imx21-uart.3"); | ||
147 | clk_register_clkdev(clk[gpt1_ipg_gate], "ipg", "imx-gpt.0"); | ||
148 | clk_register_clkdev(clk[per1], "per", "imx-gpt.0"); | ||
149 | clk_register_clkdev(clk[gpt2_ipg_gate], "ipg", "imx-gpt.1"); | ||
150 | clk_register_clkdev(clk[per1], "per", "imx-gpt.1"); | ||
151 | clk_register_clkdev(clk[gpt3_ipg_gate], "ipg", "imx-gpt.2"); | ||
152 | clk_register_clkdev(clk[per1], "per", "imx-gpt.2"); | ||
153 | clk_register_clkdev(clk[pwm_ipg_gate], "pwm", "mxc_pwm.0"); | ||
154 | clk_register_clkdev(clk[per2], "per", "imx21-cspi.0"); | ||
155 | clk_register_clkdev(clk[cspi1_ipg_gate], "ipg", "imx21-cspi.0"); | ||
156 | clk_register_clkdev(clk[per2], "per", "imx21-cspi.1"); | ||
157 | clk_register_clkdev(clk[cspi2_ipg_gate], "ipg", "imx21-cspi.1"); | ||
158 | clk_register_clkdev(clk[per2], "per", "imx21-cspi.2"); | ||
159 | clk_register_clkdev(clk[cspi3_ipg_gate], "ipg", "imx21-cspi.2"); | ||
160 | clk_register_clkdev(clk[per3], "per", "imx-fb.0"); | ||
161 | clk_register_clkdev(clk[lcdc_ipg_gate], "ipg", "imx-fb.0"); | ||
162 | clk_register_clkdev(clk[lcdc_hclk_gate], "ahb", "imx-fb.0"); | ||
163 | clk_register_clkdev(clk[usb_gate], "per", "imx21-hcd.0"); | ||
164 | clk_register_clkdev(clk[usb_hclk_gate], "ahb", "imx21-hcd.0"); | ||
165 | clk_register_clkdev(clk[nfc_gate], NULL, "mxc_nand.0"); | ||
166 | clk_register_clkdev(clk[dma_hclk_gate], "ahb", "imx-dma"); | ||
167 | clk_register_clkdev(clk[dma_gate], "ipg", "imx-dma"); | ||
168 | clk_register_clkdev(clk[wdog_gate], NULL, "imx2-wdt.0"); | ||
169 | clk_register_clkdev(clk[i2c_gate], NULL, "imx-i2c.0"); | ||
170 | clk_register_clkdev(clk[kpp_gate], NULL, "mxc-keypad"); | ||
171 | clk_register_clkdev(clk[owire_gate], NULL, "mxc_w1.0"); | ||
172 | clk_register_clkdev(clk[brom_gate], "brom", NULL); | ||
173 | clk_register_clkdev(clk[emma_gate], "emma", NULL); | ||
174 | clk_register_clkdev(clk[slcdc_gate], "slcdc", NULL); | ||
175 | clk_register_clkdev(clk[gpio_gate], "gpio", NULL); | ||
176 | clk_register_clkdev(clk[rtc_gate], "rtc", NULL); | ||
177 | clk_register_clkdev(clk[csi_hclk_gate], "csi", NULL); | ||
178 | clk_register_clkdev(clk[ssi1_gate], "ssi1", NULL); | ||
179 | clk_register_clkdev(clk[ssi2_gate], "ssi2", NULL); | ||
180 | clk_register_clkdev(clk[sdhc1_ipg_gate], "sdhc1", NULL); | ||
181 | clk_register_clkdev(clk[sdhc2_ipg_gate], "sdhc2", NULL); | ||
182 | |||
183 | mxc_timer_init(NULL, MX21_IO_ADDRESS(MX21_GPT1_BASE_ADDR), | ||
184 | MX21_INT_GPT1); | ||
185 | return 0; | ||
186 | } | ||
diff --git a/arch/arm/mach-imx/clk-imx25.c b/arch/arm/mach-imx/clk-imx25.c new file mode 100644 index 000000000000..d9833bb5fd61 --- /dev/null +++ b/arch/arm/mach-imx/clk-imx25.c | |||
@@ -0,0 +1,248 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009 by Sascha Hauer, Pengutronix | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation; either version 2 | ||
7 | * of the License, or (at your option) any later version. | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program; if not, write to the Free Software | ||
15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
16 | * MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/list.h> | ||
22 | #include <linux/clk.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <linux/clkdev.h> | ||
25 | #include <linux/err.h> | ||
26 | |||
27 | #include <mach/hardware.h> | ||
28 | #include <mach/common.h> | ||
29 | #include <mach/mx25.h> | ||
30 | #include "clk.h" | ||
31 | |||
32 | #define CRM_BASE MX25_IO_ADDRESS(MX25_CRM_BASE_ADDR) | ||
33 | |||
34 | #define CCM_MPCTL 0x00 | ||
35 | #define CCM_UPCTL 0x04 | ||
36 | #define CCM_CCTL 0x08 | ||
37 | #define CCM_CGCR0 0x0C | ||
38 | #define CCM_CGCR1 0x10 | ||
39 | #define CCM_CGCR2 0x14 | ||
40 | #define CCM_PCDR0 0x18 | ||
41 | #define CCM_PCDR1 0x1C | ||
42 | #define CCM_PCDR2 0x20 | ||
43 | #define CCM_PCDR3 0x24 | ||
44 | #define CCM_RCSR 0x28 | ||
45 | #define CCM_CRDR 0x2C | ||
46 | #define CCM_DCVR0 0x30 | ||
47 | #define CCM_DCVR1 0x34 | ||
48 | #define CCM_DCVR2 0x38 | ||
49 | #define CCM_DCVR3 0x3c | ||
50 | #define CCM_LTR0 0x40 | ||
51 | #define CCM_LTR1 0x44 | ||
52 | #define CCM_LTR2 0x48 | ||
53 | #define CCM_LTR3 0x4c | ||
54 | #define CCM_MCR 0x64 | ||
55 | |||
56 | #define ccm(x) (CRM_BASE + (x)) | ||
57 | |||
58 | static const char *cpu_sel_clks[] = { "mpll", "mpll_cpu_3_4", }; | ||
59 | static const char *per_sel_clks[] = { "ahb", "upll", }; | ||
60 | |||
61 | enum mx25_clks { | ||
62 | dummy, osc, mpll, upll, mpll_cpu_3_4, cpu_sel, cpu, ahb, usb_div, ipg, | ||
63 | per0_sel, per1_sel, per2_sel, per3_sel, per4_sel, per5_sel, per6_sel, | ||
64 | per7_sel, per8_sel, per9_sel, per10_sel, per11_sel, per12_sel, | ||
65 | per13_sel, per14_sel, per15_sel, per0, per1, per2, per3, per4, per5, | ||
66 | per6, per7, per8, per9, per10, per11, per12, per13, per14, per15, | ||
67 | csi_ipg_per, esdhc1_ipg_per, esdhc2_ipg_per, gpt_ipg_per, i2c_ipg_per, | ||
68 | lcdc_ipg_per, nfc_ipg_per, ssi1_ipg_per, ssi2_ipg_per, uart_ipg_per, | ||
69 | csi_ahb, esdhc1_ahb, esdhc2_ahb, fec_ahb, lcdc_ahb, sdma_ahb, | ||
70 | usbotg_ahb, can1_ipg, can2_ipg, csi_ipg, cspi1_ipg, cspi2_ipg, | ||
71 | cspi3_ipg, dryice_ipg, esdhc1_ipg, esdhc2_ipg, fec_ipg, iim_ipg, | ||
72 | kpp_ipg, lcdc_ipg, pwm1_ipg, pwm2_ipg, pwm3_ipg, pwm4_ipg, sdma_ipg, | ||
73 | ssi1_ipg, ssi2_ipg, tsc_ipg, uart1_ipg, uart2_ipg, uart3_ipg, | ||
74 | uart4_ipg, uart5_ipg, wdt_ipg, clk_max | ||
75 | }; | ||
76 | |||
77 | static struct clk *clk[clk_max]; | ||
78 | |||
79 | int __init mx25_clocks_init(void) | ||
80 | { | ||
81 | int i; | ||
82 | |||
83 | clk[dummy] = imx_clk_fixed("dummy", 0); | ||
84 | clk[osc] = imx_clk_fixed("osc", 24000000); | ||
85 | clk[mpll] = imx_clk_pllv1("mpll", "osc", ccm(CCM_MPCTL)); | ||
86 | clk[upll] = imx_clk_pllv1("upll", "osc", ccm(CCM_UPCTL)); | ||
87 | clk[mpll_cpu_3_4] = imx_clk_fixed_factor("mpll_cpu_3_4", "mpll", 3, 4); | ||
88 | clk[cpu_sel] = imx_clk_mux("cpu_sel", ccm(CCM_CCTL), 14, 1, cpu_sel_clks, ARRAY_SIZE(cpu_sel_clks)); | ||
89 | clk[cpu] = imx_clk_divider("cpu", "cpu_sel", ccm(CCM_CCTL), 30, 2); | ||
90 | clk[ahb] = imx_clk_divider("ahb", "cpu", ccm(CCM_CCTL), 28, 2); | ||
91 | clk[usb_div] = imx_clk_divider("usb_div", "upll", ccm(CCM_CCTL), 16, 6); | ||
92 | clk[ipg] = imx_clk_fixed_factor("ipg", "ahb", 1, 2); | ||
93 | clk[per0_sel] = imx_clk_mux("per0_sel", ccm(CCM_MCR), 0, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks)); | ||
94 | clk[per1_sel] = imx_clk_mux("per1_sel", ccm(CCM_MCR), 1, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks)); | ||
95 | clk[per2_sel] = imx_clk_mux("per2_sel", ccm(CCM_MCR), 2, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks)); | ||
96 | clk[per3_sel] = imx_clk_mux("per3_sel", ccm(CCM_MCR), 3, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks)); | ||
97 | clk[per4_sel] = imx_clk_mux("per4_sel", ccm(CCM_MCR), 4, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks)); | ||
98 | clk[per5_sel] = imx_clk_mux("per5_sel", ccm(CCM_MCR), 5, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks)); | ||
99 | clk[per6_sel] = imx_clk_mux("per6_sel", ccm(CCM_MCR), 6, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks)); | ||
100 | clk[per7_sel] = imx_clk_mux("per7_sel", ccm(CCM_MCR), 7, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks)); | ||
101 | clk[per8_sel] = imx_clk_mux("per8_sel", ccm(CCM_MCR), 8, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks)); | ||
102 | clk[per9_sel] = imx_clk_mux("per9_sel", ccm(CCM_MCR), 9, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks)); | ||
103 | clk[per10_sel] = imx_clk_mux("per10_sel", ccm(CCM_MCR), 10, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks)); | ||
104 | clk[per11_sel] = imx_clk_mux("per11_sel", ccm(CCM_MCR), 11, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks)); | ||
105 | clk[per12_sel] = imx_clk_mux("per12_sel", ccm(CCM_MCR), 12, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks)); | ||
106 | clk[per13_sel] = imx_clk_mux("per13_sel", ccm(CCM_MCR), 13, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks)); | ||
107 | clk[per14_sel] = imx_clk_mux("per14_sel", ccm(CCM_MCR), 14, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks)); | ||
108 | clk[per15_sel] = imx_clk_mux("per15_sel", ccm(CCM_MCR), 15, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks)); | ||
109 | clk[per0] = imx_clk_divider("per0", "per0_sel", ccm(CCM_PCDR0), 0, 6); | ||
110 | clk[per1] = imx_clk_divider("per1", "per1_sel", ccm(CCM_PCDR0), 8, 6); | ||
111 | clk[per2] = imx_clk_divider("per2", "per2_sel", ccm(CCM_PCDR0), 16, 6); | ||
112 | clk[per3] = imx_clk_divider("per3", "per3_sel", ccm(CCM_PCDR0), 24, 6); | ||
113 | clk[per4] = imx_clk_divider("per4", "per4_sel", ccm(CCM_PCDR1), 0, 6); | ||
114 | clk[per5] = imx_clk_divider("per5", "per5_sel", ccm(CCM_PCDR1), 8, 6); | ||
115 | clk[per6] = imx_clk_divider("per6", "per6_sel", ccm(CCM_PCDR1), 16, 6); | ||
116 | clk[per7] = imx_clk_divider("per7", "per7_sel", ccm(CCM_PCDR1), 24, 6); | ||
117 | clk[per8] = imx_clk_divider("per8", "per8_sel", ccm(CCM_PCDR2), 0, 6); | ||
118 | clk[per9] = imx_clk_divider("per9", "per9_sel", ccm(CCM_PCDR2), 8, 6); | ||
119 | clk[per10] = imx_clk_divider("per10", "per10_sel", ccm(CCM_PCDR2), 16, 6); | ||
120 | clk[per11] = imx_clk_divider("per11", "per11_sel", ccm(CCM_PCDR2), 24, 6); | ||
121 | clk[per12] = imx_clk_divider("per12", "per12_sel", ccm(CCM_PCDR3), 0, 6); | ||
122 | clk[per13] = imx_clk_divider("per13", "per13_sel", ccm(CCM_PCDR3), 8, 6); | ||
123 | clk[per14] = imx_clk_divider("per14", "per14_sel", ccm(CCM_PCDR3), 16, 6); | ||
124 | clk[per15] = imx_clk_divider("per15", "per15_sel", ccm(CCM_PCDR3), 24, 6); | ||
125 | clk[csi_ipg_per] = imx_clk_gate("csi_ipg_per", "per0", ccm(CCM_CGCR0), 0); | ||
126 | clk[esdhc1_ipg_per] = imx_clk_gate("esdhc1_ipg_per", "per3", ccm(CCM_CGCR0), 3); | ||
127 | clk[esdhc2_ipg_per] = imx_clk_gate("esdhc2_ipg_per", "per4", ccm(CCM_CGCR0), 4); | ||
128 | clk[gpt_ipg_per] = imx_clk_gate("gpt_ipg_per", "per5", ccm(CCM_CGCR0), 5); | ||
129 | clk[i2c_ipg_per] = imx_clk_gate("i2c_ipg_per", "per6", ccm(CCM_CGCR0), 6); | ||
130 | clk[lcdc_ipg_per] = imx_clk_gate("lcdc_ipg_per", "per8", ccm(CCM_CGCR0), 7); | ||
131 | clk[nfc_ipg_per] = imx_clk_gate("nfc_ipg_per", "ipg_per", ccm(CCM_CGCR0), 8); | ||
132 | clk[ssi1_ipg_per] = imx_clk_gate("ssi1_ipg_per", "per13", ccm(CCM_CGCR0), 13); | ||
133 | clk[ssi2_ipg_per] = imx_clk_gate("ssi2_ipg_per", "per14", ccm(CCM_CGCR0), 14); | ||
134 | clk[uart_ipg_per] = imx_clk_gate("uart_ipg_per", "per15", ccm(CCM_CGCR0), 15); | ||
135 | clk[csi_ahb] = imx_clk_gate("csi_ahb", "ahb", ccm(CCM_CGCR0), 18); | ||
136 | clk[esdhc1_ahb] = imx_clk_gate("esdhc1_ahb", "ahb", ccm(CCM_CGCR0), 21); | ||
137 | clk[esdhc2_ahb] = imx_clk_gate("esdhc2_ahb", "ahb", ccm(CCM_CGCR0), 22); | ||
138 | clk[fec_ahb] = imx_clk_gate("fec_ahb", "ahb", ccm(CCM_CGCR0), 23); | ||
139 | clk[lcdc_ahb] = imx_clk_gate("lcdc_ahb", "ahb", ccm(CCM_CGCR0), 24); | ||
140 | clk[sdma_ahb] = imx_clk_gate("sdma_ahb", "ahb", ccm(CCM_CGCR0), 26); | ||
141 | clk[usbotg_ahb] = imx_clk_gate("usbotg_ahb", "ahb", ccm(CCM_CGCR0), 28); | ||
142 | clk[can1_ipg] = imx_clk_gate("can1_ipg", "ipg", ccm(CCM_CGCR1), 2); | ||
143 | clk[can2_ipg] = imx_clk_gate("can2_ipg", "ipg", ccm(CCM_CGCR1), 3); | ||
144 | clk[csi_ipg] = imx_clk_gate("csi_ipg", "ipg", ccm(CCM_CGCR1), 4); | ||
145 | clk[cspi1_ipg] = imx_clk_gate("cspi1_ipg", "ipg", ccm(CCM_CGCR1), 5); | ||
146 | clk[cspi2_ipg] = imx_clk_gate("cspi2_ipg", "ipg", ccm(CCM_CGCR1), 6); | ||
147 | clk[cspi3_ipg] = imx_clk_gate("cspi3_ipg", "ipg", ccm(CCM_CGCR1), 7); | ||
148 | clk[dryice_ipg] = imx_clk_gate("dryice_ipg", "ipg", ccm(CCM_CGCR1), 8); | ||
149 | clk[esdhc1_ipg] = imx_clk_gate("esdhc1_ipg", "ipg", ccm(CCM_CGCR1), 13); | ||
150 | clk[esdhc2_ipg] = imx_clk_gate("esdhc2_ipg", "ipg", ccm(CCM_CGCR1), 14); | ||
151 | clk[fec_ipg] = imx_clk_gate("fec_ipg", "ipg", ccm(CCM_CGCR1), 15); | ||
152 | clk[iim_ipg] = imx_clk_gate("iim_ipg", "ipg", ccm(CCM_CGCR1), 26); | ||
153 | clk[kpp_ipg] = imx_clk_gate("kpp_ipg", "ipg", ccm(CCM_CGCR1), 28); | ||
154 | clk[lcdc_ipg] = imx_clk_gate("lcdc_ipg", "ipg", ccm(CCM_CGCR1), 29); | ||
155 | clk[pwm1_ipg] = imx_clk_gate("pwm1_ipg", "ipg", ccm(CCM_CGCR1), 31); | ||
156 | clk[pwm2_ipg] = imx_clk_gate("pwm2_ipg", "ipg", ccm(CCM_CGCR2), 0); | ||
157 | clk[pwm3_ipg] = imx_clk_gate("pwm3_ipg", "ipg", ccm(CCM_CGCR2), 1); | ||
158 | clk[pwm4_ipg] = imx_clk_gate("pwm4_ipg", "ipg", ccm(CCM_CGCR2), 2); | ||
159 | clk[sdma_ipg] = imx_clk_gate("sdma_ipg", "ipg", ccm(CCM_CGCR2), 6); | ||
160 | clk[ssi1_ipg] = imx_clk_gate("ssi1_ipg", "ipg", ccm(CCM_CGCR2), 11); | ||
161 | clk[ssi2_ipg] = imx_clk_gate("ssi2_ipg", "ipg", ccm(CCM_CGCR2), 12); | ||
162 | clk[tsc_ipg] = imx_clk_gate("tsc_ipg", "ipg", ccm(CCM_CGCR2), 13); | ||
163 | clk[uart1_ipg] = imx_clk_gate("uart1_ipg", "ipg", ccm(CCM_CGCR2), 14); | ||
164 | clk[uart2_ipg] = imx_clk_gate("uart2_ipg", "ipg", ccm(CCM_CGCR2), 15); | ||
165 | clk[uart3_ipg] = imx_clk_gate("uart3_ipg", "ipg", ccm(CCM_CGCR2), 16); | ||
166 | clk[uart4_ipg] = imx_clk_gate("uart4_ipg", "ipg", ccm(CCM_CGCR2), 17); | ||
167 | clk[uart5_ipg] = imx_clk_gate("uart5_ipg", "ipg", ccm(CCM_CGCR2), 18); | ||
168 | clk[wdt_ipg] = imx_clk_gate("wdt_ipg", "ipg", ccm(CCM_CGCR2), 19); | ||
169 | |||
170 | for (i = 0; i < ARRAY_SIZE(clk); i++) | ||
171 | if (IS_ERR(clk[i])) | ||
172 | pr_err("i.MX25 clk %d: register failed with %ld\n", | ||
173 | i, PTR_ERR(clk[i])); | ||
174 | |||
175 | /* i.mx25 has the i.mx21 type uart */ | ||
176 | clk_register_clkdev(clk[uart1_ipg], "ipg", "imx21-uart.0"); | ||
177 | clk_register_clkdev(clk[uart_ipg_per], "per", "imx21-uart.0"); | ||
178 | clk_register_clkdev(clk[uart2_ipg], "ipg", "imx21-uart.1"); | ||
179 | clk_register_clkdev(clk[uart_ipg_per], "per", "imx21-uart.1"); | ||
180 | clk_register_clkdev(clk[uart3_ipg], "ipg", "imx21-uart.2"); | ||
181 | clk_register_clkdev(clk[uart_ipg_per], "per", "imx21-uart.2"); | ||
182 | clk_register_clkdev(clk[uart4_ipg], "ipg", "imx21-uart.3"); | ||
183 | clk_register_clkdev(clk[uart_ipg_per], "per", "imx21-uart.3"); | ||
184 | clk_register_clkdev(clk[uart5_ipg], "ipg", "imx21-uart.4"); | ||
185 | clk_register_clkdev(clk[uart_ipg_per], "per", "imx21-uart.4"); | ||
186 | clk_register_clkdev(clk[ipg], "ipg", "imx-gpt.0"); | ||
187 | clk_register_clkdev(clk[gpt_ipg_per], "per", "imx-gpt.0"); | ||
188 | clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.0"); | ||
189 | clk_register_clkdev(clk[usbotg_ahb], "ahb", "mxc-ehci.0"); | ||
190 | clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.0"); | ||
191 | clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.1"); | ||
192 | clk_register_clkdev(clk[usbotg_ahb], "ahb", "mxc-ehci.1"); | ||
193 | clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.1"); | ||
194 | clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.2"); | ||
195 | clk_register_clkdev(clk[usbotg_ahb], "ahb", "mxc-ehci.2"); | ||
196 | clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.2"); | ||
197 | clk_register_clkdev(clk[ipg], "ipg", "fsl-usb2-udc"); | ||
198 | clk_register_clkdev(clk[usbotg_ahb], "ahb", "fsl-usb2-udc"); | ||
199 | clk_register_clkdev(clk[usb_div], "per", "fsl-usb2-udc"); | ||
200 | clk_register_clkdev(clk[nfc_ipg_per], NULL, "mxc_nand.0"); | ||
201 | /* i.mx25 has the i.mx35 type cspi */ | ||
202 | clk_register_clkdev(clk[cspi1_ipg], NULL, "imx35-cspi.0"); | ||
203 | clk_register_clkdev(clk[cspi2_ipg], NULL, "imx35-cspi.1"); | ||
204 | clk_register_clkdev(clk[cspi3_ipg], NULL, "imx35-cspi.2"); | ||
205 | clk_register_clkdev(clk[pwm1_ipg], "ipg", "mxc_pwm.0"); | ||
206 | clk_register_clkdev(clk[per10], "per", "mxc_pwm.0"); | ||
207 | clk_register_clkdev(clk[pwm1_ipg], "ipg", "mxc_pwm.1"); | ||
208 | clk_register_clkdev(clk[per10], "per", "mxc_pwm.1"); | ||
209 | clk_register_clkdev(clk[pwm1_ipg], "ipg", "mxc_pwm.2"); | ||
210 | clk_register_clkdev(clk[per10], "per", "mxc_pwm.2"); | ||
211 | clk_register_clkdev(clk[pwm1_ipg], "ipg", "mxc_pwm.3"); | ||
212 | clk_register_clkdev(clk[per10], "per", "mxc_pwm.3"); | ||
213 | clk_register_clkdev(clk[kpp_ipg], NULL, "imx-keypad"); | ||
214 | clk_register_clkdev(clk[tsc_ipg], NULL, "mx25-adc"); | ||
215 | clk_register_clkdev(clk[i2c_ipg_per], NULL, "imx-i2c.0"); | ||
216 | clk_register_clkdev(clk[i2c_ipg_per], NULL, "imx-i2c.1"); | ||
217 | clk_register_clkdev(clk[i2c_ipg_per], NULL, "imx-i2c.2"); | ||
218 | clk_register_clkdev(clk[fec_ipg], "ipg", "imx25-fec.0"); | ||
219 | clk_register_clkdev(clk[fec_ahb], "ahb", "imx25-fec.0"); | ||
220 | clk_register_clkdev(clk[dryice_ipg], NULL, "imxdi_rtc.0"); | ||
221 | clk_register_clkdev(clk[lcdc_ipg_per], "per", "imx-fb.0"); | ||
222 | clk_register_clkdev(clk[lcdc_ipg], "ipg", "imx-fb.0"); | ||
223 | clk_register_clkdev(clk[lcdc_ahb], "ahb", "imx-fb.0"); | ||
224 | clk_register_clkdev(clk[wdt_ipg], NULL, "imx2-wdt.0"); | ||
225 | clk_register_clkdev(clk[ssi1_ipg_per], "per", "imx-ssi.0"); | ||
226 | clk_register_clkdev(clk[ssi1_ipg], "ipg", "imx-ssi.0"); | ||
227 | clk_register_clkdev(clk[ssi2_ipg_per], "per", "imx-ssi.1"); | ||
228 | clk_register_clkdev(clk[ssi2_ipg], "ipg", "imx-ssi.1"); | ||
229 | clk_register_clkdev(clk[esdhc1_ipg_per], "per", "sdhci-esdhc-imx25.0"); | ||
230 | clk_register_clkdev(clk[esdhc1_ipg], "ipg", "sdhci-esdhc-imx25.0"); | ||
231 | clk_register_clkdev(clk[esdhc1_ahb], "ahb", "sdhci-esdhc-imx25.0"); | ||
232 | clk_register_clkdev(clk[esdhc2_ipg_per], "per", "sdhci-esdhc-imx25.1"); | ||
233 | clk_register_clkdev(clk[esdhc2_ipg], "ipg", "sdhci-esdhc-imx25.1"); | ||
234 | clk_register_clkdev(clk[esdhc2_ahb], "ahb", "sdhci-esdhc-imx25.1"); | ||
235 | clk_register_clkdev(clk[csi_ipg_per], "per", "mx2-camera.0"); | ||
236 | clk_register_clkdev(clk[csi_ipg], "ipg", "mx2-camera.0"); | ||
237 | clk_register_clkdev(clk[csi_ahb], "ahb", "mx2-camera.0"); | ||
238 | clk_register_clkdev(clk[dummy], "audmux", NULL); | ||
239 | clk_register_clkdev(clk[can1_ipg], NULL, "flexcan.0"); | ||
240 | clk_register_clkdev(clk[can2_ipg], NULL, "flexcan.1"); | ||
241 | /* i.mx25 has the i.mx35 type sdma */ | ||
242 | clk_register_clkdev(clk[sdma_ipg], "ipg", "imx35-sdma"); | ||
243 | clk_register_clkdev(clk[sdma_ahb], "ahb", "imx35-sdma"); | ||
244 | clk_register_clkdev(clk[iim_ipg], "iim", NULL); | ||
245 | |||
246 | mxc_timer_init(NULL, MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR), 54); | ||
247 | return 0; | ||
248 | } | ||
diff --git a/arch/arm/mach-imx/clk-imx27.c b/arch/arm/mach-imx/clk-imx27.c new file mode 100644 index 000000000000..50a7ebd8d1b2 --- /dev/null +++ b/arch/arm/mach-imx/clk-imx27.c | |||
@@ -0,0 +1,290 @@ | |||
1 | #include <linux/clk.h> | ||
2 | #include <linux/io.h> | ||
3 | #include <linux/module.h> | ||
4 | #include <linux/clkdev.h> | ||
5 | #include <linux/err.h> | ||
6 | #include <linux/clk-provider.h> | ||
7 | #include <linux/of.h> | ||
8 | |||
9 | #include <mach/common.h> | ||
10 | #include <mach/hardware.h> | ||
11 | #include "clk.h" | ||
12 | |||
13 | #define IO_ADDR_CCM(off) (MX27_IO_ADDRESS(MX27_CCM_BASE_ADDR + (off))) | ||
14 | |||
15 | /* Register offsets */ | ||
16 | #define CCM_CSCR IO_ADDR_CCM(0x0) | ||
17 | #define CCM_MPCTL0 IO_ADDR_CCM(0x4) | ||
18 | #define CCM_MPCTL1 IO_ADDR_CCM(0x8) | ||
19 | #define CCM_SPCTL0 IO_ADDR_CCM(0xc) | ||
20 | #define CCM_SPCTL1 IO_ADDR_CCM(0x10) | ||
21 | #define CCM_OSC26MCTL IO_ADDR_CCM(0x14) | ||
22 | #define CCM_PCDR0 IO_ADDR_CCM(0x18) | ||
23 | #define CCM_PCDR1 IO_ADDR_CCM(0x1c) | ||
24 | #define CCM_PCCR0 IO_ADDR_CCM(0x20) | ||
25 | #define CCM_PCCR1 IO_ADDR_CCM(0x24) | ||
26 | #define CCM_CCSR IO_ADDR_CCM(0x28) | ||
27 | #define CCM_PMCTL IO_ADDR_CCM(0x2c) | ||
28 | #define CCM_PMCOUNT IO_ADDR_CCM(0x30) | ||
29 | #define CCM_WKGDCTL IO_ADDR_CCM(0x34) | ||
30 | |||
31 | #define CCM_CSCR_UPDATE_DIS (1 << 31) | ||
32 | #define CCM_CSCR_SSI2 (1 << 23) | ||
33 | #define CCM_CSCR_SSI1 (1 << 22) | ||
34 | #define CCM_CSCR_VPU (1 << 21) | ||
35 | #define CCM_CSCR_MSHC (1 << 20) | ||
36 | #define CCM_CSCR_SPLLRES (1 << 19) | ||
37 | #define CCM_CSCR_MPLLRES (1 << 18) | ||
38 | #define CCM_CSCR_SP (1 << 17) | ||
39 | #define CCM_CSCR_MCU (1 << 16) | ||
40 | #define CCM_CSCR_OSC26MDIV (1 << 4) | ||
41 | #define CCM_CSCR_OSC26M (1 << 3) | ||
42 | #define CCM_CSCR_FPM (1 << 2) | ||
43 | #define CCM_CSCR_SPEN (1 << 1) | ||
44 | #define CCM_CSCR_MPEN (1 << 0) | ||
45 | |||
46 | /* i.MX27 TO 2+ */ | ||
47 | #define CCM_CSCR_ARM_SRC (1 << 15) | ||
48 | |||
49 | #define CCM_SPCTL1_LF (1 << 15) | ||
50 | #define CCM_SPCTL1_BRMO (1 << 6) | ||
51 | |||
52 | static const char *vpu_sel_clks[] = { "spll", "mpll_main2", }; | ||
53 | static const char *cpu_sel_clks[] = { "mpll_main2", "mpll", }; | ||
54 | static const char *clko_sel_clks[] = { | ||
55 | "ckil", "prem", "ckih", "ckih", | ||
56 | "ckih", "mpll", "spll", "cpu_div", | ||
57 | "ahb", "ipg", "per1_div", "per2_div", | ||
58 | "per3_div", "per4_div", "ssi1_div", "ssi2_div", | ||
59 | "nfc_div", "mshc_div", "vpu_div", "60m", | ||
60 | "32k", "usb_div", "dptc", | ||
61 | }; | ||
62 | |||
63 | static const char *ssi_sel_clks[] = { "spll", "mpll", }; | ||
64 | |||
65 | enum mx27_clks { | ||
66 | dummy, ckih, ckil, mpll, spll, mpll_main2, ahb, ipg, nfc_div, per1_div, | ||
67 | per2_div, per3_div, per4_div, vpu_sel, vpu_div, usb_div, cpu_sel, | ||
68 | clko_sel, cpu_div, clko_div, ssi1_sel, ssi2_sel, ssi1_div, ssi2_div, | ||
69 | clko_en, ssi2_ipg_gate, ssi1_ipg_gate, slcdc_ipg_gate, sdhc3_ipg_gate, | ||
70 | sdhc2_ipg_gate, sdhc1_ipg_gate, scc_ipg_gate, sahara_ipg_gate, | ||
71 | rtc_ipg_gate, pwm_ipg_gate, owire_ipg_gate, lcdc_ipg_gate, | ||
72 | kpp_ipg_gate, iim_ipg_gate, i2c2_ipg_gate, i2c1_ipg_gate, | ||
73 | gpt6_ipg_gate, gpt5_ipg_gate, gpt4_ipg_gate, gpt3_ipg_gate, | ||
74 | gpt2_ipg_gate, gpt1_ipg_gate, gpio_ipg_gate, fec_ipg_gate, | ||
75 | emma_ipg_gate, dma_ipg_gate, cspi3_ipg_gate, cspi2_ipg_gate, | ||
76 | cspi1_ipg_gate, nfc_baud_gate, ssi2_baud_gate, ssi1_baud_gate, | ||
77 | vpu_baud_gate, per4_gate, per3_gate, per2_gate, per1_gate, | ||
78 | usb_ahb_gate, slcdc_ahb_gate, sahara_ahb_gate, lcdc_ahb_gate, | ||
79 | vpu_ahb_gate, fec_ahb_gate, emma_ahb_gate, emi_ahb_gate, dma_ahb_gate, | ||
80 | csi_ahb_gate, brom_ahb_gate, ata_ahb_gate, wdog_ipg_gate, usb_ipg_gate, | ||
81 | uart6_ipg_gate, uart5_ipg_gate, uart4_ipg_gate, uart3_ipg_gate, | ||
82 | uart2_ipg_gate, uart1_ipg_gate, clk_max | ||
83 | }; | ||
84 | |||
85 | static struct clk *clk[clk_max]; | ||
86 | |||
87 | int __init mx27_clocks_init(unsigned long fref) | ||
88 | { | ||
89 | int i; | ||
90 | |||
91 | clk[dummy] = imx_clk_fixed("dummy", 0); | ||
92 | clk[ckih] = imx_clk_fixed("ckih", fref); | ||
93 | clk[ckil] = imx_clk_fixed("ckil", 32768); | ||
94 | clk[mpll] = imx_clk_pllv1("mpll", "ckih", CCM_MPCTL0); | ||
95 | clk[spll] = imx_clk_pllv1("spll", "ckih", CCM_SPCTL0); | ||
96 | clk[mpll_main2] = imx_clk_fixed_factor("mpll_main2", "mpll", 2, 3); | ||
97 | |||
98 | if (mx27_revision() >= IMX_CHIP_REVISION_2_0) { | ||
99 | clk[ahb] = imx_clk_divider("ahb", "mpll_main2", CCM_CSCR, 8, 2); | ||
100 | clk[ipg] = imx_clk_fixed_factor("ipg", "ahb", 1, 2); | ||
101 | } else { | ||
102 | clk[ahb] = imx_clk_divider("ahb", "mpll_main2", CCM_CSCR, 9, 4); | ||
103 | clk[ipg] = imx_clk_divider("ipg", "ahb", CCM_CSCR, 8, 1); | ||
104 | } | ||
105 | |||
106 | clk[nfc_div] = imx_clk_divider("nfc_div", "ahb", CCM_PCDR0, 6, 4); | ||
107 | clk[per1_div] = imx_clk_divider("per1_div", "mpll_main2", CCM_PCDR1, 0, 6); | ||
108 | clk[per2_div] = imx_clk_divider("per2_div", "mpll_main2", CCM_PCDR1, 8, 6); | ||
109 | clk[per3_div] = imx_clk_divider("per3_div", "mpll_main2", CCM_PCDR1, 16, 6); | ||
110 | clk[per4_div] = imx_clk_divider("per4_div", "mpll_main2", CCM_PCDR1, 24, 6); | ||
111 | clk[vpu_sel] = imx_clk_mux("vpu_sel", CCM_CSCR, 21, 1, vpu_sel_clks, ARRAY_SIZE(vpu_sel_clks)); | ||
112 | clk[vpu_div] = imx_clk_divider("vpu_div", "vpu_sel", CCM_PCDR0, 10, 3); | ||
113 | clk[usb_div] = imx_clk_divider("usb_div", "spll", CCM_CSCR, 28, 3); | ||
114 | clk[cpu_sel] = imx_clk_mux("cpu_sel", CCM_CSCR, 15, 1, cpu_sel_clks, ARRAY_SIZE(cpu_sel_clks)); | ||
115 | clk[clko_sel] = imx_clk_mux("clko_sel", CCM_CCSR, 0, 5, clko_sel_clks, ARRAY_SIZE(clko_sel_clks)); | ||
116 | if (mx27_revision() >= IMX_CHIP_REVISION_2_0) | ||
117 | clk[cpu_div] = imx_clk_divider("cpu_div", "cpu_sel", CCM_CSCR, 12, 2); | ||
118 | else | ||
119 | clk[cpu_div] = imx_clk_divider("cpu_div", "cpu_sel", CCM_CSCR, 13, 3); | ||
120 | clk[clko_div] = imx_clk_divider("clko_div", "clko_sel", CCM_PCDR0, 22, 3); | ||
121 | clk[ssi1_sel] = imx_clk_mux("ssi1_sel", CCM_CSCR, 22, 1, ssi_sel_clks, ARRAY_SIZE(ssi_sel_clks)); | ||
122 | clk[ssi2_sel] = imx_clk_mux("ssi2_sel", CCM_CSCR, 23, 1, ssi_sel_clks, ARRAY_SIZE(ssi_sel_clks)); | ||
123 | clk[ssi1_div] = imx_clk_divider("ssi1_div", "ssi1_sel", CCM_PCDR0, 16, 6); | ||
124 | clk[ssi2_div] = imx_clk_divider("ssi2_div", "ssi2_sel", CCM_PCDR0, 26, 3); | ||
125 | clk[clko_en] = imx_clk_gate("clko_en", "clko_div", CCM_PCCR0, 0); | ||
126 | clk[ssi2_ipg_gate] = imx_clk_gate("ssi2_ipg_gate", "ipg", CCM_PCCR0, 0); | ||
127 | clk[ssi1_ipg_gate] = imx_clk_gate("ssi1_ipg_gate", "ipg", CCM_PCCR0, 1); | ||
128 | clk[slcdc_ipg_gate] = imx_clk_gate("slcdc_ipg_gate", "ipg", CCM_PCCR0, 2); | ||
129 | clk[sdhc3_ipg_gate] = imx_clk_gate("sdhc3_ipg_gate", "ipg", CCM_PCCR0, 3); | ||
130 | clk[sdhc2_ipg_gate] = imx_clk_gate("sdhc2_ipg_gate", "ipg", CCM_PCCR0, 4); | ||
131 | clk[sdhc1_ipg_gate] = imx_clk_gate("sdhc1_ipg_gate", "ipg", CCM_PCCR0, 5); | ||
132 | clk[scc_ipg_gate] = imx_clk_gate("scc_ipg_gate", "ipg", CCM_PCCR0, 6); | ||
133 | clk[sahara_ipg_gate] = imx_clk_gate("sahara_ipg_gate", "ipg", CCM_PCCR0, 7); | ||
134 | clk[rtc_ipg_gate] = imx_clk_gate("rtc_ipg_gate", "ipg", CCM_PCCR0, 9); | ||
135 | clk[pwm_ipg_gate] = imx_clk_gate("pwm_ipg_gate", "ipg", CCM_PCCR0, 11); | ||
136 | clk[owire_ipg_gate] = imx_clk_gate("owire_ipg_gate", "ipg", CCM_PCCR0, 12); | ||
137 | clk[lcdc_ipg_gate] = imx_clk_gate("lcdc_ipg_gate", "ipg", CCM_PCCR0, 14); | ||
138 | clk[kpp_ipg_gate] = imx_clk_gate("kpp_ipg_gate", "ipg", CCM_PCCR0, 15); | ||
139 | clk[iim_ipg_gate] = imx_clk_gate("iim_ipg_gate", "ipg", CCM_PCCR0, 16); | ||
140 | clk[i2c2_ipg_gate] = imx_clk_gate("i2c2_ipg_gate", "ipg", CCM_PCCR0, 17); | ||
141 | clk[i2c1_ipg_gate] = imx_clk_gate("i2c1_ipg_gate", "ipg", CCM_PCCR0, 18); | ||
142 | clk[gpt6_ipg_gate] = imx_clk_gate("gpt6_ipg_gate", "ipg", CCM_PCCR0, 19); | ||
143 | clk[gpt5_ipg_gate] = imx_clk_gate("gpt5_ipg_gate", "ipg", CCM_PCCR0, 20); | ||
144 | clk[gpt4_ipg_gate] = imx_clk_gate("gpt4_ipg_gate", "ipg", CCM_PCCR0, 21); | ||
145 | clk[gpt3_ipg_gate] = imx_clk_gate("gpt3_ipg_gate", "ipg", CCM_PCCR0, 22); | ||
146 | clk[gpt2_ipg_gate] = imx_clk_gate("gpt2_ipg_gate", "ipg", CCM_PCCR0, 23); | ||
147 | clk[gpt1_ipg_gate] = imx_clk_gate("gpt1_ipg_gate", "ipg", CCM_PCCR0, 24); | ||
148 | clk[gpio_ipg_gate] = imx_clk_gate("gpio_ipg_gate", "ipg", CCM_PCCR0, 25); | ||
149 | clk[fec_ipg_gate] = imx_clk_gate("fec_ipg_gate", "ipg", CCM_PCCR0, 26); | ||
150 | clk[emma_ipg_gate] = imx_clk_gate("emma_ipg_gate", "ipg", CCM_PCCR0, 27); | ||
151 | clk[dma_ipg_gate] = imx_clk_gate("dma_ipg_gate", "ipg", CCM_PCCR0, 28); | ||
152 | clk[cspi3_ipg_gate] = imx_clk_gate("cspi3_ipg_gate", "ipg", CCM_PCCR0, 29); | ||
153 | clk[cspi2_ipg_gate] = imx_clk_gate("cspi2_ipg_gate", "ipg", CCM_PCCR0, 30); | ||
154 | clk[cspi1_ipg_gate] = imx_clk_gate("cspi1_ipg_gate", "ipg", CCM_PCCR0, 31); | ||
155 | clk[nfc_baud_gate] = imx_clk_gate("nfc_baud_gate", "nfc_div", CCM_PCCR1, 3); | ||
156 | clk[ssi2_baud_gate] = imx_clk_gate("ssi2_baud_gate", "ssi2_div", CCM_PCCR1, 4); | ||
157 | clk[ssi1_baud_gate] = imx_clk_gate("ssi1_baud_gate", "ssi1_div", CCM_PCCR1, 5); | ||
158 | clk[vpu_baud_gate] = imx_clk_gate("vpu_baud_gate", "vpu_div", CCM_PCCR1, 6); | ||
159 | clk[per4_gate] = imx_clk_gate("per4_gate", "per4_div", CCM_PCCR1, 7); | ||
160 | clk[per3_gate] = imx_clk_gate("per3_gate", "per3_div", CCM_PCCR1, 8); | ||
161 | clk[per2_gate] = imx_clk_gate("per2_gate", "per2_div", CCM_PCCR1, 9); | ||
162 | clk[per1_gate] = imx_clk_gate("per1_gate", "per1_div", CCM_PCCR1, 10); | ||
163 | clk[usb_ahb_gate] = imx_clk_gate("usb_ahb_gate", "ahb", CCM_PCCR1, 11); | ||
164 | clk[slcdc_ahb_gate] = imx_clk_gate("slcdc_ahb_gate", "ahb", CCM_PCCR1, 12); | ||
165 | clk[sahara_ahb_gate] = imx_clk_gate("sahara_ahb_gate", "ahb", CCM_PCCR1, 13); | ||
166 | clk[lcdc_ahb_gate] = imx_clk_gate("lcdc_ahb_gate", "ahb", CCM_PCCR1, 15); | ||
167 | clk[vpu_ahb_gate] = imx_clk_gate("vpu_ahb_gate", "ahb", CCM_PCCR1, 16); | ||
168 | clk[fec_ahb_gate] = imx_clk_gate("fec_ahb_gate", "ahb", CCM_PCCR1, 17); | ||
169 | clk[emma_ahb_gate] = imx_clk_gate("emma_ahb_gate", "ahb", CCM_PCCR1, 18); | ||
170 | clk[emi_ahb_gate] = imx_clk_gate("emi_ahb_gate", "ahb", CCM_PCCR1, 19); | ||
171 | clk[dma_ahb_gate] = imx_clk_gate("dma_ahb_gate", "ahb", CCM_PCCR1, 20); | ||
172 | clk[csi_ahb_gate] = imx_clk_gate("csi_ahb_gate", "ahb", CCM_PCCR1, 21); | ||
173 | clk[brom_ahb_gate] = imx_clk_gate("brom_ahb_gate", "ahb", CCM_PCCR1, 22); | ||
174 | clk[ata_ahb_gate] = imx_clk_gate("ata_ahb_gate", "ahb", CCM_PCCR1, 23); | ||
175 | clk[wdog_ipg_gate] = imx_clk_gate("wdog_ipg_gate", "ipg", CCM_PCCR1, 24); | ||
176 | clk[usb_ipg_gate] = imx_clk_gate("usb_ipg_gate", "ipg", CCM_PCCR1, 25); | ||
177 | clk[uart6_ipg_gate] = imx_clk_gate("uart6_ipg_gate", "ipg", CCM_PCCR1, 26); | ||
178 | clk[uart5_ipg_gate] = imx_clk_gate("uart5_ipg_gate", "ipg", CCM_PCCR1, 27); | ||
179 | clk[uart4_ipg_gate] = imx_clk_gate("uart4_ipg_gate", "ipg", CCM_PCCR1, 28); | ||
180 | clk[uart3_ipg_gate] = imx_clk_gate("uart3_ipg_gate", "ipg", CCM_PCCR1, 29); | ||
181 | clk[uart2_ipg_gate] = imx_clk_gate("uart2_ipg_gate", "ipg", CCM_PCCR1, 30); | ||
182 | clk[uart1_ipg_gate] = imx_clk_gate("uart1_ipg_gate", "ipg", CCM_PCCR1, 31); | ||
183 | |||
184 | for (i = 0; i < ARRAY_SIZE(clk); i++) | ||
185 | if (IS_ERR(clk[i])) | ||
186 | pr_err("i.MX27 clk %d: register failed with %ld\n", | ||
187 | i, PTR_ERR(clk[i])); | ||
188 | |||
189 | clk_register_clkdev(clk[uart1_ipg_gate], "ipg", "imx21-uart.0"); | ||
190 | clk_register_clkdev(clk[per1_gate], "per", "imx21-uart.0"); | ||
191 | clk_register_clkdev(clk[uart2_ipg_gate], "ipg", "imx21-uart.1"); | ||
192 | clk_register_clkdev(clk[per1_gate], "per", "imx21-uart.1"); | ||
193 | clk_register_clkdev(clk[uart3_ipg_gate], "ipg", "imx21-uart.2"); | ||
194 | clk_register_clkdev(clk[per1_gate], "per", "imx21-uart.2"); | ||
195 | clk_register_clkdev(clk[uart4_ipg_gate], "ipg", "imx21-uart.3"); | ||
196 | clk_register_clkdev(clk[per1_gate], "per", "imx21-uart.3"); | ||
197 | clk_register_clkdev(clk[uart5_ipg_gate], "ipg", "imx21-uart.4"); | ||
198 | clk_register_clkdev(clk[per1_gate], "per", "imx21-uart.4"); | ||
199 | clk_register_clkdev(clk[uart6_ipg_gate], "ipg", "imx21-uart.5"); | ||
200 | clk_register_clkdev(clk[per1_gate], "per", "imx21-uart.5"); | ||
201 | clk_register_clkdev(clk[gpt1_ipg_gate], "ipg", "imx-gpt.0"); | ||
202 | clk_register_clkdev(clk[per1_gate], "per", "imx-gpt.0"); | ||
203 | clk_register_clkdev(clk[gpt2_ipg_gate], "ipg", "imx-gpt.1"); | ||
204 | clk_register_clkdev(clk[per1_gate], "per", "imx-gpt.1"); | ||
205 | clk_register_clkdev(clk[gpt3_ipg_gate], "ipg", "imx-gpt.2"); | ||
206 | clk_register_clkdev(clk[per1_gate], "per", "imx-gpt.2"); | ||
207 | clk_register_clkdev(clk[gpt4_ipg_gate], "ipg", "imx-gpt.3"); | ||
208 | clk_register_clkdev(clk[per1_gate], "per", "imx-gpt.3"); | ||
209 | clk_register_clkdev(clk[gpt5_ipg_gate], "ipg", "imx-gpt.4"); | ||
210 | clk_register_clkdev(clk[per1_gate], "per", "imx-gpt.4"); | ||
211 | clk_register_clkdev(clk[gpt6_ipg_gate], "ipg", "imx-gpt.5"); | ||
212 | clk_register_clkdev(clk[per1_gate], "per", "imx-gpt.5"); | ||
213 | clk_register_clkdev(clk[pwm_ipg_gate], NULL, "mxc_pwm.0"); | ||
214 | clk_register_clkdev(clk[per2_gate], "per", "mxc-mmc.0"); | ||
215 | clk_register_clkdev(clk[sdhc1_ipg_gate], "ipg", "mxc-mmc.0"); | ||
216 | clk_register_clkdev(clk[per2_gate], "per", "mxc-mmc.1"); | ||
217 | clk_register_clkdev(clk[sdhc2_ipg_gate], "ipg", "mxc-mmc.1"); | ||
218 | clk_register_clkdev(clk[per2_gate], "per", "mxc-mmc.2"); | ||
219 | clk_register_clkdev(clk[sdhc2_ipg_gate], "ipg", "mxc-mmc.2"); | ||
220 | clk_register_clkdev(clk[cspi1_ipg_gate], NULL, "imx27-cspi.0"); | ||
221 | clk_register_clkdev(clk[cspi2_ipg_gate], NULL, "imx27-cspi.1"); | ||
222 | clk_register_clkdev(clk[cspi3_ipg_gate], NULL, "imx27-cspi.2"); | ||
223 | clk_register_clkdev(clk[per3_gate], "per", "imx-fb.0"); | ||
224 | clk_register_clkdev(clk[lcdc_ipg_gate], "ipg", "imx-fb.0"); | ||
225 | clk_register_clkdev(clk[lcdc_ahb_gate], "ahb", "imx-fb.0"); | ||
226 | clk_register_clkdev(clk[csi_ahb_gate], NULL, "mx2-camera.0"); | ||
227 | clk_register_clkdev(clk[usb_div], "per", "fsl-usb2-udc"); | ||
228 | clk_register_clkdev(clk[usb_ipg_gate], "ipg", "fsl-usb2-udc"); | ||
229 | clk_register_clkdev(clk[usb_ahb_gate], "ahb", "fsl-usb2-udc"); | ||
230 | clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.0"); | ||
231 | clk_register_clkdev(clk[usb_ipg_gate], "ipg", "mxc-ehci.0"); | ||
232 | clk_register_clkdev(clk[usb_ahb_gate], "ahb", "mxc-ehci.0"); | ||
233 | clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.1"); | ||
234 | clk_register_clkdev(clk[usb_ipg_gate], "ipg", "mxc-ehci.1"); | ||
235 | clk_register_clkdev(clk[usb_ahb_gate], "ahb", "mxc-ehci.1"); | ||
236 | clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.2"); | ||
237 | clk_register_clkdev(clk[usb_ipg_gate], "ipg", "mxc-ehci.2"); | ||
238 | clk_register_clkdev(clk[usb_ahb_gate], "ahb", "mxc-ehci.2"); | ||
239 | clk_register_clkdev(clk[ssi1_ipg_gate], NULL, "imx-ssi.0"); | ||
240 | clk_register_clkdev(clk[ssi2_ipg_gate], NULL, "imx-ssi.1"); | ||
241 | clk_register_clkdev(clk[nfc_baud_gate], NULL, "mxc_nand.0"); | ||
242 | clk_register_clkdev(clk[vpu_baud_gate], "per", "imx-vpu"); | ||
243 | clk_register_clkdev(clk[vpu_ahb_gate], "ahb", "imx-vpu"); | ||
244 | clk_register_clkdev(clk[dma_ahb_gate], "ahb", "imx-dma"); | ||
245 | clk_register_clkdev(clk[dma_ipg_gate], "ipg", "imx-dma"); | ||
246 | clk_register_clkdev(clk[fec_ipg_gate], "ipg", "imx27-fec.0"); | ||
247 | clk_register_clkdev(clk[fec_ahb_gate], "ahb", "imx27-fec.0"); | ||
248 | clk_register_clkdev(clk[wdog_ipg_gate], NULL, "imx2-wdt.0"); | ||
249 | clk_register_clkdev(clk[i2c1_ipg_gate], NULL, "imx-i2c.0"); | ||
250 | clk_register_clkdev(clk[i2c2_ipg_gate], NULL, "imx-i2c.1"); | ||
251 | clk_register_clkdev(clk[owire_ipg_gate], NULL, "mxc_w1.0"); | ||
252 | clk_register_clkdev(clk[kpp_ipg_gate], NULL, "imx-keypad"); | ||
253 | clk_register_clkdev(clk[emma_ahb_gate], "ahb", "imx-emma"); | ||
254 | clk_register_clkdev(clk[emma_ipg_gate], "ipg", "imx-emma"); | ||
255 | clk_register_clkdev(clk[iim_ipg_gate], "iim", NULL); | ||
256 | clk_register_clkdev(clk[gpio_ipg_gate], "gpio", NULL); | ||
257 | clk_register_clkdev(clk[brom_ahb_gate], "brom", NULL); | ||
258 | clk_register_clkdev(clk[ata_ahb_gate], "ata", NULL); | ||
259 | clk_register_clkdev(clk[rtc_ipg_gate], "rtc", NULL); | ||
260 | clk_register_clkdev(clk[scc_ipg_gate], "scc", NULL); | ||
261 | clk_register_clkdev(clk[cpu_div], "cpu", NULL); | ||
262 | clk_register_clkdev(clk[emi_ahb_gate], "emi_ahb" , NULL); | ||
263 | clk_register_clkdev(clk[ssi1_baud_gate], "bitrate" , "imx-ssi.0"); | ||
264 | clk_register_clkdev(clk[ssi2_baud_gate], "bitrate" , "imx-ssi.1"); | ||
265 | |||
266 | mxc_timer_init(NULL, MX27_IO_ADDRESS(MX27_GPT1_BASE_ADDR), | ||
267 | MX27_INT_GPT1); | ||
268 | |||
269 | clk_prepare_enable(clk[emi_ahb_gate]); | ||
270 | |||
271 | return 0; | ||
272 | } | ||
273 | |||
274 | #ifdef CONFIG_OF | ||
275 | int __init mx27_clocks_init_dt(void) | ||
276 | { | ||
277 | struct device_node *np; | ||
278 | u32 fref = 26000000; /* default */ | ||
279 | |||
280 | for_each_compatible_node(np, NULL, "fixed-clock") { | ||
281 | if (!of_device_is_compatible(np, "fsl,imx-osc26m")) | ||
282 | continue; | ||
283 | |||
284 | if (!of_property_read_u32(np, "clock-frequency", &fref)) | ||
285 | break; | ||
286 | } | ||
287 | |||
288 | return mx27_clocks_init(fref); | ||
289 | } | ||
290 | #endif | ||
diff --git a/arch/arm/mach-imx/clk-imx31.c b/arch/arm/mach-imx/clk-imx31.c new file mode 100644 index 000000000000..a854b9cae5ea --- /dev/null +++ b/arch/arm/mach-imx/clk-imx31.c | |||
@@ -0,0 +1,182 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 Sascha Hauer <kernel@pengutronix.de> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation; either version 2 | ||
7 | * of the License, or (at your option) any later version. | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program; if not, write to the Free Software | ||
15 | * Foundation. | ||
16 | */ | ||
17 | |||
18 | #include <linux/module.h> | ||
19 | #include <linux/clk.h> | ||
20 | #include <linux/clkdev.h> | ||
21 | #include <linux/io.h> | ||
22 | #include <linux/err.h> | ||
23 | |||
24 | #include <mach/hardware.h> | ||
25 | #include <mach/mx31.h> | ||
26 | #include <mach/common.h> | ||
27 | |||
28 | #include "clk.h" | ||
29 | #include "crmregs-imx3.h" | ||
30 | |||
31 | static const char *mcu_main_sel[] = { "spll", "mpll", }; | ||
32 | static const char *per_sel[] = { "per_div", "ipg", }; | ||
33 | static const char *csi_sel[] = { "upll", "spll", }; | ||
34 | static const char *fir_sel[] = { "mcu_main", "upll", "spll" }; | ||
35 | |||
36 | enum mx31_clks { | ||
37 | ckih, ckil, mpll, spll, upll, mcu_main, hsp, ahb, nfc, ipg, per_div, | ||
38 | per, csi, fir, csi_div, usb_div_pre, usb_div_post, fir_div_pre, | ||
39 | fir_div_post, sdhc1_gate, sdhc2_gate, gpt_gate, epit1_gate, epit2_gate, | ||
40 | iim_gate, ata_gate, sdma_gate, cspi3_gate, rng_gate, uart1_gate, | ||
41 | uart2_gate, ssi1_gate, i2c1_gate, i2c2_gate, i2c3_gate, hantro_gate, | ||
42 | mstick1_gate, mstick2_gate, csi_gate, rtc_gate, wdog_gate, pwm_gate, | ||
43 | sim_gate, ect_gate, usb_gate, kpp_gate, ipu_gate, uart3_gate, | ||
44 | uart4_gate, uart5_gate, owire_gate, ssi2_gate, cspi1_gate, cspi2_gate, | ||
45 | gacc_gate, emi_gate, rtic_gate, firi_gate, clk_max | ||
46 | }; | ||
47 | |||
48 | static struct clk *clk[clk_max]; | ||
49 | |||
50 | int __init mx31_clocks_init(unsigned long fref) | ||
51 | { | ||
52 | void __iomem *base = MX31_IO_ADDRESS(MX31_CCM_BASE_ADDR); | ||
53 | int i; | ||
54 | |||
55 | clk[ckih] = imx_clk_fixed("ckih", fref); | ||
56 | clk[ckil] = imx_clk_fixed("ckil", 32768); | ||
57 | clk[mpll] = imx_clk_pllv1("mpll", "ckih", base + MXC_CCM_MPCTL); | ||
58 | clk[spll] = imx_clk_pllv1("spll", "ckih", base + MXC_CCM_SRPCTL); | ||
59 | clk[upll] = imx_clk_pllv1("upll", "ckih", base + MXC_CCM_UPCTL); | ||
60 | clk[mcu_main] = imx_clk_mux("mcu_main", base + MXC_CCM_PMCR0, 31, 1, mcu_main_sel, ARRAY_SIZE(mcu_main_sel)); | ||
61 | clk[hsp] = imx_clk_divider("hsp", "mcu_main", base + MXC_CCM_PDR0, 11, 3); | ||
62 | clk[ahb] = imx_clk_divider("ahb", "mcu_main", base + MXC_CCM_PDR0, 3, 3); | ||
63 | clk[nfc] = imx_clk_divider("nfc", "ahb", base + MXC_CCM_PDR0, 8, 3); | ||
64 | clk[ipg] = imx_clk_divider("ipg", "ahb", base + MXC_CCM_PDR0, 6, 2); | ||
65 | clk[per_div] = imx_clk_divider("per_div", "upll", base + MXC_CCM_PDR0, 16, 5); | ||
66 | clk[per] = imx_clk_mux("per", base + MXC_CCM_CCMR, 24, 1, per_sel, ARRAY_SIZE(per_sel)); | ||
67 | clk[csi] = imx_clk_mux("csi_sel", base + MXC_CCM_CCMR, 25, 1, csi_sel, ARRAY_SIZE(csi_sel)); | ||
68 | clk[fir] = imx_clk_mux("fir_sel", base + MXC_CCM_CCMR, 11, 2, fir_sel, ARRAY_SIZE(fir_sel)); | ||
69 | clk[csi_div] = imx_clk_divider("csi_div", "csi_sel", base + MXC_CCM_PDR0, 23, 9); | ||
70 | clk[usb_div_pre] = imx_clk_divider("usb_div_pre", "upll", base + MXC_CCM_PDR1, 30, 2); | ||
71 | clk[usb_div_post] = imx_clk_divider("usb_div_post", "usb_div_pre", base + MXC_CCM_PDR1, 27, 3); | ||
72 | clk[fir_div_pre] = imx_clk_divider("fir_div_pre", "fir_sel", base + MXC_CCM_PDR1, 24, 3); | ||
73 | clk[fir_div_post] = imx_clk_divider("fir_div_post", "fir_div_pre", base + MXC_CCM_PDR1, 23, 6); | ||
74 | clk[sdhc1_gate] = imx_clk_gate2("sdhc1_gate", "per", base + MXC_CCM_CGR0, 0); | ||
75 | clk[sdhc2_gate] = imx_clk_gate2("sdhc2_gate", "per", base + MXC_CCM_CGR0, 2); | ||
76 | clk[gpt_gate] = imx_clk_gate2("gpt_gate", "per", base + MXC_CCM_CGR0, 4); | ||
77 | clk[epit1_gate] = imx_clk_gate2("epit1_gate", "per", base + MXC_CCM_CGR0, 6); | ||
78 | clk[epit2_gate] = imx_clk_gate2("epit2_gate", "per", base + MXC_CCM_CGR0, 8); | ||
79 | clk[iim_gate] = imx_clk_gate2("iim_gate", "ipg", base + MXC_CCM_CGR0, 10); | ||
80 | clk[ata_gate] = imx_clk_gate2("ata_gate", "ipg", base + MXC_CCM_CGR0, 12); | ||
81 | clk[sdma_gate] = imx_clk_gate2("sdma_gate", "ahb", base + MXC_CCM_CGR0, 14); | ||
82 | clk[cspi3_gate] = imx_clk_gate2("cspi3_gate", "ipg", base + MXC_CCM_CGR0, 16); | ||
83 | clk[rng_gate] = imx_clk_gate2("rng_gate", "ipg", base + MXC_CCM_CGR0, 18); | ||
84 | clk[uart1_gate] = imx_clk_gate2("uart1_gate", "per", base + MXC_CCM_CGR0, 20); | ||
85 | clk[uart2_gate] = imx_clk_gate2("uart2_gate", "per", base + MXC_CCM_CGR0, 22); | ||
86 | clk[ssi1_gate] = imx_clk_gate2("ssi1_gate", "spll", base + MXC_CCM_CGR0, 24); | ||
87 | clk[i2c1_gate] = imx_clk_gate2("i2c1_gate", "per", base + MXC_CCM_CGR0, 26); | ||
88 | clk[i2c2_gate] = imx_clk_gate2("i2c2_gate", "per", base + MXC_CCM_CGR0, 28); | ||
89 | clk[i2c3_gate] = imx_clk_gate2("i2c3_gate", "per", base + MXC_CCM_CGR0, 30); | ||
90 | clk[hantro_gate] = imx_clk_gate2("hantro_gate", "per", base + MXC_CCM_CGR1, 0); | ||
91 | clk[mstick1_gate] = imx_clk_gate2("mstick1_gate", "per", base + MXC_CCM_CGR1, 2); | ||
92 | clk[mstick2_gate] = imx_clk_gate2("mstick2_gate", "per", base + MXC_CCM_CGR1, 4); | ||
93 | clk[csi_gate] = imx_clk_gate2("csi_gate", "csi_div", base + MXC_CCM_CGR1, 6); | ||
94 | clk[rtc_gate] = imx_clk_gate2("rtc_gate", "ipg", base + MXC_CCM_CGR1, 8); | ||
95 | clk[wdog_gate] = imx_clk_gate2("wdog_gate", "ipg", base + MXC_CCM_CGR1, 10); | ||
96 | clk[pwm_gate] = imx_clk_gate2("pwm_gate", "per", base + MXC_CCM_CGR1, 12); | ||
97 | clk[sim_gate] = imx_clk_gate2("sim_gate", "per", base + MXC_CCM_CGR1, 14); | ||
98 | clk[ect_gate] = imx_clk_gate2("ect_gate", "per", base + MXC_CCM_CGR1, 16); | ||
99 | clk[usb_gate] = imx_clk_gate2("usb_gate", "ahb", base + MXC_CCM_CGR1, 18); | ||
100 | clk[kpp_gate] = imx_clk_gate2("kpp_gate", "ipg", base + MXC_CCM_CGR1, 20); | ||
101 | clk[ipu_gate] = imx_clk_gate2("ipu_gate", "hsp", base + MXC_CCM_CGR1, 22); | ||
102 | clk[uart3_gate] = imx_clk_gate2("uart3_gate", "per", base + MXC_CCM_CGR1, 24); | ||
103 | clk[uart4_gate] = imx_clk_gate2("uart4_gate", "per", base + MXC_CCM_CGR1, 26); | ||
104 | clk[uart5_gate] = imx_clk_gate2("uart5_gate", "per", base + MXC_CCM_CGR1, 28); | ||
105 | clk[owire_gate] = imx_clk_gate2("owire_gate", "per", base + MXC_CCM_CGR1, 30); | ||
106 | clk[ssi2_gate] = imx_clk_gate2("ssi2_gate", "spll", base + MXC_CCM_CGR2, 0); | ||
107 | clk[cspi1_gate] = imx_clk_gate2("cspi1_gate", "ipg", base + MXC_CCM_CGR2, 2); | ||
108 | clk[cspi2_gate] = imx_clk_gate2("cspi2_gate", "ipg", base + MXC_CCM_CGR2, 4); | ||
109 | clk[gacc_gate] = imx_clk_gate2("gacc_gate", "per", base + MXC_CCM_CGR2, 6); | ||
110 | clk[emi_gate] = imx_clk_gate2("emi_gate", "ahb", base + MXC_CCM_CGR2, 8); | ||
111 | clk[rtic_gate] = imx_clk_gate2("rtic_gate", "ahb", base + MXC_CCM_CGR2, 10); | ||
112 | clk[firi_gate] = imx_clk_gate2("firi_gate", "upll", base+MXC_CCM_CGR2, 12); | ||
113 | |||
114 | for (i = 0; i < ARRAY_SIZE(clk); i++) | ||
115 | if (IS_ERR(clk[i])) | ||
116 | pr_err("imx31 clk %d: register failed with %ld\n", | ||
117 | i, PTR_ERR(clk[i])); | ||
118 | |||
119 | clk_register_clkdev(clk[gpt_gate], "per", "imx-gpt.0"); | ||
120 | clk_register_clkdev(clk[ipg], "ipg", "imx-gpt.0"); | ||
121 | clk_register_clkdev(clk[cspi1_gate], NULL, "imx31-cspi.0"); | ||
122 | clk_register_clkdev(clk[cspi2_gate], NULL, "imx31-cspi.1"); | ||
123 | clk_register_clkdev(clk[cspi3_gate], NULL, "imx31-cspi.2"); | ||
124 | clk_register_clkdev(clk[pwm_gate], "pwm", NULL); | ||
125 | clk_register_clkdev(clk[wdog_gate], NULL, "imx2-wdt.0"); | ||
126 | clk_register_clkdev(clk[rtc_gate], "rtc", NULL); | ||
127 | clk_register_clkdev(clk[epit1_gate], "epit", NULL); | ||
128 | clk_register_clkdev(clk[epit2_gate], "epit", NULL); | ||
129 | clk_register_clkdev(clk[nfc], NULL, "mxc_nand.0"); | ||
130 | clk_register_clkdev(clk[ipu_gate], NULL, "ipu-core"); | ||
131 | clk_register_clkdev(clk[ipu_gate], NULL, "mx3_sdc_fb"); | ||
132 | clk_register_clkdev(clk[kpp_gate], "kpp", NULL); | ||
133 | clk_register_clkdev(clk[usb_div_post], "per", "mxc-ehci.0"); | ||
134 | clk_register_clkdev(clk[usb_gate], "ahb", "mxc-ehci.0"); | ||
135 | clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.0"); | ||
136 | clk_register_clkdev(clk[usb_div_post], "per", "mxc-ehci.1"); | ||
137 | clk_register_clkdev(clk[usb_gate], "ahb", "mxc-ehci.1"); | ||
138 | clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.1"); | ||
139 | clk_register_clkdev(clk[usb_div_post], "per", "mxc-ehci.2"); | ||
140 | clk_register_clkdev(clk[usb_gate], "ahb", "mxc-ehci.2"); | ||
141 | clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.2"); | ||
142 | clk_register_clkdev(clk[usb_div_post], "per", "fsl-usb2-udc"); | ||
143 | clk_register_clkdev(clk[usb_gate], "ahb", "fsl-usb2-udc"); | ||
144 | clk_register_clkdev(clk[ipg], "ipg", "fsl-usb2-udc"); | ||
145 | clk_register_clkdev(clk[csi_gate], NULL, "mx3-camera.0"); | ||
146 | /* i.mx31 has the i.mx21 type uart */ | ||
147 | clk_register_clkdev(clk[uart1_gate], "per", "imx21-uart.0"); | ||
148 | clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.0"); | ||
149 | clk_register_clkdev(clk[uart2_gate], "per", "imx21-uart.1"); | ||
150 | clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.1"); | ||
151 | clk_register_clkdev(clk[uart3_gate], "per", "imx21-uart.2"); | ||
152 | clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.2"); | ||
153 | clk_register_clkdev(clk[uart4_gate], "per", "imx21-uart.3"); | ||
154 | clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.3"); | ||
155 | clk_register_clkdev(clk[uart5_gate], "per", "imx21-uart.4"); | ||
156 | clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.4"); | ||
157 | clk_register_clkdev(clk[i2c1_gate], NULL, "imx-i2c.0"); | ||
158 | clk_register_clkdev(clk[i2c2_gate], NULL, "imx-i2c.1"); | ||
159 | clk_register_clkdev(clk[i2c3_gate], NULL, "imx-i2c.2"); | ||
160 | clk_register_clkdev(clk[owire_gate], NULL, "mxc_w1.0"); | ||
161 | clk_register_clkdev(clk[sdhc1_gate], NULL, "mxc-mmc.0"); | ||
162 | clk_register_clkdev(clk[sdhc2_gate], NULL, "mxc-mmc.1"); | ||
163 | clk_register_clkdev(clk[ssi1_gate], NULL, "imx-ssi.0"); | ||
164 | clk_register_clkdev(clk[ssi2_gate], NULL, "imx-ssi.1"); | ||
165 | clk_register_clkdev(clk[firi_gate], "firi", NULL); | ||
166 | clk_register_clkdev(clk[ata_gate], NULL, "pata_imx"); | ||
167 | clk_register_clkdev(clk[rtic_gate], "rtic", NULL); | ||
168 | clk_register_clkdev(clk[rng_gate], "rng", NULL); | ||
169 | clk_register_clkdev(clk[sdma_gate], NULL, "imx31-sdma"); | ||
170 | clk_register_clkdev(clk[iim_gate], "iim", NULL); | ||
171 | |||
172 | clk_set_parent(clk[csi], clk[upll]); | ||
173 | clk_prepare_enable(clk[emi_gate]); | ||
174 | clk_prepare_enable(clk[iim_gate]); | ||
175 | mx31_revision(); | ||
176 | clk_disable_unprepare(clk[iim_gate]); | ||
177 | |||
178 | mxc_timer_init(NULL, MX31_IO_ADDRESS(MX31_GPT1_BASE_ADDR), | ||
179 | MX31_INT_GPT); | ||
180 | |||
181 | return 0; | ||
182 | } | ||
diff --git a/arch/arm/mach-imx/clk-imx35.c b/arch/arm/mach-imx/clk-imx35.c new file mode 100644 index 000000000000..a9e60bf7dd75 --- /dev/null +++ b/arch/arm/mach-imx/clk-imx35.c | |||
@@ -0,0 +1,278 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | */ | ||
9 | #include <linux/mm.h> | ||
10 | #include <linux/delay.h> | ||
11 | #include <linux/clk.h> | ||
12 | #include <linux/io.h> | ||
13 | #include <linux/clkdev.h> | ||
14 | #include <linux/of.h> | ||
15 | #include <linux/err.h> | ||
16 | |||
17 | #include <mach/hardware.h> | ||
18 | #include <mach/common.h> | ||
19 | |||
20 | #include "crmregs-imx3.h" | ||
21 | #include "clk.h" | ||
22 | |||
23 | struct arm_ahb_div { | ||
24 | unsigned char arm, ahb, sel; | ||
25 | }; | ||
26 | |||
27 | static struct arm_ahb_div clk_consumer[] = { | ||
28 | { .arm = 1, .ahb = 4, .sel = 0}, | ||
29 | { .arm = 1, .ahb = 3, .sel = 1}, | ||
30 | { .arm = 2, .ahb = 2, .sel = 0}, | ||
31 | { .arm = 0, .ahb = 0, .sel = 0}, | ||
32 | { .arm = 0, .ahb = 0, .sel = 0}, | ||
33 | { .arm = 0, .ahb = 0, .sel = 0}, | ||
34 | { .arm = 4, .ahb = 1, .sel = 0}, | ||
35 | { .arm = 1, .ahb = 5, .sel = 0}, | ||
36 | { .arm = 1, .ahb = 8, .sel = 0}, | ||
37 | { .arm = 1, .ahb = 6, .sel = 1}, | ||
38 | { .arm = 2, .ahb = 4, .sel = 0}, | ||
39 | { .arm = 0, .ahb = 0, .sel = 0}, | ||
40 | { .arm = 0, .ahb = 0, .sel = 0}, | ||
41 | { .arm = 0, .ahb = 0, .sel = 0}, | ||
42 | { .arm = 4, .ahb = 2, .sel = 0}, | ||
43 | { .arm = 0, .ahb = 0, .sel = 0}, | ||
44 | }; | ||
45 | |||
46 | static char hsp_div_532[] = { 4, 8, 3, 0 }; | ||
47 | static char hsp_div_400[] = { 3, 6, 3, 0 }; | ||
48 | |||
49 | static const char *std_sel[] = {"ppll", "arm"}; | ||
50 | static const char *ipg_per_sel[] = {"ahb_per_div", "arm_per_div"}; | ||
51 | |||
52 | enum mx35_clks { | ||
53 | ckih, mpll, ppll, mpll_075, arm, hsp, hsp_div, hsp_sel, ahb, ipg, | ||
54 | arm_per_div, ahb_per_div, ipg_per, uart_sel, uart_div, esdhc_sel, | ||
55 | esdhc1_div, esdhc2_div, esdhc3_div, spdif_sel, spdif_div_pre, | ||
56 | spdif_div_post, ssi_sel, ssi1_div_pre, ssi1_div_post, ssi2_div_pre, | ||
57 | ssi2_div_post, usb_sel, usb_div, nfc_div, asrc_gate, pata_gate, | ||
58 | audmux_gate, can1_gate, can2_gate, cspi1_gate, cspi2_gate, ect_gate, | ||
59 | edio_gate, emi_gate, epit1_gate, epit2_gate, esai_gate, esdhc1_gate, | ||
60 | esdhc2_gate, esdhc3_gate, fec_gate, gpio1_gate, gpio2_gate, gpio3_gate, | ||
61 | gpt_gate, i2c1_gate, i2c2_gate, i2c3_gate, iomuxc_gate, ipu_gate, | ||
62 | kpp_gate, mlb_gate, mshc_gate, owire_gate, pwm_gate, rngc_gate, | ||
63 | rtc_gate, rtic_gate, scc_gate, sdma_gate, spba_gate, spdif_gate, | ||
64 | ssi1_gate, ssi2_gate, uart1_gate, uart2_gate, uart3_gate, usbotg_gate, | ||
65 | wdog_gate, max_gate, admux_gate, csi_gate, iim_gate, gpu2d_gate, | ||
66 | clk_max | ||
67 | }; | ||
68 | |||
69 | static struct clk *clk[clk_max]; | ||
70 | |||
71 | int __init mx35_clocks_init() | ||
72 | { | ||
73 | void __iomem *base = MX35_IO_ADDRESS(MX35_CCM_BASE_ADDR); | ||
74 | u32 pdr0, consumer_sel, hsp_sel; | ||
75 | struct arm_ahb_div *aad; | ||
76 | unsigned char *hsp_div; | ||
77 | int i; | ||
78 | |||
79 | pdr0 = __raw_readl(base + MXC_CCM_PDR0); | ||
80 | consumer_sel = (pdr0 >> 16) & 0xf; | ||
81 | aad = &clk_consumer[consumer_sel]; | ||
82 | if (!aad->arm) { | ||
83 | pr_err("i.MX35 clk: illegal consumer mux selection 0x%x\n", consumer_sel); | ||
84 | /* | ||
85 | * We are basically stuck. Continue with a default entry and hope we | ||
86 | * get far enough to actually show the above message | ||
87 | */ | ||
88 | aad = &clk_consumer[0]; | ||
89 | } | ||
90 | |||
91 | clk[ckih] = imx_clk_fixed("ckih", 24000000); | ||
92 | clk[mpll] = imx_clk_pllv1("mpll", "ckih", base + MX35_CCM_MPCTL); | ||
93 | clk[ppll] = imx_clk_pllv1("ppll", "ckih", base + MX35_CCM_PPCTL); | ||
94 | |||
95 | clk[mpll] = imx_clk_fixed_factor("mpll_075", "mpll", 3, 4); | ||
96 | |||
97 | if (aad->sel) | ||
98 | clk[arm] = imx_clk_fixed_factor("arm", "mpll_075", 1, aad->arm); | ||
99 | else | ||
100 | clk[arm] = imx_clk_fixed_factor("arm", "mpll", 1, aad->arm); | ||
101 | |||
102 | if (clk_get_rate(clk[arm]) > 400000000) | ||
103 | hsp_div = hsp_div_532; | ||
104 | else | ||
105 | hsp_div = hsp_div_400; | ||
106 | |||
107 | hsp_sel = (pdr0 >> 20) & 0x3; | ||
108 | if (!hsp_div[hsp_sel]) { | ||
109 | pr_err("i.MX35 clk: illegal hsp clk selection 0x%x\n", hsp_sel); | ||
110 | hsp_sel = 0; | ||
111 | } | ||
112 | |||
113 | clk[hsp] = imx_clk_fixed_factor("hsp", "arm", 1, hsp_div[hsp_sel]); | ||
114 | |||
115 | clk[ahb] = imx_clk_fixed_factor("ahb", "arm", 1, aad->ahb); | ||
116 | clk[ipg] = imx_clk_fixed_factor("ipg", "ahb", 1, 2); | ||
117 | |||
118 | clk[arm_per_div] = imx_clk_divider("arm_per_div", "arm", base + MX35_CCM_PDR4, 16, 6); | ||
119 | clk[ahb_per_div] = imx_clk_divider("ahb_per_div", "ahb", base + MXC_CCM_PDR0, 12, 3); | ||
120 | clk[ipg_per] = imx_clk_mux("ipg_per", base + MXC_CCM_PDR0, 26, 1, ipg_per_sel, ARRAY_SIZE(ipg_per_sel)); | ||
121 | |||
122 | clk[uart_sel] = imx_clk_mux("uart_sel", base + MX35_CCM_PDR3, 14, 1, std_sel, ARRAY_SIZE(std_sel)); | ||
123 | clk[uart_div] = imx_clk_divider("uart_div", "uart_sel", base + MX35_CCM_PDR4, 10, 6); | ||
124 | |||
125 | clk[esdhc_sel] = imx_clk_mux("esdhc_sel", base + MX35_CCM_PDR4, 9, 1, std_sel, ARRAY_SIZE(std_sel)); | ||
126 | clk[esdhc1_div] = imx_clk_divider("esdhc1_div", "esdhc_sel", base + MX35_CCM_PDR3, 0, 6); | ||
127 | clk[esdhc2_div] = imx_clk_divider("esdhc2_div", "esdhc_sel", base + MX35_CCM_PDR3, 8, 6); | ||
128 | clk[esdhc3_div] = imx_clk_divider("esdhc3_div", "esdhc_sel", base + MX35_CCM_PDR3, 16, 6); | ||
129 | |||
130 | clk[spdif_sel] = imx_clk_mux("spdif_sel", base + MX35_CCM_PDR3, 22, 1, std_sel, ARRAY_SIZE(std_sel)); | ||
131 | clk[spdif_div_pre] = imx_clk_divider("spdif_div_pre", "spdif_sel", base + MX35_CCM_PDR3, 29, 3); /* divide by 1 not allowed */ | ||
132 | clk[spdif_div_post] = imx_clk_divider("spdif_div_post", "spdif_div_pre", base + MX35_CCM_PDR3, 23, 6); | ||
133 | |||
134 | clk[ssi_sel] = imx_clk_mux("ssi_sel", base + MX35_CCM_PDR2, 6, 1, std_sel, ARRAY_SIZE(std_sel)); | ||
135 | clk[ssi1_div_pre] = imx_clk_divider("ssi1_div_pre", "ssi_sel", base + MX35_CCM_PDR2, 24, 3); | ||
136 | clk[ssi1_div_post] = imx_clk_divider("ssi1_div_post", "ssi1_div_pre", base + MX35_CCM_PDR2, 0, 6); | ||
137 | clk[ssi2_div_pre] = imx_clk_divider("ssi2_div_pre", "ssi_sel", base + MX35_CCM_PDR2, 27, 3); | ||
138 | clk[ssi2_div_post] = imx_clk_divider("ssi2_div_post", "ssi2_div_pre", base + MX35_CCM_PDR2, 8, 6); | ||
139 | |||
140 | clk[usb_sel] = imx_clk_mux("usb_sel", base + MX35_CCM_PDR4, 9, 1, std_sel, ARRAY_SIZE(std_sel)); | ||
141 | clk[usb_div] = imx_clk_divider("usb_div", "usb_sel", base + MX35_CCM_PDR4, 22, 6); | ||
142 | |||
143 | clk[nfc_div] = imx_clk_divider("nfc_div", "ahb", base + MX35_CCM_PDR4, 28, 4); | ||
144 | |||
145 | clk[asrc_gate] = imx_clk_gate2("asrc_gate", "ipg", base + MX35_CCM_CGR0, 0); | ||
146 | clk[pata_gate] = imx_clk_gate2("pata_gate", "ipg", base + MX35_CCM_CGR0, 2); | ||
147 | clk[audmux_gate] = imx_clk_gate2("audmux_gate", "ipg", base + MX35_CCM_CGR0, 4); | ||
148 | clk[can1_gate] = imx_clk_gate2("can1_gate", "ipg", base + MX35_CCM_CGR0, 6); | ||
149 | clk[can2_gate] = imx_clk_gate2("can2_gate", "ipg", base + MX35_CCM_CGR0, 8); | ||
150 | clk[cspi1_gate] = imx_clk_gate2("cspi1_gate", "ipg", base + MX35_CCM_CGR0, 10); | ||
151 | clk[cspi2_gate] = imx_clk_gate2("cspi2_gate", "ipg", base + MX35_CCM_CGR0, 12); | ||
152 | clk[ect_gate] = imx_clk_gate2("ect_gate", "ipg", base + MX35_CCM_CGR0, 14); | ||
153 | clk[edio_gate] = imx_clk_gate2("edio_gate", "ipg", base + MX35_CCM_CGR0, 16); | ||
154 | clk[emi_gate] = imx_clk_gate2("emi_gate", "ipg", base + MX35_CCM_CGR0, 18); | ||
155 | clk[epit1_gate] = imx_clk_gate2("epit1_gate", "ipg", base + MX35_CCM_CGR0, 20); | ||
156 | clk[epit2_gate] = imx_clk_gate2("epit2_gate", "ipg", base + MX35_CCM_CGR0, 22); | ||
157 | clk[esai_gate] = imx_clk_gate2("esai_gate", "ipg", base + MX35_CCM_CGR0, 24); | ||
158 | clk[esdhc1_gate] = imx_clk_gate2("esdhc1_gate", "esdhc1_div", base + MX35_CCM_CGR0, 26); | ||
159 | clk[esdhc2_gate] = imx_clk_gate2("esdhc2_gate", "esdhc2_div", base + MX35_CCM_CGR0, 28); | ||
160 | clk[esdhc3_gate] = imx_clk_gate2("esdhc3_gate", "esdhc3_div", base + MX35_CCM_CGR0, 30); | ||
161 | |||
162 | clk[fec_gate] = imx_clk_gate2("fec_gate", "ipg", base + MX35_CCM_CGR1, 0); | ||
163 | clk[gpio1_gate] = imx_clk_gate2("gpio1_gate", "ipg", base + MX35_CCM_CGR1, 2); | ||
164 | clk[gpio2_gate] = imx_clk_gate2("gpio2_gate", "ipg", base + MX35_CCM_CGR1, 4); | ||
165 | clk[gpio3_gate] = imx_clk_gate2("gpio3_gate", "ipg", base + MX35_CCM_CGR1, 6); | ||
166 | clk[gpt_gate] = imx_clk_gate2("gpt_gate", "ipg", base + MX35_CCM_CGR1, 8); | ||
167 | clk[i2c1_gate] = imx_clk_gate2("i2c1_gate", "ipg_per", base + MX35_CCM_CGR1, 10); | ||
168 | clk[i2c2_gate] = imx_clk_gate2("i2c2_gate", "ipg_per", base + MX35_CCM_CGR1, 12); | ||
169 | clk[i2c3_gate] = imx_clk_gate2("i2c3_gate", "ipg_per", base + MX35_CCM_CGR1, 14); | ||
170 | clk[iomuxc_gate] = imx_clk_gate2("iomuxc_gate", "ipg", base + MX35_CCM_CGR1, 16); | ||
171 | clk[ipu_gate] = imx_clk_gate2("ipu_gate", "hsp", base + MX35_CCM_CGR1, 18); | ||
172 | clk[kpp_gate] = imx_clk_gate2("kpp_gate", "ipg", base + MX35_CCM_CGR1, 20); | ||
173 | clk[mlb_gate] = imx_clk_gate2("mlb_gate", "ahb", base + MX35_CCM_CGR1, 22); | ||
174 | clk[mshc_gate] = imx_clk_gate2("mshc_gate", "dummy", base + MX35_CCM_CGR1, 24); | ||
175 | clk[owire_gate] = imx_clk_gate2("owire_gate", "ipg_per", base + MX35_CCM_CGR1, 26); | ||
176 | clk[pwm_gate] = imx_clk_gate2("pwm_gate", "ipg_per", base + MX35_CCM_CGR1, 28); | ||
177 | clk[rngc_gate] = imx_clk_gate2("rngc_gate", "ipg", base + MX35_CCM_CGR1, 30); | ||
178 | |||
179 | clk[rtc_gate] = imx_clk_gate2("rtc_gate", "ipg", base + MX35_CCM_CGR2, 0); | ||
180 | clk[rtic_gate] = imx_clk_gate2("rtic_gate", "ahb", base + MX35_CCM_CGR2, 2); | ||
181 | clk[scc_gate] = imx_clk_gate2("scc_gate", "ipg", base + MX35_CCM_CGR2, 4); | ||
182 | clk[sdma_gate] = imx_clk_gate2("sdma_gate", "ahb", base + MX35_CCM_CGR2, 6); | ||
183 | clk[spba_gate] = imx_clk_gate2("spba_gate", "ipg", base + MX35_CCM_CGR2, 8); | ||
184 | clk[spdif_gate] = imx_clk_gate2("spdif_gate", "spdif_div_post", base + MX35_CCM_CGR2, 10); | ||
185 | clk[ssi1_gate] = imx_clk_gate2("ssi1_gate", "ssi1_div_post", base + MX35_CCM_CGR2, 12); | ||
186 | clk[ssi2_gate] = imx_clk_gate2("ssi2_gate", "ssi2_div_post", base + MX35_CCM_CGR2, 14); | ||
187 | clk[uart1_gate] = imx_clk_gate2("uart1_gate", "uart_div", base + MX35_CCM_CGR2, 16); | ||
188 | clk[uart2_gate] = imx_clk_gate2("uart2_gate", "uart_div", base + MX35_CCM_CGR2, 18); | ||
189 | clk[uart3_gate] = imx_clk_gate2("uart3_gate", "uart_div", base + MX35_CCM_CGR2, 20); | ||
190 | clk[usbotg_gate] = imx_clk_gate2("usbotg_gate", "ahb", base + MX35_CCM_CGR2, 22); | ||
191 | clk[wdog_gate] = imx_clk_gate2("wdog_gate", "ipg", base + MX35_CCM_CGR2, 24); | ||
192 | clk[max_gate] = imx_clk_gate2("max_gate", "dummy", base + MX35_CCM_CGR2, 26); | ||
193 | clk[admux_gate] = imx_clk_gate2("admux_gate", "ipg", base + MX35_CCM_CGR2, 30); | ||
194 | |||
195 | clk[csi_gate] = imx_clk_gate2("csi_gate", "ipg", base + MX35_CCM_CGR3, 0); | ||
196 | clk[iim_gate] = imx_clk_gate2("iim_gate", "ipg", base + MX35_CCM_CGR3, 2); | ||
197 | clk[gpu2d_gate] = imx_clk_gate2("gpu2d_gate", "ahb", base + MX35_CCM_CGR3, 4); | ||
198 | |||
199 | for (i = 0; i < ARRAY_SIZE(clk); i++) | ||
200 | if (IS_ERR(clk[i])) | ||
201 | pr_err("i.MX35 clk %d: register failed with %ld\n", | ||
202 | i, PTR_ERR(clk[i])); | ||
203 | |||
204 | |||
205 | clk_register_clkdev(clk[pata_gate], NULL, "pata_imx"); | ||
206 | clk_register_clkdev(clk[can1_gate], NULL, "flexcan.0"); | ||
207 | clk_register_clkdev(clk[can2_gate], NULL, "flexcan.1"); | ||
208 | clk_register_clkdev(clk[cspi1_gate], "per", "imx35-cspi.0"); | ||
209 | clk_register_clkdev(clk[cspi1_gate], "ipg", "imx35-cspi.0"); | ||
210 | clk_register_clkdev(clk[cspi2_gate], "per", "imx35-cspi.1"); | ||
211 | clk_register_clkdev(clk[cspi2_gate], "ipg", "imx35-cspi.1"); | ||
212 | clk_register_clkdev(clk[epit1_gate], NULL, "imx-epit.0"); | ||
213 | clk_register_clkdev(clk[epit2_gate], NULL, "imx-epit.1"); | ||
214 | clk_register_clkdev(clk[esdhc1_gate], "per", "sdhci-esdhc-imx35.0"); | ||
215 | clk_register_clkdev(clk[ipg], "ipg", "sdhci-esdhc-imx35.0"); | ||
216 | clk_register_clkdev(clk[ahb], "ahb", "sdhci-esdhc-imx35.0"); | ||
217 | clk_register_clkdev(clk[esdhc2_gate], "per", "sdhci-esdhc-imx35.1"); | ||
218 | clk_register_clkdev(clk[ipg], "ipg", "sdhci-esdhc-imx35.1"); | ||
219 | clk_register_clkdev(clk[ahb], "ahb", "sdhci-esdhc-imx35.1"); | ||
220 | clk_register_clkdev(clk[esdhc3_gate], "per", "sdhci-esdhc-imx35.2"); | ||
221 | clk_register_clkdev(clk[ipg], "ipg", "sdhci-esdhc-imx35.2"); | ||
222 | clk_register_clkdev(clk[ahb], "ahb", "sdhci-esdhc-imx35.2"); | ||
223 | /* i.mx35 has the i.mx27 type fec */ | ||
224 | clk_register_clkdev(clk[fec_gate], NULL, "imx27-fec.0"); | ||
225 | clk_register_clkdev(clk[gpt_gate], "per", "imx-gpt.0"); | ||
226 | clk_register_clkdev(clk[ipg], "ipg", "imx-gpt.0"); | ||
227 | clk_register_clkdev(clk[i2c1_gate], NULL, "imx-i2c.0"); | ||
228 | clk_register_clkdev(clk[i2c2_gate], NULL, "imx-i2c.1"); | ||
229 | clk_register_clkdev(clk[i2c3_gate], NULL, "imx-i2c.2"); | ||
230 | clk_register_clkdev(clk[ipu_gate], NULL, "ipu-core"); | ||
231 | clk_register_clkdev(clk[ipu_gate], NULL, "mx3_sdc_fb"); | ||
232 | clk_register_clkdev(clk[owire_gate], NULL, "mxc_w1"); | ||
233 | clk_register_clkdev(clk[sdma_gate], NULL, "imx35-sdma"); | ||
234 | clk_register_clkdev(clk[ipg], "ipg", "imx-ssi.0"); | ||
235 | clk_register_clkdev(clk[ssi1_div_post], "per", "imx-ssi.0"); | ||
236 | clk_register_clkdev(clk[ipg], "ipg", "imx-ssi.1"); | ||
237 | clk_register_clkdev(clk[ssi2_div_post], "per", "imx-ssi.1"); | ||
238 | /* i.mx35 has the i.mx21 type uart */ | ||
239 | clk_register_clkdev(clk[uart1_gate], "per", "imx21-uart.0"); | ||
240 | clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.0"); | ||
241 | clk_register_clkdev(clk[uart2_gate], "per", "imx21-uart.1"); | ||
242 | clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.1"); | ||
243 | clk_register_clkdev(clk[uart3_gate], "per", "imx21-uart.2"); | ||
244 | clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.2"); | ||
245 | clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.0"); | ||
246 | clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.0"); | ||
247 | clk_register_clkdev(clk[usbotg_gate], "ahb", "mxc-ehci.0"); | ||
248 | clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.1"); | ||
249 | clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.1"); | ||
250 | clk_register_clkdev(clk[usbotg_gate], "ahb", "mxc-ehci.1"); | ||
251 | clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.2"); | ||
252 | clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.2"); | ||
253 | clk_register_clkdev(clk[usbotg_gate], "ahb", "mxc-ehci.2"); | ||
254 | clk_register_clkdev(clk[usb_div], "per", "fsl-usb2-udc"); | ||
255 | clk_register_clkdev(clk[ipg], "ipg", "fsl-usb2-udc"); | ||
256 | clk_register_clkdev(clk[usbotg_gate], "ahb", "fsl-usb2-udc"); | ||
257 | clk_register_clkdev(clk[wdog_gate], NULL, "imx2-wdt.0"); | ||
258 | clk_register_clkdev(clk[nfc_div], NULL, "mxc_nand.0"); | ||
259 | |||
260 | clk_prepare_enable(clk[spba_gate]); | ||
261 | clk_prepare_enable(clk[gpio1_gate]); | ||
262 | clk_prepare_enable(clk[gpio2_gate]); | ||
263 | clk_prepare_enable(clk[gpio3_gate]); | ||
264 | clk_prepare_enable(clk[iim_gate]); | ||
265 | clk_prepare_enable(clk[emi_gate]); | ||
266 | |||
267 | imx_print_silicon_rev("i.MX35", mx35_revision()); | ||
268 | |||
269 | #ifdef CONFIG_MXC_USE_EPIT | ||
270 | epit_timer_init(&epit1_clk, | ||
271 | MX35_IO_ADDRESS(MX35_EPIT1_BASE_ADDR), MX35_INT_EPIT1); | ||
272 | #else | ||
273 | mxc_timer_init(NULL, MX35_IO_ADDRESS(MX35_GPT1_BASE_ADDR), | ||
274 | MX35_INT_GPT); | ||
275 | #endif | ||
276 | |||
277 | return 0; | ||
278 | } | ||
diff --git a/arch/arm/mach-imx/clk-imx51-imx53.c b/arch/arm/mach-imx/clk-imx51-imx53.c new file mode 100644 index 000000000000..b8a382defb23 --- /dev/null +++ b/arch/arm/mach-imx/clk-imx51-imx53.c | |||
@@ -0,0 +1,466 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2011 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | */ | ||
9 | #include <linux/mm.h> | ||
10 | #include <linux/delay.h> | ||
11 | #include <linux/clk.h> | ||
12 | #include <linux/io.h> | ||
13 | #include <linux/clkdev.h> | ||
14 | #include <linux/of.h> | ||
15 | #include <linux/err.h> | ||
16 | |||
17 | #include <mach/hardware.h> | ||
18 | #include <mach/common.h> | ||
19 | |||
20 | #include "crm-regs-imx5.h" | ||
21 | #include "clk.h" | ||
22 | |||
23 | /* Low-power Audio Playback Mode clock */ | ||
24 | static const char *lp_apm_sel[] = { "osc", }; | ||
25 | |||
26 | /* This is used multiple times */ | ||
27 | static const char *standard_pll_sel[] = { "pll1_sw", "pll2_sw", "pll3_sw", "lp_apm", }; | ||
28 | static const char *periph_apm_sel[] = { "pll1_sw", "pll3_sw", "lp_apm", }; | ||
29 | static const char *main_bus_sel[] = { "pll2_sw", "periph_apm", }; | ||
30 | static const char *per_lp_apm_sel[] = { "main_bus", "lp_apm", }; | ||
31 | static const char *per_root_sel[] = { "per_podf", "ipg", }; | ||
32 | static const char *esdhc_c_sel[] = { "esdhc_a_podf", "esdhc_b_podf", }; | ||
33 | static const char *esdhc_d_sel[] = { "esdhc_a_podf", "esdhc_b_podf", }; | ||
34 | static const char *emi_slow_sel[] = { "main_bus", "ahb", }; | ||
35 | static const char *usb_phy_sel_str[] = { "osc", "usb_phy_podf", }; | ||
36 | static const char *mx51_ipu_di0_sel[] = { "di_pred", "osc", "ckih1", "tve_di", }; | ||
37 | static const char *mx53_ipu_di0_sel[] = { "di_pred", "osc", "ckih1", "di_pll4_podf", "dummy", "ldb_di0", }; | ||
38 | static const char *mx53_ldb_di0_sel[] = { "pll3_sw", "pll4_sw", }; | ||
39 | static const char *mx51_ipu_di1_sel[] = { "di_pred", "osc", "ckih1", "tve_di", "ipp_di1", }; | ||
40 | static const char *mx53_ipu_di1_sel[] = { "di_pred", "osc", "ckih1", "tve_di", "ipp_di1", "ldb_di1", }; | ||
41 | static const char *mx53_ldb_di1_sel[] = { "pll3_sw", "pll4_sw", }; | ||
42 | static const char *mx51_tve_ext_sel[] = { "osc", "ckih1", }; | ||
43 | static const char *mx53_tve_ext_sel[] = { "pll4_sw", "ckih1", }; | ||
44 | static const char *tve_sel[] = { "tve_pred", "tve_ext_sel", }; | ||
45 | static const char *ipu_sel[] = { "axi_a", "axi_b", "emi_slow_gate", "ahb", }; | ||
46 | static const char *vpu_sel[] = { "axi_a", "axi_b", "emi_slow_gate", "ahb", }; | ||
47 | |||
48 | enum imx5_clks { | ||
49 | dummy, ckil, osc, ckih1, ckih2, ahb, ipg, axi_a, axi_b, uart_pred, | ||
50 | uart_root, esdhc_a_pred, esdhc_b_pred, esdhc_c_s, esdhc_d_s, | ||
51 | emi_sel, emi_slow_podf, nfc_podf, ecspi_pred, ecspi_podf, usboh3_pred, | ||
52 | usboh3_podf, usb_phy_pred, usb_phy_podf, cpu_podf, di_pred, tve_di, | ||
53 | tve_s, uart1_ipg_gate, uart1_per_gate, uart2_ipg_gate, | ||
54 | uart2_per_gate, uart3_ipg_gate, uart3_per_gate, i2c1_gate, i2c2_gate, | ||
55 | gpt_ipg_gate, pwm1_ipg_gate, pwm1_hf_gate, pwm2_ipg_gate, pwm2_hf_gate, | ||
56 | gpt_gate, fec_gate, usboh3_per_gate, esdhc1_ipg_gate, esdhc2_ipg_gate, | ||
57 | esdhc3_ipg_gate, esdhc4_ipg_gate, ssi1_ipg_gate, ssi2_ipg_gate, | ||
58 | ssi3_ipg_gate, ecspi1_ipg_gate, ecspi1_per_gate, ecspi2_ipg_gate, | ||
59 | ecspi2_per_gate, cspi_ipg_gate, sdma_gate, emi_slow_gate, ipu_s, | ||
60 | ipu_gate, nfc_gate, ipu_di1_gate, vpu_s, vpu_gate, | ||
61 | vpu_reference_gate, uart4_ipg_gate, uart4_per_gate, uart5_ipg_gate, | ||
62 | uart5_per_gate, tve_gate, tve_pred, esdhc1_per_gate, esdhc2_per_gate, | ||
63 | esdhc3_per_gate, esdhc4_per_gate, usb_phy_gate, hsi2c_gate, | ||
64 | mipi_hsc1_gate, mipi_hsc2_gate, mipi_esc_gate, mipi_hsp_gate, | ||
65 | ldb_di1_div_3_5, ldb_di1_div, ldb_di0_div_3_5, ldb_di0_div, | ||
66 | ldb_di1_gate, can2_serial_gate, can2_ipg_gate, i2c3_gate, lp_apm, | ||
67 | periph_apm, main_bus, ahb_max, aips_tz1, aips_tz2, tmax1, tmax2, | ||
68 | tmax3, spba, uart_sel, esdhc_a_sel, esdhc_b_sel, esdhc_a_podf, | ||
69 | esdhc_b_podf, ecspi_sel, usboh3_sel, usb_phy_sel, iim_gate, | ||
70 | usboh3_gate, emi_fast_gate, ipu_di0_gate,gpc_dvfs, pll1_sw, pll2_sw, | ||
71 | pll3_sw, ipu_di0_sel, ipu_di1_sel, tve_ext_sel, mx51_mipi, pll4_sw, | ||
72 | ldb_di1_sel, di_pll4_podf, ldb_di0_sel, ldb_di0_gate, usb_phy1_gate, | ||
73 | usb_phy2_gate, per_lp_apm, per_pred1, per_pred2, per_podf, per_root, | ||
74 | clk_max | ||
75 | }; | ||
76 | |||
77 | static struct clk *clk[clk_max]; | ||
78 | |||
79 | static void __init mx5_clocks_common_init(unsigned long rate_ckil, | ||
80 | unsigned long rate_osc, unsigned long rate_ckih1, | ||
81 | unsigned long rate_ckih2) | ||
82 | { | ||
83 | int i; | ||
84 | |||
85 | clk[dummy] = imx_clk_fixed("dummy", 0); | ||
86 | clk[ckil] = imx_clk_fixed("ckil", rate_ckil); | ||
87 | clk[osc] = imx_clk_fixed("osc", rate_osc); | ||
88 | clk[ckih1] = imx_clk_fixed("ckih1", rate_ckih1); | ||
89 | clk[ckih2] = imx_clk_fixed("ckih2", rate_ckih2); | ||
90 | |||
91 | clk[lp_apm] = imx_clk_mux("lp_apm", MXC_CCM_CCSR, 9, 1, | ||
92 | lp_apm_sel, ARRAY_SIZE(lp_apm_sel)); | ||
93 | clk[periph_apm] = imx_clk_mux("periph_apm", MXC_CCM_CBCMR, 12, 2, | ||
94 | periph_apm_sel, ARRAY_SIZE(periph_apm_sel)); | ||
95 | clk[main_bus] = imx_clk_mux("main_bus", MXC_CCM_CBCDR, 25, 1, | ||
96 | main_bus_sel, ARRAY_SIZE(main_bus_sel)); | ||
97 | clk[per_lp_apm] = imx_clk_mux("per_lp_apm", MXC_CCM_CBCDR, 1, 1, | ||
98 | per_lp_apm_sel, ARRAY_SIZE(per_lp_apm_sel)); | ||
99 | clk[per_pred1] = imx_clk_divider("per_pred1", "per_lp_apm", MXC_CCM_CBCDR, 6, 2); | ||
100 | clk[per_pred2] = imx_clk_divider("per_pred2", "per_pred1", MXC_CCM_CBCDR, 3, 3); | ||
101 | clk[per_podf] = imx_clk_divider("per_podf", "per_pred2", MXC_CCM_CBCDR, 0, 3); | ||
102 | clk[per_root] = imx_clk_mux("per_root", MXC_CCM_CBCDR, 1, 0, | ||
103 | per_root_sel, ARRAY_SIZE(per_root_sel)); | ||
104 | clk[ahb] = imx_clk_divider("ahb", "main_bus", MXC_CCM_CBCDR, 10, 3); | ||
105 | clk[ahb_max] = imx_clk_gate2("ahb_max", "ahb", MXC_CCM_CCGR0, 28); | ||
106 | clk[aips_tz1] = imx_clk_gate2("aips_tz1", "ahb", MXC_CCM_CCGR0, 24); | ||
107 | clk[aips_tz2] = imx_clk_gate2("aips_tz2", "ahb", MXC_CCM_CCGR0, 26); | ||
108 | clk[tmax1] = imx_clk_gate2("tmax1", "ahb", MXC_CCM_CCGR1, 0); | ||
109 | clk[tmax2] = imx_clk_gate2("tmax2", "ahb", MXC_CCM_CCGR1, 2); | ||
110 | clk[tmax3] = imx_clk_gate2("tmax3", "ahb", MXC_CCM_CCGR1, 4); | ||
111 | clk[spba] = imx_clk_gate2("spba", "ipg", MXC_CCM_CCGR5, 0); | ||
112 | clk[ipg] = imx_clk_divider("ipg", "ahb", MXC_CCM_CBCDR, 8, 2); | ||
113 | clk[axi_a] = imx_clk_divider("axi_a", "main_bus", MXC_CCM_CBCDR, 16, 3); | ||
114 | clk[axi_b] = imx_clk_divider("axi_b", "main_bus", MXC_CCM_CBCDR, 19, 3); | ||
115 | clk[uart_sel] = imx_clk_mux("uart_sel", MXC_CCM_CSCMR1, 24, 2, | ||
116 | standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); | ||
117 | clk[uart_pred] = imx_clk_divider("uart_pred", "uart_sel", MXC_CCM_CSCDR1, 3, 3); | ||
118 | clk[uart_root] = imx_clk_divider("uart_root", "uart_pred", MXC_CCM_CSCDR1, 0, 3); | ||
119 | |||
120 | clk[esdhc_a_sel] = imx_clk_mux("esdhc_a_sel", MXC_CCM_CSCMR1, 20, 2, | ||
121 | standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); | ||
122 | clk[esdhc_b_sel] = imx_clk_mux("esdhc_b_sel", MXC_CCM_CSCMR1, 16, 2, | ||
123 | standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); | ||
124 | clk[esdhc_a_pred] = imx_clk_divider("esdhc_a_pred", "esdhc_a_sel", MXC_CCM_CSCDR1, 16, 3); | ||
125 | clk[esdhc_a_podf] = imx_clk_divider("esdhc_a_podf", "esdhc_a_pred", MXC_CCM_CSCDR1, 11, 3); | ||
126 | clk[esdhc_b_pred] = imx_clk_divider("esdhc_b_pred", "esdhc_b_sel", MXC_CCM_CSCDR1, 22, 3); | ||
127 | clk[esdhc_b_podf] = imx_clk_divider("esdhc_b_podf", "esdhc_b_pred", MXC_CCM_CSCDR1, 19, 3); | ||
128 | clk[esdhc_c_s] = imx_clk_mux("esdhc_c_sel", MXC_CCM_CSCMR1, 19, 1, esdhc_c_sel, ARRAY_SIZE(esdhc_c_sel)); | ||
129 | clk[esdhc_d_s] = imx_clk_mux("esdhc_d_sel", MXC_CCM_CSCMR1, 18, 1, esdhc_d_sel, ARRAY_SIZE(esdhc_d_sel)); | ||
130 | |||
131 | clk[emi_sel] = imx_clk_mux("emi_sel", MXC_CCM_CBCDR, 26, 1, | ||
132 | emi_slow_sel, ARRAY_SIZE(emi_slow_sel)); | ||
133 | clk[emi_slow_podf] = imx_clk_divider("emi_slow_podf", "emi_sel", MXC_CCM_CBCDR, 22, 3); | ||
134 | clk[nfc_podf] = imx_clk_divider("nfc_podf", "emi_slow_podf", MXC_CCM_CBCDR, 13, 3); | ||
135 | clk[ecspi_sel] = imx_clk_mux("ecspi_sel", MXC_CCM_CSCMR1, 4, 2, | ||
136 | standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); | ||
137 | clk[ecspi_pred] = imx_clk_divider("ecspi_pred", "ecspi_sel", MXC_CCM_CSCDR2, 25, 3); | ||
138 | clk[ecspi_podf] = imx_clk_divider("ecspi_podf", "ecspi_pred", MXC_CCM_CSCDR2, 19, 6); | ||
139 | clk[usboh3_sel] = imx_clk_mux("usboh3_sel", MXC_CCM_CSCMR1, 22, 2, | ||
140 | standard_pll_sel, ARRAY_SIZE(standard_pll_sel)); | ||
141 | clk[usboh3_pred] = imx_clk_divider("usboh3_pred", "usboh3_sel", MXC_CCM_CSCDR1, 8, 3); | ||
142 | clk[usboh3_podf] = imx_clk_divider("usboh3_podf", "usboh3_pred", MXC_CCM_CSCDR1, 6, 2); | ||
143 | clk[usb_phy_pred] = imx_clk_divider("usb_phy_pred", "pll3_sw", MXC_CCM_CDCDR, 3, 3); | ||
144 | clk[usb_phy_podf] = imx_clk_divider("usb_phy_podf", "usb_phy_pred", MXC_CCM_CDCDR, 0, 3); | ||
145 | clk[usb_phy_sel] = imx_clk_mux("usb_phy_sel", MXC_CCM_CSCMR1, 26, 1, | ||
146 | usb_phy_sel_str, ARRAY_SIZE(usb_phy_sel_str)); | ||
147 | clk[cpu_podf] = imx_clk_divider("cpu_podf", "pll1_sw", MXC_CCM_CACRR, 0, 3); | ||
148 | clk[di_pred] = imx_clk_divider("di_pred", "pll3_sw", MXC_CCM_CDCDR, 6, 3); | ||
149 | clk[tve_di] = imx_clk_fixed("tve_di", 65000000); /* FIXME */ | ||
150 | clk[tve_s] = imx_clk_mux("tve_sel", MXC_CCM_CSCMR1, 7, 1, tve_sel, ARRAY_SIZE(tve_sel)); | ||
151 | clk[iim_gate] = imx_clk_gate2("iim_gate", "ipg", MXC_CCM_CCGR0, 30); | ||
152 | clk[uart1_ipg_gate] = imx_clk_gate2("uart1_ipg_gate", "ipg", MXC_CCM_CCGR1, 6); | ||
153 | clk[uart1_per_gate] = imx_clk_gate2("uart1_per_gate", "uart_root", MXC_CCM_CCGR1, 8); | ||
154 | clk[uart2_ipg_gate] = imx_clk_gate2("uart2_ipg_gate", "ipg", MXC_CCM_CCGR1, 10); | ||
155 | clk[uart2_per_gate] = imx_clk_gate2("uart2_per_gate", "uart_root", MXC_CCM_CCGR1, 12); | ||
156 | clk[uart3_ipg_gate] = imx_clk_gate2("uart3_ipg_gate", "ipg", MXC_CCM_CCGR1, 14); | ||
157 | clk[uart3_per_gate] = imx_clk_gate2("uart3_per_gate", "uart_root", MXC_CCM_CCGR1, 16); | ||
158 | clk[i2c1_gate] = imx_clk_gate2("i2c1_gate", "per_root", MXC_CCM_CCGR1, 18); | ||
159 | clk[i2c2_gate] = imx_clk_gate2("i2c2_gate", "per_root", MXC_CCM_CCGR1, 20); | ||
160 | clk[gpt_ipg_gate] = imx_clk_gate2("gpt_ipg_gate", "ipg", MXC_CCM_CCGR2, 20); | ||
161 | clk[pwm1_ipg_gate] = imx_clk_gate2("pwm1_ipg_gate", "ipg", MXC_CCM_CCGR2, 10); | ||
162 | clk[pwm1_hf_gate] = imx_clk_gate2("pwm1_hf_gate", "ipg", MXC_CCM_CCGR2, 12); | ||
163 | clk[pwm2_ipg_gate] = imx_clk_gate2("pwm2_ipg_gate", "ipg", MXC_CCM_CCGR2, 14); | ||
164 | clk[pwm2_hf_gate] = imx_clk_gate2("pwm2_hf_gate", "ipg", MXC_CCM_CCGR2, 16); | ||
165 | clk[gpt_gate] = imx_clk_gate2("gpt_gate", "ipg", MXC_CCM_CCGR2, 18); | ||
166 | clk[fec_gate] = imx_clk_gate2("fec_gate", "ipg", MXC_CCM_CCGR2, 24); | ||
167 | clk[usboh3_gate] = imx_clk_gate2("usboh3_gate", "ipg", MXC_CCM_CCGR2, 26); | ||
168 | clk[usboh3_per_gate] = imx_clk_gate2("usboh3_per_gate", "usboh3_podf", MXC_CCM_CCGR2, 28); | ||
169 | clk[esdhc1_ipg_gate] = imx_clk_gate2("esdhc1_ipg_gate", "ipg", MXC_CCM_CCGR3, 0); | ||
170 | clk[esdhc2_ipg_gate] = imx_clk_gate2("esdhc2_ipg_gate", "ipg", MXC_CCM_CCGR3, 4); | ||
171 | clk[esdhc3_ipg_gate] = imx_clk_gate2("esdhc3_ipg_gate", "ipg", MXC_CCM_CCGR3, 8); | ||
172 | clk[esdhc4_ipg_gate] = imx_clk_gate2("esdhc4_ipg_gate", "ipg", MXC_CCM_CCGR3, 12); | ||
173 | clk[ssi1_ipg_gate] = imx_clk_gate2("ssi1_ipg_gate", "ipg", MXC_CCM_CCGR3, 16); | ||
174 | clk[ssi2_ipg_gate] = imx_clk_gate2("ssi2_ipg_gate", "ipg", MXC_CCM_CCGR3, 20); | ||
175 | clk[ssi3_ipg_gate] = imx_clk_gate2("ssi3_ipg_gate", "ipg", MXC_CCM_CCGR3, 24); | ||
176 | clk[ecspi1_ipg_gate] = imx_clk_gate2("ecspi1_ipg_gate", "ipg", MXC_CCM_CCGR4, 18); | ||
177 | clk[ecspi1_per_gate] = imx_clk_gate2("ecspi1_per_gate", "ecspi_podf", MXC_CCM_CCGR4, 20); | ||
178 | clk[ecspi2_ipg_gate] = imx_clk_gate2("ecspi2_ipg_gate", "ipg", MXC_CCM_CCGR4, 22); | ||
179 | clk[ecspi2_per_gate] = imx_clk_gate2("ecspi2_per_gate", "ecspi_podf", MXC_CCM_CCGR4, 24); | ||
180 | clk[cspi_ipg_gate] = imx_clk_gate2("cspi_ipg_gate", "ipg", MXC_CCM_CCGR4, 26); | ||
181 | clk[sdma_gate] = imx_clk_gate2("sdma_gate", "ipg", MXC_CCM_CCGR4, 30); | ||
182 | clk[emi_fast_gate] = imx_clk_gate2("emi_fast_gate", "dummy", MXC_CCM_CCGR5, 14); | ||
183 | clk[emi_slow_gate] = imx_clk_gate2("emi_slow_gate", "emi_slow_podf", MXC_CCM_CCGR5, 16); | ||
184 | clk[ipu_s] = imx_clk_mux("ipu_sel", MXC_CCM_CBCMR, 6, 2, ipu_sel, ARRAY_SIZE(ipu_sel)); | ||
185 | clk[ipu_gate] = imx_clk_gate2("ipu_gate", "ipu_sel", MXC_CCM_CCGR5, 10); | ||
186 | clk[nfc_gate] = imx_clk_gate2("nfc_gate", "nfc_podf", MXC_CCM_CCGR5, 20); | ||
187 | clk[ipu_di0_gate] = imx_clk_gate2("ipu_di0_gate", "ipu_di0_sel", MXC_CCM_CCGR6, 10); | ||
188 | clk[ipu_di1_gate] = imx_clk_gate2("ipu_di1_gate", "ipu_di1_sel", MXC_CCM_CCGR6, 12); | ||
189 | clk[vpu_s] = imx_clk_mux("vpu_sel", MXC_CCM_CBCMR, 14, 2, vpu_sel, ARRAY_SIZE(vpu_sel)); | ||
190 | clk[vpu_gate] = imx_clk_gate2("vpu_gate", "vpu_sel", MXC_CCM_CCGR5, 6); | ||
191 | clk[vpu_reference_gate] = imx_clk_gate2("vpu_reference_gate", "osc", MXC_CCM_CCGR5, 8); | ||
192 | clk[uart4_ipg_gate] = imx_clk_gate2("uart4_ipg_gate", "ipg", MXC_CCM_CCGR7, 8); | ||
193 | clk[uart4_per_gate] = imx_clk_gate2("uart4_per_gate", "uart_root", MXC_CCM_CCGR7, 10); | ||
194 | clk[uart5_ipg_gate] = imx_clk_gate2("uart5_ipg_gate", "ipg", MXC_CCM_CCGR7, 12); | ||
195 | clk[uart5_per_gate] = imx_clk_gate2("uart5_per_gate", "uart_root", MXC_CCM_CCGR7, 14); | ||
196 | clk[gpc_dvfs] = imx_clk_gate2("gpc_dvfs", "dummy", MXC_CCM_CCGR5, 24); | ||
197 | |||
198 | for (i = 0; i < ARRAY_SIZE(clk); i++) | ||
199 | if (IS_ERR(clk[i])) | ||
200 | pr_err("i.MX5 clk %d: register failed with %ld\n", | ||
201 | i, PTR_ERR(clk[i])); | ||
202 | |||
203 | clk_register_clkdev(clk[gpt_gate], "per", "imx-gpt.0"); | ||
204 | clk_register_clkdev(clk[gpt_ipg_gate], "ipg", "imx-gpt.0"); | ||
205 | clk_register_clkdev(clk[uart1_per_gate], "per", "imx21-uart.0"); | ||
206 | clk_register_clkdev(clk[uart1_ipg_gate], "ipg", "imx21-uart.0"); | ||
207 | clk_register_clkdev(clk[uart2_per_gate], "per", "imx21-uart.1"); | ||
208 | clk_register_clkdev(clk[uart2_ipg_gate], "ipg", "imx21-uart.1"); | ||
209 | clk_register_clkdev(clk[uart3_per_gate], "per", "imx21-uart.2"); | ||
210 | clk_register_clkdev(clk[uart3_ipg_gate], "ipg", "imx21-uart.2"); | ||
211 | clk_register_clkdev(clk[uart4_per_gate], "per", "imx21-uart.3"); | ||
212 | clk_register_clkdev(clk[uart4_ipg_gate], "ipg", "imx21-uart.3"); | ||
213 | clk_register_clkdev(clk[uart5_per_gate], "per", "imx21-uart.4"); | ||
214 | clk_register_clkdev(clk[uart5_ipg_gate], "ipg", "imx21-uart.4"); | ||
215 | clk_register_clkdev(clk[ecspi1_per_gate], "per", "imx51-ecspi.0"); | ||
216 | clk_register_clkdev(clk[ecspi1_ipg_gate], "ipg", "imx51-ecspi.0"); | ||
217 | clk_register_clkdev(clk[ecspi2_per_gate], "per", "imx51-ecspi.1"); | ||
218 | clk_register_clkdev(clk[ecspi2_ipg_gate], "ipg", "imx51-ecspi.1"); | ||
219 | clk_register_clkdev(clk[cspi_ipg_gate], NULL, "imx51-cspi.0"); | ||
220 | clk_register_clkdev(clk[pwm1_ipg_gate], "pwm", "mxc_pwm.0"); | ||
221 | clk_register_clkdev(clk[pwm2_ipg_gate], "pwm", "mxc_pwm.1"); | ||
222 | clk_register_clkdev(clk[i2c1_gate], NULL, "imx-i2c.0"); | ||
223 | clk_register_clkdev(clk[i2c2_gate], NULL, "imx-i2c.1"); | ||
224 | clk_register_clkdev(clk[usboh3_per_gate], "per", "mxc-ehci.0"); | ||
225 | clk_register_clkdev(clk[usboh3_gate], "ipg", "mxc-ehci.0"); | ||
226 | clk_register_clkdev(clk[usboh3_gate], "ahb", "mxc-ehci.0"); | ||
227 | clk_register_clkdev(clk[usboh3_per_gate], "per", "mxc-ehci.1"); | ||
228 | clk_register_clkdev(clk[usboh3_gate], "ipg", "mxc-ehci.1"); | ||
229 | clk_register_clkdev(clk[usboh3_gate], "ahb", "mxc-ehci.1"); | ||
230 | clk_register_clkdev(clk[usboh3_per_gate], "per", "mxc-ehci.2"); | ||
231 | clk_register_clkdev(clk[usboh3_gate], "ipg", "mxc-ehci.2"); | ||
232 | clk_register_clkdev(clk[usboh3_gate], "ahb", "mxc-ehci.2"); | ||
233 | clk_register_clkdev(clk[usboh3_per_gate], "per", "fsl-usb2-udc"); | ||
234 | clk_register_clkdev(clk[usboh3_gate], "ipg", "fsl-usb2-udc"); | ||
235 | clk_register_clkdev(clk[usboh3_gate], "ahb", "fsl-usb2-udc"); | ||
236 | clk_register_clkdev(clk[nfc_gate], NULL, "mxc_nand"); | ||
237 | clk_register_clkdev(clk[ssi1_ipg_gate], NULL, "imx-ssi.0"); | ||
238 | clk_register_clkdev(clk[ssi2_ipg_gate], NULL, "imx-ssi.1"); | ||
239 | clk_register_clkdev(clk[ssi3_ipg_gate], NULL, "imx-ssi.2"); | ||
240 | clk_register_clkdev(clk[sdma_gate], NULL, "imx35-sdma"); | ||
241 | clk_register_clkdev(clk[cpu_podf], "cpu", NULL); | ||
242 | clk_register_clkdev(clk[iim_gate], "iim", NULL); | ||
243 | clk_register_clkdev(clk[dummy], NULL, "imx2-wdt.0"); | ||
244 | clk_register_clkdev(clk[dummy], NULL, "imx2-wdt.1"); | ||
245 | clk_register_clkdev(clk[dummy], NULL, "imx-keypad"); | ||
246 | clk_register_clkdev(clk[tve_gate], NULL, "imx-tve.0"); | ||
247 | clk_register_clkdev(clk[ipu_di1_gate], "di1", "imx-tve.0"); | ||
248 | |||
249 | /* Set SDHC parents to be PLL2 */ | ||
250 | clk_set_parent(clk[esdhc_a_sel], clk[pll2_sw]); | ||
251 | clk_set_parent(clk[esdhc_b_sel], clk[pll2_sw]); | ||
252 | |||
253 | /* move usb phy clk to 24MHz */ | ||
254 | clk_set_parent(clk[usb_phy_sel], clk[osc]); | ||
255 | |||
256 | clk_prepare_enable(clk[gpc_dvfs]); | ||
257 | clk_prepare_enable(clk[ahb_max]); /* esdhc3 */ | ||
258 | clk_prepare_enable(clk[aips_tz1]); | ||
259 | clk_prepare_enable(clk[aips_tz2]); /* fec */ | ||
260 | clk_prepare_enable(clk[spba]); | ||
261 | clk_prepare_enable(clk[emi_fast_gate]); /* fec */ | ||
262 | clk_prepare_enable(clk[tmax1]); | ||
263 | clk_prepare_enable(clk[tmax2]); /* esdhc2, fec */ | ||
264 | clk_prepare_enable(clk[tmax3]); /* esdhc1, esdhc4 */ | ||
265 | } | ||
266 | |||
267 | int __init mx51_clocks_init(unsigned long rate_ckil, unsigned long rate_osc, | ||
268 | unsigned long rate_ckih1, unsigned long rate_ckih2) | ||
269 | { | ||
270 | int i; | ||
271 | |||
272 | clk[pll1_sw] = imx_clk_pllv2("pll1_sw", "osc", MX51_DPLL1_BASE); | ||
273 | clk[pll2_sw] = imx_clk_pllv2("pll2_sw", "osc", MX51_DPLL2_BASE); | ||
274 | clk[pll3_sw] = imx_clk_pllv2("pll3_sw", "osc", MX51_DPLL3_BASE); | ||
275 | clk[ipu_di0_sel] = imx_clk_mux("ipu_di0_sel", MXC_CCM_CSCMR2, 26, 3, | ||
276 | mx51_ipu_di0_sel, ARRAY_SIZE(mx51_ipu_di0_sel)); | ||
277 | clk[ipu_di1_sel] = imx_clk_mux("ipu_di1_sel", MXC_CCM_CSCMR2, 29, 3, | ||
278 | mx51_ipu_di1_sel, ARRAY_SIZE(mx51_ipu_di1_sel)); | ||
279 | clk[tve_ext_sel] = imx_clk_mux("tve_ext_sel", MXC_CCM_CSCMR1, 6, 1, | ||
280 | mx51_tve_ext_sel, ARRAY_SIZE(mx51_tve_ext_sel)); | ||
281 | clk[tve_gate] = imx_clk_gate2("tve_gate", "tve_sel", MXC_CCM_CCGR2, 30); | ||
282 | clk[tve_pred] = imx_clk_divider("tve_pred", "pll3_sw", MXC_CCM_CDCDR, 28, 3); | ||
283 | clk[esdhc1_per_gate] = imx_clk_gate2("esdhc1_per_gate", "esdhc_a_podf", MXC_CCM_CCGR3, 2); | ||
284 | clk[esdhc2_per_gate] = imx_clk_gate2("esdhc2_per_gate", "esdhc_b_podf", MXC_CCM_CCGR3, 6); | ||
285 | clk[esdhc3_per_gate] = imx_clk_gate2("esdhc3_per_gate", "esdhc_c_sel", MXC_CCM_CCGR3, 10); | ||
286 | clk[esdhc4_per_gate] = imx_clk_gate2("esdhc4_per_gate", "esdhc_d_sel", MXC_CCM_CCGR3, 14); | ||
287 | clk[usb_phy_gate] = imx_clk_gate2("usb_phy_gate", "usb_phy_sel", MXC_CCM_CCGR2, 0); | ||
288 | clk[hsi2c_gate] = imx_clk_gate2("hsi2c_gate", "ipg", MXC_CCM_CCGR1, 22); | ||
289 | clk[mipi_hsc1_gate] = imx_clk_gate2("mipi_hsc1_gate", "ipg", MXC_CCM_CCGR4, 6); | ||
290 | clk[mipi_hsc2_gate] = imx_clk_gate2("mipi_hsc2_gate", "ipg", MXC_CCM_CCGR4, 8); | ||
291 | clk[mipi_esc_gate] = imx_clk_gate2("mipi_esc_gate", "ipg", MXC_CCM_CCGR4, 10); | ||
292 | clk[mipi_hsp_gate] = imx_clk_gate2("mipi_hsp_gate", "ipg", MXC_CCM_CCGR4, 12); | ||
293 | |||
294 | for (i = 0; i < ARRAY_SIZE(clk); i++) | ||
295 | if (IS_ERR(clk[i])) | ||
296 | pr_err("i.MX51 clk %d: register failed with %ld\n", | ||
297 | i, PTR_ERR(clk[i])); | ||
298 | |||
299 | mx5_clocks_common_init(rate_ckil, rate_osc, rate_ckih1, rate_ckih2); | ||
300 | |||
301 | clk_register_clkdev(clk[hsi2c_gate], NULL, "imx-i2c.2"); | ||
302 | clk_register_clkdev(clk[mx51_mipi], "mipi_hsp", NULL); | ||
303 | clk_register_clkdev(clk[vpu_gate], NULL, "imx51-vpu.0"); | ||
304 | clk_register_clkdev(clk[fec_gate], NULL, "imx27-fec.0"); | ||
305 | clk_register_clkdev(clk[gpc_dvfs], "gpc_dvfs", NULL); | ||
306 | clk_register_clkdev(clk[ipu_gate], "bus", "imx51-ipu"); | ||
307 | clk_register_clkdev(clk[ipu_di0_gate], "di0", "imx51-ipu"); | ||
308 | clk_register_clkdev(clk[ipu_di1_gate], "di1", "imx51-ipu"); | ||
309 | clk_register_clkdev(clk[ipu_gate], "hsp", "imx51-ipu"); | ||
310 | clk_register_clkdev(clk[usb_phy_gate], "phy", "mxc-ehci.0"); | ||
311 | clk_register_clkdev(clk[esdhc1_ipg_gate], "ipg", "sdhci-esdhc-imx51.0"); | ||
312 | clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx51.0"); | ||
313 | clk_register_clkdev(clk[esdhc1_per_gate], "per", "sdhci-esdhc-imx51.0"); | ||
314 | clk_register_clkdev(clk[esdhc2_ipg_gate], "ipg", "sdhci-esdhc-imx51.1"); | ||
315 | clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx51.1"); | ||
316 | clk_register_clkdev(clk[esdhc2_per_gate], "per", "sdhci-esdhc-imx51.1"); | ||
317 | clk_register_clkdev(clk[esdhc3_ipg_gate], "ipg", "sdhci-esdhc-imx51.2"); | ||
318 | clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx51.2"); | ||
319 | clk_register_clkdev(clk[esdhc3_per_gate], "per", "sdhci-esdhc-imx51.2"); | ||
320 | clk_register_clkdev(clk[esdhc4_ipg_gate], "ipg", "sdhci-esdhc-imx51.3"); | ||
321 | clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx51.3"); | ||
322 | clk_register_clkdev(clk[esdhc4_per_gate], "per", "sdhci-esdhc-imx51.3"); | ||
323 | |||
324 | /* set the usboh3 parent to pll2_sw */ | ||
325 | clk_set_parent(clk[usboh3_sel], clk[pll2_sw]); | ||
326 | |||
327 | /* set SDHC root clock to 166.25MHZ*/ | ||
328 | clk_set_rate(clk[esdhc_a_podf], 166250000); | ||
329 | clk_set_rate(clk[esdhc_b_podf], 166250000); | ||
330 | |||
331 | /* System timer */ | ||
332 | mxc_timer_init(NULL, MX51_IO_ADDRESS(MX51_GPT1_BASE_ADDR), | ||
333 | MX51_INT_GPT); | ||
334 | |||
335 | clk_prepare_enable(clk[iim_gate]); | ||
336 | imx_print_silicon_rev("i.MX51", mx51_revision()); | ||
337 | clk_disable_unprepare(clk[iim_gate]); | ||
338 | |||
339 | return 0; | ||
340 | } | ||
341 | |||
342 | int __init mx53_clocks_init(unsigned long rate_ckil, unsigned long rate_osc, | ||
343 | unsigned long rate_ckih1, unsigned long rate_ckih2) | ||
344 | { | ||
345 | int i; | ||
346 | unsigned long r; | ||
347 | |||
348 | clk[pll1_sw] = imx_clk_pllv2("pll1_sw", "osc", MX53_DPLL1_BASE); | ||
349 | clk[pll2_sw] = imx_clk_pllv2("pll2_sw", "osc", MX53_DPLL2_BASE); | ||
350 | clk[pll3_sw] = imx_clk_pllv2("pll3_sw", "osc", MX53_DPLL3_BASE); | ||
351 | clk[pll4_sw] = imx_clk_pllv2("pll4_sw", "osc", MX53_DPLL4_BASE); | ||
352 | |||
353 | clk[ldb_di1_sel] = imx_clk_mux("ldb_di1_sel", MXC_CCM_CSCMR2, 9, 1, | ||
354 | mx53_ldb_di1_sel, ARRAY_SIZE(mx53_ldb_di1_sel)); | ||
355 | clk[ldb_di1_div_3_5] = imx_clk_fixed_factor("ldb_di1_div_3_5", "ldb_di1_sel", 2, 7); | ||
356 | clk[ldb_di1_div] = imx_clk_divider("ldb_di1_div", "ldb_di1_div_3_5", MXC_CCM_CSCMR2, 11, 1); | ||
357 | clk[di_pll4_podf] = imx_clk_divider("di_pll4_podf", "pll4_sw", MXC_CCM_CDCDR, 16, 3); | ||
358 | clk[ldb_di0_sel] = imx_clk_mux("ldb_di0_sel", MXC_CCM_CSCMR2, 8, 1, | ||
359 | mx53_ldb_di0_sel, ARRAY_SIZE(mx53_ldb_di0_sel)); | ||
360 | clk[ldb_di0_div_3_5] = imx_clk_fixed_factor("ldb_di0_div_3_5", "ldb_di0_sel", 2, 7); | ||
361 | clk[ldb_di0_div] = imx_clk_divider("ldb_di0_div", "ldb_di0_div_3_5", MXC_CCM_CSCMR2, 10, 1); | ||
362 | clk[ldb_di0_gate] = imx_clk_gate2("ldb_di0_gate", "ldb_di0_div", MXC_CCM_CCGR6, 28); | ||
363 | clk[ldb_di1_gate] = imx_clk_gate2("ldb_di1_gate", "ldb_di1_div", MXC_CCM_CCGR6, 30); | ||
364 | clk[ipu_di0_sel] = imx_clk_mux("ipu_di0_sel", MXC_CCM_CSCMR2, 26, 3, | ||
365 | mx53_ipu_di0_sel, ARRAY_SIZE(mx53_ipu_di0_sel)); | ||
366 | clk[ipu_di1_sel] = imx_clk_mux("ipu_di1_sel", MXC_CCM_CSCMR2, 29, 3, | ||
367 | mx53_ipu_di1_sel, ARRAY_SIZE(mx53_ipu_di1_sel)); | ||
368 | clk[tve_ext_sel] = imx_clk_mux("tve_ext_sel", MXC_CCM_CSCMR1, 6, 1, | ||
369 | mx53_tve_ext_sel, ARRAY_SIZE(mx53_tve_ext_sel)); | ||
370 | clk[tve_gate] = imx_clk_gate2("tve_gate", "tve_pred", MXC_CCM_CCGR2, 30); | ||
371 | clk[tve_pred] = imx_clk_divider("tve_pred", "tve_ext_sel", MXC_CCM_CDCDR, 28, 3); | ||
372 | clk[esdhc1_per_gate] = imx_clk_gate2("esdhc1_per_gate", "esdhc_a_podf", MXC_CCM_CCGR3, 2); | ||
373 | clk[esdhc2_per_gate] = imx_clk_gate2("esdhc2_per_gate", "esdhc_c_sel", MXC_CCM_CCGR3, 6); | ||
374 | clk[esdhc3_per_gate] = imx_clk_gate2("esdhc3_per_gate", "esdhc_b_podf", MXC_CCM_CCGR3, 10); | ||
375 | clk[esdhc4_per_gate] = imx_clk_gate2("esdhc4_per_gate", "esdhc_d_sel", MXC_CCM_CCGR3, 14); | ||
376 | clk[usb_phy1_gate] = imx_clk_gate2("usb_phy1_gate", "usb_phy_sel", MXC_CCM_CCGR4, 10); | ||
377 | clk[usb_phy2_gate] = imx_clk_gate2("usb_phy2_gate", "usb_phy_sel", MXC_CCM_CCGR4, 12); | ||
378 | clk[can2_serial_gate] = imx_clk_gate2("can2_serial_gate", "ipg", MXC_CCM_CCGR4, 6); | ||
379 | clk[can2_ipg_gate] = imx_clk_gate2("can2_ipg_gate", "ipg", MXC_CCM_CCGR4, 8); | ||
380 | clk[i2c3_gate] = imx_clk_gate2("i2c3_gate", "per_root", MXC_CCM_CCGR1, 22); | ||
381 | |||
382 | for (i = 0; i < ARRAY_SIZE(clk); i++) | ||
383 | if (IS_ERR(clk[i])) | ||
384 | pr_err("i.MX53 clk %d: register failed with %ld\n", | ||
385 | i, PTR_ERR(clk[i])); | ||
386 | |||
387 | mx5_clocks_common_init(rate_ckil, rate_osc, rate_ckih1, rate_ckih2); | ||
388 | |||
389 | clk_register_clkdev(clk[vpu_gate], NULL, "imx53-vpu.0"); | ||
390 | clk_register_clkdev(clk[i2c3_gate], NULL, "imx-i2c.2"); | ||
391 | clk_register_clkdev(clk[fec_gate], NULL, "imx25-fec.0"); | ||
392 | clk_register_clkdev(clk[ipu_gate], "bus", "imx53-ipu"); | ||
393 | clk_register_clkdev(clk[ipu_di0_gate], "di0", "imx53-ipu"); | ||
394 | clk_register_clkdev(clk[ipu_di1_gate], "di1", "imx53-ipu"); | ||
395 | clk_register_clkdev(clk[ipu_gate], "hsp", "imx53-ipu"); | ||
396 | clk_register_clkdev(clk[usb_phy1_gate], "usb_phy1", "mxc-ehci.0"); | ||
397 | clk_register_clkdev(clk[esdhc1_ipg_gate], "ipg", "sdhci-esdhc-imx53.0"); | ||
398 | clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx53.0"); | ||
399 | clk_register_clkdev(clk[esdhc1_per_gate], "per", "sdhci-esdhc-imx53.0"); | ||
400 | clk_register_clkdev(clk[esdhc2_ipg_gate], "ipg", "sdhci-esdhc-imx53.1"); | ||
401 | clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx53.1"); | ||
402 | clk_register_clkdev(clk[esdhc2_per_gate], "per", "sdhci-esdhc-imx53.1"); | ||
403 | clk_register_clkdev(clk[esdhc3_ipg_gate], "ipg", "sdhci-esdhc-imx53.2"); | ||
404 | clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx53.2"); | ||
405 | clk_register_clkdev(clk[esdhc3_per_gate], "per", "sdhci-esdhc-imx53.2"); | ||
406 | clk_register_clkdev(clk[esdhc4_ipg_gate], "ipg", "sdhci-esdhc-imx53.3"); | ||
407 | clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx53.3"); | ||
408 | clk_register_clkdev(clk[esdhc4_per_gate], "per", "sdhci-esdhc-imx53.3"); | ||
409 | |||
410 | /* set SDHC root clock to 200MHZ*/ | ||
411 | clk_set_rate(clk[esdhc_a_podf], 200000000); | ||
412 | clk_set_rate(clk[esdhc_b_podf], 200000000); | ||
413 | |||
414 | /* System timer */ | ||
415 | mxc_timer_init(NULL, MX53_IO_ADDRESS(MX53_GPT1_BASE_ADDR), | ||
416 | MX53_INT_GPT); | ||
417 | |||
418 | clk_prepare_enable(clk[iim_gate]); | ||
419 | imx_print_silicon_rev("i.MX53", mx53_revision()); | ||
420 | clk_disable_unprepare(clk[iim_gate]); | ||
421 | |||
422 | r = clk_round_rate(clk[usboh3_per_gate], 54000000); | ||
423 | clk_set_rate(clk[usboh3_per_gate], r); | ||
424 | |||
425 | return 0; | ||
426 | } | ||
427 | |||
428 | #ifdef CONFIG_OF | ||
429 | static void __init clk_get_freq_dt(unsigned long *ckil, unsigned long *osc, | ||
430 | unsigned long *ckih1, unsigned long *ckih2) | ||
431 | { | ||
432 | struct device_node *np; | ||
433 | |||
434 | /* retrieve the freqency of fixed clocks from device tree */ | ||
435 | for_each_compatible_node(np, NULL, "fixed-clock") { | ||
436 | u32 rate; | ||
437 | if (of_property_read_u32(np, "clock-frequency", &rate)) | ||
438 | continue; | ||
439 | |||
440 | if (of_device_is_compatible(np, "fsl,imx-ckil")) | ||
441 | *ckil = rate; | ||
442 | else if (of_device_is_compatible(np, "fsl,imx-osc")) | ||
443 | *osc = rate; | ||
444 | else if (of_device_is_compatible(np, "fsl,imx-ckih1")) | ||
445 | *ckih1 = rate; | ||
446 | else if (of_device_is_compatible(np, "fsl,imx-ckih2")) | ||
447 | *ckih2 = rate; | ||
448 | } | ||
449 | } | ||
450 | |||
451 | int __init mx51_clocks_init_dt(void) | ||
452 | { | ||
453 | unsigned long ckil, osc, ckih1, ckih2; | ||
454 | |||
455 | clk_get_freq_dt(&ckil, &osc, &ckih1, &ckih2); | ||
456 | return mx51_clocks_init(ckil, osc, ckih1, ckih2); | ||
457 | } | ||
458 | |||
459 | int __init mx53_clocks_init_dt(void) | ||
460 | { | ||
461 | unsigned long ckil, osc, ckih1, ckih2; | ||
462 | |||
463 | clk_get_freq_dt(&ckil, &osc, &ckih1, &ckih2); | ||
464 | return mx53_clocks_init(ckil, osc, ckih1, ckih2); | ||
465 | } | ||
466 | #endif | ||
diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c new file mode 100644 index 000000000000..f40a35da2e5c --- /dev/null +++ b/arch/arm/mach-imx/clk-imx6q.c | |||
@@ -0,0 +1,439 @@ | |||
1 | /* | ||
2 | * Copyright 2011 Freescale Semiconductor, Inc. | ||
3 | * Copyright 2011 Linaro Ltd. | ||
4 | * | ||
5 | * The code contained herein is licensed under the GNU General Public | ||
6 | * License. You may obtain a copy of the GNU General Public License | ||
7 | * Version 2 or later at the following locations: | ||
8 | * | ||
9 | * http://www.opensource.org/licenses/gpl-license.html | ||
10 | * http://www.gnu.org/copyleft/gpl.html | ||
11 | */ | ||
12 | |||
13 | #include <linux/init.h> | ||
14 | #include <linux/types.h> | ||
15 | #include <linux/clk.h> | ||
16 | #include <linux/clkdev.h> | ||
17 | #include <linux/err.h> | ||
18 | #include <linux/io.h> | ||
19 | #include <linux/of.h> | ||
20 | #include <linux/of_address.h> | ||
21 | #include <linux/of_irq.h> | ||
22 | #include <mach/common.h> | ||
23 | #include "clk.h" | ||
24 | |||
25 | #define CCGR0 0x68 | ||
26 | #define CCGR1 0x6c | ||
27 | #define CCGR2 0x70 | ||
28 | #define CCGR3 0x74 | ||
29 | #define CCGR4 0x78 | ||
30 | #define CCGR5 0x7c | ||
31 | #define CCGR6 0x80 | ||
32 | #define CCGR7 0x84 | ||
33 | |||
34 | #define CLPCR 0x54 | ||
35 | #define BP_CLPCR_LPM 0 | ||
36 | #define BM_CLPCR_LPM (0x3 << 0) | ||
37 | #define BM_CLPCR_BYPASS_PMIC_READY (0x1 << 2) | ||
38 | #define BM_CLPCR_ARM_CLK_DIS_ON_LPM (0x1 << 5) | ||
39 | #define BM_CLPCR_SBYOS (0x1 << 6) | ||
40 | #define BM_CLPCR_DIS_REF_OSC (0x1 << 7) | ||
41 | #define BM_CLPCR_VSTBY (0x1 << 8) | ||
42 | #define BP_CLPCR_STBY_COUNT 9 | ||
43 | #define BM_CLPCR_STBY_COUNT (0x3 << 9) | ||
44 | #define BM_CLPCR_COSC_PWRDOWN (0x1 << 11) | ||
45 | #define BM_CLPCR_WB_PER_AT_LPM (0x1 << 16) | ||
46 | #define BM_CLPCR_WB_CORE_AT_LPM (0x1 << 17) | ||
47 | #define BM_CLPCR_BYP_MMDC_CH0_LPM_HS (0x1 << 19) | ||
48 | #define BM_CLPCR_BYP_MMDC_CH1_LPM_HS (0x1 << 21) | ||
49 | #define BM_CLPCR_MASK_CORE0_WFI (0x1 << 22) | ||
50 | #define BM_CLPCR_MASK_CORE1_WFI (0x1 << 23) | ||
51 | #define BM_CLPCR_MASK_CORE2_WFI (0x1 << 24) | ||
52 | #define BM_CLPCR_MASK_CORE3_WFI (0x1 << 25) | ||
53 | #define BM_CLPCR_MASK_SCU_IDLE (0x1 << 26) | ||
54 | #define BM_CLPCR_MASK_L2CC_IDLE (0x1 << 27) | ||
55 | |||
56 | static void __iomem *ccm_base; | ||
57 | |||
58 | void __init imx6q_clock_map_io(void) { } | ||
59 | |||
60 | int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode) | ||
61 | { | ||
62 | u32 val = readl_relaxed(ccm_base + CLPCR); | ||
63 | |||
64 | val &= ~BM_CLPCR_LPM; | ||
65 | switch (mode) { | ||
66 | case WAIT_CLOCKED: | ||
67 | break; | ||
68 | case WAIT_UNCLOCKED: | ||
69 | val |= 0x1 << BP_CLPCR_LPM; | ||
70 | break; | ||
71 | case STOP_POWER_ON: | ||
72 | val |= 0x2 << BP_CLPCR_LPM; | ||
73 | break; | ||
74 | case WAIT_UNCLOCKED_POWER_OFF: | ||
75 | val |= 0x1 << BP_CLPCR_LPM; | ||
76 | val &= ~BM_CLPCR_VSTBY; | ||
77 | val &= ~BM_CLPCR_SBYOS; | ||
78 | break; | ||
79 | case STOP_POWER_OFF: | ||
80 | val |= 0x2 << BP_CLPCR_LPM; | ||
81 | val |= 0x3 << BP_CLPCR_STBY_COUNT; | ||
82 | val |= BM_CLPCR_VSTBY; | ||
83 | val |= BM_CLPCR_SBYOS; | ||
84 | break; | ||
85 | default: | ||
86 | return -EINVAL; | ||
87 | } | ||
88 | |||
89 | writel_relaxed(val, ccm_base + CLPCR); | ||
90 | |||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | static const char *step_sels[] = { "osc", "pll2_pfd2_396m", }; | ||
95 | static const char *pll1_sw_sels[] = { "pll1_sys", "step", }; | ||
96 | static const char *periph_pre_sels[] = { "pll2_bus", "pll2_pfd2_396m", "pll2_pfd0_352m", "pll2_198m", }; | ||
97 | static const char *periph_clk2_sels[] = { "pll3_usb_otg", "osc", }; | ||
98 | static const char *periph_sels[] = { "periph_pre", "periph_clk2", }; | ||
99 | static const char *periph2_sels[] = { "periph2_pre", "periph2_clk2", }; | ||
100 | static const char *axi_sels[] = { "periph", "pll2_pfd2_396m", "pll3_pfd1_540m", }; | ||
101 | static const char *audio_sels[] = { "pll4_audio", "pll3_pfd2_508m", "pll3_pfd3_454m", "pll3_usb_otg", }; | ||
102 | static const char *gpu_axi_sels[] = { "axi", "ahb", }; | ||
103 | static const char *gpu2d_core_sels[] = { "axi", "pll3_usb_otg", "pll2_pfd0_352m", "pll2_pfd2_396m", }; | ||
104 | static const char *gpu3d_core_sels[] = { "mmdc_ch0_axi", "pll3_usb_otg", "pll2_pfd1_594m", "pll2_pfd2_396m", }; | ||
105 | static const char *gpu3d_shader_sels[] = { "mmdc_ch0_axi", "pll3_usb_otg", "pll2_pfd1_594m", "pll2_pfd9_720m", }; | ||
106 | static const char *ipu_sels[] = { "mmdc_ch0_axi", "pll2_pfd2_396m", "pll3_120m", "pll3_pfd1_540m", }; | ||
107 | static const char *ldb_di_sels[] = { "pll5_video", "pll2_pfd0_352m", "pll2_pfd2_396m", "pll3_pfd1_540m", }; | ||
108 | static const char *ipu_di_pre_sels[] = { "mmdc_ch0_axi", "pll3_usb_otg", "pll5_video", "pll2_pfd0_352m", "pll2_pfd2_396m", "pll3_pfd1_540m", }; | ||
109 | static const char *ipu1_di0_sels[] = { "ipu1_di0_pre", "dummy", "dummy", "ldb_di0", "ldb_di1", }; | ||
110 | static const char *ipu1_di1_sels[] = { "ipu1_di1_pre", "dummy", "dummy", "ldb_di0", "ldb_di1", }; | ||
111 | static const char *ipu2_di0_sels[] = { "ipu2_di0_pre", "dummy", "dummy", "ldb_di0", "ldb_di1", }; | ||
112 | static const char *ipu2_di1_sels[] = { "ipu2_di1_pre", "dummy", "dummy", "ldb_di0", "ldb_di1", }; | ||
113 | static const char *hsi_tx_sels[] = { "pll3_120m", "pll2_pfd2_396m", }; | ||
114 | static const char *pcie_axi_sels[] = { "axi", "ahb", }; | ||
115 | static const char *ssi_sels[] = { "pll3_pfd2_508m", "pll3_pfd3_454m", "pll4_audio", }; | ||
116 | static const char *usdhc_sels[] = { "pll2_pfd2_396m", "pll2_pfd0_352m", }; | ||
117 | static const char *enfc_sels[] = { "pll2_pfd0_352m", "pll2_bus", "pll3_usb_otg", "pll2_pfd2_396m", }; | ||
118 | static const char *emi_sels[] = { "axi", "pll3_usb_otg", "pll2_pfd2_396m", "pll2_pfd0_352m", }; | ||
119 | static const char *vdo_axi_sels[] = { "axi", "ahb", }; | ||
120 | static const char *vpu_axi_sels[] = { "axi", "pll2_pfd2_396m", "pll2_pfd0_352m", }; | ||
121 | static const char *cko1_sels[] = { "pll3_usb_otg", "pll2_bus", "pll1_sys", "pll5_video", | ||
122 | "dummy", "axi", "enfc", "ipu1_di0", "ipu1_di1", "ipu2_di0", | ||
123 | "ipu2_di1", "ahb", "ipg", "ipg_per", "ckil", "pll4_audio", }; | ||
124 | |||
125 | static const char * const clks_init_on[] __initconst = { | ||
126 | "mmdc_ch0_axi", "mmdc_ch1_axi", "usboh3", | ||
127 | }; | ||
128 | |||
129 | enum mx6q_clks { | ||
130 | dummy, ckil, ckih, osc, pll2_pfd0_352m, pll2_pfd1_594m, pll2_pfd2_396m, | ||
131 | pll3_pfd0_720m, pll3_pfd1_540m, pll3_pfd2_508m, pll3_pfd3_454m, | ||
132 | pll2_198m, pll3_120m, pll3_80m, pll3_60m, twd, step, pll1_sw, | ||
133 | periph_pre, periph2_pre, periph_clk2_sel, periph2_clk2_sel, axi_sel, | ||
134 | esai_sel, asrc_sel, spdif_sel, gpu2d_axi, gpu3d_axi, gpu2d_core_sel, | ||
135 | gpu3d_core_sel, gpu3d_shader_sel, ipu1_sel, ipu2_sel, ldb_di0_sel, | ||
136 | ldb_di1_sel, ipu1_di0_pre_sel, ipu1_di1_pre_sel, ipu2_di0_pre_sel, | ||
137 | ipu2_di1_pre_sel, ipu1_di0_sel, ipu1_di1_sel, ipu2_di0_sel, | ||
138 | ipu2_di1_sel, hsi_tx_sel, pcie_axi_sel, ssi1_sel, ssi2_sel, ssi3_sel, | ||
139 | usdhc1_sel, usdhc2_sel, usdhc3_sel, usdhc4_sel, enfc_sel, emi_sel, | ||
140 | emi_slow_sel, vdo_axi_sel, vpu_axi_sel, cko1_sel, periph, periph2, | ||
141 | periph_clk2, periph2_clk2, ipg, ipg_per, esai_pred, esai_podf, | ||
142 | asrc_pred, asrc_podf, spdif_pred, spdif_podf, can_root, ecspi_root, | ||
143 | gpu2d_core_podf, gpu3d_core_podf, gpu3d_shader, ipu1_podf, ipu2_podf, | ||
144 | ldb_di0_podf, ldb_di1_podf, ipu1_di0_pre, ipu1_di1_pre, ipu2_di0_pre, | ||
145 | ipu2_di1_pre, hsi_tx_podf, ssi1_pred, ssi1_podf, ssi2_pred, ssi2_podf, | ||
146 | ssi3_pred, ssi3_podf, uart_serial_podf, usdhc1_podf, usdhc2_podf, | ||
147 | usdhc3_podf, usdhc4_podf, enfc_pred, enfc_podf, emi_podf, | ||
148 | emi_slow_podf, vpu_axi_podf, cko1_podf, axi, mmdc_ch0_axi_podf, | ||
149 | mmdc_ch1_axi_podf, arm, ahb, apbh_dma, asrc, can1_ipg, can1_serial, | ||
150 | can2_ipg, can2_serial, ecspi1, ecspi2, ecspi3, ecspi4, ecspi5, enet, | ||
151 | esai, gpt_ipg, gpt_ipg_per, gpu2d_core, gpu3d_core, hdmi_iahb, | ||
152 | hdmi_isfr, i2c1, i2c2, i2c3, iim, enfc, ipu1, ipu1_di0, ipu1_di1, ipu2, | ||
153 | ipu2_di0, ldb_di0, ldb_di1, ipu2_di1, hsi_tx, mlb, mmdc_ch0_axi, | ||
154 | mmdc_ch1_axi, ocram, openvg_axi, pcie_axi, pwm1, pwm2, pwm3, pwm4, | ||
155 | gpmi_bch_apb, gpmi_bch, gpmi_io, gpmi_apb, sata, sdma, spba, ssi1, | ||
156 | ssi2, ssi3, uart_ipg, uart_serial, usboh3, usdhc1, usdhc2, usdhc3, | ||
157 | usdhc4, vdo_axi, vpu_axi, cko1, pll1_sys, pll2_bus, pll3_usb_otg, | ||
158 | pll4_audio, pll5_video, pll6_mlb, pll7_usb_host, pll8_enet, clk_max | ||
159 | }; | ||
160 | |||
161 | static struct clk *clk[clk_max]; | ||
162 | |||
163 | int __init mx6q_clocks_init(void) | ||
164 | { | ||
165 | struct device_node *np; | ||
166 | void __iomem *base; | ||
167 | struct clk *c; | ||
168 | int i, irq; | ||
169 | |||
170 | clk[dummy] = imx_clk_fixed("dummy", 0); | ||
171 | |||
172 | /* retrieve the freqency of fixed clocks from device tree */ | ||
173 | for_each_compatible_node(np, NULL, "fixed-clock") { | ||
174 | u32 rate; | ||
175 | if (of_property_read_u32(np, "clock-frequency", &rate)) | ||
176 | continue; | ||
177 | |||
178 | if (of_device_is_compatible(np, "fsl,imx-ckil")) | ||
179 | clk[ckil] = imx_clk_fixed("ckil", rate); | ||
180 | else if (of_device_is_compatible(np, "fsl,imx-ckih1")) | ||
181 | clk[ckih] = imx_clk_fixed("ckih", rate); | ||
182 | else if (of_device_is_compatible(np, "fsl,imx-osc")) | ||
183 | clk[osc] = imx_clk_fixed("osc", rate); | ||
184 | } | ||
185 | |||
186 | np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-anatop"); | ||
187 | base = of_iomap(np, 0); | ||
188 | WARN_ON(!base); | ||
189 | |||
190 | /* type name parent_name base gate_mask div_mask */ | ||
191 | clk[pll1_sys] = imx_clk_pllv3(IMX_PLLV3_SYS, "pll1_sys", "osc", base, 0x2000, 0x7f); | ||
192 | clk[pll2_bus] = imx_clk_pllv3(IMX_PLLV3_GENERIC, "pll2_bus", "osc", base + 0x30, 0x2000, 0x1); | ||
193 | clk[pll3_usb_otg] = imx_clk_pllv3(IMX_PLLV3_USB, "pll3_usb_otg", "osc", base + 0x10, 0x2000, 0x3); | ||
194 | clk[pll4_audio] = imx_clk_pllv3(IMX_PLLV3_AV, "pll4_audio", "osc", base + 0x70, 0x2000, 0x7f); | ||
195 | clk[pll5_video] = imx_clk_pllv3(IMX_PLLV3_AV, "pll5_video", "osc", base + 0xa0, 0x2000, 0x7f); | ||
196 | clk[pll6_mlb] = imx_clk_pllv3(IMX_PLLV3_MLB, "pll6_mlb", "osc", base + 0xd0, 0x2000, 0x0); | ||
197 | clk[pll7_usb_host] = imx_clk_pllv3(IMX_PLLV3_USB, "pll7_usb_host","osc", base + 0x20, 0x2000, 0x3); | ||
198 | clk[pll8_enet] = imx_clk_pllv3(IMX_PLLV3_ENET, "pll8_enet", "osc", base + 0xe0, 0x182000, 0x3); | ||
199 | |||
200 | /* name parent_name reg idx */ | ||
201 | clk[pll2_pfd0_352m] = imx_clk_pfd("pll2_pfd0_352m", "pll2_bus", base + 0x100, 0); | ||
202 | clk[pll2_pfd1_594m] = imx_clk_pfd("pll2_pfd1_594m", "pll2_bus", base + 0x100, 1); | ||
203 | clk[pll2_pfd2_396m] = imx_clk_pfd("pll2_pfd2_396m", "pll2_bus", base + 0x100, 2); | ||
204 | clk[pll3_pfd0_720m] = imx_clk_pfd("pll3_pfd0_720m", "pll3_usb_otg", base + 0xf0, 0); | ||
205 | clk[pll3_pfd1_540m] = imx_clk_pfd("pll3_pfd1_540m", "pll3_usb_otg", base + 0xf0, 1); | ||
206 | clk[pll3_pfd2_508m] = imx_clk_pfd("pll3_pfd2_508m", "pll3_usb_otg", base + 0xf0, 2); | ||
207 | clk[pll3_pfd3_454m] = imx_clk_pfd("pll3_pfd3_454m", "pll3_usb_otg", base + 0xf0, 3); | ||
208 | |||
209 | /* name parent_name mult div */ | ||
210 | clk[pll2_198m] = imx_clk_fixed_factor("pll2_198m", "pll2_pfd2_396m", 1, 2); | ||
211 | clk[pll3_120m] = imx_clk_fixed_factor("pll3_120m", "pll3_usb_otg", 1, 4); | ||
212 | clk[pll3_80m] = imx_clk_fixed_factor("pll3_80m", "pll3_usb_otg", 1, 6); | ||
213 | clk[pll3_60m] = imx_clk_fixed_factor("pll3_60m", "pll3_usb_otg", 1, 8); | ||
214 | clk[twd] = imx_clk_fixed_factor("twd", "arm", 1, 2); | ||
215 | |||
216 | np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-ccm"); | ||
217 | base = of_iomap(np, 0); | ||
218 | WARN_ON(!base); | ||
219 | ccm_base = base; | ||
220 | |||
221 | /* name reg shift width parent_names num_parents */ | ||
222 | clk[step] = imx_clk_mux("step", base + 0xc, 8, 1, step_sels, ARRAY_SIZE(step_sels)); | ||
223 | clk[pll1_sw] = imx_clk_mux("pll1_sw", base + 0xc, 2, 1, pll1_sw_sels, ARRAY_SIZE(pll1_sw_sels)); | ||
224 | clk[periph_pre] = imx_clk_mux("periph_pre", base + 0x18, 18, 2, periph_pre_sels, ARRAY_SIZE(periph_pre_sels)); | ||
225 | clk[periph2_pre] = imx_clk_mux("periph2_pre", base + 0x18, 21, 2, periph_pre_sels, ARRAY_SIZE(periph_pre_sels)); | ||
226 | clk[periph_clk2_sel] = imx_clk_mux("periph_clk2_sel", base + 0x18, 12, 1, periph_clk2_sels, ARRAY_SIZE(periph_clk2_sels)); | ||
227 | clk[periph2_clk2_sel] = imx_clk_mux("periph2_clk2_sel", base + 0x18, 20, 1, periph_clk2_sels, ARRAY_SIZE(periph_clk2_sels)); | ||
228 | clk[axi_sel] = imx_clk_mux("axi_sel", base + 0x14, 6, 2, axi_sels, ARRAY_SIZE(axi_sels)); | ||
229 | clk[esai_sel] = imx_clk_mux("esai_sel", base + 0x20, 19, 2, audio_sels, ARRAY_SIZE(audio_sels)); | ||
230 | clk[asrc_sel] = imx_clk_mux("asrc_sel", base + 0x30, 7, 2, audio_sels, ARRAY_SIZE(audio_sels)); | ||
231 | clk[spdif_sel] = imx_clk_mux("spdif_sel", base + 0x30, 20, 2, audio_sels, ARRAY_SIZE(audio_sels)); | ||
232 | clk[gpu2d_axi] = imx_clk_mux("gpu2d_axi", base + 0x18, 0, 1, gpu_axi_sels, ARRAY_SIZE(gpu_axi_sels)); | ||
233 | clk[gpu3d_axi] = imx_clk_mux("gpu3d_axi", base + 0x18, 1, 1, gpu_axi_sels, ARRAY_SIZE(gpu_axi_sels)); | ||
234 | clk[gpu2d_core_sel] = imx_clk_mux("gpu2d_core_sel", base + 0x18, 16, 2, gpu2d_core_sels, ARRAY_SIZE(gpu2d_core_sels)); | ||
235 | clk[gpu3d_core_sel] = imx_clk_mux("gpu3d_core_sel", base + 0x18, 4, 2, gpu3d_core_sels, ARRAY_SIZE(gpu3d_core_sels)); | ||
236 | clk[gpu3d_shader_sel] = imx_clk_mux("gpu3d_shader_sel", base + 0x18, 8, 2, gpu3d_shader_sels, ARRAY_SIZE(gpu3d_shader_sels)); | ||
237 | clk[ipu1_sel] = imx_clk_mux("ipu1_sel", base + 0x3c, 9, 2, ipu_sels, ARRAY_SIZE(ipu_sels)); | ||
238 | clk[ipu2_sel] = imx_clk_mux("ipu2_sel", base + 0x3c, 14, 2, ipu_sels, ARRAY_SIZE(ipu_sels)); | ||
239 | clk[ldb_di0_sel] = imx_clk_mux("ldb_di0_sel", base + 0x2c, 9, 3, ldb_di_sels, ARRAY_SIZE(ldb_di_sels)); | ||
240 | clk[ldb_di1_sel] = imx_clk_mux("ldb_di1_sel", base + 0x2c, 12, 3, ldb_di_sels, ARRAY_SIZE(ldb_di_sels)); | ||
241 | clk[ipu1_di0_pre_sel] = imx_clk_mux("ipu1_di0_pre_sel", base + 0x34, 6, 3, ipu_di_pre_sels, ARRAY_SIZE(ipu_di_pre_sels)); | ||
242 | clk[ipu1_di1_pre_sel] = imx_clk_mux("ipu1_di1_pre_sel", base + 0x34, 15, 3, ipu_di_pre_sels, ARRAY_SIZE(ipu_di_pre_sels)); | ||
243 | clk[ipu2_di0_pre_sel] = imx_clk_mux("ipu2_di0_pre_sel", base + 0x38, 6, 3, ipu_di_pre_sels, ARRAY_SIZE(ipu_di_pre_sels)); | ||
244 | clk[ipu2_di1_pre_sel] = imx_clk_mux("ipu2_di1_pre_sel", base + 0x38, 15, 3, ipu_di_pre_sels, ARRAY_SIZE(ipu_di_pre_sels)); | ||
245 | clk[ipu1_di0_sel] = imx_clk_mux("ipu1_di0_sel", base + 0x34, 0, 3, ipu1_di0_sels, ARRAY_SIZE(ipu1_di0_sels)); | ||
246 | clk[ipu1_di1_sel] = imx_clk_mux("ipu1_di1_sel", base + 0x34, 9, 3, ipu1_di1_sels, ARRAY_SIZE(ipu1_di1_sels)); | ||
247 | clk[ipu2_di0_sel] = imx_clk_mux("ipu2_di0_sel", base + 0x38, 0, 3, ipu2_di0_sels, ARRAY_SIZE(ipu2_di0_sels)); | ||
248 | clk[ipu2_di1_sel] = imx_clk_mux("ipu2_di1_sel", base + 0x38, 9, 3, ipu2_di1_sels, ARRAY_SIZE(ipu2_di1_sels)); | ||
249 | clk[hsi_tx_sel] = imx_clk_mux("hsi_tx_sel", base + 0x30, 28, 1, hsi_tx_sels, ARRAY_SIZE(hsi_tx_sels)); | ||
250 | clk[pcie_axi_sel] = imx_clk_mux("pcie_axi_sel", base + 0x18, 10, 1, pcie_axi_sels, ARRAY_SIZE(pcie_axi_sels)); | ||
251 | clk[ssi1_sel] = imx_clk_mux("ssi1_sel", base + 0x1c, 10, 2, ssi_sels, ARRAY_SIZE(ssi_sels)); | ||
252 | clk[ssi2_sel] = imx_clk_mux("ssi2_sel", base + 0x1c, 12, 2, ssi_sels, ARRAY_SIZE(ssi_sels)); | ||
253 | clk[ssi3_sel] = imx_clk_mux("ssi3_sel", base + 0x1c, 14, 2, ssi_sels, ARRAY_SIZE(ssi_sels)); | ||
254 | clk[usdhc1_sel] = imx_clk_mux("usdhc1_sel", base + 0x1c, 16, 1, usdhc_sels, ARRAY_SIZE(usdhc_sels)); | ||
255 | clk[usdhc2_sel] = imx_clk_mux("usdhc2_sel", base + 0x1c, 17, 1, usdhc_sels, ARRAY_SIZE(usdhc_sels)); | ||
256 | clk[usdhc3_sel] = imx_clk_mux("usdhc3_sel", base + 0x1c, 18, 1, usdhc_sels, ARRAY_SIZE(usdhc_sels)); | ||
257 | clk[usdhc4_sel] = imx_clk_mux("usdhc4_sel", base + 0x1c, 19, 1, usdhc_sels, ARRAY_SIZE(usdhc_sels)); | ||
258 | clk[enfc_sel] = imx_clk_mux("enfc_sel", base + 0x2c, 16, 2, enfc_sels, ARRAY_SIZE(enfc_sels)); | ||
259 | clk[emi_sel] = imx_clk_mux("emi_sel", base + 0x1c, 27, 2, emi_sels, ARRAY_SIZE(emi_sels)); | ||
260 | clk[emi_slow_sel] = imx_clk_mux("emi_slow_sel", base + 0x1c, 29, 2, emi_sels, ARRAY_SIZE(emi_sels)); | ||
261 | clk[vdo_axi_sel] = imx_clk_mux("vdo_axi_sel", base + 0x18, 11, 1, vdo_axi_sels, ARRAY_SIZE(vdo_axi_sels)); | ||
262 | clk[vpu_axi_sel] = imx_clk_mux("vpu_axi_sel", base + 0x18, 14, 2, vpu_axi_sels, ARRAY_SIZE(vpu_axi_sels)); | ||
263 | clk[cko1_sel] = imx_clk_mux("cko1_sel", base + 0x60, 0, 4, cko1_sels, ARRAY_SIZE(cko1_sels)); | ||
264 | |||
265 | /* name reg shift width busy: reg, shift parent_names num_parents */ | ||
266 | clk[periph] = imx_clk_busy_mux("periph", base + 0x14, 25, 1, base + 0x48, 5, periph_sels, ARRAY_SIZE(periph_sels)); | ||
267 | clk[periph2] = imx_clk_busy_mux("periph2", base + 0x14, 26, 1, base + 0x48, 3, periph2_sels, ARRAY_SIZE(periph2_sels)); | ||
268 | |||
269 | /* name parent_name reg shift width */ | ||
270 | clk[periph_clk2] = imx_clk_divider("periph_clk2", "periph_clk2_sel", base + 0x14, 27, 3); | ||
271 | clk[periph2_clk2] = imx_clk_divider("periph2_clk2", "periph2_clk2_sel", base + 0x14, 0, 3); | ||
272 | clk[ipg] = imx_clk_divider("ipg", "ahb", base + 0x14, 8, 2); | ||
273 | clk[ipg_per] = imx_clk_divider("ipg_per", "ipg", base + 0x1c, 0, 6); | ||
274 | clk[esai_pred] = imx_clk_divider("esai_pred", "esai_sel", base + 0x28, 9, 3); | ||
275 | clk[esai_podf] = imx_clk_divider("esai_podf", "esai_pred", base + 0x28, 25, 3); | ||
276 | clk[asrc_pred] = imx_clk_divider("asrc_pred", "asrc_sel", base + 0x30, 12, 3); | ||
277 | clk[asrc_podf] = imx_clk_divider("asrc_podf", "asrc_pred", base + 0x30, 9, 3); | ||
278 | clk[spdif_pred] = imx_clk_divider("spdif_pred", "spdif_sel", base + 0x30, 25, 3); | ||
279 | clk[spdif_podf] = imx_clk_divider("spdif_podf", "spdif_pred", base + 0x30, 22, 3); | ||
280 | clk[can_root] = imx_clk_divider("can_root", "pll3_usb_otg", base + 0x20, 2, 6); | ||
281 | clk[ecspi_root] = imx_clk_divider("ecspi_root", "pll3_60m", base + 0x38, 19, 6); | ||
282 | clk[gpu2d_core_podf] = imx_clk_divider("gpu2d_core_podf", "gpu2d_core_sel", base + 0x18, 23, 3); | ||
283 | clk[gpu3d_core_podf] = imx_clk_divider("gpu3d_core_podf", "gpu3d_core_sel", base + 0x18, 26, 3); | ||
284 | clk[gpu3d_shader] = imx_clk_divider("gpu3d_shader", "gpu3d_shader_sel", base + 0x18, 29, 3); | ||
285 | clk[ipu1_podf] = imx_clk_divider("ipu1_podf", "ipu1_sel", base + 0x3c, 11, 3); | ||
286 | clk[ipu2_podf] = imx_clk_divider("ipu2_podf", "ipu2_sel", base + 0x3c, 16, 3); | ||
287 | clk[ldb_di0_podf] = imx_clk_divider("ldb_di0_podf", "ldb_di0_sel", base + 0x20, 10, 1); | ||
288 | clk[ldb_di1_podf] = imx_clk_divider("ldb_di1_podf", "ldb_di1_sel", base + 0x20, 11, 1); | ||
289 | clk[ipu1_di0_pre] = imx_clk_divider("ipu1_di0_pre", "ipu1_di0_pre_sel", base + 0x34, 3, 3); | ||
290 | clk[ipu1_di1_pre] = imx_clk_divider("ipu1_di1_pre", "ipu1_di1_pre_sel", base + 0x34, 12, 3); | ||
291 | clk[ipu2_di0_pre] = imx_clk_divider("ipu2_di0_pre", "ipu2_di0_pre_sel", base + 0x38, 3, 3); | ||
292 | clk[ipu2_di1_pre] = imx_clk_divider("ipu2_di1_pre", "ipu2_di1_pre_sel", base + 0x38, 12, 3); | ||
293 | clk[hsi_tx_podf] = imx_clk_divider("hsi_tx_podf", "hsi_tx_sel", base + 0x30, 29, 3); | ||
294 | clk[ssi1_pred] = imx_clk_divider("ssi1_pred", "ssi1_sel", base + 0x28, 6, 3); | ||
295 | clk[ssi1_podf] = imx_clk_divider("ssi1_podf", "ssi1_pred", base + 0x28, 0, 6); | ||
296 | clk[ssi2_pred] = imx_clk_divider("ssi2_pred", "ssi2_sel", base + 0x2c, 6, 3); | ||
297 | clk[ssi2_podf] = imx_clk_divider("ssi2_podf", "ssi2_pred", base + 0x2c, 0, 6); | ||
298 | clk[ssi3_pred] = imx_clk_divider("ssi3_pred", "ssi3_sel", base + 0x28, 22, 3); | ||
299 | clk[ssi3_podf] = imx_clk_divider("ssi3_podf", "ssi3_pred", base + 0x28, 16, 6); | ||
300 | clk[uart_serial_podf] = imx_clk_divider("uart_serial_podf", "pll3_80m", base + 0x24, 0, 6); | ||
301 | clk[usdhc1_podf] = imx_clk_divider("usdhc1_podf", "usdhc1_sel", base + 0x24, 11, 3); | ||
302 | clk[usdhc2_podf] = imx_clk_divider("usdhc2_podf", "usdhc2_sel", base + 0x24, 16, 3); | ||
303 | clk[usdhc3_podf] = imx_clk_divider("usdhc3_podf", "usdhc3_sel", base + 0x24, 19, 3); | ||
304 | clk[usdhc4_podf] = imx_clk_divider("usdhc4_podf", "usdhc4_sel", base + 0x24, 22, 3); | ||
305 | clk[enfc_pred] = imx_clk_divider("enfc_pred", "enfc_sel", base + 0x2c, 18, 3); | ||
306 | clk[enfc_podf] = imx_clk_divider("enfc_podf", "enfc_pred", base + 0x2c, 21, 6); | ||
307 | clk[emi_podf] = imx_clk_divider("emi_podf", "emi_sel", base + 0x1c, 20, 3); | ||
308 | clk[emi_slow_podf] = imx_clk_divider("emi_slow_podf", "emi_slow_sel", base + 0x1c, 23, 3); | ||
309 | clk[vpu_axi_podf] = imx_clk_divider("vpu_axi_podf", "vpu_axi_sel", base + 0x24, 25, 3); | ||
310 | clk[cko1_podf] = imx_clk_divider("cko1_podf", "cko1_sel", base + 0x60, 4, 3); | ||
311 | |||
312 | /* name parent_name reg shift width busy: reg, shift */ | ||
313 | clk[axi] = imx_clk_busy_divider("axi", "axi_sel", base + 0x14, 16, 3, base + 0x48, 0); | ||
314 | clk[mmdc_ch0_axi_podf] = imx_clk_busy_divider("mmdc_ch0_axi_podf", "periph", base + 0x14, 19, 3, base + 0x48, 4); | ||
315 | clk[mmdc_ch1_axi_podf] = imx_clk_busy_divider("mmdc_ch1_axi_podf", "periph2", base + 0x14, 3, 3, base + 0x48, 2); | ||
316 | clk[arm] = imx_clk_busy_divider("arm", "pll1_sw", base + 0x10, 0, 3, base + 0x48, 16); | ||
317 | clk[ahb] = imx_clk_busy_divider("ahb", "periph", base + 0x14, 10, 3, base + 0x48, 1); | ||
318 | |||
319 | /* name parent_name reg shift */ | ||
320 | clk[apbh_dma] = imx_clk_gate2("apbh_dma", "ahb", base + 0x68, 4); | ||
321 | clk[asrc] = imx_clk_gate2("asrc", "asrc_podf", base + 0x68, 6); | ||
322 | clk[can1_ipg] = imx_clk_gate2("can1_ipg", "ipg", base + 0x68, 14); | ||
323 | clk[can1_serial] = imx_clk_gate2("can1_serial", "can_root", base + 0x68, 16); | ||
324 | clk[can2_ipg] = imx_clk_gate2("can2_ipg", "ipg", base + 0x68, 18); | ||
325 | clk[can2_serial] = imx_clk_gate2("can2_serial", "can_root", base + 0x68, 20); | ||
326 | clk[ecspi1] = imx_clk_gate2("ecspi1", "ecspi_root", base + 0x6c, 0); | ||
327 | clk[ecspi2] = imx_clk_gate2("ecspi2", "ecspi_root", base + 0x6c, 2); | ||
328 | clk[ecspi3] = imx_clk_gate2("ecspi3", "ecspi_root", base + 0x6c, 4); | ||
329 | clk[ecspi4] = imx_clk_gate2("ecspi4", "ecspi_root", base + 0x6c, 6); | ||
330 | clk[ecspi5] = imx_clk_gate2("ecspi5", "ecspi_root", base + 0x6c, 8); | ||
331 | clk[enet] = imx_clk_gate2("enet", "ipg", base + 0x6c, 10); | ||
332 | clk[esai] = imx_clk_gate2("esai", "esai_podf", base + 0x6c, 16); | ||
333 | clk[gpt_ipg] = imx_clk_gate2("gpt_ipg", "ipg", base + 0x6c, 20); | ||
334 | clk[gpt_ipg_per] = imx_clk_gate2("gpt_ipg_per", "ipg_per", base + 0x6c, 22); | ||
335 | clk[gpu2d_core] = imx_clk_gate2("gpu2d_core", "gpu2d_core_podf", base + 0x6c, 24); | ||
336 | clk[gpu3d_core] = imx_clk_gate2("gpu3d_core", "gpu3d_core_podf", base + 0x6c, 26); | ||
337 | clk[hdmi_iahb] = imx_clk_gate2("hdmi_iahb", "ahb", base + 0x70, 0); | ||
338 | clk[hdmi_isfr] = imx_clk_gate2("hdmi_isfr", "pll3_pfd1_540m", base + 0x70, 4); | ||
339 | clk[i2c1] = imx_clk_gate2("i2c1", "ipg_per", base + 0x70, 6); | ||
340 | clk[i2c2] = imx_clk_gate2("i2c2", "ipg_per", base + 0x70, 8); | ||
341 | clk[i2c3] = imx_clk_gate2("i2c3", "ipg_per", base + 0x70, 10); | ||
342 | clk[iim] = imx_clk_gate2("iim", "ipg", base + 0x70, 12); | ||
343 | clk[enfc] = imx_clk_gate2("enfc", "enfc_podf", base + 0x70, 14); | ||
344 | clk[ipu1] = imx_clk_gate2("ipu1", "ipu1_podf", base + 0x74, 0); | ||
345 | clk[ipu1_di0] = imx_clk_gate2("ipu1_di0", "ipu1_di0_sel", base + 0x74, 2); | ||
346 | clk[ipu1_di1] = imx_clk_gate2("ipu1_di1", "ipu1_di1_sel", base + 0x74, 4); | ||
347 | clk[ipu2] = imx_clk_gate2("ipu2", "ipu2_podf", base + 0x74, 6); | ||
348 | clk[ipu2_di0] = imx_clk_gate2("ipu2_di0", "ipu2_di0_sel", base + 0x74, 8); | ||
349 | clk[ldb_di0] = imx_clk_gate2("ldb_di0", "ldb_di0_podf", base + 0x74, 12); | ||
350 | clk[ldb_di1] = imx_clk_gate2("ldb_di1", "ldb_di1_podf", base + 0x74, 14); | ||
351 | clk[ipu2_di1] = imx_clk_gate2("ipu2_di1", "ipu2_di1_sel", base + 0x74, 10); | ||
352 | clk[hsi_tx] = imx_clk_gate2("hsi_tx", "hsi_tx_podf", base + 0x74, 16); | ||
353 | clk[mlb] = imx_clk_gate2("mlb", "pll6_mlb", base + 0x74, 18); | ||
354 | clk[mmdc_ch0_axi] = imx_clk_gate2("mmdc_ch0_axi", "mmdc_ch0_axi_podf", base + 0x74, 20); | ||
355 | clk[mmdc_ch1_axi] = imx_clk_gate2("mmdc_ch1_axi", "mmdc_ch1_axi_podf", base + 0x74, 22); | ||
356 | clk[ocram] = imx_clk_gate2("ocram", "ahb", base + 0x74, 28); | ||
357 | clk[openvg_axi] = imx_clk_gate2("openvg_axi", "axi", base + 0x74, 30); | ||
358 | clk[pcie_axi] = imx_clk_gate2("pcie_axi", "pcie_axi_sel", base + 0x78, 0); | ||
359 | clk[pwm1] = imx_clk_gate2("pwm1", "ipg_per", base + 0x78, 16); | ||
360 | clk[pwm2] = imx_clk_gate2("pwm2", "ipg_per", base + 0x78, 18); | ||
361 | clk[pwm3] = imx_clk_gate2("pwm3", "ipg_per", base + 0x78, 20); | ||
362 | clk[pwm4] = imx_clk_gate2("pwm4", "ipg_per", base + 0x78, 22); | ||
363 | clk[gpmi_bch_apb] = imx_clk_gate2("gpmi_bch_apb", "usdhc3", base + 0x78, 24); | ||
364 | clk[gpmi_bch] = imx_clk_gate2("gpmi_bch", "usdhc4", base + 0x78, 26); | ||
365 | clk[gpmi_io] = imx_clk_gate2("gpmi_io", "enfc", base + 0x78, 28); | ||
366 | clk[gpmi_apb] = imx_clk_gate2("gpmi_apb", "usdhc3", base + 0x78, 30); | ||
367 | clk[sata] = imx_clk_gate2("sata", "ipg", base + 0x7c, 4); | ||
368 | clk[sdma] = imx_clk_gate2("sdma", "ahb", base + 0x7c, 6); | ||
369 | clk[spba] = imx_clk_gate2("spba", "ipg", base + 0x7c, 12); | ||
370 | clk[ssi1] = imx_clk_gate2("ssi1", "ssi1_podf", base + 0x7c, 18); | ||
371 | clk[ssi2] = imx_clk_gate2("ssi2", "ssi2_podf", base + 0x7c, 20); | ||
372 | clk[ssi3] = imx_clk_gate2("ssi3", "ssi3_podf", base + 0x7c, 22); | ||
373 | clk[uart_ipg] = imx_clk_gate2("uart_ipg", "ipg", base + 0x7c, 24); | ||
374 | clk[uart_serial] = imx_clk_gate2("uart_serial", "uart_serial_podf", base + 0x7c, 26); | ||
375 | clk[usboh3] = imx_clk_gate2("usboh3", "ipg", base + 0x80, 0); | ||
376 | clk[usdhc1] = imx_clk_gate2("usdhc1", "usdhc1_podf", base + 0x80, 2); | ||
377 | clk[usdhc2] = imx_clk_gate2("usdhc2", "usdhc2_podf", base + 0x80, 4); | ||
378 | clk[usdhc3] = imx_clk_gate2("usdhc3", "usdhc3_podf", base + 0x80, 6); | ||
379 | clk[usdhc4] = imx_clk_gate2("usdhc4", "usdhc4_podf", base + 0x80, 8); | ||
380 | clk[vdo_axi] = imx_clk_gate2("vdo_axi", "vdo_axi_sel", base + 0x80, 12); | ||
381 | clk[vpu_axi] = imx_clk_gate2("vpu_axi", "vpu_axi_podf", base + 0x80, 14); | ||
382 | clk[cko1] = imx_clk_gate("cko1", "cko1_podf", base + 0x60, 7); | ||
383 | |||
384 | for (i = 0; i < ARRAY_SIZE(clk); i++) | ||
385 | if (IS_ERR(clk[i])) | ||
386 | pr_err("i.MX6q clk %d: register failed with %ld\n", | ||
387 | i, PTR_ERR(clk[i])); | ||
388 | |||
389 | clk_register_clkdev(clk[mmdc_ch0_axi], NULL, "mmdc_ch0_axi"); | ||
390 | clk_register_clkdev(clk[mmdc_ch1_axi], NULL, "mmdc_ch1_axi"); | ||
391 | clk_register_clkdev(clk[gpt_ipg], "ipg", "imx-gpt.0"); | ||
392 | clk_register_clkdev(clk[gpt_ipg_per], "per", "imx-gpt.0"); | ||
393 | clk_register_clkdev(clk[twd], NULL, "smp_twd"); | ||
394 | clk_register_clkdev(clk[usboh3], NULL, "usboh3"); | ||
395 | clk_register_clkdev(clk[uart_serial], "per", "2020000.uart"); | ||
396 | clk_register_clkdev(clk[uart_ipg], "ipg", "2020000.uart"); | ||
397 | clk_register_clkdev(clk[uart_serial], "per", "21e8000.uart"); | ||
398 | clk_register_clkdev(clk[uart_ipg], "ipg", "21e8000.uart"); | ||
399 | clk_register_clkdev(clk[uart_serial], "per", "21ec000.uart"); | ||
400 | clk_register_clkdev(clk[uart_ipg], "ipg", "21ec000.uart"); | ||
401 | clk_register_clkdev(clk[uart_serial], "per", "21f0000.uart"); | ||
402 | clk_register_clkdev(clk[uart_ipg], "ipg", "21f0000.uart"); | ||
403 | clk_register_clkdev(clk[uart_serial], "per", "21f4000.uart"); | ||
404 | clk_register_clkdev(clk[uart_ipg], "ipg", "21f4000.uart"); | ||
405 | clk_register_clkdev(clk[enet], NULL, "2188000.enet"); | ||
406 | clk_register_clkdev(clk[usdhc1], NULL, "2190000.usdhc"); | ||
407 | clk_register_clkdev(clk[usdhc2], NULL, "2194000.usdhc"); | ||
408 | clk_register_clkdev(clk[usdhc3], NULL, "2198000.usdhc"); | ||
409 | clk_register_clkdev(clk[usdhc4], NULL, "219c000.usdhc"); | ||
410 | clk_register_clkdev(clk[i2c1], NULL, "21a0000.i2c"); | ||
411 | clk_register_clkdev(clk[i2c2], NULL, "21a4000.i2c"); | ||
412 | clk_register_clkdev(clk[i2c3], NULL, "21a8000.i2c"); | ||
413 | clk_register_clkdev(clk[ecspi1], NULL, "2008000.ecspi"); | ||
414 | clk_register_clkdev(clk[ecspi2], NULL, "200c000.ecspi"); | ||
415 | clk_register_clkdev(clk[ecspi3], NULL, "2010000.ecspi"); | ||
416 | clk_register_clkdev(clk[ecspi4], NULL, "2014000.ecspi"); | ||
417 | clk_register_clkdev(clk[ecspi5], NULL, "2018000.ecspi"); | ||
418 | clk_register_clkdev(clk[sdma], NULL, "20ec000.sdma"); | ||
419 | clk_register_clkdev(clk[dummy], NULL, "20bc000.wdog"); | ||
420 | clk_register_clkdev(clk[dummy], NULL, "20c0000.wdog"); | ||
421 | |||
422 | for (i = 0; i < ARRAY_SIZE(clks_init_on); i++) { | ||
423 | c = clk_get_sys(clks_init_on[i], NULL); | ||
424 | if (IS_ERR(c)) { | ||
425 | pr_err("%s: failed to get clk %s", __func__, | ||
426 | clks_init_on[i]); | ||
427 | return PTR_ERR(c); | ||
428 | } | ||
429 | clk_prepare_enable(c); | ||
430 | } | ||
431 | |||
432 | np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-gpt"); | ||
433 | base = of_iomap(np, 0); | ||
434 | WARN_ON(!base); | ||
435 | irq = irq_of_parse_and_map(np, 0); | ||
436 | mxc_timer_init(NULL, base, irq); | ||
437 | |||
438 | return 0; | ||
439 | } | ||
diff --git a/arch/arm/mach-imx/clk-pfd.c b/arch/arm/mach-imx/clk-pfd.c new file mode 100644 index 000000000000..e2ed4160f329 --- /dev/null +++ b/arch/arm/mach-imx/clk-pfd.c | |||
@@ -0,0 +1,147 @@ | |||
1 | /* | ||
2 | * Copyright 2012 Freescale Semiconductor, Inc. | ||
3 | * Copyright 2012 Linaro Ltd. | ||
4 | * | ||
5 | * The code contained herein is licensed under the GNU General Public | ||
6 | * License. You may obtain a copy of the GNU General Public License | ||
7 | * Version 2 or later at the following locations: | ||
8 | * | ||
9 | * http://www.opensource.org/licenses/gpl-license.html | ||
10 | * http://www.gnu.org/copyleft/gpl.html | ||
11 | */ | ||
12 | |||
13 | #include <linux/clk.h> | ||
14 | #include <linux/clk-provider.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/slab.h> | ||
17 | #include <linux/err.h> | ||
18 | #include "clk.h" | ||
19 | |||
20 | /** | ||
21 | * struct clk_pfd - IMX PFD clock | ||
22 | * @clk_hw: clock source | ||
23 | * @reg: PFD register address | ||
24 | * @idx: the index of PFD encoded in the register | ||
25 | * | ||
26 | * PFD clock found on i.MX6 series. Each register for PFD has 4 clk_pfd | ||
27 | * data encoded, and member idx is used to specify the one. And each | ||
28 | * register has SET, CLR and TOG registers at offset 0x4 0x8 and 0xc. | ||
29 | */ | ||
30 | struct clk_pfd { | ||
31 | struct clk_hw hw; | ||
32 | void __iomem *reg; | ||
33 | u8 idx; | ||
34 | }; | ||
35 | |||
36 | #define to_clk_pfd(_hw) container_of(_hw, struct clk_pfd, hw) | ||
37 | |||
38 | #define SET 0x4 | ||
39 | #define CLR 0x8 | ||
40 | #define OTG 0xc | ||
41 | |||
42 | static int clk_pfd_enable(struct clk_hw *hw) | ||
43 | { | ||
44 | struct clk_pfd *pfd = to_clk_pfd(hw); | ||
45 | |||
46 | writel_relaxed(1 << ((pfd->idx + 1) * 8 - 1), pfd->reg + CLR); | ||
47 | |||
48 | return 0; | ||
49 | } | ||
50 | |||
51 | static void clk_pfd_disable(struct clk_hw *hw) | ||
52 | { | ||
53 | struct clk_pfd *pfd = to_clk_pfd(hw); | ||
54 | |||
55 | writel_relaxed(1 << ((pfd->idx + 1) * 8 - 1), pfd->reg + SET); | ||
56 | } | ||
57 | |||
58 | static unsigned long clk_pfd_recalc_rate(struct clk_hw *hw, | ||
59 | unsigned long parent_rate) | ||
60 | { | ||
61 | struct clk_pfd *pfd = to_clk_pfd(hw); | ||
62 | u64 tmp = parent_rate; | ||
63 | u8 frac = (readl_relaxed(pfd->reg) >> (pfd->idx * 8)) & 0x3f; | ||
64 | |||
65 | tmp *= 18; | ||
66 | do_div(tmp, frac); | ||
67 | |||
68 | return tmp; | ||
69 | } | ||
70 | |||
71 | static long clk_pfd_round_rate(struct clk_hw *hw, unsigned long rate, | ||
72 | unsigned long *prate) | ||
73 | { | ||
74 | u64 tmp = *prate; | ||
75 | u8 frac; | ||
76 | |||
77 | tmp = tmp * 18 + rate / 2; | ||
78 | do_div(tmp, rate); | ||
79 | frac = tmp; | ||
80 | if (frac < 12) | ||
81 | frac = 12; | ||
82 | else if (frac > 35) | ||
83 | frac = 35; | ||
84 | tmp = *prate; | ||
85 | tmp *= 18; | ||
86 | do_div(tmp, frac); | ||
87 | |||
88 | return tmp; | ||
89 | } | ||
90 | |||
91 | static int clk_pfd_set_rate(struct clk_hw *hw, unsigned long rate, | ||
92 | unsigned long parent_rate) | ||
93 | { | ||
94 | struct clk_pfd *pfd = to_clk_pfd(hw); | ||
95 | u64 tmp = parent_rate; | ||
96 | u8 frac; | ||
97 | |||
98 | tmp = tmp * 18 + rate / 2; | ||
99 | do_div(tmp, rate); | ||
100 | frac = tmp; | ||
101 | if (frac < 12) | ||
102 | frac = 12; | ||
103 | else if (frac > 35) | ||
104 | frac = 35; | ||
105 | |||
106 | writel_relaxed(0x3f << (pfd->idx * 8), pfd->reg + CLR); | ||
107 | writel_relaxed(frac << (pfd->idx * 8), pfd->reg + SET); | ||
108 | |||
109 | return 0; | ||
110 | } | ||
111 | |||
112 | static const struct clk_ops clk_pfd_ops = { | ||
113 | .enable = clk_pfd_enable, | ||
114 | .disable = clk_pfd_disable, | ||
115 | .recalc_rate = clk_pfd_recalc_rate, | ||
116 | .round_rate = clk_pfd_round_rate, | ||
117 | .set_rate = clk_pfd_set_rate, | ||
118 | }; | ||
119 | |||
120 | struct clk *imx_clk_pfd(const char *name, const char *parent_name, | ||
121 | void __iomem *reg, u8 idx) | ||
122 | { | ||
123 | struct clk_pfd *pfd; | ||
124 | struct clk *clk; | ||
125 | struct clk_init_data init; | ||
126 | |||
127 | pfd = kzalloc(sizeof(*pfd), GFP_KERNEL); | ||
128 | if (!pfd) | ||
129 | return ERR_PTR(-ENOMEM); | ||
130 | |||
131 | pfd->reg = reg; | ||
132 | pfd->idx = idx; | ||
133 | |||
134 | init.name = name; | ||
135 | init.ops = &clk_pfd_ops; | ||
136 | init.flags = 0; | ||
137 | init.parent_names = &parent_name; | ||
138 | init.num_parents = 1; | ||
139 | |||
140 | pfd->hw.init = &init; | ||
141 | |||
142 | clk = clk_register(NULL, &pfd->hw); | ||
143 | if (IS_ERR(clk)) | ||
144 | kfree(pfd); | ||
145 | |||
146 | return clk; | ||
147 | } | ||
diff --git a/arch/arm/mach-imx/clk-pllv1.c b/arch/arm/mach-imx/clk-pllv1.c new file mode 100644 index 000000000000..2d856f9ccf59 --- /dev/null +++ b/arch/arm/mach-imx/clk-pllv1.c | |||
@@ -0,0 +1,66 @@ | |||
1 | #include <linux/clk.h> | ||
2 | #include <linux/clk-provider.h> | ||
3 | #include <linux/io.h> | ||
4 | #include <linux/slab.h> | ||
5 | #include <linux/kernel.h> | ||
6 | #include <linux/err.h> | ||
7 | #include <mach/common.h> | ||
8 | #include <mach/hardware.h> | ||
9 | #include <mach/clock.h> | ||
10 | #include "clk.h" | ||
11 | |||
12 | /** | ||
13 | * pll v1 | ||
14 | * | ||
15 | * @clk_hw clock source | ||
16 | * @parent the parent clock name | ||
17 | * @base base address of pll registers | ||
18 | * | ||
19 | * PLL clock version 1, found on i.MX1/21/25/27/31/35 | ||
20 | */ | ||
21 | struct clk_pllv1 { | ||
22 | struct clk_hw hw; | ||
23 | void __iomem *base; | ||
24 | }; | ||
25 | |||
26 | #define to_clk_pllv1(clk) (container_of(clk, struct clk_pllv1, clk)) | ||
27 | |||
28 | static unsigned long clk_pllv1_recalc_rate(struct clk_hw *hw, | ||
29 | unsigned long parent_rate) | ||
30 | { | ||
31 | struct clk_pllv1 *pll = to_clk_pllv1(hw); | ||
32 | |||
33 | return mxc_decode_pll(readl(pll->base), parent_rate); | ||
34 | } | ||
35 | |||
36 | struct clk_ops clk_pllv1_ops = { | ||
37 | .recalc_rate = clk_pllv1_recalc_rate, | ||
38 | }; | ||
39 | |||
40 | struct clk *imx_clk_pllv1(const char *name, const char *parent, | ||
41 | void __iomem *base) | ||
42 | { | ||
43 | struct clk_pllv1 *pll; | ||
44 | struct clk *clk; | ||
45 | struct clk_init_data init; | ||
46 | |||
47 | pll = kmalloc(sizeof(*pll), GFP_KERNEL); | ||
48 | if (!pll) | ||
49 | return ERR_PTR(-ENOMEM); | ||
50 | |||
51 | pll->base = base; | ||
52 | |||
53 | init.name = name; | ||
54 | init.ops = &clk_pllv1_ops; | ||
55 | init.flags = 0; | ||
56 | init.parent_names = &parent; | ||
57 | init.num_parents = 1; | ||
58 | |||
59 | pll->hw.init = &init; | ||
60 | |||
61 | clk = clk_register(NULL, &pll->hw); | ||
62 | if (IS_ERR(clk)) | ||
63 | kfree(pll); | ||
64 | |||
65 | return clk; | ||
66 | } | ||
diff --git a/arch/arm/mach-imx/clk-pllv2.c b/arch/arm/mach-imx/clk-pllv2.c new file mode 100644 index 000000000000..4685919deb63 --- /dev/null +++ b/arch/arm/mach-imx/clk-pllv2.c | |||
@@ -0,0 +1,249 @@ | |||
1 | #include <linux/kernel.h> | ||
2 | #include <linux/clk.h> | ||
3 | #include <linux/io.h> | ||
4 | #include <linux/errno.h> | ||
5 | #include <linux/delay.h> | ||
6 | #include <linux/slab.h> | ||
7 | #include <linux/err.h> | ||
8 | |||
9 | #include <asm/div64.h> | ||
10 | |||
11 | #include "clk.h" | ||
12 | |||
13 | #define to_clk_pllv2(clk) (container_of(clk, struct clk_pllv2, clk)) | ||
14 | |||
15 | /* PLL Register Offsets */ | ||
16 | #define MXC_PLL_DP_CTL 0x00 | ||
17 | #define MXC_PLL_DP_CONFIG 0x04 | ||
18 | #define MXC_PLL_DP_OP 0x08 | ||
19 | #define MXC_PLL_DP_MFD 0x0C | ||
20 | #define MXC_PLL_DP_MFN 0x10 | ||
21 | #define MXC_PLL_DP_MFNMINUS 0x14 | ||
22 | #define MXC_PLL_DP_MFNPLUS 0x18 | ||
23 | #define MXC_PLL_DP_HFS_OP 0x1C | ||
24 | #define MXC_PLL_DP_HFS_MFD 0x20 | ||
25 | #define MXC_PLL_DP_HFS_MFN 0x24 | ||
26 | #define MXC_PLL_DP_MFN_TOGC 0x28 | ||
27 | #define MXC_PLL_DP_DESTAT 0x2c | ||
28 | |||
29 | /* PLL Register Bit definitions */ | ||
30 | #define MXC_PLL_DP_CTL_MUL_CTRL 0x2000 | ||
31 | #define MXC_PLL_DP_CTL_DPDCK0_2_EN 0x1000 | ||
32 | #define MXC_PLL_DP_CTL_DPDCK0_2_OFFSET 12 | ||
33 | #define MXC_PLL_DP_CTL_ADE 0x800 | ||
34 | #define MXC_PLL_DP_CTL_REF_CLK_DIV 0x400 | ||
35 | #define MXC_PLL_DP_CTL_REF_CLK_SEL_MASK (3 << 8) | ||
36 | #define MXC_PLL_DP_CTL_REF_CLK_SEL_OFFSET 8 | ||
37 | #define MXC_PLL_DP_CTL_HFSM 0x80 | ||
38 | #define MXC_PLL_DP_CTL_PRE 0x40 | ||
39 | #define MXC_PLL_DP_CTL_UPEN 0x20 | ||
40 | #define MXC_PLL_DP_CTL_RST 0x10 | ||
41 | #define MXC_PLL_DP_CTL_RCP 0x8 | ||
42 | #define MXC_PLL_DP_CTL_PLM 0x4 | ||
43 | #define MXC_PLL_DP_CTL_BRM0 0x2 | ||
44 | #define MXC_PLL_DP_CTL_LRF 0x1 | ||
45 | |||
46 | #define MXC_PLL_DP_CONFIG_BIST 0x8 | ||
47 | #define MXC_PLL_DP_CONFIG_SJC_CE 0x4 | ||
48 | #define MXC_PLL_DP_CONFIG_AREN 0x2 | ||
49 | #define MXC_PLL_DP_CONFIG_LDREQ 0x1 | ||
50 | |||
51 | #define MXC_PLL_DP_OP_MFI_OFFSET 4 | ||
52 | #define MXC_PLL_DP_OP_MFI_MASK (0xF << 4) | ||
53 | #define MXC_PLL_DP_OP_PDF_OFFSET 0 | ||
54 | #define MXC_PLL_DP_OP_PDF_MASK 0xF | ||
55 | |||
56 | #define MXC_PLL_DP_MFD_OFFSET 0 | ||
57 | #define MXC_PLL_DP_MFD_MASK 0x07FFFFFF | ||
58 | |||
59 | #define MXC_PLL_DP_MFN_OFFSET 0x0 | ||
60 | #define MXC_PLL_DP_MFN_MASK 0x07FFFFFF | ||
61 | |||
62 | #define MXC_PLL_DP_MFN_TOGC_TOG_DIS (1 << 17) | ||
63 | #define MXC_PLL_DP_MFN_TOGC_TOG_EN (1 << 16) | ||
64 | #define MXC_PLL_DP_MFN_TOGC_CNT_OFFSET 0x0 | ||
65 | #define MXC_PLL_DP_MFN_TOGC_CNT_MASK 0xFFFF | ||
66 | |||
67 | #define MXC_PLL_DP_DESTAT_TOG_SEL (1 << 31) | ||
68 | #define MXC_PLL_DP_DESTAT_MFN 0x07FFFFFF | ||
69 | |||
70 | #define MAX_DPLL_WAIT_TRIES 1000 /* 1000 * udelay(1) = 1ms */ | ||
71 | |||
72 | struct clk_pllv2 { | ||
73 | struct clk_hw hw; | ||
74 | void __iomem *base; | ||
75 | }; | ||
76 | |||
77 | static unsigned long clk_pllv2_recalc_rate(struct clk_hw *hw, | ||
78 | unsigned long parent_rate) | ||
79 | { | ||
80 | long mfi, mfn, mfd, pdf, ref_clk, mfn_abs; | ||
81 | unsigned long dp_op, dp_mfd, dp_mfn, dp_ctl, pll_hfsm, dbl; | ||
82 | void __iomem *pllbase; | ||
83 | s64 temp; | ||
84 | struct clk_pllv2 *pll = to_clk_pllv2(hw); | ||
85 | |||
86 | pllbase = pll->base; | ||
87 | |||
88 | dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL); | ||
89 | pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM; | ||
90 | dbl = dp_ctl & MXC_PLL_DP_CTL_DPDCK0_2_EN; | ||
91 | |||
92 | if (pll_hfsm == 0) { | ||
93 | dp_op = __raw_readl(pllbase + MXC_PLL_DP_OP); | ||
94 | dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_MFD); | ||
95 | dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_MFN); | ||
96 | } else { | ||
97 | dp_op = __raw_readl(pllbase + MXC_PLL_DP_HFS_OP); | ||
98 | dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFD); | ||
99 | dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFN); | ||
100 | } | ||
101 | pdf = dp_op & MXC_PLL_DP_OP_PDF_MASK; | ||
102 | mfi = (dp_op & MXC_PLL_DP_OP_MFI_MASK) >> MXC_PLL_DP_OP_MFI_OFFSET; | ||
103 | mfi = (mfi <= 5) ? 5 : mfi; | ||
104 | mfd = dp_mfd & MXC_PLL_DP_MFD_MASK; | ||
105 | mfn = mfn_abs = dp_mfn & MXC_PLL_DP_MFN_MASK; | ||
106 | /* Sign extend to 32-bits */ | ||
107 | if (mfn >= 0x04000000) { | ||
108 | mfn |= 0xFC000000; | ||
109 | mfn_abs = -mfn; | ||
110 | } | ||
111 | |||
112 | ref_clk = 2 * parent_rate; | ||
113 | if (dbl != 0) | ||
114 | ref_clk *= 2; | ||
115 | |||
116 | ref_clk /= (pdf + 1); | ||
117 | temp = (u64) ref_clk * mfn_abs; | ||
118 | do_div(temp, mfd + 1); | ||
119 | if (mfn < 0) | ||
120 | temp = -temp; | ||
121 | temp = (ref_clk * mfi) + temp; | ||
122 | |||
123 | return temp; | ||
124 | } | ||
125 | |||
126 | static int clk_pllv2_set_rate(struct clk_hw *hw, unsigned long rate, | ||
127 | unsigned long parent_rate) | ||
128 | { | ||
129 | struct clk_pllv2 *pll = to_clk_pllv2(hw); | ||
130 | u32 reg; | ||
131 | void __iomem *pllbase; | ||
132 | long mfi, pdf, mfn, mfd = 999999; | ||
133 | s64 temp64; | ||
134 | unsigned long quad_parent_rate; | ||
135 | unsigned long pll_hfsm, dp_ctl; | ||
136 | |||
137 | pllbase = pll->base; | ||
138 | |||
139 | quad_parent_rate = 4 * parent_rate; | ||
140 | pdf = mfi = -1; | ||
141 | while (++pdf < 16 && mfi < 5) | ||
142 | mfi = rate * (pdf+1) / quad_parent_rate; | ||
143 | if (mfi > 15) | ||
144 | return -EINVAL; | ||
145 | pdf--; | ||
146 | |||
147 | temp64 = rate * (pdf+1) - quad_parent_rate * mfi; | ||
148 | do_div(temp64, quad_parent_rate/1000000); | ||
149 | mfn = (long)temp64; | ||
150 | |||
151 | dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL); | ||
152 | /* use dpdck0_2 */ | ||
153 | __raw_writel(dp_ctl | 0x1000L, pllbase + MXC_PLL_DP_CTL); | ||
154 | pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM; | ||
155 | if (pll_hfsm == 0) { | ||
156 | reg = mfi << 4 | pdf; | ||
157 | __raw_writel(reg, pllbase + MXC_PLL_DP_OP); | ||
158 | __raw_writel(mfd, pllbase + MXC_PLL_DP_MFD); | ||
159 | __raw_writel(mfn, pllbase + MXC_PLL_DP_MFN); | ||
160 | } else { | ||
161 | reg = mfi << 4 | pdf; | ||
162 | __raw_writel(reg, pllbase + MXC_PLL_DP_HFS_OP); | ||
163 | __raw_writel(mfd, pllbase + MXC_PLL_DP_HFS_MFD); | ||
164 | __raw_writel(mfn, pllbase + MXC_PLL_DP_HFS_MFN); | ||
165 | } | ||
166 | |||
167 | return 0; | ||
168 | } | ||
169 | |||
170 | static long clk_pllv2_round_rate(struct clk_hw *hw, unsigned long rate, | ||
171 | unsigned long *prate) | ||
172 | { | ||
173 | return rate; | ||
174 | } | ||
175 | |||
176 | static int clk_pllv2_prepare(struct clk_hw *hw) | ||
177 | { | ||
178 | struct clk_pllv2 *pll = to_clk_pllv2(hw); | ||
179 | u32 reg; | ||
180 | void __iomem *pllbase; | ||
181 | int i = 0; | ||
182 | |||
183 | pllbase = pll->base; | ||
184 | reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) | MXC_PLL_DP_CTL_UPEN; | ||
185 | __raw_writel(reg, pllbase + MXC_PLL_DP_CTL); | ||
186 | |||
187 | /* Wait for lock */ | ||
188 | do { | ||
189 | reg = __raw_readl(pllbase + MXC_PLL_DP_CTL); | ||
190 | if (reg & MXC_PLL_DP_CTL_LRF) | ||
191 | break; | ||
192 | |||
193 | udelay(1); | ||
194 | } while (++i < MAX_DPLL_WAIT_TRIES); | ||
195 | |||
196 | if (i == MAX_DPLL_WAIT_TRIES) { | ||
197 | pr_err("MX5: pll locking failed\n"); | ||
198 | return -EINVAL; | ||
199 | } | ||
200 | |||
201 | return 0; | ||
202 | } | ||
203 | |||
204 | static void clk_pllv2_unprepare(struct clk_hw *hw) | ||
205 | { | ||
206 | struct clk_pllv2 *pll = to_clk_pllv2(hw); | ||
207 | u32 reg; | ||
208 | void __iomem *pllbase; | ||
209 | |||
210 | pllbase = pll->base; | ||
211 | reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) & ~MXC_PLL_DP_CTL_UPEN; | ||
212 | __raw_writel(reg, pllbase + MXC_PLL_DP_CTL); | ||
213 | } | ||
214 | |||
215 | struct clk_ops clk_pllv2_ops = { | ||
216 | .prepare = clk_pllv2_prepare, | ||
217 | .unprepare = clk_pllv2_unprepare, | ||
218 | .recalc_rate = clk_pllv2_recalc_rate, | ||
219 | .round_rate = clk_pllv2_round_rate, | ||
220 | .set_rate = clk_pllv2_set_rate, | ||
221 | }; | ||
222 | |||
223 | struct clk *imx_clk_pllv2(const char *name, const char *parent, | ||
224 | void __iomem *base) | ||
225 | { | ||
226 | struct clk_pllv2 *pll; | ||
227 | struct clk *clk; | ||
228 | struct clk_init_data init; | ||
229 | |||
230 | pll = kzalloc(sizeof(*pll), GFP_KERNEL); | ||
231 | if (!pll) | ||
232 | return ERR_PTR(-ENOMEM); | ||
233 | |||
234 | pll->base = base; | ||
235 | |||
236 | init.name = name; | ||
237 | init.ops = &clk_pllv2_ops; | ||
238 | init.flags = 0; | ||
239 | init.parent_names = &parent; | ||
240 | init.num_parents = 1; | ||
241 | |||
242 | pll->hw.init = &init; | ||
243 | |||
244 | clk = clk_register(NULL, &pll->hw); | ||
245 | if (IS_ERR(clk)) | ||
246 | kfree(pll); | ||
247 | |||
248 | return clk; | ||
249 | } | ||
diff --git a/arch/arm/mach-imx/clk-pllv3.c b/arch/arm/mach-imx/clk-pllv3.c new file mode 100644 index 000000000000..36aac947bce1 --- /dev/null +++ b/arch/arm/mach-imx/clk-pllv3.c | |||
@@ -0,0 +1,419 @@ | |||
1 | /* | ||
2 | * Copyright 2012 Freescale Semiconductor, Inc. | ||
3 | * Copyright 2012 Linaro Ltd. | ||
4 | * | ||
5 | * The code contained herein is licensed under the GNU General Public | ||
6 | * License. You may obtain a copy of the GNU General Public License | ||
7 | * Version 2 or later at the following locations: | ||
8 | * | ||
9 | * http://www.opensource.org/licenses/gpl-license.html | ||
10 | * http://www.gnu.org/copyleft/gpl.html | ||
11 | */ | ||
12 | |||
13 | #include <linux/clk.h> | ||
14 | #include <linux/clk-provider.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/slab.h> | ||
17 | #include <linux/jiffies.h> | ||
18 | #include <linux/err.h> | ||
19 | #include "clk.h" | ||
20 | |||
21 | #define PLL_NUM_OFFSET 0x10 | ||
22 | #define PLL_DENOM_OFFSET 0x20 | ||
23 | |||
24 | #define BM_PLL_POWER (0x1 << 12) | ||
25 | #define BM_PLL_ENABLE (0x1 << 13) | ||
26 | #define BM_PLL_BYPASS (0x1 << 16) | ||
27 | #define BM_PLL_LOCK (0x1 << 31) | ||
28 | |||
29 | /** | ||
30 | * struct clk_pllv3 - IMX PLL clock version 3 | ||
31 | * @clk_hw: clock source | ||
32 | * @base: base address of PLL registers | ||
33 | * @powerup_set: set POWER bit to power up the PLL | ||
34 | * @gate_mask: mask of gate bits | ||
35 | * @div_mask: mask of divider bits | ||
36 | * | ||
37 | * IMX PLL clock version 3, found on i.MX6 series. Divider for pllv3 | ||
38 | * is actually a multiplier, and always sits at bit 0. | ||
39 | */ | ||
40 | struct clk_pllv3 { | ||
41 | struct clk_hw hw; | ||
42 | void __iomem *base; | ||
43 | bool powerup_set; | ||
44 | u32 gate_mask; | ||
45 | u32 div_mask; | ||
46 | }; | ||
47 | |||
48 | #define to_clk_pllv3(_hw) container_of(_hw, struct clk_pllv3, hw) | ||
49 | |||
50 | static int clk_pllv3_prepare(struct clk_hw *hw) | ||
51 | { | ||
52 | struct clk_pllv3 *pll = to_clk_pllv3(hw); | ||
53 | unsigned long timeout = jiffies + msecs_to_jiffies(10); | ||
54 | u32 val; | ||
55 | |||
56 | val = readl_relaxed(pll->base); | ||
57 | val &= ~BM_PLL_BYPASS; | ||
58 | if (pll->powerup_set) | ||
59 | val |= BM_PLL_POWER; | ||
60 | else | ||
61 | val &= ~BM_PLL_POWER; | ||
62 | writel_relaxed(val, pll->base); | ||
63 | |||
64 | /* Wait for PLL to lock */ | ||
65 | while (!(readl_relaxed(pll->base) & BM_PLL_LOCK)) | ||
66 | if (time_after(jiffies, timeout)) | ||
67 | return -ETIMEDOUT; | ||
68 | |||
69 | return 0; | ||
70 | } | ||
71 | |||
72 | static void clk_pllv3_unprepare(struct clk_hw *hw) | ||
73 | { | ||
74 | struct clk_pllv3 *pll = to_clk_pllv3(hw); | ||
75 | u32 val; | ||
76 | |||
77 | val = readl_relaxed(pll->base); | ||
78 | val |= BM_PLL_BYPASS; | ||
79 | if (pll->powerup_set) | ||
80 | val &= ~BM_PLL_POWER; | ||
81 | else | ||
82 | val |= BM_PLL_POWER; | ||
83 | writel_relaxed(val, pll->base); | ||
84 | } | ||
85 | |||
86 | static int clk_pllv3_enable(struct clk_hw *hw) | ||
87 | { | ||
88 | struct clk_pllv3 *pll = to_clk_pllv3(hw); | ||
89 | u32 val; | ||
90 | |||
91 | val = readl_relaxed(pll->base); | ||
92 | val |= pll->gate_mask; | ||
93 | writel_relaxed(val, pll->base); | ||
94 | |||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | static void clk_pllv3_disable(struct clk_hw *hw) | ||
99 | { | ||
100 | struct clk_pllv3 *pll = to_clk_pllv3(hw); | ||
101 | u32 val; | ||
102 | |||
103 | val = readl_relaxed(pll->base); | ||
104 | val &= ~pll->gate_mask; | ||
105 | writel_relaxed(val, pll->base); | ||
106 | } | ||
107 | |||
108 | static unsigned long clk_pllv3_recalc_rate(struct clk_hw *hw, | ||
109 | unsigned long parent_rate) | ||
110 | { | ||
111 | struct clk_pllv3 *pll = to_clk_pllv3(hw); | ||
112 | u32 div = readl_relaxed(pll->base) & pll->div_mask; | ||
113 | |||
114 | return (div == 1) ? parent_rate * 22 : parent_rate * 20; | ||
115 | } | ||
116 | |||
117 | static long clk_pllv3_round_rate(struct clk_hw *hw, unsigned long rate, | ||
118 | unsigned long *prate) | ||
119 | { | ||
120 | unsigned long parent_rate = *prate; | ||
121 | |||
122 | return (rate >= parent_rate * 22) ? parent_rate * 22 : | ||
123 | parent_rate * 20; | ||
124 | } | ||
125 | |||
126 | static int clk_pllv3_set_rate(struct clk_hw *hw, unsigned long rate, | ||
127 | unsigned long parent_rate) | ||
128 | { | ||
129 | struct clk_pllv3 *pll = to_clk_pllv3(hw); | ||
130 | u32 val, div; | ||
131 | |||
132 | if (rate == parent_rate * 22) | ||
133 | div = 1; | ||
134 | else if (rate == parent_rate * 20) | ||
135 | div = 0; | ||
136 | else | ||
137 | return -EINVAL; | ||
138 | |||
139 | val = readl_relaxed(pll->base); | ||
140 | val &= ~pll->div_mask; | ||
141 | val |= div; | ||
142 | writel_relaxed(val, pll->base); | ||
143 | |||
144 | return 0; | ||
145 | } | ||
146 | |||
147 | static const struct clk_ops clk_pllv3_ops = { | ||
148 | .prepare = clk_pllv3_prepare, | ||
149 | .unprepare = clk_pllv3_unprepare, | ||
150 | .enable = clk_pllv3_enable, | ||
151 | .disable = clk_pllv3_disable, | ||
152 | .recalc_rate = clk_pllv3_recalc_rate, | ||
153 | .round_rate = clk_pllv3_round_rate, | ||
154 | .set_rate = clk_pllv3_set_rate, | ||
155 | }; | ||
156 | |||
157 | static unsigned long clk_pllv3_sys_recalc_rate(struct clk_hw *hw, | ||
158 | unsigned long parent_rate) | ||
159 | { | ||
160 | struct clk_pllv3 *pll = to_clk_pllv3(hw); | ||
161 | u32 div = readl_relaxed(pll->base) & pll->div_mask; | ||
162 | |||
163 | return parent_rate * div / 2; | ||
164 | } | ||
165 | |||
166 | static long clk_pllv3_sys_round_rate(struct clk_hw *hw, unsigned long rate, | ||
167 | unsigned long *prate) | ||
168 | { | ||
169 | unsigned long parent_rate = *prate; | ||
170 | unsigned long min_rate = parent_rate * 54 / 2; | ||
171 | unsigned long max_rate = parent_rate * 108 / 2; | ||
172 | u32 div; | ||
173 | |||
174 | if (rate > max_rate) | ||
175 | rate = max_rate; | ||
176 | else if (rate < min_rate) | ||
177 | rate = min_rate; | ||
178 | div = rate * 2 / parent_rate; | ||
179 | |||
180 | return parent_rate * div / 2; | ||
181 | } | ||
182 | |||
183 | static int clk_pllv3_sys_set_rate(struct clk_hw *hw, unsigned long rate, | ||
184 | unsigned long parent_rate) | ||
185 | { | ||
186 | struct clk_pllv3 *pll = to_clk_pllv3(hw); | ||
187 | unsigned long min_rate = parent_rate * 54 / 2; | ||
188 | unsigned long max_rate = parent_rate * 108 / 2; | ||
189 | u32 val, div; | ||
190 | |||
191 | if (rate < min_rate || rate > max_rate) | ||
192 | return -EINVAL; | ||
193 | |||
194 | div = rate * 2 / parent_rate; | ||
195 | val = readl_relaxed(pll->base); | ||
196 | val &= ~pll->div_mask; | ||
197 | val |= div; | ||
198 | writel_relaxed(val, pll->base); | ||
199 | |||
200 | return 0; | ||
201 | } | ||
202 | |||
203 | static const struct clk_ops clk_pllv3_sys_ops = { | ||
204 | .prepare = clk_pllv3_prepare, | ||
205 | .unprepare = clk_pllv3_unprepare, | ||
206 | .enable = clk_pllv3_enable, | ||
207 | .disable = clk_pllv3_disable, | ||
208 | .recalc_rate = clk_pllv3_sys_recalc_rate, | ||
209 | .round_rate = clk_pllv3_sys_round_rate, | ||
210 | .set_rate = clk_pllv3_sys_set_rate, | ||
211 | }; | ||
212 | |||
213 | static unsigned long clk_pllv3_av_recalc_rate(struct clk_hw *hw, | ||
214 | unsigned long parent_rate) | ||
215 | { | ||
216 | struct clk_pllv3 *pll = to_clk_pllv3(hw); | ||
217 | u32 mfn = readl_relaxed(pll->base + PLL_NUM_OFFSET); | ||
218 | u32 mfd = readl_relaxed(pll->base + PLL_DENOM_OFFSET); | ||
219 | u32 div = readl_relaxed(pll->base) & pll->div_mask; | ||
220 | |||
221 | return (parent_rate * div) + ((parent_rate / mfd) * mfn); | ||
222 | } | ||
223 | |||
224 | static long clk_pllv3_av_round_rate(struct clk_hw *hw, unsigned long rate, | ||
225 | unsigned long *prate) | ||
226 | { | ||
227 | unsigned long parent_rate = *prate; | ||
228 | unsigned long min_rate = parent_rate * 27; | ||
229 | unsigned long max_rate = parent_rate * 54; | ||
230 | u32 div; | ||
231 | u32 mfn, mfd = 1000000; | ||
232 | s64 temp64; | ||
233 | |||
234 | if (rate > max_rate) | ||
235 | rate = max_rate; | ||
236 | else if (rate < min_rate) | ||
237 | rate = min_rate; | ||
238 | |||
239 | div = rate / parent_rate; | ||
240 | temp64 = (u64) (rate - div * parent_rate); | ||
241 | temp64 *= mfd; | ||
242 | do_div(temp64, parent_rate); | ||
243 | mfn = temp64; | ||
244 | |||
245 | return parent_rate * div + parent_rate / mfd * mfn; | ||
246 | } | ||
247 | |||
248 | static int clk_pllv3_av_set_rate(struct clk_hw *hw, unsigned long rate, | ||
249 | unsigned long parent_rate) | ||
250 | { | ||
251 | struct clk_pllv3 *pll = to_clk_pllv3(hw); | ||
252 | unsigned long min_rate = parent_rate * 27; | ||
253 | unsigned long max_rate = parent_rate * 54; | ||
254 | u32 val, div; | ||
255 | u32 mfn, mfd = 1000000; | ||
256 | s64 temp64; | ||
257 | |||
258 | if (rate < min_rate || rate > max_rate) | ||
259 | return -EINVAL; | ||
260 | |||
261 | div = rate / parent_rate; | ||
262 | temp64 = (u64) (rate - div * parent_rate); | ||
263 | temp64 *= mfd; | ||
264 | do_div(temp64, parent_rate); | ||
265 | mfn = temp64; | ||
266 | |||
267 | val = readl_relaxed(pll->base); | ||
268 | val &= ~pll->div_mask; | ||
269 | val |= div; | ||
270 | writel_relaxed(val, pll->base); | ||
271 | writel_relaxed(mfn, pll->base + PLL_NUM_OFFSET); | ||
272 | writel_relaxed(mfd, pll->base + PLL_DENOM_OFFSET); | ||
273 | |||
274 | return 0; | ||
275 | } | ||
276 | |||
277 | static const struct clk_ops clk_pllv3_av_ops = { | ||
278 | .prepare = clk_pllv3_prepare, | ||
279 | .unprepare = clk_pllv3_unprepare, | ||
280 | .enable = clk_pllv3_enable, | ||
281 | .disable = clk_pllv3_disable, | ||
282 | .recalc_rate = clk_pllv3_av_recalc_rate, | ||
283 | .round_rate = clk_pllv3_av_round_rate, | ||
284 | .set_rate = clk_pllv3_av_set_rate, | ||
285 | }; | ||
286 | |||
287 | static unsigned long clk_pllv3_enet_recalc_rate(struct clk_hw *hw, | ||
288 | unsigned long parent_rate) | ||
289 | { | ||
290 | struct clk_pllv3 *pll = to_clk_pllv3(hw); | ||
291 | u32 div = readl_relaxed(pll->base) & pll->div_mask; | ||
292 | |||
293 | switch (div) { | ||
294 | case 0: | ||
295 | return 25000000; | ||
296 | case 1: | ||
297 | return 50000000; | ||
298 | case 2: | ||
299 | return 100000000; | ||
300 | case 3: | ||
301 | return 125000000; | ||
302 | } | ||
303 | |||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | static long clk_pllv3_enet_round_rate(struct clk_hw *hw, unsigned long rate, | ||
308 | unsigned long *prate) | ||
309 | { | ||
310 | if (rate >= 125000000) | ||
311 | rate = 125000000; | ||
312 | else if (rate >= 100000000) | ||
313 | rate = 100000000; | ||
314 | else if (rate >= 50000000) | ||
315 | rate = 50000000; | ||
316 | else | ||
317 | rate = 25000000; | ||
318 | return rate; | ||
319 | } | ||
320 | |||
321 | static int clk_pllv3_enet_set_rate(struct clk_hw *hw, unsigned long rate, | ||
322 | unsigned long parent_rate) | ||
323 | { | ||
324 | struct clk_pllv3 *pll = to_clk_pllv3(hw); | ||
325 | u32 val, div; | ||
326 | |||
327 | switch (rate) { | ||
328 | case 25000000: | ||
329 | div = 0; | ||
330 | break; | ||
331 | case 50000000: | ||
332 | div = 1; | ||
333 | break; | ||
334 | case 100000000: | ||
335 | div = 2; | ||
336 | break; | ||
337 | case 125000000: | ||
338 | div = 3; | ||
339 | break; | ||
340 | default: | ||
341 | return -EINVAL; | ||
342 | } | ||
343 | |||
344 | val = readl_relaxed(pll->base); | ||
345 | val &= ~pll->div_mask; | ||
346 | val |= div; | ||
347 | writel_relaxed(val, pll->base); | ||
348 | |||
349 | return 0; | ||
350 | } | ||
351 | |||
352 | static const struct clk_ops clk_pllv3_enet_ops = { | ||
353 | .prepare = clk_pllv3_prepare, | ||
354 | .unprepare = clk_pllv3_unprepare, | ||
355 | .enable = clk_pllv3_enable, | ||
356 | .disable = clk_pllv3_disable, | ||
357 | .recalc_rate = clk_pllv3_enet_recalc_rate, | ||
358 | .round_rate = clk_pllv3_enet_round_rate, | ||
359 | .set_rate = clk_pllv3_enet_set_rate, | ||
360 | }; | ||
361 | |||
362 | static const struct clk_ops clk_pllv3_mlb_ops = { | ||
363 | .prepare = clk_pllv3_prepare, | ||
364 | .unprepare = clk_pllv3_unprepare, | ||
365 | .enable = clk_pllv3_enable, | ||
366 | .disable = clk_pllv3_disable, | ||
367 | }; | ||
368 | |||
369 | struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name, | ||
370 | const char *parent_name, void __iomem *base, | ||
371 | u32 gate_mask, u32 div_mask) | ||
372 | { | ||
373 | struct clk_pllv3 *pll; | ||
374 | const struct clk_ops *ops; | ||
375 | struct clk *clk; | ||
376 | struct clk_init_data init; | ||
377 | |||
378 | pll = kzalloc(sizeof(*pll), GFP_KERNEL); | ||
379 | if (!pll) | ||
380 | return ERR_PTR(-ENOMEM); | ||
381 | |||
382 | switch (type) { | ||
383 | case IMX_PLLV3_SYS: | ||
384 | ops = &clk_pllv3_sys_ops; | ||
385 | break; | ||
386 | case IMX_PLLV3_USB: | ||
387 | ops = &clk_pllv3_ops; | ||
388 | pll->powerup_set = true; | ||
389 | break; | ||
390 | case IMX_PLLV3_AV: | ||
391 | ops = &clk_pllv3_av_ops; | ||
392 | break; | ||
393 | case IMX_PLLV3_ENET: | ||
394 | ops = &clk_pllv3_enet_ops; | ||
395 | break; | ||
396 | case IMX_PLLV3_MLB: | ||
397 | ops = &clk_pllv3_mlb_ops; | ||
398 | break; | ||
399 | default: | ||
400 | ops = &clk_pllv3_ops; | ||
401 | } | ||
402 | pll->base = base; | ||
403 | pll->gate_mask = gate_mask; | ||
404 | pll->div_mask = div_mask; | ||
405 | |||
406 | init.name = name; | ||
407 | init.ops = ops; | ||
408 | init.flags = 0; | ||
409 | init.parent_names = &parent_name; | ||
410 | init.num_parents = 1; | ||
411 | |||
412 | pll->hw.init = &init; | ||
413 | |||
414 | clk = clk_register(NULL, &pll->hw); | ||
415 | if (IS_ERR(clk)) | ||
416 | kfree(pll); | ||
417 | |||
418 | return clk; | ||
419 | } | ||
diff --git a/arch/arm/mach-imx/clk.h b/arch/arm/mach-imx/clk.h new file mode 100644 index 000000000000..1bf64fe2523c --- /dev/null +++ b/arch/arm/mach-imx/clk.h | |||
@@ -0,0 +1,83 @@ | |||
1 | #ifndef __MACH_IMX_CLK_H | ||
2 | #define __MACH_IMX_CLK_H | ||
3 | |||
4 | #include <linux/spinlock.h> | ||
5 | #include <linux/clk-provider.h> | ||
6 | #include <mach/clock.h> | ||
7 | |||
8 | struct clk *imx_clk_pllv1(const char *name, const char *parent, | ||
9 | void __iomem *base); | ||
10 | |||
11 | struct clk *imx_clk_pllv2(const char *name, const char *parent, | ||
12 | void __iomem *base); | ||
13 | |||
14 | enum imx_pllv3_type { | ||
15 | IMX_PLLV3_GENERIC, | ||
16 | IMX_PLLV3_SYS, | ||
17 | IMX_PLLV3_USB, | ||
18 | IMX_PLLV3_AV, | ||
19 | IMX_PLLV3_ENET, | ||
20 | IMX_PLLV3_MLB, | ||
21 | }; | ||
22 | |||
23 | struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name, | ||
24 | const char *parent_name, void __iomem *base, u32 gate_mask, | ||
25 | u32 div_mask); | ||
26 | |||
27 | struct clk *clk_register_gate2(struct device *dev, const char *name, | ||
28 | const char *parent_name, unsigned long flags, | ||
29 | void __iomem *reg, u8 bit_idx, | ||
30 | u8 clk_gate_flags, spinlock_t *lock); | ||
31 | |||
32 | static inline struct clk *imx_clk_gate2(const char *name, const char *parent, | ||
33 | void __iomem *reg, u8 shift) | ||
34 | { | ||
35 | return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg, | ||
36 | shift, 0, &imx_ccm_lock); | ||
37 | } | ||
38 | |||
39 | struct clk *imx_clk_pfd(const char *name, const char *parent_name, | ||
40 | void __iomem *reg, u8 idx); | ||
41 | |||
42 | struct clk *imx_clk_busy_divider(const char *name, const char *parent_name, | ||
43 | void __iomem *reg, u8 shift, u8 width, | ||
44 | void __iomem *busy_reg, u8 busy_shift); | ||
45 | |||
46 | struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift, | ||
47 | u8 width, void __iomem *busy_reg, u8 busy_shift, | ||
48 | const char **parent_names, int num_parents); | ||
49 | |||
50 | static inline struct clk *imx_clk_fixed(const char *name, int rate) | ||
51 | { | ||
52 | return clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate); | ||
53 | } | ||
54 | |||
55 | static inline struct clk *imx_clk_divider(const char *name, const char *parent, | ||
56 | void __iomem *reg, u8 shift, u8 width) | ||
57 | { | ||
58 | return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT, | ||
59 | reg, shift, width, 0, &imx_ccm_lock); | ||
60 | } | ||
61 | |||
62 | static inline struct clk *imx_clk_gate(const char *name, const char *parent, | ||
63 | void __iomem *reg, u8 shift) | ||
64 | { | ||
65 | return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg, | ||
66 | shift, 0, &imx_ccm_lock); | ||
67 | } | ||
68 | |||
69 | static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg, | ||
70 | u8 shift, u8 width, const char **parents, int num_parents) | ||
71 | { | ||
72 | return clk_register_mux(NULL, name, parents, num_parents, 0, reg, shift, | ||
73 | width, 0, &imx_ccm_lock); | ||
74 | } | ||
75 | |||
76 | static inline struct clk *imx_clk_fixed_factor(const char *name, | ||
77 | const char *parent, unsigned int mult, unsigned int div) | ||
78 | { | ||
79 | return clk_register_fixed_factor(NULL, name, parent, | ||
80 | CLK_SET_RATE_PARENT, mult, div); | ||
81 | } | ||
82 | |||
83 | #endif | ||
diff --git a/arch/arm/mach-imx/clock-imx1.c b/arch/arm/mach-imx/clock-imx1.c deleted file mode 100644 index 4aabeb241563..000000000000 --- a/arch/arm/mach-imx/clock-imx1.c +++ /dev/null | |||
@@ -1,636 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2008 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License along | ||
14 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
15 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | ||
16 | */ | ||
17 | |||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/list.h> | ||
21 | #include <linux/math64.h> | ||
22 | #include <linux/err.h> | ||
23 | #include <linux/clk.h> | ||
24 | #include <linux/io.h> | ||
25 | #include <linux/clkdev.h> | ||
26 | |||
27 | #include <mach/clock.h> | ||
28 | #include <mach/hardware.h> | ||
29 | #include <mach/common.h> | ||
30 | |||
31 | #define IO_ADDR_CCM(off) (MX1_IO_ADDRESS(MX1_CCM_BASE_ADDR + (off))) | ||
32 | |||
33 | /* CCM register addresses */ | ||
34 | #define CCM_CSCR IO_ADDR_CCM(0x0) | ||
35 | #define CCM_MPCTL0 IO_ADDR_CCM(0x4) | ||
36 | #define CCM_SPCTL0 IO_ADDR_CCM(0xc) | ||
37 | #define CCM_PCDR IO_ADDR_CCM(0x20) | ||
38 | |||
39 | #define CCM_CSCR_CLKO_OFFSET 29 | ||
40 | #define CCM_CSCR_CLKO_MASK (0x7 << 29) | ||
41 | #define CCM_CSCR_USB_OFFSET 26 | ||
42 | #define CCM_CSCR_USB_MASK (0x7 << 26) | ||
43 | #define CCM_CSCR_OSC_EN_SHIFT 17 | ||
44 | #define CCM_CSCR_SYSTEM_SEL (1 << 16) | ||
45 | #define CCM_CSCR_BCLK_OFFSET 10 | ||
46 | #define CCM_CSCR_BCLK_MASK (0xf << 10) | ||
47 | #define CCM_CSCR_PRESC (1 << 15) | ||
48 | |||
49 | #define CCM_PCDR_PCLK3_OFFSET 16 | ||
50 | #define CCM_PCDR_PCLK3_MASK (0x7f << 16) | ||
51 | #define CCM_PCDR_PCLK2_OFFSET 4 | ||
52 | #define CCM_PCDR_PCLK2_MASK (0xf << 4) | ||
53 | #define CCM_PCDR_PCLK1_OFFSET 0 | ||
54 | #define CCM_PCDR_PCLK1_MASK 0xf | ||
55 | |||
56 | #define IO_ADDR_SCM(off) (MX1_IO_ADDRESS(MX1_SCM_BASE_ADDR + (off))) | ||
57 | |||
58 | /* SCM register addresses */ | ||
59 | #define SCM_GCCR IO_ADDR_SCM(0xc) | ||
60 | |||
61 | #define SCM_GCCR_DMA_CLK_EN_OFFSET 3 | ||
62 | #define SCM_GCCR_CSI_CLK_EN_OFFSET 2 | ||
63 | #define SCM_GCCR_MMA_CLK_EN_OFFSET 1 | ||
64 | #define SCM_GCCR_USBD_CLK_EN_OFFSET 0 | ||
65 | |||
66 | static int _clk_enable(struct clk *clk) | ||
67 | { | ||
68 | unsigned int reg; | ||
69 | |||
70 | reg = __raw_readl(clk->enable_reg); | ||
71 | reg |= 1 << clk->enable_shift; | ||
72 | __raw_writel(reg, clk->enable_reg); | ||
73 | |||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | static void _clk_disable(struct clk *clk) | ||
78 | { | ||
79 | unsigned int reg; | ||
80 | |||
81 | reg = __raw_readl(clk->enable_reg); | ||
82 | reg &= ~(1 << clk->enable_shift); | ||
83 | __raw_writel(reg, clk->enable_reg); | ||
84 | } | ||
85 | |||
86 | static int _clk_can_use_parent(const struct clk *clk_arr[], unsigned int size, | ||
87 | struct clk *parent) | ||
88 | { | ||
89 | int i; | ||
90 | |||
91 | for (i = 0; i < size; i++) | ||
92 | if (parent == clk_arr[i]) | ||
93 | return i; | ||
94 | |||
95 | return -EINVAL; | ||
96 | } | ||
97 | |||
98 | static unsigned long | ||
99 | _clk_simple_round_rate(struct clk *clk, unsigned long rate, unsigned int limit) | ||
100 | { | ||
101 | int div; | ||
102 | unsigned long parent_rate; | ||
103 | |||
104 | parent_rate = clk_get_rate(clk->parent); | ||
105 | |||
106 | div = parent_rate / rate; | ||
107 | if (parent_rate % rate) | ||
108 | div++; | ||
109 | |||
110 | if (div > limit) | ||
111 | div = limit; | ||
112 | |||
113 | return parent_rate / div; | ||
114 | } | ||
115 | |||
116 | static unsigned long _clk_parent_round_rate(struct clk *clk, unsigned long rate) | ||
117 | { | ||
118 | return clk->parent->round_rate(clk->parent, rate); | ||
119 | } | ||
120 | |||
121 | static int _clk_parent_set_rate(struct clk *clk, unsigned long rate) | ||
122 | { | ||
123 | return clk->parent->set_rate(clk->parent, rate); | ||
124 | } | ||
125 | |||
126 | static unsigned long clk16m_get_rate(struct clk *clk) | ||
127 | { | ||
128 | return 16000000; | ||
129 | } | ||
130 | |||
131 | static struct clk clk16m = { | ||
132 | .get_rate = clk16m_get_rate, | ||
133 | .enable = _clk_enable, | ||
134 | .enable_reg = CCM_CSCR, | ||
135 | .enable_shift = CCM_CSCR_OSC_EN_SHIFT, | ||
136 | .disable = _clk_disable, | ||
137 | }; | ||
138 | |||
139 | /* in Hz */ | ||
140 | static unsigned long clk32_rate; | ||
141 | |||
142 | static unsigned long clk32_get_rate(struct clk *clk) | ||
143 | { | ||
144 | return clk32_rate; | ||
145 | } | ||
146 | |||
147 | static struct clk clk32 = { | ||
148 | .get_rate = clk32_get_rate, | ||
149 | }; | ||
150 | |||
151 | static unsigned long clk32_premult_get_rate(struct clk *clk) | ||
152 | { | ||
153 | return clk_get_rate(clk->parent) * 512; | ||
154 | } | ||
155 | |||
156 | static struct clk clk32_premult = { | ||
157 | .parent = &clk32, | ||
158 | .get_rate = clk32_premult_get_rate, | ||
159 | }; | ||
160 | |||
161 | static const struct clk *prem_clk_clocks[] = { | ||
162 | &clk32_premult, | ||
163 | &clk16m, | ||
164 | }; | ||
165 | |||
166 | static int prem_clk_set_parent(struct clk *clk, struct clk *parent) | ||
167 | { | ||
168 | int i; | ||
169 | unsigned int reg = __raw_readl(CCM_CSCR); | ||
170 | |||
171 | i = _clk_can_use_parent(prem_clk_clocks, ARRAY_SIZE(prem_clk_clocks), | ||
172 | parent); | ||
173 | |||
174 | switch (i) { | ||
175 | case 0: | ||
176 | reg &= ~CCM_CSCR_SYSTEM_SEL; | ||
177 | break; | ||
178 | case 1: | ||
179 | reg |= CCM_CSCR_SYSTEM_SEL; | ||
180 | break; | ||
181 | default: | ||
182 | return i; | ||
183 | } | ||
184 | |||
185 | __raw_writel(reg, CCM_CSCR); | ||
186 | |||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | static struct clk prem_clk = { | ||
191 | .set_parent = prem_clk_set_parent, | ||
192 | }; | ||
193 | |||
194 | static unsigned long system_clk_get_rate(struct clk *clk) | ||
195 | { | ||
196 | return mxc_decode_pll(__raw_readl(CCM_SPCTL0), | ||
197 | clk_get_rate(clk->parent)); | ||
198 | } | ||
199 | |||
200 | static struct clk system_clk = { | ||
201 | .parent = &prem_clk, | ||
202 | .get_rate = system_clk_get_rate, | ||
203 | }; | ||
204 | |||
205 | static unsigned long mcu_clk_get_rate(struct clk *clk) | ||
206 | { | ||
207 | return mxc_decode_pll(__raw_readl(CCM_MPCTL0), | ||
208 | clk_get_rate(clk->parent)); | ||
209 | } | ||
210 | |||
211 | static struct clk mcu_clk = { | ||
212 | .parent = &clk32_premult, | ||
213 | .get_rate = mcu_clk_get_rate, | ||
214 | }; | ||
215 | |||
216 | static unsigned long fclk_get_rate(struct clk *clk) | ||
217 | { | ||
218 | unsigned long fclk = clk_get_rate(clk->parent); | ||
219 | |||
220 | if (__raw_readl(CCM_CSCR) & CCM_CSCR_PRESC) | ||
221 | fclk /= 2; | ||
222 | |||
223 | return fclk; | ||
224 | } | ||
225 | |||
226 | static struct clk fclk = { | ||
227 | .parent = &mcu_clk, | ||
228 | .get_rate = fclk_get_rate, | ||
229 | }; | ||
230 | |||
231 | /* | ||
232 | * get hclk ( SDRAM, CSI, Memory Stick, I2C, DMA ) | ||
233 | */ | ||
234 | static unsigned long hclk_get_rate(struct clk *clk) | ||
235 | { | ||
236 | return clk_get_rate(clk->parent) / (((__raw_readl(CCM_CSCR) & | ||
237 | CCM_CSCR_BCLK_MASK) >> CCM_CSCR_BCLK_OFFSET) + 1); | ||
238 | } | ||
239 | |||
240 | static unsigned long hclk_round_rate(struct clk *clk, unsigned long rate) | ||
241 | { | ||
242 | return _clk_simple_round_rate(clk, rate, 16); | ||
243 | } | ||
244 | |||
245 | static int hclk_set_rate(struct clk *clk, unsigned long rate) | ||
246 | { | ||
247 | unsigned int div; | ||
248 | unsigned int reg; | ||
249 | unsigned long parent_rate; | ||
250 | |||
251 | parent_rate = clk_get_rate(clk->parent); | ||
252 | |||
253 | div = parent_rate / rate; | ||
254 | |||
255 | if (div > 16 || div < 1 || ((parent_rate / div) != rate)) | ||
256 | return -EINVAL; | ||
257 | |||
258 | div--; | ||
259 | |||
260 | reg = __raw_readl(CCM_CSCR); | ||
261 | reg &= ~CCM_CSCR_BCLK_MASK; | ||
262 | reg |= div << CCM_CSCR_BCLK_OFFSET; | ||
263 | __raw_writel(reg, CCM_CSCR); | ||
264 | |||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | static struct clk hclk = { | ||
269 | .parent = &system_clk, | ||
270 | .get_rate = hclk_get_rate, | ||
271 | .round_rate = hclk_round_rate, | ||
272 | .set_rate = hclk_set_rate, | ||
273 | }; | ||
274 | |||
275 | static unsigned long clk48m_get_rate(struct clk *clk) | ||
276 | { | ||
277 | return clk_get_rate(clk->parent) / (((__raw_readl(CCM_CSCR) & | ||
278 | CCM_CSCR_USB_MASK) >> CCM_CSCR_USB_OFFSET) + 1); | ||
279 | } | ||
280 | |||
281 | static unsigned long clk48m_round_rate(struct clk *clk, unsigned long rate) | ||
282 | { | ||
283 | return _clk_simple_round_rate(clk, rate, 8); | ||
284 | } | ||
285 | |||
286 | static int clk48m_set_rate(struct clk *clk, unsigned long rate) | ||
287 | { | ||
288 | unsigned int div; | ||
289 | unsigned int reg; | ||
290 | unsigned long parent_rate; | ||
291 | |||
292 | parent_rate = clk_get_rate(clk->parent); | ||
293 | |||
294 | div = parent_rate / rate; | ||
295 | |||
296 | if (div > 8 || div < 1 || ((parent_rate / div) != rate)) | ||
297 | return -EINVAL; | ||
298 | |||
299 | div--; | ||
300 | |||
301 | reg = __raw_readl(CCM_CSCR); | ||
302 | reg &= ~CCM_CSCR_USB_MASK; | ||
303 | reg |= div << CCM_CSCR_USB_OFFSET; | ||
304 | __raw_writel(reg, CCM_CSCR); | ||
305 | |||
306 | return 0; | ||
307 | } | ||
308 | |||
309 | static struct clk clk48m = { | ||
310 | .parent = &system_clk, | ||
311 | .get_rate = clk48m_get_rate, | ||
312 | .round_rate = clk48m_round_rate, | ||
313 | .set_rate = clk48m_set_rate, | ||
314 | }; | ||
315 | |||
316 | /* | ||
317 | * get peripheral clock 1 ( UART[12], Timer[12], PWM ) | ||
318 | */ | ||
319 | static unsigned long perclk1_get_rate(struct clk *clk) | ||
320 | { | ||
321 | return clk_get_rate(clk->parent) / (((__raw_readl(CCM_PCDR) & | ||
322 | CCM_PCDR_PCLK1_MASK) >> CCM_PCDR_PCLK1_OFFSET) + 1); | ||
323 | } | ||
324 | |||
325 | static unsigned long perclk1_round_rate(struct clk *clk, unsigned long rate) | ||
326 | { | ||
327 | return _clk_simple_round_rate(clk, rate, 16); | ||
328 | } | ||
329 | |||
330 | static int perclk1_set_rate(struct clk *clk, unsigned long rate) | ||
331 | { | ||
332 | unsigned int div; | ||
333 | unsigned int reg; | ||
334 | unsigned long parent_rate; | ||
335 | |||
336 | parent_rate = clk_get_rate(clk->parent); | ||
337 | |||
338 | div = parent_rate / rate; | ||
339 | |||
340 | if (div > 16 || div < 1 || ((parent_rate / div) != rate)) | ||
341 | return -EINVAL; | ||
342 | |||
343 | div--; | ||
344 | |||
345 | reg = __raw_readl(CCM_PCDR); | ||
346 | reg &= ~CCM_PCDR_PCLK1_MASK; | ||
347 | reg |= div << CCM_PCDR_PCLK1_OFFSET; | ||
348 | __raw_writel(reg, CCM_PCDR); | ||
349 | |||
350 | return 0; | ||
351 | } | ||
352 | |||
353 | /* | ||
354 | * get peripheral clock 2 ( LCD, SD, SPI[12] ) | ||
355 | */ | ||
356 | static unsigned long perclk2_get_rate(struct clk *clk) | ||
357 | { | ||
358 | return clk_get_rate(clk->parent) / (((__raw_readl(CCM_PCDR) & | ||
359 | CCM_PCDR_PCLK2_MASK) >> CCM_PCDR_PCLK2_OFFSET) + 1); | ||
360 | } | ||
361 | |||
362 | static unsigned long perclk2_round_rate(struct clk *clk, unsigned long rate) | ||
363 | { | ||
364 | return _clk_simple_round_rate(clk, rate, 16); | ||
365 | } | ||
366 | |||
367 | static int perclk2_set_rate(struct clk *clk, unsigned long rate) | ||
368 | { | ||
369 | unsigned int div; | ||
370 | unsigned int reg; | ||
371 | unsigned long parent_rate; | ||
372 | |||
373 | parent_rate = clk_get_rate(clk->parent); | ||
374 | |||
375 | div = parent_rate / rate; | ||
376 | |||
377 | if (div > 16 || div < 1 || ((parent_rate / div) != rate)) | ||
378 | return -EINVAL; | ||
379 | |||
380 | div--; | ||
381 | |||
382 | reg = __raw_readl(CCM_PCDR); | ||
383 | reg &= ~CCM_PCDR_PCLK2_MASK; | ||
384 | reg |= div << CCM_PCDR_PCLK2_OFFSET; | ||
385 | __raw_writel(reg, CCM_PCDR); | ||
386 | |||
387 | return 0; | ||
388 | } | ||
389 | |||
390 | /* | ||
391 | * get peripheral clock 3 ( SSI ) | ||
392 | */ | ||
393 | static unsigned long perclk3_get_rate(struct clk *clk) | ||
394 | { | ||
395 | return clk_get_rate(clk->parent) / (((__raw_readl(CCM_PCDR) & | ||
396 | CCM_PCDR_PCLK3_MASK) >> CCM_PCDR_PCLK3_OFFSET) + 1); | ||
397 | } | ||
398 | |||
399 | static unsigned long perclk3_round_rate(struct clk *clk, unsigned long rate) | ||
400 | { | ||
401 | return _clk_simple_round_rate(clk, rate, 128); | ||
402 | } | ||
403 | |||
404 | static int perclk3_set_rate(struct clk *clk, unsigned long rate) | ||
405 | { | ||
406 | unsigned int div; | ||
407 | unsigned int reg; | ||
408 | unsigned long parent_rate; | ||
409 | |||
410 | parent_rate = clk_get_rate(clk->parent); | ||
411 | |||
412 | div = parent_rate / rate; | ||
413 | |||
414 | if (div > 128 || div < 1 || ((parent_rate / div) != rate)) | ||
415 | return -EINVAL; | ||
416 | |||
417 | div--; | ||
418 | |||
419 | reg = __raw_readl(CCM_PCDR); | ||
420 | reg &= ~CCM_PCDR_PCLK3_MASK; | ||
421 | reg |= div << CCM_PCDR_PCLK3_OFFSET; | ||
422 | __raw_writel(reg, CCM_PCDR); | ||
423 | |||
424 | return 0; | ||
425 | } | ||
426 | |||
427 | static struct clk perclk[] = { | ||
428 | { | ||
429 | .id = 0, | ||
430 | .parent = &system_clk, | ||
431 | .get_rate = perclk1_get_rate, | ||
432 | .round_rate = perclk1_round_rate, | ||
433 | .set_rate = perclk1_set_rate, | ||
434 | }, { | ||
435 | .id = 1, | ||
436 | .parent = &system_clk, | ||
437 | .get_rate = perclk2_get_rate, | ||
438 | .round_rate = perclk2_round_rate, | ||
439 | .set_rate = perclk2_set_rate, | ||
440 | }, { | ||
441 | .id = 2, | ||
442 | .parent = &system_clk, | ||
443 | .get_rate = perclk3_get_rate, | ||
444 | .round_rate = perclk3_round_rate, | ||
445 | .set_rate = perclk3_set_rate, | ||
446 | } | ||
447 | }; | ||
448 | |||
449 | static const struct clk *clko_clocks[] = { | ||
450 | &perclk[0], | ||
451 | &hclk, | ||
452 | &clk48m, | ||
453 | &clk16m, | ||
454 | &prem_clk, | ||
455 | &fclk, | ||
456 | }; | ||
457 | |||
458 | static int clko_set_parent(struct clk *clk, struct clk *parent) | ||
459 | { | ||
460 | int i; | ||
461 | unsigned int reg; | ||
462 | |||
463 | i = _clk_can_use_parent(clko_clocks, ARRAY_SIZE(clko_clocks), parent); | ||
464 | if (i < 0) | ||
465 | return i; | ||
466 | |||
467 | reg = __raw_readl(CCM_CSCR) & ~CCM_CSCR_CLKO_MASK; | ||
468 | reg |= i << CCM_CSCR_CLKO_OFFSET; | ||
469 | __raw_writel(reg, CCM_CSCR); | ||
470 | |||
471 | if (clko_clocks[i]->set_rate && clko_clocks[i]->round_rate) { | ||
472 | clk->set_rate = _clk_parent_set_rate; | ||
473 | clk->round_rate = _clk_parent_round_rate; | ||
474 | } else { | ||
475 | clk->set_rate = NULL; | ||
476 | clk->round_rate = NULL; | ||
477 | } | ||
478 | |||
479 | return 0; | ||
480 | } | ||
481 | |||
482 | static struct clk clko_clk = { | ||
483 | .set_parent = clko_set_parent, | ||
484 | }; | ||
485 | |||
486 | static struct clk dma_clk = { | ||
487 | .parent = &hclk, | ||
488 | .round_rate = _clk_parent_round_rate, | ||
489 | .set_rate = _clk_parent_set_rate, | ||
490 | .enable = _clk_enable, | ||
491 | .enable_reg = SCM_GCCR, | ||
492 | .enable_shift = SCM_GCCR_DMA_CLK_EN_OFFSET, | ||
493 | .disable = _clk_disable, | ||
494 | }; | ||
495 | |||
496 | static struct clk csi_clk = { | ||
497 | .parent = &hclk, | ||
498 | .round_rate = _clk_parent_round_rate, | ||
499 | .set_rate = _clk_parent_set_rate, | ||
500 | .enable = _clk_enable, | ||
501 | .enable_reg = SCM_GCCR, | ||
502 | .enable_shift = SCM_GCCR_CSI_CLK_EN_OFFSET, | ||
503 | .disable = _clk_disable, | ||
504 | }; | ||
505 | |||
506 | static struct clk mma_clk = { | ||
507 | .parent = &hclk, | ||
508 | .round_rate = _clk_parent_round_rate, | ||
509 | .set_rate = _clk_parent_set_rate, | ||
510 | .enable = _clk_enable, | ||
511 | .enable_reg = SCM_GCCR, | ||
512 | .enable_shift = SCM_GCCR_MMA_CLK_EN_OFFSET, | ||
513 | .disable = _clk_disable, | ||
514 | }; | ||
515 | |||
516 | static struct clk usbd_clk = { | ||
517 | .parent = &clk48m, | ||
518 | .round_rate = _clk_parent_round_rate, | ||
519 | .set_rate = _clk_parent_set_rate, | ||
520 | .enable = _clk_enable, | ||
521 | .enable_reg = SCM_GCCR, | ||
522 | .enable_shift = SCM_GCCR_USBD_CLK_EN_OFFSET, | ||
523 | .disable = _clk_disable, | ||
524 | }; | ||
525 | |||
526 | static struct clk gpt_clk = { | ||
527 | .parent = &perclk[0], | ||
528 | .round_rate = _clk_parent_round_rate, | ||
529 | .set_rate = _clk_parent_set_rate, | ||
530 | }; | ||
531 | |||
532 | static struct clk uart_clk = { | ||
533 | .parent = &perclk[0], | ||
534 | .round_rate = _clk_parent_round_rate, | ||
535 | .set_rate = _clk_parent_set_rate, | ||
536 | }; | ||
537 | |||
538 | static struct clk i2c_clk = { | ||
539 | .parent = &hclk, | ||
540 | .round_rate = _clk_parent_round_rate, | ||
541 | .set_rate = _clk_parent_set_rate, | ||
542 | }; | ||
543 | |||
544 | static struct clk spi_clk = { | ||
545 | .parent = &perclk[1], | ||
546 | .round_rate = _clk_parent_round_rate, | ||
547 | .set_rate = _clk_parent_set_rate, | ||
548 | }; | ||
549 | |||
550 | static struct clk sdhc_clk = { | ||
551 | .parent = &perclk[1], | ||
552 | .round_rate = _clk_parent_round_rate, | ||
553 | .set_rate = _clk_parent_set_rate, | ||
554 | }; | ||
555 | |||
556 | static struct clk lcdc_clk = { | ||
557 | .parent = &perclk[1], | ||
558 | .round_rate = _clk_parent_round_rate, | ||
559 | .set_rate = _clk_parent_set_rate, | ||
560 | }; | ||
561 | |||
562 | static struct clk mshc_clk = { | ||
563 | .parent = &hclk, | ||
564 | .round_rate = _clk_parent_round_rate, | ||
565 | .set_rate = _clk_parent_set_rate, | ||
566 | }; | ||
567 | |||
568 | static struct clk ssi_clk = { | ||
569 | .parent = &perclk[2], | ||
570 | .round_rate = _clk_parent_round_rate, | ||
571 | .set_rate = _clk_parent_set_rate, | ||
572 | }; | ||
573 | |||
574 | static struct clk rtc_clk = { | ||
575 | .parent = &clk32, | ||
576 | }; | ||
577 | |||
578 | #define _REGISTER_CLOCK(d, n, c) \ | ||
579 | { \ | ||
580 | .dev_id = d, \ | ||
581 | .con_id = n, \ | ||
582 | .clk = &c, \ | ||
583 | }, | ||
584 | static struct clk_lookup lookups[] __initdata = { | ||
585 | _REGISTER_CLOCK(NULL, "dma", dma_clk) | ||
586 | _REGISTER_CLOCK("mx1-camera.0", NULL, csi_clk) | ||
587 | _REGISTER_CLOCK(NULL, "mma", mma_clk) | ||
588 | _REGISTER_CLOCK("imx_udc.0", NULL, usbd_clk) | ||
589 | _REGISTER_CLOCK(NULL, "gpt", gpt_clk) | ||
590 | _REGISTER_CLOCK("imx1-uart.0", NULL, uart_clk) | ||
591 | _REGISTER_CLOCK("imx1-uart.1", NULL, uart_clk) | ||
592 | _REGISTER_CLOCK("imx1-uart.2", NULL, uart_clk) | ||
593 | _REGISTER_CLOCK("imx-i2c.0", NULL, i2c_clk) | ||
594 | _REGISTER_CLOCK("imx1-cspi.0", NULL, spi_clk) | ||
595 | _REGISTER_CLOCK("imx1-cspi.1", NULL, spi_clk) | ||
596 | _REGISTER_CLOCK("imx-mmc.0", NULL, sdhc_clk) | ||
597 | _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk) | ||
598 | _REGISTER_CLOCK(NULL, "mshc", mshc_clk) | ||
599 | _REGISTER_CLOCK(NULL, "ssi", ssi_clk) | ||
600 | _REGISTER_CLOCK("mxc_rtc.0", NULL, rtc_clk) | ||
601 | }; | ||
602 | |||
603 | int __init mx1_clocks_init(unsigned long fref) | ||
604 | { | ||
605 | unsigned int reg; | ||
606 | |||
607 | /* disable clocks we are able to */ | ||
608 | __raw_writel(0, SCM_GCCR); | ||
609 | |||
610 | clk32_rate = fref; | ||
611 | reg = __raw_readl(CCM_CSCR); | ||
612 | |||
613 | /* detect clock reference for system PLL */ | ||
614 | if (reg & CCM_CSCR_SYSTEM_SEL) { | ||
615 | prem_clk.parent = &clk16m; | ||
616 | } else { | ||
617 | /* ensure that oscillator is disabled */ | ||
618 | reg &= ~(1 << CCM_CSCR_OSC_EN_SHIFT); | ||
619 | __raw_writel(reg, CCM_CSCR); | ||
620 | prem_clk.parent = &clk32_premult; | ||
621 | } | ||
622 | |||
623 | /* detect reference for CLKO */ | ||
624 | reg = (reg & CCM_CSCR_CLKO_MASK) >> CCM_CSCR_CLKO_OFFSET; | ||
625 | clko_clk.parent = (struct clk *)clko_clocks[reg]; | ||
626 | |||
627 | clkdev_add_table(lookups, ARRAY_SIZE(lookups)); | ||
628 | |||
629 | clk_enable(&hclk); | ||
630 | clk_enable(&fclk); | ||
631 | |||
632 | mxc_timer_init(&gpt_clk, MX1_IO_ADDRESS(MX1_TIM1_BASE_ADDR), | ||
633 | MX1_TIM1_INT); | ||
634 | |||
635 | return 0; | ||
636 | } | ||
diff --git a/arch/arm/mach-imx/clock-imx21.c b/arch/arm/mach-imx/clock-imx21.c deleted file mode 100644 index ee15d8c9db08..000000000000 --- a/arch/arm/mach-imx/clock-imx21.c +++ /dev/null | |||
@@ -1,1239 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. | ||
3 | * Copyright 2008 Juergen Beisert, kernel@pengutronix.de | ||
4 | * Copyright 2008 Martin Fuzzey, mfuzzey@gmail.com | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version 2 | ||
9 | * of the License, or (at your option) any later version. | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
18 | * MA 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/clk.h> | ||
22 | #include <linux/io.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/clkdev.h> | ||
25 | |||
26 | #include <mach/clock.h> | ||
27 | #include <mach/hardware.h> | ||
28 | #include <mach/common.h> | ||
29 | #include <asm/div64.h> | ||
30 | |||
31 | #define IO_ADDR_CCM(off) (MX21_IO_ADDRESS(MX21_CCM_BASE_ADDR + (off))) | ||
32 | |||
33 | /* Register offsets */ | ||
34 | #define CCM_CSCR IO_ADDR_CCM(0x0) | ||
35 | #define CCM_MPCTL0 IO_ADDR_CCM(0x4) | ||
36 | #define CCM_MPCTL1 IO_ADDR_CCM(0x8) | ||
37 | #define CCM_SPCTL0 IO_ADDR_CCM(0xc) | ||
38 | #define CCM_SPCTL1 IO_ADDR_CCM(0x10) | ||
39 | #define CCM_OSC26MCTL IO_ADDR_CCM(0x14) | ||
40 | #define CCM_PCDR0 IO_ADDR_CCM(0x18) | ||
41 | #define CCM_PCDR1 IO_ADDR_CCM(0x1c) | ||
42 | #define CCM_PCCR0 IO_ADDR_CCM(0x20) | ||
43 | #define CCM_PCCR1 IO_ADDR_CCM(0x24) | ||
44 | #define CCM_CCSR IO_ADDR_CCM(0x28) | ||
45 | #define CCM_PMCTL IO_ADDR_CCM(0x2c) | ||
46 | #define CCM_PMCOUNT IO_ADDR_CCM(0x30) | ||
47 | #define CCM_WKGDCTL IO_ADDR_CCM(0x34) | ||
48 | |||
49 | #define CCM_CSCR_PRESC_OFFSET 29 | ||
50 | #define CCM_CSCR_PRESC_MASK (0x7 << CCM_CSCR_PRESC_OFFSET) | ||
51 | |||
52 | #define CCM_CSCR_USB_OFFSET 26 | ||
53 | #define CCM_CSCR_USB_MASK (0x7 << CCM_CSCR_USB_OFFSET) | ||
54 | #define CCM_CSCR_SD_OFFSET 24 | ||
55 | #define CCM_CSCR_SD_MASK (0x3 << CCM_CSCR_SD_OFFSET) | ||
56 | #define CCM_CSCR_SPLLRES (1 << 22) | ||
57 | #define CCM_CSCR_MPLLRES (1 << 21) | ||
58 | #define CCM_CSCR_SSI2_OFFSET 20 | ||
59 | #define CCM_CSCR_SSI2 (1 << CCM_CSCR_SSI2_OFFSET) | ||
60 | #define CCM_CSCR_SSI1_OFFSET 19 | ||
61 | #define CCM_CSCR_SSI1 (1 << CCM_CSCR_SSI1_OFFSET) | ||
62 | #define CCM_CSCR_FIR_OFFSET 18 | ||
63 | #define CCM_CSCR_FIR (1 << CCM_CSCR_FIR_OFFSET) | ||
64 | #define CCM_CSCR_SP (1 << 17) | ||
65 | #define CCM_CSCR_MCU (1 << 16) | ||
66 | #define CCM_CSCR_BCLK_OFFSET 10 | ||
67 | #define CCM_CSCR_BCLK_MASK (0xf << CCM_CSCR_BCLK_OFFSET) | ||
68 | #define CCM_CSCR_IPDIV_OFFSET 9 | ||
69 | #define CCM_CSCR_IPDIV (1 << CCM_CSCR_IPDIV_OFFSET) | ||
70 | |||
71 | #define CCM_CSCR_OSC26MDIV (1 << 4) | ||
72 | #define CCM_CSCR_OSC26M (1 << 3) | ||
73 | #define CCM_CSCR_FPM (1 << 2) | ||
74 | #define CCM_CSCR_SPEN (1 << 1) | ||
75 | #define CCM_CSCR_MPEN 1 | ||
76 | |||
77 | #define CCM_MPCTL0_CPLM (1 << 31) | ||
78 | #define CCM_MPCTL0_PD_OFFSET 26 | ||
79 | #define CCM_MPCTL0_PD_MASK (0xf << 26) | ||
80 | #define CCM_MPCTL0_MFD_OFFSET 16 | ||
81 | #define CCM_MPCTL0_MFD_MASK (0x3ff << 16) | ||
82 | #define CCM_MPCTL0_MFI_OFFSET 10 | ||
83 | #define CCM_MPCTL0_MFI_MASK (0xf << 10) | ||
84 | #define CCM_MPCTL0_MFN_OFFSET 0 | ||
85 | #define CCM_MPCTL0_MFN_MASK 0x3ff | ||
86 | |||
87 | #define CCM_MPCTL1_LF (1 << 15) | ||
88 | #define CCM_MPCTL1_BRMO (1 << 6) | ||
89 | |||
90 | #define CCM_SPCTL0_CPLM (1 << 31) | ||
91 | #define CCM_SPCTL0_PD_OFFSET 26 | ||
92 | #define CCM_SPCTL0_PD_MASK (0xf << 26) | ||
93 | #define CCM_SPCTL0_MFD_OFFSET 16 | ||
94 | #define CCM_SPCTL0_MFD_MASK (0x3ff << 16) | ||
95 | #define CCM_SPCTL0_MFI_OFFSET 10 | ||
96 | #define CCM_SPCTL0_MFI_MASK (0xf << 10) | ||
97 | #define CCM_SPCTL0_MFN_OFFSET 0 | ||
98 | #define CCM_SPCTL0_MFN_MASK 0x3ff | ||
99 | |||
100 | #define CCM_SPCTL1_LF (1 << 15) | ||
101 | #define CCM_SPCTL1_BRMO (1 << 6) | ||
102 | |||
103 | #define CCM_OSC26MCTL_PEAK_OFFSET 16 | ||
104 | #define CCM_OSC26MCTL_PEAK_MASK (0x3 << 16) | ||
105 | #define CCM_OSC26MCTL_AGC_OFFSET 8 | ||
106 | #define CCM_OSC26MCTL_AGC_MASK (0x3f << 8) | ||
107 | #define CCM_OSC26MCTL_ANATEST_OFFSET 0 | ||
108 | #define CCM_OSC26MCTL_ANATEST_MASK 0x3f | ||
109 | |||
110 | #define CCM_PCDR0_SSI2BAUDDIV_OFFSET 26 | ||
111 | #define CCM_PCDR0_SSI2BAUDDIV_MASK (0x3f << 26) | ||
112 | #define CCM_PCDR0_SSI1BAUDDIV_OFFSET 16 | ||
113 | #define CCM_PCDR0_SSI1BAUDDIV_MASK (0x3f << 16) | ||
114 | #define CCM_PCDR0_NFCDIV_OFFSET 12 | ||
115 | #define CCM_PCDR0_NFCDIV_MASK (0xf << 12) | ||
116 | #define CCM_PCDR0_48MDIV_OFFSET 5 | ||
117 | #define CCM_PCDR0_48MDIV_MASK (0x7 << CCM_PCDR0_48MDIV_OFFSET) | ||
118 | #define CCM_PCDR0_FIRIDIV_OFFSET 0 | ||
119 | #define CCM_PCDR0_FIRIDIV_MASK 0x1f | ||
120 | #define CCM_PCDR1_PERDIV4_OFFSET 24 | ||
121 | #define CCM_PCDR1_PERDIV4_MASK (0x3f << 24) | ||
122 | #define CCM_PCDR1_PERDIV3_OFFSET 16 | ||
123 | #define CCM_PCDR1_PERDIV3_MASK (0x3f << 16) | ||
124 | #define CCM_PCDR1_PERDIV2_OFFSET 8 | ||
125 | #define CCM_PCDR1_PERDIV2_MASK (0x3f << 8) | ||
126 | #define CCM_PCDR1_PERDIV1_OFFSET 0 | ||
127 | #define CCM_PCDR1_PERDIV1_MASK 0x3f | ||
128 | |||
129 | #define CCM_PCCR_HCLK_CSI_OFFSET 31 | ||
130 | #define CCM_PCCR_HCLK_CSI_REG CCM_PCCR0 | ||
131 | #define CCM_PCCR_HCLK_DMA_OFFSET 30 | ||
132 | #define CCM_PCCR_HCLK_DMA_REG CCM_PCCR0 | ||
133 | #define CCM_PCCR_HCLK_BROM_OFFSET 28 | ||
134 | #define CCM_PCCR_HCLK_BROM_REG CCM_PCCR0 | ||
135 | #define CCM_PCCR_HCLK_EMMA_OFFSET 27 | ||
136 | #define CCM_PCCR_HCLK_EMMA_REG CCM_PCCR0 | ||
137 | #define CCM_PCCR_HCLK_LCDC_OFFSET 26 | ||
138 | #define CCM_PCCR_HCLK_LCDC_REG CCM_PCCR0 | ||
139 | #define CCM_PCCR_HCLK_SLCDC_OFFSET 25 | ||
140 | #define CCM_PCCR_HCLK_SLCDC_REG CCM_PCCR0 | ||
141 | #define CCM_PCCR_HCLK_USBOTG_OFFSET 24 | ||
142 | #define CCM_PCCR_HCLK_USBOTG_REG CCM_PCCR0 | ||
143 | #define CCM_PCCR_HCLK_BMI_OFFSET 23 | ||
144 | #define CCM_PCCR_BMI_MASK (1 << CCM_PCCR_BMI_MASK) | ||
145 | #define CCM_PCCR_HCLK_BMI_REG CCM_PCCR0 | ||
146 | #define CCM_PCCR_PERCLK4_OFFSET 22 | ||
147 | #define CCM_PCCR_PERCLK4_REG CCM_PCCR0 | ||
148 | #define CCM_PCCR_SLCDC_OFFSET 21 | ||
149 | #define CCM_PCCR_SLCDC_REG CCM_PCCR0 | ||
150 | #define CCM_PCCR_FIRI_BAUD_OFFSET 20 | ||
151 | #define CCM_PCCR_FIRI_BAUD_MASK (1 << CCM_PCCR_FIRI_BAUD_MASK) | ||
152 | #define CCM_PCCR_FIRI_BAUD_REG CCM_PCCR0 | ||
153 | #define CCM_PCCR_NFC_OFFSET 19 | ||
154 | #define CCM_PCCR_NFC_REG CCM_PCCR0 | ||
155 | #define CCM_PCCR_LCDC_OFFSET 18 | ||
156 | #define CCM_PCCR_LCDC_REG CCM_PCCR0 | ||
157 | #define CCM_PCCR_SSI1_BAUD_OFFSET 17 | ||
158 | #define CCM_PCCR_SSI1_BAUD_REG CCM_PCCR0 | ||
159 | #define CCM_PCCR_SSI2_BAUD_OFFSET 16 | ||
160 | #define CCM_PCCR_SSI2_BAUD_REG CCM_PCCR0 | ||
161 | #define CCM_PCCR_EMMA_OFFSET 15 | ||
162 | #define CCM_PCCR_EMMA_REG CCM_PCCR0 | ||
163 | #define CCM_PCCR_USBOTG_OFFSET 14 | ||
164 | #define CCM_PCCR_USBOTG_REG CCM_PCCR0 | ||
165 | #define CCM_PCCR_DMA_OFFSET 13 | ||
166 | #define CCM_PCCR_DMA_REG CCM_PCCR0 | ||
167 | #define CCM_PCCR_I2C1_OFFSET 12 | ||
168 | #define CCM_PCCR_I2C1_REG CCM_PCCR0 | ||
169 | #define CCM_PCCR_GPIO_OFFSET 11 | ||
170 | #define CCM_PCCR_GPIO_REG CCM_PCCR0 | ||
171 | #define CCM_PCCR_SDHC2_OFFSET 10 | ||
172 | #define CCM_PCCR_SDHC2_REG CCM_PCCR0 | ||
173 | #define CCM_PCCR_SDHC1_OFFSET 9 | ||
174 | #define CCM_PCCR_SDHC1_REG CCM_PCCR0 | ||
175 | #define CCM_PCCR_FIRI_OFFSET 8 | ||
176 | #define CCM_PCCR_FIRI_MASK (1 << CCM_PCCR_BAUD_MASK) | ||
177 | #define CCM_PCCR_FIRI_REG CCM_PCCR0 | ||
178 | #define CCM_PCCR_SSI2_IPG_OFFSET 7 | ||
179 | #define CCM_PCCR_SSI2_REG CCM_PCCR0 | ||
180 | #define CCM_PCCR_SSI1_IPG_OFFSET 6 | ||
181 | #define CCM_PCCR_SSI1_REG CCM_PCCR0 | ||
182 | #define CCM_PCCR_CSPI2_OFFSET 5 | ||
183 | #define CCM_PCCR_CSPI2_REG CCM_PCCR0 | ||
184 | #define CCM_PCCR_CSPI1_OFFSET 4 | ||
185 | #define CCM_PCCR_CSPI1_REG CCM_PCCR0 | ||
186 | #define CCM_PCCR_UART4_OFFSET 3 | ||
187 | #define CCM_PCCR_UART4_REG CCM_PCCR0 | ||
188 | #define CCM_PCCR_UART3_OFFSET 2 | ||
189 | #define CCM_PCCR_UART3_REG CCM_PCCR0 | ||
190 | #define CCM_PCCR_UART2_OFFSET 1 | ||
191 | #define CCM_PCCR_UART2_REG CCM_PCCR0 | ||
192 | #define CCM_PCCR_UART1_OFFSET 0 | ||
193 | #define CCM_PCCR_UART1_REG CCM_PCCR0 | ||
194 | |||
195 | #define CCM_PCCR_OWIRE_OFFSET 31 | ||
196 | #define CCM_PCCR_OWIRE_REG CCM_PCCR1 | ||
197 | #define CCM_PCCR_KPP_OFFSET 30 | ||
198 | #define CCM_PCCR_KPP_REG CCM_PCCR1 | ||
199 | #define CCM_PCCR_RTC_OFFSET 29 | ||
200 | #define CCM_PCCR_RTC_REG CCM_PCCR1 | ||
201 | #define CCM_PCCR_PWM_OFFSET 28 | ||
202 | #define CCM_PCCR_PWM_REG CCM_PCCR1 | ||
203 | #define CCM_PCCR_GPT3_OFFSET 27 | ||
204 | #define CCM_PCCR_GPT3_REG CCM_PCCR1 | ||
205 | #define CCM_PCCR_GPT2_OFFSET 26 | ||
206 | #define CCM_PCCR_GPT2_REG CCM_PCCR1 | ||
207 | #define CCM_PCCR_GPT1_OFFSET 25 | ||
208 | #define CCM_PCCR_GPT1_REG CCM_PCCR1 | ||
209 | #define CCM_PCCR_WDT_OFFSET 24 | ||
210 | #define CCM_PCCR_WDT_REG CCM_PCCR1 | ||
211 | #define CCM_PCCR_CSPI3_OFFSET 23 | ||
212 | #define CCM_PCCR_CSPI3_REG CCM_PCCR1 | ||
213 | |||
214 | #define CCM_PCCR_CSPI1_MASK (1 << CCM_PCCR_CSPI1_OFFSET) | ||
215 | #define CCM_PCCR_CSPI2_MASK (1 << CCM_PCCR_CSPI2_OFFSET) | ||
216 | #define CCM_PCCR_CSPI3_MASK (1 << CCM_PCCR_CSPI3_OFFSET) | ||
217 | #define CCM_PCCR_DMA_MASK (1 << CCM_PCCR_DMA_OFFSET) | ||
218 | #define CCM_PCCR_EMMA_MASK (1 << CCM_PCCR_EMMA_OFFSET) | ||
219 | #define CCM_PCCR_GPIO_MASK (1 << CCM_PCCR_GPIO_OFFSET) | ||
220 | #define CCM_PCCR_GPT1_MASK (1 << CCM_PCCR_GPT1_OFFSET) | ||
221 | #define CCM_PCCR_GPT2_MASK (1 << CCM_PCCR_GPT2_OFFSET) | ||
222 | #define CCM_PCCR_GPT3_MASK (1 << CCM_PCCR_GPT3_OFFSET) | ||
223 | #define CCM_PCCR_HCLK_BROM_MASK (1 << CCM_PCCR_HCLK_BROM_OFFSET) | ||
224 | #define CCM_PCCR_HCLK_CSI_MASK (1 << CCM_PCCR_HCLK_CSI_OFFSET) | ||
225 | #define CCM_PCCR_HCLK_DMA_MASK (1 << CCM_PCCR_HCLK_DMA_OFFSET) | ||
226 | #define CCM_PCCR_HCLK_EMMA_MASK (1 << CCM_PCCR_HCLK_EMMA_OFFSET) | ||
227 | #define CCM_PCCR_HCLK_LCDC_MASK (1 << CCM_PCCR_HCLK_LCDC_OFFSET) | ||
228 | #define CCM_PCCR_HCLK_SLCDC_MASK (1 << CCM_PCCR_HCLK_SLCDC_OFFSET) | ||
229 | #define CCM_PCCR_HCLK_USBOTG_MASK (1 << CCM_PCCR_HCLK_USBOTG_OFFSET) | ||
230 | #define CCM_PCCR_I2C1_MASK (1 << CCM_PCCR_I2C1_OFFSET) | ||
231 | #define CCM_PCCR_KPP_MASK (1 << CCM_PCCR_KPP_OFFSET) | ||
232 | #define CCM_PCCR_LCDC_MASK (1 << CCM_PCCR_LCDC_OFFSET) | ||
233 | #define CCM_PCCR_NFC_MASK (1 << CCM_PCCR_NFC_OFFSET) | ||
234 | #define CCM_PCCR_OWIRE_MASK (1 << CCM_PCCR_OWIRE_OFFSET) | ||
235 | #define CCM_PCCR_PERCLK4_MASK (1 << CCM_PCCR_PERCLK4_OFFSET) | ||
236 | #define CCM_PCCR_PWM_MASK (1 << CCM_PCCR_PWM_OFFSET) | ||
237 | #define CCM_PCCR_RTC_MASK (1 << CCM_PCCR_RTC_OFFSET) | ||
238 | #define CCM_PCCR_SDHC1_MASK (1 << CCM_PCCR_SDHC1_OFFSET) | ||
239 | #define CCM_PCCR_SDHC2_MASK (1 << CCM_PCCR_SDHC2_OFFSET) | ||
240 | #define CCM_PCCR_SLCDC_MASK (1 << CCM_PCCR_SLCDC_OFFSET) | ||
241 | #define CCM_PCCR_SSI1_BAUD_MASK (1 << CCM_PCCR_SSI1_BAUD_OFFSET) | ||
242 | #define CCM_PCCR_SSI1_IPG_MASK (1 << CCM_PCCR_SSI1_IPG_OFFSET) | ||
243 | #define CCM_PCCR_SSI2_BAUD_MASK (1 << CCM_PCCR_SSI2_BAUD_OFFSET) | ||
244 | #define CCM_PCCR_SSI2_IPG_MASK (1 << CCM_PCCR_SSI2_IPG_OFFSET) | ||
245 | #define CCM_PCCR_UART1_MASK (1 << CCM_PCCR_UART1_OFFSET) | ||
246 | #define CCM_PCCR_UART2_MASK (1 << CCM_PCCR_UART2_OFFSET) | ||
247 | #define CCM_PCCR_UART3_MASK (1 << CCM_PCCR_UART3_OFFSET) | ||
248 | #define CCM_PCCR_UART4_MASK (1 << CCM_PCCR_UART4_OFFSET) | ||
249 | #define CCM_PCCR_USBOTG_MASK (1 << CCM_PCCR_USBOTG_OFFSET) | ||
250 | #define CCM_PCCR_WDT_MASK (1 << CCM_PCCR_WDT_OFFSET) | ||
251 | |||
252 | #define CCM_CCSR_32KSR (1 << 15) | ||
253 | |||
254 | #define CCM_CCSR_CLKMODE1 (1 << 9) | ||
255 | #define CCM_CCSR_CLKMODE0 (1 << 8) | ||
256 | |||
257 | #define CCM_CCSR_CLKOSEL_OFFSET 0 | ||
258 | #define CCM_CCSR_CLKOSEL_MASK 0x1f | ||
259 | |||
260 | #define SYS_FMCR 0x14 /* Functional Muxing Control Reg */ | ||
261 | #define SYS_CHIP_ID 0x00 /* The offset of CHIP ID register */ | ||
262 | |||
263 | static int _clk_enable(struct clk *clk) | ||
264 | { | ||
265 | u32 reg; | ||
266 | |||
267 | reg = __raw_readl(clk->enable_reg); | ||
268 | reg |= 1 << clk->enable_shift; | ||
269 | __raw_writel(reg, clk->enable_reg); | ||
270 | return 0; | ||
271 | } | ||
272 | |||
273 | static void _clk_disable(struct clk *clk) | ||
274 | { | ||
275 | u32 reg; | ||
276 | |||
277 | reg = __raw_readl(clk->enable_reg); | ||
278 | reg &= ~(1 << clk->enable_shift); | ||
279 | __raw_writel(reg, clk->enable_reg); | ||
280 | } | ||
281 | |||
282 | static unsigned long _clk_generic_round_rate(struct clk *clk, | ||
283 | unsigned long rate, | ||
284 | u32 max_divisor) | ||
285 | { | ||
286 | u32 div; | ||
287 | unsigned long parent_rate; | ||
288 | |||
289 | parent_rate = clk_get_rate(clk->parent); | ||
290 | |||
291 | div = parent_rate / rate; | ||
292 | if (parent_rate % rate) | ||
293 | div++; | ||
294 | |||
295 | if (div > max_divisor) | ||
296 | div = max_divisor; | ||
297 | |||
298 | return parent_rate / div; | ||
299 | } | ||
300 | |||
301 | static int _clk_spll_enable(struct clk *clk) | ||
302 | { | ||
303 | u32 reg; | ||
304 | |||
305 | reg = __raw_readl(CCM_CSCR); | ||
306 | reg |= CCM_CSCR_SPEN; | ||
307 | __raw_writel(reg, CCM_CSCR); | ||
308 | |||
309 | while ((__raw_readl(CCM_SPCTL1) & CCM_SPCTL1_LF) == 0) | ||
310 | ; | ||
311 | return 0; | ||
312 | } | ||
313 | |||
314 | static void _clk_spll_disable(struct clk *clk) | ||
315 | { | ||
316 | u32 reg; | ||
317 | |||
318 | reg = __raw_readl(CCM_CSCR); | ||
319 | reg &= ~CCM_CSCR_SPEN; | ||
320 | __raw_writel(reg, CCM_CSCR); | ||
321 | } | ||
322 | |||
323 | |||
324 | #define CSCR() (__raw_readl(CCM_CSCR)) | ||
325 | #define PCDR0() (__raw_readl(CCM_PCDR0)) | ||
326 | #define PCDR1() (__raw_readl(CCM_PCDR1)) | ||
327 | |||
328 | static unsigned long _clk_perclkx_round_rate(struct clk *clk, | ||
329 | unsigned long rate) | ||
330 | { | ||
331 | return _clk_generic_round_rate(clk, rate, 64); | ||
332 | } | ||
333 | |||
334 | static int _clk_perclkx_set_rate(struct clk *clk, unsigned long rate) | ||
335 | { | ||
336 | u32 reg; | ||
337 | u32 div; | ||
338 | unsigned long parent_rate; | ||
339 | |||
340 | parent_rate = clk_get_rate(clk->parent); | ||
341 | |||
342 | if (clk->id < 0 || clk->id > 3) | ||
343 | return -EINVAL; | ||
344 | |||
345 | div = parent_rate / rate; | ||
346 | if (div > 64 || div < 1 || ((parent_rate / div) != rate)) | ||
347 | return -EINVAL; | ||
348 | div--; | ||
349 | |||
350 | reg = | ||
351 | __raw_readl(CCM_PCDR1) & ~(CCM_PCDR1_PERDIV1_MASK << | ||
352 | (clk->id << 3)); | ||
353 | reg |= div << (clk->id << 3); | ||
354 | __raw_writel(reg, CCM_PCDR1); | ||
355 | |||
356 | return 0; | ||
357 | } | ||
358 | |||
359 | static unsigned long _clk_usb_recalc(struct clk *clk) | ||
360 | { | ||
361 | unsigned long usb_pdf; | ||
362 | unsigned long parent_rate; | ||
363 | |||
364 | parent_rate = clk_get_rate(clk->parent); | ||
365 | |||
366 | usb_pdf = (CSCR() & CCM_CSCR_USB_MASK) >> CCM_CSCR_USB_OFFSET; | ||
367 | |||
368 | return parent_rate / (usb_pdf + 1U); | ||
369 | } | ||
370 | |||
371 | static unsigned long _clk_usb_round_rate(struct clk *clk, | ||
372 | unsigned long rate) | ||
373 | { | ||
374 | return _clk_generic_round_rate(clk, rate, 8); | ||
375 | } | ||
376 | |||
377 | static int _clk_usb_set_rate(struct clk *clk, unsigned long rate) | ||
378 | { | ||
379 | u32 reg; | ||
380 | u32 div; | ||
381 | unsigned long parent_rate; | ||
382 | |||
383 | parent_rate = clk_get_rate(clk->parent); | ||
384 | |||
385 | div = parent_rate / rate; | ||
386 | if (div > 8 || div < 1 || ((parent_rate / div) != rate)) | ||
387 | return -EINVAL; | ||
388 | div--; | ||
389 | |||
390 | reg = CSCR() & ~CCM_CSCR_USB_MASK; | ||
391 | reg |= div << CCM_CSCR_USB_OFFSET; | ||
392 | __raw_writel(reg, CCM_CSCR); | ||
393 | |||
394 | return 0; | ||
395 | } | ||
396 | |||
397 | static unsigned long _clk_ssix_recalc(struct clk *clk, unsigned long pdf) | ||
398 | { | ||
399 | unsigned long parent_rate; | ||
400 | |||
401 | parent_rate = clk_get_rate(clk->parent); | ||
402 | |||
403 | pdf = (pdf < 2) ? 124UL : pdf; /* MX21 & MX27 TO1 */ | ||
404 | |||
405 | return 2UL * parent_rate / pdf; | ||
406 | } | ||
407 | |||
408 | static unsigned long _clk_ssi1_recalc(struct clk *clk) | ||
409 | { | ||
410 | return _clk_ssix_recalc(clk, | ||
411 | (PCDR0() & CCM_PCDR0_SSI1BAUDDIV_MASK) | ||
412 | >> CCM_PCDR0_SSI1BAUDDIV_OFFSET); | ||
413 | } | ||
414 | |||
415 | static unsigned long _clk_ssi2_recalc(struct clk *clk) | ||
416 | { | ||
417 | return _clk_ssix_recalc(clk, | ||
418 | (PCDR0() & CCM_PCDR0_SSI2BAUDDIV_MASK) >> | ||
419 | CCM_PCDR0_SSI2BAUDDIV_OFFSET); | ||
420 | } | ||
421 | |||
422 | static unsigned long _clk_nfc_recalc(struct clk *clk) | ||
423 | { | ||
424 | unsigned long nfc_pdf; | ||
425 | unsigned long parent_rate; | ||
426 | |||
427 | parent_rate = clk_get_rate(clk->parent); | ||
428 | |||
429 | nfc_pdf = (PCDR0() & CCM_PCDR0_NFCDIV_MASK) | ||
430 | >> CCM_PCDR0_NFCDIV_OFFSET; | ||
431 | |||
432 | return parent_rate / (nfc_pdf + 1); | ||
433 | } | ||
434 | |||
435 | static unsigned long _clk_parent_round_rate(struct clk *clk, unsigned long rate) | ||
436 | { | ||
437 | return clk->parent->round_rate(clk->parent, rate); | ||
438 | } | ||
439 | |||
440 | static int _clk_parent_set_rate(struct clk *clk, unsigned long rate) | ||
441 | { | ||
442 | return clk->parent->set_rate(clk->parent, rate); | ||
443 | } | ||
444 | |||
445 | static unsigned long external_high_reference; /* in Hz */ | ||
446 | |||
447 | static unsigned long get_high_reference_clock_rate(struct clk *clk) | ||
448 | { | ||
449 | return external_high_reference; | ||
450 | } | ||
451 | |||
452 | /* | ||
453 | * the high frequency external clock reference | ||
454 | * Default case is 26MHz. | ||
455 | */ | ||
456 | static struct clk ckih_clk = { | ||
457 | .get_rate = get_high_reference_clock_rate, | ||
458 | }; | ||
459 | |||
460 | static unsigned long external_low_reference; /* in Hz */ | ||
461 | |||
462 | static unsigned long get_low_reference_clock_rate(struct clk *clk) | ||
463 | { | ||
464 | return external_low_reference; | ||
465 | } | ||
466 | |||
467 | /* | ||
468 | * the low frequency external clock reference | ||
469 | * Default case is 32.768kHz. | ||
470 | */ | ||
471 | static struct clk ckil_clk = { | ||
472 | .get_rate = get_low_reference_clock_rate, | ||
473 | }; | ||
474 | |||
475 | |||
476 | static unsigned long _clk_fpm_recalc(struct clk *clk) | ||
477 | { | ||
478 | return clk_get_rate(clk->parent) * 512; | ||
479 | } | ||
480 | |||
481 | /* Output of frequency pre multiplier */ | ||
482 | static struct clk fpm_clk = { | ||
483 | .parent = &ckil_clk, | ||
484 | .get_rate = _clk_fpm_recalc, | ||
485 | }; | ||
486 | |||
487 | static unsigned long get_mpll_clk(struct clk *clk) | ||
488 | { | ||
489 | uint32_t reg; | ||
490 | unsigned long ref_clk; | ||
491 | unsigned long mfi = 0, mfn = 0, mfd = 0, pdf = 0; | ||
492 | unsigned long long temp; | ||
493 | |||
494 | ref_clk = clk_get_rate(clk->parent); | ||
495 | |||
496 | reg = __raw_readl(CCM_MPCTL0); | ||
497 | pdf = (reg & CCM_MPCTL0_PD_MASK) >> CCM_MPCTL0_PD_OFFSET; | ||
498 | mfd = (reg & CCM_MPCTL0_MFD_MASK) >> CCM_MPCTL0_MFD_OFFSET; | ||
499 | mfi = (reg & CCM_MPCTL0_MFI_MASK) >> CCM_MPCTL0_MFI_OFFSET; | ||
500 | mfn = (reg & CCM_MPCTL0_MFN_MASK) >> CCM_MPCTL0_MFN_OFFSET; | ||
501 | |||
502 | mfi = (mfi <= 5) ? 5 : mfi; | ||
503 | temp = 2LL * ref_clk * mfn; | ||
504 | do_div(temp, mfd + 1); | ||
505 | temp = 2LL * ref_clk * mfi + temp; | ||
506 | do_div(temp, pdf + 1); | ||
507 | |||
508 | return (unsigned long)temp; | ||
509 | } | ||
510 | |||
511 | static struct clk mpll_clk = { | ||
512 | .parent = &ckih_clk, | ||
513 | .get_rate = get_mpll_clk, | ||
514 | }; | ||
515 | |||
516 | static unsigned long _clk_fclk_get_rate(struct clk *clk) | ||
517 | { | ||
518 | unsigned long parent_rate; | ||
519 | u32 div; | ||
520 | |||
521 | div = (CSCR() & CCM_CSCR_PRESC_MASK) >> CCM_CSCR_PRESC_OFFSET; | ||
522 | parent_rate = clk_get_rate(clk->parent); | ||
523 | |||
524 | return parent_rate / (div+1); | ||
525 | } | ||
526 | |||
527 | static struct clk fclk_clk = { | ||
528 | .parent = &mpll_clk, | ||
529 | .get_rate = _clk_fclk_get_rate | ||
530 | }; | ||
531 | |||
532 | static unsigned long get_spll_clk(struct clk *clk) | ||
533 | { | ||
534 | uint32_t reg; | ||
535 | unsigned long ref_clk; | ||
536 | unsigned long mfi = 0, mfn = 0, mfd = 0, pdf = 0; | ||
537 | unsigned long long temp; | ||
538 | |||
539 | ref_clk = clk_get_rate(clk->parent); | ||
540 | |||
541 | reg = __raw_readl(CCM_SPCTL0); | ||
542 | pdf = (reg & CCM_SPCTL0_PD_MASK) >> CCM_SPCTL0_PD_OFFSET; | ||
543 | mfd = (reg & CCM_SPCTL0_MFD_MASK) >> CCM_SPCTL0_MFD_OFFSET; | ||
544 | mfi = (reg & CCM_SPCTL0_MFI_MASK) >> CCM_SPCTL0_MFI_OFFSET; | ||
545 | mfn = (reg & CCM_SPCTL0_MFN_MASK) >> CCM_SPCTL0_MFN_OFFSET; | ||
546 | |||
547 | mfi = (mfi <= 5) ? 5 : mfi; | ||
548 | temp = 2LL * ref_clk * mfn; | ||
549 | do_div(temp, mfd + 1); | ||
550 | temp = 2LL * ref_clk * mfi + temp; | ||
551 | do_div(temp, pdf + 1); | ||
552 | |||
553 | return (unsigned long)temp; | ||
554 | } | ||
555 | |||
556 | static struct clk spll_clk = { | ||
557 | .parent = &ckih_clk, | ||
558 | .get_rate = get_spll_clk, | ||
559 | .enable = _clk_spll_enable, | ||
560 | .disable = _clk_spll_disable, | ||
561 | }; | ||
562 | |||
563 | static unsigned long get_hclk_clk(struct clk *clk) | ||
564 | { | ||
565 | unsigned long rate; | ||
566 | unsigned long bclk_pdf; | ||
567 | |||
568 | bclk_pdf = (CSCR() & CCM_CSCR_BCLK_MASK) | ||
569 | >> CCM_CSCR_BCLK_OFFSET; | ||
570 | |||
571 | rate = clk_get_rate(clk->parent); | ||
572 | return rate / (bclk_pdf + 1); | ||
573 | } | ||
574 | |||
575 | static struct clk hclk_clk = { | ||
576 | .parent = &fclk_clk, | ||
577 | .get_rate = get_hclk_clk, | ||
578 | }; | ||
579 | |||
580 | static unsigned long get_ipg_clk(struct clk *clk) | ||
581 | { | ||
582 | unsigned long rate; | ||
583 | unsigned long ipg_pdf; | ||
584 | |||
585 | ipg_pdf = (CSCR() & CCM_CSCR_IPDIV) >> CCM_CSCR_IPDIV_OFFSET; | ||
586 | |||
587 | rate = clk_get_rate(clk->parent); | ||
588 | return rate / (ipg_pdf + 1); | ||
589 | } | ||
590 | |||
591 | static struct clk ipg_clk = { | ||
592 | .parent = &hclk_clk, | ||
593 | .get_rate = get_ipg_clk, | ||
594 | }; | ||
595 | |||
596 | static unsigned long _clk_perclkx_recalc(struct clk *clk) | ||
597 | { | ||
598 | unsigned long perclk_pdf; | ||
599 | unsigned long parent_rate; | ||
600 | |||
601 | parent_rate = clk_get_rate(clk->parent); | ||
602 | |||
603 | if (clk->id < 0 || clk->id > 3) | ||
604 | return 0; | ||
605 | |||
606 | perclk_pdf = (PCDR1() >> (clk->id << 3)) & CCM_PCDR1_PERDIV1_MASK; | ||
607 | |||
608 | return parent_rate / (perclk_pdf + 1); | ||
609 | } | ||
610 | |||
611 | static struct clk per_clk[] = { | ||
612 | { | ||
613 | .id = 0, | ||
614 | .parent = &mpll_clk, | ||
615 | .get_rate = _clk_perclkx_recalc, | ||
616 | }, { | ||
617 | .id = 1, | ||
618 | .parent = &mpll_clk, | ||
619 | .get_rate = _clk_perclkx_recalc, | ||
620 | }, { | ||
621 | .id = 2, | ||
622 | .parent = &mpll_clk, | ||
623 | .round_rate = _clk_perclkx_round_rate, | ||
624 | .set_rate = _clk_perclkx_set_rate, | ||
625 | .get_rate = _clk_perclkx_recalc, | ||
626 | /* Enable/Disable done via lcd_clkc[1] */ | ||
627 | }, { | ||
628 | .id = 3, | ||
629 | .parent = &mpll_clk, | ||
630 | .round_rate = _clk_perclkx_round_rate, | ||
631 | .set_rate = _clk_perclkx_set_rate, | ||
632 | .get_rate = _clk_perclkx_recalc, | ||
633 | /* Enable/Disable done via csi_clk[1] */ | ||
634 | }, | ||
635 | }; | ||
636 | |||
637 | static struct clk uart_ipg_clk[]; | ||
638 | |||
639 | static struct clk uart_clk[] = { | ||
640 | { | ||
641 | .id = 0, | ||
642 | .parent = &per_clk[0], | ||
643 | .secondary = &uart_ipg_clk[0], | ||
644 | }, { | ||
645 | .id = 1, | ||
646 | .parent = &per_clk[0], | ||
647 | .secondary = &uart_ipg_clk[1], | ||
648 | }, { | ||
649 | .id = 2, | ||
650 | .parent = &per_clk[0], | ||
651 | .secondary = &uart_ipg_clk[2], | ||
652 | }, { | ||
653 | .id = 3, | ||
654 | .parent = &per_clk[0], | ||
655 | .secondary = &uart_ipg_clk[3], | ||
656 | }, | ||
657 | }; | ||
658 | |||
659 | static struct clk uart_ipg_clk[] = { | ||
660 | { | ||
661 | .id = 0, | ||
662 | .parent = &ipg_clk, | ||
663 | .enable = _clk_enable, | ||
664 | .enable_reg = CCM_PCCR_UART1_REG, | ||
665 | .enable_shift = CCM_PCCR_UART1_OFFSET, | ||
666 | .disable = _clk_disable, | ||
667 | }, { | ||
668 | .id = 1, | ||
669 | .parent = &ipg_clk, | ||
670 | .enable = _clk_enable, | ||
671 | .enable_reg = CCM_PCCR_UART2_REG, | ||
672 | .enable_shift = CCM_PCCR_UART2_OFFSET, | ||
673 | .disable = _clk_disable, | ||
674 | }, { | ||
675 | .id = 2, | ||
676 | .parent = &ipg_clk, | ||
677 | .enable = _clk_enable, | ||
678 | .enable_reg = CCM_PCCR_UART3_REG, | ||
679 | .enable_shift = CCM_PCCR_UART3_OFFSET, | ||
680 | .disable = _clk_disable, | ||
681 | }, { | ||
682 | .id = 3, | ||
683 | .parent = &ipg_clk, | ||
684 | .enable = _clk_enable, | ||
685 | .enable_reg = CCM_PCCR_UART4_REG, | ||
686 | .enable_shift = CCM_PCCR_UART4_OFFSET, | ||
687 | .disable = _clk_disable, | ||
688 | }, | ||
689 | }; | ||
690 | |||
691 | static struct clk gpt_ipg_clk[]; | ||
692 | |||
693 | static struct clk gpt_clk[] = { | ||
694 | { | ||
695 | .id = 0, | ||
696 | .parent = &per_clk[0], | ||
697 | .secondary = &gpt_ipg_clk[0], | ||
698 | }, { | ||
699 | .id = 1, | ||
700 | .parent = &per_clk[0], | ||
701 | .secondary = &gpt_ipg_clk[1], | ||
702 | }, { | ||
703 | .id = 2, | ||
704 | .parent = &per_clk[0], | ||
705 | .secondary = &gpt_ipg_clk[2], | ||
706 | }, | ||
707 | }; | ||
708 | |||
709 | static struct clk gpt_ipg_clk[] = { | ||
710 | { | ||
711 | .id = 0, | ||
712 | .parent = &ipg_clk, | ||
713 | .enable = _clk_enable, | ||
714 | .enable_reg = CCM_PCCR_GPT1_REG, | ||
715 | .enable_shift = CCM_PCCR_GPT1_OFFSET, | ||
716 | .disable = _clk_disable, | ||
717 | }, { | ||
718 | .id = 1, | ||
719 | .parent = &ipg_clk, | ||
720 | .enable = _clk_enable, | ||
721 | .enable_reg = CCM_PCCR_GPT2_REG, | ||
722 | .enable_shift = CCM_PCCR_GPT2_OFFSET, | ||
723 | .disable = _clk_disable, | ||
724 | }, { | ||
725 | .id = 2, | ||
726 | .parent = &ipg_clk, | ||
727 | .enable = _clk_enable, | ||
728 | .enable_reg = CCM_PCCR_GPT3_REG, | ||
729 | .enable_shift = CCM_PCCR_GPT3_OFFSET, | ||
730 | .disable = _clk_disable, | ||
731 | }, | ||
732 | }; | ||
733 | |||
734 | static struct clk pwm_clk[] = { | ||
735 | { | ||
736 | .parent = &per_clk[0], | ||
737 | .secondary = &pwm_clk[1], | ||
738 | }, { | ||
739 | .parent = &ipg_clk, | ||
740 | .enable = _clk_enable, | ||
741 | .enable_reg = CCM_PCCR_PWM_REG, | ||
742 | .enable_shift = CCM_PCCR_PWM_OFFSET, | ||
743 | .disable = _clk_disable, | ||
744 | }, | ||
745 | }; | ||
746 | |||
747 | static struct clk sdhc_ipg_clk[]; | ||
748 | |||
749 | static struct clk sdhc_clk[] = { | ||
750 | { | ||
751 | .id = 0, | ||
752 | .parent = &per_clk[1], | ||
753 | .secondary = &sdhc_ipg_clk[0], | ||
754 | }, { | ||
755 | .id = 1, | ||
756 | .parent = &per_clk[1], | ||
757 | .secondary = &sdhc_ipg_clk[1], | ||
758 | }, | ||
759 | }; | ||
760 | |||
761 | static struct clk sdhc_ipg_clk[] = { | ||
762 | { | ||
763 | .id = 0, | ||
764 | .parent = &ipg_clk, | ||
765 | .enable = _clk_enable, | ||
766 | .enable_reg = CCM_PCCR_SDHC1_REG, | ||
767 | .enable_shift = CCM_PCCR_SDHC1_OFFSET, | ||
768 | .disable = _clk_disable, | ||
769 | }, { | ||
770 | .id = 1, | ||
771 | .parent = &ipg_clk, | ||
772 | .enable = _clk_enable, | ||
773 | .enable_reg = CCM_PCCR_SDHC2_REG, | ||
774 | .enable_shift = CCM_PCCR_SDHC2_OFFSET, | ||
775 | .disable = _clk_disable, | ||
776 | }, | ||
777 | }; | ||
778 | |||
779 | static struct clk cspi_ipg_clk[]; | ||
780 | |||
781 | static struct clk cspi_clk[] = { | ||
782 | { | ||
783 | .id = 0, | ||
784 | .parent = &per_clk[1], | ||
785 | .secondary = &cspi_ipg_clk[0], | ||
786 | }, { | ||
787 | .id = 1, | ||
788 | .parent = &per_clk[1], | ||
789 | .secondary = &cspi_ipg_clk[1], | ||
790 | }, { | ||
791 | .id = 2, | ||
792 | .parent = &per_clk[1], | ||
793 | .secondary = &cspi_ipg_clk[2], | ||
794 | }, | ||
795 | }; | ||
796 | |||
797 | static struct clk cspi_ipg_clk[] = { | ||
798 | { | ||
799 | .id = 0, | ||
800 | .parent = &ipg_clk, | ||
801 | .enable = _clk_enable, | ||
802 | .enable_reg = CCM_PCCR_CSPI1_REG, | ||
803 | .enable_shift = CCM_PCCR_CSPI1_OFFSET, | ||
804 | .disable = _clk_disable, | ||
805 | }, { | ||
806 | .id = 1, | ||
807 | .parent = &ipg_clk, | ||
808 | .enable = _clk_enable, | ||
809 | .enable_reg = CCM_PCCR_CSPI2_REG, | ||
810 | .enable_shift = CCM_PCCR_CSPI2_OFFSET, | ||
811 | .disable = _clk_disable, | ||
812 | }, { | ||
813 | .id = 3, | ||
814 | .parent = &ipg_clk, | ||
815 | .enable = _clk_enable, | ||
816 | .enable_reg = CCM_PCCR_CSPI3_REG, | ||
817 | .enable_shift = CCM_PCCR_CSPI3_OFFSET, | ||
818 | .disable = _clk_disable, | ||
819 | }, | ||
820 | }; | ||
821 | |||
822 | static struct clk lcdc_clk[] = { | ||
823 | { | ||
824 | .parent = &per_clk[2], | ||
825 | .secondary = &lcdc_clk[1], | ||
826 | .round_rate = _clk_parent_round_rate, | ||
827 | .set_rate = _clk_parent_set_rate, | ||
828 | }, { | ||
829 | .parent = &ipg_clk, | ||
830 | .secondary = &lcdc_clk[2], | ||
831 | .enable = _clk_enable, | ||
832 | .enable_reg = CCM_PCCR_LCDC_REG, | ||
833 | .enable_shift = CCM_PCCR_LCDC_OFFSET, | ||
834 | .disable = _clk_disable, | ||
835 | }, { | ||
836 | .parent = &hclk_clk, | ||
837 | .enable = _clk_enable, | ||
838 | .enable_reg = CCM_PCCR_HCLK_LCDC_REG, | ||
839 | .enable_shift = CCM_PCCR_HCLK_LCDC_OFFSET, | ||
840 | .disable = _clk_disable, | ||
841 | }, | ||
842 | }; | ||
843 | |||
844 | static struct clk csi_clk[] = { | ||
845 | { | ||
846 | .parent = &per_clk[3], | ||
847 | .secondary = &csi_clk[1], | ||
848 | .round_rate = _clk_parent_round_rate, | ||
849 | .set_rate = _clk_parent_set_rate, | ||
850 | }, { | ||
851 | .parent = &hclk_clk, | ||
852 | .enable = _clk_enable, | ||
853 | .enable_reg = CCM_PCCR_HCLK_CSI_REG, | ||
854 | .enable_shift = CCM_PCCR_HCLK_CSI_OFFSET, | ||
855 | .disable = _clk_disable, | ||
856 | }, | ||
857 | }; | ||
858 | |||
859 | static struct clk usb_clk[] = { | ||
860 | { | ||
861 | .parent = &spll_clk, | ||
862 | .secondary = &usb_clk[1], | ||
863 | .get_rate = _clk_usb_recalc, | ||
864 | .enable = _clk_enable, | ||
865 | .enable_reg = CCM_PCCR_USBOTG_REG, | ||
866 | .enable_shift = CCM_PCCR_USBOTG_OFFSET, | ||
867 | .disable = _clk_disable, | ||
868 | .round_rate = _clk_usb_round_rate, | ||
869 | .set_rate = _clk_usb_set_rate, | ||
870 | }, { | ||
871 | .parent = &hclk_clk, | ||
872 | .enable = _clk_enable, | ||
873 | .enable_reg = CCM_PCCR_HCLK_USBOTG_REG, | ||
874 | .enable_shift = CCM_PCCR_HCLK_USBOTG_OFFSET, | ||
875 | .disable = _clk_disable, | ||
876 | } | ||
877 | }; | ||
878 | |||
879 | static struct clk ssi_ipg_clk[]; | ||
880 | |||
881 | static struct clk ssi_clk[] = { | ||
882 | { | ||
883 | .id = 0, | ||
884 | .parent = &mpll_clk, | ||
885 | .secondary = &ssi_ipg_clk[0], | ||
886 | .get_rate = _clk_ssi1_recalc, | ||
887 | .enable = _clk_enable, | ||
888 | .enable_reg = CCM_PCCR_SSI1_BAUD_REG, | ||
889 | .enable_shift = CCM_PCCR_SSI1_BAUD_OFFSET, | ||
890 | .disable = _clk_disable, | ||
891 | }, { | ||
892 | .id = 1, | ||
893 | .parent = &mpll_clk, | ||
894 | .secondary = &ssi_ipg_clk[1], | ||
895 | .get_rate = _clk_ssi2_recalc, | ||
896 | .enable = _clk_enable, | ||
897 | .enable_reg = CCM_PCCR_SSI2_BAUD_REG, | ||
898 | .enable_shift = CCM_PCCR_SSI2_BAUD_OFFSET, | ||
899 | .disable = _clk_disable, | ||
900 | }, | ||
901 | }; | ||
902 | |||
903 | static struct clk ssi_ipg_clk[] = { | ||
904 | { | ||
905 | .id = 0, | ||
906 | .parent = &ipg_clk, | ||
907 | .enable = _clk_enable, | ||
908 | .enable_reg = CCM_PCCR_SSI1_REG, | ||
909 | .enable_shift = CCM_PCCR_SSI1_IPG_OFFSET, | ||
910 | .disable = _clk_disable, | ||
911 | }, { | ||
912 | .id = 1, | ||
913 | .parent = &ipg_clk, | ||
914 | .enable = _clk_enable, | ||
915 | .enable_reg = CCM_PCCR_SSI2_REG, | ||
916 | .enable_shift = CCM_PCCR_SSI2_IPG_OFFSET, | ||
917 | .disable = _clk_disable, | ||
918 | }, | ||
919 | }; | ||
920 | |||
921 | |||
922 | static struct clk nfc_clk = { | ||
923 | .parent = &fclk_clk, | ||
924 | .get_rate = _clk_nfc_recalc, | ||
925 | .enable = _clk_enable, | ||
926 | .enable_reg = CCM_PCCR_NFC_REG, | ||
927 | .enable_shift = CCM_PCCR_NFC_OFFSET, | ||
928 | .disable = _clk_disable, | ||
929 | }; | ||
930 | |||
931 | static struct clk dma_clk[] = { | ||
932 | { | ||
933 | .parent = &hclk_clk, | ||
934 | .enable = _clk_enable, | ||
935 | .enable_reg = CCM_PCCR_DMA_REG, | ||
936 | .enable_shift = CCM_PCCR_DMA_OFFSET, | ||
937 | .disable = _clk_disable, | ||
938 | .secondary = &dma_clk[1], | ||
939 | }, { | ||
940 | .enable = _clk_enable, | ||
941 | .enable_reg = CCM_PCCR_HCLK_DMA_REG, | ||
942 | .enable_shift = CCM_PCCR_HCLK_DMA_OFFSET, | ||
943 | .disable = _clk_disable, | ||
944 | }, | ||
945 | }; | ||
946 | |||
947 | static struct clk brom_clk = { | ||
948 | .parent = &hclk_clk, | ||
949 | .enable = _clk_enable, | ||
950 | .enable_reg = CCM_PCCR_HCLK_BROM_REG, | ||
951 | .enable_shift = CCM_PCCR_HCLK_BROM_OFFSET, | ||
952 | .disable = _clk_disable, | ||
953 | }; | ||
954 | |||
955 | static struct clk emma_clk[] = { | ||
956 | { | ||
957 | .parent = &hclk_clk, | ||
958 | .enable = _clk_enable, | ||
959 | .enable_reg = CCM_PCCR_EMMA_REG, | ||
960 | .enable_shift = CCM_PCCR_EMMA_OFFSET, | ||
961 | .disable = _clk_disable, | ||
962 | .secondary = &emma_clk[1], | ||
963 | }, { | ||
964 | .enable = _clk_enable, | ||
965 | .enable_reg = CCM_PCCR_HCLK_EMMA_REG, | ||
966 | .enable_shift = CCM_PCCR_HCLK_EMMA_OFFSET, | ||
967 | .disable = _clk_disable, | ||
968 | } | ||
969 | }; | ||
970 | |||
971 | static struct clk slcdc_clk[] = { | ||
972 | { | ||
973 | .parent = &hclk_clk, | ||
974 | .enable = _clk_enable, | ||
975 | .enable_reg = CCM_PCCR_SLCDC_REG, | ||
976 | .enable_shift = CCM_PCCR_SLCDC_OFFSET, | ||
977 | .disable = _clk_disable, | ||
978 | .secondary = &slcdc_clk[1], | ||
979 | }, { | ||
980 | .enable = _clk_enable, | ||
981 | .enable_reg = CCM_PCCR_HCLK_SLCDC_REG, | ||
982 | .enable_shift = CCM_PCCR_HCLK_SLCDC_OFFSET, | ||
983 | .disable = _clk_disable, | ||
984 | } | ||
985 | }; | ||
986 | |||
987 | static struct clk wdog_clk = { | ||
988 | .parent = &ipg_clk, | ||
989 | .enable = _clk_enable, | ||
990 | .enable_reg = CCM_PCCR_WDT_REG, | ||
991 | .enable_shift = CCM_PCCR_WDT_OFFSET, | ||
992 | .disable = _clk_disable, | ||
993 | }; | ||
994 | |||
995 | static struct clk gpio_clk = { | ||
996 | .parent = &ipg_clk, | ||
997 | .enable = _clk_enable, | ||
998 | .enable_reg = CCM_PCCR_GPIO_REG, | ||
999 | .enable_shift = CCM_PCCR_GPIO_OFFSET, | ||
1000 | .disable = _clk_disable, | ||
1001 | }; | ||
1002 | |||
1003 | static struct clk i2c_clk = { | ||
1004 | .id = 0, | ||
1005 | .parent = &ipg_clk, | ||
1006 | .enable = _clk_enable, | ||
1007 | .enable_reg = CCM_PCCR_I2C1_REG, | ||
1008 | .enable_shift = CCM_PCCR_I2C1_OFFSET, | ||
1009 | .disable = _clk_disable, | ||
1010 | }; | ||
1011 | |||
1012 | static struct clk kpp_clk = { | ||
1013 | .parent = &ipg_clk, | ||
1014 | .enable = _clk_enable, | ||
1015 | .enable_reg = CCM_PCCR_KPP_REG, | ||
1016 | .enable_shift = CCM_PCCR_KPP_OFFSET, | ||
1017 | .disable = _clk_disable, | ||
1018 | }; | ||
1019 | |||
1020 | static struct clk owire_clk = { | ||
1021 | .parent = &ipg_clk, | ||
1022 | .enable = _clk_enable, | ||
1023 | .enable_reg = CCM_PCCR_OWIRE_REG, | ||
1024 | .enable_shift = CCM_PCCR_OWIRE_OFFSET, | ||
1025 | .disable = _clk_disable, | ||
1026 | }; | ||
1027 | |||
1028 | static struct clk rtc_clk = { | ||
1029 | .parent = &ipg_clk, | ||
1030 | .enable = _clk_enable, | ||
1031 | .enable_reg = CCM_PCCR_RTC_REG, | ||
1032 | .enable_shift = CCM_PCCR_RTC_OFFSET, | ||
1033 | .disable = _clk_disable, | ||
1034 | }; | ||
1035 | |||
1036 | static unsigned long _clk_clko_round_rate(struct clk *clk, unsigned long rate) | ||
1037 | { | ||
1038 | return _clk_generic_round_rate(clk, rate, 8); | ||
1039 | } | ||
1040 | |||
1041 | static int _clk_clko_set_rate(struct clk *clk, unsigned long rate) | ||
1042 | { | ||
1043 | u32 reg; | ||
1044 | u32 div; | ||
1045 | unsigned long parent_rate; | ||
1046 | |||
1047 | parent_rate = clk_get_rate(clk->parent); | ||
1048 | |||
1049 | div = parent_rate / rate; | ||
1050 | |||
1051 | if (div > 8 || div < 1 || ((parent_rate / div) != rate)) | ||
1052 | return -EINVAL; | ||
1053 | div--; | ||
1054 | |||
1055 | reg = __raw_readl(CCM_PCDR0); | ||
1056 | |||
1057 | if (clk->parent == &usb_clk[0]) { | ||
1058 | reg &= ~CCM_PCDR0_48MDIV_MASK; | ||
1059 | reg |= div << CCM_PCDR0_48MDIV_OFFSET; | ||
1060 | } | ||
1061 | __raw_writel(reg, CCM_PCDR0); | ||
1062 | |||
1063 | return 0; | ||
1064 | } | ||
1065 | |||
1066 | static unsigned long _clk_clko_recalc(struct clk *clk) | ||
1067 | { | ||
1068 | u32 div = 0; | ||
1069 | unsigned long parent_rate; | ||
1070 | |||
1071 | parent_rate = clk_get_rate(clk->parent); | ||
1072 | |||
1073 | if (clk->parent == &usb_clk[0]) /* 48M */ | ||
1074 | div = __raw_readl(CCM_PCDR0) & CCM_PCDR0_48MDIV_MASK | ||
1075 | >> CCM_PCDR0_48MDIV_OFFSET; | ||
1076 | div++; | ||
1077 | |||
1078 | return parent_rate / div; | ||
1079 | } | ||
1080 | |||
1081 | static struct clk clko_clk; | ||
1082 | |||
1083 | static int _clk_clko_set_parent(struct clk *clk, struct clk *parent) | ||
1084 | { | ||
1085 | u32 reg; | ||
1086 | |||
1087 | reg = __raw_readl(CCM_CCSR) & ~CCM_CCSR_CLKOSEL_MASK; | ||
1088 | |||
1089 | if (parent == &ckil_clk) | ||
1090 | reg |= 0 << CCM_CCSR_CLKOSEL_OFFSET; | ||
1091 | else if (parent == &fpm_clk) | ||
1092 | reg |= 1 << CCM_CCSR_CLKOSEL_OFFSET; | ||
1093 | else if (parent == &ckih_clk) | ||
1094 | reg |= 2 << CCM_CCSR_CLKOSEL_OFFSET; | ||
1095 | else if (parent == mpll_clk.parent) | ||
1096 | reg |= 3 << CCM_CCSR_CLKOSEL_OFFSET; | ||
1097 | else if (parent == spll_clk.parent) | ||
1098 | reg |= 4 << CCM_CCSR_CLKOSEL_OFFSET; | ||
1099 | else if (parent == &mpll_clk) | ||
1100 | reg |= 5 << CCM_CCSR_CLKOSEL_OFFSET; | ||
1101 | else if (parent == &spll_clk) | ||
1102 | reg |= 6 << CCM_CCSR_CLKOSEL_OFFSET; | ||
1103 | else if (parent == &fclk_clk) | ||
1104 | reg |= 7 << CCM_CCSR_CLKOSEL_OFFSET; | ||
1105 | else if (parent == &hclk_clk) | ||
1106 | reg |= 8 << CCM_CCSR_CLKOSEL_OFFSET; | ||
1107 | else if (parent == &ipg_clk) | ||
1108 | reg |= 9 << CCM_CCSR_CLKOSEL_OFFSET; | ||
1109 | else if (parent == &per_clk[0]) | ||
1110 | reg |= 0xA << CCM_CCSR_CLKOSEL_OFFSET; | ||
1111 | else if (parent == &per_clk[1]) | ||
1112 | reg |= 0xB << CCM_CCSR_CLKOSEL_OFFSET; | ||
1113 | else if (parent == &per_clk[2]) | ||
1114 | reg |= 0xC << CCM_CCSR_CLKOSEL_OFFSET; | ||
1115 | else if (parent == &per_clk[3]) | ||
1116 | reg |= 0xD << CCM_CCSR_CLKOSEL_OFFSET; | ||
1117 | else if (parent == &ssi_clk[0]) | ||
1118 | reg |= 0xE << CCM_CCSR_CLKOSEL_OFFSET; | ||
1119 | else if (parent == &ssi_clk[1]) | ||
1120 | reg |= 0xF << CCM_CCSR_CLKOSEL_OFFSET; | ||
1121 | else if (parent == &nfc_clk) | ||
1122 | reg |= 0x10 << CCM_CCSR_CLKOSEL_OFFSET; | ||
1123 | else if (parent == &usb_clk[0]) | ||
1124 | reg |= 0x14 << CCM_CCSR_CLKOSEL_OFFSET; | ||
1125 | else if (parent == &clko_clk) | ||
1126 | reg |= 0x15 << CCM_CCSR_CLKOSEL_OFFSET; | ||
1127 | else | ||
1128 | return -EINVAL; | ||
1129 | |||
1130 | __raw_writel(reg, CCM_CCSR); | ||
1131 | |||
1132 | return 0; | ||
1133 | } | ||
1134 | |||
1135 | static struct clk clko_clk = { | ||
1136 | .get_rate = _clk_clko_recalc, | ||
1137 | .set_rate = _clk_clko_set_rate, | ||
1138 | .round_rate = _clk_clko_round_rate, | ||
1139 | .set_parent = _clk_clko_set_parent, | ||
1140 | }; | ||
1141 | |||
1142 | |||
1143 | #define _REGISTER_CLOCK(d, n, c) \ | ||
1144 | { \ | ||
1145 | .dev_id = d, \ | ||
1146 | .con_id = n, \ | ||
1147 | .clk = &c, \ | ||
1148 | }, | ||
1149 | static struct clk_lookup lookups[] = { | ||
1150 | /* It's unlikely that any driver wants one of them directly: | ||
1151 | _REGISTER_CLOCK(NULL, "ckih", ckih_clk) | ||
1152 | _REGISTER_CLOCK(NULL, "ckil", ckil_clk) | ||
1153 | _REGISTER_CLOCK(NULL, "fpm", fpm_clk) | ||
1154 | _REGISTER_CLOCK(NULL, "mpll", mpll_clk) | ||
1155 | _REGISTER_CLOCK(NULL, "spll", spll_clk) | ||
1156 | _REGISTER_CLOCK(NULL, "fclk", fclk_clk) | ||
1157 | _REGISTER_CLOCK(NULL, "hclk", hclk_clk) | ||
1158 | _REGISTER_CLOCK(NULL, "ipg", ipg_clk) | ||
1159 | */ | ||
1160 | _REGISTER_CLOCK(NULL, "perclk1", per_clk[0]) | ||
1161 | _REGISTER_CLOCK(NULL, "perclk2", per_clk[1]) | ||
1162 | _REGISTER_CLOCK(NULL, "perclk3", per_clk[2]) | ||
1163 | _REGISTER_CLOCK(NULL, "perclk4", per_clk[3]) | ||
1164 | _REGISTER_CLOCK(NULL, "clko", clko_clk) | ||
1165 | _REGISTER_CLOCK("imx21-uart.0", NULL, uart_clk[0]) | ||
1166 | _REGISTER_CLOCK("imx21-uart.1", NULL, uart_clk[1]) | ||
1167 | _REGISTER_CLOCK("imx21-uart.2", NULL, uart_clk[2]) | ||
1168 | _REGISTER_CLOCK("imx21-uart.3", NULL, uart_clk[3]) | ||
1169 | _REGISTER_CLOCK(NULL, "gpt1", gpt_clk[0]) | ||
1170 | _REGISTER_CLOCK(NULL, "gpt1", gpt_clk[1]) | ||
1171 | _REGISTER_CLOCK(NULL, "gpt1", gpt_clk[2]) | ||
1172 | _REGISTER_CLOCK(NULL, "pwm", pwm_clk[0]) | ||
1173 | _REGISTER_CLOCK(NULL, "sdhc1", sdhc_clk[0]) | ||
1174 | _REGISTER_CLOCK(NULL, "sdhc2", sdhc_clk[1]) | ||
1175 | _REGISTER_CLOCK("imx21-cspi.0", NULL, cspi_clk[0]) | ||
1176 | _REGISTER_CLOCK("imx21-cspi.1", NULL, cspi_clk[1]) | ||
1177 | _REGISTER_CLOCK("imx21-cspi.2", NULL, cspi_clk[2]) | ||
1178 | _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk[0]) | ||
1179 | _REGISTER_CLOCK(NULL, "csi", csi_clk[0]) | ||
1180 | _REGISTER_CLOCK("imx21-hcd.0", NULL, usb_clk[0]) | ||
1181 | _REGISTER_CLOCK(NULL, "ssi1", ssi_clk[0]) | ||
1182 | _REGISTER_CLOCK(NULL, "ssi2", ssi_clk[1]) | ||
1183 | _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk) | ||
1184 | _REGISTER_CLOCK(NULL, "dma", dma_clk[0]) | ||
1185 | _REGISTER_CLOCK(NULL, "brom", brom_clk) | ||
1186 | _REGISTER_CLOCK(NULL, "emma", emma_clk[0]) | ||
1187 | _REGISTER_CLOCK(NULL, "slcdc", slcdc_clk[0]) | ||
1188 | _REGISTER_CLOCK("imx2-wdt.0", NULL, wdog_clk) | ||
1189 | _REGISTER_CLOCK(NULL, "gpio", gpio_clk) | ||
1190 | _REGISTER_CLOCK("imx-i2c.0", NULL, i2c_clk) | ||
1191 | _REGISTER_CLOCK("mxc-keypad", NULL, kpp_clk) | ||
1192 | _REGISTER_CLOCK(NULL, "owire", owire_clk) | ||
1193 | _REGISTER_CLOCK(NULL, "rtc", rtc_clk) | ||
1194 | }; | ||
1195 | |||
1196 | /* | ||
1197 | * must be called very early to get information about the | ||
1198 | * available clock rate when the timer framework starts | ||
1199 | */ | ||
1200 | int __init mx21_clocks_init(unsigned long lref, unsigned long href) | ||
1201 | { | ||
1202 | u32 cscr; | ||
1203 | |||
1204 | external_low_reference = lref; | ||
1205 | external_high_reference = href; | ||
1206 | |||
1207 | /* detect clock reference for both system PLL */ | ||
1208 | cscr = CSCR(); | ||
1209 | if (cscr & CCM_CSCR_MCU) | ||
1210 | mpll_clk.parent = &ckih_clk; | ||
1211 | else | ||
1212 | mpll_clk.parent = &fpm_clk; | ||
1213 | |||
1214 | if (cscr & CCM_CSCR_SP) | ||
1215 | spll_clk.parent = &ckih_clk; | ||
1216 | else | ||
1217 | spll_clk.parent = &fpm_clk; | ||
1218 | |||
1219 | clkdev_add_table(lookups, ARRAY_SIZE(lookups)); | ||
1220 | |||
1221 | /* Turn off all clock gates */ | ||
1222 | __raw_writel(0, CCM_PCCR0); | ||
1223 | __raw_writel(CCM_PCCR_GPT1_MASK, CCM_PCCR1); | ||
1224 | |||
1225 | /* This turns of the serial PLL as well */ | ||
1226 | spll_clk.disable(&spll_clk); | ||
1227 | |||
1228 | /* This will propagate to all children and init all the clock rates. */ | ||
1229 | clk_enable(&per_clk[0]); | ||
1230 | clk_enable(&gpio_clk); | ||
1231 | |||
1232 | #if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC) | ||
1233 | clk_enable(&uart_clk[0]); | ||
1234 | #endif | ||
1235 | |||
1236 | mxc_timer_init(&gpt_clk[0], MX21_IO_ADDRESS(MX21_GPT1_BASE_ADDR), | ||
1237 | MX21_INT_GPT1); | ||
1238 | return 0; | ||
1239 | } | ||
diff --git a/arch/arm/mach-imx/clock-imx25.c b/arch/arm/mach-imx/clock-imx25.c deleted file mode 100644 index b0fec74c8c91..000000000000 --- a/arch/arm/mach-imx/clock-imx25.c +++ /dev/null | |||
@@ -1,346 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009 by Sascha Hauer, Pengutronix | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation; either version 2 | ||
7 | * of the License, or (at your option) any later version. | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program; if not, write to the Free Software | ||
15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
16 | * MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/list.h> | ||
22 | #include <linux/clk.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <linux/clkdev.h> | ||
25 | |||
26 | #include <mach/clock.h> | ||
27 | #include <mach/hardware.h> | ||
28 | #include <mach/common.h> | ||
29 | #include <mach/mx25.h> | ||
30 | |||
31 | #define CRM_BASE MX25_IO_ADDRESS(MX25_CRM_BASE_ADDR) | ||
32 | |||
33 | #define CCM_MPCTL 0x00 | ||
34 | #define CCM_UPCTL 0x04 | ||
35 | #define CCM_CCTL 0x08 | ||
36 | #define CCM_CGCR0 0x0C | ||
37 | #define CCM_CGCR1 0x10 | ||
38 | #define CCM_CGCR2 0x14 | ||
39 | #define CCM_PCDR0 0x18 | ||
40 | #define CCM_PCDR1 0x1C | ||
41 | #define CCM_PCDR2 0x20 | ||
42 | #define CCM_PCDR3 0x24 | ||
43 | #define CCM_RCSR 0x28 | ||
44 | #define CCM_CRDR 0x2C | ||
45 | #define CCM_DCVR0 0x30 | ||
46 | #define CCM_DCVR1 0x34 | ||
47 | #define CCM_DCVR2 0x38 | ||
48 | #define CCM_DCVR3 0x3c | ||
49 | #define CCM_LTR0 0x40 | ||
50 | #define CCM_LTR1 0x44 | ||
51 | #define CCM_LTR2 0x48 | ||
52 | #define CCM_LTR3 0x4c | ||
53 | |||
54 | static unsigned long get_rate_mpll(void) | ||
55 | { | ||
56 | ulong mpctl = __raw_readl(CRM_BASE + CCM_MPCTL); | ||
57 | |||
58 | return mxc_decode_pll(mpctl, 24000000); | ||
59 | } | ||
60 | |||
61 | static unsigned long get_rate_upll(void) | ||
62 | { | ||
63 | ulong mpctl = __raw_readl(CRM_BASE + CCM_UPCTL); | ||
64 | |||
65 | return mxc_decode_pll(mpctl, 24000000); | ||
66 | } | ||
67 | |||
68 | unsigned long get_rate_arm(struct clk *clk) | ||
69 | { | ||
70 | unsigned long cctl = readl(CRM_BASE + CCM_CCTL); | ||
71 | unsigned long rate = get_rate_mpll(); | ||
72 | |||
73 | if (cctl & (1 << 14)) | ||
74 | rate = (rate * 3) >> 2; | ||
75 | |||
76 | return rate / ((cctl >> 30) + 1); | ||
77 | } | ||
78 | |||
79 | static unsigned long get_rate_ahb(struct clk *clk) | ||
80 | { | ||
81 | unsigned long cctl = readl(CRM_BASE + CCM_CCTL); | ||
82 | |||
83 | return get_rate_arm(NULL) / (((cctl >> 28) & 0x3) + 1); | ||
84 | } | ||
85 | |||
86 | static unsigned long get_rate_ipg(struct clk *clk) | ||
87 | { | ||
88 | return get_rate_ahb(NULL) >> 1; | ||
89 | } | ||
90 | |||
91 | static unsigned long get_rate_per(int per) | ||
92 | { | ||
93 | unsigned long ofs = (per & 0x3) * 8; | ||
94 | unsigned long reg = per & ~0x3; | ||
95 | unsigned long val = (readl(CRM_BASE + CCM_PCDR0 + reg) >> ofs) & 0x3f; | ||
96 | unsigned long fref; | ||
97 | |||
98 | if (readl(CRM_BASE + 0x64) & (1 << per)) | ||
99 | fref = get_rate_upll(); | ||
100 | else | ||
101 | fref = get_rate_ahb(NULL); | ||
102 | |||
103 | return fref / (val + 1); | ||
104 | } | ||
105 | |||
106 | static unsigned long get_rate_uart(struct clk *clk) | ||
107 | { | ||
108 | return get_rate_per(15); | ||
109 | } | ||
110 | |||
111 | static unsigned long get_rate_ssi2(struct clk *clk) | ||
112 | { | ||
113 | return get_rate_per(14); | ||
114 | } | ||
115 | |||
116 | static unsigned long get_rate_ssi1(struct clk *clk) | ||
117 | { | ||
118 | return get_rate_per(13); | ||
119 | } | ||
120 | |||
121 | static unsigned long get_rate_i2c(struct clk *clk) | ||
122 | { | ||
123 | return get_rate_per(6); | ||
124 | } | ||
125 | |||
126 | static unsigned long get_rate_nfc(struct clk *clk) | ||
127 | { | ||
128 | return get_rate_per(8); | ||
129 | } | ||
130 | |||
131 | static unsigned long get_rate_gpt(struct clk *clk) | ||
132 | { | ||
133 | return get_rate_per(5); | ||
134 | } | ||
135 | |||
136 | static unsigned long get_rate_lcdc(struct clk *clk) | ||
137 | { | ||
138 | return get_rate_per(7); | ||
139 | } | ||
140 | |||
141 | static unsigned long get_rate_esdhc1(struct clk *clk) | ||
142 | { | ||
143 | return get_rate_per(3); | ||
144 | } | ||
145 | |||
146 | static unsigned long get_rate_esdhc2(struct clk *clk) | ||
147 | { | ||
148 | return get_rate_per(4); | ||
149 | } | ||
150 | |||
151 | static unsigned long get_rate_csi(struct clk *clk) | ||
152 | { | ||
153 | return get_rate_per(0); | ||
154 | } | ||
155 | |||
156 | static unsigned long get_rate_otg(struct clk *clk) | ||
157 | { | ||
158 | unsigned long cctl = readl(CRM_BASE + CCM_CCTL); | ||
159 | unsigned long rate = get_rate_upll(); | ||
160 | |||
161 | return (cctl & (1 << 23)) ? 0 : rate / ((0x3F & (cctl >> 16)) + 1); | ||
162 | } | ||
163 | |||
164 | static int clk_cgcr_enable(struct clk *clk) | ||
165 | { | ||
166 | u32 reg; | ||
167 | |||
168 | reg = __raw_readl(clk->enable_reg); | ||
169 | reg |= 1 << clk->enable_shift; | ||
170 | __raw_writel(reg, clk->enable_reg); | ||
171 | |||
172 | return 0; | ||
173 | } | ||
174 | |||
175 | static void clk_cgcr_disable(struct clk *clk) | ||
176 | { | ||
177 | u32 reg; | ||
178 | |||
179 | reg = __raw_readl(clk->enable_reg); | ||
180 | reg &= ~(1 << clk->enable_shift); | ||
181 | __raw_writel(reg, clk->enable_reg); | ||
182 | } | ||
183 | |||
184 | #define DEFINE_CLOCK(name, i, er, es, gr, sr, s) \ | ||
185 | static struct clk name = { \ | ||
186 | .id = i, \ | ||
187 | .enable_reg = CRM_BASE + er, \ | ||
188 | .enable_shift = es, \ | ||
189 | .get_rate = gr, \ | ||
190 | .set_rate = sr, \ | ||
191 | .enable = clk_cgcr_enable, \ | ||
192 | .disable = clk_cgcr_disable, \ | ||
193 | .secondary = s, \ | ||
194 | } | ||
195 | |||
196 | /* | ||
197 | * Note: the following IPG clock gating bits are wrongly marked "Reserved" in | ||
198 | * the i.MX25 Reference Manual Rev 1, table 15-13. The information below is | ||
199 | * taken from the Freescale released BSP. | ||
200 | * | ||
201 | * bit reg offset clock | ||
202 | * | ||
203 | * 0 CGCR1 0 AUDMUX | ||
204 | * 12 CGCR1 12 ESAI | ||
205 | * 16 CGCR1 16 GPIO1 | ||
206 | * 17 CGCR1 17 GPIO2 | ||
207 | * 18 CGCR1 18 GPIO3 | ||
208 | * 23 CGCR1 23 I2C1 | ||
209 | * 24 CGCR1 24 I2C2 | ||
210 | * 25 CGCR1 25 I2C3 | ||
211 | * 27 CGCR1 27 IOMUXC | ||
212 | * 28 CGCR1 28 KPP | ||
213 | * 30 CGCR1 30 OWIRE | ||
214 | * 36 CGCR2 4 RTIC | ||
215 | * 51 CGCR2 19 WDOG | ||
216 | */ | ||
217 | |||
218 | DEFINE_CLOCK(gpt_clk, 0, CCM_CGCR0, 5, get_rate_gpt, NULL, NULL); | ||
219 | DEFINE_CLOCK(uart_per_clk, 0, CCM_CGCR0, 15, get_rate_uart, NULL, NULL); | ||
220 | DEFINE_CLOCK(ssi1_per_clk, 0, CCM_CGCR0, 13, get_rate_ipg, NULL, NULL); | ||
221 | DEFINE_CLOCK(ssi2_per_clk, 0, CCM_CGCR0, 14, get_rate_ipg, NULL, NULL); | ||
222 | DEFINE_CLOCK(cspi1_clk, 0, CCM_CGCR1, 5, get_rate_ipg, NULL, NULL); | ||
223 | DEFINE_CLOCK(cspi2_clk, 0, CCM_CGCR1, 6, get_rate_ipg, NULL, NULL); | ||
224 | DEFINE_CLOCK(cspi3_clk, 0, CCM_CGCR1, 7, get_rate_ipg, NULL, NULL); | ||
225 | DEFINE_CLOCK(esdhc1_ahb_clk, 0, CCM_CGCR0, 21, get_rate_esdhc1, NULL, NULL); | ||
226 | DEFINE_CLOCK(esdhc1_per_clk, 0, CCM_CGCR0, 3, get_rate_esdhc1, NULL, | ||
227 | &esdhc1_ahb_clk); | ||
228 | DEFINE_CLOCK(esdhc2_ahb_clk, 0, CCM_CGCR0, 22, get_rate_esdhc2, NULL, NULL); | ||
229 | DEFINE_CLOCK(esdhc2_per_clk, 0, CCM_CGCR0, 4, get_rate_esdhc2, NULL, | ||
230 | &esdhc2_ahb_clk); | ||
231 | DEFINE_CLOCK(sdma_ahb_clk, 0, CCM_CGCR0, 26, NULL, NULL, NULL); | ||
232 | DEFINE_CLOCK(fec_ahb_clk, 0, CCM_CGCR0, 23, NULL, NULL, NULL); | ||
233 | DEFINE_CLOCK(lcdc_ahb_clk, 0, CCM_CGCR0, 24, NULL, NULL, NULL); | ||
234 | DEFINE_CLOCK(lcdc_per_clk, 0, CCM_CGCR0, 7, NULL, NULL, &lcdc_ahb_clk); | ||
235 | DEFINE_CLOCK(csi_ahb_clk, 0, CCM_CGCR0, 18, get_rate_csi, NULL, NULL); | ||
236 | DEFINE_CLOCK(csi_per_clk, 0, CCM_CGCR0, 0, get_rate_csi, NULL, &csi_ahb_clk); | ||
237 | DEFINE_CLOCK(uart1_clk, 0, CCM_CGCR2, 14, get_rate_uart, NULL, &uart_per_clk); | ||
238 | DEFINE_CLOCK(uart2_clk, 0, CCM_CGCR2, 15, get_rate_uart, NULL, &uart_per_clk); | ||
239 | DEFINE_CLOCK(uart3_clk, 0, CCM_CGCR2, 16, get_rate_uart, NULL, &uart_per_clk); | ||
240 | DEFINE_CLOCK(uart4_clk, 0, CCM_CGCR2, 17, get_rate_uart, NULL, &uart_per_clk); | ||
241 | DEFINE_CLOCK(uart5_clk, 0, CCM_CGCR2, 18, get_rate_uart, NULL, &uart_per_clk); | ||
242 | DEFINE_CLOCK(nfc_clk, 0, CCM_CGCR0, 8, get_rate_nfc, NULL, NULL); | ||
243 | DEFINE_CLOCK(usbotg_clk, 0, CCM_CGCR0, 28, get_rate_otg, NULL, NULL); | ||
244 | DEFINE_CLOCK(pwm1_clk, 0, CCM_CGCR1, 31, get_rate_ipg, NULL, NULL); | ||
245 | DEFINE_CLOCK(pwm2_clk, 0, CCM_CGCR2, 0, get_rate_ipg, NULL, NULL); | ||
246 | DEFINE_CLOCK(pwm3_clk, 0, CCM_CGCR2, 1, get_rate_ipg, NULL, NULL); | ||
247 | DEFINE_CLOCK(pwm4_clk, 0, CCM_CGCR2, 2, get_rate_ipg, NULL, NULL); | ||
248 | DEFINE_CLOCK(kpp_clk, 0, CCM_CGCR1, 28, get_rate_ipg, NULL, NULL); | ||
249 | DEFINE_CLOCK(tsc_clk, 0, CCM_CGCR2, 13, get_rate_ipg, NULL, NULL); | ||
250 | DEFINE_CLOCK(i2c_clk, 0, CCM_CGCR0, 6, get_rate_i2c, NULL, NULL); | ||
251 | DEFINE_CLOCK(fec_clk, 0, CCM_CGCR1, 15, get_rate_ipg, NULL, &fec_ahb_clk); | ||
252 | DEFINE_CLOCK(dryice_clk, 0, CCM_CGCR1, 8, get_rate_ipg, NULL, NULL); | ||
253 | DEFINE_CLOCK(lcdc_clk, 0, CCM_CGCR1, 29, get_rate_lcdc, NULL, &lcdc_per_clk); | ||
254 | DEFINE_CLOCK(wdt_clk, 0, CCM_CGCR2, 19, get_rate_ipg, NULL, NULL); | ||
255 | DEFINE_CLOCK(ssi1_clk, 0, CCM_CGCR2, 11, get_rate_ssi1, NULL, &ssi1_per_clk); | ||
256 | DEFINE_CLOCK(ssi2_clk, 1, CCM_CGCR2, 12, get_rate_ssi2, NULL, &ssi2_per_clk); | ||
257 | DEFINE_CLOCK(sdma_clk, 0, CCM_CGCR2, 6, get_rate_ipg, NULL, &sdma_ahb_clk); | ||
258 | DEFINE_CLOCK(esdhc1_clk, 0, CCM_CGCR1, 13, get_rate_esdhc1, NULL, | ||
259 | &esdhc1_per_clk); | ||
260 | DEFINE_CLOCK(esdhc2_clk, 1, CCM_CGCR1, 14, get_rate_esdhc2, NULL, | ||
261 | &esdhc2_per_clk); | ||
262 | DEFINE_CLOCK(audmux_clk, 0, CCM_CGCR1, 0, NULL, NULL, NULL); | ||
263 | DEFINE_CLOCK(csi_clk, 0, CCM_CGCR1, 4, get_rate_csi, NULL, &csi_per_clk); | ||
264 | DEFINE_CLOCK(can1_clk, 0, CCM_CGCR1, 2, get_rate_ipg, NULL, NULL); | ||
265 | DEFINE_CLOCK(can2_clk, 1, CCM_CGCR1, 3, get_rate_ipg, NULL, NULL); | ||
266 | DEFINE_CLOCK(iim_clk, 0, CCM_CGCR1, 26, NULL, NULL, NULL); | ||
267 | |||
268 | #define _REGISTER_CLOCK(d, n, c) \ | ||
269 | { \ | ||
270 | .dev_id = d, \ | ||
271 | .con_id = n, \ | ||
272 | .clk = &c, \ | ||
273 | }, | ||
274 | |||
275 | static struct clk_lookup lookups[] = { | ||
276 | /* i.mx25 has the i.mx21 type uart */ | ||
277 | _REGISTER_CLOCK("imx21-uart.0", NULL, uart1_clk) | ||
278 | _REGISTER_CLOCK("imx21-uart.1", NULL, uart2_clk) | ||
279 | _REGISTER_CLOCK("imx21-uart.2", NULL, uart3_clk) | ||
280 | _REGISTER_CLOCK("imx21-uart.3", NULL, uart4_clk) | ||
281 | _REGISTER_CLOCK("imx21-uart.4", NULL, uart5_clk) | ||
282 | _REGISTER_CLOCK("mxc-ehci.0", "usb", usbotg_clk) | ||
283 | _REGISTER_CLOCK("mxc-ehci.1", "usb", usbotg_clk) | ||
284 | _REGISTER_CLOCK("mxc-ehci.2", "usb", usbotg_clk) | ||
285 | _REGISTER_CLOCK("fsl-usb2-udc", "usb", usbotg_clk) | ||
286 | _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk) | ||
287 | /* i.mx25 has the i.mx35 type cspi */ | ||
288 | _REGISTER_CLOCK("imx35-cspi.0", NULL, cspi1_clk) | ||
289 | _REGISTER_CLOCK("imx35-cspi.1", NULL, cspi2_clk) | ||
290 | _REGISTER_CLOCK("imx35-cspi.2", NULL, cspi3_clk) | ||
291 | _REGISTER_CLOCK("mxc_pwm.0", NULL, pwm1_clk) | ||
292 | _REGISTER_CLOCK("mxc_pwm.1", NULL, pwm2_clk) | ||
293 | _REGISTER_CLOCK("mxc_pwm.2", NULL, pwm3_clk) | ||
294 | _REGISTER_CLOCK("mxc_pwm.3", NULL, pwm4_clk) | ||
295 | _REGISTER_CLOCK("imx-keypad", NULL, kpp_clk) | ||
296 | _REGISTER_CLOCK("mx25-adc", NULL, tsc_clk) | ||
297 | _REGISTER_CLOCK("imx-i2c.0", NULL, i2c_clk) | ||
298 | _REGISTER_CLOCK("imx-i2c.1", NULL, i2c_clk) | ||
299 | _REGISTER_CLOCK("imx-i2c.2", NULL, i2c_clk) | ||
300 | _REGISTER_CLOCK("imx25-fec.0", NULL, fec_clk) | ||
301 | _REGISTER_CLOCK("imxdi_rtc.0", NULL, dryice_clk) | ||
302 | _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk) | ||
303 | _REGISTER_CLOCK("imx2-wdt.0", NULL, wdt_clk) | ||
304 | _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk) | ||
305 | _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk) | ||
306 | _REGISTER_CLOCK("sdhci-esdhc-imx25.0", NULL, esdhc1_clk) | ||
307 | _REGISTER_CLOCK("sdhci-esdhc-imx25.1", NULL, esdhc2_clk) | ||
308 | _REGISTER_CLOCK("mx2-camera.0", NULL, csi_clk) | ||
309 | _REGISTER_CLOCK(NULL, "audmux", audmux_clk) | ||
310 | _REGISTER_CLOCK("flexcan.0", NULL, can1_clk) | ||
311 | _REGISTER_CLOCK("flexcan.1", NULL, can2_clk) | ||
312 | /* i.mx25 has the i.mx35 type sdma */ | ||
313 | _REGISTER_CLOCK("imx35-sdma", NULL, sdma_clk) | ||
314 | _REGISTER_CLOCK(NULL, "iim", iim_clk) | ||
315 | }; | ||
316 | |||
317 | int __init mx25_clocks_init(void) | ||
318 | { | ||
319 | clkdev_add_table(lookups, ARRAY_SIZE(lookups)); | ||
320 | |||
321 | /* Turn off all clocks except the ones we need to survive, namely: | ||
322 | * EMI, GPIO1-3 (CCM_CGCR1[18:16]), GPT1, IOMUXC (CCM_CGCR1[27]), IIM, | ||
323 | * SCC | ||
324 | */ | ||
325 | __raw_writel((1 << 19), CRM_BASE + CCM_CGCR0); | ||
326 | __raw_writel((0xf << 16) | (3 << 26), CRM_BASE + CCM_CGCR1); | ||
327 | __raw_writel((1 << 5), CRM_BASE + CCM_CGCR2); | ||
328 | #if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC) | ||
329 | clk_enable(&uart1_clk); | ||
330 | #endif | ||
331 | |||
332 | /* Clock source for lcdc and csi is upll */ | ||
333 | __raw_writel(__raw_readl(CRM_BASE+0x64) | (1 << 7) | (1 << 0), | ||
334 | CRM_BASE + 0x64); | ||
335 | |||
336 | /* Clock source for gpt is ahb_div */ | ||
337 | __raw_writel(__raw_readl(CRM_BASE+0x64) & ~(1 << 5), CRM_BASE + 0x64); | ||
338 | |||
339 | clk_enable(&iim_clk); | ||
340 | imx_print_silicon_rev("i.MX25", mx25_revision()); | ||
341 | clk_disable(&iim_clk); | ||
342 | |||
343 | mxc_timer_init(&gpt_clk, MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR), 54); | ||
344 | |||
345 | return 0; | ||
346 | } | ||
diff --git a/arch/arm/mach-imx/clock-imx27.c b/arch/arm/mach-imx/clock-imx27.c deleted file mode 100644 index 98e04f5a87dd..000000000000 --- a/arch/arm/mach-imx/clock-imx27.c +++ /dev/null | |||
@@ -1,785 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. | ||
3 | * Copyright 2008 Juergen Beisert, kernel@pengutronix.de | ||
4 | * Copyright 2008 Martin Fuzzey, mfuzzey@gmail.com | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version 2 | ||
9 | * of the License, or (at your option) any later version. | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
18 | * MA 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/clk.h> | ||
22 | #include <linux/io.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/clkdev.h> | ||
25 | #include <linux/of.h> | ||
26 | |||
27 | #include <asm/div64.h> | ||
28 | |||
29 | #include <mach/clock.h> | ||
30 | #include <mach/common.h> | ||
31 | #include <mach/hardware.h> | ||
32 | |||
33 | #define IO_ADDR_CCM(off) (MX27_IO_ADDRESS(MX27_CCM_BASE_ADDR + (off))) | ||
34 | |||
35 | /* Register offsets */ | ||
36 | #define CCM_CSCR IO_ADDR_CCM(0x0) | ||
37 | #define CCM_MPCTL0 IO_ADDR_CCM(0x4) | ||
38 | #define CCM_MPCTL1 IO_ADDR_CCM(0x8) | ||
39 | #define CCM_SPCTL0 IO_ADDR_CCM(0xc) | ||
40 | #define CCM_SPCTL1 IO_ADDR_CCM(0x10) | ||
41 | #define CCM_OSC26MCTL IO_ADDR_CCM(0x14) | ||
42 | #define CCM_PCDR0 IO_ADDR_CCM(0x18) | ||
43 | #define CCM_PCDR1 IO_ADDR_CCM(0x1c) | ||
44 | #define CCM_PCCR0 IO_ADDR_CCM(0x20) | ||
45 | #define CCM_PCCR1 IO_ADDR_CCM(0x24) | ||
46 | #define CCM_CCSR IO_ADDR_CCM(0x28) | ||
47 | #define CCM_PMCTL IO_ADDR_CCM(0x2c) | ||
48 | #define CCM_PMCOUNT IO_ADDR_CCM(0x30) | ||
49 | #define CCM_WKGDCTL IO_ADDR_CCM(0x34) | ||
50 | |||
51 | #define CCM_CSCR_UPDATE_DIS (1 << 31) | ||
52 | #define CCM_CSCR_SSI2 (1 << 23) | ||
53 | #define CCM_CSCR_SSI1 (1 << 22) | ||
54 | #define CCM_CSCR_VPU (1 << 21) | ||
55 | #define CCM_CSCR_MSHC (1 << 20) | ||
56 | #define CCM_CSCR_SPLLRES (1 << 19) | ||
57 | #define CCM_CSCR_MPLLRES (1 << 18) | ||
58 | #define CCM_CSCR_SP (1 << 17) | ||
59 | #define CCM_CSCR_MCU (1 << 16) | ||
60 | #define CCM_CSCR_OSC26MDIV (1 << 4) | ||
61 | #define CCM_CSCR_OSC26M (1 << 3) | ||
62 | #define CCM_CSCR_FPM (1 << 2) | ||
63 | #define CCM_CSCR_SPEN (1 << 1) | ||
64 | #define CCM_CSCR_MPEN (1 << 0) | ||
65 | |||
66 | /* i.MX27 TO 2+ */ | ||
67 | #define CCM_CSCR_ARM_SRC (1 << 15) | ||
68 | |||
69 | #define CCM_SPCTL1_LF (1 << 15) | ||
70 | #define CCM_SPCTL1_BRMO (1 << 6) | ||
71 | |||
72 | static struct clk mpll_main1_clk, mpll_main2_clk; | ||
73 | |||
74 | static int clk_pccr_enable(struct clk *clk) | ||
75 | { | ||
76 | unsigned long reg; | ||
77 | |||
78 | if (!clk->enable_reg) | ||
79 | return 0; | ||
80 | |||
81 | reg = __raw_readl(clk->enable_reg); | ||
82 | reg |= 1 << clk->enable_shift; | ||
83 | __raw_writel(reg, clk->enable_reg); | ||
84 | |||
85 | return 0; | ||
86 | } | ||
87 | |||
88 | static void clk_pccr_disable(struct clk *clk) | ||
89 | { | ||
90 | unsigned long reg; | ||
91 | |||
92 | if (!clk->enable_reg) | ||
93 | return; | ||
94 | |||
95 | reg = __raw_readl(clk->enable_reg); | ||
96 | reg &= ~(1 << clk->enable_shift); | ||
97 | __raw_writel(reg, clk->enable_reg); | ||
98 | } | ||
99 | |||
100 | static int clk_spll_enable(struct clk *clk) | ||
101 | { | ||
102 | unsigned long reg; | ||
103 | |||
104 | reg = __raw_readl(CCM_CSCR); | ||
105 | reg |= CCM_CSCR_SPEN; | ||
106 | __raw_writel(reg, CCM_CSCR); | ||
107 | |||
108 | while (!(__raw_readl(CCM_SPCTL1) & CCM_SPCTL1_LF)); | ||
109 | |||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | static void clk_spll_disable(struct clk *clk) | ||
114 | { | ||
115 | unsigned long reg; | ||
116 | |||
117 | reg = __raw_readl(CCM_CSCR); | ||
118 | reg &= ~CCM_CSCR_SPEN; | ||
119 | __raw_writel(reg, CCM_CSCR); | ||
120 | } | ||
121 | |||
122 | static int clk_cpu_set_parent(struct clk *clk, struct clk *parent) | ||
123 | { | ||
124 | int cscr = __raw_readl(CCM_CSCR); | ||
125 | |||
126 | if (clk->parent == parent) | ||
127 | return 0; | ||
128 | |||
129 | if (mx27_revision() >= IMX_CHIP_REVISION_2_0) { | ||
130 | if (parent == &mpll_main1_clk) { | ||
131 | cscr |= CCM_CSCR_ARM_SRC; | ||
132 | } else { | ||
133 | if (parent == &mpll_main2_clk) | ||
134 | cscr &= ~CCM_CSCR_ARM_SRC; | ||
135 | else | ||
136 | return -EINVAL; | ||
137 | } | ||
138 | __raw_writel(cscr, CCM_CSCR); | ||
139 | clk->parent = parent; | ||
140 | return 0; | ||
141 | } | ||
142 | return -ENODEV; | ||
143 | } | ||
144 | |||
145 | static unsigned long round_rate_cpu(struct clk *clk, unsigned long rate) | ||
146 | { | ||
147 | int div; | ||
148 | unsigned long parent_rate; | ||
149 | |||
150 | parent_rate = clk_get_rate(clk->parent); | ||
151 | |||
152 | div = parent_rate / rate; | ||
153 | if (parent_rate % rate) | ||
154 | div++; | ||
155 | |||
156 | if (div > 4) | ||
157 | div = 4; | ||
158 | |||
159 | return parent_rate / div; | ||
160 | } | ||
161 | |||
162 | static int set_rate_cpu(struct clk *clk, unsigned long rate) | ||
163 | { | ||
164 | unsigned int div; | ||
165 | uint32_t reg; | ||
166 | unsigned long parent_rate; | ||
167 | |||
168 | parent_rate = clk_get_rate(clk->parent); | ||
169 | |||
170 | div = parent_rate / rate; | ||
171 | |||
172 | if (div > 4 || div < 1 || ((parent_rate / div) != rate)) | ||
173 | return -EINVAL; | ||
174 | |||
175 | div--; | ||
176 | |||
177 | reg = __raw_readl(CCM_CSCR); | ||
178 | if (mx27_revision() >= IMX_CHIP_REVISION_2_0) { | ||
179 | reg &= ~(3 << 12); | ||
180 | reg |= div << 12; | ||
181 | reg &= ~(CCM_CSCR_FPM | CCM_CSCR_SPEN); | ||
182 | __raw_writel(reg | CCM_CSCR_UPDATE_DIS, CCM_CSCR); | ||
183 | } else { | ||
184 | printk(KERN_ERR "Can't set CPU frequency!\n"); | ||
185 | } | ||
186 | |||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | static unsigned long round_rate_per(struct clk *clk, unsigned long rate) | ||
191 | { | ||
192 | u32 div; | ||
193 | unsigned long parent_rate; | ||
194 | |||
195 | parent_rate = clk_get_rate(clk->parent); | ||
196 | |||
197 | div = parent_rate / rate; | ||
198 | if (parent_rate % rate) | ||
199 | div++; | ||
200 | |||
201 | if (div > 64) | ||
202 | div = 64; | ||
203 | |||
204 | return parent_rate / div; | ||
205 | } | ||
206 | |||
207 | static int set_rate_per(struct clk *clk, unsigned long rate) | ||
208 | { | ||
209 | u32 reg; | ||
210 | u32 div; | ||
211 | unsigned long parent_rate; | ||
212 | |||
213 | parent_rate = clk_get_rate(clk->parent); | ||
214 | |||
215 | if (clk->id < 0 || clk->id > 3) | ||
216 | return -EINVAL; | ||
217 | |||
218 | div = parent_rate / rate; | ||
219 | if (div > 64 || div < 1 || ((parent_rate / div) != rate)) | ||
220 | return -EINVAL; | ||
221 | div--; | ||
222 | |||
223 | reg = __raw_readl(CCM_PCDR1) & ~(0x3f << (clk->id << 3)); | ||
224 | reg |= div << (clk->id << 3); | ||
225 | __raw_writel(reg, CCM_PCDR1); | ||
226 | |||
227 | return 0; | ||
228 | } | ||
229 | |||
230 | static unsigned long get_rate_usb(struct clk *clk) | ||
231 | { | ||
232 | unsigned long usb_pdf; | ||
233 | unsigned long parent_rate; | ||
234 | |||
235 | parent_rate = clk_get_rate(clk->parent); | ||
236 | |||
237 | usb_pdf = (__raw_readl(CCM_CSCR) >> 28) & 0x7; | ||
238 | |||
239 | return parent_rate / (usb_pdf + 1U); | ||
240 | } | ||
241 | |||
242 | static unsigned long get_rate_ssix(struct clk *clk, unsigned long pdf) | ||
243 | { | ||
244 | unsigned long parent_rate; | ||
245 | |||
246 | parent_rate = clk_get_rate(clk->parent); | ||
247 | |||
248 | if (mx27_revision() >= IMX_CHIP_REVISION_2_0) | ||
249 | pdf += 4; /* MX27 TO2+ */ | ||
250 | else | ||
251 | pdf = (pdf < 2) ? 124UL : pdf; /* MX21 & MX27 TO1 */ | ||
252 | |||
253 | return 2UL * parent_rate / pdf; | ||
254 | } | ||
255 | |||
256 | static unsigned long get_rate_ssi1(struct clk *clk) | ||
257 | { | ||
258 | return get_rate_ssix(clk, (__raw_readl(CCM_PCDR0) >> 16) & 0x3f); | ||
259 | } | ||
260 | |||
261 | static unsigned long get_rate_ssi2(struct clk *clk) | ||
262 | { | ||
263 | return get_rate_ssix(clk, (__raw_readl(CCM_PCDR0) >> 26) & 0x3f); | ||
264 | } | ||
265 | |||
266 | static unsigned long get_rate_nfc(struct clk *clk) | ||
267 | { | ||
268 | unsigned long nfc_pdf; | ||
269 | unsigned long parent_rate; | ||
270 | |||
271 | parent_rate = clk_get_rate(clk->parent); | ||
272 | |||
273 | if (mx27_revision() >= IMX_CHIP_REVISION_2_0) | ||
274 | nfc_pdf = (__raw_readl(CCM_PCDR0) >> 6) & 0xf; | ||
275 | else | ||
276 | nfc_pdf = (__raw_readl(CCM_PCDR0) >> 12) & 0xf; | ||
277 | |||
278 | return parent_rate / (nfc_pdf + 1); | ||
279 | } | ||
280 | |||
281 | static unsigned long get_rate_vpu(struct clk *clk) | ||
282 | { | ||
283 | unsigned long vpu_pdf; | ||
284 | unsigned long parent_rate; | ||
285 | |||
286 | parent_rate = clk_get_rate(clk->parent); | ||
287 | |||
288 | if (mx27_revision() >= IMX_CHIP_REVISION_2_0) { | ||
289 | vpu_pdf = (__raw_readl(CCM_PCDR0) >> 10) & 0x3f; | ||
290 | vpu_pdf += 4; | ||
291 | } else { | ||
292 | vpu_pdf = (__raw_readl(CCM_PCDR0) >> 8) & 0xf; | ||
293 | vpu_pdf = (vpu_pdf < 2) ? 124 : vpu_pdf; | ||
294 | } | ||
295 | |||
296 | return 2UL * parent_rate / vpu_pdf; | ||
297 | } | ||
298 | |||
299 | static unsigned long round_rate_parent(struct clk *clk, unsigned long rate) | ||
300 | { | ||
301 | return clk->parent->round_rate(clk->parent, rate); | ||
302 | } | ||
303 | |||
304 | static unsigned long get_rate_parent(struct clk *clk) | ||
305 | { | ||
306 | return clk_get_rate(clk->parent); | ||
307 | } | ||
308 | |||
309 | static int set_rate_parent(struct clk *clk, unsigned long rate) | ||
310 | { | ||
311 | return clk->parent->set_rate(clk->parent, rate); | ||
312 | } | ||
313 | |||
314 | /* in Hz */ | ||
315 | static unsigned long external_high_reference = 26000000; | ||
316 | |||
317 | static unsigned long get_rate_high_reference(struct clk *clk) | ||
318 | { | ||
319 | return external_high_reference; | ||
320 | } | ||
321 | |||
322 | /* in Hz */ | ||
323 | static unsigned long external_low_reference = 32768; | ||
324 | |||
325 | static unsigned long get_rate_low_reference(struct clk *clk) | ||
326 | { | ||
327 | return external_low_reference; | ||
328 | } | ||
329 | |||
330 | static unsigned long get_rate_fpm(struct clk *clk) | ||
331 | { | ||
332 | return clk_get_rate(clk->parent) * 1024; | ||
333 | } | ||
334 | |||
335 | static unsigned long get_rate_mpll(struct clk *clk) | ||
336 | { | ||
337 | return mxc_decode_pll(__raw_readl(CCM_MPCTL0), | ||
338 | clk_get_rate(clk->parent)); | ||
339 | } | ||
340 | |||
341 | static unsigned long get_rate_mpll_main(struct clk *clk) | ||
342 | { | ||
343 | unsigned long parent_rate; | ||
344 | |||
345 | parent_rate = clk_get_rate(clk->parent); | ||
346 | |||
347 | /* i.MX27 TO2: | ||
348 | * clk->id == 0: arm clock source path 1 which is from 2 * MPLL / 2 | ||
349 | * clk->id == 1: arm clock source path 2 which is from 2 * MPLL / 3 | ||
350 | */ | ||
351 | if (mx27_revision() >= IMX_CHIP_REVISION_2_0 && clk->id == 1) | ||
352 | return 2UL * parent_rate / 3UL; | ||
353 | |||
354 | return parent_rate; | ||
355 | } | ||
356 | |||
357 | static unsigned long get_rate_spll(struct clk *clk) | ||
358 | { | ||
359 | uint32_t reg; | ||
360 | unsigned long rate; | ||
361 | |||
362 | rate = clk_get_rate(clk->parent); | ||
363 | |||
364 | reg = __raw_readl(CCM_SPCTL0); | ||
365 | |||
366 | /* On TO2 we have to write the value back. Otherwise we | ||
367 | * read 0 from this register the next time. | ||
368 | */ | ||
369 | if (mx27_revision() >= IMX_CHIP_REVISION_2_0) | ||
370 | __raw_writel(reg, CCM_SPCTL0); | ||
371 | |||
372 | return mxc_decode_pll(reg, rate); | ||
373 | } | ||
374 | |||
375 | static unsigned long get_rate_cpu(struct clk *clk) | ||
376 | { | ||
377 | u32 div; | ||
378 | unsigned long rate; | ||
379 | |||
380 | if (mx27_revision() >= IMX_CHIP_REVISION_2_0) | ||
381 | div = (__raw_readl(CCM_CSCR) >> 12) & 0x3; | ||
382 | else | ||
383 | div = (__raw_readl(CCM_CSCR) >> 13) & 0x7; | ||
384 | |||
385 | rate = clk_get_rate(clk->parent); | ||
386 | return rate / (div + 1); | ||
387 | } | ||
388 | |||
389 | static unsigned long get_rate_ahb(struct clk *clk) | ||
390 | { | ||
391 | unsigned long rate, bclk_pdf; | ||
392 | |||
393 | if (mx27_revision() >= IMX_CHIP_REVISION_2_0) | ||
394 | bclk_pdf = (__raw_readl(CCM_CSCR) >> 8) & 0x3; | ||
395 | else | ||
396 | bclk_pdf = (__raw_readl(CCM_CSCR) >> 9) & 0xf; | ||
397 | |||
398 | rate = clk_get_rate(clk->parent); | ||
399 | return rate / (bclk_pdf + 1); | ||
400 | } | ||
401 | |||
402 | static unsigned long get_rate_ipg(struct clk *clk) | ||
403 | { | ||
404 | unsigned long rate, ipg_pdf; | ||
405 | |||
406 | if (mx27_revision() >= IMX_CHIP_REVISION_2_0) | ||
407 | return clk_get_rate(clk->parent); | ||
408 | else | ||
409 | ipg_pdf = (__raw_readl(CCM_CSCR) >> 8) & 1; | ||
410 | |||
411 | rate = clk_get_rate(clk->parent); | ||
412 | return rate / (ipg_pdf + 1); | ||
413 | } | ||
414 | |||
415 | static unsigned long get_rate_per(struct clk *clk) | ||
416 | { | ||
417 | unsigned long perclk_pdf, parent_rate; | ||
418 | |||
419 | parent_rate = clk_get_rate(clk->parent); | ||
420 | |||
421 | if (clk->id < 0 || clk->id > 3) | ||
422 | return 0; | ||
423 | |||
424 | perclk_pdf = (__raw_readl(CCM_PCDR1) >> (clk->id << 3)) & 0x3f; | ||
425 | |||
426 | return parent_rate / (perclk_pdf + 1); | ||
427 | } | ||
428 | |||
429 | /* | ||
430 | * the high frequency external clock reference | ||
431 | * Default case is 26MHz. Could be changed at runtime | ||
432 | * with a call to change_external_high_reference() | ||
433 | */ | ||
434 | static struct clk ckih_clk = { | ||
435 | .get_rate = get_rate_high_reference, | ||
436 | }; | ||
437 | |||
438 | static struct clk mpll_clk = { | ||
439 | .parent = &ckih_clk, | ||
440 | .get_rate = get_rate_mpll, | ||
441 | }; | ||
442 | |||
443 | /* For i.MX27 TO2, it is the MPLL path 1 of ARM core | ||
444 | * It provides the clock source whose rate is same as MPLL | ||
445 | */ | ||
446 | static struct clk mpll_main1_clk = { | ||
447 | .id = 0, | ||
448 | .parent = &mpll_clk, | ||
449 | .get_rate = get_rate_mpll_main, | ||
450 | }; | ||
451 | |||
452 | /* For i.MX27 TO2, it is the MPLL path 2 of ARM core | ||
453 | * It provides the clock source whose rate is same MPLL * 2 / 3 | ||
454 | */ | ||
455 | static struct clk mpll_main2_clk = { | ||
456 | .id = 1, | ||
457 | .parent = &mpll_clk, | ||
458 | .get_rate = get_rate_mpll_main, | ||
459 | }; | ||
460 | |||
461 | static struct clk ahb_clk = { | ||
462 | .parent = &mpll_main2_clk, | ||
463 | .get_rate = get_rate_ahb, | ||
464 | }; | ||
465 | |||
466 | static struct clk ipg_clk = { | ||
467 | .parent = &ahb_clk, | ||
468 | .get_rate = get_rate_ipg, | ||
469 | }; | ||
470 | |||
471 | static struct clk cpu_clk = { | ||
472 | .parent = &mpll_main2_clk, | ||
473 | .set_parent = clk_cpu_set_parent, | ||
474 | .round_rate = round_rate_cpu, | ||
475 | .get_rate = get_rate_cpu, | ||
476 | .set_rate = set_rate_cpu, | ||
477 | }; | ||
478 | |||
479 | static struct clk spll_clk = { | ||
480 | .parent = &ckih_clk, | ||
481 | .get_rate = get_rate_spll, | ||
482 | .enable = clk_spll_enable, | ||
483 | .disable = clk_spll_disable, | ||
484 | }; | ||
485 | |||
486 | /* | ||
487 | * the low frequency external clock reference | ||
488 | * Default case is 32.768kHz. | ||
489 | */ | ||
490 | static struct clk ckil_clk = { | ||
491 | .get_rate = get_rate_low_reference, | ||
492 | }; | ||
493 | |||
494 | /* Output of frequency pre multiplier */ | ||
495 | static struct clk fpm_clk = { | ||
496 | .parent = &ckil_clk, | ||
497 | .get_rate = get_rate_fpm, | ||
498 | }; | ||
499 | |||
500 | #define PCCR0 CCM_PCCR0 | ||
501 | #define PCCR1 CCM_PCCR1 | ||
502 | |||
503 | #define DEFINE_CLOCK(name, i, er, es, gr, s, p) \ | ||
504 | static struct clk name = { \ | ||
505 | .id = i, \ | ||
506 | .enable_reg = er, \ | ||
507 | .enable_shift = es, \ | ||
508 | .get_rate = gr, \ | ||
509 | .enable = clk_pccr_enable, \ | ||
510 | .disable = clk_pccr_disable, \ | ||
511 | .secondary = s, \ | ||
512 | .parent = p, \ | ||
513 | } | ||
514 | |||
515 | #define DEFINE_CLOCK1(name, i, er, es, getsetround, s, p) \ | ||
516 | static struct clk name = { \ | ||
517 | .id = i, \ | ||
518 | .enable_reg = er, \ | ||
519 | .enable_shift = es, \ | ||
520 | .get_rate = get_rate_##getsetround, \ | ||
521 | .set_rate = set_rate_##getsetround, \ | ||
522 | .round_rate = round_rate_##getsetround, \ | ||
523 | .enable = clk_pccr_enable, \ | ||
524 | .disable = clk_pccr_disable, \ | ||
525 | .secondary = s, \ | ||
526 | .parent = p, \ | ||
527 | } | ||
528 | |||
529 | /* Forward declaration to keep the following list in order */ | ||
530 | static struct clk slcdc_clk1, sahara2_clk1, rtic_clk1, fec_clk1, emma_clk1, | ||
531 | dma_clk1, lcdc_clk2, vpu_clk1; | ||
532 | |||
533 | /* All clocks we can gate through PCCRx in the order of PCCRx bits */ | ||
534 | DEFINE_CLOCK(ssi2_clk1, 1, PCCR0, 0, NULL, NULL, &ipg_clk); | ||
535 | DEFINE_CLOCK(ssi1_clk1, 0, PCCR0, 1, NULL, NULL, &ipg_clk); | ||
536 | DEFINE_CLOCK(slcdc_clk, 0, PCCR0, 2, NULL, &slcdc_clk1, &ahb_clk); | ||
537 | DEFINE_CLOCK(sdhc3_clk1, 0, PCCR0, 3, NULL, NULL, &ipg_clk); | ||
538 | DEFINE_CLOCK(sdhc2_clk1, 0, PCCR0, 4, NULL, NULL, &ipg_clk); | ||
539 | DEFINE_CLOCK(sdhc1_clk1, 0, PCCR0, 5, NULL, NULL, &ipg_clk); | ||
540 | DEFINE_CLOCK(scc_clk, 0, PCCR0, 6, NULL, NULL, &ipg_clk); | ||
541 | DEFINE_CLOCK(sahara2_clk, 0, PCCR0, 7, NULL, &sahara2_clk1, &ahb_clk); | ||
542 | DEFINE_CLOCK(rtic_clk, 0, PCCR0, 8, NULL, &rtic_clk1, &ahb_clk); | ||
543 | DEFINE_CLOCK(rtc_clk, 0, PCCR0, 9, NULL, NULL, &ipg_clk); | ||
544 | DEFINE_CLOCK(pwm_clk1, 0, PCCR0, 11, NULL, NULL, &ipg_clk); | ||
545 | DEFINE_CLOCK(owire_clk, 0, PCCR0, 12, NULL, NULL, &ipg_clk); | ||
546 | DEFINE_CLOCK(mstick_clk1, 0, PCCR0, 13, NULL, NULL, &ipg_clk); | ||
547 | DEFINE_CLOCK(lcdc_clk1, 0, PCCR0, 14, NULL, &lcdc_clk2, &ipg_clk); | ||
548 | DEFINE_CLOCK(kpp_clk, 0, PCCR0, 15, NULL, NULL, &ipg_clk); | ||
549 | DEFINE_CLOCK(iim_clk, 0, PCCR0, 16, NULL, NULL, &ipg_clk); | ||
550 | DEFINE_CLOCK(i2c2_clk, 1, PCCR0, 17, NULL, NULL, &ipg_clk); | ||
551 | DEFINE_CLOCK(i2c1_clk, 0, PCCR0, 18, NULL, NULL, &ipg_clk); | ||
552 | DEFINE_CLOCK(gpt6_clk1, 0, PCCR0, 29, NULL, NULL, &ipg_clk); | ||
553 | DEFINE_CLOCK(gpt5_clk1, 0, PCCR0, 20, NULL, NULL, &ipg_clk); | ||
554 | DEFINE_CLOCK(gpt4_clk1, 0, PCCR0, 21, NULL, NULL, &ipg_clk); | ||
555 | DEFINE_CLOCK(gpt3_clk1, 0, PCCR0, 22, NULL, NULL, &ipg_clk); | ||
556 | DEFINE_CLOCK(gpt2_clk1, 0, PCCR0, 23, NULL, NULL, &ipg_clk); | ||
557 | DEFINE_CLOCK(gpt1_clk1, 0, PCCR0, 24, NULL, NULL, &ipg_clk); | ||
558 | DEFINE_CLOCK(gpio_clk, 0, PCCR0, 25, NULL, NULL, &ipg_clk); | ||
559 | DEFINE_CLOCK(fec_clk, 0, PCCR0, 26, NULL, &fec_clk1, &ahb_clk); | ||
560 | DEFINE_CLOCK(emma_clk, 0, PCCR0, 27, NULL, &emma_clk1, &ahb_clk); | ||
561 | DEFINE_CLOCK(dma_clk, 0, PCCR0, 28, NULL, &dma_clk1, &ahb_clk); | ||
562 | DEFINE_CLOCK(cspi13_clk1, 0, PCCR0, 29, NULL, NULL, &ipg_clk); | ||
563 | DEFINE_CLOCK(cspi2_clk1, 0, PCCR0, 30, NULL, NULL, &ipg_clk); | ||
564 | DEFINE_CLOCK(cspi1_clk1, 0, PCCR0, 31, NULL, NULL, &ipg_clk); | ||
565 | |||
566 | DEFINE_CLOCK(mstick_clk, 0, PCCR1, 2, NULL, &mstick_clk1, &ipg_clk); | ||
567 | DEFINE_CLOCK(nfc_clk, 0, PCCR1, 3, get_rate_nfc, NULL, &cpu_clk); | ||
568 | DEFINE_CLOCK(ssi2_clk, 1, PCCR1, 4, get_rate_ssi2, &ssi2_clk1, &mpll_main2_clk); | ||
569 | DEFINE_CLOCK(ssi1_clk, 0, PCCR1, 5, get_rate_ssi1, &ssi1_clk1, &mpll_main2_clk); | ||
570 | DEFINE_CLOCK(vpu_clk, 0, PCCR1, 6, get_rate_vpu, &vpu_clk1, &mpll_main2_clk); | ||
571 | DEFINE_CLOCK1(per4_clk, 3, PCCR1, 7, per, NULL, &mpll_main2_clk); | ||
572 | DEFINE_CLOCK1(per3_clk, 2, PCCR1, 8, per, NULL, &mpll_main2_clk); | ||
573 | DEFINE_CLOCK1(per2_clk, 1, PCCR1, 9, per, NULL, &mpll_main2_clk); | ||
574 | DEFINE_CLOCK1(per1_clk, 0, PCCR1, 10, per, NULL, &mpll_main2_clk); | ||
575 | DEFINE_CLOCK(usb_clk1, 0, PCCR1, 11, NULL, NULL, &ahb_clk); | ||
576 | DEFINE_CLOCK(slcdc_clk1, 0, PCCR1, 12, NULL, NULL, &ahb_clk); | ||
577 | DEFINE_CLOCK(sahara2_clk1, 0, PCCR1, 13, NULL, NULL, &ahb_clk); | ||
578 | DEFINE_CLOCK(rtic_clk1, 0, PCCR1, 14, NULL, NULL, &ahb_clk); | ||
579 | DEFINE_CLOCK(lcdc_clk2, 0, PCCR1, 15, NULL, NULL, &ahb_clk); | ||
580 | DEFINE_CLOCK(vpu_clk1, 0, PCCR1, 16, NULL, NULL, &ahb_clk); | ||
581 | DEFINE_CLOCK(fec_clk1, 0, PCCR1, 17, NULL, NULL, &ahb_clk); | ||
582 | DEFINE_CLOCK(emma_clk1, 0, PCCR1, 18, NULL, NULL, &ahb_clk); | ||
583 | DEFINE_CLOCK(emi_clk, 0, PCCR1, 19, NULL, NULL, &ahb_clk); | ||
584 | DEFINE_CLOCK(dma_clk1, 0, PCCR1, 20, NULL, NULL, &ahb_clk); | ||
585 | DEFINE_CLOCK(csi_clk1, 0, PCCR1, 21, NULL, NULL, &ahb_clk); | ||
586 | DEFINE_CLOCK(brom_clk, 0, PCCR1, 22, NULL, NULL, &ahb_clk); | ||
587 | DEFINE_CLOCK(pata_clk, 0, PCCR1, 23, NULL, NULL, &ahb_clk); | ||
588 | DEFINE_CLOCK(wdog_clk, 0, PCCR1, 24, NULL, NULL, &ipg_clk); | ||
589 | DEFINE_CLOCK(usb_clk, 0, PCCR1, 25, get_rate_usb, &usb_clk1, &spll_clk); | ||
590 | DEFINE_CLOCK(uart6_clk1, 0, PCCR1, 26, NULL, NULL, &ipg_clk); | ||
591 | DEFINE_CLOCK(uart5_clk1, 0, PCCR1, 27, NULL, NULL, &ipg_clk); | ||
592 | DEFINE_CLOCK(uart4_clk1, 0, PCCR1, 28, NULL, NULL, &ipg_clk); | ||
593 | DEFINE_CLOCK(uart3_clk1, 0, PCCR1, 29, NULL, NULL, &ipg_clk); | ||
594 | DEFINE_CLOCK(uart2_clk1, 0, PCCR1, 30, NULL, NULL, &ipg_clk); | ||
595 | DEFINE_CLOCK(uart1_clk1, 0, PCCR1, 31, NULL, NULL, &ipg_clk); | ||
596 | |||
597 | /* Clocks we cannot directly gate, but drivers need their rates */ | ||
598 | DEFINE_CLOCK(cspi1_clk, 0, NULL, 0, NULL, &cspi1_clk1, &per2_clk); | ||
599 | DEFINE_CLOCK(cspi2_clk, 1, NULL, 0, NULL, &cspi2_clk1, &per2_clk); | ||
600 | DEFINE_CLOCK(cspi3_clk, 2, NULL, 0, NULL, &cspi13_clk1, &per2_clk); | ||
601 | DEFINE_CLOCK(sdhc1_clk, 0, NULL, 0, NULL, &sdhc1_clk1, &per2_clk); | ||
602 | DEFINE_CLOCK(sdhc2_clk, 1, NULL, 0, NULL, &sdhc2_clk1, &per2_clk); | ||
603 | DEFINE_CLOCK(sdhc3_clk, 2, NULL, 0, NULL, &sdhc3_clk1, &per2_clk); | ||
604 | DEFINE_CLOCK(pwm_clk, 0, NULL, 0, NULL, &pwm_clk1, &per1_clk); | ||
605 | DEFINE_CLOCK(gpt1_clk, 0, NULL, 0, NULL, &gpt1_clk1, &per1_clk); | ||
606 | DEFINE_CLOCK(gpt2_clk, 1, NULL, 0, NULL, &gpt2_clk1, &per1_clk); | ||
607 | DEFINE_CLOCK(gpt3_clk, 2, NULL, 0, NULL, &gpt3_clk1, &per1_clk); | ||
608 | DEFINE_CLOCK(gpt4_clk, 3, NULL, 0, NULL, &gpt4_clk1, &per1_clk); | ||
609 | DEFINE_CLOCK(gpt5_clk, 4, NULL, 0, NULL, &gpt5_clk1, &per1_clk); | ||
610 | DEFINE_CLOCK(gpt6_clk, 5, NULL, 0, NULL, &gpt6_clk1, &per1_clk); | ||
611 | DEFINE_CLOCK(uart1_clk, 0, NULL, 0, NULL, &uart1_clk1, &per1_clk); | ||
612 | DEFINE_CLOCK(uart2_clk, 1, NULL, 0, NULL, &uart2_clk1, &per1_clk); | ||
613 | DEFINE_CLOCK(uart3_clk, 2, NULL, 0, NULL, &uart3_clk1, &per1_clk); | ||
614 | DEFINE_CLOCK(uart4_clk, 3, NULL, 0, NULL, &uart4_clk1, &per1_clk); | ||
615 | DEFINE_CLOCK(uart5_clk, 4, NULL, 0, NULL, &uart5_clk1, &per1_clk); | ||
616 | DEFINE_CLOCK(uart6_clk, 5, NULL, 0, NULL, &uart6_clk1, &per1_clk); | ||
617 | DEFINE_CLOCK1(lcdc_clk, 0, NULL, 0, parent, &lcdc_clk1, &per3_clk); | ||
618 | DEFINE_CLOCK1(csi_clk, 0, NULL, 0, parent, &csi_clk1, &per4_clk); | ||
619 | |||
620 | #define _REGISTER_CLOCK(d, n, c) \ | ||
621 | { \ | ||
622 | .dev_id = d, \ | ||
623 | .con_id = n, \ | ||
624 | .clk = &c, \ | ||
625 | }, | ||
626 | |||
627 | static struct clk_lookup lookups[] = { | ||
628 | /* i.mx27 has the i.mx21 type uart */ | ||
629 | _REGISTER_CLOCK("imx21-uart.0", NULL, uart1_clk) | ||
630 | _REGISTER_CLOCK("imx21-uart.1", NULL, uart2_clk) | ||
631 | _REGISTER_CLOCK("imx21-uart.2", NULL, uart3_clk) | ||
632 | _REGISTER_CLOCK("imx21-uart.3", NULL, uart4_clk) | ||
633 | _REGISTER_CLOCK("imx21-uart.4", NULL, uart5_clk) | ||
634 | _REGISTER_CLOCK("imx21-uart.5", NULL, uart6_clk) | ||
635 | _REGISTER_CLOCK(NULL, "gpt1", gpt1_clk) | ||
636 | _REGISTER_CLOCK(NULL, "gpt2", gpt2_clk) | ||
637 | _REGISTER_CLOCK(NULL, "gpt3", gpt3_clk) | ||
638 | _REGISTER_CLOCK(NULL, "gpt4", gpt4_clk) | ||
639 | _REGISTER_CLOCK(NULL, "gpt5", gpt5_clk) | ||
640 | _REGISTER_CLOCK(NULL, "gpt6", gpt6_clk) | ||
641 | _REGISTER_CLOCK("mxc_pwm.0", NULL, pwm_clk) | ||
642 | _REGISTER_CLOCK("mxc-mmc.0", NULL, sdhc1_clk) | ||
643 | _REGISTER_CLOCK("mxc-mmc.1", NULL, sdhc2_clk) | ||
644 | _REGISTER_CLOCK("mxc-mmc.2", NULL, sdhc3_clk) | ||
645 | _REGISTER_CLOCK("imx27-cspi.0", NULL, cspi1_clk) | ||
646 | _REGISTER_CLOCK("imx27-cspi.1", NULL, cspi2_clk) | ||
647 | _REGISTER_CLOCK("imx27-cspi.2", NULL, cspi3_clk) | ||
648 | _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk) | ||
649 | _REGISTER_CLOCK("mx2-camera.0", NULL, csi_clk) | ||
650 | _REGISTER_CLOCK("fsl-usb2-udc", "usb", usb_clk) | ||
651 | _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", usb_clk1) | ||
652 | _REGISTER_CLOCK("mxc-ehci.0", "usb", usb_clk) | ||
653 | _REGISTER_CLOCK("mxc-ehci.0", "usb_ahb", usb_clk1) | ||
654 | _REGISTER_CLOCK("mxc-ehci.1", "usb", usb_clk) | ||
655 | _REGISTER_CLOCK("mxc-ehci.1", "usb_ahb", usb_clk1) | ||
656 | _REGISTER_CLOCK("mxc-ehci.2", "usb", usb_clk) | ||
657 | _REGISTER_CLOCK("mxc-ehci.2", "usb_ahb", usb_clk1) | ||
658 | _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk) | ||
659 | _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk) | ||
660 | _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk) | ||
661 | _REGISTER_CLOCK(NULL, "vpu", vpu_clk) | ||
662 | _REGISTER_CLOCK(NULL, "dma", dma_clk) | ||
663 | _REGISTER_CLOCK(NULL, "rtic", rtic_clk) | ||
664 | _REGISTER_CLOCK(NULL, "brom", brom_clk) | ||
665 | _REGISTER_CLOCK(NULL, "emma", emma_clk) | ||
666 | _REGISTER_CLOCK("m2m-emmaprp.0", NULL, emma_clk) | ||
667 | _REGISTER_CLOCK(NULL, "slcdc", slcdc_clk) | ||
668 | _REGISTER_CLOCK("imx27-fec.0", NULL, fec_clk) | ||
669 | _REGISTER_CLOCK(NULL, "emi", emi_clk) | ||
670 | _REGISTER_CLOCK(NULL, "sahara2", sahara2_clk) | ||
671 | _REGISTER_CLOCK("pata_imx", NULL, pata_clk) | ||
672 | _REGISTER_CLOCK(NULL, "mstick", mstick_clk) | ||
673 | _REGISTER_CLOCK("imx2-wdt.0", NULL, wdog_clk) | ||
674 | _REGISTER_CLOCK(NULL, "gpio", gpio_clk) | ||
675 | _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk) | ||
676 | _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk) | ||
677 | _REGISTER_CLOCK(NULL, "iim", iim_clk) | ||
678 | _REGISTER_CLOCK(NULL, "kpp", kpp_clk) | ||
679 | _REGISTER_CLOCK("mxc_w1.0", NULL, owire_clk) | ||
680 | _REGISTER_CLOCK(NULL, "rtc", rtc_clk) | ||
681 | _REGISTER_CLOCK(NULL, "scc", scc_clk) | ||
682 | }; | ||
683 | |||
684 | /* Adjust the clock path for TO2 and later */ | ||
685 | static void __init to2_adjust_clocks(void) | ||
686 | { | ||
687 | unsigned long cscr = __raw_readl(CCM_CSCR); | ||
688 | |||
689 | if (mx27_revision() >= IMX_CHIP_REVISION_2_0) { | ||
690 | if (cscr & CCM_CSCR_ARM_SRC) | ||
691 | cpu_clk.parent = &mpll_main1_clk; | ||
692 | |||
693 | if (!(cscr & CCM_CSCR_SSI2)) | ||
694 | ssi1_clk.parent = &spll_clk; | ||
695 | |||
696 | if (!(cscr & CCM_CSCR_SSI1)) | ||
697 | ssi1_clk.parent = &spll_clk; | ||
698 | |||
699 | if (!(cscr & CCM_CSCR_VPU)) | ||
700 | vpu_clk.parent = &spll_clk; | ||
701 | } else { | ||
702 | cpu_clk.parent = &mpll_clk; | ||
703 | cpu_clk.set_parent = NULL; | ||
704 | cpu_clk.round_rate = NULL; | ||
705 | cpu_clk.set_rate = NULL; | ||
706 | ahb_clk.parent = &mpll_clk; | ||
707 | |||
708 | per1_clk.parent = &mpll_clk; | ||
709 | per2_clk.parent = &mpll_clk; | ||
710 | per3_clk.parent = &mpll_clk; | ||
711 | per4_clk.parent = &mpll_clk; | ||
712 | |||
713 | ssi1_clk.parent = &mpll_clk; | ||
714 | ssi2_clk.parent = &mpll_clk; | ||
715 | |||
716 | vpu_clk.parent = &mpll_clk; | ||
717 | } | ||
718 | } | ||
719 | |||
720 | /* | ||
721 | * must be called very early to get information about the | ||
722 | * available clock rate when the timer framework starts | ||
723 | */ | ||
724 | int __init mx27_clocks_init(unsigned long fref) | ||
725 | { | ||
726 | u32 cscr = __raw_readl(CCM_CSCR); | ||
727 | |||
728 | external_high_reference = fref; | ||
729 | |||
730 | /* detect clock reference for both system PLLs */ | ||
731 | if (cscr & CCM_CSCR_MCU) | ||
732 | mpll_clk.parent = &ckih_clk; | ||
733 | else | ||
734 | mpll_clk.parent = &fpm_clk; | ||
735 | |||
736 | if (cscr & CCM_CSCR_SP) | ||
737 | spll_clk.parent = &ckih_clk; | ||
738 | else | ||
739 | spll_clk.parent = &fpm_clk; | ||
740 | |||
741 | to2_adjust_clocks(); | ||
742 | |||
743 | clkdev_add_table(lookups, ARRAY_SIZE(lookups)); | ||
744 | |||
745 | /* Turn off all clocks we do not need */ | ||
746 | __raw_writel(0, CCM_PCCR0); | ||
747 | __raw_writel((1 << 10) | (1 << 19), CCM_PCCR1); | ||
748 | |||
749 | spll_clk.disable(&spll_clk); | ||
750 | |||
751 | /* enable basic clocks */ | ||
752 | clk_enable(&per1_clk); | ||
753 | clk_enable(&gpio_clk); | ||
754 | clk_enable(&emi_clk); | ||
755 | clk_enable(&iim_clk); | ||
756 | imx_print_silicon_rev("i.MX27", mx27_revision()); | ||
757 | clk_disable(&iim_clk); | ||
758 | |||
759 | #if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC) | ||
760 | clk_enable(&uart1_clk); | ||
761 | #endif | ||
762 | |||
763 | mxc_timer_init(&gpt1_clk, MX27_IO_ADDRESS(MX27_GPT1_BASE_ADDR), | ||
764 | MX27_INT_GPT1); | ||
765 | |||
766 | return 0; | ||
767 | } | ||
768 | |||
769 | #ifdef CONFIG_OF | ||
770 | int __init mx27_clocks_init_dt(void) | ||
771 | { | ||
772 | struct device_node *np; | ||
773 | u32 fref = 26000000; /* default */ | ||
774 | |||
775 | for_each_compatible_node(np, NULL, "fixed-clock") { | ||
776 | if (!of_device_is_compatible(np, "fsl,imx-osc26m")) | ||
777 | continue; | ||
778 | |||
779 | if (!of_property_read_u32(np, "clock-frequency", &fref)) | ||
780 | break; | ||
781 | } | ||
782 | |||
783 | return mx27_clocks_init(fref); | ||
784 | } | ||
785 | #endif | ||
diff --git a/arch/arm/mach-imx/clock-imx31.c b/arch/arm/mach-imx/clock-imx31.c deleted file mode 100644 index 3a943cd4159f..000000000000 --- a/arch/arm/mach-imx/clock-imx31.c +++ /dev/null | |||
@@ -1,630 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved. | ||
3 | * Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version 2 | ||
8 | * of the License, or (at your option) any later version. | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
17 | * MA 02110-1301, USA. | ||
18 | */ | ||
19 | |||
20 | #include <linux/module.h> | ||
21 | #include <linux/spinlock.h> | ||
22 | #include <linux/delay.h> | ||
23 | #include <linux/clk.h> | ||
24 | #include <linux/err.h> | ||
25 | #include <linux/io.h> | ||
26 | #include <linux/clkdev.h> | ||
27 | |||
28 | #include <asm/div64.h> | ||
29 | |||
30 | #include <mach/clock.h> | ||
31 | #include <mach/hardware.h> | ||
32 | #include <mach/mx31.h> | ||
33 | #include <mach/common.h> | ||
34 | |||
35 | #include "crmregs-imx3.h" | ||
36 | |||
37 | #define PRE_DIV_MIN_FREQ 10000000 /* Minimum Frequency after Predivider */ | ||
38 | |||
39 | static void __calc_pre_post_dividers(u32 div, u32 *pre, u32 *post) | ||
40 | { | ||
41 | u32 min_pre, temp_pre, old_err, err; | ||
42 | |||
43 | if (div >= 512) { | ||
44 | *pre = 8; | ||
45 | *post = 64; | ||
46 | } else if (div >= 64) { | ||
47 | min_pre = (div - 1) / 64 + 1; | ||
48 | old_err = 8; | ||
49 | for (temp_pre = 8; temp_pre >= min_pre; temp_pre--) { | ||
50 | err = div % temp_pre; | ||
51 | if (err == 0) { | ||
52 | *pre = temp_pre; | ||
53 | break; | ||
54 | } | ||
55 | err = temp_pre - err; | ||
56 | if (err < old_err) { | ||
57 | old_err = err; | ||
58 | *pre = temp_pre; | ||
59 | } | ||
60 | } | ||
61 | *post = (div + *pre - 1) / *pre; | ||
62 | } else if (div <= 8) { | ||
63 | *pre = div; | ||
64 | *post = 1; | ||
65 | } else { | ||
66 | *pre = 1; | ||
67 | *post = div; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | static struct clk mcu_pll_clk; | ||
72 | static struct clk serial_pll_clk; | ||
73 | static struct clk ipg_clk; | ||
74 | static struct clk ckih_clk; | ||
75 | |||
76 | static int cgr_enable(struct clk *clk) | ||
77 | { | ||
78 | u32 reg; | ||
79 | |||
80 | if (!clk->enable_reg) | ||
81 | return 0; | ||
82 | |||
83 | reg = __raw_readl(clk->enable_reg); | ||
84 | reg |= 3 << clk->enable_shift; | ||
85 | __raw_writel(reg, clk->enable_reg); | ||
86 | |||
87 | return 0; | ||
88 | } | ||
89 | |||
90 | static void cgr_disable(struct clk *clk) | ||
91 | { | ||
92 | u32 reg; | ||
93 | |||
94 | if (!clk->enable_reg) | ||
95 | return; | ||
96 | |||
97 | reg = __raw_readl(clk->enable_reg); | ||
98 | reg &= ~(3 << clk->enable_shift); | ||
99 | |||
100 | /* special case for EMI clock */ | ||
101 | if (clk->enable_reg == MXC_CCM_CGR2 && clk->enable_shift == 8) | ||
102 | reg |= (1 << clk->enable_shift); | ||
103 | |||
104 | __raw_writel(reg, clk->enable_reg); | ||
105 | } | ||
106 | |||
107 | static unsigned long pll_ref_get_rate(void) | ||
108 | { | ||
109 | unsigned long ccmr; | ||
110 | unsigned int prcs; | ||
111 | |||
112 | ccmr = __raw_readl(MXC_CCM_CCMR); | ||
113 | prcs = (ccmr & MXC_CCM_CCMR_PRCS_MASK) >> MXC_CCM_CCMR_PRCS_OFFSET; | ||
114 | if (prcs == 0x1) | ||
115 | return CKIL_CLK_FREQ * 1024; | ||
116 | else | ||
117 | return clk_get_rate(&ckih_clk); | ||
118 | } | ||
119 | |||
120 | static unsigned long usb_pll_get_rate(struct clk *clk) | ||
121 | { | ||
122 | unsigned long reg; | ||
123 | |||
124 | reg = __raw_readl(MXC_CCM_UPCTL); | ||
125 | |||
126 | return mxc_decode_pll(reg, pll_ref_get_rate()); | ||
127 | } | ||
128 | |||
129 | static unsigned long serial_pll_get_rate(struct clk *clk) | ||
130 | { | ||
131 | unsigned long reg; | ||
132 | |||
133 | reg = __raw_readl(MXC_CCM_SRPCTL); | ||
134 | |||
135 | return mxc_decode_pll(reg, pll_ref_get_rate()); | ||
136 | } | ||
137 | |||
138 | static unsigned long mcu_pll_get_rate(struct clk *clk) | ||
139 | { | ||
140 | unsigned long reg, ccmr; | ||
141 | |||
142 | ccmr = __raw_readl(MXC_CCM_CCMR); | ||
143 | |||
144 | if (!(ccmr & MXC_CCM_CCMR_MPE) || (ccmr & MXC_CCM_CCMR_MDS)) | ||
145 | return clk_get_rate(&ckih_clk); | ||
146 | |||
147 | reg = __raw_readl(MXC_CCM_MPCTL); | ||
148 | |||
149 | return mxc_decode_pll(reg, pll_ref_get_rate()); | ||
150 | } | ||
151 | |||
152 | static int usb_pll_enable(struct clk *clk) | ||
153 | { | ||
154 | u32 reg; | ||
155 | |||
156 | reg = __raw_readl(MXC_CCM_CCMR); | ||
157 | reg |= MXC_CCM_CCMR_UPE; | ||
158 | __raw_writel(reg, MXC_CCM_CCMR); | ||
159 | |||
160 | /* No lock bit on MX31, so using max time from spec */ | ||
161 | udelay(80); | ||
162 | |||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | static void usb_pll_disable(struct clk *clk) | ||
167 | { | ||
168 | u32 reg; | ||
169 | |||
170 | reg = __raw_readl(MXC_CCM_CCMR); | ||
171 | reg &= ~MXC_CCM_CCMR_UPE; | ||
172 | __raw_writel(reg, MXC_CCM_CCMR); | ||
173 | } | ||
174 | |||
175 | static int serial_pll_enable(struct clk *clk) | ||
176 | { | ||
177 | u32 reg; | ||
178 | |||
179 | reg = __raw_readl(MXC_CCM_CCMR); | ||
180 | reg |= MXC_CCM_CCMR_SPE; | ||
181 | __raw_writel(reg, MXC_CCM_CCMR); | ||
182 | |||
183 | /* No lock bit on MX31, so using max time from spec */ | ||
184 | udelay(80); | ||
185 | |||
186 | return 0; | ||
187 | } | ||
188 | |||
189 | static void serial_pll_disable(struct clk *clk) | ||
190 | { | ||
191 | u32 reg; | ||
192 | |||
193 | reg = __raw_readl(MXC_CCM_CCMR); | ||
194 | reg &= ~MXC_CCM_CCMR_SPE; | ||
195 | __raw_writel(reg, MXC_CCM_CCMR); | ||
196 | } | ||
197 | |||
198 | #define PDR0(mask, off) ((__raw_readl(MXC_CCM_PDR0) & mask) >> off) | ||
199 | #define PDR1(mask, off) ((__raw_readl(MXC_CCM_PDR1) & mask) >> off) | ||
200 | #define PDR2(mask, off) ((__raw_readl(MXC_CCM_PDR2) & mask) >> off) | ||
201 | |||
202 | static unsigned long mcu_main_get_rate(struct clk *clk) | ||
203 | { | ||
204 | u32 pmcr0 = __raw_readl(MXC_CCM_PMCR0); | ||
205 | |||
206 | if ((pmcr0 & MXC_CCM_PMCR0_DFSUP1) == MXC_CCM_PMCR0_DFSUP1_SPLL) | ||
207 | return clk_get_rate(&serial_pll_clk); | ||
208 | else | ||
209 | return clk_get_rate(&mcu_pll_clk); | ||
210 | } | ||
211 | |||
212 | static unsigned long ahb_get_rate(struct clk *clk) | ||
213 | { | ||
214 | unsigned long max_pdf; | ||
215 | |||
216 | max_pdf = PDR0(MXC_CCM_PDR0_MAX_PODF_MASK, | ||
217 | MXC_CCM_PDR0_MAX_PODF_OFFSET); | ||
218 | return clk_get_rate(clk->parent) / (max_pdf + 1); | ||
219 | } | ||
220 | |||
221 | static unsigned long ipg_get_rate(struct clk *clk) | ||
222 | { | ||
223 | unsigned long ipg_pdf; | ||
224 | |||
225 | ipg_pdf = PDR0(MXC_CCM_PDR0_IPG_PODF_MASK, | ||
226 | MXC_CCM_PDR0_IPG_PODF_OFFSET); | ||
227 | return clk_get_rate(clk->parent) / (ipg_pdf + 1); | ||
228 | } | ||
229 | |||
230 | static unsigned long nfc_get_rate(struct clk *clk) | ||
231 | { | ||
232 | unsigned long nfc_pdf; | ||
233 | |||
234 | nfc_pdf = PDR0(MXC_CCM_PDR0_NFC_PODF_MASK, | ||
235 | MXC_CCM_PDR0_NFC_PODF_OFFSET); | ||
236 | return clk_get_rate(clk->parent) / (nfc_pdf + 1); | ||
237 | } | ||
238 | |||
239 | static unsigned long hsp_get_rate(struct clk *clk) | ||
240 | { | ||
241 | unsigned long hsp_pdf; | ||
242 | |||
243 | hsp_pdf = PDR0(MXC_CCM_PDR0_HSP_PODF_MASK, | ||
244 | MXC_CCM_PDR0_HSP_PODF_OFFSET); | ||
245 | return clk_get_rate(clk->parent) / (hsp_pdf + 1); | ||
246 | } | ||
247 | |||
248 | static unsigned long usb_get_rate(struct clk *clk) | ||
249 | { | ||
250 | unsigned long usb_pdf, usb_prepdf; | ||
251 | |||
252 | usb_pdf = PDR1(MXC_CCM_PDR1_USB_PODF_MASK, | ||
253 | MXC_CCM_PDR1_USB_PODF_OFFSET); | ||
254 | usb_prepdf = PDR1(MXC_CCM_PDR1_USB_PRDF_MASK, | ||
255 | MXC_CCM_PDR1_USB_PRDF_OFFSET); | ||
256 | return clk_get_rate(clk->parent) / (usb_prepdf + 1) / (usb_pdf + 1); | ||
257 | } | ||
258 | |||
259 | static unsigned long csi_get_rate(struct clk *clk) | ||
260 | { | ||
261 | u32 reg, pre, post; | ||
262 | |||
263 | reg = __raw_readl(MXC_CCM_PDR0); | ||
264 | pre = (reg & MXC_CCM_PDR0_CSI_PRDF_MASK) >> | ||
265 | MXC_CCM_PDR0_CSI_PRDF_OFFSET; | ||
266 | pre++; | ||
267 | post = (reg & MXC_CCM_PDR0_CSI_PODF_MASK) >> | ||
268 | MXC_CCM_PDR0_CSI_PODF_OFFSET; | ||
269 | post++; | ||
270 | return clk_get_rate(clk->parent) / (pre * post); | ||
271 | } | ||
272 | |||
273 | static unsigned long csi_round_rate(struct clk *clk, unsigned long rate) | ||
274 | { | ||
275 | u32 pre, post, parent = clk_get_rate(clk->parent); | ||
276 | u32 div = parent / rate; | ||
277 | |||
278 | if (parent % rate) | ||
279 | div++; | ||
280 | |||
281 | __calc_pre_post_dividers(div, &pre, &post); | ||
282 | |||
283 | return parent / (pre * post); | ||
284 | } | ||
285 | |||
286 | static int csi_set_rate(struct clk *clk, unsigned long rate) | ||
287 | { | ||
288 | u32 reg, div, pre, post, parent = clk_get_rate(clk->parent); | ||
289 | |||
290 | div = parent / rate; | ||
291 | |||
292 | if ((parent / div) != rate) | ||
293 | return -EINVAL; | ||
294 | |||
295 | __calc_pre_post_dividers(div, &pre, &post); | ||
296 | |||
297 | /* Set CSI clock divider */ | ||
298 | reg = __raw_readl(MXC_CCM_PDR0) & | ||
299 | ~(MXC_CCM_PDR0_CSI_PODF_MASK | MXC_CCM_PDR0_CSI_PRDF_MASK); | ||
300 | reg |= (post - 1) << MXC_CCM_PDR0_CSI_PODF_OFFSET; | ||
301 | reg |= (pre - 1) << MXC_CCM_PDR0_CSI_PRDF_OFFSET; | ||
302 | __raw_writel(reg, MXC_CCM_PDR0); | ||
303 | |||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | static unsigned long ssi1_get_rate(struct clk *clk) | ||
308 | { | ||
309 | unsigned long ssi1_pdf, ssi1_prepdf; | ||
310 | |||
311 | ssi1_pdf = PDR1(MXC_CCM_PDR1_SSI1_PODF_MASK, | ||
312 | MXC_CCM_PDR1_SSI1_PODF_OFFSET); | ||
313 | ssi1_prepdf = PDR1(MXC_CCM_PDR1_SSI1_PRE_PODF_MASK, | ||
314 | MXC_CCM_PDR1_SSI1_PRE_PODF_OFFSET); | ||
315 | return clk_get_rate(clk->parent) / (ssi1_prepdf + 1) / (ssi1_pdf + 1); | ||
316 | } | ||
317 | |||
318 | static unsigned long ssi2_get_rate(struct clk *clk) | ||
319 | { | ||
320 | unsigned long ssi2_pdf, ssi2_prepdf; | ||
321 | |||
322 | ssi2_pdf = PDR1(MXC_CCM_PDR1_SSI2_PODF_MASK, | ||
323 | MXC_CCM_PDR1_SSI2_PODF_OFFSET); | ||
324 | ssi2_prepdf = PDR1(MXC_CCM_PDR1_SSI2_PRE_PODF_MASK, | ||
325 | MXC_CCM_PDR1_SSI2_PRE_PODF_OFFSET); | ||
326 | return clk_get_rate(clk->parent) / (ssi2_prepdf + 1) / (ssi2_pdf + 1); | ||
327 | } | ||
328 | |||
329 | static unsigned long firi_get_rate(struct clk *clk) | ||
330 | { | ||
331 | unsigned long firi_pdf, firi_prepdf; | ||
332 | |||
333 | firi_pdf = PDR1(MXC_CCM_PDR1_FIRI_PODF_MASK, | ||
334 | MXC_CCM_PDR1_FIRI_PODF_OFFSET); | ||
335 | firi_prepdf = PDR1(MXC_CCM_PDR1_FIRI_PRE_PODF_MASK, | ||
336 | MXC_CCM_PDR1_FIRI_PRE_PODF_OFFSET); | ||
337 | return clk_get_rate(clk->parent) / (firi_prepdf + 1) / (firi_pdf + 1); | ||
338 | } | ||
339 | |||
340 | static unsigned long firi_round_rate(struct clk *clk, unsigned long rate) | ||
341 | { | ||
342 | u32 pre, post; | ||
343 | u32 parent = clk_get_rate(clk->parent); | ||
344 | u32 div = parent / rate; | ||
345 | |||
346 | if (parent % rate) | ||
347 | div++; | ||
348 | |||
349 | __calc_pre_post_dividers(div, &pre, &post); | ||
350 | |||
351 | return parent / (pre * post); | ||
352 | |||
353 | } | ||
354 | |||
355 | static int firi_set_rate(struct clk *clk, unsigned long rate) | ||
356 | { | ||
357 | u32 reg, div, pre, post, parent = clk_get_rate(clk->parent); | ||
358 | |||
359 | div = parent / rate; | ||
360 | |||
361 | if ((parent / div) != rate) | ||
362 | return -EINVAL; | ||
363 | |||
364 | __calc_pre_post_dividers(div, &pre, &post); | ||
365 | |||
366 | /* Set FIRI clock divider */ | ||
367 | reg = __raw_readl(MXC_CCM_PDR1) & | ||
368 | ~(MXC_CCM_PDR1_FIRI_PODF_MASK | MXC_CCM_PDR1_FIRI_PRE_PODF_MASK); | ||
369 | reg |= (pre - 1) << MXC_CCM_PDR1_FIRI_PRE_PODF_OFFSET; | ||
370 | reg |= (post - 1) << MXC_CCM_PDR1_FIRI_PODF_OFFSET; | ||
371 | __raw_writel(reg, MXC_CCM_PDR1); | ||
372 | |||
373 | return 0; | ||
374 | } | ||
375 | |||
376 | static unsigned long mbx_get_rate(struct clk *clk) | ||
377 | { | ||
378 | return clk_get_rate(clk->parent) / 2; | ||
379 | } | ||
380 | |||
381 | static unsigned long mstick1_get_rate(struct clk *clk) | ||
382 | { | ||
383 | unsigned long msti_pdf; | ||
384 | |||
385 | msti_pdf = PDR2(MXC_CCM_PDR2_MST1_PDF_MASK, | ||
386 | MXC_CCM_PDR2_MST1_PDF_OFFSET); | ||
387 | return clk_get_rate(clk->parent) / (msti_pdf + 1); | ||
388 | } | ||
389 | |||
390 | static unsigned long mstick2_get_rate(struct clk *clk) | ||
391 | { | ||
392 | unsigned long msti_pdf; | ||
393 | |||
394 | msti_pdf = PDR2(MXC_CCM_PDR2_MST2_PDF_MASK, | ||
395 | MXC_CCM_PDR2_MST2_PDF_OFFSET); | ||
396 | return clk_get_rate(clk->parent) / (msti_pdf + 1); | ||
397 | } | ||
398 | |||
399 | static unsigned long ckih_rate; | ||
400 | |||
401 | static unsigned long clk_ckih_get_rate(struct clk *clk) | ||
402 | { | ||
403 | return ckih_rate; | ||
404 | } | ||
405 | |||
406 | static unsigned long clk_ckil_get_rate(struct clk *clk) | ||
407 | { | ||
408 | return CKIL_CLK_FREQ; | ||
409 | } | ||
410 | |||
411 | static struct clk ckih_clk = { | ||
412 | .get_rate = clk_ckih_get_rate, | ||
413 | }; | ||
414 | |||
415 | static struct clk mcu_pll_clk = { | ||
416 | .parent = &ckih_clk, | ||
417 | .get_rate = mcu_pll_get_rate, | ||
418 | }; | ||
419 | |||
420 | static struct clk mcu_main_clk = { | ||
421 | .parent = &mcu_pll_clk, | ||
422 | .get_rate = mcu_main_get_rate, | ||
423 | }; | ||
424 | |||
425 | static struct clk serial_pll_clk = { | ||
426 | .parent = &ckih_clk, | ||
427 | .get_rate = serial_pll_get_rate, | ||
428 | .enable = serial_pll_enable, | ||
429 | .disable = serial_pll_disable, | ||
430 | }; | ||
431 | |||
432 | static struct clk usb_pll_clk = { | ||
433 | .parent = &ckih_clk, | ||
434 | .get_rate = usb_pll_get_rate, | ||
435 | .enable = usb_pll_enable, | ||
436 | .disable = usb_pll_disable, | ||
437 | }; | ||
438 | |||
439 | static struct clk ahb_clk = { | ||
440 | .parent = &mcu_main_clk, | ||
441 | .get_rate = ahb_get_rate, | ||
442 | }; | ||
443 | |||
444 | #define DEFINE_CLOCK(name, i, er, es, gr, s, p) \ | ||
445 | static struct clk name = { \ | ||
446 | .id = i, \ | ||
447 | .enable_reg = er, \ | ||
448 | .enable_shift = es, \ | ||
449 | .get_rate = gr, \ | ||
450 | .enable = cgr_enable, \ | ||
451 | .disable = cgr_disable, \ | ||
452 | .secondary = s, \ | ||
453 | .parent = p, \ | ||
454 | } | ||
455 | |||
456 | #define DEFINE_CLOCK1(name, i, er, es, getsetround, s, p) \ | ||
457 | static struct clk name = { \ | ||
458 | .id = i, \ | ||
459 | .enable_reg = er, \ | ||
460 | .enable_shift = es, \ | ||
461 | .get_rate = getsetround##_get_rate, \ | ||
462 | .set_rate = getsetround##_set_rate, \ | ||
463 | .round_rate = getsetround##_round_rate, \ | ||
464 | .enable = cgr_enable, \ | ||
465 | .disable = cgr_disable, \ | ||
466 | .secondary = s, \ | ||
467 | .parent = p, \ | ||
468 | } | ||
469 | |||
470 | DEFINE_CLOCK(perclk_clk, 0, NULL, 0, NULL, NULL, &ipg_clk); | ||
471 | DEFINE_CLOCK(ckil_clk, 0, NULL, 0, clk_ckil_get_rate, NULL, NULL); | ||
472 | |||
473 | DEFINE_CLOCK(sdhc1_clk, 0, MXC_CCM_CGR0, 0, NULL, NULL, &perclk_clk); | ||
474 | DEFINE_CLOCK(sdhc2_clk, 1, MXC_CCM_CGR0, 2, NULL, NULL, &perclk_clk); | ||
475 | DEFINE_CLOCK(gpt_clk, 0, MXC_CCM_CGR0, 4, NULL, NULL, &perclk_clk); | ||
476 | DEFINE_CLOCK(epit1_clk, 0, MXC_CCM_CGR0, 6, NULL, NULL, &perclk_clk); | ||
477 | DEFINE_CLOCK(epit2_clk, 1, MXC_CCM_CGR0, 8, NULL, NULL, &perclk_clk); | ||
478 | DEFINE_CLOCK(iim_clk, 0, MXC_CCM_CGR0, 10, NULL, NULL, &ipg_clk); | ||
479 | DEFINE_CLOCK(pata_clk, 0, MXC_CCM_CGR0, 12, NULL, NULL, &ipg_clk); | ||
480 | DEFINE_CLOCK(sdma_clk1, 0, MXC_CCM_CGR0, 14, NULL, NULL, &ahb_clk); | ||
481 | DEFINE_CLOCK(cspi3_clk, 2, MXC_CCM_CGR0, 16, NULL, NULL, &ipg_clk); | ||
482 | DEFINE_CLOCK(rng_clk, 0, MXC_CCM_CGR0, 18, NULL, NULL, &ipg_clk); | ||
483 | DEFINE_CLOCK(uart1_clk, 0, MXC_CCM_CGR0, 20, NULL, NULL, &perclk_clk); | ||
484 | DEFINE_CLOCK(uart2_clk, 1, MXC_CCM_CGR0, 22, NULL, NULL, &perclk_clk); | ||
485 | DEFINE_CLOCK(ssi1_clk, 0, MXC_CCM_CGR0, 24, ssi1_get_rate, NULL, &serial_pll_clk); | ||
486 | DEFINE_CLOCK(i2c1_clk, 0, MXC_CCM_CGR0, 26, NULL, NULL, &perclk_clk); | ||
487 | DEFINE_CLOCK(i2c2_clk, 1, MXC_CCM_CGR0, 28, NULL, NULL, &perclk_clk); | ||
488 | DEFINE_CLOCK(i2c3_clk, 2, MXC_CCM_CGR0, 30, NULL, NULL, &perclk_clk); | ||
489 | |||
490 | DEFINE_CLOCK(mpeg4_clk, 0, MXC_CCM_CGR1, 0, NULL, NULL, &ahb_clk); | ||
491 | DEFINE_CLOCK(mstick1_clk, 0, MXC_CCM_CGR1, 2, mstick1_get_rate, NULL, &usb_pll_clk); | ||
492 | DEFINE_CLOCK(mstick2_clk, 1, MXC_CCM_CGR1, 4, mstick2_get_rate, NULL, &usb_pll_clk); | ||
493 | DEFINE_CLOCK1(csi_clk, 0, MXC_CCM_CGR1, 6, csi, NULL, &serial_pll_clk); | ||
494 | DEFINE_CLOCK(rtc_clk, 0, MXC_CCM_CGR1, 8, NULL, NULL, &ckil_clk); | ||
495 | DEFINE_CLOCK(wdog_clk, 0, MXC_CCM_CGR1, 10, NULL, NULL, &ipg_clk); | ||
496 | DEFINE_CLOCK(pwm_clk, 0, MXC_CCM_CGR1, 12, NULL, NULL, &perclk_clk); | ||
497 | DEFINE_CLOCK(usb_clk2, 0, MXC_CCM_CGR1, 18, usb_get_rate, NULL, &ahb_clk); | ||
498 | DEFINE_CLOCK(kpp_clk, 0, MXC_CCM_CGR1, 20, NULL, NULL, &ipg_clk); | ||
499 | DEFINE_CLOCK(ipu_clk, 0, MXC_CCM_CGR1, 22, hsp_get_rate, NULL, &mcu_main_clk); | ||
500 | DEFINE_CLOCK(uart3_clk, 2, MXC_CCM_CGR1, 24, NULL, NULL, &perclk_clk); | ||
501 | DEFINE_CLOCK(uart4_clk, 3, MXC_CCM_CGR1, 26, NULL, NULL, &perclk_clk); | ||
502 | DEFINE_CLOCK(uart5_clk, 4, MXC_CCM_CGR1, 28, NULL, NULL, &perclk_clk); | ||
503 | DEFINE_CLOCK(owire_clk, 0, MXC_CCM_CGR1, 30, NULL, NULL, &perclk_clk); | ||
504 | |||
505 | DEFINE_CLOCK(ssi2_clk, 1, MXC_CCM_CGR2, 0, ssi2_get_rate, NULL, &serial_pll_clk); | ||
506 | DEFINE_CLOCK(cspi1_clk, 0, MXC_CCM_CGR2, 2, NULL, NULL, &ipg_clk); | ||
507 | DEFINE_CLOCK(cspi2_clk, 1, MXC_CCM_CGR2, 4, NULL, NULL, &ipg_clk); | ||
508 | DEFINE_CLOCK(mbx_clk, 0, MXC_CCM_CGR2, 6, mbx_get_rate, NULL, &ahb_clk); | ||
509 | DEFINE_CLOCK(emi_clk, 0, MXC_CCM_CGR2, 8, NULL, NULL, &ahb_clk); | ||
510 | DEFINE_CLOCK(rtic_clk, 0, MXC_CCM_CGR2, 10, NULL, NULL, &ahb_clk); | ||
511 | DEFINE_CLOCK1(firi_clk, 0, MXC_CCM_CGR2, 12, firi, NULL, &usb_pll_clk); | ||
512 | |||
513 | DEFINE_CLOCK(sdma_clk2, 0, NULL, 0, NULL, NULL, &ipg_clk); | ||
514 | DEFINE_CLOCK(usb_clk1, 0, NULL, 0, usb_get_rate, NULL, &usb_pll_clk); | ||
515 | DEFINE_CLOCK(nfc_clk, 0, NULL, 0, nfc_get_rate, NULL, &ahb_clk); | ||
516 | DEFINE_CLOCK(scc_clk, 0, NULL, 0, NULL, NULL, &ipg_clk); | ||
517 | DEFINE_CLOCK(ipg_clk, 0, NULL, 0, ipg_get_rate, NULL, &ahb_clk); | ||
518 | |||
519 | #define _REGISTER_CLOCK(d, n, c) \ | ||
520 | { \ | ||
521 | .dev_id = d, \ | ||
522 | .con_id = n, \ | ||
523 | .clk = &c, \ | ||
524 | }, | ||
525 | |||
526 | static struct clk_lookup lookups[] = { | ||
527 | _REGISTER_CLOCK(NULL, "emi", emi_clk) | ||
528 | _REGISTER_CLOCK("imx31-cspi.0", NULL, cspi1_clk) | ||
529 | _REGISTER_CLOCK("imx31-cspi.1", NULL, cspi2_clk) | ||
530 | _REGISTER_CLOCK("imx31-cspi.2", NULL, cspi3_clk) | ||
531 | _REGISTER_CLOCK(NULL, "gpt", gpt_clk) | ||
532 | _REGISTER_CLOCK(NULL, "pwm", pwm_clk) | ||
533 | _REGISTER_CLOCK("imx2-wdt.0", NULL, wdog_clk) | ||
534 | _REGISTER_CLOCK(NULL, "rtc", rtc_clk) | ||
535 | _REGISTER_CLOCK(NULL, "epit", epit1_clk) | ||
536 | _REGISTER_CLOCK(NULL, "epit", epit2_clk) | ||
537 | _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk) | ||
538 | _REGISTER_CLOCK("ipu-core", NULL, ipu_clk) | ||
539 | _REGISTER_CLOCK("mx3_sdc_fb", NULL, ipu_clk) | ||
540 | _REGISTER_CLOCK(NULL, "kpp", kpp_clk) | ||
541 | _REGISTER_CLOCK("mxc-ehci.0", "usb", usb_clk1) | ||
542 | _REGISTER_CLOCK("mxc-ehci.0", "usb_ahb", usb_clk2) | ||
543 | _REGISTER_CLOCK("mxc-ehci.1", "usb", usb_clk1) | ||
544 | _REGISTER_CLOCK("mxc-ehci.1", "usb_ahb", usb_clk2) | ||
545 | _REGISTER_CLOCK("mxc-ehci.2", "usb", usb_clk1) | ||
546 | _REGISTER_CLOCK("mxc-ehci.2", "usb_ahb", usb_clk2) | ||
547 | _REGISTER_CLOCK("fsl-usb2-udc", "usb", usb_clk1) | ||
548 | _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", usb_clk2) | ||
549 | _REGISTER_CLOCK("mx3-camera.0", NULL, csi_clk) | ||
550 | /* i.mx31 has the i.mx21 type uart */ | ||
551 | _REGISTER_CLOCK("imx21-uart.0", NULL, uart1_clk) | ||
552 | _REGISTER_CLOCK("imx21-uart.1", NULL, uart2_clk) | ||
553 | _REGISTER_CLOCK("imx21-uart.2", NULL, uart3_clk) | ||
554 | _REGISTER_CLOCK("imx21-uart.3", NULL, uart4_clk) | ||
555 | _REGISTER_CLOCK("imx21-uart.4", NULL, uart5_clk) | ||
556 | _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk) | ||
557 | _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk) | ||
558 | _REGISTER_CLOCK("imx-i2c.2", NULL, i2c3_clk) | ||
559 | _REGISTER_CLOCK("mxc_w1.0", NULL, owire_clk) | ||
560 | _REGISTER_CLOCK("mxc-mmc.0", NULL, sdhc1_clk) | ||
561 | _REGISTER_CLOCK("mxc-mmc.1", NULL, sdhc2_clk) | ||
562 | _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk) | ||
563 | _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk) | ||
564 | _REGISTER_CLOCK(NULL, "firi", firi_clk) | ||
565 | _REGISTER_CLOCK("pata_imx", NULL, pata_clk) | ||
566 | _REGISTER_CLOCK(NULL, "rtic", rtic_clk) | ||
567 | _REGISTER_CLOCK(NULL, "rng", rng_clk) | ||
568 | _REGISTER_CLOCK("imx31-sdma", NULL, sdma_clk1) | ||
569 | _REGISTER_CLOCK(NULL, "sdma_ipg", sdma_clk2) | ||
570 | _REGISTER_CLOCK(NULL, "mstick", mstick1_clk) | ||
571 | _REGISTER_CLOCK(NULL, "mstick", mstick2_clk) | ||
572 | _REGISTER_CLOCK(NULL, "scc", scc_clk) | ||
573 | _REGISTER_CLOCK(NULL, "iim", iim_clk) | ||
574 | _REGISTER_CLOCK(NULL, "mpeg4", mpeg4_clk) | ||
575 | _REGISTER_CLOCK(NULL, "mbx", mbx_clk) | ||
576 | }; | ||
577 | |||
578 | int __init mx31_clocks_init(unsigned long fref) | ||
579 | { | ||
580 | u32 reg; | ||
581 | |||
582 | ckih_rate = fref; | ||
583 | |||
584 | clkdev_add_table(lookups, ARRAY_SIZE(lookups)); | ||
585 | |||
586 | /* change the csi_clk parent if necessary */ | ||
587 | reg = __raw_readl(MXC_CCM_CCMR); | ||
588 | if (!(reg & MXC_CCM_CCMR_CSCS)) | ||
589 | if (clk_set_parent(&csi_clk, &usb_pll_clk)) | ||
590 | pr_err("%s: error changing csi_clk parent\n", __func__); | ||
591 | |||
592 | |||
593 | /* Turn off all possible clocks */ | ||
594 | __raw_writel((3 << 4), MXC_CCM_CGR0); | ||
595 | __raw_writel(0, MXC_CCM_CGR1); | ||
596 | __raw_writel((3 << 8) | (3 << 14) | (3 << 16)| | ||
597 | 1 << 27 | 1 << 28, /* Bit 27 and 28 are not defined for | ||
598 | MX32, but still required to be set */ | ||
599 | MXC_CCM_CGR2); | ||
600 | |||
601 | /* | ||
602 | * Before turning off usb_pll make sure ipg_per_clk is generated | ||
603 | * by ipg_clk and not usb_pll. | ||
604 | */ | ||
605 | __raw_writel(__raw_readl(MXC_CCM_CCMR) | (1 << 24), MXC_CCM_CCMR); | ||
606 | |||
607 | usb_pll_disable(&usb_pll_clk); | ||
608 | |||
609 | pr_info("Clock input source is %ld\n", clk_get_rate(&ckih_clk)); | ||
610 | |||
611 | clk_enable(&gpt_clk); | ||
612 | clk_enable(&emi_clk); | ||
613 | clk_enable(&iim_clk); | ||
614 | mx31_revision(); | ||
615 | clk_disable(&iim_clk); | ||
616 | |||
617 | clk_enable(&serial_pll_clk); | ||
618 | |||
619 | if (mx31_revision() >= IMX_CHIP_REVISION_2_0) { | ||
620 | reg = __raw_readl(MXC_CCM_PMCR1); | ||
621 | /* No PLL restart on DVFS switch; enable auto EMI handshake */ | ||
622 | reg |= MXC_CCM_PMCR1_PLLRDIS | MXC_CCM_PMCR1_EMIRQ_EN; | ||
623 | __raw_writel(reg, MXC_CCM_PMCR1); | ||
624 | } | ||
625 | |||
626 | mxc_timer_init(&ipg_clk, MX31_IO_ADDRESS(MX31_GPT1_BASE_ADDR), | ||
627 | MX31_INT_GPT); | ||
628 | |||
629 | return 0; | ||
630 | } | ||
diff --git a/arch/arm/mach-imx/clock-imx35.c b/arch/arm/mach-imx/clock-imx35.c deleted file mode 100644 index e56c1a83eee3..000000000000 --- a/arch/arm/mach-imx/clock-imx35.c +++ /dev/null | |||
@@ -1,536 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009 by Sascha Hauer, Pengutronix | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation; either version 2 | ||
7 | * of the License, or (at your option) any later version. | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program; if not, write to the Free Software | ||
15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
16 | * MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/list.h> | ||
22 | #include <linux/clk.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <linux/clkdev.h> | ||
25 | |||
26 | #include <mach/clock.h> | ||
27 | #include <mach/hardware.h> | ||
28 | #include <mach/common.h> | ||
29 | |||
30 | #include "crmregs-imx3.h" | ||
31 | |||
32 | #ifdef HAVE_SET_RATE_SUPPORT | ||
33 | static void calc_dividers(u32 div, u32 *pre, u32 *post, u32 maxpost) | ||
34 | { | ||
35 | u32 min_pre, temp_pre, old_err, err; | ||
36 | |||
37 | min_pre = (div - 1) / maxpost + 1; | ||
38 | old_err = 8; | ||
39 | |||
40 | for (temp_pre = 8; temp_pre >= min_pre; temp_pre--) { | ||
41 | if (div > (temp_pre * maxpost)) | ||
42 | break; | ||
43 | |||
44 | if (div < (temp_pre * temp_pre)) | ||
45 | continue; | ||
46 | |||
47 | err = div % temp_pre; | ||
48 | |||
49 | if (err == 0) { | ||
50 | *pre = temp_pre; | ||
51 | break; | ||
52 | } | ||
53 | |||
54 | err = temp_pre - err; | ||
55 | |||
56 | if (err < old_err) { | ||
57 | old_err = err; | ||
58 | *pre = temp_pre; | ||
59 | } | ||
60 | } | ||
61 | |||
62 | *post = (div + *pre - 1) / *pre; | ||
63 | } | ||
64 | |||
65 | /* get the best values for a 3-bit divider combined with a 6-bit divider */ | ||
66 | static void calc_dividers_3_6(u32 div, u32 *pre, u32 *post) | ||
67 | { | ||
68 | if (div >= 512) { | ||
69 | *pre = 8; | ||
70 | *post = 64; | ||
71 | } else if (div >= 64) { | ||
72 | calc_dividers(div, pre, post, 64); | ||
73 | } else if (div <= 8) { | ||
74 | *pre = div; | ||
75 | *post = 1; | ||
76 | } else { | ||
77 | *pre = 1; | ||
78 | *post = div; | ||
79 | } | ||
80 | } | ||
81 | |||
82 | /* get the best values for two cascaded 3-bit dividers */ | ||
83 | static void calc_dividers_3_3(u32 div, u32 *pre, u32 *post) | ||
84 | { | ||
85 | if (div >= 64) { | ||
86 | *pre = *post = 8; | ||
87 | } else if (div > 8) { | ||
88 | calc_dividers(div, pre, post, 8); | ||
89 | } else { | ||
90 | *pre = 1; | ||
91 | *post = div; | ||
92 | } | ||
93 | } | ||
94 | #endif | ||
95 | |||
96 | static unsigned long get_rate_mpll(void) | ||
97 | { | ||
98 | ulong mpctl = __raw_readl(MX35_CCM_MPCTL); | ||
99 | |||
100 | return mxc_decode_pll(mpctl, 24000000); | ||
101 | } | ||
102 | |||
103 | static unsigned long get_rate_ppll(void) | ||
104 | { | ||
105 | ulong ppctl = __raw_readl(MX35_CCM_PPCTL); | ||
106 | |||
107 | return mxc_decode_pll(ppctl, 24000000); | ||
108 | } | ||
109 | |||
110 | struct arm_ahb_div { | ||
111 | unsigned char arm, ahb, sel; | ||
112 | }; | ||
113 | |||
114 | static struct arm_ahb_div clk_consumer[] = { | ||
115 | { .arm = 1, .ahb = 4, .sel = 0}, | ||
116 | { .arm = 1, .ahb = 3, .sel = 1}, | ||
117 | { .arm = 2, .ahb = 2, .sel = 0}, | ||
118 | { .arm = 0, .ahb = 0, .sel = 0}, | ||
119 | { .arm = 0, .ahb = 0, .sel = 0}, | ||
120 | { .arm = 0, .ahb = 0, .sel = 0}, | ||
121 | { .arm = 4, .ahb = 1, .sel = 0}, | ||
122 | { .arm = 1, .ahb = 5, .sel = 0}, | ||
123 | { .arm = 1, .ahb = 8, .sel = 0}, | ||
124 | { .arm = 1, .ahb = 6, .sel = 1}, | ||
125 | { .arm = 2, .ahb = 4, .sel = 0}, | ||
126 | { .arm = 0, .ahb = 0, .sel = 0}, | ||
127 | { .arm = 0, .ahb = 0, .sel = 0}, | ||
128 | { .arm = 0, .ahb = 0, .sel = 0}, | ||
129 | { .arm = 4, .ahb = 2, .sel = 0}, | ||
130 | { .arm = 0, .ahb = 0, .sel = 0}, | ||
131 | }; | ||
132 | |||
133 | static unsigned long get_rate_arm(void) | ||
134 | { | ||
135 | unsigned long pdr0 = __raw_readl(MXC_CCM_PDR0); | ||
136 | struct arm_ahb_div *aad; | ||
137 | unsigned long fref = get_rate_mpll(); | ||
138 | |||
139 | aad = &clk_consumer[(pdr0 >> 16) & 0xf]; | ||
140 | if (aad->sel) | ||
141 | fref = fref * 3 / 4; | ||
142 | |||
143 | return fref / aad->arm; | ||
144 | } | ||
145 | |||
146 | static unsigned long get_rate_ahb(struct clk *clk) | ||
147 | { | ||
148 | unsigned long pdr0 = __raw_readl(MXC_CCM_PDR0); | ||
149 | struct arm_ahb_div *aad; | ||
150 | unsigned long fref = get_rate_arm(); | ||
151 | |||
152 | aad = &clk_consumer[(pdr0 >> 16) & 0xf]; | ||
153 | |||
154 | return fref / aad->ahb; | ||
155 | } | ||
156 | |||
157 | static unsigned long get_rate_ipg(struct clk *clk) | ||
158 | { | ||
159 | return get_rate_ahb(NULL) >> 1; | ||
160 | } | ||
161 | |||
162 | static unsigned long get_rate_uart(struct clk *clk) | ||
163 | { | ||
164 | unsigned long pdr3 = __raw_readl(MX35_CCM_PDR3); | ||
165 | unsigned long pdr4 = __raw_readl(MX35_CCM_PDR4); | ||
166 | unsigned long div = ((pdr4 >> 10) & 0x3f) + 1; | ||
167 | |||
168 | if (pdr3 & (1 << 14)) | ||
169 | return get_rate_arm() / div; | ||
170 | else | ||
171 | return get_rate_ppll() / div; | ||
172 | } | ||
173 | |||
174 | static unsigned long get_rate_sdhc(struct clk *clk) | ||
175 | { | ||
176 | unsigned long pdr3 = __raw_readl(MX35_CCM_PDR3); | ||
177 | unsigned long div, rate; | ||
178 | |||
179 | if (pdr3 & (1 << 6)) | ||
180 | rate = get_rate_arm(); | ||
181 | else | ||
182 | rate = get_rate_ppll(); | ||
183 | |||
184 | switch (clk->id) { | ||
185 | default: | ||
186 | case 0: | ||
187 | div = pdr3 & 0x3f; | ||
188 | break; | ||
189 | case 1: | ||
190 | div = (pdr3 >> 8) & 0x3f; | ||
191 | break; | ||
192 | case 2: | ||
193 | div = (pdr3 >> 16) & 0x3f; | ||
194 | break; | ||
195 | } | ||
196 | |||
197 | return rate / (div + 1); | ||
198 | } | ||
199 | |||
200 | static unsigned long get_rate_mshc(struct clk *clk) | ||
201 | { | ||
202 | unsigned long pdr1 = __raw_readl(MXC_CCM_PDR1); | ||
203 | unsigned long div1, div2, rate; | ||
204 | |||
205 | if (pdr1 & (1 << 7)) | ||
206 | rate = get_rate_arm(); | ||
207 | else | ||
208 | rate = get_rate_ppll(); | ||
209 | |||
210 | div1 = (pdr1 >> 29) & 0x7; | ||
211 | div2 = (pdr1 >> 22) & 0x3f; | ||
212 | |||
213 | return rate / ((div1 + 1) * (div2 + 1)); | ||
214 | } | ||
215 | |||
216 | static unsigned long get_rate_ssi(struct clk *clk) | ||
217 | { | ||
218 | unsigned long pdr2 = __raw_readl(MX35_CCM_PDR2); | ||
219 | unsigned long div1, div2, rate; | ||
220 | |||
221 | if (pdr2 & (1 << 6)) | ||
222 | rate = get_rate_arm(); | ||
223 | else | ||
224 | rate = get_rate_ppll(); | ||
225 | |||
226 | switch (clk->id) { | ||
227 | default: | ||
228 | case 0: | ||
229 | div1 = pdr2 & 0x3f; | ||
230 | div2 = (pdr2 >> 24) & 0x7; | ||
231 | break; | ||
232 | case 1: | ||
233 | div1 = (pdr2 >> 8) & 0x3f; | ||
234 | div2 = (pdr2 >> 27) & 0x7; | ||
235 | break; | ||
236 | } | ||
237 | |||
238 | return rate / ((div1 + 1) * (div2 + 1)); | ||
239 | } | ||
240 | |||
241 | static unsigned long get_rate_csi(struct clk *clk) | ||
242 | { | ||
243 | unsigned long pdr2 = __raw_readl(MX35_CCM_PDR2); | ||
244 | unsigned long rate; | ||
245 | |||
246 | if (pdr2 & (1 << 7)) | ||
247 | rate = get_rate_arm(); | ||
248 | else | ||
249 | rate = get_rate_ppll(); | ||
250 | |||
251 | return rate / (((pdr2 >> 16) & 0x3f) + 1); | ||
252 | } | ||
253 | |||
254 | static unsigned long get_rate_otg(struct clk *clk) | ||
255 | { | ||
256 | unsigned long pdr4 = __raw_readl(MX35_CCM_PDR4); | ||
257 | unsigned long rate; | ||
258 | |||
259 | if (pdr4 & (1 << 9)) | ||
260 | rate = get_rate_arm(); | ||
261 | else | ||
262 | rate = get_rate_ppll(); | ||
263 | |||
264 | return rate / (((pdr4 >> 22) & 0x3f) + 1); | ||
265 | } | ||
266 | |||
267 | static unsigned long get_rate_ipg_per(struct clk *clk) | ||
268 | { | ||
269 | unsigned long pdr0 = __raw_readl(MXC_CCM_PDR0); | ||
270 | unsigned long pdr4 = __raw_readl(MX35_CCM_PDR4); | ||
271 | unsigned long div; | ||
272 | |||
273 | if (pdr0 & (1 << 26)) { | ||
274 | div = (pdr4 >> 16) & 0x3f; | ||
275 | return get_rate_arm() / (div + 1); | ||
276 | } else { | ||
277 | div = (pdr0 >> 12) & 0x7; | ||
278 | return get_rate_ahb(NULL) / (div + 1); | ||
279 | } | ||
280 | } | ||
281 | |||
282 | static unsigned long get_rate_hsp(struct clk *clk) | ||
283 | { | ||
284 | unsigned long hsp_podf = (__raw_readl(MXC_CCM_PDR0) >> 20) & 0x03; | ||
285 | unsigned long fref = get_rate_mpll(); | ||
286 | |||
287 | if (fref > 400 * 1000 * 1000) { | ||
288 | switch (hsp_podf) { | ||
289 | case 0: | ||
290 | return fref >> 2; | ||
291 | case 1: | ||
292 | return fref >> 3; | ||
293 | case 2: | ||
294 | return fref / 3; | ||
295 | } | ||
296 | } else { | ||
297 | switch (hsp_podf) { | ||
298 | case 0: | ||
299 | case 2: | ||
300 | return fref / 3; | ||
301 | case 1: | ||
302 | return fref / 6; | ||
303 | } | ||
304 | } | ||
305 | |||
306 | return 0; | ||
307 | } | ||
308 | |||
309 | static int clk_cgr_enable(struct clk *clk) | ||
310 | { | ||
311 | u32 reg; | ||
312 | |||
313 | reg = __raw_readl(clk->enable_reg); | ||
314 | reg |= 3 << clk->enable_shift; | ||
315 | __raw_writel(reg, clk->enable_reg); | ||
316 | |||
317 | return 0; | ||
318 | } | ||
319 | |||
320 | static void clk_cgr_disable(struct clk *clk) | ||
321 | { | ||
322 | u32 reg; | ||
323 | |||
324 | reg = __raw_readl(clk->enable_reg); | ||
325 | reg &= ~(3 << clk->enable_shift); | ||
326 | __raw_writel(reg, clk->enable_reg); | ||
327 | } | ||
328 | |||
329 | #define DEFINE_CLOCK(name, i, er, es, gr, sr) \ | ||
330 | static struct clk name = { \ | ||
331 | .id = i, \ | ||
332 | .enable_reg = er, \ | ||
333 | .enable_shift = es, \ | ||
334 | .get_rate = gr, \ | ||
335 | .set_rate = sr, \ | ||
336 | .enable = clk_cgr_enable, \ | ||
337 | .disable = clk_cgr_disable, \ | ||
338 | } | ||
339 | |||
340 | DEFINE_CLOCK(asrc_clk, 0, MX35_CCM_CGR0, 0, NULL, NULL); | ||
341 | DEFINE_CLOCK(pata_clk, 0, MX35_CCM_CGR0, 2, get_rate_ipg, NULL); | ||
342 | /* DEFINE_CLOCK(audmux_clk, 0, MX35_CCM_CGR0, 4, NULL, NULL); */ | ||
343 | DEFINE_CLOCK(can1_clk, 0, MX35_CCM_CGR0, 6, get_rate_ipg, NULL); | ||
344 | DEFINE_CLOCK(can2_clk, 1, MX35_CCM_CGR0, 8, get_rate_ipg, NULL); | ||
345 | DEFINE_CLOCK(cspi1_clk, 0, MX35_CCM_CGR0, 10, get_rate_ipg, NULL); | ||
346 | DEFINE_CLOCK(cspi2_clk, 1, MX35_CCM_CGR0, 12, get_rate_ipg, NULL); | ||
347 | DEFINE_CLOCK(ect_clk, 0, MX35_CCM_CGR0, 14, get_rate_ipg, NULL); | ||
348 | DEFINE_CLOCK(edio_clk, 0, MX35_CCM_CGR0, 16, NULL, NULL); | ||
349 | DEFINE_CLOCK(emi_clk, 0, MX35_CCM_CGR0, 18, get_rate_ipg, NULL); | ||
350 | DEFINE_CLOCK(epit1_clk, 0, MX35_CCM_CGR0, 20, get_rate_ipg, NULL); | ||
351 | DEFINE_CLOCK(epit2_clk, 1, MX35_CCM_CGR0, 22, get_rate_ipg, NULL); | ||
352 | DEFINE_CLOCK(esai_clk, 0, MX35_CCM_CGR0, 24, NULL, NULL); | ||
353 | DEFINE_CLOCK(esdhc1_clk, 0, MX35_CCM_CGR0, 26, get_rate_sdhc, NULL); | ||
354 | DEFINE_CLOCK(esdhc2_clk, 1, MX35_CCM_CGR0, 28, get_rate_sdhc, NULL); | ||
355 | DEFINE_CLOCK(esdhc3_clk, 2, MX35_CCM_CGR0, 30, get_rate_sdhc, NULL); | ||
356 | |||
357 | DEFINE_CLOCK(fec_clk, 0, MX35_CCM_CGR1, 0, get_rate_ipg, NULL); | ||
358 | DEFINE_CLOCK(gpio1_clk, 0, MX35_CCM_CGR1, 2, NULL, NULL); | ||
359 | DEFINE_CLOCK(gpio2_clk, 1, MX35_CCM_CGR1, 4, NULL, NULL); | ||
360 | DEFINE_CLOCK(gpio3_clk, 2, MX35_CCM_CGR1, 6, NULL, NULL); | ||
361 | DEFINE_CLOCK(gpt_clk, 0, MX35_CCM_CGR1, 8, get_rate_ipg, NULL); | ||
362 | DEFINE_CLOCK(i2c1_clk, 0, MX35_CCM_CGR1, 10, get_rate_ipg_per, NULL); | ||
363 | DEFINE_CLOCK(i2c2_clk, 1, MX35_CCM_CGR1, 12, get_rate_ipg_per, NULL); | ||
364 | DEFINE_CLOCK(i2c3_clk, 2, MX35_CCM_CGR1, 14, get_rate_ipg_per, NULL); | ||
365 | DEFINE_CLOCK(iomuxc_clk, 0, MX35_CCM_CGR1, 16, NULL, NULL); | ||
366 | DEFINE_CLOCK(ipu_clk, 0, MX35_CCM_CGR1, 18, get_rate_hsp, NULL); | ||
367 | DEFINE_CLOCK(kpp_clk, 0, MX35_CCM_CGR1, 20, get_rate_ipg, NULL); | ||
368 | DEFINE_CLOCK(mlb_clk, 0, MX35_CCM_CGR1, 22, get_rate_ahb, NULL); | ||
369 | DEFINE_CLOCK(mshc_clk, 0, MX35_CCM_CGR1, 24, get_rate_mshc, NULL); | ||
370 | DEFINE_CLOCK(owire_clk, 0, MX35_CCM_CGR1, 26, get_rate_ipg_per, NULL); | ||
371 | DEFINE_CLOCK(pwm_clk, 0, MX35_CCM_CGR1, 28, get_rate_ipg_per, NULL); | ||
372 | DEFINE_CLOCK(rngc_clk, 0, MX35_CCM_CGR1, 30, get_rate_ipg, NULL); | ||
373 | |||
374 | DEFINE_CLOCK(rtc_clk, 0, MX35_CCM_CGR2, 0, get_rate_ipg, NULL); | ||
375 | DEFINE_CLOCK(rtic_clk, 0, MX35_CCM_CGR2, 2, get_rate_ahb, NULL); | ||
376 | DEFINE_CLOCK(scc_clk, 0, MX35_CCM_CGR2, 4, get_rate_ipg, NULL); | ||
377 | DEFINE_CLOCK(sdma_clk, 0, MX35_CCM_CGR2, 6, NULL, NULL); | ||
378 | DEFINE_CLOCK(spba_clk, 0, MX35_CCM_CGR2, 8, get_rate_ipg, NULL); | ||
379 | DEFINE_CLOCK(spdif_clk, 0, MX35_CCM_CGR2, 10, NULL, NULL); | ||
380 | DEFINE_CLOCK(ssi1_clk, 0, MX35_CCM_CGR2, 12, get_rate_ssi, NULL); | ||
381 | DEFINE_CLOCK(ssi2_clk, 1, MX35_CCM_CGR2, 14, get_rate_ssi, NULL); | ||
382 | DEFINE_CLOCK(uart1_clk, 0, MX35_CCM_CGR2, 16, get_rate_uart, NULL); | ||
383 | DEFINE_CLOCK(uart2_clk, 1, MX35_CCM_CGR2, 18, get_rate_uart, NULL); | ||
384 | DEFINE_CLOCK(uart3_clk, 2, MX35_CCM_CGR2, 20, get_rate_uart, NULL); | ||
385 | DEFINE_CLOCK(usbotg_clk, 0, MX35_CCM_CGR2, 22, get_rate_otg, NULL); | ||
386 | DEFINE_CLOCK(wdog_clk, 0, MX35_CCM_CGR2, 24, NULL, NULL); | ||
387 | DEFINE_CLOCK(max_clk, 0, MX35_CCM_CGR2, 26, NULL, NULL); | ||
388 | DEFINE_CLOCK(audmux_clk, 0, MX35_CCM_CGR2, 30, NULL, NULL); | ||
389 | |||
390 | DEFINE_CLOCK(csi_clk, 0, MX35_CCM_CGR3, 0, get_rate_csi, NULL); | ||
391 | DEFINE_CLOCK(iim_clk, 0, MX35_CCM_CGR3, 2, NULL, NULL); | ||
392 | DEFINE_CLOCK(gpu2d_clk, 0, MX35_CCM_CGR3, 4, NULL, NULL); | ||
393 | |||
394 | DEFINE_CLOCK(usbahb_clk, 0, 0, 0, get_rate_ahb, NULL); | ||
395 | |||
396 | static int clk_dummy_enable(struct clk *clk) | ||
397 | { | ||
398 | return 0; | ||
399 | } | ||
400 | |||
401 | static void clk_dummy_disable(struct clk *clk) | ||
402 | { | ||
403 | } | ||
404 | |||
405 | static unsigned long get_rate_nfc(struct clk *clk) | ||
406 | { | ||
407 | unsigned long div1; | ||
408 | |||
409 | div1 = (__raw_readl(MX35_CCM_PDR4) >> 28) + 1; | ||
410 | |||
411 | return get_rate_ahb(NULL) / div1; | ||
412 | } | ||
413 | |||
414 | /* NAND Controller: It seems it can't be disabled */ | ||
415 | static struct clk nfc_clk = { | ||
416 | .id = 0, | ||
417 | .enable_reg = 0, | ||
418 | .enable_shift = 0, | ||
419 | .get_rate = get_rate_nfc, | ||
420 | .set_rate = NULL, /* set_rate_nfc, */ | ||
421 | .enable = clk_dummy_enable, | ||
422 | .disable = clk_dummy_disable | ||
423 | }; | ||
424 | |||
425 | #define _REGISTER_CLOCK(d, n, c) \ | ||
426 | { \ | ||
427 | .dev_id = d, \ | ||
428 | .con_id = n, \ | ||
429 | .clk = &c, \ | ||
430 | }, | ||
431 | |||
432 | static struct clk_lookup lookups[] = { | ||
433 | _REGISTER_CLOCK(NULL, "asrc", asrc_clk) | ||
434 | _REGISTER_CLOCK("pata_imx", NULL, pata_clk) | ||
435 | _REGISTER_CLOCK("flexcan.0", NULL, can1_clk) | ||
436 | _REGISTER_CLOCK("flexcan.1", NULL, can2_clk) | ||
437 | _REGISTER_CLOCK("imx35-cspi.0", NULL, cspi1_clk) | ||
438 | _REGISTER_CLOCK("imx35-cspi.1", NULL, cspi2_clk) | ||
439 | _REGISTER_CLOCK(NULL, "ect", ect_clk) | ||
440 | _REGISTER_CLOCK(NULL, "edio", edio_clk) | ||
441 | _REGISTER_CLOCK(NULL, "emi", emi_clk) | ||
442 | _REGISTER_CLOCK("imx-epit.0", NULL, epit1_clk) | ||
443 | _REGISTER_CLOCK("imx-epit.1", NULL, epit2_clk) | ||
444 | _REGISTER_CLOCK(NULL, "esai", esai_clk) | ||
445 | _REGISTER_CLOCK("sdhci-esdhc-imx35.0", NULL, esdhc1_clk) | ||
446 | _REGISTER_CLOCK("sdhci-esdhc-imx35.1", NULL, esdhc2_clk) | ||
447 | _REGISTER_CLOCK("sdhci-esdhc-imx35.2", NULL, esdhc3_clk) | ||
448 | /* i.mx35 has the i.mx27 type fec */ | ||
449 | _REGISTER_CLOCK("imx27-fec.0", NULL, fec_clk) | ||
450 | _REGISTER_CLOCK(NULL, "gpio", gpio1_clk) | ||
451 | _REGISTER_CLOCK(NULL, "gpio", gpio2_clk) | ||
452 | _REGISTER_CLOCK(NULL, "gpio", gpio3_clk) | ||
453 | _REGISTER_CLOCK("gpt.0", NULL, gpt_clk) | ||
454 | _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk) | ||
455 | _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk) | ||
456 | _REGISTER_CLOCK("imx-i2c.2", NULL, i2c3_clk) | ||
457 | _REGISTER_CLOCK(NULL, "iomuxc", iomuxc_clk) | ||
458 | _REGISTER_CLOCK("ipu-core", NULL, ipu_clk) | ||
459 | _REGISTER_CLOCK("mx3_sdc_fb", NULL, ipu_clk) | ||
460 | _REGISTER_CLOCK(NULL, "kpp", kpp_clk) | ||
461 | _REGISTER_CLOCK(NULL, "mlb", mlb_clk) | ||
462 | _REGISTER_CLOCK(NULL, "mshc", mshc_clk) | ||
463 | _REGISTER_CLOCK("mxc_w1", NULL, owire_clk) | ||
464 | _REGISTER_CLOCK(NULL, "pwm", pwm_clk) | ||
465 | _REGISTER_CLOCK(NULL, "rngc", rngc_clk) | ||
466 | _REGISTER_CLOCK(NULL, "rtc", rtc_clk) | ||
467 | _REGISTER_CLOCK(NULL, "rtic", rtic_clk) | ||
468 | _REGISTER_CLOCK(NULL, "scc", scc_clk) | ||
469 | _REGISTER_CLOCK("imx35-sdma", NULL, sdma_clk) | ||
470 | _REGISTER_CLOCK(NULL, "spba", spba_clk) | ||
471 | _REGISTER_CLOCK(NULL, "spdif", spdif_clk) | ||
472 | _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk) | ||
473 | _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk) | ||
474 | /* i.mx35 has the i.mx21 type uart */ | ||
475 | _REGISTER_CLOCK("imx21-uart.0", NULL, uart1_clk) | ||
476 | _REGISTER_CLOCK("imx21-uart.1", NULL, uart2_clk) | ||
477 | _REGISTER_CLOCK("imx21-uart.2", NULL, uart3_clk) | ||
478 | _REGISTER_CLOCK("mxc-ehci.0", "usb", usbotg_clk) | ||
479 | _REGISTER_CLOCK("mxc-ehci.1", "usb", usbotg_clk) | ||
480 | _REGISTER_CLOCK("mxc-ehci.2", "usb", usbotg_clk) | ||
481 | _REGISTER_CLOCK("fsl-usb2-udc", "usb", usbotg_clk) | ||
482 | _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", usbahb_clk) | ||
483 | _REGISTER_CLOCK("imx2-wdt.0", NULL, wdog_clk) | ||
484 | _REGISTER_CLOCK(NULL, "max", max_clk) | ||
485 | _REGISTER_CLOCK(NULL, "audmux", audmux_clk) | ||
486 | _REGISTER_CLOCK("mx3-camera.0", NULL, csi_clk) | ||
487 | _REGISTER_CLOCK(NULL, "iim", iim_clk) | ||
488 | _REGISTER_CLOCK(NULL, "gpu2d", gpu2d_clk) | ||
489 | _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk) | ||
490 | }; | ||
491 | |||
492 | int __init mx35_clocks_init() | ||
493 | { | ||
494 | unsigned int cgr2 = 3 << 26; | ||
495 | |||
496 | #if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC) | ||
497 | cgr2 |= 3 << 16; | ||
498 | #endif | ||
499 | |||
500 | clkdev_add_table(lookups, ARRAY_SIZE(lookups)); | ||
501 | |||
502 | /* Turn off all clocks except the ones we need to survive, namely: | ||
503 | * EMI, GPIO1/2/3, GPT, IOMUX, MAX and eventually uart | ||
504 | */ | ||
505 | __raw_writel((3 << 18), MX35_CCM_CGR0); | ||
506 | __raw_writel((3 << 2) | (3 << 4) | (3 << 6) | (3 << 8) | (3 << 16), | ||
507 | MX35_CCM_CGR1); | ||
508 | __raw_writel(cgr2, MX35_CCM_CGR2); | ||
509 | __raw_writel(0, MX35_CCM_CGR3); | ||
510 | |||
511 | clk_enable(&iim_clk); | ||
512 | imx_print_silicon_rev("i.MX35", mx35_revision()); | ||
513 | clk_disable(&iim_clk); | ||
514 | |||
515 | /* | ||
516 | * Check if we came up in internal boot mode. If yes, we need some | ||
517 | * extra clocks turned on, otherwise the MX35 boot ROM code will | ||
518 | * hang after a watchdog reset. | ||
519 | */ | ||
520 | if (!(__raw_readl(MX35_CCM_RCSR) & (3 << 10))) { | ||
521 | /* Additionally turn on UART1, SCC, and IIM clocks */ | ||
522 | clk_enable(&iim_clk); | ||
523 | clk_enable(&uart1_clk); | ||
524 | clk_enable(&scc_clk); | ||
525 | } | ||
526 | |||
527 | #ifdef CONFIG_MXC_USE_EPIT | ||
528 | epit_timer_init(&epit1_clk, | ||
529 | MX35_IO_ADDRESS(MX35_EPIT1_BASE_ADDR), MX35_INT_EPIT1); | ||
530 | #else | ||
531 | mxc_timer_init(&gpt_clk, | ||
532 | MX35_IO_ADDRESS(MX35_GPT1_BASE_ADDR), MX35_INT_GPT); | ||
533 | #endif | ||
534 | |||
535 | return 0; | ||
536 | } | ||
diff --git a/arch/arm/mach-imx/clock-imx6q.c b/arch/arm/mach-imx/clock-imx6q.c deleted file mode 100644 index 111c328f5420..000000000000 --- a/arch/arm/mach-imx/clock-imx6q.c +++ /dev/null | |||
@@ -1,2111 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2011 Freescale Semiconductor, Inc. | ||
3 | * Copyright 2011 Linaro Ltd. | ||
4 | * | ||
5 | * The code contained herein is licensed under the GNU General Public | ||
6 | * License. You may obtain a copy of the GNU General Public License | ||
7 | * Version 2 or later at the following locations: | ||
8 | * | ||
9 | * http://www.opensource.org/licenses/gpl-license.html | ||
10 | * http://www.gnu.org/copyleft/gpl.html | ||
11 | */ | ||
12 | |||
13 | #include <linux/init.h> | ||
14 | #include <linux/types.h> | ||
15 | #include <linux/clk.h> | ||
16 | #include <linux/clkdev.h> | ||
17 | #include <linux/io.h> | ||
18 | #include <linux/of.h> | ||
19 | #include <linux/of_address.h> | ||
20 | #include <linux/of_irq.h> | ||
21 | #include <asm/div64.h> | ||
22 | #include <asm/mach/map.h> | ||
23 | #include <mach/clock.h> | ||
24 | #include <mach/common.h> | ||
25 | #include <mach/hardware.h> | ||
26 | |||
27 | #define PLL_BASE IMX_IO_ADDRESS(MX6Q_ANATOP_BASE_ADDR) | ||
28 | #define PLL1_SYS (PLL_BASE + 0x000) | ||
29 | #define PLL2_BUS (PLL_BASE + 0x030) | ||
30 | #define PLL3_USB_OTG (PLL_BASE + 0x010) | ||
31 | #define PLL4_AUDIO (PLL_BASE + 0x070) | ||
32 | #define PLL5_VIDEO (PLL_BASE + 0x0a0) | ||
33 | #define PLL6_MLB (PLL_BASE + 0x0d0) | ||
34 | #define PLL7_USB_HOST (PLL_BASE + 0x020) | ||
35 | #define PLL8_ENET (PLL_BASE + 0x0e0) | ||
36 | #define PFD_480 (PLL_BASE + 0x0f0) | ||
37 | #define PFD_528 (PLL_BASE + 0x100) | ||
38 | #define PLL_NUM_OFFSET 0x010 | ||
39 | #define PLL_DENOM_OFFSET 0x020 | ||
40 | |||
41 | #define PFD0 7 | ||
42 | #define PFD1 15 | ||
43 | #define PFD2 23 | ||
44 | #define PFD3 31 | ||
45 | #define PFD_FRAC_MASK 0x3f | ||
46 | |||
47 | #define BM_PLL_BYPASS (0x1 << 16) | ||
48 | #define BM_PLL_ENABLE (0x1 << 13) | ||
49 | #define BM_PLL_POWER_DOWN (0x1 << 12) | ||
50 | #define BM_PLL_LOCK (0x1 << 31) | ||
51 | #define BP_PLL_SYS_DIV_SELECT 0 | ||
52 | #define BM_PLL_SYS_DIV_SELECT (0x7f << 0) | ||
53 | #define BP_PLL_BUS_DIV_SELECT 0 | ||
54 | #define BM_PLL_BUS_DIV_SELECT (0x1 << 0) | ||
55 | #define BP_PLL_USB_DIV_SELECT 0 | ||
56 | #define BM_PLL_USB_DIV_SELECT (0x3 << 0) | ||
57 | #define BP_PLL_AV_DIV_SELECT 0 | ||
58 | #define BM_PLL_AV_DIV_SELECT (0x7f << 0) | ||
59 | #define BP_PLL_ENET_DIV_SELECT 0 | ||
60 | #define BM_PLL_ENET_DIV_SELECT (0x3 << 0) | ||
61 | #define BM_PLL_ENET_EN_PCIE (0x1 << 19) | ||
62 | #define BM_PLL_ENET_EN_SATA (0x1 << 20) | ||
63 | |||
64 | #define CCM_BASE IMX_IO_ADDRESS(MX6Q_CCM_BASE_ADDR) | ||
65 | #define CCR (CCM_BASE + 0x00) | ||
66 | #define CCDR (CCM_BASE + 0x04) | ||
67 | #define CSR (CCM_BASE + 0x08) | ||
68 | #define CCSR (CCM_BASE + 0x0c) | ||
69 | #define CACRR (CCM_BASE + 0x10) | ||
70 | #define CBCDR (CCM_BASE + 0x14) | ||
71 | #define CBCMR (CCM_BASE + 0x18) | ||
72 | #define CSCMR1 (CCM_BASE + 0x1c) | ||
73 | #define CSCMR2 (CCM_BASE + 0x20) | ||
74 | #define CSCDR1 (CCM_BASE + 0x24) | ||
75 | #define CS1CDR (CCM_BASE + 0x28) | ||
76 | #define CS2CDR (CCM_BASE + 0x2c) | ||
77 | #define CDCDR (CCM_BASE + 0x30) | ||
78 | #define CHSCCDR (CCM_BASE + 0x34) | ||
79 | #define CSCDR2 (CCM_BASE + 0x38) | ||
80 | #define CSCDR3 (CCM_BASE + 0x3c) | ||
81 | #define CSCDR4 (CCM_BASE + 0x40) | ||
82 | #define CWDR (CCM_BASE + 0x44) | ||
83 | #define CDHIPR (CCM_BASE + 0x48) | ||
84 | #define CDCR (CCM_BASE + 0x4c) | ||
85 | #define CTOR (CCM_BASE + 0x50) | ||
86 | #define CLPCR (CCM_BASE + 0x54) | ||
87 | #define CISR (CCM_BASE + 0x58) | ||
88 | #define CIMR (CCM_BASE + 0x5c) | ||
89 | #define CCOSR (CCM_BASE + 0x60) | ||
90 | #define CGPR (CCM_BASE + 0x64) | ||
91 | #define CCGR0 (CCM_BASE + 0x68) | ||
92 | #define CCGR1 (CCM_BASE + 0x6c) | ||
93 | #define CCGR2 (CCM_BASE + 0x70) | ||
94 | #define CCGR3 (CCM_BASE + 0x74) | ||
95 | #define CCGR4 (CCM_BASE + 0x78) | ||
96 | #define CCGR5 (CCM_BASE + 0x7c) | ||
97 | #define CCGR6 (CCM_BASE + 0x80) | ||
98 | #define CCGR7 (CCM_BASE + 0x84) | ||
99 | #define CMEOR (CCM_BASE + 0x88) | ||
100 | |||
101 | #define CG0 0 | ||
102 | #define CG1 2 | ||
103 | #define CG2 4 | ||
104 | #define CG3 6 | ||
105 | #define CG4 8 | ||
106 | #define CG5 10 | ||
107 | #define CG6 12 | ||
108 | #define CG7 14 | ||
109 | #define CG8 16 | ||
110 | #define CG9 18 | ||
111 | #define CG10 20 | ||
112 | #define CG11 22 | ||
113 | #define CG12 24 | ||
114 | #define CG13 26 | ||
115 | #define CG14 28 | ||
116 | #define CG15 30 | ||
117 | |||
118 | #define BM_CCSR_PLL1_SW_SEL (0x1 << 2) | ||
119 | #define BM_CCSR_STEP_SEL (0x1 << 8) | ||
120 | |||
121 | #define BP_CACRR_ARM_PODF 0 | ||
122 | #define BM_CACRR_ARM_PODF (0x7 << 0) | ||
123 | |||
124 | #define BP_CBCDR_PERIPH2_CLK2_PODF 0 | ||
125 | #define BM_CBCDR_PERIPH2_CLK2_PODF (0x7 << 0) | ||
126 | #define BP_CBCDR_MMDC_CH1_AXI_PODF 3 | ||
127 | #define BM_CBCDR_MMDC_CH1_AXI_PODF (0x7 << 3) | ||
128 | #define BP_CBCDR_AXI_SEL 6 | ||
129 | #define BM_CBCDR_AXI_SEL (0x3 << 6) | ||
130 | #define BP_CBCDR_IPG_PODF 8 | ||
131 | #define BM_CBCDR_IPG_PODF (0x3 << 8) | ||
132 | #define BP_CBCDR_AHB_PODF 10 | ||
133 | #define BM_CBCDR_AHB_PODF (0x7 << 10) | ||
134 | #define BP_CBCDR_AXI_PODF 16 | ||
135 | #define BM_CBCDR_AXI_PODF (0x7 << 16) | ||
136 | #define BP_CBCDR_MMDC_CH0_AXI_PODF 19 | ||
137 | #define BM_CBCDR_MMDC_CH0_AXI_PODF (0x7 << 19) | ||
138 | #define BP_CBCDR_PERIPH_CLK_SEL 25 | ||
139 | #define BM_CBCDR_PERIPH_CLK_SEL (0x1 << 25) | ||
140 | #define BP_CBCDR_PERIPH2_CLK_SEL 26 | ||
141 | #define BM_CBCDR_PERIPH2_CLK_SEL (0x1 << 26) | ||
142 | #define BP_CBCDR_PERIPH_CLK2_PODF 27 | ||
143 | #define BM_CBCDR_PERIPH_CLK2_PODF (0x7 << 27) | ||
144 | |||
145 | #define BP_CBCMR_GPU2D_AXI_SEL 0 | ||
146 | #define BM_CBCMR_GPU2D_AXI_SEL (0x1 << 0) | ||
147 | #define BP_CBCMR_GPU3D_AXI_SEL 1 | ||
148 | #define BM_CBCMR_GPU3D_AXI_SEL (0x1 << 1) | ||
149 | #define BP_CBCMR_GPU3D_CORE_SEL 4 | ||
150 | #define BM_CBCMR_GPU3D_CORE_SEL (0x3 << 4) | ||
151 | #define BP_CBCMR_GPU3D_SHADER_SEL 8 | ||
152 | #define BM_CBCMR_GPU3D_SHADER_SEL (0x3 << 8) | ||
153 | #define BP_CBCMR_PCIE_AXI_SEL 10 | ||
154 | #define BM_CBCMR_PCIE_AXI_SEL (0x1 << 10) | ||
155 | #define BP_CBCMR_VDO_AXI_SEL 11 | ||
156 | #define BM_CBCMR_VDO_AXI_SEL (0x1 << 11) | ||
157 | #define BP_CBCMR_PERIPH_CLK2_SEL 12 | ||
158 | #define BM_CBCMR_PERIPH_CLK2_SEL (0x3 << 12) | ||
159 | #define BP_CBCMR_VPU_AXI_SEL 14 | ||
160 | #define BM_CBCMR_VPU_AXI_SEL (0x3 << 14) | ||
161 | #define BP_CBCMR_GPU2D_CORE_SEL 16 | ||
162 | #define BM_CBCMR_GPU2D_CORE_SEL (0x3 << 16) | ||
163 | #define BP_CBCMR_PRE_PERIPH_CLK_SEL 18 | ||
164 | #define BM_CBCMR_PRE_PERIPH_CLK_SEL (0x3 << 18) | ||
165 | #define BP_CBCMR_PERIPH2_CLK2_SEL 20 | ||
166 | #define BM_CBCMR_PERIPH2_CLK2_SEL (0x1 << 20) | ||
167 | #define BP_CBCMR_PRE_PERIPH2_CLK_SEL 21 | ||
168 | #define BM_CBCMR_PRE_PERIPH2_CLK_SEL (0x3 << 21) | ||
169 | #define BP_CBCMR_GPU2D_CORE_PODF 23 | ||
170 | #define BM_CBCMR_GPU2D_CORE_PODF (0x7 << 23) | ||
171 | #define BP_CBCMR_GPU3D_CORE_PODF 26 | ||
172 | #define BM_CBCMR_GPU3D_CORE_PODF (0x7 << 26) | ||
173 | #define BP_CBCMR_GPU3D_SHADER_PODF 29 | ||
174 | #define BM_CBCMR_GPU3D_SHADER_PODF (0x7 << 29) | ||
175 | |||
176 | #define BP_CSCMR1_PERCLK_PODF 0 | ||
177 | #define BM_CSCMR1_PERCLK_PODF (0x3f << 0) | ||
178 | #define BP_CSCMR1_SSI1_SEL 10 | ||
179 | #define BM_CSCMR1_SSI1_SEL (0x3 << 10) | ||
180 | #define BP_CSCMR1_SSI2_SEL 12 | ||
181 | #define BM_CSCMR1_SSI2_SEL (0x3 << 12) | ||
182 | #define BP_CSCMR1_SSI3_SEL 14 | ||
183 | #define BM_CSCMR1_SSI3_SEL (0x3 << 14) | ||
184 | #define BP_CSCMR1_USDHC1_SEL 16 | ||
185 | #define BM_CSCMR1_USDHC1_SEL (0x1 << 16) | ||
186 | #define BP_CSCMR1_USDHC2_SEL 17 | ||
187 | #define BM_CSCMR1_USDHC2_SEL (0x1 << 17) | ||
188 | #define BP_CSCMR1_USDHC3_SEL 18 | ||
189 | #define BM_CSCMR1_USDHC3_SEL (0x1 << 18) | ||
190 | #define BP_CSCMR1_USDHC4_SEL 19 | ||
191 | #define BM_CSCMR1_USDHC4_SEL (0x1 << 19) | ||
192 | #define BP_CSCMR1_EMI_PODF 20 | ||
193 | #define BM_CSCMR1_EMI_PODF (0x7 << 20) | ||
194 | #define BP_CSCMR1_EMI_SLOW_PODF 23 | ||
195 | #define BM_CSCMR1_EMI_SLOW_PODF (0x7 << 23) | ||
196 | #define BP_CSCMR1_EMI_SEL 27 | ||
197 | #define BM_CSCMR1_EMI_SEL (0x3 << 27) | ||
198 | #define BP_CSCMR1_EMI_SLOW_SEL 29 | ||
199 | #define BM_CSCMR1_EMI_SLOW_SEL (0x3 << 29) | ||
200 | |||
201 | #define BP_CSCMR2_CAN_PODF 2 | ||
202 | #define BM_CSCMR2_CAN_PODF (0x3f << 2) | ||
203 | #define BM_CSCMR2_LDB_DI0_IPU_DIV (0x1 << 10) | ||
204 | #define BM_CSCMR2_LDB_DI1_IPU_DIV (0x1 << 11) | ||
205 | #define BP_CSCMR2_ESAI_SEL 19 | ||
206 | #define BM_CSCMR2_ESAI_SEL (0x3 << 19) | ||
207 | |||
208 | #define BP_CSCDR1_UART_PODF 0 | ||
209 | #define BM_CSCDR1_UART_PODF (0x3f << 0) | ||
210 | #define BP_CSCDR1_USDHC1_PODF 11 | ||
211 | #define BM_CSCDR1_USDHC1_PODF (0x7 << 11) | ||
212 | #define BP_CSCDR1_USDHC2_PODF 16 | ||
213 | #define BM_CSCDR1_USDHC2_PODF (0x7 << 16) | ||
214 | #define BP_CSCDR1_USDHC3_PODF 19 | ||
215 | #define BM_CSCDR1_USDHC3_PODF (0x7 << 19) | ||
216 | #define BP_CSCDR1_USDHC4_PODF 22 | ||
217 | #define BM_CSCDR1_USDHC4_PODF (0x7 << 22) | ||
218 | #define BP_CSCDR1_VPU_AXI_PODF 25 | ||
219 | #define BM_CSCDR1_VPU_AXI_PODF (0x7 << 25) | ||
220 | |||
221 | #define BP_CS1CDR_SSI1_PODF 0 | ||
222 | #define BM_CS1CDR_SSI1_PODF (0x3f << 0) | ||
223 | #define BP_CS1CDR_SSI1_PRED 6 | ||
224 | #define BM_CS1CDR_SSI1_PRED (0x7 << 6) | ||
225 | #define BP_CS1CDR_ESAI_PRED 9 | ||
226 | #define BM_CS1CDR_ESAI_PRED (0x7 << 9) | ||
227 | #define BP_CS1CDR_SSI3_PODF 16 | ||
228 | #define BM_CS1CDR_SSI3_PODF (0x3f << 16) | ||
229 | #define BP_CS1CDR_SSI3_PRED 22 | ||
230 | #define BM_CS1CDR_SSI3_PRED (0x7 << 22) | ||
231 | #define BP_CS1CDR_ESAI_PODF 25 | ||
232 | #define BM_CS1CDR_ESAI_PODF (0x7 << 25) | ||
233 | |||
234 | #define BP_CS2CDR_SSI2_PODF 0 | ||
235 | #define BM_CS2CDR_SSI2_PODF (0x3f << 0) | ||
236 | #define BP_CS2CDR_SSI2_PRED 6 | ||
237 | #define BM_CS2CDR_SSI2_PRED (0x7 << 6) | ||
238 | #define BP_CS2CDR_LDB_DI0_SEL 9 | ||
239 | #define BM_CS2CDR_LDB_DI0_SEL (0x7 << 9) | ||
240 | #define BP_CS2CDR_LDB_DI1_SEL 12 | ||
241 | #define BM_CS2CDR_LDB_DI1_SEL (0x7 << 12) | ||
242 | #define BP_CS2CDR_ENFC_SEL 16 | ||
243 | #define BM_CS2CDR_ENFC_SEL (0x3 << 16) | ||
244 | #define BP_CS2CDR_ENFC_PRED 18 | ||
245 | #define BM_CS2CDR_ENFC_PRED (0x7 << 18) | ||
246 | #define BP_CS2CDR_ENFC_PODF 21 | ||
247 | #define BM_CS2CDR_ENFC_PODF (0x3f << 21) | ||
248 | |||
249 | #define BP_CDCDR_ASRC_SERIAL_SEL 7 | ||
250 | #define BM_CDCDR_ASRC_SERIAL_SEL (0x3 << 7) | ||
251 | #define BP_CDCDR_ASRC_SERIAL_PODF 9 | ||
252 | #define BM_CDCDR_ASRC_SERIAL_PODF (0x7 << 9) | ||
253 | #define BP_CDCDR_ASRC_SERIAL_PRED 12 | ||
254 | #define BM_CDCDR_ASRC_SERIAL_PRED (0x7 << 12) | ||
255 | #define BP_CDCDR_SPDIF_SEL 20 | ||
256 | #define BM_CDCDR_SPDIF_SEL (0x3 << 20) | ||
257 | #define BP_CDCDR_SPDIF_PODF 22 | ||
258 | #define BM_CDCDR_SPDIF_PODF (0x7 << 22) | ||
259 | #define BP_CDCDR_SPDIF_PRED 25 | ||
260 | #define BM_CDCDR_SPDIF_PRED (0x7 << 25) | ||
261 | #define BP_CDCDR_HSI_TX_PODF 29 | ||
262 | #define BM_CDCDR_HSI_TX_PODF (0x7 << 29) | ||
263 | #define BP_CDCDR_HSI_TX_SEL 28 | ||
264 | #define BM_CDCDR_HSI_TX_SEL (0x1 << 28) | ||
265 | |||
266 | #define BP_CHSCCDR_IPU1_DI0_SEL 0 | ||
267 | #define BM_CHSCCDR_IPU1_DI0_SEL (0x7 << 0) | ||
268 | #define BP_CHSCCDR_IPU1_DI0_PRE_PODF 3 | ||
269 | #define BM_CHSCCDR_IPU1_DI0_PRE_PODF (0x7 << 3) | ||
270 | #define BP_CHSCCDR_IPU1_DI0_PRE_SEL 6 | ||
271 | #define BM_CHSCCDR_IPU1_DI0_PRE_SEL (0x7 << 6) | ||
272 | #define BP_CHSCCDR_IPU1_DI1_SEL 9 | ||
273 | #define BM_CHSCCDR_IPU1_DI1_SEL (0x7 << 9) | ||
274 | #define BP_CHSCCDR_IPU1_DI1_PRE_PODF 12 | ||
275 | #define BM_CHSCCDR_IPU1_DI1_PRE_PODF (0x7 << 12) | ||
276 | #define BP_CHSCCDR_IPU1_DI1_PRE_SEL 15 | ||
277 | #define BM_CHSCCDR_IPU1_DI1_PRE_SEL (0x7 << 15) | ||
278 | |||
279 | #define BP_CSCDR2_IPU2_DI0_SEL 0 | ||
280 | #define BM_CSCDR2_IPU2_DI0_SEL (0x7) | ||
281 | #define BP_CSCDR2_IPU2_DI0_PRE_PODF 3 | ||
282 | #define BM_CSCDR2_IPU2_DI0_PRE_PODF (0x7 << 3) | ||
283 | #define BP_CSCDR2_IPU2_DI0_PRE_SEL 6 | ||
284 | #define BM_CSCDR2_IPU2_DI0_PRE_SEL (0x7 << 6) | ||
285 | #define BP_CSCDR2_IPU2_DI1_SEL 9 | ||
286 | #define BM_CSCDR2_IPU2_DI1_SEL (0x7 << 9) | ||
287 | #define BP_CSCDR2_IPU2_DI1_PRE_PODF 12 | ||
288 | #define BM_CSCDR2_IPU2_DI1_PRE_PODF (0x7 << 12) | ||
289 | #define BP_CSCDR2_IPU2_DI1_PRE_SEL 15 | ||
290 | #define BM_CSCDR2_IPU2_DI1_PRE_SEL (0x7 << 15) | ||
291 | #define BP_CSCDR2_ECSPI_CLK_PODF 19 | ||
292 | #define BM_CSCDR2_ECSPI_CLK_PODF (0x3f << 19) | ||
293 | |||
294 | #define BP_CSCDR3_IPU1_HSP_SEL 9 | ||
295 | #define BM_CSCDR3_IPU1_HSP_SEL (0x3 << 9) | ||
296 | #define BP_CSCDR3_IPU1_HSP_PODF 11 | ||
297 | #define BM_CSCDR3_IPU1_HSP_PODF (0x7 << 11) | ||
298 | #define BP_CSCDR3_IPU2_HSP_SEL 14 | ||
299 | #define BM_CSCDR3_IPU2_HSP_SEL (0x3 << 14) | ||
300 | #define BP_CSCDR3_IPU2_HSP_PODF 16 | ||
301 | #define BM_CSCDR3_IPU2_HSP_PODF (0x7 << 16) | ||
302 | |||
303 | #define BM_CDHIPR_AXI_PODF_BUSY (0x1 << 0) | ||
304 | #define BM_CDHIPR_AHB_PODF_BUSY (0x1 << 1) | ||
305 | #define BM_CDHIPR_MMDC_CH1_PODF_BUSY (0x1 << 2) | ||
306 | #define BM_CDHIPR_PERIPH2_SEL_BUSY (0x1 << 3) | ||
307 | #define BM_CDHIPR_MMDC_CH0_PODF_BUSY (0x1 << 4) | ||
308 | #define BM_CDHIPR_PERIPH_SEL_BUSY (0x1 << 5) | ||
309 | #define BM_CDHIPR_ARM_PODF_BUSY (0x1 << 16) | ||
310 | |||
311 | #define BP_CLPCR_LPM 0 | ||
312 | #define BM_CLPCR_LPM (0x3 << 0) | ||
313 | #define BM_CLPCR_BYPASS_PMIC_READY (0x1 << 2) | ||
314 | #define BM_CLPCR_ARM_CLK_DIS_ON_LPM (0x1 << 5) | ||
315 | #define BM_CLPCR_SBYOS (0x1 << 6) | ||
316 | #define BM_CLPCR_DIS_REF_OSC (0x1 << 7) | ||
317 | #define BM_CLPCR_VSTBY (0x1 << 8) | ||
318 | #define BP_CLPCR_STBY_COUNT 9 | ||
319 | #define BM_CLPCR_STBY_COUNT (0x3 << 9) | ||
320 | #define BM_CLPCR_COSC_PWRDOWN (0x1 << 11) | ||
321 | #define BM_CLPCR_WB_PER_AT_LPM (0x1 << 16) | ||
322 | #define BM_CLPCR_WB_CORE_AT_LPM (0x1 << 17) | ||
323 | #define BM_CLPCR_BYP_MMDC_CH0_LPM_HS (0x1 << 19) | ||
324 | #define BM_CLPCR_BYP_MMDC_CH1_LPM_HS (0x1 << 21) | ||
325 | #define BM_CLPCR_MASK_CORE0_WFI (0x1 << 22) | ||
326 | #define BM_CLPCR_MASK_CORE1_WFI (0x1 << 23) | ||
327 | #define BM_CLPCR_MASK_CORE2_WFI (0x1 << 24) | ||
328 | #define BM_CLPCR_MASK_CORE3_WFI (0x1 << 25) | ||
329 | #define BM_CLPCR_MASK_SCU_IDLE (0x1 << 26) | ||
330 | #define BM_CLPCR_MASK_L2CC_IDLE (0x1 << 27) | ||
331 | |||
332 | #define BP_CCOSR_CKO1_EN 7 | ||
333 | #define BP_CCOSR_CKO1_PODF 4 | ||
334 | #define BM_CCOSR_CKO1_PODF (0x7 << 4) | ||
335 | #define BP_CCOSR_CKO1_SEL 0 | ||
336 | #define BM_CCOSR_CKO1_SEL (0xf << 0) | ||
337 | |||
338 | #define FREQ_480M 480000000 | ||
339 | #define FREQ_528M 528000000 | ||
340 | #define FREQ_594M 594000000 | ||
341 | #define FREQ_650M 650000000 | ||
342 | #define FREQ_1300M 1300000000 | ||
343 | |||
344 | static struct clk pll1_sys; | ||
345 | static struct clk pll2_bus; | ||
346 | static struct clk pll3_usb_otg; | ||
347 | static struct clk pll4_audio; | ||
348 | static struct clk pll5_video; | ||
349 | static struct clk pll6_mlb; | ||
350 | static struct clk pll7_usb_host; | ||
351 | static struct clk pll8_enet; | ||
352 | static struct clk apbh_dma_clk; | ||
353 | static struct clk arm_clk; | ||
354 | static struct clk ipg_clk; | ||
355 | static struct clk ahb_clk; | ||
356 | static struct clk axi_clk; | ||
357 | static struct clk mmdc_ch0_axi_clk; | ||
358 | static struct clk mmdc_ch1_axi_clk; | ||
359 | static struct clk periph_clk; | ||
360 | static struct clk periph_pre_clk; | ||
361 | static struct clk periph_clk2_clk; | ||
362 | static struct clk periph2_clk; | ||
363 | static struct clk periph2_pre_clk; | ||
364 | static struct clk periph2_clk2_clk; | ||
365 | static struct clk gpu2d_core_clk; | ||
366 | static struct clk gpu3d_core_clk; | ||
367 | static struct clk gpu3d_shader_clk; | ||
368 | static struct clk ipg_perclk; | ||
369 | static struct clk emi_clk; | ||
370 | static struct clk emi_slow_clk; | ||
371 | static struct clk can1_clk; | ||
372 | static struct clk uart_clk; | ||
373 | static struct clk usdhc1_clk; | ||
374 | static struct clk usdhc2_clk; | ||
375 | static struct clk usdhc3_clk; | ||
376 | static struct clk usdhc4_clk; | ||
377 | static struct clk vpu_clk; | ||
378 | static struct clk hsi_tx_clk; | ||
379 | static struct clk ipu1_di0_pre_clk; | ||
380 | static struct clk ipu1_di1_pre_clk; | ||
381 | static struct clk ipu2_di0_pre_clk; | ||
382 | static struct clk ipu2_di1_pre_clk; | ||
383 | static struct clk ipu1_clk; | ||
384 | static struct clk ipu2_clk; | ||
385 | static struct clk ssi1_clk; | ||
386 | static struct clk ssi3_clk; | ||
387 | static struct clk esai_clk; | ||
388 | static struct clk ssi2_clk; | ||
389 | static struct clk spdif_clk; | ||
390 | static struct clk asrc_serial_clk; | ||
391 | static struct clk gpu2d_axi_clk; | ||
392 | static struct clk gpu3d_axi_clk; | ||
393 | static struct clk pcie_clk; | ||
394 | static struct clk vdo_axi_clk; | ||
395 | static struct clk ldb_di0_clk; | ||
396 | static struct clk ldb_di1_clk; | ||
397 | static struct clk ipu1_di0_clk; | ||
398 | static struct clk ipu1_di1_clk; | ||
399 | static struct clk ipu2_di0_clk; | ||
400 | static struct clk ipu2_di1_clk; | ||
401 | static struct clk enfc_clk; | ||
402 | static struct clk cko1_clk; | ||
403 | static struct clk dummy_clk = {}; | ||
404 | |||
405 | static unsigned long external_high_reference; | ||
406 | static unsigned long external_low_reference; | ||
407 | static unsigned long oscillator_reference; | ||
408 | |||
409 | static unsigned long get_oscillator_reference_clock_rate(struct clk *clk) | ||
410 | { | ||
411 | return oscillator_reference; | ||
412 | } | ||
413 | |||
414 | static unsigned long get_high_reference_clock_rate(struct clk *clk) | ||
415 | { | ||
416 | return external_high_reference; | ||
417 | } | ||
418 | |||
419 | static unsigned long get_low_reference_clock_rate(struct clk *clk) | ||
420 | { | ||
421 | return external_low_reference; | ||
422 | } | ||
423 | |||
424 | static struct clk ckil_clk = { | ||
425 | .get_rate = get_low_reference_clock_rate, | ||
426 | }; | ||
427 | |||
428 | static struct clk ckih_clk = { | ||
429 | .get_rate = get_high_reference_clock_rate, | ||
430 | }; | ||
431 | |||
432 | static struct clk osc_clk = { | ||
433 | .get_rate = get_oscillator_reference_clock_rate, | ||
434 | }; | ||
435 | |||
436 | static inline void __iomem *pll_get_reg_addr(struct clk *pll) | ||
437 | { | ||
438 | if (pll == &pll1_sys) | ||
439 | return PLL1_SYS; | ||
440 | else if (pll == &pll2_bus) | ||
441 | return PLL2_BUS; | ||
442 | else if (pll == &pll3_usb_otg) | ||
443 | return PLL3_USB_OTG; | ||
444 | else if (pll == &pll4_audio) | ||
445 | return PLL4_AUDIO; | ||
446 | else if (pll == &pll5_video) | ||
447 | return PLL5_VIDEO; | ||
448 | else if (pll == &pll6_mlb) | ||
449 | return PLL6_MLB; | ||
450 | else if (pll == &pll7_usb_host) | ||
451 | return PLL7_USB_HOST; | ||
452 | else if (pll == &pll8_enet) | ||
453 | return PLL8_ENET; | ||
454 | else | ||
455 | BUG(); | ||
456 | |||
457 | return NULL; | ||
458 | } | ||
459 | |||
460 | static int pll_enable(struct clk *clk) | ||
461 | { | ||
462 | int timeout = 0x100000; | ||
463 | void __iomem *reg; | ||
464 | u32 val; | ||
465 | |||
466 | reg = pll_get_reg_addr(clk); | ||
467 | val = readl_relaxed(reg); | ||
468 | val &= ~BM_PLL_BYPASS; | ||
469 | val &= ~BM_PLL_POWER_DOWN; | ||
470 | /* 480MHz PLLs have the opposite definition for power bit */ | ||
471 | if (clk == &pll3_usb_otg || clk == &pll7_usb_host) | ||
472 | val |= BM_PLL_POWER_DOWN; | ||
473 | writel_relaxed(val, reg); | ||
474 | |||
475 | /* Wait for PLL to lock */ | ||
476 | while (!(readl_relaxed(reg) & BM_PLL_LOCK) && --timeout) | ||
477 | cpu_relax(); | ||
478 | |||
479 | if (unlikely(!timeout)) | ||
480 | return -EBUSY; | ||
481 | |||
482 | /* Enable the PLL output now */ | ||
483 | val = readl_relaxed(reg); | ||
484 | val |= BM_PLL_ENABLE; | ||
485 | writel_relaxed(val, reg); | ||
486 | |||
487 | return 0; | ||
488 | } | ||
489 | |||
490 | static void pll_disable(struct clk *clk) | ||
491 | { | ||
492 | void __iomem *reg; | ||
493 | u32 val; | ||
494 | |||
495 | reg = pll_get_reg_addr(clk); | ||
496 | val = readl_relaxed(reg); | ||
497 | val &= ~BM_PLL_ENABLE; | ||
498 | val |= BM_PLL_BYPASS; | ||
499 | val |= BM_PLL_POWER_DOWN; | ||
500 | if (clk == &pll3_usb_otg || clk == &pll7_usb_host) | ||
501 | val &= ~BM_PLL_POWER_DOWN; | ||
502 | writel_relaxed(val, reg); | ||
503 | } | ||
504 | |||
505 | static unsigned long pll1_sys_get_rate(struct clk *clk) | ||
506 | { | ||
507 | u32 div = (readl_relaxed(PLL1_SYS) & BM_PLL_SYS_DIV_SELECT) >> | ||
508 | BP_PLL_SYS_DIV_SELECT; | ||
509 | |||
510 | return clk_get_rate(clk->parent) * div / 2; | ||
511 | } | ||
512 | |||
513 | static int pll1_sys_set_rate(struct clk *clk, unsigned long rate) | ||
514 | { | ||
515 | u32 val, div; | ||
516 | |||
517 | if (rate < FREQ_650M || rate > FREQ_1300M) | ||
518 | return -EINVAL; | ||
519 | |||
520 | div = rate * 2 / clk_get_rate(clk->parent); | ||
521 | val = readl_relaxed(PLL1_SYS); | ||
522 | val &= ~BM_PLL_SYS_DIV_SELECT; | ||
523 | val |= div << BP_PLL_SYS_DIV_SELECT; | ||
524 | writel_relaxed(val, PLL1_SYS); | ||
525 | |||
526 | return 0; | ||
527 | } | ||
528 | |||
529 | static unsigned long pll8_enet_get_rate(struct clk *clk) | ||
530 | { | ||
531 | u32 div = (readl_relaxed(PLL8_ENET) & BM_PLL_ENET_DIV_SELECT) >> | ||
532 | BP_PLL_ENET_DIV_SELECT; | ||
533 | |||
534 | switch (div) { | ||
535 | case 0: | ||
536 | return 25000000; | ||
537 | case 1: | ||
538 | return 50000000; | ||
539 | case 2: | ||
540 | return 100000000; | ||
541 | case 3: | ||
542 | return 125000000; | ||
543 | } | ||
544 | |||
545 | return 0; | ||
546 | } | ||
547 | |||
548 | static int pll8_enet_set_rate(struct clk *clk, unsigned long rate) | ||
549 | { | ||
550 | u32 val, div; | ||
551 | |||
552 | switch (rate) { | ||
553 | case 25000000: | ||
554 | div = 0; | ||
555 | break; | ||
556 | case 50000000: | ||
557 | div = 1; | ||
558 | break; | ||
559 | case 100000000: | ||
560 | div = 2; | ||
561 | break; | ||
562 | case 125000000: | ||
563 | div = 3; | ||
564 | break; | ||
565 | default: | ||
566 | return -EINVAL; | ||
567 | } | ||
568 | |||
569 | val = readl_relaxed(PLL8_ENET); | ||
570 | val &= ~BM_PLL_ENET_DIV_SELECT; | ||
571 | val |= div << BP_PLL_ENET_DIV_SELECT; | ||
572 | writel_relaxed(val, PLL8_ENET); | ||
573 | |||
574 | return 0; | ||
575 | } | ||
576 | |||
577 | static unsigned long pll_av_get_rate(struct clk *clk) | ||
578 | { | ||
579 | void __iomem *reg = (clk == &pll4_audio) ? PLL4_AUDIO : PLL5_VIDEO; | ||
580 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
581 | u32 mfn = readl_relaxed(reg + PLL_NUM_OFFSET); | ||
582 | u32 mfd = readl_relaxed(reg + PLL_DENOM_OFFSET); | ||
583 | u32 div = (readl_relaxed(reg) & BM_PLL_AV_DIV_SELECT) >> | ||
584 | BP_PLL_AV_DIV_SELECT; | ||
585 | |||
586 | return (parent_rate * div) + ((parent_rate / mfd) * mfn); | ||
587 | } | ||
588 | |||
589 | static int pll_av_set_rate(struct clk *clk, unsigned long rate) | ||
590 | { | ||
591 | void __iomem *reg = (clk == &pll4_audio) ? PLL4_AUDIO : PLL5_VIDEO; | ||
592 | unsigned int parent_rate = clk_get_rate(clk->parent); | ||
593 | u32 val, div; | ||
594 | u32 mfn, mfd = 1000000; | ||
595 | s64 temp64; | ||
596 | |||
597 | if (rate < FREQ_650M || rate > FREQ_1300M) | ||
598 | return -EINVAL; | ||
599 | |||
600 | div = rate / parent_rate; | ||
601 | temp64 = (u64) (rate - div * parent_rate); | ||
602 | temp64 *= mfd; | ||
603 | do_div(temp64, parent_rate); | ||
604 | mfn = temp64; | ||
605 | |||
606 | val = readl_relaxed(reg); | ||
607 | val &= ~BM_PLL_AV_DIV_SELECT; | ||
608 | val |= div << BP_PLL_AV_DIV_SELECT; | ||
609 | writel_relaxed(val, reg); | ||
610 | writel_relaxed(mfn, reg + PLL_NUM_OFFSET); | ||
611 | writel_relaxed(mfd, reg + PLL_DENOM_OFFSET); | ||
612 | |||
613 | return 0; | ||
614 | } | ||
615 | |||
616 | static void __iomem *pll_get_div_reg_bit(struct clk *clk, u32 *bp, u32 *bm) | ||
617 | { | ||
618 | void __iomem *reg; | ||
619 | |||
620 | if (clk == &pll2_bus) { | ||
621 | reg = PLL2_BUS; | ||
622 | *bp = BP_PLL_BUS_DIV_SELECT; | ||
623 | *bm = BM_PLL_BUS_DIV_SELECT; | ||
624 | } else if (clk == &pll3_usb_otg) { | ||
625 | reg = PLL3_USB_OTG; | ||
626 | *bp = BP_PLL_USB_DIV_SELECT; | ||
627 | *bm = BM_PLL_USB_DIV_SELECT; | ||
628 | } else if (clk == &pll7_usb_host) { | ||
629 | reg = PLL7_USB_HOST; | ||
630 | *bp = BP_PLL_USB_DIV_SELECT; | ||
631 | *bm = BM_PLL_USB_DIV_SELECT; | ||
632 | } else { | ||
633 | BUG(); | ||
634 | } | ||
635 | |||
636 | return reg; | ||
637 | } | ||
638 | |||
639 | static unsigned long pll_get_rate(struct clk *clk) | ||
640 | { | ||
641 | void __iomem *reg; | ||
642 | u32 div, bp, bm; | ||
643 | |||
644 | reg = pll_get_div_reg_bit(clk, &bp, &bm); | ||
645 | div = (readl_relaxed(reg) & bm) >> bp; | ||
646 | |||
647 | return (div == 1) ? clk_get_rate(clk->parent) * 22 : | ||
648 | clk_get_rate(clk->parent) * 20; | ||
649 | } | ||
650 | |||
651 | static int pll_set_rate(struct clk *clk, unsigned long rate) | ||
652 | { | ||
653 | void __iomem *reg; | ||
654 | u32 val, div, bp, bm; | ||
655 | |||
656 | if (rate == FREQ_528M) | ||
657 | div = 1; | ||
658 | else if (rate == FREQ_480M) | ||
659 | div = 0; | ||
660 | else | ||
661 | return -EINVAL; | ||
662 | |||
663 | reg = pll_get_div_reg_bit(clk, &bp, &bm); | ||
664 | val = readl_relaxed(reg); | ||
665 | val &= ~bm; | ||
666 | val |= div << bp; | ||
667 | writel_relaxed(val, reg); | ||
668 | |||
669 | return 0; | ||
670 | } | ||
671 | |||
672 | #define pll2_bus_get_rate pll_get_rate | ||
673 | #define pll2_bus_set_rate pll_set_rate | ||
674 | #define pll3_usb_otg_get_rate pll_get_rate | ||
675 | #define pll3_usb_otg_set_rate pll_set_rate | ||
676 | #define pll7_usb_host_get_rate pll_get_rate | ||
677 | #define pll7_usb_host_set_rate pll_set_rate | ||
678 | #define pll4_audio_get_rate pll_av_get_rate | ||
679 | #define pll4_audio_set_rate pll_av_set_rate | ||
680 | #define pll5_video_get_rate pll_av_get_rate | ||
681 | #define pll5_video_set_rate pll_av_set_rate | ||
682 | #define pll6_mlb_get_rate NULL | ||
683 | #define pll6_mlb_set_rate NULL | ||
684 | |||
685 | #define DEF_PLL(name) \ | ||
686 | static struct clk name = { \ | ||
687 | .enable = pll_enable, \ | ||
688 | .disable = pll_disable, \ | ||
689 | .get_rate = name##_get_rate, \ | ||
690 | .set_rate = name##_set_rate, \ | ||
691 | .parent = &osc_clk, \ | ||
692 | } | ||
693 | |||
694 | DEF_PLL(pll1_sys); | ||
695 | DEF_PLL(pll2_bus); | ||
696 | DEF_PLL(pll3_usb_otg); | ||
697 | DEF_PLL(pll4_audio); | ||
698 | DEF_PLL(pll5_video); | ||
699 | DEF_PLL(pll6_mlb); | ||
700 | DEF_PLL(pll7_usb_host); | ||
701 | DEF_PLL(pll8_enet); | ||
702 | |||
703 | static unsigned long pfd_get_rate(struct clk *clk) | ||
704 | { | ||
705 | u64 tmp = (u64) clk_get_rate(clk->parent) * 18; | ||
706 | u32 frac, bp_frac; | ||
707 | |||
708 | if (apbh_dma_clk.usecount == 0) | ||
709 | apbh_dma_clk.enable(&apbh_dma_clk); | ||
710 | |||
711 | bp_frac = clk->enable_shift - 7; | ||
712 | frac = readl_relaxed(clk->enable_reg) >> bp_frac & PFD_FRAC_MASK; | ||
713 | do_div(tmp, frac); | ||
714 | |||
715 | return tmp; | ||
716 | } | ||
717 | |||
718 | static int pfd_set_rate(struct clk *clk, unsigned long rate) | ||
719 | { | ||
720 | u32 val, frac, bp_frac; | ||
721 | u64 tmp = (u64) clk_get_rate(clk->parent) * 18; | ||
722 | |||
723 | if (apbh_dma_clk.usecount == 0) | ||
724 | apbh_dma_clk.enable(&apbh_dma_clk); | ||
725 | |||
726 | /* | ||
727 | * Round up the divider so that we don't set a rate | ||
728 | * higher than what is requested | ||
729 | */ | ||
730 | tmp += rate / 2; | ||
731 | do_div(tmp, rate); | ||
732 | frac = tmp; | ||
733 | frac = (frac < 12) ? 12 : frac; | ||
734 | frac = (frac > 35) ? 35 : frac; | ||
735 | |||
736 | /* | ||
737 | * The frac field always starts from 7 bits lower | ||
738 | * position of enable bit | ||
739 | */ | ||
740 | bp_frac = clk->enable_shift - 7; | ||
741 | val = readl_relaxed(clk->enable_reg); | ||
742 | val &= ~(PFD_FRAC_MASK << bp_frac); | ||
743 | val |= frac << bp_frac; | ||
744 | writel_relaxed(val, clk->enable_reg); | ||
745 | |||
746 | tmp = (u64) clk_get_rate(clk->parent) * 18; | ||
747 | do_div(tmp, frac); | ||
748 | |||
749 | if (apbh_dma_clk.usecount == 0) | ||
750 | apbh_dma_clk.disable(&apbh_dma_clk); | ||
751 | |||
752 | return 0; | ||
753 | } | ||
754 | |||
755 | static unsigned long pfd_round_rate(struct clk *clk, unsigned long rate) | ||
756 | { | ||
757 | u32 frac; | ||
758 | u64 tmp; | ||
759 | |||
760 | tmp = (u64) clk_get_rate(clk->parent) * 18; | ||
761 | tmp += rate / 2; | ||
762 | do_div(tmp, rate); | ||
763 | frac = tmp; | ||
764 | frac = (frac < 12) ? 12 : frac; | ||
765 | frac = (frac > 35) ? 35 : frac; | ||
766 | tmp = (u64) clk_get_rate(clk->parent) * 18; | ||
767 | do_div(tmp, frac); | ||
768 | |||
769 | return tmp; | ||
770 | } | ||
771 | |||
772 | static int pfd_enable(struct clk *clk) | ||
773 | { | ||
774 | u32 val; | ||
775 | |||
776 | if (apbh_dma_clk.usecount == 0) | ||
777 | apbh_dma_clk.enable(&apbh_dma_clk); | ||
778 | |||
779 | val = readl_relaxed(clk->enable_reg); | ||
780 | val &= ~(1 << clk->enable_shift); | ||
781 | writel_relaxed(val, clk->enable_reg); | ||
782 | |||
783 | if (apbh_dma_clk.usecount == 0) | ||
784 | apbh_dma_clk.disable(&apbh_dma_clk); | ||
785 | |||
786 | return 0; | ||
787 | } | ||
788 | |||
789 | static void pfd_disable(struct clk *clk) | ||
790 | { | ||
791 | u32 val; | ||
792 | |||
793 | if (apbh_dma_clk.usecount == 0) | ||
794 | apbh_dma_clk.enable(&apbh_dma_clk); | ||
795 | |||
796 | val = readl_relaxed(clk->enable_reg); | ||
797 | val |= 1 << clk->enable_shift; | ||
798 | writel_relaxed(val, clk->enable_reg); | ||
799 | |||
800 | if (apbh_dma_clk.usecount == 0) | ||
801 | apbh_dma_clk.disable(&apbh_dma_clk); | ||
802 | } | ||
803 | |||
804 | #define DEF_PFD(name, er, es, p) \ | ||
805 | static struct clk name = { \ | ||
806 | .enable_reg = er, \ | ||
807 | .enable_shift = es, \ | ||
808 | .enable = pfd_enable, \ | ||
809 | .disable = pfd_disable, \ | ||
810 | .get_rate = pfd_get_rate, \ | ||
811 | .set_rate = pfd_set_rate, \ | ||
812 | .round_rate = pfd_round_rate, \ | ||
813 | .parent = p, \ | ||
814 | } | ||
815 | |||
816 | DEF_PFD(pll2_pfd_352m, PFD_528, PFD0, &pll2_bus); | ||
817 | DEF_PFD(pll2_pfd_594m, PFD_528, PFD1, &pll2_bus); | ||
818 | DEF_PFD(pll2_pfd_400m, PFD_528, PFD2, &pll2_bus); | ||
819 | DEF_PFD(pll3_pfd_720m, PFD_480, PFD0, &pll3_usb_otg); | ||
820 | DEF_PFD(pll3_pfd_540m, PFD_480, PFD1, &pll3_usb_otg); | ||
821 | DEF_PFD(pll3_pfd_508m, PFD_480, PFD2, &pll3_usb_otg); | ||
822 | DEF_PFD(pll3_pfd_454m, PFD_480, PFD3, &pll3_usb_otg); | ||
823 | |||
824 | static unsigned long twd_clk_get_rate(struct clk *clk) | ||
825 | { | ||
826 | return clk_get_rate(clk->parent) / 2; | ||
827 | } | ||
828 | |||
829 | static struct clk twd_clk = { | ||
830 | .parent = &arm_clk, | ||
831 | .get_rate = twd_clk_get_rate, | ||
832 | }; | ||
833 | |||
834 | static unsigned long pll2_200m_get_rate(struct clk *clk) | ||
835 | { | ||
836 | return clk_get_rate(clk->parent) / 2; | ||
837 | } | ||
838 | |||
839 | static struct clk pll2_200m = { | ||
840 | .parent = &pll2_pfd_400m, | ||
841 | .get_rate = pll2_200m_get_rate, | ||
842 | }; | ||
843 | |||
844 | static unsigned long pll3_120m_get_rate(struct clk *clk) | ||
845 | { | ||
846 | return clk_get_rate(clk->parent) / 4; | ||
847 | } | ||
848 | |||
849 | static struct clk pll3_120m = { | ||
850 | .parent = &pll3_usb_otg, | ||
851 | .get_rate = pll3_120m_get_rate, | ||
852 | }; | ||
853 | |||
854 | static unsigned long pll3_80m_get_rate(struct clk *clk) | ||
855 | { | ||
856 | return clk_get_rate(clk->parent) / 6; | ||
857 | } | ||
858 | |||
859 | static struct clk pll3_80m = { | ||
860 | .parent = &pll3_usb_otg, | ||
861 | .get_rate = pll3_80m_get_rate, | ||
862 | }; | ||
863 | |||
864 | static unsigned long pll3_60m_get_rate(struct clk *clk) | ||
865 | { | ||
866 | return clk_get_rate(clk->parent) / 8; | ||
867 | } | ||
868 | |||
869 | static struct clk pll3_60m = { | ||
870 | .parent = &pll3_usb_otg, | ||
871 | .get_rate = pll3_60m_get_rate, | ||
872 | }; | ||
873 | |||
874 | static int pll1_sw_clk_set_parent(struct clk *clk, struct clk *parent) | ||
875 | { | ||
876 | u32 val = readl_relaxed(CCSR); | ||
877 | |||
878 | if (parent == &pll1_sys) { | ||
879 | val &= ~BM_CCSR_PLL1_SW_SEL; | ||
880 | val &= ~BM_CCSR_STEP_SEL; | ||
881 | } else if (parent == &osc_clk) { | ||
882 | val |= BM_CCSR_PLL1_SW_SEL; | ||
883 | val &= ~BM_CCSR_STEP_SEL; | ||
884 | } else if (parent == &pll2_pfd_400m) { | ||
885 | val |= BM_CCSR_PLL1_SW_SEL; | ||
886 | val |= BM_CCSR_STEP_SEL; | ||
887 | } else { | ||
888 | return -EINVAL; | ||
889 | } | ||
890 | |||
891 | writel_relaxed(val, CCSR); | ||
892 | |||
893 | return 0; | ||
894 | } | ||
895 | |||
896 | static struct clk pll1_sw_clk = { | ||
897 | .parent = &pll1_sys, | ||
898 | .set_parent = pll1_sw_clk_set_parent, | ||
899 | }; | ||
900 | |||
901 | static void calc_pred_podf_dividers(u32 div, u32 *pred, u32 *podf) | ||
902 | { | ||
903 | u32 min_pred, temp_pred, old_err, err; | ||
904 | |||
905 | if (div >= 512) { | ||
906 | *pred = 8; | ||
907 | *podf = 64; | ||
908 | } else if (div >= 8) { | ||
909 | min_pred = (div - 1) / 64 + 1; | ||
910 | old_err = 8; | ||
911 | for (temp_pred = 8; temp_pred >= min_pred; temp_pred--) { | ||
912 | err = div % temp_pred; | ||
913 | if (err == 0) { | ||
914 | *pred = temp_pred; | ||
915 | break; | ||
916 | } | ||
917 | err = temp_pred - err; | ||
918 | if (err < old_err) { | ||
919 | old_err = err; | ||
920 | *pred = temp_pred; | ||
921 | } | ||
922 | } | ||
923 | *podf = (div + *pred - 1) / *pred; | ||
924 | } else if (div < 8) { | ||
925 | *pred = div; | ||
926 | *podf = 1; | ||
927 | } | ||
928 | } | ||
929 | |||
930 | static int _clk_enable(struct clk *clk) | ||
931 | { | ||
932 | u32 reg; | ||
933 | reg = readl_relaxed(clk->enable_reg); | ||
934 | reg |= 0x3 << clk->enable_shift; | ||
935 | writel_relaxed(reg, clk->enable_reg); | ||
936 | |||
937 | return 0; | ||
938 | } | ||
939 | |||
940 | static void _clk_disable(struct clk *clk) | ||
941 | { | ||
942 | u32 reg; | ||
943 | reg = readl_relaxed(clk->enable_reg); | ||
944 | reg &= ~(0x3 << clk->enable_shift); | ||
945 | writel_relaxed(reg, clk->enable_reg); | ||
946 | } | ||
947 | |||
948 | static int _clk_enable_1b(struct clk *clk) | ||
949 | { | ||
950 | u32 reg; | ||
951 | reg = readl_relaxed(clk->enable_reg); | ||
952 | reg |= 0x1 << clk->enable_shift; | ||
953 | writel_relaxed(reg, clk->enable_reg); | ||
954 | |||
955 | return 0; | ||
956 | } | ||
957 | |||
958 | static void _clk_disable_1b(struct clk *clk) | ||
959 | { | ||
960 | u32 reg; | ||
961 | reg = readl_relaxed(clk->enable_reg); | ||
962 | reg &= ~(0x1 << clk->enable_shift); | ||
963 | writel_relaxed(reg, clk->enable_reg); | ||
964 | } | ||
965 | |||
966 | struct divider { | ||
967 | struct clk *clk; | ||
968 | void __iomem *reg; | ||
969 | u32 bp_pred; | ||
970 | u32 bm_pred; | ||
971 | u32 bp_podf; | ||
972 | u32 bm_podf; | ||
973 | }; | ||
974 | |||
975 | #define DEF_CLK_DIV1(d, c, r, b) \ | ||
976 | static struct divider d = { \ | ||
977 | .clk = c, \ | ||
978 | .reg = r, \ | ||
979 | .bp_podf = BP_##r##_##b##_PODF, \ | ||
980 | .bm_podf = BM_##r##_##b##_PODF, \ | ||
981 | } | ||
982 | |||
983 | DEF_CLK_DIV1(arm_div, &arm_clk, CACRR, ARM); | ||
984 | DEF_CLK_DIV1(ipg_div, &ipg_clk, CBCDR, IPG); | ||
985 | DEF_CLK_DIV1(ahb_div, &ahb_clk, CBCDR, AHB); | ||
986 | DEF_CLK_DIV1(axi_div, &axi_clk, CBCDR, AXI); | ||
987 | DEF_CLK_DIV1(mmdc_ch0_axi_div, &mmdc_ch0_axi_clk, CBCDR, MMDC_CH0_AXI); | ||
988 | DEF_CLK_DIV1(mmdc_ch1_axi_div, &mmdc_ch1_axi_clk, CBCDR, MMDC_CH1_AXI); | ||
989 | DEF_CLK_DIV1(periph_clk2_div, &periph_clk2_clk, CBCDR, PERIPH_CLK2); | ||
990 | DEF_CLK_DIV1(periph2_clk2_div, &periph2_clk2_clk, CBCDR, PERIPH2_CLK2); | ||
991 | DEF_CLK_DIV1(gpu2d_core_div, &gpu2d_core_clk, CBCMR, GPU2D_CORE); | ||
992 | DEF_CLK_DIV1(gpu3d_core_div, &gpu3d_core_clk, CBCMR, GPU3D_CORE); | ||
993 | DEF_CLK_DIV1(gpu3d_shader_div, &gpu3d_shader_clk, CBCMR, GPU3D_SHADER); | ||
994 | DEF_CLK_DIV1(ipg_perclk_div, &ipg_perclk, CSCMR1, PERCLK); | ||
995 | DEF_CLK_DIV1(emi_div, &emi_clk, CSCMR1, EMI); | ||
996 | DEF_CLK_DIV1(emi_slow_div, &emi_slow_clk, CSCMR1, EMI_SLOW); | ||
997 | DEF_CLK_DIV1(can_div, &can1_clk, CSCMR2, CAN); | ||
998 | DEF_CLK_DIV1(uart_div, &uart_clk, CSCDR1, UART); | ||
999 | DEF_CLK_DIV1(usdhc1_div, &usdhc1_clk, CSCDR1, USDHC1); | ||
1000 | DEF_CLK_DIV1(usdhc2_div, &usdhc2_clk, CSCDR1, USDHC2); | ||
1001 | DEF_CLK_DIV1(usdhc3_div, &usdhc3_clk, CSCDR1, USDHC3); | ||
1002 | DEF_CLK_DIV1(usdhc4_div, &usdhc4_clk, CSCDR1, USDHC4); | ||
1003 | DEF_CLK_DIV1(vpu_div, &vpu_clk, CSCDR1, VPU_AXI); | ||
1004 | DEF_CLK_DIV1(hsi_tx_div, &hsi_tx_clk, CDCDR, HSI_TX); | ||
1005 | DEF_CLK_DIV1(ipu1_di0_pre_div, &ipu1_di0_pre_clk, CHSCCDR, IPU1_DI0_PRE); | ||
1006 | DEF_CLK_DIV1(ipu1_di1_pre_div, &ipu1_di1_pre_clk, CHSCCDR, IPU1_DI1_PRE); | ||
1007 | DEF_CLK_DIV1(ipu2_di0_pre_div, &ipu2_di0_pre_clk, CSCDR2, IPU2_DI0_PRE); | ||
1008 | DEF_CLK_DIV1(ipu2_di1_pre_div, &ipu2_di1_pre_clk, CSCDR2, IPU2_DI1_PRE); | ||
1009 | DEF_CLK_DIV1(ipu1_div, &ipu1_clk, CSCDR3, IPU1_HSP); | ||
1010 | DEF_CLK_DIV1(ipu2_div, &ipu2_clk, CSCDR3, IPU2_HSP); | ||
1011 | DEF_CLK_DIV1(cko1_div, &cko1_clk, CCOSR, CKO1); | ||
1012 | |||
1013 | #define DEF_CLK_DIV2(d, c, r, b) \ | ||
1014 | static struct divider d = { \ | ||
1015 | .clk = c, \ | ||
1016 | .reg = r, \ | ||
1017 | .bp_pred = BP_##r##_##b##_PRED, \ | ||
1018 | .bm_pred = BM_##r##_##b##_PRED, \ | ||
1019 | .bp_podf = BP_##r##_##b##_PODF, \ | ||
1020 | .bm_podf = BM_##r##_##b##_PODF, \ | ||
1021 | } | ||
1022 | |||
1023 | DEF_CLK_DIV2(ssi1_div, &ssi1_clk, CS1CDR, SSI1); | ||
1024 | DEF_CLK_DIV2(ssi3_div, &ssi3_clk, CS1CDR, SSI3); | ||
1025 | DEF_CLK_DIV2(esai_div, &esai_clk, CS1CDR, ESAI); | ||
1026 | DEF_CLK_DIV2(ssi2_div, &ssi2_clk, CS2CDR, SSI2); | ||
1027 | DEF_CLK_DIV2(enfc_div, &enfc_clk, CS2CDR, ENFC); | ||
1028 | DEF_CLK_DIV2(spdif_div, &spdif_clk, CDCDR, SPDIF); | ||
1029 | DEF_CLK_DIV2(asrc_serial_div, &asrc_serial_clk, CDCDR, ASRC_SERIAL); | ||
1030 | |||
1031 | static struct divider *dividers[] = { | ||
1032 | &arm_div, | ||
1033 | &ipg_div, | ||
1034 | &ahb_div, | ||
1035 | &axi_div, | ||
1036 | &mmdc_ch0_axi_div, | ||
1037 | &mmdc_ch1_axi_div, | ||
1038 | &periph_clk2_div, | ||
1039 | &periph2_clk2_div, | ||
1040 | &gpu2d_core_div, | ||
1041 | &gpu3d_core_div, | ||
1042 | &gpu3d_shader_div, | ||
1043 | &ipg_perclk_div, | ||
1044 | &emi_div, | ||
1045 | &emi_slow_div, | ||
1046 | &can_div, | ||
1047 | &uart_div, | ||
1048 | &usdhc1_div, | ||
1049 | &usdhc2_div, | ||
1050 | &usdhc3_div, | ||
1051 | &usdhc4_div, | ||
1052 | &vpu_div, | ||
1053 | &hsi_tx_div, | ||
1054 | &ipu1_di0_pre_div, | ||
1055 | &ipu1_di1_pre_div, | ||
1056 | &ipu2_di0_pre_div, | ||
1057 | &ipu2_di1_pre_div, | ||
1058 | &ipu1_div, | ||
1059 | &ipu2_div, | ||
1060 | &ssi1_div, | ||
1061 | &ssi3_div, | ||
1062 | &esai_div, | ||
1063 | &ssi2_div, | ||
1064 | &enfc_div, | ||
1065 | &spdif_div, | ||
1066 | &asrc_serial_div, | ||
1067 | &cko1_div, | ||
1068 | }; | ||
1069 | |||
1070 | static unsigned long ldb_di_clk_get_rate(struct clk *clk) | ||
1071 | { | ||
1072 | u32 val = readl_relaxed(CSCMR2); | ||
1073 | |||
1074 | val &= (clk == &ldb_di0_clk) ? BM_CSCMR2_LDB_DI0_IPU_DIV : | ||
1075 | BM_CSCMR2_LDB_DI1_IPU_DIV; | ||
1076 | if (val) | ||
1077 | return clk_get_rate(clk->parent) / 7; | ||
1078 | else | ||
1079 | return clk_get_rate(clk->parent) * 2 / 7; | ||
1080 | } | ||
1081 | |||
1082 | static int ldb_di_clk_set_rate(struct clk *clk, unsigned long rate) | ||
1083 | { | ||
1084 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
1085 | u32 val = readl_relaxed(CSCMR2); | ||
1086 | |||
1087 | if (rate * 7 <= parent_rate + parent_rate / 20) | ||
1088 | val |= BM_CSCMR2_LDB_DI0_IPU_DIV; | ||
1089 | else | ||
1090 | val &= ~BM_CSCMR2_LDB_DI0_IPU_DIV; | ||
1091 | |||
1092 | writel_relaxed(val, CSCMR2); | ||
1093 | |||
1094 | return 0; | ||
1095 | } | ||
1096 | |||
1097 | static unsigned long ldb_di_clk_round_rate(struct clk *clk, unsigned long rate) | ||
1098 | { | ||
1099 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
1100 | |||
1101 | if (rate * 7 <= parent_rate + parent_rate / 20) | ||
1102 | return parent_rate / 7; | ||
1103 | else | ||
1104 | return 2 * parent_rate / 7; | ||
1105 | } | ||
1106 | |||
1107 | static unsigned long _clk_get_rate(struct clk *clk) | ||
1108 | { | ||
1109 | struct divider *d; | ||
1110 | u32 val, pred, podf; | ||
1111 | int i, num; | ||
1112 | |||
1113 | if (clk == &ldb_di0_clk || clk == &ldb_di1_clk) | ||
1114 | return ldb_di_clk_get_rate(clk); | ||
1115 | |||
1116 | num = ARRAY_SIZE(dividers); | ||
1117 | for (i = 0; i < num; i++) | ||
1118 | if (dividers[i]->clk == clk) { | ||
1119 | d = dividers[i]; | ||
1120 | break; | ||
1121 | } | ||
1122 | if (i == num) | ||
1123 | return clk_get_rate(clk->parent); | ||
1124 | |||
1125 | val = readl_relaxed(d->reg); | ||
1126 | pred = ((val & d->bm_pred) >> d->bp_pred) + 1; | ||
1127 | podf = ((val & d->bm_podf) >> d->bp_podf) + 1; | ||
1128 | |||
1129 | return clk_get_rate(clk->parent) / (pred * podf); | ||
1130 | } | ||
1131 | |||
1132 | static int clk_busy_wait(struct clk *clk) | ||
1133 | { | ||
1134 | int timeout = 0x100000; | ||
1135 | u32 bm; | ||
1136 | |||
1137 | if (clk == &axi_clk) | ||
1138 | bm = BM_CDHIPR_AXI_PODF_BUSY; | ||
1139 | else if (clk == &ahb_clk) | ||
1140 | bm = BM_CDHIPR_AHB_PODF_BUSY; | ||
1141 | else if (clk == &mmdc_ch0_axi_clk) | ||
1142 | bm = BM_CDHIPR_MMDC_CH0_PODF_BUSY; | ||
1143 | else if (clk == &periph_clk) | ||
1144 | bm = BM_CDHIPR_PERIPH_SEL_BUSY; | ||
1145 | else if (clk == &arm_clk) | ||
1146 | bm = BM_CDHIPR_ARM_PODF_BUSY; | ||
1147 | else | ||
1148 | return -EINVAL; | ||
1149 | |||
1150 | while ((readl_relaxed(CDHIPR) & bm) && --timeout) | ||
1151 | cpu_relax(); | ||
1152 | |||
1153 | if (unlikely(!timeout)) | ||
1154 | return -EBUSY; | ||
1155 | |||
1156 | return 0; | ||
1157 | } | ||
1158 | |||
1159 | static int _clk_set_rate(struct clk *clk, unsigned long rate) | ||
1160 | { | ||
1161 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
1162 | struct divider *d; | ||
1163 | u32 val, div, max_div, pred = 0, podf; | ||
1164 | int i, num; | ||
1165 | |||
1166 | if (clk == &ldb_di0_clk || clk == &ldb_di1_clk) | ||
1167 | return ldb_di_clk_set_rate(clk, rate); | ||
1168 | |||
1169 | num = ARRAY_SIZE(dividers); | ||
1170 | for (i = 0; i < num; i++) | ||
1171 | if (dividers[i]->clk == clk) { | ||
1172 | d = dividers[i]; | ||
1173 | break; | ||
1174 | } | ||
1175 | if (i == num) | ||
1176 | return -EINVAL; | ||
1177 | |||
1178 | max_div = ((d->bm_pred >> d->bp_pred) + 1) * | ||
1179 | ((d->bm_podf >> d->bp_podf) + 1); | ||
1180 | |||
1181 | div = parent_rate / rate; | ||
1182 | if (div == 0) | ||
1183 | div++; | ||
1184 | |||
1185 | if ((parent_rate / div != rate) || div > max_div) | ||
1186 | return -EINVAL; | ||
1187 | |||
1188 | if (d->bm_pred) { | ||
1189 | calc_pred_podf_dividers(div, &pred, &podf); | ||
1190 | } else { | ||
1191 | pred = 1; | ||
1192 | podf = div; | ||
1193 | } | ||
1194 | |||
1195 | val = readl_relaxed(d->reg); | ||
1196 | val &= ~(d->bm_pred | d->bm_podf); | ||
1197 | val |= (pred - 1) << d->bp_pred | (podf - 1) << d->bp_podf; | ||
1198 | writel_relaxed(val, d->reg); | ||
1199 | |||
1200 | if (clk == &axi_clk || clk == &ahb_clk || | ||
1201 | clk == &mmdc_ch0_axi_clk || clk == &arm_clk) | ||
1202 | return clk_busy_wait(clk); | ||
1203 | |||
1204 | return 0; | ||
1205 | } | ||
1206 | |||
1207 | static unsigned long _clk_round_rate(struct clk *clk, unsigned long rate) | ||
1208 | { | ||
1209 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
1210 | u32 div = parent_rate / rate; | ||
1211 | u32 div_max, pred = 0, podf; | ||
1212 | struct divider *d; | ||
1213 | int i, num; | ||
1214 | |||
1215 | if (clk == &ldb_di0_clk || clk == &ldb_di1_clk) | ||
1216 | return ldb_di_clk_round_rate(clk, rate); | ||
1217 | |||
1218 | num = ARRAY_SIZE(dividers); | ||
1219 | for (i = 0; i < num; i++) | ||
1220 | if (dividers[i]->clk == clk) { | ||
1221 | d = dividers[i]; | ||
1222 | break; | ||
1223 | } | ||
1224 | if (i == num) | ||
1225 | return -EINVAL; | ||
1226 | |||
1227 | if (div == 0 || parent_rate % rate) | ||
1228 | div++; | ||
1229 | |||
1230 | if (d->bm_pred) { | ||
1231 | calc_pred_podf_dividers(div, &pred, &podf); | ||
1232 | div = pred * podf; | ||
1233 | } else { | ||
1234 | div_max = (d->bm_podf >> d->bp_podf) + 1; | ||
1235 | if (div > div_max) | ||
1236 | div = div_max; | ||
1237 | } | ||
1238 | |||
1239 | return parent_rate / div; | ||
1240 | } | ||
1241 | |||
1242 | struct multiplexer { | ||
1243 | struct clk *clk; | ||
1244 | void __iomem *reg; | ||
1245 | u32 bp; | ||
1246 | u32 bm; | ||
1247 | int pnum; | ||
1248 | struct clk *parents[]; | ||
1249 | }; | ||
1250 | |||
1251 | static struct multiplexer axi_mux = { | ||
1252 | .clk = &axi_clk, | ||
1253 | .reg = CBCDR, | ||
1254 | .bp = BP_CBCDR_AXI_SEL, | ||
1255 | .bm = BM_CBCDR_AXI_SEL, | ||
1256 | .parents = { | ||
1257 | &periph_clk, | ||
1258 | &pll2_pfd_400m, | ||
1259 | &pll3_pfd_540m, | ||
1260 | NULL | ||
1261 | }, | ||
1262 | }; | ||
1263 | |||
1264 | static struct multiplexer periph_mux = { | ||
1265 | .clk = &periph_clk, | ||
1266 | .reg = CBCDR, | ||
1267 | .bp = BP_CBCDR_PERIPH_CLK_SEL, | ||
1268 | .bm = BM_CBCDR_PERIPH_CLK_SEL, | ||
1269 | .parents = { | ||
1270 | &periph_pre_clk, | ||
1271 | &periph_clk2_clk, | ||
1272 | NULL | ||
1273 | }, | ||
1274 | }; | ||
1275 | |||
1276 | static struct multiplexer periph_pre_mux = { | ||
1277 | .clk = &periph_pre_clk, | ||
1278 | .reg = CBCMR, | ||
1279 | .bp = BP_CBCMR_PRE_PERIPH_CLK_SEL, | ||
1280 | .bm = BM_CBCMR_PRE_PERIPH_CLK_SEL, | ||
1281 | .parents = { | ||
1282 | &pll2_bus, | ||
1283 | &pll2_pfd_400m, | ||
1284 | &pll2_pfd_352m, | ||
1285 | &pll2_200m, | ||
1286 | NULL | ||
1287 | }, | ||
1288 | }; | ||
1289 | |||
1290 | static struct multiplexer periph_clk2_mux = { | ||
1291 | .clk = &periph_clk2_clk, | ||
1292 | .reg = CBCMR, | ||
1293 | .bp = BP_CBCMR_PERIPH_CLK2_SEL, | ||
1294 | .bm = BM_CBCMR_PERIPH_CLK2_SEL, | ||
1295 | .parents = { | ||
1296 | &pll3_usb_otg, | ||
1297 | &osc_clk, | ||
1298 | NULL | ||
1299 | }, | ||
1300 | }; | ||
1301 | |||
1302 | static struct multiplexer periph2_mux = { | ||
1303 | .clk = &periph2_clk, | ||
1304 | .reg = CBCDR, | ||
1305 | .bp = BP_CBCDR_PERIPH2_CLK_SEL, | ||
1306 | .bm = BM_CBCDR_PERIPH2_CLK_SEL, | ||
1307 | .parents = { | ||
1308 | &periph2_pre_clk, | ||
1309 | &periph2_clk2_clk, | ||
1310 | NULL | ||
1311 | }, | ||
1312 | }; | ||
1313 | |||
1314 | static struct multiplexer periph2_pre_mux = { | ||
1315 | .clk = &periph2_pre_clk, | ||
1316 | .reg = CBCMR, | ||
1317 | .bp = BP_CBCMR_PRE_PERIPH2_CLK_SEL, | ||
1318 | .bm = BM_CBCMR_PRE_PERIPH2_CLK_SEL, | ||
1319 | .parents = { | ||
1320 | &pll2_bus, | ||
1321 | &pll2_pfd_400m, | ||
1322 | &pll2_pfd_352m, | ||
1323 | &pll2_200m, | ||
1324 | NULL | ||
1325 | }, | ||
1326 | }; | ||
1327 | |||
1328 | static struct multiplexer periph2_clk2_mux = { | ||
1329 | .clk = &periph2_clk2_clk, | ||
1330 | .reg = CBCMR, | ||
1331 | .bp = BP_CBCMR_PERIPH2_CLK2_SEL, | ||
1332 | .bm = BM_CBCMR_PERIPH2_CLK2_SEL, | ||
1333 | .parents = { | ||
1334 | &pll3_usb_otg, | ||
1335 | &osc_clk, | ||
1336 | NULL | ||
1337 | }, | ||
1338 | }; | ||
1339 | |||
1340 | static struct multiplexer gpu2d_axi_mux = { | ||
1341 | .clk = &gpu2d_axi_clk, | ||
1342 | .reg = CBCMR, | ||
1343 | .bp = BP_CBCMR_GPU2D_AXI_SEL, | ||
1344 | .bm = BM_CBCMR_GPU2D_AXI_SEL, | ||
1345 | .parents = { | ||
1346 | &axi_clk, | ||
1347 | &ahb_clk, | ||
1348 | NULL | ||
1349 | }, | ||
1350 | }; | ||
1351 | |||
1352 | static struct multiplexer gpu3d_axi_mux = { | ||
1353 | .clk = &gpu3d_axi_clk, | ||
1354 | .reg = CBCMR, | ||
1355 | .bp = BP_CBCMR_GPU3D_AXI_SEL, | ||
1356 | .bm = BM_CBCMR_GPU3D_AXI_SEL, | ||
1357 | .parents = { | ||
1358 | &axi_clk, | ||
1359 | &ahb_clk, | ||
1360 | NULL | ||
1361 | }, | ||
1362 | }; | ||
1363 | |||
1364 | static struct multiplexer gpu3d_core_mux = { | ||
1365 | .clk = &gpu3d_core_clk, | ||
1366 | .reg = CBCMR, | ||
1367 | .bp = BP_CBCMR_GPU3D_CORE_SEL, | ||
1368 | .bm = BM_CBCMR_GPU3D_CORE_SEL, | ||
1369 | .parents = { | ||
1370 | &mmdc_ch0_axi_clk, | ||
1371 | &pll3_usb_otg, | ||
1372 | &pll2_pfd_594m, | ||
1373 | &pll2_pfd_400m, | ||
1374 | NULL | ||
1375 | }, | ||
1376 | }; | ||
1377 | |||
1378 | static struct multiplexer gpu3d_shader_mux = { | ||
1379 | .clk = &gpu3d_shader_clk, | ||
1380 | .reg = CBCMR, | ||
1381 | .bp = BP_CBCMR_GPU3D_SHADER_SEL, | ||
1382 | .bm = BM_CBCMR_GPU3D_SHADER_SEL, | ||
1383 | .parents = { | ||
1384 | &mmdc_ch0_axi_clk, | ||
1385 | &pll3_usb_otg, | ||
1386 | &pll2_pfd_594m, | ||
1387 | &pll3_pfd_720m, | ||
1388 | NULL | ||
1389 | }, | ||
1390 | }; | ||
1391 | |||
1392 | static struct multiplexer pcie_axi_mux = { | ||
1393 | .clk = &pcie_clk, | ||
1394 | .reg = CBCMR, | ||
1395 | .bp = BP_CBCMR_PCIE_AXI_SEL, | ||
1396 | .bm = BM_CBCMR_PCIE_AXI_SEL, | ||
1397 | .parents = { | ||
1398 | &axi_clk, | ||
1399 | &ahb_clk, | ||
1400 | NULL | ||
1401 | }, | ||
1402 | }; | ||
1403 | |||
1404 | static struct multiplexer vdo_axi_mux = { | ||
1405 | .clk = &vdo_axi_clk, | ||
1406 | .reg = CBCMR, | ||
1407 | .bp = BP_CBCMR_VDO_AXI_SEL, | ||
1408 | .bm = BM_CBCMR_VDO_AXI_SEL, | ||
1409 | .parents = { | ||
1410 | &axi_clk, | ||
1411 | &ahb_clk, | ||
1412 | NULL | ||
1413 | }, | ||
1414 | }; | ||
1415 | |||
1416 | static struct multiplexer vpu_axi_mux = { | ||
1417 | .clk = &vpu_clk, | ||
1418 | .reg = CBCMR, | ||
1419 | .bp = BP_CBCMR_VPU_AXI_SEL, | ||
1420 | .bm = BM_CBCMR_VPU_AXI_SEL, | ||
1421 | .parents = { | ||
1422 | &axi_clk, | ||
1423 | &pll2_pfd_400m, | ||
1424 | &pll2_pfd_352m, | ||
1425 | NULL | ||
1426 | }, | ||
1427 | }; | ||
1428 | |||
1429 | static struct multiplexer gpu2d_core_mux = { | ||
1430 | .clk = &gpu2d_core_clk, | ||
1431 | .reg = CBCMR, | ||
1432 | .bp = BP_CBCMR_GPU2D_CORE_SEL, | ||
1433 | .bm = BM_CBCMR_GPU2D_CORE_SEL, | ||
1434 | .parents = { | ||
1435 | &axi_clk, | ||
1436 | &pll3_usb_otg, | ||
1437 | &pll2_pfd_352m, | ||
1438 | &pll2_pfd_400m, | ||
1439 | NULL | ||
1440 | }, | ||
1441 | }; | ||
1442 | |||
1443 | #define DEF_SSI_MUX(id) \ | ||
1444 | static struct multiplexer ssi##id##_mux = { \ | ||
1445 | .clk = &ssi##id##_clk, \ | ||
1446 | .reg = CSCMR1, \ | ||
1447 | .bp = BP_CSCMR1_SSI##id##_SEL, \ | ||
1448 | .bm = BM_CSCMR1_SSI##id##_SEL, \ | ||
1449 | .parents = { \ | ||
1450 | &pll3_pfd_508m, \ | ||
1451 | &pll3_pfd_454m, \ | ||
1452 | &pll4_audio, \ | ||
1453 | NULL \ | ||
1454 | }, \ | ||
1455 | } | ||
1456 | |||
1457 | DEF_SSI_MUX(1); | ||
1458 | DEF_SSI_MUX(2); | ||
1459 | DEF_SSI_MUX(3); | ||
1460 | |||
1461 | #define DEF_USDHC_MUX(id) \ | ||
1462 | static struct multiplexer usdhc##id##_mux = { \ | ||
1463 | .clk = &usdhc##id##_clk, \ | ||
1464 | .reg = CSCMR1, \ | ||
1465 | .bp = BP_CSCMR1_USDHC##id##_SEL, \ | ||
1466 | .bm = BM_CSCMR1_USDHC##id##_SEL, \ | ||
1467 | .parents = { \ | ||
1468 | &pll2_pfd_400m, \ | ||
1469 | &pll2_pfd_352m, \ | ||
1470 | NULL \ | ||
1471 | }, \ | ||
1472 | } | ||
1473 | |||
1474 | DEF_USDHC_MUX(1); | ||
1475 | DEF_USDHC_MUX(2); | ||
1476 | DEF_USDHC_MUX(3); | ||
1477 | DEF_USDHC_MUX(4); | ||
1478 | |||
1479 | static struct multiplexer emi_mux = { | ||
1480 | .clk = &emi_clk, | ||
1481 | .reg = CSCMR1, | ||
1482 | .bp = BP_CSCMR1_EMI_SEL, | ||
1483 | .bm = BM_CSCMR1_EMI_SEL, | ||
1484 | .parents = { | ||
1485 | &axi_clk, | ||
1486 | &pll3_usb_otg, | ||
1487 | &pll2_pfd_400m, | ||
1488 | &pll2_pfd_352m, | ||
1489 | NULL | ||
1490 | }, | ||
1491 | }; | ||
1492 | |||
1493 | static struct multiplexer emi_slow_mux = { | ||
1494 | .clk = &emi_slow_clk, | ||
1495 | .reg = CSCMR1, | ||
1496 | .bp = BP_CSCMR1_EMI_SLOW_SEL, | ||
1497 | .bm = BM_CSCMR1_EMI_SLOW_SEL, | ||
1498 | .parents = { | ||
1499 | &axi_clk, | ||
1500 | &pll3_usb_otg, | ||
1501 | &pll2_pfd_400m, | ||
1502 | &pll2_pfd_352m, | ||
1503 | NULL | ||
1504 | }, | ||
1505 | }; | ||
1506 | |||
1507 | static struct multiplexer esai_mux = { | ||
1508 | .clk = &esai_clk, | ||
1509 | .reg = CSCMR2, | ||
1510 | .bp = BP_CSCMR2_ESAI_SEL, | ||
1511 | .bm = BM_CSCMR2_ESAI_SEL, | ||
1512 | .parents = { | ||
1513 | &pll4_audio, | ||
1514 | &pll3_pfd_508m, | ||
1515 | &pll3_pfd_454m, | ||
1516 | &pll3_usb_otg, | ||
1517 | NULL | ||
1518 | }, | ||
1519 | }; | ||
1520 | |||
1521 | #define DEF_LDB_DI_MUX(id) \ | ||
1522 | static struct multiplexer ldb_di##id##_mux = { \ | ||
1523 | .clk = &ldb_di##id##_clk, \ | ||
1524 | .reg = CS2CDR, \ | ||
1525 | .bp = BP_CS2CDR_LDB_DI##id##_SEL, \ | ||
1526 | .bm = BM_CS2CDR_LDB_DI##id##_SEL, \ | ||
1527 | .parents = { \ | ||
1528 | &pll5_video, \ | ||
1529 | &pll2_pfd_352m, \ | ||
1530 | &pll2_pfd_400m, \ | ||
1531 | &pll3_pfd_540m, \ | ||
1532 | &pll3_usb_otg, \ | ||
1533 | NULL \ | ||
1534 | }, \ | ||
1535 | } | ||
1536 | |||
1537 | DEF_LDB_DI_MUX(0); | ||
1538 | DEF_LDB_DI_MUX(1); | ||
1539 | |||
1540 | static struct multiplexer enfc_mux = { | ||
1541 | .clk = &enfc_clk, | ||
1542 | .reg = CS2CDR, | ||
1543 | .bp = BP_CS2CDR_ENFC_SEL, | ||
1544 | .bm = BM_CS2CDR_ENFC_SEL, | ||
1545 | .parents = { | ||
1546 | &pll2_pfd_352m, | ||
1547 | &pll2_bus, | ||
1548 | &pll3_usb_otg, | ||
1549 | &pll2_pfd_400m, | ||
1550 | NULL | ||
1551 | }, | ||
1552 | }; | ||
1553 | |||
1554 | static struct multiplexer spdif_mux = { | ||
1555 | .clk = &spdif_clk, | ||
1556 | .reg = CDCDR, | ||
1557 | .bp = BP_CDCDR_SPDIF_SEL, | ||
1558 | .bm = BM_CDCDR_SPDIF_SEL, | ||
1559 | .parents = { | ||
1560 | &pll4_audio, | ||
1561 | &pll3_pfd_508m, | ||
1562 | &pll3_pfd_454m, | ||
1563 | &pll3_usb_otg, | ||
1564 | NULL | ||
1565 | }, | ||
1566 | }; | ||
1567 | |||
1568 | static struct multiplexer asrc_serial_mux = { | ||
1569 | .clk = &asrc_serial_clk, | ||
1570 | .reg = CDCDR, | ||
1571 | .bp = BP_CDCDR_ASRC_SERIAL_SEL, | ||
1572 | .bm = BM_CDCDR_ASRC_SERIAL_SEL, | ||
1573 | .parents = { | ||
1574 | &pll4_audio, | ||
1575 | &pll3_pfd_508m, | ||
1576 | &pll3_pfd_454m, | ||
1577 | &pll3_usb_otg, | ||
1578 | NULL | ||
1579 | }, | ||
1580 | }; | ||
1581 | |||
1582 | static struct multiplexer hsi_tx_mux = { | ||
1583 | .clk = &hsi_tx_clk, | ||
1584 | .reg = CDCDR, | ||
1585 | .bp = BP_CDCDR_HSI_TX_SEL, | ||
1586 | .bm = BM_CDCDR_HSI_TX_SEL, | ||
1587 | .parents = { | ||
1588 | &pll3_120m, | ||
1589 | &pll2_pfd_400m, | ||
1590 | NULL | ||
1591 | }, | ||
1592 | }; | ||
1593 | |||
1594 | #define DEF_IPU_DI_PRE_MUX(r, i, d) \ | ||
1595 | static struct multiplexer ipu##i##_di##d##_pre_mux = { \ | ||
1596 | .clk = &ipu##i##_di##d##_pre_clk, \ | ||
1597 | .reg = r, \ | ||
1598 | .bp = BP_##r##_IPU##i##_DI##d##_PRE_SEL, \ | ||
1599 | .bm = BM_##r##_IPU##i##_DI##d##_PRE_SEL, \ | ||
1600 | .parents = { \ | ||
1601 | &mmdc_ch0_axi_clk, \ | ||
1602 | &pll3_usb_otg, \ | ||
1603 | &pll5_video, \ | ||
1604 | &pll2_pfd_352m, \ | ||
1605 | &pll2_pfd_400m, \ | ||
1606 | &pll3_pfd_540m, \ | ||
1607 | NULL \ | ||
1608 | }, \ | ||
1609 | } | ||
1610 | |||
1611 | DEF_IPU_DI_PRE_MUX(CHSCCDR, 1, 0); | ||
1612 | DEF_IPU_DI_PRE_MUX(CHSCCDR, 1, 1); | ||
1613 | DEF_IPU_DI_PRE_MUX(CSCDR2, 2, 0); | ||
1614 | DEF_IPU_DI_PRE_MUX(CSCDR2, 2, 1); | ||
1615 | |||
1616 | #define DEF_IPU_DI_MUX(r, i, d) \ | ||
1617 | static struct multiplexer ipu##i##_di##d##_mux = { \ | ||
1618 | .clk = &ipu##i##_di##d##_clk, \ | ||
1619 | .reg = r, \ | ||
1620 | .bp = BP_##r##_IPU##i##_DI##d##_SEL, \ | ||
1621 | .bm = BM_##r##_IPU##i##_DI##d##_SEL, \ | ||
1622 | .parents = { \ | ||
1623 | &ipu##i##_di##d##_pre_clk, \ | ||
1624 | &dummy_clk, \ | ||
1625 | &dummy_clk, \ | ||
1626 | &ldb_di0_clk, \ | ||
1627 | &ldb_di1_clk, \ | ||
1628 | NULL \ | ||
1629 | }, \ | ||
1630 | } | ||
1631 | |||
1632 | DEF_IPU_DI_MUX(CHSCCDR, 1, 0); | ||
1633 | DEF_IPU_DI_MUX(CHSCCDR, 1, 1); | ||
1634 | DEF_IPU_DI_MUX(CSCDR2, 2, 0); | ||
1635 | DEF_IPU_DI_MUX(CSCDR2, 2, 1); | ||
1636 | |||
1637 | #define DEF_IPU_MUX(id) \ | ||
1638 | static struct multiplexer ipu##id##_mux = { \ | ||
1639 | .clk = &ipu##id##_clk, \ | ||
1640 | .reg = CSCDR3, \ | ||
1641 | .bp = BP_CSCDR3_IPU##id##_HSP_SEL, \ | ||
1642 | .bm = BM_CSCDR3_IPU##id##_HSP_SEL, \ | ||
1643 | .parents = { \ | ||
1644 | &mmdc_ch0_axi_clk, \ | ||
1645 | &pll2_pfd_400m, \ | ||
1646 | &pll3_120m, \ | ||
1647 | &pll3_pfd_540m, \ | ||
1648 | NULL \ | ||
1649 | }, \ | ||
1650 | } | ||
1651 | |||
1652 | DEF_IPU_MUX(1); | ||
1653 | DEF_IPU_MUX(2); | ||
1654 | |||
1655 | static struct multiplexer cko1_mux = { | ||
1656 | .clk = &cko1_clk, | ||
1657 | .reg = CCOSR, | ||
1658 | .bp = BP_CCOSR_CKO1_SEL, | ||
1659 | .bm = BM_CCOSR_CKO1_SEL, | ||
1660 | .parents = { | ||
1661 | &pll3_usb_otg, | ||
1662 | &pll2_bus, | ||
1663 | &pll1_sys, | ||
1664 | &pll5_video, | ||
1665 | &dummy_clk, | ||
1666 | &axi_clk, | ||
1667 | &enfc_clk, | ||
1668 | &ipu1_di0_clk, | ||
1669 | &ipu1_di1_clk, | ||
1670 | &ipu2_di0_clk, | ||
1671 | &ipu2_di1_clk, | ||
1672 | &ahb_clk, | ||
1673 | &ipg_clk, | ||
1674 | &ipg_perclk, | ||
1675 | &ckil_clk, | ||
1676 | &pll4_audio, | ||
1677 | NULL | ||
1678 | }, | ||
1679 | }; | ||
1680 | |||
1681 | static struct multiplexer *multiplexers[] = { | ||
1682 | &axi_mux, | ||
1683 | &periph_mux, | ||
1684 | &periph_pre_mux, | ||
1685 | &periph_clk2_mux, | ||
1686 | &periph2_mux, | ||
1687 | &periph2_pre_mux, | ||
1688 | &periph2_clk2_mux, | ||
1689 | &gpu2d_axi_mux, | ||
1690 | &gpu3d_axi_mux, | ||
1691 | &gpu3d_core_mux, | ||
1692 | &gpu3d_shader_mux, | ||
1693 | &pcie_axi_mux, | ||
1694 | &vdo_axi_mux, | ||
1695 | &vpu_axi_mux, | ||
1696 | &gpu2d_core_mux, | ||
1697 | &ssi1_mux, | ||
1698 | &ssi2_mux, | ||
1699 | &ssi3_mux, | ||
1700 | &usdhc1_mux, | ||
1701 | &usdhc2_mux, | ||
1702 | &usdhc3_mux, | ||
1703 | &usdhc4_mux, | ||
1704 | &emi_mux, | ||
1705 | &emi_slow_mux, | ||
1706 | &esai_mux, | ||
1707 | &ldb_di0_mux, | ||
1708 | &ldb_di1_mux, | ||
1709 | &enfc_mux, | ||
1710 | &spdif_mux, | ||
1711 | &asrc_serial_mux, | ||
1712 | &hsi_tx_mux, | ||
1713 | &ipu1_di0_pre_mux, | ||
1714 | &ipu1_di0_mux, | ||
1715 | &ipu1_di1_pre_mux, | ||
1716 | &ipu1_di1_mux, | ||
1717 | &ipu2_di0_pre_mux, | ||
1718 | &ipu2_di0_mux, | ||
1719 | &ipu2_di1_pre_mux, | ||
1720 | &ipu2_di1_mux, | ||
1721 | &ipu1_mux, | ||
1722 | &ipu2_mux, | ||
1723 | &cko1_mux, | ||
1724 | }; | ||
1725 | |||
1726 | static int _clk_set_parent(struct clk *clk, struct clk *parent) | ||
1727 | { | ||
1728 | struct multiplexer *m; | ||
1729 | int i, num; | ||
1730 | u32 val; | ||
1731 | |||
1732 | num = ARRAY_SIZE(multiplexers); | ||
1733 | for (i = 0; i < num; i++) | ||
1734 | if (multiplexers[i]->clk == clk) { | ||
1735 | m = multiplexers[i]; | ||
1736 | break; | ||
1737 | } | ||
1738 | if (i == num) | ||
1739 | return -EINVAL; | ||
1740 | |||
1741 | i = 0; | ||
1742 | while (m->parents[i]) { | ||
1743 | if (parent == m->parents[i]) | ||
1744 | break; | ||
1745 | i++; | ||
1746 | } | ||
1747 | if (!m->parents[i] || m->parents[i] == &dummy_clk) | ||
1748 | return -EINVAL; | ||
1749 | |||
1750 | val = readl_relaxed(m->reg); | ||
1751 | val &= ~m->bm; | ||
1752 | val |= i << m->bp; | ||
1753 | writel_relaxed(val, m->reg); | ||
1754 | |||
1755 | if (clk == &periph_clk) | ||
1756 | return clk_busy_wait(clk); | ||
1757 | |||
1758 | return 0; | ||
1759 | } | ||
1760 | |||
1761 | #define DEF_NG_CLK(name, p) \ | ||
1762 | static struct clk name = { \ | ||
1763 | .get_rate = _clk_get_rate, \ | ||
1764 | .set_rate = _clk_set_rate, \ | ||
1765 | .round_rate = _clk_round_rate, \ | ||
1766 | .set_parent = _clk_set_parent, \ | ||
1767 | .parent = p, \ | ||
1768 | } | ||
1769 | |||
1770 | DEF_NG_CLK(periph_clk2_clk, &osc_clk); | ||
1771 | DEF_NG_CLK(periph_pre_clk, &pll2_bus); | ||
1772 | DEF_NG_CLK(periph_clk, &periph_pre_clk); | ||
1773 | DEF_NG_CLK(periph2_clk2_clk, &osc_clk); | ||
1774 | DEF_NG_CLK(periph2_pre_clk, &pll2_bus); | ||
1775 | DEF_NG_CLK(periph2_clk, &periph2_pre_clk); | ||
1776 | DEF_NG_CLK(axi_clk, &periph_clk); | ||
1777 | DEF_NG_CLK(emi_clk, &axi_clk); | ||
1778 | DEF_NG_CLK(arm_clk, &pll1_sw_clk); | ||
1779 | DEF_NG_CLK(ahb_clk, &periph_clk); | ||
1780 | DEF_NG_CLK(ipg_clk, &ahb_clk); | ||
1781 | DEF_NG_CLK(ipg_perclk, &ipg_clk); | ||
1782 | DEF_NG_CLK(ipu1_di0_pre_clk, &pll3_pfd_540m); | ||
1783 | DEF_NG_CLK(ipu1_di1_pre_clk, &pll3_pfd_540m); | ||
1784 | DEF_NG_CLK(ipu2_di0_pre_clk, &pll3_pfd_540m); | ||
1785 | DEF_NG_CLK(ipu2_di1_pre_clk, &pll3_pfd_540m); | ||
1786 | DEF_NG_CLK(asrc_serial_clk, &pll3_usb_otg); | ||
1787 | |||
1788 | #define DEF_CLK(name, er, es, p, s) \ | ||
1789 | static struct clk name = { \ | ||
1790 | .enable_reg = er, \ | ||
1791 | .enable_shift = es, \ | ||
1792 | .enable = _clk_enable, \ | ||
1793 | .disable = _clk_disable, \ | ||
1794 | .get_rate = _clk_get_rate, \ | ||
1795 | .set_rate = _clk_set_rate, \ | ||
1796 | .round_rate = _clk_round_rate, \ | ||
1797 | .set_parent = _clk_set_parent, \ | ||
1798 | .parent = p, \ | ||
1799 | .secondary = s, \ | ||
1800 | } | ||
1801 | |||
1802 | #define DEF_CLK_1B(name, er, es, p, s) \ | ||
1803 | static struct clk name = { \ | ||
1804 | .enable_reg = er, \ | ||
1805 | .enable_shift = es, \ | ||
1806 | .enable = _clk_enable_1b, \ | ||
1807 | .disable = _clk_disable_1b, \ | ||
1808 | .get_rate = _clk_get_rate, \ | ||
1809 | .set_rate = _clk_set_rate, \ | ||
1810 | .round_rate = _clk_round_rate, \ | ||
1811 | .set_parent = _clk_set_parent, \ | ||
1812 | .parent = p, \ | ||
1813 | .secondary = s, \ | ||
1814 | } | ||
1815 | |||
1816 | DEF_CLK(aips_tz1_clk, CCGR0, CG0, &ahb_clk, NULL); | ||
1817 | DEF_CLK(aips_tz2_clk, CCGR0, CG1, &ahb_clk, NULL); | ||
1818 | DEF_CLK(apbh_dma_clk, CCGR0, CG2, &ahb_clk, NULL); | ||
1819 | DEF_CLK(asrc_clk, CCGR0, CG3, &pll4_audio, NULL); | ||
1820 | DEF_CLK(can1_serial_clk, CCGR0, CG8, &pll3_usb_otg, NULL); | ||
1821 | DEF_CLK(can1_clk, CCGR0, CG7, &pll3_usb_otg, &can1_serial_clk); | ||
1822 | DEF_CLK(can2_serial_clk, CCGR0, CG10, &pll3_usb_otg, NULL); | ||
1823 | DEF_CLK(can2_clk, CCGR0, CG9, &pll3_usb_otg, &can2_serial_clk); | ||
1824 | DEF_CLK(ecspi1_clk, CCGR1, CG0, &pll3_60m, NULL); | ||
1825 | DEF_CLK(ecspi2_clk, CCGR1, CG1, &pll3_60m, NULL); | ||
1826 | DEF_CLK(ecspi3_clk, CCGR1, CG2, &pll3_60m, NULL); | ||
1827 | DEF_CLK(ecspi4_clk, CCGR1, CG3, &pll3_60m, NULL); | ||
1828 | DEF_CLK(ecspi5_clk, CCGR1, CG4, &pll3_60m, NULL); | ||
1829 | DEF_CLK(enet_clk, CCGR1, CG5, &ipg_clk, NULL); | ||
1830 | DEF_CLK(esai_clk, CCGR1, CG8, &pll3_usb_otg, NULL); | ||
1831 | DEF_CLK(gpt_serial_clk, CCGR1, CG11, &ipg_perclk, NULL); | ||
1832 | DEF_CLK(gpt_clk, CCGR1, CG10, &ipg_perclk, &gpt_serial_clk); | ||
1833 | DEF_CLK(gpu2d_core_clk, CCGR1, CG12, &pll2_pfd_352m, &gpu2d_axi_clk); | ||
1834 | DEF_CLK(gpu3d_core_clk, CCGR1, CG13, &pll2_pfd_594m, &gpu3d_axi_clk); | ||
1835 | DEF_CLK(gpu3d_shader_clk, CCGR1, CG13, &pll3_pfd_720m, &gpu3d_axi_clk); | ||
1836 | DEF_CLK(hdmi_iahb_clk, CCGR2, CG0, &ahb_clk, NULL); | ||
1837 | DEF_CLK(hdmi_isfr_clk, CCGR2, CG2, &pll3_pfd_540m, &hdmi_iahb_clk); | ||
1838 | DEF_CLK(i2c1_clk, CCGR2, CG3, &ipg_perclk, NULL); | ||
1839 | DEF_CLK(i2c2_clk, CCGR2, CG4, &ipg_perclk, NULL); | ||
1840 | DEF_CLK(i2c3_clk, CCGR2, CG5, &ipg_perclk, NULL); | ||
1841 | DEF_CLK(iim_clk, CCGR2, CG6, &ipg_clk, NULL); | ||
1842 | DEF_CLK(enfc_clk, CCGR2, CG7, &pll2_pfd_352m, NULL); | ||
1843 | DEF_CLK(ipu1_clk, CCGR3, CG0, &mmdc_ch0_axi_clk, NULL); | ||
1844 | DEF_CLK(ipu1_di0_clk, CCGR3, CG1, &ipu1_di0_pre_clk, NULL); | ||
1845 | DEF_CLK(ipu1_di1_clk, CCGR3, CG2, &ipu1_di1_pre_clk, NULL); | ||
1846 | DEF_CLK(ipu2_clk, CCGR3, CG3, &mmdc_ch0_axi_clk, NULL); | ||
1847 | DEF_CLK(ipu2_di0_clk, CCGR3, CG4, &ipu2_di0_pre_clk, NULL); | ||
1848 | DEF_CLK(ipu2_di1_clk, CCGR3, CG5, &ipu2_di1_pre_clk, NULL); | ||
1849 | DEF_CLK(ldb_di0_clk, CCGR3, CG6, &pll3_pfd_540m, NULL); | ||
1850 | DEF_CLK(ldb_di1_clk, CCGR3, CG7, &pll3_pfd_540m, NULL); | ||
1851 | DEF_CLK(hsi_tx_clk, CCGR3, CG8, &pll2_pfd_400m, NULL); | ||
1852 | DEF_CLK(mlb_clk, CCGR3, CG9, &pll6_mlb, NULL); | ||
1853 | DEF_CLK(mmdc_ch0_ipg_clk, CCGR3, CG12, &ipg_clk, NULL); | ||
1854 | DEF_CLK(mmdc_ch0_axi_clk, CCGR3, CG10, &periph_clk, &mmdc_ch0_ipg_clk); | ||
1855 | DEF_CLK(mmdc_ch1_ipg_clk, CCGR3, CG13, &ipg_clk, NULL); | ||
1856 | DEF_CLK(mmdc_ch1_axi_clk, CCGR3, CG11, &periph2_clk, &mmdc_ch1_ipg_clk); | ||
1857 | DEF_CLK(openvg_axi_clk, CCGR3, CG13, &axi_clk, NULL); | ||
1858 | DEF_CLK(pwm1_clk, CCGR4, CG8, &ipg_perclk, NULL); | ||
1859 | DEF_CLK(pwm2_clk, CCGR4, CG9, &ipg_perclk, NULL); | ||
1860 | DEF_CLK(pwm3_clk, CCGR4, CG10, &ipg_perclk, NULL); | ||
1861 | DEF_CLK(pwm4_clk, CCGR4, CG11, &ipg_perclk, NULL); | ||
1862 | DEF_CLK(gpmi_bch_apb_clk, CCGR4, CG12, &usdhc3_clk, NULL); | ||
1863 | DEF_CLK(gpmi_bch_clk, CCGR4, CG13, &usdhc4_clk, &gpmi_bch_apb_clk); | ||
1864 | DEF_CLK(gpmi_apb_clk, CCGR4, CG15, &usdhc3_clk, &gpmi_bch_clk); | ||
1865 | DEF_CLK(gpmi_io_clk, CCGR4, CG14, &enfc_clk, &gpmi_apb_clk); | ||
1866 | DEF_CLK(sdma_clk, CCGR5, CG3, &ahb_clk, NULL); | ||
1867 | DEF_CLK(spba_clk, CCGR5, CG6, &ipg_clk, NULL); | ||
1868 | DEF_CLK(spdif_clk, CCGR5, CG7, &pll3_usb_otg, &spba_clk); | ||
1869 | DEF_CLK(ssi1_clk, CCGR5, CG9, &pll3_pfd_508m, NULL); | ||
1870 | DEF_CLK(ssi2_clk, CCGR5, CG10, &pll3_pfd_508m, NULL); | ||
1871 | DEF_CLK(ssi3_clk, CCGR5, CG11, &pll3_pfd_508m, NULL); | ||
1872 | DEF_CLK(uart_serial_clk, CCGR5, CG13, &pll3_usb_otg, NULL); | ||
1873 | DEF_CLK(uart_clk, CCGR5, CG12, &pll3_80m, &uart_serial_clk); | ||
1874 | DEF_CLK(usboh3_clk, CCGR6, CG0, &ipg_clk, NULL); | ||
1875 | DEF_CLK(usdhc1_clk, CCGR6, CG1, &pll2_pfd_400m, NULL); | ||
1876 | DEF_CLK(usdhc2_clk, CCGR6, CG2, &pll2_pfd_400m, NULL); | ||
1877 | DEF_CLK(usdhc3_clk, CCGR6, CG3, &pll2_pfd_400m, NULL); | ||
1878 | DEF_CLK(usdhc4_clk, CCGR6, CG4, &pll2_pfd_400m, NULL); | ||
1879 | DEF_CLK(emi_slow_clk, CCGR6, CG5, &axi_clk, NULL); | ||
1880 | DEF_CLK(vdo_axi_clk, CCGR6, CG6, &axi_clk, NULL); | ||
1881 | DEF_CLK(vpu_clk, CCGR6, CG7, &axi_clk, NULL); | ||
1882 | DEF_CLK_1B(cko1_clk, CCOSR, BP_CCOSR_CKO1_EN, &pll2_bus, NULL); | ||
1883 | |||
1884 | static int pcie_clk_enable(struct clk *clk) | ||
1885 | { | ||
1886 | u32 val; | ||
1887 | |||
1888 | val = readl_relaxed(PLL8_ENET); | ||
1889 | val |= BM_PLL_ENET_EN_PCIE; | ||
1890 | writel_relaxed(val, PLL8_ENET); | ||
1891 | |||
1892 | return _clk_enable(clk); | ||
1893 | } | ||
1894 | |||
1895 | static void pcie_clk_disable(struct clk *clk) | ||
1896 | { | ||
1897 | u32 val; | ||
1898 | |||
1899 | _clk_disable(clk); | ||
1900 | |||
1901 | val = readl_relaxed(PLL8_ENET); | ||
1902 | val &= BM_PLL_ENET_EN_PCIE; | ||
1903 | writel_relaxed(val, PLL8_ENET); | ||
1904 | } | ||
1905 | |||
1906 | static struct clk pcie_clk = { | ||
1907 | .enable_reg = CCGR4, | ||
1908 | .enable_shift = CG0, | ||
1909 | .enable = pcie_clk_enable, | ||
1910 | .disable = pcie_clk_disable, | ||
1911 | .set_parent = _clk_set_parent, | ||
1912 | .parent = &axi_clk, | ||
1913 | .secondary = &pll8_enet, | ||
1914 | }; | ||
1915 | |||
1916 | static int sata_clk_enable(struct clk *clk) | ||
1917 | { | ||
1918 | u32 val; | ||
1919 | |||
1920 | val = readl_relaxed(PLL8_ENET); | ||
1921 | val |= BM_PLL_ENET_EN_SATA; | ||
1922 | writel_relaxed(val, PLL8_ENET); | ||
1923 | |||
1924 | return _clk_enable(clk); | ||
1925 | } | ||
1926 | |||
1927 | static void sata_clk_disable(struct clk *clk) | ||
1928 | { | ||
1929 | u32 val; | ||
1930 | |||
1931 | _clk_disable(clk); | ||
1932 | |||
1933 | val = readl_relaxed(PLL8_ENET); | ||
1934 | val &= BM_PLL_ENET_EN_SATA; | ||
1935 | writel_relaxed(val, PLL8_ENET); | ||
1936 | } | ||
1937 | |||
1938 | static struct clk sata_clk = { | ||
1939 | .enable_reg = CCGR5, | ||
1940 | .enable_shift = CG2, | ||
1941 | .enable = sata_clk_enable, | ||
1942 | .disable = sata_clk_disable, | ||
1943 | .parent = &ipg_clk, | ||
1944 | .secondary = &pll8_enet, | ||
1945 | }; | ||
1946 | |||
1947 | #define _REGISTER_CLOCK(d, n, c) \ | ||
1948 | { \ | ||
1949 | .dev_id = d, \ | ||
1950 | .con_id = n, \ | ||
1951 | .clk = &c, \ | ||
1952 | } | ||
1953 | |||
1954 | static struct clk_lookup lookups[] = { | ||
1955 | _REGISTER_CLOCK("2020000.uart", NULL, uart_clk), | ||
1956 | _REGISTER_CLOCK("21e8000.uart", NULL, uart_clk), | ||
1957 | _REGISTER_CLOCK("21ec000.uart", NULL, uart_clk), | ||
1958 | _REGISTER_CLOCK("21f0000.uart", NULL, uart_clk), | ||
1959 | _REGISTER_CLOCK("21f4000.uart", NULL, uart_clk), | ||
1960 | _REGISTER_CLOCK("2188000.enet", NULL, enet_clk), | ||
1961 | _REGISTER_CLOCK("2190000.usdhc", NULL, usdhc1_clk), | ||
1962 | _REGISTER_CLOCK("2194000.usdhc", NULL, usdhc2_clk), | ||
1963 | _REGISTER_CLOCK("2198000.usdhc", NULL, usdhc3_clk), | ||
1964 | _REGISTER_CLOCK("219c000.usdhc", NULL, usdhc4_clk), | ||
1965 | _REGISTER_CLOCK("21a0000.i2c", NULL, i2c1_clk), | ||
1966 | _REGISTER_CLOCK("21a4000.i2c", NULL, i2c2_clk), | ||
1967 | _REGISTER_CLOCK("21a8000.i2c", NULL, i2c3_clk), | ||
1968 | _REGISTER_CLOCK("2008000.ecspi", NULL, ecspi1_clk), | ||
1969 | _REGISTER_CLOCK("200c000.ecspi", NULL, ecspi2_clk), | ||
1970 | _REGISTER_CLOCK("2010000.ecspi", NULL, ecspi3_clk), | ||
1971 | _REGISTER_CLOCK("2014000.ecspi", NULL, ecspi4_clk), | ||
1972 | _REGISTER_CLOCK("2018000.ecspi", NULL, ecspi5_clk), | ||
1973 | _REGISTER_CLOCK("20ec000.sdma", NULL, sdma_clk), | ||
1974 | _REGISTER_CLOCK("20bc000.wdog", NULL, dummy_clk), | ||
1975 | _REGISTER_CLOCK("20c0000.wdog", NULL, dummy_clk), | ||
1976 | _REGISTER_CLOCK("smp_twd", NULL, twd_clk), | ||
1977 | _REGISTER_CLOCK(NULL, "ckih", ckih_clk), | ||
1978 | _REGISTER_CLOCK(NULL, "ckil_clk", ckil_clk), | ||
1979 | _REGISTER_CLOCK(NULL, "aips_tz1_clk", aips_tz1_clk), | ||
1980 | _REGISTER_CLOCK(NULL, "aips_tz2_clk", aips_tz2_clk), | ||
1981 | _REGISTER_CLOCK(NULL, "asrc_clk", asrc_clk), | ||
1982 | _REGISTER_CLOCK(NULL, "can2_clk", can2_clk), | ||
1983 | _REGISTER_CLOCK(NULL, "hdmi_isfr_clk", hdmi_isfr_clk), | ||
1984 | _REGISTER_CLOCK(NULL, "iim_clk", iim_clk), | ||
1985 | _REGISTER_CLOCK(NULL, "mlb_clk", mlb_clk), | ||
1986 | _REGISTER_CLOCK(NULL, "openvg_axi_clk", openvg_axi_clk), | ||
1987 | _REGISTER_CLOCK(NULL, "pwm1_clk", pwm1_clk), | ||
1988 | _REGISTER_CLOCK(NULL, "pwm2_clk", pwm2_clk), | ||
1989 | _REGISTER_CLOCK(NULL, "pwm3_clk", pwm3_clk), | ||
1990 | _REGISTER_CLOCK(NULL, "pwm4_clk", pwm4_clk), | ||
1991 | _REGISTER_CLOCK(NULL, "gpmi_io_clk", gpmi_io_clk), | ||
1992 | _REGISTER_CLOCK(NULL, "usboh3_clk", usboh3_clk), | ||
1993 | _REGISTER_CLOCK(NULL, "sata_clk", sata_clk), | ||
1994 | _REGISTER_CLOCK(NULL, "cko1_clk", cko1_clk), | ||
1995 | }; | ||
1996 | |||
1997 | int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode) | ||
1998 | { | ||
1999 | u32 val = readl_relaxed(CLPCR); | ||
2000 | |||
2001 | val &= ~BM_CLPCR_LPM; | ||
2002 | switch (mode) { | ||
2003 | case WAIT_CLOCKED: | ||
2004 | break; | ||
2005 | case WAIT_UNCLOCKED: | ||
2006 | val |= 0x1 << BP_CLPCR_LPM; | ||
2007 | break; | ||
2008 | case STOP_POWER_ON: | ||
2009 | val |= 0x2 << BP_CLPCR_LPM; | ||
2010 | break; | ||
2011 | case WAIT_UNCLOCKED_POWER_OFF: | ||
2012 | val |= 0x1 << BP_CLPCR_LPM; | ||
2013 | val &= ~BM_CLPCR_VSTBY; | ||
2014 | val &= ~BM_CLPCR_SBYOS; | ||
2015 | break; | ||
2016 | case STOP_POWER_OFF: | ||
2017 | val |= 0x2 << BP_CLPCR_LPM; | ||
2018 | val |= 0x3 << BP_CLPCR_STBY_COUNT; | ||
2019 | val |= BM_CLPCR_VSTBY; | ||
2020 | val |= BM_CLPCR_SBYOS; | ||
2021 | break; | ||
2022 | default: | ||
2023 | return -EINVAL; | ||
2024 | } | ||
2025 | writel_relaxed(val, CLPCR); | ||
2026 | |||
2027 | return 0; | ||
2028 | } | ||
2029 | |||
2030 | static struct map_desc imx6q_clock_desc[] = { | ||
2031 | imx_map_entry(MX6Q, CCM, MT_DEVICE), | ||
2032 | imx_map_entry(MX6Q, ANATOP, MT_DEVICE), | ||
2033 | }; | ||
2034 | |||
2035 | void __init imx6q_clock_map_io(void) | ||
2036 | { | ||
2037 | iotable_init(imx6q_clock_desc, ARRAY_SIZE(imx6q_clock_desc)); | ||
2038 | } | ||
2039 | |||
2040 | int __init mx6q_clocks_init(void) | ||
2041 | { | ||
2042 | struct device_node *np; | ||
2043 | void __iomem *base; | ||
2044 | int i, irq; | ||
2045 | |||
2046 | /* retrieve the freqency of fixed clocks from device tree */ | ||
2047 | for_each_compatible_node(np, NULL, "fixed-clock") { | ||
2048 | u32 rate; | ||
2049 | if (of_property_read_u32(np, "clock-frequency", &rate)) | ||
2050 | continue; | ||
2051 | |||
2052 | if (of_device_is_compatible(np, "fsl,imx-ckil")) | ||
2053 | external_low_reference = rate; | ||
2054 | else if (of_device_is_compatible(np, "fsl,imx-ckih1")) | ||
2055 | external_high_reference = rate; | ||
2056 | else if (of_device_is_compatible(np, "fsl,imx-osc")) | ||
2057 | oscillator_reference = rate; | ||
2058 | } | ||
2059 | |||
2060 | for (i = 0; i < ARRAY_SIZE(lookups); i++) | ||
2061 | clkdev_add(&lookups[i]); | ||
2062 | |||
2063 | /* only keep necessary clocks on */ | ||
2064 | writel_relaxed(0x3 << CG0 | 0x3 << CG1 | 0x3 << CG2, CCGR0); | ||
2065 | writel_relaxed(0x3 << CG8 | 0x3 << CG9 | 0x3 << CG10, CCGR2); | ||
2066 | writel_relaxed(0x3 << CG10 | 0x3 << CG12, CCGR3); | ||
2067 | writel_relaxed(0x3 << CG4 | 0x3 << CG6 | 0x3 << CG7, CCGR4); | ||
2068 | writel_relaxed(0x3 << CG0, CCGR5); | ||
2069 | writel_relaxed(0, CCGR6); | ||
2070 | writel_relaxed(0, CCGR7); | ||
2071 | |||
2072 | clk_enable(&uart_clk); | ||
2073 | clk_enable(&mmdc_ch0_axi_clk); | ||
2074 | |||
2075 | clk_set_rate(&pll4_audio, FREQ_650M); | ||
2076 | clk_set_rate(&pll5_video, FREQ_650M); | ||
2077 | clk_set_parent(&ipu1_di0_clk, &ipu1_di0_pre_clk); | ||
2078 | clk_set_parent(&ipu1_di0_pre_clk, &pll5_video); | ||
2079 | clk_set_parent(&gpu3d_shader_clk, &pll2_pfd_594m); | ||
2080 | clk_set_rate(&gpu3d_shader_clk, FREQ_594M); | ||
2081 | clk_set_parent(&gpu3d_core_clk, &mmdc_ch0_axi_clk); | ||
2082 | clk_set_rate(&gpu3d_core_clk, FREQ_528M); | ||
2083 | clk_set_parent(&asrc_serial_clk, &pll3_usb_otg); | ||
2084 | clk_set_rate(&asrc_serial_clk, 1500000); | ||
2085 | clk_set_rate(&enfc_clk, 11000000); | ||
2086 | |||
2087 | /* | ||
2088 | * Before pinctrl API is available, we have to rely on the pad | ||
2089 | * configuration set up by bootloader. For usdhc example here, | ||
2090 | * u-boot sets up the pads for 49.5 MHz case, and we have to lower | ||
2091 | * the usdhc clock from 198 to 49.5 MHz to match the pad configuration. | ||
2092 | * | ||
2093 | * FIXME: This is should be removed after pinctrl API is available. | ||
2094 | * At that time, usdhc driver can call pinctrl API to change pad | ||
2095 | * configuration dynamically per different usdhc clock settings. | ||
2096 | */ | ||
2097 | clk_set_rate(&usdhc1_clk, 49500000); | ||
2098 | clk_set_rate(&usdhc2_clk, 49500000); | ||
2099 | clk_set_rate(&usdhc3_clk, 49500000); | ||
2100 | clk_set_rate(&usdhc4_clk, 49500000); | ||
2101 | |||
2102 | clk_set_parent(&cko1_clk, &ahb_clk); | ||
2103 | |||
2104 | np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-gpt"); | ||
2105 | base = of_iomap(np, 0); | ||
2106 | WARN_ON(!base); | ||
2107 | irq = irq_of_parse_and_map(np, 0); | ||
2108 | mxc_timer_init(&gpt_clk, base, irq); | ||
2109 | |||
2110 | return 0; | ||
2111 | } | ||
diff --git a/arch/arm/mach-imx/clock-mx51-mx53.c b/arch/arm/mach-imx/clock-mx51-mx53.c deleted file mode 100644 index 08470504a088..000000000000 --- a/arch/arm/mach-imx/clock-mx51-mx53.c +++ /dev/null | |||
@@ -1,1675 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved. | ||
3 | * Copyright (C) 2009-2010 Amit Kucheria <amit.kucheria@canonical.com> | ||
4 | * | ||
5 | * The code contained herein is licensed under the GNU General Public | ||
6 | * License. You may obtain a copy of the GNU General Public License | ||
7 | * Version 2 or later at the following locations: | ||
8 | * | ||
9 | * http://www.opensource.org/licenses/gpl-license.html | ||
10 | * http://www.gnu.org/copyleft/gpl.html | ||
11 | */ | ||
12 | |||
13 | #include <linux/mm.h> | ||
14 | #include <linux/delay.h> | ||
15 | #include <linux/clk.h> | ||
16 | #include <linux/io.h> | ||
17 | #include <linux/clkdev.h> | ||
18 | #include <linux/of.h> | ||
19 | |||
20 | #include <asm/div64.h> | ||
21 | |||
22 | #include <mach/hardware.h> | ||
23 | #include <mach/common.h> | ||
24 | #include <mach/clock.h> | ||
25 | |||
26 | #include "crm-regs-imx5.h" | ||
27 | |||
28 | /* External clock values passed-in by the board code */ | ||
29 | static unsigned long external_high_reference, external_low_reference; | ||
30 | static unsigned long oscillator_reference, ckih2_reference; | ||
31 | |||
32 | static struct clk osc_clk; | ||
33 | static struct clk pll1_main_clk; | ||
34 | static struct clk pll1_sw_clk; | ||
35 | static struct clk pll2_sw_clk; | ||
36 | static struct clk pll3_sw_clk; | ||
37 | static struct clk mx53_pll4_sw_clk; | ||
38 | static struct clk lp_apm_clk; | ||
39 | static struct clk periph_apm_clk; | ||
40 | static struct clk ahb_clk; | ||
41 | static struct clk ipg_clk; | ||
42 | static struct clk usboh3_clk; | ||
43 | static struct clk emi_fast_clk; | ||
44 | static struct clk ipu_clk; | ||
45 | static struct clk mipi_hsc1_clk; | ||
46 | static struct clk esdhc1_clk; | ||
47 | static struct clk esdhc2_clk; | ||
48 | static struct clk esdhc3_mx53_clk; | ||
49 | |||
50 | #define MAX_DPLL_WAIT_TRIES 1000 /* 1000 * udelay(1) = 1ms */ | ||
51 | |||
52 | /* calculate best pre and post dividers to get the required divider */ | ||
53 | static void __calc_pre_post_dividers(u32 div, u32 *pre, u32 *post, | ||
54 | u32 max_pre, u32 max_post) | ||
55 | { | ||
56 | if (div >= max_pre * max_post) { | ||
57 | *pre = max_pre; | ||
58 | *post = max_post; | ||
59 | } else if (div >= max_pre) { | ||
60 | u32 min_pre, temp_pre, old_err, err; | ||
61 | min_pre = DIV_ROUND_UP(div, max_post); | ||
62 | old_err = max_pre; | ||
63 | for (temp_pre = max_pre; temp_pre >= min_pre; temp_pre--) { | ||
64 | err = div % temp_pre; | ||
65 | if (err == 0) { | ||
66 | *pre = temp_pre; | ||
67 | break; | ||
68 | } | ||
69 | err = temp_pre - err; | ||
70 | if (err < old_err) { | ||
71 | old_err = err; | ||
72 | *pre = temp_pre; | ||
73 | } | ||
74 | } | ||
75 | *post = DIV_ROUND_UP(div, *pre); | ||
76 | } else { | ||
77 | *pre = div; | ||
78 | *post = 1; | ||
79 | } | ||
80 | } | ||
81 | |||
82 | static void _clk_ccgr_setclk(struct clk *clk, unsigned mode) | ||
83 | { | ||
84 | u32 reg = __raw_readl(clk->enable_reg); | ||
85 | |||
86 | reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift); | ||
87 | reg |= mode << clk->enable_shift; | ||
88 | |||
89 | __raw_writel(reg, clk->enable_reg); | ||
90 | } | ||
91 | |||
92 | static int _clk_ccgr_enable(struct clk *clk) | ||
93 | { | ||
94 | _clk_ccgr_setclk(clk, MXC_CCM_CCGRx_MOD_ON); | ||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | static void _clk_ccgr_disable(struct clk *clk) | ||
99 | { | ||
100 | _clk_ccgr_setclk(clk, MXC_CCM_CCGRx_MOD_OFF); | ||
101 | } | ||
102 | |||
103 | static int _clk_ccgr_enable_inrun(struct clk *clk) | ||
104 | { | ||
105 | _clk_ccgr_setclk(clk, MXC_CCM_CCGRx_MOD_IDLE); | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | static void _clk_ccgr_disable_inwait(struct clk *clk) | ||
110 | { | ||
111 | _clk_ccgr_setclk(clk, MXC_CCM_CCGRx_MOD_IDLE); | ||
112 | } | ||
113 | |||
114 | /* | ||
115 | * For the 4-to-1 muxed input clock | ||
116 | */ | ||
117 | static inline u32 _get_mux(struct clk *parent, struct clk *m0, | ||
118 | struct clk *m1, struct clk *m2, struct clk *m3) | ||
119 | { | ||
120 | if (parent == m0) | ||
121 | return 0; | ||
122 | else if (parent == m1) | ||
123 | return 1; | ||
124 | else if (parent == m2) | ||
125 | return 2; | ||
126 | else if (parent == m3) | ||
127 | return 3; | ||
128 | else | ||
129 | BUG(); | ||
130 | |||
131 | return -EINVAL; | ||
132 | } | ||
133 | |||
134 | static inline void __iomem *_mx51_get_pll_base(struct clk *pll) | ||
135 | { | ||
136 | if (pll == &pll1_main_clk) | ||
137 | return MX51_DPLL1_BASE; | ||
138 | else if (pll == &pll2_sw_clk) | ||
139 | return MX51_DPLL2_BASE; | ||
140 | else if (pll == &pll3_sw_clk) | ||
141 | return MX51_DPLL3_BASE; | ||
142 | else | ||
143 | BUG(); | ||
144 | |||
145 | return NULL; | ||
146 | } | ||
147 | |||
148 | static inline void __iomem *_mx53_get_pll_base(struct clk *pll) | ||
149 | { | ||
150 | if (pll == &pll1_main_clk) | ||
151 | return MX53_DPLL1_BASE; | ||
152 | else if (pll == &pll2_sw_clk) | ||
153 | return MX53_DPLL2_BASE; | ||
154 | else if (pll == &pll3_sw_clk) | ||
155 | return MX53_DPLL3_BASE; | ||
156 | else if (pll == &mx53_pll4_sw_clk) | ||
157 | return MX53_DPLL4_BASE; | ||
158 | else | ||
159 | BUG(); | ||
160 | |||
161 | return NULL; | ||
162 | } | ||
163 | |||
164 | static inline void __iomem *_get_pll_base(struct clk *pll) | ||
165 | { | ||
166 | if (cpu_is_mx51()) | ||
167 | return _mx51_get_pll_base(pll); | ||
168 | else | ||
169 | return _mx53_get_pll_base(pll); | ||
170 | } | ||
171 | |||
172 | static unsigned long clk_pll_get_rate(struct clk *clk) | ||
173 | { | ||
174 | long mfi, mfn, mfd, pdf, ref_clk, mfn_abs; | ||
175 | unsigned long dp_op, dp_mfd, dp_mfn, dp_ctl, pll_hfsm, dbl; | ||
176 | void __iomem *pllbase; | ||
177 | s64 temp; | ||
178 | unsigned long parent_rate; | ||
179 | |||
180 | parent_rate = clk_get_rate(clk->parent); | ||
181 | |||
182 | pllbase = _get_pll_base(clk); | ||
183 | |||
184 | dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL); | ||
185 | pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM; | ||
186 | dbl = dp_ctl & MXC_PLL_DP_CTL_DPDCK0_2_EN; | ||
187 | |||
188 | if (pll_hfsm == 0) { | ||
189 | dp_op = __raw_readl(pllbase + MXC_PLL_DP_OP); | ||
190 | dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_MFD); | ||
191 | dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_MFN); | ||
192 | } else { | ||
193 | dp_op = __raw_readl(pllbase + MXC_PLL_DP_HFS_OP); | ||
194 | dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFD); | ||
195 | dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFN); | ||
196 | } | ||
197 | pdf = dp_op & MXC_PLL_DP_OP_PDF_MASK; | ||
198 | mfi = (dp_op & MXC_PLL_DP_OP_MFI_MASK) >> MXC_PLL_DP_OP_MFI_OFFSET; | ||
199 | mfi = (mfi <= 5) ? 5 : mfi; | ||
200 | mfd = dp_mfd & MXC_PLL_DP_MFD_MASK; | ||
201 | mfn = mfn_abs = dp_mfn & MXC_PLL_DP_MFN_MASK; | ||
202 | /* Sign extend to 32-bits */ | ||
203 | if (mfn >= 0x04000000) { | ||
204 | mfn |= 0xFC000000; | ||
205 | mfn_abs = -mfn; | ||
206 | } | ||
207 | |||
208 | ref_clk = 2 * parent_rate; | ||
209 | if (dbl != 0) | ||
210 | ref_clk *= 2; | ||
211 | |||
212 | ref_clk /= (pdf + 1); | ||
213 | temp = (u64) ref_clk * mfn_abs; | ||
214 | do_div(temp, mfd + 1); | ||
215 | if (mfn < 0) | ||
216 | temp = -temp; | ||
217 | temp = (ref_clk * mfi) + temp; | ||
218 | |||
219 | return temp; | ||
220 | } | ||
221 | |||
222 | static int _clk_pll_set_rate(struct clk *clk, unsigned long rate) | ||
223 | { | ||
224 | u32 reg; | ||
225 | void __iomem *pllbase; | ||
226 | |||
227 | long mfi, pdf, mfn, mfd = 999999; | ||
228 | s64 temp64; | ||
229 | unsigned long quad_parent_rate; | ||
230 | unsigned long pll_hfsm, dp_ctl; | ||
231 | unsigned long parent_rate; | ||
232 | |||
233 | parent_rate = clk_get_rate(clk->parent); | ||
234 | |||
235 | pllbase = _get_pll_base(clk); | ||
236 | |||
237 | quad_parent_rate = 4 * parent_rate; | ||
238 | pdf = mfi = -1; | ||
239 | while (++pdf < 16 && mfi < 5) | ||
240 | mfi = rate * (pdf+1) / quad_parent_rate; | ||
241 | if (mfi > 15) | ||
242 | return -EINVAL; | ||
243 | pdf--; | ||
244 | |||
245 | temp64 = rate * (pdf+1) - quad_parent_rate * mfi; | ||
246 | do_div(temp64, quad_parent_rate/1000000); | ||
247 | mfn = (long)temp64; | ||
248 | |||
249 | dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL); | ||
250 | /* use dpdck0_2 */ | ||
251 | __raw_writel(dp_ctl | 0x1000L, pllbase + MXC_PLL_DP_CTL); | ||
252 | pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM; | ||
253 | if (pll_hfsm == 0) { | ||
254 | reg = mfi << 4 | pdf; | ||
255 | __raw_writel(reg, pllbase + MXC_PLL_DP_OP); | ||
256 | __raw_writel(mfd, pllbase + MXC_PLL_DP_MFD); | ||
257 | __raw_writel(mfn, pllbase + MXC_PLL_DP_MFN); | ||
258 | } else { | ||
259 | reg = mfi << 4 | pdf; | ||
260 | __raw_writel(reg, pllbase + MXC_PLL_DP_HFS_OP); | ||
261 | __raw_writel(mfd, pllbase + MXC_PLL_DP_HFS_MFD); | ||
262 | __raw_writel(mfn, pllbase + MXC_PLL_DP_HFS_MFN); | ||
263 | } | ||
264 | |||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | static int _clk_pll_enable(struct clk *clk) | ||
269 | { | ||
270 | u32 reg; | ||
271 | void __iomem *pllbase; | ||
272 | int i = 0; | ||
273 | |||
274 | pllbase = _get_pll_base(clk); | ||
275 | reg = __raw_readl(pllbase + MXC_PLL_DP_CTL); | ||
276 | if (reg & MXC_PLL_DP_CTL_UPEN) | ||
277 | return 0; | ||
278 | |||
279 | reg |= MXC_PLL_DP_CTL_UPEN; | ||
280 | __raw_writel(reg, pllbase + MXC_PLL_DP_CTL); | ||
281 | |||
282 | /* Wait for lock */ | ||
283 | do { | ||
284 | reg = __raw_readl(pllbase + MXC_PLL_DP_CTL); | ||
285 | if (reg & MXC_PLL_DP_CTL_LRF) | ||
286 | break; | ||
287 | |||
288 | udelay(1); | ||
289 | } while (++i < MAX_DPLL_WAIT_TRIES); | ||
290 | |||
291 | if (i == MAX_DPLL_WAIT_TRIES) { | ||
292 | pr_err("MX5: pll locking failed\n"); | ||
293 | return -EINVAL; | ||
294 | } | ||
295 | |||
296 | return 0; | ||
297 | } | ||
298 | |||
299 | static void _clk_pll_disable(struct clk *clk) | ||
300 | { | ||
301 | u32 reg; | ||
302 | void __iomem *pllbase; | ||
303 | |||
304 | pllbase = _get_pll_base(clk); | ||
305 | reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) & ~MXC_PLL_DP_CTL_UPEN; | ||
306 | __raw_writel(reg, pllbase + MXC_PLL_DP_CTL); | ||
307 | } | ||
308 | |||
309 | static int _clk_pll1_sw_set_parent(struct clk *clk, struct clk *parent) | ||
310 | { | ||
311 | u32 reg, step; | ||
312 | |||
313 | reg = __raw_readl(MXC_CCM_CCSR); | ||
314 | |||
315 | /* When switching from pll_main_clk to a bypass clock, first select a | ||
316 | * multiplexed clock in 'step_sel', then shift the glitchless mux | ||
317 | * 'pll1_sw_clk_sel'. | ||
318 | * | ||
319 | * When switching back, do it in reverse order | ||
320 | */ | ||
321 | if (parent == &pll1_main_clk) { | ||
322 | /* Switch to pll1_main_clk */ | ||
323 | reg &= ~MXC_CCM_CCSR_PLL1_SW_CLK_SEL; | ||
324 | __raw_writel(reg, MXC_CCM_CCSR); | ||
325 | /* step_clk mux switched to lp_apm, to save power. */ | ||
326 | reg = __raw_readl(MXC_CCM_CCSR); | ||
327 | reg &= ~MXC_CCM_CCSR_STEP_SEL_MASK; | ||
328 | reg |= (MXC_CCM_CCSR_STEP_SEL_LP_APM << | ||
329 | MXC_CCM_CCSR_STEP_SEL_OFFSET); | ||
330 | } else { | ||
331 | if (parent == &lp_apm_clk) { | ||
332 | step = MXC_CCM_CCSR_STEP_SEL_LP_APM; | ||
333 | } else if (parent == &pll2_sw_clk) { | ||
334 | step = MXC_CCM_CCSR_STEP_SEL_PLL2_DIVIDED; | ||
335 | } else if (parent == &pll3_sw_clk) { | ||
336 | step = MXC_CCM_CCSR_STEP_SEL_PLL3_DIVIDED; | ||
337 | } else | ||
338 | return -EINVAL; | ||
339 | |||
340 | reg &= ~MXC_CCM_CCSR_STEP_SEL_MASK; | ||
341 | reg |= (step << MXC_CCM_CCSR_STEP_SEL_OFFSET); | ||
342 | |||
343 | __raw_writel(reg, MXC_CCM_CCSR); | ||
344 | /* Switch to step_clk */ | ||
345 | reg = __raw_readl(MXC_CCM_CCSR); | ||
346 | reg |= MXC_CCM_CCSR_PLL1_SW_CLK_SEL; | ||
347 | } | ||
348 | __raw_writel(reg, MXC_CCM_CCSR); | ||
349 | return 0; | ||
350 | } | ||
351 | |||
352 | static unsigned long clk_pll1_sw_get_rate(struct clk *clk) | ||
353 | { | ||
354 | u32 reg, div; | ||
355 | unsigned long parent_rate; | ||
356 | |||
357 | parent_rate = clk_get_rate(clk->parent); | ||
358 | |||
359 | reg = __raw_readl(MXC_CCM_CCSR); | ||
360 | |||
361 | if (clk->parent == &pll2_sw_clk) { | ||
362 | div = ((reg & MXC_CCM_CCSR_PLL2_PODF_MASK) >> | ||
363 | MXC_CCM_CCSR_PLL2_PODF_OFFSET) + 1; | ||
364 | } else if (clk->parent == &pll3_sw_clk) { | ||
365 | div = ((reg & MXC_CCM_CCSR_PLL3_PODF_MASK) >> | ||
366 | MXC_CCM_CCSR_PLL3_PODF_OFFSET) + 1; | ||
367 | } else | ||
368 | div = 1; | ||
369 | return parent_rate / div; | ||
370 | } | ||
371 | |||
372 | static int _clk_pll2_sw_set_parent(struct clk *clk, struct clk *parent) | ||
373 | { | ||
374 | u32 reg; | ||
375 | |||
376 | reg = __raw_readl(MXC_CCM_CCSR); | ||
377 | |||
378 | if (parent == &pll2_sw_clk) | ||
379 | reg &= ~MXC_CCM_CCSR_PLL2_SW_CLK_SEL; | ||
380 | else | ||
381 | reg |= MXC_CCM_CCSR_PLL2_SW_CLK_SEL; | ||
382 | |||
383 | __raw_writel(reg, MXC_CCM_CCSR); | ||
384 | return 0; | ||
385 | } | ||
386 | |||
387 | static int _clk_lp_apm_set_parent(struct clk *clk, struct clk *parent) | ||
388 | { | ||
389 | u32 reg; | ||
390 | |||
391 | if (parent == &osc_clk) | ||
392 | reg = __raw_readl(MXC_CCM_CCSR) & ~MXC_CCM_CCSR_LP_APM_SEL; | ||
393 | else | ||
394 | return -EINVAL; | ||
395 | |||
396 | __raw_writel(reg, MXC_CCM_CCSR); | ||
397 | |||
398 | return 0; | ||
399 | } | ||
400 | |||
401 | static unsigned long clk_cpu_get_rate(struct clk *clk) | ||
402 | { | ||
403 | u32 cacrr, div; | ||
404 | unsigned long parent_rate; | ||
405 | |||
406 | parent_rate = clk_get_rate(clk->parent); | ||
407 | cacrr = __raw_readl(MXC_CCM_CACRR); | ||
408 | div = (cacrr & MXC_CCM_CACRR_ARM_PODF_MASK) + 1; | ||
409 | |||
410 | return parent_rate / div; | ||
411 | } | ||
412 | |||
413 | static int clk_cpu_set_rate(struct clk *clk, unsigned long rate) | ||
414 | { | ||
415 | u32 reg, cpu_podf; | ||
416 | unsigned long parent_rate; | ||
417 | |||
418 | parent_rate = clk_get_rate(clk->parent); | ||
419 | cpu_podf = parent_rate / rate - 1; | ||
420 | /* use post divider to change freq */ | ||
421 | reg = __raw_readl(MXC_CCM_CACRR); | ||
422 | reg &= ~MXC_CCM_CACRR_ARM_PODF_MASK; | ||
423 | reg |= cpu_podf << MXC_CCM_CACRR_ARM_PODF_OFFSET; | ||
424 | __raw_writel(reg, MXC_CCM_CACRR); | ||
425 | |||
426 | return 0; | ||
427 | } | ||
428 | |||
429 | static int _clk_periph_apm_set_parent(struct clk *clk, struct clk *parent) | ||
430 | { | ||
431 | u32 reg, mux; | ||
432 | int i = 0; | ||
433 | |||
434 | mux = _get_mux(parent, &pll1_sw_clk, &pll3_sw_clk, &lp_apm_clk, NULL); | ||
435 | |||
436 | reg = __raw_readl(MXC_CCM_CBCMR) & ~MXC_CCM_CBCMR_PERIPH_CLK_SEL_MASK; | ||
437 | reg |= mux << MXC_CCM_CBCMR_PERIPH_CLK_SEL_OFFSET; | ||
438 | __raw_writel(reg, MXC_CCM_CBCMR); | ||
439 | |||
440 | /* Wait for lock */ | ||
441 | do { | ||
442 | reg = __raw_readl(MXC_CCM_CDHIPR); | ||
443 | if (!(reg & MXC_CCM_CDHIPR_PERIPH_CLK_SEL_BUSY)) | ||
444 | break; | ||
445 | |||
446 | udelay(1); | ||
447 | } while (++i < MAX_DPLL_WAIT_TRIES); | ||
448 | |||
449 | if (i == MAX_DPLL_WAIT_TRIES) { | ||
450 | pr_err("MX5: Set parent for periph_apm clock failed\n"); | ||
451 | return -EINVAL; | ||
452 | } | ||
453 | |||
454 | return 0; | ||
455 | } | ||
456 | |||
457 | static int _clk_main_bus_set_parent(struct clk *clk, struct clk *parent) | ||
458 | { | ||
459 | u32 reg; | ||
460 | |||
461 | reg = __raw_readl(MXC_CCM_CBCDR); | ||
462 | |||
463 | if (parent == &pll2_sw_clk) | ||
464 | reg &= ~MXC_CCM_CBCDR_PERIPH_CLK_SEL; | ||
465 | else if (parent == &periph_apm_clk) | ||
466 | reg |= MXC_CCM_CBCDR_PERIPH_CLK_SEL; | ||
467 | else | ||
468 | return -EINVAL; | ||
469 | |||
470 | __raw_writel(reg, MXC_CCM_CBCDR); | ||
471 | |||
472 | return 0; | ||
473 | } | ||
474 | |||
475 | static struct clk main_bus_clk = { | ||
476 | .parent = &pll2_sw_clk, | ||
477 | .set_parent = _clk_main_bus_set_parent, | ||
478 | }; | ||
479 | |||
480 | static unsigned long clk_ahb_get_rate(struct clk *clk) | ||
481 | { | ||
482 | u32 reg, div; | ||
483 | unsigned long parent_rate; | ||
484 | |||
485 | parent_rate = clk_get_rate(clk->parent); | ||
486 | |||
487 | reg = __raw_readl(MXC_CCM_CBCDR); | ||
488 | div = ((reg & MXC_CCM_CBCDR_AHB_PODF_MASK) >> | ||
489 | MXC_CCM_CBCDR_AHB_PODF_OFFSET) + 1; | ||
490 | return parent_rate / div; | ||
491 | } | ||
492 | |||
493 | |||
494 | static int _clk_ahb_set_rate(struct clk *clk, unsigned long rate) | ||
495 | { | ||
496 | u32 reg, div; | ||
497 | unsigned long parent_rate; | ||
498 | int i = 0; | ||
499 | |||
500 | parent_rate = clk_get_rate(clk->parent); | ||
501 | |||
502 | div = parent_rate / rate; | ||
503 | if (div > 8 || div < 1 || ((parent_rate / div) != rate)) | ||
504 | return -EINVAL; | ||
505 | |||
506 | reg = __raw_readl(MXC_CCM_CBCDR); | ||
507 | reg &= ~MXC_CCM_CBCDR_AHB_PODF_MASK; | ||
508 | reg |= (div - 1) << MXC_CCM_CBCDR_AHB_PODF_OFFSET; | ||
509 | __raw_writel(reg, MXC_CCM_CBCDR); | ||
510 | |||
511 | /* Wait for lock */ | ||
512 | do { | ||
513 | reg = __raw_readl(MXC_CCM_CDHIPR); | ||
514 | if (!(reg & MXC_CCM_CDHIPR_AHB_PODF_BUSY)) | ||
515 | break; | ||
516 | |||
517 | udelay(1); | ||
518 | } while (++i < MAX_DPLL_WAIT_TRIES); | ||
519 | |||
520 | if (i == MAX_DPLL_WAIT_TRIES) { | ||
521 | pr_err("MX5: clk_ahb_set_rate failed\n"); | ||
522 | return -EINVAL; | ||
523 | } | ||
524 | |||
525 | return 0; | ||
526 | } | ||
527 | |||
528 | static unsigned long _clk_ahb_round_rate(struct clk *clk, | ||
529 | unsigned long rate) | ||
530 | { | ||
531 | u32 div; | ||
532 | unsigned long parent_rate; | ||
533 | |||
534 | parent_rate = clk_get_rate(clk->parent); | ||
535 | |||
536 | div = parent_rate / rate; | ||
537 | if (div > 8) | ||
538 | div = 8; | ||
539 | else if (div == 0) | ||
540 | div++; | ||
541 | return parent_rate / div; | ||
542 | } | ||
543 | |||
544 | |||
545 | static int _clk_max_enable(struct clk *clk) | ||
546 | { | ||
547 | u32 reg; | ||
548 | |||
549 | _clk_ccgr_enable(clk); | ||
550 | |||
551 | /* Handshake with MAX when LPM is entered. */ | ||
552 | reg = __raw_readl(MXC_CCM_CLPCR); | ||
553 | if (cpu_is_mx51()) | ||
554 | reg &= ~MX51_CCM_CLPCR_BYPASS_MAX_LPM_HS; | ||
555 | else if (cpu_is_mx53()) | ||
556 | reg &= ~MX53_CCM_CLPCR_BYPASS_MAX_LPM_HS; | ||
557 | __raw_writel(reg, MXC_CCM_CLPCR); | ||
558 | |||
559 | return 0; | ||
560 | } | ||
561 | |||
562 | static void _clk_max_disable(struct clk *clk) | ||
563 | { | ||
564 | u32 reg; | ||
565 | |||
566 | _clk_ccgr_disable_inwait(clk); | ||
567 | |||
568 | /* No Handshake with MAX when LPM is entered as its disabled. */ | ||
569 | reg = __raw_readl(MXC_CCM_CLPCR); | ||
570 | if (cpu_is_mx51()) | ||
571 | reg |= MX51_CCM_CLPCR_BYPASS_MAX_LPM_HS; | ||
572 | else if (cpu_is_mx53()) | ||
573 | reg &= ~MX53_CCM_CLPCR_BYPASS_MAX_LPM_HS; | ||
574 | __raw_writel(reg, MXC_CCM_CLPCR); | ||
575 | } | ||
576 | |||
577 | static unsigned long clk_ipg_get_rate(struct clk *clk) | ||
578 | { | ||
579 | u32 reg, div; | ||
580 | unsigned long parent_rate; | ||
581 | |||
582 | parent_rate = clk_get_rate(clk->parent); | ||
583 | |||
584 | reg = __raw_readl(MXC_CCM_CBCDR); | ||
585 | div = ((reg & MXC_CCM_CBCDR_IPG_PODF_MASK) >> | ||
586 | MXC_CCM_CBCDR_IPG_PODF_OFFSET) + 1; | ||
587 | |||
588 | return parent_rate / div; | ||
589 | } | ||
590 | |||
591 | static unsigned long clk_ipg_per_get_rate(struct clk *clk) | ||
592 | { | ||
593 | u32 reg, prediv1, prediv2, podf; | ||
594 | unsigned long parent_rate; | ||
595 | |||
596 | parent_rate = clk_get_rate(clk->parent); | ||
597 | |||
598 | if (clk->parent == &main_bus_clk || clk->parent == &lp_apm_clk) { | ||
599 | /* the main_bus_clk is the one before the DVFS engine */ | ||
600 | reg = __raw_readl(MXC_CCM_CBCDR); | ||
601 | prediv1 = ((reg & MXC_CCM_CBCDR_PERCLK_PRED1_MASK) >> | ||
602 | MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET) + 1; | ||
603 | prediv2 = ((reg & MXC_CCM_CBCDR_PERCLK_PRED2_MASK) >> | ||
604 | MXC_CCM_CBCDR_PERCLK_PRED2_OFFSET) + 1; | ||
605 | podf = ((reg & MXC_CCM_CBCDR_PERCLK_PODF_MASK) >> | ||
606 | MXC_CCM_CBCDR_PERCLK_PODF_OFFSET) + 1; | ||
607 | return parent_rate / (prediv1 * prediv2 * podf); | ||
608 | } else if (clk->parent == &ipg_clk) | ||
609 | return parent_rate; | ||
610 | else | ||
611 | BUG(); | ||
612 | } | ||
613 | |||
614 | static int _clk_ipg_per_set_parent(struct clk *clk, struct clk *parent) | ||
615 | { | ||
616 | u32 reg; | ||
617 | |||
618 | reg = __raw_readl(MXC_CCM_CBCMR); | ||
619 | |||
620 | reg &= ~MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL; | ||
621 | reg &= ~MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL; | ||
622 | |||
623 | if (parent == &ipg_clk) | ||
624 | reg |= MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL; | ||
625 | else if (parent == &lp_apm_clk) | ||
626 | reg |= MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL; | ||
627 | else if (parent != &main_bus_clk) | ||
628 | return -EINVAL; | ||
629 | |||
630 | __raw_writel(reg, MXC_CCM_CBCMR); | ||
631 | |||
632 | return 0; | ||
633 | } | ||
634 | |||
635 | #define clk_nfc_set_parent NULL | ||
636 | |||
637 | static unsigned long clk_nfc_get_rate(struct clk *clk) | ||
638 | { | ||
639 | unsigned long rate; | ||
640 | u32 reg, div; | ||
641 | |||
642 | reg = __raw_readl(MXC_CCM_CBCDR); | ||
643 | div = ((reg & MXC_CCM_CBCDR_NFC_PODF_MASK) >> | ||
644 | MXC_CCM_CBCDR_NFC_PODF_OFFSET) + 1; | ||
645 | rate = clk_get_rate(clk->parent) / div; | ||
646 | WARN_ON(rate == 0); | ||
647 | return rate; | ||
648 | } | ||
649 | |||
650 | static unsigned long clk_nfc_round_rate(struct clk *clk, | ||
651 | unsigned long rate) | ||
652 | { | ||
653 | u32 div; | ||
654 | unsigned long parent_rate = clk_get_rate(clk->parent); | ||
655 | |||
656 | if (!rate) | ||
657 | return -EINVAL; | ||
658 | |||
659 | div = parent_rate / rate; | ||
660 | |||
661 | if (parent_rate % rate) | ||
662 | div++; | ||
663 | |||
664 | if (div > 8) | ||
665 | return -EINVAL; | ||
666 | |||
667 | return parent_rate / div; | ||
668 | |||
669 | } | ||
670 | |||
671 | static int clk_nfc_set_rate(struct clk *clk, unsigned long rate) | ||
672 | { | ||
673 | u32 reg, div; | ||
674 | |||
675 | div = clk_get_rate(clk->parent) / rate; | ||
676 | if (div == 0) | ||
677 | div++; | ||
678 | if (((clk_get_rate(clk->parent) / div) != rate) || (div > 8)) | ||
679 | return -EINVAL; | ||
680 | |||
681 | reg = __raw_readl(MXC_CCM_CBCDR); | ||
682 | reg &= ~MXC_CCM_CBCDR_NFC_PODF_MASK; | ||
683 | reg |= (div - 1) << MXC_CCM_CBCDR_NFC_PODF_OFFSET; | ||
684 | __raw_writel(reg, MXC_CCM_CBCDR); | ||
685 | |||
686 | while (__raw_readl(MXC_CCM_CDHIPR) & | ||
687 | MXC_CCM_CDHIPR_NFC_IPG_INT_MEM_PODF_BUSY){ | ||
688 | } | ||
689 | |||
690 | return 0; | ||
691 | } | ||
692 | |||
693 | static unsigned long get_high_reference_clock_rate(struct clk *clk) | ||
694 | { | ||
695 | return external_high_reference; | ||
696 | } | ||
697 | |||
698 | static unsigned long get_low_reference_clock_rate(struct clk *clk) | ||
699 | { | ||
700 | return external_low_reference; | ||
701 | } | ||
702 | |||
703 | static unsigned long get_oscillator_reference_clock_rate(struct clk *clk) | ||
704 | { | ||
705 | return oscillator_reference; | ||
706 | } | ||
707 | |||
708 | static unsigned long get_ckih2_reference_clock_rate(struct clk *clk) | ||
709 | { | ||
710 | return ckih2_reference; | ||
711 | } | ||
712 | |||
713 | static unsigned long clk_emi_slow_get_rate(struct clk *clk) | ||
714 | { | ||
715 | u32 reg, div; | ||
716 | |||
717 | reg = __raw_readl(MXC_CCM_CBCDR); | ||
718 | div = ((reg & MXC_CCM_CBCDR_EMI_PODF_MASK) >> | ||
719 | MXC_CCM_CBCDR_EMI_PODF_OFFSET) + 1; | ||
720 | |||
721 | return clk_get_rate(clk->parent) / div; | ||
722 | } | ||
723 | |||
724 | static unsigned long _clk_ddr_hf_get_rate(struct clk *clk) | ||
725 | { | ||
726 | unsigned long rate; | ||
727 | u32 reg, div; | ||
728 | |||
729 | reg = __raw_readl(MXC_CCM_CBCDR); | ||
730 | div = ((reg & MXC_CCM_CBCDR_DDR_PODF_MASK) >> | ||
731 | MXC_CCM_CBCDR_DDR_PODF_OFFSET) + 1; | ||
732 | rate = clk_get_rate(clk->parent) / div; | ||
733 | |||
734 | return rate; | ||
735 | } | ||
736 | |||
737 | /* External high frequency clock */ | ||
738 | static struct clk ckih_clk = { | ||
739 | .get_rate = get_high_reference_clock_rate, | ||
740 | }; | ||
741 | |||
742 | static struct clk ckih2_clk = { | ||
743 | .get_rate = get_ckih2_reference_clock_rate, | ||
744 | }; | ||
745 | |||
746 | static struct clk osc_clk = { | ||
747 | .get_rate = get_oscillator_reference_clock_rate, | ||
748 | }; | ||
749 | |||
750 | /* External low frequency (32kHz) clock */ | ||
751 | static struct clk ckil_clk = { | ||
752 | .get_rate = get_low_reference_clock_rate, | ||
753 | }; | ||
754 | |||
755 | static struct clk pll1_main_clk = { | ||
756 | .parent = &osc_clk, | ||
757 | .get_rate = clk_pll_get_rate, | ||
758 | .enable = _clk_pll_enable, | ||
759 | .disable = _clk_pll_disable, | ||
760 | }; | ||
761 | |||
762 | /* Clock tree block diagram (WIP): | ||
763 | * CCM: Clock Controller Module | ||
764 | * | ||
765 | * PLL output -> | | ||
766 | * | CCM Switcher -> CCM_CLK_ROOT_GEN -> | ||
767 | * PLL bypass -> | | ||
768 | * | ||
769 | */ | ||
770 | |||
771 | /* PLL1 SW supplies to ARM core */ | ||
772 | static struct clk pll1_sw_clk = { | ||
773 | .parent = &pll1_main_clk, | ||
774 | .set_parent = _clk_pll1_sw_set_parent, | ||
775 | .get_rate = clk_pll1_sw_get_rate, | ||
776 | }; | ||
777 | |||
778 | /* PLL2 SW supplies to AXI/AHB/IP buses */ | ||
779 | static struct clk pll2_sw_clk = { | ||
780 | .parent = &osc_clk, | ||
781 | .get_rate = clk_pll_get_rate, | ||
782 | .set_rate = _clk_pll_set_rate, | ||
783 | .set_parent = _clk_pll2_sw_set_parent, | ||
784 | .enable = _clk_pll_enable, | ||
785 | .disable = _clk_pll_disable, | ||
786 | }; | ||
787 | |||
788 | /* PLL3 SW supplies to serial clocks like USB, SSI, etc. */ | ||
789 | static struct clk pll3_sw_clk = { | ||
790 | .parent = &osc_clk, | ||
791 | .set_rate = _clk_pll_set_rate, | ||
792 | .get_rate = clk_pll_get_rate, | ||
793 | .enable = _clk_pll_enable, | ||
794 | .disable = _clk_pll_disable, | ||
795 | }; | ||
796 | |||
797 | /* PLL4 SW supplies to LVDS Display Bridge(LDB) */ | ||
798 | static struct clk mx53_pll4_sw_clk = { | ||
799 | .parent = &osc_clk, | ||
800 | .set_rate = _clk_pll_set_rate, | ||
801 | .enable = _clk_pll_enable, | ||
802 | .disable = _clk_pll_disable, | ||
803 | }; | ||
804 | |||
805 | /* Low-power Audio Playback Mode clock */ | ||
806 | static struct clk lp_apm_clk = { | ||
807 | .parent = &osc_clk, | ||
808 | .set_parent = _clk_lp_apm_set_parent, | ||
809 | }; | ||
810 | |||
811 | static struct clk periph_apm_clk = { | ||
812 | .parent = &pll1_sw_clk, | ||
813 | .set_parent = _clk_periph_apm_set_parent, | ||
814 | }; | ||
815 | |||
816 | static struct clk cpu_clk = { | ||
817 | .parent = &pll1_sw_clk, | ||
818 | .get_rate = clk_cpu_get_rate, | ||
819 | .set_rate = clk_cpu_set_rate, | ||
820 | }; | ||
821 | |||
822 | static struct clk ahb_clk = { | ||
823 | .parent = &main_bus_clk, | ||
824 | .get_rate = clk_ahb_get_rate, | ||
825 | .set_rate = _clk_ahb_set_rate, | ||
826 | .round_rate = _clk_ahb_round_rate, | ||
827 | }; | ||
828 | |||
829 | static struct clk iim_clk = { | ||
830 | .parent = &ipg_clk, | ||
831 | .enable_reg = MXC_CCM_CCGR0, | ||
832 | .enable_shift = MXC_CCM_CCGRx_CG15_OFFSET, | ||
833 | }; | ||
834 | |||
835 | /* Main IP interface clock for access to registers */ | ||
836 | static struct clk ipg_clk = { | ||
837 | .parent = &ahb_clk, | ||
838 | .get_rate = clk_ipg_get_rate, | ||
839 | }; | ||
840 | |||
841 | static struct clk ipg_perclk = { | ||
842 | .parent = &lp_apm_clk, | ||
843 | .get_rate = clk_ipg_per_get_rate, | ||
844 | .set_parent = _clk_ipg_per_set_parent, | ||
845 | }; | ||
846 | |||
847 | static struct clk ahb_max_clk = { | ||
848 | .parent = &ahb_clk, | ||
849 | .enable_reg = MXC_CCM_CCGR0, | ||
850 | .enable_shift = MXC_CCM_CCGRx_CG14_OFFSET, | ||
851 | .enable = _clk_max_enable, | ||
852 | .disable = _clk_max_disable, | ||
853 | }; | ||
854 | |||
855 | static struct clk aips_tz1_clk = { | ||
856 | .parent = &ahb_clk, | ||
857 | .secondary = &ahb_max_clk, | ||
858 | .enable_reg = MXC_CCM_CCGR0, | ||
859 | .enable_shift = MXC_CCM_CCGRx_CG12_OFFSET, | ||
860 | .enable = _clk_ccgr_enable, | ||
861 | .disable = _clk_ccgr_disable_inwait, | ||
862 | }; | ||
863 | |||
864 | static struct clk aips_tz2_clk = { | ||
865 | .parent = &ahb_clk, | ||
866 | .secondary = &ahb_max_clk, | ||
867 | .enable_reg = MXC_CCM_CCGR0, | ||
868 | .enable_shift = MXC_CCM_CCGRx_CG13_OFFSET, | ||
869 | .enable = _clk_ccgr_enable, | ||
870 | .disable = _clk_ccgr_disable_inwait, | ||
871 | }; | ||
872 | |||
873 | static struct clk gpc_dvfs_clk = { | ||
874 | .enable_reg = MXC_CCM_CCGR5, | ||
875 | .enable_shift = MXC_CCM_CCGRx_CG12_OFFSET, | ||
876 | .enable = _clk_ccgr_enable, | ||
877 | .disable = _clk_ccgr_disable, | ||
878 | }; | ||
879 | |||
880 | static struct clk gpt_32k_clk = { | ||
881 | .id = 0, | ||
882 | .parent = &ckil_clk, | ||
883 | }; | ||
884 | |||
885 | static struct clk dummy_clk = { | ||
886 | .id = 0, | ||
887 | }; | ||
888 | |||
889 | static struct clk emi_slow_clk = { | ||
890 | .parent = &pll2_sw_clk, | ||
891 | .enable_reg = MXC_CCM_CCGR5, | ||
892 | .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET, | ||
893 | .enable = _clk_ccgr_enable, | ||
894 | .disable = _clk_ccgr_disable_inwait, | ||
895 | .get_rate = clk_emi_slow_get_rate, | ||
896 | }; | ||
897 | |||
898 | static int clk_ipu_enable(struct clk *clk) | ||
899 | { | ||
900 | u32 reg; | ||
901 | |||
902 | _clk_ccgr_enable(clk); | ||
903 | |||
904 | /* Enable handshake with IPU when certain clock rates are changed */ | ||
905 | reg = __raw_readl(MXC_CCM_CCDR); | ||
906 | reg &= ~MXC_CCM_CCDR_IPU_HS_MASK; | ||
907 | __raw_writel(reg, MXC_CCM_CCDR); | ||
908 | |||
909 | /* Enable handshake with IPU when LPM is entered */ | ||
910 | reg = __raw_readl(MXC_CCM_CLPCR); | ||
911 | reg &= ~MXC_CCM_CLPCR_BYPASS_IPU_LPM_HS; | ||
912 | __raw_writel(reg, MXC_CCM_CLPCR); | ||
913 | |||
914 | return 0; | ||
915 | } | ||
916 | |||
917 | static void clk_ipu_disable(struct clk *clk) | ||
918 | { | ||
919 | u32 reg; | ||
920 | |||
921 | _clk_ccgr_disable(clk); | ||
922 | |||
923 | /* Disable handshake with IPU whe dividers are changed */ | ||
924 | reg = __raw_readl(MXC_CCM_CCDR); | ||
925 | reg |= MXC_CCM_CCDR_IPU_HS_MASK; | ||
926 | __raw_writel(reg, MXC_CCM_CCDR); | ||
927 | |||
928 | /* Disable handshake with IPU when LPM is entered */ | ||
929 | reg = __raw_readl(MXC_CCM_CLPCR); | ||
930 | reg |= MXC_CCM_CLPCR_BYPASS_IPU_LPM_HS; | ||
931 | __raw_writel(reg, MXC_CCM_CLPCR); | ||
932 | } | ||
933 | |||
934 | static struct clk ahbmux1_clk = { | ||
935 | .parent = &ahb_clk, | ||
936 | .secondary = &ahb_max_clk, | ||
937 | .enable_reg = MXC_CCM_CCGR0, | ||
938 | .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET, | ||
939 | .enable = _clk_ccgr_enable, | ||
940 | .disable = _clk_ccgr_disable_inwait, | ||
941 | }; | ||
942 | |||
943 | static struct clk ipu_sec_clk = { | ||
944 | .parent = &emi_fast_clk, | ||
945 | .secondary = &ahbmux1_clk, | ||
946 | }; | ||
947 | |||
948 | static struct clk ddr_hf_clk = { | ||
949 | .parent = &pll1_sw_clk, | ||
950 | .get_rate = _clk_ddr_hf_get_rate, | ||
951 | }; | ||
952 | |||
953 | static struct clk ddr_clk = { | ||
954 | .parent = &ddr_hf_clk, | ||
955 | }; | ||
956 | |||
957 | /* clock definitions for MIPI HSC unit which has been removed | ||
958 | * from documentation, but not from hardware | ||
959 | */ | ||
960 | static int _clk_hsc_enable(struct clk *clk) | ||
961 | { | ||
962 | u32 reg; | ||
963 | |||
964 | _clk_ccgr_enable(clk); | ||
965 | /* Handshake with IPU when certain clock rates are changed. */ | ||
966 | reg = __raw_readl(MXC_CCM_CCDR); | ||
967 | reg &= ~MXC_CCM_CCDR_HSC_HS_MASK; | ||
968 | __raw_writel(reg, MXC_CCM_CCDR); | ||
969 | |||
970 | reg = __raw_readl(MXC_CCM_CLPCR); | ||
971 | reg &= ~MXC_CCM_CLPCR_BYPASS_HSC_LPM_HS; | ||
972 | __raw_writel(reg, MXC_CCM_CLPCR); | ||
973 | |||
974 | return 0; | ||
975 | } | ||
976 | |||
977 | static void _clk_hsc_disable(struct clk *clk) | ||
978 | { | ||
979 | u32 reg; | ||
980 | |||
981 | _clk_ccgr_disable(clk); | ||
982 | /* No handshake with HSC as its not enabled. */ | ||
983 | reg = __raw_readl(MXC_CCM_CCDR); | ||
984 | reg |= MXC_CCM_CCDR_HSC_HS_MASK; | ||
985 | __raw_writel(reg, MXC_CCM_CCDR); | ||
986 | |||
987 | reg = __raw_readl(MXC_CCM_CLPCR); | ||
988 | reg |= MXC_CCM_CLPCR_BYPASS_HSC_LPM_HS; | ||
989 | __raw_writel(reg, MXC_CCM_CLPCR); | ||
990 | } | ||
991 | |||
992 | static struct clk mipi_hsp_clk = { | ||
993 | .parent = &ipu_clk, | ||
994 | .enable_reg = MXC_CCM_CCGR4, | ||
995 | .enable_shift = MXC_CCM_CCGRx_CG6_OFFSET, | ||
996 | .enable = _clk_hsc_enable, | ||
997 | .disable = _clk_hsc_disable, | ||
998 | .secondary = &mipi_hsc1_clk, | ||
999 | }; | ||
1000 | |||
1001 | #define DEFINE_CLOCK_CCGR(name, i, er, es, pfx, p, s) \ | ||
1002 | static struct clk name = { \ | ||
1003 | .id = i, \ | ||
1004 | .enable_reg = er, \ | ||
1005 | .enable_shift = es, \ | ||
1006 | .get_rate = pfx##_get_rate, \ | ||
1007 | .set_rate = pfx##_set_rate, \ | ||
1008 | .round_rate = pfx##_round_rate, \ | ||
1009 | .set_parent = pfx##_set_parent, \ | ||
1010 | .enable = _clk_ccgr_enable, \ | ||
1011 | .disable = _clk_ccgr_disable, \ | ||
1012 | .parent = p, \ | ||
1013 | .secondary = s, \ | ||
1014 | } | ||
1015 | |||
1016 | #define DEFINE_CLOCK_MAX(name, i, er, es, pfx, p, s) \ | ||
1017 | static struct clk name = { \ | ||
1018 | .id = i, \ | ||
1019 | .enable_reg = er, \ | ||
1020 | .enable_shift = es, \ | ||
1021 | .get_rate = pfx##_get_rate, \ | ||
1022 | .set_rate = pfx##_set_rate, \ | ||
1023 | .set_parent = pfx##_set_parent, \ | ||
1024 | .enable = _clk_max_enable, \ | ||
1025 | .disable = _clk_max_disable, \ | ||
1026 | .parent = p, \ | ||
1027 | .secondary = s, \ | ||
1028 | } | ||
1029 | |||
1030 | #define CLK_GET_RATE(name, nr, bitsname) \ | ||
1031 | static unsigned long clk_##name##_get_rate(struct clk *clk) \ | ||
1032 | { \ | ||
1033 | u32 reg, pred, podf; \ | ||
1034 | \ | ||
1035 | reg = __raw_readl(MXC_CCM_CSCDR##nr); \ | ||
1036 | pred = (reg & MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_MASK) \ | ||
1037 | >> MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_OFFSET; \ | ||
1038 | podf = (reg & MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_MASK) \ | ||
1039 | >> MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_OFFSET; \ | ||
1040 | \ | ||
1041 | return DIV_ROUND_CLOSEST(clk_get_rate(clk->parent), \ | ||
1042 | (pred + 1) * (podf + 1)); \ | ||
1043 | } | ||
1044 | |||
1045 | #define CLK_SET_PARENT(name, nr, bitsname) \ | ||
1046 | static int clk_##name##_set_parent(struct clk *clk, struct clk *parent) \ | ||
1047 | { \ | ||
1048 | u32 reg, mux; \ | ||
1049 | \ | ||
1050 | mux = _get_mux(parent, &pll1_sw_clk, &pll2_sw_clk, \ | ||
1051 | &pll3_sw_clk, &lp_apm_clk); \ | ||
1052 | reg = __raw_readl(MXC_CCM_CSCMR##nr) & \ | ||
1053 | ~MXC_CCM_CSCMR##nr##_##bitsname##_CLK_SEL_MASK; \ | ||
1054 | reg |= mux << MXC_CCM_CSCMR##nr##_##bitsname##_CLK_SEL_OFFSET; \ | ||
1055 | __raw_writel(reg, MXC_CCM_CSCMR##nr); \ | ||
1056 | \ | ||
1057 | return 0; \ | ||
1058 | } | ||
1059 | |||
1060 | #define CLK_SET_RATE(name, nr, bitsname) \ | ||
1061 | static int clk_##name##_set_rate(struct clk *clk, unsigned long rate) \ | ||
1062 | { \ | ||
1063 | u32 reg, div, parent_rate; \ | ||
1064 | u32 pre = 0, post = 0; \ | ||
1065 | \ | ||
1066 | parent_rate = clk_get_rate(clk->parent); \ | ||
1067 | div = parent_rate / rate; \ | ||
1068 | \ | ||
1069 | if ((parent_rate / div) != rate) \ | ||
1070 | return -EINVAL; \ | ||
1071 | \ | ||
1072 | __calc_pre_post_dividers(div, &pre, &post, \ | ||
1073 | (MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_MASK >> \ | ||
1074 | MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_OFFSET) + 1, \ | ||
1075 | (MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_MASK >> \ | ||
1076 | MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_OFFSET) + 1);\ | ||
1077 | \ | ||
1078 | /* Set sdhc1 clock divider */ \ | ||
1079 | reg = __raw_readl(MXC_CCM_CSCDR##nr) & \ | ||
1080 | ~(MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_MASK \ | ||
1081 | | MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_MASK); \ | ||
1082 | reg |= (post - 1) << \ | ||
1083 | MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_OFFSET; \ | ||
1084 | reg |= (pre - 1) << \ | ||
1085 | MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_OFFSET; \ | ||
1086 | __raw_writel(reg, MXC_CCM_CSCDR##nr); \ | ||
1087 | \ | ||
1088 | return 0; \ | ||
1089 | } | ||
1090 | |||
1091 | /* UART */ | ||
1092 | CLK_GET_RATE(uart, 1, UART) | ||
1093 | CLK_SET_PARENT(uart, 1, UART) | ||
1094 | |||
1095 | static struct clk uart_root_clk = { | ||
1096 | .parent = &pll2_sw_clk, | ||
1097 | .get_rate = clk_uart_get_rate, | ||
1098 | .set_parent = clk_uart_set_parent, | ||
1099 | }; | ||
1100 | |||
1101 | /* USBOH3 */ | ||
1102 | CLK_GET_RATE(usboh3, 1, USBOH3) | ||
1103 | CLK_SET_PARENT(usboh3, 1, USBOH3) | ||
1104 | |||
1105 | static struct clk usboh3_clk = { | ||
1106 | .parent = &pll2_sw_clk, | ||
1107 | .get_rate = clk_usboh3_get_rate, | ||
1108 | .set_parent = clk_usboh3_set_parent, | ||
1109 | .enable = _clk_ccgr_enable, | ||
1110 | .disable = _clk_ccgr_disable, | ||
1111 | .enable_reg = MXC_CCM_CCGR2, | ||
1112 | .enable_shift = MXC_CCM_CCGRx_CG14_OFFSET, | ||
1113 | }; | ||
1114 | |||
1115 | static struct clk usb_ahb_clk = { | ||
1116 | .parent = &ipg_clk, | ||
1117 | .enable = _clk_ccgr_enable, | ||
1118 | .disable = _clk_ccgr_disable, | ||
1119 | .enable_reg = MXC_CCM_CCGR2, | ||
1120 | .enable_shift = MXC_CCM_CCGRx_CG13_OFFSET, | ||
1121 | }; | ||
1122 | |||
1123 | static int clk_usb_phy1_set_parent(struct clk *clk, struct clk *parent) | ||
1124 | { | ||
1125 | u32 reg; | ||
1126 | |||
1127 | reg = __raw_readl(MXC_CCM_CSCMR1) & ~MXC_CCM_CSCMR1_USB_PHY_CLK_SEL; | ||
1128 | |||
1129 | if (parent == &pll3_sw_clk) | ||
1130 | reg |= 1 << MXC_CCM_CSCMR1_USB_PHY_CLK_SEL_OFFSET; | ||
1131 | |||
1132 | __raw_writel(reg, MXC_CCM_CSCMR1); | ||
1133 | |||
1134 | return 0; | ||
1135 | } | ||
1136 | |||
1137 | static struct clk usb_phy1_clk = { | ||
1138 | .parent = &pll3_sw_clk, | ||
1139 | .set_parent = clk_usb_phy1_set_parent, | ||
1140 | .enable = _clk_ccgr_enable, | ||
1141 | .enable_reg = MXC_CCM_CCGR2, | ||
1142 | .enable_shift = MXC_CCM_CCGRx_CG0_OFFSET, | ||
1143 | .disable = _clk_ccgr_disable, | ||
1144 | }; | ||
1145 | |||
1146 | /* eCSPI */ | ||
1147 | CLK_GET_RATE(ecspi, 2, CSPI) | ||
1148 | CLK_SET_PARENT(ecspi, 1, CSPI) | ||
1149 | |||
1150 | static struct clk ecspi_main_clk = { | ||
1151 | .parent = &pll3_sw_clk, | ||
1152 | .get_rate = clk_ecspi_get_rate, | ||
1153 | .set_parent = clk_ecspi_set_parent, | ||
1154 | }; | ||
1155 | |||
1156 | /* eSDHC */ | ||
1157 | CLK_GET_RATE(esdhc1, 1, ESDHC1_MSHC1) | ||
1158 | CLK_SET_PARENT(esdhc1, 1, ESDHC1_MSHC1) | ||
1159 | CLK_SET_RATE(esdhc1, 1, ESDHC1_MSHC1) | ||
1160 | |||
1161 | /* mx51 specific */ | ||
1162 | CLK_GET_RATE(esdhc2, 1, ESDHC2_MSHC2) | ||
1163 | CLK_SET_PARENT(esdhc2, 1, ESDHC2_MSHC2) | ||
1164 | CLK_SET_RATE(esdhc2, 1, ESDHC2_MSHC2) | ||
1165 | |||
1166 | static int clk_esdhc3_set_parent(struct clk *clk, struct clk *parent) | ||
1167 | { | ||
1168 | u32 reg; | ||
1169 | |||
1170 | reg = __raw_readl(MXC_CCM_CSCMR1); | ||
1171 | if (parent == &esdhc1_clk) | ||
1172 | reg &= ~MXC_CCM_CSCMR1_ESDHC3_CLK_SEL; | ||
1173 | else if (parent == &esdhc2_clk) | ||
1174 | reg |= MXC_CCM_CSCMR1_ESDHC3_CLK_SEL; | ||
1175 | else | ||
1176 | return -EINVAL; | ||
1177 | __raw_writel(reg, MXC_CCM_CSCMR1); | ||
1178 | |||
1179 | return 0; | ||
1180 | } | ||
1181 | |||
1182 | static int clk_esdhc4_set_parent(struct clk *clk, struct clk *parent) | ||
1183 | { | ||
1184 | u32 reg; | ||
1185 | |||
1186 | reg = __raw_readl(MXC_CCM_CSCMR1); | ||
1187 | if (parent == &esdhc1_clk) | ||
1188 | reg &= ~MXC_CCM_CSCMR1_ESDHC4_CLK_SEL; | ||
1189 | else if (parent == &esdhc2_clk) | ||
1190 | reg |= MXC_CCM_CSCMR1_ESDHC4_CLK_SEL; | ||
1191 | else | ||
1192 | return -EINVAL; | ||
1193 | __raw_writel(reg, MXC_CCM_CSCMR1); | ||
1194 | |||
1195 | return 0; | ||
1196 | } | ||
1197 | |||
1198 | /* mx53 specific */ | ||
1199 | static int clk_esdhc2_mx53_set_parent(struct clk *clk, struct clk *parent) | ||
1200 | { | ||
1201 | u32 reg; | ||
1202 | |||
1203 | reg = __raw_readl(MXC_CCM_CSCMR1); | ||
1204 | if (parent == &esdhc1_clk) | ||
1205 | reg &= ~MXC_CCM_CSCMR1_ESDHC2_MSHC2_MX53_CLK_SEL; | ||
1206 | else if (parent == &esdhc3_mx53_clk) | ||
1207 | reg |= MXC_CCM_CSCMR1_ESDHC2_MSHC2_MX53_CLK_SEL; | ||
1208 | else | ||
1209 | return -EINVAL; | ||
1210 | __raw_writel(reg, MXC_CCM_CSCMR1); | ||
1211 | |||
1212 | return 0; | ||
1213 | } | ||
1214 | |||
1215 | CLK_GET_RATE(esdhc3_mx53, 1, ESDHC3_MX53) | ||
1216 | CLK_SET_PARENT(esdhc3_mx53, 1, ESDHC3_MX53) | ||
1217 | CLK_SET_RATE(esdhc3_mx53, 1, ESDHC3_MX53) | ||
1218 | |||
1219 | static int clk_esdhc4_mx53_set_parent(struct clk *clk, struct clk *parent) | ||
1220 | { | ||
1221 | u32 reg; | ||
1222 | |||
1223 | reg = __raw_readl(MXC_CCM_CSCMR1); | ||
1224 | if (parent == &esdhc1_clk) | ||
1225 | reg &= ~MXC_CCM_CSCMR1_ESDHC4_CLK_SEL; | ||
1226 | else if (parent == &esdhc3_mx53_clk) | ||
1227 | reg |= MXC_CCM_CSCMR1_ESDHC4_CLK_SEL; | ||
1228 | else | ||
1229 | return -EINVAL; | ||
1230 | __raw_writel(reg, MXC_CCM_CSCMR1); | ||
1231 | |||
1232 | return 0; | ||
1233 | } | ||
1234 | |||
1235 | #define DEFINE_CLOCK_FULL(name, i, er, es, gr, sr, e, d, p, s) \ | ||
1236 | static struct clk name = { \ | ||
1237 | .id = i, \ | ||
1238 | .enable_reg = er, \ | ||
1239 | .enable_shift = es, \ | ||
1240 | .get_rate = gr, \ | ||
1241 | .set_rate = sr, \ | ||
1242 | .enable = e, \ | ||
1243 | .disable = d, \ | ||
1244 | .parent = p, \ | ||
1245 | .secondary = s, \ | ||
1246 | } | ||
1247 | |||
1248 | #define DEFINE_CLOCK(name, i, er, es, gr, sr, p, s) \ | ||
1249 | DEFINE_CLOCK_FULL(name, i, er, es, gr, sr, _clk_ccgr_enable, _clk_ccgr_disable, p, s) | ||
1250 | |||
1251 | /* Shared peripheral bus arbiter */ | ||
1252 | DEFINE_CLOCK(spba_clk, 0, MXC_CCM_CCGR5, MXC_CCM_CCGRx_CG0_OFFSET, | ||
1253 | NULL, NULL, &ipg_clk, NULL); | ||
1254 | |||
1255 | /* UART */ | ||
1256 | DEFINE_CLOCK(uart1_ipg_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG3_OFFSET, | ||
1257 | NULL, NULL, &ipg_clk, &aips_tz1_clk); | ||
1258 | DEFINE_CLOCK(uart2_ipg_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG5_OFFSET, | ||
1259 | NULL, NULL, &ipg_clk, &aips_tz1_clk); | ||
1260 | DEFINE_CLOCK(uart3_ipg_clk, 2, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG7_OFFSET, | ||
1261 | NULL, NULL, &ipg_clk, &spba_clk); | ||
1262 | DEFINE_CLOCK(uart4_ipg_clk, 3, MXC_CCM_CCGR7, MXC_CCM_CCGRx_CG4_OFFSET, | ||
1263 | NULL, NULL, &ipg_clk, &spba_clk); | ||
1264 | DEFINE_CLOCK(uart5_ipg_clk, 4, MXC_CCM_CCGR7, MXC_CCM_CCGRx_CG6_OFFSET, | ||
1265 | NULL, NULL, &ipg_clk, &spba_clk); | ||
1266 | DEFINE_CLOCK(uart1_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG4_OFFSET, | ||
1267 | NULL, NULL, &uart_root_clk, &uart1_ipg_clk); | ||
1268 | DEFINE_CLOCK(uart2_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG6_OFFSET, | ||
1269 | NULL, NULL, &uart_root_clk, &uart2_ipg_clk); | ||
1270 | DEFINE_CLOCK(uart3_clk, 2, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG8_OFFSET, | ||
1271 | NULL, NULL, &uart_root_clk, &uart3_ipg_clk); | ||
1272 | DEFINE_CLOCK(uart4_clk, 3, MXC_CCM_CCGR7, MXC_CCM_CCGRx_CG5_OFFSET, | ||
1273 | NULL, NULL, &uart_root_clk, &uart4_ipg_clk); | ||
1274 | DEFINE_CLOCK(uart5_clk, 4, MXC_CCM_CCGR7, MXC_CCM_CCGRx_CG7_OFFSET, | ||
1275 | NULL, NULL, &uart_root_clk, &uart5_ipg_clk); | ||
1276 | |||
1277 | /* GPT */ | ||
1278 | DEFINE_CLOCK(gpt_ipg_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG10_OFFSET, | ||
1279 | NULL, NULL, &ipg_clk, NULL); | ||
1280 | DEFINE_CLOCK(gpt_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG9_OFFSET, | ||
1281 | NULL, NULL, &ipg_clk, &gpt_ipg_clk); | ||
1282 | |||
1283 | DEFINE_CLOCK(pwm1_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG6_OFFSET, | ||
1284 | NULL, NULL, &ipg_perclk, NULL); | ||
1285 | DEFINE_CLOCK(pwm2_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG8_OFFSET, | ||
1286 | NULL, NULL, &ipg_perclk, NULL); | ||
1287 | |||
1288 | /* I2C */ | ||
1289 | DEFINE_CLOCK(i2c1_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG9_OFFSET, | ||
1290 | NULL, NULL, &ipg_perclk, NULL); | ||
1291 | DEFINE_CLOCK(i2c2_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG10_OFFSET, | ||
1292 | NULL, NULL, &ipg_perclk, NULL); | ||
1293 | DEFINE_CLOCK(hsi2c_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG11_OFFSET, | ||
1294 | NULL, NULL, &ipg_clk, NULL); | ||
1295 | DEFINE_CLOCK(i2c3_mx53_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG11_OFFSET, | ||
1296 | NULL, NULL, &ipg_perclk, NULL); | ||
1297 | |||
1298 | /* FEC */ | ||
1299 | DEFINE_CLOCK(fec_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG12_OFFSET, | ||
1300 | NULL, NULL, &ipg_clk, NULL); | ||
1301 | |||
1302 | /* NFC */ | ||
1303 | DEFINE_CLOCK_CCGR(nfc_clk, 0, MXC_CCM_CCGR5, MXC_CCM_CCGRx_CG10_OFFSET, | ||
1304 | clk_nfc, &emi_slow_clk, NULL); | ||
1305 | |||
1306 | /* SSI */ | ||
1307 | DEFINE_CLOCK(ssi1_ipg_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG8_OFFSET, | ||
1308 | NULL, NULL, &ipg_clk, NULL); | ||
1309 | DEFINE_CLOCK(ssi1_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG9_OFFSET, | ||
1310 | NULL, NULL, &pll3_sw_clk, &ssi1_ipg_clk); | ||
1311 | DEFINE_CLOCK(ssi2_ipg_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG10_OFFSET, | ||
1312 | NULL, NULL, &ipg_clk, NULL); | ||
1313 | DEFINE_CLOCK(ssi2_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG11_OFFSET, | ||
1314 | NULL, NULL, &pll3_sw_clk, &ssi2_ipg_clk); | ||
1315 | DEFINE_CLOCK(ssi3_ipg_clk, 2, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG12_OFFSET, | ||
1316 | NULL, NULL, &ipg_clk, NULL); | ||
1317 | DEFINE_CLOCK(ssi3_clk, 2, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG13_OFFSET, | ||
1318 | NULL, NULL, &pll3_sw_clk, &ssi3_ipg_clk); | ||
1319 | |||
1320 | /* eCSPI */ | ||
1321 | DEFINE_CLOCK_FULL(ecspi1_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG9_OFFSET, | ||
1322 | NULL, NULL, _clk_ccgr_enable_inrun, _clk_ccgr_disable, | ||
1323 | &ipg_clk, &spba_clk); | ||
1324 | DEFINE_CLOCK(ecspi1_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG10_OFFSET, | ||
1325 | NULL, NULL, &ecspi_main_clk, &ecspi1_ipg_clk); | ||
1326 | DEFINE_CLOCK_FULL(ecspi2_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG11_OFFSET, | ||
1327 | NULL, NULL, _clk_ccgr_enable_inrun, _clk_ccgr_disable, | ||
1328 | &ipg_clk, &aips_tz2_clk); | ||
1329 | DEFINE_CLOCK(ecspi2_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG12_OFFSET, | ||
1330 | NULL, NULL, &ecspi_main_clk, &ecspi2_ipg_clk); | ||
1331 | |||
1332 | /* CSPI */ | ||
1333 | DEFINE_CLOCK(cspi_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG9_OFFSET, | ||
1334 | NULL, NULL, &ipg_clk, &aips_tz2_clk); | ||
1335 | DEFINE_CLOCK(cspi_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG13_OFFSET, | ||
1336 | NULL, NULL, &ipg_clk, &cspi_ipg_clk); | ||
1337 | |||
1338 | /* SDMA */ | ||
1339 | DEFINE_CLOCK(sdma_clk, 1, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG15_OFFSET, | ||
1340 | NULL, NULL, &ahb_clk, NULL); | ||
1341 | |||
1342 | /* eSDHC */ | ||
1343 | DEFINE_CLOCK_FULL(esdhc1_ipg_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG0_OFFSET, | ||
1344 | NULL, NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL); | ||
1345 | DEFINE_CLOCK_MAX(esdhc1_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG1_OFFSET, | ||
1346 | clk_esdhc1, &pll2_sw_clk, &esdhc1_ipg_clk); | ||
1347 | DEFINE_CLOCK_FULL(esdhc2_ipg_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG2_OFFSET, | ||
1348 | NULL, NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL); | ||
1349 | DEFINE_CLOCK_FULL(esdhc3_ipg_clk, 2, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG4_OFFSET, | ||
1350 | NULL, NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL); | ||
1351 | DEFINE_CLOCK_FULL(esdhc4_ipg_clk, 3, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG6_OFFSET, | ||
1352 | NULL, NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL); | ||
1353 | |||
1354 | /* mx51 specific */ | ||
1355 | DEFINE_CLOCK_MAX(esdhc2_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG3_OFFSET, | ||
1356 | clk_esdhc2, &pll2_sw_clk, &esdhc2_ipg_clk); | ||
1357 | |||
1358 | static struct clk esdhc3_clk = { | ||
1359 | .id = 2, | ||
1360 | .parent = &esdhc1_clk, | ||
1361 | .set_parent = clk_esdhc3_set_parent, | ||
1362 | .enable_reg = MXC_CCM_CCGR3, | ||
1363 | .enable_shift = MXC_CCM_CCGRx_CG5_OFFSET, | ||
1364 | .enable = _clk_max_enable, | ||
1365 | .disable = _clk_max_disable, | ||
1366 | .secondary = &esdhc3_ipg_clk, | ||
1367 | }; | ||
1368 | static struct clk esdhc4_clk = { | ||
1369 | .id = 3, | ||
1370 | .parent = &esdhc1_clk, | ||
1371 | .set_parent = clk_esdhc4_set_parent, | ||
1372 | .enable_reg = MXC_CCM_CCGR3, | ||
1373 | .enable_shift = MXC_CCM_CCGRx_CG7_OFFSET, | ||
1374 | .enable = _clk_max_enable, | ||
1375 | .disable = _clk_max_disable, | ||
1376 | .secondary = &esdhc4_ipg_clk, | ||
1377 | }; | ||
1378 | |||
1379 | /* mx53 specific */ | ||
1380 | static struct clk esdhc2_mx53_clk = { | ||
1381 | .id = 2, | ||
1382 | .parent = &esdhc1_clk, | ||
1383 | .set_parent = clk_esdhc2_mx53_set_parent, | ||
1384 | .enable_reg = MXC_CCM_CCGR3, | ||
1385 | .enable_shift = MXC_CCM_CCGRx_CG3_OFFSET, | ||
1386 | .enable = _clk_max_enable, | ||
1387 | .disable = _clk_max_disable, | ||
1388 | .secondary = &esdhc3_ipg_clk, | ||
1389 | }; | ||
1390 | |||
1391 | DEFINE_CLOCK_MAX(esdhc3_mx53_clk, 2, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG5_OFFSET, | ||
1392 | clk_esdhc3_mx53, &pll2_sw_clk, &esdhc2_ipg_clk); | ||
1393 | |||
1394 | static struct clk esdhc4_mx53_clk = { | ||
1395 | .id = 3, | ||
1396 | .parent = &esdhc1_clk, | ||
1397 | .set_parent = clk_esdhc4_mx53_set_parent, | ||
1398 | .enable_reg = MXC_CCM_CCGR3, | ||
1399 | .enable_shift = MXC_CCM_CCGRx_CG7_OFFSET, | ||
1400 | .enable = _clk_max_enable, | ||
1401 | .disable = _clk_max_disable, | ||
1402 | .secondary = &esdhc4_ipg_clk, | ||
1403 | }; | ||
1404 | |||
1405 | static struct clk sata_clk = { | ||
1406 | .parent = &ipg_clk, | ||
1407 | .enable = _clk_max_enable, | ||
1408 | .enable_reg = MXC_CCM_CCGR4, | ||
1409 | .enable_shift = MXC_CCM_CCGRx_CG1_OFFSET, | ||
1410 | .disable = _clk_max_disable, | ||
1411 | }; | ||
1412 | |||
1413 | static struct clk ahci_phy_clk = { | ||
1414 | .parent = &usb_phy1_clk, | ||
1415 | }; | ||
1416 | |||
1417 | static struct clk ahci_dma_clk = { | ||
1418 | .parent = &ahb_clk, | ||
1419 | }; | ||
1420 | |||
1421 | DEFINE_CLOCK(mipi_esc_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG5_OFFSET, NULL, NULL, NULL, &pll2_sw_clk); | ||
1422 | DEFINE_CLOCK(mipi_hsc2_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG4_OFFSET, NULL, NULL, &mipi_esc_clk, &pll2_sw_clk); | ||
1423 | DEFINE_CLOCK(mipi_hsc1_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG3_OFFSET, NULL, NULL, &mipi_hsc2_clk, &pll2_sw_clk); | ||
1424 | |||
1425 | /* IPU */ | ||
1426 | DEFINE_CLOCK_FULL(ipu_clk, 0, MXC_CCM_CCGR5, MXC_CCM_CCGRx_CG5_OFFSET, | ||
1427 | NULL, NULL, clk_ipu_enable, clk_ipu_disable, &ahb_clk, &ipu_sec_clk); | ||
1428 | |||
1429 | DEFINE_CLOCK_FULL(emi_fast_clk, 0, MXC_CCM_CCGR5, MXC_CCM_CCGRx_CG7_OFFSET, | ||
1430 | NULL, NULL, _clk_ccgr_enable, _clk_ccgr_disable_inwait, | ||
1431 | &ddr_clk, NULL); | ||
1432 | |||
1433 | DEFINE_CLOCK(ipu_di0_clk, 0, MXC_CCM_CCGR6, MXC_CCM_CCGRx_CG5_OFFSET, | ||
1434 | NULL, NULL, &pll3_sw_clk, NULL); | ||
1435 | DEFINE_CLOCK(ipu_di1_clk, 0, MXC_CCM_CCGR6, MXC_CCM_CCGRx_CG6_OFFSET, | ||
1436 | NULL, NULL, &pll3_sw_clk, NULL); | ||
1437 | |||
1438 | /* PATA */ | ||
1439 | DEFINE_CLOCK(pata_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG0_OFFSET, | ||
1440 | NULL, NULL, &ipg_clk, &spba_clk); | ||
1441 | |||
1442 | #define _REGISTER_CLOCK(d, n, c) \ | ||
1443 | { \ | ||
1444 | .dev_id = d, \ | ||
1445 | .con_id = n, \ | ||
1446 | .clk = &c, \ | ||
1447 | }, | ||
1448 | |||
1449 | static struct clk_lookup mx51_lookups[] = { | ||
1450 | /* i.mx51 has the i.mx21 type uart */ | ||
1451 | _REGISTER_CLOCK("imx21-uart.0", NULL, uart1_clk) | ||
1452 | _REGISTER_CLOCK("imx21-uart.1", NULL, uart2_clk) | ||
1453 | _REGISTER_CLOCK("imx21-uart.2", NULL, uart3_clk) | ||
1454 | _REGISTER_CLOCK(NULL, "gpt", gpt_clk) | ||
1455 | /* i.mx51 has the i.mx27 type fec */ | ||
1456 | _REGISTER_CLOCK("imx27-fec.0", NULL, fec_clk) | ||
1457 | _REGISTER_CLOCK("mxc_pwm.0", "pwm", pwm1_clk) | ||
1458 | _REGISTER_CLOCK("mxc_pwm.1", "pwm", pwm2_clk) | ||
1459 | _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk) | ||
1460 | _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk) | ||
1461 | _REGISTER_CLOCK("imx-i2c.2", NULL, hsi2c_clk) | ||
1462 | _REGISTER_CLOCK("mxc-ehci.0", "usb", usboh3_clk) | ||
1463 | _REGISTER_CLOCK("mxc-ehci.0", "usb_ahb", usb_ahb_clk) | ||
1464 | _REGISTER_CLOCK("mxc-ehci.0", "usb_phy1", usb_phy1_clk) | ||
1465 | _REGISTER_CLOCK("mxc-ehci.1", "usb", usboh3_clk) | ||
1466 | _REGISTER_CLOCK("mxc-ehci.1", "usb_ahb", usb_ahb_clk) | ||
1467 | _REGISTER_CLOCK("mxc-ehci.2", "usb", usboh3_clk) | ||
1468 | _REGISTER_CLOCK("mxc-ehci.2", "usb_ahb", usb_ahb_clk) | ||
1469 | _REGISTER_CLOCK("fsl-usb2-udc", "usb", usboh3_clk) | ||
1470 | _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", ahb_clk) | ||
1471 | _REGISTER_CLOCK("imx-keypad", NULL, dummy_clk) | ||
1472 | _REGISTER_CLOCK("mxc_nand", NULL, nfc_clk) | ||
1473 | _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk) | ||
1474 | _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk) | ||
1475 | _REGISTER_CLOCK("imx-ssi.2", NULL, ssi3_clk) | ||
1476 | /* i.mx51 has the i.mx35 type sdma */ | ||
1477 | _REGISTER_CLOCK("imx35-sdma", NULL, sdma_clk) | ||
1478 | _REGISTER_CLOCK(NULL, "ckih", ckih_clk) | ||
1479 | _REGISTER_CLOCK(NULL, "ckih2", ckih2_clk) | ||
1480 | _REGISTER_CLOCK(NULL, "gpt_32k", gpt_32k_clk) | ||
1481 | _REGISTER_CLOCK("imx51-ecspi.0", NULL, ecspi1_clk) | ||
1482 | _REGISTER_CLOCK("imx51-ecspi.1", NULL, ecspi2_clk) | ||
1483 | /* i.mx51 has the i.mx35 type cspi */ | ||
1484 | _REGISTER_CLOCK("imx35-cspi.0", NULL, cspi_clk) | ||
1485 | _REGISTER_CLOCK("sdhci-esdhc-imx51.0", NULL, esdhc1_clk) | ||
1486 | _REGISTER_CLOCK("sdhci-esdhc-imx51.1", NULL, esdhc2_clk) | ||
1487 | _REGISTER_CLOCK("sdhci-esdhc-imx51.2", NULL, esdhc3_clk) | ||
1488 | _REGISTER_CLOCK("sdhci-esdhc-imx51.3", NULL, esdhc4_clk) | ||
1489 | _REGISTER_CLOCK(NULL, "cpu_clk", cpu_clk) | ||
1490 | _REGISTER_CLOCK(NULL, "iim_clk", iim_clk) | ||
1491 | _REGISTER_CLOCK("imx2-wdt.0", NULL, dummy_clk) | ||
1492 | _REGISTER_CLOCK("imx2-wdt.1", NULL, dummy_clk) | ||
1493 | _REGISTER_CLOCK(NULL, "mipi_hsp", mipi_hsp_clk) | ||
1494 | _REGISTER_CLOCK("imx-ipuv3", NULL, ipu_clk) | ||
1495 | _REGISTER_CLOCK("imx-ipuv3", "di0", ipu_di0_clk) | ||
1496 | _REGISTER_CLOCK("imx-ipuv3", "di1", ipu_di1_clk) | ||
1497 | _REGISTER_CLOCK(NULL, "gpc_dvfs", gpc_dvfs_clk) | ||
1498 | _REGISTER_CLOCK("pata_imx", NULL, pata_clk) | ||
1499 | }; | ||
1500 | |||
1501 | static struct clk_lookup mx53_lookups[] = { | ||
1502 | /* i.mx53 has the i.mx21 type uart */ | ||
1503 | _REGISTER_CLOCK("imx21-uart.0", NULL, uart1_clk) | ||
1504 | _REGISTER_CLOCK("imx21-uart.1", NULL, uart2_clk) | ||
1505 | _REGISTER_CLOCK("imx21-uart.2", NULL, uart3_clk) | ||
1506 | _REGISTER_CLOCK("imx21-uart.3", NULL, uart4_clk) | ||
1507 | _REGISTER_CLOCK("imx21-uart.4", NULL, uart5_clk) | ||
1508 | _REGISTER_CLOCK(NULL, "gpt", gpt_clk) | ||
1509 | /* i.mx53 has the i.mx25 type fec */ | ||
1510 | _REGISTER_CLOCK("imx25-fec.0", NULL, fec_clk) | ||
1511 | _REGISTER_CLOCK(NULL, "iim_clk", iim_clk) | ||
1512 | _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk) | ||
1513 | _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk) | ||
1514 | _REGISTER_CLOCK("imx-i2c.2", NULL, i2c3_mx53_clk) | ||
1515 | /* i.mx53 has the i.mx51 type ecspi */ | ||
1516 | _REGISTER_CLOCK("imx51-ecspi.0", NULL, ecspi1_clk) | ||
1517 | _REGISTER_CLOCK("imx51-ecspi.1", NULL, ecspi2_clk) | ||
1518 | /* i.mx53 has the i.mx25 type cspi */ | ||
1519 | _REGISTER_CLOCK("imx35-cspi.0", NULL, cspi_clk) | ||
1520 | _REGISTER_CLOCK("sdhci-esdhc-imx53.0", NULL, esdhc1_clk) | ||
1521 | _REGISTER_CLOCK("sdhci-esdhc-imx53.1", NULL, esdhc2_mx53_clk) | ||
1522 | _REGISTER_CLOCK("sdhci-esdhc-imx53.2", NULL, esdhc3_mx53_clk) | ||
1523 | _REGISTER_CLOCK("sdhci-esdhc-imx53.3", NULL, esdhc4_mx53_clk) | ||
1524 | _REGISTER_CLOCK("imx2-wdt.0", NULL, dummy_clk) | ||
1525 | _REGISTER_CLOCK("imx2-wdt.1", NULL, dummy_clk) | ||
1526 | /* i.mx53 has the i.mx35 type sdma */ | ||
1527 | _REGISTER_CLOCK("imx35-sdma", NULL, sdma_clk) | ||
1528 | _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk) | ||
1529 | _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk) | ||
1530 | _REGISTER_CLOCK("imx-ssi.2", NULL, ssi3_clk) | ||
1531 | _REGISTER_CLOCK("imx-keypad", NULL, dummy_clk) | ||
1532 | _REGISTER_CLOCK("pata_imx", NULL, pata_clk) | ||
1533 | _REGISTER_CLOCK("imx53-ahci.0", "ahci", sata_clk) | ||
1534 | _REGISTER_CLOCK("imx53-ahci.0", "ahci_phy", ahci_phy_clk) | ||
1535 | _REGISTER_CLOCK("imx53-ahci.0", "ahci_dma", ahci_dma_clk) | ||
1536 | }; | ||
1537 | |||
1538 | static void clk_tree_init(void) | ||
1539 | { | ||
1540 | u32 reg; | ||
1541 | |||
1542 | ipg_perclk.set_parent(&ipg_perclk, &lp_apm_clk); | ||
1543 | |||
1544 | /* | ||
1545 | * Initialise the IPG PER CLK dividers to 3. IPG_PER_CLK should be at | ||
1546 | * 8MHz, its derived from lp_apm. | ||
1547 | * | ||
1548 | * FIXME: Verify if true for all boards | ||
1549 | */ | ||
1550 | reg = __raw_readl(MXC_CCM_CBCDR); | ||
1551 | reg &= ~MXC_CCM_CBCDR_PERCLK_PRED1_MASK; | ||
1552 | reg &= ~MXC_CCM_CBCDR_PERCLK_PRED2_MASK; | ||
1553 | reg &= ~MXC_CCM_CBCDR_PERCLK_PODF_MASK; | ||
1554 | reg |= (2 << MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET); | ||
1555 | __raw_writel(reg, MXC_CCM_CBCDR); | ||
1556 | } | ||
1557 | |||
1558 | int __init mx51_clocks_init(unsigned long ckil, unsigned long osc, | ||
1559 | unsigned long ckih1, unsigned long ckih2) | ||
1560 | { | ||
1561 | int i; | ||
1562 | |||
1563 | external_low_reference = ckil; | ||
1564 | external_high_reference = ckih1; | ||
1565 | ckih2_reference = ckih2; | ||
1566 | oscillator_reference = osc; | ||
1567 | |||
1568 | for (i = 0; i < ARRAY_SIZE(mx51_lookups); i++) | ||
1569 | clkdev_add(&mx51_lookups[i]); | ||
1570 | |||
1571 | clk_tree_init(); | ||
1572 | |||
1573 | clk_enable(&cpu_clk); | ||
1574 | clk_enable(&main_bus_clk); | ||
1575 | |||
1576 | clk_enable(&iim_clk); | ||
1577 | imx_print_silicon_rev("i.MX51", mx51_revision()); | ||
1578 | clk_disable(&iim_clk); | ||
1579 | |||
1580 | /* move usb_phy_clk to 24MHz */ | ||
1581 | clk_set_parent(&usb_phy1_clk, &osc_clk); | ||
1582 | |||
1583 | /* set the usboh3_clk parent to pll2_sw_clk */ | ||
1584 | clk_set_parent(&usboh3_clk, &pll2_sw_clk); | ||
1585 | |||
1586 | /* Set SDHC parents to be PLL2 */ | ||
1587 | clk_set_parent(&esdhc1_clk, &pll2_sw_clk); | ||
1588 | clk_set_parent(&esdhc2_clk, &pll2_sw_clk); | ||
1589 | |||
1590 | /* set SDHC root clock as 166.25MHZ*/ | ||
1591 | clk_set_rate(&esdhc1_clk, 166250000); | ||
1592 | clk_set_rate(&esdhc2_clk, 166250000); | ||
1593 | |||
1594 | /* System timer */ | ||
1595 | mxc_timer_init(&gpt_clk, MX51_IO_ADDRESS(MX51_GPT1_BASE_ADDR), | ||
1596 | MX51_INT_GPT); | ||
1597 | return 0; | ||
1598 | } | ||
1599 | |||
1600 | int __init mx53_clocks_init(unsigned long ckil, unsigned long osc, | ||
1601 | unsigned long ckih1, unsigned long ckih2) | ||
1602 | { | ||
1603 | int i; | ||
1604 | |||
1605 | external_low_reference = ckil; | ||
1606 | external_high_reference = ckih1; | ||
1607 | ckih2_reference = ckih2; | ||
1608 | oscillator_reference = osc; | ||
1609 | |||
1610 | for (i = 0; i < ARRAY_SIZE(mx53_lookups); i++) | ||
1611 | clkdev_add(&mx53_lookups[i]); | ||
1612 | |||
1613 | clk_tree_init(); | ||
1614 | |||
1615 | clk_set_parent(&uart_root_clk, &pll3_sw_clk); | ||
1616 | clk_enable(&cpu_clk); | ||
1617 | clk_enable(&main_bus_clk); | ||
1618 | |||
1619 | clk_enable(&iim_clk); | ||
1620 | imx_print_silicon_rev("i.MX53", mx53_revision()); | ||
1621 | clk_disable(&iim_clk); | ||
1622 | |||
1623 | /* Set SDHC parents to be PLL2 */ | ||
1624 | clk_set_parent(&esdhc1_clk, &pll2_sw_clk); | ||
1625 | clk_set_parent(&esdhc3_mx53_clk, &pll2_sw_clk); | ||
1626 | |||
1627 | /* set SDHC root clock as 200MHZ*/ | ||
1628 | clk_set_rate(&esdhc1_clk, 200000000); | ||
1629 | clk_set_rate(&esdhc3_mx53_clk, 200000000); | ||
1630 | |||
1631 | /* System timer */ | ||
1632 | mxc_timer_init(&gpt_clk, MX53_IO_ADDRESS(MX53_GPT1_BASE_ADDR), | ||
1633 | MX53_INT_GPT); | ||
1634 | return 0; | ||
1635 | } | ||
1636 | |||
1637 | #ifdef CONFIG_OF | ||
1638 | static void __init clk_get_freq_dt(unsigned long *ckil, unsigned long *osc, | ||
1639 | unsigned long *ckih1, unsigned long *ckih2) | ||
1640 | { | ||
1641 | struct device_node *np; | ||
1642 | |||
1643 | /* retrieve the freqency of fixed clocks from device tree */ | ||
1644 | for_each_compatible_node(np, NULL, "fixed-clock") { | ||
1645 | u32 rate; | ||
1646 | if (of_property_read_u32(np, "clock-frequency", &rate)) | ||
1647 | continue; | ||
1648 | |||
1649 | if (of_device_is_compatible(np, "fsl,imx-ckil")) | ||
1650 | *ckil = rate; | ||
1651 | else if (of_device_is_compatible(np, "fsl,imx-osc")) | ||
1652 | *osc = rate; | ||
1653 | else if (of_device_is_compatible(np, "fsl,imx-ckih1")) | ||
1654 | *ckih1 = rate; | ||
1655 | else if (of_device_is_compatible(np, "fsl,imx-ckih2")) | ||
1656 | *ckih2 = rate; | ||
1657 | } | ||
1658 | } | ||
1659 | |||
1660 | int __init mx51_clocks_init_dt(void) | ||
1661 | { | ||
1662 | unsigned long ckil, osc, ckih1, ckih2; | ||
1663 | |||
1664 | clk_get_freq_dt(&ckil, &osc, &ckih1, &ckih2); | ||
1665 | return mx51_clocks_init(ckil, osc, ckih1, ckih2); | ||
1666 | } | ||
1667 | |||
1668 | int __init mx53_clocks_init_dt(void) | ||
1669 | { | ||
1670 | unsigned long ckil, osc, ckih1, ckih2; | ||
1671 | |||
1672 | clk_get_freq_dt(&ckil, &osc, &ckih1, &ckih2); | ||
1673 | return mx53_clocks_init(ckil, osc, ckih1, ckih2); | ||
1674 | } | ||
1675 | #endif | ||
diff --git a/arch/arm/mach-imx/crmregs-imx3.h b/arch/arm/mach-imx/crmregs-imx3.h index 53141273df45..a1dfde53e335 100644 --- a/arch/arm/mach-imx/crmregs-imx3.h +++ b/arch/arm/mach-imx/crmregs-imx3.h | |||
@@ -24,48 +24,47 @@ | |||
24 | #define CKIH_CLK_FREQ_27MHZ 27000000 | 24 | #define CKIH_CLK_FREQ_27MHZ 27000000 |
25 | #define CKIL_CLK_FREQ 32768 | 25 | #define CKIL_CLK_FREQ 32768 |
26 | 26 | ||
27 | #define MXC_CCM_BASE (cpu_is_mx31() ? \ | 27 | extern void __iomem *mx3_ccm_base; |
28 | MX31_IO_ADDRESS(MX31_CCM_BASE_ADDR) : MX35_IO_ADDRESS(MX35_CCM_BASE_ADDR)) | ||
29 | 28 | ||
30 | /* Register addresses */ | 29 | /* Register addresses */ |
31 | #define MXC_CCM_CCMR (MXC_CCM_BASE + 0x00) | 30 | #define MXC_CCM_CCMR 0x00 |
32 | #define MXC_CCM_PDR0 (MXC_CCM_BASE + 0x04) | 31 | #define MXC_CCM_PDR0 0x04 |
33 | #define MXC_CCM_PDR1 (MXC_CCM_BASE + 0x08) | 32 | #define MXC_CCM_PDR1 0x08 |
34 | #define MX35_CCM_PDR2 (MXC_CCM_BASE + 0x0C) | 33 | #define MX35_CCM_PDR2 0x0C |
35 | #define MXC_CCM_RCSR (MXC_CCM_BASE + 0x0C) | 34 | #define MXC_CCM_RCSR 0x0C |
36 | #define MX35_CCM_PDR3 (MXC_CCM_BASE + 0x10) | 35 | #define MX35_CCM_PDR3 0x10 |
37 | #define MXC_CCM_MPCTL (MXC_CCM_BASE + 0x10) | 36 | #define MXC_CCM_MPCTL 0x10 |
38 | #define MX35_CCM_PDR4 (MXC_CCM_BASE + 0x14) | 37 | #define MX35_CCM_PDR4 0x14 |
39 | #define MXC_CCM_UPCTL (MXC_CCM_BASE + 0x14) | 38 | #define MXC_CCM_UPCTL 0x14 |
40 | #define MX35_CCM_RCSR (MXC_CCM_BASE + 0x18) | 39 | #define MX35_CCM_RCSR 0x18 |
41 | #define MXC_CCM_SRPCTL (MXC_CCM_BASE + 0x18) | 40 | #define MXC_CCM_SRPCTL 0x18 |
42 | #define MX35_CCM_MPCTL (MXC_CCM_BASE + 0x1C) | 41 | #define MX35_CCM_MPCTL 0x1C |
43 | #define MXC_CCM_COSR (MXC_CCM_BASE + 0x1C) | 42 | #define MXC_CCM_COSR 0x1C |
44 | #define MX35_CCM_PPCTL (MXC_CCM_BASE + 0x20) | 43 | #define MX35_CCM_PPCTL 0x20 |
45 | #define MXC_CCM_CGR0 (MXC_CCM_BASE + 0x20) | 44 | #define MXC_CCM_CGR0 0x20 |
46 | #define MX35_CCM_ACMR (MXC_CCM_BASE + 0x24) | 45 | #define MX35_CCM_ACMR 0x24 |
47 | #define MXC_CCM_CGR1 (MXC_CCM_BASE + 0x24) | 46 | #define MXC_CCM_CGR1 0x24 |
48 | #define MX35_CCM_COSR (MXC_CCM_BASE + 0x28) | 47 | #define MX35_CCM_COSR 0x28 |
49 | #define MXC_CCM_CGR2 (MXC_CCM_BASE + 0x28) | 48 | #define MXC_CCM_CGR2 0x28 |
50 | #define MX35_CCM_CGR0 (MXC_CCM_BASE + 0x2C) | 49 | #define MX35_CCM_CGR0 0x2C |
51 | #define MXC_CCM_WIMR (MXC_CCM_BASE + 0x2C) | 50 | #define MXC_CCM_WIMR 0x2C |
52 | #define MX35_CCM_CGR1 (MXC_CCM_BASE + 0x30) | 51 | #define MX35_CCM_CGR1 0x30 |
53 | #define MXC_CCM_LDC (MXC_CCM_BASE + 0x30) | 52 | #define MXC_CCM_LDC 0x30 |
54 | #define MX35_CCM_CGR2 (MXC_CCM_BASE + 0x34) | 53 | #define MX35_CCM_CGR2 0x34 |
55 | #define MXC_CCM_DCVR0 (MXC_CCM_BASE + 0x34) | 54 | #define MXC_CCM_DCVR0 0x34 |
56 | #define MX35_CCM_CGR3 (MXC_CCM_BASE + 0x38) | 55 | #define MX35_CCM_CGR3 0x38 |
57 | #define MXC_CCM_DCVR1 (MXC_CCM_BASE + 0x38) | 56 | #define MXC_CCM_DCVR1 0x38 |
58 | #define MXC_CCM_DCVR2 (MXC_CCM_BASE + 0x3C) | 57 | #define MXC_CCM_DCVR2 0x3C |
59 | #define MXC_CCM_DCVR3 (MXC_CCM_BASE + 0x40) | 58 | #define MXC_CCM_DCVR3 0x40 |
60 | #define MXC_CCM_LTR0 (MXC_CCM_BASE + 0x44) | 59 | #define MXC_CCM_LTR0 0x44 |
61 | #define MXC_CCM_LTR1 (MXC_CCM_BASE + 0x48) | 60 | #define MXC_CCM_LTR1 0x48 |
62 | #define MXC_CCM_LTR2 (MXC_CCM_BASE + 0x4C) | 61 | #define MXC_CCM_LTR2 0x4C |
63 | #define MXC_CCM_LTR3 (MXC_CCM_BASE + 0x50) | 62 | #define MXC_CCM_LTR3 0x50 |
64 | #define MXC_CCM_LTBR0 (MXC_CCM_BASE + 0x54) | 63 | #define MXC_CCM_LTBR0 0x54 |
65 | #define MXC_CCM_LTBR1 (MXC_CCM_BASE + 0x58) | 64 | #define MXC_CCM_LTBR1 0x58 |
66 | #define MXC_CCM_PMCR0 (MXC_CCM_BASE + 0x5C) | 65 | #define MXC_CCM_PMCR0 0x5C |
67 | #define MXC_CCM_PMCR1 (MXC_CCM_BASE + 0x60) | 66 | #define MXC_CCM_PMCR1 0x60 |
68 | #define MXC_CCM_PDR2 (MXC_CCM_BASE + 0x64) | 67 | #define MXC_CCM_PDR2 0x64 |
69 | 68 | ||
70 | /* Register bit definitions */ | 69 | /* Register bit definitions */ |
71 | #define MXC_CCM_CCMR_WBEN (1 << 27) | 70 | #define MXC_CCM_CCMR_WBEN (1 << 27) |
diff --git a/arch/arm/mach-imx/imx51-dt.c b/arch/arm/mach-imx/imx51-dt.c index 5cca573964f0..5f577fbda2c8 100644 --- a/arch/arm/mach-imx/imx51-dt.c +++ b/arch/arm/mach-imx/imx51-dt.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/irqdomain.h> | 14 | #include <linux/irqdomain.h> |
15 | #include <linux/of_irq.h> | 15 | #include <linux/of_irq.h> |
16 | #include <linux/of_platform.h> | 16 | #include <linux/of_platform.h> |
17 | #include <linux/pinctrl/machine.h> | ||
17 | #include <asm/mach/arch.h> | 18 | #include <asm/mach/arch.h> |
18 | #include <asm/mach/time.h> | 19 | #include <asm/mach/time.h> |
19 | #include <mach/common.h> | 20 | #include <mach/common.h> |
@@ -81,6 +82,8 @@ static void __init imx51_dt_init(void) | |||
81 | 82 | ||
82 | of_irq_init(imx51_irq_match); | 83 | of_irq_init(imx51_irq_match); |
83 | 84 | ||
85 | pinctrl_provide_dummies(); | ||
86 | |||
84 | node = of_find_matching_node(NULL, imx51_iomuxc_of_match); | 87 | node = of_find_matching_node(NULL, imx51_iomuxc_of_match); |
85 | if (node) { | 88 | if (node) { |
86 | of_id = of_match_node(imx51_iomuxc_of_match, node); | 89 | of_id = of_match_node(imx51_iomuxc_of_match, node); |
diff --git a/arch/arm/mach-imx/imx53-dt.c b/arch/arm/mach-imx/imx53-dt.c index 4172279b3900..574eca4b89a5 100644 --- a/arch/arm/mach-imx/imx53-dt.c +++ b/arch/arm/mach-imx/imx53-dt.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/irqdomain.h> | 15 | #include <linux/irqdomain.h> |
16 | #include <linux/of_irq.h> | 16 | #include <linux/of_irq.h> |
17 | #include <linux/of_platform.h> | 17 | #include <linux/of_platform.h> |
18 | #include <linux/pinctrl/machine.h> | ||
18 | #include <asm/mach/arch.h> | 19 | #include <asm/mach/arch.h> |
19 | #include <asm/mach/time.h> | 20 | #include <asm/mach/time.h> |
20 | #include <mach/common.h> | 21 | #include <mach/common.h> |
@@ -88,6 +89,8 @@ static void __init imx53_dt_init(void) | |||
88 | 89 | ||
89 | of_irq_init(imx53_irq_match); | 90 | of_irq_init(imx53_irq_match); |
90 | 91 | ||
92 | pinctrl_provide_dummies(); | ||
93 | |||
91 | node = of_find_matching_node(NULL, imx53_iomuxc_of_match); | 94 | node = of_find_matching_node(NULL, imx53_iomuxc_of_match); |
92 | if (node) { | 95 | if (node) { |
93 | of_id = of_match_node(imx53_iomuxc_of_match, node); | 96 | of_id = of_match_node(imx53_iomuxc_of_match, node); |
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c index da6c1d9af768..3df360a52c17 100644 --- a/arch/arm/mach-imx/mach-imx6q.c +++ b/arch/arm/mach-imx/mach-imx6q.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/of_address.h> | 19 | #include <linux/of_address.h> |
20 | #include <linux/of_irq.h> | 20 | #include <linux/of_irq.h> |
21 | #include <linux/of_platform.h> | 21 | #include <linux/of_platform.h> |
22 | #include <linux/pinctrl/machine.h> | ||
22 | #include <linux/phy.h> | 23 | #include <linux/phy.h> |
23 | #include <linux/micrel_phy.h> | 24 | #include <linux/micrel_phy.h> |
24 | #include <asm/smp_twd.h> | 25 | #include <asm/smp_twd.h> |
@@ -77,6 +78,12 @@ static int ksz9021rn_phy_fixup(struct phy_device *phydev) | |||
77 | 78 | ||
78 | static void __init imx6q_init_machine(void) | 79 | static void __init imx6q_init_machine(void) |
79 | { | 80 | { |
81 | /* | ||
82 | * This should be removed when all imx6q boards have pinctrl | ||
83 | * states for devices defined in device tree. | ||
84 | */ | ||
85 | pinctrl_provide_dummies(); | ||
86 | |||
80 | if (of_machine_is_compatible("fsl,imx6q-sabrelite")) | 87 | if (of_machine_is_compatible("fsl,imx6q-sabrelite")) |
81 | phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK, | 88 | phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK, |
82 | ksz9021rn_phy_fixup); | 89 | ksz9021rn_phy_fixup); |
diff --git a/arch/arm/mach-imx/mm-imx1.c b/arch/arm/mach-imx/mm-imx1.c index 2bded591d5c2..fcafd3dafb8c 100644 --- a/arch/arm/mach-imx/mm-imx1.c +++ b/arch/arm/mach-imx/mm-imx1.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/io.h> | 20 | #include <linux/io.h> |
21 | #include <linux/pinctrl/machine.h> | ||
21 | 22 | ||
22 | #include <asm/mach/map.h> | 23 | #include <asm/mach/map.h> |
23 | 24 | ||
@@ -58,4 +59,5 @@ void __init imx1_soc_init(void) | |||
58 | MX1_GPIO_INT_PORTC, 0); | 59 | MX1_GPIO_INT_PORTC, 0); |
59 | mxc_register_gpio("imx1-gpio", 3, MX1_GPIO4_BASE_ADDR, SZ_256, | 60 | mxc_register_gpio("imx1-gpio", 3, MX1_GPIO4_BASE_ADDR, SZ_256, |
60 | MX1_GPIO_INT_PORTD, 0); | 61 | MX1_GPIO_INT_PORTD, 0); |
62 | pinctrl_provide_dummies(); | ||
61 | } | 63 | } |
diff --git a/arch/arm/mach-imx/mm-imx21.c b/arch/arm/mach-imx/mm-imx21.c index 14d540edfd1e..5f43905e5290 100644 --- a/arch/arm/mach-imx/mm-imx21.c +++ b/arch/arm/mach-imx/mm-imx21.c | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | #include <linux/mm.h> | 21 | #include <linux/mm.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/pinctrl/machine.h> | ||
23 | #include <mach/hardware.h> | 24 | #include <mach/hardware.h> |
24 | #include <mach/common.h> | 25 | #include <mach/common.h> |
25 | #include <mach/devices-common.h> | 26 | #include <mach/devices-common.h> |
@@ -88,6 +89,7 @@ void __init imx21_soc_init(void) | |||
88 | mxc_register_gpio("imx21-gpio", 4, MX21_GPIO5_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); | 89 | mxc_register_gpio("imx21-gpio", 4, MX21_GPIO5_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); |
89 | mxc_register_gpio("imx21-gpio", 5, MX21_GPIO6_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); | 90 | mxc_register_gpio("imx21-gpio", 5, MX21_GPIO6_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); |
90 | 91 | ||
92 | pinctrl_provide_dummies(); | ||
91 | imx_add_imx_dma(); | 93 | imx_add_imx_dma(); |
92 | platform_device_register_simple("imx21-audmux", 0, imx21_audmux_res, | 94 | platform_device_register_simple("imx21-audmux", 0, imx21_audmux_res, |
93 | ARRAY_SIZE(imx21_audmux_res)); | 95 | ARRAY_SIZE(imx21_audmux_res)); |
diff --git a/arch/arm/mach-imx/mm-imx25.c b/arch/arm/mach-imx/mm-imx25.c index 153b457acdc0..6ff37140a4f8 100644 --- a/arch/arm/mach-imx/mm-imx25.c +++ b/arch/arm/mach-imx/mm-imx25.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
22 | #include <linux/pinctrl/machine.h> | ||
22 | 23 | ||
23 | #include <asm/pgtable.h> | 24 | #include <asm/pgtable.h> |
24 | #include <asm/mach/map.h> | 25 | #include <asm/mach/map.h> |
@@ -95,6 +96,7 @@ void __init imx25_soc_init(void) | |||
95 | mxc_register_gpio("imx31-gpio", 2, MX25_GPIO3_BASE_ADDR, SZ_16K, MX25_INT_GPIO3, 0); | 96 | mxc_register_gpio("imx31-gpio", 2, MX25_GPIO3_BASE_ADDR, SZ_16K, MX25_INT_GPIO3, 0); |
96 | mxc_register_gpio("imx31-gpio", 3, MX25_GPIO4_BASE_ADDR, SZ_16K, MX25_INT_GPIO4, 0); | 97 | mxc_register_gpio("imx31-gpio", 3, MX25_GPIO4_BASE_ADDR, SZ_16K, MX25_INT_GPIO4, 0); |
97 | 98 | ||
99 | pinctrl_provide_dummies(); | ||
98 | /* i.mx25 has the i.mx35 type sdma */ | 100 | /* i.mx25 has the i.mx35 type sdma */ |
99 | imx_add_imx_sdma("imx35-sdma", MX25_SDMA_BASE_ADDR, MX25_INT_SDMA, &imx25_sdma_pdata); | 101 | imx_add_imx_sdma("imx35-sdma", MX25_SDMA_BASE_ADDR, MX25_INT_SDMA, &imx25_sdma_pdata); |
100 | /* i.mx25 has the i.mx31 type audmux */ | 102 | /* i.mx25 has the i.mx31 type audmux */ |
diff --git a/arch/arm/mach-imx/mm-imx27.c b/arch/arm/mach-imx/mm-imx27.c index 8cb3f5e3e569..25662558e018 100644 --- a/arch/arm/mach-imx/mm-imx27.c +++ b/arch/arm/mach-imx/mm-imx27.c | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | #include <linux/mm.h> | 21 | #include <linux/mm.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/pinctrl/machine.h> | ||
23 | #include <mach/hardware.h> | 24 | #include <mach/hardware.h> |
24 | #include <mach/common.h> | 25 | #include <mach/common.h> |
25 | #include <mach/devices-common.h> | 26 | #include <mach/devices-common.h> |
@@ -89,6 +90,7 @@ void __init imx27_soc_init(void) | |||
89 | mxc_register_gpio("imx21-gpio", 4, MX27_GPIO5_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); | 90 | mxc_register_gpio("imx21-gpio", 4, MX27_GPIO5_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); |
90 | mxc_register_gpio("imx21-gpio", 5, MX27_GPIO6_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); | 91 | mxc_register_gpio("imx21-gpio", 5, MX27_GPIO6_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); |
91 | 92 | ||
93 | pinctrl_provide_dummies(); | ||
92 | imx_add_imx_dma(); | 94 | imx_add_imx_dma(); |
93 | /* imx27 has the imx21 type audmux */ | 95 | /* imx27 has the imx21 type audmux */ |
94 | platform_device_register_simple("imx21-audmux", 0, imx27_audmux_res, | 96 | platform_device_register_simple("imx21-audmux", 0, imx27_audmux_res, |
diff --git a/arch/arm/mach-imx/mm-imx3.c b/arch/arm/mach-imx/mm-imx3.c index 74127389e7ab..967ed5b35a45 100644 --- a/arch/arm/mach-imx/mm-imx3.c +++ b/arch/arm/mach-imx/mm-imx3.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
22 | #include <linux/pinctrl/machine.h> | ||
22 | 23 | ||
23 | #include <asm/pgtable.h> | 24 | #include <asm/pgtable.h> |
24 | #include <asm/system_misc.h> | 25 | #include <asm/system_misc.h> |
@@ -31,6 +32,10 @@ | |||
31 | #include <mach/iomux-v3.h> | 32 | #include <mach/iomux-v3.h> |
32 | #include <mach/irqs.h> | 33 | #include <mach/irqs.h> |
33 | 34 | ||
35 | #include "crmregs-imx3.h" | ||
36 | |||
37 | void __iomem *mx3_ccm_base; | ||
38 | |||
34 | static void imx3_idle(void) | 39 | static void imx3_idle(void) |
35 | { | 40 | { |
36 | unsigned long reg = 0; | 41 | unsigned long reg = 0; |
@@ -137,6 +142,7 @@ void __init imx31_init_early(void) | |||
137 | mxc_arch_reset_init(MX31_IO_ADDRESS(MX31_WDOG_BASE_ADDR)); | 142 | mxc_arch_reset_init(MX31_IO_ADDRESS(MX31_WDOG_BASE_ADDR)); |
138 | arch_ioremap_caller = imx3_ioremap_caller; | 143 | arch_ioremap_caller = imx3_ioremap_caller; |
139 | arm_pm_idle = imx3_idle; | 144 | arm_pm_idle = imx3_idle; |
145 | mx3_ccm_base = MX31_IO_ADDRESS(MX31_CCM_BASE_ADDR); | ||
140 | } | 146 | } |
141 | 147 | ||
142 | void __init mx31_init_irq(void) | 148 | void __init mx31_init_irq(void) |
@@ -210,6 +216,7 @@ void __init imx35_init_early(void) | |||
210 | mxc_arch_reset_init(MX35_IO_ADDRESS(MX35_WDOG_BASE_ADDR)); | 216 | mxc_arch_reset_init(MX35_IO_ADDRESS(MX35_WDOG_BASE_ADDR)); |
211 | arm_pm_idle = imx3_idle; | 217 | arm_pm_idle = imx3_idle; |
212 | arch_ioremap_caller = imx3_ioremap_caller; | 218 | arch_ioremap_caller = imx3_ioremap_caller; |
219 | mx3_ccm_base = MX35_IO_ADDRESS(MX35_CCM_BASE_ADDR); | ||
213 | } | 220 | } |
214 | 221 | ||
215 | void __init mx35_init_irq(void) | 222 | void __init mx35_init_irq(void) |
@@ -267,6 +274,7 @@ void __init imx35_soc_init(void) | |||
267 | mxc_register_gpio("imx31-gpio", 1, MX35_GPIO2_BASE_ADDR, SZ_16K, MX35_INT_GPIO2, 0); | 274 | mxc_register_gpio("imx31-gpio", 1, MX35_GPIO2_BASE_ADDR, SZ_16K, MX35_INT_GPIO2, 0); |
268 | mxc_register_gpio("imx31-gpio", 2, MX35_GPIO3_BASE_ADDR, SZ_16K, MX35_INT_GPIO3, 0); | 275 | mxc_register_gpio("imx31-gpio", 2, MX35_GPIO3_BASE_ADDR, SZ_16K, MX35_INT_GPIO3, 0); |
269 | 276 | ||
277 | pinctrl_provide_dummies(); | ||
270 | if (to_version == 1) { | 278 | if (to_version == 1) { |
271 | strncpy(imx35_sdma_pdata.fw_name, "sdma-imx35-to1.bin", | 279 | strncpy(imx35_sdma_pdata.fw_name, "sdma-imx35-to1.bin", |
272 | strlen(imx35_sdma_pdata.fw_name)); | 280 | strlen(imx35_sdma_pdata.fw_name)); |
diff --git a/arch/arm/mach-imx/mm-imx5.c b/arch/arm/mach-imx/mm-imx5.c index e10f3914fcfe..8b4dc20c7c53 100644 --- a/arch/arm/mach-imx/mm-imx5.c +++ b/arch/arm/mach-imx/mm-imx5.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/mm.h> | 14 | #include <linux/mm.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/clk.h> | 16 | #include <linux/clk.h> |
17 | #include <linux/pinctrl/machine.h> | ||
17 | 18 | ||
18 | #include <asm/system_misc.h> | 19 | #include <asm/system_misc.h> |
19 | #include <asm/mach/map.h> | 20 | #include <asm/mach/map.h> |
@@ -32,6 +33,7 @@ static void imx5_idle(void) | |||
32 | gpc_dvfs_clk = clk_get(NULL, "gpc_dvfs"); | 33 | gpc_dvfs_clk = clk_get(NULL, "gpc_dvfs"); |
33 | if (IS_ERR(gpc_dvfs_clk)) | 34 | if (IS_ERR(gpc_dvfs_clk)) |
34 | return; | 35 | return; |
36 | clk_prepare(gpc_dvfs_clk); | ||
35 | } | 37 | } |
36 | clk_enable(gpc_dvfs_clk); | 38 | clk_enable(gpc_dvfs_clk); |
37 | mx5_cpu_lp_set(WAIT_UNCLOCKED_POWER_OFF); | 39 | mx5_cpu_lp_set(WAIT_UNCLOCKED_POWER_OFF); |
@@ -223,6 +225,7 @@ void __init imx53_soc_init(void) | |||
223 | mxc_register_gpio("imx31-gpio", 5, MX53_GPIO6_BASE_ADDR, SZ_16K, MX53_INT_GPIO6_LOW, MX53_INT_GPIO6_HIGH); | 225 | mxc_register_gpio("imx31-gpio", 5, MX53_GPIO6_BASE_ADDR, SZ_16K, MX53_INT_GPIO6_LOW, MX53_INT_GPIO6_HIGH); |
224 | mxc_register_gpio("imx31-gpio", 6, MX53_GPIO7_BASE_ADDR, SZ_16K, MX53_INT_GPIO7_LOW, MX53_INT_GPIO7_HIGH); | 226 | mxc_register_gpio("imx31-gpio", 6, MX53_GPIO7_BASE_ADDR, SZ_16K, MX53_INT_GPIO7_LOW, MX53_INT_GPIO7_HIGH); |
225 | 227 | ||
228 | pinctrl_provide_dummies(); | ||
226 | /* i.mx53 has the i.mx35 type sdma */ | 229 | /* i.mx53 has the i.mx35 type sdma */ |
227 | imx_add_imx_sdma("imx35-sdma", MX53_SDMA_BASE_ADDR, MX53_INT_SDMA, &imx53_sdma_pdata); | 230 | imx_add_imx_sdma("imx35-sdma", MX53_SDMA_BASE_ADDR, MX53_INT_SDMA, &imx53_sdma_pdata); |
228 | 231 | ||
diff --git a/arch/arm/mach-imx/pm-imx3.c b/arch/arm/mach-imx/pm-imx3.c index b3752439632e..822103bdb709 100644 --- a/arch/arm/mach-imx/pm-imx3.c +++ b/arch/arm/mach-imx/pm-imx3.c | |||
@@ -21,14 +21,14 @@ | |||
21 | */ | 21 | */ |
22 | void mx3_cpu_lp_set(enum mx3_cpu_pwr_mode mode) | 22 | void mx3_cpu_lp_set(enum mx3_cpu_pwr_mode mode) |
23 | { | 23 | { |
24 | int reg = __raw_readl(MXC_CCM_CCMR); | 24 | int reg = __raw_readl(mx3_ccm_base + MXC_CCM_CCMR); |
25 | reg &= ~MXC_CCM_CCMR_LPM_MASK; | 25 | reg &= ~MXC_CCM_CCMR_LPM_MASK; |
26 | 26 | ||
27 | switch (mode) { | 27 | switch (mode) { |
28 | case MX3_WAIT: | 28 | case MX3_WAIT: |
29 | if (cpu_is_mx35()) | 29 | if (cpu_is_mx35()) |
30 | reg |= MXC_CCM_CCMR_LPM_WAIT_MX35; | 30 | reg |= MXC_CCM_CCMR_LPM_WAIT_MX35; |
31 | __raw_writel(reg, MXC_CCM_CCMR); | 31 | __raw_writel(reg, mx3_ccm_base + MXC_CCM_CCMR); |
32 | break; | 32 | break; |
33 | default: | 33 | default: |
34 | pr_err("Unknown cpu power mode: %d\n", mode); | 34 | pr_err("Unknown cpu power mode: %d\n", mode); |
diff --git a/arch/arm/mach-msm/board-msm8x60.c b/arch/arm/mach-msm/board-msm8x60.c index 962e71169750..fb3496a52ef4 100644 --- a/arch/arm/mach-msm/board-msm8x60.c +++ b/arch/arm/mach-msm/board-msm8x60.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/irqdomain.h> | 17 | #include <linux/irqdomain.h> |
18 | #include <linux/of.h> | 18 | #include <linux/of.h> |
19 | #include <linux/of_address.h> | 19 | #include <linux/of_address.h> |
20 | #include <linux/of_irq.h> | ||
20 | #include <linux/of_platform.h> | 21 | #include <linux/of_platform.h> |
21 | #include <linux/memblock.h> | 22 | #include <linux/memblock.h> |
22 | 23 | ||
@@ -49,10 +50,22 @@ static void __init msm8x60_map_io(void) | |||
49 | msm_map_msm8x60_io(); | 50 | msm_map_msm8x60_io(); |
50 | } | 51 | } |
51 | 52 | ||
53 | #ifdef CONFIG_OF | ||
54 | static struct of_device_id msm_dt_gic_match[] __initdata = { | ||
55 | { .compatible = "qcom,msm-8660-qgic", .data = gic_of_init }, | ||
56 | {} | ||
57 | }; | ||
58 | #endif | ||
59 | |||
52 | static void __init msm8x60_init_irq(void) | 60 | static void __init msm8x60_init_irq(void) |
53 | { | 61 | { |
54 | gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE, | 62 | if (!of_have_populated_dt()) |
55 | (void *)MSM_QGIC_CPU_BASE); | 63 | gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE, |
64 | (void *)MSM_QGIC_CPU_BASE); | ||
65 | #ifdef CONFIG_OF | ||
66 | else | ||
67 | of_irq_init(msm_dt_gic_match); | ||
68 | #endif | ||
56 | 69 | ||
57 | /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */ | 70 | /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */ |
58 | writel(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4); | 71 | writel(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4); |
@@ -73,16 +86,8 @@ static struct of_dev_auxdata msm_auxdata_lookup[] __initdata = { | |||
73 | {} | 86 | {} |
74 | }; | 87 | }; |
75 | 88 | ||
76 | static struct of_device_id msm_dt_gic_match[] __initdata = { | ||
77 | { .compatible = "qcom,msm-8660-qgic", }, | ||
78 | {} | ||
79 | }; | ||
80 | |||
81 | static void __init msm8x60_dt_init(void) | 89 | static void __init msm8x60_dt_init(void) |
82 | { | 90 | { |
83 | irq_domain_generate_simple(msm_dt_gic_match, MSM8X60_QGIC_DIST_PHYS, | ||
84 | GIC_SPI_START); | ||
85 | |||
86 | if (of_machine_is_compatible("qcom,msm8660-surf")) { | 91 | if (of_machine_is_compatible("qcom,msm8660-surf")) { |
87 | printk(KERN_INFO "Init surf UART registers\n"); | 92 | printk(KERN_INFO "Init surf UART registers\n"); |
88 | msm8x60_init_uart12dm(); | 93 | msm8x60_init_uart12dm(); |
diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig index c57f9964a713..07d5383d68ee 100644 --- a/arch/arm/mach-mxs/Kconfig +++ b/arch/arm/mach-mxs/Kconfig | |||
@@ -9,11 +9,13 @@ config SOC_IMX23 | |||
9 | bool | 9 | bool |
10 | select CPU_ARM926T | 10 | select CPU_ARM926T |
11 | select HAVE_PWM | 11 | select HAVE_PWM |
12 | select PINCTRL_IMX23 | ||
12 | 13 | ||
13 | config SOC_IMX28 | 14 | config SOC_IMX28 |
14 | bool | 15 | bool |
15 | select CPU_ARM926T | 16 | select CPU_ARM926T |
16 | select HAVE_PWM | 17 | select HAVE_PWM |
18 | select PINCTRL_IMX28 | ||
17 | 19 | ||
18 | comment "MXS platforms:" | 20 | comment "MXS platforms:" |
19 | 21 | ||
diff --git a/arch/arm/mach-mxs/Makefile b/arch/arm/mach-mxs/Makefile index 908bf9a567f1..6ce21a26412e 100644 --- a/arch/arm/mach-mxs/Makefile +++ b/arch/arm/mach-mxs/Makefile | |||
@@ -1,12 +1,9 @@ | |||
1 | # Common support | 1 | # Common support |
2 | obj-y := clock.o devices.o icoll.o iomux.o system.o timer.o mm.o | 2 | obj-y := devices.o icoll.o iomux.o system.o timer.o mm.o |
3 | 3 | ||
4 | obj-$(CONFIG_MXS_OCOTP) += ocotp.o | 4 | obj-$(CONFIG_MXS_OCOTP) += ocotp.o |
5 | obj-$(CONFIG_PM) += pm.o | 5 | obj-$(CONFIG_PM) += pm.o |
6 | 6 | ||
7 | obj-$(CONFIG_SOC_IMX23) += clock-mx23.o | ||
8 | obj-$(CONFIG_SOC_IMX28) += clock-mx28.o | ||
9 | |||
10 | obj-$(CONFIG_MACH_STMP378X_DEVB) += mach-stmp378x_devb.o | 7 | obj-$(CONFIG_MACH_STMP378X_DEVB) += mach-stmp378x_devb.o |
11 | obj-$(CONFIG_MACH_MX23EVK) += mach-mx23evk.o | 8 | obj-$(CONFIG_MACH_MX23EVK) += mach-mx23evk.o |
12 | obj-$(CONFIG_MACH_MX28EVK) += mach-mx28evk.o | 9 | obj-$(CONFIG_MACH_MX28EVK) += mach-mx28evk.o |
diff --git a/arch/arm/mach-mxs/clock-mx23.c b/arch/arm/mach-mxs/clock-mx23.c deleted file mode 100644 index e3ac52c34019..000000000000 --- a/arch/arm/mach-mxs/clock-mx23.c +++ /dev/null | |||
@@ -1,536 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
17 | */ | ||
18 | |||
19 | #include <linux/mm.h> | ||
20 | #include <linux/delay.h> | ||
21 | #include <linux/clk.h> | ||
22 | #include <linux/io.h> | ||
23 | #include <linux/jiffies.h> | ||
24 | #include <linux/clkdev.h> | ||
25 | |||
26 | #include <asm/clkdev.h> | ||
27 | #include <asm/div64.h> | ||
28 | |||
29 | #include <mach/mx23.h> | ||
30 | #include <mach/common.h> | ||
31 | #include <mach/clock.h> | ||
32 | |||
33 | #include "regs-clkctrl-mx23.h" | ||
34 | |||
35 | #define CLKCTRL_BASE_ADDR MX23_IO_ADDRESS(MX23_CLKCTRL_BASE_ADDR) | ||
36 | #define DIGCTRL_BASE_ADDR MX23_IO_ADDRESS(MX23_DIGCTL_BASE_ADDR) | ||
37 | |||
38 | #define PARENT_RATE_SHIFT 8 | ||
39 | |||
40 | static int _raw_clk_enable(struct clk *clk) | ||
41 | { | ||
42 | u32 reg; | ||
43 | |||
44 | if (clk->enable_reg) { | ||
45 | reg = __raw_readl(clk->enable_reg); | ||
46 | reg &= ~(1 << clk->enable_shift); | ||
47 | __raw_writel(reg, clk->enable_reg); | ||
48 | } | ||
49 | |||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | static void _raw_clk_disable(struct clk *clk) | ||
54 | { | ||
55 | u32 reg; | ||
56 | |||
57 | if (clk->enable_reg) { | ||
58 | reg = __raw_readl(clk->enable_reg); | ||
59 | reg |= 1 << clk->enable_shift; | ||
60 | __raw_writel(reg, clk->enable_reg); | ||
61 | } | ||
62 | } | ||
63 | |||
64 | /* | ||
65 | * ref_xtal_clk | ||
66 | */ | ||
67 | static unsigned long ref_xtal_clk_get_rate(struct clk *clk) | ||
68 | { | ||
69 | return 24000000; | ||
70 | } | ||
71 | |||
72 | static struct clk ref_xtal_clk = { | ||
73 | .get_rate = ref_xtal_clk_get_rate, | ||
74 | }; | ||
75 | |||
76 | /* | ||
77 | * pll_clk | ||
78 | */ | ||
79 | static unsigned long pll_clk_get_rate(struct clk *clk) | ||
80 | { | ||
81 | return 480000000; | ||
82 | } | ||
83 | |||
84 | static int pll_clk_enable(struct clk *clk) | ||
85 | { | ||
86 | __raw_writel(BM_CLKCTRL_PLLCTRL0_POWER | | ||
87 | BM_CLKCTRL_PLLCTRL0_EN_USB_CLKS, | ||
88 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_PLLCTRL0_SET); | ||
89 | |||
90 | /* Only a 10us delay is need. PLLCTRL1 LOCK bitfied is only a timer | ||
91 | * and is incorrect (excessive). Per definition of the PLLCTRL0 | ||
92 | * POWER field, waiting at least 10us. | ||
93 | */ | ||
94 | udelay(10); | ||
95 | |||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | static void pll_clk_disable(struct clk *clk) | ||
100 | { | ||
101 | __raw_writel(BM_CLKCTRL_PLLCTRL0_POWER | | ||
102 | BM_CLKCTRL_PLLCTRL0_EN_USB_CLKS, | ||
103 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_PLLCTRL0_CLR); | ||
104 | } | ||
105 | |||
106 | static struct clk pll_clk = { | ||
107 | .get_rate = pll_clk_get_rate, | ||
108 | .enable = pll_clk_enable, | ||
109 | .disable = pll_clk_disable, | ||
110 | .parent = &ref_xtal_clk, | ||
111 | }; | ||
112 | |||
113 | /* | ||
114 | * ref_clk | ||
115 | */ | ||
116 | #define _CLK_GET_RATE_REF(name, sr, ss) \ | ||
117 | static unsigned long name##_get_rate(struct clk *clk) \ | ||
118 | { \ | ||
119 | unsigned long parent_rate; \ | ||
120 | u32 reg, div; \ | ||
121 | \ | ||
122 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##sr); \ | ||
123 | div = (reg >> BP_CLKCTRL_##sr##_##ss##FRAC) & 0x3f; \ | ||
124 | parent_rate = clk_get_rate(clk->parent); \ | ||
125 | \ | ||
126 | return SH_DIV((parent_rate >> PARENT_RATE_SHIFT) * 18, \ | ||
127 | div, PARENT_RATE_SHIFT); \ | ||
128 | } | ||
129 | |||
130 | _CLK_GET_RATE_REF(ref_cpu_clk, FRAC, CPU) | ||
131 | _CLK_GET_RATE_REF(ref_emi_clk, FRAC, EMI) | ||
132 | _CLK_GET_RATE_REF(ref_pix_clk, FRAC, PIX) | ||
133 | _CLK_GET_RATE_REF(ref_io_clk, FRAC, IO) | ||
134 | |||
135 | #define _DEFINE_CLOCK_REF(name, er, es) \ | ||
136 | static struct clk name = { \ | ||
137 | .enable_reg = CLKCTRL_BASE_ADDR + HW_CLKCTRL_##er, \ | ||
138 | .enable_shift = BP_CLKCTRL_##er##_CLKGATE##es, \ | ||
139 | .get_rate = name##_get_rate, \ | ||
140 | .enable = _raw_clk_enable, \ | ||
141 | .disable = _raw_clk_disable, \ | ||
142 | .parent = &pll_clk, \ | ||
143 | } | ||
144 | |||
145 | _DEFINE_CLOCK_REF(ref_cpu_clk, FRAC, CPU); | ||
146 | _DEFINE_CLOCK_REF(ref_emi_clk, FRAC, EMI); | ||
147 | _DEFINE_CLOCK_REF(ref_pix_clk, FRAC, PIX); | ||
148 | _DEFINE_CLOCK_REF(ref_io_clk, FRAC, IO); | ||
149 | |||
150 | /* | ||
151 | * General clocks | ||
152 | * | ||
153 | * clk_get_rate | ||
154 | */ | ||
155 | static unsigned long rtc_clk_get_rate(struct clk *clk) | ||
156 | { | ||
157 | /* ref_xtal_clk is implemented as the only parent */ | ||
158 | return clk_get_rate(clk->parent) / 768; | ||
159 | } | ||
160 | |||
161 | static unsigned long clk32k_clk_get_rate(struct clk *clk) | ||
162 | { | ||
163 | return clk->parent->get_rate(clk->parent) / 750; | ||
164 | } | ||
165 | |||
166 | #define _CLK_GET_RATE(name, rs) \ | ||
167 | static unsigned long name##_get_rate(struct clk *clk) \ | ||
168 | { \ | ||
169 | u32 reg, div; \ | ||
170 | \ | ||
171 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs); \ | ||
172 | \ | ||
173 | if (clk->parent == &ref_xtal_clk) \ | ||
174 | div = (reg & BM_CLKCTRL_##rs##_DIV_XTAL) >> \ | ||
175 | BP_CLKCTRL_##rs##_DIV_XTAL; \ | ||
176 | else \ | ||
177 | div = (reg & BM_CLKCTRL_##rs##_DIV_##rs) >> \ | ||
178 | BP_CLKCTRL_##rs##_DIV_##rs; \ | ||
179 | \ | ||
180 | if (!div) \ | ||
181 | return -EINVAL; \ | ||
182 | \ | ||
183 | return clk_get_rate(clk->parent) / div; \ | ||
184 | } | ||
185 | |||
186 | _CLK_GET_RATE(cpu_clk, CPU) | ||
187 | _CLK_GET_RATE(emi_clk, EMI) | ||
188 | |||
189 | #define _CLK_GET_RATE1(name, rs) \ | ||
190 | static unsigned long name##_get_rate(struct clk *clk) \ | ||
191 | { \ | ||
192 | u32 reg, div; \ | ||
193 | \ | ||
194 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs); \ | ||
195 | div = (reg & BM_CLKCTRL_##rs##_DIV) >> BP_CLKCTRL_##rs##_DIV; \ | ||
196 | \ | ||
197 | if (!div) \ | ||
198 | return -EINVAL; \ | ||
199 | \ | ||
200 | return clk_get_rate(clk->parent) / div; \ | ||
201 | } | ||
202 | |||
203 | _CLK_GET_RATE1(hbus_clk, HBUS) | ||
204 | _CLK_GET_RATE1(xbus_clk, XBUS) | ||
205 | _CLK_GET_RATE1(ssp_clk, SSP) | ||
206 | _CLK_GET_RATE1(gpmi_clk, GPMI) | ||
207 | _CLK_GET_RATE1(lcdif_clk, PIX) | ||
208 | |||
209 | #define _CLK_GET_RATE_STUB(name) \ | ||
210 | static unsigned long name##_get_rate(struct clk *clk) \ | ||
211 | { \ | ||
212 | return clk_get_rate(clk->parent); \ | ||
213 | } | ||
214 | |||
215 | _CLK_GET_RATE_STUB(uart_clk) | ||
216 | _CLK_GET_RATE_STUB(audio_clk) | ||
217 | _CLK_GET_RATE_STUB(pwm_clk) | ||
218 | |||
219 | /* | ||
220 | * clk_set_rate | ||
221 | */ | ||
222 | static int cpu_clk_set_rate(struct clk *clk, unsigned long rate) | ||
223 | { | ||
224 | u32 reg, bm_busy, div_max, d, f, div, frac; | ||
225 | unsigned long diff, parent_rate, calc_rate; | ||
226 | |||
227 | parent_rate = clk_get_rate(clk->parent); | ||
228 | |||
229 | if (clk->parent == &ref_xtal_clk) { | ||
230 | div_max = BM_CLKCTRL_CPU_DIV_XTAL >> BP_CLKCTRL_CPU_DIV_XTAL; | ||
231 | bm_busy = BM_CLKCTRL_CPU_BUSY_REF_XTAL; | ||
232 | div = DIV_ROUND_UP(parent_rate, rate); | ||
233 | if (div == 0 || div > div_max) | ||
234 | return -EINVAL; | ||
235 | } else { | ||
236 | div_max = BM_CLKCTRL_CPU_DIV_CPU >> BP_CLKCTRL_CPU_DIV_CPU; | ||
237 | bm_busy = BM_CLKCTRL_CPU_BUSY_REF_CPU; | ||
238 | rate >>= PARENT_RATE_SHIFT; | ||
239 | parent_rate >>= PARENT_RATE_SHIFT; | ||
240 | diff = parent_rate; | ||
241 | div = frac = 1; | ||
242 | for (d = 1; d <= div_max; d++) { | ||
243 | f = parent_rate * 18 / d / rate; | ||
244 | if ((parent_rate * 18 / d) % rate) | ||
245 | f++; | ||
246 | if (f < 18 || f > 35) | ||
247 | continue; | ||
248 | |||
249 | calc_rate = parent_rate * 18 / f / d; | ||
250 | if (calc_rate > rate) | ||
251 | continue; | ||
252 | |||
253 | if (rate - calc_rate < diff) { | ||
254 | frac = f; | ||
255 | div = d; | ||
256 | diff = rate - calc_rate; | ||
257 | } | ||
258 | |||
259 | if (diff == 0) | ||
260 | break; | ||
261 | } | ||
262 | |||
263 | if (diff == parent_rate) | ||
264 | return -EINVAL; | ||
265 | |||
266 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC); | ||
267 | reg &= ~BM_CLKCTRL_FRAC_CPUFRAC; | ||
268 | reg |= frac; | ||
269 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC); | ||
270 | } | ||
271 | |||
272 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU); | ||
273 | reg &= ~BM_CLKCTRL_CPU_DIV_CPU; | ||
274 | reg |= div << BP_CLKCTRL_CPU_DIV_CPU; | ||
275 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU); | ||
276 | |||
277 | mxs_clkctrl_timeout(HW_CLKCTRL_CPU, bm_busy); | ||
278 | |||
279 | return 0; | ||
280 | } | ||
281 | |||
282 | #define _CLK_SET_RATE(name, dr) \ | ||
283 | static int name##_set_rate(struct clk *clk, unsigned long rate) \ | ||
284 | { \ | ||
285 | u32 reg, div_max, div; \ | ||
286 | unsigned long parent_rate; \ | ||
287 | \ | ||
288 | parent_rate = clk_get_rate(clk->parent); \ | ||
289 | div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV; \ | ||
290 | \ | ||
291 | div = DIV_ROUND_UP(parent_rate, rate); \ | ||
292 | if (div == 0 || div > div_max) \ | ||
293 | return -EINVAL; \ | ||
294 | \ | ||
295 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr); \ | ||
296 | reg &= ~BM_CLKCTRL_##dr##_DIV; \ | ||
297 | reg |= div << BP_CLKCTRL_##dr##_DIV; \ | ||
298 | if (reg & (1 << clk->enable_shift)) { \ | ||
299 | pr_err("%s: clock is gated\n", __func__); \ | ||
300 | return -EINVAL; \ | ||
301 | } \ | ||
302 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr); \ | ||
303 | \ | ||
304 | mxs_clkctrl_timeout(HW_CLKCTRL_##dr, BM_CLKCTRL_##dr##_BUSY); \ | ||
305 | return 0; \ | ||
306 | } | ||
307 | |||
308 | _CLK_SET_RATE(xbus_clk, XBUS) | ||
309 | _CLK_SET_RATE(ssp_clk, SSP) | ||
310 | _CLK_SET_RATE(gpmi_clk, GPMI) | ||
311 | _CLK_SET_RATE(lcdif_clk, PIX) | ||
312 | |||
313 | #define _CLK_SET_RATE_STUB(name) \ | ||
314 | static int name##_set_rate(struct clk *clk, unsigned long rate) \ | ||
315 | { \ | ||
316 | return -EINVAL; \ | ||
317 | } | ||
318 | |||
319 | _CLK_SET_RATE_STUB(emi_clk) | ||
320 | _CLK_SET_RATE_STUB(uart_clk) | ||
321 | _CLK_SET_RATE_STUB(audio_clk) | ||
322 | _CLK_SET_RATE_STUB(pwm_clk) | ||
323 | _CLK_SET_RATE_STUB(clk32k_clk) | ||
324 | |||
325 | /* | ||
326 | * clk_set_parent | ||
327 | */ | ||
328 | #define _CLK_SET_PARENT(name, bit) \ | ||
329 | static int name##_set_parent(struct clk *clk, struct clk *parent) \ | ||
330 | { \ | ||
331 | if (parent != clk->parent) { \ | ||
332 | __raw_writel(BM_CLKCTRL_CLKSEQ_BYPASS_##bit, \ | ||
333 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_CLKSEQ_TOG); \ | ||
334 | clk->parent = parent; \ | ||
335 | } \ | ||
336 | \ | ||
337 | return 0; \ | ||
338 | } | ||
339 | |||
340 | _CLK_SET_PARENT(cpu_clk, CPU) | ||
341 | _CLK_SET_PARENT(emi_clk, EMI) | ||
342 | _CLK_SET_PARENT(ssp_clk, SSP) | ||
343 | _CLK_SET_PARENT(gpmi_clk, GPMI) | ||
344 | _CLK_SET_PARENT(lcdif_clk, PIX) | ||
345 | |||
346 | #define _CLK_SET_PARENT_STUB(name) \ | ||
347 | static int name##_set_parent(struct clk *clk, struct clk *parent) \ | ||
348 | { \ | ||
349 | if (parent != clk->parent) \ | ||
350 | return -EINVAL; \ | ||
351 | else \ | ||
352 | return 0; \ | ||
353 | } | ||
354 | |||
355 | _CLK_SET_PARENT_STUB(uart_clk) | ||
356 | _CLK_SET_PARENT_STUB(audio_clk) | ||
357 | _CLK_SET_PARENT_STUB(pwm_clk) | ||
358 | _CLK_SET_PARENT_STUB(clk32k_clk) | ||
359 | |||
360 | /* | ||
361 | * clk definition | ||
362 | */ | ||
363 | static struct clk cpu_clk = { | ||
364 | .get_rate = cpu_clk_get_rate, | ||
365 | .set_rate = cpu_clk_set_rate, | ||
366 | .set_parent = cpu_clk_set_parent, | ||
367 | .parent = &ref_cpu_clk, | ||
368 | }; | ||
369 | |||
370 | static struct clk hbus_clk = { | ||
371 | .get_rate = hbus_clk_get_rate, | ||
372 | .parent = &cpu_clk, | ||
373 | }; | ||
374 | |||
375 | static struct clk xbus_clk = { | ||
376 | .get_rate = xbus_clk_get_rate, | ||
377 | .set_rate = xbus_clk_set_rate, | ||
378 | .parent = &ref_xtal_clk, | ||
379 | }; | ||
380 | |||
381 | static struct clk rtc_clk = { | ||
382 | .get_rate = rtc_clk_get_rate, | ||
383 | .parent = &ref_xtal_clk, | ||
384 | }; | ||
385 | |||
386 | /* usb_clk gate is controlled in DIGCTRL other than CLKCTRL */ | ||
387 | static struct clk usb_clk = { | ||
388 | .enable_reg = DIGCTRL_BASE_ADDR, | ||
389 | .enable_shift = 2, | ||
390 | .enable = _raw_clk_enable, | ||
391 | .disable = _raw_clk_disable, | ||
392 | .parent = &pll_clk, | ||
393 | }; | ||
394 | |||
395 | #define _DEFINE_CLOCK(name, er, es, p) \ | ||
396 | static struct clk name = { \ | ||
397 | .enable_reg = CLKCTRL_BASE_ADDR + HW_CLKCTRL_##er, \ | ||
398 | .enable_shift = BP_CLKCTRL_##er##_##es, \ | ||
399 | .get_rate = name##_get_rate, \ | ||
400 | .set_rate = name##_set_rate, \ | ||
401 | .set_parent = name##_set_parent, \ | ||
402 | .enable = _raw_clk_enable, \ | ||
403 | .disable = _raw_clk_disable, \ | ||
404 | .parent = p, \ | ||
405 | } | ||
406 | |||
407 | _DEFINE_CLOCK(emi_clk, EMI, CLKGATE, &ref_xtal_clk); | ||
408 | _DEFINE_CLOCK(ssp_clk, SSP, CLKGATE, &ref_xtal_clk); | ||
409 | _DEFINE_CLOCK(gpmi_clk, GPMI, CLKGATE, &ref_xtal_clk); | ||
410 | _DEFINE_CLOCK(lcdif_clk, PIX, CLKGATE, &ref_xtal_clk); | ||
411 | _DEFINE_CLOCK(uart_clk, XTAL, UART_CLK_GATE, &ref_xtal_clk); | ||
412 | _DEFINE_CLOCK(audio_clk, XTAL, FILT_CLK24M_GATE, &ref_xtal_clk); | ||
413 | _DEFINE_CLOCK(pwm_clk, XTAL, PWM_CLK24M_GATE, &ref_xtal_clk); | ||
414 | _DEFINE_CLOCK(clk32k_clk, XTAL, TIMROT_CLK32K_GATE, &ref_xtal_clk); | ||
415 | |||
416 | #define _REGISTER_CLOCK(d, n, c) \ | ||
417 | { \ | ||
418 | .dev_id = d, \ | ||
419 | .con_id = n, \ | ||
420 | .clk = &c, \ | ||
421 | }, | ||
422 | |||
423 | static struct clk_lookup lookups[] = { | ||
424 | /* for amba bus driver */ | ||
425 | _REGISTER_CLOCK("duart", "apb_pclk", xbus_clk) | ||
426 | /* for amba-pl011 driver */ | ||
427 | _REGISTER_CLOCK("duart", NULL, uart_clk) | ||
428 | _REGISTER_CLOCK("mxs-auart.0", NULL, uart_clk) | ||
429 | _REGISTER_CLOCK("rtc", NULL, rtc_clk) | ||
430 | _REGISTER_CLOCK("mxs-dma-apbh", NULL, hbus_clk) | ||
431 | _REGISTER_CLOCK("mxs-dma-apbx", NULL, xbus_clk) | ||
432 | _REGISTER_CLOCK("mxs-mmc.0", NULL, ssp_clk) | ||
433 | _REGISTER_CLOCK("mxs-mmc.1", NULL, ssp_clk) | ||
434 | _REGISTER_CLOCK(NULL, "usb", usb_clk) | ||
435 | _REGISTER_CLOCK(NULL, "audio", audio_clk) | ||
436 | _REGISTER_CLOCK("mxs-pwm.0", NULL, pwm_clk) | ||
437 | _REGISTER_CLOCK("mxs-pwm.1", NULL, pwm_clk) | ||
438 | _REGISTER_CLOCK("mxs-pwm.2", NULL, pwm_clk) | ||
439 | _REGISTER_CLOCK("mxs-pwm.3", NULL, pwm_clk) | ||
440 | _REGISTER_CLOCK("mxs-pwm.4", NULL, pwm_clk) | ||
441 | _REGISTER_CLOCK("imx23-fb", NULL, lcdif_clk) | ||
442 | _REGISTER_CLOCK("imx23-gpmi-nand", NULL, gpmi_clk) | ||
443 | }; | ||
444 | |||
445 | static int clk_misc_init(void) | ||
446 | { | ||
447 | u32 reg; | ||
448 | int ret; | ||
449 | |||
450 | /* Fix up parent per register setting */ | ||
451 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_CLKSEQ); | ||
452 | cpu_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_CPU) ? | ||
453 | &ref_xtal_clk : &ref_cpu_clk; | ||
454 | emi_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_EMI) ? | ||
455 | &ref_xtal_clk : &ref_emi_clk; | ||
456 | ssp_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP) ? | ||
457 | &ref_xtal_clk : &ref_io_clk; | ||
458 | gpmi_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_GPMI) ? | ||
459 | &ref_xtal_clk : &ref_io_clk; | ||
460 | lcdif_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_PIX) ? | ||
461 | &ref_xtal_clk : &ref_pix_clk; | ||
462 | |||
463 | /* Use int div over frac when both are available */ | ||
464 | __raw_writel(BM_CLKCTRL_CPU_DIV_XTAL_FRAC_EN, | ||
465 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU_CLR); | ||
466 | __raw_writel(BM_CLKCTRL_CPU_DIV_CPU_FRAC_EN, | ||
467 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU_CLR); | ||
468 | __raw_writel(BM_CLKCTRL_HBUS_DIV_FRAC_EN, | ||
469 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS_CLR); | ||
470 | |||
471 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_XBUS); | ||
472 | reg &= ~BM_CLKCTRL_XBUS_DIV_FRAC_EN; | ||
473 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_XBUS); | ||
474 | |||
475 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP); | ||
476 | reg &= ~BM_CLKCTRL_SSP_DIV_FRAC_EN; | ||
477 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP); | ||
478 | |||
479 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_GPMI); | ||
480 | reg &= ~BM_CLKCTRL_GPMI_DIV_FRAC_EN; | ||
481 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_GPMI); | ||
482 | |||
483 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_PIX); | ||
484 | reg &= ~BM_CLKCTRL_PIX_DIV_FRAC_EN; | ||
485 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_PIX); | ||
486 | |||
487 | /* | ||
488 | * Set safe hbus clock divider. A divider of 3 ensure that | ||
489 | * the Vddd voltage required for the cpu clock is sufficiently | ||
490 | * high for the hbus clock. | ||
491 | */ | ||
492 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS); | ||
493 | reg &= BM_CLKCTRL_HBUS_DIV; | ||
494 | reg |= 3 << BP_CLKCTRL_HBUS_DIV; | ||
495 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS); | ||
496 | |||
497 | ret = mxs_clkctrl_timeout(HW_CLKCTRL_HBUS, BM_CLKCTRL_HBUS_BUSY); | ||
498 | |||
499 | /* Gate off cpu clock in WFI for power saving */ | ||
500 | __raw_writel(BM_CLKCTRL_CPU_INTERRUPT_WAIT, | ||
501 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU_SET); | ||
502 | |||
503 | /* | ||
504 | * 480 MHz seems too high to be ssp clock source directly, | ||
505 | * so set frac to get a 288 MHz ref_io. | ||
506 | */ | ||
507 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC); | ||
508 | reg &= ~BM_CLKCTRL_FRAC_IOFRAC; | ||
509 | reg |= 30 << BP_CLKCTRL_FRAC_IOFRAC; | ||
510 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC); | ||
511 | |||
512 | return ret; | ||
513 | } | ||
514 | |||
515 | int __init mx23_clocks_init(void) | ||
516 | { | ||
517 | clk_misc_init(); | ||
518 | |||
519 | /* | ||
520 | * source ssp clock from ref_io than ref_xtal, | ||
521 | * as ref_xtal only provides 24 MHz as maximum. | ||
522 | */ | ||
523 | clk_set_parent(&ssp_clk, &ref_io_clk); | ||
524 | |||
525 | clk_prepare_enable(&cpu_clk); | ||
526 | clk_prepare_enable(&hbus_clk); | ||
527 | clk_prepare_enable(&xbus_clk); | ||
528 | clk_prepare_enable(&emi_clk); | ||
529 | clk_prepare_enable(&uart_clk); | ||
530 | |||
531 | clkdev_add_table(lookups, ARRAY_SIZE(lookups)); | ||
532 | |||
533 | mxs_timer_init(&clk32k_clk, MX23_INT_TIMER0); | ||
534 | |||
535 | return 0; | ||
536 | } | ||
diff --git a/arch/arm/mach-mxs/clock-mx28.c b/arch/arm/mach-mxs/clock-mx28.c deleted file mode 100644 index cea29c99e214..000000000000 --- a/arch/arm/mach-mxs/clock-mx28.c +++ /dev/null | |||
@@ -1,803 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
17 | */ | ||
18 | |||
19 | #include <linux/mm.h> | ||
20 | #include <linux/delay.h> | ||
21 | #include <linux/clk.h> | ||
22 | #include <linux/io.h> | ||
23 | #include <linux/jiffies.h> | ||
24 | #include <linux/clkdev.h> | ||
25 | #include <linux/spinlock.h> | ||
26 | |||
27 | #include <asm/clkdev.h> | ||
28 | #include <asm/div64.h> | ||
29 | |||
30 | #include <mach/mx28.h> | ||
31 | #include <mach/common.h> | ||
32 | #include <mach/clock.h> | ||
33 | #include <mach/digctl.h> | ||
34 | |||
35 | #include "regs-clkctrl-mx28.h" | ||
36 | |||
37 | #define CLKCTRL_BASE_ADDR MX28_IO_ADDRESS(MX28_CLKCTRL_BASE_ADDR) | ||
38 | #define DIGCTRL_BASE_ADDR MX28_IO_ADDRESS(MX28_DIGCTL_BASE_ADDR) | ||
39 | |||
40 | #define PARENT_RATE_SHIFT 8 | ||
41 | |||
42 | static struct clk pll2_clk; | ||
43 | static struct clk cpu_clk; | ||
44 | static struct clk emi_clk; | ||
45 | static struct clk saif0_clk; | ||
46 | static struct clk saif1_clk; | ||
47 | static struct clk clk32k_clk; | ||
48 | static DEFINE_SPINLOCK(clkmux_lock); | ||
49 | |||
50 | /* | ||
51 | * HW_SAIF_CLKMUX_SEL: | ||
52 | * DIRECT(0x0): SAIF0 clock pins selected for SAIF0 input clocks, and SAIF1 | ||
53 | * clock pins selected for SAIF1 input clocks. | ||
54 | * CROSSINPUT(0x1): SAIF1 clock inputs selected for SAIF0 input clocks, and | ||
55 | * SAIF0 clock inputs selected for SAIF1 input clocks. | ||
56 | * EXTMSTR0(0x2): SAIF0 clock pin selected for both SAIF0 and SAIF1 input | ||
57 | * clocks. | ||
58 | * EXTMSTR1(0x3): SAIF1 clock pin selected for both SAIF0 and SAIF1 input | ||
59 | * clocks. | ||
60 | */ | ||
61 | int mxs_saif_clkmux_select(unsigned int clkmux) | ||
62 | { | ||
63 | if (clkmux > 0x3) | ||
64 | return -EINVAL; | ||
65 | |||
66 | spin_lock(&clkmux_lock); | ||
67 | __raw_writel(BM_DIGCTL_CTRL_SAIF_CLKMUX, | ||
68 | DIGCTRL_BASE_ADDR + HW_DIGCTL_CTRL + MXS_CLR_ADDR); | ||
69 | __raw_writel(clkmux << BP_DIGCTL_CTRL_SAIF_CLKMUX, | ||
70 | DIGCTRL_BASE_ADDR + HW_DIGCTL_CTRL + MXS_SET_ADDR); | ||
71 | spin_unlock(&clkmux_lock); | ||
72 | |||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | static int _raw_clk_enable(struct clk *clk) | ||
77 | { | ||
78 | u32 reg; | ||
79 | |||
80 | if (clk->enable_reg) { | ||
81 | reg = __raw_readl(clk->enable_reg); | ||
82 | reg &= ~(1 << clk->enable_shift); | ||
83 | __raw_writel(reg, clk->enable_reg); | ||
84 | } | ||
85 | |||
86 | return 0; | ||
87 | } | ||
88 | |||
89 | static void _raw_clk_disable(struct clk *clk) | ||
90 | { | ||
91 | u32 reg; | ||
92 | |||
93 | if (clk->enable_reg) { | ||
94 | reg = __raw_readl(clk->enable_reg); | ||
95 | reg |= 1 << clk->enable_shift; | ||
96 | __raw_writel(reg, clk->enable_reg); | ||
97 | } | ||
98 | } | ||
99 | |||
100 | /* | ||
101 | * ref_xtal_clk | ||
102 | */ | ||
103 | static unsigned long ref_xtal_clk_get_rate(struct clk *clk) | ||
104 | { | ||
105 | return 24000000; | ||
106 | } | ||
107 | |||
108 | static struct clk ref_xtal_clk = { | ||
109 | .get_rate = ref_xtal_clk_get_rate, | ||
110 | }; | ||
111 | |||
112 | /* | ||
113 | * pll_clk | ||
114 | */ | ||
115 | static unsigned long pll0_clk_get_rate(struct clk *clk) | ||
116 | { | ||
117 | return 480000000; | ||
118 | } | ||
119 | |||
120 | static unsigned long pll1_clk_get_rate(struct clk *clk) | ||
121 | { | ||
122 | return 480000000; | ||
123 | } | ||
124 | |||
125 | static unsigned long pll2_clk_get_rate(struct clk *clk) | ||
126 | { | ||
127 | return 50000000; | ||
128 | } | ||
129 | |||
130 | #define _CLK_ENABLE_PLL(name, r, g) \ | ||
131 | static int name##_enable(struct clk *clk) \ | ||
132 | { \ | ||
133 | __raw_writel(BM_CLKCTRL_##r##CTRL0_POWER, \ | ||
134 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_SET); \ | ||
135 | udelay(10); \ | ||
136 | \ | ||
137 | if (clk == &pll2_clk) \ | ||
138 | __raw_writel(BM_CLKCTRL_##r##CTRL0_##g, \ | ||
139 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_CLR); \ | ||
140 | else \ | ||
141 | __raw_writel(BM_CLKCTRL_##r##CTRL0_##g, \ | ||
142 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_SET); \ | ||
143 | \ | ||
144 | return 0; \ | ||
145 | } | ||
146 | |||
147 | _CLK_ENABLE_PLL(pll0_clk, PLL0, EN_USB_CLKS) | ||
148 | _CLK_ENABLE_PLL(pll1_clk, PLL1, EN_USB_CLKS) | ||
149 | _CLK_ENABLE_PLL(pll2_clk, PLL2, CLKGATE) | ||
150 | |||
151 | #define _CLK_DISABLE_PLL(name, r, g) \ | ||
152 | static void name##_disable(struct clk *clk) \ | ||
153 | { \ | ||
154 | __raw_writel(BM_CLKCTRL_##r##CTRL0_POWER, \ | ||
155 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_CLR); \ | ||
156 | \ | ||
157 | if (clk == &pll2_clk) \ | ||
158 | __raw_writel(BM_CLKCTRL_##r##CTRL0_##g, \ | ||
159 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_SET); \ | ||
160 | else \ | ||
161 | __raw_writel(BM_CLKCTRL_##r##CTRL0_##g, \ | ||
162 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_CLR); \ | ||
163 | \ | ||
164 | } | ||
165 | |||
166 | _CLK_DISABLE_PLL(pll0_clk, PLL0, EN_USB_CLKS) | ||
167 | _CLK_DISABLE_PLL(pll1_clk, PLL1, EN_USB_CLKS) | ||
168 | _CLK_DISABLE_PLL(pll2_clk, PLL2, CLKGATE) | ||
169 | |||
170 | #define _DEFINE_CLOCK_PLL(name) \ | ||
171 | static struct clk name = { \ | ||
172 | .get_rate = name##_get_rate, \ | ||
173 | .enable = name##_enable, \ | ||
174 | .disable = name##_disable, \ | ||
175 | .parent = &ref_xtal_clk, \ | ||
176 | } | ||
177 | |||
178 | _DEFINE_CLOCK_PLL(pll0_clk); | ||
179 | _DEFINE_CLOCK_PLL(pll1_clk); | ||
180 | _DEFINE_CLOCK_PLL(pll2_clk); | ||
181 | |||
182 | /* | ||
183 | * ref_clk | ||
184 | */ | ||
185 | #define _CLK_GET_RATE_REF(name, sr, ss) \ | ||
186 | static unsigned long name##_get_rate(struct clk *clk) \ | ||
187 | { \ | ||
188 | unsigned long parent_rate; \ | ||
189 | u32 reg, div; \ | ||
190 | \ | ||
191 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##sr); \ | ||
192 | div = (reg >> BP_CLKCTRL_##sr##_##ss##FRAC) & 0x3f; \ | ||
193 | parent_rate = clk_get_rate(clk->parent); \ | ||
194 | \ | ||
195 | return SH_DIV((parent_rate >> PARENT_RATE_SHIFT) * 18, \ | ||
196 | div, PARENT_RATE_SHIFT); \ | ||
197 | } | ||
198 | |||
199 | _CLK_GET_RATE_REF(ref_cpu_clk, FRAC0, CPU) | ||
200 | _CLK_GET_RATE_REF(ref_emi_clk, FRAC0, EMI) | ||
201 | _CLK_GET_RATE_REF(ref_io0_clk, FRAC0, IO0) | ||
202 | _CLK_GET_RATE_REF(ref_io1_clk, FRAC0, IO1) | ||
203 | _CLK_GET_RATE_REF(ref_pix_clk, FRAC1, PIX) | ||
204 | _CLK_GET_RATE_REF(ref_gpmi_clk, FRAC1, GPMI) | ||
205 | |||
206 | #define _DEFINE_CLOCK_REF(name, er, es) \ | ||
207 | static struct clk name = { \ | ||
208 | .enable_reg = CLKCTRL_BASE_ADDR + HW_CLKCTRL_##er, \ | ||
209 | .enable_shift = BP_CLKCTRL_##er##_CLKGATE##es, \ | ||
210 | .get_rate = name##_get_rate, \ | ||
211 | .enable = _raw_clk_enable, \ | ||
212 | .disable = _raw_clk_disable, \ | ||
213 | .parent = &pll0_clk, \ | ||
214 | } | ||
215 | |||
216 | _DEFINE_CLOCK_REF(ref_cpu_clk, FRAC0, CPU); | ||
217 | _DEFINE_CLOCK_REF(ref_emi_clk, FRAC0, EMI); | ||
218 | _DEFINE_CLOCK_REF(ref_io0_clk, FRAC0, IO0); | ||
219 | _DEFINE_CLOCK_REF(ref_io1_clk, FRAC0, IO1); | ||
220 | _DEFINE_CLOCK_REF(ref_pix_clk, FRAC1, PIX); | ||
221 | _DEFINE_CLOCK_REF(ref_gpmi_clk, FRAC1, GPMI); | ||
222 | |||
223 | /* | ||
224 | * General clocks | ||
225 | * | ||
226 | * clk_get_rate | ||
227 | */ | ||
228 | static unsigned long lradc_clk_get_rate(struct clk *clk) | ||
229 | { | ||
230 | return clk_get_rate(clk->parent) / 16; | ||
231 | } | ||
232 | |||
233 | static unsigned long rtc_clk_get_rate(struct clk *clk) | ||
234 | { | ||
235 | /* ref_xtal_clk is implemented as the only parent */ | ||
236 | return clk_get_rate(clk->parent) / 768; | ||
237 | } | ||
238 | |||
239 | static unsigned long clk32k_clk_get_rate(struct clk *clk) | ||
240 | { | ||
241 | return clk->parent->get_rate(clk->parent) / 750; | ||
242 | } | ||
243 | |||
244 | static unsigned long spdif_clk_get_rate(struct clk *clk) | ||
245 | { | ||
246 | return clk_get_rate(clk->parent) / 4; | ||
247 | } | ||
248 | |||
249 | #define _CLK_GET_RATE(name, rs) \ | ||
250 | static unsigned long name##_get_rate(struct clk *clk) \ | ||
251 | { \ | ||
252 | u32 reg, div; \ | ||
253 | \ | ||
254 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs); \ | ||
255 | \ | ||
256 | if (clk->parent == &ref_xtal_clk) \ | ||
257 | div = (reg & BM_CLKCTRL_##rs##_DIV_XTAL) >> \ | ||
258 | BP_CLKCTRL_##rs##_DIV_XTAL; \ | ||
259 | else \ | ||
260 | div = (reg & BM_CLKCTRL_##rs##_DIV_##rs) >> \ | ||
261 | BP_CLKCTRL_##rs##_DIV_##rs; \ | ||
262 | \ | ||
263 | if (!div) \ | ||
264 | return -EINVAL; \ | ||
265 | \ | ||
266 | return clk_get_rate(clk->parent) / div; \ | ||
267 | } | ||
268 | |||
269 | _CLK_GET_RATE(cpu_clk, CPU) | ||
270 | _CLK_GET_RATE(emi_clk, EMI) | ||
271 | |||
272 | #define _CLK_GET_RATE1(name, rs) \ | ||
273 | static unsigned long name##_get_rate(struct clk *clk) \ | ||
274 | { \ | ||
275 | u32 reg, div; \ | ||
276 | \ | ||
277 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs); \ | ||
278 | div = (reg & BM_CLKCTRL_##rs##_DIV) >> BP_CLKCTRL_##rs##_DIV; \ | ||
279 | \ | ||
280 | if (!div) \ | ||
281 | return -EINVAL; \ | ||
282 | \ | ||
283 | if (clk == &saif0_clk || clk == &saif1_clk) \ | ||
284 | return clk_get_rate(clk->parent) >> 16 * div; \ | ||
285 | else \ | ||
286 | return clk_get_rate(clk->parent) / div; \ | ||
287 | } | ||
288 | |||
289 | _CLK_GET_RATE1(hbus_clk, HBUS) | ||
290 | _CLK_GET_RATE1(xbus_clk, XBUS) | ||
291 | _CLK_GET_RATE1(ssp0_clk, SSP0) | ||
292 | _CLK_GET_RATE1(ssp1_clk, SSP1) | ||
293 | _CLK_GET_RATE1(ssp2_clk, SSP2) | ||
294 | _CLK_GET_RATE1(ssp3_clk, SSP3) | ||
295 | _CLK_GET_RATE1(gpmi_clk, GPMI) | ||
296 | _CLK_GET_RATE1(lcdif_clk, DIS_LCDIF) | ||
297 | _CLK_GET_RATE1(saif0_clk, SAIF0) | ||
298 | _CLK_GET_RATE1(saif1_clk, SAIF1) | ||
299 | |||
300 | #define _CLK_GET_RATE_STUB(name) \ | ||
301 | static unsigned long name##_get_rate(struct clk *clk) \ | ||
302 | { \ | ||
303 | return clk_get_rate(clk->parent); \ | ||
304 | } | ||
305 | |||
306 | _CLK_GET_RATE_STUB(uart_clk) | ||
307 | _CLK_GET_RATE_STUB(pwm_clk) | ||
308 | _CLK_GET_RATE_STUB(can0_clk) | ||
309 | _CLK_GET_RATE_STUB(can1_clk) | ||
310 | _CLK_GET_RATE_STUB(fec_clk) | ||
311 | |||
312 | /* | ||
313 | * clk_set_rate | ||
314 | */ | ||
315 | /* fool compiler */ | ||
316 | #define BM_CLKCTRL_CPU_DIV 0 | ||
317 | #define BP_CLKCTRL_CPU_DIV 0 | ||
318 | #define BM_CLKCTRL_CPU_BUSY 0 | ||
319 | |||
320 | #define _CLK_SET_RATE(name, dr, fr, fs) \ | ||
321 | static int name##_set_rate(struct clk *clk, unsigned long rate) \ | ||
322 | { \ | ||
323 | u32 reg, bm_busy, div_max, d, f, div, frac; \ | ||
324 | unsigned long diff, parent_rate, calc_rate; \ | ||
325 | \ | ||
326 | div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV; \ | ||
327 | bm_busy = BM_CLKCTRL_##dr##_BUSY; \ | ||
328 | \ | ||
329 | if (clk->parent == &ref_xtal_clk) { \ | ||
330 | parent_rate = clk_get_rate(clk->parent); \ | ||
331 | div = DIV_ROUND_UP(parent_rate, rate); \ | ||
332 | if (clk == &cpu_clk) { \ | ||
333 | div_max = BM_CLKCTRL_CPU_DIV_XTAL >> \ | ||
334 | BP_CLKCTRL_CPU_DIV_XTAL; \ | ||
335 | bm_busy = BM_CLKCTRL_CPU_BUSY_REF_XTAL; \ | ||
336 | } \ | ||
337 | if (div == 0 || div > div_max) \ | ||
338 | return -EINVAL; \ | ||
339 | } else { \ | ||
340 | /* \ | ||
341 | * hack alert: this block modifies clk->parent, too, \ | ||
342 | * so the base to use it the grand parent. \ | ||
343 | */ \ | ||
344 | parent_rate = clk_get_rate(clk->parent->parent); \ | ||
345 | rate >>= PARENT_RATE_SHIFT; \ | ||
346 | parent_rate >>= PARENT_RATE_SHIFT; \ | ||
347 | diff = parent_rate; \ | ||
348 | div = frac = 1; \ | ||
349 | if (clk == &cpu_clk) { \ | ||
350 | div_max = BM_CLKCTRL_CPU_DIV_CPU >> \ | ||
351 | BP_CLKCTRL_CPU_DIV_CPU; \ | ||
352 | bm_busy = BM_CLKCTRL_CPU_BUSY_REF_CPU; \ | ||
353 | } \ | ||
354 | for (d = 1; d <= div_max; d++) { \ | ||
355 | f = parent_rate * 18 / d / rate; \ | ||
356 | if ((parent_rate * 18 / d) % rate) \ | ||
357 | f++; \ | ||
358 | if (f < 18 || f > 35) \ | ||
359 | continue; \ | ||
360 | \ | ||
361 | calc_rate = parent_rate * 18 / f / d; \ | ||
362 | if (calc_rate > rate) \ | ||
363 | continue; \ | ||
364 | \ | ||
365 | if (rate - calc_rate < diff) { \ | ||
366 | frac = f; \ | ||
367 | div = d; \ | ||
368 | diff = rate - calc_rate; \ | ||
369 | } \ | ||
370 | \ | ||
371 | if (diff == 0) \ | ||
372 | break; \ | ||
373 | } \ | ||
374 | \ | ||
375 | if (diff == parent_rate) \ | ||
376 | return -EINVAL; \ | ||
377 | \ | ||
378 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##fr); \ | ||
379 | reg &= ~BM_CLKCTRL_##fr##_##fs##FRAC; \ | ||
380 | reg |= frac << BP_CLKCTRL_##fr##_##fs##FRAC; \ | ||
381 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##fr); \ | ||
382 | } \ | ||
383 | \ | ||
384 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr); \ | ||
385 | if (clk == &cpu_clk) { \ | ||
386 | reg &= ~BM_CLKCTRL_CPU_DIV_CPU; \ | ||
387 | reg |= div << BP_CLKCTRL_CPU_DIV_CPU; \ | ||
388 | } else { \ | ||
389 | reg &= ~BM_CLKCTRL_##dr##_DIV; \ | ||
390 | reg |= div << BP_CLKCTRL_##dr##_DIV; \ | ||
391 | if (reg & (1 << clk->enable_shift)) { \ | ||
392 | pr_err("%s: clock is gated\n", __func__); \ | ||
393 | return -EINVAL; \ | ||
394 | } \ | ||
395 | } \ | ||
396 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr); \ | ||
397 | \ | ||
398 | return mxs_clkctrl_timeout(HW_CLKCTRL_##dr, bm_busy); \ | ||
399 | } | ||
400 | |||
401 | _CLK_SET_RATE(cpu_clk, CPU, FRAC0, CPU) | ||
402 | _CLK_SET_RATE(ssp0_clk, SSP0, FRAC0, IO0) | ||
403 | _CLK_SET_RATE(ssp1_clk, SSP1, FRAC0, IO0) | ||
404 | _CLK_SET_RATE(ssp2_clk, SSP2, FRAC0, IO1) | ||
405 | _CLK_SET_RATE(ssp3_clk, SSP3, FRAC0, IO1) | ||
406 | _CLK_SET_RATE(lcdif_clk, DIS_LCDIF, FRAC1, PIX) | ||
407 | _CLK_SET_RATE(gpmi_clk, GPMI, FRAC1, GPMI) | ||
408 | |||
409 | #define _CLK_SET_RATE1(name, dr) \ | ||
410 | static int name##_set_rate(struct clk *clk, unsigned long rate) \ | ||
411 | { \ | ||
412 | u32 reg, div_max, div; \ | ||
413 | unsigned long parent_rate; \ | ||
414 | \ | ||
415 | parent_rate = clk_get_rate(clk->parent); \ | ||
416 | div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV; \ | ||
417 | \ | ||
418 | div = DIV_ROUND_UP(parent_rate, rate); \ | ||
419 | if (div == 0 || div > div_max) \ | ||
420 | return -EINVAL; \ | ||
421 | \ | ||
422 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr); \ | ||
423 | reg &= ~BM_CLKCTRL_##dr##_DIV; \ | ||
424 | reg |= div << BP_CLKCTRL_##dr##_DIV; \ | ||
425 | if (reg & (1 << clk->enable_shift)) { \ | ||
426 | pr_err("%s: clock is gated\n", __func__); \ | ||
427 | return -EINVAL; \ | ||
428 | } \ | ||
429 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr); \ | ||
430 | \ | ||
431 | return mxs_clkctrl_timeout(HW_CLKCTRL_##dr, BM_CLKCTRL_##dr##_BUSY);\ | ||
432 | } | ||
433 | |||
434 | _CLK_SET_RATE1(xbus_clk, XBUS) | ||
435 | |||
436 | /* saif clock uses 16 bits frac div */ | ||
437 | #define _CLK_SET_RATE_SAIF(name, rs) \ | ||
438 | static int name##_set_rate(struct clk *clk, unsigned long rate) \ | ||
439 | { \ | ||
440 | u16 div; \ | ||
441 | u32 reg; \ | ||
442 | u64 lrate; \ | ||
443 | unsigned long parent_rate; \ | ||
444 | \ | ||
445 | parent_rate = clk_get_rate(clk->parent); \ | ||
446 | if (rate > parent_rate) \ | ||
447 | return -EINVAL; \ | ||
448 | \ | ||
449 | lrate = (u64)rate << 16; \ | ||
450 | do_div(lrate, parent_rate); \ | ||
451 | div = (u16)lrate; \ | ||
452 | \ | ||
453 | if (!div) \ | ||
454 | return -EINVAL; \ | ||
455 | \ | ||
456 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs); \ | ||
457 | reg &= ~BM_CLKCTRL_##rs##_DIV; \ | ||
458 | reg |= div << BP_CLKCTRL_##rs##_DIV; \ | ||
459 | if (reg & (1 << clk->enable_shift)) { \ | ||
460 | pr_err("%s: clock is gated\n", __func__); \ | ||
461 | return -EINVAL; \ | ||
462 | } \ | ||
463 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs); \ | ||
464 | \ | ||
465 | return mxs_clkctrl_timeout(HW_CLKCTRL_##rs, BM_CLKCTRL_##rs##_BUSY);\ | ||
466 | } | ||
467 | |||
468 | _CLK_SET_RATE_SAIF(saif0_clk, SAIF0) | ||
469 | _CLK_SET_RATE_SAIF(saif1_clk, SAIF1) | ||
470 | |||
471 | #define _CLK_SET_RATE_STUB(name) \ | ||
472 | static int name##_set_rate(struct clk *clk, unsigned long rate) \ | ||
473 | { \ | ||
474 | return -EINVAL; \ | ||
475 | } | ||
476 | |||
477 | _CLK_SET_RATE_STUB(emi_clk) | ||
478 | _CLK_SET_RATE_STUB(uart_clk) | ||
479 | _CLK_SET_RATE_STUB(pwm_clk) | ||
480 | _CLK_SET_RATE_STUB(spdif_clk) | ||
481 | _CLK_SET_RATE_STUB(clk32k_clk) | ||
482 | _CLK_SET_RATE_STUB(can0_clk) | ||
483 | _CLK_SET_RATE_STUB(can1_clk) | ||
484 | _CLK_SET_RATE_STUB(fec_clk) | ||
485 | |||
486 | /* | ||
487 | * clk_set_parent | ||
488 | */ | ||
489 | #define _CLK_SET_PARENT(name, bit) \ | ||
490 | static int name##_set_parent(struct clk *clk, struct clk *parent) \ | ||
491 | { \ | ||
492 | if (parent != clk->parent) { \ | ||
493 | __raw_writel(BM_CLKCTRL_CLKSEQ_BYPASS_##bit, \ | ||
494 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_CLKSEQ_TOG); \ | ||
495 | clk->parent = parent; \ | ||
496 | } \ | ||
497 | \ | ||
498 | return 0; \ | ||
499 | } | ||
500 | |||
501 | _CLK_SET_PARENT(cpu_clk, CPU) | ||
502 | _CLK_SET_PARENT(emi_clk, EMI) | ||
503 | _CLK_SET_PARENT(ssp0_clk, SSP0) | ||
504 | _CLK_SET_PARENT(ssp1_clk, SSP1) | ||
505 | _CLK_SET_PARENT(ssp2_clk, SSP2) | ||
506 | _CLK_SET_PARENT(ssp3_clk, SSP3) | ||
507 | _CLK_SET_PARENT(lcdif_clk, DIS_LCDIF) | ||
508 | _CLK_SET_PARENT(gpmi_clk, GPMI) | ||
509 | _CLK_SET_PARENT(saif0_clk, SAIF0) | ||
510 | _CLK_SET_PARENT(saif1_clk, SAIF1) | ||
511 | |||
512 | #define _CLK_SET_PARENT_STUB(name) \ | ||
513 | static int name##_set_parent(struct clk *clk, struct clk *parent) \ | ||
514 | { \ | ||
515 | if (parent != clk->parent) \ | ||
516 | return -EINVAL; \ | ||
517 | else \ | ||
518 | return 0; \ | ||
519 | } | ||
520 | |||
521 | _CLK_SET_PARENT_STUB(pwm_clk) | ||
522 | _CLK_SET_PARENT_STUB(uart_clk) | ||
523 | _CLK_SET_PARENT_STUB(clk32k_clk) | ||
524 | _CLK_SET_PARENT_STUB(spdif_clk) | ||
525 | _CLK_SET_PARENT_STUB(fec_clk) | ||
526 | _CLK_SET_PARENT_STUB(can0_clk) | ||
527 | _CLK_SET_PARENT_STUB(can1_clk) | ||
528 | |||
529 | /* | ||
530 | * clk definition | ||
531 | */ | ||
532 | static struct clk cpu_clk = { | ||
533 | .get_rate = cpu_clk_get_rate, | ||
534 | .set_rate = cpu_clk_set_rate, | ||
535 | .set_parent = cpu_clk_set_parent, | ||
536 | .parent = &ref_cpu_clk, | ||
537 | }; | ||
538 | |||
539 | static struct clk hbus_clk = { | ||
540 | .get_rate = hbus_clk_get_rate, | ||
541 | .parent = &cpu_clk, | ||
542 | }; | ||
543 | |||
544 | static struct clk xbus_clk = { | ||
545 | .get_rate = xbus_clk_get_rate, | ||
546 | .set_rate = xbus_clk_set_rate, | ||
547 | .parent = &ref_xtal_clk, | ||
548 | }; | ||
549 | |||
550 | static struct clk lradc_clk = { | ||
551 | .get_rate = lradc_clk_get_rate, | ||
552 | .parent = &clk32k_clk, | ||
553 | }; | ||
554 | |||
555 | static struct clk rtc_clk = { | ||
556 | .get_rate = rtc_clk_get_rate, | ||
557 | .parent = &ref_xtal_clk, | ||
558 | }; | ||
559 | |||
560 | /* usb_clk gate is controlled in DIGCTRL other than CLKCTRL */ | ||
561 | static struct clk usb0_clk = { | ||
562 | .enable_reg = DIGCTRL_BASE_ADDR, | ||
563 | .enable_shift = 2, | ||
564 | .enable = _raw_clk_enable, | ||
565 | .disable = _raw_clk_disable, | ||
566 | .parent = &pll0_clk, | ||
567 | }; | ||
568 | |||
569 | static struct clk usb1_clk = { | ||
570 | .enable_reg = DIGCTRL_BASE_ADDR, | ||
571 | .enable_shift = 16, | ||
572 | .enable = _raw_clk_enable, | ||
573 | .disable = _raw_clk_disable, | ||
574 | .parent = &pll1_clk, | ||
575 | }; | ||
576 | |||
577 | #define _DEFINE_CLOCK(name, er, es, p) \ | ||
578 | static struct clk name = { \ | ||
579 | .enable_reg = CLKCTRL_BASE_ADDR + HW_CLKCTRL_##er, \ | ||
580 | .enable_shift = BP_CLKCTRL_##er##_##es, \ | ||
581 | .get_rate = name##_get_rate, \ | ||
582 | .set_rate = name##_set_rate, \ | ||
583 | .set_parent = name##_set_parent, \ | ||
584 | .enable = _raw_clk_enable, \ | ||
585 | .disable = _raw_clk_disable, \ | ||
586 | .parent = p, \ | ||
587 | } | ||
588 | |||
589 | _DEFINE_CLOCK(emi_clk, EMI, CLKGATE, &ref_xtal_clk); | ||
590 | _DEFINE_CLOCK(ssp0_clk, SSP0, CLKGATE, &ref_xtal_clk); | ||
591 | _DEFINE_CLOCK(ssp1_clk, SSP1, CLKGATE, &ref_xtal_clk); | ||
592 | _DEFINE_CLOCK(ssp2_clk, SSP2, CLKGATE, &ref_xtal_clk); | ||
593 | _DEFINE_CLOCK(ssp3_clk, SSP3, CLKGATE, &ref_xtal_clk); | ||
594 | _DEFINE_CLOCK(lcdif_clk, DIS_LCDIF, CLKGATE, &ref_xtal_clk); | ||
595 | _DEFINE_CLOCK(gpmi_clk, GPMI, CLKGATE, &ref_xtal_clk); | ||
596 | _DEFINE_CLOCK(saif0_clk, SAIF0, CLKGATE, &ref_xtal_clk); | ||
597 | _DEFINE_CLOCK(saif1_clk, SAIF1, CLKGATE, &ref_xtal_clk); | ||
598 | _DEFINE_CLOCK(can0_clk, FLEXCAN, STOP_CAN0, &ref_xtal_clk); | ||
599 | _DEFINE_CLOCK(can1_clk, FLEXCAN, STOP_CAN1, &ref_xtal_clk); | ||
600 | _DEFINE_CLOCK(pwm_clk, XTAL, PWM_CLK24M_GATE, &ref_xtal_clk); | ||
601 | _DEFINE_CLOCK(uart_clk, XTAL, UART_CLK_GATE, &ref_xtal_clk); | ||
602 | _DEFINE_CLOCK(clk32k_clk, XTAL, TIMROT_CLK32K_GATE, &ref_xtal_clk); | ||
603 | _DEFINE_CLOCK(spdif_clk, SPDIF, CLKGATE, &pll0_clk); | ||
604 | _DEFINE_CLOCK(fec_clk, ENET, DISABLE, &hbus_clk); | ||
605 | |||
606 | #define _REGISTER_CLOCK(d, n, c) \ | ||
607 | { \ | ||
608 | .dev_id = d, \ | ||
609 | .con_id = n, \ | ||
610 | .clk = &c, \ | ||
611 | }, | ||
612 | |||
613 | static struct clk_lookup lookups[] = { | ||
614 | /* for amba bus driver */ | ||
615 | _REGISTER_CLOCK("duart", "apb_pclk", xbus_clk) | ||
616 | /* for amba-pl011 driver */ | ||
617 | _REGISTER_CLOCK("duart", NULL, uart_clk) | ||
618 | _REGISTER_CLOCK("imx28-fec.0", NULL, fec_clk) | ||
619 | _REGISTER_CLOCK("imx28-fec.1", NULL, fec_clk) | ||
620 | _REGISTER_CLOCK("imx28-gpmi-nand", NULL, gpmi_clk) | ||
621 | _REGISTER_CLOCK("mxs-auart.0", NULL, uart_clk) | ||
622 | _REGISTER_CLOCK("mxs-auart.1", NULL, uart_clk) | ||
623 | _REGISTER_CLOCK("mxs-auart.2", NULL, uart_clk) | ||
624 | _REGISTER_CLOCK("mxs-auart.3", NULL, uart_clk) | ||
625 | _REGISTER_CLOCK("mxs-auart.4", NULL, uart_clk) | ||
626 | _REGISTER_CLOCK("rtc", NULL, rtc_clk) | ||
627 | _REGISTER_CLOCK("pll2", NULL, pll2_clk) | ||
628 | _REGISTER_CLOCK("mxs-dma-apbh", NULL, hbus_clk) | ||
629 | _REGISTER_CLOCK("mxs-dma-apbx", NULL, xbus_clk) | ||
630 | _REGISTER_CLOCK("mxs-mmc.0", NULL, ssp0_clk) | ||
631 | _REGISTER_CLOCK("mxs-mmc.1", NULL, ssp1_clk) | ||
632 | _REGISTER_CLOCK("mxs-mmc.2", NULL, ssp2_clk) | ||
633 | _REGISTER_CLOCK("mxs-mmc.3", NULL, ssp3_clk) | ||
634 | _REGISTER_CLOCK("flexcan.0", NULL, can0_clk) | ||
635 | _REGISTER_CLOCK("flexcan.1", NULL, can1_clk) | ||
636 | _REGISTER_CLOCK(NULL, "usb0", usb0_clk) | ||
637 | _REGISTER_CLOCK(NULL, "usb1", usb1_clk) | ||
638 | _REGISTER_CLOCK("mxs-pwm.0", NULL, pwm_clk) | ||
639 | _REGISTER_CLOCK("mxs-pwm.1", NULL, pwm_clk) | ||
640 | _REGISTER_CLOCK("mxs-pwm.2", NULL, pwm_clk) | ||
641 | _REGISTER_CLOCK("mxs-pwm.3", NULL, pwm_clk) | ||
642 | _REGISTER_CLOCK("mxs-pwm.4", NULL, pwm_clk) | ||
643 | _REGISTER_CLOCK("mxs-pwm.5", NULL, pwm_clk) | ||
644 | _REGISTER_CLOCK("mxs-pwm.6", NULL, pwm_clk) | ||
645 | _REGISTER_CLOCK("mxs-pwm.7", NULL, pwm_clk) | ||
646 | _REGISTER_CLOCK(NULL, "lradc", lradc_clk) | ||
647 | _REGISTER_CLOCK(NULL, "spdif", spdif_clk) | ||
648 | _REGISTER_CLOCK("imx28-fb", NULL, lcdif_clk) | ||
649 | _REGISTER_CLOCK("mxs-saif.0", NULL, saif0_clk) | ||
650 | _REGISTER_CLOCK("mxs-saif.1", NULL, saif1_clk) | ||
651 | }; | ||
652 | |||
653 | static int clk_misc_init(void) | ||
654 | { | ||
655 | u32 reg; | ||
656 | int ret; | ||
657 | |||
658 | /* Fix up parent per register setting */ | ||
659 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_CLKSEQ); | ||
660 | cpu_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_CPU) ? | ||
661 | &ref_xtal_clk : &ref_cpu_clk; | ||
662 | emi_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_EMI) ? | ||
663 | &ref_xtal_clk : &ref_emi_clk; | ||
664 | ssp0_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP0) ? | ||
665 | &ref_xtal_clk : &ref_io0_clk; | ||
666 | ssp1_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP1) ? | ||
667 | &ref_xtal_clk : &ref_io0_clk; | ||
668 | ssp2_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP2) ? | ||
669 | &ref_xtal_clk : &ref_io1_clk; | ||
670 | ssp3_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP3) ? | ||
671 | &ref_xtal_clk : &ref_io1_clk; | ||
672 | lcdif_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF) ? | ||
673 | &ref_xtal_clk : &ref_pix_clk; | ||
674 | gpmi_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_GPMI) ? | ||
675 | &ref_xtal_clk : &ref_gpmi_clk; | ||
676 | saif0_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SAIF0) ? | ||
677 | &ref_xtal_clk : &pll0_clk; | ||
678 | saif1_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SAIF1) ? | ||
679 | &ref_xtal_clk : &pll0_clk; | ||
680 | |||
681 | /* Use int div over frac when both are available */ | ||
682 | __raw_writel(BM_CLKCTRL_CPU_DIV_XTAL_FRAC_EN, | ||
683 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU_CLR); | ||
684 | __raw_writel(BM_CLKCTRL_CPU_DIV_CPU_FRAC_EN, | ||
685 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU_CLR); | ||
686 | __raw_writel(BM_CLKCTRL_HBUS_DIV_FRAC_EN, | ||
687 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS_CLR); | ||
688 | |||
689 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_XBUS); | ||
690 | reg &= ~BM_CLKCTRL_XBUS_DIV_FRAC_EN; | ||
691 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_XBUS); | ||
692 | |||
693 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP0); | ||
694 | reg &= ~BM_CLKCTRL_SSP0_DIV_FRAC_EN; | ||
695 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP0); | ||
696 | |||
697 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP1); | ||
698 | reg &= ~BM_CLKCTRL_SSP1_DIV_FRAC_EN; | ||
699 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP1); | ||
700 | |||
701 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP2); | ||
702 | reg &= ~BM_CLKCTRL_SSP2_DIV_FRAC_EN; | ||
703 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP2); | ||
704 | |||
705 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP3); | ||
706 | reg &= ~BM_CLKCTRL_SSP3_DIV_FRAC_EN; | ||
707 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP3); | ||
708 | |||
709 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_GPMI); | ||
710 | reg &= ~BM_CLKCTRL_GPMI_DIV_FRAC_EN; | ||
711 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_GPMI); | ||
712 | |||
713 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_DIS_LCDIF); | ||
714 | reg &= ~BM_CLKCTRL_DIS_LCDIF_DIV_FRAC_EN; | ||
715 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_DIS_LCDIF); | ||
716 | |||
717 | /* SAIF has to use frac div for functional operation */ | ||
718 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SAIF0); | ||
719 | reg |= BM_CLKCTRL_SAIF0_DIV_FRAC_EN; | ||
720 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SAIF0); | ||
721 | |||
722 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SAIF1); | ||
723 | reg |= BM_CLKCTRL_SAIF1_DIV_FRAC_EN; | ||
724 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SAIF1); | ||
725 | |||
726 | /* | ||
727 | * Set safe hbus clock divider. A divider of 3 ensure that | ||
728 | * the Vddd voltage required for the cpu clock is sufficiently | ||
729 | * high for the hbus clock. | ||
730 | */ | ||
731 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS); | ||
732 | reg &= BM_CLKCTRL_HBUS_DIV; | ||
733 | reg |= 3 << BP_CLKCTRL_HBUS_DIV; | ||
734 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS); | ||
735 | |||
736 | ret = mxs_clkctrl_timeout(HW_CLKCTRL_HBUS, BM_CLKCTRL_HBUS_ASM_BUSY); | ||
737 | |||
738 | /* Gate off cpu clock in WFI for power saving */ | ||
739 | __raw_writel(BM_CLKCTRL_CPU_INTERRUPT_WAIT, | ||
740 | CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU_SET); | ||
741 | |||
742 | /* | ||
743 | * Extra fec clock setting | ||
744 | * The DENX M28 uses an external clock source | ||
745 | * and the clock output must not be enabled | ||
746 | */ | ||
747 | if (!machine_is_m28evk()) { | ||
748 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_ENET); | ||
749 | reg &= ~BM_CLKCTRL_ENET_SLEEP; | ||
750 | reg |= BM_CLKCTRL_ENET_CLK_OUT_EN; | ||
751 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_ENET); | ||
752 | } | ||
753 | |||
754 | /* | ||
755 | * 480 MHz seems too high to be ssp clock source directly, | ||
756 | * so set frac0 to get a 288 MHz ref_io0. | ||
757 | */ | ||
758 | reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC0); | ||
759 | reg &= ~BM_CLKCTRL_FRAC0_IO0FRAC; | ||
760 | reg |= 30 << BP_CLKCTRL_FRAC0_IO0FRAC; | ||
761 | __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC0); | ||
762 | |||
763 | return ret; | ||
764 | } | ||
765 | |||
766 | int __init mx28_clocks_init(void) | ||
767 | { | ||
768 | clk_misc_init(); | ||
769 | |||
770 | /* | ||
771 | * source ssp clock from ref_io0 than ref_xtal, | ||
772 | * as ref_xtal only provides 24 MHz as maximum. | ||
773 | */ | ||
774 | clk_set_parent(&ssp0_clk, &ref_io0_clk); | ||
775 | clk_set_parent(&ssp1_clk, &ref_io0_clk); | ||
776 | clk_set_parent(&ssp2_clk, &ref_io1_clk); | ||
777 | clk_set_parent(&ssp3_clk, &ref_io1_clk); | ||
778 | |||
779 | clk_prepare_enable(&cpu_clk); | ||
780 | clk_prepare_enable(&hbus_clk); | ||
781 | clk_prepare_enable(&xbus_clk); | ||
782 | clk_prepare_enable(&emi_clk); | ||
783 | clk_prepare_enable(&uart_clk); | ||
784 | |||
785 | clk_set_parent(&lcdif_clk, &ref_pix_clk); | ||
786 | clk_set_parent(&saif0_clk, &pll0_clk); | ||
787 | clk_set_parent(&saif1_clk, &pll0_clk); | ||
788 | |||
789 | /* | ||
790 | * Set an initial clock rate for the saif internal logic to work | ||
791 | * properly. This is important when working in EXTMASTER mode that | ||
792 | * uses the other saif's BITCLK&LRCLK but it still needs a basic | ||
793 | * clock which should be fast enough for the internal logic. | ||
794 | */ | ||
795 | clk_set_rate(&saif0_clk, 24000000); | ||
796 | clk_set_rate(&saif1_clk, 24000000); | ||
797 | |||
798 | clkdev_add_table(lookups, ARRAY_SIZE(lookups)); | ||
799 | |||
800 | mxs_timer_init(&clk32k_clk, MX28_INT_TIMER0); | ||
801 | |||
802 | return 0; | ||
803 | } | ||
diff --git a/arch/arm/mach-mxs/clock.c b/arch/arm/mach-mxs/clock.c deleted file mode 100644 index 97a6f4acc6cc..000000000000 --- a/arch/arm/mach-mxs/clock.c +++ /dev/null | |||
@@ -1,211 +0,0 @@ | |||
1 | /* | ||
2 | * Based on arch/arm/plat-omap/clock.c | ||
3 | * | ||
4 | * Copyright (C) 2004 - 2005 Nokia corporation | ||
5 | * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com> | ||
6 | * Modified for omap shared clock framework by Tony Lindgren <tony@atomide.com> | ||
7 | * Copyright 2007 Freescale Semiconductor, Inc. All Rights Reserved. | ||
8 | * Copyright 2008 Juergen Beisert, kernel@pengutronix.de | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * as published by the Free Software Foundation; either version 2 | ||
13 | * of the License, or (at your option) any later version. | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
22 | * MA 02110-1301, USA. | ||
23 | */ | ||
24 | |||
25 | /* #define DEBUG */ | ||
26 | |||
27 | #include <linux/clk.h> | ||
28 | #include <linux/err.h> | ||
29 | #include <linux/errno.h> | ||
30 | #include <linux/init.h> | ||
31 | #include <linux/io.h> | ||
32 | #include <linux/kernel.h> | ||
33 | #include <linux/list.h> | ||
34 | #include <linux/module.h> | ||
35 | #include <linux/mutex.h> | ||
36 | #include <linux/platform_device.h> | ||
37 | #include <linux/proc_fs.h> | ||
38 | #include <linux/semaphore.h> | ||
39 | #include <linux/string.h> | ||
40 | |||
41 | #include <mach/clock.h> | ||
42 | |||
43 | static LIST_HEAD(clocks); | ||
44 | static DEFINE_MUTEX(clocks_mutex); | ||
45 | |||
46 | /*------------------------------------------------------------------------- | ||
47 | * Standard clock functions defined in include/linux/clk.h | ||
48 | *-------------------------------------------------------------------------*/ | ||
49 | |||
50 | static void __clk_disable(struct clk *clk) | ||
51 | { | ||
52 | if (clk == NULL || IS_ERR(clk)) | ||
53 | return; | ||
54 | WARN_ON(!clk->usecount); | ||
55 | |||
56 | if (!(--clk->usecount)) { | ||
57 | if (clk->disable) | ||
58 | clk->disable(clk); | ||
59 | __clk_disable(clk->parent); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | static int __clk_enable(struct clk *clk) | ||
64 | { | ||
65 | if (clk == NULL || IS_ERR(clk)) | ||
66 | return -EINVAL; | ||
67 | |||
68 | if (clk->usecount++ == 0) { | ||
69 | __clk_enable(clk->parent); | ||
70 | |||
71 | if (clk->enable) | ||
72 | clk->enable(clk); | ||
73 | } | ||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | /* | ||
78 | * The clk_enable/clk_disable could be called by drivers in atomic context, | ||
79 | * so they should not really hold mutex. Instead, clk_prepare/clk_unprepare | ||
80 | * can hold a mutex, as the pair will only be called in non-atomic context. | ||
81 | * Before migrating to common clk framework, we can have __clk_enable and | ||
82 | * __clk_disable called in clk_prepare/clk_unprepare with mutex held and | ||
83 | * leave clk_enable/clk_disable as the dummy functions. | ||
84 | */ | ||
85 | int clk_prepare(struct clk *clk) | ||
86 | { | ||
87 | int ret = 0; | ||
88 | |||
89 | if (clk == NULL || IS_ERR(clk)) | ||
90 | return -EINVAL; | ||
91 | |||
92 | mutex_lock(&clocks_mutex); | ||
93 | ret = __clk_enable(clk); | ||
94 | mutex_unlock(&clocks_mutex); | ||
95 | |||
96 | return ret; | ||
97 | } | ||
98 | EXPORT_SYMBOL(clk_prepare); | ||
99 | |||
100 | void clk_unprepare(struct clk *clk) | ||
101 | { | ||
102 | if (clk == NULL || IS_ERR(clk)) | ||
103 | return; | ||
104 | |||
105 | mutex_lock(&clocks_mutex); | ||
106 | __clk_disable(clk); | ||
107 | mutex_unlock(&clocks_mutex); | ||
108 | } | ||
109 | EXPORT_SYMBOL(clk_unprepare); | ||
110 | |||
111 | int clk_enable(struct clk *clk) | ||
112 | { | ||
113 | return 0; | ||
114 | } | ||
115 | EXPORT_SYMBOL(clk_enable); | ||
116 | |||
117 | void clk_disable(struct clk *clk) | ||
118 | { | ||
119 | /* nothing to do */ | ||
120 | } | ||
121 | EXPORT_SYMBOL(clk_disable); | ||
122 | |||
123 | /* Retrieve the *current* clock rate. If the clock itself | ||
124 | * does not provide a special calculation routine, ask | ||
125 | * its parent and so on, until one is able to return | ||
126 | * a valid clock rate | ||
127 | */ | ||
128 | unsigned long clk_get_rate(struct clk *clk) | ||
129 | { | ||
130 | if (clk == NULL || IS_ERR(clk)) | ||
131 | return 0UL; | ||
132 | |||
133 | if (clk->get_rate) | ||
134 | return clk->get_rate(clk); | ||
135 | |||
136 | return clk_get_rate(clk->parent); | ||
137 | } | ||
138 | EXPORT_SYMBOL(clk_get_rate); | ||
139 | |||
140 | /* Round the requested clock rate to the nearest supported | ||
141 | * rate that is less than or equal to the requested rate. | ||
142 | * This is dependent on the clock's current parent. | ||
143 | */ | ||
144 | long clk_round_rate(struct clk *clk, unsigned long rate) | ||
145 | { | ||
146 | if (clk == NULL || IS_ERR(clk) || !clk->round_rate) | ||
147 | return 0; | ||
148 | |||
149 | return clk->round_rate(clk, rate); | ||
150 | } | ||
151 | EXPORT_SYMBOL(clk_round_rate); | ||
152 | |||
153 | /* Set the clock to the requested clock rate. The rate must | ||
154 | * match a supported rate exactly based on what clk_round_rate returns | ||
155 | */ | ||
156 | int clk_set_rate(struct clk *clk, unsigned long rate) | ||
157 | { | ||
158 | int ret = -EINVAL; | ||
159 | |||
160 | if (clk == NULL || IS_ERR(clk) || clk->set_rate == NULL || rate == 0) | ||
161 | return ret; | ||
162 | |||
163 | mutex_lock(&clocks_mutex); | ||
164 | ret = clk->set_rate(clk, rate); | ||
165 | mutex_unlock(&clocks_mutex); | ||
166 | |||
167 | return ret; | ||
168 | } | ||
169 | EXPORT_SYMBOL(clk_set_rate); | ||
170 | |||
171 | /* Set the clock's parent to another clock source */ | ||
172 | int clk_set_parent(struct clk *clk, struct clk *parent) | ||
173 | { | ||
174 | int ret = -EINVAL; | ||
175 | struct clk *old; | ||
176 | |||
177 | if (clk == NULL || IS_ERR(clk) || parent == NULL || | ||
178 | IS_ERR(parent) || clk->set_parent == NULL) | ||
179 | return ret; | ||
180 | |||
181 | if (clk->usecount) | ||
182 | clk_prepare_enable(parent); | ||
183 | |||
184 | mutex_lock(&clocks_mutex); | ||
185 | ret = clk->set_parent(clk, parent); | ||
186 | if (ret == 0) { | ||
187 | old = clk->parent; | ||
188 | clk->parent = parent; | ||
189 | } else { | ||
190 | old = parent; | ||
191 | } | ||
192 | mutex_unlock(&clocks_mutex); | ||
193 | |||
194 | if (clk->usecount) | ||
195 | clk_disable(old); | ||
196 | |||
197 | return ret; | ||
198 | } | ||
199 | EXPORT_SYMBOL(clk_set_parent); | ||
200 | |||
201 | /* Retrieve the clock's parent clock source */ | ||
202 | struct clk *clk_get_parent(struct clk *clk) | ||
203 | { | ||
204 | struct clk *ret = NULL; | ||
205 | |||
206 | if (clk == NULL || IS_ERR(clk)) | ||
207 | return ret; | ||
208 | |||
209 | return clk->parent; | ||
210 | } | ||
211 | EXPORT_SYMBOL(clk_get_parent); | ||
diff --git a/arch/arm/mach-mxs/include/mach/clock.h b/arch/arm/mach-mxs/include/mach/clock.h deleted file mode 100644 index 592c9ab5d760..000000000000 --- a/arch/arm/mach-mxs/include/mach/clock.h +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved. | ||
3 | * Copyright 2008 Juergen Beisert, kernel@pengutronix.de | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version 2 | ||
8 | * of the License, or (at your option) any later version. | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
17 | * MA 02110-1301, USA. | ||
18 | */ | ||
19 | |||
20 | #ifndef __MACH_MXS_CLOCK_H__ | ||
21 | #define __MACH_MXS_CLOCK_H__ | ||
22 | |||
23 | #ifndef __ASSEMBLY__ | ||
24 | #include <linux/list.h> | ||
25 | |||
26 | struct module; | ||
27 | |||
28 | struct clk { | ||
29 | int id; | ||
30 | /* Source clock this clk depends on */ | ||
31 | struct clk *parent; | ||
32 | /* Reference count of clock enable/disable */ | ||
33 | __s8 usecount; | ||
34 | /* Register bit position for clock's enable/disable control. */ | ||
35 | u8 enable_shift; | ||
36 | /* Register address for clock's enable/disable control. */ | ||
37 | void __iomem *enable_reg; | ||
38 | u32 flags; | ||
39 | /* get the current clock rate (always a fresh value) */ | ||
40 | unsigned long (*get_rate) (struct clk *); | ||
41 | /* Function ptr to set the clock to a new rate. The rate must match a | ||
42 | supported rate returned from round_rate. Leave blank if clock is not | ||
43 | programmable */ | ||
44 | int (*set_rate) (struct clk *, unsigned long); | ||
45 | /* Function ptr to round the requested clock rate to the nearest | ||
46 | supported rate that is less than or equal to the requested rate. */ | ||
47 | unsigned long (*round_rate) (struct clk *, unsigned long); | ||
48 | /* Function ptr to enable the clock. Leave blank if clock can not | ||
49 | be gated. */ | ||
50 | int (*enable) (struct clk *); | ||
51 | /* Function ptr to disable the clock. Leave blank if clock can not | ||
52 | be gated. */ | ||
53 | void (*disable) (struct clk *); | ||
54 | /* Function ptr to set the parent clock of the clock. */ | ||
55 | int (*set_parent) (struct clk *, struct clk *); | ||
56 | }; | ||
57 | |||
58 | int clk_register(struct clk *clk); | ||
59 | void clk_unregister(struct clk *clk); | ||
60 | |||
61 | #endif /* __ASSEMBLY__ */ | ||
62 | #endif /* __MACH_MXS_CLOCK_H__ */ | ||
diff --git a/arch/arm/mach-mxs/include/mach/common.h b/arch/arm/mach-mxs/include/mach/common.h index c50c3ea28a9d..84af61cf6a62 100644 --- a/arch/arm/mach-mxs/include/mach/common.h +++ b/arch/arm/mach-mxs/include/mach/common.h | |||
@@ -11,19 +11,19 @@ | |||
11 | #ifndef __MACH_MXS_COMMON_H__ | 11 | #ifndef __MACH_MXS_COMMON_H__ |
12 | #define __MACH_MXS_COMMON_H__ | 12 | #define __MACH_MXS_COMMON_H__ |
13 | 13 | ||
14 | struct clk; | ||
15 | |||
16 | extern const u32 *mxs_get_ocotp(void); | 14 | extern const u32 *mxs_get_ocotp(void); |
17 | extern int mxs_reset_block(void __iomem *); | 15 | extern int mxs_reset_block(void __iomem *); |
18 | extern void mxs_timer_init(struct clk *, int); | 16 | extern void mxs_timer_init(int); |
19 | extern void mxs_restart(char, const char *); | 17 | extern void mxs_restart(char, const char *); |
20 | extern int mxs_saif_clkmux_select(unsigned int clkmux); | 18 | extern int mxs_saif_clkmux_select(unsigned int clkmux); |
21 | 19 | ||
20 | extern void mx23_soc_init(void); | ||
22 | extern int mx23_register_gpios(void); | 21 | extern int mx23_register_gpios(void); |
23 | extern int mx23_clocks_init(void); | 22 | extern int mx23_clocks_init(void); |
24 | extern void mx23_map_io(void); | 23 | extern void mx23_map_io(void); |
25 | extern void mx23_init_irq(void); | 24 | extern void mx23_init_irq(void); |
26 | 25 | ||
26 | extern void mx28_soc_init(void); | ||
27 | extern int mx28_register_gpios(void); | 27 | extern int mx28_register_gpios(void); |
28 | extern int mx28_clocks_init(void); | 28 | extern int mx28_clocks_init(void); |
29 | extern void mx28_map_io(void); | 29 | extern void mx28_map_io(void); |
@@ -31,6 +31,4 @@ extern void mx28_init_irq(void); | |||
31 | 31 | ||
32 | extern void icoll_init_irq(void); | 32 | extern void icoll_init_irq(void); |
33 | 33 | ||
34 | extern int mxs_clkctrl_timeout(unsigned int reg_offset, unsigned int mask); | ||
35 | |||
36 | #endif /* __MACH_MXS_COMMON_H__ */ | 34 | #endif /* __MACH_MXS_COMMON_H__ */ |
diff --git a/arch/arm/mach-mxs/mach-apx4devkit.c b/arch/arm/mach-mxs/mach-apx4devkit.c index 48a7fab571a6..5e90b9dcdef8 100644 --- a/arch/arm/mach-mxs/mach-apx4devkit.c +++ b/arch/arm/mach-mxs/mach-apx4devkit.c | |||
@@ -207,6 +207,8 @@ static int apx4devkit_phy_fixup(struct phy_device *phy) | |||
207 | 207 | ||
208 | static void __init apx4devkit_init(void) | 208 | static void __init apx4devkit_init(void) |
209 | { | 209 | { |
210 | mx28_soc_init(); | ||
211 | |||
210 | mxs_iomux_setup_multiple_pads(apx4devkit_pads, | 212 | mxs_iomux_setup_multiple_pads(apx4devkit_pads, |
211 | ARRAY_SIZE(apx4devkit_pads)); | 213 | ARRAY_SIZE(apx4devkit_pads)); |
212 | 214 | ||
diff --git a/arch/arm/mach-mxs/mach-m28evk.c b/arch/arm/mach-mxs/mach-m28evk.c index 06d79963611c..4c00c879b893 100644 --- a/arch/arm/mach-mxs/mach-m28evk.c +++ b/arch/arm/mach-mxs/mach-m28evk.c | |||
@@ -319,6 +319,8 @@ static struct mxs_mmc_platform_data m28evk_mmc_pdata[] __initdata = { | |||
319 | 319 | ||
320 | static void __init m28evk_init(void) | 320 | static void __init m28evk_init(void) |
321 | { | 321 | { |
322 | mx28_soc_init(); | ||
323 | |||
322 | mxs_iomux_setup_multiple_pads(m28evk_pads, ARRAY_SIZE(m28evk_pads)); | 324 | mxs_iomux_setup_multiple_pads(m28evk_pads, ARRAY_SIZE(m28evk_pads)); |
323 | 325 | ||
324 | mx28_add_duart(); | 326 | mx28_add_duart(); |
diff --git a/arch/arm/mach-mxs/mach-mx23evk.c b/arch/arm/mach-mxs/mach-mx23evk.c index 5ea1c57d2606..e7272a41939d 100644 --- a/arch/arm/mach-mxs/mach-mx23evk.c +++ b/arch/arm/mach-mxs/mach-mx23evk.c | |||
@@ -141,6 +141,8 @@ static void __init mx23evk_init(void) | |||
141 | { | 141 | { |
142 | int ret; | 142 | int ret; |
143 | 143 | ||
144 | mx23_soc_init(); | ||
145 | |||
144 | mxs_iomux_setup_multiple_pads(mx23evk_pads, ARRAY_SIZE(mx23evk_pads)); | 146 | mxs_iomux_setup_multiple_pads(mx23evk_pads, ARRAY_SIZE(mx23evk_pads)); |
145 | 147 | ||
146 | mx23_add_duart(); | 148 | mx23_add_duart(); |
diff --git a/arch/arm/mach-mxs/mach-mx28evk.c b/arch/arm/mach-mxs/mach-mx28evk.c index e386c142f93c..dafd48e86c8c 100644 --- a/arch/arm/mach-mxs/mach-mx28evk.c +++ b/arch/arm/mach-mxs/mach-mx28evk.c | |||
@@ -226,7 +226,7 @@ static void __init mx28evk_fec_reset(void) | |||
226 | struct clk *clk; | 226 | struct clk *clk; |
227 | 227 | ||
228 | /* Enable fec phy clock */ | 228 | /* Enable fec phy clock */ |
229 | clk = clk_get_sys("pll2", NULL); | 229 | clk = clk_get_sys("enet_out", NULL); |
230 | if (!IS_ERR(clk)) | 230 | if (!IS_ERR(clk)) |
231 | clk_prepare_enable(clk); | 231 | clk_prepare_enable(clk); |
232 | 232 | ||
@@ -413,6 +413,8 @@ static void __init mx28evk_init(void) | |||
413 | { | 413 | { |
414 | int ret; | 414 | int ret; |
415 | 415 | ||
416 | mx28_soc_init(); | ||
417 | |||
416 | mxs_iomux_setup_multiple_pads(mx28evk_pads, ARRAY_SIZE(mx28evk_pads)); | 418 | mxs_iomux_setup_multiple_pads(mx28evk_pads, ARRAY_SIZE(mx28evk_pads)); |
417 | 419 | ||
418 | mx28_add_duart(); | 420 | mx28_add_duart(); |
diff --git a/arch/arm/mach-mxs/mach-stmp378x_devb.c b/arch/arm/mach-mxs/mach-stmp378x_devb.c index a626c07b8713..6548965e4a76 100644 --- a/arch/arm/mach-mxs/mach-stmp378x_devb.c +++ b/arch/arm/mach-mxs/mach-stmp378x_devb.c | |||
@@ -85,6 +85,8 @@ static void __init stmp378x_dvb_init(void) | |||
85 | { | 85 | { |
86 | int ret; | 86 | int ret; |
87 | 87 | ||
88 | mx23_soc_init(); | ||
89 | |||
88 | mxs_iomux_setup_multiple_pads(stmp378x_dvb_pads, | 90 | mxs_iomux_setup_multiple_pads(stmp378x_dvb_pads, |
89 | ARRAY_SIZE(stmp378x_dvb_pads)); | 91 | ARRAY_SIZE(stmp378x_dvb_pads)); |
90 | 92 | ||
diff --git a/arch/arm/mach-mxs/mach-tx28.c b/arch/arm/mach-mxs/mach-tx28.c index 2c0862e655ee..8837029de1a4 100644 --- a/arch/arm/mach-mxs/mach-tx28.c +++ b/arch/arm/mach-mxs/mach-tx28.c | |||
@@ -146,6 +146,8 @@ static struct mxs_mmc_platform_data tx28_mmc0_pdata __initdata = { | |||
146 | 146 | ||
147 | static void __init tx28_stk5v3_init(void) | 147 | static void __init tx28_stk5v3_init(void) |
148 | { | 148 | { |
149 | mx28_soc_init(); | ||
150 | |||
149 | mxs_iomux_setup_multiple_pads(tx28_stk5v3_pads, | 151 | mxs_iomux_setup_multiple_pads(tx28_stk5v3_pads, |
150 | ARRAY_SIZE(tx28_stk5v3_pads)); | 152 | ARRAY_SIZE(tx28_stk5v3_pads)); |
151 | 153 | ||
diff --git a/arch/arm/mach-mxs/mm.c b/arch/arm/mach-mxs/mm.c index 50af5ceebf6d..67a384edcf5b 100644 --- a/arch/arm/mach-mxs/mm.c +++ b/arch/arm/mach-mxs/mm.c | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/mm.h> | 14 | #include <linux/mm.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/pinctrl/machine.h> | ||
16 | 17 | ||
17 | #include <asm/mach/map.h> | 18 | #include <asm/mach/map.h> |
18 | 19 | ||
@@ -61,3 +62,13 @@ void __init mx28_init_irq(void) | |||
61 | { | 62 | { |
62 | icoll_init_irq(); | 63 | icoll_init_irq(); |
63 | } | 64 | } |
65 | |||
66 | void __init mx23_soc_init(void) | ||
67 | { | ||
68 | pinctrl_provide_dummies(); | ||
69 | } | ||
70 | |||
71 | void __init mx28_soc_init(void) | ||
72 | { | ||
73 | pinctrl_provide_dummies(); | ||
74 | } | ||
diff --git a/arch/arm/mach-mxs/regs-clkctrl-mx23.h b/arch/arm/mach-mxs/regs-clkctrl-mx23.h deleted file mode 100644 index 0ea5c9d0e2b2..000000000000 --- a/arch/arm/mach-mxs/regs-clkctrl-mx23.h +++ /dev/null | |||
@@ -1,331 +0,0 @@ | |||
1 | /* | ||
2 | * Freescale CLKCTRL Register Definitions | ||
3 | * | ||
4 | * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved. | ||
5 | * Copyright 2008-2010 Freescale Semiconductor, Inc. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | * This file is created by xml file. Don't Edit it. | ||
22 | * | ||
23 | * Xml Revision: 1.48 | ||
24 | * Template revision: 26195 | ||
25 | */ | ||
26 | |||
27 | #ifndef __REGS_CLKCTRL_MX23_H__ | ||
28 | #define __REGS_CLKCTRL_MX23_H__ | ||
29 | |||
30 | |||
31 | #define HW_CLKCTRL_PLLCTRL0 (0x00000000) | ||
32 | #define HW_CLKCTRL_PLLCTRL0_SET (0x00000004) | ||
33 | #define HW_CLKCTRL_PLLCTRL0_CLR (0x00000008) | ||
34 | #define HW_CLKCTRL_PLLCTRL0_TOG (0x0000000c) | ||
35 | |||
36 | #define BP_CLKCTRL_PLLCTRL0_LFR_SEL 28 | ||
37 | #define BM_CLKCTRL_PLLCTRL0_LFR_SEL 0x30000000 | ||
38 | #define BF_CLKCTRL_PLLCTRL0_LFR_SEL(v) \ | ||
39 | (((v) << 28) & BM_CLKCTRL_PLLCTRL0_LFR_SEL) | ||
40 | #define BV_CLKCTRL_PLLCTRL0_LFR_SEL__DEFAULT 0x0 | ||
41 | #define BV_CLKCTRL_PLLCTRL0_LFR_SEL__TIMES_2 0x1 | ||
42 | #define BV_CLKCTRL_PLLCTRL0_LFR_SEL__TIMES_05 0x2 | ||
43 | #define BV_CLKCTRL_PLLCTRL0_LFR_SEL__UNDEFINED 0x3 | ||
44 | #define BP_CLKCTRL_PLLCTRL0_CP_SEL 24 | ||
45 | #define BM_CLKCTRL_PLLCTRL0_CP_SEL 0x03000000 | ||
46 | #define BF_CLKCTRL_PLLCTRL0_CP_SEL(v) \ | ||
47 | (((v) << 24) & BM_CLKCTRL_PLLCTRL0_CP_SEL) | ||
48 | #define BV_CLKCTRL_PLLCTRL0_CP_SEL__DEFAULT 0x0 | ||
49 | #define BV_CLKCTRL_PLLCTRL0_CP_SEL__TIMES_2 0x1 | ||
50 | #define BV_CLKCTRL_PLLCTRL0_CP_SEL__TIMES_05 0x2 | ||
51 | #define BV_CLKCTRL_PLLCTRL0_CP_SEL__UNDEFINED 0x3 | ||
52 | #define BP_CLKCTRL_PLLCTRL0_DIV_SEL 20 | ||
53 | #define BM_CLKCTRL_PLLCTRL0_DIV_SEL 0x00300000 | ||
54 | #define BF_CLKCTRL_PLLCTRL0_DIV_SEL(v) \ | ||
55 | (((v) << 20) & BM_CLKCTRL_PLLCTRL0_DIV_SEL) | ||
56 | #define BV_CLKCTRL_PLLCTRL0_DIV_SEL__DEFAULT 0x0 | ||
57 | #define BV_CLKCTRL_PLLCTRL0_DIV_SEL__LOWER 0x1 | ||
58 | #define BV_CLKCTRL_PLLCTRL0_DIV_SEL__LOWEST 0x2 | ||
59 | #define BV_CLKCTRL_PLLCTRL0_DIV_SEL__UNDEFINED 0x3 | ||
60 | #define BM_CLKCTRL_PLLCTRL0_EN_USB_CLKS 0x00040000 | ||
61 | #define BM_CLKCTRL_PLLCTRL0_POWER 0x00010000 | ||
62 | |||
63 | #define HW_CLKCTRL_PLLCTRL1 (0x00000010) | ||
64 | |||
65 | #define BM_CLKCTRL_PLLCTRL1_LOCK 0x80000000 | ||
66 | #define BM_CLKCTRL_PLLCTRL1_FORCE_LOCK 0x40000000 | ||
67 | #define BP_CLKCTRL_PLLCTRL1_LOCK_COUNT 0 | ||
68 | #define BM_CLKCTRL_PLLCTRL1_LOCK_COUNT 0x0000FFFF | ||
69 | #define BF_CLKCTRL_PLLCTRL1_LOCK_COUNT(v) \ | ||
70 | (((v) << 0) & BM_CLKCTRL_PLLCTRL1_LOCK_COUNT) | ||
71 | |||
72 | #define HW_CLKCTRL_CPU (0x00000020) | ||
73 | #define HW_CLKCTRL_CPU_SET (0x00000024) | ||
74 | #define HW_CLKCTRL_CPU_CLR (0x00000028) | ||
75 | #define HW_CLKCTRL_CPU_TOG (0x0000002c) | ||
76 | |||
77 | #define BM_CLKCTRL_CPU_BUSY_REF_XTAL 0x20000000 | ||
78 | #define BM_CLKCTRL_CPU_BUSY_REF_CPU 0x10000000 | ||
79 | #define BM_CLKCTRL_CPU_DIV_XTAL_FRAC_EN 0x04000000 | ||
80 | #define BP_CLKCTRL_CPU_DIV_XTAL 16 | ||
81 | #define BM_CLKCTRL_CPU_DIV_XTAL 0x03FF0000 | ||
82 | #define BF_CLKCTRL_CPU_DIV_XTAL(v) \ | ||
83 | (((v) << 16) & BM_CLKCTRL_CPU_DIV_XTAL) | ||
84 | #define BM_CLKCTRL_CPU_INTERRUPT_WAIT 0x00001000 | ||
85 | #define BM_CLKCTRL_CPU_DIV_CPU_FRAC_EN 0x00000400 | ||
86 | #define BP_CLKCTRL_CPU_DIV_CPU 0 | ||
87 | #define BM_CLKCTRL_CPU_DIV_CPU 0x0000003F | ||
88 | #define BF_CLKCTRL_CPU_DIV_CPU(v) \ | ||
89 | (((v) << 0) & BM_CLKCTRL_CPU_DIV_CPU) | ||
90 | |||
91 | #define HW_CLKCTRL_HBUS (0x00000030) | ||
92 | #define HW_CLKCTRL_HBUS_SET (0x00000034) | ||
93 | #define HW_CLKCTRL_HBUS_CLR (0x00000038) | ||
94 | #define HW_CLKCTRL_HBUS_TOG (0x0000003c) | ||
95 | |||
96 | #define BM_CLKCTRL_HBUS_BUSY 0x20000000 | ||
97 | #define BM_CLKCTRL_HBUS_DCP_AS_ENABLE 0x10000000 | ||
98 | #define BM_CLKCTRL_HBUS_PXP_AS_ENABLE 0x08000000 | ||
99 | #define BM_CLKCTRL_HBUS_APBHDMA_AS_ENABLE 0x04000000 | ||
100 | #define BM_CLKCTRL_HBUS_APBXDMA_AS_ENABLE 0x02000000 | ||
101 | #define BM_CLKCTRL_HBUS_TRAFFIC_JAM_AS_ENABLE 0x01000000 | ||
102 | #define BM_CLKCTRL_HBUS_TRAFFIC_AS_ENABLE 0x00800000 | ||
103 | #define BM_CLKCTRL_HBUS_CPU_DATA_AS_ENABLE 0x00400000 | ||
104 | #define BM_CLKCTRL_HBUS_CPU_INSTR_AS_ENABLE 0x00200000 | ||
105 | #define BM_CLKCTRL_HBUS_AUTO_SLOW_MODE 0x00100000 | ||
106 | #define BP_CLKCTRL_HBUS_SLOW_DIV 16 | ||
107 | #define BM_CLKCTRL_HBUS_SLOW_DIV 0x00070000 | ||
108 | #define BF_CLKCTRL_HBUS_SLOW_DIV(v) \ | ||
109 | (((v) << 16) & BM_CLKCTRL_HBUS_SLOW_DIV) | ||
110 | #define BV_CLKCTRL_HBUS_SLOW_DIV__BY1 0x0 | ||
111 | #define BV_CLKCTRL_HBUS_SLOW_DIV__BY2 0x1 | ||
112 | #define BV_CLKCTRL_HBUS_SLOW_DIV__BY4 0x2 | ||
113 | #define BV_CLKCTRL_HBUS_SLOW_DIV__BY8 0x3 | ||
114 | #define BV_CLKCTRL_HBUS_SLOW_DIV__BY16 0x4 | ||
115 | #define BV_CLKCTRL_HBUS_SLOW_DIV__BY32 0x5 | ||
116 | #define BM_CLKCTRL_HBUS_DIV_FRAC_EN 0x00000020 | ||
117 | #define BP_CLKCTRL_HBUS_DIV 0 | ||
118 | #define BM_CLKCTRL_HBUS_DIV 0x0000001F | ||
119 | #define BF_CLKCTRL_HBUS_DIV(v) \ | ||
120 | (((v) << 0) & BM_CLKCTRL_HBUS_DIV) | ||
121 | |||
122 | #define HW_CLKCTRL_XBUS (0x00000040) | ||
123 | |||
124 | #define BM_CLKCTRL_XBUS_BUSY 0x80000000 | ||
125 | #define BM_CLKCTRL_XBUS_DIV_FRAC_EN 0x00000400 | ||
126 | #define BP_CLKCTRL_XBUS_DIV 0 | ||
127 | #define BM_CLKCTRL_XBUS_DIV 0x000003FF | ||
128 | #define BF_CLKCTRL_XBUS_DIV(v) \ | ||
129 | (((v) << 0) & BM_CLKCTRL_XBUS_DIV) | ||
130 | |||
131 | #define HW_CLKCTRL_XTAL (0x00000050) | ||
132 | #define HW_CLKCTRL_XTAL_SET (0x00000054) | ||
133 | #define HW_CLKCTRL_XTAL_CLR (0x00000058) | ||
134 | #define HW_CLKCTRL_XTAL_TOG (0x0000005c) | ||
135 | |||
136 | #define BP_CLKCTRL_XTAL_UART_CLK_GATE 31 | ||
137 | #define BM_CLKCTRL_XTAL_UART_CLK_GATE 0x80000000 | ||
138 | #define BP_CLKCTRL_XTAL_FILT_CLK24M_GATE 30 | ||
139 | #define BM_CLKCTRL_XTAL_FILT_CLK24M_GATE 0x40000000 | ||
140 | #define BP_CLKCTRL_XTAL_PWM_CLK24M_GATE 29 | ||
141 | #define BM_CLKCTRL_XTAL_PWM_CLK24M_GATE 0x20000000 | ||
142 | #define BM_CLKCTRL_XTAL_DRI_CLK24M_GATE 0x10000000 | ||
143 | #define BM_CLKCTRL_XTAL_DIGCTRL_CLK1M_GATE 0x08000000 | ||
144 | #define BP_CLKCTRL_XTAL_TIMROT_CLK32K_GATE 26 | ||
145 | #define BM_CLKCTRL_XTAL_TIMROT_CLK32K_GATE 0x04000000 | ||
146 | #define BP_CLKCTRL_XTAL_DIV_UART 0 | ||
147 | #define BM_CLKCTRL_XTAL_DIV_UART 0x00000003 | ||
148 | #define BF_CLKCTRL_XTAL_DIV_UART(v) \ | ||
149 | (((v) << 0) & BM_CLKCTRL_XTAL_DIV_UART) | ||
150 | |||
151 | #define HW_CLKCTRL_PIX (0x00000060) | ||
152 | |||
153 | #define BP_CLKCTRL_PIX_CLKGATE 31 | ||
154 | #define BM_CLKCTRL_PIX_CLKGATE 0x80000000 | ||
155 | #define BM_CLKCTRL_PIX_BUSY 0x20000000 | ||
156 | #define BM_CLKCTRL_PIX_DIV_FRAC_EN 0x00001000 | ||
157 | #define BP_CLKCTRL_PIX_DIV 0 | ||
158 | #define BM_CLKCTRL_PIX_DIV 0x00000FFF | ||
159 | #define BF_CLKCTRL_PIX_DIV(v) \ | ||
160 | (((v) << 0) & BM_CLKCTRL_PIX_DIV) | ||
161 | |||
162 | #define HW_CLKCTRL_SSP (0x00000070) | ||
163 | |||
164 | #define BP_CLKCTRL_SSP_CLKGATE 31 | ||
165 | #define BM_CLKCTRL_SSP_CLKGATE 0x80000000 | ||
166 | #define BM_CLKCTRL_SSP_BUSY 0x20000000 | ||
167 | #define BM_CLKCTRL_SSP_DIV_FRAC_EN 0x00000200 | ||
168 | #define BP_CLKCTRL_SSP_DIV 0 | ||
169 | #define BM_CLKCTRL_SSP_DIV 0x000001FF | ||
170 | #define BF_CLKCTRL_SSP_DIV(v) \ | ||
171 | (((v) << 0) & BM_CLKCTRL_SSP_DIV) | ||
172 | |||
173 | #define HW_CLKCTRL_GPMI (0x00000080) | ||
174 | |||
175 | #define BP_CLKCTRL_GPMI_CLKGATE 31 | ||
176 | #define BM_CLKCTRL_GPMI_CLKGATE 0x80000000 | ||
177 | #define BM_CLKCTRL_GPMI_BUSY 0x20000000 | ||
178 | #define BM_CLKCTRL_GPMI_DIV_FRAC_EN 0x00000400 | ||
179 | #define BP_CLKCTRL_GPMI_DIV 0 | ||
180 | #define BM_CLKCTRL_GPMI_DIV 0x000003FF | ||
181 | #define BF_CLKCTRL_GPMI_DIV(v) \ | ||
182 | (((v) << 0) & BM_CLKCTRL_GPMI_DIV) | ||
183 | |||
184 | #define HW_CLKCTRL_SPDIF (0x00000090) | ||
185 | |||
186 | #define BM_CLKCTRL_SPDIF_CLKGATE 0x80000000 | ||
187 | |||
188 | #define HW_CLKCTRL_EMI (0x000000a0) | ||
189 | |||
190 | #define BP_CLKCTRL_EMI_CLKGATE 31 | ||
191 | #define BM_CLKCTRL_EMI_CLKGATE 0x80000000 | ||
192 | #define BM_CLKCTRL_EMI_SYNC_MODE_EN 0x40000000 | ||
193 | #define BM_CLKCTRL_EMI_BUSY_REF_XTAL 0x20000000 | ||
194 | #define BM_CLKCTRL_EMI_BUSY_REF_EMI 0x10000000 | ||
195 | #define BM_CLKCTRL_EMI_BUSY_REF_CPU 0x08000000 | ||
196 | #define BM_CLKCTRL_EMI_BUSY_SYNC_MODE 0x04000000 | ||
197 | #define BM_CLKCTRL_EMI_BUSY_DCC_RESYNC 0x00020000 | ||
198 | #define BM_CLKCTRL_EMI_DCC_RESYNC_ENABLE 0x00010000 | ||
199 | #define BP_CLKCTRL_EMI_DIV_XTAL 8 | ||
200 | #define BM_CLKCTRL_EMI_DIV_XTAL 0x00000F00 | ||
201 | #define BF_CLKCTRL_EMI_DIV_XTAL(v) \ | ||
202 | (((v) << 8) & BM_CLKCTRL_EMI_DIV_XTAL) | ||
203 | #define BP_CLKCTRL_EMI_DIV_EMI 0 | ||
204 | #define BM_CLKCTRL_EMI_DIV_EMI 0x0000003F | ||
205 | #define BF_CLKCTRL_EMI_DIV_EMI(v) \ | ||
206 | (((v) << 0) & BM_CLKCTRL_EMI_DIV_EMI) | ||
207 | |||
208 | #define HW_CLKCTRL_IR (0x000000b0) | ||
209 | |||
210 | #define BM_CLKCTRL_IR_CLKGATE 0x80000000 | ||
211 | #define BM_CLKCTRL_IR_AUTO_DIV 0x20000000 | ||
212 | #define BM_CLKCTRL_IR_IR_BUSY 0x10000000 | ||
213 | #define BM_CLKCTRL_IR_IROV_BUSY 0x08000000 | ||
214 | #define BP_CLKCTRL_IR_IROV_DIV 16 | ||
215 | #define BM_CLKCTRL_IR_IROV_DIV 0x01FF0000 | ||
216 | #define BF_CLKCTRL_IR_IROV_DIV(v) \ | ||
217 | (((v) << 16) & BM_CLKCTRL_IR_IROV_DIV) | ||
218 | #define BP_CLKCTRL_IR_IR_DIV 0 | ||
219 | #define BM_CLKCTRL_IR_IR_DIV 0x000003FF | ||
220 | #define BF_CLKCTRL_IR_IR_DIV(v) \ | ||
221 | (((v) << 0) & BM_CLKCTRL_IR_IR_DIV) | ||
222 | |||
223 | #define HW_CLKCTRL_SAIF (0x000000c0) | ||
224 | |||
225 | #define BM_CLKCTRL_SAIF_CLKGATE 0x80000000 | ||
226 | #define BM_CLKCTRL_SAIF_BUSY 0x20000000 | ||
227 | #define BM_CLKCTRL_SAIF_DIV_FRAC_EN 0x00010000 | ||
228 | #define BP_CLKCTRL_SAIF_DIV 0 | ||
229 | #define BM_CLKCTRL_SAIF_DIV 0x0000FFFF | ||
230 | #define BF_CLKCTRL_SAIF_DIV(v) \ | ||
231 | (((v) << 0) & BM_CLKCTRL_SAIF_DIV) | ||
232 | |||
233 | #define HW_CLKCTRL_TV (0x000000d0) | ||
234 | |||
235 | #define BM_CLKCTRL_TV_CLK_TV108M_GATE 0x80000000 | ||
236 | #define BM_CLKCTRL_TV_CLK_TV_GATE 0x40000000 | ||
237 | |||
238 | #define HW_CLKCTRL_ETM (0x000000e0) | ||
239 | |||
240 | #define BM_CLKCTRL_ETM_CLKGATE 0x80000000 | ||
241 | #define BM_CLKCTRL_ETM_BUSY 0x20000000 | ||
242 | #define BM_CLKCTRL_ETM_DIV_FRAC_EN 0x00000040 | ||
243 | #define BP_CLKCTRL_ETM_DIV 0 | ||
244 | #define BM_CLKCTRL_ETM_DIV 0x0000003F | ||
245 | #define BF_CLKCTRL_ETM_DIV(v) \ | ||
246 | (((v) << 0) & BM_CLKCTRL_ETM_DIV) | ||
247 | |||
248 | #define HW_CLKCTRL_FRAC (0x000000f0) | ||
249 | #define HW_CLKCTRL_FRAC_SET (0x000000f4) | ||
250 | #define HW_CLKCTRL_FRAC_CLR (0x000000f8) | ||
251 | #define HW_CLKCTRL_FRAC_TOG (0x000000fc) | ||
252 | |||
253 | #define BP_CLKCTRL_FRAC_CLKGATEIO 31 | ||
254 | #define BM_CLKCTRL_FRAC_CLKGATEIO 0x80000000 | ||
255 | #define BM_CLKCTRL_FRAC_IO_STABLE 0x40000000 | ||
256 | #define BP_CLKCTRL_FRAC_IOFRAC 24 | ||
257 | #define BM_CLKCTRL_FRAC_IOFRAC 0x3F000000 | ||
258 | #define BF_CLKCTRL_FRAC_IOFRAC(v) \ | ||
259 | (((v) << 24) & BM_CLKCTRL_FRAC_IOFRAC) | ||
260 | #define BP_CLKCTRL_FRAC_CLKGATEPIX 23 | ||
261 | #define BM_CLKCTRL_FRAC_CLKGATEPIX 0x00800000 | ||
262 | #define BM_CLKCTRL_FRAC_PIX_STABLE 0x00400000 | ||
263 | #define BP_CLKCTRL_FRAC_PIXFRAC 16 | ||
264 | #define BM_CLKCTRL_FRAC_PIXFRAC 0x003F0000 | ||
265 | #define BF_CLKCTRL_FRAC_PIXFRAC(v) \ | ||
266 | (((v) << 16) & BM_CLKCTRL_FRAC_PIXFRAC) | ||
267 | #define BP_CLKCTRL_FRAC_CLKGATEEMI 15 | ||
268 | #define BM_CLKCTRL_FRAC_CLKGATEEMI 0x00008000 | ||
269 | #define BM_CLKCTRL_FRAC_EMI_STABLE 0x00004000 | ||
270 | #define BP_CLKCTRL_FRAC_EMIFRAC 8 | ||
271 | #define BM_CLKCTRL_FRAC_EMIFRAC 0x00003F00 | ||
272 | #define BF_CLKCTRL_FRAC_EMIFRAC(v) \ | ||
273 | (((v) << 8) & BM_CLKCTRL_FRAC_EMIFRAC) | ||
274 | #define BP_CLKCTRL_FRAC_CLKGATECPU 7 | ||
275 | #define BM_CLKCTRL_FRAC_CLKGATECPU 0x00000080 | ||
276 | #define BM_CLKCTRL_FRAC_CPU_STABLE 0x00000040 | ||
277 | #define BP_CLKCTRL_FRAC_CPUFRAC 0 | ||
278 | #define BM_CLKCTRL_FRAC_CPUFRAC 0x0000003F | ||
279 | #define BF_CLKCTRL_FRAC_CPUFRAC(v) \ | ||
280 | (((v) << 0) & BM_CLKCTRL_FRAC_CPUFRAC) | ||
281 | |||
282 | #define HW_CLKCTRL_FRAC1 (0x00000100) | ||
283 | #define HW_CLKCTRL_FRAC1_SET (0x00000104) | ||
284 | #define HW_CLKCTRL_FRAC1_CLR (0x00000108) | ||
285 | #define HW_CLKCTRL_FRAC1_TOG (0x0000010c) | ||
286 | |||
287 | #define BM_CLKCTRL_FRAC1_CLKGATEVID 0x80000000 | ||
288 | #define BM_CLKCTRL_FRAC1_VID_STABLE 0x40000000 | ||
289 | |||
290 | #define HW_CLKCTRL_CLKSEQ (0x00000110) | ||
291 | #define HW_CLKCTRL_CLKSEQ_SET (0x00000114) | ||
292 | #define HW_CLKCTRL_CLKSEQ_CLR (0x00000118) | ||
293 | #define HW_CLKCTRL_CLKSEQ_TOG (0x0000011c) | ||
294 | |||
295 | #define BM_CLKCTRL_CLKSEQ_BYPASS_ETM 0x00000100 | ||
296 | #define BM_CLKCTRL_CLKSEQ_BYPASS_CPU 0x00000080 | ||
297 | #define BM_CLKCTRL_CLKSEQ_BYPASS_EMI 0x00000040 | ||
298 | #define BM_CLKCTRL_CLKSEQ_BYPASS_SSP 0x00000020 | ||
299 | #define BM_CLKCTRL_CLKSEQ_BYPASS_GPMI 0x00000010 | ||
300 | #define BM_CLKCTRL_CLKSEQ_BYPASS_IR 0x00000008 | ||
301 | #define BM_CLKCTRL_CLKSEQ_BYPASS_PIX 0x00000002 | ||
302 | #define BM_CLKCTRL_CLKSEQ_BYPASS_SAIF 0x00000001 | ||
303 | |||
304 | #define HW_CLKCTRL_RESET (0x00000120) | ||
305 | |||
306 | #define BM_CLKCTRL_RESET_CHIP 0x00000002 | ||
307 | #define BM_CLKCTRL_RESET_DIG 0x00000001 | ||
308 | |||
309 | #define HW_CLKCTRL_STATUS (0x00000130) | ||
310 | |||
311 | #define BP_CLKCTRL_STATUS_CPU_LIMIT 30 | ||
312 | #define BM_CLKCTRL_STATUS_CPU_LIMIT 0xC0000000 | ||
313 | #define BF_CLKCTRL_STATUS_CPU_LIMIT(v) \ | ||
314 | (((v) << 30) & BM_CLKCTRL_STATUS_CPU_LIMIT) | ||
315 | |||
316 | #define HW_CLKCTRL_VERSION (0x00000140) | ||
317 | |||
318 | #define BP_CLKCTRL_VERSION_MAJOR 24 | ||
319 | #define BM_CLKCTRL_VERSION_MAJOR 0xFF000000 | ||
320 | #define BF_CLKCTRL_VERSION_MAJOR(v) \ | ||
321 | (((v) << 24) & BM_CLKCTRL_VERSION_MAJOR) | ||
322 | #define BP_CLKCTRL_VERSION_MINOR 16 | ||
323 | #define BM_CLKCTRL_VERSION_MINOR 0x00FF0000 | ||
324 | #define BF_CLKCTRL_VERSION_MINOR(v) \ | ||
325 | (((v) << 16) & BM_CLKCTRL_VERSION_MINOR) | ||
326 | #define BP_CLKCTRL_VERSION_STEP 0 | ||
327 | #define BM_CLKCTRL_VERSION_STEP 0x0000FFFF | ||
328 | #define BF_CLKCTRL_VERSION_STEP(v) \ | ||
329 | (((v) << 0) & BM_CLKCTRL_VERSION_STEP) | ||
330 | |||
331 | #endif /* __REGS_CLKCTRL_MX23_H__ */ | ||
diff --git a/arch/arm/mach-mxs/regs-clkctrl-mx28.h b/arch/arm/mach-mxs/regs-clkctrl-mx28.h deleted file mode 100644 index 7d1b061d7943..000000000000 --- a/arch/arm/mach-mxs/regs-clkctrl-mx28.h +++ /dev/null | |||
@@ -1,486 +0,0 @@ | |||
1 | /* | ||
2 | * Freescale CLKCTRL Register Definitions | ||
3 | * | ||
4 | * Copyright 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | * | ||
20 | * This file is created by xml file. Don't Edit it. | ||
21 | * | ||
22 | * Xml Revision: 1.48 | ||
23 | * Template revision: 26195 | ||
24 | */ | ||
25 | |||
26 | #ifndef __REGS_CLKCTRL_MX28_H__ | ||
27 | #define __REGS_CLKCTRL_MX28_H__ | ||
28 | |||
29 | #define HW_CLKCTRL_PLL0CTRL0 (0x00000000) | ||
30 | #define HW_CLKCTRL_PLL0CTRL0_SET (0x00000004) | ||
31 | #define HW_CLKCTRL_PLL0CTRL0_CLR (0x00000008) | ||
32 | #define HW_CLKCTRL_PLL0CTRL0_TOG (0x0000000c) | ||
33 | |||
34 | #define BP_CLKCTRL_PLL0CTRL0_LFR_SEL 28 | ||
35 | #define BM_CLKCTRL_PLL0CTRL0_LFR_SEL 0x30000000 | ||
36 | #define BF_CLKCTRL_PLL0CTRL0_LFR_SEL(v) \ | ||
37 | (((v) << 28) & BM_CLKCTRL_PLL0CTRL0_LFR_SEL) | ||
38 | #define BV_CLKCTRL_PLL0CTRL0_LFR_SEL__DEFAULT 0x0 | ||
39 | #define BV_CLKCTRL_PLL0CTRL0_LFR_SEL__TIMES_2 0x1 | ||
40 | #define BV_CLKCTRL_PLL0CTRL0_LFR_SEL__TIMES_05 0x2 | ||
41 | #define BV_CLKCTRL_PLL0CTRL0_LFR_SEL__UNDEFINED 0x3 | ||
42 | #define BP_CLKCTRL_PLL0CTRL0_CP_SEL 24 | ||
43 | #define BM_CLKCTRL_PLL0CTRL0_CP_SEL 0x03000000 | ||
44 | #define BF_CLKCTRL_PLL0CTRL0_CP_SEL(v) \ | ||
45 | (((v) << 24) & BM_CLKCTRL_PLL0CTRL0_CP_SEL) | ||
46 | #define BV_CLKCTRL_PLL0CTRL0_CP_SEL__DEFAULT 0x0 | ||
47 | #define BV_CLKCTRL_PLL0CTRL0_CP_SEL__TIMES_2 0x1 | ||
48 | #define BV_CLKCTRL_PLL0CTRL0_CP_SEL__TIMES_05 0x2 | ||
49 | #define BV_CLKCTRL_PLL0CTRL0_CP_SEL__UNDEFINED 0x3 | ||
50 | #define BP_CLKCTRL_PLL0CTRL0_DIV_SEL 20 | ||
51 | #define BM_CLKCTRL_PLL0CTRL0_DIV_SEL 0x00300000 | ||
52 | #define BF_CLKCTRL_PLL0CTRL0_DIV_SEL(v) \ | ||
53 | (((v) << 20) & BM_CLKCTRL_PLL0CTRL0_DIV_SEL) | ||
54 | #define BV_CLKCTRL_PLL0CTRL0_DIV_SEL__DEFAULT 0x0 | ||
55 | #define BV_CLKCTRL_PLL0CTRL0_DIV_SEL__LOWER 0x1 | ||
56 | #define BV_CLKCTRL_PLL0CTRL0_DIV_SEL__LOWEST 0x2 | ||
57 | #define BV_CLKCTRL_PLL0CTRL0_DIV_SEL__UNDEFINED 0x3 | ||
58 | #define BM_CLKCTRL_PLL0CTRL0_EN_USB_CLKS 0x00040000 | ||
59 | #define BM_CLKCTRL_PLL0CTRL0_POWER 0x00020000 | ||
60 | |||
61 | #define HW_CLKCTRL_PLL0CTRL1 (0x00000010) | ||
62 | |||
63 | #define BM_CLKCTRL_PLL0CTRL1_LOCK 0x80000000 | ||
64 | #define BM_CLKCTRL_PLL0CTRL1_FORCE_LOCK 0x40000000 | ||
65 | #define BP_CLKCTRL_PLL0CTRL1_LOCK_COUNT 0 | ||
66 | #define BM_CLKCTRL_PLL0CTRL1_LOCK_COUNT 0x0000FFFF | ||
67 | #define BF_CLKCTRL_PLL0CTRL1_LOCK_COUNT(v) \ | ||
68 | (((v) << 0) & BM_CLKCTRL_PLL0CTRL1_LOCK_COUNT) | ||
69 | |||
70 | #define HW_CLKCTRL_PLL1CTRL0 (0x00000020) | ||
71 | #define HW_CLKCTRL_PLL1CTRL0_SET (0x00000024) | ||
72 | #define HW_CLKCTRL_PLL1CTRL0_CLR (0x00000028) | ||
73 | #define HW_CLKCTRL_PLL1CTRL0_TOG (0x0000002c) | ||
74 | |||
75 | #define BM_CLKCTRL_PLL1CTRL0_CLKGATEEMI 0x80000000 | ||
76 | #define BP_CLKCTRL_PLL1CTRL0_LFR_SEL 28 | ||
77 | #define BM_CLKCTRL_PLL1CTRL0_LFR_SEL 0x30000000 | ||
78 | #define BF_CLKCTRL_PLL1CTRL0_LFR_SEL(v) \ | ||
79 | (((v) << 28) & BM_CLKCTRL_PLL1CTRL0_LFR_SEL) | ||
80 | #define BV_CLKCTRL_PLL1CTRL0_LFR_SEL__DEFAULT 0x0 | ||
81 | #define BV_CLKCTRL_PLL1CTRL0_LFR_SEL__TIMES_2 0x1 | ||
82 | #define BV_CLKCTRL_PLL1CTRL0_LFR_SEL__TIMES_05 0x2 | ||
83 | #define BV_CLKCTRL_PLL1CTRL0_LFR_SEL__UNDEFINED 0x3 | ||
84 | #define BP_CLKCTRL_PLL1CTRL0_CP_SEL 24 | ||
85 | #define BM_CLKCTRL_PLL1CTRL0_CP_SEL 0x03000000 | ||
86 | #define BF_CLKCTRL_PLL1CTRL0_CP_SEL(v) \ | ||
87 | (((v) << 24) & BM_CLKCTRL_PLL1CTRL0_CP_SEL) | ||
88 | #define BV_CLKCTRL_PLL1CTRL0_CP_SEL__DEFAULT 0x0 | ||
89 | #define BV_CLKCTRL_PLL1CTRL0_CP_SEL__TIMES_2 0x1 | ||
90 | #define BV_CLKCTRL_PLL1CTRL0_CP_SEL__TIMES_05 0x2 | ||
91 | #define BV_CLKCTRL_PLL1CTRL0_CP_SEL__UNDEFINED 0x3 | ||
92 | #define BP_CLKCTRL_PLL1CTRL0_DIV_SEL 20 | ||
93 | #define BM_CLKCTRL_PLL1CTRL0_DIV_SEL 0x00300000 | ||
94 | #define BF_CLKCTRL_PLL1CTRL0_DIV_SEL(v) \ | ||
95 | (((v) << 20) & BM_CLKCTRL_PLL1CTRL0_DIV_SEL) | ||
96 | #define BV_CLKCTRL_PLL1CTRL0_DIV_SEL__DEFAULT 0x0 | ||
97 | #define BV_CLKCTRL_PLL1CTRL0_DIV_SEL__LOWER 0x1 | ||
98 | #define BV_CLKCTRL_PLL1CTRL0_DIV_SEL__LOWEST 0x2 | ||
99 | #define BV_CLKCTRL_PLL1CTRL0_DIV_SEL__UNDEFINED 0x3 | ||
100 | #define BM_CLKCTRL_PLL1CTRL0_EN_USB_CLKS 0x00040000 | ||
101 | #define BM_CLKCTRL_PLL1CTRL0_POWER 0x00020000 | ||
102 | |||
103 | #define HW_CLKCTRL_PLL1CTRL1 (0x00000030) | ||
104 | |||
105 | #define BM_CLKCTRL_PLL1CTRL1_LOCK 0x80000000 | ||
106 | #define BM_CLKCTRL_PLL1CTRL1_FORCE_LOCK 0x40000000 | ||
107 | #define BP_CLKCTRL_PLL1CTRL1_LOCK_COUNT 0 | ||
108 | #define BM_CLKCTRL_PLL1CTRL1_LOCK_COUNT 0x0000FFFF | ||
109 | #define BF_CLKCTRL_PLL1CTRL1_LOCK_COUNT(v) \ | ||
110 | (((v) << 0) & BM_CLKCTRL_PLL1CTRL1_LOCK_COUNT) | ||
111 | |||
112 | #define HW_CLKCTRL_PLL2CTRL0 (0x00000040) | ||
113 | #define HW_CLKCTRL_PLL2CTRL0_SET (0x00000044) | ||
114 | #define HW_CLKCTRL_PLL2CTRL0_CLR (0x00000048) | ||
115 | #define HW_CLKCTRL_PLL2CTRL0_TOG (0x0000004c) | ||
116 | |||
117 | #define BM_CLKCTRL_PLL2CTRL0_CLKGATE 0x80000000 | ||
118 | #define BP_CLKCTRL_PLL2CTRL0_LFR_SEL 28 | ||
119 | #define BM_CLKCTRL_PLL2CTRL0_LFR_SEL 0x30000000 | ||
120 | #define BF_CLKCTRL_PLL2CTRL0_LFR_SEL(v) \ | ||
121 | (((v) << 28) & BM_CLKCTRL_PLL2CTRL0_LFR_SEL) | ||
122 | #define BM_CLKCTRL_PLL2CTRL0_HOLD_RING_OFF_B 0x04000000 | ||
123 | #define BP_CLKCTRL_PLL2CTRL0_CP_SEL 24 | ||
124 | #define BM_CLKCTRL_PLL2CTRL0_CP_SEL 0x03000000 | ||
125 | #define BF_CLKCTRL_PLL2CTRL0_CP_SEL(v) \ | ||
126 | (((v) << 24) & BM_CLKCTRL_PLL2CTRL0_CP_SEL) | ||
127 | #define BM_CLKCTRL_PLL2CTRL0_POWER 0x00800000 | ||
128 | |||
129 | #define HW_CLKCTRL_CPU (0x00000050) | ||
130 | #define HW_CLKCTRL_CPU_SET (0x00000054) | ||
131 | #define HW_CLKCTRL_CPU_CLR (0x00000058) | ||
132 | #define HW_CLKCTRL_CPU_TOG (0x0000005c) | ||
133 | |||
134 | #define BM_CLKCTRL_CPU_BUSY_REF_XTAL 0x20000000 | ||
135 | #define BM_CLKCTRL_CPU_BUSY_REF_CPU 0x10000000 | ||
136 | #define BM_CLKCTRL_CPU_DIV_XTAL_FRAC_EN 0x04000000 | ||
137 | #define BP_CLKCTRL_CPU_DIV_XTAL 16 | ||
138 | #define BM_CLKCTRL_CPU_DIV_XTAL 0x03FF0000 | ||
139 | #define BF_CLKCTRL_CPU_DIV_XTAL(v) \ | ||
140 | (((v) << 16) & BM_CLKCTRL_CPU_DIV_XTAL) | ||
141 | #define BM_CLKCTRL_CPU_INTERRUPT_WAIT 0x00001000 | ||
142 | #define BM_CLKCTRL_CPU_DIV_CPU_FRAC_EN 0x00000400 | ||
143 | #define BP_CLKCTRL_CPU_DIV_CPU 0 | ||
144 | #define BM_CLKCTRL_CPU_DIV_CPU 0x0000003F | ||
145 | #define BF_CLKCTRL_CPU_DIV_CPU(v) \ | ||
146 | (((v) << 0) & BM_CLKCTRL_CPU_DIV_CPU) | ||
147 | |||
148 | #define HW_CLKCTRL_HBUS (0x00000060) | ||
149 | #define HW_CLKCTRL_HBUS_SET (0x00000064) | ||
150 | #define HW_CLKCTRL_HBUS_CLR (0x00000068) | ||
151 | #define HW_CLKCTRL_HBUS_TOG (0x0000006c) | ||
152 | |||
153 | #define BM_CLKCTRL_HBUS_ASM_BUSY 0x80000000 | ||
154 | #define BM_CLKCTRL_HBUS_DCP_AS_ENABLE 0x40000000 | ||
155 | #define BM_CLKCTRL_HBUS_PXP_AS_ENABLE 0x20000000 | ||
156 | #define BM_CLKCTRL_HBUS_ASM_EMIPORT_AS_ENABLE 0x08000000 | ||
157 | #define BM_CLKCTRL_HBUS_APBHDMA_AS_ENABLE 0x04000000 | ||
158 | #define BM_CLKCTRL_HBUS_APBXDMA_AS_ENABLE 0x02000000 | ||
159 | #define BM_CLKCTRL_HBUS_TRAFFIC_JAM_AS_ENABLE 0x01000000 | ||
160 | #define BM_CLKCTRL_HBUS_TRAFFIC_AS_ENABLE 0x00800000 | ||
161 | #define BM_CLKCTRL_HBUS_CPU_DATA_AS_ENABLE 0x00400000 | ||
162 | #define BM_CLKCTRL_HBUS_CPU_INSTR_AS_ENABLE 0x00200000 | ||
163 | #define BM_CLKCTRL_HBUS_ASM_ENABLE 0x00100000 | ||
164 | #define BM_CLKCTRL_HBUS_AUTO_CLEAR_DIV_ENABLE 0x00080000 | ||
165 | #define BP_CLKCTRL_HBUS_SLOW_DIV 16 | ||
166 | #define BM_CLKCTRL_HBUS_SLOW_DIV 0x00070000 | ||
167 | #define BF_CLKCTRL_HBUS_SLOW_DIV(v) \ | ||
168 | (((v) << 16) & BM_CLKCTRL_HBUS_SLOW_DIV) | ||
169 | #define BV_CLKCTRL_HBUS_SLOW_DIV__BY1 0x0 | ||
170 | #define BV_CLKCTRL_HBUS_SLOW_DIV__BY2 0x1 | ||
171 | #define BV_CLKCTRL_HBUS_SLOW_DIV__BY4 0x2 | ||
172 | #define BV_CLKCTRL_HBUS_SLOW_DIV__BY8 0x3 | ||
173 | #define BV_CLKCTRL_HBUS_SLOW_DIV__BY16 0x4 | ||
174 | #define BV_CLKCTRL_HBUS_SLOW_DIV__BY32 0x5 | ||
175 | #define BM_CLKCTRL_HBUS_DIV_FRAC_EN 0x00000020 | ||
176 | #define BP_CLKCTRL_HBUS_DIV 0 | ||
177 | #define BM_CLKCTRL_HBUS_DIV 0x0000001F | ||
178 | #define BF_CLKCTRL_HBUS_DIV(v) \ | ||
179 | (((v) << 0) & BM_CLKCTRL_HBUS_DIV) | ||
180 | |||
181 | #define HW_CLKCTRL_XBUS (0x00000070) | ||
182 | |||
183 | #define BM_CLKCTRL_XBUS_BUSY 0x80000000 | ||
184 | #define BM_CLKCTRL_XBUS_AUTO_CLEAR_DIV_ENABLE 0x00000800 | ||
185 | #define BM_CLKCTRL_XBUS_DIV_FRAC_EN 0x00000400 | ||
186 | #define BP_CLKCTRL_XBUS_DIV 0 | ||
187 | #define BM_CLKCTRL_XBUS_DIV 0x000003FF | ||
188 | #define BF_CLKCTRL_XBUS_DIV(v) \ | ||
189 | (((v) << 0) & BM_CLKCTRL_XBUS_DIV) | ||
190 | |||
191 | #define HW_CLKCTRL_XTAL (0x00000080) | ||
192 | #define HW_CLKCTRL_XTAL_SET (0x00000084) | ||
193 | #define HW_CLKCTRL_XTAL_CLR (0x00000088) | ||
194 | #define HW_CLKCTRL_XTAL_TOG (0x0000008c) | ||
195 | |||
196 | #define BP_CLKCTRL_XTAL_UART_CLK_GATE 31 | ||
197 | #define BM_CLKCTRL_XTAL_UART_CLK_GATE 0x80000000 | ||
198 | #define BP_CLKCTRL_XTAL_PWM_CLK24M_GATE 29 | ||
199 | #define BM_CLKCTRL_XTAL_PWM_CLK24M_GATE 0x20000000 | ||
200 | #define BP_CLKCTRL_XTAL_TIMROT_CLK32K_GATE 26 | ||
201 | #define BM_CLKCTRL_XTAL_TIMROT_CLK32K_GATE 0x04000000 | ||
202 | #define BP_CLKCTRL_XTAL_DIV_UART 0 | ||
203 | #define BM_CLKCTRL_XTAL_DIV_UART 0x00000003 | ||
204 | #define BF_CLKCTRL_XTAL_DIV_UART(v) \ | ||
205 | (((v) << 0) & BM_CLKCTRL_XTAL_DIV_UART) | ||
206 | |||
207 | #define HW_CLKCTRL_SSP0 (0x00000090) | ||
208 | |||
209 | #define BP_CLKCTRL_SSP0_CLKGATE 31 | ||
210 | #define BM_CLKCTRL_SSP0_CLKGATE 0x80000000 | ||
211 | #define BM_CLKCTRL_SSP0_BUSY 0x20000000 | ||
212 | #define BM_CLKCTRL_SSP0_DIV_FRAC_EN 0x00000200 | ||
213 | #define BP_CLKCTRL_SSP0_DIV 0 | ||
214 | #define BM_CLKCTRL_SSP0_DIV 0x000001FF | ||
215 | #define BF_CLKCTRL_SSP0_DIV(v) \ | ||
216 | (((v) << 0) & BM_CLKCTRL_SSP0_DIV) | ||
217 | |||
218 | #define HW_CLKCTRL_SSP1 (0x000000a0) | ||
219 | |||
220 | #define BP_CLKCTRL_SSP1_CLKGATE 31 | ||
221 | #define BM_CLKCTRL_SSP1_CLKGATE 0x80000000 | ||
222 | #define BM_CLKCTRL_SSP1_BUSY 0x20000000 | ||
223 | #define BM_CLKCTRL_SSP1_DIV_FRAC_EN 0x00000200 | ||
224 | #define BP_CLKCTRL_SSP1_DIV 0 | ||
225 | #define BM_CLKCTRL_SSP1_DIV 0x000001FF | ||
226 | #define BF_CLKCTRL_SSP1_DIV(v) \ | ||
227 | (((v) << 0) & BM_CLKCTRL_SSP1_DIV) | ||
228 | |||
229 | #define HW_CLKCTRL_SSP2 (0x000000b0) | ||
230 | |||
231 | #define BP_CLKCTRL_SSP2_CLKGATE 31 | ||
232 | #define BM_CLKCTRL_SSP2_CLKGATE 0x80000000 | ||
233 | #define BM_CLKCTRL_SSP2_BUSY 0x20000000 | ||
234 | #define BM_CLKCTRL_SSP2_DIV_FRAC_EN 0x00000200 | ||
235 | #define BP_CLKCTRL_SSP2_DIV 0 | ||
236 | #define BM_CLKCTRL_SSP2_DIV 0x000001FF | ||
237 | #define BF_CLKCTRL_SSP2_DIV(v) \ | ||
238 | (((v) << 0) & BM_CLKCTRL_SSP2_DIV) | ||
239 | |||
240 | #define HW_CLKCTRL_SSP3 (0x000000c0) | ||
241 | |||
242 | #define BP_CLKCTRL_SSP3_CLKGATE 31 | ||
243 | #define BM_CLKCTRL_SSP3_CLKGATE 0x80000000 | ||
244 | #define BM_CLKCTRL_SSP3_BUSY 0x20000000 | ||
245 | #define BM_CLKCTRL_SSP3_DIV_FRAC_EN 0x00000200 | ||
246 | #define BP_CLKCTRL_SSP3_DIV 0 | ||
247 | #define BM_CLKCTRL_SSP3_DIV 0x000001FF | ||
248 | #define BF_CLKCTRL_SSP3_DIV(v) \ | ||
249 | (((v) << 0) & BM_CLKCTRL_SSP3_DIV) | ||
250 | |||
251 | #define HW_CLKCTRL_GPMI (0x000000d0) | ||
252 | |||
253 | #define BP_CLKCTRL_GPMI_CLKGATE 31 | ||
254 | #define BM_CLKCTRL_GPMI_CLKGATE 0x80000000 | ||
255 | #define BM_CLKCTRL_GPMI_BUSY 0x20000000 | ||
256 | #define BM_CLKCTRL_GPMI_DIV_FRAC_EN 0x00000400 | ||
257 | #define BP_CLKCTRL_GPMI_DIV 0 | ||
258 | #define BM_CLKCTRL_GPMI_DIV 0x000003FF | ||
259 | #define BF_CLKCTRL_GPMI_DIV(v) \ | ||
260 | (((v) << 0) & BM_CLKCTRL_GPMI_DIV) | ||
261 | |||
262 | #define HW_CLKCTRL_SPDIF (0x000000e0) | ||
263 | |||
264 | #define BP_CLKCTRL_SPDIF_CLKGATE 31 | ||
265 | #define BM_CLKCTRL_SPDIF_CLKGATE 0x80000000 | ||
266 | |||
267 | #define HW_CLKCTRL_EMI (0x000000f0) | ||
268 | |||
269 | #define BP_CLKCTRL_EMI_CLKGATE 31 | ||
270 | #define BM_CLKCTRL_EMI_CLKGATE 0x80000000 | ||
271 | #define BM_CLKCTRL_EMI_SYNC_MODE_EN 0x40000000 | ||
272 | #define BM_CLKCTRL_EMI_BUSY_REF_XTAL 0x20000000 | ||
273 | #define BM_CLKCTRL_EMI_BUSY_REF_EMI 0x10000000 | ||
274 | #define BM_CLKCTRL_EMI_BUSY_REF_CPU 0x08000000 | ||
275 | #define BM_CLKCTRL_EMI_BUSY_SYNC_MODE 0x04000000 | ||
276 | #define BM_CLKCTRL_EMI_BUSY_DCC_RESYNC 0x00020000 | ||
277 | #define BM_CLKCTRL_EMI_DCC_RESYNC_ENABLE 0x00010000 | ||
278 | #define BP_CLKCTRL_EMI_DIV_XTAL 8 | ||
279 | #define BM_CLKCTRL_EMI_DIV_XTAL 0x00000F00 | ||
280 | #define BF_CLKCTRL_EMI_DIV_XTAL(v) \ | ||
281 | (((v) << 8) & BM_CLKCTRL_EMI_DIV_XTAL) | ||
282 | #define BP_CLKCTRL_EMI_DIV_EMI 0 | ||
283 | #define BM_CLKCTRL_EMI_DIV_EMI 0x0000003F | ||
284 | #define BF_CLKCTRL_EMI_DIV_EMI(v) \ | ||
285 | (((v) << 0) & BM_CLKCTRL_EMI_DIV_EMI) | ||
286 | |||
287 | #define HW_CLKCTRL_SAIF0 (0x00000100) | ||
288 | |||
289 | #define BP_CLKCTRL_SAIF0_CLKGATE 31 | ||
290 | #define BM_CLKCTRL_SAIF0_CLKGATE 0x80000000 | ||
291 | #define BM_CLKCTRL_SAIF0_BUSY 0x20000000 | ||
292 | #define BM_CLKCTRL_SAIF0_DIV_FRAC_EN 0x00010000 | ||
293 | #define BP_CLKCTRL_SAIF0_DIV 0 | ||
294 | #define BM_CLKCTRL_SAIF0_DIV 0x0000FFFF | ||
295 | #define BF_CLKCTRL_SAIF0_DIV(v) \ | ||
296 | (((v) << 0) & BM_CLKCTRL_SAIF0_DIV) | ||
297 | |||
298 | #define HW_CLKCTRL_SAIF1 (0x00000110) | ||
299 | |||
300 | #define BP_CLKCTRL_SAIF1_CLKGATE 31 | ||
301 | #define BM_CLKCTRL_SAIF1_CLKGATE 0x80000000 | ||
302 | #define BM_CLKCTRL_SAIF1_BUSY 0x20000000 | ||
303 | #define BM_CLKCTRL_SAIF1_DIV_FRAC_EN 0x00010000 | ||
304 | #define BP_CLKCTRL_SAIF1_DIV 0 | ||
305 | #define BM_CLKCTRL_SAIF1_DIV 0x0000FFFF | ||
306 | #define BF_CLKCTRL_SAIF1_DIV(v) \ | ||
307 | (((v) << 0) & BM_CLKCTRL_SAIF1_DIV) | ||
308 | |||
309 | #define HW_CLKCTRL_DIS_LCDIF (0x00000120) | ||
310 | |||
311 | #define BP_CLKCTRL_DIS_LCDIF_CLKGATE 31 | ||
312 | #define BM_CLKCTRL_DIS_LCDIF_CLKGATE 0x80000000 | ||
313 | #define BM_CLKCTRL_DIS_LCDIF_BUSY 0x20000000 | ||
314 | #define BM_CLKCTRL_DIS_LCDIF_DIV_FRAC_EN 0x00002000 | ||
315 | #define BP_CLKCTRL_DIS_LCDIF_DIV 0 | ||
316 | #define BM_CLKCTRL_DIS_LCDIF_DIV 0x00001FFF | ||
317 | #define BF_CLKCTRL_DIS_LCDIF_DIV(v) \ | ||
318 | (((v) << 0) & BM_CLKCTRL_DIS_LCDIF_DIV) | ||
319 | |||
320 | #define HW_CLKCTRL_ETM (0x00000130) | ||
321 | |||
322 | #define BM_CLKCTRL_ETM_CLKGATE 0x80000000 | ||
323 | #define BM_CLKCTRL_ETM_BUSY 0x20000000 | ||
324 | #define BM_CLKCTRL_ETM_DIV_FRAC_EN 0x00000080 | ||
325 | #define BP_CLKCTRL_ETM_DIV 0 | ||
326 | #define BM_CLKCTRL_ETM_DIV 0x0000007F | ||
327 | #define BF_CLKCTRL_ETM_DIV(v) \ | ||
328 | (((v) << 0) & BM_CLKCTRL_ETM_DIV) | ||
329 | |||
330 | #define HW_CLKCTRL_ENET (0x00000140) | ||
331 | |||
332 | #define BM_CLKCTRL_ENET_SLEEP 0x80000000 | ||
333 | #define BP_CLKCTRL_ENET_DISABLE 30 | ||
334 | #define BM_CLKCTRL_ENET_DISABLE 0x40000000 | ||
335 | #define BM_CLKCTRL_ENET_STATUS 0x20000000 | ||
336 | #define BM_CLKCTRL_ENET_BUSY_TIME 0x08000000 | ||
337 | #define BP_CLKCTRL_ENET_DIV_TIME 21 | ||
338 | #define BM_CLKCTRL_ENET_DIV_TIME 0x07E00000 | ||
339 | #define BF_CLKCTRL_ENET_DIV_TIME(v) \ | ||
340 | (((v) << 21) & BM_CLKCTRL_ENET_DIV_TIME) | ||
341 | #define BM_CLKCTRL_ENET_BUSY 0x08000000 | ||
342 | #define BP_CLKCTRL_ENET_DIV 21 | ||
343 | #define BM_CLKCTRL_ENET_DIV 0x07E00000 | ||
344 | #define BF_CLKCTRL_ENET_DIV(v) \ | ||
345 | (((v) << 21) & BM_CLKCTRL_ENET_DIV) | ||
346 | #define BP_CLKCTRL_ENET_TIME_SEL 19 | ||
347 | #define BM_CLKCTRL_ENET_TIME_SEL 0x00180000 | ||
348 | #define BF_CLKCTRL_ENET_TIME_SEL(v) \ | ||
349 | (((v) << 19) & BM_CLKCTRL_ENET_TIME_SEL) | ||
350 | #define BV_CLKCTRL_ENET_TIME_SEL__XTAL 0x0 | ||
351 | #define BV_CLKCTRL_ENET_TIME_SEL__PLL 0x1 | ||
352 | #define BV_CLKCTRL_ENET_TIME_SEL__RMII_CLK 0x2 | ||
353 | #define BV_CLKCTRL_ENET_TIME_SEL__UNDEFINED 0x3 | ||
354 | #define BM_CLKCTRL_ENET_CLK_OUT_EN 0x00040000 | ||
355 | #define BM_CLKCTRL_ENET_RESET_BY_SW_CHIP 0x00020000 | ||
356 | #define BM_CLKCTRL_ENET_RESET_BY_SW 0x00010000 | ||
357 | |||
358 | #define HW_CLKCTRL_HSADC (0x00000150) | ||
359 | |||
360 | #define BM_CLKCTRL_HSADC_RESETB 0x40000000 | ||
361 | #define BP_CLKCTRL_HSADC_FREQDIV 28 | ||
362 | #define BM_CLKCTRL_HSADC_FREQDIV 0x30000000 | ||
363 | #define BF_CLKCTRL_HSADC_FREQDIV(v) \ | ||
364 | (((v) << 28) & BM_CLKCTRL_HSADC_FREQDIV) | ||
365 | |||
366 | #define HW_CLKCTRL_FLEXCAN (0x00000160) | ||
367 | |||
368 | #define BP_CLKCTRL_FLEXCAN_STOP_CAN0 30 | ||
369 | #define BM_CLKCTRL_FLEXCAN_STOP_CAN0 0x40000000 | ||
370 | #define BM_CLKCTRL_FLEXCAN_CAN0_STATUS 0x20000000 | ||
371 | #define BP_CLKCTRL_FLEXCAN_STOP_CAN1 28 | ||
372 | #define BM_CLKCTRL_FLEXCAN_STOP_CAN1 0x10000000 | ||
373 | #define BM_CLKCTRL_FLEXCAN_CAN1_STATUS 0x08000000 | ||
374 | |||
375 | #define HW_CLKCTRL_FRAC0 (0x000001b0) | ||
376 | #define HW_CLKCTRL_FRAC0_SET (0x000001b4) | ||
377 | #define HW_CLKCTRL_FRAC0_CLR (0x000001b8) | ||
378 | #define HW_CLKCTRL_FRAC0_TOG (0x000001bc) | ||
379 | |||
380 | #define BP_CLKCTRL_FRAC0_CLKGATEIO0 31 | ||
381 | #define BM_CLKCTRL_FRAC0_CLKGATEIO0 0x80000000 | ||
382 | #define BM_CLKCTRL_FRAC0_IO0_STABLE 0x40000000 | ||
383 | #define BP_CLKCTRL_FRAC0_IO0FRAC 24 | ||
384 | #define BM_CLKCTRL_FRAC0_IO0FRAC 0x3F000000 | ||
385 | #define BF_CLKCTRL_FRAC0_IO0FRAC(v) \ | ||
386 | (((v) << 24) & BM_CLKCTRL_FRAC0_IO0FRAC) | ||
387 | #define BP_CLKCTRL_FRAC0_CLKGATEIO1 23 | ||
388 | #define BM_CLKCTRL_FRAC0_CLKGATEIO1 0x00800000 | ||
389 | #define BM_CLKCTRL_FRAC0_IO1_STABLE 0x00400000 | ||
390 | #define BP_CLKCTRL_FRAC0_IO1FRAC 16 | ||
391 | #define BM_CLKCTRL_FRAC0_IO1FRAC 0x003F0000 | ||
392 | #define BF_CLKCTRL_FRAC0_IO1FRAC(v) \ | ||
393 | (((v) << 16) & BM_CLKCTRL_FRAC0_IO1FRAC) | ||
394 | #define BP_CLKCTRL_FRAC0_CLKGATEEMI 15 | ||
395 | #define BM_CLKCTRL_FRAC0_CLKGATEEMI 0x00008000 | ||
396 | #define BM_CLKCTRL_FRAC0_EMI_STABLE 0x00004000 | ||
397 | #define BP_CLKCTRL_FRAC0_EMIFRAC 8 | ||
398 | #define BM_CLKCTRL_FRAC0_EMIFRAC 0x00003F00 | ||
399 | #define BF_CLKCTRL_FRAC0_EMIFRAC(v) \ | ||
400 | (((v) << 8) & BM_CLKCTRL_FRAC0_EMIFRAC) | ||
401 | #define BP_CLKCTRL_FRAC0_CLKGATECPU 7 | ||
402 | #define BM_CLKCTRL_FRAC0_CLKGATECPU 0x00000080 | ||
403 | #define BM_CLKCTRL_FRAC0_CPU_STABLE 0x00000040 | ||
404 | #define BP_CLKCTRL_FRAC0_CPUFRAC 0 | ||
405 | #define BM_CLKCTRL_FRAC0_CPUFRAC 0x0000003F | ||
406 | #define BF_CLKCTRL_FRAC0_CPUFRAC(v) \ | ||
407 | (((v) << 0) & BM_CLKCTRL_FRAC0_CPUFRAC) | ||
408 | |||
409 | #define HW_CLKCTRL_FRAC1 (0x000001c0) | ||
410 | #define HW_CLKCTRL_FRAC1_SET (0x000001c4) | ||
411 | #define HW_CLKCTRL_FRAC1_CLR (0x000001c8) | ||
412 | #define HW_CLKCTRL_FRAC1_TOG (0x000001cc) | ||
413 | |||
414 | #define BP_CLKCTRL_FRAC1_CLKGATEGPMI 23 | ||
415 | #define BM_CLKCTRL_FRAC1_CLKGATEGPMI 0x00800000 | ||
416 | #define BM_CLKCTRL_FRAC1_GPMI_STABLE 0x00400000 | ||
417 | #define BP_CLKCTRL_FRAC1_GPMIFRAC 16 | ||
418 | #define BM_CLKCTRL_FRAC1_GPMIFRAC 0x003F0000 | ||
419 | #define BF_CLKCTRL_FRAC1_GPMIFRAC(v) \ | ||
420 | (((v) << 16) & BM_CLKCTRL_FRAC1_GPMIFRAC) | ||
421 | #define BP_CLKCTRL_FRAC1_CLKGATEHSADC 15 | ||
422 | #define BM_CLKCTRL_FRAC1_CLKGATEHSADC 0x00008000 | ||
423 | #define BM_CLKCTRL_FRAC1_HSADC_STABLE 0x00004000 | ||
424 | #define BP_CLKCTRL_FRAC1_HSADCFRAC 8 | ||
425 | #define BM_CLKCTRL_FRAC1_HSADCFRAC 0x00003F00 | ||
426 | #define BF_CLKCTRL_FRAC1_HSADCFRAC(v) \ | ||
427 | (((v) << 8) & BM_CLKCTRL_FRAC1_HSADCFRAC) | ||
428 | #define BP_CLKCTRL_FRAC1_CLKGATEPIX 7 | ||
429 | #define BM_CLKCTRL_FRAC1_CLKGATEPIX 0x00000080 | ||
430 | #define BM_CLKCTRL_FRAC1_PIX_STABLE 0x00000040 | ||
431 | #define BP_CLKCTRL_FRAC1_PIXFRAC 0 | ||
432 | #define BM_CLKCTRL_FRAC1_PIXFRAC 0x0000003F | ||
433 | #define BF_CLKCTRL_FRAC1_PIXFRAC(v) \ | ||
434 | (((v) << 0) & BM_CLKCTRL_FRAC1_PIXFRAC) | ||
435 | |||
436 | #define HW_CLKCTRL_CLKSEQ (0x000001d0) | ||
437 | #define HW_CLKCTRL_CLKSEQ_SET (0x000001d4) | ||
438 | #define HW_CLKCTRL_CLKSEQ_CLR (0x000001d8) | ||
439 | #define HW_CLKCTRL_CLKSEQ_TOG (0x000001dc) | ||
440 | |||
441 | #define BM_CLKCTRL_CLKSEQ_BYPASS_CPU 0x00040000 | ||
442 | #define BM_CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF 0x00004000 | ||
443 | #define BV_CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF__BYPASS 0x1 | ||
444 | #define BV_CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF__PFD 0x0 | ||
445 | #define BM_CLKCTRL_CLKSEQ_BYPASS_ETM 0x00000100 | ||
446 | #define BM_CLKCTRL_CLKSEQ_BYPASS_EMI 0x00000080 | ||
447 | #define BM_CLKCTRL_CLKSEQ_BYPASS_SSP3 0x00000040 | ||
448 | #define BM_CLKCTRL_CLKSEQ_BYPASS_SSP2 0x00000020 | ||
449 | #define BM_CLKCTRL_CLKSEQ_BYPASS_SSP1 0x00000010 | ||
450 | #define BM_CLKCTRL_CLKSEQ_BYPASS_SSP0 0x00000008 | ||
451 | #define BM_CLKCTRL_CLKSEQ_BYPASS_GPMI 0x00000004 | ||
452 | #define BM_CLKCTRL_CLKSEQ_BYPASS_SAIF1 0x00000002 | ||
453 | #define BM_CLKCTRL_CLKSEQ_BYPASS_SAIF0 0x00000001 | ||
454 | |||
455 | #define HW_CLKCTRL_RESET (0x000001e0) | ||
456 | |||
457 | #define BM_CLKCTRL_RESET_WDOG_POR_DISABLE 0x00000020 | ||
458 | #define BM_CLKCTRL_RESET_EXTERNAL_RESET_ENABLE 0x00000010 | ||
459 | #define BM_CLKCTRL_RESET_THERMAL_RESET_ENABLE 0x00000008 | ||
460 | #define BM_CLKCTRL_RESET_THERMAL_RESET_DEFAULT 0x00000004 | ||
461 | #define BM_CLKCTRL_RESET_CHIP 0x00000002 | ||
462 | #define BM_CLKCTRL_RESET_DIG 0x00000001 | ||
463 | |||
464 | #define HW_CLKCTRL_STATUS (0x000001f0) | ||
465 | |||
466 | #define BP_CLKCTRL_STATUS_CPU_LIMIT 30 | ||
467 | #define BM_CLKCTRL_STATUS_CPU_LIMIT 0xC0000000 | ||
468 | #define BF_CLKCTRL_STATUS_CPU_LIMIT(v) \ | ||
469 | (((v) << 30) & BM_CLKCTRL_STATUS_CPU_LIMIT) | ||
470 | |||
471 | #define HW_CLKCTRL_VERSION (0x00000200) | ||
472 | |||
473 | #define BP_CLKCTRL_VERSION_MAJOR 24 | ||
474 | #define BM_CLKCTRL_VERSION_MAJOR 0xFF000000 | ||
475 | #define BF_CLKCTRL_VERSION_MAJOR(v) \ | ||
476 | (((v) << 24) & BM_CLKCTRL_VERSION_MAJOR) | ||
477 | #define BP_CLKCTRL_VERSION_MINOR 16 | ||
478 | #define BM_CLKCTRL_VERSION_MINOR 0x00FF0000 | ||
479 | #define BF_CLKCTRL_VERSION_MINOR(v) \ | ||
480 | (((v) << 16) & BM_CLKCTRL_VERSION_MINOR) | ||
481 | #define BP_CLKCTRL_VERSION_STEP 0 | ||
482 | #define BM_CLKCTRL_VERSION_STEP 0x0000FFFF | ||
483 | #define BF_CLKCTRL_VERSION_STEP(v) \ | ||
484 | (((v) << 0) & BM_CLKCTRL_VERSION_STEP) | ||
485 | |||
486 | #endif /* __REGS_CLKCTRL_MX28_H__ */ | ||
diff --git a/arch/arm/mach-mxs/system.c b/arch/arm/mach-mxs/system.c index 80ac1fca8a00..30042e23bfa7 100644 --- a/arch/arm/mach-mxs/system.c +++ b/arch/arm/mach-mxs/system.c | |||
@@ -37,8 +37,6 @@ | |||
37 | #define MXS_MODULE_CLKGATE (1 << 30) | 37 | #define MXS_MODULE_CLKGATE (1 << 30) |
38 | #define MXS_MODULE_SFTRST (1 << 31) | 38 | #define MXS_MODULE_SFTRST (1 << 31) |
39 | 39 | ||
40 | #define CLKCTRL_TIMEOUT 10 /* 10 ms */ | ||
41 | |||
42 | static void __iomem *mxs_clkctrl_reset_addr; | 40 | static void __iomem *mxs_clkctrl_reset_addr; |
43 | 41 | ||
44 | /* | 42 | /* |
@@ -139,17 +137,3 @@ error: | |||
139 | return -ETIMEDOUT; | 137 | return -ETIMEDOUT; |
140 | } | 138 | } |
141 | EXPORT_SYMBOL(mxs_reset_block); | 139 | EXPORT_SYMBOL(mxs_reset_block); |
142 | |||
143 | int mxs_clkctrl_timeout(unsigned int reg_offset, unsigned int mask) | ||
144 | { | ||
145 | unsigned long timeout = jiffies + msecs_to_jiffies(CLKCTRL_TIMEOUT); | ||
146 | while (readl_relaxed(MXS_IO_ADDRESS(MXS_CLKCTRL_BASE_ADDR) | ||
147 | + reg_offset) & mask) { | ||
148 | if (time_after(jiffies, timeout)) { | ||
149 | pr_err("Timeout at CLKCTRL + 0x%x\n", reg_offset); | ||
150 | return -ETIMEDOUT; | ||
151 | } | ||
152 | } | ||
153 | |||
154 | return 0; | ||
155 | } | ||
diff --git a/arch/arm/mach-mxs/timer.c b/arch/arm/mach-mxs/timer.c index 564a63279f18..02d36de9c4e8 100644 --- a/arch/arm/mach-mxs/timer.c +++ b/arch/arm/mach-mxs/timer.c | |||
@@ -20,6 +20,7 @@ | |||
20 | * MA 02110-1301, USA. | 20 | * MA 02110-1301, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/err.h> | ||
23 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
24 | #include <linux/irq.h> | 25 | #include <linux/irq.h> |
25 | #include <linux/clockchips.h> | 26 | #include <linux/clockchips.h> |
@@ -243,8 +244,16 @@ static int __init mxs_clocksource_init(struct clk *timer_clk) | |||
243 | return 0; | 244 | return 0; |
244 | } | 245 | } |
245 | 246 | ||
246 | void __init mxs_timer_init(struct clk *timer_clk, int irq) | 247 | void __init mxs_timer_init(int irq) |
247 | { | 248 | { |
249 | struct clk *timer_clk; | ||
250 | |||
251 | timer_clk = clk_get_sys("timrot", NULL); | ||
252 | if (IS_ERR(timer_clk)) { | ||
253 | pr_err("%s: failed to get clk\n", __func__); | ||
254 | return; | ||
255 | } | ||
256 | |||
248 | clk_prepare_enable(timer_clk); | 257 | clk_prepare_enable(timer_clk); |
249 | 258 | ||
250 | /* | 259 | /* |
diff --git a/arch/arm/mach-pxa/include/mach/mfp-pxa2xx.h b/arch/arm/mach-pxa/include/mach/mfp-pxa2xx.h index c54cef25895c..cbf51ae81855 100644 --- a/arch/arm/mach-pxa/include/mach/mfp-pxa2xx.h +++ b/arch/arm/mach-pxa/include/mach/mfp-pxa2xx.h | |||
@@ -17,6 +17,7 @@ | |||
17 | * | 17 | * |
18 | * bit 23 - Input/Output (PXA2xx specific) | 18 | * bit 23 - Input/Output (PXA2xx specific) |
19 | * bit 24 - Wakeup Enable(PXA2xx specific) | 19 | * bit 24 - Wakeup Enable(PXA2xx specific) |
20 | * bit 25 - Keep Output (PXA2xx specific) | ||
20 | */ | 21 | */ |
21 | 22 | ||
22 | #define MFP_DIR_IN (0x0 << 23) | 23 | #define MFP_DIR_IN (0x0 << 23) |
@@ -25,6 +26,12 @@ | |||
25 | #define MFP_DIR(x) (((x) >> 23) & 0x1) | 26 | #define MFP_DIR(x) (((x) >> 23) & 0x1) |
26 | 27 | ||
27 | #define MFP_LPM_CAN_WAKEUP (0x1 << 24) | 28 | #define MFP_LPM_CAN_WAKEUP (0x1 << 24) |
29 | |||
30 | /* | ||
31 | * MFP_LPM_KEEP_OUTPUT must be specified for pins that need to | ||
32 | * retain their last output level (low or high). | ||
33 | * Note: MFP_LPM_KEEP_OUTPUT has no effect on pins configured for input. | ||
34 | */ | ||
28 | #define MFP_LPM_KEEP_OUTPUT (0x1 << 25) | 35 | #define MFP_LPM_KEEP_OUTPUT (0x1 << 25) |
29 | 36 | ||
30 | #define WAKEUP_ON_EDGE_RISE (MFP_LPM_CAN_WAKEUP | MFP_LPM_EDGE_RISE) | 37 | #define WAKEUP_ON_EDGE_RISE (MFP_LPM_CAN_WAKEUP | MFP_LPM_EDGE_RISE) |
diff --git a/arch/arm/mach-pxa/mfp-pxa2xx.c b/arch/arm/mach-pxa/mfp-pxa2xx.c index b0a842887780..ef0426a159d4 100644 --- a/arch/arm/mach-pxa/mfp-pxa2xx.c +++ b/arch/arm/mach-pxa/mfp-pxa2xx.c | |||
@@ -33,6 +33,8 @@ | |||
33 | #define BANK_OFF(n) (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2)) | 33 | #define BANK_OFF(n) (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2)) |
34 | #define GPLR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5)) | 34 | #define GPLR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5)) |
35 | #define GPDR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5) + 0x0c) | 35 | #define GPDR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5) + 0x0c) |
36 | #define GPSR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5) + 0x18) | ||
37 | #define GPCR(x) __REG2(0x40E00000, BANK_OFF((x) >> 5) + 0x24) | ||
36 | 38 | ||
37 | #define PWER_WE35 (1 << 24) | 39 | #define PWER_WE35 (1 << 24) |
38 | 40 | ||
@@ -348,6 +350,7 @@ static inline void pxa27x_mfp_init(void) {} | |||
348 | #ifdef CONFIG_PM | 350 | #ifdef CONFIG_PM |
349 | static unsigned long saved_gafr[2][4]; | 351 | static unsigned long saved_gafr[2][4]; |
350 | static unsigned long saved_gpdr[4]; | 352 | static unsigned long saved_gpdr[4]; |
353 | static unsigned long saved_gplr[4]; | ||
351 | static unsigned long saved_pgsr[4]; | 354 | static unsigned long saved_pgsr[4]; |
352 | 355 | ||
353 | static int pxa2xx_mfp_suspend(void) | 356 | static int pxa2xx_mfp_suspend(void) |
@@ -366,14 +369,26 @@ static int pxa2xx_mfp_suspend(void) | |||
366 | } | 369 | } |
367 | 370 | ||
368 | for (i = 0; i <= gpio_to_bank(pxa_last_gpio); i++) { | 371 | for (i = 0; i <= gpio_to_bank(pxa_last_gpio); i++) { |
369 | |||
370 | saved_gafr[0][i] = GAFR_L(i); | 372 | saved_gafr[0][i] = GAFR_L(i); |
371 | saved_gafr[1][i] = GAFR_U(i); | 373 | saved_gafr[1][i] = GAFR_U(i); |
372 | saved_gpdr[i] = GPDR(i * 32); | 374 | saved_gpdr[i] = GPDR(i * 32); |
375 | saved_gplr[i] = GPLR(i * 32); | ||
373 | saved_pgsr[i] = PGSR(i); | 376 | saved_pgsr[i] = PGSR(i); |
374 | 377 | ||
375 | GPDR(i * 32) = gpdr_lpm[i]; | 378 | GPSR(i * 32) = PGSR(i); |
379 | GPCR(i * 32) = ~PGSR(i); | ||
380 | } | ||
381 | |||
382 | /* set GPDR bits taking into account MFP_LPM_KEEP_OUTPUT */ | ||
383 | for (i = 0; i < pxa_last_gpio; i++) { | ||
384 | if ((gpdr_lpm[gpio_to_bank(i)] & GPIO_bit(i)) || | ||
385 | ((gpio_desc[i].config & MFP_LPM_KEEP_OUTPUT) && | ||
386 | (saved_gpdr[gpio_to_bank(i)] & GPIO_bit(i)))) | ||
387 | GPDR(i) |= GPIO_bit(i); | ||
388 | else | ||
389 | GPDR(i) &= ~GPIO_bit(i); | ||
376 | } | 390 | } |
391 | |||
377 | return 0; | 392 | return 0; |
378 | } | 393 | } |
379 | 394 | ||
@@ -384,6 +399,8 @@ static void pxa2xx_mfp_resume(void) | |||
384 | for (i = 0; i <= gpio_to_bank(pxa_last_gpio); i++) { | 399 | for (i = 0; i <= gpio_to_bank(pxa_last_gpio); i++) { |
385 | GAFR_L(i) = saved_gafr[0][i]; | 400 | GAFR_L(i) = saved_gafr[0][i]; |
386 | GAFR_U(i) = saved_gafr[1][i]; | 401 | GAFR_U(i) = saved_gafr[1][i]; |
402 | GPSR(i * 32) = saved_gplr[i]; | ||
403 | GPCR(i * 32) = ~saved_gplr[i]; | ||
387 | GPDR(i * 32) = saved_gpdr[i]; | 404 | GPDR(i * 32) = saved_gpdr[i]; |
388 | PGSR(i) = saved_pgsr[i]; | 405 | PGSR(i) = saved_pgsr[i]; |
389 | } | 406 | } |
diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c index 6bce78edce7a..4726c246dcdc 100644 --- a/arch/arm/mach-pxa/pxa27x.c +++ b/arch/arm/mach-pxa/pxa27x.c | |||
@@ -421,8 +421,11 @@ void __init pxa27x_set_i2c_power_info(struct i2c_pxa_platform_data *info) | |||
421 | pxa_register_device(&pxa27x_device_i2c_power, info); | 421 | pxa_register_device(&pxa27x_device_i2c_power, info); |
422 | } | 422 | } |
423 | 423 | ||
424 | static struct pxa_gpio_platform_data pxa27x_gpio_info __initdata = { | ||
425 | .gpio_set_wake = gpio_set_wake, | ||
426 | }; | ||
427 | |||
424 | static struct platform_device *devices[] __initdata = { | 428 | static struct platform_device *devices[] __initdata = { |
425 | &pxa_device_gpio, | ||
426 | &pxa27x_device_udc, | 429 | &pxa27x_device_udc, |
427 | &pxa_device_pmu, | 430 | &pxa_device_pmu, |
428 | &pxa_device_i2s, | 431 | &pxa_device_i2s, |
@@ -458,6 +461,7 @@ static int __init pxa27x_init(void) | |||
458 | register_syscore_ops(&pxa2xx_mfp_syscore_ops); | 461 | register_syscore_ops(&pxa2xx_mfp_syscore_ops); |
459 | register_syscore_ops(&pxa2xx_clock_syscore_ops); | 462 | register_syscore_ops(&pxa2xx_clock_syscore_ops); |
460 | 463 | ||
464 | pxa_register_device(&pxa_device_gpio, &pxa27x_gpio_info); | ||
461 | ret = platform_add_devices(devices, ARRAY_SIZE(devices)); | 465 | ret = platform_add_devices(devices, ARRAY_SIZE(devices)); |
462 | } | 466 | } |
463 | 467 | ||
diff --git a/arch/arm/mach-s3c24xx/Kconfig b/arch/arm/mach-s3c24xx/Kconfig index 0f3a327ebcaa..b34287ab5afd 100644 --- a/arch/arm/mach-s3c24xx/Kconfig +++ b/arch/arm/mach-s3c24xx/Kconfig | |||
@@ -111,10 +111,6 @@ config S3C24XX_SETUP_TS | |||
111 | help | 111 | help |
112 | Compile in platform device definition for Samsung TouchScreen. | 112 | Compile in platform device definition for Samsung TouchScreen. |
113 | 113 | ||
114 | # cpu-specific sections | ||
115 | |||
116 | if CPU_S3C2410 | ||
117 | |||
118 | config S3C2410_DMA | 114 | config S3C2410_DMA |
119 | bool | 115 | bool |
120 | depends on S3C24XX_DMA && (CPU_S3C2410 || CPU_S3C2442) | 116 | depends on S3C24XX_DMA && (CPU_S3C2410 || CPU_S3C2442) |
@@ -127,6 +123,10 @@ config S3C2410_PM | |||
127 | help | 123 | help |
128 | Power Management code common to S3C2410 and better | 124 | Power Management code common to S3C2410 and better |
129 | 125 | ||
126 | # cpu-specific sections | ||
127 | |||
128 | if CPU_S3C2410 | ||
129 | |||
130 | config S3C24XX_SIMTEC_NOR | 130 | config S3C24XX_SIMTEC_NOR |
131 | bool | 131 | bool |
132 | help | 132 | help |
diff --git a/arch/arm/mach-s5pv210/mach-goni.c b/arch/arm/mach-s5pv210/mach-goni.c index a8933de3d627..32395664e879 100644 --- a/arch/arm/mach-s5pv210/mach-goni.c +++ b/arch/arm/mach-s5pv210/mach-goni.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/gpio_keys.h> | 25 | #include <linux/gpio_keys.h> |
26 | #include <linux/input.h> | 26 | #include <linux/input.h> |
27 | #include <linux/gpio.h> | 27 | #include <linux/gpio.h> |
28 | #include <linux/mmc/host.h> | ||
28 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
29 | 30 | ||
30 | #include <asm/hardware/vic.h> | 31 | #include <asm/hardware/vic.h> |
@@ -765,6 +766,7 @@ static void __init goni_pmic_init(void) | |||
765 | /* MoviNAND */ | 766 | /* MoviNAND */ |
766 | static struct s3c_sdhci_platdata goni_hsmmc0_data __initdata = { | 767 | static struct s3c_sdhci_platdata goni_hsmmc0_data __initdata = { |
767 | .max_width = 4, | 768 | .max_width = 4, |
769 | .host_caps2 = MMC_CAP2_BROKEN_VOLTAGE, | ||
768 | .cd_type = S3C_SDHCI_CD_PERMANENT, | 770 | .cd_type = S3C_SDHCI_CD_PERMANENT, |
769 | }; | 771 | }; |
770 | 772 | ||
diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c index 7c524b4e415d..16be4c56abe3 100644 --- a/arch/arm/mach-sa1100/generic.c +++ b/arch/arm/mach-sa1100/generic.c | |||
@@ -306,7 +306,7 @@ void sa11x0_register_irda(struct irda_platform_data *irda) | |||
306 | } | 306 | } |
307 | 307 | ||
308 | static struct resource sa1100_rtc_resources[] = { | 308 | static struct resource sa1100_rtc_resources[] = { |
309 | DEFINE_RES_MEM(0x90010000, 0x9001003f), | 309 | DEFINE_RES_MEM(0x90010000, 0x40), |
310 | DEFINE_RES_IRQ_NAMED(IRQ_RTC1Hz, "rtc 1Hz"), | 310 | DEFINE_RES_IRQ_NAMED(IRQ_RTC1Hz, "rtc 1Hz"), |
311 | DEFINE_RES_IRQ_NAMED(IRQ_RTCAlrm, "rtc alarm"), | 311 | DEFINE_RES_IRQ_NAMED(IRQ_RTCAlrm, "rtc alarm"), |
312 | }; | 312 | }; |
diff --git a/arch/arm/mach-spear3xx/Kconfig b/arch/arm/mach-spear3xx/Kconfig index 2cee6b0de371..8bd37291fa4f 100644 --- a/arch/arm/mach-spear3xx/Kconfig +++ b/arch/arm/mach-spear3xx/Kconfig | |||
@@ -5,39 +5,22 @@ | |||
5 | if ARCH_SPEAR3XX | 5 | if ARCH_SPEAR3XX |
6 | 6 | ||
7 | menu "SPEAr3xx Implementations" | 7 | menu "SPEAr3xx Implementations" |
8 | config BOARD_SPEAR300_EVB | ||
9 | bool "SPEAr300 Evaluation Board" | ||
10 | select MACH_SPEAR300 | ||
11 | help | ||
12 | Supports ST SPEAr300 Evaluation Board | ||
13 | |||
14 | config BOARD_SPEAR310_EVB | ||
15 | bool "SPEAr310 Evaluation Board" | ||
16 | select MACH_SPEAR310 | ||
17 | help | ||
18 | Supports ST SPEAr310 Evaluation Board | ||
19 | |||
20 | config BOARD_SPEAR320_EVB | ||
21 | bool "SPEAr320 Evaluation Board" | ||
22 | select MACH_SPEAR320 | ||
23 | help | ||
24 | Supports ST SPEAr320 Evaluation Board | ||
25 | |||
26 | endmenu | ||
27 | |||
28 | config MACH_SPEAR300 | 8 | config MACH_SPEAR300 |
29 | bool "SPEAr300" | 9 | bool "SPEAr300 Machine support with Device Tree" |
10 | select PINCTRL_SPEAR300 | ||
30 | help | 11 | help |
31 | Supports ST SPEAr300 Machine | 12 | Supports ST SPEAr300 machine configured via the device-tree |
32 | 13 | ||
33 | config MACH_SPEAR310 | 14 | config MACH_SPEAR310 |
34 | bool "SPEAr310" | 15 | bool "SPEAr310 Machine support with Device Tree" |
16 | select PINCTRL_SPEAR310 | ||
35 | help | 17 | help |
36 | Supports ST SPEAr310 Machine | 18 | Supports ST SPEAr310 machine configured via the device-tree |
37 | 19 | ||
38 | config MACH_SPEAR320 | 20 | config MACH_SPEAR320 |
39 | bool "SPEAr320" | 21 | bool "SPEAr320 Machine support with Device Tree" |
22 | select PINCTRL_SPEAR320 | ||
40 | help | 23 | help |
41 | Supports ST SPEAr320 Machine | 24 | Supports ST SPEAr320 machine configured via the device-tree |
42 | 25 | endmenu | |
43 | endif #ARCH_SPEAR3XX | 26 | endif #ARCH_SPEAR3XX |
diff --git a/arch/arm/mach-spear3xx/Makefile b/arch/arm/mach-spear3xx/Makefile index b24862489704..8d12faa178fd 100644 --- a/arch/arm/mach-spear3xx/Makefile +++ b/arch/arm/mach-spear3xx/Makefile | |||
@@ -3,24 +3,13 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | # common files | 5 | # common files |
6 | obj-y += spear3xx.o clock.o | 6 | obj-$(CONFIG_ARCH_SPEAR3XX) += spear3xx.o |
7 | 7 | ||
8 | # spear300 specific files | 8 | # spear300 specific files |
9 | obj-$(CONFIG_MACH_SPEAR300) += spear300.o | 9 | obj-$(CONFIG_MACH_SPEAR300) += spear300.o |
10 | 10 | ||
11 | # spear300 boards files | ||
12 | obj-$(CONFIG_BOARD_SPEAR300_EVB) += spear300_evb.o | ||
13 | |||
14 | |||
15 | # spear310 specific files | 11 | # spear310 specific files |
16 | obj-$(CONFIG_MACH_SPEAR310) += spear310.o | 12 | obj-$(CONFIG_MACH_SPEAR310) += spear310.o |
17 | 13 | ||
18 | # spear310 boards files | ||
19 | obj-$(CONFIG_BOARD_SPEAR310_EVB) += spear310_evb.o | ||
20 | |||
21 | |||
22 | # spear320 specific files | 14 | # spear320 specific files |
23 | obj-$(CONFIG_MACH_SPEAR320) += spear320.o | 15 | obj-$(CONFIG_MACH_SPEAR320) += spear320.o |
24 | |||
25 | # spear320 boards files | ||
26 | obj-$(CONFIG_BOARD_SPEAR320_EVB) += spear320_evb.o | ||
diff --git a/arch/arm/mach-spear3xx/Makefile.boot b/arch/arm/mach-spear3xx/Makefile.boot index 4674a4c221db..d93e2177e6ec 100644 --- a/arch/arm/mach-spear3xx/Makefile.boot +++ b/arch/arm/mach-spear3xx/Makefile.boot | |||
@@ -1,3 +1,7 @@ | |||
1 | zreladdr-y += 0x00008000 | 1 | zreladdr-y += 0x00008000 |
2 | params_phys-y := 0x00000100 | 2 | params_phys-y := 0x00000100 |
3 | initrd_phys-y := 0x00800000 | 3 | initrd_phys-y := 0x00800000 |
4 | |||
5 | dtb-$(CONFIG_MACH_SPEAR300) += spear300-evb.dtb | ||
6 | dtb-$(CONFIG_MACH_SPEAR310) += spear310-evb.dtb | ||
7 | dtb-$(CONFIG_MACH_SPEAR320) += spear320-evb.dtb | ||
diff --git a/arch/arm/mach-spear3xx/clock.c b/arch/arm/mach-spear3xx/clock.c deleted file mode 100644 index 6c4841f55223..000000000000 --- a/arch/arm/mach-spear3xx/clock.c +++ /dev/null | |||
@@ -1,760 +0,0 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-spear3xx/clock.c | ||
3 | * | ||
4 | * SPEAr3xx machines clock framework source file | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #include <linux/init.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <asm/mach-types.h> | ||
18 | #include <plat/clock.h> | ||
19 | #include <mach/misc_regs.h> | ||
20 | |||
21 | /* root clks */ | ||
22 | /* 32 KHz oscillator clock */ | ||
23 | static struct clk osc_32k_clk = { | ||
24 | .flags = ALWAYS_ENABLED, | ||
25 | .rate = 32000, | ||
26 | }; | ||
27 | |||
28 | /* 24 MHz oscillator clock */ | ||
29 | static struct clk osc_24m_clk = { | ||
30 | .flags = ALWAYS_ENABLED, | ||
31 | .rate = 24000000, | ||
32 | }; | ||
33 | |||
34 | /* clock derived from 32 KHz osc clk */ | ||
35 | /* rtc clock */ | ||
36 | static struct clk rtc_clk = { | ||
37 | .pclk = &osc_32k_clk, | ||
38 | .en_reg = PERIP1_CLK_ENB, | ||
39 | .en_reg_bit = RTC_CLK_ENB, | ||
40 | .recalc = &follow_parent, | ||
41 | }; | ||
42 | |||
43 | /* clock derived from 24 MHz osc clk */ | ||
44 | /* pll masks structure */ | ||
45 | static struct pll_clk_masks pll1_masks = { | ||
46 | .mode_mask = PLL_MODE_MASK, | ||
47 | .mode_shift = PLL_MODE_SHIFT, | ||
48 | .norm_fdbk_m_mask = PLL_NORM_FDBK_M_MASK, | ||
49 | .norm_fdbk_m_shift = PLL_NORM_FDBK_M_SHIFT, | ||
50 | .dith_fdbk_m_mask = PLL_DITH_FDBK_M_MASK, | ||
51 | .dith_fdbk_m_shift = PLL_DITH_FDBK_M_SHIFT, | ||
52 | .div_p_mask = PLL_DIV_P_MASK, | ||
53 | .div_p_shift = PLL_DIV_P_SHIFT, | ||
54 | .div_n_mask = PLL_DIV_N_MASK, | ||
55 | .div_n_shift = PLL_DIV_N_SHIFT, | ||
56 | }; | ||
57 | |||
58 | /* pll1 configuration structure */ | ||
59 | static struct pll_clk_config pll1_config = { | ||
60 | .mode_reg = PLL1_CTR, | ||
61 | .cfg_reg = PLL1_FRQ, | ||
62 | .masks = &pll1_masks, | ||
63 | }; | ||
64 | |||
65 | /* pll rate configuration table, in ascending order of rates */ | ||
66 | struct pll_rate_tbl pll_rtbl[] = { | ||
67 | {.mode = 0, .m = 0x85, .n = 0x0C, .p = 0x1}, /* 266 MHz */ | ||
68 | {.mode = 0, .m = 0xA6, .n = 0x0C, .p = 0x1}, /* 332 MHz */ | ||
69 | }; | ||
70 | |||
71 | /* PLL1 clock */ | ||
72 | static struct clk pll1_clk = { | ||
73 | .flags = ENABLED_ON_INIT, | ||
74 | .pclk = &osc_24m_clk, | ||
75 | .en_reg = PLL1_CTR, | ||
76 | .en_reg_bit = PLL_ENABLE, | ||
77 | .calc_rate = &pll_calc_rate, | ||
78 | .recalc = &pll_clk_recalc, | ||
79 | .set_rate = &pll_clk_set_rate, | ||
80 | .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 1}, | ||
81 | .private_data = &pll1_config, | ||
82 | }; | ||
83 | |||
84 | /* PLL3 48 MHz clock */ | ||
85 | static struct clk pll3_48m_clk = { | ||
86 | .flags = ALWAYS_ENABLED, | ||
87 | .pclk = &osc_24m_clk, | ||
88 | .rate = 48000000, | ||
89 | }; | ||
90 | |||
91 | /* watch dog timer clock */ | ||
92 | static struct clk wdt_clk = { | ||
93 | .flags = ALWAYS_ENABLED, | ||
94 | .pclk = &osc_24m_clk, | ||
95 | .recalc = &follow_parent, | ||
96 | }; | ||
97 | |||
98 | /* clock derived from pll1 clk */ | ||
99 | /* cpu clock */ | ||
100 | static struct clk cpu_clk = { | ||
101 | .flags = ALWAYS_ENABLED, | ||
102 | .pclk = &pll1_clk, | ||
103 | .recalc = &follow_parent, | ||
104 | }; | ||
105 | |||
106 | /* ahb masks structure */ | ||
107 | static struct bus_clk_masks ahb_masks = { | ||
108 | .mask = PLL_HCLK_RATIO_MASK, | ||
109 | .shift = PLL_HCLK_RATIO_SHIFT, | ||
110 | }; | ||
111 | |||
112 | /* ahb configuration structure */ | ||
113 | static struct bus_clk_config ahb_config = { | ||
114 | .reg = CORE_CLK_CFG, | ||
115 | .masks = &ahb_masks, | ||
116 | }; | ||
117 | |||
118 | /* ahb rate configuration table, in ascending order of rates */ | ||
119 | struct bus_rate_tbl bus_rtbl[] = { | ||
120 | {.div = 3}, /* == parent divided by 4 */ | ||
121 | {.div = 2}, /* == parent divided by 3 */ | ||
122 | {.div = 1}, /* == parent divided by 2 */ | ||
123 | {.div = 0}, /* == parent divided by 1 */ | ||
124 | }; | ||
125 | |||
126 | /* ahb clock */ | ||
127 | static struct clk ahb_clk = { | ||
128 | .flags = ALWAYS_ENABLED, | ||
129 | .pclk = &pll1_clk, | ||
130 | .calc_rate = &bus_calc_rate, | ||
131 | .recalc = &bus_clk_recalc, | ||
132 | .set_rate = &bus_clk_set_rate, | ||
133 | .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2}, | ||
134 | .private_data = &ahb_config, | ||
135 | }; | ||
136 | |||
137 | /* auxiliary synthesizers masks */ | ||
138 | static struct aux_clk_masks aux_masks = { | ||
139 | .eq_sel_mask = AUX_EQ_SEL_MASK, | ||
140 | .eq_sel_shift = AUX_EQ_SEL_SHIFT, | ||
141 | .eq1_mask = AUX_EQ1_SEL, | ||
142 | .eq2_mask = AUX_EQ2_SEL, | ||
143 | .xscale_sel_mask = AUX_XSCALE_MASK, | ||
144 | .xscale_sel_shift = AUX_XSCALE_SHIFT, | ||
145 | .yscale_sel_mask = AUX_YSCALE_MASK, | ||
146 | .yscale_sel_shift = AUX_YSCALE_SHIFT, | ||
147 | }; | ||
148 | |||
149 | /* uart synth configurations */ | ||
150 | static struct aux_clk_config uart_synth_config = { | ||
151 | .synth_reg = UART_CLK_SYNT, | ||
152 | .masks = &aux_masks, | ||
153 | }; | ||
154 | |||
155 | /* aux rate configuration table, in ascending order of rates */ | ||
156 | struct aux_rate_tbl aux_rtbl[] = { | ||
157 | /* For PLL1 = 332 MHz */ | ||
158 | {.xscale = 1, .yscale = 8, .eq = 1}, /* 41.5 MHz */ | ||
159 | {.xscale = 1, .yscale = 4, .eq = 1}, /* 83 MHz */ | ||
160 | {.xscale = 1, .yscale = 2, .eq = 1}, /* 166 MHz */ | ||
161 | }; | ||
162 | |||
163 | /* uart synth clock */ | ||
164 | static struct clk uart_synth_clk = { | ||
165 | .en_reg = UART_CLK_SYNT, | ||
166 | .en_reg_bit = AUX_SYNT_ENB, | ||
167 | .pclk = &pll1_clk, | ||
168 | .calc_rate = &aux_calc_rate, | ||
169 | .recalc = &aux_clk_recalc, | ||
170 | .set_rate = &aux_clk_set_rate, | ||
171 | .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 1}, | ||
172 | .private_data = &uart_synth_config, | ||
173 | }; | ||
174 | |||
175 | /* uart parents */ | ||
176 | static struct pclk_info uart_pclk_info[] = { | ||
177 | { | ||
178 | .pclk = &uart_synth_clk, | ||
179 | .pclk_val = AUX_CLK_PLL1_VAL, | ||
180 | }, { | ||
181 | .pclk = &pll3_48m_clk, | ||
182 | .pclk_val = AUX_CLK_PLL3_VAL, | ||
183 | }, | ||
184 | }; | ||
185 | |||
186 | /* uart parent select structure */ | ||
187 | static struct pclk_sel uart_pclk_sel = { | ||
188 | .pclk_info = uart_pclk_info, | ||
189 | .pclk_count = ARRAY_SIZE(uart_pclk_info), | ||
190 | .pclk_sel_reg = PERIP_CLK_CFG, | ||
191 | .pclk_sel_mask = UART_CLK_MASK, | ||
192 | }; | ||
193 | |||
194 | /* uart clock */ | ||
195 | static struct clk uart_clk = { | ||
196 | .en_reg = PERIP1_CLK_ENB, | ||
197 | .en_reg_bit = UART_CLK_ENB, | ||
198 | .pclk_sel = &uart_pclk_sel, | ||
199 | .pclk_sel_shift = UART_CLK_SHIFT, | ||
200 | .recalc = &follow_parent, | ||
201 | }; | ||
202 | |||
203 | /* firda configurations */ | ||
204 | static struct aux_clk_config firda_synth_config = { | ||
205 | .synth_reg = FIRDA_CLK_SYNT, | ||
206 | .masks = &aux_masks, | ||
207 | }; | ||
208 | |||
209 | /* firda synth clock */ | ||
210 | static struct clk firda_synth_clk = { | ||
211 | .en_reg = FIRDA_CLK_SYNT, | ||
212 | .en_reg_bit = AUX_SYNT_ENB, | ||
213 | .pclk = &pll1_clk, | ||
214 | .calc_rate = &aux_calc_rate, | ||
215 | .recalc = &aux_clk_recalc, | ||
216 | .set_rate = &aux_clk_set_rate, | ||
217 | .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 1}, | ||
218 | .private_data = &firda_synth_config, | ||
219 | }; | ||
220 | |||
221 | /* firda parents */ | ||
222 | static struct pclk_info firda_pclk_info[] = { | ||
223 | { | ||
224 | .pclk = &firda_synth_clk, | ||
225 | .pclk_val = AUX_CLK_PLL1_VAL, | ||
226 | }, { | ||
227 | .pclk = &pll3_48m_clk, | ||
228 | .pclk_val = AUX_CLK_PLL3_VAL, | ||
229 | }, | ||
230 | }; | ||
231 | |||
232 | /* firda parent select structure */ | ||
233 | static struct pclk_sel firda_pclk_sel = { | ||
234 | .pclk_info = firda_pclk_info, | ||
235 | .pclk_count = ARRAY_SIZE(firda_pclk_info), | ||
236 | .pclk_sel_reg = PERIP_CLK_CFG, | ||
237 | .pclk_sel_mask = FIRDA_CLK_MASK, | ||
238 | }; | ||
239 | |||
240 | /* firda clock */ | ||
241 | static struct clk firda_clk = { | ||
242 | .en_reg = PERIP1_CLK_ENB, | ||
243 | .en_reg_bit = FIRDA_CLK_ENB, | ||
244 | .pclk_sel = &firda_pclk_sel, | ||
245 | .pclk_sel_shift = FIRDA_CLK_SHIFT, | ||
246 | .recalc = &follow_parent, | ||
247 | }; | ||
248 | |||
249 | /* gpt synthesizer masks */ | ||
250 | static struct gpt_clk_masks gpt_masks = { | ||
251 | .mscale_sel_mask = GPT_MSCALE_MASK, | ||
252 | .mscale_sel_shift = GPT_MSCALE_SHIFT, | ||
253 | .nscale_sel_mask = GPT_NSCALE_MASK, | ||
254 | .nscale_sel_shift = GPT_NSCALE_SHIFT, | ||
255 | }; | ||
256 | |||
257 | /* gpt rate configuration table, in ascending order of rates */ | ||
258 | struct gpt_rate_tbl gpt_rtbl[] = { | ||
259 | /* For pll1 = 332 MHz */ | ||
260 | {.mscale = 4, .nscale = 0}, /* 41.5 MHz */ | ||
261 | {.mscale = 2, .nscale = 0}, /* 55.3 MHz */ | ||
262 | {.mscale = 1, .nscale = 0}, /* 83 MHz */ | ||
263 | }; | ||
264 | |||
265 | /* gpt0 synth clk config*/ | ||
266 | static struct gpt_clk_config gpt0_synth_config = { | ||
267 | .synth_reg = PRSC1_CLK_CFG, | ||
268 | .masks = &gpt_masks, | ||
269 | }; | ||
270 | |||
271 | /* gpt synth clock */ | ||
272 | static struct clk gpt0_synth_clk = { | ||
273 | .flags = ALWAYS_ENABLED, | ||
274 | .pclk = &pll1_clk, | ||
275 | .calc_rate = &gpt_calc_rate, | ||
276 | .recalc = &gpt_clk_recalc, | ||
277 | .set_rate = &gpt_clk_set_rate, | ||
278 | .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2}, | ||
279 | .private_data = &gpt0_synth_config, | ||
280 | }; | ||
281 | |||
282 | /* gpt parents */ | ||
283 | static struct pclk_info gpt0_pclk_info[] = { | ||
284 | { | ||
285 | .pclk = &gpt0_synth_clk, | ||
286 | .pclk_val = AUX_CLK_PLL1_VAL, | ||
287 | }, { | ||
288 | .pclk = &pll3_48m_clk, | ||
289 | .pclk_val = AUX_CLK_PLL3_VAL, | ||
290 | }, | ||
291 | }; | ||
292 | |||
293 | /* gpt parent select structure */ | ||
294 | static struct pclk_sel gpt0_pclk_sel = { | ||
295 | .pclk_info = gpt0_pclk_info, | ||
296 | .pclk_count = ARRAY_SIZE(gpt0_pclk_info), | ||
297 | .pclk_sel_reg = PERIP_CLK_CFG, | ||
298 | .pclk_sel_mask = GPT_CLK_MASK, | ||
299 | }; | ||
300 | |||
301 | /* gpt0 timer clock */ | ||
302 | static struct clk gpt0_clk = { | ||
303 | .flags = ALWAYS_ENABLED, | ||
304 | .pclk_sel = &gpt0_pclk_sel, | ||
305 | .pclk_sel_shift = GPT0_CLK_SHIFT, | ||
306 | .recalc = &follow_parent, | ||
307 | }; | ||
308 | |||
309 | /* gpt1 synth clk configurations */ | ||
310 | static struct gpt_clk_config gpt1_synth_config = { | ||
311 | .synth_reg = PRSC2_CLK_CFG, | ||
312 | .masks = &gpt_masks, | ||
313 | }; | ||
314 | |||
315 | /* gpt1 synth clock */ | ||
316 | static struct clk gpt1_synth_clk = { | ||
317 | .flags = ALWAYS_ENABLED, | ||
318 | .pclk = &pll1_clk, | ||
319 | .calc_rate = &gpt_calc_rate, | ||
320 | .recalc = &gpt_clk_recalc, | ||
321 | .set_rate = &gpt_clk_set_rate, | ||
322 | .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2}, | ||
323 | .private_data = &gpt1_synth_config, | ||
324 | }; | ||
325 | |||
326 | static struct pclk_info gpt1_pclk_info[] = { | ||
327 | { | ||
328 | .pclk = &gpt1_synth_clk, | ||
329 | .pclk_val = AUX_CLK_PLL1_VAL, | ||
330 | }, { | ||
331 | .pclk = &pll3_48m_clk, | ||
332 | .pclk_val = AUX_CLK_PLL3_VAL, | ||
333 | }, | ||
334 | }; | ||
335 | |||
336 | /* gpt parent select structure */ | ||
337 | static struct pclk_sel gpt1_pclk_sel = { | ||
338 | .pclk_info = gpt1_pclk_info, | ||
339 | .pclk_count = ARRAY_SIZE(gpt1_pclk_info), | ||
340 | .pclk_sel_reg = PERIP_CLK_CFG, | ||
341 | .pclk_sel_mask = GPT_CLK_MASK, | ||
342 | }; | ||
343 | |||
344 | /* gpt1 timer clock */ | ||
345 | static struct clk gpt1_clk = { | ||
346 | .en_reg = PERIP1_CLK_ENB, | ||
347 | .en_reg_bit = GPT1_CLK_ENB, | ||
348 | .pclk_sel = &gpt1_pclk_sel, | ||
349 | .pclk_sel_shift = GPT1_CLK_SHIFT, | ||
350 | .recalc = &follow_parent, | ||
351 | }; | ||
352 | |||
353 | /* gpt2 synth clk configurations */ | ||
354 | static struct gpt_clk_config gpt2_synth_config = { | ||
355 | .synth_reg = PRSC3_CLK_CFG, | ||
356 | .masks = &gpt_masks, | ||
357 | }; | ||
358 | |||
359 | /* gpt1 synth clock */ | ||
360 | static struct clk gpt2_synth_clk = { | ||
361 | .flags = ALWAYS_ENABLED, | ||
362 | .pclk = &pll1_clk, | ||
363 | .calc_rate = &gpt_calc_rate, | ||
364 | .recalc = &gpt_clk_recalc, | ||
365 | .set_rate = &gpt_clk_set_rate, | ||
366 | .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2}, | ||
367 | .private_data = &gpt2_synth_config, | ||
368 | }; | ||
369 | |||
370 | static struct pclk_info gpt2_pclk_info[] = { | ||
371 | { | ||
372 | .pclk = &gpt2_synth_clk, | ||
373 | .pclk_val = AUX_CLK_PLL1_VAL, | ||
374 | }, { | ||
375 | .pclk = &pll3_48m_clk, | ||
376 | .pclk_val = AUX_CLK_PLL3_VAL, | ||
377 | }, | ||
378 | }; | ||
379 | |||
380 | /* gpt parent select structure */ | ||
381 | static struct pclk_sel gpt2_pclk_sel = { | ||
382 | .pclk_info = gpt2_pclk_info, | ||
383 | .pclk_count = ARRAY_SIZE(gpt2_pclk_info), | ||
384 | .pclk_sel_reg = PERIP_CLK_CFG, | ||
385 | .pclk_sel_mask = GPT_CLK_MASK, | ||
386 | }; | ||
387 | |||
388 | /* gpt2 timer clock */ | ||
389 | static struct clk gpt2_clk = { | ||
390 | .en_reg = PERIP1_CLK_ENB, | ||
391 | .en_reg_bit = GPT2_CLK_ENB, | ||
392 | .pclk_sel = &gpt2_pclk_sel, | ||
393 | .pclk_sel_shift = GPT2_CLK_SHIFT, | ||
394 | .recalc = &follow_parent, | ||
395 | }; | ||
396 | |||
397 | /* clock derived from pll3 clk */ | ||
398 | /* usbh clock */ | ||
399 | static struct clk usbh_clk = { | ||
400 | .pclk = &pll3_48m_clk, | ||
401 | .en_reg = PERIP1_CLK_ENB, | ||
402 | .en_reg_bit = USBH_CLK_ENB, | ||
403 | .recalc = &follow_parent, | ||
404 | }; | ||
405 | |||
406 | /* usbd clock */ | ||
407 | static struct clk usbd_clk = { | ||
408 | .pclk = &pll3_48m_clk, | ||
409 | .en_reg = PERIP1_CLK_ENB, | ||
410 | .en_reg_bit = USBD_CLK_ENB, | ||
411 | .recalc = &follow_parent, | ||
412 | }; | ||
413 | |||
414 | /* clock derived from ahb clk */ | ||
415 | /* apb masks structure */ | ||
416 | static struct bus_clk_masks apb_masks = { | ||
417 | .mask = HCLK_PCLK_RATIO_MASK, | ||
418 | .shift = HCLK_PCLK_RATIO_SHIFT, | ||
419 | }; | ||
420 | |||
421 | /* apb configuration structure */ | ||
422 | static struct bus_clk_config apb_config = { | ||
423 | .reg = CORE_CLK_CFG, | ||
424 | .masks = &apb_masks, | ||
425 | }; | ||
426 | |||
427 | /* apb clock */ | ||
428 | static struct clk apb_clk = { | ||
429 | .flags = ALWAYS_ENABLED, | ||
430 | .pclk = &ahb_clk, | ||
431 | .calc_rate = &bus_calc_rate, | ||
432 | .recalc = &bus_clk_recalc, | ||
433 | .set_rate = &bus_clk_set_rate, | ||
434 | .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2}, | ||
435 | .private_data = &apb_config, | ||
436 | }; | ||
437 | |||
438 | /* i2c clock */ | ||
439 | static struct clk i2c_clk = { | ||
440 | .pclk = &ahb_clk, | ||
441 | .en_reg = PERIP1_CLK_ENB, | ||
442 | .en_reg_bit = I2C_CLK_ENB, | ||
443 | .recalc = &follow_parent, | ||
444 | }; | ||
445 | |||
446 | /* dma clock */ | ||
447 | static struct clk dma_clk = { | ||
448 | .pclk = &ahb_clk, | ||
449 | .en_reg = PERIP1_CLK_ENB, | ||
450 | .en_reg_bit = DMA_CLK_ENB, | ||
451 | .recalc = &follow_parent, | ||
452 | }; | ||
453 | |||
454 | /* jpeg clock */ | ||
455 | static struct clk jpeg_clk = { | ||
456 | .pclk = &ahb_clk, | ||
457 | .en_reg = PERIP1_CLK_ENB, | ||
458 | .en_reg_bit = JPEG_CLK_ENB, | ||
459 | .recalc = &follow_parent, | ||
460 | }; | ||
461 | |||
462 | /* gmac clock */ | ||
463 | static struct clk gmac_clk = { | ||
464 | .pclk = &ahb_clk, | ||
465 | .en_reg = PERIP1_CLK_ENB, | ||
466 | .en_reg_bit = GMAC_CLK_ENB, | ||
467 | .recalc = &follow_parent, | ||
468 | }; | ||
469 | |||
470 | /* smi clock */ | ||
471 | static struct clk smi_clk = { | ||
472 | .pclk = &ahb_clk, | ||
473 | .en_reg = PERIP1_CLK_ENB, | ||
474 | .en_reg_bit = SMI_CLK_ENB, | ||
475 | .recalc = &follow_parent, | ||
476 | }; | ||
477 | |||
478 | /* c3 clock */ | ||
479 | static struct clk c3_clk = { | ||
480 | .pclk = &ahb_clk, | ||
481 | .en_reg = PERIP1_CLK_ENB, | ||
482 | .en_reg_bit = C3_CLK_ENB, | ||
483 | .recalc = &follow_parent, | ||
484 | }; | ||
485 | |||
486 | /* clock derived from apb clk */ | ||
487 | /* adc clock */ | ||
488 | static struct clk adc_clk = { | ||
489 | .pclk = &apb_clk, | ||
490 | .en_reg = PERIP1_CLK_ENB, | ||
491 | .en_reg_bit = ADC_CLK_ENB, | ||
492 | .recalc = &follow_parent, | ||
493 | }; | ||
494 | |||
495 | #if defined(CONFIG_MACH_SPEAR310) || defined(CONFIG_MACH_SPEAR320) | ||
496 | /* emi clock */ | ||
497 | static struct clk emi_clk = { | ||
498 | .flags = ALWAYS_ENABLED, | ||
499 | .pclk = &ahb_clk, | ||
500 | .recalc = &follow_parent, | ||
501 | }; | ||
502 | #endif | ||
503 | |||
504 | /* ssp clock */ | ||
505 | static struct clk ssp0_clk = { | ||
506 | .pclk = &apb_clk, | ||
507 | .en_reg = PERIP1_CLK_ENB, | ||
508 | .en_reg_bit = SSP_CLK_ENB, | ||
509 | .recalc = &follow_parent, | ||
510 | }; | ||
511 | |||
512 | /* gpio clock */ | ||
513 | static struct clk gpio_clk = { | ||
514 | .pclk = &apb_clk, | ||
515 | .en_reg = PERIP1_CLK_ENB, | ||
516 | .en_reg_bit = GPIO_CLK_ENB, | ||
517 | .recalc = &follow_parent, | ||
518 | }; | ||
519 | |||
520 | static struct clk dummy_apb_pclk; | ||
521 | |||
522 | #if defined(CONFIG_MACH_SPEAR300) || defined(CONFIG_MACH_SPEAR310) || \ | ||
523 | defined(CONFIG_MACH_SPEAR320) | ||
524 | /* fsmc clock */ | ||
525 | static struct clk fsmc_clk = { | ||
526 | .flags = ALWAYS_ENABLED, | ||
527 | .pclk = &ahb_clk, | ||
528 | .recalc = &follow_parent, | ||
529 | }; | ||
530 | #endif | ||
531 | |||
532 | /* common clocks to spear310 and spear320 */ | ||
533 | #if defined(CONFIG_MACH_SPEAR310) || defined(CONFIG_MACH_SPEAR320) | ||
534 | /* uart1 clock */ | ||
535 | static struct clk uart1_clk = { | ||
536 | .flags = ALWAYS_ENABLED, | ||
537 | .pclk = &apb_clk, | ||
538 | .recalc = &follow_parent, | ||
539 | }; | ||
540 | |||
541 | /* uart2 clock */ | ||
542 | static struct clk uart2_clk = { | ||
543 | .flags = ALWAYS_ENABLED, | ||
544 | .pclk = &apb_clk, | ||
545 | .recalc = &follow_parent, | ||
546 | }; | ||
547 | #endif /* CONFIG_MACH_SPEAR310 || CONFIG_MACH_SPEAR320 */ | ||
548 | |||
549 | /* common clocks to spear300 and spear320 */ | ||
550 | #if defined(CONFIG_MACH_SPEAR300) || defined(CONFIG_MACH_SPEAR320) | ||
551 | /* clcd clock */ | ||
552 | static struct clk clcd_clk = { | ||
553 | .flags = ALWAYS_ENABLED, | ||
554 | .pclk = &pll3_48m_clk, | ||
555 | .recalc = &follow_parent, | ||
556 | }; | ||
557 | |||
558 | /* sdhci clock */ | ||
559 | static struct clk sdhci_clk = { | ||
560 | .flags = ALWAYS_ENABLED, | ||
561 | .pclk = &ahb_clk, | ||
562 | .recalc = &follow_parent, | ||
563 | }; | ||
564 | #endif /* CONFIG_MACH_SPEAR300 || CONFIG_MACH_SPEAR320 */ | ||
565 | |||
566 | /* spear300 machine specific clock structures */ | ||
567 | #ifdef CONFIG_MACH_SPEAR300 | ||
568 | /* gpio1 clock */ | ||
569 | static struct clk gpio1_clk = { | ||
570 | .flags = ALWAYS_ENABLED, | ||
571 | .pclk = &apb_clk, | ||
572 | .recalc = &follow_parent, | ||
573 | }; | ||
574 | |||
575 | /* keyboard clock */ | ||
576 | static struct clk kbd_clk = { | ||
577 | .flags = ALWAYS_ENABLED, | ||
578 | .pclk = &apb_clk, | ||
579 | .recalc = &follow_parent, | ||
580 | }; | ||
581 | |||
582 | #endif | ||
583 | |||
584 | /* spear310 machine specific clock structures */ | ||
585 | #ifdef CONFIG_MACH_SPEAR310 | ||
586 | /* uart3 clock */ | ||
587 | static struct clk uart3_clk = { | ||
588 | .flags = ALWAYS_ENABLED, | ||
589 | .pclk = &apb_clk, | ||
590 | .recalc = &follow_parent, | ||
591 | }; | ||
592 | |||
593 | /* uart4 clock */ | ||
594 | static struct clk uart4_clk = { | ||
595 | .flags = ALWAYS_ENABLED, | ||
596 | .pclk = &apb_clk, | ||
597 | .recalc = &follow_parent, | ||
598 | }; | ||
599 | |||
600 | /* uart5 clock */ | ||
601 | static struct clk uart5_clk = { | ||
602 | .flags = ALWAYS_ENABLED, | ||
603 | .pclk = &apb_clk, | ||
604 | .recalc = &follow_parent, | ||
605 | }; | ||
606 | #endif | ||
607 | |||
608 | /* spear320 machine specific clock structures */ | ||
609 | #ifdef CONFIG_MACH_SPEAR320 | ||
610 | /* can0 clock */ | ||
611 | static struct clk can0_clk = { | ||
612 | .flags = ALWAYS_ENABLED, | ||
613 | .pclk = &apb_clk, | ||
614 | .recalc = &follow_parent, | ||
615 | }; | ||
616 | |||
617 | /* can1 clock */ | ||
618 | static struct clk can1_clk = { | ||
619 | .flags = ALWAYS_ENABLED, | ||
620 | .pclk = &apb_clk, | ||
621 | .recalc = &follow_parent, | ||
622 | }; | ||
623 | |||
624 | /* i2c1 clock */ | ||
625 | static struct clk i2c1_clk = { | ||
626 | .flags = ALWAYS_ENABLED, | ||
627 | .pclk = &ahb_clk, | ||
628 | .recalc = &follow_parent, | ||
629 | }; | ||
630 | |||
631 | /* ssp1 clock */ | ||
632 | static struct clk ssp1_clk = { | ||
633 | .flags = ALWAYS_ENABLED, | ||
634 | .pclk = &apb_clk, | ||
635 | .recalc = &follow_parent, | ||
636 | }; | ||
637 | |||
638 | /* ssp2 clock */ | ||
639 | static struct clk ssp2_clk = { | ||
640 | .flags = ALWAYS_ENABLED, | ||
641 | .pclk = &apb_clk, | ||
642 | .recalc = &follow_parent, | ||
643 | }; | ||
644 | |||
645 | /* pwm clock */ | ||
646 | static struct clk pwm_clk = { | ||
647 | .flags = ALWAYS_ENABLED, | ||
648 | .pclk = &apb_clk, | ||
649 | .recalc = &follow_parent, | ||
650 | }; | ||
651 | #endif | ||
652 | |||
653 | /* array of all spear 3xx clock lookups */ | ||
654 | static struct clk_lookup spear_clk_lookups[] = { | ||
655 | { .con_id = "apb_pclk", .clk = &dummy_apb_pclk}, | ||
656 | /* root clks */ | ||
657 | { .con_id = "osc_32k_clk", .clk = &osc_32k_clk}, | ||
658 | { .con_id = "osc_24m_clk", .clk = &osc_24m_clk}, | ||
659 | /* clock derived from 32 KHz osc clk */ | ||
660 | { .dev_id = "rtc-spear", .clk = &rtc_clk}, | ||
661 | /* clock derived from 24 MHz osc clk */ | ||
662 | { .con_id = "pll1_clk", .clk = &pll1_clk}, | ||
663 | { .con_id = "pll3_48m_clk", .clk = &pll3_48m_clk}, | ||
664 | { .dev_id = "wdt", .clk = &wdt_clk}, | ||
665 | /* clock derived from pll1 clk */ | ||
666 | { .con_id = "cpu_clk", .clk = &cpu_clk}, | ||
667 | { .con_id = "ahb_clk", .clk = &ahb_clk}, | ||
668 | { .con_id = "uart_synth_clk", .clk = &uart_synth_clk}, | ||
669 | { .con_id = "firda_synth_clk", .clk = &firda_synth_clk}, | ||
670 | { .con_id = "gpt0_synth_clk", .clk = &gpt0_synth_clk}, | ||
671 | { .con_id = "gpt1_synth_clk", .clk = &gpt1_synth_clk}, | ||
672 | { .con_id = "gpt2_synth_clk", .clk = &gpt2_synth_clk}, | ||
673 | { .dev_id = "uart", .clk = &uart_clk}, | ||
674 | { .dev_id = "firda", .clk = &firda_clk}, | ||
675 | { .dev_id = "gpt0", .clk = &gpt0_clk}, | ||
676 | { .dev_id = "gpt1", .clk = &gpt1_clk}, | ||
677 | { .dev_id = "gpt2", .clk = &gpt2_clk}, | ||
678 | /* clock derived from pll3 clk */ | ||
679 | { .dev_id = "designware_udc", .clk = &usbd_clk}, | ||
680 | { .con_id = "usbh_clk", .clk = &usbh_clk}, | ||
681 | /* clock derived from ahb clk */ | ||
682 | { .con_id = "apb_clk", .clk = &apb_clk}, | ||
683 | { .dev_id = "i2c_designware.0", .clk = &i2c_clk}, | ||
684 | { .dev_id = "dma", .clk = &dma_clk}, | ||
685 | { .dev_id = "jpeg", .clk = &jpeg_clk}, | ||
686 | { .dev_id = "gmac", .clk = &gmac_clk}, | ||
687 | { .dev_id = "smi", .clk = &smi_clk}, | ||
688 | { .dev_id = "c3", .clk = &c3_clk}, | ||
689 | /* clock derived from apb clk */ | ||
690 | { .dev_id = "adc", .clk = &adc_clk}, | ||
691 | { .dev_id = "ssp-pl022.0", .clk = &ssp0_clk}, | ||
692 | { .dev_id = "gpio", .clk = &gpio_clk}, | ||
693 | }; | ||
694 | |||
695 | /* array of all spear 300 clock lookups */ | ||
696 | #ifdef CONFIG_MACH_SPEAR300 | ||
697 | static struct clk_lookup spear300_clk_lookups[] = { | ||
698 | { .dev_id = "clcd", .clk = &clcd_clk}, | ||
699 | { .con_id = "fsmc", .clk = &fsmc_clk}, | ||
700 | { .dev_id = "gpio1", .clk = &gpio1_clk}, | ||
701 | { .dev_id = "keyboard", .clk = &kbd_clk}, | ||
702 | { .dev_id = "sdhci", .clk = &sdhci_clk}, | ||
703 | }; | ||
704 | #endif | ||
705 | |||
706 | /* array of all spear 310 clock lookups */ | ||
707 | #ifdef CONFIG_MACH_SPEAR310 | ||
708 | static struct clk_lookup spear310_clk_lookups[] = { | ||
709 | { .con_id = "fsmc", .clk = &fsmc_clk}, | ||
710 | { .con_id = "emi", .clk = &emi_clk}, | ||
711 | { .dev_id = "uart1", .clk = &uart1_clk}, | ||
712 | { .dev_id = "uart2", .clk = &uart2_clk}, | ||
713 | { .dev_id = "uart3", .clk = &uart3_clk}, | ||
714 | { .dev_id = "uart4", .clk = &uart4_clk}, | ||
715 | { .dev_id = "uart5", .clk = &uart5_clk}, | ||
716 | }; | ||
717 | #endif | ||
718 | |||
719 | /* array of all spear 320 clock lookups */ | ||
720 | #ifdef CONFIG_MACH_SPEAR320 | ||
721 | static struct clk_lookup spear320_clk_lookups[] = { | ||
722 | { .dev_id = "clcd", .clk = &clcd_clk}, | ||
723 | { .con_id = "fsmc", .clk = &fsmc_clk}, | ||
724 | { .dev_id = "i2c_designware.1", .clk = &i2c1_clk}, | ||
725 | { .con_id = "emi", .clk = &emi_clk}, | ||
726 | { .dev_id = "pwm", .clk = &pwm_clk}, | ||
727 | { .dev_id = "sdhci", .clk = &sdhci_clk}, | ||
728 | { .dev_id = "c_can_platform.0", .clk = &can0_clk}, | ||
729 | { .dev_id = "c_can_platform.1", .clk = &can1_clk}, | ||
730 | { .dev_id = "ssp-pl022.1", .clk = &ssp1_clk}, | ||
731 | { .dev_id = "ssp-pl022.2", .clk = &ssp2_clk}, | ||
732 | { .dev_id = "uart1", .clk = &uart1_clk}, | ||
733 | { .dev_id = "uart2", .clk = &uart2_clk}, | ||
734 | }; | ||
735 | #endif | ||
736 | |||
737 | void __init spear3xx_clk_init(void) | ||
738 | { | ||
739 | int i, cnt; | ||
740 | struct clk_lookup *lookups; | ||
741 | |||
742 | if (machine_is_spear300()) { | ||
743 | cnt = ARRAY_SIZE(spear300_clk_lookups); | ||
744 | lookups = spear300_clk_lookups; | ||
745 | } else if (machine_is_spear310()) { | ||
746 | cnt = ARRAY_SIZE(spear310_clk_lookups); | ||
747 | lookups = spear310_clk_lookups; | ||
748 | } else { | ||
749 | cnt = ARRAY_SIZE(spear320_clk_lookups); | ||
750 | lookups = spear320_clk_lookups; | ||
751 | } | ||
752 | |||
753 | for (i = 0; i < ARRAY_SIZE(spear_clk_lookups); i++) | ||
754 | clk_register(&spear_clk_lookups[i]); | ||
755 | |||
756 | for (i = 0; i < cnt; i++) | ||
757 | clk_register(&lookups[i]); | ||
758 | |||
759 | clk_init(); | ||
760 | } | ||
diff --git a/arch/arm/mach-spear3xx/include/mach/generic.h b/arch/arm/mach-spear3xx/include/mach/generic.h index 14276e5a98d2..4a95b9453c2a 100644 --- a/arch/arm/mach-spear3xx/include/mach/generic.h +++ b/arch/arm/mach-spear3xx/include/mach/generic.h | |||
@@ -14,189 +14,24 @@ | |||
14 | #ifndef __MACH_GENERIC_H | 14 | #ifndef __MACH_GENERIC_H |
15 | #define __MACH_GENERIC_H | 15 | #define __MACH_GENERIC_H |
16 | 16 | ||
17 | #include <linux/amba/pl08x.h> | ||
17 | #include <linux/init.h> | 18 | #include <linux/init.h> |
18 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
19 | #include <linux/amba/bus.h> | 20 | #include <linux/amba/bus.h> |
20 | #include <asm/mach/time.h> | 21 | #include <asm/mach/time.h> |
21 | #include <asm/mach/map.h> | 22 | #include <asm/mach/map.h> |
22 | #include <plat/padmux.h> | ||
23 | |||
24 | /* spear3xx declarations */ | ||
25 | /* | ||
26 | * Each GPT has 2 timer channels | ||
27 | * Following GPT channels will be used as clock source and clockevent | ||
28 | */ | ||
29 | #define SPEAR_GPT0_BASE SPEAR3XX_ML1_TMR_BASE | ||
30 | #define SPEAR_GPT0_CHAN0_IRQ SPEAR3XX_IRQ_CPU_GPT1_1 | ||
31 | #define SPEAR_GPT0_CHAN1_IRQ SPEAR3XX_IRQ_CPU_GPT1_2 | ||
32 | 23 | ||
33 | /* Add spear3xx family device structure declarations here */ | 24 | /* Add spear3xx family device structure declarations here */ |
34 | extern struct amba_device spear3xx_gpio_device; | ||
35 | extern struct amba_device spear3xx_uart_device; | ||
36 | extern struct sys_timer spear3xx_timer; | 25 | extern struct sys_timer spear3xx_timer; |
26 | extern struct pl022_ssp_controller pl022_plat_data; | ||
27 | extern struct pl08x_platform_data pl080_plat_data; | ||
37 | 28 | ||
38 | /* Add spear3xx family function declarations here */ | 29 | /* Add spear3xx family function declarations here */ |
30 | void __init spear_setup_of_timer(void); | ||
39 | void __init spear3xx_clk_init(void); | 31 | void __init spear3xx_clk_init(void); |
40 | void __init spear_setup_timer(void); | ||
41 | void __init spear3xx_map_io(void); | 32 | void __init spear3xx_map_io(void); |
42 | void __init spear3xx_init_irq(void); | 33 | void __init spear3xx_dt_init_irq(void); |
43 | void __init spear3xx_init(void); | ||
44 | 34 | ||
45 | void spear_restart(char, const char *); | 35 | void spear_restart(char, const char *); |
46 | 36 | ||
47 | /* pad mux declarations */ | ||
48 | #define PMX_FIRDA_MASK (1 << 14) | ||
49 | #define PMX_I2C_MASK (1 << 13) | ||
50 | #define PMX_SSP_CS_MASK (1 << 12) | ||
51 | #define PMX_SSP_MASK (1 << 11) | ||
52 | #define PMX_MII_MASK (1 << 10) | ||
53 | #define PMX_GPIO_PIN0_MASK (1 << 9) | ||
54 | #define PMX_GPIO_PIN1_MASK (1 << 8) | ||
55 | #define PMX_GPIO_PIN2_MASK (1 << 7) | ||
56 | #define PMX_GPIO_PIN3_MASK (1 << 6) | ||
57 | #define PMX_GPIO_PIN4_MASK (1 << 5) | ||
58 | #define PMX_GPIO_PIN5_MASK (1 << 4) | ||
59 | #define PMX_UART0_MODEM_MASK (1 << 3) | ||
60 | #define PMX_UART0_MASK (1 << 2) | ||
61 | #define PMX_TIMER_3_4_MASK (1 << 1) | ||
62 | #define PMX_TIMER_1_2_MASK (1 << 0) | ||
63 | |||
64 | /* pad mux devices */ | ||
65 | extern struct pmx_dev spear3xx_pmx_firda; | ||
66 | extern struct pmx_dev spear3xx_pmx_i2c; | ||
67 | extern struct pmx_dev spear3xx_pmx_ssp_cs; | ||
68 | extern struct pmx_dev spear3xx_pmx_ssp; | ||
69 | extern struct pmx_dev spear3xx_pmx_mii; | ||
70 | extern struct pmx_dev spear3xx_pmx_gpio_pin0; | ||
71 | extern struct pmx_dev spear3xx_pmx_gpio_pin1; | ||
72 | extern struct pmx_dev spear3xx_pmx_gpio_pin2; | ||
73 | extern struct pmx_dev spear3xx_pmx_gpio_pin3; | ||
74 | extern struct pmx_dev spear3xx_pmx_gpio_pin4; | ||
75 | extern struct pmx_dev spear3xx_pmx_gpio_pin5; | ||
76 | extern struct pmx_dev spear3xx_pmx_uart0_modem; | ||
77 | extern struct pmx_dev spear3xx_pmx_uart0; | ||
78 | extern struct pmx_dev spear3xx_pmx_timer_3_4; | ||
79 | extern struct pmx_dev spear3xx_pmx_timer_1_2; | ||
80 | |||
81 | #if defined(CONFIG_MACH_SPEAR310) || defined(CONFIG_MACH_SPEAR320) | ||
82 | /* padmux plgpio devices */ | ||
83 | extern struct pmx_dev spear3xx_pmx_plgpio_0_1; | ||
84 | extern struct pmx_dev spear3xx_pmx_plgpio_2_3; | ||
85 | extern struct pmx_dev spear3xx_pmx_plgpio_4_5; | ||
86 | extern struct pmx_dev spear3xx_pmx_plgpio_6_9; | ||
87 | extern struct pmx_dev spear3xx_pmx_plgpio_10_27; | ||
88 | extern struct pmx_dev spear3xx_pmx_plgpio_28; | ||
89 | extern struct pmx_dev spear3xx_pmx_plgpio_29; | ||
90 | extern struct pmx_dev spear3xx_pmx_plgpio_30; | ||
91 | extern struct pmx_dev spear3xx_pmx_plgpio_31; | ||
92 | extern struct pmx_dev spear3xx_pmx_plgpio_32; | ||
93 | extern struct pmx_dev spear3xx_pmx_plgpio_33; | ||
94 | extern struct pmx_dev spear3xx_pmx_plgpio_34_36; | ||
95 | extern struct pmx_dev spear3xx_pmx_plgpio_37_42; | ||
96 | extern struct pmx_dev spear3xx_pmx_plgpio_43_44_47_48; | ||
97 | extern struct pmx_dev spear3xx_pmx_plgpio_45_46_49_50; | ||
98 | #endif | ||
99 | |||
100 | /* spear300 declarations */ | ||
101 | #ifdef CONFIG_MACH_SPEAR300 | ||
102 | /* Add spear300 machine device structure declarations here */ | ||
103 | extern struct amba_device spear300_gpio1_device; | ||
104 | |||
105 | /* pad mux modes */ | ||
106 | extern struct pmx_mode spear300_nand_mode; | ||
107 | extern struct pmx_mode spear300_nor_mode; | ||
108 | extern struct pmx_mode spear300_photo_frame_mode; | ||
109 | extern struct pmx_mode spear300_lend_ip_phone_mode; | ||
110 | extern struct pmx_mode spear300_hend_ip_phone_mode; | ||
111 | extern struct pmx_mode spear300_lend_wifi_phone_mode; | ||
112 | extern struct pmx_mode spear300_hend_wifi_phone_mode; | ||
113 | extern struct pmx_mode spear300_ata_pabx_wi2s_mode; | ||
114 | extern struct pmx_mode spear300_ata_pabx_i2s_mode; | ||
115 | extern struct pmx_mode spear300_caml_lcdw_mode; | ||
116 | extern struct pmx_mode spear300_camu_lcd_mode; | ||
117 | extern struct pmx_mode spear300_camu_wlcd_mode; | ||
118 | extern struct pmx_mode spear300_caml_lcd_mode; | ||
119 | |||
120 | /* pad mux devices */ | ||
121 | extern struct pmx_dev spear300_pmx_fsmc_2_chips; | ||
122 | extern struct pmx_dev spear300_pmx_fsmc_4_chips; | ||
123 | extern struct pmx_dev spear300_pmx_keyboard; | ||
124 | extern struct pmx_dev spear300_pmx_clcd; | ||
125 | extern struct pmx_dev spear300_pmx_telecom_gpio; | ||
126 | extern struct pmx_dev spear300_pmx_telecom_tdm; | ||
127 | extern struct pmx_dev spear300_pmx_telecom_spi_cs_i2c_clk; | ||
128 | extern struct pmx_dev spear300_pmx_telecom_camera; | ||
129 | extern struct pmx_dev spear300_pmx_telecom_dac; | ||
130 | extern struct pmx_dev spear300_pmx_telecom_i2s; | ||
131 | extern struct pmx_dev spear300_pmx_telecom_boot_pins; | ||
132 | extern struct pmx_dev spear300_pmx_telecom_sdhci_4bit; | ||
133 | extern struct pmx_dev spear300_pmx_telecom_sdhci_8bit; | ||
134 | extern struct pmx_dev spear300_pmx_gpio1; | ||
135 | |||
136 | /* Add spear300 machine function declarations here */ | ||
137 | void __init spear300_init(struct pmx_mode *pmx_mode, struct pmx_dev **pmx_devs, | ||
138 | u8 pmx_dev_count); | ||
139 | |||
140 | #endif /* CONFIG_MACH_SPEAR300 */ | ||
141 | |||
142 | /* spear310 declarations */ | ||
143 | #ifdef CONFIG_MACH_SPEAR310 | ||
144 | /* Add spear310 machine device structure declarations here */ | ||
145 | |||
146 | /* pad mux devices */ | ||
147 | extern struct pmx_dev spear310_pmx_emi_cs_0_1_4_5; | ||
148 | extern struct pmx_dev spear310_pmx_emi_cs_2_3; | ||
149 | extern struct pmx_dev spear310_pmx_uart1; | ||
150 | extern struct pmx_dev spear310_pmx_uart2; | ||
151 | extern struct pmx_dev spear310_pmx_uart3_4_5; | ||
152 | extern struct pmx_dev spear310_pmx_fsmc; | ||
153 | extern struct pmx_dev spear310_pmx_rs485_0_1; | ||
154 | extern struct pmx_dev spear310_pmx_tdm0; | ||
155 | |||
156 | /* Add spear310 machine function declarations here */ | ||
157 | void __init spear310_init(struct pmx_mode *pmx_mode, struct pmx_dev **pmx_devs, | ||
158 | u8 pmx_dev_count); | ||
159 | |||
160 | #endif /* CONFIG_MACH_SPEAR310 */ | ||
161 | |||
162 | /* spear320 declarations */ | ||
163 | #ifdef CONFIG_MACH_SPEAR320 | ||
164 | /* Add spear320 machine device structure declarations here */ | ||
165 | |||
166 | /* pad mux modes */ | ||
167 | extern struct pmx_mode spear320_auto_net_smii_mode; | ||
168 | extern struct pmx_mode spear320_auto_net_mii_mode; | ||
169 | extern struct pmx_mode spear320_auto_exp_mode; | ||
170 | extern struct pmx_mode spear320_small_printers_mode; | ||
171 | |||
172 | /* pad mux devices */ | ||
173 | extern struct pmx_dev spear320_pmx_clcd; | ||
174 | extern struct pmx_dev spear320_pmx_emi; | ||
175 | extern struct pmx_dev spear320_pmx_fsmc; | ||
176 | extern struct pmx_dev spear320_pmx_spp; | ||
177 | extern struct pmx_dev spear320_pmx_sdhci; | ||
178 | extern struct pmx_dev spear320_pmx_i2s; | ||
179 | extern struct pmx_dev spear320_pmx_uart1; | ||
180 | extern struct pmx_dev spear320_pmx_uart1_modem; | ||
181 | extern struct pmx_dev spear320_pmx_uart2; | ||
182 | extern struct pmx_dev spear320_pmx_touchscreen; | ||
183 | extern struct pmx_dev spear320_pmx_can; | ||
184 | extern struct pmx_dev spear320_pmx_sdhci_led; | ||
185 | extern struct pmx_dev spear320_pmx_pwm0; | ||
186 | extern struct pmx_dev spear320_pmx_pwm1; | ||
187 | extern struct pmx_dev spear320_pmx_pwm2; | ||
188 | extern struct pmx_dev spear320_pmx_pwm3; | ||
189 | extern struct pmx_dev spear320_pmx_ssp1; | ||
190 | extern struct pmx_dev spear320_pmx_ssp2; | ||
191 | extern struct pmx_dev spear320_pmx_mii1; | ||
192 | extern struct pmx_dev spear320_pmx_smii0; | ||
193 | extern struct pmx_dev spear320_pmx_smii1; | ||
194 | extern struct pmx_dev spear320_pmx_i2c1; | ||
195 | |||
196 | /* Add spear320 machine function declarations here */ | ||
197 | void __init spear320_init(struct pmx_mode *pmx_mode, struct pmx_dev **pmx_devs, | ||
198 | u8 pmx_dev_count); | ||
199 | |||
200 | #endif /* CONFIG_MACH_SPEAR320 */ | ||
201 | |||
202 | #endif /* __MACH_GENERIC_H */ | 37 | #endif /* __MACH_GENERIC_H */ |
diff --git a/arch/arm/mach-spear3xx/include/mach/hardware.h b/arch/arm/mach-spear3xx/include/mach/hardware.h index 4660c0d8ec0d..40a8c178f10d 100644 --- a/arch/arm/mach-spear3xx/include/mach/hardware.h +++ b/arch/arm/mach-spear3xx/include/mach/hardware.h | |||
@@ -1,23 +1 @@ | |||
1 | /* | /* empty */ | |
2 | * arch/arm/mach-spear3xx/include/mach/hardware.h | ||
3 | * | ||
4 | * Hardware definitions for SPEAr3xx machine family | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __MACH_HARDWARE_H | ||
15 | #define __MACH_HARDWARE_H | ||
16 | |||
17 | #include <plat/hardware.h> | ||
18 | #include <mach/spear.h> | ||
19 | |||
20 | /* Vitual to physical translation of statically mapped space */ | ||
21 | #define IO_ADDRESS(x) (x | 0xF0000000) | ||
22 | |||
23 | #endif /* __MACH_HARDWARE_H */ | ||
diff --git a/arch/arm/mach-spear3xx/include/mach/irqs.h b/arch/arm/mach-spear3xx/include/mach/irqs.h index 6e265442808e..51bd62a0254c 100644 --- a/arch/arm/mach-spear3xx/include/mach/irqs.h +++ b/arch/arm/mach-spear3xx/include/mach/irqs.h | |||
@@ -14,141 +14,14 @@ | |||
14 | #ifndef __MACH_IRQS_H | 14 | #ifndef __MACH_IRQS_H |
15 | #define __MACH_IRQS_H | 15 | #define __MACH_IRQS_H |
16 | 16 | ||
17 | /* SPEAr3xx IRQ definitions */ | 17 | /* FIXME: probe all these from DT */ |
18 | #define SPEAR3XX_IRQ_HW_ACCEL_MOD_0 0 | ||
19 | #define SPEAR3XX_IRQ_INTRCOMM_RAS_ARM 1 | 18 | #define SPEAR3XX_IRQ_INTRCOMM_RAS_ARM 1 |
20 | #define SPEAR3XX_IRQ_CPU_GPT1_1 2 | ||
21 | #define SPEAR3XX_IRQ_CPU_GPT1_2 3 | ||
22 | #define SPEAR3XX_IRQ_BASIC_GPT1_1 4 | ||
23 | #define SPEAR3XX_IRQ_BASIC_GPT1_2 5 | ||
24 | #define SPEAR3XX_IRQ_BASIC_GPT2_1 6 | ||
25 | #define SPEAR3XX_IRQ_BASIC_GPT2_2 7 | ||
26 | #define SPEAR3XX_IRQ_BASIC_DMA 8 | ||
27 | #define SPEAR3XX_IRQ_BASIC_SMI 9 | ||
28 | #define SPEAR3XX_IRQ_BASIC_RTC 10 | ||
29 | #define SPEAR3XX_IRQ_BASIC_GPIO 11 | ||
30 | #define SPEAR3XX_IRQ_BASIC_WDT 12 | ||
31 | #define SPEAR3XX_IRQ_DDR_CONTROLLER 13 | ||
32 | #define SPEAR3XX_IRQ_SYS_ERROR 14 | ||
33 | #define SPEAR3XX_IRQ_WAKEUP_RCV 15 | ||
34 | #define SPEAR3XX_IRQ_JPEG 16 | ||
35 | #define SPEAR3XX_IRQ_IRDA 17 | ||
36 | #define SPEAR3XX_IRQ_ADC 18 | ||
37 | #define SPEAR3XX_IRQ_UART 19 | ||
38 | #define SPEAR3XX_IRQ_SSP 20 | ||
39 | #define SPEAR3XX_IRQ_I2C 21 | ||
40 | #define SPEAR3XX_IRQ_MAC_1 22 | ||
41 | #define SPEAR3XX_IRQ_MAC_2 23 | ||
42 | #define SPEAR3XX_IRQ_USB_DEV 24 | ||
43 | #define SPEAR3XX_IRQ_USB_H_OHCI_0 25 | ||
44 | #define SPEAR3XX_IRQ_USB_H_EHCI_0 26 | ||
45 | #define SPEAR3XX_IRQ_USB_H_EHCI_1 SPEAR3XX_IRQ_USB_H_EHCI_0 | ||
46 | #define SPEAR3XX_IRQ_USB_H_OHCI_1 27 | ||
47 | #define SPEAR3XX_IRQ_GEN_RAS_1 28 | 19 | #define SPEAR3XX_IRQ_GEN_RAS_1 28 |
48 | #define SPEAR3XX_IRQ_GEN_RAS_2 29 | 20 | #define SPEAR3XX_IRQ_GEN_RAS_2 29 |
49 | #define SPEAR3XX_IRQ_GEN_RAS_3 30 | 21 | #define SPEAR3XX_IRQ_GEN_RAS_3 30 |
50 | #define SPEAR3XX_IRQ_HW_ACCEL_MOD_1 31 | ||
51 | #define SPEAR3XX_IRQ_VIC_END 32 | 22 | #define SPEAR3XX_IRQ_VIC_END 32 |
52 | |||
53 | #define SPEAR3XX_VIRQ_START SPEAR3XX_IRQ_VIC_END | 23 | #define SPEAR3XX_VIRQ_START SPEAR3XX_IRQ_VIC_END |
54 | 24 | ||
55 | /* SPEAr300 Virtual irq definitions */ | 25 | #define NR_IRQS 160 |
56 | /* IRQs sharing IRQ_GEN_RAS_1 */ | ||
57 | #define SPEAR300_VIRQ_IT_PERS_S (SPEAR3XX_VIRQ_START + 0) | ||
58 | #define SPEAR300_VIRQ_IT_CHANGE_S (SPEAR3XX_VIRQ_START + 1) | ||
59 | #define SPEAR300_VIRQ_I2S (SPEAR3XX_VIRQ_START + 2) | ||
60 | #define SPEAR300_VIRQ_TDM (SPEAR3XX_VIRQ_START + 3) | ||
61 | #define SPEAR300_VIRQ_CAMERA_L (SPEAR3XX_VIRQ_START + 4) | ||
62 | #define SPEAR300_VIRQ_CAMERA_F (SPEAR3XX_VIRQ_START + 5) | ||
63 | #define SPEAR300_VIRQ_CAMERA_V (SPEAR3XX_VIRQ_START + 6) | ||
64 | #define SPEAR300_VIRQ_KEYBOARD (SPEAR3XX_VIRQ_START + 7) | ||
65 | #define SPEAR300_VIRQ_GPIO1 (SPEAR3XX_VIRQ_START + 8) | ||
66 | |||
67 | /* IRQs sharing IRQ_GEN_RAS_3 */ | ||
68 | #define SPEAR300_IRQ_CLCD SPEAR3XX_IRQ_GEN_RAS_3 | ||
69 | |||
70 | /* IRQs sharing IRQ_INTRCOMM_RAS_ARM */ | ||
71 | #define SPEAR300_IRQ_SDHCI SPEAR3XX_IRQ_INTRCOMM_RAS_ARM | ||
72 | |||
73 | /* SPEAr310 Virtual irq definitions */ | ||
74 | /* IRQs sharing IRQ_GEN_RAS_1 */ | ||
75 | #define SPEAR310_VIRQ_SMII0 (SPEAR3XX_VIRQ_START + 0) | ||
76 | #define SPEAR310_VIRQ_SMII1 (SPEAR3XX_VIRQ_START + 1) | ||
77 | #define SPEAR310_VIRQ_SMII2 (SPEAR3XX_VIRQ_START + 2) | ||
78 | #define SPEAR310_VIRQ_SMII3 (SPEAR3XX_VIRQ_START + 3) | ||
79 | #define SPEAR310_VIRQ_WAKEUP_SMII0 (SPEAR3XX_VIRQ_START + 4) | ||
80 | #define SPEAR310_VIRQ_WAKEUP_SMII1 (SPEAR3XX_VIRQ_START + 5) | ||
81 | #define SPEAR310_VIRQ_WAKEUP_SMII2 (SPEAR3XX_VIRQ_START + 6) | ||
82 | #define SPEAR310_VIRQ_WAKEUP_SMII3 (SPEAR3XX_VIRQ_START + 7) | ||
83 | |||
84 | /* IRQs sharing IRQ_GEN_RAS_2 */ | ||
85 | #define SPEAR310_VIRQ_UART1 (SPEAR3XX_VIRQ_START + 8) | ||
86 | #define SPEAR310_VIRQ_UART2 (SPEAR3XX_VIRQ_START + 9) | ||
87 | #define SPEAR310_VIRQ_UART3 (SPEAR3XX_VIRQ_START + 10) | ||
88 | #define SPEAR310_VIRQ_UART4 (SPEAR3XX_VIRQ_START + 11) | ||
89 | #define SPEAR310_VIRQ_UART5 (SPEAR3XX_VIRQ_START + 12) | ||
90 | |||
91 | /* IRQs sharing IRQ_GEN_RAS_3 */ | ||
92 | #define SPEAR310_VIRQ_EMI (SPEAR3XX_VIRQ_START + 13) | ||
93 | #define SPEAR310_VIRQ_PLGPIO (SPEAR3XX_VIRQ_START + 14) | ||
94 | |||
95 | /* IRQs sharing IRQ_INTRCOMM_RAS_ARM */ | ||
96 | #define SPEAR310_VIRQ_TDM_HDLC (SPEAR3XX_VIRQ_START + 15) | ||
97 | #define SPEAR310_VIRQ_RS485_0 (SPEAR3XX_VIRQ_START + 16) | ||
98 | #define SPEAR310_VIRQ_RS485_1 (SPEAR3XX_VIRQ_START + 17) | ||
99 | |||
100 | /* SPEAr320 Virtual irq definitions */ | ||
101 | /* IRQs sharing IRQ_GEN_RAS_1 */ | ||
102 | #define SPEAR320_VIRQ_EMI (SPEAR3XX_VIRQ_START + 0) | ||
103 | #define SPEAR320_VIRQ_CLCD (SPEAR3XX_VIRQ_START + 1) | ||
104 | #define SPEAR320_VIRQ_SPP (SPEAR3XX_VIRQ_START + 2) | ||
105 | |||
106 | /* IRQs sharing IRQ_GEN_RAS_2 */ | ||
107 | #define SPEAR320_IRQ_SDHCI SPEAR3XX_IRQ_GEN_RAS_2 | ||
108 | |||
109 | /* IRQs sharing IRQ_GEN_RAS_3 */ | ||
110 | #define SPEAR320_VIRQ_PLGPIO (SPEAR3XX_VIRQ_START + 3) | ||
111 | #define SPEAR320_VIRQ_I2S_PLAY (SPEAR3XX_VIRQ_START + 4) | ||
112 | #define SPEAR320_VIRQ_I2S_REC (SPEAR3XX_VIRQ_START + 5) | ||
113 | |||
114 | /* IRQs sharing IRQ_INTRCOMM_RAS_ARM */ | ||
115 | #define SPEAR320_VIRQ_CANU (SPEAR3XX_VIRQ_START + 6) | ||
116 | #define SPEAR320_VIRQ_CANL (SPEAR3XX_VIRQ_START + 7) | ||
117 | #define SPEAR320_VIRQ_UART1 (SPEAR3XX_VIRQ_START + 8) | ||
118 | #define SPEAR320_VIRQ_UART2 (SPEAR3XX_VIRQ_START + 9) | ||
119 | #define SPEAR320_VIRQ_SSP1 (SPEAR3XX_VIRQ_START + 10) | ||
120 | #define SPEAR320_VIRQ_SSP2 (SPEAR3XX_VIRQ_START + 11) | ||
121 | #define SPEAR320_VIRQ_SMII0 (SPEAR3XX_VIRQ_START + 12) | ||
122 | #define SPEAR320_VIRQ_MII1_SMII1 (SPEAR3XX_VIRQ_START + 13) | ||
123 | #define SPEAR320_VIRQ_WAKEUP_SMII0 (SPEAR3XX_VIRQ_START + 14) | ||
124 | #define SPEAR320_VIRQ_WAKEUP_MII1_SMII1 (SPEAR3XX_VIRQ_START + 15) | ||
125 | #define SPEAR320_VIRQ_I2C1 (SPEAR3XX_VIRQ_START + 16) | ||
126 | |||
127 | /* | ||
128 | * GPIO pins virtual irqs | ||
129 | * Use the lowest number for the GPIO virtual IRQs base on which subarchs | ||
130 | * we have compiled in | ||
131 | */ | ||
132 | #if defined(CONFIG_MACH_SPEAR310) | ||
133 | #define SPEAR3XX_GPIO_INT_BASE (SPEAR3XX_VIRQ_START + 18) | ||
134 | #elif defined(CONFIG_MACH_SPEAR320) | ||
135 | #define SPEAR3XX_GPIO_INT_BASE (SPEAR3XX_VIRQ_START + 17) | ||
136 | #else | ||
137 | #define SPEAR3XX_GPIO_INT_BASE (SPEAR3XX_VIRQ_START + 9) | ||
138 | #endif | ||
139 | |||
140 | #define SPEAR300_GPIO1_INT_BASE (SPEAR3XX_GPIO_INT_BASE + 8) | ||
141 | #define SPEAR3XX_PLGPIO_COUNT 102 | ||
142 | |||
143 | #if defined(CONFIG_MACH_SPEAR310) || defined(CONFIG_MACH_SPEAR320) | ||
144 | #define SPEAR3XX_PLGPIO_INT_BASE (SPEAR3XX_GPIO_INT_BASE + 8) | ||
145 | #define SPEAR3XX_GPIO_INT_END (SPEAR3XX_PLGPIO_INT_BASE + \ | ||
146 | SPEAR3XX_PLGPIO_COUNT) | ||
147 | #else | ||
148 | #define SPEAR3XX_GPIO_INT_END (SPEAR300_GPIO1_INT_BASE + 8) | ||
149 | #endif | ||
150 | |||
151 | #define SPEAR3XX_VIRQ_END SPEAR3XX_GPIO_INT_END | ||
152 | #define NR_IRQS SPEAR3XX_VIRQ_END | ||
153 | 26 | ||
154 | #endif /* __MACH_IRQS_H */ | 27 | #endif /* __MACH_IRQS_H */ |
diff --git a/arch/arm/mach-spear3xx/include/mach/misc_regs.h b/arch/arm/mach-spear3xx/include/mach/misc_regs.h index 5bd8cd8d4852..18e2ac576f25 100644 --- a/arch/arm/mach-spear3xx/include/mach/misc_regs.h +++ b/arch/arm/mach-spear3xx/include/mach/misc_regs.h | |||
@@ -14,151 +14,9 @@ | |||
14 | #ifndef __MACH_MISC_REGS_H | 14 | #ifndef __MACH_MISC_REGS_H |
15 | #define __MACH_MISC_REGS_H | 15 | #define __MACH_MISC_REGS_H |
16 | 16 | ||
17 | #include <mach/hardware.h> | 17 | #include <mach/spear.h> |
18 | 18 | ||
19 | #define MISC_BASE IOMEM(VA_SPEAR3XX_ICM3_MISC_REG_BASE) | 19 | #define MISC_BASE IOMEM(VA_SPEAR3XX_ICM3_MISC_REG_BASE) |
20 | |||
21 | #define SOC_CFG_CTR (MISC_BASE + 0x000) | ||
22 | #define DIAG_CFG_CTR (MISC_BASE + 0x004) | ||
23 | #define PLL1_CTR (MISC_BASE + 0x008) | ||
24 | #define PLL1_FRQ (MISC_BASE + 0x00C) | ||
25 | #define PLL1_MOD (MISC_BASE + 0x010) | ||
26 | #define PLL2_CTR (MISC_BASE + 0x014) | ||
27 | /* PLL_CTR register masks */ | ||
28 | #define PLL_ENABLE 2 | ||
29 | #define PLL_MODE_SHIFT 4 | ||
30 | #define PLL_MODE_MASK 0x3 | ||
31 | #define PLL_MODE_NORMAL 0 | ||
32 | #define PLL_MODE_FRACTION 1 | ||
33 | #define PLL_MODE_DITH_DSB 2 | ||
34 | #define PLL_MODE_DITH_SSB 3 | ||
35 | |||
36 | #define PLL2_FRQ (MISC_BASE + 0x018) | ||
37 | /* PLL FRQ register masks */ | ||
38 | #define PLL_DIV_N_SHIFT 0 | ||
39 | #define PLL_DIV_N_MASK 0xFF | ||
40 | #define PLL_DIV_P_SHIFT 8 | ||
41 | #define PLL_DIV_P_MASK 0x7 | ||
42 | #define PLL_NORM_FDBK_M_SHIFT 24 | ||
43 | #define PLL_NORM_FDBK_M_MASK 0xFF | ||
44 | #define PLL_DITH_FDBK_M_SHIFT 16 | ||
45 | #define PLL_DITH_FDBK_M_MASK 0xFFFF | ||
46 | |||
47 | #define PLL2_MOD (MISC_BASE + 0x01C) | ||
48 | #define PLL_CLK_CFG (MISC_BASE + 0x020) | ||
49 | #define CORE_CLK_CFG (MISC_BASE + 0x024) | ||
50 | /* CORE CLK CFG register masks */ | ||
51 | #define PLL_HCLK_RATIO_SHIFT 10 | ||
52 | #define PLL_HCLK_RATIO_MASK 0x3 | ||
53 | #define HCLK_PCLK_RATIO_SHIFT 8 | ||
54 | #define HCLK_PCLK_RATIO_MASK 0x3 | ||
55 | |||
56 | #define PERIP_CLK_CFG (MISC_BASE + 0x028) | ||
57 | /* PERIP_CLK_CFG register masks */ | ||
58 | #define UART_CLK_SHIFT 4 | ||
59 | #define UART_CLK_MASK 0x1 | ||
60 | #define FIRDA_CLK_SHIFT 5 | ||
61 | #define FIRDA_CLK_MASK 0x3 | ||
62 | #define GPT0_CLK_SHIFT 8 | ||
63 | #define GPT1_CLK_SHIFT 11 | ||
64 | #define GPT2_CLK_SHIFT 12 | ||
65 | #define GPT_CLK_MASK 0x1 | ||
66 | #define AUX_CLK_PLL3_VAL 0 | ||
67 | #define AUX_CLK_PLL1_VAL 1 | ||
68 | |||
69 | #define PERIP1_CLK_ENB (MISC_BASE + 0x02C) | ||
70 | /* PERIP1_CLK_ENB register masks */ | ||
71 | #define UART_CLK_ENB 3 | ||
72 | #define SSP_CLK_ENB 5 | ||
73 | #define I2C_CLK_ENB 7 | ||
74 | #define JPEG_CLK_ENB 8 | ||
75 | #define FIRDA_CLK_ENB 10 | ||
76 | #define GPT1_CLK_ENB 11 | ||
77 | #define GPT2_CLK_ENB 12 | ||
78 | #define ADC_CLK_ENB 15 | ||
79 | #define RTC_CLK_ENB 17 | ||
80 | #define GPIO_CLK_ENB 18 | ||
81 | #define DMA_CLK_ENB 19 | ||
82 | #define SMI_CLK_ENB 21 | ||
83 | #define GMAC_CLK_ENB 23 | ||
84 | #define USBD_CLK_ENB 24 | ||
85 | #define USBH_CLK_ENB 25 | ||
86 | #define C3_CLK_ENB 31 | ||
87 | |||
88 | #define SOC_CORE_ID (MISC_BASE + 0x030) | ||
89 | #define RAS_CLK_ENB (MISC_BASE + 0x034) | ||
90 | #define PERIP1_SOF_RST (MISC_BASE + 0x038) | ||
91 | /* PERIP1_SOF_RST register masks */ | ||
92 | #define JPEG_SOF_RST 8 | ||
93 | |||
94 | #define SOC_USER_ID (MISC_BASE + 0x03C) | ||
95 | #define RAS_SOF_RST (MISC_BASE + 0x040) | ||
96 | #define PRSC1_CLK_CFG (MISC_BASE + 0x044) | ||
97 | #define PRSC2_CLK_CFG (MISC_BASE + 0x048) | ||
98 | #define PRSC3_CLK_CFG (MISC_BASE + 0x04C) | ||
99 | /* gpt synthesizer register masks */ | ||
100 | #define GPT_MSCALE_SHIFT 0 | ||
101 | #define GPT_MSCALE_MASK 0xFFF | ||
102 | #define GPT_NSCALE_SHIFT 12 | ||
103 | #define GPT_NSCALE_MASK 0xF | ||
104 | |||
105 | #define AMEM_CLK_CFG (MISC_BASE + 0x050) | ||
106 | #define EXPI_CLK_CFG (MISC_BASE + 0x054) | ||
107 | #define CLCD_CLK_SYNT (MISC_BASE + 0x05C) | ||
108 | #define FIRDA_CLK_SYNT (MISC_BASE + 0x060) | ||
109 | #define UART_CLK_SYNT (MISC_BASE + 0x064) | ||
110 | #define GMAC_CLK_SYNT (MISC_BASE + 0x068) | ||
111 | #define RAS1_CLK_SYNT (MISC_BASE + 0x06C) | ||
112 | #define RAS2_CLK_SYNT (MISC_BASE + 0x070) | ||
113 | #define RAS3_CLK_SYNT (MISC_BASE + 0x074) | ||
114 | #define RAS4_CLK_SYNT (MISC_BASE + 0x078) | ||
115 | /* aux clk synthesiser register masks for irda to ras4 */ | ||
116 | #define AUX_SYNT_ENB 31 | ||
117 | #define AUX_EQ_SEL_SHIFT 30 | ||
118 | #define AUX_EQ_SEL_MASK 1 | ||
119 | #define AUX_EQ1_SEL 0 | ||
120 | #define AUX_EQ2_SEL 1 | ||
121 | #define AUX_XSCALE_SHIFT 16 | ||
122 | #define AUX_XSCALE_MASK 0xFFF | ||
123 | #define AUX_YSCALE_SHIFT 0 | ||
124 | #define AUX_YSCALE_MASK 0xFFF | ||
125 | |||
126 | #define ICM1_ARB_CFG (MISC_BASE + 0x07C) | ||
127 | #define ICM2_ARB_CFG (MISC_BASE + 0x080) | ||
128 | #define ICM3_ARB_CFG (MISC_BASE + 0x084) | ||
129 | #define ICM4_ARB_CFG (MISC_BASE + 0x088) | ||
130 | #define ICM5_ARB_CFG (MISC_BASE + 0x08C) | ||
131 | #define ICM6_ARB_CFG (MISC_BASE + 0x090) | ||
132 | #define ICM7_ARB_CFG (MISC_BASE + 0x094) | ||
133 | #define ICM8_ARB_CFG (MISC_BASE + 0x098) | ||
134 | #define ICM9_ARB_CFG (MISC_BASE + 0x09C) | ||
135 | #define DMA_CHN_CFG (MISC_BASE + 0x0A0) | 20 | #define DMA_CHN_CFG (MISC_BASE + 0x0A0) |
136 | #define USB2_PHY_CFG (MISC_BASE + 0x0A4) | ||
137 | #define GMAC_CFG_CTR (MISC_BASE + 0x0A8) | ||
138 | #define EXPI_CFG_CTR (MISC_BASE + 0x0AC) | ||
139 | #define PRC1_LOCK_CTR (MISC_BASE + 0x0C0) | ||
140 | #define PRC2_LOCK_CTR (MISC_BASE + 0x0C4) | ||
141 | #define PRC3_LOCK_CTR (MISC_BASE + 0x0C8) | ||
142 | #define PRC4_LOCK_CTR (MISC_BASE + 0x0CC) | ||
143 | #define PRC1_IRQ_CTR (MISC_BASE + 0x0D0) | ||
144 | #define PRC2_IRQ_CTR (MISC_BASE + 0x0D4) | ||
145 | #define PRC3_IRQ_CTR (MISC_BASE + 0x0D8) | ||
146 | #define PRC4_IRQ_CTR (MISC_BASE + 0x0DC) | ||
147 | #define PWRDOWN_CFG_CTR (MISC_BASE + 0x0E0) | ||
148 | #define COMPSSTL_1V8_CFG (MISC_BASE + 0x0E4) | ||
149 | #define COMPSSTL_2V5_CFG (MISC_BASE + 0x0E8) | ||
150 | #define COMPCOR_3V3_CFG (MISC_BASE + 0x0EC) | ||
151 | #define SSTLPAD_CFG_CTR (MISC_BASE + 0x0F0) | ||
152 | #define BIST1_CFG_CTR (MISC_BASE + 0x0F4) | ||
153 | #define BIST2_CFG_CTR (MISC_BASE + 0x0F8) | ||
154 | #define BIST3_CFG_CTR (MISC_BASE + 0x0FC) | ||
155 | #define BIST4_CFG_CTR (MISC_BASE + 0x100) | ||
156 | #define BIST5_CFG_CTR (MISC_BASE + 0x104) | ||
157 | #define BIST1_STS_RES (MISC_BASE + 0x108) | ||
158 | #define BIST2_STS_RES (MISC_BASE + 0x10C) | ||
159 | #define BIST3_STS_RES (MISC_BASE + 0x110) | ||
160 | #define BIST4_STS_RES (MISC_BASE + 0x114) | ||
161 | #define BIST5_STS_RES (MISC_BASE + 0x118) | ||
162 | #define SYSERR_CFG_CTR (MISC_BASE + 0x11C) | ||
163 | 21 | ||
164 | #endif /* __MACH_MISC_REGS_H */ | 22 | #endif /* __MACH_MISC_REGS_H */ |
diff --git a/arch/arm/mach-spear3xx/include/mach/spear.h b/arch/arm/mach-spear3xx/include/mach/spear.h index 63fd98356919..51eb953148a9 100644 --- a/arch/arm/mach-spear3xx/include/mach/spear.h +++ b/arch/arm/mach-spear3xx/include/mach/spear.h | |||
@@ -15,60 +15,26 @@ | |||
15 | #define __MACH_SPEAR3XX_H | 15 | #define __MACH_SPEAR3XX_H |
16 | 16 | ||
17 | #include <asm/memory.h> | 17 | #include <asm/memory.h> |
18 | #include <mach/spear300.h> | ||
19 | #include <mach/spear310.h> | ||
20 | #include <mach/spear320.h> | ||
21 | |||
22 | #define SPEAR3XX_ML_SDRAM_BASE UL(0x00000000) | ||
23 | |||
24 | #define SPEAR3XX_ICM9_BASE UL(0xC0000000) | ||
25 | 18 | ||
26 | /* ICM1 - Low speed connection */ | 19 | /* ICM1 - Low speed connection */ |
27 | #define SPEAR3XX_ICM1_2_BASE UL(0xD0000000) | 20 | #define SPEAR3XX_ICM1_2_BASE UL(0xD0000000) |
21 | #define VA_SPEAR3XX_ICM1_2_BASE UL(0xFD000000) | ||
28 | #define SPEAR3XX_ICM1_UART_BASE UL(0xD0000000) | 22 | #define SPEAR3XX_ICM1_UART_BASE UL(0xD0000000) |
29 | #define VA_SPEAR3XX_ICM1_UART_BASE IO_ADDRESS(SPEAR3XX_ICM1_UART_BASE) | 23 | #define VA_SPEAR3XX_ICM1_UART_BASE (VA_SPEAR3XX_ICM1_2_BASE | SPEAR3XX_ICM1_UART_BASE) |
30 | #define SPEAR3XX_ICM1_ADC_BASE UL(0xD0080000) | ||
31 | #define SPEAR3XX_ICM1_SSP_BASE UL(0xD0100000) | 24 | #define SPEAR3XX_ICM1_SSP_BASE UL(0xD0100000) |
32 | #define SPEAR3XX_ICM1_I2C_BASE UL(0xD0180000) | ||
33 | #define SPEAR3XX_ICM1_JPEG_BASE UL(0xD0800000) | ||
34 | #define SPEAR3XX_ICM1_IRDA_BASE UL(0xD1000000) | ||
35 | #define SPEAR3XX_ICM1_SRAM_BASE UL(0xD2800000) | ||
36 | |||
37 | /* ICM2 - Application Subsystem */ | ||
38 | #define SPEAR3XX_ICM2_HWACCEL0_BASE UL(0xD8800000) | ||
39 | #define SPEAR3XX_ICM2_HWACCEL1_BASE UL(0xD9000000) | ||
40 | |||
41 | /* ICM4 - High Speed Connection */ | ||
42 | #define SPEAR3XX_ICM4_BASE UL(0xE0000000) | ||
43 | #define SPEAR3XX_ICM4_MII_BASE UL(0xE0800000) | ||
44 | #define SPEAR3XX_ICM4_USBD_FIFO_BASE UL(0xE1000000) | ||
45 | #define SPEAR3XX_ICM4_USBD_CSR_BASE UL(0xE1100000) | ||
46 | #define SPEAR3XX_ICM4_USBD_PLDT_BASE UL(0xE1200000) | ||
47 | #define SPEAR3XX_ICM4_USB_EHCI0_1_BASE UL(0xE1800000) | ||
48 | #define SPEAR3XX_ICM4_USB_OHCI0_BASE UL(0xE1900000) | ||
49 | #define SPEAR3XX_ICM4_USB_OHCI1_BASE UL(0xE2100000) | ||
50 | #define SPEAR3XX_ICM4_USB_ARB_BASE UL(0xE2800000) | ||
51 | 25 | ||
52 | /* ML1 - Multi Layer CPU Subsystem */ | 26 | /* ML1 - Multi Layer CPU Subsystem */ |
53 | #define SPEAR3XX_ICM3_ML1_2_BASE UL(0xF0000000) | 27 | #define SPEAR3XX_ICM3_ML1_2_BASE UL(0xF0000000) |
54 | #define SPEAR3XX_ML1_TMR_BASE UL(0xF0000000) | 28 | #define VA_SPEAR6XX_ML_CPU_BASE UL(0xF0000000) |
55 | #define SPEAR3XX_ML1_VIC_BASE UL(0xF1100000) | ||
56 | #define VA_SPEAR3XX_ML1_VIC_BASE IO_ADDRESS(SPEAR3XX_ML1_VIC_BASE) | ||
57 | 29 | ||
58 | /* ICM3 - Basic Subsystem */ | 30 | /* ICM3 - Basic Subsystem */ |
59 | #define SPEAR3XX_ICM3_SMEM_BASE UL(0xF8000000) | ||
60 | #define SPEAR3XX_ICM3_SMI_CTRL_BASE UL(0xFC000000) | 31 | #define SPEAR3XX_ICM3_SMI_CTRL_BASE UL(0xFC000000) |
32 | #define VA_SPEAR3XX_ICM3_SMI_CTRL_BASE UL(0xFC000000) | ||
61 | #define SPEAR3XX_ICM3_DMA_BASE UL(0xFC400000) | 33 | #define SPEAR3XX_ICM3_DMA_BASE UL(0xFC400000) |
62 | #define SPEAR3XX_ICM3_SDRAM_CTRL_BASE UL(0xFC600000) | ||
63 | #define SPEAR3XX_ICM3_TMR0_BASE UL(0xFC800000) | ||
64 | #define SPEAR3XX_ICM3_WDT_BASE UL(0xFC880000) | ||
65 | #define SPEAR3XX_ICM3_RTC_BASE UL(0xFC900000) | ||
66 | #define SPEAR3XX_ICM3_GPIO_BASE UL(0xFC980000) | ||
67 | #define SPEAR3XX_ICM3_SYS_CTRL_BASE UL(0xFCA00000) | 34 | #define SPEAR3XX_ICM3_SYS_CTRL_BASE UL(0xFCA00000) |
68 | #define VA_SPEAR3XX_ICM3_SYS_CTRL_BASE IO_ADDRESS(SPEAR3XX_ICM3_SYS_CTRL_BASE) | 35 | #define VA_SPEAR3XX_ICM3_SYS_CTRL_BASE (VA_SPEAR3XX_ICM3_SMI_CTRL_BASE | SPEAR3XX_ICM3_SYS_CTRL_BASE) |
69 | #define SPEAR3XX_ICM3_MISC_REG_BASE UL(0xFCA80000) | 36 | #define SPEAR3XX_ICM3_MISC_REG_BASE UL(0xFCA80000) |
70 | #define VA_SPEAR3XX_ICM3_MISC_REG_BASE IO_ADDRESS(SPEAR3XX_ICM3_MISC_REG_BASE) | 37 | #define VA_SPEAR3XX_ICM3_MISC_REG_BASE (VA_SPEAR3XX_ICM3_SMI_CTRL_BASE | SPEAR3XX_ICM3_MISC_REG_BASE) |
71 | #define SPEAR3XX_ICM3_TMR1_BASE UL(0xFCB00000) | ||
72 | 38 | ||
73 | /* Debug uart for linux, will be used for debug and uncompress messages */ | 39 | /* Debug uart for linux, will be used for debug and uncompress messages */ |
74 | #define SPEAR_DBG_UART_BASE SPEAR3XX_ICM1_UART_BASE | 40 | #define SPEAR_DBG_UART_BASE SPEAR3XX_ICM1_UART_BASE |
@@ -78,4 +44,17 @@ | |||
78 | #define SPEAR_SYS_CTRL_BASE SPEAR3XX_ICM3_SYS_CTRL_BASE | 44 | #define SPEAR_SYS_CTRL_BASE SPEAR3XX_ICM3_SYS_CTRL_BASE |
79 | #define VA_SPEAR_SYS_CTRL_BASE VA_SPEAR3XX_ICM3_SYS_CTRL_BASE | 45 | #define VA_SPEAR_SYS_CTRL_BASE VA_SPEAR3XX_ICM3_SYS_CTRL_BASE |
80 | 46 | ||
47 | /* SPEAr320 Macros */ | ||
48 | #define SPEAR320_SOC_CONFIG_BASE UL(0xB3000000) | ||
49 | #define VA_SPEAR320_SOC_CONFIG_BASE UL(0xFE000000) | ||
50 | #define SPEAR320_CONTROL_REG IOMEM(VA_SPEAR320_SOC_CONFIG_BASE) | ||
51 | #define SPEAR320_EXT_CTRL_REG IOMEM(VA_SPEAR320_SOC_CONFIG_BASE + 0x0018) | ||
52 | #define SPEAR320_UARTX_PCLK_MASK 0x1 | ||
53 | #define SPEAR320_UART2_PCLK_SHIFT 8 | ||
54 | #define SPEAR320_UART3_PCLK_SHIFT 9 | ||
55 | #define SPEAR320_UART4_PCLK_SHIFT 10 | ||
56 | #define SPEAR320_UART5_PCLK_SHIFT 11 | ||
57 | #define SPEAR320_UART6_PCLK_SHIFT 12 | ||
58 | #define SPEAR320_RS485_PCLK_SHIFT 13 | ||
59 | |||
81 | #endif /* __MACH_SPEAR3XX_H */ | 60 | #endif /* __MACH_SPEAR3XX_H */ |
diff --git a/arch/arm/mach-spear3xx/include/mach/spear300.h b/arch/arm/mach-spear3xx/include/mach/spear300.h deleted file mode 100644 index 3b6ea0729040..000000000000 --- a/arch/arm/mach-spear3xx/include/mach/spear300.h +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-spear3xx/include/mach/spear300.h | ||
3 | * | ||
4 | * SPEAr300 Machine specific definition | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifdef CONFIG_MACH_SPEAR300 | ||
15 | |||
16 | #ifndef __MACH_SPEAR300_H | ||
17 | #define __MACH_SPEAR300_H | ||
18 | |||
19 | /* Base address of various IPs */ | ||
20 | #define SPEAR300_TELECOM_BASE UL(0x50000000) | ||
21 | |||
22 | /* Interrupt registers offsets and masks */ | ||
23 | #define SPEAR300_INT_ENB_MASK_REG 0x54 | ||
24 | #define SPEAR300_INT_STS_MASK_REG 0x58 | ||
25 | #define SPEAR300_IT_PERS_S_IRQ_MASK (1 << 0) | ||
26 | #define SPEAR300_IT_CHANGE_S_IRQ_MASK (1 << 1) | ||
27 | #define SPEAR300_I2S_IRQ_MASK (1 << 2) | ||
28 | #define SPEAR300_TDM_IRQ_MASK (1 << 3) | ||
29 | #define SPEAR300_CAMERA_L_IRQ_MASK (1 << 4) | ||
30 | #define SPEAR300_CAMERA_F_IRQ_MASK (1 << 5) | ||
31 | #define SPEAR300_CAMERA_V_IRQ_MASK (1 << 6) | ||
32 | #define SPEAR300_KEYBOARD_IRQ_MASK (1 << 7) | ||
33 | #define SPEAR300_GPIO1_IRQ_MASK (1 << 8) | ||
34 | |||
35 | #define SPEAR300_SHIRQ_RAS1_MASK 0x1FF | ||
36 | |||
37 | #define SPEAR300_CLCD_BASE UL(0x60000000) | ||
38 | #define SPEAR300_SDHCI_BASE UL(0x70000000) | ||
39 | #define SPEAR300_NAND_0_BASE UL(0x80000000) | ||
40 | #define SPEAR300_NAND_1_BASE UL(0x84000000) | ||
41 | #define SPEAR300_NAND_2_BASE UL(0x88000000) | ||
42 | #define SPEAR300_NAND_3_BASE UL(0x8c000000) | ||
43 | #define SPEAR300_NOR_0_BASE UL(0x90000000) | ||
44 | #define SPEAR300_NOR_1_BASE UL(0x91000000) | ||
45 | #define SPEAR300_NOR_2_BASE UL(0x92000000) | ||
46 | #define SPEAR300_NOR_3_BASE UL(0x93000000) | ||
47 | #define SPEAR300_FSMC_BASE UL(0x94000000) | ||
48 | #define SPEAR300_SOC_CONFIG_BASE UL(0x99000000) | ||
49 | #define SPEAR300_KEYBOARD_BASE UL(0xA0000000) | ||
50 | #define SPEAR300_GPIO_BASE UL(0xA9000000) | ||
51 | |||
52 | #endif /* __MACH_SPEAR300_H */ | ||
53 | |||
54 | #endif /* CONFIG_MACH_SPEAR300 */ | ||
diff --git a/arch/arm/mach-spear3xx/include/mach/spear310.h b/arch/arm/mach-spear3xx/include/mach/spear310.h deleted file mode 100644 index 1567d0da725f..000000000000 --- a/arch/arm/mach-spear3xx/include/mach/spear310.h +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-spear3xx/include/mach/spear310.h | ||
3 | * | ||
4 | * SPEAr310 Machine specific definition | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifdef CONFIG_MACH_SPEAR310 | ||
15 | |||
16 | #ifndef __MACH_SPEAR310_H | ||
17 | #define __MACH_SPEAR310_H | ||
18 | |||
19 | #define SPEAR310_NAND_BASE UL(0x40000000) | ||
20 | #define SPEAR310_FSMC_BASE UL(0x44000000) | ||
21 | #define SPEAR310_UART1_BASE UL(0xB2000000) | ||
22 | #define SPEAR310_UART2_BASE UL(0xB2080000) | ||
23 | #define SPEAR310_UART3_BASE UL(0xB2100000) | ||
24 | #define SPEAR310_UART4_BASE UL(0xB2180000) | ||
25 | #define SPEAR310_UART5_BASE UL(0xB2200000) | ||
26 | #define SPEAR310_HDLC_BASE UL(0xB2800000) | ||
27 | #define SPEAR310_RS485_0_BASE UL(0xB3000000) | ||
28 | #define SPEAR310_RS485_1_BASE UL(0xB3800000) | ||
29 | #define SPEAR310_SOC_CONFIG_BASE UL(0xB4000000) | ||
30 | |||
31 | /* Interrupt registers offsets and masks */ | ||
32 | #define SPEAR310_INT_STS_MASK_REG 0x04 | ||
33 | #define SPEAR310_SMII0_IRQ_MASK (1 << 0) | ||
34 | #define SPEAR310_SMII1_IRQ_MASK (1 << 1) | ||
35 | #define SPEAR310_SMII2_IRQ_MASK (1 << 2) | ||
36 | #define SPEAR310_SMII3_IRQ_MASK (1 << 3) | ||
37 | #define SPEAR310_WAKEUP_SMII0_IRQ_MASK (1 << 4) | ||
38 | #define SPEAR310_WAKEUP_SMII1_IRQ_MASK (1 << 5) | ||
39 | #define SPEAR310_WAKEUP_SMII2_IRQ_MASK (1 << 6) | ||
40 | #define SPEAR310_WAKEUP_SMII3_IRQ_MASK (1 << 7) | ||
41 | #define SPEAR310_UART1_IRQ_MASK (1 << 8) | ||
42 | #define SPEAR310_UART2_IRQ_MASK (1 << 9) | ||
43 | #define SPEAR310_UART3_IRQ_MASK (1 << 10) | ||
44 | #define SPEAR310_UART4_IRQ_MASK (1 << 11) | ||
45 | #define SPEAR310_UART5_IRQ_MASK (1 << 12) | ||
46 | #define SPEAR310_EMI_IRQ_MASK (1 << 13) | ||
47 | #define SPEAR310_TDM_HDLC_IRQ_MASK (1 << 14) | ||
48 | #define SPEAR310_RS485_0_IRQ_MASK (1 << 15) | ||
49 | #define SPEAR310_RS485_1_IRQ_MASK (1 << 16) | ||
50 | |||
51 | #define SPEAR310_SHIRQ_RAS1_MASK 0x000FF | ||
52 | #define SPEAR310_SHIRQ_RAS2_MASK 0x01F00 | ||
53 | #define SPEAR310_SHIRQ_RAS3_MASK 0x02000 | ||
54 | #define SPEAR310_SHIRQ_INTRCOMM_RAS_MASK 0x1C000 | ||
55 | |||
56 | #endif /* __MACH_SPEAR310_H */ | ||
57 | |||
58 | #endif /* CONFIG_MACH_SPEAR310 */ | ||
diff --git a/arch/arm/mach-spear3xx/include/mach/spear320.h b/arch/arm/mach-spear3xx/include/mach/spear320.h deleted file mode 100644 index 8cfa83fa1296..000000000000 --- a/arch/arm/mach-spear3xx/include/mach/spear320.h +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-spear3xx/include/mach/spear320.h | ||
3 | * | ||
4 | * SPEAr320 Machine specific definition | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifdef CONFIG_MACH_SPEAR320 | ||
15 | |||
16 | #ifndef __MACH_SPEAR320_H | ||
17 | #define __MACH_SPEAR320_H | ||
18 | |||
19 | #define SPEAR320_EMI_CTRL_BASE UL(0x40000000) | ||
20 | #define SPEAR320_FSMC_BASE UL(0x4C000000) | ||
21 | #define SPEAR320_NAND_BASE UL(0x50000000) | ||
22 | #define SPEAR320_I2S_BASE UL(0x60000000) | ||
23 | #define SPEAR320_SDHCI_BASE UL(0x70000000) | ||
24 | #define SPEAR320_CLCD_BASE UL(0x90000000) | ||
25 | #define SPEAR320_PAR_PORT_BASE UL(0xA0000000) | ||
26 | #define SPEAR320_CAN0_BASE UL(0xA1000000) | ||
27 | #define SPEAR320_CAN1_BASE UL(0xA2000000) | ||
28 | #define SPEAR320_UART1_BASE UL(0xA3000000) | ||
29 | #define SPEAR320_UART2_BASE UL(0xA4000000) | ||
30 | #define SPEAR320_SSP0_BASE UL(0xA5000000) | ||
31 | #define SPEAR320_SSP1_BASE UL(0xA6000000) | ||
32 | #define SPEAR320_I2C_BASE UL(0xA7000000) | ||
33 | #define SPEAR320_PWM_BASE UL(0xA8000000) | ||
34 | #define SPEAR320_SMII0_BASE UL(0xAA000000) | ||
35 | #define SPEAR320_SMII1_BASE UL(0xAB000000) | ||
36 | #define SPEAR320_SOC_CONFIG_BASE UL(0xB3000000) | ||
37 | |||
38 | /* Interrupt registers offsets and masks */ | ||
39 | #define SPEAR320_INT_STS_MASK_REG 0x04 | ||
40 | #define SPEAR320_INT_CLR_MASK_REG 0x04 | ||
41 | #define SPEAR320_INT_ENB_MASK_REG 0x08 | ||
42 | #define SPEAR320_GPIO_IRQ_MASK (1 << 0) | ||
43 | #define SPEAR320_I2S_PLAY_IRQ_MASK (1 << 1) | ||
44 | #define SPEAR320_I2S_REC_IRQ_MASK (1 << 2) | ||
45 | #define SPEAR320_EMI_IRQ_MASK (1 << 7) | ||
46 | #define SPEAR320_CLCD_IRQ_MASK (1 << 8) | ||
47 | #define SPEAR320_SPP_IRQ_MASK (1 << 9) | ||
48 | #define SPEAR320_SDHCI_IRQ_MASK (1 << 10) | ||
49 | #define SPEAR320_CAN_U_IRQ_MASK (1 << 11) | ||
50 | #define SPEAR320_CAN_L_IRQ_MASK (1 << 12) | ||
51 | #define SPEAR320_UART1_IRQ_MASK (1 << 13) | ||
52 | #define SPEAR320_UART2_IRQ_MASK (1 << 14) | ||
53 | #define SPEAR320_SSP1_IRQ_MASK (1 << 15) | ||
54 | #define SPEAR320_SSP2_IRQ_MASK (1 << 16) | ||
55 | #define SPEAR320_SMII0_IRQ_MASK (1 << 17) | ||
56 | #define SPEAR320_MII1_SMII1_IRQ_MASK (1 << 18) | ||
57 | #define SPEAR320_WAKEUP_SMII0_IRQ_MASK (1 << 19) | ||
58 | #define SPEAR320_WAKEUP_MII1_SMII1_IRQ_MASK (1 << 20) | ||
59 | #define SPEAR320_I2C1_IRQ_MASK (1 << 21) | ||
60 | |||
61 | #define SPEAR320_SHIRQ_RAS1_MASK 0x000380 | ||
62 | #define SPEAR320_SHIRQ_RAS3_MASK 0x000007 | ||
63 | #define SPEAR320_SHIRQ_INTRCOMM_RAS_MASK 0x3FF800 | ||
64 | |||
65 | #endif /* __MACH_SPEAR320_H */ | ||
66 | |||
67 | #endif /* CONFIG_MACH_SPEAR320 */ | ||
diff --git a/arch/arm/mach-spear3xx/spear300.c b/arch/arm/mach-spear3xx/spear300.c index f7db66812abb..f74a05bdb829 100644 --- a/arch/arm/mach-spear3xx/spear300.c +++ b/arch/arm/mach-spear3xx/spear300.c | |||
@@ -3,372 +3,62 @@ | |||
3 | * | 3 | * |
4 | * SPEAr300 machine source file | 4 | * SPEAr300 machine source file |
5 | * | 5 | * |
6 | * Copyright (C) 2009 ST Microelectronics | 6 | * Copyright (C) 2009-2012 ST Microelectronics |
7 | * Viresh Kumar<viresh.kumar@st.com> | 7 | * Viresh Kumar <viresh.kumar@st.com> |
8 | * | 8 | * |
9 | * This file is licensed under the terms of the GNU General Public | 9 | * This file is licensed under the terms of the GNU General Public |
10 | * License version 2. This program is licensed "as is" without any | 10 | * License version 2. This program is licensed "as is" without any |
11 | * warranty of any kind, whether express or implied. | 11 | * warranty of any kind, whether express or implied. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/types.h> | 14 | #define pr_fmt(fmt) "SPEAr300: " fmt |
15 | #include <linux/amba/pl061.h> | 15 | |
16 | #include <linux/ptrace.h> | 16 | #include <linux/amba/pl08x.h> |
17 | #include <asm/irq.h> | 17 | #include <linux/of_platform.h> |
18 | #include <asm/hardware/vic.h> | ||
19 | #include <asm/mach/arch.h> | ||
18 | #include <plat/shirq.h> | 20 | #include <plat/shirq.h> |
19 | #include <mach/generic.h> | 21 | #include <mach/generic.h> |
20 | #include <mach/hardware.h> | 22 | #include <mach/spear.h> |
21 | 23 | ||
22 | /* pad multiplexing support */ | 24 | /* Base address of various IPs */ |
23 | /* muxing registers */ | 25 | #define SPEAR300_TELECOM_BASE UL(0x50000000) |
24 | #define PAD_MUX_CONFIG_REG 0x00 | 26 | |
25 | #define MODE_CONFIG_REG 0x04 | 27 | /* Interrupt registers offsets and masks */ |
26 | 28 | #define SPEAR300_INT_ENB_MASK_REG 0x54 | |
27 | /* modes */ | 29 | #define SPEAR300_INT_STS_MASK_REG 0x58 |
28 | #define NAND_MODE (1 << 0) | 30 | #define SPEAR300_IT_PERS_S_IRQ_MASK (1 << 0) |
29 | #define NOR_MODE (1 << 1) | 31 | #define SPEAR300_IT_CHANGE_S_IRQ_MASK (1 << 1) |
30 | #define PHOTO_FRAME_MODE (1 << 2) | 32 | #define SPEAR300_I2S_IRQ_MASK (1 << 2) |
31 | #define LEND_IP_PHONE_MODE (1 << 3) | 33 | #define SPEAR300_TDM_IRQ_MASK (1 << 3) |
32 | #define HEND_IP_PHONE_MODE (1 << 4) | 34 | #define SPEAR300_CAMERA_L_IRQ_MASK (1 << 4) |
33 | #define LEND_WIFI_PHONE_MODE (1 << 5) | 35 | #define SPEAR300_CAMERA_F_IRQ_MASK (1 << 5) |
34 | #define HEND_WIFI_PHONE_MODE (1 << 6) | 36 | #define SPEAR300_CAMERA_V_IRQ_MASK (1 << 6) |
35 | #define ATA_PABX_WI2S_MODE (1 << 7) | 37 | #define SPEAR300_KEYBOARD_IRQ_MASK (1 << 7) |
36 | #define ATA_PABX_I2S_MODE (1 << 8) | 38 | #define SPEAR300_GPIO1_IRQ_MASK (1 << 8) |
37 | #define CAML_LCDW_MODE (1 << 9) | 39 | |
38 | #define CAMU_LCD_MODE (1 << 10) | 40 | #define SPEAR300_SHIRQ_RAS1_MASK 0x1FF |
39 | #define CAMU_WLCD_MODE (1 << 11) | 41 | |
40 | #define CAML_LCD_MODE (1 << 12) | 42 | #define SPEAR300_SOC_CONFIG_BASE UL(0x99000000) |
41 | #define ALL_MODES 0x1FFF | 43 | |
42 | 44 | ||
43 | struct pmx_mode spear300_nand_mode = { | 45 | /* SPEAr300 Virtual irq definitions */ |
44 | .id = NAND_MODE, | 46 | /* IRQs sharing IRQ_GEN_RAS_1 */ |
45 | .name = "nand mode", | 47 | #define SPEAR300_VIRQ_IT_PERS_S (SPEAR3XX_VIRQ_START + 0) |
46 | .mask = 0x00, | 48 | #define SPEAR300_VIRQ_IT_CHANGE_S (SPEAR3XX_VIRQ_START + 1) |
47 | }; | 49 | #define SPEAR300_VIRQ_I2S (SPEAR3XX_VIRQ_START + 2) |
48 | 50 | #define SPEAR300_VIRQ_TDM (SPEAR3XX_VIRQ_START + 3) | |
49 | struct pmx_mode spear300_nor_mode = { | 51 | #define SPEAR300_VIRQ_CAMERA_L (SPEAR3XX_VIRQ_START + 4) |
50 | .id = NOR_MODE, | 52 | #define SPEAR300_VIRQ_CAMERA_F (SPEAR3XX_VIRQ_START + 5) |
51 | .name = "nor mode", | 53 | #define SPEAR300_VIRQ_CAMERA_V (SPEAR3XX_VIRQ_START + 6) |
52 | .mask = 0x01, | 54 | #define SPEAR300_VIRQ_KEYBOARD (SPEAR3XX_VIRQ_START + 7) |
53 | }; | 55 | #define SPEAR300_VIRQ_GPIO1 (SPEAR3XX_VIRQ_START + 8) |
54 | 56 | ||
55 | struct pmx_mode spear300_photo_frame_mode = { | 57 | /* IRQs sharing IRQ_GEN_RAS_3 */ |
56 | .id = PHOTO_FRAME_MODE, | 58 | #define SPEAR300_IRQ_CLCD SPEAR3XX_IRQ_GEN_RAS_3 |
57 | .name = "photo frame mode", | 59 | |
58 | .mask = 0x02, | 60 | /* IRQs sharing IRQ_INTRCOMM_RAS_ARM */ |
59 | }; | 61 | #define SPEAR300_IRQ_SDHCI SPEAR3XX_IRQ_INTRCOMM_RAS_ARM |
60 | |||
61 | struct pmx_mode spear300_lend_ip_phone_mode = { | ||
62 | .id = LEND_IP_PHONE_MODE, | ||
63 | .name = "lend ip phone mode", | ||
64 | .mask = 0x03, | ||
65 | }; | ||
66 | |||
67 | struct pmx_mode spear300_hend_ip_phone_mode = { | ||
68 | .id = HEND_IP_PHONE_MODE, | ||
69 | .name = "hend ip phone mode", | ||
70 | .mask = 0x04, | ||
71 | }; | ||
72 | |||
73 | struct pmx_mode spear300_lend_wifi_phone_mode = { | ||
74 | .id = LEND_WIFI_PHONE_MODE, | ||
75 | .name = "lend wifi phone mode", | ||
76 | .mask = 0x05, | ||
77 | }; | ||
78 | |||
79 | struct pmx_mode spear300_hend_wifi_phone_mode = { | ||
80 | .id = HEND_WIFI_PHONE_MODE, | ||
81 | .name = "hend wifi phone mode", | ||
82 | .mask = 0x06, | ||
83 | }; | ||
84 | |||
85 | struct pmx_mode spear300_ata_pabx_wi2s_mode = { | ||
86 | .id = ATA_PABX_WI2S_MODE, | ||
87 | .name = "ata pabx wi2s mode", | ||
88 | .mask = 0x07, | ||
89 | }; | ||
90 | |||
91 | struct pmx_mode spear300_ata_pabx_i2s_mode = { | ||
92 | .id = ATA_PABX_I2S_MODE, | ||
93 | .name = "ata pabx i2s mode", | ||
94 | .mask = 0x08, | ||
95 | }; | ||
96 | |||
97 | struct pmx_mode spear300_caml_lcdw_mode = { | ||
98 | .id = CAML_LCDW_MODE, | ||
99 | .name = "caml lcdw mode", | ||
100 | .mask = 0x0C, | ||
101 | }; | ||
102 | |||
103 | struct pmx_mode spear300_camu_lcd_mode = { | ||
104 | .id = CAMU_LCD_MODE, | ||
105 | .name = "camu lcd mode", | ||
106 | .mask = 0x0D, | ||
107 | }; | ||
108 | |||
109 | struct pmx_mode spear300_camu_wlcd_mode = { | ||
110 | .id = CAMU_WLCD_MODE, | ||
111 | .name = "camu wlcd mode", | ||
112 | .mask = 0x0E, | ||
113 | }; | ||
114 | |||
115 | struct pmx_mode spear300_caml_lcd_mode = { | ||
116 | .id = CAML_LCD_MODE, | ||
117 | .name = "caml lcd mode", | ||
118 | .mask = 0x0F, | ||
119 | }; | ||
120 | |||
121 | /* devices */ | ||
122 | static struct pmx_dev_mode pmx_fsmc_2_chips_modes[] = { | ||
123 | { | ||
124 | .ids = NAND_MODE | NOR_MODE | PHOTO_FRAME_MODE | | ||
125 | ATA_PABX_WI2S_MODE | ATA_PABX_I2S_MODE, | ||
126 | .mask = PMX_FIRDA_MASK, | ||
127 | }, | ||
128 | }; | ||
129 | |||
130 | struct pmx_dev spear300_pmx_fsmc_2_chips = { | ||
131 | .name = "fsmc_2_chips", | ||
132 | .modes = pmx_fsmc_2_chips_modes, | ||
133 | .mode_count = ARRAY_SIZE(pmx_fsmc_2_chips_modes), | ||
134 | .enb_on_reset = 1, | ||
135 | }; | ||
136 | |||
137 | static struct pmx_dev_mode pmx_fsmc_4_chips_modes[] = { | ||
138 | { | ||
139 | .ids = NAND_MODE | NOR_MODE | PHOTO_FRAME_MODE | | ||
140 | ATA_PABX_WI2S_MODE | ATA_PABX_I2S_MODE, | ||
141 | .mask = PMX_FIRDA_MASK | PMX_UART0_MASK, | ||
142 | }, | ||
143 | }; | ||
144 | |||
145 | struct pmx_dev spear300_pmx_fsmc_4_chips = { | ||
146 | .name = "fsmc_4_chips", | ||
147 | .modes = pmx_fsmc_4_chips_modes, | ||
148 | .mode_count = ARRAY_SIZE(pmx_fsmc_4_chips_modes), | ||
149 | .enb_on_reset = 1, | ||
150 | }; | ||
151 | |||
152 | static struct pmx_dev_mode pmx_keyboard_modes[] = { | ||
153 | { | ||
154 | .ids = LEND_IP_PHONE_MODE | HEND_IP_PHONE_MODE | | ||
155 | LEND_WIFI_PHONE_MODE | HEND_WIFI_PHONE_MODE | | ||
156 | CAML_LCDW_MODE | CAMU_LCD_MODE | CAMU_WLCD_MODE | | ||
157 | CAML_LCD_MODE, | ||
158 | .mask = 0x0, | ||
159 | }, | ||
160 | }; | ||
161 | |||
162 | struct pmx_dev spear300_pmx_keyboard = { | ||
163 | .name = "keyboard", | ||
164 | .modes = pmx_keyboard_modes, | ||
165 | .mode_count = ARRAY_SIZE(pmx_keyboard_modes), | ||
166 | .enb_on_reset = 1, | ||
167 | }; | ||
168 | |||
169 | static struct pmx_dev_mode pmx_clcd_modes[] = { | ||
170 | { | ||
171 | .ids = PHOTO_FRAME_MODE, | ||
172 | .mask = PMX_TIMER_1_2_MASK | PMX_TIMER_3_4_MASK , | ||
173 | }, { | ||
174 | .ids = HEND_IP_PHONE_MODE | HEND_WIFI_PHONE_MODE | | ||
175 | CAMU_LCD_MODE | CAML_LCD_MODE, | ||
176 | .mask = PMX_TIMER_3_4_MASK, | ||
177 | }, | ||
178 | }; | ||
179 | |||
180 | struct pmx_dev spear300_pmx_clcd = { | ||
181 | .name = "clcd", | ||
182 | .modes = pmx_clcd_modes, | ||
183 | .mode_count = ARRAY_SIZE(pmx_clcd_modes), | ||
184 | .enb_on_reset = 1, | ||
185 | }; | ||
186 | |||
187 | static struct pmx_dev_mode pmx_telecom_gpio_modes[] = { | ||
188 | { | ||
189 | .ids = PHOTO_FRAME_MODE | CAMU_LCD_MODE | CAML_LCD_MODE, | ||
190 | .mask = PMX_MII_MASK, | ||
191 | }, { | ||
192 | .ids = LEND_IP_PHONE_MODE | LEND_WIFI_PHONE_MODE, | ||
193 | .mask = PMX_MII_MASK | PMX_TIMER_1_2_MASK | PMX_TIMER_3_4_MASK, | ||
194 | }, { | ||
195 | .ids = ATA_PABX_I2S_MODE | CAML_LCDW_MODE | CAMU_WLCD_MODE, | ||
196 | .mask = PMX_MII_MASK | PMX_TIMER_3_4_MASK, | ||
197 | }, { | ||
198 | .ids = HEND_IP_PHONE_MODE | HEND_WIFI_PHONE_MODE, | ||
199 | .mask = PMX_MII_MASK | PMX_TIMER_1_2_MASK, | ||
200 | }, { | ||
201 | .ids = ATA_PABX_WI2S_MODE, | ||
202 | .mask = PMX_MII_MASK | PMX_TIMER_1_2_MASK | PMX_TIMER_3_4_MASK | ||
203 | | PMX_UART0_MODEM_MASK, | ||
204 | }, | ||
205 | }; | ||
206 | |||
207 | struct pmx_dev spear300_pmx_telecom_gpio = { | ||
208 | .name = "telecom_gpio", | ||
209 | .modes = pmx_telecom_gpio_modes, | ||
210 | .mode_count = ARRAY_SIZE(pmx_telecom_gpio_modes), | ||
211 | .enb_on_reset = 1, | ||
212 | }; | ||
213 | |||
214 | static struct pmx_dev_mode pmx_telecom_tdm_modes[] = { | ||
215 | { | ||
216 | .ids = PHOTO_FRAME_MODE | LEND_IP_PHONE_MODE | | ||
217 | HEND_IP_PHONE_MODE | LEND_WIFI_PHONE_MODE | ||
218 | | HEND_WIFI_PHONE_MODE | ATA_PABX_WI2S_MODE | ||
219 | | ATA_PABX_I2S_MODE | CAML_LCDW_MODE | CAMU_LCD_MODE | ||
220 | | CAMU_WLCD_MODE | CAML_LCD_MODE, | ||
221 | .mask = PMX_UART0_MODEM_MASK | PMX_SSP_CS_MASK, | ||
222 | }, | ||
223 | }; | ||
224 | |||
225 | struct pmx_dev spear300_pmx_telecom_tdm = { | ||
226 | .name = "telecom_tdm", | ||
227 | .modes = pmx_telecom_tdm_modes, | ||
228 | .mode_count = ARRAY_SIZE(pmx_telecom_tdm_modes), | ||
229 | .enb_on_reset = 1, | ||
230 | }; | ||
231 | |||
232 | static struct pmx_dev_mode pmx_telecom_spi_cs_i2c_clk_modes[] = { | ||
233 | { | ||
234 | .ids = LEND_IP_PHONE_MODE | HEND_IP_PHONE_MODE | | ||
235 | LEND_WIFI_PHONE_MODE | HEND_WIFI_PHONE_MODE | ||
236 | | ATA_PABX_WI2S_MODE | ATA_PABX_I2S_MODE | | ||
237 | CAML_LCDW_MODE | CAML_LCD_MODE, | ||
238 | .mask = PMX_TIMER_1_2_MASK | PMX_TIMER_3_4_MASK, | ||
239 | }, | ||
240 | }; | ||
241 | |||
242 | struct pmx_dev spear300_pmx_telecom_spi_cs_i2c_clk = { | ||
243 | .name = "telecom_spi_cs_i2c_clk", | ||
244 | .modes = pmx_telecom_spi_cs_i2c_clk_modes, | ||
245 | .mode_count = ARRAY_SIZE(pmx_telecom_spi_cs_i2c_clk_modes), | ||
246 | .enb_on_reset = 1, | ||
247 | }; | ||
248 | |||
249 | static struct pmx_dev_mode pmx_telecom_camera_modes[] = { | ||
250 | { | ||
251 | .ids = CAML_LCDW_MODE | CAML_LCD_MODE, | ||
252 | .mask = PMX_MII_MASK, | ||
253 | }, { | ||
254 | .ids = CAMU_LCD_MODE | CAMU_WLCD_MODE, | ||
255 | .mask = PMX_TIMER_1_2_MASK | PMX_TIMER_3_4_MASK | PMX_MII_MASK, | ||
256 | }, | ||
257 | }; | ||
258 | |||
259 | struct pmx_dev spear300_pmx_telecom_camera = { | ||
260 | .name = "telecom_camera", | ||
261 | .modes = pmx_telecom_camera_modes, | ||
262 | .mode_count = ARRAY_SIZE(pmx_telecom_camera_modes), | ||
263 | .enb_on_reset = 1, | ||
264 | }; | ||
265 | |||
266 | static struct pmx_dev_mode pmx_telecom_dac_modes[] = { | ||
267 | { | ||
268 | .ids = ATA_PABX_I2S_MODE | CAML_LCDW_MODE | CAMU_LCD_MODE | ||
269 | | CAMU_WLCD_MODE | CAML_LCD_MODE, | ||
270 | .mask = PMX_TIMER_1_2_MASK, | ||
271 | }, | ||
272 | }; | ||
273 | |||
274 | struct pmx_dev spear300_pmx_telecom_dac = { | ||
275 | .name = "telecom_dac", | ||
276 | .modes = pmx_telecom_dac_modes, | ||
277 | .mode_count = ARRAY_SIZE(pmx_telecom_dac_modes), | ||
278 | .enb_on_reset = 1, | ||
279 | }; | ||
280 | |||
281 | static struct pmx_dev_mode pmx_telecom_i2s_modes[] = { | ||
282 | { | ||
283 | .ids = LEND_IP_PHONE_MODE | HEND_IP_PHONE_MODE | ||
284 | | LEND_WIFI_PHONE_MODE | HEND_WIFI_PHONE_MODE | | ||
285 | ATA_PABX_I2S_MODE | CAML_LCDW_MODE | CAMU_LCD_MODE | ||
286 | | CAMU_WLCD_MODE | CAML_LCD_MODE, | ||
287 | .mask = PMX_UART0_MODEM_MASK, | ||
288 | }, | ||
289 | }; | ||
290 | |||
291 | struct pmx_dev spear300_pmx_telecom_i2s = { | ||
292 | .name = "telecom_i2s", | ||
293 | .modes = pmx_telecom_i2s_modes, | ||
294 | .mode_count = ARRAY_SIZE(pmx_telecom_i2s_modes), | ||
295 | .enb_on_reset = 1, | ||
296 | }; | ||
297 | |||
298 | static struct pmx_dev_mode pmx_telecom_boot_pins_modes[] = { | ||
299 | { | ||
300 | .ids = NAND_MODE | NOR_MODE, | ||
301 | .mask = PMX_UART0_MODEM_MASK | PMX_TIMER_1_2_MASK | | ||
302 | PMX_TIMER_3_4_MASK, | ||
303 | }, | ||
304 | }; | ||
305 | |||
306 | struct pmx_dev spear300_pmx_telecom_boot_pins = { | ||
307 | .name = "telecom_boot_pins", | ||
308 | .modes = pmx_telecom_boot_pins_modes, | ||
309 | .mode_count = ARRAY_SIZE(pmx_telecom_boot_pins_modes), | ||
310 | .enb_on_reset = 1, | ||
311 | }; | ||
312 | |||
313 | static struct pmx_dev_mode pmx_telecom_sdhci_4bit_modes[] = { | ||
314 | { | ||
315 | .ids = PHOTO_FRAME_MODE | LEND_IP_PHONE_MODE | | ||
316 | HEND_IP_PHONE_MODE | LEND_WIFI_PHONE_MODE | | ||
317 | HEND_WIFI_PHONE_MODE | CAML_LCDW_MODE | CAMU_LCD_MODE | | ||
318 | CAMU_WLCD_MODE | CAML_LCD_MODE | ATA_PABX_WI2S_MODE | | ||
319 | ATA_PABX_I2S_MODE, | ||
320 | .mask = PMX_GPIO_PIN0_MASK | PMX_GPIO_PIN1_MASK | | ||
321 | PMX_GPIO_PIN2_MASK | PMX_GPIO_PIN3_MASK | | ||
322 | PMX_GPIO_PIN4_MASK | PMX_GPIO_PIN5_MASK, | ||
323 | }, | ||
324 | }; | ||
325 | |||
326 | struct pmx_dev spear300_pmx_telecom_sdhci_4bit = { | ||
327 | .name = "telecom_sdhci_4bit", | ||
328 | .modes = pmx_telecom_sdhci_4bit_modes, | ||
329 | .mode_count = ARRAY_SIZE(pmx_telecom_sdhci_4bit_modes), | ||
330 | .enb_on_reset = 1, | ||
331 | }; | ||
332 | |||
333 | static struct pmx_dev_mode pmx_telecom_sdhci_8bit_modes[] = { | ||
334 | { | ||
335 | .ids = PHOTO_FRAME_MODE | LEND_IP_PHONE_MODE | | ||
336 | HEND_IP_PHONE_MODE | LEND_WIFI_PHONE_MODE | | ||
337 | HEND_WIFI_PHONE_MODE | CAML_LCDW_MODE | CAMU_LCD_MODE | | ||
338 | CAMU_WLCD_MODE | CAML_LCD_MODE, | ||
339 | .mask = PMX_GPIO_PIN0_MASK | PMX_GPIO_PIN1_MASK | | ||
340 | PMX_GPIO_PIN2_MASK | PMX_GPIO_PIN3_MASK | | ||
341 | PMX_GPIO_PIN4_MASK | PMX_GPIO_PIN5_MASK | PMX_MII_MASK, | ||
342 | }, | ||
343 | }; | ||
344 | |||
345 | struct pmx_dev spear300_pmx_telecom_sdhci_8bit = { | ||
346 | .name = "telecom_sdhci_8bit", | ||
347 | .modes = pmx_telecom_sdhci_8bit_modes, | ||
348 | .mode_count = ARRAY_SIZE(pmx_telecom_sdhci_8bit_modes), | ||
349 | .enb_on_reset = 1, | ||
350 | }; | ||
351 | |||
352 | static struct pmx_dev_mode pmx_gpio1_modes[] = { | ||
353 | { | ||
354 | .ids = PHOTO_FRAME_MODE, | ||
355 | .mask = PMX_UART0_MODEM_MASK | PMX_TIMER_1_2_MASK | | ||
356 | PMX_TIMER_3_4_MASK, | ||
357 | }, | ||
358 | }; | ||
359 | |||
360 | struct pmx_dev spear300_pmx_gpio1 = { | ||
361 | .name = "arm gpio1", | ||
362 | .modes = pmx_gpio1_modes, | ||
363 | .mode_count = ARRAY_SIZE(pmx_gpio1_modes), | ||
364 | .enb_on_reset = 1, | ||
365 | }; | ||
366 | |||
367 | /* pmx driver structure */ | ||
368 | static struct pmx_driver pmx_driver = { | ||
369 | .mode_reg = {.offset = MODE_CONFIG_REG, .mask = 0x0000000f}, | ||
370 | .mux_reg = {.offset = PAD_MUX_CONFIG_REG, .mask = 0x00007fff}, | ||
371 | }; | ||
372 | 62 | ||
373 | /* spear3xx shared irq */ | 63 | /* spear3xx shared irq */ |
374 | static struct shirq_dev_config shirq_ras1_config[] = { | 64 | static struct shirq_dev_config shirq_ras1_config[] = { |
@@ -423,45 +113,238 @@ static struct spear_shirq shirq_ras1 = { | |||
423 | }, | 113 | }, |
424 | }; | 114 | }; |
425 | 115 | ||
426 | /* Add spear300 specific devices here */ | 116 | /* DMAC platform data's slave info */ |
427 | /* arm gpio1 device registration */ | 117 | struct pl08x_channel_data spear300_dma_info[] = { |
428 | static struct pl061_platform_data gpio1_plat_data = { | 118 | { |
429 | .gpio_base = 8, | 119 | .bus_id = "uart0_rx", |
430 | .irq_base = SPEAR300_GPIO1_INT_BASE, | 120 | .min_signal = 2, |
121 | .max_signal = 2, | ||
122 | .muxval = 0, | ||
123 | .cctl = 0, | ||
124 | .periph_buses = PL08X_AHB1, | ||
125 | }, { | ||
126 | .bus_id = "uart0_tx", | ||
127 | .min_signal = 3, | ||
128 | .max_signal = 3, | ||
129 | .muxval = 0, | ||
130 | .cctl = 0, | ||
131 | .periph_buses = PL08X_AHB1, | ||
132 | }, { | ||
133 | .bus_id = "ssp0_rx", | ||
134 | .min_signal = 8, | ||
135 | .max_signal = 8, | ||
136 | .muxval = 0, | ||
137 | .cctl = 0, | ||
138 | .periph_buses = PL08X_AHB1, | ||
139 | }, { | ||
140 | .bus_id = "ssp0_tx", | ||
141 | .min_signal = 9, | ||
142 | .max_signal = 9, | ||
143 | .muxval = 0, | ||
144 | .cctl = 0, | ||
145 | .periph_buses = PL08X_AHB1, | ||
146 | }, { | ||
147 | .bus_id = "i2c_rx", | ||
148 | .min_signal = 10, | ||
149 | .max_signal = 10, | ||
150 | .muxval = 0, | ||
151 | .cctl = 0, | ||
152 | .periph_buses = PL08X_AHB1, | ||
153 | }, { | ||
154 | .bus_id = "i2c_tx", | ||
155 | .min_signal = 11, | ||
156 | .max_signal = 11, | ||
157 | .muxval = 0, | ||
158 | .cctl = 0, | ||
159 | .periph_buses = PL08X_AHB1, | ||
160 | }, { | ||
161 | .bus_id = "irda", | ||
162 | .min_signal = 12, | ||
163 | .max_signal = 12, | ||
164 | .muxval = 0, | ||
165 | .cctl = 0, | ||
166 | .periph_buses = PL08X_AHB1, | ||
167 | }, { | ||
168 | .bus_id = "adc", | ||
169 | .min_signal = 13, | ||
170 | .max_signal = 13, | ||
171 | .muxval = 0, | ||
172 | .cctl = 0, | ||
173 | .periph_buses = PL08X_AHB1, | ||
174 | }, { | ||
175 | .bus_id = "to_jpeg", | ||
176 | .min_signal = 14, | ||
177 | .max_signal = 14, | ||
178 | .muxval = 0, | ||
179 | .cctl = 0, | ||
180 | .periph_buses = PL08X_AHB1, | ||
181 | }, { | ||
182 | .bus_id = "from_jpeg", | ||
183 | .min_signal = 15, | ||
184 | .max_signal = 15, | ||
185 | .muxval = 0, | ||
186 | .cctl = 0, | ||
187 | .periph_buses = PL08X_AHB1, | ||
188 | }, { | ||
189 | .bus_id = "ras0_rx", | ||
190 | .min_signal = 0, | ||
191 | .max_signal = 0, | ||
192 | .muxval = 1, | ||
193 | .cctl = 0, | ||
194 | .periph_buses = PL08X_AHB1, | ||
195 | }, { | ||
196 | .bus_id = "ras0_tx", | ||
197 | .min_signal = 1, | ||
198 | .max_signal = 1, | ||
199 | .muxval = 1, | ||
200 | .cctl = 0, | ||
201 | .periph_buses = PL08X_AHB1, | ||
202 | }, { | ||
203 | .bus_id = "ras1_rx", | ||
204 | .min_signal = 2, | ||
205 | .max_signal = 2, | ||
206 | .muxval = 1, | ||
207 | .cctl = 0, | ||
208 | .periph_buses = PL08X_AHB1, | ||
209 | }, { | ||
210 | .bus_id = "ras1_tx", | ||
211 | .min_signal = 3, | ||
212 | .max_signal = 3, | ||
213 | .muxval = 1, | ||
214 | .cctl = 0, | ||
215 | .periph_buses = PL08X_AHB1, | ||
216 | }, { | ||
217 | .bus_id = "ras2_rx", | ||
218 | .min_signal = 4, | ||
219 | .max_signal = 4, | ||
220 | .muxval = 1, | ||
221 | .cctl = 0, | ||
222 | .periph_buses = PL08X_AHB1, | ||
223 | }, { | ||
224 | .bus_id = "ras2_tx", | ||
225 | .min_signal = 5, | ||
226 | .max_signal = 5, | ||
227 | .muxval = 1, | ||
228 | .cctl = 0, | ||
229 | .periph_buses = PL08X_AHB1, | ||
230 | }, { | ||
231 | .bus_id = "ras3_rx", | ||
232 | .min_signal = 6, | ||
233 | .max_signal = 6, | ||
234 | .muxval = 1, | ||
235 | .cctl = 0, | ||
236 | .periph_buses = PL08X_AHB1, | ||
237 | }, { | ||
238 | .bus_id = "ras3_tx", | ||
239 | .min_signal = 7, | ||
240 | .max_signal = 7, | ||
241 | .muxval = 1, | ||
242 | .cctl = 0, | ||
243 | .periph_buses = PL08X_AHB1, | ||
244 | }, { | ||
245 | .bus_id = "ras4_rx", | ||
246 | .min_signal = 8, | ||
247 | .max_signal = 8, | ||
248 | .muxval = 1, | ||
249 | .cctl = 0, | ||
250 | .periph_buses = PL08X_AHB1, | ||
251 | }, { | ||
252 | .bus_id = "ras4_tx", | ||
253 | .min_signal = 9, | ||
254 | .max_signal = 9, | ||
255 | .muxval = 1, | ||
256 | .cctl = 0, | ||
257 | .periph_buses = PL08X_AHB1, | ||
258 | }, { | ||
259 | .bus_id = "ras5_rx", | ||
260 | .min_signal = 10, | ||
261 | .max_signal = 10, | ||
262 | .muxval = 1, | ||
263 | .cctl = 0, | ||
264 | .periph_buses = PL08X_AHB1, | ||
265 | }, { | ||
266 | .bus_id = "ras5_tx", | ||
267 | .min_signal = 11, | ||
268 | .max_signal = 11, | ||
269 | .muxval = 1, | ||
270 | .cctl = 0, | ||
271 | .periph_buses = PL08X_AHB1, | ||
272 | }, { | ||
273 | .bus_id = "ras6_rx", | ||
274 | .min_signal = 12, | ||
275 | .max_signal = 12, | ||
276 | .muxval = 1, | ||
277 | .cctl = 0, | ||
278 | .periph_buses = PL08X_AHB1, | ||
279 | }, { | ||
280 | .bus_id = "ras6_tx", | ||
281 | .min_signal = 13, | ||
282 | .max_signal = 13, | ||
283 | .muxval = 1, | ||
284 | .cctl = 0, | ||
285 | .periph_buses = PL08X_AHB1, | ||
286 | }, { | ||
287 | .bus_id = "ras7_rx", | ||
288 | .min_signal = 14, | ||
289 | .max_signal = 14, | ||
290 | .muxval = 1, | ||
291 | .cctl = 0, | ||
292 | .periph_buses = PL08X_AHB1, | ||
293 | }, { | ||
294 | .bus_id = "ras7_tx", | ||
295 | .min_signal = 15, | ||
296 | .max_signal = 15, | ||
297 | .muxval = 1, | ||
298 | .cctl = 0, | ||
299 | .periph_buses = PL08X_AHB1, | ||
300 | }, | ||
431 | }; | 301 | }; |
432 | 302 | ||
433 | AMBA_APB_DEVICE(spear300_gpio1, "gpio1", 0, SPEAR300_GPIO_BASE, | 303 | /* Add SPEAr300 auxdata to pass platform data */ |
434 | {SPEAR300_VIRQ_GPIO1}, &gpio1_plat_data); | 304 | static struct of_dev_auxdata spear300_auxdata_lookup[] __initdata = { |
305 | OF_DEV_AUXDATA("arm,pl022", SPEAR3XX_ICM1_SSP_BASE, NULL, | ||
306 | &pl022_plat_data), | ||
307 | OF_DEV_AUXDATA("arm,pl080", SPEAR3XX_ICM3_DMA_BASE, NULL, | ||
308 | &pl080_plat_data), | ||
309 | {} | ||
310 | }; | ||
435 | 311 | ||
436 | /* spear300 routines */ | 312 | static void __init spear300_dt_init(void) |
437 | void __init spear300_init(struct pmx_mode *pmx_mode, struct pmx_dev **pmx_devs, | ||
438 | u8 pmx_dev_count) | ||
439 | { | 313 | { |
440 | int ret = 0; | 314 | int ret; |
315 | |||
316 | pl080_plat_data.slave_channels = spear300_dma_info; | ||
317 | pl080_plat_data.num_slave_channels = ARRAY_SIZE(spear300_dma_info); | ||
441 | 318 | ||
442 | /* call spear3xx family common init function */ | 319 | of_platform_populate(NULL, of_default_bus_match_table, |
443 | spear3xx_init(); | 320 | spear300_auxdata_lookup, NULL); |
444 | 321 | ||
445 | /* shared irq registration */ | 322 | /* shared irq registration */ |
446 | shirq_ras1.regs.base = ioremap(SPEAR300_TELECOM_BASE, SZ_4K); | 323 | shirq_ras1.regs.base = ioremap(SPEAR300_TELECOM_BASE, SZ_4K); |
447 | if (shirq_ras1.regs.base) { | 324 | if (shirq_ras1.regs.base) { |
448 | ret = spear_shirq_register(&shirq_ras1); | 325 | ret = spear_shirq_register(&shirq_ras1); |
449 | if (ret) | 326 | if (ret) |
450 | printk(KERN_ERR "Error registering Shared IRQ\n"); | 327 | pr_err("Error registering Shared IRQ\n"); |
451 | } | 328 | } |
329 | } | ||
452 | 330 | ||
453 | /* pmx initialization */ | 331 | static const char * const spear300_dt_board_compat[] = { |
454 | pmx_driver.mode = pmx_mode; | 332 | "st,spear300", |
455 | pmx_driver.devs = pmx_devs; | 333 | "st,spear300-evb", |
456 | pmx_driver.devs_count = pmx_dev_count; | 334 | NULL, |
335 | }; | ||
457 | 336 | ||
458 | pmx_driver.base = ioremap(SPEAR300_SOC_CONFIG_BASE, SZ_4K); | 337 | static void __init spear300_map_io(void) |
459 | if (pmx_driver.base) { | 338 | { |
460 | ret = pmx_register(&pmx_driver); | 339 | spear3xx_map_io(); |
461 | if (ret) | ||
462 | printk(KERN_ERR "padmux: registration failed. err no" | ||
463 | ": %d\n", ret); | ||
464 | /* Free Mapping, device selection already done */ | ||
465 | iounmap(pmx_driver.base); | ||
466 | } | ||
467 | } | 340 | } |
341 | |||
342 | DT_MACHINE_START(SPEAR300_DT, "ST SPEAr300 SoC with Flattened Device Tree") | ||
343 | .map_io = spear300_map_io, | ||
344 | .init_irq = spear3xx_dt_init_irq, | ||
345 | .handle_irq = vic_handle_irq, | ||
346 | .timer = &spear3xx_timer, | ||
347 | .init_machine = spear300_dt_init, | ||
348 | .restart = spear_restart, | ||
349 | .dt_compat = spear300_dt_board_compat, | ||
350 | MACHINE_END | ||
diff --git a/arch/arm/mach-spear3xx/spear300_evb.c b/arch/arm/mach-spear3xx/spear300_evb.c deleted file mode 100644 index 3462ab9d6122..000000000000 --- a/arch/arm/mach-spear3xx/spear300_evb.c +++ /dev/null | |||
@@ -1,75 +0,0 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-spear3xx/spear300_evb.c | ||
3 | * | ||
4 | * SPEAr300 evaluation board source file | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #include <asm/hardware/vic.h> | ||
15 | #include <asm/mach/arch.h> | ||
16 | #include <asm/mach-types.h> | ||
17 | #include <mach/generic.h> | ||
18 | #include <mach/hardware.h> | ||
19 | |||
20 | /* padmux devices to enable */ | ||
21 | static struct pmx_dev *pmx_devs[] = { | ||
22 | /* spear3xx specific devices */ | ||
23 | &spear3xx_pmx_i2c, | ||
24 | &spear3xx_pmx_ssp_cs, | ||
25 | &spear3xx_pmx_ssp, | ||
26 | &spear3xx_pmx_mii, | ||
27 | &spear3xx_pmx_uart0, | ||
28 | |||
29 | /* spear300 specific devices */ | ||
30 | &spear300_pmx_fsmc_2_chips, | ||
31 | &spear300_pmx_clcd, | ||
32 | &spear300_pmx_telecom_sdhci_4bit, | ||
33 | &spear300_pmx_gpio1, | ||
34 | }; | ||
35 | |||
36 | static struct amba_device *amba_devs[] __initdata = { | ||
37 | /* spear3xx specific devices */ | ||
38 | &spear3xx_gpio_device, | ||
39 | &spear3xx_uart_device, | ||
40 | |||
41 | /* spear300 specific devices */ | ||
42 | &spear300_gpio1_device, | ||
43 | }; | ||
44 | |||
45 | static struct platform_device *plat_devs[] __initdata = { | ||
46 | /* spear3xx specific devices */ | ||
47 | |||
48 | /* spear300 specific devices */ | ||
49 | }; | ||
50 | |||
51 | static void __init spear300_evb_init(void) | ||
52 | { | ||
53 | unsigned int i; | ||
54 | |||
55 | /* call spear300 machine init function */ | ||
56 | spear300_init(&spear300_photo_frame_mode, pmx_devs, | ||
57 | ARRAY_SIZE(pmx_devs)); | ||
58 | |||
59 | /* Add Platform Devices */ | ||
60 | platform_add_devices(plat_devs, ARRAY_SIZE(plat_devs)); | ||
61 | |||
62 | /* Add Amba Devices */ | ||
63 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) | ||
64 | amba_device_register(amba_devs[i], &iomem_resource); | ||
65 | } | ||
66 | |||
67 | MACHINE_START(SPEAR300, "ST-SPEAR300-EVB") | ||
68 | .atag_offset = 0x100, | ||
69 | .map_io = spear3xx_map_io, | ||
70 | .init_irq = spear3xx_init_irq, | ||
71 | .handle_irq = vic_handle_irq, | ||
72 | .timer = &spear3xx_timer, | ||
73 | .init_machine = spear300_evb_init, | ||
74 | .restart = spear_restart, | ||
75 | MACHINE_END | ||
diff --git a/arch/arm/mach-spear3xx/spear310.c b/arch/arm/mach-spear3xx/spear310.c index febaa6fcfb6a..84dfb0900747 100644 --- a/arch/arm/mach-spear3xx/spear310.c +++ b/arch/arm/mach-spear3xx/spear310.c | |||
@@ -3,141 +3,84 @@ | |||
3 | * | 3 | * |
4 | * SPEAr310 machine source file | 4 | * SPEAr310 machine source file |
5 | * | 5 | * |
6 | * Copyright (C) 2009 ST Microelectronics | 6 | * Copyright (C) 2009-2012 ST Microelectronics |
7 | * Viresh Kumar<viresh.kumar@st.com> | 7 | * Viresh Kumar <viresh.kumar@st.com> |
8 | * | 8 | * |
9 | * This file is licensed under the terms of the GNU General Public | 9 | * This file is licensed under the terms of the GNU General Public |
10 | * License version 2. This program is licensed "as is" without any | 10 | * License version 2. This program is licensed "as is" without any |
11 | * warranty of any kind, whether express or implied. | 11 | * warranty of any kind, whether express or implied. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/ptrace.h> | 14 | #define pr_fmt(fmt) "SPEAr310: " fmt |
15 | #include <asm/irq.h> | 15 | |
16 | #include <linux/amba/pl08x.h> | ||
17 | #include <linux/amba/serial.h> | ||
18 | #include <linux/of_platform.h> | ||
19 | #include <asm/hardware/vic.h> | ||
20 | #include <asm/mach/arch.h> | ||
16 | #include <plat/shirq.h> | 21 | #include <plat/shirq.h> |
17 | #include <mach/generic.h> | 22 | #include <mach/generic.h> |
18 | #include <mach/hardware.h> | 23 | #include <mach/spear.h> |
19 | 24 | ||
20 | /* pad multiplexing support */ | 25 | #define SPEAR310_UART1_BASE UL(0xB2000000) |
21 | /* muxing registers */ | 26 | #define SPEAR310_UART2_BASE UL(0xB2080000) |
22 | #define PAD_MUX_CONFIG_REG 0x08 | 27 | #define SPEAR310_UART3_BASE UL(0xB2100000) |
23 | 28 | #define SPEAR310_UART4_BASE UL(0xB2180000) | |
24 | /* devices */ | 29 | #define SPEAR310_UART5_BASE UL(0xB2200000) |
25 | static struct pmx_dev_mode pmx_emi_cs_0_1_4_5_modes[] = { | 30 | #define SPEAR310_SOC_CONFIG_BASE UL(0xB4000000) |
26 | { | 31 | |
27 | .ids = 0x00, | 32 | /* Interrupt registers offsets and masks */ |
28 | .mask = PMX_TIMER_3_4_MASK, | 33 | #define SPEAR310_INT_STS_MASK_REG 0x04 |
29 | }, | 34 | #define SPEAR310_SMII0_IRQ_MASK (1 << 0) |
30 | }; | 35 | #define SPEAR310_SMII1_IRQ_MASK (1 << 1) |
31 | 36 | #define SPEAR310_SMII2_IRQ_MASK (1 << 2) | |
32 | struct pmx_dev spear310_pmx_emi_cs_0_1_4_5 = { | 37 | #define SPEAR310_SMII3_IRQ_MASK (1 << 3) |
33 | .name = "emi_cs_0_1_4_5", | 38 | #define SPEAR310_WAKEUP_SMII0_IRQ_MASK (1 << 4) |
34 | .modes = pmx_emi_cs_0_1_4_5_modes, | 39 | #define SPEAR310_WAKEUP_SMII1_IRQ_MASK (1 << 5) |
35 | .mode_count = ARRAY_SIZE(pmx_emi_cs_0_1_4_5_modes), | 40 | #define SPEAR310_WAKEUP_SMII2_IRQ_MASK (1 << 6) |
36 | .enb_on_reset = 1, | 41 | #define SPEAR310_WAKEUP_SMII3_IRQ_MASK (1 << 7) |
37 | }; | 42 | #define SPEAR310_UART1_IRQ_MASK (1 << 8) |
38 | 43 | #define SPEAR310_UART2_IRQ_MASK (1 << 9) | |
39 | static struct pmx_dev_mode pmx_emi_cs_2_3_modes[] = { | 44 | #define SPEAR310_UART3_IRQ_MASK (1 << 10) |
40 | { | 45 | #define SPEAR310_UART4_IRQ_MASK (1 << 11) |
41 | .ids = 0x00, | 46 | #define SPEAR310_UART5_IRQ_MASK (1 << 12) |
42 | .mask = PMX_TIMER_1_2_MASK, | 47 | #define SPEAR310_EMI_IRQ_MASK (1 << 13) |
43 | }, | 48 | #define SPEAR310_TDM_HDLC_IRQ_MASK (1 << 14) |
44 | }; | 49 | #define SPEAR310_RS485_0_IRQ_MASK (1 << 15) |
45 | 50 | #define SPEAR310_RS485_1_IRQ_MASK (1 << 16) | |
46 | struct pmx_dev spear310_pmx_emi_cs_2_3 = { | 51 | |
47 | .name = "emi_cs_2_3", | 52 | #define SPEAR310_SHIRQ_RAS1_MASK 0x000FF |
48 | .modes = pmx_emi_cs_2_3_modes, | 53 | #define SPEAR310_SHIRQ_RAS2_MASK 0x01F00 |
49 | .mode_count = ARRAY_SIZE(pmx_emi_cs_2_3_modes), | 54 | #define SPEAR310_SHIRQ_RAS3_MASK 0x02000 |
50 | .enb_on_reset = 1, | 55 | #define SPEAR310_SHIRQ_INTRCOMM_RAS_MASK 0x1C000 |
51 | }; | 56 | |
52 | 57 | /* SPEAr310 Virtual irq definitions */ | |
53 | static struct pmx_dev_mode pmx_uart1_modes[] = { | 58 | /* IRQs sharing IRQ_GEN_RAS_1 */ |
54 | { | 59 | #define SPEAR310_VIRQ_SMII0 (SPEAR3XX_VIRQ_START + 0) |
55 | .ids = 0x00, | 60 | #define SPEAR310_VIRQ_SMII1 (SPEAR3XX_VIRQ_START + 1) |
56 | .mask = PMX_FIRDA_MASK, | 61 | #define SPEAR310_VIRQ_SMII2 (SPEAR3XX_VIRQ_START + 2) |
57 | }, | 62 | #define SPEAR310_VIRQ_SMII3 (SPEAR3XX_VIRQ_START + 3) |
58 | }; | 63 | #define SPEAR310_VIRQ_WAKEUP_SMII0 (SPEAR3XX_VIRQ_START + 4) |
59 | 64 | #define SPEAR310_VIRQ_WAKEUP_SMII1 (SPEAR3XX_VIRQ_START + 5) | |
60 | struct pmx_dev spear310_pmx_uart1 = { | 65 | #define SPEAR310_VIRQ_WAKEUP_SMII2 (SPEAR3XX_VIRQ_START + 6) |
61 | .name = "uart1", | 66 | #define SPEAR310_VIRQ_WAKEUP_SMII3 (SPEAR3XX_VIRQ_START + 7) |
62 | .modes = pmx_uart1_modes, | 67 | |
63 | .mode_count = ARRAY_SIZE(pmx_uart1_modes), | 68 | /* IRQs sharing IRQ_GEN_RAS_2 */ |
64 | .enb_on_reset = 1, | 69 | #define SPEAR310_VIRQ_UART1 (SPEAR3XX_VIRQ_START + 8) |
65 | }; | 70 | #define SPEAR310_VIRQ_UART2 (SPEAR3XX_VIRQ_START + 9) |
66 | 71 | #define SPEAR310_VIRQ_UART3 (SPEAR3XX_VIRQ_START + 10) | |
67 | static struct pmx_dev_mode pmx_uart2_modes[] = { | 72 | #define SPEAR310_VIRQ_UART4 (SPEAR3XX_VIRQ_START + 11) |
68 | { | 73 | #define SPEAR310_VIRQ_UART5 (SPEAR3XX_VIRQ_START + 12) |
69 | .ids = 0x00, | 74 | |
70 | .mask = PMX_TIMER_1_2_MASK, | 75 | /* IRQs sharing IRQ_GEN_RAS_3 */ |
71 | }, | 76 | #define SPEAR310_VIRQ_EMI (SPEAR3XX_VIRQ_START + 13) |
72 | }; | 77 | #define SPEAR310_VIRQ_PLGPIO (SPEAR3XX_VIRQ_START + 14) |
73 | 78 | ||
74 | struct pmx_dev spear310_pmx_uart2 = { | 79 | /* IRQs sharing IRQ_INTRCOMM_RAS_ARM */ |
75 | .name = "uart2", | 80 | #define SPEAR310_VIRQ_TDM_HDLC (SPEAR3XX_VIRQ_START + 15) |
76 | .modes = pmx_uart2_modes, | 81 | #define SPEAR310_VIRQ_RS485_0 (SPEAR3XX_VIRQ_START + 16) |
77 | .mode_count = ARRAY_SIZE(pmx_uart2_modes), | 82 | #define SPEAR310_VIRQ_RS485_1 (SPEAR3XX_VIRQ_START + 17) |
78 | .enb_on_reset = 1, | ||
79 | }; | ||
80 | |||
81 | static struct pmx_dev_mode pmx_uart3_4_5_modes[] = { | ||
82 | { | ||
83 | .ids = 0x00, | ||
84 | .mask = PMX_UART0_MODEM_MASK, | ||
85 | }, | ||
86 | }; | ||
87 | |||
88 | struct pmx_dev spear310_pmx_uart3_4_5 = { | ||
89 | .name = "uart3_4_5", | ||
90 | .modes = pmx_uart3_4_5_modes, | ||
91 | .mode_count = ARRAY_SIZE(pmx_uart3_4_5_modes), | ||
92 | .enb_on_reset = 1, | ||
93 | }; | ||
94 | |||
95 | static struct pmx_dev_mode pmx_fsmc_modes[] = { | ||
96 | { | ||
97 | .ids = 0x00, | ||
98 | .mask = PMX_SSP_CS_MASK, | ||
99 | }, | ||
100 | }; | ||
101 | |||
102 | struct pmx_dev spear310_pmx_fsmc = { | ||
103 | .name = "fsmc", | ||
104 | .modes = pmx_fsmc_modes, | ||
105 | .mode_count = ARRAY_SIZE(pmx_fsmc_modes), | ||
106 | .enb_on_reset = 1, | ||
107 | }; | ||
108 | |||
109 | static struct pmx_dev_mode pmx_rs485_0_1_modes[] = { | ||
110 | { | ||
111 | .ids = 0x00, | ||
112 | .mask = PMX_MII_MASK, | ||
113 | }, | ||
114 | }; | ||
115 | |||
116 | struct pmx_dev spear310_pmx_rs485_0_1 = { | ||
117 | .name = "rs485_0_1", | ||
118 | .modes = pmx_rs485_0_1_modes, | ||
119 | .mode_count = ARRAY_SIZE(pmx_rs485_0_1_modes), | ||
120 | .enb_on_reset = 1, | ||
121 | }; | ||
122 | |||
123 | static struct pmx_dev_mode pmx_tdm0_modes[] = { | ||
124 | { | ||
125 | .ids = 0x00, | ||
126 | .mask = PMX_MII_MASK, | ||
127 | }, | ||
128 | }; | ||
129 | |||
130 | struct pmx_dev spear310_pmx_tdm0 = { | ||
131 | .name = "tdm0", | ||
132 | .modes = pmx_tdm0_modes, | ||
133 | .mode_count = ARRAY_SIZE(pmx_tdm0_modes), | ||
134 | .enb_on_reset = 1, | ||
135 | }; | ||
136 | 83 | ||
137 | /* pmx driver structure */ | ||
138 | static struct pmx_driver pmx_driver = { | ||
139 | .mux_reg = {.offset = PAD_MUX_CONFIG_REG, .mask = 0x00007fff}, | ||
140 | }; | ||
141 | 84 | ||
142 | /* spear3xx shared irq */ | 85 | /* spear3xx shared irq */ |
143 | static struct shirq_dev_config shirq_ras1_config[] = { | 86 | static struct shirq_dev_config shirq_ras1_config[] = { |
@@ -255,17 +198,247 @@ static struct spear_shirq shirq_intrcomm_ras = { | |||
255 | }, | 198 | }, |
256 | }; | 199 | }; |
257 | 200 | ||
258 | /* Add spear310 specific devices here */ | 201 | /* DMAC platform data's slave info */ |
202 | struct pl08x_channel_data spear310_dma_info[] = { | ||
203 | { | ||
204 | .bus_id = "uart0_rx", | ||
205 | .min_signal = 2, | ||
206 | .max_signal = 2, | ||
207 | .muxval = 0, | ||
208 | .cctl = 0, | ||
209 | .periph_buses = PL08X_AHB1, | ||
210 | }, { | ||
211 | .bus_id = "uart0_tx", | ||
212 | .min_signal = 3, | ||
213 | .max_signal = 3, | ||
214 | .muxval = 0, | ||
215 | .cctl = 0, | ||
216 | .periph_buses = PL08X_AHB1, | ||
217 | }, { | ||
218 | .bus_id = "ssp0_rx", | ||
219 | .min_signal = 8, | ||
220 | .max_signal = 8, | ||
221 | .muxval = 0, | ||
222 | .cctl = 0, | ||
223 | .periph_buses = PL08X_AHB1, | ||
224 | }, { | ||
225 | .bus_id = "ssp0_tx", | ||
226 | .min_signal = 9, | ||
227 | .max_signal = 9, | ||
228 | .muxval = 0, | ||
229 | .cctl = 0, | ||
230 | .periph_buses = PL08X_AHB1, | ||
231 | }, { | ||
232 | .bus_id = "i2c_rx", | ||
233 | .min_signal = 10, | ||
234 | .max_signal = 10, | ||
235 | .muxval = 0, | ||
236 | .cctl = 0, | ||
237 | .periph_buses = PL08X_AHB1, | ||
238 | }, { | ||
239 | .bus_id = "i2c_tx", | ||
240 | .min_signal = 11, | ||
241 | .max_signal = 11, | ||
242 | .muxval = 0, | ||
243 | .cctl = 0, | ||
244 | .periph_buses = PL08X_AHB1, | ||
245 | }, { | ||
246 | .bus_id = "irda", | ||
247 | .min_signal = 12, | ||
248 | .max_signal = 12, | ||
249 | .muxval = 0, | ||
250 | .cctl = 0, | ||
251 | .periph_buses = PL08X_AHB1, | ||
252 | }, { | ||
253 | .bus_id = "adc", | ||
254 | .min_signal = 13, | ||
255 | .max_signal = 13, | ||
256 | .muxval = 0, | ||
257 | .cctl = 0, | ||
258 | .periph_buses = PL08X_AHB1, | ||
259 | }, { | ||
260 | .bus_id = "to_jpeg", | ||
261 | .min_signal = 14, | ||
262 | .max_signal = 14, | ||
263 | .muxval = 0, | ||
264 | .cctl = 0, | ||
265 | .periph_buses = PL08X_AHB1, | ||
266 | }, { | ||
267 | .bus_id = "from_jpeg", | ||
268 | .min_signal = 15, | ||
269 | .max_signal = 15, | ||
270 | .muxval = 0, | ||
271 | .cctl = 0, | ||
272 | .periph_buses = PL08X_AHB1, | ||
273 | }, { | ||
274 | .bus_id = "uart1_rx", | ||
275 | .min_signal = 0, | ||
276 | .max_signal = 0, | ||
277 | .muxval = 1, | ||
278 | .cctl = 0, | ||
279 | .periph_buses = PL08X_AHB1, | ||
280 | }, { | ||
281 | .bus_id = "uart1_tx", | ||
282 | .min_signal = 1, | ||
283 | .max_signal = 1, | ||
284 | .muxval = 1, | ||
285 | .cctl = 0, | ||
286 | .periph_buses = PL08X_AHB1, | ||
287 | }, { | ||
288 | .bus_id = "uart2_rx", | ||
289 | .min_signal = 2, | ||
290 | .max_signal = 2, | ||
291 | .muxval = 1, | ||
292 | .cctl = 0, | ||
293 | .periph_buses = PL08X_AHB1, | ||
294 | }, { | ||
295 | .bus_id = "uart2_tx", | ||
296 | .min_signal = 3, | ||
297 | .max_signal = 3, | ||
298 | .muxval = 1, | ||
299 | .cctl = 0, | ||
300 | .periph_buses = PL08X_AHB1, | ||
301 | }, { | ||
302 | .bus_id = "uart3_rx", | ||
303 | .min_signal = 4, | ||
304 | .max_signal = 4, | ||
305 | .muxval = 1, | ||
306 | .cctl = 0, | ||
307 | .periph_buses = PL08X_AHB1, | ||
308 | }, { | ||
309 | .bus_id = "uart3_tx", | ||
310 | .min_signal = 5, | ||
311 | .max_signal = 5, | ||
312 | .muxval = 1, | ||
313 | .cctl = 0, | ||
314 | .periph_buses = PL08X_AHB1, | ||
315 | }, { | ||
316 | .bus_id = "uart4_rx", | ||
317 | .min_signal = 6, | ||
318 | .max_signal = 6, | ||
319 | .muxval = 1, | ||
320 | .cctl = 0, | ||
321 | .periph_buses = PL08X_AHB1, | ||
322 | }, { | ||
323 | .bus_id = "uart4_tx", | ||
324 | .min_signal = 7, | ||
325 | .max_signal = 7, | ||
326 | .muxval = 1, | ||
327 | .cctl = 0, | ||
328 | .periph_buses = PL08X_AHB1, | ||
329 | }, { | ||
330 | .bus_id = "uart5_rx", | ||
331 | .min_signal = 8, | ||
332 | .max_signal = 8, | ||
333 | .muxval = 1, | ||
334 | .cctl = 0, | ||
335 | .periph_buses = PL08X_AHB1, | ||
336 | }, { | ||
337 | .bus_id = "uart5_tx", | ||
338 | .min_signal = 9, | ||
339 | .max_signal = 9, | ||
340 | .muxval = 1, | ||
341 | .cctl = 0, | ||
342 | .periph_buses = PL08X_AHB1, | ||
343 | }, { | ||
344 | .bus_id = "ras5_rx", | ||
345 | .min_signal = 10, | ||
346 | .max_signal = 10, | ||
347 | .muxval = 1, | ||
348 | .cctl = 0, | ||
349 | .periph_buses = PL08X_AHB1, | ||
350 | }, { | ||
351 | .bus_id = "ras5_tx", | ||
352 | .min_signal = 11, | ||
353 | .max_signal = 11, | ||
354 | .muxval = 1, | ||
355 | .cctl = 0, | ||
356 | .periph_buses = PL08X_AHB1, | ||
357 | }, { | ||
358 | .bus_id = "ras6_rx", | ||
359 | .min_signal = 12, | ||
360 | .max_signal = 12, | ||
361 | .muxval = 1, | ||
362 | .cctl = 0, | ||
363 | .periph_buses = PL08X_AHB1, | ||
364 | }, { | ||
365 | .bus_id = "ras6_tx", | ||
366 | .min_signal = 13, | ||
367 | .max_signal = 13, | ||
368 | .muxval = 1, | ||
369 | .cctl = 0, | ||
370 | .periph_buses = PL08X_AHB1, | ||
371 | }, { | ||
372 | .bus_id = "ras7_rx", | ||
373 | .min_signal = 14, | ||
374 | .max_signal = 14, | ||
375 | .muxval = 1, | ||
376 | .cctl = 0, | ||
377 | .periph_buses = PL08X_AHB1, | ||
378 | }, { | ||
379 | .bus_id = "ras7_tx", | ||
380 | .min_signal = 15, | ||
381 | .max_signal = 15, | ||
382 | .muxval = 1, | ||
383 | .cctl = 0, | ||
384 | .periph_buses = PL08X_AHB1, | ||
385 | }, | ||
386 | }; | ||
259 | 387 | ||
260 | /* spear310 routines */ | 388 | /* uart devices plat data */ |
261 | void __init spear310_init(struct pmx_mode *pmx_mode, struct pmx_dev **pmx_devs, | 389 | static struct amba_pl011_data spear310_uart_data[] = { |
262 | u8 pmx_dev_count) | 390 | { |
391 | .dma_filter = pl08x_filter_id, | ||
392 | .dma_tx_param = "uart1_tx", | ||
393 | .dma_rx_param = "uart1_rx", | ||
394 | }, { | ||
395 | .dma_filter = pl08x_filter_id, | ||
396 | .dma_tx_param = "uart2_tx", | ||
397 | .dma_rx_param = "uart2_rx", | ||
398 | }, { | ||
399 | .dma_filter = pl08x_filter_id, | ||
400 | .dma_tx_param = "uart3_tx", | ||
401 | .dma_rx_param = "uart3_rx", | ||
402 | }, { | ||
403 | .dma_filter = pl08x_filter_id, | ||
404 | .dma_tx_param = "uart4_tx", | ||
405 | .dma_rx_param = "uart4_rx", | ||
406 | }, { | ||
407 | .dma_filter = pl08x_filter_id, | ||
408 | .dma_tx_param = "uart5_tx", | ||
409 | .dma_rx_param = "uart5_rx", | ||
410 | }, | ||
411 | }; | ||
412 | |||
413 | /* Add SPEAr310 auxdata to pass platform data */ | ||
414 | static struct of_dev_auxdata spear310_auxdata_lookup[] __initdata = { | ||
415 | OF_DEV_AUXDATA("arm,pl022", SPEAR3XX_ICM1_SSP_BASE, NULL, | ||
416 | &pl022_plat_data), | ||
417 | OF_DEV_AUXDATA("arm,pl080", SPEAR3XX_ICM3_DMA_BASE, NULL, | ||
418 | &pl080_plat_data), | ||
419 | OF_DEV_AUXDATA("arm,pl011", SPEAR310_UART1_BASE, NULL, | ||
420 | &spear310_uart_data[0]), | ||
421 | OF_DEV_AUXDATA("arm,pl011", SPEAR310_UART2_BASE, NULL, | ||
422 | &spear310_uart_data[1]), | ||
423 | OF_DEV_AUXDATA("arm,pl011", SPEAR310_UART3_BASE, NULL, | ||
424 | &spear310_uart_data[2]), | ||
425 | OF_DEV_AUXDATA("arm,pl011", SPEAR310_UART4_BASE, NULL, | ||
426 | &spear310_uart_data[3]), | ||
427 | OF_DEV_AUXDATA("arm,pl011", SPEAR310_UART5_BASE, NULL, | ||
428 | &spear310_uart_data[4]), | ||
429 | {} | ||
430 | }; | ||
431 | |||
432 | static void __init spear310_dt_init(void) | ||
263 | { | 433 | { |
264 | void __iomem *base; | 434 | void __iomem *base; |
265 | int ret = 0; | 435 | int ret; |
266 | 436 | ||
267 | /* call spear3xx family common init function */ | 437 | pl080_plat_data.slave_channels = spear310_dma_info; |
268 | spear3xx_init(); | 438 | pl080_plat_data.num_slave_channels = ARRAY_SIZE(spear310_dma_info); |
439 | |||
440 | of_platform_populate(NULL, of_default_bus_match_table, | ||
441 | spear310_auxdata_lookup, NULL); | ||
269 | 442 | ||
270 | /* shared irq registration */ | 443 | /* shared irq registration */ |
271 | base = ioremap(SPEAR310_SOC_CONFIG_BASE, SZ_4K); | 444 | base = ioremap(SPEAR310_SOC_CONFIG_BASE, SZ_4K); |
@@ -274,35 +447,45 @@ void __init spear310_init(struct pmx_mode *pmx_mode, struct pmx_dev **pmx_devs, | |||
274 | shirq_ras1.regs.base = base; | 447 | shirq_ras1.regs.base = base; |
275 | ret = spear_shirq_register(&shirq_ras1); | 448 | ret = spear_shirq_register(&shirq_ras1); |
276 | if (ret) | 449 | if (ret) |
277 | printk(KERN_ERR "Error registering Shared IRQ 1\n"); | 450 | pr_err("Error registering Shared IRQ 1\n"); |
278 | 451 | ||
279 | /* shirq 2 */ | 452 | /* shirq 2 */ |
280 | shirq_ras2.regs.base = base; | 453 | shirq_ras2.regs.base = base; |
281 | ret = spear_shirq_register(&shirq_ras2); | 454 | ret = spear_shirq_register(&shirq_ras2); |
282 | if (ret) | 455 | if (ret) |
283 | printk(KERN_ERR "Error registering Shared IRQ 2\n"); | 456 | pr_err("Error registering Shared IRQ 2\n"); |
284 | 457 | ||
285 | /* shirq 3 */ | 458 | /* shirq 3 */ |
286 | shirq_ras3.regs.base = base; | 459 | shirq_ras3.regs.base = base; |
287 | ret = spear_shirq_register(&shirq_ras3); | 460 | ret = spear_shirq_register(&shirq_ras3); |
288 | if (ret) | 461 | if (ret) |
289 | printk(KERN_ERR "Error registering Shared IRQ 3\n"); | 462 | pr_err("Error registering Shared IRQ 3\n"); |
290 | 463 | ||
291 | /* shirq 4 */ | 464 | /* shirq 4 */ |
292 | shirq_intrcomm_ras.regs.base = base; | 465 | shirq_intrcomm_ras.regs.base = base; |
293 | ret = spear_shirq_register(&shirq_intrcomm_ras); | 466 | ret = spear_shirq_register(&shirq_intrcomm_ras); |
294 | if (ret) | 467 | if (ret) |
295 | printk(KERN_ERR "Error registering Shared IRQ 4\n"); | 468 | pr_err("Error registering Shared IRQ 4\n"); |
296 | } | 469 | } |
470 | } | ||
297 | 471 | ||
298 | /* pmx initialization */ | 472 | static const char * const spear310_dt_board_compat[] = { |
299 | pmx_driver.base = base; | 473 | "st,spear310", |
300 | pmx_driver.mode = pmx_mode; | 474 | "st,spear310-evb", |
301 | pmx_driver.devs = pmx_devs; | 475 | NULL, |
302 | pmx_driver.devs_count = pmx_dev_count; | 476 | }; |
303 | 477 | ||
304 | ret = pmx_register(&pmx_driver); | 478 | static void __init spear310_map_io(void) |
305 | if (ret) | 479 | { |
306 | printk(KERN_ERR "padmux: registration failed. err no: %d\n", | 480 | spear3xx_map_io(); |
307 | ret); | ||
308 | } | 481 | } |
482 | |||
483 | DT_MACHINE_START(SPEAR310_DT, "ST SPEAr310 SoC with Flattened Device Tree") | ||
484 | .map_io = spear310_map_io, | ||
485 | .init_irq = spear3xx_dt_init_irq, | ||
486 | .handle_irq = vic_handle_irq, | ||
487 | .timer = &spear3xx_timer, | ||
488 | .init_machine = spear310_dt_init, | ||
489 | .restart = spear_restart, | ||
490 | .dt_compat = spear310_dt_board_compat, | ||
491 | MACHINE_END | ||
diff --git a/arch/arm/mach-spear3xx/spear310_evb.c b/arch/arm/mach-spear3xx/spear310_evb.c deleted file mode 100644 index f92c4993f65a..000000000000 --- a/arch/arm/mach-spear3xx/spear310_evb.c +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-spear3xx/spear310_evb.c | ||
3 | * | ||
4 | * SPEAr310 evaluation board source file | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #include <asm/hardware/vic.h> | ||
15 | #include <asm/mach/arch.h> | ||
16 | #include <asm/mach-types.h> | ||
17 | #include <mach/generic.h> | ||
18 | #include <mach/hardware.h> | ||
19 | |||
20 | /* padmux devices to enable */ | ||
21 | static struct pmx_dev *pmx_devs[] = { | ||
22 | /* spear3xx specific devices */ | ||
23 | &spear3xx_pmx_i2c, | ||
24 | &spear3xx_pmx_ssp, | ||
25 | &spear3xx_pmx_gpio_pin0, | ||
26 | &spear3xx_pmx_gpio_pin1, | ||
27 | &spear3xx_pmx_gpio_pin2, | ||
28 | &spear3xx_pmx_gpio_pin3, | ||
29 | &spear3xx_pmx_gpio_pin4, | ||
30 | &spear3xx_pmx_gpio_pin5, | ||
31 | &spear3xx_pmx_uart0, | ||
32 | |||
33 | /* spear310 specific devices */ | ||
34 | &spear310_pmx_emi_cs_0_1_4_5, | ||
35 | &spear310_pmx_emi_cs_2_3, | ||
36 | &spear310_pmx_uart1, | ||
37 | &spear310_pmx_uart2, | ||
38 | &spear310_pmx_uart3_4_5, | ||
39 | &spear310_pmx_fsmc, | ||
40 | &spear310_pmx_rs485_0_1, | ||
41 | &spear310_pmx_tdm0, | ||
42 | }; | ||
43 | |||
44 | static struct amba_device *amba_devs[] __initdata = { | ||
45 | /* spear3xx specific devices */ | ||
46 | &spear3xx_gpio_device, | ||
47 | &spear3xx_uart_device, | ||
48 | |||
49 | /* spear310 specific devices */ | ||
50 | }; | ||
51 | |||
52 | static struct platform_device *plat_devs[] __initdata = { | ||
53 | /* spear3xx specific devices */ | ||
54 | |||
55 | /* spear310 specific devices */ | ||
56 | }; | ||
57 | |||
58 | static void __init spear310_evb_init(void) | ||
59 | { | ||
60 | unsigned int i; | ||
61 | |||
62 | /* call spear310 machine init function */ | ||
63 | spear310_init(NULL, pmx_devs, ARRAY_SIZE(pmx_devs)); | ||
64 | |||
65 | /* Add Platform Devices */ | ||
66 | platform_add_devices(plat_devs, ARRAY_SIZE(plat_devs)); | ||
67 | |||
68 | /* Add Amba Devices */ | ||
69 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) | ||
70 | amba_device_register(amba_devs[i], &iomem_resource); | ||
71 | } | ||
72 | |||
73 | MACHINE_START(SPEAR310, "ST-SPEAR310-EVB") | ||
74 | .atag_offset = 0x100, | ||
75 | .map_io = spear3xx_map_io, | ||
76 | .init_irq = spear3xx_init_irq, | ||
77 | .handle_irq = vic_handle_irq, | ||
78 | .timer = &spear3xx_timer, | ||
79 | .init_machine = spear310_evb_init, | ||
80 | .restart = spear_restart, | ||
81 | MACHINE_END | ||
diff --git a/arch/arm/mach-spear3xx/spear320.c b/arch/arm/mach-spear3xx/spear320.c index deaaf199612c..a88fa841d29d 100644 --- a/arch/arm/mach-spear3xx/spear320.c +++ b/arch/arm/mach-spear3xx/spear320.c | |||
@@ -3,386 +3,84 @@ | |||
3 | * | 3 | * |
4 | * SPEAr320 machine source file | 4 | * SPEAr320 machine source file |
5 | * | 5 | * |
6 | * Copyright (C) 2009 ST Microelectronics | 6 | * Copyright (C) 2009-2012 ST Microelectronics |
7 | * Viresh Kumar<viresh.kumar@st.com> | 7 | * Viresh Kumar <viresh.kumar@st.com> |
8 | * | 8 | * |
9 | * This file is licensed under the terms of the GNU General Public | 9 | * This file is licensed under the terms of the GNU General Public |
10 | * License version 2. This program is licensed "as is" without any | 10 | * License version 2. This program is licensed "as is" without any |
11 | * warranty of any kind, whether express or implied. | 11 | * warranty of any kind, whether express or implied. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/ptrace.h> | 14 | #define pr_fmt(fmt) "SPEAr320: " fmt |
15 | #include <asm/irq.h> | 15 | |
16 | #include <linux/amba/pl022.h> | ||
17 | #include <linux/amba/pl08x.h> | ||
18 | #include <linux/amba/serial.h> | ||
19 | #include <linux/of_platform.h> | ||
20 | #include <asm/hardware/vic.h> | ||
21 | #include <asm/mach/arch.h> | ||
16 | #include <plat/shirq.h> | 22 | #include <plat/shirq.h> |
17 | #include <mach/generic.h> | 23 | #include <mach/generic.h> |
18 | #include <mach/hardware.h> | 24 | #include <mach/spear.h> |
19 | 25 | ||
20 | /* pad multiplexing support */ | 26 | #define SPEAR320_UART1_BASE UL(0xA3000000) |
21 | /* muxing registers */ | 27 | #define SPEAR320_UART2_BASE UL(0xA4000000) |
22 | #define PAD_MUX_CONFIG_REG 0x0C | 28 | #define SPEAR320_SSP0_BASE UL(0xA5000000) |
23 | #define MODE_CONFIG_REG 0x10 | 29 | #define SPEAR320_SSP1_BASE UL(0xA6000000) |
24 | 30 | ||
25 | /* modes */ | 31 | /* Interrupt registers offsets and masks */ |
26 | #define AUTO_NET_SMII_MODE (1 << 0) | 32 | #define SPEAR320_INT_STS_MASK_REG 0x04 |
27 | #define AUTO_NET_MII_MODE (1 << 1) | 33 | #define SPEAR320_INT_CLR_MASK_REG 0x04 |
28 | #define AUTO_EXP_MODE (1 << 2) | 34 | #define SPEAR320_INT_ENB_MASK_REG 0x08 |
29 | #define SMALL_PRINTERS_MODE (1 << 3) | 35 | #define SPEAR320_GPIO_IRQ_MASK (1 << 0) |
30 | #define ALL_MODES 0xF | 36 | #define SPEAR320_I2S_PLAY_IRQ_MASK (1 << 1) |
31 | 37 | #define SPEAR320_I2S_REC_IRQ_MASK (1 << 2) | |
32 | struct pmx_mode spear320_auto_net_smii_mode = { | 38 | #define SPEAR320_EMI_IRQ_MASK (1 << 7) |
33 | .id = AUTO_NET_SMII_MODE, | 39 | #define SPEAR320_CLCD_IRQ_MASK (1 << 8) |
34 | .name = "Automation Networking SMII Mode", | 40 | #define SPEAR320_SPP_IRQ_MASK (1 << 9) |
35 | .mask = 0x00, | 41 | #define SPEAR320_SDHCI_IRQ_MASK (1 << 10) |
36 | }; | 42 | #define SPEAR320_CAN_U_IRQ_MASK (1 << 11) |
37 | 43 | #define SPEAR320_CAN_L_IRQ_MASK (1 << 12) | |
38 | struct pmx_mode spear320_auto_net_mii_mode = { | 44 | #define SPEAR320_UART1_IRQ_MASK (1 << 13) |
39 | .id = AUTO_NET_MII_MODE, | 45 | #define SPEAR320_UART2_IRQ_MASK (1 << 14) |
40 | .name = "Automation Networking MII Mode", | 46 | #define SPEAR320_SSP1_IRQ_MASK (1 << 15) |
41 | .mask = 0x01, | 47 | #define SPEAR320_SSP2_IRQ_MASK (1 << 16) |
42 | }; | 48 | #define SPEAR320_SMII0_IRQ_MASK (1 << 17) |
43 | 49 | #define SPEAR320_MII1_SMII1_IRQ_MASK (1 << 18) | |
44 | struct pmx_mode spear320_auto_exp_mode = { | 50 | #define SPEAR320_WAKEUP_SMII0_IRQ_MASK (1 << 19) |
45 | .id = AUTO_EXP_MODE, | 51 | #define SPEAR320_WAKEUP_MII1_SMII1_IRQ_MASK (1 << 20) |
46 | .name = "Automation Expanded Mode", | 52 | #define SPEAR320_I2C1_IRQ_MASK (1 << 21) |
47 | .mask = 0x02, | 53 | |
48 | }; | 54 | #define SPEAR320_SHIRQ_RAS1_MASK 0x000380 |
49 | 55 | #define SPEAR320_SHIRQ_RAS3_MASK 0x000007 | |
50 | struct pmx_mode spear320_small_printers_mode = { | 56 | #define SPEAR320_SHIRQ_INTRCOMM_RAS_MASK 0x3FF800 |
51 | .id = SMALL_PRINTERS_MODE, | 57 | |
52 | .name = "Small Printers Mode", | 58 | /* SPEAr320 Virtual irq definitions */ |
53 | .mask = 0x03, | 59 | /* IRQs sharing IRQ_GEN_RAS_1 */ |
54 | }; | 60 | #define SPEAR320_VIRQ_EMI (SPEAR3XX_VIRQ_START + 0) |
55 | 61 | #define SPEAR320_VIRQ_CLCD (SPEAR3XX_VIRQ_START + 1) | |
56 | /* devices */ | 62 | #define SPEAR320_VIRQ_SPP (SPEAR3XX_VIRQ_START + 2) |
57 | static struct pmx_dev_mode pmx_clcd_modes[] = { | 63 | |
58 | { | 64 | /* IRQs sharing IRQ_GEN_RAS_2 */ |
59 | .ids = AUTO_NET_SMII_MODE, | 65 | #define SPEAR320_IRQ_SDHCI SPEAR3XX_IRQ_GEN_RAS_2 |
60 | .mask = 0x0, | 66 | |
61 | }, | 67 | /* IRQs sharing IRQ_GEN_RAS_3 */ |
62 | }; | 68 | #define SPEAR320_VIRQ_PLGPIO (SPEAR3XX_VIRQ_START + 3) |
63 | 69 | #define SPEAR320_VIRQ_I2S_PLAY (SPEAR3XX_VIRQ_START + 4) | |
64 | struct pmx_dev spear320_pmx_clcd = { | 70 | #define SPEAR320_VIRQ_I2S_REC (SPEAR3XX_VIRQ_START + 5) |
65 | .name = "clcd", | 71 | |
66 | .modes = pmx_clcd_modes, | 72 | /* IRQs sharing IRQ_INTRCOMM_RAS_ARM */ |
67 | .mode_count = ARRAY_SIZE(pmx_clcd_modes), | 73 | #define SPEAR320_VIRQ_CANU (SPEAR3XX_VIRQ_START + 6) |
68 | .enb_on_reset = 1, | 74 | #define SPEAR320_VIRQ_CANL (SPEAR3XX_VIRQ_START + 7) |
69 | }; | 75 | #define SPEAR320_VIRQ_UART1 (SPEAR3XX_VIRQ_START + 8) |
70 | 76 | #define SPEAR320_VIRQ_UART2 (SPEAR3XX_VIRQ_START + 9) | |
71 | static struct pmx_dev_mode pmx_emi_modes[] = { | 77 | #define SPEAR320_VIRQ_SSP1 (SPEAR3XX_VIRQ_START + 10) |
72 | { | 78 | #define SPEAR320_VIRQ_SSP2 (SPEAR3XX_VIRQ_START + 11) |
73 | .ids = AUTO_EXP_MODE, | 79 | #define SPEAR320_VIRQ_SMII0 (SPEAR3XX_VIRQ_START + 12) |
74 | .mask = PMX_TIMER_1_2_MASK | PMX_TIMER_3_4_MASK, | 80 | #define SPEAR320_VIRQ_MII1_SMII1 (SPEAR3XX_VIRQ_START + 13) |
75 | }, | 81 | #define SPEAR320_VIRQ_WAKEUP_SMII0 (SPEAR3XX_VIRQ_START + 14) |
76 | }; | 82 | #define SPEAR320_VIRQ_WAKEUP_MII1_SMII1 (SPEAR3XX_VIRQ_START + 15) |
77 | 83 | #define SPEAR320_VIRQ_I2C1 (SPEAR3XX_VIRQ_START + 16) | |
78 | struct pmx_dev spear320_pmx_emi = { | ||
79 | .name = "emi", | ||
80 | .modes = pmx_emi_modes, | ||
81 | .mode_count = ARRAY_SIZE(pmx_emi_modes), | ||
82 | .enb_on_reset = 1, | ||
83 | }; | ||
84 | |||
85 | static struct pmx_dev_mode pmx_fsmc_modes[] = { | ||
86 | { | ||
87 | .ids = ALL_MODES, | ||
88 | .mask = 0x0, | ||
89 | }, | ||
90 | }; | ||
91 | |||
92 | struct pmx_dev spear320_pmx_fsmc = { | ||
93 | .name = "fsmc", | ||
94 | .modes = pmx_fsmc_modes, | ||
95 | .mode_count = ARRAY_SIZE(pmx_fsmc_modes), | ||
96 | .enb_on_reset = 1, | ||
97 | }; | ||
98 | |||
99 | static struct pmx_dev_mode pmx_spp_modes[] = { | ||
100 | { | ||
101 | .ids = SMALL_PRINTERS_MODE, | ||
102 | .mask = 0x0, | ||
103 | }, | ||
104 | }; | ||
105 | |||
106 | struct pmx_dev spear320_pmx_spp = { | ||
107 | .name = "spp", | ||
108 | .modes = pmx_spp_modes, | ||
109 | .mode_count = ARRAY_SIZE(pmx_spp_modes), | ||
110 | .enb_on_reset = 1, | ||
111 | }; | ||
112 | |||
113 | static struct pmx_dev_mode pmx_sdhci_modes[] = { | ||
114 | { | ||
115 | .ids = AUTO_NET_SMII_MODE | AUTO_NET_MII_MODE | | ||
116 | SMALL_PRINTERS_MODE, | ||
117 | .mask = PMX_TIMER_1_2_MASK | PMX_TIMER_3_4_MASK, | ||
118 | }, | ||
119 | }; | ||
120 | |||
121 | struct pmx_dev spear320_pmx_sdhci = { | ||
122 | .name = "sdhci", | ||
123 | .modes = pmx_sdhci_modes, | ||
124 | .mode_count = ARRAY_SIZE(pmx_sdhci_modes), | ||
125 | .enb_on_reset = 1, | ||
126 | }; | ||
127 | |||
128 | static struct pmx_dev_mode pmx_i2s_modes[] = { | ||
129 | { | ||
130 | .ids = AUTO_NET_SMII_MODE | AUTO_NET_MII_MODE, | ||
131 | .mask = PMX_UART0_MODEM_MASK, | ||
132 | }, | ||
133 | }; | ||
134 | |||
135 | struct pmx_dev spear320_pmx_i2s = { | ||
136 | .name = "i2s", | ||
137 | .modes = pmx_i2s_modes, | ||
138 | .mode_count = ARRAY_SIZE(pmx_i2s_modes), | ||
139 | .enb_on_reset = 1, | ||
140 | }; | ||
141 | |||
142 | static struct pmx_dev_mode pmx_uart1_modes[] = { | ||
143 | { | ||
144 | .ids = ALL_MODES, | ||
145 | .mask = PMX_GPIO_PIN0_MASK | PMX_GPIO_PIN1_MASK, | ||
146 | }, | ||
147 | }; | ||
148 | |||
149 | struct pmx_dev spear320_pmx_uart1 = { | ||
150 | .name = "uart1", | ||
151 | .modes = pmx_uart1_modes, | ||
152 | .mode_count = ARRAY_SIZE(pmx_uart1_modes), | ||
153 | .enb_on_reset = 1, | ||
154 | }; | ||
155 | |||
156 | static struct pmx_dev_mode pmx_uart1_modem_modes[] = { | ||
157 | { | ||
158 | .ids = AUTO_EXP_MODE, | ||
159 | .mask = PMX_TIMER_1_2_MASK | PMX_TIMER_3_4_MASK | | ||
160 | PMX_SSP_CS_MASK, | ||
161 | }, { | ||
162 | .ids = SMALL_PRINTERS_MODE, | ||
163 | .mask = PMX_GPIO_PIN3_MASK | PMX_GPIO_PIN4_MASK | | ||
164 | PMX_GPIO_PIN5_MASK | PMX_SSP_CS_MASK, | ||
165 | }, | ||
166 | }; | ||
167 | |||
168 | struct pmx_dev spear320_pmx_uart1_modem = { | ||
169 | .name = "uart1_modem", | ||
170 | .modes = pmx_uart1_modem_modes, | ||
171 | .mode_count = ARRAY_SIZE(pmx_uart1_modem_modes), | ||
172 | .enb_on_reset = 1, | ||
173 | }; | ||
174 | |||
175 | static struct pmx_dev_mode pmx_uart2_modes[] = { | ||
176 | { | ||
177 | .ids = ALL_MODES, | ||
178 | .mask = PMX_FIRDA_MASK, | ||
179 | }, | ||
180 | }; | ||
181 | |||
182 | struct pmx_dev spear320_pmx_uart2 = { | ||
183 | .name = "uart2", | ||
184 | .modes = pmx_uart2_modes, | ||
185 | .mode_count = ARRAY_SIZE(pmx_uart2_modes), | ||
186 | .enb_on_reset = 1, | ||
187 | }; | ||
188 | |||
189 | static struct pmx_dev_mode pmx_touchscreen_modes[] = { | ||
190 | { | ||
191 | .ids = AUTO_NET_SMII_MODE, | ||
192 | .mask = PMX_SSP_CS_MASK, | ||
193 | }, | ||
194 | }; | ||
195 | |||
196 | struct pmx_dev spear320_pmx_touchscreen = { | ||
197 | .name = "touchscreen", | ||
198 | .modes = pmx_touchscreen_modes, | ||
199 | .mode_count = ARRAY_SIZE(pmx_touchscreen_modes), | ||
200 | .enb_on_reset = 1, | ||
201 | }; | ||
202 | |||
203 | static struct pmx_dev_mode pmx_can_modes[] = { | ||
204 | { | ||
205 | .ids = AUTO_NET_SMII_MODE | AUTO_NET_MII_MODE | AUTO_EXP_MODE, | ||
206 | .mask = PMX_GPIO_PIN2_MASK | PMX_GPIO_PIN3_MASK | | ||
207 | PMX_GPIO_PIN4_MASK | PMX_GPIO_PIN5_MASK, | ||
208 | }, | ||
209 | }; | ||
210 | |||
211 | struct pmx_dev spear320_pmx_can = { | ||
212 | .name = "can", | ||
213 | .modes = pmx_can_modes, | ||
214 | .mode_count = ARRAY_SIZE(pmx_can_modes), | ||
215 | .enb_on_reset = 1, | ||
216 | }; | ||
217 | |||
218 | static struct pmx_dev_mode pmx_sdhci_led_modes[] = { | ||
219 | { | ||
220 | .ids = AUTO_NET_SMII_MODE | AUTO_NET_MII_MODE, | ||
221 | .mask = PMX_SSP_CS_MASK, | ||
222 | }, | ||
223 | }; | ||
224 | |||
225 | struct pmx_dev spear320_pmx_sdhci_led = { | ||
226 | .name = "sdhci_led", | ||
227 | .modes = pmx_sdhci_led_modes, | ||
228 | .mode_count = ARRAY_SIZE(pmx_sdhci_led_modes), | ||
229 | .enb_on_reset = 1, | ||
230 | }; | ||
231 | |||
232 | static struct pmx_dev_mode pmx_pwm0_modes[] = { | ||
233 | { | ||
234 | .ids = AUTO_NET_SMII_MODE | AUTO_NET_MII_MODE, | ||
235 | .mask = PMX_UART0_MODEM_MASK, | ||
236 | }, { | ||
237 | .ids = AUTO_EXP_MODE | SMALL_PRINTERS_MODE, | ||
238 | .mask = PMX_MII_MASK, | ||
239 | }, | ||
240 | }; | ||
241 | |||
242 | struct pmx_dev spear320_pmx_pwm0 = { | ||
243 | .name = "pwm0", | ||
244 | .modes = pmx_pwm0_modes, | ||
245 | .mode_count = ARRAY_SIZE(pmx_pwm0_modes), | ||
246 | .enb_on_reset = 1, | ||
247 | }; | ||
248 | |||
249 | static struct pmx_dev_mode pmx_pwm1_modes[] = { | ||
250 | { | ||
251 | .ids = AUTO_NET_SMII_MODE | AUTO_NET_MII_MODE, | ||
252 | .mask = PMX_UART0_MODEM_MASK, | ||
253 | }, { | ||
254 | .ids = AUTO_EXP_MODE | SMALL_PRINTERS_MODE, | ||
255 | .mask = PMX_MII_MASK, | ||
256 | }, | ||
257 | }; | ||
258 | |||
259 | struct pmx_dev spear320_pmx_pwm1 = { | ||
260 | .name = "pwm1", | ||
261 | .modes = pmx_pwm1_modes, | ||
262 | .mode_count = ARRAY_SIZE(pmx_pwm1_modes), | ||
263 | .enb_on_reset = 1, | ||
264 | }; | ||
265 | |||
266 | static struct pmx_dev_mode pmx_pwm2_modes[] = { | ||
267 | { | ||
268 | .ids = AUTO_NET_SMII_MODE | AUTO_NET_MII_MODE, | ||
269 | .mask = PMX_SSP_CS_MASK, | ||
270 | }, { | ||
271 | .ids = AUTO_EXP_MODE | SMALL_PRINTERS_MODE, | ||
272 | .mask = PMX_MII_MASK, | ||
273 | }, | ||
274 | }; | ||
275 | |||
276 | struct pmx_dev spear320_pmx_pwm2 = { | ||
277 | .name = "pwm2", | ||
278 | .modes = pmx_pwm2_modes, | ||
279 | .mode_count = ARRAY_SIZE(pmx_pwm2_modes), | ||
280 | .enb_on_reset = 1, | ||
281 | }; | ||
282 | |||
283 | static struct pmx_dev_mode pmx_pwm3_modes[] = { | ||
284 | { | ||
285 | .ids = AUTO_EXP_MODE | SMALL_PRINTERS_MODE | AUTO_NET_SMII_MODE, | ||
286 | .mask = PMX_MII_MASK, | ||
287 | }, | ||
288 | }; | ||
289 | |||
290 | struct pmx_dev spear320_pmx_pwm3 = { | ||
291 | .name = "pwm3", | ||
292 | .modes = pmx_pwm3_modes, | ||
293 | .mode_count = ARRAY_SIZE(pmx_pwm3_modes), | ||
294 | .enb_on_reset = 1, | ||
295 | }; | ||
296 | |||
297 | static struct pmx_dev_mode pmx_ssp1_modes[] = { | ||
298 | { | ||
299 | .ids = SMALL_PRINTERS_MODE | AUTO_NET_SMII_MODE, | ||
300 | .mask = PMX_MII_MASK, | ||
301 | }, | ||
302 | }; | ||
303 | |||
304 | struct pmx_dev spear320_pmx_ssp1 = { | ||
305 | .name = "ssp1", | ||
306 | .modes = pmx_ssp1_modes, | ||
307 | .mode_count = ARRAY_SIZE(pmx_ssp1_modes), | ||
308 | .enb_on_reset = 1, | ||
309 | }; | ||
310 | |||
311 | static struct pmx_dev_mode pmx_ssp2_modes[] = { | ||
312 | { | ||
313 | .ids = AUTO_NET_SMII_MODE, | ||
314 | .mask = PMX_MII_MASK, | ||
315 | }, | ||
316 | }; | ||
317 | |||
318 | struct pmx_dev spear320_pmx_ssp2 = { | ||
319 | .name = "ssp2", | ||
320 | .modes = pmx_ssp2_modes, | ||
321 | .mode_count = ARRAY_SIZE(pmx_ssp2_modes), | ||
322 | .enb_on_reset = 1, | ||
323 | }; | ||
324 | |||
325 | static struct pmx_dev_mode pmx_mii1_modes[] = { | ||
326 | { | ||
327 | .ids = AUTO_NET_MII_MODE, | ||
328 | .mask = 0x0, | ||
329 | }, | ||
330 | }; | ||
331 | |||
332 | struct pmx_dev spear320_pmx_mii1 = { | ||
333 | .name = "mii1", | ||
334 | .modes = pmx_mii1_modes, | ||
335 | .mode_count = ARRAY_SIZE(pmx_mii1_modes), | ||
336 | .enb_on_reset = 1, | ||
337 | }; | ||
338 | |||
339 | static struct pmx_dev_mode pmx_smii0_modes[] = { | ||
340 | { | ||
341 | .ids = AUTO_NET_SMII_MODE | AUTO_EXP_MODE | SMALL_PRINTERS_MODE, | ||
342 | .mask = PMX_MII_MASK, | ||
343 | }, | ||
344 | }; | ||
345 | |||
346 | struct pmx_dev spear320_pmx_smii0 = { | ||
347 | .name = "smii0", | ||
348 | .modes = pmx_smii0_modes, | ||
349 | .mode_count = ARRAY_SIZE(pmx_smii0_modes), | ||
350 | .enb_on_reset = 1, | ||
351 | }; | ||
352 | |||
353 | static struct pmx_dev_mode pmx_smii1_modes[] = { | ||
354 | { | ||
355 | .ids = AUTO_NET_SMII_MODE | SMALL_PRINTERS_MODE, | ||
356 | .mask = PMX_MII_MASK, | ||
357 | }, | ||
358 | }; | ||
359 | |||
360 | struct pmx_dev spear320_pmx_smii1 = { | ||
361 | .name = "smii1", | ||
362 | .modes = pmx_smii1_modes, | ||
363 | .mode_count = ARRAY_SIZE(pmx_smii1_modes), | ||
364 | .enb_on_reset = 1, | ||
365 | }; | ||
366 | |||
367 | static struct pmx_dev_mode pmx_i2c1_modes[] = { | ||
368 | { | ||
369 | .ids = AUTO_EXP_MODE, | ||
370 | .mask = 0x0, | ||
371 | }, | ||
372 | }; | ||
373 | |||
374 | struct pmx_dev spear320_pmx_i2c1 = { | ||
375 | .name = "i2c1", | ||
376 | .modes = pmx_i2c1_modes, | ||
377 | .mode_count = ARRAY_SIZE(pmx_i2c1_modes), | ||
378 | .enb_on_reset = 1, | ||
379 | }; | ||
380 | |||
381 | /* pmx driver structure */ | ||
382 | static struct pmx_driver pmx_driver = { | ||
383 | .mode_reg = {.offset = MODE_CONFIG_REG, .mask = 0x00000007}, | ||
384 | .mux_reg = {.offset = PAD_MUX_CONFIG_REG, .mask = 0x00007fff}, | ||
385 | }; | ||
386 | 84 | ||
387 | /* spear3xx shared irq */ | 85 | /* spear3xx shared irq */ |
388 | static struct shirq_dev_config shirq_ras1_config[] = { | 86 | static struct shirq_dev_config shirq_ras1_config[] = { |
@@ -508,17 +206,250 @@ static struct spear_shirq shirq_intrcomm_ras = { | |||
508 | }, | 206 | }, |
509 | }; | 207 | }; |
510 | 208 | ||
511 | /* Add spear320 specific devices here */ | 209 | /* DMAC platform data's slave info */ |
210 | struct pl08x_channel_data spear320_dma_info[] = { | ||
211 | { | ||
212 | .bus_id = "uart0_rx", | ||
213 | .min_signal = 2, | ||
214 | .max_signal = 2, | ||
215 | .muxval = 0, | ||
216 | .cctl = 0, | ||
217 | .periph_buses = PL08X_AHB1, | ||
218 | }, { | ||
219 | .bus_id = "uart0_tx", | ||
220 | .min_signal = 3, | ||
221 | .max_signal = 3, | ||
222 | .muxval = 0, | ||
223 | .cctl = 0, | ||
224 | .periph_buses = PL08X_AHB1, | ||
225 | }, { | ||
226 | .bus_id = "ssp0_rx", | ||
227 | .min_signal = 8, | ||
228 | .max_signal = 8, | ||
229 | .muxval = 0, | ||
230 | .cctl = 0, | ||
231 | .periph_buses = PL08X_AHB1, | ||
232 | }, { | ||
233 | .bus_id = "ssp0_tx", | ||
234 | .min_signal = 9, | ||
235 | .max_signal = 9, | ||
236 | .muxval = 0, | ||
237 | .cctl = 0, | ||
238 | .periph_buses = PL08X_AHB1, | ||
239 | }, { | ||
240 | .bus_id = "i2c0_rx", | ||
241 | .min_signal = 10, | ||
242 | .max_signal = 10, | ||
243 | .muxval = 0, | ||
244 | .cctl = 0, | ||
245 | .periph_buses = PL08X_AHB1, | ||
246 | }, { | ||
247 | .bus_id = "i2c0_tx", | ||
248 | .min_signal = 11, | ||
249 | .max_signal = 11, | ||
250 | .muxval = 0, | ||
251 | .cctl = 0, | ||
252 | .periph_buses = PL08X_AHB1, | ||
253 | }, { | ||
254 | .bus_id = "irda", | ||
255 | .min_signal = 12, | ||
256 | .max_signal = 12, | ||
257 | .muxval = 0, | ||
258 | .cctl = 0, | ||
259 | .periph_buses = PL08X_AHB1, | ||
260 | }, { | ||
261 | .bus_id = "adc", | ||
262 | .min_signal = 13, | ||
263 | .max_signal = 13, | ||
264 | .muxval = 0, | ||
265 | .cctl = 0, | ||
266 | .periph_buses = PL08X_AHB1, | ||
267 | }, { | ||
268 | .bus_id = "to_jpeg", | ||
269 | .min_signal = 14, | ||
270 | .max_signal = 14, | ||
271 | .muxval = 0, | ||
272 | .cctl = 0, | ||
273 | .periph_buses = PL08X_AHB1, | ||
274 | }, { | ||
275 | .bus_id = "from_jpeg", | ||
276 | .min_signal = 15, | ||
277 | .max_signal = 15, | ||
278 | .muxval = 0, | ||
279 | .cctl = 0, | ||
280 | .periph_buses = PL08X_AHB1, | ||
281 | }, { | ||
282 | .bus_id = "ssp1_rx", | ||
283 | .min_signal = 0, | ||
284 | .max_signal = 0, | ||
285 | .muxval = 1, | ||
286 | .cctl = 0, | ||
287 | .periph_buses = PL08X_AHB2, | ||
288 | }, { | ||
289 | .bus_id = "ssp1_tx", | ||
290 | .min_signal = 1, | ||
291 | .max_signal = 1, | ||
292 | .muxval = 1, | ||
293 | .cctl = 0, | ||
294 | .periph_buses = PL08X_AHB2, | ||
295 | }, { | ||
296 | .bus_id = "ssp2_rx", | ||
297 | .min_signal = 2, | ||
298 | .max_signal = 2, | ||
299 | .muxval = 1, | ||
300 | .cctl = 0, | ||
301 | .periph_buses = PL08X_AHB2, | ||
302 | }, { | ||
303 | .bus_id = "ssp2_tx", | ||
304 | .min_signal = 3, | ||
305 | .max_signal = 3, | ||
306 | .muxval = 1, | ||
307 | .cctl = 0, | ||
308 | .periph_buses = PL08X_AHB2, | ||
309 | }, { | ||
310 | .bus_id = "uart1_rx", | ||
311 | .min_signal = 4, | ||
312 | .max_signal = 4, | ||
313 | .muxval = 1, | ||
314 | .cctl = 0, | ||
315 | .periph_buses = PL08X_AHB2, | ||
316 | }, { | ||
317 | .bus_id = "uart1_tx", | ||
318 | .min_signal = 5, | ||
319 | .max_signal = 5, | ||
320 | .muxval = 1, | ||
321 | .cctl = 0, | ||
322 | .periph_buses = PL08X_AHB2, | ||
323 | }, { | ||
324 | .bus_id = "uart2_rx", | ||
325 | .min_signal = 6, | ||
326 | .max_signal = 6, | ||
327 | .muxval = 1, | ||
328 | .cctl = 0, | ||
329 | .periph_buses = PL08X_AHB2, | ||
330 | }, { | ||
331 | .bus_id = "uart2_tx", | ||
332 | .min_signal = 7, | ||
333 | .max_signal = 7, | ||
334 | .muxval = 1, | ||
335 | .cctl = 0, | ||
336 | .periph_buses = PL08X_AHB2, | ||
337 | }, { | ||
338 | .bus_id = "i2c1_rx", | ||
339 | .min_signal = 8, | ||
340 | .max_signal = 8, | ||
341 | .muxval = 1, | ||
342 | .cctl = 0, | ||
343 | .periph_buses = PL08X_AHB2, | ||
344 | }, { | ||
345 | .bus_id = "i2c1_tx", | ||
346 | .min_signal = 9, | ||
347 | .max_signal = 9, | ||
348 | .muxval = 1, | ||
349 | .cctl = 0, | ||
350 | .periph_buses = PL08X_AHB2, | ||
351 | }, { | ||
352 | .bus_id = "i2c2_rx", | ||
353 | .min_signal = 10, | ||
354 | .max_signal = 10, | ||
355 | .muxval = 1, | ||
356 | .cctl = 0, | ||
357 | .periph_buses = PL08X_AHB2, | ||
358 | }, { | ||
359 | .bus_id = "i2c2_tx", | ||
360 | .min_signal = 11, | ||
361 | .max_signal = 11, | ||
362 | .muxval = 1, | ||
363 | .cctl = 0, | ||
364 | .periph_buses = PL08X_AHB2, | ||
365 | }, { | ||
366 | .bus_id = "i2s_rx", | ||
367 | .min_signal = 12, | ||
368 | .max_signal = 12, | ||
369 | .muxval = 1, | ||
370 | .cctl = 0, | ||
371 | .periph_buses = PL08X_AHB2, | ||
372 | }, { | ||
373 | .bus_id = "i2s_tx", | ||
374 | .min_signal = 13, | ||
375 | .max_signal = 13, | ||
376 | .muxval = 1, | ||
377 | .cctl = 0, | ||
378 | .periph_buses = PL08X_AHB2, | ||
379 | }, { | ||
380 | .bus_id = "rs485_rx", | ||
381 | .min_signal = 14, | ||
382 | .max_signal = 14, | ||
383 | .muxval = 1, | ||
384 | .cctl = 0, | ||
385 | .periph_buses = PL08X_AHB2, | ||
386 | }, { | ||
387 | .bus_id = "rs485_tx", | ||
388 | .min_signal = 15, | ||
389 | .max_signal = 15, | ||
390 | .muxval = 1, | ||
391 | .cctl = 0, | ||
392 | .periph_buses = PL08X_AHB2, | ||
393 | }, | ||
394 | }; | ||
395 | |||
396 | static struct pl022_ssp_controller spear320_ssp_data[] = { | ||
397 | { | ||
398 | .bus_id = 1, | ||
399 | .enable_dma = 1, | ||
400 | .dma_filter = pl08x_filter_id, | ||
401 | .dma_tx_param = "ssp1_tx", | ||
402 | .dma_rx_param = "ssp1_rx", | ||
403 | .num_chipselect = 2, | ||
404 | }, { | ||
405 | .bus_id = 2, | ||
406 | .enable_dma = 1, | ||
407 | .dma_filter = pl08x_filter_id, | ||
408 | .dma_tx_param = "ssp2_tx", | ||
409 | .dma_rx_param = "ssp2_rx", | ||
410 | .num_chipselect = 2, | ||
411 | } | ||
412 | }; | ||
413 | |||
414 | static struct amba_pl011_data spear320_uart_data[] = { | ||
415 | { | ||
416 | .dma_filter = pl08x_filter_id, | ||
417 | .dma_tx_param = "uart1_tx", | ||
418 | .dma_rx_param = "uart1_rx", | ||
419 | }, { | ||
420 | .dma_filter = pl08x_filter_id, | ||
421 | .dma_tx_param = "uart2_tx", | ||
422 | .dma_rx_param = "uart2_rx", | ||
423 | }, | ||
424 | }; | ||
512 | 425 | ||
513 | /* spear320 routines */ | 426 | /* Add SPEAr310 auxdata to pass platform data */ |
514 | void __init spear320_init(struct pmx_mode *pmx_mode, struct pmx_dev **pmx_devs, | 427 | static struct of_dev_auxdata spear320_auxdata_lookup[] __initdata = { |
515 | u8 pmx_dev_count) | 428 | OF_DEV_AUXDATA("arm,pl022", SPEAR3XX_ICM1_SSP_BASE, NULL, |
429 | &pl022_plat_data), | ||
430 | OF_DEV_AUXDATA("arm,pl080", SPEAR3XX_ICM3_DMA_BASE, NULL, | ||
431 | &pl080_plat_data), | ||
432 | OF_DEV_AUXDATA("arm,pl022", SPEAR320_SSP0_BASE, NULL, | ||
433 | &spear320_ssp_data[0]), | ||
434 | OF_DEV_AUXDATA("arm,pl022", SPEAR320_SSP1_BASE, NULL, | ||
435 | &spear320_ssp_data[1]), | ||
436 | OF_DEV_AUXDATA("arm,pl011", SPEAR320_UART1_BASE, NULL, | ||
437 | &spear320_uart_data[0]), | ||
438 | OF_DEV_AUXDATA("arm,pl011", SPEAR320_UART2_BASE, NULL, | ||
439 | &spear320_uart_data[1]), | ||
440 | {} | ||
441 | }; | ||
442 | |||
443 | static void __init spear320_dt_init(void) | ||
516 | { | 444 | { |
517 | void __iomem *base; | 445 | void __iomem *base; |
518 | int ret = 0; | 446 | int ret; |
519 | 447 | ||
520 | /* call spear3xx family common init function */ | 448 | pl080_plat_data.slave_channels = spear320_dma_info; |
521 | spear3xx_init(); | 449 | pl080_plat_data.num_slave_channels = ARRAY_SIZE(spear320_dma_info); |
450 | |||
451 | of_platform_populate(NULL, of_default_bus_match_table, | ||
452 | spear320_auxdata_lookup, NULL); | ||
522 | 453 | ||
523 | /* shared irq registration */ | 454 | /* shared irq registration */ |
524 | base = ioremap(SPEAR320_SOC_CONFIG_BASE, SZ_4K); | 455 | base = ioremap(SPEAR320_SOC_CONFIG_BASE, SZ_4K); |
@@ -527,29 +458,49 @@ void __init spear320_init(struct pmx_mode *pmx_mode, struct pmx_dev **pmx_devs, | |||
527 | shirq_ras1.regs.base = base; | 458 | shirq_ras1.regs.base = base; |
528 | ret = spear_shirq_register(&shirq_ras1); | 459 | ret = spear_shirq_register(&shirq_ras1); |
529 | if (ret) | 460 | if (ret) |
530 | printk(KERN_ERR "Error registering Shared IRQ 1\n"); | 461 | pr_err("Error registering Shared IRQ 1\n"); |
531 | 462 | ||
532 | /* shirq 3 */ | 463 | /* shirq 3 */ |
533 | shirq_ras3.regs.base = base; | 464 | shirq_ras3.regs.base = base; |
534 | ret = spear_shirq_register(&shirq_ras3); | 465 | ret = spear_shirq_register(&shirq_ras3); |
535 | if (ret) | 466 | if (ret) |
536 | printk(KERN_ERR "Error registering Shared IRQ 3\n"); | 467 | pr_err("Error registering Shared IRQ 3\n"); |
537 | 468 | ||
538 | /* shirq 4 */ | 469 | /* shirq 4 */ |
539 | shirq_intrcomm_ras.regs.base = base; | 470 | shirq_intrcomm_ras.regs.base = base; |
540 | ret = spear_shirq_register(&shirq_intrcomm_ras); | 471 | ret = spear_shirq_register(&shirq_intrcomm_ras); |
541 | if (ret) | 472 | if (ret) |
542 | printk(KERN_ERR "Error registering Shared IRQ 4\n"); | 473 | pr_err("Error registering Shared IRQ 4\n"); |
543 | } | 474 | } |
475 | } | ||
476 | |||
477 | static const char * const spear320_dt_board_compat[] = { | ||
478 | "st,spear320", | ||
479 | "st,spear320-evb", | ||
480 | NULL, | ||
481 | }; | ||
544 | 482 | ||
545 | /* pmx initialization */ | 483 | struct map_desc spear320_io_desc[] __initdata = { |
546 | pmx_driver.base = base; | 484 | { |
547 | pmx_driver.mode = pmx_mode; | 485 | .virtual = VA_SPEAR320_SOC_CONFIG_BASE, |
548 | pmx_driver.devs = pmx_devs; | 486 | .pfn = __phys_to_pfn(SPEAR320_SOC_CONFIG_BASE), |
549 | pmx_driver.devs_count = pmx_dev_count; | 487 | .length = SZ_16M, |
488 | .type = MT_DEVICE | ||
489 | }, | ||
490 | }; | ||
550 | 491 | ||
551 | ret = pmx_register(&pmx_driver); | 492 | static void __init spear320_map_io(void) |
552 | if (ret) | 493 | { |
553 | printk(KERN_ERR "padmux: registration failed. err no: %d\n", | 494 | iotable_init(spear320_io_desc, ARRAY_SIZE(spear320_io_desc)); |
554 | ret); | 495 | spear3xx_map_io(); |
555 | } | 496 | } |
497 | |||
498 | DT_MACHINE_START(SPEAR320_DT, "ST SPEAr320 SoC with Flattened Device Tree") | ||
499 | .map_io = spear320_map_io, | ||
500 | .init_irq = spear3xx_dt_init_irq, | ||
501 | .handle_irq = vic_handle_irq, | ||
502 | .timer = &spear3xx_timer, | ||
503 | .init_machine = spear320_dt_init, | ||
504 | .restart = spear_restart, | ||
505 | .dt_compat = spear320_dt_board_compat, | ||
506 | MACHINE_END | ||
diff --git a/arch/arm/mach-spear3xx/spear320_evb.c b/arch/arm/mach-spear3xx/spear320_evb.c deleted file mode 100644 index 105334ab7021..000000000000 --- a/arch/arm/mach-spear3xx/spear320_evb.c +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-spear3xx/spear320_evb.c | ||
3 | * | ||
4 | * SPEAr320 evaluation board source file | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #include <asm/hardware/vic.h> | ||
15 | #include <asm/mach/arch.h> | ||
16 | #include <asm/mach-types.h> | ||
17 | #include <mach/generic.h> | ||
18 | #include <mach/hardware.h> | ||
19 | |||
20 | /* padmux devices to enable */ | ||
21 | static struct pmx_dev *pmx_devs[] = { | ||
22 | /* spear3xx specific devices */ | ||
23 | &spear3xx_pmx_i2c, | ||
24 | &spear3xx_pmx_ssp, | ||
25 | &spear3xx_pmx_mii, | ||
26 | &spear3xx_pmx_uart0, | ||
27 | |||
28 | /* spear320 specific devices */ | ||
29 | &spear320_pmx_fsmc, | ||
30 | &spear320_pmx_sdhci, | ||
31 | &spear320_pmx_i2s, | ||
32 | &spear320_pmx_uart1, | ||
33 | &spear320_pmx_uart2, | ||
34 | &spear320_pmx_can, | ||
35 | &spear320_pmx_pwm0, | ||
36 | &spear320_pmx_pwm1, | ||
37 | &spear320_pmx_pwm2, | ||
38 | &spear320_pmx_mii1, | ||
39 | }; | ||
40 | |||
41 | static struct amba_device *amba_devs[] __initdata = { | ||
42 | /* spear3xx specific devices */ | ||
43 | &spear3xx_gpio_device, | ||
44 | &spear3xx_uart_device, | ||
45 | |||
46 | /* spear320 specific devices */ | ||
47 | }; | ||
48 | |||
49 | static struct platform_device *plat_devs[] __initdata = { | ||
50 | /* spear3xx specific devices */ | ||
51 | |||
52 | /* spear320 specific devices */ | ||
53 | }; | ||
54 | |||
55 | static void __init spear320_evb_init(void) | ||
56 | { | ||
57 | unsigned int i; | ||
58 | |||
59 | /* call spear320 machine init function */ | ||
60 | spear320_init(&spear320_auto_net_mii_mode, pmx_devs, | ||
61 | ARRAY_SIZE(pmx_devs)); | ||
62 | |||
63 | /* Add Platform Devices */ | ||
64 | platform_add_devices(plat_devs, ARRAY_SIZE(plat_devs)); | ||
65 | |||
66 | /* Add Amba Devices */ | ||
67 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) | ||
68 | amba_device_register(amba_devs[i], &iomem_resource); | ||
69 | } | ||
70 | |||
71 | MACHINE_START(SPEAR320, "ST-SPEAR320-EVB") | ||
72 | .atag_offset = 0x100, | ||
73 | .map_io = spear3xx_map_io, | ||
74 | .init_irq = spear3xx_init_irq, | ||
75 | .handle_irq = vic_handle_irq, | ||
76 | .timer = &spear3xx_timer, | ||
77 | .init_machine = spear320_evb_init, | ||
78 | .restart = spear_restart, | ||
79 | MACHINE_END | ||
diff --git a/arch/arm/mach-spear3xx/spear3xx.c b/arch/arm/mach-spear3xx/spear3xx.c index b1733c37f209..f22419ed74a8 100644 --- a/arch/arm/mach-spear3xx/spear3xx.c +++ b/arch/arm/mach-spear3xx/spear3xx.c | |||
@@ -3,71 +3,78 @@ | |||
3 | * | 3 | * |
4 | * SPEAr3XX machines common source file | 4 | * SPEAr3XX machines common source file |
5 | * | 5 | * |
6 | * Copyright (C) 2009 ST Microelectronics | 6 | * Copyright (C) 2009-2012 ST Microelectronics |
7 | * Viresh Kumar<viresh.kumar@st.com> | 7 | * Viresh Kumar <viresh.kumar@st.com> |
8 | * | 8 | * |
9 | * This file is licensed under the terms of the GNU General Public | 9 | * This file is licensed under the terms of the GNU General Public |
10 | * License version 2. This program is licensed "as is" without any | 10 | * License version 2. This program is licensed "as is" without any |
11 | * warranty of any kind, whether express or implied. | 11 | * warranty of any kind, whether express or implied. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/types.h> | 14 | #define pr_fmt(fmt) "SPEAr3xx: " fmt |
15 | #include <linux/amba/pl061.h> | 15 | |
16 | #include <linux/ptrace.h> | 16 | #include <linux/amba/pl022.h> |
17 | #include <linux/amba/pl08x.h> | ||
18 | #include <linux/of_irq.h> | ||
17 | #include <linux/io.h> | 19 | #include <linux/io.h> |
20 | #include <asm/hardware/pl080.h> | ||
18 | #include <asm/hardware/vic.h> | 21 | #include <asm/hardware/vic.h> |
19 | #include <asm/irq.h> | 22 | #include <plat/pl080.h> |
20 | #include <asm/mach/arch.h> | ||
21 | #include <mach/generic.h> | 23 | #include <mach/generic.h> |
22 | #include <mach/hardware.h> | 24 | #include <mach/spear.h> |
23 | 25 | ||
24 | /* Add spear3xx machines common devices here */ | 26 | /* ssp device registration */ |
25 | /* gpio device registration */ | 27 | struct pl022_ssp_controller pl022_plat_data = { |
26 | static struct pl061_platform_data gpio_plat_data = { | 28 | .bus_id = 0, |
27 | .gpio_base = 0, | 29 | .enable_dma = 1, |
28 | .irq_base = SPEAR3XX_GPIO_INT_BASE, | 30 | .dma_filter = pl08x_filter_id, |
31 | .dma_tx_param = "ssp0_tx", | ||
32 | .dma_rx_param = "ssp0_rx", | ||
33 | /* | ||
34 | * This is number of spi devices that can be connected to spi. There are | ||
35 | * two type of chipselects on which slave devices can work. One is chip | ||
36 | * select provided by spi masters other is controlled through external | ||
37 | * gpio's. We can't use chipselect provided from spi master (because as | ||
38 | * soon as FIFO becomes empty, CS is disabled and transfer ends). So | ||
39 | * this number now depends on number of gpios available for spi. each | ||
40 | * slave on each master requires a separate gpio pin. | ||
41 | */ | ||
42 | .num_chipselect = 2, | ||
43 | }; | ||
44 | |||
45 | /* dmac device registration */ | ||
46 | struct pl08x_platform_data pl080_plat_data = { | ||
47 | .memcpy_channel = { | ||
48 | .bus_id = "memcpy", | ||
49 | .cctl = (PL080_BSIZE_16 << PL080_CONTROL_SB_SIZE_SHIFT | \ | ||
50 | PL080_BSIZE_16 << PL080_CONTROL_DB_SIZE_SHIFT | \ | ||
51 | PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT | \ | ||
52 | PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT | \ | ||
53 | PL080_CONTROL_PROT_BUFF | PL080_CONTROL_PROT_CACHE | \ | ||
54 | PL080_CONTROL_PROT_SYS), | ||
55 | }, | ||
56 | .lli_buses = PL08X_AHB1, | ||
57 | .mem_buses = PL08X_AHB1, | ||
58 | .get_signal = pl080_get_signal, | ||
59 | .put_signal = pl080_put_signal, | ||
29 | }; | 60 | }; |
30 | 61 | ||
31 | AMBA_APB_DEVICE(spear3xx_gpio, "gpio", 0, SPEAR3XX_ICM3_GPIO_BASE, | 62 | /* |
32 | {SPEAR3XX_IRQ_BASIC_GPIO}, &gpio_plat_data); | 63 | * Following will create 16MB static virtual/physical mappings |
33 | 64 | * PHYSICAL VIRTUAL | |
34 | /* uart device registration */ | 65 | * 0xD0000000 0xFD000000 |
35 | AMBA_APB_DEVICE(spear3xx_uart, "uart", 0, SPEAR3XX_ICM1_UART_BASE, | 66 | * 0xFC000000 0xFC000000 |
36 | {SPEAR3XX_IRQ_UART}, NULL); | 67 | */ |
37 | |||
38 | /* Do spear3xx familiy common initialization part here */ | ||
39 | void __init spear3xx_init(void) | ||
40 | { | ||
41 | /* nothing to do for now */ | ||
42 | } | ||
43 | |||
44 | /* This will initialize vic */ | ||
45 | void __init spear3xx_init_irq(void) | ||
46 | { | ||
47 | vic_init((void __iomem *)VA_SPEAR3XX_ML1_VIC_BASE, 0, ~0, 0); | ||
48 | } | ||
49 | |||
50 | /* Following will create static virtual/physical mappings */ | ||
51 | struct map_desc spear3xx_io_desc[] __initdata = { | 68 | struct map_desc spear3xx_io_desc[] __initdata = { |
52 | { | 69 | { |
53 | .virtual = VA_SPEAR3XX_ICM1_UART_BASE, | 70 | .virtual = VA_SPEAR3XX_ICM1_2_BASE, |
54 | .pfn = __phys_to_pfn(SPEAR3XX_ICM1_UART_BASE), | 71 | .pfn = __phys_to_pfn(SPEAR3XX_ICM1_2_BASE), |
55 | .length = SZ_4K, | 72 | .length = SZ_16M, |
56 | .type = MT_DEVICE | ||
57 | }, { | ||
58 | .virtual = VA_SPEAR3XX_ML1_VIC_BASE, | ||
59 | .pfn = __phys_to_pfn(SPEAR3XX_ML1_VIC_BASE), | ||
60 | .length = SZ_4K, | ||
61 | .type = MT_DEVICE | ||
62 | }, { | ||
63 | .virtual = VA_SPEAR3XX_ICM3_SYS_CTRL_BASE, | ||
64 | .pfn = __phys_to_pfn(SPEAR3XX_ICM3_SYS_CTRL_BASE), | ||
65 | .length = SZ_4K, | ||
66 | .type = MT_DEVICE | 73 | .type = MT_DEVICE |
67 | }, { | 74 | }, { |
68 | .virtual = VA_SPEAR3XX_ICM3_MISC_REG_BASE, | 75 | .virtual = VA_SPEAR3XX_ICM3_SMI_CTRL_BASE, |
69 | .pfn = __phys_to_pfn(SPEAR3XX_ICM3_MISC_REG_BASE), | 76 | .pfn = __phys_to_pfn(SPEAR3XX_ICM3_SMI_CTRL_BASE), |
70 | .length = SZ_4K, | 77 | .length = SZ_16M, |
71 | .type = MT_DEVICE | 78 | .type = MT_DEVICE |
72 | }, | 79 | }, |
73 | }; | 80 | }; |
@@ -76,441 +83,15 @@ struct map_desc spear3xx_io_desc[] __initdata = { | |||
76 | void __init spear3xx_map_io(void) | 83 | void __init spear3xx_map_io(void) |
77 | { | 84 | { |
78 | iotable_init(spear3xx_io_desc, ARRAY_SIZE(spear3xx_io_desc)); | 85 | iotable_init(spear3xx_io_desc, ARRAY_SIZE(spear3xx_io_desc)); |
79 | |||
80 | /* This will initialize clock framework */ | ||
81 | spear3xx_clk_init(); | ||
82 | } | 86 | } |
83 | 87 | ||
84 | /* pad multiplexing support */ | ||
85 | /* devices */ | ||
86 | static struct pmx_dev_mode pmx_firda_modes[] = { | ||
87 | { | ||
88 | .ids = 0xffffffff, | ||
89 | .mask = PMX_FIRDA_MASK, | ||
90 | }, | ||
91 | }; | ||
92 | |||
93 | struct pmx_dev spear3xx_pmx_firda = { | ||
94 | .name = "firda", | ||
95 | .modes = pmx_firda_modes, | ||
96 | .mode_count = ARRAY_SIZE(pmx_firda_modes), | ||
97 | .enb_on_reset = 0, | ||
98 | }; | ||
99 | |||
100 | static struct pmx_dev_mode pmx_i2c_modes[] = { | ||
101 | { | ||
102 | .ids = 0xffffffff, | ||
103 | .mask = PMX_I2C_MASK, | ||
104 | }, | ||
105 | }; | ||
106 | |||
107 | struct pmx_dev spear3xx_pmx_i2c = { | ||
108 | .name = "i2c", | ||
109 | .modes = pmx_i2c_modes, | ||
110 | .mode_count = ARRAY_SIZE(pmx_i2c_modes), | ||
111 | .enb_on_reset = 0, | ||
112 | }; | ||
113 | |||
114 | static struct pmx_dev_mode pmx_ssp_cs_modes[] = { | ||
115 | { | ||
116 | .ids = 0xffffffff, | ||
117 | .mask = PMX_SSP_CS_MASK, | ||
118 | }, | ||
119 | }; | ||
120 | |||
121 | struct pmx_dev spear3xx_pmx_ssp_cs = { | ||
122 | .name = "ssp_chip_selects", | ||
123 | .modes = pmx_ssp_cs_modes, | ||
124 | .mode_count = ARRAY_SIZE(pmx_ssp_cs_modes), | ||
125 | .enb_on_reset = 0, | ||
126 | }; | ||
127 | |||
128 | static struct pmx_dev_mode pmx_ssp_modes[] = { | ||
129 | { | ||
130 | .ids = 0xffffffff, | ||
131 | .mask = PMX_SSP_MASK, | ||
132 | }, | ||
133 | }; | ||
134 | |||
135 | struct pmx_dev spear3xx_pmx_ssp = { | ||
136 | .name = "ssp", | ||
137 | .modes = pmx_ssp_modes, | ||
138 | .mode_count = ARRAY_SIZE(pmx_ssp_modes), | ||
139 | .enb_on_reset = 0, | ||
140 | }; | ||
141 | |||
142 | static struct pmx_dev_mode pmx_mii_modes[] = { | ||
143 | { | ||
144 | .ids = 0xffffffff, | ||
145 | .mask = PMX_MII_MASK, | ||
146 | }, | ||
147 | }; | ||
148 | |||
149 | struct pmx_dev spear3xx_pmx_mii = { | ||
150 | .name = "mii", | ||
151 | .modes = pmx_mii_modes, | ||
152 | .mode_count = ARRAY_SIZE(pmx_mii_modes), | ||
153 | .enb_on_reset = 0, | ||
154 | }; | ||
155 | |||
156 | static struct pmx_dev_mode pmx_gpio_pin0_modes[] = { | ||
157 | { | ||
158 | .ids = 0xffffffff, | ||
159 | .mask = PMX_GPIO_PIN0_MASK, | ||
160 | }, | ||
161 | }; | ||
162 | |||
163 | struct pmx_dev spear3xx_pmx_gpio_pin0 = { | ||
164 | .name = "gpio_pin0", | ||
165 | .modes = pmx_gpio_pin0_modes, | ||
166 | .mode_count = ARRAY_SIZE(pmx_gpio_pin0_modes), | ||
167 | .enb_on_reset = 0, | ||
168 | }; | ||
169 | |||
170 | static struct pmx_dev_mode pmx_gpio_pin1_modes[] = { | ||
171 | { | ||
172 | .ids = 0xffffffff, | ||
173 | .mask = PMX_GPIO_PIN1_MASK, | ||
174 | }, | ||
175 | }; | ||
176 | |||
177 | struct pmx_dev spear3xx_pmx_gpio_pin1 = { | ||
178 | .name = "gpio_pin1", | ||
179 | .modes = pmx_gpio_pin1_modes, | ||
180 | .mode_count = ARRAY_SIZE(pmx_gpio_pin1_modes), | ||
181 | .enb_on_reset = 0, | ||
182 | }; | ||
183 | |||
184 | static struct pmx_dev_mode pmx_gpio_pin2_modes[] = { | ||
185 | { | ||
186 | .ids = 0xffffffff, | ||
187 | .mask = PMX_GPIO_PIN2_MASK, | ||
188 | }, | ||
189 | }; | ||
190 | |||
191 | struct pmx_dev spear3xx_pmx_gpio_pin2 = { | ||
192 | .name = "gpio_pin2", | ||
193 | .modes = pmx_gpio_pin2_modes, | ||
194 | .mode_count = ARRAY_SIZE(pmx_gpio_pin2_modes), | ||
195 | .enb_on_reset = 0, | ||
196 | }; | ||
197 | |||
198 | static struct pmx_dev_mode pmx_gpio_pin3_modes[] = { | ||
199 | { | ||
200 | .ids = 0xffffffff, | ||
201 | .mask = PMX_GPIO_PIN3_MASK, | ||
202 | }, | ||
203 | }; | ||
204 | |||
205 | struct pmx_dev spear3xx_pmx_gpio_pin3 = { | ||
206 | .name = "gpio_pin3", | ||
207 | .modes = pmx_gpio_pin3_modes, | ||
208 | .mode_count = ARRAY_SIZE(pmx_gpio_pin3_modes), | ||
209 | .enb_on_reset = 0, | ||
210 | }; | ||
211 | |||
212 | static struct pmx_dev_mode pmx_gpio_pin4_modes[] = { | ||
213 | { | ||
214 | .ids = 0xffffffff, | ||
215 | .mask = PMX_GPIO_PIN4_MASK, | ||
216 | }, | ||
217 | }; | ||
218 | |||
219 | struct pmx_dev spear3xx_pmx_gpio_pin4 = { | ||
220 | .name = "gpio_pin4", | ||
221 | .modes = pmx_gpio_pin4_modes, | ||
222 | .mode_count = ARRAY_SIZE(pmx_gpio_pin4_modes), | ||
223 | .enb_on_reset = 0, | ||
224 | }; | ||
225 | |||
226 | static struct pmx_dev_mode pmx_gpio_pin5_modes[] = { | ||
227 | { | ||
228 | .ids = 0xffffffff, | ||
229 | .mask = PMX_GPIO_PIN5_MASK, | ||
230 | }, | ||
231 | }; | ||
232 | |||
233 | struct pmx_dev spear3xx_pmx_gpio_pin5 = { | ||
234 | .name = "gpio_pin5", | ||
235 | .modes = pmx_gpio_pin5_modes, | ||
236 | .mode_count = ARRAY_SIZE(pmx_gpio_pin5_modes), | ||
237 | .enb_on_reset = 0, | ||
238 | }; | ||
239 | |||
240 | static struct pmx_dev_mode pmx_uart0_modem_modes[] = { | ||
241 | { | ||
242 | .ids = 0xffffffff, | ||
243 | .mask = PMX_UART0_MODEM_MASK, | ||
244 | }, | ||
245 | }; | ||
246 | |||
247 | struct pmx_dev spear3xx_pmx_uart0_modem = { | ||
248 | .name = "uart0_modem", | ||
249 | .modes = pmx_uart0_modem_modes, | ||
250 | .mode_count = ARRAY_SIZE(pmx_uart0_modem_modes), | ||
251 | .enb_on_reset = 0, | ||
252 | }; | ||
253 | |||
254 | static struct pmx_dev_mode pmx_uart0_modes[] = { | ||
255 | { | ||
256 | .ids = 0xffffffff, | ||
257 | .mask = PMX_UART0_MASK, | ||
258 | }, | ||
259 | }; | ||
260 | |||
261 | struct pmx_dev spear3xx_pmx_uart0 = { | ||
262 | .name = "uart0", | ||
263 | .modes = pmx_uart0_modes, | ||
264 | .mode_count = ARRAY_SIZE(pmx_uart0_modes), | ||
265 | .enb_on_reset = 0, | ||
266 | }; | ||
267 | |||
268 | static struct pmx_dev_mode pmx_timer_3_4_modes[] = { | ||
269 | { | ||
270 | .ids = 0xffffffff, | ||
271 | .mask = PMX_TIMER_3_4_MASK, | ||
272 | }, | ||
273 | }; | ||
274 | |||
275 | struct pmx_dev spear3xx_pmx_timer_3_4 = { | ||
276 | .name = "timer_3_4", | ||
277 | .modes = pmx_timer_3_4_modes, | ||
278 | .mode_count = ARRAY_SIZE(pmx_timer_3_4_modes), | ||
279 | .enb_on_reset = 0, | ||
280 | }; | ||
281 | |||
282 | static struct pmx_dev_mode pmx_timer_1_2_modes[] = { | ||
283 | { | ||
284 | .ids = 0xffffffff, | ||
285 | .mask = PMX_TIMER_1_2_MASK, | ||
286 | }, | ||
287 | }; | ||
288 | |||
289 | struct pmx_dev spear3xx_pmx_timer_1_2 = { | ||
290 | .name = "timer_1_2", | ||
291 | .modes = pmx_timer_1_2_modes, | ||
292 | .mode_count = ARRAY_SIZE(pmx_timer_1_2_modes), | ||
293 | .enb_on_reset = 0, | ||
294 | }; | ||
295 | |||
296 | #if defined(CONFIG_MACH_SPEAR310) || defined(CONFIG_MACH_SPEAR320) | ||
297 | /* plgpios devices */ | ||
298 | static struct pmx_dev_mode pmx_plgpio_0_1_modes[] = { | ||
299 | { | ||
300 | .ids = 0x00, | ||
301 | .mask = PMX_FIRDA_MASK, | ||
302 | }, | ||
303 | }; | ||
304 | |||
305 | struct pmx_dev spear3xx_pmx_plgpio_0_1 = { | ||
306 | .name = "plgpio 0 and 1", | ||
307 | .modes = pmx_plgpio_0_1_modes, | ||
308 | .mode_count = ARRAY_SIZE(pmx_plgpio_0_1_modes), | ||
309 | .enb_on_reset = 1, | ||
310 | }; | ||
311 | |||
312 | static struct pmx_dev_mode pmx_plgpio_2_3_modes[] = { | ||
313 | { | ||
314 | .ids = 0x00, | ||
315 | .mask = PMX_UART0_MASK, | ||
316 | }, | ||
317 | }; | ||
318 | |||
319 | struct pmx_dev spear3xx_pmx_plgpio_2_3 = { | ||
320 | .name = "plgpio 2 and 3", | ||
321 | .modes = pmx_plgpio_2_3_modes, | ||
322 | .mode_count = ARRAY_SIZE(pmx_plgpio_2_3_modes), | ||
323 | .enb_on_reset = 1, | ||
324 | }; | ||
325 | |||
326 | static struct pmx_dev_mode pmx_plgpio_4_5_modes[] = { | ||
327 | { | ||
328 | .ids = 0x00, | ||
329 | .mask = PMX_I2C_MASK, | ||
330 | }, | ||
331 | }; | ||
332 | |||
333 | struct pmx_dev spear3xx_pmx_plgpio_4_5 = { | ||
334 | .name = "plgpio 4 and 5", | ||
335 | .modes = pmx_plgpio_4_5_modes, | ||
336 | .mode_count = ARRAY_SIZE(pmx_plgpio_4_5_modes), | ||
337 | .enb_on_reset = 1, | ||
338 | }; | ||
339 | |||
340 | static struct pmx_dev_mode pmx_plgpio_6_9_modes[] = { | ||
341 | { | ||
342 | .ids = 0x00, | ||
343 | .mask = PMX_SSP_MASK, | ||
344 | }, | ||
345 | }; | ||
346 | |||
347 | struct pmx_dev spear3xx_pmx_plgpio_6_9 = { | ||
348 | .name = "plgpio 6 to 9", | ||
349 | .modes = pmx_plgpio_6_9_modes, | ||
350 | .mode_count = ARRAY_SIZE(pmx_plgpio_6_9_modes), | ||
351 | .enb_on_reset = 1, | ||
352 | }; | ||
353 | |||
354 | static struct pmx_dev_mode pmx_plgpio_10_27_modes[] = { | ||
355 | { | ||
356 | .ids = 0x00, | ||
357 | .mask = PMX_MII_MASK, | ||
358 | }, | ||
359 | }; | ||
360 | |||
361 | struct pmx_dev spear3xx_pmx_plgpio_10_27 = { | ||
362 | .name = "plgpio 10 to 27", | ||
363 | .modes = pmx_plgpio_10_27_modes, | ||
364 | .mode_count = ARRAY_SIZE(pmx_plgpio_10_27_modes), | ||
365 | .enb_on_reset = 1, | ||
366 | }; | ||
367 | |||
368 | static struct pmx_dev_mode pmx_plgpio_28_modes[] = { | ||
369 | { | ||
370 | .ids = 0x00, | ||
371 | .mask = PMX_GPIO_PIN0_MASK, | ||
372 | }, | ||
373 | }; | ||
374 | |||
375 | struct pmx_dev spear3xx_pmx_plgpio_28 = { | ||
376 | .name = "plgpio 28", | ||
377 | .modes = pmx_plgpio_28_modes, | ||
378 | .mode_count = ARRAY_SIZE(pmx_plgpio_28_modes), | ||
379 | .enb_on_reset = 1, | ||
380 | }; | ||
381 | |||
382 | static struct pmx_dev_mode pmx_plgpio_29_modes[] = { | ||
383 | { | ||
384 | .ids = 0x00, | ||
385 | .mask = PMX_GPIO_PIN1_MASK, | ||
386 | }, | ||
387 | }; | ||
388 | |||
389 | struct pmx_dev spear3xx_pmx_plgpio_29 = { | ||
390 | .name = "plgpio 29", | ||
391 | .modes = pmx_plgpio_29_modes, | ||
392 | .mode_count = ARRAY_SIZE(pmx_plgpio_29_modes), | ||
393 | .enb_on_reset = 1, | ||
394 | }; | ||
395 | |||
396 | static struct pmx_dev_mode pmx_plgpio_30_modes[] = { | ||
397 | { | ||
398 | .ids = 0x00, | ||
399 | .mask = PMX_GPIO_PIN2_MASK, | ||
400 | }, | ||
401 | }; | ||
402 | |||
403 | struct pmx_dev spear3xx_pmx_plgpio_30 = { | ||
404 | .name = "plgpio 30", | ||
405 | .modes = pmx_plgpio_30_modes, | ||
406 | .mode_count = ARRAY_SIZE(pmx_plgpio_30_modes), | ||
407 | .enb_on_reset = 1, | ||
408 | }; | ||
409 | |||
410 | static struct pmx_dev_mode pmx_plgpio_31_modes[] = { | ||
411 | { | ||
412 | .ids = 0x00, | ||
413 | .mask = PMX_GPIO_PIN3_MASK, | ||
414 | }, | ||
415 | }; | ||
416 | |||
417 | struct pmx_dev spear3xx_pmx_plgpio_31 = { | ||
418 | .name = "plgpio 31", | ||
419 | .modes = pmx_plgpio_31_modes, | ||
420 | .mode_count = ARRAY_SIZE(pmx_plgpio_31_modes), | ||
421 | .enb_on_reset = 1, | ||
422 | }; | ||
423 | |||
424 | static struct pmx_dev_mode pmx_plgpio_32_modes[] = { | ||
425 | { | ||
426 | .ids = 0x00, | ||
427 | .mask = PMX_GPIO_PIN4_MASK, | ||
428 | }, | ||
429 | }; | ||
430 | |||
431 | struct pmx_dev spear3xx_pmx_plgpio_32 = { | ||
432 | .name = "plgpio 32", | ||
433 | .modes = pmx_plgpio_32_modes, | ||
434 | .mode_count = ARRAY_SIZE(pmx_plgpio_32_modes), | ||
435 | .enb_on_reset = 1, | ||
436 | }; | ||
437 | |||
438 | static struct pmx_dev_mode pmx_plgpio_33_modes[] = { | ||
439 | { | ||
440 | .ids = 0x00, | ||
441 | .mask = PMX_GPIO_PIN5_MASK, | ||
442 | }, | ||
443 | }; | ||
444 | |||
445 | struct pmx_dev spear3xx_pmx_plgpio_33 = { | ||
446 | .name = "plgpio 33", | ||
447 | .modes = pmx_plgpio_33_modes, | ||
448 | .mode_count = ARRAY_SIZE(pmx_plgpio_33_modes), | ||
449 | .enb_on_reset = 1, | ||
450 | }; | ||
451 | |||
452 | static struct pmx_dev_mode pmx_plgpio_34_36_modes[] = { | ||
453 | { | ||
454 | .ids = 0x00, | ||
455 | .mask = PMX_SSP_CS_MASK, | ||
456 | }, | ||
457 | }; | ||
458 | |||
459 | struct pmx_dev spear3xx_pmx_plgpio_34_36 = { | ||
460 | .name = "plgpio 34 to 36", | ||
461 | .modes = pmx_plgpio_34_36_modes, | ||
462 | .mode_count = ARRAY_SIZE(pmx_plgpio_34_36_modes), | ||
463 | .enb_on_reset = 1, | ||
464 | }; | ||
465 | |||
466 | static struct pmx_dev_mode pmx_plgpio_37_42_modes[] = { | ||
467 | { | ||
468 | .ids = 0x00, | ||
469 | .mask = PMX_UART0_MODEM_MASK, | ||
470 | }, | ||
471 | }; | ||
472 | |||
473 | struct pmx_dev spear3xx_pmx_plgpio_37_42 = { | ||
474 | .name = "plgpio 37 to 42", | ||
475 | .modes = pmx_plgpio_37_42_modes, | ||
476 | .mode_count = ARRAY_SIZE(pmx_plgpio_37_42_modes), | ||
477 | .enb_on_reset = 1, | ||
478 | }; | ||
479 | |||
480 | static struct pmx_dev_mode pmx_plgpio_43_44_47_48_modes[] = { | ||
481 | { | ||
482 | .ids = 0x00, | ||
483 | .mask = PMX_TIMER_1_2_MASK, | ||
484 | }, | ||
485 | }; | ||
486 | |||
487 | struct pmx_dev spear3xx_pmx_plgpio_43_44_47_48 = { | ||
488 | .name = "plgpio 43, 44, 47 and 48", | ||
489 | .modes = pmx_plgpio_43_44_47_48_modes, | ||
490 | .mode_count = ARRAY_SIZE(pmx_plgpio_43_44_47_48_modes), | ||
491 | .enb_on_reset = 1, | ||
492 | }; | ||
493 | |||
494 | static struct pmx_dev_mode pmx_plgpio_45_46_49_50_modes[] = { | ||
495 | { | ||
496 | .ids = 0x00, | ||
497 | .mask = PMX_TIMER_3_4_MASK, | ||
498 | }, | ||
499 | }; | ||
500 | |||
501 | struct pmx_dev spear3xx_pmx_plgpio_45_46_49_50 = { | ||
502 | .name = "plgpio 45, 46, 49 and 50", | ||
503 | .modes = pmx_plgpio_45_46_49_50_modes, | ||
504 | .mode_count = ARRAY_SIZE(pmx_plgpio_45_46_49_50_modes), | ||
505 | .enb_on_reset = 1, | ||
506 | }; | ||
507 | #endif /* CONFIG_MACH_SPEAR310 || CONFIG_MACH_SPEAR320 */ | ||
508 | |||
509 | static void __init spear3xx_timer_init(void) | 88 | static void __init spear3xx_timer_init(void) |
510 | { | 89 | { |
511 | char pclk_name[] = "pll3_48m_clk"; | 90 | char pclk_name[] = "pll3_48m_clk"; |
512 | struct clk *gpt_clk, *pclk; | 91 | struct clk *gpt_clk, *pclk; |
513 | 92 | ||
93 | spear3xx_clk_init(); | ||
94 | |||
514 | /* get the system timer clock */ | 95 | /* get the system timer clock */ |
515 | gpt_clk = clk_get_sys("gpt0", NULL); | 96 | gpt_clk = clk_get_sys("gpt0", NULL); |
516 | if (IS_ERR(gpt_clk)) { | 97 | if (IS_ERR(gpt_clk)) { |
@@ -530,9 +111,19 @@ static void __init spear3xx_timer_init(void) | |||
530 | clk_put(gpt_clk); | 111 | clk_put(gpt_clk); |
531 | clk_put(pclk); | 112 | clk_put(pclk); |
532 | 113 | ||
533 | spear_setup_timer(); | 114 | spear_setup_of_timer(); |
534 | } | 115 | } |
535 | 116 | ||
536 | struct sys_timer spear3xx_timer = { | 117 | struct sys_timer spear3xx_timer = { |
537 | .init = spear3xx_timer_init, | 118 | .init = spear3xx_timer_init, |
538 | }; | 119 | }; |
120 | |||
121 | static const struct of_device_id vic_of_match[] __initconst = { | ||
122 | { .compatible = "arm,pl190-vic", .data = vic_of_init, }, | ||
123 | { /* Sentinel */ } | ||
124 | }; | ||
125 | |||
126 | void __init spear3xx_dt_init_irq(void) | ||
127 | { | ||
128 | of_irq_init(vic_of_match); | ||
129 | } | ||
diff --git a/arch/arm/mach-spear6xx/Makefile b/arch/arm/mach-spear6xx/Makefile index 76e5750552fc..898831d93f37 100644 --- a/arch/arm/mach-spear6xx/Makefile +++ b/arch/arm/mach-spear6xx/Makefile | |||
@@ -3,4 +3,4 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | # common files | 5 | # common files |
6 | obj-y += clock.o spear6xx.o | 6 | obj-y += spear6xx.o |
diff --git a/arch/arm/mach-spear6xx/Makefile.boot b/arch/arm/mach-spear6xx/Makefile.boot index 4674a4c221db..af493da37ab6 100644 --- a/arch/arm/mach-spear6xx/Makefile.boot +++ b/arch/arm/mach-spear6xx/Makefile.boot | |||
@@ -1,3 +1,5 @@ | |||
1 | zreladdr-y += 0x00008000 | 1 | zreladdr-y += 0x00008000 |
2 | params_phys-y := 0x00000100 | 2 | params_phys-y := 0x00000100 |
3 | initrd_phys-y := 0x00800000 | 3 | initrd_phys-y := 0x00800000 |
4 | |||
5 | dtb-$(CONFIG_BOARD_SPEAR600_DT) += spear600-evb.dtb | ||
diff --git a/arch/arm/mach-spear6xx/clock.c b/arch/arm/mach-spear6xx/clock.c deleted file mode 100644 index a86499a8a15f..000000000000 --- a/arch/arm/mach-spear6xx/clock.c +++ /dev/null | |||
@@ -1,683 +0,0 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-spear6xx/clock.c | ||
3 | * | ||
4 | * SPEAr6xx machines clock framework source file | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #include <linux/init.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <plat/clock.h> | ||
18 | #include <mach/misc_regs.h> | ||
19 | |||
20 | /* root clks */ | ||
21 | /* 32 KHz oscillator clock */ | ||
22 | static struct clk osc_32k_clk = { | ||
23 | .flags = ALWAYS_ENABLED, | ||
24 | .rate = 32000, | ||
25 | }; | ||
26 | |||
27 | /* 30 MHz oscillator clock */ | ||
28 | static struct clk osc_30m_clk = { | ||
29 | .flags = ALWAYS_ENABLED, | ||
30 | .rate = 30000000, | ||
31 | }; | ||
32 | |||
33 | /* clock derived from 32 KHz osc clk */ | ||
34 | /* rtc clock */ | ||
35 | static struct clk rtc_clk = { | ||
36 | .pclk = &osc_32k_clk, | ||
37 | .en_reg = PERIP1_CLK_ENB, | ||
38 | .en_reg_bit = RTC_CLK_ENB, | ||
39 | .recalc = &follow_parent, | ||
40 | }; | ||
41 | |||
42 | /* clock derived from 30 MHz osc clk */ | ||
43 | /* pll masks structure */ | ||
44 | static struct pll_clk_masks pll1_masks = { | ||
45 | .mode_mask = PLL_MODE_MASK, | ||
46 | .mode_shift = PLL_MODE_SHIFT, | ||
47 | .norm_fdbk_m_mask = PLL_NORM_FDBK_M_MASK, | ||
48 | .norm_fdbk_m_shift = PLL_NORM_FDBK_M_SHIFT, | ||
49 | .dith_fdbk_m_mask = PLL_DITH_FDBK_M_MASK, | ||
50 | .dith_fdbk_m_shift = PLL_DITH_FDBK_M_SHIFT, | ||
51 | .div_p_mask = PLL_DIV_P_MASK, | ||
52 | .div_p_shift = PLL_DIV_P_SHIFT, | ||
53 | .div_n_mask = PLL_DIV_N_MASK, | ||
54 | .div_n_shift = PLL_DIV_N_SHIFT, | ||
55 | }; | ||
56 | |||
57 | /* pll1 configuration structure */ | ||
58 | static struct pll_clk_config pll1_config = { | ||
59 | .mode_reg = PLL1_CTR, | ||
60 | .cfg_reg = PLL1_FRQ, | ||
61 | .masks = &pll1_masks, | ||
62 | }; | ||
63 | |||
64 | /* pll rate configuration table, in ascending order of rates */ | ||
65 | struct pll_rate_tbl pll_rtbl[] = { | ||
66 | {.mode = 0, .m = 0x85, .n = 0x0C, .p = 0x1}, /* 266 MHz */ | ||
67 | {.mode = 0, .m = 0xA6, .n = 0x0C, .p = 0x1}, /* 332 MHz */ | ||
68 | }; | ||
69 | |||
70 | /* PLL1 clock */ | ||
71 | static struct clk pll1_clk = { | ||
72 | .flags = ENABLED_ON_INIT, | ||
73 | .pclk = &osc_30m_clk, | ||
74 | .en_reg = PLL1_CTR, | ||
75 | .en_reg_bit = PLL_ENABLE, | ||
76 | .calc_rate = &pll_calc_rate, | ||
77 | .recalc = &pll_clk_recalc, | ||
78 | .set_rate = &pll_clk_set_rate, | ||
79 | .rate_config = {pll_rtbl, ARRAY_SIZE(pll_rtbl), 1}, | ||
80 | .private_data = &pll1_config, | ||
81 | }; | ||
82 | |||
83 | /* PLL3 48 MHz clock */ | ||
84 | static struct clk pll3_48m_clk = { | ||
85 | .flags = ALWAYS_ENABLED, | ||
86 | .pclk = &osc_30m_clk, | ||
87 | .rate = 48000000, | ||
88 | }; | ||
89 | |||
90 | /* watch dog timer clock */ | ||
91 | static struct clk wdt_clk = { | ||
92 | .flags = ALWAYS_ENABLED, | ||
93 | .pclk = &osc_30m_clk, | ||
94 | .recalc = &follow_parent, | ||
95 | }; | ||
96 | |||
97 | /* clock derived from pll1 clk */ | ||
98 | /* cpu clock */ | ||
99 | static struct clk cpu_clk = { | ||
100 | .flags = ALWAYS_ENABLED, | ||
101 | .pclk = &pll1_clk, | ||
102 | .recalc = &follow_parent, | ||
103 | }; | ||
104 | |||
105 | /* ahb masks structure */ | ||
106 | static struct bus_clk_masks ahb_masks = { | ||
107 | .mask = PLL_HCLK_RATIO_MASK, | ||
108 | .shift = PLL_HCLK_RATIO_SHIFT, | ||
109 | }; | ||
110 | |||
111 | /* ahb configuration structure */ | ||
112 | static struct bus_clk_config ahb_config = { | ||
113 | .reg = CORE_CLK_CFG, | ||
114 | .masks = &ahb_masks, | ||
115 | }; | ||
116 | |||
117 | /* ahb rate configuration table, in ascending order of rates */ | ||
118 | struct bus_rate_tbl bus_rtbl[] = { | ||
119 | {.div = 3}, /* == parent divided by 4 */ | ||
120 | {.div = 2}, /* == parent divided by 3 */ | ||
121 | {.div = 1}, /* == parent divided by 2 */ | ||
122 | {.div = 0}, /* == parent divided by 1 */ | ||
123 | }; | ||
124 | |||
125 | /* ahb clock */ | ||
126 | static struct clk ahb_clk = { | ||
127 | .flags = ALWAYS_ENABLED, | ||
128 | .pclk = &pll1_clk, | ||
129 | .calc_rate = &bus_calc_rate, | ||
130 | .recalc = &bus_clk_recalc, | ||
131 | .set_rate = &bus_clk_set_rate, | ||
132 | .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2}, | ||
133 | .private_data = &ahb_config, | ||
134 | }; | ||
135 | |||
136 | /* auxiliary synthesizers masks */ | ||
137 | static struct aux_clk_masks aux_masks = { | ||
138 | .eq_sel_mask = AUX_EQ_SEL_MASK, | ||
139 | .eq_sel_shift = AUX_EQ_SEL_SHIFT, | ||
140 | .eq1_mask = AUX_EQ1_SEL, | ||
141 | .eq2_mask = AUX_EQ2_SEL, | ||
142 | .xscale_sel_mask = AUX_XSCALE_MASK, | ||
143 | .xscale_sel_shift = AUX_XSCALE_SHIFT, | ||
144 | .yscale_sel_mask = AUX_YSCALE_MASK, | ||
145 | .yscale_sel_shift = AUX_YSCALE_SHIFT, | ||
146 | }; | ||
147 | |||
148 | /* uart configurations */ | ||
149 | static struct aux_clk_config uart_synth_config = { | ||
150 | .synth_reg = UART_CLK_SYNT, | ||
151 | .masks = &aux_masks, | ||
152 | }; | ||
153 | |||
154 | /* aux rate configuration table, in ascending order of rates */ | ||
155 | struct aux_rate_tbl aux_rtbl[] = { | ||
156 | /* For PLL1 = 332 MHz */ | ||
157 | {.xscale = 1, .yscale = 8, .eq = 1}, /* 41.5 MHz */ | ||
158 | {.xscale = 1, .yscale = 4, .eq = 1}, /* 83 MHz */ | ||
159 | {.xscale = 1, .yscale = 2, .eq = 1}, /* 166 MHz */ | ||
160 | }; | ||
161 | |||
162 | /* uart synth clock */ | ||
163 | static struct clk uart_synth_clk = { | ||
164 | .en_reg = UART_CLK_SYNT, | ||
165 | .en_reg_bit = AUX_SYNT_ENB, | ||
166 | .pclk = &pll1_clk, | ||
167 | .calc_rate = &aux_calc_rate, | ||
168 | .recalc = &aux_clk_recalc, | ||
169 | .set_rate = &aux_clk_set_rate, | ||
170 | .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 2}, | ||
171 | .private_data = &uart_synth_config, | ||
172 | }; | ||
173 | |||
174 | /* uart parents */ | ||
175 | static struct pclk_info uart_pclk_info[] = { | ||
176 | { | ||
177 | .pclk = &uart_synth_clk, | ||
178 | .pclk_val = AUX_CLK_PLL1_VAL, | ||
179 | }, { | ||
180 | .pclk = &pll3_48m_clk, | ||
181 | .pclk_val = AUX_CLK_PLL3_VAL, | ||
182 | }, | ||
183 | }; | ||
184 | |||
185 | /* uart parent select structure */ | ||
186 | static struct pclk_sel uart_pclk_sel = { | ||
187 | .pclk_info = uart_pclk_info, | ||
188 | .pclk_count = ARRAY_SIZE(uart_pclk_info), | ||
189 | .pclk_sel_reg = PERIP_CLK_CFG, | ||
190 | .pclk_sel_mask = UART_CLK_MASK, | ||
191 | }; | ||
192 | |||
193 | /* uart0 clock */ | ||
194 | static struct clk uart0_clk = { | ||
195 | .en_reg = PERIP1_CLK_ENB, | ||
196 | .en_reg_bit = UART0_CLK_ENB, | ||
197 | .pclk_sel = &uart_pclk_sel, | ||
198 | .pclk_sel_shift = UART_CLK_SHIFT, | ||
199 | .recalc = &follow_parent, | ||
200 | }; | ||
201 | |||
202 | /* uart1 clock */ | ||
203 | static struct clk uart1_clk = { | ||
204 | .en_reg = PERIP1_CLK_ENB, | ||
205 | .en_reg_bit = UART1_CLK_ENB, | ||
206 | .pclk_sel = &uart_pclk_sel, | ||
207 | .pclk_sel_shift = UART_CLK_SHIFT, | ||
208 | .recalc = &follow_parent, | ||
209 | }; | ||
210 | |||
211 | /* firda configurations */ | ||
212 | static struct aux_clk_config firda_synth_config = { | ||
213 | .synth_reg = FIRDA_CLK_SYNT, | ||
214 | .masks = &aux_masks, | ||
215 | }; | ||
216 | |||
217 | /* firda synth clock */ | ||
218 | static struct clk firda_synth_clk = { | ||
219 | .en_reg = FIRDA_CLK_SYNT, | ||
220 | .en_reg_bit = AUX_SYNT_ENB, | ||
221 | .pclk = &pll1_clk, | ||
222 | .calc_rate = &aux_calc_rate, | ||
223 | .recalc = &aux_clk_recalc, | ||
224 | .set_rate = &aux_clk_set_rate, | ||
225 | .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 2}, | ||
226 | .private_data = &firda_synth_config, | ||
227 | }; | ||
228 | |||
229 | /* firda parents */ | ||
230 | static struct pclk_info firda_pclk_info[] = { | ||
231 | { | ||
232 | .pclk = &firda_synth_clk, | ||
233 | .pclk_val = AUX_CLK_PLL1_VAL, | ||
234 | }, { | ||
235 | .pclk = &pll3_48m_clk, | ||
236 | .pclk_val = AUX_CLK_PLL3_VAL, | ||
237 | }, | ||
238 | }; | ||
239 | |||
240 | /* firda parent select structure */ | ||
241 | static struct pclk_sel firda_pclk_sel = { | ||
242 | .pclk_info = firda_pclk_info, | ||
243 | .pclk_count = ARRAY_SIZE(firda_pclk_info), | ||
244 | .pclk_sel_reg = PERIP_CLK_CFG, | ||
245 | .pclk_sel_mask = FIRDA_CLK_MASK, | ||
246 | }; | ||
247 | |||
248 | /* firda clock */ | ||
249 | static struct clk firda_clk = { | ||
250 | .en_reg = PERIP1_CLK_ENB, | ||
251 | .en_reg_bit = FIRDA_CLK_ENB, | ||
252 | .pclk_sel = &firda_pclk_sel, | ||
253 | .pclk_sel_shift = FIRDA_CLK_SHIFT, | ||
254 | .recalc = &follow_parent, | ||
255 | }; | ||
256 | |||
257 | /* clcd configurations */ | ||
258 | static struct aux_clk_config clcd_synth_config = { | ||
259 | .synth_reg = CLCD_CLK_SYNT, | ||
260 | .masks = &aux_masks, | ||
261 | }; | ||
262 | |||
263 | /* firda synth clock */ | ||
264 | static struct clk clcd_synth_clk = { | ||
265 | .en_reg = CLCD_CLK_SYNT, | ||
266 | .en_reg_bit = AUX_SYNT_ENB, | ||
267 | .pclk = &pll1_clk, | ||
268 | .calc_rate = &aux_calc_rate, | ||
269 | .recalc = &aux_clk_recalc, | ||
270 | .set_rate = &aux_clk_set_rate, | ||
271 | .rate_config = {aux_rtbl, ARRAY_SIZE(aux_rtbl), 2}, | ||
272 | .private_data = &clcd_synth_config, | ||
273 | }; | ||
274 | |||
275 | /* clcd parents */ | ||
276 | static struct pclk_info clcd_pclk_info[] = { | ||
277 | { | ||
278 | .pclk = &clcd_synth_clk, | ||
279 | .pclk_val = AUX_CLK_PLL1_VAL, | ||
280 | }, { | ||
281 | .pclk = &pll3_48m_clk, | ||
282 | .pclk_val = AUX_CLK_PLL3_VAL, | ||
283 | }, | ||
284 | }; | ||
285 | |||
286 | /* clcd parent select structure */ | ||
287 | static struct pclk_sel clcd_pclk_sel = { | ||
288 | .pclk_info = clcd_pclk_info, | ||
289 | .pclk_count = ARRAY_SIZE(clcd_pclk_info), | ||
290 | .pclk_sel_reg = PERIP_CLK_CFG, | ||
291 | .pclk_sel_mask = CLCD_CLK_MASK, | ||
292 | }; | ||
293 | |||
294 | /* clcd clock */ | ||
295 | static struct clk clcd_clk = { | ||
296 | .en_reg = PERIP1_CLK_ENB, | ||
297 | .en_reg_bit = CLCD_CLK_ENB, | ||
298 | .pclk_sel = &clcd_pclk_sel, | ||
299 | .pclk_sel_shift = CLCD_CLK_SHIFT, | ||
300 | .recalc = &follow_parent, | ||
301 | }; | ||
302 | |||
303 | /* gpt synthesizer masks */ | ||
304 | static struct gpt_clk_masks gpt_masks = { | ||
305 | .mscale_sel_mask = GPT_MSCALE_MASK, | ||
306 | .mscale_sel_shift = GPT_MSCALE_SHIFT, | ||
307 | .nscale_sel_mask = GPT_NSCALE_MASK, | ||
308 | .nscale_sel_shift = GPT_NSCALE_SHIFT, | ||
309 | }; | ||
310 | |||
311 | /* gpt rate configuration table, in ascending order of rates */ | ||
312 | struct gpt_rate_tbl gpt_rtbl[] = { | ||
313 | /* For pll1 = 332 MHz */ | ||
314 | {.mscale = 4, .nscale = 0}, /* 41.5 MHz */ | ||
315 | {.mscale = 2, .nscale = 0}, /* 55.3 MHz */ | ||
316 | {.mscale = 1, .nscale = 0}, /* 83 MHz */ | ||
317 | }; | ||
318 | |||
319 | /* gpt0 synth clk config*/ | ||
320 | static struct gpt_clk_config gpt0_synth_config = { | ||
321 | .synth_reg = PRSC1_CLK_CFG, | ||
322 | .masks = &gpt_masks, | ||
323 | }; | ||
324 | |||
325 | /* gpt synth clock */ | ||
326 | static struct clk gpt0_synth_clk = { | ||
327 | .flags = ALWAYS_ENABLED, | ||
328 | .pclk = &pll1_clk, | ||
329 | .calc_rate = &gpt_calc_rate, | ||
330 | .recalc = &gpt_clk_recalc, | ||
331 | .set_rate = &gpt_clk_set_rate, | ||
332 | .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2}, | ||
333 | .private_data = &gpt0_synth_config, | ||
334 | }; | ||
335 | |||
336 | /* gpt parents */ | ||
337 | static struct pclk_info gpt0_pclk_info[] = { | ||
338 | { | ||
339 | .pclk = &gpt0_synth_clk, | ||
340 | .pclk_val = AUX_CLK_PLL1_VAL, | ||
341 | }, { | ||
342 | .pclk = &pll3_48m_clk, | ||
343 | .pclk_val = AUX_CLK_PLL3_VAL, | ||
344 | }, | ||
345 | }; | ||
346 | |||
347 | /* gpt parent select structure */ | ||
348 | static struct pclk_sel gpt0_pclk_sel = { | ||
349 | .pclk_info = gpt0_pclk_info, | ||
350 | .pclk_count = ARRAY_SIZE(gpt0_pclk_info), | ||
351 | .pclk_sel_reg = PERIP_CLK_CFG, | ||
352 | .pclk_sel_mask = GPT_CLK_MASK, | ||
353 | }; | ||
354 | |||
355 | /* gpt0 ARM1 subsystem timer clock */ | ||
356 | static struct clk gpt0_clk = { | ||
357 | .flags = ALWAYS_ENABLED, | ||
358 | .pclk_sel = &gpt0_pclk_sel, | ||
359 | .pclk_sel_shift = GPT0_CLK_SHIFT, | ||
360 | .recalc = &follow_parent, | ||
361 | }; | ||
362 | |||
363 | |||
364 | /* Note: gpt0 and gpt1 share same parent clocks */ | ||
365 | /* gpt parent select structure */ | ||
366 | static struct pclk_sel gpt1_pclk_sel = { | ||
367 | .pclk_info = gpt0_pclk_info, | ||
368 | .pclk_count = ARRAY_SIZE(gpt0_pclk_info), | ||
369 | .pclk_sel_reg = PERIP_CLK_CFG, | ||
370 | .pclk_sel_mask = GPT_CLK_MASK, | ||
371 | }; | ||
372 | |||
373 | /* gpt1 timer clock */ | ||
374 | static struct clk gpt1_clk = { | ||
375 | .flags = ALWAYS_ENABLED, | ||
376 | .pclk_sel = &gpt1_pclk_sel, | ||
377 | .pclk_sel_shift = GPT1_CLK_SHIFT, | ||
378 | .recalc = &follow_parent, | ||
379 | }; | ||
380 | |||
381 | /* gpt2 synth clk config*/ | ||
382 | static struct gpt_clk_config gpt2_synth_config = { | ||
383 | .synth_reg = PRSC2_CLK_CFG, | ||
384 | .masks = &gpt_masks, | ||
385 | }; | ||
386 | |||
387 | /* gpt synth clock */ | ||
388 | static struct clk gpt2_synth_clk = { | ||
389 | .flags = ALWAYS_ENABLED, | ||
390 | .pclk = &pll1_clk, | ||
391 | .calc_rate = &gpt_calc_rate, | ||
392 | .recalc = &gpt_clk_recalc, | ||
393 | .set_rate = &gpt_clk_set_rate, | ||
394 | .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2}, | ||
395 | .private_data = &gpt2_synth_config, | ||
396 | }; | ||
397 | |||
398 | /* gpt parents */ | ||
399 | static struct pclk_info gpt2_pclk_info[] = { | ||
400 | { | ||
401 | .pclk = &gpt2_synth_clk, | ||
402 | .pclk_val = AUX_CLK_PLL1_VAL, | ||
403 | }, { | ||
404 | .pclk = &pll3_48m_clk, | ||
405 | .pclk_val = AUX_CLK_PLL3_VAL, | ||
406 | }, | ||
407 | }; | ||
408 | |||
409 | /* gpt parent select structure */ | ||
410 | static struct pclk_sel gpt2_pclk_sel = { | ||
411 | .pclk_info = gpt2_pclk_info, | ||
412 | .pclk_count = ARRAY_SIZE(gpt2_pclk_info), | ||
413 | .pclk_sel_reg = PERIP_CLK_CFG, | ||
414 | .pclk_sel_mask = GPT_CLK_MASK, | ||
415 | }; | ||
416 | |||
417 | /* gpt2 timer clock */ | ||
418 | static struct clk gpt2_clk = { | ||
419 | .flags = ALWAYS_ENABLED, | ||
420 | .pclk_sel = &gpt2_pclk_sel, | ||
421 | .pclk_sel_shift = GPT2_CLK_SHIFT, | ||
422 | .recalc = &follow_parent, | ||
423 | }; | ||
424 | |||
425 | /* gpt3 synth clk config*/ | ||
426 | static struct gpt_clk_config gpt3_synth_config = { | ||
427 | .synth_reg = PRSC3_CLK_CFG, | ||
428 | .masks = &gpt_masks, | ||
429 | }; | ||
430 | |||
431 | /* gpt synth clock */ | ||
432 | static struct clk gpt3_synth_clk = { | ||
433 | .flags = ALWAYS_ENABLED, | ||
434 | .pclk = &pll1_clk, | ||
435 | .calc_rate = &gpt_calc_rate, | ||
436 | .recalc = &gpt_clk_recalc, | ||
437 | .set_rate = &gpt_clk_set_rate, | ||
438 | .rate_config = {gpt_rtbl, ARRAY_SIZE(gpt_rtbl), 2}, | ||
439 | .private_data = &gpt3_synth_config, | ||
440 | }; | ||
441 | |||
442 | /* gpt parents */ | ||
443 | static struct pclk_info gpt3_pclk_info[] = { | ||
444 | { | ||
445 | .pclk = &gpt3_synth_clk, | ||
446 | .pclk_val = AUX_CLK_PLL1_VAL, | ||
447 | }, { | ||
448 | .pclk = &pll3_48m_clk, | ||
449 | .pclk_val = AUX_CLK_PLL3_VAL, | ||
450 | }, | ||
451 | }; | ||
452 | |||
453 | /* gpt parent select structure */ | ||
454 | static struct pclk_sel gpt3_pclk_sel = { | ||
455 | .pclk_info = gpt3_pclk_info, | ||
456 | .pclk_count = ARRAY_SIZE(gpt3_pclk_info), | ||
457 | .pclk_sel_reg = PERIP_CLK_CFG, | ||
458 | .pclk_sel_mask = GPT_CLK_MASK, | ||
459 | }; | ||
460 | |||
461 | /* gpt3 timer clock */ | ||
462 | static struct clk gpt3_clk = { | ||
463 | .flags = ALWAYS_ENABLED, | ||
464 | .pclk_sel = &gpt3_pclk_sel, | ||
465 | .pclk_sel_shift = GPT3_CLK_SHIFT, | ||
466 | .recalc = &follow_parent, | ||
467 | }; | ||
468 | |||
469 | /* clock derived from pll3 clk */ | ||
470 | /* usbh0 clock */ | ||
471 | static struct clk usbh0_clk = { | ||
472 | .pclk = &pll3_48m_clk, | ||
473 | .en_reg = PERIP1_CLK_ENB, | ||
474 | .en_reg_bit = USBH0_CLK_ENB, | ||
475 | .recalc = &follow_parent, | ||
476 | }; | ||
477 | |||
478 | /* usbh1 clock */ | ||
479 | static struct clk usbh1_clk = { | ||
480 | .pclk = &pll3_48m_clk, | ||
481 | .en_reg = PERIP1_CLK_ENB, | ||
482 | .en_reg_bit = USBH1_CLK_ENB, | ||
483 | .recalc = &follow_parent, | ||
484 | }; | ||
485 | |||
486 | /* usbd clock */ | ||
487 | static struct clk usbd_clk = { | ||
488 | .pclk = &pll3_48m_clk, | ||
489 | .en_reg = PERIP1_CLK_ENB, | ||
490 | .en_reg_bit = USBD_CLK_ENB, | ||
491 | .recalc = &follow_parent, | ||
492 | }; | ||
493 | |||
494 | /* clock derived from ahb clk */ | ||
495 | /* apb masks structure */ | ||
496 | static struct bus_clk_masks apb_masks = { | ||
497 | .mask = HCLK_PCLK_RATIO_MASK, | ||
498 | .shift = HCLK_PCLK_RATIO_SHIFT, | ||
499 | }; | ||
500 | |||
501 | /* apb configuration structure */ | ||
502 | static struct bus_clk_config apb_config = { | ||
503 | .reg = CORE_CLK_CFG, | ||
504 | .masks = &apb_masks, | ||
505 | }; | ||
506 | |||
507 | /* apb clock */ | ||
508 | static struct clk apb_clk = { | ||
509 | .flags = ALWAYS_ENABLED, | ||
510 | .pclk = &ahb_clk, | ||
511 | .calc_rate = &bus_calc_rate, | ||
512 | .recalc = &bus_clk_recalc, | ||
513 | .set_rate = &bus_clk_set_rate, | ||
514 | .rate_config = {bus_rtbl, ARRAY_SIZE(bus_rtbl), 2}, | ||
515 | .private_data = &apb_config, | ||
516 | }; | ||
517 | |||
518 | /* i2c clock */ | ||
519 | static struct clk i2c_clk = { | ||
520 | .pclk = &ahb_clk, | ||
521 | .en_reg = PERIP1_CLK_ENB, | ||
522 | .en_reg_bit = I2C_CLK_ENB, | ||
523 | .recalc = &follow_parent, | ||
524 | }; | ||
525 | |||
526 | /* dma clock */ | ||
527 | static struct clk dma_clk = { | ||
528 | .pclk = &ahb_clk, | ||
529 | .en_reg = PERIP1_CLK_ENB, | ||
530 | .en_reg_bit = DMA_CLK_ENB, | ||
531 | .recalc = &follow_parent, | ||
532 | }; | ||
533 | |||
534 | /* jpeg clock */ | ||
535 | static struct clk jpeg_clk = { | ||
536 | .pclk = &ahb_clk, | ||
537 | .en_reg = PERIP1_CLK_ENB, | ||
538 | .en_reg_bit = JPEG_CLK_ENB, | ||
539 | .recalc = &follow_parent, | ||
540 | }; | ||
541 | |||
542 | /* gmac clock */ | ||
543 | static struct clk gmac_clk = { | ||
544 | .pclk = &ahb_clk, | ||
545 | .en_reg = PERIP1_CLK_ENB, | ||
546 | .en_reg_bit = GMAC_CLK_ENB, | ||
547 | .recalc = &follow_parent, | ||
548 | }; | ||
549 | |||
550 | /* smi clock */ | ||
551 | static struct clk smi_clk = { | ||
552 | .pclk = &ahb_clk, | ||
553 | .en_reg = PERIP1_CLK_ENB, | ||
554 | .en_reg_bit = SMI_CLK_ENB, | ||
555 | .recalc = &follow_parent, | ||
556 | }; | ||
557 | |||
558 | /* fsmc clock */ | ||
559 | static struct clk fsmc_clk = { | ||
560 | .pclk = &ahb_clk, | ||
561 | .en_reg = PERIP1_CLK_ENB, | ||
562 | .en_reg_bit = FSMC_CLK_ENB, | ||
563 | .recalc = &follow_parent, | ||
564 | }; | ||
565 | |||
566 | /* clock derived from apb clk */ | ||
567 | /* adc clock */ | ||
568 | static struct clk adc_clk = { | ||
569 | .pclk = &apb_clk, | ||
570 | .en_reg = PERIP1_CLK_ENB, | ||
571 | .en_reg_bit = ADC_CLK_ENB, | ||
572 | .recalc = &follow_parent, | ||
573 | }; | ||
574 | |||
575 | /* ssp0 clock */ | ||
576 | static struct clk ssp0_clk = { | ||
577 | .pclk = &apb_clk, | ||
578 | .en_reg = PERIP1_CLK_ENB, | ||
579 | .en_reg_bit = SSP0_CLK_ENB, | ||
580 | .recalc = &follow_parent, | ||
581 | }; | ||
582 | |||
583 | /* ssp1 clock */ | ||
584 | static struct clk ssp1_clk = { | ||
585 | .pclk = &apb_clk, | ||
586 | .en_reg = PERIP1_CLK_ENB, | ||
587 | .en_reg_bit = SSP1_CLK_ENB, | ||
588 | .recalc = &follow_parent, | ||
589 | }; | ||
590 | |||
591 | /* ssp2 clock */ | ||
592 | static struct clk ssp2_clk = { | ||
593 | .pclk = &apb_clk, | ||
594 | .en_reg = PERIP1_CLK_ENB, | ||
595 | .en_reg_bit = SSP2_CLK_ENB, | ||
596 | .recalc = &follow_parent, | ||
597 | }; | ||
598 | |||
599 | /* gpio0 ARM subsystem clock */ | ||
600 | static struct clk gpio0_clk = { | ||
601 | .flags = ALWAYS_ENABLED, | ||
602 | .pclk = &apb_clk, | ||
603 | .recalc = &follow_parent, | ||
604 | }; | ||
605 | |||
606 | /* gpio1 clock */ | ||
607 | static struct clk gpio1_clk = { | ||
608 | .pclk = &apb_clk, | ||
609 | .en_reg = PERIP1_CLK_ENB, | ||
610 | .en_reg_bit = GPIO1_CLK_ENB, | ||
611 | .recalc = &follow_parent, | ||
612 | }; | ||
613 | |||
614 | /* gpio2 clock */ | ||
615 | static struct clk gpio2_clk = { | ||
616 | .pclk = &apb_clk, | ||
617 | .en_reg = PERIP1_CLK_ENB, | ||
618 | .en_reg_bit = GPIO2_CLK_ENB, | ||
619 | .recalc = &follow_parent, | ||
620 | }; | ||
621 | |||
622 | static struct clk dummy_apb_pclk; | ||
623 | |||
624 | /* array of all spear 6xx clock lookups */ | ||
625 | static struct clk_lookup spear_clk_lookups[] = { | ||
626 | { .con_id = "apb_pclk", .clk = &dummy_apb_pclk}, | ||
627 | /* root clks */ | ||
628 | { .con_id = "osc_32k_clk", .clk = &osc_32k_clk}, | ||
629 | { .con_id = "osc_30m_clk", .clk = &osc_30m_clk}, | ||
630 | /* clock derived from 32 KHz os clk */ | ||
631 | { .dev_id = "rtc-spear", .clk = &rtc_clk}, | ||
632 | /* clock derived from 30 MHz os clk */ | ||
633 | { .con_id = "pll1_clk", .clk = &pll1_clk}, | ||
634 | { .con_id = "pll3_48m_clk", .clk = &pll3_48m_clk}, | ||
635 | { .dev_id = "wdt", .clk = &wdt_clk}, | ||
636 | /* clock derived from pll1 clk */ | ||
637 | { .con_id = "cpu_clk", .clk = &cpu_clk}, | ||
638 | { .con_id = "ahb_clk", .clk = &ahb_clk}, | ||
639 | { .con_id = "uart_synth_clk", .clk = &uart_synth_clk}, | ||
640 | { .con_id = "firda_synth_clk", .clk = &firda_synth_clk}, | ||
641 | { .con_id = "clcd_synth_clk", .clk = &clcd_synth_clk}, | ||
642 | { .con_id = "gpt0_synth_clk", .clk = &gpt0_synth_clk}, | ||
643 | { .con_id = "gpt2_synth_clk", .clk = &gpt2_synth_clk}, | ||
644 | { .con_id = "gpt3_synth_clk", .clk = &gpt3_synth_clk}, | ||
645 | { .dev_id = "d0000000.serial", .clk = &uart0_clk}, | ||
646 | { .dev_id = "d0080000.serial", .clk = &uart1_clk}, | ||
647 | { .dev_id = "firda", .clk = &firda_clk}, | ||
648 | { .dev_id = "clcd", .clk = &clcd_clk}, | ||
649 | { .dev_id = "gpt0", .clk = &gpt0_clk}, | ||
650 | { .dev_id = "gpt1", .clk = &gpt1_clk}, | ||
651 | { .dev_id = "gpt2", .clk = &gpt2_clk}, | ||
652 | { .dev_id = "gpt3", .clk = &gpt3_clk}, | ||
653 | /* clock derived from pll3 clk */ | ||
654 | { .dev_id = "designware_udc", .clk = &usbd_clk}, | ||
655 | { .con_id = "usbh.0_clk", .clk = &usbh0_clk}, | ||
656 | { .con_id = "usbh.1_clk", .clk = &usbh1_clk}, | ||
657 | /* clock derived from ahb clk */ | ||
658 | { .con_id = "apb_clk", .clk = &apb_clk}, | ||
659 | { .dev_id = "d0200000.i2c", .clk = &i2c_clk}, | ||
660 | { .dev_id = "dma", .clk = &dma_clk}, | ||
661 | { .dev_id = "jpeg", .clk = &jpeg_clk}, | ||
662 | { .dev_id = "gmac", .clk = &gmac_clk}, | ||
663 | { .dev_id = "smi", .clk = &smi_clk}, | ||
664 | { .dev_id = "fsmc-nand", .clk = &fsmc_clk}, | ||
665 | /* clock derived from apb clk */ | ||
666 | { .dev_id = "adc", .clk = &adc_clk}, | ||
667 | { .dev_id = "ssp-pl022.0", .clk = &ssp0_clk}, | ||
668 | { .dev_id = "ssp-pl022.1", .clk = &ssp1_clk}, | ||
669 | { .dev_id = "ssp-pl022.2", .clk = &ssp2_clk}, | ||
670 | { .dev_id = "f0100000.gpio", .clk = &gpio0_clk}, | ||
671 | { .dev_id = "fc980000.gpio", .clk = &gpio1_clk}, | ||
672 | { .dev_id = "d8100000.gpio", .clk = &gpio2_clk}, | ||
673 | }; | ||
674 | |||
675 | void __init spear6xx_clk_init(void) | ||
676 | { | ||
677 | int i; | ||
678 | |||
679 | for (i = 0; i < ARRAY_SIZE(spear_clk_lookups); i++) | ||
680 | clk_register(&spear_clk_lookups[i]); | ||
681 | |||
682 | clk_init(); | ||
683 | } | ||
diff --git a/arch/arm/mach-spear6xx/include/mach/generic.h b/arch/arm/mach-spear6xx/include/mach/generic.h index 116b99301cf5..65514b159370 100644 --- a/arch/arm/mach-spear6xx/include/mach/generic.h +++ b/arch/arm/mach-spear6xx/include/mach/generic.h | |||
@@ -15,34 +15,9 @@ | |||
15 | #define __MACH_GENERIC_H | 15 | #define __MACH_GENERIC_H |
16 | 16 | ||
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/platform_device.h> | ||
19 | #include <linux/amba/bus.h> | ||
20 | #include <asm/mach/time.h> | ||
21 | #include <asm/mach/map.h> | ||
22 | |||
23 | /* | ||
24 | * Each GPT has 2 timer channels | ||
25 | * Following GPT channels will be used as clock source and clockevent | ||
26 | */ | ||
27 | #define SPEAR_GPT0_BASE SPEAR6XX_CPU_TMR_BASE | ||
28 | #define SPEAR_GPT0_CHAN0_IRQ IRQ_CPU_GPT1_1 | ||
29 | #define SPEAR_GPT0_CHAN1_IRQ IRQ_CPU_GPT1_2 | ||
30 | |||
31 | /* Add spear6xx family device structure declarations here */ | ||
32 | extern struct amba_device gpio_device[]; | ||
33 | extern struct amba_device uart_device[]; | ||
34 | extern struct sys_timer spear6xx_timer; | ||
35 | |||
36 | /* Add spear6xx family function declarations here */ | ||
37 | void __init spear_setup_timer(void); | ||
38 | void __init spear6xx_map_io(void); | ||
39 | void __init spear6xx_init_irq(void); | ||
40 | void __init spear6xx_init(void); | ||
41 | void __init spear600_init(void); | ||
42 | void __init spear6xx_clk_init(void); | ||
43 | 18 | ||
19 | void __init spear_setup_of_timer(void); | ||
44 | void spear_restart(char, const char *); | 20 | void spear_restart(char, const char *); |
45 | 21 | void __init spear6xx_clk_init(void); | |
46 | /* Add spear600 machine device structure declarations here */ | ||
47 | 22 | ||
48 | #endif /* __MACH_GENERIC_H */ | 23 | #endif /* __MACH_GENERIC_H */ |
diff --git a/arch/arm/mach-spear6xx/include/mach/hardware.h b/arch/arm/mach-spear6xx/include/mach/hardware.h index 0b3f96ae2848..40a8c178f10d 100644 --- a/arch/arm/mach-spear6xx/include/mach/hardware.h +++ b/arch/arm/mach-spear6xx/include/mach/hardware.h | |||
@@ -1,23 +1 @@ | |||
1 | /* | /* empty */ | |
2 | * arch/arm/mach-spear6xx/include/mach/hardware.h | ||
3 | * | ||
4 | * Hardware definitions for SPEAr6xx machine family | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Rajeev Kumar<rajeev-dlh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __MACH_HARDWARE_H | ||
15 | #define __MACH_HARDWARE_H | ||
16 | |||
17 | #include <plat/hardware.h> | ||
18 | #include <mach/spear.h> | ||
19 | |||
20 | /* Vitual to physical translation of statically mapped space */ | ||
21 | #define IO_ADDRESS(x) (x | 0xF0000000) | ||
22 | |||
23 | #endif /* __MACH_HARDWARE_H */ | ||
diff --git a/arch/arm/mach-spear6xx/include/mach/irqs.h b/arch/arm/mach-spear6xx/include/mach/irqs.h index 8f214b03d75d..37a5c411a866 100644 --- a/arch/arm/mach-spear6xx/include/mach/irqs.h +++ b/arch/arm/mach-spear6xx/include/mach/irqs.h | |||
@@ -16,82 +16,10 @@ | |||
16 | 16 | ||
17 | /* IRQ definitions */ | 17 | /* IRQ definitions */ |
18 | /* VIC 1 */ | 18 | /* VIC 1 */ |
19 | #define IRQ_INTRCOMM_SW_IRQ 0 | ||
20 | #define IRQ_INTRCOMM_CPU_1 1 | ||
21 | #define IRQ_INTRCOMM_CPU_2 2 | ||
22 | #define IRQ_INTRCOMM_RAS2A11_1 3 | ||
23 | #define IRQ_INTRCOMM_RAS2A11_2 4 | ||
24 | #define IRQ_INTRCOMM_RAS2A12_1 5 | ||
25 | #define IRQ_INTRCOMM_RAS2A12_2 6 | ||
26 | #define IRQ_GEN_RAS_0 7 | ||
27 | #define IRQ_GEN_RAS_1 8 | ||
28 | #define IRQ_GEN_RAS_2 9 | ||
29 | #define IRQ_GEN_RAS_3 10 | ||
30 | #define IRQ_GEN_RAS_4 11 | ||
31 | #define IRQ_GEN_RAS_5 12 | ||
32 | #define IRQ_GEN_RAS_6 13 | ||
33 | #define IRQ_GEN_RAS_7 14 | ||
34 | #define IRQ_GEN_RAS_8 15 | ||
35 | #define IRQ_CPU_GPT1_1 16 | ||
36 | #define IRQ_CPU_GPT1_2 17 | ||
37 | #define IRQ_LOCAL_GPIO 18 | ||
38 | #define IRQ_PLL_UNLOCK 19 | ||
39 | #define IRQ_JPEG 20 | ||
40 | #define IRQ_FSMC 21 | ||
41 | #define IRQ_IRDA 22 | ||
42 | #define IRQ_RESERVED 23 | ||
43 | #define IRQ_UART_0 24 | ||
44 | #define IRQ_UART_1 25 | ||
45 | #define IRQ_SSP_1 26 | ||
46 | #define IRQ_SSP_2 27 | ||
47 | #define IRQ_I2C 28 | ||
48 | #define IRQ_GEN_RAS_9 29 | ||
49 | #define IRQ_GEN_RAS_10 30 | ||
50 | #define IRQ_GEN_RAS_11 31 | ||
51 | |||
52 | /* VIC 2 */ | ||
53 | #define IRQ_APPL_GPT1_1 32 | ||
54 | #define IRQ_APPL_GPT1_2 33 | ||
55 | #define IRQ_APPL_GPT2_1 34 | ||
56 | #define IRQ_APPL_GPT2_2 35 | ||
57 | #define IRQ_APPL_GPIO 36 | ||
58 | #define IRQ_APPL_SSP 37 | ||
59 | #define IRQ_APPL_ADC 38 | ||
60 | #define IRQ_APPL_RESERVED 39 | ||
61 | #define IRQ_AHB_EXP_MASTER 40 | ||
62 | #define IRQ_DDR_CONTROLLER 41 | ||
63 | #define IRQ_BASIC_DMA 42 | ||
64 | #define IRQ_BASIC_RESERVED1 43 | ||
65 | #define IRQ_BASIC_SMI 44 | ||
66 | #define IRQ_BASIC_CLCD 45 | ||
67 | #define IRQ_EXP_AHB_1 46 | ||
68 | #define IRQ_EXP_AHB_2 47 | ||
69 | #define IRQ_BASIC_GPT1_1 48 | ||
70 | #define IRQ_BASIC_GPT1_2 49 | ||
71 | #define IRQ_BASIC_RTC 50 | ||
72 | #define IRQ_BASIC_GPIO 51 | ||
73 | #define IRQ_BASIC_WDT 52 | ||
74 | #define IRQ_BASIC_RESERVED 53 | ||
75 | #define IRQ_AHB_EXP_SLAVE 54 | ||
76 | #define IRQ_GMAC_1 55 | ||
77 | #define IRQ_GMAC_2 56 | ||
78 | #define IRQ_USB_DEV 57 | ||
79 | #define IRQ_USB_H_OHCI_0 58 | ||
80 | #define IRQ_USB_H_EHCI_0 59 | ||
81 | #define IRQ_USB_H_OHCI_1 60 | ||
82 | #define IRQ_USB_H_EHCI_1 61 | ||
83 | #define IRQ_EXP_AHB_3 62 | ||
84 | #define IRQ_EXP_AHB_4 63 | ||
85 | |||
86 | #define IRQ_VIC_END 64 | 19 | #define IRQ_VIC_END 64 |
87 | 20 | ||
88 | /* GPIO pins virtual irqs */ | 21 | /* GPIO pins virtual irqs */ |
89 | #define SPEAR_GPIO_INT_BASE IRQ_VIC_END | 22 | #define VIRTUAL_IRQS 24 |
90 | #define SPEAR_GPIO0_INT_BASE SPEAR_GPIO_INT_BASE | 23 | #define NR_IRQS (IRQ_VIC_END + VIRTUAL_IRQS) |
91 | #define SPEAR_GPIO1_INT_BASE (SPEAR_GPIO0_INT_BASE + 8) | ||
92 | #define SPEAR_GPIO2_INT_BASE (SPEAR_GPIO1_INT_BASE + 8) | ||
93 | #define SPEAR_GPIO_INT_END (SPEAR_GPIO2_INT_BASE + 8) | ||
94 | #define VIRTUAL_IRQS (SPEAR_GPIO_INT_END - IRQ_VIC_END) | ||
95 | #define NR_IRQS (IRQ_VIC_END + VIRTUAL_IRQS) | ||
96 | 24 | ||
97 | #endif /* __MACH_IRQS_H */ | 25 | #endif /* __MACH_IRQS_H */ |
diff --git a/arch/arm/mach-spear6xx/include/mach/misc_regs.h b/arch/arm/mach-spear6xx/include/mach/misc_regs.h index 68c20a007b0d..179e45774b3a 100644 --- a/arch/arm/mach-spear6xx/include/mach/misc_regs.h +++ b/arch/arm/mach-spear6xx/include/mach/misc_regs.h | |||
@@ -14,161 +14,9 @@ | |||
14 | #ifndef __MACH_MISC_REGS_H | 14 | #ifndef __MACH_MISC_REGS_H |
15 | #define __MACH_MISC_REGS_H | 15 | #define __MACH_MISC_REGS_H |
16 | 16 | ||
17 | #include <mach/hardware.h> | 17 | #include <mach/spear.h> |
18 | 18 | ||
19 | #define MISC_BASE IOMEM(VA_SPEAR6XX_ICM3_MISC_REG_BASE) | 19 | #define MISC_BASE IOMEM(VA_SPEAR6XX_ICM3_MISC_REG_BASE) |
20 | |||
21 | #define SOC_CFG_CTR (MISC_BASE + 0x000) | ||
22 | #define DIAG_CFG_CTR (MISC_BASE + 0x004) | ||
23 | #define PLL1_CTR (MISC_BASE + 0x008) | ||
24 | #define PLL1_FRQ (MISC_BASE + 0x00C) | ||
25 | #define PLL1_MOD (MISC_BASE + 0x010) | ||
26 | #define PLL2_CTR (MISC_BASE + 0x014) | ||
27 | /* PLL_CTR register masks */ | ||
28 | #define PLL_ENABLE 2 | ||
29 | #define PLL_MODE_SHIFT 4 | ||
30 | #define PLL_MODE_MASK 0x3 | ||
31 | #define PLL_MODE_NORMAL 0 | ||
32 | #define PLL_MODE_FRACTION 1 | ||
33 | #define PLL_MODE_DITH_DSB 2 | ||
34 | #define PLL_MODE_DITH_SSB 3 | ||
35 | |||
36 | #define PLL2_FRQ (MISC_BASE + 0x018) | ||
37 | /* PLL FRQ register masks */ | ||
38 | #define PLL_DIV_N_SHIFT 0 | ||
39 | #define PLL_DIV_N_MASK 0xFF | ||
40 | #define PLL_DIV_P_SHIFT 8 | ||
41 | #define PLL_DIV_P_MASK 0x7 | ||
42 | #define PLL_NORM_FDBK_M_SHIFT 24 | ||
43 | #define PLL_NORM_FDBK_M_MASK 0xFF | ||
44 | #define PLL_DITH_FDBK_M_SHIFT 16 | ||
45 | #define PLL_DITH_FDBK_M_MASK 0xFFFF | ||
46 | |||
47 | #define PLL2_MOD (MISC_BASE + 0x01C) | ||
48 | #define PLL_CLK_CFG (MISC_BASE + 0x020) | ||
49 | #define CORE_CLK_CFG (MISC_BASE + 0x024) | ||
50 | /* CORE CLK CFG register masks */ | ||
51 | #define PLL_HCLK_RATIO_SHIFT 10 | ||
52 | #define PLL_HCLK_RATIO_MASK 0x3 | ||
53 | #define HCLK_PCLK_RATIO_SHIFT 8 | ||
54 | #define HCLK_PCLK_RATIO_MASK 0x3 | ||
55 | |||
56 | #define PERIP_CLK_CFG (MISC_BASE + 0x028) | ||
57 | /* PERIP_CLK_CFG register masks */ | ||
58 | #define CLCD_CLK_SHIFT 2 | ||
59 | #define CLCD_CLK_MASK 0x3 | ||
60 | #define UART_CLK_SHIFT 4 | ||
61 | #define UART_CLK_MASK 0x1 | ||
62 | #define FIRDA_CLK_SHIFT 5 | ||
63 | #define FIRDA_CLK_MASK 0x3 | ||
64 | #define GPT0_CLK_SHIFT 8 | ||
65 | #define GPT1_CLK_SHIFT 10 | ||
66 | #define GPT2_CLK_SHIFT 11 | ||
67 | #define GPT3_CLK_SHIFT 12 | ||
68 | #define GPT_CLK_MASK 0x1 | ||
69 | #define AUX_CLK_PLL3_VAL 0 | ||
70 | #define AUX_CLK_PLL1_VAL 1 | ||
71 | |||
72 | #define PERIP1_CLK_ENB (MISC_BASE + 0x02C) | ||
73 | /* PERIP1_CLK_ENB register masks */ | ||
74 | #define UART0_CLK_ENB 3 | ||
75 | #define UART1_CLK_ENB 4 | ||
76 | #define SSP0_CLK_ENB 5 | ||
77 | #define SSP1_CLK_ENB 6 | ||
78 | #define I2C_CLK_ENB 7 | ||
79 | #define JPEG_CLK_ENB 8 | ||
80 | #define FSMC_CLK_ENB 9 | ||
81 | #define FIRDA_CLK_ENB 10 | ||
82 | #define GPT2_CLK_ENB 11 | ||
83 | #define GPT3_CLK_ENB 12 | ||
84 | #define GPIO2_CLK_ENB 13 | ||
85 | #define SSP2_CLK_ENB 14 | ||
86 | #define ADC_CLK_ENB 15 | ||
87 | #define GPT1_CLK_ENB 11 | ||
88 | #define RTC_CLK_ENB 17 | ||
89 | #define GPIO1_CLK_ENB 18 | ||
90 | #define DMA_CLK_ENB 19 | ||
91 | #define SMI_CLK_ENB 21 | ||
92 | #define CLCD_CLK_ENB 22 | ||
93 | #define GMAC_CLK_ENB 23 | ||
94 | #define USBD_CLK_ENB 24 | ||
95 | #define USBH0_CLK_ENB 25 | ||
96 | #define USBH1_CLK_ENB 26 | ||
97 | |||
98 | #define SOC_CORE_ID (MISC_BASE + 0x030) | ||
99 | #define RAS_CLK_ENB (MISC_BASE + 0x034) | ||
100 | #define PERIP1_SOF_RST (MISC_BASE + 0x038) | ||
101 | /* PERIP1_SOF_RST register masks */ | ||
102 | #define JPEG_SOF_RST 8 | ||
103 | |||
104 | #define SOC_USER_ID (MISC_BASE + 0x03C) | ||
105 | #define RAS_SOF_RST (MISC_BASE + 0x040) | ||
106 | #define PRSC1_CLK_CFG (MISC_BASE + 0x044) | ||
107 | #define PRSC2_CLK_CFG (MISC_BASE + 0x048) | ||
108 | #define PRSC3_CLK_CFG (MISC_BASE + 0x04C) | ||
109 | /* gpt synthesizer register masks */ | ||
110 | #define GPT_MSCALE_SHIFT 0 | ||
111 | #define GPT_MSCALE_MASK 0xFFF | ||
112 | #define GPT_NSCALE_SHIFT 12 | ||
113 | #define GPT_NSCALE_MASK 0xF | ||
114 | |||
115 | #define AMEM_CLK_CFG (MISC_BASE + 0x050) | ||
116 | #define EXPI_CLK_CFG (MISC_BASE + 0x054) | ||
117 | #define CLCD_CLK_SYNT (MISC_BASE + 0x05C) | ||
118 | #define FIRDA_CLK_SYNT (MISC_BASE + 0x060) | ||
119 | #define UART_CLK_SYNT (MISC_BASE + 0x064) | ||
120 | #define GMAC_CLK_SYNT (MISC_BASE + 0x068) | ||
121 | #define RAS1_CLK_SYNT (MISC_BASE + 0x06C) | ||
122 | #define RAS2_CLK_SYNT (MISC_BASE + 0x070) | ||
123 | #define RAS3_CLK_SYNT (MISC_BASE + 0x074) | ||
124 | #define RAS4_CLK_SYNT (MISC_BASE + 0x078) | ||
125 | /* aux clk synthesiser register masks for irda to ras4 */ | ||
126 | #define AUX_SYNT_ENB 31 | ||
127 | #define AUX_EQ_SEL_SHIFT 30 | ||
128 | #define AUX_EQ_SEL_MASK 1 | ||
129 | #define AUX_EQ1_SEL 0 | ||
130 | #define AUX_EQ2_SEL 1 | ||
131 | #define AUX_XSCALE_SHIFT 16 | ||
132 | #define AUX_XSCALE_MASK 0xFFF | ||
133 | #define AUX_YSCALE_SHIFT 0 | ||
134 | #define AUX_YSCALE_MASK 0xFFF | ||
135 | |||
136 | #define ICM1_ARB_CFG (MISC_BASE + 0x07C) | ||
137 | #define ICM2_ARB_CFG (MISC_BASE + 0x080) | ||
138 | #define ICM3_ARB_CFG (MISC_BASE + 0x084) | ||
139 | #define ICM4_ARB_CFG (MISC_BASE + 0x088) | ||
140 | #define ICM5_ARB_CFG (MISC_BASE + 0x08C) | ||
141 | #define ICM6_ARB_CFG (MISC_BASE + 0x090) | ||
142 | #define ICM7_ARB_CFG (MISC_BASE + 0x094) | ||
143 | #define ICM8_ARB_CFG (MISC_BASE + 0x098) | ||
144 | #define ICM9_ARB_CFG (MISC_BASE + 0x09C) | ||
145 | #define DMA_CHN_CFG (MISC_BASE + 0x0A0) | 20 | #define DMA_CHN_CFG (MISC_BASE + 0x0A0) |
146 | #define USB2_PHY_CFG (MISC_BASE + 0x0A4) | ||
147 | #define GMAC_CFG_CTR (MISC_BASE + 0x0A8) | ||
148 | #define EXPI_CFG_CTR (MISC_BASE + 0x0AC) | ||
149 | #define PRC1_LOCK_CTR (MISC_BASE + 0x0C0) | ||
150 | #define PRC2_LOCK_CTR (MISC_BASE + 0x0C4) | ||
151 | #define PRC3_LOCK_CTR (MISC_BASE + 0x0C8) | ||
152 | #define PRC4_LOCK_CTR (MISC_BASE + 0x0CC) | ||
153 | #define PRC1_IRQ_CTR (MISC_BASE + 0x0D0) | ||
154 | #define PRC2_IRQ_CTR (MISC_BASE + 0x0D4) | ||
155 | #define PRC3_IRQ_CTR (MISC_BASE + 0x0D8) | ||
156 | #define PRC4_IRQ_CTR (MISC_BASE + 0x0DC) | ||
157 | #define PWRDOWN_CFG_CTR (MISC_BASE + 0x0E0) | ||
158 | #define COMPSSTL_1V8_CFG (MISC_BASE + 0x0E4) | ||
159 | #define COMPSSTL_2V5_CFG (MISC_BASE + 0x0E8) | ||
160 | #define COMPCOR_3V3_CFG (MISC_BASE + 0x0EC) | ||
161 | #define SSTLPAD_CFG_CTR (MISC_BASE + 0x0F0) | ||
162 | #define BIST1_CFG_CTR (MISC_BASE + 0x0F4) | ||
163 | #define BIST2_CFG_CTR (MISC_BASE + 0x0F8) | ||
164 | #define BIST3_CFG_CTR (MISC_BASE + 0x0FC) | ||
165 | #define BIST4_CFG_CTR (MISC_BASE + 0x100) | ||
166 | #define BIST5_CFG_CTR (MISC_BASE + 0x104) | ||
167 | #define BIST1_STS_RES (MISC_BASE + 0x108) | ||
168 | #define BIST2_STS_RES (MISC_BASE + 0x10C) | ||
169 | #define BIST3_STS_RES (MISC_BASE + 0x110) | ||
170 | #define BIST4_STS_RES (MISC_BASE + 0x114) | ||
171 | #define BIST5_STS_RES (MISC_BASE + 0x118) | ||
172 | #define SYSERR_CFG_CTR (MISC_BASE + 0x11C) | ||
173 | 21 | ||
174 | #endif /* __MACH_MISC_REGS_H */ | 22 | #endif /* __MACH_MISC_REGS_H */ |
diff --git a/arch/arm/mach-spear6xx/include/mach/spear.h b/arch/arm/mach-spear6xx/include/mach/spear.h index 7fd621532def..cb8ed2f4dc85 100644 --- a/arch/arm/mach-spear6xx/include/mach/spear.h +++ b/arch/arm/mach-spear6xx/include/mach/spear.h | |||
@@ -15,69 +15,25 @@ | |||
15 | #define __MACH_SPEAR6XX_H | 15 | #define __MACH_SPEAR6XX_H |
16 | 16 | ||
17 | #include <asm/memory.h> | 17 | #include <asm/memory.h> |
18 | #include <mach/spear600.h> | ||
19 | 18 | ||
20 | #define SPEAR6XX_ML_SDRAM_BASE UL(0x00000000) | ||
21 | /* ICM1 - Low speed connection */ | 19 | /* ICM1 - Low speed connection */ |
22 | #define SPEAR6XX_ICM1_BASE UL(0xD0000000) | 20 | #define SPEAR6XX_ICM1_BASE UL(0xD0000000) |
23 | 21 | #define VA_SPEAR6XX_ICM1_BASE UL(0xFD000000) | |
24 | #define SPEAR6XX_ICM1_UART0_BASE UL(0xD0000000) | 22 | #define SPEAR6XX_ICM1_UART0_BASE UL(0xD0000000) |
25 | #define VA_SPEAR6XX_ICM1_UART0_BASE IO_ADDRESS(SPEAR6XX_ICM1_UART0_BASE) | 23 | #define VA_SPEAR6XX_ICM1_UART0_BASE (VA_SPEAR6XX_ICM1_2_BASE | SPEAR6XX_ICM1_UART0_BASE) |
26 | |||
27 | #define SPEAR6XX_ICM1_UART1_BASE UL(0xD0080000) | ||
28 | #define SPEAR6XX_ICM1_SSP0_BASE UL(0xD0100000) | ||
29 | #define SPEAR6XX_ICM1_SSP1_BASE UL(0xD0180000) | ||
30 | #define SPEAR6XX_ICM1_I2C_BASE UL(0xD0200000) | ||
31 | #define SPEAR6XX_ICM1_JPEG_BASE UL(0xD0800000) | ||
32 | #define SPEAR6XX_ICM1_IRDA_BASE UL(0xD1000000) | ||
33 | #define SPEAR6XX_ICM1_FSMC_BASE UL(0xD1800000) | ||
34 | #define SPEAR6XX_ICM1_NAND_BASE UL(0xD2000000) | ||
35 | #define SPEAR6XX_ICM1_SRAM_BASE UL(0xD2800000) | ||
36 | |||
37 | /* ICM2 - Application Subsystem */ | ||
38 | #define SPEAR6XX_ICM2_BASE UL(0xD8000000) | ||
39 | #define SPEAR6XX_ICM2_TMR0_BASE UL(0xD8000000) | ||
40 | #define SPEAR6XX_ICM2_TMR1_BASE UL(0xD8080000) | ||
41 | #define SPEAR6XX_ICM2_GPIO_BASE UL(0xD8100000) | ||
42 | #define SPEAR6XX_ICM2_SSP2_BASE UL(0xD8180000) | ||
43 | #define SPEAR6XX_ICM2_ADC_BASE UL(0xD8200000) | ||
44 | 24 | ||
45 | /* ML-1, 2 - Multi Layer CPU Subsystem */ | 25 | /* ML-1, 2 - Multi Layer CPU Subsystem */ |
46 | #define SPEAR6XX_ML_CPU_BASE UL(0xF0000000) | 26 | #define SPEAR6XX_ML_CPU_BASE UL(0xF0000000) |
47 | #define SPEAR6XX_CPU_TMR_BASE UL(0xF0000000) | 27 | #define VA_SPEAR6XX_ML_CPU_BASE UL(0xF0000000) |
48 | #define SPEAR6XX_CPU_GPIO_BASE UL(0xF0100000) | ||
49 | #define SPEAR6XX_CPU_VIC_SEC_BASE UL(0xF1000000) | ||
50 | #define VA_SPEAR6XX_CPU_VIC_SEC_BASE IO_ADDRESS(SPEAR6XX_CPU_VIC_SEC_BASE) | ||
51 | #define SPEAR6XX_CPU_VIC_PRI_BASE UL(0xF1100000) | ||
52 | #define VA_SPEAR6XX_CPU_VIC_PRI_BASE IO_ADDRESS(SPEAR6XX_CPU_VIC_PRI_BASE) | ||
53 | 28 | ||
54 | /* ICM3 - Basic Subsystem */ | 29 | /* ICM3 - Basic Subsystem */ |
55 | #define SPEAR6XX_ICM3_BASE UL(0xF8000000) | ||
56 | #define SPEAR6XX_ICM3_SMEM_BASE UL(0xF8000000) | ||
57 | #define SPEAR6XX_ICM3_SMI_CTRL_BASE UL(0xFC000000) | 30 | #define SPEAR6XX_ICM3_SMI_CTRL_BASE UL(0xFC000000) |
58 | #define SPEAR6XX_ICM3_CLCD_BASE UL(0xFC200000) | 31 | #define VA_SPEAR6XX_ICM3_SMI_CTRL_BASE UL(0xFC000000) |
59 | #define SPEAR6XX_ICM3_DMA_BASE UL(0xFC400000) | 32 | #define SPEAR6XX_ICM3_DMA_BASE UL(0xFC400000) |
60 | #define SPEAR6XX_ICM3_SDRAM_CTRL_BASE UL(0xFC600000) | ||
61 | #define SPEAR6XX_ICM3_TMR_BASE UL(0xFC800000) | ||
62 | #define SPEAR6XX_ICM3_WDT_BASE UL(0xFC880000) | ||
63 | #define SPEAR6XX_ICM3_RTC_BASE UL(0xFC900000) | ||
64 | #define SPEAR6XX_ICM3_GPIO_BASE UL(0xFC980000) | ||
65 | #define SPEAR6XX_ICM3_SYS_CTRL_BASE UL(0xFCA00000) | 33 | #define SPEAR6XX_ICM3_SYS_CTRL_BASE UL(0xFCA00000) |
66 | #define VA_SPEAR6XX_ICM3_SYS_CTRL_BASE IO_ADDRESS(SPEAR6XX_ICM3_SYS_CTRL_BASE) | 34 | #define VA_SPEAR6XX_ICM3_SYS_CTRL_BASE (VA_SPEAR6XX_ICM3_SMI_CTRL_BASE | SPEAR6XX_ICM3_SYS_CTRL_BASE) |
67 | #define SPEAR6XX_ICM3_MISC_REG_BASE UL(0xFCA80000) | 35 | #define SPEAR6XX_ICM3_MISC_REG_BASE UL(0xFCA80000) |
68 | #define VA_SPEAR6XX_ICM3_MISC_REG_BASE IO_ADDRESS(SPEAR6XX_ICM3_MISC_REG_BASE) | 36 | #define VA_SPEAR6XX_ICM3_MISC_REG_BASE (VA_SPEAR6XX_ICM3_SMI_CTRL_BASE | SPEAR6XX_ICM3_MISC_REG_BASE) |
69 | |||
70 | /* ICM4 - High Speed Connection */ | ||
71 | #define SPEAR6XX_ICM4_BASE UL(0xE0000000) | ||
72 | #define SPEAR6XX_ICM4_GMAC_BASE UL(0xE0800000) | ||
73 | #define SPEAR6XX_ICM4_USBD_FIFO_BASE UL(0xE1000000) | ||
74 | #define SPEAR6XX_ICM4_USBD_CSR_BASE UL(0xE1100000) | ||
75 | #define SPEAR6XX_ICM4_USBD_PLDT_BASE UL(0xE1200000) | ||
76 | #define SPEAR6XX_ICM4_USB_EHCI0_BASE UL(0xE1800000) | ||
77 | #define SPEAR6XX_ICM4_USB_OHCI0_BASE UL(0xE1900000) | ||
78 | #define SPEAR6XX_ICM4_USB_EHCI1_BASE UL(0xE2000000) | ||
79 | #define SPEAR6XX_ICM4_USB_OHCI1_BASE UL(0xE2100000) | ||
80 | #define SPEAR6XX_ICM4_USB_ARB_BASE UL(0xE2800000) | ||
81 | 37 | ||
82 | /* Debug uart for linux, will be used for debug and uncompress messages */ | 38 | /* Debug uart for linux, will be used for debug and uncompress messages */ |
83 | #define SPEAR_DBG_UART_BASE SPEAR6XX_ICM1_UART0_BASE | 39 | #define SPEAR_DBG_UART_BASE SPEAR6XX_ICM1_UART0_BASE |
diff --git a/arch/arm/mach-spear6xx/include/mach/spear600.h b/arch/arm/mach-spear6xx/include/mach/spear600.h deleted file mode 100644 index c068cc50b0fb..000000000000 --- a/arch/arm/mach-spear6xx/include/mach/spear600.h +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-spear66xx/include/mach/spear600.h | ||
3 | * | ||
4 | * SPEAr600 Machine specific definition | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifdef CONFIG_MACH_SPEAR600 | ||
15 | |||
16 | #ifndef __MACH_SPEAR600_H | ||
17 | #define __MACH_SPEAR600_H | ||
18 | |||
19 | #endif /* __MACH_SPEAR600_H */ | ||
20 | |||
21 | #endif /* CONFIG_MACH_SPEAR600 */ | ||
diff --git a/arch/arm/mach-spear6xx/spear6xx.c b/arch/arm/mach-spear6xx/spear6xx.c index 2ed8b14c82c8..2e2e3596583e 100644 --- a/arch/arm/mach-spear6xx/spear6xx.c +++ b/arch/arm/mach-spear6xx/spear6xx.c | |||
@@ -13,41 +13,404 @@ | |||
13 | * warranty of any kind, whether express or implied. | 13 | * warranty of any kind, whether express or implied. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/amba/pl08x.h> | ||
17 | #include <linux/clk.h> | ||
18 | #include <linux/err.h> | ||
16 | #include <linux/of.h> | 19 | #include <linux/of.h> |
17 | #include <linux/of_address.h> | 20 | #include <linux/of_address.h> |
18 | #include <linux/of_irq.h> | 21 | #include <linux/of_irq.h> |
19 | #include <linux/of_platform.h> | 22 | #include <linux/of_platform.h> |
23 | #include <asm/hardware/pl080.h> | ||
20 | #include <asm/hardware/vic.h> | 24 | #include <asm/hardware/vic.h> |
21 | #include <asm/mach/arch.h> | 25 | #include <asm/mach/arch.h> |
26 | #include <asm/mach/time.h> | ||
27 | #include <asm/mach/map.h> | ||
28 | #include <plat/pl080.h> | ||
22 | #include <mach/generic.h> | 29 | #include <mach/generic.h> |
23 | #include <mach/hardware.h> | 30 | #include <mach/spear.h> |
24 | 31 | ||
25 | /* Following will create static virtual/physical mappings */ | 32 | /* dmac device registration */ |
26 | static struct map_desc spear6xx_io_desc[] __initdata = { | 33 | static struct pl08x_channel_data spear600_dma_info[] = { |
27 | { | 34 | { |
28 | .virtual = VA_SPEAR6XX_ICM1_UART0_BASE, | 35 | .bus_id = "ssp1_rx", |
29 | .pfn = __phys_to_pfn(SPEAR6XX_ICM1_UART0_BASE), | 36 | .min_signal = 0, |
30 | .length = SZ_4K, | 37 | .max_signal = 0, |
31 | .type = MT_DEVICE | 38 | .muxval = 0, |
39 | .cctl = 0, | ||
40 | .periph_buses = PL08X_AHB1, | ||
32 | }, { | 41 | }, { |
33 | .virtual = VA_SPEAR6XX_CPU_VIC_PRI_BASE, | 42 | .bus_id = "ssp1_tx", |
34 | .pfn = __phys_to_pfn(SPEAR6XX_CPU_VIC_PRI_BASE), | 43 | .min_signal = 1, |
35 | .length = SZ_4K, | 44 | .max_signal = 1, |
36 | .type = MT_DEVICE | 45 | .muxval = 0, |
46 | .cctl = 0, | ||
47 | .periph_buses = PL08X_AHB1, | ||
37 | }, { | 48 | }, { |
38 | .virtual = VA_SPEAR6XX_CPU_VIC_SEC_BASE, | 49 | .bus_id = "uart0_rx", |
39 | .pfn = __phys_to_pfn(SPEAR6XX_CPU_VIC_SEC_BASE), | 50 | .min_signal = 2, |
40 | .length = SZ_4K, | 51 | .max_signal = 2, |
41 | .type = MT_DEVICE | 52 | .muxval = 0, |
53 | .cctl = 0, | ||
54 | .periph_buses = PL08X_AHB1, | ||
55 | }, { | ||
56 | .bus_id = "uart0_tx", | ||
57 | .min_signal = 3, | ||
58 | .max_signal = 3, | ||
59 | .muxval = 0, | ||
60 | .cctl = 0, | ||
61 | .periph_buses = PL08X_AHB1, | ||
62 | }, { | ||
63 | .bus_id = "uart1_rx", | ||
64 | .min_signal = 4, | ||
65 | .max_signal = 4, | ||
66 | .muxval = 0, | ||
67 | .cctl = 0, | ||
68 | .periph_buses = PL08X_AHB1, | ||
69 | }, { | ||
70 | .bus_id = "uart1_tx", | ||
71 | .min_signal = 5, | ||
72 | .max_signal = 5, | ||
73 | .muxval = 0, | ||
74 | .cctl = 0, | ||
75 | .periph_buses = PL08X_AHB1, | ||
76 | }, { | ||
77 | .bus_id = "ssp2_rx", | ||
78 | .min_signal = 6, | ||
79 | .max_signal = 6, | ||
80 | .muxval = 0, | ||
81 | .cctl = 0, | ||
82 | .periph_buses = PL08X_AHB2, | ||
83 | }, { | ||
84 | .bus_id = "ssp2_tx", | ||
85 | .min_signal = 7, | ||
86 | .max_signal = 7, | ||
87 | .muxval = 0, | ||
88 | .cctl = 0, | ||
89 | .periph_buses = PL08X_AHB2, | ||
90 | }, { | ||
91 | .bus_id = "ssp0_rx", | ||
92 | .min_signal = 8, | ||
93 | .max_signal = 8, | ||
94 | .muxval = 0, | ||
95 | .cctl = 0, | ||
96 | .periph_buses = PL08X_AHB1, | ||
97 | }, { | ||
98 | .bus_id = "ssp0_tx", | ||
99 | .min_signal = 9, | ||
100 | .max_signal = 9, | ||
101 | .muxval = 0, | ||
102 | .cctl = 0, | ||
103 | .periph_buses = PL08X_AHB1, | ||
104 | }, { | ||
105 | .bus_id = "i2c_rx", | ||
106 | .min_signal = 10, | ||
107 | .max_signal = 10, | ||
108 | .muxval = 0, | ||
109 | .cctl = 0, | ||
110 | .periph_buses = PL08X_AHB1, | ||
111 | }, { | ||
112 | .bus_id = "i2c_tx", | ||
113 | .min_signal = 11, | ||
114 | .max_signal = 11, | ||
115 | .muxval = 0, | ||
116 | .cctl = 0, | ||
117 | .periph_buses = PL08X_AHB1, | ||
118 | }, { | ||
119 | .bus_id = "irda", | ||
120 | .min_signal = 12, | ||
121 | .max_signal = 12, | ||
122 | .muxval = 0, | ||
123 | .cctl = 0, | ||
124 | .periph_buses = PL08X_AHB1, | ||
125 | }, { | ||
126 | .bus_id = "adc", | ||
127 | .min_signal = 13, | ||
128 | .max_signal = 13, | ||
129 | .muxval = 0, | ||
130 | .cctl = 0, | ||
131 | .periph_buses = PL08X_AHB2, | ||
132 | }, { | ||
133 | .bus_id = "to_jpeg", | ||
134 | .min_signal = 14, | ||
135 | .max_signal = 14, | ||
136 | .muxval = 0, | ||
137 | .cctl = 0, | ||
138 | .periph_buses = PL08X_AHB1, | ||
139 | }, { | ||
140 | .bus_id = "from_jpeg", | ||
141 | .min_signal = 15, | ||
142 | .max_signal = 15, | ||
143 | .muxval = 0, | ||
144 | .cctl = 0, | ||
145 | .periph_buses = PL08X_AHB1, | ||
146 | }, { | ||
147 | .bus_id = "ras0_rx", | ||
148 | .min_signal = 0, | ||
149 | .max_signal = 0, | ||
150 | .muxval = 1, | ||
151 | .cctl = 0, | ||
152 | .periph_buses = PL08X_AHB1, | ||
153 | }, { | ||
154 | .bus_id = "ras0_tx", | ||
155 | .min_signal = 1, | ||
156 | .max_signal = 1, | ||
157 | .muxval = 1, | ||
158 | .cctl = 0, | ||
159 | .periph_buses = PL08X_AHB1, | ||
160 | }, { | ||
161 | .bus_id = "ras1_rx", | ||
162 | .min_signal = 2, | ||
163 | .max_signal = 2, | ||
164 | .muxval = 1, | ||
165 | .cctl = 0, | ||
166 | .periph_buses = PL08X_AHB1, | ||
167 | }, { | ||
168 | .bus_id = "ras1_tx", | ||
169 | .min_signal = 3, | ||
170 | .max_signal = 3, | ||
171 | .muxval = 1, | ||
172 | .cctl = 0, | ||
173 | .periph_buses = PL08X_AHB1, | ||
174 | }, { | ||
175 | .bus_id = "ras2_rx", | ||
176 | .min_signal = 4, | ||
177 | .max_signal = 4, | ||
178 | .muxval = 1, | ||
179 | .cctl = 0, | ||
180 | .periph_buses = PL08X_AHB1, | ||
181 | }, { | ||
182 | .bus_id = "ras2_tx", | ||
183 | .min_signal = 5, | ||
184 | .max_signal = 5, | ||
185 | .muxval = 1, | ||
186 | .cctl = 0, | ||
187 | .periph_buses = PL08X_AHB1, | ||
188 | }, { | ||
189 | .bus_id = "ras3_rx", | ||
190 | .min_signal = 6, | ||
191 | .max_signal = 6, | ||
192 | .muxval = 1, | ||
193 | .cctl = 0, | ||
194 | .periph_buses = PL08X_AHB1, | ||
195 | }, { | ||
196 | .bus_id = "ras3_tx", | ||
197 | .min_signal = 7, | ||
198 | .max_signal = 7, | ||
199 | .muxval = 1, | ||
200 | .cctl = 0, | ||
201 | .periph_buses = PL08X_AHB1, | ||
202 | }, { | ||
203 | .bus_id = "ras4_rx", | ||
204 | .min_signal = 8, | ||
205 | .max_signal = 8, | ||
206 | .muxval = 1, | ||
207 | .cctl = 0, | ||
208 | .periph_buses = PL08X_AHB1, | ||
209 | }, { | ||
210 | .bus_id = "ras4_tx", | ||
211 | .min_signal = 9, | ||
212 | .max_signal = 9, | ||
213 | .muxval = 1, | ||
214 | .cctl = 0, | ||
215 | .periph_buses = PL08X_AHB1, | ||
216 | }, { | ||
217 | .bus_id = "ras5_rx", | ||
218 | .min_signal = 10, | ||
219 | .max_signal = 10, | ||
220 | .muxval = 1, | ||
221 | .cctl = 0, | ||
222 | .periph_buses = PL08X_AHB1, | ||
223 | }, { | ||
224 | .bus_id = "ras5_tx", | ||
225 | .min_signal = 11, | ||
226 | .max_signal = 11, | ||
227 | .muxval = 1, | ||
228 | .cctl = 0, | ||
229 | .periph_buses = PL08X_AHB1, | ||
230 | }, { | ||
231 | .bus_id = "ras6_rx", | ||
232 | .min_signal = 12, | ||
233 | .max_signal = 12, | ||
234 | .muxval = 1, | ||
235 | .cctl = 0, | ||
236 | .periph_buses = PL08X_AHB1, | ||
237 | }, { | ||
238 | .bus_id = "ras6_tx", | ||
239 | .min_signal = 13, | ||
240 | .max_signal = 13, | ||
241 | .muxval = 1, | ||
242 | .cctl = 0, | ||
243 | .periph_buses = PL08X_AHB1, | ||
244 | }, { | ||
245 | .bus_id = "ras7_rx", | ||
246 | .min_signal = 14, | ||
247 | .max_signal = 14, | ||
248 | .muxval = 1, | ||
249 | .cctl = 0, | ||
250 | .periph_buses = PL08X_AHB1, | ||
251 | }, { | ||
252 | .bus_id = "ras7_tx", | ||
253 | .min_signal = 15, | ||
254 | .max_signal = 15, | ||
255 | .muxval = 1, | ||
256 | .cctl = 0, | ||
257 | .periph_buses = PL08X_AHB1, | ||
42 | }, { | 258 | }, { |
43 | .virtual = VA_SPEAR6XX_ICM3_SYS_CTRL_BASE, | 259 | .bus_id = "ext0_rx", |
44 | .pfn = __phys_to_pfn(SPEAR6XX_ICM3_SYS_CTRL_BASE), | 260 | .min_signal = 0, |
45 | .length = SZ_4K, | 261 | .max_signal = 0, |
262 | .muxval = 2, | ||
263 | .cctl = 0, | ||
264 | .periph_buses = PL08X_AHB2, | ||
265 | }, { | ||
266 | .bus_id = "ext0_tx", | ||
267 | .min_signal = 1, | ||
268 | .max_signal = 1, | ||
269 | .muxval = 2, | ||
270 | .cctl = 0, | ||
271 | .periph_buses = PL08X_AHB2, | ||
272 | }, { | ||
273 | .bus_id = "ext1_rx", | ||
274 | .min_signal = 2, | ||
275 | .max_signal = 2, | ||
276 | .muxval = 2, | ||
277 | .cctl = 0, | ||
278 | .periph_buses = PL08X_AHB2, | ||
279 | }, { | ||
280 | .bus_id = "ext1_tx", | ||
281 | .min_signal = 3, | ||
282 | .max_signal = 3, | ||
283 | .muxval = 2, | ||
284 | .cctl = 0, | ||
285 | .periph_buses = PL08X_AHB2, | ||
286 | }, { | ||
287 | .bus_id = "ext2_rx", | ||
288 | .min_signal = 4, | ||
289 | .max_signal = 4, | ||
290 | .muxval = 2, | ||
291 | .cctl = 0, | ||
292 | .periph_buses = PL08X_AHB2, | ||
293 | }, { | ||
294 | .bus_id = "ext2_tx", | ||
295 | .min_signal = 5, | ||
296 | .max_signal = 5, | ||
297 | .muxval = 2, | ||
298 | .cctl = 0, | ||
299 | .periph_buses = PL08X_AHB2, | ||
300 | }, { | ||
301 | .bus_id = "ext3_rx", | ||
302 | .min_signal = 6, | ||
303 | .max_signal = 6, | ||
304 | .muxval = 2, | ||
305 | .cctl = 0, | ||
306 | .periph_buses = PL08X_AHB2, | ||
307 | }, { | ||
308 | .bus_id = "ext3_tx", | ||
309 | .min_signal = 7, | ||
310 | .max_signal = 7, | ||
311 | .muxval = 2, | ||
312 | .cctl = 0, | ||
313 | .periph_buses = PL08X_AHB2, | ||
314 | }, { | ||
315 | .bus_id = "ext4_rx", | ||
316 | .min_signal = 8, | ||
317 | .max_signal = 8, | ||
318 | .muxval = 2, | ||
319 | .cctl = 0, | ||
320 | .periph_buses = PL08X_AHB2, | ||
321 | }, { | ||
322 | .bus_id = "ext4_tx", | ||
323 | .min_signal = 9, | ||
324 | .max_signal = 9, | ||
325 | .muxval = 2, | ||
326 | .cctl = 0, | ||
327 | .periph_buses = PL08X_AHB2, | ||
328 | }, { | ||
329 | .bus_id = "ext5_rx", | ||
330 | .min_signal = 10, | ||
331 | .max_signal = 10, | ||
332 | .muxval = 2, | ||
333 | .cctl = 0, | ||
334 | .periph_buses = PL08X_AHB2, | ||
335 | }, { | ||
336 | .bus_id = "ext5_tx", | ||
337 | .min_signal = 11, | ||
338 | .max_signal = 11, | ||
339 | .muxval = 2, | ||
340 | .cctl = 0, | ||
341 | .periph_buses = PL08X_AHB2, | ||
342 | }, { | ||
343 | .bus_id = "ext6_rx", | ||
344 | .min_signal = 12, | ||
345 | .max_signal = 12, | ||
346 | .muxval = 2, | ||
347 | .cctl = 0, | ||
348 | .periph_buses = PL08X_AHB2, | ||
349 | }, { | ||
350 | .bus_id = "ext6_tx", | ||
351 | .min_signal = 13, | ||
352 | .max_signal = 13, | ||
353 | .muxval = 2, | ||
354 | .cctl = 0, | ||
355 | .periph_buses = PL08X_AHB2, | ||
356 | }, { | ||
357 | .bus_id = "ext7_rx", | ||
358 | .min_signal = 14, | ||
359 | .max_signal = 14, | ||
360 | .muxval = 2, | ||
361 | .cctl = 0, | ||
362 | .periph_buses = PL08X_AHB2, | ||
363 | }, { | ||
364 | .bus_id = "ext7_tx", | ||
365 | .min_signal = 15, | ||
366 | .max_signal = 15, | ||
367 | .muxval = 2, | ||
368 | .cctl = 0, | ||
369 | .periph_buses = PL08X_AHB2, | ||
370 | }, | ||
371 | }; | ||
372 | |||
373 | struct pl08x_platform_data pl080_plat_data = { | ||
374 | .memcpy_channel = { | ||
375 | .bus_id = "memcpy", | ||
376 | .cctl = (PL080_BSIZE_16 << PL080_CONTROL_SB_SIZE_SHIFT | \ | ||
377 | PL080_BSIZE_16 << PL080_CONTROL_DB_SIZE_SHIFT | \ | ||
378 | PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT | \ | ||
379 | PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT | \ | ||
380 | PL080_CONTROL_PROT_BUFF | PL080_CONTROL_PROT_CACHE | \ | ||
381 | PL080_CONTROL_PROT_SYS), | ||
382 | }, | ||
383 | .lli_buses = PL08X_AHB1, | ||
384 | .mem_buses = PL08X_AHB1, | ||
385 | .get_signal = pl080_get_signal, | ||
386 | .put_signal = pl080_put_signal, | ||
387 | .slave_channels = spear600_dma_info, | ||
388 | .num_slave_channels = ARRAY_SIZE(spear600_dma_info), | ||
389 | }; | ||
390 | |||
391 | /* | ||
392 | * Following will create 16MB static virtual/physical mappings | ||
393 | * PHYSICAL VIRTUAL | ||
394 | * 0xF0000000 0xF0000000 | ||
395 | * 0xF1000000 0xF1000000 | ||
396 | * 0xD0000000 0xFD000000 | ||
397 | * 0xFC000000 0xFC000000 | ||
398 | */ | ||
399 | struct map_desc spear6xx_io_desc[] __initdata = { | ||
400 | { | ||
401 | .virtual = VA_SPEAR6XX_ML_CPU_BASE, | ||
402 | .pfn = __phys_to_pfn(SPEAR6XX_ML_CPU_BASE), | ||
403 | .length = 2 * SZ_16M, | ||
404 | .type = MT_DEVICE | ||
405 | }, { | ||
406 | .virtual = VA_SPEAR6XX_ICM1_BASE, | ||
407 | .pfn = __phys_to_pfn(SPEAR6XX_ICM1_BASE), | ||
408 | .length = SZ_16M, | ||
46 | .type = MT_DEVICE | 409 | .type = MT_DEVICE |
47 | }, { | 410 | }, { |
48 | .virtual = VA_SPEAR6XX_ICM3_MISC_REG_BASE, | 411 | .virtual = VA_SPEAR6XX_ICM3_SMI_CTRL_BASE, |
49 | .pfn = __phys_to_pfn(SPEAR6XX_ICM3_MISC_REG_BASE), | 412 | .pfn = __phys_to_pfn(SPEAR6XX_ICM3_SMI_CTRL_BASE), |
50 | .length = SZ_4K, | 413 | .length = SZ_16M, |
51 | .type = MT_DEVICE | 414 | .type = MT_DEVICE |
52 | }, | 415 | }, |
53 | }; | 416 | }; |
@@ -56,9 +419,6 @@ static struct map_desc spear6xx_io_desc[] __initdata = { | |||
56 | void __init spear6xx_map_io(void) | 419 | void __init spear6xx_map_io(void) |
57 | { | 420 | { |
58 | iotable_init(spear6xx_io_desc, ARRAY_SIZE(spear6xx_io_desc)); | 421 | iotable_init(spear6xx_io_desc, ARRAY_SIZE(spear6xx_io_desc)); |
59 | |||
60 | /* This will initialize clock framework */ | ||
61 | spear6xx_clk_init(); | ||
62 | } | 422 | } |
63 | 423 | ||
64 | static void __init spear6xx_timer_init(void) | 424 | static void __init spear6xx_timer_init(void) |
@@ -66,6 +426,8 @@ static void __init spear6xx_timer_init(void) | |||
66 | char pclk_name[] = "pll3_48m_clk"; | 426 | char pclk_name[] = "pll3_48m_clk"; |
67 | struct clk *gpt_clk, *pclk; | 427 | struct clk *gpt_clk, *pclk; |
68 | 428 | ||
429 | spear6xx_clk_init(); | ||
430 | |||
69 | /* get the system timer clock */ | 431 | /* get the system timer clock */ |
70 | gpt_clk = clk_get_sys("gpt0", NULL); | 432 | gpt_clk = clk_get_sys("gpt0", NULL); |
71 | if (IS_ERR(gpt_clk)) { | 433 | if (IS_ERR(gpt_clk)) { |
@@ -85,16 +447,24 @@ static void __init spear6xx_timer_init(void) | |||
85 | clk_put(gpt_clk); | 447 | clk_put(gpt_clk); |
86 | clk_put(pclk); | 448 | clk_put(pclk); |
87 | 449 | ||
88 | spear_setup_timer(); | 450 | spear_setup_of_timer(); |
89 | } | 451 | } |
90 | 452 | ||
91 | struct sys_timer spear6xx_timer = { | 453 | struct sys_timer spear6xx_timer = { |
92 | .init = spear6xx_timer_init, | 454 | .init = spear6xx_timer_init, |
93 | }; | 455 | }; |
94 | 456 | ||
457 | /* Add auxdata to pass platform data */ | ||
458 | struct of_dev_auxdata spear6xx_auxdata_lookup[] __initdata = { | ||
459 | OF_DEV_AUXDATA("arm,pl080", SPEAR6XX_ICM3_DMA_BASE, NULL, | ||
460 | &pl080_plat_data), | ||
461 | {} | ||
462 | }; | ||
463 | |||
95 | static void __init spear600_dt_init(void) | 464 | static void __init spear600_dt_init(void) |
96 | { | 465 | { |
97 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); | 466 | of_platform_populate(NULL, of_default_bus_match_table, |
467 | spear6xx_auxdata_lookup, NULL); | ||
98 | } | 468 | } |
99 | 469 | ||
100 | static const char *spear600_dt_board_compat[] = { | 470 | static const char *spear600_dt_board_compat[] = { |
diff --git a/arch/arm/mach-u300/core.c b/arch/arm/mach-u300/core.c index 1621ad07d284..33339745d432 100644 --- a/arch/arm/mach-u300/core.c +++ b/arch/arm/mach-u300/core.c | |||
@@ -1667,8 +1667,10 @@ void __init u300_init_irq(void) | |||
1667 | 1667 | ||
1668 | for (i = 0; i < U300_VIC_IRQS_END; i++) | 1668 | for (i = 0; i < U300_VIC_IRQS_END; i++) |
1669 | set_bit(i, (unsigned long *) &mask[0]); | 1669 | set_bit(i, (unsigned long *) &mask[0]); |
1670 | vic_init((void __iomem *) U300_INTCON0_VBASE, 0, mask[0], mask[0]); | 1670 | vic_init((void __iomem *) U300_INTCON0_VBASE, IRQ_U300_INTCON0_START, |
1671 | vic_init((void __iomem *) U300_INTCON1_VBASE, 32, mask[1], mask[1]); | 1671 | mask[0], mask[0]); |
1672 | vic_init((void __iomem *) U300_INTCON1_VBASE, IRQ_U300_INTCON1_START, | ||
1673 | mask[1], mask[1]); | ||
1672 | } | 1674 | } |
1673 | 1675 | ||
1674 | 1676 | ||
diff --git a/arch/arm/mach-u300/i2c.c b/arch/arm/mach-u300/i2c.c index a38f80238ea9..cb04bd6ab3e7 100644 --- a/arch/arm/mach-u300/i2c.c +++ b/arch/arm/mach-u300/i2c.c | |||
@@ -146,9 +146,6 @@ static struct ab3100_platform_data ab3100_plf_data = { | |||
146 | .min_uV = 1800000, | 146 | .min_uV = 1800000, |
147 | .max_uV = 1800000, | 147 | .max_uV = 1800000, |
148 | .valid_modes_mask = REGULATOR_MODE_NORMAL, | 148 | .valid_modes_mask = REGULATOR_MODE_NORMAL, |
149 | .valid_ops_mask = | ||
150 | REGULATOR_CHANGE_VOLTAGE | | ||
151 | REGULATOR_CHANGE_STATUS, | ||
152 | .always_on = 1, | 149 | .always_on = 1, |
153 | .boot_on = 1, | 150 | .boot_on = 1, |
154 | }, | 151 | }, |
@@ -160,9 +157,6 @@ static struct ab3100_platform_data ab3100_plf_data = { | |||
160 | .min_uV = 2500000, | 157 | .min_uV = 2500000, |
161 | .max_uV = 2500000, | 158 | .max_uV = 2500000, |
162 | .valid_modes_mask = REGULATOR_MODE_NORMAL, | 159 | .valid_modes_mask = REGULATOR_MODE_NORMAL, |
163 | .valid_ops_mask = | ||
164 | REGULATOR_CHANGE_VOLTAGE | | ||
165 | REGULATOR_CHANGE_STATUS, | ||
166 | .always_on = 1, | 160 | .always_on = 1, |
167 | .boot_on = 1, | 161 | .boot_on = 1, |
168 | }, | 162 | }, |
@@ -230,8 +224,7 @@ static struct ab3100_platform_data ab3100_plf_data = { | |||
230 | .max_uV = 1800000, | 224 | .max_uV = 1800000, |
231 | .valid_modes_mask = REGULATOR_MODE_NORMAL, | 225 | .valid_modes_mask = REGULATOR_MODE_NORMAL, |
232 | .valid_ops_mask = | 226 | .valid_ops_mask = |
233 | REGULATOR_CHANGE_VOLTAGE | | 227 | REGULATOR_CHANGE_VOLTAGE, |
234 | REGULATOR_CHANGE_STATUS, | ||
235 | .always_on = 1, | 228 | .always_on = 1, |
236 | .boot_on = 1, | 229 | .boot_on = 1, |
237 | }, | 230 | }, |
diff --git a/arch/arm/mach-u300/include/mach/irqs.h b/arch/arm/mach-u300/include/mach/irqs.h index ee78a26707eb..ec09c1e07b1a 100644 --- a/arch/arm/mach-u300/include/mach/irqs.h +++ b/arch/arm/mach-u300/include/mach/irqs.h | |||
@@ -12,101 +12,101 @@ | |||
12 | #ifndef __MACH_IRQS_H | 12 | #ifndef __MACH_IRQS_H |
13 | #define __MACH_IRQS_H | 13 | #define __MACH_IRQS_H |
14 | 14 | ||
15 | #define IRQ_U300_INTCON0_START 0 | 15 | #define IRQ_U300_INTCON0_START 1 |
16 | #define IRQ_U300_INTCON1_START 32 | 16 | #define IRQ_U300_INTCON1_START 33 |
17 | /* These are on INTCON0 - 30 lines */ | 17 | /* These are on INTCON0 - 30 lines */ |
18 | #define IRQ_U300_IRQ0_EXT 0 | 18 | #define IRQ_U300_IRQ0_EXT 1 |
19 | #define IRQ_U300_IRQ1_EXT 1 | 19 | #define IRQ_U300_IRQ1_EXT 2 |
20 | #define IRQ_U300_DMA 2 | 20 | #define IRQ_U300_DMA 3 |
21 | #define IRQ_U300_VIDEO_ENC_0 3 | 21 | #define IRQ_U300_VIDEO_ENC_0 4 |
22 | #define IRQ_U300_VIDEO_ENC_1 4 | 22 | #define IRQ_U300_VIDEO_ENC_1 5 |
23 | #define IRQ_U300_AAIF_RX 5 | 23 | #define IRQ_U300_AAIF_RX 6 |
24 | #define IRQ_U300_AAIF_TX 6 | 24 | #define IRQ_U300_AAIF_TX 7 |
25 | #define IRQ_U300_AAIF_VGPIO 7 | 25 | #define IRQ_U300_AAIF_VGPIO 8 |
26 | #define IRQ_U300_AAIF_WAKEUP 8 | 26 | #define IRQ_U300_AAIF_WAKEUP 9 |
27 | #define IRQ_U300_PCM_I2S0_FRAME 9 | 27 | #define IRQ_U300_PCM_I2S0_FRAME 10 |
28 | #define IRQ_U300_PCM_I2S0_FIFO 10 | 28 | #define IRQ_U300_PCM_I2S0_FIFO 11 |
29 | #define IRQ_U300_PCM_I2S1_FRAME 11 | 29 | #define IRQ_U300_PCM_I2S1_FRAME 12 |
30 | #define IRQ_U300_PCM_I2S1_FIFO 12 | 30 | #define IRQ_U300_PCM_I2S1_FIFO 13 |
31 | #define IRQ_U300_XGAM_GAMCON 13 | 31 | #define IRQ_U300_XGAM_GAMCON 14 |
32 | #define IRQ_U300_XGAM_CDI 14 | 32 | #define IRQ_U300_XGAM_CDI 15 |
33 | #define IRQ_U300_XGAM_CDICON 15 | 33 | #define IRQ_U300_XGAM_CDICON 16 |
34 | #if defined(CONFIG_MACH_U300_BS2X) || defined(CONFIG_MACH_U300_BS330) | 34 | #if defined(CONFIG_MACH_U300_BS2X) || defined(CONFIG_MACH_U300_BS330) |
35 | /* MMIACC not used on the DB3210 or DB3350 chips */ | 35 | /* MMIACC not used on the DB3210 or DB3350 chips */ |
36 | #define IRQ_U300_XGAM_MMIACC 16 | 36 | #define IRQ_U300_XGAM_MMIACC 17 |
37 | #endif | 37 | #endif |
38 | #define IRQ_U300_XGAM_PDI 17 | 38 | #define IRQ_U300_XGAM_PDI 18 |
39 | #define IRQ_U300_XGAM_PDICON 18 | 39 | #define IRQ_U300_XGAM_PDICON 19 |
40 | #define IRQ_U300_XGAM_GAMEACC 19 | 40 | #define IRQ_U300_XGAM_GAMEACC 20 |
41 | #define IRQ_U300_XGAM_MCIDCT 20 | 41 | #define IRQ_U300_XGAM_MCIDCT 21 |
42 | #define IRQ_U300_APEX 21 | 42 | #define IRQ_U300_APEX 22 |
43 | #define IRQ_U300_UART0 22 | 43 | #define IRQ_U300_UART0 23 |
44 | #define IRQ_U300_SPI 23 | 44 | #define IRQ_U300_SPI 24 |
45 | #define IRQ_U300_TIMER_APP_OS 24 | 45 | #define IRQ_U300_TIMER_APP_OS 25 |
46 | #define IRQ_U300_TIMER_APP_DD 25 | 46 | #define IRQ_U300_TIMER_APP_DD 26 |
47 | #define IRQ_U300_TIMER_APP_GP1 26 | 47 | #define IRQ_U300_TIMER_APP_GP1 27 |
48 | #define IRQ_U300_TIMER_APP_GP2 27 | 48 | #define IRQ_U300_TIMER_APP_GP2 28 |
49 | #define IRQ_U300_TIMER_OS 28 | 49 | #define IRQ_U300_TIMER_OS 29 |
50 | #define IRQ_U300_TIMER_MS 29 | 50 | #define IRQ_U300_TIMER_MS 30 |
51 | #define IRQ_U300_KEYPAD_KEYBF 30 | 51 | #define IRQ_U300_KEYPAD_KEYBF 31 |
52 | #define IRQ_U300_KEYPAD_KEYBR 31 | 52 | #define IRQ_U300_KEYPAD_KEYBR 32 |
53 | /* These are on INTCON1 - 32 lines */ | 53 | /* These are on INTCON1 - 32 lines */ |
54 | #define IRQ_U300_GPIO_PORT0 32 | 54 | #define IRQ_U300_GPIO_PORT0 33 |
55 | #define IRQ_U300_GPIO_PORT1 33 | 55 | #define IRQ_U300_GPIO_PORT1 34 |
56 | #define IRQ_U300_GPIO_PORT2 34 | 56 | #define IRQ_U300_GPIO_PORT2 35 |
57 | 57 | ||
58 | #if defined(CONFIG_MACH_U300_BS2X) || defined(CONFIG_MACH_U300_BS330) || \ | 58 | #if defined(CONFIG_MACH_U300_BS2X) || defined(CONFIG_MACH_U300_BS330) || \ |
59 | defined(CONFIG_MACH_U300_BS335) | 59 | defined(CONFIG_MACH_U300_BS335) |
60 | /* These are for DB3150, DB3200 and DB3350 */ | 60 | /* These are for DB3150, DB3200 and DB3350 */ |
61 | #define IRQ_U300_WDOG 35 | 61 | #define IRQ_U300_WDOG 36 |
62 | #define IRQ_U300_EVHIST 36 | 62 | #define IRQ_U300_EVHIST 37 |
63 | #define IRQ_U300_MSPRO 37 | 63 | #define IRQ_U300_MSPRO 38 |
64 | #define IRQ_U300_MMCSD_MCIINTR0 38 | 64 | #define IRQ_U300_MMCSD_MCIINTR0 39 |
65 | #define IRQ_U300_MMCSD_MCIINTR1 39 | 65 | #define IRQ_U300_MMCSD_MCIINTR1 40 |
66 | #define IRQ_U300_I2C0 40 | 66 | #define IRQ_U300_I2C0 41 |
67 | #define IRQ_U300_I2C1 41 | 67 | #define IRQ_U300_I2C1 42 |
68 | #define IRQ_U300_RTC 42 | 68 | #define IRQ_U300_RTC 43 |
69 | #define IRQ_U300_NFIF 43 | 69 | #define IRQ_U300_NFIF 44 |
70 | #define IRQ_U300_NFIF2 44 | 70 | #define IRQ_U300_NFIF2 45 |
71 | #endif | 71 | #endif |
72 | 72 | ||
73 | /* DB3150 and DB3200 have only 45 IRQs */ | 73 | /* DB3150 and DB3200 have only 45 IRQs */ |
74 | #if defined(CONFIG_MACH_U300_BS2X) || defined(CONFIG_MACH_U300_BS330) | 74 | #if defined(CONFIG_MACH_U300_BS2X) || defined(CONFIG_MACH_U300_BS330) |
75 | #define U300_VIC_IRQS_END 45 | 75 | #define U300_VIC_IRQS_END 46 |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | /* The DB3350-specific interrupt lines */ | 78 | /* The DB3350-specific interrupt lines */ |
79 | #ifdef CONFIG_MACH_U300_BS335 | 79 | #ifdef CONFIG_MACH_U300_BS335 |
80 | #define IRQ_U300_ISP_F0 45 | 80 | #define IRQ_U300_ISP_F0 46 |
81 | #define IRQ_U300_ISP_F1 46 | 81 | #define IRQ_U300_ISP_F1 47 |
82 | #define IRQ_U300_ISP_F2 47 | 82 | #define IRQ_U300_ISP_F2 48 |
83 | #define IRQ_U300_ISP_F3 48 | 83 | #define IRQ_U300_ISP_F3 49 |
84 | #define IRQ_U300_ISP_F4 49 | 84 | #define IRQ_U300_ISP_F4 50 |
85 | #define IRQ_U300_GPIO_PORT3 50 | 85 | #define IRQ_U300_GPIO_PORT3 51 |
86 | #define IRQ_U300_SYSCON_PLL_LOCK 51 | 86 | #define IRQ_U300_SYSCON_PLL_LOCK 52 |
87 | #define IRQ_U300_UART1 52 | 87 | #define IRQ_U300_UART1 53 |
88 | #define IRQ_U300_GPIO_PORT4 53 | 88 | #define IRQ_U300_GPIO_PORT4 54 |
89 | #define IRQ_U300_GPIO_PORT5 54 | 89 | #define IRQ_U300_GPIO_PORT5 55 |
90 | #define IRQ_U300_GPIO_PORT6 55 | 90 | #define IRQ_U300_GPIO_PORT6 56 |
91 | #define U300_VIC_IRQS_END 56 | 91 | #define U300_VIC_IRQS_END 57 |
92 | #endif | 92 | #endif |
93 | 93 | ||
94 | /* The DB3210-specific interrupt lines */ | 94 | /* The DB3210-specific interrupt lines */ |
95 | #ifdef CONFIG_MACH_U300_BS365 | 95 | #ifdef CONFIG_MACH_U300_BS365 |
96 | #define IRQ_U300_GPIO_PORT3 35 | 96 | #define IRQ_U300_GPIO_PORT3 36 |
97 | #define IRQ_U300_GPIO_PORT4 36 | 97 | #define IRQ_U300_GPIO_PORT4 37 |
98 | #define IRQ_U300_WDOG 37 | 98 | #define IRQ_U300_WDOG 38 |
99 | #define IRQ_U300_EVHIST 38 | 99 | #define IRQ_U300_EVHIST 39 |
100 | #define IRQ_U300_MSPRO 39 | 100 | #define IRQ_U300_MSPRO 40 |
101 | #define IRQ_U300_MMCSD_MCIINTR0 40 | 101 | #define IRQ_U300_MMCSD_MCIINTR0 41 |
102 | #define IRQ_U300_MMCSD_MCIINTR1 41 | 102 | #define IRQ_U300_MMCSD_MCIINTR1 42 |
103 | #define IRQ_U300_I2C0 42 | 103 | #define IRQ_U300_I2C0 43 |
104 | #define IRQ_U300_I2C1 43 | 104 | #define IRQ_U300_I2C1 44 |
105 | #define IRQ_U300_RTC 44 | 105 | #define IRQ_U300_RTC 45 |
106 | #define IRQ_U300_NFIF 45 | 106 | #define IRQ_U300_NFIF 46 |
107 | #define IRQ_U300_NFIF2 46 | 107 | #define IRQ_U300_NFIF2 47 |
108 | #define IRQ_U300_SYSCON_PLL_LOCK 47 | 108 | #define IRQ_U300_SYSCON_PLL_LOCK 48 |
109 | #define U300_VIC_IRQS_END 48 | 109 | #define U300_VIC_IRQS_END 49 |
110 | #endif | 110 | #endif |
111 | 111 | ||
112 | /* Maximum 8*7 GPIO lines */ | 112 | /* Maximum 8*7 GPIO lines */ |
@@ -117,6 +117,6 @@ | |||
117 | #define IRQ_U300_GPIO_END (U300_VIC_IRQS_END) | 117 | #define IRQ_U300_GPIO_END (U300_VIC_IRQS_END) |
118 | #endif | 118 | #endif |
119 | 119 | ||
120 | #define NR_IRQS (IRQ_U300_GPIO_END) | 120 | #define NR_IRQS (IRQ_U300_GPIO_END - IRQ_U300_INTCON0_START) |
121 | 121 | ||
122 | #endif | 122 | #endif |
diff --git a/arch/arm/mach-ux500/mbox-db5500.c b/arch/arm/mach-ux500/mbox-db5500.c index 2b2d51caf9d8..0127490218cd 100644 --- a/arch/arm/mach-ux500/mbox-db5500.c +++ b/arch/arm/mach-ux500/mbox-db5500.c | |||
@@ -168,7 +168,7 @@ static ssize_t mbox_read_fifo(struct device *dev, | |||
168 | return sprintf(buf, "0x%X\n", mbox_value); | 168 | return sprintf(buf, "0x%X\n", mbox_value); |
169 | } | 169 | } |
170 | 170 | ||
171 | static DEVICE_ATTR(fifo, S_IWUGO | S_IRUGO, mbox_read_fifo, mbox_write_fifo); | 171 | static DEVICE_ATTR(fifo, S_IWUSR | S_IRUGO, mbox_read_fifo, mbox_write_fifo); |
172 | 172 | ||
173 | static int mbox_show(struct seq_file *s, void *data) | 173 | static int mbox_show(struct seq_file *s, void *data) |
174 | { | 174 | { |
diff --git a/arch/arm/mm/abort-ev6.S b/arch/arm/mm/abort-ev6.S index ff1f7cc11f87..80741992a9fc 100644 --- a/arch/arm/mm/abort-ev6.S +++ b/arch/arm/mm/abort-ev6.S | |||
@@ -26,18 +26,23 @@ ENTRY(v6_early_abort) | |||
26 | mrc p15, 0, r1, c5, c0, 0 @ get FSR | 26 | mrc p15, 0, r1, c5, c0, 0 @ get FSR |
27 | mrc p15, 0, r0, c6, c0, 0 @ get FAR | 27 | mrc p15, 0, r0, c6, c0, 0 @ get FAR |
28 | /* | 28 | /* |
29 | * Faulty SWP instruction on 1136 doesn't set bit 11 in DFSR (erratum 326103). | 29 | * Faulty SWP instruction on 1136 doesn't set bit 11 in DFSR. |
30 | * The test below covers all the write situations, including Java bytecodes | ||
31 | */ | 30 | */ |
32 | bic r1, r1, #1 << 11 @ clear bit 11 of FSR | 31 | #ifdef CONFIG_ARM_ERRATA_326103 |
32 | ldr ip, =0x4107b36 | ||
33 | mrc p15, 0, r3, c0, c0, 0 @ get processor id | ||
34 | teq ip, r3, lsr #4 @ r0 ARM1136? | ||
35 | bne do_DataAbort | ||
33 | tst r5, #PSR_J_BIT @ Java? | 36 | tst r5, #PSR_J_BIT @ Java? |
37 | tsteq r5, #PSR_T_BIT @ Thumb? | ||
34 | bne do_DataAbort | 38 | bne do_DataAbort |
35 | do_thumb_abort fsr=r1, pc=r4, psr=r5, tmp=r3 | 39 | bic r1, r1, #1 << 11 @ clear bit 11 of FSR |
36 | ldreq r3, [r4] @ read aborted ARM instruction | 40 | ldr r3, [r4] @ read aborted ARM instruction |
37 | #ifdef CONFIG_CPU_ENDIAN_BE8 | 41 | #ifdef CONFIG_CPU_ENDIAN_BE8 |
38 | reveq r3, r3 | 42 | rev r3, r3 |
39 | #endif | 43 | #endif |
40 | do_ldrd_abort tmp=ip, insn=r3 | 44 | do_ldrd_abort tmp=ip, insn=r3 |
41 | tst r3, #1 << 20 @ L = 0 -> write | 45 | tst r3, #1 << 20 @ L = 0 -> write |
42 | orreq r1, r1, #1 << 11 @ yes. | 46 | orreq r1, r1, #1 << 11 @ yes. |
47 | #endif | ||
43 | b do_DataAbort | 48 | b do_DataAbort |
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c index a53fd2aaa2f4..2a8e380501e8 100644 --- a/arch/arm/mm/cache-l2x0.c +++ b/arch/arm/mm/cache-l2x0.c | |||
@@ -32,6 +32,7 @@ static void __iomem *l2x0_base; | |||
32 | static DEFINE_RAW_SPINLOCK(l2x0_lock); | 32 | static DEFINE_RAW_SPINLOCK(l2x0_lock); |
33 | static u32 l2x0_way_mask; /* Bitmask of active ways */ | 33 | static u32 l2x0_way_mask; /* Bitmask of active ways */ |
34 | static u32 l2x0_size; | 34 | static u32 l2x0_size; |
35 | static unsigned long sync_reg_offset = L2X0_CACHE_SYNC; | ||
35 | 36 | ||
36 | struct l2x0_regs l2x0_saved_regs; | 37 | struct l2x0_regs l2x0_saved_regs; |
37 | 38 | ||
@@ -61,12 +62,7 @@ static inline void cache_sync(void) | |||
61 | { | 62 | { |
62 | void __iomem *base = l2x0_base; | 63 | void __iomem *base = l2x0_base; |
63 | 64 | ||
64 | #ifdef CONFIG_PL310_ERRATA_753970 | 65 | writel_relaxed(0, base + sync_reg_offset); |
65 | /* write to an unmmapped register */ | ||
66 | writel_relaxed(0, base + L2X0_DUMMY_REG); | ||
67 | #else | ||
68 | writel_relaxed(0, base + L2X0_CACHE_SYNC); | ||
69 | #endif | ||
70 | cache_wait(base + L2X0_CACHE_SYNC, 1); | 66 | cache_wait(base + L2X0_CACHE_SYNC, 1); |
71 | } | 67 | } |
72 | 68 | ||
@@ -85,10 +81,13 @@ static inline void l2x0_inv_line(unsigned long addr) | |||
85 | } | 81 | } |
86 | 82 | ||
87 | #if defined(CONFIG_PL310_ERRATA_588369) || defined(CONFIG_PL310_ERRATA_727915) | 83 | #if defined(CONFIG_PL310_ERRATA_588369) || defined(CONFIG_PL310_ERRATA_727915) |
84 | static inline void debug_writel(unsigned long val) | ||
85 | { | ||
86 | if (outer_cache.set_debug) | ||
87 | outer_cache.set_debug(val); | ||
88 | } | ||
88 | 89 | ||
89 | #define debug_writel(val) outer_cache.set_debug(val) | 90 | static void pl310_set_debug(unsigned long val) |
90 | |||
91 | static void l2x0_set_debug(unsigned long val) | ||
92 | { | 91 | { |
93 | writel_relaxed(val, l2x0_base + L2X0_DEBUG_CTRL); | 92 | writel_relaxed(val, l2x0_base + L2X0_DEBUG_CTRL); |
94 | } | 93 | } |
@@ -98,7 +97,7 @@ static inline void debug_writel(unsigned long val) | |||
98 | { | 97 | { |
99 | } | 98 | } |
100 | 99 | ||
101 | #define l2x0_set_debug NULL | 100 | #define pl310_set_debug NULL |
102 | #endif | 101 | #endif |
103 | 102 | ||
104 | #ifdef CONFIG_PL310_ERRATA_588369 | 103 | #ifdef CONFIG_PL310_ERRATA_588369 |
@@ -331,6 +330,11 @@ void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask) | |||
331 | else | 330 | else |
332 | ways = 8; | 331 | ways = 8; |
333 | type = "L310"; | 332 | type = "L310"; |
333 | #ifdef CONFIG_PL310_ERRATA_753970 | ||
334 | /* Unmapped register. */ | ||
335 | sync_reg_offset = L2X0_DUMMY_REG; | ||
336 | #endif | ||
337 | outer_cache.set_debug = pl310_set_debug; | ||
334 | break; | 338 | break; |
335 | case L2X0_CACHE_ID_PART_L210: | 339 | case L2X0_CACHE_ID_PART_L210: |
336 | ways = (aux >> 13) & 0xf; | 340 | ways = (aux >> 13) & 0xf; |
@@ -379,7 +383,6 @@ void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask) | |||
379 | outer_cache.flush_all = l2x0_flush_all; | 383 | outer_cache.flush_all = l2x0_flush_all; |
380 | outer_cache.inv_all = l2x0_inv_all; | 384 | outer_cache.inv_all = l2x0_inv_all; |
381 | outer_cache.disable = l2x0_disable; | 385 | outer_cache.disable = l2x0_disable; |
382 | outer_cache.set_debug = l2x0_set_debug; | ||
383 | 386 | ||
384 | printk(KERN_INFO "%s cache controller enabled\n", type); | 387 | printk(KERN_INFO "%s cache controller enabled\n", type); |
385 | printk(KERN_INFO "l2x0: %d ways, CACHE_ID 0x%08x, AUX_CTRL 0x%08x, Cache size: %d B\n", | 388 | printk(KERN_INFO "l2x0: %d ways, CACHE_ID 0x%08x, AUX_CTRL 0x%08x, Cache size: %d B\n", |
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 595079fa9d1d..8f5813bbffb5 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c | |||
@@ -293,11 +293,11 @@ EXPORT_SYMBOL(pfn_valid); | |||
293 | #endif | 293 | #endif |
294 | 294 | ||
295 | #ifndef CONFIG_SPARSEMEM | 295 | #ifndef CONFIG_SPARSEMEM |
296 | static void arm_memory_present(void) | 296 | static void __init arm_memory_present(void) |
297 | { | 297 | { |
298 | } | 298 | } |
299 | #else | 299 | #else |
300 | static void arm_memory_present(void) | 300 | static void __init arm_memory_present(void) |
301 | { | 301 | { |
302 | struct memblock_region *reg; | 302 | struct memblock_region *reg; |
303 | 303 | ||
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index b86f8933ff91..2c7cf2f9c837 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c | |||
@@ -618,8 +618,8 @@ static void __init alloc_init_section(pud_t *pud, unsigned long addr, | |||
618 | } | 618 | } |
619 | } | 619 | } |
620 | 620 | ||
621 | static void alloc_init_pud(pgd_t *pgd, unsigned long addr, unsigned long end, | 621 | static void __init alloc_init_pud(pgd_t *pgd, unsigned long addr, |
622 | unsigned long phys, const struct mem_type *type) | 622 | unsigned long end, unsigned long phys, const struct mem_type *type) |
623 | { | 623 | { |
624 | pud_t *pud = pud_offset(pgd, addr); | 624 | pud_t *pud = pud_offset(pgd, addr); |
625 | unsigned long next; | 625 | unsigned long next; |
diff --git a/arch/arm/plat-mxc/clock.c b/arch/arm/plat-mxc/clock.c index 2ed3ab173add..5079787273d2 100644 --- a/arch/arm/plat-mxc/clock.c +++ b/arch/arm/plat-mxc/clock.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <mach/clock.h> | 41 | #include <mach/clock.h> |
42 | #include <mach/hardware.h> | 42 | #include <mach/hardware.h> |
43 | 43 | ||
44 | #ifndef CONFIG_COMMON_CLK | ||
44 | static LIST_HEAD(clocks); | 45 | static LIST_HEAD(clocks); |
45 | static DEFINE_MUTEX(clocks_mutex); | 46 | static DEFINE_MUTEX(clocks_mutex); |
46 | 47 | ||
@@ -200,6 +201,16 @@ struct clk *clk_get_parent(struct clk *clk) | |||
200 | } | 201 | } |
201 | EXPORT_SYMBOL(clk_get_parent); | 202 | EXPORT_SYMBOL(clk_get_parent); |
202 | 203 | ||
204 | #else | ||
205 | |||
206 | /* | ||
207 | * Lock to protect the clock module (ccm) registers. Used | ||
208 | * on all i.MXs | ||
209 | */ | ||
210 | DEFINE_SPINLOCK(imx_ccm_lock); | ||
211 | |||
212 | #endif /* CONFIG_COMMON_CLK */ | ||
213 | |||
203 | /* | 214 | /* |
204 | * Get the resulting clock rate from a PLL register value and the input | 215 | * Get the resulting clock rate from a PLL register value and the input |
205 | * frequency. PLLs with this register layout can at least be found on | 216 | * frequency. PLLs with this register layout can at least be found on |
diff --git a/arch/arm/plat-mxc/include/mach/clock.h b/arch/arm/plat-mxc/include/mach/clock.h index 753a5988d85c..bd940c795cbb 100644 --- a/arch/arm/plat-mxc/include/mach/clock.h +++ b/arch/arm/plat-mxc/include/mach/clock.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #ifndef __ASSEMBLY__ | 23 | #ifndef __ASSEMBLY__ |
24 | #include <linux/list.h> | 24 | #include <linux/list.h> |
25 | 25 | ||
26 | #ifndef CONFIG_COMMON_CLK | ||
26 | struct module; | 27 | struct module; |
27 | 28 | ||
28 | struct clk { | 29 | struct clk { |
@@ -59,6 +60,9 @@ struct clk { | |||
59 | 60 | ||
60 | int clk_register(struct clk *clk); | 61 | int clk_register(struct clk *clk); |
61 | void clk_unregister(struct clk *clk); | 62 | void clk_unregister(struct clk *clk); |
63 | #endif /* CONFIG_COMMON_CLK */ | ||
64 | |||
65 | extern spinlock_t imx_ccm_lock; | ||
62 | 66 | ||
63 | unsigned long mxc_decode_pll(unsigned int pll, u32 f_ref); | 67 | unsigned long mxc_decode_pll(unsigned int pll, u32 f_ref); |
64 | 68 | ||
diff --git a/arch/arm/plat-mxc/time.c b/arch/arm/plat-mxc/time.c index 7daf7c9a413b..99f958ca6cb8 100644 --- a/arch/arm/plat-mxc/time.c +++ b/arch/arm/plat-mxc/time.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/irq.h> | 25 | #include <linux/irq.h> |
26 | #include <linux/clockchips.h> | 26 | #include <linux/clockchips.h> |
27 | #include <linux/clk.h> | 27 | #include <linux/clk.h> |
28 | #include <linux/err.h> | ||
28 | 29 | ||
29 | #include <mach/hardware.h> | 30 | #include <mach/hardware.h> |
30 | #include <asm/sched_clock.h> | 31 | #include <asm/sched_clock.h> |
@@ -282,6 +283,19 @@ static int __init mxc_clockevent_init(struct clk *timer_clk) | |||
282 | void __init mxc_timer_init(struct clk *timer_clk, void __iomem *base, int irq) | 283 | void __init mxc_timer_init(struct clk *timer_clk, void __iomem *base, int irq) |
283 | { | 284 | { |
284 | uint32_t tctl_val; | 285 | uint32_t tctl_val; |
286 | struct clk *timer_ipg_clk; | ||
287 | |||
288 | if (!timer_clk) { | ||
289 | timer_clk = clk_get_sys("imx-gpt.0", "per"); | ||
290 | if (IS_ERR(timer_clk)) { | ||
291 | pr_err("i.MX timer: unable to get clk\n"); | ||
292 | return; | ||
293 | } | ||
294 | |||
295 | timer_ipg_clk = clk_get_sys("imx-gpt.0", "ipg"); | ||
296 | if (!IS_ERR(timer_ipg_clk)) | ||
297 | clk_prepare_enable(timer_ipg_clk); | ||
298 | } | ||
285 | 299 | ||
286 | clk_prepare_enable(timer_clk); | 300 | clk_prepare_enable(timer_clk); |
287 | 301 | ||
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c index ecdb3da0dea9..c58d896cd5c3 100644 --- a/arch/arm/plat-omap/dma.c +++ b/arch/arm/plat-omap/dma.c | |||
@@ -916,6 +916,13 @@ void omap_start_dma(int lch) | |||
916 | l |= OMAP_DMA_CCR_BUFFERING_DISABLE; | 916 | l |= OMAP_DMA_CCR_BUFFERING_DISABLE; |
917 | l |= OMAP_DMA_CCR_EN; | 917 | l |= OMAP_DMA_CCR_EN; |
918 | 918 | ||
919 | /* | ||
920 | * As dma_write() uses IO accessors which are weakly ordered, there | ||
921 | * is no guarantee that data in coherent DMA memory will be visible | ||
922 | * to the DMA device. Add a memory barrier here to ensure that any | ||
923 | * such data is visible prior to enabling DMA. | ||
924 | */ | ||
925 | mb(); | ||
919 | p->dma_write(l, CCR, lch); | 926 | p->dma_write(l, CCR, lch); |
920 | 927 | ||
921 | dma_chan[lch].flags |= OMAP_DMA_ACTIVE; | 928 | dma_chan[lch].flags |= OMAP_DMA_ACTIVE; |
@@ -965,6 +972,13 @@ void omap_stop_dma(int lch) | |||
965 | p->dma_write(l, CCR, lch); | 972 | p->dma_write(l, CCR, lch); |
966 | } | 973 | } |
967 | 974 | ||
975 | /* | ||
976 | * Ensure that data transferred by DMA is visible to any access | ||
977 | * after DMA has been disabled. This is important for coherent | ||
978 | * DMA regions. | ||
979 | */ | ||
980 | mb(); | ||
981 | |||
968 | if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) { | 982 | if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) { |
969 | int next_lch, cur_lch = lch; | 983 | int next_lch, cur_lch = lch; |
970 | char dma_chan_link_map[dma_lch_count]; | 984 | char dma_chan_link_map[dma_lch_count]; |
diff --git a/arch/arm/plat-samsung/include/plat/sdhci.h b/arch/arm/plat-samsung/include/plat/sdhci.h index 317e246ffc56..e834c5ef437c 100644 --- a/arch/arm/plat-samsung/include/plat/sdhci.h +++ b/arch/arm/plat-samsung/include/plat/sdhci.h | |||
@@ -18,6 +18,8 @@ | |||
18 | #ifndef __PLAT_S3C_SDHCI_H | 18 | #ifndef __PLAT_S3C_SDHCI_H |
19 | #define __PLAT_S3C_SDHCI_H __FILE__ | 19 | #define __PLAT_S3C_SDHCI_H __FILE__ |
20 | 20 | ||
21 | #include <plat/devs.h> | ||
22 | |||
21 | struct platform_device; | 23 | struct platform_device; |
22 | struct mmc_host; | 24 | struct mmc_host; |
23 | struct mmc_card; | 25 | struct mmc_card; |
@@ -356,4 +358,30 @@ static inline void exynos4_default_sdhci3(void) { } | |||
356 | 358 | ||
357 | #endif /* CONFIG_EXYNOS4_SETUP_SDHCI */ | 359 | #endif /* CONFIG_EXYNOS4_SETUP_SDHCI */ |
358 | 360 | ||
361 | static inline void s3c_sdhci_setname(int id, char *name) | ||
362 | { | ||
363 | switch (id) { | ||
364 | #ifdef CONFIG_S3C_DEV_HSMMC | ||
365 | case 0: | ||
366 | s3c_device_hsmmc0.name = name; | ||
367 | break; | ||
368 | #endif | ||
369 | #ifdef CONFIG_S3C_DEV_HSMMC1 | ||
370 | case 1: | ||
371 | s3c_device_hsmmc1.name = name; | ||
372 | break; | ||
373 | #endif | ||
374 | #ifdef CONFIG_S3C_DEV_HSMMC2 | ||
375 | case 2: | ||
376 | s3c_device_hsmmc2.name = name; | ||
377 | break; | ||
378 | #endif | ||
379 | #ifdef CONFIG_S3C_DEV_HSMMC3 | ||
380 | case 3: | ||
381 | s3c_device_hsmmc3.name = name; | ||
382 | break; | ||
383 | #endif | ||
384 | } | ||
385 | } | ||
386 | |||
359 | #endif /* __PLAT_S3C_SDHCI_H */ | 387 | #endif /* __PLAT_S3C_SDHCI_H */ |
diff --git a/arch/arm/plat-spear/Kconfig b/arch/arm/plat-spear/Kconfig index 1bb3dbce8810..387655b5ce05 100644 --- a/arch/arm/plat-spear/Kconfig +++ b/arch/arm/plat-spear/Kconfig | |||
@@ -9,9 +9,11 @@ choice | |||
9 | default ARCH_SPEAR3XX | 9 | default ARCH_SPEAR3XX |
10 | 10 | ||
11 | config ARCH_SPEAR3XX | 11 | config ARCH_SPEAR3XX |
12 | bool "SPEAr3XX" | 12 | bool "ST SPEAr3xx with Device Tree" |
13 | select ARM_VIC | 13 | select ARM_VIC |
14 | select CPU_ARM926T | 14 | select CPU_ARM926T |
15 | select USE_OF | ||
16 | select PINCTRL | ||
15 | help | 17 | help |
16 | Supports for ARM's SPEAR3XX family | 18 | Supports for ARM's SPEAR3XX family |
17 | 19 | ||
diff --git a/arch/arm/plat-spear/Makefile b/arch/arm/plat-spear/Makefile index e0f2e5b9530c..38f1235f4632 100644 --- a/arch/arm/plat-spear/Makefile +++ b/arch/arm/plat-spear/Makefile | |||
@@ -3,6 +3,6 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | # Common support | 5 | # Common support |
6 | obj-y := clock.o restart.o time.o | 6 | obj-y := restart.o time.o pl080.o |
7 | 7 | ||
8 | obj-$(CONFIG_ARCH_SPEAR3XX) += shirq.o padmux.o | 8 | obj-$(CONFIG_ARCH_SPEAR3XX) += shirq.o |
diff --git a/arch/arm/plat-spear/clock.c b/arch/arm/plat-spear/clock.c deleted file mode 100644 index 67dd00381ea6..000000000000 --- a/arch/arm/plat-spear/clock.c +++ /dev/null | |||
@@ -1,1005 +0,0 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/clock.c | ||
3 | * | ||
4 | * Clock framework for SPEAr platform | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #include <linux/bug.h> | ||
15 | #include <linux/clk.h> | ||
16 | #include <linux/debugfs.h> | ||
17 | #include <linux/err.h> | ||
18 | #include <linux/io.h> | ||
19 | #include <linux/list.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/spinlock.h> | ||
22 | #include <plat/clock.h> | ||
23 | |||
24 | static DEFINE_SPINLOCK(clocks_lock); | ||
25 | static LIST_HEAD(root_clks); | ||
26 | #ifdef CONFIG_DEBUG_FS | ||
27 | static LIST_HEAD(clocks); | ||
28 | #endif | ||
29 | |||
30 | static void propagate_rate(struct clk *, int on_init); | ||
31 | #ifdef CONFIG_DEBUG_FS | ||
32 | static int clk_debugfs_reparent(struct clk *); | ||
33 | #endif | ||
34 | |||
35 | static int generic_clk_enable(struct clk *clk) | ||
36 | { | ||
37 | unsigned int val; | ||
38 | |||
39 | if (!clk->en_reg) | ||
40 | return -EFAULT; | ||
41 | |||
42 | val = readl(clk->en_reg); | ||
43 | if (unlikely(clk->flags & RESET_TO_ENABLE)) | ||
44 | val &= ~(1 << clk->en_reg_bit); | ||
45 | else | ||
46 | val |= 1 << clk->en_reg_bit; | ||
47 | |||
48 | writel(val, clk->en_reg); | ||
49 | |||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | static void generic_clk_disable(struct clk *clk) | ||
54 | { | ||
55 | unsigned int val; | ||
56 | |||
57 | if (!clk->en_reg) | ||
58 | return; | ||
59 | |||
60 | val = readl(clk->en_reg); | ||
61 | if (unlikely(clk->flags & RESET_TO_ENABLE)) | ||
62 | val |= 1 << clk->en_reg_bit; | ||
63 | else | ||
64 | val &= ~(1 << clk->en_reg_bit); | ||
65 | |||
66 | writel(val, clk->en_reg); | ||
67 | } | ||
68 | |||
69 | /* generic clk ops */ | ||
70 | static struct clkops generic_clkops = { | ||
71 | .enable = generic_clk_enable, | ||
72 | .disable = generic_clk_disable, | ||
73 | }; | ||
74 | |||
75 | /* returns current programmed clocks clock info structure */ | ||
76 | static struct pclk_info *pclk_info_get(struct clk *clk) | ||
77 | { | ||
78 | unsigned int val, i; | ||
79 | struct pclk_info *info = NULL; | ||
80 | |||
81 | val = (readl(clk->pclk_sel->pclk_sel_reg) >> clk->pclk_sel_shift) | ||
82 | & clk->pclk_sel->pclk_sel_mask; | ||
83 | |||
84 | for (i = 0; i < clk->pclk_sel->pclk_count; i++) { | ||
85 | if (clk->pclk_sel->pclk_info[i].pclk_val == val) | ||
86 | info = &clk->pclk_sel->pclk_info[i]; | ||
87 | } | ||
88 | |||
89 | return info; | ||
90 | } | ||
91 | |||
92 | /* | ||
93 | * Set Update pclk, and pclk_info of clk and add clock sibling node to current | ||
94 | * parents children list | ||
95 | */ | ||
96 | static void clk_reparent(struct clk *clk, struct pclk_info *pclk_info) | ||
97 | { | ||
98 | unsigned long flags; | ||
99 | |||
100 | spin_lock_irqsave(&clocks_lock, flags); | ||
101 | list_del(&clk->sibling); | ||
102 | list_add(&clk->sibling, &pclk_info->pclk->children); | ||
103 | |||
104 | clk->pclk = pclk_info->pclk; | ||
105 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
106 | |||
107 | #ifdef CONFIG_DEBUG_FS | ||
108 | clk_debugfs_reparent(clk); | ||
109 | #endif | ||
110 | } | ||
111 | |||
112 | static void do_clk_disable(struct clk *clk) | ||
113 | { | ||
114 | if (!clk) | ||
115 | return; | ||
116 | |||
117 | if (!clk->usage_count) { | ||
118 | WARN_ON(1); | ||
119 | return; | ||
120 | } | ||
121 | |||
122 | clk->usage_count--; | ||
123 | |||
124 | if (clk->usage_count == 0) { | ||
125 | /* | ||
126 | * Surely, there are no active childrens or direct users | ||
127 | * of this clock | ||
128 | */ | ||
129 | if (clk->pclk) | ||
130 | do_clk_disable(clk->pclk); | ||
131 | |||
132 | if (clk->ops && clk->ops->disable) | ||
133 | clk->ops->disable(clk); | ||
134 | } | ||
135 | } | ||
136 | |||
137 | static int do_clk_enable(struct clk *clk) | ||
138 | { | ||
139 | int ret = 0; | ||
140 | |||
141 | if (!clk) | ||
142 | return -EFAULT; | ||
143 | |||
144 | if (clk->usage_count == 0) { | ||
145 | if (clk->pclk) { | ||
146 | ret = do_clk_enable(clk->pclk); | ||
147 | if (ret) | ||
148 | goto err; | ||
149 | } | ||
150 | if (clk->ops && clk->ops->enable) { | ||
151 | ret = clk->ops->enable(clk); | ||
152 | if (ret) { | ||
153 | if (clk->pclk) | ||
154 | do_clk_disable(clk->pclk); | ||
155 | goto err; | ||
156 | } | ||
157 | } | ||
158 | /* | ||
159 | * Since the clock is going to be used for the first | ||
160 | * time please reclac | ||
161 | */ | ||
162 | if (clk->recalc) { | ||
163 | ret = clk->recalc(clk); | ||
164 | if (ret) | ||
165 | goto err; | ||
166 | } | ||
167 | } | ||
168 | clk->usage_count++; | ||
169 | err: | ||
170 | return ret; | ||
171 | } | ||
172 | |||
173 | /* | ||
174 | * clk_enable - inform the system when the clock source should be running. | ||
175 | * @clk: clock source | ||
176 | * | ||
177 | * If the clock can not be enabled/disabled, this should return success. | ||
178 | * | ||
179 | * Returns success (0) or negative errno. | ||
180 | */ | ||
181 | int clk_enable(struct clk *clk) | ||
182 | { | ||
183 | unsigned long flags; | ||
184 | int ret = 0; | ||
185 | |||
186 | spin_lock_irqsave(&clocks_lock, flags); | ||
187 | ret = do_clk_enable(clk); | ||
188 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
189 | return ret; | ||
190 | } | ||
191 | EXPORT_SYMBOL(clk_enable); | ||
192 | |||
193 | /* | ||
194 | * clk_disable - inform the system when the clock source is no longer required. | ||
195 | * @clk: clock source | ||
196 | * | ||
197 | * Inform the system that a clock source is no longer required by | ||
198 | * a driver and may be shut down. | ||
199 | * | ||
200 | * Implementation detail: if the clock source is shared between | ||
201 | * multiple drivers, clk_enable() calls must be balanced by the | ||
202 | * same number of clk_disable() calls for the clock source to be | ||
203 | * disabled. | ||
204 | */ | ||
205 | void clk_disable(struct clk *clk) | ||
206 | { | ||
207 | unsigned long flags; | ||
208 | |||
209 | spin_lock_irqsave(&clocks_lock, flags); | ||
210 | do_clk_disable(clk); | ||
211 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
212 | } | ||
213 | EXPORT_SYMBOL(clk_disable); | ||
214 | |||
215 | /** | ||
216 | * clk_get_rate - obtain the current clock rate (in Hz) for a clock source. | ||
217 | * This is only valid once the clock source has been enabled. | ||
218 | * @clk: clock source | ||
219 | */ | ||
220 | unsigned long clk_get_rate(struct clk *clk) | ||
221 | { | ||
222 | unsigned long flags, rate; | ||
223 | |||
224 | spin_lock_irqsave(&clocks_lock, flags); | ||
225 | rate = clk->rate; | ||
226 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
227 | |||
228 | return rate; | ||
229 | } | ||
230 | EXPORT_SYMBOL(clk_get_rate); | ||
231 | |||
232 | /** | ||
233 | * clk_set_parent - set the parent clock source for this clock | ||
234 | * @clk: clock source | ||
235 | * @parent: parent clock source | ||
236 | * | ||
237 | * Returns success (0) or negative errno. | ||
238 | */ | ||
239 | int clk_set_parent(struct clk *clk, struct clk *parent) | ||
240 | { | ||
241 | int i, found = 0, val = 0; | ||
242 | unsigned long flags; | ||
243 | |||
244 | if (!clk || !parent) | ||
245 | return -EFAULT; | ||
246 | if (clk->pclk == parent) | ||
247 | return 0; | ||
248 | if (!clk->pclk_sel) | ||
249 | return -EPERM; | ||
250 | |||
251 | /* check if requested parent is in clk parent list */ | ||
252 | for (i = 0; i < clk->pclk_sel->pclk_count; i++) { | ||
253 | if (clk->pclk_sel->pclk_info[i].pclk == parent) { | ||
254 | found = 1; | ||
255 | break; | ||
256 | } | ||
257 | } | ||
258 | |||
259 | if (!found) | ||
260 | return -EINVAL; | ||
261 | |||
262 | spin_lock_irqsave(&clocks_lock, flags); | ||
263 | /* reflect parent change in hardware */ | ||
264 | val = readl(clk->pclk_sel->pclk_sel_reg); | ||
265 | val &= ~(clk->pclk_sel->pclk_sel_mask << clk->pclk_sel_shift); | ||
266 | val |= clk->pclk_sel->pclk_info[i].pclk_val << clk->pclk_sel_shift; | ||
267 | writel(val, clk->pclk_sel->pclk_sel_reg); | ||
268 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
269 | |||
270 | /* reflect parent change in software */ | ||
271 | clk_reparent(clk, &clk->pclk_sel->pclk_info[i]); | ||
272 | |||
273 | propagate_rate(clk, 0); | ||
274 | return 0; | ||
275 | } | ||
276 | EXPORT_SYMBOL(clk_set_parent); | ||
277 | |||
278 | /** | ||
279 | * clk_set_rate - set the clock rate for a clock source | ||
280 | * @clk: clock source | ||
281 | * @rate: desired clock rate in Hz | ||
282 | * | ||
283 | * Returns success (0) or negative errno. | ||
284 | */ | ||
285 | int clk_set_rate(struct clk *clk, unsigned long rate) | ||
286 | { | ||
287 | unsigned long flags; | ||
288 | int ret = -EINVAL; | ||
289 | |||
290 | if (!clk || !rate) | ||
291 | return -EFAULT; | ||
292 | |||
293 | if (clk->set_rate) { | ||
294 | spin_lock_irqsave(&clocks_lock, flags); | ||
295 | ret = clk->set_rate(clk, rate); | ||
296 | if (!ret) | ||
297 | /* if successful -> propagate */ | ||
298 | propagate_rate(clk, 0); | ||
299 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
300 | } else if (clk->pclk) { | ||
301 | u32 mult = clk->div_factor ? clk->div_factor : 1; | ||
302 | ret = clk_set_rate(clk->pclk, mult * rate); | ||
303 | } | ||
304 | |||
305 | return ret; | ||
306 | } | ||
307 | EXPORT_SYMBOL(clk_set_rate); | ||
308 | |||
309 | /* registers clock in platform clock framework */ | ||
310 | void clk_register(struct clk_lookup *cl) | ||
311 | { | ||
312 | struct clk *clk; | ||
313 | unsigned long flags; | ||
314 | |||
315 | if (!cl || !cl->clk) | ||
316 | return; | ||
317 | clk = cl->clk; | ||
318 | |||
319 | spin_lock_irqsave(&clocks_lock, flags); | ||
320 | |||
321 | INIT_LIST_HEAD(&clk->children); | ||
322 | if (clk->flags & ALWAYS_ENABLED) | ||
323 | clk->ops = NULL; | ||
324 | else if (!clk->ops) | ||
325 | clk->ops = &generic_clkops; | ||
326 | |||
327 | /* root clock don't have any parents */ | ||
328 | if (!clk->pclk && !clk->pclk_sel) { | ||
329 | list_add(&clk->sibling, &root_clks); | ||
330 | } else if (clk->pclk && !clk->pclk_sel) { | ||
331 | /* add clocks with only one parent to parent's children list */ | ||
332 | list_add(&clk->sibling, &clk->pclk->children); | ||
333 | } else { | ||
334 | /* clocks with more than one parent */ | ||
335 | struct pclk_info *pclk_info; | ||
336 | |||
337 | pclk_info = pclk_info_get(clk); | ||
338 | if (!pclk_info) { | ||
339 | pr_err("CLKDEV: invalid pclk info of clk with" | ||
340 | " %s dev_id and %s con_id\n", | ||
341 | cl->dev_id, cl->con_id); | ||
342 | } else { | ||
343 | clk->pclk = pclk_info->pclk; | ||
344 | list_add(&clk->sibling, &pclk_info->pclk->children); | ||
345 | } | ||
346 | } | ||
347 | |||
348 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
349 | |||
350 | /* debugfs specific */ | ||
351 | #ifdef CONFIG_DEBUG_FS | ||
352 | list_add(&clk->node, &clocks); | ||
353 | clk->cl = cl; | ||
354 | #endif | ||
355 | |||
356 | /* add clock to arm clockdev framework */ | ||
357 | clkdev_add(cl); | ||
358 | } | ||
359 | |||
360 | /** | ||
361 | * propagate_rate - recalculate and propagate all clocks to children | ||
362 | * @pclk: parent clock required to be propogated | ||
363 | * @on_init: flag for enabling clocks which are ENABLED_ON_INIT. | ||
364 | * | ||
365 | * Recalculates all children clocks | ||
366 | */ | ||
367 | void propagate_rate(struct clk *pclk, int on_init) | ||
368 | { | ||
369 | struct clk *clk, *_temp; | ||
370 | int ret = 0; | ||
371 | |||
372 | list_for_each_entry_safe(clk, _temp, &pclk->children, sibling) { | ||
373 | if (clk->recalc) { | ||
374 | ret = clk->recalc(clk); | ||
375 | /* | ||
376 | * recalc will return error if clk out is not programmed | ||
377 | * In this case configure default rate. | ||
378 | */ | ||
379 | if (ret && clk->set_rate) | ||
380 | clk->set_rate(clk, 0); | ||
381 | } | ||
382 | propagate_rate(clk, on_init); | ||
383 | |||
384 | if (!on_init) | ||
385 | continue; | ||
386 | |||
387 | /* Enable clks enabled on init, in software view */ | ||
388 | if (clk->flags & ENABLED_ON_INIT) | ||
389 | do_clk_enable(clk); | ||
390 | } | ||
391 | } | ||
392 | |||
393 | /** | ||
394 | * round_rate_index - return closest programmable rate index in rate_config tbl | ||
395 | * @clk: ptr to clock structure | ||
396 | * @drate: desired rate | ||
397 | * @rate: final rate will be returned in this variable only. | ||
398 | * | ||
399 | * Finds index in rate_config for highest clk rate which is less than | ||
400 | * requested rate. If there is no clk rate lesser than requested rate then | ||
401 | * -EINVAL is returned. This routine assumes that rate_config is written | ||
402 | * in incrementing order of clk rates. | ||
403 | * If drate passed is zero then default rate is programmed. | ||
404 | */ | ||
405 | static int | ||
406 | round_rate_index(struct clk *clk, unsigned long drate, unsigned long *rate) | ||
407 | { | ||
408 | unsigned long tmp = 0, prev_rate = 0; | ||
409 | int index; | ||
410 | |||
411 | if (!clk->calc_rate) | ||
412 | return -EFAULT; | ||
413 | |||
414 | if (!drate) | ||
415 | return -EINVAL; | ||
416 | |||
417 | /* | ||
418 | * This loops ends on two conditions: | ||
419 | * - as soon as clk is found with rate greater than requested rate. | ||
420 | * - if all clks in rate_config are smaller than requested rate. | ||
421 | */ | ||
422 | for (index = 0; index < clk->rate_config.count; index++) { | ||
423 | prev_rate = tmp; | ||
424 | tmp = clk->calc_rate(clk, index); | ||
425 | if (drate < tmp) { | ||
426 | index--; | ||
427 | break; | ||
428 | } | ||
429 | } | ||
430 | /* return if can't find suitable clock */ | ||
431 | if (index < 0) { | ||
432 | index = -EINVAL; | ||
433 | *rate = 0; | ||
434 | } else if (index == clk->rate_config.count) { | ||
435 | /* program with highest clk rate possible */ | ||
436 | index = clk->rate_config.count - 1; | ||
437 | *rate = tmp; | ||
438 | } else | ||
439 | *rate = prev_rate; | ||
440 | |||
441 | return index; | ||
442 | } | ||
443 | |||
444 | /** | ||
445 | * clk_round_rate - adjust a rate to the exact rate a clock can provide | ||
446 | * @clk: clock source | ||
447 | * @rate: desired clock rate in Hz | ||
448 | * | ||
449 | * Returns rounded clock rate in Hz, or negative errno. | ||
450 | */ | ||
451 | long clk_round_rate(struct clk *clk, unsigned long drate) | ||
452 | { | ||
453 | long rate = 0; | ||
454 | int index; | ||
455 | |||
456 | /* | ||
457 | * propagate call to parent who supports calc_rate. Similar approach is | ||
458 | * used in clk_set_rate. | ||
459 | */ | ||
460 | if (!clk->calc_rate) { | ||
461 | u32 mult; | ||
462 | if (!clk->pclk) | ||
463 | return clk->rate; | ||
464 | |||
465 | mult = clk->div_factor ? clk->div_factor : 1; | ||
466 | return clk_round_rate(clk->pclk, mult * drate) / mult; | ||
467 | } | ||
468 | |||
469 | index = round_rate_index(clk, drate, &rate); | ||
470 | if (index >= 0) | ||
471 | return rate; | ||
472 | else | ||
473 | return index; | ||
474 | } | ||
475 | EXPORT_SYMBOL(clk_round_rate); | ||
476 | |||
477 | /*All below functions are called with lock held */ | ||
478 | |||
479 | /* | ||
480 | * Calculates pll clk rate for specific value of mode, m, n and p | ||
481 | * | ||
482 | * In normal mode | ||
483 | * rate = (2 * M[15:8] * Fin)/(N * 2^P) | ||
484 | * | ||
485 | * In Dithered mode | ||
486 | * rate = (2 * M[15:0] * Fin)/(256 * N * 2^P) | ||
487 | */ | ||
488 | unsigned long pll_calc_rate(struct clk *clk, int index) | ||
489 | { | ||
490 | unsigned long rate = clk->pclk->rate; | ||
491 | struct pll_rate_tbl *tbls = clk->rate_config.tbls; | ||
492 | unsigned int mode; | ||
493 | |||
494 | mode = tbls[index].mode ? 256 : 1; | ||
495 | return (((2 * rate / 10000) * tbls[index].m) / | ||
496 | (mode * tbls[index].n * (1 << tbls[index].p))) * 10000; | ||
497 | } | ||
498 | |||
499 | /* | ||
500 | * calculates current programmed rate of pll1 | ||
501 | * | ||
502 | * In normal mode | ||
503 | * rate = (2 * M[15:8] * Fin)/(N * 2^P) | ||
504 | * | ||
505 | * In Dithered mode | ||
506 | * rate = (2 * M[15:0] * Fin)/(256 * N * 2^P) | ||
507 | */ | ||
508 | int pll_clk_recalc(struct clk *clk) | ||
509 | { | ||
510 | struct pll_clk_config *config = clk->private_data; | ||
511 | unsigned int num = 2, den = 0, val, mode = 0; | ||
512 | |||
513 | mode = (readl(config->mode_reg) >> config->masks->mode_shift) & | ||
514 | config->masks->mode_mask; | ||
515 | |||
516 | val = readl(config->cfg_reg); | ||
517 | /* calculate denominator */ | ||
518 | den = (val >> config->masks->div_p_shift) & config->masks->div_p_mask; | ||
519 | den = 1 << den; | ||
520 | den *= (val >> config->masks->div_n_shift) & config->masks->div_n_mask; | ||
521 | |||
522 | /* calculate numerator & denominator */ | ||
523 | if (!mode) { | ||
524 | /* Normal mode */ | ||
525 | num *= (val >> config->masks->norm_fdbk_m_shift) & | ||
526 | config->masks->norm_fdbk_m_mask; | ||
527 | } else { | ||
528 | /* Dithered mode */ | ||
529 | num *= (val >> config->masks->dith_fdbk_m_shift) & | ||
530 | config->masks->dith_fdbk_m_mask; | ||
531 | den *= 256; | ||
532 | } | ||
533 | |||
534 | if (!den) | ||
535 | return -EINVAL; | ||
536 | |||
537 | clk->rate = (((clk->pclk->rate/10000) * num) / den) * 10000; | ||
538 | return 0; | ||
539 | } | ||
540 | |||
541 | /* | ||
542 | * Configures new clock rate of pll | ||
543 | */ | ||
544 | int pll_clk_set_rate(struct clk *clk, unsigned long desired_rate) | ||
545 | { | ||
546 | struct pll_rate_tbl *tbls = clk->rate_config.tbls; | ||
547 | struct pll_clk_config *config = clk->private_data; | ||
548 | unsigned long val, rate; | ||
549 | int i; | ||
550 | |||
551 | i = round_rate_index(clk, desired_rate, &rate); | ||
552 | if (i < 0) | ||
553 | return i; | ||
554 | |||
555 | val = readl(config->mode_reg) & | ||
556 | ~(config->masks->mode_mask << config->masks->mode_shift); | ||
557 | val |= (tbls[i].mode & config->masks->mode_mask) << | ||
558 | config->masks->mode_shift; | ||
559 | writel(val, config->mode_reg); | ||
560 | |||
561 | val = readl(config->cfg_reg) & | ||
562 | ~(config->masks->div_p_mask << config->masks->div_p_shift); | ||
563 | val |= (tbls[i].p & config->masks->div_p_mask) << | ||
564 | config->masks->div_p_shift; | ||
565 | val &= ~(config->masks->div_n_mask << config->masks->div_n_shift); | ||
566 | val |= (tbls[i].n & config->masks->div_n_mask) << | ||
567 | config->masks->div_n_shift; | ||
568 | val &= ~(config->masks->dith_fdbk_m_mask << | ||
569 | config->masks->dith_fdbk_m_shift); | ||
570 | if (tbls[i].mode) | ||
571 | val |= (tbls[i].m & config->masks->dith_fdbk_m_mask) << | ||
572 | config->masks->dith_fdbk_m_shift; | ||
573 | else | ||
574 | val |= (tbls[i].m & config->masks->norm_fdbk_m_mask) << | ||
575 | config->masks->norm_fdbk_m_shift; | ||
576 | |||
577 | writel(val, config->cfg_reg); | ||
578 | |||
579 | clk->rate = rate; | ||
580 | |||
581 | return 0; | ||
582 | } | ||
583 | |||
584 | /* | ||
585 | * Calculates ahb, apb clk rate for specific value of div | ||
586 | */ | ||
587 | unsigned long bus_calc_rate(struct clk *clk, int index) | ||
588 | { | ||
589 | unsigned long rate = clk->pclk->rate; | ||
590 | struct bus_rate_tbl *tbls = clk->rate_config.tbls; | ||
591 | |||
592 | return rate / (tbls[index].div + 1); | ||
593 | } | ||
594 | |||
595 | /* calculates current programmed rate of ahb or apb bus */ | ||
596 | int bus_clk_recalc(struct clk *clk) | ||
597 | { | ||
598 | struct bus_clk_config *config = clk->private_data; | ||
599 | unsigned int div; | ||
600 | |||
601 | div = ((readl(config->reg) >> config->masks->shift) & | ||
602 | config->masks->mask) + 1; | ||
603 | |||
604 | if (!div) | ||
605 | return -EINVAL; | ||
606 | |||
607 | clk->rate = (unsigned long)clk->pclk->rate / div; | ||
608 | return 0; | ||
609 | } | ||
610 | |||
611 | /* Configures new clock rate of AHB OR APB bus */ | ||
612 | int bus_clk_set_rate(struct clk *clk, unsigned long desired_rate) | ||
613 | { | ||
614 | struct bus_rate_tbl *tbls = clk->rate_config.tbls; | ||
615 | struct bus_clk_config *config = clk->private_data; | ||
616 | unsigned long val, rate; | ||
617 | int i; | ||
618 | |||
619 | i = round_rate_index(clk, desired_rate, &rate); | ||
620 | if (i < 0) | ||
621 | return i; | ||
622 | |||
623 | val = readl(config->reg) & | ||
624 | ~(config->masks->mask << config->masks->shift); | ||
625 | val |= (tbls[i].div & config->masks->mask) << config->masks->shift; | ||
626 | writel(val, config->reg); | ||
627 | |||
628 | clk->rate = rate; | ||
629 | |||
630 | return 0; | ||
631 | } | ||
632 | |||
633 | /* | ||
634 | * gives rate for different values of eq, x and y | ||
635 | * | ||
636 | * Fout from synthesizer can be given from two equations: | ||
637 | * Fout1 = (Fin * X/Y)/2 EQ1 | ||
638 | * Fout2 = Fin * X/Y EQ2 | ||
639 | */ | ||
640 | unsigned long aux_calc_rate(struct clk *clk, int index) | ||
641 | { | ||
642 | unsigned long rate = clk->pclk->rate; | ||
643 | struct aux_rate_tbl *tbls = clk->rate_config.tbls; | ||
644 | u8 eq = tbls[index].eq ? 1 : 2; | ||
645 | |||
646 | return (((rate/10000) * tbls[index].xscale) / | ||
647 | (tbls[index].yscale * eq)) * 10000; | ||
648 | } | ||
649 | |||
650 | /* | ||
651 | * calculates current programmed rate of auxiliary synthesizers | ||
652 | * used by: UART, FIRDA | ||
653 | * | ||
654 | * Fout from synthesizer can be given from two equations: | ||
655 | * Fout1 = (Fin * X/Y)/2 | ||
656 | * Fout2 = Fin * X/Y | ||
657 | * | ||
658 | * Selection of eqn 1 or 2 is programmed in register | ||
659 | */ | ||
660 | int aux_clk_recalc(struct clk *clk) | ||
661 | { | ||
662 | struct aux_clk_config *config = clk->private_data; | ||
663 | unsigned int num = 1, den = 1, val, eqn; | ||
664 | |||
665 | val = readl(config->synth_reg); | ||
666 | |||
667 | eqn = (val >> config->masks->eq_sel_shift) & | ||
668 | config->masks->eq_sel_mask; | ||
669 | if (eqn == config->masks->eq1_mask) | ||
670 | den *= 2; | ||
671 | |||
672 | /* calculate numerator */ | ||
673 | num = (val >> config->masks->xscale_sel_shift) & | ||
674 | config->masks->xscale_sel_mask; | ||
675 | |||
676 | /* calculate denominator */ | ||
677 | den *= (val >> config->masks->yscale_sel_shift) & | ||
678 | config->masks->yscale_sel_mask; | ||
679 | |||
680 | if (!den) | ||
681 | return -EINVAL; | ||
682 | |||
683 | clk->rate = (((clk->pclk->rate/10000) * num) / den) * 10000; | ||
684 | return 0; | ||
685 | } | ||
686 | |||
687 | /* Configures new clock rate of auxiliary synthesizers used by: UART, FIRDA*/ | ||
688 | int aux_clk_set_rate(struct clk *clk, unsigned long desired_rate) | ||
689 | { | ||
690 | struct aux_rate_tbl *tbls = clk->rate_config.tbls; | ||
691 | struct aux_clk_config *config = clk->private_data; | ||
692 | unsigned long val, rate; | ||
693 | int i; | ||
694 | |||
695 | i = round_rate_index(clk, desired_rate, &rate); | ||
696 | if (i < 0) | ||
697 | return i; | ||
698 | |||
699 | val = readl(config->synth_reg) & | ||
700 | ~(config->masks->eq_sel_mask << config->masks->eq_sel_shift); | ||
701 | val |= (tbls[i].eq & config->masks->eq_sel_mask) << | ||
702 | config->masks->eq_sel_shift; | ||
703 | val &= ~(config->masks->xscale_sel_mask << | ||
704 | config->masks->xscale_sel_shift); | ||
705 | val |= (tbls[i].xscale & config->masks->xscale_sel_mask) << | ||
706 | config->masks->xscale_sel_shift; | ||
707 | val &= ~(config->masks->yscale_sel_mask << | ||
708 | config->masks->yscale_sel_shift); | ||
709 | val |= (tbls[i].yscale & config->masks->yscale_sel_mask) << | ||
710 | config->masks->yscale_sel_shift; | ||
711 | writel(val, config->synth_reg); | ||
712 | |||
713 | clk->rate = rate; | ||
714 | |||
715 | return 0; | ||
716 | } | ||
717 | |||
718 | /* | ||
719 | * Calculates gpt clk rate for different values of mscale and nscale | ||
720 | * | ||
721 | * Fout= Fin/((2 ^ (N+1)) * (M+1)) | ||
722 | */ | ||
723 | unsigned long gpt_calc_rate(struct clk *clk, int index) | ||
724 | { | ||
725 | unsigned long rate = clk->pclk->rate; | ||
726 | struct gpt_rate_tbl *tbls = clk->rate_config.tbls; | ||
727 | |||
728 | return rate / ((1 << (tbls[index].nscale + 1)) * | ||
729 | (tbls[index].mscale + 1)); | ||
730 | } | ||
731 | |||
732 | /* | ||
733 | * calculates current programmed rate of gpt synthesizers | ||
734 | * Fout from synthesizer can be given from below equations: | ||
735 | * Fout= Fin/((2 ^ (N+1)) * (M+1)) | ||
736 | */ | ||
737 | int gpt_clk_recalc(struct clk *clk) | ||
738 | { | ||
739 | struct gpt_clk_config *config = clk->private_data; | ||
740 | unsigned int div = 1, val; | ||
741 | |||
742 | val = readl(config->synth_reg); | ||
743 | div += (val >> config->masks->mscale_sel_shift) & | ||
744 | config->masks->mscale_sel_mask; | ||
745 | div *= 1 << (((val >> config->masks->nscale_sel_shift) & | ||
746 | config->masks->nscale_sel_mask) + 1); | ||
747 | |||
748 | if (!div) | ||
749 | return -EINVAL; | ||
750 | |||
751 | clk->rate = (unsigned long)clk->pclk->rate / div; | ||
752 | return 0; | ||
753 | } | ||
754 | |||
755 | /* Configures new clock rate of gptiliary synthesizers used by: UART, FIRDA*/ | ||
756 | int gpt_clk_set_rate(struct clk *clk, unsigned long desired_rate) | ||
757 | { | ||
758 | struct gpt_rate_tbl *tbls = clk->rate_config.tbls; | ||
759 | struct gpt_clk_config *config = clk->private_data; | ||
760 | unsigned long val, rate; | ||
761 | int i; | ||
762 | |||
763 | i = round_rate_index(clk, desired_rate, &rate); | ||
764 | if (i < 0) | ||
765 | return i; | ||
766 | |||
767 | val = readl(config->synth_reg) & ~(config->masks->mscale_sel_mask << | ||
768 | config->masks->mscale_sel_shift); | ||
769 | val |= (tbls[i].mscale & config->masks->mscale_sel_mask) << | ||
770 | config->masks->mscale_sel_shift; | ||
771 | val &= ~(config->masks->nscale_sel_mask << | ||
772 | config->masks->nscale_sel_shift); | ||
773 | val |= (tbls[i].nscale & config->masks->nscale_sel_mask) << | ||
774 | config->masks->nscale_sel_shift; | ||
775 | writel(val, config->synth_reg); | ||
776 | |||
777 | clk->rate = rate; | ||
778 | |||
779 | return 0; | ||
780 | } | ||
781 | |||
782 | /* | ||
783 | * Calculates clcd clk rate for different values of div | ||
784 | * | ||
785 | * Fout from synthesizer can be given from below equation: | ||
786 | * Fout= Fin/2*div (division factor) | ||
787 | * div is 17 bits:- | ||
788 | * 0-13 (fractional part) | ||
789 | * 14-16 (integer part) | ||
790 | * To calculate Fout we left shift val by 14 bits and divide Fin by | ||
791 | * complete div (including fractional part) and then right shift the | ||
792 | * result by 14 places. | ||
793 | */ | ||
794 | unsigned long clcd_calc_rate(struct clk *clk, int index) | ||
795 | { | ||
796 | unsigned long rate = clk->pclk->rate; | ||
797 | struct clcd_rate_tbl *tbls = clk->rate_config.tbls; | ||
798 | |||
799 | rate /= 1000; | ||
800 | rate <<= 12; | ||
801 | rate /= (2 * tbls[index].div); | ||
802 | rate >>= 12; | ||
803 | rate *= 1000; | ||
804 | |||
805 | return rate; | ||
806 | } | ||
807 | |||
808 | /* | ||
809 | * calculates current programmed rate of clcd synthesizer | ||
810 | * Fout from synthesizer can be given from below equation: | ||
811 | * Fout= Fin/2*div (division factor) | ||
812 | * div is 17 bits:- | ||
813 | * 0-13 (fractional part) | ||
814 | * 14-16 (integer part) | ||
815 | * To calculate Fout we left shift val by 14 bits and divide Fin by | ||
816 | * complete div (including fractional part) and then right shift the | ||
817 | * result by 14 places. | ||
818 | */ | ||
819 | int clcd_clk_recalc(struct clk *clk) | ||
820 | { | ||
821 | struct clcd_clk_config *config = clk->private_data; | ||
822 | unsigned int div = 1; | ||
823 | unsigned long prate; | ||
824 | unsigned int val; | ||
825 | |||
826 | val = readl(config->synth_reg); | ||
827 | div = (val >> config->masks->div_factor_shift) & | ||
828 | config->masks->div_factor_mask; | ||
829 | |||
830 | if (!div) | ||
831 | return -EINVAL; | ||
832 | |||
833 | prate = clk->pclk->rate / 1000; /* first level division, make it KHz */ | ||
834 | |||
835 | clk->rate = (((unsigned long)prate << 12) / (2 * div)) >> 12; | ||
836 | clk->rate *= 1000; | ||
837 | return 0; | ||
838 | } | ||
839 | |||
840 | /* Configures new clock rate of auxiliary synthesizers used by: UART, FIRDA*/ | ||
841 | int clcd_clk_set_rate(struct clk *clk, unsigned long desired_rate) | ||
842 | { | ||
843 | struct clcd_rate_tbl *tbls = clk->rate_config.tbls; | ||
844 | struct clcd_clk_config *config = clk->private_data; | ||
845 | unsigned long val, rate; | ||
846 | int i; | ||
847 | |||
848 | i = round_rate_index(clk, desired_rate, &rate); | ||
849 | if (i < 0) | ||
850 | return i; | ||
851 | |||
852 | val = readl(config->synth_reg) & ~(config->masks->div_factor_mask << | ||
853 | config->masks->div_factor_shift); | ||
854 | val |= (tbls[i].div & config->masks->div_factor_mask) << | ||
855 | config->masks->div_factor_shift; | ||
856 | writel(val, config->synth_reg); | ||
857 | |||
858 | clk->rate = rate; | ||
859 | |||
860 | return 0; | ||
861 | } | ||
862 | |||
863 | /* | ||
864 | * Used for clocks that always have value as the parent clock divided by a | ||
865 | * fixed divisor | ||
866 | */ | ||
867 | int follow_parent(struct clk *clk) | ||
868 | { | ||
869 | unsigned int div_factor = (clk->div_factor < 1) ? 1 : clk->div_factor; | ||
870 | |||
871 | clk->rate = clk->pclk->rate/div_factor; | ||
872 | return 0; | ||
873 | } | ||
874 | |||
875 | /** | ||
876 | * recalc_root_clocks - recalculate and propagate all root clocks | ||
877 | * | ||
878 | * Recalculates all root clocks (clocks with no parent), which if the | ||
879 | * clock's .recalc is set correctly, should also propagate their rates. | ||
880 | */ | ||
881 | void recalc_root_clocks(void) | ||
882 | { | ||
883 | struct clk *pclk; | ||
884 | unsigned long flags; | ||
885 | int ret = 0; | ||
886 | |||
887 | spin_lock_irqsave(&clocks_lock, flags); | ||
888 | list_for_each_entry(pclk, &root_clks, sibling) { | ||
889 | if (pclk->recalc) { | ||
890 | ret = pclk->recalc(pclk); | ||
891 | /* | ||
892 | * recalc will return error if clk out is not programmed | ||
893 | * In this case configure default clock. | ||
894 | */ | ||
895 | if (ret && pclk->set_rate) | ||
896 | pclk->set_rate(pclk, 0); | ||
897 | } | ||
898 | propagate_rate(pclk, 1); | ||
899 | /* Enable clks enabled on init, in software view */ | ||
900 | if (pclk->flags & ENABLED_ON_INIT) | ||
901 | do_clk_enable(pclk); | ||
902 | } | ||
903 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
904 | } | ||
905 | |||
906 | void __init clk_init(void) | ||
907 | { | ||
908 | recalc_root_clocks(); | ||
909 | } | ||
910 | |||
911 | #ifdef CONFIG_DEBUG_FS | ||
912 | /* | ||
913 | * debugfs support to trace clock tree hierarchy and attributes | ||
914 | */ | ||
915 | static struct dentry *clk_debugfs_root; | ||
916 | static int clk_debugfs_register_one(struct clk *c) | ||
917 | { | ||
918 | int err; | ||
919 | struct dentry *d; | ||
920 | struct clk *pa = c->pclk; | ||
921 | char s[255]; | ||
922 | char *p = s; | ||
923 | |||
924 | if (c) { | ||
925 | if (c->cl->con_id) | ||
926 | p += sprintf(p, "%s", c->cl->con_id); | ||
927 | if (c->cl->dev_id) | ||
928 | p += sprintf(p, "%s", c->cl->dev_id); | ||
929 | } | ||
930 | d = debugfs_create_dir(s, pa ? pa->dent : clk_debugfs_root); | ||
931 | if (!d) | ||
932 | return -ENOMEM; | ||
933 | c->dent = d; | ||
934 | |||
935 | d = debugfs_create_u32("usage_count", S_IRUGO, c->dent, | ||
936 | (u32 *)&c->usage_count); | ||
937 | if (!d) { | ||
938 | err = -ENOMEM; | ||
939 | goto err_out; | ||
940 | } | ||
941 | d = debugfs_create_u32("rate", S_IRUGO, c->dent, (u32 *)&c->rate); | ||
942 | if (!d) { | ||
943 | err = -ENOMEM; | ||
944 | goto err_out; | ||
945 | } | ||
946 | d = debugfs_create_x32("flags", S_IRUGO, c->dent, (u32 *)&c->flags); | ||
947 | if (!d) { | ||
948 | err = -ENOMEM; | ||
949 | goto err_out; | ||
950 | } | ||
951 | return 0; | ||
952 | |||
953 | err_out: | ||
954 | debugfs_remove_recursive(c->dent); | ||
955 | return err; | ||
956 | } | ||
957 | |||
958 | static int clk_debugfs_register(struct clk *c) | ||
959 | { | ||
960 | int err; | ||
961 | struct clk *pa = c->pclk; | ||
962 | |||
963 | if (pa && !pa->dent) { | ||
964 | err = clk_debugfs_register(pa); | ||
965 | if (err) | ||
966 | return err; | ||
967 | } | ||
968 | |||
969 | if (!c->dent) { | ||
970 | err = clk_debugfs_register_one(c); | ||
971 | if (err) | ||
972 | return err; | ||
973 | } | ||
974 | return 0; | ||
975 | } | ||
976 | |||
977 | static int __init clk_debugfs_init(void) | ||
978 | { | ||
979 | struct clk *c; | ||
980 | struct dentry *d; | ||
981 | int err; | ||
982 | |||
983 | d = debugfs_create_dir("clock", NULL); | ||
984 | if (!d) | ||
985 | return -ENOMEM; | ||
986 | clk_debugfs_root = d; | ||
987 | |||
988 | list_for_each_entry(c, &clocks, node) { | ||
989 | err = clk_debugfs_register(c); | ||
990 | if (err) | ||
991 | goto err_out; | ||
992 | } | ||
993 | return 0; | ||
994 | err_out: | ||
995 | debugfs_remove_recursive(clk_debugfs_root); | ||
996 | return err; | ||
997 | } | ||
998 | late_initcall(clk_debugfs_init); | ||
999 | |||
1000 | static int clk_debugfs_reparent(struct clk *c) | ||
1001 | { | ||
1002 | debugfs_remove(c->dent); | ||
1003 | return clk_debugfs_register_one(c); | ||
1004 | } | ||
1005 | #endif /* CONFIG_DEBUG_FS */ | ||
diff --git a/arch/arm/plat-spear/include/plat/clock.h b/arch/arm/plat-spear/include/plat/clock.h deleted file mode 100644 index 0062bafef12d..000000000000 --- a/arch/arm/plat-spear/include/plat/clock.h +++ /dev/null | |||
@@ -1,249 +0,0 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/clock.h | ||
3 | * | ||
4 | * Clock framework definitions for SPEAr platform | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __PLAT_CLOCK_H | ||
15 | #define __PLAT_CLOCK_H | ||
16 | |||
17 | #include <linux/list.h> | ||
18 | #include <linux/clkdev.h> | ||
19 | #include <linux/types.h> | ||
20 | |||
21 | /* clk structure flags */ | ||
22 | #define ALWAYS_ENABLED (1 << 0) /* clock always enabled */ | ||
23 | #define RESET_TO_ENABLE (1 << 1) /* reset register bit to enable clk */ | ||
24 | #define ENABLED_ON_INIT (1 << 2) /* clocks enabled at init */ | ||
25 | |||
26 | /** | ||
27 | * struct clkops - clock operations | ||
28 | * @enable: pointer to clock enable function | ||
29 | * @disable: pointer to clock disable function | ||
30 | */ | ||
31 | struct clkops { | ||
32 | int (*enable) (struct clk *); | ||
33 | void (*disable) (struct clk *); | ||
34 | }; | ||
35 | |||
36 | /** | ||
37 | * struct pclk_info - parents info | ||
38 | * @pclk: pointer to parent clk | ||
39 | * @pclk_val: value to be written for selecting this parent | ||
40 | */ | ||
41 | struct pclk_info { | ||
42 | struct clk *pclk; | ||
43 | u8 pclk_val; | ||
44 | }; | ||
45 | |||
46 | /** | ||
47 | * struct pclk_sel - parents selection configuration | ||
48 | * @pclk_info: pointer to array of parent clock info | ||
49 | * @pclk_count: number of parents | ||
50 | * @pclk_sel_reg: register for selecting a parent | ||
51 | * @pclk_sel_mask: mask for selecting parent (can be used to clear bits also) | ||
52 | */ | ||
53 | struct pclk_sel { | ||
54 | struct pclk_info *pclk_info; | ||
55 | u8 pclk_count; | ||
56 | void __iomem *pclk_sel_reg; | ||
57 | unsigned int pclk_sel_mask; | ||
58 | }; | ||
59 | |||
60 | /** | ||
61 | * struct rate_config - clk rate configurations | ||
62 | * @tbls: array of device specific clk rate tables, in ascending order of rates | ||
63 | * @count: size of tbls array | ||
64 | * @default_index: default setting when originally disabled | ||
65 | */ | ||
66 | struct rate_config { | ||
67 | void *tbls; | ||
68 | u8 count; | ||
69 | u8 default_index; | ||
70 | }; | ||
71 | |||
72 | /** | ||
73 | * struct clk - clock structure | ||
74 | * @usage_count: num of users who enabled this clock | ||
75 | * @flags: flags for clock properties | ||
76 | * @rate: programmed clock rate in Hz | ||
77 | * @en_reg: clk enable/disable reg | ||
78 | * @en_reg_bit: clk enable/disable bit | ||
79 | * @ops: clk enable/disable ops - generic_clkops selected if NULL | ||
80 | * @recalc: pointer to clock rate recalculate function | ||
81 | * @set_rate: pointer to clock set rate function | ||
82 | * @calc_rate: pointer to clock get rate function for index | ||
83 | * @rate_config: rate configuration information, used by set_rate | ||
84 | * @div_factor: division factor to parent clock. | ||
85 | * @pclk: current parent clk | ||
86 | * @pclk_sel: pointer to parent selection structure | ||
87 | * @pclk_sel_shift: register shift for selecting parent of this clock | ||
88 | * @children: list for childrens or this clock | ||
89 | * @sibling: node for list of clocks having same parents | ||
90 | * @private_data: clock specific private data | ||
91 | * @node: list to maintain clocks linearly | ||
92 | * @cl: clocklook up associated with this clock | ||
93 | * @dent: object for debugfs | ||
94 | */ | ||
95 | struct clk { | ||
96 | unsigned int usage_count; | ||
97 | unsigned int flags; | ||
98 | unsigned long rate; | ||
99 | void __iomem *en_reg; | ||
100 | u8 en_reg_bit; | ||
101 | const struct clkops *ops; | ||
102 | int (*recalc) (struct clk *); | ||
103 | int (*set_rate) (struct clk *, unsigned long rate); | ||
104 | unsigned long (*calc_rate)(struct clk *, int index); | ||
105 | struct rate_config rate_config; | ||
106 | unsigned int div_factor; | ||
107 | |||
108 | struct clk *pclk; | ||
109 | struct pclk_sel *pclk_sel; | ||
110 | unsigned int pclk_sel_shift; | ||
111 | |||
112 | struct list_head children; | ||
113 | struct list_head sibling; | ||
114 | void *private_data; | ||
115 | #ifdef CONFIG_DEBUG_FS | ||
116 | struct list_head node; | ||
117 | struct clk_lookup *cl; | ||
118 | struct dentry *dent; | ||
119 | #endif | ||
120 | }; | ||
121 | |||
122 | /* pll configuration structure */ | ||
123 | struct pll_clk_masks { | ||
124 | u32 mode_mask; | ||
125 | u32 mode_shift; | ||
126 | |||
127 | u32 norm_fdbk_m_mask; | ||
128 | u32 norm_fdbk_m_shift; | ||
129 | u32 dith_fdbk_m_mask; | ||
130 | u32 dith_fdbk_m_shift; | ||
131 | u32 div_p_mask; | ||
132 | u32 div_p_shift; | ||
133 | u32 div_n_mask; | ||
134 | u32 div_n_shift; | ||
135 | }; | ||
136 | |||
137 | struct pll_clk_config { | ||
138 | void __iomem *mode_reg; | ||
139 | void __iomem *cfg_reg; | ||
140 | struct pll_clk_masks *masks; | ||
141 | }; | ||
142 | |||
143 | /* pll clk rate config structure */ | ||
144 | struct pll_rate_tbl { | ||
145 | u8 mode; | ||
146 | u16 m; | ||
147 | u8 n; | ||
148 | u8 p; | ||
149 | }; | ||
150 | |||
151 | /* ahb and apb bus configuration structure */ | ||
152 | struct bus_clk_masks { | ||
153 | u32 mask; | ||
154 | u32 shift; | ||
155 | }; | ||
156 | |||
157 | struct bus_clk_config { | ||
158 | void __iomem *reg; | ||
159 | struct bus_clk_masks *masks; | ||
160 | }; | ||
161 | |||
162 | /* ahb and apb clk bus rate config structure */ | ||
163 | struct bus_rate_tbl { | ||
164 | u8 div; | ||
165 | }; | ||
166 | |||
167 | /* Aux clk configuration structure: applicable to UART and FIRDA */ | ||
168 | struct aux_clk_masks { | ||
169 | u32 eq_sel_mask; | ||
170 | u32 eq_sel_shift; | ||
171 | u32 eq1_mask; | ||
172 | u32 eq2_mask; | ||
173 | u32 xscale_sel_mask; | ||
174 | u32 xscale_sel_shift; | ||
175 | u32 yscale_sel_mask; | ||
176 | u32 yscale_sel_shift; | ||
177 | }; | ||
178 | |||
179 | struct aux_clk_config { | ||
180 | void __iomem *synth_reg; | ||
181 | struct aux_clk_masks *masks; | ||
182 | }; | ||
183 | |||
184 | /* aux clk rate config structure */ | ||
185 | struct aux_rate_tbl { | ||
186 | u16 xscale; | ||
187 | u16 yscale; | ||
188 | u8 eq; | ||
189 | }; | ||
190 | |||
191 | /* GPT clk configuration structure */ | ||
192 | struct gpt_clk_masks { | ||
193 | u32 mscale_sel_mask; | ||
194 | u32 mscale_sel_shift; | ||
195 | u32 nscale_sel_mask; | ||
196 | u32 nscale_sel_shift; | ||
197 | }; | ||
198 | |||
199 | struct gpt_clk_config { | ||
200 | void __iomem *synth_reg; | ||
201 | struct gpt_clk_masks *masks; | ||
202 | }; | ||
203 | |||
204 | /* gpt clk rate config structure */ | ||
205 | struct gpt_rate_tbl { | ||
206 | u16 mscale; | ||
207 | u16 nscale; | ||
208 | }; | ||
209 | |||
210 | /* clcd clk configuration structure */ | ||
211 | struct clcd_synth_masks { | ||
212 | u32 div_factor_mask; | ||
213 | u32 div_factor_shift; | ||
214 | }; | ||
215 | |||
216 | struct clcd_clk_config { | ||
217 | void __iomem *synth_reg; | ||
218 | struct clcd_synth_masks *masks; | ||
219 | }; | ||
220 | |||
221 | /* clcd clk rate config structure */ | ||
222 | struct clcd_rate_tbl { | ||
223 | u16 div; | ||
224 | }; | ||
225 | |||
226 | /* platform specific clock functions */ | ||
227 | void __init clk_init(void); | ||
228 | void clk_register(struct clk_lookup *cl); | ||
229 | void recalc_root_clocks(void); | ||
230 | |||
231 | /* clock recalc & set rate functions */ | ||
232 | int follow_parent(struct clk *clk); | ||
233 | unsigned long pll_calc_rate(struct clk *clk, int index); | ||
234 | int pll_clk_recalc(struct clk *clk); | ||
235 | int pll_clk_set_rate(struct clk *clk, unsigned long desired_rate); | ||
236 | unsigned long bus_calc_rate(struct clk *clk, int index); | ||
237 | int bus_clk_recalc(struct clk *clk); | ||
238 | int bus_clk_set_rate(struct clk *clk, unsigned long desired_rate); | ||
239 | unsigned long gpt_calc_rate(struct clk *clk, int index); | ||
240 | int gpt_clk_recalc(struct clk *clk); | ||
241 | int gpt_clk_set_rate(struct clk *clk, unsigned long desired_rate); | ||
242 | unsigned long aux_calc_rate(struct clk *clk, int index); | ||
243 | int aux_clk_recalc(struct clk *clk); | ||
244 | int aux_clk_set_rate(struct clk *clk, unsigned long desired_rate); | ||
245 | unsigned long clcd_calc_rate(struct clk *clk, int index); | ||
246 | int clcd_clk_recalc(struct clk *clk); | ||
247 | int clcd_clk_set_rate(struct clk *clk, unsigned long desired_rate); | ||
248 | |||
249 | #endif /* __PLAT_CLOCK_H */ | ||
diff --git a/arch/arm/plat-spear/include/plat/debug-macro.S b/arch/arm/plat-spear/include/plat/debug-macro.S index 02b160a1ec9b..ab3de721c5db 100644 --- a/arch/arm/plat-spear/include/plat/debug-macro.S +++ b/arch/arm/plat-spear/include/plat/debug-macro.S | |||
@@ -12,7 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/amba/serial.h> | 14 | #include <linux/amba/serial.h> |
15 | #include <mach/hardware.h> | 15 | #include <mach/spear.h> |
16 | 16 | ||
17 | .macro addruart, rp, rv, tmp | 17 | .macro addruart, rp, rv, tmp |
18 | mov \rp, #SPEAR_DBG_UART_BASE @ Physical base | 18 | mov \rp, #SPEAR_DBG_UART_BASE @ Physical base |
diff --git a/arch/arm/plat-spear/include/plat/hardware.h b/arch/arm/plat-spear/include/plat/hardware.h deleted file mode 100644 index 70187d763e26..000000000000 --- a/arch/arm/plat-spear/include/plat/hardware.h +++ /dev/null | |||
@@ -1,17 +0,0 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/hardware.h | ||
3 | * | ||
4 | * Hardware definitions for SPEAr | ||
5 | * | ||
6 | * Copyright (C) 2010 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __PLAT_HARDWARE_H | ||
15 | #define __PLAT_HARDWARE_H | ||
16 | |||
17 | #endif /* __PLAT_HARDWARE_H */ | ||
diff --git a/arch/arm/plat-spear/include/plat/padmux.h b/arch/arm/plat-spear/include/plat/padmux.h deleted file mode 100644 index 877f3adcf610..000000000000 --- a/arch/arm/plat-spear/include/plat/padmux.h +++ /dev/null | |||
@@ -1,92 +0,0 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/padmux.h | ||
3 | * | ||
4 | * SPEAr platform specific gpio pads muxing file | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __PLAT_PADMUX_H | ||
15 | #define __PLAT_PADMUX_H | ||
16 | |||
17 | #include <linux/types.h> | ||
18 | |||
19 | /* | ||
20 | * struct pmx_reg: configuration structure for mode reg and mux reg | ||
21 | * | ||
22 | * offset: offset of mode reg | ||
23 | * mask: mask of mode reg | ||
24 | */ | ||
25 | struct pmx_reg { | ||
26 | u32 offset; | ||
27 | u32 mask; | ||
28 | }; | ||
29 | |||
30 | /* | ||
31 | * struct pmx_dev_mode: configuration structure every group of modes of a device | ||
32 | * | ||
33 | * ids: all modes for this configuration | ||
34 | * mask: mask for supported mode | ||
35 | */ | ||
36 | struct pmx_dev_mode { | ||
37 | u32 ids; | ||
38 | u32 mask; | ||
39 | }; | ||
40 | |||
41 | /* | ||
42 | * struct pmx_mode: mode definition structure | ||
43 | * | ||
44 | * name: mode name | ||
45 | * mask: mode mask | ||
46 | */ | ||
47 | struct pmx_mode { | ||
48 | char *name; | ||
49 | u32 id; | ||
50 | u32 mask; | ||
51 | }; | ||
52 | |||
53 | /* | ||
54 | * struct pmx_dev: device definition structure | ||
55 | * | ||
56 | * name: device name | ||
57 | * modes: device configuration array for different modes supported | ||
58 | * mode_count: size of modes array | ||
59 | * is_active: is peripheral active/enabled | ||
60 | * enb_on_reset: if 1, mask bits to be cleared in reg otherwise to be set in reg | ||
61 | */ | ||
62 | struct pmx_dev { | ||
63 | char *name; | ||
64 | struct pmx_dev_mode *modes; | ||
65 | u8 mode_count; | ||
66 | bool is_active; | ||
67 | bool enb_on_reset; | ||
68 | }; | ||
69 | |||
70 | /* | ||
71 | * struct pmx_driver: driver definition structure | ||
72 | * | ||
73 | * mode: mode to be set | ||
74 | * devs: array of pointer to pmx devices | ||
75 | * devs_count: ARRAY_SIZE of devs | ||
76 | * base: base address of soc config registers | ||
77 | * mode_reg: structure of mode config register | ||
78 | * mux_reg: structure of device mux config register | ||
79 | */ | ||
80 | struct pmx_driver { | ||
81 | struct pmx_mode *mode; | ||
82 | struct pmx_dev **devs; | ||
83 | u8 devs_count; | ||
84 | u32 *base; | ||
85 | struct pmx_reg mode_reg; | ||
86 | struct pmx_reg mux_reg; | ||
87 | }; | ||
88 | |||
89 | /* pmx functions */ | ||
90 | int pmx_register(struct pmx_driver *driver); | ||
91 | |||
92 | #endif /* __PLAT_PADMUX_H */ | ||
diff --git a/arch/arm/plat-spear/include/plat/pl080.h b/arch/arm/plat-spear/include/plat/pl080.h new file mode 100644 index 000000000000..e14a3e4932f9 --- /dev/null +++ b/arch/arm/plat-spear/include/plat/pl080.h | |||
@@ -0,0 +1,21 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/pl080.h | ||
3 | * | ||
4 | * DMAC pl080 definitions for SPEAr platform | ||
5 | * | ||
6 | * Copyright (C) 2012 ST Microelectronics | ||
7 | * Viresh Kumar <viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #ifndef __PLAT_PL080_H | ||
15 | #define __PLAT_PL080_H | ||
16 | |||
17 | struct pl08x_dma_chan; | ||
18 | int pl080_get_signal(struct pl08x_dma_chan *ch); | ||
19 | void pl080_put_signal(struct pl08x_dma_chan *ch); | ||
20 | |||
21 | #endif /* __PLAT_PL080_H */ | ||
diff --git a/arch/arm/plat-spear/include/plat/uncompress.h b/arch/arm/plat-spear/include/plat/uncompress.h index 1bf84527aee4..6dd455bafdfd 100644 --- a/arch/arm/plat-spear/include/plat/uncompress.h +++ b/arch/arm/plat-spear/include/plat/uncompress.h | |||
@@ -13,7 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/io.h> | 14 | #include <linux/io.h> |
15 | #include <linux/amba/serial.h> | 15 | #include <linux/amba/serial.h> |
16 | #include <mach/hardware.h> | 16 | #include <mach/spear.h> |
17 | 17 | ||
18 | #ifndef __PLAT_UNCOMPRESS_H | 18 | #ifndef __PLAT_UNCOMPRESS_H |
19 | #define __PLAT_UNCOMPRESS_H | 19 | #define __PLAT_UNCOMPRESS_H |
diff --git a/arch/arm/plat-spear/padmux.c b/arch/arm/plat-spear/padmux.c deleted file mode 100644 index 555eec6dc1cb..000000000000 --- a/arch/arm/plat-spear/padmux.c +++ /dev/null | |||
@@ -1,164 +0,0 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/include/plat/padmux.c | ||
3 | * | ||
4 | * SPEAr platform specific gpio pads muxing source file | ||
5 | * | ||
6 | * Copyright (C) 2009 ST Microelectronics | ||
7 | * Viresh Kumar<viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #include <linux/err.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/slab.h> | ||
17 | #include <plat/padmux.h> | ||
18 | |||
19 | /* | ||
20 | * struct pmx: pmx definition structure | ||
21 | * | ||
22 | * base: base address of configuration registers | ||
23 | * mode_reg: mode configurations | ||
24 | * mux_reg: muxing configurations | ||
25 | * active_mode: pointer to current active mode | ||
26 | */ | ||
27 | struct pmx { | ||
28 | u32 base; | ||
29 | struct pmx_reg mode_reg; | ||
30 | struct pmx_reg mux_reg; | ||
31 | struct pmx_mode *active_mode; | ||
32 | }; | ||
33 | |||
34 | static struct pmx *pmx; | ||
35 | |||
36 | /** | ||
37 | * pmx_mode_set - Enables an multiplexing mode | ||
38 | * @mode - pointer to pmx mode | ||
39 | * | ||
40 | * It will set mode of operation in hardware. | ||
41 | * Returns -ve on Err otherwise 0 | ||
42 | */ | ||
43 | static int pmx_mode_set(struct pmx_mode *mode) | ||
44 | { | ||
45 | u32 val; | ||
46 | |||
47 | if (!mode->name) | ||
48 | return -EFAULT; | ||
49 | |||
50 | pmx->active_mode = mode; | ||
51 | |||
52 | val = readl(pmx->base + pmx->mode_reg.offset); | ||
53 | val &= ~pmx->mode_reg.mask; | ||
54 | val |= mode->mask & pmx->mode_reg.mask; | ||
55 | writel(val, pmx->base + pmx->mode_reg.offset); | ||
56 | |||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * pmx_devs_enable - Enables list of devices | ||
62 | * @devs - pointer to pmx device array | ||
63 | * @count - number of devices to enable | ||
64 | * | ||
65 | * It will enable pads for all required peripherals once and only once. | ||
66 | * If peripheral is not supported by current mode then request is rejected. | ||
67 | * Conflicts between peripherals are not handled and peripherals will be | ||
68 | * enabled in the order they are present in pmx_dev array. | ||
69 | * In case of conflicts last peripheral enabled will be present. | ||
70 | * Returns -ve on Err otherwise 0 | ||
71 | */ | ||
72 | static int pmx_devs_enable(struct pmx_dev **devs, u8 count) | ||
73 | { | ||
74 | u32 val, i, mask; | ||
75 | |||
76 | if (!count) | ||
77 | return -EINVAL; | ||
78 | |||
79 | val = readl(pmx->base + pmx->mux_reg.offset); | ||
80 | for (i = 0; i < count; i++) { | ||
81 | u8 j = 0; | ||
82 | |||
83 | if (!devs[i]->name || !devs[i]->modes) { | ||
84 | printk(KERN_ERR "padmux: dev name or modes is null\n"); | ||
85 | continue; | ||
86 | } | ||
87 | /* check if peripheral exists in active mode */ | ||
88 | if (pmx->active_mode) { | ||
89 | bool found = false; | ||
90 | for (j = 0; j < devs[i]->mode_count; j++) { | ||
91 | if (devs[i]->modes[j].ids & | ||
92 | pmx->active_mode->id) { | ||
93 | found = true; | ||
94 | break; | ||
95 | } | ||
96 | } | ||
97 | if (found == false) { | ||
98 | printk(KERN_ERR "%s device not available in %s"\ | ||
99 | "mode\n", devs[i]->name, | ||
100 | pmx->active_mode->name); | ||
101 | continue; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | /* enable peripheral */ | ||
106 | mask = devs[i]->modes[j].mask & pmx->mux_reg.mask; | ||
107 | if (devs[i]->enb_on_reset) | ||
108 | val &= ~mask; | ||
109 | else | ||
110 | val |= mask; | ||
111 | |||
112 | devs[i]->is_active = true; | ||
113 | } | ||
114 | writel(val, pmx->base + pmx->mux_reg.offset); | ||
115 | kfree(pmx); | ||
116 | |||
117 | /* this will ensure that multiplexing can't be changed now */ | ||
118 | pmx = (struct pmx *)-1; | ||
119 | |||
120 | return 0; | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * pmx_register - registers a platform requesting pad mux feature | ||
125 | * @driver - pointer to driver structure containing driver specific parameters | ||
126 | * | ||
127 | * Also this must be called only once. This will allocate memory for pmx | ||
128 | * structure, will call pmx_mode_set, will call pmx_devs_enable. | ||
129 | * Returns -ve on Err otherwise 0 | ||
130 | */ | ||
131 | int pmx_register(struct pmx_driver *driver) | ||
132 | { | ||
133 | int ret = 0; | ||
134 | |||
135 | if (pmx) | ||
136 | return -EPERM; | ||
137 | if (!driver->base || !driver->devs) | ||
138 | return -EFAULT; | ||
139 | |||
140 | pmx = kzalloc(sizeof(*pmx), GFP_KERNEL); | ||
141 | if (!pmx) | ||
142 | return -ENOMEM; | ||
143 | |||
144 | pmx->base = (u32)driver->base; | ||
145 | pmx->mode_reg.offset = driver->mode_reg.offset; | ||
146 | pmx->mode_reg.mask = driver->mode_reg.mask; | ||
147 | pmx->mux_reg.offset = driver->mux_reg.offset; | ||
148 | pmx->mux_reg.mask = driver->mux_reg.mask; | ||
149 | |||
150 | /* choose mode to enable */ | ||
151 | if (driver->mode) { | ||
152 | ret = pmx_mode_set(driver->mode); | ||
153 | if (ret) | ||
154 | goto pmx_fail; | ||
155 | } | ||
156 | ret = pmx_devs_enable(driver->devs, driver->devs_count); | ||
157 | if (ret) | ||
158 | goto pmx_fail; | ||
159 | |||
160 | return 0; | ||
161 | |||
162 | pmx_fail: | ||
163 | return ret; | ||
164 | } | ||
diff --git a/arch/arm/plat-spear/pl080.c b/arch/arm/plat-spear/pl080.c new file mode 100644 index 000000000000..a56a067717c1 --- /dev/null +++ b/arch/arm/plat-spear/pl080.c | |||
@@ -0,0 +1,80 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-spear/pl080.c | ||
3 | * | ||
4 | * DMAC pl080 definitions for SPEAr platform | ||
5 | * | ||
6 | * Copyright (C) 2012 ST Microelectronics | ||
7 | * Viresh Kumar <viresh.kumar@st.com> | ||
8 | * | ||
9 | * This file is licensed under the terms of the GNU General Public | ||
10 | * License version 2. This program is licensed "as is" without any | ||
11 | * warranty of any kind, whether express or implied. | ||
12 | */ | ||
13 | |||
14 | #include <linux/amba/pl08x.h> | ||
15 | #include <linux/amba/bus.h> | ||
16 | #include <linux/bug.h> | ||
17 | #include <linux/err.h> | ||
18 | #include <linux/io.h> | ||
19 | #include <linux/spinlock_types.h> | ||
20 | #include <mach/spear.h> | ||
21 | #include <mach/misc_regs.h> | ||
22 | |||
23 | static spinlock_t lock = __SPIN_LOCK_UNLOCKED(x); | ||
24 | |||
25 | struct { | ||
26 | unsigned char busy; | ||
27 | unsigned char val; | ||
28 | } signals[16] = {{0, 0}, }; | ||
29 | |||
30 | int pl080_get_signal(struct pl08x_dma_chan *ch) | ||
31 | { | ||
32 | const struct pl08x_channel_data *cd = ch->cd; | ||
33 | unsigned int signal = cd->min_signal, val; | ||
34 | unsigned long flags; | ||
35 | |||
36 | spin_lock_irqsave(&lock, flags); | ||
37 | |||
38 | /* Return if signal is already acquired by somebody else */ | ||
39 | if (signals[signal].busy && | ||
40 | (signals[signal].val != cd->muxval)) { | ||
41 | spin_unlock_irqrestore(&lock, flags); | ||
42 | return -EBUSY; | ||
43 | } | ||
44 | |||
45 | /* If acquiring for the first time, configure it */ | ||
46 | if (!signals[signal].busy) { | ||
47 | val = readl(DMA_CHN_CFG); | ||
48 | |||
49 | /* | ||
50 | * Each request line has two bits in DMA_CHN_CFG register. To | ||
51 | * goto the bits of current request line, do left shift of | ||
52 | * value by 2 * signal number. | ||
53 | */ | ||
54 | val &= ~(0x3 << (signal * 2)); | ||
55 | val |= cd->muxval << (signal * 2); | ||
56 | writel(val, DMA_CHN_CFG); | ||
57 | } | ||
58 | |||
59 | signals[signal].busy++; | ||
60 | signals[signal].val = cd->muxval; | ||
61 | spin_unlock_irqrestore(&lock, flags); | ||
62 | |||
63 | return signal; | ||
64 | } | ||
65 | |||
66 | void pl080_put_signal(struct pl08x_dma_chan *ch) | ||
67 | { | ||
68 | const struct pl08x_channel_data *cd = ch->cd; | ||
69 | unsigned long flags; | ||
70 | |||
71 | spin_lock_irqsave(&lock, flags); | ||
72 | |||
73 | /* if signal is not used */ | ||
74 | if (!signals[cd->min_signal].busy) | ||
75 | BUG(); | ||
76 | |||
77 | signals[cd->min_signal].busy--; | ||
78 | |||
79 | spin_unlock_irqrestore(&lock, flags); | ||
80 | } | ||
diff --git a/arch/arm/plat-spear/restart.c b/arch/arm/plat-spear/restart.c index 16f203e78d89..4471a232713a 100644 --- a/arch/arm/plat-spear/restart.c +++ b/arch/arm/plat-spear/restart.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/io.h> | 13 | #include <linux/io.h> |
14 | #include <asm/system_misc.h> | 14 | #include <asm/system_misc.h> |
15 | #include <asm/hardware/sp810.h> | 15 | #include <asm/hardware/sp810.h> |
16 | #include <mach/hardware.h> | 16 | #include <mach/spear.h> |
17 | #include <mach/generic.h> | 17 | #include <mach/generic.h> |
18 | 18 | ||
19 | void spear_restart(char mode, const char *cmd) | 19 | void spear_restart(char mode, const char *cmd) |
diff --git a/arch/arm/plat-spear/time.c b/arch/arm/plat-spear/time.c index abb5bdecd509..03321af5de9f 100644 --- a/arch/arm/plat-spear/time.c +++ b/arch/arm/plat-spear/time.c | |||
@@ -15,14 +15,15 @@ | |||
15 | #include <linux/err.h> | 15 | #include <linux/err.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
18 | #include <linux/ioport.h> | ||
18 | #include <linux/io.h> | 19 | #include <linux/io.h> |
19 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
21 | #include <linux/of_irq.h> | ||
22 | #include <linux/of_address.h> | ||
20 | #include <linux/time.h> | 23 | #include <linux/time.h> |
21 | #include <linux/irq.h> | 24 | #include <linux/irq.h> |
22 | #include <asm/mach/time.h> | 25 | #include <asm/mach/time.h> |
23 | #include <mach/generic.h> | 26 | #include <mach/generic.h> |
24 | #include <mach/hardware.h> | ||
25 | #include <mach/irqs.h> | ||
26 | 27 | ||
27 | /* | 28 | /* |
28 | * We would use TIMER0 and TIMER1 as clockevent and clocksource. | 29 | * We would use TIMER0 and TIMER1 as clockevent and clocksource. |
@@ -175,7 +176,7 @@ static struct irqaction spear_timer_irq = { | |||
175 | .handler = spear_timer_interrupt | 176 | .handler = spear_timer_interrupt |
176 | }; | 177 | }; |
177 | 178 | ||
178 | static void __init spear_clockevent_init(void) | 179 | static void __init spear_clockevent_init(int irq) |
179 | { | 180 | { |
180 | u32 tick_rate; | 181 | u32 tick_rate; |
181 | 182 | ||
@@ -195,22 +196,35 @@ static void __init spear_clockevent_init(void) | |||
195 | 196 | ||
196 | clockevents_register_device(&clkevt); | 197 | clockevents_register_device(&clkevt); |
197 | 198 | ||
198 | setup_irq(SPEAR_GPT0_CHAN0_IRQ, &spear_timer_irq); | 199 | setup_irq(irq, &spear_timer_irq); |
199 | } | 200 | } |
200 | 201 | ||
201 | void __init spear_setup_timer(void) | 202 | const static struct of_device_id timer_of_match[] __initconst = { |
203 | { .compatible = "st,spear-timer", }, | ||
204 | { }, | ||
205 | }; | ||
206 | |||
207 | void __init spear_setup_of_timer(void) | ||
202 | { | 208 | { |
203 | int ret; | 209 | struct device_node *np; |
210 | int irq, ret; | ||
211 | |||
212 | np = of_find_matching_node(NULL, timer_of_match); | ||
213 | if (!np) { | ||
214 | pr_err("%s: No timer passed via DT\n", __func__); | ||
215 | return; | ||
216 | } | ||
204 | 217 | ||
205 | if (!request_mem_region(SPEAR_GPT0_BASE, SZ_1K, "gpt0")) { | 218 | irq = irq_of_parse_and_map(np, 0); |
206 | pr_err("%s:cannot get IO addr\n", __func__); | 219 | if (!irq) { |
220 | pr_err("%s: No irq passed for timer via DT\n", __func__); | ||
207 | return; | 221 | return; |
208 | } | 222 | } |
209 | 223 | ||
210 | gpt_base = (void __iomem *)ioremap(SPEAR_GPT0_BASE, SZ_1K); | 224 | gpt_base = of_iomap(np, 0); |
211 | if (!gpt_base) { | 225 | if (!gpt_base) { |
212 | pr_err("%s:ioremap failed for gpt\n", __func__); | 226 | pr_err("%s: of iomap failed\n", __func__); |
213 | goto err_mem; | 227 | return; |
214 | } | 228 | } |
215 | 229 | ||
216 | gpt_clk = clk_get_sys("gpt0", NULL); | 230 | gpt_clk = clk_get_sys("gpt0", NULL); |
@@ -219,21 +233,19 @@ void __init spear_setup_timer(void) | |||
219 | goto err_iomap; | 233 | goto err_iomap; |
220 | } | 234 | } |
221 | 235 | ||
222 | ret = clk_enable(gpt_clk); | 236 | ret = clk_prepare_enable(gpt_clk); |
223 | if (ret < 0) { | 237 | if (ret < 0) { |
224 | pr_err("%s:couldn't enable gpt clock\n", __func__); | 238 | pr_err("%s:couldn't prepare-enable gpt clock\n", __func__); |
225 | goto err_clk; | 239 | goto err_prepare_enable_clk; |
226 | } | 240 | } |
227 | 241 | ||
228 | spear_clockevent_init(); | 242 | spear_clockevent_init(irq); |
229 | spear_clocksource_init(); | 243 | spear_clocksource_init(); |
230 | 244 | ||
231 | return; | 245 | return; |
232 | 246 | ||
233 | err_clk: | 247 | err_prepare_enable_clk: |
234 | clk_put(gpt_clk); | 248 | clk_put(gpt_clk); |
235 | err_iomap: | 249 | err_iomap: |
236 | iounmap(gpt_base); | 250 | iounmap(gpt_base); |
237 | err_mem: | ||
238 | release_mem_region(SPEAR_GPT0_BASE, SZ_1K); | ||
239 | } | 251 | } |
diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index 858748eaa144..bc683b8219b5 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <linux/sched.h> | 17 | #include <linux/sched.h> |
18 | #include <linux/smp.h> | 18 | #include <linux/smp.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/uaccess.h> | ||
21 | #include <linux/user.h> | ||
20 | 22 | ||
21 | #include <asm/cp15.h> | 23 | #include <asm/cp15.h> |
22 | #include <asm/cputype.h> | 24 | #include <asm/cputype.h> |
@@ -529,6 +531,103 @@ void vfp_flush_hwstate(struct thread_info *thread) | |||
529 | } | 531 | } |
530 | 532 | ||
531 | /* | 533 | /* |
534 | * Save the current VFP state into the provided structures and prepare | ||
535 | * for entry into a new function (signal handler). | ||
536 | */ | ||
537 | int vfp_preserve_user_clear_hwstate(struct user_vfp __user *ufp, | ||
538 | struct user_vfp_exc __user *ufp_exc) | ||
539 | { | ||
540 | struct thread_info *thread = current_thread_info(); | ||
541 | struct vfp_hard_struct *hwstate = &thread->vfpstate.hard; | ||
542 | int err = 0; | ||
543 | |||
544 | /* Ensure that the saved hwstate is up-to-date. */ | ||
545 | vfp_sync_hwstate(thread); | ||
546 | |||
547 | /* | ||
548 | * Copy the floating point registers. There can be unused | ||
549 | * registers see asm/hwcap.h for details. | ||
550 | */ | ||
551 | err |= __copy_to_user(&ufp->fpregs, &hwstate->fpregs, | ||
552 | sizeof(hwstate->fpregs)); | ||
553 | /* | ||
554 | * Copy the status and control register. | ||
555 | */ | ||
556 | __put_user_error(hwstate->fpscr, &ufp->fpscr, err); | ||
557 | |||
558 | /* | ||
559 | * Copy the exception registers. | ||
560 | */ | ||
561 | __put_user_error(hwstate->fpexc, &ufp_exc->fpexc, err); | ||
562 | __put_user_error(hwstate->fpinst, &ufp_exc->fpinst, err); | ||
563 | __put_user_error(hwstate->fpinst2, &ufp_exc->fpinst2, err); | ||
564 | |||
565 | if (err) | ||
566 | return -EFAULT; | ||
567 | |||
568 | /* Ensure that VFP is disabled. */ | ||
569 | vfp_flush_hwstate(thread); | ||
570 | |||
571 | /* | ||
572 | * As per the PCS, clear the length and stride bits for function | ||
573 | * entry. | ||
574 | */ | ||
575 | hwstate->fpscr &= ~(FPSCR_LENGTH_MASK | FPSCR_STRIDE_MASK); | ||
576 | |||
577 | /* | ||
578 | * Disable VFP in the hwstate so that we can detect if it gets | ||
579 | * used. | ||
580 | */ | ||
581 | hwstate->fpexc &= ~FPEXC_EN; | ||
582 | return 0; | ||
583 | } | ||
584 | |||
585 | /* Sanitise and restore the current VFP state from the provided structures. */ | ||
586 | int vfp_restore_user_hwstate(struct user_vfp __user *ufp, | ||
587 | struct user_vfp_exc __user *ufp_exc) | ||
588 | { | ||
589 | struct thread_info *thread = current_thread_info(); | ||
590 | struct vfp_hard_struct *hwstate = &thread->vfpstate.hard; | ||
591 | unsigned long fpexc; | ||
592 | int err = 0; | ||
593 | |||
594 | /* | ||
595 | * If VFP has been used, then disable it to avoid corrupting | ||
596 | * the new thread state. | ||
597 | */ | ||
598 | if (hwstate->fpexc & FPEXC_EN) | ||
599 | vfp_flush_hwstate(thread); | ||
600 | |||
601 | /* | ||
602 | * Copy the floating point registers. There can be unused | ||
603 | * registers see asm/hwcap.h for details. | ||
604 | */ | ||
605 | err |= __copy_from_user(&hwstate->fpregs, &ufp->fpregs, | ||
606 | sizeof(hwstate->fpregs)); | ||
607 | /* | ||
608 | * Copy the status and control register. | ||
609 | */ | ||
610 | __get_user_error(hwstate->fpscr, &ufp->fpscr, err); | ||
611 | |||
612 | /* | ||
613 | * Sanitise and restore the exception registers. | ||
614 | */ | ||
615 | __get_user_error(fpexc, &ufp_exc->fpexc, err); | ||
616 | |||
617 | /* Ensure the VFP is enabled. */ | ||
618 | fpexc |= FPEXC_EN; | ||
619 | |||
620 | /* Ensure FPINST2 is invalid and the exception flag is cleared. */ | ||
621 | fpexc &= ~(FPEXC_EX | FPEXC_FP2V); | ||
622 | hwstate->fpexc = fpexc; | ||
623 | |||
624 | __get_user_error(hwstate->fpinst, &ufp_exc->fpinst, err); | ||
625 | __get_user_error(hwstate->fpinst2, &ufp_exc->fpinst2, err); | ||
626 | |||
627 | return err ? -EFAULT : 0; | ||
628 | } | ||
629 | |||
630 | /* | ||
532 | * VFP hardware can lose all context when a CPU goes offline. | 631 | * VFP hardware can lose all context when a CPU goes offline. |
533 | * As we will be running in SMP mode with CPU hotplug, we will save the | 632 | * As we will be running in SMP mode with CPU hotplug, we will save the |
534 | * hardware state at every thread switch. We clear our held state when | 633 | * hardware state at every thread switch. We clear our held state when |
diff --git a/arch/blackfin/mach-bf538/boards/ezkit.c b/arch/blackfin/mach-bf538/boards/ezkit.c index 1633a6f306c0..85038f54354d 100644 --- a/arch/blackfin/mach-bf538/boards/ezkit.c +++ b/arch/blackfin/mach-bf538/boards/ezkit.c | |||
@@ -38,7 +38,7 @@ static struct platform_device rtc_device = { | |||
38 | .name = "rtc-bfin", | 38 | .name = "rtc-bfin", |
39 | .id = -1, | 39 | .id = -1, |
40 | }; | 40 | }; |
41 | #endif | 41 | #endif /* CONFIG_RTC_DRV_BFIN */ |
42 | 42 | ||
43 | #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) | 43 | #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) |
44 | #ifdef CONFIG_SERIAL_BFIN_UART0 | 44 | #ifdef CONFIG_SERIAL_BFIN_UART0 |
@@ -100,7 +100,7 @@ static struct platform_device bfin_uart0_device = { | |||
100 | .platform_data = &bfin_uart0_peripherals, /* Passed to driver */ | 100 | .platform_data = &bfin_uart0_peripherals, /* Passed to driver */ |
101 | }, | 101 | }, |
102 | }; | 102 | }; |
103 | #endif | 103 | #endif /* CONFIG_SERIAL_BFIN_UART0 */ |
104 | #ifdef CONFIG_SERIAL_BFIN_UART1 | 104 | #ifdef CONFIG_SERIAL_BFIN_UART1 |
105 | static struct resource bfin_uart1_resources[] = { | 105 | static struct resource bfin_uart1_resources[] = { |
106 | { | 106 | { |
@@ -148,7 +148,7 @@ static struct platform_device bfin_uart1_device = { | |||
148 | .platform_data = &bfin_uart1_peripherals, /* Passed to driver */ | 148 | .platform_data = &bfin_uart1_peripherals, /* Passed to driver */ |
149 | }, | 149 | }, |
150 | }; | 150 | }; |
151 | #endif | 151 | #endif /* CONFIG_SERIAL_BFIN_UART1 */ |
152 | #ifdef CONFIG_SERIAL_BFIN_UART2 | 152 | #ifdef CONFIG_SERIAL_BFIN_UART2 |
153 | static struct resource bfin_uart2_resources[] = { | 153 | static struct resource bfin_uart2_resources[] = { |
154 | { | 154 | { |
@@ -196,8 +196,8 @@ static struct platform_device bfin_uart2_device = { | |||
196 | .platform_data = &bfin_uart2_peripherals, /* Passed to driver */ | 196 | .platform_data = &bfin_uart2_peripherals, /* Passed to driver */ |
197 | }, | 197 | }, |
198 | }; | 198 | }; |
199 | #endif | 199 | #endif /* CONFIG_SERIAL_BFIN_UART2 */ |
200 | #endif | 200 | #endif /* CONFIG_SERIAL_BFIN */ |
201 | 201 | ||
202 | #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) | 202 | #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE) |
203 | #ifdef CONFIG_BFIN_SIR0 | 203 | #ifdef CONFIG_BFIN_SIR0 |
@@ -224,7 +224,7 @@ static struct platform_device bfin_sir0_device = { | |||
224 | .num_resources = ARRAY_SIZE(bfin_sir0_resources), | 224 | .num_resources = ARRAY_SIZE(bfin_sir0_resources), |
225 | .resource = bfin_sir0_resources, | 225 | .resource = bfin_sir0_resources, |
226 | }; | 226 | }; |
227 | #endif | 227 | #endif /* CONFIG_BFIN_SIR0 */ |
228 | #ifdef CONFIG_BFIN_SIR1 | 228 | #ifdef CONFIG_BFIN_SIR1 |
229 | static struct resource bfin_sir1_resources[] = { | 229 | static struct resource bfin_sir1_resources[] = { |
230 | { | 230 | { |
@@ -249,7 +249,7 @@ static struct platform_device bfin_sir1_device = { | |||
249 | .num_resources = ARRAY_SIZE(bfin_sir1_resources), | 249 | .num_resources = ARRAY_SIZE(bfin_sir1_resources), |
250 | .resource = bfin_sir1_resources, | 250 | .resource = bfin_sir1_resources, |
251 | }; | 251 | }; |
252 | #endif | 252 | #endif /* CONFIG_BFIN_SIR1 */ |
253 | #ifdef CONFIG_BFIN_SIR2 | 253 | #ifdef CONFIG_BFIN_SIR2 |
254 | static struct resource bfin_sir2_resources[] = { | 254 | static struct resource bfin_sir2_resources[] = { |
255 | { | 255 | { |
@@ -274,8 +274,8 @@ static struct platform_device bfin_sir2_device = { | |||
274 | .num_resources = ARRAY_SIZE(bfin_sir2_resources), | 274 | .num_resources = ARRAY_SIZE(bfin_sir2_resources), |
275 | .resource = bfin_sir2_resources, | 275 | .resource = bfin_sir2_resources, |
276 | }; | 276 | }; |
277 | #endif | 277 | #endif /* CONFIG_BFIN_SIR2 */ |
278 | #endif | 278 | #endif /* CONFIG_BFIN_SIR */ |
279 | 279 | ||
280 | #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) | 280 | #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) |
281 | #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART | 281 | #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART |
@@ -311,7 +311,7 @@ static struct platform_device bfin_sport0_uart_device = { | |||
311 | .platform_data = &bfin_sport0_peripherals, /* Passed to driver */ | 311 | .platform_data = &bfin_sport0_peripherals, /* Passed to driver */ |
312 | }, | 312 | }, |
313 | }; | 313 | }; |
314 | #endif | 314 | #endif /* CONFIG_SERIAL_BFIN_SPORT0_UART */ |
315 | #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART | 315 | #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART |
316 | static struct resource bfin_sport1_uart_resources[] = { | 316 | static struct resource bfin_sport1_uart_resources[] = { |
317 | { | 317 | { |
@@ -345,7 +345,7 @@ static struct platform_device bfin_sport1_uart_device = { | |||
345 | .platform_data = &bfin_sport1_peripherals, /* Passed to driver */ | 345 | .platform_data = &bfin_sport1_peripherals, /* Passed to driver */ |
346 | }, | 346 | }, |
347 | }; | 347 | }; |
348 | #endif | 348 | #endif /* CONFIG_SERIAL_BFIN_SPORT1_UART */ |
349 | #ifdef CONFIG_SERIAL_BFIN_SPORT2_UART | 349 | #ifdef CONFIG_SERIAL_BFIN_SPORT2_UART |
350 | static struct resource bfin_sport2_uart_resources[] = { | 350 | static struct resource bfin_sport2_uart_resources[] = { |
351 | { | 351 | { |
@@ -379,7 +379,7 @@ static struct platform_device bfin_sport2_uart_device = { | |||
379 | .platform_data = &bfin_sport2_peripherals, /* Passed to driver */ | 379 | .platform_data = &bfin_sport2_peripherals, /* Passed to driver */ |
380 | }, | 380 | }, |
381 | }; | 381 | }; |
382 | #endif | 382 | #endif /* CONFIG_SERIAL_BFIN_SPORT2_UART */ |
383 | #ifdef CONFIG_SERIAL_BFIN_SPORT3_UART | 383 | #ifdef CONFIG_SERIAL_BFIN_SPORT3_UART |
384 | static struct resource bfin_sport3_uart_resources[] = { | 384 | static struct resource bfin_sport3_uart_resources[] = { |
385 | { | 385 | { |
@@ -413,8 +413,8 @@ static struct platform_device bfin_sport3_uart_device = { | |||
413 | .platform_data = &bfin_sport3_peripherals, /* Passed to driver */ | 413 | .platform_data = &bfin_sport3_peripherals, /* Passed to driver */ |
414 | }, | 414 | }, |
415 | }; | 415 | }; |
416 | #endif | 416 | #endif /* CONFIG_SERIAL_BFIN_SPORT3_UART */ |
417 | #endif | 417 | #endif /* CONFIG_SERIAL_BFIN_SPORT */ |
418 | 418 | ||
419 | #if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE) | 419 | #if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE) |
420 | static unsigned short bfin_can_peripherals[] = { | 420 | static unsigned short bfin_can_peripherals[] = { |
@@ -452,7 +452,7 @@ static struct platform_device bfin_can_device = { | |||
452 | .platform_data = &bfin_can_peripherals, /* Passed to driver */ | 452 | .platform_data = &bfin_can_peripherals, /* Passed to driver */ |
453 | }, | 453 | }, |
454 | }; | 454 | }; |
455 | #endif | 455 | #endif /* CONFIG_CAN_BFIN */ |
456 | 456 | ||
457 | /* | 457 | /* |
458 | * USB-LAN EzExtender board | 458 | * USB-LAN EzExtender board |
@@ -488,7 +488,7 @@ static struct platform_device smc91x_device = { | |||
488 | .platform_data = &smc91x_info, | 488 | .platform_data = &smc91x_info, |
489 | }, | 489 | }, |
490 | }; | 490 | }; |
491 | #endif | 491 | #endif /* CONFIG_SMC91X */ |
492 | 492 | ||
493 | #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) | 493 | #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE) |
494 | /* all SPI peripherals info goes here */ | 494 | /* all SPI peripherals info goes here */ |
@@ -518,7 +518,8 @@ static struct flash_platform_data bfin_spi_flash_data = { | |||
518 | static struct bfin5xx_spi_chip spi_flash_chip_info = { | 518 | static struct bfin5xx_spi_chip spi_flash_chip_info = { |
519 | .enable_dma = 0, /* use dma transfer with this chip*/ | 519 | .enable_dma = 0, /* use dma transfer with this chip*/ |
520 | }; | 520 | }; |
521 | #endif | 521 | #endif /* CONFIG_MTD_M25P80 */ |
522 | #endif /* CONFIG_SPI_BFIN5XX */ | ||
522 | 523 | ||
523 | #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE) | 524 | #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE) |
524 | #include <linux/spi/ad7879.h> | 525 | #include <linux/spi/ad7879.h> |
@@ -535,7 +536,7 @@ static const struct ad7879_platform_data bfin_ad7879_ts_info = { | |||
535 | .gpio_export = 1, /* Export GPIO to gpiolib */ | 536 | .gpio_export = 1, /* Export GPIO to gpiolib */ |
536 | .gpio_base = -1, /* Dynamic allocation */ | 537 | .gpio_base = -1, /* Dynamic allocation */ |
537 | }; | 538 | }; |
538 | #endif | 539 | #endif /* CONFIG_TOUCHSCREEN_AD7879 */ |
539 | 540 | ||
540 | #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) | 541 | #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) |
541 | #include <asm/bfin-lq035q1.h> | 542 | #include <asm/bfin-lq035q1.h> |
@@ -564,7 +565,7 @@ static struct platform_device bfin_lq035q1_device = { | |||
564 | .platform_data = &bfin_lq035q1_data, | 565 | .platform_data = &bfin_lq035q1_data, |
565 | }, | 566 | }, |
566 | }; | 567 | }; |
567 | #endif | 568 | #endif /* CONFIG_FB_BFIN_LQ035Q1 */ |
568 | 569 | ||
569 | static struct spi_board_info bf538_spi_board_info[] __initdata = { | 570 | static struct spi_board_info bf538_spi_board_info[] __initdata = { |
570 | #if defined(CONFIG_MTD_M25P80) \ | 571 | #if defined(CONFIG_MTD_M25P80) \ |
@@ -579,7 +580,7 @@ static struct spi_board_info bf538_spi_board_info[] __initdata = { | |||
579 | .controller_data = &spi_flash_chip_info, | 580 | .controller_data = &spi_flash_chip_info, |
580 | .mode = SPI_MODE_3, | 581 | .mode = SPI_MODE_3, |
581 | }, | 582 | }, |
582 | #endif | 583 | #endif /* CONFIG_MTD_M25P80 */ |
583 | #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE) | 584 | #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE) |
584 | { | 585 | { |
585 | .modalias = "ad7879", | 586 | .modalias = "ad7879", |
@@ -590,7 +591,7 @@ static struct spi_board_info bf538_spi_board_info[] __initdata = { | |||
590 | .chip_select = 1, | 591 | .chip_select = 1, |
591 | .mode = SPI_CPHA | SPI_CPOL, | 592 | .mode = SPI_CPHA | SPI_CPOL, |
592 | }, | 593 | }, |
593 | #endif | 594 | #endif /* CONFIG_TOUCHSCREEN_AD7879_SPI */ |
594 | #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) | 595 | #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE) |
595 | { | 596 | { |
596 | .modalias = "bfin-lq035q1-spi", | 597 | .modalias = "bfin-lq035q1-spi", |
@@ -599,7 +600,7 @@ static struct spi_board_info bf538_spi_board_info[] __initdata = { | |||
599 | .chip_select = 2, | 600 | .chip_select = 2, |
600 | .mode = SPI_CPHA | SPI_CPOL, | 601 | .mode = SPI_CPHA | SPI_CPOL, |
601 | }, | 602 | }, |
602 | #endif | 603 | #endif /* CONFIG_FB_BFIN_LQ035Q1 */ |
603 | #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) | 604 | #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) |
604 | { | 605 | { |
605 | .modalias = "spidev", | 606 | .modalias = "spidev", |
@@ -607,7 +608,7 @@ static struct spi_board_info bf538_spi_board_info[] __initdata = { | |||
607 | .bus_num = 0, | 608 | .bus_num = 0, |
608 | .chip_select = 1, | 609 | .chip_select = 1, |
609 | }, | 610 | }, |
610 | #endif | 611 | #endif /* CONFIG_SPI_SPIDEV */ |
611 | }; | 612 | }; |
612 | 613 | ||
613 | /* SPI (0) */ | 614 | /* SPI (0) */ |
@@ -716,8 +717,6 @@ static struct platform_device bf538_spi_master2 = { | |||
716 | }, | 717 | }, |
717 | }; | 718 | }; |
718 | 719 | ||
719 | #endif /* spi master and devices */ | ||
720 | |||
721 | #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) | 720 | #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) |
722 | static struct resource bfin_twi0_resource[] = { | 721 | static struct resource bfin_twi0_resource[] = { |
723 | [0] = { | 722 | [0] = { |
@@ -759,8 +758,8 @@ static struct platform_device i2c_bfin_twi1_device = { | |||
759 | .num_resources = ARRAY_SIZE(bfin_twi1_resource), | 758 | .num_resources = ARRAY_SIZE(bfin_twi1_resource), |
760 | .resource = bfin_twi1_resource, | 759 | .resource = bfin_twi1_resource, |
761 | }; | 760 | }; |
762 | #endif | 761 | #endif /* CONFIG_BF542 */ |
763 | #endif | 762 | #endif /* CONFIG_I2C_BLACKFIN_TWI */ |
764 | 763 | ||
765 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) | 764 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) |
766 | #include <linux/gpio_keys.h> | 765 | #include <linux/gpio_keys.h> |
diff --git a/arch/hexagon/kernel/dma.c b/arch/hexagon/kernel/dma.c index 37302218ca4a..0f2367cc5493 100644 --- a/arch/hexagon/kernel/dma.c +++ b/arch/hexagon/kernel/dma.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/bootmem.h> | 22 | #include <linux/bootmem.h> |
23 | #include <linux/genalloc.h> | 23 | #include <linux/genalloc.h> |
24 | #include <asm/dma-mapping.h> | 24 | #include <asm/dma-mapping.h> |
25 | #include <linux/module.h> | ||
25 | 26 | ||
26 | struct dma_map_ops *dma_ops; | 27 | struct dma_map_ops *dma_ops; |
27 | EXPORT_SYMBOL(dma_ops); | 28 | EXPORT_SYMBOL(dma_ops); |
diff --git a/arch/hexagon/kernel/process.c b/arch/hexagon/kernel/process.c index 18c4f0b0f4ba..ff02821bfb7e 100644 --- a/arch/hexagon/kernel/process.c +++ b/arch/hexagon/kernel/process.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Process creation support for Hexagon | 2 | * Process creation support for Hexagon |
3 | * | 3 | * |
4 | * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. | 4 | * Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved. |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License version 2 and | 7 | * it under the terms of the GNU General Public License version 2 and |
@@ -88,7 +88,7 @@ void (*idle_sleep)(void) = default_idle; | |||
88 | void cpu_idle(void) | 88 | void cpu_idle(void) |
89 | { | 89 | { |
90 | while (1) { | 90 | while (1) { |
91 | tick_nohz_stop_sched_tick(1); | 91 | tick_nohz_idle_enter(); |
92 | local_irq_disable(); | 92 | local_irq_disable(); |
93 | while (!need_resched()) { | 93 | while (!need_resched()) { |
94 | idle_sleep(); | 94 | idle_sleep(); |
@@ -97,7 +97,7 @@ void cpu_idle(void) | |||
97 | local_irq_disable(); | 97 | local_irq_disable(); |
98 | } | 98 | } |
99 | local_irq_enable(); | 99 | local_irq_enable(); |
100 | tick_nohz_restart_sched_tick(); | 100 | tick_nohz_idle_exit(); |
101 | schedule(); | 101 | schedule(); |
102 | } | 102 | } |
103 | } | 103 | } |
diff --git a/arch/hexagon/kernel/ptrace.c b/arch/hexagon/kernel/ptrace.c index 32342de1a79c..96c3b2c4dbad 100644 --- a/arch/hexagon/kernel/ptrace.c +++ b/arch/hexagon/kernel/ptrace.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/ptrace.h> | 28 | #include <linux/ptrace.h> |
29 | #include <linux/regset.h> | 29 | #include <linux/regset.h> |
30 | #include <linux/user.h> | 30 | #include <linux/user.h> |
31 | #include <linux/elf.h> | ||
31 | 32 | ||
32 | #include <asm/user.h> | 33 | #include <asm/user.h> |
33 | 34 | ||
diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c index 9b44a9e2d05a..1298141874a3 100644 --- a/arch/hexagon/kernel/smp.c +++ b/arch/hexagon/kernel/smp.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * SMP support for Hexagon | 2 | * SMP support for Hexagon |
3 | * | 3 | * |
4 | * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. | 4 | * Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved. |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License version 2 and | 7 | * it under the terms of the GNU General Public License version 2 and |
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/sched.h> | 28 | #include <linux/sched.h> |
29 | #include <linux/smp.h> | 29 | #include <linux/smp.h> |
30 | #include <linux/spinlock.h> | 30 | #include <linux/spinlock.h> |
31 | #include <linux/cpu.h> | ||
31 | 32 | ||
32 | #include <asm/time.h> /* timer_interrupt */ | 33 | #include <asm/time.h> /* timer_interrupt */ |
33 | #include <asm/hexagon_vm.h> | 34 | #include <asm/hexagon_vm.h> |
@@ -177,7 +178,12 @@ void __cpuinit start_secondary(void) | |||
177 | 178 | ||
178 | printk(KERN_INFO "%s cpu %d\n", __func__, current_thread_info()->cpu); | 179 | printk(KERN_INFO "%s cpu %d\n", __func__, current_thread_info()->cpu); |
179 | 180 | ||
181 | notify_cpu_starting(cpu); | ||
182 | |||
183 | ipi_call_lock(); | ||
180 | set_cpu_online(cpu, true); | 184 | set_cpu_online(cpu, true); |
185 | ipi_call_unlock(); | ||
186 | |||
181 | local_irq_enable(); | 187 | local_irq_enable(); |
182 | 188 | ||
183 | cpu_idle(); | 189 | cpu_idle(); |
diff --git a/arch/hexagon/kernel/time.c b/arch/hexagon/kernel/time.c index 6bee15c9c113..5d9b33b67935 100644 --- a/arch/hexagon/kernel/time.c +++ b/arch/hexagon/kernel/time.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/of.h> | 28 | #include <linux/of.h> |
29 | #include <linux/of_address.h> | 29 | #include <linux/of_address.h> |
30 | #include <linux/of_irq.h> | 30 | #include <linux/of_irq.h> |
31 | #include <linux/module.h> | ||
31 | 32 | ||
32 | #include <asm/timer-regs.h> | 33 | #include <asm/timer-regs.h> |
33 | #include <asm/hexagon_vm.h> | 34 | #include <asm/hexagon_vm.h> |
diff --git a/arch/hexagon/kernel/vdso.c b/arch/hexagon/kernel/vdso.c index f212a453b527..5d39f42f7085 100644 --- a/arch/hexagon/kernel/vdso.c +++ b/arch/hexagon/kernel/vdso.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
22 | #include <linux/mm.h> | 22 | #include <linux/mm.h> |
23 | #include <linux/vmalloc.h> | 23 | #include <linux/vmalloc.h> |
24 | #include <linux/binfmts.h> | ||
24 | 25 | ||
25 | #include <asm/vdso.h> | 26 | #include <asm/vdso.h> |
26 | 27 | ||
diff --git a/arch/mips/ath79/dev-wmac.c b/arch/mips/ath79/dev-wmac.c index e21507052066..9c717bf98ffe 100644 --- a/arch/mips/ath79/dev-wmac.c +++ b/arch/mips/ath79/dev-wmac.c | |||
@@ -58,8 +58,8 @@ static void __init ar913x_wmac_setup(void) | |||
58 | 58 | ||
59 | static int ar933x_wmac_reset(void) | 59 | static int ar933x_wmac_reset(void) |
60 | { | 60 | { |
61 | ath79_device_reset_clear(AR933X_RESET_WMAC); | ||
62 | ath79_device_reset_set(AR933X_RESET_WMAC); | 61 | ath79_device_reset_set(AR933X_RESET_WMAC); |
62 | ath79_device_reset_clear(AR933X_RESET_WMAC); | ||
63 | 63 | ||
64 | return 0; | 64 | return 0; |
65 | } | 65 | } |
diff --git a/arch/mips/include/asm/mach-jz4740/irq.h b/arch/mips/include/asm/mach-jz4740/irq.h index a865c983c70a..5ad1a9c113c6 100644 --- a/arch/mips/include/asm/mach-jz4740/irq.h +++ b/arch/mips/include/asm/mach-jz4740/irq.h | |||
@@ -45,7 +45,7 @@ | |||
45 | #define JZ4740_IRQ_LCD JZ4740_IRQ(30) | 45 | #define JZ4740_IRQ_LCD JZ4740_IRQ(30) |
46 | 46 | ||
47 | /* 2nd-level interrupts */ | 47 | /* 2nd-level interrupts */ |
48 | #define JZ4740_IRQ_DMA(x) (JZ4740_IRQ(32) + (X)) | 48 | #define JZ4740_IRQ_DMA(x) (JZ4740_IRQ(32) + (x)) |
49 | 49 | ||
50 | #define JZ4740_IRQ_INTC_GPIO(x) (JZ4740_IRQ_GPIO0 - (x)) | 50 | #define JZ4740_IRQ_INTC_GPIO(x) (JZ4740_IRQ_GPIO0 - (x)) |
51 | #define JZ4740_IRQ_GPIO(x) (JZ4740_IRQ(48) + (x)) | 51 | #define JZ4740_IRQ_GPIO(x) (JZ4740_IRQ(48) + (x)) |
diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h index 73c0d45798de..9b02cfba7449 100644 --- a/arch/mips/include/asm/mmu_context.h +++ b/arch/mips/include/asm/mmu_context.h | |||
@@ -37,12 +37,6 @@ extern void tlbmiss_handler_setup_pgd(unsigned long pgd); | |||
37 | write_c0_xcontext((unsigned long) smp_processor_id() << 51); \ | 37 | write_c0_xcontext((unsigned long) smp_processor_id() << 51); \ |
38 | } while (0) | 38 | } while (0) |
39 | 39 | ||
40 | |||
41 | static inline unsigned long get_current_pgd(void) | ||
42 | { | ||
43 | return PHYS_TO_XKSEG_CACHED((read_c0_context() >> 11) & ~0xfffUL); | ||
44 | } | ||
45 | |||
46 | #else /* CONFIG_MIPS_PGD_C0_CONTEXT: using pgd_current*/ | 40 | #else /* CONFIG_MIPS_PGD_C0_CONTEXT: using pgd_current*/ |
47 | 41 | ||
48 | /* | 42 | /* |
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c index 185ca00c4c84..d5a338a1739c 100644 --- a/arch/mips/kernel/signal.c +++ b/arch/mips/kernel/signal.c | |||
@@ -257,11 +257,8 @@ asmlinkage int sys_sigsuspend(nabi_no_regargs struct pt_regs regs) | |||
257 | return -EFAULT; | 257 | return -EFAULT; |
258 | sigdelsetmask(&newset, ~_BLOCKABLE); | 258 | sigdelsetmask(&newset, ~_BLOCKABLE); |
259 | 259 | ||
260 | spin_lock_irq(¤t->sighand->siglock); | ||
261 | current->saved_sigmask = current->blocked; | 260 | current->saved_sigmask = current->blocked; |
262 | current->blocked = newset; | 261 | set_current_blocked(&newset); |
263 | recalc_sigpending(); | ||
264 | spin_unlock_irq(¤t->sighand->siglock); | ||
265 | 262 | ||
266 | current->state = TASK_INTERRUPTIBLE; | 263 | current->state = TASK_INTERRUPTIBLE; |
267 | schedule(); | 264 | schedule(); |
@@ -286,11 +283,8 @@ asmlinkage int sys_rt_sigsuspend(nabi_no_regargs struct pt_regs regs) | |||
286 | return -EFAULT; | 283 | return -EFAULT; |
287 | sigdelsetmask(&newset, ~_BLOCKABLE); | 284 | sigdelsetmask(&newset, ~_BLOCKABLE); |
288 | 285 | ||
289 | spin_lock_irq(¤t->sighand->siglock); | ||
290 | current->saved_sigmask = current->blocked; | 286 | current->saved_sigmask = current->blocked; |
291 | current->blocked = newset; | 287 | set_current_blocked(&newset); |
292 | recalc_sigpending(); | ||
293 | spin_unlock_irq(¤t->sighand->siglock); | ||
294 | 288 | ||
295 | current->state = TASK_INTERRUPTIBLE; | 289 | current->state = TASK_INTERRUPTIBLE; |
296 | schedule(); | 290 | schedule(); |
@@ -362,10 +356,7 @@ asmlinkage void sys_sigreturn(nabi_no_regargs struct pt_regs regs) | |||
362 | goto badframe; | 356 | goto badframe; |
363 | 357 | ||
364 | sigdelsetmask(&blocked, ~_BLOCKABLE); | 358 | sigdelsetmask(&blocked, ~_BLOCKABLE); |
365 | spin_lock_irq(¤t->sighand->siglock); | 359 | set_current_blocked(&blocked); |
366 | current->blocked = blocked; | ||
367 | recalc_sigpending(); | ||
368 | spin_unlock_irq(¤t->sighand->siglock); | ||
369 | 360 | ||
370 | sig = restore_sigcontext(®s, &frame->sf_sc); | 361 | sig = restore_sigcontext(®s, &frame->sf_sc); |
371 | if (sig < 0) | 362 | if (sig < 0) |
@@ -401,10 +392,7 @@ asmlinkage void sys_rt_sigreturn(nabi_no_regargs struct pt_regs regs) | |||
401 | goto badframe; | 392 | goto badframe; |
402 | 393 | ||
403 | sigdelsetmask(&set, ~_BLOCKABLE); | 394 | sigdelsetmask(&set, ~_BLOCKABLE); |
404 | spin_lock_irq(¤t->sighand->siglock); | 395 | set_current_blocked(&set); |
405 | current->blocked = set; | ||
406 | recalc_sigpending(); | ||
407 | spin_unlock_irq(¤t->sighand->siglock); | ||
408 | 396 | ||
409 | sig = restore_sigcontext(®s, &frame->rs_uc.uc_mcontext); | 397 | sig = restore_sigcontext(®s, &frame->rs_uc.uc_mcontext); |
410 | if (sig < 0) | 398 | if (sig < 0) |
@@ -580,12 +568,7 @@ static int handle_signal(unsigned long sig, siginfo_t *info, | |||
580 | if (ret) | 568 | if (ret) |
581 | return ret; | 569 | return ret; |
582 | 570 | ||
583 | spin_lock_irq(¤t->sighand->siglock); | 571 | block_sigmask(ka, sig); |
584 | sigorsets(¤t->blocked, ¤t->blocked, &ka->sa.sa_mask); | ||
585 | if (!(ka->sa.sa_flags & SA_NODEFER)) | ||
586 | sigaddset(¤t->blocked, sig); | ||
587 | recalc_sigpending(); | ||
588 | spin_unlock_irq(¤t->sighand->siglock); | ||
589 | 572 | ||
590 | return ret; | 573 | return ret; |
591 | } | 574 | } |
diff --git a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c index 06b5da392e24..ac3b8d89aae5 100644 --- a/arch/mips/kernel/signal32.c +++ b/arch/mips/kernel/signal32.c | |||
@@ -290,11 +290,8 @@ asmlinkage int sys32_sigsuspend(nabi_no_regargs struct pt_regs regs) | |||
290 | return -EFAULT; | 290 | return -EFAULT; |
291 | sigdelsetmask(&newset, ~_BLOCKABLE); | 291 | sigdelsetmask(&newset, ~_BLOCKABLE); |
292 | 292 | ||
293 | spin_lock_irq(¤t->sighand->siglock); | ||
294 | current->saved_sigmask = current->blocked; | 293 | current->saved_sigmask = current->blocked; |
295 | current->blocked = newset; | 294 | set_current_blocked(&newset); |
296 | recalc_sigpending(); | ||
297 | spin_unlock_irq(¤t->sighand->siglock); | ||
298 | 295 | ||
299 | current->state = TASK_INTERRUPTIBLE; | 296 | current->state = TASK_INTERRUPTIBLE; |
300 | schedule(); | 297 | schedule(); |
@@ -318,11 +315,8 @@ asmlinkage int sys32_rt_sigsuspend(nabi_no_regargs struct pt_regs regs) | |||
318 | return -EFAULT; | 315 | return -EFAULT; |
319 | sigdelsetmask(&newset, ~_BLOCKABLE); | 316 | sigdelsetmask(&newset, ~_BLOCKABLE); |
320 | 317 | ||
321 | spin_lock_irq(¤t->sighand->siglock); | ||
322 | current->saved_sigmask = current->blocked; | 318 | current->saved_sigmask = current->blocked; |
323 | current->blocked = newset; | 319 | set_current_blocked(&newset); |
324 | recalc_sigpending(); | ||
325 | spin_unlock_irq(¤t->sighand->siglock); | ||
326 | 320 | ||
327 | current->state = TASK_INTERRUPTIBLE; | 321 | current->state = TASK_INTERRUPTIBLE; |
328 | schedule(); | 322 | schedule(); |
@@ -488,10 +482,7 @@ asmlinkage void sys32_sigreturn(nabi_no_regargs struct pt_regs regs) | |||
488 | goto badframe; | 482 | goto badframe; |
489 | 483 | ||
490 | sigdelsetmask(&blocked, ~_BLOCKABLE); | 484 | sigdelsetmask(&blocked, ~_BLOCKABLE); |
491 | spin_lock_irq(¤t->sighand->siglock); | 485 | set_current_blocked(&blocked); |
492 | current->blocked = blocked; | ||
493 | recalc_sigpending(); | ||
494 | spin_unlock_irq(¤t->sighand->siglock); | ||
495 | 486 | ||
496 | sig = restore_sigcontext32(®s, &frame->sf_sc); | 487 | sig = restore_sigcontext32(®s, &frame->sf_sc); |
497 | if (sig < 0) | 488 | if (sig < 0) |
@@ -529,10 +520,7 @@ asmlinkage void sys32_rt_sigreturn(nabi_no_regargs struct pt_regs regs) | |||
529 | goto badframe; | 520 | goto badframe; |
530 | 521 | ||
531 | sigdelsetmask(&set, ~_BLOCKABLE); | 522 | sigdelsetmask(&set, ~_BLOCKABLE); |
532 | spin_lock_irq(¤t->sighand->siglock); | 523 | set_current_blocked(&set); |
533 | current->blocked = set; | ||
534 | recalc_sigpending(); | ||
535 | spin_unlock_irq(¤t->sighand->siglock); | ||
536 | 524 | ||
537 | sig = restore_sigcontext32(®s, &frame->rs_uc.uc_mcontext); | 525 | sig = restore_sigcontext32(®s, &frame->rs_uc.uc_mcontext); |
538 | if (sig < 0) | 526 | if (sig < 0) |
diff --git a/arch/mips/kernel/signal_n32.c b/arch/mips/kernel/signal_n32.c index ae29e894ab8d..86eb4b04631c 100644 --- a/arch/mips/kernel/signal_n32.c +++ b/arch/mips/kernel/signal_n32.c | |||
@@ -93,11 +93,8 @@ asmlinkage int sysn32_rt_sigsuspend(nabi_no_regargs struct pt_regs regs) | |||
93 | sigset_from_compat(&newset, &uset); | 93 | sigset_from_compat(&newset, &uset); |
94 | sigdelsetmask(&newset, ~_BLOCKABLE); | 94 | sigdelsetmask(&newset, ~_BLOCKABLE); |
95 | 95 | ||
96 | spin_lock_irq(¤t->sighand->siglock); | ||
97 | current->saved_sigmask = current->blocked; | 96 | current->saved_sigmask = current->blocked; |
98 | current->blocked = newset; | 97 | set_current_blocked(&newset); |
99 | recalc_sigpending(); | ||
100 | spin_unlock_irq(¤t->sighand->siglock); | ||
101 | 98 | ||
102 | current->state = TASK_INTERRUPTIBLE; | 99 | current->state = TASK_INTERRUPTIBLE; |
103 | schedule(); | 100 | schedule(); |
@@ -121,10 +118,7 @@ asmlinkage void sysn32_rt_sigreturn(nabi_no_regargs struct pt_regs regs) | |||
121 | goto badframe; | 118 | goto badframe; |
122 | 119 | ||
123 | sigdelsetmask(&set, ~_BLOCKABLE); | 120 | sigdelsetmask(&set, ~_BLOCKABLE); |
124 | spin_lock_irq(¤t->sighand->siglock); | 121 | set_current_blocked(&set); |
125 | current->blocked = set; | ||
126 | recalc_sigpending(); | ||
127 | spin_unlock_irq(¤t->sighand->siglock); | ||
128 | 122 | ||
129 | sig = restore_sigcontext(®s, &frame->rs_uc.uc_mcontext); | 123 | sig = restore_sigcontext(®s, &frame->rs_uc.uc_mcontext); |
130 | if (sig < 0) | 124 | if (sig < 0) |
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c index 4f004596a6e7..0b3393381a81 100644 --- a/arch/parisc/kernel/pdc_cons.c +++ b/arch/parisc/kernel/pdc_cons.c | |||
@@ -104,7 +104,7 @@ static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp) | |||
104 | 104 | ||
105 | static void pdc_console_tty_close(struct tty_struct *tty, struct file *filp) | 105 | static void pdc_console_tty_close(struct tty_struct *tty, struct file *filp) |
106 | { | 106 | { |
107 | if (!tty->count) { | 107 | if (tty->count == 1) { |
108 | del_timer_sync(&pdc_console_timer); | 108 | del_timer_sync(&pdc_console_timer); |
109 | tty_port_tty_set(&tty_port, NULL); | 109 | tty_port_tty_set(&tty_port, NULL); |
110 | } | 110 | } |
diff --git a/arch/powerpc/boot/dts/fsl/pq3-mpic-message-B.dtsi b/arch/powerpc/boot/dts/fsl/pq3-mpic-message-B.dtsi new file mode 100644 index 000000000000..1cf0b77b1efe --- /dev/null +++ b/arch/powerpc/boot/dts/fsl/pq3-mpic-message-B.dtsi | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * PQ3 MPIC Message (Group B) device tree stub [ controller @ offset 0x42400 ] | ||
3 | * | ||
4 | * Copyright 2012 Freescale Semiconductor Inc. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions are met: | ||
8 | * * Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * * Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * * Neither the name of Freescale Semiconductor nor the | ||
14 | * names of its contributors may be used to endorse or promote products | ||
15 | * derived from this software without specific prior written permission. | ||
16 | * | ||
17 | * | ||
18 | * ALTERNATIVELY, this software may be distributed under the terms of the | ||
19 | * GNU General Public License ("GPL") as published by the Free Software | ||
20 | * Foundation, either version 2 of that License or (at your option) any | ||
21 | * later version. | ||
22 | * | ||
23 | * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY | ||
24 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
26 | * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY | ||
27 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
30 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | */ | ||
34 | |||
35 | message@42400 { | ||
36 | compatible = "fsl,mpic-v3.1-msgr"; | ||
37 | reg = <0x42400 0x200>; | ||
38 | interrupts = < | ||
39 | 0xb4 2 0 0 | ||
40 | 0xb5 2 0 0 | ||
41 | 0xb6 2 0 0 | ||
42 | 0xb7 2 0 0>; | ||
43 | }; | ||
diff --git a/arch/powerpc/boot/dts/fsl/pq3-mpic.dtsi b/arch/powerpc/boot/dts/fsl/pq3-mpic.dtsi index fdedf7b1fe0f..71c30eb10056 100644 --- a/arch/powerpc/boot/dts/fsl/pq3-mpic.dtsi +++ b/arch/powerpc/boot/dts/fsl/pq3-mpic.dtsi | |||
@@ -53,6 +53,16 @@ timer@41100 { | |||
53 | 3 0 3 0>; | 53 | 3 0 3 0>; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | message@41400 { | ||
57 | compatible = "fsl,mpic-v3.1-msgr"; | ||
58 | reg = <0x41400 0x200>; | ||
59 | interrupts = < | ||
60 | 0xb0 2 0 0 | ||
61 | 0xb1 2 0 0 | ||
62 | 0xb2 2 0 0 | ||
63 | 0xb3 2 0 0>; | ||
64 | }; | ||
65 | |||
56 | msi@41600 { | 66 | msi@41600 { |
57 | compatible = "fsl,mpic-msi"; | 67 | compatible = "fsl,mpic-msi"; |
58 | reg = <0x41600 0x80>; | 68 | reg = <0x41600 0x80>; |
diff --git a/arch/powerpc/include/asm/irq.h b/arch/powerpc/include/asm/irq.h index e648af92ced1..0e40843a1c6e 100644 --- a/arch/powerpc/include/asm/irq.h +++ b/arch/powerpc/include/asm/irq.h | |||
@@ -18,10 +18,6 @@ | |||
18 | #include <linux/atomic.h> | 18 | #include <linux/atomic.h> |
19 | 19 | ||
20 | 20 | ||
21 | /* Define a way to iterate across irqs. */ | ||
22 | #define for_each_irq(i) \ | ||
23 | for ((i) = 0; (i) < NR_IRQS; ++(i)) | ||
24 | |||
25 | extern atomic_t ppc_n_lost_interrupts; | 21 | extern atomic_t ppc_n_lost_interrupts; |
26 | 22 | ||
27 | /* This number is used when no interrupt has been assigned */ | 23 | /* This number is used when no interrupt has been assigned */ |
diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h index c65b9294376e..c9f698a994be 100644 --- a/arch/powerpc/include/asm/mpic.h +++ b/arch/powerpc/include/asm/mpic.h | |||
@@ -275,9 +275,6 @@ struct mpic | |||
275 | unsigned int isu_mask; | 275 | unsigned int isu_mask; |
276 | /* Number of sources */ | 276 | /* Number of sources */ |
277 | unsigned int num_sources; | 277 | unsigned int num_sources; |
278 | /* default senses array */ | ||
279 | unsigned char *senses; | ||
280 | unsigned int senses_count; | ||
281 | 278 | ||
282 | /* vector numbers used for internal sources (ipi/timers) */ | 279 | /* vector numbers used for internal sources (ipi/timers) */ |
283 | unsigned int ipi_vecs[4]; | 280 | unsigned int ipi_vecs[4]; |
@@ -415,21 +412,6 @@ extern struct mpic *mpic_alloc(struct device_node *node, | |||
415 | extern void mpic_assign_isu(struct mpic *mpic, unsigned int isu_num, | 412 | extern void mpic_assign_isu(struct mpic *mpic, unsigned int isu_num, |
416 | phys_addr_t phys_addr); | 413 | phys_addr_t phys_addr); |
417 | 414 | ||
418 | /* Set default sense codes | ||
419 | * | ||
420 | * @mpic: controller | ||
421 | * @senses: array of sense codes | ||
422 | * @count: size of above array | ||
423 | * | ||
424 | * Optionally provide an array (indexed on hardware interrupt numbers | ||
425 | * for this MPIC) of default sense codes for the chip. Those are linux | ||
426 | * sense codes IRQ_TYPE_* | ||
427 | * | ||
428 | * The driver gets ownership of the pointer, don't dispose of it or | ||
429 | * anything like that. __init only. | ||
430 | */ | ||
431 | extern void mpic_set_default_senses(struct mpic *mpic, u8 *senses, int count); | ||
432 | |||
433 | 415 | ||
434 | /* Initialize the controller. After this has been called, none of the above | 416 | /* Initialize the controller. After this has been called, none of the above |
435 | * should be called again for this mpic | 417 | * should be called again for this mpic |
diff --git a/arch/powerpc/include/asm/mpic_msgr.h b/arch/powerpc/include/asm/mpic_msgr.h index 3ec37dc9003e..326d33ca55cd 100644 --- a/arch/powerpc/include/asm/mpic_msgr.h +++ b/arch/powerpc/include/asm/mpic_msgr.h | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
15 | #include <linux/spinlock.h> | 15 | #include <linux/spinlock.h> |
16 | #include <asm/smp.h> | ||
16 | 17 | ||
17 | struct mpic_msgr { | 18 | struct mpic_msgr { |
18 | u32 __iomem *base; | 19 | u32 __iomem *base; |
diff --git a/arch/powerpc/include/asm/reg_booke.h b/arch/powerpc/include/asm/reg_booke.h index b86faa9107da..8a97aa7289d3 100644 --- a/arch/powerpc/include/asm/reg_booke.h +++ b/arch/powerpc/include/asm/reg_booke.h | |||
@@ -15,11 +15,6 @@ | |||
15 | #ifndef __ASM_POWERPC_REG_BOOKE_H__ | 15 | #ifndef __ASM_POWERPC_REG_BOOKE_H__ |
16 | #define __ASM_POWERPC_REG_BOOKE_H__ | 16 | #define __ASM_POWERPC_REG_BOOKE_H__ |
17 | 17 | ||
18 | #ifdef CONFIG_BOOKE_WDT | ||
19 | extern u32 booke_wdt_enabled; | ||
20 | extern u32 booke_wdt_period; | ||
21 | #endif /* CONFIG_BOOKE_WDT */ | ||
22 | |||
23 | /* Machine State Register (MSR) Fields */ | 18 | /* Machine State Register (MSR) Fields */ |
24 | #define MSR_GS (1<<28) /* Guest state */ | 19 | #define MSR_GS (1<<28) /* Guest state */ |
25 | #define MSR_UCLE (1<<26) /* User-mode cache lock enable */ | 20 | #define MSR_UCLE (1<<26) /* User-mode cache lock enable */ |
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c index 5ec1b2354ca6..43eb74fcedde 100644 --- a/arch/powerpc/kernel/irq.c +++ b/arch/powerpc/kernel/irq.c | |||
@@ -330,14 +330,10 @@ void migrate_irqs(void) | |||
330 | 330 | ||
331 | alloc_cpumask_var(&mask, GFP_KERNEL); | 331 | alloc_cpumask_var(&mask, GFP_KERNEL); |
332 | 332 | ||
333 | for_each_irq(irq) { | 333 | for_each_irq_desc(irq, desc) { |
334 | struct irq_data *data; | 334 | struct irq_data *data; |
335 | struct irq_chip *chip; | 335 | struct irq_chip *chip; |
336 | 336 | ||
337 | desc = irq_to_desc(irq); | ||
338 | if (!desc) | ||
339 | continue; | ||
340 | |||
341 | data = irq_desc_get_irq_data(desc); | 337 | data = irq_desc_get_irq_data(desc); |
342 | if (irqd_is_per_cpu(data)) | 338 | if (irqd_is_per_cpu(data)) |
343 | continue; | 339 | continue; |
diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c index c957b1202bdc..5df777794403 100644 --- a/arch/powerpc/kernel/machine_kexec.c +++ b/arch/powerpc/kernel/machine_kexec.c | |||
@@ -23,14 +23,11 @@ | |||
23 | 23 | ||
24 | void machine_kexec_mask_interrupts(void) { | 24 | void machine_kexec_mask_interrupts(void) { |
25 | unsigned int i; | 25 | unsigned int i; |
26 | struct irq_desc *desc; | ||
26 | 27 | ||
27 | for_each_irq(i) { | 28 | for_each_irq_desc(i, desc) { |
28 | struct irq_desc *desc = irq_to_desc(i); | ||
29 | struct irq_chip *chip; | 29 | struct irq_chip *chip; |
30 | 30 | ||
31 | if (!desc) | ||
32 | continue; | ||
33 | |||
34 | chip = irq_desc_get_chip(desc); | 31 | chip = irq_desc_get_chip(desc); |
35 | if (!chip) | 32 | if (!chip) |
36 | continue; | 33 | continue; |
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index 9825f29d1faf..ec8a53fa9e8f 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c | |||
@@ -150,6 +150,9 @@ notrace void __init machine_init(u64 dt_ptr) | |||
150 | } | 150 | } |
151 | 151 | ||
152 | #ifdef CONFIG_BOOKE_WDT | 152 | #ifdef CONFIG_BOOKE_WDT |
153 | extern u32 booke_wdt_enabled; | ||
154 | extern u32 booke_wdt_period; | ||
155 | |||
153 | /* Checks wdt=x and wdt_period=xx command-line option */ | 156 | /* Checks wdt=x and wdt_period=xx command-line option */ |
154 | notrace int __init early_parse_wdt(char *p) | 157 | notrace int __init early_parse_wdt(char *p) |
155 | { | 158 | { |
diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h index af1ab5e9a691..5c3cf2d04e41 100644 --- a/arch/powerpc/net/bpf_jit.h +++ b/arch/powerpc/net/bpf_jit.h | |||
@@ -48,7 +48,13 @@ | |||
48 | /* | 48 | /* |
49 | * Assembly helpers from arch/powerpc/net/bpf_jit.S: | 49 | * Assembly helpers from arch/powerpc/net/bpf_jit.S: |
50 | */ | 50 | */ |
51 | extern u8 sk_load_word[], sk_load_half[], sk_load_byte[], sk_load_byte_msh[]; | 51 | #define DECLARE_LOAD_FUNC(func) \ |
52 | extern u8 func[], func##_negative_offset[], func##_positive_offset[] | ||
53 | |||
54 | DECLARE_LOAD_FUNC(sk_load_word); | ||
55 | DECLARE_LOAD_FUNC(sk_load_half); | ||
56 | DECLARE_LOAD_FUNC(sk_load_byte); | ||
57 | DECLARE_LOAD_FUNC(sk_load_byte_msh); | ||
52 | 58 | ||
53 | #define FUNCTION_DESCR_SIZE 24 | 59 | #define FUNCTION_DESCR_SIZE 24 |
54 | 60 | ||
diff --git a/arch/powerpc/net/bpf_jit_64.S b/arch/powerpc/net/bpf_jit_64.S index ff4506e85cce..55ba3855a97f 100644 --- a/arch/powerpc/net/bpf_jit_64.S +++ b/arch/powerpc/net/bpf_jit_64.S | |||
@@ -31,14 +31,13 @@ | |||
31 | * then branch directly to slow_path_XXX if required. (In fact, could | 31 | * then branch directly to slow_path_XXX if required. (In fact, could |
32 | * load a spare GPR with the address of slow_path_generic and pass size | 32 | * load a spare GPR with the address of slow_path_generic and pass size |
33 | * as an argument, making the call site a mtlr, li and bllr.) | 33 | * as an argument, making the call site a mtlr, li and bllr.) |
34 | * | ||
35 | * Technically, the "is addr < 0" check is unnecessary & slowing down | ||
36 | * the ABS path, as it's statically checked on generation. | ||
37 | */ | 34 | */ |
38 | .globl sk_load_word | 35 | .globl sk_load_word |
39 | sk_load_word: | 36 | sk_load_word: |
40 | cmpdi r_addr, 0 | 37 | cmpdi r_addr, 0 |
41 | blt bpf_error | 38 | blt bpf_slow_path_word_neg |
39 | .globl sk_load_word_positive_offset | ||
40 | sk_load_word_positive_offset: | ||
42 | /* Are we accessing past headlen? */ | 41 | /* Are we accessing past headlen? */ |
43 | subi r_scratch1, r_HL, 4 | 42 | subi r_scratch1, r_HL, 4 |
44 | cmpd r_scratch1, r_addr | 43 | cmpd r_scratch1, r_addr |
@@ -51,7 +50,9 @@ sk_load_word: | |||
51 | .globl sk_load_half | 50 | .globl sk_load_half |
52 | sk_load_half: | 51 | sk_load_half: |
53 | cmpdi r_addr, 0 | 52 | cmpdi r_addr, 0 |
54 | blt bpf_error | 53 | blt bpf_slow_path_half_neg |
54 | .globl sk_load_half_positive_offset | ||
55 | sk_load_half_positive_offset: | ||
55 | subi r_scratch1, r_HL, 2 | 56 | subi r_scratch1, r_HL, 2 |
56 | cmpd r_scratch1, r_addr | 57 | cmpd r_scratch1, r_addr |
57 | blt bpf_slow_path_half | 58 | blt bpf_slow_path_half |
@@ -61,7 +62,9 @@ sk_load_half: | |||
61 | .globl sk_load_byte | 62 | .globl sk_load_byte |
62 | sk_load_byte: | 63 | sk_load_byte: |
63 | cmpdi r_addr, 0 | 64 | cmpdi r_addr, 0 |
64 | blt bpf_error | 65 | blt bpf_slow_path_byte_neg |
66 | .globl sk_load_byte_positive_offset | ||
67 | sk_load_byte_positive_offset: | ||
65 | cmpd r_HL, r_addr | 68 | cmpd r_HL, r_addr |
66 | ble bpf_slow_path_byte | 69 | ble bpf_slow_path_byte |
67 | lbzx r_A, r_D, r_addr | 70 | lbzx r_A, r_D, r_addr |
@@ -69,22 +72,20 @@ sk_load_byte: | |||
69 | 72 | ||
70 | /* | 73 | /* |
71 | * BPF_S_LDX_B_MSH: ldxb 4*([offset]&0xf) | 74 | * BPF_S_LDX_B_MSH: ldxb 4*([offset]&0xf) |
72 | * r_addr is the offset value, already known positive | 75 | * r_addr is the offset value |
73 | */ | 76 | */ |
74 | .globl sk_load_byte_msh | 77 | .globl sk_load_byte_msh |
75 | sk_load_byte_msh: | 78 | sk_load_byte_msh: |
79 | cmpdi r_addr, 0 | ||
80 | blt bpf_slow_path_byte_msh_neg | ||
81 | .globl sk_load_byte_msh_positive_offset | ||
82 | sk_load_byte_msh_positive_offset: | ||
76 | cmpd r_HL, r_addr | 83 | cmpd r_HL, r_addr |
77 | ble bpf_slow_path_byte_msh | 84 | ble bpf_slow_path_byte_msh |
78 | lbzx r_X, r_D, r_addr | 85 | lbzx r_X, r_D, r_addr |
79 | rlwinm r_X, r_X, 2, 32-4-2, 31-2 | 86 | rlwinm r_X, r_X, 2, 32-4-2, 31-2 |
80 | blr | 87 | blr |
81 | 88 | ||
82 | bpf_error: | ||
83 | /* Entered with cr0 = lt */ | ||
84 | li r3, 0 | ||
85 | /* Generated code will 'blt epilogue', returning 0. */ | ||
86 | blr | ||
87 | |||
88 | /* Call out to skb_copy_bits: | 89 | /* Call out to skb_copy_bits: |
89 | * We'll need to back up our volatile regs first; we have | 90 | * We'll need to back up our volatile regs first; we have |
90 | * local variable space at r1+(BPF_PPC_STACK_BASIC). | 91 | * local variable space at r1+(BPF_PPC_STACK_BASIC). |
@@ -136,3 +137,84 @@ bpf_slow_path_byte_msh: | |||
136 | lbz r_X, BPF_PPC_STACK_BASIC+(2*8)(r1) | 137 | lbz r_X, BPF_PPC_STACK_BASIC+(2*8)(r1) |
137 | rlwinm r_X, r_X, 2, 32-4-2, 31-2 | 138 | rlwinm r_X, r_X, 2, 32-4-2, 31-2 |
138 | blr | 139 | blr |
140 | |||
141 | /* Call out to bpf_internal_load_pointer_neg_helper: | ||
142 | * We'll need to back up our volatile regs first; we have | ||
143 | * local variable space at r1+(BPF_PPC_STACK_BASIC). | ||
144 | * Allocate a new stack frame here to remain ABI-compliant in | ||
145 | * stashing LR. | ||
146 | */ | ||
147 | #define sk_negative_common(SIZE) \ | ||
148 | mflr r0; \ | ||
149 | std r0, 16(r1); \ | ||
150 | /* R3 goes in parameter space of caller's frame */ \ | ||
151 | std r_skb, (BPF_PPC_STACKFRAME+48)(r1); \ | ||
152 | std r_A, (BPF_PPC_STACK_BASIC+(0*8))(r1); \ | ||
153 | std r_X, (BPF_PPC_STACK_BASIC+(1*8))(r1); \ | ||
154 | stdu r1, -BPF_PPC_SLOWPATH_FRAME(r1); \ | ||
155 | /* R3 = r_skb, as passed */ \ | ||
156 | mr r4, r_addr; \ | ||
157 | li r5, SIZE; \ | ||
158 | bl bpf_internal_load_pointer_neg_helper; \ | ||
159 | /* R3 != 0 on success */ \ | ||
160 | addi r1, r1, BPF_PPC_SLOWPATH_FRAME; \ | ||
161 | ld r0, 16(r1); \ | ||
162 | ld r_A, (BPF_PPC_STACK_BASIC+(0*8))(r1); \ | ||
163 | ld r_X, (BPF_PPC_STACK_BASIC+(1*8))(r1); \ | ||
164 | mtlr r0; \ | ||
165 | cmpldi r3, 0; \ | ||
166 | beq bpf_error_slow; /* cr0 = EQ */ \ | ||
167 | mr r_addr, r3; \ | ||
168 | ld r_skb, (BPF_PPC_STACKFRAME+48)(r1); \ | ||
169 | /* Great success! */ | ||
170 | |||
171 | bpf_slow_path_word_neg: | ||
172 | lis r_scratch1,-32 /* SKF_LL_OFF */ | ||
173 | cmpd r_addr, r_scratch1 /* addr < SKF_* */ | ||
174 | blt bpf_error /* cr0 = LT */ | ||
175 | .globl sk_load_word_negative_offset | ||
176 | sk_load_word_negative_offset: | ||
177 | sk_negative_common(4) | ||
178 | lwz r_A, 0(r_addr) | ||
179 | blr | ||
180 | |||
181 | bpf_slow_path_half_neg: | ||
182 | lis r_scratch1,-32 /* SKF_LL_OFF */ | ||
183 | cmpd r_addr, r_scratch1 /* addr < SKF_* */ | ||
184 | blt bpf_error /* cr0 = LT */ | ||
185 | .globl sk_load_half_negative_offset | ||
186 | sk_load_half_negative_offset: | ||
187 | sk_negative_common(2) | ||
188 | lhz r_A, 0(r_addr) | ||
189 | blr | ||
190 | |||
191 | bpf_slow_path_byte_neg: | ||
192 | lis r_scratch1,-32 /* SKF_LL_OFF */ | ||
193 | cmpd r_addr, r_scratch1 /* addr < SKF_* */ | ||
194 | blt bpf_error /* cr0 = LT */ | ||
195 | .globl sk_load_byte_negative_offset | ||
196 | sk_load_byte_negative_offset: | ||
197 | sk_negative_common(1) | ||
198 | lbz r_A, 0(r_addr) | ||
199 | blr | ||
200 | |||
201 | bpf_slow_path_byte_msh_neg: | ||
202 | lis r_scratch1,-32 /* SKF_LL_OFF */ | ||
203 | cmpd r_addr, r_scratch1 /* addr < SKF_* */ | ||
204 | blt bpf_error /* cr0 = LT */ | ||
205 | .globl sk_load_byte_msh_negative_offset | ||
206 | sk_load_byte_msh_negative_offset: | ||
207 | sk_negative_common(1) | ||
208 | lbz r_X, 0(r_addr) | ||
209 | rlwinm r_X, r_X, 2, 32-4-2, 31-2 | ||
210 | blr | ||
211 | |||
212 | bpf_error_slow: | ||
213 | /* fabricate a cr0 = lt */ | ||
214 | li r_scratch1, -1 | ||
215 | cmpdi r_scratch1, 0 | ||
216 | bpf_error: | ||
217 | /* Entered with cr0 = lt */ | ||
218 | li r3, 0 | ||
219 | /* Generated code will 'blt epilogue', returning 0. */ | ||
220 | blr | ||
diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c index 73619d3aeb6c..2dc8b1484845 100644 --- a/arch/powerpc/net/bpf_jit_comp.c +++ b/arch/powerpc/net/bpf_jit_comp.c | |||
@@ -127,6 +127,9 @@ static void bpf_jit_build_epilogue(u32 *image, struct codegen_context *ctx) | |||
127 | PPC_BLR(); | 127 | PPC_BLR(); |
128 | } | 128 | } |
129 | 129 | ||
130 | #define CHOOSE_LOAD_FUNC(K, func) \ | ||
131 | ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset) | ||
132 | |||
130 | /* Assemble the body code between the prologue & epilogue. */ | 133 | /* Assemble the body code between the prologue & epilogue. */ |
131 | static int bpf_jit_build_body(struct sk_filter *fp, u32 *image, | 134 | static int bpf_jit_build_body(struct sk_filter *fp, u32 *image, |
132 | struct codegen_context *ctx, | 135 | struct codegen_context *ctx, |
@@ -391,21 +394,16 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image, | |||
391 | 394 | ||
392 | /*** Absolute loads from packet header/data ***/ | 395 | /*** Absolute loads from packet header/data ***/ |
393 | case BPF_S_LD_W_ABS: | 396 | case BPF_S_LD_W_ABS: |
394 | func = sk_load_word; | 397 | func = CHOOSE_LOAD_FUNC(K, sk_load_word); |
395 | goto common_load; | 398 | goto common_load; |
396 | case BPF_S_LD_H_ABS: | 399 | case BPF_S_LD_H_ABS: |
397 | func = sk_load_half; | 400 | func = CHOOSE_LOAD_FUNC(K, sk_load_half); |
398 | goto common_load; | 401 | goto common_load; |
399 | case BPF_S_LD_B_ABS: | 402 | case BPF_S_LD_B_ABS: |
400 | func = sk_load_byte; | 403 | func = CHOOSE_LOAD_FUNC(K, sk_load_byte); |
401 | common_load: | 404 | common_load: |
402 | /* | 405 | /* Load from [K]. */ |
403 | * Load from [K]. Reference with the (negative) | ||
404 | * SKF_NET_OFF/SKF_LL_OFF offsets is unsupported. | ||
405 | */ | ||
406 | ctx->seen |= SEEN_DATAREF; | 406 | ctx->seen |= SEEN_DATAREF; |
407 | if ((int)K < 0) | ||
408 | return -ENOTSUPP; | ||
409 | PPC_LI64(r_scratch1, func); | 407 | PPC_LI64(r_scratch1, func); |
410 | PPC_MTLR(r_scratch1); | 408 | PPC_MTLR(r_scratch1); |
411 | PPC_LI32(r_addr, K); | 409 | PPC_LI32(r_addr, K); |
@@ -429,7 +427,7 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image, | |||
429 | common_load_ind: | 427 | common_load_ind: |
430 | /* | 428 | /* |
431 | * Load from [X + K]. Negative offsets are tested for | 429 | * Load from [X + K]. Negative offsets are tested for |
432 | * in the helper functions, and result in a 'ret 0'. | 430 | * in the helper functions. |
433 | */ | 431 | */ |
434 | ctx->seen |= SEEN_DATAREF | SEEN_XREG; | 432 | ctx->seen |= SEEN_DATAREF | SEEN_XREG; |
435 | PPC_LI64(r_scratch1, func); | 433 | PPC_LI64(r_scratch1, func); |
@@ -443,13 +441,7 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image, | |||
443 | break; | 441 | break; |
444 | 442 | ||
445 | case BPF_S_LDX_B_MSH: | 443 | case BPF_S_LDX_B_MSH: |
446 | /* | 444 | func = CHOOSE_LOAD_FUNC(K, sk_load_byte_msh); |
447 | * x86 version drops packet (RET 0) when K<0, whereas | ||
448 | * interpreter does allow K<0 (__load_pointer, special | ||
449 | * ancillary data). common_load returns ENOTSUPP if K<0, | ||
450 | * so we fall back to interpreter & filter works. | ||
451 | */ | ||
452 | func = sk_load_byte_msh; | ||
453 | goto common_load; | 445 | goto common_load; |
454 | break; | 446 | break; |
455 | 447 | ||
diff --git a/arch/powerpc/platforms/85xx/common.c b/arch/powerpc/platforms/85xx/common.c index 9fef5302adc1..67dac22b4363 100644 --- a/arch/powerpc/platforms/85xx/common.c +++ b/arch/powerpc/platforms/85xx/common.c | |||
@@ -21,6 +21,12 @@ static struct of_device_id __initdata mpc85xx_common_ids[] = { | |||
21 | { .compatible = "fsl,qe", }, | 21 | { .compatible = "fsl,qe", }, |
22 | { .compatible = "fsl,cpm2", }, | 22 | { .compatible = "fsl,cpm2", }, |
23 | { .compatible = "fsl,srio", }, | 23 | { .compatible = "fsl,srio", }, |
24 | /* So that the DMA channel nodes can be probed individually: */ | ||
25 | { .compatible = "fsl,eloplus-dma", }, | ||
26 | /* For the PMC driver */ | ||
27 | { .compatible = "fsl,mpc8548-guts", }, | ||
28 | /* Probably unnecessary? */ | ||
29 | { .compatible = "gpio-leds", }, | ||
24 | {}, | 30 | {}, |
25 | }; | 31 | }; |
26 | 32 | ||
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c index 9a6f04406e0d..d208ebccb91c 100644 --- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c +++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c | |||
@@ -399,12 +399,6 @@ static int __init board_fixups(void) | |||
399 | machine_arch_initcall(mpc8568_mds, board_fixups); | 399 | machine_arch_initcall(mpc8568_mds, board_fixups); |
400 | machine_arch_initcall(mpc8569_mds, board_fixups); | 400 | machine_arch_initcall(mpc8569_mds, board_fixups); |
401 | 401 | ||
402 | static struct of_device_id mpc85xx_ids[] = { | ||
403 | { .compatible = "fsl,mpc8548-guts", }, | ||
404 | { .compatible = "gpio-leds", }, | ||
405 | {}, | ||
406 | }; | ||
407 | |||
408 | static int __init mpc85xx_publish_devices(void) | 402 | static int __init mpc85xx_publish_devices(void) |
409 | { | 403 | { |
410 | if (machine_is(mpc8568_mds)) | 404 | if (machine_is(mpc8568_mds)) |
@@ -412,10 +406,7 @@ static int __init mpc85xx_publish_devices(void) | |||
412 | if (machine_is(mpc8569_mds)) | 406 | if (machine_is(mpc8569_mds)) |
413 | simple_gpiochip_init("fsl,mpc8569mds-bcsr-gpio"); | 407 | simple_gpiochip_init("fsl,mpc8569mds-bcsr-gpio"); |
414 | 408 | ||
415 | mpc85xx_common_publish_devices(); | 409 | return mpc85xx_common_publish_devices(); |
416 | of_platform_bus_probe(NULL, mpc85xx_ids, NULL); | ||
417 | |||
418 | return 0; | ||
419 | } | 410 | } |
420 | 411 | ||
421 | machine_device_initcall(mpc8568_mds, mpc85xx_publish_devices); | 412 | machine_device_initcall(mpc8568_mds, mpc85xx_publish_devices); |
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c index e74b7cde9aee..f700c81a1321 100644 --- a/arch/powerpc/platforms/85xx/p1022_ds.c +++ b/arch/powerpc/platforms/85xx/p1022_ds.c | |||
@@ -460,18 +460,7 @@ static void __init p1022_ds_setup_arch(void) | |||
460 | pr_info("Freescale P1022 DS reference board\n"); | 460 | pr_info("Freescale P1022 DS reference board\n"); |
461 | } | 461 | } |
462 | 462 | ||
463 | static struct of_device_id __initdata p1022_ds_ids[] = { | 463 | machine_device_initcall(p1022_ds, mpc85xx_common_publish_devices); |
464 | /* So that the DMA channel nodes can be probed individually: */ | ||
465 | { .compatible = "fsl,eloplus-dma", }, | ||
466 | {}, | ||
467 | }; | ||
468 | |||
469 | static int __init p1022_ds_publish_devices(void) | ||
470 | { | ||
471 | mpc85xx_common_publish_devices(); | ||
472 | return of_platform_bus_probe(NULL, p1022_ds_ids, NULL); | ||
473 | } | ||
474 | machine_device_initcall(p1022_ds, p1022_ds_publish_devices); | ||
475 | 464 | ||
476 | machine_arch_initcall(p1022_ds, swiotlb_setup_bus_notifier); | 465 | machine_arch_initcall(p1022_ds, swiotlb_setup_bus_notifier); |
477 | 466 | ||
diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c index d09f3e8e6867..85825b5401e5 100644 --- a/arch/powerpc/platforms/cell/axon_msi.c +++ b/arch/powerpc/platforms/cell/axon_msi.c | |||
@@ -114,7 +114,7 @@ static void axon_msi_cascade(unsigned int irq, struct irq_desc *desc) | |||
114 | pr_devel("axon_msi: woff %x roff %x msi %x\n", | 114 | pr_devel("axon_msi: woff %x roff %x msi %x\n", |
115 | write_offset, msic->read_offset, msi); | 115 | write_offset, msic->read_offset, msi); |
116 | 116 | ||
117 | if (msi < NR_IRQS && irq_get_chip_data(msi) == msic) { | 117 | if (msi < nr_irqs && irq_get_chip_data(msi) == msic) { |
118 | generic_handle_irq(msi); | 118 | generic_handle_irq(msi); |
119 | msic->fifo_virt[idx] = cpu_to_le32(0xffffffff); | 119 | msic->fifo_virt[idx] = cpu_to_le32(0xffffffff); |
120 | } else { | 120 | } else { |
@@ -276,9 +276,6 @@ static int axon_msi_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) | |||
276 | if (rc) | 276 | if (rc) |
277 | return rc; | 277 | return rc; |
278 | 278 | ||
279 | /* We rely on being able to stash a virq in a u16 */ | ||
280 | BUILD_BUG_ON(NR_IRQS > 65536); | ||
281 | |||
282 | list_for_each_entry(entry, &dev->msi_list, list) { | 279 | list_for_each_entry(entry, &dev->msi_list, list) { |
283 | virq = irq_create_direct_mapping(msic->irq_domain); | 280 | virq = irq_create_direct_mapping(msic->irq_domain); |
284 | if (virq == NO_IRQ) { | 281 | if (virq == NO_IRQ) { |
@@ -392,7 +389,8 @@ static int axon_msi_probe(struct platform_device *device) | |||
392 | } | 389 | } |
393 | memset(msic->fifo_virt, 0xff, MSIC_FIFO_SIZE_BYTES); | 390 | memset(msic->fifo_virt, 0xff, MSIC_FIFO_SIZE_BYTES); |
394 | 391 | ||
395 | msic->irq_domain = irq_domain_add_nomap(dn, 0, &msic_host_ops, msic); | 392 | /* We rely on being able to stash a virq in a u16, so limit irqs to < 65536 */ |
393 | msic->irq_domain = irq_domain_add_nomap(dn, 65536, &msic_host_ops, msic); | ||
396 | if (!msic->irq_domain) { | 394 | if (!msic->irq_domain) { |
397 | printk(KERN_ERR "axon_msi: couldn't allocate irq_domain for %s\n", | 395 | printk(KERN_ERR "axon_msi: couldn't allocate irq_domain for %s\n", |
398 | dn->full_name); | 396 | dn->full_name); |
diff --git a/arch/powerpc/platforms/cell/beat_interrupt.c b/arch/powerpc/platforms/cell/beat_interrupt.c index f9a48af335cb..8c6dc42ecf65 100644 --- a/arch/powerpc/platforms/cell/beat_interrupt.c +++ b/arch/powerpc/platforms/cell/beat_interrupt.c | |||
@@ -248,6 +248,6 @@ void beatic_deinit_IRQ(void) | |||
248 | { | 248 | { |
249 | int i; | 249 | int i; |
250 | 250 | ||
251 | for (i = 1; i < NR_IRQS; i++) | 251 | for (i = 1; i < nr_irqs; i++) |
252 | beat_destruct_irq_plug(i); | 252 | beat_destruct_irq_plug(i); |
253 | } | 253 | } |
diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c index 996c5ff7824b..03685a329d7d 100644 --- a/arch/powerpc/platforms/powermac/low_i2c.c +++ b/arch/powerpc/platforms/powermac/low_i2c.c | |||
@@ -366,11 +366,20 @@ static void kw_i2c_timeout(unsigned long data) | |||
366 | unsigned long flags; | 366 | unsigned long flags; |
367 | 367 | ||
368 | spin_lock_irqsave(&host->lock, flags); | 368 | spin_lock_irqsave(&host->lock, flags); |
369 | |||
370 | /* | ||
371 | * If the timer is pending, that means we raced with the | ||
372 | * irq, in which case we just return | ||
373 | */ | ||
374 | if (timer_pending(&host->timeout_timer)) | ||
375 | goto skip; | ||
376 | |||
369 | kw_i2c_handle_interrupt(host, kw_read_reg(reg_isr)); | 377 | kw_i2c_handle_interrupt(host, kw_read_reg(reg_isr)); |
370 | if (host->state != state_idle) { | 378 | if (host->state != state_idle) { |
371 | host->timeout_timer.expires = jiffies + KW_POLL_TIMEOUT; | 379 | host->timeout_timer.expires = jiffies + KW_POLL_TIMEOUT; |
372 | add_timer(&host->timeout_timer); | 380 | add_timer(&host->timeout_timer); |
373 | } | 381 | } |
382 | skip: | ||
374 | spin_unlock_irqrestore(&host->lock, flags); | 383 | spin_unlock_irqrestore(&host->lock, flags); |
375 | } | 384 | } |
376 | 385 | ||
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c index 66ad93de1d55..c4e630576ff2 100644 --- a/arch/powerpc/platforms/powermac/pic.c +++ b/arch/powerpc/platforms/powermac/pic.c | |||
@@ -57,9 +57,9 @@ static int max_real_irqs; | |||
57 | 57 | ||
58 | static DEFINE_RAW_SPINLOCK(pmac_pic_lock); | 58 | static DEFINE_RAW_SPINLOCK(pmac_pic_lock); |
59 | 59 | ||
60 | #define NR_MASK_WORDS ((NR_IRQS + 31) / 32) | 60 | /* The max irq number this driver deals with is 128; see max_irqs */ |
61 | static unsigned long ppc_lost_interrupts[NR_MASK_WORDS]; | 61 | static DECLARE_BITMAP(ppc_lost_interrupts, 128); |
62 | static unsigned long ppc_cached_irq_mask[NR_MASK_WORDS]; | 62 | static DECLARE_BITMAP(ppc_cached_irq_mask, 128); |
63 | static int pmac_irq_cascade = -1; | 63 | static int pmac_irq_cascade = -1; |
64 | static struct irq_domain *pmac_pic_host; | 64 | static struct irq_domain *pmac_pic_host; |
65 | 65 | ||
diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig index aadbe4f6d537..178a5f300bc9 100644 --- a/arch/powerpc/platforms/pseries/Kconfig +++ b/arch/powerpc/platforms/pseries/Kconfig | |||
@@ -30,9 +30,9 @@ config PPC_SPLPAR | |||
30 | two or more partitions. | 30 | two or more partitions. |
31 | 31 | ||
32 | config EEH | 32 | config EEH |
33 | bool "PCI Extended Error Handling (EEH)" if EXPERT | 33 | bool |
34 | depends on PPC_PSERIES && PCI | 34 | depends on PPC_PSERIES && PCI |
35 | default y if !EXPERT | 35 | default y |
36 | 36 | ||
37 | config PSERIES_MSI | 37 | config PSERIES_MSI |
38 | bool | 38 | bool |
diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c index 309d38ef7322..a75e37dc41aa 100644 --- a/arch/powerpc/platforms/pseries/eeh.c +++ b/arch/powerpc/platforms/pseries/eeh.c | |||
@@ -1076,7 +1076,7 @@ static void eeh_add_device_late(struct pci_dev *dev) | |||
1076 | pr_debug("EEH: Adding device %s\n", pci_name(dev)); | 1076 | pr_debug("EEH: Adding device %s\n", pci_name(dev)); |
1077 | 1077 | ||
1078 | dn = pci_device_to_OF_node(dev); | 1078 | dn = pci_device_to_OF_node(dev); |
1079 | edev = pci_dev_to_eeh_dev(dev); | 1079 | edev = of_node_to_eeh_dev(dn); |
1080 | if (edev->pdev == dev) { | 1080 | if (edev->pdev == dev) { |
1081 | pr_debug("EEH: Already referenced !\n"); | 1081 | pr_debug("EEH: Already referenced !\n"); |
1082 | return; | 1082 | return; |
diff --git a/arch/powerpc/sysdev/cpm2_pic.c b/arch/powerpc/sysdev/cpm2_pic.c index d3be961e2ae7..10386b676d87 100644 --- a/arch/powerpc/sysdev/cpm2_pic.c +++ b/arch/powerpc/sysdev/cpm2_pic.c | |||
@@ -51,8 +51,7 @@ | |||
51 | static intctl_cpm2_t __iomem *cpm2_intctl; | 51 | static intctl_cpm2_t __iomem *cpm2_intctl; |
52 | 52 | ||
53 | static struct irq_domain *cpm2_pic_host; | 53 | static struct irq_domain *cpm2_pic_host; |
54 | #define NR_MASK_WORDS ((NR_IRQS + 31) / 32) | 54 | static unsigned long ppc_cached_irq_mask[2]; /* 2 32-bit registers */ |
55 | static unsigned long ppc_cached_irq_mask[NR_MASK_WORDS]; | ||
56 | 55 | ||
57 | static const u_char irq_to_siureg[] = { | 56 | static const u_char irq_to_siureg[] = { |
58 | 1, 1, 1, 1, 1, 1, 1, 1, | 57 | 1, 1, 1, 1, 1, 1, 1, 1, |
diff --git a/arch/powerpc/sysdev/mpc8xx_pic.c b/arch/powerpc/sysdev/mpc8xx_pic.c index d5f5416be310..b724622c3a0b 100644 --- a/arch/powerpc/sysdev/mpc8xx_pic.c +++ b/arch/powerpc/sysdev/mpc8xx_pic.c | |||
@@ -18,69 +18,45 @@ | |||
18 | extern int cpm_get_irq(struct pt_regs *regs); | 18 | extern int cpm_get_irq(struct pt_regs *regs); |
19 | 19 | ||
20 | static struct irq_domain *mpc8xx_pic_host; | 20 | static struct irq_domain *mpc8xx_pic_host; |
21 | #define NR_MASK_WORDS ((NR_IRQS + 31) / 32) | 21 | static unsigned long mpc8xx_cached_irq_mask; |
22 | static unsigned long ppc_cached_irq_mask[NR_MASK_WORDS]; | ||
23 | static sysconf8xx_t __iomem *siu_reg; | 22 | static sysconf8xx_t __iomem *siu_reg; |
24 | 23 | ||
25 | int cpm_get_irq(struct pt_regs *regs); | 24 | static inline unsigned long mpc8xx_irqd_to_bit(struct irq_data *d) |
25 | { | ||
26 | return 0x80000000 >> irqd_to_hwirq(d); | ||
27 | } | ||
26 | 28 | ||
27 | static void mpc8xx_unmask_irq(struct irq_data *d) | 29 | static void mpc8xx_unmask_irq(struct irq_data *d) |
28 | { | 30 | { |
29 | int bit, word; | 31 | mpc8xx_cached_irq_mask |= mpc8xx_irqd_to_bit(d); |
30 | unsigned int irq_nr = (unsigned int)irqd_to_hwirq(d); | 32 | out_be32(&siu_reg->sc_simask, mpc8xx_cached_irq_mask); |
31 | |||
32 | bit = irq_nr & 0x1f; | ||
33 | word = irq_nr >> 5; | ||
34 | |||
35 | ppc_cached_irq_mask[word] |= (1 << (31-bit)); | ||
36 | out_be32(&siu_reg->sc_simask, ppc_cached_irq_mask[word]); | ||
37 | } | 33 | } |
38 | 34 | ||
39 | static void mpc8xx_mask_irq(struct irq_data *d) | 35 | static void mpc8xx_mask_irq(struct irq_data *d) |
40 | { | 36 | { |
41 | int bit, word; | 37 | mpc8xx_cached_irq_mask &= ~mpc8xx_irqd_to_bit(d); |
42 | unsigned int irq_nr = (unsigned int)irqd_to_hwirq(d); | 38 | out_be32(&siu_reg->sc_simask, mpc8xx_cached_irq_mask); |
43 | |||
44 | bit = irq_nr & 0x1f; | ||
45 | word = irq_nr >> 5; | ||
46 | |||
47 | ppc_cached_irq_mask[word] &= ~(1 << (31-bit)); | ||
48 | out_be32(&siu_reg->sc_simask, ppc_cached_irq_mask[word]); | ||
49 | } | 39 | } |
50 | 40 | ||
51 | static void mpc8xx_ack(struct irq_data *d) | 41 | static void mpc8xx_ack(struct irq_data *d) |
52 | { | 42 | { |
53 | int bit; | 43 | out_be32(&siu_reg->sc_sipend, mpc8xx_irqd_to_bit(d)); |
54 | unsigned int irq_nr = (unsigned int)irqd_to_hwirq(d); | ||
55 | |||
56 | bit = irq_nr & 0x1f; | ||
57 | out_be32(&siu_reg->sc_sipend, 1 << (31-bit)); | ||
58 | } | 44 | } |
59 | 45 | ||
60 | static void mpc8xx_end_irq(struct irq_data *d) | 46 | static void mpc8xx_end_irq(struct irq_data *d) |
61 | { | 47 | { |
62 | int bit, word; | 48 | mpc8xx_cached_irq_mask |= mpc8xx_irqd_to_bit(d); |
63 | unsigned int irq_nr = (unsigned int)irqd_to_hwirq(d); | 49 | out_be32(&siu_reg->sc_simask, mpc8xx_cached_irq_mask); |
64 | |||
65 | bit = irq_nr & 0x1f; | ||
66 | word = irq_nr >> 5; | ||
67 | |||
68 | ppc_cached_irq_mask[word] |= (1 << (31-bit)); | ||
69 | out_be32(&siu_reg->sc_simask, ppc_cached_irq_mask[word]); | ||
70 | } | 50 | } |
71 | 51 | ||
72 | static int mpc8xx_set_irq_type(struct irq_data *d, unsigned int flow_type) | 52 | static int mpc8xx_set_irq_type(struct irq_data *d, unsigned int flow_type) |
73 | { | 53 | { |
74 | if (flow_type & IRQ_TYPE_EDGE_FALLING) { | 54 | /* only external IRQ senses are programmable */ |
75 | irq_hw_number_t hw = (unsigned int)irqd_to_hwirq(d); | 55 | if ((flow_type & IRQ_TYPE_EDGE_FALLING) && !(irqd_to_hwirq(d) & 1)) { |
76 | unsigned int siel = in_be32(&siu_reg->sc_siel); | 56 | unsigned int siel = in_be32(&siu_reg->sc_siel); |
77 | 57 | siel |= mpc8xx_irqd_to_bit(d); | |
78 | /* only external IRQ senses are programmable */ | 58 | out_be32(&siu_reg->sc_siel, siel); |
79 | if ((hw & 1) == 0) { | 59 | __irq_set_handler_locked(d->irq, handle_edge_irq); |
80 | siel |= (0x80000000 >> hw); | ||
81 | out_be32(&siu_reg->sc_siel, siel); | ||
82 | __irq_set_handler_locked(d->irq, handle_edge_irq); | ||
83 | } | ||
84 | } | 60 | } |
85 | return 0; | 61 | return 0; |
86 | } | 62 | } |
@@ -132,6 +108,9 @@ static int mpc8xx_pic_host_xlate(struct irq_domain *h, struct device_node *ct, | |||
132 | IRQ_TYPE_EDGE_FALLING, | 108 | IRQ_TYPE_EDGE_FALLING, |
133 | }; | 109 | }; |
134 | 110 | ||
111 | if (intspec[0] > 0x1f) | ||
112 | return 0; | ||
113 | |||
135 | *out_hwirq = intspec[0]; | 114 | *out_hwirq = intspec[0]; |
136 | if (intsize > 1 && intspec[1] < 4) | 115 | if (intsize > 1 && intspec[1] < 4) |
137 | *out_flags = map_pic_senses[intspec[1]]; | 116 | *out_flags = map_pic_senses[intspec[1]]; |
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c index 9ac71ebd2c40..395af1347749 100644 --- a/arch/powerpc/sysdev/mpic.c +++ b/arch/powerpc/sysdev/mpic.c | |||
@@ -604,18 +604,14 @@ static struct mpic *mpic_find(unsigned int irq) | |||
604 | } | 604 | } |
605 | 605 | ||
606 | /* Determine if the linux irq is an IPI */ | 606 | /* Determine if the linux irq is an IPI */ |
607 | static unsigned int mpic_is_ipi(struct mpic *mpic, unsigned int irq) | 607 | static unsigned int mpic_is_ipi(struct mpic *mpic, unsigned int src) |
608 | { | 608 | { |
609 | unsigned int src = virq_to_hw(irq); | ||
610 | |||
611 | return (src >= mpic->ipi_vecs[0] && src <= mpic->ipi_vecs[3]); | 609 | return (src >= mpic->ipi_vecs[0] && src <= mpic->ipi_vecs[3]); |
612 | } | 610 | } |
613 | 611 | ||
614 | /* Determine if the linux irq is a timer */ | 612 | /* Determine if the linux irq is a timer */ |
615 | static unsigned int mpic_is_tm(struct mpic *mpic, unsigned int irq) | 613 | static unsigned int mpic_is_tm(struct mpic *mpic, unsigned int src) |
616 | { | 614 | { |
617 | unsigned int src = virq_to_hw(irq); | ||
618 | |||
619 | return (src >= mpic->timer_vecs[0] && src <= mpic->timer_vecs[7]); | 615 | return (src >= mpic->timer_vecs[0] && src <= mpic->timer_vecs[7]); |
620 | } | 616 | } |
621 | 617 | ||
@@ -876,21 +872,45 @@ int mpic_set_irq_type(struct irq_data *d, unsigned int flow_type) | |||
876 | if (src >= mpic->num_sources) | 872 | if (src >= mpic->num_sources) |
877 | return -EINVAL; | 873 | return -EINVAL; |
878 | 874 | ||
875 | vold = mpic_irq_read(src, MPIC_INFO(IRQ_VECTOR_PRI)); | ||
876 | |||
877 | /* We don't support "none" type */ | ||
879 | if (flow_type == IRQ_TYPE_NONE) | 878 | if (flow_type == IRQ_TYPE_NONE) |
880 | if (mpic->senses && src < mpic->senses_count) | 879 | flow_type = IRQ_TYPE_DEFAULT; |
881 | flow_type = mpic->senses[src]; | 880 | |
882 | if (flow_type == IRQ_TYPE_NONE) | 881 | /* Default: read HW settings */ |
883 | flow_type = IRQ_TYPE_LEVEL_LOW; | 882 | if (flow_type == IRQ_TYPE_DEFAULT) { |
883 | switch(vold & (MPIC_INFO(VECPRI_POLARITY_MASK) | | ||
884 | MPIC_INFO(VECPRI_SENSE_MASK))) { | ||
885 | case MPIC_INFO(VECPRI_SENSE_EDGE) | | ||
886 | MPIC_INFO(VECPRI_POLARITY_POSITIVE): | ||
887 | flow_type = IRQ_TYPE_EDGE_RISING; | ||
888 | break; | ||
889 | case MPIC_INFO(VECPRI_SENSE_EDGE) | | ||
890 | MPIC_INFO(VECPRI_POLARITY_NEGATIVE): | ||
891 | flow_type = IRQ_TYPE_EDGE_FALLING; | ||
892 | break; | ||
893 | case MPIC_INFO(VECPRI_SENSE_LEVEL) | | ||
894 | MPIC_INFO(VECPRI_POLARITY_POSITIVE): | ||
895 | flow_type = IRQ_TYPE_LEVEL_HIGH; | ||
896 | break; | ||
897 | case MPIC_INFO(VECPRI_SENSE_LEVEL) | | ||
898 | MPIC_INFO(VECPRI_POLARITY_NEGATIVE): | ||
899 | flow_type = IRQ_TYPE_LEVEL_LOW; | ||
900 | break; | ||
901 | } | ||
902 | } | ||
884 | 903 | ||
904 | /* Apply to irq desc */ | ||
885 | irqd_set_trigger_type(d, flow_type); | 905 | irqd_set_trigger_type(d, flow_type); |
886 | 906 | ||
907 | /* Apply to HW */ | ||
887 | if (mpic_is_ht_interrupt(mpic, src)) | 908 | if (mpic_is_ht_interrupt(mpic, src)) |
888 | vecpri = MPIC_VECPRI_POLARITY_POSITIVE | | 909 | vecpri = MPIC_VECPRI_POLARITY_POSITIVE | |
889 | MPIC_VECPRI_SENSE_EDGE; | 910 | MPIC_VECPRI_SENSE_EDGE; |
890 | else | 911 | else |
891 | vecpri = mpic_type_to_vecpri(mpic, flow_type); | 912 | vecpri = mpic_type_to_vecpri(mpic, flow_type); |
892 | 913 | ||
893 | vold = mpic_irq_read(src, MPIC_INFO(IRQ_VECTOR_PRI)); | ||
894 | vnew = vold & ~(MPIC_INFO(VECPRI_POLARITY_MASK) | | 914 | vnew = vold & ~(MPIC_INFO(VECPRI_POLARITY_MASK) | |
895 | MPIC_INFO(VECPRI_SENSE_MASK)); | 915 | MPIC_INFO(VECPRI_SENSE_MASK)); |
896 | vnew |= vecpri; | 916 | vnew |= vecpri; |
@@ -1026,7 +1046,7 @@ static int mpic_host_map(struct irq_domain *h, unsigned int virq, | |||
1026 | irq_set_chip_and_handler(virq, chip, handle_fasteoi_irq); | 1046 | irq_set_chip_and_handler(virq, chip, handle_fasteoi_irq); |
1027 | 1047 | ||
1028 | /* Set default irq type */ | 1048 | /* Set default irq type */ |
1029 | irq_set_irq_type(virq, IRQ_TYPE_NONE); | 1049 | irq_set_irq_type(virq, IRQ_TYPE_DEFAULT); |
1030 | 1050 | ||
1031 | /* If the MPIC was reset, then all vectors have already been | 1051 | /* If the MPIC was reset, then all vectors have already been |
1032 | * initialized. Otherwise, a per source lazy initialization | 1052 | * initialized. Otherwise, a per source lazy initialization |
@@ -1417,12 +1437,6 @@ void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num, | |||
1417 | mpic->num_sources = isu_first + mpic->isu_size; | 1437 | mpic->num_sources = isu_first + mpic->isu_size; |
1418 | } | 1438 | } |
1419 | 1439 | ||
1420 | void __init mpic_set_default_senses(struct mpic *mpic, u8 *senses, int count) | ||
1421 | { | ||
1422 | mpic->senses = senses; | ||
1423 | mpic->senses_count = count; | ||
1424 | } | ||
1425 | |||
1426 | void __init mpic_init(struct mpic *mpic) | 1440 | void __init mpic_init(struct mpic *mpic) |
1427 | { | 1441 | { |
1428 | int i, cpu; | 1442 | int i, cpu; |
@@ -1555,12 +1569,12 @@ void mpic_irq_set_priority(unsigned int irq, unsigned int pri) | |||
1555 | return; | 1569 | return; |
1556 | 1570 | ||
1557 | raw_spin_lock_irqsave(&mpic_lock, flags); | 1571 | raw_spin_lock_irqsave(&mpic_lock, flags); |
1558 | if (mpic_is_ipi(mpic, irq)) { | 1572 | if (mpic_is_ipi(mpic, src)) { |
1559 | reg = mpic_ipi_read(src - mpic->ipi_vecs[0]) & | 1573 | reg = mpic_ipi_read(src - mpic->ipi_vecs[0]) & |
1560 | ~MPIC_VECPRI_PRIORITY_MASK; | 1574 | ~MPIC_VECPRI_PRIORITY_MASK; |
1561 | mpic_ipi_write(src - mpic->ipi_vecs[0], | 1575 | mpic_ipi_write(src - mpic->ipi_vecs[0], |
1562 | reg | (pri << MPIC_VECPRI_PRIORITY_SHIFT)); | 1576 | reg | (pri << MPIC_VECPRI_PRIORITY_SHIFT)); |
1563 | } else if (mpic_is_tm(mpic, irq)) { | 1577 | } else if (mpic_is_tm(mpic, src)) { |
1564 | reg = mpic_tm_read(src - mpic->timer_vecs[0]) & | 1578 | reg = mpic_tm_read(src - mpic->timer_vecs[0]) & |
1565 | ~MPIC_VECPRI_PRIORITY_MASK; | 1579 | ~MPIC_VECPRI_PRIORITY_MASK; |
1566 | mpic_tm_write(src - mpic->timer_vecs[0], | 1580 | mpic_tm_write(src - mpic->timer_vecs[0], |
diff --git a/arch/powerpc/sysdev/mpic_msgr.c b/arch/powerpc/sysdev/mpic_msgr.c index 6e7fa386e76a..483d8fa72e8b 100644 --- a/arch/powerpc/sysdev/mpic_msgr.c +++ b/arch/powerpc/sysdev/mpic_msgr.c | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | static struct mpic_msgr **mpic_msgrs; | 28 | static struct mpic_msgr **mpic_msgrs; |
29 | static unsigned int mpic_msgr_count; | 29 | static unsigned int mpic_msgr_count; |
30 | static DEFINE_RAW_SPINLOCK(msgrs_lock); | ||
30 | 31 | ||
31 | static inline void _mpic_msgr_mer_write(struct mpic_msgr *msgr, u32 value) | 32 | static inline void _mpic_msgr_mer_write(struct mpic_msgr *msgr, u32 value) |
32 | { | 33 | { |
@@ -56,12 +57,11 @@ struct mpic_msgr *mpic_msgr_get(unsigned int reg_num) | |||
56 | if (reg_num >= mpic_msgr_count) | 57 | if (reg_num >= mpic_msgr_count) |
57 | return ERR_PTR(-ENODEV); | 58 | return ERR_PTR(-ENODEV); |
58 | 59 | ||
59 | raw_spin_lock_irqsave(&msgr->lock, flags); | 60 | raw_spin_lock_irqsave(&msgrs_lock, flags); |
60 | if (mpic_msgrs[reg_num]->in_use == MSGR_FREE) { | 61 | msgr = mpic_msgrs[reg_num]; |
61 | msgr = mpic_msgrs[reg_num]; | 62 | if (msgr->in_use == MSGR_FREE) |
62 | msgr->in_use = MSGR_INUSE; | 63 | msgr->in_use = MSGR_INUSE; |
63 | } | 64 | raw_spin_unlock_irqrestore(&msgrs_lock, flags); |
64 | raw_spin_unlock_irqrestore(&msgr->lock, flags); | ||
65 | 65 | ||
66 | return msgr; | 66 | return msgr; |
67 | } | 67 | } |
@@ -228,7 +228,7 @@ static __devinit int mpic_msgr_probe(struct platform_device *dev) | |||
228 | 228 | ||
229 | reg_number = block_number * MPIC_MSGR_REGISTERS_PER_BLOCK + i; | 229 | reg_number = block_number * MPIC_MSGR_REGISTERS_PER_BLOCK + i; |
230 | msgr->base = msgr_block_addr + i * MPIC_MSGR_STRIDE; | 230 | msgr->base = msgr_block_addr + i * MPIC_MSGR_STRIDE; |
231 | msgr->mer = msgr->base + MPIC_MSGR_MER_OFFSET; | 231 | msgr->mer = (u32 *)((u8 *)msgr->base + MPIC_MSGR_MER_OFFSET); |
232 | msgr->in_use = MSGR_FREE; | 232 | msgr->in_use = MSGR_FREE; |
233 | msgr->num = i; | 233 | msgr->num = i; |
234 | raw_spin_lock_init(&msgr->lock); | 234 | raw_spin_lock_init(&msgr->lock); |
diff --git a/arch/powerpc/sysdev/scom.c b/arch/powerpc/sysdev/scom.c index 49a3ece1c6b3..702256a1ca11 100644 --- a/arch/powerpc/sysdev/scom.c +++ b/arch/powerpc/sysdev/scom.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/debugfs.h> | 22 | #include <linux/debugfs.h> |
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/export.h> | 24 | #include <linux/export.h> |
25 | #include <asm/debug.h> | ||
25 | #include <asm/prom.h> | 26 | #include <asm/prom.h> |
26 | #include <asm/scom.h> | 27 | #include <asm/scom.h> |
27 | 28 | ||
diff --git a/arch/powerpc/sysdev/xics/xics-common.c b/arch/powerpc/sysdev/xics/xics-common.c index ea5e204e3450..cd1d18db92c6 100644 --- a/arch/powerpc/sysdev/xics/xics-common.c +++ b/arch/powerpc/sysdev/xics/xics-common.c | |||
@@ -188,6 +188,7 @@ void xics_migrate_irqs_away(void) | |||
188 | { | 188 | { |
189 | int cpu = smp_processor_id(), hw_cpu = hard_smp_processor_id(); | 189 | int cpu = smp_processor_id(), hw_cpu = hard_smp_processor_id(); |
190 | unsigned int irq, virq; | 190 | unsigned int irq, virq; |
191 | struct irq_desc *desc; | ||
191 | 192 | ||
192 | /* If we used to be the default server, move to the new "boot_cpuid" */ | 193 | /* If we used to be the default server, move to the new "boot_cpuid" */ |
193 | if (hw_cpu == xics_default_server) | 194 | if (hw_cpu == xics_default_server) |
@@ -202,8 +203,7 @@ void xics_migrate_irqs_away(void) | |||
202 | /* Allow IPIs again... */ | 203 | /* Allow IPIs again... */ |
203 | icp_ops->set_priority(DEFAULT_PRIORITY); | 204 | icp_ops->set_priority(DEFAULT_PRIORITY); |
204 | 205 | ||
205 | for_each_irq(virq) { | 206 | for_each_irq_desc(virq, desc) { |
206 | struct irq_desc *desc; | ||
207 | struct irq_chip *chip; | 207 | struct irq_chip *chip; |
208 | long server; | 208 | long server; |
209 | unsigned long flags; | 209 | unsigned long flags; |
@@ -212,9 +212,8 @@ void xics_migrate_irqs_away(void) | |||
212 | /* We can't set affinity on ISA interrupts */ | 212 | /* We can't set affinity on ISA interrupts */ |
213 | if (virq < NUM_ISA_INTERRUPTS) | 213 | if (virq < NUM_ISA_INTERRUPTS) |
214 | continue; | 214 | continue; |
215 | desc = irq_to_desc(virq); | ||
216 | /* We only need to migrate enabled IRQS */ | 215 | /* We only need to migrate enabled IRQS */ |
217 | if (!desc || !desc->action) | 216 | if (!desc->action) |
218 | continue; | 217 | continue; |
219 | if (desc->irq_data.domain != xics_host) | 218 | if (desc->irq_data.domain != xics_host) |
220 | continue; | 219 | continue; |
diff --git a/arch/sh/include/asm/atomic.h b/arch/sh/include/asm/atomic.h index 37f2f4a55231..f4c1c20bcdf6 100644 --- a/arch/sh/include/asm/atomic.h +++ b/arch/sh/include/asm/atomic.h | |||
@@ -11,7 +11,7 @@ | |||
11 | #include <linux/types.h> | 11 | #include <linux/types.h> |
12 | #include <asm/cmpxchg.h> | 12 | #include <asm/cmpxchg.h> |
13 | 13 | ||
14 | #define ATOMIC_INIT(i) ( (atomic_t) { (i) } ) | 14 | #define ATOMIC_INIT(i) { (i) } |
15 | 15 | ||
16 | #define atomic_read(v) (*(volatile int *)&(v)->counter) | 16 | #define atomic_read(v) (*(volatile int *)&(v)->counter) |
17 | #define atomic_set(v,i) ((v)->counter = (i)) | 17 | #define atomic_set(v,i) ((v)->counter = (i)) |
diff --git a/arch/sh/mm/fault_32.c b/arch/sh/mm/fault_32.c index 324eef93c900..e99b104d967a 100644 --- a/arch/sh/mm/fault_32.c +++ b/arch/sh/mm/fault_32.c | |||
@@ -86,7 +86,7 @@ static noinline int vmalloc_fault(unsigned long address) | |||
86 | pte_t *pte_k; | 86 | pte_t *pte_k; |
87 | 87 | ||
88 | /* Make sure we are in vmalloc/module/P3 area: */ | 88 | /* Make sure we are in vmalloc/module/P3 area: */ |
89 | if (!(address >= VMALLOC_START && address < P3_ADDR_MAX)) | 89 | if (!(address >= P3SEG && address < P3_ADDR_MAX)) |
90 | return -1; | 90 | return -1; |
91 | 91 | ||
92 | /* | 92 | /* |
diff --git a/arch/tile/include/asm/pci.h b/arch/tile/include/asm/pci.h index 5d5a635530bd..32e6cbe8dff3 100644 --- a/arch/tile/include/asm/pci.h +++ b/arch/tile/include/asm/pci.h | |||
@@ -47,8 +47,8 @@ struct pci_controller { | |||
47 | */ | 47 | */ |
48 | #define PCI_DMA_BUS_IS_PHYS 1 | 48 | #define PCI_DMA_BUS_IS_PHYS 1 |
49 | 49 | ||
50 | int __devinit tile_pci_init(void); | 50 | int __init tile_pci_init(void); |
51 | int __devinit pcibios_init(void); | 51 | int __init pcibios_init(void); |
52 | 52 | ||
53 | static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) {} | 53 | static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) {} |
54 | 54 | ||
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c index a1bb59eecc18..b56d12bf5900 100644 --- a/arch/tile/kernel/pci.c +++ b/arch/tile/kernel/pci.c | |||
@@ -141,7 +141,7 @@ static int __devinit tile_init_irqs(int controller_id, | |||
141 | * | 141 | * |
142 | * Returns the number of controllers discovered. | 142 | * Returns the number of controllers discovered. |
143 | */ | 143 | */ |
144 | int __devinit tile_pci_init(void) | 144 | int __init tile_pci_init(void) |
145 | { | 145 | { |
146 | int i; | 146 | int i; |
147 | 147 | ||
@@ -287,7 +287,7 @@ static void __devinit fixup_read_and_payload_sizes(void) | |||
287 | * The controllers have been set up by the time we get here, by a call to | 287 | * The controllers have been set up by the time we get here, by a call to |
288 | * tile_pci_init. | 288 | * tile_pci_init. |
289 | */ | 289 | */ |
290 | int __devinit pcibios_init(void) | 290 | int __init pcibios_init(void) |
291 | { | 291 | { |
292 | int i; | 292 | int i; |
293 | 293 | ||
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 1d14cc6b79ad..c9866b0b77d8 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -81,7 +81,7 @@ config X86 | |||
81 | select CLKEVT_I8253 | 81 | select CLKEVT_I8253 |
82 | select ARCH_HAVE_NMI_SAFE_CMPXCHG | 82 | select ARCH_HAVE_NMI_SAFE_CMPXCHG |
83 | select GENERIC_IOMAP | 83 | select GENERIC_IOMAP |
84 | select DCACHE_WORD_ACCESS if !DEBUG_PAGEALLOC | 84 | select DCACHE_WORD_ACCESS |
85 | 85 | ||
86 | config INSTRUCTION_DECODER | 86 | config INSTRUCTION_DECODER |
87 | def_bool (KPROBES || PERF_EVENTS) | 87 | def_bool (KPROBES || PERF_EVENTS) |
diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S index a0559930a180..c85e3ac99bba 100644 --- a/arch/x86/boot/compressed/head_32.S +++ b/arch/x86/boot/compressed/head_32.S | |||
@@ -33,6 +33,9 @@ | |||
33 | __HEAD | 33 | __HEAD |
34 | ENTRY(startup_32) | 34 | ENTRY(startup_32) |
35 | #ifdef CONFIG_EFI_STUB | 35 | #ifdef CONFIG_EFI_STUB |
36 | jmp preferred_addr | ||
37 | |||
38 | .balign 0x10 | ||
36 | /* | 39 | /* |
37 | * We don't need the return address, so set up the stack so | 40 | * We don't need the return address, so set up the stack so |
38 | * efi_main() can find its arugments. | 41 | * efi_main() can find its arugments. |
@@ -41,12 +44,17 @@ ENTRY(startup_32) | |||
41 | 44 | ||
42 | call efi_main | 45 | call efi_main |
43 | cmpl $0, %eax | 46 | cmpl $0, %eax |
44 | je preferred_addr | ||
45 | movl %eax, %esi | 47 | movl %eax, %esi |
46 | call 1f | 48 | jne 2f |
47 | 1: | 49 | 1: |
50 | /* EFI init failed, so hang. */ | ||
51 | hlt | ||
52 | jmp 1b | ||
53 | 2: | ||
54 | call 3f | ||
55 | 3: | ||
48 | popl %eax | 56 | popl %eax |
49 | subl $1b, %eax | 57 | subl $3b, %eax |
50 | subl BP_pref_address(%esi), %eax | 58 | subl BP_pref_address(%esi), %eax |
51 | add BP_code32_start(%esi), %eax | 59 | add BP_code32_start(%esi), %eax |
52 | leal preferred_addr(%eax), %eax | 60 | leal preferred_addr(%eax), %eax |
diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index 558d76ce23bc..87e03a13d8e3 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S | |||
@@ -200,18 +200,28 @@ ENTRY(startup_64) | |||
200 | * entire text+data+bss and hopefully all of memory. | 200 | * entire text+data+bss and hopefully all of memory. |
201 | */ | 201 | */ |
202 | #ifdef CONFIG_EFI_STUB | 202 | #ifdef CONFIG_EFI_STUB |
203 | pushq %rsi | 203 | /* |
204 | * The entry point for the PE/COFF executable is 0x210, so only | ||
205 | * legacy boot loaders will execute this jmp. | ||
206 | */ | ||
207 | jmp preferred_addr | ||
208 | |||
209 | .org 0x210 | ||
204 | mov %rcx, %rdi | 210 | mov %rcx, %rdi |
205 | mov %rdx, %rsi | 211 | mov %rdx, %rsi |
206 | call efi_main | 212 | call efi_main |
207 | popq %rsi | ||
208 | cmpq $0,%rax | ||
209 | je preferred_addr | ||
210 | movq %rax,%rsi | 213 | movq %rax,%rsi |
211 | call 1f | 214 | cmpq $0,%rax |
215 | jne 2f | ||
212 | 1: | 216 | 1: |
217 | /* EFI init failed, so hang. */ | ||
218 | hlt | ||
219 | jmp 1b | ||
220 | 2: | ||
221 | call 3f | ||
222 | 3: | ||
213 | popq %rax | 223 | popq %rax |
214 | subq $1b, %rax | 224 | subq $3b, %rax |
215 | subq BP_pref_address(%rsi), %rax | 225 | subq BP_pref_address(%rsi), %rax |
216 | add BP_code32_start(%esi), %eax | 226 | add BP_code32_start(%esi), %eax |
217 | leaq preferred_addr(%rax), %rax | 227 | leaq preferred_addr(%rax), %rax |
diff --git a/arch/x86/boot/compressed/relocs.c b/arch/x86/boot/compressed/relocs.c index d3c0b0277666..fb7117a4ade1 100644 --- a/arch/x86/boot/compressed/relocs.c +++ b/arch/x86/boot/compressed/relocs.c | |||
@@ -403,13 +403,11 @@ static void print_absolute_symbols(void) | |||
403 | for (i = 0; i < ehdr.e_shnum; i++) { | 403 | for (i = 0; i < ehdr.e_shnum; i++) { |
404 | struct section *sec = &secs[i]; | 404 | struct section *sec = &secs[i]; |
405 | char *sym_strtab; | 405 | char *sym_strtab; |
406 | Elf32_Sym *sh_symtab; | ||
407 | int j; | 406 | int j; |
408 | 407 | ||
409 | if (sec->shdr.sh_type != SHT_SYMTAB) { | 408 | if (sec->shdr.sh_type != SHT_SYMTAB) { |
410 | continue; | 409 | continue; |
411 | } | 410 | } |
412 | sh_symtab = sec->symtab; | ||
413 | sym_strtab = sec->link->strtab; | 411 | sym_strtab = sec->link->strtab; |
414 | for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Sym); j++) { | 412 | for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Sym); j++) { |
415 | Elf32_Sym *sym; | 413 | Elf32_Sym *sym; |
diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c index ed549767a231..24443a332083 100644 --- a/arch/x86/boot/tools/build.c +++ b/arch/x86/boot/tools/build.c | |||
@@ -205,8 +205,13 @@ int main(int argc, char ** argv) | |||
205 | put_unaligned_le32(file_sz, &buf[pe_header + 0x50]); | 205 | put_unaligned_le32(file_sz, &buf[pe_header + 0x50]); |
206 | 206 | ||
207 | #ifdef CONFIG_X86_32 | 207 | #ifdef CONFIG_X86_32 |
208 | /* Address of entry point */ | 208 | /* |
209 | put_unaligned_le32(i, &buf[pe_header + 0x28]); | 209 | * Address of entry point. |
210 | * | ||
211 | * The EFI stub entry point is +16 bytes from the start of | ||
212 | * the .text section. | ||
213 | */ | ||
214 | put_unaligned_le32(i + 16, &buf[pe_header + 0x28]); | ||
210 | 215 | ||
211 | /* .text size */ | 216 | /* .text size */ |
212 | put_unaligned_le32(file_sz, &buf[pe_header + 0xb0]); | 217 | put_unaligned_le32(file_sz, &buf[pe_header + 0xb0]); |
@@ -217,9 +222,11 @@ int main(int argc, char ** argv) | |||
217 | /* | 222 | /* |
218 | * Address of entry point. startup_32 is at the beginning and | 223 | * Address of entry point. startup_32 is at the beginning and |
219 | * the 64-bit entry point (startup_64) is always 512 bytes | 224 | * the 64-bit entry point (startup_64) is always 512 bytes |
220 | * after. | 225 | * after. The EFI stub entry point is 16 bytes after that, as |
226 | * the first instruction allows legacy loaders to jump over | ||
227 | * the EFI stub initialisation | ||
221 | */ | 228 | */ |
222 | put_unaligned_le32(i + 512, &buf[pe_header + 0x28]); | 229 | put_unaligned_le32(i + 528, &buf[pe_header + 0x28]); |
223 | 230 | ||
224 | /* .text size */ | 231 | /* .text size */ |
225 | put_unaligned_le32(file_sz, &buf[pe_header + 0xc0]); | 232 | put_unaligned_le32(file_sz, &buf[pe_header + 0xc0]); |
diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c index 4824fb45560f..07b3a68d2d29 100644 --- a/arch/x86/ia32/ia32_aout.c +++ b/arch/x86/ia32/ia32_aout.c | |||
@@ -294,8 +294,7 @@ static int load_aout_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
294 | 294 | ||
295 | /* OK, This is the point of no return */ | 295 | /* OK, This is the point of no return */ |
296 | set_personality(PER_LINUX); | 296 | set_personality(PER_LINUX); |
297 | set_thread_flag(TIF_IA32); | 297 | set_personality_ia32(false); |
298 | current->mm->context.ia32_compat = 1; | ||
299 | 298 | ||
300 | setup_new_exec(bprm); | 299 | setup_new_exec(bprm); |
301 | 300 | ||
diff --git a/arch/x86/include/asm/posix_types.h b/arch/x86/include/asm/posix_types.h index 3427b7798dbc..7ef7c3020e5c 100644 --- a/arch/x86/include/asm/posix_types.h +++ b/arch/x86/include/asm/posix_types.h | |||
@@ -7,9 +7,9 @@ | |||
7 | #else | 7 | #else |
8 | # ifdef __i386__ | 8 | # ifdef __i386__ |
9 | # include "posix_types_32.h" | 9 | # include "posix_types_32.h" |
10 | # elif defined(__LP64__) | 10 | # elif defined(__ILP32__) |
11 | # include "posix_types_64.h" | ||
12 | # else | ||
13 | # include "posix_types_x32.h" | 11 | # include "posix_types_x32.h" |
12 | # else | ||
13 | # include "posix_types_64.h" | ||
14 | # endif | 14 | # endif |
15 | #endif | 15 | #endif |
diff --git a/arch/x86/include/asm/sigcontext.h b/arch/x86/include/asm/sigcontext.h index 4a085383af27..5ca71c065eef 100644 --- a/arch/x86/include/asm/sigcontext.h +++ b/arch/x86/include/asm/sigcontext.h | |||
@@ -257,7 +257,7 @@ struct sigcontext { | |||
257 | __u64 oldmask; | 257 | __u64 oldmask; |
258 | __u64 cr2; | 258 | __u64 cr2; |
259 | struct _fpstate __user *fpstate; /* zero when no FPU context */ | 259 | struct _fpstate __user *fpstate; /* zero when no FPU context */ |
260 | #ifndef __LP64__ | 260 | #ifdef __ILP32__ |
261 | __u32 __fpstate_pad; | 261 | __u32 __fpstate_pad; |
262 | #endif | 262 | #endif |
263 | __u64 reserved1[8]; | 263 | __u64 reserved1[8]; |
diff --git a/arch/x86/include/asm/siginfo.h b/arch/x86/include/asm/siginfo.h index fc1aa5535646..34c47b3341c0 100644 --- a/arch/x86/include/asm/siginfo.h +++ b/arch/x86/include/asm/siginfo.h | |||
@@ -2,7 +2,13 @@ | |||
2 | #define _ASM_X86_SIGINFO_H | 2 | #define _ASM_X86_SIGINFO_H |
3 | 3 | ||
4 | #ifdef __x86_64__ | 4 | #ifdef __x86_64__ |
5 | # define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int)) | 5 | # ifdef __ILP32__ /* x32 */ |
6 | typedef long long __kernel_si_clock_t __attribute__((aligned(4))); | ||
7 | # define __ARCH_SI_CLOCK_T __kernel_si_clock_t | ||
8 | # define __ARCH_SI_ATTRIBUTES __attribute__((aligned(8))) | ||
9 | # else /* x86-64 */ | ||
10 | # define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int)) | ||
11 | # endif | ||
6 | #endif | 12 | #endif |
7 | 13 | ||
8 | #include <asm-generic/siginfo.h> | 14 | #include <asm-generic/siginfo.h> |
diff --git a/arch/x86/include/asm/unistd.h b/arch/x86/include/asm/unistd.h index 37cdc9d99bb1..4437001d8e3d 100644 --- a/arch/x86/include/asm/unistd.h +++ b/arch/x86/include/asm/unistd.h | |||
@@ -63,10 +63,10 @@ | |||
63 | #else | 63 | #else |
64 | # ifdef __i386__ | 64 | # ifdef __i386__ |
65 | # include <asm/unistd_32.h> | 65 | # include <asm/unistd_32.h> |
66 | # elif defined(__LP64__) | 66 | # elif defined(__ILP32__) |
67 | # include <asm/unistd_64.h> | ||
68 | # else | ||
69 | # include <asm/unistd_x32.h> | 67 | # include <asm/unistd_x32.h> |
68 | # else | ||
69 | # include <asm/unistd_64.h> | ||
70 | # endif | 70 | # endif |
71 | #endif | 71 | #endif |
72 | 72 | ||
diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h index 6fe6767b7124..e58f03b206c3 100644 --- a/arch/x86/include/asm/word-at-a-time.h +++ b/arch/x86/include/asm/word-at-a-time.h | |||
@@ -43,4 +43,37 @@ static inline unsigned long has_zero(unsigned long a) | |||
43 | return ((a - REPEAT_BYTE(0x01)) & ~a) & REPEAT_BYTE(0x80); | 43 | return ((a - REPEAT_BYTE(0x01)) & ~a) & REPEAT_BYTE(0x80); |
44 | } | 44 | } |
45 | 45 | ||
46 | /* | ||
47 | * Load an unaligned word from kernel space. | ||
48 | * | ||
49 | * In the (very unlikely) case of the word being a page-crosser | ||
50 | * and the next page not being mapped, take the exception and | ||
51 | * return zeroes in the non-existing part. | ||
52 | */ | ||
53 | static inline unsigned long load_unaligned_zeropad(const void *addr) | ||
54 | { | ||
55 | unsigned long ret, dummy; | ||
56 | |||
57 | asm( | ||
58 | "1:\tmov %2,%0\n" | ||
59 | "2:\n" | ||
60 | ".section .fixup,\"ax\"\n" | ||
61 | "3:\t" | ||
62 | "lea %2,%1\n\t" | ||
63 | "and %3,%1\n\t" | ||
64 | "mov (%1),%0\n\t" | ||
65 | "leal %2,%%ecx\n\t" | ||
66 | "andl %4,%%ecx\n\t" | ||
67 | "shll $3,%%ecx\n\t" | ||
68 | "shr %%cl,%0\n\t" | ||
69 | "jmp 2b\n" | ||
70 | ".previous\n" | ||
71 | _ASM_EXTABLE(1b, 3b) | ||
72 | :"=&r" (ret),"=&c" (dummy) | ||
73 | :"m" (*(unsigned long *)addr), | ||
74 | "i" (-sizeof(unsigned long)), | ||
75 | "i" (sizeof(unsigned long)-1)); | ||
76 | return ret; | ||
77 | } | ||
78 | |||
46 | #endif /* _ASM_WORD_AT_A_TIME_H */ | 79 | #endif /* _ASM_WORD_AT_A_TIME_H */ |
diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h index baaca8defec8..764b66a4cf89 100644 --- a/arch/x86/include/asm/x86_init.h +++ b/arch/x86/include/asm/x86_init.h | |||
@@ -195,6 +195,5 @@ extern struct x86_msi_ops x86_msi; | |||
195 | 195 | ||
196 | extern void x86_init_noop(void); | 196 | extern void x86_init_noop(void); |
197 | extern void x86_init_uint_noop(unsigned int unused); | 197 | extern void x86_init_uint_noop(unsigned int unused); |
198 | extern void x86_default_fixup_cpu_id(struct cpuinfo_x86 *c, int node); | ||
199 | 198 | ||
200 | #endif | 199 | #endif |
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c index 103b6ab368d3..146a49c763a4 100644 --- a/arch/x86/kernel/acpi/sleep.c +++ b/arch/x86/kernel/acpi/sleep.c | |||
@@ -24,6 +24,10 @@ unsigned long acpi_realmode_flags; | |||
24 | static char temp_stack[4096]; | 24 | static char temp_stack[4096]; |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | asmlinkage void acpi_enter_s3(void) | ||
28 | { | ||
29 | acpi_enter_sleep_state(3, wake_sleep_flags); | ||
30 | } | ||
27 | /** | 31 | /** |
28 | * acpi_suspend_lowlevel - save kernel state | 32 | * acpi_suspend_lowlevel - save kernel state |
29 | * | 33 | * |
diff --git a/arch/x86/kernel/acpi/sleep.h b/arch/x86/kernel/acpi/sleep.h index 416d4be13fef..d68677a2a010 100644 --- a/arch/x86/kernel/acpi/sleep.h +++ b/arch/x86/kernel/acpi/sleep.h | |||
@@ -3,12 +3,16 @@ | |||
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include <asm/trampoline.h> | 5 | #include <asm/trampoline.h> |
6 | #include <linux/linkage.h> | ||
6 | 7 | ||
7 | extern unsigned long saved_video_mode; | 8 | extern unsigned long saved_video_mode; |
8 | extern long saved_magic; | 9 | extern long saved_magic; |
9 | 10 | ||
10 | extern int wakeup_pmode_return; | 11 | extern int wakeup_pmode_return; |
11 | 12 | ||
13 | extern u8 wake_sleep_flags; | ||
14 | extern asmlinkage void acpi_enter_s3(void); | ||
15 | |||
12 | extern unsigned long acpi_copy_wakeup_routine(unsigned long); | 16 | extern unsigned long acpi_copy_wakeup_routine(unsigned long); |
13 | extern void wakeup_long64(void); | 17 | extern void wakeup_long64(void); |
14 | 18 | ||
diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S index 13ab720573e3..72610839f03b 100644 --- a/arch/x86/kernel/acpi/wakeup_32.S +++ b/arch/x86/kernel/acpi/wakeup_32.S | |||
@@ -74,9 +74,7 @@ restore_registers: | |||
74 | ENTRY(do_suspend_lowlevel) | 74 | ENTRY(do_suspend_lowlevel) |
75 | call save_processor_state | 75 | call save_processor_state |
76 | call save_registers | 76 | call save_registers |
77 | pushl $3 | 77 | call acpi_enter_s3 |
78 | call acpi_enter_sleep_state | ||
79 | addl $4, %esp | ||
80 | 78 | ||
81 | # In case of S3 failure, we'll emerge here. Jump | 79 | # In case of S3 failure, we'll emerge here. Jump |
82 | # to ret_point to recover | 80 | # to ret_point to recover |
diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S index 8ea5164cbd04..014d1d28c397 100644 --- a/arch/x86/kernel/acpi/wakeup_64.S +++ b/arch/x86/kernel/acpi/wakeup_64.S | |||
@@ -71,9 +71,7 @@ ENTRY(do_suspend_lowlevel) | |||
71 | movq %rsi, saved_rsi | 71 | movq %rsi, saved_rsi |
72 | 72 | ||
73 | addq $8, %rsp | 73 | addq $8, %rsp |
74 | movl $3, %edi | 74 | call acpi_enter_s3 |
75 | xorl %eax, %eax | ||
76 | call acpi_enter_sleep_state | ||
77 | /* in case something went wrong, restore the machine status and go on */ | 75 | /* in case something went wrong, restore the machine status and go on */ |
78 | jmp resume_point | 76 | jmp resume_point |
79 | 77 | ||
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 11544d8f1e97..edc24480469f 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c | |||
@@ -1637,9 +1637,11 @@ static int __init apic_verify(void) | |||
1637 | mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; | 1637 | mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; |
1638 | 1638 | ||
1639 | /* The BIOS may have set up the APIC at some other address */ | 1639 | /* The BIOS may have set up the APIC at some other address */ |
1640 | rdmsr(MSR_IA32_APICBASE, l, h); | 1640 | if (boot_cpu_data.x86 >= 6) { |
1641 | if (l & MSR_IA32_APICBASE_ENABLE) | 1641 | rdmsr(MSR_IA32_APICBASE, l, h); |
1642 | mp_lapic_addr = l & MSR_IA32_APICBASE_BASE; | 1642 | if (l & MSR_IA32_APICBASE_ENABLE) |
1643 | mp_lapic_addr = l & MSR_IA32_APICBASE_BASE; | ||
1644 | } | ||
1643 | 1645 | ||
1644 | pr_info("Found and enabled local APIC!\n"); | 1646 | pr_info("Found and enabled local APIC!\n"); |
1645 | return 0; | 1647 | return 0; |
@@ -1657,13 +1659,15 @@ int __init apic_force_enable(unsigned long addr) | |||
1657 | * MSR. This can only be done in software for Intel P6 or later | 1659 | * MSR. This can only be done in software for Intel P6 or later |
1658 | * and AMD K7 (Model > 1) or later. | 1660 | * and AMD K7 (Model > 1) or later. |
1659 | */ | 1661 | */ |
1660 | rdmsr(MSR_IA32_APICBASE, l, h); | 1662 | if (boot_cpu_data.x86 >= 6) { |
1661 | if (!(l & MSR_IA32_APICBASE_ENABLE)) { | 1663 | rdmsr(MSR_IA32_APICBASE, l, h); |
1662 | pr_info("Local APIC disabled by BIOS -- reenabling.\n"); | 1664 | if (!(l & MSR_IA32_APICBASE_ENABLE)) { |
1663 | l &= ~MSR_IA32_APICBASE_BASE; | 1665 | pr_info("Local APIC disabled by BIOS -- reenabling.\n"); |
1664 | l |= MSR_IA32_APICBASE_ENABLE | addr; | 1666 | l &= ~MSR_IA32_APICBASE_BASE; |
1665 | wrmsr(MSR_IA32_APICBASE, l, h); | 1667 | l |= MSR_IA32_APICBASE_ENABLE | addr; |
1666 | enabled_via_apicbase = 1; | 1668 | wrmsr(MSR_IA32_APICBASE, l, h); |
1669 | enabled_via_apicbase = 1; | ||
1670 | } | ||
1667 | } | 1671 | } |
1668 | return apic_verify(); | 1672 | return apic_verify(); |
1669 | } | 1673 | } |
@@ -2209,10 +2213,12 @@ static void lapic_resume(void) | |||
2209 | * FIXME! This will be wrong if we ever support suspend on | 2213 | * FIXME! This will be wrong if we ever support suspend on |
2210 | * SMP! We'll need to do this as part of the CPU restore! | 2214 | * SMP! We'll need to do this as part of the CPU restore! |
2211 | */ | 2215 | */ |
2212 | rdmsr(MSR_IA32_APICBASE, l, h); | 2216 | if (boot_cpu_data.x86 >= 6) { |
2213 | l &= ~MSR_IA32_APICBASE_BASE; | 2217 | rdmsr(MSR_IA32_APICBASE, l, h); |
2214 | l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr; | 2218 | l &= ~MSR_IA32_APICBASE_BASE; |
2215 | wrmsr(MSR_IA32_APICBASE, l, h); | 2219 | l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr; |
2220 | wrmsr(MSR_IA32_APICBASE, l, h); | ||
2221 | } | ||
2216 | } | 2222 | } |
2217 | 2223 | ||
2218 | maxlvt = lapic_get_maxlvt(); | 2224 | maxlvt = lapic_get_maxlvt(); |
diff --git a/arch/x86/kernel/apic/apic_numachip.c b/arch/x86/kernel/apic/apic_numachip.c index 899803e03214..23e75422e013 100644 --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c | |||
@@ -207,8 +207,11 @@ static void __init map_csrs(void) | |||
207 | 207 | ||
208 | static void fixup_cpu_id(struct cpuinfo_x86 *c, int node) | 208 | static void fixup_cpu_id(struct cpuinfo_x86 *c, int node) |
209 | { | 209 | { |
210 | c->phys_proc_id = node; | 210 | |
211 | per_cpu(cpu_llc_id, smp_processor_id()) = node; | 211 | if (c->phys_proc_id != node) { |
212 | c->phys_proc_id = node; | ||
213 | per_cpu(cpu_llc_id, smp_processor_id()) = node; | ||
214 | } | ||
212 | } | 215 | } |
213 | 216 | ||
214 | static int __init numachip_system_init(void) | 217 | static int __init numachip_system_init(void) |
diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c index 8a778db45e3a..991e315f4227 100644 --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c | |||
@@ -24,6 +24,12 @@ static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id) | |||
24 | { | 24 | { |
25 | if (x2apic_phys) | 25 | if (x2apic_phys) |
26 | return x2apic_enabled(); | 26 | return x2apic_enabled(); |
27 | else if ((acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) && | ||
28 | (acpi_gbl_FADT.flags & ACPI_FADT_APIC_PHYSICAL) && | ||
29 | x2apic_enabled()) { | ||
30 | printk(KERN_DEBUG "System requires x2apic physical mode\n"); | ||
31 | return 1; | ||
32 | } | ||
27 | else | 33 | else |
28 | return 0; | 34 | return 0; |
29 | } | 35 | } |
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 0a44b90602b0..146bb6218eec 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c | |||
@@ -26,7 +26,8 @@ | |||
26 | * contact AMD for precise details and a CPU swap. | 26 | * contact AMD for precise details and a CPU swap. |
27 | * | 27 | * |
28 | * See http://www.multimania.com/poulot/k6bug.html | 28 | * See http://www.multimania.com/poulot/k6bug.html |
29 | * http://www.amd.com/K6/k6docs/revgd.html | 29 | * and section 2.6.2 of "AMD-K6 Processor Revision Guide - Model 6" |
30 | * (Publication # 21266 Issue Date: August 1998) | ||
30 | * | 31 | * |
31 | * The following test is erm.. interesting. AMD neglected to up | 32 | * The following test is erm.. interesting. AMD neglected to up |
32 | * the chip setting when fixing the bug but they also tweaked some | 33 | * the chip setting when fixing the bug but they also tweaked some |
@@ -94,7 +95,6 @@ static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c) | |||
94 | "system stability may be impaired when more than 32 MB are used.\n"); | 95 | "system stability may be impaired when more than 32 MB are used.\n"); |
95 | else | 96 | else |
96 | printk(KERN_CONT "probably OK (after B9730xxxx).\n"); | 97 | printk(KERN_CONT "probably OK (after B9730xxxx).\n"); |
97 | printk(KERN_INFO "Please see http://membres.lycos.fr/poulot/k6bug.html\n"); | ||
98 | } | 98 | } |
99 | 99 | ||
100 | /* K6 with old style WHCR */ | 100 | /* K6 with old style WHCR */ |
@@ -353,10 +353,11 @@ static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c) | |||
353 | node = per_cpu(cpu_llc_id, cpu); | 353 | node = per_cpu(cpu_llc_id, cpu); |
354 | 354 | ||
355 | /* | 355 | /* |
356 | * If core numbers are inconsistent, it's likely a multi-fabric platform, | 356 | * On multi-fabric platform (e.g. Numascale NumaChip) a |
357 | * so invoke platform-specific handler | 357 | * platform-specific handler needs to be called to fixup some |
358 | * IDs of the CPU. | ||
358 | */ | 359 | */ |
359 | if (c->phys_proc_id != node) | 360 | if (x86_cpuinit.fixup_cpu_id) |
360 | x86_cpuinit.fixup_cpu_id(c, node); | 361 | x86_cpuinit.fixup_cpu_id(c, node); |
361 | 362 | ||
362 | if (!node_online(node)) { | 363 | if (!node_online(node)) { |
@@ -579,6 +580,24 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c) | |||
579 | } | 580 | } |
580 | } | 581 | } |
581 | 582 | ||
583 | /* re-enable TopologyExtensions if switched off by BIOS */ | ||
584 | if ((c->x86 == 0x15) && | ||
585 | (c->x86_model >= 0x10) && (c->x86_model <= 0x1f) && | ||
586 | !cpu_has(c, X86_FEATURE_TOPOEXT)) { | ||
587 | u64 val; | ||
588 | |||
589 | if (!rdmsrl_amd_safe(0xc0011005, &val)) { | ||
590 | val |= 1ULL << 54; | ||
591 | wrmsrl_amd_safe(0xc0011005, val); | ||
592 | rdmsrl(0xc0011005, val); | ||
593 | if (val & (1ULL << 54)) { | ||
594 | set_cpu_cap(c, X86_FEATURE_TOPOEXT); | ||
595 | printk(KERN_INFO FW_INFO "CPU: Re-enabling " | ||
596 | "disabled Topology Extensions Support\n"); | ||
597 | } | ||
598 | } | ||
599 | } | ||
600 | |||
582 | cpu_detect_cache_sizes(c); | 601 | cpu_detect_cache_sizes(c); |
583 | 602 | ||
584 | /* Multi core CPU? */ | 603 | /* Multi core CPU? */ |
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 67e258362a3d..cf79302198a6 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
@@ -1163,15 +1163,6 @@ static void dbg_restore_debug_regs(void) | |||
1163 | #endif /* ! CONFIG_KGDB */ | 1163 | #endif /* ! CONFIG_KGDB */ |
1164 | 1164 | ||
1165 | /* | 1165 | /* |
1166 | * Prints an error where the NUMA and configured core-number mismatch and the | ||
1167 | * platform didn't override this to fix it up | ||
1168 | */ | ||
1169 | void __cpuinit x86_default_fixup_cpu_id(struct cpuinfo_x86 *c, int node) | ||
1170 | { | ||
1171 | pr_err("NUMA core number %d differs from configured core number %d\n", node, c->phys_proc_id); | ||
1172 | } | ||
1173 | |||
1174 | /* | ||
1175 | * cpu_init() initializes state that is per-CPU. Some data is already | 1166 | * cpu_init() initializes state that is per-CPU. Some data is already |
1176 | * initialized (naturally) in the bootstrap process, such as the GDT | 1167 | * initialized (naturally) in the bootstrap process, such as the GDT |
1177 | * and IDT. We reload them nevertheless, this function acts as a | 1168 | * and IDT. We reload them nevertheless, this function acts as a |
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c index 73d08ed98a64..b8f3653dddbc 100644 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c | |||
@@ -433,14 +433,14 @@ int amd_set_l3_disable_slot(struct amd_northbridge *nb, int cpu, unsigned slot, | |||
433 | /* check if @slot is already used or the index is already disabled */ | 433 | /* check if @slot is already used or the index is already disabled */ |
434 | ret = amd_get_l3_disable_slot(nb, slot); | 434 | ret = amd_get_l3_disable_slot(nb, slot); |
435 | if (ret >= 0) | 435 | if (ret >= 0) |
436 | return -EINVAL; | 436 | return -EEXIST; |
437 | 437 | ||
438 | if (index > nb->l3_cache.indices) | 438 | if (index > nb->l3_cache.indices) |
439 | return -EINVAL; | 439 | return -EINVAL; |
440 | 440 | ||
441 | /* check whether the other slot has disabled the same index already */ | 441 | /* check whether the other slot has disabled the same index already */ |
442 | if (index == amd_get_l3_disable_slot(nb, !slot)) | 442 | if (index == amd_get_l3_disable_slot(nb, !slot)) |
443 | return -EINVAL; | 443 | return -EEXIST; |
444 | 444 | ||
445 | amd_l3_disable_index(nb, cpu, slot, index); | 445 | amd_l3_disable_index(nb, cpu, slot, index); |
446 | 446 | ||
@@ -468,8 +468,8 @@ static ssize_t store_cache_disable(struct _cpuid4_info *this_leaf, | |||
468 | err = amd_set_l3_disable_slot(this_leaf->base.nb, cpu, slot, val); | 468 | err = amd_set_l3_disable_slot(this_leaf->base.nb, cpu, slot, val); |
469 | if (err) { | 469 | if (err) { |
470 | if (err == -EEXIST) | 470 | if (err == -EEXIST) |
471 | printk(KERN_WARNING "L3 disable slot %d in use!\n", | 471 | pr_warning("L3 slot %d in use/index already disabled!\n", |
472 | slot); | 472 | slot); |
473 | return err; | 473 | return err; |
474 | } | 474 | } |
475 | return count; | 475 | return count; |
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c index 7734bcbb5a3a..2d6e6498c176 100644 --- a/arch/x86/kernel/i387.c +++ b/arch/x86/kernel/i387.c | |||
@@ -235,6 +235,7 @@ int init_fpu(struct task_struct *tsk) | |||
235 | if (tsk_used_math(tsk)) { | 235 | if (tsk_used_math(tsk)) { |
236 | if (HAVE_HWFP && tsk == current) | 236 | if (HAVE_HWFP && tsk == current) |
237 | unlazy_fpu(tsk); | 237 | unlazy_fpu(tsk); |
238 | tsk->thread.fpu.last_cpu = ~0; | ||
238 | return 0; | 239 | return 0; |
239 | } | 240 | } |
240 | 241 | ||
diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c index 73465aab28f8..8a2ce8fd41c0 100644 --- a/arch/x86/kernel/microcode_amd.c +++ b/arch/x86/kernel/microcode_amd.c | |||
@@ -82,11 +82,6 @@ static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig) | |||
82 | { | 82 | { |
83 | struct cpuinfo_x86 *c = &cpu_data(cpu); | 83 | struct cpuinfo_x86 *c = &cpu_data(cpu); |
84 | 84 | ||
85 | if (c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10) { | ||
86 | pr_warning("CPU%d: family %d not supported\n", cpu, c->x86); | ||
87 | return -1; | ||
88 | } | ||
89 | |||
90 | csig->rev = c->microcode; | 85 | csig->rev = c->microcode; |
91 | pr_info("CPU%d: patch_level=0x%08x\n", cpu, csig->rev); | 86 | pr_info("CPU%d: patch_level=0x%08x\n", cpu, csig->rev); |
92 | 87 | ||
@@ -380,6 +375,13 @@ static struct microcode_ops microcode_amd_ops = { | |||
380 | 375 | ||
381 | struct microcode_ops * __init init_amd_microcode(void) | 376 | struct microcode_ops * __init init_amd_microcode(void) |
382 | { | 377 | { |
378 | struct cpuinfo_x86 *c = &cpu_data(0); | ||
379 | |||
380 | if (c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10) { | ||
381 | pr_warning("AMD CPU family 0x%x not supported\n", c->x86); | ||
382 | return NULL; | ||
383 | } | ||
384 | |||
383 | patch = (void *)get_zeroed_page(GFP_KERNEL); | 385 | patch = (void *)get_zeroed_page(GFP_KERNEL); |
384 | if (!patch) | 386 | if (!patch) |
385 | return NULL; | 387 | return NULL; |
diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c index 87a0f8688301..c9bda6d6035c 100644 --- a/arch/x86/kernel/microcode_core.c +++ b/arch/x86/kernel/microcode_core.c | |||
@@ -419,10 +419,8 @@ static int mc_device_add(struct device *dev, struct subsys_interface *sif) | |||
419 | if (err) | 419 | if (err) |
420 | return err; | 420 | return err; |
421 | 421 | ||
422 | if (microcode_init_cpu(cpu) == UCODE_ERROR) { | 422 | if (microcode_init_cpu(cpu) == UCODE_ERROR) |
423 | sysfs_remove_group(&dev->kobj, &mc_attr_group); | ||
424 | return -EINVAL; | 423 | return -EINVAL; |
425 | } | ||
426 | 424 | ||
427 | return err; | 425 | return err; |
428 | } | 426 | } |
@@ -528,11 +526,11 @@ static int __init microcode_init(void) | |||
528 | microcode_ops = init_intel_microcode(); | 526 | microcode_ops = init_intel_microcode(); |
529 | else if (c->x86_vendor == X86_VENDOR_AMD) | 527 | else if (c->x86_vendor == X86_VENDOR_AMD) |
530 | microcode_ops = init_amd_microcode(); | 528 | microcode_ops = init_amd_microcode(); |
531 | 529 | else | |
532 | if (!microcode_ops) { | ||
533 | pr_err("no support for this CPU vendor\n"); | 530 | pr_err("no support for this CPU vendor\n"); |
531 | |||
532 | if (!microcode_ops) | ||
534 | return -ENODEV; | 533 | return -ENODEV; |
535 | } | ||
536 | 534 | ||
537 | microcode_pdev = platform_device_register_simple("microcode", -1, | 535 | microcode_pdev = platform_device_register_simple("microcode", -1, |
538 | NULL, 0); | 536 | NULL, 0); |
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c index e9f265fd79ae..9cf71d0b2d37 100644 --- a/arch/x86/kernel/x86_init.c +++ b/arch/x86/kernel/x86_init.c | |||
@@ -93,7 +93,6 @@ struct x86_init_ops x86_init __initdata = { | |||
93 | struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = { | 93 | struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = { |
94 | .early_percpu_clock_init = x86_init_noop, | 94 | .early_percpu_clock_init = x86_init_noop, |
95 | .setup_percpu_clockev = setup_secondary_APIC_clock, | 95 | .setup_percpu_clockev = setup_secondary_APIC_clock, |
96 | .fixup_cpu_id = x86_default_fixup_cpu_id, | ||
97 | }; | 96 | }; |
98 | 97 | ||
99 | static void default_nmi_init(void) { }; | 98 | static void default_nmi_init(void) { }; |
diff --git a/arch/x86/platform/geode/net5501.c b/arch/x86/platform/geode/net5501.c index 66d377e334f7..646e3b5b4bb6 100644 --- a/arch/x86/platform/geode/net5501.c +++ b/arch/x86/platform/geode/net5501.c | |||
@@ -63,7 +63,7 @@ static struct gpio_led net5501_leds[] = { | |||
63 | .name = "net5501:1", | 63 | .name = "net5501:1", |
64 | .gpio = 6, | 64 | .gpio = 6, |
65 | .default_trigger = "default-on", | 65 | .default_trigger = "default-on", |
66 | .active_low = 1, | 66 | .active_low = 0, |
67 | }, | 67 | }, |
68 | }; | 68 | }; |
69 | 69 | ||
diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c index e0a37233c0af..e31bcd8f2eee 100644 --- a/arch/x86/platform/mrst/mrst.c +++ b/arch/x86/platform/mrst/mrst.c | |||
@@ -805,7 +805,7 @@ void intel_scu_devices_create(void) | |||
805 | } else | 805 | } else |
806 | i2c_register_board_info(i2c_bus[i], i2c_devs[i], 1); | 806 | i2c_register_board_info(i2c_bus[i], i2c_devs[i], 1); |
807 | } | 807 | } |
808 | intel_scu_notifier_post(SCU_AVAILABLE, 0L); | 808 | intel_scu_notifier_post(SCU_AVAILABLE, NULL); |
809 | } | 809 | } |
810 | EXPORT_SYMBOL_GPL(intel_scu_devices_create); | 810 | EXPORT_SYMBOL_GPL(intel_scu_devices_create); |
811 | 811 | ||
@@ -814,7 +814,7 @@ void intel_scu_devices_destroy(void) | |||
814 | { | 814 | { |
815 | int i; | 815 | int i; |
816 | 816 | ||
817 | intel_scu_notifier_post(SCU_DOWN, 0L); | 817 | intel_scu_notifier_post(SCU_DOWN, NULL); |
818 | 818 | ||
819 | for (i = 0; i < ipc_next_dev; i++) | 819 | for (i = 0; i < ipc_next_dev; i++) |
820 | platform_device_del(ipc_devs[i]); | 820 | platform_device_del(ipc_devs[i]); |
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 4f51bebac02c..a8f8844b8d32 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c | |||
@@ -261,7 +261,8 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx, | |||
261 | 261 | ||
262 | static bool __init xen_check_mwait(void) | 262 | static bool __init xen_check_mwait(void) |
263 | { | 263 | { |
264 | #ifdef CONFIG_ACPI | 264 | #if defined(CONFIG_ACPI) && !defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR) && \ |
265 | !defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR_MODULE) | ||
265 | struct xen_platform_op op = { | 266 | struct xen_platform_op op = { |
266 | .cmd = XENPF_set_processor_pminfo, | 267 | .cmd = XENPF_set_processor_pminfo, |
267 | .u.set_pminfo.id = -1, | 268 | .u.set_pminfo.id = -1, |
@@ -349,7 +350,6 @@ static void __init xen_init_cpuid_mask(void) | |||
349 | /* Xen will set CR4.OSXSAVE if supported and not disabled by force */ | 350 | /* Xen will set CR4.OSXSAVE if supported and not disabled by force */ |
350 | if ((cx & xsave_mask) != xsave_mask) | 351 | if ((cx & xsave_mask) != xsave_mask) |
351 | cpuid_leaf1_ecx_mask &= ~xsave_mask; /* disable XSAVE & OSXSAVE */ | 352 | cpuid_leaf1_ecx_mask &= ~xsave_mask; /* disable XSAVE & OSXSAVE */ |
352 | |||
353 | if (xen_check_mwait()) | 353 | if (xen_check_mwait()) |
354 | cpuid_leaf1_ecx_set_mask = (1 << (X86_FEATURE_MWAIT % 32)); | 354 | cpuid_leaf1_ecx_set_mask = (1 << (X86_FEATURE_MWAIT % 32)); |
355 | } | 355 | } |
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c index 5fac6919b957..0503c0c493a9 100644 --- a/arch/x86/xen/smp.c +++ b/arch/x86/xen/smp.c | |||
@@ -178,6 +178,7 @@ static void __init xen_fill_possible_map(void) | |||
178 | static void __init xen_filter_cpu_maps(void) | 178 | static void __init xen_filter_cpu_maps(void) |
179 | { | 179 | { |
180 | int i, rc; | 180 | int i, rc; |
181 | unsigned int subtract = 0; | ||
181 | 182 | ||
182 | if (!xen_initial_domain()) | 183 | if (!xen_initial_domain()) |
183 | return; | 184 | return; |
@@ -192,8 +193,22 @@ static void __init xen_filter_cpu_maps(void) | |||
192 | } else { | 193 | } else { |
193 | set_cpu_possible(i, false); | 194 | set_cpu_possible(i, false); |
194 | set_cpu_present(i, false); | 195 | set_cpu_present(i, false); |
196 | subtract++; | ||
195 | } | 197 | } |
196 | } | 198 | } |
199 | #ifdef CONFIG_HOTPLUG_CPU | ||
200 | /* This is akin to using 'nr_cpus' on the Linux command line. | ||
201 | * Which is OK as when we use 'dom0_max_vcpus=X' we can only | ||
202 | * have up to X, while nr_cpu_ids is greater than X. This | ||
203 | * normally is not a problem, except when CPU hotplugging | ||
204 | * is involved and then there might be more than X CPUs | ||
205 | * in the guest - which will not work as there is no | ||
206 | * hypercall to expand the max number of VCPUs an already | ||
207 | * running guest has. So cap it up to X. */ | ||
208 | if (subtract) | ||
209 | nr_cpu_ids = nr_cpu_ids - subtract; | ||
210 | #endif | ||
211 | |||
197 | } | 212 | } |
198 | 213 | ||
199 | static void __init xen_smp_prepare_boot_cpu(void) | 214 | static void __init xen_smp_prepare_boot_cpu(void) |
diff --git a/arch/x86/xen/xen-asm.S b/arch/x86/xen/xen-asm.S index 79d7362ad6d1..3e45aa000718 100644 --- a/arch/x86/xen/xen-asm.S +++ b/arch/x86/xen/xen-asm.S | |||
@@ -96,7 +96,7 @@ ENTRY(xen_restore_fl_direct) | |||
96 | 96 | ||
97 | /* check for unmasked and pending */ | 97 | /* check for unmasked and pending */ |
98 | cmpw $0x0001, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_pending | 98 | cmpw $0x0001, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_pending |
99 | jz 1f | 99 | jnz 1f |
100 | 2: call check_events | 100 | 2: call check_events |
101 | 1: | 101 | 1: |
102 | ENDPATCH(xen_restore_fl_direct) | 102 | ENDPATCH(xen_restore_fl_direct) |
diff --git a/arch/xtensa/include/asm/hardirq.h b/arch/xtensa/include/asm/hardirq.h index 26664cef8f11..91695a135498 100644 --- a/arch/xtensa/include/asm/hardirq.h +++ b/arch/xtensa/include/asm/hardirq.h | |||
@@ -11,9 +11,6 @@ | |||
11 | #ifndef _XTENSA_HARDIRQ_H | 11 | #ifndef _XTENSA_HARDIRQ_H |
12 | #define _XTENSA_HARDIRQ_H | 12 | #define _XTENSA_HARDIRQ_H |
13 | 13 | ||
14 | void ack_bad_irq(unsigned int irq); | ||
15 | #define ack_bad_irq ack_bad_irq | ||
16 | |||
17 | #include <asm-generic/hardirq.h> | 14 | #include <asm-generic/hardirq.h> |
18 | 15 | ||
19 | #endif /* _XTENSA_HARDIRQ_H */ | 16 | #endif /* _XTENSA_HARDIRQ_H */ |
diff --git a/arch/xtensa/include/asm/io.h b/arch/xtensa/include/asm/io.h index d04cd3a625fa..4beb43c087d3 100644 --- a/arch/xtensa/include/asm/io.h +++ b/arch/xtensa/include/asm/io.h | |||
@@ -14,6 +14,7 @@ | |||
14 | #ifdef __KERNEL__ | 14 | #ifdef __KERNEL__ |
15 | #include <asm/byteorder.h> | 15 | #include <asm/byteorder.h> |
16 | #include <asm/page.h> | 16 | #include <asm/page.h> |
17 | #include <linux/bug.h> | ||
17 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
18 | 19 | ||
19 | #include <linux/types.h> | 20 | #include <linux/types.h> |
diff --git a/arch/xtensa/kernel/signal.c b/arch/xtensa/kernel/signal.c index b69b000349fc..d78869a00b11 100644 --- a/arch/xtensa/kernel/signal.c +++ b/arch/xtensa/kernel/signal.c | |||
@@ -496,6 +496,7 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset) | |||
496 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 496 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); |
497 | 497 | ||
498 | if (signr > 0) { | 498 | if (signr > 0) { |
499 | int ret; | ||
499 | 500 | ||
500 | /* Are we from a system call? */ | 501 | /* Are we from a system call? */ |
501 | 502 | ||