2 * linux/arch/arm/mach-omap2/board-3430sdp.c
4 * Copyright (C) 2007 Texas Instruments
6 * Modified from mach-omap2/board-generic.c
8 * Initial code: Syed Mohammed Khasim
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.
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>
26 #include <asm/hardware.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
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>
42 #include <asm/delay.h>
44 #define SDP3430_SMC91X_CS 3
46 #define ENABLE_VAUX3_DEDICATED 0x03
47 #define ENABLE_VAUX3_DEV_GRP 0x20
50 static struct resource sdp3430_smc91x_resources[] = {
52 .start = OMAP34XX_ETHR_START,
53 .end = OMAP34XX_ETHR_START + SZ_4K,
54 .flags = IORESOURCE_MEM,
59 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
63 static struct platform_device sdp3430_smc91x_device = {
66 .num_resources = ARRAY_SIZE(sdp3430_smc91x_resources),
67 .resource = sdp3430_smc91x_resources,
70 static int sdp3430_keymap[] = {
104 static struct omap_kp_platform_data sdp3430_kp_data = {
107 .keymap = sdp3430_keymap,
108 .keymapsize = ARRAY_SIZE(sdp3430_keymap),
112 static struct platform_device sdp3430_kp_device = {
113 .name = "omap_twl4030keypad",
116 .platform_data = &sdp3430_kp_data,
123 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
125 * @return - void. If request gpio fails then Flag KERN_ERR.
127 static void ads7846_dev_init(void)
129 if (omap_request_gpio(ts_gpio) < 0) {
130 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
134 omap_set_gpio_direction(ts_gpio, 1);
136 omap_set_gpio_debounce(ts_gpio, 1);
137 omap_set_gpio_debounce_time(ts_gpio, 0xa);
140 static int ads7846_get_pendown_state(void)
142 return !omap_get_gpio_datain(ts_gpio);
146 * This enable(1)/disable(0) the voltage for TS: uses twl4030 calls
148 static int ads7846_vaux_control(int vaux_cntrl)
152 #ifdef CONFIG_TWL4030_CORE
153 /* check for return value of ldo_use: if success it returns 0 */
154 if (vaux_cntrl == VAUX_ENABLE) {
155 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
156 ENABLE_VAUX3_DEDICATED, TWL4030_VAUX3_DEDICATED))
158 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
159 ENABLE_VAUX3_DEV_GRP, TWL4030_VAUX3_DEV_GRP))
161 } else if (vaux_cntrl == VAUX_DISABLE) {
162 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
163 0x00, TWL4030_VAUX3_DEDICATED))
165 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
166 0x00, TWL4030_VAUX3_DEV_GRP))
175 static struct ads7846_platform_data tsc2046_config __initdata = {
176 .get_pendown_state = ads7846_get_pendown_state,
178 .vaux_control = ads7846_vaux_control,
182 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
184 .single_channel = 1, /* 0: slave, 1: master */
187 static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
190 * TSC2046 operates at a max freqency of 2MHz, so
191 * operate slightly below at 1.5MHz
193 .modalias = "ads7846",
196 .max_speed_hz = 1500000,
197 .controller_data = &tsc2046_mcspi_config,
199 .platform_data = &tsc2046_config,
203 static struct platform_device sdp3430_lcd_device = {
204 .name = "sdp2430_lcd",
208 static struct platform_device *sdp3430_devices[] __initdata = {
209 &sdp3430_smc91x_device,
214 static inline void __init sdp3430_init_smc91x(void)
217 unsigned long cs_mem_base;
220 eth_cs = SDP3430_SMC91X_CS;
222 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
223 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
227 sdp3430_smc91x_resources[0].start = cs_mem_base + 0x0;
228 sdp3430_smc91x_resources[0].end = cs_mem_base + 0xf;
231 if (is_sil_rev_greater_than(OMAP3430_REV_ES1_0))
232 eth_gpio = OMAP34XX_ETHR_GPIO_IRQ_SDPV2;
234 eth_gpio = OMAP34XX_ETHR_GPIO_IRQ_SDPV1;
236 sdp3430_smc91x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio);
238 if (omap_request_gpio(eth_gpio) < 0) {
239 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
243 omap_set_gpio_direction(eth_gpio, 1);
246 static void __init omap_3430sdp_init_irq(void)
248 omap2_init_common_hw();
251 sdp3430_init_smc91x();
254 static struct omap_uart_config sdp3430_uart_config __initdata = {
255 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
258 static struct omap_lcd_config sdp3430_lcd_config __initdata = {
259 .ctrl_name = "internal",
262 static struct omap_mmc_config sdp3430_mmc_config __initdata = {
269 static struct omap_board_config_kernel sdp3430_config[] __initdata = {
270 { OMAP_TAG_UART, &sdp3430_uart_config },
271 {OMAP_TAG_LCD, &sdp3430_lcd_config},
272 {OMAP_TAG_MMC, &sdp3430_mmc_config },
275 static int __init omap3430_i2c_init(void)
277 omap_register_i2c_bus(1, 2600, NULL, 0);
278 omap_register_i2c_bus(2, 400, NULL, 0);
279 omap_register_i2c_bus(3, 400, NULL, 0);
283 extern void __init sdp3430_flash_init(void);
285 static void __init omap_3430sdp_init(void)
287 platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
288 omap_board_config = sdp3430_config;
289 omap_board_config_size = ARRAY_SIZE(sdp3430_config);
290 if (is_sil_rev_greater_than(OMAP3430_REV_ES1_0))
291 ts_gpio = OMAP34XX_TS_GPIO_IRQ_SDPV2;
293 ts_gpio = OMAP34XX_TS_GPIO_IRQ_SDPV1;
294 sdp3430_spi_board_info[0].irq = OMAP_GPIO_IRQ(ts_gpio);
295 spi_register_board_info(sdp3430_spi_board_info,
296 ARRAY_SIZE(sdp3430_spi_board_info));
298 sdp3430_flash_init();
304 static void __init omap_3430sdp_map_io(void)
306 omap2_set_globals_343x();
307 omap2_map_common_io();
309 arch_initcall(omap3430_i2c_init);
311 MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
312 /* Maintainer: Syed Khasim - Texas Instruments Inc */
313 .phys_io = 0x48000000,
314 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
315 .boot_params = 0x80000100,
316 .map_io = omap_3430sdp_map_io,
317 .init_irq = omap_3430sdp_init_irq,
318 .init_machine = omap_3430sdp_init,
319 .timer = &omap_timer,