aboutsummaryrefslogtreecommitdiffstats
path: root/roms/u-boot/board/lego/ev3
diff options
context:
space:
mode:
authorAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
committerAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
commitaf1a266670d040d2f4083ff309d732d648afba2a (patch)
tree2fc46203448ddcc6f81546d379abfaeb323575e9 /roms/u-boot/board/lego/ev3
parente02cda008591317b1625707ff8e115a4841aa889 (diff)
Add submodule dependency filesHEADmaster
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'roms/u-boot/board/lego/ev3')
-rw-r--r--roms/u-boot/board/lego/ev3/Kconfig12
-rw-r--r--roms/u-boot/board/lego/ev3/MAINTAINERS6
-rw-r--r--roms/u-boot/board/lego/ev3/Makefile8
-rw-r--r--roms/u-boot/board/lego/ev3/README55
-rw-r--r--roms/u-boot/board/lego/ev3/legoev3.c142
5 files changed, 223 insertions, 0 deletions
diff --git a/roms/u-boot/board/lego/ev3/Kconfig b/roms/u-boot/board/lego/ev3/Kconfig
new file mode 100644
index 000000000..14b3f0c1c
--- /dev/null
+++ b/roms/u-boot/board/lego/ev3/Kconfig
@@ -0,0 +1,12 @@
+if TARGET_LEGOEV3
+
+config SYS_BOARD
+ default "ev3"
+
+config SYS_VENDOR
+ default "lego"
+
+config SYS_CONFIG_NAME
+ default "legoev3"
+
+endif
diff --git a/roms/u-boot/board/lego/ev3/MAINTAINERS b/roms/u-boot/board/lego/ev3/MAINTAINERS
new file mode 100644
index 000000000..11b326160
--- /dev/null
+++ b/roms/u-boot/board/lego/ev3/MAINTAINERS
@@ -0,0 +1,6 @@
+LEGOEV3 BOARD
+M: David Lechner <david@lechnology.com>
+S: Maintained
+F: board/lego/ev3/
+F: include/configs/legoev3.h
+F: configs/legoev3_defconfig
diff --git a/roms/u-boot/board/lego/ev3/Makefile b/roms/u-boot/board/lego/ev3/Makefile
new file mode 100644
index 000000000..11b52ca1d
--- /dev/null
+++ b/roms/u-boot/board/lego/ev3/Makefile
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2000, 2001, 2002
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
+
+obj-y += legoev3.o
diff --git a/roms/u-boot/board/lego/ev3/README b/roms/u-boot/board/lego/ev3/README
new file mode 100644
index 000000000..9ad93e820
--- /dev/null
+++ b/roms/u-boot/board/lego/ev3/README
@@ -0,0 +1,55 @@
+Summary
+=======
+
+LEGO MINDSTORMS EV3 is a toy robot produced by the LEGO Group. It is based
+on the davinci da850 evm. The EV3 has a 16MB spi flash and a SDHC microSD card
+reader.
+
+Booting
+=======
+
+The EV3 contains a bootloader in EEPROM that loads u-boot.bin from address 0x0
+of the SPI flash memory (with a size of 256KiB!). Because the EEPROM is read-
+only and it takes care of low level configuration (PLL and DDR), we don't use
+U-Boot to produce an SPL image.
+
+Using the default configuration, U-Boot had a boot scrips that works as follows:
+
+* Check to see if microSD card is present
+* If it is, try to load boot.scr from the first FAT partition
+* If loading boot.scr was successful, run it
+* Otherwise, try loading uEnv.txt
+* If loading uEnv.txt was successful, import it
+* If there is a uenvcmd variable (from uEnv.txt), run it
+* Try to load uImage from the first FAT partition
+* If it was successful, try to load da850-lego-ev3.dtb
+* If loading uImage was successful, boot it (DT is optional)
+* If none of the above was successful, try booting from flash
+
+Suggested Flash Memory Layout
+=============================
+
+The following is based on the default U-Boot configuration:
+
+| Image (file) | Start Addr. | Max. Size |
++--------------------+-------------+-------------------+
+| u-boot.bin | 0x0 | 0x40000 (256KiB) |
+| da850-lego-ev3.dtb | 0x40000 | 0x10000 (64KiB) |
+| uImage | 0x50000 | 0x400000 (4MiB) |
+| rootfs (squashfs) | 0x450000 | 0xa00000 (10MiB) |
+
+Writing image to flash
+======================
+
+The EEPROM contains a program for uploading an image file to the flash memory.
+The program is started by holding down the right button on the EV3 when powering
+it on. You can also `run fwupdateboot` in the u-boot shell to reboot into this
+mode. The image can then be uploaded using the official LEGO MINDSTORMS EV3
+software or a 3rd party program capable of uploading a firmware file.
+
+If you are booting from the microSD card, it is enough to just write uboot.bin
+to the flash. If you are not using a microSD card, you will need to create an
+image file using the layout described above.
+
+IMPORTANT: The EEPROM bootloader only copies 256k, so u-boot.img must not
+exceed that size!
diff --git a/roms/u-boot/board/lego/ev3/legoev3.c b/roms/u-boot/board/lego/ev3/legoev3.c
new file mode 100644
index 000000000..980ffef4c
--- /dev/null
+++ b/roms/u-boot/board/lego/ev3/legoev3.c
@@ -0,0 +1,142 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2016 David Lechner <david@lechnology.com>
+ *
+ * Based on da850evm.c
+ *
+ * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Based on da830evm.c. Original Copyrights follow:
+ *
+ * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <nick.thompson@gefanuc.com>
+ * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
+ */
+
+#include <common.h>
+#include <env.h>
+#include <i2c.h>
+#include <init.h>
+#include <spi.h>
+#include <spi_flash.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/pinmux_defs.h>
+#include <asm/global_data.h>
+#include <asm/io.h>
+#include <asm/arch/davinci_misc.h>
+#include <linux/errno.h>
+#include <hwconfig.h>
+#include <asm/mach-types.h>
+#include <asm/setup.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define EEPROM_I2C_ADDR 0x50
+#define EEPROM_REV_OFFSET 0x3F00
+#define EEPROM_BDADDR_OFFSET 0x3F06
+
+const struct pinmux_resource pinmuxes[] = {
+ PINMUX_ITEM(spi0_pins_base),
+ PINMUX_ITEM(spi0_pins_scs0),
+ PINMUX_ITEM(uart1_pins_txrx),
+ PINMUX_ITEM(i2c0_pins),
+ PINMUX_ITEM(mmc0_pins),
+};
+
+const int pinmuxes_size = ARRAY_SIZE(pinmuxes);
+
+const struct lpsc_resource lpsc[] = {
+ { DAVINCI_LPSC_SPI0 }, /* Serial Flash */
+ { DAVINCI_LPSC_UART1 }, /* console */
+ { DAVINCI_LPSC_MMC_SD },
+};
+
+const int lpsc_size = ARRAY_SIZE(lpsc);
+
+/*
+ * The Bluetooth address serves as the board serial number.
+ */
+static void setup_serial_number(void)
+{
+ u32 offset;
+ char serial_number[13];
+ u8 buf[6];
+ u8 eeprom_rev;
+
+ if (env_get("serial#"))
+ return;
+
+ if (i2c_read(EEPROM_I2C_ADDR, EEPROM_REV_OFFSET, 2, buf, 2)) {
+ printf("\nEEPROM revision read failed!\n");
+ return;
+ }
+
+ /*
+ * EEPROM rev 3 has Bluetooth address at EEPROM_REV_OFFSET.
+ * Other revisions have checksum at EEPROM_REV_OFFSET+1
+ * to detect this.
+ */
+ if ((buf[0] ^ buf[1]) == 0xFF)
+ eeprom_rev = buf[0];
+ else
+ eeprom_rev = 3;
+
+ /* EEPROM rev 3 has Bluetooth address where rev should be */
+ offset = (eeprom_rev == 3) ? EEPROM_REV_OFFSET : EEPROM_BDADDR_OFFSET;
+
+ if (i2c_read(EEPROM_I2C_ADDR, offset, 2, buf, 6)) {
+ printf("\nEEPROM serial read failed!\n");
+ return;
+ }
+
+ sprintf(serial_number, "%02X%02X%02X%02X%02X%02X",
+ buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
+
+ env_set("serial#", serial_number);
+}
+
+int board_early_init_f(void)
+{
+ /* enable the console UART */
+ writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST |
+ DAVINCI_UART_PWREMU_MGMT_UTRST),
+ &davinci_uart1_ctrl_regs->pwremu_mgmt);
+
+ /*
+ * Power on required peripherals
+ * ARM does not have access by default to PSC0 and PSC1
+ * assuming here that the DSP bootloader has set the IOPU
+ * such that PSC access is available to ARM
+ */
+ if (da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc)))
+ return 1;
+
+ return 0;
+}
+
+int board_init(void)
+{
+ irq_init();
+
+ /* address of boot parameters */
+ gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
+
+ /* setup the SUSPSRC for ARM to control emulation suspend */
+ writel(readl(&davinci_syscfg_regs->suspsrc) &
+ ~(DAVINCI_SYSCFG_SUSPSRC_I2C |
+ DAVINCI_SYSCFG_SUSPSRC_SPI0 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
+ DAVINCI_SYSCFG_SUSPSRC_UART1),
+ &davinci_syscfg_regs->suspsrc);
+
+ /* configure pinmux settings */
+ if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes)))
+ return 1;
+
+ return 0;
+}
+
+int board_late_init(void)
+{
+ setup_serial_number();
+
+ return 0;
+}