Re: [PATCH v3 5/6] board: stm32f469-disco: add support to display

2023-12-11 Thread Patrice CHOTARD



On 12/11/23 23:05, Dario Binacchi wrote:
> Add support to Orise Tech OTM8009A display on stm32f469-disco board.
> 
> It was necessary to retrieve the framebuffer address from the device tree
> because the address returned by the video-uclass driver pointed to a memory
> area that was not usable.
> 
> Signed-off-by: Dario Binacchi 
> ---
> 
> Changes in v3:
> - Replace SDRAM_SIZE constant with global data gd->ram_size.
> 
> Changes in v2:
> - Add DRAM_SIZE macro.
> - Fix frame buffer allocation function so that it is backward compatible
>   with boards other than the one it was introduced for (i. e. 
> stm32f469-disco).
>   Tested on stm32f469-disco and stm32mp157f-dk2 boards.
> 
>  configs/stm32f469-discovery_defconfig | 13 +++
>  drivers/video/stm32/stm32_ltdc.c  | 31 +++
>  2 files changed, 44 insertions(+)
> 
> diff --git a/configs/stm32f469-discovery_defconfig 
> b/configs/stm32f469-discovery_defconfig
> index 21c5498466cd..85e795e83e7d 100644
> --- a/configs/stm32f469-discovery_defconfig
> +++ b/configs/stm32f469-discovery_defconfig
> @@ -21,6 +21,7 @@ CONFIG_CMD_GPT=y
>  # CONFIG_RANDOM_UUID is not set
>  CONFIG_CMD_MMC=y
>  # CONFIG_CMD_SETEXPR is not set
> +CONFIG_CMD_BMP=y
>  CONFIG_CMD_CACHE=y
>  CONFIG_CMD_TIMER=y
>  # CONFIG_ISO_PARTITION is not set
> @@ -40,3 +41,15 @@ CONFIG_SPI_FLASH_STMICRO=y
>  CONFIG_SPI=y
>  CONFIG_DM_SPI=y
>  CONFIG_STM32_QSPI=y
> +CONFIG_VIDEO=y
> +CONFIG_BACKLIGHT_GPIO=y
> +CONFIG_VIDEO_LCD_ORISETECH_OTM8009A=y
> +CONFIG_VIDEO_STM32=y
> +CONFIG_VIDEO_STM32_DSI=y
> +CONFIG_VIDEO_STM32_MAX_XRES=480
> +CONFIG_VIDEO_STM32_MAX_YRES=800
> +CONFIG_BMP_16BPP=y
> +CONFIG_BMP_24BPP=y
> +CONFIG_BMP_32BPP=y
> +CONFIG_DM_REGULATOR=y
> +CONFIG_DM_REGULATOR_FIXED=y
> diff --git a/drivers/video/stm32/stm32_ltdc.c 
> b/drivers/video/stm32/stm32_ltdc.c
> index 6fd90e33919d..4f60ba8ebeeb 100644
> --- a/drivers/video/stm32/stm32_ltdc.c
> +++ b/drivers/video/stm32/stm32_ltdc.c
> @@ -495,6 +495,33 @@ static void stm32_ltdc_set_layer1(struct stm32_ltdc_priv 
> *priv, ulong fb_addr)
>   setbits_le32(priv->regs + LTDC_L1CR, LXCR_LEN);
>  }
>  
> +#if IS_ENABLED(CONFIG_TARGET_STM32F469_DISCOVERY)
> +static int stm32_ltdc_alloc_fb(struct udevice *dev)
> +{
> + u32 sdram_size = gd->ram_size;
> + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
> + phys_addr_t cpu;
> + dma_addr_t bus;
> + u64 dma_size;
> + int ret;
> +
> + ret = dev_get_dma_range(dev, &cpu, &bus, &dma_size);
> + if (ret) {
> + dev_err(dev, "failed to get dma address\n");
> + return ret;
> + }
> +
> + uc_plat->base = bus + sdram_size - ALIGN(uc_plat->size, uc_plat->align);
> + return 0;
> +}
> +#else
> +static inline int stm32_ltdc_alloc_fb(struct udevice *dev)
> +{
> + /* Delegate framebuffer allocation to video-uclass */
> + return 0;
> +}
> +#endif
> +
>  static int stm32_ltdc_probe(struct udevice *dev)
>  {
>   struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
> @@ -605,6 +632,10 @@ static int stm32_ltdc_probe(struct udevice *dev)
>   priv->crop_h = timings.vactive.typ;
>   priv->alpha = 0xFF;
>  
> + ret = stm32_ltdc_alloc_fb(dev);
> + if (ret)
> + return ret;
> +
>   dev_dbg(dev, "%dx%d %dbpp frame buffer at 0x%lx\n",
>   timings.hactive.typ, timings.vactive.typ,
>   VNBITS(priv->l2bpp), uc_plat->base);

Reviewed-by: Patrice Chotard 

Thanks
Patrice


Re: [PATCH v3 4/6] ARM: dts: stm32: support MIPI DSI on stm32f469-disco board

2023-12-11 Thread Patrice CHOTARD



On 12/11/23 23:05, Dario Binacchi wrote:
> Unlike Linux, the DSI driver requires the LTDC clock to be properly
> probed. Hence, the changes made to the DSI node.
> 
> Signed-off-by: Dario Binacchi 
> ---
> 
> (no changes since v1)
> 
>  arch/arm/dts/stm32f469-disco-u-boot.dtsi | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm/dts/stm32f469-disco-u-boot.dtsi 
> b/arch/arm/dts/stm32f469-disco-u-boot.dtsi
> index 8e781c5a7b23..47ba9fa4a783 100644
> --- a/arch/arm/dts/stm32f469-disco-u-boot.dtsi
> +++ b/arch/arm/dts/stm32f469-disco-u-boot.dtsi
> @@ -92,7 +92,9 @@
>  
>  &dsi {
>   clocks = <&rcc 0 STM32F4_APB2_CLOCK(DSI)>,
> +  <&rcc 0 STM32F4_APB2_CLOCK(LTDC)>,
><&clk_hse>;
> + clock-names = "pclk", "px_clk", "ref";
>  };
>  
>  &gpioa {
> @@ -140,6 +142,8 @@
>  };
>  
>   + bootph-all;
> +
>   clocks = <&rcc 0 STM32F4_APB2_CLOCK(LTDC)>;
>  };
>  
Reviewed-by: Patrice Chotard 

Thanks
Patrice


RE: [PATCH v1 1/1] arm64: zynqmp: Add output-enable pins to SOMs

2023-12-11 Thread Frager, Neal
> Now that the zynqmp pinctrl driver supports the tri-state registers, make 
> sure that the pins requiring output-enable are configured appropriately for 
> SOMs.

> Without it, all tristate setting for MIOs, which are not related to SOM 
> itself, are using default configuration which is not correct setting.
> It means SDs, USBs, ethernet, etc. are not working properly.

> In past it was fixed through calling tristate configuration via bootcmd:
> usb_init=mw 0xFF180208 2020
> kv260_gem3=mw 0xFF18020C 0xFC0 && gpio toggle gpio@ff0a38 && \
>  gpio toggle gpio@ff0a38

> Signed-off-by: Neal Frager 
> ---
> arch/arm/dts/zynqmp-sck-kd-g-revA.dts | 7 +++
> 1 file changed, 7 insertions(+)

> diff --git a/arch/arm/dts/zynqmp-sck-kd-g-revA.dts 
> b/arch/arm/dts/zynqmp-sck-kd-g-revA.dts
> index 56f3128528..ffdb60fa51 100644
> --- a/arch/arm/dts/zynqmp-sck-kd-g-revA.dts
> +++ b/arch/arm/dts/zynqmp-sck-kd-g-revA.dts
> @@ -175,6 +175,7 @@
 
Please do not apply v1 of this patch.  I will making a slight update / 
correction with v2.

Best regards,
Neal Frager
AMD


Re: [PATCH 00/21] Qualcomm generic board support

2023-12-11 Thread Sumit Garg
Hi Tom,

On Sun, 10 Dec 2023 at 03:33, Tom Rini  wrote:
>
> On Mon, Dec 04, 2023 at 11:02:57AM +0530, Sumit Garg wrote:
>
> [snip]
> > But currently u-boot doesn't have a proper way to validate those DTS
> > against DT bindings (maintained in Linux kernel). Although there are
> > Devicetree schema tools available here [2], there isn't a versioned
> > release package of DT bindings which one should use to validate DTS
> > files.
>
> I will have more / other things to say but I want to chime in here. That
> U-Boot cannot validate the DTS files is a bug, not a feature. I would
> very much appreciate if someone(s) with time and skills to do so would
> re-sync us with the kernel Kbuild again so that we can both stay in sync
> again and have the validation targets / functionality available here
> too.
>

Agree, the Kbuild changes to add dtbs_check was the first thing I
implemented after importing devicetree-rebasing repo in u-boot (see
commit [1] for details). Usage with PR [2] included:

While building any u-boot target, just add make target: "dtbs_check"
and you will see the DT schema checks being performed. Steps:

$ make _defconfig
$ make -j`nproc` dtbs_check

Currently there are a lot of incompatibility warnings I have seen for
the platforms I built. This shows how much difficult it has been to
keep DT in sync with upstream DT bindings.

TBH, this was the only motivation for me to get into discussion with
DT bindings maintainers for a separate repo. But since with
devicetree-rebasing, we get devictree files bundled along and then I
got into reusing them for building DTBs in u-boot. This has the other
benefit of reducing maintainer's pain to keep DT in sync with Linux
kernel major releases (see amlogic platforms to be the first migrator
[3]).

[1] 
https://github.com/u-boot/u-boot/pull/451/commits/7ea2dc2477992a603fa881d0da563246ee2f02d9
[2] https://github.com/u-boot/u-boot/pull/451
[3] 
https://github.com/u-boot/u-boot/pull/451/commits/38c2ac62e9134604d1a56179d57baa1877712b3e

-Sumit

> --
> Tom


T113 sunxi SPI NAND thoughts, feedback wanted

2023-12-11 Thread John Watts
Greetings sunxi and U-Boot friends!

Over the past five months I've managed to slog through getting a
complete SPI NAND U-Boot and Linux setup running on my Mango Pi MQ.

My tree is here, but I will be slowly trying to upstream my work over
the next few months: https://github.com/Jookia/u-boot/commits/jookia_t113/

It is based on master at the moment with the following patches:
- SUNIV SPI NAND support in SPL
  
(https://lore.kernel.org/u-boot/8034158c-03ab-7488-6afa-a67f04264...@gmail.com)
- UART1 and UART2 support for the Mango Pi MQ
- SPI NAND device tree addition for my device
- A new boot option: BOOT_DEVICE_SPINAND
- SPL SPI booting on the T113 (superseeded by someone else)
- SPI controller support for the T113 (superseeded by someone else)
- MTD Kconfig requirement for UBI
- spinand_ helper functions to support UBI in the SPL
- UBI SPINAND support
- UBI SPL FIT support
- musb gadget suport (superseeded by someone else)

This patch seems to be independently written for the T113 SPI support
but looks the same as what I've done:
https://lore.kernel.org/u-boot/2023133432.755363-1-biguncle...@gmail.com/

The same with this USB fix:
https://lore.kernel.org/u-boot/20230615190701.327852-1-cfswo...@gmail.com/

I plan to add feedback and review to both these patches. Though USB is a
separate subject, I would be interested to know what speeds people are
getting over USB gadget on the T113. DFU seems to cap out at 70KiB/s,
much lower than SSH in Linux.

Anyway, talking in IRC and reading patches on the mailing list, it seems
there's a little lack of direction for SPI NAND support in U-Boot.
Particularly around how to integrate it alongside existing NAND support
and handling bad blocks.

I'd like to first talk about the boot device situation. It works like
this:

- BOOT_DEVICE_SPI means SPI NOR memory
- BOOT_DEVICE_NAND means parallel NAND memory
- BOOT_DEVICE_ONENAND means OneNAND memory
- drivers/mtd/spi uses drivers/spi/spi-mem
- drivers/mtd/nand/spi uses drivers/spi/spi-mem
- drivers/spi/spi-mem uses drivers/spi/spi-sunxi
- common/spl/spl_spi uses drivers/spi/spi-mem and BOOT_DEVICE_SPI
- common/spl/spl_nand uses mtd/nand/raw and BOOT_DEVICE_NAND
- common/spl/spl_onenand uses drivers/mtd/onenand and BOOT_DEVICE_ONENAND
- common/spl/spl_ubi uses drivers/mtd/nand/raw or drivers/mtd/onenand
  and either BOOT_DEVICE_NAND or BOOT_DEVICE_ONENAND
- drivers/nand/raw has a sunxi NAND and sunxi NAND SPL driver
- arch/arm/mach-sunxi/spl_spi_sunxi implements its own SPI loader

A quick grep shows the following custom SPL_LOAD_IMAGE_METHODs in arch:

arch/arm/mach-sunxi/spl_spi_sunxi.c:SPL_LOAD_IMAGE_METHOD("sunxi SPI", 0, 
BOOT_DEVICE_SPI, spl_spi_load_image);
arch/x86/cpu/apollolake/spl.c:SPL_LOAD_IMAGE_METHOD("Mapped SPI", 2, 
BOOT_DEVICE_SPI_MMAP, rom_load_image);
arch/x86/cpu/apollolake/spl.c:SPL_LOAD_IMAGE_METHOD("Fast SPI", 1, 
BOOT_DEVICE_FAST_SPI,

Looking closer at the NAND APIs SPL uses, it calls the following
functions and defines:

nand_init();
nand_deselect();
int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst);
int nand_spl_read_block(int block, int offset, int len, void *dst);
int onenand_spl_read_block(int block, int offset, int len, void *dst);
int onenand_spl_load_image(uint32_t offs, uint32_t size, void *dst);
BOOT_DEVICE_NAND
BOOT_DEVICE_ONENAND
CONFIG_SYS_ONENAND_PAGE_SIZE
CONFIG_SYS_NAND_U_BOOT_OFFS
CONFIG_SYS_NAND_BLOCK_SIZE
CONFIG_SYS_NAND_PAGE_SIZE
CONFIG_SPL_SPI_SUNXI_NAND_ASSUMED_PAGESIZE (used by SUNIV NAND patch)

In the SUNIV NAND patch there was a question of whether to add a
device-specific BOOT_DEVICE. I think the answer to that heavily depends
on whether the current OneNAND/NAND separation makes sense. The APIs are
basically the same, just with different implementations. The only thing
the BOOT_DEVICE_ does here is indicate that there is a distinct boot
ROM option and that we have booted from it. This disambiguates which
NAND we would be using on sunxi: Parallel or SPI.

In my patches I went ahead and added a new SPI NAND API:

spinand_init();
spinand_deselect();
spinand_spl_read_block(int block, int offset, int len, void *dst);
BOOT_DEVICE_SPINAND
CONFIG_SPL_SPINAND_PAGE_SIZE
CONFIG_SPL_SPINAND_BLOCK_SIZE
(I removed the SUNIV NAND config)

I implemented this in the custom sunxi loader code and made UBI use it.
It might be better off as its own thing in drivers/mtd/nand/spi. Then
perhaps arch/arm/mach-sunxi/spl_spi_sunxi could be refactored and moved
to drivers/mtd/spi/, or removed entirely.

I also want to note that with NAND there's also the question of what to
do with bad blocks: The flash I use has 128KiB block sizes. The SPL is
32KiB and U-Boot is 444KiB, needing 4 blocks.

The boot ROM will try multiple pages. To quote
https://linux-sunxi.org/Bootable_SPI_flash:

"Some SoCs can also boot from SPI NAND flash. Here the BROM tries to
read a valid first stage bootloader starting from page number 0, 32, 64,
96, 128, 160, 192 and 224. It only reads the first 1024 by

Re: [PATCH v2] imx: imx8mp: Add support for Polyhex Debix Model A SBC

2023-12-11 Thread Gilles Talis
Hi Milan,

Le jeu. 7 déc. 2023 à 11:09, Milan Zamazal  a écrit :

> Peng Fan  writes:
>
> > On 5/24/2023 3:21 AM, Gilles Talis wrote:
> >> Add support for the Polyhex Debix Model A SBC board.
> >> It is an industrial grade single board computer based on
> >> NXP's i.MX 8M Plus.
> >> Currently supported interfaces are:
> >> - Serial console
> >> - Micro SD
> >> - eQOS and FEC Ethernet
> >> imx8mp-debix-model-a.dts is taken from Linux 6.3.
> >> Signed-off-by: Gilles Talis
> >
> > Reviewed-by: Peng Fan 
>
> Do you know why the patch has been left (as far as I can see) without
> further action?
>
I don't know. I assume the maintainer is very busy or has missed it. I was
planning to do a resend in the next few weeks.


>
> BTW, I applied it to current master, compiled approximately following
> https://docs.u-boot.org/en/latest/board/nxp/imx8mp_evk.html and tried to
> use it on Debix Model A.  U-Boot starts but cannot find the partition
> table on the SD card:
>
>   U-Boot SPL 2024.01-rc3-07226-g43f2873fa9-dirty (Jan 01 1980 - 00:00:00
> +)
>   Normal Boot
>   WDT:   Started watchdog@3028 with servicing every 1000ms (60s
> timeout)
>   Trying to boot from BOOTROM
>   Boot Stage: Primary boot
>   image offset 0x8000, pagesize 0x200, ivt offset 0x0
>   NOTICE:  BL31: v2.2(release):rel_imx_5.4.70_2.3.6-0-g15e8ff164-dirty
>   NOTICE:  BL31: Built : 00:00:00, Jan  1 1980
>
>
>   U-Boot 2024.01-rc3-07226-g43f2873fa9-dirty (Jan 01 1980 - 00:00:00 +)
>
>   CPU:   Freescale i.MX8MP[8] rev1.1 at 1200 MHz
>   Reset cause: POR
>   Model: Polyhex Debix Model A i.MX8MPlus board
>   DRAM:  2 GiB
>   Core:  83 devices, 22 uclasses, devicetree: separate
>   WDT:   Started watchdog@3028 with servicing every 1000ms (60s
> timeout)
>   MMC:   FSL_SDHC: 1, FSL_SDHC: 2
>   Loading Environment from MMC... *** Warning - bad CRC, using default
> environment
>
>   In:serial@3089
>   Out:   serial@3089
>   Err:   serial@3089
>   Net:   eth1: ethernet@30bf [PRIME]
>   Hit any key to stop autoboot:  2 <0x08><0x08><0x08> 1 <0x08><0x08><0x08>
> 0
>   switch to partitions #0, OK
>   mmc1 is current device
>   Scanning mmc 1:1...
>   ,** No partition table - mmc 1 **
>   Couldn't find partition mmc 1:1
>   ,** No partition table - mmc 1 **
>   Couldn't find partition mmc 1:1
>   ,** No partition table - mmc 1 **
>   Couldn't find partition mmc 1:1
>   ,** No partition table - mmc 1 **
>   Couldn't find partition mmc 1:1
>   ,** No partition table - mmc 1 **
>   Couldn't find partition mmc 1:1
>   ,** No partition table - mmc 1 **
>   Couldn't find partition mmc 1:1
>   ,** No partition table - mmc 1 **
>   Couldn't find partition mmc 1:1
>   <0x1b>7<0x1b>[r<0x1b>[999;999H<0x1b>[6n<0x1b>8Card did not respond to
> voltage select! : -110
>   No EFI system partition
>   No EFI system partition
>   Failed to persist EFI variables
>   Remove /soc@0/bus@3080/ethernet@30be:phy-reset-gpios
>   BootOrder not defined
>   EFI boot manager: Cannot load any image
>   ,** No partition table - mmc 1 **
>   Couldn't find partition mmc 1:1
>   Card did not respond to voltage select! : -110
>   u-boot=>
>
> When I use an old U-Boot blob provided by Debix, it boots fine from the
> same SD card.  The SD card contains a Fedora aarch64 image with a msdos
> partition table.
>
> Do you know what could be wrong?
>
Interesting. I don't have a clue yet,. but let me give it a try and come
back to you. Where can I download the Fedora aarch64 image you mentioned
above?


>
> Regards,
> Milan
>
> Thanks!
Gilles.


Re: [PATCH v4] arm: dts: rockpro64: Add RockPro64 smbios

2023-12-11 Thread Kever Yang



On 2023/11/13 19:23, Shantur Rathore wrote:

Add smbios information for Pine64 RockPro64 board and enable in
config

Signed-off-by: Shantur Rathore 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  Changes
  v4: Change PINE64 to Pine64
  v3: Enable SYSINFO and SYSINFO_SMBIOS in defconfig

  arch/arm/dts/rk3399-rockpro64-u-boot.dtsi | 22 ++
  configs/rockpro64-rk3399_defconfig|  2 ++
  2 files changed, 24 insertions(+)

diff --git a/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi 
b/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi
index 732727d9b0..089732524a 100644
--- a/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi
+++ b/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi
@@ -9,6 +9,28 @@
chosen {
u-boot,spl-boot-order = "same-as-spl", &spi_flash, &sdmmc, 
&sdhci;
};
+
+smbios {
+compatible = "u-boot,sysinfo-smbios";
+smbios {
+system {
+manufacturer = "Pine64";
+product = "RockPro64";
+};
+
+baseboard {
+manufacturer = "Pine64";
+product = "RockPro64";
+};
+
+chassis {
+manufacturer = "Pine64";
+product = "RockPro64";
+};
+};
+};
+
+
  };
  
  &sdhci {

diff --git a/configs/rockpro64-rk3399_defconfig 
b/configs/rockpro64-rk3399_defconfig
index 4cd6b76665..affb6137e0 100644
--- a/configs/rockpro64-rk3399_defconfig
+++ b/configs/rockpro64-rk3399_defconfig
@@ -90,6 +90,8 @@ CONFIG_BAUDRATE=150
  CONFIG_DEBUG_UART_SHIFT=2
  CONFIG_SYS_NS16550_MEM32=y
  CONFIG_ROCKCHIP_SPI=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
  CONFIG_SYSRESET=y
  CONFIG_USB=y
  CONFIG_USB_XHCI_HCD=y


[PATCH V3 7/7] doc: board: anbernic: Update rgxx3 to add new boards

2023-12-11 Thread Chris Morgan
From: Chris Morgan 

Update the RGxx3 documentation to note that it now supports the
RG-ARC-D, RG-ARC-S, Powkiddy RK2023, and Powkiddy RGB30. Also update
verbiage around panel detection to note that it is no longer hard coded
to the RG503.

Signed-off-by: Chris Morgan 
---
 doc/board/anbernic/rgxx3.rst | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/doc/board/anbernic/rgxx3.rst b/doc/board/anbernic/rgxx3.rst
index 7d1beb423c..d159ed2f76 100644
--- a/doc/board/anbernic/rgxx3.rst
+++ b/doc/board/anbernic/rgxx3.rst
@@ -5,6 +5,8 @@ U-Boot for Anbernic RGxx3 Devices
 
 This allows U-Boot to boot the following Anbernic devices:
 
+ - Anbernic RG-ARC-D
+ - Anbernic RG-ARC-S
  - Anbernic RG353M
  - Anbernic RG353P
  - Anbernic RG353PS
@@ -12,18 +14,24 @@ This allows U-Boot to boot the following Anbernic devices:
  - Anbernic RG353VS
  - Anbernic RG503
 
+Additionally, the following very similar non-Anbernic devices are also
+supported:
+
+ - Powkiddy RGB30
+ - Powkiddy RK2023
+
 The correct device is detected automatically by comparing ADC values
 from ADC channel 1. In the event of an RG353V or RG353P, an attempt
 is then made to probe for an eMMC and if it fails the device is assumed
 to be an RG353VS or RG353PS. Based on the detected device, the
 environment variables "board", "board_name", and "fdtfile" are set to
 the correct values corresponding to the board which can be read by a
-boot script to boot with the correct device tree. If the board detected
-is not of type RG503 (which currently has only 1 panel revision) a
-panel detect is then performed by probing a "dummy" display on the DSI
-bus and then querying the display ID. The display ID is then compared
-to a table to get the known compatible string for use in Linux, and
-this string is saved as an environment variable of "panel".
+boot script to boot with the correct device tree. If a board is defined
+as requiring panel detection, a panel detect is then performed by
+probing a "dummy" display on the DSI bus and then querying the display
+ID. The display ID is then compared to a table to get the known
+compatible string for use in Linux, and this string is saved as an
+environment variable of "panel".
 
 FDT fixups are performed in the event of an RG353M to change the device
 name, or in the event the panel detected does not match the devicetree.
-- 
2.34.1



[PATCH V3 5/7] rockchip: board: Add board_rng_seed() for all Rockchip devices

2023-12-11 Thread Chris Morgan
From: Chris Morgan 

Allow all rockchip devices to use the hardware RNG to seed Linux
RNG.

Signed-off-by: Chris Morgan 
---
 arch/arm/mach-rockchip/board.c | 32 ++
 board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c | 29 
 2 files changed, 32 insertions(+), 29 deletions(-)

diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c
index 57f08e0be0..77145524ea 100644
--- a/arch/arm/mach-rockchip/board.c
+++ b/arch/arm/mach-rockchip/board.c
@@ -348,3 +348,35 @@ __weak int misc_init_r(void)
return ret;
 }
 #endif
+
+#if IS_ENABLED(CONFIG_BOARD_RNG_SEED) && IS_ENABLED(CONFIG_RNG_ROCKCHIP)
+#include 
+
+/* Use hardware rng to seed Linux random. */
+__weak int board_rng_seed(struct abuf *buf)
+{
+   struct udevice *dev;
+   size_t len = 0x8;
+   u64 *data;
+
+   data = malloc(len);
+   if (!data) {
+   printf("Out of memory\n");
+   return -ENOMEM;
+   }
+
+   if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) {
+   printf("No RNG device\n");
+   return -ENODEV;
+   }
+
+   if (dm_rng_read(dev, data, len)) {
+   printf("Reading RNG failed\n");
+   return -EIO;
+   }
+
+   abuf_init_set(buf, data, len);
+
+   return 0;
+}
+#endif
diff --git a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c 
b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
index 45854709f5..7bef5a53f0 100644
--- a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
+++ b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
@@ -17,7 +17,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -137,34 +136,6 @@ void spl_board_init(void)
   (GPIO0_BASE + GPIO_SWPORT_DR_H));
 }
 
