45bd521e5de91640c853382dc764135fa6f2796f
[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         int (*init_platform_hw)(void);  
236         int (*exit_platform_hw)(void);
237         int (*init_parameter)(int id);  
238 };
239
240 struct ft5506_platform_data {
241     int     (*get_pendown_state)(void);
242     int     (*init_platform_hw)(void);
243     int     (*platform_sleep)(void);
244     int     (*platform_wakeup)(void);
245     void    (*exit_platform_hw)(void);
246 };
247 struct cm3217_platform_data {
248         int irq_pin;
249         int power_pin;
250         int (*init_platform_hw)(void);
251         void (*exit_platform_hw)(void);
252 };
253
254 struct irda_info {
255         u32 intr_pin;
256         int (*iomux_init)(void);
257         int (*iomux_deinit)(void);
258         int (*irda_pwr_ctl)(int en);
259 };
260
261 struct rk29_gpio_expander_info {
262         unsigned int gpio_num;
263         unsigned int pin_type;  //GPIO_IN or GPIO_OUT
264         unsigned int pin_value; //GPIO_HIGH or GPIO_LOW
265 };
266
267 /*vmac*/
268 struct rk29_vmac_platform_data {
269         int (*vmac_register_set)(void);
270         int (*rmii_io_init)(void);
271         int (*rmii_io_deinit)(void);
272         int (*rmii_power_control)(int enable);
273         int(*rmii_speed_switch)(int speed);
274 };
275 /* adc battery */
276 #define LCDC_ON 0x0001
277 #define BACKLIGHT_ON 0x0002
278 struct rk30_adc_battery_platform_data {
279         int (*io_init)(void);
280         int (*io_deinit)(void);
281         int (*is_dc_charging)(void);
282         int (*charging_ok)(void);
283
284         int (*is_usb_charging)(void);
285         int spport_usb_charging ;
286         int (*control_usb_charging)(int);
287
288         int usb_det_pin;
289         int dc_det_pin;
290         int batt_low_pin;
291         int charge_ok_pin;
292         int charge_set_pin;
293         int back_light_pin;
294
295         int ctrl_charge_led_pin;
296         int ctrl_charge_enable;
297         void (*ctrl_charge_led)(int);
298         
299         int dc_det_level;
300         int batt_low_level;
301         int charge_ok_level;
302         int charge_set_level;
303         int usb_det_level;
304         
305         int adc_channel;
306
307         int dc_det_pin_pull;    //pull up/down enable/disbale
308         int batt_low_pin_pull;
309         int charge_ok_pin_pull;
310         int charge_set_pin_pull;
311
312         int low_voltage_protection; // low voltage protection
313
314         int charging_sleep; // don't have lock,if chargeing_sleep = 0;else have lock
315         
316         int is_reboot_charging;
317         int save_capacity;  //save capacity to /data/bat_last_capacity.dat,  suggested use
318
319         int reference_voltage; // the rK2928 is 3300;RK3066 and rk29 are 2500;rk3066B is 1800;
320         int pull_up_res;      //divider resistance ,  pull-up resistor
321         int pull_down_res; //divider resistance , pull-down resistor
322
323         int time_down_discharge; //the time of capactiy drop 1% --discharge
324         int time_up_charge; //the time of capacity up 1% ---charging 
325
326         int  use_board_table;
327         int  table_size;
328         int  *discharge_table;
329         int  *charge_table;
330         int  *property_tabel;
331         int *board_batt_table;
332
333 };
334
335 #ifndef _LINUX_WLAN_PLAT_H_
336 struct wifi_platform_data {
337         int (*set_power)(int val);
338         int (*set_reset)(int val);
339         int (*set_carddetect)(int val);
340         void *(*mem_prealloc)(int section, unsigned long size);
341         int (*get_mac_addr)(unsigned char *buf);
342 };
343 #endif
344
345 struct goodix_platform_data {
346         int model ;
347         int rest_pin;
348         int irq_pin ;
349         int (*get_pendown_state)(void);
350         int (*init_platform_hw)(void);
351         int (*platform_sleep)(void);
352         int (*platform_wakeup)(void);
353         void (*exit_platform_hw)(void);
354 };
355
356 struct ct360_platform_data {
357         u16             model;
358         u16             x_max;
359         u16             y_max;
360         void    (*hw_init)(void);
361         void    (*shutdown)(int);
362 };
363
364 struct ft5606_platform_data {
365     int     (*get_pendown_state)(void);
366     int     (*init_platform_hw)(void);
367     int     (*platform_sleep)(void);
368     int     (*platform_wakeup)(void);
369     void    (*exit_platform_hw)(void);
370 };
371
372 #if defined(CONFIG_TOUCHSCREEN_FT5306) || defined(CONFIG_TOUCHSCREEN_FT5306_WPX2)
373 struct ft5x0x_platform_data{
374         u16     model;
375         int     max_x;
376         int     max_y;
377         int     key_min_x;
378         int     key_min_y;
379         int     xy_swap;
380         int     x_revert;
381         int     y_revert;
382         int     (*get_pendown_state)(void);
383         int     (*init_platform_hw)(void);
384         int     (*ft5x0x_platform_sleep)(void);
385         int     (*ft5x0x_platform_wakeup)(void);
386         void    (*exit_platform_hw)(void);
387 };
388 #endif
389
390 #if defined (CONFIG_TOUCHSCREEN_SITRONIX_A720)
391 struct ft5x0x_platform_data{
392     u16     model;
393     int     (*get_pendown_state)(void);
394     int     (*init_platform_hw)(void);
395     int     (*ft5x0x_platform_sleep)(void);
396     int     (*ft5x0x_platform_wakeup)(void);
397     void    (*exit_platform_hw)(void);
398     int     (*direction_otation)(int *x ,int *y );
399 };
400 #endif
401
402 #if defined (CONFIG_TOUCHSCREEN_I30)
403 struct ft5306_platform_data {
404     int     rest_pin;
405     int     irq_pin;
406     int     (*get_pendown_state)(void);
407     int     (*init_platform_hw)(void);
408     int     (*platform_sleep)(void);
409     int     (*platform_wakeup)(void);
410     void    (*exit_platform_hw)(void);
411 };
412 #endif
413
414 #if defined (CONFIG_EETI_EGALAX)
415 struct eeti_egalax_platform_data {
416     u16     model;
417     int     (*get_pendown_state)(void);
418     int     (*init_platform_hw)(void);
419     int     (*eeti_egalax_platform_sleep)(void);
420     int     (*eeti_egalax_platform_wakeup)(void);
421     void    (*exit_platform_hw)(void);
422     int     standby_pin;
423     int     standby_value;
424     int     disp_on_pin;
425     int     disp_on_value;
426 };
427 #endif
428
429 struct ts_hw_data {
430         int reset_gpio;
431         int touch_en_gpio;
432         int (*init_platform_hw)(void);
433 };
434
435 #if defined(CONFIG_TOUCHSCREEN_BYD693X)
436 struct byd_platform_data {
437         u16     model;
438         int     pwr_pin;
439         int     int_pin;
440         int     rst_pin;
441         int     pwr_on_value;
442         int     *tp_flag;
443
444         uint16_t screen_max_x;
445         uint16_t screen_max_y;
446         u8 swap_xy :1;
447         u8 xpol :1;
448         u8 ypol :1;
449 };
450 #endif
451
452 struct codec_io_info {
453         char    iomux_name[50];
454         int     iomux_mode;
455 };
456
457 struct rt3261_platform_data {
458         unsigned int codec_en_gpio;
459         struct codec_io_info codec_en_gpio_info;
460         int (*io_init)(int, char *, int);
461         unsigned int spk_num;
462         unsigned int modem_input_mode;
463         unsigned int lout_to_modem_mode;
464         unsigned int spk_amplify;
465         unsigned int playback_if1_data_control;
466         unsigned int playback_if2_data_control;
467 };
468
469 struct rk610_codec_platform_data {
470         unsigned int spk_ctl_io;
471         int (*io_init)(void);
472         int boot_depop;//if found boot pop,set boot_depop 1 test
473         /*
474                 Some amplifiers enable a longer time.
475                 config after pa_enable_io delay pa_enable_time(ms)
476                 default = 0,preferably not more than 1000ms
477                 so value range is 0 - 1000.
478         */
479         unsigned int pa_enable_time;
480 };
481
482 struct rk_hdmi_platform_data {
483         int (*io_init)(void);
484 };
485 #define BOOT_MODE_NORMAL                0
486 #define BOOT_MODE_FACTORY2              1
487 #define BOOT_MODE_RECOVERY              2
488 #define BOOT_MODE_CHARGE                3
489 #define BOOT_MODE_POWER_TEST            4
490 #define BOOT_MODE_OFFMODE_CHARGING      5
491 #define BOOT_MODE_REBOOT                6
492 #define BOOT_MODE_PANIC                 7
493 #define BOOT_MODE_WATCHDOG              8
494 int board_boot_mode(void);
495
496 /* for USB detection */
497 #if defined(CONFIG_USB_GADGET) && !defined(CONFIG_RK_USB_DETECT_BY_OTG_BVALID)
498 int __init board_usb_detect_init(unsigned gpio);
499 #else
500 static int inline board_usb_detect_init(unsigned gpio) { return 0; }
501 #endif
502
503 #ifdef CONFIG_RK_EARLY_PRINTK
504 void __init rk29_setup_early_printk(void);
505 #else
506 static void inline rk29_setup_early_printk(void) {}
507 #endif
508
509 /* for wakeup Android */
510 void rk28_send_wakeup_key(void);
511
512 /* for reserved memory 
513  * function: board_mem_reserve_add 
514  * return value: start address of reserved memory */
515 phys_addr_t __init board_mem_reserve_add(char *name, size_t size);
516 void __init board_mem_reserved(void);
517
518 extern struct rk29_sdmmc_platform_data default_sdmmc0_data;
519 extern struct rk29_sdmmc_platform_data default_sdmmc1_data;
520
521 extern struct i2c_gpio_platform_data default_i2c_gpio_data;
522 extern struct rk29_vmac_platform_data board_vmac_data;
523
524 void __init board_clock_init(void);
525 void board_gpio_suspend(void);
526 void board_gpio_resume(void);
527 void __sramfunc board_pmu_suspend(void);
528 void __sramfunc board_pmu_resume(void);
529
530 /*
531  * For DDR frequency scaling setup. Board code something like this:
532  *
533  * This array _must_ be sorted in ascending frequency (without DDR_FREQ_*) order.
534  * 必须按频率(不必考虑DDR_FREQ_*)递增。
535  *static struct cpufreq_frequency_table dvfs_ddr_table[] = {
536  *      {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND,    .index = xxxx * 1000},
537  *      {.frequency = 200 * 1000 + DDR_FREQ_IDLE,       .index = xxxx * 1000},
538  *      {.frequency = 300 * 1000 + DDR_FREQ_VIDEO,      .index = xxxx * 1000},
539  *      {.frequency = 400 * 1000 + DDR_FREQ_NORMAL,     .index = xxxx * 1000},
540  *      {.frequency = CPUFREQ_TABLE_END},
541  *};
542  */
543 enum ddr_freq_mode {
544         DDR_FREQ_NORMAL = 1,    // default
545         DDR_FREQ_VIDEO,         // when video is playing
546        DDR_FREQ_DUALVIEW,     // when dual view,lcdc0 and lcdc1 open at the same time
547         DDR_FREQ_IDLE,          // when screen is idle
548         DDR_FREQ_SUSPEND,       // when early suspend
549 };
550
551 #endif