[PATCH v3 17/17] configs: Enable HDMI Out for ROC-RK3328-CC

2024-01-16 Thread Jagan Teki
U-Boot 2024.01-00901-g75d07e0e6e-dirty (Jan 17 2024 - 12:50:56 +0530)

Model: Firefly roc-rk3328-cc
DRAM:  4 GiB
PMIC:  RK8050 (on=0x40, off=0x00)
Core:  236 devices, 26 uclasses, devicetree: separate
MMC:   mmc@ff50: 1, mmc@ff52: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:serial,usbkbd
Out:   serial,vidconsole
Err:   serial,vidconsole
Model: Firefly roc-rk3328-cc
Net:   eth0: ethernet@ff54
Hit any key to stop autoboot:  0
=> dm tree
 Class Index  Probed  DriverName
---
 root  0  [ + ]   root_driver   root_driver
 firmware  0  [   ]   psci  |-- psci
 clk   0  [ + ]   fixed_clock   |-- xin24m
 syscon0  [ + ]   rockchip_rk3328_grf   |-- syscon@ff10
 serial0  [ + ]   ns16550_serial|-- serial@ff13
 i2c   0  [ + ]   rockchip_rk3066_i2c   |-- i2c@ff16
 pmic  0  [ + ]   rockchip_rk805|   `-- pmic@18
 sysreset  0  [   ]   rk8xx_sysreset|   |-- rk8xx_sysreset
 regulator 0  [ + ]   rk8xx_buck|   |-- DCDC_REG1
 regulator 1  [ + ]   rk8xx_buck|   |-- DCDC_REG2
 regulator 2  [ + ]   rk8xx_buck|   |-- DCDC_REG3
 regulator 3  [ + ]   rk8xx_buck|   |-- DCDC_REG4
 regulator 4  [ + ]   rk8xx_ldo |   |-- LDO_REG1
 regulator 5  [ + ]   rk8xx_ldo |   |-- LDO_REG2
 regulator 6  [ + ]   rk8xx_ldo |   `-- LDO_REG3
 video 0  [ + ]   rk3328_vop|-- vop@ff37
 vidconsole0  [ + ]   vidconsole0   |   `-- vop@ff37.vidconsole0
 display   0  [ + ]   rk3328_hdmi_rockchip  |-- hdmi@ff3c
 phy   0  [ + ]   inno_hdmi_phy |-- phy@ff43
 clk   1  [ + ]   rockchip_rk3328_cru   |-- clock-controller@ff44
 sysreset  1  [   ]   rockchip_sysreset |   |-- sysreset
 reset 0  [ + ]   rockchip_reset|   `-- reset

Signed-off-by: Jagan Teki 
---
Changes for v3, v2:
- none

 configs/roc-cc-rk3328_defconfig | 5 +
 1 file changed, 5 insertions(+)

diff --git a/configs/roc-cc-rk3328_defconfig b/configs/roc-cc-rk3328_defconfig
index 4ac3c9403b..4eef9016dc 100644
--- a/configs/roc-cc-rk3328_defconfig
+++ b/configs/roc-cc-rk3328_defconfig
@@ -79,6 +79,7 @@ CONFIG_PHY_REALTEK=y
 CONFIG_PHY_GIGE=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_GMAC_ROCKCHIP=y
+CONFIG_PHY_ROCKCHIP_INNO_HDMI=y
 CONFIG_PHY_ROCKCHIP_INNO_USB2=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
@@ -114,6 +115,10 @@ CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_DWC2_OTG=y
+CONFIG_VIDEO=y
+CONFIG_DISPLAY=y
+CONFIG_VIDEO_ROCKCHIP=y
+CONFIG_DISPLAY_ROCKCHIP_HDMI=y
 CONFIG_SPL_TINY_MEMSET=y
 CONFIG_TPL_TINY_MEMSET=y
 CONFIG_ERRNO_STR=y
-- 
2.25.1



[PATCH v3 16/17] configs: evb-rk3328: Enable vidconsole for rk3328

2024-01-16 Thread Jagan Teki
Enable video console for Rockchip RK3328.

Signed-off-by: Jagan Teki 
---
Changes for v3, v2:
- none

 include/configs/evb_rk3328.h| 5 +
 include/configs/rk3328_common.h | 1 +
 2 files changed, 6 insertions(+)

diff --git a/include/configs/evb_rk3328.h b/include/configs/evb_rk3328.h
index d10e5b1d2e..c985080f7b 100644
--- a/include/configs/evb_rk3328.h
+++ b/include/configs/evb_rk3328.h
@@ -6,6 +6,11 @@
 #ifndef __EVB_RK3328_H
 #define __EVB_RK3328_H
 
+#define ROCKCHIP_DEVICE_SETTINGS \
+   "stdin=serial,usbkbd\0" \
+   "stdout=serial,vidconsole\0" \
+   "stderr=serial,vidconsole\0"
+
 #include 
 
 #endif
diff --git a/include/configs/rk3328_common.h b/include/configs/rk3328_common.h
index e920ec7e5d..2c40674b22 100644
--- a/include/configs/rk3328_common.h
+++ b/include/configs/rk3328_common.h
@@ -26,6 +26,7 @@
ENV_MEM_LAYOUT_SETTINGS \
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
"partitions=" PARTS_DEFAULT \
+   ROCKCHIP_DEVICE_SETTINGS \
"boot_targets=" BOOT_TARGETS "\0"
 
 #endif
-- 
2.25.1



[PATCH v3 15/17] rockchip: Enable preconsole for rk3328

2024-01-16 Thread Jagan Teki
Enable and set the start address of pre-console buffer for RK3328.

Signed-off-by: Jagan Teki 
---
Changes for v3, v2:
- none

 arch/arm/mach-rockchip/Kconfig | 1 +
 common/Kconfig | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index b577a911e7..60f403fe74 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -179,6 +179,7 @@ config ROCKCHIP_RK3328
select SUPPORT_TPL
select TPL
select TPL_NEEDS_SEPARATE_STACK if TPL
+   imply PRE_CONSOLE_BUFFER
imply ROCKCHIP_COMMON_BOARD
imply ROCKCHIP_SDRAM_COMMON
imply SPL_ROCKCHIP_COMMON_BOARD
diff --git a/common/Kconfig b/common/Kconfig
index 0283701f1d..5e3070e925 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -231,7 +231,7 @@ config PRE_CON_BUF_ADDR
default 0x2f00 if ARCH_SUNXI && MACH_SUN9I
default 0x4f00 if ARCH_SUNXI && !MACH_SUN9I
default 0x0f00 if ROCKCHIP_RK3288
-   default 0x0f20 if ROCKCHIP_RK3399
+   default 0x0f20 if ROCKCHIP_RK3399 || ROCKCHIP_RK3328
help
  This sets the start address of the pre-console buffer. This must
  be in available memory and is accessed before relocation and
-- 
2.25.1



[PATCH v3 14/17] ARM: dts: rk3328: Enable VOP for bootph-all

2024-01-16 Thread Jagan Teki
Model: Firefly roc-rk3328-cc
DRAM: 1 GiB (effective 1022 MiB)
Video device 'vop@ff37' cannot allocate frame buffer memory -ensure the 
device is set up before relocation
Error binding driver 'rockchip_rk3328_vop': -28
Some drivers failed to bind
initcall sequence 3ffcd5e8 failed at call 0021a5c4 (err=-28)
 ### ERROR ### Please RESET the board ###

Signed-off-by: Jagan Teki 
---
Changes for v3, v2:
- none

 arch/arm/dts/rk3328-u-boot.dtsi | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/dts/rk3328-u-boot.dtsi b/arch/arm/dts/rk3328-u-boot.dtsi
index a9f2536de2..5258fec566 100644
--- a/arch/arm/dts/rk3328-u-boot.dtsi
+++ b/arch/arm/dts/rk3328-u-boot.dtsi
@@ -68,3 +68,7 @@
  {
bootph-all;
 };
+
+ {
+   bootph-all;
+};
-- 
2.25.1



[PATCH v3 13/17] video: rockchip: Add rk3328 vop support

2024-01-16 Thread Jagan Teki
From: Jagan Teki 

Add support for Rockchip RK3328 VOP.

Require VOP cleanup before handoff to Linux by writing reset values to
WIN registers. Without this Linux VOP trigger page fault as below
[0.752016] Loading compiled-in X.509 certificates
[0.787796] inno_hdmi_phy_rk3328_clk_recalc_rate: parent 2400
[0.788391] inno-hdmi-phy ff43.phy: inno_hdmi_phy_rk3328_clk_recalc_rate 
rate 14850 vco 14850
[0.798353] rockchip-drm display-subsystem: bound ff37.vop (ops 
vop_component_ops)
[0.799403] dwhdmi-rockchip ff3c.hdmi: supply avdd-0v9 not found, using 
dummy regulator
[0.800288] rk_iommu ff373f00.iommu: Enable stall request timed out, status: 
0x4b
[0.801131] dwhdmi-rockchip ff3c.hdmi: supply avdd-1v8 not found, using 
dummy regulator
[0.802056] rk_iommu ff373f00.iommu: Disable paging request timed out, 
status: 0x4b
[0.803233] dwhdmi-rockchip ff3c.hdmi: Detected HDMI TX controller 
v2.11a with HDCP (inno_dw_hdmi_phy2)
[0.805355] dwhdmi-rockchip ff3c.hdmi: registered DesignWare HDMI I2C 
bus driver
[0.808769] rockchip-drm display-subsystem: bound ff3c.hdmi (ops 
dw_hdmi_rockchip_ops)
[0.810869] [drm] Initialized rockchip 1.0.0 20140818 for display-subsystem 
on minor 0

Signed-off-by: Jagan Teki 
---
Changes for v3:
- Add WIN0 disable at remove
Changes for v2:
- Add VOP cleanup
- Update commit

 drivers/video/rockchip/Makefile |  1 +
 drivers/video/rockchip/rk3328_vop.c | 83 +
 2 files changed, 84 insertions(+)
 create mode 100644 drivers/video/rockchip/rk3328_vop.c

diff --git a/drivers/video/rockchip/Makefile b/drivers/video/rockchip/Makefile
index 4991303c73..f55beceebf 100644
--- a/drivers/video/rockchip/Makefile
+++ b/drivers/video/rockchip/Makefile
@@ -6,6 +6,7 @@
 ifdef CONFIG_VIDEO_ROCKCHIP
 obj-y += rk_vop.o
 obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288_vop.o
+obj-$(CONFIG_ROCKCHIP_RK3328) += rk3328_vop.o
 obj-$(CONFIG_ROCKCHIP_RK3399) += rk3399_vop.o
 obj-$(CONFIG_DISPLAY_ROCKCHIP_EDP) += rk_edp.o
 obj-$(CONFIG_DISPLAY_ROCKCHIP_LVDS) += rk_lvds.o
diff --git a/drivers/video/rockchip/rk3328_vop.c 
b/drivers/video/rockchip/rk3328_vop.c
new file mode 100644
index 00..55233f19ee
--- /dev/null
+++ b/drivers/video/rockchip/rk3328_vop.c
@@ -0,0 +1,83 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2023 Edgeble AI Technologies Pvt. Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include "rk_vop.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static void rk3328_set_pin_polarity(struct udevice *dev,
+   enum vop_modes mode, u32 polarity)
+{
+   struct rk_vop_priv *priv = dev_get_priv(dev);
+   struct rk3288_vop *regs = priv->regs;
+
+   switch (mode) {
+   case VOP_MODE_HDMI:
+   clrsetbits_le32(>dsp_ctrl1,
+   M_RK3399_DSP_HDMI_POL,
+   V_RK3399_DSP_HDMI_POL(polarity));
+   break;
+   default:
+   debug("%s: unsupported output mode %x\n", __func__, mode);
+   }
+}
+
+static int rk3328_vop_probe(struct udevice *dev)
+{
+   /* Before relocation we don't need to do anything */
+   if (!(gd->flags & GD_FLG_RELOC))
+   return 0;
+
+   return rk_vop_probe(dev);
+}
+
+static int rk3328_vop_remove(struct udevice *dev)
+{
+   struct rk_vop_priv *priv = dev_get_priv(dev);
+   struct rk3288_vop *regs = priv->regs;
+   struct rk3288_vop *win_regs = priv->regs + priv->win_offset;
+
+   /* FIXME: Explicit disabling of WIN0 is needed to avoid iommu
+* page-fault in Linux, better handling of iommu-address in
+* Linux might drop this.
+*/
+   clrbits_le32(_regs->win0_ctrl0, M_WIN0_EN);
+   writel(0x01, >reg_cfg_done);
+
+   return 0;
+}
+
+struct rkvop_driverdata rk3328_driverdata = {
+   .dsp_offset = 0x490,
+   .win_offset = 0xd0,
+   .features = VOP_FEATURE_OUTPUT_10BIT,
+   .set_pin_polarity = rk3328_set_pin_polarity,
+};
+
+static const struct udevice_id rk3328_vop_ids[] = {
+   {
+   .compatible = "rockchip,rk3328-vop",
+   .data = (ulong)_driverdata
+   },
+   { /* sentile */ }
+};
+
+static const struct video_ops rk3328_vop_ops = {
+};
+
+U_BOOT_DRIVER(rk3328_vop) = {
+   .name   = "rk3328_vop",
+   .id = UCLASS_VIDEO,
+   .of_match = rk3328_vop_ids,
+   .ops= _vop_ops,
+   .bind   = rk_vop_bind,
+   .probe  = rk3328_vop_probe,
+   .remove = rk3328_vop_remove,
+   .priv_auto  = sizeof(struct rk_vop_priv),
+   .flags  = DM_FLAG_PRE_RELOC | DM_FLAG_OS_PREPARE,
+};
-- 
2.25.1



[PATCH v3 12/17] video: rockchip: Add rk3328 hdmi support

2024-01-16 Thread Jagan Teki
From: Jagan Teki 

Add Rockchip RK3328 HDMI Out driver.

Signed-off-by: Jagan Teki 
---
Changes for v3:
- drop data
Changes for v2:
- none

 drivers/video/rockchip/Makefile  |   1 +
 drivers/video/rockchip/rk3328_hdmi.c | 126 +++
 drivers/video/rockchip/rk_hdmi.h |   3 +
 3 files changed, 130 insertions(+)
 create mode 100644 drivers/video/rockchip/rk3328_hdmi.c

diff --git a/drivers/video/rockchip/Makefile b/drivers/video/rockchip/Makefile
index 8128289cc8..4991303c73 100644
--- a/drivers/video/rockchip/Makefile
+++ b/drivers/video/rockchip/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_ROCKCHIP_RK3399) += rk3399_vop.o
 obj-$(CONFIG_DISPLAY_ROCKCHIP_EDP) += rk_edp.o
 obj-$(CONFIG_DISPLAY_ROCKCHIP_LVDS) += rk_lvds.o
 obj-hdmi-$(CONFIG_ROCKCHIP_RK3288) += rk3288_hdmi.o
+obj-hdmi-$(CONFIG_ROCKCHIP_RK3328) += rk3328_hdmi.o
 obj-hdmi-$(CONFIG_ROCKCHIP_RK3399) += rk3399_hdmi.o
 obj-$(CONFIG_DISPLAY_ROCKCHIP_HDMI) += rk_hdmi.o $(obj-hdmi-y)
 obj-mipi-$(CONFIG_ROCKCHIP_RK3288) += rk3288_mipi.o
diff --git a/drivers/video/rockchip/rk3328_hdmi.c 
b/drivers/video/rockchip/rk3328_hdmi.c
new file mode 100644
index 00..763669c09b
--- /dev/null
+++ b/drivers/video/rockchip/rk3328_hdmi.c
@@ -0,0 +1,126 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2023 Edgeble AI Technologies Pvt. Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "rk_hdmi.h"
+
+#define RK3328_IO_3V_DOMAIN  (7 << (9 + 16))
+#define RK3328_IO_5V_DOMAIN  ((7 << 9) | (3 << (9 + 16)))
+#define RK3328_IO_DDC_IN_MSK ((3 << 10) | (3 << (10 + 16)))
+#define RK3328_IO_CTRL_BY_HDMI   ((1 << 13) | (1 << (13 + 16)))
+
+static int rk3328_hdmi_enable(struct udevice *dev, int panel_bpp,
+ const struct display_timing *edid)
+{
+   struct rk_hdmi_priv *priv = dev_get_priv(dev);
+
+   return dw_hdmi_enable(>hdmi, edid);
+}
+
+static int rk3328_dw_hdmi_phy_cfg(struct dw_hdmi *hdmi, uint pixclock)
+{
+   struct rk_hdmi_priv *priv = container_of(hdmi, struct rk_hdmi_priv, 
hdmi);
+   int ret;
+
+   ret = generic_phy_init(>phy);
+   if (ret) {
+   printf("failed to init phy (ret=%d)\n", ret);
+   return ret;
+   }
+
+   ret = generic_phy_power_on(>phy);
+   if (ret) {
+   printf("failed to power on phy (ret=%d)\n", ret);
+   return ret;
+   }
+
+   return 0;
+}
+
+static void rk3328_dw_hdmi_setup_hpd(struct dw_hdmi *hdmi)
+{
+   struct rk_hdmi_priv *priv = container_of(hdmi, struct rk_hdmi_priv, 
hdmi);
+   struct rk3328_grf_regs *grf = priv->grf;
+
+   writel(RK3328_IO_DDC_IN_MSK, >soc_con[2]);
+   writel(RK3328_IO_CTRL_BY_HDMI, >soc_con[3]);
+}
+
+static void rk3328_dw_hdmi_read_hpd(struct dw_hdmi *hdmi, bool hpd_status)
+{
+   struct rk_hdmi_priv *priv = container_of(hdmi, struct rk_hdmi_priv, 
hdmi);
+   struct rk3328_grf_regs *grf = priv->grf;
+
+   if (hpd_status)
+   writel(RK3328_IO_5V_DOMAIN, >soc_con[4]);
+   else
+   writel(RK3328_IO_3V_DOMAIN, >soc_con[4]);
+}
+
+static const struct dw_hdmi_phy_ops dw_hdmi_rk3328_phy_ops = {
+   .phy_set = rk3328_dw_hdmi_phy_cfg,
+   .setup_hpd = rk3328_dw_hdmi_setup_hpd,
+   .read_hpd = rk3328_dw_hdmi_read_hpd,
+};
+
+static int rk3328_hdmi_of_to_plat(struct udevice *dev)
+{
+   struct rk_hdmi_priv *priv = dev_get_priv(dev);
+   struct dw_hdmi *hdmi = >hdmi;
+
+   hdmi->i2c_clk_high = 0x71;
+   hdmi->i2c_clk_low = 0x76;
+
+   rk_hdmi_of_to_plat(dev);
+
+   hdmi->ops = _hdmi_rk3328_phy_ops;
+
+   return 0;
+}
+
+static int rk3328_hdmi_probe(struct udevice *dev)
+{
+   struct rk_hdmi_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   ret = generic_phy_get_by_name(dev, "hdmi", >phy);
+   if (ret) {
+   printf("failed to get hdmi phy\n");
+   return ret;
+   };
+
+   ret = rk_hdmi_probe(dev);
+   if (ret) {
+   printf("failed to probe rk hdmi\n");
+   return ret;
+   }
+
+   return 0;
+}
+
+static const struct dm_display_ops rk3328_hdmi_ops = {
+   .read_edid = rk_hdmi_read_edid,
+   .enable = rk3328_hdmi_enable,
+};
+
+static const struct udevice_id rk3328_hdmi_ids[] = {
+   { .compatible = "rockchip,rk3328-dw-hdmi" },
+   { }
+};
+
+U_BOOT_DRIVER(rk3328_hdmi_rockchip) = {
+   .name = "rk3328_hdmi_rockchip",
+   .id = UCLASS_DISPLAY,
+   .of_match = rk3328_hdmi_ids,
+   .ops = _hdmi_ops,
+   .of_to_plat = rk3328_hdmi_of_to_plat,
+   .probe = rk3328_hdmi_probe,
+   .priv_auto  = sizeof(struct rk_hdmi_priv),
+};
diff --git a/drivers/video/rockchip/rk_hdmi.h b/drivers/video/rockchip/rk_hdmi.h
index 200dbaea74..dcfba3d3d7 100644
--- a/drivers/video/rockchip/rk_hdmi.h
+++ b/drivers/video/rockchip/rk_hdmi.h
@@ -6,6 +6,8 @@
 #ifndef __RK_HDMI_H__
 #define __RK_HDMI_H__
 

[PATCH v3 11/17] phy: rockchip: Add Rockchip INNO HDMI PHY driver

2024-01-16 Thread Jagan Teki
From: Jagan Teki 

Add Rockchip INNO HDMI PHY driver for RK3328.

Reference from linux-next phy-rockchip-inno-hdmi driver.

Signed-off-by: Jagan Teki 
---
Changes for v3, v2:
- none

 drivers/phy/rockchip/Kconfig  |   7 +
 drivers/phy/rockchip/Makefile |   1 +
 drivers/phy/rockchip/phy-rockchip-inno-hdmi.c | 885 ++
 3 files changed, 893 insertions(+)
 create mode 100644 drivers/phy/rockchip/phy-rockchip-inno-hdmi.c

diff --git a/drivers/phy/rockchip/Kconfig b/drivers/phy/rockchip/Kconfig
index 0247d93ab4..80128335d5 100644
--- a/drivers/phy/rockchip/Kconfig
+++ b/drivers/phy/rockchip/Kconfig
@@ -12,6 +12,13 @@ config PHY_ROCKCHIP_INNO_DSIDPHY
help
  Support for Rockchip MIPI DPHY with Innosilicon IP block.
 
+config PHY_ROCKCHIP_INNO_HDMI
+   bool "Rockchip INNO HDMI PHY Driver"
+   depends on ARCH_ROCKCHIP
+   select PHY
+   help
+ Enable this to support the Rockchip Innosilicon HDMI PHY.
+
 config PHY_ROCKCHIP_INNO_USB2
bool "Rockchip INNO USB2PHY Driver"
depends on ARCH_ROCKCHIP
diff --git a/drivers/phy/rockchip/Makefile b/drivers/phy/rockchip/Makefile
index 7fdbd10797..0420017425 100644
--- a/drivers/phy/rockchip/Makefile
+++ b/drivers/phy/rockchip/Makefile
@@ -3,6 +3,7 @@
 # Copyright (C) 2020 Amarula Solutions(India)
 #
 
+obj-$(CONFIG_PHY_ROCKCHIP_INNO_HDMI)   += phy-rockchip-inno-hdmi.o
 obj-$(CONFIG_PHY_ROCKCHIP_INNO_USB2)   += phy-rockchip-inno-usb2.o
 obj-$(CONFIG_PHY_ROCKCHIP_NANENG_COMBOPHY) += phy-rockchip-naneng-combphy.o
 obj-$(CONFIG_PHY_ROCKCHIP_PCIE)+= phy-rockchip-pcie.o
diff --git a/drivers/phy/rockchip/phy-rockchip-inno-hdmi.c 
b/drivers/phy/rockchip/phy-rockchip-inno-hdmi.c
new file mode 100644
index 00..3bb1a254ff
--- /dev/null
+++ b/drivers/phy/rockchip/phy-rockchip-inno-hdmi.c
@@ -0,0 +1,885 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Rockchip Innosilicon HDMI PHY
+ *
+ * Copyright (c) 2023 Edgeble AI Technologies Pvt. Ltd.
+ * Copyright (c) 2017 Rockchip Electronics Co. Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define UPDATE(x, h, l)(((x) << (l)) & GENMASK((h), (l)))
+
+/* REG: 0x01 */
+#define RK3328_BYPASS_RXSENSE_EN   BIT(2)
+#define RK3328_BYPASS_POWERON_EN   BIT(1)
+#define RK3328_BYPASS_PLLPD_EN BIT(0)
+/* REG: 0x02 */
+#define RK3328_INT_POL_HIGHBIT(7)
+#define RK3328_BYPASS_PDATA_EN BIT(4)
+#define RK3328_PDATA_ENBIT(0)
+/* REG:0x05 */
+#define RK3328_INT_TMDS_CLK(x) UPDATE(x, 7, 4)
+#define RK3328_INT_TMDS_D2(x)  UPDATE(x, 3, 0)
+/* REG:0x07 */
+#define RK3328_INT_TMDS_D1(x)  UPDATE(x, 7, 4)
+#define RK3328_INT_TMDS_D0(x)  UPDATE(x, 3, 0)
+/* for all RK3328_INT_TMDS_*, ESD_DET as defined in 0xc8-0xcb */
+#define RK3328_INT_AGND_LOW_PULSE_LOCKED   BIT(3)
+#define RK3328_INT_RXSENSE_LOW_PULSE_LOCKEDBIT(2)
+#define RK3328_INT_VSS_AGND_ESD_DETBIT(1)
+#define RK3328_INT_AGND_VSS_ESD_DETBIT(0)
+/* REG: 0xa0 */
+#define RK3328_PCLK_VCO_DIV_5_MASK BIT(1)
+#define RK3328_PCLK_VCO_DIV_5(x)   UPDATE(x, 1, 1)
+#define RK3328_PRE_PLL_POWER_DOWN  BIT(0)
+/* REG: 0xa1 */
+#define RK3328_PRE_PLL_PRE_DIV_MASKGENMASK(5, 0)
+#define RK3328_PRE_PLL_PRE_DIV(x)  UPDATE(x, 5, 0)
+/* REG: 0xa2 */
+/* unset means center spread */
+#define RK3328_SPREAD_SPECTRUM_MOD_DOWNBIT(7)
+#define RK3328_SPREAD_SPECTRUM_MOD_DISABLE BIT(6)
+#define RK3328_PRE_PLL_FRAC_DIV_DISABLEUPDATE(3, 5, 4)
+#define RK3328_PRE_PLL_FB_DIV_11_8_MASKGENMASK(3, 0)
+#define RK3328_PRE_PLL_FB_DIV_11_8(x)  UPDATE((x) >> 8, 3, 0)
+/* REG: 0xa3 */
+#define RK3328_PRE_PLL_FB_DIV_7_0(x)   UPDATE(x, 7, 0)
+/* REG: 0xa4*/
+#define RK3328_PRE_PLL_TMDSCLK_DIV_C_MASK  GENMASK(1, 0)
+#define RK3328_PRE_PLL_TMDSCLK_DIV_C(x)UPDATE(x, 1, 0)
+#define RK3328_PRE_PLL_TMDSCLK_DIV_B_MASK  GENMASK(3, 2)
+#define RK3328_PRE_PLL_TMDSCLK_DIV_B(x)UPDATE(x, 3, 2)
+#define RK3328_PRE_PLL_TMDSCLK_DIV_A_MASK  GENMASK(5, 4)
+#define RK3328_PRE_PLL_TMDSCLK_DIV_A(x)UPDATE(x, 5, 4)
+/* REG: 0xa5 */
+#define RK3328_PRE_PLL_PCLK_DIV_B_SHIFT5
+#define RK3328_PRE_PLL_PCLK_DIV_B_MASK GENMASK(6, 5)
+#define RK3328_PRE_PLL_PCLK_DIV_B(x)   UPDATE(x, 6, 5)
+#define RK3328_PRE_PLL_PCLK_DIV_A_MASK GENMASK(4, 0)
+#define 

[PATCH v3 10/17] clk: rk3328: Add get hdmiphy clock

2024-01-16 Thread Jagan Teki
From: Jagan Teki 

Add support to get the hdmiphy clock for RK3328 PCLK_HDMIPHY.

Signed-off-by: Jagan Teki 
---
Changes for v3, v2:
- none

 drivers/clk/rockchip/clk_rk3328.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/clk/rockchip/clk_rk3328.c 
b/drivers/clk/rockchip/clk_rk3328.c
index ee7edb9d10..5bb9238abb 100644
--- a/drivers/clk/rockchip/clk_rk3328.c
+++ b/drivers/clk/rockchip/clk_rk3328.c
@@ -179,6 +179,10 @@ enum {
CLK_I2C3_DIV_CON_SHIFT  = 8,
CLK_I2C2_PLL_SEL_SHIFT  = 7,
CLK_I2C2_DIV_CON_SHIFT  = 0,
+
+   /* CLKSEL_CON40 */
+   CLK_HDMIPHY_DIV_CON_SHIFT   = 3,
+   CLK_HDMIPHY_DIV_CON_MASK= 0x7 << CLK_HDMIPHY_DIV_CON_SHIFT,
 };
 
 #define VCO_MAX_KHZ(3200 * (MHz / KHz))
@@ -661,6 +665,16 @@ static ulong rk3328_vop_set_clk(struct rk3328_clk_priv 
*priv,
 }
 #endif
 
+static ulong rk3328_hdmiphy_get_clk(struct rk3328_cru *cru)
+{
+   u32 div, con;
+
+   con = readl(>clksel_con[40]);
+   div = (con & CLK_HDMIPHY_DIV_CON_MASK) >> CLK_HDMIPHY_DIV_CON_SHIFT;
+
+   return DIV_TO_RATE(GPLL_HZ, div);
+}
+
 static ulong rk3328_clk_get_rate(struct clk *clk)
 {
struct rk3328_clk_priv *priv = dev_get_priv(clk->dev);
@@ -690,6 +704,9 @@ static ulong rk3328_clk_get_rate(struct clk *clk)
case SCLK_SPI:
rate = rk3328_spi_get_clk(priv->cru);
break;
+   case PCLK_HDMIPHY:
+   rate = rk3328_hdmiphy_get_clk(priv->cru);
+   break;
default:
return -ENOENT;
}
-- 
2.25.1



[PATCH v3 09/17] clk: rockchip: rk3328: Add VOP clk support

2024-01-16 Thread Jagan Teki
From: Jagan Teki 

VOP get and set clock would needed for VOP drivers.

Add support for it.

Signed-off-by: Jagan Teki 
---
Changes for v3:
- none
Changes for v2:
- Add DCLK get rate

 .../include/asm/arch-rockchip/cru_rk3328.h| 34 +++
 drivers/clk/rockchip/clk_rk3328.c | 88 ++-
 2 files changed, 120 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/arch-rockchip/cru_rk3328.h 
b/arch/arm/include/asm/arch-rockchip/cru_rk3328.h
index 226744d67d..4ad1d33e05 100644
--- a/arch/arm/include/asm/arch-rockchip/cru_rk3328.h
+++ b/arch/arm/include/asm/arch-rockchip/cru_rk3328.h
@@ -62,6 +62,40 @@ check_member(rk3328_cru, sdmmc_ext_con[1], 0x39c);
 enum apll_frequencies {
APLL_816_MHZ,
APLL_600_MHZ,
+
+   /* CRU_CLK_SEL37_CON */
+   ACLK_VIO_PLL_SEL_CPLL   = 0,
+   ACLK_VIO_PLL_SEL_GPLL   = 1,
+   ACLK_VIO_PLL_SEL_HDMIPHY= 2,
+   ACLK_VIO_PLL_SEL_USB480M= 3,
+   ACLK_VIO_PLL_SEL_SHIFT  = 6,
+   ACLK_VIO_PLL_SEL_MASK   = 3 << ACLK_VIO_PLL_SEL_SHIFT,
+   ACLK_VIO_DIV_CON_SHIFT  = 0,
+   ACLK_VIO_DIV_CON_MASK   = 0x1f << ACLK_VIO_DIV_CON_SHIFT,
+   HCLK_VIO_DIV_CON_SHIFT  = 8,
+   HCLK_VIO_DIV_CON_MASK   = 0x1f << HCLK_VIO_DIV_CON_SHIFT,
+
+   /* CRU_CLK_SEL39_CON */
+   ACLK_VOP_PLL_SEL_CPLL   = 0,
+   ACLK_VOP_PLL_SEL_GPLL   = 1,
+   ACLK_VOP_PLL_SEL_HDMIPHY= 2,
+   ACLK_VOP_PLL_SEL_USB480M= 3,
+   ACLK_VOP_PLL_SEL_SHIFT  = 6,
+   ACLK_VOP_PLL_SEL_MASK   = 3 << ACLK_VOP_PLL_SEL_SHIFT,
+   ACLK_VOP_DIV_CON_SHIFT  = 0,
+   ACLK_VOP_DIV_CON_MASK   = 0x1f << ACLK_VOP_DIV_CON_SHIFT,
+
+   /* CRU_CLK_SEL40_CON */
+   DCLK_LCDC_PLL_SEL_GPLL  = 0,
+   DCLK_LCDC_PLL_SEL_CPLL  = 1,
+   DCLK_LCDC_PLL_SEL_SHIFT = 0,
+   DCLK_LCDC_PLL_SEL_MASK  = 1 << DCLK_LCDC_PLL_SEL_SHIFT,
+   DCLK_LCDC_SEL_HDMIPHY   = 0,
+   DCLK_LCDC_SEL_PLL   = 1,
+   DCLK_LCDC_SEL_SHIFT = 1,
+   DCLK_LCDC_SEL_MASK  = 1 << DCLK_LCDC_SEL_SHIFT,
+   DCLK_LCDC_DIV_CON_SHIFT = 8,
+   DCLK_LCDC_DIV_CON_MASK  = 0xFf << DCLK_LCDC_DIV_CON_SHIFT,
 };
 
 void rk3328_configure_cpu(struct rk3328_cru *cru,
diff --git a/drivers/clk/rockchip/clk_rk3328.c 
b/drivers/clk/rockchip/clk_rk3328.c
index ef97381f0e..ee7edb9d10 100644
--- a/drivers/clk/rockchip/clk_rk3328.c
+++ b/drivers/clk/rockchip/clk_rk3328.c
@@ -581,6 +581,86 @@ static ulong rk3328_spi_set_clk(struct rk3328_cru *cru, 
uint hz)
return rk3328_spi_get_clk(cru);
 }
 
