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/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/gpio.h>
35 #include <asm/arch/mux.h>
36 #include <asm/arch/board.h>
37 #include <asm/arch/common.h>
38 #include <asm/arch/keypad.h>
39 #include <asm/arch/gpmc.h>
40 #include <asm/arch/mcspi.h>
41 #include "prcm-regs.h"
45 #define SDP2430_FLASH_CS 0
46 #define SDP2430_SMC91X_CS 5
48 /* GPIO used for TSC2046 (touchscreen)
50 * Also note that the tsc2046 is the same silicon as the ads7846, so
51 * that driver is used for the touchscreen. */
54 static struct mtd_partition sdp2430_partitions[] = {
55 /* bootloader (U-Boot, etc) in first sector */
60 .mask_flags = MTD_WRITEABLE, /* force read-only */
62 /* bootloader params in the next sector */
65 .offset = MTDPART_OFS_APPEND,
72 .offset = MTDPART_OFS_APPEND,
79 .offset = MTDPART_OFS_APPEND,
80 .size = MTDPART_SIZ_FULL,
85 static struct flash_platform_data sdp2430_flash_data = {
86 .map_name = "cfi_probe",
88 .parts = sdp2430_partitions,
89 .nr_parts = ARRAY_SIZE(sdp2430_partitions),
92 static struct resource sdp2430_flash_resource = {
93 .start = SDP2430_CS0_BASE,
94 .end = SDP2430_CS0_BASE + SZ_64M - 1,
95 .flags = IORESOURCE_MEM,
98 static struct platform_device sdp2430_flash_device = {
102 .platform_data = &sdp2430_flash_data,
105 .resource = &sdp2430_flash_resource,
108 static struct resource sdp2430_smc91x_resources[] = {
110 .start = SDP2430_CS0_BASE,
111 .end = SDP2430_CS0_BASE + SZ_64M - 1,
112 .flags = IORESOURCE_MEM,
115 .start = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
116 .end = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
117 .flags = IORESOURCE_IRQ,
121 static struct platform_device sdp2430_smc91x_device = {
124 .num_resources = ARRAY_SIZE(sdp2430_smc91x_resources),
125 .resource = sdp2430_smc91x_resources,
129 * Key mapping for 2430 SDP board
132 static int sdp2430_keymap[] = {
134 KEY(0, 1, KEY_RIGHT),
143 KEY(2, 0, KEY_ENTER),
166 static struct omap_kp_platform_data sdp2430_kp_data = {
169 .keymap = sdp2430_keymap,
170 .keymapsize = ARRAY_SIZE(sdp2430_keymap),
174 static struct platform_device sdp2430_kp_device = {
175 .name = "omap_twl4030keypad",
178 .platform_data = &sdp2430_kp_data,
182 static struct platform_device *sdp2430_devices[] __initdata = {
183 &sdp2430_smc91x_device,
184 &sdp2430_flash_device,
188 static void ads7846_dev_init(void)
190 if (omap_request_gpio(TS_GPIO) < 0)
191 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
193 omap_set_gpio_direction(TS_GPIO, 1);
195 omap_set_gpio_debounce(TS_GPIO, 1);
196 omap_set_gpio_debounce_time(TS_GPIO, 0xa);
199 static int ads7846_get_pendown_state(void)
201 return !omap_get_gpio_datain(TS_GPIO);
204 static struct ads7846_platform_data tsc2046_config __initdata = {
205 .get_pendown_state = ads7846_get_pendown_state,
209 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
211 .single_channel = 0, /* 0: slave, 1: master */
214 static struct spi_board_info sdp2430_spi_board_info[] __initdata = {
217 * TSC2046 operates at a max freqency of 2MHz, so
218 * operate slightly below at 1.5MHz
220 .modalias = "ads7846",
223 .max_speed_hz = 1500000,
224 .controller_data = &tsc2046_mcspi_config,
225 .irq = OMAP_GPIO_IRQ(TS_GPIO),
226 .platform_data = &tsc2046_config,
230 static inline void __init sdp2430_init_smc91x(void)
233 unsigned long cs_mem_base;
237 eth_cs = SDP2430_SMC91X_CS;
239 l3ck = clk_get(NULL, "core_l3_ck");
243 rate = clk_get_rate(l3ck);
245 /* Make sure CS1 timings are correct, for 2430 always muxed */
246 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
248 if (rate >= 160000000) {
249 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
250 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
251 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
252 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
253 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
254 } else if (rate >= 130000000) {
255 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
256 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
257 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
258 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
259 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
260 } else { /* rate = 100000000 */
261 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
262 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
263 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
264 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
265 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
268 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
269 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
273 sdp2430_smc91x_resources[0].start = cs_mem_base + 0x300;
274 sdp2430_smc91x_resources[0].end = cs_mem_base + 0x30f;
277 if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ) < 0) {
278 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
279 OMAP24XX_ETHR_GPIO_IRQ);
280 gpmc_cs_free(eth_cs);
283 omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ, 1);
287 static void __init omap_2430sdp_init_irq(void)
289 omap2_init_common_hw();
292 sdp2430_init_smc91x();
295 static struct omap_uart_config sdp2430_uart_config __initdata = {
296 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
299 static struct omap_board_config_kernel sdp2430_config[] __initdata = {
300 {OMAP_TAG_UART, &sdp2430_uart_config},
303 #if defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
305 #define OMAP2_I2C_BASE1 0x48070000
306 #define OMAP2_I2C_BASE2 0x48072000
307 #define OMAP2_I2C_INT1 56
308 #define OMAP2_I2C_INT2 57
310 static u32 omap2_i2c1_clkrate = 400;
311 static u32 omap2_i2c2_clkrate = 2600;
313 static struct resource i2c_resources1[] = {
315 .start = OMAP2_I2C_BASE1,
316 .end = OMAP2_I2C_BASE1 + 0x3f,
317 .flags = IORESOURCE_MEM,
320 .start = OMAP2_I2C_INT1,
321 .flags = IORESOURCE_IRQ,
325 static struct resource i2c_resources2[] = {
327 .start = OMAP2_I2C_BASE2,
328 .end = OMAP2_I2C_BASE2 + 0x3f,
329 .flags = IORESOURCE_MEM,
332 .start = OMAP2_I2C_INT2,
333 .flags = IORESOURCE_IRQ,
337 static struct platform_device omap_i2c_device1 = {
340 .num_resources = ARRAY_SIZE(i2c_resources1),
341 .resource = i2c_resources1,
343 .platform_data = &omap2_i2c1_clkrate,
347 static struct platform_device omap_i2c_device2 = {
350 .num_resources = ARRAY_SIZE(i2c_resources2),
351 .resource = i2c_resources2,
353 .platform_data = &omap2_i2c2_clkrate,
357 static void omap_init_i2c(void)
359 (void) platform_device_register(&omap_i2c_device2);
360 (void) platform_device_register(&omap_i2c_device1);
365 static void omap_init_i2c(void) {}
369 static int __init omap2430_i2c_init(void)
375 extern void __init sdp2430_flash_init(void);
376 extern void __init sdp2430_usb_init(void);
378 static void __init omap_2430sdp_init(void)
380 platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices));
381 omap_board_config = sdp2430_config;
382 omap_board_config_size = ARRAY_SIZE(sdp2430_config);
385 sdp2430_flash_init();
388 spi_register_board_info(sdp2430_spi_board_info,
389 ARRAY_SIZE(sdp2430_spi_board_info));
393 static void __init omap_2430sdp_map_io(void)
395 omap2_map_common_io();
398 arch_initcall(omap2430_i2c_init);
400 MACHINE_START(OMAP_2430SDP, "OMAP2430 sdp2430 board")
401 /* Maintainer: Syed Khasim - Texas Instruments Inc */
402 .phys_io = 0x48000000,
403 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
404 .boot_params = 0x80000100,
405 .map_io = omap_2430sdp_map_io,
406 .init_irq = omap_2430sdp_init_irq,
407 .init_machine = omap_2430sdp_init,
408 .timer = &omap_timer,