-/* Use hardware rng to seed Linux random. */
-int board_rng_seed(struct abuf *buf)
-{
-   struct udevice *dev;
-   size_t len = 0x8;
-   u64 *data;
-
-   data = malloc(len);
-   if (!data) {
-   printf("Out of memory\n");
-   return -ENOMEM;
-   }
-
-   if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) {
-   printf("No RNG device\n");
-   return -ENODEV;
-   }
-
-   if (dm_rng_read(dev, data, len)) {
-   printf("Reading RNG failed\n");
-   return -EIO;
-   }
-
-   abuf_init_set(buf, data, len);
-
-   return 0;
-}
-
 /*
  * Buzz the buzzer so the user knows something is going on. Make it
  * optional in case PWM is disabled.
-- 
2.34.1



[PATCH V3 1/7] board: rockchip: Refactor panel auto-detect code

2023-12-11 Thread Chris Morgan
From: Chris Morgan 

Make the inability to detect a panel using the auto detection code not
fail the entire boot process. This means that if the panel ID cannot
be read we don't set an environment variable for the panel, and if an
environment variable for the panel is not set we don't attempt to
update the compatible string. Changes to the code also ensure that
when there are multiple compatible strings required for the panel
we use them both, which solves some issues that will pop up soon
for the Linux driver.

Signed-off-by: Chris Morgan 
---
 board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c | 115 +
 1 file changed, 74 insertions(+), 41 deletions(-)

diff --git a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c 
b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
index 3f1a42d184..3d0c614623 100644
--- a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
+++ b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
@@ -40,6 +40,7 @@ struct rg3xx_model {
const char *board;
const char *board_name;
const char *fdtfile;
+   const bool detect_panel;
 };
 
 enum rgxx3_device_id {
@@ -54,52 +55,67 @@ enum rgxx3_device_id {
 
 static const struct rg3xx_model rg3xx_model_details[] = {
[RG353M] = {
-   517, /* Observed average from device */
-   "rk3566-anbernic-rg353m",
-   "RG353M",
-   DTB_DIR "rk3566-anbernic-rg353p.dtb", /* Identical devices */
+   .adc_value = 517, /* Observed average from device */
+   .board = "rk3566-anbernic-rg353m",
+   .board_name = "RG353M",
+   /* Device is identical to RG353P. */
+   .fdtfile = DTB_DIR "rk3566-anbernic-rg353p.dtb",
+   .detect_panel = 1,
},
[RG353P] = {
-   860, /* Documented value of 860 */
-   "rk3566-anbernic-rg353p",
-   "RG353P",
-   DTB_DIR "rk3566-anbernic-rg353p.dtb",
+   .adc_value = 860, /* Documented value of 860 */
+   .board = "rk3566-anbernic-rg353p",
+   .board_name = "RG353P",
+   .fdtfile = DTB_DIR "rk3566-anbernic-rg353p.dtb",
+   .detect_panel = 1,
},
[RG353V] = {
-   695, /* Observed average from device */
-   "rk3566-anbernic-rg353v",
-   "RG353V",
-   DTB_DIR "rk3566-anbernic-rg353v.dtb",
+   .adc_value = 695, /* Observed average from device */
+   .board = "rk3566-anbernic-rg353v",
+   .board_name = "RG353V",
+   .fdtfile = DTB_DIR "rk3566-anbernic-rg353v.dtb",
+   .detect_panel = 1,
},
[RG503] = {
-   1023, /* Observed average from device */
-   "rk3566-anbernic-rg503",
-   "RG503",
-   DTB_DIR "rk3566-anbernic-rg503.dtb",
+   .adc_value = 1023, /* Observed average from device */
+   .board = "rk3566-anbernic-rg503",
+   .board_name = "RG503",
+   .fdtfile = DTB_DIR "rk3566-anbernic-rg503.dtb",
+   .detect_panel = 0,
},
/* Devices with duplicate ADC value */
[RG353PS] = {
-   860, /* Observed average from device */
-   "rk3566-anbernic-rg353ps",
-   "RG353PS",
-   DTB_DIR "rk3566-anbernic-rg353ps.dtb",
+   .adc_value = 860, /* Observed average from device */
+   .board = "rk3566-anbernic-rg353ps",
+   .board_name = "RG353PS",
+   .fdtfile = DTB_DIR "rk3566-anbernic-rg353ps.dtb",
+   .detect_panel = 1,
},
[RG353VS] = {
-   695, /* Gathered from second hand information */
-   "rk3566-anbernic-rg353vs",
-   "RG353VS",
-   DTB_DIR "rk3566-anbernic-rg353vs.dtb",
+   .adc_value = 695, /* Gathered from second hand information */
+   .board = "rk3566-anbernic-rg353vs",
+   .board_name = "RG353VS",
+   .fdtfile = DTB_DIR "rk3566-anbernic-rg353vs.dtb",
+   .detect_panel = 1,
},
 };
 
 struct rg353_panel {
const u16 id;
-   const char *panel_compat;
+   const char *panel_compat[2];
 };
 
 static const struct rg353_panel rg353_panel_details[] = {
-   { .id = 0x3052, .panel_compat = "newvision,nv3051d"},
-   { .id = 0x3821, .panel_compat = "anbernic,rg353v-panel-v2"},
+   {
+   .id = 0x3052,
+   .panel_compat[0] = "anbernic,rg353p-panel",
+   .panel_compat[1] = "newvision,nv3051d",
+   },
+   {
+   .id = 0x3821,
+   .panel_compat[0] = "anbernic,rg353v-panel-v2",
+   .panel_compat[1] = NULL,
+   },
 };
 
 /*
@@ -298,11 +314,10 @@ int rgxx3_detect_display(void)
if (!panel) {
printf("Unable to identify panel_id %x\n",
   (panel_id[0] << 8) | panel_

[PATCH V3 6/7] board: rockchip: Add support for new boards to RGxx3

2023-12-11 Thread Chris Morgan
From: Chris Morgan 

Add support for the Anbernic RG-ARC-D, Anbernic RG-ARC-S, Powkiddy
RK2023, and Powkiddy RGB30 to the Anbernic RGxx3. While the Powkiddy
devices are manufactured by Powkiddy instead of Anbernic,
the hardware is so similar they can all use the same bootloader.

Signed-off-by: Chris Morgan 
---
 board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c | 44 +++---
 1 file changed, 39 insertions(+), 5 deletions(-)

diff --git a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c 
b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
index 7bef5a53f0..2445663d43 100644
--- a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
+++ b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
@@ -48,9 +48,13 @@ enum rgxx3_device_id {
RG353P,
RG353V,
RG503,
+   RGB30,
+   RK2023,
+   RGARCD,
/* Devices with duplicate ADC value */
RG353PS,
RG353VS,
+   RGARCS,
 };
 
 static const struct rg3xx_model rg3xx_model_details[] = {
@@ -83,6 +87,27 @@ static const struct rg3xx_model rg3xx_model_details[] = {
.fdtfile = DTB_DIR "rk3566-anbernic-rg503.dtb",
.detect_panel = 0,
},
+   [RGB30] = {
+   .adc_value = 383, /* Gathered from second hand information */
+   .board = "rk3566-powkiddy-rgb30",
+   .board_name = "RGB30",
+   .fdtfile = DTB_DIR "rk3566-powkiddy-rgb30.dtb",
+   .detect_panel = 0,
+   },
+   [RK2023] = {
+   .adc_value = 635, /* Observed average from device */
+   .board = "rk3566-powkiddy-rk2023",
+   .board_name = "RK2023",
+   .fdtfile = DTB_DIR "rk3566-powkiddy-rk2023.dtb",
+   .detect_panel = 0,
+   },
+   [RGARCD] = {
+   .adc_value = 183, /* Observed average from device */
+   .board = "rk3566-anbernic-rg-arc-d",
+   .board_name = "Anbernic RG ARC-D",
+   .fdtfile = DTB_DIR "rk3566-anbernic-rg-arc-d.dtb",
+   .detect_panel = 0,
+   },
/* Devices with duplicate ADC value */
[RG353PS] = {
.adc_value = 860, /* Observed average from device */
@@ -98,6 +123,13 @@ static const struct rg3xx_model rg3xx_model_details[] = {
.fdtfile = DTB_DIR "rk3566-anbernic-rg353vs.dtb",
.detect_panel = 1,
},
+   [RGARCS] = {
+   .adc_value = 183, /* Observed average from device */
+   .board = "rk3566-anbernic-rg-arc-s",
+   .board_name = "Anbernic RG ARC-S",
+   .fdtfile = DTB_DIR "rk3566-anbernic-rg-arc-s.dtb",
+   .detect_panel = 0,
+   },
 };
 
 struct rg353_panel {
@@ -332,19 +364,21 @@ int rgxx3_detect_device(void)
}
 
/*
-* Try to access the eMMC on an RG353V or RG353P. If it's
-* missing, it's an RG353VS or RG353PS. Note we could also
-* check for a touchscreen at 0x1a on i2c2.
+* Try to access the eMMC on an RG353V, RG353P, or RG Arc D.
+* If it's missing, it's an RG353VS, RG353PS, or RG Arc S.
+* Note we could also check for a touchscreen at 0x1a on i2c2.
 */
-   if (board_id == RG353V || board_id == RG353P) {
+   if (board_id == RG353V || board_id == RG353P || board_id == RGARCD) {
mmc = find_mmc_device(0);
if (mmc) {
ret = mmc_init(mmc);
if (ret) {
if (board_id == RG353V)
board_id = RG353VS;
-   else
+   if (board_id == RG353P)
board_id = RG353PS;
+   else
+   board_id = RGARCS;
}
}
}
-- 
2.34.1



[PATCH V3 4/7] board: rockchip: Add Recovery Button for Anbernic RGxx3

2023-12-11 Thread Chris Morgan
From: Chris Morgan 

Add support for users to enter recovery mode by holding the function
button when they power up the device.

Since the device has soldered eMMC and sometimes does not expose a clk
pin on the mainboard there is a small chance that a user who flashes a
bad bootloader may not be able to recover if the headers themselves
are valid. As a result this check is done during spl_early_init() to
ensure that it runs as early as possible, and it does so by directly
manipulating the ADC hardware in lieu of loading the ADC driver.

Signed-off-by: Chris Morgan 
---
 arch/arm/dts/rk3566-anbernic-rgxx3-u-boot.dtsi | 11 +++
 board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c |  6 +-
 configs/anbernic-rgxx3-rk3566_defconfig| 16 
 include/configs/anbernic-rgxx3-rk3566.h|  2 ++
 4 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/arch/arm/dts/rk3566-anbernic-rgxx3-u-boot.dtsi 
b/arch/arm/dts/rk3566-anbernic-rgxx3-u-boot.dtsi
index f986e1941e..e3ab196d22 100644
--- a/arch/arm/dts/rk3566-anbernic-rgxx3-u-boot.dtsi
+++ b/arch/arm/dts/rk3566-anbernic-rgxx3-u-boot.dtsi
@@ -76,6 +76,12 @@
/delete-property/ clock-names;
 };
 
+&saradc {
+   bootph-all;
+   vref-supply = <&vcc_sys>;
+   status = "okay";
+};
+
 &sdhci {
pinctrl-0 = <&emmc_bus8>, <&emmc_clk>, <&emmc_cmd>,
<&emmc_datastrobe>, <&emmc_rstnout>;
@@ -94,3 +100,8 @@
bootph-all;
status = "okay";
 };
+
+&vcc_sys {
+   bootph-all;
+   status = "okay";
+};
diff --git a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c 
b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
index 3d0c614623..45854709f5 100644
--- a/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
+++ b/board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -119,11 +120,14 @@ static const struct rg353_panel rg353_panel_details[] = {
 };
 
 /*
- * Start LED very early so user knows device is on. Set color
+ * Check if rockchip_dnl button is pressed and reboot into rockusb if
+ * true. Start LED very early so user knows device is on. Set color
  * to red.
  */
 void spl_board_init(void)
 {
+   setup_boot_mode();
+
/* Set GPIO0_C5, GPIO0_C6, and GPIO0_C7 to output. */
writel(GPIO_WRITEMASK(GPIO_C7 | GPIO_C6 | GPIO_C5) | \
   (GPIO_C7 | GPIO_C6 | GPIO_C5),
diff --git a/configs/anbernic-rgxx3-rk3566_defconfig 
b/configs/anbernic-rgxx3-rk3566_defconfig
index ed6643d9d4..4e72f75815 100644
--- a/configs/anbernic-rgxx3-rk3566_defconfig
+++ b/configs/anbernic-rgxx3-rk3566_defconfig
@@ -3,6 +3,7 @@ CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_COUNTER_FREQUENCY=2400
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_TEXT_BASE=0x00a0
+CONFIG_SPL_GPIO=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=2
@@ -24,7 +25,9 @@ CONFIG_SYS_LOAD_ADDR=0xc00800
 CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_SPL_FIT_SIGNATURE=y
 CONFIG_SPL_LOAD_FIT=y
+CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
 CONFIG_DEFAULT_FDT_FILE="rockchip/rk3566-anbernic-rgxx3.dtb"
@@ -32,7 +35,7 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3566-anbernic-rgxx3.dtb"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_BOARD_RNG_SEED=y
-CONFIG_SPL_MAX_SIZE=0x2
+CONFIG_SPL_MAX_SIZE=0x4
 CONFIG_SPL_PAD_TO=0x7f8000
 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x400
@@ -41,6 +44,8 @@ CONFIG_SPL_BOARD_INIT=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
 # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
 CONFIG_SPL_STACK_R=y
+CONFIG_SPL_ADC=y
+CONFIG_SPL_POWER=y
 CONFIG_SPL_ATF=y
 CONFIG_CMD_PWM=y
 CONFIG_CMD_GPT=y
@@ -50,8 +55,10 @@ CONFIG_CMD_MMC=y
 # CONFIG_SPL_DOS_PARTITION is not set
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_LIVE=y
+CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks 
assigned-clock-rates assigned-clock-parents"
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 # CONFIG_NET is not set
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_REGMAP=y
 CONFIG_SPL_SYSCON=y
 CONFIG_SPL_CLK=y
@@ -67,13 +74,13 @@ CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_SDMA=y
 CONFIG_MMC_SDHCI_ROCKCHIP=y
 CONFIG_PHY_ROCKCHIP_INNO_DSIDPHY=y
+CONFIG_SPL_PINCTRL=y
 CONFIG_DM_PMIC=y
 CONFIG_DM_PMIC_FAN53555=y
 CONFIG_PMIC_RK8XX=y
-CONFIG_REGULATOR_PWM=y
-CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_SPL_DM_REGULATOR=y
+CONFIG_SPL_DM_REGULATOR_FIXED=y
 CONFIG_REGULATOR_RK8XX=y
-CONFIG_DM_REGULATOR_SCMI=y
 CONFIG_PWM_ROCKCHIP=y
 CONFIG_SPL_RAM=y
 # CONFIG_RAM_ROCKCHIP_DEBUG is not set
@@ -89,5 +96,6 @@ CONFIG_VIDEO_ROCKCHIP=y
 CONFIG_DISPLAY_ROCKCHIP_DW_MIPI=y
 CONFIG_VIDEO_BRIDGE=y
 CONFIG_REGEX=y
+# CONFIG_RSA is not set
 CONFIG_ERRNO_STR=y
 # CONFIG_EFI_LOADER is not set
diff --git a/include/configs/anbernic-rgxx3-rk3566.h 
b/include/configs/anbernic-rgxx3-rk3566.h
index 3c4ea4e7d8..2aaac55c06 100644
--- a/include/configs/anbernic-rgxx3-rk3566.h
+++ b/include/config

[PATCH V3 3/7] rockchip: boot_mode: Allow rockchip_dnl_key_pressed() in SPL

2023-12-11 Thread Chris Morgan
From: Chris Morgan 

Update the rockchip_dnl_key_pressed() so that it can run in
SPL. Also change the ADC channel to a define that can be
overridden by a board specific option.

Signed-off-by: Chris Morgan 
---
 arch/arm/mach-rockchip/Makefile|  4 ++--
 arch/arm/mach-rockchip/boot_mode.c | 11 ++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile
index 1dc92066bb..ff089ae949 100644
--- a/arch/arm/mach-rockchip/Makefile
+++ b/arch/arm/mach-rockchip/Makefile
@@ -15,13 +15,13 @@ obj-tpl-$(CONFIG_ROCKCHIP_PX30) += px30-board-tpl.o
 
 obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
 
-ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
-
 # Always include boot_mode.o, as we bypass it (i.e. turn it off)
 # inside of boot_mode.c when CONFIG_ROCKCHIP_BOOT_MODE_REG is 0.  This way,
 # we can have the preprocessor correctly recognise both 0x0 and 0
 # meaning "turn it off".
 obj-y += boot_mode.o
+
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
 obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o
 obj-$(CONFIG_MISC_INIT_R) += misc.o
 endif
diff --git a/arch/arm/mach-rockchip/boot_mode.c 
b/arch/arm/mach-rockchip/boot_mode.c
index eb8f65ae4e..d2308768be 100644
--- a/arch/arm/mach-rockchip/boot_mode.c
+++ b/arch/arm/mach-rockchip/boot_mode.c
@@ -38,6 +38,10 @@ void set_back_to_bootrom_dnl_flag(void)
 #define KEY_DOWN_MIN_VAL   0
 #define KEY_DOWN_MAX_VAL   30
 
+#ifndef RK_DNL_ADC_CHAN
+#define RK_DNL_ADC_CHAN1
+#endif
+
 __weak int rockchip_dnl_key_pressed(void)
 {
unsigned int val;
@@ -52,7 +56,8 @@ __weak int rockchip_dnl_key_pressed(void)
ret = -ENODEV;
uclass_foreach_dev(dev, uc) {
if (!strncmp(dev->name, "saradc", 6)) {
-   ret = adc_channel_single_shot(dev->name, 1, &val);
+   ret = adc_channel_single_shot(dev->name,
+ RK_DNL_ADC_CHAN, &val);
break;
}
}
@@ -73,11 +78,13 @@ __weak int rockchip_dnl_key_pressed(void)
 
 void rockchip_dnl_mode_check(void)
 {
+#if CONFIG_IS_ENABLED(ADC)
if (rockchip_dnl_key_pressed()) {
printf("download key pressed, entering download mode...");
set_back_to_bootrom_dnl_flag();
do_reset(NULL, 0, 0, NULL);
}
+#endif
 }
 
 int setup_boot_mode(void)
@@ -90,6 +97,7 @@ int setup_boot_mode(void)
boot_mode = readl(reg);
debug("%s: boot mode 0x%08x\n", __func__, boot_mode);
 
+#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
/* Clear boot mode */
writel(BOOT_NORMAL, reg);
 
@@ -103,6 +111,7 @@ int setup_boot_mode(void)
env_set("preboot", "setenv preboot; ums mmc 0");
break;
}
+#endif
 
return 0;
 }
-- 
2.34.1



[PATCH V3 2/7] spl: Add Kconfig options for ADC

2023-12-11 Thread Chris Morgan
From: Chris Morgan 

Add kconfig options to enable ADC in SPL

Signed-off-by: Chris Morgan 
---
 common/spl/Kconfig   | 7 +++
 drivers/Makefile | 1 +
 drivers/adc/Makefile | 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index c521b02f4a..ada9dcea5c 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -579,6 +579,13 @@ config SPL_FIT_IMAGE_TINY
  ensure this information is available to the next image
  invoked).
 
+config SPL_ADC
+   bool "Support ADC drivers"
+   help
+ Enable ADC drivers in SPL. These drivers can allow the reading of
+ analog values from one or more channels. Enable this option to
+ build the drivers in drivers/adc as part of an SPL build.
+
 config SPL_CACHE
bool "Support CACHE drivers"
help
diff --git a/drivers/Makefile b/drivers/Makefile
index bf73b7718c..81ba2c534e 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0+
 
+obj-$(CONFIG_$(SPL_)ADC) += adc/
 obj-$(CONFIG_$(SPL_TPL_)BIOSEMU) += bios_emulator/
 obj-$(CONFIG_$(SPL_TPL_)BLK) += block/
 obj-$(CONFIG_$(SPL_TPL_)BOOTCOUNT_LIMIT) += bootcount/
diff --git a/drivers/adc/Makefile b/drivers/adc/Makefile
index 5336c82097..9eb07769b0 100644
--- a/drivers/adc/Makefile
+++ b/drivers/adc/Makefile
@@ -4,7 +4,7 @@
 # Przemyslaw Marczak 
 #
 
-obj-$(CONFIG_ADC) += adc-uclass.o
+obj-$(CONFIG_$(SPL_)ADC) += adc-uclass.o
 obj-$(CONFIG_ADC_EXYNOS) += exynos-adc.o
 obj-$(CONFIG_ADC_SANDBOX) += sandbox.o
 obj-$(CONFIG_SARADC_ROCKCHIP) += rockchip-saradc.o
-- 
2.34.1



[PATCH V3 0/7] Add Additional Boards and Features to RGxx3

2023-12-11 Thread Chris Morgan
From: Chris Morgan 

The RGxx3 is a pseudo-device for U-Boot that works for every Anbernic
RGxx3 series device on the market. Add support for another series of
very similar devices from Powkiddy.

Changes since V2:
 - Modify the mach-rockchip level rockchip_dnl_key_pressed() so that
   we can also call it in SPL mode and eliminate the board specific
   function. This requires adding ADC support to SPL. Additionally,
   I had to change the regulator for the saradc to a fixed regulator
   and add GPIO and regulator support to SPL.
 - Move the board specific board_rng_seed to the mach-rockchip level
   board file so that other rockchip boards with a hardware RNG can
   benefit. This should only be called if both the Rockchip
   hardware RNG as well as the rng seed functions are enabled.
 - Add two new boards (the RG-ARC-D and RG-ARC-S). I removed the
   previous code review due to the extensive changes made.

Changes since V1:
 - Update verbiage around function button to say "recovery" mode
   instead of calling it "maskrom" mode, which has a specific
   meaning. Also note that recovery function was done in a board
   specific manner to ensure it can run early.
 - Update board level documentation for the RGxx3.

Chris Morgan (7):
  board: rockchip: Refactor panel auto-detect code
  spl: Add Kconfig options for ADC
  rockchip: boot_mode: Allow rockchip_dnl_key_pressed() in SPL
  board: rockchip: Add Recovery Button for Anbernic RGxx3
  rockchip: board: Add board_rng_seed() for all Rockchip devices
  board: rockchip: Add support for new boards to RGxx3
  doc: board: anbernic: Update rgxx3 to add new boards

 .../arm/dts/rk3566-anbernic-rgxx3-u-boot.dtsi |  11 +
 arch/arm/mach-rockchip/Makefile   |   4 +-
 arch/arm/mach-rockchip/board.c|  32 +++
 arch/arm/mach-rockchip/boot_mode.c|  11 +-
 board/anbernic/rgxx3_rk3566/rgxx3-rk3566.c| 194 +++---
 common/spl/Kconfig|   7 +
 configs/anbernic-rgxx3-rk3566_defconfig   |  16 +-
 doc/board/anbernic/rgxx3.rst  |  20 +-
 drivers/Makefile  |   1 +
 drivers/adc/Makefile  |   2 +-
 include/configs/anbernic-rgxx3-rk3566.h   |   2 +
 11 files changed, 210 insertions(+), 90 deletions(-)

-- 
2.34.1



[PATCH v3 6/6] board: stm32f469-disco: add splash screen with stmicroelectronics logo

2023-12-11 Thread Dario Binacchi
Display the STMicroelectronics logo with features VIDEO_LOGO and
SPLASH_SCREEN on stm32f469-disco board.

Signed-off-by: Dario Binacchi 
Reviewed-by: Patrice Chotard 

---

Changes in v3:
- Add Patrice Chotard's Reviewed-by tag.
- Remove RFC tag
- Split "[4/5] ARM: dts: stm32: support display on stm32f469-disco board"
  patch in 2 parts:
  - DTS ([4/6] ARM: dts: stm32: support MIPI DSI on stm32f469-disco board)
  - config and LTDC driver update ([5/6] board: stm32f469-disco: add support to 
display)

Changes in v2:
- Add Patrice Chotard's Reviewed-by tag to patches 1, 2 and 3 of the series.
- Fix frame buffer allocation for stm32f469 discovery board.

 configs/stm32f469-discovery_defconfig |   3 +++
 include/configs/stm32f469-discovery.h |   2 ++
 tools/logos/stm32f469-discovery.bmp   | Bin 0 -> 18532 bytes
 3 files changed, 5 insertions(+)
 create mode 100644 tools/logos/stm32f469-discovery.bmp

diff --git a/configs/stm32f469-discovery_defconfig 
b/configs/stm32f469-discovery_defconfig
index 85e795e83e7d..b7e35aeae200 100644
--- a/configs/stm32f469-discovery_defconfig
+++ b/configs/stm32f469-discovery_defconfig
@@ -42,12 +42,15 @@ CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_STM32_QSPI=y
 CONFIG_VIDEO=y
+CONFIG_VIDEO_LOGO=y
 CONFIG_BACKLIGHT_GPIO=y
 CONFIG_VIDEO_LCD_ORISETECH_OTM8009A=y
 CONFIG_VIDEO_STM32=y
 CONFIG_VIDEO_STM32_DSI=y
 CONFIG_VIDEO_STM32_MAX_XRES=480
 CONFIG_VIDEO_STM32_MAX_YRES=800
+CONFIG_SPLASH_SCREEN=y
+CONFIG_SPLASH_SCREEN_ALIGN=y
 CONFIG_BMP_16BPP=y
 CONFIG_BMP_24BPP=y
 CONFIG_BMP_32BPP=y
diff --git a/include/configs/stm32f469-discovery.h 
b/include/configs/stm32f469-discovery.h
index 62a7e9af0c56..75bb9cd8d06f 100644
--- a/include/configs/stm32f469-discovery.h
+++ b/include/configs/stm32f469-discovery.h
@@ -31,6 +31,8 @@
"scriptaddr=0x00418000\0"   \
"pxefile_addr_r=0x00428000\0" \
"ramdisk_addr_r=0x00438000\0"   \
+   "splashimage=0x00448000\0" \
+   "splashpos=m,m\0" \
BOOTENV
 
 #endif /* __CONFIG_H */
diff --git a/tools/logos/stm32f469-discovery.bmp 
b/tools/logos/stm32f469-discovery.bmp
new file mode 100644
index 
..ecc8d984218fb13fddf0ba9cf68f2cfad829e289
GIT binary patch
literal 18532
zcmeI4cXZX&w(r;65wa7qNk~Y5gbqmv5Fw!j5+O7xl9*5>^j-qed+)tS@6wBaRB3{M
zG^rvTq<29PJ?imP-e<18^`MV)eL3Teaql13aUl7vHRoJ&eP>
z%wT@IEylFuj~FL^jJa0Tn0Xc4f9!w`nis$P&puSCQMcE$Pk$_ux+`yR-Z4+5RH;%y
z?c2AH;7{iH^XL1#;d|MuNYiPtO8m=zEccuLUc7i=rj8tL{`t>;n(v=~XLfJfVn+4u
zWiDU5VCn>CGXMC;KTO@od?q<8o7uN>r}_EkpUhwX`d8EO?IiP$zyIB&6v$~VpTA)K
z_P4*8AHM&S`O9DaV*d2q_oiOaLS|rxcIM{w>!w$Wrlvu35%ZUye>UrvFE{t^-Zg)P
zu4|(P=Bvk#%nv{OV3y6BV{UwT&0M>3*|d4Hs`=*YZ%mJ-Y39#A{bas<_O1Ey>Q&RP
zO)GQh+&R-IrnuR+YlrF5u%3B;_H5I#N+t8>KmXYbN$+HyeD#$X(7vtNw04a-@bSkc
zEiTr4{p6{6_RTZXA*r_c```a&K0k57tX#0boIQDx=f9h;pFTAUr%yA-4<9zSZd^A#
zn>8_KPn|OBmM%5z-l}0brY4(K)e_Cog9pvV)vLhZXVbP;b#wjNHPftO9Bcn*zBql_
z^l8;&iusQ
zKHawu`se1{nKNem!2V`f*DmJAKmB07`|ew_XZv<@>a)+xl}i`Rkpl-z|F*5oiuvD!_Z!@-kU-KM2hjvLfy<0Xjj~+fS5AWYMTi1VJ9zT3&x}`M&^DAce
zmaS&W@L}fO-8*L4+&O0T;)Uk${{3d@oZ0N}p;@zdu{nMGxVd!Uym|WMiP^qkqglCd
zp&8k$r#b)m=jP6>o95ydUzlwh*PB5d+ncrTzi(D8T42Tv=x06y?;n5s(QH}2&P*FM
z!aTTt&)mIz%Y1g|koo56*XH)k8)o5q)6FNlcA1SUSDGWN`@ynh=>5!`Vo#HX3^sEo
zO~h}$G)rdAH1nrUF(;26H6MMr(JY$r9{6p=X8X;$m_wF$t
zu2~IkpP0?-)|v@}2C#=?tasBqxOWd9dW`O8&5W_5&BVd1F?o`iK6<3tuxh3Gbnjm5
ze$_0WH_u!=f6hF7aNk@wd)7R9@W33{vj?6rX7aG1=GdWwX6CrDX34BsX7+^f=EAuz
z%txCxn*Dornc>~KniEG4n-M*_ne{7Im@)nOn8h<@n4Oz8n>9<8m|a^po6qshJ7BSG
z!+K)mv6(bHu|NHm1N?G|rg1=+_hC$M4*(N>?Z)qs`WFc~HNu<1h8)4r5cqQCcOoNHmft
z!SJ|bn0TqQBqQgfW9B!dl01}Z(%xaDvV1C)7+-FP5(hno6C2M!N^zw5!|Bf+KmSGQYr5wml9QdhiLQazp*)o9kHmS-K0R0+a~L!mZPzhapj|iFFKZ>4DDjmcG7H=Fw|E4xehEA`
zhFupB2M7g91<)ETPcy40T?B_}j77jTkm#r+eqc3N)_}ND#1WB4L3}&9TL&?5`{;a1-R_(?nb={4f^7G5{aW0~=9MD_}`GUD;j8sIn^Uvsk0K;rbWq&R$;jgb?wQ64h88L!ot
z$xa>|futPlH7_ftAw7U>SeRY+hVCG7;6hI)KK+^Mi3ZVfTPCt|nmHj0@o~7Bdr?f-%FygkJ_@IX`qa%oc_HdO4*MSn^>rEct4c_;e3t@#k
z9!%?^>r`@eDYO|*{BI@Cp9R~uWiR7ZWDeuG-TSMBm5wR4pV7WW{+le^tf81EEUAoBgoFF^OZow!9wL*;>@Jh`9=&jDavhdt~EL_U}uLU(C!FnZ`aG;8=h>swmz^k>Q;*wX5Yap
z-SJk`#z+~(9E*0466|e=jkjvhwIQ}$?9PwKZpd>9{HChpL8ce}Qxudh+sF^Wrw>aa
zlxo#ttW)o$C{&-x@lq64;n^2C1wg=y3LK8)9C-XucJ5_y8$~5uAWMiB_2A}Gn)q%&
zg(?B%Q=*|R^==rH!Q|;Jc=lRp0tP;Kn~l>H!`#Qvo?=f$z$gGYpYVG#_T~$Quj4Oo
z3IT@CUShnPT(I%kkbSmitq&!HtXrM>6H6>PSUWegA$ZYOHYyXycn3u@=P&k&!slzT
zN(?_|vabpt(u;X(7h=c3$Yq|-$Qss;z&4?1oKZWxVf!Y{4qi4U_E@c>!Ej_ov1gY{
zsdEF-Ie@zHmb63b1bIXDu+wBBC=jn}$Furw0A5m8{8+Oz)<|I=FJm1n>)_c3j)ST0
z|H3+x#X1WsIk41J0cE^DE^Fc%LBBv>)^*W)?E{7#e?QUHEU6
zm#`iwnQR|CN6Mp-KQVahC8V*u_32O|vAgXZA{ZG6MTXEOmXd5=98MLa?y^z>`Fg8e
zIiC9CfFeWQ&OYM1(CS{J2WP~ref73#=Ou%
z{d>$xL9cn
z6;ks|#t;lSjl>G8t1A+vRR<`%$32W##;~{x{Zsf*l0Qde*+es1wu<%LhEUQClIm`Mrj?(90#)
z`8}hUowKWErI*bt-TZP=D_1(YqtlrG$nW-(jkFgXjd!W6iR7G#SbG@K{H24<_4TAE
zJ9Mz$jAA&(X1Y*NtS%#5x#&pK`EwAT^9R8^+@pjdH38{S#HscvZv29zGssM(LMeW$
zWjs%A{2s|-ejgoRmhxKB5Euk#V2<*yf#@^pT6RB8gm3
z(DvSVFf}|GUt2CK(XvK

[PATCH v3 5/6] board: stm32f469-disco: add support to display

2023-12-11 Thread Dario Binacchi
Add support to Orise Tech OTM8009A display on stm32f469-disco board.

It was necessary to retrieve the framebuffer address from the device tree
because the address returned by the video-uclass driver pointed to a memory
area that was not usable.

Signed-off-by: Dario Binacchi 
---

Changes in v3:
- Replace SDRAM_SIZE constant with global data gd->ram_size.

Changes in v2:
- Add DRAM_SIZE macro.
- Fix frame buffer allocation function so that it is backward compatible
  with boards other than the one it was introduced for (i. e. stm32f469-disco).
  Tested on stm32f469-disco and stm32mp157f-dk2 boards.

 configs/stm32f469-discovery_defconfig | 13 +++
 drivers/video/stm32/stm32_ltdc.c  | 31 +++
 2 files changed, 44 insertions(+)

diff --git a/configs/stm32f469-discovery_defconfig 
b/configs/stm32f469-discovery_defconfig
index 21c5498466cd..85e795e83e7d 100644
--- a/configs/stm32f469-discovery_defconfig
+++ b/configs/stm32f469-discovery_defconfig
@@ -21,6 +21,7 @@ CONFIG_CMD_GPT=y
 # CONFIG_RANDOM_UUID is not set
 CONFIG_CMD_MMC=y
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_BMP=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIMER=y
 # CONFIG_ISO_PARTITION is not set
@@ -40,3 +41,15 @@ CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_STM32_QSPI=y
+CONFIG_VIDEO=y
+CONFIG_BACKLIGHT_GPIO=y
+CONFIG_VIDEO_LCD_ORISETECH_OTM8009A=y
+CONFIG_VIDEO_STM32=y
+CONFIG_VIDEO_STM32_DSI=y
+CONFIG_VIDEO_STM32_MAX_XRES=480
+CONFIG_VIDEO_STM32_MAX_YRES=800
+CONFIG_BMP_16BPP=y
+CONFIG_BMP_24BPP=y
+CONFIG_BMP_32BPP=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
diff --git a/drivers/video/stm32/stm32_ltdc.c b/drivers/video/stm32/stm32_ltdc.c
index 6fd90e33919d..4f60ba8ebeeb 100644
--- a/drivers/video/stm32/stm32_ltdc.c
+++ b/drivers/video/stm32/stm32_ltdc.c
@@ -495,6 +495,33 @@ static void stm32_ltdc_set_layer1(struct stm32_ltdc_priv 
*priv, ulong fb_addr)
setbits_le32(priv->regs + LTDC_L1CR, LXCR_LEN);
 }
 
+#if IS_ENABLED(CONFIG_TARGET_STM32F469_DISCOVERY)
+static int stm32_ltdc_alloc_fb(struct udevice *dev)
+{
+   u32 sdram_size = gd->ram_size;
+   struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
+   phys_addr_t cpu;
+   dma_addr_t bus;
+   u64 dma_size;
+   int ret;
+
+   ret = dev_get_dma_range(dev, &cpu, &bus, &dma_size);
+   if (ret) {
+   dev_err(dev, "failed to get dma address\n");
+   return ret;
+   }
+
+   uc_plat->base = bus + sdram_size - ALIGN(uc_plat->size, uc_plat->align);
+   return 0;
+}
+#else
+static inline int stm32_ltdc_alloc_fb(struct udevice *dev)
+{
+   /* Delegate framebuffer allocation to video-uclass */
+   return 0;
+}
+#endif
+
 static int stm32_ltdc_probe(struct udevice *dev)
 {
struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
@@ -605,6 +632,10 @@ static int stm32_ltdc_probe(struct udevice *dev)
priv->crop_h = timings.vactive.typ;
priv->alpha = 0xFF;
 
+   ret = stm32_ltdc_alloc_fb(dev);
+   if (ret)
+   return ret;
+
dev_dbg(dev, "%dx%d %dbpp frame buffer at 0x%lx\n",
timings.hactive.typ, timings.vactive.typ,
VNBITS(priv->l2bpp), uc_plat->base);
-- 
2.43.0



[PATCH v3 4/6] ARM: dts: stm32: support MIPI DSI on stm32f469-disco board

2023-12-11 Thread Dario Binacchi
Unlike Linux, the DSI driver requires the LTDC clock to be properly
probed. Hence, the changes made to the DSI node.

Signed-off-by: Dario Binacchi 
---

(no changes since v1)

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

diff --git a/arch/arm/dts/stm32f469-disco-u-boot.dtsi 
b/arch/arm/dts/stm32f469-disco-u-boot.dtsi
index 8e781c5a7b23..47ba9fa4a783 100644
--- a/arch/arm/dts/stm32f469-disco-u-boot.dtsi
+++ b/arch/arm/dts/stm32f469-disco-u-boot.dtsi
@@ -92,7 +92,9 @@
 
 &dsi {
clocks = <&rcc 0 STM32F4_APB2_CLOCK(DSI)>,
+<&rcc 0 STM32F4_APB2_CLOCK(LTDC)>,
 <&clk_hse>;
+   clock-names = "pclk", "px_clk", "ref";
 };
 
 &gpioa {
@@ -140,6 +142,8 @@
 };
 
 ;
 };
 
-- 
2.43.0



[PATCH v3 3/6] ARM: dts: stm32: make the DSI clock usable by the clock driver

2023-12-11 Thread Dario Binacchi
As described in [1], the "clocks" property contains "a phandle to the
clock device node, an index selecting between gated clocks (0) and other
clocks (1), and an index specifying the clock to use." The current version
of the clock driver, unlike the kernel, is currently able to properly
handle nodes with "clocks" properties with an index set to 0.

This patch is preparatory for future developments that require the use
of the DSI clock.

[1] Documentation/devicetree/bindings/clock/st,stm32-rcc.txt
Signed-off-by: Dario Binacchi 
Reviewed-by: Patrice Chotard 

---

(no changes since v2)

Changes in v2:
- Add Patrice Chotard's Reviewed-by tag.

 arch/arm/dts/stm32f469-disco-u-boot.dtsi | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/dts/stm32f469-disco-u-boot.dtsi 
b/arch/arm/dts/stm32f469-disco-u-boot.dtsi
index dcc70369cd0d..8e781c5a7b23 100644
--- a/arch/arm/dts/stm32f469-disco-u-boot.dtsi
+++ b/arch/arm/dts/stm32f469-disco-u-boot.dtsi
@@ -90,6 +90,11 @@
bootph-all;
 };
 
+&dsi {
+   clocks = <&rcc 0 STM32F4_APB2_CLOCK(DSI)>,
+<&clk_hse>;
+};
+
 &gpioa {
bootph-all;
 };
-- 
2.43.0



[PATCH v3 2/6] ARM: dts: stm32: make the LTDC clock usable by the clock driver

2023-12-11 Thread Dario Binacchi
As described in [1], the "clocks" property contains "a phandle to the
clock device node, an index selecting between gated clocks (0) and other
clocks (1), and an index specifying the clock to use." The current version
of the clock driver, unlike the kernel, is currently able to properly
handle nodes with "clocks" properties with an index set to 0.

This patch is preparatory for future developments that require the use
of the LTDC clock.

[1] Documentation/devicetree/bindings/clock/st,stm32-rcc.txt
Signed-off-by: Dario Binacchi 
Reviewed-by: Patrice Chotard 

---

(no changes since v2)

Changes in v2:
- Add Patrice Chotard's Reviewed-by tag.

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

diff --git a/arch/arm/dts/stm32f469-disco-u-boot.dtsi 
b/arch/arm/dts/stm32f469-disco-u-boot.dtsi
index c07e2022e4a8..dcc70369cd0d 100644
--- a/arch/arm/dts/stm32f469-disco-u-boot.dtsi
+++ b/arch/arm/dts/stm32f469-disco-u-boot.dtsi
@@ -134,6 +134,10 @@
bootph-all;
 };
 
+;
+};
+
 &pinctrl {
bootph-all;
 
-- 
2.43.0



[PATCH v3 1/6] ARM: dts: stm32f469-disco: sync with Linux 6.5

2023-12-11 Thread Dario Binacchi
Sync the devicetree with linux 6.5 for stm32f746-disco board.

Signed-off-by: Dario Binacchi 
Reviewed-by: Patrice Chotard 

---

(no changes since v2)

Changes in v2:
- Add Patrice Chotard's Reviewed-by tag.

 arch/arm/dts/stm32f469-disco.dts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/dts/stm32f469-disco.dts b/arch/arm/dts/stm32f469-disco.dts
index 6e0ffc1903be..c9acabf0f530 100644
--- a/arch/arm/dts/stm32f469-disco.dts
+++ b/arch/arm/dts/stm32f469-disco.dts
@@ -119,7 +119,7 @@
};
};
 
-   panel-dsi@0 {
+   panel@0 {
compatible = "orisetech,otm8009a";
reg = <0>; /* dsi virtual channel (0..3) */
reset-gpios = <&gpioh 7 GPIO_ACTIVE_LOW>;
@@ -138,7 +138,7 @@
status = "okay";
 
port {
-   ltdc_out_dsi: endpoint@0 {
+   ltdc_out_dsi: endpoint {
remote-endpoint = <&dsi_in>;
};
};
-- 
2.43.0



[PATCH v3 0/6] Support display on stm32f469-disco board

2023-12-11 Thread Dario Binacchi
The series adds support for the Orise Tech OTM8009A display on the
stm32f469-disco board. Substantial differences in the drivers for clock
management, LTDC and DSI compared to Linux, made it necessary to modify
the device tree. These changes were made in stm32f469-disco-uboot.dtsi to
avoid altering the Linux device tree. It is therefore desirable, as soon
as possible, to add these drivers the functionalities so that they do not
require device tree properties that deviate from those present in the Linux
version.

Changes in v3:
- Add Patrice Chotard's Reviewed-by tag.
- Remove RFC tag
- Split "[4/5] ARM: dts: stm32: support display on stm32f469-disco board"
  patch in 2 parts:
  - DTS ([4/6] ARM: dts: stm32: support MIPI DSI on stm32f469-disco board)
  - config and LTDC driver update ([5/6] board: stm32f469-disco: add support to 
display)

Changes in v2:
- Add Patrice Chotard's Reviewed-by tag to patches 1, 2 and 3 of the series.
- Fix frame buffer allocation for stm32f469 discovery board.

Dario Binacchi (6):
  ARM: dts: stm32f469-disco: sync with Linux 6.5
  ARM: dts: stm32: make the LTDC clock usable by the clock driver
  ARM: dts: stm32: make the DSI clock usable by the clock driver
  ARM: dts: stm32: support MIPI DSI on stm32f469-disco board
  board: stm32f469-disco: add support to display
  board: stm32f469-disco: add splash screen with stmicroelectronics logo

 arch/arm/dts/stm32f469-disco-u-boot.dtsi |  13 ++
 arch/arm/dts/stm32f469-disco.dts |   4 +--
 configs/stm32f469-discovery_defconfig|  16 
 drivers/video/stm32/stm32_ltdc.c |  31 +++
 include/configs/stm32f469-discovery.h|   2 ++
 tools/logos/stm32f469-discovery.bmp  | Bin 0 -> 18532 bytes
 6 files changed, 64 insertions(+), 2 deletions(-)
 create mode 100644 tools/logos/stm32f469-discovery.bmp

-- 
2.43.0



Re: [PATCH 1/1] clk: imx8mn: add pwm clocks

2023-12-11 Thread Fabio Estevam
Hi Nicolas,

On Mon, Dec 11, 2023 at 1:52 PM Nicolas Heemeryck
 wrote:
>
> Based on Linux kernel 6.7-rc4, add necessary clocks for the PWM
> controllers.
>
> Signed-off-by: Nicolas Heemeryck 

Reviewed-by: Fabio Estevam 


Re: [PATCH v4] arm: dts: rockpro64: Add RockPro64 smbios

2023-12-11 Thread Tom Rini
On Mon, Dec 11, 2023 at 08:42:19PM +, Shantur Rathore wrote:
> Hi,
> 
> On Mon, Nov 13, 2023 at 11:24 AM Shantur Rathore  wrote:
> >
> > Add smbios information for Pine64 RockPro64 board and enable in
> > config
> >
> > Signed-off-by: Shantur Rathore 
> > ---
> >  Changes
> >  v4: Change PINE64 to Pine64
> >  v3: Enable SYSINFO and SYSINFO_SMBIOS in defconfig
> >
> >  arch/arm/dts/rk3399-rockpro64-u-boot.dtsi | 22 ++
> >  configs/rockpro64-rk3399_defconfig|  2 ++
> >  2 files changed, 24 insertions(+)
> >
> > diff --git a/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi 
> > b/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi
> > index 732727d9b0..089732524a 100644
> > --- a/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi
> > +++ b/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi
> > @@ -9,6 +9,28 @@
> > chosen {
> > u-boot,spl-boot-order = "same-as-spl", &spi_flash, &sdmmc, 
> > &sdhci;
> > };
> > +
> > +smbios {
> > +compatible = "u-boot,sysinfo-smbios";
> > +smbios {
> > +system {
> > +manufacturer = "Pine64";
> > +product = "RockPro64";
> > +};
> > +
> > +baseboard {
> > +manufacturer = "Pine64";
> > +product = "RockPro64";
> > +};
> > +
> > +chassis {
> > +manufacturer = "Pine64";
> > +product = "RockPro64";
> > +};
> > +};
> > +};
> > +
> > +
> >  };
> >
> >  &sdhci {
> > diff --git a/configs/rockpro64-rk3399_defconfig 
> > b/configs/rockpro64-rk3399_defconfig
> > index 4cd6b76665..affb6137e0 100644
> > --- a/configs/rockpro64-rk3399_defconfig
> > +++ b/configs/rockpro64-rk3399_defconfig
> > @@ -90,6 +90,8 @@ CONFIG_BAUDRATE=150
> >  CONFIG_DEBUG_UART_SHIFT=2
> >  CONFIG_SYS_NS16550_MEM32=y
> >  CONFIG_ROCKCHIP_SPI=y
> > +CONFIG_SYSINFO=y
> > +CONFIG_SYSINFO_SMBIOS=y
> >  CONFIG_SYSRESET=y
> >  CONFIG_USB=y
> >  CONFIG_USB_XHCI_HCD=y
> > --
> > 2.40.1
> >
> 
> Can this please be merged if no changes are required?
> 
> [0] - 
> https://patchwork.ozlabs.org/project/uboot/patch/20231113112309.730323-...@shantur.com/

Yes, we should just defer this and pickup the SMBIOS series that Ilias
has posted.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v4] arm: dts: rockpro64: Add RockPro64 smbios

2023-12-11 Thread Shantur Rathore
Hi,

On Mon, Nov 13, 2023 at 11:24 AM Shantur Rathore  wrote:
>
> Add smbios information for Pine64 RockPro64 board and enable in
> config
>
> Signed-off-by: Shantur Rathore 
> ---
>  Changes
>  v4: Change PINE64 to Pine64
>  v3: Enable SYSINFO and SYSINFO_SMBIOS in defconfig
>
>  arch/arm/dts/rk3399-rockpro64-u-boot.dtsi | 22 ++
>  configs/rockpro64-rk3399_defconfig|  2 ++
>  2 files changed, 24 insertions(+)
>
> diff --git a/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi 
> b/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi
> index 732727d9b0..089732524a 100644
> --- a/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi
> +++ b/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi
> @@ -9,6 +9,28 @@
> chosen {
> u-boot,spl-boot-order = "same-as-spl", &spi_flash, &sdmmc, 
> &sdhci;
> };
> +
> +smbios {
> +compatible = "u-boot,sysinfo-smbios";
> +smbios {
> +system {
> +manufacturer = "Pine64";
> +product = "RockPro64";
> +};
> +
> +baseboard {
> +manufacturer = "Pine64";
> +product = "RockPro64";
> +};
> +
> +chassis {
> +manufacturer = "Pine64";
> +product = "RockPro64";
> +};
> +};
> +};
> +
> +
>  };
>
>  &sdhci {
> diff --git a/configs/rockpro64-rk3399_defconfig 
> b/configs/rockpro64-rk3399_defconfig
> index 4cd6b76665..affb6137e0 100644
> --- a/configs/rockpro64-rk3399_defconfig
> +++ b/configs/rockpro64-rk3399_defconfig
> @@ -90,6 +90,8 @@ CONFIG_BAUDRATE=150
>  CONFIG_DEBUG_UART_SHIFT=2
>  CONFIG_SYS_NS16550_MEM32=y
>  CONFIG_ROCKCHIP_SPI=y
> +CONFIG_SYSINFO=y
> +CONFIG_SYSINFO_SMBIOS=y
>  CONFIG_SYSRESET=y
>  CONFIG_USB=y
>  CONFIG_USB_XHCI_HCD=y
> --
> 2.40.1
>

Can this please be merged if no changes are required?

[0] - 
https://patchwork.ozlabs.org/project/uboot/patch/20231113112309.730323-...@shantur.com/

Kind regards,
Shantur


Re: [PATCH 1/3] iommu: fix compilation when CONFIG_PCI disabled

2023-12-11 Thread Tom Rini
On Mon, Dec 11, 2023 at 07:47:04PM +, Caleb Connolly wrote:
> 
> 
> On 11/12/2023 19:17, Tom Rini wrote:
> > On Mon, Dec 11, 2023 at 08:08:32PM +0100, Dragan Simic wrote:
> >> On 2023-12-11 19:41, Caleb Connolly wrote:
> >>> The dev_pci_iommu_enable() function is only available when CONFIG_PCI is
> >>> enabled, replace the runtime check with a preprocessor one to fix
> >>> compilation with pci disabled.
> >>>
> >>> Signed-off-by: Caleb Connolly 
> >>> ---
> >>>  drivers/iommu/iommu-uclass.c | 5 +++--
> >>>  1 file changed, 3 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/drivers/iommu/iommu-uclass.c b/drivers/iommu/iommu-uclass.c
> >>> index 72f123df55a5..98731d5e2c44 100644
> >>> --- a/drivers/iommu/iommu-uclass.c
> >>> +++ b/drivers/iommu/iommu-uclass.c
> >>> @@ -100,9 +100,10 @@ int dev_iommu_enable(struct udevice *dev)
> >>>   dev->iommu = dev_iommu;
> >>>   }
> >>>
> >>> - if (CONFIG_IS_ENABLED(PCI) && count < 0 &&
> >>> - device_is_on_pci_bus(dev))
> >>> +#if CONFIG_IS_ENABLED(PCI)
> >>> + if (count < 0 && device_is_on_pci_bus(dev))
> >>>   return dev_pci_iommu_enable(dev);
> >>> +#endif
> >>>
> >>>   return 0;
> >>>  }
> >>
> >> Perhaps there's no need to introduce an ifdef here.
> > 
> > Yes, how exactly are you getting a build failure? dev_pci_iommu_enable
> > should be available and return false with CONFIG_PCI=n.
> 
> Hi,
> 
> Without this patch I get
> 
> ../drivers/iommu/iommu-uclass.c: In function 'dev_iommu_enable':
> ../drivers/iommu/iommu-uclass.c:116:24: warning: implicit declaration of
> function 'dev_pci_iommu_enable'; did you mean 'dev_iommu_enable'?
> [-Wimplicit-function-declaration]
>   116 | return dev_pci_iommu_enable(dev);
>   |^~~~
>   |dev_iommu_enable
> 
> Grepping shows there is only one definition, which is the static
> function definition in iommu-uclass which is #ifdef'd out when
> CONFIG_PCI is disabled.
> 
> ; rg "dev_pci_iommu_enable"
> drivers/iommu/iommu-uclass.c
> 18:static int dev_pci_iommu_enable(struct udevice *dev)
> 116:return dev_pci_iommu_enable(dev);
> > 
> 
> Am I missing a patch or something? The function is only defined in one
> place in the whole of U-Boot.

Oh sorry, you're right, I checked the wrong function. I guess I'll defer
to Simon on if he prefers to just use #ifdef here or __maybe_unused
dev_pci_iommu_enable instead.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/3] iommu: fix compilation when CONFIG_PCI disabled

2023-12-11 Thread Caleb Connolly



On 11/12/2023 19:17, Tom Rini wrote:
> On Mon, Dec 11, 2023 at 08:08:32PM +0100, Dragan Simic wrote:
>> On 2023-12-11 19:41, Caleb Connolly wrote:
>>> The dev_pci_iommu_enable() function is only available when CONFIG_PCI is
>>> enabled, replace the runtime check with a preprocessor one to fix
>>> compilation with pci disabled.
>>>
>>> Signed-off-by: Caleb Connolly 
>>> ---
>>>  drivers/iommu/iommu-uclass.c | 5 +++--
>>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/iommu/iommu-uclass.c b/drivers/iommu/iommu-uclass.c
>>> index 72f123df55a5..98731d5e2c44 100644
>>> --- a/drivers/iommu/iommu-uclass.c
>>> +++ b/drivers/iommu/iommu-uclass.c
>>> @@ -100,9 +100,10 @@ int dev_iommu_enable(struct udevice *dev)
>>> dev->iommu = dev_iommu;
>>> }
>>>
>>> -   if (CONFIG_IS_ENABLED(PCI) && count < 0 &&
>>> -   device_is_on_pci_bus(dev))
>>> +#if CONFIG_IS_ENABLED(PCI)
>>> +   if (count < 0 && device_is_on_pci_bus(dev))
>>> return dev_pci_iommu_enable(dev);
>>> +#endif
>>>
>>> return 0;
>>>  }
>>
>> Perhaps there's no need to introduce an ifdef here.
> 
> Yes, how exactly are you getting a build failure? dev_pci_iommu_enable
> should be available and return false with CONFIG_PCI=n.

Hi,

Without this patch I get

../drivers/iommu/iommu-uclass.c: In function 'dev_iommu_enable':
../drivers/iommu/iommu-uclass.c:116:24: warning: implicit declaration of
function 'dev_pci_iommu_enable'; did you mean 'dev_iommu_enable'?
[-Wimplicit-function-declaration]
  116 | return dev_pci_iommu_enable(dev);
  |^~~~
  |dev_iommu_enable

Grepping shows there is only one definition, which is the static
function definition in iommu-uclass which is #ifdef'd out when
CONFIG_PCI is disabled.

; rg "dev_pci_iommu_enable"
drivers/iommu/iommu-uclass.c
18:static int dev_pci_iommu_enable(struct udevice *dev)
116:return dev_pci_iommu_enable(dev);
> 

Am I missing a patch or something? The function is only defined in one
place in the whole of U-Boot.

-- 
// Caleb (they/them)


Re: [PATCH v3] mmc: Poll CD in case cyclic framework is enabled

2023-12-11 Thread Marek Vasut

On 12/11/23 18:52, Simon Glass wrote:

Hi Marek,

On Sun, 10 Dec 2023 at 08:03, Marek Vasut
 wrote:


In case the cyclic framework is enabled, poll the card detect of already
initialized cards and deinitialize them in case they are removed. Since
the card initialization is a longer process and card initialization is
done on first access to an uninitialized card anyway, avoid initializing
newly detected uninitialized cards in the cyclic callback.

Signed-off-by: Marek Vasut 
---
Cc: Jaehoon Chung 
Cc: Peng Fan 
Cc: Simon Glass 
---
V2: Move the cyclic registration/unregistration into mmc init/deinit
V3: Replace if (CONFIG_IS_ENABLED(CYCLIC)...) with #if as the former
 does not work with structure members
---
  drivers/mmc/mmc.c | 36 
  include/mmc.h |  5 +
  2 files changed, 41 insertions(+)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index eb5010c1465..a5686dbc12e 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2985,6 +2985,22 @@ static int mmc_complete_init(struct mmc *mmc)
 return err;
  }

+#if CONFIG_IS_ENABLED(CYCLIC)
+static void mmc_cyclic_cd_poll(void *ctx)
+{
+   struct mmc *m = ctx;
+
+   if (!m->has_init)
+   return;
+
+   if (mmc_getcd(m))
+   return;
+
+   mmc_deinit(m);
+   m->has_init = 0;
+}
+#endif
+
  int mmc_init(struct mmc *mmc)
  {
 int err = 0;
@@ -3007,6 +3023,19 @@ int mmc_init(struct mmc *mmc)
 if (err)
 pr_info("%s: %d, time %lu\n", __func__, err, get_timer(start));

+#if CONFIG_IS_ENABLED(CYCLIC)


We really shouldn't be adding new #ifdefs to the code.

If you really want to make put ->cyclic behind an #ifdef then how
about creating an accessor as is done in global_data.h ?


That's really just working around the underlying issue, which is that 
this does not compile:


struct foo {
#if CONFIG_IS_ENABLED(STUFF)
  type member;
#endif
...
};

type fn() {
...
if (CONFIG_IS_ENABLED(STUFF))
  access struct->member;
...
}

Accessor won't make it any better, would it ? It would only attempt to 
hide the error and make the code more fragile, i.e. this:


accessor(struct)
{
type fn() {
if (CONFIG_IS_ENABLED(STUFF))
  return access struct->member;
else
  return 0;
}

}

type fn() {
...
  accessor(struct);
...
}

I suspect it also won't compile for one thing, and for the other, it 
really just hides the issue.


Re: [PATCH 1/3] iommu: fix compilation when CONFIG_PCI disabled

2023-12-11 Thread Tom Rini
On Mon, Dec 11, 2023 at 08:08:32PM +0100, Dragan Simic wrote:
> On 2023-12-11 19:41, Caleb Connolly wrote:
> > The dev_pci_iommu_enable() function is only available when CONFIG_PCI is
> > enabled, replace the runtime check with a preprocessor one to fix
> > compilation with pci disabled.
> > 
> > Signed-off-by: Caleb Connolly 
> > ---
> >  drivers/iommu/iommu-uclass.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/iommu/iommu-uclass.c b/drivers/iommu/iommu-uclass.c
> > index 72f123df55a5..98731d5e2c44 100644
> > --- a/drivers/iommu/iommu-uclass.c
> > +++ b/drivers/iommu/iommu-uclass.c
> > @@ -100,9 +100,10 @@ int dev_iommu_enable(struct udevice *dev)
> > dev->iommu = dev_iommu;
> > }
> > 
> > -   if (CONFIG_IS_ENABLED(PCI) && count < 0 &&
> > -   device_is_on_pci_bus(dev))
> > +#if CONFIG_IS_ENABLED(PCI)
> > +   if (count < 0 && device_is_on_pci_bus(dev))
> > return dev_pci_iommu_enable(dev);
> > +#endif
> > 
> > return 0;
> >  }
> 
> Perhaps there's no need to introduce an ifdef here.

Yes, how exactly are you getting a build failure? dev_pci_iommu_enable
should be available and return false with CONFIG_PCI=n.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] include: env: ti: ti_common: Run main_cpsw0_qsgmii_phyinit conditionally

