f36402020510e5bb2e614f86151bac63dbd86ac6
[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 (*io_init)(void);
30         int (*io_deinit)(void);
31         int (*check_idle)(int);
32 };
33
34 struct spi_cs_gpio {
35         const char *name;
36         unsigned int cs_gpio;
37         char *cs_iomux_name;
38         unsigned int cs_iomux_mode;
39 };
40
41 struct rk29xx_spi_platform_data {
42         int (*io_init)(struct spi_cs_gpio*, int);
43         int (*io_deinit)(struct spi_cs_gpio*, int);
44         int (*io_fix_leakage_bug)(void);
45         int (*io_resume_leakage_bug)(void);
46         struct spi_cs_gpio *chipselect_gpios;
47         u16 num_chipselect;
48 };
49
50 struct rk29_bl_info {
51         u32 pwm_id;
52         u32 bl_ref;
53         int (*io_init)(void);
54         int (*io_deinit)(void);
55         int (*pwm_suspend)(void);
56         int (*pwm_resume)(void);
57         int min_brightness;     /* 0 ~ 255 */
58         unsigned int delay_ms;  /* in milliseconds */
59         int pre_div;
60 };
61
62 struct rk29_io_t {
63     unsigned long io_addr;
64     unsigned long enable;
65     unsigned long disable;
66     int (*io_init)(void);
67 };
68
69 enum {
70         PMIC_TYPE_NONE =0,
71         PMIC_TYPE_WM8326 =1,
72         PMIC_TYPE_TPS65910 =2,
73         PMIC_TYPE_ACT8931 =3,
74         PMIC_TYPE_MAX,
75 };
76 extern __sramdata  int g_pmic_type;
77 #define pmic_is_wm8326()  (g_pmic_type == PMIC_TYPE_WM8326)
78 #define pmic_is_tps65910()  (g_pmic_type == PMIC_TYPE_TPS65910)
79 #define pmic_is_act8931()  (g_pmic_type == PMIC_TYPE_ACT8931)
80
81 struct  pmu_info {
82         char            *name;
83         int             min_uv;
84         int             max_uv;   
85         int          suspend_vol;
86 };
87
88 struct rk29_fb_setting_info {
89         u8 data_num;
90         u8 vsync_en;
91         u8 den_en;
92         u8 mcu_fmk_en;
93         u8 disp_on_en;
94         u8 standby_en;
95 };
96
97 struct rk29fb_info {
98         u32 fb_id;
99         enum rk_disp_prop prop;         //display device property,like PRMRY,EXTEND
100         u32 mcu_fmk_pin;
101         struct rk29lcd_info *lcd_info;
102         int (*io_init)(struct rk29_fb_setting_info *fb_setting);
103         int (*io_deinit)(void);
104         int (*io_enable)(void);
105         int (*io_disable)(void);
106         void (*set_screen_info)(struct rk29fb_screen *screen, struct rk29lcd_info *lcd_info );
107 };
108
109 struct rksdmmc_iomux {
110     char    *name;  //set the MACRO of gpio
111     int     fgpio;
112     int     fmux;
113 };
114
115 struct rksdmmc_gpio {
116     int     io;                             //set the address of gpio
117     char    name[64];   //
118     int     enable;  // disable = !enable   //set the default value,i.e,GPIO_HIGH or GPIO_LOW
119     struct rksdmmc_iomux  iomux;
120 };
121
122
123 struct rksdmmc_gpio_board {
124     struct rksdmmc_gpio   clk_gpio;
125     struct rksdmmc_gpio   cmd_gpio;
126     struct rksdmmc_gpio   data0_gpio;
127     struct rksdmmc_gpio   data1_gpio;    
128     struct rksdmmc_gpio   data2_gpio;
129     struct rksdmmc_gpio   data3_gpio;
130    
131     struct rksdmmc_gpio   detect_irq;    
132     struct rksdmmc_gpio   power_en_gpio;   
133     struct rksdmmc_gpio   write_prt;
134     struct rksdmmc_gpio   sdio_irq_gpio;
135 };
136
137
138 struct rksdmmc_gpio_wifi_moudle {
139     struct rksdmmc_gpio   power_n;  //PMU_EN  
140     struct rksdmmc_gpio   reset_n;  //SYSRET_B, DAIRST 
141     struct rksdmmc_gpio   vddio;    //power source
142     struct rksdmmc_gpio   bgf_int_b;
143     struct rksdmmc_gpio   wifi_int_b;
144     struct rksdmmc_gpio   gps_sync;
145     struct rksdmmc_gpio   ANTSEL2;  //pin5--ANTSEL2  
146     struct rksdmmc_gpio   ANTSEL3;  //pin6--ANTSEL3 
147     struct rksdmmc_gpio   GPS_LAN;  //pin33--GPS_LAN
148 };
149
150
151 struct rk29_sdmmc_platform_data {
152         unsigned int host_caps;
153         unsigned int host_ocr_avail;
154         unsigned int use_dma:1;
155         char dma_name[8];
156         int (*io_init)(void);
157         int (*io_deinit)(void);
158         void (*set_iomux)(int device_id, unsigned int bus_width);//added by xbw at 2011-10-13
159         int (*status)(struct device *);
160         int (*register_status_notify)(void (*callback)(int card_present, void *dev_id), void *dev_id);
161         int detect_irq;
162         int insert_card_level;
163     int power_en;
164         int power_en_level;
165         int enable_sd_wakeup;
166         int write_prt;
167         int write_prt_enalbe_level;
168         unsigned int sdio_INT_gpio; 
169         struct rksdmmc_gpio   det_pin_info;
170         int (*sd_vcc_reset)(void);
171 };
172
173 struct gsensor_platform_data {
174         u16 model;
175         u16 swap_xy;
176         u16 swap_xyz;
177         signed char orientation[9];
178         int (*get_pendown_state)(void);
179         int (*init_platform_hw)(void);
180         int (*gsensor_platform_sleep)(void);
181         int (*gsensor_platform_wakeup)(void);
182         void (*exit_platform_hw)(void);
183 };
184
185 struct ft5606_platform_data {
186     int     (*get_pendown_state)(void);
187     int     (*init_platform_hw)(void);
188     int     (*platform_sleep)(void);
189     int     (*platform_wakeup)(void);
190     void    (*exit_platform_hw)(void);
191 };
192
193 struct akm8975_platform_data {
194         short m_layout[4][3][3];
195         char project_name[64];
196         int gpio_DRDY;
197 };
198
199 struct sensor_platform_data {
200         int type;
201         int irq;
202         int power_pin;
203         int reset_pin;
204         int irq_enable;         //if irq_enable=1 then use irq else use polling  
205         int poll_delay_ms;      //polling
206         int x_min;              //filter
207         int y_min;
208         int z_min;
209         int factory;
210         unsigned char address;
211         signed char orientation[9];
212         short m_layout[4][3][3];
213         char project_name[64];
214         int (*init_platform_hw)(void);
215         void (*exit_platform_hw)(void);
216         int (*power_on)(void);
217         int (*power_off)(void);
218 };
219
220 /* Platform data for the board id */
221 struct board_id_platform_data {
222         int gpio_pin[32];
223         int num_gpio;
224         int (*init_platform_hw)(void);  
225         int (*exit_platform_hw)(void);
226         int (*init_parameter)(int id);  
227 };
228
229
230
231 struct goodix_platform_data {
232         int model ;
233         int rest_pin;
234         int irq_pin ;
235         int (*get_pendown_state)(void);
236         int (*init_platform_hw)(void);
237         int (*platform_sleep)(void);
238         int (*platform_wakeup)(void);
239         void (*exit_platform_hw)(void);
240 };
241
242 struct ct360_platform_data {
243         u16             model;
244         u16             x_max;
245         u16             y_max;
246         void    (*hw_init)(void);
247         void    (*shutdown)(int);
248 };
249
250
251 struct cm3217_platform_data {
252         int irq_pin;
253         int power_pin;
254         int (*init_platform_hw)(void);
255         void (*exit_platform_hw)(void);
256 };
257
258 struct irda_info {
259         u32 intr_pin;
260         int (*iomux_init)(void);
261         int (*iomux_deinit)(void);
262         int (*irda_pwr_ctl)(int en);
263 };
264
265 struct rk29_gpio_expander_info {
266         unsigned int gpio_num;
267         unsigned int pin_type;  //GPIO_IN or GPIO_OUT
268         unsigned int pin_value; //GPIO_HIGH or GPIO_LOW
269 };
270
271 /*vmac*/
272 struct rk29_vmac_platform_data {
273         int (*vmac_register_set)(void);
274         int (*rmii_io_init)(void);
275         int (*rmii_io_deinit)(void);
276         int (*rmii_power_control)(int enable);
277         int(*rmii_speed_switch)(int speed);
278 };
279 /* adc battery */
280 struct rk30_adc_battery_platform_data {
281         int (*io_init)(void);
282         int (*io_deinit)(void);
283         int (*is_dc_charging)(void);
284         int (*charging_ok)(void);
285
286         int (*is_usb_charging)(void);
287         int spport_usb_charging ;
288         int (*control_usb_charging)(int);
289
290         int usb_det_pin;
291         int dc_det_pin;
292         int batt_low_pin;
293         int charge_ok_pin;
294         int charge_set_pin;
295         int back_light_pin;
296
297         int ctrl_charge_led_pin;
298         int ctrl_charge_enable;
299         void (*ctrl_charge_led)(int);
300         
301         int dc_det_level;
302         int batt_low_level;
303         int charge_ok_level;
304         int charge_set_level;
305         int usb_det_level;
306         
307         int adc_channel;
308
309         int dc_det_pin_pull;    //pull up/down enable/disbale
310         int batt_low_pin_pull;
311         int charge_ok_pin_pull;
312         int charge_set_pin_pull;
313
314         int low_voltage_protection; // low voltage protection
315
316         int charging_sleep; // don't have lock,if chargeing_sleep = 0;else have lock
317         
318         int is_reboot_charging;
319         int save_capacity;  //save capacity to /data/bat_last_capacity.dat,  suggested use
320
321         int reference_voltage; // the rK2928 is 3300;RK3066 and rk29 are 2500;rk3066B is 1800;
322         int pull_up_res;      //divider resistance ,  pull-up resistor
323         int pull_down_res; //divider resistance , pull-down resistor
324
325         int time_down_discharge; //the time of capactiy drop 1% --discharge
326         int time_up_charge; //the time of capacity up 1% ---charging 
327
328         int  use_board_table;
329         int  table_size;
330         int  *discharge_table;
331         int  *charge_table;
332         int  *property_tabel;
333         int *board_batt_table;
334
335 };
336
337
338 #define BOOT_MODE_NORMAL                0
339 #define BOOT_MODE_FACTORY2              1
340 #define BOOT_MODE_RECOVERY              2
341 #define BOOT_MODE_CHARGE                3
342 #define BOOT_MODE_POWER_TEST            4
343 #define BOOT_MODE_OFFMODE_CHARGING      5
344 #define BOOT_MODE_REBOOT                6
345 #define BOOT_MODE_PANIC                 7
346 int board_boot_mode(void);
347
348 /* for USB detection */
349 #ifdef CONFIG_USB_GADGET
350 int __init board_usb_detect_init(unsigned gpio);
351 #else
352 static int inline board_usb_detect_init(unsigned gpio) { return 0; }
353 #endif
354
355 #ifdef CONFIG_RK_EARLY_PRINTK
356 void __init rk29_setup_early_printk(void);
357 #else
358 static void inline rk29_setup_early_printk(void) {}
359 #endif
360
361 /* for wakeup Android */
362 void rk28_send_wakeup_key(void);
363
364 /* for reserved memory 
365  * function: board_mem_reserve_add 
366  * return value: start address of reserved memory */
367 phys_addr_t __init board_mem_reserve_add(char *name, size_t size);
368 void __init board_mem_reserved(void);
369
370 /*
371  * For DDR frequency scaling setup. Board code something like this:
372  *
373  * This array _must_ be sorted in ascending frequency (without DDR_FREQ_*) order.
374  * 必须按频率(不必考虑DDR_FREQ_*)递增。
375  *static struct cpufreq_frequency_table dvfs_ddr_table[] = {
376  *      {.frequency = 200 * 1000 + DDR_FREQ_SUSPEND,    .index = xxxx * 1000},
377  *      {.frequency = 200 * 1000 + DDR_FREQ_IDLE,       .index = xxxx * 1000},
378  *      {.frequency = 300 * 1000 + DDR_FREQ_VIDEO,      .index = xxxx * 1000},
379  *      {.frequency = 400 * 1000 + DDR_FREQ_NORMAL,     .index = xxxx * 1000},
380  *      {.frequency = CPUFREQ_TABLE_END},
381  *};
382  */
383 enum ddr_freq_mode {
384         DDR_FREQ_NORMAL = 1,    // default
385         DDR_FREQ_VIDEO,         // when video is playing
386         DDR_FREQ_IDLE,          // when screen is idle
387         DDR_FREQ_SUSPEND,       // when early suspend
388 };
389
390 #endif