1 /* arch/arm/mach-rk30/board-rk30-sdk.c
3 * Copyright (C) 2012 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/skbuff.h>
24 #include <linux/spi/spi.h>
25 #include <linux/mmc/host.h>
26 #include <linux/ion.h>
28 #include <asm/setup.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
32 #include <asm/mach/flash.h>
33 #include <asm/hardware/gic.h>
35 #include <mach/board.h>
36 #include <mach/hardware.h>
38 #include <mach/gpio.h>
39 #include <mach/iomux.h>
40 /*set touchscreen different type header*/
41 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI)
42 #include "../../../drivers/input/touchscreen/xpt2046_ts.h"
43 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
44 #include "../../../drivers/input/touchscreen/xpt2046_tslib_ts.h"
45 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
46 #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h"
48 #if defined(CONFIG_SPIM_RK29)
49 #include "../../../drivers/spi/rk29_spim.h"
52 #define RK30_FB0_MEM_SIZE 8*SZ_1M
55 /*****************************************************************************************
57 * author: hhb@rock-chips.com
58 *****************************************************************************************/
59 #if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
60 #define XPT2046_GPIO_INT RK30_PIN4_PC2
61 #define DEBOUNCE_REPTIME 3
64 static struct xpt2046_platform_data xpt2046_info = {
69 .debounce_rep = DEBOUNCE_REPTIME,
71 .gpio_pendown = XPT2046_GPIO_INT,
72 .pendown_iomux_name = GPIO4C2_SMCDATA2_TRACEDATA2_NAME,
73 .pendown_iomux_mode = GPIO4C_GPIO4C2,
74 .touch_virtualkey_length = 60,
75 .penirq_recheck_delay_usecs = 1,
76 #if defined(CONFIG_TOUCHSCREEN_480X800)
82 .touch_ad_bottom = 310,
83 .touch_ad_left = 3772,
84 .touch_ad_right = 340,
85 #elif defined(CONFIG_TOUCHSCREEN_800X480)
91 .touch_ad_bottom = 207,
92 .touch_ad_left = 5938,
93 .touch_ad_right = 153,
94 #elif defined(CONFIG_TOUCHSCREEN_320X480)
100 .touch_ad_bottom = 256,
101 .touch_ad_left = 3658,
102 .touch_ad_right = 380,
105 #elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
106 static struct xpt2046_platform_data xpt2046_info = {
111 .debounce_rep = DEBOUNCE_REPTIME,
113 .gpio_pendown = XPT2046_GPIO_INT,
114 .pendown_iomux_name = GPIO4C2_SMCDATA2_TRACEDATA2_NAME,
115 .pendown_iomux_mode = GPIO4C_GPIO4C2,
116 .touch_virtualkey_length = 60,
117 .penirq_recheck_delay_usecs = 1,
119 #if defined(CONFIG_TOUCHSCREEN_480X800)
124 .screen_x = { 70, 410, 70, 410, 240},
125 .screen_y = { 50, 50, 740, 740, 400},
126 .uncali_x_default = { 3267, 831, 3139, 715, 1845 },
127 .uncali_y_default = { 3638, 3664, 564, 591, 2087 },
128 #elif defined(CONFIG_TOUCHSCREEN_800X480)
133 .screen_x[5] = { 50, 750, 50, 750, 400};
134 .screen_y[5] = { 40, 40, 440, 440, 240};
135 .uncali_x_default[5] = { 438, 565, 3507, 3631, 2105 };
136 .uncali_y_default[5] = { 3756, 489, 3792, 534, 2159 };
137 #elif defined(CONFIG_TOUCHSCREEN_320X480)
142 .screen_x[5] = { 50, 270, 50, 270, 160};
143 .screen_y[5] = { 40, 40, 440, 440, 240};
144 .uncali_x_default[5] = { 812, 3341, 851, 3371, 2183 };
145 .uncali_y_default[5] = { 442, 435, 3193, 3195, 2004 };
149 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
150 static struct rk29xx_spi_chip xpt2046_chip = {
155 static struct spi_board_info board_spi_devices[] = {
156 #if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
158 .modalias = "xpt2046_ts",
159 .chip_select = 1,// 2,
160 .max_speed_hz = 1 * 1000 * 800,/* (max sample rate @ 3V) * (cmd + data + overhead) */
162 .irq = XPT2046_GPIO_INT,
163 .platform_data = &xpt2046_info,
164 .controller_data = &xpt2046_chip,
171 /***********************************************************
173 ************************************************************/
174 #ifdef CONFIG_BACKLIGHT_RK29_BL
176 #define PWM_MUX_NAME GPIO0A3_PWM0_NAME
177 #define PWM_MUX_MODE GPIO0A_PWM0
178 #define PWM_MUX_MODE_GPIO GPIO0A_GPIO0A3
179 #define PWM_GPIO RK30_PIN0_PA3
180 #define PWM_EFFECT_VALUE 1
182 #define LCD_DISP_ON_PIN
184 #ifdef LCD_DISP_ON_PIN
185 //#define BL_EN_MUX_NAME GPIOF34_UART3_SEL_NAME
186 //#define BL_EN_MUX_MODE IOMUXB_GPIO1_B34
188 #define BL_EN_PIN INVALID_GPIO //?
189 #define BL_EN_VALUE GPIO_HIGH
191 static int rk29_backlight_io_init(void)
194 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
195 #ifdef LCD_DISP_ON_PIN
196 // rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
198 ret = gpio_request(BL_EN_PIN, NULL);
201 gpio_free(BL_EN_PIN);
204 gpio_direction_output(BL_EN_PIN, 0);
205 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
210 static int rk29_backlight_io_deinit(void)
213 #ifdef LCD_DISP_ON_PIN
214 gpio_free(BL_EN_PIN);
216 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
220 static int rk29_backlight_pwm_suspend(void)
223 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
224 if (gpio_request(PWM_GPIO, NULL)) {
225 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
228 gpio_direction_output(PWM_GPIO, GPIO_LOW);
229 #ifdef LCD_DISP_ON_PIN
230 gpio_direction_output(BL_EN_PIN, 0);
231 gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
236 static int rk29_backlight_pwm_resume(void)
239 rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
240 #ifdef LCD_DISP_ON_PIN
242 gpio_direction_output(BL_EN_PIN, 1);
243 gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
248 static struct rk29_bl_info rk29_bl_info = {
250 .bl_ref = PWM_EFFECT_VALUE,
251 .io_init = rk29_backlight_io_init,
252 .io_deinit = rk29_backlight_io_deinit,
253 .pwm_suspend = rk29_backlight_pwm_suspend,
254 .pwm_resume = rk29_backlight_pwm_resume,
258 static struct platform_device rk29_device_backlight = {
259 .name = "rk29_backlight",
262 .platform_data = &rk29_bl_info,
269 #if defined (CONFIG_GS_MMA8452)
270 #define MMA8452_INT_PIN RK30_PIN4_PC0
272 static int mma8452_init_platform_hw(void)
274 rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
276 if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
277 gpio_free(MMA8452_INT_PIN);
278 printk("mma8452_init_platform_hw gpio_request error\n");
281 gpio_pull_updown(MMA8452_INT_PIN, 1);
286 static struct mma8452_platform_data mma8452_info = {
290 .init_platform_hw= mma8452_init_platform_hw,
291 .orientation = { -1, 0, 0, 0, 0, 1, 0, -1, 0},
294 #if defined(CONFIG_GYRO_L3G4200D)
296 #include <linux/l3g4200d.h>
297 #define L3G4200D_INT_PIN RK30_PIN4_PC3
299 static int l3g4200d_init_platform_hw(void)
301 if (gpio_request(L3G4200D_INT_PIN, NULL) != 0) {
302 gpio_free(L3G4200D_INT_PIN);
303 printk("%s: request l3g4200d int pin error\n", __func__);
306 gpio_pull_updown(L3G4200D_INT_PIN, 1);
310 static struct l3g4200d_platform_data l3g4200d_info = {
321 .init = l3g4200d_init_platform_hw,
327 #ifdef CONFIG_FB_ROCKCHIP
328 static struct resource resource_fb[] = {
332 .end = 0,//RK30_FB0_MEM_SIZE - 1,
333 .flags = IORESOURCE_MEM,
336 .name = "ipp buf", //for rotate
338 .end = 0,//RK30_FB0_MEM_SIZE - 1,
339 .flags = IORESOURCE_MEM,
344 .end = 0,//RK30_FB0_MEM_SIZE - 1,
345 .flags = IORESOURCE_MEM,
349 static struct platform_device device_fb = {
352 .num_resources = ARRAY_SIZE(resource_fb),
353 .resource = resource_fb,
357 static struct platform_device *devices[] __initdata = {
358 #ifdef CONFIG_BACKLIGHT_RK29_BL
359 &rk29_device_backlight,
361 #ifdef CONFIG_FB_ROCKCHIP
367 #ifdef CONFIG_I2C0_RK30
368 static struct i2c_board_info __initdata i2c0_info[] = {
369 #if defined (CONFIG_GS_MMA8452)
371 .type = "gs_mma8452",
374 .irq = MMA8452_INT_PIN,
375 .platform_data = &mma8452_info,
378 #if defined (CONFIG_GYRO_L3G4200D)
380 .type = "l3g4200d_gryo",
383 .irq = L3G4200D_INT_PIN,
384 .platform_data = &l3g4200d_info,
388 #if defined (CONFIG_SND_SOC_RK1000)
390 .type = "rk1000_i2c_codec",
395 .type = "rk1000_control",
403 #ifdef CONFIG_I2C1_RK30
404 static struct i2c_board_info __initdata i2c1_info[] = {
408 #ifdef CONFIG_I2C2_RK30
409 static struct i2c_board_info __initdata i2c2_info[] = {
413 #ifdef CONFIG_I2C3_RK30
414 static struct i2c_board_info __initdata i2c3_info[] = {
418 #ifdef CONFIG_I2C4_RK30
419 static struct i2c_board_info __initdata i2c4_info[] = {
423 static void __init rk30_i2c_register_board_info(void)
425 #ifdef CONFIG_I2C0_RK30
426 i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
428 #ifdef CONFIG_I2C1_RK30
429 i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
431 #ifdef CONFIG_I2C2_RK30
432 i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
434 #ifdef CONFIG_I2C3_RK30
435 i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
437 #ifdef CONFIG_I2C4_RK30
438 i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
443 static void __init machine_rk30_board_init(void)
445 rk30_i2c_register_board_info();
446 spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
447 platform_add_devices(devices, ARRAY_SIZE(devices));
450 static void __init rk30_reserve(void)
452 #ifdef CONFIG_FB_ROCKCHIP
453 resource_fb[0].start = board_mem_reserve_add("fb0",RK30_FB0_MEM_SIZE);
454 resource_fb[0].end = resource_fb[0].start + RK30_FB0_MEM_SIZE - 1;
455 resource_fb[1].start = board_mem_reserve_add("ipp buf",RK30_FB0_MEM_SIZE);
456 resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
457 resource_fb[2].start = board_mem_reserve_add("fb2",RK30_FB0_MEM_SIZE);
458 resource_fb[2].end = resource_fb[2].start + RK30_FB0_MEM_SIZE - 1;
460 board_mem_reserved();
463 MACHINE_START(RK30, "RK30board")
464 .boot_params = PLAT_PHYS_OFFSET + 0x800,
466 .reserve = &rk30_reserve,
467 .map_io = rk30_map_io,
468 .init_irq = rk30_init_irq,
469 .timer = &rk30_timer,
470 .init_machine = machine_rk30_board_init,