Staging: hv: remove OnChildDeviceAdd vmbus_driver callback
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-omap2 / board-omap3stalker.c
blobf2527212541347afc144cc1c2df375304c6ce6a1
1 /*
2 * linux/arch/arm/mach-omap2/board-omap3evm.c
4 * Copyright (C) 2008 Guangzhou EMA-Tech
6 * Modified from mach-omap2/board-omap3evm.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/err.h>
20 #include <linux/clk.h>
21 #include <linux/io.h>
22 #include <linux/leds.h>
23 #include <linux/gpio.h>
24 #include <linux/input.h>
25 #include <linux/gpio_keys.h>
27 #include <linux/regulator/machine.h>
28 #include <linux/i2c/twl.h>
29 #include <linux/mmc/host.h>
31 #include <mach/hardware.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
35 #include <asm/mach/flash.h>
37 #include <plat/board.h>
38 #include <plat/common.h>
39 #include <plat/gpmc.h>
40 #include <plat/nand.h>
41 #include <plat/usb.h>
42 #include <plat/display.h>
44 #include <plat/mcspi.h>
45 #include <linux/input/matrix_keypad.h>
46 #include <linux/spi/spi.h>
47 #include <linux/spi/ads7846.h>
48 #include <linux/interrupt.h>
49 #include <linux/smsc911x.h>
50 #include <linux/i2c/at24.h>
52 #include "sdram-micron-mt46h32m32lf-6.h"
53 #include "mux.h"
54 #include "hsmmc.h"
55 #include "timer-gp.h"
57 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
58 #define OMAP3STALKER_ETHR_START 0x2c000000
59 #define OMAP3STALKER_ETHR_SIZE 1024
60 #define OMAP3STALKER_ETHR_GPIO_IRQ 19
61 #define OMAP3STALKER_SMC911X_CS 5
63 static struct resource omap3stalker_smsc911x_resources[] = {
64 [0] = {
65 .start = OMAP3STALKER_ETHR_START,
66 .end =
67 (OMAP3STALKER_ETHR_START + OMAP3STALKER_ETHR_SIZE - 1),
68 .flags = IORESOURCE_MEM,
70 [1] = {
71 .start = OMAP_GPIO_IRQ(OMAP3STALKER_ETHR_GPIO_IRQ),
72 .end = OMAP_GPIO_IRQ(OMAP3STALKER_ETHR_GPIO_IRQ),
73 .flags = (IORESOURCE_IRQ | IRQF_TRIGGER_LOW),
77 static struct smsc911x_platform_config smsc911x_config = {
78 .phy_interface = PHY_INTERFACE_MODE_MII,
79 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
80 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
81 .flags = (SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS),
84 static struct platform_device omap3stalker_smsc911x_device = {
85 .name = "smsc911x",
86 .id = -1,
87 .num_resources = ARRAY_SIZE(omap3stalker_smsc911x_resources),
88 .resource = &omap3stalker_smsc911x_resources[0],
89 .dev = {
90 .platform_data = &smsc911x_config,
94 static inline void __init omap3stalker_init_eth(void)
96 int eth_cs;
97 struct clk *l3ck;
98 unsigned int rate;
100 eth_cs = OMAP3STALKER_SMC911X_CS;
102 l3ck = clk_get(NULL, "l3_ck");
103 if (IS_ERR(l3ck))
104 rate = 100000000;
105 else
106 rate = clk_get_rate(l3ck);
108 omap_mux_init_gpio(19, OMAP_PIN_INPUT_PULLUP);
109 if (gpio_request(OMAP3STALKER_ETHR_GPIO_IRQ, "SMC911x irq") < 0) {
110 printk(KERN_ERR
111 "Failed to request GPIO%d for smc911x IRQ\n",
112 OMAP3STALKER_ETHR_GPIO_IRQ);
113 return;
116 gpio_direction_input(OMAP3STALKER_ETHR_GPIO_IRQ);
118 platform_device_register(&omap3stalker_smsc911x_device);
121 #else
122 static inline void __init omap3stalker_init_eth(void)
124 return;
126 #endif
129 * OMAP3 DSS control signals
132 #define DSS_ENABLE_GPIO 199
133 #define LCD_PANEL_BKLIGHT_GPIO 210
134 #define ENABLE_VPLL2_DEV_GRP 0xE0
136 static int lcd_enabled;
137 static int dvi_enabled;
139 static void __init omap3_stalker_display_init(void)
141 return;
144 static int omap3_stalker_enable_lcd(struct omap_dss_device *dssdev)
146 if (dvi_enabled) {
147 printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
148 return -EINVAL;
150 gpio_set_value(DSS_ENABLE_GPIO, 1);
151 gpio_set_value(LCD_PANEL_BKLIGHT_GPIO, 1);
152 lcd_enabled = 1;
153 return 0;
156 static void omap3_stalker_disable_lcd(struct omap_dss_device *dssdev)
158 gpio_set_value(DSS_ENABLE_GPIO, 0);
159 gpio_set_value(LCD_PANEL_BKLIGHT_GPIO, 0);
160 lcd_enabled = 0;
163 static struct omap_dss_device omap3_stalker_lcd_device = {
164 .name = "lcd",
165 .driver_name = "generic_panel",
166 .phy.dpi.data_lines = 24,
167 .type = OMAP_DISPLAY_TYPE_DPI,
168 .platform_enable = omap3_stalker_enable_lcd,
169 .platform_disable = omap3_stalker_disable_lcd,
172 static int omap3_stalker_enable_tv(struct omap_dss_device *dssdev)
174 return 0;
177 static void omap3_stalker_disable_tv(struct omap_dss_device *dssdev)
181 static struct omap_dss_device omap3_stalker_tv_device = {
182 .name = "tv",
183 .driver_name = "venc",
184 .type = OMAP_DISPLAY_TYPE_VENC,
185 #if defined(CONFIG_OMAP2_VENC_OUT_TYPE_SVIDEO)
186 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
187 #elif defined(CONFIG_OMAP2_VENC_OUT_TYPE_COMPOSITE)
188 .u.venc.type = OMAP_DSS_VENC_TYPE_COMPOSITE,
189 #endif
190 .platform_enable = omap3_stalker_enable_tv,
191 .platform_disable = omap3_stalker_disable_tv,
194 static int omap3_stalker_enable_dvi(struct omap_dss_device *dssdev)
196 if (lcd_enabled) {
197 printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
198 return -EINVAL;
200 gpio_set_value(DSS_ENABLE_GPIO, 1);
201 dvi_enabled = 1;
202 return 0;
205 static void omap3_stalker_disable_dvi(struct omap_dss_device *dssdev)
207 gpio_set_value(DSS_ENABLE_GPIO, 0);
208 dvi_enabled = 0;
211 static struct omap_dss_device omap3_stalker_dvi_device = {
212 .name = "dvi",
213 .driver_name = "generic_panel",
214 .type = OMAP_DISPLAY_TYPE_DPI,
215 .phy.dpi.data_lines = 24,
216 .platform_enable = omap3_stalker_enable_dvi,
217 .platform_disable = omap3_stalker_disable_dvi,
220 static struct omap_dss_device *omap3_stalker_dss_devices[] = {
221 &omap3_stalker_lcd_device,
222 &omap3_stalker_tv_device,
223 &omap3_stalker_dvi_device,
226 static struct omap_dss_board_info omap3_stalker_dss_data = {
227 .num_devices = ARRAY_SIZE(omap3_stalker_dss_devices),
228 .devices = omap3_stalker_dss_devices,
229 .default_device = &omap3_stalker_dvi_device,
232 static struct platform_device omap3_stalker_dss_device = {
233 .name = "omapdss",
234 .id = -1,
235 .dev = {
236 .platform_data = &omap3_stalker_dss_data,
240 static struct regulator_consumer_supply omap3stalker_vmmc1_supply = {
241 .supply = "vmmc",
244 static struct regulator_consumer_supply omap3stalker_vsim_supply = {
245 .supply = "vmmc_aux",
248 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
249 static struct regulator_init_data omap3stalker_vmmc1 = {
250 .constraints = {
251 .min_uV = 1850000,
252 .max_uV = 3150000,
253 .valid_modes_mask = REGULATOR_MODE_NORMAL
254 | REGULATOR_MODE_STANDBY,
255 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
256 | REGULATOR_CHANGE_MODE | REGULATOR_CHANGE_STATUS,
258 .num_consumer_supplies = 1,
259 .consumer_supplies = &omap3stalker_vmmc1_supply,
262 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
263 static struct regulator_init_data omap3stalker_vsim = {
264 .constraints = {
265 .min_uV = 1800000,
266 .max_uV = 3000000,
267 .valid_modes_mask = REGULATOR_MODE_NORMAL
268 | REGULATOR_MODE_STANDBY,
269 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
270 | REGULATOR_CHANGE_MODE | REGULATOR_CHANGE_STATUS,
272 .num_consumer_supplies = 1,
273 .consumer_supplies = &omap3stalker_vsim_supply,
276 static struct omap2_hsmmc_info mmc[] = {
278 .mmc = 1,
279 .caps = MMC_CAP_4_BIT_DATA,
280 .gpio_cd = -EINVAL,
281 .gpio_wp = 23,
283 {} /* Terminator */
286 static struct gpio_keys_button gpio_buttons[] = {
288 .code = BTN_EXTRA,
289 .gpio = 18,
290 .desc = "user",
291 .wakeup = 1,
295 static struct gpio_keys_platform_data gpio_key_info = {
296 .buttons = gpio_buttons,
297 .nbuttons = ARRAY_SIZE(gpio_buttons),
300 static struct platform_device keys_gpio = {
301 .name = "gpio-keys",
302 .id = -1,
303 .dev = {
304 .platform_data = &gpio_key_info,
308 static struct gpio_led gpio_leds[] = {
310 .name = "stalker:D8:usr0",
311 .default_trigger = "default-on",
312 .gpio = 126,
315 .name = "stalker:D9:usr1",
316 .default_trigger = "default-on",
317 .gpio = 127,
320 .name = "stalker:D3:mmc0",
321 .gpio = -EINVAL, /* gets replaced */
322 .active_low = true,
323 .default_trigger = "mmc0",
326 .name = "stalker:D4:heartbeat",
327 .gpio = -EINVAL, /* gets replaced */
328 .active_low = true,
329 .default_trigger = "heartbeat",
333 static struct gpio_led_platform_data gpio_led_info = {
334 .leds = gpio_leds,
335 .num_leds = ARRAY_SIZE(gpio_leds),
338 static struct platform_device leds_gpio = {
339 .name = "leds-gpio",
340 .id = -1,
341 .dev = {
342 .platform_data = &gpio_led_info,
346 static int
347 omap3stalker_twl_gpio_setup(struct device *dev,
348 unsigned gpio, unsigned ngpio)
350 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
351 omap_mux_init_gpio(23, OMAP_PIN_INPUT);
352 mmc[0].gpio_cd = gpio + 0;
353 omap2_hsmmc_init(mmc);
355 /* link regulators to MMC adapters */
356 omap3stalker_vmmc1_supply.dev = mmc[0].dev;
357 omap3stalker_vsim_supply.dev = mmc[0].dev;
360 * Most GPIOs are for USB OTG. Some are mostly sent to
361 * the P2 connector; notably LEDA for the LCD backlight.
364 /* TWL4030_GPIO_MAX + 0 == ledA, LCD Backlight control */
365 gpio_request(gpio + TWL4030_GPIO_MAX, "EN_LCD_BKL");
366 gpio_direction_output(gpio + TWL4030_GPIO_MAX, 0);
368 /* gpio + 7 == DVI Enable */
369 gpio_request(gpio + 7, "EN_DVI");
370 gpio_direction_output(gpio + 7, 0);
372 /* TWL4030_GPIO_MAX + 1 == ledB (out, mmc0) */
373 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
374 /* GPIO + 13 == ledsync (out, heartbeat) */
375 gpio_leds[3].gpio = gpio + 13;
377 platform_device_register(&leds_gpio);
378 return 0;
381 static struct twl4030_gpio_platform_data omap3stalker_gpio_data = {
382 .gpio_base = OMAP_MAX_GPIO_LINES,
383 .irq_base = TWL4030_GPIO_IRQ_BASE,
384 .irq_end = TWL4030_GPIO_IRQ_END,
385 .use_leds = true,
386 .setup = omap3stalker_twl_gpio_setup,
389 static struct twl4030_usb_data omap3stalker_usb_data = {
390 .usb_mode = T2_USB_MODE_ULPI,
393 static uint32_t board_keymap[] = {
394 KEY(0, 0, KEY_LEFT),
395 KEY(0, 1, KEY_DOWN),
396 KEY(0, 2, KEY_ENTER),
397 KEY(0, 3, KEY_M),
399 KEY(1, 0, KEY_RIGHT),
400 KEY(1, 1, KEY_UP),
401 KEY(1, 2, KEY_I),
402 KEY(1, 3, KEY_N),
404 KEY(2, 0, KEY_A),
405 KEY(2, 1, KEY_E),
406 KEY(2, 2, KEY_J),
407 KEY(2, 3, KEY_O),
409 KEY(3, 0, KEY_B),
410 KEY(3, 1, KEY_F),
411 KEY(3, 2, KEY_K),
412 KEY(3, 3, KEY_P)
415 static struct matrix_keymap_data board_map_data = {
416 .keymap = board_keymap,
417 .keymap_size = ARRAY_SIZE(board_keymap),
420 static struct twl4030_keypad_data omap3stalker_kp_data = {
421 .keymap_data = &board_map_data,
422 .rows = 4,
423 .cols = 4,
424 .rep = 1,
427 static struct twl4030_madc_platform_data omap3stalker_madc_data = {
428 .irq_line = 1,
431 static struct twl4030_codec_audio_data omap3stalker_audio_data = {
432 .audio_mclk = 26000000,
435 static struct twl4030_codec_data omap3stalker_codec_data = {
436 .audio_mclk = 26000000,
437 .audio = &omap3stalker_audio_data,
440 static struct regulator_consumer_supply omap3_stalker_vdda_dac_supply = {
441 .supply = "vdda_dac",
442 .dev = &omap3_stalker_dss_device.dev,
445 /* VDAC for DSS driving S-Video */
446 static struct regulator_init_data omap3_stalker_vdac = {
447 .constraints = {
448 .min_uV = 1800000,
449 .max_uV = 1800000,
450 .apply_uV = true,
451 .valid_modes_mask = REGULATOR_MODE_NORMAL
452 | REGULATOR_MODE_STANDBY,
453 .valid_ops_mask = REGULATOR_CHANGE_MODE
454 | REGULATOR_CHANGE_STATUS,
456 .num_consumer_supplies = 1,
457 .consumer_supplies = &omap3_stalker_vdda_dac_supply,
460 /* VPLL2 for digital video outputs */
461 static struct regulator_consumer_supply omap3_stalker_vpll2_supply = {
462 .supply = "vdds_dsi",
463 .dev = &omap3_stalker_lcd_device.dev,
466 static struct regulator_init_data omap3_stalker_vpll2 = {
467 .constraints = {
468 .name = "VDVI",
469 .min_uV = 1800000,
470 .max_uV = 1800000,
471 .apply_uV = true,
472 .valid_modes_mask = REGULATOR_MODE_NORMAL
473 | REGULATOR_MODE_STANDBY,
474 .valid_ops_mask = REGULATOR_CHANGE_MODE
475 | REGULATOR_CHANGE_STATUS,
477 .num_consumer_supplies = 1,
478 .consumer_supplies = &omap3_stalker_vpll2_supply,
481 static struct twl4030_platform_data omap3stalker_twldata = {
482 .irq_base = TWL4030_IRQ_BASE,
483 .irq_end = TWL4030_IRQ_END,
485 /* platform_data for children goes here */
486 .keypad = &omap3stalker_kp_data,
487 .madc = &omap3stalker_madc_data,
488 .usb = &omap3stalker_usb_data,
489 .gpio = &omap3stalker_gpio_data,
490 .codec = &omap3stalker_codec_data,
491 .vdac = &omap3_stalker_vdac,
492 .vpll2 = &omap3_stalker_vpll2,
495 static struct i2c_board_info __initdata omap3stalker_i2c_boardinfo[] = {
497 I2C_BOARD_INFO("twl4030", 0x48),
498 .flags = I2C_CLIENT_WAKE,
499 .irq = INT_34XX_SYS_NIRQ,
500 .platform_data = &omap3stalker_twldata,
504 static struct at24_platform_data fram_info = {
505 .byte_len = (64 * 1024) / 8,
506 .page_size = 8192,
507 .flags = AT24_FLAG_ADDR16 | AT24_FLAG_IRUGO,
510 static struct i2c_board_info __initdata omap3stalker_i2c_boardinfo3[] = {
512 I2C_BOARD_INFO("24c64", 0x50),
513 .flags = I2C_CLIENT_WAKE,
514 .platform_data = &fram_info,
518 static int __init omap3_stalker_i2c_init(void)
521 * REVISIT: These entries can be set in omap3evm_twl_data
522 * after a merge with MFD tree
524 omap3stalker_twldata.vmmc1 = &omap3stalker_vmmc1;
525 omap3stalker_twldata.vsim = &omap3stalker_vsim;
527 omap_register_i2c_bus(1, 2600, omap3stalker_i2c_boardinfo,
528 ARRAY_SIZE(omap3stalker_i2c_boardinfo));
529 omap_register_i2c_bus(2, 400, NULL, 0);
530 omap_register_i2c_bus(3, 400, omap3stalker_i2c_boardinfo3,
531 ARRAY_SIZE(omap3stalker_i2c_boardinfo3));
532 return 0;
535 #define OMAP3_STALKER_TS_GPIO 175
536 static void ads7846_dev_init(void)
538 if (gpio_request(OMAP3_STALKER_TS_GPIO, "ADS7846 pendown") < 0)
539 printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
541 gpio_direction_input(OMAP3_STALKER_TS_GPIO);
542 gpio_set_debounce(OMAP3_STALKER_TS_GPIO, 310);
545 static int ads7846_get_pendown_state(void)
547 return !gpio_get_value(OMAP3_STALKER_TS_GPIO);
550 static struct ads7846_platform_data ads7846_config = {
551 .x_max = 0x0fff,
552 .y_max = 0x0fff,
553 .x_plate_ohms = 180,
554 .pressure_max = 255,
555 .debounce_max = 10,
556 .debounce_tol = 3,
557 .debounce_rep = 1,
558 .get_pendown_state = ads7846_get_pendown_state,
559 .keep_vref_on = 1,
560 .settle_delay_usecs = 150,
563 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
564 .turbo_mode = 0,
565 .single_channel = 1, /* 0: slave, 1: master */
568 static struct spi_board_info omap3stalker_spi_board_info[] = {
569 [0] = {
570 .modalias = "ads7846",
571 .bus_num = 1,
572 .chip_select = 0,
573 .max_speed_hz = 1500000,
574 .controller_data = &ads7846_mcspi_config,
575 .irq = OMAP_GPIO_IRQ(OMAP3_STALKER_TS_GPIO),
576 .platform_data = &ads7846_config,
580 static struct omap_board_config_kernel omap3_stalker_config[] __initdata = {
583 static void __init omap3_stalker_init_irq(void)
585 omap_board_config = omap3_stalker_config;
586 omap_board_config_size = ARRAY_SIZE(omap3_stalker_config);
587 omap2_init_common_hw(mt46h32m32lf6_sdrc_params, NULL);
588 omap_init_irq();
589 #ifdef CONFIG_OMAP_32K_TIMER
590 omap2_gp_clockevent_set_gptimer(12);
591 #endif
592 omap_gpio_init();
595 static struct platform_device *omap3_stalker_devices[] __initdata = {
596 &omap3_stalker_dss_device,
597 &keys_gpio,
600 static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
601 .port_mode[0] = EHCI_HCD_OMAP_MODE_UNKNOWN,
602 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
603 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
605 .phy_reset = true,
606 .reset_gpio_port[0] = -EINVAL,
607 .reset_gpio_port[1] = 21,
608 .reset_gpio_port[2] = -EINVAL,
611 #ifdef CONFIG_OMAP_MUX
612 static struct omap_board_mux board_mux[] __initdata = {
613 OMAP3_MUX(SYS_NIRQ, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP |
614 OMAP_PIN_OFF_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE),
615 OMAP3_MUX(MCSPI1_CS1, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP |
616 OMAP_PIN_OFF_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE),
617 {.reg_offset = OMAP_MUX_TERMINATOR},
619 #else
620 #define board_mux NULL
621 #endif
623 static struct omap_musb_board_data musb_board_data = {
624 .interface_type = MUSB_INTERFACE_ULPI,
625 .mode = MUSB_OTG,
626 .power = 100,
629 static void __init omap3_stalker_init(void)
631 omap3_mux_init(board_mux, OMAP_PACKAGE_CUS);
633 omap3_stalker_i2c_init();
635 platform_add_devices(omap3_stalker_devices,
636 ARRAY_SIZE(omap3_stalker_devices));
638 spi_register_board_info(omap3stalker_spi_board_info,
639 ARRAY_SIZE(omap3stalker_spi_board_info));
641 omap_serial_init();
642 usb_musb_init(&musb_board_data);
643 usb_ehci_init(&ehci_pdata);
644 ads7846_dev_init();
646 omap_mux_init_gpio(21, OMAP_PIN_OUTPUT);
647 omap_mux_init_gpio(18, OMAP_PIN_INPUT_PULLUP);
649 omap3stalker_init_eth();
650 omap3_stalker_display_init();
651 /* Ensure SDRC pins are mux'd for self-refresh */
652 omap_mux_init_signal("sdr_cke0", OMAP_PIN_OUTPUT);
653 omap_mux_init_signal("sdr_cke1", OMAP_PIN_OUTPUT);
656 MACHINE_START(SBC3530, "OMAP3 STALKER")
657 /* Maintainer: Jason Lam -lzg@ema-tech.com */
658 .boot_params = 0x80000100,
659 .map_io = omap3_map_io,
660 .init_irq = omap3_stalker_init_irq,
661 .init_machine = omap3_stalker_init,
662 .timer = &omap_timer,
663 MACHINE_END