+#ifndef CONFIG_SPL_BUILD
+static ulong rk3328_vop_get_clk(struct rk3328_clk_priv *priv, ulong clk_id)
+{
+   struct rk3328_cru *cru = priv->cru;
+   u32 div, con, parent;
+
+   switch (clk_id) {
+   case ACLK_VOP_PRE:
+   con = readl(>clksel_con[39]);
+   div = (con & ACLK_VOP_DIV_CON_MASK) >> ACLK_VOP_DIV_CON_SHIFT;
+   parent = GPLL_HZ;
+   break;
+   case ACLK_VIO_PRE:
+   con = readl(>clksel_con[37]);
+   div = (con & ACLK_VIO_DIV_CON_MASK) >> ACLK_VIO_DIV_CON_SHIFT;
+   parent = GPLL_HZ;
+   break;
+   case DCLK_LCDC:
+   con = readl(>clksel_con[40]);
+   div = (con & DCLK_LCDC_DIV_CON_MASK) >> DCLK_LCDC_DIV_CON_SHIFT;
+   parent = GPLL_HZ;
+   break;
+   default:
+   printf("%s: Unsupported vop get clk#%ld\n", __func__, clk_id);
+   return -ENOENT;
+   }
+
+   return DIV_TO_RATE(parent, div);
+}
+
+static ulong rk3328_vop_set_clk(struct rk3328_clk_priv *priv,
+   ulong clk_id, uint hz)
+{
+   struct rk3328_cru *cru = priv->cru;
+   int src_clk_div;
+   u32 con, parent;
+
+   src_clk_div = DIV_ROUND_UP(GPLL_HZ, hz);
+   assert(src_clk_div - 1 < 31);
+
+   switch (clk_id) {
+   case ACLK_VOP_PRE:
+   rk_clrsetreg(>clksel_con[39],
+ACLK_VOP_PLL_SEL_MASK | ACLK_VOP_DIV_CON_MASK,
+ACLK_VOP_PLL_SEL_CPLL << ACLK_VOP_PLL_SEL_SHIFT |
+(src_clk_div - 1) << ACLK_VOP_DIV_CON_SHIFT);
+   break;
+   case ACLK_VIO_PRE:
+   rk_clrsetreg(>clksel_con[37],
+ACLK_VIO_PLL_SEL_MASK | ACLK_VIO_DIV_CON_MASK,
+ACLK_VIO_PLL_SEL_CPLL << ACLK_VIO_PLL_SEL_SHIFT |
+(src_clk_div - 1) << ACLK_VIO_DIV_CON_SHIFT);
+   break;
+   case DCLK_LCDC:
+   con = readl(>clksel_con[40]);
+   con = (con & DCLK_LCDC_SEL_MASK) >> DCLK_LCDC_SEL_SHIFT;
+   if (con) {
+   parent = readl(>clksel_con[40]);
+   parent = 

[PATCH v3 08/17] video: rockchip: vop: Add dsp offset support

2024-01-16 Thread Jagan Teki
From: Jagan Teki 

Unlike RK3399, RK3288 the Newer Rockchip SoC's like RK3328 have
different offsets for dsp registers.

Group the dsp register set via dsp_regs pointers so that dsp_offset
would point the dsp_regs to access for any changes in the offset value.

Signed-off-by: Jagan Teki 
---
Changes for v3, v2:
- none

 drivers/video/rockchip/rk_vop.c | 14 --
 drivers/video/rockchip/rk_vop.h |  2 ++
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/video/rockchip/rk_vop.c b/drivers/video/rockchip/rk_vop.c
index b719a4e4ea..acc02e5d7c 100644
--- a/drivers/video/rockchip/rk_vop.c
+++ b/drivers/video/rockchip/rk_vop.c
@@ -165,6 +165,7 @@ static void rkvop_mode_set(struct udevice *dev,
 {
struct rk_vop_priv *priv = dev_get_priv(dev);
struct rk3288_vop *regs = priv->regs;
+   struct rk3288_vop *dsp_regs = priv->regs + priv->dsp_offset;
struct rkvop_driverdata *data =
(struct rkvop_driverdata *)dev_get_driver_data(dev);
 
@@ -198,27 +199,27 @@ static void rkvop_mode_set(struct udevice *dev,
 
writel(V_HSYNC(hsync_len) |
   V_HORPRD(hsync_len + hback_porch + hactive + hfront_porch),
-   >dsp_htotal_hs_end);
+   _regs->dsp_htotal_hs_end);
 
writel(V_HEAP(hsync_len + hback_porch + hactive) |
   V_HASP(hsync_len + hback_porch),
-  >dsp_hact_st_end);
+  _regs->dsp_hact_st_end);
 
writel(V_VSYNC(vsync_len) |
   V_VERPRD(vsync_len + vback_porch + vactive + vfront_porch),
-  >dsp_vtotal_vs_end);
+  _regs->dsp_vtotal_vs_end);
 
writel(V_VAEP(vsync_len + vback_porch + vactive)|
   V_VASP(vsync_len + vback_porch),
-  >dsp_vact_st_end);
+  _regs->dsp_vact_st_end);
 
writel(V_HEAP(hsync_len + hback_porch + hactive) |
   V_HASP(hsync_len + hback_porch),
-  >post_dsp_hact_info);
+  _regs->post_dsp_hact_info);
 
writel(V_VAEP(vsync_len + vback_porch + vactive)|
   V_VASP(vsync_len + vback_porch),
-  >post_dsp_vact_info);
+  _regs->post_dsp_vact_info);
 
writel(0x01, >reg_cfg_done); /* enable reg config */
 }
@@ -452,6 +453,7 @@ int rk_vop_probe(struct udevice *dev)
 
priv->regs = dev_read_addr_ptr(dev);
priv->win_offset = ops->win_offset;
+   priv->dsp_offset = ops->dsp_offset;
 
/*
 * Try all the ports until we find one that works. In practice this
diff --git a/drivers/video/rockchip/rk_vop.h b/drivers/video/rockchip/rk_vop.h
index 909f5602e5..eba68d87c4 100644
--- a/drivers/video/rockchip/rk_vop.h
+++ b/drivers/video/rockchip/rk_vop.h
@@ -12,6 +12,7 @@ struct rk_vop_priv {
void *grf;
void *regs;
int win_offset;
+   int dsp_offset;
 };
 
 enum vop_features {
@@ -20,6 +21,7 @@ enum vop_features {
 
 struct rkvop_driverdata {
int win_offset;
+   int dsp_offset;
/* configuration */
u32 features;
/* block-specific setters/getters */
-- 
2.25.1



[PATCH v3 07/17] video: rockchip: vop: Add win offset support

2024-01-16 Thread Jagan Teki
From: Jagan Teki 

Unlike RK3399, RK3288 the Newer Rockchip SoC's like RK3328 have
different offsets for win registers.

Group the win register set via win_regs pointers so that win_offset
would point the win_regs to access for any changes in the offset value.

Signed-off-by: Jagan Teki 
---
Changes for v3, v2:
- none

 drivers/video/rockchip/rk_vop.c | 22 +-
 drivers/video/rockchip/rk_vop.h |  2 ++
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/video/rockchip/rk_vop.c b/drivers/video/rockchip/rk_vop.c
index 158ba7cbf6..b719a4e4ea 100644
--- a/drivers/video/rockchip/rk_vop.c
+++ b/drivers/video/rockchip/rk_vop.c
@@ -46,6 +46,7 @@ static void rkvop_enable(struct udevice *dev, ulong fbbase,
 {
struct rk_vop_priv *priv = dev_get_priv(dev);
struct rk3288_vop *regs = priv->regs;
+   struct rk3288_vop *win_regs = priv->regs + priv->win_offset;
u32 lb_mode;
u32 rgb_mode;
u32 hactive = edid->hactive.typ;
@@ -53,32 +54,32 @@ static void rkvop_enable(struct udevice *dev, ulong fbbase,
int ret;
 
writel(V_ACT_WIDTH(hactive - 1) | V_ACT_HEIGHT(vactive - 1),
-  >win0_act_info);
+  _regs->win0_act_info);
 
writel(V_DSP_XST(edid->hsync_len.typ + edid->hback_porch.typ) |
   V_DSP_YST(edid->vsync_len.typ + edid->vback_porch.typ),
-  >win0_dsp_st);
+  _regs->win0_dsp_st);
 
writel(V_DSP_WIDTH(hactive - 1) |
V_DSP_HEIGHT(vactive - 1),
-   >win0_dsp_info);
+   _regs->win0_dsp_info);
 
-   clrsetbits_le32(>win0_color_key, M_WIN0_KEY_EN | M_WIN0_KEY_COLOR,
+   clrsetbits_le32(_regs->win0_color_key, M_WIN0_KEY_EN | 
M_WIN0_KEY_COLOR,
V_WIN0_KEY_EN(0) | V_WIN0_KEY_COLOR(0));
 
switch (fb_bits_per_pixel) {
case 16:
rgb_mode = RGB565;
-   writel(V_RGB565_VIRWIDTH(hactive), >win0_vir);
+   writel(V_RGB565_VIRWIDTH(hactive), _regs->win0_vir);
break;
case 24:
rgb_mode = RGB888;
-   writel(V_RGB888_VIRWIDTH(hactive), >win0_vir);
+   writel(V_RGB888_VIRWIDTH(hactive), _regs->win0_vir);
break;
case 32:
default:
rgb_mode = ARGB;
-   writel(V_ARGB888_VIRWIDTH(hactive), >win0_vir);
+   writel(V_ARGB888_VIRWIDTH(hactive), _regs->win0_vir);
break;
}
 
@@ -91,12 +92,12 @@ static void rkvop_enable(struct udevice *dev, ulong fbbase,
else
lb_mode = LB_RGB_1280X8;
 
-   clrsetbits_le32(>win0_ctrl0,
+   clrsetbits_le32(_regs->win0_ctrl0,
M_WIN0_LB_MODE | M_WIN0_DATA_FMT | M_WIN0_EN,
V_WIN0_LB_MODE(lb_mode) | V_WIN0_DATA_FMT(rgb_mode) |
V_WIN0_EN(1));
 
-   writel(fbbase, >win0_yrgb_mst);
+   writel(fbbase, _regs->win0_yrgb_mst);
writel(0x01, >reg_cfg_done); /* enable reg config */
 
ret = reset_assert(dclk_rst);
@@ -415,6 +416,8 @@ int rk_vop_probe(struct udevice *dev)
 {
struct video_uc_plat *plat = dev_get_uclass_plat(dev);
struct rk_vop_priv *priv = dev_get_priv(dev);
+   struct rkvop_driverdata *ops =
+   (struct rkvop_driverdata *)dev_get_driver_data(dev);
int ret = 0;
ofnode port, node;
struct reset_ctl ahb_rst;
@@ -448,6 +451,7 @@ int rk_vop_probe(struct udevice *dev)
 #endif
 
priv->regs = dev_read_addr_ptr(dev);
+   priv->win_offset = ops->win_offset;
 
/*
 * Try all the ports until we find one that works. In practice this
diff --git a/drivers/video/rockchip/rk_vop.h b/drivers/video/rockchip/rk_vop.h
index 0528fb23f5..909f5602e5 100644
--- a/drivers/video/rockchip/rk_vop.h
+++ b/drivers/video/rockchip/rk_vop.h
@@ -11,6 +11,7 @@
 struct rk_vop_priv {
void *grf;
void *regs;
+   int win_offset;
 };
 
 enum vop_features {
@@ -18,6 +19,7 @@ enum vop_features {
 };
 
 struct rkvop_driverdata {
+   int win_offset;
/* configuration */
u32 features;
/* block-specific setters/getters */
-- 
2.25.1



[PATCH v3 06/17] video: rockchip: vop: Simplify rkvop_enable

2024-01-16 Thread Jagan Teki
From: Jagan Teki 

Get the regs from priv pointer instead of passing it an argument.

This would simplify the code and better readability.

Signed-off-by: Jagan Teki 
---
Changes for v3, v2:
- none

 drivers/video/rockchip/rk_vop.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/video/rockchip/rk_vop.c b/drivers/video/rockchip/rk_vop.c
index c514e2a0e4..158ba7cbf6 100644
--- a/drivers/video/rockchip/rk_vop.c
+++ b/drivers/video/rockchip/rk_vop.c
@@ -39,11 +39,13 @@ enum vop_pol {
DCLK_INVERT= 3
 };
 
-static void rkvop_enable(struct udevice *dev, struct rk3288_vop *regs, ulong 
fbbase,
+static void rkvop_enable(struct udevice *dev, ulong fbbase,
 int fb_bits_per_pixel,
 const struct display_timing *edid,
 struct reset_ctl *dclk_rst)
 {
+   struct rk_vop_priv *priv = dev_get_priv(dev);
+   struct rk3288_vop *regs = priv->regs;
u32 lb_mode;
u32 rgb_mode;
u32 hactive = edid->hactive.typ;
@@ -243,9 +245,7 @@ static void rkvop_mode_set(struct udevice *dev,
 static int rk_display_init(struct udevice *dev, ulong fbbase, ofnode ep_node)
 {
struct video_priv *uc_priv = dev_get_uclass_priv(dev);
-   struct rk_vop_priv *priv = dev_get_priv(dev);
int vop_id, remote_vop_id;
-   struct rk3288_vop *regs = priv->regs;
struct display_timing timing;
struct udevice *disp;
int ret;
@@ -380,7 +380,7 @@ static int rk_display_init(struct udevice *dev, ulong 
fbbase, ofnode ep_node)
return ret;
}
 
-   rkvop_enable(dev, regs, fbbase, 1 << l2bpp, , _rst);
+   rkvop_enable(dev, fbbase, 1 << l2bpp, , _rst);
 
ret = display_enable(disp, 1 << l2bpp, );
if (ret)
-- 
2.25.1



[PATCH v3 05/17] video: dw_hdmi: Add setup_hpd hook

2024-01-16 Thread Jagan Teki
From: Jagan Teki 

Add support for DW HDMI Setup HPD status.

Signed-off-by: Jagan Teki 
---
Changes for v3:
- check hdmi->ops
Changes for v2:
- none

 drivers/video/dw_hdmi.c | 3 +++
 include/dw_hdmi.h   | 1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/video/dw_hdmi.c b/drivers/video/dw_hdmi.c
index 989b7ab2db..ab4811cfc7 100644
--- a/drivers/video/dw_hdmi.c
+++ b/drivers/video/dw_hdmi.c
@@ -1061,4 +1061,7 @@ void dw_hdmi_init(struct dw_hdmi *hdmi)
 
/* enable i2c client nack % arbitration error irq */
hdmi_write(hdmi, ~0x44, HDMI_I2CM_CTLINT);
+
+   if (hdmi->ops && hdmi->ops->setup_hpd)
+   hdmi->ops->setup_hpd(hdmi);
 }
diff --git a/include/dw_hdmi.h b/include/dw_hdmi.h
index a1f0e64507..f4d66edace 100644
--- a/include/dw_hdmi.h
+++ b/include/dw_hdmi.h
@@ -539,6 +539,7 @@ struct dw_hdmi;
 struct dw_hdmi_phy_ops {
int (*phy_set)(struct dw_hdmi *hdmi, uint mpixelclock);
void (*read_hpd)(struct dw_hdmi *hdmi, bool hdp_status);
+   void (*setup_hpd)(struct dw_hdmi *hdmi);
 };
 
 struct dw_hdmi {
-- 
2.25.1



[PATCH v3 04/17] video: dw_hdmi: Add read_hpd hook

2024-01-16 Thread Jagan Teki
From: Jagan Teki 

Add support for DW HDMI Read HPD status.

Signed-off-by: Jagan Teki 
---
Changes for v3:
- check hdmi->ops
Changes for v2:
- none

 drivers/video/dw_hdmi.c | 3 +++
 include/dw_hdmi.h   | 1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/video/dw_hdmi.c b/drivers/video/dw_hdmi.c
index 3a3b9b7a21..989b7ab2db 100644
--- a/drivers/video/dw_hdmi.c
+++ b/drivers/video/dw_hdmi.c
@@ -946,6 +946,9 @@ int dw_hdmi_detect_hpd(struct dw_hdmi *hdmi)
return -ENODEV;
}
 
+   if (hdmi->ops && hdmi->ops->read_hpd)
+   hdmi->ops->read_hpd(hdmi, true);
+
return 0;
 }
 
diff --git a/include/dw_hdmi.h b/include/dw_hdmi.h
index ba2ce5ea7f..a1f0e64507 100644
--- a/include/dw_hdmi.h
+++ b/include/dw_hdmi.h
@@ -538,6 +538,7 @@ struct dw_hdmi;
 
 struct dw_hdmi_phy_ops {
int (*phy_set)(struct dw_hdmi *hdmi, uint mpixelclock);
+   void (*read_hpd)(struct dw_hdmi *hdmi, bool hdp_status);
 };
 
 struct dw_hdmi {
-- 
2.25.1



[PATCH v3 03/17] video: dw_hdmi: Extend the HPD detection

2024-01-16 Thread Jagan Teki
From: Jagan Teki 

HPD detection on some DW HDMIdesigned SoC's would need to read and
setup the HPD status explicitly.

So, extend the HPD detection code by adding the dw_hdmi_detect_hpd
function and move the default detection code caller there.

The new read and setup hdp will integrate the same function in
later patches.

Signed-off-by: Jagan Teki 
---
Changes for v3, v2:
- none

 drivers/video/dw_hdmi.c | 13 +
 drivers/video/rockchip/rk_hdmi.c|  8 +++-
 drivers/video/sunxi/sunxi_dw_hdmi.c |  8 +++-
 include/dw_hdmi.h   |  1 +
 4 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/video/dw_hdmi.c b/drivers/video/dw_hdmi.c
index 4914ba6146..3a3b9b7a21 100644
--- a/drivers/video/dw_hdmi.c
+++ b/drivers/video/dw_hdmi.c
@@ -936,6 +936,19 @@ int dw_hdmi_phy_wait_for_hpd(struct dw_hdmi *hdmi)
return -1;
 }
 
+int dw_hdmi_detect_hpd(struct dw_hdmi *hdmi)
+{
+   int ret;
+
+   ret = dw_hdmi_phy_wait_for_hpd(hdmi);
+   if (ret < 0) {
+   debug("hdmi can not get hpd signal\n");
+   return -ENODEV;
+   }
+
+   return 0;
+}
+
 void dw_hdmi_phy_init(struct dw_hdmi *hdmi)
 {
/* enable phy i2cm done irq */
diff --git a/drivers/video/rockchip/rk_hdmi.c b/drivers/video/rockchip/rk_hdmi.c
index d5b5a529d2..16f6303513 100644
--- a/drivers/video/rockchip/rk_hdmi.c
+++ b/drivers/video/rockchip/rk_hdmi.c
@@ -114,11 +114,9 @@ int rk_hdmi_probe(struct udevice *dev)
dw_hdmi_init(hdmi);
dw_hdmi_phy_init(hdmi);
 
-   ret = dw_hdmi_phy_wait_for_hpd(hdmi);
-   if (ret < 0) {
-   debug("hdmi can not get hpd signal\n");
-   return -1;
-   }
+   ret = dw_hdmi_detect_hpd(hdmi);
+   if (ret < 0)
+   return ret;
 
return 0;
 }
diff --git a/drivers/video/sunxi/sunxi_dw_hdmi.c 
b/drivers/video/sunxi/sunxi_dw_hdmi.c
index 986e69d66b..a5e8d39e98 100644
--- a/drivers/video/sunxi/sunxi_dw_hdmi.c
+++ b/drivers/video/sunxi/sunxi_dw_hdmi.c
@@ -358,11 +358,9 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev)
 
sunxi_dw_hdmi_phy_init(>hdmi);
 
-   ret = dw_hdmi_phy_wait_for_hpd(>hdmi);
-   if (ret < 0) {
-   debug("hdmi can not get hpd signal\n");
-   return -1;
-   }
+   ret = dw_hdmi_detect_hpd(>hdmi);
+   if (ret < 0)
+   return ret;
 
dw_hdmi_init(>hdmi);
 
diff --git a/include/dw_hdmi.h b/include/dw_hdmi.h
index 17bdd2dbf9..ba2ce5ea7f 100644
--- a/include/dw_hdmi.h
+++ b/include/dw_hdmi.h
@@ -562,5 +562,6 @@ void dw_hdmi_phy_init(struct dw_hdmi *hdmi);
 int dw_hdmi_enable(struct dw_hdmi *hdmi, const struct display_timing *edid);
 int dw_hdmi_read_edid(struct dw_hdmi *hdmi, u8 *buf, int buf_size);
 void dw_hdmi_init(struct dw_hdmi *hdmi);
+int dw_hdmi_detect_hpd(struct dw_hdmi *hdmi);
 
 #endif
-- 
2.25.1



[PATCH v3 02/17] video: dw_hdmi: Add Vendor PHY handling

2024-01-16 Thread Jagan Teki
From: Jagan Teki 

DW HDMI support Vendor PHY like Rockchip RK3328 Inno HDMI PHY.

Extend the vendor phy handling by adding platform phy hooks.

Signed-off-by: Jagan Teki 
---
Changes for v3:
- drop data
- assign ops directly
Changes for v2:
- fix meson cfg

 drivers/video/dw_hdmi.c | 10 +-
 drivers/video/meson/meson_dw_hdmi.c |  6 +-
 drivers/video/rockchip/rk_hdmi.c|  1 -
 drivers/video/sunxi/sunxi_dw_hdmi.c |  6 +-
 include/dw_hdmi.h   |  8 +++-
 5 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/video/dw_hdmi.c b/drivers/video/dw_hdmi.c
index c4fbb18294..4914ba6146 100644
--- a/drivers/video/dw_hdmi.c
+++ b/drivers/video/dw_hdmi.c
@@ -988,7 +988,7 @@ int dw_hdmi_enable(struct dw_hdmi *hdmi, const struct 
display_timing *edid)
 
hdmi_av_composer(hdmi, edid);
 
-   ret = hdmi->phy_set(hdmi, edid->pixelclock.typ);
+   ret = hdmi->ops->phy_set(hdmi, edid->pixelclock.typ);
if (ret)
return ret;
 
@@ -1009,10 +1009,18 @@ int dw_hdmi_enable(struct dw_hdmi *hdmi, const struct 
display_timing *edid)
return 0;
 }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_synopsys_phy_ops = {
+   .phy_set = dw_hdmi_phy_cfg,
+};
+
 void dw_hdmi_init(struct dw_hdmi *hdmi)
 {
uint ih_mute;
 
+   /* hook Synopsys PHYs ops */
+   if (!hdmi->ops)
+   hdmi->ops = _hdmi_synopsys_phy_ops;
+
/*
 * boot up defaults are:
 * hdmi_ih_mute   = 0x03 (disabled)
diff --git a/drivers/video/meson/meson_dw_hdmi.c 
b/drivers/video/meson/meson_dw_hdmi.c
index 5db01904b5..259af1b457 100644
--- a/drivers/video/meson/meson_dw_hdmi.c
+++ b/drivers/video/meson/meson_dw_hdmi.c
@@ -375,6 +375,10 @@ static int meson_dw_hdmi_wait_hpd(struct dw_hdmi *hdmi)
return -ETIMEDOUT;
 }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_meson_phy_ops = {
+   .phy_set = meson_dw_hdmi_phy_init,
+};
+
 static int meson_dw_hdmi_probe(struct udevice *dev)
 {
struct meson_dw_hdmi *priv = dev_get_priv(dev);
@@ -397,7 +401,7 @@ static int meson_dw_hdmi_probe(struct udevice *dev)
 
priv->hdmi.hdmi_data.enc_out_bus_format = MEDIA_BUS_FMT_RGB888_1X24;
priv->hdmi.hdmi_data.enc_in_bus_format = MEDIA_BUS_FMT_YUV8_1X24;
-   priv->hdmi.phy_set = meson_dw_hdmi_phy_init;
+   priv->hdmi.ops = _hdmi_meson_phy_ops;
if (meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_G12A))
priv->hdmi.reg_io_width = 1;
else {
diff --git a/drivers/video/rockchip/rk_hdmi.c b/drivers/video/rockchip/rk_hdmi.c
index b75a174489..d5b5a529d2 100644
--- a/drivers/video/rockchip/rk_hdmi.c
+++ b/drivers/video/rockchip/rk_hdmi.c
@@ -90,7 +90,6 @@ int rk_hdmi_of_to_plat(struct udevice *dev)
/* hdmi->i2c_clk_{high,low} are set up by the SoC driver */
 
hdmi->reg_io_width = 4;
-   hdmi->phy_set = dw_hdmi_phy_cfg;
 
priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 
diff --git a/drivers/video/sunxi/sunxi_dw_hdmi.c 
b/drivers/video/sunxi/sunxi_dw_hdmi.c
index 0324a050d0..986e69d66b 100644
--- a/drivers/video/sunxi/sunxi_dw_hdmi.c
+++ b/drivers/video/sunxi/sunxi_dw_hdmi.c
@@ -369,6 +369,10 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev)
return 0;
 }
 
+static const struct dw_hdmi_phy_ops dw_hdmi_sunxi_phy_ops = {
+   .phy_set = sunxi_dw_hdmi_phy_cfg,
+};
+
 static int sunxi_dw_hdmi_of_to_plat(struct udevice *dev)
 {
struct sunxi_dw_hdmi_priv *priv = dev_get_priv(dev);
@@ -379,7 +383,7 @@ static int sunxi_dw_hdmi_of_to_plat(struct udevice *dev)
hdmi->i2c_clk_high = 0xd8;
hdmi->i2c_clk_low = 0xfe;
hdmi->reg_io_width = 1;
-   hdmi->phy_set = sunxi_dw_hdmi_phy_cfg;
+   hdmi->ops = _hdmi_sunxi_phy_ops;
 
ret = reset_get_bulk(dev, >resets);
if (ret)
diff --git a/include/dw_hdmi.h b/include/dw_hdmi.h
index 8acae3839f..17bdd2dbf9 100644
--- a/include/dw_hdmi.h
+++ b/include/dw_hdmi.h
@@ -534,6 +534,12 @@ struct hdmi_data_info {
struct hdmi_vmode video_mode;
 };
 
+struct dw_hdmi;
+
+struct dw_hdmi_phy_ops {
+   int (*phy_set)(struct dw_hdmi *hdmi, uint mpixelclock);
+};
+
 struct dw_hdmi {
ulong ioaddr;
const struct hdmi_mpll_config *mpll_cfg;
@@ -543,8 +549,8 @@ struct dw_hdmi {
u8 reg_io_width;
struct hdmi_data_info hdmi_data;
struct udevice *ddc_bus;
+   const struct dw_hdmi_phy_ops *ops;
 
-   int (*phy_set)(struct dw_hdmi *hdmi, uint mpixelclock);
void (*write_reg)(struct dw_hdmi *hdmi, u8 val, int offset);
u8 (*read_reg)(struct dw_hdmi *hdmi, int offset);
 };
-- 
2.25.1



[PATCH v3 01/17] video: rockchip: hdmi: Detect hpd after controller init

2024-01-16 Thread Jagan Teki
From: Jagan Teki 

HDP is a hardware connector event, so detect the same once the
controller and attached PHY initialization are done.

Signed-off-by: Jagan Teki 
---
Changes for v3, v2:
- none

 drivers/video/rockchip/rk_hdmi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/video/rockchip/rk_hdmi.c b/drivers/video/rockchip/rk_hdmi.c
index 8dcd4d5964..b75a174489 100644
--- a/drivers/video/rockchip/rk_hdmi.c
+++ b/drivers/video/rockchip/rk_hdmi.c
@@ -112,14 +112,14 @@ int rk_hdmi_probe(struct udevice *dev)
struct dw_hdmi *hdmi = >hdmi;
int ret;
 
+   dw_hdmi_init(hdmi);
+   dw_hdmi_phy_init(hdmi);
+
ret = dw_hdmi_phy_wait_for_hpd(hdmi);
if (ret < 0) {
debug("hdmi can not get hpd signal\n");
return -1;
}
 
-   dw_hdmi_init(hdmi);
-   dw_hdmi_phy_init(hdmi);
-
return 0;
 }
-- 
2.25.1



[PATCH v3 00/17] video: dw_hdmi: Support Vendor PHY

2024-01-16 Thread Jagan Teki
From: Jagan Teki 

Unlike RK3399, Sunxi/Meson DW HDMI the new Rockchip SoC Rk3328 would
support external vendor PHY with DW HDMI chip.

Support this vendor PHY by adding new platform PHY ops via DW HDMI
driver and call the respective generic phy from platform driver code.

This series tested in RK3328 with 1080p (1920x1080) resolution.

Patch 0001/0005: Support Vendor PHY
Patch 0006/0008: VOP extension for win, dsp offsets
Patch 0009/0010: RK3328 VOP, HDMI clocks
Patch 0011:  Rockchip Inno HDMI PHY
Patch 0012:  RK3328 HDMI driver
Patch 0013:  RK3328 VOP driver
Patch 0014/0017: Enable HDMI Out for RK3328

Changes for v3:
- updated phy_ops logic
- tested in BPI-M64
- updated handoff logic for rk3328

Changes for v2:
- Use proper cfg function for meson
- Add VOP cleanup code.
- Add DCLK get rate

Linux VOP/HDMI out issues seems resolved with explicit WIN0 disable.

Any inputs?
Jagan.

Jagan Teki (17):
  video: rockchip: hdmi: Detect hpd after controller init
  video: dw_hdmi: Add Vendor PHY handling
  video: dw_hdmi: Extend the HPD detection
  video: dw_hdmi: Add read_hpd hook
  video: dw_hdmi: Add setup_hpd hook
  video: rockchip: vop: Simplify rkvop_enable
  video: rockchip: vop: Add win offset support
  video: rockchip: vop: Add dsp offset support
  clk: rockchip: rk3328: Add VOP clk support
  clk: rk3328: Add get hdmiphy clock
  phy: rockchip: Add Rockchip INNO HDMI PHY driver
  video: rockchip: Add rk3328 hdmi support
  video: rockchip: Add rk3328 vop support
  ARM: dts: rk3328: Enable VOP for bootph-all
  rockchip: Enable preconsole for rk3328
  configs: evb-rk3328: Enable vidconsole for rk3328
  configs: Enable HDMI Out for ROC-RK3328-CC

 arch/arm/dts/rk3328-u-boot.dtsi   |   4 +
 .../include/asm/arch-rockchip/cru_rk3328.h|  34 +
 arch/arm/mach-rockchip/Kconfig|   1 +
 common/Kconfig|   2 +-
 configs/roc-cc-rk3328_defconfig   |   5 +
 drivers/clk/rockchip/clk_rk3328.c | 105 ++-
 drivers/phy/rockchip/Kconfig  |   7 +
 drivers/phy/rockchip/Makefile |   1 +
 drivers/phy/rockchip/phy-rockchip-inno-hdmi.c | 885 ++
 drivers/video/dw_hdmi.c   |  29 +-
 drivers/video/meson/meson_dw_hdmi.c   |   6 +-
 drivers/video/rockchip/Makefile   |   2 +
 drivers/video/rockchip/rk3328_hdmi.c  | 126 +++
 drivers/video/rockchip/rk3328_vop.c   |  83 ++
 drivers/video/rockchip/rk_hdmi.c  |  11 +-
 drivers/video/rockchip/rk_hdmi.h  |   3 +
 drivers/video/rockchip/rk_vop.c   |  44 +-
 drivers/video/rockchip/rk_vop.h   |   4 +
 drivers/video/sunxi/sunxi_dw_hdmi.c   |  14 +-
 include/configs/evb_rk3328.h  |   5 +
 include/configs/rk3328_common.h   |   1 +
 include/dw_hdmi.h |  11 +-
 22 files changed, 1345 insertions(+), 38 deletions(-)
 create mode 100644 drivers/phy/rockchip/phy-rockchip-inno-hdmi.c
 create mode 100644 drivers/video/rockchip/rk3328_hdmi.c
 create mode 100644 drivers/video/rockchip/rk3328_vop.c

-- 
2.25.1



Re: [PATCH v5 0/4] cmd: bootefi: refactor the code for bootmgr

2024-01-16 Thread Heinrich Schuchardt

On 1/17/24 05:39, AKASHI Takahiro wrote:

This patch set is motivated by the discussion[1] regarding
CONFIG_BOOTEFI_BOOTMGR option.

# This version (v5) contains only the remaining commits.

At the end, bootefi.c will be decomposed into two parts, one for
providing the command itself and one for implementing helper functions.
EFI_LOADER will now be available without CONFIG_CMDLINE or specifically
CONFIG_CMD_BOOTEFI if invoked via bootmeth/bootstd.

Then, EFI_LOADER library side will be further split into two options
for fine-grain control:
CONFIG_EFI_BINARY_EXEC: execute UEFI binaries which are to be explicitly
 loaded by U-Boot's load commands/functions or other methods
 (like a jtag debugger?)
 It supports bootmeth_efi as well as "bootefi |hello"(/"bootm"?).

CONFIG_EFI_BOOTMGR: provide EFI boot manger functionality
 It supports bootmeth_efi_mgr as well as "bootefi bootmgr".

As such, We will no longer need CONFIG_EFI_BINARY_EXEC if we want to only
make use of the UEFI boot manger for booting a next stage OS.

Prerequisite

This patch set is based on top of the latest "master" branch.

Tests
=
* ran and passed py/efi_selftest on sandbox locally
* ran and passed py/test_efi_bootmgr on sandbox locally
* passed CI check (github pull request[2])


Thanks for rebasing. Testing on CI
https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/19342
looks good.

Best regards

Heinrich



Changes
===
v4 (Jan 17, 2024)
* rebased onto the latest master branch again

v4 (Jan 10, 2024)
* rebased onto the latest master branch
* moved binary execution portion of code (EFI_BINARY_EXEC) to
   a new file, efi_bootbin.c, instead of efi_helper.c (patch#1)

v3 (Dec 18, 2023)
* rebased onto Tom's latest next branch
* remove already-merged commits

v2 (Nov 21, 2023)
* rebased onto Tom's next branch
* remove already merged commits
* revise commit messages
* add patch #5 which was split from ex-patch#5
RFC (Oct 26, 2023)

[1] https://lists.denx.de/pipermail/u-boot/2023-October/534598.html
[2] https://dev.azure.com/u-boot/u-boot/_build/results?buildId=7760=results

AKASHI Takahiro (4):
   efi_loader: split unrelated code from efi_bootmgr.c
   efi_loader: rename BOOTEFI_BOOTMGR to EFI_BOOTMGR
   net: tftp: remove explicit efi configuration dependency
   fs: remove explicit efi configuration dependency

  boot/Kconfig |   4 +-
  boot/Makefile|   2 +-
  cmd/Kconfig  |  10 +-
  cmd/efidebug.c   |   4 +-
  fs/fs.c  |   7 +-
  include/efi_loader.h |  28 +-
  lib/efi_loader/Kconfig   |  11 +-
  lib/efi_loader/Makefile  |   3 +-
  lib/efi_loader/efi_bootbin.c | 211 +
  lib/efi_loader/efi_bootmgr.c | 488 ---
  lib/efi_loader/efi_device_path.c |   3 +-
  lib/efi_loader/efi_helper.c  | 286 ++
  net/tftp.c   |  10 +-
  test/boot/bootflow.c |   2 +-
  14 files changed, 546 insertions(+), 523 deletions(-)
  create mode 100644 lib/efi_loader/efi_bootbin.c





Re: [PATCH v3 0/2] xilinx: Update the kaslr-seed property

2024-01-16 Thread Michal Simek




On 1/17/24 04:20, Venkatesh Yadav Abbarapu wrote:

Update the kaslr-seed property and enable the config CONFIG_OF_BOARD_SETUP.

Changes in v2:
- Created macro for size variable.
- Removed malloc and created array for rng buffer.
- Added debug logs for all the apis.
Changes in v3:
- Fixed the return values.

Venkatesh Yadav Abbarapu (2):
   xilinx: board: Update the kaslr-seed property
   configs: zynqmp_kria: Enable CONFIG_OF_BOARD_SETUP

  board/xilinx/common/board.c  | 49 
  configs/xilinx_zynqmp_kria_defconfig |  1 +
  2 files changed, 50 insertions(+)



Applied.
M


Re: [PATCH v2 00/32] Qualcomm generic board support

2024-01-16 Thread Sumit Garg
On Fri, 22 Dec 2023 at 12:36, Sumit Garg  wrote:
>
> On Thu, 21 Dec 2023 at 21:08, Caleb Connolly  
> wrote:
> >
> >
> >
> > On 20/12/2023 13:07, Sumit Garg wrote:
> > > Hi Caleb,
> >
> > Hi Sumit,
> >
> > [...]
> >
> > >>
> > >> == Upstream DT ==
> > >>
> > >> All Qualcomm boards have had their devicetree files replaced with the
> > >> upstream versions. Previous patch series made the necessary driver
> > >> adjustments to fully support the upstream DT format. All future
> > >> Qualcomm boards should use upstream DTS by default.
> > >>
> > >> Once Sumit's work to import dt-rebasing has been merged, we will drop
> > >> the imported DT and bindings again.
> > >
> > > Since there is consensus building in the U-Boot community to use DT
> > > rebasing subtree, I would suggest you rebase your work on top of [1].
> > > You can take an amlogic SoC patch [2] as a reference and see
> > > corresponding value-add. I don't see the point of unnecessary churn if
> > > there is consensus we agree upon.
> >
> >
> > I designed this so that we can just delete the imported stuff once the
> > dt-rebasing series is merged. Importing a few files and deleting them
> > later is not really a big deal, so please let's not block fixing
> > Qualcomm support on this tangentially related series.
>
> Fair enough, I think I can live with that for the time being. Let me
> give this series a spin on QCS404.

Just to update here, this series doesn't boot on QCS404. Internally I
am working with Caleb to fix issues seen. One of the major issues was
to not map reserved memory ranges in U-Boot as mapping then leads to a
hang on QCS404 (see [1] for details).

[1] 
https://github.com/u-boot/u-boot/commit/881338a0c6686bbcf043275714d43080b746b17e

-Sumit

>
> >
> > Thanks,
> >
> > >
> > > [1] 
> > > https://lore.kernel.org/all/20231214135103.1606605-1-sumit.g...@linaro.org/
> > > [2] 
> > > https://lore.kernel.org/all/20231214135103.1606605-8-sumit.g...@linaro.org/
> > >
> > >>
> >
> > --
> > // Caleb (they/them)


Re: [PATCH v1] Kconfig: boot: Imply BOOTSTD_DEFAULT when BOOTSTD_FULL=y

2024-01-16 Thread Shantur Rathore
On Sat, Dec 23, 2023 at 6:53 AM Shantur Rathore  wrote:
>
> We need BOOTSTD_DEFAULT when BOOTSTD_FULL is selected.
>
> Signed-off-by: Shantur Rathore 
> ---
>
>  boot/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/boot/Kconfig b/boot/Kconfig
> index 9f5b8a0cb2..fc96aadb27 100644
> --- a/boot/Kconfig
> +++ b/boot/Kconfig
> @@ -426,6 +426,7 @@ config VPL_BOOTSTD
>  config BOOTSTD_FULL
> bool "Enhanced features for standard boot"
> default y if SANDBOX
> +   imply BOOTSTD_DEFAULTS
> help
>   This enables various useful features for standard boot, which are 
> not
>   essential for operation:
> --
> 2.40.1
>

Ping


Re: [PATCH v3] arch: arm: Kconfig: Enable BOOTSTD_FULL for Rockchip SoCs

2024-01-16 Thread Shantur Rathore
Hi Kever,

On Wed, Jan 10, 2024 at 11:58 AM Shantur Rathore  wrote:
>
> Hi Kever,
>
> On Tue, Jan 9, 2024 at 10:55 AM Kever Yang  wrote:
> >
> > Hi Shantur, Tom,
> >
> > On 2023/12/10 04:45, Tom Rini wrote:
> > > On Sat, Dec 09, 2023 at 07:49:04PM +, Shantur Rathore wrote:
> > >> On Sat, Dec 9, 2023 at 7:18 PM Tom Rini  wrote:
> > >>> On Fri, Dec 08, 2023 at 10:52:02AM +, Shantur Rathore wrote:
> > >>>
> >  Hi Tom / Kever
> > 
> >  On Sun, Nov 19, 2023 at 5:24 PM Shantur Rathore  
> >  wrote:
> > > Rockchip SoCs can support wide range of bootflows.
> > > Without full bootflow commands, it can be difficult to
> > > figure out issues if any, hence enable by default.
> > >
> > > Reviewed-by: Simon Glass 
> > >
> > > Signed-off-by: Shantur Rathore 
> > > ---
> > >
> > > (no changes since v1)
> > >
> > >   arch/arm/Kconfig | 1 +
> > >   1 file changed, 1 insertion(+)
> > >
> > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > > index d812685c98..fca6ef6d7e 100644
> > > --- a/arch/arm/Kconfig
> > > +++ b/arch/arm/Kconfig
> > > @@ -1986,6 +1986,7 @@ config ARCH_ROCKCHIP
> > >  imply CMD_DM
> > >  imply DEBUG_UART_BOARD_INIT
> > >  imply BOOTSTD_DEFAULTS
> > > +   imply BOOTSTD_FULL if BOOTSTD_DEFAULTS
> > >  imply FAT_WRITE
> > >  imply SARADC_ROCKCHIP
> > >  imply SPL_SYSRESET
> >  Can this please be merged in ?
> > >>> I wonder if we shouldn't really globally default to BOOTSTD_FULL if
> > >>> BOOTSTD_DEFAULTS for everyone.
> > >>>
> > >> Its matter of ~21KB in size, unless any platform is really to its
> > >> limits it should be alright.
> > > Maybe I need to re-check things too, since I wonder how much of that
> > > growth is re-enabling things that were removed when dropping the DISTRO
> > > stuff, and so for platforms just migrating over now it would be smaller
> > > in size if much.
> >
> > A board maintainer is free to enable this option, but I don't agree to
> > enable this for everyone.
> >
> > Not like rk3399 and rk3588, some of other SoCs always want a clean and
> > simple but usable U-Boot,
> >
> > eg. rk3036 and rk3308 are still in the list.
> >
>
> The discussion is what we consider "usable U-Boot"
> By default bootstd doesn't have any options and not even to show what
> it's going to boot.
>
> Would it be acceptable if BOOTSTD_FULL is enabled for SoCs rather than boards?
>

Can you please suggest the way forward?
Initially the patch was for RockPro64 and then after discussion it was
suggested that as BOOTSTD_DEFAULT is very very limited
we should enable BOOTSTD_FULL for SoCs that can support multiple boot modes.

Kind regards,
Shantur


[PATCH v5 4/4] fs: remove explicit efi configuration dependency

2024-01-16 Thread AKASHI Takahiro
Now it is clear that the feature actually depends on efi interfaces,
not "bootefi" command. efi_set_bootdev() will automatically be nullified
if necessary efi component is disabled.

Signed-off-by: AKASHI Takahiro 
Reviewed-by: Simon Glass 
---
 fs/fs.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index f1a0b70d1d57..acf465bdd807 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -791,10 +791,9 @@ int do_load(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[],
return 1;
}
 
-   if (IS_ENABLED(CONFIG_CMD_BOOTEFI))
-   efi_set_bootdev(argv[1], (argc > 2) ? argv[2] : "",
-   (argc > 4) ? argv[4] : "", map_sysmem(addr, 0),
-   len_read);
+   efi_set_bootdev(argv[1], (argc > 2) ? argv[2] : "",
+   (argc > 4) ? argv[4] : "", map_sysmem(addr, 0),
+   len_read);
 
printf("%llu bytes read in %lu ms", len_read, time);
if (time > 0) {
-- 
2.34.1



[PATCH v5 3/4] net: tftp: remove explicit efi configuration dependency

2024-01-16 Thread AKASHI Takahiro
Now it is clear that the feature actually depends on efi interfaces,
not "bootefi" command. efi_set_bootdev() will automatically be nullified
if necessary efi component is disabled.

Signed-off-by: AKASHI Takahiro 
Reviewed-by: Ramon Fried 
Reviewed-by: Tom Rini 
---
 net/tftp.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/net/tftp.c b/net/tftp.c
index 88e71e67de35..2e335413492b 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -302,12 +302,10 @@ static void tftp_complete(void)
time_start * 1000, "/s");
}
puts("\ndone\n");
-   if (IS_ENABLED(CONFIG_CMD_BOOTEFI)) {
-   if (!tftp_put_active)
-   efi_set_bootdev("Net", "", tftp_filename,
-   map_sysmem(tftp_load_addr, 0),
-   net_boot_file_size);
-   }
+   if (!tftp_put_active)
+   efi_set_bootdev("Net", "", tftp_filename,
+   map_sysmem(tftp_load_addr, 0),
+   net_boot_file_size);
net_set_state(NETLOOP_SUCCESS);
 }
 
-- 
2.34.1



[PATCH v5 2/4] efi_loader: rename BOOTEFI_BOOTMGR to EFI_BOOTMGR

2024-01-16 Thread AKASHI Takahiro
At this point, EFI boot manager interfaces is fully independent from
bootefi command. So just rename the configuration parameter.

Signed-off-by: AKASHI Takahiro 
Reviewed-by: Simon Glass 
---
 boot/Makefile   | 2 +-
 cmd/Kconfig | 4 ++--
 cmd/efidebug.c  | 4 ++--
 lib/efi_loader/Kconfig  | 2 +-
 lib/efi_loader/Makefile | 2 +-
 test/boot/bootflow.c| 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/boot/Makefile b/boot/Makefile
index a47e00274622..f0a279cde161 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -35,7 +35,7 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SANDBOX) += 
bootmeth_sandbox.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SCRIPT) += bootmeth_script.o
 obj-$(CONFIG_$(SPL_TPL_)CEDIT) += cedit.o
 ifdef CONFIG_$(SPL_TPL_)BOOTSTD_FULL
