1 /* arch/arm/mach-rk2818/devices.c
3 * Copyright (C) 2010 ROCKCHIP, Inc.
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
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.
17 #include <linux/kernel.h>
18 #include <linux/platform_device.h>
19 #include <linux/android_pmem.h>
20 #include <linux/usb/android_composite.h>
22 #include <mach/irqs.h>
23 #include <mach/rk2818_iomap.h>
26 #include <asm/mach/flash.h>
27 #include <linux/mtd/nand.h>
28 #include <linux/mtd/partitions.h>
30 #include <linux/dm9000.h>
31 #include <mach/gpio.h>
32 #include <mach/rk2818_nand.h>
33 static struct resource resources_sdmmc0[] = {
35 .start = IRQ_NR_SDMMC0,
37 .flags = IORESOURCE_IRQ,
40 .start = RK2818_SDMMC0_PHYS,
41 .end = RK2818_SDMMC0_PHYS + SZ_8K -1,
42 .flags = IORESOURCE_MEM,
45 static struct resource resources_sdmmc1[] = {
47 .start = IRQ_NR_SDMMC1,
49 .flags = IORESOURCE_IRQ,
52 .start = RK2818_SDMMC1_PHYS,
53 .end = RK2818_SDMMC1_PHYS + SZ_8K -1,
54 .flags = IORESOURCE_MEM,
59 static struct resource resources_i2c0[] = {
63 .flags = IORESOURCE_IRQ,
66 .start = RK2818_I2C0_PHYS,
67 .end = RK2818_I2C0_PHYS + SZ_4K - 1,
68 .flags = IORESOURCE_MEM,
71 static struct resource resources_i2c1[] = {
75 .flags = IORESOURCE_IRQ,
78 .start = RK2818_I2C1_PHYS,
79 .end = RK2818_I2C1_PHYS + SZ_4K - 1,
80 .flags = IORESOURCE_MEM,
84 * rk2818 4 uarts device
86 static struct resource resources_uart0[] = {
88 .start = IRQ_NR_UART0,
90 .flags = IORESOURCE_IRQ,
93 .start = RK2818_UART0_PHYS,
94 .end = RK2818_UART0_PHYS + SZ_1K - 1,
95 .flags = IORESOURCE_MEM,
98 static struct resource resources_uart1[] = {
100 .start = IRQ_NR_UART1,
102 .flags = IORESOURCE_IRQ,
105 .start = RK2818_UART1_PHYS,
106 .end = RK2818_UART1_PHYS + SZ_1K - 1,
107 .flags = IORESOURCE_MEM,
110 static struct resource resources_uart2[] = {
112 .start = IRQ_NR_UART2,
114 .flags = IORESOURCE_IRQ,
117 .start = RK2818_UART2_PHYS,
118 .end = RK2818_UART2_PHYS + SZ_1K - 1,
119 .flags = IORESOURCE_MEM,
122 static struct resource resources_uart3[] = {
124 .start = IRQ_NR_UART3,
126 .flags = IORESOURCE_IRQ,
129 .start = RK2818_UART3_PHYS,
130 .end = RK2818_UART3_PHYS + SZ_1K - 1,
131 .flags = IORESOURCE_MEM,
135 struct platform_device rk2818_device_sdmmc0 = {
136 .name = "rk2818_sdmmc",
138 .num_resources = ARRAY_SIZE(resources_sdmmc0),
139 .resource = resources_sdmmc0,
141 .platform_data = &default_sdmmc0_data,
144 struct platform_device rk2818_device_sdmmc1 = {
145 .name = "rk2818_sdmmc",
147 .num_resources = ARRAY_SIZE(resources_sdmmc1),
148 .resource = resources_sdmmc1,
150 .platform_data = &default_sdmmc1_data,
154 struct platform_device rk2818_device_i2c0 = {
155 .name = "rk2818_i2c",
157 .num_resources = ARRAY_SIZE(resources_i2c0),
158 .resource = resources_i2c0,
160 .platform_data = &default_i2c0_data,
163 struct platform_device rk2818_device_i2c1 = {
164 .name = "rk2818_i2c",
166 .num_resources = ARRAY_SIZE(resources_i2c1),
167 .resource = resources_i2c1,
169 .platform_data = &default_i2c1_data,
172 struct platform_device rk2818_device_i2c2 = {
176 .platform_data = &default_i2c2_data,
179 struct platform_device rk2818_device_i2c3 = {
183 .platform_data = &default_i2c3_data,
186 struct platform_device rk2818_device_uart0 = {
187 .name = "rk2818_serial",
189 .num_resources = ARRAY_SIZE(resources_uart0),
190 .resource = resources_uart0,
192 struct platform_device rk2818_device_uart1 = {
193 .name = "rk2818_serial",
195 .num_resources = ARRAY_SIZE(resources_uart1),
196 .resource = resources_uart1,
198 struct platform_device rk2818_device_uart2 = {
199 .name = "rk2818_serial",
201 .num_resources = ARRAY_SIZE(resources_uart2),
202 .resource = resources_uart2,
204 struct platform_device rk2818_device_uart3 = {
205 .name = "rk2818_serial",
207 .num_resources = ARRAY_SIZE(resources_uart3),
208 .resource = resources_uart3,
212 * rk2818 spi master device
214 static struct resource resources_spim[] = {
216 .start = IRQ_NR_SPIM,
218 .flags = IORESOURCE_IRQ,
221 .start = RK2818_SPIMASTER_PHYS,
222 .end = RK2818_SPIMASTER_PHYS + SZ_4K - 1,
223 .flags = IORESOURCE_MEM,
226 struct platform_device rk2818_device_spim = {
227 .name = "rk2818_spim",
229 .num_resources = ARRAY_SIZE(resources_spim),
230 .resource = resources_spim,
233 /* rk2818 fb resource */
234 static struct resource rk2818_fb_resource[] = {
236 .start = RK2818_LCDC_PHYS,
237 .end = RK2818_LCDC_PHYS + RK2818_LCDC_SIZE - 1,
238 .flags = IORESOURCE_MEM,
241 .start = IRQ_NR_LCDC,
243 .flags = IORESOURCE_IRQ,
248 extern struct rk2818_fb_mach_info rk2818_fb_mach_info;
250 struct platform_device rk2818_device_fb = {
253 .num_resources = ARRAY_SIZE(rk2818_fb_resource),
254 .resource = rk2818_fb_resource,
256 .platform_data = &rk2818_fb_mach_info,
260 /***********************************************************
262 * author :nzy zhongyw
264 ***************************************************************/
265 extern struct rk2818bl_info rk2818_bl_info;
267 struct platform_device rk2818_device_backlight = {
268 .name = "rk2818_backlight",
271 .platform_data = &rk2818_bl_info,
278 static struct resource dm9k_resource[] = {
280 .start = RK2818_NANDC_PHYS + 0x800 + (1*0x100 + 0x8), //nand_cs1+nand_cmd
281 .end = RK2818_NANDC_PHYS + 0x800 + (1*0x100 + 0x8) + 3,
282 .flags = IORESOURCE_MEM,
285 .start = RK2818_NANDC_PHYS + 0x800 + (1*0x100 + 0x4), //nand_cs1+nand_data
286 .end = RK2818_NANDC_PHYS + 0x800 + (1*0x100 + 0x4) + 3,
287 .flags = IORESOURCE_MEM,
290 .start = RK2818_PIN_PE2, //use pe2 as interrupt
291 .end = RK2818_PIN_PE2,
292 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
297 /* for the moment we limit ourselves to 8bit IO until some
298 * better IO routines can be written and tested
301 static struct dm9000_plat_data dm9k_platdata = {
302 .flags = DM9000_PLATF_8BITONLY,
305 struct platform_device rk2818_device_dm9k = {
308 .num_resources = ARRAY_SIZE(dm9k_resource),
309 .resource = dm9k_resource,
311 .platform_data = &dm9k_platdata,
317 static struct resource rk2818_adc_resource[] = {
321 .flags = IORESOURCE_IRQ,
324 .start = RK2818_ADC_PHYS,
325 .end = RK2818_ADC_PHYS + RK2818_ADC_SIZE - 1,
326 .flags = IORESOURCE_MEM,
331 struct platform_device rk2818_device_adc = {
332 .name = "rk2818-adc",
334 .num_resources = ARRAY_SIZE(rk2818_adc_resource),
335 .resource = rk2818_adc_resource,
339 struct platform_device rk2818_device_adckey = {
340 .name = "rk2818-adckey",
342 .dev.parent = &rk2818_device_adc.dev,
347 static struct resource resources_i2s[] = {
351 .flags = IORESOURCE_IRQ,
354 .start = RK2818_I2S_PHYS,
355 .end = RK2818_I2S_PHYS + SZ_8K - 1,
356 .flags = IORESOURCE_MEM,
359 struct platform_device rk2818_device_i2s = {
360 .name = "rk2818_i2s",
362 .num_resources = ARRAY_SIZE(resources_i2s),
363 .resource = resources_i2s,
366 struct platform_device rk2818_device_battery = {
367 .name = "rk2818-battery",
374 static struct resource resources_dsp[] = {
376 .start = RK2818_DSP_PHYS,
377 .end = RK2818_DSP_PHYS + 0x5fffff,
378 .flags = IORESOURCE_DMA,
381 .start = IRQ_NR_PIUCMD,
382 .end = IRQ_NR_PIUCMD,
383 .flags = IORESOURCE_IRQ,
386 .start = IRQ_NR_DSPSWI,
387 .end = IRQ_NR_DSPSWI,
388 .flags = IORESOURCE_IRQ,
391 static u64 rk2818_device_dsp_dmamask = 0xffffffffUL;
392 struct platform_device rk2818_device_dsp = {
395 .num_resources = ARRAY_SIZE(resources_dsp),
396 .resource = resources_dsp,
398 .dma_mask = &rk2818_device_dsp_dmamask,
399 .coherent_dma_mask = 0xffffffffUL
405 #if defined(CONFIG_ANDROID_PMEM)
407 static struct android_pmem_platform_data pmem_pdata = {
415 static struct android_pmem_platform_data pmem_pdata_dsp = {
423 struct platform_device rk2818_device_pmem = {
424 .name = "android_pmem",
426 .dev = { .platform_data = &pmem_pdata },
429 struct platform_device rk2818_device_pmem_dsp = {
430 .name = "android_pmem",
432 .dev = { .platform_data = &pmem_pdata_dsp },
436 #if defined(CONFIG_MTD_NAND_RK2818)
437 static struct resource nand_resources[] = {
439 .start = RK2818_NANDC_PHYS,
440 .end = RK2818_NANDC_PHYS+RK2818_NANDC_SIZE -1,
441 .flags = IORESOURCE_MEM,
444 static struct rk2818_nand_platform_data rk2818_nand_data = {
445 .width = 1, /* data bus width in bytes */
446 .hw_ecc = 1, /* hw ecc 0: soft ecc */
449 struct platform_device rk2818_nand_device = {
450 .name = "rk2818-nand",
452 .resource = nand_resources,
453 .num_resources= ARRAY_SIZE(nand_resources),
455 .platform_data= &rk2818_nand_data,
462 static struct resource dwc_otg_resource[] = {
466 .flags = IORESOURCE_IRQ,
469 .start = RK2818_USBOTG_PHYS,
470 .end = RK2818_USBOTG_PHYS + RK2818_USBOTG_SIZE - 1,
471 .flags = IORESOURCE_MEM,
476 struct platform_device rk2818_device_dwc_otg = {
479 .num_resources = ARRAY_SIZE(dwc_otg_resource),
480 .resource = dwc_otg_resource,
482 #ifdef CONFIG_RK2818_HOST11
483 static struct resource rk2818_host11_resource[] = {
485 .start = IRQ_NR_USB_HOST,
486 .end = IRQ_NR_USB_HOST,
487 .flags = IORESOURCE_IRQ,
490 .start = RK2818_USBHOST_PHYS,
491 .end = RK2818_USBHOST_PHYS + RK2818_USBHOST_SIZE - 1,
492 .flags = IORESOURCE_MEM,
497 struct platform_device rk2818_device_host11 = {
498 .name = "rk2818_host11",
500 .num_resources = ARRAY_SIZE(rk2818_host11_resource),
501 .resource = rk2818_host11_resource,
504 static char *usb_functions_rockchip[] = {
508 static char *usb_functions_rockchip_adb[] = {
513 static char *usb_functions_rndis_rockchip[] = {
518 static char *usb_functions_rndis_rockchip_adb[] = {
524 #ifdef CONFIG_USB_ANDROID_DIAG
525 static char *usb_functions_adb_diag[] = {
532 static char *usb_functions_all[] = {
533 #ifdef CONFIG_USB_ANDROID_RNDIS
537 #ifdef CONFIG_USB_ANDROID_ADB
540 #ifdef CONFIG_USB_ANDROID_ACM
543 #ifdef CONFIG_USB_ANDROID_DIAG
548 static struct android_usb_product usb_products[] = {
550 .product_id = 0x2810,//0x0c02,//0x4e11,
551 .num_functions = ARRAY_SIZE(usb_functions_rockchip),
552 .functions = usb_functions_rockchip,
555 .product_id = 0x4e12,
556 .num_functions = ARRAY_SIZE(usb_functions_rockchip_adb),
557 .functions = usb_functions_rockchip_adb,
560 .product_id = 0x4e13,
561 .num_functions = ARRAY_SIZE(usb_functions_rndis_rockchip),
562 .functions = usb_functions_rndis_rockchip,
565 .product_id = 0x4e14,
566 .num_functions = ARRAY_SIZE(usb_functions_rndis_rockchip_adb),
567 .functions = usb_functions_rndis_rockchip_adb,
569 #ifdef CONFIG_USB_ANDROID_DIAG
571 .product_id = 0x4e17,
572 .num_functions = ARRAY_SIZE(usb_functions_adb_diag),
573 .functions = usb_functions_adb_diag,
578 static struct android_usb_platform_data android_usb_pdata = {
579 .vendor_id = 0x2207,//0x0bb4,//0x18d1,
580 .product_id = 0x2810,//0x4e11,
582 .product_name = "rk2818 sdk",
583 .manufacturer_name = "RockChip",
584 .num_products = ARRAY_SIZE(usb_products),
585 .products = usb_products,
586 .num_functions = ARRAY_SIZE(usb_functions_all),
587 .functions = usb_functions_all,
591 struct platform_device android_usb_device = {
592 .name = "android_usb",
595 .platform_data = &android_usb_pdata,
599 static struct usb_mass_storage_platform_data mass_storage_pdata = {
601 .vendor = "RockChip",
602 .product = "rk2818 sdk",
607 struct platform_device usb_mass_storage_device = {
608 .name = "usb_mass_storage",
611 .platform_data = &mass_storage_pdata,