adapt all kind of board
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rk2818 / include / mach / board.h
1 /* arch/arm/mach-rk2818/include/mach/board.h
2  *
3  * Copyright (C) 2010 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 #ifndef __ASM_ARCH_RK2818_BOARD_H
17 #define __ASM_ARCH_RK2818_BOARD_H
18
19 #include <linux/types.h>
20 #include <linux/timer.h>
21 #include <linux/notifier.h>
22
23
24
25 #define INVALID_GPIO        -1
26
27
28 struct rk2818_io_cfg {
29         int (*io_init)(void *);
30         int (*io_deinit)(void *);
31 };
32
33 /* platform device data structures */
34 struct platform_device;
35 struct i2c_client;
36 struct rk2818_sdmmc_platform_data {
37         unsigned int host_caps;
38         unsigned int host_ocr_avail;
39         unsigned int use_dma:1;
40         unsigned int no_detect:1;
41         char dma_name[8];
42         int (*io_init)(void);
43         int (*io_deinit)(void);
44 };
45
46 struct rk2818_i2c_spi_data {
47         int     bus_num;        
48         unsigned int    flags;     
49         unsigned int    slave_addr; 
50         unsigned long   scl_rate;   
51 };
52 struct rk2818_i2c_platform_data {
53         int     bus_num;        
54         unsigned int    flags;     
55         unsigned int    slave_addr; 
56         unsigned long   scl_rate;   
57 #define I2C_MODE_IRQ    0
58 #define I2C_MODE_POLL   1
59         unsigned int    mode:1;
60         int (*io_init)(void);
61         int (*io_deinit)(void);
62 };
63
64 struct rk2818_fb_gpio{
65     u32 display_on;
66     u32 lcd_standby;
67     u32 mcu_fmk_pin;
68 };
69
70 struct rk2818_fb_iomux{
71     char *data16;
72     char *data18;
73     char *data24;
74     char *den;
75     char *vsync;
76     char *mcu_fmk;
77 };
78
79 struct rk2818_fb_mach_info {
80     struct rk2818_fb_gpio *gpio;
81     struct rk2818_fb_iomux *iomux;
82 };
83
84 struct rk2818_bl_info{
85     u32 pwm_id;
86     u32 bl_ref;
87     int (*io_init)(void);
88     int (*io_deinit)(void);
89     struct timer_list timer;  
90     struct notifier_block freq_transition;
91 };
92
93 struct rk2818_gpio_expander_info {
94         unsigned int gpio_num;// ³õʼ»¯µÄpin ½Åºê¶¨Òå È磺RK2818_PIN_PI0
95         unsigned int pin_type;//³õʼ»¯µÄpin ÎªÊäÈëpin»¹ÊÇÊä³öpin È磺GPIO_IN
96         unsigned int pin_value;//Èç¹ûΪ output pin ÉèÖõçƽ£¬È磺GPIO_HIGH
97 };
98
99
100 struct pca9554_platform_data {
101         /*  the first extern gpio number in all of gpio groups */
102         unsigned gpio_base;
103         unsigned        gpio_pin_num;
104         /*  the first gpio irq  number in all of irq source */
105
106         unsigned gpio_irq_start;
107         unsigned irq_pin_num;        //ÖжϵĸöÊý
108         unsigned    pca9954_irq_pin;        //À©Õ¹IOµÄÖжϹÒÔÚÄĸögpio
109         /* initial polarity inversion setting */
110         uint16_t        invert;
111         struct rk2818_gpio_expander_info  *settinginfo;
112         int  settinginfolen;
113         void            *context;       /* param to setup/teardown */
114
115         int             (*setup)(struct i2c_client *client,unsigned gpio, unsigned ngpio,void *context);
116         int             (*teardown)(struct i2c_client *client,unsigned gpio, unsigned ngpio,void *context);
117         char            **names;
118 };
119
120 /*lcd*/
121 struct lcd_td043mgea1_data{
122     u32 pin_txd;
123     u32 pin_clk;
124     u32 pin_cs;
125     void (*screen_set_iomux)(u8 enable);
126 };
127
128 /*battery*/
129 struct rk2818_battery_platform_data {
130         int (*io_init)(void);
131         int (*io_deinit)(void);
132         int charge_ok_pin;
133 };
134
135 /*g_sensor*/
136 struct rk2818_gs_platform_data {
137         int (*io_init)(void);
138         int (*io_deinit)(void);
139         int gsensor_irq_pin;
140 };
141
142 /*serial*/
143 struct rk2818_serial_platform_data {
144         int (*io_init)(void);
145         int (*io_deinit)(void);
146 };
147
148 /*i2s*/
149 struct rk2818_i2s_platform_data {
150         int (*io_init)(void);
151         int (*io_deinit)(void);
152 };
153
154 /*spi*/
155 struct spi_cs_gpio {
156         const char *name;
157         unsigned int cs_gpio;
158 };
159
160 struct rk2818_spi_platform_data {
161         int (*io_init)(void);
162         int (*io_deinit)(void);
163         struct spi_cs_gpio *chipselect_gpios;   
164         u16 num_chipselect;
165 };
166
167 //ROCKCHIP AD KEY CODE ,for demo board
168 //      key             --->    EV      
169 #define AD2KEY1                 114   ///VOLUME_DOWN
170 #define AD2KEY2                 115   ///VOLUME_UP
171 #define AD2KEY3                 59    ///MENU
172 #define AD2KEY4                 102   ///HOME
173 #define AD2KEY5                 158   ///BACK
174 #define AD2KEY6                 61    ///CALL
175 #define AD2KEY7                 127   ///SEARCH
176 #define ENDCALL                                 62
177 #define KEYSTART                                28                      //ENTER
178 #define KEYMENU                                 AD2KEY6         ///CALL
179 #define KEY_PLAY_SHORT_PRESS    KEYSTART        //code for short press the play key
180 #define KEY_PLAY_LONG_PRESS             ENDCALL         //code for long press the play key
181
182 //ADC Registers
183 typedef  struct tagADC_keyst
184 {
185         unsigned int adc_value;
186         unsigned int adc_keycode;
187 }ADC_keyst,*pADC_keyst;
188
189 /*ad key*/
190 struct adc_key_data{
191     u32 pin_playon;
192     u32 playon_level;
193     u32 adc_empty;
194     u32 adc_invalid;
195     u32 adc_drift;
196     u32 adc_chn;
197     ADC_keyst * adc_key_table;
198     unsigned char *initKeyCode;
199     u32 adc_key_cnt;
200 };
201
202 struct rk2818_adckey_platform_data {
203         int (*io_init)(void);
204         int (*io_deinit)(void);
205         struct adc_key_data *adc_key;
206 };
207
208 /* common init routines for use by arch/arm/mach-msm/board-*.c */
209 void __init rk2818_add_devices(void);
210 void __init rk2818_map_common_io(void);
211 void __init rk2818_init_irq(void);
212 void __init rk2818_init_gpio(void);
213 void __init rk2818_clock_init(void);
214
215 #endif