2023-12-11 Thread Tom Rini
On Mon, Dec 11, 2023 at 04:12:09PM +0530, Siddharth Vadapalli wrote:

> From: Manorit Chawdhry 
> 
> The main_cpsw0_qsgmii_phyinit command is defined only for certain TI
> SoCs which have the do_main_cpsw0_qsgmii_phyinit variable set.
> 
> Add a check to ensure that the main_cpsw0_qsgmii_phyinit command is run
> only for such SoCs.
> 
> Signed-off-by: Manorit Chawdhry 
> Signed-off-by: Siddharth Vadapalli 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/3] iommu: fix compilation when CONFIG_PCI disabled

2023-12-11 Thread Dragan Simic

On 2023-12-11 19:41, Caleb Connolly wrote:
The dev_pci_iommu_enable() function is only available when CONFIG_PCI 
is

enabled, replace the runtime check with a preprocessor one to fix
compilation with pci disabled.

Signed-off-by: Caleb Connolly 
---
 drivers/iommu/iommu-uclass.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/iommu-uclass.c 
b/drivers/iommu/iommu-uclass.c

index 72f123df55a5..98731d5e2c44 100644
--- a/drivers/iommu/iommu-uclass.c
+++ b/drivers/iommu/iommu-uclass.c
@@ -100,9 +100,10 @@ int dev_iommu_enable(struct udevice *dev)
dev->iommu = dev_iommu;
}

