Path: blob/master/arch/arm/mach-davinci/board-omapl138-hawk.c
10699 views
/*1* Hawkboard.org based on TI's OMAP-L138 Platform2*3* Initial code: Syed Mohammed Khasim4*5* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com6*7* This file is licensed under the terms of the GNU General Public License8* version 2. This program is licensed "as is" without any warranty of9* any kind, whether express or implied.10*/11#include <linux/kernel.h>12#include <linux/init.h>13#include <linux/console.h>14#include <linux/gpio.h>1516#include <asm/mach-types.h>17#include <asm/mach/arch.h>1819#include <mach/cp_intc.h>20#include <mach/da8xx.h>21#include <mach/mux.h>2223#define HAWKBOARD_PHY_ID "0:07"24#define DA850_HAWK_MMCSD_CD_PIN GPIO_TO_PIN(3, 12)25#define DA850_HAWK_MMCSD_WP_PIN GPIO_TO_PIN(3, 13)2627#define DA850_USB1_VBUS_PIN GPIO_TO_PIN(2, 4)28#define DA850_USB1_OC_PIN GPIO_TO_PIN(6, 13)2930static short omapl138_hawk_mii_pins[] __initdata = {31DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,32DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,33DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,34DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,35DA850_MDIO_D,36-137};3839static __init void omapl138_hawk_config_emac(void)40{41void __iomem *cfgchip3 = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);42int ret;43u32 val;44struct davinci_soc_info *soc_info = &davinci_soc_info;4546val = __raw_readl(cfgchip3);47val &= ~BIT(8);48ret = davinci_cfg_reg_list(omapl138_hawk_mii_pins);49if (ret) {50pr_warning("%s: cpgmac/mii mux setup failed: %d\n",51__func__, ret);52return;53}5455/* configure the CFGCHIP3 register for MII */56__raw_writel(val, cfgchip3);57pr_info("EMAC: MII PHY configured\n");5859soc_info->emac_pdata->phy_id = HAWKBOARD_PHY_ID;6061ret = da8xx_register_emac();62if (ret)63pr_warning("%s: emac registration failed: %d\n",64__func__, ret);65}6667/*68* The following EDMA channels/slots are not being used by drivers (for69* example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM/Hawkboard,70* hence they are being reserved for codecs on the DSP side.71*/72static const s16 da850_dma0_rsv_chans[][2] = {73/* (offset, number) */74{ 8, 6},75{24, 4},76{30, 2},77{-1, -1}78};7980static const s16 da850_dma0_rsv_slots[][2] = {81/* (offset, number) */82{ 8, 6},83{24, 4},84{30, 50},85{-1, -1}86};8788static const s16 da850_dma1_rsv_chans[][2] = {89/* (offset, number) */90{ 0, 28},91{30, 2},92{-1, -1}93};9495static const s16 da850_dma1_rsv_slots[][2] = {96/* (offset, number) */97{ 0, 28},98{30, 90},99{-1, -1}100};101102static struct edma_rsv_info da850_edma_cc0_rsv = {103.rsv_chans = da850_dma0_rsv_chans,104.rsv_slots = da850_dma0_rsv_slots,105};106107static struct edma_rsv_info da850_edma_cc1_rsv = {108.rsv_chans = da850_dma1_rsv_chans,109.rsv_slots = da850_dma1_rsv_slots,110};111112static struct edma_rsv_info *da850_edma_rsv[2] = {113&da850_edma_cc0_rsv,114&da850_edma_cc1_rsv,115};116117static const short hawk_mmcsd0_pins[] = {118DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,119DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,120DA850_GPIO3_12, DA850_GPIO3_13,121-1122};123124static int da850_hawk_mmc_get_ro(int index)125{126return gpio_get_value(DA850_HAWK_MMCSD_WP_PIN);127}128129static int da850_hawk_mmc_get_cd(int index)130{131return !gpio_get_value(DA850_HAWK_MMCSD_CD_PIN);132}133134static struct davinci_mmc_config da850_mmc_config = {135.get_ro = da850_hawk_mmc_get_ro,136.get_cd = da850_hawk_mmc_get_cd,137.wires = 4,138.max_freq = 50000000,139.caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,140.version = MMC_CTLR_VERSION_2,141};142143static __init void omapl138_hawk_mmc_init(void)144{145int ret;146147ret = davinci_cfg_reg_list(hawk_mmcsd0_pins);148if (ret) {149pr_warning("%s: MMC/SD0 mux setup failed: %d\n",150__func__, ret);151return;152}153154ret = gpio_request_one(DA850_HAWK_MMCSD_CD_PIN,155GPIOF_DIR_IN, "MMC CD");156if (ret < 0) {157pr_warning("%s: can not open GPIO %d\n",158__func__, DA850_HAWK_MMCSD_CD_PIN);159return;160}161162ret = gpio_request_one(DA850_HAWK_MMCSD_WP_PIN,163GPIOF_DIR_IN, "MMC WP");164if (ret < 0) {165pr_warning("%s: can not open GPIO %d\n",166__func__, DA850_HAWK_MMCSD_WP_PIN);167goto mmc_setup_wp_fail;168}169170ret = da8xx_register_mmcsd0(&da850_mmc_config);171if (ret) {172pr_warning("%s: MMC/SD0 registration failed: %d\n",173__func__, ret);174goto mmc_setup_mmcsd_fail;175}176177return;178179mmc_setup_mmcsd_fail:180gpio_free(DA850_HAWK_MMCSD_WP_PIN);181mmc_setup_wp_fail:182gpio_free(DA850_HAWK_MMCSD_CD_PIN);183}184185static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id);186static da8xx_ocic_handler_t hawk_usb_ocic_handler;187188static const short da850_hawk_usb11_pins[] = {189DA850_GPIO2_4, DA850_GPIO6_13,190-1191};192193static int hawk_usb_set_power(unsigned port, int on)194{195gpio_set_value(DA850_USB1_VBUS_PIN, on);196return 0;197}198199static int hawk_usb_get_power(unsigned port)200{201return gpio_get_value(DA850_USB1_VBUS_PIN);202}203204static int hawk_usb_get_oci(unsigned port)205{206return !gpio_get_value(DA850_USB1_OC_PIN);207}208209static int hawk_usb_ocic_notify(da8xx_ocic_handler_t handler)210{211int irq = gpio_to_irq(DA850_USB1_OC_PIN);212int error = 0;213214if (handler != NULL) {215hawk_usb_ocic_handler = handler;216217error = request_irq(irq, omapl138_hawk_usb_ocic_irq,218IRQF_DISABLED | IRQF_TRIGGER_RISING |219IRQF_TRIGGER_FALLING,220"OHCI over-current indicator", NULL);221if (error)222pr_err("%s: could not request IRQ to watch "223"over-current indicator changes\n", __func__);224} else {225free_irq(irq, NULL);226}227return error;228}229230static struct da8xx_ohci_root_hub omapl138_hawk_usb11_pdata = {231.set_power = hawk_usb_set_power,232.get_power = hawk_usb_get_power,233.get_oci = hawk_usb_get_oci,234.ocic_notify = hawk_usb_ocic_notify,235/* TPS2087 switch @ 5V */236.potpgt = (3 + 1) / 2, /* 3 ms max */237};238239static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id)240{241hawk_usb_ocic_handler(&omapl138_hawk_usb11_pdata, 1);242return IRQ_HANDLED;243}244245static __init void omapl138_hawk_usb_init(void)246{247int ret;248u32 cfgchip2;249250ret = davinci_cfg_reg_list(da850_hawk_usb11_pins);251if (ret) {252pr_warning("%s: USB 1.1 PinMux setup failed: %d\n",253__func__, ret);254return;255}256257/* Setup the Ref. clock frequency for the HAWK at 24 MHz. */258259cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));260cfgchip2 &= ~CFGCHIP2_REFFREQ;261cfgchip2 |= CFGCHIP2_REFFREQ_24MHZ;262__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));263264ret = gpio_request_one(DA850_USB1_VBUS_PIN,265GPIOF_DIR_OUT, "USB1 VBUS");266if (ret < 0) {267pr_err("%s: failed to request GPIO for USB 1.1 port "268"power control: %d\n", __func__, ret);269return;270}271272ret = gpio_request_one(DA850_USB1_OC_PIN,273GPIOF_DIR_IN, "USB1 OC");274if (ret < 0) {275pr_err("%s: failed to request GPIO for USB 1.1 port "276"over-current indicator: %d\n", __func__, ret);277goto usb11_setup_oc_fail;278}279280ret = da8xx_register_usb11(&omapl138_hawk_usb11_pdata);281if (ret) {282pr_warning("%s: USB 1.1 registration failed: %d\n",283__func__, ret);284goto usb11_setup_fail;285}286287return;288289usb11_setup_fail:290gpio_free(DA850_USB1_OC_PIN);291usb11_setup_oc_fail:292gpio_free(DA850_USB1_VBUS_PIN);293}294295static struct davinci_uart_config omapl138_hawk_uart_config __initdata = {296.enabled_uarts = 0x7,297};298299static __init void omapl138_hawk_init(void)300{301int ret;302303davinci_serial_init(&omapl138_hawk_uart_config);304305omapl138_hawk_config_emac();306307ret = da850_register_edma(da850_edma_rsv);308if (ret)309pr_warning("%s: EDMA registration failed: %d\n",310__func__, ret);311312omapl138_hawk_mmc_init();313314omapl138_hawk_usb_init();315316ret = da8xx_register_watchdog();317if (ret)318pr_warning("omapl138_hawk_init: "319"watchdog registration failed: %d\n",320ret);321}322323#ifdef CONFIG_SERIAL_8250_CONSOLE324static int __init omapl138_hawk_console_init(void)325{326if (!machine_is_omapl138_hawkboard())327return 0;328329return add_preferred_console("ttyS", 2, "115200");330}331console_initcall(omapl138_hawk_console_init);332#endif333334static void __init omapl138_hawk_map_io(void)335{336da850_init();337}338339MACHINE_START(OMAPL138_HAWKBOARD, "AM18x/OMAP-L138 Hawkboard")340.boot_params = (DA8XX_DDR_BASE + 0x100),341.map_io = omapl138_hawk_map_io,342.init_irq = cp_intc_init,343.timer = &davinci_timer,344.init_machine = omapl138_hawk_init,345MACHINE_END346347348