-obj-$(CONFIG_BOOTEFI_BOOTMGR) += bootmeth_efi_mgr.o
+obj-$(CONFIG_EFI_BOOTMGR) += bootmeth_efi_mgr.o
 obj-$(CONFIG_$(SPL_TPL_)EXPO) += bootflow_menu.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow_menu.o
 endif
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 150fa37a50a7..62d2ae3d3f1b 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -395,7 +395,7 @@ config CMD_BOOTEFI_BINARY
 
 config CMD_BOOTEFI_BOOTMGR
bool "UEFI Boot Manager command"
-   depends on BOOTEFI_BOOTMGR
+   depends on EFI_BOOTMGR
default y
help
  Select this option to enable the 'bootmgr' subcommand of 'bootefi'.
@@ -2153,7 +2153,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 BOOTEFI_BOOTMGR
+   depends on EFI_BOOTMGR
select MENU
help
  Enable the 'eficonfig' command which provides the menu-driven UEFI
diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index aa8523797efb..a3a7556ea4a5 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -1414,7 +1414,7 @@ static __maybe_unused int do_efi_test_bootmgr(struct 
cmd_tbl *cmdtp, int flag,
 }
 
 static struct cmd_tbl cmd_efidebug_test_sub[] = {
-#ifdef CONFIG_BOOTEFI_BOOTMGR
+#ifdef CONFIG_EFI_BOOTMGR
U_BOOT_CMD_MKENT(bootmgr, CONFIG_SYS_MAXARGS, 1, do_efi_test_bootmgr,
 "", ""),
 #endif
@@ -1608,7 +1608,7 @@ U_BOOT_LONGHELP(efidebug,
"  - show UEFI memory map\n"
"efidebug tables\n"
"  - show UEFI configuration tables\n"
-#ifdef CONFIG_BOOTEFI_BOOTMGR
+#ifdef CONFIG_EFI_BOOTMGR
"efidebug test bootmgr\n"
"  - run simple bootmgr for test\n"
 #endif
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 64f2f1cdd161..db5571de1d95 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -41,7 +41,7 @@ config EFI_BINARY_EXEC
  You may enable CMD_BOOTEFI_BINARY so that you can use bootefi
  command to do that.
 
-config BOOTEFI_BOOTMGR
+config EFI_BOOTMGR
bool "UEFI Boot Manager"
default y
select BOOTMETH_GLOBAL if BOOTSTD
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index f0a31b4ad509..fcb0af7e7d6d 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -49,7 +49,7 @@ targets += initrddump.o
 endif
 
 obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
-obj-$(CONFIG_BOOTEFI_BOOTMGR) += efi_bootmgr.o
+obj-$(CONFIG_EFI_BOOTMGR) += efi_bootmgr.o
 obj-$(CONFIG_EFI_BINARY_EXEC) += efi_bootbin.o
 obj-y += efi_boottime.o
 obj-y += efi_helper.o
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 104f49deef2a..fa54dde661c8 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -374,7 +374,7 @@ static int bootflow_system(struct unit_test_state *uts)
 {
struct udevice *bootstd, *dev;
 
-   if (!IS_ENABLED(CONFIG_BOOTEFI_BOOTMGR))
+   if (!IS_ENABLED(CONFIG_EFI_BOOTMGR))
return -EAGAIN;
ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, ));
ut_assertok(device_bind(bootstd, DM_DRIVER_GET(bootmeth_efi_mgr),
-- 
2.34.1



[PATCH v5 1/4] efi_loader: split unrelated code from efi_bootmgr.c

2024-01-16 Thread AKASHI Takahiro
Some code moved from cmd/bootefi.c is actually necessary only for "bootefi
" command (starting an image manually loaded by a user using U-Boot
load commands or other methods (like JTAG debugger).

The code will never been opted out as unused code by a compiler which
doesn't know how EFI boot manager is implemented. So introduce a new
configuration, CONFIG_EFI_BINARY_EXEC, to enforce them opted out
explicitly.

Signed-off-by: AKASHI Takahiro 
---
 boot/Kconfig |   4 +-
 cmd/Kconfig  |   6 +-
 include/efi_loader.h |  28 +-
 lib/efi_loader/Kconfig   |   9 +
 lib/efi_loader/Makefile  |   1 +
 lib/efi_loader/efi_bootbin.c | 211 +
 lib/efi_loader/efi_bootmgr.c | 488 ---
 lib/efi_loader/efi_device_path.c |   3 +-
 lib/efi_loader/efi_helper.c  | 286 ++
 9 files changed, 531 insertions(+), 505 deletions(-)
 create mode 100644 lib/efi_loader/efi_bootbin.c

diff --git a/boot/Kconfig b/boot/Kconfig
index 0894ecf4df1f..70ff24808b0b 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -523,7 +523,7 @@ config BOOTMETH_EXTLINUX_PXE
 
 config BOOTMETH_EFILOADER
bool "Bootdev support for EFI boot"
-   depends on BOOTEFI_BOOTMGR
+   depends on EFI_BINARY_EXEC
default y
help
  Enables support for EFI boot using bootdevs. This makes the
@@ -558,7 +558,7 @@ config BOOTMETH_DISTRO
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 BOOTEFI_BOOTMGR # E.g. Ubuntu uses this
+   select BOOTMETH_EFILOADER if EFI_BINARY_EXEC # E.g. Ubuntu uses this
 
 config SPL_BOOTMETH_VBE
bool "Bootdev support for Verified Boot for Embedded (SPL)"
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 26ad03b6..150fa37a50a7 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -294,7 +294,7 @@ config CMD_BOOTMETH
 
 config BOOTM_EFI
bool "Support booting UEFI FIT images"
-   depends on BOOTEFI_BOOTMGR && CMD_BOOTM && FIT
+   depends on EFI_BINARY_EXEC && CMD_BOOTM && FIT
default y
help
  Support booting UEFI FIT images via the bootm command.
@@ -386,7 +386,7 @@ config CMD_BOOTEFI
 if CMD_BOOTEFI
 config CMD_BOOTEFI_BINARY
bool "Allow booting an EFI binary directly"
-   depends on BOOTEFI_BOOTMGR
+   depends on EFI_BINARY_EXEC
default y
help
  Select this option to enable direct execution of binary at 'bootefi'.
@@ -416,7 +416,7 @@ config CMD_BOOTEFI_HELLO_COMPILE
 
 config CMD_BOOTEFI_HELLO
bool "Allow booting a standard EFI hello world for testing"
-   depends on CMD_BOOTEFI_HELLO_COMPILE
+   depends on CMD_BOOTEFI_BINARY && CMD_BOOTEFI_HELLO_COMPILE
default y if CMD_BOOTEFI_SELFTEST
help
  This adds a standard EFI hello world application to U-Boot so that
diff --git a/include/efi_loader.h b/include/efi_loader.h
index d3725041b20d..d5fca2fa5efc 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -90,11 +90,7 @@ efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len);
  * back to u-boot world
  */
 void efi_restore_gd(void);
-/* Call this to unset the current device name */
-void efi_clear_bootdev(void);
-/* Call this to set the current device name */
-void efi_set_bootdev(const char *dev, const char *devnr, const char *path,
-void *buffer, size_t buffer_size);
+
 /* Called by networking code to memorize the dhcp ack package */
 void efi_net_set_dhcp_ack(void *pkt, int len);
 /* Print information about all loaded images */
@@ -116,10 +112,6 @@ static inline efi_status_t efi_add_runtime_mmio(void 
*mmio_ptr, u64 len)
 
 /* No loader configured, stub out EFI_ENTRY */
 static inline void efi_restore_gd(void) { }
-static inline void efi_clear_bootdev(void) { }
-static inline void efi_set_bootdev(const char *dev, const char *devnr,
-  const char *path, void *buffer,
-  size_t buffer_size) { }
 static inline void efi_net_set_dhcp_ack(void *pkt, int len) { }
 static inline void efi_print_image_infos(void *pc) { }
 static inline efi_status_t efi_launch_capsules(void)
@@ -129,6 +121,20 @@ static inline efi_status_t efi_launch_capsules(void)
 
 #endif /* CONFIG_IS_ENABLED(EFI_LOADER) */
 
+#if CONFIG_IS_ENABLED(EFI_BINARY_EXEC)
+/* Call this to unset the current device name */
+void efi_clear_bootdev(void);
+/* Call this to set the current device name */
+void efi_set_bootdev(const char *dev, const char *devnr, const char *path,
+void *buffer, size_t buffer_size);
+#else
+static inline void efi_clear_bootdev(void) { }
+
+static inline void efi_set_bootdev(const char *dev, const char *devnr,
+  const char *path, void *buffer,
+ 

[PATCH v5 0/4] cmd: bootefi: refactor the code for bootmgr

2024-01-16 Thread AKASHI Takahiro
This patch set is motivated by the discussion[1] regarding
CONFIG_BOOTEFI_BOOTMGR option.

# This version (v5) contains only the remaining commits.

At the end, bootefi.c will be decomposed into two parts, one for
providing the command itself and one for implementing helper functions.
EFI_LOADER will now be available without CONFIG_CMDLINE or specifically
CONFIG_CMD_BOOTEFI if invoked via bootmeth/bootstd.

Then, EFI_LOADER library side will be further split into two options
for fine-grain control:
CONFIG_EFI_BINARY_EXEC: execute UEFI binaries which are to be explicitly
loaded by U-Boot's load commands/functions or other methods
(like a jtag debugger?)
It supports bootmeth_efi as well as "bootefi |hello"(/"bootm"?).

CONFIG_EFI_BOOTMGR: provide EFI boot manger functionality
It supports bootmeth_efi_mgr as well as "bootefi bootmgr".

As such, We will no longer need CONFIG_EFI_BINARY_EXEC if we want to only
make use of the UEFI boot manger for booting a next stage OS.

Prerequisite

This patch set is based on top of the latest "master" branch.

Tests
=
* ran and passed py/efi_selftest on sandbox locally
* ran and passed py/test_efi_bootmgr on sandbox locally
* passed CI check (github pull request[2])

Changes
===
v4 (Jan 17, 2024)
* rebased onto the latest master branch again

v4 (Jan 10, 2024)
* rebased onto the latest master branch
* moved binary execution portion of code (EFI_BINARY_EXEC) to
  a new file, efi_bootbin.c, instead of efi_helper.c (patch#1)

v3 (Dec 18, 2023)
* rebased onto Tom's latest next branch
* remove already-merged commits

v2 (Nov 21, 2023)
* rebased onto Tom's next branch
* remove already merged commits
* revise commit messages
* add patch #5 which was split from ex-patch#5
RFC (Oct 26, 2023)

[1] https://lists.denx.de/pipermail/u-boot/2023-October/534598.html
[2] https://dev.azure.com/u-boot/u-boot/_build/results?buildId=7760=results

AKASHI Takahiro (4):
  efi_loader: split unrelated code from efi_bootmgr.c
  efi_loader: rename BOOTEFI_BOOTMGR to EFI_BOOTMGR
  net: tftp: remove explicit efi configuration dependency
  fs: remove explicit efi configuration dependency

 boot/Kconfig |   4 +-
 boot/Makefile|   2 +-
 cmd/Kconfig  |  10 +-
 cmd/efidebug.c   |   4 +-
 fs/fs.c  |   7 +-
 include/efi_loader.h |  28 +-
 lib/efi_loader/Kconfig   |  11 +-
 lib/efi_loader/Makefile  |   3 +-
 lib/efi_loader/efi_bootbin.c | 211 +
 lib/efi_loader/efi_bootmgr.c | 488 ---
 lib/efi_loader/efi_device_path.c |   3 +-
 lib/efi_loader/efi_helper.c  | 286 ++
 net/tftp.c   |  10 +-
 test/boot/bootflow.c |   2 +-
 14 files changed, 546 insertions(+), 523 deletions(-)
 create mode 100644 lib/efi_loader/efi_bootbin.c

-- 
2.34.1



[PATCH] mtd: nand: Print warning for unsupported ecc modes

2024-01-16 Thread Venkatesh Yadav Abbarapu
Currently only hw ecc is supported in U-Boot. If any other ecc mode is
given in DT, it simply ignores and switches to hw ecc. So better print
what is being done.

Revert this patch once soft ecc support is fixed in future.

Signed-off-by: Ashok Reddy Soma 
Signed-off-by: Venkatesh Yadav Abbarapu 
---
 drivers/mtd/nand/raw/nand_base.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index c40a0f23d7..200f7f8ba0 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -4463,6 +4463,9 @@ static int nand_dt_init(struct mtd_info *mtd, struct 
nand_chip *chip, ofnode nod
 
str = ofnode_read_string(node, "nand-ecc-mode");
if (str) {
+   if (strcmp(str, "hw"))
+   printf("%s ecc is not supported, switching to hw 
ecc\n", str);
+
if (!strcmp(str, "none"))
ecc_mode = NAND_ECC_NONE;
else if (!strcmp(str, "soft"))
-- 
2.25.1



[PATCH v3 2/2] configs: zynqmp_kria: Enable CONFIG_OF_BOARD_SETUP

2024-01-16 Thread Venkatesh Yadav Abbarapu
Enable CONFIG_OF_BOARD_SETUP, so we could use ft_board_setup()
to enable the kaslr-seed and pass to kernel.

Signed-off-by: Michal Simek 
Signed-off-by: Venkatesh Yadav Abbarapu 
---
 configs/xilinx_zynqmp_kria_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/xilinx_zynqmp_kria_defconfig 
b/configs/xilinx_zynqmp_kria_defconfig
index a65a59c1ae..86741f1773 100644
--- a/configs/xilinx_zynqmp_kria_defconfig
+++ b/configs/xilinx_zynqmp_kria_defconfig
@@ -33,6 +33,7 @@ CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x1000
 CONFIG_SYS_BOOTM_LEN=0x640
 CONFIG_DISTRO_DEFAULTS=y
+CONFIG_OF_BOARD_SETUP=y
 # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
 CONFIG_USE_PREBOOT=y
 CONFIG_SYS_PBSIZE=2073
-- 
2.25.1



[PATCH v3 0/2] xilinx: Update the kaslr-seed property

2024-01-16 Thread Venkatesh Yadav Abbarapu
Update the kaslr-seed property and enable the config CONFIG_OF_BOARD_SETUP.

Changes in v2:
- Created macro for size variable.
- Removed malloc and created array for rng buffer.
- Added debug logs for all the apis.
Changes in v3:
- Fixed the return values.

Venkatesh Yadav Abbarapu (2):
  xilinx: board: Update the kaslr-seed property
  configs: zynqmp_kria: Enable CONFIG_OF_BOARD_SETUP

 board/xilinx/common/board.c  | 49 
 configs/xilinx_zynqmp_kria_defconfig |  1 +
 2 files changed, 50 insertions(+)

-- 
2.25.1



[PATCH v3 1/2] xilinx: board: Update the kaslr-seed property

2024-01-16 Thread Venkatesh Yadav Abbarapu
Create a ft_board_setup() api that gets called as part
of bootm/booti before jumping to kernel. In this
ft_board_setup() callback that will inspect the DTB
and insert the device tree blob with the "kaslr-seed" property.

Signed-off-by: Michal Simek 
Signed-off-by: Venkatesh Yadav Abbarapu 
---
 board/xilinx/common/board.c | 49 +
 1 file changed, 49 insertions(+)

diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 12a877c715..9641ed307b 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -682,3 +683,51 @@ phys_addr_t board_get_usable_ram_top(phys_size_t 
total_size)
return reg + size;
 }
 #endif
+
+#ifdef CONFIG_OF_BOARD_SETUP
+#define MAX_RAND_SIZE 8
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+   size_t n = MAX_RAND_SIZE;
+   struct udevice *dev;
+   u8 buf[MAX_RAND_SIZE];
+   int nodeoffset, ret;
+
+   if (uclass_get_device(UCLASS_RNG, 0, ) || !dev) {
+   debug("No RNG device\n");
+   return 0;
+   }
+
+   if (dm_rng_read(dev, buf, n)) {
+   debug("Reading RNG failed\n");
+   return 0;
+   }
+
+   if (!blob) {
+   debug("No FDT memory address configured. Please configure\n"
+ "the FDT address via \"fdt addr \" command.\n"
+ "Aborting!\n");
+   return 0;
+   }
+
+   ret = fdt_check_header(blob);
+   if (ret < 0) {
+   debug("fdt_chosen: %s\n", fdt_strerror(ret));
+   return ret;
+   }
+
+   nodeoffset = fdt_find_or_add_subnode(blob, 0, "chosen");
+   if (nodeoffset < 0) {
+   debug("Reading chosen node failed\n");
+   return nodeoffset;
+   }
+
+   ret = fdt_setprop(blob, nodeoffset, "kaslr-seed", buf, sizeof(buf));
+   if (ret < 0) {
+   debug("Unable to set kaslr-seed on chosen node: %s\n", 
fdt_strerror(ret));
+   return ret;
+   }
+
+   return 0;
+}
+#endif
-- 
2.25.1



Re: [PATCH v2 1/2] part: Add a function to find ESP partition

2024-01-16 Thread Sean Anderson

On 1/16/24 07:36, Mayuresh Chitale wrote:

If a disk has an EFI system partition (ESP) then it can be used to
locate the boot files. Add a function to find the ESP.

Signed-off-by: Mayuresh Chitale 
Reviewed-by: Heinrich Schuchardt 
---
  disk/part.c| 16 
  include/part.h | 11 +++
  2 files changed, 27 insertions(+)

diff --git a/disk/part.c b/disk/part.c
index 36b88205eca..6b1fbc18637 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -848,3 +848,19 @@ int part_get_bootable(struct blk_desc *desc)
  
  	return 0;

  }
+
+int part_get_esp(struct blk_desc *desc)
+{
+   struct disk_partition info;
+   int p;
+
+   for (p = 1; p <= MAX_SEARCH_PARTITIONS; p++) {
+   int ret;
+
+   ret = part_get_info(desc, p, );
+   if (!ret && (info.bootable & PART_EFI_SYSTEM_PARTITION))
+   return p;
+   }
+
+   return 0;
+}
diff --git a/include/part.h b/include/part.h
index db34bc6bb7d..30e049c8f19 100644
--- a/include/part.h
+++ b/include/part.h
@@ -690,6 +690,14 @@ int part_get_type_by_name(const char *name);
   */
  int part_get_bootable(struct blk_desc *desc);
  
+/**

+ * part_get_esp() - Find the EFI system partition
+ *
+ * @desc: Block-device descriptor
+ * @Return the EFI system partition, or 0 if there is none
+ */
+int part_get_esp(struct blk_desc *desc);
+
  #else
  static inline int part_driver_get_count(void)
  { return 0; }
@@ -700,6 +708,9 @@ static inline struct part_driver 
*part_driver_get_first(void)
  static inline bool part_get_bootable(struct blk_desc *desc)
  { return false; }
  
+static inline bool part_get_esp(struct blk_desc *desc)


Please use the same signature as above.


+{ return false; }


The statement here should be on its own line.

--Sean


+
  #endif /* CONFIG_PARTITIONS */
  
  #endif /* _PART_H */




Re: [PATCH v4 2/4] efi_loader: rename BOOTEFI_BOOTMGR to EFI_BOOTMGR

2024-01-16 Thread AKASHI Takahiro
On Tue, Jan 16, 2024 at 07:44:22PM +0100, Heinrich Schuchardt wrote:
> On 1/16/24 02:43, AKASHI Takahiro wrote:
> > On Mon, Jan 15, 2024 at 03:16:22PM +0100, Heinrich Schuchardt wrote:
> > > On 15.01.24 11:12, AKASHI Takahiro wrote:
> > > > On Mon, Jan 15, 2024 at 09:34:51AM +0100, Heinrich Schuchardt wrote:
> > > > > On 1/15/24 01:58, AKASHI Takahiro wrote:
> > > > > > On Sun, Jan 14, 2024 at 01:46:45PM +0100, Heinrich Schuchardt wrote:
> > > > > > > On 1/10/24 02:16, AKASHI Takahiro wrote:
> > > > > > > > At this point, EFI boot manager interfaces is fully independent 
> > > > > > > > from
> > > > > > > > bootefi command. So just rename the configuration parameter.
> > > > > > > > 
> > > > > > > > Signed-off-by: AKASHI Takahiro 
> > > > > > > > Reviewed-by: Simon Glass 
> > > > > > > 
> > > > > > > This patch breaks the 'bootefi hello' command in
> > > > > > > qemu-riscv64_smode_defconfig and other QEMU defconfigs.
> > > > > > 
> > > > > > What happened? Please elaborate details so that I can trace your 
> > > > > > issue.
> > > > > > 
> > > > > > On my side, I didn't see any problem with "bootefi hello" on 
> > > > > > qemu-arm64
> > > > > > and moreover CI check (github pull request) didn't complain 
> > > > > > anything.
> > > > > 
> > > > > The failures are logged in
> > > > > https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/19302
> > > > 
> > > > In the logs for qemu-arm64, qemu-risc64 and maybe others as well,
> > > > I see the same error:
> > > > --- ---
> > > > __ test_efi_grub_net 
> > > > ___
> > > > test/py/tests/test_efi_loader.py:188: in test_efi_grub_net
> > > >   addr = fetch_tftp_file(u_boot_console, 
> > > > 'env__efi_loader_grub_file')
> > > > test/py/tests/test_efi_loader.py:136: in fetch_tftp_file
> > > >   assert expected_text in output
> > > > E   assert 'Bytes transferred = 520192' in "*** ERROR: `serverip' not 
> > > > set"
> > > > --- ---
> > > > 
> > > > This seems to be the root cause and my commit will have nothing to do
> > > > with the problem.
> > > > Please check the test environment.
> > > 
> > > You are looking at test_efi_grub_net. I referred to 'bootefi hello',
> > > i.e. test_efi_helloworld_builtin:
> > > 
> > > 
> > > - Captured stdout call
> > > -
> > > => bootefi hello
> > > 
> > > =>
> > > 
> > > 
> > > The command does not provide any output.
> > 
> > Ah, yeah, but
> > 
> > > > 
> > > > -Takahiro Akashi
> > > > 
> > > > > I have pushed the tag failed_20240114 to
> > > > > https://source.denx.de/u-boot/custodians/u-boot-efi.git for analysis.
> > 
> > While I compiled this code and tried to run "bootefi hello",
> > I could not reproduce this issue, always seeing the right output
> > either on qemu-arm64 or sandbox64.
> > (I also invoked test_efi_loader/efi_helloworld_builtin locally,
> > but the test passed.)
> > So no clue.
> 
> Please, rebase your patch set upon origin/master and retry the tests.

After rebasing my commits to the latest master (please note that my v4 has
already been rebased on the master at my submission time), I tried the test
again but anyhow the test passed as before on my side.
I'm not able to reproduce your issue.

The only conflicting commit was f19171c919e0 ("efi_loader: Clean up
efi_dp_append and efi_dp_concat"). I don't think that it would make
any difference.

-Takahiro Akashi


> Best regards
> 
> Heinrich
> 


Re: [PATCH v3 4/4] sunxi: Enable SPL FIT loading for 32-bit SoCs

2024-01-16 Thread Andre Przywara
On Fri, 8 Dec 2023 01:39:45 +
Andre Przywara  wrote:

Hi Samuel,

> On Tue, 31 Oct 2023 00:17:41 -0500
> Samuel Holland  wrote:
> 
> Hi,
> 
> > Now that 32-bit SoCs can load U-Boot proper (and possibly other
> > firmware) from a FIT, use this method by default. SPL_FIT_IMAGE_TINY is
> > required to stay within the 24 or 32 KiB SPL size limit on early SoCs;
> > for consistency, enable it everywhere.  
> 
> Mmh, so that changes the build for an awful lot of boards, especially
> old ones that no one can be bothered to test anymore. I am bit scared
> of that change there, especially with the limited SRAM size there.
> 
> I think the main motivation stems from crust on H3, and since H3 boards
> are still in good use and get tested, I'd prefer to enable it just for
> H3 boards, at least for now.
> If we don't hear anything bad for a while, we could try to enable it
> (by default) on the other SoCs as well.
> 
> What do you think?

Any ideas here? I plan to take the other three patches, which would
already allow people to enable FIT in their (def)config.
I can just leave this one off for now, and we can merge a changed
version later?

Cheers,
Andre

> > 
> > Signed-off-by: Samuel Holland 
> > ---
> > 
> > (no changes since v2)
> > 
> > Changes in v2:
> >  - New patch for v2, split from the .dtsi changes
> > 
> >  arch/arm/Kconfig   | 1 +
> >  common/spl/Kconfig | 3 +--
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > index d812685c984..42781d02f0f 100644
> > --- a/arch/arm/Kconfig
> > +++ b/arch/arm/Kconfig
> > @@ -1167,6 +1167,7 @@ config ARCH_SUNXI
> > imply SPL_GPIO
> > imply SPL_LIBCOMMON_SUPPORT
> > imply SPL_LIBGENERIC_SUPPORT
> > +   imply SPL_LOAD_FIT
> > imply SPL_MMC if MMC
> > imply SPL_POWER
> > imply SPL_SERIAL
> > diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> > index a0968ff1065..aebbfbf99d2 100644
> > --- a/common/spl/Kconfig
> > +++ b/common/spl/Kconfig
> > @@ -567,8 +567,7 @@ config SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION
> >  config SPL_FIT_IMAGE_TINY
> > bool "Remove functionality from SPL FIT loading to reduce size"
> > depends on SPL_FIT
> > -   default y if MACH_SUN50I || MACH_SUN50I_H5 || SUN50I_GEN_H6
> > -   default y if ARCH_IMX8M || ARCH_IMX9
> > +   default y if ARCH_IMX8M || ARCH_IMX9 || ARCH_SUNXI
> > help
> >   Enable this to reduce the size of the FIT image loading code
> >   in SPL, if space for the SPL binary is very tight.  
> 



Re: [PATCH v1] net: sun8i-emac: Add support for fixed-link phy

2024-01-16 Thread Andre Przywara
On Tue, 16 Jan 2024 19:58:56 +0300
Maxim Kiselev  wrote:

Hi Maxim,

> вт, 16 янв. 2024 г. в 03:18, Andre Przywara :
> >
> > On Thu, 15 Jun 2023 00:44:06 +0300
> > Maxim Kiselev  wrote:
> >
> > Hi Maxim,
> >  
> > > From: Maksim Kiselev 
> > >
> > > Based on dt-specs fixed-link doesn't require phy-handle to be used.  
> >
> > Do you have such a board?  
> 
> Yes, I had a custom board with T113 SoC which has fixed phy eth.
> 
> > And where is that written down? I don't see
> > it explicitly mentioned as optional in ethernet-controller.yaml or in
> > the DT spec PDF.  
> 
> Sorry for that commit description. I just found the similar commit, that
> fixes the same problem for zynq_gem
> 3888c8d1979289efe685fe29276aed4d4b685975 ("net: zynq_gem: Add support for
> fixed-link phy") and copied the description from there.
> 
> > The sun8i EMAC binding lists phy-handle as required,
> > so that would need to be relaxed there then.  
> 
> Oh, indeed. So it will require to send dt-binding changes to Linux first...

Well, in the long run yes, but this doesn't mean that this patch needs
to wait - if that fixes a problem for you. I think in general that
rationale is probably true and phy-handle should be optional,
especially since the code can already cope with it.

I would just like to have this documented in the commit message.

Cheers,
Andre

> Therefore, I think we can live without fixed-phy support for sun8i EMAC.
> At least until some device with such a configuration appears on the
> market :)
> 
> > > Fix driver to only read phy related setting when phy-handle is found.  
> >
> > The patch itself looks fine, we already specify -1 as the default when
> > the PHY DT node does not contain a reg property, so that looks like it
> > would work.
> >
> > Cheers,
> > Andre
> >  
> > > Signed-off-by: Maksim Kiselev 
> > > ---
> > >  drivers/net/sun8i_emac.c | 7 ++-
> > >  1 file changed, 2 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
> > > index 04c3274fbe..0e339d69e0 100644
> > > --- a/drivers/net/sun8i_emac.c
> > > +++ b/drivers/net/sun8i_emac.c
> > > @@ -834,11 +834,8 @@ static int sun8i_emac_eth_of_to_plat(struct udevice 
> > > *dev)
> > >   priv->use_internal_phy = false;
> > >
> > >   offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "phy-handle");
> > > - if (offset < 0) {
> > > - debug("%s: Cannot find PHY address\n", __func__);
> > > - return -EINVAL;
> > > - }
> > > - priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1);
> > > + if (offset >= 0)
> > > + priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", 
> > > -1);
> > >
> > >   pdata->phy_interface = dev_read_phy_mode(dev);
> > >   debug("phy interface %d\n", pdata->phy_interface);  
> >  
> 
> Best wishes,
> Maksim



[PATCH v1 1/1] net: ti: am65-cpsw-nuss: Remove incorrect RGMII_ID bit functionality

2024-01-16 Thread Ken Sloat
The CPSW implementations on the AM6x platforms do not support the
selectable RGMII TX clk delay functionality via the RGMII_ID_MODE bit as
the earlier platforms did. According to various TI datasheets, reference
manuals, hardware design guides and TI forum posts from TI, this bit is
"not timed, tested, or characterized. RGMII_ID is enabled by default and
the register bit reserved."

The driver implementation today however, will incorrectly set this bit
whenever the interface mode is in RGMII_ID or RGMII_TXID.

To fix this, remove any statement setting this bit, and moreover, mask
bits 31:4 as these are all reserved.

See:
https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1211306/am625-enet1_ctrl_rgmii_id-_mode
https://www.ti.com/lit/pdf/spruiv7 (Rev. B Figure 14-1717)
https://www.ti.com/lit/gpn/am625 (Rev. B Figure 7-31 Note A)
https://www.ti.com/lit/an/sprad05b/sprad05b.pdf (Rev. B Section 7.4)

Signed-off-by: Ken Sloat 
---
 drivers/net/ti/am65-cpsw-nuss.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ti/am65-cpsw-nuss.c b/drivers/net/ti/am65-cpsw-nuss.c
index 18a33c4c0e..51c432408f 100644
--- a/drivers/net/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ti/am65-cpsw-nuss.c
@@ -256,7 +256,6 @@ static int am65_cpsw_gmii_sel_k3(struct am65_cpsw_priv 
*priv,
 {
struct udevice *dev = priv->dev;
u32 offset, reg, phandle;
-   bool rgmii_id = false;
fdt_addr_t gmii_sel;
u32 mode = 0;
ofnode node;
@@ -296,7 +295,6 @@ static int am65_cpsw_gmii_sel_k3(struct am65_cpsw_priv 
*priv,
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII_TXID:
mode = AM65_GMII_SEL_MODE_RGMII;
-   rgmii_id = true;
break;
 
case PHY_INTERFACE_MODE_SGMII:
@@ -313,15 +311,13 @@ static int am65_cpsw_gmii_sel_k3(struct am65_cpsw_priv 
*priv,
break;
};
 
-   if (rgmii_id)
-   mode |= AM65_GMII_SEL_RGMII_IDMODE;
-
-   reg = mode;
+   /* bits 31:4 are reserved */
+   reg = (GENMASK(31, 4) & reg) | mode;
dev_dbg(dev, "gmii_sel PHY mode: %u, new gmii_sel: %08x\n",
phy_mode, reg);
writel(reg, gmii_sel);
 
-   reg = readl(gmii_sel);
+   reg = GENMASK(3, 0) & readl(gmii_sel);
if (reg != mode) {
dev_err(dev,
"gmii_sel PHY mode NOT SET!: requested: %08x, gmii_sel: 
%08x\n",
-- 
2.34.1



Re: [PATCH 5/5] test: unit test for smbios command

2024-01-16 Thread Tom Rini
On Sat, Dec 23, 2023 at 01:44:29AM +0100, Heinrich Schuchardt wrote:

> Provide a unit test for the smbios command.
> 
> Provide different test functions for QEMU, sandbox, and other systems.
> 
> Signed-off-by: Heinrich Schuchardt 
> Acked-by: Ilias Apalodimas 
> Reviewed-by: Simon Glass 
> ---
>  test/py/tests/test_smbios.py | 47 
>  1 file changed, 47 insertions(+)
>  create mode 100644 test/py/tests/test_smbios.py
> 
> --
> 2.43.0
> 
> diff --git a/test/py/tests/test_smbios.py b/test/py/tests/test_smbios.py
> new file mode 100644
> index 00..86d8d07539
> --- /dev/null
> +++ b/test/py/tests/test_smbios.py
> @@ -0,0 +1,47 @@
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +
> +"""Test smbios command"""
> +
> +import pytest
> +
> +@pytest.mark.buildconfigspec('cmd_smbios')
> +@pytest.mark.notbuildconfigspec('qfw_smbios')
> +@pytest.mark.notbuildconfigspec('sandbox')
> +def test_cmd_smbios(u_boot_console):
> +"""Run the smbios command"""
> +output = u_boot_console.run_command('smbios')
> +assert 'DMI type 0,' in output
> +assert 'String 1: U-Boot' in output
> +assert 'DMI type 1,' in output
> +assert 'DMI type 2,' in output
> +assert 'DMI type 3,' in output
> +assert 'DMI type 4,' in output
> +assert 'DMI type 127,' in output
> +
> +@pytest.mark.buildconfigspec('cmd_smbios')
> +@pytest.mark.buildconfigspec('qfw_smbios')
> +@pytest.mark.notbuildconfigspec('sandbox')
> +# TODO:
> +# QEMU v8.2.0 lacks SMBIOS support for RISC-V
> +# Once support is available in our Docker image we can remove the constraint.
> +@pytest.mark.notbuildconfigspec('riscv')
> +def test_cmd_smbios_qemu(u_boot_console):
> +"""Run the smbios command on QEMU"""
> +output = u_boot_console.run_command('smbios')
> +assert 'DMI type 1,' in output
> +assert 'Manufacturer: QEMU' in output
> +assert 'DMI type 127,' in output
> +
> +@pytest.mark.buildconfigspec('cmd_smbios')
> +@pytest.mark.buildconfigspec('sandbox')
> +def test_cmd_smbios_sandbox(u_boot_console):
> +"""Run the smbios command on the sandbox"""
> +output = u_boot_console.run_command('smbios')
> +assert 'DMI type 0,' in output
> +assert 'String 1: U-Boot' in output
> +assert 'DMI type 1,' in output
> +assert 'Manufacturer: sandbox' in output
> +assert 'DMI type 2,' in output
> +assert 'DMI type 3,' in output
> +assert 'DMI type 4,' in output
> +assert 'DMI type 127,' in output

This fails on coreboot:
https://source.denx.de/u-boot/u-boot/-/jobs/771654

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v4 2/4] efi_loader: rename BOOTEFI_BOOTMGR to EFI_BOOTMGR

2024-01-16 Thread Heinrich Schuchardt

On 1/16/24 02:43, AKASHI Takahiro wrote:

On Mon, Jan 15, 2024 at 03:16:22PM +0100, Heinrich Schuchardt wrote:

On 15.01.24 11:12, AKASHI Takahiro wrote:

On Mon, Jan 15, 2024 at 09:34:51AM +0100, Heinrich Schuchardt wrote:

On 1/15/24 01:58, AKASHI Takahiro wrote:

On Sun, Jan 14, 2024 at 01:46:45PM +0100, Heinrich Schuchardt wrote:

On 1/10/24 02:16, AKASHI Takahiro wrote:

At this point, EFI boot manager interfaces is fully independent from
bootefi command. So just rename the configuration parameter.

Signed-off-by: AKASHI Takahiro 
Reviewed-by: Simon Glass 


This patch breaks the 'bootefi hello' command in
qemu-riscv64_smode_defconfig and other QEMU defconfigs.


What happened? Please elaborate details so that I can trace your issue.

On my side, I didn't see any problem with "bootefi hello" on qemu-arm64
and moreover CI check (github pull request) didn't complain anything.


The failures are logged in
https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/19302


In the logs for qemu-arm64, qemu-risc64 and maybe others as well,
I see the same error:
--- ---
__ test_efi_grub_net ___
test/py/tests/test_efi_loader.py:188: in test_efi_grub_net
  addr = fetch_tftp_file(u_boot_console, 'env__efi_loader_grub_file')
test/py/tests/test_efi_loader.py:136: in fetch_tftp_file
  assert expected_text in output
E   assert 'Bytes transferred = 520192' in "*** ERROR: `serverip' not set"
--- ---

This seems to be the root cause and my commit will have nothing to do
with the problem.
Please check the test environment.


You are looking at test_efi_grub_net. I referred to 'bootefi hello',
i.e. test_efi_helloworld_builtin:


- Captured stdout call
-
=> bootefi hello

=>


The command does not provide any output.


Ah, yeah, but



-Takahiro Akashi


I have pushed the tag failed_20240114 to
https://source.denx.de/u-boot/custodians/u-boot-efi.git for analysis.


While I compiled this code and tried to run "bootefi hello",
I could not reproduce this issue, always seeing the right output
either on qemu-arm64 or sandbox64.
(I also invoked test_efi_loader/efi_helloworld_builtin locally,
but the test passed.)
So no clue.


Please, rebase your patch set upon origin/master and retry the tests.

Best regards

Heinrich



Re: [PATCH v13 00/24] Modernize U-Boot shell

2024-01-16 Thread Francis Laniel
Hi!


Le mardi 16 janvier 2024, 00:34:24 +07 Patrice CHOTARD a écrit :
> On 1/11/24 18:04, Francesco Dolcini wrote:
> > Hello Tom, Francis
> > 
> > On Fri, Dec 29, 2023 at 07:55:37PM +0100, Francis Laniel wrote:
> >> Le jeudi 28 décembre 2023, 21:58:59 CET Tom Rini a écrit :
> >>> On Fri, 22 Dec 2023 22:02:20 +0100, Francis Laniel wrote:
>  During 2021 summer, Sean Anderson wrote a contribution to add a new
>  shell,
>  based on LIL, to U-Boot [1, 2].
>  While one of the goals of this contribution was to address the fact
>  actual
>  U-Boot shell, which is based on Busybox hush, is old there was a
>  discussion
>  about adding a new shell versus updating the actual one [3, 4].
>  
>  So, in this series, with Harald Seiler, we updated the actual U-Boot
>  shell
>  to reflect what is currently in Busybox source code.
>  Basically, this contribution is about taking a snapshot of Busybox
>  shell/hush.c file (as it exists in commit 37460f5da) and adapt it to
>  suit
>  U-Boot needs.
>  
>  [...]
> >>> 
> >>> Applied to u-boot/next, thanks!
> >> 
> >> Thank you for the merge!
> >> If there is any problem, do not hesitate to mail me and I will take care
> >> of
> >> it!
> > 
> > This change, specifically setting the modern hush shell as default, is
> > breaking our boot script, just noticed since the current U-Boot master
> > has a regression for us.
> > 
> > We still need to figure out the exact details, here [1] you can find the
> > boot script (that has some placeholder that is replaced during build).
> > 
> > and the error is something like:
> > 
> > ```
> > ## Executing script at 9028
> > Loading DeviceTree: k3-am625-verdin-nonwifi-dev.dtb
> > 69025 bytes read in 11 ms (6 MiB/s)
> > 82 bytes read in 9 ms (8.8 KiB/s)
> > Working FDT set to 9020
> > syntax error at 'done'HUSH died!
> > resetting ...
> > ```
> > 
> > that I _assume_ comes from this line
> > 
> > env set set_apply_overlays 'env set apply_overlays "for overlay_file
> > in \\${fdt_overlays}; do echo Applying Overlay: \\${overlay_file} &&
> > ${load_cmd} \\${loadaddr} \\${overlays_prefix}\\${overlay_file} &&
> > fdt apply \\${loadaddr}; env set overlay_file; done; true"'> 
> > [1]
> > https://git.toradex.com/cgit/meta-toradex-bsp-common.git/tree/recipes-bsp
> > /u-boot/u-boot-distro-boot/boot.cmd.in
> > 
> > Francesco
> 
> Hi all
> 
> I observed a similar issue with STM32MP157c-DK2 board.
> Since commit 78912cfde281 ("cmd: Set modern hush as default shell") U-Boot
> crashes :
> 
> 
> U-Boot 2024.01-00486-g697758e7c81-dirty (Jan 15 2024 - 18:23:52 +0100)
> 
> CPU: STM32MP157CAC Rev.B
> Model: STMicroelectronics STM32MP157C-DK2 Discovery Board
> Board: stm32mp1 in trusted mode (st,stm32mp157c-dk2)
> Board: MB1272 Var2.0 Rev.C-01
> DRAM:  512 MiB
> Clocks:
> - MPU : 650 MHz
> - MCU : 208.878 MHz
> - AXI : 266.500 MHz
> - PER : 24 MHz
> - DDR : 533 MHz
> optee optee: OP-TEE: revision 4.0 (e92de4ca)
> I/TC: Reserved shared memory is disabled
> I/TC: Dynamic shared memory is enabled
> I/TC: Normal World virtualization support is disabled
> I/TC: Asynchronous notifications are disabled
> Core:  311 devices, 40 uclasses, devicetree: board
> WDT:   Started watchdog@5a002000 with servicing every 1000ms (32s timeout)
> NAND:  0 MiB
> MMC:   STM32 SD/MMC: 0
> Loading Environment from MMC... OK
> In:No input devices available!
> Out:   No output devices available!
> Err:   No error devices available!
> Net:   eth0: ethernet@5800a000
> Hit any key to stop autoboot:  0
> Boot over mmc0!
> switch to partitions #0, OK
> mmc0 is current device
> Scanning mmc 0:8...
> data abort
> pc : []  lr : []
> reloc pc : []lr : []
> sp : dbafc848  ip : ddbfc578 fp : ddbedf18
> r10:   r9 : dbb15e70 r8 : 
> r7 : dbb5bf98  r6 : dbb5de10 r5 : dbb5bf98  r4 : ddbeda78
> r3 : dbb5dc08  r2 : 33f8 r1 : 0071  r0 : ddbede00
> Flags: nzcv  IRQs off  FIQs off  Mode SVC_32 (T)
> Code: 3138 1c48 f854 0030 (eb04) 05c1
> Resetting CPU ...
> 
> 
> It crashes in blkcache_fill() , i didn't investigate deeply into this issue
> yet, but i can reproduce this issue by stopping autoboot by pressing a key
> and running a environment command as shown below :
> 
> U-Boot 2024.01-00486-g697758e7c81-dirty (Jan 15 2024 - 18:23:52 +0100)
> 
> CPU: STM32MP157CAC Rev.B
> Model: STMicroelectronics STM32MP157C-DK2 Discovery Board
> Board: stm32mp1 in trusted mode (st,stm32mp157c-dk2)
> Board: MB1272 Var2.0 Rev.C-01
> DRAM:  512 MiB
> Clocks:
> - MPU : 650 MHz
> - MCU : 208.878 MHz
> - AXI : 266.500 MHz
> - PER : 24 MHz
> - DDR : 533 MHz
> optee optee: OP-TEE: revision 4.0 (e92de4ca)
> I/TC: Reserved shared memory is disabled
> I/TC: Dynamic shared memory is enabled
> I/TC: Normal World virtualization support is disabled
> I/TC: Asynchronous notifications are disabled
> Core:  311 devices, 40 uclasses, devicetree: board
> WDT:   Started watchdog@5a002000 with 

Re: [PATCH v13 00/24] Modernize U-Boot shell

2024-01-16 Thread Francis Laniel
Hi!


Le vendredi 12 janvier 2024, 00:04:18 +07 Francesco Dolcini a écrit :
> Hello Tom, Francis
> 
> On Fri, Dec 29, 2023 at 07:55:37PM +0100, Francis Laniel wrote:
> > Le jeudi 28 décembre 2023, 21:58:59 CET Tom Rini a écrit :
> > > On Fri, 22 Dec 2023 22:02:20 +0100, Francis Laniel wrote:
> > > > During 2021 summer, Sean Anderson wrote a contribution to add a new
> > > > shell,
> > > > based on LIL, to U-Boot [1, 2].
> > > > While one of the goals of this contribution was to address the fact
> > > > actual
> > > > U-Boot shell, which is based on Busybox hush, is old there was a
> > > > discussion
> > > > about adding a new shell versus updating the actual one [3, 4].
> > > > 
> > > > So, in this series, with Harald Seiler, we updated the actual U-Boot
> > > > shell
> > > > to reflect what is currently in Busybox source code.
> > > > Basically, this contribution is about taking a snapshot of Busybox
> > > > shell/hush.c file (as it exists in commit 37460f5da) and adapt it to
> > > > suit
> > > > U-Boot needs.
> > > > 
> > > > [...]
> > > 
> > > Applied to u-boot/next, thanks!
> > 
> > Thank you for the merge!
> > If there is any problem, do not hesitate to mail me and I will take care
> > of
> > it!
> 
> This change, specifically setting the modern hush shell as default, is
> breaking our boot script, just noticed since the current U-Boot master
> has a regression for us.
> 
> We still need to figure out the exact details, here [1] you can find the
> boot script (that has some placeholder that is replaced during build).
> 
> and the error is something like:
> 
> ```
> ## Executing script at 9028
> Loading DeviceTree: k3-am625-verdin-nonwifi-dev.dtb
> 69025 bytes read in 11 ms (6 MiB/s)
> 82 bytes read in 9 ms (8.8 KiB/s)
> Working FDT set to 9020
> syntax error at 'done'HUSH died!
> resetting ...
> ```
> 
> that I _assume_ comes from this line
> 
> env set set_apply_overlays 'env set apply_overlays "for overlay_file in
> \\${fdt_overlays}; do echo Applying Overlay: \\${overlay_file} &&
> ${load_cmd} \\${loadaddr} \\${overlays_prefix}\\${overlay_file} && fdt
> apply \\${loadaddr}; env set overlay_file; done; true"'

Sorry for the inconvenience, I tried to reproduce on my side and noticed some 
strange behavior.
For the moment, can you please try to only escape "$" with "\$ and not "\\$"?
I would like to confirm some insights I have.

> [1]
> https://git.toradex.com/cgit/meta-toradex-bsp-common.git/tree/recipes-bsp/u
> -boot/u-boot-distro-boot/boot.cmd.in
> 
> Francesco

Best regards.




[PATCH v6 7/7] bloblist: Load the bloblist from the previous loader

2024-01-16 Thread Raymond Mao
During bloblist initialization, load the bloblist via boot arguments
from the previous loader.
If a valid bloblist exists in boot arguments, relocate it into the
fixed bloblist memory region.
If not, fallback to support BLOBLIST_ADDR or BLOBLIST_ALLOC.

Signed-off-by: Raymond Mao 
---
Changes in v4
- Add weak default function.
- Add comments for BLOBLIST_ALLOC.
- Add local debug macro.
- Refine the commit message.
Changes in V5
- Drop the dependence on OF_BOARD.
- Remove local debug macro.

 common/bloblist.c  | 62 --
 include/bloblist.h | 10 
 2 files changed, 54 insertions(+), 18 deletions(-)

diff --git a/common/bloblist.c b/common/bloblist.c
index c2fd07575f..ad06d7a179 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -487,37 +487,57 @@ int bloblist_reloc(void *to, uint to_size)
return 0;
 }
 
+/*
+ * Weak default function for getting bloblist from boot args.
+ */
+int __weak xferlist_from_boot_arg(ulong __always_unused addr,
+ ulong __always_unused size)
+{
+   return -ENOENT;
+}
+
 int bloblist_init(void)
 {
bool fixed = IS_ENABLED(CONFIG_BLOBLIST_FIXED);
int ret = -ENOENT;
ulong addr, size;
-   bool expected;
-
-   /**
-* We don't expect to find an existing bloblist in the first phase of
-* U-Boot that runs. Also we have no way to receive the address of an
-* allocated bloblist from a previous stage, so it must be at a fixed
+   /*
+* If U-Boot is not in the first phase, an existing bloblist must be
+* at a fixed address.
+*/
+   bool from_addr = fixed && !u_boot_first_phase();
+   /*
+* If U-Boot is in the first phase that an arch custom routine should
+* install the bloblist passed from previous loader to this fixed
 * address.
 */
-   expected = fixed && !u_boot_first_phase();
+   bool from_boot_arg = fixed && u_boot_first_phase();
+
if (spl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST))
-   expected = false;
+   from_addr = false;
if (fixed)
addr = IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED,
  CONFIG_BLOBLIST_ADDR);
size = CONFIG_BLOBLIST_SIZE;
-   if (expected) {
+
+   if (from_boot_arg)
+   ret = xferlist_from_boot_arg(addr, size);
+   else if (from_addr)
ret = bloblist_check(addr, size);
-   if (ret) {
-   log_warning("Expected bloblist at %lx not found 
(err=%d)\n",
-   addr, ret);
-   } else {
-   /* Get the real size, if it is not what we expected */
-   size = gd->bloblist->total_size;
-   }
-   }
+
+   if (ret)
+   log_warning("Bloblist at %lx not found (err=%d)\n",
+   addr, ret);
+   else
+   /* Get the real size */
+   size = gd->bloblist->total_size;
+
if (ret) {
+   /*
+* If we don't have a bloblist from a fixed address, or the one
+* in the fixed address is not valid. we must allocate the
+* memory for it now.
+*/
if (CONFIG_IS_ENABLED(BLOBLIST_ALLOC)) {
void *ptr = memalign(BLOBLIST_ALIGN, size);
 
@@ -525,7 +545,8 @@ int bloblist_init(void)
return log_msg_ret("alloc", -ENOMEM);
addr = map_to_sysmem(ptr);
} else if (!fixed) {
-   return log_msg_ret("!fixed", ret);
+   return log_msg_ret("BLOBLIST_FIXED is not enabled",
+  ret);
}
log_debug("Creating new bloblist size %lx at %lx\n", size,
  addr);
@@ -538,6 +559,11 @@ int bloblist_init(void)
return log_msg_ret("ini", ret);
gd->flags |= GD_FLG_BLOBLIST_READY;
 
+#ifdef DEBUG
+   bloblist_show_stats();
+   bloblist_show_list();
+#endif
+
return 0;
 }
 
diff --git a/include/bloblist.h b/include/bloblist.h
index 0ae079d62a..7fbdd622bc 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -482,4 +482,14 @@ static inline int bloblist_maybe_init(void)
  */
 int bloblist_check_reg_conv(ulong rfdt, ulong rzero, ulong rsig);
 
+/**
+ * xferlist_from_boot_arg() - Get bloblist from the boot args and relocate it
+ *   to the specified address.
+ *
+ * @addr: Address for the bloblist
+ * @size: Size of space reserved for the bloblist
+ * Return: 0 if OK, else on error
+ */
+int xferlist_from_boot_arg(ulong addr, ulong size);
+
 #endif /* __BLOBLIST_H */
-- 
2.25.1



[PATCH v6 6/7] arm: Get bloblist from boot arguments

2024-01-16 Thread Raymond Mao
Add arch custom function to get bloblist from boot arguments.
Check whether boot arguments aligns with the register conventions
defined in FW Handoff spec v0.9.
Add bloblist related options into qemu-arm default config.
Remove OF_HAS_PRIOR_STAGE and OF_BOARD from qemu-arm config.

Signed-off-by: Raymond Mao 
---
Changes in v2
- Remove low level code for copying boot arguments.
- Refactor board_fdt_blob_setup() and remove direct access of gd->bloblist.
Changes in v3
- Optimize board_bloblist_from_boot_arg().
Changes in v4
- Move the function as an Arm-arch library instead of a board-specific one.
Changes in V5
- Drop the dependence on OF_BOARD.
- Move external declaration to header file.
- Adjust the position of BLOBLIST in defconfig file.
Changes in V6
- Drop imply OF_HAS_PRIOR_STAGE from qemu-arm.

 arch/arm/Kconfig |  1 -
 arch/arm/lib/Makefile|  2 ++
 arch/arm/lib/xferlist.c  | 27 +++
 arch/arm/lib/xferlist.h  | 19 +++
 configs/qemu_arm64_defconfig |  3 +++
 5 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/lib/xferlist.c
 create mode 100644 arch/arm/lib/xferlist.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 2d4458b7b5..745b68f20f 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1047,7 +1047,6 @@ config ARCH_QEMU
imply DM_RNG
imply DM_RTC
imply RTC_PL031
-   imply OF_HAS_PRIOR_STAGE
imply VIDEO
imply VIDEO_BOCHS
imply SYS_WHITE_ON_BLACK
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index b1bcd37466..67275fba61 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -85,6 +85,8 @@ obj-y += psci-dt.o
 
 obj-$(CONFIG_DEBUG_LL) += debug.o
 
+obj-$(CONFIG_BLOBLIST)  += xferlist.o
+
 # For EABI conformant tool chains, provide eabi_compat()
 ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS)))
 extra-y+= eabi_compat.o
diff --git a/arch/arm/lib/xferlist.c b/arch/arm/lib/xferlist.c
new file mode 100644
index 00..e9734959dc
--- /dev/null
+++ b/arch/arm/lib/xferlist.c
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2023 Linaro Limited
+ * Author: Raymond Mao 
+ */
+#include 
+#include 
+#include 
+#include "xferlist.h"
+
+int xferlist_from_boot_arg(ulong addr, ulong size)
+{
+   int ret;
+
+   ret = bloblist_check(saved_args[3], size);
+   if (ret)
+   return ret;
+
+   /* Check the register conventions */
+   ret = bloblist_check_reg_conv(saved_args[0], saved_args[2],
+ saved_args[1]);
+   if (!ret)
+   /* Relocate the bloblist to the fixed address */
+   ret = bloblist_reloc((void *)addr, size);
+
+   return ret;
+}
diff --git a/arch/arm/lib/xferlist.h b/arch/arm/lib/xferlist.h
new file mode 100644
index 00..60d79c1a8e
--- /dev/null
+++ b/arch/arm/lib/xferlist.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause */
+/*
+ * Copyright (C) 2023 Linaro Limited
+ * Author: Raymond Mao 
+ */
+
+#ifndef _XFERLIST_H_
+#define _XFERLIST_H_
+
+/*
+ * Boot parameters saved from start.S
+ * saved_args[0]: FDT base address
+ * saved_args[1]: Bloblist signature
+ * saved_args[2]: must be 0
+ * saved_args[3]: Bloblist base address
+ */
+extern unsigned long saved_args[];
+
+#endif /* _XFERLIST_H_ */
diff --git a/configs/qemu_arm64_defconfig b/configs/qemu_arm64_defconfig
index 5100e193be..80a5409c51 100644
--- a/configs/qemu_arm64_defconfig
+++ b/configs/qemu_arm64_defconfig
@@ -27,6 +27,9 @@ CONFIG_USE_PREBOOT=y
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_PCI_INIT_R=y
+CONFIG_BLOBLIST=y
+CONFIG_BLOBLIST_ADDR=0x40004000
+CONFIG_BLOBLIST_SIZE=0x4000
 CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_BOOTEFI_SELFTEST=y
 CONFIG_CMD_NVEDIT_EFI=y
-- 
2.25.1



[PATCH v6 5/7] arm: armv8: save boot arguments

2024-01-16 Thread Raymond Mao
Save boot arguments x[0-3] into an array for handover of bloblist from
previous boot stage.

Signed-off-by: Raymond Mao 
---
Changes in v2
- New patch file created for v2.
Changes in V5
- Drop the dependence on OF_BOARD.

 arch/arm/cpu/armv8/start.S | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S
index 6cc1d26e5e..91cdd03947 100644
--- a/arch/arm/cpu/armv8/start.S
+++ b/arch/arm/cpu/armv8/start.S
@@ -370,5 +370,19 @@ ENTRY(c_runtime_cpu_setup)
 ENDPROC(c_runtime_cpu_setup)
 
 WEAK(save_boot_params)
+#if (IS_ENABLED(CONFIG_BLOBLIST))
+   adr x9, saved_args
+   stp x0, x1, [x9]
+   /* Increment the address by 16 bytes for the next pair of values */
+   stp x2, x3, [x9, #16]
+#endif
b   save_boot_params_ret/* back to my caller */
 ENDPROC(save_boot_params)
+
+.section .data
+.global saved_args
+saved_args:
+   .rept 4
+   .xword 0
+   .endr
+END(saved_args)
-- 
2.25.1



[PATCH v6 4/7] arm: armv7: save boot arguments

2024-01-16 Thread Raymond Mao
Save boot arguments r[0-3] into an array for handover of bloblist from
previous boot stage.

Signed-off-by: Raymond Mao 
---
Changes in v2
- New patch file created for v2.
Changes in v3
- Swap value of r0 with r2.
Changes in v4
- Fix a bug when saving the boot args.
Changes in V5
- Drop the dependence on OF_BOARD.

 arch/arm/cpu/armv7/start.S | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
index 69e281b086..f4f50ab9a4 100644
--- a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -152,9 +152,28 @@ ENDPROC(c_runtime_cpu_setup)
  *
  */
 WEAK(save_boot_params)
+#if (IS_ENABLED(CONFIG_BLOBLIST))
+   ldr r12, =saved_args
+   /*
+* Intentionally swapping r0 with r2 in order to simplify the C
+* function we use later.
+*/
+   str r2, [r12]
+   str r1, [r12, #4]
+   str r0, [r12, #8]
+   str r3, [r12, #12]
+#endif
b   save_boot_params_ret@ back to my caller
 ENDPROC(save_boot_params)
 
+.section .data
+.global saved_args
+saved_args:
+   .rept 4
+   .word 0
+   .endr
+END(saved_args)
+
 #ifdef CONFIG_ARMV7_LPAE
 WEAK(switch_to_hypervisor)
b   switch_to_hypervisor_ret
-- 
2.25.1



[PATCH v6 3/7] bloblist: refactor of bloblist_reloc()

2024-01-16 Thread Raymond Mao
The current bloblist pointer and size can be retrieved from global
data, so we don't need to pass them from the function arguments.
This change also help to remove all external access of gd->bloblist
outside of bloblist module.

Signed-off-by: Raymond Mao 
---
Changes in v2
- New patch file created for v2.
Changes in v3
- Check the space size before copying the bloblist.
- Add return code of bloblist_reloc().
Changes in v4
- return error code from bloblist_reloc().

 common/bloblist.c  | 10 --
 common/board_f.c   |  9 +++--
 include/bloblist.h |  8 
 test/bloblist.c|  6 ++
 4 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/common/bloblist.c b/common/bloblist.c
index 26b0ba33b1..c2fd07575f 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -472,13 +472,19 @@ void bloblist_show_list(void)
}
 }
 
-void bloblist_reloc(void *to, uint to_size, void *from, uint from_size)
+int bloblist_reloc(void *to, uint to_size)
 {
struct bloblist_hdr *hdr;
 
-   memcpy(to, from, from_size);
+   if (to_size < gd->bloblist->total_size)
+   return -ENOSPC;
+
+   memcpy(to, gd->bloblist, gd->bloblist->total_size);
hdr = to;
hdr->total_size = to_size;
+   gd->bloblist = to;
+
+   return 0;
 }
 
 int bloblist_init(void)
diff --git a/common/board_f.c b/common/board_f.c
index d4d7d01f8f..f4145a2698 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -676,13 +676,10 @@ static int reloc_bloblist(void)
return 0;
}
if (gd->new_bloblist) {
-   int size = CONFIG_BLOBLIST_SIZE;
-
debug("Copying bloblist from %p to %p, size %x\n",
- gd->bloblist, gd->new_bloblist, size);
-   bloblist_reloc(gd->new_bloblist, CONFIG_BLOBLIST_SIZE_RELOC,
-  gd->bloblist, size);
-   gd->bloblist = gd->new_bloblist;
+ gd->bloblist, gd->new_bloblist, gd->bloblist->total_size);
+   return bloblist_reloc(gd->new_bloblist,
+ CONFIG_BLOBLIST_SIZE_RELOC);
}
 #endif
 
diff --git a/include/bloblist.h b/include/bloblist.h
index cc78259e5a..0ae079d62a 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -426,11 +426,11 @@ const char *bloblist_tag_name(enum bloblist_tag_t tag);
  * bloblist_reloc() - Relocate the bloblist and optionally resize it
  *
  * @to: Pointer to new bloblist location (must not overlap old location)
- * @to_size: New size for bloblist (must be larger than from_size)
- * @from: Pointer to bloblist to relocate
- * @from_size: Size of bloblist to relocate
+ * @to_size: New size for bloblist
+ * Return: 0 if OK, -ENOSPC if the new size is small than the bloblist total
+ *size.
  */
-void bloblist_reloc(void *to, uint to_size, void *from, uint from_size);
+int bloblist_reloc(void *to, uint to_size);
 
 /**
  * bloblist_init() - Init the bloblist system with a single bloblist
diff --git a/test/bloblist.c b/test/bloblist.c
index 7dab9addf8..1c60bbac36 100644
--- a/test/bloblist.c
+++ b/test/bloblist.c
@@ -376,13 +376,12 @@ static int bloblist_test_reloc(struct unit_test_state 
*uts)
 {
const uint large_size = TEST_BLOBLIST_SIZE;
const uint small_size = 0x20;
-   void *old_ptr, *new_ptr;
+   void *new_ptr;
void *blob1, *blob2;
ulong new_addr;
ulong new_size;
 
ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0, 0));
-   old_ptr = map_sysmem(TEST_ADDR, TEST_BLOBLIST_SIZE);
 
/* Add one blob and then one that won't fit */
blob1 = bloblist_add(TEST_TAG, small_size, 0);
@@ -394,8 +393,7 @@ static int bloblist_test_reloc(struct unit_test_state *uts)
new_addr = TEST_ADDR + TEST_BLOBLIST_SIZE;
new_size = TEST_BLOBLIST_SIZE + 0x100;
new_ptr = map_sysmem(new_addr, TEST_BLOBLIST_SIZE);
-   bloblist_reloc(new_ptr, new_size, old_ptr, TEST_BLOBLIST_SIZE);
-   gd->bloblist = new_ptr;
+   ut_assertok(bloblist_reloc(new_ptr, new_size));
 
/* Check the old blob is there and that we can now add the bigger one */
ut_assertnonnull(bloblist_find(TEST_TAG, small_size));
-- 
2.25.1



[PATCH v6 2/7] bloblist: check bloblist with specified buffer size

2024-01-16 Thread Raymond Mao
Instead of expecting the bloblist total size to be the same as the
pre-allocated buffer size, practically we are more interested in
whether the pre-allocated buffer size is bigger than the bloblist
total size.

Signed-off-by: Raymond Mao 
Reviewed-by: Ilias Apalodimas 
---
Changes in v2
- New patch file created for v2.
Changes in v4
- Update function header of bloblist_check().

 common/bloblist.c  | 2 +-
 include/bloblist.h | 9 +
 test/bloblist.c| 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/common/bloblist.c b/common/bloblist.c
index 980b1ddbcb..26b0ba33b1 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -384,7 +384,7 @@ int bloblist_check(ulong addr, uint size)
return log_msg_ret("Bad magic", -ENOENT);
if (hdr->version != BLOBLIST_VERSION)
return log_msg_ret("Bad version", -EPROTONOSUPPORT);
-   if (!hdr->total_size || (size && hdr->total_size != size))
+   if (!hdr->total_size || (size && hdr->total_size > size))
return log_msg_ret("Bad total size", -EFBIG);
if (hdr->used_size > hdr->total_size)
return log_msg_ret("Bad used size", -ENOENT);
diff --git a/include/bloblist.h b/include/bloblist.h
index f7e800f681..cc78259e5a 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -348,12 +348,13 @@ int bloblist_new(ulong addr, uint size, uint flags, uint 
align_log2);
  * bloblist_check() - Check if a bloblist exists
  *
  * @addr: Address of bloblist
- * @size: Expected size of blobsize, or 0 to detect the size
+ * @size: Reserved space size for blobsize, or 0 to use the total size
  * Return: 0 if OK, -ENOENT if the magic number doesn't match (indicating that
- * there problem is no bloblist at the given address), -EPROTONOSUPPORT
+ * there problem is no bloblist at the given address) or any fields for header
+ * size, used size and total size do not match, -EPROTONOSUPPORT
  * if the version does not match, -EIO if the checksum does not match,
