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>
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>
38 #include <plat/omap4-keypad.h>
45 #define ETH_KS8851_IRQ 34
46 #define ETH_KS8851_POWER_ON 48
47 #define ETH_KS8851_QUART 138
48 #define OMAP4_SFH7741_SENSOR_OUTPUT_GPIO 184
49 #define OMAP4_SFH7741_ENABLE_GPIO 188
51 static const int sdp4430_keymap[] = {
57 KEY(0, 5, KEY_UNKNOWN),
59 KEY(0, 7, KEY_LEFTSHIFT),
66 KEY(1, 5, KEY_UNKNOWN),
75 KEY(2, 5, KEY_UNKNOWN),
77 KEY(2, 7, KEY_CAPSLOCK),
80 KEY(3, 1, KEY_KPPLUS),
84 KEY(3, 5, KEY_UNKNOWN),
92 KEY(4, 4, KEY_VOLUMEUP),
93 KEY(4, 5, KEY_UNKNOWN),
102 KEY(5, 5, KEY_VOLUMEDOWN),
104 KEY(5, 7, KEY_RIGHT),
110 KEY(6, 4, KEY_BACKSPACE),
111 KEY(6, 5, KEY_UNKNOWN),
115 KEY(7, 0, KEY_PROG1),
116 KEY(7, 1, KEY_PROG2),
117 KEY(7, 2, KEY_PROG3),
118 KEY(7, 3, KEY_PROG4),
120 KEY(7, 5, KEY_UNKNOWN),
125 static struct matrix_keymap_data sdp4430_keymap_data = {
126 .keymap = sdp4430_keymap,
127 .keymap_size = ARRAY_SIZE(sdp4430_keymap),
130 static struct omap4_keypad_platform_data sdp4430_keypad_data = {
131 .keymap_data = &sdp4430_keymap_data,
135 static struct gpio_led sdp4430_gpio_leds[] = {
137 .name = "omap4:green:debug0",
141 .name = "omap4:green:debug1",
145 .name = "omap4:green:debug2",
149 .name = "omap4:green:debug3",
153 .name = "omap4:green:debug4",
157 .name = "omap4:blue:user",
161 .name = "omap4:red:user",
165 .name = "omap4:green:user",
171 static struct gpio_keys_button sdp4430_gpio_keys[] = {
173 .desc = "Proximity Sensor",
175 .code = SW_FRONT_PROXIMITY,
176 .gpio = OMAP4_SFH7741_SENSOR_OUTPUT_GPIO,
181 static struct gpio_led_platform_data sdp4430_led_data = {
182 .leds = sdp4430_gpio_leds,
183 .num_leds = ARRAY_SIZE(sdp4430_gpio_leds),
186 static struct led_pwm sdp4430_pwm_leds[] = {
188 .name = "omap4:green:chrg",
190 .max_brightness = 255,
191 .pwm_period_ns = 7812500,
195 static struct led_pwm_platform_data sdp4430_pwm_data = {
196 .num_leds = ARRAY_SIZE(sdp4430_pwm_leds),
197 .leds = sdp4430_pwm_leds,
200 static struct platform_device sdp4430_leds_pwm = {
204 .platform_data = &sdp4430_pwm_data,
208 static int omap_prox_activate(struct device *dev)
210 gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 1);
214 static void omap_prox_deactivate(struct device *dev)
216 gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 0);
219 static struct gpio_keys_platform_data sdp4430_gpio_keys_data = {
220 .buttons = sdp4430_gpio_keys,
221 .nbuttons = ARRAY_SIZE(sdp4430_gpio_keys),
222 .enable = omap_prox_activate,
223 .disable = omap_prox_deactivate,
226 static struct platform_device sdp4430_gpio_keys_device = {
230 .platform_data = &sdp4430_gpio_keys_data,
234 static struct platform_device sdp4430_leds_gpio = {
238 .platform_data = &sdp4430_led_data,
241 static struct spi_board_info sdp4430_spi_board_info[] __initdata = {
243 .modalias = "ks8851",
246 .max_speed_hz = 24000000,
247 .irq = ETH_KS8851_IRQ,
251 static int omap_ethernet_init(void)
255 /* Request of GPIO lines */
257 status = gpio_request(ETH_KS8851_POWER_ON, "eth_power");
259 pr_err("Cannot request GPIO %d\n", ETH_KS8851_POWER_ON);
263 status = gpio_request(ETH_KS8851_QUART, "quart");
265 pr_err("Cannot request GPIO %d\n", ETH_KS8851_QUART);
269 status = gpio_request(ETH_KS8851_IRQ, "eth_irq");
271 pr_err("Cannot request GPIO %d\n", ETH_KS8851_IRQ);
275 /* Configuration of requested GPIO lines */
277 status = gpio_direction_output(ETH_KS8851_POWER_ON, 1);
279 pr_err("Cannot set output GPIO %d\n", ETH_KS8851_IRQ);
283 status = gpio_direction_output(ETH_KS8851_QUART, 1);
285 pr_err("Cannot set output GPIO %d\n", ETH_KS8851_QUART);
289 status = gpio_direction_input(ETH_KS8851_IRQ);
291 pr_err("Cannot set input GPIO %d\n", ETH_KS8851_IRQ);
298 gpio_free(ETH_KS8851_IRQ);
300 gpio_free(ETH_KS8851_QUART);
302 gpio_free(ETH_KS8851_POWER_ON);
306 static struct platform_device sdp4430_lcd_device = {
307 .name = "sdp4430_lcd",
311 static struct platform_device *sdp4430_devices[] __initdata = {
313 &sdp4430_gpio_keys_device,
318 static struct omap_lcd_config sdp4430_lcd_config __initdata = {
319 .ctrl_name = "internal",
322 static struct omap_board_config_kernel sdp4430_config[] __initdata = {
323 { OMAP_TAG_LCD, &sdp4430_lcd_config },
326 static void __init omap_4430sdp_init_early(void)
328 omap2_init_common_infrastructure();
329 omap2_init_common_devices(NULL, NULL);
330 #ifdef CONFIG_OMAP_32K_TIMER
331 omap2_gp_clockevent_set_gptimer(1);
335 static struct omap_musb_board_data musb_board_data = {
336 .interface_type = MUSB_INTERFACE_UTMI,
341 static struct twl4030_usb_data omap4_usbphy_data = {
342 .phy_init = omap4430_phy_init,
343 .phy_exit = omap4430_phy_exit,
344 .phy_power = omap4430_phy_power,
345 .phy_set_clock = omap4430_phy_set_clk,
348 static struct omap2_hsmmc_info mmc[] = {
351 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
354 .nonremovable = true,
355 .ocr_mask = MMC_VDD_29_30,
359 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
365 static struct regulator_consumer_supply sdp4430_vaux_supply[] = {
368 .dev_name = "omap_hsmmc.1",
371 static struct regulator_consumer_supply sdp4430_vmmc_supply[] = {
374 .dev_name = "omap_hsmmc.0",
378 static int omap4_twl6030_hsmmc_late_init(struct device *dev)
381 struct platform_device *pdev = container_of(dev,
382 struct platform_device, dev);
383 struct omap_mmc_platform_data *pdata = dev->platform_data;
385 /* Setting MMC1 Card detect Irq */
387 ret = twl6030_mmc_card_detect_config();
389 pr_err("Failed configuring MMC1 card detect\n");
390 pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE +
391 MMCDETECT_INTR_OFFSET;
392 pdata->slots[0].card_detect = twl6030_mmc_card_detect;
397 static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
399 struct omap_mmc_platform_data *pdata;
401 /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
403 pr_err("Failed %s\n", __func__);
406 pdata = dev->platform_data;
407 pdata->init = omap4_twl6030_hsmmc_late_init;
410 static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
412 struct omap2_hsmmc_info *c;
414 omap2_hsmmc_init(controllers);
415 for (c = controllers; c->mmc; c++)
416 omap4_twl6030_hsmmc_set_late_init(c->dev);
421 static struct regulator_init_data sdp4430_vaux1 = {
426 .valid_modes_mask = REGULATOR_MODE_NORMAL
427 | REGULATOR_MODE_STANDBY,
428 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
429 | REGULATOR_CHANGE_MODE
430 | REGULATOR_CHANGE_STATUS,
432 .num_consumer_supplies = 1,
433 .consumer_supplies = sdp4430_vaux_supply,
436 static struct regulator_init_data sdp4430_vaux2 = {
441 .valid_modes_mask = REGULATOR_MODE_NORMAL
442 | REGULATOR_MODE_STANDBY,
443 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
444 | REGULATOR_CHANGE_MODE
445 | REGULATOR_CHANGE_STATUS,
449 static struct regulator_init_data sdp4430_vaux3 = {
454 .valid_modes_mask = REGULATOR_MODE_NORMAL
455 | REGULATOR_MODE_STANDBY,
456 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
457 | REGULATOR_CHANGE_MODE
458 | REGULATOR_CHANGE_STATUS,
462 /* VMMC1 for MMC1 card */
463 static struct regulator_init_data sdp4430_vmmc = {
468 .valid_modes_mask = REGULATOR_MODE_NORMAL
469 | REGULATOR_MODE_STANDBY,
470 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
471 | REGULATOR_CHANGE_MODE
472 | REGULATOR_CHANGE_STATUS,
474 .num_consumer_supplies = 1,
475 .consumer_supplies = sdp4430_vmmc_supply,
478 static struct regulator_init_data sdp4430_vpp = {
483 .valid_modes_mask = REGULATOR_MODE_NORMAL
484 | REGULATOR_MODE_STANDBY,
485 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
486 | REGULATOR_CHANGE_MODE
487 | REGULATOR_CHANGE_STATUS,
491 static struct regulator_init_data sdp4430_vusim = {
496 .valid_modes_mask = REGULATOR_MODE_NORMAL
497 | REGULATOR_MODE_STANDBY,
498 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
499 | REGULATOR_CHANGE_MODE
500 | REGULATOR_CHANGE_STATUS,
504 static struct regulator_init_data sdp4430_vana = {
508 .valid_modes_mask = REGULATOR_MODE_NORMAL
509 | REGULATOR_MODE_STANDBY,
510 .valid_ops_mask = REGULATOR_CHANGE_MODE
511 | REGULATOR_CHANGE_STATUS,
515 static struct regulator_init_data sdp4430_vcxio = {
519 .valid_modes_mask = REGULATOR_MODE_NORMAL
520 | REGULATOR_MODE_STANDBY,
521 .valid_ops_mask = REGULATOR_CHANGE_MODE
522 | REGULATOR_CHANGE_STATUS,
526 static struct regulator_init_data sdp4430_vdac = {
530 .valid_modes_mask = REGULATOR_MODE_NORMAL
531 | REGULATOR_MODE_STANDBY,
532 .valid_ops_mask = REGULATOR_CHANGE_MODE
533 | REGULATOR_CHANGE_STATUS,
537 static struct regulator_init_data sdp4430_vusb = {
542 .valid_modes_mask = REGULATOR_MODE_NORMAL
543 | REGULATOR_MODE_STANDBY,
544 .valid_ops_mask = REGULATOR_CHANGE_MODE
545 | REGULATOR_CHANGE_STATUS,
549 static struct twl4030_platform_data sdp4430_twldata = {
550 .irq_base = TWL6030_IRQ_BASE,
551 .irq_end = TWL6030_IRQ_END,
554 .vmmc = &sdp4430_vmmc,
556 .vusim = &sdp4430_vusim,
557 .vana = &sdp4430_vana,
558 .vcxio = &sdp4430_vcxio,
559 .vdac = &sdp4430_vdac,
560 .vusb = &sdp4430_vusb,
561 .vaux1 = &sdp4430_vaux1,
562 .vaux2 = &sdp4430_vaux2,
563 .vaux3 = &sdp4430_vaux3,
564 .usb = &omap4_usbphy_data
567 static struct i2c_board_info __initdata sdp4430_i2c_boardinfo[] = {
569 I2C_BOARD_INFO("twl6030", 0x48),
570 .flags = I2C_CLIENT_WAKE,
571 .irq = OMAP44XX_IRQ_SYS_1N,
572 .platform_data = &sdp4430_twldata,
575 static struct i2c_board_info __initdata sdp4430_i2c_3_boardinfo[] = {
577 I2C_BOARD_INFO("tmp105", 0x48),
580 I2C_BOARD_INFO("bh1780", 0x29),
583 static struct i2c_board_info __initdata sdp4430_i2c_4_boardinfo[] = {
585 I2C_BOARD_INFO("hmc5843", 0x1e),
588 static int __init omap4_i2c_init(void)
591 * Phoenix Audio IC needs I2C1 to
592 * start with 400 KHz or less
594 omap_register_i2c_bus(1, 400, sdp4430_i2c_boardinfo,
595 ARRAY_SIZE(sdp4430_i2c_boardinfo));
596 omap_register_i2c_bus(2, 400, NULL, 0);
597 omap_register_i2c_bus(3, 400, sdp4430_i2c_3_boardinfo,
598 ARRAY_SIZE(sdp4430_i2c_3_boardinfo));
599 omap_register_i2c_bus(4, 400, sdp4430_i2c_4_boardinfo,
600 ARRAY_SIZE(sdp4430_i2c_4_boardinfo));
604 static void __init omap_sfh7741prox_init(void)
608 error = gpio_request(OMAP4_SFH7741_ENABLE_GPIO, "sfh7741");
610 pr_err("%s:failed to request GPIO %d, error %d\n",
611 __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
615 error = gpio_direction_output(OMAP4_SFH7741_ENABLE_GPIO , 0);
617 pr_err("%s: GPIO configuration failed: GPIO %d,error %d\n",
618 __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
619 gpio_free(OMAP4_SFH7741_ENABLE_GPIO);
623 #ifdef CONFIG_OMAP_MUX
624 static struct omap_board_mux board_mux[] __initdata = {
625 OMAP4_MUX(USBB2_ULPITLL_CLK, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
626 { .reg_offset = OMAP_MUX_TERMINATOR },
629 #define board_mux NULL
632 static void __init omap_4430sdp_init(void)
635 int package = OMAP_PACKAGE_CBS;
637 if (omap_rev() == OMAP4430_REV_ES1_0)
638 package = OMAP_PACKAGE_CBL;
639 omap4_mux_init(board_mux, package);
641 omap_board_config = sdp4430_config;
642 omap_board_config_size = ARRAY_SIZE(sdp4430_config);
645 omap_sfh7741prox_init();
646 platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
648 omap4_twl6030_hsmmc_init(mmc);
650 usb_musb_init(&musb_board_data);
652 status = omap_ethernet_init();
654 pr_err("Ethernet initialization failed: %d\n", status);
656 sdp4430_spi_board_info[0].irq = gpio_to_irq(ETH_KS8851_IRQ);
657 spi_register_board_info(sdp4430_spi_board_info,
658 ARRAY_SIZE(sdp4430_spi_board_info));
661 status = omap4_keyboard_init(&sdp4430_keypad_data);
663 pr_err("Keypad initialization failed: %d\n", status);
666 static void __init omap_4430sdp_map_io(void)
668 omap2_set_globals_443x();
669 omap44xx_map_common_io();
672 MACHINE_START(OMAP_4430SDP, "OMAP4430 4430SDP board")
673 /* Maintainer: Santosh Shilimkar - Texas Instruments Inc */
674 .boot_params = 0x80000100,
675 .reserve = omap_reserve,
676 .map_io = omap_4430sdp_map_io,
677 .init_early = omap_4430sdp_init_early,
678 .init_irq = gic_init_irq,
679 .init_machine = omap_4430sdp_init,
680 .timer = &omap_timer,