board: sl28: add sl28cpld support and board cleanups
Subsystems (3)
cover board: sl28: add sl28cpld support and board cleanups
Add support for the sl28cpld management controller found on this board. This is especially useful, because of the integrated watchdog in this controller. It is used to supervise the bootup of the bootloader and will automatically switch to the failsafe bootloader if u-boot didn't start. Up until now, we had to disable this feature, leaving a gap in the failsafe boot concept of this board. Now, with this driver in place, this watchdog can be enabled at reset and u-boot will disable it late during its startup.
Additionally, add support for the GPIOs which are connected to this controller.
Besides this support, there are various cleanups, like DRAM output fix, printing the version of the management controller and disabling the random MAC address generation.
Implementationwise, the MFD driver is implemented as UCLASS_NOP which provides basic access functions and will enumerate its child nodes. The device tree binding is the same as already acked by the linux kernel.
Michael Walle (10):
misc: add sl28cpld base driver
watchdog: add sl28cpld watchdog driver
gpio: add sl28cpld driver
board: sl28: fix DRAM pretty print
board: sl28: print CPLD version on bootup
board: sl28: enable sl28cpld support
board: sl28: enable SoC watchdog support
board: sl28: disable recovery watchdog
board: sl28: remove "Useful I2C tricks" section from docs
board: sl28: disable random MAC address generation
MAINTAINERS | 7 ++ board/kontron/sl28/sl28.c | 59 +++++++++++- configs/kontron_sl28_defconfig | 11 ++- doc/board/kontron/sl28.rst | 66 +++++++------ drivers/gpio/Kconfig | 6 ++ drivers/gpio/Makefile | 1 + drivers/gpio/sl28cpld-gpio.c | 165 ++++++++++++++++++++++++++++++++ drivers/misc/Kconfig | 8 ++ drivers/misc/Makefile | 1 + drivers/misc/sl28cpld.c | 105 ++++++++++++++++++++ drivers/watchdog/Kconfig | 7 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/sl28cpld-wdt.c | 109 +++++++++++++++++++++ include/sl28cpld.h | 17 ++++ 14 files changed, 528 insertions(+), 35 deletions(-) create mode 100644 drivers/gpio/sl28cpld-gpio.c create mode 100644 drivers/misc/sl28cpld.c create mode 100644 drivers/watchdog/sl28cpld-wdt.c create mode 100644 include/sl28cpld.h
Signature · 1 line
2.30.2
PATCH 1/10 misc: add sl28cpld base driver
Add a multi-function device driver which will probe its children and provides methods to access the device.
--- MAINTAINERS | 5 ++ drivers/misc/Kconfig | 8 +++ drivers/misc/Makefile | 1 + drivers/misc/sl28cpld.c | 105 ++++++++++++++++++++++++++++++++++++++++ include/sl28cpld.h | 14 ++++++ 5 files changed, 133 insertions(+) create mode 100644 drivers/misc/sl28cpld.c create mode 100644 include/sl28cpld.h
MAINTAINERS +5 -0
@@ -1100,6 +1100,11 @@ S: Maintained T: git https://source.denx.de/u-boot/custodians/u-boot-sh.git F: arch/sh/ +SL28CLPD +M: Michael Walle <[email protected]> +S: Maintained +F: drivers/misc/sl28cpld.c + SPI M: Jagan Teki <[email protected]> S: Maintained
drivers/misc/Kconfig +8 -0
@@ -500,4 +500,12 @@ config ESM_PMIC Support ESM (Error Signal Monitor) on PMIC devices. ESM is used typically to reboot the board in error condition. +config SL28CPLD + bool "Enable Kontron sl28cpld multi-function driver" + depends on DM_I2C + help + Support for the Kontron sl28cpld management controller. This is + the base driver which provides common access methods for the + sub-drivers. + endmenu
drivers/misc/Makefile +1 -0
@@ -82,3 +82,4 @@ obj-$(CONFIG_MICROCHIP_FLEXCOM) += microchip_flexcom.o obj-$(CONFIG_K3_AVS0) += k3_avs.o obj-$(CONFIG_ESM_K3) += k3_esm.o obj-$(CONFIG_ESM_PMIC) += esm_pmic.o +obj-$(CONFIG_SL28CPLD) += sl28cpld.o
drivers/misc/sl28cpld.c new file +105 -0
105 lines not on this page · raw message
include/sl28cpld.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (c) 2021 Michael Walle <[email protected]> +*/ + +#ifndef __SL28CPLD_H +#define __SL28CPLD_H + +int sl28cpld_read (struct udevice *dev,uint offset); +int sl28cpld_write (struct udevice *dev,uint offset,uint8_t value); +int sl28cpld_update (struct udevice *dev,uint offset,uint8_t clear, +uint8_t set); + +#endif
Signature · 1 line
2.30.2
PATCH 2/10 watchdog: add sl28cpld watchdog driver
In reply to Michael WalleThe watchdog timer is part of the sl28cpld management controller. The watchdog timer usually supervises the bootloader boot-up and if it bites the failsafe bootloader will be activated. Apart from that it supports the usual board level reset and one SMARC speciality: driving the WDT_TIMEOUT# signal.
--- MAINTAINERS | 1 + doc/board/kontron/sl28.rst | 53 +++++++++++----- drivers/watchdog/Kconfig | 7 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/sl28cpld-wdt.c | 109 ++++++++++++++++++++++++++++++++ 5 files changed, 154 insertions(+), 17 deletions(-) create mode 100644 drivers/watchdog/sl28cpld-wdt.c
MAINTAINERS +1 -0
@@ -1104,6 +1104,7 @@ SL28CLPD M: Michael Walle <[email protected]> S: Maintained F: drivers/misc/sl28cpld.c +F: drivers/watchdog/sl28cpld-wdt.c SPI M: Jagan Teki <[email protected]>
doc/board/kontron/sl28.rst +36 -17
65 lines not on this page · raw message
drivers/watchdog/Kconfig +7 -0
@@ -257,6 +257,13 @@ config WDT_SBSA In the single stage mode, when the timeout is reached, your system will be reset by WS1. The first signal (WS0) is ignored. +config WDT_SL28CPLD + bool "sl28cpld watchdog timer support" + depends on WDT && SL28CPLD + help + Enable support for the watchdog timer in the Kontron sl28cpld + management controller. + config WDT_SP805 bool "SP805 watchdog timer support" depends on WDT
drivers/watchdog/Makefile +1 -0
@@ -34,6 +34,7 @@ obj-$(CONFIG_WDT_OCTEONTX) += octeontx_wdt.o obj-$(CONFIG_WDT_OMAP3) += omap_wdt.o obj-$(CONFIG_WDT_SBSA) += sbsa_gwdt.o obj-$(CONFIG_WDT_K3_RTI) += rti_wdt.o +obj-$(CONFIG_WDT_SL28CPLD) += sl28cpld-wdt.o obj-$(CONFIG_WDT_SP805) += sp805_wdt.o obj-$(CONFIG_WDT_STM32MP) += stm32mp_wdt.o obj-$(CONFIG_WDT_SUNXI) += sunxi_wdt.o
drivers/watchdog/sl28cpld-wdt.c new file +109 -0
109 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH 3/10 gpio: add sl28cpld driver
In reply to Michael WalleThe gpio block is part of the sl28cpld sl28cpld management controller. There are three different flavors: the usual input and output where the direction is configurable, but also input only and output only variants.
--- MAINTAINERS | 1 + drivers/gpio/Kconfig | 6 ++ drivers/gpio/Makefile | 1 + drivers/gpio/sl28cpld-gpio.c | 165 +++++++++++++++++++++++++++++++++++ 4 files changed, 173 insertions(+) create mode 100644 drivers/gpio/sl28cpld-gpio.c
MAINTAINERS +1 -0
@@ -1103,6 +1103,7 @@ F: arch/sh/ SL28CLPD M: Michael Walle <[email protected]> S: Maintained +F: drivers/gpio/sl28cpld-gpio.c F: drivers/misc/sl28cpld.c F: drivers/watchdog/sl28cpld-wdt.c
drivers/gpio/Kconfig +6 -0
@@ -523,4 +523,10 @@ config NOMADIK_GPIO into a number of banks each with 32 GPIOs. The GPIOs for a device are defined in the device tree with one node for each bank. +config SL28CPLD_GPIO + bool "Kontron sl28cpld GPIO driver" + depends on DM_GPIO && SL28CPLD + help + Support GPIO access on Kontron sl28cpld board management controllers. + endif
drivers/gpio/Makefile +1 -0
@@ -69,3 +69,4 @@ obj-$(CONFIG_NX_GPIO) += nx_gpio.o obj-$(CONFIG_SIFIVE_GPIO) += sifive-gpio.o obj-$(CONFIG_NOMADIK_GPIO) += nmk_gpio.o obj-$(CONFIG_MAX7320_GPIO) += max7320_gpio.o +obj-$(CONFIG_SL28CPLD_GPIO) += sl28cpld-gpio.o
drivers/gpio/sl28cpld-gpio.c new file +165 -0
165 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH 4/10 board: sl28: fix DRAM pretty print
In reply to Michael WalleThe current console output is:
DRAM: 4 GiB
DDR 4 GiB (DDR3, 32-bit, CL=11, ECC on)
The size is printed twice and we can save one line of console output if we join both lines. The new output is as follows:
DRAM: 4 GiB (DDR3, 32-bit, CL=11, ECC on)
--- board/kontron/sl28/sl28.c | 2 -- 1 file changed, 2 deletions(-)
board/kontron/sl28/sl28.c +0 -2
@@ -47,8 +47,6 @@ int checkboard(void)void detail_board_ddr_info (void ) { -puts ("\nDDR " ); -print_size (gd->bd->bi_dram[0 ].size + gd->bd->bi_dram[1 ].size,"" );print_ddr_info (0 ); }
Signature · 1 line
2.30.2
PATCH 5/10 board: sl28: print CPLD version on bootup
In reply to Michael WalleMost of the time it is very useful to have the version of the board management controller. Now that we have a driver, print it during startup.
--- board/kontron/sl28/sl28.c | 28 ++++++++++++++++++++++++++++ include/sl28cpld.h | 2 ++ 2 files changed, 30 insertions(+)
board/kontron/sl28/sl28.c +28 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0+ #include <common.h> +#include <dm.h> #include <malloc.h> #include <errno.h> #include <fsl_ddr.h>
@@ -15,6 +16,7 @@#include <fsl_immap.h> #include <netdev.h> +#include <sl28cpld.h> #include <fdtdec.h> #include <miiphy.h>
@@ -39,9 +41,35 @@ int board_eth_init(struct bd_info *bis)return pci_eth_init (bis); } +static int __sl28cpld_read (uint reg) +{ +struct udevice *dev; +int ret; + + ret =uclass_get_device_by_driver (UCLASS_NOP , +DM_DRIVER_GET (sl28cpld), &dev); +if (ret) +return ret; + +return sl28cpld_read (dev, reg); +} + +static void print_cpld_version (void ) +{ +int version =__sl28cpld_read (SL28CPLD_VERSION ); + +if (version <0 ) +printf ("CPLD: error reading version (%d)\n" , version); +else +printf ("CPLD: v%d\n" , version); +} +int checkboard (void ) {printf ("EL: %d\n" ,current_el ()); +if (CONFIG_IS_ENABLED (SL28CPLD )) +print_cpld_version (); +return 0 ; }
include/sl28cpld.h +2 -0
@@ -6,6 +6,8 @@#ifndef __SL28CPLD_H#define __SL28CPLD_H +#define SL28CPLD_VERSION 0x03 +int sl28cpld_read (struct udevice *dev,uint offset);int sl28cpld_write (struct udevice *dev,uint offset,uint8_t value); int sl28cpld_update(struct udevice *dev, uint offset, uint8_t clear,
Signature · 1 line
2.30.2
PATCH 6/10 board: sl28: enable sl28cpld support
In reply to Michael WalleEnable the GPIO and watchdog driver. Don't start the watchdog automatically, though.
--- configs/kontron_sl28_defconfig | 8 ++++++++ 1 file changed, 8 insertions(+)
configs/kontron_sl28_defconfig +8 -0
@@ -41,12 +41,14 @@ CONFIG_CMD_GREPENV=y CONFIG_CMD_NVEDIT_EFI=y CONFIG_CMD_DFU=y CONFIG_CMD_DM=y +CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y CONFIG_CMD_PCI=y CONFIG_CMD_USB=y CONFIG_CMD_USB_MASS_STORAGE=y +CONFIG_CMD_WDT=y CONFIG_CMD_CACHE=y CONFIG_CMD_EFIDEBUG=y CONFIG_CMD_RNG=y
@@ -68,8 +70,10 @@ CONFIG_DDR_ECC=y CONFIG_ECC_INIT_VIA_DDRCONTROLLER=y CONFIG_DFU_MMC=y CONFIG_DFU_SF=y +CONFIG_SL28CPLD_GPIO=y CONFIG_I2C_SET_DEFAULT_BUS_NUM=y CONFIG_I2C_MUX=y +CONFIG_SL28CPLD=y CONFIG_MMC_HS400_SUPPORT=y CONFIG_FSL_ESDHC=y CONFIG_FSL_ESDHC_SUPPORT_ADMA2=y
@@ -101,6 +105,10 @@ CONFIG_USB_DWC3=y CONFIG_USB_DWC3_LAYERSCAPE=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DOWNLOAD=y +# CONFIG_WATCHDOG is not set +# CONFIG_WATCHDOG_AUTOSTART is not set +CONFIG_WDT=y +CONFIG_WDT_SL28CPLD=y CONFIG_OF_LIBFDT_ASSUME_MASK=0x0 CONFIG_OF_LIBFDT_OVERLAY=y CONFIG_EFI_SET_TIME=y
Signature · 1 line
2.30.2
PATCH 7/10 board: sl28: enable SoC watchdog support
In reply to Michael WalleThe SoC provides two additional watchdogs integrated in the SoC. Enable support for these.
--- configs/kontron_sl28_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/kontron_sl28_defconfig +1 -0
@@ -109,6 +109,7 @@ CONFIG_USB_GADGET_DOWNLOAD=y # CONFIG_WATCHDOG_AUTOSTART is not set CONFIG_WDT=y CONFIG_WDT_SL28CPLD=y +CONFIG_WDT_SP805=y CONFIG_OF_LIBFDT_ASSUME_MASK=0x0 CONFIG_OF_LIBFDT_OVERLAY=y CONFIG_EFI_SET_TIME=y
Signature · 1 line
2.30.2
PATCH 8/10 board: sl28: disable recovery watchdog
In reply to Michael WalleThis board has an internal watchdog which supervises the board startup. Although, the initial state of the watchdog is configurable, it is enabled by default. In board_late_init(), which means almost everything worked as expected, disable the watchdog.
--- board/kontron/sl28/sl28.c | 29 +++++++++++++++++++++++++++++ doc/board/kontron/sl28.rst | 12 ++++++------ 2 files changed, 35 insertions(+), 6 deletions(-)
board/kontron/sl28/sl28.c +29 -0
@@ -15,6 +15,7 @@#include <asm/arch/soc.h> #include <fsl_immap.h> #include <netdev.h> +#include <wdt.h> #include <sl28cpld.h> #include <fdtdec.h>
@@ -73,6 +74,34 @@ int checkboard(void)return 0 ; } +static void stop_recovery_watchdog (void ) +{ +struct udevice *dev; +int ret; + + ret =uclass_get_device_by_driver (UCLASS_WDT , +DM_DRIVER_GET (sl28cpld_wdt), &dev); +if (!ret) +wdt_stop (dev); +} + +int fsl_board_late_init (void ) +{ +/* +* Usually, the after a board reset, the watchdog is enabled by +* default. This is to supervise the bootloader boot-up. Therefore, +* to prevent a watchdog reset if we don't actively kick it, we have +* to disable it. +* +* If the watchdog isn't enabled at reset (which is a configuration +* option) disabling it doesn't hurt either. +*/ +if (!CONFIG_IS_ENABLED (WATCHDOG_AUTOSTART )) +stop_recovery_watchdog (); + +return 0 ; +} +void detail_board_ddr_info (void ) {print_ddr_info (0 );
doc/board/kontron/sl28.rst +6 -6
@@ -23,17 +23,17 @@ Copy u-boot.rom to a TFTP server. Install the bootloader on the board ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Please note, this bootloader doesn't support the builtin watchdog (yet), -therefore you have to disable it, see below. Otherwise you'll end up in -the failsafe bootloader on every reset:: +To install the bootloader binary use the following command:: > tftp path/to/u-boot.rom > sf probe 0 > sf update $fileaddr 0x210000 $filesize -The board is fully failsafe, you can't break anything. But because you've -disabled the builtin watchdog you might have to manually enter failsafe -mode by asserting the ``FORCE_RECOV#`` line during board reset. +The board is fully failsafe, you can't break anything. If builtin watchdog +is enabled, you'll automatically end up in the failsafe bootloader if +something goes wrong. If the watchdog is disabled, you have to manually +enter failsafe mode by asserting the ``FORCE_RECOV#`` line during board +reset. Update image ------------
Signature · 1 line
2.30.2
PATCH 9/10 board: sl28: remove "Useful I2C tricks" section from docs
In reply to Michael WalleThey are no longer needed, because we now have proper driver support for the sl28cpld management controller.
--- doc/board/kontron/sl28.rst | 15 --------------- 1 file changed, 15 deletions(-)
doc/board/kontron/sl28.rst +0 -15
@@ -50,21 +50,6 @@ Afterward you can copy this file to your ESP into the /EFI/UpdateCapsule/ folder. On the next EFI boot this will automatically update your bootloader. -Useful I2C tricks ------------------ - -The board has a board management controller which is not supported in -u-boot (yet). But you can use the i2c command to access it. - -- reset into failsafe bootloader:: - - > i2c mw 4a 5.1 0; i2c mw 4a 6.1 6b; i2c mw 4a 4.1 42 - -- read board management controller version:: - - > i2c md 4a 3.1 1 - - Builtin watchdog ----------------
Signature · 1 line
2.30.2
PATCH 10/10 board: sl28: disable random MAC address generation
In reply to Michael WalleNowadays, u-boot (when CONFIG_NET_RANDOM_ETHADDR is set) will set enetaddr to a random value if not set and then pass the randomly generated MAC address to linux.
This is bad for the following reasons:
(1) it makes it impossible for linux to detect this error
(2) linux won't trigger any fallback mechanism for the case where it didn't find any valid MAC address
(3) a saveenv will store this randomly generated MAC address in the environment
Probably, the user will also be unaware that something is wrong. He will just get different MAC addresses on each reboot, asking himself why this is the case.
As this board usually have a serial port, the user can just fix this by setting the MAC address manually in the environment. Also disable the netconsole just in case, because it cannot be guaranteed that it will work in any case. After all, this was just a convenience option, because the bootloader - right now - doesn't have the ability to read the MAC address, which is stored in the OTP. But it is far more important to have a clear view of whats wrong with a board and that means we can no longer use this Kconfig option.
--- configs/kontron_sl28_defconfig | 2 -- 1 file changed, 2 deletions(-)
configs/kontron_sl28_defconfig +0 -2
@@ -59,8 +59,6 @@ CONFIG_OF_LIST="" CONFIG_ENV_OVERWRITE=y CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_SYS_REDUNDAND_ENVIRONMENT=y -CONFIG_NET_RANDOM_ETHADDR=y -CONFIG_NETCONSOLE=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_SCSI_AHCI=y CONFIG_SATA_CEVA=y
Signature · 1 line
2.30.2
Re: [PATCH 10/10] board: sl28: disable random MAC address generation
Quoted 3 lines · Michael Walle
Nowadays, u-boot (when
CONFIG_NET_RANDOM_ETHADDRis set) will set enetaddr to a random value if not set and then pass the randomly generated MAC address to linux.
First, for clarity I'm not nak'ing this. I kind of would like to see a slight reword as I think some things aren't 100% correct, even if the "save random MAC to ethaddr environment variable" change goes in. For example, it's quite long standing that (dev|pdata)->enetaddr populates "mac-address" and "local-mac-address" and it seems in some older cases we only set the "local-mac-address" property.
Quoted 4 lines
This is bad for the following reasons:
(1) it makes it impossible for linux to detect this error
(2) linux won't trigger any fallback mechanism for the case where it didn't find any valid MAC address
This feels in some ways to be a limitation of the binding:
https://www.kernel.org/doc/Documentation/devicetree/bindings/net/ethernet-controller.yaml
And it reads like we really must be populating "mac-address" with that random one and while providing a blank "local-mac-address" would be a way to say we don't know the true device one, it seems that wouldn't be used / noticed?
Quoted 26 lines
(3) a saveenv will store this randomly generated MAC address in the environment
Probably, the user will also be unaware that something is wrong. He will just get different MAC addresses on each reboot, asking himself why this is the case.
As this board usually have a serial port, the user can just fix this by setting the MAC address manually in the environment. Also disable the netconsole just in case, because it cannot be guaranteed that it will work in any case. After all, this was just a convenience option, because the bootloader - right now - doesn't have the ability to read the MAC address, which is stored in the OTP. But it is far more important to have a clear view of whats wrong with a board and that means we can no longer use this
Kconfigoption.Signed-off-by Michael Walle <[email protected]>--- configs/kontron_sl28_defconfig | 2 -- 1 file changed, 2 deletions(-)configs/kontron_sl28_defconfig +0
-0
configs/kontron_sl28_defconfig CONFIG_OF_LIST="" · line 64
Quoted 8 lines
configs/kontron_sl28_defconfig +0
-2@@ -59,8 +59,6 @@ CONFIG_OF_LIST="" CONFIG_ENV_OVERWRITE=y CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_SYS_REDUNDAND_ENVIRONMENT=y -CONFIG_NET_RANDOM_ETHADDR=y -CONFIG_NETCONSOLE=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_SCSI_AHCI=y CONFIG_SATA_CEVA=y
Now, an alternate solution here would be to enable these two options still and write an ft_board_setup() with:
... if ethaddr is in the locally administered pool then
fdt_delprop(... "mac-address");
fdt_delprop(... "local-mac-address");And that should cause the kernel to fall through the cases to find out where to get the real MAC from. I'm not super happy with this at first, but I also don't see anything clever in the binding we can do.
Signature · 1 line
Tom
Re: [PATCH 10/10] board: sl28: disable random MAC address generation
Am 2021-11-16 22:14, schrieb Tom Rini:
Quoted 6 lines · Michael Walle
Quoted 4 lines
Nowadays, u-boot (when
CONFIG_NET_RANDOM_ETHADDRis set) will set enetaddr to a random value if not set and then pass the randomly generated MAC address to linux.
Quoted 6 lines
First, for clarity I'm not nak'ing this. I kind of would like to see a slight reword as I think some things aren't 100% correct, even if the "save random MAC to ethaddr environment variable" change goes in. For example, it's quite long standing that (dev|pdata)->enetaddr populates "mac-address" and "local-mac-address" and it seems in some older cases we only set the "local-mac-address" property.
fdt_fixup_memory() in common/fdt_support.c does a env_get(mac).
I'm not even sure, if there is a connection between what is fixed up in the kernel DT and the corresponding device in u-boot if CONFIG_DM_SEQ_ALIAS is not set.
Quoted 7 lines
Quoted 4 lines
This is bad for the following reasons:
(1) it makes it impossible for linux to detect this error
(2) linux won't trigger any fallback mechanism for the case where it didn't find any valid MAC addressThis feels in some ways to be a limitation of the binding:
https://www.kernel.org/doc/Documentation/devicetree/bindings/net/ethernet-controller.yaml
Agreed. But it doesn't render my argument invalid ;)
Quoted 4 lines
And it reads like we really must be populating "mac-address" with that random one and while providing a blank "local-mac-address" would be a way to say we don't know the true device one, it seems that wouldn't be used / noticed?
I guess it will just use the one populated in mac-address, i.e. the random one. Btw, the binding says "last used" what if u-boot never actually used that ethernet controller, should it then be empty or populated with the random mac address.
Quoted 38 lines
Quoted 26 lines
(3) a saveenv will store this randomly generated MAC address in the environment
Probably, the user will also be unaware that something is wrong. He will just get different MAC addresses on each reboot, asking himself why this is the case.
As this board usually have a serial port, the user can just fix this by setting the MAC address manually in the environment. Also disable the netconsole just in case, because it cannot be guaranteed that it will work in any case. After all, this was just a convenience option, because the bootloader - right now - doesn't have the ability to read the MAC address, which is stored in the OTP. But it is far more important to have a clear view of whats wrong with a board and that means we can no longer use this
Kconfigoption.Signed-off-by Michael Walle <[email protected]>--- configs/kontron_sl28_defconfig | 2 -- 1 file changed, 2 deletions(-)configs/kontron_sl28_defconfig +0
-0configs/kontron_sl28_defconfig CONFIG_OF_LIST="" · line 64
Quoted 8 lines
configs/kontron_sl28_defconfig +0
-2@@ -59,8 +59,6 @@ CONFIG_OF_LIST="" CONFIG_ENV_OVERWRITE=y CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_SYS_REDUNDAND_ENVIRONMENT=y -CONFIG_NET_RANDOM_ETHADDR=y -CONFIG_NETCONSOLE=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_SCSI_AHCI=y CONFIG_SATA_CEVA=yNow, an alternate solution here would be to enable these two options still and write an
ft_board_setup()with:
... if ethaddr is in the locally administered pool then
Quoted 2 lines
fdt_delprop(... "mac-address");
fdt_delprop(... "local-mac-address");Which would also trigger if a user sets a "locally administered" mac himself. Even if unlikely, I'm opposed to such magic and unexpected behavior. Sooner or later it will bite you.
Quoted 3 lines
And that should cause the kernel to fall through the cases to find out where to get the real MAC from. I'm not super happy with this at first, but I also don't see anything clever in the binding we can do.
If I'll need this one again, then I'll just add the random mac generation in board_eth_init(), I think.
-michael
Re: [PATCH 10/10] board: sl28: disable random MAC address generation
Quoted 7 lines · Michael Walle
Am 2021-11-16 22:14, schrieb Tom Rini:
Quoted 6 lines · Michael Walle
Quoted 4 lines
Nowadays, u-boot (when
CONFIG_NET_RANDOM_ETHADDRis set) will set enetaddr to a random value if not set and then pass the randomly generated MAC address to linux.
Quoted 8 lines
Quoted 6 lines
First, for clarity I'm not nak'ing this. I kind of would like to see a slight reword as I think some things aren't 100% correct, even if the "save random MAC to ethaddr environment variable" change goes in. For example, it's quite long standing that (dev|pdata)->enetaddr populates "mac-address" and "local-mac-address" and it seems in some older cases we only set the "local-mac-address" property.
fdt_fixup_memory()incommon/fdt_support.cdoes aenv_get(mac).
Whoops, yes, I misrecalled this.
Quoted 3 lines
I'm not even sure, if there is a connection between what is fixed up in the kernel DT and the corresponding device in u-boot if
CONFIG_DM_SEQ_ALIASis not set.
And then yes, the logic here can be further fragile at times with multiple interfaces.
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
This is bad for the following reasons:
(1) it makes it impossible for linux to detect this error
(2) linux won't trigger any fallback mechanism for the case where it didn't find any valid MAC addressThis feels in some ways to be a limitation of the binding:
https://www.kernel.org/doc/Documentation/devicetree/bindings/net/ethernet-controller.yamlAgreed. But it doesn't render my argument invalid ;)
"Bug" or "feature", but yes, OK.
Quoted 9 lines
Quoted 4 lines
And it reads like we really must be populating "mac-address" with that random one and while providing a blank "local-mac-address" would be a way to say we don't know the true device one, it seems that wouldn't be used / noticed?
I guess it will just use the one populated in mac-address, i.e. the random one. Btw, the binding says "last used" what if u-boot never actually used that ethernet controller, should it then be empty or populated with the random mac address.
My gut feeling here is that we have an example of a binding that has been formalized around what exists in the wild, and was not strictly intentional and clear at all times. What we do today in the case of ethernet devices we haven't used is populate both, just like the one we have used, based on the environment. And popping over to current Linux kernel git, the handful of boards that hard-code a non-zero mac-address or local-mac-address in the dts just makes things even less-clear on what to do. Which probably leaves us with "populate mac-address with whatever you can".
Quoted 46 lines
Quoted 43 lines
Quoted 31 lines
(3) a saveenv will store this randomly generated MAC address in the environment
Probably, the user will also be unaware that something is wrong. He will
just get different MAC addresses on each reboot, asking himself why this
is the case.As this board usually have a serial port, the user can just fix this by
setting the MAC address manually in the environment. Also disable the netconsole just in case, because it cannot be guaranteed that it will work in any case. After all, this was just a convenience option, because
the bootloader - right now - doesn't have the ability to read the MAC address, which is stored in the OTP. But it is far more important to have a clear view of whats wrong with a board and that means we can no longer use thisKconfigoption.Signed-off-by Michael Walle <[email protected]>--- configs/kontron_sl28_defconfig | 2 -- 1 file changed, 2 deletions(-)configs/kontron_sl28_defconfig +0
-0configs/kontron_sl28_defconfig CONFIG_OF_LIST="" · line 64
Quoted 8 lines
configs/kontron_sl28_defconfig +0
-2@@ -59,8 +59,6 @@ CONFIG_OF_LIST="" CONFIG_ENV_OVERWRITE=y CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_SYS_REDUNDAND_ENVIRONMENT=y -CONFIG_NET_RANDOM_ETHADDR=y -CONFIG_NETCONSOLE=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_SCSI_AHCI=y CONFIG_SATA_CEVA=yNow, an alternate solution here would be to enable these two options still and write an
ft_board_setup()with:
... if ethaddr is in the locally administered pool thenQuoted 2 lines
fdt_delprop(... "mac-address"); fdt_delprop(... "local-mac-address");
Quoted 3 lines
Which would also trigger if a user sets a "locally administered" mac himself. Even if unlikely, I'm opposed to such magic and unexpected behavior. Sooner or later it will bite you.
A fair point, yes.
Quoted 6 lines
Quoted 3 lines
And that should cause the kernel to fall through the cases to find out where to get the real MAC from. I'm not super happy with this at first, but I also don't see anything clever in the binding we can do.
If I'll need this one again, then I'll just add the random mac generation in
board_eth_init(), I think.
OK.
Signature · 1 line
Tom
Re: [PATCH 10/10] board: sl28: disable random MAC address generation
Am 2021-11-17 19:24, schrieb Tom Rini:
Quoted 15 lines · Michael Walle
Quoted 14 lines
Am 2021-11-16 22:14, schrieb Tom Rini:
Quoted 12 lines · Michael Walle
Quoted 4 lines
Nowadays, u-boot (when
CONFIG_NET_RANDOM_ETHADDRis set) will set enetaddr to a random value if not set and then pass the randomly generated MAC address to linux.First, for clarity I'm not nak'ing this. I kind of would like to see a slight reword as I think some things aren't 100% correct, even if the "save random MAC to ethaddr environment variable" change goes in. For example, it's quite long standing that (dev|pdata)->enetaddr populates "mac-address" and "local-mac-address" and it seems in some older cases we only set the "local-mac-address" property.
Quoted 3 lines
Quoted 1 line
fdt_fixup_memory()incommon/fdt_support.cdoes aenv_get(mac).Whoops, yes, I misrecalled this.
That means you are fine with this commit message?
-michael
Re: [PATCH 10/10] board: sl28: disable random MAC address generation
Quoted 16 lines · Michael Walle
Am 2021-11-17 19:24, schrieb Tom Rini:
Quoted 15 lines · Michael Walle
Quoted 14 lines
Am 2021-11-16 22:14, schrieb Tom Rini:
Quoted 12 lines · Michael Walle
Quoted 4 lines
Nowadays, u-boot (when
CONFIG_NET_RANDOM_ETHADDRis set) will set enetaddr to a random value if not set and then pass the randomly generated MAC address to linux.First, for clarity I'm not nak'ing this. I kind of would like to see a slight reword as I think some things aren't 100% correct, even if the "save random MAC to ethaddr environment variable" change goes in. For example, it's quite long standing that (dev|pdata)->enetaddr populates "mac-address" and "local-mac-address" and it seems in some older cases we only set the "local-mac-address" property.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
fdt_fixup_memory()incommon/fdt_support.cdoes aenv_get(mac).Whoops, yes, I misrecalled this.
That means you are fine with this commit message?
Well, so long as it goes in after the change that makes NET_RANDOM_ETHADDR update the environment, yes, it's all correct.
Signature · 1 line
Tom
Am 2021-11-15 23:45, schrieb Michael Walle:
Quoted 11 lines
Add support for the sl28cpld management controller found on this board. This is especially useful, because of the integrated watchdog in this controller. It is used to supervise the bootup of the bootloader and will automatically switch to the failsafe bootloader if u-boot didn't start. Up until now, we had to disable this feature, leaving a gap in the failsafe boot concept of this board. Now, with this driver in place, this watchdog can be enabled at reset and u-boot will disable it late during its startup.
Additionally, add support for the GPIOs which are connected to this controller.
Quoted 7 lines
Besides this support, there are various cleanups, like DRAM output fix, printing the version of the management controller and disabling the random MAC address generation.
Implementationwise, the MFD driver is implemented as
UCLASS_NOPwhich provides basic access functions and will enumerate its child nodes. The device tree binding is the same as already acked by the linux kernel.
Ping. This is now 2.5 month old. It doesn't even touch anything outside my own board.
-michael
Quoted 21 lines · Michael Walle
Am 2021-11-15 23:45, schrieb Michael Walle:
Quoted 20 lines
Add support for the sl28cpld management controller found on this board. This is especially useful, because of the integrated watchdog in this controller. It is used to supervise the bootup of the bootloader and will
automatically switch to the failsafe bootloader if u-boot didn't start. Up
until now, we had to disable this feature, leaving a gap in the failsafe boot concept of this board. Now, with this driver in place, this watchdog
can be enabled at reset and u-boot will disable it late during its startup.Additionally, add support for the GPIOs which are connected to this controller.
Besides this support, there are various cleanups, like DRAM output fix, printing the version of the management controller and disabling the random
MAC address generation.
Quoted 6 lines
Quoted 3 lines
Implementationwise, the MFD driver is implemented as
UCLASS_NOPwhich provides basic access functions and will enumerate its child nodes. The device tree binding is the same as already acked by the linux kernel.Ping. This is now 2.5 month old. It doesn't even touch anything outside my own board.
Priyanka?
Signature · 1 line
Tom
Quoted 35 lines
-----Original Message-----
From: Tom Rini <[email protected]>
Sent: Monday, January 31, 2022 8:56 PM
To: Michael Walle <[email protected]>; Priyanka Jain <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 00/10] board: sl28: add sl28cpld support and board cleanupsQuoted 22 lines · Michael Walle
Am 2021-11-15 23:45, schrieb Michael Walle:
Quoted 21 lines
Add support for the sl28cpld management controller found on this board. This is especially useful, because of the integrated watchdog in this controller. It is used to supervise the bootup of the bootloader and will automatically switch to the failsafe bootloader if u-boot didn't start.
Up
until now, we had to disable this feature, leaving a gap in the failsafe boot concept of this board. Now, with this driver in place, this watchdog can be enabled at reset and u-boot will disable it late during its startup.Additionally, add support for the GPIOs which are connected to this controller.
Besides this support, there are various cleanups, like DRAM output fix, printing the version of the management controller and disabling the random MAC address generation.
Implementationwise, the MFD driver is implemented as
UCLASS_NOPwhich provides basic access functions and will enumerate its child nodes. The device tree binding is the same as already acked by the linuxkernel.
Quoted 1 line
Quoted 7 lines
Quoted 2 lines
Ping. This is now 2.5 month old. It doesn't even touch anything outside my own board.
Priyanka?
--
Tom
I saw the series delegated to me today.
I will review and merge if no comments in my next pull-request.
Regards
Priyanka