[PATCH] arm64: zynqmp: Disable Tri-state for MIO38 Pin

2023-10-19 Thread Tejas Bhumkar
gpio38 is used in SOM's kv260 to reset the Ethernet PHY.
At present, HW reset is not working properly as Tri-state??
is enabled for MIO38, causing inappropriate PHY register reads.

Disabled Tri-state for MIO38 to make HW reset work.

Tri-state disable :
ZynqMP> md 0xFF180208 2
ff180208: 00bfe7a3 0540

Tri-state enable :
ZynqMP> md 0xFF180208 2
ff180208: 00bfe7e3 0540

Signed-off-by: Tejas Bhumkar 
---
 arch/arm/dts/zynqmp-sck-kv-g-revA.dtso | 25 +
 arch/arm/dts/zynqmp-sck-kv-g-revB.dtso | 25 +
 2 files changed, 50 insertions(+)

diff --git a/arch/arm/dts/zynqmp-sck-kv-g-revA.dtso 
b/arch/arm/dts/zynqmp-sck-kv-g-revA.dtso
index 22e7d68d02..c4f1da9218 100644
--- a/arch/arm/dts/zynqmp-sck-kv-g-revA.dtso
+++ b/arch/arm/dts/zynqmp-sck-kv-g-revA.dtso
@@ -190,6 +190,25 @@
  {
status = "okay";
 
+   pinctrl_gpio0_default: gpio0-default {
+conf {
+groups = "gpio0_38_grp";
+bias-pull-up;
+power-source = ;
+};
+
+mux {
+groups = "gpio0_38_grp";
+function = "gpio0";
+};
+
+conf-tx {
+pins = "MIO38";
+bias-disable;
+output-enable;
+};
+};
+
pinctrl_uart1_default: uart1-default {
conf {
groups = "uart1_9_grp";
@@ -345,6 +364,12 @@
};
 };
 
+ {
+status = "okay";
+pinctrl-names = "default";
+pinctrl-0 = <_gpio0_default>;
+};
+
  {
status = "okay";
pinctrl-names = "default";
diff --git a/arch/arm/dts/zynqmp-sck-kv-g-revB.dtso 
b/arch/arm/dts/zynqmp-sck-kv-g-revB.dtso
index eadc256306..6c5e0e5660 100644
--- a/arch/arm/dts/zynqmp-sck-kv-g-revB.dtso
+++ b/arch/arm/dts/zynqmp-sck-kv-g-revB.dtso
@@ -178,6 +178,25 @@
  {
status = "okay";
 
+   pinctrl_gpio0_default: gpio0-default {
+   conf {
+   groups = "gpio0_38_grp";
+   bias-pull-up;
+   power-source = ;
+   };
+
+   mux {
+   groups = "gpio0_38_grp";
+   function = "gpio0";
+   };
+
+   conf-tx {
+   pins = "MIO38";
+   bias-disable;
+   output-enable;
+   };
+   };
+
pinctrl_uart1_default: uart1-default {
conf {
groups = "uart1_9_grp";
@@ -333,6 +352,12 @@
};
 };
 
+ {
+   status = "okay";
+   pinctrl-names = "default";
+   pinctrl-0 = <_gpio0_default>;
+};
+
  {
status = "okay";
pinctrl-names = "default";
-- 
2.27.0



Re: [PATCH] mmc: renesas-sdhi: Fix error handling in rzg2l_sdhi_setup

2023-10-19 Thread Marek Vasut

On 10/19/23 16:50, Paul Barker wrote:

We should ensure that reset_free() is called in the error path.

Signed-off-by: Paul Barker 
Fixes: 93c811b7331b ("mmc: renesas-sdhi: Initialize module on RZ/G2L")
---
  drivers/mmc/renesas-sdhi.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
index 1ea6e1066f2b..865efdd32184 100644
--- a/drivers/mmc/renesas-sdhi.c
+++ b/drivers/mmc/renesas-sdhi.c
@@ -998,7 +998,7 @@ static int rzg2l_sdhi_setup(struct udevice *dev)
ret = reset_get_by_index(dev, 0, );
if (ret < 0) {
dev_err(dev, "failed to get reset line\n");
-   goto err_reset;
+   goto err_get_reset;
}
  
  	ret = reset_deassert();

@@ -1016,6 +1016,8 @@ static int rzg2l_sdhi_setup(struct udevice *dev)
  err_tmio_probe:
reset_assert();
  err_reset:
+   reset_free();
+err_get_reset:
clk_disable();
  err_aclk:
clk_disable();

base-commit: 9a0cf3993f71043ba08c315572c54622de42d447


Reviewed-by: Marek Vasut 

btw is email playing tricks on me , or is Jaehoon and Peng not on CC ?
$ ./scripts/get_maintainer.pl -f drivers/mmc/renesas-sdhi.c

(I added them to this mail)


Re: [PATCH 1/2] configs: rockchip: Use dwc3-generic driver on RK3328 and RK3399

2023-10-19 Thread Marek Vasut

On 10/19/23 22:39, Jonas Karlman wrote:

On 2023-10-19 01:44, Marek Vasut wrote:

On 10/19/23 00:30, Jonas Karlman wrote:

[..]


+++ b/configs/rock960-rk3399_defconfig
@@ -50,6 +50,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
   CONFIG_SYS_MMC_ENV_DEV=1
   CONFIG_ROCKCHIP_GPIO=y
   CONFIG_SYS_I2C_ROCKCHIP=y
+CONFIG_MISC=y
   CONFIG_MMC_DW=y
   CONFIG_MMC_DW_ROCKCHIP=y
   CONFIG_MMC_SDHCI=y
@@ -70,12 +71,12 @@ CONFIG_SYS_NS16550_MEM32=y
   CONFIG_SYSRESET=y
   CONFIG_USB=y
   CONFIG_USB_XHCI_HCD=y
-CONFIG_USB_XHCI_DWC3=y
   CONFIG_USB_EHCI_HCD=y
   CONFIG_USB_EHCI_GENERIC=y
   CONFIG_USB_OHCI_HCD=y
   CONFIG_USB_OHCI_GENERIC=y
   CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_GENERIC=y


Why not add 'default y if ROCKCHIP' into the Kconfig instead ? This will
have the same effect, without requiring such massive modification of
config files.


Not fully sure what you mean by this and how that would reduce number of
affected defconfig-files. The USB_XHCI_DWC3 should still be removed from
these defconfig-files or wrong driver could be used by these boards.

Touching the defconfig-files help notify board maintainers that changes
are happening to their boards.

There will also be a separate patch that remove the rockchip,rk3399-dwc3
compatible from the dwc3-of-simple driver to finalize this transition to
use dwc3-generic driver for affected rockchip boards.


It wasn't clear to me you're switching one driver to another, thanks for 
clarification.


"
Also enable DM_USB_GADGET for any board that enable
USB_DWC3_GADGET.
"

This you can do in Kconfig file, something like:
select DM_USB_GADGET if USB_DWC3_GADGET && 


Re: [PATCH] clock_imx8mm: Add a stub for imx8mp_fec_interface_init()

2023-10-19 Thread Marek Vasut

On 10/20/23 02:47, Fabio Estevam wrote:

From: Fabio Estevam 

When CONFIG_DWC_ETH_QOS_IMX=y and CONFIG_FEC_MXC is not selected, the
following warning is seen:

arch/arm/mach-imx/imx8m/clock_imx8mm.c: In function 'board_interface_eth_init':
arch/arm/mach-imx/imx8m/clock_imx8mm.c:914:24: warning: implicit declaration of 
function 'imx8mp_fec_interface_init; did you mean 'imx8mp_eqos_interface_init'? 
[-Wimplicit-function-declaration]

Fix it by adding a stub for imx8mp_fec_interface_init() to handle this
case.

This follows the same approach done on imx8mp_eqos_interface_init().

Signed-off-by: Fabio Estevam 


Reviewed-by: Marek Vasut 


[PATCH] mpc85xx: relocate code in non-SPL build

2023-10-19 Thread Martin Fäcknitz
When building a non-SPL image, relocation is needed. This patch restores
the old behaviour before commit b35316fb67: CONFIG_SPL_SKIP_RELOCATE was
only defined if CONFIG_SPL_BUILD was defined.

Fixes: b35316fb67cb ("Convert CONFIG_SPL_INIT_MINIMAL et al to Kconfig")
Signed-off-by: Martin Fäcknitz 
---
 arch/powerpc/cpu/mpc85xx/start.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/cpu/mpc85xx/start.S b/arch/powerpc/cpu/mpc85xx/start.S
index 562b6993b9..318872f82b 100644
--- a/arch/powerpc/cpu/mpc85xx/start.S
+++ b/arch/powerpc/cpu/mpc85xx/start.S
@@ -1617,7 +1617,7 @@ relocate_code:
mr  r10,r5  /* Save copy of Destination Address */
 
GET_GOT
-#ifndef CONFIG_SPL_SKIP_RELOCATE
+#if !defined(CONFIG_SPL_SKIP_RELOCATE) || !defined(CONFIG_SPL_BUILD)
mr  r3,r5   /* Destination Address  */
lis r4,CONFIG_VAL(SYS_MONITOR_BASE)@h   /* Source  
Address  */
ori r4,r4,CONFIG_VAL(SYS_MONITOR_BASE)@l
-- 
2.11.0



How to use USB_HOST for at91 OHCI USB

2023-10-19 Thread Afshin Pir
Hi all

I want to use usb command and usb mass storage with at91 ohci. These features 
depend on USB_HOST, but I found that USB_ATMEL option does not select USB_HOST 
and I don't know why. How can I do this?

Best Regards

This email is confidential and may contain information subject to legal 
privilege. If you are not the intended recipient please advise us of our error 
by return e-mail then delete this email and any attached files. You may not 
copy, disclose or use the contents in any way. The views expressed in this 
email may not be those of Gallagher Group Ltd or subsidiary companies thereof.



[PATCH v3 6/6] spi: zynq_qspi: Add parallel memories support in QSPI driver

2023-10-19 Thread Venkatesh Yadav Abbarapu
Add support for parallel memories in zynq_qspi.c driver. In case of
parallel memories STRIPE bit is set and sent to the qspi ip, which will
send data bits to both the flashes in parallel. However for few commands
we should not use stripe, instead send same data to both the flashes.
Those commands are exclueded by using zynqmp_qspi_update_stripe().

Also update copyright info for this file.

Signed-off-by: Ashok Reddy Soma 
Signed-off-by: Venkatesh Yadav Abbarapu 
---
 drivers/spi/zynq_qspi.c | 140 
 include/spi.h   |   4 ++
 2 files changed, 131 insertions(+), 13 deletions(-)

diff --git a/drivers/spi/zynq_qspi.c b/drivers/spi/zynq_qspi.c
index 069d2a77de..3471c301bf 100644
--- a/drivers/spi/zynq_qspi.c
+++ b/drivers/spi/zynq_qspi.c
@@ -1,7 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * (C) Copyright 2013 Xilinx, Inc.
+ * (C) Copyright 2013 - 2022, Xilinx, Inc.
  * (C) Copyright 2015 Jagan Teki 
+ * (C) Copyright 2023, Advanced Micro Devices, Inc.
  *
  * Xilinx Zynq Quad-SPI(QSPI) controller driver (master mode only)
  */
@@ -13,10 +14,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include "../mtd/spi/sf_internal.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -42,6 +45,22 @@ DECLARE_GLOBAL_DATA_PTR;
 #define ZYNQ_QSPI_TXD_00_01_OFFSET 0x80/* Transmit 1-byte inst */
 #define ZYNQ_QSPI_TXD_00_10_OFFSET 0x84/* Transmit 2-byte inst */
 #define ZYNQ_QSPI_TXD_00_11_OFFSET 0x88/* Transmit 3-byte inst */
+#define ZYNQ_QSPI_FR_QOUT_CODE 0x6B/* read instruction code */
+#define ZYNQ_QSPI_FR_DUALIO_CODE   0xBB
+
+#define QSPI_SELECT_LOWER_CS   BIT(0)
+#define QSPI_SELECT_UPPER_CS   BIT(1)
+
+/*
+ * QSPI Linear Configuration Register
+ *
+ * It is named Linear Configuration but it controls other modes when not in
+ * linear mode also.
+ */
+#define ZYNQ_QSPI_LCFG_TWO_MEM_MASK0x4000 /* QSPI Enable Bit Mask */
+#define ZYNQ_QSPI_LCFG_SEP_BUS_MASK0x2000 /* QSPI Enable Bit Mask */
+#define ZYNQ_QSPI_LCFG_U_PAGE  0x1000 /* QSPI Upper memory set */
+#define ZYNQ_QSPI_LCFG_DUMMY_SHIFT 8
 
 #define ZYNQ_QSPI_TXFIFO_THRESHOLD 1   /* Tx FIFO threshold level*/
 #define ZYNQ_QSPI_RXFIFO_THRESHOLD 32  /* Rx FIFO threshold level */
@@ -101,7 +120,12 @@ struct zynq_qspi_priv {
int bytes_to_transfer;
int bytes_to_receive;
unsigned int is_inst;
+   unsigned int is_parallel;
+   unsigned int is_stacked;
+   unsigned int is_dio;
+   unsigned int u_page;
unsigned cs_change:1;
+   unsigned is_strip:1;
 };
 
 static int zynq_qspi_of_to_plat(struct udevice *bus)
@@ -112,7 +136,6 @@ static int zynq_qspi_of_to_plat(struct udevice *bus)
 
plat->regs = (struct zynq_qspi_regs *)fdtdec_get_addr(blob,
  node, "reg");
-
return 0;
 }
 
@@ -147,6 +170,9 @@ static void zynq_qspi_init_hw(struct zynq_qspi_priv *priv)
/* Disable Interrupts */
writel(ZYNQ_QSPI_IXR_ALL_MASK, >idr);
 
+   /* Disable linear mode as the boot loader may have used it */
+   writel(0x0, >lqspicfg);
+
/* Clear the TX and RX threshold reg */
writel(ZYNQ_QSPI_TXFIFO_THRESHOLD, >txftr);
writel(ZYNQ_QSPI_RXFIFO_THRESHOLD, >rxftr);
@@ -164,12 +190,11 @@ static void zynq_qspi_init_hw(struct zynq_qspi_priv *priv)
confr |= ZYNQ_QSPI_CR_IFMODE_MASK | ZYNQ_QSPI_CR_MCS_MASK |
ZYNQ_QSPI_CR_PCS_MASK | ZYNQ_QSPI_CR_FW_MASK |
ZYNQ_QSPI_CR_MSTREN_MASK;
-   writel(confr, >cr);
 
-   /* Disable the LQSPI feature */
-   confr = readl(>lqspicfg);
-   confr &= ~ZYNQ_QSPI_LQSPICFG_LQMODE_MASK;
-   writel(confr, >lqspicfg);
+   if (priv->is_stacked)
+   confr |= 0x10;
+
+   writel(confr, >cr);
 
/* Enable SPI */
writel(ZYNQ_QSPI_ENR_SPI_EN_MASK, >enr);
@@ -180,6 +205,8 @@ static int zynq_qspi_child_pre_probe(struct udevice *bus)
struct spi_slave *slave = dev_get_parent_priv(bus);
struct zynq_qspi_priv *priv = dev_get_priv(bus->parent);
 
+   slave->multi_cs_cap = true;
+   slave->dio = priv->is_dio;
priv->max_hz = slave->max_hz;
 
return 0;
@@ -363,8 +390,8 @@ static void zynq_qspi_fill_tx_fifo(struct zynq_qspi_priv 
*priv, u32 size)
unsigned len, offset;
struct zynq_qspi_regs *regs = priv->regs;
static const unsigned offsets[4] = {
-   ZYNQ_QSPI_TXD_00_00_OFFSET, ZYNQ_QSPI_TXD_00_01_OFFSET,
-   ZYNQ_QSPI_TXD_00_10_OFFSET, ZYNQ_QSPI_TXD_00_11_OFFSET };
+   ZYNQ_QSPI_TXD_00_01_OFFSET, ZYNQ_QSPI_TXD_00_10_OFFSET,
+   ZYNQ_QSPI_TXD_00_11_OFFSET, ZYNQ_QSPI_TXD_00_00_OFFSET };
 
while ((fifocount < size) &&
(priv->bytes_to_transfer > 0)) {
@@ -386,7 +413,11 @@ static void zynq_qspi_fill_tx_fifo(struct 

[PATCH v3 4/6] spi: spi-uclass: Read chipselect and restrict capabilities

2023-10-19 Thread Venkatesh Yadav Abbarapu
From: Ashok Reddy Soma 

Read chipselect properties from DT which are populated using 'reg'
property and save it in plat->cs[] array for later use.

Also read multi chipselect capability which is used for
parallel-memories and return errors if they are passed on using DT but
driver is not capable of handling it.

Signed-off-by: Ashok Reddy Soma 
Signed-off-by: Venkatesh Yadav Abbarapu 
---
 drivers/mtd/spi/sandbox.c|  2 +-
 drivers/spi/altera_spi.c |  4 ++--
 drivers/spi/atcspi200_spi.c  |  2 +-
 drivers/spi/ath79_spi.c  |  2 +-
 drivers/spi/atmel_spi.c  |  6 +++---
 drivers/spi/bcm63xx_hsspi.c  | 42 ++--
 drivers/spi/bcm63xx_spi.c|  6 +++---
 drivers/spi/bcmbca_hsspi.c   | 34 ++---
 drivers/spi/cf_spi.c |  6 +++---
 drivers/spi/davinci_spi.c|  6 +++---
 drivers/spi/fsl_dspi.c   | 18 
 drivers/spi/fsl_espi.c   |  4 ++--
 drivers/spi/fsl_qspi.c   |  4 ++--
 drivers/spi/gxp_spi.c|  2 +-
 drivers/spi/mpc8xx_spi.c |  4 ++--
 drivers/spi/mpc8xxx_spi.c| 10 -
 drivers/spi/mscc_bb_spi.c|  4 ++--
 drivers/spi/mxc_spi.c|  6 +++---
 drivers/spi/npcm_fiu_spi.c   | 14 ++--
 drivers/spi/nxp_fspi.c   |  2 +-
 drivers/spi/octeon_spi.c |  2 +-
 drivers/spi/omap3_spi.c  |  4 ++--
 drivers/spi/pic32_spi.c  |  2 +-
 drivers/spi/rk_spi.c |  4 ++--
 drivers/spi/rockchip_sfc.c   |  2 +-
 drivers/spi/spi-aspeed-smc.c | 28 
 drivers/spi/spi-mxic.c   |  6 +++---
 drivers/spi/spi-qup.c|  4 ++--
 drivers/spi/spi-sifive.c |  6 +++---
 drivers/spi/spi-sn-f-ospi.c  |  2 +-
 drivers/spi/spi-sunxi.c  |  6 +++---
 drivers/spi/spi-synquacer.c  |  4 ++--
 drivers/spi/spi-uclass.c | 21 +-
 drivers/spi/stm32_qspi.c |  2 +-
 drivers/spi/stm32_spi.c  |  4 ++--
 drivers/spi/ti_qspi.c| 14 ++--
 drivers/spi/xilinx_spi.c |  4 ++--
 drivers/spi/zynq_qspi.c  |  6 +++---
 drivers/spi/zynq_spi.c   |  6 +++---
 include/spi.h|  2 +-
 lib/acpi/acpi_device.c   |  2 +-
 41 files changed, 160 insertions(+), 149 deletions(-)

diff --git a/drivers/mtd/spi/sandbox.c b/drivers/mtd/spi/sandbox.c
index 4fe547171a..72036d5a88 100644
--- a/drivers/mtd/spi/sandbox.c
+++ b/drivers/mtd/spi/sandbox.c
@@ -139,7 +139,7 @@ static int sandbox_sf_probe(struct udevice *dev)
return ret;
}
slave_plat = dev_get_parent_plat(dev);
-   cs = slave_plat->cs;
+   cs = slave_plat->cs[0];
debug("found at cs %d\n", cs);
 
if (!pdata->filename) {
diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c
index 989679e881..48782f81c1 100644
--- a/drivers/spi/altera_spi.c
+++ b/drivers/spi/altera_spi.c
@@ -96,7 +96,7 @@ static int altera_spi_xfer(struct udevice *dev, unsigned int 
bitlen,
uint32_t reg, data, start;
 
debug("%s: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n", __func__,
- dev_seq(bus), slave_plat->cs, bitlen, bytes, flags);
+ dev_seq(bus), slave_plat->cs[0], bitlen, bytes, flags);
 
if (bitlen == 0)
goto done;
@@ -111,7 +111,7 @@ static int altera_spi_xfer(struct udevice *dev, unsigned 
int bitlen,
readl(>rxdata);
 
if (flags & SPI_XFER_BEGIN)
-   spi_cs_activate(dev, slave_plat->cs);
+   spi_cs_activate(dev, slave_plat->cs[0]);
 
while (bytes--) {
if (txp)
diff --git a/drivers/spi/atcspi200_spi.c b/drivers/spi/atcspi200_spi.c
index de9c14837c..acee743653 100644
--- a/drivers/spi/atcspi200_spi.c
+++ b/drivers/spi/atcspi200_spi.c
@@ -321,7 +321,7 @@ static int atcspi200_spi_claim_bus(struct udevice *dev)
struct udevice *bus = dev->parent;
struct nds_spi_slave *ns = dev_get_priv(bus);
 
-   if (slave_plat->cs >= ns->num_cs) {
+   if (slave_plat->cs[0] >= ns->num_cs) {
printf("Invalid SPI chipselect\n");
return -EINVAL;
}
diff --git a/drivers/spi/ath79_spi.c b/drivers/spi/ath79_spi.c
index 205567ef54..ad10cec2a6 100644
--- a/drivers/spi/ath79_spi.c
+++ b/drivers/spi/ath79_spi.c
@@ -74,7 +74,7 @@ static int ath79_spi_xfer(struct udevice *dev, unsigned int 
bitlen,
if (restbits)
bytes++;
 
-   out = AR71XX_SPI_IOC_CS_ALL & ~(AR71XX_SPI_IOC_CS(slave->cs));
+   out = AR71XX_SPI_IOC_CS_ALL & ~(AR71XX_SPI_IOC_CS(slave->cs[0]));
while (bytes > 0) {
bytes--;
curbyte = 0;
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index aec6f4eca9..e2de39d1ef 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -126,7 +126,7 @@ static int atmel_spi_claim_bus(struct udevice *dev)
struct atmel_spi_priv *priv = dev_get_priv(bus);
struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev);
struct at91_spi *reg_base = 

[PATCH v3 5/6] spi: zynqmp_gqspi: Add parallel memories support in GQSPI driver

2023-10-19 Thread Venkatesh Yadav Abbarapu
Add support for parallel memories in zynqmp_gqspi.c driver. In case of
parallel memories STRIPE bit is set and sent to the qspi ip, which will
send data bits to both the flashes in parallel. However for few commands
we should not use stripe, instead send same data to both the flashes.
Those commands are exclueded by using zynqmp_qspi_update_stripe().

Also update copyright info for this file.

Signed-off-by: Ashok Reddy Soma 
Signed-off-by: Venkatesh Yadav Abbarapu 
---
 drivers/spi/zynqmp_gqspi.c | 142 -
 include/spi.h  |  12 
 2 files changed, 138 insertions(+), 16 deletions(-)

diff --git a/drivers/spi/zynqmp_gqspi.c b/drivers/spi/zynqmp_gqspi.c
index ec59ef5804..620b5e4fc7 100644
--- a/drivers/spi/zynqmp_gqspi.c
+++ b/drivers/spi/zynqmp_gqspi.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * (C) Copyright 2018 Xilinx
+ * (C) Copyright 2013 - 2022, Xilinx, Inc.
+ * (C) Copyright 2023, Advanced Micro Devices, Inc.
  *
  * Xilinx ZynqMP Generic Quad-SPI(QSPI) controller driver(master mode only)
  */
@@ -23,6 +24,8 @@
 #include 
 #include 
 #include 
+#include 
+#include "../mtd/spi/sf_internal.h"
 #include 
 
 #define GQSPI_GFIFO_STRT_MODE_MASK BIT(29)
@@ -86,6 +89,9 @@
 #define SPI_XFER_ON_LOWER  1
 #define SPI_XFER_ON_UPPER  2
 
+#define GQSPI_SELECT_LOWER_CS  BIT(0)
+#define GQSPI_SELECT_UPPER_CS  BIT(1)
+
 #define GQSPI_DMA_ALIGN0x4
 #define GQSPI_MAX_BAUD_RATE_VAL7
 #define GQSPI_DFLT_BAUD_RATE_VAL   2
@@ -181,13 +187,14 @@ struct zynqmp_qspi_priv {
int bytes_to_transfer;
int bytes_to_receive;
const struct spi_mem_op *op;
+   unsigned int is_parallel;
+   unsigned int u_page;
+   unsigned int bus;
+   unsigned int stripe;
+   unsigned int flags;
+   u32 max_hz;
 };
 
-__weak int zynqmp_mmio_write(const u32 address, const u32 mask, const u32 
value)
-{
-   return 0;
-}
-
 static int zynqmp_qspi_of_to_plat(struct udevice *bus)
 {
struct zynqmp_qspi_plat *plat = dev_get_plat(bus);
@@ -234,9 +241,30 @@ static u32 zynqmp_qspi_bus_select(struct zynqmp_qspi_priv 
*priv)
 {
u32 gqspi_fifo_reg = 0;
 
-   gqspi_fifo_reg = GQSPI_GFIFO_LOW_BUS |
-GQSPI_GFIFO_CS_LOWER;
-
+   if (priv->is_parallel) {
+   if (priv->bus == SPI_XFER_ON_BOTH)
+   gqspi_fifo_reg = GQSPI_GFIFO_LOW_BUS |
+GQSPI_GFIFO_UP_BUS |
+GQSPI_GFIFO_CS_UPPER |
+GQSPI_GFIFO_CS_LOWER;
+   else if (priv->bus == SPI_XFER_ON_LOWER)
+   gqspi_fifo_reg = GQSPI_GFIFO_LOW_BUS |
+GQSPI_GFIFO_CS_UPPER |
+GQSPI_GFIFO_CS_LOWER;
+   else if (priv->bus == SPI_XFER_ON_UPPER)
+   gqspi_fifo_reg = GQSPI_GFIFO_UP_BUS |
+GQSPI_GFIFO_CS_LOWER |
+GQSPI_GFIFO_CS_UPPER;
+   else
+   debug("Wrong Bus selection:0x%x\n", priv->bus);
+   } else {
+   if (priv->u_page)
+   gqspi_fifo_reg = GQSPI_GFIFO_LOW_BUS |
+GQSPI_GFIFO_CS_UPPER;
+   else
+   gqspi_fifo_reg = GQSPI_GFIFO_LOW_BUS |
+GQSPI_GFIFO_CS_LOWER;
+   }
return gqspi_fifo_reg;
 }
 
@@ -291,7 +319,13 @@ static void zynqmp_qspi_chipselect(struct zynqmp_qspi_priv 
*priv, int is_on)
gqspi_fifo_reg |= GQSPI_SPI_MODE_SPI |
  GQSPI_IMD_DATA_CS_ASSERT;
} else {
-   gqspi_fifo_reg = GQSPI_GFIFO_LOW_BUS;
+   if (priv->is_parallel)
+   gqspi_fifo_reg = GQSPI_GFIFO_UP_BUS |
+GQSPI_GFIFO_LOW_BUS;
+   else if (priv->u_page)
+   gqspi_fifo_reg = GQSPI_GFIFO_UP_BUS;
+   else
+   gqspi_fifo_reg = GQSPI_GFIFO_LOW_BUS;
gqspi_fifo_reg |= GQSPI_IMD_DATA_CS_DEASSERT;
}
 
@@ -362,13 +396,16 @@ static int zynqmp_qspi_set_speed(struct udevice *bus, 
uint speed)
u32 confr;
u8 baud_rate_val = 0;
 
-   debug("%s\n", __func__);
-   if (speed > plat->frequency)
-   speed = plat->frequency;
+   /*
+* If speed == 0 or speed > max freq, then set speed to highest
+*/
+   if (!speed || speed > priv->max_hz)
+   speed = priv->max_hz;
+
+   debug("%s %d\n", __func__, speed);
+
 
if (plat->speed_hz != speed) {
-   /* Set the clock frequency */
-   /* If speed == 0, default to lowest speed */
while 

[PATCH v3 3/6] mtd: spi-nor: Add parallel and stacked memories support in read_bar and write_bar

2023-10-19 Thread Venkatesh Yadav Abbarapu
From: Ashok Reddy Soma 

Add support for parallel memories and stacked memories configuration
in read_bar and write_bar functions.

Signed-off-by: Ashok Reddy Soma 
Signed-off-by: Venkatesh Yadav Abbarapu 
---
 drivers/mtd/spi/spi-nor-core.c | 55 +-
 1 file changed, 47 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 373979d19b..264aa6080b 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -885,12 +885,32 @@ static int clean_bar(struct spi_nor *nor)
 
 static int write_bar(struct spi_nor *nor, u32 offset)
 {
-   u8 cmd, bank_sel;
+   u8 cmd, bank_sel, upage_curr;
int ret;
+   struct mtd_info *mtd = >mtd;
+
+   /* Wait until previous write command is finished */
+   if (spi_nor_wait_till_ready(nor))
+   return 1;
+
+   if (nor->flags & (SNOR_F_HAS_PARALLEL | SNOR_F_HAS_STACKED) &&
+   mtd->size <= SZ_32M)
+   return 0;
+
+   if (mtd->size <= SZ_16M)
+   return 0;
+
+   offset = offset % (u32)mtd->size;
+   bank_sel = offset >> 24;
 
-   bank_sel = offset / SZ_16M;
-   if (bank_sel == nor->bank_curr)
-   goto bar_end;
+   upage_curr = nor->spi->flags & SPI_XFER_U_PAGE;
+
+   if (!(nor->flags & SNOR_F_HAS_STACKED) && bank_sel == nor->bank_curr)
+   return 0;
+   else if (upage_curr == nor->upage_prev && bank_sel == nor->bank_curr)
+   return 0;
+   else
+   nor->upage_prev = upage_curr;
 
cmd = nor->bank_write_cmd;
write_enable(nor);
@@ -900,15 +920,19 @@ static int write_bar(struct spi_nor *nor, u32 offset)
return ret;
}
 
-bar_end:
nor->bank_curr = bank_sel;
-   return nor->bank_curr;
+
+   return write_disable(nor);
 }
 
 static int read_bar(struct spi_nor *nor, const struct flash_info *info)
 {
u8 curr_bank = 0;
int ret;
+   struct mtd_info *mtd = >mtd;
+
+   if (mtd->size <= SZ_16M)
+   return 0;
 
switch (JEDEC_MFR(info)) {
case SNOR_MFR_SPANSION:
@@ -920,15 +944,30 @@ static int read_bar(struct spi_nor *nor, const struct 
flash_info *info)
nor->bank_write_cmd = SPINOR_OP_WREAR;
}
 
+   if (nor->flags & SNOR_F_HAS_PARALLEL)
+   nor->spi->flags |= SPI_XFER_LOWER;
+
ret = nor->read_reg(nor, nor->bank_read_cmd,
-   _bank, 1);
+   _bank, 1);
if (ret) {
debug("SF: fail to read bank addr register\n");
return ret;
}
nor->bank_curr = curr_bank;
 
-   return 0;
+   // Make sure both chips use the same BAR
+   if (nor->flags & SNOR_F_HAS_PARALLEL) {
+   write_enable(nor);
+   ret = nor->write_reg(nor, nor->bank_write_cmd, _bank, 1);
+   if (ret)
+   return ret;
+
+   ret = write_disable(nor);
+   if (ret)
+   return ret;
+   }
+
+   return ret;
 }
 #endif
 
-- 
2.25.1



[PATCH v3 2/6] mtd: spi-nor: Add parallel memories support for read_sr and read_fsr

2023-10-19 Thread Venkatesh Yadav Abbarapu
From: Ashok Reddy Soma 

Add support for parallel memories flash configuration in read status
register and read flag status register functions.

Signed-off-by: Ashok Reddy Soma 
Signed-off-by: Venkatesh Yadav Abbarapu 
---
 drivers/mtd/spi/spi-nor-core.c | 50 --
 1 file changed, 36 insertions(+), 14 deletions(-)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index b2e5494e78..373979d19b 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -438,8 +438,9 @@ static ssize_t spi_nor_write_data(struct spi_nor *nor, 
loff_t to, size_t len,
 }
 
 /*
- * Read the status register, returning its value in the location
- * Return the status register value.
+ * Return the status register value. If the chip is parallel, then the
+ * read will be striped, so we should read 2 bytes to get the sr
+ * register value from both of the parallel chips.
  * Returns negative if error occurred.
  */
 static int read_sr(struct spi_nor *nor)
@@ -471,18 +472,29 @@ static int read_sr(struct spi_nor *nor)
if (spi_nor_protocol_is_dtr(nor->reg_proto))
op.data.nbytes = 2;
 
-   ret = spi_nor_read_write_reg(nor, , val);
-   if (ret < 0) {
-   pr_debug("error %d reading SR\n", (int)ret);
-   return ret;
+   if (nor->flags & SNOR_F_HAS_PARALLEL) {
+   op.data.nbytes = 2;
+   ret = spi_nor_read_write_reg(nor, , [0]);
+   if (ret < 0) {
+   pr_debug("error %d reading SR\n", (int)ret);
+   return ret;
+   }
+   val[0] |= val[1];
+   } else {
+   ret = spi_nor_read_write_reg(nor, , [0]);
+   if (ret < 0) {
+   pr_debug("error %d reading SR\n", (int)ret);
+   return ret;
+   }
}
 
-   return *val;
+   return val[0];
 }
 
 /*
- * Read the flag status register, returning its value in the location
- * Return the status register value.
+ * Return the flag status register value. If the chip is parallel, then
+ * the read will be striped, so we should read 2 bytes to get the fsr
+ * register value from both of the parallel chips.
  * Returns negative if error occurred.
  */
 static int read_fsr(struct spi_nor *nor)
@@ -514,13 +526,23 @@ static int read_fsr(struct spi_nor *nor)
if (spi_nor_protocol_is_dtr(nor->reg_proto))
op.data.nbytes = 2;
 
-   ret = spi_nor_read_write_reg(nor, , val);
-   if (ret < 0) {
-   pr_debug("error %d reading FSR\n", ret);
-   return ret;
+   if (nor->flags & SNOR_F_HAS_PARALLEL) {
+   op.data.nbytes = 2;
+   ret = spi_nor_read_write_reg(nor, , [0]);
+   if (ret < 0) {
+   pr_debug("error %d reading SR\n", (int)ret);
+   return ret;
+   }
+   val[0] &= val[1];
+   } else {
+   ret = spi_nor_read_write_reg(nor, , [0]);
+   if (ret < 0) {
+   pr_debug("error %d reading FSR\n", ret);
+   return ret;
+   }
}
 
-   return *val;
+   return val[0];
 }
 
 /*
-- 
2.25.1



[PATCH v3 1/6] mtd: spi-nor: Add parallel and stacked memories support

2023-10-19 Thread Venkatesh Yadav Abbarapu
From: Ashok Reddy Soma 

In parallel mode, the current implementation assumes that a maximum of
two flashes are connected. The QSPI controller splits the data evenly
between both the flashes so, both the flashes that are connected in
parallel mode should be identical.
During each operation SPI-NOR sets 0th bit for CS0 & 1st bit for CS1 in
nor->flags.

In stacked mode the current implementation assumes that a maximum of two
flashes are connected and both the flashes are of same make but can
differ in sizes. So, except the sizes all other flash parameters of both
the flashes are identical

Spi-nor will pass on the appropriate flash select flag to low level
driver, and it will select pass all the data to that particular flash.

Write operation in parallel mode are performed in page size * 2 chunks as
each write operation results in writing both the flashes. For doubling
the address space each operation is performed at addr/2 flash offset,
where addr is the address specified by the user.

Similarly for read and erase operations it will read from both flashes,
so size and offset are divided by 2 and send to flash.

Signed-off-by: Ashok Reddy Soma 
Signed-off-by: Venkatesh Yadav Abbarapu 
---
 drivers/mtd/spi/spi-nor-core.c | 280 +
 include/linux/mtd/spi-nor.h|  13 ++
 include/spi.h  |  12 ++
 3 files changed, 277 insertions(+), 28 deletions(-)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index db20feb4da..b2e5494e78 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -639,12 +639,17 @@ static u8 spi_nor_convert_3to4_erase(u8 opcode)
 static void spi_nor_set_4byte_opcodes(struct spi_nor *nor,
  const struct flash_info *info)
 {
+   bool shift = 0;
+
+   if (nor->flags & SNOR_F_HAS_PARALLEL)
+   shift = 1;
+
/* Do some manufacturer fixups first */
switch (JEDEC_MFR(info)) {
case SNOR_MFR_SPANSION:
/* No small sector erase for 4-byte command set */
nor->erase_opcode = SPINOR_OP_SE;
-   nor->mtd.erasesize = info->sector_size;
+   nor->mtd.erasesize = info->sector_size << shift;
break;
 
default:
@@ -965,8 +970,8 @@ static int spi_nor_erase_sector(struct spi_nor *nor, u32 
addr)
 static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
 {
struct spi_nor *nor = mtd_to_spi_nor(mtd);
+   u32 addr, len, rem, offset;
bool addr_known = false;
-   u32 addr, len, rem;
int ret, err;
 
dev_dbg(nor->dev, "at 0x%llx, len %lld\n", (long long)instr->addr,
@@ -991,6 +996,19 @@ static int spi_nor_erase(struct mtd_info *mtd, struct 
erase_info *instr)
ret = -EINTR;
goto erase_err;
}
+
+   offset = addr;
+   if (nor->flags & SNOR_F_HAS_PARALLEL)
+   offset /= 2;
+
+   if (nor->flags & SNOR_F_HAS_STACKED) {
+   if (offset >= (mtd->size / 2)) {
+   offset = offset - (mtd->size / 2);
+   nor->spi->flags |= SPI_XFER_U_PAGE;
+   } else {
+   nor->spi->flags &= ~SPI_XFER_U_PAGE;
+   }
+   }
 #ifdef CONFIG_SPI_FLASH_BAR
ret = write_bar(nor, addr);
if (ret < 0)
@@ -1394,6 +1412,9 @@ static const struct flash_info *spi_nor_read_id(struct 
spi_nor *nor)
u8  id[SPI_NOR_MAX_ID_LEN];
const struct flash_info *info;
 
+   if (nor->flags & SNOR_F_HAS_PARALLEL)
+   nor->spi->flags |= SPI_XFER_LOWER;
+
tmp = nor->read_reg(nor, SPINOR_OP_RDID, id, SPI_NOR_MAX_ID_LEN);
if (tmp < 0) {
dev_dbg(nor->dev, "error %d reading JEDEC ID\n", tmp);
@@ -1418,28 +1439,57 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t 
from, size_t len,
 {
struct spi_nor *nor = mtd_to_spi_nor(mtd);
int ret;
+   u32 offset = from;
+   u32 stack_shift = 0;
+   u32 read_len = 0;
+   u32 rem_bank_len = 0;
+   u8 bank;
+   u8 is_ofst_odd = 0;
 
dev_dbg(nor->dev, "from 0x%08x, len %zd\n", (u32)from, len);
 
-   while (len) {
-   loff_t addr = from;
-   size_t read_len = len;
+   if ((nor->flags & SNOR_F_HAS_PARALLEL) && (offset & 1)) {
+   /* We can hit this case when we use file system like ubifs */
+   from = (loff_t)(from - 1);
+   len = (size_t)(len + 1);
+   is_ofst_odd = 1;
+   }
 
-#ifdef CONFIG_SPI_FLASH_BAR
-   u32 remain_len;
+   while (len) {
+   if (nor->addr_width == 3) {
+   if (nor->flags & SNOR_F_HAS_PARALLEL) {
+   bank = (u32)from / (SZ_16M << 0x01);

[PATCH v3 0/6] spi-nor: Add parallel and stacked memories support

2023-10-19 Thread Venkatesh Yadav Abbarapu
This series adds support for Xilinx qspi parallel and stacked memeories.

In parallel mode, the current implementation assumes that a maximum of
two flashes are connected. The QSPI controller splits the data evenly
between both the flashes so, both the flashes that are connected in
parallel mode should be identical.
During each operation SPI-NOR sets 0th bit for CS0 & 1st bit for CS1 in
nor->flags.

In stacked mode the current implementation assumes that a maximum of two
flashes are connected and both the flashes are of same make but can differ
in sizes. So, except the sizes all other flash parameters of both the flashes
are identical.

Spi-nor will pass on the appropriate flash select flag to low level driver,
and it will select pass all the data to that particular flash.

Write operation in parallel mode are performed in page size * 2 chunks as each
write operation results in writing both the flashes. For doubling the address
space each operation is performed at addr/2 flash offset, where addr is the
address specified by the user.

Similarly for read and erase operations it will read from both flashes, so size
and offset are divided by 2 and send to flash.

Changes in v2:
- Fixed the compilation issues.
Changes in v3:
- Fixed the CI issues.

Ashok Reddy Soma (4):
  mtd: spi-nor: Add parallel and stacked memories support
  mtd: spi-nor: Add parallel memories support for read_sr and read_fsr
  mtd: spi-nor: Add parallel and stacked memories support in read_bar
and write_bar
  spi: spi-uclass: Read chipselect and restrict capabilities

Venkatesh Yadav Abbarapu (2):
  spi: zynqmp_gqspi: Add parallel memories support in GQSPI driver
  spi: zynq_qspi: Add parallel memories support in QSPI driver

 drivers/mtd/spi/sandbox.c  |   2 +-
 drivers/mtd/spi/spi-nor-core.c | 385 -
 drivers/spi/altera_spi.c   |   4 +-
 drivers/spi/atcspi200_spi.c|   2 +-
 drivers/spi/ath79_spi.c|   2 +-
 drivers/spi/atmel_spi.c|   6 +-
 drivers/spi/bcm63xx_hsspi.c|  42 ++--
 drivers/spi/bcm63xx_spi.c  |   6 +-
 drivers/spi/bcmbca_hsspi.c |  34 +--
 drivers/spi/cf_spi.c   |   6 +-
 drivers/spi/davinci_spi.c  |   6 +-
 drivers/spi/fsl_dspi.c |  18 +-
 drivers/spi/fsl_espi.c |   4 +-
 drivers/spi/fsl_qspi.c |   4 +-
 drivers/spi/gxp_spi.c  |   2 +-
 drivers/spi/mpc8xx_spi.c   |   4 +-
 drivers/spi/mpc8xxx_spi.c  |  10 +-
 drivers/spi/mscc_bb_spi.c  |   4 +-
 drivers/spi/mxc_spi.c  |   6 +-
 drivers/spi/npcm_fiu_spi.c |  14 +-
 drivers/spi/nxp_fspi.c |   2 +-
 drivers/spi/octeon_spi.c   |   2 +-
 drivers/spi/omap3_spi.c|   4 +-
 drivers/spi/pic32_spi.c|   2 +-
 drivers/spi/rk_spi.c   |   4 +-
 drivers/spi/rockchip_sfc.c |   2 +-
 drivers/spi/spi-aspeed-smc.c   |  28 +--
 drivers/spi/spi-mxic.c |   6 +-
 drivers/spi/spi-qup.c  |   4 +-
 drivers/spi/spi-sifive.c   |   6 +-
 drivers/spi/spi-sn-f-ospi.c|   2 +-
 drivers/spi/spi-sunxi.c|   6 +-
 drivers/spi/spi-synquacer.c|   4 +-
 drivers/spi/spi-uclass.c   |  21 +-
 drivers/spi/stm32_qspi.c   |   2 +-
 drivers/spi/stm32_spi.c|   4 +-
 drivers/spi/ti_qspi.c  |  14 +-
 drivers/spi/xilinx_spi.c   |   4 +-
 drivers/spi/zynq_qspi.c| 146 +++--
 drivers/spi/zynq_spi.c |   6 +-
 drivers/spi/zynqmp_gqspi.c | 142 ++--
 include/linux/mtd/spi-nor.h|  13 ++
 include/spi.h  |  30 ++-
 lib/acpi/acpi_device.c |   2 +-
 44 files changed, 789 insertions(+), 228 deletions(-)

-- 
2.25.1



Re: [PATCH 2/2] bootcount: Add driver model I2C driver

2023-10-19 Thread Heiko Schocher
Hello Philip,

On 18.10.23 18:10, Simon Glass wrote:
> Hi Philip,
> 
> On Wed, 18 Oct 2023 at 05:00, Philip Oberfichtner  > wrote:
>>
>> Hi Heiko,
>>
>> On Wed, Oct 18, 2023 at 06:31:57AM +0200, Heiko Schocher wrote:
>> > [...]
>> >
>> > May Philip can use uclass_get_device_by_phandle and try a list of
>> > possible UCLASS candidates, like UCLASS_RTC, UCLASS_I2C_EEPROM,
>> > UCLASS_POWER,... and if found, check if parent is UCLASS_I2C...
>> >
>> > may not so expensive ...
>>
>> Looks more cheap and elegant than the other variants indeed. But I'm not
>> sure if we can maintain generality using this approach.
>>
>> What if the specific I2C driver is not included in the build, because
>> the devices "actual" functionality is not required?
> 
> Then the device will not be bound and the function will fail. There needs to 
> be a node and a bound
> device.

Yep.

>> Or what if a driver
>> for the specific device does not even exist in U-Boot?
>>
>> Wouldn't the device fail to probe then?
> 
> The DT should specify the compatible string so the correct i2c driver is 
> used. If there isn't one,I
> believe it uses I2C_GENERIC but you'll need to check it.

Yes, needs a check.

But... that is the real issue with that approach (more or less with
all bootcounter drivers?) ... if you assume that the device driver
is not there, may there is missing device init/probe stuff, so also
may the bootcounter will not work!

The i2c device should know, that some registers, mem (or whatever) is
used for bootcounter function, so that it does not use this space for
other device stuff ... to make bootcounters correct, we need something
like a MFD approach here ... and register a bootcounter within that...
so init/probe stuff is always done, and registers/mem is reserved ...

But unfortunately we do not have this...

>> Please correct me if I'm wrong, I'd give it a shot in that case.
>> Otherwise I'll try it with the aforementioned
>> device_find_global_by_ofnode() followed by device_bind_driver() using
>> UCLASS_I2C_GENERIC (I hope that works).
> 
> That is the same approach, I think. But anyway I think Heiko knows more about 
> this than me.

Hmm... yes, with UCLASS_I2C_GENERIC it could also work, but see my
comment above ...

bye,
Heiko
-- 
DENX Software Engineering GmbH,  Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


Re: Branches in uboot-imx

2023-10-19 Thread Fabio Estevam
Hi Grzegorz,

On Thu, Oct 19, 2023 at 11:58 AM Grzegorz Borowiak  wrote:
>
> Hello!
>
> I just cloned the repository:
>
> https://github.com/nxp-imx/uboot-imx

This is a U-Boot fork maintained by NXP.

Only NXP can help you with this one.

> and I encountered a rather large amount of branches (listed below).
>
> Are these branches somehow described, so I could read what they are about?
> Especially I'm interested in branches whose names begin with "imx" and
> "lf". What are differences between them, and how are they different from
> branches here:
>
> https://github.com/u-boot/u-boot

This is the mainline repo, which is developed by the U-Boot community.

i.MX SoCs are well supported in mainline U-Boot, so give it a try with
mainline :-)


[PATCH] clock_imx8mm: Add a stub for imx8mp_fec_interface_init()

2023-10-19 Thread Fabio Estevam
From: Fabio Estevam 

When CONFIG_DWC_ETH_QOS_IMX=y and CONFIG_FEC_MXC is not selected, the
following warning is seen: 

arch/arm/mach-imx/imx8m/clock_imx8mm.c: In function 'board_interface_eth_init':
arch/arm/mach-imx/imx8m/clock_imx8mm.c:914:24: warning: implicit declaration of 
function 'imx8mp_fec_interface_init; did you mean 'imx8mp_eqos_interface_init'? 
[-Wimplicit-function-declaration]

Fix it by adding a stub for imx8mp_fec_interface_init() to handle this
case.

This follows the same approach done on imx8mp_eqos_interface_init().

Signed-off-by: Fabio Estevam 
---
 arch/arm/mach-imx/imx8m/clock_imx8mm.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/mach-imx/imx8m/clock_imx8mm.c 
b/arch/arm/mach-imx/imx8m/clock_imx8mm.c
index 986870799d36..5cf97a5ea952 100644
--- a/arch/arm/mach-imx/imx8m/clock_imx8mm.c
+++ b/arch/arm/mach-imx/imx8m/clock_imx8mm.c
@@ -904,6 +904,13 @@ static int imx8mp_fec_interface_init(struct udevice *dev,
 
return 0;
 }
+#else
+static int imx8mp_fec_interface_init(struct udevice *dev,
+phy_interface_t interface_type,
+bool mx8mp)
+{
+   return 0;
+}
 #endif
 
 int board_interface_eth_init(struct udevice *dev, phy_interface_t 
interface_type)
-- 
2.34.1



Re: Falcon mode on RISC-V

2023-10-19 Thread Randolph Lin
On Thu, Oct 19, 2023 at 10:49:56PM +0200, Heinrich Schuchardt wrote:
Hi Heinrich
> Hello Randolph,
> 
> I just saw your patches merged to enable Falcon mode on RISC-V using
> CONFIG_SPL_LOAD_FIT_OPENSBI_OS_BOOT. I did not see any documentation update.
> 
> Should information about your development be added to
> doc/develop/falcon.rst? Would you be willing to provide a patch?
> 
> Best regards
> 
> Heinrich
Thanks a lot, I will update it ASAP.

Randolph
Sincerely



Re: [PATCH v3 22/32] efi: Update EFI_LOADER to depend on DM_ETH

2023-10-19 Thread AKASHI Takahiro
On Thu, Oct 19, 2023 at 08:01:11AM -0600, Simon Glass wrote:
> Hi Heinrich,
> 
> On Wed, 18 Oct 2023 at 06:55, Heinrich Schuchardt  wrote:
> >
> > On 10/17/23 16:09, Tom Rini wrote:
> > > On Mon, Oct 16, 2023 at 04:28:13PM -0600, Simon Glass wrote:
> > >
> > >> Since efi_device_path.c calls eth_get_dev() and assumes that Ethernet is
> > >> available, add it as an explicit dependency.
> > >>
> > >> Signed-off-by: Simon Glass 
> > >> ---
> > >>
> > >> (no changes since v2)
> > >>
> > >> Changes in v2:
> > >> - Add new patch to update EFI_LOADER to depend on DM_ETH
> > >>
> > >>   lib/efi_loader/Kconfig | 1 +
> > >>   1 file changed, 1 insertion(+)
> > >>
> > >> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> > >> index 13cad6342c36..fca4b3eef270 100644
> > >> --- a/lib/efi_loader/Kconfig
> > >> +++ b/lib/efi_loader/Kconfig
> > >> @@ -11,6 +11,7 @@ config EFI_LOADER
> > >>  # We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB
> > >>  depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT
> > >>  depends on BLK
> > >> +depends on DM_ETH
> > >>  depends on !EFI_APP
> > >>  default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8
> > >>  select CHARSET
> > >
> > > Does this work for you Heinrich, or do you want to clarify the
> > > dependencies (and re-organize the code as needed) around networking?
> > >
> >
> > We should be able to boot via EFI on devices without U-Boot network support.
> >
> > We already use IS_ENABLED(CONFIG_NETDEVICES) to avoid invoking
> > eth_get_dev() if there is no network. CONFIG_NETDEVICES=y selects
> > CONFIG_DM_ETH.
> >
> > Why is this not sufficient?
> > Is there a configuration that does not build?
> 
> The point of this series is to disable CMDLINE and fix up what breaks.
> 
> In this case we have some sort of breakage...perhaps Tom has already
> found it, but otherwise could you take a look?
> 
> We should be able to disable NET and LTO in sandbox and still build.
> But this fails at present[1]. You can try it on -master

Obviously, it would be necessary to enclose efi_dp_from_eth()
with "if defined(CONFIG_NETDEVICES)" (or DM_ETH).
Then, we could drop "depends on DM_ETH".

Another possible place for completeness is "case UCLASS_ETH" clause
in dp_size(), but it seems to be harmless.

-Takahiro Akashi


> Regards,
> Simon
> 
> [1] sjg@sjg1:~/u$ crosfw sandbox -L
> cmd: make -j4 'CROSS_COMPILE=' --no-print-directory 'HOSTSTRIP=true'
> 'QEMU_ARCH=' 'KCONFIG_NOSILENTUPDATE=1' 'O=/tmp/b/sandbox' 'NO_LTO=1'
> -s 'BUILD_ROM=1' all
> /usr/bin/ld: lib/efi_loader/efi_device_path.o: in function `efi_dp_from_eth':
> /home/sjg/c/src/third_party/u-boot/files/lib/efi_loader/efi_device_path.c:985:(.text+0xca4):
> undefined reference to `eth_get_dev'
> /usr/bin/ld: 
> /home/sjg/c/src/third_party/u-boot/files/lib/efi_loader/efi_device_path.c:987:(.text+0xca9):
> undefined reference to `eth_get_dev'
> /usr/bin/ld: 
> /home/sjg/c/src/third_party/u-boot/files/lib/efi_loader/efi_device_path.c:993:(.text+0xcc9):
> undefined reference to `eth_get_dev'
> collect2: error: ld returned 1 exit status
> make[1]: *** [/home/sjg/c/src/third_party/u-boot/files/Makefile:1765:
> u-boot] Error 1
> make: *** [Makefile:177: sub-make] Error 2
> 
> sjg@sjg1:~/u$ crosfw sandbox
> sjg@sjg1:~/u$ (passes)
> 
> 'crosfw xx' is just 'buildman --bo xxx'
> 
> diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
> index a92bb896c63e..4e9996a92342 100644
> --- a/boot/pxe_utils.c
> +++ b/boot/pxe_utils.c
> @@ -48,7 +48,7 @@ int pxe_get_file_size(ulong *sizep)
> 
>   return 0;
>  }
> -
> +#if 0
>  /**
>   * format_mac_pxe() - obtain a MAC address in the PXE format
>   *
> @@ -82,7 +82,7 @@ int format_mac_pxe(char *outbuf, size_t outbuf_len)
> 
>   return 1;
>  }
> -
> +#endif
>  /**
>   * get_relfile() - read a file relative to the PXE file
>   *
> diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
> index 47417cb0391d..57bb6202dbb5 100644
> --- a/configs/sandbox_defconfig
> +++ b/configs/sandbox_defconfig
> @@ -349,3 +349,4 @@ CONFIG_TEST_FDTDEC=y
>  CONFIG_UNIT_TEST=y
>  CONFIG_UT_TIME=y
>  CONFIG_UT_DM=y
> +# CONFIG_NET is not set
> 
> Regards,
> Simon


[PATCH 3/3] sunxi: dts: arm: add T113s/D1 DT files from Linux-v6.6-rc6

2023-10-19 Thread Andre Przywara
This copies in some devicetree files from the official Linux kernel tree,
v6.6-rc6. It covers a board with the Allwinner T113s SoC, which shares
many devices with its RISC-V sibling, the Allwinner D1(s). This is the
reason for the core .dtsi files landing in the arch/riscv directory.

We are only adjusting the include path to accommodate for the differences
in the U-Boot build system.

Signed-off-by: Andre Przywara 
---
 .../arm/dts/sun8i-t113s-mangopi-mq-r-t113.dts |  35 +
 arch/arm/dts/sun8i-t113s.dtsi |  59 ++
 arch/arm/dts/sunxi-d1s-t113-mangopi-mq-r.dtsi | 126 +++
 arch/riscv/dts/sunxi-d1-t113.dtsi |  15 +
 arch/riscv/dts/sunxi-d1s-t113.dtsi| 927 ++
 include/dt-bindings/clock/sun20i-d1-ccu.h | 158 +++
 include/dt-bindings/clock/sun20i-d1-r-ccu.h   |  19 +
 include/dt-bindings/reset/sun20i-d1-ccu.h |  79 ++
 include/dt-bindings/reset/sun20i-d1-r-ccu.h   |  16 +
 9 files changed, 1434 insertions(+)
 create mode 100644 arch/arm/dts/sun8i-t113s-mangopi-mq-r-t113.dts
 create mode 100644 arch/arm/dts/sun8i-t113s.dtsi
 create mode 100644 arch/arm/dts/sunxi-d1s-t113-mangopi-mq-r.dtsi
 create mode 100644 arch/riscv/dts/sunxi-d1-t113.dtsi
 create mode 100644 arch/riscv/dts/sunxi-d1s-t113.dtsi
 create mode 100644 include/dt-bindings/clock/sun20i-d1-ccu.h
 create mode 100644 include/dt-bindings/clock/sun20i-d1-r-ccu.h
 create mode 100644 include/dt-bindings/reset/sun20i-d1-ccu.h
 create mode 100644 include/dt-bindings/reset/sun20i-d1-r-ccu.h

diff --git a/arch/arm/dts/sun8i-t113s-mangopi-mq-r-t113.dts 
b/arch/arm/dts/sun8i-t113s-mangopi-mq-r-t113.dts
new file mode 100644
index 000..8b3a7538381
--- /dev/null
+++ b/arch/arm/dts/sun8i-t113s-mangopi-mq-r-t113.dts
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+// Copyright (C) 2022 Arm Ltd.
+
+#include 
+
+/dts-v1/;
+
+#include "sun8i-t113s.dtsi"
+#include "sunxi-d1s-t113-mangopi-mq-r.dtsi"
+
+/ {
+   model = "MangoPi MQ-R-T113";
+   compatible = "widora,mangopi-mq-r-t113", "allwinner,sun8i-t113s";
+
+   aliases {
+   ethernet0 = 
+   };
+};
+
+ {
+   cpu-supply = <_vcc_core>;
+};
+
+ {
+   cpu-supply = <_vcc_core>;
+};
+
+ {
+   rtl8189ftv: wifi@1 {
+   reg = <1>;
+   interrupt-parent = <>;
+   interrupts = <6 10 IRQ_TYPE_LEVEL_LOW>; /* PG10 = WL_WAKE_AP */
+   interrupt-names = "host-wake";
+   };
+};
diff --git a/arch/arm/dts/sun8i-t113s.dtsi b/arch/arm/dts/sun8i-t113s.dtsi
new file mode 100644
index 000..b94b69142af
--- /dev/null
+++ b/arch/arm/dts/sun8i-t113s.dtsi
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+// Copyright (C) 2022 Arm Ltd.
+
+#define SOC_PERIPHERAL_IRQ(nr) GIC_SPI nr
+
+#include 
+#include <../../riscv/dts/sunxi-d1s-t113.dtsi>
+#include <../../riscv/dts/sunxi-d1-t113.dtsi>
+
+/ {
+   interrupt-parent = <>;
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   compatible = "arm,cortex-a7";
+   device_type = "cpu";
+   reg = <0>;
+   clocks = < CLK_CPUX>;
+   clock-names = "cpu";
+   };
+
+   cpu1: cpu@1 {
+   compatible = "arm,cortex-a7";
+   device_type = "cpu";
+   reg = <1>;
+   clocks = < CLK_CPUX>;
+   clock-names = "cpu";
+   };
+   };
+
+   gic: interrupt-controller@1c81000 {
+   compatible = "arm,gic-400";
+   reg = <0x03021000 0x1000>,
+ <0x03022000 0x2000>,
+ <0x03024000 0x2000>,
+ <0x03026000 0x2000>;
+   interrupts = ;
+   interrupt-controller;
+   #interrupt-cells = <3>;
+   };
+
+   timer {
+   compatible = "arm,armv7-timer";
+   interrupts = ,
+,
+,
+;
+   };
+
+   pmu {
+   compatible = "arm,cortex-a7-pmu";
+   interrupts = ,
+;
+   interrupt-affinity = <>, <>;
+   };
+};
diff --git a/arch/arm/dts/sunxi-d1s-t113-mangopi-mq-r.dtsi 
b/arch/arm/dts/sunxi-d1s-t113-mangopi-mq-r.dtsi
new file mode 100644
index 000..a415c4a78a7
--- /dev/null
+++ b/arch/arm/dts/sunxi-d1s-t113-mangopi-mq-r.dtsi
@@ -0,0 +1,126 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+// Copyright (C) 2022 Arm Ltd.
+/*
+ * Common peripherals and configurations for MangoPi MQ-R boards.
+ */
+
+#include 
+#include 
+
+/ {
+   aliases {
+   serial3 = 
+   };
+
+   chosen {
+   stdout-path = "serial3:115200n8";
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   

[PATCH 1/3] sunxi: dts: arm64: update devicetree files from Linux-v6.6-rc6

2023-10-19 Thread Andre Przywara
Sync the devicetree files from the official Linux kernel tree, v6.6-rc6.
This is covering Allwinner SoCs with 64-bit ARM cores.

Only small cosmetic changes (clock name fixed), but we add the DT for
the new OrangePi Zero 3 board, for which U-Boot enablement patches are
pending.

As before, this omits the non-backwards compatible changes to the R_INTC
controller, to remain compatible with older kernels.

Signed-off-by: Andre Przywara 
---
 arch/arm/dts/sun50i-a64.dtsi|   3 +-
 arch/arm/dts/sun50i-h6-pine-h64-model-b.dts |   2 +-
 arch/arm/dts/sun50i-h616-orangepi-zero.dtsi | 134 
 arch/arm/dts/sun50i-h616-orangepi-zero2.dts | 121 +-
 arch/arm/dts/sun50i-h616-x96-mate.dts   |   2 +-
 arch/arm/dts/sun50i-h618-orangepi-zero3.dts |  94 ++
 include/dt-bindings/clock/sun50i-h6-ccu.h   |   2 +-
 include/dt-bindings/clock/sun50i-h616-ccu.h |   2 +-
 include/dt-bindings/clock/sun6i-rtc.h   |   2 +-
 include/dt-bindings/reset/sun50i-h6-ccu.h   |   2 +-
 include/dt-bindings/reset/sun50i-h6-r-ccu.h |   2 +-
 include/dt-bindings/reset/sun50i-h616-ccu.h |   2 +-
 12 files changed, 240 insertions(+), 128 deletions(-)
 create mode 100644 arch/arm/dts/sun50i-h616-orangepi-zero.dtsi
 create mode 100644 arch/arm/dts/sun50i-h618-orangepi-zero3.dts

diff --git a/arch/arm/dts/sun50i-a64.dtsi b/arch/arm/dts/sun50i-a64.dtsi
index 135762b34fd..2240eaec5dd 100644
--- a/arch/arm/dts/sun50i-a64.dtsi
+++ b/arch/arm/dts/sun50i-a64.dtsi
@@ -93,6 +93,7 @@
L2: l2-cache {
compatible = "cache";
cache-level = <2>;
+   cache-unified;
};
};
 
@@ -407,7 +408,7 @@
interrupts = ;
clocks = < CLK_BUS_TCON0>, < CLK_TCON0>;
clock-names = "ahb", "tcon-ch0";
-   clock-output-names = "tcon-pixel-clock";
+   clock-output-names = "tcon-data-clock";
#clock-cells = <0>;
resets = < RST_BUS_TCON0>, < RST_BUS_LVDS>;
reset-names = "lcd", "lvds";
diff --git a/arch/arm/dts/sun50i-h6-pine-h64-model-b.dts 
b/arch/arm/dts/sun50i-h6-pine-h64-model-b.dts
index 686f58e7700..b710f1a0f53 100644
--- a/arch/arm/dts/sun50i-h6-pine-h64-model-b.dts
+++ b/arch/arm/dts/sun50i-h6-pine-h64-model-b.dts
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: (GPL-2.0+ or MIT)
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
 /*
  * Copyright (C) 2019 Corentin LABBE 
  */
diff --git a/arch/arm/dts/sun50i-h616-orangepi-zero.dtsi 
b/arch/arm/dts/sun50i-h616-orangepi-zero.dtsi
new file mode 100644
index 000..15290e6892f
--- /dev/null
+++ b/arch/arm/dts/sun50i-h616-orangepi-zero.dtsi
@@ -0,0 +1,134 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2020 Arm Ltd.
+ *
+ * DT nodes common between Orange Pi Zero 2 and Orange Pi Zero 3.
+ * Excludes PMIC nodes and properties, since they are different between the 
two.
+ */
+
+#include "sun50i-h616.dtsi"
+
+#include 
+#include 
+#include 
+
+/ {
+   aliases {
+   ethernet0 = 
+   serial0 = 
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   led-0 {
+   function = LED_FUNCTION_POWER;
+   color = ;
+   gpios = < 2 12 GPIO_ACTIVE_HIGH>; /* PC12 */
+   default-state = "on";
+   };
+
+   led-1 {
+   function = LED_FUNCTION_STATUS;
+   color = ;
+   gpios = < 2 13 GPIO_ACTIVE_HIGH>; /* PC13 */
+   };
+   };
+
+   reg_vcc5v: vcc5v {
+   /* board wide 5V supply directly from the USB-C socket */
+   compatible = "regulator-fixed";
+   regulator-name = "vcc-5v";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   regulator-always-on;
+   };
+
+   reg_usb1_vbus: regulator-usb1-vbus {
+   compatible = "regulator-fixed";
+   regulator-name = "usb1-vbus";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_vcc5v>;
+   enable-active-high;
+   gpio = < 2 16 GPIO_ACTIVE_HIGH>; /* PC16 */
+   };
+};
+
+ {
+   status = "okay";
+};
+
+/* USB 2 & 3 are on headers only. */
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_rgmii_pins>;
+   phy-mode = "rgmii";
+   phy-handle = <_rgmii_phy>;
+   allwinner,rx-delay-ps = <3100>;
+   allwinner,tx-delay-ps = <700>;
+   status = "okay";
+};
+
+ {
+   ext_rgmii_phy: ethernet-phy@1 {
+   compatible = "ethernet-phy-ieee802.3-c22";

[PATCH 2/3] sunxi: dts: arm: update devicetree files from Linux-v6.6-rc6

2023-10-19 Thread Andre Przywara
Sync the devicetree files from the official Linux kernel tree, v6.6-rc6.
This is covering Allwinner SoCs with 32-bit ARM cores, minus the T113s
board and related .dtsi files, which come separately.

Only small changes: Bluetooth got enabled on the C.H.I.P., and a clock
got renamed. More interesting is the addition of a board, for which
U-Boot enablement patches are pending.

As before, this omits the non-backwards compatible changes to the R_INTC
controller, to remain compatible with older kernels.

Signed-off-by: Andre Przywara 
---
 arch/arm/dts/axp209.dtsi  |   7 +
 arch/arm/dts/sun5i-r8-chip.dts|   6 +
 arch/arm/dts/sun5i.dtsi   |  11 +-
 arch/arm/dts/sun7i-a20-icnova-a20-adb4006.dts | 137 ++
 arch/arm/dts/sun7i-a20-icnova-a20.dtsi|  62 
 arch/arm/dts/sun8i-a23-a33.dtsi   |   2 +-
 arch/arm/dts/sun8i-a83t.dtsi  |   2 +-
 arch/arm/dts/sun8i-v3s.dtsi   |   2 +-
 8 files changed, 225 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/dts/sun7i-a20-icnova-a20-adb4006.dts
 create mode 100644 arch/arm/dts/sun7i-a20-icnova-a20.dtsi

diff --git a/arch/arm/dts/axp209.dtsi b/arch/arm/dts/axp209.dtsi
index ca240cd6f6c..469d0f7d518 100644
--- a/arch/arm/dts/axp209.dtsi
+++ b/arch/arm/dts/axp209.dtsi
@@ -48,6 +48,13 @@
  * http://dl.linux-sunxi.org/AXP/AXP209%20Datasheet%20v1.0_cn.pdf
  */
 
+/ {
+   pmic-temp {
+   compatible = "iio-hwmon";
+   io-channels = <_adc 4>; /* Internal temperature */
+   };
+};
+
  {
compatible = "x-powers,axp209";
interrupt-controller;
diff --git a/arch/arm/dts/sun5i-r8-chip.dts b/arch/arm/dts/sun5i-r8-chip.dts
index fd37bd1f392..4192c23848c 100644
--- a/arch/arm/dts/sun5i-r8-chip.dts
+++ b/arch/arm/dts/sun5i-r8-chip.dts
@@ -255,6 +255,12 @@
pinctrl-0 = <_pg_pins>,
<_cts_rts_pg_pins>;
status = "okay";
+
+   bluetooth {
+   compatible = "realtek,rtl8723bs-bt";
+   device-wake-gpios = <_gpio 3 GPIO_ACTIVE_HIGH>;
+   host-wake-gpios = < 1 3 GPIO_ACTIVE_HIGH>; /* PB3 */
+   };
 };
 
 _otg {
diff --git a/arch/arm/dts/sun5i.dtsi b/arch/arm/dts/sun5i.dtsi
index 250d6b87ab4..d7c7b454a11 100644
--- a/arch/arm/dts/sun5i.dtsi
+++ b/arch/arm/dts/sun5i.dtsi
@@ -286,7 +286,7 @@
clock-names = "ahb",
  "tcon-ch0",
  "tcon-ch1";
-   clock-output-names = "tcon-pixel-clock";
+   clock-output-names = "tcon-data-clock";
#clock-cells = <0>;
status = "disabled";
 
@@ -517,6 +517,15 @@
bias-pull-up;
};
 
+   /omit-if-no-ref/
+   mmc2_4bit_pe_pins: mmc2-4bit-pe-pins {
+   pins = "PE4", "PE5", "PE6", "PE7",
+  "PE8", "PE9";
+   function = "mmc2";
+   drive-strength = <30>;
+   bias-pull-up;
+   };
+
mmc2_8bit_pins: mmc2-8bit-pins {
pins = "PC6", "PC7", "PC8", "PC9",
   "PC10", "PC11", "PC12", "PC13",
diff --git a/arch/arm/dts/sun7i-a20-icnova-a20-adb4006.dts 
b/arch/arm/dts/sun7i-a20-icnova-a20-adb4006.dts
new file mode 100644
index 000..577ead1d02a
--- /dev/null
+++ b/arch/arm/dts/sun7i-a20-icnova-a20-adb4006.dts
@@ -0,0 +1,137 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+// Copyright (C) 2023 In-Circuit GmbH
+
+/dts-v1/;
+
+#include "sun7i-a20-icnova-a20.dtsi"
+
+#include 
+#include 
+
+/ {
+   model = "In-Circuit ICnova A20 ADB4006";
+   compatible = "incircuit,icnova-a20-adb4006", "incircuit,icnova-a20",
+"allwinner,sun7i-a20";
+
+   aliases {
+   serial0 = 
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   hdmi-connector {
+   compatible = "hdmi-connector";
+   type = "a";
+
+   port {
+   hdmi_con_in: endpoint {
+   remote-endpoint = <_out_con>;
+   };
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   led-0 {
+   function = LED_FUNCTION_POWER;
+   color = ;
+   gpios = < 7 21 GPIO_ACTIVE_HIGH>; /* PH21 */
+   default-state = "on";
+   };
+
+   led-1 {
+   function = LED_FUNCTION_HEARTBEAT;
+   color = ;
+   gpios = < 7 20 GPIO_ACTIVE_HIGH>; /* PH20 */
+   

[PATCH 0/3] sunxi: devicetree updates from Linux v6.6

2023-10-19 Thread Andre Przywara
This updates the devicetree files to match the Linux kernel repository
as of v6.6-rc6.
Mostly cosmetic changes, but we gain some new board files and the T113s
board .dtsi files, which are needed for the pending U-Boot patches.

Split per architecture, with the T113s being separate due to its RISC-V
relationship.

Andre Przywara (3):
  sunxi: dts: arm64: update devicetree files from Linux-v6.6-rc6
  sunxi: dts: arm: update devicetree files from Linux-v6.6-rc6
  sunxi: dts: arm: add T113s/D1 DT files from Linux-v6.6-rc6

 arch/arm/dts/axp209.dtsi  |   7 +
 arch/arm/dts/sun50i-a64.dtsi  |   3 +-
 arch/arm/dts/sun50i-h6-pine-h64-model-b.dts   |   2 +-
 arch/arm/dts/sun50i-h616-orangepi-zero.dtsi   | 134 +++
 arch/arm/dts/sun50i-h616-orangepi-zero2.dts   | 121 +--
 arch/arm/dts/sun50i-h616-x96-mate.dts |   2 +-
 arch/arm/dts/sun50i-h618-orangepi-zero3.dts   |  94 ++
 arch/arm/dts/sun5i-r8-chip.dts|   6 +
 arch/arm/dts/sun5i.dtsi   |  11 +-
 arch/arm/dts/sun7i-a20-icnova-a20-adb4006.dts | 137 +++
 arch/arm/dts/sun7i-a20-icnova-a20.dtsi|  62 ++
 arch/arm/dts/sun8i-a23-a33.dtsi   |   2 +-
 arch/arm/dts/sun8i-a83t.dtsi  |   2 +-
 .../arm/dts/sun8i-t113s-mangopi-mq-r-t113.dts |  35 +
 arch/arm/dts/sun8i-t113s.dtsi |  59 ++
 arch/arm/dts/sun8i-v3s.dtsi   |   2 +-
 arch/arm/dts/sunxi-d1s-t113-mangopi-mq-r.dtsi | 126 +++
 arch/riscv/dts/sunxi-d1-t113.dtsi |  15 +
 arch/riscv/dts/sunxi-d1s-t113.dtsi| 927 ++
 include/dt-bindings/clock/sun20i-d1-ccu.h | 158 +++
 include/dt-bindings/clock/sun20i-d1-r-ccu.h   |  19 +
 include/dt-bindings/clock/sun50i-h6-ccu.h |   2 +-
 include/dt-bindings/clock/sun50i-h616-ccu.h   |   2 +-
 include/dt-bindings/clock/sun6i-rtc.h |   2 +-
 include/dt-bindings/reset/sun20i-d1-ccu.h |  79 ++
 include/dt-bindings/reset/sun20i-d1-r-ccu.h   |  16 +
 include/dt-bindings/reset/sun50i-h6-ccu.h |   2 +-
 include/dt-bindings/reset/sun50i-h6-r-ccu.h   |   2 +-
 include/dt-bindings/reset/sun50i-h616-ccu.h   |   2 +-
 29 files changed, 1899 insertions(+), 132 deletions(-)
 create mode 100644 arch/arm/dts/sun50i-h616-orangepi-zero.dtsi
 create mode 100644 arch/arm/dts/sun50i-h618-orangepi-zero3.dts
 create mode 100644 arch/arm/dts/sun7i-a20-icnova-a20-adb4006.dts
 create mode 100644 arch/arm/dts/sun7i-a20-icnova-a20.dtsi
 create mode 100644 arch/arm/dts/sun8i-t113s-mangopi-mq-r-t113.dts
 create mode 100644 arch/arm/dts/sun8i-t113s.dtsi
 create mode 100644 arch/arm/dts/sunxi-d1s-t113-mangopi-mq-r.dtsi
 create mode 100644 arch/riscv/dts/sunxi-d1-t113.dtsi
 create mode 100644 arch/riscv/dts/sunxi-d1s-t113.dtsi
 create mode 100644 include/dt-bindings/clock/sun20i-d1-ccu.h
 create mode 100644 include/dt-bindings/clock/sun20i-d1-r-ccu.h
 create mode 100644 include/dt-bindings/reset/sun20i-d1-ccu.h
 create mode 100644 include/dt-bindings/reset/sun20i-d1-r-ccu.h

-- 
2.35.8



Re: [PATCH v2 02/22] net: sunxi_emac: chase DT nodes to find PHY regulator

2023-10-19 Thread Samuel Holland
Hi Andre,

On 9/28/23 16:54, Andre Przywara wrote:
> At the moment the sun4i EMAC driver relies on hardcoded CONFIG_MACPWR
> Kconfig symbols to enable potential PHY regulators. As we want to get rid
> of those, we need to find the regulator by chasing up the DT.
> 
> The sun4i-emac binding puts the PHY regulator into the MDIO node, which
> is the parent of the PHY device. U-Boot does not have (and does not
> need) an MDIO driver, so we need to chase down the regulator through the
> EMAC node: we follow the "phy-handle" property to find the PHY node,
> then go up to its parent, where we find the "phy-supply" link to the
> regulator. Let U-Boot find the associated regulator device, and put that
> into the private device struct, so we can find and enable the regulator
> at probe time, later.

This does somewhat duplicate the logic from dm_eth_connect_phy_handle(),
and putting the regulator in a UCLASS_MDIO device's probe function would
work out cleanly (albeit with the usual DM overhead). But that can be a
later refactoring.

> Signed-off-by: Andre Przywara 
> Reviewed-by: Sam Edwards 
> ---
>  drivers/net/sunxi_emac.c | 39 +++
>  1 file changed, 39 insertions(+)
> 
> diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c
> index 4c90d4b4981..f1f0e52 100644
> --- a/drivers/net/sunxi_emac.c
> +++ b/drivers/net/sunxi_emac.c
> @@ -17,6 +17,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  /* EMAC register  */
>  struct emac_regs {
> @@ -165,6 +166,7 @@ struct emac_eth_dev {
>   struct phy_device *phydev;
>   int link_printed;
>   uchar rx_buf[EMAC_RX_BUFSIZE];
> + struct udevice *phy_reg;
>  };
>  
>  struct emac_rxhdr {
> @@ -572,6 +574,9 @@ static int sunxi_emac_eth_probe(struct udevice *dev)
>   if (ret)
>   return ret;
>  
> + if (priv->phy_reg)
> + regulator_set_enable(priv->phy_reg, true);
> +
>   return sunxi_emac_init_phy(priv, dev);
>  }
>  
> @@ -585,9 +590,43 @@ static const struct eth_ops sunxi_emac_eth_ops = {
>  static int sunxi_emac_eth_of_to_plat(struct udevice *dev)
>  {
>   struct eth_pdata *pdata = dev_get_plat(dev);
> + struct emac_eth_dev *priv = dev_get_priv(dev);
> + struct ofnode_phandle_args args;
> + ofnode mdio_node;
> + int ret;
>  
>   pdata->iobase = dev_read_addr(dev);
>  
> + /* The PHY regulator is in the MDIO node, not the EMAC or PHY node. */
> + ret = dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, );

You can use dev_get_phy_node() here. Either way:

Reviewed-by: Samuel Holland 

> + if (ret) {
> + dev_err(dev, "failed to get PHY node\n");
> + return ret;
> + }
> +
> + /*
> +  * U-Boot does not have (and does not need) a device driver for the
> +  * MDIO device, so just "pass through" that DT node to get to the
> +  * regulator phandle.
> +  * The PHY regulator is optional, though: ignore if we cannot find
> +  * a phy-supply property.
> +  */
> + mdio_node = ofnode_get_parent(args.node);
> + ret= ofnode_parse_phandle_with_args(mdio_node, "phy-supply", NULL, 0, 0,
> + );
> + if (ret && ret != -ENOENT) {
> + dev_err(dev, "failed to get PHY supply node\n");
> + return ret;
> + }
> + if (!ret) {
> + ret = uclass_get_device_by_ofnode(UCLASS_REGULATOR, args.node,
> +   >phy_reg);
> + if (ret) {
> + dev_err(dev, "failed to get PHY regulator node\n");
> + return ret;
> + }
> + }
> +
>   return 0;
>  }
>  



Re: [PATCH v2 12/22] clk: sunxi: Add support for the D1 CCU

2023-10-19 Thread Samuel Holland
On 9/28/23 16:54, Andre Przywara wrote:
> From: Samuel Holland 
> 
> Since the D1 CCU binding is defined, we can add support for its
> gates/resets, following the pattern of the existing drivers.
> 
> Signed-off-by: Samuel Holland 
> Reviewed-by: Andre Przywara 
> Acked-by: Sean Anderson 
> Signed-off-by: Andre Przywara 
> ---
>  drivers/clk/sunxi/Kconfig |   6 +
>  drivers/clk/sunxi/Makefile|   1 +
>  drivers/clk/sunxi/clk_d1.c|  84 
>  drivers/clk/sunxi/clk_sunxi.c |   5 +
>  include/dt-bindings/clock/sun20i-d1-ccu.h | 158 ++
>  include/dt-bindings/reset/sun20i-d1-ccu.h |  79 +++
>  6 files changed, 333 insertions(+)
>  create mode 100644 drivers/clk/sunxi/clk_d1.c
>  create mode 100644 include/dt-bindings/clock/sun20i-d1-ccu.h
>  create mode 100644 include/dt-bindings/reset/sun20i-d1-ccu.h
> 
> [...]
> diff --git a/drivers/clk/sunxi/clk_sunxi.c b/drivers/clk/sunxi/clk_sunxi.c
> index ec02a2d0370..a0011a35d91 100644
> --- a/drivers/clk/sunxi/clk_sunxi.c
> +++ b/drivers/clk/sunxi/clk_sunxi.c
> @@ -118,6 +118,7 @@ extern const struct ccu_desc a64_ccu_desc;
>  extern const struct ccu_desc a80_ccu_desc;
>  extern const struct ccu_desc a80_mmc_clk_desc;
>  extern const struct ccu_desc a83t_ccu_desc;
> +extern const struct ccu_desc d1_ccu_desc;
>  extern const struct ccu_desc f1c100s_ccu_desc;
>  extern const struct ccu_desc h3_ccu_desc;
>  extern const struct ccu_desc h6_ccu_desc;
> @@ -214,6 +215,10 @@ static const struct udevice_id sunxi_clk_ids[] = {
>  #ifdef CONFIG_CLK_SUNIV_F1C100S
>   { .compatible = "allwinner,suniv-f1c100s-ccu",
> .data = (ulong)_ccu_desc },
> +#endif
> +#ifdef CONFIG_CLK_SUN20I_D1
> + { .compatible = "allwinner,sun20i-d1-ccu",
> +   .data = (ulong)_ccu_desc },

Please keep these entries sorted numerically. Otherwise, your changes
look good to me.

Regards,
Samuel



Re: [PATCH v2 01/22] sunxi: remove CONFIG_SATAPWR

2023-10-19 Thread Samuel Holland
On 9/28/23 16:54, Andre Przywara wrote:
> The CONFIG_SATAPWR Kconfig symbol was used to point to a GPIO that
> enables the power for a SATA harddisk.
> In the DT this is described with the target-supply property in the AHCI
> DT node, pointing to a (GPIO controlled) regulator. Since we need SATA
> only in U-Boot proper, and use a DM driver for AHCI there, we should use
> the DT instead of hardcoding this.
> 
> Add code to the sunxi AHCI driver to check the DT for that regulator and
> enable it, at probe time. Then drop the current code from board.c, which
> was doing that job before.
> This allows us to remove the SATAPWR Kconfig definition and the
> respective values from the defconfigs.
> We also select the generic fixed regulator driver, which handles those
> GPIO controlled regulators.
> 
> Signed-off-by: Andre Przywara 
> Reviewed-by: Sam Edwards 
> ---
>  arch/arm/Kconfig |  2 ++
>  arch/arm/mach-sunxi/Kconfig  |  8 
>  board/sunxi/board.c  | 16 +---
>  configs/A10-OLinuXino-Lime_defconfig |  1 -
>  configs/A20-OLinuXino-Lime2-eMMC_defconfig   |  1 -
>  configs/A20-OLinuXino-Lime2_defconfig|  1 -
>  configs/A20-OLinuXino-Lime_defconfig |  1 -
>  configs/A20-OLinuXino_MICRO-eMMC_defconfig   |  1 -
>  configs/A20-OLinuXino_MICRO_defconfig|  1 -
>  configs/A20-Olimex-SOM-EVB_defconfig |  1 -
>  configs/A20-Olimex-SOM204-EVB-eMMC_defconfig |  1 -
>  configs/A20-Olimex-SOM204-EVB_defconfig  |  1 -
>  configs/Cubieboard2_defconfig|  1 -
>  configs/Cubieboard_defconfig |  1 -
>  configs/Cubietruck_defconfig |  1 -
>  configs/Itead_Ibox_A20_defconfig |  1 -
>  configs/Lamobo_R1_defconfig  |  1 -
>  configs/Linksprite_pcDuino3_Nano_defconfig   |  1 -
>  configs/Linksprite_pcDuino3_defconfig|  1 -
>  configs/Sinovoip_BPI_M3_defconfig|  1 -
>  configs/orangepi_plus_defconfig  |  2 +-
>  drivers/ata/ahci_sunxi.c |  9 +
>  22 files changed, 13 insertions(+), 41 deletions(-)
> 
> [...]
> diff --git a/configs/orangepi_plus_defconfig b/configs/orangepi_plus_defconfig
> index 76de72aa228..ed585881d49 100644
> --- a/configs/orangepi_plus_defconfig
> +++ b/configs/orangepi_plus_defconfig
> @@ -7,7 +7,6 @@ CONFIG_DRAM_CLK=672
>  CONFIG_MACPWR="PD6"
>  CONFIG_MMC_SUNXI_SLOT_EXTRA=2
>  CONFIG_USB1_VBUS_PIN="PG13"
> -CONFIG_SATAPWR="PG11"
>  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
>  CONFIG_SPL_I2C=y
>  CONFIG_SPL_SYS_I2C_LEGACY=y
> @@ -16,3 +15,4 @@ CONFIG_SUN8I_EMAC=y
>  CONFIG_SY8106A_POWER=y
>  CONFIG_USB_EHCI_HCD=y
>  CONFIG_USB_OHCI_HCD=y
> +CONFIG_USB3_VBUS_PIN="PG11"

This change is unrelated to the purpose of this commit.

Regards,
Samuel




Re: [PATCH] board: synquacer: Update the flash image layout

2023-10-19 Thread Masahisa Kojima
On Thu, 19 Oct 2023 at 22:54, Ilias Apalodimas
 wrote:
>
> The SynQuacer Developerbox, in EFI mode, supports A/B capsule
> updates and single image ones. The flash layout in the latter case is
> outdated, update it with the new offsets and images
>
> Signed-off-by: Ilias Apalodimas 
> ---
>  board/socionext/developerbox/developerbox.c | 23 +
>  1 file changed, 1 insertion(+), 22 deletions(-)

Tested-By: Masahisa Kojima 

Thank you for fixing this issue.
I have tested both A/B multi-bank and single image(multi-bank
disabled) capsule updates work fine.

Thanks,
Masahisa Kojima

>
> diff --git a/board/socionext/developerbox/developerbox.c 
> b/board/socionext/developerbox/developerbox.c
> index 9585944d80c1..ac4415ff3bbb 100644
> --- a/board/socionext/developerbox/developerbox.c
> +++ b/board/socionext/developerbox/developerbox.c
> @@ -20,39 +20,18 @@
>
>  #if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)
>  struct efi_fw_image fw_images[] = {
> -#if CONFIG_IS_ENABLED(FWU_MULTI_BANK_UPDATE)
> {
> .image_type_id = DEVELOPERBOX_FIP_IMAGE_GUID,
> .fw_name = u"DEVELOPERBOX-FIP",
> .image_index = 1,
> },
> -#else
> -   {
> -   .image_type_id = DEVELOPERBOX_UBOOT_IMAGE_GUID,
> -   .fw_name = u"DEVELOPERBOX-UBOOT",
> -   .image_index = 1,
> -   },
> -   {
> -   .image_type_id = DEVELOPERBOX_FIP_IMAGE_GUID,
> -   .fw_name = u"DEVELOPERBOX-FIP",
> -   .image_index = 2,
> -   },
> -   {
> -   .image_type_id = DEVELOPERBOX_OPTEE_IMAGE_GUID,
> -   .fw_name = u"DEVELOPERBOX-OPTEE",
> -   .image_index = 3,
> -   },
> -#endif
>  };
>
>  struct efi_capsule_update_info update_info = {
> -   .dfu_string = "mtd nor1=u-boot.bin raw 20 10;"
> -   "fip.bin raw 18 78000;"
> -   "optee.bin raw 50 10",
> +   .dfu_string = "mtd nor1=fip.bin raw 60 40",
> .num_images = ARRAY_SIZE(fw_images),
> .images = fw_images,
>  };
> -
>  #endif /* EFI_HAVE_CAPSULE_SUPPORT */
>
>  static struct mm_region sc2a11_mem_map[] = {
> --
> 2.40.1
>


Re: [PATCH v13 0/8] tpm: Support boot measurements

2023-10-19 Thread Ilias Apalodimas
Hi Eddie,

Does the series compile for you against -master?
For qemu_arm64_defonfig I am getting compilation errors both locally
and on the CI
https://source.denx.de/u-boot/custodians/u-boot-tpm/-/jobs/717362#L39

Thanks
/Ilias

On Thu, 19 Oct 2023 at 19:45, Ilias Apalodimas
 wrote:
>
> Thanks Eddie
>
> I've queued this up on public CI.  I also have an internal one, this
> one failed to add the TF-A eventlog, but everything else looks fine.
> I'll have a look tomorrow, but since this used to work on earlier
> versions I suspect it's going to be trivial to fix
>
> Cheers
> /Ilias
>
> On Thu, 19 Oct 2023 at 19:21, Eddie James  wrote:
> >
> > This series adds support for measuring the boot images more generically
> > than the existing EFI support. Several EFI functions have been moved to
> > the TPM layer. The series includes optional measurement from the bootm
> > command.
> > A new test case has been added for the bootm measurement to test the new
> > path, and the sandbox TPM2 driver has been updated to support this use
> > case.
> >
> > Changes since v12:
> >  - Rebase on master.
> >  - Add detail to documentation.
> >
> > Changes since v11:
> >  - Rebase on next. Sorry for the delay (been on leave).
> >
> > Changes since v10:
> >  - Fix commit message on efi_loader change
> >  - Drop python test change
> >  - Squash armv7 fix from Ilias
> >
> > Changes since v9:
> >  - Rebase and add Ilias' fixes (thanks!)
> >
> > Changes since v8:
> >  - Fix a sandbox driver off-by-one error in checking the property type.
> >  - Fix log parsing again - any data corruption seen while replaying the
> >event log was failing the entire measurement.
> >  - Added an option to ignore the existing log and a configuration option
> >for systems to select that for the bootm measurement. This would only
> >be selected for systems that know that U-Boot is the first stage
> >bootloader. This is necessary because the reserved memory region may
> >persist through resets and so U-Boot attempts to append to the
> >previous boot's log.
> >
> > Changes since v7:
> >  - Change name of tcg2_init_log and add more documentation
> >  - Add a check, when parsing the event log header, to ensure that the
> >previous stage bootloader used all the active PCRs.
> >  - Change name of tcg2_log_find_end
> >  - Fix the greater than or equal to check to exit the log parsing
> >  - Make sure log_position is 0 if there is any error discovering the log
> >  - Return errors parsing the log if the data is corrupt so that we don't
> >end up with half a log
> >
> > Changes since v6:
> >  - Added comment for bootm_measure
> >  - Fixed line length in bootm_measure
> >  - Added Linaro copyright for all the EFI moved code
> >  - Changed tcg2_init_log (and by extension, tcg2_measurement_init) to
> >copy any discovered event log to the user's log if passed in.
> >
> > Changes since v5:
> >  - Re-ordered the patches to put the sandbox TPM driver patch second
> >  - Remove unused platform_get_eventlog in efi_tcg2.c
> >  - First look for tpm_event_log_* properties instead of linux,sml-*
> >  - Fix efi_tcg2.c compilation
> >  - Select SHA* configs
> >  - Remove the !SANDBOX dependency for EFI TCG2
> >  - Only compile in the measurement u-boot command when CONFIG_MEASURED_BOOT
> >is enabled
> >
> > Changes since v4:
> >  - Remove tcg2_measure_event function and check for NULL data in
> >tcg2_measure_data
> >  - Use tpm_auto_startup
> >  - Fix efi_tcg2.c compilation for removing tcg2_pcr_read function
> >  - Change PCR indexes for initrd and dtb
> >  - Drop u8 casting in measurement test
> >  - Use bullets in documentation
> >
> > Changes since v3:
> >  - Reordered headers
> >  - Refactored more of EFI code into common code
> > Removed digest_info structure and instead used the common alg_to_mask
> >   and alg_to_len
> > Improved event log parsing in common code to get it equivalent to EFI
> >   Common code now extends PCR if previous bootloader stage couldn't
> >   No need to allocate memory in the common code, so EFI copies the
> >   discovered buffer like it did before
> > Rename efi measure_event function
> >
> > Changes since v2:
> >  - Add documentation.
> >  - Changed reserved memory address to the top of the RAM for sandbox dts.
> >  - Add measure state to booti and bootz.
> >  - Skip measurement for EFI images that should be measured
> >
> > Changes since v1:
> >  - Refactor TPM layer functions to allow EFI system to use them, and
> >remove duplicate EFI functions.
> >  - Add test case
> >  - Drop #ifdefs for bootm
> >  - Add devicetree measurement config option
> >  - Update sandbox TPM driver
> >
> > Eddie James (6):
> >   tpm: Fix spelling for tpmu_ha union
> >   tpm: sandbox: Update for needed TPM2 capabilities
> >   tpm: Support boot measurements
> >   bootm: Support boot measurement
> >   test: Add sandbox TPM boot measurement
> >   doc: Add measured boot documentation
> >
> > Ilias 

[PATCH] net: eth-uclass: Improve error message when MAC is not found

2023-10-19 Thread Fabio Estevam
From: Fabio Estevam 

While bringinp up a new board without the MAC fuses programmed,
the following error message was observed:

Error: ethernet@30bf address not set.

Improve the error message to make it clearer the reason of
the failure.

Signed-off-by: Fabio Estevam 
---
 net/eth-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 4311f3fe6e89..1f0985ec52ca 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -594,7 +594,7 @@ static int eth_post_probe(struct udevice *dev)
eth_env_set_enetaddr_by_index("eth", dev_seq(dev),
  pdata->enetaddr);
 #else
-   printf("\nError: %s address not set.\n",
+   printf("\nError: %s a valid MAC address was not found.\n",
   dev->name);
return -EINVAL;
 #endif
-- 
2.34.1



Re: [PATCH v3 2/2] imx8mp_evk: Remove unneeded header files

2023-10-19 Thread Hugo Villeneuve
On Thu, 19 Oct 2023 18:51:13 -0300
Fabio Estevam  wrote:

> From: Fabio Estevam 
> 
> Cleanup the file by removing unneeded header files.
> 
> Signed-off-by: Fabio Estevam 

Reviewed-by: Hugo Villeneuve 


> ---
> Changes since v2:
> - Also remove  and DECLARE_GLOBAL_DATA_PTR. (Hugo)
> 
>  board/freescale/imx8mp_evk/imx8mp_evk.c | 13 -
>  1 file changed, 13 deletions(-)
> 
> diff --git a/board/freescale/imx8mp_evk/imx8mp_evk.c 
> b/board/freescale/imx8mp_evk/imx8mp_evk.c
> index 42291c958e39..024b46ef8bc2 100644
> --- a/board/freescale/imx8mp_evk/imx8mp_evk.c
> +++ b/board/freescale/imx8mp_evk/imx8mp_evk.c
> @@ -3,20 +3,7 @@
>   * Copyright 2019 NXP
>   */
>  
> -#include 
>  #include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -
> -DECLARE_GLOBAL_DATA_PTR;
>  
>  int board_init(void)
>  {
> -- 
> 2.34.1
> 
> 


[PATCH v3 2/2] imx8mp_evk: Remove unneeded header files

2023-10-19 Thread Fabio Estevam
From: Fabio Estevam 

Cleanup the file by removing unneeded header files.

Signed-off-by: Fabio Estevam 
---
Changes since v2:
- Also remove  and DECLARE_GLOBAL_DATA_PTR. (Hugo)

 board/freescale/imx8mp_evk/imx8mp_evk.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/board/freescale/imx8mp_evk/imx8mp_evk.c 
b/board/freescale/imx8mp_evk/imx8mp_evk.c
index 42291c958e39..024b46ef8bc2 100644
--- a/board/freescale/imx8mp_evk/imx8mp_evk.c
+++ b/board/freescale/imx8mp_evk/imx8mp_evk.c
@@ -3,20 +3,7 @@
  * Copyright 2019 NXP
  */
 
-#include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-DECLARE_GLOBAL_DATA_PTR;
 
 int board_init(void)
 {
-- 
2.34.1



[PATCH v3 1/2] imx8mp_evk: Simplify Ethernet initialization

2023-10-19 Thread Fabio Estevam
From: Fabio Estevam 

With DM enabled, there is no need for board code to initialize
the Ethernet interfaces.

The RTL8211FDI Ethernet PHYs have 25MHz oscillator, so there is no
need to enable the RGMII TX clk output.

Also, there is no need for describing the deprecated phy-reset FEC
properties, nor passing reset properties to the EQOS interface in
u-boot.dtsi.

Remove all these unneeded pieces.

Tested both Ethernet interfaces after these changes.

Signed-off-by: Fabio Estevam 
Reviewed-by: Hugo Villeneuve 
---
Changes since v2:
- Only collected Hugo's tag.

 arch/arm/dts/imx8mp-evk-u-boot.dtsi | 14 -
 board/freescale/imx8mp_evk/imx8mp_evk.c | 28 +
 2 files changed, 1 insertion(+), 41 deletions(-)

diff --git a/arch/arm/dts/imx8mp-evk-u-boot.dtsi 
b/arch/arm/dts/imx8mp-evk-u-boot.dtsi
index 0bf489b46248..51c84383673c 100644
--- a/arch/arm/dts/imx8mp-evk-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-evk-u-boot.dtsi
@@ -137,17 +137,3 @@
  {
bootph-pre-ram;
 };
-
- {
-   reset-gpios = < 22 GPIO_ACTIVE_LOW>;
-   reset-delay-us = <15000>;
-   reset-post-delay-us = <10>;
-};
-
- {
-   phy-reset-gpios = < 2 GPIO_ACTIVE_LOW>;
-   phy-reset-duration = <15>;
-   phy-reset-post-delay = <100>;
-};
-
-
diff --git a/board/freescale/imx8mp_evk/imx8mp_evk.c 
b/board/freescale/imx8mp_evk/imx8mp_evk.c
index a24b8c1d8608..42291c958e39 100644
--- a/board/freescale/imx8mp_evk/imx8mp_evk.c
+++ b/board/freescale/imx8mp_evk/imx8mp_evk.c
@@ -7,8 +7,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -20,33 +18,9 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static void setup_fec(void)
-{
-   struct iomuxc_gpr_base_regs *gpr =
-   (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
-
-   /* Enable RGMII TX clk output */
-   setbits_le32(>gpr[1], BIT(22));
-}
-
-#if CONFIG_IS_ENABLED(NET)
-int board_phy_config(struct phy_device *phydev)
-{
-   if (phydev->drv->config)
-   phydev->drv->config(phydev);
-   return 0;
-}
-#endif
-
 int board_init(void)
 {
-   int ret = 0;
-
-   if (IS_ENABLED(CONFIG_FEC_MXC)) {
-   setup_fec();
-   }
-
-   return ret;
+   return 0;
 }
 
 int board_late_init(void)
-- 
2.34.1



Falcon mode on RISC-V

2023-10-19 Thread Heinrich Schuchardt

Hello Randolph,

I just saw your patches merged to enable Falcon mode on RISC-V using
CONFIG_SPL_LOAD_FIT_OPENSBI_OS_BOOT. I did not see any documentation update.

Should information about your development be added to
doc/develop/falcon.rst? Would you be willing to provide a patch?

Best regards

Heinrich


Re: [RESEND PATCH v1 1/2] spi: add support for Amlogic A1 SPI Flash Controller

2023-10-19 Thread Igor Prusov
On Tue, Oct 17, 2023 at 09:33:02PM -0600, Simon Glass wrote:
> Hi Igor,
> 
> On Tue, 17 Oct 2023 at 11:18, Igor Prusov  wrote:
> >
> > From: Igor Prusov 
> >
> > Add A1 SPIFC driver from Linux. Slightly modified to use u-boot driver
> > framework and accommodate to lack of ioread32_rep/iowrite32_rep.
> 
> Well, you could bring them in!
> 
I was thinking about it, but I'd prefer to make a separate series with
it, if you don't mind. Need some time to figure out best way to
integrate them into u-boot and I'd like to take a look at other drivers
that could use those while I'm at it.

[...]

-- 
Best Regards,
Igor Prusov


Re: [PATCH 1/2] configs: rockchip: Use dwc3-generic driver on RK3328 and RK3399

2023-10-19 Thread Jonas Karlman
On 2023-10-19 01:44, Marek Vasut wrote:
> On 10/19/23 00:30, Jonas Karlman wrote:
> 
> [..]
> 
>> +++ b/configs/rock960-rk3399_defconfig
>> @@ -50,6 +50,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>>   CONFIG_SYS_MMC_ENV_DEV=1
>>   CONFIG_ROCKCHIP_GPIO=y
>>   CONFIG_SYS_I2C_ROCKCHIP=y
>> +CONFIG_MISC=y
>>   CONFIG_MMC_DW=y
>>   CONFIG_MMC_DW_ROCKCHIP=y
>>   CONFIG_MMC_SDHCI=y
>> @@ -70,12 +71,12 @@ CONFIG_SYS_NS16550_MEM32=y
>>   CONFIG_SYSRESET=y
>>   CONFIG_USB=y
>>   CONFIG_USB_XHCI_HCD=y
>> -CONFIG_USB_XHCI_DWC3=y
>>   CONFIG_USB_EHCI_HCD=y
>>   CONFIG_USB_EHCI_GENERIC=y
>>   CONFIG_USB_OHCI_HCD=y
>>   CONFIG_USB_OHCI_GENERIC=y
>>   CONFIG_USB_DWC3=y
>> +CONFIG_USB_DWC3_GENERIC=y
> 
> Why not add 'default y if ROCKCHIP' into the Kconfig instead ? This will 
> have the same effect, without requiring such massive modification of 
> config files.

Not fully sure what you mean by this and how that would reduce number of
affected defconfig-files. The USB_XHCI_DWC3 should still be removed from
these defconfig-files or wrong driver could be used by these boards.

Touching the defconfig-files help notify board maintainers that changes
are happening to their boards.

There will also be a separate patch that remove the rockchip,rk3399-dwc3
compatible from the dwc3-of-simple driver to finalize this transition to
use dwc3-generic driver for affected rockchip boards.

Regards,
Jonas

> 
> (seems some of the CC domains are not even working, so CC list clipped)



Re: [PATCH v2 1/2] imx8mp_evk: Simplify Ethernet initialization

2023-10-19 Thread Hugo Villeneuve
On Thu, 19 Oct 2023 16:21:54 -0300
Fabio Estevam  wrote:

> From: Fabio Estevam 
> 
> With DM enabled, there is no need for board code to initialize
> the Ethernet interfaces.
> 
> The RTL8211FDI Ethernet PHYs have 25MHz oscillator, so there is no
> need to enable the RGMII TX clk output.
> 
> Also, there is no need for describing the deprecated phy-reset FEC
> properties, nor passing reset properties to the EQOS interface in
> u-boot.dtsi.
> 
> Remove all these unneeded pieces.
> 
> Tested both Ethernet interfaces after these changes.
> 
> Signed-off-by: Fabio Estevam 

Reviewed-by: Hugo Villeneuve 


> ---
> Changes since v1:
> - Removed Ethernet related headers. (Hugo)
> - Also removed custom eqos reset properties from u-boot.dtsi.
> 
>  arch/arm/dts/imx8mp-evk-u-boot.dtsi | 14 -
>  board/freescale/imx8mp_evk/imx8mp_evk.c | 28 +
>  2 files changed, 1 insertion(+), 41 deletions(-)
> 
> diff --git a/arch/arm/dts/imx8mp-evk-u-boot.dtsi 
> b/arch/arm/dts/imx8mp-evk-u-boot.dtsi
> index 0bf489b46248..51c84383673c 100644
> --- a/arch/arm/dts/imx8mp-evk-u-boot.dtsi
> +++ b/arch/arm/dts/imx8mp-evk-u-boot.dtsi
> @@ -137,17 +137,3 @@
>   {
>   bootph-pre-ram;
>  };
> -
> - {
> - reset-gpios = < 22 GPIO_ACTIVE_LOW>;
> - reset-delay-us = <15000>;
> - reset-post-delay-us = <10>;
> -};
> -
> - {
> - phy-reset-gpios = < 2 GPIO_ACTIVE_LOW>;
> - phy-reset-duration = <15>;
> - phy-reset-post-delay = <100>;
> -};
> -
> -
> diff --git a/board/freescale/imx8mp_evk/imx8mp_evk.c 
> b/board/freescale/imx8mp_evk/imx8mp_evk.c
> index a24b8c1d8608..42291c958e39 100644
> --- a/board/freescale/imx8mp_evk/imx8mp_evk.c
> +++ b/board/freescale/imx8mp_evk/imx8mp_evk.c
> @@ -7,8 +7,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
> -#include 
>  #include 
>  #include 
>  #include 
> @@ -20,33 +18,9 @@
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> -static void setup_fec(void)
> -{
> - struct iomuxc_gpr_base_regs *gpr =
> - (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
> -
> - /* Enable RGMII TX clk output */
> - setbits_le32(>gpr[1], BIT(22));
> -}
> -
> -#if CONFIG_IS_ENABLED(NET)
> -int board_phy_config(struct phy_device *phydev)
> -{
> - if (phydev->drv->config)
> - phydev->drv->config(phydev);
> - return 0;
> -}
> -#endif
> -
>  int board_init(void)
>  {
> - int ret = 0;
> -
> - if (IS_ENABLED(CONFIG_FEC_MXC)) {
> - setup_fec();
> - }
> -
> - return ret;
> + return 0;
>  }
>  
>  int board_late_init(void)
> -- 
> 2.34.1
> 
> 


Re: [PATCH v2 2/2] mx8mp_evk: Remove unneeded header files

2023-10-19 Thread Hugo Villeneuve
On Thu, 19 Oct 2023 16:21:55 -0300
Fabio Estevam  wrote:

> From: Fabio Estevam 
> 
> Cleanup the file by removing unneeded header files.
> 
> Signed-off-by: Fabio Estevam 
> ---
> Changes since v1:
> - Newly introduced. (Hugo)
> 
>  board/freescale/imx8mp_evk/imx8mp_evk.c | 10 --
>  1 file changed, 10 deletions(-)
> 
> diff --git a/board/freescale/imx8mp_evk/imx8mp_evk.c 
> b/board/freescale/imx8mp_evk/imx8mp_evk.c
> index 42291c958e39..e62e27db48d9 100644
> --- a/board/freescale/imx8mp_evk/imx8mp_evk.c
> +++ b/board/freescale/imx8mp_evk/imx8mp_evk.c
> @@ -3,18 +3,8 @@
>   * Copyright 2019 NXP
>   */
>  
> -#include 
>  #include 
> -#include 
> -#include 
> -#include 
>  #include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
>  
>  DECLARE_GLOBAL_DATA_PTR;

Hi Fabio,
after that, do you even need DECLARE_GLOBAL_DATA_PTR and its associated
header file?

Hugo.


Re: CONFIG_SPL_SKIP_RELOCATE in non-SPL build

2023-10-19 Thread Tom Rini
On Thu, Oct 19, 2023 at 03:30:25PM +0200, Martin Fäcknitz wrote:
> Hello,
> 
> The patch
>   Convert CONFIG_SPL_INIT_MINIMAL et al to Kconfig
>   (b35316fb67cb7aeaf022032ce078135251372f39)
> 
> changes the behaviour for non-SPL builds when relocating code. The patch
> sets the CONFIG_SPL_SKIP_RELOCATE option in a few freescale boards, e.g.
> T1024RDB_SDCARD_defconfig.
> 
> Before, CONFIG_SPL_SKIP_RELOCATE was only defined when building the SPL image:
> 
>  #ifdef CONFIG_SPL_BUILD
> -#define CONFIG_SPL_SKIP_RELOCATE
>  #define CONFIG_SPL_COMMON_INIT_DDR
>  #define CONFIG_SYS_CCSR_DO_NOT_RELOCATE
>  #endif
> 
> Now, the relocate_code function in arch/powerpc/cpu/mpc85xx/start.S does no
> relocation because CONFIG_SPL_SKIP_RELOCATE is always defined:
> 
> relocate_code:
>   ...
> #ifndef CONFIG_SPL_SKIP_RELOCATE
>   ... relocate code from SYS_MONITOR_BASE to gd->relocaddr ..
> #endif
> 
> When jump_to_copy is called (common/board_f.c), the
> 
>   relocate_code(gd->start_addr_sp, gd->new_gd, gd->relocaddr)
> 
> would not relocate u-boot (located at SYS_MONITOR_BASE) to gd->relocaddr.
> 
> For example, SYS_MONITOR_BASE is 0x3000. and gd->relocaddr is 0x7bf7.:
> 
> Relocation Offset is: 4bf7
> 
> 
> Relocating to 7bf7, new gd at 7bb6de50, sp at 7bb6b540
> 
> Any access to memory 7bf7+ is invalid, because no relocation was done.
> 
> When patching
> 
>   -#ifndef CONFIG_SPL_SKIP_RELOCATE
>   +#if !defined(CONFIG_SPL_SKIP_RELOCATE) || !defined(CONFIG_SPL_BUILD)
> 
> relocation is done in non-SPL builds and booting works.
> 
> Testet on T1042E board using U-Boot 2023.10.02-01420.

Thanks for the report.  Can you submit a full patch to correct this?
Unfortunately there's few people available to test those platforms which
is why they're in the state they are in.

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] imx8mn-var-som: Simplify FEC initialization

2023-10-19 Thread Hugo Villeneuve
From: Hugo Villeneuve 

With DM enabled, there is no need for board code to initialize
the FEC interface.

The ethernet PHYs on the symphony carrier board have a dedicated
crystal/oscillator. If the SOM has the EC configuration option
(onboard ethernet PHY), it also has a dedicated crystal/oscillator.
So in all cases, there is no need to enable the RGMII TX clk output.

This follows a similar change introduced by Fabio Estevam:
  Link: 
https://lore.kernel.org/u-boot/20231019170441.1610453-1-feste...@gmail.com/

Signed-off-by: Hugo Villeneuve 
---
 board/variscite/imx8mn_var_som/imx8mn_var_som.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/board/variscite/imx8mn_var_som/imx8mn_var_som.c 
b/board/variscite/imx8mn_var_som/imx8mn_var_som.c
index 61b9455a8f4..994fd4f7058 100644
--- a/board/variscite/imx8mn_var_som/imx8mn_var_som.c
+++ b/board/variscite/imx8mn_var_som/imx8mn_var_som.c
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -46,20 +45,8 @@ struct var_imx8_eeprom_info {
u8 partnumber2[5];/* Part number 2 */
 } __packed;
 
-static void setup_fec(void)
-{
-   struct iomuxc_gpr_base_regs *gpr =
-   (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
-
-   /* Use 125M anatop REF_CLK1 for ENET1, not from external */
-   clrsetbits_le32(>gpr[1], 0x2000, 0);
-}
-
 int board_init(void)
 {
-   if (IS_ENABLED(CONFIG_FEC_MXC))
-   setup_fec();
-
return 0;
 }
 

base-commit: 4655b75335384e040358a2e3e478cc42f32a96c9
-- 
2.39.2



[PATCH] imx8mn_var_som: Add myself to MAINTAINERS

2023-10-19 Thread Hugo Villeneuve
From: Hugo Villeneuve 

I would like to help maintaining the imx8mn_var_som symphony board.

Add myself to MAINTAINERS.

Signed-off-by: Hugo Villeneuve 
---
 board/variscite/imx8mn_var_som/MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/variscite/imx8mn_var_som/MAINTAINERS 
b/board/variscite/imx8mn_var_som/MAINTAINERS
index 068f807ae69..367f72dfe4f 100644
--- a/board/variscite/imx8mn_var_som/MAINTAINERS
+++ b/board/variscite/imx8mn_var_som/MAINTAINERS
@@ -1,5 +1,6 @@
 ARM i.MX8MN VARISCITE VAR-SOM-MX8MN MODULE
 M: Ariel D'Alessandro 
+M: Hugo Villeneuve 
 S: Maintained
 F: arch/arm/dts/imx8mn-var-som*
 F: board/variscite/imx8mn_var_som/

base-commit: 4655b75335384e040358a2e3e478cc42f32a96c9
-- 
2.39.2



[PATCH v2 2/2] mx8mp_evk: Remove unneeded header files

2023-10-19 Thread Fabio Estevam
From: Fabio Estevam 

Cleanup the file by removing unneeded header files.

Signed-off-by: Fabio Estevam 
---
Changes since v1:
- Newly introduced. (Hugo)

 board/freescale/imx8mp_evk/imx8mp_evk.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/board/freescale/imx8mp_evk/imx8mp_evk.c 
b/board/freescale/imx8mp_evk/imx8mp_evk.c
index 42291c958e39..e62e27db48d9 100644
--- a/board/freescale/imx8mp_evk/imx8mp_evk.c
+++ b/board/freescale/imx8mp_evk/imx8mp_evk.c
@@ -3,18 +3,8 @@
  * Copyright 2019 NXP
  */
 
-#include 
 #include 
-#include 
-#include 
-#include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
-- 
2.34.1



[PATCH v2 1/2] imx8mp_evk: Simplify Ethernet initialization

2023-10-19 Thread Fabio Estevam
From: Fabio Estevam 

With DM enabled, there is no need for board code to initialize
the Ethernet interfaces.

The RTL8211FDI Ethernet PHYs have 25MHz oscillator, so there is no
need to enable the RGMII TX clk output.

Also, there is no need for describing the deprecated phy-reset FEC
properties, nor passing reset properties to the EQOS interface in
u-boot.dtsi.

Remove all these unneeded pieces.

Tested both Ethernet interfaces after these changes.

Signed-off-by: Fabio Estevam 
---
Changes since v1:
- Removed Ethernet related headers. (Hugo)
- Also removed custom eqos reset properties from u-boot.dtsi.

 arch/arm/dts/imx8mp-evk-u-boot.dtsi | 14 -
 board/freescale/imx8mp_evk/imx8mp_evk.c | 28 +
 2 files changed, 1 insertion(+), 41 deletions(-)

diff --git a/arch/arm/dts/imx8mp-evk-u-boot.dtsi 
b/arch/arm/dts/imx8mp-evk-u-boot.dtsi
index 0bf489b46248..51c84383673c 100644
--- a/arch/arm/dts/imx8mp-evk-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-evk-u-boot.dtsi
@@ -137,17 +137,3 @@
  {
bootph-pre-ram;
 };
-
- {
-   reset-gpios = < 22 GPIO_ACTIVE_LOW>;
-   reset-delay-us = <15000>;
-   reset-post-delay-us = <10>;
-};
-
- {
-   phy-reset-gpios = < 2 GPIO_ACTIVE_LOW>;
-   phy-reset-duration = <15>;
-   phy-reset-post-delay = <100>;
-};
-
-
diff --git a/board/freescale/imx8mp_evk/imx8mp_evk.c 
b/board/freescale/imx8mp_evk/imx8mp_evk.c
index a24b8c1d8608..42291c958e39 100644
--- a/board/freescale/imx8mp_evk/imx8mp_evk.c
+++ b/board/freescale/imx8mp_evk/imx8mp_evk.c
@@ -7,8 +7,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -20,33 +18,9 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static void setup_fec(void)
-{
-   struct iomuxc_gpr_base_regs *gpr =
-   (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
-
-   /* Enable RGMII TX clk output */
-   setbits_le32(>gpr[1], BIT(22));
-}
-
-#if CONFIG_IS_ENABLED(NET)
-int board_phy_config(struct phy_device *phydev)
-{
-   if (phydev->drv->config)
-   phydev->drv->config(phydev);
-   return 0;
-}
-#endif
-
 int board_init(void)
 {
-   int ret = 0;
-
-   if (IS_ENABLED(CONFIG_FEC_MXC)) {
-   setup_fec();
-   }
-
-   return ret;
+   return 0;
 }
 
 int board_late_init(void)
-- 
2.34.1



Re: [PATCH] imx8mp_evk: Simplify FEC initialization

2023-10-19 Thread Hugo Villeneuve
On Thu, 19 Oct 2023 14:04:41 -0300
Fabio Estevam  wrote:

> From: Fabio Estevam 
> 
> With DM enabled, there is no need for board code to initialize
> the FEC interface.
> 
> The RTL8211FDI Ethernet PHYs have 25MHz oscillator, so there is no
> need to enable the RGMII TX clk output.
> 
> Also, there is no need for describing the deprecated phy-reset properties
> in u-boot.dtsi.
> 
> Remove all these uneeded pieces.
> 
> Signed-off-by: Fabio Estevam 
> ---
>  arch/arm/dts/imx8mp-evk-u-boot.dtsi |  8 
>  board/freescale/imx8mp_evk/imx8mp_evk.c | 26 +
>  2 files changed, 1 insertion(+), 33 deletions(-)
> 
> diff --git a/arch/arm/dts/imx8mp-evk-u-boot.dtsi 
> b/arch/arm/dts/imx8mp-evk-u-boot.dtsi
> index 43f13a9c22f7..db6bc6a11883 100644
> --- a/arch/arm/dts/imx8mp-evk-u-boot.dtsi
> +++ b/arch/arm/dts/imx8mp-evk-u-boot.dtsi
> @@ -150,11 +150,3 @@
>   reset-delay-us = <15000>;
>   reset-post-delay-us = <10>;
>  };
> -
> - {
> - phy-reset-gpios = < 2 GPIO_ACTIVE_LOW>;
> - phy-reset-duration = <15>;
> - phy-reset-post-delay = <100>;
> -};
> -
> -
> diff --git a/board/freescale/imx8mp_evk/imx8mp_evk.c 
> b/board/freescale/imx8mp_evk/imx8mp_evk.c
> index a24b8c1d8608..2c2b8383c8dc 100644
> --- a/board/freescale/imx8mp_evk/imx8mp_evk.c
> +++ b/board/freescale/imx8mp_evk/imx8mp_evk.c
> @@ -20,33 +20,9 @@
>  
>  DECLARE_GLOBAL_DATA_PTR;

Hi Fabio,
there is probably some #includes that are no longer necessary after
this change... maybe remove them as well, or in another cleanup patch?

Hugo.


> -static void setup_fec(void)
> -{
> - struct iomuxc_gpr_base_regs *gpr =
> - (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
> -
> - /* Enable RGMII TX clk output */
> - setbits_le32(>gpr[1], BIT(22));
> -}
> -
> -#if CONFIG_IS_ENABLED(NET)
> -int board_phy_config(struct phy_device *phydev)
> -{
> - if (phydev->drv->config)
> - phydev->drv->config(phydev);
> - return 0;
> -}
> -#endif
> -
>  int board_init(void)
>  {
> - int ret = 0;
> -
> - if (IS_ENABLED(CONFIG_FEC_MXC)) {
> - setup_fec();
> - }
> -
> - return ret;
> + return 0;
>  }
>  
>  int board_late_init(void)
> -- 
> 2.34.1
> 


Re: [PATCH v13 6/8] doc: Add measured boot documentation

2023-10-19 Thread Heinrich Schuchardt

On 10/19/23 18:21, Eddie James wrote:

Briefly describe the feature and specify the requirements.

Signed-off-by: Eddie James 
Reviewed-by: Simon Glass 
---
Changes since v12:
  - Add a bit of detail about OS usage and what pieces are measured

  doc/usage/index.rst |  1 +
  doc/usage/measured_boot.rst | 31 +++
  2 files changed, 32 insertions(+)
  create mode 100644 doc/usage/measured_boot.rst

diff --git a/doc/usage/index.rst b/doc/usage/index.rst
index 98b4719c40..bf53bb6bda 100644
--- a/doc/usage/index.rst
+++ b/doc/usage/index.rst
@@ -14,6 +14,7 @@ Use U-Boot
 partitions
 cmdline
 semihosting
+   measured_boot

  Shell commands
  --
diff --git a/doc/usage/measured_boot.rst b/doc/usage/measured_boot.rst
new file mode 100644
index 00..0aad590859
--- /dev/null
+++ b/doc/usage/measured_boot.rst
@@ -0,0 +1,31 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Measured Boot
+=
+
+U-Boot can perform a measured boot, the process of hashing various components
+of the boot process, extending the results in the TPM and logging the
+component's measurement in memory for the operating system to consume.
+
+By default, U-Boot will measure the operating system (linux) image, the


The OS image would mean the root file system? I guess you mean the
loaded EFI binary here. Measured boot is not Linux specific.

We should consider different scenarios:

* U-Boot loading kernel, initrd, device-tree
* U-Boot loading GRUB (or another boot manager), device-tree,
  GRUB loading initrd
* U-Boot loading GRUB and passing a device-tree to GRUB,
  GRUB loading initrd and a new device-tree

With the documentation the user should be enabled to understand what
U-Boot measures in each of these cases. Please, observe that upstream
GRUB uses LoadImage() while distros (e.g. Debian and Ubuntu) tend to
bypass LoadImage().

Arent't there some other objects measured?

- SMBIOS table
- ACPI tables (still to be implemented)
- EFI variables

Best regards

Heinrich


+initrd image, and the "bootargs" environment variable. By enabling
+CONFIG_MEASURE_DEVICETREE, U-Boot will also measure the devicetree image.
+
+The operating system typically would verify that the hashes found in the
+TPM PCRs match the contents of the event log. This can further be checked
+against the hash results of previous boots.
+
+Requirements
+-
+
+* A hardware TPM 2.0 supported by the U-Boot drivers
+* CONFIG_TPM=y
+* CONFIG_MEASURED_BOOT=y
+* Device-tree configuration of the TPM device to specify the memory area
+  for event logging. The TPM device node must either contain a phandle to
+  a reserved memory region or "linux,sml-base" and "linux,sml-size"
+  indicating the address and size of the memory region. An example can be
+  found in arch/sandbox/dts/test.dts
+* The operating system must also be configured to use the memory regions
+  specified in the U-Boot device-tree in order to make use of the event
+  log.




Re: [PATCH v13 7/8] efi_loader: fix EFI_ENTRY point on get_active_pcr_banks

2023-10-19 Thread Heinrich Schuchardt

On 10/19/23 18:21, Eddie James wrote:

From: Ilias Apalodimas 

efi_tcg2_get_active_pcr_banks doesn't immediately call the
EFI_ENTRY() wrapper once it enters the function. Move the call a
few lines above to cover the error cases properly as well.

Signed-off-by: Ilias Apalodimas 


Reviewed-by: Heinrich Schuchardt 


---
  lib/efi_loader/efi_tcg2.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
index 7ada536568..dae1b166c8 100644
--- a/lib/efi_loader/efi_tcg2.c
+++ b/lib/efi_loader/efi_tcg2.c
@@ -949,16 +949,16 @@ efi_tcg2_get_active_pcr_banks(struct efi_tcg2_protocol 
*this,
struct udevice *dev;
efi_status_t ret;

+   EFI_ENTRY("%p, %p", this, active_pcr_banks);
+
if (!this || !active_pcr_banks) {
ret = EFI_INVALID_PARAMETER;
goto out;
}
-
ret = tcg2_platform_get_tpm2();
if (ret != EFI_SUCCESS)
goto out;

-   EFI_ENTRY("%p, %p", this, active_pcr_banks);
ret = tcg2_get_active_pcr_banks(dev, active_pcr_banks);

  out:




Re: [PATCH 1/9] DO NOT MERGE: arm: dts: k3-j7200-r5-common: Add pmic node for esm

2023-10-19 Thread Nishanth Menon
On 14:42-20231019, Thomas Richard wrote:
> On 10/16/23 18:29, Nishanth Menon wrote:
> > On 16:11-20231016, Thomas Richard wrote:
> >> From: Gowtham Tammana 
> >>
> >> Add pmic tps659413 node needed for ESM error event handling.
> >>
> >> Signed-off-by: Gowtham Tammana 
> >> Signed-off-by: Neha Malcom Francis 
> >> Signed-off-by: Thomas Richard 
> >> ---
> >>
> >>  arch/arm/dts/k3-j7200-r5-common-proc-board.dts | 17 ++---
> >>  1 file changed, 14 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/arch/arm/dts/k3-j7200-r5-common-proc-board.dts 
> >> b/arch/arm/dts/k3-j7200-r5-common-proc-board.dts
> >> index e62f9218e8..2bf0d5e3c0 100644
> >> --- a/arch/arm/dts/k3-j7200-r5-common-proc-board.dts
> >> +++ b/arch/arm/dts/k3-j7200-r5-common-proc-board.dts
> >> @@ -249,13 +249,24 @@
> >>  
> >>  _i2c0 {
> >>bootph-pre-ram;
> >> +  pinctrl-names = "default";
> >> +  pinctrl-0 = <_i2c0_pins_default>;
> >> +  clock-frequency = <40>;
> >> +
> >> +  tps659413: tps659413@48 {
> >> +  compatible = "ti,tps659413";
> >> +  reg = <0x48>;
> >> +  bootph-pre-ram;
> >> +
> >> +  regulators_a: regulators {
> >> +  bootph-pre-ram;
> >> +  };
> >> +  };
> >> +
> >>lp876441: lp876441@4c {
> >>compatible = "ti,lp876441";
> >>reg = <0x4c>;
> >>bootph-pre-ram;
> >> -  pinctrl-names = "default";
> >> -  pinctrl-0 = <_i2c0_pins_default>;
> >> -  clock-frequency = <40>;
> >>  
> >>regulators: regulators {
> >>bootph-pre-ram;
> >> -- 
> >> 2.39.2
> >>
> > 
> > Please send these changes upstream linux kernel.
> 
> Hi Nishanth,
> 
> I found this series
> (https://lore.kernel.org/all/20230810-tps6594-v6-0-2b2e2399e...@ti.com/)
> which includes a patch to create the two pmic nodes for j7200 target.
> It matches exactly my needs.
> 
> I found it was merged in TI linux kernel
> https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/commit/arch/arm64/boot/dts/ti/k3-j7200-som-p0.dtsi?h=ti-linux-6.1.y=0b3a445305b24aafba567909dac75961a0e8908c)

I will skip commenting on TI vendor kernel and bootloader stuff.
> 
> 
> But referring to your answer
> (https://lore.kernel.org/all/169164472311.19570.17843597381384613605.b4...@ti.com/)
> this series will not be merged upstream as is.
> 
> Should I send a single patch to declare pmics only for J7200 ?
> Could I just send a minimal definition of the pmics, or should I send a
> full definition (including regulators) ?
> 

It will be good to discuss kernel patches in kernel.org mailing lists :)

But yeah - that series was pretty much close to getting merged before
I had to drop when testing I do failed. If we are doing it, we'd need
to do as a full definition (including regulators).. Though, I am
disappointed at TI dropping the ball on this (Udit/Praneeth: hint -
this is blocking additional progress).

-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
849D 1736 249D


[PULL] u-boot-sh/master_uart_test

2023-10-19 Thread Marek Vasut
The following changes since commit e463222cce0df86f05a117f06e1737f539841fe6:

  Merge branch 'master' of 
https://source.denx.de/u-boot/custodians/u-boot-riscv (2023-10-19 09:40:04 
-0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-sh.git master_uart_test

for you to fetch changes up to 966caedfa89acaeceb6968f051b7ae26c4c6673f:

  serial: sh: Add RZ/G2L SCIF support (2023-10-19 17:03:20 +0200)


Paul Barker (2):
  serial: sh: Fix error handling
  serial: sh: Add RZ/G2L SCIF support

 arch/arm/mach-rmobile/Kconfig |  1 +
 drivers/serial/serial_sh.c| 31 +--
 drivers/serial/serial_sh.h| 19 ++-
 3 files changed, 48 insertions(+), 3 deletions(-)


[PATCH] imx8mp_evk: Simplify FEC initialization

2023-10-19 Thread Fabio Estevam
From: Fabio Estevam 

With DM enabled, there is no need for board code to initialize
the FEC interface.

The RTL8211FDI Ethernet PHYs have 25MHz oscillator, so there is no
need to enable the RGMII TX clk output.

Also, there is no need for describing the deprecated phy-reset properties
in u-boot.dtsi.

Remove all these uneeded pieces.

Signed-off-by: Fabio Estevam 
---
 arch/arm/dts/imx8mp-evk-u-boot.dtsi |  8 
 board/freescale/imx8mp_evk/imx8mp_evk.c | 26 +
 2 files changed, 1 insertion(+), 33 deletions(-)

diff --git a/arch/arm/dts/imx8mp-evk-u-boot.dtsi 
b/arch/arm/dts/imx8mp-evk-u-boot.dtsi
index 43f13a9c22f7..db6bc6a11883 100644
--- a/arch/arm/dts/imx8mp-evk-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-evk-u-boot.dtsi
@@ -150,11 +150,3 @@
reset-delay-us = <15000>;
reset-post-delay-us = <10>;
 };
-
- {
-   phy-reset-gpios = < 2 GPIO_ACTIVE_LOW>;
-   phy-reset-duration = <15>;
-   phy-reset-post-delay = <100>;
-};
-
-
diff --git a/board/freescale/imx8mp_evk/imx8mp_evk.c 
b/board/freescale/imx8mp_evk/imx8mp_evk.c
index a24b8c1d8608..2c2b8383c8dc 100644
--- a/board/freescale/imx8mp_evk/imx8mp_evk.c
+++ b/board/freescale/imx8mp_evk/imx8mp_evk.c
@@ -20,33 +20,9 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static void setup_fec(void)
-{
-   struct iomuxc_gpr_base_regs *gpr =
-   (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
-
-   /* Enable RGMII TX clk output */
-   setbits_le32(>gpr[1], BIT(22));
-}
-
-#if CONFIG_IS_ENABLED(NET)
-int board_phy_config(struct phy_device *phydev)
-{
-   if (phydev->drv->config)
-   phydev->drv->config(phydev);
-   return 0;
-}
-#endif
-
 int board_init(void)
 {
-   int ret = 0;
-
-   if (IS_ENABLED(CONFIG_FEC_MXC)) {
-   setup_fec();
-   }
-
-   return ret;
+   return 0;
 }
 
 int board_late_init(void)
-- 
2.34.1



Re: [PATCH v13 0/8] tpm: Support boot measurements

2023-10-19 Thread Ilias Apalodimas
Thanks Eddie

I've queued this up on public CI.  I also have an internal one, this
one failed to add the TF-A eventlog, but everything else looks fine.
I'll have a look tomorrow, but since this used to work on earlier
versions I suspect it's going to be trivial to fix

Cheers
/Ilias

On Thu, 19 Oct 2023 at 19:21, Eddie James  wrote:
>
> This series adds support for measuring the boot images more generically
> than the existing EFI support. Several EFI functions have been moved to
> the TPM layer. The series includes optional measurement from the bootm
> command.
> A new test case has been added for the bootm measurement to test the new
> path, and the sandbox TPM2 driver has been updated to support this use
> case.
>
> Changes since v12:
>  - Rebase on master.
>  - Add detail to documentation.
>
> Changes since v11:
>  - Rebase on next. Sorry for the delay (been on leave).
>
> Changes since v10:
>  - Fix commit message on efi_loader change
>  - Drop python test change
>  - Squash armv7 fix from Ilias
>
> Changes since v9:
>  - Rebase and add Ilias' fixes (thanks!)
>
> Changes since v8:
>  - Fix a sandbox driver off-by-one error in checking the property type.
>  - Fix log parsing again - any data corruption seen while replaying the
>event log was failing the entire measurement.
>  - Added an option to ignore the existing log and a configuration option
>for systems to select that for the bootm measurement. This would only
>be selected for systems that know that U-Boot is the first stage
>bootloader. This is necessary because the reserved memory region may
>persist through resets and so U-Boot attempts to append to the
>previous boot's log.
>
> Changes since v7:
>  - Change name of tcg2_init_log and add more documentation
>  - Add a check, when parsing the event log header, to ensure that the
>previous stage bootloader used all the active PCRs.
>  - Change name of tcg2_log_find_end
>  - Fix the greater than or equal to check to exit the log parsing
>  - Make sure log_position is 0 if there is any error discovering the log
>  - Return errors parsing the log if the data is corrupt so that we don't
>end up with half a log
>
> Changes since v6:
>  - Added comment for bootm_measure
>  - Fixed line length in bootm_measure
>  - Added Linaro copyright for all the EFI moved code
>  - Changed tcg2_init_log (and by extension, tcg2_measurement_init) to
>copy any discovered event log to the user's log if passed in.
>
> Changes since v5:
>  - Re-ordered the patches to put the sandbox TPM driver patch second
>  - Remove unused platform_get_eventlog in efi_tcg2.c
>  - First look for tpm_event_log_* properties instead of linux,sml-*
>  - Fix efi_tcg2.c compilation
>  - Select SHA* configs
>  - Remove the !SANDBOX dependency for EFI TCG2
>  - Only compile in the measurement u-boot command when CONFIG_MEASURED_BOOT
>is enabled
>
> Changes since v4:
>  - Remove tcg2_measure_event function and check for NULL data in
>tcg2_measure_data
>  - Use tpm_auto_startup
>  - Fix efi_tcg2.c compilation for removing tcg2_pcr_read function
>  - Change PCR indexes for initrd and dtb
>  - Drop u8 casting in measurement test
>  - Use bullets in documentation
>
> Changes since v3:
>  - Reordered headers
>  - Refactored more of EFI code into common code
> Removed digest_info structure and instead used the common alg_to_mask
>   and alg_to_len
> Improved event log parsing in common code to get it equivalent to EFI
>   Common code now extends PCR if previous bootloader stage couldn't
>   No need to allocate memory in the common code, so EFI copies the
>   discovered buffer like it did before
> Rename efi measure_event function
>
> Changes since v2:
>  - Add documentation.
>  - Changed reserved memory address to the top of the RAM for sandbox dts.
>  - Add measure state to booti and bootz.
>  - Skip measurement for EFI images that should be measured
>
> Changes since v1:
>  - Refactor TPM layer functions to allow EFI system to use them, and
>remove duplicate EFI functions.
>  - Add test case
>  - Drop #ifdefs for bootm
>  - Add devicetree measurement config option
>  - Update sandbox TPM driver
>
> Eddie James (6):
>   tpm: Fix spelling for tpmu_ha union
>   tpm: sandbox: Update for needed TPM2 capabilities
>   tpm: Support boot measurements
>   bootm: Support boot measurement
>   test: Add sandbox TPM boot measurement
>   doc: Add measured boot documentation
>
> Ilias Apalodimas (2):
>   efi_loader: fix EFI_ENTRY point on get_active_pcr_banks
>   test: use a non system PCR for testing PCR extend
>
>  arch/sandbox/dts/sandbox.dtsi  |  13 +
>  arch/sandbox/dts/test.dts  |  13 +
>  boot/Kconfig   |  32 ++
>  boot/bootm.c   |  74 +++
>  cmd/booti.c|   1 +
>  cmd/bootm.c|   2 +
>  cmd/bootz.c|   1 +
>  configs/sandbox_defconfig  |   1 +
>  doc/usage/index.rst|   1 +
>  

[PATCH v13 4/8] bootm: Support boot measurement

2023-10-19 Thread Eddie James
Add a configuration option to measure the boot through the bootm
function. Add the measurement state to the booti and bootz paths
as well.

Signed-off-by: Eddie James 
Reviewed-by: Simon Glass 
---
Changes since v8:
 - Added a configuration option to select to ignore any existing
   event log. This would only be selected for systems that know
   that U-Boot is the first stage bootloader. This is necessary
   because the reserved memory region may persist through resets
   and so U-Boot attempts to append to the previous boot's log.

Changes since v6:
 - Added comment for bootm_measure
 - Fixed line length in bootm_measure

 boot/Kconfig| 32 +
 boot/bootm.c| 74 +
 cmd/booti.c |  1 +
 cmd/bootm.c |  2 ++
 cmd/bootz.c |  1 +
 include/bootm.h | 11 
 include/image.h |  1 +
 7 files changed, 122 insertions(+)

diff --git a/boot/Kconfig b/boot/Kconfig
index a01e6cb8aa..abbc72f4cf 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -685,6 +685,38 @@ config LEGACY_IMAGE_FORMAT
  loaded. If a board needs the legacy image format support in this
  case, enable it here.
 
+config MEASURED_BOOT
+   bool "Measure boot images and configuration to TPM and event log"
+   depends on HASH && TPM_V2
+   help
+ This option enables measurement of the boot process. Measurement
+ involves creating cryptographic hashes of the binary images that
+ are booting and storing them in the TPM. In addition, a log of
+ these hashes is stored in memory for the OS to verify the booted
+ images and configuration. Enable this if the OS has configured
+ some memory area for the event log and you intend to use some
+ attestation tools on your system.
+
+if MEASURED_BOOT
+   config MEASURE_DEVICETREE
+   bool "Measure the devicetree image"
+   default y if MEASURED_BOOT
+   help
+ On some platforms, the devicetree is not static as it may contain
+ random MAC addresses or other such data that changes each boot.
+ Therefore, it should not be measured into the TPM. In that case,
+ disable the measurement here.
+
+   config MEASURE_IGNORE_LOG
+   bool "Ignore the existing event log"
+   default n
+   help
+ On platforms that use an event log memory region that persists
+ through system resets and are the first stage bootloader, then
+ this option should be enabled to ignore any existing data in the
+ event log memory region.
+endif # MEASURED_BOOT
+
 config SUPPORT_RAW_INITRD
bool "Enable raw initrd images"
help
diff --git a/boot/bootm.c b/boot/bootm.c
index 8f96a80d42..cb61485c22 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #if defined(CONFIG_CMD_USB)
 #include 
 #endif
@@ -673,6 +674,75 @@ int bootm_process_cmdline_env(int flags)
return 0;
 }
 
+int bootm_measure(struct bootm_headers *images)
+{
+   int ret = 0;
+
+   /* Skip measurement if EFI is going to do it */
+   if (images->os.os == IH_OS_EFI &&
+   IS_ENABLED(CONFIG_EFI_TCG2_PROTOCOL) &&
+   IS_ENABLED(CONFIG_BOOTM_EFI))
+   return ret;
+
+   if (IS_ENABLED(CONFIG_MEASURED_BOOT)) {
+   struct tcg2_event_log elog;
+   struct udevice *dev;
+   void *initrd_buf;
+   void *image_buf;
+   const char *s;
+   u32 rd_len;
+   bool ign;
+
+   elog.log_size = 0;
+   ign = IS_ENABLED(CONFIG_MEASURE_IGNORE_LOG);
+   ret = tcg2_measurement_init(, , ign);
+   if (ret)
+   return ret;
+
+   image_buf = map_sysmem(images->os.image_start,
+  images->os.image_len);
+   ret = tcg2_measure_data(dev, , 8, images->os.image_len,
+   image_buf, EV_COMPACT_HASH,
+   strlen("linux") + 1, (u8 *)"linux");
+   if (ret)
+   goto unmap_image;
+
+   rd_len = images->rd_end - images->rd_start;
+   initrd_buf = map_sysmem(images->rd_start, rd_len);
+   ret = tcg2_measure_data(dev, , 9, rd_len, initrd_buf,
+   EV_COMPACT_HASH, strlen("initrd") + 1,
+   (u8 *)"initrd");
+   if (ret)
+   goto unmap_initrd;
+
+   if (IS_ENABLED(CONFIG_MEASURE_DEVICETREE)) {
+   ret = tcg2_measure_data(dev, , 0, images->ft_len,
+   (u8 *)images->ft_addr,
+   EV_TABLE_OF_DEVICES,
+   strlen("dts") + 1,
+ 

[PATCH v13 8/8] test: use a non system PCR for testing PCR extend

2023-10-19 Thread Eddie James
From: Ilias Apalodimas 

We currently use PCR 0 for testing the PCR read/extend functionality in
our selftests.  How ever those PCRs are defined by the TCG spec for
platform use.  For example if the tests run *after* the efi subsystem
initialization, which extends PCRs 0 & 7 it will give a false positive.

So let's switch over to a PCR which is more suitable and is defined for
OS use.  It's worth noting that we are using PCR10 here, since PCR9 is
used internally by U-Boot if we choose to measure the loaded DTB

Reviewed-by: Simon Glass 
Signed-off-by: Ilias Apalodimas 
---
 test/py/tests/test_tpm2.py | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/test/py/tests/test_tpm2.py b/test/py/tests/test_tpm2.py
index c2579fa02c..47392b87a9 100644
--- a/test/py/tests/test_tpm2.py
+++ b/test/py/tests/test_tpm2.py
@@ -239,7 +239,7 @@ def test_tpm2_dam_parameters(u_boot_console):
 def test_tpm2_pcr_read(u_boot_console):
 """Execute a TPM2_PCR_Read command.
 
-Perform a PCR read of the 0th PCR. Must be zero.
+Perform a PCR read of the 10th PCR. Must be zero.
 """
 if is_sandbox(u_boot_console):
 tpm2_sandbox_init(u_boot_console)
@@ -247,7 +247,7 @@ def test_tpm2_pcr_read(u_boot_console):
 force_init(u_boot_console)
 ram = u_boot_utils.find_ram_base(u_boot_console)
 
-read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % ram)
+read_pcr = u_boot_console.run_command('tpm2 pcr_read 10 0x%x' % ram)
 output = u_boot_console.run_command('echo $?')
 assert output.endswith('0')
 
@@ -257,7 +257,7 @@ def test_tpm2_pcr_read(u_boot_console):
 updates = int(re.findall(r'\d+', str)[0])
 
 # Check the output value
-assert 'PCR #0 content' in read_pcr
+assert 'PCR #10 content' in read_pcr
 assert '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' in read_pcr
 
 @pytest.mark.buildconfigspec('cmd_tpm_v2')
@@ -275,19 +275,19 @@ def test_tpm2_pcr_extend(u_boot_console):
 force_init(u_boot_console)
 ram = u_boot_utils.find_ram_base(u_boot_console)
 
-read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % (ram + 
0x20))
+read_pcr = u_boot_console.run_command('tpm2 pcr_read 10 0x%x' % (ram + 
0x20))
 output = u_boot_console.run_command('echo $?')
 assert output.endswith('0')
 str = re.findall(r'\d+ known updates', read_pcr)[0]
 updates = int(re.findall(r'\d+', str)[0])
 
-u_boot_console.run_command('tpm2 pcr_extend 0 0x%x' % ram)
+u_boot_console.run_command('tpm2 pcr_extend 10 0x%x' % ram)
 output = u_boot_console.run_command('echo $?')
 assert output.endswith('0')
 
 # Read the value back into a different place so we can still use 'ram' as
 # our zero bytes
-read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % (ram + 
0x20))
+read_pcr = u_boot_console.run_command('tpm2 pcr_read 10 0x%x' % (ram + 
0x20))
 output = u_boot_console.run_command('echo $?')
 assert output.endswith('0')
 assert 'f5 a5 fd 42 d1 6a 20 30 27 98 ef 6e d3 09 97 9b' in read_pcr
@@ -297,11 +297,11 @@ def test_tpm2_pcr_extend(u_boot_console):
 new_updates = int(re.findall(r'\d+', str)[0])
 assert (updates + 1) == new_updates
 
-u_boot_console.run_command('tpm2 pcr_extend 0 0x%x' % ram)
+u_boot_console.run_command('tpm2 pcr_extend 10 0x%x' % ram)
 output = u_boot_console.run_command('echo $?')
 assert output.endswith('0')
 
-read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % (ram + 
0x20))
+read_pcr = u_boot_console.run_command('tpm2 pcr_read 10 0x%x' % (ram + 
0x20))
 output = u_boot_console.run_command('echo $?')
 assert output.endswith('0')
 assert '7a 05 01 f5 95 7b df 9c b3 a8 ff 49 66 f0 22 65' in read_pcr
-- 
2.39.3



[PATCH v13 3/8] tpm: Support boot measurements

2023-10-19 Thread Eddie James
Add TPM2 functions to support boot measurement. This includes
starting up the TPM, initializing/appending the event log, and
measuring the U-Boot version. Much of the code was used in the
EFI subsystem, so remove it there and use the common functions.

Signed-off-by: Eddie James 
---
Changes since v10:
 - Fix compile warning for armv7 (thanks Ilias)

Changes since v8:
 - Fix log parsing again - any data corruption seen while replaying the
   event log was failing the entire measurement.
 - Added an option to ignore the existing log. This should only be used
   for systems that know that U-Boot is the first stage bootloader. This
   is necessary because the reserved memory region may persist through
   resets and so U-Boot attempts to append to the previous boot's log.

Changes since v7:
 - Change name of tcg2_init_log and add more documentation
 - Add a check, when parsing the event log header, to ensure that the
   previous stage bootloader used all the active PCRs.
 - Change name of tcg2_log_find_end
 - Fix the greater than or equal to check to exit the log parsing
 - Make sure log_position is 0 if there is any error discovering the log
 - Return errors parsing the log if the data is corrupt so that we don't
   end up with half a log

Changes since v6:
 - Added Linaro copyright for all the EFI moved code
 - Changed tcg2_init_log (and by extension, tcg2_measurement_init) to
   copy any discovered event log to the user's log if passed in.

Changes since v5:
 - Remove unused platform_get_eventlog in efi_tcg2.c
 - First look for tpm_event_log_* properties instead of linux,sml-*
 - Fix efi_tcg2.c compilation
 - Select SHA* configs

Changes since v4:
 - Remove tcg2_measure_event function and check for NULL data in
   tcg2_measure_data
 - Use tpm_auto_startup
 - Fix efi_tcg2.c compilation for removing tcg2_pcr_read function

Changes since v3:
 - Reordered headers
 - Refactored more of EFI code into common code
Removed digest_info structure and instead used the common alg_to_mask
  and alg_to_len
Improved event log parsing in common code to get it equivalent to EFI
  Common code now extends PCR if previous bootloader stage couldn't
  No need to allocate memory in the common code, so EFI copies the
  discovered buffer like it did before
Rename efi measure_event function

Changes since v1:
 - Refactor TPM layer functions to allow EFI system to use them, and
   remove duplicate EFI functions

 include/efi_tcg2.h|  44 --
 include/tpm-v2.h  | 259 
 lib/Kconfig   |   4 +
 lib/efi_loader/efi_tcg2.c | 821 --
 lib/tpm-v2.c  | 814 +
 5 files changed, 1154 insertions(+), 788 deletions(-)

diff --git a/include/efi_tcg2.h b/include/efi_tcg2.h
index b1c3abd097..b21c5cb3dd 100644
--- a/include/efi_tcg2.h
+++ b/include/efi_tcg2.h
@@ -129,50 +129,6 @@ struct efi_tcg2_boot_service_capability {
 #define BOOT_SERVICE_CAPABILITY_MIN \
offsetof(struct efi_tcg2_boot_service_capability, number_of_pcr_banks)
 
-#define TCG_EFI_SPEC_ID_EVENT_SIGNATURE_03 "Spec ID Event03"
-#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MAJOR_TPM2 2
-#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MINOR_TPM2 0
-#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_ERRATA_TPM2 2
-
-/**
- *  struct TCG_EfiSpecIdEventAlgorithmSize - hashing algorithm information
- *
- *  @algorithm_id: algorithm defined in enum tpm2_algorithms
- *  @digest_size:  size of the algorithm
- */
-struct tcg_efi_spec_id_event_algorithm_size {
-   u16  algorithm_id;
-   u16  digest_size;
-} __packed;
-
-/**
- * struct TCG_EfiSpecIDEventStruct - content of the event log header
- *
- * @signature: signature, set to Spec ID Event03
- * @platform_class:class defined in TCG ACPI Specification
- * Client  Common Header.
- * @spec_version_minor:minor version
- * @spec_version_major:major version
- * @spec_version_errata:   major version
- * @uintn_size:size of the efi_uintn_t fields used in 
various
- * data structures used in this specification.
- * 0x01 indicates u32  and 0x02  indicates u64
- * @number_of_algorithms:  hashing algorithms used in this event log
- * @digest_sizes:  array of number_of_algorithms pairs
- * 1st member defines the algorithm id
- * 2nd member defines the algorithm size
- */
-struct tcg_efi_spec_id_event {
-   u8 signature[16];
-   u32 platform_class;
-   u8 spec_version_minor;
-   u8 spec_version_major;
-   u8 spec_errata;
-   u8 uintn_size;
-   u32 number_of_algorithms;
-   struct tcg_efi_spec_id_event_algorithm_size digest_sizes[];
-} __packed;
-
 /**
  * struct tdEFI_TCG2_FINAL_EVENTS_TABLE - log entries after Get Event Log
  

[PATCH v13 6/8] doc: Add measured boot documentation

2023-10-19 Thread Eddie James
Briefly describe the feature and specify the requirements.

Signed-off-by: Eddie James 
Reviewed-by: Simon Glass 
---
Changes since v12:
 - Add a bit of detail about OS usage and what pieces are measured

 doc/usage/index.rst |  1 +
 doc/usage/measured_boot.rst | 31 +++
 2 files changed, 32 insertions(+)
 create mode 100644 doc/usage/measured_boot.rst

diff --git a/doc/usage/index.rst b/doc/usage/index.rst
index 98b4719c40..bf53bb6bda 100644
--- a/doc/usage/index.rst
+++ b/doc/usage/index.rst
@@ -14,6 +14,7 @@ Use U-Boot
partitions
cmdline
semihosting
+   measured_boot
 
 Shell commands
 --
diff --git a/doc/usage/measured_boot.rst b/doc/usage/measured_boot.rst
new file mode 100644
index 00..0aad590859
--- /dev/null
+++ b/doc/usage/measured_boot.rst
@@ -0,0 +1,31 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Measured Boot
+=
+
+U-Boot can perform a measured boot, the process of hashing various components
+of the boot process, extending the results in the TPM and logging the
+component's measurement in memory for the operating system to consume.
+
+By default, U-Boot will measure the operating system (linux) image, the
+initrd image, and the "bootargs" environment variable. By enabling
+CONFIG_MEASURE_DEVICETREE, U-Boot will also measure the devicetree image.
+
+The operating system typically would verify that the hashes found in the
+TPM PCRs match the contents of the event log. This can further be checked
+against the hash results of previous boots.
+
+Requirements
+-
+
+* A hardware TPM 2.0 supported by the U-Boot drivers
+* CONFIG_TPM=y
+* CONFIG_MEASURED_BOOT=y
+* Device-tree configuration of the TPM device to specify the memory area
+  for event logging. The TPM device node must either contain a phandle to
+  a reserved memory region or "linux,sml-base" and "linux,sml-size"
+  indicating the address and size of the memory region. An example can be
+  found in arch/sandbox/dts/test.dts
+* The operating system must also be configured to use the memory regions
+  specified in the U-Boot device-tree in order to make use of the event
+  log.
-- 
2.39.3



[PATCH v13 5/8] test: Add sandbox TPM boot measurement

2023-10-19 Thread Eddie James
Use the sandbox TPM driver to measure some boot images in a unit
test case.

Signed-off-by: Eddie James 
Reviewed-by: Simon Glass 
Acked-by: Ilias Apalodimas 
---
Changes since v5:
 - Only compile in the measurement u-boot command when
   CONFIG_MEASURED_BOOT is enabled.

 arch/sandbox/dts/sandbox.dtsi | 13 +++
 arch/sandbox/dts/test.dts | 13 +++
 configs/sandbox_defconfig |  1 +
 include/test/suites.h |  1 +
 test/boot/Makefile|  1 +
 test/boot/measurement.c   | 66 +++
 test/cmd_ut.c |  4 +++
 7 files changed, 99 insertions(+)
 create mode 100644 test/boot/measurement.c

diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi
index ff7e5584c5..241f397ba6 100644
--- a/arch/sandbox/dts/sandbox.dtsi
+++ b/arch/sandbox/dts/sandbox.dtsi
@@ -4,11 +4,23 @@
  * and sandbox64 builds.
  */
 
+#include 
 #include 
 
 #define USB_CLASS_HUB  9
 
 / {
+   reserved-memory {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+
+   event_log: tcg_event_log {
+   no-map;
+   reg = <(CFG_SYS_SDRAM_SIZE - 0x2000) 0x2000>;
+   };
+   };
+
binman {
};
 
@@ -342,6 +354,7 @@
 
tpm2 {
compatible = "sandbox,tpm2";
+   memory-region = <_log>;
};
 
triangle {
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index e430347356..67159b3d01 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -9,6 +9,7 @@
 
 /dts-v1/;
 
+#include 
 #include 
 #include 
 #include 
@@ -68,6 +69,17 @@
osd0 = "/osd";
};
 
+   reserved-memory {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+
+   event_log: tcg_event_log {
+   no-map;
+   reg = <(CFG_SYS_SDRAM_SIZE - 0x2000) 0x2000>;
+   };
+   };
+
binman: binman {
};
 
@@ -1423,6 +1435,7 @@
 
tpm2 {
compatible = "sandbox,tpm2";
+   memory-region = <_log>;
};
 
tpm {
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 47417cb039..757dcac4ca 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -349,3 +349,4 @@ CONFIG_TEST_FDTDEC=y
 CONFIG_UNIT_TEST=y
 CONFIG_UT_TIME=y
 CONFIG_UT_DM=y
+CONFIG_MEASURED_BOOT=y
diff --git a/include/test/suites.h b/include/test/suites.h
index 1c7dc65966..48ed549c13 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -45,6 +45,7 @@ int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[]);
 int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
+int do_ut_measurement(struct cmd_tbl *cmdtp, int flag, int argc, char * const 
argv[]);
 int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
diff --git a/test/boot/Makefile b/test/boot/Makefile
index 52947580ae..068522cb9e 100644
--- a/test/boot/Makefile
+++ b/test/boot/Makefile
@@ -4,6 +4,7 @@
 
 obj-$(CONFIG_BOOTSTD) += bootdev.o bootstd_common.o bootflow.o bootmeth.o
 obj-$(CONFIG_FIT) += image.o
+obj-$(CONFIG_MEASURED_BOOT) += measurement.o
 
 obj-$(CONFIG_EXPO) += expo.o
 obj-$(CONFIG_CEDIT) += cedit.o
diff --git a/test/boot/measurement.c b/test/boot/measurement.c
new file mode 100644
index 00..9db2ed324c
--- /dev/null
+++ b/test/boot/measurement.c
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test for measured boot functions
+ *
+ * Copyright 2023 IBM Corp.
+ * Written by Eddie James 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MEASUREMENT_TEST(_name, _flags)\
+   UNIT_TEST(_name, _flags, measurement_test)
+
+static int measure(struct unit_test_state *uts)
+{
+   struct bootm_headers images;
+   const size_t size = 1024;
+   u8 *kernel;
+   u8 *initrd;
+   size_t i;
+
+   kernel = malloc(size);
+   initrd = malloc(size);
+
+   images.os.image_start = map_to_sysmem(kernel);
+   images.os.image_len = size;
+
+   images.rd_start = map_to_sysmem(initrd);
+   images.rd_end = images.rd_start + size;
+
+   images.ft_addr = malloc(size);
+   images.ft_len = size;
+
+   env_set("bootargs", "measurement testing");
+
+   for (i = 0; i < size; ++i) {
+   kernel[i] = 0xf0 | (i & 0xf);
+   initrd[i] = (i & 0xf0) | 0xf;
+   images.ft_addr[i] = i & 0xff;
+   }
+
+   

[PATCH v13 7/8] efi_loader: fix EFI_ENTRY point on get_active_pcr_banks

2023-10-19 Thread Eddie James
From: Ilias Apalodimas 

efi_tcg2_get_active_pcr_banks doesn't immediately call the
EFI_ENTRY() wrapper once it enters the function. Move the call a
few lines above to cover the error cases properly as well.

Signed-off-by: Ilias Apalodimas 
---
 lib/efi_loader/efi_tcg2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
index 7ada536568..dae1b166c8 100644
--- a/lib/efi_loader/efi_tcg2.c
+++ b/lib/efi_loader/efi_tcg2.c
@@ -949,16 +949,16 @@ efi_tcg2_get_active_pcr_banks(struct efi_tcg2_protocol 
*this,
struct udevice *dev;
efi_status_t ret;
 
+   EFI_ENTRY("%p, %p", this, active_pcr_banks);
+
if (!this || !active_pcr_banks) {
ret = EFI_INVALID_PARAMETER;
goto out;
}
-
ret = tcg2_platform_get_tpm2();
if (ret != EFI_SUCCESS)
goto out;
 
-   EFI_ENTRY("%p, %p", this, active_pcr_banks);
ret = tcg2_get_active_pcr_banks(dev, active_pcr_banks);
 
 out:
-- 
2.39.3



[PATCH v13 1/8] tpm: Fix spelling for tpmu_ha union

2023-10-19 Thread Eddie James
tmpu -> tpmu

Signed-off-by: Eddie James 
Reviewed-by: Ilias Apalodimas 
---
 include/tpm-v2.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/tpm-v2.h b/include/tpm-v2.h
index 2b6980e441..6684033deb 100644
--- a/include/tpm-v2.h
+++ b/include/tpm-v2.h
@@ -169,7 +169,7 @@ struct tcg_pcr_event {
 /**
  * Definition of TPMU_HA Union
  */
-union tmpu_ha {
+union tpmu_ha {
u8 sha1[TPM2_SHA1_DIGEST_SIZE];
u8 sha256[TPM2_SHA256_DIGEST_SIZE];
u8 sm3_256[TPM2_SM3_256_DIGEST_SIZE];
@@ -185,7 +185,7 @@ union tmpu_ha {
  */
 struct tpmt_ha {
u16 hash_alg;
-   union tmpu_ha digest;
+   union tpmu_ha digest;
 } __packed;
 
 /**
-- 
2.39.3



[PATCH v13 2/8] tpm: sandbox: Update for needed TPM2 capabilities

2023-10-19 Thread Eddie James
The driver needs to support getting the PCRs in the capabilities
command. Fix various other things and support the max number
of PCRs for TPM2.
Remove the !SANDBOX dependency for EFI TCG2 as well.

Signed-off-by: Eddie James 
Reviewed-by: Simon Glass 
Acked-by: Ilias Apalodimas 
---
Changes since v8:
 - Use >= for checking the property against TPM2_PROPERTIES_OFFSET

Changes since v5:
 - Remove the !SANDBOX dependency for EFI TCG2

 drivers/tpm/tpm2_tis_sandbox.c | 100 -
 lib/efi_loader/Kconfig |   2 -
 2 files changed, 72 insertions(+), 30 deletions(-)

diff --git a/drivers/tpm/tpm2_tis_sandbox.c b/drivers/tpm/tpm2_tis_sandbox.c
index e4004cfcca..d15a28d9fc 100644
--- a/drivers/tpm/tpm2_tis_sandbox.c
+++ b/drivers/tpm/tpm2_tis_sandbox.c
@@ -22,11 +22,6 @@ enum tpm2_hierarchy {
TPM2_HIERARCHY_NB,
 };
 
-/* Subset of supported capabilities */
-enum tpm2_capability {
-   TPM_CAP_TPM_PROPERTIES = 0x6,
-};
-
 /* Subset of supported properties */
 #define TPM2_PROPERTIES_OFFSET 0x020E
 
@@ -38,7 +33,8 @@ enum tpm2_cap_tpm_property {
TPM2_PROPERTY_NB,
 };
 
-#define SANDBOX_TPM_PCR_NB 1
+#define SANDBOX_TPM_PCR_NB TPM2_MAX_PCRS
+#define SANDBOX_TPM_PCR_SELECT_MAX ((SANDBOX_TPM_PCR_NB + 7) / 8)
 
 /*
  * Information about our TPM emulation. This is preserved in the sandbox
@@ -433,7 +429,7 @@ static int sandbox_tpm2_xfer(struct udevice *dev, const u8 
*sendbuf,
int i, j;
 
/* TPM2_GetProperty */
-   u32 capability, property, property_count;
+   u32 capability, property, property_count, val;
 
/* TPM2_PCR_Read/Extend variables */
int pcr_index = 0;
@@ -542,19 +538,32 @@ static int sandbox_tpm2_xfer(struct udevice *dev, const 
u8 *sendbuf,
case TPM2_CC_GET_CAPABILITY:
capability = get_unaligned_be32(sent);
sent += sizeof(capability);
-   if (capability != TPM_CAP_TPM_PROPERTIES) {
-   printf("Sandbox TPM only support TPM_CAPABILITIES\n");
-   return TPM2_RC_HANDLE;
-   }
-
property = get_unaligned_be32(sent);
sent += sizeof(property);
-   property -= TPM2_PROPERTIES_OFFSET;
-
property_count = get_unaligned_be32(sent);
sent += sizeof(property_count);
-   if (!property_count ||
-   property + property_count > TPM2_PROPERTY_NB) {
+
+   switch (capability) {
+   case TPM2_CAP_PCRS:
+   break;
+   case TPM2_CAP_TPM_PROPERTIES:
+   if (!property_count) {
+   rc = TPM2_RC_HANDLE;
+   return sandbox_tpm2_fill_buf(recv, recv_len,
+tag, rc);
+   }
+
+   if (property >= TPM2_PROPERTIES_OFFSET &&
+   ((property - TPM2_PROPERTIES_OFFSET) +
+property_count > TPM2_PROPERTY_NB)) {
+   rc = TPM2_RC_HANDLE;
+   return sandbox_tpm2_fill_buf(recv, recv_len,
+tag, rc);
+   }
+   break;
+   default:
+   printf("Sandbox TPM2 only supports TPM2_CAP_PCRS or "
+  "TPM2_CAP_TPM_PROPERTIES\n");
rc = TPM2_RC_HANDLE;
return sandbox_tpm2_fill_buf(recv, recv_len, tag, rc);
}
@@ -578,18 +587,53 @@ static int sandbox_tpm2_xfer(struct udevice *dev, const 
u8 *sendbuf,
put_unaligned_be32(capability, recv);
recv += sizeof(capability);
 
-   /* Give the number of properties that follow */
-   put_unaligned_be32(property_count, recv);
-   recv += sizeof(property_count);
-
-   /* Fill with the properties */
-   for (i = 0; i < property_count; i++) {
-   put_unaligned_be32(TPM2_PROPERTIES_OFFSET + property +
-  i, recv);
-   recv += sizeof(property);
-   put_unaligned_be32(tpm->properties[property + i],
-  recv);
-   recv += sizeof(property);
+   switch (capability) {
+   case TPM2_CAP_PCRS:
+   /* Give the number of algorithms supported - just 
SHA256 */
+   put_unaligned_be32(1, recv);
+   recv += sizeof(u32);
+
+   /* Give SHA256 algorithm */
+   put_unaligned_be16(TPM2_ALG_SHA256, recv);
+   recv += sizeof(u16);
+
+   /* Select the PCRs supported */
+   *recv 

[PATCH v13 0/8] tpm: Support boot measurements

2023-10-19 Thread Eddie James
This series adds support for measuring the boot images more generically
than the existing EFI support. Several EFI functions have been moved to
the TPM layer. The series includes optional measurement from the bootm 
command.
A new test case has been added for the bootm measurement to test the new
path, and the sandbox TPM2 driver has been updated to support this use
case.

Changes since v12:
 - Rebase on master.
 - Add detail to documentation.

Changes since v11:
 - Rebase on next. Sorry for the delay (been on leave).

Changes since v10:
 - Fix commit message on efi_loader change
 - Drop python test change
 - Squash armv7 fix from Ilias

Changes since v9:
 - Rebase and add Ilias' fixes (thanks!)

Changes since v8:
 - Fix a sandbox driver off-by-one error in checking the property type.
 - Fix log parsing again - any data corruption seen while replaying the
   event log was failing the entire measurement.
 - Added an option to ignore the existing log and a configuration option
   for systems to select that for the bootm measurement. This would only
   be selected for systems that know that U-Boot is the first stage
   bootloader. This is necessary because the reserved memory region may
   persist through resets and so U-Boot attempts to append to the
   previous boot's log.

Changes since v7:
 - Change name of tcg2_init_log and add more documentation
 - Add a check, when parsing the event log header, to ensure that the
   previous stage bootloader used all the active PCRs.
 - Change name of tcg2_log_find_end
 - Fix the greater than or equal to check to exit the log parsing
 - Make sure log_position is 0 if there is any error discovering the log
 - Return errors parsing the log if the data is corrupt so that we don't
   end up with half a log

Changes since v6:
 - Added comment for bootm_measure
 - Fixed line length in bootm_measure
 - Added Linaro copyright for all the EFI moved code
 - Changed tcg2_init_log (and by extension, tcg2_measurement_init) to
   copy any discovered event log to the user's log if passed in.

Changes since v5:
 - Re-ordered the patches to put the sandbox TPM driver patch second
 - Remove unused platform_get_eventlog in efi_tcg2.c
 - First look for tpm_event_log_* properties instead of linux,sml-*
 - Fix efi_tcg2.c compilation
 - Select SHA* configs
 - Remove the !SANDBOX dependency for EFI TCG2
 - Only compile in the measurement u-boot command when CONFIG_MEASURED_BOOT
   is enabled

Changes since v4:
 - Remove tcg2_measure_event function and check for NULL data in
   tcg2_measure_data
 - Use tpm_auto_startup
 - Fix efi_tcg2.c compilation for removing tcg2_pcr_read function
 - Change PCR indexes for initrd and dtb
 - Drop u8 casting in measurement test
 - Use bullets in documentation

Changes since v3:
 - Reordered headers
 - Refactored more of EFI code into common code
Removed digest_info structure and instead used the common alg_to_mask
  and alg_to_len
Improved event log parsing in common code to get it equivalent to EFI
  Common code now extends PCR if previous bootloader stage couldn't
  No need to allocate memory in the common code, so EFI copies the
  discovered buffer like it did before
Rename efi measure_event function

Changes since v2:
 - Add documentation.
 - Changed reserved memory address to the top of the RAM for sandbox dts.
 - Add measure state to booti and bootz.
 - Skip measurement for EFI images that should be measured

Changes since v1:
 - Refactor TPM layer functions to allow EFI system to use them, and
   remove duplicate EFI functions.
 - Add test case
 - Drop #ifdefs for bootm
 - Add devicetree measurement config option
 - Update sandbox TPM driver

Eddie James (6):
  tpm: Fix spelling for tpmu_ha union
  tpm: sandbox: Update for needed TPM2 capabilities
  tpm: Support boot measurements
  bootm: Support boot measurement
  test: Add sandbox TPM boot measurement
  doc: Add measured boot documentation

Ilias Apalodimas (2):
  efi_loader: fix EFI_ENTRY point on get_active_pcr_banks
  test: use a non system PCR for testing PCR extend

 arch/sandbox/dts/sandbox.dtsi  |  13 +
 arch/sandbox/dts/test.dts  |  13 +
 boot/Kconfig   |  32 ++
 boot/bootm.c   |  74 +++
 cmd/booti.c|   1 +
 cmd/bootm.c|   2 +
 cmd/bootz.c|   1 +
 configs/sandbox_defconfig  |   1 +
 doc/usage/index.rst|   1 +
 doc/usage/measured_boot.rst|  23 +
 drivers/tpm/tpm2_tis_sandbox.c | 100 ++--
 include/bootm.h|  11 +
 include/efi_tcg2.h |  44 --
 include/image.h|   1 +
 include/test/suites.h  |   1 +
 include/tpm-v2.h   | 263 ++-
 lib/Kconfig|   4 +
 lib/efi_loader/Kconfig |   2 -
 lib/efi_loader/efi_tcg2.c  | 823 -
 lib/tpm-v2.c   | 814 
 test/boot/Makefile |   1 

Re: [PATCH v12 6/8] doc: Add measured boot documentation

2023-10-19 Thread Eddie James



On 10/12/23 10:29, Simon Glass wrote:

Hi Eddie,

On Thu, 12 Oct 2023 at 08:08, Eddie James  wrote:

Briefly describe the feature and specify the requirements.

Signed-off-by: Eddie James 
Reviewed-by: Simon Glass 

This could use a bit more detail. What pieces are measured? What DT
binding is used for the TPM? How is the info checked by the OS or
whatever?



Sure, I'll add a little bit more. The DT binding is described in the 
requirements section.







---
  doc/usage/index.rst |  1 +
  doc/usage/measured_boot.rst | 23 +++
  2 files changed, 24 insertions(+)
  create mode 100644 doc/usage/measured_boot.rst

diff --git a/doc/usage/index.rst b/doc/usage/index.rst
index fa702920fa..fb043a8923 100644
--- a/doc/usage/index.rst
+++ b/doc/usage/index.rst
@@ -14,6 +14,7 @@ Use U-Boot
 partitions
 cmdline
 semihosting
+   measured_boot

  Shell commands
  --
diff --git a/doc/usage/measured_boot.rst b/doc/usage/measured_boot.rst
new file mode 100644
index 00..8357b1f480
--- /dev/null
+++ b/doc/usage/measured_boot.rst
@@ -0,0 +1,23 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Measured Boot
+=
+
+U-Boot can perform a measured boot, the process of hashing various components
+of the boot process, extending the results in the TPM and logging the
+component's measurement in memory for the operating system to consume.
+
+Requirements
+-
+
+* A hardware TPM 2.0 supported by the U-Boot drivers
+* CONFIG_TPM=y
+* CONFIG_MEASURED_BOOT=y
+* Device-tree configuration of the TPM device to specify the memory area
+  for event logging. The TPM device node must either contain a phandle to
+  a reserved memory region or "linux,sml-base" and "linux,sml-size"
+  indicating the address and size of the memory region. An example can be
+  found in arch/sandbox/dts/test.dts
+* The operating system must also be configured to use the memory regions
+  specified in the U-Boot device-tree in order to make use of the event
+  log.

Regards,
Simon


Re: [PATCH v2 1/1] efi_loader: expose the device-tree file name

2023-10-19 Thread Heinrich Schuchardt

On 19.10.23 15:55, Simon Glass wrote:

Hi Heinrich,

On Wed, 18 Oct 2023 at 02:15, Heinrich Schuchardt
 wrote:


On 10/18/23 05:33, Simon Glass wrote:

Hi Heinrich,

On Tue, 17 Oct 2023 at 07:50, Heinrich Schuchardt
 wrote:


Forward and backward compatibility of Linux kernel device-trees is
sometimes missing. One solution approach is to load a kernel specific
device-tree. This can either be done via a U-Boot scripts (like the one
generated by Debian package flash-kernel or by a boot loader like GRUB.
The boot loader approach currently requires to know the device-tree name
before first boot which makes it unusable for generic images.

Expose the device-tree file name as EFI variable FdtFile.
This will allow bootloaders to load a kernel specific device-tree.

The variable will not be exposed on ACPI based systems or if the
environment variable fdtfile is not defined.

Signed-off-by: Heinrich Schuchardt 
---
v2:
  Use a unique GUID to enable future U-Boot independent
  standardization.
  Do not try to add the variable on ACPI based systems.
---
   include/efi_loader.h   |  5 +
   lib/efi_loader/efi_setup.c | 30 ++
   2 files changed, 35 insertions(+)


I was too slow to reply to v1.

Does grub load the DT? I was assuming that U-Boot would pass it on?
What is the interface between U-Boot and grub?


The device-tree built into U-Boot is often out of date and not usable to
boot current Linux. A single device-tree can be loaded by U-Boot from
file and passed on as EFI configuration table. This device-tree may not
be compatible with all kernel versions exposed by GRUB.

GRUB provides a devicetree command. It is disabled if you use secure
boot. At least in Debian and Ubuntu GRUB invokes the
EFI_DT_FIXUP_PROTOCOL exposed by U-Boot to run U-Boot's device-tree
fix-ups after loading a device-tree.

Vendor scripts for GRUB like Ubuntu's /etc/grub.d/10_linux add
devicetree commands to the boot options in grub.cfg.


Thanks. I wonder if you could document this somewhere? It seems like
there are a lot of options and it is quite complicated.

Back to the question, I suppose you are expecting grub to load the DT
using this filename? But why doesn't U-Boot load it instead? It seems
very convoluted.


A separate file of this name exists for every kernel version installed. 
The loaded dtb must match the kernel. U-Boot does not know what kernel 
version will be chosen in GRUB. And for a generic image GRUB does not 
what board it is on.




Also, can we test this interface?


Neither the sandbox nor QEMU have environment variable fdtfile. And we 
don't create the EFI variable with ACPI as used on the sandbox.


Best regards

Heinrich


Re: [PATCH v5 00/11] spl: Use common function for loading/parsing images

2023-10-19 Thread Tom Rini
On Wed, Oct 18, 2023 at 01:33:20PM -0400, Sean Anderson wrote:
> On 8/3/23 00:41, Heinrich Schuchardt wrote:
> > On 8/3/23 03:31, Tom Rini wrote:
> > > On Wed, Aug 02, 2023 at 09:13:21PM -0400, Sean Anderson wrote:
> > > > On 8/2/23 16:11, Tom Rini wrote:
> > > > > On Mon, Jul 31, 2023 at 06:42:52PM -0400, Sean Anderson wrote:
> > > > > 
> > > > > > This series adds support for loading all image types (Legacy, FIT 
> > > > > > (with
> > > > > > and without LOAD_FIT_FULL), and i.MX) to the MMC, SPI, NOR, NET, 
> > > > > > FAT,
> > > > > > and EXT load methods. It does this by introducing a helper function
> > > > > > which handles the minutiae of invoking the proper parsing function, 
> > > > > > and
> > > > > > reading the rest of the image.
> > > > > > 
> > > > > > Hopefully, this will make it easier for load methods to support all
> > > > > > image types that U-Boot supports, without having undocumented
> > > > > > unsupported image types. I applied this to several loaders which 
> > > > > > were
> > > > > > invoking spl_load_simple_fit and/or spl_parse_image_header, but I 
> > > > > > did
> > > > > > not use it with others (e.g. DFU/RAM) which had complications in the
> > > > > > mix.
> > > > > > 
> > > > > > In order to meet size requirements for some boards, the first two
> > > > > > patches of this series are general size-reduction changes. The 
> > > > > > ffs/fls
> > > > > > change in particular should reduce code size across the board. The
> > > > > > malloc change also has the potential to reduce code size. I've left 
> > > > > > it
> > > > > > disabled by default, but maybe we can reverse that in the future.
> > > > > > 
> > > > > > Here's some bloat-o-meter for j7200_evm_a72_defconfig with ext4 
> > > > > > support
> > > > > > enabed:
> > > > > > 
> > > > > add/remove: 2/1 grow/shrink: 1/5 up/down: 444/-584 (-140)
> > > > > > Function old new   delta
> > > > > > spl_load   - 216    +216
> > > > > spl_simple_read    - 184    +184
> > > > > > spl_fit_read  60 104 +44
> > > > > > file_fat_read 40   - -40
> > > > > > spl_nor_load_image   120  76 -44
> > > > > > spl_load_image_ext   364 296 -68
> > > > > spl_load_image_fat   320 200    -120
> > > > > > spl_spi_load_image   304 176    -128
> > > > > > spl_mmc_load 716 532    -184
> > > > > > Total: Before=233618, After=233478, chg -0.06%
> > > > > > 
> > > > > > For most boards with a few load methods, this series should break 
> > > > > > even.
> > > > > > However, in the worst case this series will add around 100 bytes.
> > > > > > 
> > > > > > I have only tested a few loaders. Please try booting your favorite 
> > > > > > board
> > > > > > with NOR/SPI flash or SPI falcon mode.
> > > > > 
> > > > > > On sama5d27_wlsom1_ek_mmc_defconfig, 100 bytes is too much, so this
> > > > > > series depends on [1] to fit everything in. CI run at [2].
> > > > > > 
> > > > > > [1] 
> > > > > > https://lore.kernel.org/u-boot/20230731223327.109865-1-sean.ander...@seco.com/
> > > > > > [2] 
> > > > > > https://source.denx.de/u-boot/custodians/u-boot-clk/-/pipelines/17116
> > > > > 
> > > > > I've boot-tested this on my lab and a handful of SD+FAT or SD+raw boot
> > > > > devices, and it's all worked.  I also did my usual world build
> > > > > before/after to check out the size changes and well, I don't know.  
> > > > > The
> > > > > size wins come on platforms where there's both FAT+EXT support.  And
> > > > > then on mips with say mt7620_rfb I wonder if we're loosing
> > > > > functionality.
> > > > 
> > > > Yes we are. I'll address this in v6.
> > > > 
> > > > > But most platforms grow a bit, especially if they're just
> > > > > a single load type (which is the most common case). Maybe this problem
> > > > > needs to be approached another way? I've put the whole log over at
> > > > > https://gist.github.com/trini/e6772b2134e0eb44393364ea98729e06 and 
> > > > > maybe
> > > > > something will jump out to you.
> > > > 
> > > > The fls/ffs patch [1] reduces the growth by around 80 bytes on ARM
> > > > platforms. I sent it separately for ease of review, but it really should
> > > > be applied before this series, since a good portion of the growth is due
> > > > to that one function call. It seems like MIPS also has this instruction
> > > > (and Linux uses it), so I can try putting together a patch for it as
> > > > well.
> > > > 
> > > > In the future, I would like to convert bl_len to bl_shift or something,
> > > > which would remove the need for fls (and going from bl_shift to bl_len
> > > > is just a shift). spl_load_info is used in a lot of places, so I wanted
> > > > to do that in a follow-up. On arches with efficient 

Re: [PATCH 6/6] led: add TI LP5562 LED driver

2023-10-19 Thread Marek Vasut

On 10/19/23 11:58, Rasmus Villemoes wrote:

From: Doug Zobel 

Driver for the TI LP5562 4 channel LED controller. Supports
independent on/off control of all 4 channels. Supports LED_BLINK on 3
independent channels: blue/green/red. The white channel can blink, but
shares the blue channel blink rate.

Heavily based on patch originally from Doug Zobel [1].

I have modified it so it matches the DT bindings in the linux tree,
and also follows the linux driver implementation more closely. This
should address Tom's concerns, and also matches my goal of making the
U-Boot driver work with our existing .dts which is known to work in
linux.

As our boards only have the R,G,B outputs connected, I have not
actually tested how the white channel behaves, but the R,G,B work
exactly as expected.

[1] 
https://lore.kernel.org/u-boot/1547150757-1561-1-git-send-email-douglas.zo...@climate.com/

Cc: Doug Zobel 
Signed-off-by: Rasmus Villemoes 
---
  doc/device-tree-bindings/leds/leds-lp5562.txt |  63 ++
  drivers/led/Kconfig   |   8 +
  drivers/led/Makefile  |   1 +
  drivers/led/led_lp5562.c  | 578 ++
  4 files changed, 650 insertions(+)
  create mode 100644 doc/device-tree-bindings/leds/leds-lp5562.txt
  create mode 100644 drivers/led/led_lp5562.c

diff --git a/doc/device-tree-bindings/leds/leds-lp5562.txt 
b/doc/device-tree-bindings/leds/leds-lp5562.txt
new file mode 100644
index 00..4e0c742959
--- /dev/null
+++ b/doc/device-tree-bindings/leds/leds-lp5562.txt


Why not use Linux Documentation/devicetree/bindings/leds/leds-lp55xx.yaml ?

[...]


--- /dev/null
+++ b/drivers/led/led_lp5562.c
@@ -0,0 +1,578 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Doug Zobel 


Why not port Linux drivers/leds/leds-lp5562.c ?


Re: [PATCH 4/6] led: led_gpio: use led_bind_generic() helper

2023-10-19 Thread Marek Vasut

On 10/19/23 11:58, Rasmus Villemoes wrote:

Commit message is missing.


Re: [PATCH 5/6] led: led_pwm: use led_bind_generic() helper

2023-10-19 Thread Marek Vasut

On 10/19/23 11:58, Rasmus Villemoes wrote:

Commit message is missing.


Re: [PATCH 3/6] led: introduce led_bind_generic()

2023-10-19 Thread Marek Vasut

On 10/19/23 11:58, Rasmus Villemoes wrote:

All existing drivers in drivers/led/ contain a .bind method that does
exactly the same thing, with just the actual driver name
differing. Create a helper so all those individual methods can be
changed to one-liners.

Signed-off-by: Rasmus Villemoes 


Reviewed-by: Marek Vasut 


Re: [PATCH 2/6] led-uclass: honour ->label field populated by driver's own .bind

2023-10-19 Thread Marek Vasut

On 10/19/23 11:58, Rasmus Villemoes wrote:

If the driver's own .bind method has populated uc_plat->label, don't
override that. This is necessary for an upcoming driver for ti,lp5562,
where the DT binding unfortunately says to use "chan-name" and not
"label".

Signed-off-by: Rasmus Villemoes 
---
  drivers/led/led-uclass.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c
index 5a5d07b9a7..0232fa84de 100644
--- a/drivers/led/led-uclass.c
+++ b/drivers/led/led-uclass.c
@@ -71,7 +71,9 @@ static int led_post_bind(struct udevice *dev)
struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev);
const char *default_state;
  
-	uc_plat->label = dev_read_string(dev, "label");

+   if (!uc_plat->label)
+   uc_plat->label = dev_read_string(dev, "label");
+


One thing I have to wonder about is, why does this controller have label 
property in the top-level node , what is that used for ?


(see Linux Documentation/devicetree/bindings/leds/leds-lp55xx.yaml)

Reviewed-by: Marek Vasut 


Re: [PATCH 1/6] led-uclass: do not create fallback label for top-level node

2023-10-19 Thread Marek Vasut

On 10/19/23 11:58, Rasmus Villemoes wrote:

Many existing drivers, and led-uclass itself, rely on uc_plat->label
being NULL for the device representing the top node, as opposed to the
child nodes representing individual LEDs. This means that the drivers
whose .probe methods rely on this were broken by 83c63f0d1185 ("led:
Move OF "label" property parsing to core"), and also that the top node
wrongly shows up with 'led list'. Some drivers have since been fixed
up individually, e.g.

e3aa76644c2a "led: gpio: Check device compatible string to determine the top level 
node"
01074697801b "led: gpio: Use NOP uclass driver for top-level node"
910b01c27c04 "drivers: led: bcm6753: do not use null label to find the top"

Binding the same driver to the top node as to the individual child
nodes is arguably wrong, and the approach of using a UCLASS_NOP driver
for the top node is probably better.


Note that
83c63f0d1185 ("led: Move OF "label" property parsing to core")
and
01074697801b ("led: gpio: Use NOP uclass driver for top-level node")
were applied shortly after each other, so I don't see the point of the 
aforementioned rant.


I sort-of understand what you are trying to do in this patch based on 
$SUBJECT of this email, but not from this wall of text, so can you 
abbreviate the commit message ?



But as a temporary work-around, we can use a heuristic that only sets
the label to the fallback value derived from the node name if the node
does not have a "compatible" property - i.e., if it has been bound to
the LED driver explicitly via device_bind_driver_to_node() [similar to
what e3aa76644c2a did, but that then vanished with the next commit.]

Fixes: 83c63f0d1185 ("led: Move OF "label" property parsing to core")
Signed-off-by: Rasmus Villemoes 
---
  drivers/led/led-uclass.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c
index 68ca3c2970..5a5d07b9a7 100644
--- a/drivers/led/led-uclass.c
+++ b/drivers/led/led-uclass.c
@@ -72,7 +72,7 @@ static int led_post_bind(struct udevice *dev)
const char *default_state;
  
  	uc_plat->label = dev_read_string(dev, "label");

-   if (!uc_plat->label)
+   if (!uc_plat->label && !dev_read_string(dev, "compatible"))
uc_plat->label = ofnode_get_name(dev_ofnode(dev));


Is there an existing driver which has a top-level DT node with "label" 
property ?



uc_plat->default_state = LEDST_COUNT;




Re: [RESEND PATCH v1 1/2] spi: add support for Amlogic A1 SPI Flash Controller

2023-10-19 Thread Igor Prusov
On Tue, Oct 17, 2023 at 09:33:02PM -0600, Simon Glass wrote:
> Hi Igor,
> 
> On Tue, 17 Oct 2023 at 11:18, Igor Prusov  wrote:
> >
> > From: Igor Prusov 
> >
> > Add A1 SPIFC driver from Linux. Slightly modified to use u-boot driver
> > framework and accommodate to lack of ioread32_rep/iowrite32_rep.
> 
> Well, you could bring them in!
> 
> >
> > Based on Linux version 6.6-rc4
> >
> > Signed-off-by: Igor Prusov 
> > Signed-off-by: Martin Kurbanov 
> > ---
> >  drivers/spi/Kconfig  |   8 +
> >  drivers/spi/Makefile |   1 +
> >  drivers/spi/meson_spifc_a1.c | 384 +++
> >  3 files changed, 393 insertions(+)
> >  create mode 100644 drivers/spi/meson_spifc_a1.c
> 
> Reviewed-by: Simon Glass 
> 
> nits below
> 
> >
> > diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
> > index 854b8b88da..dedb366370 100644
> > --- a/drivers/spi/Kconfig
> > +++ b/drivers/spi/Kconfig
> > @@ -251,6 +251,14 @@ config MICROCHIP_COREQSPI
> >   Enable the QSPI driver for Microchip FPGA QSPI controllers.
> >   This driver can be used on Polarfire SoC.
> >
> > +config MESON_SPIFC_A1
> > +   bool "Amlogic Meson A1 SPI Flash Controller driver"
> > +   depends on ARCH_MESON
> > +   help
> > + Enable the Amlogic A1 SPI Flash Controller (SPIFC) driver.
> > + This driver can be used to access the SPI NOR/NAND flash chips on
> > + Amlogic A1 SoC.
> 
> What speeds does and modes it support? Can you add a little more detail?
> 
Sure, will add in v2.
> > +
> >  config MPC8XX_SPI
> > bool "MPC8XX SPI Driver"
> > depends on MPC8xx
> > diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
> > index c27b3327c3..14bdb97f18 100644
> > --- a/drivers/spi/Makefile
> > +++ b/drivers/spi/Makefile
> > @@ -41,6 +41,7 @@ obj-$(CONFIG_ICH_SPI) +=  ich.o
> >  obj-$(CONFIG_IPROC_QSPI) += iproc_qspi.o
> >  obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
> >  obj-$(CONFIG_MESON_SPIFC) += meson_spifc.o
> > +obj-$(CONFIG_MESON_SPIFC_A1) += meson_spifc_a1.o
> >  obj-$(CONFIG_MICROCHIP_COREQSPI) += microchip_coreqspi.o
> >  obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
> >  obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
> > diff --git a/drivers/spi/meson_spifc_a1.c b/drivers/spi/meson_spifc_a1.c
> > new file mode 100644
> > index 00..4b840c4634
> > --- /dev/null
> > +++ b/drivers/spi/meson_spifc_a1.c
> > @@ -0,0 +1,384 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Driver for Amlogic A1 SPI flash controller (SPIFC)
> > + *
> > + * Copyright (c) 2023, SberDevices. All Rights Reserved.
> > + *
> > + * Author: Martin Kurbanov 
> > + *
> > + * Ported to u-boot:
> > + * Author: Igor Prusov 
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#define SPIFC_A1_AHB_CTRL_REG  0x0
> > +#define SPIFC_A1_AHB_BUS_ENBIT(31)
> > +
> > +#define SPIFC_A1_USER_CTRL0_REG0x200
> > +#define SPIFC_A1_USER_REQUEST_ENABLE   BIT(31)
> > +#define SPIFC_A1_USER_REQUEST_FINISH   BIT(30)
> > +#define SPIFC_A1_USER_DATA_UPDATED BIT(0)
> > +
> > +#define SPIFC_A1_USER_CTRL1_REG0x204
> > +#define SPIFC_A1_USER_CMD_ENABLE   BIT(30)
> > +#define SPIFC_A1_USER_CMD_MODE GENMASK(29, 28)
> > +#define SPIFC_A1_USER_CMD_CODE GENMASK(27, 20)
> > +#define SPIFC_A1_USER_ADDR_ENABLE  BIT(19)
> > +#define SPIFC_A1_USER_ADDR_MODEGENMASK(18, 17)
> > +#define SPIFC_A1_USER_ADDR_BYTES   GENMASK(16, 15)
> > +#define SPIFC_A1_USER_DOUT_ENABLE  BIT(14)
> > +#define SPIFC_A1_USER_DOUT_MODEGENMASK(11, 10)
> > +#define SPIFC_A1_USER_DOUT_BYTES   GENMASK(9, 0)
> > +
> > +#define SPIFC_A1_USER_CTRL2_REG0x208
> > +#define SPIFC_A1_USER_DUMMY_ENABLE BIT(31)
> > +#define SPIFC_A1_USER_DUMMY_MODE   GENMASK(30, 29)
> > +#define SPIFC_A1_USER_DUMMY_CLK_SYCLES GENMASK(28, 23)
> > +
> > +#define SPIFC_A1_USER_CTRL3_REG0x20c
> > +#define SPIFC_A1_USER_DIN_ENABLE   BIT(31)
> > +#define SPIFC_A1_USER_DIN_MODE GENMASK(28, 27)
> > +#define SPIFC_A1_USER_DIN_BYTESGENMASK(25, 16)
> > +
> > +#define SPIFC_A1_USER_ADDR_REG 0x210
> > +
> > +#define SPIFC_A1_AHB_REQ_CTRL_REG  0x214
> > +#define SPIFC_A1_AHB_REQ_ENABLEBIT(31)
> > +
> > +#define SPIFC_A1_ACTIMING0_REG (0x0088 << 2)
> > +#define SPIFC_A1_TSLCH GENMASK(31, 30)
> > +#define SPIFC_A1_TCLSH GENMASK(29, 28)
> > +#define SPIFC_A1_TSHWL GENMASK(20, 16)
> > +#define SPIFC_A1_TSHSL2GENMASK(15, 12)
> > +#define SPIFC_A1_TSHSL1GENMASK(11, 8)
> > +#define SPIFC_A1_TWHSL GENMASK(7, 0)
> > +
> > +#define SPIFC_A1_DBUF_CTRL_REG 0x240
> > +#define SPIFC_A1_DBUF_DIR  BIT(31)
> > +#define 

Re: [v4 11/24] efi: Rearrange the Kconfig for CMD_BOOTEFI_BOOTMGR

2023-10-19 Thread Tom Rini
On Thu, Oct 19, 2023 at 05:24:33PM +0200, Heinrich Schuchardt wrote:
> On 19.10.23 17:19, Tom Rini wrote:
> > On Thu, Oct 19, 2023 at 05:16:28PM +0200, Heinrich Schuchardt wrote:
> > > On 19.10.23 17:00, Tom Rini wrote:
> > > > From: Simon Glass 
> > > > 
> > > > The command should not be used to enable library functionality. Add a
> > > > new BOOTEFI_BOOTMGR Kconfig for that. Adjust the conditions so that the
> > > > same code is built.
> > > > 
> > > > Signed-off-by: Simon Glass 
> > > > Suggested-by: AKASHI Takahiro 
> > > > ---
> > > > Cc: Heinrich Schuchardt 
> > > > Cc: Ilias Apalodimas 
> > > > Changes in v4:
> > > > - Integrate AKASHI Takahiro's feedback from v3
> > > > - Reword the help text on CMD_BOOTEFI_BOOTMGR slightly
> > > > ---
> > > >cmd/Kconfig | 11 ++-
> > > >lib/efi_loader/Kconfig  |  6 +++---
> > > >lib/efi_loader/Makefile |  2 +-
> > > >3 files changed, 14 insertions(+), 5 deletions(-)
> > > > 
> > > > diff --git a/cmd/Kconfig b/cmd/Kconfig
> > > > index 16e5cb8f0633..872cb49150cc 100644
> > > > --- a/cmd/Kconfig
> > > > +++ b/cmd/Kconfig
> > > > @@ -379,6 +379,15 @@ config CMD_BOOTEFI
> > > > help
> > > >   Boot an EFI image from memory.
> > > > +config CMD_BOOTEFI_BOOTMGR
> > > > +   bool "UEFI Boot Manager command"
> > > > +   depends on BOOTEFI_BOOTMGR && CMD_BOOTEFI
> > > > +   default y
> > > > +   help
> > > > + Select this option to enable the 'bootmgr' subcommand of 
> > > > 'bootefi'.
> > > > + This subcommand will allow you to select the UEFI binary to 
> > > > be booted
> > > > + via UEFI variables Boot, BootOrder, and BootNext.
> > > > +
> > > >config CMD_BOOTEFI_HELLO_COMPILE
> > > > bool "Compile a standard EFI hello world binary for testing"
> > > > depends on CMD_BOOTEFI && !CPU_V7M
> > > > @@ -2110,7 +2119,7 @@ config CMD_EFIDEBUG
> > > >config CMD_EFICONFIG
> > > > bool "eficonfig - provide menu-driven uefi variables 
> > > > maintenance interface"
> > > > default y if !HAS_BOARD_SIZE_LIMIT
> > > > -   depends on CMD_BOOTEFI_BOOTMGR
> > > > +   depends on BOOTEFI_BOOTMGR
> > > > select MENU
> > > > help
> > > >   Enable the 'eficonfig' command which provides the menu-driven 
> > > > UEFI
> > > > diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> > > > index d20aaab6dba4..13cad6342c36 100644
> > > > --- a/lib/efi_loader/Kconfig
> > > > +++ b/lib/efi_loader/Kconfig
> > > > @@ -32,14 +32,14 @@ config EFI_LOADER
> > > >if EFI_LOADER
> > > > -config CMD_BOOTEFI_BOOTMGR
> > > > +config BOOTEFI_BOOTMGR
> > > > bool "UEFI Boot Manager"
> > > > default y
> > > > select BOOTMETH_GLOBAL if BOOTSTD
> > > > help
> > > >   Select this option if you want to select the UEFI binary to 
> > > > be booted
> > > > - via UEFI variables Boot, BootOrder, and BootNext. This 
> > > > enables the
> > > > - 'bootefi bootmgr' command.
> > > > + via UEFI variables Boot, BootOrder, and BootNext. You 
> > > > should also
> > > > + normally enable CMD_BOOTEFI_BOOTMGR so that the command is 
> > > > available.
> > > >choice
> > > > prompt "Store for non-volatile UEFI variables"
> > > > diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
> > > > index 8d31fc61c601..0a2cb6e3c476 100644
> > > > --- a/lib/efi_loader/Makefile
> > > > +++ b/lib/efi_loader/Makefile
> > > > @@ -42,7 +42,7 @@ targets += initrddump.o
> > > >endif
> > > >obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
> > > > -obj-$(CONFIG_CMD_BOOTEFI_BOOTMGR) += efi_bootmgr.o
> > > > +obj-$(CONFIG_BOOTEFI_BOOTMGR) += efi_bootmgr.o
> > > >obj-y += efi_boottime.o
> > > >obj-y += efi_helper.o
> > > >obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += efi_capsule.o
> > > 
> > > This patch looks wrong.
> > > 
> > > Symbol CONFIG_CMD_BOOTEFI_BOOTMGR is used in a lot of places where it is 
> > > not
> > > related to the 'bootefi bootmgr' subcommand.
> > > 
> > > I see no benefit in two separate symbols. If you want to rename the 
> > > symbol,
> > > please, replace *all* occurrences:
> > > 
> > > %s/CONFIG_CMD_BOOTEFI_BOOTMGR/CONFIG_BOOTEFI_BOOTMGR/
> > 
> > Yes, there's work on the EFI_LOADER side of things to support the use
> > case of "boot to menu" (or, "boot to efi bootmgr") of which this is the
> > starting point. The follow-up work that I'm hoping you or someone else
> > with more EFI_LOADER experience will pick up is splitting cmd/bootefi.c
> > such that we can call in to starting an EFI payload (or bootmgr) without
> > the command line.
> > 
> 
> Even after factoring out the boot functionality I would not know why we
> should have two separate symbols. I am fine with a rename which makes it
> clear that this symbol is about a library functionality.

Because there's the library functionality and there's the literal
command code. If you're 

Re: [v4 11/24] efi: Rearrange the Kconfig for CMD_BOOTEFI_BOOTMGR

2023-10-19 Thread Heinrich Schuchardt

On 19.10.23 17:19, Tom Rini wrote:

On Thu, Oct 19, 2023 at 05:16:28PM +0200, Heinrich Schuchardt wrote:

On 19.10.23 17:00, Tom Rini wrote:

From: Simon Glass 

The command should not be used to enable library functionality. Add a
new BOOTEFI_BOOTMGR Kconfig for that. Adjust the conditions so that the
same code is built.

Signed-off-by: Simon Glass 
Suggested-by: AKASHI Takahiro 
---
Cc: Heinrich Schuchardt 
Cc: Ilias Apalodimas 
Changes in v4:
- Integrate AKASHI Takahiro's feedback from v3
- Reword the help text on CMD_BOOTEFI_BOOTMGR slightly
---
   cmd/Kconfig | 11 ++-
   lib/efi_loader/Kconfig  |  6 +++---
   lib/efi_loader/Makefile |  2 +-
   3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 16e5cb8f0633..872cb49150cc 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -379,6 +379,15 @@ config CMD_BOOTEFI
help
  Boot an EFI image from memory.
+config CMD_BOOTEFI_BOOTMGR
+   bool "UEFI Boot Manager command"
+   depends on BOOTEFI_BOOTMGR && CMD_BOOTEFI
+   default y
+   help
+ Select this option to enable the 'bootmgr' subcommand of 'bootefi'.
+ This subcommand will allow you to select the UEFI binary to be booted
+ via UEFI variables Boot, BootOrder, and BootNext.
+
   config CMD_BOOTEFI_HELLO_COMPILE
bool "Compile a standard EFI hello world binary for testing"
depends on CMD_BOOTEFI && !CPU_V7M
@@ -2110,7 +2119,7 @@ config CMD_EFIDEBUG
   config CMD_EFICONFIG
bool "eficonfig - provide menu-driven uefi variables maintenance 
interface"
default y if !HAS_BOARD_SIZE_LIMIT
-   depends on CMD_BOOTEFI_BOOTMGR
+   depends on BOOTEFI_BOOTMGR
select MENU
help
  Enable the 'eficonfig' command which provides the menu-driven UEFI
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index d20aaab6dba4..13cad6342c36 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -32,14 +32,14 @@ config EFI_LOADER
   if EFI_LOADER
-config CMD_BOOTEFI_BOOTMGR
+config BOOTEFI_BOOTMGR
bool "UEFI Boot Manager"
default y
select BOOTMETH_GLOBAL if BOOTSTD
help
  Select this option if you want to select the UEFI binary to be booted
- via UEFI variables Boot, BootOrder, and BootNext. This enables the
- 'bootefi bootmgr' command.
+ via UEFI variables Boot, BootOrder, and BootNext. You should also
+ normally enable CMD_BOOTEFI_BOOTMGR so that the command is available.
   choice
prompt "Store for non-volatile UEFI variables"
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index 8d31fc61c601..0a2cb6e3c476 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -42,7 +42,7 @@ targets += initrddump.o
   endif
   obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
-obj-$(CONFIG_CMD_BOOTEFI_BOOTMGR) += efi_bootmgr.o
+obj-$(CONFIG_BOOTEFI_BOOTMGR) += efi_bootmgr.o
   obj-y += efi_boottime.o
   obj-y += efi_helper.o
   obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += efi_capsule.o


This patch looks wrong.

Symbol CONFIG_CMD_BOOTEFI_BOOTMGR is used in a lot of places where it is not
related to the 'bootefi bootmgr' subcommand.

I see no benefit in two separate symbols. If you want to rename the symbol,
please, replace *all* occurrences:

%s/CONFIG_CMD_BOOTEFI_BOOTMGR/CONFIG_BOOTEFI_BOOTMGR/


Yes, there's work on the EFI_LOADER side of things to support the use
case of "boot to menu" (or, "boot to efi bootmgr") of which this is the
starting point. The follow-up work that I'm hoping you or someone else
with more EFI_LOADER experience will pick up is splitting cmd/bootefi.c
such that we can call in to starting an EFI payload (or bootmgr) without
the command line.



Even after factoring out the boot functionality I would not know why we 
should have two separate symbols. I am fine with a rename which makes it 
clear that this symbol is about a library functionality.


Best regards

Heinrich


Re: [v4 11/24] efi: Rearrange the Kconfig for CMD_BOOTEFI_BOOTMGR

2023-10-19 Thread Tom Rini
On Thu, Oct 19, 2023 at 05:16:28PM +0200, Heinrich Schuchardt wrote:
> On 19.10.23 17:00, Tom Rini wrote:
> > From: Simon Glass 
> > 
> > The command should not be used to enable library functionality. Add a
> > new BOOTEFI_BOOTMGR Kconfig for that. Adjust the conditions so that the
> > same code is built.
> > 
> > Signed-off-by: Simon Glass 
> > Suggested-by: AKASHI Takahiro 
> > ---
> > Cc: Heinrich Schuchardt 
> > Cc: Ilias Apalodimas 
> > Changes in v4:
> > - Integrate AKASHI Takahiro's feedback from v3
> > - Reword the help text on CMD_BOOTEFI_BOOTMGR slightly
> > ---
> >   cmd/Kconfig | 11 ++-
> >   lib/efi_loader/Kconfig  |  6 +++---
> >   lib/efi_loader/Makefile |  2 +-
> >   3 files changed, 14 insertions(+), 5 deletions(-)
> > 
> > diff --git a/cmd/Kconfig b/cmd/Kconfig
> > index 16e5cb8f0633..872cb49150cc 100644
> > --- a/cmd/Kconfig
> > +++ b/cmd/Kconfig
> > @@ -379,6 +379,15 @@ config CMD_BOOTEFI
> > help
> >   Boot an EFI image from memory.
> > +config CMD_BOOTEFI_BOOTMGR
> > +   bool "UEFI Boot Manager command"
> > +   depends on BOOTEFI_BOOTMGR && CMD_BOOTEFI
> > +   default y
> > +   help
> > + Select this option to enable the 'bootmgr' subcommand of 'bootefi'.
> > + This subcommand will allow you to select the UEFI binary to be booted
> > + via UEFI variables Boot, BootOrder, and BootNext.
> > +
> >   config CMD_BOOTEFI_HELLO_COMPILE
> > bool "Compile a standard EFI hello world binary for testing"
> > depends on CMD_BOOTEFI && !CPU_V7M
> > @@ -2110,7 +2119,7 @@ config CMD_EFIDEBUG
> >   config CMD_EFICONFIG
> > bool "eficonfig - provide menu-driven uefi variables maintenance 
> > interface"
> > default y if !HAS_BOARD_SIZE_LIMIT
> > -   depends on CMD_BOOTEFI_BOOTMGR
> > +   depends on BOOTEFI_BOOTMGR
> > select MENU
> > help
> >   Enable the 'eficonfig' command which provides the menu-driven UEFI
> > diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> > index d20aaab6dba4..13cad6342c36 100644
> > --- a/lib/efi_loader/Kconfig
> > +++ b/lib/efi_loader/Kconfig
> > @@ -32,14 +32,14 @@ config EFI_LOADER
> >   if EFI_LOADER
> > -config CMD_BOOTEFI_BOOTMGR
> > +config BOOTEFI_BOOTMGR
> > bool "UEFI Boot Manager"
> > default y
> > select BOOTMETH_GLOBAL if BOOTSTD
> > help
> >   Select this option if you want to select the UEFI binary to be booted
> > - via UEFI variables Boot, BootOrder, and BootNext. This enables the
> > - 'bootefi bootmgr' command.
> > + via UEFI variables Boot, BootOrder, and BootNext. You should also
> > + normally enable CMD_BOOTEFI_BOOTMGR so that the command is available.
> >   choice
> > prompt "Store for non-volatile UEFI variables"
> > diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
> > index 8d31fc61c601..0a2cb6e3c476 100644
> > --- a/lib/efi_loader/Makefile
> > +++ b/lib/efi_loader/Makefile
> > @@ -42,7 +42,7 @@ targets += initrddump.o
> >   endif
> >   obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
> > -obj-$(CONFIG_CMD_BOOTEFI_BOOTMGR) += efi_bootmgr.o
> > +obj-$(CONFIG_BOOTEFI_BOOTMGR) += efi_bootmgr.o
> >   obj-y += efi_boottime.o
> >   obj-y += efi_helper.o
> >   obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += efi_capsule.o
> 
> This patch looks wrong.
> 
> Symbol CONFIG_CMD_BOOTEFI_BOOTMGR is used in a lot of places where it is not
> related to the 'bootefi bootmgr' subcommand.
> 
> I see no benefit in two separate symbols. If you want to rename the symbol,
> please, replace *all* occurrences:
> 
> %s/CONFIG_CMD_BOOTEFI_BOOTMGR/CONFIG_BOOTEFI_BOOTMGR/

Yes, there's work on the EFI_LOADER side of things to support the use
case of "boot to menu" (or, "boot to efi bootmgr") of which this is the
starting point. The follow-up work that I'm hoping you or someone else
with more EFI_LOADER experience will pick up is splitting cmd/bootefi.c
such that we can call in to starting an EFI payload (or bootmgr) without
the command line.

-- 
Tom


signature.asc
Description: PGP signature


Re: [v4 11/24] efi: Rearrange the Kconfig for CMD_BOOTEFI_BOOTMGR

2023-10-19 Thread Heinrich Schuchardt

On 19.10.23 17:00, Tom Rini wrote:

From: Simon Glass 

The command should not be used to enable library functionality. Add a
new BOOTEFI_BOOTMGR Kconfig for that. Adjust the conditions so that the
same code is built.

Signed-off-by: Simon Glass 
Suggested-by: AKASHI Takahiro 
---
Cc: Heinrich Schuchardt 
Cc: Ilias Apalodimas 
Changes in v4:
- Integrate AKASHI Takahiro's feedback from v3
- Reword the help text on CMD_BOOTEFI_BOOTMGR slightly
---
  cmd/Kconfig | 11 ++-
  lib/efi_loader/Kconfig  |  6 +++---
  lib/efi_loader/Makefile |  2 +-
  3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 16e5cb8f0633..872cb49150cc 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -379,6 +379,15 @@ config CMD_BOOTEFI
help
  Boot an EFI image from memory.
  
+config CMD_BOOTEFI_BOOTMGR

+   bool "UEFI Boot Manager command"
+   depends on BOOTEFI_BOOTMGR && CMD_BOOTEFI
+   default y
+   help
+ Select this option to enable the 'bootmgr' subcommand of 'bootefi'.
+ This subcommand will allow you to select the UEFI binary to be booted
+ via UEFI variables Boot, BootOrder, and BootNext.
+
  config CMD_BOOTEFI_HELLO_COMPILE
bool "Compile a standard EFI hello world binary for testing"
depends on CMD_BOOTEFI && !CPU_V7M
@@ -2110,7 +2119,7 @@ config CMD_EFIDEBUG
  config CMD_EFICONFIG
bool "eficonfig - provide menu-driven uefi variables maintenance 
interface"
default y if !HAS_BOARD_SIZE_LIMIT
-   depends on CMD_BOOTEFI_BOOTMGR
+   depends on BOOTEFI_BOOTMGR
select MENU
help
  Enable the 'eficonfig' command which provides the menu-driven UEFI
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index d20aaab6dba4..13cad6342c36 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -32,14 +32,14 @@ config EFI_LOADER
  
  if EFI_LOADER
  
-config CMD_BOOTEFI_BOOTMGR

+config BOOTEFI_BOOTMGR
bool "UEFI Boot Manager"
default y
select BOOTMETH_GLOBAL if BOOTSTD
help
  Select this option if you want to select the UEFI binary to be booted
- via UEFI variables Boot, BootOrder, and BootNext. This enables the
- 'bootefi bootmgr' command.
+ via UEFI variables Boot, BootOrder, and BootNext. You should also
+ normally enable CMD_BOOTEFI_BOOTMGR so that the command is available.
  
  choice

prompt "Store for non-volatile UEFI variables"
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index 8d31fc61c601..0a2cb6e3c476 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -42,7 +42,7 @@ targets += initrddump.o
  endif
  
  obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o

-obj-$(CONFIG_CMD_BOOTEFI_BOOTMGR) += efi_bootmgr.o
+obj-$(CONFIG_BOOTEFI_BOOTMGR) += efi_bootmgr.o
  obj-y += efi_boottime.o
  obj-y += efi_helper.o
  obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += efi_capsule.o


This patch looks wrong.

Symbol CONFIG_CMD_BOOTEFI_BOOTMGR is used in a lot of places where it is 
not related to the 'bootefi bootmgr' subcommand.


I see no benefit in two separate symbols. If you want to rename the 
symbol, please, replace *all* occurrences:


%s/CONFIG_CMD_BOOTEFI_BOOTMGR/CONFIG_BOOTEFI_BOOTMGR/

Best regards

Heinrich


[PATCH] common: Reword CONSOLE_RECORD_.*SIZE help texts

2023-10-19 Thread Tom Rini
Make it clear that in the options for setting the console record buffer
sizes that we are talking about buffers for that feature specifically
and not the general console buffers.

Signed-off-by: Tom Rini 
---
 common/Kconfig | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 93c96f23b013..2d6d412f5e33 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -28,26 +28,26 @@ config CONSOLE_RECORD_OUT_SIZE
depends on CONSOLE_RECORD
default 0x400 if CONSOLE_RECORD
help
- Set the size of the console output buffer. When this fills up, no
- more data will be recorded until some is removed. The buffer is
- allocated immediately after the malloc() region is ready.
+ Set the size of the console recording output buffer. When this fills
+ up, no more data will be recorded until some is removed. The buffer
+ is allocated immediately after the malloc() region is ready.
 
 config CONSOLE_RECORD_OUT_SIZE_F
hex "Output buffer size before relocation"
depends on CONSOLE_RECORD
default 0x400 if CONSOLE_RECORD
help
- Set the size of the console output buffer before relocation. When
- this fills up, no more data will be recorded until some is removed.
- The buffer is allocated immediately after the early malloc() region is
- ready.
+ Set the size of the console recording output buffer before
+ relocation. When this fills up, no more data will be recorded until
+ some is removed.  The buffer is allocated immediately after the early
+ malloc() region is ready.
 
 config CONSOLE_RECORD_IN_SIZE
hex "Input buffer size"
depends on CONSOLE_RECORD
default 0x100 if CONSOLE_RECORD
help
- Set the size of the console input buffer. When this contains data,
+ Set the size of the console recording input buffer. When this 
contains data,
  tstc() and getc() will use this in preference to real device input.
  The buffer is allocated immediately after the malloc() region is
  ready.
-- 
2.34.1



[v4 24/24] clk_k210.c: Clean up how we handle nop

2023-10-19 Thread Tom Rini
Now that sandbox has  and defines nop() there we should
include that in our driver for clarity and then remove our local nop()
from .

Signed-off-by: Tom Rini 
---
I can see that our ARM  should be  and
updated in a few other ways to match how the kernel is currently.  This
is not a big deal yet as this driver is only for sandbox for risc-v

Cc: Sean Anderson 
---
 drivers/clk/clk_k210.c | 1 +
 include/k210/pll.h | 3 ---
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/clk/clk_k210.c b/drivers/clk/clk_k210.c
index c534cc07e092..b9469b93853b 100644
--- a/drivers/clk/clk_k210.c
+++ b/drivers/clk/clk_k210.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/include/k210/pll.h b/include/k210/pll.h
index fd16a89cb203..175c47f6f233 100644
--- a/include/k210/pll.h
+++ b/include/k210/pll.h
@@ -16,9 +16,6 @@ struct k210_pll_config {
 #ifdef CONFIG_UNIT_TEST
 TEST_STATIC int k210_pll_calc_config(u32 rate, u32 rate_in,
 struct k210_pll_config *best);
-#ifndef nop
-#define nop()
-#endif
 
 #endif
 #endif /* K210_PLL_H */
-- 
2.34.1



[v4 23/24] sandbox: Add

2023-10-19 Thread Tom Rini
Add a mostly empty asm/barrier.h file for sandbox where we define nop() to
be an empty function.

Signed-off-by: Tom Rini 
---
 arch/sandbox/include/asm/barrier.h | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 arch/sandbox/include/asm/barrier.h

diff --git a/arch/sandbox/include/asm/barrier.h 
b/arch/sandbox/include/asm/barrier.h
new file mode 100644
index ..0928a78cbf8b
--- /dev/null
+++ b/arch/sandbox/include/asm/barrier.h
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#define nop()
-- 
2.34.1



[v4 22/24] sandbox: Avoid requiring CMDLINE

2023-10-19 Thread Tom Rini
From: Simon Glass 

Add some dependencies on features that we had been selecting so that we
can still disable CMDLINE.

Signed-off-by: Simon Glass 
Signed-off-by: Tom Rini 
---
Changes in v4:
- Reword the commit slightly (Tom)
- Rework overall to select if CMDLINE

Changes in v3:
- Reorder the Kconfig options a little
---
 arch/Kconfig | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index edfa3f7f83aa..78727050aecd 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -134,7 +134,7 @@ config SANDBOX
select ARCH_SUPPORTS_LTO
select BOARD_LATE_INIT
select BZIP2
-   select CMD_POWEROFF
+   select CMD_POWEROFF if CMDLINE
select DM
select DM_EVENT
select DM_FUZZING_ENGINE
@@ -152,10 +152,10 @@ config SANDBOX
select PCI_ENDPOINT
select SPI
select SUPPORT_OF_CONTROL
-   select SYSRESET_CMD_POWEROFF
+   select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
select SYS_CACHE_SHIFT_4
select IRQ
-   select SUPPORT_EXTENSION_SCAN
+   select SUPPORT_EXTENSION_SCAN if CMDLINE
select SUPPORT_ACPI
imply BITREVERSE
select BLOBLIST
-- 
2.34.1



[v4 21/24] sandbox: Disable CONFIG_DISTRO_DEFAULTS

2023-10-19 Thread Tom Rini
From: Simon Glass 

This is not used for sandbox, so drop it. Enable the things that it
controls to avoid dstrastic changes in the config settings for
sandbox builds.

The end result is that these are enabled:

   BOOTMETH_DISTRO
   BOOTSTD_DEFAULTS

and these are disabled:

   USE_BOOTCOMMAND
   BOOTCOMMAND (was "run distro_bootcmd")
   DISTRO_DEFAULTS

Note that the tools-only build has already disabled DISTRO_DEFAULTS
and BOOTSTD_FULL

Signed-off-by: Simon Glass 
Signed-off-by: Tom Rini 
---
Changes in v4:
- Only modify sandbox and restrict the changes to only DISTRO_DEFAULTS
---
 arch/Kconfig   | 3 +++
 configs/sandbox64_defconfig| 1 -
 configs/sandbox_defconfig  | 1 -
 configs/sandbox_flattree_defconfig | 1 -
 configs/sandbox_noinst_defconfig   | 1 -
 configs/sandbox_spl_defconfig  | 1 -
 configs/sandbox_vpl_defconfig  | 1 -
 7 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 19f2891ba1c5..edfa3f7f83aa 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -208,6 +208,9 @@ config SANDBOX
imply PHYSMEM
imply GENERATE_ACPI_TABLE
imply BINMAN
+   imply BOOTSTD_DEFAULTS if BOOTSTD_FULL && CMDLINE
+   imply BOOTMETH_DISTRO if BOOTSTD_FULL && CMDLINE
+   imply CMD_SYSBOOT if BOOTSTD_FULL
 
 config SH
bool "SuperH architecture"
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index 1a033b22018b..ff895b930170 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -14,7 +14,6 @@ CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_LEGACY_IMAGE_FORMAT=y
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 47417cb0391d..5230b81be2c4 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -14,7 +14,6 @@ CONFIG_FIT_RSASSA_PSS=y
 CONFIG_FIT_CIPHER=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_LEGACY_IMAGE_FORMAT=y
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
diff --git a/configs/sandbox_flattree_defconfig 
b/configs/sandbox_flattree_defconfig
index 29ae4532c508..8df2a82c521c 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -12,7 +12,6 @@ CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_LEGACY_IMAGE_FORMAT=y
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
diff --git a/configs/sandbox_noinst_defconfig b/configs/sandbox_noinst_defconfig
index db05e6308329..44e55f4452f3 100644
--- a/configs/sandbox_noinst_defconfig
+++ b/configs/sandbox_noinst_defconfig
@@ -25,7 +25,6 @@ CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_LOAD_FIT=y
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index 56072b15ad2d..015e0a59d085 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -20,7 +20,6 @@ CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_LOAD_FIT=y
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
diff --git a/configs/sandbox_vpl_defconfig b/configs/sandbox_vpl_defconfig
index 5bd0281796d4..9935575352b2 100644
--- a/configs/sandbox_vpl_defconfig
+++ b/configs/sandbox_vpl_defconfig
@@ -27,7 +27,6 @@ CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_FIT_BEST_MATCH=y
 CONFIG_SPL_LOAD_FIT=y
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
-- 
2.34.1



[v4 20/24] cmd: Make most commands depend on CMDLINE

2023-10-19 Thread Tom Rini
From: Simon Glass 

If we disable CMDLINE then we should not ask about enabling the hush
parser nor any of the commands that would be run on the command line as
it is no longer available. Convert the CMDLINE option into a menuconfig
and make every command referenced under cmd/Kconfig depend on it.

This leaves as future work moving the commands that are not under the
cmd/ hierarchy as future work.

Signed-off-by: Simon Glass 
Signed-off-by: Tom Rini 
---
Changes in v4:
- Reword the commit message slightly.
- Make this not depend on other patches
---
 Makefile|  2 +-
 cmd/Kconfig | 20 
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile
index e0040a40d330..969f3f74a74d 100644
--- a/Makefile
+++ b/Makefile
@@ -851,7 +851,7 @@ HAVE_VENDOR_COMMON_LIB = $(if $(wildcard 
$(srctree)/board/$(VENDOR)/common/Makef
 libs-$(CONFIG_API) += api/
 libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
 libs-y += boot/
-libs-y += cmd/
+libs-$(CONFIG_CMDLINE) += cmd/
 libs-y += common/
 libs-$(CONFIG_OF_EMBED) += dts/
 libs-y += env/
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 099ec444ae99..91297cb53f9a 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1,7 +1,5 @@
-menu "Command line interface"
-
-config CMDLINE
-   bool "Support U-Boot commands"
+menuconfig CMDLINE
+   bool "Command line interface"
default y
help
  Enable U-Boot's command-line functions. This provides a means
@@ -11,9 +9,10 @@ config CMDLINE
  Depending on the number of commands enabled, this can add
  substantially to the size of U-Boot.
 
+if CMDLINE
+
 config HUSH_PARSER
bool "Use hush shell"
-   depends on CMDLINE
help
  This option enables the "hush" shell (from Busybox) as command line
  interpreter, thus enabling powerful command line syntax like
@@ -25,7 +24,6 @@ config HUSH_PARSER
 
 config CMDLINE_EDITING
bool "Enable command line editing"
-   depends on CMDLINE
default y
help
  Enable editing and History functions for interactive command line
@@ -40,15 +38,13 @@ config CMDLINE_PS_SUPPORT
 
 config AUTO_COMPLETE
bool "Enable auto complete using TAB"
-   depends on CMDLINE
default y
help
  Enable auto completion of commands using TAB.
 
 config SYS_LONGHELP
bool "Enable long help messages"
-   depends on CMDLINE
-   default y if CMDLINE
+   default y
help
  Defined when you want long help messages included
  Do not set this option when short of memory.
@@ -77,8 +73,7 @@ config SYS_MAXARGS
 
 config SYS_XTRACE
bool "Command execution tracer"
-   depends on CMDLINE
-   default y if CMDLINE
+   default y
help
  This option enables the possiblity to print all commands before
  executing them and after all variables are evaluated (similar
@@ -2872,4 +2867,5 @@ config CMD_MESON
default y
help
  Enable useful commands for the Meson Soc family developed by Amlogic 
Inc.
-endmenu
+
+endif
-- 
2.34.1



[v4 19/24] boot: Make preboot and bootcmd require CMDLINE

2023-10-19 Thread Tom Rini
In order for a predefined "preboot" or "bootcmd" to be executed by the
running system we must have a command line.  Add CMDLINE as a
dependency.

Signed-off-by: Tom Rini 
---
 boot/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/boot/Kconfig b/boot/Kconfig
index 40a04f43ee3d..fabf6fec2195 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -1558,6 +1558,7 @@ config BOOTARGS_SUBST
 
 config USE_BOOTCOMMAND
bool "Enable a default value for bootcmd"
+   depends on CMDLINE
help
  Provide a default value for the bootcmd entry in the environment.  If
  autoboot is enabled this is what will be run automatically.  Enable
@@ -1577,6 +1578,7 @@ config BOOTCOMMAND
 
 config USE_PREBOOT
bool "Enable preboot"
+   depends on CMDLINE
help
  When this option is enabled, the existence of the environment
  variable "preboot" will be checked immediately before starting the
-- 
2.34.1



[v4 18/24] bootmeth_script: Depend on CMDLINE

2023-10-19 Thread Tom Rini
As this particular bootmeth requires the command line and assorted
commands to function, make sure we have CMDLINE enabled.

Signed-off-by: Tom Rini 
---
 boot/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 7c92e0974c5f..40a04f43ee3d 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -543,7 +543,7 @@ config BOOTMETH_VBE
 
 config BOOTMETH_DISTRO
bool  # Options needed to boot any distro
-   select BOOTMETH_SCRIPT  # E.g. Armbian uses scripts
+   select BOOTMETH_SCRIPT if CMDLINE # E.g. Armbian uses scripts
select BOOTMETH_EXTLINUX  # E.g. Debian uses these
select BOOTMETH_EXTLINUX_PXE if CMD_PXE && CMD_NET && DM_ETH
select BOOTMETH_EFILOADER if CMD_BOOTEFI # E.g. Ubuntu uses this
@@ -671,6 +671,7 @@ config BOOTMETH_SANDBOX
 config BOOTMETH_SCRIPT
bool "Bootdev support for U-Boot scripts"
default y if BOOTSTD_FULL
+   depends on CMDLINE
select HUSH_PARSER
help
  Enables support for booting a distro via a U-Boot script. This makes
-- 
2.34.1



[v4 17/24] bootmeth_cros: Require bootm.o and bootm_os.o

2023-10-19 Thread Tom Rini
In order to use bootmeth_cros, at least on non-X86, we need to be able
to start any type of kernel that the "bootm" code paths can handle.  Add
these objects to the required list for this option.

Signed-off-by: Tom Rini 
---
Cc: Simon Glass 
---
 boot/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/boot/Makefile b/boot/Makefile
index ad608598d298..3fd048bb41ab 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -28,7 +28,7 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EXTLINUX) += bootmeth_extlinux.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EXTLINUX_PXE) += bootmeth_pxe.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFILOADER) += bootmeth_efi.o
-obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_CROS) += bootmeth_cros.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_CROS) += bootm.o bootm_os.o bootmeth_cros.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SANDBOX) += bootmeth_sandbox.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SCRIPT) += bootmeth_script.o
 ifdef CONFIG_$(SPL_TPL_)BOOTSTD_FULL
-- 
2.34.1



[v4 15/24] boot: Rework BOOT_DEFAULTS to allow for CMDLINE to be disabled

2023-10-19 Thread Tom Rini
We split BOOT_DEFAULTS to have BOOT_DEFAULTS_FEATURES and
BOOT_DEFAULTS_CMDS that in turn list general features or commands that
we want enabled when BOOT_DEFAULTS is selected.  We only select
BOOT_DEFAULTS_CMDS if CMDLINE is set.

Signed-off-by: Tom Rini 
---
 boot/Kconfig | 23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 2075ecd34b1f..88b9296ee1bf 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -346,8 +346,16 @@ config PXE_UTILS
help
  Utilities for parsing PXE file formats.
 
-config BOOT_DEFAULTS
-   bool  # Common defaults for standard boot and distroboot
+config BOOT_DEFAULTS_FEATURES
+   bool
+   select SUPPORT_RAW_INITRD
+   select ENV_VARS_UBOOT_CONFIG
+   imply USB_STORAGE
+   imply EFI_PARTITION
+   imply ISO_PARTITION
+
+config BOOT_DEFAULTS_CMDS
+   bool
imply USE_BOOTCOMMAND
select CMD_ENV_EXISTS
select CMD_EXT2
@@ -358,14 +366,14 @@ config BOOT_DEFAULTS
select CMD_DHCP if CMD_NET
select CMD_PING if CMD_NET
select CMD_PXE if CMD_NET
-   select SUPPORT_RAW_INITRD
-   select ENV_VARS_UBOOT_CONFIG
select CMD_BOOTI if ARM64
select CMD_BOOTZ if ARM && !ARM64
imply CMD_MII if NET
-   imply USB_STORAGE
-   imply EFI_PARTITION
-   imply ISO_PARTITION
+
+config BOOT_DEFAULTS
+   bool  # Common defaults for standard boot and distroboot
+   select BOOT_DEFAULTS_FEATURES
+   select BOOT_DEFAULTS_CMDS if CMDLINE
help
  These are not required but are commonly needed to support a good
  selection of booting methods. Enable this to improve the capability
@@ -431,7 +439,6 @@ config BOOTSTD_FULL
 config BOOTSTD_DEFAULTS
bool "Select some common defaults for standard boot"
depends on BOOTSTD
-   imply USE_BOOTCOMMAND
select BOOT_DEFAULTS
select BOOTMETH_DISTRO
help
-- 
2.34.1



[v4 14/24] boot: Make DISTRO_DEFAULTS select CMDLINE

2023-10-19 Thread Tom Rini
The implementation of DISTRO_DEFAULTS is done in environment scripts and
requires the command line in order to work. Because of this, select
CMDLINE here.

Signed-off-by: Tom Rini 
---
 boot/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/boot/Kconfig b/boot/Kconfig
index 0dbd10a93469..2075ecd34b1f 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -777,6 +777,7 @@ endmenu # Boot images
 
 config DISTRO_DEFAULTS
bool "(deprecated) Script-based booting of Linux distributions"
+   select CMDLINE
select BOOT_DEFAULTS
select AUTO_COMPLETE
select CMDLINE_EDITING
-- 
2.34.1



[v4 16/24] boot: Move SYS_BOOTM_LEN to be by LEGACY_IMAGE_FORMAT

2023-10-19 Thread Tom Rini
This particular option is required for booting all image types,
regardless of if we are starting an OS via command line or something
else.  Move the question for SYS_BOOTM_LEN to be by the question for
LEGACY_IMAGE_FORMAT, as that's where our generic OS questions start.

Signed-off-by: Tom Rini 
---
 boot/Kconfig | 11 +++
 cmd/Kconfig  | 11 ---
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 88b9296ee1bf..7c92e0974c5f 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -692,6 +692,17 @@ config LEGACY_IMAGE_FORMAT
  loaded. If a board needs the legacy image format support in this
  case, enable it here.
 
+config SYS_BOOTM_LEN
+   hex "Maximum size of a decompresed OS image"
+   depends on CMD_BOOTM || CMD_BOOTI || CMD_BOOTZ || \
+   LEGACY_IMAGE_FORMAT || SPL_LEGACY_IMAGE_FORMAT
+   default 0x400 if PPC || ARM64
+   default 0x100 if X86 || ARCH_MX6 || ARCH_MX7
+   default 0x80
+   help
+ This is the maximum size of the buffer that is used to decompress the 
OS
+ image in to if attempting to boot a compressed image.
+
 config SUPPORT_RAW_INITRD
bool "Enable raw initrd images"
help
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 872cb49150cc..099ec444ae99 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -361,17 +361,6 @@ config BOOTM_VXWORKS
help
  Support booting VxWorks images via the bootm command.
 
-config SYS_BOOTM_LEN
-   hex "Maximum size of a decompresed OS image"
-   depends on CMD_BOOTM || CMD_BOOTI || CMD_BOOTZ || \
-  LEGACY_IMAGE_FORMAT || SPL_LEGACY_IMAGE_FORMAT
-   default 0x400 if PPC || ARM64
-   default 0x100 if X86 || ARCH_MX6 || ARCH_MX7
-   default 0x80
-   help
- This is the maximum size of the buffer that is used to decompress the 
OS
- image in to, if passing a compressed image to bootm/booti/bootz.
-
 config CMD_BOOTEFI
bool "bootefi"
depends on EFI_LOADER
-- 
2.34.1



[v4 11/24] efi: Rearrange the Kconfig for CMD_BOOTEFI_BOOTMGR

2023-10-19 Thread Tom Rini
From: Simon Glass 

The command should not be used to enable library functionality. Add a
new BOOTEFI_BOOTMGR Kconfig for that. Adjust the conditions so that the
same code is built.

Signed-off-by: Simon Glass 
Suggested-by: AKASHI Takahiro 
---
Cc: Heinrich Schuchardt 
Cc: Ilias Apalodimas 
Changes in v4:
- Integrate AKASHI Takahiro's feedback from v3
- Reword the help text on CMD_BOOTEFI_BOOTMGR slightly
---
 cmd/Kconfig | 11 ++-
 lib/efi_loader/Kconfig  |  6 +++---
 lib/efi_loader/Makefile |  2 +-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 16e5cb8f0633..872cb49150cc 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -379,6 +379,15 @@ config CMD_BOOTEFI
help
  Boot an EFI image from memory.
 
+config CMD_BOOTEFI_BOOTMGR
+   bool "UEFI Boot Manager command"
+   depends on BOOTEFI_BOOTMGR && CMD_BOOTEFI
+   default y
+   help
+ Select this option to enable the 'bootmgr' subcommand of 'bootefi'.
+ This subcommand will allow you to select the UEFI binary to be booted
+ via UEFI variables Boot, BootOrder, and BootNext.
+
 config CMD_BOOTEFI_HELLO_COMPILE
bool "Compile a standard EFI hello world binary for testing"
depends on CMD_BOOTEFI && !CPU_V7M
@@ -2110,7 +2119,7 @@ config CMD_EFIDEBUG
 config CMD_EFICONFIG
bool "eficonfig - provide menu-driven uefi variables maintenance 
interface"
default y if !HAS_BOARD_SIZE_LIMIT
-   depends on CMD_BOOTEFI_BOOTMGR
+   depends on BOOTEFI_BOOTMGR
select MENU
help
  Enable the 'eficonfig' command which provides the menu-driven UEFI
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index d20aaab6dba4..13cad6342c36 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -32,14 +32,14 @@ config EFI_LOADER
 
 if EFI_LOADER
 
-config CMD_BOOTEFI_BOOTMGR
+config BOOTEFI_BOOTMGR
bool "UEFI Boot Manager"
default y
select BOOTMETH_GLOBAL if BOOTSTD
help
  Select this option if you want to select the UEFI binary to be booted
- via UEFI variables Boot, BootOrder, and BootNext. This enables the
- 'bootefi bootmgr' command.
+ via UEFI variables Boot, BootOrder, and BootNext. You should also
+ normally enable CMD_BOOTEFI_BOOTMGR so that the command is available.
 
 choice
prompt "Store for non-volatile UEFI variables"
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index 8d31fc61c601..0a2cb6e3c476 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -42,7 +42,7 @@ targets += initrddump.o
 endif
 
 obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
-obj-$(CONFIG_CMD_BOOTEFI_BOOTMGR) += efi_bootmgr.o
+obj-$(CONFIG_BOOTEFI_BOOTMGR) += efi_bootmgr.o
 obj-y += efi_boottime.o
 obj-y += efi_helper.o
 obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += efi_capsule.o
-- 
2.34.1



[v4 13/24] autoboot: Correct dependencies on CMDLINE

2023-10-19 Thread Tom Rini
From: Simon Glass 

Make AUTOBOOT depend on CMDLINE since it is mostly meaningless without it.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---
 boot/Kconfig | 29 +++--
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index e0ded3249343..0dbd10a93469 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -1162,14 +1162,16 @@ menu "Autoboot options"
 
 config AUTOBOOT
bool "Autoboot"
+   depends on CMDLINE
default y
help
  This enables the autoboot.  See doc/README.autoboot for detail.
 
+if AUTOBOOT
+
 config BOOTDELAY
int "delay in seconds before automatically booting"
default 2
-   depends on AUTOBOOT
help
  Delay before automatically running bootcmd;
  set to 0 to autoboot with no delay, but you can stop it by key input.
@@ -1191,9 +1193,11 @@ config AUTOBOOT_KEYED
  U-Boot automatic booting process and bring the device
  to the U-Boot prompt for user input.
 
+if AUTOBOOT_KEYED
+
 config AUTOBOOT_FLUSH_STDIN
bool "Enable flushing stdin before starting to read the password"
-   depends on AUTOBOOT_KEYED && !SANDBOX
+   depends on !SANDBOX
help
  When this option is enabled stdin buffer will be flushed before
  starting to read the password.
@@ -1202,7 +1206,6 @@ config AUTOBOOT_FLUSH_STDIN
 
 config AUTOBOOT_PROMPT
string "Autoboot stop prompt"
-   depends on AUTOBOOT_KEYED
default "Autoboot in %d seconds\\n"
help
  This string is displayed before the boot delay selected by
@@ -1218,7 +1221,6 @@ config AUTOBOOT_PROMPT
 
 config AUTOBOOT_ENCRYPTION
bool "Enable encryption in autoboot stopping"
-   depends on AUTOBOOT_KEYED
help
  This option allows a string to be entered into U-Boot to stop the
  autoboot.
@@ -1245,7 +1247,7 @@ config AUTOBOOT_SHA256_FALLBACK
 
 config AUTOBOOT_DELAY_STR
string "Delay autobooting via specific input key / string"
-   depends on AUTOBOOT_KEYED && !AUTOBOOT_ENCRYPTION
+   depends on !AUTOBOOT_ENCRYPTION
help
  This option delays the automatic boot feature by issuing
  a specific input key or string. If CONFIG_AUTOBOOT_DELAY_STR
@@ -1257,7 +1259,7 @@ config AUTOBOOT_DELAY_STR
 
 config AUTOBOOT_STOP_STR
string "Stop autobooting via specific input key / string"
-   depends on AUTOBOOT_KEYED && !AUTOBOOT_ENCRYPTION
+   depends on !AUTOBOOT_ENCRYPTION
help
  This option enables stopping (aborting) of the automatic
  boot feature only by issuing a specific input key or
@@ -1269,7 +1271,7 @@ config AUTOBOOT_STOP_STR
 
 config AUTOBOOT_KEYED_CTRLC
bool "Enable Ctrl-C autoboot interruption"
-   depends on AUTOBOOT_KEYED && !AUTOBOOT_ENCRYPTION
+   depends on !AUTOBOOT_ENCRYPTION
help
  This option allows for the boot sequence to be interrupted
  by ctrl-c, in addition to the "bootdelaykey" and "bootstopkey".
@@ -1278,7 +1280,7 @@ config AUTOBOOT_KEYED_CTRLC
 
 config AUTOBOOT_NEVER_TIMEOUT
bool "Make the password entry never time-out"
-   depends on AUTOBOOT_KEYED && AUTOBOOT_ENCRYPTION && CRYPT_PW
+   depends on AUTOBOOT_ENCRYPTION && CRYPT_PW
help
  This option removes the timeout from the password entry
  when the user first presses the  key before entering
@@ -1286,7 +1288,7 @@ config AUTOBOOT_NEVER_TIMEOUT
 
 config AUTOBOOT_STOP_STR_ENABLE
bool "Enable fixed string to stop autobooting"
-   depends on AUTOBOOT_KEYED && AUTOBOOT_ENCRYPTION
+   depends on AUTOBOOT_ENCRYPTION
help
  This option enables the feature to add a fixed stop
  string that is defined at compile time.
@@ -1317,9 +1319,12 @@ config AUTOBOOT_STOP_STR_SHA256
  includes a ":", the portion prior to the ":" will be treated
  as a salt value.
 
+endif  # AUTOBOOT_KEYED
+
+if !AUTOBOOT_KEYED
+
 config AUTOBOOT_USE_MENUKEY
bool "Allow a specify key to run a menu from the environment"
-   depends on !AUTOBOOT_KEYED
help
  If a specific key is pressed to stop autoboot, then the commands in
  the environment variable 'menucmd' are executed before boot starts.
@@ -1334,6 +1339,10 @@ config AUTOBOOT_MENUKEY
  For example, 33 means "!" in ASCII, so pressing ! at boot would take
  this action.
 
+endif
+
+endif  # AUTOBOOT
+
 config AUTOBOOT_MENU_SHOW
bool "Show a menu on boot"
depends on CMD_BOOTMENU
-- 
2.34.1



[v4 12/24] bootmeth: Make BOOTMETH_EFILOADER depend on CMD_BOOTEFI

2023-10-19 Thread Tom Rini
Today, the bootmeth for using the EFI loader via bootefi depends on
calling the bootefi command directly, so make this in turn depend on
CMD_BOOTEFI.

Signed-off-by: Tom Rini 
---
 boot/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index a01e6cb8aafe..e0ded3249343 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -504,7 +504,7 @@ config BOOTMETH_EXTLINUX_PXE
 
 config BOOTMETH_EFILOADER
bool "Bootdev support for EFI boot"
-   depends on EFI_LOADER
+   depends on CMD_BOOTEFI
default y
help
  Enables support for EFI boot using bootdevs. This makes the
@@ -539,7 +539,7 @@ config BOOTMETH_DISTRO
select BOOTMETH_SCRIPT  # E.g. Armbian uses scripts
select BOOTMETH_EXTLINUX  # E.g. Debian uses these
select BOOTMETH_EXTLINUX_PXE if CMD_PXE && CMD_NET && DM_ETH
-   select BOOTMETH_EFILOADER if EFI_LOADER # E.g. Ubuntu uses this
+   select BOOTMETH_EFILOADER if CMD_BOOTEFI # E.g. Ubuntu uses this
 
 config SPL_BOOTMETH_VBE
bool "Bootdev support for Verified Boot for Embedded (SPL)"
-- 
2.34.1



[v4 10/24] cli_simple: Rework this support slightly

2023-10-19 Thread Tom Rini
The interactive portion of our non-HUSH 'simple' parser is guarded by
CONFIG_CMDLINE already.  Much of the code behind this simple parser is
also used as "input" parser, such as from menu interfaces and so forth
and not strictly command line input.  To support this, always build the
assorted cli object files, but guard the interactive portions of
cli_simple.c with a CMDLINE check.

Signed-off-by: Tom Rini 
---
 common/Makefile |  2 +-
 common/cli_simple.c | 77 +++--
 2 files changed, 40 insertions(+), 39 deletions(-)

diff --git a/common/Makefile b/common/Makefile
index b711dc29b65e..1495436d5d45 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -8,6 +8,7 @@ ifndef CONFIG_SPL_BUILD
 obj-y += init/
 obj-y += main.o
 obj-y += exports.o
+obj-y += cli_getch.o cli_simple.o cli_readline.o
 obj-$(CONFIG_HUSH_PARSER) += cli_hush.o
 obj-$(CONFIG_AUTOBOOT) += autoboot.o
 obj-y += version.o
@@ -38,7 +39,6 @@ obj-$(CONFIG_SPLASH_SOURCE) += splash_source.o
 obj-$(CONFIG_MENU) += menu.o
 obj-$(CONFIG_UPDATE_COMMON) += update.o
 obj-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
-obj-$(CONFIG_CMDLINE) += cli_getch.o cli_readline.o cli_simple.o
 
 endif # !CONFIG_SPL_BUILD
 
diff --git a/common/cli_simple.c b/common/cli_simple.c
index e80ba488a5eb..f89ba92d1b05 100644
--- a/common/cli_simple.c
+++ b/common/cli_simple.c
@@ -22,44 +22,6 @@
 #define debug_parser(fmt, args...) \
debug_cond(DEBUG_PARSER, fmt, ##args)
 
-
-int cli_simple_parse_line(char *line, char *argv[])
-{
-   int nargs = 0;
-
-   debug_parser("%s: \"%s\"\n", __func__, line);
-   while (nargs < CONFIG_SYS_MAXARGS) {
-   /* skip any white space */
-   while (isblank(*line))
-   ++line;
-
-   if (*line == '\0') {/* end of line, no more args*/
-   argv[nargs] = NULL;
-   debug_parser("%s: nargs=%d\n", __func__, nargs);
-   return nargs;
-   }
-
-   argv[nargs++] = line;   /* begin of argument string */
-
-   /* find end of string */
-   while (*line && !isblank(*line))
-   ++line;
-
-   if (*line == '\0') {/* end of line, no more args*/
-   argv[nargs] = NULL;
-   debug_parser("parse_line: nargs=%d\n", nargs);
-   return nargs;
-   }
-
-   *line++ = '\0'; /* terminate current arg */
-   }
-
-   printf("** Too many args (max. %d) **\n", CONFIG_SYS_MAXARGS);
-
-   debug_parser("%s: nargs=%d\n", __func__, nargs);
-   return nargs;
-}
-
 int cli_simple_process_macros(const char *input, char *output, int max_size)
 {
char c, prev;
@@ -172,6 +134,44 @@ int cli_simple_process_macros(const char *input, char 
*output, int max_size)
return ret;
 }
 
+#ifdef CONFIG_CMDLINE
+int cli_simple_parse_line(char *line, char *argv[])
+{
+   int nargs = 0;
+
+   debug_parser("%s: \"%s\"\n", __func__, line);
+   while (nargs < CONFIG_SYS_MAXARGS) {
+   /* skip any white space */
+   while (isblank(*line))
+   ++line;
+
+   if (*line == '\0') {/* end of line, no more args*/
+   argv[nargs] = NULL;
+   debug_parser("%s: nargs=%d\n", __func__, nargs);
+   return nargs;
+   }
+
+   argv[nargs++] = line;   /* begin of argument string */
+
+   /* find end of string */
+   while (*line && !isblank(*line))
+   ++line;
+
+   if (*line == '\0') {/* end of line, no more args*/
+   argv[nargs] = NULL;
+   debug_parser("parse_line: nargs=%d\n", nargs);
+   return nargs;
+   }
+
+   *line++ = '\0'; /* terminate current arg */
+   }
+
+   printf("** Too many args (max. %d) **\n", CONFIG_SYS_MAXARGS);
+
+   debug_parser("%s: nargs=%d\n", __func__, nargs);
+   return nargs;
+}
+
  /*
  * WARNING:
  *
@@ -346,3 +346,4 @@ int cli_simple_run_command_list(char *cmd, int flag)
 
return rcode;
 }
+#endif
-- 
2.34.1



[v4 08/24] test: Make UNIT_TEST depend on CMDLINE

2023-10-19 Thread Tom Rini
From: Simon Glass 

Many tests make some use of the command line, so require it for all test
code.

This could be teased apart, perhaps with a test flag indicating that it
uses the command line. Leave that for later.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---
 test/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/Kconfig b/test/Kconfig
index ca648d23376f..c3db727c58e3 100644
--- a/test/Kconfig
+++ b/test/Kconfig
@@ -2,6 +2,7 @@ menu "Testing"
 
 config UNIT_TEST
bool "Unit tests"
+   depends on CMDLINE
help
  Select this to compile in unit tests for various parts of
  U-Boot. Test suites will be subcommands of the "ut" command.
-- 
2.34.1



[v4 09/24] video: Don't require the font command

2023-10-19 Thread Tom Rini
From: Simon Glass 

While it is nice to have the font command, using 'select' makes it
impossible to build the console code without it. Stop using 'select' and
make it default if CONSOLE_TRUETYPE is enabled when asking the command.

Signed-off-by: Simon Glass 
Signed-off-by: Tom Rini 
---
Changes in v4:
- Rework to have the command itself be default y if CONSOLE_TRUETYPE
  instead of selecting it. (Tom)
---
 cmd/Kconfig   | 2 +-
 drivers/video/Kconfig | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index ecf25b062ad6..16e5cb8f0633 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -2340,7 +2340,7 @@ config CMD_VIDCONSOLE
 config CMD_SELECT_FONT
bool "select font size"
depends on VIDEO
-   default n
+   default y if CONSOLE_TRUETYPE
help
  Enabling this will provide 'font' command.
  Allows font selection at runtime.
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index ab927641bb7a..6f319ba0d544 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -180,7 +180,6 @@ config CONSOLE_ROTATION
 
 config CONSOLE_TRUETYPE
bool "Support a console that uses TrueType fonts"
-   select CMD_SELECT_FONT
help
  TrueTrype fonts can provide outline-drawing capability rather than
  needing to provide a bitmap for each font and size that is needed.
-- 
2.34.1



[v4 07/24] env: Move env_set() out of cmd/nvedit.c and in to env/common.c

2023-10-19 Thread Tom Rini
Inside of env/common.c we already have our helper env_set_xxx functions,
and even have a comment that explains why env_set() itself wasn't moved.
We now handle that move. This requires that we rename the previous
_do_env_set() to env_do_env_set() and note it as an internal env
function. Add comments about this function to explain why we do this
when we add the prototype. Add a new function, env_inc_id() to allow for
the counter to be updated by both commands and callers, and document
this as well by the prototype.

Signed-off-by: Tom Rini 
---
 cmd/Makefile   |   4 +-
 cmd/nvedit.c   | 122 ++---
 env/common.c   | 113 --
 include/env.h  |   8 +++
 include/env_internal.h |  12 
 5 files changed, 135 insertions(+), 124 deletions(-)

diff --git a/cmd/Makefile b/cmd/Makefile
index 44db5f22861e..27a0045e7f94 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -128,6 +128,7 @@ endif
 obj-$(CONFIG_CMD_MUX) += mux.o
 obj-$(CONFIG_CMD_NAND) += nand.o
 obj-$(CONFIG_CMD_NET) += net.o
+obj-$(CONFIG_ENV_SUPPORT) += nvedit.o
 obj-$(CONFIG_CMD_NVEDIT_EFI) += nvedit_efi.o
 obj-$(CONFIG_CMD_ONENAND) += onenand.o
 obj-$(CONFIG_CMD_OSD) += osd.o
@@ -244,9 +245,6 @@ endif # !CONFIG_SPL_BUILD
 
 obj-$(CONFIG_$(SPL_)CMD_TLV_EEPROM) += tlv_eeprom.o
 
-# core command
-obj-y += nvedit.o
-
 obj-$(CONFIG_CMD_BCM_EXT_UTILS) += broadcom/
 
 filechk_data_gz = (echo "static const char data_gz[] ="; cat $< | 
scripts/bin2c; echo ";")
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index daf1ad37f9be..e77338f81394 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -49,20 +49,6 @@ DECLARE_GLOBAL_DATA_PTR;
  */
 #defineMAX_ENV_SIZE(1 << 20)   /* 1 MiB */
 
-/*
- * This variable is incremented on each do_env_set(), so it can
- * be used via env_get_id() as an indication, if the environment
- * has changed or not. So it is possible to reread an environment
- * variable only if the environment was changed ... done so for
- * example in NetInitLoop()
- */
-static int env_id = 1;
-
-int env_get_id(void)
-{
-   return env_id;
-}
-
 #ifndef CONFIG_SPL_BUILD
 /*
  * Command interface: print one or all environment variables
@@ -198,104 +184,6 @@ DONE:
 #endif
 #endif /* CONFIG_SPL_BUILD */
 
-/*
- * Set a new environment variable,
- * or replace or delete an existing one.
- */
-static int _do_env_set(int flag, int argc, char *const argv[], int env_flag)
-{
-   int   i, len;
-   char  *name, *value, *s;
-   struct env_entry e, *ep;
-
-   debug("Initial value for argc=%d\n", argc);
-
-#if !IS_ENABLED(CONFIG_SPL_BUILD) && IS_ENABLED(CONFIG_CMD_NVEDIT_EFI)
-   if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'e')
-   return do_env_set_efi(NULL, flag, --argc, ++argv);
-#endif
-
-   while (argc > 1 && **(argv + 1) == '-') {
-   char *arg = *++argv;
-
-   --argc;
-   while (*++arg) {
-   switch (*arg) {
-   case 'f':   /* force */
-   env_flag |= H_FORCE;
-   break;
-   default:
-   return CMD_RET_USAGE;
-   }
-   }
-   }
-   debug("Final value for argc=%d\n", argc);
-   name = argv[1];
-
-   if (strchr(name, '=')) {
-   printf("## Error: illegal character '='"
-  "in variable name \"%s\"\n", name);
-   return 1;
-   }
-
-   env_id++;
-
-   /* Delete only ? */
-   if (argc < 3 || argv[2] == NULL) {
-   int rc = hdelete_r(name, _htab, env_flag);
-
-   /* If the variable didn't exist, don't report an error */
-   return rc && rc != -ENOENT ? 1 : 0;
-   }
-
-   /*
-* Insert / replace new value
-*/
-   for (i = 2, len = 0; i < argc; ++i)
-   len += strlen(argv[i]) + 1;
-
-   value = malloc(len);
-   if (value == NULL) {
-   printf("## Can't malloc %d bytes\n", len);
-   return 1;
-   }
-   for (i = 2, s = value; i < argc; ++i) {
-   char *v = argv[i];
-
-   while ((*s++ = *v++) != '\0')
-   ;
-   *(s - 1) = ' ';
-   }
-   if (s != value)
-   *--s = '\0';
-
-   e.key   = name;
-   e.data  = value;
-   hsearch_r(e, ENV_ENTER, , _htab, env_flag);
-   free(value);
-   if (!ep) {
-   printf("## Error inserting \"%s\" variable, errno=%d\n",
-   name, errno);
-   return 1;
-   }
-
-   return 0;
-}
-
-int env_set(const char *varname, const char *varvalue)
-{
-   const char * const argv[4] = { "setenv", varname, varvalue, NULL };
-
-   /* before import into hashtable */
-   if (!(gd->flags & GD_FLG_ENV_READY))
-   return 1;
-
-   if 

[v4 06/24] Kconfig: Move CONFIG_SYS_[CP]BSIZE to common/Kconfig

2023-10-19 Thread Tom Rini
Move CONFIG_SYS_CBSIZE (console buffer size) and CONFIG_SYS_PBSIZE
(console print buffer size) out of cmd/Kconfig and in to common/Kconfig.
Create help entries for both which explain their usage and why they are
both not entirely command centric.

Signed-off-by: Tom Rini 
---
 cmd/Kconfig| 14 --
 common/Kconfig | 23 +++
 2 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 5554bd14e2ef..ecf25b062ad6 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -75,20 +75,6 @@ config SYS_MAXARGS
int "Maximum number arguments accepted by commands"
default 16
 
-config SYS_CBSIZE
-   int "Console input buffer size"
-   default 2048 if ARCH_TEGRA || ARCH_VERSAL || ARCH_ZYNQ || ARCH_ZYNQMP 
|| \
-   RCAR_GEN3 || TARGET_SOCFPGA_SOC64
-   default 512 if ARCH_MX5 || ARCH_MX6 || ARCH_MX7 || FSL_LSCH2 || \
-   FSL_LSCH3 || X86
-   default 256 if M68K || PPC
-   default 1024
-
-config SYS_PBSIZE
-   int "Buffer size for console output"
-   default 1024 if ARCH_SUNXI
-   default 1044
-
 config SYS_XTRACE
bool "Command execution tracer"
depends on CMDLINE
diff --git a/common/Kconfig b/common/Kconfig
index 93c96f23b013..fba1548e135b 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -52,6 +52,29 @@ config CONSOLE_RECORD_IN_SIZE
  The buffer is allocated immediately after the malloc() region is
  ready.
 
+config SYS_CBSIZE
+   int "Console input buffer size"
+   default 2048 if ARCH_TEGRA || ARCH_VERSAL || ARCH_ZYNQ || ARCH_ZYNQMP 
|| \
+   RCAR_GEN3 || TARGET_SOCFPGA_SOC64
+   default 512 if ARCH_MX5 || ARCH_MX6 || ARCH_MX7 || FSL_LSCH2 || \
+   FSL_LSCH3 || X86
+   default 256 if M68K || PPC
+   default 1024
+   help
+ Set the size of the console input buffer. This is used both in the
+ case of reading input literally from the user in some manner as well
+ as when we need to construct or modify that type of input, for
+ example when constructing "bootargs" for the OS.
+
+config SYS_PBSIZE
+   int "Console output buffer size"
+   default 1024 if ARCH_SUNXI
+   default 1044
+   help
+ Set the size of the console output buffer. This is used when we need
+ to work with some form of a buffer while providing output in some
+ form to the user.
+
 config DISABLE_CONSOLE
bool "Add functionality to disable console completely"
help
-- 
2.34.1



[v4 05/24] qemu: Correct CMD_QFW dependencies in Kconfig

2023-10-19 Thread Tom Rini
Rather than selecting CMD_QFW, we should make the option itself by
enabled by default on these platforms.  Then in the board-specific
Kconfig we should select the appropriate back-end as needed if the
command is enabled.

Signed-off-by: Tom Rini 
---
Cc: Tuomas Tynkkynen 
Cc: Bin Meng 
---
 board/emulation/qemu-arm/Kconfig | 3 +--
 board/emulation/qemu-x86/Kconfig | 2 +-
 cmd/Kconfig  | 2 ++
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/board/emulation/qemu-arm/Kconfig b/board/emulation/qemu-arm/Kconfig
index 09c95413a541..ac2d078f42a1 100644
--- a/board/emulation/qemu-arm/Kconfig
+++ b/board/emulation/qemu-arm/Kconfig
@@ -5,8 +5,7 @@ config TEXT_BASE
 
 config BOARD_SPECIFIC_OPTIONS # dummy
def_bool y
-   select CMD_QFW
-   select QFW_MMIO
+   select QFW_MMIO if CMD_QFW
imply VIRTIO_MMIO
imply VIRTIO_PCI
imply VIRTIO_NET
diff --git a/board/emulation/qemu-x86/Kconfig b/board/emulation/qemu-x86/Kconfig
index 787751abba4f..01dc1d497aec 100644
--- a/board/emulation/qemu-x86/Kconfig
+++ b/board/emulation/qemu-x86/Kconfig
@@ -20,7 +20,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
def_bool y
select X86_RESET_VECTOR
select QEMU
-   select QFW_PIO
+   select QFW_PIO if CMD_QFW
select BOARD_ROMSIZE_KB_1024
imply VIRTIO_PCI
imply VIRTIO_NET
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 5bc0a92d57ad..5554bd14e2ef 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -2239,6 +2239,8 @@ config CMD_SYSBOOT
 config CMD_QFW
bool "qfw"
select QFW
+   default y if TARGET_QEMU_ARM_32BIT || TARGET_QEMU_ARM_64BIT || \
+   TARGET_QEMU_X86 || TARGET_QEMU_X86_64
help
  This provides access to the QEMU firmware interface.  The main
  feature is to allow easy loading of files passed to qemu-system
-- 
2.34.1



[v4 04/24] version: Separate our version string from the version command

2023-10-19 Thread Tom Rini
In order to be able to disable all commands we need to construct our
version string in a common file, and have the version command reference
that string, like the other users of it do.  Create common/version.c
with just the strings.

Signed-off-by: Tom Rini 
---
 cmd/version.c|  9 -
 common/Makefile  |  1 +
 common/version.c | 16 
 3 files changed, 17 insertions(+), 9 deletions(-)
 create mode 100644 common/version.c

diff --git a/cmd/version.c b/cmd/version.c
index 87e1fa4159c1..d99a44f19fb3 100644
--- a/cmd/version.c
+++ b/cmd/version.c
@@ -7,21 +7,12 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #ifdef CONFIG_SYS_COREBOOT
 #include 
 #endif
 
-#define U_BOOT_VERSION_STRING U_BOOT_VERSION " (" U_BOOT_DATE " - " \
-   U_BOOT_TIME " " U_BOOT_TZ ")" CONFIG_IDENT_STRING
-
-const char version_string[] = U_BOOT_VERSION_STRING;
-const unsigned short version_num = U_BOOT_VERSION_NUM;
-const unsigned char version_num_patch = U_BOOT_VERSION_NUM_PATCH;
-
 static int do_version(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[])
 {
diff --git a/common/Makefile b/common/Makefile
index cdeadf72026c..b711dc29b65e 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -10,6 +10,7 @@ obj-y += main.o
 obj-y += exports.o
 obj-$(CONFIG_HUSH_PARSER) += cli_hush.o
 obj-$(CONFIG_AUTOBOOT) += autoboot.o
+obj-y += version.o
 
 # # boards
 obj-y += board_f.o
diff --git a/common/version.c b/common/version.c
new file mode 100644
index ..6e27bb80e398
--- /dev/null
+++ b/common/version.c
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+ */
+
+#include 
+#include 
+#include 
+
+#define U_BOOT_VERSION_STRING U_BOOT_VERSION " (" U_BOOT_DATE " - " \
+   U_BOOT_TIME " " U_BOOT_TZ ")" CONFIG_IDENT_STRING
+
+const char version_string[] = U_BOOT_VERSION_STRING;
+const unsigned short version_num = U_BOOT_VERSION_NUM;
+const unsigned char version_num_patch = U_BOOT_VERSION_NUM_PATCH;
-- 
2.34.1



[v4 03/24] dfu: Make DFU_TFTP depend on NETDEVICES

2023-10-19 Thread Tom Rini
In order to do a DFU update over TFTP we need to have some network
device available, so make this depend on NETDEVICES

Signed-off-by: Tom Rini 
---
 drivers/dfu/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig
index 4e80e85d10d7..8771678ca5a0 100644
--- a/drivers/dfu/Kconfig
+++ b/drivers/dfu/Kconfig
@@ -19,6 +19,7 @@ config DFU_WRITE_ALT
 
 config DFU_TFTP
bool "DFU via TFTP"
+   depends on NETDEVICES
select UPDATE_COMMON
select DFU_OVER_TFTP
help
-- 
2.34.1



[v4 02/24] virtio: Make VIRTIO_NET depend on NETDEVICES

2023-10-19 Thread Tom Rini
As VIRTIO_NET is the symbol for enabling network devices, make this
depend on NETDEVICES

Signed-off-by: Tom Rini 
---
Cc: Bin Meng 
---
 drivers/virtio/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig
index 852f6735b602..1de68867d52e 100644
--- a/drivers/virtio/Kconfig
+++ b/drivers/virtio/Kconfig
@@ -56,7 +56,7 @@ config VIRTIO_SANDBOX
 
 config VIRTIO_NET
bool "virtio net driver"
-   depends on VIRTIO
+   depends on VIRTIO && NETDEVICES
help
  This is the virtual net driver for virtio. It can be used with
  QEMU based targets.
-- 
2.34.1



[v4 01/24] buildman: Use oldconfig when adjusting the config

2023-10-19 Thread Tom Rini
From: Simon Glass 

We cannot be sure that the new config is consistent, particularly when
changing a major item like CONFIG_CMDLINE. Use 'make oldconfig' to
check that and avoid any such problems.

Signed-off-by: Simon Glass 
---
 tools/buildman/builder.py   | 2 +-
 tools/buildman/builderthread.py | 6 ++
 tools/buildman/func_test.py | 4 +++-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index 5305477c5be6..782e59dd5cca 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -476,7 +476,7 @@ class Builder:
 Args:
 commit: Commit object that is being built
 brd: Board object that is being built
-stage: Stage that we are at (mrproper, config, build)
+stage: Stage that we are at (mrproper, config, oldconfig, build)
 cwd: Directory where make should be run
 args: Arguments to pass to make
 kwargs: Arguments to pass to command.run_pipe()
diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index 6a61f64da1d4..a8599c0bb2a8 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -426,6 +426,12 @@ class BuilderThread(threading.Thread):
 
 # Now do the build, if everything looks OK
 if result.return_code == 0:
+if adjust_cfg:
+oldc_args = list(args) + ['oldconfig']
+oldc_result = self.make(commit, brd, 'oldconfig', cwd,
+*oldc_args, env=env)
+if oldc_result.return_code:
+return oldc_result
 result = self._build(commit, brd, cwd, args, env, cmd_list,
  config_only)
 if adjust_cfg:
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index 55dd494fe8ee..6b88ed815d65 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -439,6 +439,8 @@ class TestFunctional(unittest.TestCase):
 tools.write_file(fname, b'CONFIG_SOMETHING=1')
 return command.CommandResult(return_code=0,
 combined='Test configuration complete')
+elif stage == 'oldconfig':
+return command.CommandResult(return_code=0)
 elif stage == 'build':
 stderr = ''
 fname = os.path.join(cwd or '', out_dir, 'u-boot')
@@ -461,7 +463,7 @@ Some images are invalid'''
 return command.CommandResult(return_code=0)
 
 # Not handled, so abort
-print('make', stage)
+print('_HandleMake failure: make', stage)
 sys.exit(1)
 
 # Example function to print output lines
-- 
2.34.1



Re: Branches in uboot-imx

2023-10-19 Thread Peter Robinson
On Thu, Oct 19, 2023 at 3:58 PM Grzegorz Borowiak  wrote:
>
> Hello!
>
> I just cloned the repository:
>
> https://github.com/nxp-imx/uboot-imx
>
> and I encountered a rather large amount of branches (listed below).
>
> Are these branches somehow described, so I could read what they are about?
> Especially I'm interested in branches whose names begin with "imx" and
> "lf". What are differences between them, and how are they different from
> branches here:

You would have to ask NXP about that, that repo is not part of the
upstream project.

> https://github.com/u-boot/u-boot
>
> ?
>
> imx_4.14.98_8qxpc0_er
> imx_5.4.0_8dxlphantom_er
> imx_v2017.03_4.9.11_1.0.0_ga
> imx_v2017.03_4.9.123_imx8mm_ga
> imx_v2017.03_4.9.51_imx8_beta1
> imx_v2017.03_4.9.51_imx8_beta2
> imx_v2017.03_4.9.51_imx8m_beta
> imx_v2017.03_4.9.51_imx8m_ga
> imx_v2017.03_4.9.88_2.0.0_ga
> imx_v2017.03_4.9.88_imx8mm_alpha
> imx_v2017.03_4.9.88_imx8qxp_beta2
> imx_v2018.03_4.14.62_1.0.0_beta
> imx_v2018.03_4.14.78_1.0.0_ga
> imx_v2018.03_4.14.98_2.0.0_ga
> imx_v2018.03_4.14.98_2.1.0
> imx_v2018.03_4.14.98_2.2.0
> imx_v2018.03_4.14.98_2.3.0
> imx_v2019.04_4.19.35_1.0.0
> imx_v2019.04_4.19.35_1.1.0
> imx_v2019.04_5.4.3_2.0.0
> imx_v2020.04_5.4.24_2.1.0
> imx_v2020.04_5.4.47_2.2.0
> imx_v2020.04_5.4.70_2.3.0
> lf-5.4.y_v2019.04
> lf_v2020.04
> lf_v2021.04
> lf_v2022.04
> lf_v2023.04
> master
> nxp/imx_3.14.38_6ul_engr
> nxp/imx_v2009.08
> nxp/imx_v2009.08_1.1.0
> nxp/imx_v2009.08_10.04.01
> nxp/imx_v2009.08_10.05.02
> nxp/imx_v2009.08_10.07.11
> nxp/imx_v2009.08_10.10.01
> nxp/imx_v2009.08_10.11.01
> nxp/imx_v2009.08_10.12.01
> nxp/imx_v2009.08_11.04.01
> nxp/imx_v2009.08_11.05.01
> nxp/imx_v2009.08_11.09.01
> nxp/imx_v2009.08_11.11.01
> nxp/imx_v2009.08_12.01.01
> nxp/imx_v2009.08_12.02.01
> nxp/imx_v2009.08_12.09.01
> nxp/imx_v2009.08_12.10.02
> nxp/imx_v2009.08_3.0.0
> nxp/imx_v2009.08_3.0.35_4.0.0
> nxp/imx_v2009.08_3.0.35_4.1.0
> nxp/imx_v2009.08_r13.4.y
> nxp/imx_v2013.04_3.10.17_1.0.0_beta
> nxp/imx_v2013.04_3.10.17_1.0.0_ga
> nxp/imx_v2013.04_3.10.31_1.1.0_alpha
> nxp/imx_v2013.04_3.10.9_1.0.0_alpha
> nxp/imx_v2013.04_3.5.7_1.0.0_alpha
> nxp/imx_v2014.04_3.10.31_1.1.0_beta
> nxp/imx_v2014.04_3.10.31_1.1.0_beta2
> nxp/imx_v2014.04_3.10.53_1.1.0_ga
> nxp/imx_v2014.04_3.14.28_1.0.0_ga
> nxp/imx_v2014.04_3.14.28_7d_alpha
> nxp/imx_v2014.04_3.14.38_6qp_beta
> nxp/imx_v2014.04_kk4.4.3_2.y
> nxp/imx_v2015.04
> nxp/imx_v2015.04_3.14.38_6qp_ga
> nxp/imx_v2015.04_3.14.38_6ul7d_beta
> nxp/imx_v2015.04_3.14.38_6ul_ga
> nxp/imx_v2015.04_3.14.52_1.1.0_ga
> nxp/imx_v2015.04_4.1.15_1.0.0_ga
> nxp/imx_v2015.04_brillo
> nxp/imx_v2016.03_4.1.15_2.0.0_ga
> nxp/imx_v2016.03_4.1.30_7ulp_alpha
> nxp/imx_v2016.03_4.1.33_7ulp_beta
> nxp/imx_v2017.03_4.9.11_1.0.0_ga
> nxp/maddev-imx-android-r10.3
> nxp/maddev-imx-android-r13.2
> nxp/master
> nxp/scm-imx_v2016.03_4.1.15_2.0.0_ga
> u-boot/master
> u-boot/next
> u-boot/origin
> u-boot/u-boot-2009.11.y
> u-boot/u-boot-2013.01.y
> u-boot/u-boot-2016.09.y


Re: U-Boot 2023.10 does not boot from uSD on RPi4

2023-10-19 Thread Ivan Ivanov

Hi,

On Thu, 2023-10-19 at 08:32 -0600, Simon Glass wrote:
> > > > 
> > > > I am afraid we still have a boot issue. This time device can not boot 
> > > > from USB.
> > > > Device boot order was changed to USB first then uSD. uSD card is 
> > > > removed.
> > > > 
> > > > Please see [1] attachment #870321 for boot log details.
> > > > 
> > > > I have not invested time to debug this, still.
> > > 
> > > Thanks for the info. Is this using 'boot_targets=mmc usb pxe dhcp'?
> > > 
> > 
> > Yes. "boot_targets=mmc usb pxe dhcp". Full environment added to the bug.
> > 
> > https://bugzilla.suse.com/show_bug.cgi?id=1216036
> 
> OK thank you, I will take a look.
> 
> I wonder if there is a way of testing pending patches, or do they need
> to be applied before they can be tested in your systems?

I am not sure what do you mean here. openSUSE uses this [1] project
on Open Build Service to build installable packages. As you can see 
there are few patches on top of u-boot-2023.10 release including [2].

What I can do is to build new package with any proposed patch on 
top of last release. Of course I can also build the U-Boot and just 
copy binary to the board. 

In other words I could test any proposed patch :-)

Regards,
Ivan

[1] https://build.opensuse.org/package/show/hardware:boot/u-boot
[2] bootstd: Scan all bootdevs in a boot_targets entry


Re: U-Boot 2023.10 does not boot from uSD on RPi4

2023-10-19 Thread Ivan Ivanov
On Thu, 2023-10-19 at 08:00 -0600, Simon Glass wrote:
> > > 
> > > [2] 
> > > https://patchwork.ozlabs.org/project/uboot/patch/20230923205017.1754340-1-...@chromium.org/
> > > 
> > > > > 
> > > > > [1] https://lists.denx.de/pipermail/u-boot/2023-October/533158.html
> > > > > 
> > > > > > 'git bisect' points to:
> > > > > > **
> > > > > > commit c771e5b8c2a186fb072b6c6f571d4a3cc86efba9
> > > > > > Author: Simon Glass 
> > > > > > Date:   Thu Jul 27 15:54:28 2023 -0600
> > > > > > 
> > > > > >  arm: rpi: Switch to standard boot
> > > > > > 
> > > > > >  Drop use of the distro scripts and use standard boot instead.
> > > > > > 
> > > > > >  We don't need to specify the mmc devices individually, since 
> > > > > > they are
> > > > > >  used in order from 0 to 2, and standard boot uses that order 
> > > > > > anyway.
> > > > > > 
> > > > > >  Signed-off-by: Simon Glass 
> > > > > > **
> > > > > > 
> > > > > > The following patch fixes the boot from uSD on RPi4 (not tested on 
> > > > > > RPi3 nor RPi
> > > > > Zero 2 W):
> > > > > > **
> > > > > > diff --git a/board/raspberrypi/rpi/rpi.env
> > > > > > b/board/raspberrypi/rpi/rpi.env index 30228285ed..02210b97b5 100644
> > > > > > --- a/board/raspberrypi/rpi/rpi.env
> > > > > > +++ b/board/raspberrypi/rpi/rpi.env
> > > > > > @@ -74,4 +74,4 @@ pxefile_addr_r=0x0250
> > > > > >   fdt_addr_r=0x0260
> > > > > >   ramdisk_addr_r=0x0270
> > > > > > 
> > > > > > -boot_targets=mmc usb pxe dhcp
> > > > > > +boot_targets=mmc0 mmc1 mmc2 usb pxe dhcp
> > > > > > **
> > > > > > 
> > > > > > So, the comment from Simon " We don't need to specify the mmc 
> > > > > > devices
> > > > > individually, since they are used in order from 0 to 2, and standard 
> > > > > boot uses that
> > > > > order anyway" seems wrong for the RPi4 case.
> > > > > > 
> > 
> > I am afraid we still have a boot issue. This time device can not boot from 
> > USB.
> > Device boot order was changed to USB first then uSD. uSD card is removed.
> > 
> > Please see [1] attachment #870321 for boot log details.
> > 
> > I have not invested time to debug this, still.
> 
> Thanks for the info. Is this using 'boot_targets=mmc usb pxe dhcp'?
> 

Yes. "boot_targets=mmc usb pxe dhcp". Full environment added to the bug.

https://bugzilla.suse.com/show_bug.cgi?id=1216036




[PATCH] doc: Replace dm_dump_all() with dm_dump_tree()

2023-10-19 Thread Dylan Corrales
Replace dm_dump_all() with dm_dump_tree() in driver model documentation,
to reflect changes introduced in commit 145287040480 ("dm: core: Rename
dm_dump_all()").

Signed-off-by: Dylan Corrales 
---

 doc/develop/driver-model/debugging.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/develop/driver-model/debugging.rst 
b/doc/develop/driver-model/debugging.rst
index bbb2794340..e13abddae6 100644
--- a/doc/develop/driver-model/debugging.rst
+++ b/doc/develop/driver-model/debugging.rst
@@ -49,7 +49,7 @@ to see errors. Common ones are:
  of_to_plat() method in the driver.
 
 If there is no error, you should check if the device is actually bound. Call
-dm_dump_all() just before you locate the device to make sure it exists.
+dm_dump_tree() just before you locate the device to make sure it exists.
 
 If it does not exist, check your device tree compatible strings match up with
 what the driver expects (in the struct udevice_id array).
-- 
2.34.1



  1   2   >