All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH u-boot-marvell 0/7] Changes for Turris MOX
@ 2021-06-02 17:09 Marek Behún
  2021-06-02 17:09 ` [PATCH u-boot-marvell 1/7] arm: mvebu: dts: turris_mox: add button and LED nodes Marek Behún
                   ` (7 more replies)
  0 siblings, 8 replies; 34+ messages in thread
From: Marek Behún @ 2021-06-02 17:09 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár, Marek Behún

Hello Stefan,

Here are some changes for Turris MOX:
- dts changes
- more config options enabled
- rescue mode support added

If it is possible, since this touches only our device, we would like
this to be also merged for v2021.07 (once reviewed by you and Pali).

(The last patch touches common armada-37xx.dtsi, but it only changes
 name of a U-Boot's dts node to follow Linux' dts. No board code seems
 to depend on this name.)

Marek

Marek Behún (7):
  arm: mvebu: dts: turris_mox: add button and LED nodes
  arm: mvebu: turris_mox: add support for board rescue mode
  arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue
  arm: mvebu: configs: turris_mox: add fdtfile default env variable
  arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions
  arm: mvebu: turris_mox: enable options for Turris network boot
  arm64: a37xx: dts: rename internal-regs node

 arch/arm/dts/armada-3720-turris-mox.dts |  55 ++++++++++++
 arch/arm/dts/armada-37xx.dtsi           |   2 +-
 board/CZ.NIC/turris_mox/turris_mox.c    | 106 ++++++++++++++++++++++++
 configs/turris_mox_defconfig            |  14 ++++
 include/configs/turris_mox.h            |  10 +++
 5 files changed, 186 insertions(+), 1 deletion(-)

-- 
2.26.3


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

* [PATCH u-boot-marvell 1/7] arm: mvebu: dts: turris_mox: add button and LED nodes
  2021-06-02 17:09 [PATCH u-boot-marvell 0/7] Changes for Turris MOX Marek Behún
@ 2021-06-02 17:09 ` Marek Behún
  2021-06-02 17:09 ` [PATCH u-boot-marvell 2/7] arm: mvebu: turris_mox: add support for board rescue mode Marek Behún
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 34+ messages in thread
From: Marek Behún @ 2021-06-02 17:09 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár, Marek Behún

Add nodes for indicator LED and reset button so that board code can
implement board factory reset mechanism.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 arch/arm/dts/armada-3720-turris-mox.dts | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts
index 8e0ebf508d..741b0eeeee 100644
--- a/arch/arm/dts/armada-3720-turris-mox.dts
+++ b/arch/arm/dts/armada-3720-turris-mox.dts
@@ -11,6 +11,8 @@
 /dts-v1/;
 
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
 #include "armada-372x.dtsi"
 
 / {
@@ -34,6 +36,28 @@
 		reg = <0x00000000 0x00000000 0x00000000 0x20000000>;
 	};
 
+	leds {
+		compatible = "gpio-leds";
+
+		led {
+			gpios = <&gpiosb 21 GPIO_ACTIVE_LOW>;
+			color = <LED_COLOR_ID_RED>;
+			function = LED_FUNCTION_ACTIVITY;
+		};
+	};
+
+	gpio-keys {
+		compatible = "gpio-keys";
+
+		reset {
+			compatible = "gpio-keys";
+			label = "reset";
+			linux,code = <KEY_RESTART>;
+			gpios = <&gpiosb 20 GPIO_ACTIVE_LOW>;
+			debounce-interval = <60>;
+		};
+	};
+
 	reg_usb3_vbus: usb3_vbus@0 {
 		compatible = "regulator-fixed";
 		regulator-name = "usb3-vbus";
-- 
2.26.3


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

* [PATCH u-boot-marvell 2/7] arm: mvebu: turris_mox: add support for board rescue mode
  2021-06-02 17:09 [PATCH u-boot-marvell 0/7] Changes for Turris MOX Marek Behún
  2021-06-02 17:09 ` [PATCH u-boot-marvell 1/7] arm: mvebu: dts: turris_mox: add button and LED nodes Marek Behún
@ 2021-06-02 17:09 ` Marek Behún
  2021-06-03 15:18   ` Marek Behún
  2021-06-02 17:09 ` [PATCH u-boot-marvell 3/7] arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue Marek Behún
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 34+ messages in thread
From: Marek Behún @ 2021-06-02 17:09 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár, Marek Behún

Add necessary config options and board code to support board factory
reset / rescue mode on Turris MOX.

In order to also support invoking rescue mode from U-Boot console,
without having to press the factory reset button, put the rescue command
into `bootcmd_rescue` default environment variable. When factory reset
button is pressed, invoke rescue mode via distroboot by setting
`boot_targets` to `rescue`.

Rescue boot from console can be invoked by running
  run bootcmd_rescue

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 board/CZ.NIC/turris_mox/turris_mox.c | 71 ++++++++++++++++++++++++++++
 configs/turris_mox_defconfig         |  6 +++
 include/configs/turris_mox.h         |  9 ++++
 3 files changed, 86 insertions(+)

diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c
index 15cbf92550..a78f33661e 100644
--- a/board/CZ.NIC/turris_mox/turris_mox.c
+++ b/board/CZ.NIC/turris_mox/turris_mox.c
@@ -10,11 +10,13 @@
 #include <asm/global_data.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
+#include <button.h>
 #include <clk.h>
 #include <dm.h>
 #include <env.h>
 #include <fdt_support.h>
 #include <init.h>
+#include <led.h>
 #include <linux/delay.h>
 #include <linux/libfdt.h>
 #include <linux/string.h>
@@ -44,6 +46,8 @@
 #define SFP_GPIO_PATH	"/soc/internal-regs@d0000000/spi@10600/moxtet@1/gpio@0"
 #define PCIE_PATH	"/soc/pcie@d0070000"
 #define SFP_PATH	"/sfp"
+#define LED_PATH	"/leds/led"
+#define BUTTON_PATH	"/gpio-keys/reset"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -373,6 +377,71 @@ int misc_init_r(void)
 	return 0;
 }
 
+static bool read_reset_button(void)
+{
+	struct udevice *button, *led;
+	int i;
+
+	if (device_get_global_by_ofnode(ofnode_path(BUTTON_PATH), &button)) {
+		printf("Cannot find reset button!\n");
+		return false;
+	}
+
+	if (device_get_global_by_ofnode(ofnode_path(LED_PATH), &led)) {
+		printf("Cannot find status LED!\n");
+		return false;
+	}
+
+	led_set_state(led, LEDST_ON);
+
+	for (i = 0; i < 21; ++i) {
+		if (button_get_state(button) != BUTTON_ON)
+			return false;
+		if (i < 20)
+			mdelay(50);
+	}
+
+	led_set_state(led, LEDST_OFF);
+
+	return true;
+}
+
+static void handle_reset_button(void)
+{
+	if (read_reset_button()) {
+		const char * const vars[3] = {
+			"bootcmd",
+			"bootcmd_rescue",
+			"distro_bootcmd",
+		};
+
+		/*
+		 * Set the above envs to their default values, in case the user
+		 * managed to break them.
+		 */
+		env_set_default_vars(3, (char * const *)vars, 0);
+
+		/* Ensure bootcmd_rescue is used by distroboot */
+		env_set("boot_targets", "rescue");
+
+		printf("RESET button was pressed, overwriting boot_targets!\n");
+	} else {
+		/*
+		 * In case the user somehow managed to save environment with
+		 * boot_targets=rescue, reset boot_targets to default value.
+		 * This could happen in subsequent commands if bootcmd_rescue
+		 * failed.
+		 */
+		if (!strcmp(env_get("boot_targets"), "rescue")) {
+			const char * const vars[1] = {
+				"boot_targets",
+			};
+
+			env_set_default_vars(1, (char * const *)vars, 0);
+		}
+	}
+}
+
 static void mox_print_info(void)
 {
 	int ret, board_version, ram_size;
@@ -543,6 +612,8 @@ int last_stage_init(void)
 
 	printf("\n");
 
+	handle_reset_button();
+
 	return 0;
 }
 
diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig
index 75524babbc..d6d37a3d7d 100644
--- a/configs/turris_mox_defconfig
+++ b/configs/turris_mox_defconfig
@@ -23,10 +23,14 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_ARCH_EARLY_INIT_R=y
 CONFIG_MISC_INIT_R=y
+CONFIG_BUTTON=y
+CONFIG_BUTTON_GPIO=y
+CONFIG_CMD_BUTTON=y
 CONFIG_CMD_CLK=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
+CONFIG_CMD_LED=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_SPI=y
@@ -46,6 +50,8 @@ CONFIG_CLK=y
 CONFIG_CLK_MVEBU=y
 # CONFIG_MVEBU_GPIO is not set
 CONFIG_DM_I2C=y
+CONFIG_LED=y
+CONFIG_LED_GPIO=y
 CONFIG_MISC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_SDMA=y
diff --git a/include/configs/turris_mox.h b/include/configs/turris_mox.h
index 51445ec60a..6b2b6b3bd4 100644
--- a/include/configs/turris_mox.h
+++ b/include/configs/turris_mox.h
@@ -75,12 +75,21 @@
 
 #include <config_distro_bootcmd.h>
 
+#define TURRIS_MOX_BOOTCMD_RESCUE \
+	"setenv bootargs \"console=ttyMV0,115200 " \
+			  "earlycon=ar3700_uart,0xd0012000\" && " \
+	"sf probe && " \
+	"sf read ${kernel_addr_r} 0x190000 && " \
+	"lzmadec ${kernel_addr_r} ${ramdisk_addr_r} && " \
+	"bootm ${ramdisk_addr_r}"
+
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	"scriptaddr=0x4d00000\0"	\
 	"pxefile_addr_r=0x4e00000\0"	\
 	"fdt_addr_r=0x4f00000\0"	\
 	"kernel_addr_r=0x5000000\0"	\
 	"ramdisk_addr_r=0x8000000\0"	\
+	"bootcmd_rescue=" TURRIS_MOX_BOOTCMD_RESCUE "\0" \
 	BOOTENV
 
 #endif /* _CONFIG_TURRIS_MOX_H */
-- 
2.26.3


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

* [PATCH u-boot-marvell 3/7] arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue
  2021-06-02 17:09 [PATCH u-boot-marvell 0/7] Changes for Turris MOX Marek Behún
  2021-06-02 17:09 ` [PATCH u-boot-marvell 1/7] arm: mvebu: dts: turris_mox: add button and LED nodes Marek Behún
  2021-06-02 17:09 ` [PATCH u-boot-marvell 2/7] arm: mvebu: turris_mox: add support for board rescue mode Marek Behún
@ 2021-06-02 17:09 ` Marek Behún
  2021-06-02 17:09 ` [PATCH u-boot-marvell 4/7] arm: mvebu: configs: turris_mox: add fdtfile default env variable Marek Behún
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 34+ messages in thread
From: Marek Behún @ 2021-06-02 17:09 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár, Marek Behún

Configure blinking on ethernet PHY LEDs on the MOX A board when entering
rescue mode via reset button.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 board/CZ.NIC/turris_mox/turris_mox.c | 35 ++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c
index a78f33661e..44c272c7cb 100644
--- a/board/CZ.NIC/turris_mox/turris_mox.c
+++ b/board/CZ.NIC/turris_mox/turris_mox.c
@@ -377,6 +377,38 @@ int misc_init_r(void)
 	return 0;
 }
 
