Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2004-2008 |
| 3 | * Texas Instruments, <www.ti.com> |
| 4 | * |
| 5 | * Author : |
| 6 | * Manikandan Pillai <mani.pillai@ti.com> |
| 7 | * |
| 8 | * Derived from Beagle Board and 3430 SDP code by |
| 9 | * Richard Woodruff <r-woodruff2@ti.com> |
| 10 | * Syed Mohammed Khasim <khasim@ti.com> |
| 11 | * |
| 12 | * See file CREDITS for list of people who contributed to this |
| 13 | * project. |
| 14 | * |
| 15 | * This program is free software; you can redistribute it and/or |
| 16 | * modify it under the terms of the GNU General Public License as |
| 17 | * published by the Free Software Foundation; either version 2 of |
| 18 | * the License, or (at your option) any later version. |
| 19 | * |
| 20 | * This program is distributed in the hope that it will be useful, |
| 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | * GNU General Public License for more details. |
| 24 | * |
| 25 | * You should have received a copy of the GNU General Public License |
| 26 | * along with this program; if not, write to the Free Software |
| 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 28 | * MA 02111-1307 USA |
| 29 | */ |
| 30 | #include <common.h> |
Ben Warren | 736fead | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 31 | #include <netdev.h> |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 32 | #include <asm/io.h> |
| 33 | #include <asm/arch/mem.h> |
| 34 | #include <asm/arch/mux.h> |
| 35 | #include <asm/arch/sys_proto.h> |
Sriramakrishnan | c068258 | 2011-07-18 09:21:55 -0400 | [diff] [blame^] | 36 | #include <asm/arch/gpio.h> |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 37 | #include <i2c.h> |
| 38 | #include <asm/mach-types.h> |
| 39 | #include "evm.h" |
| 40 | |
Sriramakrishnan | c068258 | 2011-07-18 09:21:55 -0400 | [diff] [blame^] | 41 | #define OMAP3EVM_GPIO_ETH_RST_GEN1 64 |
| 42 | #define OMAP3EVM_GPIO_ETH_RST_GEN2 7 |
| 43 | |
John Rigby | 2956532 | 2010-12-20 18:27:51 -0700 | [diff] [blame] | 44 | DECLARE_GLOBAL_DATA_PTR; |
| 45 | |
Dirk Behme | b606ef4 | 2010-12-18 07:40:28 +0100 | [diff] [blame] | 46 | static u32 omap3_evm_version; |
Ajay Kumar Gupta | b5abf64 | 2010-06-10 11:20:49 +0530 | [diff] [blame] | 47 | |
Dirk Behme | b606ef4 | 2010-12-18 07:40:28 +0100 | [diff] [blame] | 48 | u32 get_omap3_evm_rev(void) |
Ajay Kumar Gupta | b5abf64 | 2010-06-10 11:20:49 +0530 | [diff] [blame] | 49 | { |
| 50 | return omap3_evm_version; |
| 51 | } |
| 52 | |
| 53 | static void omap3_evm_get_revision(void) |
| 54 | { |
Sanjeev Premi | 76ee9a2 | 2010-11-04 16:02:32 -0400 | [diff] [blame] | 55 | #if defined(CONFIG_CMD_NET) |
| 56 | /* |
| 57 | * Board revision can be ascertained only by identifying |
| 58 | * the Ethernet chipset. |
| 59 | */ |
Ajay Kumar Gupta | b5abf64 | 2010-06-10 11:20:49 +0530 | [diff] [blame] | 60 | unsigned int smsc_id; |
| 61 | |
| 62 | /* Ethernet PHY ID is stored at ID_REV register */ |
| 63 | smsc_id = readl(CONFIG_SMC911X_BASE + 0x50) & 0xFFFF0000; |
| 64 | printf("Read back SMSC id 0x%x\n", smsc_id); |
| 65 | |
| 66 | switch (smsc_id) { |
| 67 | /* SMSC9115 chipset */ |
| 68 | case 0x01150000: |
| 69 | omap3_evm_version = OMAP3EVM_BOARD_GEN_1; |
| 70 | break; |
| 71 | /* SMSC 9220 chipset */ |
| 72 | case 0x92200000: |
| 73 | default: |
| 74 | omap3_evm_version = OMAP3EVM_BOARD_GEN_2; |
| 75 | } |
Sanjeev Premi | 76ee9a2 | 2010-11-04 16:02:32 -0400 | [diff] [blame] | 76 | #else |
| 77 | #if defined(CONFIG_STATIC_BOARD_REV) |
| 78 | /* |
| 79 | * Look for static defintion of the board revision |
| 80 | */ |
| 81 | omap3_evm_version = CONFIG_STATIC_BOARD_REV; |
| 82 | #else |
| 83 | /* |
| 84 | * Fallback to the default above. |
| 85 | */ |
| 86 | omap3_evm_version = OMAP3EVM_BOARD_GEN_2; |
| 87 | #endif |
| 88 | #endif /* CONFIG_CMD_NET */ |
Ajay Kumar Gupta | b5abf64 | 2010-06-10 11:20:49 +0530 | [diff] [blame] | 89 | } |
| 90 | |
Sanjeev Premi | 63f4240 | 2010-11-04 16:02:29 -0400 | [diff] [blame] | 91 | #ifdef CONFIG_USB_OMAP3 |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 92 | /* |
Ajay Kumar Gupta | 944a489 | 2010-06-10 11:20:50 +0530 | [diff] [blame] | 93 | * MUSB port on OMAP3EVM Rev >= E requires extvbus programming. |
| 94 | */ |
| 95 | u8 omap3_evm_need_extvbus(void) |
| 96 | { |
| 97 | u8 retval = 0; |
| 98 | |
| 99 | if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2) |
| 100 | retval = 1; |
| 101 | |
| 102 | return retval; |
| 103 | } |
Sanjeev Premi | 63f4240 | 2010-11-04 16:02:29 -0400 | [diff] [blame] | 104 | #endif |
Ajay Kumar Gupta | 944a489 | 2010-06-10 11:20:50 +0530 | [diff] [blame] | 105 | |
| 106 | /* |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 107 | * Routine: board_init |
| 108 | * Description: Early hardware init. |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 109 | */ |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 110 | int board_init(void) |
| 111 | { |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 112 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 113 | /* board id for Linux */ |
| 114 | gd->bd->bi_arch_number = MACH_TYPE_OMAP3EVM; |
| 115 | /* boot param addr */ |
| 116 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 117 | |
| 118 | return 0; |
| 119 | } |
| 120 | |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 121 | /* |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 122 | * Routine: misc_init_r |
| 123 | * Description: Init ethernet (done here so udelay works) |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 124 | */ |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 125 | int misc_init_r(void) |
| 126 | { |
| 127 | |
| 128 | #ifdef CONFIG_DRIVER_OMAP34XX_I2C |
| 129 | i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); |
| 130 | #endif |
| 131 | |
| 132 | #if defined(CONFIG_CMD_NET) |
| 133 | setup_net_chip(); |
| 134 | #endif |
Sanjeev Premi | 76ee9a2 | 2010-11-04 16:02:32 -0400 | [diff] [blame] | 135 | omap3_evm_get_revision(); |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 136 | |
Sanjeev Premi | 6921b31 | 2011-07-18 09:20:15 -0400 | [diff] [blame] | 137 | #if defined(CONFIG_CMD_NET) |
| 138 | reset_net_chip(); |
| 139 | #endif |
Dirk Behme | e6a6a70 | 2009-03-12 19:30:50 +0100 | [diff] [blame] | 140 | dieid_num_r(); |
| 141 | |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 142 | return 0; |
| 143 | } |
| 144 | |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 145 | /* |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 146 | * Routine: set_muxconf_regs |
| 147 | * Description: Setting up the configuration Mux registers specific to the |
| 148 | * hardware. Many pins need to be moved from protect to primary |
| 149 | * mode. |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 150 | */ |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 151 | void set_muxconf_regs(void) |
| 152 | { |
| 153 | MUX_EVM(); |
| 154 | } |
| 155 | |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 156 | /* |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 157 | * Routine: setup_net_chip |
| 158 | * Description: Setting up the configuration GPMC registers specific to the |
| 159 | * Ethernet hardware. |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 160 | */ |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 161 | static void setup_net_chip(void) |
| 162 | { |
Dirk Behme | 97a099e | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 163 | struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE; |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 164 | |
| 165 | /* Configure GPMC registers */ |
Dirk Behme | 8941135 | 2009-08-08 09:30:22 +0200 | [diff] [blame] | 166 | writel(NET_GPMC_CONFIG1, &gpmc_cfg->cs[5].config1); |
| 167 | writel(NET_GPMC_CONFIG2, &gpmc_cfg->cs[5].config2); |
| 168 | writel(NET_GPMC_CONFIG3, &gpmc_cfg->cs[5].config3); |
| 169 | writel(NET_GPMC_CONFIG4, &gpmc_cfg->cs[5].config4); |
| 170 | writel(NET_GPMC_CONFIG5, &gpmc_cfg->cs[5].config5); |
| 171 | writel(NET_GPMC_CONFIG6, &gpmc_cfg->cs[5].config6); |
| 172 | writel(NET_GPMC_CONFIG7, &gpmc_cfg->cs[5].config7); |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 173 | |
| 174 | /* Enable off mode for NWE in PADCONF_GPMC_NWE register */ |
| 175 | writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe); |
| 176 | /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */ |
| 177 | writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe); |
| 178 | /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */ |
| 179 | writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00, |
| 180 | &ctrl_base->gpmc_nadv_ale); |
Sanjeev Premi | 6921b31 | 2011-07-18 09:20:15 -0400 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | /** |
| 184 | * Reset the ethernet chip. |
| 185 | */ |
| 186 | static void reset_net_chip(void) |
| 187 | { |
Sriramakrishnan | c068258 | 2011-07-18 09:21:55 -0400 | [diff] [blame^] | 188 | int ret; |
| 189 | int rst_gpio; |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 190 | |
Sriramakrishnan | c068258 | 2011-07-18 09:21:55 -0400 | [diff] [blame^] | 191 | if (get_omap3_evm_rev() == OMAP3EVM_BOARD_GEN_1) { |
| 192 | rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN1; |
| 193 | } else { |
| 194 | rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN2; |
| 195 | } |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 196 | |
Sriramakrishnan | c068258 | 2011-07-18 09:21:55 -0400 | [diff] [blame^] | 197 | ret = omap_request_gpio(rst_gpio); |
| 198 | if (ret < 0) { |
| 199 | printf("Unable to get GPIO %d\n", rst_gpio); |
| 200 | return ; |
| 201 | } |
| 202 | |
| 203 | /* Configure as output */ |
| 204 | omap_set_gpio_direction(rst_gpio, 0); |
| 205 | |
| 206 | /* Send a pulse on the GPIO pin */ |
| 207 | omap_set_gpio_dataout(rst_gpio, 1); |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 208 | udelay(1); |
Sriramakrishnan | c068258 | 2011-07-18 09:21:55 -0400 | [diff] [blame^] | 209 | omap_set_gpio_dataout(rst_gpio, 0); |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 210 | udelay(1); |
Sriramakrishnan | c068258 | 2011-07-18 09:21:55 -0400 | [diff] [blame^] | 211 | omap_set_gpio_dataout(rst_gpio, 1); |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 212 | } |
Ben Warren | 736fead | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 213 | |
| 214 | int board_eth_init(bd_t *bis) |
| 215 | { |
| 216 | int rc = 0; |
| 217 | #ifdef CONFIG_SMC911X |
| 218 | rc = smc911x_initialize(0, CONFIG_SMC911X_BASE); |
| 219 | #endif |
| 220 | return rc; |
| 221 | } |