All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] LEGO MINDSTORMS EV3 updates
@ 2021-01-11 19:24 David Lechner
  2021-01-11 19:24 ` [PATCH 1/4] ARM: legoev3: set serial# env var David Lechner
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: David Lechner @ 2021-01-11 19:24 UTC (permalink / raw)
  To: u-boot

This is a collection of a few updates/cleanups for LEGO MINDSTORMS EV3.

David Lechner (4):
  ARM: legoev3: set serial# env var
  ARM: legoev3: drop bi_arch_number
  configs: legoev3: disable CONFIG_NET
  configs: legoev3: disable non-Linux boot options

 board/lego/ev3/legoev3.c  | 89 +++++++++++++++++----------------------
 configs/legoev3_defconfig |  8 +++-
 include/configs/legoev3.h |  2 -
 3 files changed, 46 insertions(+), 53 deletions(-)

-- 
2.25.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] ARM: legoev3: set serial# env var
  2021-01-11 19:24 [PATCH 0/4] LEGO MINDSTORMS EV3 updates David Lechner
@ 2021-01-11 19:24 ` David Lechner
  2021-01-11 19:24 ` [PATCH 2/4] ARM: legoev3: drop bi_arch_number David Lechner
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: David Lechner @ 2021-01-11 19:24 UTC (permalink / raw)
  To: u-boot

This sets the serial# environmet variable instead of using ATAGs on
LEGO MINDSTORMS EV3.

Also fix some nomenclature while we are touching this code (Bluetooth
address is not the same as MAC address, EEPROM version is not the same
as board version).

Signed-off-by: David Lechner <david@lechnology.com>
---
 board/lego/ev3/legoev3.c  | 85 ++++++++++++++++++---------------------
 configs/legoev3_defconfig |  1 +
 include/configs/legoev3.h |  2 -
 3 files changed, 40 insertions(+), 48 deletions(-)

diff --git a/board/lego/ev3/legoev3.c b/board/lego/ev3/legoev3.c
index 51b669a891..9ef3e12ce8 100644
--- a/board/lego/ev3/legoev3.c
+++ b/board/lego/ev3/legoev3.c
@@ -13,6 +13,7 @@
  */
 
 #include <common.h>
+#include <env.h>
 #include <i2c.h>
 #include <init.h>
 #include <spi.h>
@@ -28,11 +29,9 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-u8 board_rev;
-
 #define EEPROM_I2C_ADDR		0x50
 #define EEPROM_REV_OFFSET	0x3F00
-#define EEPROM_MAC_OFFSET	0x3F06
+#define EEPROM_BDADDR_OFFSET	0x3F06
 
 const struct pinmux_resource pinmuxes[] = {
 	PINMUX_ITEM(spi0_pins_base),
@@ -52,59 +51,46 @@ const struct lpsc_resource lpsc[] = {
 
 const int lpsc_size = ARRAY_SIZE(lpsc);
 
-u32 get_board_rev(void)
-{
-	u8 buf[2];
-
-	if (!board_rev) {
-		if (i2c_read(EEPROM_I2C_ADDR, EEPROM_REV_OFFSET, 2, buf, 2)) {
-			printf("\nBoard revision read failed!\n");
-		} else {
-			/*
-			 * Board rev 3 has MAC address at EEPROM_REV_OFFSET.
-			 * Other revisions have checksum at EEPROM_REV_OFFSET+1
-			 * to detect this.
-			 */
-			if ((buf[0] ^ buf[1]) == 0xFF)
-				board_rev = buf[0];
-			else
-				board_rev = 3;
-		}
-	}
-
-	return board_rev;
-}
-
 /*
- * The Bluetooth MAC address serves as the board serial number.
+ * The Bluetooth address serves as the board serial number.
  */
-void get_board_serial(struct tag_serialnr *serialnr)
+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;
+	}
 
-	if (!board_rev)
-		board_rev = get_board_rev();
+	/*
+	 * 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;
 
-	/* Board rev 3 has MAC address where rev should be */
-	offset = (board_rev == 3) ? EEPROM_REV_OFFSET : EEPROM_MAC_OFFSET;
+	/* 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("\nBoard serial read failed!\n");
-	} else {
-		u8 *nr;
-
-		nr = (u8 *)&serialnr->low;
-		nr[0] = buf[5];
-		nr[1] = buf[4];
-		nr[2] = buf[3];
-		nr[3] = buf[2];
-		nr = (u8 *)&serialnr->high;
-		nr[0] = buf[1];
-		nr[1] = buf[0];
-		nr[2] = 0;
-		nr[3] = 0;
+		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)
@@ -150,3 +136,10 @@ int board_init(void)
 
 	return 0;
 }
+
+int board_late_init(void)
+{
+	setup_serial_number();
+
+	return 0;
+}
diff --git a/configs/legoev3_defconfig b/configs/legoev3_defconfig
index 7aff11ccca..fb0c4dc951 100644
--- a/configs/legoev3_defconfig
+++ b/configs/legoev3_defconfig
@@ -12,6 +12,7 @@ CONFIG_AUTOBOOT_STOP_STR="l"
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_BOARD_EARLY_INIT_F=y
+CONFIG_BOARD_LATE_INIT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_ASKENV=y
 CONFIG_CRC32_VERIFY=y
diff --git a/include/configs/legoev3.h b/include/configs/legoev3.h
index a5f7fab15e..ca96683a3a 100644
--- a/include/configs/legoev3.h
+++ b/include/configs/legoev3.h
@@ -65,8 +65,6 @@
 #define LINUX_BOOT_PARAM_ADDR	(PHYS_SDRAM_1 + 0x100)
 #define CONFIG_HWCONFIG		/* enable hwconfig */
 #define CONFIG_CMDLINE_TAG
-#define CONFIG_REVISION_TAG
-#define CONFIG_SERIAL_TAG
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_SETUP_INITRD_TAG
 #define CONFIG_BOOTCOMMAND \
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] ARM: legoev3: drop bi_arch_number
  2021-01-11 19:24 [PATCH 0/4] LEGO MINDSTORMS EV3 updates David Lechner
  2021-01-11 19:24 ` [PATCH 1/4] ARM: legoev3: set serial# env var David Lechner