+static void mox_phy_modify(struct phy_device *phydev, int page, int reg,
+			   u16 mask, u16 set)
+{
+	int val;
+
+	val = phydev->drv->readext(phydev, MDIO_DEVAD_NONE, page, reg);
+	val &= ~mask;
+	val |= set;
+	phydev->drv->writeext(phydev, MDIO_DEVAD_NONE, page, reg, val);
+}
+
+static void mox_phy_leds_start_blinking(void)
+{
+	struct phy_device *phydev;
+	struct mii_dev *bus;
+
+	bus = miiphy_get_dev_by_name("neta@30000");
+	if (!bus) {
+		printf("Cannot get MDIO bus device!\n");
+		return;
+	}
+
+	phydev = phy_find_by_mask(bus, BIT(1), PHY_INTERFACE_MODE_RGMII);
+	if (!phydev) {
+		printf("Cannot get ethernet PHY!\n");
+		return;
+	}
+
+	mox_phy_modify(phydev, 3, 0x12, 0x700, 0x400);
+	mox_phy_modify(phydev, 3, 0x10, 0xff, 0xbb);
+}
+
 static bool read_reset_button(void)
 {
 	struct udevice *button, *led;
@@ -424,6 +456,9 @@ static void handle_reset_button(void)
 		/* Ensure bootcmd_rescue is used by distroboot */
 		env_set("boot_targets", "rescue");
 
+		/* start blinking PHY LEDs */
+		mox_phy_leds_start_blinking();
+
 		printf("RESET button was pressed, overwriting boot_targets!\n");
 	} else {
 		/*
-- 
2.26.3


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

* [PATCH u-boot-marvell 4/7] arm: mvebu: configs: turris_mox: add fdtfile default env variable
  2021-06-02 17:09 [PATCH u-boot-marvell 0/7] Changes for Turris MOX Marek Behún
                   ` (2 preceding siblings ...)
  2021-06-02 17:09 ` [PATCH u-boot-marvell 3/7] arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue Marek Behún
@ 2021-06-02 17:09 ` Marek Behún
  2021-06-02 17:09 ` [PATCH u-boot-marvell 5/7] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions Marek Behún
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 34+ messages in thread
From: Marek Behún @ 2021-06-02 17:09 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár, Marek Behún

Add default fdtfile environment variable with value
marvell/armada-3720-turris-mox.dtb.

This can be useful for some boot scenarios.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 include/configs/turris_mox.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/turris_mox.h b/include/configs/turris_mox.h
index 6b2b6b3bd4..2b28cf0901 100644
--- a/include/configs/turris_mox.h
+++ b/include/configs/turris_mox.h
@@ -89,6 +89,7 @@
 	"fdt_addr_r=0x4f00000\0"	\
 	"kernel_addr_r=0x5000000\0"	\
 	"ramdisk_addr_r=0x8000000\0"	\
+	"fdtfile=marvell/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
 	"bootcmd_rescue=" TURRIS_MOX_BOOTCMD_RESCUE "\0" \
 	BOOTENV
 
-- 
2.26.3


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

* [PATCH u-boot-marvell 5/7] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions
  2021-06-02 17:09 [PATCH u-boot-marvell 0/7] Changes for Turris MOX Marek Behún
                   ` (3 preceding siblings ...)
  2021-06-02 17:09 ` [PATCH u-boot-marvell 4/7] arm: mvebu: configs: turris_mox: add fdtfile default env variable Marek Behún
@ 2021-06-02 17:09 ` Marek Behún
  2021-06-02 17:10 ` [PATCH u-boot-marvell 6/7] arm: mvebu: turris_mox: enable options for Turris network boot Marek Behún
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 34+ messages in thread
From: Marek Behún @ 2021-06-02 17:09 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár, Marek Behún

Add nodes for SPI NOR partitions to the device tree of Turris MOX, as
are in Linux' device tree.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 arch/arm/dts/armada-3720-turris-mox.dts | 31 +++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts
index 741b0eeeee..f47ced05c5 100644
--- a/arch/arm/dts/armada-3720-turris-mox.dts
+++ b/arch/arm/dts/armada-3720-turris-mox.dts
@@ -164,6 +164,37 @@
 		reg = <0>;
 		spi-max-frequency = <20000000>;
 		m25p,fast-read;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "secure-firmware";
+				reg = <0x0 0x20000>;
+			};
+
+			partition@20000 {
+				label = "a53-firmware";
+				reg = <0x20000 0x160000>;
+			};
+
+			partition@180000 {
+				label = "u-boot-env";
+				reg = <0x180000 0x10000>;
+			};
+
+			partition@190000 {
+				label = "Rescue system";
+				reg = <0x190000 0x660000>;
+			};
+
+			partition@7f0000 {
+				label = "dtb";
+				reg = <0x7f0000 0x10000>;
+			};
+		};
 	};
 
 	moxtet@1 {
-- 
2.26.3


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

* [PATCH u-boot-marvell 6/7] arm: mvebu: turris_mox: enable options for Turris network boot
  2021-06-02 17:09 [PATCH u-boot-marvell 0/7] Changes for Turris MOX Marek Behún
                   ` (4 preceding siblings ...)
  2021-06-02 17:09 ` [PATCH u-boot-marvell 5/7] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions Marek Behún
@ 2021-06-02 17:10 ` Marek Behún
  2021-06-02 17:10 ` [PATCH u-boot-marvell 7/7] arm64: a37xx: dts: rename internal-regs node Marek Behún
  2021-06-07 14:34 ` [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX Marek Behún
  7 siblings, 0 replies; 34+ messages in thread
From: Marek Behún @ 2021-06-02 17:10 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár, Marek Behún

Enable configuration options to support Turris network boot. This
includes FIT support and some crypto commands.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 configs/turris_mox_defconfig | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig
index d6d37a3d7d..f93be912c9 100644
--- a/configs/turris_mox_defconfig
+++ b/configs/turris_mox_defconfig
@@ -25,14 +25,17 @@ CONFIG_ARCH_EARLY_INIT_R=y
 CONFIG_MISC_INIT_R=y
 CONFIG_BUTTON=y
 CONFIG_BUTTON_GPIO=y
+CONFIG_CMD_AES=y
 CONFIG_CMD_BUTTON=y
 CONFIG_CMD_CLK=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
+CONFIG_CMD_HASH=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_LED=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PCI=y
+CONFIG_CMD_SHA1SUM=y
 CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_WDT=y
@@ -46,6 +49,11 @@ CONFIG_MAC_PARTITION=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_FIT=y
+CONFIG_FIT_ENABLE_SHA256_SUPPORT=y
+# CONFIG_FIT_SIGNATURE is not set
+CONFIG_FIT_VERBOSE=y
+# CONFIG_FIT_BEST_MATCH is not set
 CONFIG_CLK=y
 CONFIG_CLK_MVEBU=y
 # CONFIG_MVEBU_GPIO is not set
-- 
2.26.3


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

* [PATCH u-boot-marvell 7/7] arm64: a37xx: dts: rename internal-regs node
  2021-06-02 17:09 [PATCH u-boot-marvell 0/7] Changes for Turris MOX Marek Behún
                   ` (5 preceding siblings ...)
  2021-06-02 17:10 ` [PATCH u-boot-marvell 6/7] arm: mvebu: turris_mox: enable options for Turris network boot Marek Behún
@ 2021-06-02 17:10 ` Marek Behún
  2021-06-03 15:20   ` Marek Behún
  2021-06-07 14:34 ` [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX Marek Behún
  7 siblings, 1 reply; 34+ messages in thread
From: Marek Behún @ 2021-06-02 17:10 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár, Marek Behún

The node `internal-regs` is called `internal-regs@d0000000`
in Linux' device tree. Rename this in U-Boot also.

No in-tree code depends on this name, so this should be safe.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 arch/arm/dts/armada-37xx.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/dts/armada-37xx.dtsi b/arch/arm/dts/armada-37xx.dtsi
index a1052add0c..ad86bf5c1d 100644
--- a/arch/arm/dts/armada-37xx.dtsi
+++ b/arch/arm/dts/armada-37xx.dtsi
@@ -93,7 +93,7 @@
 		#size-cells = <2>;
 		ranges;
 
-		internal-regs {
+		internal-regs@d0000000 {
 			#address-cells = <1>;
 			#size-cells = <1>;
 			compatible = "simple-bus";
-- 
2.26.3


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

* Re: [PATCH u-boot-marvell 2/7] arm: mvebu: turris_mox: add support for board rescue mode
  2021-06-02 17:09 ` [PATCH u-boot-marvell 2/7] arm: mvebu: turris_mox: add support for board rescue mode Marek Behún
@ 2021-06-03 15:18   ` Marek Behún
  0 siblings, 0 replies; 34+ messages in thread
From: Marek Behún @ 2021-06-03 15:18 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár

On Wed,  2 Jun 2021 19:09:56 +0200
Marek Behún <marek.behun@nic.cz> wrote:

> +#define TURRIS_MOX_BOOTCMD_RESCUE \
> +	"setenv bootargs \"console=ttyMV0,115200 " \
> +			  "earlycon=ar3700_uart,0xd0012000\" && " \
> +	"sf probe && " \
> +	"sf read ${kernel_addr_r} 0x190000 && " \
> +	"lzmadec ${kernel_addr_r} ${ramdisk_addr_r} && " \
> +	"bootm ${ramdisk_addr_r}"

OMG, we should use constants for addresses here instead of
${kernel_addr_r} and ${ramdisk_addr_r}, in case user changes or removed
this variables.

I will update this in v2.

> +
>  #define CONFIG_EXTRA_ENV_SETTINGS	\
>  	"scriptaddr=0x4d00000\0"	\
>  	"pxefile_addr_r=0x4e00000\0"	\
>  	"fdt_addr_r=0x4f00000\0"	\
>  	"kernel_addr_r=0x5000000\0"	\
>  	"ramdisk_addr_r=0x8000000\0"	\
> +	"bootcmd_rescue=" TURRIS_MOX_BOOTCMD_RESCUE "\0" \
>  	BOOTENV
>  
>  #endif /* _CONFIG_TURRIS_MOX_H */


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

* Re: [PATCH u-boot-marvell 7/7] arm64: a37xx: dts: rename internal-regs node
  2021-06-02 17:10 ` [PATCH u-boot-marvell 7/7] arm64: a37xx: dts: rename internal-regs node Marek Behún
@ 2021-06-03 15:20   ` Marek Behún
  0 siblings, 0 replies; 34+ messages in thread
From: Marek Behún @ 2021-06-03 15:20 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár

On Wed,  2 Jun 2021 19:10:01 +0200
Marek Behún <marek.behun@nic.cz> wrote:

> The node `internal-regs` is called `internal-regs@d0000000`
> in Linux' device tree. Rename this in U-Boot also.
> 
> No in-tree code depends on this name, so this should be safe.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  arch/arm/dts/armada-37xx.dtsi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/dts/armada-37xx.dtsi
> b/arch/arm/dts/armada-37xx.dtsi index a1052add0c..ad86bf5c1d 100644
> --- a/arch/arm/dts/armada-37xx.dtsi
> +++ b/arch/arm/dts/armada-37xx.dtsi
> @@ -93,7 +93,7 @@
>  		#size-cells = <2>;
>  		ranges;
>  
> -		internal-regs {
> +		internal-regs@d0000000 {
>  			#address-cells = <1>;
>  			#size-cells = <1>;
>  			compatible = "simple-bus";

On second thought we can ignore this patch for now. We can update the
whole DTS to kernel's DTS once all drivers are updated to support
kernel bindings.

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

* [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX
  2021-06-02 17:09 [PATCH u-boot-marvell 0/7] Changes for Turris MOX Marek Behún
                   ` (6 preceding siblings ...)
  2021-06-02 17:10 ` [PATCH u-boot-marvell 7/7] arm64: a37xx: dts: rename internal-regs node Marek Behún
@ 2021-06-07 14:34 ` Marek Behún
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 1/6] arm: mvebu: dts: turris_mox: add button and LED nodes Marek Behún
                     ` (6 more replies)
  7 siblings, 7 replies; 34+ messages in thread
From: Marek Behún @ 2021-06-07 14:34 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár, Marek Behún

Hello Stefan,

Here are some changes for Turris MOX (v2):
- dts changes
- more config options enabled
- rescue mode support added

If it is possible, since this touches only our device, we would like
this to be also merged for v2021.07 (once reviewed by you and Pali).

Changes since v1:
- use constant addresses instead of ${kernel_addr_r} and
  ${ramdisk_addr_r} in bootcmd_rescue, so that this command won't fail
  if those addresses are changed
- dropped last patch changing internal-regs node name in dts. We don't
  need this now, let's do this in the future once we will be aligning
  U-Boot's DTS with kernel's DTS

Marek Behún (6):
  arm: mvebu: dts: turris_mox: add button and LED nodes
  arm: mvebu: turris_mox: add support for board rescue mode
  arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue
  arm: mvebu: configs: turris_mox: add fdtfile default env variable
  arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions
  arm: mvebu: turris_mox: enable options for Turris network boot

 arch/arm/dts/armada-3720-turris-mox.dts |  55 ++++++++++++
 board/CZ.NIC/turris_mox/turris_mox.c    | 106 ++++++++++++++++++++++++
 configs/turris_mox_defconfig            |  14 ++++
 include/configs/turris_mox.h            |  10 +++
 4 files changed, 185 insertions(+)

-- 
2.31.1


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

* [PATCH u-boot-marvell v2 1/6] arm: mvebu: dts: turris_mox: add button and LED nodes
  2021-06-07 14:34 ` [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX Marek Behún
@ 2021-06-07 14:34   ` Marek Behún
  2021-06-08  9:47     ` Pali Rohár
  2021-06-10  5:06     ` Stefan Roese
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 2/6] arm: mvebu: turris_mox: add support for board rescue mode Marek Behún
                     ` (5 subsequent siblings)
  6 siblings, 2 replies; 34+ messages in thread
From: Marek Behún @ 2021-06-07 14:34 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár, Marek Behún

Add nodes for indicator LED and reset button so that board code can
implement board factory reset mechanism.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 arch/arm/dts/armada-3720-turris-mox.dts | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts
index 8e0ebf508d..741b0eeeee 100644
--- a/arch/arm/dts/armada-3720-turris-mox.dts
+++ b/arch/arm/dts/armada-3720-turris-mox.dts
@@ -11,6 +11,8 @@
 /dts-v1/;
 
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
 #include "armada-372x.dtsi"
 
 / {
@@ -34,6 +36,28 @@
 		reg = <0x00000000 0x00000000 0x00000000 0x20000000>;
 	};
 
+	leds {
+		compatible = "gpio-leds";
+
+		led {
+			gpios = <&gpiosb 21 GPIO_ACTIVE_LOW>;
+			color = <LED_COLOR_ID_RED>;
+			function = LED_FUNCTION_ACTIVITY;
+		};
+	};
+
+	gpio-keys {
+		compatible = "gpio-keys";
+
+		reset {
+			compatible = "gpio-keys";
+			label = "reset";
+			linux,code = <KEY_RESTART>;
+			gpios = <&gpiosb 20 GPIO_ACTIVE_LOW>;
+			debounce-interval = <60>;
+		};
+	};
+
 	reg_usb3_vbus: usb3_vbus@0 {
 		compatible = "regulator-fixed";
 		regulator-name = "usb3-vbus";
-- 
2.31.1


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

* [PATCH u-boot-marvell v2 2/6] arm: mvebu: turris_mox: add support for board rescue mode
  2021-06-07 14:34 ` [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX Marek Behún
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 1/6] arm: mvebu: dts: turris_mox: add button and LED nodes Marek Behún
@ 2021-06-07 14:34   ` Marek Behún
  2021-06-08  9:48     ` Pali Rohár
  2021-06-10  5:09     ` Stefan Roese
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 3/6] arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue Marek Behún
                     ` (4 subsequent siblings)
  6 siblings, 2 replies; 34+ messages in thread
From: Marek Behún @ 2021-06-07 14:34 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár, Marek Behún

Add necessary config options and board code to support board factory
reset / rescue mode on Turris MOX.

In order to also support invoking rescue mode from U-Boot console,
without having to press the factory reset button, put the rescue command
into `bootcmd_rescue` default environment variable. When factory reset
button is pressed, invoke rescue mode via distroboot by setting
`boot_targets` to `rescue`.

Rescue boot from console can be invoked by running
  run bootcmd_rescue

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 board/CZ.NIC/turris_mox/turris_mox.c | 71 ++++++++++++++++++++++++++++
 configs/turris_mox_defconfig         |  6 +++
 include/configs/turris_mox.h         |  9 ++++
 3 files changed, 86 insertions(+)

diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c
index 15cbf92550..a78f33661e 100644
--- a/board/CZ.NIC/turris_mox/turris_mox.c
+++ b/board/CZ.NIC/turris_mox/turris_mox.c
@@ -10,11 +10,13 @@
 #include <asm/global_data.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
+#include <button.h>
 #include <clk.h>
 #include <dm.h>
 #include <env.h>
 #include <fdt_support.h>
 #include <init.h>
+#include <led.h>
 #include <linux/delay.h>
 #include <linux/libfdt.h>
 #include <linux/string.h>
@@ -44,6 +46,8 @@
 #define SFP_GPIO_PATH	"/soc/internal-regs@d0000000/spi@10600/moxtet@1/gpio@0"
 #define PCIE_PATH	"/soc/pcie@d0070000"
 #define SFP_PATH	"/sfp"
+#define LED_PATH	"/leds/led"
+#define BUTTON_PATH	"/gpio-keys/reset"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -373,6 +377,71 @@ int misc_init_r(void)
 	return 0;
 }
 
+static bool read_reset_button(void)
+{
+	struct udevice *button, *led;
+	int i;
+
+	if (device_get_global_by_ofnode(ofnode_path(BUTTON_PATH), &button)) {
+		printf("Cannot find reset button!\n");
+		return false;
+	}
+
+	if (device_get_global_by_ofnode(ofnode_path(LED_PATH), &led)) {
+		printf("Cannot find status LED!\n");
+		return false;
+	}
+
+	led_set_state(led, LEDST_ON);
+
+	for (i = 0; i < 21; ++i) {
+		if (button_get_state(button) != BUTTON_ON)
+			return false;
+		if (i < 20)
+			mdelay(50);
+	}
+
+	led_set_state(led, LEDST_OFF);
+
+	return true;
+}
+
+static void handle_reset_button(void)
+{
+	if (read_reset_button()) {
+		const char * const vars[3] = {
+			"bootcmd",
+			"bootcmd_rescue",
+			"distro_bootcmd",
+		};
+
+		/*
+		 * Set the above envs to their default values, in case the user
+		 * managed to break them.
+		 */
+		env_set_default_vars(3, (char * const *)vars, 0);
+
+		/* Ensure bootcmd_rescue is used by distroboot */
+		env_set("boot_targets", "rescue");
+
+		printf("RESET button was pressed, overwriting boot_targets!\n");
+	} else {
+		/*
+		 * In case the user somehow managed to save environment with
+		 * boot_targets=rescue, reset boot_targets to default value.
+		 * This could happen in subsequent commands if bootcmd_rescue
+		 * failed.
+		 */
+		if (!strcmp(env_get("boot_targets"), "rescue")) {
+			const char * const vars[1] = {
+				"boot_targets",
+			};
+
+			env_set_default_vars(1, (char * const *)vars, 0);
+		}
+	}
+}
+
 static void mox_print_info(void)
 {
 	int ret, board_version, ram_size;
@@ -543,6 +612,8 @@ int last_stage_init(void)
 
 	printf("\n");
 
+	handle_reset_button();
+
 	return 0;
 }
 
diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig
index 75524babbc..d6d37a3d7d 100644
--- a/configs/turris_mox_defconfig
+++ b/configs/turris_mox_defconfig
@@ -23,10 +23,14 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_ARCH_EARLY_INIT_R=y
 CONFIG_MISC_INIT_R=y
+CONFIG_BUTTON=y
+CONFIG_BUTTON_GPIO=y
+CONFIG_CMD_BUTTON=y
 CONFIG_CMD_CLK=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
+CONFIG_CMD_LED=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_SPI=y
@@ -46,6 +50,8 @@ CONFIG_CLK=y
 CONFIG_CLK_MVEBU=y
 # CONFIG_MVEBU_GPIO is not set
 CONFIG_DM_I2C=y
+CONFIG_LED=y
+CONFIG_LED_GPIO=y
 CONFIG_MISC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_SDMA=y
diff --git a/include/configs/turris_mox.h b/include/configs/turris_mox.h
index 51445ec60a..b148b1621a 100644
--- a/include/configs/turris_mox.h
+++ b/include/configs/turris_mox.h
@@ -75,12 +75,21 @@
 
 #include <config_distro_bootcmd.h>
 
+#define TURRIS_MOX_BOOTCMD_RESCUE \
+	"setenv bootargs \"console=ttyMV0,115200 " \
+			  "earlycon=ar3700_uart,0xd0012000\" && " \
+	"sf probe && " \
+	"sf read 0x5000000 0x190000 && " \
+	"lzmadec 0x5000000 0x5800000 && " \
+	"bootm 0x5800000"
+
 #define CONFIG_EXTRA_ENV_SETTINGS	\
 	"scriptaddr=0x4d00000\0"	\
 	"pxefile_addr_r=0x4e00000\0"	\
 	"fdt_addr_r=0x4f00000\0"	\
 	"kernel_addr_r=0x5000000\0"	\
 	"ramdisk_addr_r=0x8000000\0"	\
+	"bootcmd_rescue=" TURRIS_MOX_BOOTCMD_RESCUE "\0" \
 	BOOTENV
 
 #endif /* _CONFIG_TURRIS_MOX_H */
-- 
2.31.1


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

* [PATCH u-boot-marvell v2 3/6] arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue
  2021-06-07 14:34 ` [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX Marek Behún
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 1/6] arm: mvebu: dts: turris_mox: add button and LED nodes Marek Behún
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 2/6] arm: mvebu: turris_mox: add support for board rescue mode Marek Behún
@ 2021-06-07 14:34   ` Marek Behún
  2021-06-08  9:49     ` Pali Rohár
  2021-06-10  5:09     ` Stefan Roese
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 4/6] arm: mvebu: configs: turris_mox: add fdtfile default env variable Marek Behún
                     ` (3 subsequent siblings)
  6 siblings, 2 replies; 34+ messages in thread
From: Marek Behún @ 2021-06-07 14:34 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár, Marek Behún

Configure blinking on ethernet PHY LEDs on the MOX A board when entering
rescue mode via reset button.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 board/CZ.NIC/turris_mox/turris_mox.c | 35 ++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c
index a78f33661e..44c272c7cb 100644
--- a/board/CZ.NIC/turris_mox/turris_mox.c
+++ b/board/CZ.NIC/turris_mox/turris_mox.c
@@ -377,6 +377,38 @@ int misc_init_r(void)
 	return 0;
 }
 
+static void mox_phy_modify(struct phy_device *phydev, int page, int reg,
+			   u16 mask, u16 set)
+{
+	int val;
+
+	val = phydev->drv->readext(phydev, MDIO_DEVAD_NONE, page, reg);
+	val &= ~mask;
+	val |= set;
+	phydev->drv->writeext(phydev, MDIO_DEVAD_NONE, page, reg, val);
+}
+
+static void mox_phy_leds_start_blinking(void)
+{
+	struct phy_device *phydev;
+	struct mii_dev *bus;
+
+	bus = miiphy_get_dev_by_name("neta@30000");
+	if (!bus) {
+		printf("Cannot get MDIO bus device!\n");
+		return;
+	}
+
+	phydev = phy_find_by_mask(bus, BIT(1), PHY_INTERFACE_MODE_RGMII);
+	if (!phydev) {
+		printf("Cannot get ethernet PHY!\n");
+		return;
+	}
+
+	mox_phy_modify(phydev, 3, 0x12, 0x700, 0x400);
+	mox_phy_modify(phydev, 3, 0x10, 0xff, 0xbb);
+}
+
 static bool read_reset_button(void)
 {
 	struct udevice *button, *led;
@@ -424,6 +456,9 @@ static void handle_reset_button(void)
 		/* Ensure bootcmd_rescue is used by distroboot */
 		env_set("boot_targets", "rescue");
 
+		/* start blinking PHY LEDs */
+		mox_phy_leds_start_blinking();
+
 		printf("RESET button was pressed, overwriting boot_targets!\n");
 	} else {
 		/*
-- 
2.31.1


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

* [PATCH u-boot-marvell v2 4/6] arm: mvebu: configs: turris_mox: add fdtfile default env variable
  2021-06-07 14:34 ` [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX Marek Behún
                     ` (2 preceding siblings ...)
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 3/6] arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue Marek Behún
@ 2021-06-07 14:34   ` Marek Behún
  2021-06-08  9:50     ` Pali Rohár
  2021-06-10  5:10     ` Stefan Roese
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 5/6] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions Marek Behún
                     ` (2 subsequent siblings)
  6 siblings, 2 replies; 34+ messages in thread
From: Marek Behún @ 2021-06-07 14:34 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár, Marek Behún

Add default fdtfile environment variable with value
marvell/armada-3720-turris-mox.dtb.

This can be useful for some boot scenarios.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 include/configs/turris_mox.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/turris_mox.h b/include/configs/turris_mox.h
index b148b1621a..9c021a1ef9 100644
--- a/include/configs/turris_mox.h
+++ b/include/configs/turris_mox.h
@@ -89,6 +89,7 @@
 	"fdt_addr_r=0x4f00000\0"	\
 	"kernel_addr_r=0x5000000\0"	\
 	"ramdisk_addr_r=0x8000000\0"	\
+	"fdtfile=marvell/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
 	"bootcmd_rescue=" TURRIS_MOX_BOOTCMD_RESCUE "\0" \
 	BOOTENV
 
-- 
2.31.1


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

* [PATCH u-boot-marvell v2 5/6] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions
  2021-06-07 14:34 ` [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX Marek Behún
                     ` (3 preceding siblings ...)
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 4/6] arm: mvebu: configs: turris_mox: add fdtfile default env variable Marek Behún
@ 2021-06-07 14:34   ` Marek Behún
  2021-06-08  9:51     ` Pali Rohár
  2021-06-10  5:11     ` Stefan Roese
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 6/6] arm: mvebu: turris_mox: enable options for Turris network boot Marek Behún
  2021-06-10  7:54   ` [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX Stefan Roese
  6 siblings, 2 replies; 34+ messages in thread
From: Marek Behún @ 2021-06-07 14:34 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár, Marek Behún

Add nodes for SPI NOR partitions to the device tree of Turris MOX, as
are in Linux' device tree.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 arch/arm/dts/armada-3720-turris-mox.dts | 31 +++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts
index 741b0eeeee..f47ced05c5 100644
--- a/arch/arm/dts/armada-3720-turris-mox.dts
+++ b/arch/arm/dts/armada-3720-turris-mox.dts
@@ -164,6 +164,37 @@
 		reg = <0>;
 		spi-max-frequency = <20000000>;
 		m25p,fast-read;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "secure-firmware";
+				reg = <0x0 0x20000>;
+			};
+
+			partition@20000 {
+				label = "a53-firmware";
+				reg = <0x20000 0x160000>;
+			};
+
+			partition@180000 {
+				label = "u-boot-env";
+				reg = <0x180000 0x10000>;
+			};
+
+			partition@190000 {
+				label = "Rescue system";
+				reg = <0x190000 0x660000>;
+			};
+
+			partition@7f0000 {
+				label = "dtb";
+				reg = <0x7f0000 0x10000>;
+			};
+		};
 	};
 
 	moxtet@1 {
-- 
2.31.1


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

* [PATCH u-boot-marvell v2 6/6] arm: mvebu: turris_mox: enable options for Turris network boot
  2021-06-07 14:34 ` [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX Marek Behún
                     ` (4 preceding siblings ...)
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 5/6] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions Marek Behún
@ 2021-06-07 14:34   ` Marek Behún
  2021-06-08  9:52     ` Pali Rohár
  2021-06-10  5:11     ` Stefan Roese
  2021-06-10  7:54   ` [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX Stefan Roese
  6 siblings, 2 replies; 34+ messages in thread
From: Marek Behún @ 2021-06-07 14:34 UTC (permalink / raw)
  To: Stefan Roese, u-boot; +Cc: Pali Rohár, Marek Behún

Enable configuration options to support Turris network boot. This
includes FIT support and some crypto commands.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 configs/turris_mox_defconfig | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig
index d6d37a3d7d..f93be912c9 100644
--- a/configs/turris_mox_defconfig
+++ b/configs/turris_mox_defconfig
@@ -25,14 +25,17 @@ CONFIG_ARCH_EARLY_INIT_R=y
 CONFIG_MISC_INIT_R=y
 CONFIG_BUTTON=y
 CONFIG_BUTTON_GPIO=y
+CONFIG_CMD_AES=y
 CONFIG_CMD_BUTTON=y
 CONFIG_CMD_CLK=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
+CONFIG_CMD_HASH=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_LED=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PCI=y
+CONFIG_CMD_SHA1SUM=y
 CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_WDT=y
@@ -46,6 +49,11 @@ CONFIG_MAC_PARTITION=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_FIT=y
+CONFIG_FIT_ENABLE_SHA256_SUPPORT=y
+# CONFIG_FIT_SIGNATURE is not set
+CONFIG_FIT_VERBOSE=y
+# CONFIG_FIT_BEST_MATCH is not set
 CONFIG_CLK=y
 CONFIG_CLK_MVEBU=y
 # CONFIG_MVEBU_GPIO is not set
-- 
2.31.1


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

* Re: [PATCH u-boot-marvell v2 1/6] arm: mvebu: dts: turris_mox: add button and LED nodes
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 1/6] arm: mvebu: dts: turris_mox: add button and LED nodes Marek Behún
@ 2021-06-08  9:47     ` Pali Rohár
  2021-06-10  5:06     ` Stefan Roese
  1 sibling, 0 replies; 34+ messages in thread
From: Pali Rohár @ 2021-06-08  9:47 UTC (permalink / raw)
  To: Marek Behún; +Cc: Stefan Roese, u-boot

On Monday 07 June 2021 16:34:46 Marek Behún wrote:
> Add nodes for indicator LED and reset button so that board code can
> implement board factory reset mechanism.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Pali Rohár <pali@kernel.org>

> ---
>  arch/arm/dts/armada-3720-turris-mox.dts | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts
> index 8e0ebf508d..741b0eeeee 100644
> --- a/arch/arm/dts/armada-3720-turris-mox.dts
> +++ b/arch/arm/dts/armada-3720-turris-mox.dts
> @@ -11,6 +11,8 @@
>  /dts-v1/;
>  
>  #include <dt-bindings/gpio/gpio.h>
> +#include <dt-bindings/input/input.h>
> +#include <dt-bindings/leds/common.h>
>  #include "armada-372x.dtsi"
>  
>  / {
> @@ -34,6 +36,28 @@
>  		reg = <0x00000000 0x00000000 0x00000000 0x20000000>;
>  	};
>  
> +	leds {
> +		compatible = "gpio-leds";
> +
> +		led {
> +			gpios = <&gpiosb 21 GPIO_ACTIVE_LOW>;
> +			color = <LED_COLOR_ID_RED>;
> +			function = LED_FUNCTION_ACTIVITY;
> +		};
> +	};
> +
> +	gpio-keys {
> +		compatible = "gpio-keys";
> +
> +		reset {
> +			compatible = "gpio-keys";
> +			label = "reset";
> +			linux,code = <KEY_RESTART>;
> +			gpios = <&gpiosb 20 GPIO_ACTIVE_LOW>;
> +			debounce-interval = <60>;
> +		};
> +	};
> +
>  	reg_usb3_vbus: usb3_vbus@0 {
>  		compatible = "regulator-fixed";
>  		regulator-name = "usb3-vbus";
> -- 
> 2.31.1
> 

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

* Re: [PATCH u-boot-marvell v2 2/6] arm: mvebu: turris_mox: add support for board rescue mode
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 2/6] arm: mvebu: turris_mox: add support for board rescue mode Marek Behún
@ 2021-06-08  9:48     ` Pali Rohár
  2021-06-10  5:09     ` Stefan Roese
  1 sibling, 0 replies; 34+ messages in thread
From: Pali Rohár @ 2021-06-08  9:48 UTC (permalink / raw)
  To: Marek Behún; +Cc: Stefan Roese, u-boot

On Monday 07 June 2021 16:34:47 Marek Behún wrote:
> Add necessary config options and board code to support board factory
> reset / rescue mode on Turris MOX.
> 
> In order to also support invoking rescue mode from U-Boot console,
> without having to press the factory reset button, put the rescue command
> into `bootcmd_rescue` default environment variable. When factory reset
> button is pressed, invoke rescue mode via distroboot by setting
> `boot_targets` to `rescue`.
> 
> Rescue boot from console can be invoked by running
>   run bootcmd_rescue
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Pali Rohár <pali@kernel.org>

> ---
>  board/CZ.NIC/turris_mox/turris_mox.c | 71 ++++++++++++++++++++++++++++
>  configs/turris_mox_defconfig         |  6 +++
>  include/configs/turris_mox.h         |  9 ++++
>  3 files changed, 86 insertions(+)
> 
> diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c
> index 15cbf92550..a78f33661e 100644
> --- a/board/CZ.NIC/turris_mox/turris_mox.c
> +++ b/board/CZ.NIC/turris_mox/turris_mox.c
> @@ -10,11 +10,13 @@
>  #include <asm/global_data.h>
>  #include <asm/io.h>
>  #include <asm/gpio.h>
> +#include <button.h>
>  #include <clk.h>
>  #include <dm.h>
>  #include <env.h>
>  #include <fdt_support.h>
>  #include <init.h>
> +#include <led.h>
>  #include <linux/delay.h>
>  #include <linux/libfdt.h>
>  #include <linux/string.h>
> @@ -44,6 +46,8 @@
>  #define SFP_GPIO_PATH	"/soc/internal-regs@d0000000/spi@10600/moxtet@1/gpio@0"
>  #define PCIE_PATH	"/soc/pcie@d0070000"
>  #define SFP_PATH	"/sfp"
> +#define LED_PATH	"/leds/led"
> +#define BUTTON_PATH	"/gpio-keys/reset"
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -373,6 +377,71 @@ int misc_init_r(void)
>  	return 0;
>  }
>  
> +static bool read_reset_button(void)
> +{
> +	struct udevice *button, *led;
> +	int i;
> +
> +	if (device_get_global_by_ofnode(ofnode_path(BUTTON_PATH), &button)) {
> +		printf("Cannot find reset button!\n");
> +		return false;
> +	}
> +
> +	if (device_get_global_by_ofnode(ofnode_path(LED_PATH), &led)) {
> +		printf("Cannot find status LED!\n");
> +		return false;
> +	}
> +
> +	led_set_state(led, LEDST_ON);
> +
> +	for (i = 0; i < 21; ++i) {
> +		if (button_get_state(button) != BUTTON_ON)
> +			return false;
> +		if (i < 20)
> +			mdelay(50);
> +	}
> +
> +	led_set_state(led, LEDST_OFF);
> +
> +	return true;
> +}
> +
> +static void handle_reset_button(void)
> +{
> +	if (read_reset_button()) {
> +		const char * const vars[3] = {
> +			"bootcmd",
> +			"bootcmd_rescue",
> +			"distro_bootcmd",
> +		};
> +
> +		/*
> +		 * Set the above envs to their default values, in case the user
> +		 * managed to break them.
> +		 */
> +		env_set_default_vars(3, (char * const *)vars, 0);
> +
> +		/* Ensure bootcmd_rescue is used by distroboot */
> +		env_set("boot_targets", "rescue");
> +
> +		printf("RESET button was pressed, overwriting boot_targets!\n");
> +	} else {
> +		/*
> +		 * In case the user somehow managed to save environment with
> +		 * boot_targets=rescue, reset boot_targets to default value.
> +		 * This could happen in subsequent commands if bootcmd_rescue
> +		 * failed.
> +		 */
> +		if (!strcmp(env_get("boot_targets"), "rescue")) {
> +			const char * const vars[1] = {
> +				"boot_targets",
> +			};
> +
> +			env_set_default_vars(1, (char * const *)vars, 0);
> +		}
> +	}
> +}
> +
>  static void mox_print_info(void)
>  {
>  	int ret, board_version, ram_size;
> @@ -543,6 +612,8 @@ int last_stage_init(void)
>  
>  	printf("\n");
>  
> +	handle_reset_button();
> +
>  	return 0;
>  }
>  
> diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig
> index 75524babbc..d6d37a3d7d 100644
> --- a/configs/turris_mox_defconfig
> +++ b/configs/turris_mox_defconfig
> @@ -23,10 +23,14 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
>  # CONFIG_DISPLAY_BOARDINFO is not set
>  CONFIG_ARCH_EARLY_INIT_R=y
>  CONFIG_MISC_INIT_R=y
> +CONFIG_BUTTON=y
> +CONFIG_BUTTON_GPIO=y
> +CONFIG_CMD_BUTTON=y
>  CONFIG_CMD_CLK=y
>  # CONFIG_CMD_FLASH is not set
>  CONFIG_CMD_GPIO=y
>  CONFIG_CMD_I2C=y
> +CONFIG_CMD_LED=y
>  CONFIG_CMD_MMC=y
>  CONFIG_CMD_PCI=y
>  CONFIG_CMD_SPI=y
> @@ -46,6 +50,8 @@ CONFIG_CLK=y
>  CONFIG_CLK_MVEBU=y
>  # CONFIG_MVEBU_GPIO is not set
>  CONFIG_DM_I2C=y
> +CONFIG_LED=y
> +CONFIG_LED_GPIO=y
>  CONFIG_MISC=y
>  CONFIG_MMC_SDHCI=y
>  CONFIG_MMC_SDHCI_SDMA=y
> diff --git a/include/configs/turris_mox.h b/include/configs/turris_mox.h
> index 51445ec60a..b148b1621a 100644
> --- a/include/configs/turris_mox.h
> +++ b/include/configs/turris_mox.h
> @@ -75,12 +75,21 @@
>  
>  #include <config_distro_bootcmd.h>
>  
> +#define TURRIS_MOX_BOOTCMD_RESCUE \
> +	"setenv bootargs \"console=ttyMV0,115200 " \
> +			  "earlycon=ar3700_uart,0xd0012000\" && " \
> +	"sf probe && " \
> +	"sf read 0x5000000 0x190000 && " \
> +	"lzmadec 0x5000000 0x5800000 && " \
> +	"bootm 0x5800000"
> +
>  #define CONFIG_EXTRA_ENV_SETTINGS	\
>  	"scriptaddr=0x4d00000\0"	\
>  	"pxefile_addr_r=0x4e00000\0"	\
>  	"fdt_addr_r=0x4f00000\0"	\
>  	"kernel_addr_r=0x5000000\0"	\
>  	"ramdisk_addr_r=0x8000000\0"	\
> +	"bootcmd_rescue=" TURRIS_MOX_BOOTCMD_RESCUE "\0" \
>  	BOOTENV
>  
>  #endif /* _CONFIG_TURRIS_MOX_H */
> -- 
> 2.31.1
> 

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

* Re: [PATCH u-boot-marvell v2 3/6] arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 3/6] arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue Marek Behún
@ 2021-06-08  9:49     ` Pali Rohár
  2021-06-10  5:09     ` Stefan Roese
  1 sibling, 0 replies; 34+ messages in thread
From: Pali Rohár @ 2021-06-08  9:49 UTC (permalink / raw)
  To: Marek Behún; +Cc: Stefan Roese, u-boot

On Monday 07 June 2021 16:34:48 Marek Behún wrote:
> Configure blinking on ethernet PHY LEDs on the MOX A board when entering
> rescue mode via reset button.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Pali Rohár <pali@kernel.org>

> ---
>  board/CZ.NIC/turris_mox/turris_mox.c | 35 ++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c
> index a78f33661e..44c272c7cb 100644
> --- a/board/CZ.NIC/turris_mox/turris_mox.c
> +++ b/board/CZ.NIC/turris_mox/turris_mox.c
> @@ -377,6 +377,38 @@ int misc_init_r(void)
>  	return 0;
>  }
>  
> +static void mox_phy_modify(struct phy_device *phydev, int page, int reg,
> +			   u16 mask, u16 set)
> +{
> +	int val;
> +
> +	val = phydev->drv->readext(phydev, MDIO_DEVAD_NONE, page, reg);
> +	val &= ~mask;
> +	val |= set;
> +	phydev->drv->writeext(phydev, MDIO_DEVAD_NONE, page, reg, val);
> +}
> +
> +static void mox_phy_leds_start_blinking(void)
> +{
> +	struct phy_device *phydev;
> +	struct mii_dev *bus;
> +
> +	bus = miiphy_get_dev_by_name("neta@30000");
> +	if (!bus) {
> +		printf("Cannot get MDIO bus device!\n");
> +		return;
> +	}
> +
> +	phydev = phy_find_by_mask(bus, BIT(1), PHY_INTERFACE_MODE_RGMII);
> +	if (!phydev) {
> +		printf("Cannot get ethernet PHY!\n");
> +		return;
> +	}
> +
> +	mox_phy_modify(phydev, 3, 0x12, 0x700, 0x400);
> +	mox_phy_modify(phydev, 3, 0x10, 0xff, 0xbb);
> +}
> +
>  static bool read_reset_button(void)
>  {
>  	struct udevice *button, *led;
> @@ -424,6 +456,9 @@ static void handle_reset_button(void)
>  		/* Ensure bootcmd_rescue is used by distroboot */
>  		env_set("boot_targets", "rescue");
>  
> +		/* start blinking PHY LEDs */
> +		mox_phy_leds_start_blinking();
> +
>  		printf("RESET button was pressed, overwriting boot_targets!\n");
>  	} else {
>  		/*
> -- 
> 2.31.1
> 

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

* Re: [PATCH u-boot-marvell v2 4/6] arm: mvebu: configs: turris_mox: add fdtfile default env variable
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 4/6] arm: mvebu: configs: turris_mox: add fdtfile default env variable Marek Behún
@ 2021-06-08  9:50     ` Pali Rohár
  2021-06-10  5:10     ` Stefan Roese
  1 sibling, 0 replies; 34+ messages in thread
From: Pali Rohár @ 2021-06-08  9:50 UTC (permalink / raw)
  To: Marek Behún; +Cc: Stefan Roese, u-boot

On Monday 07 June 2021 16:34:49 Marek Behún wrote:
> Add default fdtfile environment variable with value
> marvell/armada-3720-turris-mox.dtb.
> 
> This can be useful for some boot scenarios.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Pali Rohár <pali@kernel.org>

> ---
>  include/configs/turris_mox.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/configs/turris_mox.h b/include/configs/turris_mox.h
> index b148b1621a..9c021a1ef9 100644
> --- a/include/configs/turris_mox.h
> +++ b/include/configs/turris_mox.h
> @@ -89,6 +89,7 @@
>  	"fdt_addr_r=0x4f00000\0"	\
>  	"kernel_addr_r=0x5000000\0"	\
>  	"ramdisk_addr_r=0x8000000\0"	\
> +	"fdtfile=marvell/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
>  	"bootcmd_rescue=" TURRIS_MOX_BOOTCMD_RESCUE "\0" \
>  	BOOTENV
>  
> -- 
> 2.31.1
> 

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

* Re: [PATCH u-boot-marvell v2 5/6] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 5/6] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions Marek Behún
@ 2021-06-08  9:51     ` Pali Rohár
  2021-06-10  5:12       ` Stefan Roese
  2021-06-10  5:11     ` Stefan Roese
  1 sibling, 1 reply; 34+ messages in thread
From: Pali Rohár @ 2021-06-08  9:51 UTC (permalink / raw)
  To: Marek Behún; +Cc: Stefan Roese, u-boot

On Monday 07 June 2021 16:34:50 Marek Behún wrote:
> Add nodes for SPI NOR partitions to the device tree of Turris MOX, as
> are in Linux' device tree.

This patch is not needed (for now) as U-Boot cannot parse SPI NOR
partitions from DT yet. U-Boot for SPI NOR currently supports specifying
partitions only via CONFIG_MTDPARTS_DEFAULT compile option.

> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  arch/arm/dts/armada-3720-turris-mox.dts | 31 +++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts
> index 741b0eeeee..f47ced05c5 100644
> --- a/arch/arm/dts/armada-3720-turris-mox.dts
> +++ b/arch/arm/dts/armada-3720-turris-mox.dts
> @@ -164,6 +164,37 @@
>  		reg = <0>;
>  		spi-max-frequency = <20000000>;
>  		m25p,fast-read;
> +
> +		partitions {
> +			compatible = "fixed-partitions";
> +			#address-cells = <1>;
> +			#size-cells = <1>;
> +
> +			partition@0 {
> +				label = "secure-firmware";
> +				reg = <0x0 0x20000>;
> +			};
> +
> +			partition@20000 {
> +				label = "a53-firmware";
> +				reg = <0x20000 0x160000>;
> +			};
> +
> +			partition@180000 {
> +				label = "u-boot-env";
> +				reg = <0x180000 0x10000>;
> +			};
> +
> +			partition@190000 {
> +				label = "Rescue system";
> +				reg = <0x190000 0x660000>;
> +			};
> +
> +			partition@7f0000 {
> +				label = "dtb";
> +				reg = <0x7f0000 0x10000>;
> +			};
> +		};
>  	};
>  
>  	moxtet@1 {
> -- 
> 2.31.1
> 

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

* Re: [PATCH u-boot-marvell v2 6/6] arm: mvebu: turris_mox: enable options for Turris network boot
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 6/6] arm: mvebu: turris_mox: enable options for Turris network boot Marek Behún
@ 2021-06-08  9:52     ` Pali Rohár
  2021-06-10  5:11     ` Stefan Roese
  1 sibling, 0 replies; 34+ messages in thread
From: Pali Rohár @ 2021-06-08  9:52 UTC (permalink / raw)
  To: Marek Behún; +Cc: Stefan Roese, u-boot

On Monday 07 June 2021 16:34:51 Marek Behún wrote:
> Enable configuration options to support Turris network boot. This
> includes FIT support and some crypto commands.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Pali Rohár <pali@kernel.org>

> ---
>  configs/turris_mox_defconfig | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig
> index d6d37a3d7d..f93be912c9 100644
> --- a/configs/turris_mox_defconfig
> +++ b/configs/turris_mox_defconfig
> @@ -25,14 +25,17 @@ CONFIG_ARCH_EARLY_INIT_R=y
>  CONFIG_MISC_INIT_R=y
>  CONFIG_BUTTON=y
>  CONFIG_BUTTON_GPIO=y
> +CONFIG_CMD_AES=y
>  CONFIG_CMD_BUTTON=y
>  CONFIG_CMD_CLK=y
>  # CONFIG_CMD_FLASH is not set
>  CONFIG_CMD_GPIO=y
> +CONFIG_CMD_HASH=y
>  CONFIG_CMD_I2C=y
>  CONFIG_CMD_LED=y
>  CONFIG_CMD_MMC=y
>  CONFIG_CMD_PCI=y
> +CONFIG_CMD_SHA1SUM=y
>  CONFIG_CMD_SPI=y
>  CONFIG_CMD_USB=y
>  CONFIG_CMD_WDT=y
> @@ -46,6 +49,11 @@ CONFIG_MAC_PARTITION=y
>  CONFIG_ENV_OVERWRITE=y
>  CONFIG_ENV_IS_IN_SPI_FLASH=y
>  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> +CONFIG_FIT=y
> +CONFIG_FIT_ENABLE_SHA256_SUPPORT=y
> +# CONFIG_FIT_SIGNATURE is not set
> +CONFIG_FIT_VERBOSE=y
> +# CONFIG_FIT_BEST_MATCH is not set
>  CONFIG_CLK=y
>  CONFIG_CLK_MVEBU=y
>  # CONFIG_MVEBU_GPIO is not set
> -- 
> 2.31.1
> 

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

* Re: [PATCH u-boot-marvell v2 1/6] arm: mvebu: dts: turris_mox: add button and LED nodes
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 1/6] arm: mvebu: dts: turris_mox: add button and LED nodes Marek Behún
  2021-06-08  9:47     ` Pali Rohár
@ 2021-06-10  5:06     ` Stefan Roese
  1 sibling, 0 replies; 34+ messages in thread
