Re: [PATCH v6] remoteproc: uclass: Add methods to load firmware to rproc and boot rproc

2024-03-10 Thread Anwar, Md Danish



On 3/7/2024 6:16 PM, Tom Rini wrote:
> On Wed, Feb 28, 2024 at 05:36:45PM +0530, MD Danish Anwar wrote:
>> Add APIs to set a firmware_name to a rproc and boot the rproc with the
> 
>> same firmware.
>>
>> Clients can call rproc_set_firmware() API to set firmware_name for a rproc
>> whereas rproc_boot() will load the firmware set by rproc_set_firmware() to
>> a buffer by calling request_firmware_into_buf(). rproc_boot() will then
>> load the firmware file to the remote processor and start the remote
>> processor.
>>
>> Also include "fs-loader.h" and make remoteproc driver select FS_LOADER in
>> Kconfig so that we can call request_firmware_into_buf() from remoteproc
>> driver.
>>
>> Signed-off-by: MD Danish Anwar 
>> Acked-by: Ravi Gunasekaran 
>> Reviewed-by: Roger Quadros 
> 
> This breaks building on am64x_evm_r5 am65x_evm_r5_usbdfu
> am65x_evm_r5_usbmsc in next currently, thanks.
> 
I will work on fixing this build error and re-spin the patch.

-- 
Thanks and Regards,
Md Danish Anwar


[PATCH v4] board: rockchip: add Rockchip Toybrick TB-RK3588X board

2024-03-10 Thread Elon Zhang
TB-RK3588X board is a Rockchip Toybrick RK3588 based development board.

Specification:
Rockchip Rk3588 SoC
4x ARM Cortex-A76, 4x ARM Cortex-A55
8/16GB Memory LPDDR4x
Mali G610MC4 GPU
2× MIPI-CSI0 Connector
1x 2Lanes PCIe3.0 Connector
1x SATA3.0 Connector
32GB eMMC Module
2x USB 2.0, 2x USB 3.0
1x HDMI Output, 1x HDMI Input
2x Ethernet Port

Functions work normally:
[1] USB2.0 Host
[2] Ethernet0 with PHY RTL8211F

More information can be obtained from the following websites:
[1] https://t.rock-chips.com/en/wiki/EN/tb-rk3588x_en/index.html
[2] http://t.rock-chips.com/

