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