Skip to contentSkip to conversation

udoo_neo: Convert to watchdog driver model

PATCH Applied Fabio Estevam 1 participant 5 messages Jul 19, 2024 – Jul 22, 2024

Subsystems (3)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH v2 1/4 udoo_neo: Convert to watchdog driver model

Commit 68dcbdd594d4 ("ARM: imx: Add weak default reset_cpu()") caused the 'reset' command in U-Boot to not cause a board reset.

Fix it by switching to the watchdog driver model via sysreset, which is the preferred method for implementing the watchdog reset.

With the watchdog driver model in place, it is no longer needed to have board code to initialize the watchdog, so remove its related board code.

---
Changes since v1:
- Remove board wdog board code.

 arch/arm/dts/imx6sx-udoo-neo-basic-u-boot.dtsi | 12 ++++++++++++
 board/udoo/neo/neo.c                           | 16 ----------------
 configs/udoo_neo_defconfig                     |  3 +++
 3 files changed, 15 insertions(+), 16 deletions(-)
arch/arm/dts/imx6sx-udoo-neo-basic-u-boot.dtsi +12 -0
index b5e1f2b9a16f..7f5a6424bac8 100644
@@ -1,5 +1,13 @@
 // SPDX-License-Identifier: GPL-2.0+
 
+/ {
+	wdt-reboot {
+		compatible = "wdt-reboot";
+		wdt = <&wdog1>;
+		bootph-pre-ram;
+	};
+};
+
 &soc {
 	bootph-all;
 };
@@ -15,3 +23,7 @@
 &uart1 {
 	bootph-all;
 };
+
+&wdog1 {
+	bootph-pre-ram;
+};
board/udoo/neo/neo.c +0 -16
index b435b721e53c..1a0aaecc3328 100644
@@ -57,9 +57,6 @@ enum {
 #define ENET_RX_PAD_CTRL  (PAD_CTL_PKE | PAD_CTL_PUE |          \
 	PAD_CTL_SPEED_MED   | PAD_CTL_SRE_FAST)
 
-#define WDOG_PAD_CTRL (PAD_CTL_PUE | PAD_CTL_PKE | PAD_CTL_SPEED_MED |	\
-	PAD_CTL_DSE_40ohm)
-
 #define BOARD_DETECT_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE |		\
 	PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED |		\
 	PAD_CTL_DSE_34ohm | PAD_CTL_HYS | PAD_CTL_SRE_FAST)
@@ -113,10 +110,6 @@ static iomux_v3_cfg_t const phy_control_pads[] = {
 	MUX_PAD_CTRL(ENET_CLK_PAD_CTRL),
 };
 
-static iomux_v3_cfg_t const wdog_b_pad = {
-	MX6_PAD_GPIO1_IO13__GPIO1_IO_13 | MUX_PAD_CTRL(WDOG_PAD_CTRL),
-};
-
 static iomux_v3_cfg_t const peri_3v3_pads[] = {
 	MX6_PAD_QSPI1A_DATA0__GPIO4_IO_16 | MUX_PAD_CTRL(NO_PAD_CTRL),
 };
@@ -148,15 +141,6 @@ int board_init(void)
 	/* Address of boot parameters */
 	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
 
-	/*
-	 * Because kernel set WDOG_B mux before pad with the commone pinctrl
-	 * framwork now and wdog reset will be triggered once set WDOG_B mux
-	 * with default pad setting, we set pad setting here to workaround this.
-	 * Since imx_iomux_v3_setup_pad also set mux before pad setting, we set
-	 * as GPIO mux firstly here to workaround it.
-	 */
-	imx_iomux_v3_setup_pad(wdog_b_pad);
-
 	/* Enable PERI_3V3, which is used by SD2, ENET, LVDS, BT */
 	imx_iomux_v3_setup_multiple_pads(peri_3v3_pads,
 					 ARRAY_SIZE(peri_3v3_pads));
configs/udoo_neo_defconfig +3 -0
index 4986b4c26260..9f9ad0ad5ec7 100644
@@ -61,5 +61,8 @@ CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_ANATOP=y
 CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_WATCHDOG=y
 CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
+CONFIG_IMX_WATCHDOG=y
Signature · 1 line
2.34.1
author reviewer
#1 lore raw

PATCH v2 2/4 udoo_neo: Select LTO

u-boot.img has grown in such a way that it overwrites the environment region.

Select CONFIG_LTO to help reducing the U-Boot binary size and add a build-time size check to avoid U-Boot to overlap the environment region.

---
Changes since v1:
- Newly introduced.

 configs/udoo_neo_defconfig | 3 +++
 1 file changed, 3 insertions(+)
configs/udoo_neo_defconfig +3 -0
index 9f9ad0ad5ec7..97e3b379835f 100644
@@ -19,6 +19,9 @@ CONFIG_SPL_SERIAL=y
 CONFIG_SPL=y
 CONFIG_SPL_LIBDISK_SUPPORT=y
 # CONFIG_CMD_BMODE is not set
