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/i2c/twl4030.h>
24 #include <linux/spi/spi.h>
25 #include <linux/spi/ads7846.h>
27 #include <mach/hardware.h>
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
32 #include <mach/mcspi.h>
33 #include <mach/gpio.h>
35 #include <mach/board.h>
36 #include <mach/usb-musb.h>
37 #include <mach/usb-ehci.h>
38 #include <mach/hsmmc.h>
39 #include <mach/common.h>
40 #include <mach/keypad.h>
42 #include <mach/gpmc.h>
43 #include <linux/i2c/twl4030-rtc.h>
46 #include <asm/delay.h>
47 #include <mach/control.h>
49 #include "sdram-qimonda-hyb18m512160af-6.h"
51 #define SDP3430_SMC91X_CS 3
53 #define ENABLE_VAUX3_DEDICATED 0x03
54 #define ENABLE_VAUX3_DEV_GRP 0x20
57 #define TWL4030_MSECURE_GPIO 22
59 static struct resource sdp3430_smc91x_resources[] = {
61 .start = OMAP34XX_ETHR_START,
62 .end = OMAP34XX_ETHR_START + SZ_4K,
63 .flags = IORESOURCE_MEM,
68 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
72 static struct platform_device sdp3430_smc91x_device = {
75 .num_resources = ARRAY_SIZE(sdp3430_smc91x_resources),
76 .resource = sdp3430_smc91x_resources,
79 static int sdp3430_keymap[] = {
113 static struct omap_kp_platform_data sdp3430_kp_data = {
116 .keymap = sdp3430_keymap,
117 .keymapsize = ARRAY_SIZE(sdp3430_keymap),
119 .irq = TWL4030_MODIRQ_KEYPAD,
122 static struct platform_device sdp3430_kp_device = {
123 .name = "omap_twl4030keypad",
126 .platform_data = &sdp3430_kp_data,
132 #ifdef CONFIG_RTC_DRV_TWL4030
133 static int twl4030_rtc_init(void)
137 /* 3430ES2.0 doesn't have msecure/gpio-22 line connected to T2 */
138 if (is_device_type_gp() && is_sil_rev_less_than(OMAP3430_REV_ES2_0)) {
139 u32 msecure_pad_config_reg = omap_ctrl_base_get() + 0xA3C;
143 ret = omap_request_gpio(TWL4030_MSECURE_GPIO);
145 printk(KERN_ERR "twl4030_rtc_init: can't"
146 "reserve GPIO:%d !\n", TWL4030_MSECURE_GPIO);
150 * TWL4030 will be in secure mode if msecure line from OMAP
151 * is low. Make msecure line high in order to change the
152 * TWL4030 RTC time and calender registers.
154 omap_set_gpio_direction(TWL4030_MSECURE_GPIO, 0);
156 tmp = omap_readw(msecure_pad_config_reg);
157 tmp &= 0xF8; /* To enable mux mode 03/04 = GPIO_RTC */
158 tmp |= mux_mask;/* To enable mux mode 03/04 = GPIO_RTC */
159 omap_writew(tmp, msecure_pad_config_reg);
161 omap_set_gpio_dataout(TWL4030_MSECURE_GPIO, 1);
167 static void twl4030_rtc_exit(void)
169 if (is_device_type_gp() &&
170 is_sil_rev_less_than(OMAP3430_REV_ES2_0)) {
171 omap_free_gpio(TWL4030_MSECURE_GPIO);
175 static struct twl4030rtc_platform_data sdp3430_twl4030rtc_data = {
176 .init = &twl4030_rtc_init,
177 .exit = &twl4030_rtc_exit,
180 static struct platform_device sdp3430_twl4030rtc_device = {
181 .name = "twl4030_rtc",
184 .platform_data = &sdp3430_twl4030rtc_data,
190 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
192 * @return - void. If request gpio fails then Flag KERN_ERR.
194 static void ads7846_dev_init(void)
196 if (omap_request_gpio(ts_gpio) < 0) {
197 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
201 omap_set_gpio_direction(ts_gpio, 1);
203 omap_set_gpio_debounce(ts_gpio, 1);
204 omap_set_gpio_debounce_time(ts_gpio, 0xa);
207 static int ads7846_get_pendown_state(void)
209 return !omap_get_gpio_datain(ts_gpio);
213 * This enable(1)/disable(0) the voltage for TS: uses twl4030 calls
215 static int ads7846_vaux_control(int vaux_cntrl)
219 #ifdef CONFIG_TWL4030_CORE
220 /* check for return value of ldo_use: if success it returns 0 */
221 if (vaux_cntrl == VAUX_ENABLE) {
222 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
223 ENABLE_VAUX3_DEDICATED, TWL4030_VAUX3_DEDICATED))
225 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
226 ENABLE_VAUX3_DEV_GRP, TWL4030_VAUX3_DEV_GRP))
228 } else if (vaux_cntrl == VAUX_DISABLE) {
229 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
230 0x00, TWL4030_VAUX3_DEDICATED))
232 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
233 0x00, TWL4030_VAUX3_DEV_GRP))
242 static struct ads7846_platform_data tsc2046_config __initdata = {
243 .get_pendown_state = ads7846_get_pendown_state,
245 .vaux_control = ads7846_vaux_control,
249 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
251 .single_channel = 1, /* 0: slave, 1: master */
254 static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
257 * TSC2046 operates at a max freqency of 2MHz, so
258 * operate slightly below at 1.5MHz
260 .modalias = "ads7846",
263 .max_speed_hz = 1500000,
264 .controller_data = &tsc2046_mcspi_config,
266 .platform_data = &tsc2046_config,
270 static struct platform_device sdp3430_lcd_device = {
271 .name = "sdp2430_lcd",
275 static struct platform_device *sdp3430_devices[] __initdata = {
276 &sdp3430_smc91x_device,
279 #ifdef CONFIG_RTC_DRV_TWL4030
280 &sdp3430_twl4030rtc_device,
284 static inline void __init sdp3430_init_smc91x(void)
287 unsigned long cs_mem_base;
290 eth_cs = SDP3430_SMC91X_CS;
292 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
293 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
297 sdp3430_smc91x_resources[0].start = cs_mem_base + 0x0;
298 sdp3430_smc91x_resources[0].end = cs_mem_base + 0xf;
301 if (is_sil_rev_greater_than(OMAP3430_REV_ES1_0))
302 eth_gpio = OMAP34XX_ETHR_GPIO_IRQ_SDPV2;
304 eth_gpio = OMAP34XX_ETHR_GPIO_IRQ_SDPV1;
306 sdp3430_smc91x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio);
308 if (omap_request_gpio(eth_gpio) < 0) {
309 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
313 omap_set_gpio_direction(eth_gpio, 1);
316 static void __init omap_3430sdp_init_irq(void)
318 omap2_init_common_hw(hyb18m512160af6_sdrc_params);
321 sdp3430_init_smc91x();
324 static struct omap_uart_config sdp3430_uart_config __initdata = {
325 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
328 static struct omap_lcd_config sdp3430_lcd_config __initdata = {
329 .ctrl_name = "internal",
332 static struct omap_mmc_config sdp3430_mmc_config __initdata = {
339 static struct omap_board_config_kernel sdp3430_config[] __initdata = {
340 { OMAP_TAG_UART, &sdp3430_uart_config },
341 {OMAP_TAG_LCD, &sdp3430_lcd_config},
342 {OMAP_TAG_MMC, &sdp3430_mmc_config },
345 static int __init omap3430_i2c_init(void)
347 omap_register_i2c_bus(1, 2600, NULL, 0);
348 omap_register_i2c_bus(2, 400, NULL, 0);
349 omap_register_i2c_bus(3, 400, NULL, 0);
353 extern void __init sdp3430_flash_init(void);
355 static void __init omap_3430sdp_init(void)
357 platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
358 omap_board_config = sdp3430_config;
359 omap_board_config_size = ARRAY_SIZE(sdp3430_config);
360 if (is_sil_rev_greater_than(OMAP3430_REV_ES1_0))
361 ts_gpio = OMAP34XX_TS_GPIO_IRQ_SDPV2;
363 ts_gpio = OMAP34XX_TS_GPIO_IRQ_SDPV1;
364 sdp3430_spi_board_info[0].irq = OMAP_GPIO_IRQ(ts_gpio);
365 spi_register_board_info(sdp3430_spi_board_info,
366 ARRAY_SIZE(sdp3430_spi_board_info));
368 sdp3430_flash_init();
369 twl4030_bci_battery_init();
376 static void __init omap_3430sdp_map_io(void)
378 omap2_set_globals_343x();
379 omap2_map_common_io();
381 arch_initcall(omap3430_i2c_init);
383 MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
384 /* Maintainer: Syed Khasim - Texas Instruments Inc */
385 .phys_io = 0x48000000,
386 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
387 .boot_params = 0x80000100,
388 .map_io = omap_3430sdp_map_io,
389 .init_irq = omap_3430sdp_init_irq,
390 .init_machine = omap_3430sdp_init,
391 .timer = &omap_timer,