blob: 8a3aa0c5bfdad3234d424f0b98e34e58ab3b3791 [file] [log] [blame]
Dirk Behmead9bc8e2009-01-28 21:39:58 +01001/*
Tom Rini673283f2011-11-18 12:48:09 +00002 * (C) Copyright 2004-2011
Dirk Behmead9bc8e2009-01-28 21:39:58 +01003 * 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 Warren736fead2009-07-20 22:01:11 -070031#include <netdev.h>
Dirk Behmead9bc8e2009-01-28 21:39:58 +010032#include <asm/io.h>
33#include <asm/arch/mem.h>
34#include <asm/arch/mux.h>
35#include <asm/arch/sys_proto.h>
Vaibhav Hiremathdcc4f382011-09-03 21:42:35 -040036#include <asm/arch/mmc_host_def.h>
Sanjeev Premi84c3b632011-09-08 10:51:01 -040037#include <asm/gpio.h>
Dirk Behmead9bc8e2009-01-28 21:39:58 +010038#include <i2c.h>
39#include <asm/mach-types.h>
Tom Rini673283f2011-11-18 12:48:09 +000040#include <linux/mtd/nand.h>
Dirk Behmead9bc8e2009-01-28 21:39:58 +010041#include "evm.h"
42
Sriramakrishnanc0682582011-07-18 09:21:55 -040043#define OMAP3EVM_GPIO_ETH_RST_GEN1 64
44#define OMAP3EVM_GPIO_ETH_RST_GEN2 7
45
John Rigby29565322010-12-20 18:27:51 -070046DECLARE_GLOBAL_DATA_PTR;
47
Dirk Behmeb606ef42010-12-18 07:40:28 +010048static u32 omap3_evm_version;
Ajay Kumar Guptab5abf642010-06-10 11:20:49 +053049
Dirk Behmeb606ef42010-12-18 07:40:28 +010050u32 get_omap3_evm_rev(void)
Ajay Kumar Guptab5abf642010-06-10 11:20:49 +053051{
52 return omap3_evm_version;
53}
54
55static void omap3_evm_get_revision(void)
56{
Sanjeev Premi76ee9a22010-11-04 16:02:32 -040057#if defined(CONFIG_CMD_NET)
58 /*
59 * Board revision can be ascertained only by identifying
60 * the Ethernet chipset.
61 */
Ajay Kumar Guptab5abf642010-06-10 11:20:49 +053062 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 Premi76ee9a22010-11-04 16:02:32 -040078#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 Guptab5abf642010-06-10 11:20:49 +053091}
92
Sanjeev Premi63f42402010-11-04 16:02:29 -040093#ifdef CONFIG_USB_OMAP3
Tom Rix58911512009-04-01 22:02:20 -050094/*
Ajay Kumar Gupta944a4892010-06-10 11:20:50 +053095 * MUSB port on OMAP3EVM Rev >= E requires extvbus programming.
96 */
97u8 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 Premi63f42402010-11-04 16:02:29 -0400106#endif
Ajay Kumar Gupta944a4892010-06-10 11:20:50 +0530107
108/*
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100109 * Routine: board_init
110 * Description: Early hardware init.
Tom Rix58911512009-04-01 22:02:20 -0500111 */
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100112int board_init(void)
113{
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100114 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 Rini673283f2011-11-18 12:48:09 +0000123#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 */
Peter Barada8c4445d2012-11-13 07:40:28 +0000131void get_board_mem_timings(struct board_sdrc_timings *timings)
Tom Rini673283f2011-11-18 12:48:09 +0000132{
133 int pop_mfr, pop_id;
134
135 /*
136 * We need to identify what PoP memory is on the board so that
137 * we know what timings to use. To map the ID values please see
138 * nand_ids.c
139 */
140 identify_nand_chip(&pop_mfr, &pop_id);
141
142 if (pop_mfr == NAND_MFR_HYNIX && pop_id == 0xbc) {
143 /* 256MB DDR */
Peter Barada8c4445d2012-11-13 07:40:28 +0000144 timings->mcfg = HYNIX_V_MCFG_200(256 << 20);
145 timings->ctrla = HYNIX_V_ACTIMA_200;
146 timings->ctrlb = HYNIX_V_ACTIMB_200;
Tom Rini673283f2011-11-18 12:48:09 +0000147 } else {
148 /* 128MB DDR */
Peter Barada8c4445d2012-11-13 07:40:28 +0000149 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
150 timings->ctrla = MICRON_V_ACTIMA_165;
151 timings->ctrlb = MICRON_V_ACTIMB_165;
Tom Rini673283f2011-11-18 12:48:09 +0000152 }
Peter Barada8c4445d2012-11-13 07:40:28 +0000153 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
154 timings->mr = MICRON_V_MR_165;
Tom Rini673283f2011-11-18 12:48:09 +0000155}
156#endif
157
Tom Rix58911512009-04-01 22:02:20 -0500158/*
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100159 * Routine: misc_init_r
160 * Description: Init ethernet (done here so udelay works)
Tom Rix58911512009-04-01 22:02:20 -0500161 */
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100162int misc_init_r(void)
163{
164
165#ifdef CONFIG_DRIVER_OMAP34XX_I2C
166 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
167#endif
168
169#if defined(CONFIG_CMD_NET)
170 setup_net_chip();
171#endif
Sanjeev Premi76ee9a22010-11-04 16:02:32 -0400172 omap3_evm_get_revision();
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100173
Sanjeev Premi6921b312011-07-18 09:20:15 -0400174#if defined(CONFIG_CMD_NET)
175 reset_net_chip();
176#endif
Dirk Behmee6a6a702009-03-12 19:30:50 +0100177 dieid_num_r();
178
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100179 return 0;
180}
181
Tom Rix58911512009-04-01 22:02:20 -0500182/*
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100183 * Routine: set_muxconf_regs
184 * Description: Setting up the configuration Mux registers specific to the
185 * hardware. Many pins need to be moved from protect to primary
186 * mode.
Tom Rix58911512009-04-01 22:02:20 -0500187 */
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100188void set_muxconf_regs(void)
189{
190 MUX_EVM();
191}
192
Sanjeev Premi5626f332011-07-18 09:23:00 -0400193#ifdef CONFIG_CMD_NET
Tom Rix58911512009-04-01 22:02:20 -0500194/*
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100195 * Routine: setup_net_chip
196 * Description: Setting up the configuration GPMC registers specific to the
197 * Ethernet hardware.
Tom Rix58911512009-04-01 22:02:20 -0500198 */
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100199static void setup_net_chip(void)
200{
Dirk Behme97a099e2009-08-08 09:30:21 +0200201 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100202
203 /* Configure GPMC registers */
Dirk Behme89411352009-08-08 09:30:22 +0200204 writel(NET_GPMC_CONFIG1, &gpmc_cfg->cs[5].config1);
205 writel(NET_GPMC_CONFIG2, &gpmc_cfg->cs[5].config2);
206 writel(NET_GPMC_CONFIG3, &gpmc_cfg->cs[5].config3);
207 writel(NET_GPMC_CONFIG4, &gpmc_cfg->cs[5].config4);
208 writel(NET_GPMC_CONFIG5, &gpmc_cfg->cs[5].config5);
209 writel(NET_GPMC_CONFIG6, &gpmc_cfg->cs[5].config6);
210 writel(NET_GPMC_CONFIG7, &gpmc_cfg->cs[5].config7);
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100211
212 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
213 writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
214 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
215 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
216 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
217 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
218 &ctrl_base->gpmc_nadv_ale);
Sanjeev Premi6921b312011-07-18 09:20:15 -0400219}
220
221/**
222 * Reset the ethernet chip.
223 */
224static void reset_net_chip(void)
225{
Sriramakrishnanc0682582011-07-18 09:21:55 -0400226 int ret;
227 int rst_gpio;
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100228
Sriramakrishnanc0682582011-07-18 09:21:55 -0400229 if (get_omap3_evm_rev() == OMAP3EVM_BOARD_GEN_1) {
230 rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN1;
231 } else {
232 rst_gpio = OMAP3EVM_GPIO_ETH_RST_GEN2;
233 }
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100234
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400235 ret = gpio_request(rst_gpio, "");
Sriramakrishnanc0682582011-07-18 09:21:55 -0400236 if (ret < 0) {
237 printf("Unable to get GPIO %d\n", rst_gpio);
238 return ;
239 }
240
241 /* Configure as output */
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400242 gpio_direction_output(rst_gpio, 0);
Sriramakrishnanc0682582011-07-18 09:21:55 -0400243
244 /* Send a pulse on the GPIO pin */
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400245 gpio_set_value(rst_gpio, 1);
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100246 udelay(1);
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400247 gpio_set_value(rst_gpio, 0);
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100248 udelay(1);
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400249 gpio_set_value(rst_gpio, 1);
Dirk Behmead9bc8e2009-01-28 21:39:58 +0100250}
Ben Warren736fead2009-07-20 22:01:11 -0700251
252int board_eth_init(bd_t *bis)
253{
254 int rc = 0;
255#ifdef CONFIG_SMC911X
Sanjeev Premi5e463a22011-09-02 05:57:16 +0000256#define STR_ENV_ETHADDR "ethaddr"
257
258 struct eth_device *dev;
259 uchar eth_addr[6];
260
Ben Warren736fead2009-07-20 22:01:11 -0700261 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
Sanjeev Premi5e463a22011-09-02 05:57:16 +0000262
263 if (!eth_getenv_enetaddr(STR_ENV_ETHADDR, eth_addr)) {
264 dev = eth_get_dev_by_index(0);
265 if (dev) {
266 eth_setenv_enetaddr(STR_ENV_ETHADDR, dev->enetaddr);
267 } else {
268 printf("omap3evm: Couldn't get eth device\n");
269 rc = -1;
270 }
271 }
Ben Warren736fead2009-07-20 22:01:11 -0700272#endif
273 return rc;
274}
Sanjeev Premi5626f332011-07-18 09:23:00 -0400275#endif /* CONFIG_CMD_NET */
Vaibhav Hiremathdcc4f382011-09-03 21:42:35 -0400276
Tom Rini673283f2011-11-18 12:48:09 +0000277#if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
Vaibhav Hiremathdcc4f382011-09-03 21:42:35 -0400278int board_mmc_init(bd_t *bis)
279{
Jonathan Solnitbbbc1ae2012-02-24 11:30:18 +0000280 omap_mmc_init(0, 0, 0);
Vaibhav Hiremathdcc4f382011-09-03 21:42:35 -0400281 return 0;
282}
283#endif