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-fac.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 #include <plat/config.h>
67 #include <plat/board.h>
68 #include "../plat-rk/rk-fac-config.c"
69 #if 1
70 #define INIT_ERR(name)     do { printk("%s: %s init Failed: \n", __func__, (name)); } while(0)
71 #else
72 #define INIT_ERR(name)
73 #endif
74
75 /***********************************************************
76 *       board config
77 ************************************************************/
78
79 //pwm regulator
80 #define REG_PWM                 1  // (0 ~ 2)
81 //pmic
82 #define PMU_INT_PIN             RK30_PIN3_PC6
83 #define PMU_SLEEP_PIN           RK30_PIN3_PC4
84 //ion reserve memory
85 #define ION_RESERVE_SIZE        (80 * SZ_1M)
86
87 static int pwm_mode[] = {PWM0, PWM1, PWM2};
88 static inline int rk_gpio_request(int gpio, int direction, int value, const char *label)
89 {
90         int ret = 0;
91         unsigned long flags = 0;
92
93         if(!gpio_is_valid(gpio))
94                 return 0;
95
96         if(direction == GPIOF_DIR_IN)
97                 flags = GPIOF_IN;
98         else if(value == GPIO_LOW)
99                 flags = GPIOF_OUT_INIT_LOW;
100         else
101                 flags = GPIOF_OUT_INIT_HIGH;
102
103         ret = gpio_request_one(gpio, flags, label);
104         if(ret < 0)
105                 pr_err("Failed to request '%s'\n", label);
106
107         return ret;
108 }
109 ////////////////////////////////////////////////////////////////////////////////////////
110 //key
111 ////////////////////////////////////////////////////////////////////////////////////////
112 #include <plat/key.h>
113 static struct rk29_keys_button key_button[] = { 
114         {               
115                 .desc   = "play",               
116                 .code   = KEY_POWER,            
117                 .wakeup = 1,    
118         },      
119         {               
120                 .desc   = "vol-",       
121                 .code   = KEY_VOLUMEDOWN,       
122         },      
123         {               
124                 .desc   = "vol+",               
125                 .code   = KEY_VOLUMEUP, 
126         },      
127         {               
128                 .desc   = "menu",               
129                 .code   = EV_MENU,      
130         },      
131         {               
132                 .desc   = "esc",                
133                 .code   = KEY_BACK,     
134         },      
135         {               
136                 .desc   = "home",               
137                 .code   = KEY_HOME,     
138         },      
139 };
140 struct rk29_keys_platform_data rk29_keys_pdata = {      
141         .buttons        = key_button,   
142         .chn    = -1,  //chn: 0-7, if do not use ADC,set 'chn' -1
143 };
144 ////////////////////////////////////////////////////////////////////////////////////////
145 //Backlight
146 ////////////////////////////////////////////////////////////////////////////////////////
147 #ifdef CONFIG_BACKLIGHT_RK29_BL
148 static int rk29_backlight_io_init(void)
149 {
150         int ret = 0;
151         printk("rk29_backlight_io_init %d\n",bl_pwm_mode);
152         iomux_set(bl_pwm_mode);
153         msleep(50);     
154         if(bl_en== -1)                
155                 return 0;  
156         ret = port_output_init(bl_en, 1, "bl_en"); 
157         if(ret < 0){                
158                 printk("%s: port output init faild\n", __func__);
159                 return ret;        
160         }        
161         port_output_on(bl_en);
162
163         return ret;
164         
165 }
166
167 static int rk29_backlight_io_deinit(void)
168 {
169         int ret = 0, pwm_gpio;  
170         
171         if(bl_en != -1)                
172                 port_deinit(bl_en); 
173         
174         pwm_gpio = iomux_mode_to_gpio(bl_pwm_mode);
175         gpio_request(pwm_gpio, NULL);
176         gpio_direction_output(pwm_gpio, GPIO_LOW);
177         return ret;
178 }
179
180 static int rk29_backlight_pwm_suspend(void)
181 {
182         int ret = 0, pwm_gpio;
183
184         pwm_gpio = iomux_mode_to_gpio(bl_pwm_mode);
185         if (gpio_request(pwm_gpio, NULL)) {
186                 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
187                 return -1;
188         }
189         gpio_direction_output(pwm_gpio, GPIO_LOW);
190         port_output_off(bl_en);
191         return ret;
192 }
193
194 static int rk29_backlight_pwm_resume(void)
195 {
196         int pwm_gpio = iomux_mode_to_gpio(bl_pwm_mode);
197
198         gpio_free(pwm_gpio);
199         iomux_set(bl_pwm_mode);
200         msleep(30);
201         port_output_on(bl_en);
202         return 0;
203 }
204
205 static struct rk29_bl_info rk29_bl_info = {
206         .io_init = rk29_backlight_io_init,
207         .io_deinit = rk29_backlight_io_deinit,
208         .pwm_suspend = rk29_backlight_pwm_suspend,
209         .pwm_resume = rk29_backlight_pwm_resume,
210 };
211
212 static struct platform_device rk29_device_backlight = {
213         .name   = "rk29_backlight",
214         .id     = -1,
215         .dev    = {
216                 .platform_data  = &rk29_bl_info,
217         }
218 };
219 #endif
220 ////////////////////////////////////////////////////////////////////////////////////////
221 //LCD
222 ////////////////////////////////////////////////////////////////////////////////////////
223 #ifdef CONFIG_FB_ROCKCHIP
224 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
225 {
226         int ret = 0;
227         //printk("rk_fb_io_init %x,%x,%x\n",lcd_cs,lcd_en,lcd_std);
228         if(lcd_cs != -1){                
229                 ret = port_output_init(lcd_cs, 1, "lcd_cs"); 
230                 if(ret < 0)                       
231                         printk("%s: port output init faild\n", __func__);
232                 port_output_on(lcd_cs);
233         }   
234         
235         if(lcd_en != -1){          
236                 ret = port_output_init(lcd_en, 1, "lcd_en");        
237                 if(ret < 0)                
238                         printk("%s: port output init faild\n", __func__);       
239                 port_output_on(lcd_en); 
240         }
241         
242         return 0;
243 }
244 static int rk_fb_io_disable(void)
245 {
246         if(lcd_cs != -1)                
247                 port_output_off(lcd_cs);        
248         if(lcd_en != -1)                
249                 port_output_on(lcd_en); 
250         return 0;
251 }
252 static int rk_fb_io_enable(void)
253 {
254         if(lcd_en != -1)                
255                 port_output_on(lcd_en); 
256         if(lcd_cs != -1)                
257                 port_output_on(lcd_cs);         
258         return 0;
259 }
260
261 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
262 struct rk29fb_info lcdc0_screen_info = {
263 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC0) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
264         .prop      = EXTEND,    //extend display device
265         .io_init    = NULL,
266         .io_disable = NULL,
267         .io_enable = NULL,
268         .set_screen_info = hdmi_init_lcdc,
269 #else
270         .prop      = PRMRY,             //primary display device
271         .io_init   = rk_fb_io_init,
272         .io_disable = rk_fb_io_disable,
273         .io_enable = rk_fb_io_enable,
274         .set_screen_info = set_lcd_info,
275 #endif
276 };
277 #endif
278
279 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
280 struct rk29fb_info lcdc1_screen_info = {
281 #if defined(CONFIG_RK_HDMI) && defined(CONFIG_HDMI_SOURCE_LCDC1) && defined(CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL)
282         .prop      = EXTEND,    //extend display device
283         .io_init    = NULL,
284         .io_disable = NULL,
285         .io_enable = NULL,
286         .set_screen_info = hdmi_init_lcdc,
287 #else
288         .prop      = PRMRY,             //primary display device
289         .io_init   = rk_fb_io_init,
290         .io_disable = rk_fb_io_disable,
291         .io_enable = rk_fb_io_enable,
292         .set_screen_info = set_lcd_info,
293 #endif
294 };
295 #endif
296
297 static struct resource resource_fb[] = {
298         [0] = {
299                 .name  = "fb0 buf",
300                 .start = 0,
301                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
302                 .flags = IORESOURCE_MEM,
303         },
304         [1] = {
305                 .name  = "ipp buf",  //for rotate
306                 .start = 0,
307                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
308                 .flags = IORESOURCE_MEM,
309         },
310         [2] = {
311                 .name  = "fb2 buf",
312                 .start = 0,
313                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
314                 .flags = IORESOURCE_MEM,
315         },
316 };
317
318 static struct platform_device device_fb = {
319         .name           = "rk-fb",
320         .id             = -1,
321         .num_resources  = ARRAY_SIZE(resource_fb),
322         .resource       = resource_fb,
323 };
324 #endif
325
326 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
327 static struct resource resource_lcdc0[] = {
328         [0] = {
329                 .name  = "lcdc0 reg",
330                 .start = RK3026_LCDC0_PHYS,
331                 .end   = RK3026_LCDC0_PHYS + RK3026_LCDC0_SIZE - 1,
332                 .flags = IORESOURCE_MEM,
333         },
334         
335         [1] = {
336                 .name  = "lcdc0 irq",
337                 .start = IRQ_LCDC,
338                 .end   = IRQ_LCDC,
339                 .flags = IORESOURCE_IRQ,
340         },
341 };
342
343 static struct platform_device device_lcdc0 = {
344         .name             = "rk30-lcdc",
345         .id               = 0,
346         .num_resources    = ARRAY_SIZE(resource_lcdc0),
347         .resource         = resource_lcdc0,
348         .dev            = {
349                 .platform_data = &lcdc0_screen_info,
350         },
351 };
352 #endif
353
354 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
355 static struct resource resource_lcdc1[] = {
356         [0] = {
357                 .name  = "lcdc1 reg",
358                 .start = RK3026_LCDC1_PHYS,
359                 .end   = RK3026_LCDC1_PHYS + RK3026_LCDC1_SIZE - 1,
360                 .flags = IORESOURCE_MEM,
361         },
362         [1] = {
363                 .name  = "lcdc1 irq",
364                 .start = IRQ_LCDC1,
365                 .end   = IRQ_LCDC1,
366                 .flags = IORESOURCE_IRQ,
367         },
368 };
369
370 static struct platform_device device_lcdc1 = {
371         .name             = "rk30-lcdc",
372         .id               = 1,
373         .num_resources    = ARRAY_SIZE(resource_lcdc1),
374         .resource         = resource_lcdc1,
375         .dev            = {
376                 .platform_data = &lcdc1_screen_info,
377         },
378 };
379 #endif
380
381 static int rk_platform_add_display_devices(void)
382 {
383         struct platform_device *fb = NULL;  //fb
384         struct platform_device *lcdc0 = NULL; //lcdc0
385         struct platform_device *lcdc1 = NULL; //lcdc1
386         struct platform_device *bl = NULL; //backlight
387 #ifdef CONFIG_FB_ROCKCHIP
388         fb = &device_fb;
389 #endif
390
391 #if defined(CONFIG_LCDC0_RK3066B) || defined(CONFIG_LCDC0_RK3188)
392         lcdc0 = &device_lcdc0,
393 #endif
394
395 #if defined(CONFIG_LCDC1_RK3066B) || defined(CONFIG_LCDC1_RK3188)
396         lcdc1 = &device_lcdc1,
397 #endif
398
399 #ifdef CONFIG_BACKLIGHT_RK29_BL
400         bl = &rk29_device_backlight,
401 #endif
402         __rk_platform_add_display_devices(fb,lcdc0,lcdc1,bl);
403
404         return 0;
405 }
406
407 ////////////////////////////////////////////////////////////////////////////////////////
408 //TP
409 ////////////////////////////////////////////////////////////////////////////////////////
410 #if (defined(CONFIG_TOUCHSCREEN_GSLX680_RK3168)||defined (CONFIG_TOUCHSCREEN_GSLX680_RK3028))
411 static int gslx680_init_platform_hw()
412         {
413         int ret;
414         if(tp_rst!=-1){
415         ret = port_output_init(tp_rst, 1, "tp_rst"); 
416                 if(ret<0)
417                         printk("%s: port output init faild\n", __func__);       
418         }
419     
420     port_output_on(tp_rst);
421     mdelay(10);
422     port_output_off(tp_rst);
423     mdelay(10);
424     port_output_on(tp_rst);
425     msleep(300);
426     return 0;
427         }
428         
429 static struct tp_platform_data gslx680_data = {
430
431   .init_platform_hw = gslx680_init_platform_hw,
432 };
433 struct i2c_board_info __initdata gslx680_info = {
434         .type = "gslX680",
435         .flags = 0,
436         .platform_data = &gslx680_data,
437 };
438 #endif
439
440
441 #if defined (CONFIG_TOUCHSCREEN_86V_GT811_IIC)
442 int gt811_init_platform_hw(int irq,int reset)
443 {
444     int ret;
445         if(tp_rst!=-1){
446         ret = port_output_init(tp_rst, 1, "tp_rst"); 
447                 if(ret<0)
448                         printk("%s: port output init faild\n", __func__);       
449         }
450
451         port_output_off(tp_rst);
452     msleep(500);
453     port_output_off(tp_rst);
454     msleep(500);
455     port_output_on(tp_rst);
456     mdelay(100);
457     return 0;
458 }
459
460
461 static struct tp_platform_data gt811_data = {
462   .model= 811,
463   .init_platform_hw= gt811_init_platform_hw,
464 };
465
466 struct i2c_board_info __initdata gt811_info = {
467         .type = "gt811_ts",
468         .flags = 0,
469         .platform_data = &gt811_data,
470 };
471 #endif
472 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
473 #define TOUCH_PWR_PIN    RK30_PIN0_PC5   // need to fly line by hardware engineer
474 static int goodix_init_platform_hw(void)
475 {
476         int ret;
477         
478         if (TOUCH_PWR_PIN != INVALID_GPIO) {
479                 ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin");
480                 if (ret != 0) {
481                         gpio_free(TOUCH_PWR_PIN);
482                         printk("goodix power error\n");
483                         return -EIO;
484                 }
485                 gpio_direction_output(TOUCH_PWR_PIN, 0);
486                 gpio_set_value(TOUCH_PWR_PIN, GPIO_LOW);
487                 msleep(100);
488         }
489
490         if(tp_rst!=-1){
491         ret = port_output_init(tp_rst, 1, "tp_rst"); 
492                 if(ret<0)
493                         printk("%s: port output init faild\n", __func__);       
494         }
495         port_output_on(tp_rst);
496         msleep(100);
497         return 0;
498 }
499
500 struct tp_platform_data goodix_data = {
501         .model = 8105,
502         .init_platform_hw = goodix_init_platform_hw,
503 };
504
505 struct i2c_board_info __initdata goodix_info = {
506   .type = "Goodix-TS",
507   .flags = 0,
508   .platform_data = &goodix_data,
509 };
510 #endif
511
512 ////////////////////////////////////////////////////////////////////////////////////////
513 //Gsensor
514 ////////////////////////////////////////////////////////////////////////////////////////
515 #if defined (CONFIG_GS_LSM303D)
516 static int lms303d_init_platform_hw(void)
517 {
518         return 0;
519 }
520 static struct sensor_platform_data lms303d_data = {
521         .type = SENSOR_TYPE_ACCEL,
522         .irq_enable = 1,
523         .poll_delay_ms = 30,
524     .init_platform_hw = lms303d_init_platform_hw,
525 };
526 struct i2c_board_info __initdata lms303d_info = {
527     .type                   = "gs_lsm303d",
528     .flags                  = 0,
529     .platform_data          =&lms303d_data, 
530 };
531 #endif
532
533 #if defined (CONFIG_GS_MMA8452)
534 static int mma8452_init_platform_hw(void)
535 {
536         return 0;
537 }
538
539 static struct sensor_platform_data mma8452_data = {
540         .type = SENSOR_TYPE_ACCEL,
541         .irq_enable = 1,
542         .poll_delay_ms = 30,
543     .init_platform_hw = mma8452_init_platform_hw,
544 };
545 struct i2c_board_info __initdata mma8452_info = {
546     .type                   = "gs_mma8452",
547     .flags                  = 0,
548     .platform_data          =&mma8452_data, 
549 };
550 #endif
551
552 /*MMA7660 gsensor*/
553 #if defined (CONFIG_GS_MMA7660)
554 static int mma7660_init_platform_hw(void)
555 {
556         //rk30_mux_api_set(GPIO1B2_SPI_RXD_UART1_SIN_NAME, GPIO1B_GPIO1B2);
557
558         return 0;
559 }
560
561 static struct sensor_platform_data mma7660_data = {
562         .type = SENSOR_TYPE_ACCEL,
563         .irq_enable = 1,
564         .poll_delay_ms = 30,
565     .init_platform_hw = mma7660_init_platform_hw,
566 };
567 struct i2c_board_info __initdata mma7660_info = {
568         .type                   = "gs_mma7660",
569         .flags                  = 0,
570         .platform_data          =&mma7660_data, 
571 };
572 #endif
573
574 #if defined (CONFIG_GS_MXC6225)
575 static int mxc6225_init_platform_hw(void)
576 {
577 //        rk30_mux_api_set(GPIO1B1_SPI_TXD_UART1_SOUT_NAME, GPIO1B_GPIO1B1);
578         return 0;
579 }
580
581 static struct sensor_platform_data mxc6225_data = {
582         .type = SENSOR_TYPE_ACCEL,
583         .irq_enable = 0,
584         .poll_delay_ms = 30,
585         .init_platform_hw = mxc6225_init_platform_hw,    
586 };
587 struct i2c_board_info __initdata mxc6225_info = {
588         .type                   = "gs_mxc6225",
589         .flags                  = 0,
590         .platform_data          =&mxc6225_data, 
591 };
592 #endif
593
594 #if defined (CONFIG_GS_DMT10)
595 static int dmt10_init_platform_hw(void)
596 {
597         return 0;
598 }
599
600 static struct sensor_platform_data dmt10_data = {
601         .type = SENSOR_TYPE_ACCEL,
602         .irq_enable = 0,
603         .poll_delay_ms = 30,
604         .init_platform_hw = dmt10_init_platform_hw,    
605 };
606 struct i2c_board_info __initdata dmt10_info = {
607         .type                   = "gs_dmard10",
608         .flags                  = 0,
609         .platform_data          =&dmt10_data, 
610 };
611 #endif
612
613
614 #if defined (CONFIG_GS_LIS3DH)
615 static int lis3dh_init_platform_hw(void)
616 {
617         return 0;
618 }
619 static struct sensor_platform_data lis3dh_data = {
620         .type = SENSOR_TYPE_ACCEL,
621         .irq_enable = 1,
622         .poll_delay_ms = 30,
623         .init_platform_hw = lis3dh_init_platform_hw,
624 };
625 struct i2c_board_info __initdata lis3dh_info = {
626         .type                   = "gs_lis3dh",
627         .flags                  = 0,
628         .platform_data          =&lis3dh_data, 
629 };
630 #endif
631
632 ////////////////////////////////////////////////////////////////////////////////////////
633 //battery
634 ////////////////////////////////////////////////////////////////////////////////////////
635 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
636 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
637
638 };
639  
640
641 static struct platform_device rk30_device_adc_battery = {
642         .name   = "rk30-battery",
643         .id     = -1,
644         .dev = {
645                 .platform_data = &rk30_adc_battery_platdata,
646         },
647 };
648 #endif
649
650 ////////////////////////////////////////////////////////////////////////////////////////
651 //codec
652 ////////////////////////////////////////////////////////////////////////////////////////
653 #ifdef CONFIG_SND_SOC_RK3026
654 struct rk3026_codec_pdata rk3026_codec_pdata_info={
655     .spk_ctl_gpio = RK2928_PIN3_PD4,
656     .hp_ctl_gpio = RK2928_PIN3_PD4,
657 };
658
659 static struct resource resources_acodec[] = {
660         {
661                 .start  = RK2928_ACODEC_PHYS,
662                 .end    = RK2928_ACODEC_PHYS + RK2928_ACODEC_SIZE - 1,
663                 .flags  = IORESOURCE_MEM,
664         },
665 };
666
667 static struct platform_device rk3026_codec = {
668         .name   = "rk3026-codec",
669         .id             = -1,
670         .resource = resources_acodec,
671         .dev = {
672                 .platform_data = &rk3026_codec_pdata_info,
673     }
674 };
675 #endif
676
677 #if defined (CONFIG_SND_RK29_SOC_RT5631)
678 static struct codec_platform_data rt5631_data = {
679 };
680 struct i2c_board_info __initdata rt5631_info = {
681         .type                   = "rt5631",
682         .flags                  = 0,
683         .platform_data          =&rt5631_data, 
684 };
685 #endif
686
687 #if defined (CONFIG_SND_RK29_SOC_ES8323)
688 static struct codec_platform_data es8323_data = {
689 };
690 struct i2c_board_info __initdata es8323_info = {
691         .type                   = "es8323",
692         .flags                  = 0,
693         .platform_data          =&es8323_data, 
694 };
695 #endif
696
697 #if defined(CONFIG_MFD_RK616)
698 #define RK616_SCL_RATE                  (100*1000)   //i2c scl rate
699 static int rk616_power_on_init(void)
700 {
701         int ret;
702                 
703         if(codec_power!=-1)
704         {
705                 ret = port_output_init(codec_power, 1, "codec_power"); 
706                 if(ret < 0)                       
707                         printk("%s: port output init faild\n", __func__);
708                 port_output_on(codec_power);
709         }
710         
711         if(codec_rst!=-1)
712         {
713                 ret = port_output_init(codec_rst, 1, "codec_rst"); 
714                 if(ret < 0)                       
715                         printk("%s: port output init faild\n", __func__);
716                 port_output_on(codec_rst);
717                 msleep(100);
718                 port_output_off(codec_rst);
719                 msleep(100);
720                 port_output_on(codec_rst);
721         }
722         return 0;
723         
724 }
725
726
727 static int rk616_power_deinit(void)
728 {
729         if(codec_power!=-1)
730         {
731                 port_output_off(codec_power);
732                 port_deinit(codec_power);
733         }
734         if(codec_rst!=-1)
735         {
736                 port_output_off(codec_rst);
737                 port_deinit(codec_rst);
738         }
739         return 0;
740 }
741
742 static struct rk616_platform_data rk616_pdata = {
743         .power_init = rk616_power_on_init,
744         .power_deinit = rk616_power_deinit,
745         .scl_rate   = RK616_SCL_RATE,
746         .lcd0_func = INPUT,             //port lcd0 as input
747         .lcd1_func = INPUT,             //port lcd1 as input
748         .lvds_ch_nr = 1,                //the number of used lvds channel  
749         //.hdmi_irq = RK30_PIN2_PD6,
750         //.spk_ctl_gpio = RK30_PIN2_PD7,
751         .hp_ctl_gpio = RK30_PIN2_PD7,
752 };
753
754 struct i2c_board_info __initdata rk616_info = {
755         .type          = "rk616",
756         .flags         = 0,
757         .platform_data = &rk616_pdata,
758 };
759 #endif
760
761
762 ////////////////////////////////////////////////////////////////////////////////////////
763 //spi
764 ////////////////////////////////////////////////////////////////////////////////////////
765 static struct spi_board_info board_spi_devices[] = {
766 };
767
768
769 ////////////////////////////////////////////////////////////////////////////////////////
770 //compass
771 ////////////////////////////////////////////////////////////////////////////////////////
772 #if defined (CONFIG_COMPASS_AK8975)
773 static struct sensor_platform_data akm8975_info =
774 {
775         .type = SENSOR_TYPE_COMPASS,
776         .irq_enable = 1,
777         .poll_delay_ms = 30,
778         .m_layout = 
779         {
780                 {
781                         {1, 0, 0},
782                         {0, 1, 0},
783                         {0, 0, 1},
784                 },
785
786                 {
787                         {1, 0, 0},
788                         {0, 1, 0},
789                         {0, 0, 1},
790                 },
791
792                 {
793                         {1, 0, 0},
794                         {0, 1, 0},
795                         {0, 0, 1},
796                 },
797
798                 {
799                         {1, 0, 0},
800                         {0, 1, 0},
801                         {0, 0, 1},
802                 },
803         }
804 };
805
806 #endif
807
808 #if defined (CONFIG_COMPASS_AK8963)
809 static struct sensor_platform_data akm8963_info =
810 {
811        .type = SENSOR_TYPE_COMPASS,
812        .irq_enable = 1,
813        .poll_delay_ms = 30,
814        .m_layout = 
815        {
816                {
817                        {0, 1, 0},
818                        {1, 0, 0},
819                        {0, 0, -1},
820                },
821
822                {
823                        {1, 0, 0},
824                        {0, 1, 0},
825                        {0, 0, 1},
826                },
827
828                {
829                        {0, -1, 0},
830                        {-1, 0, 0},
831                        {0, 0, -1},
832                },
833
834                {
835                        {1, 0, 0},
836                        {0, 1, 0},
837                        {0, 0, 1},
838                },
839        }
840 };
841
842 #endif
843
844
845 #if defined(CONFIG_GYRO_L3G4200D)
846
847 #include <linux/l3g4200d.h>
848 #define L3G4200D_INT_PIN  RK30_PIN0_PB4
849
850 static int l3g4200d_init_platform_hw(void)
851 {
852         return 0;
853 }
854
855 static struct sensor_platform_data l3g4200d_info = {
856         .type = SENSOR_TYPE_GYROSCOPE,
857         .irq_enable = 1,
858         .poll_delay_ms = 30,
859         .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
860         .init_platform_hw = l3g4200d_init_platform_hw,
861         .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
862         .y_min = 40,
863         .z_min = 20,
864 };
865
866 #endif
867
868 #ifdef CONFIG_LS_CM3217
869 static struct sensor_platform_data cm3217_info = {
870         .type = SENSOR_TYPE_LIGHT,
871         .irq_enable = 0,
872         .poll_delay_ms = 500,
873 };
874
875 #endif
876
877
878 /***********************************************************
879 *       sdmmc
880 ************************************************************/
881 #ifdef CONFIG_SDMMC_RK29
882 #include "board-rk3028a-86v-sdmmc-config.c"
883 #include "../plat-rk/rk-sdmmc-ops.c"
884 #include "../plat-rk/rk-sdmmc-wifi.c"
885 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
886
887 #ifdef CONFIG_SDMMC0_RK29
888 #define CONFIG_SDMMC0_USE_DMA
889 static int rk29_sdmmc0_cfg_gpio(void)
890 {
891         rk29_sdmmc_set_iomux(0, 0xFFFF);
892         #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
893         iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
894         #else
895         iomux_set(MMC0_DETN);
896         #endif  
897
898         #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
899         gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
900         gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
901         #endif
902         return 0;
903 }
904
905 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
906         .host_ocr_avail =
907             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
908              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
909              MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
910         .host_caps =
911             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
912         .io_init = rk29_sdmmc0_cfg_gpio,
913
914         .set_iomux = rk29_sdmmc_set_iomux,
915
916         .dma_name = "sd_mmc",
917 #ifdef CONFIG_SDMMC0_USE_DMA
918         .use_dma = 1,
919 #else
920         .use_dma = 0,
921 #endif
922
923 #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
924         .status = rk29sdk_wifi_mmc0_status,
925         .register_status_notify = rk29sdk_wifi_mmc0_status_register,
926 #endif
927
928 #if defined(RK29SDK_SD_CARD_PWR_EN) || (INVALID_GPIO != RK29SDK_SD_CARD_PWR_EN)
929         .power_en = RK29SDK_SD_CARD_PWR_EN,
930         .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL,
931 #else
932         .power_en = INVALID_GPIO,
933         .power_en_level = GPIO_LOW,
934 #endif    
935         .enable_sd_wakeup = 0,
936
937 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
938         .write_prt = SDMMC0_WRITE_PROTECT_PIN,
939         .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE;
940 #else
941         .write_prt = INVALID_GPIO,
942 #endif
943
944         .det_pin_info = {    
945                 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)  
946                 .io             = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO,
947                 .enable         = RK29SDK_SD_CARD_INSERT_LEVEL,
948                 #else
949                 .io             = INVALID_GPIO,
950                 .enable         = GPIO_LOW,
951                 #endif    
952         }, 
953
954 };
955 #endif // CONFIG_SDMMC0_RK29
956
957 #ifdef CONFIG_SDMMC1_RK29
958 #define CONFIG_SDMMC1_USE_DMA
959 static int rk29_sdmmc1_cfg_gpio(void)
960 {
961 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
962         gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
963         gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
964 #endif
965         return 0;
966 }
967
968 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
969         .host_ocr_avail =
970             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
971              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
972              MMC_VDD_33_34),
973
974 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
975         .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
976                       MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
977 #else
978         .host_caps =
979             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
980 #endif
981
982         .io_init = rk29_sdmmc1_cfg_gpio,
983
984         .set_iomux = rk29_sdmmc_set_iomux,
985
986         .dma_name = "sdio",
987 #ifdef CONFIG_SDMMC1_USE_DMA
988         .use_dma = 1,
989 #else
990         .use_dma = 0,
991 #endif
992
993 #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
994         .status = rk29sdk_wifi_status,
995         .register_status_notify = rk29sdk_wifi_status_register,
996 #endif
997
998 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
999         .write_prt = SDMMC1_WRITE_PROTECT_PIN,
1000         .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE;
1001 #else
1002         .write_prt = INVALID_GPIO,
1003 #endif
1004
1005     #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO)
1006         .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT,
1007     #endif
1008
1009         .det_pin_info = {    
1010         #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
1011                 #if defined(RK29SDK_SD_CARD_DETECT_N) || (INVALID_GPIO != RK29SDK_SD_CARD_DETECT_N)  
1012                 .io             = RK29SDK_SD_CARD_DETECT_N,
1013                 #else
1014                 .io             = INVALID_GPIO,
1015                 #endif   
1016
1017                 .enable         = RK29SDK_SD_CARD_INSERT_LEVEL,
1018         #else
1019                 .io             = INVALID_GPIO,
1020                 .enable         = GPIO_LOW,
1021         #endif
1022         },
1023         .enable_sd_wakeup = 0,
1024 };
1025 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
1026
1027 /***********************************************************
1028 *       rfkill
1029 ************************************************************/
1030 #ifdef CONFIG_RFKILL_RK
1031 // bluetooth rfkill device, its driver in net/rfkill/rfkill-rk.c
1032 static struct rfkill_rk_platform_data rfkill_rk_platdata = {
1033         .type               = RFKILL_TYPE_BLUETOOTH,
1034
1035         .poweron_gpio       = { // BT_REG_ON
1036                 .io             = INVALID_GPIO, //RK30_PIN3_PC7,
1037                 .enable         = GPIO_HIGH,
1038                 .iomux          = {
1039                         .name       = "bt_poweron",
1040                         //.fgpio      = GPIO3_C7,
1041                 },
1042         },
1043
1044         .reset_gpio         = { // BT_RST
1045                 .io             = RK30_PIN1_PB3, // set io to INVALID_GPIO for disable it
1046                 .enable         = GPIO_LOW,
1047                 .iomux          = {
1048                         .name       = "bt_reset",
1049                         .fgpio      = GPIO1_B3,
1050                 },
1051         }, 
1052
1053         .wake_gpio          = { // BT_WAKE, use to control bt's sleep and wakeup
1054                 .io             = RK30_PIN1_PB2, // set io to INVALID_GPIO for disable it
1055                 .enable         = GPIO_HIGH,
1056                 .iomux          = {
1057                         .name       = "bt_wake",
1058                         .fgpio      = GPIO1_B2,
1059                 },
1060         },
1061
1062         .wake_host_irq      = { // BT_HOST_WAKE, for bt wakeup host when it is in deep sleep
1063                 .gpio           = {
1064                         .io         = RK30_PIN0_PA4, // set io to INVALID_GPIO for disable it
1065                         .enable     = GPIO_LOW,      // set GPIO_LOW for falling, set 0 for rising
1066                         .iomux      = {
1067                                 .name   = "bt_wake_host",
1068                                 //.fgpio  = GPIO0_A4,  
1069                         },
1070                 },
1071         },
1072
1073         .rts_gpio           = { // UART_RTS, enable or disable BT's data coming
1074                 .io             = RK30_PIN1_PA3, // set io to INVALID_GPIO for disable it
1075                 .enable         = GPIO_LOW,
1076                 .iomux          = {
1077                         .name       = "bt_rts",
1078                         .fgpio      = GPIO1_A3,
1079                         .fmux       = UART0_RTSN,
1080                 },
1081         }
1082 };
1083
1084 static struct platform_device device_rfkill_rk = {
1085     .name   = "rfkill_rk",
1086     .id     = -1,
1087     .dev    = {
1088         .platform_data = &rfkill_rk_platdata,
1089     },
1090 };
1091 #endif
1092
1093 /***********************************************************
1094 *       ion
1095 ************************************************************/
1096 #ifdef CONFIG_ION
1097 static struct ion_platform_data rk30_ion_pdata = {
1098         .nr = 1,
1099         .heaps = {
1100                 {
1101                         .type = ION_HEAP_TYPE_CARVEOUT,
1102                         .id = ION_NOR_HEAP_ID,
1103                         .name = "norheap",
1104                         .size = ION_RESERVE_SIZE,
1105                 }
1106         },
1107 };
1108
1109 static struct platform_device device_ion = {
1110         .name = "ion-rockchip",
1111         .id = 0,
1112         .dev = {
1113                 .platform_data = &rk30_ion_pdata,
1114         },
1115 };
1116 #endif
1117
1118 /***********************************************************
1119 *       pwm regulator
1120 ************************************************************/
1121 #ifdef CONFIG_RK30_PWM_REGULATOR
1122 static int pwm_voltage_map[] = {
1123         800000,  825000,  850000,  875000,  900000,  925000 ,
1124         950000,  975000,  1000000, 1025000, 1050000, 1075000, 
1125         1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 
1126         1250000, 1275000, 1300000, 1325000, 1350000, 1375000
1127 };
1128
1129 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
1130         {
1131                 .supply = "vdd_core",
1132         }
1133 };
1134
1135 struct regulator_init_data pwm_regulator_init_dcdc[1] = {
1136         {
1137                 .constraints = {
1138                         .name = "PWM_DCDC1",
1139                         .min_uV = 600000,
1140                         .max_uV = 1800000,      //0.6-1.8V
1141                         .apply_uV = true,
1142                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
1143                 },
1144                 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
1145                 .consumer_supplies = pwm_dcdc1_consumers,
1146         },
1147 };
1148
1149 static struct pwm_platform_data pwm_regulator_info[1] = {
1150         {
1151                 .pwm_id = REG_PWM,
1152                 .pwm_voltage = 1200000,
1153                 .suspend_voltage = 1050000,
1154                 .min_uV = 950000,
1155                 .max_uV = 1400000,
1156                 .coefficient = 504,     //50.4%
1157                 .pwm_voltage_map = pwm_voltage_map,
1158                 .init_data      = &pwm_regulator_init_dcdc[0],
1159         },
1160 };
1161 struct platform_device pwm_regulator_device[1] = {
1162         {
1163                 .name = "pwm-voltage-regulator",
1164                 .id = 0,
1165                 .dev            = {
1166                         .platform_data = &pwm_regulator_info[0],
1167                 }
1168         },
1169 };
1170
1171 static void pwm_regulator_init(void)
1172 {
1173         pwm_regulator_info[0].pwm_gpio = iomux_mode_to_gpio(pwm_mode[REG_PWM]);
1174         pwm_regulator_info[0].pwm_iomux_pwm = pwm_mode[REG_PWM];
1175         pwm_regulator_info[0].pwm_iomux_gpio = iomux_switch_gpio_mode(pwm_mode[REG_PWM]);
1176 }
1177 #endif
1178
1179 int __sramdata pwm_iomux, pwm_do, pwm_dir, pwm_en;
1180 #define grf_readl(offset)       readl_relaxed(RK30_GRF_BASE + offset)
1181 #define grf_writel(v, offset)   do { writel_relaxed(v, RK30_GRF_BASE + offset); dsb(); } while (0)
1182
1183 #define GPIO0_D2_OFFSET         10
1184 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
1185 {
1186 #ifdef CONFIG_RK30_PWM_REGULATOR
1187         #if 0
1188         /* pwm0: GPIO0_D2, pwm1: GPIO0_D3, pwm2: GPIO0_D4 */
1189         int off = GPIO0_D2_OFFSET + REG_PWM;
1190
1191         sram_udelay(10000);
1192         pwm_iomux = grf_readl(GRF_GPIO0D_IOMUX);
1193         pwm_dir = grf_readl(GRF_GPIO0H_DIR);
1194         pwm_do = grf_readl(GRF_GPIO0H_DO);
1195         pwm__en = grf_readl(GRF_GPIO0H_EN);
1196
1197         grf_writel((1<<(2 * off), GRF_GPIO0D_IOMUX);
1198         grf_writel((1<<(16 + off))|(1<<off), GRF_GPIO0H_DIR);
1199         grf_writel((1<<(16 + off))|(1<<off), GRF_GPIO0H_DO);
1200         #endif
1201 #endif
1202 }
1203
1204 void __sramfunc rk30_pwm_logic_resume_voltage(void)
1205 {
1206 #ifdef CONFIG_RK30_PWM_REGULATOR
1207         #if 0
1208         /* pwm0: GPIO0_D2, pwm1: GPIO0_D3, pwm2: GPIO0_D4 */
1209         int off = GPIO0_D2_OFFSET + REG_PWM;
1210
1211         grf_writel((1<<(2 * off))|pwm_iomux, GRF_GPIO0D_IOMUX);
1212         grf_writel(((1<<(16 + off))|pwm_dir), GRF_GPIO0L_DIR);
1213         grf_writel(((1<<(16 + off))|pwm_do), GRF_GPIO0L_DO);
1214         grf_writel(((1<<(16 + off))|pwm_en), GRF_GPIO0L_EN);
1215         sram_udelay(10000);
1216         #endif
1217 #endif
1218 }
1219 extern void pwm_suspend_voltage(void);
1220 extern void pwm_resume_voltage(void);
1221
1222 void  rk30_pwm_suspend_voltage_set(void)
1223 {
1224 #ifdef CONFIG_RK30_PWM_REGULATOR
1225         pwm_suspend_voltage();
1226 #endif
1227 }
1228
1229 void  rk30_pwm_resume_voltage_set(void)
1230 {
1231 #ifdef CONFIG_RK30_PWM_REGULATOR
1232         pwm_resume_voltage();
1233 #endif
1234 }
1235
1236 /***********************************************************
1237 *       pmic
1238 ************************************************************/
1239 int __sramdata g_pmic_type =  0;
1240
1241 #ifdef CONFIG_MFD_TPS65910
1242 #define TPS65910_HOST_IRQ       PMU_INT_PIN
1243 #define PMU_POWER_SLEEP         PMU_SLEEP_PIN
1244 static struct pmu_info  tps65910_dcdc_info[] = {
1245         {
1246                 .name          = "vdd_core",   //logic
1247                 .min_uv          = 1100000,
1248                 .max_uv         = 1100000,
1249         },
1250         {
1251                 .name          = "vdd_cpu",    //arm
1252                 .min_uv          = 1100000,
1253                 .max_uv         = 1100000,
1254         },
1255         {
1256                 .name          = "vio",   //vcc_io
1257                 .min_uv          = 3300000,
1258                 .max_uv         = 3300000,
1259         },
1260         
1261 };
1262 static  struct pmu_info  tps65910_ldo_info[] = {
1263         /*{
1264                 .name          = "vpll",   //vdd10
1265                 .min_uv          = 1000000,
1266                 .max_uv         = 1000000,
1267         },*/
1268         {
1269                 .name          = "vdig1",    //vcc18_cif
1270                 .min_uv          = 2800000,//1800000,
1271                 .max_uv         = 2800000,//1800000,
1272         },
1273         {
1274                 .name          = "vdig2",   //vdd11
1275                 .min_uv          = 1100000,
1276                 .max_uv         = 1100000,
1277         },
1278         {
1279                 .name          = "vaux1",   //vcc28_cif
1280                 .min_uv          = 2800000,
1281                 .max_uv         = 2800000,
1282         },
1283         {
1284                 .name          = "vaux2",   //vcc33
1285                 .min_uv          = 3300000,
1286                 .max_uv         = 3300000,
1287         },
1288         {
1289                 .name          = "vaux33",   //vcc_tp
1290                 .min_uv          = 3300000,
1291                 .max_uv         = 3300000,
1292         },
1293         {
1294                 .name          = "vmmc",   //vcca30
1295                 .min_uv          = 3000000,
1296                 .max_uv         = 3000000,
1297         },
1298         {
1299                 .name          = "vdac",   //
1300                 .min_uv          = 1800000,
1301                 .max_uv         = 1800000,
1302         },
1303 };
1304 #include "../mach-rk30/board-pmu-tps65910.c"
1305 #endif
1306
1307 void __sramfunc board_pmu_suspend(void)
1308 {
1309         #if defined (CONFIG_MFD_TPS65910)
1310         if(pmic_is_tps65910())
1311                 board_pmu_tps65910_suspend();
1312         #endif
1313 }
1314
1315 void __sramfunc board_pmu_resume(void)
1316 {
1317         #if defined (CONFIG_MFD_TPS65910)
1318         if(pmic_is_tps65910())
1319                 board_pmu_tps65910_resume();
1320         #endif
1321 }
1322
1323 #if defined(CONFIG_GPS_RK)
1324 #define GPS_OSCEN_PIN   RK2928_PIN1_PB0
1325 #define GPS_RXEN_PIN    RK2928_PIN1_PB0
1326
1327 static int rk_gps_io_init(void)
1328 {
1329         printk("%s \n", __FUNCTION__);
1330         
1331         gpio_request(GPS_OSCEN_PIN, NULL);
1332         gpio_direction_output(GPS_OSCEN_PIN, GPIO_LOW); 
1333         
1334         iomux_set(GPS_CLK);//GPS_CLK
1335         iomux_set(GPS_MAG);//GPS_MAG
1336         iomux_set(GPS_SIGN);//GPS_SIGN
1337 #if 0
1338         gpio_request(RK30_PIN1_PA6, NULL);
1339         gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
1340
1341         gpio_request(RK30_PIN1_PA5, NULL);
1342         gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW); 
1343
1344         gpio_request(RK30_PIN1_PA7, NULL);
1345         gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);         
1346 #endif  
1347         return 0;
1348 }
1349 static int rk_gps_power_up(void)
1350 {
1351         printk("%s \n", __FUNCTION__);
1352
1353         return 0;
1354 }
1355
1356 static int rk_gps_power_down(void)
1357 {
1358         printk("%s \n", __FUNCTION__);
1359
1360         return 0;
1361 }
1362
1363 static int rk_gps_reset_set(int level)
1364 {
1365         return 0;
1366 }
1367 static int rk_enable_hclk_gps(void)
1368 {
1369         struct clk *gps_aclk = NULL;
1370         gps_aclk = clk_get(NULL, "aclk_gps");
1371         if(gps_aclk) {
1372                 clk_enable(gps_aclk);
1373                 clk_put(gps_aclk);
1374                 printk("%s \n", __FUNCTION__);
1375         }
1376         else
1377                 printk("get gps aclk fail\n");
1378         return 0;
1379 }
1380 static int rk_disable_hclk_gps(void)
1381 {
1382         struct clk *gps_aclk = NULL;
1383         gps_aclk = clk_get(NULL, "aclk_gps");
1384         if(gps_aclk) {
1385                 //TO wait long enough until GPS ISR is finished.
1386                 msleep(5);
1387                 clk_disable(gps_aclk);
1388                 clk_put(gps_aclk);
1389                 printk("%s \n", __FUNCTION__);
1390         }       
1391         else
1392                 printk("get gps aclk fail\n");
1393         return 0;
1394 }
1395 static struct rk_gps_data rk_gps_info = {
1396         .io_init = rk_gps_io_init,
1397         .power_up = rk_gps_power_up,
1398         .power_down = rk_gps_power_down,
1399         .reset = rk_gps_reset_set,
1400         .enable_hclk_gps = rk_enable_hclk_gps,
1401         .disable_hclk_gps = rk_disable_hclk_gps,
1402         .GpsSign = RK2928_PIN1_PA5,
1403         .GpsMag = RK2928_PIN1_PA4,        //GPIO index
1404         .GpsClk = RK2928_PIN1_PA2,        //GPIO index
1405         .GpsVCCEn = GPS_OSCEN_PIN,     //GPIO index
1406 #if 0   
1407         .GpsSpi_CSO = RK30_PIN1_PA4,    //GPIO index
1408         .GpsSpiClk = RK30_PIN1_PA5,     //GPIO index
1409         .GpsSpiMOSI = RK30_PIN1_PA7,      //GPIO index
1410 #endif  
1411         .GpsIrq = IRQ_GPS,
1412         .GpsSpiEn = 0,
1413         .GpsAdcCh = 2,
1414         .u32GpsPhyAddr = RK2928_GPS_PHYS,
1415         .u32GpsPhySize = RK2928_GPS_SIZE,
1416 };
1417
1418 static struct platform_device rk_device_gps = {
1419         .name = "gps_hv5820b",
1420         .id = -1,
1421         .dev            = {
1422         .platform_data = &rk_gps_info,
1423                 }
1424         };
1425 #endif
1426
1427
1428 /***********************************************************
1429 *       i2c
1430 ************************************************************/
1431 #ifdef CONFIG_I2C0_RK30
1432 static struct i2c_board_info __initdata i2c0_info[] = {
1433 #if defined (CONFIG_MFD_TPS65910)
1434         {
1435                 .type           = "tps65910",
1436                 .addr           = TPS65910_I2C_ID0,
1437                 .flags          = 0,
1438                 .irq            = TPS65910_HOST_IRQ,
1439                 .platform_data = &tps65910_data,
1440         },
1441 #endif
1442
1443 };
1444 #endif
1445
1446 #ifdef CONFIG_I2C1_RK30
1447 static struct i2c_board_info __initdata i2c1_info[] = {
1448 #if defined (CONFIG_COMPASS_AK8975)
1449         {
1450                 .type          = "ak8975",
1451                 .addr          = 0x0d,
1452                 .flags         = 0,
1453                 .irq           = RK30_PIN3_PD7, 
1454                 .platform_data = &akm8975_info,
1455                 .irq           = RK30_PIN3_PD7, 
1456                 .platform_data = &akm8975_info,
1457         },
1458 #endif
1459 #if defined (CONFIG_COMPASS_AK8963)
1460         {
1461                 .type          = "ak8963",
1462                 .addr          = 0x0d,
1463                 .flags         = 0,
1464                 .irq           = RK30_PIN3_PD7, 
1465                 .platform_data = &akm8963_info,
1466         },
1467 #endif
1468 #if defined (CONFIG_GYRO_L3G4200D)
1469         {
1470                 .type          = "l3g4200d_gryo",
1471                 .addr          = 0x69,
1472                 .flags         = 0,
1473                 .irq           = L3G4200D_INT_PIN,
1474                 .platform_data = &l3g4200d_info,
1475         },
1476 #endif
1477
1478 };
1479 #endif
1480
1481 #ifdef CONFIG_I2C2_RK30
1482 static struct i2c_board_info __initdata i2c2_info[] = {
1483 };
1484 #endif
1485
1486 #ifdef CONFIG_I2C3_RK30
1487 static struct i2c_board_info __initdata i2c3_info[] = {
1488 };
1489 #endif
1490
1491 #ifdef CONFIG_I2C_GPIO_RK30
1492 #define I2C_SDA_PIN     INVALID_GPIO// RK30_PIN2_PD6   //set sda_pin here
1493 #define I2C_SCL_PIN     INVALID_GPIO//RK30_PIN2_PD7   //set scl_pin here
1494 static int rk30_i2c_io_init(void)
1495 {
1496         return 0;
1497 }
1498
1499 struct i2c_gpio_platform_data default_i2c_gpio_data = {
1500        .sda_pin = I2C_SDA_PIN,
1501        .scl_pin = I2C_SCL_PIN,
1502        .udelay = 5, // clk = 500/udelay = 100Khz
1503        .timeout = 100,//msecs_to_jiffies(100),
1504        .bus_num    = 5,
1505        .io_init = rk30_i2c_io_init,
1506 };
1507
1508 static struct i2c_board_info __initdata i2c_gpio_info[] = {
1509
1510 };
1511 #endif
1512
1513 static void __init rk30_i2c_register_board_info(void)
1514 {
1515 #ifdef CONFIG_I2C0_RK30
1516         i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
1517 #endif
1518 #ifdef CONFIG_I2C1_RK30
1519         i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
1520 #endif
1521 #ifdef CONFIG_I2C2_RK30
1522         i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
1523 #endif
1524 #ifdef CONFIG_I2C3_RK30
1525         i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
1526 #endif
1527 #ifdef CONFIG_I2C_GPIO_RK30
1528         i2c_register_board_info(4, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
1529 #endif
1530 }
1531
1532 /***********************************************************
1533 *       board init
1534 ************************************************************/
1535 static struct platform_device *devices[] __initdata = {
1536 #ifdef CONFIG_ION
1537         &device_ion,
1538 #endif
1539 #ifdef CONFIG_WIFI_CONTROL_FUNC
1540         &rk29sdk_wifi_device,
1541 #endif
1542 #ifdef CONFIG_RFKILL_RK
1543         &device_rfkill_rk,
1544 #endif
1545 #ifdef CONFIG_BATTERY_RK30_ADC_FAC
1546         &rk30_device_adc_battery,
1547 #endif
1548 #ifdef CONFIG_SND_SOC_RK3026
1549         &rk3026_codec,
1550 #endif
1551 #ifdef CONFIG_GPS_RK
1552         &rk_device_gps,
1553 #endif
1554 };
1555
1556 static void rk30_pm_power_off(void)
1557 {
1558 #if defined(CONFIG_MFD_TPS65910)
1559         tps65910_device_shutdown();//tps65910 shutdown
1560 #endif
1561         port_output_off(pwr_on);
1562         while(1);
1563 }
1564 static int __init tp_board_init(void)
1565 {
1566         int i;
1567         struct port_config irq_port;
1568         struct port_config rst_port;
1569         int ret = check_tp_param();
1570
1571         if(ret < 0)
1572             return ret;
1573
1574    irq_port = get_port_config(tp_irq);
1575          rst_port = get_port_config(tp_rst);
1576 #if (defined (CONFIG_TOUCHSCREEN_GSLX680_RK3168)||defined (CONFIG_TOUCHSCREEN_GSLX680_RK3028))
1577         if(tp_type == TP_TYPE_GSLX680){          
1578                 gslx680_data.irq_pin = irq_port.gpio;
1579                 gslx680_info.addr = tp_addr; 
1580                 gslx680_data.reset_pin= rst_port.gpio;
1581                 gslx680_data.x_max=tp_xmax;
1582                 gslx680_data.y_max=tp_ymax;
1583                 gslx680_data.firmVer=tp_firmVer;
1584                 i2c_register_board_info(tp_i2c, &gslx680_info, 1);
1585         }
1586 #endif   
1587
1588 #if defined (CONFIG_TOUCHSCREEN_86V_GT811_IIC)
1589         if(tp_type == TP_TYPE_GT811_86V){
1590                 gt811_data.irq_pin = irq_port.gpio;
1591                 gt811_info.addr = tp_addr; 
1592                 gt811_data.reset_pin= rst_port.gpio;
1593                 gt811_data.x_max=tp_xmax;
1594                 gt811_data.y_max=tp_ymax;
1595                 i2c_register_board_info(tp_i2c, &gt811_info, 1);
1596         }
1597 #endif
1598
1599 #if defined(CONFIG_TOUCHSCREEN_GT8XX)
1600         if(tp_type == TP_TYPE_GT8XX){           
1601                 goodix_data.irq_pin = irq_port.gpio;
1602                 goodix_info.addr = tp_addr; 
1603                 goodix_data.reset_pin= rst_port.gpio;
1604                 goodix_data.x_max=tp_xmax;
1605                 goodix_data.y_max=tp_ymax;
1606                 i2c_register_board_info(tp_i2c, &goodix_info, 1);
1607         }
1608 #endif
1609     return 0;
1610 }
1611
1612
1613 static int __init codec_board_init(void)
1614 {
1615         struct port_config spk_port;
1616         struct port_config hp_port;
1617         struct port_config hdmi_irq_port;
1618         int ret = check_codec_param();
1619
1620         if(ret < 0)
1621             return ret;
1622
1623         spk_port = get_port_config(spk_ctl);
1624         hp_port = get_port_config(hp_det);
1625
1626 #if defined (CONFIG_SND_RK29_SOC_RT5631)
1627         if(codec_type == CODEC_TYPE_RT5631){
1628                 rt5631_data.spk_pin = spk_port.gpio;
1629                 rt5631_info.addr = codec_addr; 
1630                 rt5631_data.hp_pin= hp_port.gpio;
1631                 i2c_register_board_info(codec_i2c, &rt5631_info, 1);
1632         }
1633 #endif  
1634
1635 #if defined (CONFIG_SND_RK29_SOC_ES8323)
1636         if(codec_type == CODEC_TYPE_ES8323){
1637                 es8323_data.spk_pin = spk_port.gpio;
1638                 es8323_info.addr = codec_addr; 
1639                 es8323_data.hp_pin= hp_port.gpio;
1640                 i2c_register_board_info(codec_i2c, &es8323_info, 1);
1641         }
1642 #endif  
1643
1644 #if defined (CONFIG_MFD_RK616)
1645 if(codec_type == CODEC_TYPE_RK616){
1646                 rk616_pdata.spk_ctl_gpio = spk_port.gpio;
1647                 rk616_info.addr = codec_addr; 
1648                 rk616_pdata.hdmi_irq= get_port_config(codec_hdmi_irq).gpio;
1649                 i2c_register_board_info(codec_i2c, &rk616_info, 1);
1650         }
1651 #endif 
1652         return 0;
1653 }
1654
1655 static int __init chg_board_init(void)
1656 {   
1657         int i;
1658         int ret = check_chg_param();        
1659         if(ret < 0)                
1660                 return ret;  
1661 #ifdef CONFIG_BATTERY_RK30_ADC_FAC      
1662         //rk30_adc_battery_platdata.adc_channel = chg_adc;        
1663         if(dc_det != -1){                
1664                 rk30_adc_battery_platdata.dc_det_pin = get_port_config(dc_det).gpio;
1665                 printk("rk30_adc_battery_platdata.dc_det_pin %d %d",rk30_adc_battery_platdata.dc_det_pin,RK30_PIN0_PB2);
1666                 rk30_adc_battery_platdata.dc_det_level = !get_port_config(dc_det).io.active_low;
1667                 } 
1668         else{
1669                         rk30_adc_battery_platdata.dc_det_pin=INVALID_GPIO;
1670                 }
1671         if(bat_low != -1){                
1672                 rk30_adc_battery_platdata.batt_low_pin = get_port_config(bat_low).gpio;
1673                 rk30_adc_battery_platdata.batt_low_level = !get_port_config(bat_low).io.active_low;
1674                 }
1675         else{
1676                         rk30_adc_battery_platdata.batt_low_pin=INVALID_GPIO;
1677                 }
1678         if(chg_ok != -1){                
1679                 rk30_adc_battery_platdata.charge_ok_pin = get_port_config(chg_ok).gpio;
1680                 rk30_adc_battery_platdata.charge_ok_level = !get_port_config(chg_ok).io.active_low;
1681                 }
1682         else{
1683                 rk30_adc_battery_platdata.charge_ok_pin=INVALID_GPIO;
1684                 }       
1685         if(chg_set != -1){                
1686                 rk30_adc_battery_platdata.charge_set_pin = get_port_config(chg_set).gpio; 
1687                 rk30_adc_battery_platdata.charge_set_level = !get_port_config(chg_set).io.active_low;
1688                 } 
1689         else{
1690                 rk30_adc_battery_platdata.charge_set_pin=INVALID_GPIO;
1691                 }
1692         if(usb_det!= -1){
1693                         rk30_adc_battery_platdata.usb_det_pin = get_port_config(chg_set).gpio; 
1694                         rk30_adc_battery_platdata.usb_det_level = !get_port_config(chg_set).io.active_low;
1695                 }
1696         else{
1697                 rk30_adc_battery_platdata.usb_det_pin=INVALID_GPIO;                     
1698                 }
1699
1700         if(ref_vol!= -1){
1701                 rk30_adc_battery_platdata.reference_voltage=ref_vol;
1702                 }
1703         
1704         if(up_res!= -1){
1705                 rk30_adc_battery_platdata.pull_up_res=up_res;
1706                 }
1707         if(down_res!= -1){
1708                 rk30_adc_battery_platdata.pull_down_res=down_res;
1709                 }
1710         if(root_chg!= -1){
1711                 rk30_adc_battery_platdata.is_reboot_charging=root_chg;
1712                 }
1713         if(save_cap!= -1){
1714                 rk30_adc_battery_platdata.save_capacity=save_cap;
1715                 }
1716         if(low_vol!= -1){
1717                 rk30_adc_battery_platdata.low_voltage_protection=low_vol;
1718                 }
1719
1720         for(i=0;i<11;i++)
1721         {
1722                 rk30_adc_battery_platdata.chargeArray[i]=bat_charge[i];
1723                 rk30_adc_battery_platdata.dischargeArray[i]=bat_discharge[i];
1724         }
1725 #endif          
1726         return 0;
1727 }
1728
1729 static int __init gs_board_init(void)
1730 {        
1731         int i;        
1732         struct port_config port;        
1733         int ret = check_gs_param();        
1734         if(ret < 0)                
1735                 return ret;        
1736          port = get_port_config(gs_irq);       
1737 //mma7660
1738 #if defined (CONFIG_GS_MMA7660)        
1739         if(gs_type == GS_TYPE_MMA7660){
1740                 
1741                 mma7660_info.irq = port.gpio;                
1742                 mma7660_info.addr = gs_addr;               
1743                 for(i = 0; i < 9; i++)                        
1744                         mma7660_data.orientation[i] = gs_orig[i];               
1745                 i2c_register_board_info(gs_i2c, &mma7660_info, 1);        
1746         }
1747 #endif
1748
1749 #if defined (CONFIG_GS_LIS3DH)
1750         if(gs_type == GS_TYPE_LIS3DH){                
1751                 lis3dh_info.irq = port.gpio;                
1752                 lis3dh_info.addr = gs_addr;                
1753                 for(i = 0; i < 9; i++)                        
1754                         lis3dh_data.orientation[i] = gs_orig[i];                
1755                 i2c_register_board_info(gs_i2c, &lis3dh_info, 1); 
1756         }
1757 #endif
1758
1759 #if defined (CONFIG_GS_MXC6225)
1760         if(gs_type == GS_TYPE_MXC6225){ 
1761                 mxc6225_info.irq = port.gpio;                
1762                 mxc6225_info.addr = gs_addr;                
1763                 for(i = 0; i < 9; i++)                        
1764                         mxc6225_data.orientation[i] = gs_orig[i];               
1765                 i2c_register_board_info(gs_i2c, &mxc6225_info, 1); 
1766         }
1767 #endif
1768
1769 #if defined (CONFIG_GS_DMT10)
1770         if(gs_type == GS_TYPE_DMARAD10){ 
1771                 dmt10_info.irq = port.gpio;                
1772                 dmt10_info.addr = gs_addr;                
1773                 for(i = 0; i < 9; i++)                        
1774                         dmt10_data.orientation[i] = gs_orig[i];         
1775                 i2c_register_board_info(gs_i2c, &dmt10_info, 1); 
1776         }
1777 #endif
1778
1779 #if defined (CONFIG_GS_MMA8452)
1780         if(gs_type == GS_TYPE_MMA8452){ 
1781                 mma8452_info.irq = port.gpio;                
1782                 mma8452_info.addr = gs_addr;                
1783                 for(i = 0; i < 9; i++)                        
1784                         mma8452_data.orientation[i] = gs_orig[i];               
1785                 i2c_register_board_info(gs_i2c, &mma8452_info, 1); 
1786         }
1787 #endif
1788
1789 #if defined (CONFIG_GS_LSM303D)
1790         if(gs_type == GS_TYPE_LSM303D){ 
1791                 lms303d_info.irq = port.gpio;                
1792                 lms303d_info.addr = gs_addr;                
1793                 for(i = 0; i < 9; i++)                        
1794                         lms303d_data.orientation[i] = gs_orig[i];               
1795                 i2c_register_board_info(gs_i2c, &lms303d_info, 1); 
1796         }
1797 #endif
1798         return 0;
1799 }
1800
1801 static int __init bl_board_init(void){       
1802         int ret = check_bl_param();        
1803         if(ret < 0)                
1804                 return ret; 
1805
1806         switch(bl_pwmid)
1807     {
1808         case 0:
1809                         bl_pwm_mode = PWM0;
1810                         break;
1811                 case 1:
1812                         bl_pwm_mode = PWM1;
1813                         break;
1814                 case 2:
1815                         bl_pwm_mode = PWM2;
1816                         break;
1817     }
1818         
1819         rk29_bl_info.pwm_id = bl_pwmid;
1820         rk29_bl_info.brightness_mode=bl_mode;
1821         rk29_bl_info.pre_div=bl_div;
1822         rk29_bl_info.bl_ref = bl_ref;
1823         rk29_bl_info.min_brightness=bl_min;
1824         rk29_bl_info.max_brightness=bl_max;
1825
1826
1827         return 0;
1828 }
1829
1830 static int __init lcd_board_init(void)
1831 {        
1832         return check_lcd_param();
1833 }
1834
1835 static int __init key_board_init(void){        
1836         int i;        
1837         struct port_config port;        
1838         for(i = 0; i < key_val_size; i++){ 
1839                 if(key_val[i] & (1<<31)){                        
1840                         key_button[i].adc_value = key_val[i] & 0xffff;                        
1841                         key_button[i].gpio = INVALID_GPIO;                
1842                 }else{
1843                         port = get_port_config(key_val[i]);
1844                         key_button[i].gpio = port.gpio;                        
1845                         key_button[i].active_low = port.io.active_low;                
1846                 }        
1847         }        
1848         rk29_keys_pdata.nbuttons = key_val_size;        
1849         rk29_keys_pdata.chn = key_adc;        
1850         return 0;
1851 }
1852
1853 static int __init wifi_board_init(void)
1854 {        
1855         return check_wifi_param();
1856 }
1857
1858
1859 static int __init rk_config_init(void)
1860 {
1861         int ret = 0;
1862         ret = lcd_board_init();       
1863         if(ret < 0)                
1864                 INIT_ERR("lcd");
1865
1866         ret = bl_board_init();       
1867         if(ret < 0)                
1868                 INIT_ERR("backlight");
1869         
1870         ret = tp_board_init();
1871         if(ret < 0)
1872                 INIT_ERR("tp");  
1873
1874         ret = gs_board_init();       
1875         if(ret < 0)                
1876                 INIT_ERR("gsensor");
1877         
1878         ret = codec_board_init();
1879         if(ret < 0)
1880                 INIT_ERR("codec"); 
1881
1882         ret = key_board_init();        
1883         if(ret < 0)
1884                 INIT_ERR("key"); 
1885
1886         ret = chg_board_init();
1887         if(ret < 0)
1888                 INIT_ERR("charge"); 
1889
1890         ret = wifi_board_init();
1891         if(ret < 0)
1892                 INIT_ERR("wifi"); 
1893         
1894         return 0;       
1895 }
1896
1897 static void __init machine_rk30_board_init(void)
1898 {
1899 #ifdef CONFIG_RK30_PWM_REGULATOR
1900         pwm_regulator_init();
1901 #endif
1902         avs_init();
1903         pm_power_off = rk30_pm_power_off;
1904         rk_power_on();
1905         rk_config_init();
1906         rk30_i2c_register_board_info();
1907         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
1908         platform_add_devices(devices, ARRAY_SIZE(devices));
1909         rk_platform_add_display_devices();      
1910 #if defined(CONFIG_WIFI_CONTROL_FUNC)
1911         rk29sdk_wifi_bt_gpio_control_init();
1912 #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC)
1913     rk29sdk_wifi_combo_module_gpio_init();
1914 #endif
1915 }
1916
1917 static void __init rk30_reserve(void)
1918 {
1919         //fb reserve
1920 #ifdef CONFIG_FB_ROCKCHIP
1921         resource_fb[0].start = board_mem_reserve_add("fb0 buf", get_fb_size());
1922         resource_fb[0].end = resource_fb[0].start + get_fb_size()- 1;
1923         #if 0
1924         resource_fb[1].start = board_mem_reserve_add("ipp buf", RK30_FB0_MEM_SIZE);
1925         resource_fb[1].end = resource_fb[1].start + RK30_FB0_MEM_SIZE - 1;
1926         #endif
1927
1928         #if defined(CONFIG_FB_ROTATE) || !defined(CONFIG_THREE_FB_BUFFER)
1929         resource_fb[2].start = board_mem_reserve_add("fb2 buf",get_fb_size());
1930         resource_fb[2].end = resource_fb[2].start + get_fb_size() - 1;
1931         #endif
1932 #endif
1933         //ion reserve
1934 #ifdef CONFIG_ION
1935         rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
1936 #endif
1937
1938 #ifdef CONFIG_VIDEO_RK29
1939         rk30_camera_request_reserve_mem();
1940 #endif
1941 #ifdef CONFIG_GPS_RK
1942         //it must be more than 8MB
1943         rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
1944 #endif
1945         board_mem_reserved();
1946 }
1947
1948 /***********************************************************
1949 *       clock
1950 ************************************************************/
1951 static struct cpufreq_frequency_table dvfs_arm_table[] = {
1952         {.frequency = 312 * 1000,       .index = 1100 * 1000},
1953         {.frequency = 504 * 1000,       .index = 1100 * 1000},
1954         {.frequency = 816 * 1000,       .index = 1150 * 1000},
1955         {.frequency = 1008 * 1000,      .index = 1200 * 1000},
1956         //{.frequency = 1200 * 1000,      .index = 1300 * 1000},
1957         //{.frequency = 1416 * 1000,      .index = 1200 * 1000},
1958         //{.frequency = 1608 * 1000,      .index = 1200 * 1000},
1959         {.frequency = CPUFREQ_TABLE_END},
1960 };
1961
1962 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
1963         //{.frequency = 100 * 1000,       .index = 1200 * 1000},
1964         {.frequency = 200 * 1000,       .index = 1200 * 1000},
1965         //{.frequency = 266 * 1000,       .index = 1200 * 1000},
1966         //{.frequency = 300 * 1000,       .index = 1200 * 1000},
1967         //{.frequency = 400 * 1000,       .index = 1200 * 1000},
1968         {.frequency = CPUFREQ_TABLE_END},
1969 };
1970
1971 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
1972         //{.frequency = 200 * 1000 + DDR_FREQ_SUSPEND,    .index = 1200 * 1000},
1973         //{.frequency = 300 * 1000 + DDR_FREQ_VIDEO,      .index = 1200 * 1000},
1974         {.frequency = 360 * 1000 + DDR_FREQ_NORMAL,     .index = 1200 * 1000},
1975         {.frequency = CPUFREQ_TABLE_END},
1976 };
1977
1978 void __init board_clock_init(void)
1979 {
1980         rk2928_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
1981         //dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);    
1982         dvfs_set_freq_volt_table(clk_get(NULL, "cpu"), dvfs_arm_table);
1983         dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
1984         dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
1985 }
1986
1987 /************************ end *****************************/
1988 MACHINE_START(RK30, "RK30board")
1989         .boot_params    = PLAT_PHYS_OFFSET + 0x800,
1990         .fixup          = rk2928_fixup,
1991         .reserve        = &rk30_reserve,
1992         .map_io         = rk2928_map_io,
1993         .init_irq       = rk2928_init_irq,
1994         .timer          = &rk2928_timer,
1995         .init_machine   = machine_rk30_board_init,
1996 MACHINE_END