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