Path: blob/master/arch/arm/mach-omap2/board-overo.c
10817 views
/*1* board-overo.c (Gumstix Overo)2*3* Initial code: Steve Sakoman <[email protected]>4*5* This program is free software; you can redistribute it and/or6* modify it under the terms of the GNU General Public License7* version 2 as published by the Free Software Foundation.8*9* This program is distributed in the hope that it will be useful, but10* WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU12* General Public License for more details.13*14* You should have received a copy of the GNU General Public License15* along with this program; if not, write to the Free Software16* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA17* 02110-1301 USA18*19*/2021#include <linux/clk.h>22#include <linux/delay.h>23#include <linux/err.h>24#include <linux/init.h>25#include <linux/io.h>26#include <linux/gpio.h>27#include <linux/kernel.h>28#include <linux/platform_device.h>29#include <linux/i2c/twl.h>30#include <linux/regulator/machine.h>31#include <linux/regulator/fixed.h>32#include <linux/spi/spi.h>3334#include <linux/mtd/mtd.h>35#include <linux/mtd/nand.h>36#include <linux/mtd/partitions.h>37#include <linux/mmc/host.h>3839#include <asm/mach-types.h>40#include <asm/mach/arch.h>41#include <asm/mach/flash.h>42#include <asm/mach/map.h>4344#include <plat/board.h>45#include <plat/common.h>46#include <video/omapdss.h>47#include <video/omap-panel-generic-dpi.h>48#include <plat/gpmc.h>49#include <mach/hardware.h>50#include <plat/nand.h>51#include <plat/mcspi.h>52#include <plat/mux.h>53#include <plat/usb.h>5455#include "mux.h"56#include "sdram-micron-mt46h32m32lf-6.h"57#include "hsmmc.h"58#include "common-board-devices.h"5960#define OVERO_GPIO_BT_XGATE 1561#define OVERO_GPIO_W2W_NRESET 1662#define OVERO_GPIO_PENDOWN 11463#define OVERO_GPIO_BT_NRESET 16464#define OVERO_GPIO_USBH_CPEN 16865#define OVERO_GPIO_USBH_NRESET 1836667#define OVERO_SMSC911X_CS 568#define OVERO_SMSC911X_GPIO 17669#define OVERO_SMSC911X2_CS 470#define OVERO_SMSC911X2_GPIO 657172#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \73defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)7475/* fixed regulator for ads7846 */76static struct regulator_consumer_supply ads7846_supply =77REGULATOR_SUPPLY("vcc", "spi1.0");7879static struct regulator_init_data vads7846_regulator = {80.constraints = {81.valid_ops_mask = REGULATOR_CHANGE_STATUS,82},83.num_consumer_supplies = 1,84.consumer_supplies = &ads7846_supply,85};8687static struct fixed_voltage_config vads7846 = {88.supply_name = "vads7846",89.microvolts = 3300000, /* 3.3V */90.gpio = -EINVAL,91.startup_delay = 0,92.init_data = &vads7846_regulator,93};9495static struct platform_device vads7846_device = {96.name = "reg-fixed-voltage",97.id = 1,98.dev = {99.platform_data = &vads7846,100},101};102103static void __init overo_ads7846_init(void)104{105omap_ads7846_init(1, OVERO_GPIO_PENDOWN, 0, NULL);106platform_device_register(&vads7846_device);107}108109#else110static inline void __init overo_ads7846_init(void) { return; }111#endif112113#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)114115#include <linux/smsc911x.h>116#include <plat/gpmc-smsc911x.h>117118static struct omap_smsc911x_platform_data smsc911x_cfg = {119.id = 0,120.cs = OVERO_SMSC911X_CS,121.gpio_irq = OVERO_SMSC911X_GPIO,122.gpio_reset = -EINVAL,123.flags = SMSC911X_USE_32BIT,124};125126static struct omap_smsc911x_platform_data smsc911x2_cfg = {127.id = 1,128.cs = OVERO_SMSC911X2_CS,129.gpio_irq = OVERO_SMSC911X2_GPIO,130.gpio_reset = -EINVAL,131.flags = SMSC911X_USE_32BIT,132};133134static void __init overo_init_smsc911x(void)135{136gpmc_smsc911x_init(&smsc911x_cfg);137gpmc_smsc911x_init(&smsc911x2_cfg);138}139140#else141static inline void __init overo_init_smsc911x(void) { return; }142#endif143144/* DSS */145static int lcd_enabled;146static int dvi_enabled;147148#define OVERO_GPIO_LCD_EN 144149#define OVERO_GPIO_LCD_BL 145150151static struct gpio overo_dss_gpios[] __initdata = {152{ OVERO_GPIO_LCD_EN, GPIOF_OUT_INIT_HIGH, "OVERO_GPIO_LCD_EN" },153{ OVERO_GPIO_LCD_BL, GPIOF_OUT_INIT_HIGH, "OVERO_GPIO_LCD_BL" },154};155156static void __init overo_display_init(void)157{158if (gpio_request_array(overo_dss_gpios, ARRAY_SIZE(overo_dss_gpios))) {159printk(KERN_ERR "could not obtain DSS control GPIOs\n");160return;161}162163gpio_export(OVERO_GPIO_LCD_EN, 0);164gpio_export(OVERO_GPIO_LCD_BL, 0);165}166167static int overo_panel_enable_dvi(struct omap_dss_device *dssdev)168{169if (lcd_enabled) {170printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");171return -EINVAL;172}173dvi_enabled = 1;174175return 0;176}177178static void overo_panel_disable_dvi(struct omap_dss_device *dssdev)179{180dvi_enabled = 0;181}182183static struct panel_generic_dpi_data dvi_panel = {184.name = "generic",185.platform_enable = overo_panel_enable_dvi,186.platform_disable = overo_panel_disable_dvi,187};188189static struct omap_dss_device overo_dvi_device = {190.name = "dvi",191.type = OMAP_DISPLAY_TYPE_DPI,192.driver_name = "generic_dpi_panel",193.data = &dvi_panel,194.phy.dpi.data_lines = 24,195};196197static struct omap_dss_device overo_tv_device = {198.name = "tv",199.driver_name = "venc",200.type = OMAP_DISPLAY_TYPE_VENC,201.phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,202};203204static int overo_panel_enable_lcd(struct omap_dss_device *dssdev)205{206if (dvi_enabled) {207printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");208return -EINVAL;209}210211gpio_set_value(OVERO_GPIO_LCD_EN, 1);212gpio_set_value(OVERO_GPIO_LCD_BL, 1);213lcd_enabled = 1;214return 0;215}216217static void overo_panel_disable_lcd(struct omap_dss_device *dssdev)218{219gpio_set_value(OVERO_GPIO_LCD_EN, 0);220gpio_set_value(OVERO_GPIO_LCD_BL, 0);221lcd_enabled = 0;222}223224static struct panel_generic_dpi_data lcd43_panel = {225.name = "samsung_lte430wq_f0c",226.platform_enable = overo_panel_enable_lcd,227.platform_disable = overo_panel_disable_lcd,228};229230static struct omap_dss_device overo_lcd43_device = {231.name = "lcd43",232.type = OMAP_DISPLAY_TYPE_DPI,233.driver_name = "generic_dpi_panel",234.data = &lcd43_panel,235.phy.dpi.data_lines = 24,236};237238#if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \239defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)240static struct omap_dss_device overo_lcd35_device = {241.type = OMAP_DISPLAY_TYPE_DPI,242.name = "lcd35",243.driver_name = "lgphilips_lb035q02_panel",244.phy.dpi.data_lines = 24,245.platform_enable = overo_panel_enable_lcd,246.platform_disable = overo_panel_disable_lcd,247};248#endif249250static struct omap_dss_device *overo_dss_devices[] = {251&overo_dvi_device,252&overo_tv_device,253#if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \254defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)255&overo_lcd35_device,256#endif257&overo_lcd43_device,258};259260static struct omap_dss_board_info overo_dss_data = {261.num_devices = ARRAY_SIZE(overo_dss_devices),262.devices = overo_dss_devices,263.default_device = &overo_dvi_device,264};265266static struct regulator_consumer_supply overo_vdda_dac_supply =267REGULATOR_SUPPLY("vdda_dac", "omapdss_venc");268269static struct regulator_consumer_supply overo_vdds_dsi_supply[] = {270REGULATOR_SUPPLY("vdds_dsi", "omapdss"),271REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi1"),272};273274static struct mtd_partition overo_nand_partitions[] = {275{276.name = "xloader",277.offset = 0, /* Offset = 0x00000 */278.size = 4 * NAND_BLOCK_SIZE,279.mask_flags = MTD_WRITEABLE280},281{282.name = "uboot",283.offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */284.size = 14 * NAND_BLOCK_SIZE,285},286{287.name = "uboot environment",288.offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */289.size = 2 * NAND_BLOCK_SIZE,290},291{292.name = "linux",293.offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */294.size = 32 * NAND_BLOCK_SIZE,295},296{297.name = "rootfs",298.offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */299.size = MTDPART_SIZ_FULL,300},301};302303static struct omap2_hsmmc_info mmc[] = {304{305.mmc = 1,306.caps = MMC_CAP_4_BIT_DATA,307.gpio_cd = -EINVAL,308.gpio_wp = -EINVAL,309},310{311.mmc = 2,312.caps = MMC_CAP_4_BIT_DATA,313.gpio_cd = -EINVAL,314.gpio_wp = -EINVAL,315.transceiver = true,316.ocr_mask = 0x00100000, /* 3.3V */317},318{} /* Terminator */319};320321static struct regulator_consumer_supply overo_vmmc1_supply = {322.supply = "vmmc",323};324325#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)326#include <linux/leds.h>327328static struct gpio_led gpio_leds[] = {329{330.name = "overo:red:gpio21",331.default_trigger = "heartbeat",332.gpio = 21,333.active_low = true,334},335{336.name = "overo:blue:gpio22",337.default_trigger = "none",338.gpio = 22,339.active_low = true,340},341{342.name = "overo:blue:COM",343.default_trigger = "mmc0",344.gpio = -EINVAL, /* gets replaced */345.active_low = true,346},347};348349static struct gpio_led_platform_data gpio_leds_pdata = {350.leds = gpio_leds,351.num_leds = ARRAY_SIZE(gpio_leds),352};353354static struct platform_device gpio_leds_device = {355.name = "leds-gpio",356.id = -1,357.dev = {358.platform_data = &gpio_leds_pdata,359},360};361362static void __init overo_init_led(void)363{364platform_device_register(&gpio_leds_device);365}366367#else368static inline void __init overo_init_led(void) { return; }369#endif370371#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)372#include <linux/input.h>373#include <linux/gpio_keys.h>374375static struct gpio_keys_button gpio_buttons[] = {376{377.code = BTN_0,378.gpio = 23,379.desc = "button0",380.wakeup = 1,381},382{383.code = BTN_1,384.gpio = 14,385.desc = "button1",386.wakeup = 1,387},388};389390static struct gpio_keys_platform_data gpio_keys_pdata = {391.buttons = gpio_buttons,392.nbuttons = ARRAY_SIZE(gpio_buttons),393};394395static struct platform_device gpio_keys_device = {396.name = "gpio-keys",397.id = -1,398.dev = {399.platform_data = &gpio_keys_pdata,400},401};402403static void __init overo_init_keys(void)404{405platform_device_register(&gpio_keys_device);406}407408#else409static inline void __init overo_init_keys(void) { return; }410#endif411412static int overo_twl_gpio_setup(struct device *dev,413unsigned gpio, unsigned ngpio)414{415omap2_hsmmc_init(mmc);416417overo_vmmc1_supply.dev = mmc[0].dev;418419#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)420/* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */421gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;422#endif423424return 0;425}426427static struct twl4030_gpio_platform_data overo_gpio_data = {428.gpio_base = OMAP_MAX_GPIO_LINES,429.irq_base = TWL4030_GPIO_IRQ_BASE,430.irq_end = TWL4030_GPIO_IRQ_END,431.use_leds = true,432.setup = overo_twl_gpio_setup,433};434435static struct twl4030_usb_data overo_usb_data = {436.usb_mode = T2_USB_MODE_ULPI,437};438439static struct regulator_init_data overo_vmmc1 = {440.constraints = {441.min_uV = 1850000,442.max_uV = 3150000,443.valid_modes_mask = REGULATOR_MODE_NORMAL444| REGULATOR_MODE_STANDBY,445.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE446| REGULATOR_CHANGE_MODE447| REGULATOR_CHANGE_STATUS,448},449.num_consumer_supplies = 1,450.consumer_supplies = &overo_vmmc1_supply,451};452453/* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */454static struct regulator_init_data overo_vdac = {455.constraints = {456.min_uV = 1800000,457.max_uV = 1800000,458.valid_modes_mask = REGULATOR_MODE_NORMAL459| REGULATOR_MODE_STANDBY,460.valid_ops_mask = REGULATOR_CHANGE_MODE461| REGULATOR_CHANGE_STATUS,462},463.num_consumer_supplies = 1,464.consumer_supplies = &overo_vdda_dac_supply,465};466467/* VPLL2 for digital video outputs */468static struct regulator_init_data overo_vpll2 = {469.constraints = {470.name = "VDVI",471.min_uV = 1800000,472.max_uV = 1800000,473.valid_modes_mask = REGULATOR_MODE_NORMAL474| REGULATOR_MODE_STANDBY,475.valid_ops_mask = REGULATOR_CHANGE_MODE476| REGULATOR_CHANGE_STATUS,477},478.num_consumer_supplies = ARRAY_SIZE(overo_vdds_dsi_supply),479.consumer_supplies = overo_vdds_dsi_supply,480};481482static struct twl4030_codec_audio_data overo_audio_data;483484static struct twl4030_codec_data overo_codec_data = {485.audio_mclk = 26000000,486.audio = &overo_audio_data,487};488489static struct twl4030_platform_data overo_twldata = {490.irq_base = TWL4030_IRQ_BASE,491.irq_end = TWL4030_IRQ_END,492.gpio = &overo_gpio_data,493.usb = &overo_usb_data,494.codec = &overo_codec_data,495.vmmc1 = &overo_vmmc1,496.vdac = &overo_vdac,497.vpll2 = &overo_vpll2,498};499500static int __init overo_i2c_init(void)501{502omap3_pmic_init("tps65950", &overo_twldata);503/* i2c2 pins are used for gpio */504omap_register_i2c_bus(3, 400, NULL, 0);505return 0;506}507508static struct spi_board_info overo_spi_board_info[] __initdata = {509#if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \510defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)511{512.modalias = "lgphilips_lb035q02_panel-spi",513.bus_num = 1,514.chip_select = 1,515.max_speed_hz = 500000,516.mode = SPI_MODE_3,517},518#endif519};520521static int __init overo_spi_init(void)522{523overo_ads7846_init();524spi_register_board_info(overo_spi_board_info,525ARRAY_SIZE(overo_spi_board_info));526return 0;527}528529static void __init overo_init_early(void)530{531omap2_init_common_infrastructure();532omap2_init_common_devices(mt46h32m32lf6_sdrc_params,533mt46h32m32lf6_sdrc_params);534}535536static const struct usbhs_omap_board_data usbhs_bdata __initconst = {537.port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,538.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,539.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,540.phy_reset = true,541.reset_gpio_port[0] = -EINVAL,542.reset_gpio_port[1] = OVERO_GPIO_USBH_NRESET,543.reset_gpio_port[2] = -EINVAL544};545546#ifdef CONFIG_OMAP_MUX547static struct omap_board_mux board_mux[] __initdata = {548{ .reg_offset = OMAP_MUX_TERMINATOR },549};550#endif551552static struct gpio overo_bt_gpios[] __initdata = {553{ OVERO_GPIO_BT_XGATE, GPIOF_OUT_INIT_LOW, "lcd enable" },554{ OVERO_GPIO_BT_NRESET, GPIOF_OUT_INIT_HIGH, "lcd bl enable" },555};556557static void __init overo_init(void)558{559int ret;560561omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);562overo_i2c_init();563omap_display_init(&overo_dss_data);564omap_serial_init();565omap_nand_flash_init(0, overo_nand_partitions,566ARRAY_SIZE(overo_nand_partitions));567usb_musb_init(NULL);568usbhs_init(&usbhs_bdata);569overo_spi_init();570overo_ads7846_init();571overo_init_smsc911x();572overo_display_init();573overo_init_led();574overo_init_keys();575576/* Ensure SDRC pins are mux'd for self-refresh */577omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);578omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);579580ret = gpio_request_one(OVERO_GPIO_W2W_NRESET, GPIOF_OUT_INIT_HIGH,581"OVERO_GPIO_W2W_NRESET");582if (ret == 0) {583gpio_export(OVERO_GPIO_W2W_NRESET, 0);584gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);585udelay(10);586gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);587} else {588printk(KERN_ERR "could not obtain gpio for "589"OVERO_GPIO_W2W_NRESET\n");590}591592ret = gpio_request_array(overo_bt_gpios, ARRAY_SIZE(overo_bt_gpios));593if (ret) {594pr_err("%s: could not obtain BT gpios\n", __func__);595} else {596gpio_export(OVERO_GPIO_BT_XGATE, 0);597gpio_export(OVERO_GPIO_BT_NRESET, 0);598gpio_set_value(OVERO_GPIO_BT_NRESET, 0);599mdelay(6);600gpio_set_value(OVERO_GPIO_BT_NRESET, 1);601}602603ret = gpio_request_one(OVERO_GPIO_USBH_CPEN, GPIOF_OUT_INIT_HIGH,604"OVERO_GPIO_USBH_CPEN");605if (ret == 0)606gpio_export(OVERO_GPIO_USBH_CPEN, 0);607else608printk(KERN_ERR "could not obtain gpio for "609"OVERO_GPIO_USBH_CPEN\n");610}611612MACHINE_START(OVERO, "Gumstix Overo")613.boot_params = 0x80000100,614.reserve = omap_reserve,615.map_io = omap3_map_io,616.init_early = overo_init_early,617.init_irq = omap_init_irq,618.init_machine = overo_init,619.timer = &omap_timer,620MACHINE_END621622623