+CONFIG_LTO=y
+CONFIG_HAS_BOARD_SIZE_LIMIT=y
+CONFIG_BOARD_SIZE_LIMIT=523264
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTCOMMAND="run findfdt; run distro_bootcmd"
 CONFIG_SYS_PBSIZE=532
Signature · 1 line
2.34.1
author reviewer
#2 lore raw

PATCH v2 3/4 udoo-neo: Do not print devicetree model

In reply to Fabio Estevam

The udoo_neo_defconfig target supports several board variants. All of these variants use the imx6sx-udoo-neo-basic devicetree in U-Boot.

Currently, the devicetree model as well as the board variant name are shown:

...
Model: UDOO Neo Basic
Board: UDOO Neo FULL
...

Printing the devicetree model that is used internally by U-Boot may confuse users.

Unselect the CONFIG_DISPLAY_BOARDINFO option and move the board printing inside board_init() so that only the real board name that is detected in run-time is printed.

---
Changes since v1:
- Newly introduced.

 board/udoo/neo/neo.c       | 43 +++++++++++++++++---------------------
 configs/udoo_neo_defconfig |  1 +
 2 files changed, 20 insertions(+), 24 deletions(-)
board/udoo/neo/neo.c +19 -24
index 1a0aaecc3328..4cf214bf17c6 100644
@@ -136,8 +136,25 @@ static int setup_fec(void)
 	return enable_fec_anatop_clock(0, ENET_25MHZ);
 }
 
+static char *board_string(int type)
+{
+	switch (type) {
+	case UDOO_NEO_TYPE_BASIC:
+		return "BASIC";
+	case UDOO_NEO_TYPE_BASIC_KS:
+		return "BASICKS";
+	case UDOO_NEO_TYPE_FULL:
+		return "FULL";
+	case UDOO_NEO_TYPE_EXTENDED:
+		return "EXTENDED";
+	}
+	return "UNDEFINED";
+}
+
 int board_init(void)
 {
+	int *board_type = (int *)OCRAM_START;
+
 	/* Address of boot parameters */
 	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
 
@@ -149,6 +166,8 @@ int board_init(void)
 	gpio_request(IMX_GPIO_NR(4, 16), "ncp692");
 	gpio_direction_output(IMX_GPIO_NR(4, 16) , 1);
 
+	printf("Board: UDOO Neo %s\n", board_string(*board_type));
+
 	setup_fec();
 
 	return 0;
@@ -179,30 +198,6 @@ int board_mmc_init(struct bd_info *bis)
 	return fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
 }
 