-   if (CONFIG_IS_ENABLED(PCI) && count < 0 &&
-   device_is_on_pci_bus(dev))
+#if CONFIG_IS_ENABLED(PCI)
+   if (count < 0 && device_is_on_pci_bus(dev))
return dev_pci_iommu_enable(dev);
+#endif

return 0;
 }


Perhaps there's no need to introduce an ifdef here.


[PATCH 3/3] iommu: add qcom-hyp-smmu

2023-12-11 Thread Caleb Connolly
Add a basic implementation of the ARM SMMU. This driver is intended for
use on Qualcomm platforms where the SMMU has been configured by a previous
bootloader, cannot be turned off, and doesn't support BYPASS streams.
It keeps all existing stream mappings and only creates new ones for stream
ids that aren't already configured.

This driver is necessary to support peripherals that perform DMA which
weren't configured by the previous stage bootloader (for example USB).
It works by allocating a context bank using identity mapping (as U-Boot
doesn't use virtual addresses).

Signed-off-by: Caleb Connolly 
---
 drivers/iommu/Kconfig |  16 ++
 drivers/iommu/Makefile|   1 +
 drivers/iommu/qcom-hyp-smmu.c | 396 ++
 3 files changed, 413 insertions(+)

diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index dabc1f900d58..2ba6d9c13622 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -24,4 +24,20 @@ config APPLE_DART
  configuration to put the DART into bypass mode such that it can
  be used transparently by U-Boot.
 
+config QCOM_HYP_SMMU
+   bool "Qualcomm quirky SMMU support"
+   depends on IOMMU && ARCH_SNAPDRAGON
+   help
+ Enable support for the Qualcomm variant of the Arm System MMU-500.
+ Qualcomm boards have a non-standard SMMU where some registers are
+ emulated by the hypervisor. It is initialised early in the boot
+ process and can't be turned off.
+
+ The main caveat with this hardware is that it doesn't support BYPASS
+ streams, attempting to configure once will instead wind up with a
+ FAULT stream, and the device will crash when DMA is attempted.
+
+ Say Y here to enable support for non-boot peripherals like USB by
+ configuring identity mapped streams for them.
+
 endmenu
diff --git a/drivers/iommu/Makefile b/drivers/iommu/Makefile
index e3e0900e1703..438cab8a7c49 100644
--- a/drivers/iommu/Makefile
+++ b/drivers/iommu/Makefile
@@ -4,3 +4,4 @@ obj-$(CONFIG_IOMMU) += iommu-uclass.o
 
 obj-$(CONFIG_APPLE_DART) += apple_dart.o
 obj-$(CONFIG_SANDBOX) += sandbox_iommu.o
+obj-$(CONFIG_QCOM_HYP_SMMU) += qcom-hyp-smmu.o
diff --git a/drivers/iommu/qcom-hyp-smmu.c b/drivers/iommu/qcom-hyp-smmu.c
new file mode 100644
index ..8e5cdb581550
--- /dev/null
+++ b/drivers/iommu/qcom-hyp-smmu.c
@@ -0,0 +1,396 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2023 Linaro Ltd.
+ * Basic ARM SMMU-500 driver, assuming a pre-initialised SMMU and only 
IDENTITY domains
+ * this driver only implements the bare minimum to configure stream mappings 
for periphals
+ * used by u-boot on platforms where the SMMU can't be disabled.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define ARM_SMMU_GR0 0
+#define ARM_SMMU_GR1 1
+
+#define ARM_SMMU_GR0_ID0 0x20
+#define ARM_SMMU_ID0_NUMSMRG GENMASK(7, 0) /* Number of stream mapping groups 
*/
+#define ARM_SMMU_GR0_ID1 0x24
+#define ARM_SMMU_ID1_PAGESIZE \
+   BIT(31) /* Page shift is 16 bits when set, otherwise 23 */
+#define ARM_SMMU_ID1_NUMPAGENDXB \
+   GENMASK(30, 28) /* Number of pages before context banks */
+#define ARM_SMMU_ID1_NUMCB GENMASK(7, 0) /* Number of context banks supported 
*/
+
+#define ARM_SMMU_GR1_CBAR(n) (0x0 + ((n) << 2))
+#define ARM_SMMU_CBAR_TYPE GENMASK(17, 16)
+#define ARM_SMMU_CBAR_VMID GENMASK(7, 0)
+enum arm_smmu_cbar_type {
+   CBAR_TYPE_S2_TRANS,
+   CBAR_TYPE_S1_TRANS_S2_BYPASS,
+   CBAR_TYPE_S1_TRANS_S2_FAULT,
+   CBAR_TYPE_S1_TRANS_S2_TRANS,
+};
+
+#define ARM_SMMU_GR1_CBA2R(n) (0x800 + ((n) << 2))
+#define ARM_SMMU_CBA2R_VA64 BIT(0)
+
+/* Per-CB system control register */
+#define ARM_SMMU_CB_SCTLR 0x0
+#define ARM_SMMU_SCTLR_CFCFG BIT(7) /* Stall on context fault */
+#define ARM_SMMU_SCTLR_CFIE BIT(6) /* Context fault interrupt enable */
+#define ARM_SMMU_SCTLR_CFRE BIT(5) /* Abort on context fault */
+
+/* Translation Table Base, holds address of translation table in memory to be 
used
+ * for this context bank. Or 0 for bypass
+ */
+#define ARM_SMMU_CB_TTBR0 0x20
+#define ARM_SMMU_CB_TTBR1 0x28
+/* Translation Control Register, configured TTBR/TLB behaviour (0 for bypass) 
*/
+#define ARM_SMMU_CB_TCR 0x30
+/* Memory Attribute Indirection, also 0 for bypass */
+#define ARM_SMMU_CB_S1_MAIR0 0x38
+#define ARM_SMMU_CB_S1_MAIR1 0x3c
+
+#define ARM_SMMU_GR0_SMR(n) (0x800 + ((n) << 2))
+#define ARM_SMMU_SMR_VALID BIT(31)
+#define ARM_SMMU_SMR_MASK GENMASK(31, 16) // Always 0 for now??
+#define ARM_SMMU_SMR_ID GENMASK(15, 0)
+
+#define ARM_SMMU_GR0_S2CR(n) (0xc00 + ((n) << 2))
+#define ARM_SMMU_S2CR_PRIVCFG GENMASK(25, 24)
+
+enum arm_smmu_s2cr_privcfg {
+   S2CR_PRIVCFG_DEFAULT,
+   S2CR_PRIVCFG_DIPAN,
+   S2CR_PRIVCFG_UNPRIV,
+   S2CR_PRIVCFG_PRIV,
+};
+
+#define ARM_SMMU_S2CR_TYPE GENMASK(17, 16)
+
+enum arm_smmu_s2cr_type {
+   S2CR_TY

[PATCH 2/3] iommu: add a connect op

2023-12-11 Thread Caleb Connolly
Add an optional iommu callback to be invoked before a device probes.
This can be used to configure the IOMMU in preparation for the device
(e.g. by allocating a context bank)

Signed-off-by: Caleb Connolly 
---
 drivers/iommu/iommu-uclass.c | 11 +++
 include/iommu.h  |  9 +
 2 files changed, 20 insertions(+)

diff --git a/drivers/iommu/iommu-uclass.c b/drivers/iommu/iommu-uclass.c
index 98731d5e2c44..6babc0e3a672 100644
--- a/drivers/iommu/iommu-uclass.c
+++ b/drivers/iommu/iommu-uclass.c
@@ -77,6 +77,7 @@ int dev_iommu_enable(struct udevice *dev)
 {
struct ofnode_phandle_args args;
struct udevice *dev_iommu;
+   const struct iommu_ops *ops;
int i, count, ret = 0;
 
count = dev_count_phandle_with_args(dev, "iommus",
@@ -98,6 +99,16 @@ int dev_iommu_enable(struct udevice *dev)
return ret;
}
dev->iommu = dev_iommu;
+
+   if (dev->parent && dev->parent->iommu == dev_iommu)
+   continue;
+
+   ops = device_get_ops(dev->iommu);
+   if (ops && ops->connect) {
+   ret = ops->connect(dev);
+   if (ret)
+   return ret;
+   }
}
 
 #if CONFIG_IS_ENABLED(PCI)
diff --git a/include/iommu.h b/include/iommu.h
index cf9719c5e91c..b8ba0b8e7077 100644
--- a/include/iommu.h
+++ b/include/iommu.h
@@ -4,6 +4,15 @@
 struct udevice;
 
 struct iommu_ops {
+   /**
+* init() - Connect a device to it's IOMMU, called before probe()
+* The iommu device can be fetched through dev->iommu
+*
+* @iommu_dev:  IOMMU device
+* @dev:Device to connect
+* @return 0 if OK, -errno on error
+*/
+   int (*connect)(struct udevice *dev);
/**
 * map() - map DMA memory
 *

-- 
2.42.1



[PATCH 1/3] iommu: fix compilation when CONFIG_PCI disabled

2023-12-11 Thread Caleb Connolly
The dev_pci_iommu_enable() function is only available when CONFIG_PCI is
enabled, replace the runtime check with a preprocessor one to fix
compilation with pci disabled.

Signed-off-by: Caleb Connolly 
---
 drivers/iommu/iommu-uclass.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/iommu-uclass.c b/drivers/iommu/iommu-uclass.c
index 72f123df55a5..98731d5e2c44 100644
--- a/drivers/iommu/iommu-uclass.c
+++ b/drivers/iommu/iommu-uclass.c
@@ -100,9 +100,10 @@ int dev_iommu_enable(struct udevice *dev)
dev->iommu = dev_iommu;
}
 
-   if (CONFIG_IS_ENABLED(PCI) && count < 0 &&
-   device_is_on_pci_bus(dev))
+#if CONFIG_IS_ENABLED(PCI)
+   if (count < 0 && device_is_on_pci_bus(dev))
return dev_pci_iommu_enable(dev);
+#endif
 
return 0;
 }

-- 
2.42.1



[PATCH 0/3] Qualcomm quirky SMMU support

2023-12-11 Thread Caleb Connolly
Qualcomm platforms are heavily locked down, in many cases offering no
way for users to gain EL2 or EL3 code execution and including many
additional security features. Among these are modifications made to
the SMMU behaviour (done by having the hypervisor intercept register
accesses). On many platforms it is not possible to disable the SMMU,
and not possible to configure streams in BYPASS.

To enable support for peripherals like USB which depend on DMA, we must
allocate a context bank on the SMMU and configure an IDENTITY mapping.

This patch series fixes support for building IOMMU without CONFIG_PCI.

Then, it introduces first introduces support for a .connect() op in
IOMMU drivers, this is called before the peripheral drivers .probe()
function and allows for IOMMU devices to perform one-time setup.

Lastly, introduce a new driver which supports the SMMU as found on
Qualcomm platforms, when a DMA capable peripherals is probed, this
driver will first see if the previous stage bootloader configured a
context bank for the given stream ID already, and if not then it
allocates and configures one so that DMA accesses will work.

There are no in-tree users for this driver yet, however it is required
for upcoming USB support on SDM845 and future Qualcomm platforms.

---
Caleb Connolly (3):
  iommu: fix compilation when CONFIG_PCI disabled
  iommu: add a connect op
  iommu: add qcom-hyp-smmu

 drivers/iommu/Kconfig |  16 ++
 drivers/iommu/Makefile|   1 +
 drivers/iommu/iommu-uclass.c  |  16 +-
 drivers/iommu/qcom-hyp-smmu.c | 396 ++
 include/iommu.h   |   9 +
 5 files changed, 436 insertions(+), 2 deletions(-)
---
base-commit: 8806443ed784dad5b5daf351b0175acb3343e729

// Caleb (they/them)



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

2023-12-11 Thread Tom Rini
On Mon, Dec 11, 2023 at 11:22:45AM -0700, Simon Glass wrote:
> Hi Tom,
[snip]
> > I think in hind-sight too much stuff is omitted without BOOTSTD_FULL.
> > The option itself then enables other stuff too by default, but some
> > parts of the bootflow command itself should be visible even without FULL
> > to make things easier on the user.
> 
> At the time the goal was to avoid growth compared to the distro
> scripts. We could perhaps add some more things in with BOOTSTD_FULL
> but still have it as an option?

Right. But now that we've tried this, some of the feedback has been that
it's just too minimal right now. Like looking at the help message for
bootflow, list and info should probably always be available. And maybe
the flags for "scan" should be re-thought? Too late to change things now
but "bootflow scan -b" should maybe how it's always been for "scan and
boot".

-- 
Tom


signature.asc
Description: PGP signature


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

2023-12-11 Thread Simon Glass
Hi Tom,

On Mon, 11 Dec 2023 at 11:19, Tom Rini  wrote:
>
> On Mon, Dec 11, 2023 at 10:52:12AM -0700, Simon Glass wrote:
> > Hi,
> >
> > On Sat, 9 Dec 2023 at 15:19, Shantur Rathore  wrote:
> > >
> > > On Sat, Dec 9, 2023 at 8:56 PM Tom Rini  wrote:
> > > >
> > > > On Fri, Dec 08, 2023 at 01:59:26PM +, Shantur Rathore wrote:
> > > > > Hi Peter,
> > > > >
> > > > > On Fri, Dec 8, 2023 at 12:59 PM Peter Robinson  
> > > > > wrote:
> > > > > >
> > > > > > On Fri, Dec 8, 2023 at 12:52 PM Shantur Rathore  
> > > > > > wrote:
> > > > > > >
> > > > > > > Hi Jagan,
> > > > > > >
> > > > > > > On Fri, Dec 8, 2023 at 11:13 AM Jagan Teki 
> > > > > > >  wrote:
> > > > > > > >
> > > > > > > > On Sun, Nov 19, 2023 at 10:54 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
> > > > > > > >
> > > > > > > > Yes, but better to give this option to specific board vendors as
> > > > > > > > defaults are enough to boot 1st bootflow and what ever media's 
> > > > > > > > it has.
> > > > > > > >
> > > > > > >
> > > > > > > Yes, that's correct it is enough to boot but by default there is 
> > > > > > > no option
> > > > > > > to choose what to boot from.
> > > > > > > This was discussed in an earlier version of this patch [0] where 
> > > > > > > I was
> > > > > > > explicitly enabling only for RP64.
> > > > > >
> > > > > > What actual extra functionality does this provide, what is the 
> > > > > > impact
> > > > > > on the size of images? You've not provided reasonable justification
> > > > > > outside of very vague statements, it would be useful to know what 
> > > > > > the
> > > > > > added options actually solves.
> > > > >
> > > > > BOOTSTD_FULL enables all the options in bootflow commands. This is 
> > > > > needed if
> > > > > - you want to choose between multiple available bootflows rather than
> > > > > just boot one default.
> > > > > - if you need to list the available bootflows that bootstd has found
> > > > > - if you need to select and boot any bootflow other than default.
> > > > > By default all other commands in U-boot come with options to show 
> > > > > details
> > > > > For example, nvme info, nvme detail, usb info, usb tree but with
> > > > > bootstd no way to know anything.
> > > > >
> > > > > Image size - u-boot.itd without BOOTSTD_FULL - 1193984 bytes
> > > > > Image size - u-boot.itb with BOOTSTD_FULL - 1214976 bytes
> > > > > Difference - 20992 bytes
> > > > >
> > > > > According to binman for RK3399 u-boot can take upto 4M [1] so we have
> > > > > ample space.
> > > > >
> > > > > This was discussed in the previous patch in the link below [0]
> > > > >
> > > > > [0] - 
> > > > > https://patchwork.ozlabs.org/project/uboot/patch/2023001329.537704-...@shantur.com/
> > > > > [1] - 
> > > > > https://github.com/shantur/u-boot/blob/master/arch/arm/dts/rk3399-u-boot.dtsi#L68
> > > >
> > > > If I'm recalling everything right, this also brings "bootflow" as a
> > > > command more in line with what could be done with distro_bootcmd in
> > > > terms of "cover every possible case and let the user override things"
> > > >
> > > Yes,
> > > That's correct.
> > >
> > > U_BOOT_LONGHELP(bootflow,
> > > #ifdef CONFIG_CMD_BOOTFLOW_FULL
> > > "scan [-abeGl] [bdev]  - scan for valid bootflows (-l list, -a all, -e
> > > errors, -b boot, -G no global)\n"
> > > "bootflow list [-e] - list scanned bootflows (-e errors)\n"
> > > "bootflow select [|] - select a bootflow\n"
> > > "bootflow info [-ds]- show info on current bootflow (-d
> > > dump bootflow)\n"
> > > "bootflow read  - read all current-bootflow files\n"
> > > "bootflow boot  - boot current bootflow\n"
> > > "bootflow menu [-t] - show a menu of available bootflows\n"
> > > "bootflow cmdline [set|get|clear|delete|auto]  [] -
> > > update cmdline"
> > > #else
> > > "scan - boot first available bootflow\n"
> > > #endif
> > > );
> >
> > I suggest we keep it off for now, as we did put in qu

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

2023-12-11 Thread Tom Rini
On Mon, Dec 11, 2023 at 10:52:12AM -0700, Simon Glass wrote:
> Hi,
> 
> On Sat, 9 Dec 2023 at 15:19, Shantur Rathore  wrote:
> >
> > On Sat, Dec 9, 2023 at 8:56 PM Tom Rini  wrote:
> > >
> > > On Fri, Dec 08, 2023 at 01:59:26PM +, Shantur Rathore wrote:
> > > > Hi Peter,
> > > >
> > > > On Fri, Dec 8, 2023 at 12:59 PM Peter Robinson  
> > > > wrote:
> > > > >
> > > > > On Fri, Dec 8, 2023 at 12:52 PM Shantur Rathore  
> > > > > wrote:
> > > > > >
> > > > > > Hi Jagan,
> > > > > >
> > > > > > On Fri, Dec 8, 2023 at 11:13 AM Jagan Teki 
> > > > > >  wrote:
> > > > > > >
> > > > > > > On Sun, Nov 19, 2023 at 10:54 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
> > > > > > >
> > > > > > > Yes, but better to give this option to specific board vendors as
> > > > > > > defaults are enough to boot 1st bootflow and what ever media's it 
> > > > > > > has.
> > > > > > >
> > > > > >
> > > > > > Yes, that's correct it is enough to boot but by default there is no 
> > > > > > option
> > > > > > to choose what to boot from.
> > > > > > This was discussed in an earlier version of this patch [0] where I 
> > > > > > was
> > > > > > explicitly enabling only for RP64.
> > > > >
> > > > > What actual extra functionality does this provide, what is the impact
> > > > > on the size of images? You've not provided reasonable justification
> > > > > outside of very vague statements, it would be useful to know what the
> > > > > added options actually solves.
> > > >
> > > > BOOTSTD_FULL enables all the options in bootflow commands. This is 
> > > > needed if
> > > > - you want to choose between multiple available bootflows rather than
> > > > just boot one default.
> > > > - if you need to list the available bootflows that bootstd has found
> > > > - if you need to select and boot any bootflow other than default.
> > > > By default all other commands in U-boot come with options to show 
> > > > details
> > > > For example, nvme info, nvme detail, usb info, usb tree but with
> > > > bootstd no way to know anything.
> > > >
> > > > Image size - u-boot.itd without BOOTSTD_FULL - 1193984 bytes
> > > > Image size - u-boot.itb with BOOTSTD_FULL - 1214976 bytes
> > > > Difference - 20992 bytes
> > > >
> > > > According to binman for RK3399 u-boot can take upto 4M [1] so we have
> > > > ample space.
> > > >
> > > > This was discussed in the previous patch in the link below [0]
> > > >
> > > > [0] - 
> > > > https://patchwork.ozlabs.org/project/uboot/patch/2023001329.537704-...@shantur.com/
> > > > [1] - 
> > > > https://github.com/shantur/u-boot/blob/master/arch/arm/dts/rk3399-u-boot.dtsi#L68
> > >
> > > If I'm recalling everything right, this also brings "bootflow" as a
> > > command more in line with what could be done with distro_bootcmd in
> > > terms of "cover every possible case and let the user override things"
> > >
> > Yes,
> > That's correct.
> >
> > U_BOOT_LONGHELP(bootflow,
> > #ifdef CONFIG_CMD_BOOTFLOW_FULL
> > "scan [-abeGl] [bdev]  - scan for valid bootflows (-l list, -a all, -e
> > errors, -b boot, -G no global)\n"
> > "bootflow list [-e] - list scanned bootflows (-e errors)\n"
> > "bootflow select [|] - select a bootflow\n"
> > "bootflow info [-ds]- show info on current bootflow (-d
> > dump bootflow)\n"
> > "bootflow read  - read all current-bootflow files\n"
> > "bootflow boot  - boot current bootflow\n"
> > "bootflow menu [-t] - show a menu of available bootflows\n"
> > "bootflow cmdline [set|get|clear|delete|auto]  [] -
> > update cmdline"
> > #else
> > "scan - boot first available bootflow\n"
> > #endif
> > );
> 
> I suggest we keep it off for now, as we did put in quite a bit of
> effort to reduce code size. It would be a shame to throw it all away.
> 
> That said, I can imagine this becoming a pain for people over time, as
> the 'bootflow' command becomes the common way to interact with U-Boot.
> I just wonder if it is too early to make the switch?

I think in hind-sight to

[PATCH v2 2/2] test: vboot: Using variable 'old_dtb' before assignment

2023-12-11 Thread Heinrich Schuchardt
old_dtb can only be assumed initialized in the finally block
if it is assigned a value before the try statement.

Avoid a pylint error reported by current pylint.

Signed-off-by: Heinrich Schuchardt 
Reviewed-by: Simon Glass 
---
v2:
mention pylint in commit message
---
 test/py/tests/test_vboot.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py
index 04fa59f98b..7e0e8e4475 100644
--- a/test/py/tests/test_vboot.py
+++ b/test/py/tests/test_vboot.py
@@ -533,10 +533,10 @@ def test_vboot(u_boot_console, name, sha_algo, padding, 
sign_options, required,
 with open(evil_kernel, 'wb') as fd:
 fd.write(500 * b'\x01')
 
+# We need to use our own device tree file. Remember to restore it
+# afterwards.
+old_dtb = cons.config.dtb
 try:
-# We need to use our own device tree file. Remember to restore it
-# afterwards.
-old_dtb = cons.config.dtb
 cons.config.dtb = dtb
 if global_sign:
 test_global_sign(sha_algo, padding, sign_options)
-- 
2.40.1



[PATCH v2 1/2] test: fit: Using variable 'old_dtb' before assignment

2023-12-11 Thread Heinrich Schuchardt
old_dtb can only be assumed initialized in the finally block
if it is assigned a value before the try statement.

Avoid a pylint error reported by current pylint.

Signed-off-by: Heinrich Schuchardt 
Reviewed-by: Simon Glass 
---
v2:
mention pylint in commit message
---
 test/py/tests/test_fit.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py
index f45848484e..04f64fd4bc 100755
--- a/test/py/tests/test_fit.py
+++ b/test/py/tests/test_fit.py
@@ -390,10 +390,10 @@ def test_fit(u_boot_console):
 
 
 cons = u_boot_console
+# We need to use our own device tree file. Remember to restore it
+# afterwards.
+old_dtb = cons.config.dtb
 try:
-# We need to use our own device tree file. Remember to restore it
-# afterwards.
-old_dtb = cons.config.dtb
 mkimage = cons.config.build_dir + '/tools/mkimage'
 run_fit_test(mkimage)
 finally:
-- 
2.40.1



[PATCH v2 0/2] test: Using variable 'old_dtb' before assignment

2023-12-11 Thread Heinrich Schuchardt
Avoid errors reported by 'make pylint_err.

v2:
mention pylint in commit messages

Heinrich Schuchardt (2):
  test: fit: Using variable 'old_dtb' before assignment
  test: vboot: Using variable 'old_dtb' before assignment

 test/py/tests/test_fit.py   | 6 +++---
 test/py/tests/test_vboot.py | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

-- 
2.40.1



Re: [PATCH 1/1] binman: elf: Using variable 'old_val' before assignment

2023-12-11 Thread Heinrich Schuchardt

On 11.12.23 18:52, Simon Glass wrote:

On Sat, 9 Dec 2023 at 11:50, Heinrich Schuchardt
 wrote:


old_val can only be assumed initialized in the finally block
if it is assigned a value before the try statement.

Signed-off-by: Heinrich Schuchardt 
---
  tools/binman/elf_test.py | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py
index e3dee79d06..b64134123c 100644
--- a/tools/binman/elf_test.py
+++ b/tools/binman/elf_test.py
@@ -249,8 +249,8 @@ class TestElf(unittest.TestCase):



Reviewed-by: Simon Glass 

An odd case though...I cannot imagine how this might fail.


This patch is needed to use a recent pylint. Otherwise 'make pylint_err' 
will fail in future.


Best regards

Heinrich


Re: [PATCH 2/2] test: vboot: Using variable 'old_dtb' before assignment

2023-12-11 Thread Heinrich Schuchardt

On 11.12.23 18:52, Simon Glass wrote:

On Sat, 9 Dec 2023 at 11:54, Heinrich Schuchardt
 wrote:


old_dtb can only be assumed initialized in the finally block
if it is assigned a value before the try statement.

Signed-off-by: Heinrich Schuchardt 
---
  test/py/tests/test_vboot.py | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)



Reviewed-by: Simon Glass 

I suggest mentioning the motivation for the patch in your commit
message. E.g. does it cause a pylint failure?


You only get a pylint error with current pylint, not with the one used 
by our CI.


Best regards

Heinrich


Re: [PATCH 00/18] Complete decoupling of bootm logic from commands

2023-12-11 Thread Simon Glass
Hi Tom,

On Sat, 9 Dec 2023 at 12:09, Tom Rini  wrote:
>
> On Sun, Dec 03, 2023 at 05:26:16PM -0700, Simon Glass wrote:
>
> > This series continues refactoring the bootm code to allow it to be used
> > with CONFIG_COMMAND disabled. The OS-handling code is refactored and
> > a new bootm_run() function is created to run through the bootm stages.
> > This completes the work.
> >
> > A booti_go() function is created also, in case it proves useful, but at
> > last for now standard boot does not use this.
> >
> > This is cmdd (part d of CMDLINE refactoring)
> > It depends on dm/bootstda-working
> > which depends on dm/cmdc-working
>
> Since I would ask "what's the size impact of all of this?", I went and
> checked. I rebased your current cmdd-working branch on top of current
> next, and compared. While I'm sure this will change a little given
> feedback so far, generally platforms shrink a little (probably due to
> the bootm args stuff you dropped, but may need to keep). The only big
> growth I saw was branch specific and your "rpi" patch, oh yes, that
> grows rpi_4 given that you change a bunch of stuff there. So that
> doesn't count.
>
> So generally speaking, I'm OK with this series up to cmdd-working, and
> will continue catching up and providing specific feedback.
>

OK, great. I have had a busy week but may be able to catch up a bit on
the plane.

Regards,
Simon


Re: [PATCH] CI: update pylint to recent version

2023-12-11 Thread Simon Glass
Hi Heinrich,

On Sat, 9 Dec 2023 at 13:03, Heinrich Schuchardt
 wrote:
>
> We are missing some Python problems like
>
>"Using variable 'varname' before assignment"
>
> Switch to a more recent version. Adjust the documentation accordingly.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  .azure-pipelines.yml  | 2 +-
>  .gitlab-ci.yml| 2 +-
>  doc/develop/python_cq.rst | 4 ++--
>  3 files changed, 4 insertions(+), 4 deletions(-)
>

Reviewed-by: Simon Glass 

Is there an associated patch to actually fix these problems?

Regards,
Simon


Re: [PATCH 1/1] binman: elf: Using variable 'old_val' before assignment

2023-12-11 Thread Simon Glass
On Sat, 9 Dec 2023 at 11:50, Heinrich Schuchardt
 wrote:
>
> old_val can only be assumed initialized in the finally block
> if it is assigned a value before the try statement.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  tools/binman/elf_test.py | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py
> index e3dee79d06..b64134123c 100644
> --- a/tools/binman/elf_test.py
> +++ b/tools/binman/elf_test.py
> @@ -249,8 +249,8 @@ class TestElf(unittest.TestCase):
>

Reviewed-by: Simon Glass 

An odd case though...I cannot imagine how this might fail.


Re: [PATCH 01/14] boot: Reorder FIT and BOOTSTD to be first

2023-12-11 Thread Simon Glass
Hi Tom,

On Sat, 9 Dec 2023 at 11:39, Tom Rini  wrote:
>
> On Sun, Dec 03, 2023 at 05:31:25PM -0700, Simon Glass wrote:
>
> > The boot menu shows Android first and then a timestamp option. Move
> > these later since they are less commonly used.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >  boot/Kconfig | 36 ++--
> >  1 file changed, 18 insertions(+), 18 deletions(-)
>
> Meh? Maybe this should be alphabetical instead, and some menu's added as
> needed.

I like to see common things first...although I agree if you know
nothing then alpha can be useful.

But when I look at 'make menuconfig' it seems much better with this patch.

Regards,
Simon


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

2023-12-11 Thread Simon Glass
Hi,

On Tue, 28 Nov 2023 at 13:31, Chiu, Chasel  wrote:
>
>
>
>
> > -Original Message-
> > From: Ard Biesheuvel 
> > Sent: Tuesday, November 28, 2023 10:08 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
> >
> > You are referring to a 2000 line patch so it is not 100% clear where to 
> > look tbh.
> >
> >
> > On Tue, 21 Nov 2023 at 19:37, Chiu, Chasel  wrote:
> > >
> > >
> > > In PR, UefiPayloadPkg/Library/FdtParserLib/FdtParserLib.c, line 268 is for
> > related example code.
> > >
> >
> > That refers to a 'memory-allocation' node, right? How does that relate to 
> > the
> > 'reserved-memory' node?
> >
> > And crucially, how does this clarify in which way "runtime-code" and 
> > "runtime-
> > data" reservations are being used?
> >
> > Since the very beginning of this discussion, I have been asking repeatedly 
> > for
> > examples that describe the wider context in which these reservations are 
> > used.
> > The "runtime" into runtime-code and runtime-data means that these regions 
> > have
> > a special significance to the operating system, not just to the next 
> > bootloader
> > stage. So I want to understand exactly why it is necessary to describe these
> > regions in a way where the operating system might be expected to interpret 
> > this
> > information and act upon it.
> >
>
>
> I think runtime code and data today are mainly for supporting UEFI runtime 
> services - some BIOS functions for OS to utilize, OS may follow below ACPI 
> spec to treat them as reserved range:
> https://uefi.org/specs/ACPI/6.5/15_System_Address_Map_Interfaces.html#uefi-memory-types-and-mapping-to-acpi-address-range-types
>
> Like I mentioned earlier, that PR is still in early phase and has not 
> reflected all the required changes yet, but the idea is to build 
> gEfiMemoryTypeInformationGuid HOB from FDT reserved-memory nodes.
> UEFI generic Payload has DxeMain integrated, however Memory Types are 
> platform-specific, for example, some platforms may need bigger runtime memory 
> for their implementation, that's why we want such FDT reserved-memory node to 
> tell DxeMain.
>
> The Payload flow will be like this:
>   Payload creates built-in default MemoryTypes table ->
> FDT reserved-memory node to override if required (this also ensures the 
> same memory map cross boots so ACPI S4 works) ->
>   Build gEfiMemoryTypeInformationGuid HOB by "platfom specific" 
> MemoryTypes Table ->
> DxeMain/GCD to consume this MemoryTypes table and setup memory 
> service ->
>   Install memory types table to UEFI system table.Configuration 
> table...
>
> Note: if Payload built-in default MemoryTypes table works fine for the 
> platform, then FDT reserved-memory node does not need to provide such 'usage' 
> compatible strings. (optional)
> This FDT node could allow flexibility/compatibility without rebuilding 
> Payload binary.
>
> Not sure if I answered all your questions, please highlight which area you 
> need more information.

Any more thoughts on this? If not, I would like to see this patch
applied, please.

Regards,
Simon


>
> Thanks,
> Chasel
>
>
> >
> > >
> > > > -Original Message-
> > > > From: Chiu, Chasel
> > > > Sent: Tuesday, November 21, 2023 10:34 AM
> > > > To: Ard Biesheuvel ; Simon Glass 
> > > > Cc: 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
> > > > ; Chiu, Chasel 
> > > > Subject: RE: [PATCH v7 2/2] schemas: Add some common reserved-memory
> > > > usages
> > > >
> > > >
> > > > Hi Ard,
> > > >
> > > > Here is the POC PR for your reference:
> > > > https://github.com/tianocore/edk2/pull/4969/files#diff-
> > > >
> > ccebabae5274b21634723a2111ee0de11bed6cfe8cb206ef9e263d9c5f926a9cR26
> > > > 8
> > > > Please note that this PR is still in early phase and expected to
> > > > have significant changes.
> > > >
> > > > The idea is that payload entry will create
> > > > gEfiMemoryTypeInformationGuid HOB with payload default memory types
> > > > and allow FDT to override if correspond node present.
> > > > Please let me know if you have questions or suggestions.
> > > >
> > > > Thanks,
> > > > Chasel
> > > >
> > > >
> > > > > -Original Message-
> > > > > From: Ard Biesheuvel 
> > > > > Sent: Tuesday, November 21, 2023 8:42 AM
> > > > > To: Simon Glass 
> > > > > Cc: Chiu, Chasel ;
> > > > > devicet...@vger.kernel.org; Mark Rutland ;
> > > > > Rob Herring ; Tan, Lean Sheng
> > > > > ; lkml ;
> > > > > Dhaval

Re: [PATCH v3] mmc: Poll CD in case cyclic framework is enabled

2023-12-11 Thread Simon Glass
Hi Marek,

On Sun, 10 Dec 2023 at 08:03, Marek Vasut
 wrote:
>
> In case the cyclic framework is enabled, poll the card detect of already
> initialized cards and deinitialize them in case they are removed. Since
> the card initialization is a longer process and card initialization is
> done on first access to an uninitialized card anyway, avoid initializing
> newly detected uninitialized cards in the cyclic callback.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Jaehoon Chung 
> Cc: Peng Fan 
> Cc: Simon Glass 
> ---
> V2: Move the cyclic registration/unregistration into mmc init/deinit
> V3: Replace if (CONFIG_IS_ENABLED(CYCLIC)...) with #if as the former
> does not work with structure members
> ---
>  drivers/mmc/mmc.c | 36 
>  include/mmc.h |  5 +
>  2 files changed, 41 insertions(+)
>
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index eb5010c1465..a5686dbc12e 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -2985,6 +2985,22 @@ static int mmc_complete_init(struct mmc *mmc)
> return err;
>  }
>
> +#if CONFIG_IS_ENABLED(CYCLIC)
> +static void mmc_cyclic_cd_poll(void *ctx)
> +{
> +   struct mmc *m = ctx;
> +
> +   if (!m->has_init)
> +   return;
> +
> +   if (mmc_getcd(m))
> +   return;
> +
> +   mmc_deinit(m);
> +   m->has_init = 0;
> +}
> +#endif
> +
>  int mmc_init(struct mmc *mmc)
>  {
> int err = 0;
> @@ -3007,6 +3023,19 @@ int mmc_init(struct mmc *mmc)
> if (err)
> pr_info("%s: %d, time %lu\n", __func__, err, 
> get_timer(start));
>
> +#if CONFIG_IS_ENABLED(CYCLIC)

We really shouldn't be adding new #ifdefs to the code.

If you really want to make put ->cyclic behind an #ifdef then how
about creating an accessor as is done in global_data.h ?

> +   if (!mmc->cyclic) {
> +   /* Register cyclic function for card detect polling */
> +   mmc->cyclic = cyclic_register(mmc_cyclic_cd_poll, 100 * 1000,
> + mmc->cfg->name, mmc);
> +   if (!mmc->cyclic) {
> +   printf("Failed to register %s CD poll function\n",
> +   mmc->cfg->name);
> +   err = -EINVAL;
> +   }
> +   }
> +#endif
> +
> return err;
>  }
>
> @@ -3014,6 +3043,13 @@ int mmc_deinit(struct mmc *mmc)
>  {
> u32 caps_filtered;
>
> +#if CONFIG_IS_ENABLED(CYCLIC)
> +   if (mmc->cyclic) {
> +   cyclic_unregister(mmc->cyclic);
> +   mmc->cyclic = NULL;
> +   }
> +#endif
> +
> if (!CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) &&
> !CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) &&
> !CONFIG_IS_ENABLED(MMC_HS400_SUPPORT))
> diff --git a/include/mmc.h b/include/mmc.h
> index 1022db3ffa7..4256d5567ef 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -14,6 +14,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>
>  struct bd_info;
> @@ -739,6 +740,10 @@ struct mmc {
> u8 hs400_tuning;
>
> enum bus_mode user_speed_mode; /* input speed mode from user */
> +
> +#if CONFIG_IS_ENABLED(CYCLIC)
> +   struct cyclic_info  *cyclic;
> +#endif
>  };
>
>  #if CONFIG_IS_ENABLED(DM_MMC)
> --
> 2.42.0
>

