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/init.h>
18 #include <linux/kernel.h>
19 #include <linux/platform_device.h>
20 #include <linux/resource.h>
22 #include <linux/dma-mapping.h>
24 #include <asm/mach-jz4740/platform.h>
25 #include <asm/mach-jz4740/base.h>
26 #include <asm/mach-jz4740/irq.h>
28 #include <linux/serial_core.h>
29 #include <linux/serial_8250.h>
35 static struct resource jz4740_usb_ohci_resources
[] = {
37 .start
= JZ4740_UHC_BASE_ADDR
,
38 .end
= JZ4740_UHC_BASE_ADDR
+ 0x1000 - 1,
39 .flags
= IORESOURCE_MEM
,
42 .start
= JZ4740_IRQ_UHC
,
43 .end
= JZ4740_IRQ_UHC
,
44 .flags
= IORESOURCE_IRQ
,
48 struct platform_device jz4740_usb_ohci_device
= {
49 .name
= "jz4740-ohci",
52 .dma_mask
= &jz4740_usb_ohci_device
.dev
.coherent_dma_mask
,
53 .coherent_dma_mask
= DMA_BIT_MASK(32),
55 .num_resources
= ARRAY_SIZE(jz4740_usb_ohci_resources
),
56 .resource
= jz4740_usb_ohci_resources
,
59 /* UDC (USB gadget controller) */
60 static struct resource jz4740_usb_gdt_resources
[] = {
62 .start
= JZ4740_UDC_BASE_ADDR
,
63 .end
= JZ4740_UDC_BASE_ADDR
+ 0x1000 - 1,
64 .flags
= IORESOURCE_MEM
,
67 .start
= JZ4740_IRQ_UDC
,
68 .end
= JZ4740_IRQ_UDC
,
69 .flags
= IORESOURCE_IRQ
,
73 struct platform_device jz4740_udc_device
= {
77 .dma_mask
= &jz4740_udc_device
.dev
.coherent_dma_mask
,
78 .coherent_dma_mask
= DMA_BIT_MASK(32),
80 .num_resources
= ARRAY_SIZE(jz4740_usb_gdt_resources
),
81 .resource
= jz4740_usb_gdt_resources
,
84 /* MMC/SD controller */
85 static struct resource jz4740_mmc_resources
[] = {
87 .start
= JZ4740_MSC_BASE_ADDR
,
88 .end
= JZ4740_MSC_BASE_ADDR
+ 0x1000 - 1,
89 .flags
= IORESOURCE_MEM
,
92 .start
= JZ4740_IRQ_MSC
,
93 .end
= JZ4740_IRQ_MSC
,
94 .flags
= IORESOURCE_IRQ
,
98 struct platform_device jz4740_mmc_device
= {
102 .dma_mask
= &jz4740_mmc_device
.dev
.coherent_dma_mask
,
103 .coherent_dma_mask
= DMA_BIT_MASK(32),
105 .num_resources
= ARRAY_SIZE(jz4740_mmc_resources
),
106 .resource
= jz4740_mmc_resources
,
110 static struct resource jz4740_rtc_resources
[] = {
112 .start
= JZ4740_RTC_BASE_ADDR
,
113 .end
= JZ4740_RTC_BASE_ADDR
+ 0x38 - 1,
114 .flags
= IORESOURCE_MEM
,
117 .start
= JZ4740_IRQ_RTC
,
118 .end
= JZ4740_IRQ_RTC
,
119 .flags
= IORESOURCE_IRQ
,
123 struct platform_device jz4740_rtc_device
= {
124 .name
= "jz4740-rtc",
126 .num_resources
= ARRAY_SIZE(jz4740_rtc_resources
),
127 .resource
= jz4740_rtc_resources
,
131 static struct resource jz4740_i2c_resources
[] = {
133 .start
= JZ4740_I2C_BASE_ADDR
,
134 .end
= JZ4740_I2C_BASE_ADDR
+ 0x1000 - 1,
135 .flags
= IORESOURCE_MEM
,
138 .start
= JZ4740_IRQ_I2C
,
139 .end
= JZ4740_IRQ_I2C
,
140 .flags
= IORESOURCE_IRQ
,
144 struct platform_device jz4740_i2c_device
= {
145 .name
= "jz4740-i2c",
147 .num_resources
= ARRAY_SIZE(jz4740_i2c_resources
),
148 .resource
= jz4740_i2c_resources
,
151 /* NAND controller */
152 static struct resource jz4740_nand_resources
[] = {
155 .start
= JZ4740_EMC_BASE_ADDR
,
156 .end
= JZ4740_EMC_BASE_ADDR
+ 0x1000 - 1,
157 .flags
= IORESOURCE_MEM
,
162 .end
= 0x180C0000 - 1,
163 .flags
= IORESOURCE_MEM
,
167 struct platform_device jz4740_nand_device
= {
168 .name
= "jz4740-nand",
169 .num_resources
= ARRAY_SIZE(jz4740_nand_resources
),
170 .resource
= jz4740_nand_resources
,
174 static struct resource jz4740_framebuffer_resources
[] = {
176 .start
= JZ4740_LCD_BASE_ADDR
,
177 .end
= JZ4740_LCD_BASE_ADDR
+ 0x1000 - 1,
178 .flags
= IORESOURCE_MEM
,
182 struct platform_device jz4740_framebuffer_device
= {
185 .num_resources
= ARRAY_SIZE(jz4740_framebuffer_resources
),
186 .resource
= jz4740_framebuffer_resources
,
188 .dma_mask
= &jz4740_framebuffer_device
.dev
.coherent_dma_mask
,
189 .coherent_dma_mask
= DMA_BIT_MASK(32),
194 static struct resource jz4740_i2s_resources
[] = {
196 .start
= JZ4740_AIC_BASE_ADDR
,
197 .end
= JZ4740_AIC_BASE_ADDR
+ 0x38 - 1,
198 .flags
= IORESOURCE_MEM
,
202 struct platform_device jz4740_i2s_device
= {
203 .name
= "jz4740-i2s",
205 .num_resources
= ARRAY_SIZE(jz4740_i2s_resources
),
206 .resource
= jz4740_i2s_resources
,
210 struct platform_device jz4740_pcm_device
= {
211 .name
= "jz4740-pcm-audio",
216 static struct resource jz4740_codec_resources
[] = {
218 .start
= JZ4740_AIC_BASE_ADDR
+ 0x80,
219 .end
= JZ4740_AIC_BASE_ADDR
+ 0x88 - 1,
220 .flags
= IORESOURCE_MEM
,
224 struct platform_device jz4740_codec_device
= {
225 .name
= "jz4740-codec",
227 .num_resources
= ARRAY_SIZE(jz4740_codec_resources
),
228 .resource
= jz4740_codec_resources
,
232 static struct resource jz4740_adc_resources
[] = {
234 .start
= JZ4740_SADC_BASE_ADDR
,
235 .end
= JZ4740_SADC_BASE_ADDR
+ 0x30,
236 .flags
= IORESOURCE_MEM
,
239 .start
= JZ4740_IRQ_SADC
,
240 .end
= JZ4740_IRQ_SADC
,
241 .flags
= IORESOURCE_IRQ
,
244 .start
= JZ4740_IRQ_ADC_BASE
,
245 .end
= JZ4740_IRQ_ADC_BASE
,
246 .flags
= IORESOURCE_IRQ
,
250 struct platform_device jz4740_adc_device
= {
251 .name
= "jz4740-adc",
253 .num_resources
= ARRAY_SIZE(jz4740_adc_resources
),
254 .resource
= jz4740_adc_resources
,
258 #define JZ4740_UART_DATA(_id) \
260 .flags = UPF_SKIP_TEST | UPF_IOREMAP | UPF_FIXED_TYPE, \
261 .iotype = UPIO_MEM, \
263 .serial_out = jz4740_serial_out, \
264 .type = PORT_16550, \
265 .mapbase = JZ4740_UART ## _id ## _BASE_ADDR, \
266 .irq = JZ4740_IRQ_UART ## _id, \
269 static struct plat_serial8250_port jz4740_uart_data
[] = {
275 static struct platform_device jz4740_uart_device
= {
276 .name
= "serial8250",
279 .platform_data
= jz4740_uart_data
,
283 void jz4740_serial_device_register(void)
285 struct plat_serial8250_port
*p
;
287 for (p
= jz4740_uart_data
; p
->flags
!= 0; ++p
)
288 p
->uartclk
= jz4740_clock_bdata
.ext_rate
;
290 platform_device_register(&jz4740_uart_device
);