blob: 9c926938ba2ec661565dbf1769adaba386806e02 [file] [log] [blame]
Dirk Behme220faba2009-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 Johansson4963f922009-09-29 10:22:45 -040032#include <netdev.h>
Tom Rix0f2a8042009-06-28 12:52:30 -050033#include <twl4030.h>
Dirk Behme220faba2009-01-28 21:39:57 +010034#include <asm/io.h>
Steve Sakomanb7d80522010-09-19 21:21:07 -070035#include <asm/arch/mmc_host_def.h>
Dirk Behme220faba2009-01-28 21:39:57 +010036#include <asm/arch/mux.h>
Olof Johansson4963f922009-09-29 10:22:45 -040037#include <asm/arch/mem.h>
Dirk Behme220faba2009-01-28 21:39:57 +010038#include <asm/arch/sys_proto.h>
Olof Johansson4963f922009-09-29 10:22:45 -040039#include <asm/arch/gpio.h>
Dirk Behme220faba2009-01-28 21:39:57 +010040#include <asm/mach-types.h>
41#include "overo.h"
42
Olof Johansson4963f922009-09-29 10:22:45 -040043#if defined(CONFIG_CMD_NET)
44static void setup_net_chip(void);
45#endif
46
Steve Sakoman0d1d0082010-08-12 21:07:02 -070047/* GPMC definitions for LAN9221 chips on Tobi expansion boards */
48static const u32 gpmc_lan_config[] = {
49 NET_LAN9221_GPMC_CONFIG1,
50 NET_LAN9221_GPMC_CONFIG2,
51 NET_LAN9221_GPMC_CONFIG3,
52 NET_LAN9221_GPMC_CONFIG4,
53 NET_LAN9221_GPMC_CONFIG5,
54 NET_LAN9221_GPMC_CONFIG6,
55 /*CONFIG7- computed as params */
56};
57
Tom Rix558bb832009-04-01 22:02:20 -050058/*
Dirk Behme220faba2009-01-28 21:39:57 +010059 * Routine: board_init
60 * Description: Early hardware init.
Tom Rix558bb832009-04-01 22:02:20 -050061 */
Dirk Behme220faba2009-01-28 21:39:57 +010062int board_init(void)
63{
64 DECLARE_GLOBAL_DATA_PTR;
65
66 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
67 /* board id for Linux */
68 gd->bd->bi_arch_number = MACH_TYPE_OVERO;
69 /* boot param addr */
70 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
71
72 return 0;
73}
74
Tom Rix558bb832009-04-01 22:02:20 -050075/*
Steve Sakoman5ddc70b2010-08-12 15:13:02 -070076 * Routine: get_board_revision
77 * Description: Returns the board revision
78 */
79int get_board_revision(void)
80{
81 int revision;
82
83 if (!omap_request_gpio(112) &&
84 !omap_request_gpio(113) &&
85 !omap_request_gpio(115)) {
86
87 omap_set_gpio_direction(112, 1);
88 omap_set_gpio_direction(113, 1);
89 omap_set_gpio_direction(115, 1);
90
91 revision = omap_get_gpio_datain(115) << 2 |
92 omap_get_gpio_datain(113) << 1 |
93 omap_get_gpio_datain(112);
94
95 omap_free_gpio(112);
96 omap_free_gpio(113);
97 omap_free_gpio(115);
98 } else {
99 printf("Error: unable to acquire board revision GPIOs\n");
100 revision = -1;
101 }
102
103 return revision;
104}
105
106/*
Steve Sakoman541ce992010-08-24 10:37:29 -0700107 * Routine: get_sdio2_config
108 * Description: Return information about the wifi module connection
109 * Returns 0 if the module connects though a level translator
110 * Returns 1 if the module connects directly
111 */
112int get_sdio2_config(void)
113{
114 int sdio_direct;
115
116 if (!omap_request_gpio(130) && !omap_request_gpio(139)) {
117
118 omap_set_gpio_direction(130, 0);
119 omap_set_gpio_direction(139, 1);
120
121 sdio_direct = 1;
122 omap_set_gpio_dataout(130, 0);
123 if (omap_get_gpio_datain(139) == 0) {
124 omap_set_gpio_dataout(130, 1);
125 if (omap_get_gpio_datain(139) == 1)
126 sdio_direct = 0;
127 }
128
129 omap_free_gpio(130);
130 omap_free_gpio(139);
131 } else {
132 printf("Error: unable to acquire sdio2 clk GPIOs\n");
133 sdio_direct = -1;
134 }
135
136 return sdio_direct;
137}
138
139/*
Dirk Behme220faba2009-01-28 21:39:57 +0100140 * Routine: misc_init_r
141 * Description: Configure board specific parts
Tom Rix558bb832009-04-01 22:02:20 -0500142 */
Dirk Behme220faba2009-01-28 21:39:57 +0100143int misc_init_r(void)
144{
Tom Rix0f2a8042009-06-28 12:52:30 -0500145 twl4030_power_init();
Grazvydas Ignotas17887bf2009-12-10 17:10:21 +0200146 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
Dirk Behme220faba2009-01-28 21:39:57 +0100147
Olof Johansson4963f922009-09-29 10:22:45 -0400148#if defined(CONFIG_CMD_NET)
149 setup_net_chip();
150#endif
151
Steve Sakoman5ddc70b2010-08-12 15:13:02 -0700152 printf("Board revision: %d\n", get_board_revision());
Steve Sakoman541ce992010-08-24 10:37:29 -0700153
154 switch (get_sdio2_config()) {
155 case 0:
156 printf("Tranceiver detected on mmc2\n");
157 MUX_OVERO_SDIO2_TRANSCEIVER();
158 break;
159 case 1:
160 printf("Direct connection on mmc2\n");
161 MUX_OVERO_SDIO2_DIRECT();
162 break;
163 default:
164 printf("Unable to detect mmc2 connection type\n");
165 }
166
Dirk Behme12dbcf62009-03-12 19:30:50 +0100167 dieid_num_r();
168
Dirk Behme220faba2009-01-28 21:39:57 +0100169 return 0;
170}
171
Tom Rix558bb832009-04-01 22:02:20 -0500172/*
Dirk Behme220faba2009-01-28 21:39:57 +0100173 * Routine: set_muxconf_regs
174 * Description: Setting up the configuration Mux registers specific to the
175 * hardware. Many pins need to be moved from protect to primary
176 * mode.
Tom Rix558bb832009-04-01 22:02:20 -0500177 */
Dirk Behme220faba2009-01-28 21:39:57 +0100178void set_muxconf_regs(void)
179{
180 MUX_OVERO();
181}
Olof Johansson4963f922009-09-29 10:22:45 -0400182
183#if defined(CONFIG_CMD_NET)
184/*
185 * Routine: setup_net_chip
186 * Description: Setting up the configuration GPMC registers specific to the
187 * Ethernet hardware.
188 */
189static void setup_net_chip(void)
190{
191 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
192
Steve Sakoman0d1d0082010-08-12 21:07:02 -0700193 /* first lan chip */
194 enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000,
195 GPMC_SIZE_16M);
196
197 /* second lan chip */
198 enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[4], 0x2B000000,
199 GPMC_SIZE_16M);
Olof Johansson4963f922009-09-29 10:22:45 -0400200
201 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
202 writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
203 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
204 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
205 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
206 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
207 &ctrl_base->gpmc_nadv_ale);
208
209 /* Make GPIO 64 as output pin and send a magic pulse through it */
210 if (!omap_request_gpio(64)) {
211 omap_set_gpio_direction(64, 0);
212 omap_set_gpio_dataout(64, 1);
213 udelay(1);
214 omap_set_gpio_dataout(64, 0);
215 udelay(1);
216 omap_set_gpio_dataout(64, 1);
217 }
218}
219#endif
220
221int board_eth_init(bd_t *bis)
222{
223 int rc = 0;
224#ifdef CONFIG_SMC911X
225 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
226#endif
227 return rc;
228}
Steve Sakomanb7d80522010-09-19 21:21:07 -0700229
230#ifdef CONFIG_GENERIC_MMC
231int board_mmc_init(bd_t *bis)
232{
233 omap_mmc_init(0);
234 return 0;
235}
236#endif