Commit | Line | Data |
---|---|---|
d2912cb1 | 1 | // SPDX-License-Identifier: GPL-2.0-only |
4e4fc05a | 2 | /* |
5c0dbb8f | 3 | * linux/arch/arm/mach-pxa/colibri-pxa270.c |
4e4fc05a | 4 | * |
5c0dbb8f | 5 | * Support for Toradex PXA270 based Colibri module |
4e4fc05a | 6 | * Daniel Mack <daniel@caiaq.de> |
f95bb540 | 7 | * Marek Vasut <marek.vasut@gmail.com> |
4e4fc05a DM |
8 | */ |
9 | ||
10 | #include <linux/init.h> | |
4e4fc05a | 11 | #include <linux/interrupt.h> |
6a7a5dca | 12 | #include <linux/moduleparam.h> |
4c243c85 | 13 | #include <linux/kernel.h> |
4e4fc05a DM |
14 | #include <linux/mtd/mtd.h> |
15 | #include <linux/mtd/partitions.h> | |
16 | #include <linux/mtd/physmap.h> | |
4c243c85 | 17 | #include <linux/platform_device.h> |
a927ef89 | 18 | #include <linux/regulator/machine.h> |
7cca84ab | 19 | #include <linux/ucb1400.h> |
4c243c85 | 20 | |
4e4fc05a | 21 | #include <asm/mach/arch.h> |
4e4fc05a | 22 | #include <asm/mach/flash.h> |
4c243c85 | 23 | #include <asm/mach-types.h> |
87dfb311 | 24 | #include <linux/sizes.h> |
51c62982 | 25 | |
7cca84ab | 26 | #include <mach/audio.h> |
4c25c5d2 AB |
27 | #include "colibri.h" |
28 | #include "pxa27x.h" | |
4e4fc05a | 29 | |
4e4fc05a | 30 | #include "devices.h" |
4c243c85 | 31 | #include "generic.h" |
4e4fc05a | 32 | |
9b6956f4 MV |
33 | /****************************************************************************** |
34 | * Evaluation board MFP | |
35 | ******************************************************************************/ | |
a3172e54 | 36 | #ifdef CONFIG_MACH_COLIBRI_EVALBOARD |
9b6956f4 MV |
37 | static mfp_cfg_t colibri_pxa270_evalboard_pin_config[] __initdata = { |
38 | /* MMC */ | |
39 | GPIO32_MMC_CLK, | |
40 | GPIO92_MMC_DAT_0, | |
41 | GPIO109_MMC_DAT_1, | |
42 | GPIO110_MMC_DAT_2, | |
43 | GPIO111_MMC_DAT_3, | |
44 | GPIO112_MMC_CMD, | |
45 | GPIO0_GPIO, /* SD detect */ | |
46 | ||
47 | /* FFUART */ | |
48 | GPIO39_FFUART_TXD, | |
49 | GPIO34_FFUART_RXD, | |
50 | ||
51 | /* UHC */ | |
52 | GPIO88_USBH1_PWR, | |
53 | GPIO89_USBH1_PEN, | |
54 | GPIO119_USBH2_PWR, | |
55 | GPIO120_USBH2_PEN, | |
56 | ||
57 | /* PCMCIA */ | |
58 | GPIO85_nPCE_1, | |
59 | GPIO54_nPCE_2, | |
60 | GPIO55_nPREG, | |
61 | GPIO50_nPIOR, | |
62 | GPIO51_nPIOW, | |
63 | GPIO49_nPWE, | |
64 | GPIO48_nPOE, | |
65 | GPIO57_nIOIS16, | |
66 | GPIO56_nPWAIT, | |
67 | GPIO104_PSKTSEL, | |
68 | GPIO53_GPIO, /* RESET */ | |
69 | GPIO83_GPIO, /* BVD1 */ | |
70 | GPIO82_GPIO, /* BVD2 */ | |
71 | GPIO1_GPIO, /* READY */ | |
72 | GPIO84_GPIO, /* DETECT */ | |
73 | GPIO107_GPIO, /* PPEN */ | |
072e1ae7 MV |
74 | |
75 | /* I2C */ | |
76 | GPIO117_I2C_SCL, | |
77 | GPIO118_I2C_SDA, | |
9b6956f4 MV |
78 | }; |
79 | #else | |
80 | static mfp_cfg_t colibri_pxa270_evalboard_pin_config[] __initdata = {}; | |
81 | #endif | |
82 | ||
83 | #ifdef CONFIG_MACH_COLIBRI_PXA270_INCOME | |
84 | static mfp_cfg_t income_pin_config[] __initdata = { | |
85 | /* MMC */ | |
86 | GPIO32_MMC_CLK, | |
87 | GPIO92_MMC_DAT_0, | |
88 | GPIO109_MMC_DAT_1, | |
89 | GPIO110_MMC_DAT_2, | |
90 | GPIO111_MMC_DAT_3, | |
91 | GPIO112_MMC_CMD, | |
92 | GPIO0_GPIO, /* SD detect */ | |
93 | GPIO1_GPIO, /* SD read-only */ | |
94 | ||
95 | /* FFUART */ | |
96 | GPIO39_FFUART_TXD, | |
97 | GPIO34_FFUART_RXD, | |
98 | ||
99 | /* BFUART */ | |
100 | GPIO42_BTUART_RXD, | |
101 | GPIO43_BTUART_TXD, | |
102 | GPIO45_BTUART_RTS, | |
103 | ||
104 | /* STUART */ | |
105 | GPIO46_STUART_RXD, | |
106 | GPIO47_STUART_TXD, | |
107 | ||
108 | /* UHC */ | |
109 | GPIO88_USBH1_PWR, | |
110 | GPIO89_USBH1_PEN, | |
111 | ||
112 | /* LCD */ | |
113 | GPIOxx_LCD_TFT_16BPP, | |
114 | ||
115 | /* PWM */ | |
116 | GPIO16_PWM0_OUT, | |
117 | ||
118 | /* I2C */ | |
119 | GPIO117_I2C_SCL, | |
120 | GPIO118_I2C_SDA, | |
121 | ||
122 | /* LED */ | |
123 | GPIO54_GPIO, /* LED A */ | |
124 | GPIO55_GPIO, /* LED B */ | |
125 | }; | |
126 | #else | |
127 | static mfp_cfg_t income_pin_config[] __initdata = {}; | |
128 | #endif | |
129 | ||
f95bb540 MV |
130 | /****************************************************************************** |
131 | * Pin configuration | |
132 | ******************************************************************************/ | |
5c0dbb8f | 133 | static mfp_cfg_t colibri_pxa270_pin_config[] __initdata = { |
f95bb540 | 134 | /* Ethernet */ |
c0b1541f EM |
135 | GPIO78_nCS_2, /* Ethernet CS */ |
136 | GPIO114_GPIO, /* Ethernet IRQ */ | |
d01b8d64 | 137 | |
7cca84ab MV |
138 | /* AC97 */ |
139 | GPIO28_AC97_BITCLK, | |
140 | GPIO29_AC97_SDATA_IN_0, | |
141 | GPIO30_AC97_SDATA_OUT, | |
142 | GPIO31_AC97_SYNC, | |
143 | GPIO95_AC97_nRESET, | |
144 | GPIO98_AC97_SYSCLK, | |
145 | GPIO113_GPIO, /* Touchscreen IRQ */ | |
c0b1541f EM |
146 | }; |
147 | ||
f95bb540 MV |
148 | /****************************************************************************** |
149 | * NOR Flash | |
150 | ******************************************************************************/ | |
151 | #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) | |
4e4fc05a DM |
152 | static struct mtd_partition colibri_partitions[] = { |
153 | { | |
154 | .name = "Bootloader", | |
155 | .offset = 0x00000000, | |
156 | .size = 0x00040000, | |
f95bb540 | 157 | .mask_flags = MTD_WRITEABLE /* force read-only */ |
4e4fc05a DM |
158 | }, { |
159 | .name = "Kernel", | |
160 | .offset = 0x00040000, | |
161 | .size = 0x00400000, | |
162 | .mask_flags = 0 | |
163 | }, { | |
164 | .name = "Rootfs", | |
165 | .offset = 0x00440000, | |
166 | .size = MTDPART_SIZ_FULL, | |
167 | .mask_flags = 0 | |
168 | } | |
169 | }; | |
170 | ||
171 | static struct physmap_flash_data colibri_flash_data[] = { | |
172 | { | |
173 | .width = 4, /* bankwidth in bytes */ | |
174 | .parts = colibri_partitions, | |
175 | .nr_parts = ARRAY_SIZE(colibri_partitions) | |
176 | } | |
177 | }; | |
178 | ||
5c0dbb8f | 179 | static struct resource colibri_pxa270_flash_resource = { |
4e4fc05a DM |
180 | .start = PXA_CS0_PHYS, |
181 | .end = PXA_CS0_PHYS + SZ_32M - 1, | |
182 | .flags = IORESOURCE_MEM, | |
183 | }; | |
184 | ||
5c0dbb8f | 185 | static struct platform_device colibri_pxa270_flash_device = { |
4e4fc05a DM |
186 | .name = "physmap-flash", |
187 | .id = 0, | |
188 | .dev = { | |
189 | .platform_data = colibri_flash_data, | |
190 | }, | |
5c0dbb8f | 191 | .resource = &colibri_pxa270_flash_resource, |
4e4fc05a DM |
192 | .num_resources = 1, |
193 | }; | |
194 | ||
f95bb540 MV |
195 | static void __init colibri_pxa270_nor_init(void) |
196 | { | |
197 | platform_device_register(&colibri_pxa270_flash_device); | |
198 | } | |
199 | #else | |
200 | static inline void colibri_pxa270_nor_init(void) {} | |
201 | #endif | |
202 | ||
203 | /****************************************************************************** | |
204 | * Ethernet | |
205 | ******************************************************************************/ | |
206 | #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) | |
207 | static struct resource colibri_pxa270_dm9000_resources[] = { | |
403d2971 | 208 | { |
f95bb540 MV |
209 | .start = PXA_CS2_PHYS, |
210 | .end = PXA_CS2_PHYS + 3, | |
4e4fc05a DM |
211 | .flags = IORESOURCE_MEM, |
212 | }, | |
403d2971 | 213 | { |
f95bb540 MV |
214 | .start = PXA_CS2_PHYS + 4, |
215 | .end = PXA_CS2_PHYS + 4 + 500, | |
4e4fc05a DM |
216 | .flags = IORESOURCE_MEM, |
217 | }, | |
403d2971 | 218 | { |
4929f5a8 HZ |
219 | .start = PXA_GPIO_TO_IRQ(GPIO114_COLIBRI_PXA270_ETH_IRQ), |
220 | .end = PXA_GPIO_TO_IRQ(GPIO114_COLIBRI_PXA270_ETH_IRQ), | |
d0afc85f | 221 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING, |
4e4fc05a DM |
222 | }, |
223 | }; | |
224 | ||
f95bb540 | 225 | static struct platform_device colibri_pxa270_dm9000_device = { |
4e4fc05a DM |
226 | .name = "dm9000", |
227 | .id = -1, | |
f95bb540 MV |
228 | .num_resources = ARRAY_SIZE(colibri_pxa270_dm9000_resources), |
229 | .resource = colibri_pxa270_dm9000_resources, | |
4e4fc05a DM |
230 | }; |
231 | ||
f95bb540 MV |
232 | static void __init colibri_pxa270_eth_init(void) |
233 | { | |
234 | platform_device_register(&colibri_pxa270_dm9000_device); | |
235 | } | |
236 | #else | |
237 | static inline void colibri_pxa270_eth_init(void) {} | |
5c0dbb8f | 238 | #endif |
4e4fc05a | 239 | |
7cca84ab MV |
240 | /****************************************************************************** |
241 | * Audio and Touchscreen | |
242 | ******************************************************************************/ | |
243 | #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \ | |
244 | defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE) | |
245 | static pxa2xx_audio_ops_t colibri_pxa270_ac97_pdata = { | |
246 | .reset_gpio = 95, | |
247 | }; | |
248 | ||
249 | static struct ucb1400_pdata colibri_pxa270_ucb1400_pdata = { | |
4929f5a8 | 250 | .irq = PXA_GPIO_TO_IRQ(GPIO113_COLIBRI_PXA270_TS_IRQ), |
7cca84ab MV |
251 | }; |
252 | ||
253 | static struct platform_device colibri_pxa270_ucb1400_device = { | |
254 | .name = "ucb1400_core", | |
255 | .id = -1, | |
256 | .dev = { | |
257 | .platform_data = &colibri_pxa270_ucb1400_pdata, | |
258 | }, | |
259 | }; | |
260 | ||
261 | static void __init colibri_pxa270_tsc_init(void) | |
262 | { | |
263 | pxa_set_ac97_info(&colibri_pxa270_ac97_pdata); | |
264 | platform_device_register(&colibri_pxa270_ucb1400_device); | |
265 | } | |
266 | #else | |
267 | static inline void colibri_pxa270_tsc_init(void) {} | |
268 | #endif | |
269 | ||
4c243c85 DM |
270 | static int colibri_pxa270_baseboard; |
271 | core_param(colibri_pxa270_baseboard, colibri_pxa270_baseboard, int, 0444); | |
272 | ||
5c0dbb8f | 273 | static void __init colibri_pxa270_init(void) |
4e4fc05a | 274 | { |
5c0dbb8f | 275 | pxa2xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa270_pin_config)); |
f95bb540 MV |
276 | |
277 | colibri_pxa270_nor_init(); | |
278 | colibri_pxa270_eth_init(); | |
7cca84ab | 279 | colibri_pxa270_tsc_init(); |
4c243c85 DM |
280 | |
281 | switch (colibri_pxa270_baseboard) { | |
a3172e54 | 282 | case COLIBRI_EVALBOARD: |
9b6956f4 MV |
283 | pxa2xx_mfp_config(ARRAY_AND_SIZE( |
284 | colibri_pxa270_evalboard_pin_config)); | |
a3172e54 | 285 | colibri_evalboard_init(); |
4c243c85 | 286 | break; |
403d2971 | 287 | case COLIBRI_PXA270_INCOME: |
9b6956f4 | 288 | pxa2xx_mfp_config(ARRAY_AND_SIZE(income_pin_config)); |
403d2971 MV |
289 | colibri_pxa270_income_boardinit(); |
290 | break; | |
4c243c85 DM |
291 | default: |
292 | printk(KERN_ERR "Illegal colibri_pxa270_baseboard type %d\n", | |
293 | colibri_pxa270_baseboard); | |
294 | } | |
a927ef89 RJ |
295 | |
296 | regulator_has_full_constraints(); | |
4e4fc05a DM |
297 | } |
298 | ||
403d2971 MV |
299 | /* The "Income s.r.o. SH-Dmaster PXA270 SBC" board can be booted either |
300 | * with the INCOME mach type or with COLIBRI and the kernel parameter | |
301 | * "colibri_pxa270_baseboard=1" | |
302 | */ | |
303 | static void __init colibri_pxa270_income_init(void) | |
304 | { | |
305 | colibri_pxa270_baseboard = COLIBRI_PXA270_INCOME; | |
306 | colibri_pxa270_init(); | |
307 | } | |
308 | ||
5c0dbb8f | 309 | MACHINE_START(COLIBRI, "Toradex Colibri PXA270") |
7375aba6 | 310 | .atag_offset = 0x100, |
5c0dbb8f | 311 | .init_machine = colibri_pxa270_init, |
851982c1 | 312 | .map_io = pxa27x_map_io, |
4e611091 | 313 | .nr_irqs = PXA_NR_IRQS, |
4e4fc05a | 314 | .init_irq = pxa27x_init_irq, |
8a97ae2f | 315 | .handle_irq = pxa27x_handle_irq, |
6bb27d73 | 316 | .init_time = pxa_timer_init, |
271a74fc | 317 | .restart = pxa_restart, |
4e4fc05a | 318 | MACHINE_END |
5c0dbb8f | 319 | |
403d2971 | 320 | MACHINE_START(INCOME, "Income s.r.o. SH-Dmaster PXA270 SBC") |
7375aba6 | 321 | .atag_offset = 0x100, |
403d2971 | 322 | .init_machine = colibri_pxa270_income_init, |
851982c1 | 323 | .map_io = pxa27x_map_io, |
4e611091 | 324 | .nr_irqs = PXA_NR_IRQS, |
403d2971 | 325 | .init_irq = pxa27x_init_irq, |
8a97ae2f | 326 | .handle_irq = pxa27x_handle_irq, |
6bb27d73 | 327 | .init_time = pxa_timer_init, |
271a74fc | 328 | .restart = pxa_restart, |
403d2971 MV |
329 | MACHINE_END |
330 |