ceca4ac45773394cc3a60c7a365ae4a13a658d0d
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk2928 / board-rk2928-phonepad.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 #if defined(CONFIG_SC6610)
58 #include <linux/mu509.h>
59 #endif
60
61 #include "board-rk2928-phonepad-camera.c" 
62 #include "board-rk2928-phonepad-key.c"
63
64 #ifdef  CONFIG_THREE_FB_BUFFER
65 #define RK30_FB0_MEM_SIZE 12*SZ_1M
66 #else
67 #define RK30_FB0_MEM_SIZE 8*SZ_1M
68 #endif
69
70 static struct spi_board_info board_spi_devices[] = {
71 };
72
73 /***********************************************************
74 *       rk30  backlight
75 ************************************************************/
76 #ifdef CONFIG_BACKLIGHT_RK29_BL
77 #define PWM_ID            0
78 #define PWM_MUX_NAME      GPIO0D2_PWM_0_NAME
79 #define PWM_MUX_MODE      GPIO0D_PWM_0
80 #define PWM_MUX_MODE_GPIO GPIO0D_GPIO0D2
81 #define PWM_GPIO          RK2928_PIN0_PD2
82 #define PWM_EFFECT_VALUE  1
83
84 //#define LCD_DISP_ON_PIN
85
86 #ifdef  LCD_DISP_ON_PIN
87
88 #define BL_EN_PIN         RK2928_PIN1_PB0
89 #define BL_EN_VALUE       GPIO_HIGH
90 #endif
91 static int rk29_backlight_io_init(void)
92 {
93         int ret = 0;
94         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
95 #ifdef  LCD_DISP_ON_PIN
96         // rk30_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
97
98         ret = gpio_request(BL_EN_PIN, NULL);
99         if (ret != 0) {
100                 gpio_free(BL_EN_PIN);
101         }
102
103         gpio_direction_output(BL_EN_PIN, 0);
104         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
105 #endif
106         return ret;
107 }
108
109 static int rk29_backlight_io_deinit(void)
110 {
111         int ret = 0;
112 #ifdef  LCD_DISP_ON_PIN
113         gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
114         gpio_free(BL_EN_PIN);
115 #endif
116         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
117         return ret;
118 }
119
120 static int rk29_backlight_pwm_suspend(void)
121 {
122         int ret = 0;
123         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
124         if (gpio_request(PWM_GPIO, NULL)) {
125                 printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
126                 return -1;
127         }
128         gpio_direction_output(PWM_GPIO, GPIO_LOW);
129 #ifdef  LCD_DISP_ON_PIN
130         gpio_direction_output(BL_EN_PIN, 0);
131         gpio_set_value(BL_EN_PIN, !BL_EN_VALUE);
132 #endif
133
134         return ret;
135 }
136
137 static int rk29_backlight_pwm_resume(void)
138 {
139         gpio_free(PWM_GPIO);
140         rk30_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
141 #ifdef  LCD_DISP_ON_PIN
142         msleep(30);
143         gpio_direction_output(BL_EN_PIN, 1);
144         gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
145 #endif
146         return 0;
147 }
148
149 static struct rk29_bl_info rk29_bl_info = {
150         .pwm_id = PWM_ID,
151         .min_brightness = 80,
152         .bl_ref = PWM_EFFECT_VALUE,
153         .io_init = rk29_backlight_io_init,
154         .io_deinit = rk29_backlight_io_deinit,
155         .pwm_suspend = rk29_backlight_pwm_suspend,
156         .pwm_resume = rk29_backlight_pwm_resume,
157 };
158
159 static struct platform_device rk29_device_backlight = {
160         .name   = "rk29_backlight",
161         .id     = -1,
162         .dev    = {
163                 .platform_data  = &rk29_bl_info,
164         }
165 };
166
167 #endif
168
169 #ifdef CONFIG_FB_ROCKCHIP
170
171 #define LCD_MUX_NAME  GPIO0C3_UART0_CTSN_NAME
172 #define LCD_GPIO_MODE GPIO0C_GPIO0C3
173
174 #define LCD_EN        RK2928_PIN0_PC3
175 #define LCD_EN_VALUE  GPIO_LOW
176
177 static int rk_fb_io_init(struct rk29_fb_setting_info *fb_setting)
178 {
179         int ret = 0;
180
181     rk30_mux_api_set(LCD_MUX_NAME, LCD_GPIO_MODE);
182         ret = gpio_request(LCD_EN, NULL);
183         if (ret != 0)
184         {
185                 gpio_free(LCD_EN);
186                 printk(KERN_ERR "request lcd en pin fail!\n");
187                 return -1;
188         }
189         else
190         {
191                 gpio_direction_output(LCD_EN, LCD_EN_VALUE); //disable
192         }
193         return 0;
194 }
195 static int rk_fb_io_disable(void)
196 {
197     gpio_set_value(LCD_EN, !LCD_EN_VALUE);
198         return 0;
199 }
200 static int rk_fb_io_enable(void)
201 {
202     gpio_set_value(LCD_EN, LCD_EN_VALUE);
203         return 0;
204 }
205
206 #if defined(CONFIG_LCDC_RK2928)
207 struct rk29fb_info lcdc_screen_info = {
208         .prop      = PRMRY,             //primary display device
209         .io_init   = rk_fb_io_init,
210         .io_disable = rk_fb_io_disable,
211         .io_enable = rk_fb_io_enable,
212         .set_screen_info = set_lcd_info,
213 };
214 #endif
215
216 static struct resource resource_fb[] = {
217         [0] = {
218                 .name  = "fb0 buf",
219                 .start = 0,
220                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
221                 .flags = IORESOURCE_MEM,
222         },
223         [1] = {
224                 .name  = "ipp buf",  //for rotate
225                 .start = 0,
226                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
227                 .flags = IORESOURCE_MEM,
228         },
229         [2] = {
230                 .name  = "fb2 buf",
231                 .start = 0,
232                 .end   = 0,//RK30_FB0_MEM_SIZE - 1,
233                 .flags = IORESOURCE_MEM,
234         },
235 };
236
237 static struct platform_device device_fb = {
238         .name           = "rk-fb",
239         .id             = -1,
240         .num_resources  = ARRAY_SIZE(resource_fb),
241         .resource       = resource_fb,
242 };
243 #endif
244
245 //LCDC
246 #ifdef CONFIG_LCDC_RK2928
247 static struct resource resource_lcdc[] = {
248         [0] = {
249                 .name  = "lcdc reg",
250                 .start = RK2928_LCDC_PHYS,
251                 .end   = RK2928_LCDC_PHYS + RK2928_LCDC_SIZE - 1,
252                 .flags = IORESOURCE_MEM,
253         },
254         
255         [1] = {
256                 .name  = "lcdc irq",
257                 .start = IRQ_LCDC,
258                 .end   = IRQ_LCDC,
259                 .flags = IORESOURCE_IRQ,
260         },
261 };
262
263 static struct platform_device device_lcdc = {
264         .name             = "rk2928-lcdc",
265         .id               = 0,
266         .num_resources    = ARRAY_SIZE(resource_lcdc),
267         .resource         = resource_lcdc,
268         .dev            = {
269                 .platform_data = &lcdc_screen_info,
270         },
271 };
272 #endif
273
274 #ifdef CONFIG_ION
275 #define ION_RESERVE_SIZE        (80 * SZ_1M)
276 static struct ion_platform_data rk30_ion_pdata = {
277         .nr = 1,
278         .heaps = {
279                 {
280                         .type = ION_HEAP_TYPE_CARVEOUT,
281                         .id = ION_NOR_HEAP_ID,
282                         .name = "norheap",
283                         .size = ION_RESERVE_SIZE,
284                 }
285         },
286 };
287
288 static struct platform_device device_ion = {
289         .name = "ion-rockchip",
290         .id = 0,
291         .dev = {
292                 .platform_data = &rk30_ion_pdata,
293         },
294 };
295 #endif
296
297
298 #if defined (CONFIG_TOUCHSCREEN_I30)
299 #define TOUCH_RESET_PIN RK2928_PIN3_PD5
300 #define TOUCH_INT_PIN   RK2928_PIN3_PC7
301 int ft5306_init_platform_hw(void)
302 {
303         struct regulator *ldo;
304 //      printk("ft5306_init_platform_hw\n");
305
306         ldo = regulator_get(NULL, "vaux33");
307         regulator_disable(ldo);
308         
309         if(gpio_request(TOUCH_RESET_PIN,NULL) != 0)
310         {
311                 gpio_free(TOUCH_RESET_PIN);
312                 printk("ft5306_init_platform_hw TOUCH_RESET_PIN error\n");
313                 return -EIO;
314         }
315
316         if(gpio_request(TOUCH_INT_PIN,NULL) != 0)
317         {
318                 gpio_free(TOUCH_INT_PIN);
319                 printk("ift5306_init_platform_hw TOUCH_INT_PIN error\n");
320                 return -EIO;
321         }
322         gpio_direction_input(TOUCH_INT_PIN);
323         gpio_direction_output(TOUCH_RESET_PIN, 1);
324         gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
325         msleep(50);
326         regulator_enable(ldo);
327         regulator_put(ldo);
328         msleep(300);
329         return 0;
330         
331 }
332
333 void ft5306_exit_platform_hw(void)
334 {
335 //      printk("ft5306_exit_platform_hw\n");
336         gpio_free(TOUCH_RESET_PIN);
337         gpio_free(TOUCH_INT_PIN);
338 }
339
340 int ft5306_platform_sleep(void)
341 {
342 #if 0
343         struct regulator *ldo;
344         ldo = regulator_get(NULL, "ldo9");
345         regulator_disable(ldo);
346         regulator_put(ldo);
347
348         printk("ft5306_platform_sleep\n");
349 #endif
350         gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
351         return 0;
352 }
353
354 int ft5306_platform_wakeup(void)
355 {
356 #if 0
357         struct regulator *ldo;
358         ldo = regulator_get(NULL, "ldo9");
359         regulator_set_voltage(ldo, 3300000, 3300000);
360         regulator_enable(ldo);
361         regulator_put(ldo);
362
363         printk("ft5306_platform_wakeup\n");
364 #endif
365         gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
366         msleep(300);
367         return 0;
368 }
369
370 struct ft5306_platform_data ft5306_info = {
371   .irq_pin = TOUCH_INT_PIN,
372   .rest_pin = TOUCH_RESET_PIN,
373   .init_platform_hw= ft5306_init_platform_hw,
374   .exit_platform_hw= ft5306_exit_platform_hw,
375   .platform_sleep  = ft5306_platform_sleep,
376   .platform_wakeup = ft5306_platform_wakeup,
377
378 };
379 #endif
380
381 #if defined(CONFIG_TOUCHSCREEN_BYD693X)
382
383 #define TOUCH_RESET_PIN RK2928_PIN3_PD5
384 #define TOUCH_INT_PIN   RK2928_PIN3_PC7
385 struct byd_platform_data byd693x_info = {
386         .int_pin = TOUCH_INT_PIN,
387         .rst_pin = TOUCH_RESET_PIN,
388         .screen_max_x = 800,
389         .screen_max_y = 480,
390         .xpol = -1,
391 };
392 #endif
393
394 /*MMA7660 gsensor*/
395 #if defined (CONFIG_GS_MMA7660)
396 #define MMA7660_INT_PIN   RK2928_PIN1_PB1
397
398 static int mma7660_init_platform_hw(void)
399 {
400         rk30_mux_api_set(GPIO1B1_SPI_TXD_UART1_SOUT_NAME, GPIO1B_GPIO1B1);
401
402         return 0;
403 }
404
405 static struct sensor_platform_data mma7660_info = {
406         .type = SENSOR_TYPE_ACCEL,
407         .irq_enable = 1,
408         .poll_delay_ms = 30,
409         .init_platform_hw = mma7660_init_platform_hw,
410         .orientation = {-1, 0, 0, 0, 0, -1, 0, 1, 0},
411 };
412 #endif
413
414
415 #if defined (CONFIG_GS_KXTIK)
416 #define KXTIK_INT_PIN         RK2928_PIN3_PD1
417 #if 0
418
419 static int kxtik_init_hw(void)
420 {
421         int ret = 0;
422         
423         ret = gpio_request(KXTIK_INT_PIN,"kxtik_irq");
424         if(ret){
425                 printk("kxtik gpio request fail!\n");
426                 return ret;
427         }
428         else{
429                 gpio_direction_input(KXTIK_INT_PIN);
430         }
431         return ret;
432 }
433 static void kxtik_exit_hw(void)
434 {
435         gpio_free(KXTIK_INT_PIN);
436 }
437
438 static struct gsensor_platform_data kxtik_pdata = {
439         .swap_xy = 0,
440         .swap_xyz = 1,
441         .init_platform_hw = kxtik_init_hw,
442         .exit_platform_hw = kxtik_exit_hw,
443         .orientation = {-1, 0, 0, 0, 0, -1, 0, 1, 0},
444 };
445
446 #endif
447 static int kxtik_init_platform_hw(void)
448 {
449         printk("%s: >>>>>>>>>>>>>>>>\n\n\n", __func__);
450         return 0;
451 }
452
453 static struct sensor_platform_data kxtik_pdata = {
454         .type = SENSOR_TYPE_ACCEL,
455         .irq_enable = 1,
456         .poll_delay_ms = 30,
457         .init_platform_hw = kxtik_init_platform_hw,
458         .orientation = {-1, 0, 0, 0, 0, -1, 0, 1, 0},
459         //.orientation = {0, 1, 0, 0, 0, -1, 1, 0, 0},
460 };
461
462 #endif /* CONFIG_GS_KXTIK*/
463
464 #ifdef CONFIG_INPUT_AP321XX
465 #define AP321XX_INT_PIN         RK2928_PIN0_PC6
466
467 static int AP321XX_init_hw(void)
468 {
469         int ret = 0;
470         ret = gpio_request(AP321XX_INT_PIN, NULL);
471         if (ret != 0)
472         {
473                 gpio_free(AP321XX_INT_PIN);
474                 printk(KERN_ERR "request AP321XX_INT_PIN fail!\n");
475                 return -1;
476         }
477         else
478         {
479                 gpio_direction_input(AP321XX_INT_PIN);
480         }
481         return 0;
482 }
483
484 static void AP321XX_exit_hw(void)
485 {
486         gpio_free(AP321XX_INT_PIN);
487         return;
488 }
489
490 static struct ap321xx_platform_data ap321xx_info = {
491         .init_platform_hw = AP321XX_init_hw,
492         .exit_platform_hw = AP321XX_exit_hw,
493 };
494
495 #endif
496
497 #if defined(CONFIG_BATTERY_RK30_ADC)||defined(CONFIG_BATTERY_RK30_ADC_FAC)
498 static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = {
499         .dc_det_pin      = RK2928_PIN1_PA5,
500         .batt_low_pin    = INVALID_GPIO,
501         .charge_set_pin  = INVALID_GPIO,
502         .charge_ok_pin   = RK2928_PIN1_PA0,
503         .dc_det_level    = GPIO_LOW,  //
504         .charge_ok_level = GPIO_HIGH,
505 };
506
507 static struct platform_device rk30_device_adc_battery = {
508         .name   = "rk30-battery",
509         .id     = -1,
510         .dev = {
511                 .platform_data = &rk30_adc_battery_platdata,
512         },
513 };
514 #endif
515
516
517 #if CONFIG_RK30_PWM_REGULATOR
518 const static int pwm_voltage_map[] = {
519         1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000
520 };
521
522 static struct regulator_consumer_supply pwm_dcdc1_consumers[] = {
523         {
524                 .supply = "vdd_core",
525         }
526 };
527
528 struct regulator_init_data pwm_regulator_init_dcdc[1] =
529 {
530         {
531                 .constraints = {
532                         .name = "PWM_DCDC1",
533                         .min_uV = 600000,
534                         .max_uV = 1800000,      //0.6-1.8V
535                         .apply_uV = true,
536                         .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
537                 },
538                 .num_consumer_supplies = ARRAY_SIZE(pwm_dcdc1_consumers),
539                 .consumer_supplies = pwm_dcdc1_consumers,
540         },
541 };
542
543 static struct pwm_platform_data pwm_regulator_info[1] = {
544         {
545                 .pwm_id = 2,
546                 .pwm_gpio = RK2928_PIN0_PD4,
547                 .pwm_iomux_name = GPIO0D4_PWM_2_NAME,
548                 .pwm_iomux_pwm = GPIO0D_PWM_2, 
549                 .pwm_iomux_gpio = GPIO0D_GPIO0D4,
550                 .pwm_voltage = 1200000,
551                 .suspend_voltage = 1050000,
552                 .min_uV = 1000000,
553                 .max_uV = 1400000,
554                 .coefficient = 455,     //45.5%
555                 .pwm_voltage_map = pwm_voltage_map,
556                 .init_data      = &pwm_regulator_init_dcdc[0],
557         },
558 };
559
560 struct platform_device pwm_regulator_device[1] = {
561         {
562                 .name = "pwm-voltage-regulator",
563                 .id = 0,
564                 .dev            = {
565                         .platform_data = &pwm_regulator_info[0],
566                 }
567         },
568 };
569 #endif
570 /**************************************************************************************************
571  * SDMMC devices,  include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05
572 **************************************************************************************************/
573 #ifdef CONFIG_SDMMC_RK29
574 #include "board-rk2928-phonepad-sdmmc.c"
575
576 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
577 #define SDMMC0_WRITE_PROTECT_PIN        RK2928_PIN1_PA7 //According to your own project to set the value of write-protect-pin.
578 #endif
579
580 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
581 #define SDMMC1_WRITE_PROTECT_PIN        RK2928_PIN0_PD5 //According to your own project to set the value of write-protect-pin.
582 #endif
583
584 #define RK29SDK_WIFI_SDIO_CARD_DETECT_N    RK2928_PIN0_PB2
585
586 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
587
588 #ifdef CONFIG_SDMMC0_RK29
589 static int rk29_sdmmc0_cfg_gpio(void)
590 {
591         rk29_sdmmc_set_iomux(0, 0xFFFF);
592
593         rk30_mux_api_set(GPIO1C1_MMC0_DETN_NAME, GPIO1C_MMC0_DETN);
594
595 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
596         gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp");
597         gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN);
598 #endif
599
600         return 0;
601 }
602
603 #define CONFIG_SDMMC0_USE_DMA
604 struct rk29_sdmmc_platform_data default_sdmmc0_data = {
605         .host_ocr_avail =
606             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
607              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
608              MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36),
609         .host_caps =
610             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
611         .io_init = rk29_sdmmc0_cfg_gpio,
612
613 #if !defined(CONFIG_SDMMC_RK29_OLD)
614         .set_iomux = rk29_sdmmc_set_iomux,
615 #endif
616
617         .dma_name = "sd_mmc",
618 #ifdef CONFIG_SDMMC0_USE_DMA
619         .use_dma = 1,
620 #else
621         .use_dma = 0,
622 #endif
623         .detect_irq =  INVALID_GPIO,
624         .enable_sd_wakeup = 0,
625
626 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
627         .write_prt = SDMMC0_WRITE_PROTECT_PIN,
628 #else
629         .write_prt = INVALID_GPIO,
630 #endif
631 };
632 #endif // CONFIG_SDMMC0_RK29
633 #ifdef CONFIG_SDMMC1_RK29
634 #define CONFIG_SDMMC1_USE_DMA
635 static int rk29_sdmmc1_cfg_gpio(void)
636 {
637 #if defined(CONFIG_SDMMC_RK29_OLD)
638         rk30_mux_api_set(GPIO0B0_MMC1_CMD_NAME, GPIO0B_MMC1_CMD);
639         rk30_mux_api_set(GPIO0B1_MMC1_CLKOUT_NAME, GPIO0B_MMC1_CLKOUT);
640         rk30_mux_api_set(GPIO0B3_MMC1_D0_NAME, GPIO0B_MMC1_D0);
641         rk30_mux_api_set(GPIO0B4_MMC1_D1_NAME, GPIO0B_MMC1_D1);
642         rk30_mux_api_set(GPIO0B5_MMC1_D2_NAME, GPIO0B_MMC1_D2);
643         rk30_mux_api_set(GPIO0B6_MMC1_D3_NAME, GPIO0B_MMC1_D3);
644         //rk30_mux_api_set(GPIO0B2_MMC1_DETN_NAME, GPIO0B_MMC1_DETN);
645
646 #else
647
648 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
649         gpio_request(SDMMC1_WRITE_PROTECT_PIN, "sdio-wp");
650         gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN);
651 #endif
652
653 #endif
654
655         return 0;
656 }
657
658 struct rk29_sdmmc_platform_data default_sdmmc1_data = {
659         .host_ocr_avail =
660             (MMC_VDD_25_26 | MMC_VDD_26_27 | MMC_VDD_27_28 | MMC_VDD_28_29 |
661              MMC_VDD_29_30 | MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
662              MMC_VDD_33_34),
663
664 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
665         .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
666                       MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
667 #else
668         .host_caps =
669             (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
670 #endif
671
672         .io_init = rk29_sdmmc1_cfg_gpio,
673
674 #if !defined(CONFIG_SDMMC_RK29_OLD)
675         .set_iomux = rk29_sdmmc_set_iomux,
676 #endif
677
678         .dma_name = "sdio",
679 #ifdef CONFIG_SDMMC1_USE_DMA
680         .use_dma = 1,
681 #else
682         .use_dma = 0,
683 #endif
684
685 #if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD)
686 #ifdef CONFIG_WIFI_CONTROL_FUNC
687         .status = rk29sdk_wifi_status,
688         .register_status_notify = rk29sdk_wifi_status_register,
689 #endif
690 #if 1
691         .detect_irq = INVALID_GPIO,//RK29SDK_WIFI_SDIO_CARD_DETECT_N,
692 #endif
693
694 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
695         .write_prt = SDMMC1_WRITE_PROTECT_PIN,
696 #else
697         .write_prt = INVALID_GPIO,
698 #endif
699
700 #else
701         .detect_irq = INVALID_GPIO,
702         .enable_sd_wakeup = 0,
703 #endif
704
705 };
706 #endif //endif--#ifdef CONFIG_SDMMC1_RK29
707
708 #if defined(CONFIG_SC6610)
709 static int sc6610_io_init(void)
710 {
711         
712         return 0;
713 }
714
715 static int sc6610_io_deinit(void)
716 {
717         
718
719         return 0;
720 }
721
722 struct rk29_mu509_data rk29_sc6610_info = {
723         .io_init = sc6610_io_init,
724         .io_deinit = sc6610_io_deinit,
725         .bp_power = RK2928_PIN3_PC2,//RK29_PIN0_PB4,
726         .bp_reset = NULL,//RK29_PIN0_PB3,
727         .bp_wakeup_ap = RK2928_PIN3_PC3,//RK29_PIN0_PC2,
728         .ap_wakeup_bp = RK2928_PIN3_PC4,//RK29_PIN0_PB0, 
729         .modem_assert = RK2928_PIN3_PC5,
730 };
731 struct platform_device rk29_device_sc6610 = {
732         .name = "SC6610",
733         .id = -1,
734         .dev            = {
735                 .platform_data = &rk29_sc6610_info,
736         }
737     };
738 #endif
739 #ifdef CONFIG_SND_SOC_RK2928
740 static struct resource resources_acodec[] = {
741         {
742                 .start  = RK2928_ACODEC_PHYS,
743                 .end    = RK2928_ACODEC_PHYS + RK2928_ACODEC_SIZE - 1,
744                 .flags  = IORESOURCE_MEM,
745         },
746         {
747                 .start  = RK2928_PIN3_PD4,
748                 .end    = RK2928_PIN3_PD4,
749                 .flags  = IORESOURCE_IO,
750         },
751 };
752
753 static struct platform_device device_acodec = {
754         .name   = "rk2928-codec",
755         .id             = -1,
756         .num_resources  = ARRAY_SIZE(resources_acodec),
757         .resource       = resources_acodec,
758 };
759 #endif
760
761 static struct platform_device *devices[] __initdata = {
762 #ifdef CONFIG_FB_ROCKCHIP
763         &device_fb,
764 #endif
765 #ifdef CONFIG_LCDC_RK2928
766         &device_lcdc,
767 #endif
768 #ifdef CONFIG_BACKLIGHT_RK29_BL
769         &rk29_device_backlight,
770 #endif
771 #ifdef CONFIG_ION
772         &device_ion,
773 #endif
774 #ifdef CONFIG_SND_SOC_RK2928
775         &device_acodec,
776 #endif
777
778 #if defined(CONFIG_BATTERY_RK30_ADC)||defined(CONFIG_BATTERY_RK30_ADC_FAC)
779         &rk30_device_adc_battery,
780 #endif
781 #if defined(CONFIG_SC6610)
782         &rk29_device_sc6610,
783
784 #endif
785 };
786 //i2c
787 #ifdef CONFIG_I2C0_RK30
788 #ifdef CONFIG_MFD_TPS65910
789 #define TPS65910_HOST_IRQ        RK2928_PIN3_PC6
790 #include "board-rk2928-phonepad-tps65910.c"
791 #endif
792 #ifdef CONFIG_REGULATOR_ACT8931
793 #include "board-rk2928-sdk-act8931.c"
794 #endif
795
796 static struct i2c_board_info __initdata i2c0_info[] = {
797 #if defined (CONFIG_MFD_TPS65910)
798         {
799         .type           = "tps65910",
800         .addr           = TPS65910_I2C_ID0,
801         .flags          = 0,
802         .irq            = TPS65910_HOST_IRQ,
803         .platform_data = &tps65910_data,
804         },
805 #endif
806 #if defined (CONFIG_REGULATOR_ACT8931)
807         {
808                 .type                   = "act8931",
809                 .addr           = 0x5b, 
810                 .flags                  = 0,
811                 .platform_data=&act8931_data,
812         },
813 #endif
814 };
815 #endif
816 #ifdef CONFIG_I2C1_RK30
817 static struct i2c_board_info __initdata i2c1_info[] = {
818 #if defined (CONFIG_GS_MMA7660)
819                 {
820                         .type           = "gs_mma7660",
821                         .addr           = 0x4c,
822                         .flags          = 0,
823                         .irq            = MMA7660_INT_PIN,
824                         .platform_data = &mma7660_info,
825                 },
826 #endif
827
828
829 #if defined (CONFIG_GS_KXTIK)
830                 {
831                                 .type           = "gs_kxtik",
832                                 .addr           = 0x0F,
833                                 .flags          = 0,
834                                 .platform_data = &kxtik_pdata,
835                                 .irq = KXTIK_INT_PIN, // Replace with appropriate GPIO setup
836                 },
837 #endif
838
839 #ifdef CONFIG_INPUT_AP321XX
840         {
841                 .type                   = "ap321xx",
842                 .addr                   = 0x1E,
843                 .flags                  = 0,
844                 .irq                     = AP321XX_INT_PIN,
845                 .platform_data = &ap321xx_info
846         },
847 #endif
848 #ifdef CONFIG_RDA5990
849 #define RDA_WIFI_CORE_ADDR (0x13)
850 #define RDA_WIFI_RF_ADDR (0x14) //correct add is 0x14
851 #define RDA_BT_CORE_ADDR (0x15)
852 #define RDA_BT_RF_ADDR (0x16)
853
854 #define RDA_WIFI_RF_I2C_DEVNAME "rda_wifi_rf_i2c"
855 #define RDA_WIFI_CORE_I2C_DEVNAME "rda_wifi_core_i2c"
856 #define RDA_BT_RF_I2C_DEVNAME "rda_bt_rf_i2c"
857 #define RDA_BT_CORE_I2C_DEVNAME "rda_bt_core_i2c"
858                 {
859                         .type          = RDA_WIFI_CORE_I2C_DEVNAME,
860                         .addr          = RDA_WIFI_CORE_ADDR,
861                         .flags         = 0,
862
863                 },
864
865                 {
866                         .type          = RDA_WIFI_RF_I2C_DEVNAME,
867                         .addr          = RDA_WIFI_RF_ADDR,
868                         .flags         = 0,
869
870                 },
871                 {
872                         .type          = RDA_BT_CORE_I2C_DEVNAME,
873                         .addr          = RDA_BT_CORE_ADDR,
874                         .flags         = 0,
875
876                 },
877                 {
878                         .type          = RDA_BT_RF_I2C_DEVNAME,
879                         .addr          = RDA_BT_RF_ADDR,
880                         .flags         = 0,
881
882                 },
883 #endif
884
885 };
886 #endif
887 #ifdef CONFIG_I2C2_RK30
888 static struct i2c_board_info __initdata i2c2_info[] = {
889 #if defined (CONFIG_TOUCHSCREEN_I30)
890         {
891                 .type          = "ft5x0x_ts",
892                 .addr          = 0x38,
893                 .flags         = 0,
894                 .irq           = TOUCH_INT_PIN,
895                 .platform_data = &ft5306_info,
896         },
897 #endif
898 #if defined(CONFIG_TOUCHSCREEN_BYD693X)
899         {
900                 .type          = "byd693x-ts",
901                 .addr          = 0x52,
902                 .flags         = 0,
903                 .irq           = TOUCH_INT_PIN,
904                 .platform_data = &byd693x_info,
905         },
906 #endif
907 };
908 #endif
909 #ifdef CONFIG_I2C3_RK30
910 static struct i2c_board_info __initdata i2c3_info[] = {
911 };
912 #endif
913 #ifdef CONFIG_I2C_GPIO_RK30
914 #define I2C_SDA_PIN     INVALID_GPIO   //set sda_pin here
915 #define I2C_SCL_PIN     INVALID_GPIO   //set scl_pin here
916 static int rk30_i2c_io_init(void)
917 {
918         //set iomux (gpio) here
919
920         return 0;
921 }
922 struct i2c_gpio_platform_data default_i2c_gpio_data = {
923        .sda_pin = I2C_SDA_PIN,
924        .scl_pin = I2C_SCL_PIN,
925        .udelay = 5, // clk = 500/udelay = 100Khz
926        .timeout = 100,//msecs_to_jiffies(100),
927        .bus_num    = 5,
928        .io_init = rk30_i2c_io_init,
929 };
930 static struct i2c_board_info __initdata i2c_gpio_info[] = {
931 };
932 #endif
933 static void __init rk30_i2c_register_board_info(void)
934 {
935 #ifdef CONFIG_I2C0_RK30
936         i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
937 #endif
938 #ifdef CONFIG_I2C1_RK30
939         i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
940 #endif
941 #ifdef CONFIG_I2C2_RK30
942         i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
943 #endif
944 #ifdef CONFIG_I2C3_RK30
945         i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
946 #endif
947 #ifdef CONFIG_I2C_GPIO_RK30
948         i2c_register_board_info(4, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
949 #endif
950 }
951 //end of i2c
952
953 #define POWER_ON_PIN RK2928_PIN1_PA2   //power_hold
954 static void rk2928_pm_power_off(void)
955 {
956         printk(KERN_ERR "rk2928_pm_power_off start...\n");
957         
958         #if defined(CONFIG_MFD_TPS65910)
959                 tps65910_device_shutdown();//tps65910 shutdown
960         #endif
961         gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
962         
963 };
964
965 static void __init rk2928_board_init(void)
966 {
967         gpio_request(POWER_ON_PIN, "poweronpin");
968         gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
969         gpio_free(POWER_ON_PIN);
970         
971         pm_power_off = rk2928_pm_power_off;
972         
973         rk30_i2c_register_board_info();
974         spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
975         platform_add_devices(devices, ARRAY_SIZE(devices));
976
977 }
978
979 static void __init rk2928_reserve(void)
980 {
981 #ifdef CONFIG_ION
982         rk30_ion_pdata.heaps[0].base = board_mem_reserve_add("ion", ION_RESERVE_SIZE);
983 #endif
984 #ifdef CONFIG_FB_ROCKCHIP
985         resource_fb[0].start = board_mem_reserve_add("fb0", RK30_FB0_MEM_SIZE);
986         resource_fb[0].end = resource_fb[0].start + RK30_FB0_MEM_SIZE - 1;
987 #endif
988 #ifdef CONFIG_VIDEO_RK29
989         rk30_camera_request_reserve_mem();
990 #endif
991         board_mem_reserved();
992 }
993 /**
994  * dvfs_cpu_logic_table: table for arm and logic dvfs 
995  * @frequency   : arm frequency
996  * @cpu_volt    : arm voltage depend on frequency
997  * @logic_volt  : logic voltage arm requests depend on frequency
998  * comments     : min arm/logic voltage
999  */
1000 static struct dvfs_arm_table dvfs_cpu_logic_table[] = {
1001         {.frequency = 216 * 1000,       .cpu_volt = 1200 * 1000,        .logic_volt = 1200 * 1000},//0.975V/1.000V
1002         {.frequency = 312 * 1000,       .cpu_volt = 1200 * 1000,        .logic_volt = 1200 * 1000},//0.975V/1.000V
1003         {.frequency = 408 * 1000,       .cpu_volt = 1200 * 1000,        .logic_volt = 1200 * 1000},//1.000V/1.025V
1004         {.frequency = 504 * 1000,       .cpu_volt = 1200 * 1000,        .logic_volt = 1200 * 1000},//1.000V/1.025V
1005         {.frequency = 600 * 1000,       .cpu_volt = 1200 * 1000,        .logic_volt = 1200 * 1000},//1.025V/1.050V
1006         {.frequency = 696 * 1000,       .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.000V/1.025V
1007         {.frequency = 816 * 1000,       .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
1008         //{.frequency = 912 * 1000,     .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
1009         //{.frequency = 1008 * 1000,    .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
1010 #if 0
1011         {.frequency = 1104 * 1000,      .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
1012         {.frequency = 1200 * 1000,      .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
1013         {.frequency = 1104 * 1000,      .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
1014         {.frequency = 1248 * 1000,      .cpu_volt = 1400 * 1000,        .logic_volt = 1200 * 1000},//1.100V/1.050V
1015 #endif
1016         //{.frequency = 1000 * 1000,    .cpu_volt = 1225 * 1000,        .logic_volt = 1200 * 1000},//1.150V/1.100V
1017         {.frequency = CPUFREQ_TABLE_END},
1018 };
1019
1020 static struct cpufreq_frequency_table dvfs_gpu_table[] = {
1021         {.frequency = 266 * 1000,       .index = 1050 * 1000},
1022         {.frequency = 400 * 1000,       .index = 1275 * 1000},
1023         {.frequency = CPUFREQ_TABLE_END},
1024 };
1025
1026 static struct cpufreq_frequency_table dvfs_ddr_table[] = {
1027         {.frequency = 300 * 1000,       .index = 1050 * 1000},
1028         {.frequency = 400 * 1000,       .index = 1125 * 1000},
1029         {.frequency = CPUFREQ_TABLE_END},
1030 };
1031
1032 #define DVFS_CPU_TABLE_SIZE     (ARRAY_SIZE(dvfs_cpu_logic_table))
1033 static struct cpufreq_frequency_table cpu_dvfs_table[DVFS_CPU_TABLE_SIZE];
1034 static struct cpufreq_frequency_table dep_cpu2core_table[DVFS_CPU_TABLE_SIZE];
1035
1036 void __init board_clock_init(void)
1037 {
1038         rk2928_clock_data_init(periph_pll_default, codec_pll_default, RK30_CLOCKS_DEFAULT_FLAGS);
1039         dvfs_set_arm_logic_volt(dvfs_cpu_logic_table, cpu_dvfs_table, dep_cpu2core_table);
1040         dvfs_set_freq_volt_table(clk_get(NULL, "gpu"), dvfs_gpu_table);
1041         //dvfs_set_freq_volt_table(clk_get(NULL, "ddr"), dvfs_ddr_table);
1042         printk("%s end\n", __func__);
1043 }
1044
1045
1046 MACHINE_START(RK2928, "RK2928board")
1047         .boot_params    = PLAT_PHYS_OFFSET + 0x800,
1048         .fixup          = rk2928_fixup,
1049         .reserve        = &rk2928_reserve,
1050         .map_io         = rk2928_map_io,
1051         .init_irq       = rk2928_init_irq,
1052         .timer          = &rk2928_timer,
1053         .init_machine   = rk2928_board_init,
1054 MACHINE_END