rk3026: i2s add several attempts to double confirm i2s frac effect
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk3026 / board-rk3028a-86v.c
1 /*
2  * Copyright (C) 2013 ROCKCHIP, Inc.
3  *
4  * This software is licensed under the terms of the GNU General Public
5  * License version 2, as published by the Free Software Foundation, and
6  * may be copied, distributed, and modified under those terms.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  */
14
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/input.h>
19 #include <linux/io.h>
20 #include <linux/delay.h>
21 #include <linux/i2c.h>
22 #include <linux/skbuff.h>
23 #include <linux/spi/spi.h>
24 #include <linux/mmc/host.h>
25 #include <linux/ion.h>
26 #include <linux/cpufreq.h>
27 #include <linux/clk.h>
28 #include <linux/rk_fb.h>
29 #include <linux/regulator/machine.h>
30 #include <linux/rfkill-rk.h>
31 #include <linux/sensor-dev.h>
32 #include <linux/mfd/tps65910.h>
33 #include <linux/regulator/act8846.h>
34 #include <linux/regulator/rk29-pwm-regulator.h>
35
36 #include <asm/setup.h>
37 #include <asm/mach-types.h>
38 #include <asm/mach/arch.h>
39 #include <asm/mach/map.h>
40 #include <asm/mach/flash.h>
41 #include <asm/hardware/gic.h>
42
43 #include <mach/dvfs.h>
44 #include <mach/board.h>
45 #include <mach/hardware.h>
46 #include <mach/io.h>
47 #include <mach/gpio.h>
48 #include <mach/iomux.h>
49
50 #if defined(CONFIG_SPIM_RK29)
51 #include "../../../drivers/spi/rk29_spim.h"
52 #endif
53
54 #ifdef CONFIG_SND_SOC_RK3026
55 #include "../../../sound/soc/codecs/rk3026_codec.h"
56 #endif
57
58 #if defined(CONFIG_RK_HDMI)
59         #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
60 #endif
61
62 #if defined(CONFIG_GPS_RK)
63 #include "../../../drivers/misc/gps/rk_gps/rk_gps.h"
64 #endif
65 #include "board-rk3028a-86v-camera.c"
66
67 /***********************************************************
68 *       board config
69 ************************************************************/
70 //system power on
71 #define POWER_ON_PIN            RK30_PIN1_PA1  //PWR_HOLD
72
73 //touchscreen
74 #define TOUCH_RST_PIN           RK30_PIN3_PC3
75 #define TOUCH_RST_VALUE         GPIO_HIGH
76 #define TOUCH_PWR_PIN           RK30_PIN2_PD0
77 #define TOUCH_PWR_VALUE         GPIO_LOW
78 #define TOUCH_INT_PIN           RK30_PIN3_PC7
79
80 //backlight
81 #define LCD_DISP_ON_PIN
82 #define BL_PWM                  0  // (0 ~ 2)
83 #define PWM_EFFECT_VALUE        0
84 #define BL_EN_PIN               RK30_PIN3_PC5
85 #define BL_EN_VALUE             GPIO_HIGH
86
87 //fb
88 #define LCD_EN_PIN              RK30_PIN3_PD2
89 #define LCD_EN_VALUE            GPIO_LOW
90 #define LCD_CS_PIN              INVALID_GPIO
91 #define LCD_CS_VALUE            GPIO_LOW
92
93 //gsensor
94 #define GS_INT_PIN              RK30_PIN3_PD1
95
96 //sdmmc
97 //Reference to board-rk3028a-tb-sdmmc-config.c
98
99 //keyboard
100 //#define RK31XX_MAINBOARD_V1      //if mainboard is RK31XX_MAINBOARD_V1.0
101 #define PLAY_ON_PIN             RK30_PIN0_PD1   //wakeup key            
102
103 //pwm regulator
104 #define REG_PWM                 1  // (0 ~ 2)
105
106 //pmic
107 #define PMU_INT_PIN             RK30_PIN3_PC6
108 #define PMU_SLEEP_PIN           RK30_PIN3_PC4
109
110 //ion reserve memory
111 #define ION_RESERVE_SIZE        (80 * SZ_1M)
112
113 static int pwm_mode[] = {PWM0, PWM1, PWM2};
114 static inline int rk_gpio_request(int gpio, int direction, int value, const char *label)
115 {
116         int ret = 0;
117         unsigned long flags = 0;
118
119         if(!gpio_is_valid(gpio))
120                 return 0;
121
122         if(direction == GPIOF_DIR_IN)
123                 flags = GPIOF_IN;
124         else if(value == GPIO_LOW)
125                 flags = GPIOF_OUT_INIT_LOW;
126         else
127                 flags = GPIOF_OUT_INIT_HIGH;
128
129         ret = gpio_request_one(gpio, flags, label);
130         if(ret < 0)
131                 pr_err("Failed to request '%s'\n", label);
132
133         return ret;
134 }
135
136 static struct spi_board_info board_spi_devices[] = {
137 };
138
139 /***********************************************************
140 *       touchscreen
141 ************************************************************/
142 #if defined(CONFIG_TOUCHSCREEN_GSLX680_RK3028)
143 //#define TOUCH_RESET_PIN RK30_PIN0_PC1
144 //#define TOUCH_EN_PIN NULL
145 //#define TOUCH_INT_PIN RK30_PIN0_PB4
146         
147         int gslx680_init_platform_hw(void)
148         {
149         
150                if(gpio_request(TOUCH_RST_PIN,NULL) != 0){
151                         gpio_free(TOUCH_RST_PIN);
152                         printk("gslx680_init_platform_hw gpio_request error\n");
153                         return -EIO;
154                 }
155                 if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
156                         gpio_free(TOUCH_INT_PIN);
157                         printk("gslx680_init_platform_hw  gpio_request error\n");
158                         return -EIO;
159                 }
160                 gpio_direction_output(TOUCH_RST_PIN, TOUCH_RST_VALUE);
161                 mdelay(10);
162                 gpio_set_value(TOUCH_RST_PIN,!TOUCH_RST_VALUE);
163                 mdelay(10);
164                 gpio_set_value(TOUCH_RST_PIN,TOUCH_RST_VALUE);
165                 msleep(300);
166                 return 0;
167         
168         }
169         
170         struct ts_hw_data     gslx680_info = {
171                 .reset_gpio = TOUCH_RST_PIN,
172                 .touch_en_gpio = TOUCH_INT_PIN,
173                 .init_platform_hw = gslx680_init_platform_hw,
174         };
175 #endif
176
177
178 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
179 static int goodix_init_platform_hw(void)
180 {
181         int ret  = 0;
182
183         ret = rk_gpio_request(TOUCH_PWR_PIN, GPIOF_DIR_OUT, TOUCH_PWR_VALUE, "touch_pwr");
184         if(ret < 0)
185                 return ret; 
186         msleep(100);
187
188         ret = rk_gpio_request(TOUCH_RST_PIN, GPIOF_DIR_OUT, TOUCH_RST_VALUE, "touch_rst");
189         if(ret < 0)
190                 return ret; 
191         msleep(100);
192
193         return 0;
194 }
195
196 struct goodix_platform_data goodix_info = {
197         .model = 8105,
198         .irq_pin = TOUCH_INT_PIN,
199         .rest_pin = TOUCH_RST_PIN,
200         .init_platform_hw = goodix_init_platform_hw,
201 };
202 #endif
203
204 /***********************************************************
205 *       rk30  backlight
206 ************************************************************/
207 #ifdef CONFIG_BACKLIGHT_RK29_BL
208 static int rk29_backlight_io_init(void)
209 {
210         int ret = 0;
211
212         iomux_set(pwm_mode[BL_PWM]);
213         msleep(50);
214 #ifdef  LCD_DISP_ON_PIN
215         ret = rk_gpio_request(BL_EN_PIN, GPIOF_DIR_OUT, BL_EN_VALUE, "bl_en");
216         if(ret < 0)
217                 return ret;
218 #endif
219         return 0;
220 }
221
222 static int rk29_backlight_io_deinit(void)
223 {
224         int pwm_gpio;
225 #ifdef  LCD_DISP_ON_PIN
226         gpio_free(BL_EN_PIN);
227 #endif
228         pwm_gpio = iomux_mode_to_gpio(pwm_mode[BL_PWM]);
229         return rk_gpio_request(BL_EN_PIN, GPIOF_DIR_OUT, GPIO_LOW, "BL_PWM");
230 }
231
232 static int rk29_backlight_pwm_suspend(void)
233 {
234         int ret, pwm_gpio = iomux_mode_to_gpio(pwm_mode[BL_PWM]);
235
236         ret = rk_gpio_request(pwm_gpio, GPIOF_DIR_OUT, GPIO_LOW, "BL_PWM");
237         if(ret < 0)
238                 return ret;
239 #ifdef  LCD_DISP_ON_PIN
240         gpio_direction_output(BL_EN_PIN, !BL_EN_VALUE);
241 #endif
242         return ret;
243 }
244
245 static int rk29_backlight_pwm_resume(void)
246 {
247         int pwm_gpio = iomux_mode_to_gpio(pwm_mode[BL_PWM]);
248
249         gpio_free(pwm_gpio);
250         iomux_set(pwm_mode[BL_PWM]);
251 #ifdef  LCD_DISP_ON_PIN
252         msleep(30);
253         gpio_direction_output(BL_EN_PIN, BL_EN_VALUE);
254 #endif
255         return 0;
256 }
257
258 static struct rk29_bl_info rk29_bl_info = {
259         .pwm_id = BL_PWM,
260         .min_brightness=60,
261         .max_brightness=255,
262         .brightness_mode = BRIGHTNESS_MODE_CONIC,
263         .bl_ref = PWM_EFFECT_VALUE,
264         .io_init = rk29_backlight_io_init,
265         .io_deinit = rk29_backlight_io_deinit,
266         .pwm_suspend = rk29_backlight_pwm_suspend,
267         .pwm_resume = rk29_backlight_pwm_resume,
268 };
269
270 static struct platform_device rk29_device_backlight = {
271         .name   = "rk29_backlight",
272         .id     = -1,
273         .dev    = {
274                 .platform_data  = &rk29_bl_info,
275         }
276 };
277 #endif
278
279 /***********************************************************
280 *       fb
281 ************************************************************/
282 #ifdef CONFIG_FB_ROCKCHIP
283 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
284 {
285         int ret = 0;
286
287         ret = rk_gpio_request(LCD_CS_PIN, GPIOF_DIR_OUT, LCD_CS_VALUE, "lcd_cs");
288         if(ret < 0)
289                 return ret;
290
291         return rk_gpio_request(LCD_EN_PIN, GPIOF_DIR_OUT, LCD_EN_VALUE, "lcd_en");
292 }
293
294 static int rk_fb_io_disable(void)
295 {
296         gpio_set_value(LCD_CS_PIN, !LCD_CS_VALUE);
297         gpio_set_value(LCD_EN_PIN, !LCD_EN_VALUE);
298
299         return 0;
300 }
301
302 static int rk_fb_io_enable(void)
303 {
304         gpio_set_value(LCD_CS_PIN, LCD_CS_VALUE);
305         gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
306
307         return 0;
308 }
309
310 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
311 struct rk29fb_info lcdc0_screen_info = {
312 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC0) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
313         .prop      = EXTEND,    //extend display device
314         .io_init    = NULL,
315         .io_disable = NULL,
316         .io_enable = NULL,
317         .set_screen_info = hdmi_init_lcdc,
318 #else
319         .prop      = PRMRY,             //primary display device
320         .io_init   = rk_fb_io_init,
321         .io_disable = rk_fb_io_disable,
322         .io_enable = rk_fb_io_enable,
323         .set_screen_info = set_lcd_info,
324 #endif
325 };
326 #endif
327
328 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
329 struct rk29fb_info lcdc1_screen_info = {
330 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC1) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
331         .prop      = EXTEND,    //extend display device
332         .io_init    = NULL,
333         .io_disable = NULL,
334         .io_enable = NULL,
335         .set_screen_info = hdmi_init_lcdc,
336 #else
337         .prop      = PRMRY,             //primary display device
338         .io_init   = rk_fb_io_init,
339         .io_disable = rk_fb_io_disable,
340         .io_enable = rk_fb_io_enable,
341         .set_screen_info = set_lcd_info,
342 #endif
343 };
344 #endif
345
346 static struct resource resource_fb[] = {
347         [0] = {
348                 .name  = "fb0 buf",
349                 .start = 0,
350                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
351                 .flags = IORESOURCE_MEM,
352         },
353         [1] = {
354                 .name  = "ipp buf",  //for rotate
355                 .start = 0,
356                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
357                 .flags = IORESOURCE_MEM,
358         },
359         [2] = {
360                 .name  = "fb2 buf",
361                 .start = 0,
362                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
363                 .flags = IORESOURCE_MEM,
364         },
365 };
366
367 static struct platform_device device_fb = {
368         .name           = "rk-fb",
369         .id             = -1,
370         .num_resources  = ARRAY_SIZE(resource_fb),
371         .resource       = resource_fb,
372 };
373 #endif
374
375 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
376 static struct resource resource_lcdc0[] = {
377         [0] = {
378                 .name  = "lcdc0 reg",
379                 .start = RK3026_LCDC0_PHYS,
380                 .end   = RK3026_LCDC0_PHYS + RK3026_LCDC0_SIZE - 1,
381                 .flags = IORESOURCE_MEM,
382         },
383         
384         [1] = {
385                 .name  = "lcdc0 irq",
386                 .start = IRQ_LCDC,
387                 .end   = IRQ_LCDC,
388                 .flags = IORESOURCE_IRQ,
389         },
390 };
391
392 static struct platform_device device_lcdc0 = {
393         .name             = "rk30-lcdc",
394         .id               = 0,
395         .num_resources    = ARRAY_SIZE(resource_lcdc0),
396         .resource         = resource_lcdc0,
397         .dev            = {
398                 .platform_data = &lcdc0_screen_info,
399         },
400 };
401 #endif
402
403 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
404 static struct resource resource_lcdc1[] = {
405         [0] = {
406                 .name  = "lcdc1 reg",
407                 .start = RK3026_LCDC1_PHYS,
408                 .end   = RK3026_LCDC1_PHYS + RK3026_LCDC1_SIZE - 1,
409                 .flags = IORESOURCE_MEM,
410         },
411         [1] = {
412                 .name  = "lcdc1 irq",
413                 .start = IRQ_LCDC1,
414                 .end   = IRQ_LCDC1,
415                 .flags = IORESOURCE_IRQ,
416         },
417 };
418
419 static struct platform_device device_lcdc1 = {
420         .name             = "rk30-lcdc",
421         .id               = 1,
422         .num_resources    = ARRAY_SIZE(resource_lcdc1),
423         .resource         = resource_lcdc1,
424         .dev            = {
425                 .platform_data = &lcdc1_screen_info,
426         },
427 };
428 #endif
429
430 static int rk_platform_add_display_devices(void)
431 {
432         struct platform_device *fb = NULL;  //fb
433         struct platform_device *lcdc0 = NULL; //lcdc0
434         struct platform_device *lcdc1 = NULL; //lcdc1
435         struct platform_device *bl = NULL; //backlight
436 #ifdef CONFIG_FB_ROCKCHIP
437         fb = &device_fb;
438 #endif
439
440 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
441         lcdc0 = &device_lcdc0,
442 #endif
443
444 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
445         lcdc1 = &device_lcdc1,
446 #endif
447
448 #ifdef CONFIG_BACKLIGHT_RK29_BL
449         bl = &rk29_device_backlight,
450 #endif
451         __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
452
453         return 0;
454 }
455
456
457 /***********************************************************
458 *       gsensor
459 ************************************************************/
460 // mma 8452 gsensor
461 #if defined (CONFIG_GS_MMA8452)
462 #define MMA8452_INT_PIN GS_INT_PIN
463 static int mma8452_init_platform_hw(void)
464 {
465         return 0;
466 }
467
468 static struct sensor_platform_data mma8452_info = {
469         .type = SENSOR_TYPE_ACCEL,
470         .irq_enable = 1,
471         .poll_delay_ms = 30,
472         .init_platform_hw = mma8452_init_platform_hw,
473         .orientation = {-1, 0, 0, 0, -1, 0, 0, 0, 1},
474 };
475 #endif
476
477 // lsm303d gsensor
478 #if defined (CONFIG_GS_LSM303D)
479 #define LSM303D_INT_PIN GS_INT_PIN
480 static int lms303d_init_platform_hw(void)
481 {
482         return 0;
483 }
484
485 static struct sensor_platform_data lms303d_info = {
486         .type = SENSOR_TYPE_ACCEL,
487         .irq_enable = 1,
488         .poll_delay_ms = 30,
489         .init_platform_hw = lms303d_init_platform_hw,
490         .orientation = {-1, 0, 0, 0, -1, 0, 0, 0, 1},
491 };
492 #endif
493
494
495 /*MMA7660 gsensor*/
496 #if defined (CONFIG_GS_MMA7660)
497 #define MMA7660_INT_PIN   GS_INT_PIN
498
499 static int mma7660_init_platform_hw(void)
500 {
501         //rk30_mux_api_set(GPIO1B2_SPI_RXD_UART1_SIN_NAME, GPIO1B_GPIO1B2);
502
503         return 0;
504 }
505
506 static struct sensor_platform_data mma7660_info = {
507         .type = SENSOR_TYPE_ACCEL,
508         .irq_enable = 1,
509         .poll_delay_ms = 30,
510     .init_platform_hw = mma7660_init_platform_hw,
511 #ifndef CONFIG_MFD_RK616
512         #ifdef CONFIG_TOUCHSCREEN_GSLX680_RK3168
513         .orientation = {-1, 0, 0, 0, -1, 0, 0, 0, 1},
514         #else
515     .orientation = {0, -1, 0, -1, 0, 0, 0, 0, -1},
516     #endif  
517 #else
518         .orientation = {1, 0, 0, 0, -1, 0, 0, 0, -1},
519 #endif  
520 };
521 #endif
522
523
524 #if defined (CONFIG_GS_MXC6225)
525 #define MXC6225_INT_PIN   GS_INT_PIN
526
527 static int mxc6225_init_platform_hw(void)
528 {
529         return 0;
530 }
531
532 static struct sensor_platform_data mxc6225_info = {
533         .type = SENSOR_TYPE_ACCEL,
534         .irq_enable = 0,
535         .poll_delay_ms = 30,
536         .init_platform_hw = mxc6225_init_platform_hw,
537         .orientation = { 0, -1, 0, 1, 0, 0, 0, 0, 0},
538 };
539 #endif
540 #if defined (CONFIG_GS_LIS3DH)
541 #define LIS3DH_INT_PIN   GS_INT_PIN
542         
543         static int lis3dh_init_platform_hw(void)
544         {
545         
546                 return 0;
547         }
548         
549         static struct sensor_platform_data lis3dh_info = {
550                 .type = SENSOR_TYPE_ACCEL,
551                 .irq_enable = 1,
552                 .poll_delay_ms = 30,
553                 .init_platform_hw = lis3dh_init_platform_hw,
554                 .orientation = {1, 0, 0, 0, 1, 0, 0, 0, 1},
555         };
556 #endif
557
558 #if defined (CONFIG_COMPASS_AK8975)
559 static struct sensor_platform_data akm8975_info =
560 {
561         .type = SENSOR_TYPE_COMPASS,
562         .irq_enable = 1,
563         .poll_delay_ms = 30,
564         .m_layout = 
565         {
566                 {
567                         {1, 0, 0},
568                         {0, 1, 0},
569                         {0, 0, 1},
570                 },
571
572                 {
573                         {1, 0, 0},
574                         {0, 1, 0},
575                         {0, 0, 1},
576                 },
577
578                 {
579                         {1, 0, 0},
580                         {0, 1, 0},
581                         {0, 0, 1},
582                 },
583
584                 {
585                         {1, 0, 0},
586                         {0, 1, 0},
587                         {0, 0, 1},
588                 },
589         }
590 };
591
592 #endif
593
594 #if defined (CONFIG_COMPASS_AK8963)
595 static struct sensor_platform_data akm8963_info =
596 {
597        .type = SENSOR_TYPE_COMPASS,
598        .irq_enable = 1,
599        .poll_delay_ms = 30,
600        .m_layout = 
601        {
602                {
603                        {0, 1, 0},
604                        {1, 0, 0},
605                        {0, 0, -1},
606                },
607
608                {
609                        {1, 0, 0},
610                        {0, 1, 0},
611                        {0, 0, 1},
612                },
613
614                {
615                        {0, -1, 0},
616                        {-1, 0, 0},
617                        {0, 0, -1},
618                },
619
620                {
621                        {1, 0, 0},
622                        {0, 1, 0},
623                        {0, 0, 1},
624                },
625        }
626 };
627
628 #endif
629
630
631 #if defined(CONFIG_GYRO_L3G4200D)
632
633 #include <linux/l3g4200d.h>
634 #define L3G4200D_INT_PIN  RK30_PIN0_PB4
635
636 static int l3g4200d_init_platform_hw(void)
637 {
638         return 0;
639 }
640
641 static struct sensor_platform_data l3g4200d_info = {
642         .type = SENSOR_TYPE_GYROSCOPE,
643         .irq_enable = 1,
644         .poll_delay_ms = 30,
645         .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
646         .init_platform_hw = l3g4200d_init_platform_hw,
647         .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
648         .y_min = 40,
649         .z_min = 20,
650 };
651
652 #endif
653
654 #ifdef CONFIG_LS_CM3217
655 static struct sensor_platform_data cm3217_info = {
656         .type = SENSOR_TYPE_LIGHT,
657         .irq_enable = 0,
658         .poll_delay_ms = 500,
659 };
660
661 #endif
662
663 /***********************************************************
664 *       keyboard
665 ************************************************************/
666 #include <plat/key.h>
667
668 static struct rk29_keys_button key_button[] = {
669         {
670                 .desc   = "play",
671                 .code   = KEY_POWER,
672                 .gpio   = PLAY_ON_PIN,
673                 .active_low = PRESS_LEV_LOW,
674                 .wakeup = 1,
675         },
676 /* disable adc keyboard,
677  * because rk280a adc reference voltage is 3.3V, but
678  * rk30xx mainbord key's supply voltage is 2.5V and
679  * rk31xx mainbord key's supply voltage is 1.8V.
680  */
681  /*
682         {
683                 .desc   = "vol+",
684                 .code   = KEY_VOLUMEUP,
685                 .gpio = INVALID_GPIO,
686                 .adc_value      = 1,
687                 .active_low = PRESS_LEV_LOW,
688         },
689         {
690                 .desc   = "vol-",
691                 .code   = KEY_VOLUMEDOWN,
692                 .gpio = INVALID_GPIO,
693                 .adc_value      = 512,
694                 .active_low = PRESS_LEV_LOW,
695         },
696         {
697         .desc   = "menu",
698         .code   = EV_MENU,
699         .adc_value      = 133,
700         .gpio = INVALID_GPIO,
701         .active_low = PRESS_LEV_LOW,
702     },
703     {
704          .code   = KEY_HOME,
705          .adc_value      = 550,
706          .gpio = INVALID_GPIO,
707          .active_low = PRESS_LEV_LOW,
708     },
709     {
710          .desc   = "esc",
711          .code   = KEY_BACK,
712          .adc_value      = 333,
713                 .gpio = INVALID_GPIO,
714                 .active_low = PRESS_LEV_LOW,
715         },
716         {
717                 .desc   = "camera",
718                 .code   = KEY_CAMERA,
719                 .adc_value      = 742,
720                 .gpio = INVALID_GPIO,
721                 .active_low = PRESS_LEV_LOW,
722         },*/
723
724 };
725
726 struct rk29_keys_platform_data rk29_keys_pdata = {
727         .buttons        = key_button,
728         .nbuttons       = ARRAY_SIZE(key_button),
729         .chn    = 3,  //chn: 0-7, if do not use ADC,set 'chn' -1
730 };
731
732 /***********************************************************
733 *       sdmmc
734 ************************************************************/
735 #ifdef CONFIG_SDMMC_RK29
736 #include "board-rk3028a-86v-sdmmc-config.c"
737 #include "../plat-rk/rk-sdmmc-ops.c"
738 #include "../plat-rk/rk-sdmmc-wifi.c"
739 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
740
741 #ifdef CONFIG_SDMMC0_RK29
742 #define CONFIG_SDMMC0_USE_DMA
743 static int rk29_sdmmc0_cfg_gpio(void)
744 {
745         rk29_sdmmc_set_iomux(0, 0xFFFF);
746         #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
747         iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
748         #else
749         iomux_set(MMC0_DETN);
750         #endif  
751
752         #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
753         gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
754         gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
755         #endif
756         return 0;
757 }
758
759 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
760         .host_ocr_avail =
761             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
762              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
763              MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
764         .host_caps =
765             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
766         .io_init = rk29_sdmmc0_cfg_gpio,
767
768         .set_iomux = rk29_sdmmc_set_iomux,
769
770         .dma_name = "sd_mmc",
771 #ifdef CONFIG_SDMMC0_USE_DMA
772         .use_dma = 1,
773 #else
774         .use_dma = 0,
775 #endif
776
777 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
778         .status = rk29sdk_wifi_mmc0_status,
779         .register_status_notify = rk29sdk_wifi_mmc0_status_register,
780 #endif
781
782 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
783         .power_en = RK29SDK_SD_CARD_PWR_EN,
784         .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
785 #else
786         .power_en = INVALID_GPIO,
787         .power_en_level = GPIO_LOW,
788 #endif    
789         .enable_sd_wakeup = 0,
790
791 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
792         .write_prt = SDMMC0_WRITE_PROTECT_PIN,
793         .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
794 #else
795         .write_prt = INVALID_GPIO,
796 #endif
797
798         .det_pin_info = {    
799                 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)  
800                 .io             = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
801                 .enable         = RK29SDK_SD_CARD_INSERT_LEVEL,
802                 #else
803                 .io             = INVALID_GPIO,
804                 .enable         = GPIO_LOW,
805                 #endif    
806         }, 
807
808 };
809 #endif // CONFIG_SDMMC0_RK29
810
811 #ifdef CONFIG_SDMMC1_RK29
812 #define CONFIG_SDMMC1_USE_DMA
813 static int rk29_sdmmc1_cfg_gpio(void)
814 {
815 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
816         gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
817         gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
818 #endif
819         return 0;
820 }
821
822 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
823         .host_ocr_avail =
824             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
825              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
826              MMC_VDD_33_34),
827
828 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
829         .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
830                       MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
831 #else
832         .host_caps =
833             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
834 #endif
835
836         .io_init = rk29_sdmmc1_cfg_gpio,
837
838         .set_iomux = rk29_sdmmc_set_iomux,
839
840         .dma_name = "sdio",
841 #ifdef CONFIG_SDMMC1_USE_DMA
842         .use_dma = 1,
843 #else
844         .use_dma = 0,
845 #endif
846
847 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
848         .status = rk29sdk_wifi_status,
849         .register_status_notify = rk29sdk_wifi_status_register,
850 #endif
851
852 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
853         .write_prt = SDMMC1_WRITE_PROTECT_PIN,
854         .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
855 #else
856         .write_prt = INVALID_GPIO,
857 #endif
858
859     #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
860         .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
861     #endif
862
863         .det_pin_info = {    
864         #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
865                 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)  
866                 .io             = RK29SDK_SD_CARD_DETECT_N,
867                 #else
868                 .io             = INVALID_GPIO,
869                 #endif   
870
871                 .enable         = RK29SDK_SD_CARD_INSERT_LEVEL,
872         #else
873                 .io             = INVALID_GPIO,
874                 .enable         = GPIO_LOW,
875         #endif
876         },
877         .enable_sd_wakeup = 0,
878 };
879 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
880
881 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
882 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
883         .dc_det_pin      = RK30_PIN1_PB4,
884         .batt_low_pin    = INVALID_GPIO, 
885         .charge_set_pin  = INVALID_GPIO,
886         .charge_ok_pin   = RK30_PIN1_PA0,
887          .usb_det_pin = INVALID_GPIO,
888         .dc_det_level    = GPIO_LOW,
889         .charge_ok_level = GPIO_HIGH,
890
891         .reference_voltage = 3300, // the rK2928 is 3300;RK3066 and rk29 are 2500;rk3066B is 1800;
892        .pull_up_res = 200,     //divider resistance ,  pull-up resistor
893        .pull_down_res = 120, //divider resistance , pull-down resistor
894
895         .is_reboot_charging = 1,
896         .save_capacity   = 1 ,
897         .low_voltage_protection = 3600,    
898 };
899
900 static struct platform_device rk30_device_adc_battery = {
901         .name   = "rk30-battery",
902         .id     = -1,
903         .dev = {
904                 .platform_data = &rk30_adc_battery_platdata,
905         },
906 };
907 #endif
908
909
910 /***********************************************************
911 *       rfkill
912 ************************************************************/
913 #ifdef CONFIG_RFKILL_RK
914 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
915 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
916         .type               = RFKILL_TYPE_BLUETOOTH,
917
918         .poweron_gpio       = { // BT_REG_ON
919                 .io             = INVALID_GPIO, //RK30_PIN3_PC7,
920                 .enable         = GPIO_HIGH,
921                 .iomux          = {
922                         .name       = "bt_poweron",
923                         //.fgpio      = GPIO3_C7,
924                 },
925         },
926
927         .reset_gpio         = { // BT_RST
928                 .io             = RK30_PIN1_PB3, // set io to INVALID_GPIO for disable it
929                 .enable         = GPIO_LOW,
930                 .iomux          = {
931                         .name       = "bt_reset",
932                         .fgpio      = GPIO1_B3,
933                 },
934         }, 
935
936         .wake_gpio          = { // BT_WAKE, use to control bt's sleep and wakeup
937                 .io             = RK30_PIN1_PB2, // set io to INVALID_GPIO for disable it
938                 .enable         = GPIO_HIGH,
939                 .iomux          = {
940                         .name       = "bt_wake",
941                         .fgpio      = GPIO1_B2,
942                 },
943         },
944
945         .wake_host_irq      = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
946                 .gpio           = {
947                         .io         = RK30_PIN0_PA4, // set io to INVALID_GPIO for disable it
948                         .enable     = GPIO_LOW,      // set GPIO_LOW for falling, set 0 for rising
949                         .iomux      = {
950                                 .name   = "bt_wake_host",
951                                 //.fgpio  = GPIO0_A4,  
952                         },
953                 },
954         },
955
956         .rts_gpio           = { // UART_RTS, enable or disable BT's data coming
957                 .io             = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
958                 .enable         = GPIO_LOW,
959                 .iomux          = {
960                         .name       = "bt_rts",
961                         .fgpio      = GPIO1_A3,
962                         .fmux       = UART0_RTSN,
963                 },
964         }
965 };
966
967 static struct platform_device device_rfkill_rk = {
968     .name   = "rfkill_rk",
969     .id     = -1,
970     .dev    = {
971         .platform_data = &rfkill_rk_platdata,
972     },
973 };
974 #endif
975
976 /***********************************************************
977 *       ion
978 ************************************************************/
979 #ifdef CONFIG_ION
980 static struct ion_platform_data rk30_ion_pdata = {
981         .nr = 1,
982         .heaps = {
983                 {
984                         .type = ION_HEAP_TYPE_CARVEOUT,
985                         .id = ION_NOR_HEAP_ID,
986                         .name = "norheap",
987                         .size = ION_RESERVE_SIZE,
988                 }
989         },
990 };
991
992 static struct platform_device device_ion = {
993         .name = "ion-rockchip",
994         .id = 0,
995         .dev = {
996                 .platform_data = &rk30_ion_pdata,
997         },
998 };
999 #endif
1000
1001 /***********************************************************
1002 *       pwm regulator
1003 ************************************************************/
1004 #ifdef CONFIG_RK30_PWM_REGULATOR
1005 static int pwm_voltage_map[] = {
1006         800000,  825000,  850000,  875000,  900000,  925000 ,
1007         950000,  975000,  1000000, 1025000, 1050000, 1075000, 
1008         1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 
1009         1250000, 1275000, 1300000, 1325000, 1350000, 1375000
1010 };
1011
1012 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1013         {
1014                 .supply = "vdd_core",
1015         }
1016 };
1017
1018 struct regulator_init_data pwm_regulator_init_dcdc[1] = {
1019         {
1020                 .constraints = {
1021                         .name = "PWM_DCDC1",
1022                         .min_uV = 600000,
1023                         .max_uV = 1800000,      //0.6-1.8V
1024                         .apply_uV = true,
1025                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1026                 },
1027                 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1028                 .consumer_supplies = pwm_dcdc1_consumers,
1029         },
1030 };
1031
1032 static struct pwm_platform_data pwm_regulator_info[1] = {
1033         {
1034                 .pwm_id = REG_PWM,
1035                 .pwm_voltage = 1200000,
1036                 .suspend_voltage = 1050000,
1037                 .min_uV = 950000,
1038                 .max_uV = 1400000,
1039                 .coefficient = 504,     //50.4%
1040                 .pwm_voltage_map = pwm_voltage_map,
1041                 .init_data      = &pwm_regulator_init_dcdc[0],
1042         },
1043 };
1044 struct platform_device pwm_regulator_device[1] = {
1045         {
1046                 .name = "pwm-voltage-regulator",
1047                 .id = 0,
1048                 .dev            = {
1049                         .platform_data = &pwm_regulator_info[0],
1050                 }
1051         },
1052 };
1053
1054 static void pwm_regulator_init(void)
1055 {
1056         pwm_regulator_info[0].pwm_gpio = iomux_mode_to_gpio(pwm_mode[REG_PWM]);
1057         pwm_regulator_info[0].pwm_iomux_pwm = pwm_mode[REG_PWM];
1058         pwm_regulator_info[0].pwm_iomux_gpio = iomux_switch_gpio_mode(pwm_mode[REG_PWM]);
1059 }
1060 #endif
1061
1062 int __sramdata pwm_iomux, pwm_do, pwm_dir, pwm_en;
1063 #define grf_readl(offset)       readl_relaxed(RK30_GRF_BASE + offset)
1064 #define grf_writel(v, offset)   do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
1065
1066 #define GPIO0_D2_OFFSET         10
1067 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1068 {
1069 #ifdef CONFIG_RK30_PWM_REGULATOR
1070         #if 0
1071         /* pwm0: GPIO0_D2, pwm1: GPIO0_D3, pwm2: GPIO0_D4 */
1072         int off = GPIO0_D2_OFFSET + REG_PWM;
1073
1074         sram_udelay(10000);
1075         pwm_iomux = grf_readl(GRF_GPIO0D_IOMUX);
1076         pwm_dir = grf_readl(GRF_GPIO0H_DIR);
1077         pwm_do = grf_readl(GRF_GPIO0H_DO);
1078         pwm__en = grf_readl(GRF_GPIO0H_EN);
1079
1080         grf_writel((1<<(2 * off), GRF_GPIO0D_IOMUX);
1081         grf_writel((1<<(16 + off))|(1<<off), GRF_GPIO0H_DIR);
1082         grf_writel((1<<(16 + off))|(1<<off), GRF_GPIO0H_DO);
1083         #endif
1084 #endif
1085 }
1086
1087 void __sramfunc rk30_pwm_logic_resume_voltage(void)
1088 {
1089 #ifdef CONFIG_RK30_PWM_REGULATOR
1090         #if 0
1091         /* pwm0: GPIO0_D2, pwm1: GPIO0_D3, pwm2: GPIO0_D4 */
1092         int off = GPIO0_D2_OFFSET + REG_PWM;
1093
1094         grf_writel((1<<(2 * off))|pwm_iomux, GRF_GPIO0D_IOMUX);
1095         grf_writel(((1<<(16 + off))|pwm_dir), GRF_GPIO0L_DIR);
1096         grf_writel(((1<<(16 + off))|pwm_do), GRF_GPIO0L_DO);
1097         grf_writel(((1<<(16 + off))|pwm_en), GRF_GPIO0L_EN);
1098         sram_udelay(10000);
1099         #endif
1100 #endif
1101 }
1102 extern void pwm_suspend_voltage(void);
1103 extern void pwm_resume_voltage(void);
1104
1105 void  rk30_pwm_suspend_voltage_set(void)
1106 {
1107 #ifdef CONFIG_RK30_PWM_REGULATOR
1108         pwm_suspend_voltage();
1109 #endif
1110 }
1111
1112 void  rk30_pwm_resume_voltage_set(void)
1113 {
1114 #ifdef CONFIG_RK30_PWM_REGULATOR
1115         pwm_resume_voltage();
1116 #endif
1117 }
1118
1119 /***********************************************************
1120 *       pmic
1121 ************************************************************/
1122 int __sramdata g_pmic_type =  0;
1123
1124 #ifdef CONFIG_MFD_TPS65910
1125 #define TPS65910_HOST_IRQ       PMU_INT_PIN
1126 #define PMU_POWER_SLEEP         PMU_SLEEP_PIN
1127 static struct pmu_info  tps65910_dcdc_info[] = {
1128         {
1129                 .name          = "vdd_core",   //logic
1130                 .min_uv          = 1100000,
1131                 .max_uv         = 1100000,
1132         },
1133         {
1134                 .name          = "vdd_cpu",    //arm
1135                 .min_uv          = 1100000,
1136                 .max_uv         = 1100000,
1137         },
1138         {
1139                 .name          = "vio",   //vcc_io
1140                 .min_uv          = 3300000,
1141                 .max_uv         = 3300000,
1142         },
1143         
1144 };
1145 static  struct pmu_info  tps65910_ldo_info[] = {
1146         /*{
1147                 .name          = "vpll",   //vdd10
1148                 .min_uv          = 1000000,
1149                 .max_uv         = 1000000,
1150         },*/
1151         {
1152                 .name          = "vdig1",    //vcc18_cif
1153                 .min_uv          = 2800000,//1800000,
1154                 .max_uv         = 2800000,//1800000,
1155         },
1156         {
1157                 .name          = "vdig2",   //vdd11
1158                 .min_uv          = 1100000,
1159                 .max_uv         = 1100000,
1160         },
1161         {
1162                 .name          = "vaux1",   //vcc28_cif
1163                 .min_uv          = 2800000,
1164                 .max_uv         = 2800000,
1165         },
1166         {
1167                 .name          = "vaux2",   //vcc33
1168                 .min_uv          = 3300000,
1169                 .max_uv         = 3300000,
1170         },
1171         {
1172                 .name          = "vaux33",   //vcc_tp
1173                 .min_uv          = 3300000,
1174                 .max_uv         = 3300000,
1175         },
1176         {
1177                 .name          = "vmmc",   //vcca30
1178                 .min_uv          = 3000000,
1179                 .max_uv         = 3000000,
1180         },
1181         {
1182                 .name          = "vdac",   //
1183                 .min_uv          = 1800000,
1184                 .max_uv         = 1800000,
1185         },
1186 };
1187 #include "../mach-rk30/board-pmu-tps65910.c"
1188 #endif
1189
1190 void __sramfunc board_pmu_suspend(void)
1191 {
1192         #if defined (CONFIG_MFD_TPS65910)
1193         if(pmic_is_tps65910())
1194                 board_pmu_tps65910_suspend();
1195         #endif
1196 }
1197
1198 void __sramfunc board_pmu_resume(void)
1199 {
1200         #if defined (CONFIG_MFD_TPS65910)
1201         if(pmic_is_tps65910())
1202                 board_pmu_tps65910_resume();
1203         #endif
1204 }
1205
1206 #ifdef CONFIG_SND_SOC_RK3026
1207 struct rk3026_codec_pdata rk3026_codec_pdata_info={
1208     .spk_ctl_gpio = RK2928_PIN3_PD4,
1209     .hp_ctl_gpio = RK2928_PIN3_PD4,
1210 };
1211
1212 static struct resource resources_acodec[] = {
1213         {
1214                 .start  = RK2928_ACODEC_PHYS,
1215                 .end    = RK2928_ACODEC_PHYS + RK2928_ACODEC_SIZE - 1,
1216                 .flags  = IORESOURCE_MEM,
1217         },
1218 };
1219
1220 static struct platform_device rk3026_codec = {
1221         .name   = "rk3026-codec",
1222         .id             = -1,
1223         .resource = resources_acodec,
1224         .dev = {
1225                 .platform_data = &rk3026_codec_pdata_info,
1226     }
1227 };
1228 #endif
1229 #if defined(CONFIG_GPS_RK)
1230 #define GPS_OSCEN_PIN   RK2928_PIN1_PB0
1231 #define GPS_RXEN_PIN    RK2928_PIN1_PB0
1232
1233 static int rk_gps_io_init(void)
1234 {
1235         printk("%s \n", __FUNCTION__);
1236         
1237         gpio_request(GPS_OSCEN_PIN, NULL);
1238         gpio_direction_output(GPS_OSCEN_PIN, GPIO_LOW); 
1239         
1240         iomux_set(GPS_CLK);//GPS_CLK
1241         iomux_set(GPS_MAG);//GPS_MAG
1242         iomux_set(GPS_SIGN);//GPS_SIGN
1243 #if 0
1244         gpio_request(RK30_PIN1_PA6, NULL);
1245         gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1246
1247         gpio_request(RK30_PIN1_PA5, NULL);
1248         gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW); 
1249
1250         gpio_request(RK30_PIN1_PA7, NULL);
1251         gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);         
1252 #endif  
1253         return 0;
1254 }
1255 static int rk_gps_power_up(void)
1256 {
1257         printk("%s \n", __FUNCTION__);
1258
1259         return 0;
1260 }
1261
1262 static int rk_gps_power_down(void)
1263 {
1264         printk("%s \n", __FUNCTION__);
1265
1266         return 0;
1267 }
1268
1269 static int rk_gps_reset_set(int level)
1270 {
1271         return 0;
1272 }
1273 static int rk_enable_hclk_gps(void)
1274 {
1275         struct clk *gps_aclk = NULL;
1276         gps_aclk = clk_get(NULL, "aclk_gps");
1277         if(gps_aclk) {
1278                 clk_enable(gps_aclk);
1279                 clk_put(gps_aclk);
1280                 printk("%s \n", __FUNCTION__);
1281         }
1282         else
1283                 printk("get gps aclk fail\n");
1284         return 0;
1285 }
1286 static int rk_disable_hclk_gps(void)
1287 {
1288         struct clk *gps_aclk = NULL;
1289         gps_aclk = clk_get(NULL, "aclk_gps");
1290         if(gps_aclk) {
1291                 //TO wait long enough until GPS ISR is finished.
1292                 msleep(5);
1293                 clk_disable(gps_aclk);
1294                 clk_put(gps_aclk);
1295                 printk("%s \n", __FUNCTION__);
1296         }       
1297         else
1298                 printk("get gps aclk fail\n");
1299         return 0;
1300 }
1301 static struct rk_gps_data rk_gps_info = {
1302         .io_init = rk_gps_io_init,
1303         .power_up = rk_gps_power_up,
1304         .power_down = rk_gps_power_down,
1305         .reset = rk_gps_reset_set,
1306         .enable_hclk_gps = rk_enable_hclk_gps,
1307         .disable_hclk_gps = rk_disable_hclk_gps,
1308         .GpsSign = RK2928_PIN1_PA5,
1309         .GpsMag = RK2928_PIN1_PA4,        //GPIO index
1310         .GpsClk = RK2928_PIN1_PA2,        //GPIO index
1311         .GpsVCCEn = GPS_OSCEN_PIN,     //GPIO index
1312 #if 0   
1313         .GpsSpi_CSO = RK30_PIN1_PA4,    //GPIO index
1314         .GpsSpiClk = RK30_PIN1_PA5,     //GPIO index
1315         .GpsSpiMOSI = RK30_PIN1_PA7,      //GPIO index
1316 #endif  
1317         .GpsIrq = IRQ_GPS,
1318         .GpsSpiEn = 0,
1319         .GpsAdcCh = 2,
1320         .u32GpsPhyAddr = RK2928_GPS_PHYS,
1321         .u32GpsPhySize = RK2928_GPS_SIZE,
1322 };
1323
1324 static struct platform_device rk_device_gps = {
1325         .name = "gps_hv5820b",
1326         .id = -1,
1327         .dev            = {
1328         .platform_data = &rk_gps_info,
1329                 }
1330         };
1331 #endif
1332
1333
1334 /***********************************************************
1335 *       i2c
1336 ************************************************************/
1337 #ifdef CONFIG_I2C0_RK30
1338 static struct i2c_board_info __initdata i2c0_info[] = {
1339 #if defined (CONFIG_MFD_TPS65910)
1340         {
1341                 .type           = "tps65910",
1342                 .addr           = TPS65910_I2C_ID0,
1343                 .flags          = 0,
1344                 .irq            = TPS65910_HOST_IRQ,
1345                 .platform_data = &tps65910_data,
1346         },
1347 #endif
1348
1349 };
1350 #endif
1351
1352 #ifdef CONFIG_I2C1_RK30
1353 static struct i2c_board_info __initdata i2c1_info[] = {
1354 #if defined (CONFIG_GS_MXC6225)
1355         {
1356                 .type           = "gs_mxc6225",
1357                 .addr           = 0x15,
1358                 .flags          = 0,
1359                 .irq            = MXC6225_INT_PIN,
1360                 .platform_data  = &mxc6225_info,
1361         },
1362 #endif
1363 #if defined (CONFIG_GS_MMA7660)
1364         {
1365                 .type           = "gs_mma7660",//gs_mma7660
1366                 .addr           = 0x4c,
1367                 .flags          = 0,
1368                 .irq            = MMA7660_INT_PIN,
1369                 .platform_data = &mma7660_info,
1370         },
1371 #endif
1372 #if defined (CONFIG_GS_MMA8452)
1373         {
1374                 .type           = "gs_mma8452",
1375                 .addr           = 0x1d,
1376                 .flags          = 0,
1377                 .irq            = MMA8452_INT_PIN,
1378                 .platform_data = &mma8452_info,
1379         },
1380 #endif
1381 #if defined (CONFIG_GS_LIS3DH)
1382         {
1383                 .type           = "gs_lis3dh",
1384                 .addr           = 0x19,   //0x19(SA0-->VCC), 0x18(SA0-->GND)
1385                 .flags          = 0,
1386                 .irq            = LIS3DH_INT_PIN,
1387                 .platform_data = &lis3dh_info,
1388         },
1389 #endif
1390 #if defined (CONFIG_GS_LSM303D)
1391         {
1392             .type           = "gs_lsm303d",
1393             .addr           = 0x1d,   //0x19(SA0-->VCC), 0x18(SA0-->GND)
1394             .flags          = 0,
1395             .irq            = LSM303D_INT_PIN,         
1396             .platform_data  = &lms303d_info,           
1397         },
1398 #endif
1399 #if defined (CONFIG_COMPASS_AK8975)
1400         {
1401                 .type          = "ak8975",
1402                 .addr          = 0x0d,
1403                 .flags         = 0,
1404                 .irq           = RK30_PIN3_PD7, 
1405                 .platform_data = &akm8975_info,
1406                 .irq           = RK30_PIN3_PD7, 
1407                 .platform_data = &akm8975_info,
1408         },
1409 #endif
1410 #if defined (CONFIG_COMPASS_AK8963)
1411         {
1412                 .type          = "ak8963",
1413                 .addr          = 0x0d,
1414                 .flags         = 0,
1415                 .irq           = RK30_PIN3_PD7, 
1416                 .platform_data = &akm8963_info,
1417         },
1418 #endif
1419 #if defined (CONFIG_GYRO_L3G4200D)
1420         {
1421                 .type          = "l3g4200d_gryo",
1422                 .addr          = 0x69,
1423                 .flags         = 0,
1424                 .irq           = L3G4200D_INT_PIN,
1425                 .platform_data = &l3g4200d_info,
1426         },
1427 #endif
1428
1429 };
1430 #endif
1431
1432 #ifdef CONFIG_I2C2_RK30
1433 static struct i2c_board_info __initdata i2c2_info[] = {
1434 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
1435         {
1436                 .type          = "Goodix-TS",
1437                 .addr          = 0x55,
1438                 .flags         = 0,
1439                 .irq           = TOUCH_INT_PIN,
1440                 .platform_data = &goodix_info,
1441         },
1442 #endif
1443 #if defined (CONFIG_TOUCHSCREEN_GSLX680_RK3028)
1444     {
1445         .type           = "gslX680",
1446         .addr           = 0x40,
1447         .flags          = 0,
1448         .platform_data =&gslx680_info,
1449     },
1450 #endif
1451
1452 };
1453 #endif
1454
1455 #ifdef CONFIG_I2C3_RK30
1456 static struct i2c_board_info __initdata i2c3_info[] = {
1457 };
1458 #endif
1459
1460 #ifdef CONFIG_I2C_GPIO_RK30
1461 #define I2C_SDA_PIN     INVALID_GPIO// RK30_PIN2_PD6   //set sda_pin here
1462 #define I2C_SCL_PIN     INVALID_GPIO//RK30_PIN2_PD7   //set scl_pin here
1463 static int rk30_i2c_io_init(void)
1464 {
1465         return 0;
1466 }
1467
1468 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1469        .sda_pin = I2C_SDA_PIN,
1470        .scl_pin = I2C_SCL_PIN,
1471        .udelay = 5, // clk = 500/udelay = 100Khz
1472        .timeout = 100,//msecs_to_jiffies(100),
1473        .bus_num    = 5,
1474        .io_init = rk30_i2c_io_init,
1475 };
1476
1477 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1478 };
1479 #endif
1480
1481 static void __init rk30_i2c_register_board_info(void)
1482 {
1483 #ifdef CONFIG_I2C0_RK30
1484         i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1485 #endif
1486 #ifdef CONFIG_I2C1_RK30
1487         i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1488 #endif
1489 #ifdef CONFIG_I2C2_RK30
1490         i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1491 #endif
1492 #ifdef CONFIG_I2C3_RK30
1493         i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1494 #endif
1495 #ifdef CONFIG_I2C_GPIO_RK30
1496         i2c_register_board_info(4, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1497 #endif
1498 }
1499
1500 /***********************************************************
1501 *       board init
1502 ************************************************************/
1503 static struct platform_device *devices[] __initdata = {
1504 #ifdef CONFIG_ION
1505         &device_ion,
1506 #endif
1507 #ifdef CONFIG_WIFI_CONTROL_FUNC
1508         &rk29sdk_wifi_device,
1509 #endif
1510 #ifdef CONFIG_RFKILL_RK
1511         &device_rfkill_rk,
1512 #endif
1513 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
1514         &rk30_device_adc_battery,
1515 #endif
1516 #ifdef CONFIG_SND_SOC_RK3026
1517         &rk3026_codec,
1518 #endif
1519 #ifdef CONFIG_GPS_RK
1520         &rk_device_gps,
1521 #endif
1522 };
1523
1524 static void rk30_pm_power_off(void)
1525 {
1526 #if defined(CONFIG_MFD_TPS65910)
1527         tps65910_device_shutdown();//tps65910 shutdown
1528 #endif
1529         gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
1530         while(1);
1531 }
1532
1533 static void __init machine_rk30_board_init(void)
1534 {
1535 #ifdef CONFIG_RK30_PWM_REGULATOR
1536         pwm_regulator_init();
1537 #endif
1538         avs_init();
1539         pm_power_off = rk30_pm_power_off;
1540         rk_gpio_request(POWER_ON_PIN, GPIOF_DIR_OUT, GPIO_HIGH, "system power on");
1541         rk30_i2c_register_board_info();
1542         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1543         platform_add_devices(devices, ARRAY_SIZE(devices));
1544         rk_platform_add_display_devices();      
1545 #if defined(CONFIG_WIFI_CONTROL_FUNC)
1546         rk29sdk_wifi_bt_gpio_control_init();
1547 #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1548     rk29sdk_wifi_combo_module_gpio_init();
1549 #endif
1550 }
1551
1552 static void __init rk30_reserve(void)
1553 {
1554         //fb reserve
1555 #ifdef CONFIG_FB_ROCKCHIP
1556         resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
1557         resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
1558         #if 0
1559         resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
1560         resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
1561         #endif
1562
1563         #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
1564         resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
1565         resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
1566         #endif
1567 #endif
1568         //ion reserve
1569 #ifdef CONFIG_ION
1570         rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
1571 #endif
1572
1573 #ifdef CONFIG_VIDEO_RK29
1574         rk30_camera_request_reserve_mem();
1575 #endif
1576 #ifdef CONFIG_GPS_RK
1577         //it must be more than 8MB
1578         rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
1579 #endif
1580         board_mem_reserved();
1581 }
1582
1583 /***********************************************************
1584 *       clock
1585 ************************************************************/
1586 static struct cpufreq_frequency_table dvfs_arm_table[] = {
1587         {.frequency = 312 * 1000,       .index = 1100 * 1000},
1588         {.frequency = 504 * 1000,       .index = 1100 * 1000},
1589         {.frequency = 816 * 1000,       .index = 1150 * 1000},
1590         {.frequency = 1008 * 1000,      .index = 1200 * 1000},
1591         //{.frequency = 1200 * 1000,      .index = 1300 * 1000},
1592         //{.frequency = 1416 * 1000,      .index = 1200 * 1000},
1593         //{.frequency = 1608 * 1000,      .index = 1200 * 1000},
1594         {.frequency = CPUFREQ_TABLE_END},
1595 };
1596
1597 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
1598         //{.frequency = 100 * 1000,       .index = 1200 * 1000},
1599         {.frequency = 200 * 1000,       .index = 1200 * 1000},
1600         //{.frequency = 266 * 1000,       .index = 1200 * 1000},
1601         //{.frequency = 300 * 1000,       .index = 1200 * 1000},
1602         //{.frequency = 400 * 1000,       .index = 1200 * 1000},
1603         {.frequency = CPUFREQ_TABLE_END},
1604 };
1605
1606 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
1607         //{.frequency = 200 * 1000 + DDR_FREQ_SUSPEND,    .index = 1200 * 1000},
1608         //{.frequency = 300 * 1000 + DDR_FREQ_VIDEO,      .index = 1200 * 1000},
1609         {.frequency = 360 * 1000 + DDR_FREQ_NORMAL,     .index = 1200 * 1000},
1610         {.frequency = CPUFREQ_TABLE_END},
1611 };
1612
1613 void __init board_clock_init(void)
1614 {
1615         rk2928_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
1616         //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);    
1617         dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
1618         dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
1619         dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
1620 }
1621
1622 /************************ end *****************************/
1623 MACHINE_START(RK30, "RK30board")
1624         .boot_params    = PLAT_PHYS_OFFSET + 0x800,
1625         .fixup          = rk2928_fixup,
1626         .reserve        = &rk30_reserve,
1627         .map_io         = rk2928_map_io,
1628         .init_irq       = rk2928_init_irq,
1629         .timer          = &rk2928_timer,
1630         .init_machine   = machine_rk30_board_init,
1631 MACHINE_END