Merge remote-tracking branch 'aosp/android-3.0' into develop-3.0
[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 struct rk30_i2c_platform_data {
22         char *name;
23         int bus_num;
24 #define I2C_RK29_ADAP   0
25 #define I2C_RK30_ADAP   1
26         int adap_type;
27         int is_div_from_arm;
28         u32 flags;
29         int scl_mode;
30         int sda_mode;
31         int (*io_init)(void);
32         int (*io_deinit)(void);
33 };
34
35 struct spi_cs_gpio {
36         const char *name;
37         unsigned int cs_gpio;
38         char *cs_iomux_name;
39         unsigned int cs_iomux_mode;
40 };
41
42 struct rk29xx_spi_platform_data {
43         int (*io_init)(struct spi_cs_gpio*, int);
44         int (*io_deinit)(struct spi_cs_gpio*, int);
45         int (*io_fix_leakage_bug)(void);
46         int (*io_resume_leakage_bug)(void);
47         struct spi_cs_gpio *chipselect_gpios;
48         u16 num_chipselect;
49 };
50
51 struct rk29_bl_info {
52         u32 pwm_id;
53         u32 bl_ref;
54         int (*io_init)(void);
55         int (*io_deinit)(void);
56         int (*pwm_suspend)(void);
57         int (*pwm_resume)(void);
58         int min_brightness;     /* 0 ~ 255 */
59         unsigned int delay_ms;  /* in milliseconds */
60         int pre_div;
61 };
62
63 struct rk29_io_t {
64     unsigned long io_addr;
65     unsigned long enable;
66     unsigned long disable;
67     int (*io_init)(void);
68 };
69
70 enum {
71         PMIC_TYPE_NONE =0,
72         PMIC_TYPE_WM8326 =1,
73         PMIC_TYPE_TPS65910 =2,
74         PMIC_TYPE_ACT8931 =3,
75         PMIC_TYPE_ACT8846 =3,
76         PMIC_TYPE_MAX,
77 };
78 extern __sramdata  int g_pmic_type;
79 #define pmic_is_wm8326()  (g_pmic_type == PMIC_TYPE_WM8326)
80 #define pmic_is_tps65910()  (g_pmic_type == PMIC_TYPE_TPS65910)
81 #define pmic_is_act8931()  (g_pmic_type == PMIC_TYPE_ACT8931)
82 #define pmic_is_act8846()  (g_pmic_type == PMIC_TYPE_ACT8846)
83
84 struct  pmu_info {
85         char            *name;
86         int             min_uv;
87         int             max_uv;   
88         int          suspend_vol;
89 };
90
91
92 struct rksdmmc_iomux {
93     char    *name;  //set the MACRO of gpio
94     int     fgpio;
95     int     fmux;
96 };
97
98 struct rksdmmc_gpio {
99     int     io;                             //set the address of gpio
100     char    name[64];   //
101     int     enable;  // disable = !enable   //set the default value,i.e,GPIO_HIGH or GPIO_LOW
102     struct rksdmmc_iomux  iomux;
103 };
104
105
106 struct rksdmmc_gpio_board {
107     struct rksdmmc_gpio   clk_gpio;
108     struct rksdmmc_gpio   cmd_gpio;
109     struct rksdmmc_gpio   data0_gpio;
110     struct rksdmmc_gpio   data1_gpio;    
111     struct rksdmmc_gpio   data2_gpio;
112     struct rksdmmc_gpio   data3_gpio;
113    
114     struct rksdmmc_gpio   detect_irq;    
115     struct rksdmmc_gpio   power_en_gpio;   
116     struct rksdmmc_gpio   write_prt;
117     struct rksdmmc_gpio   sdio_irq_gpio;
118 };
119
120
121 struct rksdmmc_gpio_wifi_moudle {
122     struct rksdmmc_gpio   power_n;  //PMU_EN  
123     struct rksdmmc_gpio   reset_n;  //SYSRET_B, DAIRST 
124     struct rksdmmc_gpio   vddio;    //power source
125     struct rksdmmc_gpio   bgf_int_b;
126     struct rksdmmc_gpio   wifi_int_b;
127     struct rksdmmc_gpio   gps_sync;
128     struct rksdmmc_gpio   ANTSEL2;  //pin5--ANTSEL2  
129     struct rksdmmc_gpio   ANTSEL3;  //pin6--ANTSEL3 
130     struct rksdmmc_gpio   GPS_LAN;  //pin33--GPS_LAN
131 };
132
133
134 struct rk29_sdmmc_platform_data {
135         unsigned int host_caps;
136         unsigned int host_ocr_avail;
137         unsigned int use_dma:1;
138         char dma_name[8];
139         int (*io_init)(void);
140         int (*io_deinit)(void);
141         void (*set_iomux)(int device_id, unsigned int bus_width);//added by xbw at 2011-10-13
142         int (*status)(struct device *);
143         int (*register_status_notify)(void (*callback)(int card_present, void *dev_id), void *dev_id);
144         int detect_irq;
145         int insert_card_level;
146     int power_en;
147         int power_en_level;
148         int enable_sd_wakeup;
149         int write_prt;
150         int write_prt_enalbe_level;
151         unsigned int sdio_INT_gpio; 
152         struct rksdmmc_gpio   det_pin_info;
153         int (*sd_vcc_reset)(void);
154 };
155
156 struct gsensor_platform_data {
157         u16 model;
158         u16 swap_xy;
159         u16 swap_xyz;
160         signed char orientation[9];
161         int (*get_pendown_state)(void);
162         int (*init_platform_hw)(void);
163         int (*gsensor_platform_sleep)(void);
164         int (*gsensor_platform_wakeup)(void);
165         void (*exit_platform_hw)(void);
166 };
167
168 struct akm8975_platform_data {
169         short m_layout[4][3][3];
170         char project_name[64];
171         int gpio_DRDY;
172 };
173
174 struct sensor_platform_data {
175         int type;
176         int irq;
177         int power_pin;
178         int reset_pin;
179         int irq_enable;         //if irq_enable=1 then use irq else use polling  
180         int poll_delay_ms;      //polling
181         int x_min;              //filter
182         int y_min;
183         int z_min;
184         int factory;
185         unsigned char address;
186         signed char orientation[9];
187         short m_layout[4][3][3];
188         char project_name[64];
189         int (*init_platform_hw)(void);
190         void (*exit_platform_hw)(void);
191         int (*power_on)(void);
192         int (*power_off)(void);
193 };
194
195 /* Platform data for the board id */
196 struct board_id_platform_data {
197         int gpio_pin[32];
198         int num_gpio;
199         int (*init_platform_hw)(void);  
200         int (*exit_platform_hw)(void);
201         int (*init_parameter)(int id);  
202 };
203
204 struct cm3217_platform_data {
205         int irq_pin;
206         int power_pin;
207         int (*init_platform_hw)(void);
208         void (*exit_platform_hw)(void);
209 };
210
211 struct irda_info {
212         u32 intr_pin;
213         int (*iomux_init)(void);
214         int (*iomux_deinit)(void);
215         int (*irda_pwr_ctl)(int en);
216 };
217
218 struct rk29_gpio_expander_info {
219         unsigned int gpio_num;
220         unsigned int pin_type;  //GPIO_IN or GPIO_OUT
221         unsigned int pin_value; //GPIO_HIGH or GPIO_LOW
222 };
223
224 /*vmac*/
225 struct rk29_vmac_platform_data {
226         int (*vmac_register_set)(void);
227         int (*rmii_io_init)(void);
228         int (*rmii_io_deinit)(void);
229         int (*rmii_power_control)(int enable);
230         int(*rmii_speed_switch)(int speed);
231 };
232 /* adc battery */
233 struct rk30_adc_battery_platform_data {
234         int (*io_init)(void);
235         int (*io_deinit)(void);
236         int (*is_dc_charging)(void);
237         int (*charging_ok)(void);
238
239         int (*is_usb_charging)(void);
240         int spport_usb_charging ;
241         int (*control_usb_charging)(int);
242
243         int usb_det_pin;
244         int dc_det_pin;
245         int batt_low_pin;
246         int charge_ok_pin;
247         int charge_set_pin;
248         int back_light_pin;
249
250         int ctrl_charge_led_pin;
251         int ctrl_charge_enable;
252         void (*ctrl_charge_led)(int);
253         
254         int dc_det_level;
255         int batt_low_level;
256         int charge_ok_level;
257         int charge_set_level;
258         int usb_det_level;
259         
260         int adc_channel;
261
262         int dc_det_pin_pull;    //pull up/down enable/disbale
263         int batt_low_pin_pull;
264         int charge_ok_pin_pull;
265         int charge_set_pin_pull;
266
267         int low_voltage_protection; // low voltage protection
268
269         int charging_sleep; // don't have lock,if chargeing_sleep = 0;else have lock
270         
271         int is_reboot_charging;
272         int save_capacity;  //save capacity to /data/bat_last_capacity.dat,  suggested use
273
274         int reference_voltage; // the rK2928 is 3300;RK3066 and rk29 are 2500;rk3066B is 1800;
275         int pull_up_res;      //divider resistance ,  pull-up resistor
276         int pull_down_res; //divider resistance , pull-down resistor
277
278         int time_down_discharge; //the time of capactiy drop 1% --discharge
279         int time_up_charge; //the time of capacity up 1% ---charging 
280
281         int  use_board_table;
282         int  table_size;
283         int  *discharge_table;
284         int  *charge_table;
285         int  *property_tabel;
286         int *board_batt_table;
287
288 };
289
290 #ifndef _LINUX_WLAN_PLAT_H_
291 struct wifi_platform_data {
292         int (*set_power)(int val);
293         int (*set_reset)(int val);
294         int (*set_carddetect)(int val);
295         void *(*mem_prealloc)(int section, unsigned long size);
296         int (*get_mac_addr)(unsigned char *buf);
297 };
298 #endif
299
300 struct goodix_platform_data {
301         int model ;
302         int rest_pin;
303         int irq_pin ;
304         int (*get_pendown_state)(void);
305         int (*init_platform_hw)(void);
306         int (*platform_sleep)(void);
307         int (*platform_wakeup)(void);
308         void (*exit_platform_hw)(void);
309 };
310
311 struct ct360_platform_data {
312         u16             model;
313         u16             x_max;
314         u16             y_max;
315         void    (*hw_init)(void);
316         void    (*shutdown)(int);
317 };
318
319 struct ft5606_platform_data {
320     int     (*get_pendown_state)(void);
321     int     (*init_platform_hw)(void);
322     int     (*platform_sleep)(void);
323     int     (*platform_wakeup)(void);
324     void    (*exit_platform_hw)(void);
325 };
326
327 #if defined(CONFIG_TOUCHSCREEN_FT5306) || defined(CONFIG_TOUCHSCREEN_FT5306_WPX2)
328 struct ft5x0x_platform_data{
329         u16     model;
330         int     max_x;
331         int     max_y;
332         int     key_min_x;
333         int     key_min_y;
334         int     xy_swap;
335         int     x_revert;
336         int     y_revert;
337         int     (*get_pendown_state)(void);
338         int     (*init_platform_hw)(void);
339         int     (*ft5x0x_platform_sleep)(void);
340         int     (*ft5x0x_platform_wakeup)(void);
341         void    (*exit_platform_hw)(void);
342 };
343 #endif
344
345 #if defined (CONFIG_TOUCHSCREEN_SITRONIX_A720)
346 struct ft5x0x_platform_data{
347     u16     model;
348     int     (*get_pendown_state)(void);
349     int     (*init_platform_hw)(void);
350     int     (*ft5x0x_platform_sleep)(void);
351     int     (*ft5x0x_platform_wakeup)(void);
352     void    (*exit_platform_hw)(void);
353     int     (*direction_otation)(int *x ,int *y );
354 };
355 #endif
356
357 #if defined (CONFIG_TOUCHSCREEN_I30)
358 struct ft5306_platform_data {
359     int     rest_pin;
360     int     irq_pin;
361     int     (*get_pendown_state)(void);
362     int     (*init_platform_hw)(void);
363     int     (*platform_sleep)(void);
364     int     (*platform_wakeup)(void);
365     void    (*exit_platform_hw)(void);
366 };
367 #endif
368
369 #if defined (CONFIG_EETI_EGALAX)
370 struct eeti_egalax_platform_data {
371     u16     model;
372     int     (*get_pendown_state)(void);
373     int     (*init_platform_hw)(void);
374     int     (*eeti_egalax_platform_sleep)(void);
375     int     (*eeti_egalax_platform_wakeup)(void);
376     void    (*exit_platform_hw)(void);
377     int     standby_pin;
378     int     standby_value;
379     int     disp_on_pin;
380     int     disp_on_value;
381 };
382 #endif
383
384 struct ts_hw_data {
385         int reset_gpio;
386         int touch_en_gpio;
387 };
388
389 #if defined(CONFIG_TOUCHSCREEN_BYD693X)
390 struct byd_platform_data {
391         u16     model;
392         int     pwr_pin;
393         int     int_pin;
394         int     rst_pin;
395         int     pwr_on_value;
396         int     *tp_flag;
397
398         uint16_t screen_max_x;
399         uint16_t screen_max_y;
400         u8 swap_xy :1;
401         u8 xpol :1;
402         u8 ypol :1;
403 };
404 #endif
405
406 struct codec_io_info {
407         char    iomux_name[50];
408         int     iomux_mode;
409 };
410
411 struct rt3261_platform_data {
412         unsigned int codec_en_gpio;
413         struct codec_io_info codec_en_gpio_info;
414         int (*io_init)(int, char *, int);
415         unsigned int spk_num;
416         unsigned int modem_input_mode;
417         unsigned int lout_to_modem_mode;
418         unsigned int spk_amplify;
419         unsigned int playback_if1_data_control;
420         unsigned int playback_if2_data_control;
421 };
422
423 struct rk610_codec_platform_data {
424         unsigned int spk_ctl_io;
425         int (*io_init)(void);
426         int boot_depop;//if found boot pop,set boot_depop 1 test
427 };
428
429 #define BOOT_MODE_NORMAL                0
430 #define BOOT_MODE_FACTORY2              1
431 #define BOOT_MODE_RECOVERY              2
432 #define BOOT_MODE_CHARGE                3
433 #define BOOT_MODE_POWER_TEST            4
434 #define BOOT_MODE_OFFMODE_CHARGING      5
435 #define BOOT_MODE_REBOOT                6
436 #define BOOT_MODE_PANIC                 7
437 int board_boot_mode(void);
438
439 /* for USB detection */
440 #ifdef CONFIG_USB_GADGET
441 int __init board_usb_detect_init(unsigned gpio);
442 #else
443 static int inline board_usb_detect_init(unsigned gpio) { return 0; }
444 #endif
445
446 #ifdef CONFIG_RK_EARLY_PRINTK
447 void __init rk29_setup_early_printk(void);
448 #else
449 static void inline rk29_setup_early_printk(void) {}
450 #endif
451
452 /* for wakeup Android */
453 void rk28_send_wakeup_key(void);
454
455 /* for reserved memory 
456  * function: board_mem_reserve_add 
457  * return value: start address of reserved memory */
458 phys_addr_t __init board_mem_reserve_add(char *name, size_t size);
459 void __init board_mem_reserved(void);
460
461 extern struct rk29_sdmmc_platform_data default_sdmmc0_data;
462 extern struct rk29_sdmmc_platform_data default_sdmmc1_data;
463
464 extern struct i2c_gpio_platform_data default_i2c_gpio_data;
465 extern struct rk29_vmac_platform_data board_vmac_data;
466
467 void __init board_clock_init(void);
468 void board_gpio_suspend(void);
469 void board_gpio_resume(void);
470 void __sramfunc board_pmu_suspend(void);
471 void __sramfunc board_pmu_resume(void);
472
473 /*
474  * For DDR frequency scaling setup. Board code something like this:
475  *
476  * This array _must_ be sorted in ascending frequency (without DDR_FREQ_*) order.
477  * 必须按频率(不必考虑DDR_FREQ_*)递增。
478  *static struct cpufreq_frequency_table dvfs_ddr_table[] = {
479  *      {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND,    .index = xxxx * 1000},
480  *      {.frequency = 200 * 1000 + DDR_FREQ_IDLE,       .index = xxxx * 1000},
481  *      {.frequency = 300 * 1000 + DDR_FREQ_VIDEO,      .index = xxxx * 1000},
482  *      {.frequency = 400 * 1000 + DDR_FREQ_NORMAL,     .index = xxxx * 1000},
483  *      {.frequency = CPUFREQ_TABLE_END},
484  *};
485  */
486 enum ddr_freq_mode {
487         DDR_FREQ_NORMAL = 1,    // default
488         DDR_FREQ_VIDEO,         // when video is playing
489         DDR_FREQ_IDLE,          // when screen is idle
490         DDR_FREQ_SUSPEND,       // when early suspend
491 };
492
493 #endif