- * -EFBIG if the expected size does not match the detected size, -ENOSPC
- * if the size is not large enough to hold the headers
+ * -EFBIG if the reserved space size is small than the total size or total size
+ * is 0
  */
 int bloblist_check(ulong addr, uint size);
 
diff --git a/test/bloblist.c b/test/bloblist.c
index 17d9dd03d0..7dab9addf8 100644
--- a/test/bloblist.c
+++ b/test/bloblist.c
@@ -207,7 +207,7 @@ static int bloblist_test_checksum(struct unit_test_state 
*uts)
hdr->flags++;
 
hdr->total_size--;
-   ut_asserteq(-EFBIG, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
+   ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
hdr->total_size++;
 
hdr->spare++;
-- 
2.25.1



[PATCH v6 1/7] bloblist: add API to check the register conventions

2024-01-16 Thread Raymond Mao
Add bloblist_check_reg_conv() to check whether the bloblist is compliant
to the register conventions defined in Firmware Handoff specification.
This API can be used for all Arm platforms.

Signed-off-by: Raymond Mao 
---
Changes in v2
- Refactor of bloblist_check_reg_conv().
Changes in v3
- bloblist_check_reg_conv() returns -ENOENT if OF_BOARD is disabled.
Changes in v4
- Add checking of signature register.
Changes in V5
- Drop the dependence on OF_BOARD.

 common/bloblist.c  | 11 +++
 include/bloblist.h | 20 
 2 files changed, 31 insertions(+)

diff --git a/common/bloblist.c b/common/bloblist.c
index 2d373910b6..980b1ddbcb 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -542,3 +542,14 @@ int bloblist_maybe_init(void)
 
return 0;
 }