Regards,
Simon


Re: [PATCH 02/14] bootm: Add a Kconfig option for bootm functionality

2023-12-11 Thread Simon Glass
Hi Tom,

On Sat, 9 Dec 2023 at 11:39, Tom Rini  wrote:
>
> On Sun, Dec 03, 2023 at 05:31:26PM -0700, Simon Glass wrote:
>
> > Create a separate Kconfig option which enables the bootm logic,
> > separate from the 'bootm' command. This will eventually allow booting
> > without CMDLINE enabled.
> >
> > Update boards which disable CMD_BOOTM to disable BOOTM instead, since
> > CMD_BOOTM now depends on BOOTM
> >
> > Signed-off-by: Simon Glass 
>
> This is fine, to start with. But I wonder if it shouldn't be an
> unprompted option and select'd by functionality as needed. That might be
> clearer to the user going through menus, but we can see better once the
> whole picture is available.

Perhaps. As you imply, it will likely become clearer later.

Regards,
Simon


Re: [PATCH 1/1] cmd: check argc for acpi dump

2023-12-11 Thread Simon Glass
On Sat, 9 Dec 2023 at 10:05, Heinrich Schuchardt
 wrote:
>
> 'acpi dump' without parameter results in a NULL dereference. Check the
> number of arguments.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  cmd/acpi.c | 3 +++
>  1 file changed, 3 insertions(+)
>

Reviewed-by: Simon Glass 

This could have a test in test/dm/acpi.c if you like


Re: [PATCH] pxe_utils: Increase feedback to user when fdt file is not found

2023-12-11 Thread Simon Glass
On Thu, 7 Dec 2023 at 07:28, Michael Trimarchi
 wrote:
>
> extlinux.conf can set fdtdir. fdtdir look for fdt file using
> information found in the enviroment variable. The function does
> not report any error in the case the file is not found
>
> Scanning for bootflows in all bootdevs
> Seq  Method   State   UclassPart  Name  Filename
> ---  ---  --        
> 
> Scanning global bootmeth 'efi_mgr':
> No EFI system partition
> No EFI system partition
> Failed to persist EFI variables
> Scanning bootdev 'mmc@fa1.bootdev':
>   0  extlinux ready   mmc  1  mmc@fa1.bootdev.part_ 
> /boot/extlinux/extlinux.conf
> ** Booting bootflow 'mmc@fa1.bootdev.part_1' with extlinux
> 1:  am62x-sk-buildroot
> Retrieving file: /boot/Image
> append: console=ttyS2,115200n8 
> root=PARTUUID=c586a30c-0bf1-4323-aba8-779c814ee135 rw
> rootfstype=ext4 rootwait earlycon=ns16550a,mmio32,0x0280
> Retrieving file: /boot/k3-am623_ccm_m3.dtb
> Skipping fdtdir /boot/ for failure retrieving dts
>
> Signed-off-by: Michael Trimarchi 
> ---
>  boot/pxe_utils.c | 5 +
>  1 file changed, 5 insertions(+)

Reviewed-by: Simon Glass 


Re: [PATCH 2/2] test: vboot: Using variable 'old_dtb' before assignment

2023-12-11 Thread Simon Glass
On Sat, 9 Dec 2023 at 11:54, Heinrich Schuchardt
 wrote:
>
> old_dtb can only be assumed initialized in the finally block
> if it is assigned a value before the try statement.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  test/py/tests/test_vboot.py | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>

Reviewed-by: Simon Glass 

I suggest mentioning the motivation for the patch in your commit
message. E.g. does it cause a pylint failure?


Re: [PATCH 1/2] test: fit: Using variable 'old_dtb' before assignment

2023-12-11 Thread Simon Glass
On Sat, 9 Dec 2023 at 11:54, Heinrich Schuchardt
 wrote:
>
> old_dtb can only be assumed initialized in the finally block
> if it is assigned a value before the try statement.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  test/py/tests/test_fit.py | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass 


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

2023-12-11 Thread Simon Glass
Hi,

On Sat, 9 Dec 2023 at 15:19, Shantur Rathore  wrote:
>
> On Sat, Dec 9, 2023 at 8:56 PM Tom Rini  wrote:
> >
> > On Fri, Dec 08, 2023 at 01:59:26PM +, Shantur Rathore wrote:
> > > Hi Peter,
> > >
> > > On Fri, Dec 8, 2023 at 12:59 PM Peter Robinson  
> > > wrote:
> > > >
> > > > On Fri, Dec 8, 2023 at 12:52 PM Shantur Rathore  
> > > > wrote:
> > > > >
> > > > > Hi Jagan,
> > > > >
> > > > > On Fri, Dec 8, 2023 at 11:13 AM Jagan Teki 
> > > > >  wrote:
> > > > > >
> > > > > > On Sun, Nov 19, 2023 at 10:54 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
> > > > > >
> > > > > > Yes, but better to give this option to specific board vendors as
> > > > > > defaults are enough to boot 1st bootflow and what ever media's it 
> > > > > > has.
> > > > > >
> > > > >
> > > > > Yes, that's correct it is enough to boot but by default there is no 
> > > > > option
> > > > > to choose what to boot from.
> > > > > This was discussed in an earlier version of this patch [0] where I was
> > > > > explicitly enabling only for RP64.
> > > >
> > > > What actual extra functionality does this provide, what is the impact
> > > > on the size of images? You've not provided reasonable justification
> > > > outside of very vague statements, it would be useful to know what the
> > > > added options actually solves.
> > >
> > > BOOTSTD_FULL enables all the options in bootflow commands. This is needed 
> > > if
> > > - you want to choose between multiple available bootflows rather than
> > > just boot one default.
> > > - if you need to list the available bootflows that bootstd has found
> > > - if you need to select and boot any bootflow other than default.
> > > By default all other commands in U-boot come with options to show details
> > > For example, nvme info, nvme detail, usb info, usb tree but with
> > > bootstd no way to know anything.
> > >
> > > Image size - u-boot.itd without BOOTSTD_FULL - 1193984 bytes
> > > Image size - u-boot.itb with BOOTSTD_FULL - 1214976 bytes
> > > Difference - 20992 bytes
> > >
> > > According to binman for RK3399 u-boot can take upto 4M [1] so we have
> > > ample space.
> > >
> > > This was discussed in the previous patch in the link below [0]
> > >
> > > [0] - 
> > > https://patchwork.ozlabs.org/project/uboot/patch/2023001329.537704-...@shantur.com/
> > > [1] - 
> > > https://github.com/shantur/u-boot/blob/master/arch/arm/dts/rk3399-u-boot.dtsi#L68
> >
> > If I'm recalling everything right, this also brings "bootflow" as a
> > command more in line with what could be done with distro_bootcmd in
> > terms of "cover every possible case and let the user override things"
> >
> Yes,
> That's correct.
>
> U_BOOT_LONGHELP(bootflow,
> #ifdef CONFIG_CMD_BOOTFLOW_FULL
> "scan [-abeGl] [bdev]  - scan for valid bootflows (-l list, -a all, -e
> errors, -b boot, -G no global)\n"
> "bootflow list [-e] - list scanned bootflows (-e errors)\n"
> "bootflow select [|] - select a bootflow\n"
> "bootflow info [-ds]- show info on current bootflow (-d
> dump bootflow)\n"
> "bootflow read  - read all current-bootflow files\n"
> "bootflow boot  - boot current bootflow\n"
> "bootflow menu [-t] - show a menu of available bootflows\n"
> "bootflow cmdline [set|get|clear|delete|auto]  [] -
> update cmdline"
> #else
> "scan - boot first available bootflow\n"
> #endif
> );

I suggest we keep it off for now, as we did put in quite a bit of
effort to reduce code size. It would be a shame to throw it all away.

That said, I can imagine this becoming a pain for people over time, as
the 'bootflow' command becomes the common way to interact with U-Boot.
I just wonder if it is too early to make the switch?

Regards,
Simon


Re: [PATCH] imx: imx-hab: Select SPL_DRIVERS_MISC in the SPL case

2023-12-11 Thread Lisandro Pérez Meyer
On Mon, Dec 11, 2023 at 10:46 AM Fabio Estevam  wrote:
>
> From: Fabio Estevam 
>
> Selecting CONFIG_IMX_HAB=y on a SPL target, such as apalis_imx6_defconfig,
> for example, leads to the following build error:
>
> /usr/bin/arm-linux-gnueabihf-ld.bfd: arch/arm/mach-imx/hab.o: in function 
> `imx_hab_is_enabled':
> arch/arm/mach-imx/hab.c:879: undefined reference to `fuse_read'
>
> fuse_read() comes from SPL_MXC_OCOTP, which depends on SPL_DRIVERS_MISC,
> since commit 251a3053b1e6 ("misc: imx: remove DM dependency for ocotp
> driver in SPL").
>
> Select SPL_DRIVERS_MISC in the SPL case to fix this build issue.
>
> Reported-by: Lisandro Pérez Meyer 
> Signed-off-by: Fabio Estevam 
> ---
>  arch/arm/mach-imx/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
> index abd48d42583a..c34bc25c0bfb 100644
> --- a/arch/arm/mach-imx/Kconfig
> +++ b/arch/arm/mach-imx/Kconfig
> @@ -54,6 +54,7 @@ config IMX_HAB
> bool "Support i.MX HAB features"
> depends on ARCH_MX7 || ARCH_MX6 || ARCH_MX5 || ARCH_IMX8M || 
> ARCH_MX7ULP
> select FSL_CAAM if HAS_CAAM
> +   select SPL_DRIVERS_MISC if SPL
> imply CMD_DEKBLOB if HAS_CAAM
> help
>   This option enables the support for secure boot (HAB).
> --
> 2.34.1
>

Tested-by: Lisandro Pérez Meyer 

-- 
Lisandro Pérez Meyer
Embedded Platform Engineer


Re: [PATCH 4/5] lib: vsprintf: enable '%*pb[l]' format specifier

2023-12-11 Thread Heinrich Schuchardt

On 11.12.23 13:20, lukas.funke-...@weidmueller.com wrote:

From: Lukas Funke 

The commit enables vsprintf() to handle the '%*pb[l]' format specifier
in order to print bitmaps and its derivatives such as cpumask and
nodemask [1]. This can be used to derive kernel boot parameters from
bitmaks such as 'isolcpu' or 'nohz_full' [2].

[1] https://www.kernel.org/doc/Documentation/printk-formats.txt
[2] https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html

Signed-off-by: Lukas Funke 


Please, add a change for doc/develop/printf.rst to the patch describing
the new format.

Best regards

Heinrich


---

  lib/vsprintf.c | 75 ++
  1 file changed, 75 insertions(+)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index e14c6ca9f9..abbd80ea9c 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -25,6 +25,7 @@
  #include 
  #include 
  #include 
+#include 

  /* we use this so that we can do without the ctype library */
  #define is_digit(c)   ((c) >= '0' && (c) <= '9')
@@ -390,6 +391,71 @@ static char *ip4_addr_string(char *buf, char *end, u8 
*addr, int field_width,
  flags & ~SPECIAL);
  }

