1 /* linux/arch/arm/mach-rk2818/board-midsdk.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>
38 #include <linux/mtd/nand.h>
39 #include <linux/mtd/partitions.h>
44 /* --------------------------------------------------------------------
45 * ÉùÃ÷ÁËrk2818_gpioBankÊý×飬²¢¶¨ÒåÁËGPIO¼Ä´æÆ÷×éIDºÍ¼Ä´æÆ÷»ùµØÖ·¡£
46 * -------------------------------------------------------------------- */
48 static struct rk2818_gpio_bank rk2818_gpioBank[] = {
51 .offset = RK2818_GPIO0_BASE,
56 .offset = RK2818_GPIO0_BASE,
61 .offset = RK2818_GPIO0_BASE,
66 .offset = RK2818_GPIO0_BASE,
71 .offset = RK2818_GPIO1_BASE,
76 .offset = RK2818_GPIO1_BASE,
81 .offset = RK2818_GPIO1_BASE,
86 .offset = RK2818_GPIO1_BASE,
91 //IOÓ³É䷽ʽÃèÊö £¬Ã¿¸öΪһ¶ÎÏßÐÔÁ¬ÐøÓ³Éä
92 static struct map_desc rk2818_io_desc[] __initdata = {
95 .virtual = RK2818_MCDMA_BASE, //ÐéÄâµØÖ·
96 .pfn = __phys_to_pfn(RK2818_MCDMA_PHYS), //ÎïÀíµØÖ·£¬ÐëÓëÒ³±í¶ÔÆë
97 .length = RK2818_MCDMA_SIZE, //³¤¶È
98 .type = MT_DEVICE //Ó³É䷽ʽ
102 .virtual = RK2818_DWDMA_BASE,
103 .pfn = __phys_to_pfn(RK2818_DWDMA_PHYS),
104 .length = RK2818_DWDMA_SIZE,
109 .virtual = RK2818_INTC_BASE,
110 .pfn = __phys_to_pfn(RK2818_INTC_PHYS),
111 .length = RK2818_INTC_SIZE,
116 .virtual = RK2818_NANDC_BASE,
117 .pfn = __phys_to_pfn(RK2818_NANDC_PHYS),
118 .length = RK2818_NANDC_SIZE,
123 .virtual = RK2818_SDRAMC_BASE,
124 .pfn = __phys_to_pfn(RK2818_SDRAMC_PHYS),
125 .length = RK2818_SDRAMC_SIZE,
130 .virtual = RK2818_ARMDARBITER_BASE,
131 .pfn = __phys_to_pfn(RK2818_ARMDARBITER_PHYS),
132 .length = RK2818_ARMDARBITER_SIZE,
137 .virtual = RK2818_APB_BASE,
138 .pfn = __phys_to_pfn(RK2818_APB_PHYS),
144 .virtual = RK2818_WDT_BASE,
145 .pfn = __phys_to_pfn(RK2818_WDT_PHYS),
146 .length = 0xa0000, ///apb bus i2s i2c spi no map in this
150 /*****************************************************************************************
153 *****************************************************************************************/
154 void rk2818_sdmmc0_cfg_gpio(struct platform_device *dev)
156 rk2818_mux_api_set(GPIOF3_APWM1_MMC0DETN_NAME, IOMUXA_SDMMC1_DETECT_N);
157 rk2818_mux_api_set(GPIOH_MMC0D_SEL_NAME, IOMUXA_SDMMC0_DATA123);
158 rk2818_mux_api_set(GPIOH_MMC0_SEL_NAME, IOMUXA_SDMMC0_CMD_DATA0_CLKOUT);
161 void rk2818_sdmmc1_cfg_gpio(struct platform_device *dev)
163 rk2818_mux_api_set(GPIOG_MMC1_SEL_NAME, IOMUXA_SDMMC1_CMD_DATA0_CLKOUT);
164 rk2818_mux_api_set(GPIOG_MMC1D_SEL_NAME, IOMUXA_SDMMC1_DATA123);
166 /* wifi power up (gpio control) */
167 rk2818_mux_api_set(GPIOH7_HSADCCLK_SEL_NAME,IOMUXB_GPIO1_D7);
168 rk2818_mux_api_set(GPIOF5_APWM3_DPWM3_NAME,IOMUXB_GPIO1_B5);
169 gpio_request(RK2818_PIN_PH7, "sdio");
170 gpio_direction_output(RK2818_PIN_PH7,GPIO_HIGH);
174 #define CONFIG_SDMMC0_USE_DMA
175 #define CONFIG_SDMMC1_USE_DMA
176 struct rk2818_sdmmc_platform_data default_sdmmc0_data = {
177 .host_ocr_avail = (MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
178 MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
179 MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
180 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
181 .cfg_gpio = rk2818_sdmmc0_cfg_gpio,
183 .dma_name = "sd_mmc",
184 #ifdef CONFIG_SDMMC0_USE_DMA
190 struct rk2818_sdmmc_platform_data default_sdmmc1_data = {
191 .host_ocr_avail = (MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
192 MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
193 MMC_VDD_32_33|MMC_VDD_33_34),
194 .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
195 MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
196 .cfg_gpio = rk2818_sdmmc1_cfg_gpio,
199 #ifdef CONFIG_SDMMC1_USE_DMA
206 /*****************************************************************************************
207 * extern gpio devices
209 *****************************************************************************************/
210 #if defined (CONFIG_GPIO_PCA9554)
211 struct rk2818_gpio_expander_info extern_gpio_settinginfo[] = {
213 .gpio_num =RK2818_PIN_PI0,
215 //.pin_value =GPIO_HIGH,
219 .gpio_num =RK2818_PIN_PI4,// tp3
221 //.pin_value =GPIO_HIGH,
225 .gpio_num =RK2818_PIN_PI5,//tp4
227 //.pin_value =GPIO_HIGH,
230 .gpio_num =RK2818_PIN_PI6,//tp2
231 .pin_type = GPIO_OUT,
232 //.pin_value =GPIO_HIGH,
235 .gpio_num =RK2818_PIN_PI7,//tp1
236 .pin_type = GPIO_OUT,
237 .pin_value =GPIO_HIGH,
244 struct pca9554_platform_data rk2818_pca9554_data={
245 .gpio_base=GPIOS_EXPANDER_BASE,
246 .gpio_pin_num=CONFIG_EXPANDED_GPIO_NUM,
247 .gpio_irq_start=NR_AIC_IRQS + 2*NUM_GROUP,
248 .irq_pin_num=CONFIG_EXPANDED_GPIO_IRQ_NUM,
249 .pca9954_irq_pin=RK2818_PIN_PE2,
250 .settinginfo=extern_gpio_settinginfo,
251 .settinginfolen=ARRAY_SIZE(extern_gpio_settinginfo),
256 /*****************************************************************************************
259 *****************************************************************************************/
260 void rk2818_i2c0_cfg_gpio(struct platform_device *dev)
262 rk2818_mux_api_set(GPIOE_I2C0_SEL_NAME, IOMUXA_I2C0);
265 void rk2818_i2c1_cfg_gpio(struct platform_device *dev)
267 rk2818_mux_api_set(GPIOE_U1IR_I2C1_NAME, IOMUXA_I2C1);
269 struct rk2818_i2c_platform_data default_i2c0_data = {
273 .scl_rate = 400*1000,
274 .cfg_gpio = rk2818_i2c0_cfg_gpio,
276 struct rk2818_i2c_platform_data default_i2c1_data = {
277 #ifdef CONFIG_I2C0_RK2818
284 .scl_rate = 400*1000,
285 .cfg_gpio = rk2818_i2c1_cfg_gpio,
288 static struct i2c_board_info __initdata board_i2c0_devices[] = {
289 #if defined (CONFIG_RK1000_CONTROL)
291 .type = "rk1000_control",
297 #if defined (CONFIG_RK1000_TVOUT)
299 .type = "rk1000_tvout",
304 #if defined (CONFIG_SND_SOC_RK1000)
306 .type = "rk1000_i2c_codec",
311 #if defined (CONFIG_SND_SOC_WM8988)
319 static struct i2c_board_info __initdata board_i2c1_devices[] = {
320 #if defined (CONFIG_RTC_HYM8563)
322 .type = "rtc_hym8563",
327 #if defined (CONFIG_FM_QN8006)
334 #if defined (CONFIG_GPIO_PCA9554)
336 .type = "extend_gpio_pca9554",
339 .platform_data=&rk2818_pca9554_data.gpio_base,
346 /*****************************************************************************************
349 *****************************************************************************************/
350 static struct spi_board_info board_spi_devices[] = {
351 #if defined(CONFIG_ENC28J60)
353 .modalias = "enc28j60",
355 .max_speed_hz = 12 * 1000 * 1000,
360 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
362 .modalias = "xpt2046_ts",
364 .max_speed_hz = 1000000,/* (max sample rate @ 3V) * (cmd + data + overhead) */
366 .irq = RK2818_PIN_PE3,
371 /*rk2818_fb gpio information*/
372 static struct rk2818_fb_gpio rk2818_fb_gpio_info = {
374 .display_on = (GPIO_LOW<<16)|RK2818_PIN_PA2,
379 /*rk2818_fb iomux information*/
380 static struct rk2818_fb_iomux rk2818_fb_iomux_info = {
381 .data16 = GPIOC_LCDC16BIT_SEL_NAME,
382 .data18 = GPIOC_LCDC18BIT_SEL_NAME,
383 .data24 = GPIOC_LCDC24BIT_SEL_NAME,
384 .den = CXGPIO_LCDDEN_SEL_NAME,
385 .vsync = CXGPIO_LCDVSYNC_SEL_NAME,
389 struct rk2818_fb_mach_info rk2818_fb_mach_info = {
390 .gpio = &rk2818_fb_gpio_info,
391 .iomux = &rk2818_fb_iomux_info,
394 struct rk2818bl_info rk2818_bl_info = {
396 .pw_pin = GPIO_HIGH | (RK2818_PIN_PA3<< 8) ,
398 .pw_iomux = GPIOA23_UART2_SEL_NAME,
401 static struct platform_device *devices[] __initdata = {
402 &rk2818_device_uart1,
404 #ifdef CONFIG_I2C0_RK2818
407 #ifdef CONFIG_I2C1_RK2818
410 #ifdef CONFIG_SDMMC0_RK2818
411 &rk2818_device_sdmmc0,
413 #ifdef CONFIG_SDMMC1_RK2818
414 &rk2818_device_sdmmc1,
418 #if defined(CONFIG_ANDROID_PMEM)
420 &rk2818_device_pmem_dsp,
423 &rk2818_device_adckey,
424 &rk2818_device_battery,
426 &rk2818_device_backlight,
428 #ifdef CONFIG_MTD_NAND_RK2818
433 extern struct sys_timer rk2818_timer;
434 #define POWER_PIN RK2818_PIN_PA3
435 static void rk2818_power_on(void)
438 ret = gpio_request(POWER_PIN, NULL);
440 printk("failed to request power_off gpio\n");
444 gpio_pull_updown(POWER_PIN, GPIOPullUp);
445 ret = gpio_direction_output(POWER_PIN, GPIO_HIGH);
447 printk("failed to set power_off gpio output\n");
451 gpio_set_value(POWER_PIN, 1);/*power on*/
454 gpio_free(POWER_PIN);
457 static void rk2818_power_off(void)
459 printk("shut down system now ...\n");
460 gpio_set_value(POWER_PIN, 0);/*power down*/
463 static void __init machine_rk2818_init_irq(void)
466 rk2818_gpio_init(rk2818_gpioBank, 8);
467 rk2818_gpio_irq_setup();
470 static void __init machine_rk2818_board_init(void)
473 pm_power_off = rk2818_power_off;
474 #ifdef CONFIG_I2C0_RK2818
475 i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
476 ARRAY_SIZE(board_i2c0_devices));
478 #ifdef CONFIG_I2C1_RK2818
479 i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
480 ARRAY_SIZE(board_i2c1_devices));
482 platform_add_devices(devices, ARRAY_SIZE(devices));
483 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
484 rk2818_mux_api_set(GPIOB4_SPI0CS0_MMC0D4_NAME,IOMUXA_GPIO0_B4); //IOMUXA_SPI0_CSN0);//use for gpio SPI CS0
485 rk2818_mux_api_set(GPIOB0_SPI0CSN1_MMC1PCA_NAME,IOMUXA_GPIO0_B0); //IOMUXA_SPI0_CSN1);//use for gpio SPI CS1
486 rk2818_mux_api_set(GPIOB_SPI0_MMC0_NAME,IOMUXA_SPI0);//use for SPI CLK SDI SDO
489 static void __init machine_rk2818_mapio(void)
491 iotable_init(rk2818_io_desc, ARRAY_SIZE(rk2818_io_desc));
496 MACHINE_START(RK2818, "RK28board")
498 /* UART for LL DEBUG */
499 .phys_io = 0x18002000,
500 .io_pg_offst = ((0xFF100000) >> 18) & 0xfffc,
501 .boot_params = RK2818_SDRAM_PHYS + 0xf8000,
502 .map_io = machine_rk2818_mapio,
503 .init_irq = machine_rk2818_init_irq,
504 .init_machine = machine_rk2818_board_init,
505 .timer = &rk2818_timer,