+
+int bloblist_check_reg_conv(ulong rfdt, ulong rzero, ulong rsig)
+{
+   if (rzero || rsig != (BLOBLIST_MAGIC | BLOBLIST_REGCONV_VER) ||
+   rfdt != (ulong)bloblist_find(BLOBLISTT_CONTROL_FDT, 0)) {
+   gd->bloblist = NULL;  /* Reset the gd bloblist pointer */
+   return -EIO;
+   }
+
+   return 0;
+}
diff --git a/include/bloblist.h b/include/bloblist.h
index 84fc943819..f7e800f681 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -78,6 +78,13 @@ enum {
BLOBLIST_VERSION= 1,
BLOBLIST_MAGIC  = 0x4a0fb10b,
 
+   /*
+* FIXME:
+* Register convention version should be placed into a higher byte
+* https://github.com/FirmwareHandoff/firmware_handoff/issues/32
+*/
+   BLOBLIST_REGCONV_VER= 1 << 24,
+
BLOBLIST_BLOB_ALIGN_LOG2 = 3,
BLOBLIST_BLOB_ALIGN  = 1 << BLOBLIST_BLOB_ALIGN_LOG2,
 
@@ -461,4 +468,17 @@ static inline int bloblist_maybe_init(void)
 }
 #endif /* BLOBLIST */
 
+/**
+ * bloblist_check_reg_conv() - Check whether the bloblist is compliant to
+ *the register conventions according to the
+ *Firmware Handoff spec.
+ *
+ * @rfdt:  Register that holds the FDT base address.
+ * @rzero: Register that must be zero.
+ * @rsig:  Register that holds signature and register conventions version.
+ * Return: 0 if OK, -EIO if the bloblist is not compliant to the register
+ *conventions.
+ */
+int bloblist_check_reg_conv(ulong rfdt, ulong rzero, ulong rsig);
+
 #endif /* __BLOBLIST_H */
-- 
2.25.1



[PATCH v6 0/7] Handoff bloblist from previous boot stage

2024-01-16 Thread Raymond Mao
This patch set adds/adapts a few bloblist APIs and implements Arm arch
custom function to retrieve the bloblist (aka. Transfer List) from
previous loader via boot arguments when BLOBLIST option is enabled and
all boot arguments are compliant to the register conventions defined
in the Firmware Handoff spec v0.9.

If an arch wishes to have different behaviors for loading bloblist
from the previous boot stage, it is required to implement the custom
function xferlist_from_boot_arg().

V5:
Drop [PATCH v4 8/9] fdt: update the document and Kconfig description.
V6:
Drop [PATCH v5 8/8] fdt: get FDT from bloblist.

Raymond Mao (7):
  bloblist: add API to check the register conventions
  bloblist: check bloblist with specified buffer size
  bloblist: refactor of bloblist_reloc()
  arm: armv7: save boot arguments
  arm: armv8: save boot arguments
  arm: Get bloblist from boot arguments
  bloblist: Load the bloblist from the previous loader

 arch/arm/Kconfig |  1 -
 arch/arm/cpu/armv7/start.S   | 19 
 arch/arm/cpu/armv8/start.S   | 14 ++
 arch/arm/lib/Makefile|  2 +
 arch/arm/lib/xferlist.c  | 27 
 arch/arm/lib/xferlist.h  | 19 
 common/bloblist.c| 85 +++-
 common/board_f.c |  9 ++--
 configs/qemu_arm64_defconfig |  3 ++
 include/bloblist.h   | 47 
 test/bloblist.c  |  8 ++--
 11 files changed, 193 insertions(+), 41 deletions(-)
 create mode 100644 arch/arm/lib/xferlist.c
 create mode 100644 arch/arm/lib/xferlist.h

-- 
2.25.1



Re: [PATCH v1] net: sun8i-emac: Add support for fixed-link phy

2024-01-16 Thread Maxim Kiselev
вт, 16 янв. 2024 г. в 03:18, Andre Przywara :
>
> On Thu, 15 Jun 2023 00:44:06 +0300
> Maxim Kiselev  wrote:
>
> Hi Maxim,
>
> > From: Maksim Kiselev 
> >
> > Based on dt-specs fixed-link doesn't require phy-handle to be used.
>
> Do you have such a board?

Yes, I had a custom board with T113 SoC which has fixed phy eth.

> And where is that written down? I don't see
> it explicitly mentioned as optional in ethernet-controller.yaml or in
> the DT spec PDF.

Sorry for that commit description. I just found the similar commit, that
fixes the same problem for zynq_gem
3888c8d1979289efe685fe29276aed4d4b685975 ("net: zynq_gem: Add support for
fixed-link phy") and copied the description from there.

> The sun8i EMAC binding lists phy-handle as required,
> so that would need to be relaxed there then.

Oh, indeed. So it will require to send dt-binding changes to Linux first...

Therefore, I think we can live without fixed-phy support for sun8i EMAC.
At least until some device with such a configuration appears on the
market :)

> > Fix driver to only read phy related setting when phy-handle is found.
>
> The patch itself looks fine, we already specify -1 as the default when
> the PHY DT node does not contain a reg property, so that looks like it
> would work.
>
> Cheers,
> Andre
>
> > Signed-off-by: Maksim Kiselev 
> > ---
> >  drivers/net/sun8i_emac.c | 7 ++-
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
> > index 04c3274fbe..0e339d69e0 100644
> > --- a/drivers/net/sun8i_emac.c
> > +++ b/drivers/net/sun8i_emac.c
> > @@ -834,11 +834,8 @@ static int sun8i_emac_eth_of_to_plat(struct udevice 
> > *dev)
> >   priv->use_internal_phy = false;
> >
> >   offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "phy-handle");
> > - if (offset < 0) {
> > - debug("%s: Cannot find PHY address\n", __func__);
> > - return -EINVAL;
> > - }
> > - priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1);
> > + if (offset >= 0)
> > + priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", 
> > -1);
> >
> >   pdata->phy_interface = dev_read_phy_mode(dev);
> >   debug("phy interface %d\n", pdata->phy_interface);
>

Best wishes,
Maksim


Re: Please pull qcom-2024.04-rc1

2024-01-16 Thread Tom Rini
On Tue, Jan 16, 2024 at 12:33:18PM +, Caleb Connolly wrote:

> Hi Tom,
> 
> The following changes since commit 697758e7c81131da6db0e3b10515019fe3aca8c9:
> 
>   Merge branch 'master-sync-dts-663' of 
> https://source.denx.de/u-boot/custodians/u-boot-sh (2024-01-14 18:07:49 -0500)
> 
> are available in the Git repository at:
> 
>   g...@source.denx.de:/u-boot/custodians/u-boot-snapdragon.git 
> tags/qcom-2024.04-rc1
> 
> for you to fetch changes up to 4c3dfa1b8babf9fc0575ce08eed99f950d3bab84:
> 
>   sandbox_flattree: enable button support (2024-01-16 12:26:54 +)

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: Pull request: Please pull u-boot-imx-20240115

2024-01-16 Thread Tom Rini
On Mon, Jan 15, 2024 at 11:45:54PM -0300, Fabio Estevam wrote:

> Hi Tom,
> 
> Please pull from u-boot-imx, thanks.
> 
> The following changes since commit 547d3dd28a46a18d59e00a153c8becca8d4e8cf9:
> 
>   Merge branch '2024-01-12-assorted-fixes' (2024-01-12 08:34:50 -0500)
> 
> are available in the Git repository at:
> 
>   https://gitlab.denx.de/u-boot/custodians/u-boot-imx.git 
> tags/u-boot-imx-20240115
> 
> for you to fetch changes up to 662e7ef7f0e84114dd58d77ccdcfdf61d1a0df31:
> 
>   arm: xea: Add support for boot image source descriptor in SPL (2024-01-15 
> 10:55:42 -0300)
> 
> u-boot-imx-20240115

I would appreciate a brief summary I can paste in to the merge commit in
the future please.

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PULL] Pull request for u-boot-nand-20240115

2024-01-16 Thread Tom Rini
On Mon, Jan 15, 2024 at 11:48:12AM +0100, Dario Binacchi wrote:

> Hello Tom,
> 
> The following changes since commit 697758e7c81131da6db0e3b10515019fe3aca8c9:
> 
>   Merge branch 'master-sync-dts-663' of
> https://source.denx.de/u-boot/custodians/u-boot-sh (2024-01-14
> 18:07:49 -0500)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/u-boot.git u-boot-nand-20240115

For next time, you passed a wrong parameter to request-pull I think,
this should be
https://source.denx.de/u-boot/custodians/u-boot-nand-flash.git

> for you to fetch changes up to 4dfa08af79097d068d6657a4c77e7d474733b796:
> 
>   arm: mach-k3: am642: Define NAND boot device (2024-01-15 08:58:24 +0100)
> 
> Gitlab CI showed no issues:
> https://source.denx.de/u-boot/custodians/u-boot-nand-flash/-/pipelines/19322
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 3/3] doc: sophgo: milkv_duo: document Milk-V Duo board

2024-01-16 Thread Kongyang Liu
Heinrich Schuchardt  于2024年1月15日周一 05:27写道:
>
> On 1/14/24 19:07, Kongyang Liu wrote:
> > Add document for Milk-V Duo board which based on Sophgo's CV1800B SoC.
> >
> > Signed-off-by: Kongyang Liu 
> > ---
> >
> > (no changes since v1)
> >
> >   doc/board/index.rst|  1 +
> >   doc/board/sophgo/index.rst |  8 ++
> >   doc/board/sophgo/milkv_duo.rst | 50 ++
> >   3 files changed, 59 insertions(+)
> >   create mode 100644 doc/board/sophgo/index.rst
> >   create mode 100644 doc/board/sophgo/milkv_duo.rst
> >
> > diff --git a/doc/board/index.rst b/doc/board/index.rst
> > index 531e547e7e..a0bd534742 100644
> > --- a/doc/board/index.rst
> > +++ b/doc/board/index.rst
> > @@ -45,6 +45,7 @@ Board-specific doc
> >  sifive/index
> >  sipeed/index
> >  socionext/index
> > +   sophgo/index
> >  st/index
> >  starfive/index
> >  ste/index
> > diff --git a/doc/board/sophgo/index.rst b/doc/board/sophgo/index.rst
> > new file mode 100644
> > index 00..e097afdac6
> > --- /dev/null
> > +++ b/doc/board/sophgo/index.rst
> > @@ -0,0 +1,8 @@
> > +.. SPDX-License-Identifier: GPL-2.0+
> > +
> > +Sophgo
> > +==
> > +.. toctree::
> > +   :maxdepth: 1
> > +
> > +   milkv_duo
> > diff --git a/doc/board/sophgo/milkv_duo.rst b/doc/board/sophgo/milkv_duo.rst
> > new file mode 100644
> > index 00..b63304b510
> > --- /dev/null
> > +++ b/doc/board/sophgo/milkv_duo.rst
> > @@ -0,0 +1,50 @@
> > +.. SPDX-License-Identifier: GPL-2.0+
> > +
> > +Milk-V Duo
> > +==
> > +
> > +CV1800B RISC-V SoC
> > +--
> > +The CV1800B is a high-performance, low-power 1+1 64-bit RISC-V SoC from 
> > Sophgo.
> > +
> > +Mainline support
> > +
> > +The support for following drivers are already enabled:
> > +1. ns16550 UART Driver.
> > +
> > +Building
> > +
> > +1. Add the RISC-V toolchain to your PATH.
> > +2. Setup ARCH & cross compilation environment variable:
> > +
> > +.. code-block:: console
> > +
> > +   export CROSS_COMPILE=
> > +   cd 
> > +   make milkv_duo_defconfig
> > +   make
> > +
> > +This will generate u-boot-dtb.bin
> > +
> > +Booting
> > +~~~
> > +Currently, we rely on vendor FSBL(First Stage Boot Loader) to initialize 
> > the
> > +clock and load the u-boot image, then bootup from it.
>
> Thank you for providing documentation for the board.
>
> Could you please, additionally describe the procedure to run
> u-boot-dtb.bin on top of FSBL.
>
I'd like to clarify your request for describing the procedure to run
u-boot-dtb.bin on top of FSBL. Are you looking for a detailed, step-by-step
guide to replicate the process and successfully run u-boot-dtb.bin, or
would you prefer a more concise overview?

Best regards
Kongyang Liu

> Best regards
>
> Heinrich
>
> > +
> > +Sample boot log from Milk-V Duo board
> > +~
> > +.. code-block:: none
> > +
> > +   U-Boot 2024.01-rc5-00010-g51965baa36 (Dec 28 2023 - 13:15:53 
> > +0800)milkv_duo
> > +
> > +   DRAM:  63.3 MiB
> > +   Core:  10 devices, 8 uclasses, devicetree: separate
> > +   Loading Environment from nowhere... OK
> > +   In:serial@414
> > +   Out:   serial@414
> > +   Err:   serial@414
> > +   Net:   No ethernet found.
> > +   milkv_duo# cpu detail
> > + 0: cpu@0  rv64imafdc
> > +  ID = 0, freq = 0 Hz: L1 cache, MMU
> > +   milkv_duo#
>


Re: [PATCH v2 1/3] riscv: sophgo: milkv_duo: initial support added

2024-01-16 Thread Kongyang Liu
Heinrich Schuchardt  于2024年1月15日周一 05:57写道:
>
> On 1/14/24 19:07, Kongyang Liu wrote:
> > Add support for Sophgo's Milk-V Duo board, only minimal device tree and
> > serial console are enabled, and it can boot via vendor first stage
> > bootloader.
> >
> > Signed-off-by: Kongyang Liu 
>
> The sequence of patches seems to be wrong.
>
> We expect that after each single patch building succeeds. But the
> device-tree is neither in this patch nor in a preceding patch. Please,
> swap patch 1 and 2.
>
> make[2]: *** No rule to make target
> 'arch/riscv/dts/cv1800b-milkv-duo.dtb', needed by 'dtbs'.
>
>
I forgot defconfig relies on dts files, I will swap patch 1 and 2.

> >
> > ---
> >
> > Changes in v2:
> > - Fold the defconfig patch to first patch
> > - Remove unnecessary environment settings of consoledev and baudrate in
> > config
> >
> >   arch/riscv/Kconfig |  4 
> >   board/sophgo/milkv_duo/Kconfig | 28 
> >   board/sophgo/milkv_duo/MAINTAINERS |  6 ++
> >   board/sophgo/milkv_duo/Makefile|  5 +
> >   board/sophgo/milkv_duo/board.c |  9 +
> >   configs/milkv_duo_defconfig| 24 
> >   include/configs/milkv_duo.h| 12 
> >   7 files changed, 88 insertions(+)
> >   create mode 100644 board/sophgo/milkv_duo/Kconfig
> >   create mode 100644 board/sophgo/milkv_duo/MAINTAINERS
> >   create mode 100644 board/sophgo/milkv_duo/Makefile
> >   create mode 100644 board/sophgo/milkv_duo/board.c
> >   create mode 100644 configs/milkv_duo_defconfig
> >   create mode 100644 include/configs/milkv_duo.h
> >
> > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > index 6d0d812ddb..de99ce3a28 100644
> > --- a/arch/riscv/Kconfig
> > +++ b/arch/riscv/Kconfig
> > @@ -14,6 +14,9 @@ config TARGET_ANDES_AE350
> >   config TARGET_MICROCHIP_ICICLE
> >   bool "Support Microchip PolarFire-SoC Icicle Board"
> >
> > +config TARGET_MILKV_DUO
> > + bool "Support Milk-v Duo Board"
> > +
> >   config TARGET_OPENPITON_RISCV64
> >   bool "Support RISC-V cores on OpenPiton SoC"
> >
> > @@ -80,6 +83,7 @@ source "board/openpiton/riscv64/Kconfig"
> >   source "board/sifive/unleashed/Kconfig"
> >   source "board/sifive/unmatched/Kconfig"
> >   source "board/sipeed/maix/Kconfig"
> > +source "board/sophgo/milkv_duo/Kconfig"
> >   source "board/starfive/visionfive2/Kconfig"
> >   source "board/thead/th1520_lpi4a/Kconfig"
>
> error: patch failed: arch/riscv/Kconfig:80
>
> Please, rebase.
>
>
I will rebase it.

> >
> > diff --git a/board/sophgo/milkv_duo/Kconfig b/board/sophgo/milkv_duo/Kconfig
> > new file mode 100644
> > index 00..2a458f291c
> > --- /dev/null
> > +++ b/board/sophgo/milkv_duo/Kconfig
> > @@ -0,0 +1,28 @@
> > +if TARGET_MILKV_DUO
> > +
> > +config SYS_BOARD
> > + default "milkv_duo"
> > +
> > +config SYS_VENDOR
> > + default "sophgo"
> > +
> > +config SYS_CPU
> > + default "generic"
> > +
> > +config SYS_CONFIG_NAME
> > + default "milkv_duo"
> > +
> > +config TEXT_BASE
> > + default 0x8020
> > +
> > +config ENV_SIZE
> > + default 0x2
> > +
> > +config ENV_SECT_SIZE
> > + default 0x4
> > +
> > +config BOARD_SPECIFIC_OPTIONS
> > + def_bool y
> > + select GENERIC_RISCV
> > +
> > +endif
> > diff --git a/board/sophgo/milkv_duo/MAINTAINERS 
> > b/board/sophgo/milkv_duo/MAINTAINERS
> > new file mode 100644
> > index 00..651a0592f7
> > --- /dev/null
> > +++ b/board/sophgo/milkv_duo/MAINTAINERS
> > @@ -0,0 +1,6 @@
> > +Milk-V Duo
> > +M:   Kongyang Liu 
> > +S:   Maintained
> > +F:   board/sophgo/milkv_duo/
> > +F:   configs/milkv_duo_defconfig
> > +F:   doc/board/sophgo/milkv_duo.rst
> > diff --git a/board/sophgo/milkv_duo/Makefile 
> > b/board/sophgo/milkv_duo/Makefile
> > new file mode 100644
> > index 00..a087013f5c
> > --- /dev/null
> > +++ b/board/sophgo/milkv_duo/Makefile
> > @@ -0,0 +1,5 @@
> > +# SPDX-License-Identifier: GPL-2.0+
> > +#
> > +# Copyright (c) 2024, Kongyang Liu 
> > +
> > +obj-y := board.o
> > diff --git a/board/sophgo/milkv_duo/board.c b/board/sophgo/milkv_duo/board.c
> > new file mode 100644
> > index 00..eaa47be173
> > --- /dev/null
> > +++ b/board/sophgo/milkv_duo/board.c
> > @@ -0,0 +1,9 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * Copyright (c) 2024, Kongyang Liu 
> > + */
> > +
> > +int board_init(void)
> > +{
> > + return 0;
> > +}
> > diff --git a/configs/milkv_duo_defconfig b/configs/milkv_duo_defconfig
> > new file mode 100644
> > index 00..c4782639ef
> > --- /dev/null
> > +++ b/configs/milkv_duo_defconfig
> > @@ -0,0 +1,24 @@
> > +CONFIG_RISCV=y
> > +CONFIG_SYS_MALLOC_LEN=0x82
> > +CONFIG_SYS_MALLOC_F_LEN=0x2000
> > +CONFIG_NR_DRAM_BANKS=1
> > +CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
> > +CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8230
> > +CONFIG_DEFAULT_DEVICE_TREE="cv1800b-milkv-duo"
> > +CONFIG_IDENT_STRING="milkv_duo"
> > +CONFIG_SYS_LOAD_ADDR=0x8008
> > 