+static char *bitmap_string(char *buf, char *end, const unsigned long *bitmap,
+  int field_width, int precision, int flags)
+{
+   const int CHUNKSIZE = 32;
+   int nr_bits = max_t(int, field_width, 0);
+   int i, chunksz;
+   int first = 1;
+
+   chunksz = nr_bits & (CHUNKSIZE - 1);
+   if (chunksz == 0)
+   chunksz = CHUNKSIZE;
+
+   i = ALIGN(nr_bits, CHUNKSIZE) - CHUNKSIZE;
+   for (; i >= 0; i -= CHUNKSIZE) {
+   u32 chunkmask, val;
+   int word, bit;
+
+   chunkmask = ((1ULL << chunksz) - 1);
+   word = i / BITS_PER_LONG;
+   bit = i % BITS_PER_LONG;
+   val = (bitmap[word] >> bit) & chunkmask;
+
+   if (!first) {
+   if (buf < end)
+   *buf = ',';
+   buf++;
+   }
+   first = 0;
+
+   field_width = DIV_ROUND_UP(chunksz, 4);
+   buf = number(buf, end, val, 16, field_width, precision,
+(SMALL | ZEROPAD));
+
+   chunksz = CHUNKSIZE;
+   }
+   return buf;
+}
+
+static char *bitmap_list_string(char *buf, char *end, unsigned long *addr,
+   int field_width, int precision, int flags)
+{
+   int nr_bits = max_t(int, field_width, 0);
+   int first = 1;
+   int rbot, rtop;
+
+   for_each_set_bitrange(rbot, rtop, addr, nr_bits) {
+   if (!first) {
+   if (buf < end)
+   *buf = ',';
+   buf++;
+   }
+   first = 0;
+
+   buf = number(buf, end, rbot, 10, 0, -1, 0);
+   if (rtop == rbot + 1)
+   continue;
+
+   if (buf < end)
+   *buf = '-';
+   buf = number(++buf, end, rtop - 1, 10, 0, -1, 0);
+   }
+
+   return buf;
+}
+
  #ifdef CONFIG_LIB_UUID
  /*
   * This works (roughly) the same way as Linux's.
@@ -503,6 +569,15 @@ static char *pointer(const char *fmt, char *buf, char 
*end, void *ptr,
   precision, flags);
flags &= ~SPECIAL;
break;
+   case 'b':
+   switch (fmt[1]) {
+   case 'l':
+   return bitmap_list_string(buf, end, ptr, field_width,
+   precision, flags);
+   default:
+   return bitmap_string(buf, end, ptr, field_width,
+   precision, flags);
+   }
  #ifdef CONFIG_LIB_UUID
case 'U':
return uuid_string(buf, end, ptr, field_width, precision,




RE: [PATCH v12 24/24] configs: Use old hush for several boards

2023-12-11 Thread Holger Brunck
> Signed-off-by: Francis Laniel 
> ---
>  configs/kmcent2_defconfig  | 1 +
>  configs/kmcoge5ne_defconfig| 1 +
>  configs/kmeter1_defconfig  | 1 +
>  configs/kmopti2_defconfig  | 1 +
>  configs/kmsupx5_defconfig  | 1 +
>  configs/kmtepr2_defconfig  | 1 +
>  configs/pg_wcom_expu1_defconfig| 1 +
>  configs/pg_wcom_expu1_update_defconfig | 1 +
>  configs/pg_wcom_seli8_defconfig| 1 +
>  configs/pg_wcom_seli8_update_defconfig | 1 +
>  configs/socfpga_secu1_defconfig| 1 +
>  configs/tuge1_defconfig| 1 +
>  configs/tuxx1_defconfig| 1 +
>  13 files changed, 13 insertions(+)
> 
> diff --git a/configs/kmcent2_defconfig b/configs/kmcent2_defconfig index
> 2cf9565fc9..ac272b3840 100644
> --- a/configs/kmcent2_defconfig
> +++ b/configs/kmcent2_defconfig
> @@ -111,3 +111,4 @@ CONFIG_BCH=y
>  CONFIG_PANIC_HANG=y
>  CONFIG_LZO=y
>  CONFIG_POST=y
> +CONFIG_HUSH_OLD_PARSER=y
> diff --git a/configs/kmcoge5ne_defconfig b/configs/kmcoge5ne_defconfig
> index 257ceeca90..ace5080690 100644
> --- a/configs/kmcoge5ne_defconfig
> +++ b/configs/kmcoge5ne_defconfig
> @@ -202,3 +202,4 @@ CONFIG_QE=y
>  CONFIG_SYS_NS16550=y
>  CONFIG_BCH=y
>  CONFIG_POST=y
> +CONFIG_HUSH_OLD_PARSER=y
> diff --git a/configs/kmeter1_defconfig b/configs/kmeter1_defconfig index
> 46e0370e35..56b83c085d 100644
> --- a/configs/kmeter1_defconfig
> +++ b/configs/kmeter1_defconfig
> @@ -173,3 +173,4 @@ CONFIG_DM_ETH_PHY=y
>  CONFIG_QE_UEC=y
>  CONFIG_QE=y
>  CONFIG_SYS_NS16550=y
> +CONFIG_HUSH_OLD_PARSER=y
> diff --git a/configs/kmopti2_defconfig b/configs/kmopti2_defconfig index
> c6c021adde..08c7602f5d 100644
> --- a/configs/kmopti2_defconfig
> +++ b/configs/kmopti2_defconfig
> @@ -183,3 +183,4 @@ CONFIG_QE_UEC=y
>  # CONFIG_PINCTRL_FULL is not set
>  CONFIG_QE=y
>  CONFIG_SYS_NS16550=y
> +CONFIG_HUSH_OLD_PARSER=y
> diff --git a/configs/kmsupx5_defconfig b/configs/kmsupx5_defconfig index
> 25642e7018..72db26f320 100644
> --- a/configs/kmsupx5_defconfig
> +++ b/configs/kmsupx5_defconfig
> @@ -166,3 +166,4 @@ CONFIG_QE_UEC=y
>  # CONFIG_PINCTRL_FULL is not set
>  CONFIG_QE=y
>  CONFIG_SYS_NS16550=y
> +CONFIG_HUSH_OLD_PARSER=y
> diff --git a/configs/kmtepr2_defconfig b/configs/kmtepr2_defconfig index
> ea37a29060..ed908d3c77 100644
> --- a/configs/kmtepr2_defconfig
> +++ b/configs/kmtepr2_defconfig
> @@ -182,3 +182,4 @@ CONFIG_QE_UEC=y
>  # CONFIG_PINCTRL_FULL is not set
>  CONFIG_QE=y
>  CONFIG_SYS_NS16550=y
> +CONFIG_HUSH_OLD_PARSER=y
> diff --git a/configs/pg_wcom_expu1_defconfig
> b/configs/pg_wcom_expu1_defconfig index 455b439151..0337447f79 100644
> --- a/configs/pg_wcom_expu1_defconfig
> +++ b/configs/pg_wcom_expu1_defconfig
> @@ -105,3 +105,4 @@ CONFIG_DM_SERIAL=y
>  CONFIG_SYS_NS16550=y
>  CONFIG_LZO=y
>  CONFIG_POST=y
> +CONFIG_HUSH_OLD_PARSER=y
> diff --git a/configs/pg_wcom_expu1_update_defconfig
> b/configs/pg_wcom_expu1_update_defconfig
> index 269116cd0d..e5daa306ab 100644
> --- a/configs/pg_wcom_expu1_update_defconfig
> +++ b/configs/pg_wcom_expu1_update_defconfig
> @@ -103,3 +103,4 @@ CONFIG_DM_SERIAL=y
>  CONFIG_SYS_NS16550=y
>  CONFIG_LZO=y
>  CONFIG_POST=y
> +CONFIG_HUSH_OLD_PARSER=y
> diff --git a/configs/pg_wcom_seli8_defconfig
> b/configs/pg_wcom_seli8_defconfig index 678bc10070..e86a17abdf 100644
> --- a/configs/pg_wcom_seli8_defconfig
> +++ b/configs/pg_wcom_seli8_defconfig
> @@ -105,3 +105,4 @@ CONFIG_DM_SERIAL=y
>  CONFIG_SYS_NS16550=y
>  CONFIG_LZO=y
>  CONFIG_POST=y
> +CONFIG_HUSH_OLD_PARSER=y
> diff --git a/configs/pg_wcom_seli8_update_defconfig
> b/configs/pg_wcom_seli8_update_defconfig
> index 7c7b001903..886334a043 100644
> --- a/configs/pg_wcom_seli8_update_defconfig
> +++ b/configs/pg_wcom_seli8_update_defconfig
> @@ -103,3 +103,4 @@ CONFIG_DM_SERIAL=y
>  CONFIG_SYS_NS16550=y
>  CONFIG_LZO=y
>  CONFIG_POST=y
> +CONFIG_HUSH_OLD_PARSER=y
> diff --git a/configs/socfpga_secu1_defconfig
> b/configs/socfpga_secu1_defconfig index b8052f1dee..2622bb0432 100644
> --- a/configs/socfpga_secu1_defconfig
> +++ b/configs/socfpga_secu1_defconfig
> @@ -113,3 +113,4 @@ CONFIG_DESIGNWARE_WATCHDOG=y
> CONFIG_WDT=y  CONFIG_SYS_TIMER_COUNTS_DOWN=y  # CONFIG_GZIP is
> not set
> +CONFIG_HUSH_OLD_PARSER=y
> diff --git a/configs/tuge1_defconfig b/configs/tuge1_defconfig index
> 9ff5d1599f..5c4d33235e 100644
> --- a/configs/tuge1_defconfig
> +++ b/configs/tuge1_defconfig
> @@ -166,3 +166,4 @@ CONFIG_QE_UEC=y
>  # CONFIG_PINCTRL_FULL is not set
>  CONFIG_QE=y
>  CONFIG_SYS_NS16550=y
> +CONFIG_HUSH_OLD_PARSER=y
> diff --git a/configs/tuxx1_defconfig b/configs/tuxx1_defconfig index
> 5b33e8fa64..16b50dd571 100644
> --- a/configs/tuxx1_defconfig
> +++ b/configs/tuxx1_defconfig
> @@ -183,3 +183,4 @@ CONFIG_QE_UEC=y
>  # CONFIG_PINCTRL_FULL is not set
>  CONFIG_QE=y
>  CONFIG_SYS_NS16550=y
> +CONFIG_HUSH_OLD_PARSER=y
> --
> 2.34.1

Reviewed-by: 

Thanks for taking care of this. 

Best regards
Holger Brunck


Re: [PATCH v1] configs: verdin-am62: Disable SPL FIT Overlay

2023-12-11 Thread Marcel Ziswiler
On Mon, 2023-12-11 at 14:45 +0100, Francesco Dolcini wrote:
> From: Francesco Dolcini 
> 
> Disable CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY, this is not required nor used
> on verdin am62, disable it to save precious binary size.
> 
> Update defconfig using savedefconfig, this adds CONFIG_OF_LIBFDT_OVERLAY
> explicitly.
> 
> Signed-off-by: Francesco Dolcini 

Acked-by: Marcel Ziswiler 

> ---
>  configs/verdin-am62_a53_defconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configs/verdin-am62_a53_defconfig 
> b/configs/verdin-am62_a53_defconfig
> index 780860180879..cdd6ba8baed4 100644
> --- a/configs/verdin-am62_a53_defconfig
> +++ b/configs/verdin-am62_a53_defconfig
> @@ -17,6 +17,7 @@ CONFIG_ENV_OFFSET=0xDE00
>  CONFIG_DM_GPIO=y
>  CONFIG_DEFAULT_DEVICE_TREE="k3-am625-verdin-wifi-dev"
>  CONFIG_SPL_TEXT_BASE=0x8008
> +CONFIG_OF_LIBFDT_OVERLAY=y
>  CONFIG_DM_RESET=y
>  CONFIG_SPL_MMC=y
>  CONFIG_SPL_SERIAL=y
> @@ -33,7 +34,6 @@ CONFIG_SYS_MEMTEST_END=0xB000
>  CONFIG_FIT_VERBOSE=y
>  CONFIG_SPL_LOAD_FIT=y
>  CONFIG_SPL_LOAD_FIT_ADDRESS=0x8100
> -CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY=y
>  CONFIG_LEGACY_IMAGE_FORMAT=y
>  CONFIG_DISTRO_DEFAULTS=y
>  CONFIG_BOOTDELAY=1


Re: [PATCH] imx: imx-hab: Select SPL_DRIVERS_MISC in the SPL case

2023-12-11 Thread Fabio Estevam

Hi Lisandro,

On 11/12/2023 11:45, Lisandro Pérez Meyer wrote:


I actually tested this, so, should I reply with Reviewed-By?


Feel free to reply with your Tested-by tag.

Thanks


Re: [PATCH] imx: imx-hab: Select SPL_DRIVERS_MISC in the SPL case

2023-12-11 Thread Lisandro Pérez Meyer
On Mon, Dec 11, 2023 at 10:46 AM Fabio Estevam  wrote:
>
> From: Fabio Estevam 
>
> Selecting CONFIG_IMX_HAB=y on a SPL target, such as apalis_imx6_defconfig,
> for example, leads to the following build error:
>
> /usr/bin/arm-linux-gnueabihf-ld.bfd: arch/arm/mach-imx/hab.o: in function 
> `imx_hab_is_enabled':
> arch/arm/mach-imx/hab.c:879: undefined reference to `fuse_read'
>
> fuse_read() comes from SPL_MXC_OCOTP, which depends on SPL_DRIVERS_MISC,
> since commit 251a3053b1e6 ("misc: imx: remove DM dependency for ocotp
> driver in SPL").
>
> Select SPL_DRIVERS_MISC in the SPL case to fix this build issue.
>
> Reported-by: Lisandro Pérez Meyer 
> Signed-off-by: Fabio Estevam 
> ---
>  arch/arm/mach-imx/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
> index abd48d42583a..c34bc25c0bfb 100644
> --- a/arch/arm/mach-imx/Kconfig
> +++ b/arch/arm/mach-imx/Kconfig
> @@ -54,6 +54,7 @@ config IMX_HAB
> bool "Support i.MX HAB features"
> depends on ARCH_MX7 || ARCH_MX6 || ARCH_MX5 || ARCH_IMX8M || 
> ARCH_MX7ULP
> select FSL_CAAM if HAS_CAAM
> +   select SPL_DRIVERS_MISC if SPL
> imply CMD_DEKBLOB if HAS_CAAM
> help
>   This option enables the support for secure boot (HAB).
> --
> 2.34.1

I actually tested this, so, should I reply with Reviewed-By?


-- 
Lisandro Pérez Meyer
Embedded Platform Engineer


[PATCH 0/1] Add PWM clock support for imx8mn.

2023-12-11 Thread Nicolas Heemeryck
This patch intends to bring PWM clock support on imx8mn based on the
Linux kernel and other imx8m.


Nicolas Heemeryck (1):
  clk: imx8mn: add pwm clocks

 drivers/clk/imx/clk-imx8mn.c | 30 ++
 1 file changed, 30 insertions(+)

-- 
2.34.1


-- 
- Confidential -


[PATCH 1/1] clk: imx8mn: add pwm clocks

2023-12-11 Thread Nicolas Heemeryck
Based on Linux kernel 6.7-rc4, add necessary clocks for the PWM
controllers.

Signed-off-by: Nicolas Heemeryck 

---

 drivers/clk/imx/clk-imx8mn.c | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/drivers/clk/imx/clk-imx8mn.c b/drivers/clk/imx/clk-imx8mn.c
index 692823e74b88..457acb8a401e 100644
--- a/drivers/clk/imx/clk-imx8mn.c
+++ b/drivers/clk/imx/clk-imx8mn.c
@@ -83,6 +83,20 @@ static const char *imx8mn_i2c3_sels[] = {"clock-osc-24m", 
"sys_pll1_160m", "sys_
 static const char *imx8mn_i2c4_sels[] = {"clock-osc-24m", "sys_pll1_160m", 
"sys_pll2_50m", "sys_pll3_out", "audio_pll1_out",
 "video_pll_out", "audio_pll2_out", 
"sys_pll1_133m", };
 
+#ifndef CONFIG_SPL_BUILD
+static const char *imx8mn_pwm1_sels[] = {"clock-osc-24m", "sys_pll2_100m", 
"sys_pll1_160m", "sys_pll1_40m",
+"sys_pll3_out", "clk_ext1", 
"sys_pll1_80m", "video_pll_out", };
+
+static const char *imx8mn_pwm2_sels[] = {"clock-osc-24m", "sys_pll2_100m", 
"sys_pll1_160m", "sys_pll1_40m",
+"sys_pll3_out", "clk_ext1", 
"sys_pll1_80m", "video_pll_out", };
+
+static const char *imx8mn_pwm3_sels[] = {"clock-osc-24m", "sys_pll2_100m", 
"sys_pll1_160m", "sys_pll1_40m",
+"sys_pll3_out", "clk_ext2", 
"sys_pll1_80m", "video_pll_out", };
+
+static const char *imx8mn_pwm4_sels[] = {"clock-osc-24m", "sys_pll2_100m", 
"sys_pll1_160m", "sys_pll1_40m",
+"sys_pll3_out", "clk_ext2", 
"sys_pll1_80m", "video_pll_out", };
+#endif
+
 static const char *imx8mn_wdog_sels[] = {"clock-osc-24m", "sys_pll1_133m", 
"sys_pll1_160m", "m7_alt_pll",
 "sys_pll2_125m", "sys_pll3_out", 
"sys_pll1_80m", "sys_pll2_166m", };
 
@@ -330,6 +344,22 @@ static int imx8mn_clk_probe(struct udevice *dev)
clk_dm(IMX8MN_CLK_ENET1_ROOT,
   imx_clk_gate4("enet1_root_clk", "enet_axi",
   base + 0x40a0, 0));
+   clk_dm(IMX8MN_CLK_PWM1,
+  imx8m_clk_composite("pwm1", imx8mn_pwm1_sels, base + 0xb380));
+   clk_dm(IMX8MN_CLK_PWM2,
+  imx8m_clk_composite("pwm2", imx8mn_pwm2_sels, base + 0xb400));
+   clk_dm(IMX8MN_CLK_PWM3,
+  imx8m_clk_composite("pwm3", imx8mn_pwm3_sels, base + 0xb480));
+   clk_dm(IMX8MN_CLK_PWM4,
+  imx8m_clk_composite("pwm4", imx8mn_pwm4_sels, base + 0xb500));
+   clk_dm(IMX8MN_CLK_PWM1_ROOT,
+  imx_clk_gate4("pwm1_root_clk", "pwm1", base + 0x4280, 0));
+   clk_dm(IMX8MN_CLK_PWM2_ROOT,
+  imx_clk_gate4("pwm2_root_clk", "pwm2", base + 0x4290, 0));
+   clk_dm(IMX8MN_CLK_PWM3_ROOT,
+  imx_clk_gate4("pwm3_root_clk", "pwm3", base + 0x42a0, 0));
+   clk_dm(IMX8MN_CLK_PWM4_ROOT,
+  imx_clk_gate4("pwm4_root_clk", "pwm4", base + 0x42b0, 0));
 #endif
 
 #if CONFIG_IS_ENABLED(DM_SPI)
-- 
2.34.1


-- 
- Confidential -


[PATCH v2] timer: starfive: Add Starfive timer support

2023-12-11 Thread Jun Liang Tan
From: Kuan Lim Lee 

Add timer driver in Starfive SoC. It is an timer that outside
of CPU core and inside Starfive SoC.

Signed-off-by: Kuan Lim Lee 
Signed-off-by: Wei Liang Lim 

Changes for v2:
- correct driver name, comment, variable
---
 drivers/timer/starfive-timer.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/timer/starfive-timer.c b/drivers/timer/starfive-timer.c
index 816402fdbf..6ac7d7f1d0 100644
--- a/drivers/timer/starfive-timer.c
+++ b/drivers/timer/starfive-timer.c
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2022 StarFive, Inc. All rights reserved.
- *   Author: Lee Kuan Lim 
+ *   Author: Kuan Lim Lee 
  */
 
 #include 
@@ -48,8 +48,8 @@ static int starfive_probe(struct udevice *dev)
int ret;
 
priv->base = dev_read_addr_ptr(dev);
-   if (IS_ERR(priv->base))
-   return PTR_ERR(priv->base);
+   if (!priv->base)
+   return -EINVAL;
 
timer_channel = dev_read_u32_default(dev, "channel", 0);
priv->base = priv->base + (0x40 * timer_channel);
@@ -64,14 +64,16 @@ static int starfive_probe(struct udevice *dev)
return ret;
uc_priv->clock_rate = clk_get_rate(&clk);
 
-   /* Initiate timer, channel 0 */
-   /* Unmask Interrupt Mask */
+   /*
+* Initiate timer, channel 0
+* Unmask Interrupt Mask
+*/
writel(0, priv->base + STF_TIMER_INT_MASK);
/* Single run mode Setting */
if (dev_read_bool(dev, "single-run"))
writel(1, priv->base + STF_TIMER_CTL);
/* Set Reload value */
-   priv->timer_size = dev_read_u32_default(dev, "timer-size", 0x);
+   priv->timer_size = dev_read_u32_default(dev, "timer-size", -1U);
writel(priv->timer_size, priv->base + STF_TIMER_LOAD);
/* Enable to start timer */
writel(1, priv->base + STF_TIMER_ENABLE);
@@ -85,7 +87,7 @@ static const struct udevice_id starfive_ids[] = {
 };
 
 U_BOOT_DRIVER(jh8100_starfive_timer) = {
-   .name   = "jh8100_starfive_timer",
+   .name   = "starfive_timer",
.id = UCLASS_TIMER,
.of_match   = starfive_ids,
.probe  = starfive_probe,
-- 
2.25.1



[PATCH] imx: imx-hab: Select SPL_DRIVERS_MISC in the SPL case

2023-12-11 Thread Fabio Estevam
From: Fabio Estevam 

Selecting CONFIG_IMX_HAB=y on a SPL target, such as apalis_imx6_defconfig,
for example, leads to the following build error:

/usr/bin/arm-linux-gnueabihf-ld.bfd: arch/arm/mach-imx/hab.o: in function 
`imx_hab_is_enabled':
arch/arm/mach-imx/hab.c:879: undefined reference to `fuse_read'

fuse_read() comes from SPL_MXC_OCOTP, which depends on SPL_DRIVERS_MISC,
since commit 251a3053b1e6 ("misc: imx: remove DM dependency for ocotp
driver in SPL").

Select SPL_DRIVERS_MISC in the SPL case to fix this build issue.

Reported-by: Lisandro Pérez Meyer 
Signed-off-by: Fabio Estevam 
---
 arch/arm/mach-imx/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index abd48d42583a..c34bc25c0bfb 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -54,6 +54,7 @@ config IMX_HAB
bool "Support i.MX HAB features"
depends on ARCH_MX7 || ARCH_MX6 || ARCH_MX5 || ARCH_IMX8M || ARCH_MX7ULP
select FSL_CAAM if HAS_CAAM
+   select SPL_DRIVERS_MISC if SPL
imply CMD_DEKBLOB if HAS_CAAM
help
  This option enables the support for secure boot (HAB).
-- 
2.34.1



[PATCH v1] configs: verdin-am62: Disable SPL FIT Overlay

2023-12-11 Thread Francesco Dolcini
From: Francesco Dolcini 

Disable CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY, this is not required nor used
on verdin am62, disable it to save precious binary size.

Update defconfig using savedefconfig, this adds CONFIG_OF_LIBFDT_OVERLAY
explicitly.

Signed-off-by: Francesco Dolcini 
---
 configs/verdin-am62_a53_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/verdin-am62_a53_defconfig 
b/configs/verdin-am62_a53_defconfig
index 780860180879..cdd6ba8baed4 100644
--- a/configs/verdin-am62_a53_defconfig
+++ b/configs/verdin-am62_a53_defconfig
@@ -17,6 +17,7 @@ CONFIG_ENV_OFFSET=0xDE00
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="k3-am625-verdin-wifi-dev"
 CONFIG_SPL_TEXT_BASE=0x8008
+CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_DM_RESET=y
 CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y
@@ -33,7 +34,6 @@ CONFIG_SYS_MEMTEST_END=0xB000
 CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x8100
-CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY=y
 CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTDELAY=1
-- 
2.25.1



[PATCH 4/5] lib: vsprintf: enable '%*pb[l]' format specifier

2023-12-11 Thread lukas . funke-oss
From: Lukas Funke 

The commit enables vsprintf() to handle the '%*pb[l]' format specifier
in order to print bitmaps and its derivatives such as cpumask and
nodemask [1]. This can be used to derive kernel boot parameters from
bitmaks such as 'isolcpu' or 'nohz_full' [2].

[1] https://www.kernel.org/doc/Documentation/printk-formats.txt
[2] https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html

Signed-off-by: Lukas Funke 
---

 lib/vsprintf.c | 75 ++
 1 file changed, 75 insertions(+)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index e14c6ca9f9..abbd80ea9c 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* we use this so that we can do without the ctype library */
 #define is_digit(c)((c) >= '0' && (c) <= '9')
@@ -390,6 +391,71 @@ static char *ip4_addr_string(char *buf, char *end, u8 
*addr, int field_width,
  flags & ~SPECIAL);
 }
 
+static char *bitmap_string(char *buf, char *end, const unsigned long *bitmap,
+  int field_width, int precision, int flags)
+{
+   const int CHUNKSIZE = 32;
+   int nr_bits = max_t(int, field_width, 0);
+   int i, chunksz;
+   int first = 1;
+
+   chunksz = nr_bits & (CHUNKSIZE - 1);
+   if (chunksz == 0)
+   chunksz = CHUNKSIZE;
+
+   i = ALIGN(nr_bits, CHUNKSIZE) - CHUNKSIZE;
+   for (; i >= 0; i -= CHUNKSIZE) {
+   u32 chunkmask, val;
+   int word, bit;
+
+   chunkmask = ((1ULL << chunksz) - 1);
+   word = i / BITS_PER_LONG;
+   bit = i % BITS_PER_LONG;
+   val = (bitmap[word] >> bit) & chunkmask;
+
+   if (!first) {
+   if (buf < end)
+   *buf = ',';
+   buf++;
+   }
+   first = 0;
+
+   field_width = DIV_ROUND_UP(chunksz, 4);
+   buf = number(buf, end, val, 16, field_width, precision,
+(SMALL | ZEROPAD));
+
+   chunksz = CHUNKSIZE;
+   }
+   return buf;
+}
+
+static char *bitmap_list_string(char *buf, char *end, unsigned long *addr,
+   int field_width, int precision, int flags)
+{
+   int nr_bits = max_t(int, field_width, 0);
+   int first = 1;
+   int rbot, rtop;
+
+   for_each_set_bitrange(rbot, rtop, addr, nr_bits) {
+   if (!first) {
+   if (buf < end)
+   *buf = ',';
+   buf++;
+   }
+   first = 0;
+
+   buf = number(buf, end, rbot, 10, 0, -1, 0);
+   if (rtop == rbot + 1)
+   continue;
+
+   if (buf < end)
+   *buf = '-';
+   buf = number(++buf, end, rtop - 1, 10, 0, -1, 0);
+   }
+
+   return buf;
+}
+
 #ifdef CONFIG_LIB_UUID
 /*
  * This works (roughly) the same way as Linux's.
@@ -503,6 +569,15 @@ static char *pointer(const char *fmt, char *buf, char 
*end, void *ptr,
   precision, flags);
flags &= ~SPECIAL;
break;
+   case 'b':
+   switch (fmt[1]) {
+   case 'l':
+   return bitmap_list_string(buf, end, ptr, field_width,
+   precision, flags);
+   default:
+   return bitmap_string(buf, end, ptr, field_width,
+   precision, flags);
+   }
 #ifdef CONFIG_LIB_UUID
case 'U':
return uuid_string(buf, end, ptr, field_width, precision,
-- 
2.30.2



[PATCH 5/5] cmd: printf: forward '%p' format string specifier

2023-12-11 Thread lukas . funke-oss
From: Lukas Funke 

Forward '%p' format specifier to the underlying format logic in order
to print pointers, especially bitmaps.

Signed-off-by: Lukas Funke 
---

 cmd/printf.c | 29 +
 1 file changed, 29 insertions(+)

diff --git a/cmd/printf.c b/cmd/printf.c
index 0c6887e0d6..a90c923871 100644
--- a/cmd/printf.c
+++ b/cmd/printf.c
@@ -90,6 +90,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define WANT_HEX_ESCAPES 0
 #define PRINT_CONVERSION_ERROR 1
@@ -476,6 +477,16 @@ static int get_width_prec(const char *str)
return (int)v;
 }
 
+static int print_pointer(struct print_inf *inf, char *format,
+unsigned int fmt_length, const char *argument)
+{
+   u64 value = simple_strtoull(argument, NULL, 0);
+
+   printf_str(inf, format, &value);
+
+   return inf->error;
+}
+
 /* Print the text in FORMAT, using ARGV for arguments to any '%' directives.
  * Return advanced ARGV.
  */
@@ -536,6 +547,24 @@ static char **print_formatted(struct print_inf *inf, char 
*f, char **argv, int *
}
}
}
+   if (*f == 'p') {
+   static const char ptr_format_chars[] = "bl";
+   ++f;
+   ++direc_length;
+   char *p = strchr(ptr_format_chars, *f);
+   /* consume whole format token */
+   while (*f != '\0' && *(p++) == *f) {
+   ++f;
+   ++direc_length;
+   }
+   if (print_pointer(inf, direc_start, 
direc_length, *argv++)) {
+   printf("`%s': invalid format\n", 
direc_start);
+   /* causes main() to exit with error */
+   return saved_argv - 1;
+   }
+   f--;
+   break;
+   }
 
/* Remove "lLhz" size modifiers, repeatedly.
 * bash does not like "%lld", but coreutils
-- 
2.30.2



[PATCH 2/5] linux: bitmap.h: add 'for_each_set_bitrange' iteration macro

2023-12-11 Thread lukas . funke-oss
From: Lukas Funke 

Add 'for_each_set_bitrange' (from Linux kernel) in order to iterate
over each set bitrange of a bitmap. This becomes handy if one wants
to generate a cpu list i.e. for isolcpu or nohz_full.

Signed-off-by: Lukas Funke 
---

 include/linux/bitmap.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 0a8503af9f..9714533078 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -159,6 +159,13 @@ static inline unsigned long find_first_bit(const unsigned 
long *addr, unsigned l
 (bit) < (size);\
 (bit) = find_next_bit((addr), (size), (bit) + 1))
 
+#define for_each_set_bitrange(b, e, addr, size)\
+   for ((b) = 0;   \
+(b) = find_next_bit((addr), (size), b),\
+(e) = find_next_zero_bit((addr), (size), (b) + 1), \
+(b) < (size);  \
+(b) = (e) + 1)
+
 static inline unsigned long
 bitmap_find_next_zero_area(unsigned long *map,
   unsigned long size,
-- 
2.30.2



[PATCH 1/5] sandbox: add generic find_next_zero_bit implementation

2023-12-11 Thread lukas . funke-oss
From: Lukas Funke 

Add generic 'find_next_zero_bit' implementation in order to enable the
use of the 'for_each_set_bitrange' macro. The implementation is currently
missing for the sandbox-arch and using the function results in a linker
error.

There are more efficient implementations in the architecture specific
implementations. However, for the sandbox the implementation should be
simple and portable.

Signed-off-by: Lukas Funke 
---

 arch/sandbox/include/asm/bitops.h | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/include/asm/bitops.h 
b/arch/sandbox/include/asm/bitops.h
index f27d5e98c5..453ff005d2 100644
--- a/arch/sandbox/include/asm/bitops.h
+++ b/arch/sandbox/include/asm/bitops.h
@@ -104,8 +104,20 @@ static inline int __test_and_change_bit(int nr, void *addr)
return (old & mask) != 0;
 }
 
-extern int find_first_zero_bit(void *addr, unsigned size);
-extern int find_next_zero_bit(void *addr, int size, int offset);
+#define find_first_zero_bit(addr, size) \
+   find_next_zero_bit((addr), (size), 0)
+
+static inline int find_next_zero_bit(const unsigned long *addr, int size,
+int offset) {
+   unsigned long *p = ((unsigned long *)addr) + (offset >> 5);
+
+   while ((~(*p) & 0x1 << offset) == 0x0ll && (offset < size)) {
+   offset++;
+   p = ((unsigned long *)addr) + (offset >> 5);
+   }
+
+   return offset;
+}
 
 /*
  * This routine doesn't need to be atomic.
-- 
2.30.2



[PATCH 0/5] Enable setexpr command to print cpu-list like bitmaps

2023-12-11 Thread lukas . funke-oss
From: Lukas Funke 


This series enables the 'setexpr' command to print "cpu list"-like
bitmaps based on the printk format specifier [1].

One use-case is to pass cpu list [2] based kernel parameter like
'isolcpu', 'nohz_full', irq affinity or RCU related CPU parameter to
the kernel via a separate firmware variable without exposing the
'bootargs' variable to directly.

Example:

setexpr isolcpu_bootarg=%32pbl $myCPUisolation
&& env set bootargs "$isolcpu_bootarg"
&& bootm

[1] https://www.kernel.org/doc/Documentation/printk-formats.txt
[2] https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html



Lukas Funke (5):
  sandbox: add generic find_next_zero_bit implementation
  linux: bitmap.h: add 'for_each_set_bitrange' iteration macro
  test: cmd: setexptr: Add tests for bitmap string format
  lib: vsprintf: enable '%*pb[l]' format specifier
  cmd: printf: forward '%p' format string specifier

 arch/sandbox/include/asm/bitops.h | 16 ++-
 cmd/printf.c  | 29 
 include/linux/bitmap.h|  7 +++
 lib/vsprintf.c| 75 +++
 test/cmd/setexpr.c|  9 
 5 files changed, 134 insertions(+), 2 deletions(-)

-- 
2.30.2



[PATCH 3/5] test: cmd: setexptr: Add tests for bitmap string format

2023-12-11 Thread lukas . funke-oss
From: Lukas Funke 

Add test to test the bitmap format specifier

Signed-off-by: Lukas Funke 
---

 test/cmd/setexpr.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c
index 312593e1e3..4e1c9e983b 100644
--- a/test/cmd/setexpr.c
+++ b/test/cmd/setexpr.c
@@ -465,6 +465,15 @@ static int setexpr_test_fmt(struct unit_test_state *uts)
ut_asserteq(1, run_command("setexpr fred fmt hello% bf", 0));
/* Error exceeding maximum string length */
ut_asserteq(1, run_command("setexpr fred fmt \"%0128d\" 456", 0));
+   /* Test bitmask long string*/
+   ut_assertok(run_command("setexpr fred fmt isolcpu=%32pbl 0x1F1", 0));
+   ut_asserteq_str("isolcpu=0,4-8", env_get("fred"));
+   /* Test bitmask long string (more complicated) */
+   ut_assertok(run_command("setexpr fred fmt nohz_full=%32pbl 0x", 
0));
+   ut_asserteq_str("nohz_full=0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30", 
env_get("fred"));
+   /* Test bitmask short string*/
+   ut_assertok(run_command("setexpr fred fmt %32pb 0x", 0));
+   ut_asserteq_str("", env_get("fred"));
 
