gps:add gps support for rk2928 and rk3066b
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk30 / board-rk3066b-sdk.c
1 /*
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/fb.h>
44 #include <linux/regulator/machine.h>
45 #include <linux/rfkill-rk.h>
46 #include <linux/sensor-dev.h>
47 #include <linux/mfd/tps65910.h>
48 #include <linux/regulator/rk29-pwm-regulator.h>
49
50 #if defined(CONFIG_MFD_RK610)
51 #include <linux/mfd/rk610_core.h>
52 #endif
53
54 #if defined(CONFIG_HDMI_RK30)
55         #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
56 #endif
57
58 #if defined(CONFIG_SPIM_RK29)
59 #include "../../../drivers/spi/rk29_spim.h"
60 #endif
61 #if defined(CONFIG_GPS_RK)
62 #include "../../../drivers/misc/gps/rk_gps/rk_gps.h"
63 #endif
64
65 #if defined(CONFIG_MU509)
66 #include <linux/mu509.h>
67 #endif
68 #if defined(CONFIG_MW100)
69 #include <linux/mw100.h>
70 #endif
71 #if defined(CONFIG_MT6229)
72 #include <linux/mt6229.h>
73 #endif
74 #if defined(CONFIG_ANDROID_TIMED_GPIO)
75 #include "../../../drivers/staging/android/timed_gpio.h"
76 #endif
77
78 #ifdef  CONFIG_THREE_FB_BUFFER
79 #define RK30_FB0_MEM_SIZE 12*SZ_1M
80 #else
81 #define RK30_FB0_MEM_SIZE 8*SZ_1M
82 #endif
83
84 #include "board-rk3066b-sdk-camera.c"
85 #include "board-rk3066b-sdk-key.c"
86
87 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
88 #define TOUCH_RESET_PIN  RK30_PIN2_PC0
89 #define TOUCH_PWR_PIN    RK30_PIN2_PB4
90 static int goodix_init_platform_hw(void)
91 {
92         int ret;
93         
94         rk30_mux_api_set(GPIO2C0_LCDC1DATA16_SMCADDR0_TRACECLK_NAME, GPIO2C_GPIO2C0);
95         rk30_mux_api_set(GPIO2B4_LCDC1DATA12_SMCDATA12_TRACEDATA12_NAME, GPIO2B_GPIO2B4);
96         printk("%s:0x%x,0x%x\n",__func__,rk30_mux_api_get(GPIO2C0_LCDC1DATA16_SMCADDR0_TRACECLK_NAME),rk30_mux_api_get(GPIO2B4_LCDC1DATA12_SMCDATA12_TRACEDATA12_NAME));
97
98         if (TOUCH_PWR_PIN != INVALID_GPIO) {
99                 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
100                 if (ret != 0) {
101                         gpio_free(TOUCH_PWR_PIN);
102                         printk("goodix power error\n");
103                         return -EIO;
104                 }
105                 gpio_direction_output(TOUCH_PWR_PIN, 0);
106                 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
107                 msleep(100);
108         }
109
110         if (TOUCH_RESET_PIN != INVALID_GPIO) {
111                 ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin");
112                 if (ret != 0) {
113                         gpio_free(TOUCH_RESET_PIN);
114                         printk("goodix gpio_request error\n");
115                         return -EIO;
116                 }
117                 gpio_direction_output(TOUCH_RESET_PIN, 1);
118                 msleep(100);
119                 //gpio_set_value(TOUCH_RESET_PIN, GPIO_LOW);
120                 //msleep(100);
121                 //gpio_set_value(TOUCH_RESET_PIN, GPIO_HIGH);
122                 //msleep(500);
123         }
124         return 0;
125 }
126
127 struct goodix_platform_data goodix_info = {
128         .model = 8105,
129         .irq_pin = RK30_PIN0_PD4,
130         .rest_pin = TOUCH_RESET_PIN,
131         .init_platform_hw = goodix_init_platform_hw,
132 };
133 #endif
134
135 static struct spi_board_info board_spi_devices[] = {
136 };
137
138 /***********************************************************
139 *       rk30  backlight
140 ************************************************************/
141 #ifdef CONFIG_BACKLIGHT_RK29_BL
142 #define PWM_ID            2
143 #define PWM_MUX_NAME      GPIO3D5_PWM2_JTAGTCK_OTGDRVVBUS_NAME
144 #define PWM_MUX_MODE      GPIO3D_PWM2
145 #define PWM_MUX_MODE_GPIO GPIO3D_GPIO3D5
146 #define PWM_GPIO          RK30_PIN3_PD5
147 #define PWM_EFFECT_VALUE  1
148
149 #define LCD_DISP_ON_PIN
150
151 #ifdef  LCD_DISP_ON_PIN
152 #define BL_EN_PIN         RK30_PIN0_PA2
153 #define BL_EN_VALUE       GPIO_HIGH
154 #endif
155 static int rk29_backlight_io_init(void)
156 {
157         int ret = 0;
158         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
159 #ifdef  LCD_DISP_ON_PIN
160         // rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
161
162         ret = gpio_request(BL_EN_PIN, NULL);
163         if (ret != 0) {
164                 gpio_free(BL_EN_PIN);
165         }
166
167         gpio_direction_output(BL_EN_PIN, 0);
168         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
169 #endif
170         return ret;
171 }
172
173 static int rk29_backlight_io_deinit(void)
174 {
175         int ret = 0;
176 #ifdef  LCD_DISP_ON_PIN
177         gpio_free(BL_EN_PIN);
178 #endif
179         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
180         gpio_request(PWM_GPIO, NULL);
181         gpio_direction_output(PWM_GPIO, GPIO_LOW);
182         return ret;
183 }
184
185 static int rk29_backlight_pwm_suspend(void)
186 {
187         int ret = 0;
188         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
189         if (gpio_request(PWM_GPIO, NULL)) {
190                 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
191                 return -1;
192         }
193         gpio_direction_output(PWM_GPIO, GPIO_LOW);
194 #ifdef  LCD_DISP_ON_PIN
195         gpio_direction_output(BL_EN_PIN, 0);
196         gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
197 #endif
198         return ret;
199 }
200
201 static int rk29_backlight_pwm_resume(void)
202 {
203         gpio_free(PWM_GPIO);
204         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
205 #ifdef  LCD_DISP_ON_PIN
206         msleep(30);
207         gpio_direction_output(BL_EN_PIN, 1);
208         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
209 #endif
210         return 0;
211 }
212
213 static struct rk29_bl_info rk29_bl_info = {
214         .pwm_id = PWM_ID,
215         .bl_ref = PWM_EFFECT_VALUE,
216         .io_init = rk29_backlight_io_init,
217         .io_deinit = rk29_backlight_io_deinit,
218         .pwm_suspend = rk29_backlight_pwm_suspend,
219         .pwm_resume = rk29_backlight_pwm_resume,
220 };
221
222 static struct platform_device rk29_device_backlight = {
223         .name   = "rk29_backlight",
224         .id     = -1,
225         .dev    = {
226                 .platform_data  = &rk29_bl_info,
227         }
228 };
229
230 #endif
231
232 #ifdef CONFIG_RK29_SUPPORT_MODEM
233
234 #define RK30_MODEM_POWER        RK30_PIN2_PB0
235 #define RK30_MODEM_POWER_IOMUX  rk29_mux_api_set(GPIO2B0_LCDC1DATA8_SMCDATA8_TRACEDATA8_NAME, GPIO2B_GPIO2B0)
236
237 static int rk30_modem_io_init(void)
238 {
239     printk("%s\n", __FUNCTION__);
240     RK30_MODEM_POWER_IOMUX;
241
242         return 0;
243 }
244
245 static struct rk29_io_t rk30_modem_io = {
246     .io_addr    = RK30_MODEM_POWER,
247     .enable     = GPIO_HIGH,
248     .disable    = GPIO_LOW,
249     .io_init    = rk30_modem_io_init,
250 };
251
252 static struct platform_device rk30_device_modem = {
253         .name   = "rk30_modem",
254         .id     = -1,
255         .dev    = {
256                 .platform_data  = &rk30_modem_io,
257         }
258 };
259 #endif
260 #if defined(CONFIG_MU509)
261 static int mu509_io_init(void)
262 {
263
264         rk30_mux_api_set(GPIO2B0_LCDC1DATA8_SMCDATA8_TRACEDATA8_NAME, GPIO2B_GPIO2B0);
265        rk30_mux_api_set(GPIO2D1_LCDC1DEN_SMCWEN_NAME, GPIO2D_GPIO2D1);
266         rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
267         rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
268         return 0;
269 }
270
271 static int mu509_io_deinit(void)
272 {
273         
274         return 0;
275 }
276  
277 struct rk29_mu509_data rk29_mu509_info = {
278         .io_init = mu509_io_init,
279         .io_deinit = mu509_io_deinit,
280         .modem_power_en = RK30_PIN2_PB0,
281         .bp_power = RK30_PIN2_PB0,
282         .bp_reset = RK30_PIN2_PD1,
283         .ap_wakeup_bp = RK30_PIN2_PB7,
284         .bp_wakeup_ap = RK30_PIN6_PA0, 
285 };
286 struct platform_device rk29_device_mu509 = {    
287         .name = "mu509",        
288         .id = -1,       
289         .dev            = {
290                 .platform_data = &rk29_mu509_info,
291         }       
292     };
293 #endif
294 #if defined(CONFIG_MW100)
295 static int mw100_io_init(void)
296 {
297          rk30_mux_api_set(GPIO2B0_LCDC1DATA8_SMCDATA8_TRACEDATA8_NAME, GPIO2B_GPIO2B0);
298          rk30_mux_api_set(GPIO2D1_LCDC1DEN_SMCWEN_NAME, GPIO2D_GPIO2D1);
299          rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
300          rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
301         return 0;
302 }
303
304 static int mw100_io_deinit(void)
305 {
306         
307         return 0;
308 }
309  
310 struct rk29_mw100_data rk29_mw100_info = {
311         .io_init = mw100_io_init,
312         .io_deinit = mw100_io_deinit,
313         .modem_power_en = RK30_PIN6_PB0,
314         .bp_power = RK30_PIN2_PB0,
315         .bp_reset = RK30_PIN2_PD1,
316         .ap_wakeup_bp = RK30_PIN2_PB7,
317         .bp_wakeup_ap = RK30_PIN6_PA0,
318 };
319 struct platform_device rk29_device_mw100 = {    
320         .name = "mw100",        
321         .id = -1,       
322         .dev            = {
323                 .platform_data = &rk29_mw100_info,
324         }       
325     };
326 #endif
327 #if defined(CONFIG_MT6229)
328 static int mt6229_io_init(void)
329 {
330          rk30_mux_api_set(GPIO2B0_LCDC1DATA8_SMCDATA8_TRACEDATA8_NAME, GPIO2B_GPIO2B0);
331          rk30_mux_api_set(GPIO2D1_LCDC1DEN_SMCWEN_NAME, GPIO2D_GPIO2D1);
332          rk30_mux_api_set(GPIO2B7_LCDC1DATA15_SMCADDR19_HSADCDATA7_NAME, GPIO2B_GPIO2B7);
333          rk30_mux_api_set(GPIO2C0_LCDCDATA16_GPSCLK_HSADCCLKOUT_NAME, GPIO2C_GPIO2C0);
334         return 0;
335 }
336
337 static int mt6229_io_deinit(void)
338 {
339         
340         return 0;
341 }
342  
343 struct rk29_mt6229_data rk29_mt6229_info = {
344         .io_init = mt6229_io_init,
345         .io_deinit = mt6229_io_deinit,
346         .modem_power_en = RK30_PIN2_PB0,
347         .bp_power = RK30_PIN2_PB0,//RK30_PIN2_PB6,
348         .bp_reset = RK30_PIN2_PD1,
349         .ap_wakeup_bp = RK30_PIN2_PC0,
350         .bp_wakeup_ap = RK30_PIN6_PA0,
351 };
352 struct platform_device rk29_device_mt6229 = {   
353         .name = "mt6229",       
354         .id = -1,       
355         .dev            = {
356                 .platform_data = &rk29_mt6229_info,
357         }       
358     };
359 #endif
360
361 /*MMA8452 gsensor*/
362 #if defined (CONFIG_GS_MMA8452)
363 #define MMA8452_INT_PIN   RK30_PIN3_PD7
364
365 static int mma8452_init_platform_hw(void)
366 {
367         return 0;
368 }
369
370 static struct sensor_platform_data mma8452_info = {
371         .type = SENSOR_TYPE_ACCEL,
372         .irq_enable = 1,
373         .poll_delay_ms = 30,
374         .init_platform_hw = mma8452_init_platform_hw,
375         .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
376 };
377 #endif
378 #if defined (CONFIG_GS_LIS3DH)
379 #define LIS3DH_INT_PIN   RK30_PIN3_PD7
380
381 static int lis3dh_init_platform_hw(void)
382 {
383
384         return 0;
385 }
386
387 static struct sensor_platform_data lis3dh_info = {
388         .type = SENSOR_TYPE_ACCEL,
389         .irq_enable = 1,
390         .poll_delay_ms = 30,
391         .init_platform_hw = lis3dh_init_platform_hw,
392         .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
393 };
394 #endif
395 #if defined (CONFIG_COMPASS_AK8975)
396 static struct sensor_platform_data akm8975_info =
397 {
398         .type = SENSOR_TYPE_COMPASS,
399         .irq_enable = 1,
400         .poll_delay_ms = 30,
401         .m_layout = 
402         {
403                 {
404                         {1, 0, 0},
405                         {0, 1, 0},
406                         {0, 0, 1},
407                 },
408
409                 {
410                         {1, 0, 0},
411                         {0, 1, 0},
412                         {0, 0, 1},
413                 },
414
415                 {
416                         {1, 0, 0},
417                         {0, 1, 0},
418                         {0, 0, 1},
419                 },
420
421                 {
422                         {1, 0, 0},
423                         {0, 1, 0},
424                         {0, 0, 1},
425                 },
426         }
427 };
428
429 #endif
430
431 #if defined(CONFIG_GYRO_L3G4200D)
432
433 #include <linux/l3g4200d.h>
434 #define L3G4200D_INT_PIN  RK30_PIN0_PB4
435
436 static int l3g4200d_init_platform_hw(void)
437 {
438         return 0;
439 }
440
441 static struct sensor_platform_data l3g4200d_info = {
442         .type = SENSOR_TYPE_GYROSCOPE,
443         .irq_enable = 1,
444         .poll_delay_ms = 30,
445         .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
446         .init_platform_hw = l3g4200d_init_platform_hw,
447         .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
448         .y_min = 40,
449         .z_min = 20,
450 };
451
452 #endif
453
454 #ifdef CONFIG_LS_CM3217
455 static struct sensor_platform_data cm3217_info = {
456         .type = SENSOR_TYPE_LIGHT,
457         .irq_enable = 0,
458         .poll_delay_ms = 500,
459 };
460
461 #endif
462
463 #ifdef CONFIG_FB_ROCKCHIP
464
465 #define LCD_CS_PIN         INVALID_GPIO
466 #define LCD_CS_VALUE       GPIO_HIGH
467
468 #define LCD_EN_PIN         RK30_PIN0_PB0
469 #define LCD_EN_VALUE       GPIO_HIGH
470
471 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
472 {
473         int ret = 0;
474
475         if(LCD_CS_PIN !=INVALID_GPIO)
476         {
477                 ret = gpio_request(LCD_CS_PIN, NULL);
478                 if (ret != 0)
479                 {
480                         gpio_free(LCD_CS_PIN);
481                         printk(KERN_ERR "request lcd cs pin fail!\n");
482                         return -1;
483                 }
484                 else
485                 {
486                         gpio_direction_output(LCD_CS_PIN, LCD_CS_VALUE);
487                 }
488         }
489
490         if(LCD_EN_PIN !=INVALID_GPIO)
491         {
492                 ret = gpio_request(LCD_EN_PIN, NULL);
493                 if (ret != 0)
494                 {
495                         gpio_free(LCD_EN_PIN);
496                         printk(KERN_ERR "request lcd en pin fail!\n");
497                         return -1;
498                 }
499                 else
500                 {
501                         gpio_direction_output(LCD_EN_PIN, LCD_EN_VALUE);
502                 }
503         }
504         return 0;
505 }
506 static int rk_fb_io_disable(void)
507 {
508         if(LCD_CS_PIN !=INVALID_GPIO)
509         {
510                 gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
511         }
512         if(LCD_EN_PIN !=INVALID_GPIO)
513         {
514                 gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
515         }
516         return 0;
517 }
518 static int rk_fb_io_enable(void)
519 {
520         if(LCD_CS_PIN !=INVALID_GPIO)
521         {
522                 gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
523         }
524         if(LCD_EN_PIN !=INVALID_GPIO)
525         {
526                 gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
527         }
528         return 0;
529 }
530
531 #if defined(CONFIG_LCDC0_RK3066B)
532 struct rk29fb_info lcdc0_screen_info = {
533         .prop      = PRMRY,             //primary display device
534         .io_init   = rk_fb_io_init,
535         .io_disable = rk_fb_io_disable,
536         .io_enable = rk_fb_io_enable,
537         .set_screen_info = set_lcd_info,
538 };
539 #endif
540
541 #if defined(CONFIG_LCDC1_RK3066B)
542 struct rk29fb_info lcdc1_screen_info = {
543         #if defined(CONFIG_HDMI_RK30)
544         .prop           = EXTEND,       //extend display device
545         .lcd_info  = NULL,
546         .set_screen_info = hdmi_init_lcdc,
547         #endif
548 };
549 #endif
550
551 static struct resource resource_fb[] = {
552         [0] = {
553                 .name  = "fb0 buf",
554                 .start = 0,
555                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
556                 .flags = IORESOURCE_MEM,
557         },
558         [1] = {
559                 .name  = "ipp buf",  //for rotate
560                 .start = 0,
561                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
562                 .flags = IORESOURCE_MEM,
563         },
564         [2] = {
565                 .name  = "fb2 buf",
566                 .start = 0,
567                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
568                 .flags = IORESOURCE_MEM,
569         },
570 };
571
572 static struct platform_device device_fb = {
573         .name           = "rk-fb",
574         .id             = -1,
575         .num_resources  = ARRAY_SIZE(resource_fb),
576         .resource       = resource_fb,
577 };
578 #endif
579
580 #if defined(CONFIG_LCDC0_RK3066B)
581 static struct resource resource_lcdc0[] = {
582         [0] = {
583                 .name  = "lcdc0 reg",
584                 .start = RK30_LCDC0_PHYS,
585                 .end   = RK30_LCDC0_PHYS + RK30_LCDC0_SIZE - 1,
586                 .flags = IORESOURCE_MEM,
587         },
588         
589         [1] = {
590                 .name  = "lcdc0 irq",
591                 .start = IRQ_LCDC0,
592                 .end   = IRQ_LCDC0,
593                 .flags = IORESOURCE_IRQ,
594         },
595 };
596
597 static struct platform_device device_lcdc0 = {
598         .name             = "rk30-lcdc",
599         .id               = 0,
600         .num_resources    = ARRAY_SIZE(resource_lcdc0),
601         .resource         = resource_lcdc0,
602         .dev            = {
603                 .platform_data = &lcdc0_screen_info,
604         },
605 };
606 #endif
607 #if defined(CONFIG_LCDC1_RK3066B) 
608 static struct resource resource_lcdc1[] = {
609         [0] = {
610                 .name  = "lcdc1 reg",
611                 .start = RK30_LCDC1_PHYS,
612                 .end   = RK30_LCDC1_PHYS + RK30_LCDC1_SIZE - 1,
613                 .flags = IORESOURCE_MEM,
614         },
615         [1] = {
616                 .name  = "lcdc1 irq",
617                 .start = IRQ_LCDC1,
618                 .end   = IRQ_LCDC1,
619                 .flags = IORESOURCE_IRQ,
620         },
621 };
622
623 static struct platform_device device_lcdc1 = {
624         .name             = "rk30-lcdc",
625         .id               = 1,
626         .num_resources    = ARRAY_SIZE(resource_lcdc1),
627         .resource         = resource_lcdc1,
628         .dev            = {
629                 .platform_data = &lcdc1_screen_info,
630         },
631 };
632 #endif
633
634 #if defined(CONFIG_MFD_RK610)
635 #define RK610_RST_PIN_MUX_NAME          GPIO2C5_LCDC1DATA21_SMCADDR5_NAME 
636 #define RK610_RST_PIN_MUX_MODE          GPIO2C_GPIO2C5
637 #define RK610_RST_PIN                   RK30_PIN2_PC5
638 static int rk610_power_on_init(void)
639 {
640         int ret;
641         if(RK610_RST_PIN != INVALID_GPIO)
642         {
643                 rk30_mux_api_set(RK610_RST_PIN_MUX_NAME,RK610_RST_PIN_MUX_MODE);
644                 ret = gpio_request(RK610_RST_PIN, "rk610 reset");
645                 if (ret)
646                 {
647                         printk(KERN_ERR "rk610_control_probe request gpio fail\n");
648                 }
649                 else 
650                 {
651                         gpio_direction_output(RK610_RST_PIN, GPIO_HIGH);
652                         msleep(100);
653                         gpio_direction_output(RK610_RST_PIN, GPIO_LOW);
654                         msleep(100);
655                         gpio_set_value(RK610_RST_PIN, GPIO_HIGH);
656                 }
657         }
658
659         return 0;
660         
661 }
662
663
664 static struct rk610_ctl_platform_data rk610_ctl_pdata = {
665         .rk610_power_on_init = rk610_power_on_init,
666 };
667 #endif
668
669 #ifdef CONFIG_ANDROID_TIMED_GPIO
670 static struct timed_gpio timed_gpios[] = {
671         {
672                 .name = "vibrator",
673                 .gpio = RK30_PIN3_PD3,
674                 .max_timeout = 1000,
675                 .active_low = 0,
676                 .adjust_time =20,      //adjust for diff product
677         },
678 };
679
680 static struct timed_gpio_platform_data rk29_vibrator_info = {
681         .num_gpios = 1,
682         .gpios = timed_gpios,
683 };
684
685 static struct platform_device rk29_device_vibrator = {
686         .name = "timed-gpio",
687         .id = -1,
688         .dev = {
689                 .platform_data = &rk29_vibrator_info,
690         },
691
692 };
693 #endif
694
695 #ifdef CONFIG_LEDS_GPIO_PLATFORM
696 static struct gpio_led rk29_leds[] = {
697         {
698                 .name = "button-backlight",
699                 .gpio = RK30_PIN2_PB3,
700                 .default_trigger = "timer",
701                 .active_low = 0,
702                 .retain_state_suspended = 0,
703                 .default_state = LEDS_GPIO_DEFSTATE_OFF,
704         },
705 };
706
707 static struct gpio_led_platform_data rk29_leds_pdata = {
708         .leds = rk29_leds,
709         .num_leds = ARRAY_SIZE(rk29_leds),
710 };
711
712 static struct platform_device rk29_device_gpio_leds = {
713         .name   = "leds-gpio",
714         .id     = -1,
715         .dev    = {
716                 .platform_data  = &rk29_leds_pdata,
717         },
718 };
719 #endif
720
721 #ifdef CONFIG_RK_IRDA
722 #define IRDA_IRQ_PIN           RK30_PIN0_PA3
723
724 static int irda_iomux_init(void)
725 {
726         int ret = 0;
727
728         //irda irq pin
729         ret = gpio_request(IRDA_IRQ_PIN, NULL);
730         if (ret != 0) {
731                 gpio_free(IRDA_IRQ_PIN);
732                 printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n ");
733         }
734         gpio_pull_updown(IRDA_IRQ_PIN, PullDisable);
735         gpio_direction_input(IRDA_IRQ_PIN);
736
737         return 0;
738 }
739
740 static int irda_iomux_deinit(void)
741 {
742         gpio_free(IRDA_IRQ_PIN);
743         return 0;
744 }
745
746 static struct irda_info rk29_irda_info = {
747         .intr_pin = IRDA_IRQ_PIN,
748         .iomux_init = irda_iomux_init,
749         .iomux_deinit = irda_iomux_deinit,
750         //.irda_pwr_ctl = bu92747guw_power_ctl,
751 };
752
753 static struct platform_device irda_device = {
754 #ifdef CONFIG_RK_IRDA_NET
755         .name = "rk_irda",
756 #else
757         .name = "bu92747_irda",
758 #endif
759         .id = -1,
760         .dev = {
761                 .platform_data = &rk29_irda_info,
762         }
763 };
764 #endif
765
766 #ifdef CONFIG_ION
767 #define ION_RESERVE_SIZE        (80 * SZ_1M)
768 static struct ion_platform_data rk30_ion_pdata = {
769         .nr = 1,
770         .heaps = {
771                 {
772                         .type = ION_HEAP_TYPE_CARVEOUT,
773                         .id = ION_NOR_HEAP_ID,
774                         .name = "norheap",
775                         .size = ION_RESERVE_SIZE,
776                 }
777         },
778 };
779
780 static struct platform_device device_ion = {
781         .name = "ion-rockchip",
782         .id = 0,
783         .dev = {
784                 .platform_data = &rk30_ion_pdata,
785         },
786 };
787 #endif
788
789 /**************************************************************************************************
790  * SDMMC devices,  include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
791 **************************************************************************************************/
792 #ifdef CONFIG_SDMMC_RK29
793 #include "board-rk3066b-sdk-sdmmc.c"
794
795 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
796 #define SDMMC0_WRITE_PROTECT_PIN        RK30_PIN3_PB7   //According to your own project to set the value of write-protect-pin.
797 #endif
798
799 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
800 #define SDMMC1_WRITE_PROTECT_PIN        RK30_PIN3_PC7   //According to your own project to set the value of write-protect-pin.
801 #endif
802
803 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N    RK30_PIN6_PB2
804
805 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
806
807 #ifdef CONFIG_SDMMC0_RK29
808 static int rk29_sdmmc0_cfg_gpio(void)
809 {
810 #ifdef CONFIG_SDMMC_RK29_OLD
811         rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_SDMMC0_CMD);
812         rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_SDMMC0_CLKOUT);
813         rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_SDMMC0_DATA0);
814         rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_SDMMC0_DATA1);
815         rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_SDMMC0_DATA2);
816         rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_SDMMC0_DATA3);
817
818         rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6);
819
820         rk30_mux_api_set(GPIO3A7_SDMMC0PWREN_NAME, GPIO3A_GPIO3A7);
821         gpio_request(RK30_PIN3_PA7, "sdmmc-power");
822         gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
823
824 #else
825         rk29_sdmmc_set_iomux(0, 0xFFFF);
826
827         rk30_mux_api_set(GPIO3B0_SDMMC0DETECTN_NAME, GPIO3B_SDMMC0DETECTN);
828
829 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
830         gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
831         gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
832 #endif
833
834 #endif
835
836         return 0;
837 }
838
839 #define CONFIG_SDMMC0_USE_DMA
840 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
841         .host_ocr_avail =
842             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
843              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
844              MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
845         .host_caps =
846             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
847         .io_init = rk29_sdmmc0_cfg_gpio,
848
849 #if !defined(CONFIG_SDMMC_RK29_OLD)
850         .set_iomux = rk29_sdmmc_set_iomux,
851 #endif
852
853         .dma_name = "sd_mmc",
854 #ifdef CONFIG_SDMMC0_USE_DMA
855         .use_dma = 1,
856 #else
857         .use_dma = 0,
858 #endif
859         .detect_irq = RK30_PIN3_PB6,    // INVALID_GPIO
860         .enable_sd_wakeup = 0,
861
862 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
863         .write_prt = SDMMC0_WRITE_PROTECT_PIN,
864 #else
865         .write_prt = INVALID_GPIO,
866 #endif
867 };
868 #endif // CONFIG_SDMMC0_RK29
869
870 #ifdef CONFIG_SDMMC1_RK29
871 #define CONFIG_SDMMC1_USE_DMA
872 static int rk29_sdmmc1_cfg_gpio(void)
873 {
874 #if defined(CONFIG_SDMMC_RK29_OLD)
875         rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_SMMC1_CMD);
876         rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_SDMMC1_CLKOUT);
877         rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_SDMMC1_DATA0);
878         rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1);
879         rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2);
880         rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3);
881         //rk30_mux_api_set(GPIO3C6_SDMMC1DETECTN_NAME, GPIO3C_SDMMC1_DETECT_N);
882
883 #else
884
885 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
886         gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
887         gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
888 #endif
889
890 #endif
891
892         return 0;
893 }
894
895 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
896         .host_ocr_avail =
897             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
898              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
899              MMC_VDD_33_34),
900
901 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
902         .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
903                       MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
904 #else
905         .host_caps =
906             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
907 #endif
908
909         .io_init = rk29_sdmmc1_cfg_gpio,
910
911 #if !defined(CONFIG_SDMMC_RK29_OLD)
912         .set_iomux = rk29_sdmmc_set_iomux,
913 #endif
914
915         .dma_name = "sdio",
916 #ifdef CONFIG_SDMMC1_USE_DMA
917         .use_dma = 1,
918 #else
919         .use_dma = 0,
920 #endif
921
922 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
923 #ifdef CONFIG_WIFI_CONTROL_FUNC
924         .status = rk29sdk_wifi_status,
925         .register_status_notify = rk29sdk_wifi_status_register,
926 #endif
927 #if 0
928         .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
929 #endif
930
931 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
932         .write_prt = SDMMC1_WRITE_PROTECT_PIN,
933 #else
934         .write_prt = INVALID_GPIO,
935 #endif
936
937 #else
938         .detect_irq = INVALID_GPIO,
939         .enable_sd_wakeup = 0,
940 #endif
941
942 };
943 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
944
945 /**************************************************************************************************
946  * the end of setting for SDMMC devices
947 **************************************************************************************************/
948
949 #ifdef CONFIG_BATTERY_RK30_ADC
950 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
951         .dc_det_pin      = RK30_PIN0_PB2,
952         .batt_low_pin    = RK30_PIN0_PB1, 
953         .charge_set_pin  = INVALID_GPIO,
954         .charge_ok_pin   = RK30_PIN0_PA6,
955         .dc_det_level    = GPIO_LOW,
956         .charge_ok_level = GPIO_HIGH,
957 };
958
959 static struct platform_device rk30_device_adc_battery = {
960         .name   = "rk30-battery",
961         .id     = -1,
962         .dev = {
963                 .platform_data = &rk30_adc_battery_platdata,
964         },
965 };
966 #endif
967 #ifdef CONFIG_RK30_PWM_REGULATOR
968 const static int pwm_voltage_map[] = {
969         1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000
970 };
971
972 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
973         {
974                 .supply = "vdd_core",
975         }
976 };
977
978 struct regulator_init_data pwm_regulator_init_dcdc[1] =
979 {
980         {
981                 .constraints = {
982                         .name = "PWM_DCDC1",
983                         .min_uV = 600000,
984                         .max_uV = 1800000,      //0.6-1.8V
985                         .apply_uV = true,
986                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
987                 },
988                 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
989                 .consumer_supplies = pwm_dcdc1_consumers,
990         },
991 };
992
993 static struct pwm_platform_data pwm_regulator_info[1] = {
994         {
995                 .pwm_id = 3,
996                 .pwm_gpio = RK30_PIN3_PD6,
997                 .pwm_iomux_name = GPIO3D6_PWM3_JTAGTMS_HOSTDRVVBUS_NAME,
998                 .pwm_iomux_pwm = GPIO3D_PWM3,
999                 .pwm_iomux_gpio = GPIO3D_GPIO3D6,
1000                 .pwm_voltage = 1100000,
1001                 .suspend_voltage = 1050000,
1002                 .min_uV = 1000000,
1003                 .max_uV = 1400000,
1004                 .coefficient = 455,     //45.5%
1005                 .pwm_voltage_map = pwm_voltage_map,
1006                 .init_data      = &pwm_regulator_init_dcdc[0],
1007         },
1008 };
1009
1010 struct platform_device pwm_regulator_device[1] = {
1011         {
1012                 .name = "pwm-voltage-regulator",
1013                 .id = 0,
1014                 .dev            = {
1015                         .platform_data = &pwm_regulator_info[0],
1016                 }
1017         },
1018 };
1019 #endif
1020
1021 #ifdef CONFIG_RK29_VMAC
1022 #define PHY_PWR_EN_GPIO RK30_PIN1_PD6
1023 #include "board-rk30-sdk-vmac.c"
1024 #endif
1025
1026 #ifdef CONFIG_RFKILL_RK
1027 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1028 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1029     .type               = RFKILL_TYPE_BLUETOOTH,
1030
1031     .poweron_gpio       = { // BT_REG_ON
1032         .io             = INVALID_GPIO, //RK30_PIN3_PC7,
1033         .enable         = GPIO_HIGH,
1034         .iomux          = {
1035             .name       = GPIO3C7_SDMMC1WRITEPRT_RMIICRS_NAME,
1036             .fgpio      = GPIO3C_GPIO3C7,
1037         },
1038     },
1039
1040     .reset_gpio         = { // BT_RST
1041         .io             = RK30_PIN3_PD1, // set io to INVALID_GPIO for disable it
1042         .enable         = GPIO_LOW,
1043         .iomux          = {
1044             .name       = GPIO3D1_SDMMC1BACKENDPWR_MIIMDCLK_NAME,
1045             .fgpio      = GPIO3D_GPIO3D1,
1046        },
1047    }, 
1048
1049     .wake_gpio          = { // BT_WAKE, use to control bt's sleep and wakeup
1050         .io             = RK30_PIN3_PC6, // set io to INVALID_GPIO for disable it
1051         .enable         = GPIO_HIGH,
1052         .iomux          = {
1053             .name       = GPIO3C6_SDMMC1DETECTN_RMIIRXERR_NAME,
1054             .fgpio      = GPIO3C_GPIO3C6,
1055         },
1056     },
1057
1058     .wake_host_irq      = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1059         .gpio           = {
1060             .io         = RK30_PIN0_PA5, // set io to INVALID_GPIO for disable it
1061             .enable     = GPIO_LOW,      // set GPIO_LOW for falling, set 0 for rising
1062             .iomux      = {
1063                 .name   = NULL,
1064             },
1065         },
1066     },
1067
1068     .rts_gpio           = { // UART_RTS, enable or disable BT's data coming
1069         .io             = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1070         .enable         = GPIO_LOW,
1071         .iomux          = {
1072             .name       = GPIO1A3_UART0RTSN_NAME,
1073             .fgpio      = GPIO1A_GPIO1A3,
1074             .fmux       = GPIO1A_UART0RTSN,
1075         },
1076     },
1077 };
1078
1079 static struct platform_device device_rfkill_rk = {
1080     .name   = "rfkill_rk",
1081     .id     = -1,
1082     .dev    = {
1083         .platform_data = &rfkill_rk_platdata,
1084     },
1085 };
1086 #endif
1087
1088 #if defined(CONFIG_GPS_RK)
1089 int rk_gps_io_init(void)
1090 {
1091         printk("%s \n", __FUNCTION__);
1092         
1093         rk30_mux_api_set(GPIO1B5_UART3RTSN_NAME, GPIO1B_GPIO1B5);//VCC_EN
1094         gpio_request(RK30_PIN1_PB5, NULL);
1095         gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
1096
1097         rk30_mux_api_set(GPIO1B4_UART3CTSN_GPSRFCLK_NAME, GPIO1B_GPSRFCLK);//GPS_CLK
1098         rk30_mux_api_set(GPIO1B2_UART3SIN_GPSMAG_NAME, GPIO1B_GPSMAG);//GPS_MAG
1099         rk30_mux_api_set(GPIO1B3_UART3SOUT_GPSSIG_NAME, GPIO1B_GPSSIG);//GPS_SIGN
1100
1101         rk30_mux_api_set(GPIO1A6_UART1CTSN_SPI0CLK_NAME, GPIO1A_GPIO1A6);//SPI_CLK
1102         gpio_request(RK30_PIN1_PA6, NULL);
1103         gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1104
1105         rk30_mux_api_set(GPIO1A5_UART1SOUT_SPI0TXD_NAME, GPIO1A_GPIO1A5);//SPI_MOSI
1106         gpio_request(RK30_PIN1_PA5, NULL);
1107         gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW); 
1108
1109         rk30_mux_api_set(GPIO1A7_UART1RTSN_SPI0CSN0_NAME, GPIO1A_GPIO1A7);//SPI_CS
1110         gpio_request(RK30_PIN1_PA7, NULL);
1111         gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);         
1112         return 0;
1113 }
1114 int rk_gps_power_up(void)
1115 {
1116         printk("%s \n", __FUNCTION__);
1117
1118         return 0;
1119 }
1120
1121 int rk_gps_power_down(void)
1122 {
1123         printk("%s \n", __FUNCTION__);
1124
1125         return 0;
1126 }
1127
1128 int rk_gps_reset_set(int level)
1129 {
1130         return 0;
1131 }
1132 int rk_enable_hclk_gps(void)
1133 {
1134         printk("%s \n", __FUNCTION__);
1135         clk_enable(clk_get(NULL, "hclk_gps"));
1136         return 0;
1137 }
1138 int rk_disable_hclk_gps(void)
1139 {
1140         printk("%s \n", __FUNCTION__);
1141         clk_disable(clk_get(NULL, "hclk_gps"));
1142         return 0;
1143 }
1144 struct rk_gps_data rk_gps_info = {
1145         .io_init = rk_gps_io_init,
1146         .power_up = rk_gps_power_up,
1147         .power_down = rk_gps_power_down,
1148         .reset = rk_gps_reset_set,
1149         .enable_hclk_gps = rk_enable_hclk_gps,
1150         .disable_hclk_gps = rk_disable_hclk_gps,
1151         .GpsSign = RK30_PIN1_PB3,
1152         .GpsMag = RK30_PIN1_PB2,        //GPIO index
1153         .GpsClk = RK30_PIN1_PB4,        //GPIO index
1154         .GpsVCCEn = RK30_PIN1_PB5,     //GPIO index
1155         .GpsSpi_CSO = RK30_PIN1_PA4,    //GPIO index
1156         .GpsSpiClk = RK30_PIN1_PA5,     //GPIO index
1157         .GpsSpiMOSI = RK30_PIN1_PA7,      //GPIO index
1158         .GpsIrq = IRQ_GPS,
1159         .GpsSpiEn = 0,
1160         .GpsAdcCh = 2,
1161         .u32GpsPhyAddr = RK30_GPS_PHYS,
1162         .u32GpsPhySize = RK30_GPS_SIZE,
1163 };
1164
1165 struct platform_device rk_device_gps = {
1166         .name = "gps_hv5820b",
1167         .id = -1,
1168         .dev            = {
1169         .platform_data = &rk_gps_info,
1170                 }
1171         };
1172 #endif
1173
1174
1175 static struct platform_device *devices[] __initdata = {
1176 #ifdef CONFIG_FB_ROCKCHIP
1177         &device_fb,
1178 #endif
1179 #if defined(CONFIG_LCDC0_RK3066B)
1180         &device_lcdc0,
1181 #endif
1182 #if defined(CONFIG_LCDC1_RK3066B)
1183         &device_lcdc1,
1184 #endif
1185                 
1186 #ifdef CONFIG_BACKLIGHT_RK29_BL
1187         &rk29_device_backlight,
1188 #endif
1189
1190 #ifdef CONFIG_ION
1191         &device_ion,
1192 #endif
1193 #ifdef CONFIG_ANDROID_TIMED_GPIO
1194         &rk29_device_vibrator,
1195 #endif
1196 #ifdef CONFIG_LEDS_GPIO_PLATFORM
1197         &rk29_device_gpio_leds,
1198 #endif
1199 #ifdef CONFIG_RK_IRDA
1200         &irda_device,
1201 #endif
1202 #ifdef CONFIG_WIFI_CONTROL_FUNC
1203         &rk29sdk_wifi_device,
1204 #endif
1205 #ifdef CONFIG_RK29_SUPPORT_MODEM
1206         &rk30_device_modem,
1207 #endif
1208 #if defined(CONFIG_MU509)
1209         &rk29_device_mu509,
1210 #endif
1211 #if defined(CONFIG_MW100)
1212         &rk29_device_mw100,
1213 #endif
1214 #if defined(CONFIG_MT6229)
1215         &rk29_device_mt6229,
1216 #endif
1217 #ifdef CONFIG_BATTERY_RK30_ADC
1218         &rk30_device_adc_battery,
1219 #endif
1220 #ifdef CONFIG_RFKILL_RK
1221         &device_rfkill_rk,
1222 #endif
1223 #ifdef CONFIG_GPS_RK
1224         &rk_device_gps,
1225 #endif
1226
1227 };
1228
1229 // i2c
1230 #ifdef CONFIG_I2C0_RK30
1231 static struct i2c_board_info __initdata i2c0_info[] = {
1232 #if defined (CONFIG_GS_MMA8452)
1233         {
1234                 .type           = "gs_mma8452",
1235                 .addr           = 0x1d,
1236                 .flags          = 0,
1237                 .irq            = MMA8452_INT_PIN,
1238                 .platform_data = &mma8452_info,
1239         },
1240 #endif
1241 #if defined (CONFIG_GS_LIS3DH)
1242         {
1243                 .type           = "gs_lis3dh",
1244                 .addr           = 0x19,   //0x19(SA0-->VCC), 0x18(SA0-->GND)
1245                 .flags          = 0,
1246                 .irq            = LIS3DH_INT_PIN,
1247                 .platform_data = &lis3dh_info,
1248         },
1249 #endif
1250 #if defined (CONFIG_COMPASS_AK8975)
1251         {
1252                 .type          = "ak8975",
1253                 .addr          = 0x0d,
1254                 .flags         = 0,
1255                 .irq           = RK30_PIN0_PD5,
1256                 .platform_data = &akm8975_info,
1257         },
1258 #endif
1259 #if defined (CONFIG_GYRO_L3G4200D)
1260         {
1261                 .type          = "l3g4200d_gryo",
1262                 .addr          = 0x69,
1263                 .flags         = 0,
1264                 .irq           = L3G4200D_INT_PIN,
1265                 .platform_data = &l3g4200d_info,
1266         },
1267 #endif
1268 #if defined (CONFIG_SND_SOC_RK1000)
1269         {
1270                 .type          = "rk1000_i2c_codec",
1271                 .addr          = 0x60,
1272                 .flags         = 0,
1273         },
1274         {
1275                 .type          = "rk1000_control",
1276                 .addr          = 0x40,
1277                 .flags         = 0,
1278         },
1279 #endif
1280 #if defined (CONFIG_SND_SOC_RT5631)
1281         {
1282                 .type                   = "rt5631",
1283                 .addr                   = 0x1a,
1284                 .flags                  = 0,
1285         },
1286 #endif
1287
1288 #ifdef CONFIG_MFD_RK610
1289                 {
1290                         .type                   = "rk610_ctl",
1291                         .addr                   = 0x40,
1292                         .flags                  = 0,
1293                         .platform_data          = &rk610_ctl_pdata,
1294                 },
1295 #ifdef CONFIG_RK610_TVOUT
1296                 {
1297                         .type                   = "rk610_tvout",
1298                         .addr                   = 0x42,
1299                         .flags                  = 0,
1300                 },
1301 #endif
1302 #ifdef CONFIG_HDMI_RK610
1303                 {
1304                         .type                   = "rk610_hdmi",
1305                         .addr                   = 0x46,
1306                         .flags                  = 0,
1307                         .irq                    = INVALID_GPIO,
1308                 },
1309 #endif
1310 #ifdef CONFIG_SND_SOC_RK610
1311                 {//RK610_CODEC addr  from 0x60 to 0x80 (0x60~0x80)
1312                         .type                   = "rk610_i2c_codec",
1313                         .addr                   = 0x60,
1314                         .flags                  = 0,
1315                 },
1316 #endif
1317 #endif
1318
1319 };
1320 #endif
1321
1322 #define PMIC_TYPE_WM8326        1
1323 #define PMIC_TYPE_TPS65910      2
1324 int __sramdata g_pmic_type =  0;
1325 #ifdef CONFIG_I2C1_RK30
1326 #ifdef CONFIG_MFD_WM831X_I2C
1327 #include "board-rk3066b-sdk-wm8326.c"
1328 #endif
1329 #ifdef CONFIG_MFD_TPS65910
1330 #ifdef CONFIG_ARCH_RK3066B
1331 #define TPS65910_HOST_IRQ        RK30_PIN0_PB3
1332 #else
1333 #define TPS65910_HOST_IRQ        RK30_PIN6_PA4
1334 #endif
1335 #include "board-rk3066b-sdk-tps65910.c"
1336 #endif
1337
1338 static struct i2c_board_info __initdata i2c1_info[] = {
1339 #if defined (CONFIG_MFD_WM831X_I2C)
1340         {
1341                 .type          = "wm8326",
1342                 .addr          = 0x34,
1343                 .flags         = 0,
1344                 .irq           = RK30_PIN0_PB3,
1345                 .platform_data = &wm831x_platdata,
1346         },
1347 #endif
1348 #if defined (CONFIG_MFD_TPS65910)
1349         {
1350         .type           = "tps65910",
1351         .addr           = TPS65910_I2C_ID0,
1352         .flags          = 0,
1353         .irq            = TPS65910_HOST_IRQ,
1354         .platform_data = &tps65910_data,
1355         },
1356 #endif
1357 };
1358 #endif
1359
1360 void __sramfunc board_pmu_suspend(void)
1361 {      
1362         #if defined (CONFIG_MFD_WM831X_I2C)
1363        if(g_pmic_type == PMIC_TYPE_WM8326)
1364        board_pmu_wm8326_suspend();
1365         #endif
1366         #if defined (CONFIG_MFD_TPS65910)
1367        if(g_pmic_type == PMIC_TYPE_TPS65910)
1368        board_pmu_tps65910_suspend(); 
1369     #endif   
1370 }
1371
1372 void __sramfunc board_pmu_resume(void)
1373 {      
1374         #if defined (CONFIG_MFD_WM831X_I2C)
1375        if(g_pmic_type == PMIC_TYPE_WM8326)
1376        board_pmu_wm8326_resume();
1377         #endif
1378         #if defined (CONFIG_MFD_TPS65910)
1379        if(g_pmic_type == PMIC_TYPE_TPS65910)
1380        board_pmu_tps65910_resume(); 
1381         #endif
1382 }
1383
1384  int __sramdata gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1385
1386 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1387 {
1388 #ifdef CONFIG_RK30_PWM_REGULATOR
1389
1390 //      int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
1391         sram_udelay(10000);
1392         gpio0d7_iomux = readl_relaxed(GRF_GPIO0D_IOMUX);
1393         gpio0d7_do = grf_readl(GRF_GPIO0H_DO);
1394         gpio0d7_dir = grf_readl(GRF_GPIO0H_DIR);
1395         gpio0d7_en = grf_readl(GRF_GPIO0H_EN);
1396
1397         writel_relaxed((1<<30), GRF_GPIO0D_IOMUX);
1398         grf_writel((1<<31)|(1<<15), GRF_GPIO0H_DIR);
1399         grf_writel((1<<31)|(1<<15), GRF_GPIO0H_DO);
1400         grf_writel((1<<31)|(1<<15), GRF_GPIO0H_EN);
1401 #endif 
1402 }
1403 void __sramfunc rk30_pwm_logic_resume_voltage(void)
1404 {
1405 #ifdef CONFIG_RK30_PWM_REGULATOR
1406         writel_relaxed((1<<30)|gpio0d7_iomux, GRF_GPIO0D_IOMUX);
1407         grf_writel((1<<31)|gpio0d7_en, GRF_GPIO0H_EN);
1408         grf_writel((1<<31)|gpio0d7_dir, GRF_GPIO0H_DIR);
1409         grf_writel((1<<31)|gpio0d7_do, GRF_GPIO0H_DO);
1410         sram_udelay(10000);
1411
1412 #endif
1413
1414 }
1415 extern void pwm_suspend_voltage(void);
1416 extern void pwm_resume_voltage(void);
1417 void  rk30_pwm_suspend_voltage_set(void)
1418 {
1419 #ifdef CONFIG_RK30_PWM_REGULATOR
1420         pwm_suspend_voltage();
1421 #endif
1422 }
1423 void  rk30_pwm_resume_voltage_set(void)
1424 {
1425 #ifdef CONFIG_RK30_PWM_REGULATOR
1426         pwm_resume_voltage();
1427 #endif
1428 }
1429
1430
1431 #ifdef CONFIG_I2C2_RK30
1432 static struct i2c_board_info __initdata i2c2_info[] = {
1433 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1434         {
1435                 .type          = "Goodix-TS",
1436                 .addr          = 0x55,
1437                 .flags         = 0,
1438                 .irq           = RK30_PIN0_PD4,
1439                 .platform_data = &goodix_info,
1440         },
1441 #endif
1442 #if defined (CONFIG_LS_CM3217)
1443         {
1444                 .type          = "lightsensor",
1445                 .addr          = 0x10,
1446                 .flags         = 0,
1447                 .platform_data = &cm3217_info,
1448         },
1449 #endif
1450 };
1451 #endif
1452
1453 #ifdef CONFIG_I2C3_RK30
1454 static struct i2c_board_info __initdata i2c3_info[] = {
1455 };
1456 #endif
1457
1458 #ifdef CONFIG_I2C4_RK30
1459 static struct i2c_board_info __initdata i2c4_info[] = {
1460 };
1461 #endif
1462
1463 #ifdef CONFIG_I2C_GPIO_RK30
1464 #define I2C_SDA_PIN     INVALID_GPIO// RK30_PIN2_PD6   //set sda_pin here
1465 #define I2C_SCL_PIN     INVALID_GPIO//RK30_PIN2_PD7   //set scl_pin here
1466 static int rk30_i2c_io_init(void)
1467 {
1468         //set iomux (gpio) here
1469         //rk30_mux_api_set(GPIO2D7_I2C1SCL_NAME, GPIO2D_GPIO2D7);
1470         //rk30_mux_api_set(GPIO2D6_I2C1SDA_NAME, GPIO2D_GPIO2D6);
1471
1472         return 0;
1473 }
1474 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1475        .sda_pin = I2C_SDA_PIN,
1476        .scl_pin = I2C_SCL_PIN,
1477        .udelay = 5, // clk = 500/udelay = 100Khz
1478        .timeout = 100,//msecs_to_jiffies(100),
1479        .bus_num    = 5,
1480        .io_init = rk30_i2c_io_init,
1481 };
1482 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1483 };
1484 #endif
1485
1486 static void __init rk30_i2c_register_board_info(void)
1487 {
1488 #ifdef CONFIG_I2C0_RK30
1489         i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1490 #endif
1491 #ifdef CONFIG_I2C1_RK30
1492         i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1493 #endif
1494 #ifdef CONFIG_I2C2_RK30
1495         i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1496 #endif
1497 #ifdef CONFIG_I2C3_RK30
1498         i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1499 #endif
1500 #ifdef CONFIG_I2C4_RK30
1501         i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
1502 #endif
1503 #ifdef CONFIG_I2C_GPIO_RK30
1504         i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1505 #endif
1506 }
1507 //end of i2c
1508
1509 #define POWER_ON_PIN RK30_PIN0_PA0   //power_hold
1510 static void rk30_pm_power_off(void)
1511 {
1512         printk(KERN_ERR "rk30_pm_power_off start...\n");
1513         gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1514 #if defined(CONFIG_MFD_WM831X)
1515         wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000);  //set sys_pwr 0
1516         wm831x_device_shutdown(Wm831x);//wm8326 shutdown
1517 #endif
1518         while (1);
1519 }
1520
1521 static void __init machine_rk30_board_init(void)
1522 {
1523         //avs_init();
1524         gpio_request(POWER_ON_PIN, "poweronpin");
1525         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
1526         
1527         pm_power_off = rk30_pm_power_off;
1528         
1529         rk30_i2c_register_board_info();
1530         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1531         platform_add_devices(devices, ARRAY_SIZE(devices));
1532         board_usb_detect_init(RK30_PIN0_PA7);
1533
1534 #ifdef CONFIG_WIFI_CONTROL_FUNC
1535         rk29sdk_wifi_bt_gpio_control_init();
1536 #endif
1537 }
1538
1539 static void __init rk30_reserve(void)
1540 {
1541 #ifdef CONFIG_ION
1542         rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
1543 #endif
1544 #ifdef CONFIG_FB_ROCKCHIP
1545         resource_fb[0].start = board_mem_reserve_add("fb0", RK30_FB0_MEM_SIZE);
1546         resource_fb[0].end = resource_fb[0].start + RK30_FB0_MEM_SIZE - 1;
1547         #if 0
1548         resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
1549         resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
1550         resource_fb[2].start = board_mem_reserve_add("fb2", RK30_FB0_MEM_SIZE);
1551         resource_fb[2].end = resource_fb[2].start + RK30_FB0_MEM_SIZE - 1;
1552         #endif
1553 #endif
1554 #ifdef CONFIG_VIDEO_RK29
1555         rk30_camera_request_reserve_mem();
1556 #endif
1557         
1558 #ifdef CONFIG_GPS_RK
1559         //it must be more than 8MB
1560         rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
1561 #endif
1562         board_mem_reserved();
1563 }
1564
1565 /**
1566  * dvfs_cpu_logic_table: table for arm and logic dvfs 
1567  * @frequency   : arm frequency
1568  * @cpu_volt    : arm voltage depend on frequency
1569  * @logic_volt  : logic voltage arm requests depend on frequency
1570  * comments     : min arm/logic voltage
1571  */
1572 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
1573         {.frequency = 252 * 1000,       .cpu_volt = 1000 * 1000,        .logic_volt = 1000 * 1000},//0.975V/1.000V
1574         {.frequency = 504 * 1000,       .cpu_volt = 1000 * 1000,        .logic_volt = 1000 * 1000},//0.975V/1.000V
1575         {.frequency = 816 * 1000,       .cpu_volt = 1000 * 1000,        .logic_volt = 1000 * 1000},//1.000V/1.025V
1576         {.frequency = 1008 * 1000,      .cpu_volt = 1000 * 1000,        .logic_volt = 1000 * 1000},//1.025V/1.050V
1577         {.frequency = 1200 * 1000,      .cpu_volt = 1000 * 1000,        .logic_volt = 1000 * 1000},//1.100V/1.050V
1578 #if 0
1579         {.frequency = 1272 * 1000,      .cpu_volt = 1225 * 1000,        .logic_volt = 1200 * 1000},//1.150V/1.100V
1580         {.frequency = 1416 * 1000,      .cpu_volt = 1300 * 1000,        .logic_volt = 1200 * 1000},//1.225V/1.100V
1581         {.frequency = 1512 * 1000,      .cpu_volt = 1350 * 1000,        .logic_volt = 1250 * 1000},//1.300V/1.150V
1582         {.frequency = 1608 * 1000,      .cpu_volt = 1425 * 1000,        .logic_volt = 1300 * 1000},//1.325V/1.175V
1583 #endif
1584         {.frequency = CPUFREQ_TABLE_END},
1585 };
1586
1587 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
1588         {.frequency = 266 * 1000,       .index = 1000 * 1000},
1589         {.frequency = 400 * 1000,       .index = 1000 * 1000},
1590         {.frequency = CPUFREQ_TABLE_END},
1591 };
1592
1593 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
1594         {.frequency = 300 * 1000,       .index = 1000 * 1000},
1595         {.frequency = 400 * 1000,       .index = 1000 * 1000},
1596         {.frequency = CPUFREQ_TABLE_END},
1597 };
1598
1599 #define DVFS_CPU_TABLE_SIZE     (ARRAY_SIZE(dvfs_cpu_logic_table))
1600 static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
1601 static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
1602
1603 void __init board_clock_init(void)
1604 {
1605         rk30_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
1606         dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
1607         dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
1608         dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
1609 }
1610
1611 MACHINE_START(RK30, "RK30board")
1612         .boot_params    = PLAT_PHYS_OFFSET + 0x800,
1613         .fixup          = rk30_fixup,
1614         .reserve        = &rk30_reserve,
1615         .map_io         = rk30_map_io,
1616         .init_irq       = rk30_init_irq,
1617         .timer          = &rk30_timer,
1618         .init_machine   = machine_rk30_board_init,
1619 MACHINE_END