From: Stefan Roese @ 2021-06-10  5:06 UTC (permalink / raw)
  To: Marek Behún, u-boot; +Cc: Pali Rohár

On 07.06.21 16:34, Marek Behún wrote:
> Add nodes for indicator LED and reset button so that board code can
> implement board factory reset mechanism.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   arch/arm/dts/armada-3720-turris-mox.dts | 24 ++++++++++++++++++++++++
>   1 file changed, 24 insertions(+)
> 
> diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts
> index 8e0ebf508d..741b0eeeee 100644
> --- a/arch/arm/dts/armada-3720-turris-mox.dts
> +++ b/arch/arm/dts/armada-3720-turris-mox.dts
> @@ -11,6 +11,8 @@
>   /dts-v1/;
>   
>   #include <dt-bindings/gpio/gpio.h>
> +#include <dt-bindings/input/input.h>
> +#include <dt-bindings/leds/common.h>
>   #include "armada-372x.dtsi"
>   
>   / {
> @@ -34,6 +36,28 @@
>   		reg = <0x00000000 0x00000000 0x00000000 0x20000000>;
>   	};
>   
> +	leds {
> +		compatible = "gpio-leds";
> +
> +		led {
> +			gpios = <&gpiosb 21 GPIO_ACTIVE_LOW>;
> +			color = <LED_COLOR_ID_RED>;
> +			function = LED_FUNCTION_ACTIVITY;
> +		};
> +	};
> +
> +	gpio-keys {
> +		compatible = "gpio-keys";
> +
> +		reset {
> +			compatible = "gpio-keys";
> +			label = "reset";
> +			linux,code = <KEY_RESTART>;
> +			gpios = <&gpiosb 20 GPIO_ACTIVE_LOW>;
> +			debounce-interval = <60>;
> +		};
> +	};
> +
>   	reg_usb3_vbus: usb3_vbus@0 {
>   		compatible = "regulator-fixed";
>   		regulator-name = "usb3-vbus";
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH u-boot-marvell v2 2/6] arm: mvebu: turris_mox: add support for board rescue mode
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 2/6] arm: mvebu: turris_mox: add support for board rescue mode Marek Behún
  2021-06-08  9:48     ` Pali Rohár
@ 2021-06-10  5:09     ` Stefan Roese
  1 sibling, 0 replies; 34+ messages in thread
