1 /* linux/arch/arm/mach-rk2818/board-phonesdk.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.
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/input.h>
21 #include <linux/delay.h>
22 #include <linux/i2c.h>
23 #include <linux/spi/spi.h>
24 #include <linux/mmc/host.h>
26 #include <mach/hardware.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/flash.h>
32 #include <mach/irqs.h>
33 #include <mach/board.h>
34 #include <mach/rk2818_iomap.h>
35 #include <mach/iomux.h>
36 #include <mach/gpio.h>
37 #include <mach/rk2818_nand.h>
39 #include <linux/mtd/nand.h>
40 #include <linux/mtd/partitions.h>
41 #include <linux/dm9000.h>
45 #include "../../../drivers/spi/rk2818_spim.h"
46 #include "../../../drivers/input/touchscreen/xpt2046_ts.h"
47 #include "../../../drivers/staging/android/timed_gpio.h"
48 #include "../../../sound/soc/codecs/wm8994.h"
50 /* --------------------------------------------------------------------
51 * ÉùÃ÷ÁËrk2818_gpioBankÊý×飬²¢¶¨ÒåÁËGPIO¼Ä´æÆ÷×éIDºÍ¼Ä´æÆ÷»ùµØÖ·¡£
52 * -------------------------------------------------------------------- */
54 static struct rk2818_gpio_bank rk2818_gpioBank[] = {
57 .offset = RK2818_GPIO0_BASE,
62 .offset = RK2818_GPIO0_BASE,
67 .offset = RK2818_GPIO0_BASE,
72 .offset = RK2818_GPIO0_BASE,
77 .offset = RK2818_GPIO1_BASE,
82 .offset = RK2818_GPIO1_BASE,
87 .offset = RK2818_GPIO1_BASE,
92 .offset = RK2818_GPIO1_BASE,
97 //IOÓ³É䷽ʽÃèÊö £¬Ã¿¸öΪһ¶ÎÏßÐÔÁ¬ÐøÓ³Éä
98 static struct map_desc rk2818_io_desc[] __initdata = {
101 .virtual = RK2818_MCDMA_BASE, //ÐéÄâµØÖ·
102 .pfn = __phys_to_pfn(RK2818_MCDMA_PHYS), //ÎïÀíµØÖ·£¬ÐëÓëÒ³±í¶ÔÆë
103 .length = RK2818_MCDMA_SIZE, //³¤¶È
104 .type = MT_DEVICE //Ó³É䷽ʽ
108 .virtual = RK2818_DWDMA_BASE,
109 .pfn = __phys_to_pfn(RK2818_DWDMA_PHYS),
110 .length = RK2818_DWDMA_SIZE,
115 .virtual = RK2818_INTC_BASE,
116 .pfn = __phys_to_pfn(RK2818_INTC_PHYS),
117 .length = RK2818_INTC_SIZE,
122 .virtual = RK2818_NANDC_BASE,
123 .pfn = __phys_to_pfn(RK2818_NANDC_PHYS),
124 .length = RK2818_NANDC_SIZE,
129 .virtual = RK2818_SDRAMC_BASE,
130 .pfn = __phys_to_pfn(RK2818_SDRAMC_PHYS),
131 .length = RK2818_SDRAMC_SIZE,
136 .virtual = RK2818_ARMDARBITER_BASE,
137 .pfn = __phys_to_pfn(RK2818_ARMDARBITER_PHYS),
138 .length = RK2818_ARMDARBITER_SIZE,
143 .virtual = RK2818_APB_BASE,
144 .pfn = __phys_to_pfn(RK2818_APB_PHYS),
150 .virtual = RK2818_WDT_BASE,
151 .pfn = __phys_to_pfn(RK2818_WDT_PHYS),
152 .length = 0xa0000, ///apb bus i2s i2c spi no map in this
156 /*****************************************************************************************
159 *****************************************************************************************/
160 static int rk2818_sdmmc0_io_init(void)
162 rk2818_mux_api_set(GPIOF3_APWM1_MMC0DETN_NAME, IOMUXA_SDMMC1_DETECT_N);
163 rk2818_mux_api_set(GPIOH_MMC0D_SEL_NAME, IOMUXA_SDMMC0_DATA123);
164 rk2818_mux_api_set(GPIOH_MMC0_SEL_NAME, IOMUXA_SDMMC0_CMD_DATA0_CLKOUT);
168 static int rk2818_sdmmc1_io_init(void)
170 rk2818_mux_api_set(GPIOG_MMC1_SEL_NAME, IOMUXA_SDMMC1_CMD_DATA0_CLKOUT);
171 rk2818_mux_api_set(GPIOG_MMC1D_SEL_NAME, IOMUXA_SDMMC1_DATA123);
175 #define CONFIG_SDMMC0_USE_DMA
176 #define CONFIG_SDMMC1_USE_DMA
177 struct rk2818_sdmmc_platform_data default_sdmmc0_data = {
178 .host_ocr_avail = (MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
179 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
180 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
181 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
182 .io_init = rk2818_sdmmc0_io_init,
184 .dma_name = "sd_mmc",
185 #ifdef CONFIG_SDMMC0_USE_DMA
191 struct rk2818_sdmmc_platform_data default_sdmmc1_data = {
192 .host_ocr_avail = (MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
193 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
194 MMC_VDD_32_33|MMC_VDD_33_34),
195 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
196 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
197 .io_init = rk2818_sdmmc1_io_init,
200 #ifdef CONFIG_SDMMC1_USE_DMA
207 /*****************************************************************************************
208 * extern gpio devices
210 *****************************************************************************************/
211 #if defined (CONFIG_GPIO_PCA9554)
212 struct rk2818_gpio_expander_info extern_gpio_settinginfo[] = {
214 .gpio_num =RK2818_PIN_PI0,
216 //.pin_value =GPIO_HIGH,
220 .gpio_num =RK2818_PIN_PI4,// tp3
222 //.pin_value =GPIO_HIGH,
226 .gpio_num =RK2818_PIN_PI5,//tp4
228 //.pin_value =GPIO_HIGH,
231 .gpio_num =RK2818_PIN_PI6,//tp2
232 .pin_type = GPIO_OUT,
233 //.pin_value =GPIO_HIGH,
236 .gpio_num =RK2818_PIN_PI7,//tp1
237 .pin_type = GPIO_OUT,
238 .pin_value =GPIO_HIGH,
245 struct pca9554_platform_data rk2818_pca9554_data={
246 .gpio_base=GPIOS_EXPANDER_BASE,
247 .gpio_pin_num=CONFIG_EXPANDED_GPIO_NUM,
248 .gpio_irq_start=NR_AIC_IRQS + 2*NUM_GROUP,
249 .irq_pin_num=CONFIG_EXPANDED_GPIO_IRQ_NUM,
250 .pca9954_irq_pin=RK2818_PIN_PE2,
251 .settinginfo=extern_gpio_settinginfo,
252 .settinginfolen=ARRAY_SIZE(extern_gpio_settinginfo),
257 #if defined (CONFIG_IOEXTEND_TCA6424)
258 struct rk2818_gpio_expander_info extgpio_tca6424_settinginfo[] = {
261 .gpio_num = TCA6424_P01,
262 .pin_type = GPIO_OUT,
263 .pin_value = GPIO_LOW,
267 .gpio_num = TCA6424_P02,// tp3
268 .pin_type = GPIO_OUT,
269 .pin_value = GPIO_LOW,
272 .gpio_num = TCA6424_P03,
273 .pin_type = GPIO_OUT,
274 .pin_value = GPIO_LOW,
278 .gpio_num = TCA6424_P04,// tp3
279 .pin_type = GPIO_OUT,
280 .pin_value = GPIO_LOW,
283 .gpio_num = TCA6424_P05,
284 .pin_type = GPIO_OUT,
285 .pin_value = GPIO_LOW,
288 .gpio_num = TCA6424_P12,
290 //.pin_value =GPIO_HIGH,
294 .gpio_num = TCA6424_P13,// tp3
296 //.pin_value =GPIO_HIGH,
299 .gpio_num = TCA6424_P14,
301 //.pin_value =GPIO_HIGH,
305 .gpio_num = TCA6424_P15,// tp3
307 //.pin_value =GPIO_HIGH,
312 struct tca6424_platform_data rk2818_tca6424_data={
313 .gpio_base=GPIO_EXPANDER_BASE,
314 .gpio_pin_num=CONFIG_EXPANDED_GPIO_NUM,
315 .gpio_irq_start=NR_AIC_IRQS + 2*NUM_GROUP + CONFIG_SPI_FPGA_GPIO_IRQ_NUM,
316 .irq_pin_num=CONFIG_EXPANDED_GPIO_IRQ_NUM,
317 .tca6424_irq_pin=RK2818_PIN_PA1,
318 .settinginfo=extgpio_tca6424_settinginfo,
319 .settinginfolen=ARRAY_SIZE(extgpio_tca6424_settinginfo),
320 .names="extend_gpio_tca6424",
326 /*****************************************************************************************
328 * author: kfx@rock-chips.com
329 *****************************************************************************************/
330 static void rk2818_i2c0_io_init(void)
332 rk2818_mux_api_set(GPIOE_I2C0_SEL_NAME, IOMUXA_I2C0);
335 static void rk2818_i2c1_io_init(void)
337 rk2818_mux_api_set(GPIOE_U1IR_I2C1_NAME, IOMUXA_I2C1);
339 struct rk2818_i2c_platform_data default_i2c0_data = {
343 .scl_rate = 400*1000,
344 .mode = I2C_MODE_IRQ,
345 .io_init = rk2818_i2c0_io_init,
347 struct rk2818_i2c_platform_data default_i2c1_data = {
348 #ifdef CONFIG_I2C0_RK2818
355 .scl_rate = 400*1000,
356 .mode = I2C_MODE_IRQ,
357 .io_init = rk2818_i2c1_io_init,
360 struct rk2818_i2c_spi_data default_i2c2_data = {
364 .scl_rate = 400*1000,
367 struct rk2818_i2c_spi_data default_i2c3_data = {
372 .scl_rate = 400*1000,
375 static struct i2c_board_info __initdata board_i2c0_devices[] = {
376 #if defined (CONFIG_RK1000_CONTROL)
378 .type = "rk1000_control",
384 #if defined (CONFIG_RK1000_TVOUT)
386 .type = "rk1000_tvout",
391 #if defined (CONFIG_SND_SOC_RK1000)
393 .type = "rk1000_i2c_codec",
398 #if defined (CONFIG_SND_SOC_WM8988)
406 static struct i2c_board_info __initdata board_i2c1_devices[] = {
407 #if defined (CONFIG_RTC_HYM8563)
409 .type = "rtc_hym8563",
414 #if defined (CONFIG_FM_QN8006)
421 #if defined (CONFIG_GPIO_PCA9554)
423 .type = "extend_gpio_pca9554",
426 .platform_data=&rk2818_pca9554_data.gpio_base,
429 #if defined (CONFIG_IOEXTEND_TCA6424)
431 .type = "extend_gpio_tca6424",
434 .platform_data=&rk2818_tca6424_data.gpio_base,
438 #if defined (CONFIG_PMIC_LP8725)
445 #if defined (CONFIG_GS_MMA7660)
447 .type = "gs_mma7660",
451 .platform_data = &rk2818_gs_platdata,
457 static struct i2c_board_info __initdata board_i2c2_devices[] = {
460 /*****************************************************************************************
462 * author: cjq@rock-chips.com
463 *****************************************************************************************/
464 static struct wm8994_platform_data wm8994_data = {
472 .headset_call_vol = 0,
473 .speaker_call_vol = 0,
474 .earpiece_call_vol = 0,
477 static struct i2c_board_info __initdata board_i2c3_devices[] = {
478 #if defined (CONFIG_SND_SOC_WM8994)
483 .platform_data = &wm8994_data,
488 /*****************************************************************************************
490 * author: lw@rock-chips.com
491 *****************************************************************************************/
492 #define CHARGEOK_PIN RK2818_PIN_PB1
493 struct rk2818_battery_platform_data rk2818_battery_platdata = {
494 .charge_ok_pin = CHARGEOK_PIN,
496 /*****************************************************************************************
498 * author: lhh@rock-chips.com
499 *****************************************************************************************/
500 static int serial_io_init(void)
506 //UART0µÄËĸö¹Ü½ÅÏÈIOMUX³ÉGPIO
507 //È»ºó·Ö±ðÉèÖÃÊäÈëÊä³ö/À¸ßÀµÍ´¦Àí
509 //·ÀÖ¹Ö±½ÓIOMUX³ÉUARTºóËĸö¹Ü½ÅµÄ״̬²»¶Ôʱ
510 //²Ù×÷UARTµ¼ÖÂUART_USR_BUSYʼÖÕΪ1Ôì³ÉÈçÏÂËÀÑ»·
511 //while(rk2818_uart_read(port,UART_USR)&UART_USR_BUSY)
512 //UARTËĸö¹Ü½ÅÔÚδ´«ÊäʱÕý³£×´Ì¬Ó¦¸ÃΪ£º
515 //×¢Ò⣺CTS/RTSΪµÍÓÐЧ£¬Ó²¼þÉϲ»Ó¦¸ÃÇ¿ÐÐ×öÉÏÀ
516 rk2818_mux_api_set(GPIOG1_UART0_MMC1WPT_NAME, IOMUXA_GPIO1_C1 /*IOMUXA_UART0_SOUT*/);
517 rk2818_mux_api_set(GPIOG0_UART0_MMC1DET_NAME, IOMUXA_GPIO1_C0 /*IOMUXA_UART0_SIN*/);
519 ret = gpio_request(RK2818_PIN_PG0, NULL);
522 gpio_free(RK2818_PIN_PG0);
524 gpio_direction_output(RK2818_PIN_PG0,GPIO_HIGH);
527 ret = gpio_request(RK2818_PIN_PG1, NULL);
530 gpio_free(RK2818_PIN_PG1);
532 gpio_direction_output(RK2818_PIN_PG1,GPIO_HIGH);
534 gpio_pull_updown(RK2818_PIN_PG1,GPIOPullUp);
535 gpio_pull_updown(RK2818_PIN_PG0,GPIOPullUp);
537 rk2818_mux_api_set(GPIOG1_UART0_MMC1WPT_NAME, IOMUXA_UART0_SOUT);
538 rk2818_mux_api_set(GPIOG0_UART0_MMC1DET_NAME, IOMUXA_UART0_SIN);
540 rk2818_mux_api_set(GPIOB2_U0CTSN_SEL_NAME, IOMUXB_GPIO0_B2/*IOMUXB_UART0_CTS_N*/);
541 rk2818_mux_api_set(GPIOB3_U0RTSN_SEL_NAME, IOMUXB_GPIO0_B3/*IOMUXB_UART0_RTS_N*/);
543 ret = gpio_request(RK2818_PIN_PB2, NULL);
546 gpio_free(RK2818_PIN_PB2);
548 gpio_direction_input(RK2818_PIN_PB2);
549 // gpio_direction_output(RK2818_PIN_PB2,GPIO_LOW);
551 ret = gpio_request(RK2818_PIN_PB3, NULL);
554 gpio_free(RK2818_PIN_PB3);
556 gpio_direction_output(RK2818_PIN_PB3,GPIO_LOW);
559 rk2818_mux_api_set(GPIOB2_U0CTSN_SEL_NAME, IOMUXB_UART0_CTS_N);
560 rk2818_mux_api_set(GPIOB3_U0RTSN_SEL_NAME, IOMUXB_UART0_RTS_N);
565 struct rk2818_serial_platform_data rk2818_serial0_platdata = {
566 .io_init = serial_io_init,
569 /*****************************************************************************************
571 * author: lhhrock-chips.com
572 *****************************************************************************************/
573 static int i2s_io_init(void)
575 /* Configure the I2S pins in correct mode */
576 rk2818_mux_api_set(CXGPIO_I2S_SEL_NAME,IOMUXB_I2S_INTERFACE);
580 struct rk2818_i2s_platform_data rk2818_i2s_platdata = {
581 .io_init = i2s_io_init,
583 /*****************************************************************************************
585 * author: lhhrock-chips.com
586 *****************************************************************************************/
587 #define SPI_CHIPSELECT_NUM 3
588 static int spi_io_init(void)
591 rk2818_mux_api_set(GPIOB4_SPI0CS0_MMC0D4_NAME, IOMUXA_GPIO0_B4);
593 rk2818_mux_api_set(GPIOB0_SPI0CSN1_MMC1PCA_NAME, IOMUXA_GPIO0_B0);
595 rk2818_mux_api_set(GPIOB_SPI0_MMC0_NAME, IOMUXA_SPI0);
597 rk2818_mux_api_set(GPIOF5_APWM3_DPWM3_NAME,IOMUXB_GPIO1_B5);
601 static int spi_io_deinit(void)
603 rk2818_mux_api_mode_resume(GPIOB4_SPI0CS0_MMC0D4_NAME);
604 rk2818_mux_api_mode_resume(GPIOB0_SPI0CSN1_MMC1PCA_NAME);
605 rk2818_mux_api_mode_resume(GPIOB_SPI0_MMC0_NAME);
606 rk2818_mux_api_mode_resume(GPIOF5_APWM3_DPWM3_NAME);
610 struct spi_cs_gpio rk2818_spi_cs_gpios[SPI_CHIPSELECT_NUM] = {
613 .cs_gpio = RK2818_PIN_PB4,
617 .cs_gpio = RK2818_PIN_PB0,
621 .cs_gpio = RK2818_PIN_PF5,
625 struct rk2818_spi_platform_data rk2818_spi_platdata = {
626 .num_chipselect = SPI_CHIPSELECT_NUM,//raho ´ó°åÐèÒªÖ§³Ö3¸öƬѡ dxj
627 .chipselect_gpios = rk2818_spi_cs_gpios,
628 .io_init = spi_io_init,
629 .io_deinit = spi_io_deinit,
631 /*****************************************************************************************
632 * xpt2046 touch panel
633 * author: dxjrock-chips.com
634 *****************************************************************************************/
635 #define XPT2046_GPIO_INT RK2818_PIN_PE1
636 #define DEBOUNCE_REPTIME 3
638 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI)
639 static struct xpt2046_platform_data xpt2046_info = {
648 .debounce_rep = DEBOUNCE_REPTIME,
650 .gpio_pendown = XPT2046_GPIO_INT,
651 .penirq_recheck_delay_usecs = 1,
653 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)
654 static struct xpt2046_platform_data xpt2046_info = {
663 .debounce_rep = DEBOUNCE_REPTIME,
665 .gpio_pendown = XPT2046_GPIO_INT,
666 .penirq_recheck_delay_usecs = 1,
668 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
669 static struct xpt2046_platform_data xpt2046_info = {
678 .debounce_rep = DEBOUNCE_REPTIME,
680 #if defined(CONFIG_MACH_RAHO)
681 .gpio_pendown = RK2818_PIN_PE1,
683 .gpio_pendown = RK2818_PIN_PE3,
685 .penirq_recheck_delay_usecs = 1,
687 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
688 static struct xpt2046_platform_data xpt2046_info = {
697 .debounce_rep = DEBOUNCE_REPTIME,
699 #if defined(CONFIG_MACH_RAHO)
700 .gpio_pendown = RK2818_PIN_PE1,
702 .gpio_pendown = RK2818_PIN_PE3,
704 .penirq_recheck_delay_usecs = 1,
707 static struct spi_board_info board_spi_devices[] = {
708 #if defined(CONFIG_SPI_FPGA)
709 { /* fpga ice65l08xx */
710 .modalias = "spi_fpga",
712 .max_speed_hz = 8 * 1000 * 1000,
717 #if defined(CONFIG_ENC28J60)
719 .modalias = "enc28j60",
721 .max_speed_hz = 12 * 1000 * 1000,
726 #if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI)\
727 ||defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
729 .modalias = "xpt2046_ts",
731 .max_speed_hz = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
733 .irq = XPT2046_GPIO_INT,
734 .platform_data = &xpt2046_info,
739 /*rk2818_fb gpio information*/
740 static struct rk2818_fb_gpio rk2818_fb_gpio_info = {
741 .display_on = (GPIO_LOW<<16)|RK2818_PIN_PB1,
746 /*rk2818_fb iomux information*/
747 static struct rk2818_fb_iomux rk2818_fb_iomux_info = {
748 .data16 = GPIOC_LCDC16BIT_SEL_NAME,
749 .data18 = GPIOC_LCDC18BIT_SEL_NAME,
750 .data24 = GPIOC_LCDC24BIT_SEL_NAME,
751 .den = CXGPIO_LCDDEN_SEL_NAME,
752 .vsync = CXGPIO_LCDVSYNC_SEL_NAME,
756 struct rk2818_fb_mach_info rk2818_fb_mach_info = {
757 .gpio = &rk2818_fb_gpio_info,
758 .iomux = &rk2818_fb_iomux_info,
761 /*****************************************************************************************
763 * author: nzy@rock-chips.com
764 *****************************************************************************************/
766 GPIOF2_APWM0_SEL_NAME, IOMUXB_PWM0
767 GPIOF3_APWM1_MMC0DETN_NAME, IOMUXA_PWM1
768 GPIOF4_APWM2_MMC0WPT_NAME, IOMUXA_PWM2
769 GPIOF5_APWM3_DPWM3_NAME, IOMUXB_PWM3
773 #define PWM_MUX_NAME GPIOF2_APWM0_SEL_NAME
774 #define PWM_MUX_MODE IOMUXB_PWM0
775 #define PWM_EFFECT_VALUE 0
778 #define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
779 #define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
781 #define BL_EN_PIN RK2818_PIN_PF3
782 #define BL_EN_VALUE GPIO_HIGH
786 static int rk2818_backlight_io_init(void)
790 rk2818_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
792 rk2818_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
794 ret = gpio_request(BL_EN_PIN, NULL);
797 gpio_free(BL_EN_PIN);
798 printk(KERN_ERR ">>>>>> lcd_cs gpio_request err \n ");
801 gpio_direction_output(BL_EN_PIN, 0);
802 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
807 static int rk2818_backlight_io_deinit(void)
811 gpio_free(BL_EN_PIN);
813 rk2818_mux_api_mode_resume(PWM_MUX_NAME);
815 rk2818_mux_api_mode_resume(BL_EN_MUX_NAME);
819 struct rk2818_bl_info rk2818_bl_info = {
821 .bl_ref = PWM_EFFECT_VALUE,
822 .io_init = rk2818_backlight_io_init,
823 .io_deinit = rk2818_backlight_io_deinit,
826 /********************************************************
827 * dm9000 net work devices
829 ********************************************************/
832 GPIOA5_FLASHCS1_SEL_NAME IOMUXB_FLASH_CS1
833 GPIOA6_FLASHCS2_SEL_NAME IOMUXB_FLASH_CS2
834 GPIOA7_FLASHCS3_SEL_NAME IOMUXB_FLASH_CS3
835 GPIOE_SPI1_FLASH_SEL1_NAME IOMUXA_FLASH_CS45
836 GPIOE_SPI1_FLASH_SEL_NAME IOMUXA_FLASH_CS67
838 #define DM9000_USE_NAND_CS 1 //cs can be 1,2,3,4,5,6 or 7
839 #define DM9000_CS_IOMUX_NAME GPIOA5_FLASHCS1_SEL_NAME
840 #define DM9000_CS_IOMUX_MODE IOMUXB_FLASH_CS1
841 #define DM9000_NET_INT_PIN RK2818_PIN_PA3
842 #define DM9000_INT_IOMUX_NAME GPIOA23_UART2_SEL_NAME
843 #define DM9000_INT_IOMUX_MODE IOMUXB_GPIO0_A23
844 #define DM9000_INT_INIT_VALUE GPIOPullDown
845 #define DM9000_IRQ IRQF_TRIGGER_HIGH
846 #define DM9000_IO_ADDR (RK2818_NANDC_PHYS + 0x800 + DM9000_USE_NAND_CS*0x100 + 0x8)
847 #define DM9000_DATA_ADDR (RK2818_NANDC_PHYS + 0x800 + DM9000_USE_NAND_CS*0x100 + 0x4)
849 static int dm9k_gpio_set(void)
852 rk2818_mux_api_set(DM9000_CS_IOMUX_NAME, DM9000_CS_IOMUX_MODE);
854 rk2818_mux_api_set(DM9000_INT_IOMUX_NAME, DM9000_INT_IOMUX_MODE);
858 static int dm9k_gpio_free(void)
860 rk2818_mux_api_mode_resume(DM9000_INT_IOMUX_NAME);
861 rk2818_mux_api_mode_resume(DM9000_CS_IOMUX_NAME);
865 static struct resource dm9k_resource[] = {
867 .start = DM9000_IO_ADDR,
868 .end = DM9000_IO_ADDR + 3,
869 .flags = IORESOURCE_MEM,
872 .start = DM9000_DATA_ADDR,
873 .end = DM9000_DATA_ADDR + 3,
874 .flags = IORESOURCE_MEM,
877 .start = DM9000_NET_INT_PIN,
878 .end = DM9000_NET_INT_PIN,
879 .flags = IORESOURCE_IRQ | DM9000_IRQ,
884 /* for the moment we limit ourselves to 8bit IO until some
885 * better IO routines can be written and tested
887 struct dm9000_plat_data dm9k_platdata = {
888 .flags = DM9000_PLATF_8BITONLY,
889 .irq_pin = DM9000_NET_INT_PIN,
890 .irq_pin_value = DM9000_INT_INIT_VALUE,
891 .io_init = dm9k_gpio_set,
892 .io_deinit = dm9k_gpio_free,
895 struct platform_device rk2818_device_dm9k = {
898 .num_resources = ARRAY_SIZE(dm9k_resource),
899 .resource = dm9k_resource,
901 .platform_data = &dm9k_platdata,
907 /*****************************************************************************************
909 * author: hxy@rock-chips.com
910 *****************************************************************************************/
912 GPIOA5_FLASHCS1_SEL_NAME, IOMUXB_FLASH_CS1
913 GPIOA6_FLASHCS2_SEL_NAME, IOMUXB_FLASH_CS2
914 GPIOA7_FLASHCS3_SEL_NAME, IOMUXB_FLASH_CS3
915 GPIOE_SPI1_FLASH_SEL1_NAME, IOMUXA_FLASH_CS45
916 GPIOE_SPI1_FLASH_SEL_NAME, IOMUXA_FLASH_CS67
919 #define NAND_CS_MAX_NUM 1 /*form 0 to 8, it is 0 when no nand flash */
921 int rk2818_nand_io_init(void)
923 #if (NAND_CS_MAX_NUM == 2)
924 rk2818_mux_api_set(GPIOA5_FLASHCS1_SEL_NAME, IOMUXB_FLASH_CS1);
925 #elif (NAND_CS_MAX_NUM == 3)
926 rk2818_mux_api_set(GPIOA5_FLASHCS1_SEL_NAME, IOMUXB_FLASH_CS1);
927 rk2818_mux_api_set(GPIOA6_FLASHCS2_SEL_NAME, IOMUXB_FLASH_CS2);
928 #elif (NAND_CS_MAX_NUM == 4)
929 rk2818_mux_api_set(GPIOA5_FLASHCS1_SEL_NAME, IOMUXB_FLASH_CS1);
930 rk2818_mux_api_set(GPIOA6_FLASHCS2_SEL_NAME, IOMUXB_FLASH_CS2);
931 rk2818_mux_api_set(GPIOA7_FLASHCS3_SEL_NAME, IOMUXB_FLASH_CS3);
932 #elif ((NAND_CS_MAX_NUM == 5) || (NAND_CS_MAX_NUM == 6))
933 rk2818_mux_api_set(GPIOA5_FLASHCS1_SEL_NAME, IOMUXB_FLASH_CS1);
934 rk2818_mux_api_set(GPIOA6_FLASHCS2_SEL_NAME, IOMUXB_FLASH_CS2);
935 rk2818_mux_api_set(GPIOA7_FLASHCS3_SEL_NAME, IOMUXB_FLASH_CS3);
936 rk2818_mux_api_set(GPIOE_SPI1_FLASH_SEL1_NAME, IOMUXA_FLASH_CS45);
937 #elif ((NAND_CS_MAX_NUM == 7) || (NAND_CS_MAX_NUM == 8))
938 rk2818_mux_api_set(GPIOA5_FLASHCS1_SEL_NAME, IOMUXB_FLASH_CS1);
939 rk2818_mux_api_set(GPIOA6_FLASHCS2_SEL_NAME, IOMUXB_FLASH_CS2);
940 rk2818_mux_api_set(GPIOA7_FLASHCS3_SEL_NAME, IOMUXB_FLASH_CS3);
941 rk2818_mux_api_set(GPIOE_SPI1_FLASH_SEL1_NAME, IOMUXA_FLASH_CS45);
942 rk2818_mux_api_set(GPIOE_SPI1_FLASH_SEL_NAME, IOMUXA_FLASH_CS67);
947 struct rk2818_nand_platform_data rk2818_nand_data = {
948 .width = 1, /* data bus width in bytes */
949 .hw_ecc = 1, /* hw ecc 0: soft ecc */
951 .io_init = rk2818_nand_io_init,
955 /*****************************************/
957 static struct platform_device *devices[] __initdata = {
958 &rk2818_device_uart1,
959 #ifdef CONFIG_I2C0_RK2818
962 #ifdef CONFIG_I2C1_RK2818
965 #ifdef CONFIG_SDMMC0_RK2818
966 &rk2818_device_sdmmc0,
968 #ifdef CONFIG_SDMMC1_RK2818
969 &rk2818_device_sdmmc1,
973 #if defined(CONFIG_ANDROID_PMEM)
975 &rk2818_device_pmem_dsp,
978 &rk2818_device_adckey,
979 &rk2818_device_battery,
981 &rk2818_device_backlight,
983 #ifdef CONFIG_MTD_NAND_RK2818
990 #ifdef CONFIG_DWC_OTG
991 &rk2818_device_dwc_otg,
993 #ifdef CONFIG_RK2818_HOST11
994 &rk2818_device_host11,
996 #ifdef CONFIG_USB_ANDROID
998 &usb_mass_storage_device,
1003 extern struct sys_timer rk2818_timer;
1004 #define POWER_PIN RK2818_PIN_PH7
1005 static void rk2818_power_on(void)
1008 ret = gpio_request(POWER_PIN, NULL);
1010 printk("failed to request power_off gpio\n");
1014 gpio_pull_updown(POWER_PIN, GPIOPullUp);
1015 ret = gpio_direction_output(POWER_PIN, GPIO_HIGH);
1017 printk("failed to set power_off gpio output\n");
1021 gpio_set_value(POWER_PIN, 1);/*power on*/
1024 gpio_free(POWER_PIN);
1027 static void rk2818_power_off(void)
1029 printk("shut down system now ...\n");
1030 gpio_set_value(POWER_PIN, 0);/*power down*/
1033 void lcd_set_iomux(u8 enable)
1039 rk2818_mux_api_set(CXGPIO_HSADC_SEL_NAME, 0);
1040 ret = gpio_request(RK2818_PIN_PA4, NULL);
1043 gpio_free(RK2818_PIN_PA4);
1044 printk(">>>>>> lcd cs gpio_request err \n ");
1048 rk2818_mux_api_set(GPIOE_U1IR_I2C1_NAME, 0);
1050 ret = gpio_request(RK2818_PIN_PE7, NULL);
1053 gpio_free(RK2818_PIN_PE7);
1054 printk(">>>>>> lcd clk gpio_request err \n ");
1058 ret = gpio_request(RK2818_PIN_PE6, NULL);
1061 gpio_free(RK2818_PIN_PE6);
1062 printk(">>>>>> lcd txd gpio_request err \n ");
1068 gpio_free(RK2818_PIN_PA4);
1069 //rk2818_mux_api_set(CXGPIO_HSADC_SEL_NAME, 1);
1070 rk2818_mux_api_mode_resume(CXGPIO_HSADC_SEL_NAME);
1072 gpio_free(RK2818_PIN_PE7);
1073 gpio_free(RK2818_PIN_PE6);
1074 //rk2818_mux_api_set(GPIOE_U1IR_I2C1_NAME, 2);
1075 rk2818_mux_api_mode_resume(GPIOE_U1IR_I2C1_NAME);
1083 struct lcd_td043mgea1_data lcd_td043mgea1 = {
1084 .pin_txd = RK2818_PIN_PE6,
1085 .pin_clk = RK2818_PIN_PE7,
1086 .pin_cs = RK2818_PIN_PA4,
1087 .screen_set_iomux = lcd_set_iomux,
1091 #define PLAY_ON_PIN RK2818_PIN_PE1
1092 #define PLAY_ON_LEVEL 1
1093 static ADC_keyst gAdcValueTab[] =
1095 {95, AD2KEY1},///VOLUME_DOWN
1096 {249, AD2KEY2},///VOLUME_UP
1097 {408, AD2KEY3},///MENU
1098 {560, AD2KEY4},///HOME
1099 {725, AD2KEY5},///BACK
1100 {816, AD2KEY6},///CALL
1104 static unsigned char gInitKeyCode[] =
1106 AD2KEY1,AD2KEY2,AD2KEY3,AD2KEY4,AD2KEY5,AD2KEY6,
1107 ENDCALL,KEYSTART,KEY_WAKEUP,
1110 struct adc_key_data rk2818_adc_key = {
1111 .pin_playon = PLAY_ON_PIN,
1112 .playon_level = PLAY_ON_LEVEL,
1117 .adc_key_table = gAdcValueTab,
1118 .initKeyCode = gInitKeyCode,
1121 struct rk2818_adckey_platform_data rk2818_adckey_platdata = {
1122 .adc_key = &rk2818_adc_key,
1124 #if CONFIG_ANDROID_TIMED_GPIO
1125 struct timed_gpio_platform_data rk28_vibrator_info = {
1130 static void __init machine_rk2818_init_irq(void)
1133 rk2818_gpio_init(rk2818_gpioBank, 8);
1134 rk2818_gpio_irq_setup();
1137 static void __init machine_rk2818_board_init(void)
1140 pm_power_off = rk2818_power_off;
1141 #ifdef CONFIG_I2C0_RK2818
1142 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
1143 ARRAY_SIZE(board_i2c0_devices));
1145 #ifdef CONFIG_I2C1_RK2818
1146 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
1147 ARRAY_SIZE(board_i2c1_devices));
1149 #ifdef CONFIG_SPI_I2C
1150 i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
1151 ARRAY_SIZE(board_i2c2_devices));
1152 i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
1153 ARRAY_SIZE(board_i2c3_devices));
1155 platform_add_devices(devices, ARRAY_SIZE(devices));
1156 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1157 //rk2818_mux_api_set(GPIOB4_SPI0CS0_MMC0D4_NAME,IOMUXA_GPIO0_B4); //IOMUXA_SPI0_CSN0);//use for gpio SPI CS0
1158 //rk2818_mux_api_set(GPIOB0_SPI0CSN1_MMC1PCA_NAME,IOMUXA_GPIO0_B0); //IOMUXA_SPI0_CSN1);//use for gpio SPI CS1
1159 //rk2818_mux_api_set(GPIOB_SPI0_MMC0_NAME,IOMUXA_SPI0);//use for SPI CLK SDI SDO
1162 static void __init machine_rk2818_mapio(void)
1164 iotable_init(rk2818_io_desc, ARRAY_SIZE(rk2818_io_desc));
1165 rk2818_clock_init();
1166 rk2818_iomux_init();
1169 MACHINE_START(RK2818, "RK28board")
1171 /* UART for LL DEBUG */
1172 .phys_io = 0x18002000,
1173 .io_pg_offst = ((0xFF100000) >> 18) & 0xfffc,
1174 .boot_params = RK2818_SDRAM_PHYS + 0x88000,
1175 .map_io = machine_rk2818_mapio,
1176 .init_irq = machine_rk2818_init_irq,
1177 .init_machine = machine_rk2818_board_init,
1178 .timer = &rk2818_timer,