ac: add for display key control
[firefly-linux-kernel-4.4.55.git] / arch / arm / plat-rk / include / plat / board.h
1 #ifndef __PLAT_BOARD_H
2 #define __PLAT_BOARD_H
3
4 #include <linux/types.h>
5 #include <linux/init.h>
6 #include <linux/device.h>
7 #include <linux/rk_screen.h>
8 #include <plat/sram.h>
9
10 struct adc_platform_data {
11         int ref_volt;
12         int base_chn;
13         int (*get_base_volt)(void);
14 };
15 enum {
16         I2C_IDLE = 0,
17         I2C_SDA_LOW,
18         I2C_SCL_LOW,
19         BOTH_LOW,
20 };
21
22 struct akm8963_platform_data { 
23                  int gpio_DRDY;
24                  int gpio_RST;
25                  char layout;
26                  char outbit;         
27 }; 
28
29 struct rk30_i2c_platform_data {
30         char *name;
31         int bus_num;
32 #define I2C_RK29_ADAP   0
33 #define I2C_RK30_ADAP   1
34         int adap_type;
35         int is_div_from_arm;
36         u32 flags;
37         int scl_mode;
38         int sda_mode;
39         int (*io_init)(void);
40         int (*io_deinit)(void);
41 };
42
43 struct spi_cs_gpio {
44         const char *name;
45         unsigned int cs_gpio;
46         char *cs_iomux_name;
47         unsigned int cs_iomux_mode;
48 };
49
50 struct rk29xx_spi_platform_data {
51         int (*io_init)(struct spi_cs_gpio*, int);
52         int (*io_deinit)(struct spi_cs_gpio*, int);
53         int (*io_fix_leakage_bug)(void);
54         int (*io_resume_leakage_bug)(void);
55         struct spi_cs_gpio *chipselect_gpios;
56         u16 num_chipselect;
57 };
58
59 enum {
60         BRIGHTNESS_MODE_LINE=0,
61         BRIGHTNESS_MODE_CONIC =1,
62 };
63
64
65 struct rk29_bl_info {
66         u32 pwm_id;
67         u32 bl_ref;
68         int (*io_init)(void);
69         int (*io_deinit)(void);
70         int (*pwm_suspend)(void);
71         int (*pwm_resume)(void);
72         int min_brightness;     /* 0 ~ 255 */
73         int max_brightness;     /* 0 ~ 255 */
74         int brightness_mode;
75         unsigned int delay_ms;  /* in milliseconds */
76         int pre_div;
77 };
78
79 struct rk29_io_t {
80     unsigned long io_addr;
81     unsigned long enable;
82     unsigned long disable;
83     int (*io_init)(void);
84 };
85
86 enum {
87         PMIC_TYPE_NONE =0,
88         PMIC_TYPE_WM8326 =1,
89         PMIC_TYPE_TPS65910 =2,
90         PMIC_TYPE_ACT8931 =3,
91         PMIC_TYPE_ACT8846 =3,
92         PMIC_TYPE_RK808 =4,
93         PMIC_TYPE_RICOH619 =5,
94         PMIC_TYPE_RT5025 =6,
95         PMIC_TYPE_MAX,
96 };
97 extern __sramdata  int g_pmic_type;
98 #define pmic_is_wm8326()  (g_pmic_type == PMIC_TYPE_WM8326)
99 #define pmic_is_tps65910()  (g_pmic_type == PMIC_TYPE_TPS65910)
100 #define pmic_is_act8931()  (g_pmic_type == PMIC_TYPE_ACT8931)
101 #define pmic_is_act8846()  (g_pmic_type == PMIC_TYPE_ACT8846)
102 #define pmic_is_rk808()  (g_pmic_type == PMIC_TYPE_RK808)
103 #define pmic_is_ricoh619()  (g_pmic_type == PMIC_TYPE_RICOH619)
104 #define pmic_is_rt5025()  (g_pmic_type == PMIC_TYPE_RT5025)
105
106 struct  pmu_info {
107         char            *name;
108         int             min_uv;
109         int             max_uv;   
110         int          suspend_vol;
111 };
112
113
114 struct rksdmmc_iomux {
115     char    *name;  //set the MACRO of gpio
116     int     fgpio;
117     int     fmux;
118 };
119
120 struct rksdmmc_gpio {
121     int     io;                             //set the address of gpio
122     char    name[64];   //
123     int     enable;  // disable = !enable   //set the default value,i.e,GPIO_HIGH or GPIO_LOW
124     struct rksdmmc_iomux  iomux;
125 };
126
127
128 struct rksdmmc_gpio_board {
129     struct rksdmmc_gpio   clk_gpio;
130     struct rksdmmc_gpio   cmd_gpio;
131     struct rksdmmc_gpio   data0_gpio;
132     struct rksdmmc_gpio   data1_gpio;    
133     struct rksdmmc_gpio   data2_gpio;
134     struct rksdmmc_gpio   data3_gpio;
135    
136     struct rksdmmc_gpio   detect_irq;    
137     struct rksdmmc_gpio   power_en_gpio;   
138     struct rksdmmc_gpio   write_prt;
139     struct rksdmmc_gpio   sdio_irq_gpio;
140 };
141
142
143 struct rksdmmc_gpio_wifi_moudle {
144     struct rksdmmc_gpio   power_n;  //PMU_EN  
145     struct rksdmmc_gpio   reset_n;  //SYSRET_B, DAIRST 
146     struct rksdmmc_gpio   vddio;    //power source
147     struct rksdmmc_gpio   bgf_int_b;
148     struct rksdmmc_gpio   wifi_int_b;
149     struct rksdmmc_gpio   gps_sync;
150     struct rksdmmc_gpio   ANTSEL2;  //pin5--ANTSEL2  
151     struct rksdmmc_gpio   ANTSEL3;  //pin6--ANTSEL3 
152     struct rksdmmc_gpio   GPS_LAN;  //pin33--GPS_LAN
153 };
154
155
156 struct rk29_sdmmc_platform_data {
157         unsigned int host_caps;
158         unsigned int host_ocr_avail;
159         unsigned int use_dma:1;
160         char dma_name[8];
161         int (*io_init)(void);
162         int (*io_deinit)(void);
163         void (*set_iomux)(int device_id, unsigned int bus_width);//added by xbw at 2011-10-13
164         int (*status)(struct device *);
165         int (*register_status_notify)(void (*callback)(int card_present, void *dev_id), void *dev_id);
166         int detect_irq;
167         int insert_card_level;
168     int power_en;
169         int power_en_level;
170         int enable_sd_wakeup;
171         int write_prt;
172         int write_prt_enalbe_level;
173         unsigned int sdio_INT_gpio;
174         int sdio_INT_level;
175 #define USE_SDIO_INT_LEVEL  /*In order to be compatible with old project, those who do not define the member  sdio_INT_level */
176         struct rksdmmc_gpio   det_pin_info;
177         int (*sd_vcc_reset)(void);
178 };
179
180 struct gsensor_platform_data {
181         u16 model;
182         u16 swap_xy;
183         u16 swap_xyz;
184         signed char orientation[9];
185         int (*get_pendown_state)(void);
186         int (*init_platform_hw)(void);
187         int (*gsensor_platform_sleep)(void);
188         int (*gsensor_platform_wakeup)(void);
189         void (*exit_platform_hw)(void);
190 };
191
192 struct akm8975_platform_data {
193         short m_layout[4][3][3];
194         char project_name[64];
195         int gpio_DRDY;
196 };
197
198 struct akm_platform_data {
199        short m_layout[4][3][3];
200        char project_name[64];
201        char layout;
202        char outbit;
203        int gpio_DRDY;
204        int gpio_RST;
205 };
206
207
208 struct sensor_platform_data {
209         int type;
210         int irq;
211         int power_pin;
212         int reset_pin;
213         int standby_pin;
214         int irq_enable;         //if irq_enable=1 then use irq else use polling  
215         int poll_delay_ms;      //polling
216         int x_min;              //filter
217         int y_min;
218         int z_min;
219         int factory;
220         int layout;
221         unsigned char address;
222         signed char orientation[9];
223         short m_layout[4][3][3];
224         char project_name[64];
225         int (*init_platform_hw)(void);
226         void (*exit_platform_hw)(void);
227         int (*power_on)(void);
228         int (*power_off)(void);
229 };
230
231 /* Platform data for the board id */
232 struct board_id_platform_data {
233         int gpio_pin[32];
234         int num_gpio;
235         char *board_id_buf;
236         int (*init_platform_hw)(void);
237         int (*exit_platform_hw)(void);
238         struct board_device_table *device_table;
239         int device_table_size;
240         int (*init_parameter)(int id);  
241 };
242
243 struct ft5506_platform_data {
244     int     (*get_pendown_state)(void);
245     int     (*init_platform_hw)(void);
246     int     (*platform_sleep)(void);
247     int     (*platform_wakeup)(void);
248     void    (*exit_platform_hw)(void);
249 };
250 struct cm3217_platform_data {
251         int irq_pin;
252         int power_pin;
253         int (*init_platform_hw)(void);
254         void (*exit_platform_hw)(void);
255 };
256
257 struct irda_info {
258         u32 intr_pin;
259         int (*iomux_init)(void);
260         int (*iomux_deinit)(void);
261         int (*irda_pwr_ctl)(int en);
262 };
263
264 struct rk29_gpio_expander_info {
265         unsigned int gpio_num;
266         unsigned int pin_type;  //GPIO_IN or GPIO_OUT
267         unsigned int pin_value; //GPIO_HIGH or GPIO_LOW
268 };
269
270 /*vmac*/
271 struct rk29_vmac_platform_data {
272         int (*vmac_register_set)(void);
273         int (*rmii_io_init)(void);
274         int (*rmii_io_deinit)(void);
275         int (*rmii_power_control)(int enable);
276         int(*rmii_speed_switch)(int speed);
277 };
278 /* adc battery */
279 #define LCDC_ON 0x0001
280 #define BACKLIGHT_ON 0x0002
281 struct rk30_adc_battery_platform_data {
282         int (*io_init)(void);
283         int (*io_deinit)(void);
284         int (*is_dc_charging)(void);
285         int (*charging_ok)(void);
286
287         int (*is_usb_charging)(void);
288         int spport_usb_charging ;
289         int (*control_usb_charging)(int);
290
291         int usb_det_pin;
292         int dc_det_pin;
293         int batt_low_pin;
294         int charge_ok_pin;
295         int charge_set_pin;
296         int back_light_pin;
297
298         int ctrl_charge_led_pin;
299         int ctrl_charge_enable;
300         void (*ctrl_charge_led)(int);
301         
302         int dc_det_level;
303         int batt_low_level;
304         int charge_ok_level;
305         int charge_set_level;
306         int usb_det_level;
307         
308         int adc_channel;
309
310         int dc_det_pin_pull;    //pull up/down enable/disbale
311         int batt_low_pin_pull;
312         int charge_ok_pin_pull;
313         int charge_set_pin_pull;
314
315         int low_voltage_protection; // low voltage protection
316
317         int charging_sleep; // don't have lock,if chargeing_sleep = 0;else have lock
318         
319         int is_reboot_charging;
320         int save_capacity;  //save capacity to /data/bat_last_capacity.dat,  suggested use
321
322         int reference_voltage; // the rK2928 is 3300;RK3066 and rk29 are 2500;rk3066B is 1800;
323         int pull_up_res;      //divider resistance ,  pull-up resistor
324         int pull_down_res; //divider resistance , pull-down resistor
325
326         int time_down_discharge; //the time of capactiy drop 1% --discharge
327         int time_up_charge; //the time of capacity up 1% ---charging 
328
329         int  use_board_table;
330         int  table_size;
331         int  *discharge_table;
332         int  *charge_table;
333         int  *property_tabel;
334         int *board_batt_table;
335         int chargeArray[11];
336         int dischargeArray[11];
337
338
339 };
340
341 #ifndef _LINUX_WLAN_PLAT_H_
342 struct wifi_platform_data {
343         int (*set_power)(int val);
344         int (*set_reset)(int val);
345         int (*set_carddetect)(int val);
346         void *(*mem_prealloc)(int section, unsigned long size);
347         int (*get_mac_addr)(unsigned char *buf);
348 };
349 #endif
350
351 struct goodix_platform_data {
352         int model ;
353         int rest_pin;
354         int irq_pin ;
355         int (*get_pendown_state)(void);
356         int (*init_platform_hw)(void);
357         int (*platform_sleep)(void);
358         int (*platform_wakeup)(void);
359         void (*exit_platform_hw)(void);
360 };
361
362 struct tp_platform_data {
363         int model;
364         int x_max;
365         int y_max;
366         int reset_pin;
367         int irq_pin ;
368         int firmVer;
369         int (*get_pendown_state)(void);
370         int (*init_platform_hw)(void);
371         int (*platform_sleep)(void);
372         int (*platform_wakeup)(void);
373         void (*exit_platform_hw)(void);
374 };
375
376
377 struct codec_platform_data {
378         int spk_pin;
379         int hp_pin ;
380 };
381
382 struct ac_usb_switch_platform_data {
383         int usb_switch_pin;
384         int pc_state_pin ;
385 };
386 struct ct360_platform_data {
387         u16             model;
388         u16             x_max;
389         u16             y_max;
390         void    (*hw_init)(void);
391         void    (*shutdown)(int);
392 };
393
394 struct ft5606_platform_data {
395     int     (*get_pendown_state)(void);
396     int     (*init_platform_hw)(void);
397     int     (*platform_sleep)(void);
398     int     (*platform_wakeup)(void);
399     void    (*exit_platform_hw)(void);
400 };
401
402 #if defined(CONFIG_TOUCHSCREEN_FT5306) || defined(CONFIG_TOUCHSCREEN_FT5306_WPX2)
403 struct ft5x0x_platform_data{
404         u16     model;
405         int     max_x;
406         int     max_y;
407         int     key_min_x;
408         int     key_min_y;
409         int     xy_swap;
410         int     x_revert;
411         int     y_revert;
412         int     (*get_pendown_state)(void);
413         int     (*init_platform_hw)(void);
414         int     (*ft5x0x_platform_sleep)(void);
415         int     (*ft5x0x_platform_wakeup)(void);
416         void    (*exit_platform_hw)(void);
417 };
418 #endif
419
420 #if defined (CONFIG_TOUCHSCREEN_SITRONIX_A720)
421 struct ft5x0x_platform_data{
422     u16     model;
423     int     (*get_pendown_state)(void);
424     int     (*init_platform_hw)(void);
425     int     (*ft5x0x_platform_sleep)(void);
426     int     (*ft5x0x_platform_wakeup)(void);
427     void    (*exit_platform_hw)(void);
428     int     (*direction_otation)(int *x ,int *y );
429 };
430 #endif
431
432 #if defined (CONFIG_TOUCHSCREEN_I30)
433 struct ft5306_platform_data {
434     int     rest_pin;
435     int     irq_pin;
436     int     (*get_pendown_state)(void);
437     int     (*init_platform_hw)(void);
438     int     (*platform_sleep)(void);
439     int     (*platform_wakeup)(void);
440     void    (*exit_platform_hw)(void);
441 };
442 #endif
443
444 #if defined (CONFIG_EETI_EGALAX)
445 struct eeti_egalax_platform_data {
446     u16     model;
447     int     (*get_pendown_state)(void);
448     int     (*init_platform_hw)(void);
449     int     (*eeti_egalax_platform_sleep)(void);
450     int     (*eeti_egalax_platform_wakeup)(void);
451     void    (*exit_platform_hw)(void);
452     int     standby_pin;
453     int     standby_value;
454     int     disp_on_pin;
455     int     disp_on_value;
456 };
457 #endif
458
459 struct ts_hw_data {
460         int reset_gpio;
461         int touch_en_gpio;
462         int (*init_platform_hw)(void);
463 };
464
465 #if defined(CONFIG_TOUCHSCREEN_BYD693X)
466 struct byd_platform_data {
467         u16     model;
468         int     pwr_pin;
469         int     int_pin;
470         int     rst_pin;
471         int     pwr_on_value;
472         int     *tp_flag;
473
474         uint16_t screen_max_x;
475         uint16_t screen_max_y;
476         u8 swap_xy :1;
477         u8 xpol :1;
478         u8 ypol :1;
479 };
480 #endif
481
482 struct codec_io_info {
483         char    iomux_name[50];
484         int     iomux_mode;
485 };
486
487 struct rt3261_platform_data {
488         unsigned int codec_en_gpio;
489         struct codec_io_info codec_en_gpio_info;
490         int (*io_init)(int, char *, int);
491         unsigned int spk_num;
492         unsigned int modem_input_mode;
493         unsigned int lout_to_modem_mode;
494         unsigned int spk_amplify;
495         unsigned int playback_if1_data_control;
496         unsigned int playback_if2_data_control;
497 };
498
499 struct rk610_codec_platform_data {
500         unsigned int spk_ctl_io;
501         int (*io_init)(void);
502         int boot_depop;//if found boot pop,set boot_depop 1 test
503         /*
504                 Some amplifiers enable a longer time.
505                 config after pa_enable_io delay pa_enable_time(ms)
506                 default = 0,preferably not more than 1000ms
507                 so value range is 0 - 1000.
508         */
509         unsigned int pa_enable_time;
510 };
511
512 struct rk_hdmi_platform_data {
513         int (*io_init)(void);
514 };
515 #define BOOT_MODE_NORMAL                0
516 #define BOOT_MODE_FACTORY2              1
517 #define BOOT_MODE_RECOVERY              2
518 #define BOOT_MODE_CHARGE                3
519 #define BOOT_MODE_POWER_TEST            4
520 #define BOOT_MODE_OFFMODE_CHARGING      5
521 #define BOOT_MODE_REBOOT                6
522 #define BOOT_MODE_PANIC                 7
523 #define BOOT_MODE_WATCHDOG              8
524 int board_boot_mode(void);
525
526 static inline const char *boot_mode_name(u32 mode)
527 {
528         switch (mode) {
529         case BOOT_MODE_NORMAL: return "NORMAL";
530         case BOOT_MODE_FACTORY2: return "FACTORY2";
531         case BOOT_MODE_RECOVERY: return "RECOVERY";
532         case BOOT_MODE_CHARGE: return "CHARGE";
533         case BOOT_MODE_POWER_TEST: return "POWER_TEST";
534         case BOOT_MODE_OFFMODE_CHARGING: return "OFFMODE_CHARGING";
535         case BOOT_MODE_REBOOT: return "REBOOT";
536         case BOOT_MODE_PANIC: return "PANIC";
537         case BOOT_MODE_WATCHDOG: return "WATCHDOG";
538         default: return "";
539         }
540 }
541
542 /* for USB detection */
543 #if defined(CONFIG_USB_GADGET) && !defined(CONFIG_RK_USB_DETECT_BY_OTG_BVALID)
544 int __init board_usb_detect_init(unsigned gpio);
545 #else
546 static int inline board_usb_detect_init(unsigned gpio) { return 0; }
547 #endif
548
549 #ifdef CONFIG_RK_EARLY_PRINTK
550 void __init rk29_setup_early_printk(void);
551 #else
552 static void inline rk29_setup_early_printk(void) {}
553 #endif
554
555 /* for wakeup Android */
556 void rk28_send_wakeup_key(void);
557
558 /* for reserved memory 
559  * function: board_mem_reserve_add 
560  * return value: start address of reserved memory */
561 phys_addr_t __init board_mem_reserve_add(char *name, size_t size);
562 void __init board_mem_reserved(void);
563
564 extern struct rk29_sdmmc_platform_data default_sdmmc0_data;
565 extern struct rk29_sdmmc_platform_data default_sdmmc1_data;
566
567 extern struct i2c_gpio_platform_data default_i2c_gpio_data;
568 extern struct rk29_vmac_platform_data board_vmac_data;
569
570 void __init board_clock_init(void);
571 void board_gpio_suspend(void);
572 void board_gpio_resume(void);
573 void __sramfunc board_pmu_suspend(void);
574 void __sramfunc board_pmu_resume(void);
575
576 /*
577  * For DDR frequency scaling setup. Board code something like this:
578  *
579  * This array _must_ be sorted in ascending frequency (without DDR_FREQ_*) order.
580  * static struct cpufreq_frequency_table dvfs_ddr_table[] = {
581  *      {.frequency = 200 * 1000 + DDR_FREQ_IDLE,       .index = xxxx * 1000},
582  *      {.frequency = 300 * 1000 + DDR_FREQ_VIDEO,      .index = xxxx * 1000},
583  *      {.frequency = 400 * 1000 + DDR_FREQ_NORMAL,     .index = xxxx * 1000},
584  *      {.frequency = CPUFREQ_TABLE_END},
585  *};
586  */
587 enum ddr_freq_mode {
588         DDR_FREQ_SUSPEND=(0x1<<0),      // when early suspend
589         DDR_FREQ_VIDEO=(0x1<<1),                // when video is playing
590         DDR_FREQ_VIDEO_LOW=(0x1<<2),                // when video is playing low
591         DDR_FREQ_DUALVIEW=(0x1<<3),     // when dual view,lcdc0 and lcdc1 open at the same time
592         DDR_FREQ_IDLE=(0x1<<4),         // when screen is idle
593         DDR_FREQ_NORMAL=(0x1<<8),      // default
594 };
595
596 #endif