blob: 1d552647335aa4fdd5a3a1f2ba15d258371b0425 [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 *
Wolfgang Denk1a459662013-07-08 09:37:19 +020014 * SPDX-License-Identifier: GPL-2.0+
Dirk Behmef904cdb2009-01-27 18:19:12 +010015 */
16#include <common.h>
Simon Glassb3f4ca12014-10-22 21:37:15 -060017#include <dm.h>
18#include <ns16550.h>
Uri Mashiach2d8d1902017-01-19 10:51:45 +020019#ifdef CONFIG_LED_STATUS
Jason Kridner70d8c942011-04-18 17:23:35 -040020#include <status_led.h>
21#endif
Tom Rix2c155132009-06-28 12:52:30 -050022#include <twl4030.h>
Masahiro Yamada6ae39002017-11-30 13:45:24 +090023#include <linux/mtd/rawnand.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010024#include <asm/io.h>
Steve Sakoman0cd31142010-09-19 21:19:48 -070025#include <asm/arch/mmc_host_def.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010026#include <asm/arch/mux.h>
Tom Rini75c57a32011-11-18 12:48:08 +000027#include <asm/arch/mem.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010028#include <asm/arch/sys_proto.h>
Sanjeev Premi84c3b632011-09-08 10:51:01 -040029#include <asm/gpio.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010030#include <asm/mach-types.h>
Ilya Yanokc642b152012-11-06 13:48:30 +000031#include <asm/omap_musb.h>
Masahiro Yamada1221ce42016-09-21 11:28:55 +090032#include <linux/errno.h>
Ilya Yanokc642b152012-11-06 13:48:30 +000033#include <linux/usb/ch9.h>
34#include <linux/usb/gadget.h>
35#include <linux/usb/musb.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010036#include "beagle.h"
Jason Kridnerf835ea72010-07-21 07:41:25 -050037#include <command.h>
Dirk Behmef904cdb2009-01-27 18:19:12 +010038
Tom Rini8850c5d2017-05-12 22:33:27 -040039#ifdef CONFIG_USB_EHCI_HCD
Govindraj.R43b62392012-02-06 03:55:34 +000040#include <usb.h>
41#include <asm/ehci-omap.h>
42#endif
43
Koen Kooica5f80a2010-09-20 10:21:33 -070044#define TWL4030_I2C_BUS 0
45#define EXPANSION_EEPROM_I2C_BUS 1
46#define EXPANSION_EEPROM_I2C_ADDRESS 0x50
47
48#define TINCANTOOLS_ZIPPY 0x01000100
49#define TINCANTOOLS_ZIPPY2 0x02000100
50#define TINCANTOOLS_TRAINER 0x04000100
51#define TINCANTOOLS_SHOWDOG 0x03000100
52#define KBADC_BEAGLEFPGA 0x01000600
Koen Kooiee8485f2011-04-18 17:29:35 -040053#define LW_BEAGLETOUCH 0x01000700
54#define BRAINMUX_LCDOG 0x01000800
55#define BRAINMUX_LCDOGTOUCH 0x02000800
56#define BBTOYS_WIFI 0x01000B00
57#define BBTOYS_VGA 0x02000B00
58#define BBTOYS_LCD 0x03000B00
Peter Meerwald6cce5502012-01-03 04:14:35 +000059#define BCT_BRETTL3 0x01000F00
Peter Meerwaldef88e602012-06-28 05:38:35 +000060#define BCT_BRETTL4 0x02000F00
robertcnelson@gmail.com8a1f2dc2013-02-04 06:03:30 +000061#define LSR_COM6L_ADPT 0x01001300
Koen Kooica5f80a2010-09-20 10:21:33 -070062#define BEAGLE_NO_EEPROM 0xffffffff
63
John Rigby29565322010-12-20 18:27:51 -070064DECLARE_GLOBAL_DATA_PTR;
65
Koen Kooica5f80a2010-09-20 10:21:33 -070066static struct {
67 unsigned int device_vendor;
68 unsigned char revision;
69 unsigned char content;
70 char fab_revision[8];
71 char env_var[16];
72 char env_setting[64];
73} expansion_config;
74
Simon Glassb3f4ca12014-10-22 21:37:15 -060075static const struct ns16550_platdata beagle_serial = {
Adam Ford2f6ed3b2016-03-07 21:08:49 -060076 .base = OMAP34XX_UART3,
77 .reg_shift = 2,
Heiko Schocher17fa0322017-01-18 08:05:49 +010078 .clock = V_NS16550_CLK,
79 .fcr = UART_FCR_DEFVAL,
Simon Glassb3f4ca12014-10-22 21:37:15 -060080};
81
82U_BOOT_DEVICE(beagle_uart) = {
Thomas Chouc7b96862015-11-19 21:48:12 +080083 "ns16550_serial",
Simon Glassb3f4ca12014-10-22 21:37:15 -060084 &beagle_serial
85};
86
Tom Rix58911512009-04-01 22:02:20 -050087/*
Dirk Behmef904cdb2009-01-27 18:19:12 +010088 * Routine: board_init
89 * Description: Early hardware init.
Tom Rix58911512009-04-01 22:02:20 -050090 */
Dirk Behmef904cdb2009-01-27 18:19:12 +010091int board_init(void)
92{
Dirk Behmef904cdb2009-01-27 18:19:12 +010093 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
94 /* board id for Linux */
95 gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
96 /* boot param addr */
97 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
98
Uri Mashiach2d8d1902017-01-19 10:51:45 +020099#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
100 status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON);
Jason Kridner70d8c942011-04-18 17:23:35 -0400101#endif
102
Dirk Behmef904cdb2009-01-27 18:19:12 +0100103 return 0;
104}
105
Derald D. Woods4b379282017-12-29 10:37:32 -0600106#if defined(CONFIG_SPL_OS_BOOT)
107int spl_start_uboot(void)
108{
109 /* break into full u-boot on 'c' */
110 if (serial_tstc() && serial_getc() == 'c')
111 return 1;
112
113 return 0;
114}
115#endif /* CONFIG_SPL_OS_BOOT */
116
Tom Rix58911512009-04-01 22:02:20 -0500117/*
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700118 * Routine: get_board_revision
119 * Description: Detect if we are running on a Beagle revision Ax/Bx,
Tom Rini8ce4e5f2013-04-16 16:31:20 -0400120 * C1/2/3, C4, xM Ax/Bx or xM Cx. This can be done by reading
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700121 * the level of GPIO173, GPIO172 and GPIO171. This should
122 * result in
123 * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
124 * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
125 * GPIO173, GPIO172, GPIO171: 1 0 1 => C4
Tom Rini8ce4e5f2013-04-16 16:31:20 -0400126 * GPIO173, GPIO172, GPIO171: 0 1 0 => xM Cx
127 * GPIO173, GPIO172, GPIO171: 0 0 0 => xM Ax/Bx
Tom Rix58911512009-04-01 22:02:20 -0500128 */
Peter Meerwaldfff1a572012-07-02 03:19:03 +0000129static int get_board_revision(void)
Dirk Behmef956fd02009-02-12 18:55:41 +0100130{
Simon Glassb3f4ca12014-10-22 21:37:15 -0600131 static int revision = -1;
Dirk Behmef956fd02009-02-12 18:55:41 +0100132
Simon Glassb3f4ca12014-10-22 21:37:15 -0600133 if (revision == -1) {
134 if (!gpio_request(171, "rev0") &&
135 !gpio_request(172, "rev1") &&
136 !gpio_request(173, "rev2")) {
137 gpio_direction_input(171);
138 gpio_direction_input(172);
139 gpio_direction_input(173);
Dirk Behmef956fd02009-02-12 18:55:41 +0100140
Simon Glassb3f4ca12014-10-22 21:37:15 -0600141 revision = gpio_get_value(173) << 2 |
142 gpio_get_value(172) << 1 |
143 gpio_get_value(171);
144 } else {
145 printf("Error: unable to acquire board revision GPIOs\n");
146 }
Tom Rix718763c2009-06-03 01:53:57 -0500147 }
Dirk Behmef956fd02009-02-12 18:55:41 +0100148
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700149 return revision;
Dirk Behmef956fd02009-02-12 18:55:41 +0100150}
151
Tom Rini75c57a32011-11-18 12:48:08 +0000152#ifdef CONFIG_SPL_BUILD
153/*
154 * Routine: get_board_mem_timings
155 * Description: If we use SPL then there is no x-loader nor config header
156 * so we have to setup the DDR timings ourself on both banks.
157 */
Peter Barada8c4445d2012-11-13 07:40:28 +0000158void get_board_mem_timings(struct board_sdrc_timings *timings)
Tom Rini75c57a32011-11-18 12:48:08 +0000159{
160 int pop_mfr, pop_id;
161
162 /*
163 * We need to identify what PoP memory is on the board so that
164 * we know what timings to use. If we can't identify it then
165 * we know it's an xM. To map the ID values please see nand_ids.c
166 */
167 identify_nand_chip(&pop_mfr, &pop_id);
168
Peter Barada8c4445d2012-11-13 07:40:28 +0000169 timings->mr = MICRON_V_MR_165;
Tom Rini75c57a32011-11-18 12:48:08 +0000170 switch (get_board_revision()) {
171 case REVISION_C4:
172 if (pop_mfr == NAND_MFR_STMICRO && pop_id == 0xba) {
173 /* 512MB DDR */
Peter Barada8c4445d2012-11-13 07:40:28 +0000174 timings->mcfg = NUMONYX_V_MCFG_165(512 << 20);
175 timings->ctrla = NUMONYX_V_ACTIMA_165;
176 timings->ctrlb = NUMONYX_V_ACTIMB_165;
177 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
Tom Rini75c57a32011-11-18 12:48:08 +0000178 break;
robertcnelson@gmail.com223b8aa2012-01-27 07:09:42 +0000179 } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xba) {
180 /* Beagleboard Rev C4, 512MB Nand/256MB DDR*/
Peter Barada8c4445d2012-11-13 07:40:28 +0000181 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
182 timings->ctrla = MICRON_V_ACTIMA_165;
183 timings->ctrlb = MICRON_V_ACTIMB_165;
184 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
robertcnelson@gmail.com223b8aa2012-01-27 07:09:42 +0000185 break;
Tom Rini75c57a32011-11-18 12:48:08 +0000186 } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xbc) {
187 /* Beagleboard Rev C5, 256MB DDR */
Peter Barada8c4445d2012-11-13 07:40:28 +0000188 timings->mcfg = MICRON_V_MCFG_200(256 << 20);
189 timings->ctrla = MICRON_V_ACTIMA_200;
190 timings->ctrlb = MICRON_V_ACTIMB_200;
191 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
Tom Rini75c57a32011-11-18 12:48:08 +0000192 break;
193 }
Nishanth Menonaf4d8962013-07-15 07:11:30 -0500194 case REVISION_XM_AB:
Tom Rini75c57a32011-11-18 12:48:08 +0000195 case REVISION_XM_C:
196 if (pop_mfr == 0) {
197 /* 256MB DDR */
Peter Barada8c4445d2012-11-13 07:40:28 +0000198 timings->mcfg = MICRON_V_MCFG_200(256 << 20);
199 timings->ctrla = MICRON_V_ACTIMA_200;
200 timings->ctrlb = MICRON_V_ACTIMB_200;
201 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
Tom Rini75c57a32011-11-18 12:48:08 +0000202 } else {
203 /* 512MB DDR */
Peter Barada8c4445d2012-11-13 07:40:28 +0000204 timings->mcfg = NUMONYX_V_MCFG_165(512 << 20);
205 timings->ctrla = NUMONYX_V_ACTIMA_165;
206 timings->ctrlb = NUMONYX_V_ACTIMB_165;
207 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
Tom Rini75c57a32011-11-18 12:48:08 +0000208 }
209 break;
210 default:
211 /* Assume 128MB and Micron/165MHz timings to be safe */
Peter Barada8c4445d2012-11-13 07:40:28 +0000212 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
213 timings->ctrla = MICRON_V_ACTIMA_165;
214 timings->ctrlb = MICRON_V_ACTIMB_165;
215 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
Tom Rini75c57a32011-11-18 12:48:08 +0000216 }
217}
218#endif
219
Tom Rix58911512009-04-01 22:02:20 -0500220/*
Koen Kooica5f80a2010-09-20 10:21:33 -0700221 * Routine: get_expansion_id
222 * Description: This function checks for expansion board by checking I2C
223 * bus 1 for the availability of an AT24C01B serial EEPROM.
224 * returns the device_vendor field from the EEPROM
225 */
Peter Meerwaldfff1a572012-07-02 03:19:03 +0000226static unsigned int get_expansion_id(void)
Koen Kooica5f80a2010-09-20 10:21:33 -0700227{
228 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
229
230 /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
231 if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
232 i2c_set_bus_num(TWL4030_I2C_BUS);
233 return BEAGLE_NO_EEPROM;
234 }
235
236 /* read configuration data */
237 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
238 sizeof(expansion_config));
239
robertcnelson@gmail.comff229ec2013-02-04 06:03:10 +0000240 /* retry reading configuration data with 16bit addressing */
241 if ((expansion_config.device_vendor == 0xFFFFFF00) ||
242 (expansion_config.device_vendor == 0xFFFFFFFF)) {
243 printf("EEPROM is blank or 8bit addressing failed: retrying with 16bit:\n");
244 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 2, (u8 *)&expansion_config,
245 sizeof(expansion_config));
246 }
247
Koen Kooica5f80a2010-09-20 10:21:33 -0700248 i2c_set_bus_num(TWL4030_I2C_BUS);
249
250 return expansion_config.device_vendor;
251}
252
Peter Meerwald2c30c182012-07-10 06:07:34 +0000253#ifdef CONFIG_VIDEO_OMAP3
Koen Kooica5f80a2010-09-20 10:21:33 -0700254/*
Jason Kridner3f16ab92011-04-19 14:01:13 -0500255 * Configure DSS to display background color on DVID
256 * Configure VENC to display color bar on S-Video
257 */
Peter Meerwaldfff1a572012-07-02 03:19:03 +0000258static void beagle_display_init(void)
Jason Kridner3f16ab92011-04-19 14:01:13 -0500259{
260 omap3_dss_venc_config(&venc_config_std_tv, VENC_HEIGHT, VENC_WIDTH);
261 switch (get_board_revision()) {
262 case REVISION_AXBX:
263 case REVISION_CX:
264 case REVISION_C4:
265 omap3_dss_panel_config(&dvid_cfg);
266 break;
Nishanth Menonaf4d8962013-07-15 07:11:30 -0500267 case REVISION_XM_AB:
Jason Kridner3f16ab92011-04-19 14:01:13 -0500268 case REVISION_XM_C:
269 default:
270 omap3_dss_panel_config(&dvid_cfg_xm);
271 break;
272 }
273}
274
275/*
Peter Meerwald4258aa62012-02-08 05:24:26 +0000276 * Enable DVI power
277 */
Anatolij Gustschin3fbc6932012-03-27 23:05:07 +0000278static void beagle_dvi_pup(void)
279{
Peter Meerwald4258aa62012-02-08 05:24:26 +0000280 uchar val;
281
282 switch (get_board_revision()) {
283 case REVISION_AXBX:
284 case REVISION_CX:
285 case REVISION_C4:
Simon Glassb3f4ca12014-10-22 21:37:15 -0600286 gpio_request(170, "dvi");
Peter Meerwald4258aa62012-02-08 05:24:26 +0000287 gpio_direction_output(170, 0);
288 gpio_set_value(170, 1);
289 break;
Nishanth Menonaf4d8962013-07-15 07:11:30 -0500290 case REVISION_XM_AB:
Peter Meerwald4258aa62012-02-08 05:24:26 +0000291 case REVISION_XM_C:
292 default:
293 #define GPIODATADIR1 (TWL4030_BASEADD_GPIO+3)
294 #define GPIODATAOUT1 (TWL4030_BASEADD_GPIO+6)
295
296 i2c_read(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
297 val |= 4;
298 i2c_write(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
299
300 i2c_read(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
301 val |= 4;
302 i2c_write(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
303 break;
304 }
305}
Peter Meerwald2c30c182012-07-10 06:07:34 +0000306#endif
Peter Meerwald4258aa62012-02-08 05:24:26 +0000307
Ilya Yanokc642b152012-11-06 13:48:30 +0000308#ifdef CONFIG_USB_MUSB_OMAP2PLUS
309static struct musb_hdrc_config musb_config = {
310 .multipoint = 1,
311 .dyn_fifo = 1,
312 .num_eps = 16,
313 .ram_bits = 12,
314};
315
316static struct omap_musb_board_data musb_board_data = {
317 .interface_type = MUSB_INTERFACE_ULPI,
318};
319
320static struct musb_hdrc_platform_data musb_plat = {
Paul Kocialkowski95de1e22015-08-04 17:04:06 +0200321#if defined(CONFIG_USB_MUSB_HOST)
Ilya Yanokc642b152012-11-06 13:48:30 +0000322 .mode = MUSB_HOST,
Paul Kocialkowski95de1e22015-08-04 17:04:06 +0200323#elif defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanokc642b152012-11-06 13:48:30 +0000324 .mode = MUSB_PERIPHERAL,
325#else
Paul Kocialkowski95de1e22015-08-04 17:04:06 +0200326#error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET"
Ilya Yanokc642b152012-11-06 13:48:30 +0000327#endif
328 .config = &musb_config,
329 .power = 100,
330 .platform_ops = &omap2430_ops,
331 .board_data = &musb_board_data,
332};
333#endif
334
Peter Meerwald4258aa62012-02-08 05:24:26 +0000335/*
Dirk Behmef904cdb2009-01-27 18:19:12 +0100336 * Routine: misc_init_r
337 * Description: Configure board specific parts
Tom Rix58911512009-04-01 22:02:20 -0500338 */
Dirk Behmef904cdb2009-01-27 18:19:12 +0100339int misc_init_r(void)
340{
Dirk Behme97a099e2009-08-08 09:30:21 +0200341 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
342 struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
Jason Kridnerf14a5222011-04-20 13:52:26 +0000343 struct control_prog_io *prog_io_base = (struct control_prog_io *)OMAP34XX_CTRL_BASE;
Nishanth Menon548a64d2014-03-28 11:00:06 -0500344 bool generate_fake_mac = false;
Alexander Kochetkov04e2a132014-09-29 21:46:48 +0400345 u32 value;
Steve Kipiszd4e53f02011-04-18 17:27:00 -0400346
347 /* Enable i2c2 pullup resisters */
Alexander Kochetkov04e2a132014-09-29 21:46:48 +0400348 value = readl(&prog_io_base->io1);
349 value &= ~(PRG_I2C2_PULLUPRESX);
350 writel(value, &prog_io_base->io1);
Dirk Behmef904cdb2009-01-27 18:19:12 +0100351
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700352 switch (get_board_revision()) {
353 case REVISION_AXBX:
354 printf("Beagle Rev Ax/Bx\n");
Simon Glass382bee52017-08-03 12:22:09 -0600355 env_set("beaglerev", "AxBx");
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700356 break;
357 case REVISION_CX:
358 printf("Beagle Rev C1/C2/C3\n");
Simon Glass382bee52017-08-03 12:22:09 -0600359 env_set("beaglerev", "Cx");
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700360 MUX_BEAGLE_C();
361 break;
362 case REVISION_C4:
363 printf("Beagle Rev C4\n");
Simon Glass382bee52017-08-03 12:22:09 -0600364 env_set("beaglerev", "C4");
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700365 MUX_BEAGLE_C();
366 /* Set VAUX2 to 1.8V for EHCI PHY */
367 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
368 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
369 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
370 TWL4030_PM_RECEIVER_DEV_GRP_P1);
371 break;
Nishanth Menonaf4d8962013-07-15 07:11:30 -0500372 case REVISION_XM_AB:
373 printf("Beagle xM Rev A/B\n");
Simon Glass382bee52017-08-03 12:22:09 -0600374 env_set("beaglerev", "xMAB");
Steve Sakoman08cbba2ab2010-08-19 20:56:11 -0700375 MUX_BEAGLE_XM();
376 /* Set VAUX2 to 1.8V for EHCI PHY */
377 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
378 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
379 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
380 TWL4030_PM_RECEIVER_DEV_GRP_P1);
Nishanth Menon548a64d2014-03-28 11:00:06 -0500381 generate_fake_mac = true;
Steve Sakoman08cbba2ab2010-08-19 20:56:11 -0700382 break;
Koen Kooi1ffcb342011-06-17 09:37:37 +0200383 case REVISION_XM_C:
384 printf("Beagle xM Rev C\n");
Simon Glass382bee52017-08-03 12:22:09 -0600385 env_set("beaglerev", "xMC");
Koen Kooi1ffcb342011-06-17 09:37:37 +0200386 MUX_BEAGLE_XM();
387 /* Set VAUX2 to 1.8V for EHCI PHY */
388 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
389 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
390 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
391 TWL4030_PM_RECEIVER_DEV_GRP_P1);
Nishanth Menon548a64d2014-03-28 11:00:06 -0500392 generate_fake_mac = true;
Koen Kooi1ffcb342011-06-17 09:37:37 +0200393 break;
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700394 default:
395 printf("Beagle unknown 0x%02x\n", get_board_revision());
Koen Kooif6e593b2011-04-18 17:28:32 -0400396 MUX_BEAGLE_XM();
397 /* Set VAUX2 to 1.8V for EHCI PHY */
398 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
399 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
400 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
401 TWL4030_PM_RECEIVER_DEV_GRP_P1);
Nishanth Menon548a64d2014-03-28 11:00:06 -0500402 generate_fake_mac = true;
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700403 }
404
Koen Kooica5f80a2010-09-20 10:21:33 -0700405 switch (get_expansion_id()) {
406 case TINCANTOOLS_ZIPPY:
407 printf("Recognized Tincantools Zippy board (rev %d %s)\n",
408 expansion_config.revision,
409 expansion_config.fab_revision);
410 MUX_TINCANTOOLS_ZIPPY();
Simon Glass382bee52017-08-03 12:22:09 -0600411 env_set("buddy", "zippy");
Koen Kooica5f80a2010-09-20 10:21:33 -0700412 break;
413 case TINCANTOOLS_ZIPPY2:
414 printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
415 expansion_config.revision,
416 expansion_config.fab_revision);
417 MUX_TINCANTOOLS_ZIPPY();
Simon Glass382bee52017-08-03 12:22:09 -0600418 env_set("buddy", "zippy2");
Koen Kooica5f80a2010-09-20 10:21:33 -0700419 break;
420 case TINCANTOOLS_TRAINER:
421 printf("Recognized Tincantools Trainer board (rev %d %s)\n",
422 expansion_config.revision,
423 expansion_config.fab_revision);
424 MUX_TINCANTOOLS_ZIPPY();
425 MUX_TINCANTOOLS_TRAINER();
Simon Glass382bee52017-08-03 12:22:09 -0600426 env_set("buddy", "trainer");
Koen Kooica5f80a2010-09-20 10:21:33 -0700427 break;
428 case TINCANTOOLS_SHOWDOG:
429 printf("Recognized Tincantools Showdow board (rev %d %s)\n",
430 expansion_config.revision,
431 expansion_config.fab_revision);
432 /* Place holder for DSS2 definition for showdog lcd */
Simon Glass382bee52017-08-03 12:22:09 -0600433 env_set("defaultdisplay", "showdoglcd");
434 env_set("buddy", "showdog");
Koen Kooica5f80a2010-09-20 10:21:33 -0700435 break;
436 case KBADC_BEAGLEFPGA:
437 printf("Recognized KBADC Beagle FPGA board\n");
438 MUX_KBADC_BEAGLEFPGA();
Simon Glass382bee52017-08-03 12:22:09 -0600439 env_set("buddy", "beaglefpga");
Koen Kooica5f80a2010-09-20 10:21:33 -0700440 break;
Koen Kooiee8485f2011-04-18 17:29:35 -0400441 case LW_BEAGLETOUCH:
442 printf("Recognized Liquidware BeagleTouch board\n");
Simon Glass382bee52017-08-03 12:22:09 -0600443 env_set("buddy", "beagletouch");
Koen Kooiee8485f2011-04-18 17:29:35 -0400444 break;
445 case BRAINMUX_LCDOG:
446 printf("Recognized Brainmux LCDog board\n");
Simon Glass382bee52017-08-03 12:22:09 -0600447 env_set("buddy", "lcdog");
Koen Kooiee8485f2011-04-18 17:29:35 -0400448 break;
449 case BRAINMUX_LCDOGTOUCH:
450 printf("Recognized Brainmux LCDog Touch board\n");
Simon Glass382bee52017-08-03 12:22:09 -0600451 env_set("buddy", "lcdogtouch");
Koen Kooiee8485f2011-04-18 17:29:35 -0400452 break;
453 case BBTOYS_WIFI:
454 printf("Recognized BeagleBoardToys WiFi board\n");
455 MUX_BBTOYS_WIFI()
Simon Glass382bee52017-08-03 12:22:09 -0600456 env_set("buddy", "bbtoys-wifi");
Masahiro Yamada51855e82017-06-13 15:17:28 +0900457 break;
Koen Kooiee8485f2011-04-18 17:29:35 -0400458 case BBTOYS_VGA:
459 printf("Recognized BeagleBoardToys VGA board\n");
Masahiro Yamada51855e82017-06-13 15:17:28 +0900460 break;
Koen Kooiee8485f2011-04-18 17:29:35 -0400461 case BBTOYS_LCD:
462 printf("Recognized BeagleBoardToys LCD board\n");
Masahiro Yamada51855e82017-06-13 15:17:28 +0900463 break;
Peter Meerwald6cce5502012-01-03 04:14:35 +0000464 case BCT_BRETTL3:
Peter Meerwaldef88e602012-06-28 05:38:35 +0000465 printf("Recognized bct electronic GmbH brettl3 board\n");
466 break;
467 case BCT_BRETTL4:
468 printf("Recognized bct electronic GmbH brettl4 board\n");
469 break;
robertcnelson@gmail.com8a1f2dc2013-02-04 06:03:30 +0000470 case LSR_COM6L_ADPT:
471 printf("Recognized LSR COM6L Adapter Board\n");
472 MUX_BBTOYS_WIFI()
Simon Glass382bee52017-08-03 12:22:09 -0600473 env_set("buddy", "lsr-com6l-adpt");
robertcnelson@gmail.com8a1f2dc2013-02-04 06:03:30 +0000474 break;
Koen Kooica5f80a2010-09-20 10:21:33 -0700475 case BEAGLE_NO_EEPROM:
476 printf("No EEPROM on expansion board\n");
Simon Glass382bee52017-08-03 12:22:09 -0600477 env_set("buddy", "none");
Koen Kooica5f80a2010-09-20 10:21:33 -0700478 break;
479 default:
480 printf("Unrecognized expansion board: %x\n",
481 expansion_config.device_vendor);
Simon Glass382bee52017-08-03 12:22:09 -0600482 env_set("buddy", "unknown");
Koen Kooica5f80a2010-09-20 10:21:33 -0700483 }
484
485 if (expansion_config.content == 1)
Simon Glass382bee52017-08-03 12:22:09 -0600486 env_set(expansion_config.env_var, expansion_config.env_setting);
Koen Kooica5f80a2010-09-20 10:21:33 -0700487
Tom Rix2c155132009-06-28 12:52:30 -0500488 twl4030_power_init();
Christian Spielberger38a77c32011-08-24 17:17:31 -0500489 switch (get_board_revision()) {
Nishanth Menonaf4d8962013-07-15 07:11:30 -0500490 case REVISION_XM_AB:
Christian Spielberger38a77c32011-08-24 17:17:31 -0500491 twl4030_led_init(TWL4030_LED_LEDEN_LEDBON);
492 break;
493 default:
494 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
495 break;
496 }
Dirk Behmef904cdb2009-01-27 18:19:12 +0100497
Bob Feretich52d82e42011-02-24 13:16:44 +0000498 /* Set GPIO states before they are made outputs */
Dirk Behmef904cdb2009-01-27 18:19:12 +0100499 writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
500 &gpio6_base->setdataout);
501 writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
502 GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
503
Bob Feretich52d82e42011-02-24 13:16:44 +0000504 /* Configure GPIOs to output */
505 writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
506 writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
507 GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
508
Paul Kocialkowski679f82c2015-08-27 19:37:13 +0200509 omap_die_id_display();
Peter Meerwald4258aa62012-02-08 05:24:26 +0000510
Peter Meerwald2c30c182012-07-10 06:07:34 +0000511#ifdef CONFIG_VIDEO_OMAP3
Peter Meerwald4258aa62012-02-08 05:24:26 +0000512 beagle_dvi_pup();
Jason Kridner3f16ab92011-04-19 14:01:13 -0500513 beagle_display_init();
514 omap3_dss_enable();
Peter Meerwald2c30c182012-07-10 06:07:34 +0000515#endif
Dirk Behmee6a6a702009-03-12 19:30:50 +0100516
Ilya Yanokc642b152012-11-06 13:48:30 +0000517#ifdef CONFIG_USB_MUSB_OMAP2PLUS
518 musb_register(&musb_plat, &musb_board_data, (void *)MUSB_BASE);
519#endif
520
Paul Kocialkowski07815eb2015-08-27 19:37:12 +0200521 if (generate_fake_mac)
522 omap_die_id_usbethaddr();
Nishanth Menon548a64d2014-03-28 11:00:06 -0500523
Derald D. Woodsebf6e262018-02-26 17:52:57 -0600524#if defined(CONFIG_MTDIDS_DEFAULT) && defined(CONFIG_MTDPARTS_DEFAULT)
525 if (strlen(CONFIG_MTDIDS_DEFAULT))
526 env_set("mtdids", CONFIG_MTDIDS_DEFAULT);
527
528 if (strlen(CONFIG_MTDPARTS_DEFAULT))
529 env_set("mtdparts", CONFIG_MTDPARTS_DEFAULT);
530#endif
531
Dirk Behmef904cdb2009-01-27 18:19:12 +0100532 return 0;
533}
534
Tom Rix58911512009-04-01 22:02:20 -0500535/*
Dirk Behmef904cdb2009-01-27 18:19:12 +0100536 * Routine: set_muxconf_regs
537 * Description: Setting up the configuration Mux registers specific to the
538 * hardware. Many pins need to be moved from protect to primary
539 * mode.
Tom Rix58911512009-04-01 22:02:20 -0500540 */
Dirk Behmef904cdb2009-01-27 18:19:12 +0100541void set_muxconf_regs(void)
542{
543 MUX_BEAGLE();
Dirk Behmef904cdb2009-01-27 18:19:12 +0100544}
Steve Sakoman0cd31142010-09-19 21:19:48 -0700545
Masahiro Yamada4aa2ba32017-05-09 20:31:39 +0900546#if defined(CONFIG_MMC)
Steve Sakoman0cd31142010-09-19 21:19:48 -0700547int board_mmc_init(bd_t *bis)
548{
Nikita Kiryanove3913f52012-12-03 02:19:47 +0000549 return omap_mmc_init(0, 0, 0, -1, -1);
Steve Sakoman0cd31142010-09-19 21:19:48 -0700550}
551#endif
Alexander Hollerd90859a2011-04-19 09:30:35 -0400552
Masahiro Yamada4aa2ba32017-05-09 20:31:39 +0900553#if defined(CONFIG_MMC)
Paul Kocialkowskiaac54502014-11-08 20:55:47 +0100554void board_mmc_power_init(void)
555{
556 twl4030_power_mmc_init(0);
557}
558#endif
559
Tom Rini8850c5d2017-05-12 22:33:27 -0400560#if defined(CONFIG_USB_EHCI_HCD) && !defined(CONFIG_SPL_BUILD)
Alexander Hollerd90859a2011-04-19 09:30:35 -0400561/* Call usb_stop() before starting the kernel */
562void show_boot_progress(int val)
563{
Simon Glass578ac1e2011-12-10 11:07:54 +0000564 if (val == BOOTSTAGE_ID_RUN_OS)
Alexander Hollerd90859a2011-04-19 09:30:35 -0400565 usb_stop();
566}
Govindraj.R43b62392012-02-06 03:55:34 +0000567
568static struct omap_usbhs_board_data usbhs_bdata = {
569 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
570 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
571 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
572};
573
Troy Kisky127efc42013-10-10 15:27:57 -0700574int ehci_hcd_init(int index, enum usb_init_type init,
575 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
Govindraj.R43b62392012-02-06 03:55:34 +0000576{
Mateusz Zalega16297cf2013-10-04 19:22:26 +0200577 return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
Govindraj.R43b62392012-02-06 03:55:34 +0000578}
579
Lucas Stach676ae062012-09-26 00:14:35 +0200580int ehci_hcd_stop(int index)
Govindraj.R43b62392012-02-06 03:55:34 +0000581{
582 return omap_ehci_hcd_stop();
583}
584
Tom Rini8850c5d2017-05-12 22:33:27 -0400585#endif /* CONFIG_USB_EHCI_HCD */
Ilya Yanokc642b152012-11-06 13:48:30 +0000586
Paul Kocialkowski95de1e22015-08-04 17:04:06 +0200587#if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanokc642b152012-11-06 13:48:30 +0000588int board_eth_init(bd_t *bis)
589{
590 return usb_eth_initialize(bis);
591}
592#endif