Kernel commits:
8ffe365f8dc7 ("arm64: dts: rockchip: Add devicetree support for 
TB-RK3588X board")
7140387ff49d ("dt-bindings: arm: rockchip: Add Toybrick TB-RK3588X")

Reviewed-by: Weizhao Ouyang 
Signed-off-by: Elon Zhang 
---
Changes since v3:
  - unsigned int ret -> int ret of fdtdec_add_reserved_memory()

Changes since v2:
  - Sync dts file from upstream linux kernel

Changes since v1:
  - Remove BOARD_SPECIFIC_OPTIONS in board Kconfig
---
 arch/arm/dts/rk3588-toybrick-x0-u-boot.dtsi   |  12 +
 arch/arm/dts/rk3588-toybrick-x0.dts   | 688 ++
 arch/arm/mach-rockchip/rk3588/Kconfig |  25 +
 board/rockchip/toybrick_rk3588/Kconfig|  12 +
 board/rockchip/toybrick_rk3588/MAINTAINERS|   8 +
 board/rockchip/toybrick_rk3588/Makefile   |   6 +
 .../toybrick_rk3588/toybrick-rk3588.c |  39 +
 configs/toybrick-rk3588_defconfig |  82 +++
 doc/board/rockchip/rockchip.rst   |   1 +
 include/configs/toybrick_rk3588.h |  15 +
 10 files changed, 888 insertions(+)
 create mode 100644 arch/arm/dts/rk3588-toybrick-x0-u-boot.dtsi
 create mode 100644 arch/arm/dts/rk3588-toybrick-x0.dts
 create mode 100644 board/rockchip/toybrick_rk3588/Kconfig
 create mode 100644 board/rockchip/toybrick_rk3588/MAINTAINERS
 create mode 100644 board/rockchip/toybrick_rk3588/Makefile
 create mode 100644 board/rockchip/toybrick_rk3588/toybrick-rk3588.c
 create mode 100644 configs/toybrick-rk3588_defconfig
 create mode 100644 include/configs/toybrick_rk3588.h

diff --git a/arch/arm/dts/rk3588-toybrick-x0-u-boot.dtsi 
b/arch/arm/dts/rk3588-toybrick-x0-u-boot.dtsi
new file mode 100644
index 00..1aeb5410e4
--- /dev/null
+++ b/arch/arm/dts/rk3588-toybrick-x0-u-boot.dtsi
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2024 Rockchip Electronics Co., Ltd.
+ */
+
+#include "rk3588-u-boot.dtsi"
+
+/ {
+   chosen {
+   u-boot,spl-boot-order = "same-as-spl", 
+   };
+};
diff --git a/arch/arm/dts/rk3588-toybrick-x0.dts 
b/arch/arm/dts/rk3588-toybrick-x0.dts
new file mode 100644
index 00..9090c5c99f
--- /dev/null
+++ b/arch/arm/dts/rk3588-toybrick-x0.dts
@@ -0,0 +1,688 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2024 Rockchip Electronics Co., Ltd.
+ *
+ */
+
+/dts-v1/;
+
+#include 
+#include 
+#include 
+#include "rk3588.dtsi"
+
+/ {
+   model = "Rockchip Toybrick TB-RK3588X Board";
+   compatible = "rockchip,rk3588-toybrick-x0", "rockchip,rk3588";
+
+   aliases {
+   mmc0 = 
+   };
+
+   chosen {
+   stdout-path = "serial2:150n8";
+   };
+
+   adc-keys {
+   compatible = "adc-keys";
+   io-channels = < 1>;
+   io-channel-names = "buttons";
+   keyup-threshold-microvolt = <180>;
+   poll-interval = <100>;
+
+   button-vol-up {
+   label = "Volume Up";
+   linux,code = ;
+   press-threshold-microvolt = <17000>;
+   };
+
+   button-vol-down {
+   label = "Volume Down";
+   linux,code = ;
+   press-threshold-microvolt = <417000>;
+   };
+
+   button-menu {
+   label = "Menu";
+   linux,code = ;
+   press-threshold-microvolt = <89>;
+   };
+
+   button-escape {
+   label = "Escape";
+   linux,code = ;
+   press-threshold-microvolt = <1235000>;
+   };
+   };
+
+   backlight: backlight {
+   compatible = "pwm-backlight";
+   power-supply = <_dcin>;
+   pwms = < 0 25000 0>;
+   };
+
+   pcie20_avdd0v85: pcie20-avdd0v85-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "pcie20_avdd0v85";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <85>;
+   regulator-max-microvolt = <85>;
+   vin-supply = <_0v85_s0>;
+   };
+
+   

Re: [PATCH v6 00/11] An effort to bring DT bindings compliance within U-Boot

2024-03-10 Thread Tony Dinh
Hi Sumit,
Hi Tom,

On Mon, Mar 4, 2024 at 4:29 AM Fabio Estevam  wrote:
>
> On Mon, Mar 4, 2024 at 9:15 AM Sumit Garg  wrote:
>
> > I suppose the earlier reference patch wasn't complete, can you rather
> > try its v4 [1] instead?
> >
> > [1] 
> > https://patchwork.ozlabs.org/project/uboot/patch/20240304121257.3551104-1-sumit.g...@linaro.org/
>
> This one works, thanks!

I'm testing this for a Marvell Armada 385 board (Synology DS116). I'm
on the next branch, but  perhaps something is still missing.

diff --git a/configs/ds116_defconfig b/configs/ds116_defconfig
index 02ddc0e7918..1fbedcf91cf 100644
--- a/configs/ds116_defconfig
+++ b/configs/ds116_defconfig
@@ -16,7 +16,7 @@ CONFIG_SF_DEFAULT_SPEED=5000
 CONFIG_ENV_SIZE=0x1
 CONFIG_ENV_OFFSET=0x7E
 CONFIG_ENV_SECT_SIZE=0x1
-CONFIG_DEFAULT_DEVICE_TREE="armada-385-synology-ds116"
+CONFIG_DEFAULT_DEVICE_TREE="marvell/armada-385-synology-ds116"
 CONFIG_SPL_TEXT_BASE=0x4030
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL_STACK=0x4002c000
@@ -29,7 +29,6 @@ CONFIG_PCI=y
 CONFIG_DEBUG_UART=y
 CONFIG_AHCI=y
 CONFIG_BOOTSTD_FULL=y
-CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_BOOTDELAY=10
 CONFIG_USE_PREBOOT=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
@@ -57,6 +56,7 @@ CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_MTDPARTS=y
 
CONFIG_MTDPARTS_DEFAULT="mtdparts=spi0.0:1m(u-boot),7040k(kernel),64k(u-boot-env),-(data)"
+CONFIG_OF_UPSTREAM=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_VERSION_VARIABLE=y

# make ds116_defconfig

# grep -i ds116 .config
CONFIG_SYS_BOARD="ds116"
CONFIG_SYS_CONFIG_NAME="ds116"
CONFIG_TARGET_DS116=y
CONFIG_DEFAULT_DEVICE_TREE="marvell/armada-385-synology-ds116"
CONFIG_IDENT_STRING="\nSynology DS116"
CONFIG_SYS_PROMPT="DS116> "
CONFIG_OF_LIST="marvell/armada-385-synology-ds116"
CONFIG_SPL_OF_LIST="marvell/armada-385-synology-ds116"

Built it, and looks like vendor Marvell is missing during the Make
file execution.

make -f ./scripts/Makefile.build obj=dts dtbs
make -f ./scripts/Makefile.build obj=dts/upstream/src/arm dtbs
scripts/Makefile.build:57: dts/upstream/src/arm/Makefile: No such file
or directory
make[2]: *** No rule to make target 'dts/upstream/src/arm/Makefile'.  Stop.
make[1]: *** [dts/Makefile:54: arch-dtbs] Error 2
make: *** [Makefile:1166: dts/dt.dtb] Error 2
make: *** Waiting for unfinished jobs
make: Leaving directory '/usr/src/u-boot'

I also tried Bryan's patch like you've suggested to Fabio. But it
seems Bryan's patch was already in the next branch. Did I miss
something?

All the best ,
Tony


Re: [PATCH 1/4] rockchip: Update the default USB Product ID value

2024-03-10 Thread Kever Yang

Hi Jonas,

On 2024/3/8 18:42, Jonas Karlman wrote:

Hi Kever,

On 2024-03-08 10:22, Kever Yang wrote:

Hi Jonas,

      Thanks for your patch.

On 2024/2/27 07:08, Jonas Karlman wrote:

RK3036 is using the USB product id normally used by RK3066B, and RK3328
is using the product id normally used by RK3368.

Fix this and update the default USB_GADGET_PRODUCT_NUM Kconfig option
for remaining supported Rockchip SoCs to match the product id used in
Mask ROM mode. Also remove a reference to the unknown ROCKCHIP_RK3229
symbol.

RK3229 belongs to RK322X which is reuse with RK3228.

Note that this ID is used for rockusb gadget, if work as mass storage,
it should use other

ID, or else it will confuse the driver in host side, eg. the Windows
driver may not able to

recognize the device if using two different gadget type with the same ID.

Patch 3 in this series will change to use 0x0010 product id when ums
mode is enabled and fall back to use the USB_GADGET_PRODUCT_NUM for any
other gadget mode.

Yes, I see that a few seconds after I send that mail.


The ROCKCHIP_RK3229 symbol is not defined or used anywhere U-Boot so the
change in this patch to remove it from the condition should have no
impact. If RK3229 need a special product id separate from 0x320b used by
ROCKCHIP_RK322X, it can be defined in the defconfig for such board.


ROCKCHIP_RK3229 does not need any more, because it's included in Rk322X.

So please update the commit message with " remove ROCKCHIP_RK3229 because
it's included in ROCKCHIP_RK322X" instead of "unknown ROCKCHIP_RK3229".



I tested this on Windows with rockusb and ums on RK3308, RK3328, RK3399
RK356x and RK3588 boards, switching between ums and rockusb should work
as intended, rockusb driver was used in rockusb mode and in ums mode the
device would show up as a disk.

   => rockusb 0 mmc 1
   => ums 0 mmc 1

I think all product id below is correct,


Yes, I have check these IDs, they are correct.


Thanks,
- Kever

but I have not been able to
runtime validate for other SoCs then the ones listed above.

Regards,
Jonas



Thanks,
- Kever

Signed-off-by: Jonas Karlman 
---
   drivers/usb/gadget/Kconfig | 15 ---
   1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index c72a8047635c..4621a6fd5e64 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -70,12 +70,21 @@ config USB_GADGET_PRODUCT_NUM
hex "Product ID of the USB device"
default 0x701a if ARCH_TEGRA
default 0x1010 if ARCH_SUNXI
-   default 0x310a if ROCKCHIP_RK3036
+   default 0x110a if ROCKCHIP_RV1108
+   default 0x110b if ROCKCHIP_RV1126
default 0x300a if ROCKCHIP_RK3066
+   default 0x301a if ROCKCHIP_RK3036
+   default 0x310b if ROCKCHIP_RK3188
default 0x310c if ROCKCHIP_RK3128
-   default 0x320a if ROCKCHIP_RK3229 || ROCKCHIP_RK3288
-   default 0x330a if ROCKCHIP_RK3328
+   default 0x320a if ROCKCHIP_RK3288
+   default 0x320b if ROCKCHIP_RK322X
+   default 0x320c if ROCKCHIP_RK3328
+   default 0x330a if ROCKCHIP_RK3368
default 0x330c if ROCKCHIP_RK3399
+   default 0x330d if ROCKCHIP_PX30
+   default 0x330e if ROCKCHIP_RK3308
+   default 0x350a if ROCKCHIP_RK3568
+   default 0x350b if ROCKCHIP_RK3588
default 0x0
help
  Product ID of the USB device emulated, reported to the host device.


[PATCH V2] mtd: spinand: Add support for XTX SPINAND

2024-03-10 Thread Bruce Suen
Add support for XTX XT26G0xA and XT26xxxD,the driver is ported from
linux-6.7.1.

Signed-off-by: Bruce Suen 
---
V1->V2:
- remove patch errors
---
 drivers/mtd/nand/spi/Makefile |   2 +-
 drivers/mtd/nand/spi/core.c   |   1 +
 drivers/mtd/nand/spi/xtx.c| 266 ++
 include/linux/mtd/spinand.h   |   1 +
 4 files changed, 269 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/nand/spi/xtx.c

diff --git a/drivers/mtd/nand/spi/Makefile b/drivers/mtd/nand/spi/Makefile
index f172f4787f..65b836b34c 100644
--- a/drivers/mtd/nand/spi/Makefile
+++ b/drivers/mtd/nand/spi/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 
 spinand-objs := core.o esmt.o gigadevice.o macronix.o micron.o paragon.o
-spinand-objs += toshiba.o winbond.o
+spinand-objs += toshiba.o winbond.o xtx.o
 obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 8ca33459f9..62c28aa422 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -829,6 +829,7 @@ static const struct spinand_manufacturer 
*spinand_manufacturers[] = {
_spinand_manufacturer,
_spinand_manufacturer,
_c8_spinand_manufacturer,
+   _spinand_manufacturer,
 };
 
 static int spinand_manufacturer_match(struct spinand_device *spinand,
diff --git a/drivers/mtd/nand/spi/xtx.c b/drivers/mtd/nand/spi/xtx.c
new file mode 100644
index 00..6b7b265136
--- /dev/null
+++ b/drivers/mtd/nand/spi/xtx.c
@@ -0,0 +1,266 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Author:
+ * Felix Matouschek 
+ */
+
+#include 
+#ifndef __UBOOT__
+#include 
+#include 
+#endif
+#include 
+
+#define SPINAND_MFR_XTX0x0B
+
+#define XT26G0XA_STATUS_ECC_MASK   GENMASK(5, 2)
+#define XT26G0XA_STATUS_ECC_NO_DETECTED(0 << 2)
+#define XT26G0XA_STATUS_ECC_8_CORRECTED(3 << 4)
+#define XT26G0XA_STATUS_ECC_UNCOR_ERROR(2 << 4)
+
+#define XT26XXXD_STATUS_ECC3_ECC2_MASK GENMASK(7, 6)
+#define XT26XXXD_STATUS_ECC_NO_DETECTED (0)
+#define XT26XXXD_STATUS_ECC_1_7_CORRECTED   (1)
+#define XT26XXXD_STATUS_ECC_8_CORRECTED (3)
+#define XT26XXXD_STATUS_ECC_UNCOR_ERROR (2)
+
+static SPINAND_OP_VARIANTS(read_cache_variants,
+   SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
+   SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+
+static SPINAND_OP_VARIANTS(write_cache_variants,
+   SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
+   SPINAND_PROG_LOAD(true, 0, NULL, 0));
+
+static SPINAND_OP_VARIANTS(update_cache_variants,
+   SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
+   SPINAND_PROG_LOAD(false, 0, NULL, 0));
+
+static int xt26g0xa_ooblayout_ecc(struct mtd_info *mtd, int section,
+   struct mtd_oob_region *region)
+{
+   if (section)
+   return -ERANGE;
+
+   region->offset = 48;
+   region->length = 16;
+
+   return 0;
+}
+
+static int xt26g0xa_ooblayout_free(struct mtd_info *mtd, int section,
+   struct mtd_oob_region *region)
+{
+   if (section)
+   return -ERANGE;
+
+   region->offset = 1;
+   region->length = 47;
+
+   return 0;
+}
+
+static const struct mtd_ooblayout_ops xt26g0xa_ooblayout = {
+   .ecc = xt26g0xa_ooblayout_ecc,
+   .rfree = xt26g0xa_ooblayout_free,
+};
+
+static int xt26g0xa_ecc_get_status(struct spinand_device *spinand,
+  u8 status)
+{
+   status = status & XT26G0XA_STATUS_ECC_MASK;
+
+   switch (status) {
+   case XT26G0XA_STATUS_ECC_NO_DETECTED:
+   return 0;
+   case XT26G0XA_STATUS_ECC_8_CORRECTED:
+   return 8;
+   case XT26G0XA_STATUS_ECC_UNCOR_ERROR:
+   return -EBADMSG;
+   default:
+   break;
+   }
+
+   /* At this point values greater than (2 << 4) are invalid  */
+   if (status > XT26G0XA_STATUS_ECC_UNCOR_ERROR)
+   return -EINVAL;
+
+   /* (1 << 2) through (7 << 2) are 1-7 corrected errors */
+   return status >> 2;
+}
+
+static int xt26xxxd_ooblayout_ecc(struct mtd_info *mtd, int section,
+ struct mtd_oob_region *region)
+{
+   if (section)
+   return -ERANGE;
+
+   region->offset = mtd->oobsize / 2;
+   region->length = mtd->oobsize / 2;
+
+   return 0;
+}
+
+static int xt26xxxd_ooblayout_free(struct mtd_info *mtd, int section,
+  struct mtd_oob_region *region)
+{
+   if (section)
+   return -ERANGE;
+
+   region->offset = 2;
+   region->length = mtd->oobsize / 2 - 

[PATCH v3 v3 1/1] arch: arm: Agilex5 enablement

2024-03-10 Thread Jit Loon Lim
This patch is to enable Agilex5 platform for Intel
product. Changes, modification and new files are
created for board, dts, configs and makefile to
create the base for Agilex5.

Signed-off-by: Jit Loon Lim 

Changes v2 -> v3:
- Added FPGA 240G DDR region
Changes v1 -> v2:
- fixed git auto merge issue
---
 arch/arm/Kconfig  |   4 +-
 arch/arm/dts/Makefile |   1 +
 arch/arm/dts/socfpga_agilex5-u-boot.dtsi  |  71 ++
 arch/arm/dts/socfpga_agilex5.dtsi | 575 ++
 .../arm/dts/socfpga_agilex5_socdk-u-boot.dtsi | 133 
 arch/arm/dts/socfpga_agilex5_socdk.dts| 163 
 arch/arm/dts/socfpga_soc64_fit-u-boot.dtsi|  38 +-
 arch/arm/mach-socfpga/Kconfig |  19 +-
 arch/arm/mach-socfpga/Makefile|  14 +-
 arch/arm/mach-socfpga/board.c |  56 +-
 arch/arm/mach-socfpga/clock_manager_agilex5.c |  89 +++
 .../include/mach/base_addr_soc64.h|  38 +-
 .../mach-socfpga/include/mach/clock_manager.h |   4 +-
 .../include/mach/clock_manager_agilex5.h  |  12 +
 .../mach-socfpga/include/mach/handoff_soc64.h |  31 +-
 .../mach-socfpga/include/mach/mailbox_s10.h   |   1 +
 arch/arm/mach-socfpga/mmu-arm64_s10.c |  59 +-
 board/intel/agilex5-socdk/MAINTAINERS |   8 +
 configs/socfpga_agilex5_defconfig | 116 +++
 drivers/clk/altera/Makefile   |   1 +
 drivers/clk/altera/clk-agilex5.c  | 743 ++
 drivers/clk/altera/clk-agilex5.h  | 284 +++
 include/configs/socfpga_agilex5_socdk.h   |  12 +
 include/configs/socfpga_soc64_common.h| 143 +++-
 include/dt-bindings/clock/agilex5-clock.h |  71 ++
 include/dt-bindings/reset/altr,rst-mgr-agx5.h |  80 ++
 26 files changed, 2730 insertions(+), 36 deletions(-)
 create mode 100644 arch/arm/dts/socfpga_agilex5-u-boot.dtsi
 create mode 100644 arch/arm/dts/socfpga_agilex5.dtsi
 create mode 100644 arch/arm/dts/socfpga_agilex5_socdk-u-boot.dtsi
 create mode 100644 arch/arm/dts/socfpga_agilex5_socdk.dts
 create mode 100644 arch/arm/mach-socfpga/clock_manager_agilex5.c
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_agilex5.h
 create mode 100644 board/intel/agilex5-socdk/MAINTAINERS
 create mode 100644 configs/socfpga_agilex5_defconfig
 create mode 100644 drivers/clk/altera/clk-agilex5.c
 create mode 100644 drivers/clk/altera/clk-agilex5.h
 create mode 100644 include/configs/socfpga_agilex5_socdk.h
 create mode 100644 include/dt-bindings/clock/agilex5-clock.h
 create mode 100644 include/dt-bindings/reset/altr,rst-mgr-agx5.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index fde85dc0d5..6df805f44c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -28,6 +28,7 @@ config COUNTER_FREQUENCY
ROCKCHIP_RK3288 || ROCKCHIP_RK322X || ROCKCHIP_RK3036
default 2500 if ARCH_LX2160A || ARCH_LX2162A || ARCH_LS1088A
default 1 if ARCH_ZYNQMP
+   default 2 if ARCH_SOCFPGA && ARM64 && TARGET_SOCFPGA_AGILEX5
default 0
help
  For platforms with ARMv8-A and ARMv7-A which features a system
@@ -1124,7 +1125,8 @@ config ARCH_SOCFPGA
select SYS_THUMB_BUILD if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
select SYSRESET
select SYSRESET_SOCFPGA if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
-   select SYSRESET_SOCFPGA_SOC64 if TARGET_SOCFPGA_SOC64
+   select SYSRESET_SOCFPGA_SOC64 if !TARGET_SOCFPGA_AGILEX5 && \
+ TARGET_SOCFPGA_SOC64
imply CMD_DM
imply CMD_MTDPARTS
imply CRC32_VERIFY
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index d9725030d5..2b4f896ad2 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -548,6 +548,7 @@ dtb-$(CONFIG_TARGET_THUNDERX_88XX) += thunderx-88xx.dtb
 
 dtb-$(CONFIG_ARCH_SOCFPGA) +=  \
socfpga_agilex_socdk.dtb\
+   socfpga_agilex5_socdk.dtb   \
socfpga_arria5_secu1.dtb\
socfpga_arria5_socdk.dtb\
socfpga_arria10_chameleonv3_270_2.dtb   \
diff --git a/arch/arm/dts/socfpga_agilex5-u-boot.dtsi 
b/arch/arm/dts/socfpga_agilex5-u-boot.dtsi
new file mode 100644
index 00..a8167e5c14
--- /dev/null
+++ b/arch/arm/dts/socfpga_agilex5-u-boot.dtsi
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * U-Boot additions
+ *
+ * Copyright (C) 2024 Intel Corporation 
+ */
+
+#include "socfpga_soc64_fit-u-boot.dtsi"
+
+/{
+   memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   bootph-all;
+   };
+};
+
+ {
+   bootph-all;
+};
+
+ {
+   reset-names = "i2c";
+};
+
+ {
+   reset-names = "i2c";
+};
+
+ {
+   reset-names = "i2c";
+};
+
+ {
+   reset-names = "i2c";
+};
+
+ {
+   resets = < SDMMC_RESET>, < 

[PATCH v3 0/1] Agilex5 enablement

2024-03-10 Thread Jit Loon Lim
V1: 
https://patchwork.ozlabs.org/project/uboot/patch/20240220143603.22091-1-jit.loon@intel.com/
V2: Fixed Git auto-merge causing misalignment of code and insert/delete
V3: Added 240G FPGA DDR region

Jit Loon Lim (1):
  arch: arm: Agilex5 enablement

 arch/arm/Kconfig  |   4 +-
 arch/arm/dts/Makefile |   1 +
 arch/arm/dts/socfpga_agilex5-u-boot.dtsi  |  71 ++
 arch/arm/dts/socfpga_agilex5.dtsi | 575 ++
 .../arm/dts/socfpga_agilex5_socdk-u-boot.dtsi | 133 
 arch/arm/dts/socfpga_agilex5_socdk.dts| 163 
 arch/arm/dts/socfpga_soc64_fit-u-boot.dtsi|  38 +-
 arch/arm/mach-socfpga/Kconfig |  19 +-
 arch/arm/mach-socfpga/Makefile|  14 +-
 arch/arm/mach-socfpga/board.c |  56 +-
 arch/arm/mach-socfpga/clock_manager_agilex5.c |  89 +++
 .../include/mach/base_addr_soc64.h|  38 +-
 .../mach-socfpga/include/mach/clock_manager.h |   4 +-
 .../include/mach/clock_manager_agilex5.h  |  12 +
 .../mach-socfpga/include/mach/handoff_soc64.h |  31 +-
 .../mach-socfpga/include/mach/mailbox_s10.h   |   1 +
 arch/arm/mach-socfpga/mmu-arm64_s10.c |  59 +-
 board/intel/agilex5-socdk/MAINTAINERS |   8 +
 configs/socfpga_agilex5_defconfig | 116 +++
 drivers/clk/altera/Makefile   |   1 +
 drivers/clk/altera/clk-agilex5.c  | 743 ++
 drivers/clk/altera/clk-agilex5.h  | 284 +++
 include/configs/socfpga_agilex5_socdk.h   |  12 +
 include/configs/socfpga_soc64_common.h| 143 +++-
 include/dt-bindings/clock/agilex5-clock.h |  71 ++
 include/dt-bindings/reset/altr,rst-mgr-agx5.h |  80 ++
 26 files changed, 2730 insertions(+), 36 deletions(-)
 create mode 100644 arch/arm/dts/socfpga_agilex5-u-boot.dtsi
 create mode 100644 arch/arm/dts/socfpga_agilex5.dtsi
 create mode 100644 arch/arm/dts/socfpga_agilex5_socdk-u-boot.dtsi
 create mode 100644 arch/arm/dts/socfpga_agilex5_socdk.dts
 create mode 100644 arch/arm/mach-socfpga/clock_manager_agilex5.c
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_agilex5.h
 create mode 100644 board/intel/agilex5-socdk/MAINTAINERS
 create mode 100644 configs/socfpga_agilex5_defconfig
 create mode 100644 drivers/clk/altera/clk-agilex5.c
 create mode 100644 drivers/clk/altera/clk-agilex5.h
 create mode 100644 include/configs/socfpga_agilex5_socdk.h
 create mode 100644 include/dt-bindings/clock/agilex5-clock.h
 create mode 100644 include/dt-bindings/reset/altr,rst-mgr-agx5.h

-- 
2.26.2



RE: [PATCH] arm: dts: imx8mp-beacon-kit: Resync DTS with Linux 6.8

2024-03-10 Thread Peng Fan
> Subject: [PATCH] arm: dts: imx8mp-beacon-kit: Resync DTS with Linux 6.8
> 
> The device tree has evolved over time, so re-sync.  This also partial reverts
> one change on the PCIe, because U-Boot doesn't have a proper driver.
> However, since the clock is configured to generate a 100MHz reference clock
> by default, a proper driver isn't really necessary.
> 
> Signed-off-by: Adam Ford 

Acked-by: Peng Fan 
> 
> diff --git a/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi
> b/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi
> index 393fd8ec2e..ed183f83a7 100644
> --- a/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi
> +++ b/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi
> @@ -6,6 +6,13 @@
>  #include "imx8mp-u-boot.dtsi"
> 
>  / {
> + /* U-Boot does not yet have a proper PCIe clk driver */
> + pcie0_refclk: clock-pcie {
> + compatible = "fixed-clock";
> + #clock-cells = <0>;
> + clock-frequency = <1>;
> + };
> +
>   wdt-reboot {
>   compatible = "wdt-reboot";
>   wdt = <>;
> @@ -13,6 +20,10 @@
>   };
>  };
> 
> +_phy {
> + clocks = <_refclk>;
> +};
> +
>  &{/soc@0/bus@3080/i2c@30a2/pmic@25} {
>   bootph-pre-ram;
>  };
> diff --git a/arch/arm/dts/imx8mp-beacon-kit.dts b/arch/arm/dts/imx8mp-
> beacon-kit.dts
> index cdae45a48c..a08057410b 100644
> --- a/arch/arm/dts/imx8mp-beacon-kit.dts
> +++ b/arch/arm/dts/imx8mp-beacon-kit.dts
> @@ -23,6 +23,12 @@
>   stdout-path = 
>   };
> 
> + clk_xtal25: clock-xtal25 {
> + compatible = "fixed-clock";
> + #clock-cells = <0>;
> + clock-frequency = <2500>;
> + };
> +
>   connector {
>   compatible = "usb-c-connector";
>   label = "USB-C";
> @@ -49,6 +55,12 @@
>   };
>   };
> 
> + dmic_codec: dmic-codec {
> + compatible = "dmic-codec";
> + num-channels = <1>;
> + #sound-dai-cells = <0>;
> + };
> +
>   gpio-keys {
>   compatible = "gpio-keys";
>   autorepeat;
> @@ -82,6 +94,17 @@
>   };
>   };
> 
> + bridge-connector {
> + compatible = "hdmi-connector";
> + type = "a";
> +
> + port {
> + hdmi_con: endpoint {
> + remote-endpoint = <_out>;
> + };
> + };
> + };
> +
>   leds {
>   compatible = "gpio-leds";
>   pinctrl-names = "default";
> @@ -112,10 +135,13 @@
>   };
>   };
> 
> - pcie0_refclk: clock-pcie {
> - compatible = "fixed-clock";
> - #clock-cells = <0>;
> - clock-frequency = <1>;
> + reg_audio: regulator-wm8962 {
> + compatible = "regulator-fixed";
> + regulator-name = "3v3_aud";
> + regulator-min-microvolt = <330>;
> + regulator-max-microvolt = <330>;
> + gpio = <_1 11 GPIO_ACTIVE_HIGH>;
> + enable-active-high;
>   };
> 
>   reg_usdhc2_vmmc: regulator-usdhc2 {
> @@ -137,6 +163,68 @@
>   gpio = <_1 0 GPIO_ACTIVE_HIGH>;
>   enable-active-high;
>   };
> +
> + sound-adv7535 {
> + compatible = "simple-audio-card";
> + simple-audio-card,name = "sound-adv7535";
> + simple-audio-card,format = "i2s";
> +
> + simple-audio-card,cpu {
> + sound-dai = <>;
> + system-clock-direction-out;
> + };
> +
> + simple-audio-card,codec {
> + sound-dai = <_bridge>;
> + };
> + };
> +
> + sound-dmic {
> + compatible = "simple-audio-card";
> + simple-audio-card,name = "sound-pdm";
> + simple-audio-card,format = "i2s";
> + simple-audio-card,bitclock-master = <_master>;
> + simple-audio-card,frame-master = <_master>;
> +
> + dailink_master: simple-audio-card,cpu {
> + sound-dai = <>;
> + };
> +
> + simple-audio-card,codec {
> + sound-dai = <_codec>;
> + };
> + };
> +
> + sound-wm8962 {
> + compatible = "simple-audio-card";
> + simple-audio-card,name = "wm8962";
> + simple-audio-card,format = "i2s";
> + simple-audio-card,widgets = "Headphone", "Headphones",
> + "Microphone", "Headset Mic",
> + "Speaker", "Speaker";
> + simple-audio-card,routing = "Headphones", "HPOUTL",
> + "Headphones", "HPOUTR",
> + "Speaker", "SPKOUTL",
> + "Speaker", "SPKOUTR",
> + "Headset Mic", "MICBIAS",
> +   

Re: [PATCH] sunxi: h616: add initial support for T95 AXP313 TV Box

2024-03-10 Thread Andre Przywara
On Sat,  9 Mar 2024 19:24:26 +
Kamil Kasperski  wrote:

Hi Kamil,

many thanks for sending a patch, that looks mostly good from the
technical point of view, only some smaller comments.

But please note that the devicetree needs to go through the Linux
mailing lists and repo first, and we automatically copy it from the
Linux tree once it has been merged there. This is to ensure proper
review and checks with the Linux tooling.

So can you please send just the .dts file to the DT and sunxi
maintainers the respective lists, as reported by get_maintainer.pl?
Then we can take it from there.

> T95 is a most commonly known for being a box with a pre-installed malware.
> It uses Allwinner H616 and comes with eMMC and DDR3 memory.
> This device comes with two versions - one with AXP305 PMIC and another with 
> AXP313 PMIC.
> The AXP313 version comes with Secure Boot enabled and locked bootloader, so 
> the u-boot has to be built with TOC0.
> DRAM settings are taken from Allwinner's boot0 for this box.

Ah, thanks for figuring those out, that's very helpful.

> 
> Cc: Andre Przywara 
> 
> Signed-off-by: Kamil Kasperski 
> ---
>  arch/arm/dts/Makefile   |   3 +-
>  arch/arm/dts/sun50i-h616-t95-axp313.dts | 148 
>  configs/t95_axp313_defconfig|  27 +
>  3 files changed, 177 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm/dts/sun50i-h616-t95-axp313.dts
>  create mode 100644 configs/t95_axp313_defconfig
> 
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index b102ffb5f6..144daf6c48 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -842,7 +842,8 @@ dtb-$(CONFIG_MACH_SUN50I_H616) += \
>   sun50i-h618-orangepi-zero2w.dtb \
>   sun50i-h618-orangepi-zero3.dtb \
>   sun50i-h618-transpeed-8k618-t.dtb \
> - sun50i-h616-x96-mate.dtb
> + sun50i-h616-x96-mate.dtb \
> + sun50i-h616-t95-axp313.dtb
>  dtb-$(CONFIG_MACH_SUN50I) += \
>   sun50i-a64-amarula-relic.dtb \
>   sun50i-a64-bananapi-m64.dtb \
> diff --git a/arch/arm/dts/sun50i-h616-t95-axp313.dts 
> b/arch/arm/dts/sun50i-h616-t95-axp313.dts
> new file mode 100644
> index 00..b006f363d5
> --- /dev/null
> +++ b/arch/arm/dts/sun50i-h616-t95-axp313.dts
> @@ -0,0 +1,148 @@
> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> +/*
> + * Copyright (C) 2021 Arm Ltd.

Please change this copyright you and this year.

> + */
> +
> +/dts-v1/;
> +
> +#include "sun50i-h616.dtsi"
> +
> +#include 
> +#include 
> +
> +/ {
> + model = "T95 (AXP313)";
> + compatible = "mbox,t95-axp313", "allwinner,sun50i-h616";

What is "mbox"? Do you have any more information about this vendor?
In any case a new vendor would need to be added to
Documentation/devicetree/bindings/vendor-prefixes.yaml, in a separate
patch. Also you need a patch to add this compatible combination to
Documentation/devicetree/bindings/arm/sunxi.yaml.

Cheers,
Andre

> +
> + aliases {
> + serial0 = 
> + };
> +
> + chosen {
> + stdout-path = "serial0:115200n8";
> + };
> +
> + reg_vcc5v: vcc5v {
> + /* board wide 5V supply directly from the DC input */
> + compatible = "regulator-fixed";
> + regulator-name = "vcc-5v";
> + regulator-min-microvolt = <500>;
> + regulator-max-microvolt = <500>;
> + regulator-always-on;
> + };
> +};
> +
> + {
> + status = "okay";
> +};
> +
> + {
> + status = "okay";
> +};
> +
> + {
> + status = "okay";
> +};
> +
> + {
> + cd-gpios = < 8 16 GPIO_ACTIVE_LOW>; /* PI16 */
> + vmmc-supply = <_dldo1>;
> + status = "okay";
> +};
> +
> + {
> + vmmc-supply = <_dldo1>;
> + vqmmc-supply = <_aldo1>;
> + bus-width = <8>;
> + non-removable;
> + cap-mmc-hw-reset;
> + mmc-ddr-1_8v;
> + mmc-hs200-1_8v;
> + status = "okay";
> +};
> +
> + {
> + status = "okay";
> +};
> +
> + {
> + status = "okay";
> +};
> +
> +_i2c {
> + status = "okay";
> +
> + axp313: pmic@36 {
> + compatible = "x-powers,axp313a";
> + reg = <0x36>;
> + #interrupt-cells = <1>;
> + interrupt-controller;
> + interrupt-parent = <>;
> + interrupts = <2 9 IRQ_TYPE_LEVEL_LOW>;  /* PC9 */
> +
> + vin1-supply = <_vcc5v>;
> + vin2-supply = <_vcc5v>;
> + vin3-supply = <_vcc5v>;
> +
> + regulators {
> + /* Supplies VCC-PLL, so needs to be always on. */
> + reg_aldo1: aldo1 {
> + regulator-always-on;
> + regulator-min-microvolt = <180>;
> + regulator-max-microvolt = <180>;
> + regulator-name = "vcc1v8";
> + };
> +
> + /* Supplies VCC-IO, so needs to be always on. */
> + reg_dldo1: dldo1 {

[PATCH v4] Makefile: use shell to calculate map_size

2024-03-10 Thread Leon M. Busch-George
From: "Leon M. Busch-George" 

The error message "bc: command not found" is easily missed since the
build continues.
bc is not a part of coreutils or base-devel. POSIX sh can also do the
calculation.

Signed-off-by: Leon M. Busch-George 
Reviewed-by: Dragan Simic 
---
 Makefile | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index a2bc9d5903..fac3a05dd5 100644
--- a/Makefile
+++ b/Makefile
@@ -1273,12 +1273,17 @@ OBJCOPYFLAGS_u-boot-nodtb.bin := -O binary \
$(if $(CONFIG_MPC85XX_HAVE_RESET_VECTOR),$(if 
$(CONFIG_OF_SEPARATE),-R .bootpg -R .resetvec))
 
 binary_size_check: u-boot-nodtb.bin FORCE
-   @file_size=$(shell wc -c u-boot-nodtb.bin | awk '{print $$1}') ; \
+   @file_size=$(shell wc -c u-boot-nodtb.bin | awk '{ print $$1 }') ; \
map_size=$(shell cat u-boot.map | \
-   awk '/_image_copy_start/ {start = $$1} /_image_binary_end/ {end 
= $$1} END {if (start != "" && end != "") print "ibase=16; " toupper(end) " - " 
toupper(start)}' \
-   | sed 's/0X//g' \
-   | bc); \
-   if [ "" != "$$map_size" ]; then \
+   awk ' \
+   /_image_copy_start/ { start = $$1 } \
+   /_image_binary_end/ { end = $$1 } \
+   END { \
+   if (start != "" && end != "") \
+   print end " " start; \
+   }' \
+   | sh -c 'read end start && echo $$((end - start))'); \
+   if [ -n "$$map_size" ]; then \
if test $$map_size -ne $$file_size; then \
echo "u-boot.map shows a binary size of $$map_size" >&2 
; \
echo "  but u-boot-nodtb.bin shows $$file_size" >&2 ; \
-- 
2.44.0



[PATCH] CI: Update to using clang-17

2024-03-10 Thread Tom Rini
Currently, llvm-17 is the stable release. Update our container and CI to
fetch and use that.

Signed-off-by: Tom Rini 
---
 .azure-pipelines.yml| 6 +++---
 .gitlab-ci.yml  | 4 ++--
 tools/docker/Dockerfile | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 1d73215afbae..798c137b2f6e 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -278,16 +278,16 @@ stages:
   TEST_PY_TEST_SPEC: "version"
 sandbox_clang:
   TEST_PY_BD: "sandbox"
-  OVERRIDE: "-O clang-16"
+  OVERRIDE: "-O clang-17"
 sandbox_clang_asan:
   TEST_PY_BD: "sandbox"
-  OVERRIDE: "-O clang-16 -a ASAN"
+  OVERRIDE: "-O clang-17 -a ASAN"
   TEST_PY_TEST_SPEC: "version"
 sandbox64:
   TEST_PY_BD: "sandbox64"
 sandbox64_clang:
   TEST_PY_BD: "sandbox64"
-  OVERRIDE: "-O clang-16"
+  OVERRIDE: "-O clang-17"
 sandbox_spl:
   TEST_PY_BD: "sandbox_spl"
   TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff or test_spl"
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8bfbadd6c89f..dc68187d79cf 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -256,7 +256,7 @@ sandbox test.py:
 sandbox with clang test.py:
   variables:
 TEST_PY_BD: "sandbox"
-OVERRIDE: "-O clang-16"
+OVERRIDE: "-O clang-17"
   <<: *buildman_and_testpy_dfn
 
 sandbox64 test.py:
@@ -267,7 +267,7 @@ sandbox64 test.py:
 sandbox64 with clang test.py:
   variables:
 TEST_PY_BD: "sandbox64"
-OVERRIDE: "-O clang-16"
+OVERRIDE: "-O clang-17"
   <<: *buildman_and_testpy_dfn
 
 sandbox_spl test.py:
diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index 6122776bc64d..ab82d01a3417 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -12,7 +12,7 @@ ENV DEBIAN_FRONTEND=noninteractive
 # Add LLVM repository
 RUN apt-get update && apt-get install -y gnupg2 wget xz-utils && rm -rf 
/var/lib/apt/lists/*
 RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
-RUN echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main | tee 
/etc/apt/sources.list.d/llvm.list
+RUN echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main | tee 
/etc/apt/sources.list.d/llvm.list
 
 # Manually install the kernel.org "Crosstool" based toolchains for gcc-13.2.0
 RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-aarch64-linux.tar.xz
 | tar -C /opt -xJ
@@ -40,7 +40,7 @@ RUN apt-get update && apt-get install -y \
bison \
build-essential \
cgpt \
-   clang-16 \
+   clang-17 \
coreutils \
cpio \
curl \
-- 
2.34.1



Re: [RFC 2/5] riscv: set fdtfile on Milk-V Mars

2024-03-10 Thread E Shattow
On Fri, Mar 8, 2024 at 2:57 PM Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
...

> > I do not like this practice of force setting fdtfile environment
> > variable. If I set fdtfile from u-boot prompt and saveenv, I expect that
> > my action as the user will persist over a reboot but instead it gets
> > ignored and overwritten by this strategy. Is this necessary to happen
> > before the boot scripts?
>
>
We could check if $fdtfile is already set before the update.
>
> This would require that the default environment does not include it. Cf.
>
> include/configs/starfive-visionfive2.h:51:
> "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
>
...

The default environment is expected to have a sensible default, and
implicitly is only used when there is a checksum error (so no existing
valid fdtfile environment variable). It is not nice to remove capability
from userspace i.e. Linux mtd interface access to update u-boot environment
variables; setting fdtfile as such has no effect as it will always be force
set by this routine. The workaround now is to set fdtfile from a boot.scr
but that adds a dependency to reside on storage (which is not always true
for all boot situations).

What of "fdtfile=${fdtfile_board}" for the default environment and this
routine instead updates $fdtfile_board (or similar) ? I'm not sure what to
suggest, or if this is a common practice for u-boot board support. Thanks -
E


[PATCH v2 4/4] rockchip: Migrate to use DM_USB_GADGET on RK3328

2024-03-10 Thread Jonas Karlman
USB gadget is not working fully as expected on RK3328, it uses a
board_usb_init() function to initialize the DWC2 OTG port.

The board_usb_init() function does not intgrate with the generic phy
framework and as a result the USB phy is not properly configured before
or after USB gadget use.

Having both USB_DWC2 and DWC2_OTG enabled for the same board is also
causing some issues.

Trying to use rockusb or ums command after usb stop result in a freeze
due to usb stop is putting the phy in a suspended state.

  => usb start
  => usb stop
  => ums 0 mmc 0
  --> freeze due to usb phy is suspended <--

Fix this by only using one of USB_DWC2 (host) or DWC2_OTG (peripheral)
depending on the most likely usage of the otg port and by migrating to
use DM_USB_GADGET instead of a board_usb_init() function.

The nanopi-r2 and orangepi-r1-plus variants share OTG and power using a
Type-C connector, mark these boards dr_mode as peripheral, the most
likely usage is for recovery and image download.

The rock64 and roc-cc currently use dr_mode as host, remove the DWC2_OTG
driver from these boards to ensure that the USB_DWC2 driver is used.

The rock-pi-e board does not enable the usb20_otg node so both USB_DWC2
and DWC2_OTG is removed from this board.

Enable RockUSB and UMS on all boards with a otg port in peripheral mode.

Also with the migration to DM_USB_GADGET completed the U-Boot specific
change to reorder usb nodes in the soc device tree can be reverted.

Signed-off-by: Jonas Karlman 
Reviewed-by: Kever Yang 
---
v2:
- Drop use of DWC3_GENERIC and revert to use XHCI_DWC3 for USB 3.0 host
  for devices using another port with otg/peripheral dr_mode to work
  around build errors when mixing DWC3_GENERIC and DWC2_OTG.
- Collect r-b tag
---
 arch/arm/dts/rk3328-nanopi-r2s-u-boot.dtsi|  4 ++
 .../rk3328-orangepi-r1-plus-lts-u-boot.dtsi   |  4 ++
 .../dts/rk3328-orangepi-r1-plus-u-boot.dtsi   |  4 ++
 arch/arm/dts/rk3328-roc-cc-u-boot.dtsi|  4 ++
 arch/arm/dts/rk3328-rock-pi-e-u-boot.dtsi |  9 
 arch/arm/dts/rk3328-rock64-u-boot.dtsi|  4 ++
 arch/arm/dts/rk3328-u-boot.dtsi   |  4 --
 arch/arm/dts/rk3328.dtsi  | 41 ---
 configs/evb-rk3328_defconfig  |  7 +++-
 configs/nanopi-r2c-plus-rk3328_defconfig  |  7 +++-
 configs/nanopi-r2c-rk3328_defconfig   |  7 +++-
 configs/nanopi-r2s-rk3328_defconfig   |  7 +++-
 configs/orangepi-r1-plus-lts-rk3328_defconfig |  7 +++-
 configs/orangepi-r1-plus-rk3328_defconfig |  7 +++-
 configs/roc-cc-rk3328_defconfig   |  7 
 configs/rock-pi-e-rk3328_defconfig|  7 
 configs/rock64-rk3328_defconfig   |  6 ---
 17 files changed, 75 insertions(+), 61 deletions(-)

diff --git a/arch/arm/dts/rk3328-nanopi-r2s-u-boot.dtsi 
b/arch/arm/dts/rk3328-nanopi-r2s-u-boot.dtsi
index cca4f06145cf..4fa170eeaf8d 100644
--- a/arch/arm/dts/rk3328-nanopi-r2s-u-boot.dtsi
+++ b/arch/arm/dts/rk3328-nanopi-r2s-u-boot.dtsi
@@ -15,6 +15,10 @@
bootph-all;
 };
 
+_otg {
+   dr_mode = "peripheral";
+};
+
 _io_sdio {
bootph-pre-ram;
 };
diff --git a/arch/arm/dts/rk3328-orangepi-r1-plus-lts-u-boot.dtsi 
b/arch/arm/dts/rk3328-orangepi-r1-plus-lts-u-boot.dtsi
index 0dbe5a01f986..0a9423cd9c7e 100644
--- a/arch/arm/dts/rk3328-orangepi-r1-plus-lts-u-boot.dtsi
+++ b/arch/arm/dts/rk3328-orangepi-r1-plus-lts-u-boot.dtsi
@@ -33,6 +33,10 @@
bootph-pre-ram;
 };
 
+_otg {
+   dr_mode = "peripheral";
+};
+
 _sd {
bootph-pre-ram;
 };
diff --git a/arch/arm/dts/rk3328-orangepi-r1-plus-u-boot.dtsi 
b/arch/arm/dts/rk3328-orangepi-r1-plus-u-boot.dtsi
index 1af75ada1a62..1096821fc5d3 100644
--- a/arch/arm/dts/rk3328-orangepi-r1-plus-u-boot.dtsi
+++ b/arch/arm/dts/rk3328-orangepi-r1-plus-u-boot.dtsi
@@ -33,6 +33,10 @@
bootph-pre-ram;
 };
 
+_otg {
+   dr_mode = "peripheral";
+};
+
 _sd {
bootph-pre-ram;
 };
diff --git a/arch/arm/dts/rk3328-roc-cc-u-boot.dtsi 
b/arch/arm/dts/rk3328-roc-cc-u-boot.dtsi
index 47d74964fd0c..582d6ba49b4e 100644
--- a/arch/arm/dts/rk3328-roc-cc-u-boot.dtsi
+++ b/arch/arm/dts/rk3328-roc-cc-u-boot.dtsi
@@ -29,6 +29,10 @@
};
 };
 
+_otg {
+   hnp-srp-disable;
+};
+
 _sd {
bootph-pre-ram;
 };
diff --git a/arch/arm/dts/rk3328-rock-pi-e-u-boot.dtsi 
b/arch/arm/dts/rk3328-rock-pi-e-u-boot.dtsi
index 9ed0aef1ecc9..d314bfad6fc0 100644
--- a/arch/arm/dts/rk3328-rock-pi-e-u-boot.dtsi
+++ b/arch/arm/dts/rk3328-rock-pi-e-u-boot.dtsi
@@ -29,6 +29,15 @@
};
 };
 
+_host {
+   phy-supply = <_host_5v>;
+};
+
+_host_5v {
+   /delete-property/ regulator-always-on;
+   /delete-property/ regulator-boot-on;
+};
+
 _sd {
bootph-pre-ram;
 };
diff --git a/arch/arm/dts/rk3328-rock64-u-boot.dtsi 
b/arch/arm/dts/rk3328-rock64-u-boot.dtsi
index 85426495c3d8..551cff6f24f6 100644
--- a/arch/arm/dts/rk3328-rock64-u-boot.dtsi
+++ b/arch/arm/dts/rk3328-rock64-u-boot.dtsi
@@ -55,6 +55,10 @@

[PATCH v2 1/4] rockchip: Update the default USB Product ID value

2024-03-10 Thread Jonas Karlman
RK3036 is using the USB product id normally used by RK3066B, and RK3328
is using the product id normally used by RK3368.

Fix this and update the default USB_GADGET_PRODUCT_NUM Kconfig option
for remaining supported Rockchip SoCs to match the product id used in
Maskrom mode.

Also remove a reference to an undefined ROCKCHIP_RK3229 Kconfig symbol.

Signed-off-by: Jonas Karlman 
---
v2:
- Update commit message
---
 drivers/usb/gadget/Kconfig | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index c72a8047635c..4621a6fd5e64 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -70,12 +70,21 @@ config USB_GADGET_PRODUCT_NUM
hex "Product ID of the USB device"
default 0x701a if ARCH_TEGRA
default 0x1010 if ARCH_SUNXI
-   default 0x310a if ROCKCHIP_RK3036
+   default 0x110a if ROCKCHIP_RV1108
+   default 0x110b if ROCKCHIP_RV1126
default 0x300a if ROCKCHIP_RK3066
+   default 0x301a if ROCKCHIP_RK3036
+   default 0x310b if ROCKCHIP_RK3188
default 0x310c if ROCKCHIP_RK3128
-   default 0x320a if ROCKCHIP_RK3229 || ROCKCHIP_RK3288
-   default 0x330a if ROCKCHIP_RK3328
+   default 0x320a if ROCKCHIP_RK3288
+   default 0x320b if ROCKCHIP_RK322X
+   default 0x320c if ROCKCHIP_RK3328
+   default 0x330a if ROCKCHIP_RK3368
default 0x330c if ROCKCHIP_RK3399
+   default 0x330d if ROCKCHIP_PX30
+   default 0x330e if ROCKCHIP_RK3308
+   default 0x350a if ROCKCHIP_RK3568
+   default 0x350b if ROCKCHIP_RK3588
default 0x0
help
  Product ID of the USB device emulated, reported to the host device.
-- 
2.43.2



[PATCH v2 3/4] rockchip: board: Use a common USB Product ID for UMS

2024-03-10 Thread Jonas Karlman
Change to use the common Product ID 0x0010 when the ums command is used.

This matches downstream vendor U-Boot and is a Product ID that tools
such as rkdeveloptool and RKDevTool will identify as MSC mode.

Signed-off-by: Jonas Karlman 
Reviewed-by: Kever Yang 
---
v2:
- No change
- Collect r-b tag
---
 arch/arm/mach-rockchip/board.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c
index f84ff542aea9..e9cfba756639 100644
--- a/arch/arm/mach-rockchip/board.c
+++ b/arch/arm/mach-rockchip/board.c
@@ -221,8 +221,23 @@ void enable_caches(void)
 #endif
 
 #if IS_ENABLED(CONFIG_USB_GADGET)
-#if IS_ENABLED(CONFIG_USB_GADGET_DWC2_OTG) && !IS_ENABLED(CONFIG_DM_USB_GADGET)
 #include 
+
+#if IS_ENABLED(CONFIG_USB_GADGET_DOWNLOAD)
+#define ROCKCHIP_G_DNL_UMS_PRODUCT_NUM 0x0010
+
+int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
+{
+   if (!strcmp(name, "usb_dnl_ums"))
+   put_unaligned(ROCKCHIP_G_DNL_UMS_PRODUCT_NUM, >idProduct);
+   else
+   put_unaligned(CONFIG_USB_GADGET_PRODUCT_NUM, >idProduct);
+
+   return 0;
+}
+#endif /* CONFIG_USB_GADGET_DOWNLOAD */
+
+#if IS_ENABLED(CONFIG_USB_GADGET_DWC2_OTG) && !IS_ENABLED(CONFIG_DM_USB_GADGET)
 #include 
 #include 
 
-- 
2.43.2



[PATCH v2 2/4] rockchip: board: Prepare for use of DM_USB_GADGET with DWC2_OTG

2024-03-10 Thread Jonas Karlman
The board_usb_init() and board_usb_cleanup() functions is always
included when USB_GADGET and USB_GADGET_DWC2_OTG is enabled.

Prepare for a change to use DM_USB_GADGET with DWC2_OTG by adding an
extra ifdef condition. The extra separate ifdef for USB_GADGET prepare
for next patch that adds a g_dnl_bind_fixup() function.

Signed-off-by: Jonas Karlman 
Reviewed-by: Kever Yang 
---
v2:
- No change
- Collect r-b tag
---
 arch/arm/mach-rockchip/board.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c
index dea5805c4665..f84ff542aea9 100644
--- a/arch/arm/mach-rockchip/board.c
+++ b/arch/arm/mach-rockchip/board.c
@@ -220,7 +220,8 @@ void enable_caches(void)
 }
 #endif
 
-#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
+#if IS_ENABLED(CONFIG_USB_GADGET)
+#if IS_ENABLED(CONFIG_USB_GADGET_DWC2_OTG) && !IS_ENABLED(CONFIG_DM_USB_GADGET)
 #include 
 #include 
 #include 
@@ -296,6 +297,7 @@ int board_usb_cleanup(int index, enum usb_init_type init)
return 0;
 }
 #endif /* CONFIG_USB_GADGET_DWC2_OTG */
+#endif /* CONFIG_USB_GADGET */
 
 #if IS_ENABLED(CONFIG_FASTBOOT)
 int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
-- 
2.43.2



[PATCH] arm: dts: imx8mp-beacon-kit: Resync DTS with Linux 6.8

2024-03-10 Thread Adam Ford
The device tree has evolved over time, so re-sync.  This also
partial reverts one change on the PCIe, because U-Boot doesn't
have a proper driver.  However, since the clock is configured
to generate a 100MHz reference clock by default, a proper driver
isn't really necessary.

Signed-off-by: Adam Ford 

diff --git a/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi 
b/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi
index 393fd8ec2e..ed183f83a7 100644
--- a/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-beacon-kit-u-boot.dtsi
@@ -6,6 +6,13 @@
 #include "imx8mp-u-boot.dtsi"
 
 / {
+   /* U-Boot does not yet have a proper PCIe clk driver */
+   pcie0_refclk: clock-pcie {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <1>;
+   };
+
wdt-reboot {
compatible = "wdt-reboot";
wdt = <>;
@@ -13,6 +20,10 @@
};
 };
 
+_phy {
+   clocks = <_refclk>;
+};
+
 &{/soc@0/bus@3080/i2c@30a2/pmic@25} {
bootph-pre-ram;
 };
diff --git a/arch/arm/dts/imx8mp-beacon-kit.dts 
b/arch/arm/dts/imx8mp-beacon-kit.dts
index cdae45a48c..a08057410b 100644
--- a/arch/arm/dts/imx8mp-beacon-kit.dts
+++ b/arch/arm/dts/imx8mp-beacon-kit.dts
@@ -23,6 +23,12 @@
stdout-path = 
};
 
+   clk_xtal25: clock-xtal25 {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <2500>;
+   };
+
connector {
compatible = "usb-c-connector";
label = "USB-C";
@@ -49,6 +55,12 @@
};
};
 
