Syed Mohammed Khasim | 53c5ec3 | 2009-05-28 14:13:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-omap2/board-omap3evm.c |
| 3 | * |
| 4 | * Copyright (C) 2008 Texas Instruments |
| 5 | * |
| 6 | * Modified from mach-omap2/board-3430sdp.c |
| 7 | * |
| 8 | * Initial code: Syed Mohammed Khasim |
| 9 | * |
| 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. |
| 13 | */ |
| 14 | |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/platform_device.h> |
| 18 | #include <linux/delay.h> |
| 19 | #include <linux/err.h> |
| 20 | #include <linux/clk.h> |
| 21 | #include <linux/gpio.h> |
| 22 | #include <linux/input.h> |
| 23 | #include <linux/leds.h> |
| 24 | |
| 25 | #include <linux/spi/spi.h> |
| 26 | #include <linux/spi/ads7846.h> |
| 27 | #include <linux/i2c/twl4030.h> |
Gupta, Ajay Kumar | e8e2ff4 | 2009-07-29 11:58:57 +0530 | [diff] [blame] | 28 | #include <linux/usb/otg.h> |
Syed Mohammed Khasim | 53c5ec3 | 2009-05-28 14:13:28 -0700 | [diff] [blame] | 29 | |
| 30 | #include <mach/hardware.h> |
| 31 | #include <asm/mach-types.h> |
| 32 | #include <asm/mach/arch.h> |
| 33 | #include <asm/mach/map.h> |
| 34 | |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame^] | 35 | #include <plat/board.h> |
| 36 | #include <plat/mux.h> |
| 37 | #include <plat/usb.h> |
| 38 | #include <plat/common.h> |
| 39 | #include <plat/mcspi.h> |
| 40 | #include <plat/keypad.h> |
Syed Mohammed Khasim | 53c5ec3 | 2009-05-28 14:13:28 -0700 | [diff] [blame] | 41 | |
| 42 | #include "sdram-micron-mt46h32m32lf-6.h" |
| 43 | #include "mmc-twl4030.h" |
| 44 | |
| 45 | #define OMAP3_EVM_TS_GPIO 175 |
| 46 | |
| 47 | #define OMAP3EVM_ETHR_START 0x2c000000 |
| 48 | #define OMAP3EVM_ETHR_SIZE 1024 |
| 49 | #define OMAP3EVM_ETHR_GPIO_IRQ 176 |
| 50 | #define OMAP3EVM_SMC911X_CS 5 |
| 51 | |
| 52 | static struct resource omap3evm_smc911x_resources[] = { |
| 53 | [0] = { |
| 54 | .start = OMAP3EVM_ETHR_START, |
| 55 | .end = (OMAP3EVM_ETHR_START + OMAP3EVM_ETHR_SIZE - 1), |
| 56 | .flags = IORESOURCE_MEM, |
| 57 | }, |
| 58 | [1] = { |
| 59 | .start = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ), |
| 60 | .end = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ), |
| 61 | .flags = IORESOURCE_IRQ, |
| 62 | }, |
| 63 | }; |
| 64 | |
| 65 | static struct platform_device omap3evm_smc911x_device = { |
| 66 | .name = "smc911x", |
| 67 | .id = -1, |
| 68 | .num_resources = ARRAY_SIZE(omap3evm_smc911x_resources), |
| 69 | .resource = &omap3evm_smc911x_resources[0], |
| 70 | }; |
| 71 | |
| 72 | static inline void __init omap3evm_init_smc911x(void) |
| 73 | { |
| 74 | int eth_cs; |
| 75 | struct clk *l3ck; |
| 76 | unsigned int rate; |
| 77 | |
| 78 | eth_cs = OMAP3EVM_SMC911X_CS; |
| 79 | |
| 80 | l3ck = clk_get(NULL, "l3_ck"); |
| 81 | if (IS_ERR(l3ck)) |
| 82 | rate = 100000000; |
| 83 | else |
| 84 | rate = clk_get_rate(l3ck); |
| 85 | |
| 86 | if (gpio_request(OMAP3EVM_ETHR_GPIO_IRQ, "SMC911x irq") < 0) { |
| 87 | printk(KERN_ERR "Failed to request GPIO%d for smc911x IRQ\n", |
| 88 | OMAP3EVM_ETHR_GPIO_IRQ); |
| 89 | return; |
| 90 | } |
| 91 | |
| 92 | gpio_direction_input(OMAP3EVM_ETHR_GPIO_IRQ); |
| 93 | } |
| 94 | |
Syed Mohammed Khasim | 53c5ec3 | 2009-05-28 14:13:28 -0700 | [diff] [blame] | 95 | static struct twl4030_hsmmc_info mmc[] = { |
| 96 | { |
| 97 | .mmc = 1, |
| 98 | .wires = 4, |
| 99 | .gpio_cd = -EINVAL, |
| 100 | .gpio_wp = 63, |
| 101 | }, |
| 102 | {} /* Terminator */ |
| 103 | }; |
| 104 | |
| 105 | static struct gpio_led gpio_leds[] = { |
| 106 | { |
| 107 | .name = "omap3evm::ledb", |
| 108 | /* normally not visible (board underside) */ |
| 109 | .default_trigger = "default-on", |
| 110 | .gpio = -EINVAL, /* gets replaced */ |
| 111 | .active_low = true, |
| 112 | }, |
| 113 | }; |
| 114 | |
| 115 | static struct gpio_led_platform_data gpio_led_info = { |
| 116 | .leds = gpio_leds, |
| 117 | .num_leds = ARRAY_SIZE(gpio_leds), |
| 118 | }; |
| 119 | |
| 120 | static struct platform_device leds_gpio = { |
| 121 | .name = "leds-gpio", |
| 122 | .id = -1, |
| 123 | .dev = { |
| 124 | .platform_data = &gpio_led_info, |
| 125 | }, |
| 126 | }; |
| 127 | |
| 128 | |
| 129 | static int omap3evm_twl_gpio_setup(struct device *dev, |
| 130 | unsigned gpio, unsigned ngpio) |
| 131 | { |
| 132 | /* gpio + 0 is "mmc0_cd" (input/IRQ) */ |
| 133 | omap_cfg_reg(L8_34XX_GPIO63); |
| 134 | mmc[0].gpio_cd = gpio + 0; |
| 135 | twl4030_mmc_init(mmc); |
| 136 | |
| 137 | /* |
| 138 | * Most GPIOs are for USB OTG. Some are mostly sent to |
| 139 | * the P2 connector; notably LEDA for the LCD backlight. |
| 140 | */ |
| 141 | |
| 142 | /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */ |
| 143 | gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1; |
| 144 | |
| 145 | platform_device_register(&leds_gpio); |
| 146 | |
| 147 | return 0; |
| 148 | } |
| 149 | |
| 150 | static struct twl4030_gpio_platform_data omap3evm_gpio_data = { |
| 151 | .gpio_base = OMAP_MAX_GPIO_LINES, |
| 152 | .irq_base = TWL4030_GPIO_IRQ_BASE, |
| 153 | .irq_end = TWL4030_GPIO_IRQ_END, |
| 154 | .use_leds = true, |
| 155 | .setup = omap3evm_twl_gpio_setup, |
| 156 | }; |
| 157 | |
| 158 | static struct twl4030_usb_data omap3evm_usb_data = { |
| 159 | .usb_mode = T2_USB_MODE_ULPI, |
| 160 | }; |
| 161 | |
Tony Lindgren | 4f54333 | 2009-09-24 16:23:16 -0700 | [diff] [blame] | 162 | static int board_keymap[] = { |
Syed Mohammed Khasim | 53c5ec3 | 2009-05-28 14:13:28 -0700 | [diff] [blame] | 163 | KEY(0, 0, KEY_LEFT), |
| 164 | KEY(0, 1, KEY_RIGHT), |
| 165 | KEY(0, 2, KEY_A), |
| 166 | KEY(0, 3, KEY_B), |
| 167 | KEY(1, 0, KEY_DOWN), |
| 168 | KEY(1, 1, KEY_UP), |
| 169 | KEY(1, 2, KEY_E), |
| 170 | KEY(1, 3, KEY_F), |
| 171 | KEY(2, 0, KEY_ENTER), |
| 172 | KEY(2, 1, KEY_I), |
| 173 | KEY(2, 2, KEY_J), |
| 174 | KEY(2, 3, KEY_K), |
| 175 | KEY(3, 0, KEY_M), |
| 176 | KEY(3, 1, KEY_N), |
| 177 | KEY(3, 2, KEY_O), |
| 178 | KEY(3, 3, KEY_P) |
| 179 | }; |
| 180 | |
Tony Lindgren | 4f54333 | 2009-09-24 16:23:16 -0700 | [diff] [blame] | 181 | static struct matrix_keymap_data board_map_data = { |
| 182 | .keymap = board_keymap, |
| 183 | .keymap_size = ARRAY_SIZE(board_keymap), |
| 184 | }; |
| 185 | |
Syed Mohammed Khasim | 53c5ec3 | 2009-05-28 14:13:28 -0700 | [diff] [blame] | 186 | static struct twl4030_keypad_data omap3evm_kp_data = { |
Tony Lindgren | 4f54333 | 2009-09-24 16:23:16 -0700 | [diff] [blame] | 187 | .keymap_data = &board_map_data, |
Syed Mohammed Khasim | 53c5ec3 | 2009-05-28 14:13:28 -0700 | [diff] [blame] | 188 | .rows = 4, |
| 189 | .cols = 4, |
Syed Mohammed Khasim | 53c5ec3 | 2009-05-28 14:13:28 -0700 | [diff] [blame] | 190 | .rep = 1, |
| 191 | }; |
| 192 | |
| 193 | static struct twl4030_madc_platform_data omap3evm_madc_data = { |
| 194 | .irq_line = 1, |
| 195 | }; |
| 196 | |
| 197 | static struct twl4030_platform_data omap3evm_twldata = { |
| 198 | .irq_base = TWL4030_IRQ_BASE, |
| 199 | .irq_end = TWL4030_IRQ_END, |
| 200 | |
| 201 | /* platform_data for children goes here */ |
| 202 | .keypad = &omap3evm_kp_data, |
| 203 | .madc = &omap3evm_madc_data, |
| 204 | .usb = &omap3evm_usb_data, |
| 205 | .gpio = &omap3evm_gpio_data, |
| 206 | }; |
| 207 | |
| 208 | static struct i2c_board_info __initdata omap3evm_i2c_boardinfo[] = { |
| 209 | { |
| 210 | I2C_BOARD_INFO("twl4030", 0x48), |
| 211 | .flags = I2C_CLIENT_WAKE, |
| 212 | .irq = INT_34XX_SYS_NIRQ, |
| 213 | .platform_data = &omap3evm_twldata, |
| 214 | }, |
| 215 | }; |
| 216 | |
| 217 | static int __init omap3_evm_i2c_init(void) |
| 218 | { |
| 219 | omap_register_i2c_bus(1, 2600, omap3evm_i2c_boardinfo, |
| 220 | ARRAY_SIZE(omap3evm_i2c_boardinfo)); |
| 221 | omap_register_i2c_bus(2, 400, NULL, 0); |
| 222 | omap_register_i2c_bus(3, 400, NULL, 0); |
| 223 | return 0; |
| 224 | } |
| 225 | |
| 226 | static struct platform_device omap3_evm_lcd_device = { |
| 227 | .name = "omap3evm_lcd", |
| 228 | .id = -1, |
| 229 | }; |
| 230 | |
| 231 | static struct omap_lcd_config omap3_evm_lcd_config __initdata = { |
| 232 | .ctrl_name = "internal", |
| 233 | }; |
| 234 | |
| 235 | static void ads7846_dev_init(void) |
| 236 | { |
| 237 | if (gpio_request(OMAP3_EVM_TS_GPIO, "ADS7846 pendown") < 0) |
| 238 | printk(KERN_ERR "can't get ads7846 pen down GPIO\n"); |
| 239 | |
| 240 | gpio_direction_input(OMAP3_EVM_TS_GPIO); |
| 241 | |
| 242 | omap_set_gpio_debounce(OMAP3_EVM_TS_GPIO, 1); |
| 243 | omap_set_gpio_debounce_time(OMAP3_EVM_TS_GPIO, 0xa); |
| 244 | } |
| 245 | |
| 246 | static int ads7846_get_pendown_state(void) |
| 247 | { |
| 248 | return !gpio_get_value(OMAP3_EVM_TS_GPIO); |
| 249 | } |
| 250 | |
| 251 | struct ads7846_platform_data ads7846_config = { |
| 252 | .x_max = 0x0fff, |
| 253 | .y_max = 0x0fff, |
| 254 | .x_plate_ohms = 180, |
| 255 | .pressure_max = 255, |
| 256 | .debounce_max = 10, |
| 257 | .debounce_tol = 3, |
| 258 | .debounce_rep = 1, |
| 259 | .get_pendown_state = ads7846_get_pendown_state, |
| 260 | .keep_vref_on = 1, |
| 261 | .settle_delay_usecs = 150, |
| 262 | }; |
| 263 | |
| 264 | static struct omap2_mcspi_device_config ads7846_mcspi_config = { |
| 265 | .turbo_mode = 0, |
| 266 | .single_channel = 1, /* 0: slave, 1: master */ |
| 267 | }; |
| 268 | |
| 269 | struct spi_board_info omap3evm_spi_board_info[] = { |
| 270 | [0] = { |
| 271 | .modalias = "ads7846", |
| 272 | .bus_num = 1, |
| 273 | .chip_select = 0, |
| 274 | .max_speed_hz = 1500000, |
| 275 | .controller_data = &ads7846_mcspi_config, |
| 276 | .irq = OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO), |
| 277 | .platform_data = &ads7846_config, |
| 278 | }, |
| 279 | }; |
| 280 | |
Paul Walmsley | b3c6df3 | 2009-09-03 20:14:02 +0300 | [diff] [blame] | 281 | static struct omap_board_config_kernel omap3_evm_config[] __initdata = { |
| 282 | { OMAP_TAG_LCD, &omap3_evm_lcd_config }, |
| 283 | }; |
| 284 | |
Syed Mohammed Khasim | 53c5ec3 | 2009-05-28 14:13:28 -0700 | [diff] [blame] | 285 | static void __init omap3_evm_init_irq(void) |
| 286 | { |
Paul Walmsley | b3c6df3 | 2009-09-03 20:14:02 +0300 | [diff] [blame] | 287 | omap_board_config = omap3_evm_config; |
| 288 | omap_board_config_size = ARRAY_SIZE(omap3_evm_config); |
Jean Pihet | 58cda88 | 2009-07-24 19:43:25 -0600 | [diff] [blame] | 289 | omap2_init_common_hw(mt46h32m32lf6_sdrc_params, NULL); |
Syed Mohammed Khasim | 53c5ec3 | 2009-05-28 14:13:28 -0700 | [diff] [blame] | 290 | omap_init_irq(); |
| 291 | omap_gpio_init(); |
| 292 | omap3evm_init_smc911x(); |
| 293 | } |
| 294 | |
Syed Mohammed Khasim | 53c5ec3 | 2009-05-28 14:13:28 -0700 | [diff] [blame] | 295 | static struct platform_device *omap3_evm_devices[] __initdata = { |
| 296 | &omap3_evm_lcd_device, |
| 297 | &omap3evm_smc911x_device, |
| 298 | }; |
| 299 | |
| 300 | static void __init omap3_evm_init(void) |
| 301 | { |
| 302 | omap3_evm_i2c_init(); |
| 303 | |
| 304 | platform_add_devices(omap3_evm_devices, ARRAY_SIZE(omap3_evm_devices)); |
Syed Mohammed Khasim | 53c5ec3 | 2009-05-28 14:13:28 -0700 | [diff] [blame] | 305 | |
| 306 | spi_register_board_info(omap3evm_spi_board_info, |
| 307 | ARRAY_SIZE(omap3evm_spi_board_info)); |
| 308 | |
| 309 | omap_serial_init(); |
Gupta, Ajay Kumar | e8e2ff4 | 2009-07-29 11:58:57 +0530 | [diff] [blame] | 310 | #ifdef CONFIG_NOP_USB_XCEIV |
| 311 | /* OMAP3EVM uses ISP1504 phy and so register nop transceiver */ |
| 312 | usb_nop_xceiv_register(); |
| 313 | #endif |
Syed Mohammed Khasim | 53c5ec3 | 2009-05-28 14:13:28 -0700 | [diff] [blame] | 314 | usb_musb_init(); |
| 315 | ads7846_dev_init(); |
| 316 | } |
| 317 | |
| 318 | static void __init omap3_evm_map_io(void) |
| 319 | { |
| 320 | omap2_set_globals_343x(); |
| 321 | omap2_map_common_io(); |
| 322 | } |
| 323 | |
| 324 | MACHINE_START(OMAP3EVM, "OMAP3 EVM") |
| 325 | /* Maintainer: Syed Mohammed Khasim - Texas Instruments */ |
| 326 | .phys_io = 0x48000000, |
Santosh Shilimkar | b4224b2 | 2009-10-19 17:25:55 -0700 | [diff] [blame] | 327 | .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc, |
Syed Mohammed Khasim | 53c5ec3 | 2009-05-28 14:13:28 -0700 | [diff] [blame] | 328 | .boot_params = 0x80000100, |
| 329 | .map_io = omap3_evm_map_io, |
| 330 | .init_irq = omap3_evm_init_irq, |
| 331 | .init_machine = omap3_evm_init, |
| 332 | .timer = &omap_timer, |
| 333 | MACHINE_END |