blob: 0138fc91fcbe2ac71c0cba0b46a643d1d661a842 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Dirk Behmef904cdb2009-01-27 18:19:12 +01002/*
Tom Rini75c57a32011-11-18 12:48:08 +00003 * (C) Copyright 2004-2011
Dirk Behmef904cdb2009-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 Behmef904cdb2009-01-27 18:19:12 +010014 */
15#include <common.h>
Simon Glassb3f4ca12014-10-22 21:37:15 -060016#include <dm.h>
Simon Glass9fb625c2019-08-01 09:46:51 -060017#include <env.h>
Simon Glassb3f4ca12014-10-22 21:37:15 -060018#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
Tom Rix58911512009-04-01 22:02:20 -050075/*
Dirk Behmef904cdb2009-01-27 18:19:12 +010076 * Routine: board_init
77 * Description: Early hardware init.
Tom Rix58911512009-04-01 22:02:20 -050078 */
Dirk Behmef904cdb2009-01-27 18:19:12 +010079int board_init(void)
80{
Dirk Behmef904cdb2009-01-27 18:19:12 +010081 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
82 /* board id for Linux */
83 gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
84 /* boot param addr */
85 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
86
Uri Mashiach2d8d1902017-01-19 10:51:45 +020087#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
88 status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON);
Jason Kridner70d8c942011-04-18 17:23:35 -040089#endif
90
Dirk Behmef904cdb2009-01-27 18:19:12 +010091 return 0;
92}
93
Derald D. Woods4b379282017-12-29 10:37:32 -060094#if defined(CONFIG_SPL_OS_BOOT)
95int spl_start_uboot(void)
96{
97 /* break into full u-boot on 'c' */
98 if (serial_tstc() && serial_getc() == 'c')
99 return 1;
100
101 return 0;
102}
103#endif /* CONFIG_SPL_OS_BOOT */
104
Tom Rix58911512009-04-01 22:02:20 -0500105/*
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700106 * Routine: get_board_revision
107 * Description: Detect if we are running on a Beagle revision Ax/Bx,
Tom Rini8ce4e5f2013-04-16 16:31:20 -0400108 * C1/2/3, C4, xM Ax/Bx or xM Cx. This can be done by reading
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700109 * the level of GPIO173, GPIO172 and GPIO171. This should
110 * result in
111 * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
112 * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
113 * GPIO173, GPIO172, GPIO171: 1 0 1 => C4
Tom Rini8ce4e5f2013-04-16 16:31:20 -0400114 * GPIO173, GPIO172, GPIO171: 0 1 0 => xM Cx
115 * GPIO173, GPIO172, GPIO171: 0 0 0 => xM Ax/Bx
Tom Rix58911512009-04-01 22:02:20 -0500116 */
Peter Meerwaldfff1a572012-07-02 03:19:03 +0000117static int get_board_revision(void)
Dirk Behmef956fd02009-02-12 18:55:41 +0100118{
Simon Glassb3f4ca12014-10-22 21:37:15 -0600119 static int revision = -1;
Dirk Behmef956fd02009-02-12 18:55:41 +0100120
Simon Glassb3f4ca12014-10-22 21:37:15 -0600121 if (revision == -1) {
122 if (!gpio_request(171, "rev0") &&
123 !gpio_request(172, "rev1") &&
124 !gpio_request(173, "rev2")) {
125 gpio_direction_input(171);
126 gpio_direction_input(172);
127 gpio_direction_input(173);
Dirk Behmef956fd02009-02-12 18:55:41 +0100128
Simon Glassb3f4ca12014-10-22 21:37:15 -0600129 revision = gpio_get_value(173) << 2 |
130 gpio_get_value(172) << 1 |
131 gpio_get_value(171);
132 } else {
133 printf("Error: unable to acquire board revision GPIOs\n");
134 }
Tom Rix718763c2009-06-03 01:53:57 -0500135 }
Dirk Behmef956fd02009-02-12 18:55:41 +0100136
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700137 return revision;
Dirk Behmef956fd02009-02-12 18:55:41 +0100138}
139
Tom Rini75c57a32011-11-18 12:48:08 +0000140#ifdef CONFIG_SPL_BUILD
141/*
142 * Routine: get_board_mem_timings
143 * Description: If we use SPL then there is no x-loader nor config header
144 * so we have to setup the DDR timings ourself on both banks.
145 */
Peter Barada8c4445d2012-11-13 07:40:28 +0000146void get_board_mem_timings(struct board_sdrc_timings *timings)
Tom Rini75c57a32011-11-18 12:48:08 +0000147{
148 int pop_mfr, pop_id;
149
150 /*
151 * We need to identify what PoP memory is on the board so that
152 * we know what timings to use. If we can't identify it then
153 * we know it's an xM. To map the ID values please see nand_ids.c
154 */
155 identify_nand_chip(&pop_mfr, &pop_id);
156
Peter Barada8c4445d2012-11-13 07:40:28 +0000157 timings->mr = MICRON_V_MR_165;
Tom Rini75c57a32011-11-18 12:48:08 +0000158 switch (get_board_revision()) {
159 case REVISION_C4:
160 if (pop_mfr == NAND_MFR_STMICRO && pop_id == 0xba) {
161 /* 512MB DDR */
Peter Barada8c4445d2012-11-13 07:40:28 +0000162 timings->mcfg = NUMONYX_V_MCFG_165(512 << 20);
163 timings->ctrla = NUMONYX_V_ACTIMA_165;
164 timings->ctrlb = NUMONYX_V_ACTIMB_165;
165 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
Tom Rini75c57a32011-11-18 12:48:08 +0000166 break;
robertcnelson@gmail.com223b8aa2012-01-27 07:09:42 +0000167 } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xba) {
168 /* Beagleboard Rev C4, 512MB Nand/256MB DDR*/
Peter Barada8c4445d2012-11-13 07:40:28 +0000169 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
170 timings->ctrla = MICRON_V_ACTIMA_165;
171 timings->ctrlb = MICRON_V_ACTIMB_165;
172 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
robertcnelson@gmail.com223b8aa2012-01-27 07:09:42 +0000173 break;
Tom Rini75c57a32011-11-18 12:48:08 +0000174 } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xbc) {
175 /* Beagleboard Rev C5, 256MB DDR */
Peter Barada8c4445d2012-11-13 07:40:28 +0000176 timings->mcfg = MICRON_V_MCFG_200(256 << 20);
177 timings->ctrla = MICRON_V_ACTIMA_200;
178 timings->ctrlb = MICRON_V_ACTIMB_200;
179 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
Tom Rini75c57a32011-11-18 12:48:08 +0000180 break;
181 }
Nishanth Menonaf4d8962013-07-15 07:11:30 -0500182 case REVISION_XM_AB:
Tom Rini75c57a32011-11-18 12:48:08 +0000183 case REVISION_XM_C:
184 if (pop_mfr == 0) {
185 /* 256MB DDR */
Peter Barada8c4445d2012-11-13 07:40:28 +0000186 timings->mcfg = MICRON_V_MCFG_200(256 << 20);
187 timings->ctrla = MICRON_V_ACTIMA_200;
188 timings->ctrlb = MICRON_V_ACTIMB_200;
189 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
Tom Rini75c57a32011-11-18 12:48:08 +0000190 } else {
191 /* 512MB DDR */
Peter Barada8c4445d2012-11-13 07:40:28 +0000192 timings->mcfg = NUMONYX_V_MCFG_165(512 << 20);
193 timings->ctrla = NUMONYX_V_ACTIMA_165;
194 timings->ctrlb = NUMONYX_V_ACTIMB_165;
195 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
Tom Rini75c57a32011-11-18 12:48:08 +0000196 }
197 break;
198 default:
199 /* Assume 128MB and Micron/165MHz timings to be safe */
Peter Barada8c4445d2012-11-13 07:40:28 +0000200 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
201 timings->ctrla = MICRON_V_ACTIMA_165;
202 timings->ctrlb = MICRON_V_ACTIMB_165;
203 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
Tom Rini75c57a32011-11-18 12:48:08 +0000204 }
205}
206#endif
207
Tom Rix58911512009-04-01 22:02:20 -0500208/*
Koen Kooica5f80a2010-09-20 10:21:33 -0700209 * Routine: get_expansion_id
210 * Description: This function checks for expansion board by checking I2C
211 * bus 1 for the availability of an AT24C01B serial EEPROM.
212 * returns the device_vendor field from the EEPROM
213 */
Peter Meerwaldfff1a572012-07-02 03:19:03 +0000214static unsigned int get_expansion_id(void)
Koen Kooica5f80a2010-09-20 10:21:33 -0700215{
216 i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
217
218 /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
219 if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
220 i2c_set_bus_num(TWL4030_I2C_BUS);
221 return BEAGLE_NO_EEPROM;
222 }
223
224 /* read configuration data */
225 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
226 sizeof(expansion_config));
227
robertcnelson@gmail.comff229ec2013-02-04 06:03:10 +0000228 /* retry reading configuration data with 16bit addressing */
229 if ((expansion_config.device_vendor == 0xFFFFFF00) ||
230 (expansion_config.device_vendor == 0xFFFFFFFF)) {
231 printf("EEPROM is blank or 8bit addressing failed: retrying with 16bit:\n");
232 i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 2, (u8 *)&expansion_config,
233 sizeof(expansion_config));
234 }
235
Koen Kooica5f80a2010-09-20 10:21:33 -0700236 i2c_set_bus_num(TWL4030_I2C_BUS);
237
238 return expansion_config.device_vendor;
239}
240
Peter Meerwald2c30c182012-07-10 06:07:34 +0000241#ifdef CONFIG_VIDEO_OMAP3
Koen Kooica5f80a2010-09-20 10:21:33 -0700242/*
Jason Kridner3f16ab92011-04-19 14:01:13 -0500243 * Configure DSS to display background color on DVID
244 * Configure VENC to display color bar on S-Video
245 */
Peter Meerwaldfff1a572012-07-02 03:19:03 +0000246static void beagle_display_init(void)
Jason Kridner3f16ab92011-04-19 14:01:13 -0500247{
248 omap3_dss_venc_config(&venc_config_std_tv, VENC_HEIGHT, VENC_WIDTH);
249 switch (get_board_revision()) {
250 case REVISION_AXBX:
251 case REVISION_CX:
252 case REVISION_C4:
253 omap3_dss_panel_config(&dvid_cfg);
254 break;
Nishanth Menonaf4d8962013-07-15 07:11:30 -0500255 case REVISION_XM_AB:
Jason Kridner3f16ab92011-04-19 14:01:13 -0500256 case REVISION_XM_C:
257 default:
258 omap3_dss_panel_config(&dvid_cfg_xm);
259 break;
260 }
261}
262
263/*
Peter Meerwald4258aa62012-02-08 05:24:26 +0000264 * Enable DVI power
265 */
Anatolij Gustschin3fbc6932012-03-27 23:05:07 +0000266static void beagle_dvi_pup(void)
267{
Peter Meerwald4258aa62012-02-08 05:24:26 +0000268 uchar val;
269
270 switch (get_board_revision()) {
271 case REVISION_AXBX:
272 case REVISION_CX:
273 case REVISION_C4:
Simon Glassb3f4ca12014-10-22 21:37:15 -0600274 gpio_request(170, "dvi");
Peter Meerwald4258aa62012-02-08 05:24:26 +0000275 gpio_direction_output(170, 0);
276 gpio_set_value(170, 1);
277 break;
Nishanth Menonaf4d8962013-07-15 07:11:30 -0500278 case REVISION_XM_AB:
Peter Meerwald4258aa62012-02-08 05:24:26 +0000279 case REVISION_XM_C:
280 default:
281 #define GPIODATADIR1 (TWL4030_BASEADD_GPIO+3)
282 #define GPIODATAOUT1 (TWL4030_BASEADD_GPIO+6)
283
284 i2c_read(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
285 val |= 4;
286 i2c_write(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1);
287
288 i2c_read(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
289 val |= 4;
290 i2c_write(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1);
291 break;
292 }
293}
Peter Meerwald2c30c182012-07-10 06:07:34 +0000294#endif
Peter Meerwald4258aa62012-02-08 05:24:26 +0000295
Ilya Yanokc642b152012-11-06 13:48:30 +0000296#ifdef CONFIG_USB_MUSB_OMAP2PLUS
297static struct musb_hdrc_config musb_config = {
298 .multipoint = 1,
299 .dyn_fifo = 1,
300 .num_eps = 16,
301 .ram_bits = 12,
302};
303
304static struct omap_musb_board_data musb_board_data = {
305 .interface_type = MUSB_INTERFACE_ULPI,
306};
307
308static struct musb_hdrc_platform_data musb_plat = {
Paul Kocialkowski95de1e22015-08-04 17:04:06 +0200309#if defined(CONFIG_USB_MUSB_HOST)
Ilya Yanokc642b152012-11-06 13:48:30 +0000310 .mode = MUSB_HOST,
Paul Kocialkowski95de1e22015-08-04 17:04:06 +0200311#elif defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanokc642b152012-11-06 13:48:30 +0000312 .mode = MUSB_PERIPHERAL,
313#else
Paul Kocialkowski95de1e22015-08-04 17:04:06 +0200314#error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET"
Ilya Yanokc642b152012-11-06 13:48:30 +0000315#endif
316 .config = &musb_config,
317 .power = 100,
318 .platform_ops = &omap2430_ops,
319 .board_data = &musb_board_data,
320};
321#endif
322
Peter Meerwald4258aa62012-02-08 05:24:26 +0000323/*
Dirk Behmef904cdb2009-01-27 18:19:12 +0100324 * Routine: misc_init_r
325 * Description: Configure board specific parts
Tom Rix58911512009-04-01 22:02:20 -0500326 */
Dirk Behmef904cdb2009-01-27 18:19:12 +0100327int misc_init_r(void)
328{
Dirk Behme97a099e2009-08-08 09:30:21 +0200329 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
330 struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
Jason Kridnerf14a5222011-04-20 13:52:26 +0000331 struct control_prog_io *prog_io_base = (struct control_prog_io *)OMAP34XX_CTRL_BASE;
Nishanth Menon548a64d2014-03-28 11:00:06 -0500332 bool generate_fake_mac = false;
Alexander Kochetkov04e2a132014-09-29 21:46:48 +0400333 u32 value;
Steve Kipiszd4e53f02011-04-18 17:27:00 -0400334
335 /* Enable i2c2 pullup resisters */
Alexander Kochetkov04e2a132014-09-29 21:46:48 +0400336 value = readl(&prog_io_base->io1);
337 value &= ~(PRG_I2C2_PULLUPRESX);
338 writel(value, &prog_io_base->io1);
Dirk Behmef904cdb2009-01-27 18:19:12 +0100339
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700340 switch (get_board_revision()) {
341 case REVISION_AXBX:
342 printf("Beagle Rev Ax/Bx\n");
Simon Glass382bee52017-08-03 12:22:09 -0600343 env_set("beaglerev", "AxBx");
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700344 break;
345 case REVISION_CX:
346 printf("Beagle Rev C1/C2/C3\n");
Simon Glass382bee52017-08-03 12:22:09 -0600347 env_set("beaglerev", "Cx");
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700348 MUX_BEAGLE_C();
349 break;
350 case REVISION_C4:
351 printf("Beagle Rev C4\n");
Simon Glass382bee52017-08-03 12:22:09 -0600352 env_set("beaglerev", "C4");
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700353 MUX_BEAGLE_C();
354 /* Set VAUX2 to 1.8V for EHCI PHY */
355 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
356 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
357 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
358 TWL4030_PM_RECEIVER_DEV_GRP_P1);
359 break;
Nishanth Menonaf4d8962013-07-15 07:11:30 -0500360 case REVISION_XM_AB:
361 printf("Beagle xM Rev A/B\n");
Simon Glass382bee52017-08-03 12:22:09 -0600362 env_set("beaglerev", "xMAB");
Steve Sakoman08cbba2ab2010-08-19 20:56:11 -0700363 MUX_BEAGLE_XM();
364 /* Set VAUX2 to 1.8V for EHCI PHY */
365 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
366 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
367 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
368 TWL4030_PM_RECEIVER_DEV_GRP_P1);
Nishanth Menon548a64d2014-03-28 11:00:06 -0500369 generate_fake_mac = true;
Steve Sakoman08cbba2ab2010-08-19 20:56:11 -0700370 break;
Koen Kooi1ffcb342011-06-17 09:37:37 +0200371 case REVISION_XM_C:
372 printf("Beagle xM Rev C\n");
Simon Glass382bee52017-08-03 12:22:09 -0600373 env_set("beaglerev", "xMC");
Koen Kooi1ffcb342011-06-17 09:37:37 +0200374 MUX_BEAGLE_XM();
375 /* Set VAUX2 to 1.8V for EHCI PHY */
376 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
377 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
378 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
379 TWL4030_PM_RECEIVER_DEV_GRP_P1);
Nishanth Menon548a64d2014-03-28 11:00:06 -0500380 generate_fake_mac = true;
Koen Kooi1ffcb342011-06-17 09:37:37 +0200381 break;
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700382 default:
383 printf("Beagle unknown 0x%02x\n", get_board_revision());
Koen Kooif6e593b2011-04-18 17:28:32 -0400384 MUX_BEAGLE_XM();
385 /* Set VAUX2 to 1.8V for EHCI PHY */
386 twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
387 TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
388 TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
389 TWL4030_PM_RECEIVER_DEV_GRP_P1);
Nishanth Menon548a64d2014-03-28 11:00:06 -0500390 generate_fake_mac = true;
Steve Sakoman06b95bd2010-08-12 15:17:37 -0700391 }
392
Koen Kooica5f80a2010-09-20 10:21:33 -0700393 switch (get_expansion_id()) {
394 case TINCANTOOLS_ZIPPY:
395 printf("Recognized Tincantools Zippy board (rev %d %s)\n",
396 expansion_config.revision,
397 expansion_config.fab_revision);
398 MUX_TINCANTOOLS_ZIPPY();
Simon Glass382bee52017-08-03 12:22:09 -0600399 env_set("buddy", "zippy");
Koen Kooica5f80a2010-09-20 10:21:33 -0700400 break;
401 case TINCANTOOLS_ZIPPY2:
402 printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
403 expansion_config.revision,
404 expansion_config.fab_revision);
405 MUX_TINCANTOOLS_ZIPPY();
Simon Glass382bee52017-08-03 12:22:09 -0600406 env_set("buddy", "zippy2");
Koen Kooica5f80a2010-09-20 10:21:33 -0700407 break;
408 case TINCANTOOLS_TRAINER:
409 printf("Recognized Tincantools Trainer board (rev %d %s)\n",
410 expansion_config.revision,
411 expansion_config.fab_revision);
412 MUX_TINCANTOOLS_ZIPPY();
413 MUX_TINCANTOOLS_TRAINER();
Simon Glass382bee52017-08-03 12:22:09 -0600414 env_set("buddy", "trainer");
Koen Kooica5f80a2010-09-20 10:21:33 -0700415 break;
416 case TINCANTOOLS_SHOWDOG:
417 printf("Recognized Tincantools Showdow board (rev %d %s)\n",
418 expansion_config.revision,
419 expansion_config.fab_revision);
420 /* Place holder for DSS2 definition for showdog lcd */
Simon Glass382bee52017-08-03 12:22:09 -0600421 env_set("defaultdisplay", "showdoglcd");
422 env_set("buddy", "showdog");
Koen Kooica5f80a2010-09-20 10:21:33 -0700423 break;
424 case KBADC_BEAGLEFPGA:
425 printf("Recognized KBADC Beagle FPGA board\n");
426 MUX_KBADC_BEAGLEFPGA();
Simon Glass382bee52017-08-03 12:22:09 -0600427 env_set("buddy", "beaglefpga");
Koen Kooica5f80a2010-09-20 10:21:33 -0700428 break;
Koen Kooiee8485f2011-04-18 17:29:35 -0400429 case LW_BEAGLETOUCH:
430 printf("Recognized Liquidware BeagleTouch board\n");
Simon Glass382bee52017-08-03 12:22:09 -0600431 env_set("buddy", "beagletouch");
Koen Kooiee8485f2011-04-18 17:29:35 -0400432 break;
433 case BRAINMUX_LCDOG:
434 printf("Recognized Brainmux LCDog board\n");
Simon Glass382bee52017-08-03 12:22:09 -0600435 env_set("buddy", "lcdog");
Koen Kooiee8485f2011-04-18 17:29:35 -0400436 break;
437 case BRAINMUX_LCDOGTOUCH:
438 printf("Recognized Brainmux LCDog Touch board\n");
Simon Glass382bee52017-08-03 12:22:09 -0600439 env_set("buddy", "lcdogtouch");
Koen Kooiee8485f2011-04-18 17:29:35 -0400440 break;
441 case BBTOYS_WIFI:
442 printf("Recognized BeagleBoardToys WiFi board\n");
443 MUX_BBTOYS_WIFI()
Simon Glass382bee52017-08-03 12:22:09 -0600444 env_set("buddy", "bbtoys-wifi");
Masahiro Yamada51855e82017-06-13 15:17:28 +0900445 break;
Koen Kooiee8485f2011-04-18 17:29:35 -0400446 case BBTOYS_VGA:
447 printf("Recognized BeagleBoardToys VGA board\n");
Masahiro Yamada51855e82017-06-13 15:17:28 +0900448 break;
Koen Kooiee8485f2011-04-18 17:29:35 -0400449 case BBTOYS_LCD:
450 printf("Recognized BeagleBoardToys LCD board\n");
Masahiro Yamada51855e82017-06-13 15:17:28 +0900451 break;
Peter Meerwald6cce5502012-01-03 04:14:35 +0000452 case BCT_BRETTL3:
Peter Meerwaldef88e602012-06-28 05:38:35 +0000453 printf("Recognized bct electronic GmbH brettl3 board\n");
454 break;
455 case BCT_BRETTL4:
456 printf("Recognized bct electronic GmbH brettl4 board\n");
457 break;
robertcnelson@gmail.com8a1f2dc2013-02-04 06:03:30 +0000458 case LSR_COM6L_ADPT:
459 printf("Recognized LSR COM6L Adapter Board\n");
460 MUX_BBTOYS_WIFI()
Simon Glass382bee52017-08-03 12:22:09 -0600461 env_set("buddy", "lsr-com6l-adpt");
robertcnelson@gmail.com8a1f2dc2013-02-04 06:03:30 +0000462 break;
Koen Kooica5f80a2010-09-20 10:21:33 -0700463 case BEAGLE_NO_EEPROM:
464 printf("No EEPROM on expansion board\n");
Simon Glass382bee52017-08-03 12:22:09 -0600465 env_set("buddy", "none");
Koen Kooica5f80a2010-09-20 10:21:33 -0700466 break;
467 default:
468 printf("Unrecognized expansion board: %x\n",
469 expansion_config.device_vendor);
Simon Glass382bee52017-08-03 12:22:09 -0600470 env_set("buddy", "unknown");
Koen Kooica5f80a2010-09-20 10:21:33 -0700471 }
472
473 if (expansion_config.content == 1)
Simon Glass382bee52017-08-03 12:22:09 -0600474 env_set(expansion_config.env_var, expansion_config.env_setting);
Koen Kooica5f80a2010-09-20 10:21:33 -0700475
Tom Rix2c155132009-06-28 12:52:30 -0500476 twl4030_power_init();
Christian Spielberger38a77c32011-08-24 17:17:31 -0500477 switch (get_board_revision()) {
Nishanth Menonaf4d8962013-07-15 07:11:30 -0500478 case REVISION_XM_AB:
Christian Spielberger38a77c32011-08-24 17:17:31 -0500479 twl4030_led_init(TWL4030_LED_LEDEN_LEDBON);
480 break;
481 default:
482 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
483 break;
484 }
Dirk Behmef904cdb2009-01-27 18:19:12 +0100485
Bob Feretich52d82e42011-02-24 13:16:44 +0000486 /* Set GPIO states before they are made outputs */
Dirk Behmef904cdb2009-01-27 18:19:12 +0100487 writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
488 &gpio6_base->setdataout);
489 writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
490 GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
491
Bob Feretich52d82e42011-02-24 13:16:44 +0000492 /* Configure GPIOs to output */
493 writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
494 writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
495 GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
496
Paul Kocialkowski679f82c2015-08-27 19:37:13 +0200497 omap_die_id_display();
Peter Meerwald4258aa62012-02-08 05:24:26 +0000498
Peter Meerwald2c30c182012-07-10 06:07:34 +0000499#ifdef CONFIG_VIDEO_OMAP3
Peter Meerwald4258aa62012-02-08 05:24:26 +0000500 beagle_dvi_pup();
Jason Kridner3f16ab92011-04-19 14:01:13 -0500501 beagle_display_init();
502 omap3_dss_enable();
Peter Meerwald2c30c182012-07-10 06:07:34 +0000503#endif
Dirk Behmee6a6a702009-03-12 19:30:50 +0100504
Ilya Yanokc642b152012-11-06 13:48:30 +0000505#ifdef CONFIG_USB_MUSB_OMAP2PLUS
506 musb_register(&musb_plat, &musb_board_data, (void *)MUSB_BASE);
507#endif
508
Paul Kocialkowski07815eb2015-08-27 19:37:12 +0200509 if (generate_fake_mac)
510 omap_die_id_usbethaddr();
Nishanth Menon548a64d2014-03-28 11:00:06 -0500511
Derald D. Woodsebf6e262018-02-26 17:52:57 -0600512#if defined(CONFIG_MTDIDS_DEFAULT) && defined(CONFIG_MTDPARTS_DEFAULT)
513 if (strlen(CONFIG_MTDIDS_DEFAULT))
514 env_set("mtdids", CONFIG_MTDIDS_DEFAULT);
515
516 if (strlen(CONFIG_MTDPARTS_DEFAULT))
517 env_set("mtdparts", CONFIG_MTDPARTS_DEFAULT);
518#endif
519
Dirk Behmef904cdb2009-01-27 18:19:12 +0100520 return 0;
521}
522
Tom Rix58911512009-04-01 22:02:20 -0500523/*
Dirk Behmef904cdb2009-01-27 18:19:12 +0100524 * Routine: set_muxconf_regs
525 * Description: Setting up the configuration Mux registers specific to the
526 * hardware. Many pins need to be moved from protect to primary
527 * mode.
Tom Rix58911512009-04-01 22:02:20 -0500528 */
Dirk Behmef904cdb2009-01-27 18:19:12 +0100529void set_muxconf_regs(void)
530{
531 MUX_BEAGLE();
Dirk Behmef904cdb2009-01-27 18:19:12 +0100532}
Steve Sakoman0cd31142010-09-19 21:19:48 -0700533
Masahiro Yamada4aa2ba32017-05-09 20:31:39 +0900534#if defined(CONFIG_MMC)
Steve Sakoman0cd31142010-09-19 21:19:48 -0700535int board_mmc_init(bd_t *bis)
536{
Nikita Kiryanove3913f52012-12-03 02:19:47 +0000537 return omap_mmc_init(0, 0, 0, -1, -1);
Steve Sakoman0cd31142010-09-19 21:19:48 -0700538}
539#endif
Alexander Hollerd90859a2011-04-19 09:30:35 -0400540
Masahiro Yamada4aa2ba32017-05-09 20:31:39 +0900541#if defined(CONFIG_MMC)
Paul Kocialkowskiaac54502014-11-08 20:55:47 +0100542void board_mmc_power_init(void)
543{
544 twl4030_power_mmc_init(0);
545}
546#endif
547
Tom Rini8850c5d2017-05-12 22:33:27 -0400548#if defined(CONFIG_USB_EHCI_HCD) && !defined(CONFIG_SPL_BUILD)
Alexander Hollerd90859a2011-04-19 09:30:35 -0400549/* Call usb_stop() before starting the kernel */
550void show_boot_progress(int val)
551{
Simon Glass578ac1e2011-12-10 11:07:54 +0000552 if (val == BOOTSTAGE_ID_RUN_OS)
Alexander Hollerd90859a2011-04-19 09:30:35 -0400553 usb_stop();
554}
Govindraj.R43b62392012-02-06 03:55:34 +0000555
556static struct omap_usbhs_board_data usbhs_bdata = {
557 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
558 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
559 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
560};
561
Troy Kisky127efc42013-10-10 15:27:57 -0700562int ehci_hcd_init(int index, enum usb_init_type init,
563 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
Govindraj.R43b62392012-02-06 03:55:34 +0000564{
Mateusz Zalega16297cf2013-10-04 19:22:26 +0200565 return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
Govindraj.R43b62392012-02-06 03:55:34 +0000566}
567
Lucas Stach676ae062012-09-26 00:14:35 +0200568int ehci_hcd_stop(int index)
Govindraj.R43b62392012-02-06 03:55:34 +0000569{
570 return omap_ehci_hcd_stop();
571}
572
Tom Rini8850c5d2017-05-12 22:33:27 -0400573#endif /* CONFIG_USB_EHCI_HCD */
Ilya Yanokc642b152012-11-06 13:48:30 +0000574
Paul Kocialkowski95de1e22015-08-04 17:04:06 +0200575#if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET)
Ilya Yanokc642b152012-11-06 13:48:30 +0000576int board_eth_init(bd_t *bis)
577{
578 return usb_eth_initialize(bis);
579}
580#endif