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