2 * Copyright (C) 2009-2010, Lars-Peter Clausen <lars@metafoo.de>
3 * JZ4740 platform devices
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
10 * You should have received a copy of the GNU General Public License along
11 * with this program; if not, write to the Free Software Foundation, Inc.,
12 * 675 Mass Ave, Cambridge, MA 02139, USA.
16 #include <linux/device.h>
17 #include <linux/kernel.h>
18 #include <linux/platform_device.h>
19 #include <linux/resource.h>
21 #include <linux/dma-mapping.h>
23 #include <linux/usb/musb.h>
25 #include <asm/mach-jz4740/platform.h>
26 #include <asm/mach-jz4740/base.h>
27 #include <asm/mach-jz4740/irq.h>
29 #include <linux/serial_core.h>
30 #include <linux/serial_8250.h>
36 static struct resource jz4740_usb_ohci_resources
[] = {
38 .start
= JZ4740_UHC_BASE_ADDR
,
39 .end
= JZ4740_UHC_BASE_ADDR
+ 0x1000 - 1,
40 .flags
= IORESOURCE_MEM
,
43 .start
= JZ4740_IRQ_UHC
,
44 .end
= JZ4740_IRQ_UHC
,
45 .flags
= IORESOURCE_IRQ
,
49 struct platform_device jz4740_usb_ohci_device
= {
50 .name
= "jz4740-ohci",
53 .dma_mask
= &jz4740_usb_ohci_device
.dev
.coherent_dma_mask
,
54 .coherent_dma_mask
= DMA_BIT_MASK(32),
56 .num_resources
= ARRAY_SIZE(jz4740_usb_ohci_resources
),
57 .resource
= jz4740_usb_ohci_resources
,
60 /* USB Device Controller */
61 struct platform_device jz4740_udc_xceiv_device
= {
62 .name
= "usb_phy_generic",
66 static struct resource jz4740_udc_resources
[] = {
68 .start
= JZ4740_UDC_BASE_ADDR
,
69 .end
= JZ4740_UDC_BASE_ADDR
+ 0x10000 - 1,
70 .flags
= IORESOURCE_MEM
,
73 .start
= JZ4740_IRQ_UDC
,
74 .end
= JZ4740_IRQ_UDC
,
75 .flags
= IORESOURCE_IRQ
,
80 struct platform_device jz4740_udc_device
= {
81 .name
= "musb-jz4740",
84 .dma_mask
= &jz4740_udc_device
.dev
.coherent_dma_mask
,
85 .coherent_dma_mask
= DMA_BIT_MASK(32),
87 .num_resources
= ARRAY_SIZE(jz4740_udc_resources
),
88 .resource
= jz4740_udc_resources
,
91 /* MMC/SD controller */
92 static struct resource jz4740_mmc_resources
[] = {
94 .start
= JZ4740_MSC_BASE_ADDR
,
95 .end
= JZ4740_MSC_BASE_ADDR
+ 0x1000 - 1,
96 .flags
= IORESOURCE_MEM
,
99 .start
= JZ4740_IRQ_MSC
,
100 .end
= JZ4740_IRQ_MSC
,
101 .flags
= IORESOURCE_IRQ
,
105 struct platform_device jz4740_mmc_device
= {
106 .name
= "jz4740-mmc",
109 .dma_mask
= &jz4740_mmc_device
.dev
.coherent_dma_mask
,
110 .coherent_dma_mask
= DMA_BIT_MASK(32),
112 .num_resources
= ARRAY_SIZE(jz4740_mmc_resources
),
113 .resource
= jz4740_mmc_resources
,
117 static struct resource jz4740_rtc_resources
[] = {
119 .start
= JZ4740_RTC_BASE_ADDR
,
120 .end
= JZ4740_RTC_BASE_ADDR
+ 0x38 - 1,
121 .flags
= IORESOURCE_MEM
,
124 .start
= JZ4740_IRQ_RTC
,
125 .end
= JZ4740_IRQ_RTC
,
126 .flags
= IORESOURCE_IRQ
,
130 struct platform_device jz4740_rtc_device
= {
131 .name
= "jz4740-rtc",
133 .num_resources
= ARRAY_SIZE(jz4740_rtc_resources
),
134 .resource
= jz4740_rtc_resources
,
138 static struct resource jz4740_i2c_resources
[] = {
140 .start
= JZ4740_I2C_BASE_ADDR
,
141 .end
= JZ4740_I2C_BASE_ADDR
+ 0x1000 - 1,
142 .flags
= IORESOURCE_MEM
,
145 .start
= JZ4740_IRQ_I2C
,
146 .end
= JZ4740_IRQ_I2C
,
147 .flags
= IORESOURCE_IRQ
,
151 struct platform_device jz4740_i2c_device
= {
152 .name
= "jz4740-i2c",
154 .num_resources
= ARRAY_SIZE(jz4740_i2c_resources
),
155 .resource
= jz4740_i2c_resources
,
158 /* NAND controller */
159 static struct resource jz4740_nand_resources
[] = {
162 .start
= JZ4740_EMC_BASE_ADDR
,
163 .end
= JZ4740_EMC_BASE_ADDR
+ 0x1000 - 1,
164 .flags
= IORESOURCE_MEM
,
169 .end
= 0x180C0000 - 1,
170 .flags
= IORESOURCE_MEM
,
175 .end
= 0x140C0000 - 1,
176 .flags
= IORESOURCE_MEM
,
181 .end
= 0x0C0C0000 - 1,
182 .flags
= IORESOURCE_MEM
,
187 .end
= 0x080C0000 - 1,
188 .flags
= IORESOURCE_MEM
,
192 struct platform_device jz4740_nand_device
= {
193 .name
= "jz4740-nand",
194 .num_resources
= ARRAY_SIZE(jz4740_nand_resources
),
195 .resource
= jz4740_nand_resources
,
199 static struct resource jz4740_framebuffer_resources
[] = {
201 .start
= JZ4740_LCD_BASE_ADDR
,
202 .end
= JZ4740_LCD_BASE_ADDR
+ 0x1000 - 1,
203 .flags
= IORESOURCE_MEM
,
207 struct platform_device jz4740_framebuffer_device
= {
210 .num_resources
= ARRAY_SIZE(jz4740_framebuffer_resources
),
211 .resource
= jz4740_framebuffer_resources
,
213 .dma_mask
= &jz4740_framebuffer_device
.dev
.coherent_dma_mask
,
214 .coherent_dma_mask
= DMA_BIT_MASK(32),
219 static struct resource jz4740_i2s_resources
[] = {
221 .start
= JZ4740_AIC_BASE_ADDR
,
222 .end
= JZ4740_AIC_BASE_ADDR
+ 0x38 - 1,
223 .flags
= IORESOURCE_MEM
,
227 struct platform_device jz4740_i2s_device
= {
228 .name
= "jz4740-i2s",
230 .num_resources
= ARRAY_SIZE(jz4740_i2s_resources
),
231 .resource
= jz4740_i2s_resources
,
235 struct platform_device jz4740_pcm_device
= {
236 .name
= "jz4740-pcm-audio",
241 static struct resource jz4740_codec_resources
[] = {
243 .start
= JZ4740_AIC_BASE_ADDR
+ 0x80,
244 .end
= JZ4740_AIC_BASE_ADDR
+ 0x88 - 1,
245 .flags
= IORESOURCE_MEM
,
249 struct platform_device jz4740_codec_device
= {
250 .name
= "jz4740-codec",
252 .num_resources
= ARRAY_SIZE(jz4740_codec_resources
),
253 .resource
= jz4740_codec_resources
,
257 static struct resource jz4740_adc_resources
[] = {
259 .start
= JZ4740_SADC_BASE_ADDR
,
260 .end
= JZ4740_SADC_BASE_ADDR
+ 0x30,
261 .flags
= IORESOURCE_MEM
,
264 .start
= JZ4740_IRQ_SADC
,
265 .end
= JZ4740_IRQ_SADC
,
266 .flags
= IORESOURCE_IRQ
,
269 .start
= JZ4740_IRQ_ADC_BASE
,
270 .end
= JZ4740_IRQ_ADC_BASE
,
271 .flags
= IORESOURCE_IRQ
,
275 struct platform_device jz4740_adc_device
= {
276 .name
= "jz4740-adc",
278 .num_resources
= ARRAY_SIZE(jz4740_adc_resources
),
279 .resource
= jz4740_adc_resources
,
283 #define JZ4740_UART_DATA(_id) \
285 .flags = UPF_SKIP_TEST | UPF_IOREMAP | UPF_FIXED_TYPE, \
286 .iotype = UPIO_MEM, \
288 .serial_out = jz4740_serial_out, \
289 .type = PORT_16550, \
290 .mapbase = JZ4740_UART ## _id ## _BASE_ADDR, \
291 .irq = JZ4740_IRQ_UART ## _id, \
294 static struct plat_serial8250_port jz4740_uart_data
[] = {
300 static struct platform_device jz4740_uart_device
= {
301 .name
= "serial8250",
304 .platform_data
= jz4740_uart_data
,
308 void jz4740_serial_device_register(void)
310 struct plat_serial8250_port
*p
;
312 for (p
= jz4740_uart_data
; p
->flags
!= 0; ++p
)
313 p
->uartclk
= jz4740_clock_bdata
.ext_rate
;
315 platform_device_register(&jz4740_uart_device
);
319 static struct resource jz4740_wdt_resources
[] = {
321 .start
= JZ4740_WDT_BASE_ADDR
,
322 .end
= JZ4740_WDT_BASE_ADDR
+ 0x10 - 1,
323 .flags
= IORESOURCE_MEM
,
327 struct platform_device jz4740_wdt_device
= {
328 .name
= "jz4740-wdt",
330 .num_resources
= ARRAY_SIZE(jz4740_wdt_resources
),
331 .resource
= jz4740_wdt_resources
,
335 struct platform_device jz4740_pwm_device
= {
336 .name
= "jz4740-pwm",
341 static struct resource jz4740_dma_resources
[] = {
343 .start
= JZ4740_DMAC_BASE_ADDR
,
344 .end
= JZ4740_DMAC_BASE_ADDR
+ 0x400 - 1,
345 .flags
= IORESOURCE_MEM
,
348 .start
= JZ4740_IRQ_DMAC
,
349 .end
= JZ4740_IRQ_DMAC
,
350 .flags
= IORESOURCE_IRQ
,
354 struct platform_device jz4740_dma_device
= {
355 .name
= "jz4740-dma",
357 .num_resources
= ARRAY_SIZE(jz4740_dma_resources
),
358 .resource
= jz4740_dma_resources
,