From: Stefan Roese @ 2021-06-10  5:09 UTC (permalink / raw)
  To: Marek Behún, u-boot; +Cc: Pali Rohár

On 07.06.21 16:34, Marek Behún wrote:
> Add necessary config options and board code to support board factory
> reset / rescue mode on Turris MOX.
> 
> In order to also support invoking rescue mode from U-Boot console,
> without having to press the factory reset button, put the rescue command
> into `bootcmd_rescue` default environment variable. When factory reset
> button is pressed, invoke rescue mode via distroboot by setting
> `boot_targets` to `rescue`.
> 
> Rescue boot from console can be invoked by running
>    run bootcmd_rescue
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   board/CZ.NIC/turris_mox/turris_mox.c | 71 ++++++++++++++++++++++++++++
>   configs/turris_mox_defconfig         |  6 +++
>   include/configs/turris_mox.h         |  9 ++++
>   3 files changed, 86 insertions(+)
> 
> diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c
> index 15cbf92550..a78f33661e 100644
> --- a/board/CZ.NIC/turris_mox/turris_mox.c
> +++ b/board/CZ.NIC/turris_mox/turris_mox.c
> @@ -10,11 +10,13 @@
>   #include <asm/global_data.h>
>   #include <asm/io.h>
>   #include <asm/gpio.h>
> +#include <button.h>
>   #include <clk.h>
>   #include <dm.h>
>   #include <env.h>
>   #include <fdt_support.h>
>   #include <init.h>
> +#include <led.h>
>   #include <linux/delay.h>
>   #include <linux/libfdt.h>
>   #include <linux/string.h>
> @@ -44,6 +46,8 @@
>   #define SFP_GPIO_PATH	"/soc/internal-regs@d0000000/spi@10600/moxtet@1/gpio@0"
>   #define PCIE_PATH	"/soc/pcie@d0070000"
>   #define SFP_PATH	"/sfp"
> +#define LED_PATH	"/leds/led"
> +#define BUTTON_PATH	"/gpio-keys/reset"
>   
>   DECLARE_GLOBAL_DATA_PTR;
>   
> @@ -373,6 +377,71 @@ int misc_init_r(void)
>   	return 0;
>   }
>   
> +static bool read_reset_button(void)
> +{
> +	struct udevice *button, *led;
> +	int i;
> +
> +	if (device_get_global_by_ofnode(ofnode_path(BUTTON_PATH), &button)) {
> +		printf("Cannot find reset button!\n");
> +		return false;
> +	}
> +
> +	if (device_get_global_by_ofnode(ofnode_path(LED_PATH), &led)) {
> +		printf("Cannot find status LED!\n");
> +		return false;
> +	}
> +
> +	led_set_state(led, LEDST_ON);
> +
> +	for (i = 0; i < 21; ++i) {
> +		if (button_get_state(button) != BUTTON_ON)
> +			return false;
> +		if (i < 20)
> +			mdelay(50);
> +	}
> +
> +	led_set_state(led, LEDST_OFF);
> +
> +	return true;
> +}
> +
> +static void handle_reset_button(void)
> +{
> +	if (read_reset_button()) {
> +		const char * const vars[3] = {
> +			"bootcmd",
> +			"bootcmd_rescue",
> +			"distro_bootcmd",
> +		};
> +
> +		/*
> +		 * Set the above envs to their default values, in case the user
> +		 * managed to break them.
> +		 */
> +		env_set_default_vars(3, (char * const *)vars, 0);
> +
> +		/* Ensure bootcmd_rescue is used by distroboot */
> +		env_set("boot_targets", "rescue");
> +
> +		printf("RESET button was pressed, overwriting boot_targets!\n");
> +	} else {
> +		/*
> +		 * In case the user somehow managed to save environment with
> +		 * boot_targets=rescue, reset boot_targets to default value.
> +		 * This could happen in subsequent commands if bootcmd_rescue
> +		 * failed.
> +		 */
> +		if (!strcmp(env_get("boot_targets"), "rescue")) {
> +			const char * const vars[1] = {
> +				"boot_targets",
> +			};
> +
> +			env_set_default_vars(1, (char * const *)vars, 0);
> +		}
> +	}
> +}
> +
>   static void mox_print_info(void)
>   {
>   	int ret, board_version, ram_size;
> @@ -543,6 +612,8 @@ int last_stage_init(void)
>   
>   	printf("\n");
>   
> +	handle_reset_button();
> +
>   	return 0;
>   }
>   
> diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig
> index 75524babbc..d6d37a3d7d 100644
> --- a/configs/turris_mox_defconfig
> +++ b/configs/turris_mox_defconfig
> @@ -23,10 +23,14 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
>   # CONFIG_DISPLAY_BOARDINFO is not set
>   CONFIG_ARCH_EARLY_INIT_R=y
>   CONFIG_MISC_INIT_R=y
> +CONFIG_BUTTON=y
> +CONFIG_BUTTON_GPIO=y
> +CONFIG_CMD_BUTTON=y
>   CONFIG_CMD_CLK=y
>   # CONFIG_CMD_FLASH is not set
>   CONFIG_CMD_GPIO=y
>   CONFIG_CMD_I2C=y
> +CONFIG_CMD_LED=y
>   CONFIG_CMD_MMC=y
>   CONFIG_CMD_PCI=y
>   CONFIG_CMD_SPI=y
> @@ -46,6 +50,8 @@ CONFIG_CLK=y
>   CONFIG_CLK_MVEBU=y
>   # CONFIG_MVEBU_GPIO is not set
>   CONFIG_DM_I2C=y
> +CONFIG_LED=y
> +CONFIG_LED_GPIO=y
>   CONFIG_MISC=y
>   CONFIG_MMC_SDHCI=y
>   CONFIG_MMC_SDHCI_SDMA=y
> diff --git a/include/configs/turris_mox.h b/include/configs/turris_mox.h
> index 51445ec60a..b148b1621a 100644
> --- a/include/configs/turris_mox.h
> +++ b/include/configs/turris_mox.h
> @@ -75,12 +75,21 @@
>   
>   #include <config_distro_bootcmd.h>
>   
> +#define TURRIS_MOX_BOOTCMD_RESCUE \
> +	"setenv bootargs \"console=ttyMV0,115200 " \
> +			  "earlycon=ar3700_uart,0xd0012000\" && " \
> +	"sf probe && " \
> +	"sf read 0x5000000 0x190000 && " \
> +	"lzmadec 0x5000000 0x5800000 && " \
> +	"bootm 0x5800000"
> +
>   #define CONFIG_EXTRA_ENV_SETTINGS	\
>   	"scriptaddr=0x4d00000\0"	\
>   	"pxefile_addr_r=0x4e00000\0"	\
>   	"fdt_addr_r=0x4f00000\0"	\
>   	"kernel_addr_r=0x5000000\0"	\
>   	"ramdisk_addr_r=0x8000000\0"	\
> +	"bootcmd_rescue=" TURRIS_MOX_BOOTCMD_RESCUE "\0" \
>   	BOOTENV
>   
>   #endif /* _CONFIG_TURRIS_MOX_H */
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH u-boot-marvell v2 3/6] arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 3/6] arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue Marek Behún
  2021-06-08  9:49     ` Pali Rohár
@ 2021-06-10  5:09     ` Stefan Roese
  1 sibling, 0 replies; 34+ messages in thread
