]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-3430sdp.c
19549d7f8726fcb1d15eb165b55bc0ed1cc76281
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-3430sdp.c
1 /*
2  * linux/arch/arm/mach-omap2/board-3430sdp.c
3  *
4  * Copyright (C) 2007 Texas Instruments
5  *
6  * Modified from mach-omap2/board-generic.c
7  *
8  * Initial code: Syed Mohammed Khasim
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/input.h>
20 #include <linux/workqueue.h>
21 #include <linux/err.h>
22 #include <linux/clk.h>
23 #include <linux/i2c/twl4030.h>
24 #include <linux/spi/spi.h>
25 #include <linux/spi/ads7846.h>
26
27 #include <asm/hardware.h>
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
31
32 #include <asm/arch/mcspi.h>
33 #include <asm/arch/gpio.h>
34 #include <asm/arch/mux.h>
35 #include <asm/arch/board.h>
36 #include <asm/arch/usb-musb.h>
37 #include <asm/arch/usb-ehci.h>
38 #include <asm/arch/hsmmc.h>
39 #include <asm/arch/common.h>
40 #include <asm/arch/keypad.h>
41 #include <asm/arch/dma.h>
42 #include <asm/arch/gpmc.h>
43
44 #include <asm/io.h>
45 #include <asm/delay.h>
46
47 #define SDP3430_SMC91X_CS       3
48
49 #define ENABLE_VAUX3_DEDICATED  0x03
50 #define ENABLE_VAUX3_DEV_GRP    0x20
51
52
53 static struct resource sdp3430_smc91x_resources[] = {
54         [0] = {
55                 .start  = OMAP34XX_ETHR_START,
56                 .end    = OMAP34XX_ETHR_START + SZ_4K,
57                 .flags  = IORESOURCE_MEM,
58         },
59         [1] = {
60                 .start  = 0,
61                 .end    = 0,
62                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
63         },
64 };
65
66 static struct platform_device sdp3430_smc91x_device = {
67         .name           = "smc91x",
68         .id             = -1,
69         .num_resources  = ARRAY_SIZE(sdp3430_smc91x_resources),
70         .resource       = sdp3430_smc91x_resources,
71 };
72
73 static int sdp3430_keymap[] = {
74         KEY(0, 0, KEY_LEFT),
75         KEY(0, 1, KEY_RIGHT),
76         KEY(0, 2, KEY_A),
77         KEY(0, 3, KEY_B),
78         KEY(0, 4, KEY_C),
79         KEY(1, 0, KEY_DOWN),
80         KEY(1, 1, KEY_UP),
81         KEY(1, 2, KEY_E),
82         KEY(1, 3, KEY_F),
83         KEY(1, 4, KEY_G),
84         KEY(2, 0, KEY_ENTER),
85         KEY(2, 1, KEY_I),
86         KEY(2, 2, KEY_J),
87         KEY(2, 3, KEY_K),
88         KEY(2, 4, KEY_3),
89         KEY(3, 0, KEY_M),
90         KEY(3, 1, KEY_N),
91         KEY(3, 2, KEY_O),
92         KEY(3, 3, KEY_P),
93         KEY(3, 4, KEY_Q),
94         KEY(4, 0, KEY_R),
95         KEY(4, 1, KEY_4),
96         KEY(4, 2, KEY_T),
97         KEY(4, 3, KEY_U),
98         KEY(4, 4, KEY_D),
99         KEY(5, 0, KEY_V),
100         KEY(5, 1, KEY_W),
101         KEY(5, 2, KEY_L),
102         KEY(5, 3, KEY_S),
103         KEY(5, 4, KEY_H),
104         0
105 };
106
107 static struct omap_kp_platform_data sdp3430_kp_data = {
108         .rows           = 5,
109         .cols           = 6,
110         .keymap         = sdp3430_keymap,
111         .keymapsize     = ARRAY_SIZE(sdp3430_keymap),
112         .rep            = 1,
113 };
114
115 static struct platform_device sdp3430_kp_device = {
116         .name           = "omap_twl4030keypad",
117         .id             = -1,
118         .dev            = {
119                 .platform_data  = &sdp3430_kp_data,
120         },
121 };
122
123 static int ts_gpio;
124
125 /**
126  * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
127  *
128  * @return - void. If request gpio fails then Flag KERN_ERR.
129  */
130 static void ads7846_dev_init(void)
131 {
132         if (omap_request_gpio(ts_gpio) < 0) {
133                 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
134                 return;
135         }
136
137         omap_set_gpio_direction(ts_gpio, 1);
138
139         omap_set_gpio_debounce(ts_gpio, 1);
140         omap_set_gpio_debounce_time(ts_gpio, 0xa);
141 }
142
143 static int ads7846_get_pendown_state(void)
144 {
145         return !omap_get_gpio_datain(ts_gpio);
146 }
147
148 /*
149  * This enable(1)/disable(0) the voltage for TS: uses twl4030 calls
150  */
151 static int ads7846_vaux_control(int vaux_cntrl)
152 {
153         int ret = 0;
154
155 #ifdef CONFIG_TWL4030_CORE
156         /* check for return value of ldo_use: if success it returns 0 */
157         if (vaux_cntrl == VAUX_ENABLE) {
158                 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
159                         ENABLE_VAUX3_DEDICATED, TWL4030_VAUX3_DEDICATED))
160                         return -EIO;
161                 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
162                         ENABLE_VAUX3_DEV_GRP, TWL4030_VAUX3_DEV_GRP))
163                         return -EIO;
164         } else if (vaux_cntrl == VAUX_DISABLE) {
165                 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
166                         0x00, TWL4030_VAUX3_DEDICATED))
167                         return -EIO;
168                 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
169                         0x00, TWL4030_VAUX3_DEV_GRP))
170                         return -EIO;
171         }
172 #else
173         ret = -EIO;
174 #endif
175         return ret;
176 }
177
178 static struct ads7846_platform_data tsc2046_config __initdata = {
179         .get_pendown_state      = ads7846_get_pendown_state,
180         .keep_vref_on           = 1,
181         .vaux_control           = ads7846_vaux_control,
182 };
183
184
185 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
186         .turbo_mode     = 0,
187         .single_channel = 1,  /* 0: slave, 1: master */
188 };
189
190 static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
191         [0] = {
192                 /*
193                  * TSC2046 operates at a max freqency of 2MHz, so
194                  * operate slightly below at 1.5MHz
195                  */
196                 .modalias               = "ads7846",
197                 .bus_num                = 1,
198                 .chip_select            = 0,
199                 .max_speed_hz           = 1500000,
200                 .controller_data        = &tsc2046_mcspi_config,
201                 .irq                    = 0,
202                 .platform_data          = &tsc2046_config,
203         },
204 };
205
206 static struct platform_device sdp3430_lcd_device = {
207         .name           = "sdp2430_lcd",
208         .id             = -1,
209 };
210
211 static struct platform_device *sdp3430_devices[] __initdata = {
212         &sdp3430_smc91x_device,
213         &sdp3430_kp_device,
214         &sdp3430_lcd_device,
215 };
216
217 static inline void __init sdp3430_init_smc91x(void)
218 {
219         int eth_cs;
220         unsigned long cs_mem_base;
221         int eth_gpio = 0;
222
223         eth_cs = SDP3430_SMC91X_CS;
224
225         if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
226                 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
227                 return;
228         }
229
230         sdp3430_smc91x_resources[0].start = cs_mem_base + 0x0;
231         sdp3430_smc91x_resources[0].end   = cs_mem_base + 0xf;
232         udelay(100);
233
234         if (is_sil_rev_greater_than(OMAP3430_REV_ES1_0))
235                 eth_gpio = OMAP34XX_ETHR_GPIO_IRQ_SDPV2;
236         else
237                 eth_gpio = OMAP34XX_ETHR_GPIO_IRQ_SDPV1;
238
239         sdp3430_smc91x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio);
240
241         if (omap_request_gpio(eth_gpio) < 0) {
242                 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
243                         eth_gpio);
244                 return;
245         }
246         omap_set_gpio_direction(eth_gpio, 1);
247 }
248
249 static void __init omap_3430sdp_init_irq(void)
250 {
251         omap2_init_common_hw(NULL);
252         omap_init_irq();
253         omap_gpio_init();
254         sdp3430_init_smc91x();
255 }
256
257 static struct omap_uart_config sdp3430_uart_config __initdata = {
258         .enabled_uarts  = ((1 << 0) | (1 << 1) | (1 << 2)),
259 };
260
261 static struct omap_lcd_config sdp3430_lcd_config __initdata = {
262         .ctrl_name      = "internal",
263 };
264
265 static struct omap_mmc_config sdp3430_mmc_config __initdata = {
266         .mmc [0] = {
267                 .enabled        = 1,
268                 .wire4          = 1,
269         },
270 };
271
272 static struct omap_board_config_kernel sdp3430_config[] __initdata = {
273         { OMAP_TAG_UART,        &sdp3430_uart_config },
274         {OMAP_TAG_LCD,          &sdp3430_lcd_config},
275         {OMAP_TAG_MMC,          &sdp3430_mmc_config },
276 };
277
278 static int __init omap3430_i2c_init(void)
279 {
280         omap_register_i2c_bus(1, 2600, NULL, 0);
281         omap_register_i2c_bus(2, 400, NULL, 0);
282         omap_register_i2c_bus(3, 400, NULL, 0);
283         return 0;
284 }
285
286 extern void __init sdp3430_flash_init(void);
287
288 static void __init omap_3430sdp_init(void)
289 {
290         platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
291         omap_board_config = sdp3430_config;
292         omap_board_config_size = ARRAY_SIZE(sdp3430_config);
293         if (is_sil_rev_greater_than(OMAP3430_REV_ES1_0))
294                 ts_gpio = OMAP34XX_TS_GPIO_IRQ_SDPV2;
295         else
296                 ts_gpio = OMAP34XX_TS_GPIO_IRQ_SDPV1;
297         sdp3430_spi_board_info[0].irq = OMAP_GPIO_IRQ(ts_gpio);
298         spi_register_board_info(sdp3430_spi_board_info,
299                                 ARRAY_SIZE(sdp3430_spi_board_info));
300         ads7846_dev_init();
301         sdp3430_flash_init();
302         omap_serial_init();
303         usb_musb_init();
304         usb_ehci_init();
305         hsmmc_init();
306 }
307
308 static void __init omap_3430sdp_map_io(void)
309 {
310         omap2_set_globals_343x();
311         omap2_map_common_io();
312 }
313 arch_initcall(omap3430_i2c_init);
314
315 MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
316         /* Maintainer: Syed Khasim - Texas Instruments Inc */
317         .phys_io        = 0x48000000,
318         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
319         .boot_params    = 0x80000100,
320         .map_io         = omap_3430sdp_map_io,
321         .init_irq       = omap_3430sdp_init_irq,
322         .init_machine   = omap_3430sdp_init,
323         .timer          = &omap_timer,
324 MACHINE_END