unmap_sysmem(buf);
 
-- 
2.30.2



Re: [PATCH v1 0/5] Convert recently merged T30 boards to use DM PMIC

2023-12-11 Thread Thierry Reding
On Wed, Nov 15, 2023 at 02:11:49PM -0500, Tom Rini wrote:
> On Wed, Nov 15, 2023 at 04:51:08PM +0100, Thierry Reding wrote:
> > On Mon, Nov 06, 2023 at 04:04:07PM -0500, Tom Rini wrote:
> > > On Mon, Nov 06, 2023 at 02:11:16PM +, Peter Robinson wrote:
> > > > On Mon, Nov 6, 2023 at 1:28 PM Svyatoslav Ryhel  
> > > > wrote:
> > > > >
> > > > > пн, 6 лист. 2023 р. о 15:13 Peter Robinson  
> > > > > пише:
> > > > > >
> > > > > > On Mon, Nov 6, 2023 at 11:58 AM Svyatoslav Ryhel 
> > > > > >  wrote:
> > > > > > >
> > > > > > > пн, 6 лист. 2023 р. о 13:46 Peter Robinson  
> > > > > > > пише:
> > > > > > > >
> > > > > > > > Hi Svyatoslav,
> > > > > > > >
> > > > > > > > > Since the proposed PMIC patches have been accepted, I see the 
> > > > > > > > > need
> > > > > > > > > to convert boards which I maintain to use DM drivers instead 
> > > > > > > > > of board hacks.
> > > > > > > > >
> > > > > > > > > Svyatoslav Ryhel (5):
> > > > > > > > >   board: lg-x3: convert LG Optimus 4X and Vu to use DM PMIC
> > > > > > > > >   board: endeavoru: convert HTC One X to use DM PMIC
> > > > > > > >
> > > > > > > > Is there a reason why the two above devices don't appear to 
> > > > > > > > have their
> > > > > > > > .dts files in the upstream kernel?
> > > > > > > >
> > > > > > >
> > > > > > > Yes, there is a reason. Linux maintainers treat submitters as
> > > > > > > existential enemies or as dirt at least. I was trying to work with
> > > > > > > linux but I have no desire to spend any time to upstream 
> > > > > > > endeavoru or
> > > > > > > lg_x3.
> > > > > >
> > > > > > The usual policy for acceptance into U-Boot is to have upstream 
> > > > > > review
> > > > > > in the kernel first.
> > > > > >
> > > > >
> > > > > May you point to a policy which clearly and explicitly states this as
> > > > > a mandatory condition?
> > > > 
> > > > There have been a number of devices rejected in the past until their
> > > > DT are upstream but I'll leave Tom, who I've explicitly added on cc:,
> > > > to clarify the exact policy.
> > > 
> > > Well, here is where it's tricky. I brought this up for one of the
> > > Broadcom MIPS platforms a week or two back, and Linus Walleij's point
> > > (and I'm paraphrasing) is there's not really an upstream for it to go.
> > > 
> > > What we cannot have is device tree bindings[1] that aren't upstream or
> > > worse yet conflict with the official bindings.
> > > 
> > > So the general way to resolve that is have device tree file be drop-in
> > > from the linux kernel, and what additions we must have be done via
> > > -u-boot.dtsi files. And in turn, some SoCs are better about keeping in
> > > sync with the kernel than other SoCs are.
> > > 
> > > Now, upstream being actively hostile to dts files, especially for older
> > > platforms? That's unfortunate. So long as we aren't violating the rules
> > > about bindings, the intention is that we don't have device trees that
> > > are either (a) massively out of sync with the kernel[2] or (b) kept
> > > intentionally mismatched from the kernel.
> > > 
> > > -- 
> > > Tom
> > > 
> > > [1]: There are both examples like binman that Simon is working on at
> > > least but this is more exception than intentional rule.
> > > [2]: Per our other conversions, I know the tegra ones are in this
> > > unfortunate state in general
> > 
> > On the Tegra side we've been fairly lax about the device trees in
> > U-Boot, I suppose. The assumption had always been that U-Boot would load
> > an external DTB and pass it to the kernel on boot, so keeping them both
> > in sync was never a high priority.
> > 
> > U-Boot does only a very tiny amount of what Linux does, so dropping in
> > the kernel DTB always seemed a bit overkill.
> > 
> > In either case, if this is problematic, it's something that I could take
> > a look at. Again, it's expected that the device trees are different, for
> > historical reasons, but I'd be surprised if they actually conflict with
> > one another. U-Boot's DTB was always supposed to be a subset of the
> > Linux DTB.
> 
> So, the issue with U-Boot and kernel device trees being out of sync is
> that we then can't support the model of "just pass the current DT to the
> OS". This in general is good to support because it means that even if a
> given platform isn't formally SystemReady IR certified it's still likely
> to be functional.

This is certainly not something that we ever strived for with Tegra. It
was always very clear that we needed to get the DTB from the same source
as the kernel. The vast majority of what's in the DTB is completely
useless for U-Boot because it simply doesn't support (and doesn't have
to support) a lot of the hardware that Linux supports.

One concern that I have with this policy is that for certain devices we
may just not be able to do this. Especially with some early OEM devices
I recall that they had limited storage for the bootloader. Since the DTB
needs to be embedded, a full-blown DTB from Linux might inflate the size

[PATCH v2 2/2] mtd: rawnand: omap_elm: Fix elm_init definition

2023-12-11 Thread Roger Quadros
The macro ELM_BASE is defined in mach/hardware.h and is
not visible at the omap_elm.h header file. Avoid using it
in omap_elm.h.

Reported-by: Hong Guan 
Fixes: 7363cf0581a3 ("mtd: rawnand: omap_elm: u-boot driver model support")
Signed-off-by: Roger Quadros 
---
 drivers/mtd/nand/raw/omap_elm.c | 4 ++--
 drivers/mtd/nand/raw/omap_elm.h | 6 --
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/raw/omap_elm.c b/drivers/mtd/nand/raw/omap_elm.c
index 56a2c39e4f..015ec9bc2d 100644
--- a/drivers/mtd/nand/raw/omap_elm.c
+++ b/drivers/mtd/nand/raw/omap_elm.c
@@ -185,7 +185,6 @@ void elm_reset(void)
;
 }
 
-#ifdef ELM_BASE
 /**
  * elm_init - Initialize ELM module
  *
@@ -194,10 +193,11 @@ void elm_reset(void)
  */
 void elm_init(void)
 {
+#ifdef ELM_BASE
elm_cfg = (struct elm *)ELM_BASE;
elm_reset();
-}
 #endif
+}
 
 #if CONFIG_IS_ENABLED(SYS_NAND_SELF_INIT)
 
diff --git a/drivers/mtd/nand/raw/omap_elm.h b/drivers/mtd/nand/raw/omap_elm.h
index a7f7bacb15..f3db00d55d 100644
--- a/drivers/mtd/nand/raw/omap_elm.h
+++ b/drivers/mtd/nand/raw/omap_elm.h
@@ -74,12 +74,6 @@ int elm_check_error(u8 *syndrome, enum bch_level bch_type, 
u32 *error_count,
u32 *error_locations);
 int elm_config(enum bch_level level);
 void elm_reset(void);
-#ifdef ELM_BASE
 void elm_init(void);
-#else
-static inline void elm_init(void)
-{
-}
-#endif
 #endif /* __ASSEMBLY__ */
 #endif /* __ASM_ARCH_ELM_H */
-- 
2.34.1



[PATCH v2 1/2] mtd: nand: omap_gpmc: Fix NAND in SPL for AM335x

2023-12-11 Thread Roger Quadros
AM335x uses a special driver "am335x_spl_bch.c" as SPL
NAND loader. This driver expects 1 sector at a time ECC
and doesn't work well with multi-sector ECC that was implemented in
commit 04fcd2587321 ("mtd: rawnand: omap_gpmc: Fix BCH6/16 HW based correction")

Additionally, the omap_elm driver does not support multi sector ECC and will
need more work and tests to get multi sector working correctly on all
platforms.

Switch back to 1 sector at a time read/ECC.

Fixes: 04fcd2587321 ("mtd: rawnand: omap_gpmc: Fix BCH6/16 HW based correction")
Signed-off-by: Roger Quadros 
Tested-by: Enrico Leto 
Tested-by: Heiko Schocher 
---
 drivers/mtd/nand/raw/omap_gpmc.c | 95 ++--
 1 file changed, 29 insertions(+), 66 deletions(-)

diff --git a/drivers/mtd/nand/raw/omap_gpmc.c b/drivers/mtd/nand/raw/omap_gpmc.c
index 1a5ed0de31..7345fd579b 100644
--- a/drivers/mtd/nand/raw/omap_gpmc.c
+++ b/drivers/mtd/nand/raw/omap_gpmc.c
@@ -293,7 +293,7 @@ static void __maybe_unused omap_enable_hwecc_bch(struct 
mtd_info *mtd,
break;
case OMAP_ECC_BCH8_CODE_HW:
bch_type = 1;
-   nsectors = chip->ecc.steps;
+   nsectors = 1;
if (mode == NAND_ECC_READ) {
wr_mode   = BCH_WRAPMODE_1;
ecc_size0 = BCH8R_ECC_SIZE0;
@@ -306,7 +306,7 @@ static void __maybe_unused omap_enable_hwecc_bch(struct 
mtd_info *mtd,
break;
case OMAP_ECC_BCH16_CODE_HW:
bch_type = 0x2;
-   nsectors = chip->ecc.steps;
+   nsectors = 1;
if (mode == NAND_ECC_READ) {
wr_mode   = 0x01;
ecc_size0 = 52; /* ECC bits in nibbles per sector */
@@ -345,17 +345,16 @@ static void __maybe_unused omap_enable_hwecc_bch(struct 
mtd_info *mtd,
 }
 
 /**
- * _omap_calculate_ecc_bch - Generate BCH ECC bytes for one sector
+ * omap_calculate_ecc_bch - Generate BCH ECC bytes for one sector
  * @mtd:MTD device structure
  * @dat:The pointer to data on which ecc is computed
  * @ecc_code:   The ecc_code buffer
- * @sector: The sector number (for a multi sector page)
  *
  * Support calculating of BCH4/8/16 ECC vectors for one sector
  * within a page. Sector number is in @sector.
  */
-static int _omap_calculate_ecc_bch(struct mtd_info *mtd, const u8 *dat,
-  u8 *ecc_code, int sector)
+static int __maybe_unused omap_calculate_ecc_bch(struct mtd_info *mtd, const 
u8 *dat,
+u8 *ecc_code)
 {
struct nand_chip *chip = mtd_to_nand(mtd);
struct omap_nand_info *info = nand_get_controller_data(chip);
@@ -368,7 +367,7 @@ static int _omap_calculate_ecc_bch(struct mtd_info *mtd, 
const u8 *dat,
case OMAP_ECC_BCH8_CODE_HW_DETECTION_SW:
 #endif
case OMAP_ECC_BCH8_CODE_HW:
-   ptr = &gpmc_cfg->bch_result_0_3[sector].bch_result_x[3];
+   ptr = &gpmc_cfg->bch_result_0_3[0].bch_result_x[3];
val = readl(ptr);
ecc_code[i++] = (val >>  0) & 0xFF;
ptr--;
@@ -383,21 +382,21 @@ static int _omap_calculate_ecc_bch(struct mtd_info *mtd, 
const u8 *dat,
 
break;
case OMAP_ECC_BCH16_CODE_HW:
-   val = readl(&gpmc_cfg->bch_result_4_6[sector].bch_result_x[2]);
+   val = readl(&gpmc_cfg->bch_result_4_6[0].bch_result_x[2]);
ecc_code[i++] = (val >>  8) & 0xFF;
ecc_code[i++] = (val >>  0) & 0xFF;
-   val = readl(&gpmc_cfg->bch_result_4_6[sector].bch_result_x[1]);
+   val = readl(&gpmc_cfg->bch_result_4_6[0].bch_result_x[1]);
ecc_code[i++] = (val >> 24) & 0xFF;
ecc_code[i++] = (val >> 16) & 0xFF;
ecc_code[i++] = (val >>  8) & 0xFF;
ecc_code[i++] = (val >>  0) & 0xFF;
-   val = readl(&gpmc_cfg->bch_result_4_6[sector].bch_result_x[0]);
+   val = readl(&gpmc_cfg->bch_result_4_6[0].bch_result_x[0]);
ecc_code[i++] = (val >> 24) & 0xFF;
ecc_code[i++] = (val >> 16) & 0xFF;
ecc_code[i++] = (val >>  8) & 0xFF;
ecc_code[i++] = (val >>  0) & 0xFF;
for (j = 3; j >= 0; j--) {
-   val = 
readl(&gpmc_cfg->bch_result_0_3[sector].bch_result_x[j]
+   val = readl(&gpmc_cfg->bch_result_0_3[0].bch_result_x[j]
);
ecc_code[i++] = (val >> 24) & 0xFF;
ecc_code[i++] = (val >> 16) & 0xFF;
@@ -431,22 +430,6 @@ static int _omap_calculate_ecc_bch(struct mtd_info *mtd, 
const u8 *dat,
return 0;
 }
 
-/**
- * omap_calculate_ecc_bch - ECC generator for 1 sector
- * @mtd:MTD device structure
- * @dat:   The pointer to data on which ecc is com

[PATCH v2 0/2] mtd: nand: omap_gpmc: Fix NAND for AM335x

2023-12-11 Thread Roger Quadros
Hi,

These patches fix NAND and ELM for AM335x and related legacy platforms
that use HW BCH and ELM modules.

All CI tests pass: https://github.com/u-boot/u-boot/pull/453

Changelog:

v2:
- added __maybe_unused to omap_calculate_ecc_bch. fixes CI tests
- Added Tested-by Tags
- Explained about omap_elm single sector support in commit log 

cheers,
-roger

Roger Quadros (2):
  mtd: nand: omap_gpmc: Fix NAND in SPL for AM335x
  mtd: rawnand: omap_elm: Fix elm_init definition

 drivers/mtd/nand/raw/omap_elm.c  |  4 +-
 drivers/mtd/nand/raw/omap_elm.h  |  6 --
 drivers/mtd/nand/raw/omap_gpmc.c | 95 ++--
 3 files changed, 31 insertions(+), 74 deletions(-)


base-commit: 2f0282922b2c458eea7f85c500a948a587437b63
-- 
2.34.1



[PATCH] boot: add support for fdt_fixup command in environment

2023-12-11 Thread Matthias Schiffer
The "fdt" command is convenient for making small changes to the OS FDT,
especially during development. This is easy when the kernel and FDT are
loaded separately, but can be cumbersome for FIT images, requiring to
unpack the image, manually apply overlays, etc.

Add an option to execute a command "fdt_fixup" from the environment at
the beginning of image_setup_libfdt() (after overlays are applied, and
before the other fixups).

Signed-off-by: Matthias Schiffer 
---
 boot/Kconfig |  9 +
 boot/image-fdt.c | 19 +--
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index ef71883a502..7eea935f490 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -1502,6 +1502,15 @@ if OF_LIBFDT
 
 menu "Devicetree fixup"
 
+config OF_ENV_SETUP
+   bool "Run a command from environment to set up device tree before boot"
+   depends on CMD_FDT
+   help
+ This causes U-Boot to run a command from the environment variable
+ fdt_fixup before booting into the operating system, which can use the
+ fdt command to modify the device tree. The device tree is then passed
+ to the OS.
+
 config OF_BOARD_SETUP
bool "Set up board-specific details in device tree before boot"
help
diff --git a/boot/image-fdt.c b/boot/image-fdt.c
index f10200f6474..78b5c639381 100644
--- a/boot/image-fdt.c
+++ b/boot/image-fdt.c
@@ -9,6 +9,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -608,8 +609,22 @@ int image_setup_libfdt(struct bootm_headers *images, void 
*blob,
 {
ulong *initrd_start = &images->initrd_start;
ulong *initrd_end = &images->initrd_end;
-   int ret = -EPERM;
-   int fdt_ret;
+   int ret, fdt_ret;
+
+   if (IS_ENABLED(CONFIG_OF_ENV_SETUP)) {
+   const char *fdt_fixup;
+
+   fdt_fixup = env_get("fdt_fixup");
+   if (fdt_fixup) {
+   set_working_fdt_addr(map_to_sysmem(blob));
+   ret = run_command_list(fdt_fixup, -1, 0);
+   if (ret)
+   printf("WARNING: fdt_fixup command returned 
%d\n",
+  ret);
+   }
+   }
+
+   ret = -EPERM;
 
if (fdt_root(blob) < 0) {
printf("ERROR: root node setup failed\n");
-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/



[PATCH] include: env: ti: ti_common: Run main_cpsw0_qsgmii_phyinit conditionally

2023-12-11 Thread Siddharth Vadapalli
From: Manorit Chawdhry 

The main_cpsw0_qsgmii_phyinit command is defined only for certain TI
SoCs which have the do_main_cpsw0_qsgmii_phyinit variable set.

Add a check to ensure that the main_cpsw0_qsgmii_phyinit command is run
only for such SoCs.

Signed-off-by: Manorit Chawdhry 
Signed-off-by: Siddharth Vadapalli 
---

Hello,

This patch is based on commit
65eed68772 test/py: Disable error E0611 in two cases for pylint

Regards,
Siddharth.

 include/env/ti/ti_common.env | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/env/ti/ti_common.env b/include/env/ti/ti_common.env
index f5d84216e3..f0f89a2287 100644
--- a/include/env/ti/ti_common.env
+++ b/include/env/ti/ti_common.env
@@ -25,7 +25,10 @@ run_fit=run get_fit_config; bootm 
${addr_fit}#${name_fit_config}${overlaystring}
 bootcmd_ti_mmc=
run findfdt; run init_${boot};
 #if CONFIG_CMD_REMOTEPROC
-   run main_cpsw0_qsgmii_phyinit; run boot_rprocs;
+   if test ${do_main_cpsw0_qsgmii_phyinit} -eq 1;
+   then run main_cpsw0_qsgmii_phyinit;
+   fi
+   run boot_rprocs;
 #endif
if test ${boot_fit} -eq 1;
then run get_fit_${boot}; run get_fit_overlaystring; run 
run_fit;
-- 
2.34.1



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

2023-12-11 Thread Neil Armstrong

On 11/12/2023 09:59, Jagan Teki wrote:

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 
---
  drivers/video/dw_hdmi.c  | 29 +++-
  drivers/video/meson/meson_dw_hdmi.c  | 11 ++-
  drivers/video/rockchip/rk3399_hdmi.c |  8 +++-
  drivers/video/rockchip/rk_hdmi.c |  2 +-
  drivers/video/sunxi/sunxi_dw_hdmi.c  | 11 ++-
  include/dw_hdmi.h| 14 +-
  6 files changed, 69 insertions(+), 6 deletions(-)

diff --git a/drivers/video/dw_hdmi.c b/drivers/video/dw_hdmi.c
index c4fbb18294..ea12a09407 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,37 @@ 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,
+};
+
+static void dw_hdmi_detect_phy(struct dw_hdmi *hdmi)
+{
+   if (!hdmi->data)
+   return;
+
+   /* hook Synopsys PHYs ops */
+   if (!hdmi->data->phy_force_vendor) {
+   hdmi->ops = &dw_hdmi_synopsys_phy_ops;
+   return;
+   }
+
+   /* Vendor HDMI PHYs must assign phy_ops in plat_data */
+   if (!hdmi->data->phy_ops) {
+   printf("Unsupported Vendor HDMI phy_ops\n");
+   return;
+   }
+
+   /* hook Vendor HDMI PHYs ops */
+   hdmi->ops = hdmi->data->phy_ops;
+}
+
  void dw_hdmi_init(struct dw_hdmi *hdmi)
  {
uint ih_mute;
  
+	dw_hdmi_detect_phy(hdmi);

+
/*
 * 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..63ca3ac52e 100644
--- a/drivers/video/meson/meson_dw_hdmi.c
+++ b/drivers/video/meson/meson_dw_hdmi.c
@@ -375,6 +375,15 @@ 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_cfg,


Pretty sure this should be meson_dw_hdmi_phy_init


+};
+
+static const struct dw_hdmi_plat_data dw_hdmi_meson_plat_data = {
+   .phy_force_vendor = true,
+   .phy_ops = &dw_hdmi_meson_phy_ops,
+};
+
  static int meson_dw_hdmi_probe(struct udevice *dev)
  {
struct meson_dw_hdmi *priv = dev_get_priv(dev);
@@ -397,7 +406,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.data = &dw_hdmi_meson_plat_data;
if (meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_G12A))
priv->hdmi.reg_io_width = 1;
else {
diff --git a/drivers/video/rockchip/rk3399_hdmi.c 
b/drivers/video/rockchip/rk3399_hdmi.c
index 3041360c6e..b32139a8a6 100644
--- a/drivers/video/rockchip/rk3399_hdmi.c
+++ b/drivers/video/rockchip/rk3399_hdmi.c
@@ -64,8 +64,14 @@ static const struct dm_display_ops rk3399_hdmi_ops = {
.enable = rk3399_hdmi_enable,
  };
  
+static const struct dw_hdmi_plat_data rk3399_hdmi_drv_data = {

+};
+
  static const struct udevice_id rk3399_hdmi_ids[] = {
-   { .compatible = "rockchip,rk3399-dw-hdmi" },
+   {
+   .compatible = "rockchip,rk3399-dw-hdmi",
+   .data = (ulong)&rk3399_hdmi_drv_data
+   },
{ }
  };
  
diff --git a/drivers/video/rockchip/rk_hdmi.c b/drivers/video/rockchip/rk_hdmi.c

index b75a174489..e34f532cd6 100644
--- a/drivers/video/rockchip/rk_hdmi.c
+++ b/drivers/video/rockchip/rk_hdmi.c
@@ -83,6 +83,7 @@ int rk_hdmi_of_to_plat(struct udevice *dev)
struct rk_hdmi_priv *priv = dev_get_priv(dev);
struct dw_hdmi *hdmi = &priv->hdmi;
  
+	hdmi->data = (const struct dw_hdmi_plat_data *)dev_get_driver_data(dev);

hdmi->ioaddr = (ulong)dev_read_addr(dev);
hdmi->mpll_cfg = rockchip_mpll_cfg;
hdmi->phy_cfg = rockchip_phy_config;
@@ -90,7 +91,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..4b67a1614e 100644
--- a/drivers/video/sunxi/sunxi_dw_hdmi.c
+++ b/drivers/video/sunxi/sunxi_dw_hdmi.c
@@ -369,6 +369,15 @@ sta

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

2023-12-11 Thread Jagan Teki
U-Boot 2024.01-rc4-00053-gb9f7cafdd9-dirty (Dec 11 2023 - 13:18:15 +0530)

Model: Firefly roc-rk3328-cc
DRAM:  1 GiB (effective 1022 MiB)
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

tmdsclock = 14850; chipversion = 1
In:serial
Out:   vidconsole
Err:   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 
---
 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 16/17] configs: evb-rk3328: Enable vidconsole for rk3328

2023-12-11 Thread Jagan Teki
Enable video console for Rockchip RK3328.

Signed-off-by: Jagan Teki 
---
 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 15/17] rockchip: Enable preconsole for rk3328

2023-12-11 Thread Jagan Teki
Enable and set the start address of pre-console buffer for RK3328.

Signed-off-by: Jagan Teki 
---
 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 0f54819519..093ebfbd1e 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -208,7 +208,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 14/17] ARM: dts: rk3328: Enable VOP for bootph-all

2023-12-11 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 
---
 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 @@
 &spi0 {
bootph-all;
 };
+
+&vop {
+   bootph-all;
+};
-- 
2.25.1



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

2023-12-11 Thread Jagan Teki
From: Jagan Teki 

Add support for Rockchip RK3328 VOP.

Signed-off-by: Jagan Teki 
---
 drivers/video/rockchip/Makefile |  1 +
 drivers/video/rockchip/rk3328_vop.c | 66 +
 2 files changed, 67 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..2512314e64
--- /dev/null
+++ b/drivers/video/rockchip/rk3328_vop.c
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2023 Edgeble AI Technologies Pvt. Ltd.
+ */
+
+#include 
+#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(®s->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);
+}
+
+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)&rk3328_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= &rk3328_vop_ops,
+   .bind   = rk_vop_bind,
+   .probe  = rk3328_vop_probe,
+   .priv_auto  = sizeof(struct rk_vop_priv),
+};
-- 
2.25.1



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

2023-12-11 Thread Jagan Teki
From: Jagan Teki 

Add Rockchip RK3328 HDMI Out driver.

Signed-off-by: Jagan Teki 
---
 drivers/video/rockchip/Makefile  |   1 +
 drivers/video/rockchip/rk3328_hdmi.c | 131 +++
 drivers/video/rockchip/rk_hdmi.h |   3 +
 3 files changed, 135 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..23624699ba
--- /dev/null
+++ b/drivers/video/rockchip/rk3328_hdmi.c
@@ -0,0 +1,131 @@
+// 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(&priv->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(&priv->phy);
+   if (ret) {
+   printf("failed to init phy (ret=%d)\n", ret);
+   return ret;
+   }
+
+   ret = generic_phy_power_on(&priv->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, &grf->soc_con[2]);
+   writel(RK3328_IO_CTRL_BY_HDMI, &grf->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, &grf->soc_con[4]);
+   else
+   writel(RK3328_IO_3V_DOMAIN, &grf->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 const struct dw_hdmi_plat_data dw_hdmi_rk3328_plat_data = {
+   .phy_force_vendor = true,
+   .phy_ops = &dw_hdmi_rk3328_phy_ops,
+};
+
+static int rk3328_hdmi_of_to_plat(struct udevice *dev)
+{
+   struct rk_hdmi_priv *priv = dev_get_priv(dev);
+   struct dw_hdmi *hdmi = &priv->hdmi;
+
+   hdmi->i2c_clk_high = 0x71;
+   hdmi->i2c_clk_low = 0x76;
+
+   rk_hdmi_of_to_plat(dev);
+
+   hdmi->data = &dw_hdmi_rk3328_plat_data;
+
+   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", &priv->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 = &rk3328_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 200dbaea

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

2023-12-11 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 
---
 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 RK3328_PRE_PLL_PCLK_DIV_A(x)   UPDA

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

2023-12-11 Thread Jagan Teki
From: Jagan Teki 

Add support to get the hdmiphy clock for RK3328 PCLK_HDMIPHY.

Signed-off-by: Jagan Teki 
---
 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 7fcf84f08e..5a4a555d36 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))
@@ -656,6 +660,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(&cru->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);
@@ -685,6 +699,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 09/17] clk: rockchip: rk3328: Add VOP clk support

2023-12-11 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 
---
 .../include/asm/arch-rockchip/cru_rk3328.h| 34 
 drivers/clk/rockchip/clk_rk3328.c | 83 ++-
 2 files changed, 115 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..7fcf84f08e 100644
--- a/drivers/clk/rockchip/clk_rk3328.c
+++ b/drivers/clk/rockchip/clk_rk3328.c
@@ -581,6 +581,81 @@ 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(&cru->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(&cru->clksel_con[37]);
+   div = (con & ACLK_VIO_DIV_CON_MASK) >> ACLK_VIO_DIV_CON_SHIFT;
+   parent = GPLL_HZ;
+   break;
+   default:
+   debug("%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(&cru->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(&cru->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(&cru->clksel_con[40]);
+   con = (con & DCLK_LCDC_SEL_MASK) >> DCLK_LCDC_SEL_SHIFT;
+   if (con) {
+   parent = readl(&cru->clksel_con[40]);
+   parent = (parent & DCLK_LCDC_PLL_SEL_MASK) >>
+DCLK_LCDC_PLL_SEL_SHIFT;
+   if (parent)
+   src_clk_div = DIV_ROUND_UP(GPLL_HZ, hz);
+   else
+ 

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

2023-12-11 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 
---
 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),
-   ®s->dsp_htotal_hs_end);
+   &dsp_regs->dsp_htotal_hs_end);
 
writel(V_HEAP(hsync_len + hback_porch + hactive) |
   V_HASP(hsync_len + hback_porch),
-  ®s->dsp_hact_st_end);
+  &dsp_regs->dsp_hact_st_end);
 
writel(V_VSYNC(vsync_len) |
   V_VERPRD(vsync_len + vback_porch + vactive + vfront_porch),
-  ®s->dsp_vtotal_vs_end);
+  &dsp_regs->dsp_vtotal_vs_end);
 
writel(V_VAEP(vsync_len + vback_porch + vactive)|
   V_VASP(vsync_len + vback_porch),
-  ®s->dsp_vact_st_end);
+  &dsp_regs->dsp_vact_st_end);
 
writel(V_HEAP(hsync_len + hback_porch + hactive) |
   V_HASP(hsync_len + hback_porch),
-  ®s->post_dsp_hact_info);
+  &dsp_regs->post_dsp_hact_info);
 
writel(V_VAEP(vsync_len + vback_porch + vactive)|
   V_VASP(vsync_len + vback_porch),
-  ®s->post_dsp_vact_info);
+  &dsp_regs->post_dsp_vact_info);
 
