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