Dirk Behme | bb732be | 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 | fbfdd3a | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 31 | #include <netdev.h> |
Dirk Behme | bb732be | 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> |
Vaibhav Hiremath | 4fdf2b7 | 2011-09-03 21:42:35 -0400 | [diff] [blame] | 36 | #include <asm/arch/mmc_host_def.h> |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 37 | #include <asm/gpio.h> |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 38 | #include <i2c.h> |
| 39 | #include <asm/mach-types.h> |
| 40 | #include "evm.h" |
| 41 | |
Sriramakrishnan | 0f188c3 | 2011-07-18 09:21:55 -0400 | [diff] [blame] | 42 | #define OMAP3EVM_GPIO_ETH_RST_GEN1 64 |
| 43 | #define OMAP3EVM_GPIO_ETH_RST_GEN2 7 |
| 44 | |
John Rigby | 0d21ed0 | 2010-12-20 18:27:51 -0700 | [diff] [blame] | 45 | DECLARE_GLOBAL_DATA_PTR; |
| 46 | |
Dirk Behme | 85ed709 | 2010-12-18 07:40:28 +0100 | [diff] [blame] | 47 | static u32 omap3_evm_version; |
Ajay Kumar Gupta | 13fc2bd | 2010-06-10 11:20:49 +0530 | [diff] [blame] | 48 | |
Dirk Behme | 85ed709 | 2010-12-18 07:40:28 +0100 | [diff] [blame] | 49 | u32 get_omap3_evm_rev(void) |
Ajay Kumar Gupta | 13fc2bd | 2010-06-10 11:20:49 +0530 | [diff] [blame] | 50 | { |
| 51 | return omap3_evm_version; |
| 52 | } |
| 53 | |
| 54 | static void omap3_evm_get_revision(void) |
| 55 | { |
Sanjeev Premi | 88105fb | 2010-11-04 16:02:32 -0400 | [diff] [blame] | 56 | #if defined(CONFIG_CMD_NET) |
| 57 | /* |
| 58 | * Board revision can be ascertained only by identifying |
| 59 | * the Ethernet chipset. |
| 60 | */ |
Ajay Kumar Gupta | 13fc2bd | 2010-06-10 11:20:49 +0530 | [diff] [blame] | 61 | unsigned int smsc_id; |
| 62 | |
| 63 | /* Ethernet PHY ID is stored at ID_REV register */ |
| 64 | smsc_id = readl(CONFIG_SMC911X_BASE + 0x50) & 0xFFFF0000; |
| 65 | printf("Read back SMSC id 0x%x\n", smsc_id); |
| 66 | |
| 67 | switch (smsc_id) { |
| 68 | /* SMSC9115 chipset */ |
| 69 | case 0x01150000: |
| 70 | omap3_evm_version = OMAP3EVM_BOARD_GEN_1; |
| 71 | break; |
| 72 | /* SMSC 9220 chipset */ |
| 73 | case 0x92200000: |
| 74 | default: |
| 75 | omap3_evm_version = OMAP3EVM_BOARD_GEN_2; |
| 76 | } |
Sanjeev Premi | 88105fb | 2010-11-04 16:02:32 -0400 | [diff] [blame] | 77 | #else |
| 78 | #if defined(CONFIG_STATIC_BOARD_REV) |
| 79 | /* |
| 80 | * Look for static defintion of the board revision |
| 81 | */ |
| 82 | omap3_evm_version = CONFIG_STATIC_BOARD_REV; |
| 83 | #else |
| 84 | /* |
| 85 | * Fallback to the default above. |
| 86 | */ |
| 87 | omap3_evm_version = OMAP3EVM_BOARD_GEN_2; |
| 88 | #endif |
| 89 | #endif /* CONFIG_CMD_NET */ |
Ajay Kumar Gupta | 13fc2bd | 2010-06-10 11:20:49 +0530 | [diff] [blame] | 90 | } |
| 91 | |
Sanjeev Premi | fa299ff | 2010-11-04 16:02:29 -0400 | [diff] [blame] | 92 | #ifdef CONFIG_USB_OMAP3 |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 93 | /* |
Ajay Kumar Gupta | aeeac6b | 2010-06-10 11:20:50 +0530 | [diff] [blame] | 94 | * MUSB port on OMAP3EVM Rev >= E requires extvbus programming. |
| 95 | */ |
| 96 | u8 omap3_evm_need_extvbus(void) |
| 97 | { |
| 98 | u8 retval = 0; |
| 99 | |
| 100 | if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2) |
| 101 | retval = 1; |
| 102 | |
| 103 | return retval; |
| 104 | } |
Sanjeev Premi | fa299ff | 2010-11-04 16:02:29 -0400 | [diff] [blame] | 105 | #endif |
Ajay Kumar Gupta | aeeac6b | 2010-06-10 11:20:50 +0530 | [diff] [blame] | 106 | |
| 107 | /* |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 108 | * Routine: board_init |
| 109 | * Description: Early hardware init. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 110 | */ |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 111 | int board_init(void) |
| 112 | { |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 113 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 114 | /* board id for Linux */ |
| 115 | gd->bd->bi_arch_number = MACH_TYPE_OMAP3EVM; |
| 116 | /* boot param addr */ |
| 117 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 118 | |
| 119 | return 0; |
| 120 | } |
| 121 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 122 | /* |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 123 | * Routine: misc_init_r |
| 124 | * Description: Init ethernet (done here so udelay works) |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 125 | */ |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 126 | int misc_init_r(void) |
| 127 | { |
| 128 | |
| 129 | #ifdef CONFIG_DRIVER_OMAP34XX_I2C |
| 130 | i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); |
| 131 | #endif |
| 132 | |
| 133 | #if defined(CONFIG_CMD_NET) |
| 134 | setup_net_chip(); |
| 135 | #endif |
Sanjeev Premi | 88105fb | 2010-11-04 16:02:32 -0400 | [diff] [blame] | 136 | omap3_evm_get_revision(); |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 137 | |
Sanjeev Premi | 5e09e44 | 2011-07-18 09:20:15 -0400 | [diff] [blame] | 138 | #if defined(CONFIG_CMD_NET) |
| 139 | reset_net_chip(); |
| 140 | #endif |
Dirk Behme | 12dbcf6 | 2009-03-12 19:30:50 +0100 | [diff] [blame] | 141 | dieid_num_r(); |
| 142 | |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 143 | return 0; |
| 144 | } |
| 145 | |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 146 | /* |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 147 | * Routine: set_muxconf_regs |
| 148 | * Description: Setting up the configuration Mux registers specific to the |
| 149 | * hardware. Many pins need to be moved from protect to primary |
| 150 | * mode. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 151 | */ |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 152 | void set_muxconf_regs(void) |
| 153 | { |
| 154 | MUX_EVM(); |
| 155 | } |
| 156 | |
Sanjeev Premi | 654e3ce | 2011-07-18 09:23:00 -0400 | [diff] [blame] | 157 | #ifdef CONFIG_CMD_NET |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 158 | /* |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 159 | * Routine: setup_net_chip |
| 160 | * Description: Setting up the configuration GPMC registers specific to the |
| 161 | * Ethernet hardware. |
Tom Rix | 558bb83 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 162 | */ |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 163 | static void setup_net_chip(void) |
| 164 | { |
Dirk Behme | dc7af20 | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 165 | struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE; |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 166 | |
| 167 | /* Configure GPMC registers */ |
Dirk Behme | a4becd6 | 2009-08-08 09:30:22 +0200 | [diff] [blame] | 168 | writel(NET_GPMC_CONFIG1, &gpmc_cfg->cs[5].config1); |
| 169 | writel(NET_GPMC_CONFIG2, &gpmc_cfg->cs[5].config2); |
| 170 | writel(NET_GPMC_CONFIG3, &gpmc_cfg->cs[5].config3); |
| 171 | writel(NET_GPMC_CONFIG4, &gpmc_cfg->cs[5].config4); |
| 172 | writel(NET_GPMC_CONFIG5, &gpmc_cfg->cs[5].config5); |
| 173 | writel(NET_GPMC_CONFIG6, &gpmc_cfg->cs[5].config6); |
| 174 | writel(NET_GPMC_CONFIG7, &gpmc_cfg->cs[5].config7); |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 175 | |
| 176 | /* Enable off mode for NWE in PADCONF_GPMC_NWE register */ |
| 177 | writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe); |
| 178 | /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */ |
| 179 | writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe); |
| 180 | /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */ |
| 181 | writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00, |
| 182 | &ctrl_base->gpmc_nadv_ale); |
Sanjeev Premi | 5e09e44 | 2011-07-18 09:20:15 -0400 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | /** |
| 186 | * Reset the ethernet chip. |
| 187 | */ |
| 188 | static void reset_net_chip(void) |
| 189 | { |
Sriramakrishnan | 0f188c3 | 2011-07-18 09:21:55 -0400 | [diff] [blame] | 190 | int ret; |
| 191 | int rst_gpio; |
| 192 | |
| 193 | if (get_omap3_evm_rev() == OMAP3EVM_BOARD_GEN_1) { |
| 194 | rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN1; |
| 195 | } else { |
| 196 | rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN2; |
| 197 | } |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 198 | |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 199 | ret = gpio_request(rst_gpio, ""); |
Sriramakrishnan | 0f188c3 | 2011-07-18 09:21:55 -0400 | [diff] [blame] | 200 | if (ret < 0) { |
| 201 | printf("Unable to get GPIO %d\n", rst_gpio); |
| 202 | return ; |
| 203 | } |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 204 | |
Sriramakrishnan | 0f188c3 | 2011-07-18 09:21:55 -0400 | [diff] [blame] | 205 | /* Configure as output */ |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 206 | gpio_direction_output(rst_gpio, 0); |
Sriramakrishnan | 0f188c3 | 2011-07-18 09:21:55 -0400 | [diff] [blame] | 207 | |
| 208 | /* Send a pulse on the GPIO pin */ |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 209 | gpio_set_value(rst_gpio, 1); |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 210 | udelay(1); |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 211 | gpio_set_value(rst_gpio, 0); |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 212 | udelay(1); |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 213 | gpio_set_value(rst_gpio, 1); |
Dirk Behme | bb732be | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 214 | } |
Ben Warren | fbfdd3a | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 215 | |
| 216 | int board_eth_init(bd_t *bis) |
| 217 | { |
| 218 | int rc = 0; |
| 219 | #ifdef CONFIG_SMC911X |
Sanjeev Premi | 9a2c3ac | 2011-09-02 05:57:16 +0000 | [diff] [blame^] | 220 | #define STR_ENV_ETHADDR "ethaddr" |
| 221 | |
| 222 | struct eth_device *dev; |
| 223 | uchar eth_addr[6]; |
| 224 | |
Ben Warren | fbfdd3a | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 225 | rc = smc911x_initialize(0, CONFIG_SMC911X_BASE); |
Sanjeev Premi | 9a2c3ac | 2011-09-02 05:57:16 +0000 | [diff] [blame^] | 226 | |
| 227 | if (!eth_getenv_enetaddr(STR_ENV_ETHADDR, eth_addr)) { |
| 228 | dev = eth_get_dev_by_index(0); |
| 229 | if (dev) { |
| 230 | eth_setenv_enetaddr(STR_ENV_ETHADDR, dev->enetaddr); |
| 231 | } else { |
| 232 | printf("omap3evm: Couldn't get eth device\n"); |
| 233 | rc = -1; |
| 234 | } |
| 235 | } |
Ben Warren | fbfdd3a | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 236 | #endif |
| 237 | return rc; |
| 238 | } |
Sanjeev Premi | 654e3ce | 2011-07-18 09:23:00 -0400 | [diff] [blame] | 239 | #endif /* CONFIG_CMD_NET */ |
Vaibhav Hiremath | 4fdf2b7 | 2011-09-03 21:42:35 -0400 | [diff] [blame] | 240 | |
| 241 | #ifdef CONFIG_GENERIC_MMC |
| 242 | int board_mmc_init(bd_t *bis) |
| 243 | { |
| 244 | omap_mmc_init(0); |
| 245 | return 0; |
| 246 | } |
| 247 | #endif |