writel(0x01, ®s->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 07/17] video: rockchip: vop: Add win offset support

2023-12-11 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 
---
 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),
-  ®s->win0_act_info);
+  &win_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),
-  ®s->win0_dsp_st);
+  &win_regs->win0_dsp_st);
 
writel(V_DSP_WIDTH(hactive - 1) |
V_DSP_HEIGHT(vactive - 1),
-   ®s->win0_dsp_info);
+   &win_regs->win0_dsp_info);
 
-   clrsetbits_le32(®s->win0_color_key, M_WIN0_KEY_EN | M_WIN0_KEY_COLOR,
+   clrsetbits_le32(&win_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), ®s->win0_vir);
+   writel(V_RGB565_VIRWIDTH(hactive), &win_regs->win0_vir);
break;
case 24:
rgb_mode = RGB888;
-   writel(V_RGB888_VIRWIDTH(hactive), ®s->win0_vir);
+   writel(V_RGB888_VIRWIDTH(hactive), &win_regs->win0_vir);
break;
case 32:
default:
rgb_mode = ARGB;
-   writel(V_ARGB888_VIRWIDTH(hactive), ®s->win0_vir);
+   writel(V_ARGB888_VIRWIDTH(hactive), &win_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(®s->win0_ctrl0,
+   clrsetbits_le32(&win_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, ®s->win0_yrgb_mst);
+   writel(fbbase, &win_regs->win0_yrgb_mst);
writel(0x01, ®s->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 06/17] video: rockchip: vop: Simplify rkvop_enable

2023-12-11 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 
---
 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, &timing, &dclk_rst);
+   rkvop_enable(dev, fbbase, 1 << l2bpp, &timing, &dclk_rst);
 
ret = display_enable(disp, 1 << l2bpp, &timing);
if (ret)
-- 
2.25.1



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

2023-12-11 Thread Jagan Teki
From: Jagan Teki 

Add support for DW HDMI Setup HPD status.

Signed-off-by: Jagan Teki 
---
 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 172e6b45a6..3e0e20e59b 100644
--- a/drivers/video/dw_hdmi.c
+++ b/drivers/video/dw_hdmi.c
@@ -1080,4 +1080,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->setup_hpd)
+   hdmi->ops->setup_hpd(hdmi);
 }
diff --git a/include/dw_hdmi.h b/include/dw_hdmi.h
index d6de472cee..9a44b9e90c 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_plat_data {
-- 
2.25.1



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

2023-12-11 Thread Jagan Teki
From: Jagan Teki 

Add support for DW HDMI Read HPD status.

Signed-off-by: Jagan Teki 
---
 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 0a597206f0..172e6b45a6 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->read_hpd)
+   hdmi->ops->read_hpd(hdmi, true);
+
return 0;
 }
 
diff --git a/include/dw_hdmi.h b/include/dw_hdmi.h
index 756560e092..d6de472cee 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_plat_data {
-- 
2.25.1



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

2023-12-11 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 
---
 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 ea12a09407..0a597206f0 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 e34f532cd6..8a65f2440e 100644
--- a/drivers/video/rockchip/rk_hdmi.c
+++ b/drivers/video/rockchip/rk_hdmi.c
@@ -115,11 +115,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 4b67a1614e..513276d812 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(&priv->hdmi);
 
-   ret = dw_hdmi_phy_wait_for_hpd(&priv->hdmi);
-   if (ret < 0) {
-   debug("hdmi can not get hpd signal\n");
-   return -1;
-   }
+   ret = dw_hdmi_detect_hpd(&priv->hdmi);
+   if (ret < 0)
+   return ret;
 
dw_hdmi_init(&priv->hdmi);
 
diff --git a/include/dw_hdmi.h b/include/dw_hdmi.h
index 4ad8b39f84..756560e092 100644
--- a/include/dw_hdmi.h
+++ b/include/dw_hdmi.h
@@ -568,5 +568,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 02/17] video: dw_hdmi: Add Vendor PHY handling

2023-12-11 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 
---
 drivers/video/dw_hdmi.c  | 29 +++-
 drivers/video/meson/meson_dw_hdmi.c  | 11 ++-
 drivers/video/rockchip/rk3399_hdmi.c |  8 +++-
 drivers/video/rockchip/rk_hdmi.c |  2 +-
 drivers/video/sunxi/sunxi_dw_hdmi.c  | 11 ++-
 include/dw_hdmi.h| 14 +-
 6 files changed, 69 insertions(+), 6 deletions(-)

diff --git a/drivers/video/dw_hdmi.c b/drivers/video/dw_hdmi.c
index c4fbb18294..ea12a09407 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,37 @@ 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,
+};
+
+static void dw_hdmi_detect_phy(struct dw_hdmi *hdmi)
+{
+   if (!hdmi->data)
+   return;
+
+   /* hook Synopsys PHYs ops */
+   if (!hdmi->data->phy_force_vendor) {
+   hdmi->ops = &dw_hdmi_synopsys_phy_ops;
+   return;
+   }
+
+   /* Vendor HDMI PHYs must assign phy_ops in plat_data */
+   if (!hdmi->data->phy_ops) {
+   printf("Unsupported Vendor HDMI phy_ops\n");
+   return;
+   }
+
+   /* hook Vendor HDMI PHYs ops */
+   hdmi->ops = hdmi->data->phy_ops;
+}
+
 void dw_hdmi_init(struct dw_hdmi *hdmi)
 {
uint ih_mute;
 
+   dw_hdmi_detect_phy(hdmi);
+
/*
 * 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..63ca3ac52e 100644
--- a/drivers/video/meson/meson_dw_hdmi.c
+++ b/drivers/video/meson/meson_dw_hdmi.c
@@ -375,6 +375,15 @@ 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_cfg,
+};
+
+static const struct dw_hdmi_plat_data dw_hdmi_meson_plat_data = {
+   .phy_force_vendor = true,
+   .phy_ops = &dw_hdmi_meson_phy_ops,
+};
+
 static int meson_dw_hdmi_probe(struct udevice *dev)
 {
struct meson_dw_hdmi *priv = dev_get_priv(dev);
@@ -397,7 +406,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.data = &dw_hdmi_meson_plat_data;
if (meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_G12A))
priv->hdmi.reg_io_width = 1;
else {
diff --git a/drivers/video/rockchip/rk3399_hdmi.c 
b/drivers/video/rockchip/rk3399_hdmi.c
index 3041360c6e..b32139a8a6 100644
--- a/drivers/video/rockchip/rk3399_hdmi.c
+++ b/drivers/video/rockchip/rk3399_hdmi.c
@@ -64,8 +64,14 @@ static const struct dm_display_ops rk3399_hdmi_ops = {
.enable = rk3399_hdmi_enable,
 };
 
+static const struct dw_hdmi_plat_data rk3399_hdmi_drv_data = {
+};
+
 static const struct udevice_id rk3399_hdmi_ids[] = {
-   { .compatible = "rockchip,rk3399-dw-hdmi" },
+   {
+   .compatible = "rockchip,rk3399-dw-hdmi",
+   .data = (ulong)&rk3399_hdmi_drv_data
+   },
{ }
 };
 
diff --git a/drivers/video/rockchip/rk_hdmi.c b/drivers/video/rockchip/rk_hdmi.c
index b75a174489..e34f532cd6 100644
--- a/drivers/video/rockchip/rk_hdmi.c
+++ b/drivers/video/rockchip/rk_hdmi.c
@@ -83,6 +83,7 @@ int rk_hdmi_of_to_plat(struct udevice *dev)
struct rk_hdmi_priv *priv = dev_get_priv(dev);
struct dw_hdmi *hdmi = &priv->hdmi;
 
+   hdmi->data = (const struct dw_hdmi_plat_data *)dev_get_driver_data(dev);
hdmi->ioaddr = (ulong)dev_read_addr(dev);
hdmi->mpll_cfg = rockchip_mpll_cfg;
hdmi->phy_cfg = rockchip_phy_config;
@@ -90,7 +91,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..4b67a1614e 100644
--- a/drivers/video/sunxi/sunxi_dw_hdmi.c
+++ b/drivers/video/sunxi/sunxi_dw_hdmi.c
@@ -369,6 +369,15 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev)
return 0;
 }
 
+static const struct dw

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

2023-12-11 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 
---
 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 = &priv->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 00/17] video: dw_hdmi: Support Vendor PHY

2023-12-11 Thread 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

Importent:
One pontential issues is that Linux HDMI out on RK3328 has effected by
this patchset as I wouldn't find any relation or clue.

[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

The only way I can use Linux HDMI by disabling IOMMU or support
disable-iommu link for RK3328 via DT [1].

[1] https://www.spinics.net/lists/devicetree/msg605124.html

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 | 100 +-
 drivers/phy/rockchip/Kconfig  |   7 +
 drivers/phy/rockchip/Makefile |   1 +
 drivers/phy/rockchip/phy-rockchip-inno-hdmi.c | 885 ++
 drivers/video/dw_hdmi.c   |  48 +-
 drivers/video/meson/meson_dw_hdmi.c   |  11 +-
 drivers/video/rockchip/Makefile   |   2 +
 drivers/video/rockchip/rk3328_hdmi.c  | 131 +++
 drivers/video/rockchip/rk3328_vop.c   |  66 ++
 drivers/video/rockchip/rk3399_hdmi.c  |   8 +-
 drivers/video/rockchip/rk_hdmi.c  |  12 +-
 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   |  19 +-
 include/configs/evb_rk3328.h  |   5 +
 include/configs/rk3328_common.h   |   1 +
 include/dw_hdmi.h |  17 +-
 23 files changed, 1371 insertions(+), 39 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: [RESEND RFC PATCH v2 4/5] ARM: dts: stm32: support display on stm32f469-disco board

2023-12-11 Thread Patrice CHOTARD



On 11/30/23 15:40, Dario Binacchi wrote:
> Add support to Orise Tech OTM8009A display on stm32f469-disco board.
> 
> It was necessary to retrieve the framebuffer address from the device tree
> because the address returned by the video-uclass driver pointed to a memory
> area that was not usable.
> 
> Furthermore, unlike Linux, the DSI driver requires the LTDC clock to be
> properly probed. Hence, the changes made to the DSI node in
> stm32f469-disco-u-boot.dtsi.
> 
> Signed-off-by: Dario Binacchi 
> 
> ---
> 
> Changes in v2:
> - Add DRAM_SIZE macro.
> - Fix frame buffer allocation function so that it is backward compatible
>   with boards other than the one it was introduced for (i. e. 
> stm32f469-disco).
>   Tested on stm32f469-disco and stm32mp157f-dk2 boards.
> 
>  arch/arm/dts/stm32f469-disco-u-boot.dtsi |  4 +++
>  configs/stm32f469-discovery_defconfig| 13 ++
>  drivers/video/stm32/stm32_ltdc.c | 31 
>  3 files changed, 48 insertions(+)
> 
> diff --git a/arch/arm/dts/stm32f469-disco-u-boot.dtsi 
> b/arch/arm/dts/stm32f469-disco-u-boot.dtsi
> index 8e781c5a7b23..47ba9fa4a783 100644
> --- a/arch/arm/dts/stm32f469-disco-u-boot.dtsi
> +++ b/arch/arm/dts/stm32f469-disco-u-boot.dtsi
> @@ -92,7 +92,9 @@
>  
>  &dsi {
>   clocks = <&rcc 0 STM32F4_APB2_CLOCK(DSI)>,
> +  <&rcc 0 STM32F4_APB2_CLOCK(LTDC)>,
><&clk_hse>;
> + clock-names = "pclk", "px_clk", "ref";
>  };
>  
>  &gpioa {
> @@ -140,6 +142,8 @@
>  };
>  
>   + bootph-all;
> +
>   clocks = <&rcc 0 STM32F4_APB2_CLOCK(LTDC)>;
>  };
>  
> diff --git a/configs/stm32f469-discovery_defconfig 
> b/configs/stm32f469-discovery_defconfig
> index 21c5498466cd..85e795e83e7d 100644
> --- a/configs/stm32f469-discovery_defconfig
> +++ b/configs/stm32f469-discovery_defconfig
> @@ -21,6 +21,7 @@ CONFIG_CMD_GPT=y
>  # CONFIG_RANDOM_UUID is not set
>  CONFIG_CMD_MMC=y
>  # CONFIG_CMD_SETEXPR is not set
> +CONFIG_CMD_BMP=y
>  CONFIG_CMD_CACHE=y
>  CONFIG_CMD_TIMER=y
>  # CONFIG_ISO_PARTITION is not set
> @@ -40,3 +41,15 @@ CONFIG_SPI_FLASH_STMICRO=y
>  CONFIG_SPI=y
>  CONFIG_DM_SPI=y
>  CONFIG_STM32_QSPI=y
> +CONFIG_VIDEO=y
> +CONFIG_BACKLIGHT_GPIO=y
> +CONFIG_VIDEO_LCD_ORISETECH_OTM8009A=y
> +CONFIG_VIDEO_STM32=y
> +CONFIG_VIDEO_STM32_DSI=y
> +CONFIG_VIDEO_STM32_MAX_XRES=480
> +CONFIG_VIDEO_STM32_MAX_YRES=800
> +CONFIG_BMP_16BPP=y
> +CONFIG_BMP_24BPP=y
> +CONFIG_BMP_32BPP=y
> +CONFIG_DM_REGULATOR=y
> +CONFIG_DM_REGULATOR_FIXED=y
> diff --git a/drivers/video/stm32/stm32_ltdc.c 
> b/drivers/video/stm32/stm32_ltdc.c
> index 6fd90e33919d..9054db1d78b3 100644
> --- a/drivers/video/stm32/stm32_ltdc.c
> +++ b/drivers/video/stm32/stm32_ltdc.c
> @@ -495,6 +495,33 @@ static void stm32_ltdc_set_layer1(struct stm32_ltdc_priv 
> *priv, ulong fb_addr)
>   setbits_le32(priv->regs + LTDC_L1CR, LXCR_LEN);
>  }
>  
> +#if IS_ENABLED(CONFIG_TARGET_STM32F469_DISCOVERY)
> +static int stm32_ltdc_alloc_fb(struct udevice *dev)
> +{
> +#define SDRAM_SIZE 0x100 /* 128Mbit = 16 Mbyte = 0x100 */

Hi Dario,

Sorry for the delay

The SDRAM_SIZE can be retrieve using gd->ram_size, i propose to replace by this 
:
u32 sdram_size = gd->ram_size;


> + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
> + phys_addr_t cpu;
> + dma_addr_t bus;
> + u64 dma_size;
> + int ret;
> +
> + ret = dev_get_dma_range(dev, &cpu, &bus, &dma_size);
> + if (ret) {
> + dev_err(dev, "failed to get dma address\n");
> + return ret;
> + }
> +
> + uc_plat->base = bus + SDRAM_SIZE - ALIGN(uc_plat->size, uc_plat->align);
> + return 0;
> +}
> +#else
> +static inline int stm32_ltdc_alloc_fb(struct udevice *dev)
> +{
> + /* Delegate framebuffer allocation to video-uclass */
> + return 0;
> +}
> +#endif
> +
>  static int stm32_ltdc_probe(struct udevice *dev)
>  {
>   struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
> @@ -605,6 +632,10 @@ static int stm32_ltdc_probe(struct udevice *dev)
>   priv->crop_h = timings.vactive.typ;
>   priv->alpha = 0xFF;
>  
> + ret = stm32_ltdc_alloc_fb(dev);
> + if (ret)
> + return ret;
> +
>   dev_dbg(dev, "%dx%d %dbpp frame buffer at 0x%lx\n",
>   timings.hactive.typ, timings.vactive.typ,
>   VNBITS(priv->l2bpp), uc_plat->base);

Can you split this patch in 2 parts:
  _ DTS
  _ LTDC driver update

Thanks
Patrice




Re: [RESEND RFC PATCH v2 5/5] board: stm32f469-disco: add splash screen with stmicroelectronics logo

2023-12-11 Thread Patrice CHOTARD



On 11/30/23 15:40, Dario Binacchi wrote:
> Display the STMicroelectronics logo with features VIDEO_LOGO and
> SPLASH_SCREEN on stm32f469-disco board.
> 
> Signed-off-by: Dario Binacchi 
> 
> ---
> 
> Changes in v2:
> - Add Patrice Chotard's Reviewed-by tag to patches 1, 2 and 3 of the series.
> - Fix frame buffer allocation for stm32f469 discovery board.
> 
>  configs/stm32f469-discovery_defconfig |   3 +++
>  include/configs/stm32f469-discovery.h |   2 ++
>  tools/logos/stm32f469-discovery.bmp   | Bin 0 -> 18532 bytes
>  3 files changed, 5 insertions(+)
>  create mode 100644 tools/logos/stm32f469-discovery.bmp
> 
> diff --git a/configs/stm32f469-discovery_defconfig 
> b/configs/stm32f469-discovery_defconfig
> index 85e795e83e7d..b7e35aeae200 100644
> --- a/configs/stm32f469-discovery_defconfig
> +++ b/configs/stm32f469-discovery_defconfig
> @@ -42,12 +42,15 @@ CONFIG_SPI=y
>  CONFIG_DM_SPI=y
>  CONFIG_STM32_QSPI=y
>  CONFIG_VIDEO=y
> +CONFIG_VIDEO_LOGO=y
>  CONFIG_BACKLIGHT_GPIO=y
>  CONFIG_VIDEO_LCD_ORISETECH_OTM8009A=y
>  CONFIG_VIDEO_STM32=y
>  CONFIG_VIDEO_STM32_DSI=y
>  CONFIG_VIDEO_STM32_MAX_XRES=480
>  CONFIG_VIDEO_STM32_MAX_YRES=800
> +CONFIG_SPLASH_SCREEN=y
> +CONFIG_SPLASH_SCREEN_ALIGN=y
>  CONFIG_BMP_16BPP=y
>  CONFIG_BMP_24BPP=y
>  CONFIG_BMP_32BPP=y
> diff --git a/include/configs/stm32f469-discovery.h 
> b/include/configs/stm32f469-discovery.h
> index 62a7e9af0c56..75bb9cd8d06f 100644
> --- a/include/configs/stm32f469-discovery.h
> +++ b/include/configs/stm32f469-discovery.h
> @@ -31,6 +31,8 @@
>   "scriptaddr=0x00418000\0"   \
>   "pxefile_addr_r=0x00428000\0" \
>   "ramdisk_addr_r=0x00438000\0"   \
> + "splashimage=0x00448000\0" \
> + "splashpos=m,m\0" \
>   BOOTENV
>  
>  #endif /* __CONFIG_H */
> diff --git a/tools/logos/stm32f469-discovery.bmp 
> b/tools/logos/stm32f469-discovery.bmp
> new file mode 100644
> index 
> ..ecc8d984218fb13fddf0ba9cf68f2cfad829e289
> GIT binary patch
> literal 18532
> zcmeI4cXZX&w(r;65wa7qNk~Y5gbqmv5Fw!j5+O7xl9*5>^j-qed+)tS@6wBaRB3{M
> zG^rvTq<29PJ?imP-e<18^`MV)eL3Teaql13aUl7vHRoJ&eP>
> z%wT@IEylFuj~FL^jJa0Tn0Xc4f9!w`nis$P&puSCQMcE$Pk$_ux+`yR-Z4+5RH;%y
> z?c2AH;7{iH^XL1#;d|MuNYiPtO8m=zEccuLUc7i=rj8tL{`t>;n(v=~XLfJfVn+4u
> zWiDU5VCn>CGXMC;KTO@od?q<8o7uN>r}_EkpUhwX`d8EO?IiP$zyIB&6v$~VpTA)K
> z_P4*8AHM&S`O9DaV*d2q_oiOaLS|rxcIM{w>!w$Wrlvu35%ZUye>UrvFE{t^-Zg)P
> zu4|(P=Bvk#%nv{OV3y6BV{UwT&0M>3*|d4Hs`=*YZ%mJ-Y39#A{bas<_O1Ey>Q&RP
> zO)GQh+&R-IrnuR+YlrF5u%3B;_H5I#N+t8>KmXYbN$+HyeD#$X(7vtNw04a-@bSkc
> zEiTr4{p6{6_RTZXA*r_c```a&K0k57tX#0boIQDx=f9h;pFTAUr%yA-4<9zSZd^A#
> zn>8_KPn|OBmM%5z-l}0brY4(K)e_Cog9pvV)vLhZXVbP;b#wjNHPftO9Bcn*zBql_
> z^l8;&iusQ
> zKHawu`se1{nKNem!2V`f*DmJAKmB07`|ew_XZv<@>a)+xl}i`Rkpl-z|F*5oiuv zlL}?P^-FX2&TVu5-d%I(lfCA|kt3#gVgmZ#Ftf&wGxzS?F$< zHBY~KVt)GJM>D!_Z!@-kU-KM2hjvLfy<0Xjj~+fS5AWYMTi1VJ9zT3&x}`M&^DAce
> zmaS&W@L}fO-8*L4+&O0T;)Uk${{3d@oZ0N}p;@zdu{nMGxVd!Uym|WMiP^qkqglCd
> zp&8k$r#b)m=jP6>o95ydUzlwh*PB5d+ncrTzi(D8T42Tv=x06y?;n5s(QH}2&P*FM
> z!aTTt&)mIz%Y1g|koo56*XH)k8)o5q)6FNlcA1SUSDGWN`@ynh=>5!`Vo#HX3^sEo
> zO~h}$G)rdAH1nrUF(;26H6MMr(JY$r9{6p=X8X;$m_wF$t
> zu2~IkpP0?-)|v@}2C#=?tasBqxOWd9dW`O8&5W_5&BVd1F?o`iK6<3tuxh3Gbnjm5
> ze$_0WH_u!=f6hF7aNk@wd)7R9@W33{vj?6rX7aG1=GdWwX6CrDX34BsX7+^f=EAuz
> z%txCxn*Dornc>~KniEG4n-M*_ne{7Im@)nOn8h<@n4Oz8n>9<8m|a^po6qshJ7BSG
> z!+K)mv6(bHu|NHm zD#2c@#7hc@p9KB@&bN&O${3j z(UL>1N?G|rg1=+_hC$M4*(N>?Z)qs`WFc~HNu z4$@H`NjCXfrppK@%Sf6eeGBDvBdz5EvTDmzDI}| z;*j<-73yfYFNb`LjFd&}!dpV*q%=~Rc}nAqv44xh&w#*osb?vU$(k$%sr}%Ole%S$
> z!%-Q!P<}Rca~6;Y2@5u?ADGKXu*{SoB$SpXaD;+NLMG_><1h8)4r5cqQCcOoNHmft
> z!SJ|bn0TqQBqQgfW9B!dl01}Z(%xaDvV1C)7 zU%qy{CgY`p^pK;{NStV```#`eNEa;8S zSq4c02sPrVoa~g{@aC2; zE1@y6LT0n$=hB}Q{PC#b*g6{+Ijt4u%bVcS%2!dV#EuGMNvGXW19@9kNmKSS9UG;|
> z>+-FP5(hno6C2M!N^zw5!|Bf+KmSGQYr5wml9QdhiLQazp*)o9k z{S9k%VvVoSe-Zm!AlK3QoCKojN>HmS-K0R0+a~L!mZPzha zUv+#q9-S^1LBNSsZb~tpN-?T4rJ%{jDy*8>pj|iFFKZ>4DDjmcG7H=Fw|E4xehEA`
> zhFupB2M7g91<)ETPcy40T?B_}j77jTkm#r+eqc3N)_}ND#1WB4L3}&9 zfKf0$mJKa#L0OMDuEc1NypDD5OLunTBGN8PJP|xmT&!K6xV#}HWepg2X9r_t637Lz
> z13z}qQmRNYl8S*vQ6wiY?qd8Z68eCj3$DEQ$uXXfOCE7y87GK;B2AFmT3WDzgIykC
> zPfsKoEJEcotn)5TL&?5`{;a1-R_(?nb={4f^7G5{aW0~= zH<8DzI9Semd3*UXzg3QilPF9D{X3droZe)bfp}JVbZI7SBm~}r*uaICC9s#R=;Y(0
> zn&rdidxNhx_N*^O*lP>9MD_}`GUD;j8sIn^Uvsk0K;rbWq&R$;jgb?wQ64h88L!ot
> z$xa>|futPlH7_ftAw7U>SeRY+hVCG7;6hI)KK+^Mi3ZVfTPCt zoaExUF&>|nmHj0@o~7Bdr?f-%FygkJ_@IX`qa%oc_HdO4*MSn^>rEct4c_;e3t@#k
> z9!%?^>r`@eDYO|*{BI@Cp9R~uWiR7ZWDeuG zLD4vZ&y@oIJ>-TSMBm5wR4pV7WW{+le^tf81EEUAoBgoFF^OZow!9 zLKqt=SNVIP?2;lDp{A0~a|p9L(QyjYkEJamO(Y+GcOeryz0@9=@yQfMYO{lT z4&56w5+`+JEkCc~+iIOKyg8Cx6a#6s&Q4@`%N%J2ZaJYFN@h`Cj*w;Y)K;^$NK%RA
> zki6CIEF3Jdi36(a#J1YHIyQIPt1#B~#)jD5W3O#UeP0UTbMvrIJ&-!VF3KTu3enO=
> zLYa>wL*;>@Jh`9=&jDavhdt~E zTQQ!K{WiB=v5j@#B@QdIe}8gDA@V>L_U}uLU(C!FnZ`aG;8=h>swmz zSov*i+J~y{js17aYOFW~izZ7&X~FNOr3yUZ_*4h%P@Y^@fNYeX{JKCUhz~JW3NI}J