2 * linux/arch/arm/mach-omap2/board-2430sdp.c
4 * Copyright (C) 2006 Texas Instruments
6 * Modified from mach-omap2/board-generic.c
8 * Initial Code : Based on a patch from Komal Shah and Richard Woodruff
9 * Updated the Code for 2430 SDP : Syed Mohammed Khasim
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/partitions.h>
21 #include <linux/delay.h>
22 #include <linux/input.h>
23 #include <linux/i2c/twl4030.h>
24 #include <linux/err.h>
25 #include <linux/clk.h>
27 #include <linux/spi/spi.h>
28 #include <linux/spi/ads7846.h>
30 #include <mach/hardware.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
34 #include <asm/mach/flash.h>
36 #include <mach/gpio.h>
38 #include <mach/board.h>
39 #include <mach/usb-musb.h>
40 #include <mach/common.h>
41 #include <mach/keypad.h>
42 #include <mach/gpmc.h>
43 #include <mach/mcspi.h>
46 #include "mmc-twl4030.h"
49 #define SDP2430_FLASH_CS 0
50 #define SDP2430_SMC91X_CS 5
52 /* GPIO used for TSC2046 (touchscreen)
54 * Also note that the tsc2046 is the same silicon as the ads7846, so
55 * that driver is used for the touchscreen. */
58 #define TWL4030_MSECURE_GPIO 118
59 #define SECONDARY_LCD_GPIO 147
61 static struct mtd_partition sdp2430_partitions[] = {
62 /* bootloader (U-Boot, etc) in first sector */
67 .mask_flags = MTD_WRITEABLE, /* force read-only */
69 /* bootloader params in the next sector */
72 .offset = MTDPART_OFS_APPEND,
79 .offset = MTDPART_OFS_APPEND,
86 .offset = MTDPART_OFS_APPEND,
87 .size = MTDPART_SIZ_FULL,
92 static struct flash_platform_data sdp2430_flash_data = {
93 .map_name = "cfi_probe",
95 .parts = sdp2430_partitions,
96 .nr_parts = ARRAY_SIZE(sdp2430_partitions),
99 static struct resource sdp2430_flash_resource = {
100 .start = SDP2430_CS0_BASE,
101 .end = SDP2430_CS0_BASE + SZ_64M - 1,
102 .flags = IORESOURCE_MEM,
105 static struct platform_device sdp2430_flash_device = {
109 .platform_data = &sdp2430_flash_data,
112 .resource = &sdp2430_flash_resource,
115 static struct resource sdp2430_smc91x_resources[] = {
117 .start = SDP2430_CS0_BASE,
118 .end = SDP2430_CS0_BASE + SZ_64M - 1,
119 .flags = IORESOURCE_MEM,
122 .start = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
123 .end = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
124 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
128 static struct platform_device sdp2430_lcd_device = {
129 .name = "sdp2430_lcd",
133 static struct platform_device sdp2430_smc91x_device = {
136 .num_resources = ARRAY_SIZE(sdp2430_smc91x_resources),
137 .resource = sdp2430_smc91x_resources,
141 * Key mapping for 2430 SDP board
144 static int sdp2430_keymap[] = {
146 KEY(0, 1, KEY_RIGHT),
155 KEY(2, 0, KEY_ENTER),
178 static struct twl4030_keypad_data sdp2430_kp_data = {
181 .keymap = sdp2430_keymap,
182 .keymapsize = ARRAY_SIZE(sdp2430_keymap),
186 static int __init msecure_init(void)
190 #ifdef CONFIG_RTC_DRV_TWL4030
191 ret = gpio_request(TWL4030_MSECURE_GPIO, "msecure");
193 printk(KERN_ERR "msecure_init: can't reserve GPIO:%d !\n",
194 TWL4030_MSECURE_GPIO);
198 * TWL4030 will be in secure mode if msecure line from OMAP is low.
199 * Make msecure line high in order to change the TWL4030 RTC time
200 * and calender registers.
202 gpio_direction_output(TWL4030_MSECURE_GPIO, 1);
209 static struct platform_device *sdp2430_devices[] __initdata = {
210 &sdp2430_smc91x_device,
211 &sdp2430_flash_device,
215 static void ads7846_dev_init(void)
217 if (gpio_request(TS_GPIO, "ads7846 irq") < 0)
218 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
220 gpio_direction_input(TS_GPIO);
222 omap_set_gpio_debounce(TS_GPIO, 1);
223 omap_set_gpio_debounce_time(TS_GPIO, 0xa);
226 static int ads7846_get_pendown_state(void)
228 return !gpio_get_value(TS_GPIO);
231 static struct ads7846_platform_data tsc2046_config __initdata = {
232 .get_pendown_state = ads7846_get_pendown_state,
236 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
238 .single_channel = 0, /* 0: slave, 1: master */
241 static struct omap_lcd_config sdp2430_lcd_config __initdata = {
242 .ctrl_name = "internal",
245 static struct spi_board_info sdp2430_spi_board_info[] __initdata = {
248 * TSC2046 operates at a max freqency of 2MHz, so
249 * operate slightly below at 1.5MHz
251 .modalias = "ads7846",
254 .max_speed_hz = 1500000,
255 .controller_data = &tsc2046_mcspi_config,
256 .irq = OMAP_GPIO_IRQ(TS_GPIO),
257 .platform_data = &tsc2046_config,
261 static inline void __init sdp2430_init_smc91x(void)
264 unsigned long cs_mem_base;
266 struct clk *gpmc_fck;
268 eth_cs = SDP2430_SMC91X_CS;
270 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
271 if (IS_ERR(gpmc_fck)) {
276 clk_enable(gpmc_fck);
277 rate = clk_get_rate(gpmc_fck);
279 /* Make sure CS1 timings are correct, for 2430 always muxed */
280 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
282 if (rate >= 160000000) {
283 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
284 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
285 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
286 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
287 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
288 } else if (rate >= 130000000) {
289 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
290 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
291 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
292 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
293 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
294 } else { /* rate = 100000000 */
295 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
296 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
297 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
298 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
299 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
302 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
303 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
307 sdp2430_smc91x_resources[0].start = cs_mem_base + 0x300;
308 sdp2430_smc91x_resources[0].end = cs_mem_base + 0x30f;
311 if (gpio_request(OMAP24XX_ETHR_GPIO_IRQ, "SMC91x irq") < 0) {
312 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
313 OMAP24XX_ETHR_GPIO_IRQ);
314 gpmc_cs_free(eth_cs);
317 gpio_direction_input(OMAP24XX_ETHR_GPIO_IRQ);
320 clk_disable(gpmc_fck);
324 static void __init omap_2430sdp_init_irq(void)
326 omap2_init_common_hw(NULL);
329 sdp2430_init_smc91x();
332 static struct omap_uart_config sdp2430_uart_config __initdata = {
333 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
337 struct omap_serial_console_config sdp2430_serial_console_config __initdata = {
339 .console_speed = 115200,
342 static struct omap_board_config_kernel sdp2430_config[] __initdata = {
343 {OMAP_TAG_UART, &sdp2430_uart_config},
344 {OMAP_TAG_LCD, &sdp2430_lcd_config},
345 {OMAP_TAG_SERIAL_CONSOLE, &sdp2430_serial_console_config},
349 static struct twl4030_gpio_platform_data sdp2430_gpio_data = {
350 .gpio_base = OMAP_MAX_GPIO_LINES,
351 .irq_base = TWL4030_GPIO_IRQ_BASE,
352 .irq_end = TWL4030_GPIO_IRQ_END,
355 static struct twl4030_usb_data sdp2430_usb_data = {
356 .usb_mode = T2_USB_MODE_ULPI,
359 static struct twl4030_madc_platform_data sdp2430_madc_data = {
363 static struct twl4030_platform_data sdp2430_twldata = {
364 .irq_base = TWL4030_IRQ_BASE,
365 .irq_end = TWL4030_IRQ_END,
367 /* platform_data for children goes here */
368 .gpio = &sdp2430_gpio_data,
369 .madc = &sdp2430_madc_data,
370 .keypad = &sdp2430_kp_data,
371 .usb = &sdp2430_usb_data,
374 static struct i2c_board_info __initdata sdp2430_i2c_boardinfo[] = {
376 I2C_BOARD_INFO("twl4030", 0x48),
377 .flags = I2C_CLIENT_WAKE,
378 .irq = INT_24XX_SYS_NIRQ,
379 .platform_data = &sdp2430_twldata,
383 static int __init omap2430_i2c_init(void)
385 omap_register_i2c_bus(1, 400, NULL, 0);
386 omap_register_i2c_bus(2, 2600, sdp2430_i2c_boardinfo,
387 ARRAY_SIZE(sdp2430_i2c_boardinfo));
391 static struct twl4030_hsmmc_info mmc[] __initdata = {
402 static void __init omap_2430sdp_init(void)
406 platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices));
407 omap_board_config = sdp2430_config;
408 omap_board_config_size = ARRAY_SIZE(sdp2430_config);
413 sdp2430_flash_init();
416 spi_register_board_info(sdp2430_spi_board_info,
417 ARRAY_SIZE(sdp2430_spi_board_info));
419 twl4030_mmc_init(mmc);
421 /* turn off secondary LCD backlight */
422 gpio_direction_output(SECONDARY_LCD_GPIO, 0);
425 static void __init omap_2430sdp_map_io(void)
427 omap2_set_globals_243x();
428 omap2_map_common_io();
431 MACHINE_START(OMAP_2430SDP, "OMAP2430 sdp2430 board")
432 /* Maintainer: Syed Khasim - Texas Instruments Inc */
433 .phys_io = 0x48000000,
434 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
435 .boot_params = 0x80000100,
436 .map_io = omap_2430sdp_map_io,
437 .init_irq = omap_2430sdp_init_irq,
438 .init_machine = omap_2430sdp_init,
439 .timer = &omap_timer,