Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Maintainer : Steve Sakoman <steve@sakoman.com> |
| 3 | * |
| 4 | * Derived from Beagle Board, 3430 SDP, and OMAP3EVM code by |
| 5 | * Richard Woodruff <r-woodruff2@ti.com> |
| 6 | * Syed Mohammed Khasim <khasim@ti.com> |
| 7 | * Sunil Kumar <sunilsaini05@gmail.com> |
| 8 | * Shashi Ranjan <shashiranjanmca05@gmail.com> |
| 9 | * |
| 10 | * (C) Copyright 2004-2008 |
| 11 | * Texas Instruments, <www.ti.com> |
| 12 | * |
| 13 | * See file CREDITS for list of people who contributed to this |
| 14 | * project. |
| 15 | * |
| 16 | * This program is free software; you can redistribute it and/or |
| 17 | * modify it under the terms of the GNU General Public License as |
| 18 | * published by the Free Software Foundation; either version 2 of |
| 19 | * the License, or (at your option) any later version. |
| 20 | * |
| 21 | * This program is distributed in the hope that it will be useful, |
| 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 | * GNU General Public License for more details. |
| 25 | * |
| 26 | * You should have received a copy of the GNU General Public License |
| 27 | * along with this program; if not, write to the Free Software |
| 28 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 29 | * MA 02111-1307 USA |
| 30 | */ |
| 31 | #include <common.h> |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 32 | #include <netdev.h> |
Tom Rix | 0f2a804 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 33 | #include <twl4030.h> |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 34 | #include <asm/io.h> |
| 35 | #include <asm/arch/mux.h> |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 36 | #include <asm/arch/mem.h> |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 37 | #include <asm/arch/sys_proto.h> |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 38 | #include <asm/arch/gpio.h> |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 39 | #include <asm/mach-types.h> |
| 40 | #include "overo.h" |
| 41 | |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 42 | #if defined(CONFIG_CMD_NET) |
| 43 | static void setup_net_chip(void); |
| 44 | #endif |
| 45 | |
Steve Sakoman | 0d1d008 | 2010-08-12 21:07:02 -0700 | [diff] [blame] | 46 | /* GPMC definitions for LAN9221 chips on Tobi expansion boards */ |
| 47 | static const u32 gpmc_lan_config[] = { |
| 48 | NET_LAN9221_GPMC_CONFIG1, |
| 49 | NET_LAN9221_GPMC_CONFIG2, |
| 50 | NET_LAN9221_GPMC_CONFIG3, |
| 51 | NET_LAN9221_GPMC_CONFIG4, |
| 52 | NET_LAN9221_GPMC_CONFIG5, |
| 53 | NET_LAN9221_GPMC_CONFIG6, |
| 54 | /*CONFIG7- computed as params */ |
| 55 | }; |
| 56 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 57 | /* |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 58 | * Routine: board_init |
| 59 | * Description: Early hardware init. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 60 | */ |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 61 | int board_init(void) |
| 62 | { |
| 63 | DECLARE_GLOBAL_DATA_PTR; |
| 64 | |
| 65 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 66 | /* board id for Linux */ |
| 67 | gd->bd->bi_arch_number = MACH_TYPE_OVERO; |
| 68 | /* boot param addr */ |
| 69 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 70 | |
| 71 | return 0; |
| 72 | } |
| 73 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 74 | /* |
Steve Sakoman | 5ddc70b | 2010-08-12 15:13:02 -0700 | [diff] [blame] | 75 | * Routine: get_board_revision |
| 76 | * Description: Returns the board revision |
| 77 | */ |
| 78 | int get_board_revision(void) |
| 79 | { |
| 80 | int revision; |
| 81 | |
| 82 | if (!omap_request_gpio(112) && |
| 83 | !omap_request_gpio(113) && |
| 84 | !omap_request_gpio(115)) { |
| 85 | |
| 86 | omap_set_gpio_direction(112, 1); |
| 87 | omap_set_gpio_direction(113, 1); |
| 88 | omap_set_gpio_direction(115, 1); |
| 89 | |
| 90 | revision = omap_get_gpio_datain(115) << 2 | |
| 91 | omap_get_gpio_datain(113) << 1 | |
| 92 | omap_get_gpio_datain(112); |
| 93 | |
| 94 | omap_free_gpio(112); |
| 95 | omap_free_gpio(113); |
| 96 | omap_free_gpio(115); |
| 97 | } else { |
| 98 | printf("Error: unable to acquire board revision GPIOs\n"); |
| 99 | revision = -1; |
| 100 | } |
| 101 | |
| 102 | return revision; |
| 103 | } |
| 104 | |
| 105 | /* |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 106 | * Routine: get_sdio2_config |
| 107 | * Description: Return information about the wifi module connection |
| 108 | * Returns 0 if the module connects though a level translator |
| 109 | * Returns 1 if the module connects directly |
| 110 | */ |
| 111 | int get_sdio2_config(void) |
| 112 | { |
| 113 | int sdio_direct; |
| 114 | |
| 115 | if (!omap_request_gpio(130) && !omap_request_gpio(139)) { |
| 116 | |
| 117 | omap_set_gpio_direction(130, 0); |
| 118 | omap_set_gpio_direction(139, 1); |
| 119 | |
| 120 | sdio_direct = 1; |
| 121 | omap_set_gpio_dataout(130, 0); |
| 122 | if (omap_get_gpio_datain(139) == 0) { |
| 123 | omap_set_gpio_dataout(130, 1); |
| 124 | if (omap_get_gpio_datain(139) == 1) |
| 125 | sdio_direct = 0; |
| 126 | } |
| 127 | |
| 128 | omap_free_gpio(130); |
| 129 | omap_free_gpio(139); |
| 130 | } else { |
| 131 | printf("Error: unable to acquire sdio2 clk GPIOs\n"); |
| 132 | sdio_direct = -1; |
| 133 | } |
| 134 | |
| 135 | return sdio_direct; |
| 136 | } |
| 137 | |
| 138 | /* |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 139 | * Routine: misc_init_r |
| 140 | * Description: Configure board specific parts |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 141 | */ |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 142 | int misc_init_r(void) |
| 143 | { |
Tom Rix | 0f2a804 | 2009-06-28 12:52:30 -0500 | [diff] [blame] | 144 | twl4030_power_init(); |
Grazvydas Ignotas | 17887bf | 2009-12-10 17:10:21 +0200 | [diff] [blame] | 145 | twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 146 | |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 147 | #if defined(CONFIG_CMD_NET) |
| 148 | setup_net_chip(); |
| 149 | #endif |
| 150 | |
Steve Sakoman | 5ddc70b | 2010-08-12 15:13:02 -0700 | [diff] [blame] | 151 | printf("Board revision: %d\n", get_board_revision()); |
Steve Sakoman | 541ce99 | 2010-08-24 10:37:29 -0700 | [diff] [blame] | 152 | |
| 153 | switch (get_sdio2_config()) { |
| 154 | case 0: |
| 155 | printf("Tranceiver detected on mmc2\n"); |
| 156 | MUX_OVERO_SDIO2_TRANSCEIVER(); |
| 157 | break; |
| 158 | case 1: |
| 159 | printf("Direct connection on mmc2\n"); |
| 160 | MUX_OVERO_SDIO2_DIRECT(); |
| 161 | break; |
| 162 | default: |
| 163 | printf("Unable to detect mmc2 connection type\n"); |
| 164 | } |
| 165 | |
Dirk Behme | 12dbcf6 | 2009-03-12 19:30:50 +0100 | [diff] [blame] | 166 | dieid_num_r(); |
| 167 | |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 168 | return 0; |
| 169 | } |
| 170 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 171 | /* |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 172 | * Routine: set_muxconf_regs |
| 173 | * Description: Setting up the configuration Mux registers specific to the |
| 174 | * hardware. Many pins need to be moved from protect to primary |
| 175 | * mode. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 176 | */ |
Dirk Behme | 220faba | 2009-01-28 21:39:57 +0100 | [diff] [blame] | 177 | void set_muxconf_regs(void) |
| 178 | { |
| 179 | MUX_OVERO(); |
| 180 | } |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 181 | |
| 182 | #if defined(CONFIG_CMD_NET) |
| 183 | /* |
| 184 | * Routine: setup_net_chip |
| 185 | * Description: Setting up the configuration GPMC registers specific to the |
| 186 | * Ethernet hardware. |
| 187 | */ |
| 188 | static void setup_net_chip(void) |
| 189 | { |
| 190 | struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE; |
| 191 | |
Steve Sakoman | 0d1d008 | 2010-08-12 21:07:02 -0700 | [diff] [blame] | 192 | /* first lan chip */ |
| 193 | enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000, |
| 194 | GPMC_SIZE_16M); |
| 195 | |
| 196 | /* second lan chip */ |
| 197 | enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[4], 0x2B000000, |
| 198 | GPMC_SIZE_16M); |
Olof Johansson | 4963f92 | 2009-09-29 10:22:45 -0400 | [diff] [blame] | 199 | |
| 200 | /* Enable off mode for NWE in PADCONF_GPMC_NWE register */ |
| 201 | writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe); |
| 202 | /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */ |
| 203 | writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe); |
| 204 | /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */ |
| 205 | writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00, |
| 206 | &ctrl_base->gpmc_nadv_ale); |
| 207 | |
| 208 | /* Make GPIO 64 as output pin and send a magic pulse through it */ |
| 209 | if (!omap_request_gpio(64)) { |
| 210 | omap_set_gpio_direction(64, 0); |
| 211 | omap_set_gpio_dataout(64, 1); |
| 212 | udelay(1); |
| 213 | omap_set_gpio_dataout(64, 0); |
| 214 | udelay(1); |
| 215 | omap_set_gpio_dataout(64, 1); |
| 216 | } |
| 217 | } |
| 218 | #endif |
| 219 | |
| 220 | int board_eth_init(bd_t *bis) |
| 221 | { |
| 222 | int rc = 0; |
| 223 | #ifdef CONFIG_SMC911X |
| 224 | rc = smc911x_initialize(0, CONFIG_SMC911X_BASE); |
| 225 | #endif |
| 226 | return rc; |
| 227 | } |