blob: 2fdee7c08bff6c05ca0591aa86ca416a72b34264 [file] [log] [blame]
Dirk Behmef904cdb2009-01-27 18:19:12 +01001/*
2 * (C) Copyright 2004-2008
3 * Texas Instruments, <www.ti.com>
4 *
5 * Author :
6 * Sunil Kumar <sunilsaini05@gmail.com>
7 * Shashi Ranjan <shashiranjanmca05@gmail.com>
8 *
9 * Derived from Beagle Board and 3430 SDP code by
10 * Richard Woodruff <r-woodruff2@ti.com>
11 * Syed Mohammed Khasim <khasim@ti.com>
12 *
13 *
14 * See file CREDITS for list of people who contributed to this
15 * project.
16 *
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 * MA 02111-1307 USA
31 */
32#include <common.h>
Jason Kridner70d8c942011-04-18 17:23:35 -040033#ifdef CONFIG_STATUS_LED
34#include <status_led.h>
35#endif
Tom Rix2c155132009-06-28 12:52:30 -050036#include <twl4030.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010037#include <asm/io.h>
Steve Sakoman0cd31142010-09-19 21:19:48 -070038#include <asm/arch/mmc_host_def.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010039#include <asm/arch/mux.h>
40#include <asm/arch/sys_proto.h>
Tom Rix718763c2009-06-03 01:53:57 -050041#include <asm/arch/gpio.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010042#include <asm/mach-types.h>
43#include "beagle.h"
44
Koen Kooica5f80a2010-09-20 10:21:33 -070045#define TWL4030_I2C_BUS 0
46#define EXPANSION_EEPROM_I2C_BUS 1
47#define EXPANSION_EEPROM_I2C_ADDRESS 0x50
48
49#define TINCANTOOLS_ZIPPY 0x01000100
50#define TINCANTOOLS_ZIPPY2 0x02000100
51#define TINCANTOOLS_TRAINER 0x04000100
52#define TINCANTOOLS_SHOWDOG 0x03000100
53#define KBADC_BEAGLEFPGA 0x01000600
54
55#define BEAGLE_NO_EEPROM 0xffffffff
56
John Rigby29565322010-12-20 18:27:51 -070057DECLARE_GLOBAL_DATA_PTR;
58
Koen Kooica5f80a2010-09-20 10:21:33 -070059static struct {
60 unsigned int device_vendor;
61 unsigned char revision;
62 unsigned char content;
63 char fab_revision[8];
64 char env_var[16];
65 char env_setting[64];
66} expansion_config;
67
Tom Rix58911512009-04-01 22:02:20 -050068/*
Dirk Behmef904cdb2009-01-27 18:19:12 +010069 * Routine: board_init
70 * Description: Early hardware init.
Tom Rix58911512009-04-01 22:02:20 -050071 */
Dirk Behmef904cdb2009-01-27 18:19:12 +010072int board_init(void)
73{
Dirk Behmef904cdb2009-01-27 18:19:12 +010074 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
75 /* board id for Linux */
76 gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
77 /* boot param addr */
78 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
79
Jason Kridner70d8c942011-04-18 17:23:35 -040080#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
81 status_led_set (STATUS_LED_BOOT, STATUS_LED_ON);
82#endif
83
Dirk Behmef904cdb2009-01-27 18:19:12 +010084 return 0;
85}
86
Tom Rix58911512009-04-01 22:02:20 -050087/*
Steve Sakoman06b95bd2010-08-12 15:17:37 -070088 * Routine: get_board_revision
89 * Description: Detect if we are running on a Beagle revision Ax/Bx,
Steve Sakoman08cbba2ab2010-08-19 20:56:11 -070090 * C1/2/3, C4 or xM. This can be done by reading
Steve Sakoman06b95bd2010-08-12 15:17:37 -070091 * the level of GPIO173, GPIO172 and GPIO171. This should
92 * result in
93 * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
94 * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
95 * GPIO173, GPIO172, GPIO171: 1 0 1 => C4
Steve Sakoman08cbba2ab2010-08-19 20:56:11 -070096 * GPIO173, GPIO172, GPIO171: 0 0 0 => xM
Tom Rix58911512009-04-01 22:02:20 -050097 */
Steve Sakoman06b95bd2010-08-12 15:17:37 -070098int get_board_revision(void)
Dirk Behmef956fd02009-02-12 18:55:41 +010099{
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700100 int revision;
Dirk Behmef956fd02009-02-12 18:55:41 +0100101
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700102 if (!omap_request_gpio(171) &&
103 !omap_request_gpio(172) &&
104 !omap_request_gpio(173)) {
Dirk Behmef956fd02009-02-12 18:55:41 +0100105
Tom Rix718763c2009-06-03 01:53:57 -0500106 omap_set_gpio_direction(171, 1);
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700107 omap_set_gpio_direction(172, 1);
108 omap_set_gpio_direction(173, 1);
Dirk Behmef956fd02009-02-12 18:55:41 +0100109
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700110 revision = omap_get_gpio_datain(173) << 2 |
111 omap_get_gpio_datain(172) << 1 |
112 omap_get_gpio_datain(171);
113
114 omap_free_gpio(171);
115 omap_free_gpio(172);
116 omap_free_gpio(173);
117 } else {
118 printf("Error: unable to acquire board revision GPIOs\n");
119 revision = -1;
Tom Rix718763c2009-06-03 01:53:57 -0500120 }
Dirk Behmef956fd02009-02-12 18:55:41 +0100121
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700122 return revision;
Dirk Behmef956fd02009-02-12 18:55:41 +0100123}
124
Tom Rix58911512009-04-01 22:02:20 -0500125/*
Koen Kooica5f80a2010-09-20 10:21:33 -0700126 * Routine: get_expansion_id
127 * Description: This function checks for expansion board by checking I2C
128 * bus 1 for the availability of an AT24C01B serial EEPROM.
129 * returns the device_vendor field from the EEPROM
130 */
131unsigned int get_expansion_id(void)
132{
133 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
134
135 /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
136 if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
137 i2c_set_bus_num(TWL4030_I2C_BUS);
138 return BEAGLE_NO_EEPROM;
139 }
140
141 /* read configuration data */
142 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
143 sizeof(expansion_config));
144
145 i2c_set_bus_num(TWL4030_I2C_BUS);
146
147 return expansion_config.device_vendor;
148}
149
150/*
Dirk Behmef904cdb2009-01-27 18:19:12 +0100151 * Routine: misc_init_r
152 * Description: Configure board specific parts
Tom Rix58911512009-04-01 22:02:20 -0500153 */
Dirk Behmef904cdb2009-01-27 18:19:12 +0100154int misc_init_r(void)
155{
Dirk Behme97a099e2009-08-08 09:30:21 +0200156 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
157 struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
Steve Kipiszd4e53f02011-04-18 17:27:00 -0400158 struct control_prog_io *prog_io_base = (struct gpio *)OMAP34XX_CTRL_BASE;
159
160 /* Enable i2c2 pullup resisters */
161 writel(~(PRG_I2C2_PULLUPRESX), &prog_io_base->io1);
Dirk Behmef904cdb2009-01-27 18:19:12 +0100162
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700163 switch (get_board_revision()) {
164 case REVISION_AXBX:
165 printf("Beagle Rev Ax/Bx\n");
166 setenv("beaglerev", "AxBx");
167 setenv("mpurate", "600");
168 break;
169 case REVISION_CX:
170 printf("Beagle Rev C1/C2/C3\n");
171 setenv("beaglerev", "Cx");
172 setenv("mpurate", "600");
173 MUX_BEAGLE_C();
174 break;
175 case REVISION_C4:
176 printf("Beagle Rev C4\n");
Steve Sakoman08cbba2ab2010-08-19 20:56:11 -0700177 setenv("beaglerev", "C4");
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700178 setenv("mpurate", "720");
179 MUX_BEAGLE_C();
180 /* Set VAUX2 to 1.8V for EHCI PHY */
181 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
182 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
183 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
184 TWL4030_PM_RECEIVER_DEV_GRP_P1);
185 break;
Steve Sakoman08cbba2ab2010-08-19 20:56:11 -0700186 case REVISION_XM:
187 printf("Beagle xM Rev A\n");
188 setenv("beaglerev", "xMA");
189 setenv("mpurate", "1000");
190 MUX_BEAGLE_XM();
191 /* Set VAUX2 to 1.8V for EHCI PHY */
192 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
193 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
194 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
195 TWL4030_PM_RECEIVER_DEV_GRP_P1);
196 break;
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700197 default:
198 printf("Beagle unknown 0x%02x\n", get_board_revision());
199 }
200
Koen Kooica5f80a2010-09-20 10:21:33 -0700201 switch (get_expansion_id()) {
202 case TINCANTOOLS_ZIPPY:
203 printf("Recognized Tincantools Zippy board (rev %d %s)\n",
204 expansion_config.revision,
205 expansion_config.fab_revision);
206 MUX_TINCANTOOLS_ZIPPY();
207 setenv("buddy", "zippy");
208 break;
209 case TINCANTOOLS_ZIPPY2:
210 printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
211 expansion_config.revision,
212 expansion_config.fab_revision);
213 MUX_TINCANTOOLS_ZIPPY();
214 setenv("buddy", "zippy2");
215 break;
216 case TINCANTOOLS_TRAINER:
217 printf("Recognized Tincantools Trainer board (rev %d %s)\n",
218 expansion_config.revision,
219 expansion_config.fab_revision);
220 MUX_TINCANTOOLS_ZIPPY();
221 MUX_TINCANTOOLS_TRAINER();
222 setenv("buddy", "trainer");
223 break;
224 case TINCANTOOLS_SHOWDOG:
225 printf("Recognized Tincantools Showdow board (rev %d %s)\n",
226 expansion_config.revision,
227 expansion_config.fab_revision);
228 /* Place holder for DSS2 definition for showdog lcd */
229 setenv("defaultdisplay", "showdoglcd");
230 setenv("buddy", "showdog");
231 break;
232 case KBADC_BEAGLEFPGA:
233 printf("Recognized KBADC Beagle FPGA board\n");
234 MUX_KBADC_BEAGLEFPGA();
235 setenv("buddy", "beaglefpga");
236 break;
237 case BEAGLE_NO_EEPROM:
238 printf("No EEPROM on expansion board\n");
239 setenv("buddy", "none");
240 break;
241 default:
242 printf("Unrecognized expansion board: %x\n",
243 expansion_config.device_vendor);
244 setenv("buddy", "unknown");
245 }
246
247 if (expansion_config.content == 1)
248 setenv(expansion_config.env_var, expansion_config.env_setting);
249
Tom Rix2c155132009-06-28 12:52:30 -0500250 twl4030_power_init();
Grazvydas Ignotasead39d72009-12-10 17:10:21 +0200251 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
Dirk Behmef904cdb2009-01-27 18:19:12 +0100252
253 /* Configure GPIOs to output */
254 writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
255 writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
256 GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
257
258 /* Set GPIOs */
259 writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
260 &gpio6_base->setdataout);
261 writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
262 GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
263
Dirk Behmee6a6a702009-03-12 19:30:50 +0100264 dieid_num_r();
265
Dirk Behmef904cdb2009-01-27 18:19:12 +0100266 return 0;
267}
268
Tom Rix58911512009-04-01 22:02:20 -0500269/*
Dirk Behmef904cdb2009-01-27 18:19:12 +0100270 * Routine: set_muxconf_regs
271 * Description: Setting up the configuration Mux registers specific to the
272 * hardware. Many pins need to be moved from protect to primary
273 * mode.
Tom Rix58911512009-04-01 22:02:20 -0500274 */
Dirk Behmef904cdb2009-01-27 18:19:12 +0100275void set_muxconf_regs(void)
276{
277 MUX_BEAGLE();
Dirk Behmef904cdb2009-01-27 18:19:12 +0100278}
Steve Sakoman0cd31142010-09-19 21:19:48 -0700279
280#ifdef CONFIG_GENERIC_MMC
281int board_mmc_init(bd_t *bis)
282{
283 omap_mmc_init(0);
284 return 0;
285}
286#endif