Re: [PATCH] common: console: Fix print complete stdio device list

2024-01-16 Thread Bin Meng
On Wed, Jan 17, 2024 at 12:13 AM Patrice Chotard
 wrote:
>
> In case CONSOLE_MUX and SYS_CONSOLE_IS_IN_ENV are on and
> stdin or stdout or stderr are missing in environment, as fallback, get
> these either from stdio_devices[std] or stdio_devices[std]->name.
>
> Fixes: 6b343ab38d ("console: Print out complete stdio device list")
>
> Signed-off-by: Patrice Chotard 
> ---
>
>  common/console.c | 23 +++
>  1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/common/console.c b/common/console.c
> index cad65891fc9..8bfcfce5643 100644
> --- a/common/console.c
> +++ b/common/console.c
> @@ -1049,6 +1049,11 @@ int console_clear(void)
> return 0;
>  }
>
> +static char *get_stdio(const u8 std)
> +{
> +   return stdio_devices[std] ? stdio_devices[std]->name : "No devices 
> available!";
> +}
> +
>  static void stdio_print_current_devices(void)
>  {
> char *stdinname, *stdoutname, *stderrname;
> @@ -1060,19 +1065,13 @@ static void stdio_print_current_devices(void)
> stdoutname = env_get("stdout");
> stderrname = env_get("stderr");
>
> -   stdinname = stdinname ? : "No input devices available!";
> -   stdoutname = stdoutname ? : "No output devices available!";
> -   stderrname = stderrname ? : "No error devices available!";
> +   stdinname = stdinname ? : get_stdio(stdin);
> +   stdoutname = stdoutname ? : get_stdio(stdout);
> +   stderrname = stderrname ? : get_stdio(stderr);
> } else {
> -   stdinname = stdio_devices[stdin] ?
> -   stdio_devices[stdin]->name :
> -   "No input devices available!";
> -   stdoutname = stdio_devices[stdout] ?
> -   stdio_devices[stdout]->name :
> -   "No output devices available!";
> -   stderrname = stdio_devices[stderr] ?
> -   stdio_devices[stderr]->name :
> -   "No error devices available!";
> +   stdinname = get_stdio(stdin);
> +   stdoutname = get_stdio(stdout);
> +   stderrname = get_stdio(stderr);
> }
>
> /* Print information */
> --

This can be further simplified to:

char *stdinname = NULL;
char *stdoutname = NULL;
char *stderrname NULL;

if (CONFIG_IS_ENABLED(CONSOLE_MUX) &&
 CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)) {
   /* stdin stdout and stderr are in environment */
   stdinname  = env_get("stdin");
   stdoutname = env_get("stdout");
   stderrname = env_get("stderr");
}

   stdinname = stdinname ? : get_stdio(stdin);
   stdoutname = stdoutname ? : get_stdio(stdout);
   stderrname = stderrname ? : get_stdio(stderr);

Regards,
Bin


Re: [PATCH v2 1/2] part: Add a function to find ESP partition

2024-01-16 Thread Heinrich Schuchardt

On 16.01.24 14:45, Heinrich Schuchardt wrote:

On 16.01.24 13:36, Mayuresh Chitale wrote:

If a disk has an EFI system partition (ESP) then it can be used to
locate the boot files. Add a function to find the ESP.

Signed-off-by: Mayuresh Chitale 
Reviewed-by: Heinrich Schuchardt 


I ran your patches through Gitlab CI and some issues came up:

https://source.denx.de/u-boot/custodians/u-boot-efi/-/jobs/771497
https://source.denx.de/u-boot/custodians/u-boot-efi/-/jobs/771498

Could you, please, have a look at it.

Best regards

Heinrich


---
  disk/part.c    | 16 
  include/part.h | 11 +++
  2 files changed, 27 insertions(+)

diff --git a/disk/part.c b/disk/part.c
index 36b88205eca..6b1fbc18637 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -848,3 +848,19 @@ int part_get_bootable(struct blk_desc *desc)
  return 0;
  }
+
+int part_get_esp(struct blk_desc *desc)
+{
+    struct disk_partition info;
+    int p;
+
+    for (p = 1; p <= MAX_SEARCH_PARTITIONS; p++) {
+    int ret;
+
+    ret = part_get_info(desc, p, );
+    if (!ret && (info.bootable & PART_EFI_SYSTEM_PARTITION))
+    return p;
+    }
+
+    return 0;
+}
diff --git a/include/part.h b/include/part.h
index db34bc6bb7d..30e049c8f19 100644
--- a/include/part.h
+++ b/include/part.h
@@ -690,6 +690,14 @@ int part_get_type_by_name(const char *name);
   */
  int part_get_bootable(struct blk_desc *desc);
+/**
+ * part_get_esp() - Find the EFI system partition
+ *
+ * @desc: Block-device descriptor
+ * @Return the EFI system partition, or 0 if there is none


We want to be able to add the include to our API documentation. This 
requires adhering to the Sphinx documentation style.


%s/@Return the/Return:/

Cf. 
https://www.kernel.org/doc/html/v6.7/doc-guide/kernel-doc.html#function-documentation


Best regards

Heinrich


+ */
+int part_get_esp(struct blk_desc *desc);
+
  #else
  static inline int part_driver_get_count(void)
  { return 0; }
@@ -700,6 +708,9 @@ static inline struct part_driver 
*part_driver_get_first(void)

  static inline bool part_get_bootable(struct blk_desc *desc)
  { return false; }
+static inline bool part_get_esp(struct blk_desc *desc)
+{ return false; }
+
  #endif /* CONFIG_PARTITIONS */
  #endif /* _PART_H */






[PATCH] common: console: Fix print complete stdio device list

2024-01-16 Thread Patrice Chotard
In case CONSOLE_MUX and SYS_CONSOLE_IS_IN_ENV are on and
stdin or stdout or stderr are missing in environment, as fallback, get
these either from stdio_devices[std] or stdio_devices[std]->name.

Fixes: 6b343ab38d ("console: Print out complete stdio device list")

Signed-off-by: Patrice Chotard 
---

 common/console.c | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/common/console.c b/common/console.c
index cad65891fc9..8bfcfce5643 100644
--- a/common/console.c
+++ b/common/console.c
@@ -1049,6 +1049,11 @@ int console_clear(void)
return 0;
 }
 
+static char *get_stdio(const u8 std)
+{
+   return stdio_devices[std] ? stdio_devices[std]->name : "No devices 
available!";
+}
+
 static void stdio_print_current_devices(void)
 {
char *stdinname, *stdoutname, *stderrname;
@@ -1060,19 +1065,13 @@ static void stdio_print_current_devices(void)
stdoutname = env_get("stdout");
stderrname = env_get("stderr");
 
-   stdinname = stdinname ? : "No input devices available!";
-   stdoutname = stdoutname ? : "No output devices available!";
-   stderrname = stderrname ? : "No error devices available!";
+   stdinname = stdinname ? : get_stdio(stdin);
+   stdoutname = stdoutname ? : get_stdio(stdout);
+   stderrname = stderrname ? : get_stdio(stderr);
} else {
-   stdinname = stdio_devices[stdin] ?
-   stdio_devices[stdin]->name :
-   "No input devices available!";
-   stdoutname = stdio_devices[stdout] ?
-   stdio_devices[stdout]->name :
-   "No output devices available!";
-   stderrname = stdio_devices[stderr] ?
-   stdio_devices[stderr]->name :
-   "No error devices available!";
+   stdinname = get_stdio(stdin);
+   stdoutname = get_stdio(stdout);
+   stderrname = get_stdio(stderr);
}
 
/* Print information */
-- 
2.25.1



Re: [PATCH v5 8/8] fdt: get FDT from bloblist

2024-01-16 Thread Tom Rini
On Mon, Jan 15, 2024 at 12:08:26PM -0500, Raymond Mao wrote:
> Hi Tom,
> 
> On Mon, 15 Jan 2024 at 09:57, Raymond Mao  wrote:
> 
> > Hi Tom,
> >
> > On Sat, 13 Jan 2024 at 10:27, Tom Rini  wrote:
> >
> >> On Fri, Jan 12, 2024 at 01:33:34PM -0800, Raymond Mao wrote:
> >>
> >> > Get device tree from a bloblist if it exists.
> >> > If not, fallback to traditional way.
> >> >
> >> > Signed-off-by: Raymond Mao 
> >> > ---
> >> > Changes in v2
> >> > - Refactor of board_fdt_blob_setup().
> >> > Changes in v4
> >> > - Move the logics from board custom function to fdt library.
> >> > Changes in V5
> >> > - Rebase the changes on top of master.
> >> >
> >> >  lib/fdtdec.c | 18 +-
> >> >  1 file changed, 9 insertions(+), 9 deletions(-)
> >>
> >> Why was this just not dropped after:
> >> commit 70fe23859437ffe4efe0793423937d8b78ebf9d6
> >>
> > In commit 70fe23859437ffe4efe0793423937d8b78ebf9d6, the FDT from bloblist
> > is always overridden when OF_BOARD is enabled (OF_BOARD is enabled when
> > OF_HAS_PRIOR_STAGE is on). I think this is not what we want.
> > The FDT from the bloblist passed from the previous stage should be the
> > default setting.
> >
> > If we want to build with OF_HAS_PRIOR_STAGE=y and without OF_BOARD to
> avoid the
> FDT from bloblist not being overridden,
> `imply OF_HAS_PRIOR_STAGE` needs to be dropped from Kconfig for ARCH_QEMU,
> otherwise check-of.sh will always complain.
> Do you mind me adding a patch to arch/arm/Kconfig? And then we can drop
> [PATCH v5 8/8].

Platforms that are able to migrate towards using bloblist should disable
OF_BOARD/OF_HAS_PRIOR_STAGE/etc and just use the bloblist, yes.

-- 
Tom


signature.asc
Description: PGP signature


Re: [Upstream] [PATCH v4 0/2] *** Add support for phyCORE-AM62x ***

2024-01-16 Thread Tom Rini
On Tue, Jan 16, 2024 at 06:54:57AM +0100, Wadim Egorov wrote:

> Hello,
> 
> is there something missing in this series for it to be applied?
> I would like to add support for a 2nd k3/am64x board based on this. So it
> would be nice to know if I can do it the same way or should wait for more k3
> changes to come in first?

Yes, sorry, I'll pick this up soon.

> 
> Regards,
> Wadim
> 
> Am 20.12.23 um 10:18 schrieb Wadim Egorov:
> > v4:
> >- Rebase on current next
> >- Drop schema file overrides from binman
> > 
> > v3: https://lists.denx.de/pipermail/u-boot/2023-December/539779.html
> > v2: https://lists.denx.de/pipermail/u-boot/2023-November/538971.html
> > v1: https://lists.denx.de/pipermail/u-boot/2023-October/535750.html
> > 
> > Wadim Egorov (2):
> >board: phytec: am62x: Add PHYTEC phyCORE-AM62x SoM
> >doc: board: phytec: Add phyCORE-AM62x
> > 
> >   arch/arm/dts/Makefile |4 +-
> >   .../arm/dts/k3-am62-phycore-som-ddr4-2gb.dtsi | 2190 +
> >   arch/arm/dts/k3-am62-phycore-som.dtsi |  324 +++
> >   .../k3-am625-phyboard-lyra-rdk-u-boot.dtsi|  166 ++
> >   arch/arm/dts/k3-am625-phyboard-lyra-rdk.dts   |  266 ++
> >   arch/arm/dts/k3-am625-phycore-som-binman.dtsi |  314 +++
> >   arch/arm/dts/k3-am625-r5-phycore-som-2gb.dts  |  119 +
> >   arch/arm/mach-k3/am62x/Kconfig|   17 +
> >   board/phytec/phycore_am62x/Kconfig|   33 +
> >   board/phytec/phycore_am62x/MAINTAINERS|   15 +
> >   board/phytec/phycore_am62x/Makefile   |8 +
> >   board/phytec/phycore_am62x/board-cfg.yaml |   36 +
> >   board/phytec/phycore_am62x/phycore-am62x.c|   59 +
> >   board/phytec/phycore_am62x/phycore_am62x.env  |   23 +
> >   board/phytec/phycore_am62x/pm-cfg.yaml|   12 +
> >   board/phytec/phycore_am62x/rm-cfg.yaml| 1088 
> >   board/phytec/phycore_am62x/sec-cfg.yaml   |  379 +++
> >   configs/phycore_am62x_a53_defconfig   |  115 +
> >   configs/phycore_am62x_r5_defconfig|  130 +
> >   doc/board/phytec/index.rst|1 +
> >   doc/board/phytec/phycore-am62x.rst|  158 ++
> >   doc/board/ti/k3.rst   |1 +
> >   include/configs/phycore_am62x.h   |   15 +
> >   23 files changed, 5472 insertions(+), 1 deletion(-)
> >   create mode 100644 arch/arm/dts/k3-am62-phycore-som-ddr4-2gb.dtsi
> >   create mode 100644 arch/arm/dts/k3-am62-phycore-som.dtsi
> >   create mode 100644 arch/arm/dts/k3-am625-phyboard-lyra-rdk-u-boot.dtsi
> >   create mode 100644 arch/arm/dts/k3-am625-phyboard-lyra-rdk.dts
> >   create mode 100644 arch/arm/dts/k3-am625-phycore-som-binman.dtsi
> >   create mode 100644 arch/arm/dts/k3-am625-r5-phycore-som-2gb.dts
> >   create mode 100644 board/phytec/phycore_am62x/Kconfig
> >   create mode 100644 board/phytec/phycore_am62x/MAINTAINERS
> >   create mode 100644 board/phytec/phycore_am62x/Makefile
> >   create mode 100644 board/phytec/phycore_am62x/board-cfg.yaml
> >   create mode 100644 board/phytec/phycore_am62x/phycore-am62x.c
> >   create mode 100644 board/phytec/phycore_am62x/phycore_am62x.env
> >   create mode 100644 board/phytec/phycore_am62x/pm-cfg.yaml
> >   create mode 100644 board/phytec/phycore_am62x/rm-cfg.yaml
> >   create mode 100644 board/phytec/phycore_am62x/sec-cfg.yaml
> >   create mode 100644 configs/phycore_am62x_a53_defconfig
> >   create mode 100644 configs/phycore_am62x_r5_defconfig
> >   create mode 100644 doc/board/phytec/phycore-am62x.rst
> >   create mode 100644 include/configs/phycore_am62x.h
> > 
> 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v7 2/2] schemas: Add some common reserved-memory usages

2024-01-16 Thread Ard Biesheuvel
On Thu, 4 Jan 2024 at 18:53, Chiu, Chasel  wrote:
>
>
>
> > -Original Message-
> > From: Ard Biesheuvel 
> > Sent: Thursday, January 4, 2024 12:43 AM
> > To: Chiu, Chasel 
> > Cc: Simon Glass ; devicet...@vger.kernel.org; Mark 
> > Rutland
> > ; Rob Herring ; Tan, Lean Sheng
> > ; lkml ; Dhaval
> > Sharma ; Brune, Maximilian
> > ; Yunhui Cui ;
> > Dong, Guo ; Tom Rini ; ron minnich
> > ; Guo, Gua ; linux-
> > a...@vger.kernel.org; U-Boot Mailing List 
> > Subject: Re: [PATCH v7 2/2] schemas: Add some common reserved-memory
> > usages
> >
> > On Thu, 4 Jan 2024 at 01:25, Chiu, Chasel  wrote:
> > >
> > >
> > >
> > > > -Original Message-
> > > > From: Ard Biesheuvel 
> > > > Sent: Wednesday, January 3, 2024 7:22 AM
> > > > To: Chiu, Chasel 
> > > > Cc: Simon Glass ; devicet...@vger.kernel.org; Mark
> > > > Rutland ; Rob Herring ; Tan,
> > > > Lean Sheng ; lkml
> > > > ; Dhaval Sharma ;
> > > > Brune, Maximilian ; Yunhui Cui
> > > > ; Dong, Guo ; Tom Rini
> > > > ; ron minnich ; Guo, Gua
> > > > ; linux- a...@vger.kernel.org; U-Boot Mailing
> > > > List 
> > > > Subject: Re: [PATCH v7 2/2] schemas: Add some common reserved-memory
> > > > usages
> > > >
> > > > On Fri, 22 Dec 2023 at 20:52, Chiu, Chasel  
> > > > wrote:
> > > > >
> > > > >
> > > > > Please see my reply below inline.
> > > > >
> > > > > Thanks,
> > > > > Chasel
> > > > >
> > > > ...
> > > > > > > > The gEfiMemoryTypeInformationGuid HOB typically carries
> > > > > > > > platform defaults, and the actual memory type information is
> > > > > > > > kept in a non-volatile EFI variable, which gets updated when
> > > > > > > > the memory usage changes. Is this different for UefiPayloadPkg?
> > > > > > > >
> > > > > > > > (For those among the cc'ees less versed in EFI/EDK2: when
> > > > > > > > you get the 'config changed -rebooting' message from the
> > > > > > > > boot firmware, it typically means that this memory type
> > > > > > > > table has changed, and a reboot is necessary.)
> > > > > > > >
> > > > > > > > So the platform init needs to read this variable, or get the
> > > > > > > > information in a different way. I assume it is the payload,
> > > > > > > > not the platform init that updates the variable when
> > > > > > > > necessary. This means the information flows from payload(n)
> > > > > > > > to platform init(n+1), where n is a monotonic index tracking
> > > > > > > > consecutive boots of the
> > > > system.
> > > > > > > >
> > > > > > > > Can you explain how the DT fits into this? How are the
> > > > > > > > runtime-code and runtime-data memory reservation nodes under
> > > > > > > > /reserved-memory used to implement this information exchange
> > > > > > > > between platform init and payload? And how do the HOB and
> > > > > > > > the EFI
> > > > variable fit into this picture?
> > > > > > >
> > > > > > >
> > > > > > > 1. With some offline discussion, we would move
> > > > > > > gEfiMemoryTypeInformationGuid usage to FDT->upl-custom node.
> > > > > > > This is because it is edk2 implementation choice and non-edk2
> > > > > > > PlatformInit or Payload may not have such memory optimization
> > > > > > > implementation. (not a generic usage/requirement for
> > > > > > > PlatformInit and Payload)
> > > > > > >
> > > > > > > The edk2 example flow will be like below:
> > > > > > >
> > > > > > > PlatformInit to GetVariable of gEfiMemoryTypeInformationGuid
> > > > > > > and create Hob-
> > > > > > >
> > > > > > >   PlatformInit to initialize FDT->upl-custom node to report
> > > > > > gEfiMemoryTypeInformationGuid HOB information ->
> > > > > > > UefiPayload entry to re-create
> > > > > > > gEfiMemoryTypeInformationGuid HOB basing
> > > > > > on FDT input (instead of the default MemoryType inside
> > > > > > UefiPayload)
> > > > > > ->
> > > > > > >   UefiPayload DxeMain/Gcd will consume
> > > > > > > gEfiMemoryTypeInformationGuid
> > > > > > Hob for memory type information ->
> > > > > > > UefiPayload to initialize UEFI environment (mainly DXE 
> > > > > > > dispatcher) -
> > >
> > > > > > >   (additional FV binary appended to common UefiPayload
> > > > > > > binary)
> > > > > > PlatformPayload to provide VariableService which is platform
> > > > > > specific ->
> > > > > > > UefiPayload UefiBootManager will SetVariable if
> > > > > > > memory type change
> > > > > > needed and request a warm reset ->
> > > > > > >   Back to PlatformInit ...
> > > > > > >
> > > > > >
> > > > > > OK so the upl-custom node can do whatever it needs to. I imagine
> > > > > > these will include the memory descriptor attribute field, and
> > > > > > other parts that may be missing from the /reserved-memory DT node
> > specification?
> > > > >
> > > > >
> > > > > Yes, if needed by edk2 specific implementation, not generic
> > > > > enough, we may
> > > > consider to use upl-custom node to pass those data.
> > > > >
> > > > >
> > > > > >
> > > > > > >
> > > > > > > 2. Now the proposed reserved-memory node 

[PATCH 1/1] part: correct documentation of part_get_bootable()

2024-01-16 Thread Heinrich Schuchardt
We have to use 'Return:' to render the description of the return value in
the HTML documentation.