@ 2021-01-11 19:24 ` David Lechner
  2021-01-11 19:24 ` [PATCH 3/4] configs: legoev3: disable CONFIG_NET David Lechner
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: David Lechner @ 2021-01-11 19:24 UTC (permalink / raw)
  To: u-boot

This drops assigning bi_arch_number on LEGO MINDSTORMS EV3. This board
never had its own unique number and since we are using device tree,
we no longer need to pass an arch number to Linux.

Signed-off-by: David Lechner <david@lechnology.com>
---
 board/lego/ev3/legoev3.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/board/lego/ev3/legoev3.c b/board/lego/ev3/legoev3.c
index 9ef3e12ce8..e30e2e82df 100644
--- a/board/lego/ev3/legoev3.c
+++ b/board/lego/ev3/legoev3.c
@@ -116,10 +116,6 @@ int board_init(void)
 {
 	irq_init();
 
-	/* arch number of the board */
-	/* LEGO didn't register for a unique number and uses da850evm */
-	gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DA850_EVM;
-
 	/* address of boot parameters */
 	gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
 
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] configs: legoev3: disable CONFIG_NET
  2021-01-11 19:24 [PATCH 0/4] LEGO MINDSTORMS EV3 updates David Lechner
  2021-01-11 19:24 ` [PATCH 1/4] ARM: legoev3: set serial# env var David Lechner
  2021-01-11 19:24 ` [PATCH 2/4] ARM: legoev3: drop bi_arch_number David Lechner