-static char *board_string(int type)
-{
-	switch (type) {
-	case UDOO_NEO_TYPE_BASIC:
-		return "BASIC";
-	case UDOO_NEO_TYPE_BASIC_KS:
-		return "BASICKS";
-	case UDOO_NEO_TYPE_FULL:
-		return "FULL";
-	case UDOO_NEO_TYPE_EXTENDED:
-		return "EXTENDED";
-	}
-	return "UNDEFINED";
-}
-
-/* Override the default implementation, DT model is not accurate */
-int checkboard(void)
-{
-	int *board_type = (int *)OCRAM_START;
-
-	printf("Board: UDOO Neo %s\n", board_string(*board_type));
-	return 0;
-}
-
 int board_late_init(void)
 {
 	int *board_type = (int *)OCRAM_START;
configs/udoo_neo_defconfig +1 -0
index 97e3b379835f..826d5a115043 100644
@@ -25,6 +25,7 @@ CONFIG_BOARD_SIZE_LIMIT=523264
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTCOMMAND="run findfdt; run distro_bootcmd"
 CONFIG_SYS_PBSIZE=532
+# CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_SPL_SYS_MALLOC=y
 CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_FS_EXT4=y
Signature · 1 line
2.34.1
author reviewer
#3 lore raw

PATCH v2 4/4 udoo-neo: Convert to OF_UPSTREAM

In reply to Fabio Estevam

Instead of using the local imx6sx-udoo-neo devicetree copies from U-Boot, convert the imx6sx-udoo-neo boards to OF_UPSTREAM so that the upstream kernel devicetrees can be used instead.

Tested on a imx6sx-udoo-neo-full board.

---
Changes since v1:
- Newly introduced.

 arch/arm/dts/Makefile                     |   5 +-
 arch/arm/dts/imx6sx-udoo-neo-basic.dts    |  33 --
 arch/arm/dts/imx6sx-udoo-neo-extended.dts |  26 --
 arch/arm/dts/imx6sx-udoo-neo-full.dts     |  41 --
 arch/arm/dts/imx6sx-udoo-neo.dtsi         | 482 ----------------------
 arch/arm/mach-imx/mx6/Kconfig             |   1 +
 configs/udoo_neo_defconfig                |   2 +-
 7 files changed, 3 insertions(+), 587 deletions(-)
 delete mode 100644 arch/arm/dts/imx6sx-udoo-neo-basic.dts
 delete mode 100644 arch/arm/dts/imx6sx-udoo-neo-extended.dts
 delete mode 100644 arch/arm/dts/imx6sx-udoo-neo-full.dts
 delete mode 100644 arch/arm/dts/imx6sx-udoo-neo.dtsi
arch/arm/dts/Makefile +1 -4
index 7265e5542574..a4d95c8306bb 100644
@@ -840,10 +840,7 @@ dtb-$(CONFIG_MX6SLL) += imx6sll-evk.dtb
 dtb-$(CONFIG_MX6SX) += \
 	imx6sx-sabreauto.dtb \
 	imx6sx-sdb.dtb \
-	imx6sx-softing-vining-2000.dtb \
-	imx6sx-udoo-neo-basic.dtb \
-	imx6sx-udoo-neo-extended.dtb \
-	imx6sx-udoo-neo-full.dtb
+	imx6sx-softing-vining-2000.dtb
 
 dtb-$(CONFIG_MX6UL) += \
 	imx6ul-geam.dtb \
arch/arm/dts/imx6sx-udoo-neo-basic.dts deleted +0 -33
deleted file mode 100644
index 205ea26484e3..000000000000
@@ -1,33 +0,0 @@
-// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
-/*
- * Copyright (c) 2016 Andreas Färber
- */
-
-/dts-v1/;
-
-#include "imx6sx-udoo-neo.dtsi"
-
-/ {
-	model = "UDOO Neo Basic";
-	compatible = "udoo,neobasic", "fsl,imx6sx";
-
-	memory@80000000 {
-		device_type = "memory";
-		reg = <0x80000000 0x20000000>;
-	};
-};
-
-&fec1 {
-	phy-handle = <&ethphy1>;
-	status = "okay";
-
-	mdio {
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		ethphy1: ethernet-phy@0 {
-			compatible = "ethernet-phy-ieee802.3-c22";
-			reg = <0>;
-		};
-	};
-};
arch/arm/dts/imx6sx-udoo-neo-extended.dts deleted +0 -26
deleted file mode 100644
index 5817b4985391..000000000000
@@ -1,26 +0,0 @@
-// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
-/*
- * Copyright (c) 2016 Andreas Färber
- */
-
-/dts-v1/;
-
-#include "imx6sx-udoo-neo.dtsi"
-
-/ {
-	model = "UDOO Neo Extended";
-	compatible = "udoo,neoextended", "fsl,imx6sx";
-
-	memory@80000000 {
-		device_type = "memory";
-		reg = <0x80000000 0x40000000>;
-	};
-};
-
-&i2c4 { /* Onboard Motion sensors */
-	status = "okay";
-};
-
-&uart3 { /* Bluetooth */
-	status = "okay";
-};
arch/arm/dts/imx6sx-udoo-neo-full.dts deleted +0 -41

41 lines not on this page · raw message

arch/arm/dts/imx6sx-udoo-neo.dtsi deleted +0 -482

482 lines not on this page · raw message

arch/arm/mach-imx/mx6/Kconfig +1 -0
index 7800553ae8d9..bee9d5f4877c 100644
@@ -636,6 +636,7 @@ config TARGET_UDOO_NEO
 	select DM_THERMAL
 	select SUPPORT_SPL
 	imply CMD_DM
+	imply OF_UPSTREAM
 
 config TARGET_SOFTING_VINING_2000
 	bool "Softing VIN|ING 2000"
configs/udoo_neo_defconfig +1 -1
index 826d5a115043..0c76b005557b 100644
@@ -11,7 +11,7 @@ CONFIG_ENV_OFFSET=0x80000
 CONFIG_MX6SX=y
 CONFIG_TARGET_UDOO_NEO=y
 CONFIG_DM_GPIO=y
-CONFIG_DEFAULT_DEVICE_TREE="imx6sx-udoo-neo-basic"
+CONFIG_DEFAULT_DEVICE_TREE="nxp/imx/imx6sx-udoo-neo-basic"
 CONFIG_SPL_TEXT_BASE=0x00908000
 CONFIG_SYS_MONITOR_LEN=409600
 CONFIG_SPL_MMC=y
Signature · 1 line
2.34.1
author reviewer Applied
#4 lore raw
In reply to Fabio Estevam
Quoted 7 lines · Fabio Estevam

Commit 68dcbdd594d4 ("ARM: imx: Add weak default reset_cpu()") caused the 'reset' command in U-Boot to not cause a board reset.

Fix it by switching to the watchdog driver model via sysreset, which is the preferred method for implementing the watchdog reset.

Quoted 8 lines

With the watchdog driver model in place, it is no longer needed to have board code to initialize the watchdog, so remove its related board code.

---
Changes since v1:
- Remove board wdog board code.

Applied all, thanks.