blob: 2cca6da0216dee2d647c2aa7fc146a3a66609b5a [file] [log] [blame]
Dirk Behmef904cdb2009-01-27 18:19:12 +01001/*
Tom Rini75c57a32011-11-18 12:48:08 +00002 * (C) Copyright 2004-2011
Dirk Behmef904cdb2009-01-27 18:19:12 +01003 * 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>
Tom Rini75c57a32011-11-18 12:48:08 +000037#include <linux/mtd/nand.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010038#include <asm/io.h>
Steve Sakoman0cd31142010-09-19 21:19:48 -070039#include <asm/arch/mmc_host_def.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010040#include <asm/arch/mux.h>
Tom Rini75c57a32011-11-18 12:48:08 +000041#include <asm/arch/mem.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010042#include <asm/arch/sys_proto.h>
Sanjeev Premi84c3b632011-09-08 10:51:01 -040043#include <asm/gpio.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010044#include <asm/mach-types.h>
Alexander Hollerd90859a2011-04-19 09:30:35 -040045#ifdef CONFIG_USB_EHCI
46#include <usb.h>
47#include <asm/arch/clocks.h>
48#include <asm/arch/clocks_omap3.h>
49#include <asm/arch/ehci_omap3.h>
50/* from drivers/usb/host/ehci-core.h */
51extern struct ehci_hccr *hccr;
52extern volatile struct ehci_hcor *hcor;
53#endif
Dirk Behmef904cdb2009-01-27 18:19:12 +010054#include "beagle.h"
Jason Kridnerf835ea72010-07-21 07:41:25 -050055#include <command.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010056
Alexander Hollerd90859a2011-04-19 09:30:35 -040057#define pr_debug(fmt, args...) debug(fmt, ##args)
58
Koen Kooica5f80a2010-09-20 10:21:33 -070059#define TWL4030_I2C_BUS 0
60#define EXPANSION_EEPROM_I2C_BUS 1
61#define EXPANSION_EEPROM_I2C_ADDRESS 0x50
62
63#define TINCANTOOLS_ZIPPY 0x01000100
64#define TINCANTOOLS_ZIPPY2 0x02000100
65#define TINCANTOOLS_TRAINER 0x04000100
66#define TINCANTOOLS_SHOWDOG 0x03000100
67#define KBADC_BEAGLEFPGA 0x01000600
Koen Kooiee8485f2011-04-18 17:29:35 -040068#define LW_BEAGLETOUCH 0x01000700
69#define BRAINMUX_LCDOG 0x01000800
70#define BRAINMUX_LCDOGTOUCH 0x02000800
71#define BBTOYS_WIFI 0x01000B00
72#define BBTOYS_VGA 0x02000B00
73#define BBTOYS_LCD 0x03000B00
Peter Meerwald6cce5502012-01-03 04:14:35 +000074#define BCT_BRETTL3 0x01000F00
Koen Kooica5f80a2010-09-20 10:21:33 -070075#define BEAGLE_NO_EEPROM 0xffffffff
76
John Rigby29565322010-12-20 18:27:51 -070077DECLARE_GLOBAL_DATA_PTR;
78
Koen Kooica5f80a2010-09-20 10:21:33 -070079static struct {
80 unsigned int device_vendor;
81 unsigned char revision;
82 unsigned char content;
83 char fab_revision[8];
84 char env_var[16];
85 char env_setting[64];
86} expansion_config;
87
Tom Rix58911512009-04-01 22:02:20 -050088/*
Dirk Behmef904cdb2009-01-27 18:19:12 +010089 * Routine: board_init
90 * Description: Early hardware init.
Tom Rix58911512009-04-01 22:02:20 -050091 */
Dirk Behmef904cdb2009-01-27 18:19:12 +010092int board_init(void)
93{
Dirk Behmef904cdb2009-01-27 18:19:12 +010094 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
95 /* board id for Linux */
96 gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
97 /* boot param addr */
98 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
99
Jason Kridner70d8c942011-04-18 17:23:35 -0400100#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
101 status_led_set (STATUS_LED_BOOT, STATUS_LED_ON);
102#endif
103
Dirk Behmef904cdb2009-01-27 18:19:12 +0100104 return 0;
105}
106
Tom Rix58911512009-04-01 22:02:20 -0500107/*
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700108 * Routine: get_board_revision
109 * Description: Detect if we are running on a Beagle revision Ax/Bx,
Steve Sakoman08cbba2ab2010-08-19 20:56:11 -0700110 * C1/2/3, C4 or xM. This can be done by reading
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700111 * the level of GPIO173, GPIO172 and GPIO171. This should
112 * result in
113 * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
114 * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
115 * GPIO173, GPIO172, GPIO171: 1 0 1 => C4
Steve Sakoman08cbba2ab2010-08-19 20:56:11 -0700116 * GPIO173, GPIO172, GPIO171: 0 0 0 => xM
Tom Rix58911512009-04-01 22:02:20 -0500117 */
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700118int get_board_revision(void)
Dirk Behmef956fd02009-02-12 18:55:41 +0100119{
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700120 int revision;
Dirk Behmef956fd02009-02-12 18:55:41 +0100121
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400122 if (!gpio_request(171, "") &&
123 !gpio_request(172, "") &&
124 !gpio_request(173, "")) {
Dirk Behmef956fd02009-02-12 18:55:41 +0100125
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400126 gpio_direction_input(171);
127 gpio_direction_input(172);
128 gpio_direction_input(173);
Dirk Behmef956fd02009-02-12 18:55:41 +0100129
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400130 revision = gpio_get_value(173) << 2 |
131 gpio_get_value(172) << 1 |
132 gpio_get_value(171);
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700133 } else {
134 printf("Error: unable to acquire board revision GPIOs\n");
135 revision = -1;
Tom Rix718763c2009-06-03 01:53:57 -0500136 }
Dirk Behmef956fd02009-02-12 18:55:41 +0100137
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700138 return revision;
Dirk Behmef956fd02009-02-12 18:55:41 +0100139}
140
Tom Rini75c57a32011-11-18 12:48:08 +0000141#ifdef CONFIG_SPL_BUILD
142/*
143 * Routine: get_board_mem_timings
144 * Description: If we use SPL then there is no x-loader nor config header
145 * so we have to setup the DDR timings ourself on both banks.
146 */
147void get_board_mem_timings(u32 *mcfg, u32 *ctrla, u32 *ctrlb, u32 *rfr_ctrl,
148 u32 *mr)
149{
150 int pop_mfr, pop_id;
151
152 /*
153 * We need to identify what PoP memory is on the board so that
154 * we know what timings to use. If we can't identify it then
155 * we know it's an xM. To map the ID values please see nand_ids.c
156 */
157 identify_nand_chip(&pop_mfr, &pop_id);
158
159 *mr = MICRON_V_MR_165;
160 switch (get_board_revision()) {
161 case REVISION_C4:
162 if (pop_mfr == NAND_MFR_STMICRO && pop_id == 0xba) {
163 /* 512MB DDR */
164 *mcfg = NUMONYX_V_MCFG_165(512 << 20);
165 *ctrla = NUMONYX_V_ACTIMA_165;
166 *ctrlb = NUMONYX_V_ACTIMB_165;
167 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
168 break;
robertcnelson@gmail.com223b8aa2012-01-27 07:09:42 +0000169 } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xba) {
170 /* Beagleboard Rev C4, 512MB Nand/256MB DDR*/
171 *mcfg = MICRON_V_MCFG_165(128 << 20);
172 *ctrla = MICRON_V_ACTIMA_165;
173 *ctrlb = MICRON_V_ACTIMB_165;
174 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
175 break;
Tom Rini75c57a32011-11-18 12:48:08 +0000176 } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xbc) {
177 /* Beagleboard Rev C5, 256MB DDR */
178 *mcfg = MICRON_V_MCFG_200(256 << 20);
179 *ctrla = MICRON_V_ACTIMA_200;
180 *ctrlb = MICRON_V_ACTIMB_200;
181 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
182 break;
183 }
184 case REVISION_XM_A:
185 case REVISION_XM_B:
186 case REVISION_XM_C:
187 if (pop_mfr == 0) {
188 /* 256MB DDR */
189 *mcfg = MICRON_V_MCFG_200(256 << 20);
190 *ctrla = MICRON_V_ACTIMA_200;
191 *ctrlb = MICRON_V_ACTIMB_200;
192 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
193 } else {
194 /* 512MB DDR */
195 *mcfg = NUMONYX_V_MCFG_165(512 << 20);
196 *ctrla = NUMONYX_V_ACTIMA_165;
197 *ctrlb = NUMONYX_V_ACTIMB_165;
198 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
199 }
200 break;
201 default:
202 /* Assume 128MB and Micron/165MHz timings to be safe */
203 *mcfg = MICRON_V_MCFG_165(128 << 20);
204 *ctrla = MICRON_V_ACTIMA_165;
205 *ctrlb = MICRON_V_ACTIMB_165;
206 *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
207 }
208}
209#endif
210
Tom Rix58911512009-04-01 22:02:20 -0500211/*
Koen Kooica5f80a2010-09-20 10:21:33 -0700212 * Routine: get_expansion_id
213 * Description: This function checks for expansion board by checking I2C
214 * bus 1 for the availability of an AT24C01B serial EEPROM.
215 * returns the device_vendor field from the EEPROM
216 */
217unsigned int get_expansion_id(void)
218{
219 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
220
221 /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
222 if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
223 i2c_set_bus_num(TWL4030_I2C_BUS);
224 return BEAGLE_NO_EEPROM;
225 }
226
227 /* read configuration data */
228 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
229 sizeof(expansion_config));
230
231 i2c_set_bus_num(TWL4030_I2C_BUS);
232
233 return expansion_config.device_vendor;
234}
235
236/*
Jason Kridner3f16ab92011-04-19 14:01:13 -0500237 * Configure DSS to display background color on DVID
238 * Configure VENC to display color bar on S-Video
239 */
240void beagle_display_init(void)
241{
242 omap3_dss_venc_config(&venc_config_std_tv, VENC_HEIGHT, VENC_WIDTH);
243 switch (get_board_revision()) {
244 case REVISION_AXBX:
245 case REVISION_CX:
246 case REVISION_C4:
247 omap3_dss_panel_config(&dvid_cfg);
248 break;
249 case REVISION_XM_A:
250 case REVISION_XM_B:
251 case REVISION_XM_C:
252 default:
253 omap3_dss_panel_config(&dvid_cfg_xm);
254 break;
255 }
256}
257
258/*
Dirk Behmef904cdb2009-01-27 18:19:12 +0100259 * Routine: misc_init_r
260 * Description: Configure board specific parts
Tom Rix58911512009-04-01 22:02:20 -0500261 */
Dirk Behmef904cdb2009-01-27 18:19:12 +0100262int misc_init_r(void)
263{
Dirk Behme97a099e2009-08-08 09:30:21 +0200264 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
265 struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
Jason Kridnerf14a5222011-04-20 13:52:26 +0000266 struct control_prog_io *prog_io_base = (struct control_prog_io *)OMAP34XX_CTRL_BASE;
Steve Kipiszd4e53f02011-04-18 17:27:00 -0400267
268 /* Enable i2c2 pullup resisters */
269 writel(~(PRG_I2C2_PULLUPRESX), &prog_io_base->io1);
Dirk Behmef904cdb2009-01-27 18:19:12 +0100270
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700271 switch (get_board_revision()) {
272 case REVISION_AXBX:
273 printf("Beagle Rev Ax/Bx\n");
274 setenv("beaglerev", "AxBx");
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700275 break;
276 case REVISION_CX:
277 printf("Beagle Rev C1/C2/C3\n");
278 setenv("beaglerev", "Cx");
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700279 MUX_BEAGLE_C();
280 break;
281 case REVISION_C4:
282 printf("Beagle Rev C4\n");
Steve Sakoman08cbba2ab2010-08-19 20:56:11 -0700283 setenv("beaglerev", "C4");
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700284 MUX_BEAGLE_C();
285 /* Set VAUX2 to 1.8V for EHCI PHY */
286 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
287 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
288 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
289 TWL4030_PM_RECEIVER_DEV_GRP_P1);
290 break;
Koen Kooif6e593b2011-04-18 17:28:32 -0400291 case REVISION_XM_A:
Steve Sakoman08cbba2ab2010-08-19 20:56:11 -0700292 printf("Beagle xM Rev A\n");
293 setenv("beaglerev", "xMA");
Koen Kooif6e593b2011-04-18 17:28:32 -0400294 MUX_BEAGLE_XM();
295 /* Set VAUX2 to 1.8V for EHCI PHY */
296 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
297 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
298 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
299 TWL4030_PM_RECEIVER_DEV_GRP_P1);
300 break;
301 case REVISION_XM_B:
302 printf("Beagle xM Rev B\n");
303 setenv("beaglerev", "xMB");
Steve Sakoman08cbba2ab2010-08-19 20:56:11 -0700304 MUX_BEAGLE_XM();
305 /* Set VAUX2 to 1.8V for EHCI PHY */
306 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
307 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
308 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
309 TWL4030_PM_RECEIVER_DEV_GRP_P1);
310 break;
Koen Kooi1ffcb342011-06-17 09:37:37 +0200311 case REVISION_XM_C:
312 printf("Beagle xM Rev C\n");
313 setenv("beaglerev", "xMC");
314 MUX_BEAGLE_XM();
315 /* Set VAUX2 to 1.8V for EHCI PHY */
316 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
317 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
318 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
319 TWL4030_PM_RECEIVER_DEV_GRP_P1);
320 break;
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700321 default:
322 printf("Beagle unknown 0x%02x\n", get_board_revision());
Koen Kooif6e593b2011-04-18 17:28:32 -0400323 MUX_BEAGLE_XM();
324 /* Set VAUX2 to 1.8V for EHCI PHY */
325 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
326 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
327 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
328 TWL4030_PM_RECEIVER_DEV_GRP_P1);
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700329 }
330
Koen Kooica5f80a2010-09-20 10:21:33 -0700331 switch (get_expansion_id()) {
332 case TINCANTOOLS_ZIPPY:
333 printf("Recognized Tincantools Zippy board (rev %d %s)\n",
334 expansion_config.revision,
335 expansion_config.fab_revision);
336 MUX_TINCANTOOLS_ZIPPY();
337 setenv("buddy", "zippy");
338 break;
339 case TINCANTOOLS_ZIPPY2:
340 printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
341 expansion_config.revision,
342 expansion_config.fab_revision);
343 MUX_TINCANTOOLS_ZIPPY();
344 setenv("buddy", "zippy2");
345 break;
346 case TINCANTOOLS_TRAINER:
347 printf("Recognized Tincantools Trainer board (rev %d %s)\n",
348 expansion_config.revision,
349 expansion_config.fab_revision);
350 MUX_TINCANTOOLS_ZIPPY();
351 MUX_TINCANTOOLS_TRAINER();
352 setenv("buddy", "trainer");
353 break;
354 case TINCANTOOLS_SHOWDOG:
355 printf("Recognized Tincantools Showdow board (rev %d %s)\n",
356 expansion_config.revision,
357 expansion_config.fab_revision);
358 /* Place holder for DSS2 definition for showdog lcd */
359 setenv("defaultdisplay", "showdoglcd");
360 setenv("buddy", "showdog");
361 break;
362 case KBADC_BEAGLEFPGA:
363 printf("Recognized KBADC Beagle FPGA board\n");
364 MUX_KBADC_BEAGLEFPGA();
365 setenv("buddy", "beaglefpga");
366 break;
Koen Kooiee8485f2011-04-18 17:29:35 -0400367 case LW_BEAGLETOUCH:
368 printf("Recognized Liquidware BeagleTouch board\n");
369 setenv("buddy", "beagletouch");
370 break;
371 case BRAINMUX_LCDOG:
372 printf("Recognized Brainmux LCDog board\n");
373 setenv("buddy", "lcdog");
374 break;
375 case BRAINMUX_LCDOGTOUCH:
376 printf("Recognized Brainmux LCDog Touch board\n");
377 setenv("buddy", "lcdogtouch");
378 break;
379 case BBTOYS_WIFI:
380 printf("Recognized BeagleBoardToys WiFi board\n");
381 MUX_BBTOYS_WIFI()
382 setenv("buddy", "bbtoys-wifi");
383 break;;
384 case BBTOYS_VGA:
385 printf("Recognized BeagleBoardToys VGA board\n");
386 break;;
387 case BBTOYS_LCD:
388 printf("Recognized BeagleBoardToys LCD board\n");
389 break;;
Peter Meerwald6cce5502012-01-03 04:14:35 +0000390 case BCT_BRETTL3:
391 printf("Recognized bct electronic GmbH brettl3 board\n");
392 break;
Koen Kooica5f80a2010-09-20 10:21:33 -0700393 case BEAGLE_NO_EEPROM:
394 printf("No EEPROM on expansion board\n");
395 setenv("buddy", "none");
396 break;
397 default:
398 printf("Unrecognized expansion board: %x\n",
399 expansion_config.device_vendor);
400 setenv("buddy", "unknown");
401 }
402
403 if (expansion_config.content == 1)
404 setenv(expansion_config.env_var, expansion_config.env_setting);
405
Tom Rix2c155132009-06-28 12:52:30 -0500406 twl4030_power_init();
Christian Spielberger38a77c32011-08-24 17:17:31 -0500407 switch (get_board_revision()) {
408 case REVISION_XM_A:
409 case REVISION_XM_B:
410 twl4030_led_init(TWL4030_LED_LEDEN_LEDBON);
411 break;
412 default:
413 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
414 break;
415 }
Dirk Behmef904cdb2009-01-27 18:19:12 +0100416
Bob Feretich52d82e42011-02-24 13:16:44 +0000417 /* Set GPIO states before they are made outputs */
Dirk Behmef904cdb2009-01-27 18:19:12 +0100418 writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
419 &gpio6_base->setdataout);
420 writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
421 GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
422
Bob Feretich52d82e42011-02-24 13:16:44 +0000423 /* Configure GPIOs to output */
424 writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
425 writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
426 GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
427
Dirk Behmee6a6a702009-03-12 19:30:50 +0100428 dieid_num_r();
Jason Kridner3f16ab92011-04-19 14:01:13 -0500429 beagle_display_init();
430 omap3_dss_enable();
Dirk Behmee6a6a702009-03-12 19:30:50 +0100431
Dirk Behmef904cdb2009-01-27 18:19:12 +0100432 return 0;
433}
434
Tom Rix58911512009-04-01 22:02:20 -0500435/*
Dirk Behmef904cdb2009-01-27 18:19:12 +0100436 * Routine: set_muxconf_regs
437 * Description: Setting up the configuration Mux registers specific to the
438 * hardware. Many pins need to be moved from protect to primary
439 * mode.
Tom Rix58911512009-04-01 22:02:20 -0500440 */
Dirk Behmef904cdb2009-01-27 18:19:12 +0100441void set_muxconf_regs(void)
442{
443 MUX_BEAGLE();
Dirk Behmef904cdb2009-01-27 18:19:12 +0100444}
Steve Sakoman0cd31142010-09-19 21:19:48 -0700445
Tom Rini75c57a32011-11-18 12:48:08 +0000446#if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
Steve Sakoman0cd31142010-09-19 21:19:48 -0700447int board_mmc_init(bd_t *bis)
448{
449 omap_mmc_init(0);
450 return 0;
451}
452#endif
Alexander Hollerd90859a2011-04-19 09:30:35 -0400453
454#ifdef CONFIG_USB_EHCI
455
456#define GPIO_PHY_RESET 147
457
458/* Reset is needed otherwise the kernel-driver will throw an error. */
459int ehci_hcd_stop(void)
460{
461 pr_debug("Resetting OMAP3 EHCI\n");
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400462 gpio_set_value(GPIO_PHY_RESET, 0);
Alexander Hollerd90859a2011-04-19 09:30:35 -0400463 writel(OMAP_UHH_SYSCONFIG_SOFTRESET, OMAP3_UHH_BASE + OMAP_UHH_SYSCONFIG);
Koen Kooif44047d2011-06-17 09:26:17 +0200464 /* disable USB clocks */
465 struct prcm *prcm_base = (struct prcm *)PRCM_BASE;
466 sr32(&prcm_base->iclken_usbhost, 0, 1, 0);
467 sr32(&prcm_base->fclken_usbhost, 0, 2, 0);
468 sr32(&prcm_base->iclken3_core, 2, 1, 0);
469 sr32(&prcm_base->fclken3_core, 2, 1, 0);
Alexander Hollerd90859a2011-04-19 09:30:35 -0400470 return 0;
471}
472
473/* Call usb_stop() before starting the kernel */
474void show_boot_progress(int val)
475{
476 if(val == 15)
477 usb_stop();
478}
479
480/*
481 * Initialize the OMAP3 EHCI controller and PHY on the BeagleBoard.
482 * Based on "drivers/usb/host/ehci-omap.c" from Linux 2.6.37.
483 * See there for additional Copyrights.
484 */
485int ehci_hcd_init(void)
486{
487 pr_debug("Initializing OMAP3 ECHI\n");
488
489 /* Put the PHY in RESET */
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400490 gpio_request(GPIO_PHY_RESET, "");
491 gpio_direction_output(GPIO_PHY_RESET, 0);
492 gpio_set_value(GPIO_PHY_RESET, 0);
Alexander Hollerd90859a2011-04-19 09:30:35 -0400493
494 /* Hold the PHY in RESET for enough time till DIR is high */
495 /* Refer: ISSUE1 */
496 udelay(10);
497
498 struct prcm *prcm_base = (struct prcm *)PRCM_BASE;
499 /* Enable USBHOST_L3_ICLK (USBHOST_MICLK) */
500 sr32(&prcm_base->iclken_usbhost, 0, 1, 1);
501 /*
502 * Enable USBHOST_48M_FCLK (USBHOST_FCLK1)
503 * and USBHOST_120M_FCLK (USBHOST_FCLK2)
504 */
505 sr32(&prcm_base->fclken_usbhost, 0, 2, 3);
506 /* Enable USBTTL_ICLK */
507 sr32(&prcm_base->iclken3_core, 2, 1, 1);
508 /* Enable USBTTL_FCLK */
509 sr32(&prcm_base->fclken3_core, 2, 1, 1);
510 pr_debug("USB clocks enabled\n");
511
512 /* perform TLL soft reset, and wait until reset is complete */
513 writel(OMAP_USBTLL_SYSCONFIG_SOFTRESET,
514 OMAP3_USBTLL_BASE + OMAP_USBTLL_SYSCONFIG);
515 /* Wait for TLL reset to complete */
516 while (!(readl(OMAP3_USBTLL_BASE + OMAP_USBTLL_SYSSTATUS)
517 & OMAP_USBTLL_SYSSTATUS_RESETDONE));
518 pr_debug("TLL reset done\n");
519
520 writel(OMAP_USBTLL_SYSCONFIG_ENAWAKEUP |
521 OMAP_USBTLL_SYSCONFIG_SIDLEMODE |
522 OMAP_USBTLL_SYSCONFIG_CACTIVITY,
523 OMAP3_USBTLL_BASE + OMAP_USBTLL_SYSCONFIG);
524
525 /* Put UHH in NoIdle/NoStandby mode */
526 writel(OMAP_UHH_SYSCONFIG_ENAWAKEUP
527 | OMAP_UHH_SYSCONFIG_SIDLEMODE
528 | OMAP_UHH_SYSCONFIG_CACTIVITY
529 | OMAP_UHH_SYSCONFIG_MIDLEMODE,
530 OMAP3_UHH_BASE + OMAP_UHH_SYSCONFIG);
531
532 /* setup burst configurations */
533 writel(OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN
534 | OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN
535 | OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN,
536 OMAP3_UHH_BASE + OMAP_UHH_HOSTCONFIG);
537
538 /*
539 * Refer ISSUE1:
540 * Hold the PHY in RESET for enough time till
541 * PHY is settled and ready
542 */
543 udelay(10);
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400544 gpio_set_value(GPIO_PHY_RESET, 1);
Alexander Hollerd90859a2011-04-19 09:30:35 -0400545
546 hccr = (struct ehci_hccr *)(OMAP3_EHCI_BASE);
547 hcor = (struct ehci_hcor *)(OMAP3_EHCI_BASE + 0x10);
548
549 pr_debug("OMAP3 EHCI init done\n");
550 return 0;
551}
552
553#endif /* CONFIG_USB_EHCI */
Jason Kridnerf835ea72010-07-21 07:41:25 -0500554
Tom Rini75c57a32011-11-18 12:48:08 +0000555#ifndef CONFIG_SPL_BUILD
Jason Kridnerf835ea72010-07-21 07:41:25 -0500556/*
557 * This command returns the status of the user button on beagle xM
558 * Input - none
559 * Returns - 1 if button is held down
560 * 0 if button is not held down
561 */
Dirk Behme513e6fd2011-09-22 01:53:22 +0000562int do_userbutton(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Jason Kridnerf835ea72010-07-21 07:41:25 -0500563{
564 int button = 0;
565 int gpio;
566
567 /*
568 * pass address parameter as argv[0] (aka command name),
569 * and all remaining args
570 */
571 switch (get_board_revision()) {
572 case REVISION_AXBX:
573 case REVISION_CX:
574 case REVISION_C4:
575 gpio = 7;
576 break;
577 case REVISION_XM_A:
578 case REVISION_XM_B:
579 case REVISION_XM_C:
580 default:
581 gpio = 4;
582 break;
583 }
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400584 gpio_request(gpio, "");
585 gpio_direction_input(gpio);
Jason Kridnerf835ea72010-07-21 07:41:25 -0500586 printf("The user button is currently ");
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400587 if (gpio_get_value(gpio))
Jason Kridnerf835ea72010-07-21 07:41:25 -0500588 {
589 button = 1;
590 printf("PRESSED.\n");
591 }
592 else
593 {
594 button = 0;
595 printf("NOT pressed.\n");
596 }
597
Jason Kridnerf835ea72010-07-21 07:41:25 -0500598 return !button;
599}
600
601/* -------------------------------------------------------------------- */
602
603U_BOOT_CMD(
604 userbutton, CONFIG_SYS_MAXARGS, 1, do_userbutton,
605 "Return the status of the BeagleBoard USER button",
606 ""
607);
Tom Rini75c57a32011-11-18 12:48:08 +0000608#endif