blob: 9139ad87d400b0de8b59e30531421c48271fa165 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Dirk Behme2781f802009-01-27 18:19:12 +01002/*
Tom Rini06c32fb2011-11-18 12:48:08 +00003 * (C) Copyright 2004-2011
Dirk Behme2781f802009-01-27 18:19:12 +01004 * Texas Instruments, <www.ti.com>
5 *
6 * Author :
7 * Sunil Kumar <sunilsaini05@gmail.com>
8 * Shashi Ranjan <shashiranjanmca05@gmail.com>
9 *
10 * Derived from Beagle Board and 3430 SDP code by
11 * Richard Woodruff <r-woodruff2@ti.com>
12 * Syed Mohammed Khasim <khasim@ti.com>
13 *
Dirk Behme2781f802009-01-27 18:19:12 +010014 */
15#include <common.h>
Simon Glass1ea97892020-05-10 11:40:00 -060016#include <bootstage.h>
Simon Glassbc0f4ea2014-10-22 21:37:15 -060017#include <dm.h>
Simon Glass5e6201b2019-08-01 09:46:51 -060018#include <env.h>
Simon Glass97589732020-05-10 11:40:02 -060019#include <init.h>
Simon Glass274e0b02020-05-10 11:39:56 -060020#include <net.h>
Simon Glassbc0f4ea2014-10-22 21:37:15 -060021#include <ns16550.h>
Simon Glass36736182019-11-14 12:57:24 -070022#include <serial.h>
Uri Mashiach4892d392017-01-19 10:51:45 +020023#ifdef CONFIG_LED_STATUS
Jason Kridnerc3ef8bc2011-04-18 17:23:35 -040024#include <status_led.h>
25#endif
Tom Rix0f2a8042009-06-28 12:52:30 -050026#include <twl4030.h>
Masahiro Yamada2b7a8732017-11-30 13:45:24 +090027#include <linux/mtd/rawnand.h>
Dirk Behme2781f802009-01-27 18:19:12 +010028#include <asm/io.h>
Steve Sakoman57c62412010-09-19 21:19:48 -070029#include <asm/arch/mmc_host_def.h>
Dirk Behme2781f802009-01-27 18:19:12 +010030#include <asm/arch/mux.h>
Tom Rini06c32fb2011-11-18 12:48:08 +000031#include <asm/arch/mem.h>
Dirk Behme2781f802009-01-27 18:19:12 +010032#include <asm/arch/sys_proto.h>
Sanjeev Premi7b3dc822011-09-08 10:51:01 -040033#include <asm/gpio.h>
Dirk Behme2781f802009-01-27 18:19:12 +010034#include <asm/mach-types.h>
Ilya Yanokcb7b2b82012-11-06 13:48:30 +000035#include <asm/omap_musb.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +090036#include <linux/errno.h>
Ilya Yanokcb7b2b82012-11-06 13:48:30 +000037#include <linux/usb/ch9.h>
38#include <linux/usb/gadget.h>
39#include <linux/usb/musb.h>
Dirk Behme2781f802009-01-27 18:19:12 +010040#include "beagle.h"
Jason Kridner85a08fb2010-07-21 07:41:25 -050041#include <command.h>
Dirk Behme2781f802009-01-27 18:19:12 +010042
Tom Riniceed5d22017-05-12 22:33:27 -040043#ifdef CONFIG_USB_EHCI_HCD
Govindraj.Redc16a02012-02-06 03:55:34 +000044#include <usb.h>
45#include <asm/ehci-omap.h>
46#endif
47
Koen Kooib6241c22010-09-20 10:21:33 -070048#define TWL4030_I2C_BUS 0
49#define EXPANSION_EEPROM_I2C_BUS 1
50#define EXPANSION_EEPROM_I2C_ADDRESS 0x50
51
52#define TINCANTOOLS_ZIPPY 0x01000100
53#define TINCANTOOLS_ZIPPY2 0x02000100
54#define TINCANTOOLS_TRAINER 0x04000100
55#define TINCANTOOLS_SHOWDOG 0x03000100
56#define KBADC_BEAGLEFPGA 0x01000600
Koen Kooi3d5dac62011-04-18 17:29:35 -040057#define LW_BEAGLETOUCH 0x01000700
58#define BRAINMUX_LCDOG 0x01000800
59#define BRAINMUX_LCDOGTOUCH 0x02000800
60#define BBTOYS_WIFI 0x01000B00
61#define BBTOYS_VGA 0x02000B00
62#define BBTOYS_LCD 0x03000B00
Peter Meerwald1aca7382012-01-03 04:14:35 +000063#define BCT_BRETTL3 0x01000F00
Peter Meerwaldad5691f2012-06-28 05:38:35 +000064#define BCT_BRETTL4 0x02000F00
robertcnelson@gmail.com346d7eb2013-02-04 06:03:30 +000065#define LSR_COM6L_ADPT 0x01001300
Koen Kooib6241c22010-09-20 10:21:33 -070066#define BEAGLE_NO_EEPROM 0xffffffff
67
John Rigby0d21ed02010-12-20 18:27:51 -070068DECLARE_GLOBAL_DATA_PTR;
69
Koen Kooib6241c22010-09-20 10:21:33 -070070static struct {
71 unsigned int device_vendor;
72 unsigned char revision;
73 unsigned char content;
74 char fab_revision[8];
75 char env_var[16];
76 char env_setting[64];
77} expansion_config;
78
Tom Rix558bb832009-04-01 22:02:20 -050079/*
Dirk Behme2781f802009-01-27 18:19:12 +010080 * Routine: board_init
81 * Description: Early hardware init.
Tom Rix558bb832009-04-01 22:02:20 -050082 */
Dirk Behme2781f802009-01-27 18:19:12 +010083int board_init(void)
84{
Dirk Behme2781f802009-01-27 18:19:12 +010085 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
86 /* board id for Linux */
87 gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
88 /* boot param addr */
89 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
90
Uri Mashiach4892d392017-01-19 10:51:45 +020091#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
92 status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON);
Jason Kridnerc3ef8bc2011-04-18 17:23:35 -040093#endif
94
Dirk Behme2781f802009-01-27 18:19:12 +010095 return 0;
96}
97
Derald D. Woods2b6b0892017-12-29 10:37:32 -060098#if defined(CONFIG_SPL_OS_BOOT)
99int spl_start_uboot(void)
100{
101 /* break into full u-boot on 'c' */
102 if (serial_tstc() && serial_getc() == 'c')
103 return 1;
104
105 return 0;
106}
107#endif /* CONFIG_SPL_OS_BOOT */
108
Tom Rix558bb832009-04-01 22:02:20 -0500109/*
Steve Sakoman3ca33762010-08-12 15:17:37 -0700110 * Routine: get_board_revision
111 * Description: Detect if we are running on a Beagle revision Ax/Bx,
Tom Rini4dfad752013-04-16 16:31:20 -0400112 * C1/2/3, C4, xM Ax/Bx or xM Cx. This can be done by reading
Steve Sakoman3ca33762010-08-12 15:17:37 -0700113 * the level of GPIO173, GPIO172 and GPIO171. This should
114 * result in
115 * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
116 * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
117 * GPIO173, GPIO172, GPIO171: 1 0 1 => C4
Tom Rini4dfad752013-04-16 16:31:20 -0400118 * GPIO173, GPIO172, GPIO171: 0 1 0 => xM Cx
119 * GPIO173, GPIO172, GPIO171: 0 0 0 => xM Ax/Bx
Tom Rix558bb832009-04-01 22:02:20 -0500120 */
Peter Meerwalda93ee5f2012-07-02 03:19:03 +0000121static int get_board_revision(void)
Dirk Behme78716112009-02-12 18:55:41 +0100122{
Simon Glassbc0f4ea2014-10-22 21:37:15 -0600123 static int revision = -1;
Dirk Behme78716112009-02-12 18:55:41 +0100124
Simon Glassbc0f4ea2014-10-22 21:37:15 -0600125 if (revision == -1) {
126 if (!gpio_request(171, "rev0") &&
127 !gpio_request(172, "rev1") &&
128 !gpio_request(173, "rev2")) {
129 gpio_direction_input(171);
130 gpio_direction_input(172);
131 gpio_direction_input(173);
Dirk Behme78716112009-02-12 18:55:41 +0100132
Simon Glassbc0f4ea2014-10-22 21:37:15 -0600133 revision = gpio_get_value(173) << 2 |
134 gpio_get_value(172) << 1 |
135 gpio_get_value(171);
136 } else {
137 printf("Error: unable to acquire board revision GPIOs\n");
138 }
Tom Rix70d05412009-06-03 01:53:57 -0500139 }
Dirk Behme78716112009-02-12 18:55:41 +0100140
Steve Sakoman3ca33762010-08-12 15:17:37 -0700141 return revision;
Dirk Behme78716112009-02-12 18:55:41 +0100142}
143
Tom Rini06c32fb2011-11-18 12:48:08 +0000144#ifdef CONFIG_SPL_BUILD
145/*
146 * Routine: get_board_mem_timings
147 * Description: If we use SPL then there is no x-loader nor config header
148 * so we have to setup the DDR timings ourself on both banks.
149 */
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000150void get_board_mem_timings(struct board_sdrc_timings *timings)
Tom Rini06c32fb2011-11-18 12:48:08 +0000151{
152 int pop_mfr, pop_id;
153
154 /*
155 * We need to identify what PoP memory is on the board so that
156 * we know what timings to use. If we can't identify it then
157 * we know it's an xM. To map the ID values please see nand_ids.c
158 */
159 identify_nand_chip(&pop_mfr, &pop_id);
160
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000161 timings->mr = MICRON_V_MR_165;
Tom Rini06c32fb2011-11-18 12:48:08 +0000162 switch (get_board_revision()) {
163 case REVISION_C4:
164 if (pop_mfr == NAND_MFR_STMICRO && pop_id == 0xba) {
165 /* 512MB DDR */
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000166 timings->mcfg = NUMONYX_V_MCFG_165(512 << 20);
167 timings->ctrla = NUMONYX_V_ACTIMA_165;
168 timings->ctrlb = NUMONYX_V_ACTIMB_165;
169 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
Tom Rini06c32fb2011-11-18 12:48:08 +0000170 break;
robertcnelson@gmail.com4b949bb2012-01-27 07:09:42 +0000171 } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xba) {
172 /* Beagleboard Rev C4, 512MB Nand/256MB DDR*/
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000173 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
174 timings->ctrla = MICRON_V_ACTIMA_165;
175 timings->ctrlb = MICRON_V_ACTIMB_165;
176 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
robertcnelson@gmail.com4b949bb2012-01-27 07:09:42 +0000177 break;
Tom Rini06c32fb2011-11-18 12:48:08 +0000178 } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xbc) {
179 /* Beagleboard Rev C5, 256MB DDR */
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000180 timings->mcfg = MICRON_V_MCFG_200(256 << 20);
181 timings->ctrla = MICRON_V_ACTIMA_200;
182 timings->ctrlb = MICRON_V_ACTIMB_200;
183 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
Tom Rini06c32fb2011-11-18 12:48:08 +0000184 break;
185 }
Nishanth Menon1d65fb32013-07-15 07:11:30 -0500186 case REVISION_XM_AB:
Tom Rini06c32fb2011-11-18 12:48:08 +0000187 case REVISION_XM_C:
188 if (pop_mfr == 0) {
189 /* 256MB DDR */
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000190 timings->mcfg = MICRON_V_MCFG_200(256 << 20);
191 timings->ctrla = MICRON_V_ACTIMA_200;
192 timings->ctrlb = MICRON_V_ACTIMB_200;
193 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
Tom Rini06c32fb2011-11-18 12:48:08 +0000194 } else {
195 /* 512MB DDR */
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000196 timings->mcfg = NUMONYX_V_MCFG_165(512 << 20);
197 timings->ctrla = NUMONYX_V_ACTIMA_165;
198 timings->ctrlb = NUMONYX_V_ACTIMB_165;
199 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
Tom Rini06c32fb2011-11-18 12:48:08 +0000200 }
201 break;
202 default:
203 /* Assume 128MB and Micron/165MHz timings to be safe */
Peter Baradaedb5c2f2012-11-13 07:40:28 +0000204 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
205 timings->ctrla = MICRON_V_ACTIMA_165;
206 timings->ctrlb = MICRON_V_ACTIMB_165;
207 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
Tom Rini06c32fb2011-11-18 12:48:08 +0000208 }
209}
210#endif
211
Tom Rix558bb832009-04-01 22:02:20 -0500212/*
Koen Kooib6241c22010-09-20 10:21:33 -0700213 * Routine: get_expansion_id
214 * Description: This function checks for expansion board by checking I2C
215 * bus 1 for the availability of an AT24C01B serial EEPROM.
216 * returns the device_vendor field from the EEPROM
217 */
Peter Meerwalda93ee5f2012-07-02 03:19:03 +0000218static unsigned int get_expansion_id(void)
Koen Kooib6241c22010-09-20 10:21:33 -0700219{
220 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
221
222 /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
223 if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
224 i2c_set_bus_num(TWL4030_I2C_BUS);
225 return BEAGLE_NO_EEPROM;
226 }
227
228 /* read configuration data */
229 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
230 sizeof(expansion_config));
231
robertcnelson@gmail.comaba0c9c2013-02-04 06:03:10 +0000232 /* retry reading configuration data with 16bit addressing */
233 if ((expansion_config.device_vendor == 0xFFFFFF00) ||
234 (expansion_config.device_vendor == 0xFFFFFFFF)) {
235 printf("EEPROM is blank or 8bit addressing failed: retrying with 16bit:\n");
236 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 2, (u8 *)&expansion_config,
237 sizeof(expansion_config));
238 }
239
Koen Kooib6241c22010-09-20 10:21:33 -0700240 i2c_set_bus_num(TWL4030_I2C_BUS);
241
242 return expansion_config.device_vendor;
243}
244
Peter Meerwalda2f54562012-07-10 06:07:34 +0000245#ifdef CONFIG_VIDEO_OMAP3
Koen Kooib6241c22010-09-20 10:21:33 -0700246/*
Jason Kridnerb8f6ac52011-04-19 14:01:13 -0500247 * Configure DSS to display background color on DVID
248 * Configure VENC to display color bar on S-Video
249 */
Peter Meerwalda93ee5f2012-07-02 03:19:03 +0000250static void beagle_display_init(void)
Jason Kridnerb8f6ac52011-04-19 14:01:13 -0500251{
252 omap3_dss_venc_config(&venc_config_std_tv, VENC_HEIGHT, VENC_WIDTH);
253 switch (get_board_revision()) {
254 case REVISION_AXBX:
255 case REVISION_CX:
256 case REVISION_C4:
257 omap3_dss_panel_config(&dvid_cfg);
258 break;
Nishanth Menon1d65fb32013-07-15 07:11:30 -0500259 case REVISION_XM_AB:
Jason Kridnerb8f6ac52011-04-19 14:01:13 -0500260 case REVISION_XM_C:
261 default:
262 omap3_dss_panel_config(&dvid_cfg_xm);
263 break;
264 }
265}
266
267/*
Peter Meerwald03ed0462012-02-08 05:24:26 +0000268 * Enable DVI power
269 */
Anatolij Gustschin359260b2012-03-27 23:05:07 +0000270static void beagle_dvi_pup(void)
271{
Peter Meerwald03ed0462012-02-08 05:24:26 +0000272 uchar val;
273
274 switch (get_board_revision()) {
275 case REVISION_AXBX:
276 case REVISION_CX:
277 case REVISION_C4:
Simon Glassbc0f4ea2014-10-22 21:37:15 -0600278 gpio_request(170, "dvi");
Peter Meerwald03ed0462012-02-08 05:24:26 +0000279 gpio_direction_output(170, 0);
280 gpio_set_value(170, 1);
281 break;
Nishanth Menon1d65fb32013-07-15 07:11:30 -0500282 case REVISION_XM_AB:
Peter Meerwald03ed0462012-02-08 05:24:26 +0000283 case REVISION_XM_C:
284 default:
285 #define GPIODATADIR1 (TWL4030_BASEADD_GPIO+3)
286 #define GPIODATAOUT1 (TWL4030_BASEADD_GPIO+6)
287
288 i2c_read(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
289 val |= 4;
290 i2c_write(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
291
292 i2c_read(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
293 val |= 4;
294 i2c_write(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
295 break;
296 }
297}
Peter Meerwalda2f54562012-07-10 06:07:34 +0000298#endif
Peter Meerwald03ed0462012-02-08 05:24:26 +0000299
Ilya Yanokcb7b2b82012-11-06 13:48:30 +0000300#ifdef CONFIG_USB_MUSB_OMAP2PLUS
301static struct musb_hdrc_config musb_config = {
302 .multipoint = 1,
303 .dyn_fifo = 1,
304 .num_eps = 16,
305 .ram_bits = 12,
306};
307
308static struct omap_musb_board_data musb_board_data = {
309 .interface_type = MUSB_INTERFACE_ULPI,
310};
311
312static struct musb_hdrc_platform_data musb_plat = {
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +0200313#if defined(CONFIG_USB_MUSB_HOST)
Ilya Yanokcb7b2b82012-11-06 13:48:30 +0000314 .mode = MUSB_HOST,
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +0200315#elif defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanokcb7b2b82012-11-06 13:48:30 +0000316 .mode = MUSB_PERIPHERAL,
317#else
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +0200318#error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET"
Ilya Yanokcb7b2b82012-11-06 13:48:30 +0000319#endif
320 .config = &musb_config,
321 .power = 100,
322 .platform_ops = &omap2430_ops,
323 .board_data = &musb_board_data,
324};
325#endif
326
Peter Meerwald03ed0462012-02-08 05:24:26 +0000327/*
Dirk Behme2781f802009-01-27 18:19:12 +0100328 * Routine: misc_init_r
329 * Description: Configure board specific parts
Tom Rix558bb832009-04-01 22:02:20 -0500330 */
Dirk Behme2781f802009-01-27 18:19:12 +0100331int misc_init_r(void)
332{
Dirk Behmedc7af202009-08-08 09:30:21 +0200333 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
334 struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
Jason Kridner40aebca2011-04-20 13:52:26 +0000335 struct control_prog_io *prog_io_base = (struct control_prog_io *)OMAP34XX_CTRL_BASE;
Nishanth Menon739b98f2014-03-28 11:00:06 -0500336 bool generate_fake_mac = false;
Alexander Kochetkov7822fe02014-09-29 21:46:48 +0400337 u32 value;
Steve Kipiszbf7438a2011-04-18 17:27:00 -0400338
339 /* Enable i2c2 pullup resisters */
Alexander Kochetkov7822fe02014-09-29 21:46:48 +0400340 value = readl(&prog_io_base->io1);
341 value &= ~(PRG_I2C2_PULLUPRESX);
342 writel(value, &prog_io_base->io1);
Dirk Behme2781f802009-01-27 18:19:12 +0100343
Steve Sakoman3ca33762010-08-12 15:17:37 -0700344 switch (get_board_revision()) {
345 case REVISION_AXBX:
346 printf("Beagle Rev Ax/Bx\n");
Simon Glass6a38e412017-08-03 12:22:09 -0600347 env_set("beaglerev", "AxBx");
Steve Sakoman3ca33762010-08-12 15:17:37 -0700348 break;
349 case REVISION_CX:
350 printf("Beagle Rev C1/C2/C3\n");
Simon Glass6a38e412017-08-03 12:22:09 -0600351 env_set("beaglerev", "Cx");
Steve Sakoman3ca33762010-08-12 15:17:37 -0700352 MUX_BEAGLE_C();
353 break;
354 case REVISION_C4:
355 printf("Beagle Rev C4\n");
Simon Glass6a38e412017-08-03 12:22:09 -0600356 env_set("beaglerev", "C4");
Steve Sakoman3ca33762010-08-12 15:17:37 -0700357 MUX_BEAGLE_C();
358 /* Set VAUX2 to 1.8V for EHCI PHY */
359 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
360 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
361 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
362 TWL4030_PM_RECEIVER_DEV_GRP_P1);
363 break;
Nishanth Menon1d65fb32013-07-15 07:11:30 -0500364 case REVISION_XM_AB:
365 printf("Beagle xM Rev A/B\n");
Simon Glass6a38e412017-08-03 12:22:09 -0600366 env_set("beaglerev", "xMAB");
Steve Sakomanac929952010-08-19 20:56:11 -0700367 MUX_BEAGLE_XM();
368 /* Set VAUX2 to 1.8V for EHCI PHY */
369 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
370 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
371 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
372 TWL4030_PM_RECEIVER_DEV_GRP_P1);
Nishanth Menon739b98f2014-03-28 11:00:06 -0500373 generate_fake_mac = true;
Steve Sakomanac929952010-08-19 20:56:11 -0700374 break;
Koen Kooi63308442011-06-17 09:37:37 +0200375 case REVISION_XM_C:
376 printf("Beagle xM Rev C\n");
Simon Glass6a38e412017-08-03 12:22:09 -0600377 env_set("beaglerev", "xMC");
Koen Kooi63308442011-06-17 09:37:37 +0200378 MUX_BEAGLE_XM();
379 /* Set VAUX2 to 1.8V for EHCI PHY */
380 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
381 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
382 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
383 TWL4030_PM_RECEIVER_DEV_GRP_P1);
Nishanth Menon739b98f2014-03-28 11:00:06 -0500384 generate_fake_mac = true;
Koen Kooi63308442011-06-17 09:37:37 +0200385 break;
Steve Sakoman3ca33762010-08-12 15:17:37 -0700386 default:
387 printf("Beagle unknown 0x%02x\n", get_board_revision());
Koen Kooi5b8018c2011-04-18 17:28:32 -0400388 MUX_BEAGLE_XM();
389 /* Set VAUX2 to 1.8V for EHCI PHY */
390 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
391 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
392 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
393 TWL4030_PM_RECEIVER_DEV_GRP_P1);
Nishanth Menon739b98f2014-03-28 11:00:06 -0500394 generate_fake_mac = true;
Steve Sakoman3ca33762010-08-12 15:17:37 -0700395 }
396
Koen Kooib6241c22010-09-20 10:21:33 -0700397 switch (get_expansion_id()) {
398 case TINCANTOOLS_ZIPPY:
399 printf("Recognized Tincantools Zippy board (rev %d %s)\n",
400 expansion_config.revision,
401 expansion_config.fab_revision);
402 MUX_TINCANTOOLS_ZIPPY();
Simon Glass6a38e412017-08-03 12:22:09 -0600403 env_set("buddy", "zippy");
Koen Kooib6241c22010-09-20 10:21:33 -0700404 break;
405 case TINCANTOOLS_ZIPPY2:
406 printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
407 expansion_config.revision,
408 expansion_config.fab_revision);
409 MUX_TINCANTOOLS_ZIPPY();
Simon Glass6a38e412017-08-03 12:22:09 -0600410 env_set("buddy", "zippy2");
Koen Kooib6241c22010-09-20 10:21:33 -0700411 break;
412 case TINCANTOOLS_TRAINER:
413 printf("Recognized Tincantools Trainer board (rev %d %s)\n",
414 expansion_config.revision,
415 expansion_config.fab_revision);
416 MUX_TINCANTOOLS_ZIPPY();
417 MUX_TINCANTOOLS_TRAINER();
Simon Glass6a38e412017-08-03 12:22:09 -0600418 env_set("buddy", "trainer");
Koen Kooib6241c22010-09-20 10:21:33 -0700419 break;
420 case TINCANTOOLS_SHOWDOG:
421 printf("Recognized Tincantools Showdow board (rev %d %s)\n",
422 expansion_config.revision,
423 expansion_config.fab_revision);
424 /* Place holder for DSS2 definition for showdog lcd */
Simon Glass6a38e412017-08-03 12:22:09 -0600425 env_set("defaultdisplay", "showdoglcd");
426 env_set("buddy", "showdog");
Koen Kooib6241c22010-09-20 10:21:33 -0700427 break;
428 case KBADC_BEAGLEFPGA:
429 printf("Recognized KBADC Beagle FPGA board\n");
430 MUX_KBADC_BEAGLEFPGA();
Simon Glass6a38e412017-08-03 12:22:09 -0600431 env_set("buddy", "beaglefpga");
Koen Kooib6241c22010-09-20 10:21:33 -0700432 break;
Koen Kooi3d5dac62011-04-18 17:29:35 -0400433 case LW_BEAGLETOUCH:
434 printf("Recognized Liquidware BeagleTouch board\n");
Simon Glass6a38e412017-08-03 12:22:09 -0600435 env_set("buddy", "beagletouch");
Koen Kooi3d5dac62011-04-18 17:29:35 -0400436 break;
437 case BRAINMUX_LCDOG:
438 printf("Recognized Brainmux LCDog board\n");
Simon Glass6a38e412017-08-03 12:22:09 -0600439 env_set("buddy", "lcdog");
Koen Kooi3d5dac62011-04-18 17:29:35 -0400440 break;
441 case BRAINMUX_LCDOGTOUCH:
442 printf("Recognized Brainmux LCDog Touch board\n");
Simon Glass6a38e412017-08-03 12:22:09 -0600443 env_set("buddy", "lcdogtouch");
Koen Kooi3d5dac62011-04-18 17:29:35 -0400444 break;
445 case BBTOYS_WIFI:
446 printf("Recognized BeagleBoardToys WiFi board\n");
447 MUX_BBTOYS_WIFI()
Simon Glass6a38e412017-08-03 12:22:09 -0600448 env_set("buddy", "bbtoys-wifi");
Masahiro Yamada622b7b32017-06-13 15:17:28 +0900449 break;
Koen Kooi3d5dac62011-04-18 17:29:35 -0400450 case BBTOYS_VGA:
451 printf("Recognized BeagleBoardToys VGA board\n");
Masahiro Yamada622b7b32017-06-13 15:17:28 +0900452 break;
Koen Kooi3d5dac62011-04-18 17:29:35 -0400453 case BBTOYS_LCD:
454 printf("Recognized BeagleBoardToys LCD board\n");
Masahiro Yamada622b7b32017-06-13 15:17:28 +0900455 break;
Peter Meerwald1aca7382012-01-03 04:14:35 +0000456 case BCT_BRETTL3:
Peter Meerwaldad5691f2012-06-28 05:38:35 +0000457 printf("Recognized bct electronic GmbH brettl3 board\n");
458 break;
459 case BCT_BRETTL4:
460 printf("Recognized bct electronic GmbH brettl4 board\n");
461 break;
robertcnelson@gmail.com346d7eb2013-02-04 06:03:30 +0000462 case LSR_COM6L_ADPT:
463 printf("Recognized LSR COM6L Adapter Board\n");
464 MUX_BBTOYS_WIFI()
Simon Glass6a38e412017-08-03 12:22:09 -0600465 env_set("buddy", "lsr-com6l-adpt");
robertcnelson@gmail.com346d7eb2013-02-04 06:03:30 +0000466 break;
Koen Kooib6241c22010-09-20 10:21:33 -0700467 case BEAGLE_NO_EEPROM:
468 printf("No EEPROM on expansion board\n");
Simon Glass6a38e412017-08-03 12:22:09 -0600469 env_set("buddy", "none");
Koen Kooib6241c22010-09-20 10:21:33 -0700470 break;
471 default:
472 printf("Unrecognized expansion board: %x\n",
473 expansion_config.device_vendor);
Simon Glass6a38e412017-08-03 12:22:09 -0600474 env_set("buddy", "unknown");
Koen Kooib6241c22010-09-20 10:21:33 -0700475 }
476
477 if (expansion_config.content == 1)
Simon Glass6a38e412017-08-03 12:22:09 -0600478 env_set(expansion_config.env_var, expansion_config.env_setting);
Koen Kooib6241c22010-09-20 10:21:33 -0700479
Tom Rix0f2a8042009-06-28 12:52:30 -0500480 twl4030_power_init();
Christian Spielberger3be83dc2011-08-24 17:17:31 -0500481 switch (get_board_revision()) {
Nishanth Menon1d65fb32013-07-15 07:11:30 -0500482 case REVISION_XM_AB:
Christian Spielberger3be83dc2011-08-24 17:17:31 -0500483 twl4030_led_init(TWL4030_LED_LEDEN_LEDBON);
484 break;
485 default:
486 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
487 break;
488 }
Dirk Behme2781f802009-01-27 18:19:12 +0100489
Bob Feretich0ad89512011-02-24 13:16:44 +0000490 /* Set GPIO states before they are made outputs */
Dirk Behme2781f802009-01-27 18:19:12 +0100491 writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
492 &gpio6_base->setdataout);
493 writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
494 GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
495
Bob Feretich0ad89512011-02-24 13:16:44 +0000496 /* Configure GPIOs to output */
497 writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
498 writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
499 GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
500
Paul Kocialkowski6bc318e2015-08-27 19:37:13 +0200501 omap_die_id_display();
Peter Meerwald03ed0462012-02-08 05:24:26 +0000502
Peter Meerwalda2f54562012-07-10 06:07:34 +0000503#ifdef CONFIG_VIDEO_OMAP3
Peter Meerwald03ed0462012-02-08 05:24:26 +0000504 beagle_dvi_pup();
Jason Kridnerb8f6ac52011-04-19 14:01:13 -0500505 beagle_display_init();
506 omap3_dss_enable();
Peter Meerwalda2f54562012-07-10 06:07:34 +0000507#endif
Dirk Behme12dbcf62009-03-12 19:30:50 +0100508
Ilya Yanokcb7b2b82012-11-06 13:48:30 +0000509#ifdef CONFIG_USB_MUSB_OMAP2PLUS
510 musb_register(&musb_plat, &musb_board_data, (void *)MUSB_BASE);
511#endif
512
Paul Kocialkowski2edadee2015-08-27 19:37:12 +0200513 if (generate_fake_mac)
514 omap_die_id_usbethaddr();
Nishanth Menon739b98f2014-03-28 11:00:06 -0500515
Derald D. Woodsbe010352018-02-26 17:52:57 -0600516#if defined(CONFIG_MTDIDS_DEFAULT) && defined(CONFIG_MTDPARTS_DEFAULT)
517 if (strlen(CONFIG_MTDIDS_DEFAULT))
518 env_set("mtdids", CONFIG_MTDIDS_DEFAULT);
519
520 if (strlen(CONFIG_MTDPARTS_DEFAULT))
521 env_set("mtdparts", CONFIG_MTDPARTS_DEFAULT);
522#endif
523
Dirk Behme2781f802009-01-27 18:19:12 +0100524 return 0;
525}
526
Tom Rix558bb832009-04-01 22:02:20 -0500527/*
Dirk Behme2781f802009-01-27 18:19:12 +0100528 * Routine: set_muxconf_regs
529 * Description: Setting up the configuration Mux registers specific to the
530 * hardware. Many pins need to be moved from protect to primary
531 * mode.
Tom Rix558bb832009-04-01 22:02:20 -0500532 */
Dirk Behme2781f802009-01-27 18:19:12 +0100533void set_muxconf_regs(void)
534{
535 MUX_BEAGLE();
Dirk Behme2781f802009-01-27 18:19:12 +0100536}
Steve Sakoman57c62412010-09-19 21:19:48 -0700537
Masahiro Yamada0a780172017-05-09 20:31:39 +0900538#if defined(CONFIG_MMC)
Steve Sakoman57c62412010-09-19 21:19:48 -0700539int board_mmc_init(bd_t *bis)
540{
Nikita Kiryanov4be9dbc2012-12-03 02:19:47 +0000541 return omap_mmc_init(0, 0, 0, -1, -1);
Steve Sakoman57c62412010-09-19 21:19:48 -0700542}
543#endif
Alexander Holler8f6f15c2011-04-19 09:30:35 -0400544
Masahiro Yamada0a780172017-05-09 20:31:39 +0900545#if defined(CONFIG_MMC)
Paul Kocialkowski69559892014-11-08 20:55:47 +0100546void board_mmc_power_init(void)
547{
548 twl4030_power_mmc_init(0);
549}
550#endif
551
Tom Riniceed5d22017-05-12 22:33:27 -0400552#if defined(CONFIG_USB_EHCI_HCD) && !defined(CONFIG_SPL_BUILD)
Alexander Holler8f6f15c2011-04-19 09:30:35 -0400553/* Call usb_stop() before starting the kernel */
554void show_boot_progress(int val)
555{
Simon Glass29395642011-12-10 11:07:54 +0000556 if (val == BOOTSTAGE_ID_RUN_OS)
Alexander Holler8f6f15c2011-04-19 09:30:35 -0400557 usb_stop();
558}
Govindraj.Redc16a02012-02-06 03:55:34 +0000559
560static struct omap_usbhs_board_data usbhs_bdata = {
561 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
562 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
563 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
564};
565
Troy Kisky7d6bbb92013-10-10 15:27:57 -0700566int ehci_hcd_init(int index, enum usb_init_type init,
567 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
Govindraj.Redc16a02012-02-06 03:55:34 +0000568{
Mateusz Zalegad862f892013-10-04 19:22:26 +0200569 return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
Govindraj.Redc16a02012-02-06 03:55:34 +0000570}
571
Lucas Stach3494a4c2012-09-26 00:14:35 +0200572int ehci_hcd_stop(int index)
Govindraj.Redc16a02012-02-06 03:55:34 +0000573{
574 return omap_ehci_hcd_stop();
575}
576
Tom Riniceed5d22017-05-12 22:33:27 -0400577#endif /* CONFIG_USB_EHCI_HCD */
Ilya Yanokcb7b2b82012-11-06 13:48:30 +0000578
Paul Kocialkowskif34dfcb2015-08-04 17:04:06 +0200579#if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanokcb7b2b82012-11-06 13:48:30 +0000580int board_eth_init(bd_t *bis)
581{
582 return usb_eth_initialize(bis);
583}
584#endif