Fixes: f55aa4454ac3 ("part: Add a fallback for part_get_bootable()")
Fixes: dcffa4428d03 ("part: Add a function to find the first bootable 
partition")
Signed-off-by: Heinrich Schuchardt 
---
 include/part.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/part.h b/include/part.h
index db34bc6bb7d..32ee4048856 100644
--- a/include/part.h
+++ b/include/part.h
@@ -685,8 +685,8 @@ int part_get_type_by_name(const char *name);
 /**
  * part_get_bootable() - Find the first bootable partition
  *
- * @desc: Block-device descriptor
- * @return first bootable partition, or 0 if there is none
+ * @desc:  Block-device descriptor
+ * Return: first bootable partition, or 0 if there is none
  */
 int part_get_bootable(struct blk_desc *desc);
 
-- 
2.43.0



Re: [PATCH v7] fdt: Allow the devicetree to come from a bloblist

2024-01-16 Thread Conor Dooley
Yo,

On Wed, Jan 03, 2024 at 06:49:19PM -0700, Simon Glass wrote:
> Standard passage provides for a bloblist to be passed from one firmware
> phase to the next. That can be used to pass the devicetree along as well.
> Add an option to support this.
> 
> Tests for this will be added as part of the Universal Payload work.
> 
> Signed-off-by: Simon Glass 

Since this was merged into master, U-Boot is no longer booting on my
icicle kit (At least that's what my bisection tells me). This is a
RISC-V board and U-Boot for it is built from
microchip_mpfs_icicle_defconfig.

There's zero output on the console from U-Boot at all, the last thing
that I see is OpenSBI before things grind to a halt.

Thanks,
Conor.


> ---
> The discussion on this was not resolved and is now important due to the
> bloblist series from Raymond. So I am sending it again since I believe
> this is a better starting point than building on OF_BOARD
> 
> Changes in v7:
> - Drop use of OF_BLOBLIST
> 
> Changes in v6:
> - Don't allow bloblist with OF_EMBED
> 
> Changes in v5:
> - Make OF_BLOBLIST default y
> - Make OF_BLOBLIST optional at runtime
> 
> Changes in v4:
> - Rebase to -next
> 
>  doc/develop/devicetree/control.rst |  3 ++
>  include/fdtdec.h   |  6 ++--
>  lib/fdtdec.c   | 44 +++---
>  3 files changed, 41 insertions(+), 12 deletions(-)
> 
> diff --git a/doc/develop/devicetree/control.rst 
> b/doc/develop/devicetree/control.rst
> index cbb65c9b177..11c92d440f4 100644
> --- a/doc/develop/devicetree/control.rst
> +++ b/doc/develop/devicetree/control.rst
> @@ -108,6 +108,9 @@ If CONFIG_OF_BOARD is defined, a board-specific routine 
> will provide the
>  devicetree at runtime, for example if an earlier bootloader stage creates
>  it and passes it to U-Boot.
>  
> +If CONFIG_BLOBLIST is defined, the devicetree may come from a bloblist passed
> +from a previous stage, if present.
> +
>  If CONFIG_SANDBOX is defined, then it will be read from a file on
>  startup. Use the -d flag to U-Boot to specify the file to read, -D for the
>  default and -T for the test devicetree, used to run sandbox unit tests.
> diff --git a/include/fdtdec.h b/include/fdtdec.h
> index bd1149f46d0..e80de24076c 100644
> --- a/include/fdtdec.h
> +++ b/include/fdtdec.h
> @@ -72,7 +72,7 @@ struct bd_info;
>   *   U-Boot is packaged as an ELF file, e.g. for debugging purposes
>   * @FDTSRC_ENV: Provided by the fdtcontroladdr environment variable. This 
> should
>   *   be used for debugging/development only
> - * @FDTSRC_NONE: No devicetree at all
> + * @FDTSRC_BLOBLIST: Provided by a bloblist from an earlier phase
>   */
>  enum fdt_source_t {
>   FDTSRC_SEPARATE,
> @@ -80,6 +80,7 @@ enum fdt_source_t {
>   FDTSRC_BOARD,
>   FDTSRC_EMBED,
>   FDTSRC_ENV,
> + FDTSRC_BLOBLIST,
>  };
>  
>  /*
> @@ -1190,7 +1191,8 @@ int fdtdec_resetup(int *rescan);
>   *
>   * The existing devicetree is available at gd->fdt_blob
>   *
> - * @err internal error code if we fail to setup a DTB
> + * @err: 0 on success, -EEXIST if the devicetree is already correct, or other
> + * internal error code if we fail to setup a DTB
>   * @returns new devicetree blob pointer
>   */
>  void *board_fdt_blob_setup(int *err);
> diff --git a/lib/fdtdec.c b/lib/fdtdec.c
> index 4016bf3c113..b2c59ab3818 100644
> --- a/lib/fdtdec.c
> +++ b/lib/fdtdec.c
> @@ -7,6 +7,10 @@
>   */
>  
>  #ifndef USE_HOSTCC
> +
> +#define LOG_CATEGORY LOGC_DT
> +
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -86,6 +90,7 @@ static const char *const fdt_src_name[] = {
>   [FDTSRC_BOARD] = "board",
>   [FDTSRC_EMBED] = "embed",
>   [FDTSRC_ENV] = "env",
> + [FDTSRC_BLOBLIST] = "bloblist",
>  };
>  
>  const char *fdtdec_get_srcname(void)
> @@ -1662,23 +1667,42 @@ static void setup_multi_dtb_fit(void)
>  
>  int fdtdec_setup(void)
>  {
> - int ret;
> + int ret = -ENOENT;
> +
> + /* If allowing a bloblist, check that first */
> + if (CONFIG_IS_ENABLED(BLOBLIST)) {
> + ret = bloblist_maybe_init();
> + if (!ret) {
> + gd->fdt_blob = bloblist_find(BLOBLISTT_CONTROL_FDT, 0);
> + if (gd->fdt_blob) {
> + gd->fdt_src = FDTSRC_BLOBLIST;
> + log_debug("Devicetree is in bloblist at %p\n",
> +   gd->fdt_blob);
> + } else {
> + log_debug("No FDT found in bloblist\n");
> + ret = -ENOENT;
> + }
> + }
> + }
>  
> - /* The devicetree is typically appended to U-Boot */
> - if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
> - gd->fdt_blob = fdt_find_separate();
> - gd->fdt_src = FDTSRC_SEPARATE;
> - } else { /* embed dtb in ELF file for testing / development */
> - gd->fdt_blob = dtb_dt_embedded();
> - gd->fdt_src = 

Re: [PATCH v2 1/2] part: Add a function to find ESP partition

2024-01-16 Thread Heinrich Schuchardt

On 16.01.24 13:36, Mayuresh Chitale wrote:

If a disk has an EFI system partition (ESP) then it can be used to
locate the boot files. Add a function to find the ESP.

Signed-off-by: Mayuresh Chitale 
Reviewed-by: Heinrich Schuchardt 
---
  disk/part.c| 16 
  include/part.h | 11 +++
  2 files changed, 27 insertions(+)

diff --git a/disk/part.c b/disk/part.c
index 36b88205eca..6b1fbc18637 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -848,3 +848,19 @@ int part_get_bootable(struct blk_desc *desc)
  
  	return 0;

  }
+
+int part_get_esp(struct blk_desc *desc)
+{
+   struct disk_partition info;
+   int p;
+
+   for (p = 1; p <= MAX_SEARCH_PARTITIONS; p++) {
+   int ret;
+
+   ret = part_get_info(desc, p, );
+   if (!ret && (info.bootable & PART_EFI_SYSTEM_PARTITION))
+   return p;
+   }
+
+   return 0;
+}
diff --git a/include/part.h b/include/part.h
index db34bc6bb7d..30e049c8f19 100644
--- a/include/part.h
+++ b/include/part.h
@@ -690,6 +690,14 @@ int part_get_type_by_name(const char *name);
   */
  int part_get_bootable(struct blk_desc *desc);
  
+/**

+ * part_get_esp() - Find the EFI system partition
+ *
+ * @desc: Block-device descriptor
+ * @Return the EFI system partition, or 0 if there is none


We want to be able to add the include to our API documentation. This 
requires adhering to the Sphinx documentation style.


%s/@Return the/Return:/

Cf. 
https://www.kernel.org/doc/html/v6.7/doc-guide/kernel-doc.html#function-documentation


Best regards

Heinrich


+ */
+int part_get_esp(struct blk_desc *desc);
+
  #else
  static inline int part_driver_get_count(void)
  { return 0; }
@@ -700,6 +708,9 @@ static inline struct part_driver 
*part_driver_get_first(void)
  static inline bool part_get_bootable(struct blk_desc *desc)
  { return false; }
  
+static inline bool part_get_esp(struct blk_desc *desc)

+{ return false; }
+
  #endif /* CONFIG_PARTITIONS */
  
  #endif /* _PART_H */




Re: [PATCH v2 2/2] spl: Add support for booting from ESP

2024-01-16 Thread Heinrich Schuchardt

On 16.01.24 13:36, Mayuresh Chitale wrote:

Some platforms as described by EBBR specification may store images in
the FIRMWARE directory of the UEFI system partition(ESP). Add support
to boot from the EFI system partition if it is enabled for a platform.

Signed-off-by: Mayuresh Chitale 


Thank you for respinning this series.

For future submissions it would be preferable to have the changes
between the versions also in the individual patches.


---
  common/spl/Kconfig  |  8 +++
  common/spl/spl_blk_fs.c | 51 ++---
  common/spl/spl_fat.c| 34 +++
  3 files changed, 75 insertions(+), 18 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index cf7ffc9b112..48e4e43196a 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1292,6 +1292,14 @@ config SPL_SATA_RAW_U_BOOT_SECTOR
  Sector on the SATA disk to load U-Boot from, when the SATA disk is 
being
  used in raw mode. Units: SATA disk sectors (1 sector = 512 bytes).

+config SPL_ESP_BOOT
+   bool "Load next stage boot image from the UEFI system partition"
+   default y if BOOT_DEFAULTS
+   select SPL_PARTITION_TYPE_GUID
+   help
+ When enabled, first try to boot from the UEFI system partition as
+ described in the Ch.4 of the EBBR specification.
+
  config SPL_NVME
bool "NVM Express device support"
depends on BLK
diff --git a/common/spl/spl_blk_fs.c b/common/spl/spl_blk_fs.c
index 04eac6f306b..a2e8c2ce910 100644
--- a/common/spl/spl_blk_fs.c
+++ b/common/spl/spl_blk_fs.c
@@ -10,12 +10,15 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 

  struct blk_dev {
const char *ifname;
const char *filename;
+   int devnum;
+   int partnum;
char dev_part_str[8];
  };

@@ -44,6 +47,29 @@ static ulong spl_fit_read(struct spl_load_info *load, ulong 
file_offset,
return actlen;
  }

+static int spl_blk_file_size(struct blk_dev *dev, const char *filename,
+loff_t *filesize)
+{
+   int ret;
+
+   snprintf(dev->dev_part_str, sizeof(dev->dev_part_str) - 1, "%x:%x",
+dev->devnum, dev->partnum);


Using log functions allows to provide more information if
CONFIG_SPL_LOG=y otherwise they fall back to printf() and debug().


+   debug("Loading file %s from %s %s\n", filename, dev->ifname,
+ dev->dev_part_str);


log_debug(


+   ret = fs_set_blk_dev(dev->ifname, dev->dev_part_str, FS_TYPE_ANY);
+   if (ret) {
+   printf("spl: unable to set blk_dev %s %s. Err - %d\n",


SPL binary size is limited on many systems. There is already a message
telling that we are in SPL. I would suggest to abbreviate the message.

log_err("Can't access %s %s\n", dev->ifname, dev->dev_part_str);


+  dev->ifname, dev->dev_part_str, ret);
+   return ret;
+   }
+
+   ret = fs_size(filename, filesize);
+   if (ret)
+   printf("spl: unable to get size, file: %s. Err - %d\n",
+  filename, ret);


log_err("File not found %s\n", filename);

Moving to log functions and adjusting the messages can be done in a
follow up patch. I don't want to stop this series.

Reviewed-by: Heinrich Schuchardt 



+   return ret;
+}
+
  int spl_blk_load_image(struct spl_image_info *spl_image,
   struct spl_boot_device *bootdev,
   enum uclass_id uclass_id, int devnum, int partnum)
@@ -53,7 +79,7 @@ int spl_blk_load_image(struct spl_image_info *spl_image,
loff_t filesize;
struct blk_dev dev;
struct spl_load_info load;
-   int ret;
+   int ret, part;

blk_desc = blk_get_devnum_by_uclass_id(uclass_id, devnum);
if (!blk_desc) {
@@ -65,21 +91,18 @@ int spl_blk_load_image(struct spl_image_info *spl_image,

dev.filename = filename;
dev.ifname = blk_get_uclass_name(uclass_id);
-   snprintf(dev.dev_part_str, sizeof(dev.dev_part_str) - 1, "%x:%x",
-devnum, partnum);
-   ret = fs_set_blk_dev(dev.ifname, dev.dev_part_str, FS_TYPE_ANY);
-   if (ret) {
-   printf("spl: unable to set blk_dev %s %s. Err - %d\n",
-  dev.ifname, dev.dev_part_str, ret);
-   return ret;
+   dev.devnum = devnum;
+   dev.partnum = partnum;
+   if (IS_ENABLED(CONFIG_SPL_ESP_BOOT)) {
+   part = part_get_esp(blk_desc);
+   if (part)
+   dev.partnum = part;
+   else
+   return -ENODEV;
}
-
-   ret = fs_size(filename, );
-   if (ret) {
-   printf("spl: unable to get file size: %s. Err - %d\n",
-  filename, ret);
+   ret = spl_blk_file_size(, filename, );
+   if (ret)
return ret;
-   }

load.read = spl_fit_read;
if 

Re: [PATCH v2 13/32] board: dragonboard410c: import board code from mach-snapdragon

2024-01-16 Thread Caleb Connolly



On 20/12/2023 13:47, Sumit Garg wrote:
> Hi Caleb,
> 
> On Tue, 19 Dec 2023 at 21:34, Caleb Connolly  
> wrote:
>>
>> Some of the db410c board support code was written to be generic and
>> placed in mach-snapdragon. However, as the db410c is the only board
>> using this, move the code out of mach-snapdragon. This makes is more
>> obvious what code is relevant for which targets and helps tidy things up
>> a little more.
> 
> This change will be incompatible with HMIBSC board support being
> proposed in the other thread. It will lead to further code duplication
> among boards. You should rather reverse it to keep APQ8016 SoC
> specific changes in mach-snapdragon and let the derivative boards use
> them.

Re-capping our off-list discussion: the HMIBSC board only depends on the
usb init code and button handling code.

The usb init code will be moved to mach-snapdragon in the next revision
of this series, and the button code will eventually be handled by my
proposed "button cmd" patch.

The smem code (msm_fixup_memory()) will be dropped in favour of using DT
as the source of truth.
> 
> -Sumit
> 
>>
>> Signed-off-by: Caleb Connolly 
>> ---
>>  arch/arm/mach-snapdragon/Makefile  |  2 -
>>  arch/arm/mach-snapdragon/include/mach/dram.h   | 12 -
>>  arch/arm/mach-snapdragon/misc.c| 55 
>> --
>>  board/qualcomm/dragonboard410c/Makefile|  3 +-
>>  board/qualcomm/dragonboard410c/dragonboard410c.c   |  4 +-
>>  .../qualcomm/dragonboard410c/misc.c| 51 +++-
>>  .../mach => board/qualcomm/dragonboard410c}/misc.h |  1 +
>>  7 files changed, 54 insertions(+), 74 deletions(-)
>>
>> diff --git a/arch/arm/mach-snapdragon/Makefile 
>> b/arch/arm/mach-snapdragon/Makefile
>> index 3a3a297c1768..d02432df8b04 100644
>> --- a/arch/arm/mach-snapdragon/Makefile
>> +++ b/arch/arm/mach-snapdragon/Makefile
>> @@ -6,6 +6,4 @@ obj-$(CONFIG_SDM845) += sysmap-sdm845.o
>>  obj-$(CONFIG_SDM845) += init_sdm845.o
>>  obj-$(CONFIG_TARGET_DRAGONBOARD820C) += sysmap-apq8096.o
>>  obj-$(CONFIG_TARGET_DRAGONBOARD410C) += sysmap-apq8016.o
>> -obj-y += misc.o
>> -obj-y += dram.o
>>  obj-$(CONFIG_TARGET_QCS404EVB) += sysmap-qcs404.o
>> diff --git a/arch/arm/mach-snapdragon/include/mach/dram.h 
>> b/arch/arm/mach-snapdragon/include/mach/dram.h
>> deleted file mode 100644
>> index 0a9eedda414c..
>> --- a/arch/arm/mach-snapdragon/include/mach/dram.h
>> +++ /dev/null
>> @@ -1,12 +0,0 @@
>> -/* SPDX-License-Identifier: GPL-2.0+ */
>> -/*
>> - * Snapdragon DRAM
>> - * Copyright (C) 2018 Ramon Fried 
>> - */
>> -
>> -#ifndef DRAM_H
>> -#define DRAM_H
>> -
>> -int msm_fixup_memory(void *blob);
>> -
>> -#endif
>> diff --git a/arch/arm/mach-snapdragon/misc.c 
>> b/arch/arm/mach-snapdragon/misc.c
>> deleted file mode 100644
>> index 7d452f4529b7..
>> --- a/arch/arm/mach-snapdragon/misc.c
>> +++ /dev/null
>> @@ -1,55 +0,0 @@
>> -// SPDX-License-Identifier: GPL-2.0+
>> -/*
>> - * Miscellaneous Snapdragon functionality
>> - *
>> - * (C) Copyright 2018 Ramon Fried 
>> - *
>> - */
>> -
>> -#include 
>> -#include 
>> -#include 
>> -#include 
>> -
>> -/* UNSTUFF_BITS macro taken from Linux Kernel: drivers/mmc/core/sd.c */
>> -#define UNSTUFF_BITS(resp, start, size) \
>> -   ({ \
>> -   const int __size = size; \
>> -   const u32 __mask = (__size < 32 ? 1 << __size : 0) - 1; \
>> -   const int __off = 3 - ((start) / 32); \
>> -   const int __shft = (start) & 31; \
>> -   u32 __res; \
>> -   \
>> -   __res = resp[__off] >> __shft; \
>> -   if (__size + __shft > 32) \
>> -   __res |= resp[__off - 1] << ((32 - __shft) % 32); \
>> -   __res & __mask; \
>> -   })
>> -
>> -u32 msm_board_serial(void)
>> -{
>> -   struct mmc *mmc_dev;
>> -
>> -   mmc_dev = find_mmc_device(0);
>> -   if (!mmc_dev)
>> -   return 0;
>> -
>> -   if (mmc_init(mmc_dev))
>> -   return 0;
>> -
>> -   return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
>> -}
>> -
>> -void msm_generate_mac_addr(u8 *mac)
>> -{
>> -   /* use locally adminstrated pool */
>> -   mac[0] = 0x02;
>> -   mac[1] = 0x00;
>> -
>> -   /*
>> -* Put the 32-bit serial number in the last 32-bit of the MAC 
>> address.
>> -* Use big endian order so it is consistent with the serial number
>> -* written as a hexadecimal string, e.g. 0x1234abcd -> 
>> 02:00:12:34:ab:cd
>> -*/
>> -   put_unaligned_be32(msm_board_serial(), [2]);
>> -}
>> diff --git a/board/qualcomm/dragonboard410c/Makefile 
>> b/board/qualcomm/dragonboard410c/Makefile
>> index 1b99c8b0efef..a3ae1a5f9136 100644
>> --- a/board/qualcomm/dragonboard410c/Makefile
>> +++ b/board/qualcomm/dragonboard410c/Makefile
>> @@ -2,4 +2,5 @@
>>  #
>>  # (C) Copyright 2015 Mateusz Kulikowski 
>>
>> -obj-y  := 

[PATCH] Add XMC XM25QH128C/XM25QH256C/XM25QU256C/XM25QH512C/XM25QU512C site: https://www.xmcwh.com/site/product

2024-01-16 Thread Ssunk
Signed-off-by: Kankan Sun 
---
V1 -> V2: separate the ID and Defconfig 
 drivers/mtd/spi/spi-nor-ids.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c
index 8db522fca0..32329704d5 100644
--- a/drivers/mtd/spi/spi-nor-ids.c
+++ b/drivers/mtd/spi/spi-nor-ids.c
@@ -554,6 +554,10 @@ const struct flash_info spi_nor_ids[] = {
{ INFO("XM25QH64C", 0x204017, 0, 64 * 1024, 128, SECT_4K | 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
{ INFO("XM25QH128A", 0x207018, 0, 64 * 1024, 256, SECT_4K | 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
{ INFO("XM25QU128C", 0x204118, 0, 64 * 1024, 256, SECT_4K | 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
+   { INFO("XM25QH256C", 0x204019, 0, 64 * 1024, 512, SECT_4K | 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("XM25QU256C", 0x204119, 0, 64 * 1024, 512, SECT_4K | 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("XM25QH512C", 0x204020, 0, 64 * 1024, 1024, SECT_4K | 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
+   { INFO("XM25QU512C", 0x204120, 0, 64 * 1024, 1024, SECT_4K | 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
 #endif
 #ifdef CONFIG_SPI_FLASH_XTX
/* XTX Technology Limited */
-- 
2.34.1



Re: [PATCH v2 1/2] xilinx: board: Update the kaslr-seed property

2024-01-16 Thread Michal Simek




On 1/16/24 05:50, Venkatesh Yadav Abbarapu wrote:

Create a ft_board_setup() api that gets called as part
of bootm/booti before jumping to kernel. In this
ft_board_setup() callback that will inspect the DTB
and insert the device tree blob with the "kaslr-seed" property.

Signed-off-by: Michal Simek 
Signed-off-by: Venkatesh Yadav Abbarapu 
---
  board/xilinx/common/board.c | 50 +
  1 file changed, 50 insertions(+)

diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 12a877c715..2796d45351 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -25,6 +25,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -682,3 +683,52 @@ phys_addr_t board_get_usable_ram_top(phys_size_t 
total_size)
return reg + size;
  }
  #endif
+
+#ifdef CONFIG_OF_BOARD_SETUP
+#define MAX_RAND_SIZE 8
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+   size_t n = MAX_RAND_SIZE;
+   struct udevice *dev;
+   u8 buf[MAX_RAND_SIZE];
+   int nodeoffset;
+   int ret;


put it on the same line.


+
+   if (uclass_get_device(UCLASS_RNG, 0, ) || !dev) {
+   debug("No RNG device\n");
+   return -EINVAL;


Why did you changed it from 0?

Pretty much this change breaks all current SOMs with saved variables because 
most of them doesn't really start TPM.


I would say return 0 here.



+   }
+
+   if (dm_rng_read(dev, buf, n)) {
+   debug("Reading RNG failed\n");
+   return -EINVAL;


return 0 here.


+   }
+
+   if (!blob) {
+   debug("No FDT memory address configured. Please configure\n"
+ "the FDT address via \"fdt addr \" command.\n"
+ "Aborting!\n");
+   return -EINVAL;


return 0


+   }
+
+   ret = fdt_check_header(blob);
+   if (ret < 0) {
+   debug("fdt_chosen: %s\n", fdt_strerror(ret));
+   return -EINVAL;


no reason to make own return code

return ret;


+   }
+
+   nodeoffset = fdt_find_or_add_subnode(blob, 0, "chosen");
+   if (nodeoffset < 0) {
+   debug("Reading chosen node failed\n");
+   return -EINVAL;


return ret;


+   }
+
+   ret = fdt_setprop(blob, nodeoffset, "kaslr-seed", buf, sizeof(buf));
+   if (ret < 0) {
+   debug("Unable to set kaslr-seed on chosen node: %s\n", 
fdt_strerror(ret));
+   return -EINVAL;


return ret;


+   }
+
+   return ret;


return 0;


+}
+#endif


M


[PATCH v2 2/2] spl: Add support for booting from ESP

2024-01-16 Thread Mayuresh Chitale
Some platforms as described by EBBR specification may store images in
the FIRMWARE directory of the UEFI system partition(ESP). Add support
to boot from the EFI system partition if it is enabled for a platform.

Signed-off-by: Mayuresh Chitale 
---
 common/spl/Kconfig  |  8 +++
 common/spl/spl_blk_fs.c | 51 ++---
 common/spl/spl_fat.c| 34 +++
 3 files changed, 75 insertions(+), 18 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index cf7ffc9b112..48e4e43196a 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1292,6 +1292,14 @@ config SPL_SATA_RAW_U_BOOT_SECTOR
  Sector on the SATA disk to load U-Boot from, when the SATA disk is 
being
  used in raw mode. Units: SATA disk sectors (1 sector = 512 bytes).
 
+config SPL_ESP_BOOT
+   bool "Load next stage boot image from the UEFI system partition"
+   default y if BOOT_DEFAULTS
+   select SPL_PARTITION_TYPE_GUID
+   help
+ When enabled, first try to boot from the UEFI system partition as
+ described in the Ch.4 of the EBBR specification.
+
 config SPL_NVME
bool "NVM Express device support"
depends on BLK
diff --git a/common/spl/spl_blk_fs.c b/common/spl/spl_blk_fs.c
index 04eac6f306b..a2e8c2ce910 100644
--- a/common/spl/spl_blk_fs.c
+++ b/common/spl/spl_blk_fs.c
@@ -10,12 +10,15 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
 struct blk_dev {
const char *ifname;
const char *filename;
+   int devnum;
+   int partnum;
char dev_part_str[8];
 };
 
@@ -44,6 +47,29 @@ static ulong spl_fit_read(struct spl_load_info *load, ulong 
file_offset,
return actlen;
 }
 
+static int spl_blk_file_size(struct blk_dev *dev, const char *filename,
+loff_t *filesize)
+{
+   int ret;
+
+   snprintf(dev->dev_part_str, sizeof(dev->dev_part_str) - 1, "%x:%x",
+dev->devnum, dev->partnum);
+   debug("Loading file %s from %s %s\n", filename, dev->ifname,
+ dev->dev_part_str);
+   ret = fs_set_blk_dev(dev->ifname, dev->dev_part_str, FS_TYPE_ANY);
+   if (ret) {
+   printf("spl: unable to set blk_dev %s %s. Err - %d\n",
+  dev->ifname, dev->dev_part_str, ret);
+   return ret;
+   }
+
+   ret = fs_size(filename, filesize);
+   if (ret)
+   printf("spl: unable to get size, file: %s. Err - %d\n",
+  filename, ret);
+   return ret;
+}
+
 int spl_blk_load_image(struct spl_image_info *spl_image,
   struct spl_boot_device *bootdev,
   enum uclass_id uclass_id, int devnum, int partnum)
@@ -53,7 +79,7 @@ int spl_blk_load_image(struct spl_image_info *spl_image,
loff_t filesize;
struct blk_dev dev;
struct spl_load_info load;
-   int ret;
+   int ret, part;
 
blk_desc = blk_get_devnum_by_uclass_id(uclass_id, devnum);
if (!blk_desc) {
@@ -65,21 +91,18 @@ int spl_blk_load_image(struct spl_image_info *spl_image,
 
dev.filename = filename;
dev.ifname = blk_get_uclass_name(uclass_id);
-   snprintf(dev.dev_part_str, sizeof(dev.dev_part_str) - 1, "%x:%x",
-devnum, partnum);
-   ret = fs_set_blk_dev(dev.ifname, dev.dev_part_str, FS_TYPE_ANY);
-   if (ret) {
-   printf("spl: unable to set blk_dev %s %s. Err - %d\n",
-  dev.ifname, dev.dev_part_str, ret);
-   return ret;
+   dev.devnum = devnum;
+   dev.partnum = partnum;
+   if (IS_ENABLED(CONFIG_SPL_ESP_BOOT)) {
+   part = part_get_esp(blk_desc);
+   if (part)
+   dev.partnum = part;
+   else
+   return -ENODEV;
}
-
-   ret = fs_size(filename, );
-   if (ret) {
-   printf("spl: unable to get file size: %s. Err - %d\n",
-  filename, ret);
+   ret = spl_blk_file_size(, filename, );
+   if (ret)
return ret;
-   }
 
load.read = spl_fit_read;
if (IS_ENABLED(CONFIG_SPL_FS_FAT_DMA_ALIGN))
diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index a52f9e178e6..8c426a3f3e7 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -60,10 +60,10 @@ static ulong spl_fit_read(struct spl_load_info *load, ulong 
file_offset,
return actread;
 }
 
-int spl_load_image_fat(struct spl_image_info *spl_image,
-  struct spl_boot_device *bootdev,
-  struct blk_desc *block_dev, int partition,
-  const char *filename)
+int spl_load_image_fat_one(struct spl_image_info *spl_image,
+  struct spl_boot_device *bootdev,
+  struct blk_desc *block_dev, int partition,
+  const char *filename)
 {
int 

[PATCH v2 1/2] part: Add a function to find ESP partition

2024-01-16 Thread Mayuresh Chitale
If a disk has an EFI system partition (ESP) then it can be used to
locate the boot files. Add a function to find the ESP.

Signed-off-by: Mayuresh Chitale 
Reviewed-by: Heinrich Schuchardt 
---
 disk/part.c| 16 
 include/part.h | 11 +++
 2 files changed, 27 insertions(+)

diff --git a/disk/part.c b/disk/part.c
index 36b88205eca..6b1fbc18637 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -848,3 +848,19 @@ int part_get_bootable(struct blk_desc *desc)
 
return 0;
 }
+
+int part_get_esp(struct blk_desc *desc)
+{
+   struct disk_partition info;
+   int p;
+
+   for (p = 1; p <= MAX_SEARCH_PARTITIONS; p++) {
+   int ret;
+
+   ret = part_get_info(desc, p, );
+   if (!ret && (info.bootable & PART_EFI_SYSTEM_PARTITION))
+   return p;
+   }
+
+   return 0;
+}
diff --git a/include/part.h b/include/part.h
index db34bc6bb7d..30e049c8f19 100644
--- a/include/part.h
+++ b/include/part.h
@@ -690,6 +690,14 @@ int part_get_type_by_name(const char *name);
  */
 int part_get_bootable(struct blk_desc *desc);
 
+/**
+ * part_get_esp() - Find the EFI system partition
+ *
+ * @desc: Block-device descriptor
+ * @Return the EFI system partition, or 0 if there is none
+ */
+int part_get_esp(struct blk_desc *desc);
+
 #else
 static inline int part_driver_get_count(void)
 { return 0; }
@@ -700,6 +708,9 @@ static inline struct part_driver 
*part_driver_get_first(void)
 static inline bool part_get_bootable(struct blk_desc *desc)
 { return false; }
 
+static inline bool part_get_esp(struct blk_desc *desc)
+{ return false; }
+
 #endif /* CONFIG_PARTITIONS */
 
 #endif /* _PART_H */
-- 
2.34.1



[PATCH v2 0/2] SPL EBBR - EFI System Partition support

2024-01-16 Thread Mayuresh Chitale
This series adds support to locate an EFI System Partition on a disk and
boot the next stage from such a parition if found. The next stage image
is expected to be under the FIRMWARE directory as described in the EBBR
specification [1]. Also update the spl_blk_fs and spl_fat drivers to
prefer booting from ESP and fall back to the configured parition in
case of a failure.

Changes in v2:
- Rebase on latest next branch
- Enable SPL_ESP_BOOT by default
- For NVMe boot, remove fallback in case of ESP boot failure

Mayuresh Chitale (2):
  part: Add a function to find ESP partition
  spl: Add support for booting from ESP

 common/spl/Kconfig  |  8 +++
 common/spl/spl_blk_fs.c | 51 ++---
 common/spl/spl_fat.c| 34 +++
 disk/part.c | 16 +
 include/part.h  | 11 +
 5 files changed, 102 insertions(+), 18 deletions(-)

-- 
2.34.1



Please pull qcom-2024.04-rc1

2024-01-16 Thread Caleb Connolly
Hi Tom,

The following changes since commit 697758e7c81131da6db0e3b10515019fe3aca8c9:

  Merge branch 'master-sync-dts-663' of 
https://source.denx.de/u-boot/custodians/u-boot-sh (2024-01-14 18:07:49 -0500)

are available in the Git repository at:

  g...@source.denx.de:/u-boot/custodians/u-boot-snapdragon.git 
tags/qcom-2024.04-rc1

for you to fetch changes up to 4c3dfa1b8babf9fc0575ce08eed99f950d3bab84:

  sandbox_flattree: enable button support (2024-01-16 12:26:54 +)

Qualcomm architecture changes:

* Move clock and pinctrl drivers out of mach-snapdragon
* Various clock driver improvements
* Convert PMIC power/reset key driver to use the button API
* Preparetory work for migrating to upstream DT

Caleb Connolly (23):
  clk/qcom: move from mach-snapdragon
  clk/qcom: move ipq4019 driver from mach-ipq40xx
  clk/qcom: sdm845: add register map for simple gate clocks
  clk/qcom: use function pointers for enable and set_rate
  clk/qcom: add mnd_width to clk_rcg_set_rate_mnd()
  clk/qcom: fix rcg divider value
  pinctrl: qcom: move out of mach-snapdragon
  pinctrl: qcom: move ipq4019 driver from mach-ipq40xx
  pinctrl: qcom: make compatible with linux DTs
  msm_gpio: use unsigned int
  serial: msm-geni: don't rely on parent misc device
  serial: msm-geni: handle devm_clk_get() errors
  gpio: qcom_pmic: fix silent dev_read_addr downcast
  button: qcom-pmic: introduce Qualcomm PMIC button driver
  mach-snapdragon: switch to PMIC button driver
  gpio: qcom_pmic: drop pon GPIO driver
  gpio: qcom_pmic: support upstream DT
  dts: qcom: adjust pmic gpio to use upstream bindings
  gpio: qcom_pmic: drop gpio-count property
  spmi: msm: fix register range names
  pmic: qcom: dont use dev_read_addr to get USID
  test: spmi: fix tests
  sandbox_flattree: enable button support

Konrad Dybcio (1):
  clk/qcom: handle resets and clocks in one device

 MAINTAINERS|   3 +
 arch/arm/Kconfig   |   3 +
 arch/arm/dts/dragonboard410c-uboot.dtsi|  11 -
 arch/arm/dts/dragonboard410c.dts   |  25 +-
 arch/arm/dts/dragonboard820c-uboot.dtsi|  12 -
 arch/arm/dts/dragonboard820c.dts   |  26 +-
 arch/arm/dts/dragonboard845c-uboot.dtsi|  13 +-
 arch/arm/dts/dragonboard845c.dts   |   4 +
 arch/arm/dts/qcom-ipq4019.dtsi |  14 +-
 arch/arm/dts/qcs404-evb.dts|  29 +-
 arch/arm/dts/sdm845.dtsi   |  44 +--
 arch/arm/dts/starqltechn-uboot.dtsi|  15 +-
 arch/arm/dts/starqltechn.dts   |  36 +--
 arch/arm/mach-ipq40xx/Makefile |   9 -
 arch/arm/mach-ipq40xx/clock-ipq4019.c  |  88 --
 arch/arm/mach-ipq40xx/pinctrl-snapdragon.c | 166 ---
 arch/arm/mach-snapdragon/Kconfig   |  11 +
 arch/arm/mach-snapdragon/Makefile  |  10 -
 arch/arm/mach-snapdragon/clock-sdm845.c|  98 ---
 arch/arm/mach-snapdragon/clock-snapdragon.c| 181 
 arch/arm/mach-snapdragon/clock-snapdragon.h|  48 
 arch/arm/mach-snapdragon/include/mach/gpio.h   |  28 +-
 .../mach-snapdragon/include/mach/sysmap-apq8016.h  |  39 ---
 .../mach-snapdragon/include/mach/sysmap-apq8096.h  |  37 ---
 .../mach-snapdragon/include/mach/sysmap-qcs404.h   |  88 --
 .../mach-snapdragon/include/mach/sysmap-sdm845.h   |  42 ---
 arch/arm/mach-snapdragon/init_sdm845.c |  45 +--
 arch/arm/mach-snapdragon/pinctrl-sdm845.c  |  44 ---
 arch/arm/mach-snapdragon/pinctrl-snapdragon.h  |  33 ---
 arch/sandbox/dts/test.dts  |   2 +-
 board/qualcomm/dragonboard410c/dragonboard410c.c   |  31 +--
 board/qualcomm/dragonboard820c/dragonboard820c.c   |  35 +--
 configs/sandbox_flattree_defconfig |   3 +
 doc/device-tree-bindings/gpio/pm8916_gpio.txt  |  48 
 doc/device-tree-bindings/pmic/qcom,spmi-pmic.txt   |  94 ---
 doc/device-tree-bindings/spmi/spmi-msm.txt |  26 --
 drivers/button/Kconfig |   9 +
 drivers/button/Makefile|   1 +
 drivers/button/button-qcom-pmic.c  | 165 +++
 drivers/clk/Kconfig|   1 +
 drivers/clk/Makefile   |   1 +
 drivers/clk/qcom/Kconfig   |  52 
 drivers/clk/qcom/Makefile  |  10 +
 .../clk/qcom}/clock-apq8016.c  |  60 +++-
 .../clk/qcom}/clock-apq8096.c  |  56 +++-
 .../reset-qcom.c => clk/qcom/clock-ipq4019.c}  | 160 ---
 drivers/clk/qcom/clock-qcom.c 

Re: [PATCH 03/10] soc: ti: k3-navss-ringacc: Initialize base address of ring cfg registers

2024-01-16 Thread Roger Quadros
Hi,

On 12/01/2024 08:47, Siddharth Vadapalli wrote:
> From: Kishon Vijay Abraham I 
> 
> Initialize base address of ring config registers required to natively
> setup ring cfg registers in the absence of Device Manager (DM) services
> at R5 SPL stage.
> 
> Signed-off-by: Kishon Vijay Abraham I 
> Signed-off-by: Siddharth Vadapalli 
> ---
>  drivers/soc/ti/k3-navss-ringacc.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/soc/ti/k3-navss-ringacc.c 
> b/drivers/soc/ti/k3-navss-ringacc.c
> index 7a2fbb0db6..31e9b372ee 100644
> --- a/drivers/soc/ti/k3-navss-ringacc.c
> +++ b/drivers/soc/ti/k3-navss-ringacc.c
> @@ -1030,8 +1030,8 @@ static int k3_nav_ringacc_init(struct udevice *dev, 
> struct k3_nav_ringacc *ringa
>  struct k3_nav_ringacc *k3_ringacc_dmarings_init(struct udevice *dev,
>   struct k3_ringacc_init_data 
> *data)
>  {
> + void __iomem *base_rt, *base_cfg;
>   struct k3_nav_ringacc *ringacc;
> - void __iomem *base_rt;
>   int i;
>  
>   ringacc = devm_kzalloc(dev, sizeof(*ringacc), GFP_KERNEL);
> @@ -1049,6 +1049,10 @@ struct k3_nav_ringacc *k3_ringacc_dmarings_init(struct 
> udevice *dev,
>   if (!base_rt)
>   return ERR_PTR(-EINVAL);
>  
> + base_cfg = dev_read_addr_name_ptr(dev, "cfg");
> + if (!base_cfg)
> + return ERR_PTR(-EINVAL);
> +

Should this be restricted only for R5 SPL case? else we conflict with
Device Manager services?

>   ringacc->rings = devm_kzalloc(dev,
> sizeof(*ringacc->rings) *
> ringacc->num_rings * 2,
> @@ -1063,6 +1067,7 @@ struct k3_nav_ringacc *k3_ringacc_dmarings_init(struct 
> udevice *dev,
>   for (i = 0; i < ringacc->num_rings; i++) {
>   struct k3_nav_ring *ring = >rings[i];
>  
> + ring->cfg = base_cfg + KNAV_RINGACC_CFG_REGS_STEP * i;
>   ring->rt = base_rt + K3_DMARING_RING_RT_REGS_STEP * i;
>   ring->parent = ringacc;
>   ring->ring_id = i;

-- 
cheers,
-roger


Re: [PATCH v4 4/7] arm: dts: k3-am625-sk: Enable usb port in u-boot

2024-01-16 Thread Sjoerd Simons
On Tue, 2024-01-16 at 12:17 +0100, Mattijs Korpershoek wrote:
> Hi Sjoerd
> 
> Thank you for the patch.
> 
> On ven., janv. 12, 2024 at 09:52, Sjoerd Simons
>  wrote:
> 
> > Enable usb0 in all boot phases for use with DFU
> > 
> > Signed-off-by: Sjoerd Simons 
> > 
> > ---
> > 
> > Changes in v4:
> > - Don't force usb0 into peripheral mode
> 
> I know that dr_mode = "peripheral" has been removed as requested by
> Roger here:
> 
> https://lore.kernel.org/all/054aa15f-05b9-4645-ab00-fac1be46d...@kernel.org/
> 
> However, the reason for this was the following series:
> https://lore.kernel.org/all/20230706-handle-otg-as-periph-v3-0-27e24fa17...@baylibre.com/
> 
> I've spoken to Julien (off-list) about the above series and he
> confirmed
> that there are no plans to keep working this.
> 
> Therefore, I'd prefer to re-instate dr_mode = "peripheral" here to
> make
> this series simpler and focus on enabling DFU.
> 
> Would that be possible ?

If others agree sure; I really don't care either way (I wouldn't use
the port as host in any case), I only addressed it because i got a
complaint about it :)

Roger?

> 
> > 
> > Changes in v3:
> > - Enable usb nodes in all boot phases
> > 
> > Changes in v2:
> > - Only enable usb port 0 DFU in SPL
> > 
> >  arch/arm/dts/k3-am625-sk-u-boot.dtsi | 8 
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/arch/arm/dts/k3-am625-sk-u-boot.dtsi
> > b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
> > index fa778b0ff4c..67c9fa2bbc3 100644
> > --- a/arch/arm/dts/k3-am625-sk-u-boot.dtsi
> > +++ b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
> > @@ -46,3 +46,11 @@
> >  _port2 {
> >     status = "disabled";
> >  };
> > +
> > + {
> > +   bootph-all;
> > +};
> > +
> > + {
> > +   bootph-all;
> > +};
> > -- 
> > 2.43.0

-- 
Sjoerd Simons
Collabora Ltd.


Re: [PATCH v4 4/7] arm: dts: k3-am625-sk: Enable usb port in u-boot

2024-01-16 Thread Mattijs Korpershoek
Hi Sjoerd

Thank you for the patch.

On ven., janv. 12, 2024 at 09:52, Sjoerd Simons  wrote:

> Enable usb0 in all boot phases for use with DFU
>
> Signed-off-by: Sjoerd Simons 
>
> ---
>
> Changes in v4:
> - Don't force usb0 into peripheral mode

I know that dr_mode = "peripheral" has been removed as requested by
Roger here:

https://lore.kernel.org/all/054aa15f-05b9-4645-ab00-fac1be46d...@kernel.org/

However, the reason for this was the following series:
https://lore.kernel.org/all/20230706-handle-otg-as-periph-v3-0-27e24fa17...@baylibre.com/

I've spoken to Julien (off-list) about the above series and he confirmed
that there are no plans to keep working this.

Therefore, I'd prefer to re-instate dr_mode = "peripheral" here to make
this series simpler and focus on enabling DFU.

Would that be possible ?

>
> Changes in v3:
> - Enable usb nodes in all boot phases
>
> Changes in v2:
> - Only enable usb port 0 DFU in SPL
>
>  arch/arm/dts/k3-am625-sk-u-boot.dtsi | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/arch/arm/dts/k3-am625-sk-u-boot.dtsi 
> b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
> index fa778b0ff4c..67c9fa2bbc3 100644
> --- a/arch/arm/dts/k3-am625-sk-u-boot.dtsi
> +++ b/arch/arm/dts/k3-am625-sk-u-boot.dtsi
> @@ -46,3 +46,11 @@
>  _port2 {
>   status = "disabled";
>  };
> +
> + {
> + bootph-all;
> +};
> +
> + {
> + bootph-all;
> +};
> -- 
> 2.43.0


Re: [PATCH v4 7/7] doc: board: Add document for DFU boot on am62x SoCs

2024-01-16 Thread Mattijs Korpershoek
Hi Sjoerd,

Thank you for the patch.

On ven., janv. 12, 2024 at 09:52, Sjoerd Simons  wrote:

> Both AM62 SK and beagleplay support DFU boot in a similar way now;
> Document how to actually run DFU boot for both boards
>
> Signed-off-by: Sjoerd Simons 

>
> ---
>
> Changes in v4:
> - New patch
>
>  doc/board/beagle/am62x_beagleplay.rst | 12 +
>  doc/board/ti/am62x_sk.rst | 37 +++
>  2 files changed, 49 insertions(+)
>
> diff --git a/doc/board/beagle/am62x_beagleplay.rst 
> b/doc/board/beagle/am62x_beagleplay.rst
> index 7784e62b0b7..4c8b0845845 100644
> --- a/doc/board/beagle/am62x_beagleplay.rst
> +++ b/doc/board/beagle/am62x_beagleplay.rst
> @@ -270,6 +270,18 @@ for details.
>  To switch to SD card boot mode, hold the USR button while powering on
>  with Type-C power supply, then release when power LED lights up.
>  
> +DFU based boot
> +--
> +
> +To boot the board over DFU, ensure there is no SD card inserted with a
> +bootloader. Hold the USR switch while plugging into the Type C to boot into 
> DFU
> +mode. After power-on the build artifacts needs to be uploaded one by one 
> with a
> +tool like dfu-util.
> +
> +.. include::  ../ti/am62x_sk.rst
> +:start-after: .. am62x_evm_rst_include_start_dfu_boot
> +:end-before: .. am62x_evm_rst_include_end_dfu_boot
> +
>  Debugging U-Boot
>  
>  
> diff --git a/doc/board/ti/am62x_sk.rst b/doc/board/ti/am62x_sk.rst
> index b12dc85f06b..904a54cd5ff 100644
> --- a/doc/board/ti/am62x_sk.rst
> +++ b/doc/board/ti/am62x_sk.rst
> @@ -105,6 +105,20 @@ Set the variables corresponding to this platform:
>  
>  * 3.1 R5:
>  
> +.. include::  ../ti/k3.rst
> +:start-after: .. k3_rst_include_start_build_steps_spl_r5
> +:end-before: .. k3_rst_include_end_build_steps_spl_r5
> +
> +* 3.1.1 Alternatively build R5 for DFU boot:
> +
> +As the SPL size can get to big when building with support for booting both 
> from

s/to/too

> +local storage *and* DFU an extra config fragment should be used to enable DFU
> +support (and disable storage support)
> +
> +.. prompt:: bash $
> +
> +  export UBOOT_CFG_CORTEXR=${UBOOT_CFG_CORTEXR} am62x_r5_usbdfu.config
> +
>  .. include::  ../ti/k3.rst
>  :start-after: .. k3_rst_include_start_build_steps_spl_r5
>  :end-before: .. k3_rst_include_end_build_steps_spl_r5
> @@ -251,6 +265,29 @@ https://www.ti.com/lit/pdf/spruiv7 under the `Boot Mode 
> Pins` section.
>  
>  For SW2 and SW1, the switch state in the "ON" position = 1.
>  
> +DFU based boot
> +--
> +
> +To boot the board over DFU, set the switches to DFU mode and connect to the
> +USB Type C DRD Port on the board. After power-on the build artifacts needs 
> to be

s/Type/type
s/Port/port

> +uploaded one by one with a tool like dfu-util.
> +
> +.. am62x_evm_rst_include_start_dfu_boot
> +
> +The initial ROM will have a DFU alt named `bootloader` for the initial R5 spl
> +upload. The next stages as exposed by u-boot have target alts matching the 
> name

s/u-boot/U-Boot

> +of the artifacts, for these a USB reset has to be done after each upload.
> +
> +When using dfu-util the following commands can be used to boot to a u-boot 
> shell:

s/u-boot/U-Boot

With all above typos addressed:

Reviewed-by: Mattijs Korpershoek 


> +
> +.. prompt:: bash $
> +
> +  dfu-util -a bootloader -D tiboot3.bin
> +  dfu-util -R -a tispl -D tispl.bin
> +  dfu-util -R -a u-boot.img -D u-boot.img
> +
> +.. am62x_evm_rst_include_end_dfu_boot
> +
>  Debugging U-Boot
>  
>  
> -- 
> 2.43.0


Re: [PATCH v4 3/7] board: ti: am62x: am62x: include env for DFU

2024-01-16 Thread Mattijs Korpershoek
Hi Sjoerd,

Thank you for the patch.

On ven., janv. 12, 2024 at 09:52, Sjoerd Simons  wrote:

> Include standard TI K3 dfu environment
>
> Signed-off-by: Sjoerd Simons 

Reviewed-by: Mattijs Korpershoek 

>
> ---
>
> (no changes since v3)
>
> Changes in v3:
> - Add dfu via environment rather then config headers
>
> Changes in v2:
> - Minimize config changes to just DFU configuration
>
>  board/ti/am62x/am62x.env | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/board/ti/am62x/am62x.env b/board/ti/am62x/am62x.env
> index e53a55c38fb..0651b9cd7cb 100644
> --- a/board/ti/am62x/am62x.env
> +++ b/board/ti/am62x/am62x.env
> @@ -1,6 +1,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  name_kern=Image
>  console=ttyS2,115200n8
> -- 
> 2.43.0


Re: [PATCH v4 2/7] usb: dwc3: Switch to device mode on gadget start

2024-01-16 Thread Mattijs Korpershoek
Hi Sjoerd, Caleb

On ven., janv. 12, 2024 at 12:55, Caleb Connolly  
wrote:

> Hi Sjoerd,
>
> On 12/01/2024 08:52, Sjoerd Simons wrote:
>> When dr_mode is "otg" the dwc3 is initially configured in _OTG mode;
>> However in this mode the gadget functionality doesn't work without
>> further configuration. To resolve that on gadget start switch to _DEVICE
>> mode globally and go back to _OTG on stop again.
>> 
>> For this the dwc3_set_mode is renamed to dwc3_core_set_mode to avoid a
>> conflict with the same function exposed by xhci-dwc3
>
> I think exporting dwc3_core_set_mode() is probably sensible here. But
> I'm not so sure on calling it from dwc3_gadget_start(), that's making
> assumptions about board specific implementation details - some boards
> might require additional configuration to switch into gadget mode.

Indeed. As an example, take the Khadas VIM3 which has a glue driver to
do the mode switching.

>
> What about calling dwc3_core_set_mode() from within your board-specific
> board_usb_init() function?

With DM_USB_GADGET, board_usb_init/cleanup() are no longer used.

For VIM3, I solved this with:
https://lore.kernel.org/all/20221024-meson-dm-usb-v1-1-2ab077a50...@baylibre.com/

Maybe that can help?

>
> Obviously as you said the ideal solution here is that we can correctly
> traverse the type-c connector model from within U-Boot, but that's a
> whole other kettle of fish :P
>
> On Qualcomm platforms I'm currently handling this by overriding the
> dr_mode property in a -u-boot.dtsi file, if you aren't using the
> same DT for U-Boot and Linux then maybe this would be acceptable for you
> too?

I would prefer a -u-boot.dtsi change as well.

>
> Kind regards,
>> 
>> Signed-off-by: Sjoerd Simons 
>> 
>> ---
>> 
>> Changes in v4:
>> - New patch
>> 
>>  drivers/usb/dwc3/core.c   | 10 +-
>>  drivers/usb/dwc3/core.h   |  1 +
>>  drivers/usb/dwc3/gadget.c |  6 ++
>>  3 files changed, 12 insertions(+), 5 deletions(-)
>> 
>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>> index 4b4fcd8a22e..d22d4c4bb6a 100644
>> --- a/drivers/usb/dwc3/core.c
>> +++ b/drivers/usb/dwc3/core.c
>> @@ -42,7 +42,7 @@
>>  static LIST_HEAD(dwc3_list);
>>  /* 
>> -- */
>>  
>> -static void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
>> +void dwc3_core_set_mode(struct dwc3 *dwc, u32 mode)
>>  {
>>  u32 reg;
>>  
>> @@ -736,7 +736,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
>>  
>>  switch (dwc->dr_mode) {
>>  case USB_DR_MODE_PERIPHERAL:
>> -dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
>> +dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
>>  ret = dwc3_gadget_init(dwc);
>>  if (ret) {
>>  dev_err(dwc->dev, "failed to initialize gadget\n");
>> @@ -744,7 +744,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
>>  }
>>  break;
>>  case USB_DR_MODE_HOST:
>> -dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
>> +dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
>>  ret = dwc3_host_init(dwc);
>>  if (ret) {
>>  dev_err(dwc->dev, "failed to initialize host\n");
>> @@ -752,7 +752,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
>>  }
>>  break;
>>  case USB_DR_MODE_OTG:
>> -dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
>> +dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
>>  ret = dwc3_host_init(dwc);
>>  if (ret) {
>>  dev_err(dwc->dev, "failed to initialize host\n");
>> @@ -810,7 +810,7 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc)
>>   * switch back to peripheral mode
>>   * This enables the phy to enter idle and then, if enabled, suspend.
>>   */
>> -dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
>> +dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
>>  dwc3_gadget_run(dwc);
>>  }
>>  
>> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
>> index 4162a682298..1e7eda89a34 100644
>> --- a/drivers/usb/dwc3/core.h
>> +++ b/drivers/usb/dwc3/core.h
>> @@ -1057,6 +1057,7 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc);
>>  void dwc3_of_parse(struct dwc3 *dwc);
>>  int dwc3_init(struct dwc3 *dwc);
>>  void dwc3_remove(struct dwc3 *dwc);
>> +void dwc3_core_set_mode(struct dwc3 *dwc, u32 mode);
>>  
>>  static inline int dwc3_host_init(struct dwc3 *dwc)
>>  { return 0; }
>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>> index 406d36ceafe..69d9fe40e2f 100644
>> --- a/drivers/usb/dwc3/gadget.c
>> +++ b/drivers/usb/dwc3/gadget.c
>> @@ -1468,6 +1468,9 @@ static int dwc3_gadget_start(struct usb_gadget *g,
>>  
>>  dwc->gadget_driver  = driver;
>>  
>> +if (dwc->dr_mode == DWC3_GCTL_PRTCAP_OTG)
>> +dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
>> +
>>  reg = dwc3_readl(dwc->regs, 

Re: [PATCH v4 2/7] usb: dwc3: Switch to device mode on gadget start

2024-01-16 Thread Mattijs Korpershoek
Hi Sjoerd,

Thank you for the patch.

On ven., janv. 12, 2024 at 09:52, Sjoerd Simons  wrote:

> When dr_mode is "otg" the dwc3 is initially configured in _OTG mode;
> However in this mode the gadget functionality doesn't work without
> further configuration. To resolve that on gadget start switch to _DEVICE
> mode globally and go back to _OTG on stop again.
>
> For this the dwc3_set_mode is renamed to dwc3_core_set_mode to avoid a
> conflict with the same function exposed by xhci-dwc3
>
> Signed-off-by: Sjoerd Simons 

Reviewed-by: Mattijs Korpershoek 

nitpick below.

>
> ---
>
> Changes in v4:
> - New patch
>
>  drivers/usb/dwc3/core.c   | 10 +-
>  drivers/usb/dwc3/core.h   |  1 +
>  drivers/usb/dwc3/gadget.c |  6 ++
>  3 files changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 4b4fcd8a22e..d22d4c4bb6a 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -42,7 +42,7 @@
>  static LIST_HEAD(dwc3_list);
>  /* 
> -- */
>  
> -static void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
> +void dwc3_core_set_mode(struct dwc3 *dwc, u32 mode)
>  {
>   u32 reg;
>  
> @@ -736,7 +736,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
>  
>   switch (dwc->dr_mode) {
>   case USB_DR_MODE_PERIPHERAL:
> - dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
> + dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
>   ret = dwc3_gadget_init(dwc);
>   if (ret) {
>   dev_err(dwc->dev, "failed to initialize gadget\n");
> @@ -744,7 +744,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
>   }
>   break;
>   case USB_DR_MODE_HOST:
> - dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
> + dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
>   ret = dwc3_host_init(dwc);
>   if (ret) {
>   dev_err(dwc->dev, "failed to initialize host\n");
> @@ -752,7 +752,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
>   }
>   break;
>   case USB_DR_MODE_OTG:
> - dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
> + dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
>   ret = dwc3_host_init(dwc);
>   if (ret) {
>   dev_err(dwc->dev, "failed to initialize host\n");
> @@ -810,7 +810,7 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc)
>* switch back to peripheral mode
>* This enables the phy to enter idle and then, if enabled, suspend.
>*/
> - dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
> + dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
>   dwc3_gadget_run(dwc);
>  }
>  
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index 4162a682298..1e7eda89a34 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -1057,6 +1057,7 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc);
>  void dwc3_of_parse(struct dwc3 *dwc);
>  int dwc3_init(struct dwc3 *dwc);
>  void dwc3_remove(struct dwc3 *dwc);
> +void dwc3_core_set_mode(struct dwc3 *dwc, u32 mode);
>  
>  static inline int dwc3_host_init(struct dwc3 *dwc)
>  { return 0; }
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 406d36ceafe..69d9fe40e2f 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -1468,6 +1468,9 @@ static int dwc3_gadget_start(struct usb_gadget *g,
>  
>   dwc->gadget_driver  = driver;
>  

Doesn't this bit deserves a comment ? When looking at the code it's not
obvious that we do this because PRTCAP_OTG is non-functional without any
additional configuration.

Maybe something in the lines of:

   /**
* WORKAROUND: in OTG mode, gadget functionality is non-functional.
* Switch to gadget mode only to enable gadget mode
*/

?

> + if (dwc->dr_mode == DWC3_GCTL_PRTCAP_OTG)
> + dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
> +
>   reg = dwc3_readl(dwc->regs, DWC3_DCFG);
>   reg &= ~(DWC3_DCFG_SPEED_MASK);
>  
> @@ -1559,6 +1562,9 @@ static int dwc3_gadget_stop(struct usb_gadget *g)
>   __dwc3_gadget_ep_disable(dwc->eps[0]);
>   __dwc3_gadget_ep_disable(dwc->eps[1]);
>  
> + if (dwc->dr_mode == DWC3_GCTL_PRTCAP_OTG)
> + dwc3_core_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
> +
>   dwc->gadget_driver  = NULL;
>  
>   spin_unlock_irqrestore(>lock, flags);
> -- 
> 2.43.0


Re: [PATCH v4 1/7] usb: dwc3: Add dwc3 glue driver for am62

2024-01-16 Thread Mattijs Korpershoek
Hi Sjoerd,

Thank you for the patch.

On ven., janv. 12, 2024 at 09:52, Sjoerd Simons  wrote:

> Add glue code for TI AM62 to the dwc3 driver; Most code adopted from
> TI vendor u-boot code.
>
> Signed-off-by: Sjoerd Simons 
>
> ---
>
> Changes in v4:
> - Add config dependency on SYSCON
> - Move defines and constants outside out of function scope
>
> Changes in v2:
> - Switch dwc3 glue to a seperate driver rather then in dwc-generic
>
>  drivers/usb/dwc3/Kconfig |  14 
>  drivers/usb/dwc3/Makefile|   1 +
>  drivers/usb/dwc3/dwc3-am62.c | 125 +++
>  3 files changed, 140 insertions(+)
>  create mode 100644 drivers/usb/dwc3/dwc3-am62.c
>
> diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
> index c0c8c16fd9c..0100723a68b 100644
> --- a/drivers/usb/dwc3/Kconfig
> +++ b/drivers/usb/dwc3/Kconfig
> @@ -37,6 +37,20 @@ config SPL_USB_DWC3_GENERIC
> Select this for Xilinx ZynqMP and similar Platforms.
> This wrapper supports Host and Peripheral operation modes.
>  
> +config SPL_USB_DWC3_AM62
> + bool "TI AM62 USB wrapper"
> + depends on SPL_DM_USB && SPL_USB_DWC3_GENERIC && SPL_SYSCON
> + help
> +   Select this for TI AM62 Platforms.
> +   This wrapper supports Host and Peripheral operation modes.
> +
> +config USB_DWC3_AM62
> + bool "TI AM62 USB wrapper"
> + depends on DM_USB && USB_DWC3_GENERIC && SYSCON
> + help
> +   Select this for TI AM62 Platforms.
> +   This wrapper supports Host and Peripheral operation modes.
> +
>  config USB_DWC3_MESON_G12A
>   bool "Amlogic Meson G12A USB wrapper"
>   depends on DM_USB && USB_DWC3 && ARCH_MESON
> diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
> index 97b4f7191ca..a46b6824ab7 100644
> --- a/drivers/usb/dwc3/Makefile
> +++ b/drivers/usb/dwc3/Makefile
> @@ -6,6 +6,7 @@ dwc3-y:= core.o
>  
>  obj-$(CONFIG_USB_DWC3_GADGET)+= gadget.o ep0.o
>  
> +obj-$(CONFIG_$(SPL_)USB_DWC3_AM62)   += dwc3-am62.o
>  obj-$(CONFIG_USB_DWC3_OMAP)  += dwc3-omap.o
>  obj-$(CONFIG_USB_DWC3_MESON_G12A)+= dwc3-meson-g12a.o
>  obj-$(CONFIG_USB_DWC3_MESON_GXL) += dwc3-meson-gxl.o
> diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c
> new file mode 100644
> index 000..99519602eb2
> --- /dev/null
> +++ b/drivers/usb/dwc3/dwc3-am62.c
> @@ -0,0 +1,125 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * TI AM62 specific glue layer for DWC3
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "dwc3-generic.h"
> +
> +#define USBSS_MODE_CONTROL   0x1c
> +#define USBSS_PHY_CONFIG 0x8
> +#define USBSS_PHY_VBUS_SEL_MASK  GENMASK(2, 1)
> +#define USBSS_PHY_VBUS_SEL_SHIFT 1
> +#define USBSS_MODE_VALID BIT(0)
> +#define PHY_PLL_REFCLK_MASK  GENMASK(3, 0)
> +static const int dwc3_ti_am62_rate_table[] = {   /* in KHZ */
> + 9600,
> + 1,
> + 12000,
> + 19200,
> + 2,
> + 24000,
> + 25000,
> + 26000,
> + 38400,
> + 4,
> + 58000,
> + 5,
> + 52000,
> +};
> +
> +static void dwc3_ti_am62_glue_configure(struct udevice *dev, int index,
> + enum usb_dr_mode mode)
> +{
> + struct clk usb2_refclk;
> + int rate_code, i, ret;
> + unsigned long rate;
> + u32 reg;
> + void *usbss;
> + bool vbus_divider;
> + struct regmap *syscon;
> + struct ofnode_phandle_args args;
> +
> + usbss = dev_remap_addr_index(dev, 0);
> + if (IS_ERR(usbss)) {
> + dev_err(dev, "can't map IOMEM resource\n");
> + return;
> + }
> +
> + ret = clk_get_by_name(dev, "ref", _refclk);
> + if (ret) {
> + dev_err(dev, "can't get usb2_refclk\n");
> + return;
> + }
> +
> + /* Calculate the rate code */
> + rate = clk_get_rate(_refclk);
> + rate /= 1000;   /* To KHz */
> + for (i = 0; i < ARRAY_SIZE(dwc3_ti_am62_rate_table); i++) {
> + if (dwc3_ti_am62_rate_table[i] == rate)
> + break;
> + }
> +
> + if (i == ARRAY_SIZE(dwc3_ti_am62_rate_table)) {
> + dev_err(dev, "unsupported usb2_refclk rate: %lu KHz\n", rate);
> + return;
> + }
> +
> + rate_code = i;
> +
> + /* Read the syscon property */
> + syscon = syscon_regmap_lookup_by_phandle(dev, 
> "ti,syscon-phy-pll-refclk");
> + if (IS_ERR(syscon)) {
> + dev_err(dev, "unable to get ti,syscon-phy-pll-refclk regmap\n");
> + return;
> + }
> +
> + ret = ofnode_parse_phandle_with_args(dev_ofnode(dev), 
> "ti,syscon-phy-pll-refclk", NULL, 1,
> +  0, );
> + if (ret)
> + return;
> +
> + /* Program PHY PLL refclk by reading syscon property */
> + ret = regmap_update_bits(syscon, args.args[0], 

Re: [PATCH v4 0/7] Add DFU and usb boot for TI am62x SK and beagleplay

2024-01-16 Thread Mattijs Korpershoek
Hi Sjoerd,

Thank you for the series.

On ven., janv. 12, 2024 at 09:52, Sjoerd Simons  wrote:

> This series adds DFU support for TI AM62 SK board and new since this
> version also for beagleplay.
>
> Since the last revision, apart from beagleplay support the main changes
> are:
> * Documentation was added on how to use this functionality on both boards
> * the R5 configuration is now done via a config fragment rather
>   then a full configuraiton
> * A new patch was added for dwc3 to work in device mode even if dr_mode is
>   configured as otg. Avoiding the need for an explicit switch to
>   periphal in the u-boot dts

I've tested on Beagle Play that I could load/recover the board via
snagboot:

U-Boot SPL 2023.04 (Sep 27 2023 - 11:19:48 +0200)
SYSFW ABI: 3.1 (firmware rev 0x0009 '9.0.5--v09.00.05 (Kool Koala)')
SPL initial stack usage: 13392 bytes
Trying to boot from DFU
##DOWNLOAD ... OK
Ctrl+C to exit ...
##DOWNLOAD ... OK
Ctrl+C to exit ...
Loading Environment from nowhere... OK
init_env from device 10 not supported!
Starting ATF on ARM64 core...

NOTICE:  BL3'.9(release):d7a7135d32a8
NOTICE:  BL31: Built : 10:53:52, Jan 16 2024

U-Boot SPL 2024.01-14350-g416e52ada83a (Jan 16 2024 - 10:54:58 +0100)
SYSFW ABI: 3.1 (firmware rev 0x0009 '9.0.5--v09.00.05 (Kool Koala)')
SPL initial stack usage: 1888 bytes
Trying to boot from DFU


U-Boot 2024.01-14350-g416e52ada83a (Jan 16 2024 - 10:54:58 +0100)

SoC:   AM62X SR1.0 GP
Model: BeagleBoard.org BeaglePlay
DRAM:  2 GiB
Core:  104 devices, 29 uclasses, devicetree: separate
MMC:   mmc@fa1: 0, mmc@fa0: 1, mmc@fa2: 2
Loading Environment from nowhere... OK
In:serial@280
Out:   serial@280
Err:   serial@280
Net:   No ethernet found.

Press SPACE to abort autoboot in 2 seconds


I've also tested (from the DFU'd U-Boot) that I could scan for usb keys:
=> usb start
[..]
1 USB Device(s) found

So for the series:
Tested-by: Mattijs Korpershoek  # on beagle play

>
> I will also submit the dts changes to linux so that those can be dropped
> again in the near future (hopefully)
>
> Changes in v4:
> - Add config dependency on SYSCON
> - Move defines and constants outside out of function scope
> - Don't force usb0 into peripheral mode
> - Move R5 dfu config to a config fragment rather then a full defconfig
> - Don't enable XHCI for the R5 SPL, unneeded
>
> Change in v3:
> - Add dfu via environment rather then config headers
> - Enable usb nodes in all boot phases
> - Run savedefconfig to adjust to more recent u-boot
>
> Changes in v2:
> - Switch dwc3 glue to a seperate driver rather then in dwc-generic
> - Minimize config changes to just DFU configuration
> - Only enable usb port 0 DFU in SPL
> - Create a seperate defconfig for R5
>
> Sjoerd Simons (7):
>   usb: dwc3: Add dwc3 glue driver for am62
>   usb: dwc3: Switch to device mode on gadget start
>   board: ti: am62x: am62x: include env for DFU
>   arm: dts: k3-am625-sk: Enable usb port in u-boot
>   configs: am62x_evm_*: Enable USB and DFU support
>   beagleplay: Add DFU support
>   doc: board: Add document for DFU boot on am62x SoCs
>
>  arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi |   8 ++
>  arch/arm/dts/k3-am625-sk-u-boot.dtsi |   8 ++
>  board/beagle/beagleplay/beagleplay.env   |   1 +
>  board/ti/am62x/am62x.env |   1 +
>  configs/am62x_beagleplay_a53_defconfig   |  30 +
>  configs/am62x_evm_a53_defconfig  |  30 +
>  configs/am62x_r5_usbdfu.config   |  28 +
>  doc/board/beagle/am62x_beagleplay.rst|  12 ++
>  doc/board/ti/am62x_sk.rst|  37 ++
>  drivers/usb/dwc3/Kconfig |  14 +++
>  drivers/usb/dwc3/Makefile|   1 +
>  drivers/usb/dwc3/core.c  |  10 +-
>  drivers/usb/dwc3/core.h  |   1 +
>  drivers/usb/dwc3/dwc3-am62.c | 125 +++
>  drivers/usb/dwc3/gadget.c|   6 +
>  15 files changed, 307 insertions(+), 5 deletions(-)
>  create mode 100644 configs/am62x_r5_usbdfu.config
>  create mode 100644 drivers/usb/dwc3/dwc3-am62.c
>
> -- 
> 2.43.0


Re: Re: Re: [PATCH v4 5/6] mmc: bcmstb: Add support for bcm2712 SD controller

2024-01-16 Thread Ivan T. Ivanov
Hi,

> On 01-12 09:44, Ivan T. Ivanov wrote:
> On 01-11 23:07, Stefan Wahren wrote:
> > 
> > Hi Ivan,
> > 
> > Am 10.01.24 um 13:29 schrieb Ivan T. Ivanov:
> > > Borrow SD quirks from vendor Linux driver.
> > > 
> > > "BCM2712 unfortunately carries with it a perennial bug with the SD
> > > controller register interface present on previous chips (2711/2709/2708).
> > > Accesses must be dword-sized and a read-modify-write cycle to the 32-bit
> > > registers containing the COMMAND, TRANSFER_MODE, BLOCK_SIZE and
> > > BLOCK_COUNT registers tramples the upper/lower 16 bits of data written.
> > > BCM2712 does not seem to need the extreme delay between each write as on
> > > previous chips, just the serialisation of writes to these registers in a
> > > single 32-bit operation."
> > > 
> > > Signed-off-by: Ivan T. Ivanov 
> > did you noticed this commit/pull request?
> > 
> > https://github.com/raspberrypi/linux/pull/5842/commits/3c9d840dc933cfb13a77fd3c03356ee4adacc30b
> 
> Doh, no. Let me check.

And indeed, no special accessors are needed. I am preparing new version
and will send it shortly.

Thanks,
Ivan



Re: Re: [PATCH v4 2/6] rpi5: Use devicetree as alternative way to read IO base addresses

2024-01-16 Thread Ivan T. Ivanov
On 01-10 10:00, Florian Fainelli wrote:
> On 1/10/24 04:29, Ivan T. Ivanov wrote:
> > From: Dmitry Malkin 
> > 
> > MBOX and Watchdog on RPi5/bcm2712 has a different base IO offsets.
> 
> s/has a/have a /
> 

Thanks!

> > Find them via devicetree blob passed by bootloader.
> > 
> > Signed-off-by: Dmitry Malkin 
> > Reviewed-by: Matthias Brugger 
> > Signed-off-by: Ivan T. Ivanov 
> > ---
> >   arch/arm/mach-bcm283x/include/mach/base.h  |  5 ++-
> >   arch/arm/mach-bcm283x/include/mach/mbox.h  |  3 +-
> >   arch/arm/mach-bcm283x/include/mach/sdhci.h |  3 +-
> >   arch/arm/mach-bcm283x/include/mach/timer.h |  3 +-
> >   arch/arm/mach-bcm283x/include/mach/wdog.h  |  3 +-
> >   arch/arm/mach-bcm283x/init.c   | 43 ++
> >   6 files changed, 43 insertions(+), 17 deletions(-)
> > 
> > diff --git a/arch/arm/mach-bcm283x/include/mach/base.h 
> > b/arch/arm/mach-bcm283x/include/mach/base.h
> > index 4ccaf69693..6de99e7ea1 100644
> > --- a/arch/arm/mach-bcm283x/include/mach/base.h
> > +++ b/arch/arm/mach-bcm283x/include/mach/base.h
> > @@ -6,7 +6,10 @@
> >   #ifndef _BCM283x_BASE_H_
> >   #define _BCM283x_BASE_H_
> > -extern unsigned long rpi_bcm283x_base;
> > +extern unsigned long rpi_mbox_base;
> > +extern unsigned long rpi_timer_base;
> > +extern unsigned long rpi_sdhci_base;
> > +extern unsigned long rpi_wdog_base;
> 
> Maybe suffix those variables with _phys_base to denote they are physical
> addresses, even if you seem to use a 1:1 mapping between virtual and
> physical, knowing which type of address we are dealing with right away is
> clearer.

I am not an expert on U-Boot, but I think mapping is always 1:1, so
explicit naming it that way looks redundant. As you can see even initial
naming don't specify it. But if you insist I could change it.

Regards,
Ivan



Re: [PATCH] sandbox_flattree: enable button support

2024-01-16 Thread Neil Armstrong

On 15/01/2024 19:50, Caleb Connolly wrote:

sandbox_flattree enables QCOM_PMIC_GPIO which now depends on BUTTON. As
a result the button tests now get run, but fail because the ADC and GPIO
button drivers aren't enabled.

Enable them to run the tests for sandbox_flattree.

Reported-by: Neil Armstrong 
Signed-off-by: Caleb Connolly 
---
  configs/sandbox_flattree_defconfig | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/configs/sandbox_flattree_defconfig 
b/configs/sandbox_flattree_defconfig
index 0b637727d9f1..ad364f6e128e 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -101,6 +101,9 @@ CONFIG_SYS_ATA_DATA_OFFSET=0
  CONFIG_SYS_ATA_REG_OFFSET=1
  CONFIG_SYS_ATA_ALT_OFFSET=2
  CONFIG_SYS_ATA_IDE0_OFFSET=0
+CONFIG_BUTTON=y
+CONFIG_BUTTON_ADC=y
+CONFIG_BUTTON_GPIO=y
  CONFIG_CLK=y
  CONFIG_CLK_COMPOSITE_CCF=y
  CONFIG_CLK_K210=y


Reviewed-by: Neil Armstrong 


Re: [PATCH 0/2] MAINTAINERS: add Mattijs for Android AB / AVB

2024-01-16 Thread Mattijs Korpershoek
Hi,

On Fri, 12 Jan 2024 09:40:43 +0100, Mattijs Korpershoek wrote:
> Igor has not been active for quite some time on lore:
> https://lore.kernel.org/all/?q=igor.opan...@gmail.com
> 
> It seems that Android AB and AVB could use some help maintaining.
> 
> I'm interested in helping with maintaining the android_ab
> command. I'm a long time android/aosp developer and my daily job is
> still doing android work.
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu 
(u-boot-dfu)

[1/2] MAINTAINERS: add Mattijs for Android AB
  
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/dbc949f74687597a08be3a1186489e60172f8e43
[2/2] MAINTAINERS: add Mattijs for Android AVB
  
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/05fac1a6187b7e97e75bbd40738686ae12948bf8

--
Mattijs


Re: [PATCH 0/2] MAINTAINERS: add Mattijs for Android AB / AVB

2024-01-16 Thread Mattijs Korpershoek
Hi Tom, all,

On ven., janv. 12, 2024 at 08:50, Tom Rini  wrote:

> On Fri, Jan 12, 2024 at 09:40:43AM +0100, Mattijs Korpershoek wrote:
>
>> Igor has not been active for quite some time on lore:
>> https://lore.kernel.org/all/?q=igor.opan...@gmail.com
>> 
>> It seems that Android AB and AVB could use some help maintaining.
>> 
>> I'm interested in helping with maintaining the android_ab
>> command. I'm a long time android/aosp developer and my daily job is
>> still doing android work.
>> 
>> Add myself as maintainer for Android AB and for Android AVB.
>> 
>> Note: the patches are split because I discussed taking over AB
>> privately with Sam, but I did not discuss taking over AVB.
>> 
>> Signed-off-by: Mattijs Korpershoek 
>> ---
>> Mattijs Korpershoek (2):
>>   MAINTAINERS: add Mattijs for Android AB
>>   MAINTAINERS: add Mattijs for Android AVB
>> 
>>  MAINTAINERS | 2 ++
>>  1 file changed, 2 insertions(+)
>
> Thanks for volunteering to take this work on. Please use the u-boot-dfu
> tree for this as well.

I will submit this through u-boot-dfu as well.

Thank you for trusting me with this work.


>
> -- 
> Tom


Re: [RFC][PATCH] ARM: imx: verdin-imx8mm: Set CAN oscillator frequency based on model

2024-01-16 Thread Francesco Dolcini
On Tue, Jan 16, 2024 at 02:01:02AM +0100, Marek Vasut wrote:
> On 1/15/24 16:44, Francesco Dolcini wrote:
> > On Sat, Jan 13, 2024 at 07:33:17PM +0100, Marek Vasut wrote:
> > 0059, V1.1A and V1.1B, use a 20MHz oscillator
> > 0055, V1.1A, V1.1B, V1.1C and V1.1D, use a 20Mhz oscillator
> 
> Do you happen to have a table of what was populated with which oscillator,
> so I can fill all the 20 MHz parts in right away ?

I guess that one quoted here from my previous email is "the table", but maybe I
have not understood your question.

Francesco