1 /* arch/arm/mach-rk29/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 #ifdef CONFIG_USB_ANDROID
20 #include <linux/usb/android_composite.h>
22 #include <linux/delay.h>
23 #include <linux/dma-mapping.h>
25 #include <mach/irqs.h>
26 #include <mach/rk29_iomap.h>
27 #include <mach/rk29-dma-pl330.h>
28 #include <mach/rk29_camera.h> /* ddl@rock-chips.com : camera support */
29 #include <mach/board.h>
30 #include <mach/loader.h>
32 #ifdef CONFIG_ADC_RK29
33 static struct resource rk29_adc_resource[] = {
37 .flags = IORESOURCE_IRQ,
40 .start = RK29_ADC_PHYS,
41 .end = RK29_ADC_PHYS + RK29_ADC_SIZE - 1,
42 .flags = IORESOURCE_MEM,
47 struct platform_device rk29_device_adc = {
50 .num_resources = ARRAY_SIZE(rk29_adc_resource),
51 .resource = rk29_adc_resource,
56 #ifdef CONFIG_BATTERY_RK29_ADC
57 struct platform_device rk29_adc_device_battery = {
58 .name = "rk2918-battery",
61 .platform_data = &rk29_adc_battery_platdata,
65 #ifdef CONFIG_RK29_VMAC
66 static u64 eth_dmamask = DMA_BIT_MASK(32);
67 static struct resource rk29_vmac_resource[] = {
69 .start = RK29_MAC_PHYS,
70 .end = RK29_MAC_PHYS + RK29_MAC_SIZE - 1,
71 .flags = IORESOURCE_MEM,
76 .flags = IORESOURCE_IRQ,
81 struct platform_device rk29_device_vmac = {
85 .dma_mask = ð_dmamask,
86 .coherent_dma_mask = DMA_BIT_MASK(32),
87 .platform_data = &rk29_vmac_pdata,
89 .num_resources = ARRAY_SIZE(rk29_vmac_resource),
90 .resource = rk29_vmac_resource,
94 #ifdef CONFIG_I2C_RK29
95 #ifdef CONFIG_RK29_I2C0_CONTROLLER
96 static struct resource resources_i2c0[] = {
100 .flags = IORESOURCE_IRQ,
103 .start = RK29_I2C0_PHYS,
104 .end = RK29_I2C0_PHYS + SZ_4K - 1,
105 .flags = IORESOURCE_MEM,
109 #ifdef CONFIG_RK29_I2C1_CONTROLLER
110 static struct resource resources_i2c1[] = {
114 .flags = IORESOURCE_IRQ,
117 .start = RK29_I2C1_PHYS,
118 .end = RK29_I2C1_PHYS + SZ_4K - 1,
119 .flags = IORESOURCE_MEM,
123 #ifdef CONFIG_RK29_I2C2_CONTROLLER
124 static struct resource resources_i2c2[] = {
128 .flags = IORESOURCE_IRQ,
131 .start = RK29_I2C2_PHYS,
132 .end = RK29_I2C2_PHYS + SZ_4K - 1,
133 .flags = IORESOURCE_MEM,
137 #ifdef CONFIG_RK29_I2C3_CONTROLLER
138 static struct resource resources_i2c3[] = {
142 .flags = IORESOURCE_IRQ,
145 .start = RK29_I2C3_PHYS,
146 .end = RK29_I2C3_PHYS + SZ_4K - 1,
147 .flags = IORESOURCE_MEM,
151 struct platform_device rk29_device_i2c0 = {
152 #ifdef CONFIG_RK29_I2C0_CONTROLLER
155 .num_resources = ARRAY_SIZE(resources_i2c0),
156 .resource = resources_i2c0,
158 .platform_data = &default_i2c0_data,
164 .platform_data = &default_i2c0_data,
168 struct platform_device rk29_device_i2c1 = {
169 #ifdef CONFIG_RK29_I2C1_CONTROLLER
172 .num_resources = ARRAY_SIZE(resources_i2c1),
173 .resource = resources_i2c1,
175 .platform_data = &default_i2c1_data,
181 .platform_data = &default_i2c1_data,
185 struct platform_device rk29_device_i2c2 = {
186 #ifdef CONFIG_RK29_I2C2_CONTROLLER
189 .num_resources = ARRAY_SIZE(resources_i2c2),
190 .resource = resources_i2c2,
192 .platform_data = &default_i2c2_data,
198 .platform_data = &default_i2c2_data,
202 struct platform_device rk29_device_i2c3 = {
203 #ifdef CONFIG_RK29_I2C3_CONTROLLER
206 .num_resources = ARRAY_SIZE(resources_i2c3),
207 .resource = resources_i2c3,
209 .platform_data = &default_i2c3_data,
215 .platform_data = &default_i2c3_data,
221 /***********************************************************
223 ***************************************************************/
224 #ifdef CONFIG_BACKLIGHT_RK29_BL
225 struct platform_device rk29_device_backlight = {
226 .name = "rk29_backlight",
229 .platform_data = &rk29_bl_info,
234 #ifdef CONFIG_BUTTON_LIGHT
235 struct platform_device rk29_device_buttonlight = {
236 .name = "rk29_button_light",
239 .platform_data = &rk29_button_light_info,
243 #ifdef CONFIG_SDMMC0_RK29
244 #ifndef CONFIG_EMMC_RK29
245 static struct resource resources_sdmmc0[] = {
249 .flags = IORESOURCE_IRQ,
252 .start = RK29_SDMMC0_PHYS,
253 .end = RK29_SDMMC0_PHYS + RK29_SDMMC0_SIZE -1,
254 .flags = IORESOURCE_MEM,
258 static struct resource resources_sdmmc0[] = {
262 .flags = IORESOURCE_IRQ,
265 .start = RK29_EMMC_PHYS,
266 .end = RK29_EMMC_PHYS + RK29_EMMC_SIZE -1,
267 .flags = IORESOURCE_MEM,
272 #ifdef CONFIG_SDMMC1_RK29
273 static struct resource resources_sdmmc1[] = {
277 .flags = IORESOURCE_IRQ,
280 .start = RK29_SDMMC1_PHYS,
281 .end = RK29_SDMMC1_PHYS + RK29_SDMMC1_SIZE -1,
282 .flags = IORESOURCE_MEM,
287 #ifdef CONFIG_SDMMC0_RK29
288 struct platform_device rk29_device_sdmmc0 = {
289 .name = "rk29_sdmmc",
291 .num_resources = ARRAY_SIZE(resources_sdmmc0),
292 .resource = resources_sdmmc0,
294 .platform_data = &default_sdmmc0_data,
298 #ifdef CONFIG_SDMMC1_RK29
299 struct platform_device rk29_device_sdmmc1 = {
300 .name = "rk29_sdmmc",
302 .num_resources = ARRAY_SIZE(resources_sdmmc1),
303 .resource = resources_sdmmc1,
305 .platform_data = &default_sdmmc1_data,
311 * rk29 wdt device ADDED BY HHB@ROCK-CHIPS.COM
314 #ifdef CONFIG_RK29_WATCHDOG
316 static struct resource resources_wdt[] = {
320 .flags = IORESOURCE_IRQ,
323 .start = RK29_WDT_PHYS,
324 .end = RK29_WDT_PHYS + RK29_WDT_SIZE - 1,
325 .flags = IORESOURCE_MEM,
329 struct platform_device rk29_device_wdt = {
332 .num_resources = ARRAY_SIZE(resources_wdt),
333 .resource = resources_wdt,
340 * rk29 4 uarts device
342 #ifdef CONFIG_UART0_RK29
343 static struct resource resources_uart0[] = {
347 .flags = IORESOURCE_IRQ,
350 .start = RK29_UART0_PHYS,
351 .end = RK29_UART0_PHYS + RK29_UART0_SIZE - 1,
352 .flags = IORESOURCE_MEM,
356 #ifdef CONFIG_UART1_RK29
357 static struct resource resources_uart1[] = {
361 .flags = IORESOURCE_IRQ,
364 .start = RK29_UART1_PHYS,
365 .end = RK29_UART1_PHYS + RK29_UART1_SIZE - 1,
366 .flags = IORESOURCE_MEM,
370 #ifdef CONFIG_UART2_RK29
371 static struct resource resources_uart2[] = {
375 .flags = IORESOURCE_IRQ,
378 .start = RK29_UART2_PHYS,
379 .end = RK29_UART2_PHYS + RK29_UART2_SIZE - 1,
380 .flags = IORESOURCE_MEM,
384 #ifdef CONFIG_UART3_RK29
385 static struct resource resources_uart3[] = {
389 .flags = IORESOURCE_IRQ,
392 .start = RK29_UART3_PHYS,
393 .end = RK29_UART3_PHYS + RK29_UART3_SIZE - 1,
394 .flags = IORESOURCE_MEM,
398 #ifdef CONFIG_UART0_RK29
399 struct platform_device rk29_device_uart0 = {
400 .name = "rk29_serial",
402 .num_resources = ARRAY_SIZE(resources_uart0),
403 .resource = resources_uart0,
406 #ifdef CONFIG_UART1_RK29
407 struct platform_device rk29_device_uart1 = {
408 .name = "rk29_serial",
410 .num_resources = ARRAY_SIZE(resources_uart1),
411 .resource = resources_uart1,
414 #ifdef CONFIG_UART2_RK29
415 struct platform_device rk29_device_uart2 = {
416 .name = "rk29_serial",
418 .num_resources = ARRAY_SIZE(resources_uart2),
419 .resource = resources_uart2,
422 #ifdef CONFIG_UART3_RK29
423 struct platform_device rk29_device_uart3 = {
424 .name = "rk29_serial",
426 .num_resources = ARRAY_SIZE(resources_uart3),
427 .resource = resources_uart3,
432 * rk29xx spi master device
434 static struct resource rk29_spi0_resources[] = {
438 .flags = IORESOURCE_IRQ,
441 .start = RK29_SPI0_PHYS,
442 .end = RK29_SPI0_PHYS + RK29_SPI0_SIZE - 1,
443 .flags = IORESOURCE_MEM,
446 .start = DMACH_SPI0_TX,
447 .end = DMACH_SPI0_TX,
448 .flags = IORESOURCE_DMA,
451 .start = DMACH_SPI0_RX,
452 .end = DMACH_SPI0_RX,
453 .flags = IORESOURCE_DMA,
457 struct platform_device rk29xx_device_spi0m = {
458 .name = "rk29xx_spim",
460 .num_resources = ARRAY_SIZE(rk29_spi0_resources),
461 .resource = rk29_spi0_resources,
463 .platform_data = &rk29xx_spi0_platdata,
467 static struct resource rk29_spi1_resources[] = {
471 .flags = IORESOURCE_IRQ,
474 .start = RK29_SPI1_PHYS,
475 .end = RK29_SPI1_PHYS + RK29_SPI1_SIZE - 1,
476 .flags = IORESOURCE_MEM,
479 .start = DMACH_SPI1_TX,
480 .end = DMACH_SPI1_TX,
481 .flags = IORESOURCE_DMA,
484 .start = DMACH_SPI1_RX,
485 .end = DMACH_SPI1_RX,
486 .flags = IORESOURCE_DMA,
490 struct platform_device rk29xx_device_spi1m = {
491 .name = "rk29xx_spim",
493 .num_resources = ARRAY_SIZE(rk29_spi1_resources),
494 .resource = rk29_spi1_resources,
496 .platform_data = &rk29xx_spi1_platdata,
500 #if defined(CONFIG_MTD_NAND_RK29XX)
501 static struct resource rk29xxnand_resources[] = {
503 .start = RK29_NANDC_PHYS,
504 .end = RK29_NANDC_PHYS+RK29_NANDC_SIZE -1,
505 .flags = IORESOURCE_MEM,
509 struct platform_device rk29xx_device_nand = {
510 .name = "rk29xxnand",
512 .resource = rk29xxnand_resources,
513 .num_resources= ARRAY_SIZE(rk29xxnand_resources),
515 .platform_data= &rk29_nand_data,
522 #if defined(CONFIG_MTD_NAND_RK29)
523 static struct resource nand_resources[] = {
525 .start = RK29_NANDC_PHYS,
526 .end = RK29_NANDC_PHYS+RK29_NANDC_SIZE -1,
527 .flags = IORESOURCE_MEM,
531 struct platform_device rk29_device_nand = {
534 .resource = nand_resources,
535 .num_resources= ARRAY_SIZE(nand_resources),
537 .platform_data= &rk29_nand_data,
543 #if defined(CONFIG_SND_RK29_SOC_I2S)
544 static struct resource rk29_iis_2ch_resource[] = {
546 .start = RK29_I2S_2CH_PHYS,
547 .end = RK29_I2S_2CH_PHYS + RK29_I2S_2CH_SIZE -1,
548 .flags = IORESOURCE_MEM,
551 .start = DMACH_I2S_2CH_TX,
552 .end = DMACH_I2S_2CH_TX,
553 .flags = IORESOURCE_DMA,
556 .start = DMACH_I2S_2CH_RX,
557 .end = DMACH_I2S_2CH_RX,
558 .flags = IORESOURCE_DMA,
561 .start = IRQ_I2S_2CH,
563 .flags = IORESOURCE_IRQ,
567 struct platform_device rk29_device_iis_2ch = {
570 .num_resources = ARRAY_SIZE(rk29_iis_2ch_resource),
571 .resource = rk29_iis_2ch_resource,
574 static struct resource rk29_iis_8ch_resource[] = {
576 .start = RK29_I2S_8CH_PHYS,
577 .end = RK29_I2S_8CH_PHYS + RK29_I2S_8CH_SIZE - 1,
578 .flags = IORESOURCE_MEM,
581 .start = DMACH_I2S_8CH_TX,
582 .end = DMACH_I2S_8CH_TX,
583 .flags = IORESOURCE_DMA,
586 .start = DMACH_I2S_8CH_RX,
587 .end = DMACH_I2S_8CH_RX,
588 .flags = IORESOURCE_DMA,
591 .start = IRQ_I2S_8CH,
593 .flags = IORESOURCE_IRQ,
597 struct platform_device rk29_device_iis_8ch = {
600 .num_resources = ARRAY_SIZE(rk29_iis_8ch_resource),
601 .resource = rk29_iis_8ch_resource,
605 static struct platform_device rk29_device_pcm = {
606 .name = "rockchip-audio",
610 #ifdef CONFIG_RK29_IPP
611 /* rk29 ipp resource */
612 static struct resource rk29_ipp_resource[] = {
614 .start = RK29_IPP_PHYS,
615 .end = RK29_IPP_PHYS + RK29_IPP_SIZE - 1,
616 .flags = IORESOURCE_MEM,
621 .flags = IORESOURCE_IRQ,
626 //extern struct rk29ipp_info rk29_ipp_info;
627 struct platform_device rk29_device_ipp = {
630 .num_resources = ARRAY_SIZE(rk29_ipp_resource),
631 .resource = rk29_ipp_resource,
635 #ifdef CONFIG_USB20_OTG
637 static struct resource usb20_otg_resource[] = {
639 .start = IRQ_USB_OTG0,
641 .flags = IORESOURCE_IRQ,
644 .start = RK29_USBOTG0_PHYS,
645 .end = RK29_USBOTG0_PHYS + RK29_USBOTG0_SIZE - 1,
646 .flags = IORESOURCE_MEM,
651 struct platform_device rk29_device_usb20_otg = {
654 .num_resources = ARRAY_SIZE(usb20_otg_resource),
655 .resource = usb20_otg_resource,
658 #ifdef CONFIG_USB_ANDROID
660 static char *usb_functions_rockchip[] = {
664 static char *usb_functions_rockchip_adb[] = {
669 static char *usb_functions_rndis_rockchip[] = {
674 static char *usb_functions_rndis_rockchip_adb[] = {
680 #ifdef CONFIG_USB_ANDROID_DIAG
681 static char *usb_functions_adb_diag[] = {
688 static char *usb_functions_all[] = {
689 #ifdef CONFIG_USB_ANDROID_RNDIS
693 #ifdef CONFIG_USB_ANDROID_ADB
696 #ifdef CONFIG_USB_ANDROID_ACM
699 #ifdef CONFIG_USB_ANDROID_DIAG
704 static struct android_usb_product usb_products[] = {
706 .product_id = 0x2910,//0x0c02,//0x4e11,
707 .num_functions = ARRAY_SIZE(usb_functions_rockchip),
708 .functions = usb_functions_rockchip,
711 .product_id = 0x0c02,//0x0c02,//0x4e12,
712 .num_functions = ARRAY_SIZE(usb_functions_rockchip_adb),
713 .functions = usb_functions_rockchip_adb,
716 .product_id = 0x4e13,
717 .num_functions = ARRAY_SIZE(usb_functions_rndis_rockchip),
718 .functions = usb_functions_rndis_rockchip,
721 .product_id = 0x4e14,
722 .num_functions = ARRAY_SIZE(usb_functions_rndis_rockchip_adb),
723 .functions = usb_functions_rndis_rockchip_adb,
725 #ifdef CONFIG_USB_ANDROID_DIAG
727 .product_id = 0x4e17,
728 .num_functions = ARRAY_SIZE(usb_functions_adb_diag),
729 .functions = usb_functions_adb_diag,
734 * if anyone want to use adb driver of HTC G1,
735 * please change vendor_id to 0x0bb4 and product_id to 0x0c02.
737 static struct android_usb_platform_data android_usb_pdata = {
738 .vendor_id = 0x0bb4,//0x2207,//0x0bb4,//0x18d1,
739 .product_id = 0x4e11,//0x2910,//0x4e11,
741 .product_name = "rk2918 sdk",
742 .manufacturer_name = "RockChip",
743 .num_products = ARRAY_SIZE(usb_products),
744 .products = usb_products,
745 .num_functions = ARRAY_SIZE(usb_functions_all),
746 .functions = usb_functions_all,
750 struct platform_device android_usb_device = {
751 .name = "android_usb",
754 .platform_data = &android_usb_pdata,
758 /********************usb*********************/
759 struct usb_mass_storage_platform_data mass_storage_pdata = {
761 .vendor = "RockChip",
762 .product = "rk29 sdk",
767 struct platform_device usb_mass_storage_device = {
768 .name = "usb_mass_storage",
771 .platform_data = &mass_storage_pdata,
776 #ifdef CONFIG_USB_ANDROID_RNDIS
777 static struct usb_ether_platform_data rndis_pdata = {
778 /* ethaddr is filled by board_serialno_setup */
779 .ethaddr = {0xf0, 0xde, 0xf1, 0x42, 0xe8, 0x10},
780 .vendorID = 0x22b8,// moto xt701 //0x2207,
781 .vendorDescr = "RockChip",
784 struct platform_device rk29_device_rndis = {
788 .platform_data = &rndis_pdata,
793 #ifdef CONFIG_USB11_HOST
794 static struct resource usb11_host_resource[] = {
796 .start = IRQ_USB_HOST,
798 .flags = IORESOURCE_IRQ,
801 .start = RK29_USBHOST_PHYS,
802 .end = RK29_USBHOST_PHYS + RK29_USBHOST_SIZE - 1,
803 .flags = IORESOURCE_MEM,
808 struct platform_device rk29_device_usb11_host = {
809 .name = "usb11_host",
811 .num_resources = ARRAY_SIZE(usb11_host_resource),
812 .resource = usb11_host_resource,
815 #ifdef CONFIG_USB20_HOST
816 static struct resource usb20_host_resource[] = {
818 .start = IRQ_USB_OTG1,
820 .flags = IORESOURCE_IRQ,
823 .start = RK29_USBOTG1_PHYS,
824 .end = RK29_USBOTG1_PHYS + RK29_USBOTG1_SIZE - 1,
825 .flags = IORESOURCE_MEM,
830 struct platform_device rk29_device_usb20_host = {
831 .name = "usb20_host",
833 .num_resources = ARRAY_SIZE(usb20_host_resource),
834 .resource = usb20_host_resource,
838 static struct resource rk29_pmu_resource = {
841 .flags = IORESOURCE_IRQ,
844 struct platform_device rk29_device_pmu = {
846 .id = ARM_PMU_DEVICE_CPU,
848 .resource = &rk29_pmu_resource,
851 static int boot_mode;
852 static int __init boot_mode_init(char *s)
854 if (!strcmp(s, "normal"))
855 boot_mode = BOOT_MODE_NORMAL;
856 else if (!strcmp(s, "factory2"))
857 boot_mode = BOOT_MODE_FACTORY2;
858 else if (!strcmp(s, "recovery"))
859 boot_mode = BOOT_MODE_RECOVERY;
860 else if (!strcmp(s, "charge"))
861 boot_mode = BOOT_MODE_CHARGE;
862 else if (!strcmp(s, "power_test"))
863 boot_mode = BOOT_MODE_POWER_TEST;
864 else if (!strcmp(s, "offmode_charging"))
865 boot_mode = BOOT_MODE_OFFMODE_CHARGING;
869 __setup("androidboot.mode=", boot_mode_init);
871 __init void rk29_boot_mode_init_by_register(void)
873 u32 flag = readl(RK29_TIMER0_BASE);
874 if (flag == (SYS_KERNRL_REBOOT_FLAG | BOOT_RECOVER)) {
875 boot_mode = BOOT_MODE_RECOVERY;
876 } else if (strstr(boot_command_line, "(parameter)")) {
877 boot_mode = BOOT_MODE_RECOVERY;
879 boot_mode = readl(RK29_GRF_BASE + 0xdc); // GRF_OS_REG3
882 printk("Boot mode: %d\n", boot_mode);
885 int board_boot_mode(void)
889 EXPORT_SYMBOL(board_boot_mode);
891 static int __init rk29_init_devices(void)
893 platform_device_register(&rk29_device_pmu);
894 platform_device_register(&rk29_device_pcm);
897 arch_initcall(rk29_init_devices);