rk2928:a720:support i2c commucintion in sram and reduce arm and logic voltage when...
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk2928 / board-rk2928-a720.c
1 /* arch/arm/mach-rk2928/board-rk2928-fpga.c
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
30 #include <asm/setup.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
34 #include <asm/mach/flash.h>
35 #include <asm/hardware/gic.h>
36 #include <mach/dvfs.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
57 #include "board-rk2928-a720-camera.c" 
58 #include "board-rk2928-a720-key.c"
59
60 #ifdef  CONFIG_THREE_FB_BUFFER
61 #define RK30_FB0_MEM_SIZE 12*SZ_1M
62 #else
63 #define RK30_FB0_MEM_SIZE 8*SZ_1M
64 #endif
65
66 static struct spi_board_info board_spi_devices[] = {
67 };
68
69 /***********************************************************
70 *       rk30  backlight
71 ************************************************************/
72 #ifdef CONFIG_BACKLIGHT_RK29_BL
73 #define PWM_ID            0
74 #define PWM_MUX_NAME      GPIO0D2_PWM_0_NAME
75 #define PWM_MUX_MODE      GPIO0D_PWM_0
76 #define PWM_MUX_MODE_GPIO GPIO0D_GPIO0D2
77 #define PWM_GPIO          RK2928_PIN0_PD2
78 #define PWM_EFFECT_VALUE  0
79
80 #define LCD_DISP_ON_PIN
81
82 #ifdef  LCD_DISP_ON_PIN
83
84 #define BL_EN_PIN         RK2928_PIN1_PB0
85 #define BL_EN_VALUE       GPIO_HIGH
86 #endif
87 static int rk29_backlight_io_init(void)
88 {
89         int ret = 0;
90         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
91 #ifdef  LCD_DISP_ON_PIN
92         // rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
93
94         ret = gpio_request(BL_EN_PIN, NULL);
95         if (ret != 0) {
96                 gpio_free(BL_EN_PIN);
97         }
98
99         gpio_direction_output(BL_EN_PIN, 0);
100         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
101 #endif
102         return ret;
103 }
104
105 static int rk29_backlight_io_deinit(void)
106 {
107         int ret = 0;
108 #ifdef  LCD_DISP_ON_PIN
109         gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
110         gpio_free(BL_EN_PIN);
111 #endif
112         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
113         return ret;
114 }
115
116 static int rk29_backlight_pwm_suspend(void)
117 {
118         int ret = 0;
119         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
120         if (gpio_request(PWM_GPIO, NULL)) {
121                 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
122                 return -1;
123         }
124         gpio_direction_output(PWM_GPIO, GPIO_LOW);
125 #ifdef  LCD_DISP_ON_PIN
126         gpio_direction_output(BL_EN_PIN, 0);
127         gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
128 #endif
129
130         return ret;
131 }
132
133 static int rk29_backlight_pwm_resume(void)
134 {
135         gpio_free(PWM_GPIO);
136         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
137 #ifdef  LCD_DISP_ON_PIN
138         msleep(30);
139         gpio_direction_output(BL_EN_PIN, 1);
140         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
141 #endif
142         return 0;
143 }
144
145 static struct rk29_bl_info rk29_bl_info = {
146         .pwm_id = PWM_ID,
147         .min_brightness = 80,
148         .bl_ref = PWM_EFFECT_VALUE,
149         .io_init = rk29_backlight_io_init,
150         .io_deinit = rk29_backlight_io_deinit,
151         .pwm_suspend = rk29_backlight_pwm_suspend,
152         .pwm_resume = rk29_backlight_pwm_resume,
153 };
154
155 static struct platform_device rk29_device_backlight = {
156         .name   = "rk29_backlight",
157         .id     = -1,
158         .dev    = {
159                 .platform_data  = &rk29_bl_info,
160         }
161 };
162
163 #endif
164
165 #ifdef CONFIG_FB_ROCKCHIP
166
167 #define LCD_MUX_NAME  GPIO0C2_UART0_RTSN_NAME
168 #define LCD_GPIO_MODE GPIO0C_GPIO0C2
169
170 #define LCD_EN        RK2928_PIN0_PC2
171 #define LCD_EN_VALUE  GPIO_LOW
172
173 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
174 {
175         int ret = 0;
176
177         rk30_mux_api_set(LCD_MUX_NAME, LCD_GPIO_MODE);
178
179         ret = gpio_request(LCD_EN, NULL);
180         if (ret != 0)
181         {
182                 gpio_free(LCD_EN);
183                 printk(KERN_ERR "request lcd en pin fail!\n");
184                 return -1;
185         }
186         else
187         {
188                 gpio_direction_output(LCD_EN, LCD_EN_VALUE); //disable
189         }
190         return 0;
191 }
192 static int rk_fb_io_disable(void)
193 {
194         gpio_set_value(LCD_EN, !LCD_EN_VALUE);
195         return 0;
196 }
197 static int rk_fb_io_enable(void)
198 {
199         gpio_set_value(LCD_EN, LCD_EN_VALUE);
200         return 0;
201 }
202
203 #if defined(CONFIG_LCDC_RK2928)
204 struct rk29fb_info lcdc_screen_info = {
205         .prop      = PRMRY,             //primary display device
206         .io_init   = rk_fb_io_init,
207         .io_disable = rk_fb_io_disable,
208         .io_enable = rk_fb_io_enable,
209         .set_screen_info = set_lcd_info,
210 };
211 #endif
212
213 static struct resource resource_fb[] = {
214         [0] = {
215                 .name  = "fb0 buf",
216                 .start = 0,
217                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
218                 .flags = IORESOURCE_MEM,
219         },
220         [1] = {
221                 .name  = "ipp buf",  //for rotate
222                 .start = 0,
223                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
224                 .flags = IORESOURCE_MEM,
225         },
226         [2] = {
227                 .name  = "fb2 buf",
228                 .start = 0,
229                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
230                 .flags = IORESOURCE_MEM,
231         },
232 };
233
234 static struct platform_device device_fb = {
235         .name           = "rk-fb",
236         .id             = -1,
237         .num_resources  = ARRAY_SIZE(resource_fb),
238         .resource       = resource_fb,
239 };
240 #endif
241
242 //LCDC
243 #ifdef CONFIG_LCDC_RK2928
244 static struct resource resource_lcdc[] = {
245         [0] = {
246                 .name  = "lcdc reg",
247                 .start = RK2928_LCDC_PHYS,
248                 .end   = RK2928_LCDC_PHYS + RK2928_LCDC_SIZE - 1,
249                 .flags = IORESOURCE_MEM,
250         },
251         
252         [1] = {
253                 .name  = "lcdc irq",
254                 .start = IRQ_LCDC,
255                 .end   = IRQ_LCDC,
256                 .flags = IORESOURCE_IRQ,
257         },
258 };
259
260 static struct platform_device device_lcdc = {
261         .name             = "rk2928-lcdc",
262         .id               = 0,
263         .num_resources    = ARRAY_SIZE(resource_lcdc),
264         .resource         = resource_lcdc,
265         .dev            = {
266                 .platform_data = &lcdc_screen_info,
267         },
268 };
269 #endif
270
271 #ifdef CONFIG_ION
272 #define ION_RESERVE_SIZE        (80 * SZ_1M)
273 static struct ion_platform_data rk30_ion_pdata = {
274         .nr = 1,
275         .heaps = {
276                 {
277                         .type = ION_HEAP_TYPE_CARVEOUT,
278                         .id = ION_NOR_HEAP_ID,
279                         .name = "norheap",
280                         .size = ION_RESERVE_SIZE,
281                 }
282         },
283 };
284
285 static struct platform_device device_ion = {
286         .name = "ion-rockchip",
287         .id = 0,
288         .dev = {
289                 .platform_data = &rk30_ion_pdata,
290         },
291 };
292 #endif
293
294
295 #if defined(CONFIG_TOUCHSCREEN_SITRONIX_A720)
296
297 #define TOUCH_RESET_PIN  RK2928_PIN1_PA3
298 #define TOUCH_INT_PIN    RK2928_PIN1_PB3
299 int ft5306_init_platform_hw(void)
300 {
301
302         //printk("ft5306_init_platform_hw\n");
303         if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
304                 gpio_free(TOUCH_RESET_PIN);
305                 printk("ft5306_init_platform_hw gpio_request error\n");
306                 return -EIO;
307         }
308
309         if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
310                 gpio_free(TOUCH_INT_PIN);
311                 printk("ift5306_init_platform_hw gpio_request error\n");
312                 return -EIO;
313         }
314         gpio_direction_output(TOUCH_RESET_PIN, GPIO_HIGH);
315         mdelay(10);
316         gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
317         mdelay(10);
318         gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
319         msleep(300);
320         return 0;
321
322 }
323
324 struct ft5x0x_platform_data sitronix_info = {
325         .model = 5007,
326         .init_platform_hw= ft5306_init_platform_hw,
327 };
328
329 #endif
330
331
332 /*MMA7660 gsensor*/
333 #if defined (CONFIG_GS_MMA7660)
334 #define MMA7660_INT_PIN   RK2928_PIN1_PB1
335
336 static int mma7660_init_platform_hw(void)
337 {
338         rk30_mux_api_set(GPIO1B1_SPI_TXD_UART1_SOUT_NAME, GPIO1B_GPIO1B1);
339
340         return 0;
341 }
342
343 static struct sensor_platform_data mma7660_info = {
344         .type = SENSOR_TYPE_ACCEL,
345         .irq_enable = 1,
346         .poll_delay_ms = 30,
347         .init_platform_hw = mma7660_init_platform_hw,
348         .orientation = {-1, 0, 0, 0, 0, -1, 0, 1, 0},
349 };
350 #endif
351
352
353 #if CONFIG_RK30_PWM_REGULATOR
354 const static int pwm_voltage_map[] = {
355         1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000
356 };
357
358 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
359         {
360                 .supply = "vdd_core",
361         }
362 };
363
364 struct regulator_init_data pwm_regulator_init_dcdc[1] =
365 {
366         {
367                 .constraints = {
368                         .name = "PWM_DCDC1",
369                         .min_uV = 600000,
370                         .max_uV = 1800000,      //0.6-1.8V
371                         .apply_uV = true,
372                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
373                 },
374                 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
375                 .consumer_supplies = pwm_dcdc1_consumers,
376         },
377 };
378
379 static struct pwm_platform_data pwm_regulator_info[1] = {
380         {
381                 .pwm_id = 2,
382                 .pwm_gpio = RK2928_PIN0_PD4,
383                 .pwm_iomux_name = GPIO0D4_PWM_2_NAME,
384                 .pwm_iomux_pwm = GPIO0D_PWM_2, 
385                 .pwm_iomux_gpio = GPIO0D_GPIO0D4,
386                 .pwm_voltage = 1200000,
387                 .suspend_voltage = 1050000,
388                 .min_uV = 1000000,
389                 .max_uV = 1400000,
390                 .coefficient = 455,     //45.5%
391                 .pwm_voltage_map = pwm_voltage_map,
392                 .init_data      = &pwm_regulator_init_dcdc[0],
393         },
394 };
395
396 struct platform_device pwm_regulator_device[1] = {
397         {
398                 .name = "pwm-voltage-regulator",
399                 .id = 0,
400                 .dev            = {
401                         .platform_data = &pwm_regulator_info[0],
402                 }
403         },
404 };
405 #endif
406 /**************************************************************************************************
407  * SDMMC devices,  include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
408 **************************************************************************************************/
409 #ifdef CONFIG_SDMMC_RK29
410 #include "board-rk2928-sdk-sdmmc.c"
411
412 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
413 #define SDMMC0_WRITE_PROTECT_PIN        RK2928_PIN1_PA7 //According to your own project to set the value of write-protect-pin.
414 #endif
415
416 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
417 #define SDMMC1_WRITE_PROTECT_PIN        RK2928_PIN0_PD5 //According to your own project to set the value of write-protect-pin.
418 #endif
419
420 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N    RK2928_PIN0_PB2
421
422 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
423
424 #ifdef CONFIG_SDMMC0_RK29
425 static int rk29_sdmmc0_cfg_gpio(void)
426 {
427         rk29_sdmmc_set_iomux(0, 0xFFFF);
428
429         rk30_mux_api_set(GPIO1C1_MMC0_DETN_NAME, GPIO1C_MMC0_DETN);
430
431 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
432         gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
433         gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
434 #endif
435
436         return 0;
437 }
438
439 #define CONFIG_SDMMC0_USE_DMA
440 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
441         .host_ocr_avail =
442             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
443              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
444              MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
445         .host_caps =
446             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
447         .io_init = rk29_sdmmc0_cfg_gpio,
448
449 #if !defined(CONFIG_SDMMC_RK29_OLD)
450         .set_iomux = rk29_sdmmc_set_iomux,
451 #endif
452
453         .dma_name = "sd_mmc",
454 #ifdef CONFIG_SDMMC0_USE_DMA
455         .use_dma = 1,
456 #else
457         .use_dma = 0,
458 #endif
459         .detect_irq = RK2928_PIN1_PC1,  // INVALID_GPIO
460         .enable_sd_wakeup = 0,
461
462 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
463         .write_prt = SDMMC0_WRITE_PROTECT_PIN,
464 #else
465         .write_prt = INVALID_GPIO,
466 #endif
467 };
468 #endif // CONFIG_SDMMC0_RK29
469
470 #ifdef CONFIG_SND_SOC_RK2928
471 static struct resource resources_acodec[] = {
472         {
473                 .start  = RK2928_ACODEC_PHYS,
474                 .end    = RK2928_ACODEC_PHYS + RK2928_ACODEC_SIZE - 1,
475                 .flags  = IORESOURCE_MEM,
476         },
477         {
478                 .start  = RK2928_PIN1_PA0,
479                 .end    = RK2928_PIN1_PA0,
480                 .flags  = IORESOURCE_IO,
481         },
482 };
483
484 static struct platform_device device_acodec = {
485         .name   = "rk2928-codec",
486         .id             = -1,
487         .num_resources  = ARRAY_SIZE(resources_acodec),
488         .resource       = resources_acodec,
489 };
490 #endif
491
492 static struct platform_device *devices[] __initdata = {
493 #ifdef CONFIG_FB_ROCKCHIP
494         &device_fb,
495 #endif
496 #ifdef CONFIG_LCDC_RK2928
497         &device_lcdc,
498 #endif
499 #ifdef CONFIG_BACKLIGHT_RK29_BL
500         &rk29_device_backlight,
501 #endif
502 #ifdef CONFIG_ION
503         &device_ion,
504 #endif
505 #ifdef CONFIG_SND_SOC_RK2928
506         &device_acodec,
507 #endif
508 };
509 //i2c
510 #ifdef CONFIG_I2C0_RK30
511 #ifdef CONFIG_MFD_TPS65910
512 #define TPS65910_HOST_IRQ        RK2928_PIN1_PB2
513 #include "board-rk2928-a720-tps65910.c"
514 #endif
515 #ifdef CONFIG_REGULATOR_ACT8931
516 #include "board-rk2928-sdk-act8931.c"
517 #endif
518
519 static struct i2c_board_info __initdata i2c0_info[] = {
520 #if defined (CONFIG_MFD_TPS65910)
521         {
522         .type           = "tps65910",
523         .addr           = TPS65910_I2C_ID0,
524         .flags          = 0,
525         .irq            = TPS65910_HOST_IRQ,
526         .platform_data = &tps65910_data,
527         },
528 #endif
529 #if defined (CONFIG_REGULATOR_ACT8931)
530         {
531                 .type                   = "act8931",
532                 .addr           = 0x5b, 
533                 .flags                  = 0,
534                 .platform_data=&act8931_data,
535         },
536 #endif
537
538 };
539 #endif
540
541 int __sramdata gpio0d4_iomux,gpio0d4_do,gpio0d4_dir;
542
543 #define gpio_readl(offset)      readl_relaxed(RK2928_GPIO0_BASE + offset)
544 #define gpio_writel(v, offset)  do { writel_relaxed(v, RK2928_GPIO0_BASE + offset); dsb(); } while (0)
545
546 void __sramfunc rk30_pwm_logic_suspend_voltage(void)
547 {
548 #ifdef CONFIG_RK30_PWM_REGULATOR
549
550 //      int gpio0d7_iomux,gpio0d7_do,gpio0d7_dir,gpio0d7_en;
551         sram_udelay(10000);
552         gpio0d4_iomux = readl_relaxed(GRF_GPIO0D_IOMUX);
553         gpio0d4_do = gpio_readl(GPIO_SWPORTA_DR);
554         gpio0d4_dir = gpio_readl(GPIO_SWPORTA_DDR);
555
556         writel_relaxed((gpio0d4_iomux |(1<<24)) & (~(1<<8)), GRF_GPIO0D_IOMUX);
557         gpio_writel(gpio0d4_dir |(1<<28), GPIO_SWPORTA_DDR);
558         gpio_writel(gpio0d4_do |(1<<28), GPIO_SWPORTA_DR);
559         
560 #endif 
561 }
562 void __sramfunc rk30_pwm_logic_resume_voltage(void)
563 {
564 #ifdef CONFIG_RK30_PWM_REGULATOR
565         writel_relaxed((1<<24)|gpio0d4_iomux, GRF_GPIO0D_IOMUX);
566         gpio_writel(gpio0d4_dir, GPIO_SWPORTA_DDR);
567         gpio_writel(gpio0d4_do, GPIO_SWPORTA_DR);
568         sram_udelay(10000);
569
570 #endif
571
572 }
573 extern void pwm_suspend_voltage(void);
574 extern void pwm_resume_voltage(void);
575 void  rk30_pwm_suspend_voltage_set(void)
576 {
577 #ifdef CONFIG_RK30_PWM_REGULATOR
578         pwm_suspend_voltage();
579 #endif
580 }
581 void  rk30_pwm_resume_voltage_set(void)
582 {
583 #ifdef CONFIG_RK30_PWM_REGULATOR
584         pwm_resume_voltage();
585 #endif
586 }
587
588 #ifdef CONFIG_I2C1_RK30
589 static struct i2c_board_info __initdata i2c1_info[] = {
590 #if defined (CONFIG_GS_MMA7660)
591                 {
592                         .type           = "gs_mma7660",
593                         .addr           = 0x4c,
594                         .flags          = 0,
595                         .irq            = MMA7660_INT_PIN,
596                         .platform_data = &mma7660_info,
597                 },
598 #endif
599
600 };
601 #endif
602 #ifdef CONFIG_I2C2_RK30
603 static struct i2c_board_info __initdata i2c2_info[] = {
604 #if defined (CONFIG_TOUCHSCREEN_SITRONIX_A720)
605 {
606         .type           ="sitronix",
607         .addr           = 0x38,
608         .flags          = 0,
609         .irq            = TOUCH_INT_PIN,
610         .platform_data = &sitronix_info,
611 },
612 #endif
613 };
614 #endif
615 #ifdef CONFIG_I2C3_RK30
616 static struct i2c_board_info __initdata i2c3_info[] = {
617 };
618 #endif
619 #ifdef CONFIG_I2C_GPIO_RK30
620 #define I2C_SDA_PIN     INVALID_GPIO   //set sda_pin here
621 #define I2C_SCL_PIN     INVALID_GPIO   //set scl_pin here
622 static int rk30_i2c_io_init(void)
623 {
624         //set iomux (gpio) here
625
626         return 0;
627 }
628 struct i2c_gpio_platform_data default_i2c_gpio_data = {
629        .sda_pin = I2C_SDA_PIN,
630        .scl_pin = I2C_SCL_PIN,
631        .udelay = 5, // clk = 500/udelay = 100Khz
632        .timeout = 100,//msecs_to_jiffies(100),
633        .bus_num    = 5,
634        .io_init = rk30_i2c_io_init,
635 };
636 static struct i2c_board_info __initdata i2c_gpio_info[] = {
637 };
638 #endif
639 static void __init rk30_i2c_register_board_info(void)
640 {
641 #ifdef CONFIG_I2C0_RK30
642         i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
643 #endif
644 #ifdef CONFIG_I2C1_RK30
645         i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
646 #endif
647 #ifdef CONFIG_I2C2_RK30
648         i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
649 #endif
650 #ifdef CONFIG_I2C3_RK30
651         i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
652 #endif
653 #ifdef CONFIG_I2C_GPIO_RK30
654         i2c_register_board_info(4, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
655 #endif
656 }
657 //end of i2c
658
659 #define POWER_ON_PIN RK2928_PIN1_PA2   //power_hold
660 static void rk2928_pm_power_off(void)
661 {
662         printk(KERN_ERR "rk2928_pm_power_off start...\n");
663         
664         #if defined(CONFIG_MFD_TPS65910)
665                 tps65910_device_shutdown();//tps65910 shutdown
666         #endif
667         gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
668         
669 };
670
671 static void __init rk2928_board_init(void)
672 {
673         gpio_request(POWER_ON_PIN, "poweronpin");
674         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
675         gpio_free(POWER_ON_PIN);
676         
677         pm_power_off = rk2928_pm_power_off;
678         
679         rk30_i2c_register_board_info();
680         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
681         platform_add_devices(devices, ARRAY_SIZE(devices));
682
683 }
684
685 static void __init rk2928_reserve(void)
686 {
687 #ifdef CONFIG_ION
688         rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
689 #endif
690 #ifdef CONFIG_FB_ROCKCHIP
691         resource_fb[0].start = board_mem_reserve_add("fb0", RK30_FB0_MEM_SIZE);
692         resource_fb[0].end = resource_fb[0].start + RK30_FB0_MEM_SIZE - 1;
693 #endif
694 #ifdef CONFIG_VIDEO_RK29
695         rk30_camera_request_reserve_mem();
696 #endif
697         board_mem_reserved();
698 }
699 /**
700  * dvfs_cpu_logic_table: table for arm and logic dvfs 
701  * @frequency   : arm frequency
702  * @cpu_volt    : arm voltage depend on frequency
703  * @logic_volt  : logic voltage arm requests depend on frequency
704  * comments     : min arm/logic voltage
705  */
706 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
707         {.frequency = 216 * 1000,       .cpu_volt = 1200 * 1000,        .logic_volt = 1200 * 1000},//0.975V/1.000V
708         {.frequency = 312 * 1000,       .cpu_volt = 1200 * 1000,        .logic_volt = 1200 * 1000},//0.975V/1.000V
709         {.frequency = 408 * 1000,       .cpu_volt = 1200 * 1000,        .logic_volt = 1200 * 1000},//1.000V/1.025V
710         {.frequency = 504 * 1000,       .cpu_volt = 1200 * 1000,        .logic_volt = 1200 * 1000},//1.000V/1.025V
711         {.frequency = 600 * 1000,       .cpu_volt = 1200 * 1000,        .logic_volt = 1200 * 1000},//1.025V/1.050V
712         {.frequency = 696 * 1000,       .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.000V/1.025V
713         {.frequency = 816 * 1000,       .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
714         //{.frequency = 912 * 1000,     .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
715         //{.frequency = 1008 * 1000,    .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
716 #if 0
717         {.frequency = 1104 * 1000,      .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
718         {.frequency = 1200 * 1000,      .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
719         {.frequency = 1104 * 1000,      .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
720         {.frequency = 1248 * 1000,      .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
721 #endif
722         //{.frequency = 1000 * 1000,    .cpu_volt = 1225 * 1000,        .logic_volt = 1200 * 1000},//1.150V/1.100V
723         {.frequency = CPUFREQ_TABLE_END},
724 };
725
726 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
727         {.frequency = 266 * 1000,       .index = 1050 * 1000},
728         {.frequency = 400 * 1000,       .index = 1275 * 1000},
729         {.frequency = CPUFREQ_TABLE_END},
730 };
731
732 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
733         {.frequency = 300 * 1000,       .index = 1050 * 1000},
734         {.frequency = 400 * 1000,       .index = 1125 * 1000},
735         {.frequency = CPUFREQ_TABLE_END},
736 };
737
738 #define DVFS_CPU_TABLE_SIZE     (ARRAY_SIZE(dvfs_cpu_logic_table))
739 static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
740 static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
741
742 void __init board_clock_init(void)
743 {
744         rk2928_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
745         dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
746         dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
747         //dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
748         printk("%s end\n", __func__);
749 }
750
751
752 MACHINE_START(RK2928, "RK2928board")
753         .boot_params    = PLAT_PHYS_OFFSET + 0x800,
754         .fixup          = rk2928_fixup,
755         .reserve        = &rk2928_reserve,
756         .map_io         = rk2928_map_io,
757         .init_irq       = rk2928_init_irq,
758         .timer          = &rk2928_timer,
759         .init_machine   = rk2928_board_init,
760 MACHINE_END