Search
SailfishOS Open Build Service
>
Projects
>
home:sledge
:
beagle
>
kernel-adaptation-dm3730
> 0003-mach-omap2-added-medistream-board.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File 0003-mach-omap2-added-medistream-board.patch of Package kernel-adaptation-dm3730
From b7d427f7898118796a7a9d4336bdc37e926c1bfa Mon Sep 17 00:00:00 2001 From: MediStream-Devel-VM <info@berlinux-solutions.de> Date: Mon, 6 Aug 2012 11:14:15 +0200 Subject: [PATCH 3/9] mach-omap2: -added medistream board --- arch/arm/mach-omap2/Kconfig | 7 + arch/arm/mach-omap2/Makefile | 1 + arch/arm/mach-omap2/board-medistream.c | 454 ++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/io.c | 4 + arch/arm/tools/mach-types | 1 + 5 files changed, 467 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-omap2/board-medistream.c diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig index 8141b76..9f9c9bc 100644 --- a/arch/arm/mach-omap2/Kconfig +++ b/arch/arm/mach-omap2/Kconfig @@ -196,6 +196,13 @@ config MACH_OMAP3EVM default y select OMAP_PACKAGE_CBB +config MACH_MEDISTREAM + bool "Bewatec MediStream Board" + depends on ARCH_OMAP3 + default y + select OMAP_PACKAGE_CUS + select NET_POLL_CONTROLLER if SMSC911X + config MACH_OMAP3517EVM bool "OMAP3517/ AM3517 EVM board" depends on ARCH_OMAP3 diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile index 49f92bc..d7ffe2b 100644 --- a/arch/arm/mach-omap2/Makefile +++ b/arch/arm/mach-omap2/Makefile @@ -200,6 +200,7 @@ obj-$(CONFIG_MACH_OMAP3_TORPEDO) += board-omap3logic.o obj-$(CONFIG_MACH_ENCORE) += board-omap3encore.o obj-$(CONFIG_MACH_OVERO) += board-overo.o obj-$(CONFIG_MACH_OMAP3EVM) += board-omap3evm.o +obj-$(CONFIG_MACH_MEDISTREAM) += board-medistream.o obj-$(CONFIG_MACH_OMAP3_PANDORA) += board-omap3pandora.o obj-$(CONFIG_MACH_OMAP_3430SDP) += board-3430sdp.o obj-$(CONFIG_MACH_NOKIA_N8X0) += board-n8x0.o diff --git a/arch/arm/mach-omap2/board-medistream.c b/arch/arm/mach-omap2/board-medistream.c new file mode 100644 index 0000000..d064604 --- /dev/null +++ b/arch/arm/mach-omap2/board-medistream.c @@ -0,0 +1,454 @@ +/* + * linux/arch/arm/mach-omap2/board-medistream.c + * + * Copyright (C) 2008 Texas Instruments + * + * Modified from mach-omap2/board-3430sdp.c + * + * Initial code: Syed Mohammed Khasim + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/platform_device.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/clk.h> +#include <linux/gpio.h> +#include <linux/input.h> +#include <linux/leds.h> +#include <linux/interrupt.h> + +#include <linux/mtd/mtd.h> +#include <linux/mtd/partitions.h> +#include <linux/mtd/nand.h> +#include <linux/mmc/host.h> + +#include <linux/spi/spi.h> +#include <linux/i2c/twl.h> +#include <linux/usb/otg.h> +#include <linux/smsc911x.h> + +#include <linux/regulator/fixed.h> +#include <linux/regulator/machine.h> +#include <linux/mmc/host.h> +#include <linux/export.h> + +#include <mach/hardware.h> +#include <asm/mach-types.h> +#include <asm/mach/arch.h> +#include <asm/mach/map.h> + +#include <plat/board.h> +#include <plat/usb.h> +#include "common.h" +#include <plat/mcspi.h> +#include <video/omapdss.h> +#include <video/omap-panel-dvi.h> + +#include "mux.h" +#include "sdram-micron-mt46h32m32lf-6.h" +#include "hsmmc.h" +#include "common-board-devices.h" + +#define MEDISTREAM_EHCI_VBUS 22 +#define MEDISTREAM_EHCI_SELECT 61 + +#define MEDISTREAM_ETHR_START 0x2c000000 +#define MEDISTREAM_ETHR_SIZE 1024 +#define MEDISTREAM_ETHR_GPIO_IRQ 29 +#define MEDISTREAM_SMSC911X_CS 5 + +#define MEDISTREAM_POWER_FEEDBACK_GPIO 41 + +enum { + MEDISTREAM_BOARD_GEN_1 = 0, /* OMAP3530 */ + MEDISTREAM_BOARD_GEN_2, /* DM3730 */ +}; + +static u8 medistream_version; + +u8 get_medistream_rev(void) +{ + return medistream_version; +} +EXPORT_SYMBOL(get_medistream_rev); + +static void __init medistream_get_revision(void) +{ + if (cpu_is_omap3630()) { + medistream_version = MEDISTREAM_BOARD_GEN_2; + } else { + medistream_version = MEDISTREAM_BOARD_GEN_1; + } +} + +static struct mtd_partition medistream_nand_partitions[] = { + /* All the partition sizes are listed in terms of NAND block size */ + { + .name = "X-Loader", + .offset = 0, + .size = 4 * NAND_BLOCK_SIZE, + .mask_flags = MTD_WRITEABLE, /* force read-only */ + }, + { + .name = "U-Boot", + .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */ + .size = 15 * NAND_BLOCK_SIZE, + .mask_flags = MTD_WRITEABLE, /* force read-only */ + }, + { + .name = "U-Boot Env", + .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */ + .size = 1 * NAND_BLOCK_SIZE, + }, + { + .name = "Kernel", + .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */ + .size = 40 * NAND_BLOCK_SIZE, + }, + { + .name = "File System", + .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */ + .size = MTDPART_SIZ_FULL, + }, +}; + +#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) +#include <plat/gpmc-smsc911x.h> + +static struct omap_smsc911x_platform_data smsc911x_cfg = { + .cs = MEDISTREAM_SMSC911X_CS, + .gpio_irq = MEDISTREAM_ETHR_GPIO_IRQ, + .gpio_reset = -EINVAL, + .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS, +}; + +static inline void __init medistream_init_smsc911x(void) +{ + gpmc_smsc911x_init(&smsc911x_cfg); +} + +#else +static inline void __init medistream_init_smsc911x(void) { return; } +#endif + +/* + * MEDISTREAM LCD Panel control signals + */ +#define MEDISTREAM_LED_ENABLE_GPIO 26 +#define MEDISTREAM_LCD_ENABLE_GPIO 134 + +static struct gpio medistream_dss_gpios[] __initdata = { + { MEDISTREAM_LED_ENABLE_GPIO, GPIOF_OUT_INIT_LOW, "led_enable" }, + { MEDISTREAM_LCD_ENABLE_GPIO, GPIOF_OUT_INIT_LOW, "lcd_enable" }, +}; + +static int lcd_enabled; + +static void __init medistream_display_init(void) +{ + omap_mux_init_gpio(MEDISTREAM_LED_ENABLE_GPIO, OMAP_PIN_INPUT); + omap_mux_init_gpio(MEDISTREAM_LCD_ENABLE_GPIO, OMAP_PIN_INPUT_PULLUP); + + if(gpio_request_array(medistream_dss_gpios, + ARRAY_SIZE(medistream_dss_gpios))) { + printk(KERN_ERR "failed to get lcd_panel_* gpios\n"); + } +} + +static int medistream_enable_lcd(struct omap_dss_device *dssdev) +{ + gpio_set_value(MEDISTREAM_LED_ENABLE_GPIO, 0); + gpio_set_value(MEDISTREAM_LCD_ENABLE_GPIO, 1); + + lcd_enabled = 1; + return 0; +} + +static void medistream_disable_lcd(struct omap_dss_device *dssdev) +{ + gpio_set_value(MEDISTREAM_LED_ENABLE_GPIO, 1); + gpio_set_value(MEDISTREAM_LCD_ENABLE_GPIO, 0); + + lcd_enabled = 0; +} + +static struct omap_dss_device medistream_lcd_device = { + .name = "lcd", +#ifdef CONFIG_PANEL_MEDISTREAM + .driver_name = "Medistream Panel", +#endif + .type = OMAP_DISPLAY_TYPE_DPI, + .phy.dpi.data_lines = 24, + .platform_enable = medistream_enable_lcd, + .platform_disable = medistream_disable_lcd, +}; + +static struct omap_dss_device *medistream_dss_devices[] = { + &medistream_lcd_device, +}; + +static struct omap_dss_board_info medistream_dss_data = { + .num_devices = ARRAY_SIZE(medistream_dss_devices), + .devices = medistream_dss_devices, + .default_device = &medistream_lcd_device, +}; + +static struct regulator_consumer_supply medistream_vmmc1_supply[] = { + REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"), +}; + +static struct regulator_consumer_supply medistream_vsim_supply[] = { + REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.0"), +}; + +/* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */ +static struct regulator_init_data medistream_vmmc1 = { + .constraints = { + .min_uV = 1850000, + .max_uV = 3150000, + .valid_modes_mask = REGULATOR_MODE_NORMAL + | REGULATOR_MODE_STANDBY, + .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE + | REGULATOR_CHANGE_MODE + | REGULATOR_CHANGE_STATUS, + }, + .num_consumer_supplies = ARRAY_SIZE(medistream_vmmc1_supply), + .consumer_supplies = medistream_vmmc1_supply, +}; + +/* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */ +static struct regulator_init_data medistream_vsim = { + .constraints = { + .min_uV = 1800000, + .max_uV = 3000000, + .valid_modes_mask = REGULATOR_MODE_NORMAL + | REGULATOR_MODE_STANDBY, + .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE + | REGULATOR_CHANGE_MODE + | REGULATOR_CHANGE_STATUS, + }, + .num_consumer_supplies = ARRAY_SIZE(medistream_vsim_supply), + .consumer_supplies = medistream_vsim_supply, +}; + +static struct omap2_hsmmc_info mmc[] = { + { + .mmc = 1, + .caps = MMC_CAP_4_BIT_DATA, + .gpio_cd = -EINVAL, + .gpio_wp = 27, //65, + .deferred = true, + }, + {} /* Terminator */ +}; + +static int medistream_twl_gpio_setup(struct device *dev, + unsigned gpio, unsigned ngpio) +{ + omap_mux_init_gpio(65, OMAP_PIN_INPUT); + + /* gpio + 0 is "mmc0_cd" (input/IRQ) */ + mmc[0].gpio_cd = gpio + 0; + omap_hsmmc_late_init(mmc); + + return 0; +} + +static struct twl4030_gpio_platform_data medistream_gpio_data = { + .gpio_base = OMAP_MAX_GPIO_LINES, + .irq_base = TWL4030_GPIO_IRQ_BASE, + .irq_end = TWL4030_GPIO_IRQ_END, + .use_leds = true, + .setup = medistream_twl_gpio_setup, +}; + +static struct regulator_consumer_supply omap3evm_vio_supply[] = { + REGULATOR_SUPPLY("vcc", "spi1.0"), +}; + +/* VIO for ads7846 */ +static struct regulator_init_data omap3evm_vio = { + .constraints = { + .min_uV = 1800000, + .max_uV = 1800000, + .apply_uV = true, + .valid_modes_mask = REGULATOR_MODE_NORMAL + | REGULATOR_MODE_STANDBY, + .valid_ops_mask = REGULATOR_CHANGE_MODE + | REGULATOR_CHANGE_STATUS, + }, + .num_consumer_supplies = ARRAY_SIZE(omap3evm_vio_supply), + .consumer_supplies = omap3evm_vio_supply, +}; + +static struct twl4030_platform_data medistream_twldata = { + /* platform_data for children goes here */ + .gpio = &medistream_gpio_data, + .vmmc1 = &medistream_vmmc1, + .vsim = &medistream_vsim, +}; + +static int __init medistream_i2c_init(void) +{ + omap3_pmic_get_config(&medistream_twldata, + TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_MADC | + TWL_COMMON_PDATA_AUDIO, + TWL_COMMON_REGULATOR_VDAC | TWL_COMMON_REGULATOR_VPLL2); + + medistream_twldata.vpll2->constraints.name = "VDVI"; + medistream_twldata.vdac->constraints.apply_uV = true; + medistream_twldata.vpll2->constraints.apply_uV = true; + + omap3_pmic_init("twl4030", &medistream_twldata); + omap_register_i2c_bus(2, 400, NULL, 0); + omap_register_i2c_bus(3, 400, NULL, 0); + return 0; +} + +static struct omap_board_config_kernel medistream_config[] __initdata = { +}; + +static struct usbhs_omap_board_data usbhs_bdata __initdata = { + + .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY, //OMAP_USBHS_PORT_MODE_UNUSED, + .port_mode[1] = OMAP_EHCI_PORT_MODE_TLL, //OMAP_EHCI_PORT_MODE_PHY, + .port_mode[2] = OMAP_EHCI_PORT_MODE_TLL, //OMAP_USBHS_PORT_MODE_UNUSED, + + .phy_reset = true, + + /* PHY reset GPIO will be runtime programmed based on EVM version */ + .reset_gpio_port[0] = -EINVAL, + .reset_gpio_port[1] = -EINVAL, + .reset_gpio_port[2] = -EINVAL +}; + +#ifdef CONFIG_OMAP_MUX +static struct omap_board_mux medistream_board_mux[] __initdata = { + OMAP3_MUX(ETK_D10, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), /* GPIO24, USB */ + OMAP3_MUX(ETK_D12, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), /* GPIO26, LCD backlight */ + OMAP3_MUX(ETK_D15, OMAP_MUX_MODE4 | OMAP_PIN_INPUT), /* GPIO29, ETH0 */ + OMAP3_MUX(SDMMC2_DAT2, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), /* GPIO134, LCD_EN */ + + /* Configure MCBSP3 pins to UART2 mux*/ + OMAP3_MUX(MCBSP3_DX, OMAP_MUX_MODE1 | OMAP_PIN_OUTPUT | OMAP_PULL_ENA |OMAP_PULL_UP ), + OMAP3_MUX(MCBSP3_DR, OMAP_MUX_MODE1 | OMAP_PIN_INPUT), + OMAP3_MUX(MCBSP3_CLKX, OMAP_MUX_MODE1 | OMAP_PIN_OUTPUT), + OMAP3_MUX(MCBSP3_FSX, OMAP_MUX_MODE1 | OMAP_PIN_INPUT), + + /* power feedback pin */ + OMAP3_MUX(GPMC_A8, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT |OMAP_PULL_ENA |OMAP_PULL_UP), + + { .reg_offset = OMAP_MUX_TERMINATOR }, +}; +#else +#define medistream_board_mux NULL +#endif + +static void medistream_poweroff(void) { + u8 val; + + // set powerfeedback pin to low + gpio_set_value(MEDISTREAM_POWER_FEEDBACK_GPIO, 0); + + // set DEVOFF bit of PWR_P1_SW_EVENTS + if(twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &val, 0x10)) { + printk(KERN_WARNING "I2C error while reading TWL4030" "PM_MASTER P1_SW_EVENTS\n"); + } + val |= 0x01; + if(twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, val, 0x10)) { + printk(KERN_WARNING "I2C error while writing TWL4030" "PM_MASTER P1_SW_EVENTS\n"); + } +} + +static struct omap_musb_board_data musb_board_data = { + .interface_type = MUSB_INTERFACE_ULPI, + .mode = MUSB_OTG, + .power = 100, + .extvbus = 1, +}; + +static struct gpio medistream_ehci_gpios[] __initdata = { + { MEDISTREAM_EHCI_VBUS, GPIOF_OUT_INIT_HIGH, "enable EHCI VBUS" }, + { MEDISTREAM_EHCI_SELECT, GPIOF_OUT_INIT_LOW, "select EHCI port" }, + { MEDISTREAM_POWER_FEEDBACK_GPIO, GPIOF_OUT_INIT_HIGH, "POWER FEEDBACK" }, +}; + +static void __init medistream_init(void) +{ + pm_power_off = medistream_poweroff; + + medistream_get_revision(); + + omap3_mux_init(medistream_board_mux, OMAP_PACKAGE_CUS); + + omap_board_config = medistream_config; + omap_board_config_size = ARRAY_SIZE(medistream_config); + + if (gpio_request(24,"GPIO24") < 0) + printk(KERN_ERR "Can't get GPIO24 for USB reset\n"); + gpio_direction_output(24, 1); + gpio_set_value(24, 1); + + if (gpio_request(28,"GPIO24")<0) + printk(KERN_ERR "Can't get GPIO28 for USB phy reset\n"); + gpio_direction_output(28, 1); + gpio_set_value(28, 1); + + omap_mux_init_gpio(137, OMAP_PIN_OUTPUT); + if (gpio_request(137,"eth_rst")<0) + printk(KERN_ERR "Can't get 137 eth_rst\n"); + gpio_direction_output(137, 1); + gpio_set_value(137, 1); omap_hsmmc_init(mmc); + + medistream_i2c_init(); + + omap_display_init(&medistream_dss_data); + + omap_serial_init(); + omap_sdrc_init(mt46h32m32lf6_sdrc_params, NULL); + + /* MEDISTREAM uses ISP1504 phy and so register nop transceiver */ + usb_nop_xceiv_register(); + +#if 0 + /* enable EHCI VBUS using GPIO22 */ + omap_mux_init_gpio(MEDISTREAM_EHCI_VBUS, OMAP_PIN_INPUT_PULLUP); + /* Select EHCI port on main board */ + omap_mux_init_gpio(MEDISTREAM_EHCI_SELECT, + OMAP_PIN_INPUT_PULLUP); + gpio_request_array(medistream_ehci_gpios, + ARRAY_SIZE(medistream_ehci_gpios)); + + /* setup EHCI phy reset config */ + omap_mux_init_gpio(21, OMAP_PIN_INPUT_PULLUP); + usbhs_bdata.reset_gpio_port[1] = 21; +#endif + + usb_musb_init(&musb_board_data); + usbhs_init(&usbhs_bdata); + + omap_nand_flash_init(NAND_BUSWIDTH_16, medistream_nand_partitions, + ARRAY_SIZE(medistream_nand_partitions)); + + medistream_init_smsc911x(); + medistream_display_init(); +} + +MACHINE_START(MEDISTREAM, "Bewatec MediStream") + /* Maintainer: Syed Mohammed Khasim - Texas Instruments */ + .atag_offset = 0x100, + .reserve = omap_reserve, + .map_io = omap3_map_io, + .init_early = omap35xx_init_early, + .init_irq = omap3_init_irq, + .handle_irq = omap3_intc_handle_irq, + .init_machine = medistream_init, + .timer = &omap3_timer, + .restart = omap_prcm_restart, +MACHINE_END diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c index 065bd76..67af888 100644 --- a/arch/arm/mach-omap2/io.c +++ b/arch/arm/mach-omap2/io.c @@ -317,6 +317,7 @@ void __init omap44xx_map_common_io(void) * -EINVAL if the dpll3_m2_ck cannot be found, 0 if called on OMAP2, * or passes along the return value of clk_set_rate(). */ +#ifndef CONFIG_MACH_MEDISTREAM static int __init _omap2_init_reprogram_sdrc(void) { struct clk *dpll3_m2_ck; @@ -340,6 +341,7 @@ static int __init _omap2_init_reprogram_sdrc(void) return v; } +#endif static int _set_hwmod_postsetup_state(struct omap_hwmod *oh, void *data) { @@ -491,6 +493,8 @@ void __init omap_sdrc_init(struct omap_sdrc_params *sdrc_cs0, if (cpu_is_omap24xx() || omap3_has_sdrc()) { omap2_sdrc_init(sdrc_cs0, sdrc_cs1); +#ifndef CONFIG_MACH_MEDISTREAM _omap2_init_reprogram_sdrc(); +#endif } } diff --git a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types index f9c9f33..d1db747 100644 --- a/arch/arm/tools/mach-types +++ b/arch/arm/tools/mach-types @@ -1169,3 +1169,4 @@ elite_ulk MACH_ELITE_ULK ELITE_ULK 3888 pov2 MACH_POV2 POV2 3889 ipod_touch_2g MACH_IPOD_TOUCH_2G IPOD_TOUCH_2G 3890 da850_pqab MACH_DA850_PQAB DA850_PQAB 3891 +medistream MACH_MEDISTREAM MEDISTREAM 8888 -- 1.7.5.4