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/regulator/fixed.h>
26 #include <linux/leds.h>
27 #include <linux/leds_pwm.h>
29 #include <mach/hardware.h>
30 #include <mach/omap4-common.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
35 #include <plat/board.h>
36 #include <plat/common.h>
39 #include <plat/omap4-keypad.h>
40 #include <video/omapdss.h>
45 #include "common-board-devices.h"
47 #define ETH_KS8851_IRQ 34
48 #define ETH_KS8851_POWER_ON 48
49 #define ETH_KS8851_QUART 138
50 #define OMAP4_SFH7741_SENSOR_OUTPUT_GPIO 184
51 #define OMAP4_SFH7741_ENABLE_GPIO 188
52 #define HDMI_GPIO_HPD 60 /* Hot plug pin for HDMI */
53 #define HDMI_GPIO_LS_OE 41 /* Level shifter for HDMI */
55 static const int sdp4430_keymap[] = {
61 KEY(0, 5, KEY_UNKNOWN),
63 KEY(0, 7, KEY_LEFTSHIFT),
70 KEY(1, 5, KEY_UNKNOWN),
79 KEY(2, 5, KEY_UNKNOWN),
81 KEY(2, 7, KEY_CAPSLOCK),
84 KEY(3, 1, KEY_KPPLUS),
88 KEY(3, 5, KEY_UNKNOWN),
96 KEY(4, 4, KEY_VOLUMEUP),
97 KEY(4, 5, KEY_UNKNOWN),
106 KEY(5, 5, KEY_VOLUMEDOWN),
108 KEY(5, 7, KEY_RIGHT),
114 KEY(6, 4, KEY_BACKSPACE),
115 KEY(6, 5, KEY_UNKNOWN),
119 KEY(7, 0, KEY_PROG1),
120 KEY(7, 1, KEY_PROG2),
121 KEY(7, 2, KEY_PROG3),
122 KEY(7, 3, KEY_PROG4),
124 KEY(7, 5, KEY_UNKNOWN),
129 static struct matrix_keymap_data sdp4430_keymap_data = {
130 .keymap = sdp4430_keymap,
131 .keymap_size = ARRAY_SIZE(sdp4430_keymap),
134 static struct omap4_keypad_platform_data sdp4430_keypad_data = {
135 .keymap_data = &sdp4430_keymap_data,
139 static struct gpio_led sdp4430_gpio_leds[] = {
141 .name = "omap4:green:debug0",
145 .name = "omap4:green:debug1",
149 .name = "omap4:green:debug2",
153 .name = "omap4:green:debug3",
157 .name = "omap4:green:debug4",
161 .name = "omap4:blue:user",
165 .name = "omap4:red:user",
169 .name = "omap4:green:user",
175 static struct gpio_keys_button sdp4430_gpio_keys[] = {
177 .desc = "Proximity Sensor",
179 .code = SW_FRONT_PROXIMITY,
180 .gpio = OMAP4_SFH7741_SENSOR_OUTPUT_GPIO,
185 static struct gpio_led_platform_data sdp4430_led_data = {
186 .leds = sdp4430_gpio_leds,
187 .num_leds = ARRAY_SIZE(sdp4430_gpio_leds),
190 static struct led_pwm sdp4430_pwm_leds[] = {
192 .name = "omap4:green:chrg",
194 .max_brightness = 255,
195 .pwm_period_ns = 7812500,
199 static struct led_pwm_platform_data sdp4430_pwm_data = {
200 .num_leds = ARRAY_SIZE(sdp4430_pwm_leds),
201 .leds = sdp4430_pwm_leds,
204 static struct platform_device sdp4430_leds_pwm = {
208 .platform_data = &sdp4430_pwm_data,
212 static int omap_prox_activate(struct device *dev)
214 gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 1);
218 static void omap_prox_deactivate(struct device *dev)
220 gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 0);
223 static struct gpio_keys_platform_data sdp4430_gpio_keys_data = {
224 .buttons = sdp4430_gpio_keys,
225 .nbuttons = ARRAY_SIZE(sdp4430_gpio_keys),
226 .enable = omap_prox_activate,
227 .disable = omap_prox_deactivate,
230 static struct platform_device sdp4430_gpio_keys_device = {
234 .platform_data = &sdp4430_gpio_keys_data,
238 static struct platform_device sdp4430_leds_gpio = {
242 .platform_data = &sdp4430_led_data,
245 static struct spi_board_info sdp4430_spi_board_info[] __initdata = {
247 .modalias = "ks8851",
250 .max_speed_hz = 24000000,
251 .irq = ETH_KS8851_IRQ,
255 static struct gpio sdp4430_eth_gpios[] __initdata = {
256 { ETH_KS8851_POWER_ON, GPIOF_OUT_INIT_HIGH, "eth_power" },
257 { ETH_KS8851_QUART, GPIOF_OUT_INIT_HIGH, "quart" },
258 { ETH_KS8851_IRQ, GPIOF_IN, "eth_irq" },
261 static int __init omap_ethernet_init(void)
265 /* Request of GPIO lines */
266 status = gpio_request_array(sdp4430_eth_gpios,
267 ARRAY_SIZE(sdp4430_eth_gpios));
269 pr_err("Cannot request ETH GPIOs\n");
274 static struct platform_device sdp4430_lcd_device = {
275 .name = "sdp4430_lcd",
279 static struct regulator_consumer_supply sdp4430_vbat_supply[] = {
280 REGULATOR_SUPPLY("vddvibl", "twl6040-vibra"),
281 REGULATOR_SUPPLY("vddvibr", "twl6040-vibra"),
284 static struct regulator_init_data sdp4430_vbat_data = {
288 .num_consumer_supplies = ARRAY_SIZE(sdp4430_vbat_supply),
289 .consumer_supplies = sdp4430_vbat_supply,
292 static struct fixed_voltage_config sdp4430_vbat_pdata = {
293 .supply_name = "VBAT",
294 .microvolts = 3750000,
295 .init_data = &sdp4430_vbat_data,
299 static struct platform_device sdp4430_vbat = {
300 .name = "reg-fixed-voltage",
303 .platform_data = &sdp4430_vbat_pdata,
307 static struct platform_device *sdp4430_devices[] __initdata = {
309 &sdp4430_gpio_keys_device,
315 static struct omap_lcd_config sdp4430_lcd_config __initdata = {
316 .ctrl_name = "internal",
319 static struct omap_board_config_kernel sdp4430_config[] __initdata = {
320 { OMAP_TAG_LCD, &sdp4430_lcd_config },
323 static void __init omap_4430sdp_init_early(void)
325 omap2_init_common_infrastructure();
326 omap2_init_common_devices(NULL, NULL);
329 static struct omap_musb_board_data musb_board_data = {
330 .interface_type = MUSB_INTERFACE_UTMI,
335 static struct omap2_hsmmc_info mmc[] = {
338 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
341 .nonremovable = true,
342 .ocr_mask = MMC_VDD_29_30,
347 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
353 static struct regulator_consumer_supply sdp4430_vaux_supply[] = {
354 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
357 static int omap4_twl6030_hsmmc_late_init(struct device *dev)
360 struct platform_device *pdev = container_of(dev,
361 struct platform_device, dev);
362 struct omap_mmc_platform_data *pdata = dev->platform_data;
364 /* Setting MMC1 Card detect Irq */
366 ret = twl6030_mmc_card_detect_config();
368 pr_err("Failed configuring MMC1 card detect\n");
369 pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE +
370 MMCDETECT_INTR_OFFSET;
371 pdata->slots[0].card_detect = twl6030_mmc_card_detect;
376 static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
378 struct omap_mmc_platform_data *pdata;
380 /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
382 pr_err("Failed %s\n", __func__);
385 pdata = dev->platform_data;
386 pdata->init = omap4_twl6030_hsmmc_late_init;
389 static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
391 struct omap2_hsmmc_info *c;
393 omap2_hsmmc_init(controllers);
394 for (c = controllers; c->mmc; c++)
395 omap4_twl6030_hsmmc_set_late_init(c->dev);
400 static struct regulator_init_data sdp4430_vaux1 = {
405 .valid_modes_mask = REGULATOR_MODE_NORMAL
406 | REGULATOR_MODE_STANDBY,
407 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
408 | REGULATOR_CHANGE_MODE
409 | REGULATOR_CHANGE_STATUS,
411 .num_consumer_supplies = ARRAY_SIZE(sdp4430_vaux_supply),
412 .consumer_supplies = sdp4430_vaux_supply,
415 static struct regulator_init_data sdp4430_vusim = {
420 .valid_modes_mask = REGULATOR_MODE_NORMAL
421 | REGULATOR_MODE_STANDBY,
422 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
423 | REGULATOR_CHANGE_MODE
424 | REGULATOR_CHANGE_STATUS,
428 static struct twl4030_vibra_data twl6040_vibra = {
433 .vddvibl_uV = 0, /* fixed volt supply - VBAT */
434 .vddvibr_uV = 0, /* fixed volt supply - VBAT */
437 static struct twl4030_audio_data twl6040_audio = {
439 .vibra = &twl6040_vibra,
440 .audpwron_gpio = 127,
441 .naudint_irq = OMAP44XX_IRQ_SYS_2N,
442 .irq_base = TWL6040_CODEC_IRQ_BASE,
445 static struct twl4030_platform_data sdp4430_twldata = {
446 .audio = &twl6040_audio,
448 .vusim = &sdp4430_vusim,
449 .vaux1 = &sdp4430_vaux1,
452 static struct i2c_board_info __initdata sdp4430_i2c_3_boardinfo[] = {
454 I2C_BOARD_INFO("tmp105", 0x48),
457 I2C_BOARD_INFO("bh1780", 0x29),
460 static struct i2c_board_info __initdata sdp4430_i2c_4_boardinfo[] = {
462 I2C_BOARD_INFO("hmc5843", 0x1e),
465 static int __init omap4_i2c_init(void)
467 omap4_pmic_get_config(&sdp4430_twldata, TWL_COMMON_PDATA_USB,
468 TWL_COMMON_REGULATOR_VDAC |
469 TWL_COMMON_REGULATOR_VAUX2 |
470 TWL_COMMON_REGULATOR_VAUX3 |
471 TWL_COMMON_REGULATOR_VMMC |
472 TWL_COMMON_REGULATOR_VPP |
473 TWL_COMMON_REGULATOR_VANA |
474 TWL_COMMON_REGULATOR_VCXIO |
475 TWL_COMMON_REGULATOR_VUSB |
476 TWL_COMMON_REGULATOR_CLK32KG);
477 omap4_pmic_init("twl6030", &sdp4430_twldata);
478 omap_register_i2c_bus(2, 400, NULL, 0);
479 omap_register_i2c_bus(3, 400, sdp4430_i2c_3_boardinfo,
480 ARRAY_SIZE(sdp4430_i2c_3_boardinfo));
481 omap_register_i2c_bus(4, 400, sdp4430_i2c_4_boardinfo,
482 ARRAY_SIZE(sdp4430_i2c_4_boardinfo));
486 static void __init omap_sfh7741prox_init(void)
490 error = gpio_request_one(OMAP4_SFH7741_ENABLE_GPIO,
491 GPIOF_OUT_INIT_LOW, "sfh7741");
493 pr_err("%s:failed to request GPIO %d, error %d\n",
494 __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
497 static void sdp4430_hdmi_mux_init(void)
499 /* PAD0_HDMI_HPD_PAD1_HDMI_CEC */
500 omap_mux_init_signal("hdmi_hpd",
501 OMAP_PIN_INPUT_PULLUP);
502 omap_mux_init_signal("hdmi_cec",
503 OMAP_PIN_INPUT_PULLUP);
504 /* PAD0_HDMI_DDC_SCL_PAD1_HDMI_DDC_SDA */
505 omap_mux_init_signal("hdmi_ddc_scl",
506 OMAP_PIN_INPUT_PULLUP);
507 omap_mux_init_signal("hdmi_ddc_sda",
508 OMAP_PIN_INPUT_PULLUP);
511 static struct gpio sdp4430_hdmi_gpios[] = {
512 { HDMI_GPIO_HPD, GPIOF_OUT_INIT_HIGH, "hdmi_gpio_hpd" },
513 { HDMI_GPIO_LS_OE, GPIOF_OUT_INIT_HIGH, "hdmi_gpio_ls_oe" },
516 static int sdp4430_panel_enable_hdmi(struct omap_dss_device *dssdev)
520 status = gpio_request_array(sdp4430_hdmi_gpios,
521 ARRAY_SIZE(sdp4430_hdmi_gpios));
523 pr_err("%s: Cannot request HDMI GPIOs\n", __func__);
528 static void sdp4430_panel_disable_hdmi(struct omap_dss_device *dssdev)
530 gpio_free(HDMI_GPIO_LS_OE);
531 gpio_free(HDMI_GPIO_HPD);
534 static struct omap_dss_device sdp4430_hdmi_device = {
536 .driver_name = "hdmi_panel",
537 .type = OMAP_DISPLAY_TYPE_HDMI,
540 .dispc_fclk_src = OMAP_DSS_CLK_SRC_FCK,
547 .platform_enable = sdp4430_panel_enable_hdmi,
548 .platform_disable = sdp4430_panel_disable_hdmi,
549 .channel = OMAP_DSS_CHANNEL_DIGIT,
552 static struct omap_dss_device *sdp4430_dss_devices[] = {
553 &sdp4430_hdmi_device,
556 static struct omap_dss_board_info sdp4430_dss_data = {
557 .num_devices = ARRAY_SIZE(sdp4430_dss_devices),
558 .devices = sdp4430_dss_devices,
559 .default_device = &sdp4430_hdmi_device,
562 void omap_4430sdp_display_init(void)
564 sdp4430_hdmi_mux_init();
565 omap_display_init(&sdp4430_dss_data);
568 #ifdef CONFIG_OMAP_MUX
569 static struct omap_board_mux board_mux[] __initdata = {
570 OMAP4_MUX(USBB2_ULPITLL_CLK, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
571 { .reg_offset = OMAP_MUX_TERMINATOR },
574 static struct omap_device_pad serial2_pads[] __initdata = {
575 OMAP_MUX_STATIC("uart2_cts.uart2_cts",
576 OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
577 OMAP_MUX_STATIC("uart2_rts.uart2_rts",
578 OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
579 OMAP_MUX_STATIC("uart2_rx.uart2_rx",
580 OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
581 OMAP_MUX_STATIC("uart2_tx.uart2_tx",
582 OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
585 static struct omap_device_pad serial3_pads[] __initdata = {
586 OMAP_MUX_STATIC("uart3_cts_rctx.uart3_cts_rctx",
587 OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
588 OMAP_MUX_STATIC("uart3_rts_sd.uart3_rts_sd",
589 OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
590 OMAP_MUX_STATIC("uart3_rx_irrx.uart3_rx_irrx",
591 OMAP_PIN_INPUT | OMAP_MUX_MODE0),
592 OMAP_MUX_STATIC("uart3_tx_irtx.uart3_tx_irtx",
593 OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
596 static struct omap_device_pad serial4_pads[] __initdata = {
597 OMAP_MUX_STATIC("uart4_rx.uart4_rx",
598 OMAP_PIN_INPUT | OMAP_MUX_MODE0),
599 OMAP_MUX_STATIC("uart4_tx.uart4_tx",
600 OMAP_PIN_OUTPUT | OMAP_MUX_MODE0),
603 static struct omap_board_data serial2_data __initdata = {
605 .pads = serial2_pads,
606 .pads_cnt = ARRAY_SIZE(serial2_pads),
609 static struct omap_board_data serial3_data __initdata = {
611 .pads = serial3_pads,
612 .pads_cnt = ARRAY_SIZE(serial3_pads),
615 static struct omap_board_data serial4_data __initdata = {
617 .pads = serial4_pads,
618 .pads_cnt = ARRAY_SIZE(serial4_pads),
621 static inline void board_serial_init(void)
623 struct omap_board_data bdata;
628 /* pass dummy data for UART1 */
629 omap_serial_init_port(&bdata);
631 omap_serial_init_port(&serial2_data);
632 omap_serial_init_port(&serial3_data);
633 omap_serial_init_port(&serial4_data);
636 #define board_mux NULL
638 static inline void board_serial_init(void)
644 static void __init omap_4430sdp_init(void)
647 int package = OMAP_PACKAGE_CBS;
649 if (omap_rev() == OMAP4430_REV_ES1_0)
650 package = OMAP_PACKAGE_CBL;
651 omap4_mux_init(board_mux, NULL, package);
653 omap_board_config = sdp4430_config;
654 omap_board_config_size = ARRAY_SIZE(sdp4430_config);
657 omap_sfh7741prox_init();
658 platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
660 omap4_twl6030_hsmmc_init(mmc);
662 usb_musb_init(&musb_board_data);
664 status = omap_ethernet_init();
666 pr_err("Ethernet initialization failed: %d\n", status);
668 sdp4430_spi_board_info[0].irq = gpio_to_irq(ETH_KS8851_IRQ);
669 spi_register_board_info(sdp4430_spi_board_info,
670 ARRAY_SIZE(sdp4430_spi_board_info));
673 status = omap4_keyboard_init(&sdp4430_keypad_data);
675 pr_err("Keypad initialization failed: %d\n", status);
677 omap_4430sdp_display_init();
680 static void __init omap_4430sdp_map_io(void)
682 omap2_set_globals_443x();
683 omap44xx_map_common_io();
686 MACHINE_START(OMAP_4430SDP, "OMAP4430 4430SDP board")
687 /* Maintainer: Santosh Shilimkar - Texas Instruments Inc */
688 .boot_params = 0x80000100,
689 .reserve = omap_reserve,
690 .map_io = omap_4430sdp_map_io,
691 .init_early = omap_4430sdp_init_early,
692 .init_irq = gic_init_irq,
693 .init_machine = omap_4430sdp_init,
694 .timer = &omap4_timer,