ARM: OMAP2: use early init hook
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-omap2 / board-4430sdp.c
blob12d99e582cd651864b289ed70df1131191f5a488
1 /*
2 * Board support file for OMAP4430 SDP.
4 * Copyright (C) 2009 Texas Instruments
6 * Author: Santosh Shilimkar <santosh.shilimkar@ti.com>
8 * Based on mach-omap2/board-3430sdp.c
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/io.h>
19 #include <linux/gpio.h>
20 #include <linux/usb/otg.h>
21 #include <linux/spi/spi.h>
22 #include <linux/i2c/twl.h>
23 #include <linux/gpio_keys.h>
24 #include <linux/regulator/machine.h>
25 #include <linux/leds.h>
26 #include <linux/leds_pwm.h>
28 #include <mach/hardware.h>
29 #include <mach/omap4-common.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
34 #include <plat/board.h>
35 #include <plat/common.h>
36 #include <plat/usb.h>
37 #include <plat/mmc.h>
39 #include "mux.h"
40 #include "hsmmc.h"
41 #include "timer-gp.h"
42 #include "control.h"
44 #define ETH_KS8851_IRQ 34
45 #define ETH_KS8851_POWER_ON 48
46 #define ETH_KS8851_QUART 138
47 #define OMAP4SDP_MDM_PWR_EN_GPIO 157
48 #define OMAP4_SFH7741_SENSOR_OUTPUT_GPIO 184
49 #define OMAP4_SFH7741_ENABLE_GPIO 188
51 static struct gpio_led sdp4430_gpio_leds[] = {
53 .name = "omap4:green:debug0",
54 .gpio = 61,
57 .name = "omap4:green:debug1",
58 .gpio = 30,
61 .name = "omap4:green:debug2",
62 .gpio = 7,
65 .name = "omap4:green:debug3",
66 .gpio = 8,
69 .name = "omap4:green:debug4",
70 .gpio = 50,
73 .name = "omap4:blue:user",
74 .gpio = 169,
77 .name = "omap4:red:user",
78 .gpio = 170,
81 .name = "omap4:green:user",
82 .gpio = 139,
87 static struct gpio_keys_button sdp4430_gpio_keys[] = {
89 .desc = "Proximity Sensor",
90 .type = EV_SW,
91 .code = SW_FRONT_PROXIMITY,
92 .gpio = OMAP4_SFH7741_SENSOR_OUTPUT_GPIO,
93 .active_low = 0,
97 static struct gpio_led_platform_data sdp4430_led_data = {
98 .leds = sdp4430_gpio_leds,
99 .num_leds = ARRAY_SIZE(sdp4430_gpio_leds),
102 static struct led_pwm sdp4430_pwm_leds[] = {
104 .name = "omap4:green:chrg",
105 .pwm_id = 1,
106 .max_brightness = 255,
107 .pwm_period_ns = 7812500,
111 static struct led_pwm_platform_data sdp4430_pwm_data = {
112 .num_leds = ARRAY_SIZE(sdp4430_pwm_leds),
113 .leds = sdp4430_pwm_leds,
116 static struct platform_device sdp4430_leds_pwm = {
117 .name = "leds_pwm",
118 .id = -1,
119 .dev = {
120 .platform_data = &sdp4430_pwm_data,
124 static int omap_prox_activate(struct device *dev)
126 gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 1);
127 return 0;
130 static void omap_prox_deactivate(struct device *dev)
132 gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 0);
135 static struct gpio_keys_platform_data sdp4430_gpio_keys_data = {
136 .buttons = sdp4430_gpio_keys,
137 .nbuttons = ARRAY_SIZE(sdp4430_gpio_keys),
138 .enable = omap_prox_activate,
139 .disable = omap_prox_deactivate,
142 static struct platform_device sdp4430_gpio_keys_device = {
143 .name = "gpio-keys",
144 .id = -1,
145 .dev = {
146 .platform_data = &sdp4430_gpio_keys_data,
150 static struct platform_device sdp4430_leds_gpio = {
151 .name = "leds-gpio",
152 .id = -1,
153 .dev = {
154 .platform_data = &sdp4430_led_data,
157 static struct spi_board_info sdp4430_spi_board_info[] __initdata = {
159 .modalias = "ks8851",
160 .bus_num = 1,
161 .chip_select = 0,
162 .max_speed_hz = 24000000,
163 .irq = ETH_KS8851_IRQ,
167 static int omap_ethernet_init(void)
169 int status;
171 /* Request of GPIO lines */
173 status = gpio_request(ETH_KS8851_POWER_ON, "eth_power");
174 if (status) {
175 pr_err("Cannot request GPIO %d\n", ETH_KS8851_POWER_ON);
176 return status;
179 status = gpio_request(ETH_KS8851_QUART, "quart");
180 if (status) {
181 pr_err("Cannot request GPIO %d\n", ETH_KS8851_QUART);
182 goto error1;
185 status = gpio_request(ETH_KS8851_IRQ, "eth_irq");
186 if (status) {
187 pr_err("Cannot request GPIO %d\n", ETH_KS8851_IRQ);
188 goto error2;
191 /* Configuration of requested GPIO lines */
193 status = gpio_direction_output(ETH_KS8851_POWER_ON, 1);
194 if (status) {
195 pr_err("Cannot set output GPIO %d\n", ETH_KS8851_IRQ);
196 goto error3;
199 status = gpio_direction_output(ETH_KS8851_QUART, 1);
200 if (status) {
201 pr_err("Cannot set output GPIO %d\n", ETH_KS8851_QUART);
202 goto error3;
205 status = gpio_direction_input(ETH_KS8851_IRQ);
206 if (status) {
207 pr_err("Cannot set input GPIO %d\n", ETH_KS8851_IRQ);
208 goto error3;
211 return 0;
213 error3:
214 gpio_free(ETH_KS8851_IRQ);
215 error2:
216 gpio_free(ETH_KS8851_QUART);
217 error1:
218 gpio_free(ETH_KS8851_POWER_ON);
219 return status;
222 static struct platform_device sdp4430_lcd_device = {
223 .name = "sdp4430_lcd",
224 .id = -1,
227 static struct platform_device *sdp4430_devices[] __initdata = {
228 &sdp4430_lcd_device,
229 &sdp4430_gpio_keys_device,
230 &sdp4430_leds_gpio,
231 &sdp4430_leds_pwm,
234 static struct omap_lcd_config sdp4430_lcd_config __initdata = {
235 .ctrl_name = "internal",
238 static struct omap_board_config_kernel sdp4430_config[] __initdata = {
239 { OMAP_TAG_LCD, &sdp4430_lcd_config },
242 static void __init omap_4430sdp_init_early(void)
244 omap_board_config = sdp4430_config;
245 omap_board_config_size = ARRAY_SIZE(sdp4430_config);
246 omap2_init_common_infrastructure();
247 omap2_init_common_devices(NULL, NULL);
248 #ifdef CONFIG_OMAP_32K_TIMER
249 omap2_gp_clockevent_set_gptimer(1);
250 #endif
253 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
254 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
255 .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
256 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
257 .phy_reset = false,
258 .reset_gpio_port[0] = -EINVAL,
259 .reset_gpio_port[1] = -EINVAL,
260 .reset_gpio_port[2] = -EINVAL,
263 static struct omap_musb_board_data musb_board_data = {
264 .interface_type = MUSB_INTERFACE_UTMI,
265 .mode = MUSB_OTG,
266 .power = 100,
269 static struct twl4030_usb_data omap4_usbphy_data = {
270 .phy_init = omap4430_phy_init,
271 .phy_exit = omap4430_phy_exit,
272 .phy_power = omap4430_phy_power,
273 .phy_set_clock = omap4430_phy_set_clk,
276 static struct omap2_hsmmc_info mmc[] = {
278 .mmc = 1,
279 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
280 .gpio_wp = -EINVAL,
283 .mmc = 2,
284 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
285 .gpio_cd = -EINVAL,
286 .gpio_wp = -EINVAL,
287 .nonremovable = true,
288 .ocr_mask = MMC_VDD_29_30,
290 {} /* Terminator */
293 static struct regulator_consumer_supply sdp4430_vaux_supply[] = {
295 .supply = "vmmc",
296 .dev_name = "mmci-omap-hs.1",
299 static struct regulator_consumer_supply sdp4430_vmmc_supply[] = {
301 .supply = "vmmc",
302 .dev_name = "mmci-omap-hs.0",
306 static int omap4_twl6030_hsmmc_late_init(struct device *dev)
308 int ret = 0;
309 struct platform_device *pdev = container_of(dev,
310 struct platform_device, dev);
311 struct omap_mmc_platform_data *pdata = dev->platform_data;
313 /* Setting MMC1 Card detect Irq */
314 if (pdev->id == 0) {
315 ret = twl6030_mmc_card_detect_config();
316 if (ret)
317 pr_err("Failed configuring MMC1 card detect\n");
318 pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE +
319 MMCDETECT_INTR_OFFSET;
320 pdata->slots[0].card_detect = twl6030_mmc_card_detect;
322 return ret;
325 static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
327 struct omap_mmc_platform_data *pdata;
329 /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
330 if (!dev) {
331 pr_err("Failed %s\n", __func__);
332 return;
334 pdata = dev->platform_data;
335 pdata->init = omap4_twl6030_hsmmc_late_init;
338 static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
340 struct omap2_hsmmc_info *c;
342 omap2_hsmmc_init(controllers);
343 for (c = controllers; c->mmc; c++)
344 omap4_twl6030_hsmmc_set_late_init(c->dev);
346 return 0;
349 static struct regulator_init_data sdp4430_vaux1 = {
350 .constraints = {
351 .min_uV = 1000000,
352 .max_uV = 3000000,
353 .apply_uV = true,
354 .valid_modes_mask = REGULATOR_MODE_NORMAL
355 | REGULATOR_MODE_STANDBY,
356 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
357 | REGULATOR_CHANGE_MODE
358 | REGULATOR_CHANGE_STATUS,
360 .num_consumer_supplies = 1,
361 .consumer_supplies = sdp4430_vaux_supply,
364 static struct regulator_init_data sdp4430_vaux2 = {
365 .constraints = {
366 .min_uV = 1200000,
367 .max_uV = 2800000,
368 .apply_uV = true,
369 .valid_modes_mask = REGULATOR_MODE_NORMAL
370 | REGULATOR_MODE_STANDBY,
371 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
372 | REGULATOR_CHANGE_MODE
373 | REGULATOR_CHANGE_STATUS,
377 static struct regulator_init_data sdp4430_vaux3 = {
378 .constraints = {
379 .min_uV = 1000000,
380 .max_uV = 3000000,
381 .apply_uV = true,
382 .valid_modes_mask = REGULATOR_MODE_NORMAL
383 | REGULATOR_MODE_STANDBY,
384 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
385 | REGULATOR_CHANGE_MODE
386 | REGULATOR_CHANGE_STATUS,
390 /* VMMC1 for MMC1 card */
391 static struct regulator_init_data sdp4430_vmmc = {
392 .constraints = {
393 .min_uV = 1200000,
394 .max_uV = 3000000,
395 .apply_uV = true,
396 .valid_modes_mask = REGULATOR_MODE_NORMAL
397 | REGULATOR_MODE_STANDBY,
398 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
399 | REGULATOR_CHANGE_MODE
400 | REGULATOR_CHANGE_STATUS,
402 .num_consumer_supplies = 1,
403 .consumer_supplies = sdp4430_vmmc_supply,
406 static struct regulator_init_data sdp4430_vpp = {
407 .constraints = {
408 .min_uV = 1800000,
409 .max_uV = 2500000,
410 .apply_uV = true,
411 .valid_modes_mask = REGULATOR_MODE_NORMAL
412 | REGULATOR_MODE_STANDBY,
413 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
414 | REGULATOR_CHANGE_MODE
415 | REGULATOR_CHANGE_STATUS,
419 static struct regulator_init_data sdp4430_vusim = {
420 .constraints = {
421 .min_uV = 1200000,
422 .max_uV = 2900000,
423 .apply_uV = true,
424 .valid_modes_mask = REGULATOR_MODE_NORMAL
425 | REGULATOR_MODE_STANDBY,
426 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
427 | REGULATOR_CHANGE_MODE
428 | REGULATOR_CHANGE_STATUS,
432 static struct regulator_init_data sdp4430_vana = {
433 .constraints = {
434 .min_uV = 2100000,
435 .max_uV = 2100000,
436 .apply_uV = true,
437 .valid_modes_mask = REGULATOR_MODE_NORMAL
438 | REGULATOR_MODE_STANDBY,
439 .valid_ops_mask = REGULATOR_CHANGE_MODE
440 | REGULATOR_CHANGE_STATUS,
444 static struct regulator_init_data sdp4430_vcxio = {
445 .constraints = {
446 .min_uV = 1800000,
447 .max_uV = 1800000,
448 .apply_uV = true,
449 .valid_modes_mask = REGULATOR_MODE_NORMAL
450 | REGULATOR_MODE_STANDBY,
451 .valid_ops_mask = REGULATOR_CHANGE_MODE
452 | REGULATOR_CHANGE_STATUS,
456 static struct regulator_init_data sdp4430_vdac = {
457 .constraints = {
458 .min_uV = 1800000,
459 .max_uV = 1800000,
460 .apply_uV = true,
461 .valid_modes_mask = REGULATOR_MODE_NORMAL
462 | REGULATOR_MODE_STANDBY,
463 .valid_ops_mask = REGULATOR_CHANGE_MODE
464 | REGULATOR_CHANGE_STATUS,
468 static struct regulator_init_data sdp4430_vusb = {
469 .constraints = {
470 .min_uV = 3300000,
471 .max_uV = 3300000,
472 .apply_uV = true,
473 .valid_modes_mask = REGULATOR_MODE_NORMAL
474 | REGULATOR_MODE_STANDBY,
475 .valid_ops_mask = REGULATOR_CHANGE_MODE
476 | REGULATOR_CHANGE_STATUS,
480 static struct twl4030_platform_data sdp4430_twldata = {
481 .irq_base = TWL6030_IRQ_BASE,
482 .irq_end = TWL6030_IRQ_END,
484 /* Regulators */
485 .vmmc = &sdp4430_vmmc,
486 .vpp = &sdp4430_vpp,
487 .vusim = &sdp4430_vusim,
488 .vana = &sdp4430_vana,
489 .vcxio = &sdp4430_vcxio,
490 .vdac = &sdp4430_vdac,
491 .vusb = &sdp4430_vusb,
492 .vaux1 = &sdp4430_vaux1,
493 .vaux2 = &sdp4430_vaux2,
494 .vaux3 = &sdp4430_vaux3,
495 .usb = &omap4_usbphy_data
498 static struct i2c_board_info __initdata sdp4430_i2c_boardinfo[] = {
500 I2C_BOARD_INFO("twl6030", 0x48),
501 .flags = I2C_CLIENT_WAKE,
502 .irq = OMAP44XX_IRQ_SYS_1N,
503 .platform_data = &sdp4430_twldata,
506 static struct i2c_board_info __initdata sdp4430_i2c_3_boardinfo[] = {
508 I2C_BOARD_INFO("tmp105", 0x48),
511 I2C_BOARD_INFO("bh1780", 0x29),
514 static struct i2c_board_info __initdata sdp4430_i2c_4_boardinfo[] = {
516 I2C_BOARD_INFO("hmc5843", 0x1e),
519 static int __init omap4_i2c_init(void)
522 * Phoenix Audio IC needs I2C1 to
523 * start with 400 KHz or less
525 omap_register_i2c_bus(1, 400, sdp4430_i2c_boardinfo,
526 ARRAY_SIZE(sdp4430_i2c_boardinfo));
527 omap_register_i2c_bus(2, 400, NULL, 0);
528 omap_register_i2c_bus(3, 400, sdp4430_i2c_3_boardinfo,
529 ARRAY_SIZE(sdp4430_i2c_3_boardinfo));
530 omap_register_i2c_bus(4, 400, sdp4430_i2c_4_boardinfo,
531 ARRAY_SIZE(sdp4430_i2c_4_boardinfo));
532 return 0;
535 static void __init omap_sfh7741prox_init(void)
537 int error;
539 error = gpio_request(OMAP4_SFH7741_ENABLE_GPIO, "sfh7741");
540 if (error < 0) {
541 pr_err("%s:failed to request GPIO %d, error %d\n",
542 __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
543 return;
546 error = gpio_direction_output(OMAP4_SFH7741_ENABLE_GPIO , 0);
547 if (error < 0) {
548 pr_err("%s: GPIO configuration failed: GPIO %d,error %d\n",
549 __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
550 gpio_free(OMAP4_SFH7741_ENABLE_GPIO);
554 #ifdef CONFIG_OMAP_MUX
555 static struct omap_board_mux board_mux[] __initdata = {
556 OMAP4_MUX(USBB2_ULPITLL_CLK, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
557 { .reg_offset = OMAP_MUX_TERMINATOR },
559 #else
560 #define board_mux NULL
561 #endif
563 static void __init omap_4430sdp_init(void)
565 int status;
566 int package = OMAP_PACKAGE_CBS;
568 if (omap_rev() == OMAP4430_REV_ES1_0)
569 package = OMAP_PACKAGE_CBL;
570 omap4_mux_init(board_mux, package);
572 omap4_i2c_init();
573 omap_sfh7741prox_init();
574 platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
575 omap_serial_init();
576 omap4_twl6030_hsmmc_init(mmc);
578 /* Power on the ULPI PHY */
579 status = gpio_request(OMAP4SDP_MDM_PWR_EN_GPIO, "USBB1 PHY VMDM_3V3");
580 if (status)
581 pr_err("%s: Could not get USBB1 PHY GPIO\n", __func__);
582 else
583 gpio_direction_output(OMAP4SDP_MDM_PWR_EN_GPIO, 1);
585 usb_ehci_init(&ehci_pdata);
586 usb_musb_init(&musb_board_data);
588 status = omap_ethernet_init();
589 if (status) {
590 pr_err("Ethernet initialization failed: %d\n", status);
591 } else {
592 sdp4430_spi_board_info[0].irq = gpio_to_irq(ETH_KS8851_IRQ);
593 spi_register_board_info(sdp4430_spi_board_info,
594 ARRAY_SIZE(sdp4430_spi_board_info));
598 static void __init omap_4430sdp_map_io(void)
600 omap2_set_globals_443x();
601 omap44xx_map_common_io();
604 MACHINE_START(OMAP_4430SDP, "OMAP4430 4430SDP board")
605 /* Maintainer: Santosh Shilimkar - Texas Instruments Inc */
606 .boot_params = 0x80000100,
607 .reserve = omap_reserve,
608 .map_io = omap_4430sdp_map_io,
609 .init_early = omap_4430sdp_init_early,
610 .init_irq = gic_init_irq,
611 .init_machine = omap_4430sdp_init,
612 .timer = &omap_timer,
613 MACHINE_END