blob: 73330db156a8db886d6a4aee06a4f1a05948af00 [file] [log] [blame]
Dirk Behmebb732be2009-01-28 21:39:58 +01001/*
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 Warrenfbfdd3a2009-07-20 22:01:11 -070031#include <netdev.h>
Dirk Behmebb732be2009-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>
36#include <i2c.h>
37#include <asm/mach-types.h>
38#include "evm.h"
39
Ajay Kumar Gupta13fc2bd2010-06-10 11:20:49 +053040static u8 omap3_evm_version;
41
42u8 get_omap3_evm_rev(void)
43{
44 return omap3_evm_version;
45}
46
47static void omap3_evm_get_revision(void)
48{
49 unsigned int smsc_id;
50
51 /* Ethernet PHY ID is stored at ID_REV register */
52 smsc_id = readl(CONFIG_SMC911X_BASE + 0x50) & 0xFFFF0000;
53 printf("Read back SMSC id 0x%x\n", smsc_id);
54
55 switch (smsc_id) {
56 /* SMSC9115 chipset */
57 case 0x01150000:
58 omap3_evm_version = OMAP3EVM_BOARD_GEN_1;
59 break;
60 /* SMSC 9220 chipset */
61 case 0x92200000:
62 default:
63 omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
64 }
65}
66
Sanjeev Premifa299ff2010-11-04 16:02:29 -040067#ifdef CONFIG_USB_OMAP3
Tom Rix558bb832009-04-01 22:02:20 -050068/*
Ajay Kumar Guptaaeeac6b2010-06-10 11:20:50 +053069 * MUSB port on OMAP3EVM Rev >= E requires extvbus programming.
70 */
71u8 omap3_evm_need_extvbus(void)
72{
73 u8 retval = 0;
74
75 if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2)
76 retval = 1;
77
78 return retval;
79}
Sanjeev Premifa299ff2010-11-04 16:02:29 -040080#endif
Ajay Kumar Guptaaeeac6b2010-06-10 11:20:50 +053081
82/*
Dirk Behmebb732be2009-01-28 21:39:58 +010083 * Routine: board_init
84 * Description: Early hardware init.
Tom Rix558bb832009-04-01 22:02:20 -050085 */
Dirk Behmebb732be2009-01-28 21:39:58 +010086int board_init(void)
87{
88 DECLARE_GLOBAL_DATA_PTR;
89
90 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
91 /* board id for Linux */
92 gd->bd->bi_arch_number = MACH_TYPE_OMAP3EVM;
93 /* boot param addr */
94 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
95
96 return 0;
97}
98
Tom Rix558bb832009-04-01 22:02:20 -050099/*
Dirk Behmebb732be2009-01-28 21:39:58 +0100100 * Routine: misc_init_r
101 * Description: Init ethernet (done here so udelay works)
Tom Rix558bb832009-04-01 22:02:20 -0500102 */
Dirk Behmebb732be2009-01-28 21:39:58 +0100103int misc_init_r(void)
104{
105
106#ifdef CONFIG_DRIVER_OMAP34XX_I2C
107 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
108#endif
109
110#if defined(CONFIG_CMD_NET)
111 setup_net_chip();
112#endif
113
Dirk Behme12dbcf62009-03-12 19:30:50 +0100114 dieid_num_r();
115
Dirk Behmebb732be2009-01-28 21:39:58 +0100116 return 0;
117}
118
Tom Rix558bb832009-04-01 22:02:20 -0500119/*
Dirk Behmebb732be2009-01-28 21:39:58 +0100120 * Routine: set_muxconf_regs
121 * Description: Setting up the configuration Mux registers specific to the
122 * hardware. Many pins need to be moved from protect to primary
123 * mode.
Tom Rix558bb832009-04-01 22:02:20 -0500124 */
Dirk Behmebb732be2009-01-28 21:39:58 +0100125void set_muxconf_regs(void)
126{
127 MUX_EVM();
128}
129
Tom Rix558bb832009-04-01 22:02:20 -0500130/*
Dirk Behmebb732be2009-01-28 21:39:58 +0100131 * Routine: setup_net_chip
132 * Description: Setting up the configuration GPMC registers specific to the
133 * Ethernet hardware.
Tom Rix558bb832009-04-01 22:02:20 -0500134 */
Dirk Behmebb732be2009-01-28 21:39:58 +0100135static void setup_net_chip(void)
136{
Dirk Behmedc7af202009-08-08 09:30:21 +0200137 struct gpio *gpio3_base = (struct gpio *)OMAP34XX_GPIO3_BASE;
Dirk Behmedc7af202009-08-08 09:30:21 +0200138 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
Dirk Behmebb732be2009-01-28 21:39:58 +0100139
140 /* Configure GPMC registers */
Dirk Behmea4becd62009-08-08 09:30:22 +0200141 writel(NET_GPMC_CONFIG1, &gpmc_cfg->cs[5].config1);
142 writel(NET_GPMC_CONFIG2, &gpmc_cfg->cs[5].config2);
143 writel(NET_GPMC_CONFIG3, &gpmc_cfg->cs[5].config3);
144 writel(NET_GPMC_CONFIG4, &gpmc_cfg->cs[5].config4);
145 writel(NET_GPMC_CONFIG5, &gpmc_cfg->cs[5].config5);
146 writel(NET_GPMC_CONFIG6, &gpmc_cfg->cs[5].config6);
147 writel(NET_GPMC_CONFIG7, &gpmc_cfg->cs[5].config7);
Dirk Behmebb732be2009-01-28 21:39:58 +0100148
149 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
150 writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
151 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
152 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
153 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
154 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
155 &ctrl_base->gpmc_nadv_ale);
156
157 /* Make GPIO 64 as output pin */
158 writel(readl(&gpio3_base->oe) & ~(GPIO0), &gpio3_base->oe);
159
160 /* Now send a pulse on the GPIO pin */
161 writel(GPIO0, &gpio3_base->setdataout);
162 udelay(1);
163 writel(GPIO0, &gpio3_base->cleardataout);
164 udelay(1);
165 writel(GPIO0, &gpio3_base->setdataout);
Ajay Kumar Gupta13fc2bd2010-06-10 11:20:49 +0530166
167 /* determine omap3evm revision */
168 omap3_evm_get_revision();
Dirk Behmebb732be2009-01-28 21:39:58 +0100169}
Ben Warrenfbfdd3a2009-07-20 22:01:11 -0700170
171int board_eth_init(bd_t *bis)
172{
173 int rc = 0;
174#ifdef CONFIG_SMC911X
175 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
176#endif
177 return rc;
178}