Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 1 | /* |
Tom Rini | 673283f | 2011-11-18 12:48:09 +0000 | [diff] [blame] | 2 | * (C) Copyright 2004-2011 |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 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> |
Vaibhav Hiremath | dcc4f38 | 2011-09-03 21:42:35 -0400 | [diff] [blame] | 36 | #include <asm/arch/mmc_host_def.h> |
Sanjeev Premi | 84c3b63 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 37 | #include <asm/gpio.h> |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 38 | #include <i2c.h> |
| 39 | #include <asm/mach-types.h> |
Tom Rini | 673283f | 2011-11-18 12:48:09 +0000 | [diff] [blame] | 40 | #include <linux/mtd/nand.h> |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 41 | #include "evm.h" |
| 42 | |
Sriramakrishnan | c068258 | 2011-07-18 09:21:55 -0400 | [diff] [blame] | 43 | #define OMAP3EVM_GPIO_ETH_RST_GEN1 64 |
| 44 | #define OMAP3EVM_GPIO_ETH_RST_GEN2 7 |
| 45 | |
John Rigby | 2956532 | 2010-12-20 18:27:51 -0700 | [diff] [blame] | 46 | DECLARE_GLOBAL_DATA_PTR; |
| 47 | |
Dirk Behme | b606ef4 | 2010-12-18 07:40:28 +0100 | [diff] [blame] | 48 | static u32 omap3_evm_version; |
Ajay Kumar Gupta | b5abf64 | 2010-06-10 11:20:49 +0530 | [diff] [blame] | 49 | |
Dirk Behme | b606ef4 | 2010-12-18 07:40:28 +0100 | [diff] [blame] | 50 | u32 get_omap3_evm_rev(void) |
Ajay Kumar Gupta | b5abf64 | 2010-06-10 11:20:49 +0530 | [diff] [blame] | 51 | { |
| 52 | return omap3_evm_version; |
| 53 | } |
| 54 | |
| 55 | static void omap3_evm_get_revision(void) |
| 56 | { |
Sanjeev Premi | 76ee9a2 | 2010-11-04 16:02:32 -0400 | [diff] [blame] | 57 | #if defined(CONFIG_CMD_NET) |
| 58 | /* |
| 59 | * Board revision can be ascertained only by identifying |
| 60 | * the Ethernet chipset. |
| 61 | */ |
Ajay Kumar Gupta | b5abf64 | 2010-06-10 11:20:49 +0530 | [diff] [blame] | 62 | unsigned int smsc_id; |
| 63 | |
| 64 | /* Ethernet PHY ID is stored at ID_REV register */ |
| 65 | smsc_id = readl(CONFIG_SMC911X_BASE + 0x50) & 0xFFFF0000; |
| 66 | printf("Read back SMSC id 0x%x\n", smsc_id); |
| 67 | |
| 68 | switch (smsc_id) { |
| 69 | /* SMSC9115 chipset */ |
| 70 | case 0x01150000: |
| 71 | omap3_evm_version = OMAP3EVM_BOARD_GEN_1; |
| 72 | break; |
| 73 | /* SMSC 9220 chipset */ |
| 74 | case 0x92200000: |
| 75 | default: |
| 76 | omap3_evm_version = OMAP3EVM_BOARD_GEN_2; |
| 77 | } |
Sanjeev Premi | 76ee9a2 | 2010-11-04 16:02:32 -0400 | [diff] [blame] | 78 | #else |
| 79 | #if defined(CONFIG_STATIC_BOARD_REV) |
| 80 | /* |
| 81 | * Look for static defintion of the board revision |
| 82 | */ |
| 83 | omap3_evm_version = CONFIG_STATIC_BOARD_REV; |
| 84 | #else |
| 85 | /* |
| 86 | * Fallback to the default above. |
| 87 | */ |
| 88 | omap3_evm_version = OMAP3EVM_BOARD_GEN_2; |
| 89 | #endif |
| 90 | #endif /* CONFIG_CMD_NET */ |
Ajay Kumar Gupta | b5abf64 | 2010-06-10 11:20:49 +0530 | [diff] [blame] | 91 | } |
| 92 | |
Sanjeev Premi | 63f4240 | 2010-11-04 16:02:29 -0400 | [diff] [blame] | 93 | #ifdef CONFIG_USB_OMAP3 |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 94 | /* |
Ajay Kumar Gupta | 944a489 | 2010-06-10 11:20:50 +0530 | [diff] [blame] | 95 | * MUSB port on OMAP3EVM Rev >= E requires extvbus programming. |
| 96 | */ |
| 97 | u8 omap3_evm_need_extvbus(void) |
| 98 | { |
| 99 | u8 retval = 0; |
| 100 | |
| 101 | if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2) |
| 102 | retval = 1; |
| 103 | |
| 104 | return retval; |
| 105 | } |
Sanjeev Premi | 63f4240 | 2010-11-04 16:02:29 -0400 | [diff] [blame] | 106 | #endif |
Ajay Kumar Gupta | 944a489 | 2010-06-10 11:20:50 +0530 | [diff] [blame] | 107 | |
| 108 | /* |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 109 | * Routine: board_init |
| 110 | * Description: Early hardware init. |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 111 | */ |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 112 | int board_init(void) |
| 113 | { |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 114 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 115 | /* board id for Linux */ |
| 116 | gd->bd->bi_arch_number = MACH_TYPE_OMAP3EVM; |
| 117 | /* boot param addr */ |
| 118 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 119 | |
| 120 | return 0; |
| 121 | } |
| 122 | |
Tom Rini | 673283f | 2011-11-18 12:48:09 +0000 | [diff] [blame] | 123 | #ifdef CONFIG_SPL_BUILD |
| 124 | /* |
| 125 | * Routine: get_board_mem_timings |
| 126 | * Description: If we use SPL then there is no x-loader nor config header |
| 127 | * so we have to setup the DDR timings ourself on the first bank. This |
| 128 | * provides the timing values back to the function that configures |
| 129 | * the memory. |
| 130 | */ |
| 131 | void get_board_mem_timings(u32 *mcfg, u32 *ctrla, u32 *ctrlb, u32 *rfr_ctrl, |
| 132 | u32 *mr) |
| 133 | { |
| 134 | int pop_mfr, pop_id; |
| 135 | |
| 136 | /* |
| 137 | * We need to identify what PoP memory is on the board so that |
| 138 | * we know what timings to use. To map the ID values please see |
| 139 | * nand_ids.c |
| 140 | */ |
| 141 | identify_nand_chip(&pop_mfr, &pop_id); |
| 142 | |
| 143 | if (pop_mfr == NAND_MFR_HYNIX && pop_id == 0xbc) { |
| 144 | /* 256MB DDR */ |
| 145 | *mcfg = HYNIX_V_MCFG_200(256 << 20); |
| 146 | *ctrla = HYNIX_V_ACTIMA_200; |
| 147 | *ctrlb = HYNIX_V_ACTIMB_200; |
| 148 | } else { |
| 149 | /* 128MB DDR */ |
| 150 | *mcfg = MICRON_V_MCFG_165(128 << 20); |
| 151 | *ctrla = MICRON_V_ACTIMA_165; |
| 152 | *ctrlb = MICRON_V_ACTIMB_165; |
| 153 | } |
| 154 | *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
| 155 | *mr = MICRON_V_MR_165; |
| 156 | } |
| 157 | #endif |
| 158 | |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 159 | /* |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 160 | * Routine: misc_init_r |
| 161 | * Description: Init ethernet (done here so udelay works) |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 162 | */ |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 163 | int misc_init_r(void) |
| 164 | { |
| 165 | |
| 166 | #ifdef CONFIG_DRIVER_OMAP34XX_I2C |
| 167 | i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); |
| 168 | #endif |
| 169 | |
| 170 | #if defined(CONFIG_CMD_NET) |
| 171 | setup_net_chip(); |
| 172 | #endif |
Sanjeev Premi | 76ee9a2 | 2010-11-04 16:02:32 -0400 | [diff] [blame] | 173 | omap3_evm_get_revision(); |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 174 | |
Sanjeev Premi | 6921b31 | 2011-07-18 09:20:15 -0400 | [diff] [blame] | 175 | #if defined(CONFIG_CMD_NET) |
| 176 | reset_net_chip(); |
| 177 | #endif |
Dirk Behme | e6a6a70 | 2009-03-12 19:30:50 +0100 | [diff] [blame] | 178 | dieid_num_r(); |
| 179 | |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 180 | return 0; |
| 181 | } |
| 182 | |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 183 | /* |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 184 | * Routine: set_muxconf_regs |
| 185 | * Description: Setting up the configuration Mux registers specific to the |
| 186 | * hardware. Many pins need to be moved from protect to primary |
| 187 | * mode. |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 188 | */ |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 189 | void set_muxconf_regs(void) |
| 190 | { |
| 191 | MUX_EVM(); |
| 192 | } |
| 193 | |
Sanjeev Premi | 5626f33 | 2011-07-18 09:23:00 -0400 | [diff] [blame] | 194 | #ifdef CONFIG_CMD_NET |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 195 | /* |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 196 | * Routine: setup_net_chip |
| 197 | * Description: Setting up the configuration GPMC registers specific to the |
| 198 | * Ethernet hardware. |
Tom Rix | 5891151 | 2009-04-01 22:02:20 -0500 | [diff] [blame] | 199 | */ |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 200 | static void setup_net_chip(void) |
| 201 | { |
Dirk Behme | 97a099e | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 202 | struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE; |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 203 | |
| 204 | /* Configure GPMC registers */ |
Dirk Behme | 8941135 | 2009-08-08 09:30:22 +0200 | [diff] [blame] | 205 | writel(NET_GPMC_CONFIG1, &gpmc_cfg->cs[5].config1); |
| 206 | writel(NET_GPMC_CONFIG2, &gpmc_cfg->cs[5].config2); |
| 207 | writel(NET_GPMC_CONFIG3, &gpmc_cfg->cs[5].config3); |
| 208 | writel(NET_GPMC_CONFIG4, &gpmc_cfg->cs[5].config4); |
| 209 | writel(NET_GPMC_CONFIG5, &gpmc_cfg->cs[5].config5); |
| 210 | writel(NET_GPMC_CONFIG6, &gpmc_cfg->cs[5].config6); |
| 211 | writel(NET_GPMC_CONFIG7, &gpmc_cfg->cs[5].config7); |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 212 | |
| 213 | /* Enable off mode for NWE in PADCONF_GPMC_NWE register */ |
| 214 | writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe); |
| 215 | /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */ |
| 216 | writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe); |
| 217 | /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */ |
| 218 | writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00, |
| 219 | &ctrl_base->gpmc_nadv_ale); |
Sanjeev Premi | 6921b31 | 2011-07-18 09:20:15 -0400 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | /** |
| 223 | * Reset the ethernet chip. |
| 224 | */ |
| 225 | static void reset_net_chip(void) |
| 226 | { |
Sriramakrishnan | c068258 | 2011-07-18 09:21:55 -0400 | [diff] [blame] | 227 | int ret; |
| 228 | int rst_gpio; |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 229 | |
Sriramakrishnan | c068258 | 2011-07-18 09:21:55 -0400 | [diff] [blame] | 230 | if (get_omap3_evm_rev() == OMAP3EVM_BOARD_GEN_1) { |
| 231 | rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN1; |
| 232 | } else { |
| 233 | rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN2; |
| 234 | } |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 235 | |
Sanjeev Premi | 84c3b63 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 236 | ret = gpio_request(rst_gpio, ""); |
Sriramakrishnan | c068258 | 2011-07-18 09:21:55 -0400 | [diff] [blame] | 237 | if (ret < 0) { |
| 238 | printf("Unable to get GPIO %d\n", rst_gpio); |
| 239 | return ; |
| 240 | } |
| 241 | |
| 242 | /* Configure as output */ |
Sanjeev Premi | 84c3b63 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 243 | gpio_direction_output(rst_gpio, 0); |
Sriramakrishnan | c068258 | 2011-07-18 09:21:55 -0400 | [diff] [blame] | 244 | |
| 245 | /* Send a pulse on the GPIO pin */ |
Sanjeev Premi | 84c3b63 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 246 | gpio_set_value(rst_gpio, 1); |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 247 | udelay(1); |
Sanjeev Premi | 84c3b63 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 248 | gpio_set_value(rst_gpio, 0); |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 249 | udelay(1); |
Sanjeev Premi | 84c3b63 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 250 | gpio_set_value(rst_gpio, 1); |
Dirk Behme | ad9bc8e | 2009-01-28 21:39:58 +0100 | [diff] [blame] | 251 | } |
Ben Warren | 736fead | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 252 | |
| 253 | int board_eth_init(bd_t *bis) |
| 254 | { |
| 255 | int rc = 0; |
| 256 | #ifdef CONFIG_SMC911X |
Sanjeev Premi | 5e463a2 | 2011-09-02 05:57:16 +0000 | [diff] [blame] | 257 | #define STR_ENV_ETHADDR "ethaddr" |
| 258 | |
| 259 | struct eth_device *dev; |
| 260 | uchar eth_addr[6]; |
| 261 | |
Ben Warren | 736fead | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 262 | rc = smc911x_initialize(0, CONFIG_SMC911X_BASE); |
Sanjeev Premi | 5e463a2 | 2011-09-02 05:57:16 +0000 | [diff] [blame] | 263 | |
| 264 | if (!eth_getenv_enetaddr(STR_ENV_ETHADDR, eth_addr)) { |
| 265 | dev = eth_get_dev_by_index(0); |
| 266 | if (dev) { |
| 267 | eth_setenv_enetaddr(STR_ENV_ETHADDR, dev->enetaddr); |
| 268 | } else { |
| 269 | printf("omap3evm: Couldn't get eth device\n"); |
| 270 | rc = -1; |
| 271 | } |
| 272 | } |
Ben Warren | 736fead | 2009-07-20 22:01:11 -0700 | [diff] [blame] | 273 | #endif |
| 274 | return rc; |
| 275 | } |
Sanjeev Premi | 5626f33 | 2011-07-18 09:23:00 -0400 | [diff] [blame] | 276 | #endif /* CONFIG_CMD_NET */ |
Vaibhav Hiremath | dcc4f38 | 2011-09-03 21:42:35 -0400 | [diff] [blame] | 277 | |
Tom Rini | 673283f | 2011-11-18 12:48:09 +0000 | [diff] [blame] | 278 | #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD) |
Vaibhav Hiremath | dcc4f38 | 2011-09-03 21:42:35 -0400 | [diff] [blame] | 279 | int board_mmc_init(bd_t *bis) |
| 280 | { |
| 281 | omap_mmc_init(0); |
| 282 | return 0; |
| 283 | } |
| 284 | #endif |