ARM64: DTS: Add rk3399-firefly uart4 device, node as /dev/ttyS1
[firefly-linux-kernel-4.4.55.git] / board-rk30-phone-a22.c
1 /* arch/arm/mach-rk30/board-rk30-sdk.c
2  *
3  * Copyright (C) 2012 ROCKCHIP, Inc.
4  *
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.
8  *
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.
13  *
14  */
15
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/input.h>
20 #include <linux/io.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>
27 #include <linux/cpufreq.h>
28 #include <linux/clk.h>
29 #include <mach/dvfs.h>
30
31 #include <asm/setup.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
35 #include <asm/mach/flash.h>
36 #include <asm/hardware/gic.h>
37
38 #include <mach/board.h>
39 #include <mach/hardware.h>
40 #include <mach/io.h>
41 #include <mach/gpio.h>
42 #include <mach/iomux.h>
43 #include <linux/mpu.h>
44 #include <linux/fb.h>
45 #include <linux/wimo.h>
46
47 #if defined(CONFIG_HDMI_RK30)
48         #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
49 #endif
50
51 #include <linux/regulator/fixed.h>
52 #include <linux/mfd/wm8994/pdata.h>
53 #include <linux/regulator/machine.h>
54 #include "../../../drivers/headset_observe/rk_headset.h"
55 #include <linux/regulator/rk29-pwm-regulator.h>
56
57 #if defined(CONFIG_SPIM_RK29)
58 #include "../../../drivers/spi/rk29_spim.h"
59 #endif
60 #if defined(CONFIG_ANDROID_TIMED_GPIO)
61 #include "../../../drivers/staging/android/timed_gpio.h"
62 #endif
63 #if defined(CONFIG_BACKLIGHT_AW9364)
64 #include "../../../drivers/video/backlight/aw9364_bl.h"
65 #endif
66 #if defined(CONFIG_RK29_SC8800)
67 #include "../../../drivers/tty/serial/sc8800.h"
68 #endif
69 #if defined(CONFIG_TDSC8800)
70 #include <linux/mtk23d.h>
71 #endif
72 #if defined(CONFIG_SMS_SPI_ROCKCHIP)
73 #include "../../../drivers/cmmb/siano/smsspiphy.h"
74 #endif
75
76
77 #define RK30_FB0_MEM_SIZE 8*SZ_1M
78
79 #ifdef CONFIG_VIDEO_RK29
80 /*---------------- Camera Sensor Macro Define Begin  ------------------------*/
81 /*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
82 #define CONFIG_SENSOR_0 RK29_CAM_SENSOR_MT9T111                                         /* back camera sensor */
83 #define CONFIG_SENSOR_IIC_ADDR_0                0x78
84 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0    4
85 #define CONFIG_SENSOR_CIF_INDEX_0                    1
86 #define CONFIG_SENSOR_ORIENTATION_0       90
87 #define CONFIG_SENSOR_POWER_PIN_0                 RK30_PIN4_PC6
88 #define CONFIG_SENSOR_RESET_PIN_0                 INVALID_GPIO
89 #define CONFIG_SENSOR_POWERDN_PIN_0       RK30_PIN1_PD6
90 #define CONFIG_SENSOR_FALSH_PIN_0                 INVALID_GPIO
91 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_H
92 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
93 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
94 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_H
95
96 #define CONFIG_SENSOR_QCIF_FPS_FIXED_0          15000
97 #define CONFIG_SENSOR_240X160_FPS_FIXED_0   15000
98 #define CONFIG_SENSOR_QVGA_FPS_FIXED_0          15000
99 #define CONFIG_SENSOR_CIF_FPS_FIXED_0           15000
100 #define CONFIG_SENSOR_VGA_FPS_FIXED_0           15000
101 #define CONFIG_SENSOR_480P_FPS_FIXED_0          15000
102 #define CONFIG_SENSOR_SVGA_FPS_FIXED_0          15000
103 #define CONFIG_SENSOR_720P_FPS_FIXED_0          30000
104
105 #define CONFIG_SENSOR_01  RK29_CAM_SENSOR_OV5642                   /* back camera sensor 1 */
106 #define CONFIG_SENSOR_IIC_ADDR_01           0x00
107 #define CONFIG_SENSOR_CIF_INDEX_01                    1
108 #define CONFIG_SENSOR_IIC_ADAPTER_ID_01    4
109 #define CONFIG_SENSOR_ORIENTATION_01       90
110 #define CONFIG_SENSOR_POWER_PIN_01         INVALID_GPIO
111 #define CONFIG_SENSOR_RESET_PIN_01         INVALID_GPIO
112 #define CONFIG_SENSOR_POWERDN_PIN_01       RK30_PIN1_PD6
113 #define CONFIG_SENSOR_FALSH_PIN_01         INVALID_GPIO
114 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_01 RK29_CAM_POWERACTIVE_L
115 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_01 RK29_CAM_RESETACTIVE_L
116 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_01 RK29_CAM_POWERDNACTIVE_H
117 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_01 RK29_CAM_FLASHACTIVE_L
118
119 #define CONFIG_SENSOR_QCIF_FPS_FIXED_01      15000
120 #define CONFIG_SENSOR_240X160_FPS_FIXED_01   15000
121 #define CONFIG_SENSOR_QVGA_FPS_FIXED_01      15000
122 #define CONFIG_SENSOR_CIF_FPS_FIXED_01       15000
123 #define CONFIG_SENSOR_VGA_FPS_FIXED_01       15000
124 #define CONFIG_SENSOR_480P_FPS_FIXED_01      15000
125 #define CONFIG_SENSOR_SVGA_FPS_FIXED_01      15000
126 #define CONFIG_SENSOR_720P_FPS_FIXED_01     30000
127
128 #define CONFIG_SENSOR_02 RK29_CAM_SENSOR_OV5640                      /* back camera sensor 2 */
129 #define CONFIG_SENSOR_IIC_ADDR_02           0x00
130 #define CONFIG_SENSOR_CIF_INDEX_02                    1
131 #define CONFIG_SENSOR_IIC_ADAPTER_ID_02    4
132 #define CONFIG_SENSOR_ORIENTATION_02       90
133 #define CONFIG_SENSOR_POWER_PIN_02         INVALID_GPIO
134 #define CONFIG_SENSOR_RESET_PIN_02         INVALID_GPIO
135 #define CONFIG_SENSOR_POWERDN_PIN_02       RK30_PIN1_PD6
136 #define CONFIG_SENSOR_FALSH_PIN_02         INVALID_GPIO
137 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_02 RK29_CAM_POWERACTIVE_L
138 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_02 RK29_CAM_RESETACTIVE_L
139 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_02 RK29_CAM_POWERDNACTIVE_H
140 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_02 RK29_CAM_FLASHACTIVE_L
141
142 #define CONFIG_SENSOR_QCIF_FPS_FIXED_02      15000
143 #define CONFIG_SENSOR_240X160_FPS_FIXED_02   15000
144 #define CONFIG_SENSOR_QVGA_FPS_FIXED_02      15000
145 #define CONFIG_SENSOR_CIF_FPS_FIXED_02       15000
146 #define CONFIG_SENSOR_VGA_FPS_FIXED_02       15000
147 #define CONFIG_SENSOR_480P_FPS_FIXED_02      15000
148 #define CONFIG_SENSOR_SVGA_FPS_FIXED_02      15000
149 #define CONFIG_SENSOR_720P_FPS_FIXED_02      30000
150
151 #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_GC0309                      /* front camera sensor 0 */
152 #define CONFIG_SENSOR_IIC_ADDR_1            0x42
153 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1    3
154 #define CONFIG_SENSOR_CIF_INDEX_1                                 0
155 #define CONFIG_SENSOR_ORIENTATION_1       270
156 #define CONFIG_SENSOR_POWER_PIN_1         RK30_PIN4_PC6
157 #define CONFIG_SENSOR_RESET_PIN_1         INVALID_GPIO
158 #define CONFIG_SENSOR_POWERDN_PIN_1       RK30_PIN1_PB7
159 #define CONFIG_SENSOR_FALSH_PIN_1         INVALID_GPIO
160 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_H
161 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
162 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
163 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
164
165 #define CONFIG_SENSOR_QCIF_FPS_FIXED_1          15000
166 #define CONFIG_SENSOR_240X160_FPS_FIXED_1   15000
167 #define CONFIG_SENSOR_QVGA_FPS_FIXED_1          15000
168 #define CONFIG_SENSOR_CIF_FPS_FIXED_1           15000
169 #define CONFIG_SENSOR_VGA_FPS_FIXED_1           15000
170 #define CONFIG_SENSOR_480P_FPS_FIXED_1          15000
171 #define CONFIG_SENSOR_SVGA_FPS_FIXED_1          15000
172 #define CONFIG_SENSOR_720P_FPS_FIXED_1          30000
173
174 #define CONFIG_SENSOR_11 RK29_CAM_SENSOR_OV2659                      /* front camera sensor 1 */
175 #define CONFIG_SENSOR_IIC_ADDR_11           0x00
176 #define CONFIG_SENSOR_IIC_ADAPTER_ID_11    3
177 #define CONFIG_SENSOR_CIF_INDEX_1                                 0
178 #define CONFIG_SENSOR_ORIENTATION_11       270
179 #define CONFIG_SENSOR_POWER_PIN_11         INVALID_GPIO
180 #define CONFIG_SENSOR_RESET_PIN_11         INVALID_GPIO
181 #define CONFIG_SENSOR_POWERDN_PIN_11       RK30_PIN1_PB7
182 #define CONFIG_SENSOR_FALSH_PIN_11         INVALID_GPIO
183 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_11 RK29_CAM_POWERACTIVE_L
184 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_11 RK29_CAM_RESETACTIVE_L
185 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_11 RK29_CAM_POWERDNACTIVE_H
186 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_11 RK29_CAM_FLASHACTIVE_L
187
188 #define CONFIG_SENSOR_QCIF_FPS_FIXED_11      15000
189 #define CONFIG_SENSOR_240X160_FPS_FIXED_11   15000
190 #define CONFIG_SENSOR_QVGA_FPS_FIXED_11      15000
191 #define CONFIG_SENSOR_CIF_FPS_FIXED_11       15000
192 #define CONFIG_SENSOR_VGA_FPS_FIXED_11       15000
193 #define CONFIG_SENSOR_480P_FPS_FIXED_11      15000
194 #define CONFIG_SENSOR_SVGA_FPS_FIXED_11      15000
195 #define CONFIG_SENSOR_720P_FPS_FIXED_11      30000
196
197 #define CONFIG_SENSOR_12 RK29_CAM_SENSOR_OV2655                      /* front camera sensor 2 */
198 #define CONFIG_SENSOR_IIC_ADDR_12           0x00
199 #define CONFIG_SENSOR_IIC_ADAPTER_ID_12    3
200 #define CONFIG_SENSOR_CIF_INDEX_1                                 0
201 #define CONFIG_SENSOR_ORIENTATION_12       270
202 #define CONFIG_SENSOR_POWER_PIN_12         INVALID_GPIO
203 #define CONFIG_SENSOR_RESET_PIN_12         INVALID_GPIO
204 #define CONFIG_SENSOR_POWERDN_PIN_12       RK30_PIN1_PB7
205 #define CONFIG_SENSOR_FALSH_PIN_12         INVALID_GPIO
206 #define CONFIG_SENSOR_POWERACTIVE_LEVEL_12 RK29_CAM_POWERACTIVE_L
207 #define CONFIG_SENSOR_RESETACTIVE_LEVEL_12 RK29_CAM_RESETACTIVE_L
208 #define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_12 RK29_CAM_POWERDNACTIVE_H
209 #define CONFIG_SENSOR_FLASHACTIVE_LEVEL_12 RK29_CAM_FLASHACTIVE_L
210
211 #define CONFIG_SENSOR_QCIF_FPS_FIXED_12      15000
212 #define CONFIG_SENSOR_240X160_FPS_FIXED_12   15000
213 #define CONFIG_SENSOR_QVGA_FPS_FIXED_12      15000
214 #define CONFIG_SENSOR_CIF_FPS_FIXED_12       15000
215 #define CONFIG_SENSOR_VGA_FPS_FIXED_12       15000
216 #define CONFIG_SENSOR_480P_FPS_FIXED_12      15000
217 #define CONFIG_SENSOR_SVGA_FPS_FIXED_12      15000
218 #define CONFIG_SENSOR_720P_FPS_FIXED_12      30000
219
220
221 #endif  //#ifdef CONFIG_VIDEO_RK29
222 /*---------------- Camera Sensor Configuration Macro End------------------------*/
223 #include "../../../drivers/media/video/rk30_camera.c"
224 /*---------------- Camera Sensor Macro Define End  ---------*/
225
226 #define PMEM_CAM_SIZE PMEM_CAM_NECESSARY
227 /*****************************************************************************************
228  * camera  devices
229  * author: ddl@rock-chips.com
230  *****************************************************************************************/
231 #ifdef CONFIG_VIDEO_RK29
232 #define CONFIG_SENSOR_POWER_IOCTL_USR      0
233 #define CONFIG_SENSOR_RESET_IOCTL_USR      0
234 #define CONFIG_SENSOR_POWERDOWN_IOCTL_USR          0
235 #define CONFIG_SENSOR_FLASH_IOCTL_USR      0
236
237 #if CONFIG_SENSOR_POWER_IOCTL_USR
238 static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
239 {
240         #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
241 }
242 #endif
243
244 #if CONFIG_SENSOR_RESET_IOCTL_USR
245 static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
246 {
247         #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
248 }
249 #endif
250
251 #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
252 static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
253 {
254         #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
255 }
256 #endif
257
258 #if CONFIG_SENSOR_FLASH_IOCTL_USR
259 static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
260 {
261         #error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
262 }
263 #endif
264
265 static struct rk29camera_platform_ioctl_cb      sensor_ioctl_cb = {
266         #if CONFIG_SENSOR_POWER_IOCTL_USR
267         .sensor_power_cb = sensor_power_usr_cb,
268         #else
269         .sensor_power_cb = NULL,
270         #endif
271
272         #if CONFIG_SENSOR_RESET_IOCTL_USR
273         .sensor_reset_cb = sensor_reset_usr_cb,
274         #else
275         .sensor_reset_cb = NULL,
276         #endif
277
278         #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
279         .sensor_powerdown_cb = sensor_powerdown_usr_cb,
280         #else
281         .sensor_powerdown_cb = NULL,
282         #endif
283
284         #if CONFIG_SENSOR_FLASH_IOCTL_USR
285         .sensor_flash_cb = sensor_flash_usr_cb,
286         #else
287         .sensor_flash_cb = NULL,
288         #endif
289 };
290
291 #if CONFIG_SENSOR_IIC_ADDR_0
292 static struct reginfo_t rk_init_data_sensor_reg_0[] =
293 {
294                 {0x0000, 0x00,0,0}
295         };
296 static struct reginfo_t rk_init_data_sensor_winseqreg_0[] ={
297         {0x0000, 0x00,0,0}
298         };
299 #endif
300
301 #if CONFIG_SENSOR_IIC_ADDR_1
302 static struct reginfo_t rk_init_data_sensor_reg_1[] =
303 {
304     {0x0000, 0x00,0,0}
305 };
306 static struct reginfo_t rk_init_data_sensor_winseqreg_1[] =
307 {
308        {0x0000, 0x00,0,0}
309 };
310 #endif
311 static rk_sensor_user_init_data_s rk_init_data_sensor[RK_CAM_NUM] = 
312 {
313     {
314        .rk_sensor_init_width = INVALID_VALUE,
315        .rk_sensor_init_height = INVALID_VALUE,
316        .rk_sensor_init_bus_param = INVALID_VALUE,
317        .rk_sensor_init_pixelcode = INVALID_VALUE,
318        .rk_sensor_init_data = NULL,//rk_init_data_sensor_reg_0,
319        .rk_sensor_init_winseq = NULL,//rk_init_data_sensor_winseqreg_0,
320        .rk_sensor_winseq_size = 0,//sizeof(rk_init_data_sensor_winseqreg_0) / sizeof(struct reginfo_t),
321     },{
322         .rk_sensor_init_width = INVALID_VALUE,
323        .rk_sensor_init_height = INVALID_VALUE,
324        .rk_sensor_init_bus_param = INVALID_VALUE,
325        .rk_sensor_init_pixelcode = INVALID_VALUE,
326        .rk_sensor_init_data = NULL,//rk_init_data_sensor_reg_1,
327        .rk_sensor_init_winseq = NULL,//rk_init_data_sensor_winseqreg_1,
328        .rk_sensor_winseq_size = 0,//sizeof(rk_init_data_sensor_winseqreg_1) / sizeof(struct reginfo_t),
329     }
330
331  };
332 #include "../../../drivers/media/video/rk30_camera.c"
333
334 #endif /* CONFIG_VIDEO_RK29 */
335
336 #if defined(CONFIG_TOUCHSCREEN_ILI2102_IIC) 
337 #include "../../../drivers/input/touchscreen/ili2102_ts.h"
338 #define TOUCH_GPIO_INT      RK30_PIN4_PC2
339 #define TOUCH_GPIO_RESET    RK30_PIN4_PD0
340 static struct ili2102_platform_data ili2102_info = {
341         .model                  = 2102,
342         .swap_xy                = 0,
343         .x_min                  = 0,
344         .x_max                  = 480,
345         .y_min                  = 0,
346         .y_max                  = 800,
347         .gpio_reset     = TOUCH_GPIO_RESET,
348         .gpio_reset_active_low = 1,
349         .gpio_pendown           = TOUCH_GPIO_INT,
350         .pendown_iomux_name = GPIO4C2_SMCDATA2_TRACEDATA2_NAME,
351         .resetpin_iomux_name = GPIO4D0_SMCDATA8_TRACEDATA8_NAME,
352         .pendown_iomux_mode = GPIO4C_GPIO4C2,
353         .resetpin_iomux_mode = GPIO4D_GPIO4D0,
354 };
355 #endif
356
357
358 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
359 #define TOUCH_RESET_PIN  RK30_PIN4_PD0
360 #define TOUCH_PWR_PIN    INVALID_GPIO
361 int goodix_init_platform_hw(void)
362 {
363         int ret;
364         
365         rk30_mux_api_set(GPIO4D0_SMCDATA8_TRACEDATA8_NAME, GPIO4D_GPIO4D0);
366         rk30_mux_api_set(GPIO4C2_SMCDATA2_TRACEDATA2_NAME, GPIO4C_GPIO4C2);
367         printk("%s:0x%x,0x%x\n",__func__,rk30_mux_api_get(GPIO4D0_SMCDATA8_TRACEDATA8_NAME),rk30_mux_api_get(GPIO4C2_SMCDATA2_TRACEDATA2_NAME));
368
369         if (TOUCH_PWR_PIN != INVALID_GPIO) {
370                 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
371                 if (ret != 0) {
372                         gpio_free(TOUCH_PWR_PIN);
373                         printk("goodix power error\n");
374                         return -EIO;
375                 }
376                 gpio_direction_output(TOUCH_PWR_PIN, 0);
377                 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
378                 msleep(100);
379         }
380
381         if (TOUCH_RESET_PIN != INVALID_GPIO) {
382                 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
383                 if (ret != 0) {
384                         gpio_free(TOUCH_RESET_PIN);
385                         printk("goodix gpio_request error\n");
386                         return -EIO;
387                 }
388                 gpio_direction_output(TOUCH_RESET_PIN, 0);
389                 gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
390                 msleep(10);
391                 gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
392                 msleep(500);
393         }
394         return 0;
395 }
396
397 struct goodix_platform_data goodix_info = {
398         .model = 8105,
399         .irq_pin = RK30_PIN4_PC2,
400         .rest_pin = TOUCH_RESET_PIN,
401         .init_platform_hw = goodix_init_platform_hw,
402 };
403 #endif
404
405 #if defined(CONFIG_RK29_SC8800)
406 static int sc8800_io_init(void)
407 {
408         rk30_mux_api_set(GPIO2B5_LCDC1DATA13_SMCADDR17_HSADCDATA8_NAME, GPIO2B_GPIO2B5);
409         rk30_mux_api_set(GPIO2A2_LCDCDATA2_SMCADDR6_NAME, GPIO2A_GPIO2A2);
410         return 0;
411 }
412
413 static int sc8800_io_deinit(void)
414 {
415
416         return 0;
417 }
418
419
420 static struct plat_sc8800 sc8800_plat_data = {
421         .slav_rts_pin = RK30_PIN6_PA0,
422         .slav_rdy_pin = RK30_PIN2_PB5,
423         .master_rts_pin = RK30_PIN6_PA1,
424         .master_rdy_pin = RK30_PIN2_PA2,
425         //.poll_time = 100,
426         .io_init = sc8800_io_init,
427     .io_deinit = sc8800_io_deinit,
428 };
429
430 static struct rk29xx_spi_chip sc8800_spi_chip = {
431         //.poll_mode = 1,
432         .enable_dma = 1,
433 };
434
435 #endif
436 #if defined(CONFIG_SMS_SPI_ROCKCHIP)
437 #define CMMB_1186_SPIIRQ RK30_PIN4_PB7
438 #define CMMB_1186_RESET RK30_PIN0_PD5
439
440 void cmmb_io_init_mux(void)
441 {
442 //      rk30_mux_api_set(GPIO1A4_UART1SIN_SPI0CSN0_NAME,GPIO1A_GPIO1A4);
443
444 }
445 void cmmb_io_set_for_pm(void)
446 {
447         printk("entering cmmb_io_set_for_pm\n");
448         rk30_mux_api_set(GPIO0D5_I2S22CHSDO_SMCADDR1_NAME,GPIO0D_GPIO0D5);
449         gpio_request(CMMB_1186_RESET, NULL);//cmmb reset pin
450         gpio_direction_output(CMMB_1186_RESET,0);
451         rk30_mux_api_set(GPIO1A4_UART1SIN_SPI0CSN0_NAME,GPIO1A_GPIO1A4);
452         gpio_request(RK30_PIN1_PA4, NULL);//cmmb cs pin
453         gpio_direction_input(RK30_PIN1_PA4);
454         gpio_pull_updown(RK30_PIN1_PA4, 0);
455 }
456
457 void cmmb_power_on_by_wm831x(void)
458 {
459         struct regulator *ldo;
460 #if 0
461         printk("entering cmmb_power_on_by_wm831x\n");
462
463         rk29_mux_api_set(GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,GPIO1L_SPI0_CSN1);
464         gpio_request(RK29_PIN6_PD2, NULL);
465         gpio_direction_output(RK29_PIN6_PD2,0);
466         mdelay(200);
467
468         ldo = regulator_get(NULL, "ldo8");              //cmmb
469         regulator_set_voltage(ldo,1200000,1200000);
470         regulator_set_suspend_voltage(ldo,1200000);
471         regulator_enable(ldo);
472         printk("%s set ldo8=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
473         regulator_put(ldo);
474
475         ldo = regulator_get(NULL, "ldo9");              //cmmb
476         regulator_set_voltage(ldo,3000000,3000000);
477         regulator_set_suspend_voltage(ldo,3000000);
478         regulator_enable(ldo);
479         printk("%s set ldo9=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
480         regulator_put(ldo);
481
482         mdelay(200);
483         gpio_direction_output(RK29_PIN6_PD2,1);
484 #endif
485 }
486
487 void cmmb_power_down_by_wm831x(void)
488 {
489         struct regulator* ldo;
490 #if 0
491         printk("entering cmmb_power_down_by_wm831x\n");
492
493         ldo = regulator_get(NULL, "ldo8");
494         regulator_set_voltage(ldo,0,0);
495         regulator_disable(ldo);
496         regulator_put(ldo);
497
498         ldo = regulator_get(NULL, "ldo9");
499         regulator_set_voltage(ldo,0,0);
500         regulator_disable(ldo);
501         regulator_put(ldo);
502 #endif
503 }
504
505 static struct cmmb_io_def_s cmmb_io = {
506         .cmmb_pw_en = INVALID_GPIO,
507         .cmmb_pw_dwn = INVALID_GPIO,
508         .cmmb_pw_rst = CMMB_1186_RESET,
509         .cmmb_irq = CMMB_1186_SPIIRQ,
510         .io_init_mux = cmmb_io_init_mux,
511         .cmmb_io_pm = cmmb_io_set_for_pm,
512         .cmmb_power_on = cmmb_power_on_by_wm831x,
513         .cmmb_power_down = cmmb_power_down_by_wm831x
514 };
515
516 static struct rk29xx_spi_chip cmb_spi_chip = {
517         //.poll_mode = 1,
518         .enable_dma = 1,
519 };
520
521 #endif
522
523 static struct spi_board_info board_spi_devices[] = {
524 #if defined(CONFIG_RK29_SC8800)
525                 {
526                         .modalias  = "sc8800",
527                         .bus_num = 1,
528                         .platform_data = &sc8800_plat_data,
529                         .max_speed_hz  = 12*1000*1000,
530                         .chip_select   = 0,             
531                         .controller_data = &sc8800_spi_chip,
532                 },
533 #endif
534         
535 #if defined(CONFIG_SMS_SPI_ROCKCHIP)
536                 {
537                         .modalias       = "siano1186",
538                         .chip_select    = 0,
539                         .max_speed_hz   = 12*1000*1000,
540                         .bus_num        = 0,
541                         .irq            =CMMB_1186_SPIIRQ,
542                         .platform_data = &cmmb_io,      
543                         .controller_data = &cmb_spi_chip,
544                 },
545 #endif
546
547 };
548 /*****************************************************************************************
549  * wm8994  codec
550  * author: qjb@rock-chips.com
551  *****************************************************************************************/
552 #if defined(CONFIG_MFD_WM8994)
553 static struct regulator_consumer_supply wm8994_fixed_voltage0_supplies[] = {
554         REGULATOR_SUPPLY("DBVDD", "0-001a"),
555         REGULATOR_SUPPLY("AVDD2", "0-001a"),
556         REGULATOR_SUPPLY("CPVDD", "0-001a"),
557 };
558
559 static struct regulator_consumer_supply wm8994_fixed_voltage1_supplies[] = {
560         REGULATOR_SUPPLY("SPKVDD1", "0-001a"),
561         REGULATOR_SUPPLY("SPKVDD2", "0-001a"),
562 };
563
564 static struct regulator_init_data wm8994_fixed_voltage0_init_data = {
565         .constraints = {
566                 .always_on = 1,
567         },
568         .num_consumer_supplies  = ARRAY_SIZE(wm8994_fixed_voltage0_supplies),
569         .consumer_supplies      = wm8994_fixed_voltage0_supplies,
570 };
571
572 static struct regulator_init_data wm8994_fixed_voltage1_init_data = {
573         .constraints = {
574                 .always_on = 1,
575         },
576         .num_consumer_supplies  = ARRAY_SIZE(wm8994_fixed_voltage1_supplies),
577         .consumer_supplies      = wm8994_fixed_voltage1_supplies,
578 };
579
580 static struct fixed_voltage_config wm8994_fixed_voltage0_config = {
581         .supply_name    = "VCC_1.8V_PDA",
582         .microvolts     = 1800000,
583         .gpio           = -EINVAL,
584         .init_data      = &wm8994_fixed_voltage0_init_data,
585 };
586
587 static struct fixed_voltage_config wm8994_fixed_voltage1_config = {
588         .supply_name    = "V_BAT",
589         .microvolts     = 3700000,
590         .gpio           = -EINVAL,
591         .init_data      = &wm8994_fixed_voltage1_init_data,
592 };
593
594 static struct platform_device wm8994_fixed_voltage0 = {
595         .name           = "reg-fixed-voltage",
596         .id             = 0,
597         .dev            = {
598                 .platform_data  = &wm8994_fixed_voltage0_config,
599         },
600 };
601
602 static struct platform_device wm8994_fixed_voltage1 = {
603         .name           = "reg-fixed-voltage",
604         .id             = 1,
605         .dev            = {
606                 .platform_data  = &wm8994_fixed_voltage1_config,
607         },
608 };
609
610 static struct regulator_consumer_supply wm8994_avdd1_supply =
611         REGULATOR_SUPPLY("AVDD1", "0-001a");
612
613 static struct regulator_consumer_supply wm8994_dcvdd_supply =
614         REGULATOR_SUPPLY("DCVDD", "0-001a");
615
616
617
618 static struct regulator_init_data wm8994_ldo1_data = {
619         .constraints    = {
620                 .name           = "AVDD1_3.0V",
621                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
622         },
623         .num_consumer_supplies  = 1,
624         .consumer_supplies      = &wm8994_avdd1_supply,
625 };
626
627 static struct regulator_init_data wm8994_ldo2_data = {
628         .constraints    = {
629                 .name           = "DCVDD_1.0V",
630         },
631         .num_consumer_supplies  = 1,
632         .consumer_supplies      = &wm8994_dcvdd_supply,
633 };
634
635 static struct wm8994_pdata wm8994_platform_data = {
636 #if defined (CONFIG_GPIO_WM8994)        
637         .gpio_base = WM8994_GPIO_EXPANDER_BASE,
638         //Fill value to initialize the GPIO     
639 //      .gpio_defaults ={},
640         /* configure gpio1 function: 0x0001(Logic level input/output) */
641 //      .gpio_defaults[0] = 0x0001,
642         /* configure gpio3/4/5/7 function for AIF2 voice */
643         .gpio_defaults[2] = 0x2100,
644         .gpio_defaults[3] = 0x2100,
645         .gpio_defaults[4] = 0xA100,
646 //      .gpio_defaults[6] = 0x0100,
647         /* configure gpio8/9/10/11 function for AIF3 BT */
648         .gpio_defaults[7] = 0xA100,
649         .gpio_defaults[8] = 0x2100,
650         .gpio_defaults[9] = 0x2100,
651         .gpio_defaults[10] = 0x2100,    
652 #endif          
653
654         .ldo[0] = { RK30_PIN3_PA6, NULL, &wm8994_ldo1_data,GPIO3A6_SDMMC0RSTNOUT_NAME, GPIO3A_GPIO3A6}, /* XM0FRNB_2 */
655         .ldo[1] = { 0, NULL, &wm8994_ldo2_data },
656
657         .micdet_irq = 0,
658         .irq_base = 0,
659
660         .lineout1_diff = 1,
661 //      .BB_input_diff = 1,
662 };
663 #endif 
664
665 #ifdef CONFIG_RK_HEADSET_DET
666 #define HEADSET_GPIO RK29_PIN4_PD2
667 struct rk_headset_pdata rk_headset_info = {
668         .Headset_gpio           = RK30_PIN6_PA5,
669         .headset_in_type= HEADSET_IN_HIGH,
670         .Hook_gpio = RK30_PIN1_PB2,//Detection Headset--Must be set
671         .hook_key_code = KEY_MEDIA,
672 };
673
674 struct platform_device rk_device_headset = {
675                 .name   = "rk_headsetdet",
676                 .id     = 0,
677                 .dev    = {
678                     .platform_data = &rk_headset_info,
679                 }
680 };
681 #endif
682
683 #if CONFIG_RK30_PWM_REGULATOR
684 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
685         {
686                 .supply = "vdd_core",
687         }
688 };
689
690 static struct regulator_consumer_supply pwm_dcdc2_consumers[] = {
691         {
692                 .supply = "vdd_cpu",
693         }
694 };
695
696 struct regulator_init_data pwm_regulator_init_dcdc[2] =
697 {
698         {
699                 .constraints = {
700                         .name = "PWM_DCDC1",
701                         .min_uV = 600000,
702                         .max_uV = 1800000,      //0.6-1.8V
703                         .apply_uV = true,
704                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
705                 },
706                 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
707                 .consumer_supplies = pwm_dcdc1_consumers,
708         },
709         {
710                 .constraints = {
711                         .name = "PWM_DCDC2",
712                         .min_uV = 600000,
713                         .max_uV = 1800000,      //0.6-1.8V
714                         .apply_uV = true,
715                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
716                 },
717                 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc2_consumers),
718                 .consumer_supplies = pwm_dcdc2_consumers,
719         },
720 };
721
722 static struct pwm_platform_data pwm_regulator_info[2] = {
723         {
724                 .pwm_id = 0,
725                 .pwm_gpio = RK30_PIN0_PA3,
726                 .pwm_iomux_name = GPIO0A3_PWM0_NAME,
727                 .pwm_iomux_pwm = GPIO0A_PWM0,
728                 .pwm_iomux_gpio = GPIO0A_GPIO0A3,
729                 .pwm_voltage = 1100000,
730                 .init_data      = &pwm_regulator_init_dcdc[0],
731         },
732         {
733                 .pwm_id = 2,
734                 .pwm_gpio = RK30_PIN0_PD6,
735                 .pwm_iomux_name = GPIO0D6_PWM2_NAME,
736                 .pwm_iomux_pwm = GPIO0D_PWM2,
737                 .pwm_iomux_gpio = GPIO0D_GPIO0D6,
738                 .pwm_voltage = 1100000,
739                 .init_data      = &pwm_regulator_init_dcdc[1],
740         },
741
742 };
743
744
745 struct platform_device pwm_regulator_device[2] = {
746         {
747                 .name = "pwm-voltage-regulator",
748                 .id = 0,
749                 .dev            = {
750                         .platform_data = &pwm_regulator_info[0],
751                 }
752         },
753         {
754                 .name = "pwm-voltage-regulator",
755                 .id = 1,
756                 .dev            = {
757                         .platform_data = &pwm_regulator_info[1],
758                 }
759         },
760
761 };
762
763
764 #endif
765
766 /***********************************************************
767 *       rk30  backlight
768 ************************************************************/
769 #ifdef CONFIG_BACKLIGHT_AW9364
770 static int aw9364_backlight_io_init(void)
771 {
772         rk30_mux_api_set(GPIO4D2_SMCDATA10_TRACEDATA10_NAME, GPIO4D_GPIO4D2);
773         return 0;
774 }
775
776 static int aw9364_backlight_io_deinit(void)
777 {
778         return 0;
779 }
780 struct aw9364_platform_data aw9364_bl_info = {
781         .pin_en   = RK30_PIN4_PD2,
782         .io_init   = aw9364_backlight_io_init,
783         .io_deinit = aw9364_backlight_io_deinit,
784 };
785
786 struct platform_device aw9364_device_backlight = {
787         .name = "aw9364_backlight",
788         .id = -1,               
789         .dev            = {
790         .platform_data = &aw9364_bl_info,       
791         }                       
792 };
793         
794 #endif
795
796 #ifdef CONFIG_BACKLIGHT_RK29_BL
797 #define PWM_ID            0
798 #define PWM_MUX_NAME      GPIO0A3_PWM0_NAME
799 #define PWM_MUX_MODE      GPIO0A_PWM0
800 #define PWM_MUX_MODE_GPIO GPIO0A_GPIO0A3
801 #define PWM_GPIO          RK30_PIN0_PA3
802 #define PWM_EFFECT_VALUE  1
803
804 #define LCD_DISP_ON_PIN
805
806 #ifdef  LCD_DISP_ON_PIN
807 //#define BL_EN_MUX_NAME    GPIOF34_UART3_SEL_NAME
808 //#define BL_EN_MUX_MODE    IOMUXB_GPIO1_B34
809
810 #define BL_EN_PIN         RK30_PIN6_PB3
811 #define BL_EN_VALUE       GPIO_HIGH
812 #endif
813 static int rk29_backlight_io_init(void)
814 {
815         int ret = 0;
816         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
817 #ifdef  LCD_DISP_ON_PIN
818         // rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
819
820         ret = gpio_request(BL_EN_PIN, NULL);
821         if (ret != 0) {
822                 gpio_free(BL_EN_PIN);
823         }
824
825         gpio_direction_output(BL_EN_PIN, 0);
826         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
827 #endif
828         return ret;
829 }
830
831 static int rk29_backlight_io_deinit(void)
832 {
833         int ret = 0;
834 #ifdef  LCD_DISP_ON_PIN
835         gpio_free(BL_EN_PIN);
836 #endif
837         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
838         return ret;
839 }
840
841 static int rk29_backlight_pwm_suspend(void)
842 {
843         int ret = 0;
844         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
845         if (gpio_request(PWM_GPIO, NULL)) {
846                 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
847                 return -1;
848         }
849         gpio_direction_output(PWM_GPIO, GPIO_LOW);
850 #ifdef  LCD_DISP_ON_PIN
851         gpio_direction_output(BL_EN_PIN, 0);
852         gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
853 #endif
854         return ret;
855 }
856
857 static int rk29_backlight_pwm_resume(void)
858 {
859         gpio_free(PWM_GPIO);
860         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
861 #ifdef  LCD_DISP_ON_PIN
862         msleep(30);
863         gpio_direction_output(BL_EN_PIN, 1);
864         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
865 #endif
866         return 0;
867 }
868
869 static struct rk29_bl_info rk29_bl_info = {
870         .pwm_id = PWM_ID,
871         .bl_ref = PWM_EFFECT_VALUE,
872         .io_init = rk29_backlight_io_init,
873         .io_deinit = rk29_backlight_io_deinit,
874         .pwm_suspend = rk29_backlight_pwm_suspend,
875         .pwm_resume = rk29_backlight_pwm_resume,
876 };
877
878 static struct platform_device rk29_device_backlight = {
879         .name   = "rk29_backlight",
880         .id     = -1,
881         .dev    = {
882                 .platform_data  = &rk29_bl_info,
883         }
884 };
885
886 #endif
887
888 /*MMA8452 gsensor*/
889 #if defined (CONFIG_GS_MMA8452)
890 #define MMA8452_INT_PIN   RK30_PIN4_PC0
891
892 static int mma8452_init_platform_hw(void)
893 {
894         rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
895
896         if (gpio_request(MMA8452_INT_PIN, NULL) != 0) {
897                 gpio_free(MMA8452_INT_PIN);
898                 printk("mma8452_init_platform_hw gpio_request error\n");
899                 return -EIO;
900         }
901         gpio_pull_updown(MMA8452_INT_PIN, 1);
902         return 0;
903 }
904
905 static struct gsensor_platform_data mma8452_info = {
906         .model = 8452,
907         .swap_xy = 0,
908         .swap_xyz = 1,
909         .init_platform_hw = mma8452_init_platform_hw,
910         .orientation = {0, -1, 0, 0, 0, -1, -1, 0, 0},
911 };
912 #endif
913 #if defined (CONFIG_COMPASS_AK8975)
914 static struct akm8975_platform_data akm8975_info =
915 {
916         .m_layout = 
917         {
918                 {
919                         {0, 1, 0},
920                         {-1, 0, 0},
921                         {0, 0, -1},
922                 },
923
924                 {
925                         {1, 0, 0},
926                         {0, 1, 0},
927                         {0, 0, 1},
928                 },
929
930                 {
931                         {1, 0, 0},
932                         {0, 1, 0},
933                         {0, 0, 1},
934                 },
935
936                 {
937                         {1, 0, 0},
938                         {0, 1, 0},
939                         {0, 0, 1},
940                 },
941         }
942 };
943
944 #endif
945
946 /*mpu3050*/
947 #if defined (CONFIG_MPU_SENSORS_MPU3050)
948 static struct mpu_platform_data mpu3050_data = {
949         .int_config = 0x10,
950         .orientation = { 1, 0, 0,0, 1, 0, 0, 0, 1 },
951 };
952 #endif
953
954 /* accel */
955 #if defined (CONFIG_MPU_SENSORS_MMA845X)
956 static struct ext_slave_platform_data inv_mpu_mma845x_data = {
957         .bus         = EXT_SLAVE_BUS_SECONDARY,
958         .adapt_num = 0,
959         .orientation = {1, 0, 0, 0, 1, 0, 0, 0, 1},
960 };
961 #endif
962
963 /* compass */
964 #if defined (CONFIG_MPU_SENSORS_AK8975)
965 static struct ext_slave_platform_data inv_mpu_ak8975_data = {
966         .bus         = EXT_SLAVE_BUS_PRIMARY,
967         .adapt_num = 0,
968         .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
969 };
970 #endif
971
972
973 #if defined(CONFIG_GYRO_L3G4200D)
974
975 #include <linux/l3g4200d.h>
976 #define L3G4200D_INT_PIN  RK30_PIN4_PC3
977
978 static int l3g4200d_init_platform_hw(void)
979 {
980         if (gpio_request(L3G4200D_INT_PIN, NULL) != 0) {
981                 gpio_free(L3G4200D_INT_PIN);
982                 printk("%s: request l3g4200d int pin error\n", __func__);
983                 return -EIO;
984         }
985         gpio_pull_updown(L3G4200D_INT_PIN, 1);
986         return 0;
987 }
988
989 static struct l3g4200d_platform_data l3g4200d_info = {
990         .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
991         .init = l3g4200d_init_platform_hw,
992         .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
993         .y_min = 40,
994         .z_min = 20,
995 };
996
997 #endif
998
999
1000
1001 #ifdef CONFIG_LS_CM3217
1002
1003 #define CM3217_POWER_PIN        INVALID_GPIO
1004 #define CM3217_IRQ_PIN          INVALID_GPIO
1005 static int cm3217_init_hw(void)
1006 {
1007 #if 0
1008         if (gpio_request(CM3217_POWER_PIN, NULL) != 0) {
1009                 gpio_free(CM3217_POWER_PIN);
1010                 printk("%s: request cm3217 power pin error\n", __func__);
1011                 return -EIO;
1012         }
1013         gpio_pull_updown(CM3217_POWER_PIN, PullDisable);
1014
1015         if (gpio_request(CM3217_IRQ_PIN, NULL) != 0) {
1016                 gpio_free(CM3217_IRQ_PIN);
1017                 printk("%s: request cm3217 int pin error\n", __func__);
1018                 return -EIO;
1019         }
1020         gpio_pull_updown(CM3217_IRQ_PIN, PullDisable);
1021 #endif
1022         return 0;
1023 }
1024
1025 static void cm3217_exit_hw(void)
1026 {
1027 #if 0
1028         gpio_free(CM3217_POWER_PIN);
1029         gpio_free(CM3217_IRQ_PIN);
1030 #endif
1031         return;
1032 }
1033
1034 static struct cm3217_platform_data cm3217_info = {
1035         .irq_pin = CM3217_IRQ_PIN,
1036         .power_pin = CM3217_POWER_PIN,
1037         .init_platform_hw = cm3217_init_hw,
1038         .exit_platform_hw = cm3217_exit_hw,
1039 };
1040 #endif
1041
1042 #ifdef CONFIG_FB_ROCKCHIP
1043
1044 /*****************************************************************************************
1045  * lcd  devices
1046  * author: zyw@rock-chips.com
1047  *****************************************************************************************/
1048 //#ifdef  CONFIG_LCD_TD043MGEA1
1049
1050 #define LCD_TXD_PIN             RK30_PIN0_PB7
1051 #define LCD_CLK_PIN             RK30_PIN0_PB6
1052 #define LCD_CS_PIN              RK30_PIN0_PB5
1053 #define LCD_RST_PIN             RK30_PIN4_PC7
1054
1055 /*****************************************************************************************
1056 * frame buffer  devices
1057 * author: zyw@rock-chips.com
1058 *****************************************************************************************/
1059 #define FB_ID                       0
1060 #define FB_DISPLAY_ON_PIN           INVALID_GPIO//RK29_PIN6_PD0
1061 #define FB_LCD_STANDBY_PIN          INVALID_GPIO//RK29_PIN6_PD1
1062 #define FB_LCD_CABC_EN_PIN          INVALID_GPIO//RK29_PIN6_PD2
1063 #define FB_MCU_FMK_PIN              INVALID_GPIO
1064
1065 #define FB_DISPLAY_ON_VALUE         GPIO_HIGH
1066 #define FB_LCD_STANDBY_VALUE        GPIO_HIGH
1067
1068
1069 //#endif
1070 static int rk29_lcd_io_init(void)
1071 {
1072         int ret = 0;
1073         //printk("rk29_lcd_io_init\n");
1074         //ret = gpio_request(LCD_RXD_PIN, NULL);
1075         ret = gpio_request(LCD_TXD_PIN, NULL);
1076         ret = gpio_request(LCD_CLK_PIN, NULL);
1077         ret = gpio_request(LCD_CS_PIN, NULL);
1078
1079         rk30_mux_api_set(GPIO0B7_I2S8CHSDO3_NAME, GPIO0B_GPIO0B7);
1080         rk30_mux_api_set(GPIO0B6_I2S8CHSDO2_NAME, GPIO0B_GPIO0B6);
1081         rk30_mux_api_set(GPIO0B5_I2S8CHSDO1_NAME, GPIO0B_GPIO0B5);
1082         
1083
1084         gpio_request(LCD_RST_PIN, NULL);
1085         gpio_direction_output(LCD_RST_PIN, 1);
1086         gpio_direction_output(LCD_RST_PIN, 0);
1087         usleep_range(5*1000, 5*1000);
1088         gpio_set_value(LCD_RST_PIN, 1);
1089         usleep_range(50*1000, 50*1000);
1090         gpio_free(LCD_RST_PIN);
1091
1092         return ret;
1093 }
1094
1095 #if defined (CONFIG_RK29_WORKING_POWER_MANAGEMENT)
1096 static int rk29_lcd_io_deinit(void)
1097 {
1098         int ret = 0;
1099         
1100         gpio_direction_output(LCD_TXD_PIN, 1);
1101         gpio_direction_output(LCD_CLK_PIN, 1);
1102
1103         gpio_free(LCD_CS_PIN);
1104         gpio_free(LCD_CLK_PIN);
1105         gpio_free(LCD_TXD_PIN);
1106
1107         return ret;
1108 }
1109 #else
1110 static int rk29_lcd_io_deinit(void)
1111 {
1112         int ret = 0;
1113         //printk("rk29_lcd_io_deinit\n");
1114         gpio_free(LCD_CS_PIN);
1115         gpio_free(LCD_CLK_PIN);
1116         gpio_free(LCD_TXD_PIN);
1117         //gpio_free(LCD_RXD_PIN);
1118
1119         //rk30_mux_api_set(GPIO0B7_I2S8CHSDO3_NAME, GPIO0B_GPIO0B7);
1120         //rk30_mux_api_set(GPIO0B6_I2S8CHSDO2_NAME, GPIO0B_GPIO0B6);
1121         //rk30_mux_api_set(GPIO0B5_I2S8CHSDO1_NAME, GPIO0B_GPIO0B5);
1122
1123         return ret;
1124 }
1125 #endif
1126
1127
1128 static struct rk29lcd_info rk29_lcd_info = {
1129     .txd_pin  = LCD_TXD_PIN,
1130     .clk_pin = LCD_CLK_PIN,
1131     .cs_pin = LCD_CS_PIN,
1132     .io_init   = rk29_lcd_io_init,
1133     .io_deinit = rk29_lcd_io_deinit,
1134 };
1135
1136
1137
1138 #define LCD_EN_MUX_NAME    GPIO4C7_SMCDATA7_TRACEDATA7_NAME
1139 #define LCD_EN_PIN         RK30_PIN4_PC7
1140 #define LCD_EN_VALUE       GPIO_HIGH
1141
1142 static int rk_fb_io_init(void)
1143 {
1144         int ret = 0;
1145         rk30_mux_api_set(LCD_EN_MUX_NAME, GPIO4C_GPIO4C7);
1146         ret = gpio_request(LCD_EN_PIN, NULL);
1147         if (ret != 0)
1148         {
1149                 gpio_free(LCD_EN_PIN);
1150                 printk(KERN_ERR "request lcd en pin fail!\n");
1151                 return -1;
1152         }
1153         else
1154         {
1155                 gpio_direction_output(LCD_EN_PIN, 1);
1156                 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
1157         }
1158         return 0;
1159 }
1160 static int rk_fb_io_disable(void)
1161 {
1162         gpio_set_value(LCD_EN_PIN, ~LCD_EN_VALUE);
1163         return 0;
1164 }
1165 static int rk_fb_io_enable(void)
1166 {
1167         gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
1168         return 0;
1169 }
1170
1171
1172 #if defined(CONFIG_LCDC0_RK30)
1173 struct rk29fb_info lcdc0_screen_info = {
1174         .fb_id   = FB_ID,
1175         .prop      = PRMRY,
1176         .mcu_fmk_pin = FB_MCU_FMK_PIN,
1177         .lcd_info = &rk29_lcd_info,
1178         .io_init   = rk_fb_io_init,
1179         .io_disable = rk_fb_io_disable,
1180         .io_enable = rk_fb_io_enable,
1181         .set_screen_info = set_lcd_info,
1182 };
1183 #endif
1184 #if defined(CONFIG_LCDC1_RK30)
1185 struct rk29fb_info lcdc1_screen_info = {
1186         #if defined(CONFIG_HDMI_RK30)
1187         .prop      = EXTEND,
1188         .lcd_info  = NULL,
1189         .set_screen_info = hdmi_set_info,
1190         #endif
1191 };
1192 #endif
1193
1194 static struct resource resource_fb[] = {
1195         [0] = {
1196                 .name  = "fb0 buf",
1197                 .start = 0,
1198                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
1199                 .flags = IORESOURCE_MEM,
1200         },
1201         [1] = {
1202                 .name  = "ipp buf",  //for rotate
1203                 .start = 0,
1204                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
1205                 .flags = IORESOURCE_MEM,
1206         },
1207         [2] = {
1208                 .name  = "fb2 buf",
1209                 .start = 0,
1210                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
1211                 .flags = IORESOURCE_MEM,
1212         },
1213 };
1214
1215 static struct platform_device device_fb = {
1216         .name           = "rk-fb",
1217         .id             = -1,
1218         .num_resources  = ARRAY_SIZE(resource_fb),
1219         .resource       = resource_fb,
1220 };
1221 #endif
1222 #ifdef  CONFIG_FB_WIMO
1223 static struct wimo_platform_data wimo_pdata = {
1224         .name           = "wimo",
1225 };
1226
1227 static struct platform_device wimo_device = {
1228         .name           = "wimo",
1229         .id                 = -1,
1230         .dev            = {
1231         .platform_data = &wimo_pdata,
1232         },
1233 };
1234 #endif
1235
1236
1237 #ifdef CONFIG_ANDROID_TIMED_GPIO
1238 static struct timed_gpio timed_gpios[] = {
1239         {
1240                 .name = "vibrator",
1241                 .gpio = RK30_PIN0_PA4,
1242                 .max_timeout = 1000,
1243                 .active_low = 0,
1244                 .adjust_time =20,      //adjust for diff product
1245         },
1246 };
1247
1248 static struct timed_gpio_platform_data rk29_vibrator_info = {
1249         .num_gpios = 1,
1250         .gpios = timed_gpios,
1251 };
1252
1253 static struct platform_device rk29_device_vibrator = {
1254         .name = "timed-gpio",
1255         .id = -1,
1256         .dev = {
1257                 .platform_data = &rk29_vibrator_info,
1258         },
1259
1260 };
1261 #endif
1262
1263 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1264 static struct gpio_led rk29_leds[] = {
1265         {
1266                 .name = "button-backlight",
1267                 .gpio = RK30_PIN4_PD7,
1268                 .default_trigger = "timer",
1269                 .active_low = 0,
1270                 .retain_state_suspended = 0,
1271                 .default_state = LEDS_GPIO_DEFSTATE_OFF,
1272         },
1273 };
1274
1275 static struct gpio_led_platform_data rk29_leds_pdata = {
1276         .leds = rk29_leds,
1277         .num_leds = ARRAY_SIZE(rk29_leds),
1278 };
1279
1280 static struct platform_device rk29_device_gpio_leds = {
1281         .name   = "leds-gpio",
1282         .id     = -1,
1283         .dev    = {
1284                 .platform_data  = &rk29_leds_pdata,
1285         },
1286 };
1287 #endif
1288
1289 #ifdef CONFIG_RK_IRDA
1290 #define IRDA_IRQ_PIN           RK30_PIN6_PA1
1291
1292 static int irda_iomux_init(void)
1293 {
1294         int ret = 0;
1295
1296         //irda irq pin
1297         ret = gpio_request(IRDA_IRQ_PIN, NULL);
1298         if (ret != 0) {
1299                 gpio_free(IRDA_IRQ_PIN);
1300                 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
1301         }
1302         gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
1303         gpio_direction_input(IRDA_IRQ_PIN);
1304
1305         return 0;
1306 }
1307
1308 static int irda_iomux_deinit(void)
1309 {
1310         gpio_free(IRDA_IRQ_PIN);
1311         return 0;
1312 }
1313
1314 static struct irda_info rk29_irda_info = {
1315         .intr_pin = IRDA_IRQ_PIN,
1316         .iomux_init = irda_iomux_init,
1317         .iomux_deinit = irda_iomux_deinit,
1318         //.irda_pwr_ctl = bu92747guw_power_ctl,
1319 };
1320
1321 static struct platform_device irda_device = {
1322 #ifdef CONFIG_RK_IRDA_NET
1323         .name = "rk_irda",
1324 #else
1325         .name = "bu92747_irda",
1326 #endif
1327         .id = -1,
1328         .dev = {
1329                 .platform_data = &rk29_irda_info,
1330         }
1331 };
1332 #endif
1333
1334 #ifdef CONFIG_ION
1335 #define ION_RESERVE_SIZE        (80 * SZ_1M)
1336 static struct ion_platform_data rk30_ion_pdata = {
1337         .nr = 1,
1338         .heaps = {
1339                 {
1340                         .type = ION_HEAP_TYPE_CARVEOUT,
1341                         .id = ION_NOR_HEAP_ID,
1342                         .name = "norheap",
1343                         .size = ION_RESERVE_SIZE,
1344                 }
1345         },
1346 };
1347
1348 static struct platform_device device_ion = {
1349         .name = "ion-rockchip",
1350         .id = 0,
1351         .dev = {
1352                 .platform_data = &rk30_ion_pdata,
1353         },
1354 };
1355 #endif
1356
1357 /**************************************************************************************************
1358  * SDMMC devices,  include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
1359 **************************************************************************************************/
1360 #ifdef CONFIG_SDMMC_RK29
1361 #include "board-rk30-phone-sdmmc.c"
1362
1363 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1364 #define SDMMC0_WRITE_PROTECT_PIN        RK30_PIN3_PB7   //According to your own project to set the value of write-protect-pin.
1365 #endif
1366
1367 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1368 #define SDMMC1_WRITE_PROTECT_PIN        RK30_PIN3_PC7   //According to your own project to set the value of write-protect-pin.
1369 #endif
1370
1371 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N    RK30_PIN6_PB2
1372
1373 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
1374
1375 #ifdef CONFIG_SDMMC0_RK29
1376 static int rk29_sdmmc0_cfg_gpio(void)
1377 {
1378 #ifdef CONFIG_SDMMC_RK29_OLD
1379         rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_SDMMC0_CMD);
1380         rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_SDMMC0_CLKOUT);
1381         rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_SDMMC0_DATA0);
1382         rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_SDMMC0_DATA1);
1383         rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_SDMMC0_DATA2);
1384         rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_SDMMC0_DATA3);
1385
1386         rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
1387
1388         rk30_mux_api_set(GPIO3A7_SDMMC0PWREN_NAME, GPIO3A_GPIO3A7);
1389         gpio_request(RK30_PIN3_PA7, "sdmmc-power");
1390         gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
1391
1392 #else
1393         rk29_sdmmc_set_iomux(0, 0xFFFF);
1394
1395         rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_SDMMC0_DETECT_N);
1396
1397 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1398         gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
1399         gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
1400 #endif
1401
1402 #endif
1403
1404         return 0;
1405 }
1406
1407 #define CONFIG_SDMMC0_USE_DMA
1408 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
1409         .host_ocr_avail =
1410             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1411              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1412              MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
1413         .host_caps =
1414             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1415         .io_init = rk29_sdmmc0_cfg_gpio,
1416
1417 #if !defined(CONFIG_SDMMC_RK29_OLD)
1418         .set_iomux = rk29_sdmmc_set_iomux,
1419 #endif
1420
1421         .dma_name = "sd_mmc",
1422 #ifdef CONFIG_SDMMC0_USE_DMA
1423         .use_dma = 1,
1424 #else
1425         .use_dma = 0,
1426 #endif
1427         .detect_irq = INVALID_GPIO,     // INVALID_GPIO
1428         .enable_sd_wakeup = 0,
1429
1430 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
1431         .write_prt = SDMMC0_WRITE_PROTECT_PIN,
1432 #else
1433         .write_prt = INVALID_GPIO,
1434 #endif
1435 };
1436 #endif // CONFIG_SDMMC0_RK29
1437
1438 #ifdef CONFIG_SDMMC1_RK29
1439 #define CONFIG_SDMMC1_USE_DMA
1440 static int rk29_sdmmc1_cfg_gpio(void)
1441 {
1442 #if defined(CONFIG_SDMMC_RK29_OLD)
1443         rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_SMMC1_CMD);
1444         rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_SDMMC1_CLKOUT);
1445         rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_SDMMC1_DATA0);
1446         rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1);
1447         rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2);
1448         rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3);
1449         //rk30_mux_api_set(GPIO3C6_SDMMC1DETECTN_NAME, GPIO3C_SDMMC1_DETECT_N);
1450
1451 #else
1452
1453 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1454         gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
1455         gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
1456 #endif
1457
1458 #endif
1459
1460         return 0;
1461 }
1462
1463 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
1464         .host_ocr_avail =
1465             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
1466              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
1467              MMC_VDD_33_34),
1468
1469 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1470         .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
1471                       MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1472 #else
1473         .host_caps =
1474             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
1475 #endif
1476
1477         .io_init = rk29_sdmmc1_cfg_gpio,
1478
1479 #if !defined(CONFIG_SDMMC_RK29_OLD)
1480         .set_iomux = rk29_sdmmc_set_iomux,
1481 #endif
1482
1483         .dma_name = "sdio",
1484 #ifdef CONFIG_SDMMC1_USE_DMA
1485         .use_dma = 1,
1486 #else
1487         .use_dma = 0,
1488 #endif
1489
1490 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1491 #ifdef CONFIG_WIFI_CONTROL_FUNC
1492         .status = rk29sdk_wifi_status,
1493         .register_status_notify = rk29sdk_wifi_status_register,
1494 #endif
1495 #if 0
1496         .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
1497 #endif
1498
1499 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
1500         .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1501 #else
1502         .write_prt = INVALID_GPIO,
1503 #endif
1504
1505 #else
1506         .detect_irq = INVALID_GPIO,
1507         .enable_sd_wakeup = 0,
1508 #endif
1509
1510 };
1511 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1512
1513 /* bluetooth rfkill device */
1514 static struct platform_device rk29sdk_rfkill = {
1515         .name = "rk29sdk_rfkill",
1516         .id = -1,
1517 };
1518
1519 /**************************************************************************************************
1520  * the end of setting for SDMMC devices
1521 **************************************************************************************************/
1522
1523 /*************td modem sc8800 power control*************/
1524
1525 #if defined(CONFIG_TDSC8800)
1526 #define BP_VOL_PIN                      RK30_PIN6_PB2
1527
1528 static int tdsc8800_io_init(void)
1529 {
1530         
1531         return 0;
1532 }
1533
1534 static int tdsc8800_io_deinit(void)
1535 {
1536
1537         return 0;
1538 }
1539
1540 struct rk2818_23d_data rk29_tdsc8800_info = {
1541         .io_init = tdsc8800_io_init,
1542     .io_deinit = tdsc8800_io_deinit,
1543         .bp_power = BP_VOL_PIN,
1544         .bp_power_active_low = 1,
1545 };
1546 struct platform_device rk29_device_tdsc8800 = {
1547     .name = "tdsc8800",
1548         .id = -1,
1549         .dev            = {
1550                 .platform_data = &rk29_tdsc8800_info,
1551         }
1552     };
1553 #endif
1554
1555
1556 static struct platform_device *devices[] __initdata = {
1557 #ifdef CONFIG_RK30_PWM_REGULATOR
1558                 &pwm_regulator_device[0],
1559                 &pwm_regulator_device[1],
1560 #endif
1561 #ifdef CONFIG_BACKLIGHT_RK29_BL
1562         &rk29_device_backlight,
1563 #endif
1564 #ifdef CONFIG_BACKLIGHT_AW9364
1565         &aw9364_device_backlight,
1566 #endif
1567 #ifdef CONFIG_FB_ROCKCHIP
1568         &device_fb,
1569 #endif
1570 #ifdef CONFIG_ION
1571         &device_ion,
1572 #endif
1573 #ifdef CONFIG_FB_WIMO
1574         &wimo_device,
1575 #endif
1576 #ifdef CONFIG_ANDROID_TIMED_GPIO
1577         &rk29_device_vibrator,
1578 #endif
1579 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1580         &rk29_device_gpio_leds,
1581 #endif
1582 #ifdef CONFIG_RK_IRDA
1583         &irda_device,
1584 #endif
1585 #ifdef CONFIG_WIFI_CONTROL_FUNC
1586         &rk29sdk_wifi_device,
1587 #endif
1588 #ifdef CONFIG_BT
1589     &rk29sdk_rfkill,
1590 #endif
1591 #ifdef CONFIG_MFD_WM8994
1592         &wm8994_fixed_voltage0,
1593         &wm8994_fixed_voltage1,
1594 #endif  
1595 #ifdef CONFIG_RK_HEADSET_DET
1596     &rk_device_headset,
1597 #endif
1598 #ifdef CONFIG_TDSC8800
1599         &rk29_device_tdsc8800,
1600 #endif
1601
1602 };
1603
1604 // i2c
1605 #ifdef CONFIG_I2C0_RK30
1606 static struct i2c_board_info __initdata i2c0_info[] = {
1607 #if defined (CONFIG_GS_MMA8452)
1608         {
1609                 .type           = "gs_mma8452",
1610                 .addr           = 0x1c,
1611                 .flags          = 0,
1612                 .irq            = MMA8452_INT_PIN,
1613                 .platform_data = &mma8452_info,
1614         },
1615 #endif
1616 #if defined (CONFIG_COMPASS_AK8975)
1617         {
1618                 .type          = "ak8975",
1619                 .addr          = 0x0d,
1620                 .flags         = 0,
1621                 .irq           = RK30_PIN4_PC1,
1622                 .platform_data = &akm8975_info,
1623         },
1624 #endif
1625 #if defined (CONFIG_GYRO_L3G4200D)
1626         {
1627                 .type          = "l3g4200d_gryo",
1628                 .addr          = 0x69,
1629                 .flags         = 0,
1630                 .irq           = L3G4200D_INT_PIN,
1631                 .platform_data = &l3g4200d_info,
1632         },
1633 #endif
1634 #if defined (CONFIG_MPU_SENSORS_MPU3050) 
1635         {
1636                 .type                   = "mpu3050",
1637                 .addr                   = 0x68,
1638                 .flags                  = 0,
1639                 .irq                    = RK30_PIN4_PC3,
1640                 .platform_data  = &mpu3050_data,
1641         },
1642 #endif
1643 #if defined (CONFIG_MPU_SENSORS_MMA845X)
1644         {
1645                 .type                   = "mma845x",
1646                 .addr           = 0x1c,
1647                 .flags                  = 0,    
1648                 .irq                    = RK30_PIN4_PC0,
1649                 .platform_data = &inv_mpu_mma845x_data,
1650         },
1651 #endif
1652 #if defined (CONFIG_MPU_SENSORS_AK8975)
1653         {
1654                 .type                   = "ak8975",
1655                 .addr                   = 0x0d,
1656                 .flags                  = 0,    
1657                 .irq                    = RK30_PIN4_PC1,
1658                 .platform_data = &inv_mpu_ak8975_data,
1659         },
1660 #endif
1661
1662 #if defined (CONFIG_SND_SOC_RK1000)
1663         {
1664                 .type          = "rk1000_i2c_codec",
1665                 .addr          = 0x60,
1666                 .flags         = 0,
1667         },
1668         {
1669                 .type          = "rk1000_control",
1670                 .addr          = 0x40,
1671                 .flags         = 0,
1672         },
1673 #endif
1674 #if defined (CONFIG_SND_SOC_RT5631)
1675         {
1676                 .type                   = "rt5631",
1677                 .addr                   = 0x1a,
1678                 .flags                  = 0,
1679         },
1680 #endif
1681
1682 #ifdef CONFIG_MFD_RK610
1683                 {
1684                         .type                   = "rk610_ctl",
1685                         .addr                   = 0x40,
1686                         .flags                  = 0,
1687                 },
1688 #ifdef CONFIG_RK610_TVOUT
1689                 {
1690                         .type                   = "rk610_tvout",
1691                         .addr                   = 0x42,
1692                         .flags                  = 0,
1693                 },
1694 #endif
1695 #ifdef CONFIG_HDMI_RK610
1696                 {
1697                         .type                   = "rk610_hdmi",
1698                         .addr                   = 0x46,
1699                         .flags                  = 0,
1700                         .irq                    = RK29_PIN5_PA2,
1701                 },
1702 #endif
1703 #ifdef CONFIG_SND_SOC_RK610
1704                 {//RK610_CODEC addr  from 0x60 to 0x80 (0x60~0x80)
1705                         .type                   = "rk610_i2c_codec",
1706                         .addr                   = 0x60,
1707                         .flags                  = 0,
1708                 },
1709 #endif
1710 #endif
1711 #if defined (CONFIG_SND_SOC_WM8994)
1712         {
1713                 .type                   = "wm8994",
1714                 .addr           = 0x1a,
1715                 .flags                  = 0,
1716         #if defined(CONFIG_MFD_WM8994)                  
1717                 .platform_data  = &wm8994_platform_data,        
1718         #endif                  
1719         },
1720 #endif
1721
1722 };
1723 #endif
1724
1725 #ifdef CONFIG_I2C1_RK30
1726 #if 0
1727 #include "board-rk30-phone-wm831x.c"
1728
1729 static struct i2c_board_info __initdata i2c1_info[] = {
1730 #if defined (CONFIG_MFD_WM831X_I2C)
1731         {
1732                 .type          = "wm8310",
1733                 .addr          = 0x34,
1734                 .flags         = 0,
1735                 .irq           = RK30_PIN6_PA4,
1736                 .platform_data = &wm831x_platdata,
1737         },
1738 #endif
1739 };
1740 #endif
1741 #endif
1742
1743 #ifdef CONFIG_I2C2_RK30
1744 static struct i2c_board_info __initdata i2c2_info[] = {
1745 #if defined (CONFIG_TOUCHSCREEN_ILI2102_IIC)
1746         {
1747                 .type                   = "ili2102_ts",
1748                 .addr                   = 0x41,
1749                 .flags                  = I2C_M_NEED_DELAY,
1750                 .udelay          = 100,
1751                 .irq                    = TOUCH_GPIO_INT,
1752                 .platform_data = &ili2102_info,
1753         },      
1754 #endif
1755
1756 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1757         {
1758                 .type          = "Goodix-TS",
1759                 .addr          = 0x55,
1760                 .flags         = 0,
1761                 .irq           = RK30_PIN4_PC2,
1762                 .platform_data = &goodix_info,
1763         },
1764 #endif
1765 #if defined (CONFIG_LS_CM3217)
1766         {
1767                 .type          = "lightsensor",
1768                 .addr          = 0x10,
1769                 .flags         = 0,
1770                 .irq           = CM3217_IRQ_PIN,
1771                 .platform_data = &cm3217_info,
1772         },
1773 #endif
1774 };
1775 #endif
1776
1777 #ifdef CONFIG_I2C3_RK30
1778 static struct i2c_board_info __initdata i2c3_info[] = {
1779 };
1780 #endif
1781
1782 #ifdef CONFIG_I2C4_RK30
1783 static struct i2c_board_info __initdata i2c4_info[] = {
1784 };
1785 #endif
1786
1787 #ifdef CONFIG_I2C_GPIO_RK30
1788 #include "board-rk30-phone-wm831x.c"
1789
1790 #define I2C_SDA_PIN     RK30_PIN2_PD7   //set sda_pin here
1791 #define I2C_SCL_PIN     RK30_PIN2_PD6   //set scl_pin here
1792 static int rk30_i2c_io_init(void)
1793 {
1794         //set iomux (gpio) here
1795         rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1796         rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1797
1798         return 0;
1799 }
1800 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1801        .sda_pin = I2C_SDA_PIN,
1802        .scl_pin = I2C_SCL_PIN,
1803        .udelay = 5, // clk = 500/udelay = 100Khz
1804        .timeout = 100,//msecs_to_jiffies(100),
1805        .bus_num    = 5,
1806        .io_init = rk30_i2c_io_init,
1807 };
1808 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1809 #if defined (CONFIG_MFD_WM831X_I2C)
1810                 {
1811                         .type              = "wm8310",
1812                         .addr              = 0x34,
1813                         .flags             = 0,
1814                         .irq               = RK30_PIN6_PA4,
1815                         .platform_data = &wm831x_platdata,
1816                 },
1817 #endif
1818 };
1819 #endif
1820
1821
1822 static void __init rk30_i2c_register_board_info(void)
1823 {
1824 #ifdef CONFIG_I2C0_RK30
1825         i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1826 #endif
1827 #ifdef CONFIG_I2C1_RK30
1828         i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1829 #endif
1830 #ifdef CONFIG_I2C2_RK30
1831         i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1832 #endif
1833 #ifdef CONFIG_I2C3_RK30
1834         i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1835 #endif
1836 #ifdef CONFIG_I2C4_RK30
1837         i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1838 #endif
1839 #ifdef CONFIG_I2C_GPIO_RK30
1840         i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1841 #endif
1842
1843 }
1844 //end of i2c
1845
1846 #define POWER_ON_PIN RK30_PIN6_PB0   //power_hold
1847 static void rk30_pm_power_off(void)
1848 {
1849         printk(KERN_ERR "rk30_pm_power_off start...\n");
1850         gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1851 #if defined(CONFIG_MFD_WM831X)
1852         wm831x_device_shutdown(Wm831x);//wm8326 shutdown
1853 #endif
1854         while (1);
1855 }
1856
1857 static void __init machine_rk30_board_init(void)
1858 {
1859         gpio_request(POWER_ON_PIN, "poweronpin");
1860         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1861         
1862         pm_power_off = rk30_pm_power_off;
1863         
1864         rk30_i2c_register_board_info();
1865         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1866         platform_add_devices(devices, ARRAY_SIZE(devices));
1867         board_usb_detect_init(RK30_PIN6_PA3);
1868         
1869 #if defined (CONFIG_MPU_SENSORS_MPU3050)
1870         rk30_mux_api_set(GPIO4C3_SMCDATA3_TRACEDATA3_NAME, GPIO4C_GPIO4C3);
1871 #endif
1872
1873 #ifdef CONFIG_WIFI_CONTROL_FUNC
1874         rk29sdk_wifi_bt_gpio_control_init();
1875 #endif
1876 }
1877
1878 static void __init rk30_reserve(void)
1879 {
1880 #ifdef CONFIG_ION
1881         rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
1882 #endif
1883 #ifdef CONFIG_FB_ROCKCHIP
1884         resource_fb[0].start = board_mem_reserve_add("fb0", RK30_FB0_MEM_SIZE);
1885         resource_fb[0].end = resource_fb[0].start + RK30_FB0_MEM_SIZE - 1;
1886         resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
1887         resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
1888         resource_fb[2].start = board_mem_reserve_add("fb2", RK30_FB0_MEM_SIZE);
1889         resource_fb[2].end = resource_fb[2].start + RK30_FB0_MEM_SIZE - 1;
1890 #endif
1891 #ifdef CONFIG_VIDEO_RK29
1892         rk30_camera_request_reserve_mem();
1893 #endif
1894         board_mem_reserved();
1895 }
1896
1897 /**
1898  * dvfs_cpu_logic_table: table for arm and logic dvfs 
1899  * @frequency   : arm frequency
1900  * @cpu_volt    : arm voltage depend on frequency
1901  * @logic_volt  : logic voltage arm requests depend on frequency
1902  * comments     : min arm/logic voltage
1903  */
1904 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
1905         //{.frequency = 252 * 1000,     .cpu_volt = 1050 * 1000,        .logic_volt = 1050 * 1000},//0.975V/1.000V
1906         //{.frequency = 504 * 1000,     .cpu_volt = 1050 * 1000,        .logic_volt = 1050 * 1000},//0.975V/1.000V
1907         {.frequency = 816 * 1000,       .cpu_volt = 1100 * 1000,        .logic_volt = 1100 * 1000},
1908         {.frequency = 1008 * 1000,      .cpu_volt = 1150 * 1000,        .logic_volt = 1100 * 1000},
1909         {.frequency = 1200 * 1000,      .cpu_volt = 1200 * 1000,        .logic_volt = 1100 * 1000},
1910         //{.frequency = 1272 * 1000,    .cpu_volt = 1200 * 1000,        .logic_volt = 1150 * 1000},//1.150V/1.100V
1911         //{.frequency = 1416 * 1000,    .cpu_volt = 1275 * 1000,        .logic_volt = 1150 * 1000},//1.225V/1.100V
1912         //{.frequency = 1512 * 1000,    .cpu_volt = 1325 * 1000,        .logic_volt = 1200 * 1000},//1.300V/1.150V
1913         //{.frequency = 1608 * 1000,    .cpu_volt = 1350 * 1000,        .logic_volt = 1200 * 1000},//1.325V/1.175V
1914         {.frequency = CPUFREQ_TABLE_END},
1915 };
1916
1917 #define DVFS_CPU_TABLE_SIZE     (ARRAY_SIZE(dvfs_cpu_logic_table))
1918 static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
1919 static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
1920
1921 void __init board_clock_init(void)
1922 {
1923         rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
1924         dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
1925 }
1926
1927 MACHINE_START(RK30, "RK30board")
1928         .boot_params    = PLAT_PHYS_OFFSET + 0x800,
1929         .fixup          = rk30_fixup,
1930         .reserve        = &rk30_reserve,
1931         .map_io         = rk30_map_io,
1932         .init_irq       = rk30_init_irq,
1933         .timer          = &rk30_timer,
1934         .init_machine   = machine_rk30_board_init,
1935 MACHINE_END