@ 2021-01-11 19:24 ` David Lechner
  2021-01-11 19:24 ` [PATCH 4/4] configs: legoev3: disable non-Linux boot options David Lechner
  2021-01-18  4:16 ` [PATCH 0/4] LEGO MINDSTORMS EV3 updates Lokesh Vutla
  4 siblings, 0 replies; 6+ messages in thread
From: David Lechner @ 2021-01-11 19:24 UTC (permalink / raw)
  To: u-boot

This disables the CONFIG_NET setting for LEGO MINDSTORMS EV3. This board
does not have any built-in networking, so it does not make sense to
enable this feature.

This also fixes the warning:

===================== WARNING ======================
This board does not use CONFIG_DM_ETH (Driver Model
for Ethernet drivers). Please update the board to use
CONFIG_DM_ETH before the v2020.07 release. Failure to
update by the deadline may result in board removal.
See doc/driver-model/migration.rst for more info.
====================================================

Signed-off-by: David Lechner <david@lechnology.com>
---
 configs/legoev3_defconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/configs/legoev3_defconfig b/configs/legoev3_defconfig
index fb0c4dc951..3dfbdf2b2e 100644
--- a/configs/legoev3_defconfig
+++ b/configs/legoev3_defconfig
@@ -21,13 +21,13 @@ CONFIG_CMD_MX_CYCLIC=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
-# CONFIG_CMD_NET is not set
 CONFIG_CMD_EXT4=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_DIAG=y
 CONFIG_OF_CONTROL=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_VERSION_VARIABLE=y
+# CONFIG_NET is not set
 CONFIG_DM=y
 # CONFIG_DM_DEVICE_REMOVE is not set
 CONFIG_SYS_I2C_DAVINCI=y
@@ -41,3 +41,4 @@ CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_DAVINCI_SPI=y
+CONFIG_REGEX=y
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] configs: legoev3: disable non-Linux boot options
  2021-01-11 19:24 [PATCH 0/4] LEGO MINDSTORMS EV3 updates David Lechner
                   ` (2 preceding siblings ...)
  2021-01-11 19:24 ` [PATCH 3/4] configs: legoev3: disable CONFIG_NET David Lechner
@ 2021-01-11 19:24 ` David Lechner
  2021-01-18  4:16 ` [PATCH 0/4] LEGO MINDSTORMS EV3 updates Lokesh Vutla
  4 siblings, 0 replies; 6+ messages in thread
From: David Lechner @ 2021-01-11 19:24 UTC (permalink / raw)
  To: u-boot

This disables booting to non-Linux OSes.

This board is uncomfortably close to its 256K size limit, so every
few KB saved helps.

Signed-off-by: David Lechner <david@lechnology.com>
---
 configs/legoev3_defconfig | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/configs/legoev3_defconfig b/configs/legoev3_defconfig
index 3dfbdf2b2e..34bc72fb8b 100644
--- a/configs/legoev3_defconfig
+++ b/configs/legoev3_defconfig
@@ -14,6 +14,10 @@ CONFIG_AUTOBOOT_STOP_STR="l"
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_BOARD_LATE_INIT=y
 CONFIG_HUSH_PARSER=y
+# CONFIG_BOOTM_NETBSD is not set
+# CONFIG_BOOTM_PLAN9 is not set
+# CONFIG_BOOTM_RTEMS is not set
+# CONFIG_BOOTM_VXWORKS is not set
 CONFIG_CMD_ASKENV=y
 CONFIG_CRC32_VERIFY=y
 CONFIG_CMD_MX_CYCLIC=y
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 0/4] LEGO MINDSTORMS EV3 updates
  2021-01-11 19:24 [PATCH 0/4] LEGO MINDSTORMS EV3 updates David Lechner
                   ` (3 preceding siblings ...)
  2021-01-11 19:24 ` [PATCH 4/4] configs: legoev3: disable non-Linux boot options David Lechner
@ 2021-01-18  4:16 ` Lokesh Vutla
  4 siblings, 0 replies; 6+ messages in thread
From: Lokesh Vutla @ 2021-01-18  4:16 UTC (permalink / raw)
  To: u-boot



On 12/01/21 12:54 am, David Lechner wrote:
> This is a collection of a few updates/cleanups for LEGO MINDSTORMS EV3.

Applied to u-boot-ti/for-next branch.

Thanks and regards,
Lokesh

> 
> David Lechner (4):
>   ARM: legoev3: set serial# env var
>   ARM: legoev3: drop bi_arch_number
>   configs: legoev3: disable CONFIG_NET
>   configs: legoev3: disable non-Linux boot options
> 
>  board/lego/ev3/legoev3.c  | 89 +++++++++++++++++----------------------
>  configs/legoev3_defconfig |  8 +++-
>  include/configs/legoev3.h |  2 -
>  3 files changed, 46 insertions(+), 53 deletions(-)
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-18  4:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11 19:24 [PATCH 0/4] LEGO MINDSTORMS EV3 updates David Lechner
2021-01-11 19:24 ` [PATCH 1/4] ARM: legoev3: set serial# env var David Lechner
2021-01-11 19:24 ` [PATCH 2/4] ARM: legoev3: drop bi_arch_number David Lechner
2021-01-11 19:24 ` [PATCH 3/4] configs: legoev3: disable CONFIG_NET David Lechner
2021-01-11 19:24 ` [PATCH 4/4] configs: legoev3: disable non-Linux boot options David Lechner
2021-01-18  4:16 ` [PATCH 0/4] LEGO MINDSTORMS EV3 updates Lokesh Vutla

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.