Victor Rodriguez | 6c18c91 | 2010-09-23 11:28:40 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Hawkboard.org based on TI's OMAP-L138 Platform |
| 3 | * |
| 4 | * Initial code: Syed Mohammed Khasim |
| 5 | * |
| 6 | * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com |
| 7 | * |
| 8 | * This file is licensed under the terms of the GNU General Public License |
| 9 | * version 2. This program is licensed "as is" without any warranty of |
| 10 | * any kind, whether express or implied. |
| 11 | */ |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/console.h> |
| 15 | #include <linux/gpio.h> |
| 16 | |
| 17 | #include <asm/mach-types.h> |
| 18 | #include <asm/mach/arch.h> |
| 19 | |
| 20 | #include <mach/cp_intc.h> |
| 21 | #include <mach/da8xx.h> |
Victor Rodriguez | bb59b7f | 2010-12-27 16:43:08 -0600 | [diff] [blame] | 22 | #include <mach/mux.h> |
| 23 | |
| 24 | #define HAWKBOARD_PHY_ID "0:07" |
Victor Rodriguez | ef782d8d | 2010-12-27 16:43:11 -0600 | [diff] [blame^] | 25 | #define DA850_HAWK_MMCSD_CD_PIN GPIO_TO_PIN(3, 12) |
| 26 | #define DA850_HAWK_MMCSD_WP_PIN GPIO_TO_PIN(3, 13) |
Victor Rodriguez | bb59b7f | 2010-12-27 16:43:08 -0600 | [diff] [blame] | 27 | |
| 28 | static short omapl138_hawk_mii_pins[] __initdata = { |
| 29 | DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3, |
| 30 | DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER, |
| 31 | DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3, |
| 32 | DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK, |
| 33 | DA850_MDIO_D, |
| 34 | -1 |
| 35 | }; |
| 36 | |
| 37 | static __init void omapl138_hawk_config_emac(void) |
| 38 | { |
| 39 | void __iomem *cfgchip3 = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG); |
| 40 | int ret; |
| 41 | u32 val; |
| 42 | struct davinci_soc_info *soc_info = &davinci_soc_info; |
| 43 | |
| 44 | val = __raw_readl(cfgchip3); |
| 45 | val &= ~BIT(8); |
| 46 | ret = davinci_cfg_reg_list(omapl138_hawk_mii_pins); |
| 47 | if (ret) { |
| 48 | pr_warning("%s: cpgmac/mii mux setup failed: %d\n", |
| 49 | __func__, ret); |
| 50 | return; |
| 51 | } |
| 52 | |
| 53 | /* configure the CFGCHIP3 register for MII */ |
| 54 | __raw_writel(val, cfgchip3); |
| 55 | pr_info("EMAC: MII PHY configured\n"); |
| 56 | |
| 57 | soc_info->emac_pdata->phy_id = HAWKBOARD_PHY_ID; |
| 58 | |
| 59 | ret = da8xx_register_emac(); |
| 60 | if (ret) |
| 61 | pr_warning("%s: emac registration failed: %d\n", |
| 62 | __func__, ret); |
| 63 | } |
| 64 | |
Victor Rodriguez | 5f72f38 | 2010-12-27 16:43:09 -0600 | [diff] [blame] | 65 | /* |
| 66 | * The following EDMA channels/slots are not being used by drivers (for |
| 67 | * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM/Hawkboard, |
| 68 | * hence they are being reserved for codecs on the DSP side. |
| 69 | */ |
| 70 | static const s16 da850_dma0_rsv_chans[][2] = { |
| 71 | /* (offset, number) */ |
| 72 | { 8, 6}, |
| 73 | {24, 4}, |
| 74 | {30, 2}, |
| 75 | {-1, -1} |
| 76 | }; |
| 77 | |
| 78 | static const s16 da850_dma0_rsv_slots[][2] = { |
| 79 | /* (offset, number) */ |
| 80 | { 8, 6}, |
| 81 | {24, 4}, |
| 82 | {30, 50}, |
| 83 | {-1, -1} |
| 84 | }; |
| 85 | |
| 86 | static const s16 da850_dma1_rsv_chans[][2] = { |
| 87 | /* (offset, number) */ |
| 88 | { 0, 28}, |
| 89 | {30, 2}, |
| 90 | {-1, -1} |
| 91 | }; |
| 92 | |
| 93 | static const s16 da850_dma1_rsv_slots[][2] = { |
| 94 | /* (offset, number) */ |
| 95 | { 0, 28}, |
| 96 | {30, 90}, |
| 97 | {-1, -1} |
| 98 | }; |
| 99 | |
| 100 | static struct edma_rsv_info da850_edma_cc0_rsv = { |
| 101 | .rsv_chans = da850_dma0_rsv_chans, |
| 102 | .rsv_slots = da850_dma0_rsv_slots, |
| 103 | }; |
| 104 | |
| 105 | static struct edma_rsv_info da850_edma_cc1_rsv = { |
| 106 | .rsv_chans = da850_dma1_rsv_chans, |
| 107 | .rsv_slots = da850_dma1_rsv_slots, |
| 108 | }; |
| 109 | |
| 110 | static struct edma_rsv_info *da850_edma_rsv[2] = { |
| 111 | &da850_edma_cc0_rsv, |
| 112 | &da850_edma_cc1_rsv, |
| 113 | }; |
Victor Rodriguez | 6c18c91 | 2010-09-23 11:28:40 -0500 | [diff] [blame] | 114 | |
Victor Rodriguez | ef782d8d | 2010-12-27 16:43:11 -0600 | [diff] [blame^] | 115 | static const short hawk_mmcsd0_pins[] = { |
| 116 | DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2, |
| 117 | DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD, |
| 118 | DA850_GPIO3_12, DA850_GPIO3_13, |
| 119 | -1 |
| 120 | }; |
| 121 | |
| 122 | static int da850_hawk_mmc_get_ro(int index) |
| 123 | { |
| 124 | return gpio_get_value(DA850_HAWK_MMCSD_WP_PIN); |
| 125 | } |
| 126 | |
| 127 | static int da850_hawk_mmc_get_cd(int index) |
| 128 | { |
| 129 | return !gpio_get_value(DA850_HAWK_MMCSD_CD_PIN); |
| 130 | } |
| 131 | |
| 132 | static struct davinci_mmc_config da850_mmc_config = { |
| 133 | .get_ro = da850_hawk_mmc_get_ro, |
| 134 | .get_cd = da850_hawk_mmc_get_cd, |
| 135 | .wires = 4, |
| 136 | .max_freq = 50000000, |
| 137 | .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED, |
| 138 | .version = MMC_CTLR_VERSION_2, |
| 139 | }; |
| 140 | |
| 141 | static __init void omapl138_hawk_mmc_init(void) |
| 142 | { |
| 143 | int ret; |
| 144 | |
| 145 | ret = davinci_cfg_reg_list(hawk_mmcsd0_pins); |
| 146 | if (ret) { |
| 147 | pr_warning("%s: MMC/SD0 mux setup failed: %d\n", |
| 148 | __func__, ret); |
| 149 | return; |
| 150 | } |
| 151 | |
| 152 | ret = gpio_request_one(DA850_HAWK_MMCSD_CD_PIN, |
| 153 | GPIOF_DIR_IN, "MMC CD"); |
| 154 | if (ret < 0) { |
| 155 | pr_warning("%s: can not open GPIO %d\n", |
| 156 | __func__, DA850_HAWK_MMCSD_CD_PIN); |
| 157 | return; |
| 158 | } |
| 159 | |
| 160 | ret = gpio_request_one(DA850_HAWK_MMCSD_WP_PIN, |
| 161 | GPIOF_DIR_IN, "MMC WP"); |
| 162 | if (ret < 0) { |
| 163 | pr_warning("%s: can not open GPIO %d\n", |
| 164 | __func__, DA850_HAWK_MMCSD_WP_PIN); |
| 165 | goto mmc_setup_wp_fail; |
| 166 | } |
| 167 | |
| 168 | ret = da8xx_register_mmcsd0(&da850_mmc_config); |
| 169 | if (ret) { |
| 170 | pr_warning("%s: MMC/SD0 registration failed: %d\n", |
| 171 | __func__, ret); |
| 172 | goto mmc_setup_mmcsd_fail; |
| 173 | } |
| 174 | |
| 175 | return; |
| 176 | |
| 177 | mmc_setup_mmcsd_fail: |
| 178 | gpio_free(DA850_HAWK_MMCSD_WP_PIN); |
| 179 | mmc_setup_wp_fail: |
| 180 | gpio_free(DA850_HAWK_MMCSD_CD_PIN); |
| 181 | } |
| 182 | |
Victor Rodriguez | 6c18c91 | 2010-09-23 11:28:40 -0500 | [diff] [blame] | 183 | static struct davinci_uart_config omapl138_hawk_uart_config __initdata = { |
| 184 | .enabled_uarts = 0x7, |
| 185 | }; |
| 186 | |
| 187 | static __init void omapl138_hawk_init(void) |
| 188 | { |
| 189 | int ret; |
| 190 | |
| 191 | davinci_serial_init(&omapl138_hawk_uart_config); |
| 192 | |
Victor Rodriguez | bb59b7f | 2010-12-27 16:43:08 -0600 | [diff] [blame] | 193 | omapl138_hawk_config_emac(); |
| 194 | |
Victor Rodriguez | 5f72f38 | 2010-12-27 16:43:09 -0600 | [diff] [blame] | 195 | ret = da850_register_edma(da850_edma_rsv); |
| 196 | if (ret) |
| 197 | pr_warning("%s: EDMA registration failed: %d\n", |
| 198 | __func__, ret); |
| 199 | |
Victor Rodriguez | ef782d8d | 2010-12-27 16:43:11 -0600 | [diff] [blame^] | 200 | omapl138_hawk_mmc_init(); |
| 201 | |
Victor Rodriguez | 6c18c91 | 2010-09-23 11:28:40 -0500 | [diff] [blame] | 202 | ret = da8xx_register_watchdog(); |
| 203 | if (ret) |
| 204 | pr_warning("omapl138_hawk_init: " |
| 205 | "watchdog registration failed: %d\n", |
| 206 | ret); |
| 207 | } |
| 208 | |
| 209 | #ifdef CONFIG_SERIAL_8250_CONSOLE |
| 210 | static int __init omapl138_hawk_console_init(void) |
| 211 | { |
| 212 | if (!machine_is_omapl138_hawkboard()) |
| 213 | return 0; |
| 214 | |
| 215 | return add_preferred_console("ttyS", 2, "115200"); |
| 216 | } |
| 217 | console_initcall(omapl138_hawk_console_init); |
| 218 | #endif |
| 219 | |
| 220 | static void __init omapl138_hawk_map_io(void) |
| 221 | { |
| 222 | da850_init(); |
| 223 | } |
| 224 | |
| 225 | MACHINE_START(OMAPL138_HAWKBOARD, "AM18x/OMAP-L138 Hawkboard") |
Victor Rodriguez | 6c18c91 | 2010-09-23 11:28:40 -0500 | [diff] [blame] | 226 | .boot_params = (DA8XX_DDR_BASE + 0x100), |
| 227 | .map_io = omapl138_hawk_map_io, |
| 228 | .init_irq = cp_intc_init, |
| 229 | .timer = &davinci_timer, |
| 230 | .init_machine = omapl138_hawk_init, |
| 231 | MACHINE_END |