blob: 1c7087b7ed8cfa5138446617c96e6825a1fe745a [file] [log] [blame]
Dirk Behme9d0fc812009-01-28 21:39:57 +01001/*
2 * Maintainer : Steve Sakoman <steve@sakoman.com>
3 *
4 * Derived from Beagle Board, 3430 SDP, and OMAP3EVM code by
5 * Richard Woodruff <r-woodruff2@ti.com>
6 * Syed Mohammed Khasim <khasim@ti.com>
7 * Sunil Kumar <sunilsaini05@gmail.com>
8 * Shashi Ranjan <shashiranjanmca05@gmail.com>
9 *
10 * (C) Copyright 2004-2008
11 * Texas Instruments, <www.ti.com>
12 *
13 * See file CREDITS for list of people who contributed to this
14 * project.
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 */
31#include <common.h>
Olof Johanssondf382622009-09-29 10:22:45 -040032#include <netdev.h>
Tom Rix2c155132009-06-28 12:52:30 -050033#include <twl4030.h>
Dirk Behme9d0fc812009-01-28 21:39:57 +010034#include <asm/io.h>
35#include <asm/arch/mux.h>
Olof Johanssondf382622009-09-29 10:22:45 -040036#include <asm/arch/mem.h>
Dirk Behme9d0fc812009-01-28 21:39:57 +010037#include <asm/arch/sys_proto.h>
Olof Johanssondf382622009-09-29 10:22:45 -040038#include <asm/arch/gpio.h>
Dirk Behme9d0fc812009-01-28 21:39:57 +010039#include <asm/mach-types.h>
40#include "overo.h"
41
Olof Johanssondf382622009-09-29 10:22:45 -040042#if defined(CONFIG_CMD_NET)
43static void setup_net_chip(void);
44#endif
45
Tom Rix58911512009-04-01 22:02:20 -050046/*
Dirk Behme9d0fc812009-01-28 21:39:57 +010047 * Routine: board_init
48 * Description: Early hardware init.
Tom Rix58911512009-04-01 22:02:20 -050049 */
Dirk Behme9d0fc812009-01-28 21:39:57 +010050int board_init(void)
51{
52 DECLARE_GLOBAL_DATA_PTR;
53
54 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
55 /* board id for Linux */
56 gd->bd->bi_arch_number = MACH_TYPE_OVERO;
57 /* boot param addr */
58 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
59
60 return 0;
61}
62
Tom Rix58911512009-04-01 22:02:20 -050063/*
Steve Sakomanc2d5b342010-08-12 15:13:02 -070064 * Routine: get_board_revision
65 * Description: Returns the board revision
66 */
67int get_board_revision(void)
68{
69 int revision;
70
71 if (!omap_request_gpio(112) &&
72 !omap_request_gpio(113) &&
73 !omap_request_gpio(115)) {
74
75 omap_set_gpio_direction(112, 1);
76 omap_set_gpio_direction(113, 1);
77 omap_set_gpio_direction(115, 1);
78
79 revision = omap_get_gpio_datain(115) << 2 |
80 omap_get_gpio_datain(113) << 1 |
81 omap_get_gpio_datain(112);
82
83 omap_free_gpio(112);
84 omap_free_gpio(113);
85 omap_free_gpio(115);
86 } else {
87 printf("Error: unable to acquire board revision GPIOs\n");
88 revision = -1;
89 }
90
91 return revision;
92}
93
94/*
Dirk Behme9d0fc812009-01-28 21:39:57 +010095 * Routine: misc_init_r
96 * Description: Configure board specific parts
Tom Rix58911512009-04-01 22:02:20 -050097 */
Dirk Behme9d0fc812009-01-28 21:39:57 +010098int misc_init_r(void)
99{
Tom Rix2c155132009-06-28 12:52:30 -0500100 twl4030_power_init();
Grazvydas Ignotasead39d72009-12-10 17:10:21 +0200101 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
Dirk Behme9d0fc812009-01-28 21:39:57 +0100102
Olof Johanssondf382622009-09-29 10:22:45 -0400103#if defined(CONFIG_CMD_NET)
104 setup_net_chip();
105#endif
106
Steve Sakomanc2d5b342010-08-12 15:13:02 -0700107 printf("Board revision: %d\n", get_board_revision());
Dirk Behmee6a6a702009-03-12 19:30:50 +0100108 dieid_num_r();
109
Dirk Behme9d0fc812009-01-28 21:39:57 +0100110 return 0;
111}
112
Tom Rix58911512009-04-01 22:02:20 -0500113/*
Dirk Behme9d0fc812009-01-28 21:39:57 +0100114 * Routine: set_muxconf_regs
115 * Description: Setting up the configuration Mux registers specific to the
116 * hardware. Many pins need to be moved from protect to primary
117 * mode.
Tom Rix58911512009-04-01 22:02:20 -0500118 */
Dirk Behme9d0fc812009-01-28 21:39:57 +0100119void set_muxconf_regs(void)
120{
121 MUX_OVERO();
122}
Olof Johanssondf382622009-09-29 10:22:45 -0400123
124#if defined(CONFIG_CMD_NET)
125/*
126 * Routine: setup_net_chip
127 * Description: Setting up the configuration GPMC registers specific to the
128 * Ethernet hardware.
129 */
130static void setup_net_chip(void)
131{
132 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
133
134 /* Configure GPMC registers */
Scott Ellis093d6012010-01-27 11:11:46 -0500135 writel(NET_LAN9221_GPMC_CONFIG1, &gpmc_cfg->cs[5].config1);
136 writel(NET_LAN9221_GPMC_CONFIG2, &gpmc_cfg->cs[5].config2);
137 writel(NET_LAN9221_GPMC_CONFIG3, &gpmc_cfg->cs[5].config3);
138 writel(NET_LAN9221_GPMC_CONFIG4, &gpmc_cfg->cs[5].config4);
139 writel(NET_LAN9221_GPMC_CONFIG5, &gpmc_cfg->cs[5].config5);
140 writel(NET_LAN9221_GPMC_CONFIG6, &gpmc_cfg->cs[5].config6);
141 writel(NET_LAN9221_GPMC_CONFIG7, &gpmc_cfg->cs[5].config7);
Olof Johanssondf382622009-09-29 10:22:45 -0400142
143 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
144 writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
145 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
146 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
147 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
148 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
149 &ctrl_base->gpmc_nadv_ale);
150
151 /* Make GPIO 64 as output pin and send a magic pulse through it */
152 if (!omap_request_gpio(64)) {
153 omap_set_gpio_direction(64, 0);
154 omap_set_gpio_dataout(64, 1);
155 udelay(1);
156 omap_set_gpio_dataout(64, 0);
157 udelay(1);
158 omap_set_gpio_dataout(64, 1);
159 }
160}
161#endif
162
163int board_eth_init(bd_t *bis)
164{
165 int rc = 0;
166#ifdef CONFIG_SMC911X
167 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
168#endif
169 return rc;
170}