From: Stefan Roese @ 2021-06-10  5:09 UTC (permalink / raw)
  To: Marek Behún, u-boot; +Cc: Pali Rohár

On 07.06.21 16:34, Marek Behún wrote:
> Configure blinking on ethernet PHY LEDs on the MOX A board when entering
> rescue mode via reset button.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   board/CZ.NIC/turris_mox/turris_mox.c | 35 ++++++++++++++++++++++++++++
>   1 file changed, 35 insertions(+)
> 
> diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c
> index a78f33661e..44c272c7cb 100644
> --- a/board/CZ.NIC/turris_mox/turris_mox.c
> +++ b/board/CZ.NIC/turris_mox/turris_mox.c
> @@ -377,6 +377,38 @@ int misc_init_r(void)
>   	return 0;
>   }
>   
> +static void mox_phy_modify(struct phy_device *phydev, int page, int reg,
> +			   u16 mask, u16 set)
> +{
> +	int val;
> +
> +	val = phydev->drv->readext(phydev, MDIO_DEVAD_NONE, page, reg);
> +	val &= ~mask;
> +	val |= set;
> +	phydev->drv->writeext(phydev, MDIO_DEVAD_NONE, page, reg, val);
> +}
> +
> +static void mox_phy_leds_start_blinking(void)
> +{
> +	struct phy_device *phydev;
> +	struct mii_dev *bus;
> +
> +	bus = miiphy_get_dev_by_name("neta@30000");
> +	if (!bus) {
> +		printf("Cannot get MDIO bus device!\n");
> +		return;
> +	}
> +
> +	phydev = phy_find_by_mask(bus, BIT(1), PHY_INTERFACE_MODE_RGMII);
> +	if (!phydev) {
> +		printf("Cannot get ethernet PHY!\n");
> +		return;
> +	}
> +
> +	mox_phy_modify(phydev, 3, 0x12, 0x700, 0x400);
> +	mox_phy_modify(phydev, 3, 0x10, 0xff, 0xbb);
> +}
> +
>   static bool read_reset_button(void)
>   {
>   	struct udevice *button, *led;
> @@ -424,6 +456,9 @@ static void handle_reset_button(void)
>   		/* Ensure bootcmd_rescue is used by distroboot */
>   		env_set("boot_targets", "rescue");
>   
> +		/* start blinking PHY LEDs */
> +		mox_phy_leds_start_blinking();
> +
>   		printf("RESET button was pressed, overwriting boot_targets!\n");
>   	} else {
>   		/*
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH u-boot-marvell v2 4/6] arm: mvebu: configs: turris_mox: add fdtfile default env variable
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 4/6] arm: mvebu: configs: turris_mox: add fdtfile default env variable Marek Behún
  2021-06-08  9:50     ` Pali Rohár
@ 2021-06-10  5:10     ` Stefan Roese
  1 sibling, 0 replies; 34+ messages in thread
From: Stefan Roese @ 2021-06-10  5:10 UTC (permalink / raw)
  To: Marek Behún, u-boot; +Cc: Pali Rohár

On 07.06.21 16:34, Marek Behún wrote:
> Add default fdtfile environment variable with value
> marvell/armada-3720-turris-mox.dtb.
> 
> This can be useful for some boot scenarios.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   include/configs/turris_mox.h | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/include/configs/turris_mox.h b/include/configs/turris_mox.h
> index b148b1621a..9c021a1ef9 100644
> --- a/include/configs/turris_mox.h
> +++ b/include/configs/turris_mox.h
> @@ -89,6 +89,7 @@
>   	"fdt_addr_r=0x4f00000\0"	\
>   	"kernel_addr_r=0x5000000\0"	\
>   	"ramdisk_addr_r=0x8000000\0"	\
> +	"fdtfile=marvell/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
>   	"bootcmd_rescue=" TURRIS_MOX_BOOTCMD_RESCUE "\0" \
>   	BOOTENV
>   
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH u-boot-marvell v2 5/6] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 5/6] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions Marek Behún
  2021-06-08  9:51     ` Pali Rohár
@ 2021-06-10  5:11     ` Stefan Roese
  1 sibling, 0 replies; 34+ messages in thread
From: Stefan Roese @ 2021-06-10  5:11 UTC (permalink / raw)
  To: Marek Behún, u-boot; +Cc: Pali Rohár

On 07.06.21 16:34, Marek Behún wrote:
> Add nodes for SPI NOR partitions to the device tree of Turris MOX, as
> are in Linux' device tree.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   arch/arm/dts/armada-3720-turris-mox.dts | 31 +++++++++++++++++++++++++
>   1 file changed, 31 insertions(+)
> 
> diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts
> index 741b0eeeee..f47ced05c5 100644
> --- a/arch/arm/dts/armada-3720-turris-mox.dts
> +++ b/arch/arm/dts/armada-3720-turris-mox.dts
> @@ -164,6 +164,37 @@
>   		reg = <0>;
>   		spi-max-frequency = <20000000>;
>   		m25p,fast-read;
> +
> +		partitions {
> +			compatible = "fixed-partitions";
> +			#address-cells = <1>;
> +			#size-cells = <1>;
> +
> +			partition@0 {
> +				label = "secure-firmware";
> +				reg = <0x0 0x20000>;
> +			};
> +
> +			partition@20000 {
> +				label = "a53-firmware";
> +				reg = <0x20000 0x160000>;
> +			};
> +
> +			partition@180000 {
> +				label = "u-boot-env";
> +				reg = <0x180000 0x10000>;
> +			};
> +
> +			partition@190000 {
> +				label = "Rescue system";
> +				reg = <0x190000 0x660000>;
> +			};
> +
> +			partition@7f0000 {
> +				label = "dtb";
> +				reg = <0x7f0000 0x10000>;
> +			};
> +		};
>   	};
>   
>   	moxtet@1 {
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH u-boot-marvell v2 6/6] arm: mvebu: turris_mox: enable options for Turris network boot
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 6/6] arm: mvebu: turris_mox: enable options for Turris network boot Marek Behún
  2021-06-08  9:52     ` Pali Rohár
@ 2021-06-10  5:11     ` Stefan Roese
  1 sibling, 0 replies; 34+ messages in thread
From: Stefan Roese @ 2021-06-10  5:11 UTC (permalink / raw)
  To: Marek Behún, u-boot; +Cc: Pali Rohár

On 07.06.21 16:34, Marek Behún wrote:
> Enable configuration options to support Turris network boot. This
> includes FIT support and some crypto commands.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   configs/turris_mox_defconfig | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig
> index d6d37a3d7d..f93be912c9 100644
> --- a/configs/turris_mox_defconfig
> +++ b/configs/turris_mox_defconfig
> @@ -25,14 +25,17 @@ CONFIG_ARCH_EARLY_INIT_R=y
>   CONFIG_MISC_INIT_R=y
>   CONFIG_BUTTON=y
>   CONFIG_BUTTON_GPIO=y
> +CONFIG_CMD_AES=y
>   CONFIG_CMD_BUTTON=y
>   CONFIG_CMD_CLK=y
>   # CONFIG_CMD_FLASH is not set
>   CONFIG_CMD_GPIO=y
> +CONFIG_CMD_HASH=y
>   CONFIG_CMD_I2C=y
>   CONFIG_CMD_LED=y
>   CONFIG_CMD_MMC=y
>   CONFIG_CMD_PCI=y
> +CONFIG_CMD_SHA1SUM=y
>   CONFIG_CMD_SPI=y
>   CONFIG_CMD_USB=y
>   CONFIG_CMD_WDT=y
> @@ -46,6 +49,11 @@ CONFIG_MAC_PARTITION=y
>   CONFIG_ENV_OVERWRITE=y
>   CONFIG_ENV_IS_IN_SPI_FLASH=y
>   CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> +CONFIG_FIT=y
> +CONFIG_FIT_ENABLE_SHA256_SUPPORT=y
> +# CONFIG_FIT_SIGNATURE is not set
> +CONFIG_FIT_VERBOSE=y
> +# CONFIG_FIT_BEST_MATCH is not set
>   CONFIG_CLK=y
>   CONFIG_CLK_MVEBU=y
>   # CONFIG_MVEBU_GPIO is not set
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH u-boot-marvell v2 5/6] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions
  2021-06-08  9:51     ` Pali Rohár
@ 2021-06-10  5:12       ` Stefan Roese
  2021-06-10 14:07         ` Pali Rohár
  0 siblings, 1 reply; 34+ messages in thread
From: Stefan Roese @ 2021-06-10  5:12 UTC (permalink / raw)
  To: Pali Rohár, Marek Behún; +Cc: u-boot

Hi Pali,

On 08.06.21 11:51, Pali Rohár wrote:
> On Monday 07 June 2021 16:34:50 Marek Behún wrote:
>> Add nodes for SPI NOR partitions to the device tree of Turris MOX, as
>> are in Linux' device tree.
> 
> This patch is not needed (for now) as U-Boot cannot parse SPI NOR
> partitions from DT yet. U-Boot for SPI NOR currently supports specifying
> partitions only via CONFIG_MTDPARTS_DEFAULT compile option.

But do you agree that this patch "does not hurt"? I'm asking to check,
if I should include this patch in a potential pull request.

Thanks,
Stefan

>> Signed-off-by: Marek Behún <marek.behun@nic.cz>
>> ---
>>   arch/arm/dts/armada-3720-turris-mox.dts | 31 +++++++++++++++++++++++++
>>   1 file changed, 31 insertions(+)
>>
>> diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts
>> index 741b0eeeee..f47ced05c5 100644
>> --- a/arch/arm/dts/armada-3720-turris-mox.dts
>> +++ b/arch/arm/dts/armada-3720-turris-mox.dts
>> @@ -164,6 +164,37 @@
>>   		reg = <0>;
>>   		spi-max-frequency = <20000000>;
>>   		m25p,fast-read;
>> +
>> +		partitions {
>> +			compatible = "fixed-partitions";
>> +			#address-cells = <1>;
>> +			#size-cells = <1>;
>> +
>> +			partition@0 {
>> +				label = "secure-firmware";
>> +				reg = <0x0 0x20000>;
>> +			};
>> +
>> +			partition@20000 {
>> +				label = "a53-firmware";
>> +				reg = <0x20000 0x160000>;
>> +			};
>> +
>> +			partition@180000 {
>> +				label = "u-boot-env";
>> +				reg = <0x180000 0x10000>;
>> +			};
>> +
>> +			partition@190000 {
>> +				label = "Rescue system";
>> +				reg = <0x190000 0x660000>;
>> +			};
>> +
>> +			partition@7f0000 {
>> +				label = "dtb";
>> +				reg = <0x7f0000 0x10000>;
>> +			};
>> +		};
>>   	};
>>   
>>   	moxtet@1 {
>> -- 
>> 2.31.1
>>


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX
  2021-06-07 14:34 ` [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX Marek Behún
                     ` (5 preceding siblings ...)
  2021-06-07 14:34   ` [PATCH u-boot-marvell v2 6/6] arm: mvebu: turris_mox: enable options for Turris network boot Marek Behún
@ 2021-06-10  7:54   ` Stefan Roese
  6 siblings, 0 replies; 34+ messages in thread
From: Stefan Roese @ 2021-06-10  7:54 UTC (permalink / raw)
  To: Marek Behún, u-boot; +Cc: Pali Rohár

On 07.06.21 16:34, Marek Behún wrote:
> Hello Stefan,
> 
> Here are some changes for Turris MOX (v2):
> - dts changes
> - more config options enabled
> - rescue mode support added
> 
> If it is possible, since this touches only our device, we would like
> this to be also merged for v2021.07 (once reviewed by you and Pali).

Done. ;)

Applied to u-boot-marvell/master

Thanks,
Stefan


> Changes since v1:
> - use constant addresses instead of ${kernel_addr_r} and
>    ${ramdisk_addr_r} in bootcmd_rescue, so that this command won't fail
>    if those addresses are changed
> - dropped last patch changing internal-regs node name in dts. We don't
>    need this now, let's do this in the future once we will be aligning
>    U-Boot's DTS with kernel's DTS
> 
> Marek Behún (6):
>    arm: mvebu: dts: turris_mox: add button and LED nodes
>    arm: mvebu: turris_mox: add support for board rescue mode
>    arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue
>    arm: mvebu: configs: turris_mox: add fdtfile default env variable
>    arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions
>    arm: mvebu: turris_mox: enable options for Turris network boot
> 
>   arch/arm/dts/armada-3720-turris-mox.dts |  55 ++++++++++++
>   board/CZ.NIC/turris_mox/turris_mox.c    | 106 ++++++++++++++++++++++++
>   configs/turris_mox_defconfig            |  14 ++++
>   include/configs/turris_mox.h            |  10 +++
>   4 files changed, 185 insertions(+)
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH u-boot-marvell v2 5/6] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions
  2021-06-10  5:12       ` Stefan Roese
@ 2021-06-10 14:07         ` Pali Rohár
  2021-06-10 14:28           ` Marek Behun
  0 siblings, 1 reply; 34+ messages in thread
From: Pali Rohár @ 2021-06-10 14:07 UTC (permalink / raw)
  To: Stefan Roese; +Cc: Marek Behún, u-boot

On Thursday 10 June 2021 07:12:53 Stefan Roese wrote:
> Hi Pali,
> 
> On 08.06.21 11:51, Pali Rohár wrote:
> > On Monday 07 June 2021 16:34:50 Marek Behún wrote:
> > > Add nodes for SPI NOR partitions to the device tree of Turris MOX, as
> > > are in Linux' device tree.
> > 
> > This patch is not needed (for now) as U-Boot cannot parse SPI NOR
> > partitions from DT yet. U-Boot for SPI NOR currently supports specifying
> > partitions only via CONFIG_MTDPARTS_DEFAULT compile option.
> 
> But do you agree that this patch "does not hurt"? I'm asking to check,
> if I should include this patch in a potential pull request.

Yes. This does not hurt and currently does nothing. And after patches
for SPI NOR parsing are merged then this patch can be useful.

So if you are fine with merging which which currently does noting and in
future is useful then there is no problem with it.

> 
> Thanks,
> Stefan
> 
> > > Signed-off-by: Marek Behún <marek.behun@nic.cz>
> > > ---
> > >   arch/arm/dts/armada-3720-turris-mox.dts | 31 +++++++++++++++++++++++++
> > >   1 file changed, 31 insertions(+)
> > > 
> > > diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts
> > > index 741b0eeeee..f47ced05c5 100644
> > > --- a/arch/arm/dts/armada-3720-turris-mox.dts
> > > +++ b/arch/arm/dts/armada-3720-turris-mox.dts
> > > @@ -164,6 +164,37 @@
> > >   		reg = <0>;
> > >   		spi-max-frequency = <20000000>;
> > >   		m25p,fast-read;
> > > +
> > > +		partitions {
> > > +			compatible = "fixed-partitions";
> > > +			#address-cells = <1>;
> > > +			#size-cells = <1>;
> > > +
> > > +			partition@0 {
> > > +				label = "secure-firmware";
> > > +				reg = <0x0 0x20000>;
> > > +			};
> > > +
> > > +			partition@20000 {
> > > +				label = "a53-firmware";
> > > +				reg = <0x20000 0x160000>;
> > > +			};
> > > +
> > > +			partition@180000 {
> > > +				label = "u-boot-env";
> > > +				reg = <0x180000 0x10000>;
> > > +			};
> > > +
> > > +			partition@190000 {
> > > +				label = "Rescue system";
> > > +				reg = <0x190000 0x660000>;
> > > +			};
> > > +
> > > +			partition@7f0000 {
> > > +				label = "dtb";
> > > +				reg = <0x7f0000 0x10000>;
> > > +			};
> > > +		};
> > >   	};
> > >   	moxtet@1 {
> > > -- 
> > > 2.31.1
> > > 
> 
> 
> Viele Grüße,
> Stefan
> 
> -- 
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH u-boot-marvell v2 5/6] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions
  2021-06-10 14:07         ` Pali Rohár
@ 2021-06-10 14:28           ` Marek Behun
  2021-06-11  4:14             ` Stefan Roese
  0 siblings, 1 reply; 34+ messages in thread
From: Marek Behun @ 2021-06-10 14:28 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Stefan Roese, u-boot

On Thu, 10 Jun 2021 16:07:05 +0200
Pali Rohár <pali@kernel.org> wrote:

> On Thursday 10 June 2021 07:12:53 Stefan Roese wrote:
> > Hi Pali,
> > 
> > On 08.06.21 11:51, Pali Rohár wrote:  
> > > On Monday 07 June 2021 16:34:50 Marek Behún wrote:  
> > > > Add nodes for SPI NOR partitions to the device tree of Turris MOX, as
> > > > are in Linux' device tree.  
> > > 
> > > This patch is not needed (for now) as U-Boot cannot parse SPI NOR
> > > partitions from DT yet. U-Boot for SPI NOR currently supports specifying
> > > partitions only via CONFIG_MTDPARTS_DEFAULT compile option.  
> > 
> > But do you agree that this patch "does not hurt"? I'm asking to check,
> > if I should include this patch in a potential pull request.  
> 
> Yes. This does not hurt and currently does nothing. And after patches
> for SPI NOR parsing are merged then this patch can be useful.
> 
> So if you are fine with merging which which currently does noting and in
> future is useful then there is no problem with it.

Moreover this definition is also in kernel's DTS. I am going to try to
work on the U-Boot's A3720 comphy driver so that we can completely
align U-Boot's A3720 DTS files with kernel's.

Marek

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

* Re: [PATCH u-boot-marvell v2 5/6] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions
  2021-06-10 14:28           ` Marek Behun
@ 2021-06-11  4:14             ` Stefan Roese
  0 siblings, 0 replies; 34+ messages in thread
From: Stefan Roese @ 2021-06-11  4:14 UTC (permalink / raw)
  To: Marek Behun, Pali Rohár; +Cc: u-boot

On 10.06.21 16:28, Marek Behun wrote:
> On Thu, 10 Jun 2021 16:07:05 +0200
> Pali Rohár <pali@kernel.org> wrote:
> 
>> On Thursday 10 June 2021 07:12:53 Stefan Roese wrote:
>>> Hi Pali,
>>>
>>> On 08.06.21 11:51, Pali Rohár wrote:
>>>> On Monday 07 June 2021 16:34:50 Marek Behún wrote:
>>>>> Add nodes for SPI NOR partitions to the device tree of Turris MOX, as
>>>>> are in Linux' device tree.
>>>>
>>>> This patch is not needed (for now) as U-Boot cannot parse SPI NOR
>>>> partitions from DT yet. U-Boot for SPI NOR currently supports specifying
>>>> partitions only via CONFIG_MTDPARTS_DEFAULT compile option.
>>>
>>> But do you agree that this patch "does not hurt"? I'm asking to check,
>>> if I should include this patch in a potential pull request.
>>
>> Yes. This does not hurt and currently does nothing. And after patches
>> for SPI NOR parsing are merged then this patch can be useful.
>>
>> So if you are fine with merging which which currently does noting and in
>> future is useful then there is no problem with it.

It should be available in mainline now.

> Moreover this definition is also in kernel's DTS. I am going to try to
> work on the U-Boot's A3720 comphy driver so that we can completely
> align U-Boot's A3720 DTS files with kernel's.

Perfect. Thanks for working on this.

Thanks,
Stefan

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

end of thread, other threads:[~2021-06-11  4:14 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02 17:09 [PATCH u-boot-marvell 0/7] Changes for Turris MOX Marek Behún
2021-06-02 17:09 ` [PATCH u-boot-marvell 1/7] arm: mvebu: dts: turris_mox: add button and LED nodes Marek Behún
2021-06-02 17:09 ` [PATCH u-boot-marvell 2/7] arm: mvebu: turris_mox: add support for board rescue mode Marek Behún
2021-06-03 15:18   ` Marek Behún
2021-06-02 17:09 ` [PATCH u-boot-marvell 3/7] arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue Marek Behún
2021-06-02 17:09 ` [PATCH u-boot-marvell 4/7] arm: mvebu: configs: turris_mox: add fdtfile default env variable Marek Behún
2021-06-02 17:09 ` [PATCH u-boot-marvell 5/7] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions Marek Behún
2021-06-02 17:10 ` [PATCH u-boot-marvell 6/7] arm: mvebu: turris_mox: enable options for Turris network boot Marek Behún
2021-06-02 17:10 ` [PATCH u-boot-marvell 7/7] arm64: a37xx: dts: rename internal-regs node Marek Behún
2021-06-03 15:20   ` Marek Behún
2021-06-07 14:34 ` [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX Marek Behún
2021-06-07 14:34   ` [PATCH u-boot-marvell v2 1/6] arm: mvebu: dts: turris_mox: add button and LED nodes Marek Behún
2021-06-08  9:47     ` Pali Rohár
2021-06-10  5:06     ` Stefan Roese
2021-06-07 14:34   ` [PATCH u-boot-marvell v2 2/6] arm: mvebu: turris_mox: add support for board rescue mode Marek Behún
2021-06-08  9:48     ` Pali Rohár
2021-06-10  5:09     ` Stefan Roese
2021-06-07 14:34   ` [PATCH u-boot-marvell v2 3/6] arm: mvebu: turris_mox: start blinking PHY LEDs when entering rescue Marek Behún
2021-06-08  9:49     ` Pali Rohár
2021-06-10  5:09     ` Stefan Roese
2021-06-07 14:34   ` [PATCH u-boot-marvell v2 4/6] arm: mvebu: configs: turris_mox: add fdtfile default env variable Marek Behún
2021-06-08  9:50     ` Pali Rohár
2021-06-10  5:10     ` Stefan Roese
2021-06-07 14:34   ` [PATCH u-boot-marvell v2 5/6] arm: mvebu: dts: turris_mox: add nodes for SPI NOR partitions Marek Behún
2021-06-08  9:51     ` Pali Rohár
2021-06-10  5:12       ` Stefan Roese
2021-06-10 14:07         ` Pali Rohár
2021-06-10 14:28           ` Marek Behun
2021-06-11  4:14             ` Stefan Roese
2021-06-10  5:11     ` Stefan Roese
2021-06-07 14:34   ` [PATCH u-boot-marvell v2 6/6] arm: mvebu: turris_mox: enable options for Turris network boot Marek Behún
2021-06-08  9:52     ` Pali Rohár
2021-06-10  5:11     ` Stefan Roese
2021-06-10  7:54   ` [PATCH u-boot-marvell v2 0/6] Changes for Turris MOX Stefan Roese

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.