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/mtd/mtd.h>
19 #include <linux/mtd/partitions.h>
20 #include <linux/delay.h>
21 #include <linux/input.h>
22 #include <linux/workqueue.h>
23 #include <linux/err.h>
24 #include <linux/clk.h>
25 #include <linux/spi/spi.h>
26 #include <linux/spi/ads7846.h>
28 #include <asm/hardware.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
32 #include <asm/mach/flash.h>
34 #include <asm/arch/twl4030.h>
35 #include <asm/arch/mcspi.h>
36 #include <asm/arch/gpio.h>
37 #include <asm/arch/mux.h>
38 #include <asm/arch/board.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>
45 #include <asm/delay.h>
47 #define SDP3430_FLASH_CS 0
48 #define SDP3430_SMC91X_CS 3
50 #define ENABLE_VAUX3_DEDICATED 0x03
51 #define ENABLE_VAUX3_DEV_GRP 0x20
53 static struct mtd_partition sdp3430_partitions[] = {
54 /* bootloader (U-Boot, etc) in first sector */
59 .mask_flags = MTD_WRITEABLE, /* force read-only */
61 /* bootloader params in the next sector */
64 .offset = MTDPART_OFS_APPEND,
71 .offset = MTDPART_OFS_APPEND,
78 .offset = MTDPART_OFS_APPEND,
79 .size = MTDPART_SIZ_FULL,
84 static struct flash_platform_data sdp3430_flash_data = {
85 .map_name = "cfi_probe",
87 .parts = sdp3430_partitions,
88 .nr_parts = ARRAY_SIZE(sdp3430_partitions),
91 static struct resource sdp3430_flash_resource = {
93 .end = FLASH_BASE + SZ_64M - 1,
94 .flags = IORESOURCE_MEM,
97 static struct platform_device sdp3430_flash_device = {
101 .platform_data = &sdp3430_flash_data,
104 .resource = &sdp3430_flash_resource,
107 static struct resource sdp3430_smc91x_resources[] = {
109 .start = OMAP34XX_ETHR_START,
110 .end = OMAP34XX_ETHR_START + SZ_4K,
111 .flags = IORESOURCE_MEM,
114 .start = OMAP_GPIO_IRQ(OMAP34XX_ETHR_GPIO_IRQ),
116 .flags = IORESOURCE_IRQ,
120 static struct platform_device sdp3430_smc91x_device = {
123 .num_resources = ARRAY_SIZE(sdp3430_smc91x_resources),
124 .resource = sdp3430_smc91x_resources,
127 static int sdp3430_keymap[] = {
129 KEY(0, 1, KEY_RIGHT),
138 KEY(2, 0, KEY_ENTER),
161 static struct omap_kp_platform_data sdp3430_kp_data = {
164 .keymap = sdp3430_keymap,
165 .keymapsize = ARRAY_SIZE(sdp3430_keymap),
169 static struct platform_device sdp3430_kp_device = {
170 .name = "omap_twl4030keypad",
173 .platform_data = &sdp3430_kp_data,
178 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
180 * @return - void. If request gpio fails then Flag KERN_ERR.
182 static void ads7846_dev_init(void)
184 if (omap_request_gpio(TS_GPIO) < 0) {
185 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
189 omap_set_gpio_direction(TS_GPIO, 1);
191 omap_set_gpio_debounce(TS_GPIO, 1);
192 omap_set_gpio_debounce_time(TS_GPIO, 0xa);
195 static int ads7846_get_pendown_state(void)
197 return !omap_get_gpio_datain(TS_GPIO);
201 * This enable(1)/disable(0) the voltage for TS: uses twl4030 calls
203 static int ads7846_vaux_control(int vaux_cntrl)
207 #ifdef CONFIG_TWL4030_CORE
208 /* check for return value of ldo_use: if success it returns 0 */
209 if (vaux_cntrl == VAUX_ENABLE) {
210 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
211 ENABLE_VAUX3_DEDICATED, TWL4030_VAUX3_DEDICATED))
213 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
214 ENABLE_VAUX3_DEV_GRP, TWL4030_VAUX3_DEV_GRP))
216 } else if (vaux_cntrl == VAUX_DISABLE) {
217 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
218 0x00, TWL4030_VAUX3_DEDICATED))
220 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
221 0x00, TWL4030_VAUX3_DEV_GRP))
230 static struct ads7846_platform_data tsc2046_config __initdata = {
231 .get_pendown_state = ads7846_get_pendown_state,
233 .vaux_control = ads7846_vaux_control,
237 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
239 .single_channel = 1, /* 0: slave, 1: master */
242 static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
245 * TSC2046 operates at a max freqency of 2MHz, so
246 * operate slightly below at 1.5MHz
248 .modalias = "ads7846",
251 .max_speed_hz = 1500000,
252 .controller_data = &tsc2046_mcspi_config,
253 .irq = OMAP_GPIO_IRQ(TS_GPIO),
254 .platform_data = &tsc2046_config,
257 static struct platform_device *sdp3430_devices[] __initdata = {
258 &sdp3430_smc91x_device,
259 &sdp3430_flash_device,
263 static inline void __init sdp3430_init_smc91x(void)
266 unsigned long cs_mem_base;
268 eth_cs = SDP3430_SMC91X_CS;
270 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
271 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
275 sdp3430_smc91x_resources[0].start = cs_mem_base + 0x0;
276 sdp3430_smc91x_resources[0].end = cs_mem_base + 0xf;
279 if (omap_request_gpio(OMAP34XX_ETHR_GPIO_IRQ) < 0) {
280 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
281 OMAP34XX_ETHR_GPIO_IRQ);
284 omap_set_gpio_direction(OMAP34XX_ETHR_GPIO_IRQ, 1);
287 static void __init omap_3430sdp_init_irq(void)
289 omap2_init_common_hw();
292 sdp3430_init_smc91x();
295 static struct omap_uart_config sdp3430_uart_config __initdata = {
296 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
299 static struct omap_board_config_kernel sdp3430_config[] = {
300 { OMAP_TAG_UART, &sdp3430_uart_config },
302 static int __init omap3430_i2c_init(void)
304 omap_register_i2c_bus(1, 2600, NULL, 0);
305 omap_register_i2c_bus(2, 400, NULL, 0);
306 omap_register_i2c_bus(3, 400, NULL, 0);
310 static void __init omap_3430sdp_init(void)
312 platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
313 omap_board_config = sdp3430_config;
314 omap_board_config_size = ARRAY_SIZE(sdp3430_config);
315 spi_register_board_info(sdp3430_spi_board_info,
316 ARRAY_SIZE(sdp3430_spi_board_info));
321 static void __init omap_3430sdp_map_io(void)
323 omap2_set_globals_343x();
324 omap2_map_common_io();
326 arch_initcall(omap3430_i2c_init);
328 MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
329 /* Maintainer: Syed Khasim - Texas Instruments Inc */
330 .phys_io = 0x48000000,
331 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
332 .boot_params = 0x80000100,
333 .map_io = omap_3430sdp_map_io,
334 .init_irq = omap_3430sdp_init_irq,
335 .init_machine = omap_3430sdp_init,
336 .timer = &omap_timer,