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