2 * Freescale STMP37XX/STMP378X platform devices
4 * Embedded Alley Solutions, Inc <source@embeddedalley.com>
6 * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
7 * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
11 * The code contained herein is licensed under the GNU General Public
12 * License. You may obtain a copy of the GNU General Public License
13 * Version 2 or later at the following locations:
15 * http://www.opensource.org/licenses/gpl-license.html
16 * http://www.gnu.org/copyleft/gpl.html
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/device.h>
21 #include <linux/platform_device.h>
22 #include <linux/dma-mapping.h>
25 #include <mach/platform.h>
26 #include <mach/stmp3xxx.h>
27 #include <mach/regs-lcdif.h>
28 #include <mach/regs-uartapp.h>
29 #include <mach/regs-gpmi.h>
30 #include <mach/regs-usbctrl.h>
31 #include <mach/regs-ssp.h>
32 #include <mach/regs-rtc.h>
34 static u64 common_dmamask
= DMA_BIT_MASK(32);
36 static struct resource appuart_resources
[] = {
38 .start
= IRQ_UARTAPP_INTERNAL
,
39 .end
= IRQ_UARTAPP_INTERNAL
,
40 .flags
= IORESOURCE_IRQ
,
42 .start
= IRQ_UARTAPP_RX_DMA
,
43 .end
= IRQ_UARTAPP_RX_DMA
,
44 .flags
= IORESOURCE_IRQ
,
46 .start
= IRQ_UARTAPP_TX_DMA
,
47 .end
= IRQ_UARTAPP_TX_DMA
,
48 .flags
= IORESOURCE_IRQ
,
50 .start
= REGS_UARTAPP1_PHYS
,
51 .end
= REGS_UARTAPP1_PHYS
+ REGS_UARTAPP_SIZE
,
52 .flags
= IORESOURCE_MEM
,
55 .start
= STMP3XXX_DMA(6, STMP3XXX_BUS_APBX
),
56 .end
= STMP3XXX_DMA(6, STMP3XXX_BUS_APBX
),
57 .flags
= IORESOURCE_DMA
,
60 .start
= STMP3XXX_DMA(7, STMP3XXX_BUS_APBX
),
61 .end
= STMP3XXX_DMA(7, STMP3XXX_BUS_APBX
),
62 .flags
= IORESOURCE_DMA
,
66 struct platform_device stmp3xxx_appuart
= {
67 .name
= "stmp3xxx-appuart",
69 .resource
= appuart_resources
,
70 .num_resources
= ARRAY_SIZE(appuart_resources
),
72 .dma_mask
= &common_dmamask
,
73 .coherent_dma_mask
= DMA_BIT_MASK(32),
77 struct platform_device stmp3xxx_watchdog
= {
78 .name
= "stmp3xxx_wdt",
82 static struct resource ts_resource
[] = {
84 .flags
= IORESOURCE_IRQ
,
85 .start
= IRQ_TOUCH_DETECT
,
86 .end
= IRQ_TOUCH_DETECT
,
88 .flags
= IORESOURCE_IRQ
,
89 .start
= IRQ_LRADC_CH5
,
94 struct platform_device stmp3xxx_touchscreen
= {
95 .name
= "stmp3xxx_ts",
97 .resource
= ts_resource
,
98 .num_resources
= ARRAY_SIZE(ts_resource
),
104 struct platform_device stmp3xxx_keyboard
= {
105 .name
= "stmp3xxx-keyboard",
109 static struct resource gpmi_resources
[] = {
111 .flags
= IORESOURCE_MEM
,
112 .start
= REGS_GPMI_PHYS
,
113 .end
= REGS_GPMI_PHYS
+ REGS_GPMI_SIZE
,
115 .flags
= IORESOURCE_IRQ
,
116 .start
= IRQ_GPMI_DMA
,
119 .flags
= IORESOURCE_DMA
,
120 .start
= STMP3XXX_DMA(4, STMP3XXX_BUS_APBH
),
121 .end
= STMP3XXX_DMA(8, STMP3XXX_BUS_APBH
),
125 struct platform_device stmp3xxx_gpmi
= {
129 .dma_mask
= &common_dmamask
,
130 .coherent_dma_mask
= DMA_BIT_MASK(32),
132 .resource
= gpmi_resources
,
133 .num_resources
= ARRAY_SIZE(gpmi_resources
),
136 static struct resource mmc1_resource
[] = {
138 .flags
= IORESOURCE_MEM
,
139 .start
= REGS_SSP1_PHYS
,
140 .end
= REGS_SSP1_PHYS
+ REGS_SSP_SIZE
,
142 .flags
= IORESOURCE_DMA
,
143 .start
= STMP3XXX_DMA(1, STMP3XXX_BUS_APBH
),
144 .end
= STMP3XXX_DMA(1, STMP3XXX_BUS_APBH
),
146 .flags
= IORESOURCE_IRQ
,
147 .start
= IRQ_SSP1_DMA
,
150 .flags
= IORESOURCE_IRQ
,
151 .start
= IRQ_SSP_ERROR
,
152 .end
= IRQ_SSP_ERROR
,
156 struct platform_device stmp3xxx_mmc
= {
157 .name
= "stmp3xxx-mmc",
160 .dma_mask
= &common_dmamask
,
161 .coherent_dma_mask
= DMA_BIT_MASK(32),
163 .resource
= mmc1_resource
,
164 .num_resources
= ARRAY_SIZE(mmc1_resource
),
167 static struct resource usb_resources
[] = {
169 .start
= REGS_USBCTRL_PHYS
,
170 .end
= REGS_USBCTRL_PHYS
+ SZ_4K
,
171 .flags
= IORESOURCE_MEM
,
173 .start
= IRQ_USB_CTRL
,
175 .flags
= IORESOURCE_IRQ
,
179 struct platform_device stmp3xxx_udc
= {
180 .name
= "fsl-usb2-udc",
183 .dma_mask
= &common_dmamask
,
184 .coherent_dma_mask
= DMA_BIT_MASK(32),
186 .resource
= usb_resources
,
187 .num_resources
= ARRAY_SIZE(usb_resources
),
190 struct platform_device stmp3xxx_ehci
= {
194 .dma_mask
= &common_dmamask
,
195 .coherent_dma_mask
= DMA_BIT_MASK(32),
197 .resource
= usb_resources
,
198 .num_resources
= ARRAY_SIZE(usb_resources
),
201 static struct resource rtc_resources
[] = {
203 .start
= REGS_RTC_PHYS
,
204 .end
= REGS_RTC_PHYS
+ REGS_RTC_SIZE
,
205 .flags
= IORESOURCE_MEM
,
207 .start
= IRQ_RTC_ALARM
,
208 .end
= IRQ_RTC_ALARM
,
209 .flags
= IORESOURCE_IRQ
,
211 .start
= IRQ_RTC_1MSEC
,
212 .end
= IRQ_RTC_1MSEC
,
213 .flags
= IORESOURCE_IRQ
,
217 struct platform_device stmp3xxx_rtc
= {
218 .name
= "stmp3xxx-rtc",
220 .resource
= rtc_resources
,
221 .num_resources
= ARRAY_SIZE(rtc_resources
),
224 static struct resource ssp1_resources
[] = {
226 .start
= REGS_SSP1_PHYS
,
227 .end
= REGS_SSP1_PHYS
+ REGS_SSP_SIZE
,
228 .flags
= IORESOURCE_MEM
,
230 .start
= IRQ_SSP1_DMA
,
232 .flags
= IORESOURCE_IRQ
,
234 .start
= STMP3XXX_DMA(1, STMP3XXX_BUS_APBH
),
235 .end
= STMP3XXX_DMA(1, STMP3XXX_BUS_APBH
),
236 .flags
= IORESOURCE_DMA
,
240 static struct resource ssp2_resources
[] = {
242 .start
= REGS_SSP2_PHYS
,
243 .end
= REGS_SSP2_PHYS
+ REGS_SSP_SIZE
,
244 .flags
= IORESOURCE_MEM
,
246 .start
= IRQ_SSP2_DMA
,
248 .flags
= IORESOURCE_IRQ
,
250 .start
= STMP3XXX_DMA(2, STMP3XXX_BUS_APBH
),
251 .end
= STMP3XXX_DMA(2, STMP3XXX_BUS_APBH
),
252 .flags
= IORESOURCE_DMA
,
256 struct platform_device stmp3xxx_spi1
= {
257 .name
= "stmp3xxx_ssp",
260 .dma_mask
= &common_dmamask
,
261 .coherent_dma_mask
= DMA_BIT_MASK(32),
263 .resource
= ssp1_resources
,
264 .num_resources
= ARRAY_SIZE(ssp1_resources
),
267 struct platform_device stmp3xxx_spi2
= {
268 .name
= "stmp3xxx_ssp",
271 .dma_mask
= &common_dmamask
,
272 .coherent_dma_mask
= DMA_BIT_MASK(32),
274 .resource
= ssp2_resources
,
275 .num_resources
= ARRAY_SIZE(ssp2_resources
),
278 static struct resource fb_resource
[] = {
280 .flags
= IORESOURCE_IRQ
,
281 .start
= IRQ_LCDIF_DMA
,
282 .end
= IRQ_LCDIF_DMA
,
284 .flags
= IORESOURCE_IRQ
,
285 .start
= IRQ_LCDIF_ERROR
,
286 .end
= IRQ_LCDIF_ERROR
,
288 .flags
= IORESOURCE_MEM
,
289 .start
= REGS_LCDIF_PHYS
,
290 .end
= REGS_LCDIF_PHYS
+ REGS_LCDIF_SIZE
,
294 struct platform_device stmp3xxx_framebuffer
= {
295 .name
= "stmp3xxx-fb",
298 .dma_mask
= &common_dmamask
,
299 .coherent_dma_mask
= DMA_BIT_MASK(32),
301 .num_resources
= ARRAY_SIZE(fb_resource
),
302 .resource
= fb_resource
,
305 #define CMDLINE_DEVICE_CHOOSE(name, dev1, dev2) \
306 static char *cmdline_device_##name; \
307 static int cmdline_device_##name##_setup(char *dev) \
309 cmdline_device_##name = dev + 1; \
312 __setup(#name, cmdline_device_##name##_setup); \
313 int stmp3xxx_##name##_device_register(void) \
315 struct platform_device *d = NULL; \
316 if (!cmdline_device_##name || \
317 !strcmp(cmdline_device_##name, #dev1)) \
318 d = &stmp3xxx_##dev1; \
319 else if (!strcmp(cmdline_device_##name, #dev2)) \
320 d = &stmp3xxx_##dev2; \
322 printk(KERN_ERR"Unknown %s assignment '%s'.\n", \
323 #name, cmdline_device_##name); \
324 return d ? platform_device_register(d) : -ENOENT; \
327 CMDLINE_DEVICE_CHOOSE(ssp1
, mmc
, spi1
)
328 CMDLINE_DEVICE_CHOOSE(ssp2
, gpmi
, spi2
)
330 struct platform_device stmp3xxx_backlight
= {
331 .name
= "stmp3xxx-bl",
335 struct platform_device stmp3xxx_rotdec
= {
336 .name
= "stmp3xxx-rotdec",
340 struct platform_device stmp3xxx_persistent
= {
341 .name
= "stmp3xxx-persistent",
345 struct platform_device stmp3xxx_dcp_bootstream
= {
346 .name
= "stmp3xxx-dcpboot",
349 .dma_mask
= &common_dmamask
,
350 .coherent_dma_mask
= DMA_BIT_MASK(32),
354 static struct resource dcp_resources
[] = {
356 .start
= IRQ_DCP_VMI
,
358 .flags
= IORESOURCE_IRQ
,
362 .flags
= IORESOURCE_IRQ
,
366 struct platform_device stmp3xxx_dcp
= {
367 .name
= "stmp3xxx-dcp",
369 .resource
= dcp_resources
,
370 .num_resources
= ARRAY_SIZE(dcp_resources
),
372 .dma_mask
= &common_dmamask
,
373 .coherent_dma_mask
= DMA_BIT_MASK(32),
377 static struct resource battery_resource
[] = {
379 .flags
= IORESOURCE_IRQ
,
385 struct platform_device stmp3xxx_battery
= {
386 .name
= "stmp3xxx-battery",
387 .resource
= battery_resource
,
388 .num_resources
= ARRAY_SIZE(battery_resource
),