+   dmic_codec: dmic-codec {
+   compatible = "dmic-codec";
+   num-channels = <1>;
+   #sound-dai-cells = <0>;
+   };
+
gpio-keys {
compatible = "gpio-keys";
autorepeat;
@@ -82,6 +94,17 @@
};
};
 
+   bridge-connector {
+   compatible = "hdmi-connector";
+   type = "a";
+
+   port {
+   hdmi_con: endpoint {
+   remote-endpoint = <_out>;
+   };
+   };
+   };
+
leds {
compatible = "gpio-leds";
pinctrl-names = "default";
@@ -112,10 +135,13 @@
};
};
 
-   pcie0_refclk: clock-pcie {
-   compatible = "fixed-clock";
-   #clock-cells = <0>;
-   clock-frequency = <1>;
+   reg_audio: regulator-wm8962 {
+   compatible = "regulator-fixed";
+   regulator-name = "3v3_aud";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   gpio = <_1 11 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
};
 
reg_usdhc2_vmmc: regulator-usdhc2 {
@@ -137,6 +163,68 @@
gpio = <_1 0 GPIO_ACTIVE_HIGH>;
enable-active-high;
};
+
+   sound-adv7535 {
+   compatible = "simple-audio-card";
+   simple-audio-card,name = "sound-adv7535";
+   simple-audio-card,format = "i2s";
+
+   simple-audio-card,cpu {
+   sound-dai = <>;
+   system-clock-direction-out;
+   };
+
+   simple-audio-card,codec {
+   sound-dai = <_bridge>;
+   };
+   };
+
+   sound-dmic {
+   compatible = "simple-audio-card";
+   simple-audio-card,name = "sound-pdm";
+   simple-audio-card,format = "i2s";
+   simple-audio-card,bitclock-master = <_master>;
+   simple-audio-card,frame-master = <_master>;
+
+   dailink_master: simple-audio-card,cpu {
+   sound-dai = <>;
+   };
+
+   simple-audio-card,codec {
+   sound-dai = <_codec>;
+   };
+   };
+
+   sound-wm8962 {
+   compatible = "simple-audio-card";
+   simple-audio-card,name = "wm8962";
+   simple-audio-card,format = "i2s";
+   simple-audio-card,widgets = "Headphone", "Headphones",
+   "Microphone", "Headset Mic",
+   "Speaker", "Speaker";
+   simple-audio-card,routing = "Headphones", "HPOUTL",
+   "Headphones", "HPOUTR",
+   "Speaker", "SPKOUTL",
+   "Speaker", "SPKOUTR",
+   "Headset Mic", "MICBIAS",
+   "IN3R", "Headset Mic";
+
+   simple-audio-card,cpu {
+   sound-dai = <>;
+   };
+
+   

[PATCH] arm: Check FEAT_CCIDX when parsing ccsidr_el1 register

2024-03-10 Thread Lukasz Wiecaszek
Current Cache Size ID Register (ccsidr_el1) has two "flavors"
depending on whether FEAT_CCIDX is implemented or not.
When FEAT_CCIDX is implemented Associativity parameter
is coded on bits [23:3] and NumSets parameter on bits [55:32].
When FEAT_CCIDX is not implemented then Associativity parameter
is coded on bits [12:3] and NumSets parameter on bits [27:13].
Current U-Boot code does not check whether FEAT_CCIDX is implemented
and always parses ccsidr_el1 as if FEAT_CCIDX was not implemented.
This is of course wrong on systems where FEAT_CCIDX is implemented.
This patch fixes that problems and tests whether FEAT_CCIDX
is implemented or not and accordingly parses the ccsidr_el1 register.

Signed-off-by: Lukasz Wiecaszek 
---
 arch/arm/cpu/armv8/cache.S | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/cpu/armv8/cache.S b/arch/arm/cpu/armv8/cache.S
index 3fe935cf28..c9e46859b4 100644
--- a/arch/arm/cpu/armv8/cache.S
+++ b/arch/arm/cpu/armv8/cache.S
@@ -20,6 +20,7 @@
  *
  * x0: cache level
  * x1: 0 clean & invalidate, 1 invalidate only
+ * x16: FEAT_CCIDX
  * x2~x9: clobbered
  */
 .pushsection .text.__asm_dcache_level, "ax"
@@ -29,8 +30,14 @@ ENTRY(__asm_dcache_level)
isb /* sync change of cssidr_el1 */
mrs x6, ccsidr_el1  /* read the new cssidr_el1 */
ubfxx2, x6,  #0,  #3/* x2 <- log2(cache line size)-4 */
+   cbz x16, 3f /* check for FEAT_CCIDX */
+   ubfxx3, x6,  #3, #21/* x3 <- number of cache ways - 1 */
+   ubfxx4, x6, #32, #24/* x4 <- number of cache sets - 1 */
+   b   4f
+3:
ubfxx3, x6,  #3, #10/* x3 <- number of cache ways - 1 */
ubfxx4, x6, #13, #15/* x4 <- number of cache sets - 1 */
+4:
add x2, x2, #4  /* x2 <- log2(cache line size) */
clz w5, w3  /* bit position of #ways */
/* x12 <- cache level << 1 */
@@ -74,6 +81,8 @@ ENTRY(__asm_dcache_all)
ubfxx11, x10, #24, #3   /* x11 <- loc */
cbz x11, finished   /* if loc is 0, exit */
mov x15, lr
+   mrs x16, s3_0_c0_c7_2   /* read value of id_aa64mmfr2_el1*/
+   ubfxx16, x16, #20, #4   /* save FEAT_CCIDX identifier in x16 */
mov x0, #0  /* start flush at cache level 0 */
/* x0  <- cache level */
/* x10 <- clidr_el1 */
-- 
2.44.0



[PATCH 3/3] configs: milkv_duo: Add ethernet configs

2024-03-10 Thread Kongyang Liu
Add configs related to ethernet and ethernet boot command for Sophgo Milk-V
Duo board

Signed-off-by: Kongyang Liu 
---

 configs/milkv_duo_defconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/configs/milkv_duo_defconfig b/configs/milkv_duo_defconfig
index e8413d7aa9..f66c4c5358 100644
--- a/configs/milkv_duo_defconfig
+++ b/configs/milkv_duo_defconfig
@@ -19,14 +19,18 @@ CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="milkv_duo# "
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_PXE=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_ENV_OVERWRITE=y
+CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_MMC=y
 CONFIG_MMC_IO_VOLTAGE=y
 CONFIG_MMC_UHS_SUPPORT=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_ADMA=y
 CONFIG_MMC_SDHCI_CV1800B=y
+CONFIG_ETH_DESIGNWARE=y
 CONFIG_SYS_NS16550=y
 CONFIG_SYS_NS16550_MEM32=y
-- 
2.41.0



[PATCH 2/3] riscv: dts: sophgo: Add ethernet node

2024-03-10 Thread Kongyang Liu
Add ethernet node for cv1800b SoC

Signed-off-by: Kongyang Liu 
---

 arch/riscv/dts/cv18xx.dtsi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/riscv/dts/cv18xx.dtsi b/arch/riscv/dts/cv18xx.dtsi
index ec99c4deeb..013372a40c 100644
--- a/arch/riscv/dts/cv18xx.dtsi
+++ b/arch/riscv/dts/cv18xx.dtsi
@@ -197,6 +197,12 @@
status = "disabled";
};
 
+   ethernet0: ethernet@407 {
+   compatible = "sophgo,cv1800b-ethernet";
+   reg = <0x0407 0x1>;
+   phy-mode = "rmii";
+   };
+
plic: interrupt-controller@7000 {
reg = <0x7000 0x400>;
interrupts-extended = <_intc 11>, <_intc 9>;
-- 
2.41.0



[PATCH 1/3] board: milkv_duo: Add init code for Milk-V Duo ethernet

2024-03-10 Thread Kongyang Liu
Initialize register in cv1800b ethernet phy to make it compatible with
generic phy driver

Signed-off-by: Kongyang Liu 

---

 board/sophgo/milkv_duo/Makefile   |  3 +-
 board/sophgo/milkv_duo/board.c|  4 ++
 board/sophgo/milkv_duo/ethernet.c | 79 +++
 board/sophgo/milkv_duo/ethernet.h | 11 +
 drivers/net/designware.c  |  1 +
 5 files changed, 97 insertions(+), 1 deletion(-)
 create mode 100644 board/sophgo/milkv_duo/ethernet.c
 create mode 100644 board/sophgo/milkv_duo/ethernet.h

diff --git a/board/sophgo/milkv_duo/Makefile b/board/sophgo/milkv_duo/Makefile
index a087013f5c..d0525eba85 100644
--- a/board/sophgo/milkv_duo/Makefile
+++ b/board/sophgo/milkv_duo/Makefile
@@ -2,4 +2,5 @@
 #
 # Copyright (c) 2024, Kongyang Liu 
 
-obj-y := board.o
+obj-y += board.o
+obj-$(CONFIG_NET) += ethernet.o
diff --git a/board/sophgo/milkv_duo/board.c b/board/sophgo/milkv_duo/board.c
index eaa47be173..311576fe1c 100644
--- a/board/sophgo/milkv_duo/board.c
+++ b/board/sophgo/milkv_duo/board.c
@@ -3,7 +3,11 @@
  * Copyright (c) 2024, Kongyang Liu 
  */
 
+#include "ethernet.h"
+
 int board_init(void)
 {
+   if (IS_ENABLED(CONFIG_NET))
+   cv1800b_ephy_init();
return 0;
 }
diff --git a/board/sophgo/milkv_duo/ethernet.c 
b/board/sophgo/milkv_duo/ethernet.c
new file mode 100644
index 00..e997ce1037
--- /dev/null
+++ b/board/sophgo/milkv_duo/ethernet.c
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2024, Kongyang Liu 
+ */
+
+#include 
+#include 
+#include 
+
+#define REG_EPHY_TOP_WRAP (u32 *)0x03009800
+#define REG_EPHY_BASE (u32 *)0x03009000
+
+#define REG_EPHY_CTL REG_EPHY_TOP_WRAP
+#define REG_EPHY_APB_RW_SEL  REG_EPHY_TOP_WRAP + 1
+
+/* Page 0 register */
+#define REG_PHY_ID1  REG_EPHY_BASE + MII_PHYSID1
+#define REG_PHY_ID2  REG_EPHY_BASE + MII_PHYSID2
+#define REG_PHY_PAGE_SEL REG_EPHY_BASE + 0x1f
+
+/* Page 5 register */
+#define REG_PD_EN_CTLREG_EPHY_BASE + 0x10
+
+/* REG_EPHY_CTL */
+#define REG_EPHY_SHUTDOWNBIT(0)
+#define REG_EPHY_ANA_RST_N   BIT(1)
+#define REG_EPHY_DIG_RST_N   BIT(2)
+#define REG_EPHY_MAIN_RST_N  BIT(3)
+
+/* REG_PD_EN_CTL */
+#define REG_EN_ETH_TXRT  BIT(0)
+#define REG_EN_ETH_CLK100M   BIT(1)
+#define REG_EN_ETH_CLK125M   BIT(2)
+#define REG_EN_ETH_PLL_LCKDETBIT(3)
+#define REG_EN_ETH_RXADC BIT(4)
+#define REG_EN_ETH_RXPGA BIT(5)
+#define REG_EN_ETH_RXRT  BIT(6)
+#define REG_EN_ETH_TXCROSSOVER   BIT(7)
+#define REG_PD_ETH_PLL   BIT(8)
+#define REG_PD_ETH_TXDAC BIT(9)
+#define REG_PD_ETH_TXDACBST  BIT(10)
+#define REG_PD_ETH_TXECHOBIT(11)
+#define REG_PD_ETH_TXDRV_NMOSBIT(12)
+#define REG_PD_ETH_TXLDO BIT(13)
+
+void cv1800b_ephy_init(void)
+{
+   u32 reg;
+   u32 phy_id = 1;
+
+   /* enable direct memory access for phy register */
+   writel(1, REG_EPHY_APB_RW_SEL);
+
+   reg = readl(REG_EPHY_CTL);
+   reg &= ~REG_EPHY_SHUTDOWN;
+   reg |= REG_EPHY_ANA_RST_N | REG_EPHY_DIG_RST_N | REG_EPHY_MAIN_RST_N;
+   writel(reg, REG_EPHY_CTL);
+
+   /* switch to page 5 */
+   writel(5 << 8, REG_PHY_PAGE_SEL);
+   reg = readl(REG_PD_EN_CTL);
+   reg &= ~(REG_PD_ETH_TXLDO | REG_PD_ETH_TXDRV_NMOS | REG_PD_ETH_TXDAC | 
REG_PD_ETH_PLL);
+   reg |= REG_EN_ETH_TXRT | REG_EN_ETH_CLK100M | REG_EN_ETH_CLK125M
+   | REG_EN_ETH_PLL_LCKDET | REG_EN_ETH_RXADC | REG_EN_ETH_RXPGA | 
REG_EN_ETH_RXRT;
+   writel(reg, REG_PD_EN_CTL);
+
+   /* switch to page 0 */
+   writel(0 << 8, REG_PHY_PAGE_SEL);
+   /*
+* As the phy_id in the cv1800b PHY register is initialized to 0, it
+* is necessary to manually initialize the phy_id to an arbitrary
+* value so that it could corresponds to the generic PHY driver.
+*/
+   writel(phy_id >> 16, REG_PHY_ID1);
+   writel(phy_id & 0x, REG_PHY_ID2);
+
+   /* switch to MDIO control */
+   writel(0, REG_EPHY_APB_RW_SEL);
+}
diff --git a/board/sophgo/milkv_duo/ethernet.h 
b/board/sophgo/milkv_duo/ethernet.h
new file mode 100644
index 00..7b21f1b0f6
--- /dev/null
+++ b/board/sophgo/milkv_duo/ethernet.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2024, Kongyang Liu 
+ */
+
+#ifndef __CV1800B_ETHERNET_H
+#define __CV1800B_ETHERNET_H
+
+void cv1800b_ephy_init(void);
+
+#endif
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index c222197b11..e4e173f9fd 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -861,6 +861,7 @@ static const struct udevice_id designware_eth_ids[] = {
{ .compatible = "amlogic,meson6-dwmac" },
{ .compatible = "st,stm32-dwmac" },
{ .compatible = "snps,arc-dwmac-3.70a" },
+   { .compatible = "sophgo,cv1800b-ethernet" },
{ }
 };
 
-- 
2.41.0



[PATCH 0/3] board: sophgo: milkv_duo: Add ethernet support for Milk-V Duo board

2024-03-10 Thread Kongyang Liu
This series add init code for cv1800b ethernet phy and enable ethernet
support for Sophgo Milk-V Duo board.

In cv1800b, due to the PHY register phy_id being initialized to 0, it is
necessary to initialize the PHY before the ethernet driver initialization.
Therefore, the initialization code is placed in the board_init function.

Duo to modification of dts and defconfig, This series depends on the series:
https://lore.kernel.org/all/20240309175330.79267-1-seashell11234...@gmail.com/


Kongyang Liu (3):
  board: milkv_duo: Add init code for Milk-V Duo ethernet
  riscv: dts: sophgo: Add ethernet node
  configs: milkv_duo: Add ethernet configs

 arch/riscv/dts/cv18xx.dtsi|  6 +++
 board/sophgo/milkv_duo/Makefile   |  3 +-
 board/sophgo/milkv_duo/board.c|  4 ++
 board/sophgo/milkv_duo/ethernet.c | 79 +++
 board/sophgo/milkv_duo/ethernet.h | 11 +
 configs/milkv_duo_defconfig   |  4 ++
 drivers/net/designware.c  |  1 +
 7 files changed, 107 insertions(+), 1 deletion(-)
 create mode 100644 board/sophgo/milkv_duo/ethernet.c
 create mode 100644 board/sophgo/milkv_duo/ethernet.h

-- 
2.41.0



Re: [PATCH v3] Makefile: use shell to calculate map_size

2024-03-10 Thread Dragan Simic

On 2024-03-05 18:15, Dragan Simic wrote:

On 2024-03-05 17:46, Leon M. Busch-George wrote:

From: "Leon M. Busch-George" 

The error message "bc: command not found" is easily missed since the
build continues.
bc is not a part of coreutils or base-devel. POSIX sh can also do the
calculation.

Signed-off-by: Leon M. Busch-George 


Sorry, I totally missed the v3.  It's still looking good to me, and my
Reviewed-by tag still applies, together with the small nitpick.


---
 Makefile | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index a2bc9d5903..0aef07ef3b 100644
--- a/Makefile
+++ b/Makefile
@@ -1275,10 +1275,15 @@ OBJCOPYFLAGS_u-boot-nodtb.bin := -O binary \
 binary_size_check: u-boot-nodtb.bin FORCE
@file_size=$(shell wc -c u-boot-nodtb.bin | awk '{print $$1}') ; \
map_size=$(shell cat u-boot.map | \
-   awk '/_image_copy_start/ {start = $$1} /_image_binary_end/ {end 
=
$$1} END {if (start != "" && end != "") print "ibase=16; "
toupper(end) " - " toupper(start)}' \
-   | sed 's/0X//g' \
-   | bc); \
-   if [ "" != "$$map_size" ]; then \
+   awk ' \
+   /_image_copy_start/ { start = $$1 } \
+   /_image_binary_end/ { end = $$1 } \
+   END { \
+   if (start != "" && end != "") \
+   print end " " start; \
+   }' \
+   | sh -c 'read end start && echo $$((end - start))'); \
+   if [ -n "$$map_size" ]; then \
if test $$map_size -ne $$file_size; then \
echo "u-boot.map shows a binary size of $$map_size" >&2 
; \
echo "  but u-boot-nodtb.bin shows $$file_size" >&2 ; \


