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/spi/spi.h>
24 #include <linux/spi/ads7846.h>
25 #include <linux/i2c/twl4030.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/common.h>
40 #include <mach/gpmc.h>
43 #include <asm/delay.h>
44 #include <mach/control.h>
46 #include "sdram-qimonda-hyb18m512160af-6.h"
47 #include "mmc-twl4030.h"
49 #define CONFIG_DISABLE_HFCLK 1
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 twl4030_keypad_data sdp3430_kp_data = {
116 .keymap = sdp3430_keymap,
117 .keymapsize = ARRAY_SIZE(sdp3430_keymap),
123 static int __init msecure_init(void)
127 #ifdef CONFIG_RTC_DRV_TWL4030
128 /* 3430ES2.0 doesn't have msecure/gpio-22 line connected to T2 */
129 if (omap_type() == OMAP2_DEVICE_TYPE_GP &&
130 omap_rev() < OMAP3430_REV_ES2_0) {
131 void __iomem *msecure_pad_config_reg = omap_ctrl_base_get() +
136 ret = gpio_request(TWL4030_MSECURE_GPIO, "msecure");
138 printk(KERN_ERR "msecure_init: can't"
139 "reserve GPIO:%d !\n", TWL4030_MSECURE_GPIO);
143 * TWL4030 will be in secure mode if msecure line from OMAP
144 * is low. Make msecure line high in order to change the
145 * TWL4030 RTC time and calender registers.
147 tmp = __raw_readw(msecure_pad_config_reg);
148 tmp &= 0xF8; /* To enable mux mode 03/04 = GPIO_RTC */
149 tmp |= mux_mask;/* To enable mux mode 03/04 = GPIO_RTC */
150 __raw_writew(tmp, msecure_pad_config_reg);
152 gpio_direction_output(TWL4030_MSECURE_GPIO, 1);
160 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
162 * @return - void. If request gpio fails then Flag KERN_ERR.
164 static void ads7846_dev_init(void)
166 if (gpio_request(ts_gpio, "ADS7846 pendown") < 0) {
167 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
171 gpio_direction_input(ts_gpio);
173 omap_set_gpio_debounce(ts_gpio, 1);
174 omap_set_gpio_debounce_time(ts_gpio, 0xa);
177 static int ads7846_get_pendown_state(void)
179 return !gpio_get_value(ts_gpio);
183 * This enable(1)/disable(0) the voltage for TS: uses twl4030 calls
185 static int ads7846_vaux_control(int vaux_cntrl)
189 #ifdef CONFIG_TWL4030_CORE
190 /* check for return value of ldo_use: if success it returns 0 */
191 if (vaux_cntrl == VAUX_ENABLE) {
192 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
193 ENABLE_VAUX3_DEDICATED, TWL4030_VAUX3_DEDICATED))
195 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
196 ENABLE_VAUX3_DEV_GRP, TWL4030_VAUX3_DEV_GRP))
198 } else if (vaux_cntrl == VAUX_DISABLE) {
199 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
200 0x00, TWL4030_VAUX3_DEDICATED))
202 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
203 0x00, TWL4030_VAUX3_DEV_GRP))
212 static struct ads7846_platform_data tsc2046_config __initdata = {
213 .get_pendown_state = ads7846_get_pendown_state,
215 .vaux_control = ads7846_vaux_control,
219 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
221 .single_channel = 1, /* 0: slave, 1: master */
224 static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
227 * TSC2046 operates at a max freqency of 2MHz, so
228 * operate slightly below at 1.5MHz
230 .modalias = "ads7846",
233 .max_speed_hz = 1500000,
234 .controller_data = &tsc2046_mcspi_config,
236 .platform_data = &tsc2046_config,
240 static struct platform_device sdp3430_lcd_device = {
241 .name = "sdp2430_lcd",
245 static struct platform_device *sdp3430_devices[] __initdata = {
246 &sdp3430_smc91x_device,
250 static inline void __init sdp3430_init_smc91x(void)
253 unsigned long cs_mem_base;
256 eth_cs = SDP3430_SMC91X_CS;
258 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
259 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
263 sdp3430_smc91x_resources[0].start = cs_mem_base + 0x0;
264 sdp3430_smc91x_resources[0].end = cs_mem_base + 0xf;
267 if (omap_rev() > OMAP3430_REV_ES1_0)
268 eth_gpio = OMAP34XX_ETHR_GPIO_IRQ_SDPV2;
270 eth_gpio = OMAP34XX_ETHR_GPIO_IRQ_SDPV1;
272 sdp3430_smc91x_resources[1].start = gpio_to_irq(eth_gpio);
274 if (gpio_request(eth_gpio, "SMC91x irq") < 0) {
275 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
279 gpio_direction_input(eth_gpio);
282 static void __init omap_3430sdp_init_irq(void)
284 omap2_init_common_hw(hyb18m512160af6_sdrc_params);
287 sdp3430_init_smc91x();
290 static struct omap_uart_config sdp3430_uart_config __initdata = {
291 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
294 static struct omap_lcd_config sdp3430_lcd_config __initdata = {
295 .ctrl_name = "internal",
298 static struct omap_board_config_kernel sdp3430_config[] __initdata = {
299 { OMAP_TAG_UART, &sdp3430_uart_config },
300 { OMAP_TAG_LCD, &sdp3430_lcd_config },
303 static int sdp3430_batt_table[] = {
305 30800, 29500, 28300, 27100,
306 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
307 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
308 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
309 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
310 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
311 4040, 3910, 3790, 3670, 3550
314 static struct twl4030_bci_platform_data sdp3430_bci_data = {
315 .battery_tmp_tbl = sdp3430_batt_table,
316 .tblsize = ARRAY_SIZE(sdp3430_batt_table),
319 static struct twl4030_gpio_platform_data sdp3430_gpio_data = {
320 .gpio_base = OMAP_MAX_GPIO_LINES,
321 .irq_base = TWL4030_GPIO_IRQ_BASE,
322 .irq_end = TWL4030_GPIO_IRQ_END,
325 static struct twl4030_usb_data sdp3430_usb_data = {
326 .usb_mode = T2_USB_MODE_ULPI,
329 static struct twl4030_madc_platform_data sdp3430_madc_data = {
334 static struct twl4030_ins __initdata sleep_on_seq[] = {
336 * Turn off VDD1 and VDD2.
338 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 4},
339 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2},
340 #ifdef CONFIG_DISABLE_HFCLK
342 * And also turn off the OMAP3 PLLs and the sysclk output.
344 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_OFF), 3},
345 {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_OFF), 3},
349 static struct twl4030_script sleep_on_script __initdata = {
350 .script = sleep_on_seq,
351 .size = ARRAY_SIZE(sleep_on_seq),
352 .flags = TRITON_SLEEP_SCRIPT,
355 static struct twl4030_ins wakeup_seq[] __initdata = {
356 #ifndef CONFIG_DISABLE_HFCLK
358 * Wakeup VDD1 and VDD2.
360 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 4},
361 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 2},
364 * Reenable the OMAP3 PLLs.
365 * Wakeup VDD1 and VDD2.
366 * Reenable sysclk output.
368 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_ACTIVE), 0x30},
369 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 0x30},
370 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 0x37},
371 {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 3},
372 #endif /* #ifndef CONFIG_DISABLE_HFCLK */
375 static struct twl4030_script wakeup_script __initdata = {
376 .script = wakeup_seq,
377 .size = ARRAY_SIZE(wakeup_seq),
378 .flags = TRITON_WAKEUP12_SCRIPT | TRITON_WAKEUP3_SCRIPT,
381 static struct twl4030_ins wrst_seq[] __initdata = {
384 * Reset VDD1 regulator.
385 * Reset VDD2 regulator.
386 * Reset VPLL1 regulator.
387 * Enable sysclk output.
390 {MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_OFF), 2},
391 {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_WRST), 15},
392 {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_WRST), 15},
393 {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_WRST), 0x60},
394 {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2},
395 {MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_ACTIVE), 2},
397 static struct twl4030_script wrst_script __initdata = {
399 .size = ARRAY_SIZE(wakeup_seq),
400 .flags = TRITON_WRST_SCRIPT,
403 static struct twl4030_script *twl4030_scripts[] __initdata = {
409 static struct twl4030_power_data sdp3430_t2scripts_data __initdata = {
410 .scripts = twl4030_scripts,
411 .size = ARRAY_SIZE(twl4030_scripts),
414 static struct twl4030_platform_data sdp3430_twldata = {
415 .irq_base = TWL4030_IRQ_BASE,
416 .irq_end = TWL4030_IRQ_END,
418 /* platform_data for children goes here */
419 .bci = &sdp3430_bci_data,
420 .gpio = &sdp3430_gpio_data,
421 .madc = &sdp3430_madc_data,
422 .keypad = &sdp3430_kp_data,
423 .power = &sdp3430_t2scripts_data,
424 .usb = &sdp3430_usb_data,
427 static struct i2c_board_info __initdata sdp3430_i2c_boardinfo[] = {
429 I2C_BOARD_INFO("twl4030", 0x48),
430 .flags = I2C_CLIENT_WAKE,
431 .irq = INT_34XX_SYS_NIRQ,
432 .platform_data = &sdp3430_twldata,
436 static int __init omap3430_i2c_init(void)
438 omap_register_i2c_bus(1, 2600, sdp3430_i2c_boardinfo,
439 ARRAY_SIZE(sdp3430_i2c_boardinfo));
440 omap_register_i2c_bus(2, 400, NULL, 0);
441 omap_register_i2c_bus(3, 400, NULL, 0);
445 static struct twl4030_hsmmc_info mmc[] __initdata = {
461 extern void __init sdp3430_flash_init(void);
463 static void __init omap_3430sdp_init(void)
466 platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
467 omap_board_config = sdp3430_config;
468 omap_board_config_size = ARRAY_SIZE(sdp3430_config);
469 if (omap_rev() > OMAP3430_REV_ES1_0)
470 ts_gpio = OMAP34XX_TS_GPIO_IRQ_SDPV2;
472 ts_gpio = OMAP34XX_TS_GPIO_IRQ_SDPV1;
473 sdp3430_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
474 spi_register_board_info(sdp3430_spi_board_info,
475 ARRAY_SIZE(sdp3430_spi_board_info));
477 sdp3430_flash_init();
482 twl4030_mmc_init(mmc);
485 static void __init omap_3430sdp_map_io(void)
487 omap2_set_globals_343x();
488 omap2_map_common_io();
491 MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
492 /* Maintainer: Syed Khasim - Texas Instruments Inc */
493 .phys_io = 0x48000000,
494 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
495 .boot_params = 0x80000100,
496 .map_io = omap_3430sdp_map_io,
497 .init_irq = omap_3430sdp_init_irq,
498 .init_machine = omap_3430sdp_init,
499 .timer = &omap_timer,