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>
21 #include <linux/delay.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 <mach/gpio.h>
31 #include <mach/rk2818_nand.h>
32 #include <mach/iomux.h>
33 #include <mach/rk2818_camera.h> /* ddl@rock-chips.com : camera support */
34 #include <linux/i2c.h>
35 #include <linux/miscdevice.h>
36 #include <linux/circ_buf.h>
37 #include <mach/spi_fpga.h>
38 #include <media/soc_camera.h>
39 #include "../../../drivers/staging/android/timed_gpio.h"
40 static struct resource resources_sdmmc0[] = {
42 .start = IRQ_NR_SDMMC0,
44 .flags = IORESOURCE_IRQ,
47 .start = RK2818_SDMMC0_PHYS,
48 .end = RK2818_SDMMC0_PHYS + SZ_8K -1,
49 .flags = IORESOURCE_MEM,
52 static struct resource resources_sdmmc1[] = {
54 .start = IRQ_NR_SDMMC1,
56 .flags = IORESOURCE_IRQ,
59 .start = RK2818_SDMMC1_PHYS,
60 .end = RK2818_SDMMC1_PHYS + SZ_8K -1,
61 .flags = IORESOURCE_MEM,
66 static struct resource resources_i2c0[] = {
70 .flags = IORESOURCE_IRQ,
73 .start = RK2818_I2C0_PHYS,
74 .end = RK2818_I2C0_PHYS + SZ_4K - 1,
75 .flags = IORESOURCE_MEM,
78 static struct resource resources_i2c1[] = {
82 .flags = IORESOURCE_IRQ,
85 .start = RK2818_I2C1_PHYS,
86 .end = RK2818_I2C1_PHYS + SZ_4K - 1,
87 .flags = IORESOURCE_MEM,
91 * rk2818 4 uarts device
93 static struct resource resources_uart0[] = {
95 .start = IRQ_NR_UART0,
97 .flags = IORESOURCE_IRQ,
100 .start = RK2818_UART0_PHYS,
101 .end = RK2818_UART0_PHYS + SZ_1K - 1,
102 .flags = IORESOURCE_MEM,
105 static struct resource resources_uart1[] = {
107 .start = IRQ_NR_UART1,
109 .flags = IORESOURCE_IRQ,
112 .start = RK2818_UART1_PHYS,
113 .end = RK2818_UART1_PHYS + SZ_1K - 1,
114 .flags = IORESOURCE_MEM,
117 static struct resource resources_uart2[] = {
119 .start = IRQ_NR_UART2,
121 .flags = IORESOURCE_IRQ,
124 .start = RK2818_UART2_PHYS,
125 .end = RK2818_UART2_PHYS + SZ_1K - 1,
126 .flags = IORESOURCE_MEM,
129 static struct resource resources_uart3[] = {
131 .start = IRQ_NR_UART3,
133 .flags = IORESOURCE_IRQ,
136 .start = RK2818_UART3_PHYS,
137 .end = RK2818_UART3_PHYS + SZ_1K - 1,
138 .flags = IORESOURCE_MEM,
142 struct platform_device rk2818_device_sdmmc0 = {
143 .name = "rk2818_sdmmc",
145 .num_resources = ARRAY_SIZE(resources_sdmmc0),
146 .resource = resources_sdmmc0,
148 .platform_data = &default_sdmmc0_data,
151 struct platform_device rk2818_device_sdmmc1 = {
152 .name = "rk2818_sdmmc",
154 .num_resources = ARRAY_SIZE(resources_sdmmc1),
155 .resource = resources_sdmmc1,
157 .platform_data = &default_sdmmc1_data,
161 struct platform_device rk2818_device_i2c0 = {
162 .name = "rk2818_i2c",
164 .num_resources = ARRAY_SIZE(resources_i2c0),
165 .resource = resources_i2c0,
167 .platform_data = &default_i2c0_data,
170 struct platform_device rk2818_device_i2c1 = {
171 .name = "rk2818_i2c",
173 .num_resources = ARRAY_SIZE(resources_i2c1),
174 .resource = resources_i2c1,
176 .platform_data = &default_i2c1_data,
179 struct platform_device rk2818_device_i2c2 = {
183 .platform_data = &default_i2c2_data,
186 struct platform_device rk2818_device_i2c3 = {
190 .platform_data = &default_i2c3_data,
193 struct platform_device rk2818_device_uart0 = {
194 .name = "rk2818_serial",
196 .num_resources = ARRAY_SIZE(resources_uart0),
197 .resource = resources_uart0,
199 .platform_data = &rk2818_serial0_platdata,
202 struct platform_device rk2818_device_uart1 = {
203 .name = "rk2818_serial",
205 .num_resources = ARRAY_SIZE(resources_uart1),
206 .resource = resources_uart1,
208 struct platform_device rk2818_device_uart2 = {
209 .name = "rk2818_serial",
211 .num_resources = ARRAY_SIZE(resources_uart2),
212 .resource = resources_uart2,
214 struct platform_device rk2818_device_uart3 = {
215 .name = "rk2818_serial",
217 .num_resources = ARRAY_SIZE(resources_uart3),
218 .resource = resources_uart3,
222 * rk2818 spi master device
224 static struct resource resources_spim[] = {
226 .start = IRQ_NR_SPIM,
228 .flags = IORESOURCE_IRQ,
231 .start = RK2818_SPIMASTER_PHYS,
232 .end = RK2818_SPIMASTER_PHYS + SZ_4K - 1,
233 .flags = IORESOURCE_MEM,
236 struct platform_device rk2818_device_spim = {
237 .name = "rk2818_spim",
239 .num_resources = ARRAY_SIZE(resources_spim),
240 .resource = resources_spim,
242 .platform_data = &rk2818_spi_platdata,
246 /* rk2818 fb resource */
247 static struct resource rk2818_fb_resource[] = {
249 .start = RK2818_LCDC_PHYS,
250 .end = RK2818_LCDC_PHYS + RK2818_LCDC_SIZE - 1,
251 .flags = IORESOURCE_MEM,
254 .start = IRQ_NR_LCDC,
256 .flags = IORESOURCE_IRQ,
261 extern struct rk2818_fb_mach_info rk2818_fb_mach_info;
263 struct platform_device rk2818_device_fb = {
266 .num_resources = ARRAY_SIZE(rk2818_fb_resource),
267 .resource = rk2818_fb_resource,
269 .platform_data = &rk2818_fb_mach_info,
273 /***********************************************************
275 * author :nzy zhongyw
277 ***************************************************************/
278 struct platform_device rk2818_device_backlight = {
279 .name = "rk2818_backlight",
282 .platform_data = &rk2818_bl_info,
286 /* RK2818 Camera : ddl@rock-chips.com */
287 #ifdef CONFIG_VIDEO_RK2818
289 static struct resource rk2818_camera_resource[] = {
291 .start = RK2818_VIP_PHYS,
292 .end = RK2818_VIP_PHYS + RK2818_VIP_SIZE - 1,
293 .flags = IORESOURCE_MEM,
298 .flags = IORESOURCE_IRQ,
302 static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
304 /*platform_device : */
305 struct platform_device rk2818_device_camera = {
306 .name = RK28_CAM_DRV_NAME,
307 .id = RK28_CAM_PLATFORM_DEV_ID, /* This is used to put cameras on this interface */
308 .num_resources = ARRAY_SIZE(rk2818_camera_resource),
309 .resource = rk2818_camera_resource,
311 .dma_mask = &rockchip_device_camera_dmamask,
312 .coherent_dma_mask = 0xffffffffUL,
313 .platform_data = &rk28_camera_platform_data,
317 /*platform_device : soc-camera need */
318 struct platform_device rk2818_soc_camera_pdrv = {
319 .name = "soc-camera-pdrv",
322 .init_name = "ov2655",
323 .platform_data = &rk2818_iclink,
329 static struct resource rk2818_adc_resource[] = {
333 .flags = IORESOURCE_IRQ,
336 .start = RK2818_ADC_PHYS,
337 .end = RK2818_ADC_PHYS + RK2818_ADC_SIZE - 1,
338 .flags = IORESOURCE_MEM,
343 struct platform_device rk2818_device_adc = {
344 .name = "rk2818-adc",
346 .num_resources = ARRAY_SIZE(rk2818_adc_resource),
347 .resource = rk2818_adc_resource,
351 struct platform_device rk2818_device_adckey = {
352 .name = "rk2818-adckey",
354 .dev.parent = &rk2818_device_adc.dev,
355 .dev.platform_data = &rk2818_adckey_platdata,
361 static struct resource resources_i2s[] = {
365 .flags = IORESOURCE_IRQ,
368 .start = RK2818_I2S_PHYS,
369 .end = RK2818_I2S_PHYS + SZ_8K - 1,
370 .flags = IORESOURCE_MEM,
373 struct platform_device rk2818_device_i2s = {
374 .name = "rk2818_i2s",
376 .num_resources = ARRAY_SIZE(resources_i2s),
377 .resource = resources_i2s,
379 .platform_data = &rk2818_i2s_platdata,
383 struct platform_device rk2818_device_battery = {
384 .name = "rk2818-battery",
387 .platform_data = &rk2818_battery_platdata,
394 static struct resource resources_dsp[] = {
396 .start = RK2818_DSP_PHYS,
397 .end = RK2818_DSP_PHYS + 0x5fffff,
398 .flags = IORESOURCE_DMA,
401 .start = IRQ_NR_PIUCMD,
402 .end = IRQ_NR_PIUCMD,
403 .flags = IORESOURCE_IRQ,
406 .start = IRQ_NR_DSPSWI,
407 .end = IRQ_NR_DSPSWI,
408 .flags = IORESOURCE_IRQ,
411 static u64 rk2818_device_dsp_dmamask = 0xffffffffUL;
412 struct platform_device rk2818_device_dsp = {
415 .num_resources = ARRAY_SIZE(resources_dsp),
416 .resource = resources_dsp,
418 .dma_mask = &rk2818_device_dsp_dmamask,
419 .coherent_dma_mask = 0xffffffffUL
424 struct platform_device rk2818_device_rfkill = {
425 .name = "rkbt_rfkill",
430 #if defined(CONFIG_ANDROID_PMEM)
432 static struct android_pmem_platform_data pmem_pdata = {
440 static struct android_pmem_platform_data pmem_pdata_dsp = {
448 struct platform_device rk2818_device_pmem = {
449 .name = "android_pmem",
451 .dev = { .platform_data = &pmem_pdata },
454 struct platform_device rk2818_device_pmem_dsp = {
455 .name = "android_pmem",
457 .dev = { .platform_data = &pmem_pdata_dsp },
461 #if defined(CONFIG_MTD_NAND_RK2818)
462 static struct resource nand_resources[] = {
464 .start = RK2818_NANDC_PHYS,
465 .end = RK2818_NANDC_PHYS+RK2818_NANDC_SIZE -1,
466 .flags = IORESOURCE_MEM,
470 struct platform_device rk2818_nand_device = {
471 .name = "rk2818-nand",
473 .resource = nand_resources,
474 .num_resources= ARRAY_SIZE(nand_resources),
476 .platform_data= &rk2818_nand_data,
483 static struct resource dwc_otg_resource[] = {
487 .flags = IORESOURCE_IRQ,
490 .start = RK2818_USBOTG_PHYS,
491 .end = RK2818_USBOTG_PHYS + RK2818_USBOTG_SIZE - 1,
492 .flags = IORESOURCE_MEM,
497 struct platform_device rk2818_device_dwc_otg = {
500 .num_resources = ARRAY_SIZE(dwc_otg_resource),
501 .resource = dwc_otg_resource,
503 #ifdef CONFIG_RK2818_HOST11
504 static struct resource rk2818_host11_resource[] = {
506 .start = IRQ_NR_USB_HOST,
507 .end = IRQ_NR_USB_HOST,
508 .flags = IORESOURCE_IRQ,
511 .start = RK2818_USBHOST_PHYS,
512 .end = RK2818_USBHOST_PHYS + RK2818_USBHOST_SIZE - 1,
513 .flags = IORESOURCE_MEM,
518 struct platform_device rk2818_device_host11 = {
519 .name = "rk2818_host11",
521 .num_resources = ARRAY_SIZE(rk2818_host11_resource),
522 .resource = rk2818_host11_resource,
525 static char *usb_functions_rockchip[] = {
529 static char *usb_functions_rockchip_adb[] = {
534 static char *usb_functions_rndis_rockchip[] = {
539 static char *usb_functions_rndis_rockchip_adb[] = {
545 #ifdef CONFIG_USB_ANDROID_DIAG
546 static char *usb_functions_adb_diag[] = {
553 static char *usb_functions_all[] = {
554 #ifdef CONFIG_USB_ANDROID_RNDIS
558 #ifdef CONFIG_USB_ANDROID_ADB
561 #ifdef CONFIG_USB_ANDROID_ACM
564 #ifdef CONFIG_USB_ANDROID_DIAG
569 static struct android_usb_product usb_products[] = {
571 .product_id = 0x2810,//0x0c02,//0x4e11,
572 .num_functions = ARRAY_SIZE(usb_functions_rockchip),
573 .functions = usb_functions_rockchip,
576 .product_id = 0x4e12,
577 .num_functions = ARRAY_SIZE(usb_functions_rockchip_adb),
578 .functions = usb_functions_rockchip_adb,
581 .product_id = 0x4e13,
582 .num_functions = ARRAY_SIZE(usb_functions_rndis_rockchip),
583 .functions = usb_functions_rndis_rockchip,
586 .product_id = 0x4e14,
587 .num_functions = ARRAY_SIZE(usb_functions_rndis_rockchip_adb),
588 .functions = usb_functions_rndis_rockchip_adb,
590 #ifdef CONFIG_USB_ANDROID_DIAG
592 .product_id = 0x4e17,
593 .num_functions = ARRAY_SIZE(usb_functions_adb_diag),
594 .functions = usb_functions_adb_diag,
599 static struct android_usb_platform_data android_usb_pdata = {
600 .vendor_id = 0x2207,//0x0bb4,//0x18d1,
601 .product_id = 0x2810,//0x4e11,
603 .product_name = "rk2818 sdk",
604 .manufacturer_name = "RockChip",
605 .num_products = ARRAY_SIZE(usb_products),
606 .products = usb_products,
607 .num_functions = ARRAY_SIZE(usb_functions_all),
608 .functions = usb_functions_all,
612 struct platform_device android_usb_device = {
613 .name = "android_usb",
616 .platform_data = &android_usb_pdata,
620 static struct usb_mass_storage_platform_data mass_storage_pdata = {
622 .vendor = "RockChip",
623 .product = "rk2818 sdk",
628 struct platform_device usb_mass_storage_device = {
629 .name = "usb_mass_storage",
632 .platform_data = &mass_storage_pdata,
636 #if CONFIG_ANDROID_TIMED_GPIO
637 struct platform_device rk28_device_vibrator ={
638 .name = "timed-gpio",
641 .platform_data = &rk28_vibrator_info,