Re: [PATCH v2] Makefile: use shell to calculate map_size

2024-03-10 Thread Dragan Simic

Hello Leon,

On 2024-03-04 21:44, Dragan Simic wrote:

On 2024-03-04 21:38, Leon M. Busch-George wrote:

From: "Leon M. Busch-George" 

The error message "bc: command not found" is easily missed since the
build continues.
bc is not a part of coreutils or base-devel. POSIX sh can also do the
calculation.

Signed-off-by: Leon M. Busch-George 


The v2 is looking good to me.  I also did some testing of the awk code
by hand, outside of the actual Makefile, and it worked as expected.

See also one small nitpick below, and please feel free to include:

Reviewed-by: Dragan Simic 


---
 Makefile | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index a2bc9d5903..e8e794368e 100644
--- a/Makefile
+++ b/Makefile
@@ -1275,10 +1275,15 @@ OBJCOPYFLAGS_u-boot-nodtb.bin := -O binary \
 binary_size_check: u-boot-nodtb.bin FORCE
@file_size=$(shell wc -c u-boot-nodtb.bin | awk '{print $$1}') ; \


Perhaps a couple of spaces could be added around "print $$1" in the
line above, to nicely round off the code cleanups.


map_size=$(shell cat u-boot.map | \
-   awk '/_image_copy_start/ {start = $$1} /_image_binary_end/ {end 
=
$$1} END {if (start != "" && end != "") print "ibase=16; "
toupper(end) " - " toupper(start)}' \
-   | sed 's/0X//g' \
-   | bc); \
-   if [ "" != "$$map_size" ]; then \
+   awk ' \
+   /_image_copy_start/ { start = $$1 } \
+   /_image_binary_end/ { end = $$1 } \
+   END { \
+   if (start != "" && end != "") \
+   print end " " start; \
+   }' \
+		| sh -c 'read end start; [ -n "$$end" ] && echo $$((end - 
start))'); \

+   if [ -n "$$map_size" ]; then \
if test $$map_size -ne $$file_size; then \
echo "u-boot.map shows a binary size of $$map_size" >&2 
; \
echo "  but u-boot-nodtb.bin shows $$file_size" >&2 ; \