Re: [PATCH v2 9/9] usb: xhci: Fix root hub descriptor

2023-02-21 Thread Marek Vasut

On 2/21/23 10:28, Mark Kettenis wrote:

Date: Tue, 21 Feb 2023 01:46:22 +0100
From: Marek Vasut 


Hi Marek,


On 2/21/23 00:45, Simon Glass wrote:

On Sat, 21 Jan 2023 at 12:28, Mark Kettenis  wrote:


When a system has multiple XHCI controllers, some of the
properties described in the descriptor of the root hub (such as
the number of ports) might differ between controllers.  Fix this
by switching from a single global hub descriptor to a hub
descriptor per controller.

Signed-off-by: Mark Kettenis 
Reviewed-by: Marek Vasut 
---
   drivers/usb/host/xhci.c | 15 ---
   include/usb/xhci.h  |  1 +
   2 files changed, 9 insertions(+), 7 deletions(-)


Tested on: Chromebook Brya (Intel Alder Lake):
Tested-by: Simon Glass 


Mark, do you plan to pick the entire series via some apple tree or shall
I pick the USB parts via USB tree ? If the later, then please collect
the AB/RB tags and send me just the two xhci patches separately. If the
former, no action is needed.


Tom already merged the whole series into master a few weeks ago.  Not
sure why Simon thought it made sense to add his Tested-by tags when
the patch in question is already on master.


Uh, well, then all is good, thanks !


Re: [PATCH v2 RESEND 0/6] Update Chameleon v3 configuration

2023-02-21 Thread Marek Vasut

On 2/21/23 16:17, Paweł Anikiel wrote:

These changes add the third chameleon variation and make it easier to
deploy images to different boards.

v2 changes:
  - rename chameleonv3.dts to .dtsi
  - add missing CONFIG_SPL_MAX_SIZE symbol

Paweł Anikiel (6):
   socfpga: chameleonv3: Enable ext4 in SPL
   socfpga: chameleonv3: Move environment to a text file
   arm: dts: chameleonv3: Override chameleonv3 bitstream names
   arm: dts: chameleonv3: Rename chameleonv3.dts to .dtsi
   arm: dts: chameleonv3: Add 270-2 variant
   chameleonv3: Convert CONFIG_SPL_MAX_SIZE to Kconfig

  arch/arm/dts/Makefile   |  1 +
  ...eleonv3.dts => socfpga_arria10_chameleonv3.dtsi} |  0
  .../socfpga_arria10_chameleonv3_270_2-u-boot.dtsi   | 12 
  arch/arm/dts/socfpga_arria10_chameleonv3_270_2.dts  |  5 +
  .../socfpga_arria10_chameleonv3_270_3-u-boot.dtsi   |  4 
  arch/arm/dts/socfpga_arria10_chameleonv3_270_3.dts  |  2 +-
  .../socfpga_arria10_chameleonv3_480_2-u-boot.dtsi   |  4 
  arch/arm/dts/socfpga_arria10_chameleonv3_480_2.dts  |  2 +-
  board/google/chameleonv3/environment.txt| 13 +
  configs/socfpga_chameleonv3_defconfig   |  2 ++
  include/configs/socfpga_chameleonv3.h   |  9 -
  11 files changed, 47 insertions(+), 7 deletions(-)
  rename arch/arm/dts/{socfpga_arria10_chameleonv3.dts => 
socfpga_arria10_chameleonv3.dtsi} (100%)
  create mode 100644 arch/arm/dts/socfpga_arria10_chameleonv3_270_2-u-boot.dtsi
  create mode 100644 arch/arm/dts/socfpga_arria10_chameleonv3_270_2.dts
  create mode 100644 board/google/chameleonv3/environment.txt


Applied all, thanks.

Please just keep an eye on this and let me know if this doesn't land in 
mainline in like a week or so. Sorry for the delay.


[PULL] u-boot-socfpga/master

2023-02-21 Thread Marek Vasut

The following changes since commit 4eb7c5030d3f3c707c02a64dc8ea90de3da89928:

  Merge tag 'efi-2023-04-rc3' of 
https://source.denx.de/u-boot/custodians/u-boot-efi (2023-02-19 17:03:30 
-0500)


are available in the Git repository at:

  git://git.denx.de/u-boot-socfpga.git master

for you to fetch changes up to 52b8fca7178afdcacb31cfcdfea9429779d084a1:

  chameleonv3: Convert CONFIG_SPL_MAX_SIZE to Kconfig (2023-02-22 
00:28:39 +0100)



Paweł Anikiel (6):
  socfpga: chameleonv3: Enable ext4 in SPL
  socfpga: chameleonv3: Move environment to a text file
  arm: dts: chameleonv3: Override chameleonv3 bitstream names
  arm: dts: chameleonv3: Rename chameleonv3.dts to .dtsi
  arm: dts: chameleonv3: Add 270-2 variant
  chameleonv3: Convert CONFIG_SPL_MAX_SIZE to Kconfig

 arch/arm/dts/Makefile 
|  1 +
 arch/arm/dts/{socfpga_arria10_chameleonv3.dts => 
socfpga_arria10_chameleonv3.dtsi} |  0
 arch/arm/dts/socfpga_arria10_chameleonv3_270_2-u-boot.dtsi 
| 12 
 arch/arm/dts/socfpga_arria10_chameleonv3_270_2.dts 
|  5 +
 arch/arm/dts/socfpga_arria10_chameleonv3_270_3-u-boot.dtsi 
|  4 
 arch/arm/dts/socfpga_arria10_chameleonv3_270_3.dts 
|  2 +-
 arch/arm/dts/socfpga_arria10_chameleonv3_480_2-u-boot.dtsi 
|  4 
 arch/arm/dts/socfpga_arria10_chameleonv3_480_2.dts 
|  2 +-
 board/google/chameleonv3/environment.txt 
| 13 +
 configs/socfpga_chameleonv3_defconfig 
|  2 ++
 include/configs/socfpga_chameleonv3.h 
|  9 -

 11 files changed, 47 insertions(+), 7 deletions(-)
 rename arch/arm/dts/{socfpga_arria10_chameleonv3.dts => 
socfpga_arria10_chameleonv3.dtsi} (100%)
 create mode 100644 
arch/arm/dts/socfpga_arria10_chameleonv3_270_2-u-boot.dtsi

 create mode 100644 arch/arm/dts/socfpga_arria10_chameleonv3_270_2.dts
 create mode 100644 board/google/chameleonv3/environment.txt


Re: [PATCH v2] usb: dwc3: Use the devm_gpiod_get_optional() API for reset gpio

2023-02-21 Thread Marek Vasut

On 1/13/23 06:12, Venkatesh Yadav Abbarapu wrote:

As the "reset-gpios" property is optional, don't return the
error and just skip the gpio reset sequence.

Signed-off-by: Venkatesh Yadav Abbarapu 
---
Changes in v2:
- Replaced the gpio_request_by_name() the API with
devm_gpiod_get_optional().


The PX30 seems to fail to build:

https://source.denx.de/u-boot/custodians/u-boot-usb/-/jobs/580968


Re: [PATCH v4 00/10] usb: dwc3: Refactor dwc3-generic and apply to dwc3-uniphier

2023-02-21 Thread Marek Vasut

On 2/22/23 03:00, Kunihiko Hayashi wrote:

Hi Marek,

On 2023/02/21 0:53, Marek Vasut wrote:

On 2/20/23 06:50, Kunihiko Hayashi wrote:

This series achieves refactoring of dwc3-generic.

First, dwc3-generic allows DT controller nodes to be children of glue
nodes,
but outside of glue nodes.

To achieve this goal, define a glue-specific function to get controller
node,
look up more reference clocks in the controller node, and initialize
clocks
in children of glue node before access to the controller,

Next, this series exports the structures and functions from the driver
source
to the header, and replaces dwc3-uniphier driver as one implementation
using
them. This expects dwc3-generic to prevent more SoC-dependent codes.

The dwc3-uniphier has original USB node, however, tentatively added its
own
node dedicated to U-Boot. After this refactoring, the driver needs to 
add

clock entries and PHY driver to enable them corresponding to the
properties
in the original node.

PATCH 1 has been provided below.

https://patchwork.ozlabs.org/project/uboot/patch/20221215223822.137739-1-ma...@denx.de/

PATCH 2 is based on the suggested patch from Marek.

PATCH 4-5 and 9-10 have been already reviewed in the previous v1.
    https://lists.denx.de/pipermail/u-boot/2023-January/505689.html

I think this series is good to go. Do you want to pull this through the
uniphier git tree and send PR to Tom that way , or shall I pick it all
via usb git tree ? I think the former option is better.


Currently I don't have the public uniphier git tree and
the maintainership, so I'd like to choose the latter at the moment.
Colud you please pick it now?


Applied to usb/next , thanks .

+CC Tom, I think it would be good to get you a git tree for the uniphier 
stuff , what do you think ?


Re: [PATCH v2] usb: dwc3: Use the devm_gpiod_get_optional() API for reset gpio

2023-02-22 Thread Marek Vasut

On 2/22/23 08:01, Michal Simek wrote:



On 2/22/23 02:06, Marek Vasut wrote:

On 1/13/23 06:12, Venkatesh Yadav Abbarapu wrote:

As the "reset-gpios" property is optional, don't return the
error and just skip the gpio reset sequence.

Signed-off-by: Venkatesh Yadav Abbarapu 
---
Changes in v2:
- Replaced the gpio_request_by_name() the API with
devm_gpiod_get_optional().


The PX30 seems to fail to build:

https://source.denx.de/u-boot/custodians/u-boot-usb/-/jobs/580968


Doesn't look usb related.

+Please report this bug.
+make[4]: *** [scripts/Makefile.build:257: spl/drivers/mmc/mmc.o] Error 1
+make[3]: *** [scripts/Makefile.build:397: spl/drivers/mmc] Error 2
+make[2]: *** [scripts/Makefile.spl:533: spl/drivers] Error 2

Can you please double check it?


u-boot/master without this patch built fine, usb/next just built fine 
too. I did retrigger the failing build to see if this is transient 
failure, but it would be good if someone at xilinx could build-test the 
px30 too .


[PULL] u-boot-usb/next

2023-02-22 Thread Marek Vasut

The following changes since commit 4eb7c5030d3f3c707c02a64dc8ea90de3da89928:

  Merge tag 'efi-2023-04-rc3' of 
https://source.denx.de/u-boot/custodians/u-boot-efi (2023-02-19 17:03:30 
-0500)


are available in the Git repository at:

  git://source.denx.de/u-boot-usb.git next

for you to fetch changes up to a073f9d7779e3f911306b61b7856a2262a8148a4:

  uniphier_defconfig: Disable USB_XHCI_DWC3 (2023-02-22 04:22:30 +0100)


Kunihiko Hayashi (9):
  usb: dwc3-generic: Allow different controller DT node pattern
  usb: dwc3-generic: Add clock initialization in child DT node
  usb: dwc3-generic: Export glue structures and functions
  usb: dwc3-generic: Add the size of regs property to glue structure
  reset: uniphier: Add USB glue reset support
  clk: uniphier: Add missing USB SS-PHY clocks
  phy: socionext: Add UniPhier USB3 PHY driver
  usb: dwc3-uniphier: Use dwc3-generic instead of xhci-dwc3
  uniphier_defconfig: Disable USB_XHCI_DWC3

Marek Vasut (1):
  usb: dwc3: Look up reference clock DT phandle in both controller 
DT nodes


 configs/uniphier_v7_defconfig |   1 -
 configs/uniphier_v8_defconfig |   1 -
 drivers/clk/uniphier/clk-uniphier-sys.c   |   5 +++
 drivers/phy/socionext/Kconfig |   8 +
 drivers/phy/socionext/Makefile|   1 +
 drivers/phy/socionext/phy-uniphier-usb3.c | 168 
+++
 drivers/reset/reset-uniphier.c|  78 
+-

 drivers/usb/dwc3/Kconfig  |   4 ++-
 drivers/usb/dwc3/dwc3-generic.c   | 132 
---

 drivers/usb/dwc3/dwc3-generic.h   |  33 ++
 drivers/usb/dwc3/dwc3-uniphier.c  | 116 
+--

 11 files changed, 453 insertions(+), 94 deletions(-)
 create mode 100644 drivers/phy/socionext/phy-uniphier-usb3.c
 create mode 100644 drivers/usb/dwc3/dwc3-generic.h


Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

2023-02-22 Thread Marek Vasut

On 2/22/23 16:44, Ralph Siemsen wrote:

Clock driver for the Renesas RZ/N1 SoC family. This is based
on the Linux kernel drivers/clk/renesas/r9a06g032-clocks.c.


For starters, can you please include the exact kernel version , ideally 
commit ID, from which this way pulled, so that future updates can pull 
in the diffs from that commit easily ?


Also, can you please CC me on the entire series ?

Thanks


[PULL] u-boot-usb/master

2023-02-22 Thread Marek Vasut

The following changes since commit 4eb7c5030d3f3c707c02a64dc8ea90de3da89928:

  Merge tag 'efi-2023-04-rc3' of 
https://source.denx.de/u-boot/custodians/u-boot-efi (2023-02-19 17:03:30 
-0500)


are available in the Git repository at:

  git://source.denx.de/u-boot-usb.git master

for you to fetch changes up to 237d1f60b1db52074441bc3a5848fe98503726a2:

  usb: dwc3: Use the devm_gpiod_get_optional() API for reset gpio 
(2023-02-22 00:28:05 +0100)



Venkatesh Yadav Abbarapu (1):
  usb: dwc3: Use the devm_gpiod_get_optional() API for reset gpio

 drivers/usb/dwc3/dwc3-generic.c | 38 
+++---

 1 file changed, 19 insertions(+), 19 deletions(-)


Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

2023-02-22 Thread Marek Vasut

On 2/22/23 17:57, Ralph Siemsen wrote:

On Wed, Feb 22, 2023 at 05:06:14PM +0100, Marek Vasut wrote:

On 2/22/23 16:44, Ralph Siemsen wrote:

Clock driver for the Renesas RZ/N1 SoC family. This is based
on the Linux kernel drivers/clk/renesas/r9a06g032-clocks.c.


For starters, can you please include the exact kernel version , 
ideally commit ID, from which this way pulled, so that future updates 
can pull in the diffs from that commit easily ?


Very reasonable request, but a bit difficult to give a concise answer. 
Originally I took the driver as found in the 5.15 kernel. The driver 
actually had not changed since 5.13 commit 6bd913f54f2f ("clk: renesas: 
r9a06g032: Switch to .determine_rate()"). So that's the starting point.


I incorporated subsequent changes to the clock tables and related 
cleanups. Those were only merged into Linux much later:


2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel
f46efcc4746f clk: renesas: r9a06g032: Drop some unused fields
2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description

Linux driver also had a few other commits, but these are not applicable 
to the u-boot version due to structural changes:


6bd913f54f2f clk: renesas: r9a06g032: Switch to .determine_rate()
f2fb4fe62390 clk: renesas: Zero init clk_init_data
2182066d95c3 clk: renesas: r9a06g032: Probe possible children
885525c1e7e2 clk: renesas: r9a06g032: Export function to set dmamux
02693e11611e clk: renesas: r9a06g032: Repair grave increment error

So I would say it is "up to date" with the lastest Linux commit, even 
though it is based on an earlier version. Is there a good way to include 
the above in the commit message, succinctly?


Is this still in sync with Linux 6.1.y ? That's the latest LTS .


Also, can you please CC me on the entire series ?


I've added you to series-cc for future versions. Note that some of the 
mails are currently stuck in moderation queue (too many recipients). I 
let patman pick the default recipients.


Thanks


Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

2023-02-22 Thread Marek Vasut

On 2/22/23 18:21, Ralph Siemsen wrote:

On Wed, Feb 22, 2023 at 06:07:45PM +0100, Marek Vasut wrote:

On 2/22/23 17:57, Ralph Siemsen wrote:

On Wed, Feb 22, 2023 at 05:06:14PM +0100, Marek Vasut wrote:

On 2/22/23 16:44, Ralph Siemsen wrote:

Clock driver for the Renesas RZ/N1 SoC family. This is based
on the Linux kernel drivers/clk/renesas/r9a06g032-clocks.c.


For starters, can you please include the exact kernel version , 
ideally commit ID, from which this way pulled, so that future 
updates can pull in the diffs from that commit easily ?


Very reasonable request, but a bit difficult to give a concise 
answer. Originally I took the driver as found in the 5.15 kernel. The 
driver actually had not changed since 5.13 commit 6bd913f54f2f ("clk: 
renesas: r9a06g032: Switch to .determine_rate()"). So that's the 
starting point.


I incorporated subsequent changes to the clock tables and related 
cleanups. Those were only merged into Linux much later:


2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel
f46efcc4746f clk: renesas: r9a06g032: Drop some unused fields
2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description

Linux driver also had a few other commits, but these are not 
applicable to the u-boot version due to structural changes:


6bd913f54f2f clk: renesas: r9a06g032: Switch to .determine_rate()
f2fb4fe62390 clk: renesas: Zero init clk_init_data
2182066d95c3 clk: renesas: r9a06g032: Probe possible children
885525c1e7e2 clk: renesas: r9a06g032: Export function to set dmamux
02693e11611e clk: renesas: r9a06g032: Repair grave increment error

So I would say it is "up to date" with the lastest Linux commit, even 
though it is based on an earlier version. Is there a good way to 
include the above in the commit message, succinctly?


Is this still in sync with Linux 6.1.y ? That's the latest LTS .


Yes. Although the commits have different hashes than what I reported 
above, the 6.1.y LTS branch has the same changes.


Then please include the Linux 6.1.y commit ID , or Torvalds' tree if 
that contains new fixes . Let's not use some old/downstream stuff .


Note that the u-boot version of the driver has changed considerably from 
the Linux version. In terms of pulling future diffs over, I would be 
concerned mostly about keeping the clock tables in sync. There have been 
a few mistakes found and fixed in those already.


Are those fixes in mainline Linux ?


Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

2023-02-22 Thread Marek Vasut

On 2/22/23 19:32, Ralph Siemsen wrote:

On Wed, Feb 22, 2023 at 06:47:44PM +0100, Marek Vasut wrote:

On 2/22/23 18:21, Ralph Siemsen wrote:

On Wed, Feb 22, 2023 at 06:07:45PM +0100, Marek Vasut wrote:

On 2/22/23 17:57, Ralph Siemsen wrote:

On Wed, Feb 22, 2023 at 05:06:14PM +0100, Marek Vasut wrote:

On 2/22/23 16:44, Ralph Siemsen wrote:

Clock driver for the Renesas RZ/N1 SoC family. This is based
on the Linux kernel drivers/clk/renesas/r9a06g032-clocks.c.


For starters, can you please include the exact kernel version , 
ideally commit ID, from which this way pulled, so that future 
updates can pull in the diffs from that commit easily ?


Very reasonable request, but a bit difficult to give a concise 
answer. Originally I took the driver as found in the 5.15 kernel. 
The driver actually had not changed since 5.13 commit 6bd913f54f2f 
("clk: renesas: r9a06g032: Switch to .determine_rate()"). So that's 
the starting point.


I incorporated subsequent changes to the clock tables and related 
cleanups. Those were only merged into Linux much later:


2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel
f46efcc4746f clk: renesas: r9a06g032: Drop some unused fields
2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description

Linux driver also had a few other commits, but these are not 
applicable to the u-boot version due to structural changes:


6bd913f54f2f clk: renesas: r9a06g032: Switch to .determine_rate()
f2fb4fe62390 clk: renesas: Zero init clk_init_data
2182066d95c3 clk: renesas: r9a06g032: Probe possible children
885525c1e7e2 clk: renesas: r9a06g032: Export function to set dmamux
02693e11611e clk: renesas: r9a06g032: Repair grave increment error

So I would say it is "up to date" with the lastest Linux commit, 
even though it is based on an earlier version. Is there a good way 
to include the above in the commit message, succinctly?


Is this still in sync with Linux 6.1.y ? That's the latest LTS .


Yes. Although the commits have different hashes than what I reported 
above, the 6.1.y LTS branch has the same changes.


Then please include the Linux 6.1.y commit ID , or Torvalds' tree if 
that contains new fixes . Let's not use some old/downstream stuff .


I've amended the commit message as follows:

     Clock driver for the Renesas RZ/N1 SoC family. This is based
     on the Linux kernel drivers/clk/renesas/r9a06g032-clocks.c as found in
     commit 02693e11611e ("clk: renesas: r9a06g032: Repair grave 
increment error")

     included in Torvalds kernel v6.2. Identical code is in LTS 6.1.y.


Thank you !

Note that the u-boot version of the driver has changed considerably 
from the Linux version. In terms of pulling future diffs over, I 
would be concerned mostly about keeping the clock tables in sync. 
There have been a few mistakes found and fixed in those already.


Are those fixes in mainline Linux ?


Yes, they are in mainline:
2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel
   merged into 6.0, and also backported to earlier LTS branches
2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description
    merged into 5.19, seems to be missing from LTS branches


Use Linux 6.2.y as a base then. And please submit the missing patches 
for LTS branch inclusion too if possible, I guess they were missing 
Fixes: tag ?


Re: [PULL] u-boot-usb/next

2023-02-22 Thread Marek Vasut

On 2/22/23 19:37, Tom Rini wrote:

On Wed, Feb 22, 2023 at 04:36:08PM +0100, Marek Vasut wrote:


The following changes since commit 4eb7c5030d3f3c707c02a64dc8ea90de3da89928:

   Merge tag 'efi-2023-04-rc3' of
https://source.denx.de/u-boot/custodians/u-boot-efi (2023-02-19 17:03:30
-0500)

are available in the Git repository at:

   git://source.denx.de/u-boot-usb.git next


This seems to be based on current master and not current next, can you
please rebase?


Try below, build just passed

The following changes since commit 2bfd217a16978794b43f0a30111b7472fba232b6:

  Merge tag 'dm-next-valentine' of 
https://source.denx.de/u-boot/custodians/u-boot-dm into next (2023-02-14 
15:11:37 -0500)


are available in the Git repository at:

  git://source.denx.de/u-boot-usb.git next

for you to fetch changes up to aeb8b59f2f4aeb02ac87ec39f834177a0e260f85:

  uniphier_defconfig: Disable USB_XHCI_DWC3 (2023-02-22 19:40:11 +0100)


Kunihiko Hayashi (9):
  usb: dwc3-generic: Allow different controller DT node pattern
  usb: dwc3-generic: Add clock initialization in child DT node
  usb: dwc3-generic: Export glue structures and functions
  usb: dwc3-generic: Add the size of regs property to glue structure
  reset: uniphier: Add USB glue reset support
  clk: uniphier: Add missing USB SS-PHY clocks
  phy: socionext: Add UniPhier USB3 PHY driver
  usb: dwc3-uniphier: Use dwc3-generic instead of xhci-dwc3
  uniphier_defconfig: Disable USB_XHCI_DWC3

Marek Vasut (1):
  usb: dwc3: Look up reference clock DT phandle in both controller 
DT nodes


 configs/uniphier_v7_defconfig |   1 -
 configs/uniphier_v8_defconfig |   1 -
 drivers/clk/uniphier/clk-uniphier-sys.c   |   5 +++
 drivers/phy/socionext/Kconfig |   8 +
 drivers/phy/socionext/Makefile|   1 +
 drivers/phy/socionext/phy-uniphier-usb3.c | 168 
+++
 drivers/reset/reset-uniphier.c|  78 
+-

 drivers/usb/dwc3/Kconfig  |   4 ++-
 drivers/usb/dwc3/dwc3-generic.c   | 132 
---

 drivers/usb/dwc3/dwc3-generic.h   |  33 ++
 drivers/usb/dwc3/dwc3-uniphier.c  | 116 
+--

 11 files changed, 453 insertions(+), 94 deletions(-)
 create mode 100644 drivers/phy/socionext/phy-uniphier-usb3.c
 create mode 100644 drivers/usb/dwc3/dwc3-generic.h



Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

2023-02-22 Thread Marek Vasut

On 2/22/23 20:32, Ralph Siemsen wrote:

On Wed, Feb 22, 2023 at 07:45:45PM +0100, Marek Vasut wrote:

On 2/22/23 19:32, Ralph Siemsen wrote:

On Wed, Feb 22, 2023 at 06:47:44PM +0100, Marek Vasut wrote:

Are those fixes in mainline Linux ?


Yes, they are in mainline:
2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel
  merged into 6.0, and also backported to earlier LTS branches
2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description
   merged into 5.19, seems to be missing from LTS branches


Use Linux 6.2.y as a base then.


Okay, done.

And please submit the missing patches for LTS branch inclusion too if 
possible, I guess they were missing Fixes: tag ?


Seems it was part of a series which added support for the RTC device:
https://lore.kernel.org/all/20220421090016.79517-3-miquel.ray...@bootlin.com/
Since it is new feature, I guess one could argue that the clock table 
fix is not needed in older LTS kernels, since no driver uses that clock.

But most likely it was just overlooked. I'll check with Miquel.


Much appreciated, thanks !

+CC Miquel


[PATCH] usb: dwc3-uniphier: Imply PHY

2023-02-22 Thread Marek Vasut
Make sure the PHY subsystem is activated for the uniphier DWC3 glue
logic, as it depends on PHY implementation there.

Signed-off-by: Marek Vasut 
---
Cc: Kunihiko Hayashi 
Cc: Tom Rini 
---
 drivers/usb/dwc3/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index 7ddfa94e51..e39a133f84 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -56,6 +56,7 @@ config USB_DWC3_MESON_GXL
 config USB_DWC3_UNIPHIER
bool "DesignWare USB3 Host Support on UniPhier Platforms"
depends on ARCH_UNIPHIER && USB_DWC3
+   imply PHY
select USB_DWC3_GENERIC
select PHY_UNIPHIER_USB3
help
-- 
2.39.1



Re: [PULL] u-boot-usb/next

2023-02-22 Thread Marek Vasut

On 2/23/23 02:50, Tom Rini wrote:

On Wed, Feb 22, 2023 at 11:09:00PM +0100, Marek Vasut wrote:


On 2/22/23 19:37, Tom Rini wrote:

On Wed, Feb 22, 2023 at 04:36:08PM +0100, Marek Vasut wrote:


The following changes since commit 4eb7c5030d3f3c707c02a64dc8ea90de3da89928:

Merge tag 'efi-2023-04-rc3' of
https://source.denx.de/u-boot/custodians/u-boot-efi (2023-02-19 17:03:30
-0500)

are available in the Git repository at:

git://source.denx.de/u-boot-usb.git next


This seems to be based on current master and not current next, can you
please rebase?


Try below, build just passed

The following changes since commit 2bfd217a16978794b43f0a30111b7472fba232b6:

   Merge tag 'dm-next-valentine' of
https://source.denx.de/u-boot/custodians/u-boot-dm into next (2023-02-14
15:11:37 -0500)

are available in the Git repository at:

   git://source.denx.de/u-boot-usb.git next

for you to fetch changes up to aeb8b59f2f4aeb02ac87ec39f834177a0e260f85:

   uniphier_defconfig: Disable USB_XHCI_DWC3 (2023-02-22 19:40:11 +0100)


Kunihiko Hayashi (9):
   usb: dwc3-generic: Allow different controller DT node pattern
   usb: dwc3-generic: Add clock initialization in child DT node
   usb: dwc3-generic: Export glue structures and functions
   usb: dwc3-generic: Add the size of regs property to glue structure
   reset: uniphier: Add USB glue reset support
   clk: uniphier: Add missing USB SS-PHY clocks
   phy: socionext: Add UniPhier USB3 PHY driver
   usb: dwc3-uniphier: Use dwc3-generic instead of xhci-dwc3
   uniphier_defconfig: Disable USB_XHCI_DWC3

Marek Vasut (1):
   usb: dwc3: Look up reference clock DT phandle in both controller DT
nodes


Getting there. I see:
+(uniphier_v8 uniphier_v7) WARNING: unmet direct dependencies detected for 
PHY_UNIPHIER_USB3
+(uniphier_v8 uniphier_v7)   Depends on [n]: PHY [=n] && ARCH_UNIPHIER [=y]
+(uniphier_v8 uniphier_v7)   Selected by [y]:
+(uniphier_v8 uniphier_v7)   - USB_DWC3_UNIPHIER [=y] && USB [=y] && ARCH_UNIPHIER [=y] 
&& USB_DWC3 [=y]

Which I will take a quick run at fixing, if you don't, shortly.


I just sent this one, that should help:
[PATCH] usb: dwc3-uniphier: Imply PHY


Re: [PATCH v2 1/2] env: mmc: Clean up macro usage

2023-02-23 Thread Marek Vasut

On 2/23/23 11:41, Patrick DELAUNAY wrote:

Hi Marek,


Hi,


On 2/9/23 13:30, Marek Vasut wrote:

Consistently use 'if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID))' instead of
mix of ifdef.

Signed-off-by: Marek Vasut 
---
Cc: Patrice Chotard 
Cc: Patrick Delaunay 
Cc: Tom Rini 
---
V2: Replace CONFIG_IS_ENABLED(PARTITION_TYPE_GUID) with 
IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)

---
  env/mmc.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/env/mmc.c b/env/mmc.c
index 5b01f657a7a..d51a5579128 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -73,8 +73,7 @@ static inline int mmc_offset_try_partition(const 
char *str, int copy, s64 *val)
  if (str && !strncmp((const char *)info.name, str, 
sizeof(info.name)))

  break;
-#ifdef CONFIG_PARTITION_TYPE_GUID
-    if (!str) {
+    if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID) && !str) {
  const efi_guid_t env_guid = PARTITION_U_BOOT_ENVIRONMENT;
  efi_guid_t type_guid;
@@ -82,7 +81,6 @@ static inline int mmc_offset_try_partition(const 
char *str, int copy, s64 *val)

  if (!memcmp(&env_guid, &type_guid, sizeof(efi_guid_t)))
  break;
  }
-#endif
  }
  /* round up to info.blksz */



If I remenber, I try this test with IS_ENABLED when I propose my patch

and I have compilation issue on next line


+            uuid_str_to_bin(info.type_guid, type_guid.b, 
UUID_STR_FORMAT_GUID);



because "info.type_guid" don't exist in struct disk_partition

see ./include/part.h:59


struct disk_partition {
     lbaint_t    start;    /* # of first block in partition    */
...
#ifdef CONFIG_PARTITION_TYPE_GUID
     char    type_guid[UUID_STR_LEN + 1];    /* type GUID as string, if 
exists    */

#endif
...
};


Uh, which defconfig triggers this ?

Also, is there a way to deal with this failure without reinstating the 
ifdef ? Tom ?


Re: [PATCH v2] usb: dwc3: Use the devm_gpiod_get_optional() API for reset gpio

2023-02-23 Thread Marek Vasut

On 2/23/23 10:24, Michal Simek wrote:



On 2/22/23 16:33, Marek Vasut wrote:

On 2/22/23 08:01, Michal Simek wrote:



On 2/22/23 02:06, Marek Vasut wrote:

On 1/13/23 06:12, Venkatesh Yadav Abbarapu wrote:

As the "reset-gpios" property is optional, don't return the
error and just skip the gpio reset sequence.

Signed-off-by: Venkatesh Yadav Abbarapu 
---
Changes in v2:
- Replaced the gpio_request_by_name() the API with
devm_gpiod_get_optional().


The PX30 seems to fail to build:

https://source.denx.de/u-boot/custodians/u-boot-usb/-/jobs/580968


Doesn't look usb related.

+Please report this bug.
+make[4]: *** [scripts/Makefile.build:257: spl/drivers/mmc/mmc.o] 
Error 1

+make[3]: *** [scripts/Makefile.build:397: spl/drivers/mmc] Error 2
+make[2]: *** [scripts/Makefile.spl:533: spl/drivers] Error 2

Can you please double check it?


u-boot/master without this patch built fine, usb/next just built fine 
too. I did retrigger the failing build to see if this is transient 
failure, but it would be good if someone at xilinx could build-test 
the px30 too .


TBH. I actually was building it myself before I sent this email.


The build passed, so it was a transient error, this patch is now part of 
u-boot/master too.


Re: [PATCH v2 2/2] usb: move CONFIG_USB_HUB_DEBOUNCE_TIMEOUT to USB

2023-02-23 Thread Marek Vasut

On 2/23/23 11:10, Patrick DELAUNAY wrote:

Hi,

On 1/25/23 19:40, Heinrich Schuchardt wrote:

This configuration setting is only relevant if the board supports USB.
It should not be in the main menu but in the USB menu.

The setting is only relevant in USB host mode.

Fixes: 5454dea3137d ("usb: hub: allow to increase HUB_DEBOUNCE_TIMEOUT")
Signed-off-by: Heinrich Schuchardt 
---
v2:
let CONFIG_USB_HUB_DEBOUNCE_TIMEOUT depend on CONFIG_USB_HOST
---
  common/Kconfig  | 12 
  drivers/usb/Kconfig | 11 +++
  2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index e3a5e1be1e..0afc01b759 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1106,15 +1106,3 @@ config FDT_SIMPLEFB
  config IO_TRACE
  bool
-
-config USB_HUB_DEBOUNCE_TIMEOUT
-    int "Timeout in milliseconds for USB HUB connection"
-    depends on USB
-    default 1000
-    help
-  Value in milliseconds of the USB connection timeout, the max 
delay to
-  wait the hub port status to be connected steadily after being 
powered

-  off and powered on in the usb hub driver.
-  This define allows to increase the HUB_DEBOUNCE_TIMEOUT default
-  value = 1s because some usb device needs around 1.5s to be 
initialized
-  and a 2s value should solve detection issue on problematic USB 
keys.

diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index ebe6bf9498..94fb32d107 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -115,6 +115,17 @@ config USB_ONBOARD_HUB
    power regulator. An example for such a hub is the Microchip
    USB2514B.
+config USB_HUB_DEBOUNCE_TIMEOUT
+    int "Timeout in milliseconds for USB HUB connection"
+    default 1000
+    help
+  Value in milliseconds of the USB connection timeout, the max 
delay to
+  wait the hub port status to be connected steadily after being 
powered

+  off and powered on in the usb hub driver.
+  This define allows to increase the HUB_DEBOUNCE_TIMEOUT default
+  value = 1s because some usb device needs around 1.5s to be 
initialized
+  and a 2s value should solve detection issue on problematic USB 
keys.

+
  if USB_KEYBOARD
  config USB_KEYBOARD_FN_KEYS




Reviewed-by: Patrick Delaunay 


Applied both to usb/master, thanks for the reminder, sorry for the delay.


Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

2023-02-23 Thread Marek Vasut

On 2/23/23 08:17, Miquel Raynal wrote:

Hello Marek & Ralph,

marek.va...@mailbox.org wrote on Thu, 23 Feb 2023 01:12:49 +0100:


On 2/22/23 20:32, Ralph Siemsen wrote:

On Wed, Feb 22, 2023 at 07:45:45PM +0100, Marek Vasut wrote:

On 2/22/23 19:32, Ralph Siemsen wrote:

On Wed, Feb 22, 2023 at 06:47:44PM +0100, Marek Vasut wrote:

Are those fixes in mainline Linux ?


Yes, they are in mainline:
2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel
   merged into 6.0, and also backported to earlier LTS branches
2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description
    merged into 5.19, seems to be missing from LTS branches


Use Linux 6.2.y as a base then.


Okay, done.
   

And please submit the missing patches for LTS branch inclusion too if >> 
possible, I guess they were missing Fixes: tag ?


Seems it was part of a series which added support for the RTC device:
https://lore.kernel.org/all/20220421090016.79517-3-miquel.ray...@bootlin.com/
Since it is new feature, I guess one could argue that the clock table > fix is 
not needed in older LTS kernels, since no driver uses that clock.
But most likely it was just overlooked. I'll check with Miquel.


Much appreciated, thanks !

+CC Miquel


As Ralph rightly pointed out, even though the clock description was
wrong there was no user at that time so I did not bother with a Fixes
tag. Anyhow, as the change does only impact the RTC clock, it should be
harmless to backport if you want.


Either way is fine by me, I just want to be sure the u-boot clock tables 
are in sync with Linux as much as possible, and can be easily resynced 
in the future, that's all.


[PATCH v2] usb: dwc3-uniphier: Select PHY

2023-02-23 Thread Marek Vasut
Make sure the PHY subsystem is activated for the uniphier DWC3 glue
logic, as it depends on PHY implementation there.

Signed-off-by: Marek Vasut 
---
Cc: Kunihiko Hayashi 
Cc: Tom Rini 
---
V2: Use select
- imply means you can turn off the option and expect things to work
  "it's a good idea to have X enabled" is when to use imply
  "you must have X for Y to work" is when to use select
---
 drivers/usb/dwc3/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index 7ddfa94e51..d1665f8c58 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -57,6 +57,7 @@ config USB_DWC3_UNIPHIER
bool "DesignWare USB3 Host Support on UniPhier Platforms"
depends on ARCH_UNIPHIER && USB_DWC3
select USB_DWC3_GENERIC
+   select PHY
select PHY_UNIPHIER_USB3
help
  Support of USB2/3 functionality in Socionext UniPhier platforms.
-- 
2.39.1



[PATCH] usb: dwc3-meson-g12a: Select PHY instead of imply PHY

2023-02-23 Thread Marek Vasut
Imply means you can turn off the option and expect things to work
- "it's a good idea to have X enabled" is when to use imply
- "you must have X for Y to work" is when to use select

Use "select" here.

Signed-off-by: Marek Vasut 
---
Cc: Mattijs Korpershoek 
Cc: Neil Armstrong 
Cc: Tom Rini 
---
 drivers/usb/dwc3/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index f010291d022..e8373b30bb7 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -40,7 +40,7 @@ config SPL_USB_DWC3_GENERIC
 config USB_DWC3_MESON_G12A
bool "Amlogic Meson G12A USB wrapper"
depends on DM_USB && USB_DWC3 && ARCH_MESON
-   imply PHY
+   select PHY
help
  Select this for Amlogic Meson G12A Platforms.
  This wrapper supports Host and Peripheral operation modes.
@@ -48,7 +48,7 @@ config USB_DWC3_MESON_G12A
 config USB_DWC3_MESON_GXL
bool "Amlogic Meson GXL USB wrapper"
depends on DM_USB && USB_DWC3 && ARCH_MESON
-   imply PHY
+   select PHY
help
  Select this for Amlogic Meson GXL and GXM Platforms.
  This wrapper supports Host and Peripheral operation modes.
-- 
2.39.1



Re: [PATCH v2 1/2] env: mmc: Clean up macro usage

2023-02-23 Thread Marek Vasut

On 2/23/23 17:32, Tom Rini wrote:

On Thu, Feb 23, 2023 at 02:22:51PM +0100, Marek Vasut wrote:

On 2/23/23 11:41, Patrick DELAUNAY wrote:

Hi Marek,


Hi,


On 2/9/23 13:30, Marek Vasut wrote:

Consistently use 'if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID))' instead of
mix of ifdef.

Signed-off-by: Marek Vasut 
---
Cc: Patrice Chotard 
Cc: Patrick Delaunay 
Cc: Tom Rini 
---
V2: Replace CONFIG_IS_ENABLED(PARTITION_TYPE_GUID) with
IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)
---
   env/mmc.c | 4 +---
   1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/env/mmc.c b/env/mmc.c
index 5b01f657a7a..d51a5579128 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -73,8 +73,7 @@ static inline int mmc_offset_try_partition(const
char *str, int copy, s64 *val)
   if (str && !strncmp((const char *)info.name, str,
sizeof(info.name)))
   break;
-#ifdef CONFIG_PARTITION_TYPE_GUID
-    if (!str) {
+    if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID) && !str) {
   const efi_guid_t env_guid = PARTITION_U_BOOT_ENVIRONMENT;
   efi_guid_t type_guid;
@@ -82,7 +81,6 @@ static inline int mmc_offset_try_partition(const
char *str, int copy, s64 *val)
   if (!memcmp(&env_guid, &type_guid, sizeof(efi_guid_t)))
   break;
   }
-#endif
   }
   /* round up to info.blksz */



If I remenber, I try this test with IS_ENABLED when I propose my patch

and I have compilation issue on next line


+            uuid_str_to_bin(info.type_guid, type_guid.b,
UUID_STR_FORMAT_GUID);


because "info.type_guid" don't exist in struct disk_partition

see ./include/part.h:59


struct disk_partition {
      lbaint_t    start;    /* # of first block in partition    */
...
#ifdef CONFIG_PARTITION_TYPE_GUID
      char    type_guid[UUID_STR_LEN + 1];    /* type GUID as string, if
exists    */
#endif
...
};


Uh, which defconfig triggers this ?

Also, is there a way to deal with this failure without reinstating the ifdef
? Tom ?


It's likely on one of the platforms that disables EFI_LOADER, where this
ends up being a fail to build.  I don't recall which, but I've seen it
before. So we probably don't end up converting this to a macro check.


Can you pick the 2/2 for starters ? It is a bugfix and applies cleanly, 
so let's not block that one. I'll keep 1/2 in my queue and revisit it, I 
see the failure in CI now.


Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

2023-02-24 Thread Marek Vasut

On 2/24/23 16:14, Ralph Siemsen wrote:

On Thu, Feb 23, 2023 at 9:09 AM Miquel Raynal  wrote:


Hi Marek,

marek.va...@mailbox.org wrote on Thu, 23 Feb 2023 14:56:41 +0100:


Either way is fine by me, I just want to be sure the u-boot clock tables are in 
sync with Linux as much as possible, and can be easily resynced in the future, 
that's all.


Of course. The fix is mainline already, so on that regard we should be
fine.


Right, so mainline has all the fixes, the only thing missing there is
the "cleanup" of the clock tables, which I have done in the u-boot
version under review. Assuming this is satisfactory, I will aim to get
the same cleanup done on the clock tables in the kernel side, so they
are in sync with u-boot.


Could you at least submit the clean up to Linux and then sync the result 
to U-Boot, and indicate the Linux clock table came from commit 
 with extra patch  on top ?


I think that would be best.


Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

2023-02-24 Thread Marek Vasut

On 2/24/23 19:00, Ralph Siemsen wrote:

Hi Marek,

On Fri, Feb 24, 2023 at 12:05 PM Marek Vasut  wrote:


Could you at least submit the clean up to Linux and then sync the result
to U-Boot, and indicate the Linux clock table came from commit
 with extra patch  on top ?


Yes will do. I am refreshing my linux-side patch as we speak.


Thanks !


[PATCH 01/32] cmd: fdt: Import is_printable_string() from DTC to fix u32 misprint

2023-02-27 Thread Marek Vasut
Import is_printable_string() implementation from DTC 1.7.0 as of
DTC commit 039a994 ("Bump version to v1.7.0") . This fixes a print
of u32 property which so far used to be printed as string by U-Boot
fdt print command.

We might see the case where the parsed property value, in this case
it is a 32-bit integer, identified as a printable string or a null byte
(concatenated strings) because of its last character happens to be:
  0x00 (null character), 0xB (vertical tab character) or
  0x10 (line feed character)
In this situation, if the string is identified as printable string,
it will be displayed as character instead of hex value

When the isprint() condition is true, there are two possibilities:
  1) The character is ASCII character (except the first 32)
  2) The character is extended ASCII character

For example,
NG property in device tree:
clock-frequency = <1664>;
by default, would be displayed as
clock-frequency = "", "ýè";
and with this patch applied, would be displayed as
clock-frequency = <0x00fde800>;

Full investigation was done by Nam and Hai, patch reworked by Marek
to use common code from DTC.

Signed-off-by: Hai Pham 
Signed-off-by: Nam Nguyen 
Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 cmd/fdt.c | 36 ++--
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 1972490bdc2..bf2415661e2 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -878,41 +878,33 @@ static int fdt_parse_prop(char * const *newval, int 
count, char *data, int *len)
 static int is_printable_string(const void *data, int len)
 {
const char *s = data;
+   const char *ss, *se;
 
/* zero length is not */
if (len == 0)
return 0;
 
-   /* must terminate with zero or '\n' */
-   if (s[len - 1] != '\0' && s[len - 1] != '\n')
+   /* must terminate with zero */
+   if (s[len - 1] != '\0')
return 0;
 
-   /* printable or a null byte (concatenated strings) */
-   while (((*s == '\0') || isprint(*s) || isspace(*s)) && (len > 0)) {
-   /*
-* If we see a null, there are three possibilities:
-* 1) If len == 1, it is the end of the string, printable
-* 2) Next character also a null, not printable.
-* 3) Next character not a null, continue to check.
-*/
-   if (s[0] == '\0') {
-   if (len == 1)
-   return 1;
-   if (s[1] == '\0')
-   return 0;
-   }
+   se = s + len;
+
+   while (s < se) {
+   ss = s;
+   while (s < se && *s && isprint((unsigned char)*s))
+   s++;
+
+   /* not zero, or not done yet */
+   if (*s != '\0' || s == ss)
+   return 0;
+
s++;
-   len--;
}
 
-   /* Not the null termination, or not done yet: not printable */
-   if (*s != '\0' || (len != 0))
-   return 0;
-
return 1;
 }
 
-
 /*
  * Print the property in the best format, a heuristic guess.  Print as
  * a string, concatenated strings, a byte, word, double word, or (if all
-- 
2.39.2



[PATCH 02/32] cmd: fdt: Fix handling of empty properties for fdt get addr and fdt get size

2023-02-27 Thread Marek Vasut
It is perfectly valid to request an address or size of FDT property
without value, the only special case if requesting of the value of
FDT property without value. Invert the test such, that properties
without value still set the variable from 'fdt get addr/size' to
address of the property or size of the property, where the later
is 0.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 cmd/fdt.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index bf2415661e2..56b3585c3ac 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -446,15 +446,17 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
} else {
nodep = fdt_getprop(
working_fdt, nodeoffset, prop, &len);
-   if (len == 0) {
-   /* no property value */
-   env_set(var, "");
-   return 0;
-   } else if (nodep && len > 0) {
+   if (nodep && len >= 0) {
if (subcmd[0] == 'v') {
int index = 0;
int ret;
 
+   if (len == 0) {
+   /* no property value */
+   env_set(var, "");
+   return 0;
+   }
+
if (argc == 7)
index = simple_strtoul(argv[6], 
NULL, 10);
 
-- 
2.39.2



[PATCH 05/32] cmd: fdt: Check argc before accessing argv in fdt bootcpu

2023-02-27 Thread Marek Vasut
On case 'fdt bootcpu' is invoked without parameters, argv[2] is not
valid and this command would SEGFAULT in sandbox environment. Add
missing argc test to avoid the crash and rather print usage help
message.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 cmd/fdt.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 29d748891d0..734c9b36a07 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -597,7 +597,12 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
 * Set boot cpu id
 */
} else if (strncmp(argv[1], "boo", 3) == 0) {
-   unsigned long tmp = hextoul(argv[2], NULL);
+   unsigned long tmp;
+
+   if (argc != 3)
+   return CMD_RET_USAGE;
+
+   tmp = hextoul(argv[2], NULL);
fdt_set_boot_cpuid_phys(working_fdt, tmp);
 
/*
-- 
2.39.2



[PATCH 03/32] cmd: fdt: Fix fdt rm behavior on non-existent property and error message space

2023-02-27 Thread Marek Vasut
In case an FDT contains a node '/test-node@1234' , with no property
called 'noprop' in that node, the following command triggers a print
of help message for 'fdt' command instead of erroring out:
=> fdt rm /test-node@1234 noprop
This is because the subcommand errornously returns 'err' instead of
CMD_RET_FAILURE, fix it. Furthermore, align the number of spaces past
fdt_delprop() in error message with the rest of the code.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 cmd/fdt.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 56b3585c3ac..644b58ac4d7 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -547,16 +547,16 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
if (argc > 3) {
err = fdt_delprop(working_fdt, nodeoffset, argv[3]);
if (err < 0) {
-   printf("libfdt fdt_delprop():  %s\n",
+   printf("libfdt fdt_delprop(): %s\n",
fdt_strerror(err));
-   return err;
+   return CMD_RET_FAILURE;
}
} else {
err = fdt_del_node(working_fdt, nodeoffset);
if (err < 0) {
-   printf("libfdt fdt_del_node():  %s\n",
+   printf("libfdt fdt_del_node(): %s\n",
fdt_strerror(err));
-   return err;
+   return CMD_RET_FAILURE;
}
}
 
-- 
2.39.2



[PATCH 04/32] cmd: fdt: Fix fdt rsvmem behavior on non-existent index and error message space

2023-02-27 Thread Marek Vasut
In case 'fdt rsvmem delete index' is passed a non-existent index, one
which does not exist in 'fdt rsvmem print', then the following command
triggers a print of help message for 'fdt' command instead of erroring
out:
=> fdt rsvmem delete 1234
This is because the subcommand errornously returns 'err' instead of
CMD_RET_FAILURE, fix it. Furthermore, align the number of spaces past
fdt_del_mem_rsv() and fdt_add_mem_rsv() in error message with the rest
of the code.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 cmd/fdt.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 644b58ac4d7..29d748891d0 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -644,18 +644,18 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
err = fdt_add_mem_rsv(working_fdt, addr, size);
 
if (err < 0) {
-   printf("libfdt fdt_add_mem_rsv():  %s\n",
+   printf("libfdt fdt_add_mem_rsv(): %s\n",
fdt_strerror(err));
-   return err;
+   return CMD_RET_FAILURE;
}
} else if (argv[2][0] == 'd') {
unsigned long idx = hextoul(argv[3], NULL);
int err = fdt_del_mem_rsv(working_fdt, idx);
 
if (err < 0) {
-   printf("libfdt fdt_del_mem_rsv():  %s\n",
+   printf("libfdt fdt_del_mem_rsv(): %s\n",
fdt_strerror(err));
-   return err;
+   return CMD_RET_FAILURE;
}
} else {
/* Unrecognized command */
-- 
2.39.2



[PATCH 06/32] cmd: fdt: Check argc before accessing argv in fdt memory

2023-02-27 Thread Marek Vasut
On case 'fdt memory' is invoked without parameters, argv[2]/argv[3]
is not valid and this command would SEGFAULT in sandbox environment.
Add missing argc test to avoid the crash and rather print usage help
message.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 cmd/fdt.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 734c9b36a07..f257bee8643 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -611,6 +611,10 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
} else if (strncmp(argv[1], "me", 2) == 0) {
uint64_t addr, size;
int err;
+
+   if (argc != 4)
+   return CMD_RET_USAGE;
+
addr = simple_strtoull(argv[2], NULL, 16);
size = simple_strtoull(argv[3], NULL, 16);
err = fdt_fixup_memory(working_fdt, addr, size);
-- 
2.39.2



[PATCH 07/32] cmd: fdt: Align checksign parameter names in help text

2023-02-27 Thread Marek Vasut
The help text references 'addr' as an optional key start address,
but the explanation references the same as 'start', make sure they
both read as 'addr'. Also update the abbreviated 'addr' in the
explanation to 'address'.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 cmd/fdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index f257bee8643..279dad9fe11 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -1138,8 +1138,8 @@ static char fdt_help_text[] =
"/ - initrd start 
addr/size\n"
 #if defined(CONFIG_FIT_SIGNATURE)
"fdt checksign []  - check FIT signature\n"
-   " - addr of key blob\n"
-   "  default 
gd->fdt_blob\n"
+   "   - address of key blob\n"
+   "   default gd->fdt_blob\n"
 #endif
"NOTE: Dereference aliases by omitting the leading '/', "
"e.g. fdt print ethernet0.";
-- 
2.39.2



[PATCH 12/32] test: cmd: fdt: Rename fdt_test_resize() to fdt_test_addr_resize()

2023-02-27 Thread Marek Vasut
The 'fdt' command has a 'resize' subcommand, rename the fdt_test_resize()
to fdt_test_addr_resize() to avoid confusion about what it is testing.
There is currently no resize test.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 7974c88c0d6..a50285eafab 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -108,7 +108,7 @@ static int fdt_test_addr(struct unit_test_state *uts)
 FDT_TEST(fdt_test_addr, UT_TESTF_CONSOLE_REC);
 
 /* Test 'fdt addr' resizing an fdt */
-static int fdt_test_resize(struct unit_test_state *uts)
+static int fdt_test_addr_resize(struct unit_test_state *uts)
 {
char fdt[256];
const int newsize = sizeof(fdt) / 2;
@@ -140,7 +140,7 @@ static int fdt_test_resize(struct unit_test_state *uts)
 
return 0;
 }
-FDT_TEST(fdt_test_resize, UT_TESTF_CONSOLE_REC);
+FDT_TEST(fdt_test_addr_resize, UT_TESTF_CONSOLE_REC);
 
 /* Test 'fdt get' reading an fdt */
 static int fdt_test_get(struct unit_test_state *uts)
-- 
2.39.2



[PATCH 11/32] test: Add ut_assert_nextline_empty() empty line helper

2023-02-27 Thread Marek Vasut
Add helper macro to test for empty lines, which is an inobvious
wrapper around ut_assert_nextline("%s", "") .

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 include/test/ut.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/test/ut.h b/include/test/ut.h
index 4d00b4eeca1..2b0dab32f68 100644
--- a/include/test/ut.h
+++ b/include/test/ut.h
@@ -334,6 +334,10 @@ int ut_check_console_dump(struct unit_test_state *uts, int 
total_bytes);
return CMD_RET_FAILURE; \
}   \
 
+/* Assert that the next console output line is empty */
+#define ut_assert_nextline_empty() \
+   ut_assert_nextline("%s", "")
+
 /**
  * ut_check_free() - Return the number of bytes free in the malloc() pool
  *
-- 
2.39.2



[PATCH 15/32] test: cmd: fdt: Test alias resolution in 'fdt get value'

2023-02-27 Thread Marek Vasut
The 'fdt' command help contains the following note:
"
Dereference aliases by omitting the leading '/', e.g. fdt print ethernet0.
"
Add test for it.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 65 ++
 1 file changed, 45 insertions(+), 20 deletions(-)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 21553a2f3dc..e04ba37f19f 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -239,56 +239,81 @@ static int fdt_test_addr_resize(struct unit_test_state 
*uts)
 FDT_TEST(fdt_test_addr_resize, UT_TESTF_CONSOLE_REC);
 
 /* Test 'fdt get value' reading an fdt */
-static int fdt_test_get_value(struct unit_test_state *uts)
+static int fdt_test_get_value_common(struct unit_test_state *uts,
+const char *node)
 {
-   char fdt[4096];
-   ulong addr;
-
-   ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt)));
-   addr = map_to_sysmem(fdt);
-   set_working_fdt_addr(addr);
-
-   /* Test getting default element of /test-node@1234 node clock-names 
property */
+   /* Test getting default element of $node node clock-names property */
ut_assertok(console_record_reset_enable());
-   ut_assertok(run_command("fdt get value fdflt /test-node@1234 
clock-names", 0));
+   ut_assertok(run_commandf("fdt get value fdflt %s clock-names", node));
ut_asserteq_str("fixed", env_get("fdflt"));
ut_assertok(ut_check_console_end(uts));
 
-   /* Test getting 0th element of /test-node@1234 node clock-names 
property */
+   /* Test getting 0th element of $node node clock-names property */
ut_assertok(console_record_reset_enable());
-   ut_assertok(run_command("fdt get value fzero /test-node@1234 
clock-names 0", 0));
+   ut_assertok(run_commandf("fdt get value fzero %s clock-names 0", node));
ut_asserteq_str("fixed", env_get("fzero"));
ut_assertok(ut_check_console_end(uts));
 
-   /* Test getting 1st element of /test-node@1234 node clock-names 
property */
+   /* Test getting 1st element of $node node clock-names property */
ut_assertok(console_record_reset_enable());
-   ut_assertok(run_command("fdt get value fone /test-node@1234 clock-names 
1", 0));
+   ut_assertok(run_commandf("fdt get value fone %s clock-names 1", node));
ut_asserteq_str("i2c", env_get("fone"));
ut_assertok(ut_check_console_end(uts));
 
-   /* Test getting 2nd element of /test-node@1234 node clock-names 
property */
+   /* Test getting 2nd element of $node node clock-names property */
ut_assertok(console_record_reset_enable());
-   ut_assertok(run_command("fdt get value ftwo /test-node@1234 clock-names 
2", 0));
+   ut_assertok(run_commandf("fdt get value ftwo %s clock-names 2", node));
ut_asserteq_str("spi", env_get("ftwo"));
ut_assertok(ut_check_console_end(uts));
 
-   /* Test missing 10th element of /test-node@1234 node clock-names 
property */
+   /* Test missing 10th element of $node node clock-names property */
ut_assertok(console_record_reset_enable());
-   ut_asserteq(1, run_command("fdt get value ften /test-node@1234 
clock-names 10", 0));
+   ut_asserteq(1, run_commandf("fdt get value ften %s clock-names 10", 
node));
ut_assertok(ut_check_console_end(uts));
 
-   /* Test getting default element of /test-node@1234 node nonexistent 
property */
+   /* Test getting default element of $node node nonexistent property */
ut_assertok(console_record_reset_enable());
-   ut_asserteq(1, run_command("fdt get value fnone /test-node@1234 
nonexistent", 1));
+   ut_asserteq(1, run_commandf("fdt get value fnone %s nonexistent", 
node));
ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND");
ut_assertok(ut_check_console_end(uts));
 
+   return 0;
+}
+
+static int fdt_test_get_value(struct unit_test_state *uts)
+{
+   char fdt[4096];
+   ulong addr;
+   int ret;
+
+   ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt)));
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   ret = fdt_test_get_value_common(uts, "/test-node@1234");
+   if (!ret)
+   ret = fdt_test_get_value_common(uts, "testnodealias");
+   if (ret)
+   return ret;
+
/* Test getting default element of /nonexistent node */
ut_assertok(console_record_reset_enable());
ut_asserteq(1, run_command("fdt get value fnode /nonexistent 
nonexistent", 1));
ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
   

[PATCH 09/32] cmd: fdt: Map address returned from fdt get addr to sysmem

2023-02-27 Thread Marek Vasut
The address returned from 'fdt get addr' command must be mapped
into sysmem, as this is a working FDT. Access to this address
without mapping it would lead to crash e.g. in sandbox.

The following command triggers the crash:
"
./u-boot -Dc 'fdt addr $fdtcontroladdr ; fdt get addr var / compatible ; md 
$var'
"

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 cmd/fdt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index bc19303159d..f2576ab4b38 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -468,7 +468,8 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
/* Get address */
char buf[19];
 
-   snprintf(buf, sizeof(buf), "0x%p", 
nodep);
+   snprintf(buf, sizeof(buf), "0x%lx",
+(ulong)map_to_sysmem(nodep));
env_set(var, buf);
} else if (subcmd[0] == 's') {
/* Get size */
-- 
2.39.2



[PATCH 08/32] cmd: fdt: Handle 64bit pointers in fdt get addr

2023-02-27 Thread Marek Vasut
The command assumed 32bit pointers so far, with 64bit pointer the
command would overwrite a piece of stack. Fix it by extending the
array size to cater for 64bit pointer, and use snprintf() to avoid
writing past the end of the array ever again.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 cmd/fdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 279dad9fe11..bc19303159d 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -466,9 +466,9 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
return ret;
} else if (subcmd[0] == 'a') {
/* Get address */
-   char buf[11];
+   char buf[19];
 
-   sprintf(buf, "0x%p", nodep);
+   snprintf(buf, sizeof(buf), "0x%p", 
nodep);
env_set(var, buf);
} else if (subcmd[0] == 's') {
/* Get size */
-- 
2.39.2



[PATCH 10/32] cmd: fdt: Add support for integer arrays in fdt get value with index

2023-02-27 Thread Marek Vasut
Currently any integer array value is set as long up-to-40 character
hexadecimal string into environment variable when extracted from an
FDT using 'fdt get value path prop index', because the support for
handling integer arrays is not implemented, and fdt_value_env_set()
code falls back into the hash handling behavior instead.

Implement this support simply by checking whether user supplied any
index. If index is set and the property length is multiple of four,
then this is an integer array, and the code would extract value at
specified index.

There is a subtle change where default index is set to -1 instead of 0.
This is OK, since the only place which checks for index to be less or
equal zero is the string array handling code in fdt_value_env_set() and
that code would work perfectly well with index -1 too.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 cmd/fdt.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index f2576ab4b38..f38fe909c3e 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -77,7 +77,17 @@ static int fdt_value_env_set(const void *nodep, int len,
 
sprintf(buf, "0x%08X", fdt32_to_cpu(*(fdt32_t *)nodep));
env_set(var, buf);
-   } else if (len%4 == 0 && len <= 20) {
+   } else if (len % 4 == 0 && index >= 0) {
+   /* Needed to print integer arrays. */
+   const unsigned int *nodec = (const unsigned int *)nodep;
+   char buf[11];
+
+   if (index * 4 >= len)
+   return 1;
+
+   sprintf(buf, "0x%08X", fdt32_to_cpu(*(nodec + index)));
+   env_set(var, buf);
+   } else if (len % 4 == 0 && len <= 20) {
/* Needed to print things like sha1 hashes. */
char buf[41];
int i;
@@ -448,7 +458,7 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
working_fdt, nodeoffset, prop, &len);
if (nodep && len >= 0) {
if (subcmd[0] == 'v') {
-   int index = 0;
+   int index = -1;
int ret;
 
if (len == 0) {
-- 
2.39.2



[PATCH 13/32] test: cmd: fdt: Rename fdt_test_get() to fdt_test_get_value()

2023-02-27 Thread Marek Vasut
The 'fdt get' command has a 'get value' subcommand, rename the fdt_test_get()
to fdt_test_get_value() to avoid confusion about what it is testing. There is
currently no get 'get name', 'get addr', 'get size' subcommand test.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index a50285eafab..03a29c6b9c0 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -142,8 +142,8 @@ static int fdt_test_addr_resize(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_addr_resize, UT_TESTF_CONSOLE_REC);
 
-/* Test 'fdt get' reading an fdt */
-static int fdt_test_get(struct unit_test_state *uts)
+/* Test 'fdt get value' reading an fdt */
+static int fdt_test_get_value(struct unit_test_state *uts)
 {
ulong addr;
 
@@ -193,7 +193,7 @@ static int fdt_test_get(struct unit_test_state *uts)
 
return 0;
 }
-FDT_TEST(fdt_test_get, UT_TESTF_CONSOLE_REC);
+FDT_TEST(fdt_test_get_value, UT_TESTF_CONSOLE_REC);
 
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
-- 
2.39.2



[PATCH 14/32] test: cmd: fdt: Generate fuller DT internally and switch fdt get value to it

2023-02-27 Thread Marek Vasut
Implement function to generate internal test DT fragment and switch
the 'fdt get value' test to this instead of depending on the sandbox
DT. Rename clk-test node to test-node node. This FDT fragment will be
reused by other tests. No functional change.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 124 +++--
 1 file changed, 111 insertions(+), 13 deletions(-)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 03a29c6b9c0..21553a2f3dc 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -39,6 +39,102 @@ static int make_test_fdt(struct unit_test_state *uts, void 
*fdt, int size)
return 0;
 }
 
+/**
+ * make_fuller_fdt() - Create an FDT with root node and properties
+ *
+ * The size is set to the minimum needed
+ *
+ * @uts: Test state
+ * @fdt: Place to write FDT
+ * @size: Maximum size of space for fdt
+ */
+static int make_fuller_fdt(struct unit_test_state *uts, void *fdt, int size)
+{
+   fdt32_t regs[2] = { cpu_to_fdt32(0x1234), cpu_to_fdt32(0x1000) };
+
+   /*
+* Assemble the following DT for test purposes:
+*
+* / {
+*  #address-cells = <0x0001>;
+*  #size-cells = <0x0001>;
+*  compatible = "u-boot,fdt-test";
+*  model = "U-Boot FDT test";
+*
+*  aliases {
+*  badalias = "/bad/alias";
+*  subnodealias = "/test-node@1234/subnode";
+*  testnodealias = "/test-node@1234";
+*  };
+*
+*  test-node@1234 {
+*  #address-cells = <0x>;
+*  #size-cells = <0x>;
+*  compatible = "u-boot,fdt-test-device1";
+*  clock-names = "fixed", "i2c", "spi", "uart2", "uart1";
+*  u-boot,empty-property;
+*  clock-frequency = <0x00fde800>;
+*  regs = <0x1234 0x1000>;
+*
+*  subnode {
+*  #address-cells = <0x>;
+*  #size-cells = <0x>;
+*  compatible = "u-boot,fdt-subnode-test-device";
+*  };
+*  };
+* };
+*/
+
+   ut_assertok(fdt_create(fdt, size));
+   ut_assertok(fdt_finish_reservemap(fdt));
+   ut_assert(fdt_begin_node(fdt, "") >= 0);
+
+   ut_assertok(fdt_property_u32(fdt, "#address-cells", 1));
+   ut_assertok(fdt_property_u32(fdt, "#size-cells", 1));
+   /*  */
+   ut_assertok(fdt_property_string(fdt, "compatible", "u-boot,fdt-test"));
+   /*  */
+   ut_assertok(fdt_property_string(fdt, "model", "U-Boot FDT test"));
+
+   ut_assert(fdt_begin_node(fdt, "aliases") >= 0);
+   /*  */
+   ut_assertok(fdt_property_string(fdt, "badalias", "/bad/alias"));
+   /*  */
+   ut_assertok(fdt_property_string(fdt, "subnodealias", 
"/test-node@1234/subnode"));
+   /*  */
+   ut_assertok(fdt_property_string(fdt, "testnodealias", 
"/test-node@1234"));
+   ut_assertok(fdt_end_node(fdt));
+
+   ut_assert(fdt_begin_node(fdt, "test-node@1234") >= 0);
+   ut_assertok(fdt_property_cell(fdt, "#address-cells", 0));
+   ut_assertok(fdt_property_cell(fdt, "#size-cells", 0));
+   /*  */
+   ut_assertok(fdt_property_string(fdt, "compatible", 
"u-boot,fdt-test-device1"));
+   /*  */
+   ut_assertok(fdt_property(fdt, "clock-names", 
"fixed\0i2c\0spi\0uart2\0uart1\0", 26));
+   /*  */
+   ut_assertok(fdt_property(fdt, "u-boot,empty-property", NULL, 0));
+   /*
+* 
+* This value is deliberate as it used to break cmd/fdt.c
+* is_printable_string() implementation.
+*/
+   ut_assertok(fdt_property_u32(fdt, "clock-frequency", 1664));
+   /*  */
+   ut_assertok(fdt_property(fdt, "regs", ®s, sizeof(regs)));
+   ut_assert(fdt_begin_node(fdt, "subnode") >= 0);
+   ut_assertok(fdt_property_cell(fdt, "#address-cells", 0));
+   ut_assertok(fdt_property_cell(fdt, "#size-cells", 0));
+   ut_assertok(fdt_property_string(fdt, "compatible", 
"u-boot,fdt-subnode-test-device"));
+   ut_assertok(fdt_end_node(fdt));
+   ut_assertok(fdt_end_node(fdt));
+
+   ut_assertok(fdt_end_node(fdt));
+   ut_assertok(fdt_finish(fdt));
+
+   return 0;
+}
+
 /* Test 'fdt addr&#x

[PATCH 16/32] test: cmd: fdt: Test both string and integer arrays in 'fdt get value'

2023-02-27 Thread Marek Vasut
The 'fdt get value' subcommand now supports extraction of integer value
from integer arrays, add test for it, including a test for special case
unindexed integer array read, which is handled as hash and treated as a
long string instead of integer.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 58 --
 1 file changed, 42 insertions(+), 16 deletions(-)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index e04ba37f19f..69a69c5c75c 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -239,38 +239,64 @@ static int fdt_test_addr_resize(struct unit_test_state 
*uts)
 FDT_TEST(fdt_test_addr_resize, UT_TESTF_CONSOLE_REC);
 
 /* Test 'fdt get value' reading an fdt */
+static int fdt_test_get_value_string(struct unit_test_state *uts,
+const char *node, const char *prop,
+const char *idx,  const char *strres,
+const int intres)
+{
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt get value var %s %s %s",
+node, prop, idx ? : ""));
+   if (strres) {
+   ut_asserteq_str(strres, env_get("var"));
+   } else {
+   ut_asserteq(intres, env_get_hex("var", 0x1234));
+   }
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+
 static int fdt_test_get_value_common(struct unit_test_state *uts,
 const char *node)
 {
/* Test getting default element of $node node clock-names property */
-   ut_assertok(console_record_reset_enable());
-   ut_assertok(run_commandf("fdt get value fdflt %s clock-names", node));
-   ut_asserteq_str("fixed", env_get("fdflt"));
-   ut_assertok(ut_check_console_end(uts));
+   fdt_test_get_value_string(uts, node, "clock-names", NULL, "fixed", 0);
 
/* Test getting 0th element of $node node clock-names property */
-   ut_assertok(console_record_reset_enable());
-   ut_assertok(run_commandf("fdt get value fzero %s clock-names 0", node));
-   ut_asserteq_str("fixed", env_get("fzero"));
-   ut_assertok(ut_check_console_end(uts));
+   fdt_test_get_value_string(uts, node, "clock-names", "0", "fixed", 0);
 
/* Test getting 1st element of $node node clock-names property */
-   ut_assertok(console_record_reset_enable());
-   ut_assertok(run_commandf("fdt get value fone %s clock-names 1", node));
-   ut_asserteq_str("i2c", env_get("fone"));
-   ut_assertok(ut_check_console_end(uts));
+   fdt_test_get_value_string(uts, node, "clock-names", "1", "i2c", 0);
 
/* Test getting 2nd element of $node node clock-names property */
-   ut_assertok(console_record_reset_enable());
-   ut_assertok(run_commandf("fdt get value ftwo %s clock-names 2", node));
-   ut_asserteq_str("spi", env_get("ftwo"));
-   ut_assertok(ut_check_console_end(uts));
+   fdt_test_get_value_string(uts, node, "clock-names", "2", "spi", 0);
+
+   /*
+* Test getting default element of $node node regs property.
+* The result here is highly unusual, the non-index value read from
+* integer array is a string of concatenated values from the array,
+* but only if the array is shorter than 40 characters. Anything
+* longer is an error. This is a special case for handling hashes.
+*/
+   fdt_test_get_value_string(uts, node, "regs", NULL, "34120010", 
0);
+
+   /* Test getting 0th element of $node node regs property */
+   fdt_test_get_value_string(uts, node, "regs", "0", NULL, 0x1234);
+
+   /* Test getting 1st element of $node node regs property */
+   fdt_test_get_value_string(uts, node, "regs", "1", NULL, 0x1000);
 
/* Test missing 10th element of $node node clock-names property */
ut_assertok(console_record_reset_enable());
ut_asserteq(1, run_commandf("fdt get value ften %s clock-names 10", 
node));
ut_assertok(ut_check_console_end(uts));
 
+   /* Test missing 10th element of $node node regs property */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt get value ften %s regs 10", node));
+   ut_assertok(ut_check_console_end(uts));
+
/* Test getting default element of $node node nonexistent property */
ut_assertok(console_record_reset_enable());
ut_asserteq(1, run_commandf("fdt get value fnone %s nonexistent", 
node));
-- 
2.39.2



[PATCH 17/32] test: cmd: fdt: Test fdt move

2023-02-27 Thread Marek Vasut
Add 'fdt move' test which works as follows:
- Create simple FDT, map it to sysmem
- 'move' the FDT into new zeroed out sysmem location
- Verify newly active FDT is in the new location
- Compare both locations

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 69a69c5c75c..023b83eb019 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -238,6 +238,40 @@ static int fdt_test_addr_resize(struct unit_test_state 
*uts)
 }
 FDT_TEST(fdt_test_addr_resize, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_move(struct unit_test_state *uts)
+{
+   char fdt[256];
+   ulong addr, newaddr = 0x1;
+   const int size = sizeof(fdt);
+   uint32_t ts;
+   void *buf;
+
+   /* Original source DT */
+   ut_assertok(make_test_fdt(uts, fdt, size));
+   ts = fdt_totalsize(fdt);
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Moved target DT location */
+   buf = map_sysmem(newaddr, size);
+   memset(buf, 0, size);
+
+   /* Test moving the working FDT to a new location */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt move %08x %08x %x", addr, newaddr, ts));
+   ut_assert_nextline("Working FDT set to %lx", newaddr);
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Compare the source and destination DTs */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("cmp.b %08x %08x %x", addr, newaddr, ts));
+   ut_assert_nextline("Total of %d byte(s) were the same", ts);
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+FDT_TEST(fdt_test_move, UT_TESTF_CONSOLE_REC);
+
 /* Test 'fdt get value' reading an fdt */
 static int fdt_test_get_value_string(struct unit_test_state *uts,
 const char *node, const char *prop,
-- 
2.39.2



[PATCH 18/32] test: cmd: fdt: Test fdt resize

2023-02-27 Thread Marek Vasut
Add 'fdt resize' test which works as follows:
- Create simple FDT with extra size 0, map it to sysmem
- 'resize' the FDT by 0x2000 bytes
- Verify the new space has been added to the FDT

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 023b83eb019..266fb6e3ed0 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -272,6 +272,30 @@ static int fdt_test_move(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_move, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_resize(struct unit_test_state *uts)
+{
+   char fdt[256];
+   const unsigned int newsize = 0x2000;
+   uint32_t ts;
+   ulong addr;
+
+   /* Original source DT */
+   ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt)));
+   fdt_shrink_to_minimum(fdt, 0);  /* Resize with 0 extra bytes */
+   ts = fdt_totalsize(fdt);
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test resizing the working FDT and verify the new space was added */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt resize %x", newsize));
+   ut_asserteq(ts + newsize, fdt_totalsize(fdt));
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+FDT_TEST(fdt_test_resize, UT_TESTF_CONSOLE_REC);
+
 /* Test 'fdt get value' reading an fdt */
 static int fdt_test_get_value_string(struct unit_test_state *uts,
 const char *node, const char *prop,
-- 
2.39.2



[PATCH 19/32] test: cmd: fdt: Test fdt print and list

2023-02-27 Thread Marek Vasut
Add 'fdt print' and 'fdt list' test which works as follows:
- Create fuller FDT, map it to sysmem
- Print the entire FDT, parts of the FDT and select properties
- Compare output from the print or list

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 143 +
 1 file changed, 143 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 266fb6e3ed0..793525c02c5 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -296,6 +296,149 @@ static int fdt_test_resize(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_resize, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_print_list_common(struct unit_test_state *uts,
+ const char *opc, const char *node)
+{
+   /*
+* Test printing/listing the working FDT
+* subnode $node/subnode
+*/
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt %s %s/subnode", opc, node));
+   ut_assert_nextline("subnode {");
+   ut_assert_nextline("\t#address-cells = <0x>;");
+   ut_assert_nextline("\t#size-cells = <0x>;");
+   ut_assert_nextline("\tcompatible = 
\"u-boot,fdt-subnode-test-device\";");
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   /*
+* Test printing/listing the working FDT
+* path / string property model
+*/
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt %s / model", opc));
+   ut_assert_nextline("model = \"U-Boot FDT test\"");
+   ut_assertok(ut_check_console_end(uts));
+
+   /*
+* Test printing/listing the working FDT
+* path $node string property compatible
+*/
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt %s %s compatible", opc, node));
+   ut_assert_nextline("compatible = \"u-boot,fdt-test-device1\"");
+   ut_assertok(ut_check_console_end(uts));
+
+   /*
+* Test printing/listing the working FDT
+* path $node stringlist property clock-names
+*/
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt %s %s clock-names", opc, node));
+   ut_assert_nextline("clock-names = \"fixed\", \"i2c\", \"spi\", 
\"uart2\", \"uart1\"");
+   ut_assertok(ut_check_console_end(uts));
+
+   /*
+* Test printing/listing the working FDT
+* path $node u32 property clock-frequency
+*/
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt %s %s clock-frequency", opc, node));
+   ut_assert_nextline("clock-frequency = <0x00fde800>");
+   ut_assertok(ut_check_console_end(uts));
+
+   /*
+* Test printing/listing the working FDT
+* path $node empty property u-boot,empty-property
+*/
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt %s %s u-boot,empty-property", opc, node));
+   /*
+* This is the only 'fdt print' / 'fdt list' incantation which
+* prefixes the property with node path. This has been in U-Boot
+* since the beginning of the command 'fdt', keep it.
+*/
+   ut_assert_nextline("%s u-boot,empty-property", node);
+   ut_assertok(ut_check_console_end(uts));
+
+   /*
+* Test printing/listing the working FDT
+* path $node prop-encoded array property regs
+*/
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt %s %s regs", opc, node));
+   ut_assert_nextline("regs = <0x1234 0x1000>");
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+
+static int fdt_test_print_list(struct unit_test_state *uts, bool print)
+{
+   const char *opc = print ? "print" : "list";
+   char fdt[4096];
+   ulong addr;
+   int ret;
+
+   /* Original source DT */
+   ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt)));
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test printing/listing the working FDT -- node / */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt %s", opc));
+   ut_assert_nextline("/ {");
+   ut_assert_nextline("\t#address-cells = <0x000

[PATCH 20/32] test: cmd: fdt: Test fdt get name

2023-02-27 Thread Marek Vasut
Add 'fdt get name' test which works as follows:
- Create fuller FDT, map it to sysmem
- Get name of / node 0, 1 and /clk-test node 0
- Compare output and validate the node name
- Get name of / node 2 and /clk-test node 1
- Compare output and validate the node is not present
- Get name of / node -1 and /clk-test node -1
- Compare output and validate the node name equals node 0 name
- Check nonexistent node, verify the command errors out

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 79 ++
 1 file changed, 79 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 793525c02c5..fa95241c8f2 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -545,6 +545,85 @@ static int fdt_test_get_value(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_get_value, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_get_name(struct unit_test_state *uts)
+{
+   char fdt[4096];
+   ulong addr;
+
+   ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt)));
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test getting name of node 0 in /, which is /aliases node */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_command("fdt get name nzero / 0", 0));
+   ut_asserteq_str("aliases", env_get("nzero"));
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of node 1 in /, which is /test-node@1234 node */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_command("fdt get name none / 1", 0));
+   ut_asserteq_str("test-node@1234", env_get("none"));
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of node -1 in /, which is /aliases node, same as 0 
*/
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_command("fdt get name nmone / -1", 0));
+   ut_asserteq_str("aliases", env_get("nmone"));
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of node 2 in /, which does not exist */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get name ntwo / 2", 1));
+   ut_assert_nextline("libfdt node not found");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of node 0 in /test-node@1234, which is /subnode 
node */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_command("fdt get name snzero /test-node@1234 0", 0));
+   ut_asserteq_str("subnode", env_get("snzero"));
+   ut_assertok(run_command("fdt get name asnzero testnodealias 0", 0));
+   ut_asserteq_str("subnode", env_get("asnzero"));
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of node 1 in /test-node@1234, which does not exist 
*/
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get name snone /test-node@1234 1", 1));
+   ut_assert_nextline("libfdt node not found");
+   ut_asserteq(1, run_command("fdt get name asnone testnodealias 1", 1));
+   ut_assert_nextline("libfdt node not found");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of node -1 in /test-node@1234, which is /subnode 
node, same as 0 */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_command("fdt get name snmone /test-node@1234 -1", 0));
+   ut_asserteq_str("subnode", env_get("snmone"));
+   ut_assertok(run_command("fdt get name asnmone testnodealias -1", 0));
+   ut_asserteq_str("subnode", env_get("asnmone"));
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of nonexistent node */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get name nonode /nonexistent 0", 1));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of bad alias */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get name vbadalias badalias 0", 1));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting name of nonexistent alias */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get name vnoalias noalias 0&quo

[PATCH 21/32] test: cmd: fdt: Test fdt get addr

2023-02-27 Thread Marek Vasut
Add 'fdt get addr' test which works as follows:
- Create fuller FDT, map it to sysmem
- Get address of various properties
- Compare addresses calculated by UT and fdt command

This test is special in that it has to go through gruesome remapping scheme
where the test calculates:
- pointer offsets of the generated FDT root and the property being tested
- map_sysmem() result of environment variable "fdtaddr" and the one set
  by the test matching address of property being tested
- difference between the later and the former, to obtain offset of the
  DT property from start of DT
The offsets must match in both the UT and the tested U-Boot, if they do
not, the test fails.

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 66 ++
 1 file changed, 66 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index fa95241c8f2..e829052bfd9 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -624,6 +624,72 @@ static int fdt_test_get_name(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_get_name, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_get_addr_common(struct unit_test_state *uts, char *fdt,
+   const char *path, const char *prop)
+{
+   unsigned int offset;
+   int path_offset;
+   void *prop_ptr;
+   int len = 0;
+
+   ut_assert((path_offset = fdt_path_offset(fdt, path)) >= 0);
+   ut_assertnonnull(prop_ptr = (void *)fdt_getprop(fdt, path_offset,
+   prop, &len));
+   offset = (char *)prop_ptr - fdt;
+
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt get addr pstr %s %s", path, prop));
+   ut_asserteq((ulong)map_sysmem(env_get_hex("fdtaddr", 0x1234), 0),
+   (ulong)(map_sysmem(env_get_hex("pstr", 0x1234), 0) - 
offset));
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+
+static int fdt_test_get_addr(struct unit_test_state *uts)
+{
+   char fdt[4096];
+   ulong addr;
+
+   ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt)));
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test getting address of root node / string property "compatible" */
+   fdt_test_get_addr_common(uts, fdt, "/", "compatible");
+
+   /* Test getting address of node /test-node@1234 stringlist property 
"clock-names" */
+   fdt_test_get_addr_common(uts, fdt, "/test-node@1234", "clock-names");
+   fdt_test_get_addr_common(uts, fdt, "testnodealias", "clock-names");
+
+   /* Test getting address of node /test-node@1234 u32 property 
"clock-frequency" */
+   fdt_test_get_addr_common(uts, fdt, "/test-node@1234", 
"clock-frequency");
+   fdt_test_get_addr_common(uts, fdt, "testnodealias", "clock-frequency");
+
+   /* Test getting address of node /test-node@1234 empty property 
"u-boot,empty-property" */
+   fdt_test_get_addr_common(uts, fdt, "/test-node@1234", 
"u-boot,empty-property");
+   fdt_test_get_addr_common(uts, fdt, "testnodealias", 
"u-boot,empty-property");
+
+   /* Test getting address of node /test-node@1234 array property "regs" */
+   fdt_test_get_addr_common(uts, fdt, "/test-node@1234", "regs");
+   fdt_test_get_addr_common(uts, fdt, "testnodealias", "regs");
+
+   /* Test getting address of node /test-node@1234/subnode non-existent 
property "noprop" */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get addr pnoprop 
/test-node@1234/subnode noprop", 1));
+   ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting address of non-existent node /test-node@1234/nonode@1 
property "noprop" */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get addr pnonode 
/test-node@1234/nonode@1 noprop", 1));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+FDT_TEST(fdt_test_get_addr, UT_TESTF_CONSOLE_REC);
+
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);
-- 
2.39.2



[PATCH 22/32] test: cmd: fdt: Test fdt get size

2023-02-27 Thread Marek Vasut
Add 'fdt get size' test which works as follows:
- Create fuller FDT, map it to sysmem
- Get size of various properties
- Get node count of available nodes
- Test non-existent nodes and properties

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 87 ++
 1 file changed, 87 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index e829052bfd9..ae67b468b71 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -690,6 +690,93 @@ static int fdt_test_get_addr(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_get_addr, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_get_size_common(struct unit_test_state *uts,
+const char *path, const char *prop,
+const unsigned int val)
+{
+   ut_assertok(console_record_reset_enable());
+   if (prop) {
+   ut_assertok(run_commandf("fdt get size sstr %s %s", path, 
prop));
+   } else {
+   ut_assertok(run_commandf("fdt get size sstr %s", path));
+   }
+   ut_asserteq(val, env_get_hex("sstr", 0x1234));
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+
+static int fdt_test_get_size(struct unit_test_state *uts)
+{
+   char fdt[4096];
+   ulong addr;
+
+   ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt)));
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test getting size of root node / string property "compatible" */
+   fdt_test_get_size_common(uts, "/", "compatible", 16);
+
+   /* Test getting size of node /test-node@1234 stringlist property 
"clock-names" */
+   fdt_test_get_size_common(uts, "/test-node@1234", "clock-names", 26);
+   fdt_test_get_size_common(uts, "testnodealias", "clock-names", 26);
+
+   /* Test getting size of node /test-node@1234 u32 property 
"clock-frequency" */
+   fdt_test_get_size_common(uts, "/test-node@1234", "clock-frequency", 4);
+   fdt_test_get_size_common(uts, "testnodealias", "clock-frequency", 4);
+
+   /* Test getting size of node /test-node@1234 empty property 
"u-boot,empty-property" */
+   fdt_test_get_size_common(uts, "/test-node@1234", 
"u-boot,empty-property", 0);
+   fdt_test_get_size_common(uts, "testnodealias", "u-boot,empty-property", 
0);
+
+   /* Test getting size of node /test-node@1234 array property "regs" */
+   fdt_test_get_size_common(uts, "/test-node@1234", "regs", 8);
+   fdt_test_get_size_common(uts, "testnodealias", "regs", 8);
+
+   /* Test getting node count of node / */
+   fdt_test_get_size_common(uts, "/", NULL, 2);
+
+   /* Test getting node count of node /test-node@1234/subnode */
+   fdt_test_get_size_common(uts, "/test-node@1234/subnode", NULL, 0);
+   fdt_test_get_size_common(uts, "subnodealias", NULL, 0);
+
+   /* Test getting size of node /test-node@1234/subnode non-existent 
property "noprop" */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get size pnoprop 
/test-node@1234/subnode noprop", 1));
+   ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND");
+   ut_asserteq(1, run_command("fdt get size pnoprop subnodealias noprop", 
1));
+   ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting size of non-existent node /test-node@1234/nonode@1 
property "noprop" */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get size pnonode 
/test-node@1234/nonode@1 noprop", 1));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting node count of non-existent node 
/test-node@1234/nonode@1 */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get size pnonode 
/test-node@1234/nonode@1", 1));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting node count of bad alias badalias */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_command("fdt get size pnonode badalias noprop", 1));
+   ut_assert_nextline("libfdt fdt_pa

[PATCH 23/32] test: cmd: fdt: Test fdt set

2023-02-27 Thread Marek Vasut
Add 'fdt set' test which works as follows:
- Create fuller FDT, map it to sysmem
- Set either existing property to overwrite it, or new property
- Test setting both single properties as well as string and integer arrays
- Test setting to non-existent nodes and aliases
- Verify set values using 'fdt get value'

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 123 +
 1 file changed, 123 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index ae67b468b71..42d067090aa 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -777,6 +777,129 @@ static int fdt_test_get_size(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_get_size, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_set_single(struct unit_test_state *uts,
+  const char *path, const char *prop,
+  const char *sval, int ival, bool integer)
+{
+   ut_assertok(console_record_reset_enable());
+   if (sval) {
+   ut_assertok(run_commandf("fdt set %s %s %s", path, prop, sval));
+   } else if (integer) {
+   ut_assertok(run_commandf("fdt set %s %s <%d>", path, prop, 
ival));
+   } else {
+   ut_assertok(run_commandf("fdt set %s %s", path, prop));
+   }
+
+   ut_assertok(run_commandf("fdt get value svar %s %s", path, prop));
+   if (sval) {
+   ut_asserteq_str(sval, env_get("svar"));
+   } else if (integer) {
+   ut_asserteq(ival, env_get_hex("svar", 0x1234));
+   } else {
+   ut_assertnull(env_get("svar"));
+   }
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+
+static int fdt_test_set_multi(struct unit_test_state *uts,
+ const char *path, const char *prop,
+ const char *sval1, const char *sval2,
+ int ival1, int ival2)
+{
+   ut_assertok(console_record_reset_enable());
+   if (sval1 && sval2) {
+   ut_assertok(run_commandf("fdt set %s %s %s %s end", path, prop, 
sval1, sval2));
+   ut_assertok(run_commandf("fdt set %s %s %s %s", path, prop, 
sval1, sval2));
+   } else {
+   ut_assertok(run_commandf("fdt set %s %s <%d %d 10>", path, 
prop, ival1, ival2));
+   ut_assertok(run_commandf("fdt set %s %s <%d %d>", path, prop, 
ival1, ival2));
+   }
+
+   /*
+* The "end/10" above and "svarn" below is used to validate that
+* previous 'fdt set' to longer array does not polute newly set
+* shorter array.
+*/
+   ut_assertok(run_commandf("fdt get value svar1 %s %s 0", path, prop));
+   ut_assertok(run_commandf("fdt get value svar2 %s %s 1", path, prop));
+   ut_asserteq(1, run_commandf("fdt get value svarn %s %s 2", path, prop));
+   if (sval1 && sval2) {
+   ut_asserteq_str(sval1, env_get("svar1"));
+   ut_asserteq_str(sval2, env_get("svar2"));
+   ut_assertnull(env_get("svarn"));
+   } else {
+   ut_asserteq(ival1, env_get_hex("svar1", 0x1234));
+   ut_asserteq(ival2, env_get_hex("svar2", 0x1234));
+   ut_assertnull(env_get("svarn"));
+   }
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+
+static int fdt_test_set_node(struct unit_test_state *uts,
+const char *path, const char *prop)
+{
+   fdt_test_set_single(uts, path, prop, "new", 0, false);
+   fdt_test_set_single(uts, path, prop, "rewrite", 0, false);
+   fdt_test_set_single(uts, path, prop, NULL, 42, true);
+   fdt_test_set_single(uts, path, prop, NULL, 0, false);
+   fdt_test_set_multi(uts, path, prop, NULL, NULL, 42, 1701);
+   fdt_test_set_multi(uts, path, prop, NULL, NULL, 74656, 9);
+   fdt_test_set_multi(uts, path, prop, "42", "1701", 0, 0);
+   fdt_test_set_multi(uts, path, prop, "74656", "9", 0, 0);
+
+   return 0;
+}
+
+static int fdt_test_set(struct unit_test_state *uts)
+{
+   char fdt[8192];
+   ulong addr;
+
+   ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt)));
+   fdt_shrink_to_minimum(fdt, 4096);   /* Resize with 4096 extra bytes 
*/
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test setting of root node / existing property "compatible" */
+   fdt_test_set_nod

[PATCH 24/32] test: cmd: fdt: Test fdt mknode

2023-02-27 Thread Marek Vasut
Add 'fdt mknode' test which works as follows:
- Create fuller FDT, map it to sysmem
- Create node either in / or subnode
- Attempt to create node over existing node, which fails
- Attempt to create subnodes in non-existing nodes or aliases
- Verify created nodes using fdt list command

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 68 ++
 1 file changed, 68 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 42d067090aa..dec783f6e26 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -900,6 +900,74 @@ static int fdt_test_set(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_set, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_mknode(struct unit_test_state *uts)
+{
+   char fdt[8192];
+   ulong addr;
+
+   ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt)));
+   fdt_shrink_to_minimum(fdt, 4096);   /* Resize with 4096 extra bytes 
*/
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test creation of new node in / */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt mknode / newnode"));
+   ut_assertok(run_commandf("fdt list /newnode"));
+   ut_assert_nextline("newnode {");
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test creation of new node in /test-node@1234 */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt mknode /test-node@1234 newsubnode"));
+   ut_assertok(run_commandf("fdt list /test-node@1234/newsubnode"));
+   ut_assert_nextline("newsubnode {");
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test creation of new node in /test-node@1234 by alias */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt mknode testnodealias newersubnode"));
+   ut_assertok(run_commandf("fdt list testnodealias/newersubnode"));
+   ut_assert_nextline("newersubnode {");
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test creation of new node in /test-node@1234 over existing node */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt mknode testnodealias newsubnode"));
+   ut_assert_nextline("libfdt fdt_add_subnode(): FDT_ERR_EXISTS");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test creation of new node in /test-node@1234 by alias over existing 
node */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt mknode testnodealias newersubnode"));
+   ut_assert_nextline("libfdt fdt_add_subnode(): FDT_ERR_EXISTS");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test creation of new node in non-existent node */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt mknode /no-node newnosubnode"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test creation of new node in non-existent alias */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt mknode noalias newfailsubnode"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_BADPATH");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test creation of new node in bad alias */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt mknode badalias newbadsubnode"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+FDT_TEST(fdt_test_mknode, UT_TESTF_CONSOLE_REC);
+
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);
-- 
2.39.2



[PATCH 25/32] test: cmd: fdt: Test fdt rm

2023-02-27 Thread Marek Vasut
Add 'fdt rm' test which works as follows:
- Create fuller FDT, map it to sysmem
- Selectively delete nodes or properties by both path and aliases
- Verify created nodes or properties using fdt print command

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 84 ++
 1 file changed, 84 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index dec783f6e26..39a20337c95 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -968,6 +968,90 @@ static int fdt_test_mknode(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_mknode, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_rm(struct unit_test_state *uts)
+{
+   char fdt[4096];
+   ulong addr;
+
+   ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt)));
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test removal of property in root node / */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt print / compatible"));
+   ut_assert_nextline("compatible = \"u-boot,fdt-test\"");
+   ut_assertok(run_commandf("fdt rm / compatible"));
+   ut_asserteq(1, run_commandf("fdt print / compatible"));
+   ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of property clock-names in subnode /test-node@1234 */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt print /test-node@1234 clock-names"));
+   ut_assert_nextline("clock-names = \"fixed\", \"i2c\", \"spi\", 
\"uart2\", \"uart1\"");
+   ut_assertok(run_commandf("fdt rm /test-node@1234 clock-names"));
+   ut_asserteq(1, run_commandf("fdt print /test-node@1234 clock-names"));
+   ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of property u-boot,empty-property in subnode 
/test-node@1234 by alias */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt print testnodealias 
u-boot,empty-property"));
+   ut_assert_nextline("testnodealias u-boot,empty-property");
+   ut_assertok(run_commandf("fdt rm testnodealias u-boot,empty-property"));
+   ut_asserteq(1, run_commandf("fdt print testnodealias 
u-boot,empty-property"));
+   ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of non-existent property noprop in subnode 
/test-node@1234 */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt rm /test-node@1234 noprop"));
+   ut_assert_nextline("libfdt fdt_delprop(): FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of non-existent node /no-node@5678 */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt rm /no-node@5678"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of subnode /test-node@1234/subnode by alias */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt rm subnodealias"));
+   ut_asserteq(1, run_commandf("fdt print /test-node@1234/subnode"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of node by non-existent alias */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt rm noalias"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_BADPATH");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of node by bad alias */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt rm noalias"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_BADPATH");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test removal of node /test-node@1234 */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt rm /test-node@1234"));
+   ut_asserteq(1, run_commandf("fdt print /test-node@1234"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   u

[PATCH 26/32] test: cmd: fdt: Test fdt header

2023-02-27 Thread Marek Vasut
Add 'fdt header' test which works as follows:
- Create basic FDT, map it to sysmem
- Print the FDT header
- Get all members of the FDT header into variable and
  verify the variables contain correct data

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 59 ++
 1 file changed, 59 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 39a20337c95..b0c7ff52ca3 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -1052,6 +1052,65 @@ static int fdt_test_rm(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_rm, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_header_get(struct unit_test_state *uts, char fdt[4096],
+  const char *field, const unsigned long val)
+{
+   /* Test getting valid header entry */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt header get fvar %s", field));
+   ut_asserteq(val, env_get_hex("fvar", 0x1234));
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting malformed header entry */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt header get fvar typo%stypo", field));
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+
+static int fdt_test_header(struct unit_test_state *uts)
+{
+   char fdt[256];
+   ulong addr;
+
+   ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt)));
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test header print */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt header"));
+   ut_assert_nextline("magic:\t\t\t0x%x", fdt_magic(fdt));
+   ut_assert_nextline("totalsize:\t\t0x%x (%d)", fdt_totalsize(fdt), 
fdt_totalsize(fdt));
+   ut_assert_nextline("off_dt_struct:\t\t0x%x", fdt_off_dt_struct(fdt));
+   ut_assert_nextline("off_dt_strings:\t\t0x%x", fdt_off_dt_strings(fdt));
+   ut_assert_nextline("off_mem_rsvmap:\t\t0x%x", fdt_off_mem_rsvmap(fdt));
+   ut_assert_nextline("version:\t\t%d", fdt_version(fdt));
+   ut_assert_nextline("last_comp_version:\t%d", 
fdt_last_comp_version(fdt));
+   ut_assert_nextline("boot_cpuid_phys:\t0x%x", fdt_boot_cpuid_phys(fdt));
+   ut_assert_nextline("size_dt_strings:\t0x%x", fdt_size_dt_strings(fdt));
+   ut_assert_nextline("size_dt_struct:\t\t0x%x", fdt_size_dt_struct(fdt));
+   ut_assert_nextline("number mem_rsv:\t\t0x%x", fdt_num_mem_rsv(fdt));
+   ut_assert_nextline_empty();
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test header get */
+   fdt_test_header_get(uts, fdt, "magic", fdt_magic(fdt));
+   fdt_test_header_get(uts, fdt, "totalsize", fdt_totalsize(fdt));
+   fdt_test_header_get(uts, fdt, "off_dt_struct", fdt_off_dt_struct(fdt));
+   fdt_test_header_get(uts, fdt, "off_dt_strings", 
fdt_off_dt_strings(fdt));
+   fdt_test_header_get(uts, fdt, "off_mem_rsvmap", 
fdt_off_mem_rsvmap(fdt));
+   fdt_test_header_get(uts, fdt, "version", fdt_version(fdt));
+   fdt_test_header_get(uts, fdt, "last_comp_version", 
fdt_last_comp_version(fdt));
+   fdt_test_header_get(uts, fdt, "boot_cpuid_phys", 
fdt_boot_cpuid_phys(fdt));
+   fdt_test_header_get(uts, fdt, "size_dt_strings", 
fdt_size_dt_strings(fdt));
+   fdt_test_header_get(uts, fdt, "size_dt_struct", 
fdt_size_dt_struct(fdt));
+
+   return 0;
+}
+FDT_TEST(fdt_test_header, UT_TESTF_CONSOLE_REC);
+
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);
-- 
2.39.2



[PATCH 27/32] test: cmd: fdt: Test fdt bootcpu

2023-02-27 Thread Marek Vasut
Add 'fdt bootcpu' test which works as follows:
- Create basic FDT, map it to sysmem
- Print the FDT bootcpu
- Set the FDT bootcpu and read the value back using 'fdt header get'
- Perform the previous step twice to validate bootcpu overwrite

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 33 +
 1 file changed, 33 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index b0c7ff52ca3..f4dd4238ad2 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -,6 +,39 @@ static int fdt_test_header(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_header, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_bootcpu(struct unit_test_state *uts)
+{
+   char fdt[256];
+   ulong addr;
+   int i;
+
+   ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt)));
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test getting default bootcpu entry */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt header get bootcpu boot_cpuid_phys"));
+   ut_asserteq(0, env_get_ulong("bootcpu", 10, 0x1234));
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test setting and getting new bootcpu entry, twice, to test overwrite 
*/
+   for (i = 42; i <= 43; i++) {
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt bootcpu %d", i));
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test getting new bootcpu entry */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt header get bootcpu 
boot_cpuid_phys"));
+   ut_asserteq(i, env_get_ulong("bootcpu", 10, 0x1234));
+   ut_assertok(ut_check_console_end(uts));
+   }
+
+   return 0;
+}
+FDT_TEST(fdt_test_bootcpu, UT_TESTF_CONSOLE_REC);
+
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);
-- 
2.39.2



[PATCH 30/32] test: cmd: fdt: Test fdt chosen

2023-02-27 Thread Marek Vasut
Add 'fdt chosen' test which works as follows:
- Create basic DT, map it to sysmem
- Print /chosen node, verify it is nonexistent
- Create chosen node
- Print /chosen node, verify it contains only version
- Create /chosen node with initrd entries
- Print /chosen node, verify it contains version and initrd entries

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 48 
 1 file changed, 48 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 8f7a62584da..721916b070d 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -1290,6 +1290,54 @@ static int fdt_test_rsvmem(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_rsvmem, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_chosen(struct unit_test_state *uts)
+{
+   const char *env_bootargs = env_get("bootargs");
+   char fdt[8192];
+   ulong addr;
+
+   ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt)));
+   fdt_shrink_to_minimum(fdt, 4096);   /* Resize with 4096 extra bytes 
*/
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test default chosen node presence, fail as there is no /chosen node 
*/
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt print /chosen"));
+   ut_assert_nextline("libfdt fdt_path_offset() returned 
FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test add new chosen node without initrd */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt chosen"));
+   ut_assertok(run_commandf("fdt print /chosen"));
+   ut_assert_nextline("chosen {");
+   ut_assert_nextlinen("\tu-boot,version = "); /* Ignore the version 
string */
+   if (env_bootargs)
+   ut_assert_nextline("\tbootargs = \"%s\";", env_bootargs);
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test add new chosen node with initrd */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt chosen 0x1234 0x5678"));
+   ut_assertok(run_commandf("fdt print /chosen"));
+   ut_assert_nextline("chosen {");
+   ut_assert_nextline("\tlinux,initrd-end = <0x%08x 0x%08x>;",
+  upper_32_bits(0x1234 + 0x5678 - 1),
+  lower_32_bits(0x1234 + 0x5678 - 1));
+   ut_assert_nextline("\tlinux,initrd-start = <0x%08x 0x%08x>;",
+  upper_32_bits(0x1234), lower_32_bits(0x1234));
+   ut_assert_nextlinen("\tu-boot,version = "); /* Ignore the version 
string */
+   if (env_bootargs)
+   ut_assert_nextline("\tbootargs = \"%s\";", env_bootargs);
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+FDT_TEST(fdt_test_chosen, UT_TESTF_CONSOLE_REC);
+
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);
-- 
2.39.2



[PATCH 29/32] test: cmd: fdt: Test fdt rsvmem

2023-02-27 Thread Marek Vasut
Add 'fdt rsvmem' test which works as follows:
- Create custom FDT with single reserved memory (rsvmem) entry, map it to sysmem
- Add new rsvmem entry
- Delete existing older rsvmem entry
- Add new rsvmem entry again
- Always print the rsvmem list and validate it

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 63 ++
 1 file changed, 63 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index ff97571a64b..8f7a62584da 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -1227,6 +1227,69 @@ static int fdt_test_memory(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_memory, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_rsvmem(struct unit_test_state *uts)
+{
+   char fdt[8192];
+   ulong addr;
+
+   ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt)));
+   fdt_shrink_to_minimum(fdt, 4096);   /* Resize with 4096 extra bytes 
*/
+   fdt_add_mem_rsv(fdt, 0x42, 0x1701);
+   fdt_add_mem_rsv(fdt, 0x74656, 0x9);
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test default reserved memory node presence */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt rsvmem print"));
+   ut_assert_nextline("index\t\t   start\t\tsize");
+   ut_assert_nextline("");
+   ut_assert_nextline("%x\t%016x\t%016x", 0, 0x42, 0x1701);
+   ut_assert_nextline("%x\t%016x\t%016x", 1, 0x74656, 0x9);
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test add new reserved memory node */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt rsvmem add 0x1234 0x5678"));
+   ut_assertok(run_commandf("fdt rsvmem print"));
+   ut_assert_nextline("index\t\t   start\t\tsize");
+   ut_assert_nextline("");
+   ut_assert_nextline("%x\t%016x\t%016x", 0, 0x42, 0x1701);
+   ut_assert_nextline("%x\t%016x\t%016x", 1, 0x74656, 0x9);
+   ut_assert_nextline("%x\t%016x\t%016x", 2, 0x1234, 0x5678);
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test delete reserved memory node */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt rsvmem delete 0"));
+   ut_assertok(run_commandf("fdt rsvmem print"));
+   ut_assert_nextline("index\t\t   start\t\tsize");
+   ut_assert_nextline("");
+   ut_assert_nextline("%x\t%016x\t%016x", 0, 0x74656, 0x9);
+   ut_assert_nextline("%x\t%016x\t%016x", 1, 0x1234, 0x5678);
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test re-add new reserved memory node */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt rsvmem add 0x42 0x1701"));
+   ut_assertok(run_commandf("fdt rsvmem print"));
+   ut_assert_nextline("index\t\t   start\t\tsize");
+   ut_assert_nextline("");
+   ut_assert_nextline("%x\t%016x\t%016x", 0, 0x74656, 0x9);
+   ut_assert_nextline("%x\t%016x\t%016x", 1, 0x1234, 0x5678);
+   ut_assert_nextline("%x\t%016x\t%016x", 2, 0x42, 0x1701);
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test delete nonexistent reserved memory node */
+   ut_assertok(console_record_reset_enable());
+   ut_asserteq(1, run_commandf("fdt rsvmem delete 10"));
+   ut_assert_nextline("libfdt fdt_del_mem_rsv(): FDT_ERR_NOTFOUND");
+   ut_assertok(ut_check_console_end(uts));
+
+   return 0;
+}
+FDT_TEST(fdt_test_rsvmem, UT_TESTF_CONSOLE_REC);
+
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);
-- 
2.39.2



[PATCH 28/32] test: cmd: fdt: Test fdt memory

2023-02-27 Thread Marek Vasut
Add 'fdt memory' test which works as follows:
- Create custom FDT with /memory node, with select #*cells, map it to sysmem
- Perform memory fixup
- Read back the /memory node and validate its content

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 83 ++
 1 file changed, 83 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index f4dd4238ad2..ff97571a64b 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -1144,6 +1144,89 @@ static int fdt_test_bootcpu(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_bootcpu, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_memory_cells(struct unit_test_state *uts,
+const unsigned int cells)
+{
+   unsigned char *pada, *pads;
+   unsigned char *seta, *sets;
+   char fdt[8192];
+   const int size = sizeof(fdt);
+   fdt32_t *regs;
+   ulong addr;
+   char *spc;
+   int i;
+
+   /* Create DT with node /memory { regs = <0x100 0x200>; } and #*cells */
+   ut_assertnonnull(regs = calloc(2 * cells, sizeof(*regs)));
+   ut_assertnonnull(pada = calloc(12, cells));
+   ut_assertnonnull(pads = calloc(12, cells));
+   ut_assertnonnull(seta = calloc(12, cells));
+   ut_assertnonnull(sets = calloc(12, cells));
+   for (i = cells; i >= 1; i--) {
+   regs[cells - 1] = cpu_to_fdt32(i * 0x1);
+   regs[(cells * 2) - 1] = cpu_to_fdt32(~i);
+   snprintf(seta + (8 * (cells - i)), 9, "%08x", i * 0x1);
+   snprintf(sets + (8 * (cells - i)), 9, "%08x", ~i);
+   spc = (i != 1) ? " " : "";
+   snprintf(pada + (11 * (cells - i)), 12, "0x%08x%s", i * 
0x1, spc);
+   snprintf(pads + (11 * (cells - i)), 12, "0x%08x%s", ~i, spc);
+   }
+
+   ut_assertok(fdt_create(fdt, size));
+   ut_assertok(fdt_finish_reservemap(fdt));
+   ut_assert(fdt_begin_node(fdt, "") >= 0);
+   ut_assertok(fdt_property_u32(fdt, "#address-cells", cells));
+   ut_assertok(fdt_property_u32(fdt, "#size-cells", cells));
+   ut_assert(fdt_begin_node(fdt, "memory") >= 0);
+   ut_assertok(fdt_property_string(fdt, "device_type", "memory"));
+   ut_assertok(fdt_property(fdt, "reg", ®s, cells * 2));
+   ut_assertok(fdt_end_node(fdt));
+   ut_assertok(fdt_end_node(fdt));
+   ut_assertok(fdt_finish(fdt));
+   fdt_shrink_to_minimum(fdt, 4096);   /* Resize with 4096 extra bytes 
*/
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Test updating the memory node */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt memory 0x%s 0x%s", seta, sets));
+   ut_assertok(run_commandf("fdt print /memory"));
+   ut_assert_nextline("memory {");
+   ut_assert_nextline("\tdevice_type = \"memory\";");
+   ut_assert_nextline("\treg = <%s %s>;", pada, pads);
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   free(sets);
+   free(seta);
+   free(pads);
+   free(pada);
+   free(regs);
+
+   return 0;
+}
+
+static int fdt_test_memory(struct unit_test_state *uts)
+{
+   /*
+* Test memory fixup for 32 and 64 bit systems, anything bigger is
+* so far unsupported and fails because of simple_stroull() being
+* 64bit tops in the 'fdt memory' command implementation.
+*/
+   fdt_test_memory_cells(uts, 1);
+   fdt_test_memory_cells(uts, 2);
+
+   /*
+* The 'fdt memory' command is limited to /memory node, it does
+* not support any other valid DT memory node format, which is
+* either one or multiple /memory@adresss nodes. Therefore, this
+* DT variant is not tested here.
+*/
+
+   return 0;
+}
+FDT_TEST(fdt_test_memory, UT_TESTF_CONSOLE_REC);
+
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test);
-- 
2.39.2



[PATCH 32/32] test: cmd: fdt: Add list of remaining missing tests

2023-02-27 Thread Marek Vasut
Add list of missing tests for the 'fdt' command, currently
the missing sandbox tests are only 'fdt boardsetup' and
'fdt checksign' .

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 02c13e2d9b9..cb9379cdd4f 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -15,6 +15,13 @@
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
+/*
+ * Missing tests:
+ * fdt boardsetup - Do board-specific set up
+ * fdt checksign [] - check FIT signature
+ *   - address of key blob
+ *   default gd->fdt_blob
+ */
 
 /* Declare a new fdt test */
 #define FDT_TEST(_name, _flags)UNIT_TEST(_name, _flags, fdt_test)
-- 
2.39.2



[PATCH 31/32] test: cmd: fdt: Test fdt apply

2023-02-27 Thread Marek Vasut
Add 'fdt chosen' test which works as follows:
- Create basic DT, map it to sysmem
- Apply DTO which adds single property via fragment (without address spec)
- Apply DTO which adds more properties (string, u32, empty) and a subnode,
  with phandle via frament@0 and thus tests /__symbols__ node
- Apply DTO which modifies property of the previous DTO via phandle and thus
  tests the /__fixups__ node
- Print modified DT, verify it contains updates from DTOs

The test case can be triggered using:
"
./u-boot -Dc 'ut fdt'
"
To dump the full output from commands used during test, add '-v' flag.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 test/cmd/fdt.c | 152 +
 1 file changed, 152 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 721916b070d..02c13e2d9b9 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -1338,6 +1338,158 @@ static int fdt_test_chosen(struct unit_test_state *uts)
 }
 FDT_TEST(fdt_test_chosen, UT_TESTF_CONSOLE_REC);
 
+static int fdt_test_apply(struct unit_test_state *uts)
+{
+   char fdt[8192], fdto[8192];
+   ulong addr, addro;
+
+   /* Create base DT with __symbols__ node */
+   ut_assertok(fdt_create(fdt, sizeof(fdt)));
+   ut_assertok(fdt_finish_reservemap(fdt));
+   ut_assert(fdt_begin_node(fdt, "") >= 0);
+   ut_assert(fdt_begin_node(fdt, "__symbols__") >= 0);
+   ut_assertok(fdt_end_node(fdt));
+   ut_assertok(fdt_end_node(fdt));
+   ut_assertok(fdt_finish(fdt));
+   fdt_shrink_to_minimum(fdt, 4096);   /* Resize with 4096 extra bytes 
*/
+   addr = map_to_sysmem(fdt);
+   set_working_fdt_addr(addr);
+
+   /* Create DTO which adds single property to root node / */
+   ut_assertok(fdt_create(fdto, sizeof(fdto)));
+   ut_assertok(fdt_finish_reservemap(fdto));
+   ut_assert(fdt_begin_node(fdto, "") >= 0);
+   ut_assert(fdt_begin_node(fdto, "fragment") >= 0);
+   ut_assertok(fdt_property_string(fdto, "target-path", "/"));
+   ut_assert(fdt_begin_node(fdto, "__overlay__") >= 0);
+   ut_assertok(fdt_property_string(fdto, "newstring", "newvalue"));
+   ut_assertok(fdt_end_node(fdto));
+   ut_assertok(fdt_end_node(fdto));
+   ut_assertok(fdt_finish(fdto));
+   addro = map_to_sysmem(fdto);
+
+   /* Test default DT print */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt print /"));
+   ut_assert_nextline("/ {");
+   ut_assert_nextline("\t__symbols__ {");
+   ut_assert_nextline("\t};");
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   /* Test simple DTO application */
+   ut_assertok(console_record_reset_enable());
+   ut_assertok(run_commandf("fdt apply 0x%08x", addro));
+   ut_assertok(run_commandf("fdt print /"));
+   ut_assert_nextline("/ {");
+   ut_assert_nextline("\tnewstring = \"newvalue\";");
+   ut_assert_nextline("\t__symbols__ {");
+   ut_assert_nextline("\t};");
+   ut_assert_nextline("};");
+   ut_assertok(ut_check_console_end(uts));
+
+   /*
+* Create complex DTO which:
+* - modifies newstring property in root node /
+* - adds new properties to root node /
+* - adds new subnode with properties to root node /
+* - adds phandle to the subnode and therefore __symbols__ node
+*/
+   ut_assertok(fdt_create(fdto, sizeof(fdto)));
+   ut_assertok(fdt_finish_reservemap(fdto));
+   ut_assert(fdt_begin_node(fdto, "") >= 0);
+   ut_assertok(fdt_property_cell(fdto, "#address-cells", 1));
+   ut_assertok(fdt_property_cell(fdto, "#size-cells", 0));
+
+   ut_assert(fdt_begin_node(fdto, "fragment@0") >= 0);
+   ut_assertok(fdt_property_string(fdto, "target-path", "/"));
+   ut_assert(fdt_begin_node(fdto, "__overlay__") >= 0);
+   ut_assertok(fdt_property_string(fdto, "newstring", "newervalue"));
+   ut_assertok(fdt_property_u32(fdto, "newu32", 0x12345678));
+   ut_assertok(fdt_property(fdto, "empty-property", NULL, 0));
+   ut_assert(fdt_begin_node(fdto, "subnode") >= 0);
+   ut_assertok(fdt_property_string(fdto, "subnewstring", "newervalue"));
+   ut_assertok(fdt_property_u32(fdto, "subnewu32", 0x12345678));
+   ut_assertok(fdt_property(fdto, "subempty-property", NULL, 0));
+   ut_assertok(fdt_property_u32(fdto, "phandle", 0x01));
+   ut_assertok(fdt_end_node(fdto));

[PATCH] console: Use only 0x00 as line separator for console recording

2023-02-27 Thread Marek Vasut
In case character 0x20 (space) is used as line separator,
character 0x9 (tab) is treated end of line. Commands which
output a lot of tabs, i.e. various tree printing commands
like 'fdt print' then end up generating a lot of newlines
in the recorded output, and the recorded output is corrupted.

Use character 0x00 (NUL) as separator instead to treat the
tabs as valid part of recorded line.

Suggested-by: Simon Glass 
Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 common/console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/console.c b/common/console.c
index e4301a49322..71ad8efd6f4 100644
--- a/common/console.c
+++ b/common/console.c
@@ -842,7 +842,7 @@ int console_record_readline(char *str, int maxlen)
return -ENOSPC;
 
return membuff_readline((struct membuff *)&gd->console_out, str,
-   maxlen, ' ');
+   maxlen, '\0');
 }
 
 int console_record_avail(void)
-- 
2.39.2



[PATCH] image: Fix potentially uninitialized data variable

2023-02-27 Thread Marek Vasut
In case fitImage support is disabled, and image_locate_script() is
passed a fitImage, then the 'data' variable is used uninitialized.
Drop into the default: branch of the switch-case statement and do
not return the uninitialized data, and do not modify the return
pointer either, just print an error message.

Reported by clang build:
"
$ make HOSTCC=clang CC=clang KCFLAGS=-Werror sandbox64_defconfig && make 
HOSTCC=clang CC=clang KCFLAGS=-Werror
...
boot/image-board.c:1006:7: error: variable 'data' is used uninitialized 
whenever switch case is taken [-Werror,-Wsometimes-uninitialized]
case IMAGE_FORMAT_LEGACY:
 ^~~
include/image.h:608:29: note: expanded from macro 'IMAGE_FORMAT_LEGACY'
^~~~
boot/image-board.c:1128:19: note: uninitialized use occurs here
*datap = (char *)data;
 ^~~~
boot/image-board.c:1001:11: note: initialize the variable 'data' to silence 
this warning
u32 *data;
     ^
  = NULL
"

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Michal Simek 
Cc: Oleksandr Suvorov 
Cc: Simon Glass 
Cc: Stefan Roese 
Cc: Tom Rini 
---
 boot/image-board.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/boot/image-board.c b/boot/image-board.c
index 25b60ec30b3..9bf70824cb7 100644
--- a/boot/image-board.c
+++ b/boot/image-board.c
@@ -1004,7 +1004,9 @@ int image_locate_script(void *buf, int size, const char 
*fit_uname,
 
switch (genimg_get_format(buf)) {
case IMAGE_FORMAT_LEGACY:
-   if (IS_ENABLED(CONFIG_LEGACY_IMAGE_FORMAT)) {
+   if (!IS_ENABLED(CONFIG_LEGACY_IMAGE_FORMAT)) {
+   goto exit_image_format;
+   } else {
hdr = buf;
 
if (!image_check_magic(hdr)) {
@@ -1047,7 +1049,9 @@ int image_locate_script(void *buf, int size, const char 
*fit_uname,
}
break;
case IMAGE_FORMAT_FIT:
-   if (IS_ENABLED(CONFIG_FIT)) {
+   if (!IS_ENABLED(CONFIG_FIT)) {
+   goto exit_image_format;
+   } else {
fit_hdr = buf;
if (fit_check_format(fit_hdr, IMAGE_SIZE_INVAL)) {
puts("Bad FIT image format\n");
@@ -1121,12 +1125,15 @@ fallback:
}
break;
default:
-   puts("Wrong image format for \"source\" command\n");
-   return -EPERM;
+   goto exit_image_format;
}
 
*datap = (char *)data;
*lenp = len;
 
return 0;
+
+exit_image_format:
+   puts("Wrong image format for \"source\" command\n");
+   return -EPERM;
 }
-- 
2.39.2



[PATCH 1/2] mmc: renesas-sdhi: Always configure default SDnH clock rate to 800 MHz

2023-02-27 Thread Marek Vasut
The prior stage bootloader might have left the SDnCKCR register in completely
arbitrary state before passing control to U-Boot, which includes the register
being populated with incorrect values. Currently the SDHI driver will attempt
to use clock framework to configure SDn clock, which may fail in case SDnCKCR
contains invalid values for the SDnH clock, because the clock framework would
not be able to determine SDnH clock rate and would get -EINVAL instead, which
in turn would not allow the clock framework to determine the correct SDn clock
divider ratio.

This failure occurs specifically in case SDnCKCR reads back 0x209 .

Correct the problem by first setting default SDnH clock rate to 800 MHz, thus
assuring the SDnCKCR SDnH bits are correct, and only afterward set up the SDn
clock rate to default 200 MHz.

Note that the SDHI driver may reconfigure SDnH clock later based on IOS
settings obtained from the attached card, the 800 MHz set up here is only
the default value.

Signed-off-by: Marek Vasut 
---
Cc: Jaehoon Chung 
Cc: Peng Fan 
---
 drivers/mmc/renesas-sdhi.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
index 4a1accebfcb..2473261f3c4 100644
--- a/drivers/mmc/renesas-sdhi.c
+++ b/drivers/mmc/renesas-sdhi.c
@@ -977,8 +977,16 @@ static int renesas_sdhi_probe(struct udevice *dev)
 
/* optional SDnH clock */
ret = clk_get_by_name(dev, "clkh", &priv->clkh);
-   if (ret < 0)
+   if (ret < 0) {
dev_dbg(dev, "failed to get clkh\n");
+   } else {
+   ret = clk_set_rate(&priv->clkh, 8);
+   if (ret < 0) {
+   dev_err(dev, "failed to set rate for SDnH clock\n");
+   clk_free(&priv->clk);
+   return ret;
+   }
+   }
 
/* set to max rate */
ret = clk_set_rate(&priv->clk, 2);
-- 
2.39.2



[PATCH 2/2] mmc: renesas-sdhi: Add proper probe error fail path

2023-02-27 Thread Marek Vasut
In case one of the calls in probe fail, trigger a fail path and
undo all the steps done in probe until the point of failure.
The current implementation failed to stop controller clock and
free claimed clock, so fix that. Furthermore, print return code
in error prints for easier debugging.

Signed-off-by: Marek Vasut 
---
Cc: Jaehoon Chung 
Cc: Peng Fan 
---
 drivers/mmc/renesas-sdhi.c | 26 +-
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
index 2473261f3c4..34119f949aa 100644
--- a/drivers/mmc/renesas-sdhi.c
+++ b/drivers/mmc/renesas-sdhi.c
@@ -982,37 +982,45 @@ static int renesas_sdhi_probe(struct udevice *dev)
} else {
ret = clk_set_rate(&priv->clkh, 8);
if (ret < 0) {
-   dev_err(dev, "failed to set rate for SDnH clock\n");
-   clk_free(&priv->clk);
-   return ret;
+   dev_err(dev, "failed to set rate for SDnH clock 
(%d)\n", ret);
+   goto err_clk;
}
}
 
/* set to max rate */
ret = clk_set_rate(&priv->clk, 2);
if (ret < 0) {
-   dev_err(dev, "failed to set rate for host clock\n");
-   clk_free(&priv->clk);
-   return ret;
+   dev_err(dev, "failed to set rate for SDn clock (%d)\n", ret);
+   goto err_clkh;
}
 
ret = clk_enable(&priv->clk);
if (ret) {
-   dev_err(dev, "failed to enable host clock\n");
-   return ret;
+   dev_err(dev, "failed to enable SDn clock (%d)\n", ret);
+   goto err_clkh;
}
 
priv->quirks = quirks;
ret = tmio_sd_probe(dev, quirks);
+   if (ret)
+   goto err_tmio_probe;
 
renesas_sdhi_filter_caps(dev);
 
 #if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) || \
 CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) || \
 CONFIG_IS_ENABLED(MMC_HS400_SUPPORT)
-   if (!ret && (priv->caps & TMIO_SD_CAP_RCAR_UHS))
+   if (priv->caps & TMIO_SD_CAP_RCAR_UHS)
renesas_sdhi_reset_tuning(priv);
 #endif
+   return 0;
+
+err_tmio_probe:
+   clk_disable(&priv->clk);
+err_clkh:
+   clk_free(&priv->clkh);
+err_clk:
+   clk_free(&priv->clk);
return ret;
 }
 
-- 
2.39.2



[PATCH] CI: gitlab: Collect pytest artifacts

2023-02-27 Thread Marek Vasut
Copy build artifacts for all test.py tests, so they show up in
artifacts storage for later inspection. The test.py tests output
in CI is basically useless, but it is far more useful in the html
output for analysis and debugging.

Suggested-by: Simon Glass 
Signed-off-by: Marek Vasut 
---
Cc: Simon Glass 
Cc: Tom Rini 
---
 .gitlab-ci.yml | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 272d69e2206..1b761f26e9a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -77,9 +77,12 @@ stages:
 ${TEST_PY_TEST_SPEC:+"-k ${TEST_PY_TEST_SPEC}"}
 --build-dir "$UBOOT_TRAVIS_BUILD_DIR"
 # It seems that the files in /tmp go away, so copy out what we need
-- if [[ "${TEST_PY_BD}" == "coreboot" ]]; then
-cp -v /tmp/coreboot/*.{html,css} .;
-  fi
+- cp -v /tmp/${TEST_PY_BD}/*.{html,css} .
+  artifacts:
+paths:
+  - "*.html"
+  - "*.css"
+expire_in: 1 week
 
 build all 32bit ARM platforms:
   stage: world build
@@ -454,9 +457,4 @@ coreboot test.py:
 TEST_PY_BD: "coreboot"
 TEST_PY_TEST_SPEC: "not sleep"
 TEST_PY_ID: "--id qemu"
-  artifacts:
-paths:
-  - "*.html"
-  - "*.css"
-expire_in: 1 week
   <<: *buildman_and_testpy_dfn
-- 
2.39.2



[PATCH 1/3] sysinfo: rcar3: Fix Draak and Eagle board code

2023-02-27 Thread Marek Vasut
From: Tam Nguyen 

Correct the board code ID based on the hardware documentation

Reviewed-by: Marek Vasut 
Signed-off-by: Tam Nguyen 
Signed-off-by: Hai Pham 
Signed-off-by: Marek Vasut 
---
 drivers/sysinfo/rcar3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/sysinfo/rcar3.c b/drivers/sysinfo/rcar3.c
index c2f4ddfbbe3..c0afc92f675 100644
--- a/drivers/sysinfo/rcar3.c
+++ b/drivers/sysinfo/rcar3.c
@@ -16,12 +16,12 @@
 #define BOARD_SALVATOR_X   0x0
 #define BOARD_KRIEK0x1
 #define BOARD_STARTER_KIT  0x2
+#define BOARD_EAGLE0x3
 #define BOARD_SALVATOR_XS  0x4
+#define BOARD_DRAAK0x7
 #define BOARD_EBISU0x8
 #define BOARD_STARTER_KIT_PRE  0xB
 #define BOARD_EBISU_4D 0xD
-#define BOARD_DRAAK0xE
-#define BOARD_EAGLE0xF
 
 /**
  * struct sysinfo_rcar_priv - sysinfo private data
-- 
2.39.2



[PATCH 3/3] ARM: dts: renesas: Enable sysinfo on R-Car D3 Draak

2023-02-27 Thread Marek Vasut
From: Tam Nguyen 

Enable support for sysinfo on R-Car D3 Draak board. The sysinfo is used
e.g. to access and decode board-specific information and then in turn
used by board-info to print those information.

Reviewed-by: Marek Vasut 
Signed-off-by: Tam Nguyen 
Signed-off-by: Hai Pham 
Signed-off-by: Marek Vasut 
[Marek: Drop compatible from I2C node, this is in r8a77995.dtsi already.
Drop status = "okay" from EEPROM node.
Add dts: tag.
Fix Kconfig EEPROM address to be 0x50 and match the DT, sync config.]
---
 arch/arm/dts/r8a77995-draak-u-boot.dts | 19 +++
 configs/r8a77995_draak_defconfig   |  5 +
 2 files changed, 24 insertions(+)

diff --git a/arch/arm/dts/r8a77995-draak-u-boot.dts 
b/arch/arm/dts/r8a77995-draak-u-boot.dts
index 0ea2570c1dc..260bc5da19f 100644
--- a/arch/arm/dts/r8a77995-draak-u-boot.dts
+++ b/arch/arm/dts/r8a77995-draak-u-boot.dts
@@ -8,6 +8,25 @@
 #include "r8a77995-draak.dts"
 #include "r8a77995-u-boot.dtsi"
 
+/ {
+   sysinfo {
+   compatible = "renesas,rcar-sysinfo";
+   i2c-eeprom = <&sysinfo_eeprom>;
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&i2c0 {
+   u-boot,dm-pre-reloc;
+
+   sysinfo_eeprom: eeprom@50 {
+   compatible = "rohm,br24t01", "atmel,24c01";
+   reg = <0x50>;
+   pagesize = <8>;
+   u-boot,dm-pre-reloc;
+   };
+};
+
 &rpc {
reg = <0 0xee20 0 0x100>, <0 0x0800 0 0x0400>;
status = "disabled";
diff --git a/configs/r8a77995_draak_defconfig b/configs/r8a77995_draak_defconfig
index 4ddb66aef9c..a09b33e7740 100644
--- a/configs/r8a77995_draak_defconfig
+++ b/configs/r8a77995_draak_defconfig
@@ -33,6 +33,7 @@ CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=64
 CONFIG_SYS_PBSIZE=2068
 CONFIG_CMD_BOOTZ=y
+CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=10
 CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
@@ -65,6 +66,9 @@ CONFIG_DFU_SF=y
 CONFIG_RCAR_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_RCAR_I2C=y
+CONFIG_MISC=y
+CONFIG_I2C_EEPROM=y
+CONFIG_SYS_I2C_EEPROM_ADDR=0x50
 CONFIG_MMC_IO_VOLTAGE=y
 CONFIG_MMC_UHS_SUPPORT=y
 CONFIG_MMC_HS200_SUPPORT=y
@@ -94,6 +98,7 @@ CONFIG_SCIF_CONSOLE=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_RENESAS_RPC_SPI=y
+CONFIG_SYSINFO=y
 CONFIG_TEE=y
 CONFIG_OPTEE=y
 CONFIG_USB=y
-- 
2.39.2



[PATCH 2/3] ARM: dts: renesas: Enable sysinfo on R-Car V3H Condor/Condor-I

2023-02-27 Thread Marek Vasut
From: Tam Nguyen 

Add new sysinfo IDs for R-Car V3H Condor/Condor-I .

Enable support for sysinfo on R-Car V3H Condor/Condor-I. The sysinfo is
used e.g. to access and decode board-specific information and then in
turn used by board-info to print those information.

Reviewed-by: Marek Vasut 
Signed-off-by: Tam Nguyen 
Signed-off-by: Hai Pham 
Signed-off-by: Marek Vasut 
[Marek: Drop compatible from I2C node, this is in r8a77980.dtsi already.
Drop status = "okay" from EEPROM node.
Add dts: tag.
Update the commit message, note the new sysinfo IDs.
Fix Kconfig EEPROM address to be 0x50 and match the DT, sync config.]
---
 arch/arm/dts/r8a77980-condor-u-boot.dts | 17 +
 configs/r8a77980_condor_defconfig   |  5 +
 drivers/sysinfo/rcar3.c | 15 +++
 3 files changed, 37 insertions(+)

diff --git a/arch/arm/dts/r8a77980-condor-u-boot.dts 
b/arch/arm/dts/r8a77980-condor-u-boot.dts
index 576a74e6030..530abdb72bc 100644
--- a/arch/arm/dts/r8a77980-condor-u-boot.dts
+++ b/arch/arm/dts/r8a77980-condor-u-boot.dts
@@ -12,6 +12,23 @@
aliases {
spi0 = &rpc;
};
+
+   sysinfo {
+   compatible = "renesas,rcar-sysinfo";
+   i2c-eeprom = <&sysinfo_eeprom>;
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&i2c0 {
+   u-boot,dm-pre-reloc;
+
+   sysinfo_eeprom: eeprom@50 {
+   compatible = "rohm,br24t01", "atmel,24c01";
+   reg = <0x50>;
+   pagesize = <8>;
+   u-boot,dm-pre-reloc;
+   };
 };
 
 &rpc {
diff --git a/configs/r8a77980_condor_defconfig 
b/configs/r8a77980_condor_defconfig
index 0c3493cdf8d..e1b3dc5d38a 100644
--- a/configs/r8a77980_condor_defconfig
+++ b/configs/r8a77980_condor_defconfig
@@ -33,6 +33,7 @@ CONFIG_HUSH_PARSER=y
 CONFIG_SYS_MAXARGS=64
 CONFIG_SYS_PBSIZE=2068
 CONFIG_CMD_BOOTZ=y
+CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=10
 CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
@@ -64,6 +65,9 @@ CONFIG_DFU_SF=y
 CONFIG_RCAR_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_RCAR_I2C=y
+CONFIG_MISC=y
+CONFIG_I2C_EEPROM=y
+CONFIG_SYS_I2C_EEPROM_ADDR=0x50
 CONFIG_MMC_IO_VOLTAGE=y
 CONFIG_MMC_UHS_SUPPORT=y
 CONFIG_MMC_HS200_SUPPORT=y
@@ -84,6 +88,7 @@ CONFIG_SCIF_CONSOLE=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_RENESAS_RPC_SPI=y
+CONFIG_SYSINFO=y
 CONFIG_TEE=y
 CONFIG_OPTEE=y
 CONFIG_USB=y
diff --git a/drivers/sysinfo/rcar3.c b/drivers/sysinfo/rcar3.c
index c0afc92f675..7b127986da7 100644
--- a/drivers/sysinfo/rcar3.c
+++ b/drivers/sysinfo/rcar3.c
@@ -18,10 +18,12 @@
 #define BOARD_STARTER_KIT  0x2
 #define BOARD_EAGLE0x3
 #define BOARD_SALVATOR_XS  0x4
+#define BOARD_CONDOR   0x6
 #define BOARD_DRAAK0x7
 #define BOARD_EBISU0x8
 #define BOARD_STARTER_KIT_PRE  0xB
 #define BOARD_EBISU_4D 0xD
+#define BOARD_CONDOR_I 0x10
 
 /**
  * struct sysinfo_rcar_priv - sysinfo private data
@@ -65,6 +67,7 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv)
const u8 board_rev = priv->val & BOARD_REV_MASK;
bool salvator_xs = false;
bool ebisu_4d = false;
+   bool condor_i = false;
char rev_major = '?';
char rev_minor = '?';
 
@@ -138,6 +141,18 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv 
*priv)
 "Renesas Kriek board rev %c.%c",
 rev_major, rev_minor);
return;
+   case BOARD_CONDOR_I:
+   condor_i = true;
+   fallthrough;
+   case BOARD_CONDOR:
+   if (!board_rev) { /* Only rev 0 is valid */
+   rev_major = '1';
+   rev_minor = '0';
+   }
+   snprintf(priv->boardmodel, sizeof(priv->boardmodel),
+   "Renesas Condor%s board rev %c.%c",
+   condor_i ? "-I" : "", rev_major, rev_minor);
+   return;
default:
snprintf(priv->boardmodel, sizeof(priv->boardmodel),
 "Renesas -Unknown- board rev ?.?");
-- 
2.39.2



[PATCH] ARM: renesas: Remove defines for USB on Eagle/Condor

2023-02-27 Thread Marek Vasut
From: Hai Pham 

The Eagle board based on R-Car V3M, which does not support any USB
interfaces. The same applies for the Condor board based on R-Car V3H.

Remove the defines.

Reviewed-by: Marek Vasut 
Signed-off-by: Hai Pham 
Signed-off-by: Marek Vasut 
---
 configs/r8a77970_eagle_defconfig  | 6 --
 configs/r8a77980_condor_defconfig | 6 --
 2 files changed, 12 deletions(-)

diff --git a/configs/r8a77970_eagle_defconfig b/configs/r8a77970_eagle_defconfig
index efbfd6559e7..37af576493b 100644
--- a/configs/r8a77970_eagle_defconfig
+++ b/configs/r8a77970_eagle_defconfig
@@ -37,7 +37,6 @@ CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_SPI=y
-CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
@@ -82,9 +81,4 @@ CONFIG_DM_SPI=y
 CONFIG_RENESAS_RPC_SPI=y
 CONFIG_TEE=y
 CONFIG_OPTEE=y
-CONFIG_USB=y
-CONFIG_USB_XHCI_HCD=y
-CONFIG_USB_EHCI_HCD=y
-CONFIG_USB_EHCI_GENERIC=y
-CONFIG_USB_STORAGE=y
 CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/r8a77980_condor_defconfig 
b/configs/r8a77980_condor_defconfig
index e1b3dc5d38a..687a894d80c 100644
--- a/configs/r8a77980_condor_defconfig
+++ b/configs/r8a77980_condor_defconfig
@@ -39,7 +39,6 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_SPI=y
-CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
@@ -91,9 +90,4 @@ CONFIG_RENESAS_RPC_SPI=y
 CONFIG_SYSINFO=y
 CONFIG_TEE=y
 CONFIG_OPTEE=y
-CONFIG_USB=y
-CONFIG_USB_XHCI_HCD=y
-CONFIG_USB_EHCI_HCD=y
-CONFIG_USB_EHCI_GENERIC=y
-CONFIG_USB_STORAGE=y
 CONFIG_OF_LIBFDT_OVERLAY=y
-- 
2.39.2



[PATCH] ARM: renesas: Demote overlap memory nodes message to debug on Gen3

2023-02-27 Thread Marek Vasut
From: Hai Pham 

The R-Car DTs might contains multiple /memory@* nodes from various
sources, i.e. prior firmware, u-boot itself or the OS

The duplicates are likely to happen so the messages are not meaningful
in the default setting since we have already handled that.

Reduce the message to debug level.

Reviewed-by: Marek Vasut 
Signed-off-by: Hai Pham 
Signed-off-by: Marek Vasut 
---
 board/renesas/rcar-common/common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/board/renesas/rcar-common/common.c 
b/board/renesas/rcar-common/common.c
index daa1beb14f8..0ddae95e230 100644
--- a/board/renesas/rcar-common/common.c
+++ b/board/renesas/rcar-common/common.c
@@ -73,9 +73,9 @@ static int is_mem_overlap(void *blob, int first_mem_node, int 
curr_mem_node)
if (curr_mem_res.start >= first_mem_res.end)
continue;
 
-   printf("Overlap found: 0x%llx..0x%llx / 
0x%llx..0x%llx\n",
-   first_mem_res.start, first_mem_res.end,
-   curr_mem_res.start, curr_mem_res.end);
+   log_debug("Overlap found: 0x%llx..0x%llx / 
0x%llx..0x%llx\n",
+ first_mem_res.start, first_mem_res.end,
+ curr_mem_res.start, curr_mem_res.end);
 
return 1;
}
-- 
2.39.2



[PATCH] ARM: renesas: Enable DTO support by default on R-Car Gen3

2023-02-27 Thread Marek Vasut
All R-Car Gen3 defconfigs present in U-Boot do enable DTO support,
enable it for all of R-Car Gen3 by default in Kconfig instead, so
that no new boards would miss this functionality.

Signed-off-by: Marek Vasut 
---
 arch/arm/mach-rmobile/Kconfig.64 | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-rmobile/Kconfig.64 b/arch/arm/mach-rmobile/Kconfig.64
index 8e617e58244..554130b435b 100644
--- a/arch/arm/mach-rmobile/Kconfig.64
+++ b/arch/arm/mach-rmobile/Kconfig.64
@@ -204,4 +204,7 @@ config SYS_MALLOC_F_LEN
 config DM_RESET
default y if RCAR_GEN3
 
+config OF_LIBFDT_OVERLAY
+   default y if RCAR_GEN3
+
 endif
-- 
2.39.2



[PATCH 1/2] ARM: renesas: falcon: Initialize ARM generic timer and GICv3 if EL3

2023-02-27 Thread Marek Vasut
From: Hai Pham 

U-Boot executes at EL3 is required to initalize those settings.
In other cases, they will be done by prior-stage firmware instead.

This fixes crash when U-Boot is at non-secure exception level.

Reviewed-by: Marek Vasut 
Signed-off-by: Hai Pham 
Signed-off-by: Marek Vasut 
---
 board/renesas/falcon/falcon.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/board/renesas/falcon/falcon.c b/board/renesas/falcon/falcon.c
index b0cb4e747b6..b7e7fd9003a 100644
--- a/board/renesas/falcon/falcon.c
+++ b/board/renesas/falcon/falcon.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -69,7 +70,8 @@ static void init_gic_v3(void)
 
 void s_init(void)
 {
-   init_generic_timer();
+   if (current_el() == 3)
+   init_generic_timer();
 }
 
 int board_early_init_f(void)
@@ -86,7 +88,8 @@ int board_init(void)
/* address of boot parameters */
gd->bd->bi_boot_params = CONFIG_TEXT_BASE + 0x5;
 
-   init_gic_v3();
+   if (current_el() == 3)
+   init_gic_v3();
 
return 0;
 }
-- 
2.39.2



[PATCH 2/2] ARM: renesas: falcon: Enable RWDT reset for V3U Falcon

2023-02-27 Thread Marek Vasut
From: Hai Pham 

Enable RWDT reset on Reset Controller so that it can be used as
reset trigger source for V3U Falcon.

Reviewed-by: Marek Vasut 
Signed-off-by: Hai Pham 
Signed-off-by: Marek Vasut  # Use one 
current_el() in board_init
---
 board/renesas/falcon/falcon.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/board/renesas/falcon/falcon.c b/board/renesas/falcon/falcon.c
index b7e7fd9003a..ab7464d0ee3 100644
--- a/board/renesas/falcon/falcon.c
+++ b/board/renesas/falcon/falcon.c
@@ -83,21 +83,27 @@ int board_early_init_f(void)
return 0;
 }
 
+#define RST_BASE   0xE616 /* Domain0 */
+#define RST_SRESCR0(RST_BASE + 0x18)
+#define RST_SPRES  0x5AA58000
+#define RST_WDTRSTCR   (RST_BASE + 0x10)
+#define RST_RWDT   0xA55A8002
+
 int board_init(void)
 {
/* address of boot parameters */
gd->bd->bi_boot_params = CONFIG_TEXT_BASE + 0x5;
 
-   if (current_el() == 3)
+   if (current_el() == 3) {
init_gic_v3();
 
+   /* Enable RWDT reset */
+   writel(RST_RWDT, RST_WDTRSTCR);
+   }
+
return 0;
 }
 
-#define RST_BASE   0xE616 /* Domain0 */
-#define RST_SRESCR0(RST_BASE + 0x18)
-#define RST_SPRES  0x5AA58000
-
 void reset_cpu(void)
 {
writel(RST_SPRES, RST_SRESCR0);
-- 
2.39.2



[PATCH 1/2] i2c: rcar_iic: Sort Kconfig depends list ascending

2023-02-27 Thread Marek Vasut
Sort the list of "depends" symbols in ascending order.
No functional change.

Signed-off-by: Marek Vasut 
---
Cc: Heiko Schocher 
---
 drivers/i2c/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 3279fef1eb0..aa51f0c869e 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -492,7 +492,7 @@ config SYS_I2C_RCAR_I2C
 
 config SYS_I2C_RCAR_IIC
bool "Renesas RCar Gen3 IIC driver"
-   depends on (RCAR_GEN3 || RCAR_GEN2) && DM_I2C
+   depends on (RCAR_GEN2 || RCAR_GEN3) && DM_I2C
help
  Support for Renesas RCar Gen3 IIC controller.
 
-- 
2.39.2



[PATCH 2/2] i2c: rcar_i2c: Sort Kconfig depends list ascending

2023-02-27 Thread Marek Vasut
Sort the list of "depends" symbols in ascending order.
No functional change.

Signed-off-by: Marek Vasut 
---
Cc: Heiko Schocher 
---
 drivers/i2c/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index aa51f0c869e..1d998d14732 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -486,7 +486,7 @@ config SYS_I2C_OMAP24XX
 
 config SYS_I2C_RCAR_I2C
bool "Renesas RCar I2C driver"
-   depends on (RCAR_GEN3 || RCAR_GEN2) && DM_I2C
+   depends on (RCAR_GEN2 || RCAR_GEN3) && DM_I2C
help
  Support for Renesas RCar I2C controller.
 
-- 
2.39.2



[PATCH] net: ravb: Support fixed PHY in R-Car

2023-02-27 Thread Marek Vasut
From: Mikhail Lappo 

Calling old U-Boot API doesn't allow to use fixed PHY.
Searching by mask is the part of new function, after
scanning FDT for a fixed PHY definition

Fixes: e821a7bdb13 ("net: ravb: Detect PHY correctly")
Reviewed-by: Marek Vasut 
Signed-off-by: Mikhail Lappo 
Signed-off-by: Hai Pham 
[Hai Pham: Drop phy_connect_dev since it's called in phy_connect]
Signed-off-by: Marek Vasut 
[Marek: Use mask -1 instead of 0 to reinstate the search behavior
over all PHY addresses. Add Fixes tag, sort the tag list.]
---
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
 drivers/net/ravb.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
index 5a835cc06ff..0bc50dc7335 100644
--- a/drivers/net/ravb.c
+++ b/drivers/net/ravb.c
@@ -310,7 +310,7 @@ static int ravb_phy_config(struct udevice *dev)
struct ravb_priv *eth = dev_get_priv(dev);
struct eth_pdata *pdata = dev_get_plat(dev);
struct phy_device *phydev;
-   int mask = 0x, reg;
+   int reg;
 
if (dm_gpio_is_valid(ð->reset_gpio)) {
dm_gpio_set_value(ð->reset_gpio, 1);
@@ -319,12 +319,10 @@ static int ravb_phy_config(struct udevice *dev)
mdelay(1);
}
 
-   phydev = phy_find_by_mask(eth->bus, mask);
+   phydev = phy_connect(eth->bus, -1, dev, pdata->phy_interface);
if (!phydev)
return -ENODEV;
 
-   phy_connect_dev(phydev, dev, pdata->phy_interface);
-
eth->phydev = phydev;
 
phydev->supported &= SUPPORTED_100baseT_Full |
-- 
2.39.2



[PATCH 1/6] misc: ub251xb: Fix use of CONFIG_IS_ENABLED on DM_REGULATOR

2023-02-27 Thread Marek Vasut
The DM_REGULATOR symbol has SPL counterpart in:
  drivers/power/regulator/Kconfig:config SPL_DM_REGULATOR
Use CONFIG_IS_ENABLED() macro to match on the correct
variant depending on the build stage.

Signed-off-by: Marek Vasut 
---
Cc: Anatolij Gustschin 
Cc: Jaehoon Chung 
Cc: Marek Vasut 
Cc: Peng Fan 
Cc: Stefan Herbrechtsmeier 
---
 drivers/misc/usb251xb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/usb251xb.c b/drivers/misc/usb251xb.c
index a78ad1843ae..92e92ba5e62 100644
--- a/drivers/misc/usb251xb.c
+++ b/drivers/misc/usb251xb.c
@@ -334,7 +334,7 @@ static int usb251xb_probe(struct udevice *dev)
struct usb251xb *hub = dev_get_priv(dev);
int err;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR) && hub->vdd) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && hub->vdd) {
err = regulator_set_enable(hub->vdd, true);
if (err)
return err;
@@ -391,7 +391,7 @@ static int usb251xb_of_to_plat(struct udevice *dev)
return err;
}
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
err = device_get_supply_regulator(dev, "vdd-supply",
  &hub->vdd);
if (err && err != -ENOENT) {
-- 
2.39.2



[PATCH 4/6] video: rm68200: Fix use of CONFIG_IS_ENABLED on DM_REGULATOR

2023-02-27 Thread Marek Vasut
The DM_REGULATOR symbol has SPL counterpart in:
  drivers/power/regulator/Kconfig:config SPL_DM_REGULATOR
Use CONFIG_IS_ENABLED() macro to match on the correct
variant depending on the build stage.

Signed-off-by: Marek Vasut 
---
Cc: Anatolij Gustschin 
Cc: Jaehoon Chung 
Cc: Marek Vasut 
Cc: Peng Fan 
Cc: Stefan Herbrechtsmeier 
---
 drivers/video/raydium-rm68200.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/raydium-rm68200.c b/drivers/video/raydium-rm68200.c
index 373668d28bf..f1fce55a2cb 100644
--- a/drivers/video/raydium-rm68200.c
+++ b/drivers/video/raydium-rm68200.c
@@ -266,7 +266,7 @@ static int rm68200_panel_of_to_plat(struct udevice *dev)
struct rm68200_panel_priv *priv = dev_get_priv(dev);
int ret;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
ret =  device_get_supply_regulator(dev, "power-supply",
   &priv->reg);
if (ret && ret != -ENOENT) {
@@ -299,7 +299,7 @@ static int rm68200_panel_probe(struct udevice *dev)
struct mipi_dsi_panel_plat *plat = dev_get_plat(dev);
int ret;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR) && priv->reg) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && priv->reg) {
ret = regulator_set_enable(priv->reg, true);
if (ret)
return ret;
-- 
2.39.2



[PATCH 2/6] mmc: npcm_sdhci: Fix use of CONFIG_IS_ENABLED on DM_REGULATOR

2023-02-27 Thread Marek Vasut
The DM_REGULATOR symbol has SPL counterpart in:
  drivers/power/regulator/Kconfig:config SPL_DM_REGULATOR
Use CONFIG_IS_ENABLED() macro to match on the correct
variant depending on the build stage.

Signed-off-by: Marek Vasut 
---
Cc: Anatolij Gustschin 
Cc: Jaehoon Chung 
Cc: Marek Vasut 
Cc: Peng Fan 
Cc: Stefan Herbrechtsmeier 
---
 drivers/mmc/npcm_sdhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/npcm_sdhci.c b/drivers/mmc/npcm_sdhci.c
index 7eb17cce0b3..d63521d6855 100644
--- a/drivers/mmc/npcm_sdhci.c
+++ b/drivers/mmc/npcm_sdhci.c
@@ -36,7 +36,7 @@ static int npcm_sdhci_probe(struct udevice *dev)
return ret;
}
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
device_get_supply_regulator(dev, "vqmmc-supply", &vqmmc_supply);
vqmmc_uv = dev_read_u32_default(dev, "vqmmc-microvolt", 0);
/* Set IO voltage */
-- 
2.39.2



[PATCH 3/6] video: otm8009a: Fix use of CONFIG_IS_ENABLED on DM_REGULATOR

2023-02-27 Thread Marek Vasut
The DM_REGULATOR symbol has SPL counterpart in:
  drivers/power/regulator/Kconfig:config SPL_DM_REGULATOR
Use CONFIG_IS_ENABLED() macro to match on the correct
variant depending on the build stage.

Signed-off-by: Marek Vasut 
---
Cc: Anatolij Gustschin 
Cc: Jaehoon Chung 
Cc: Marek Vasut 
Cc: Peng Fan 
Cc: Stefan Herbrechtsmeier 
---
 drivers/video/orisetech_otm8009a.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/orisetech_otm8009a.c 
b/drivers/video/orisetech_otm8009a.c
index 95738e34bf6..848f174b6e4 100644
--- a/drivers/video/orisetech_otm8009a.c
+++ b/drivers/video/orisetech_otm8009a.c
@@ -300,7 +300,7 @@ static int otm8009a_panel_of_to_plat(struct udevice *dev)
struct otm8009a_panel_priv *priv = dev_get_priv(dev);
int ret;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
ret =  device_get_supply_regulator(dev, "power-supply",
   &priv->reg);
if (ret && ret != -ENOENT) {
@@ -326,7 +326,7 @@ static int otm8009a_panel_probe(struct udevice *dev)
struct mipi_dsi_panel_plat *plat = dev_get_plat(dev);
int ret;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR) && priv->reg) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && priv->reg) {
dev_dbg(dev, "enable regulator '%s'\n", priv->reg->name);
ret = regulator_set_enable(priv->reg, true);
if (ret)
-- 
2.39.2



[PATCH 5/6] video: simple-panel: Fix use of CONFIG_IS_ENABLED on DM_REGULATOR

2023-02-27 Thread Marek Vasut
The DM_REGULATOR symbol has SPL counterpart in:
  drivers/power/regulator/Kconfig:config SPL_DM_REGULATOR
Use CONFIG_IS_ENABLED() macro to match on the correct
variant depending on the build stage.

Signed-off-by: Marek Vasut 
---
Cc: Anatolij Gustschin 
Cc: Jaehoon Chung 
Cc: Marek Vasut 
Cc: Peng Fan 
Cc: Stefan Herbrechtsmeier 
---
 drivers/video/simple_panel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/simple_panel.c b/drivers/video/simple_panel.c
index 91c91ee75d8..092906c82c9 100644
--- a/drivers/video/simple_panel.c
+++ b/drivers/video/simple_panel.c
@@ -53,7 +53,7 @@ static int simple_panel_of_to_plat(struct udevice *dev)
struct simple_panel_priv *priv = dev_get_priv(dev);
int ret;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
   "power-supply", &priv->reg);
if (ret) {
@@ -89,7 +89,7 @@ static int simple_panel_probe(struct udevice *dev)
struct simple_panel_priv *priv = dev_get_priv(dev);
int ret;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR) && priv->reg) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && priv->reg) {
debug("%s: Enable regulator '%s'\n", __func__, priv->reg->name);
ret = regulator_set_enable(priv->reg, true);
if (ret)
-- 
2.39.2



[PATCH 6/6] video: tl070wsh30: Fix use of CONFIG_IS_ENABLED on DM_REGULATOR

2023-02-27 Thread Marek Vasut
The DM_REGULATOR symbol has SPL counterpart in:
  drivers/power/regulator/Kconfig:config SPL_DM_REGULATOR
Use CONFIG_IS_ENABLED() macro to match on the correct
variant depending on the build stage.

Signed-off-by: Marek Vasut 
---
Cc: Anatolij Gustschin 
Cc: Jaehoon Chung 
Cc: Marek Vasut 
Cc: Peng Fan 
Cc: Stefan Herbrechtsmeier 
---
 drivers/video/tdo-tl070wsh30.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/tdo-tl070wsh30.c b/drivers/video/tdo-tl070wsh30.c
index 7ad0af73f05..273672db024 100644
--- a/drivers/video/tdo-tl070wsh30.c
+++ b/drivers/video/tdo-tl070wsh30.c
@@ -75,7 +75,7 @@ static int tl070wsh30_panel_of_to_plat(struct udevice *dev)
struct tl070wsh30_panel_priv *priv = dev_get_priv(dev);
int ret;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
ret =  device_get_supply_regulator(dev, "power-supply",
   &priv->reg);
if (ret && ret != -ENOENT) {
@@ -108,7 +108,7 @@ static int tl070wsh30_panel_probe(struct udevice *dev)
struct mipi_dsi_panel_plat *plat = dev_get_plat(dev);
int ret;
 
-   if (IS_ENABLED(CONFIG_DM_REGULATOR) && priv->reg) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && priv->reg) {
ret = regulator_set_enable(priv->reg, true);
if (ret)
return ret;
-- 
2.39.2



Re: [PATCH] CI: gitlab: Collect pytest artifacts

2023-02-27 Thread Marek Vasut

On 2/28/23 00:36, Tom Rini wrote:

[...]


@@ -454,9 +457,4 @@ coreboot test.py:
  TEST_PY_BD: "coreboot"
  TEST_PY_TEST_SPEC: "not sleep"
  TEST_PY_ID: "--id qemu"
-  artifacts:
-paths:
-  - "*.html"
-  - "*.css"
-expire_in: 1 week
<<: *buildman_and_testpy_dfn


So, what looks like a debugging artifact was included in the proper
patch and merged, and yes,
https://u-boot.source-pages.denx.de/-/u-boot/-/jobs/585388/artifacts/test-log.html
is quite handy in the case of test failure.


Do you also get SSL_ERROR_BAD_CERT_DOMAIN warning ? That might be 
something to fix. +CC Harald.


[PATCH v2] CI: gitlab: Collect pytest artifacts

2023-02-27 Thread Marek Vasut
Copy build artifacts for all test.py tests, so they show up in
artifacts storage for later inspection. The test.py tests output
in CI is basically useless, but it is far more useful in the html
output for analysis and debugging.

Reviewed-by: Tom Rini 
Suggested-by: Simon Glass 
Signed-off-by: Marek Vasut 
---
Cc: Simon Glass 
Cc: Tom Rini 
---
V2: - Drop bogus comment
- Add RB from Tom
---
 .gitlab-ci.yml | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 272d69e2206..3a2fd3dee08 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -76,10 +76,12 @@ stages:
   ./test/py/test.py -ra --bd ${TEST_PY_BD} ${TEST_PY_ID}
 ${TEST_PY_TEST_SPEC:+"-k ${TEST_PY_TEST_SPEC}"}
 --build-dir "$UBOOT_TRAVIS_BUILD_DIR"
-# It seems that the files in /tmp go away, so copy out what we need
-- if [[ "${TEST_PY_BD}" == "coreboot" ]]; then
-cp -v /tmp/coreboot/*.{html,css} .;
-  fi
+- cp -v /tmp/${TEST_PY_BD}/*.{html,css} .
+  artifacts:
+paths:
+  - "*.html"
+  - "*.css"
+expire_in: 1 week
 
 build all 32bit ARM platforms:
   stage: world build
@@ -454,9 +456,4 @@ coreboot test.py:
 TEST_PY_BD: "coreboot"
 TEST_PY_TEST_SPEC: "not sleep"
 TEST_PY_ID: "--id qemu"
-  artifacts:
-paths:
-  - "*.html"
-  - "*.css"
-expire_in: 1 week
   <<: *buildman_and_testpy_dfn
-- 
2.39.2



[PATCH] Kconfig: Sort the BUILD_TARGET list

2023-02-27 Thread Marek Vasut
Sort the defaults list in BUILD_TARGET Kconfig option. No functional change.

Signed-off-by: Marek Vasut 
---
Cc: Heinrich Schuchardt 
Cc: Simon Glass 
Cc: Tom Rini 
---
 Kconfig | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Kconfig b/Kconfig
index a75cce7e28f..6dd524b0acb 100644
--- a/Kconfig
+++ b/Kconfig
@@ -454,16 +454,16 @@ config REMAKE_ELF
 
 config BUILD_TARGET
string "Build target special images"
+   default "u-boot-elf.srec" if RCAR_GEN3
+   default "u-boot-with-spl.bin" if ARCH_AT91 && SPL_NAND_SUPPORT
+   default "u-boot-with-spl.bin" if MPC85xx && !E500MC && !E5500 && !E6500 
&& SPL
+   default "u-boot-with-spl.imx" if ARCH_MX6 && SPL
+   default "u-boot-with-spl.kwb" if ARMADA_32BIT && SPL
default "u-boot-with-spl.sfp" if TARGET_SOCFPGA_ARRIA10
default "u-boot-with-spl.sfp" if TARGET_SOCFPGA_GEN5
-   default "u-boot-with-spl.kwb" if ARMADA_32BIT && SPL
-   default "u-boot-elf.srec" if RCAR_GEN3
default "u-boot.itb" if !BINMAN && SPL_LOAD_FIT && (ARCH_ROCKCHIP || \
ARCH_SUNXI || RISCV || ARCH_ZYNQMP)
default "u-boot.kwb" if (ARCH_KIRKWOOD || ARMADA_32BIT) && !SPL
-   default "u-boot-with-spl.bin" if MPC85xx && !E500MC && !E5500 && !E6500 
&& SPL
-   default "u-boot-with-spl.bin" if ARCH_AT91 && SPL_NAND_SUPPORT
-   default "u-boot-with-spl.imx" if ARCH_MX6 && SPL
help
  Some SoCs need special image types (e.g. U-Boot binary
  with a special header) as build targets. By defining
-- 
2.39.2



[PATCH] mmc: tmio: Replace ifdeffery with IS_ENABLED/CONFIG_IS_ENABLED macros

2023-02-27 Thread Marek Vasut
Instead of #if and #ifdef, use IS_ENABLED and CONFIG_IS_ENABLED macros.
This improves build test coverage. The CONFIG_SPL_BUILD must remain an
ifdef, as CONFIG_SPL_STACK may not always be defined, e.g. in U-Boot
proper build. No functional change.

Signed-off-by: Marek Vasut 
---
Cc: Jaehoon Chung 
Cc: Peng Fan 
---
 drivers/mmc/tmio-common.c | 59 +++
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/drivers/mmc/tmio-common.c b/drivers/mmc/tmio-common.c
index e9c7d3a2e00..81bc6083dea 100644
--- a/drivers/mmc/tmio-common.c
+++ b/drivers/mmc/tmio-common.c
@@ -369,22 +369,23 @@ static bool tmio_sd_addr_is_dmaable(struct mmc_data *data)
if (!IS_ALIGNED(addr, TMIO_SD_DMA_MINALIGN))
return false;
 
-#if defined(CONFIG_RCAR_GEN3)
-   if (!(data->flags & MMC_DATA_READ) && !IS_ALIGNED(addr, 128))
-   return false;
-   /* Gen3 DMA has 32bit limit */
-   if (addr >> 32)
-   return false;
-#endif
+   if (IS_ENABLED(CONFIG_RCAR_GEN3)) {
+   if (!(data->flags & MMC_DATA_READ) && !IS_ALIGNED(addr, 128))
+   return false;
+   /* Gen3 DMA has 32bit limit */
+   if (addr >> 32)
+   return false;
+   }
 
-#if defined(CONFIG_ARCH_UNIPHIER) && !defined(CONFIG_ARM64) && \
-   defined(CONFIG_SPL_BUILD)
-   /*
-* For UniPhier ARMv7 SoCs, the stack is allocated in the locked ways
-* of L2, which is unreachable from the DMA engine.
-*/
-   if (addr < CONFIG_SPL_STACK)
-   return false;
+#ifdef CONFIG_SPL_BUILD
+   if (IS_ENABLED(CONFIG_ARCH_UNIPHIER) && 
!CONFIG_IS_ENABLED(CONFIG_ARM64)) {
+   /*
+* For UniPhier ARMv7 SoCs, the stack is allocated in locked
+* ways of L2, which is unreachable from the DMA engine.
+*/
+   if (addr < CONFIG_SPL_STACK)
+   return false;
+   }
 #endif
 
return true;
@@ -622,25 +623,22 @@ static void tmio_sd_set_clk_rate(struct tmio_sd_priv 
*priv, struct mmc *mmc)
 static void tmio_sd_set_pins(struct udevice *dev)
 {
__maybe_unused struct mmc *mmc = mmc_get_mmc_dev(dev);
-
-#ifdef CONFIG_DM_REGULATOR
struct tmio_sd_priv *priv = dev_get_priv(dev);
 
-   if (priv->vqmmc_dev) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && priv->vqmmc_dev) {
if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
regulator_set_value(priv->vqmmc_dev, 180);
else
regulator_set_value(priv->vqmmc_dev, 330);
regulator_set_enable(priv->vqmmc_dev, true);
}
-#endif
 
-#ifdef CONFIG_PINCTRL
-   if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
-   pinctrl_select_state(dev, "state_uhs");
-   else
-   pinctrl_select_state(dev, "default");
-#endif
+   if (CONFIG_IS_ENABLED(PINCTRL)) {
+   if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
+   pinctrl_select_state(dev, "state_uhs");
+   else
+   pinctrl_select_state(dev, "default");
+   }
 }
 
 int tmio_sd_set_ios(struct udevice *dev)
@@ -734,11 +732,12 @@ int tmio_sd_probe(struct udevice *dev, u32 quirks)
if (!priv->regbase)
return -ENOMEM;
 
-#ifdef CONFIG_DM_REGULATOR
-   device_get_supply_regulator(dev, "vqmmc-supply", &priv->vqmmc_dev);
-   if (priv->vqmmc_dev)
-   regulator_set_value(priv->vqmmc_dev, 330);
-#endif
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
+   device_get_supply_regulator(dev, "vqmmc-supply",
+   &priv->vqmmc_dev);
+   if (priv->vqmmc_dev)
+   regulator_set_value(priv->vqmmc_dev, 330);
+   }
 
ret = mmc_of_parse(dev, &plat->cfg);
if (ret < 0) {
-- 
2.39.2



[PATCH] clk: renesas: rcar-gen3: Replace SSCG caching with MDSEL/PE caching

2023-02-27 Thread Marek Vasut
Do not cache the single CPG MODE register bit 12, instead cache the
entire register value, and only pick the matching bit from the cached
value when core clock of type MDSEL or PE are used. Both MDSEL and PE
clock type currently define .offset field as 12 on Gen3, which means
this code will use bit 12 on Gen3 again, however there are additional
clock on Gen4 which use different bits, and having this flexibility
in place now will be useful when adding Gen4.

No functional change.

Signed-off-by: Marek Vasut 
---
 drivers/clk/renesas/clk-rcar-gen3.c | 18 +-
 drivers/clk/renesas/rcar-gen3-cpg.h |  2 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/clk/renesas/clk-rcar-gen3.c 
b/drivers/clk/renesas/clk-rcar-gen3.c
index d778db6569d..9545e0a1435 100644
--- a/drivers/clk/renesas/clk-rcar-gen3.c
+++ b/drivers/clk/renesas/clk-rcar-gen3.c
@@ -55,6 +55,7 @@ static int gen3_clk_get_parent(struct gen3_clk_priv *priv, 
struct clk *clk,
   struct cpg_mssr_info *info, struct clk *parent)
 {
const struct cpg_core_clk *core;
+   u8 shift;
int ret;
 
if (!renesas_clk_is_mod(clk)) {
@@ -63,8 +64,9 @@ static int gen3_clk_get_parent(struct gen3_clk_priv *priv, 
struct clk *clk,
return ret;
 
if (core->type == CLK_TYPE_GEN3_MDSEL) {
+   shift = priv->cpg_mode & BIT(core->offset) ? 16 : 0;
parent->dev = clk->dev;
-   parent->id = core->parent >> (priv->sscg ? 16 : 0);
+   parent->id = core->parent >> shift;
parent->id &= 0x;
return 0;
}
@@ -183,6 +185,7 @@ static u64 gen3_clk_get_rate64(struct clk *clk)
priv->cpg_pll_config;
u32 value, div;
u64 rate = 0;
+   u8 shift;
int ret;
 
debug("%s[%i] Clock: id=%lu\n", __func__, __LINE__, clk->id);
@@ -277,11 +280,11 @@ static u64 gen3_clk_get_rate64(struct clk *clk)
"FIXED");
 
case CLK_TYPE_GEN3_MDSEL:
-   div = (core->div >> (priv->sscg ? 16 : 0)) & 0x;
+   shift = priv->cpg_mode & BIT(core->offset) ? 16 : 0;
+   div = (core->div >> shift) & 0x;
rate = gen3_clk_get_rate64(&parent) / div;
debug("%s[%i] PE clk: parent=%i div=%u => rate=%llu\n",
- __func__, __LINE__,
- (core->parent >> (priv->sscg ? 16 : 0)) & 0x,
+ __func__, __LINE__, (core->parent >> shift) & 0x,
  div, rate);
return rate;
 
@@ -407,7 +410,6 @@ static int gen3_clk_probe(struct udevice *dev)
struct cpg_mssr_info *info =
(struct cpg_mssr_info *)dev_get_driver_data(dev);
fdt_addr_t rst_base;
-   u32 cpg_mode;
int ret;
 
priv->base = dev_read_addr_ptr(dev);
@@ -423,15 +425,13 @@ static int gen3_clk_probe(struct udevice *dev)
if (rst_base == FDT_ADDR_T_NONE)
return -EINVAL;
 
-   cpg_mode = readl(rst_base + info->reset_modemr_offset);
+   priv->cpg_mode = readl(rst_base + info->reset_modemr_offset);
 
priv->cpg_pll_config =
-   (struct rcar_gen3_cpg_pll_config 
*)info->get_pll_config(cpg_mode);
+   (struct rcar_gen3_cpg_pll_config 
*)info->get_pll_config(priv->cpg_mode);
if (!priv->cpg_pll_config->extal_div)
return -EINVAL;
 
-   priv->sscg = !(cpg_mode & BIT(12));
-
if (info->reg_layout == CLK_REG_LAYOUT_RCAR_GEN2_AND_GEN3) {
priv->info->status_regs = mstpsr;
priv->info->control_regs = smstpcr;
diff --git a/drivers/clk/renesas/rcar-gen3-cpg.h 
b/drivers/clk/renesas/rcar-gen3-cpg.h
index 200e4adb906..894e3765495 100644
--- a/drivers/clk/renesas/rcar-gen3-cpg.h
+++ b/drivers/clk/renesas/rcar-gen3-cpg.h
@@ -132,7 +132,7 @@ struct gen3_clk_priv {
struct cpg_mssr_info*info;
struct clk  clk_extal;
struct clk  clk_extalr;
-   boolsscg;
+   u32 cpg_mode;
const struct rcar_gen3_cpg_pll_config *cpg_pll_config;
 };
 
-- 
2.39.2



[PATCH 1/2] pinctrl: renesas: Replace ifdeffery with IS_ENABLED()

2023-02-27 Thread Marek Vasut
Switch ifdef in sh_gpio_get_value() to IS_ENABLED() macro.
The CONFIG_RCAR_GEN3 will never have SPL counterpart, so
the IS_ENABLED() macro is the right one here. No functional
change, except for improved build test coverage.

Signed-off-by: Marek Vasut 
---
 drivers/gpio/sh_pfc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/sh_pfc.c b/drivers/gpio/sh_pfc.c
index 988f7e9bbad..92522b63bbe 100644
--- a/drivers/gpio/sh_pfc.c
+++ b/drivers/gpio/sh_pfc.c
@@ -568,10 +568,10 @@ static int sh_gpio_get_value(struct pinmux_info *gpioc, 
unsigned gpio)
 
if (!gpioc || get_data_reg(gpioc, gpio, &dr, &bit) != 0)
return -1;
-#if defined(CONFIG_RCAR_GEN3)
-   if ((gpioc->gpios[gpio].flags & PINMUX_FLAG_TYPE) == PINMUX_TYPE_INPUT)
+
+   if (IS_ENABLED(CONFIG_RCAR_GEN3) &&
+   ((gpioc->gpios[gpio].flags & PINMUX_FLAG_TYPE) == 
PINMUX_TYPE_INPUT))
offset += 4;
-#endif
 
return gpio_read_bit(dr, offset, bit);
 }
-- 
2.39.2



[PATCH 2/2] pinctrl: renesas: Drop non-existent PFC info table entries

2023-02-27 Thread Marek Vasut
Remove PFC info table entries which are never instantiated,
since there are no drivers for those. No functional change.

Signed-off-by: Marek Vasut 
---
 drivers/pinctrl/renesas/sh_pfc.h | 15 ---
 1 file changed, 15 deletions(-)

diff --git a/drivers/pinctrl/renesas/sh_pfc.h b/drivers/pinctrl/renesas/sh_pfc.h
index 59d447ead5c..0ab743e80d5 100644
--- a/drivers/pinctrl/renesas/sh_pfc.h
+++ b/drivers/pinctrl/renesas/sh_pfc.h
@@ -309,21 +309,6 @@ extern const struct sh_pfc_soc_info r8a77980_pinmux_info;
 extern const struct sh_pfc_soc_info r8a77990_pinmux_info;
 extern const struct sh_pfc_soc_info r8a77995_pinmux_info;
 extern const struct sh_pfc_soc_info r8a779a0_pinmux_info;
-extern const struct sh_pfc_soc_info r8a779f0_pinmux_info;
-extern const struct sh_pfc_soc_info r8a779g0_pinmux_info;
-extern const struct sh_pfc_soc_info sh7203_pinmux_info;
-extern const struct sh_pfc_soc_info sh7264_pinmux_info;
-extern const struct sh_pfc_soc_info sh7269_pinmux_info;
-extern const struct sh_pfc_soc_info sh73a0_pinmux_info;
-extern const struct sh_pfc_soc_info sh7720_pinmux_info;
-extern const struct sh_pfc_soc_info sh7722_pinmux_info;
-extern const struct sh_pfc_soc_info sh7723_pinmux_info;
-extern const struct sh_pfc_soc_info sh7724_pinmux_info;
-extern const struct sh_pfc_soc_info sh7734_pinmux_info;
-extern const struct sh_pfc_soc_info sh7757_pinmux_info;
-extern const struct sh_pfc_soc_info sh7785_pinmux_info;
-extern const struct sh_pfc_soc_info sh7786_pinmux_info;
-extern const struct sh_pfc_soc_info shx3_pinmux_info;
 
 /* 
-
  * Helper macros to create pin and port lists
-- 
2.39.2



[PATCH] ARM: rmobile: Convert ifdef in rmobile_get_prr() to IS_ENABLED()

2023-02-27 Thread Marek Vasut
Switch ifdef in rmobile_get_prr() to IS_ENABLED() macro.
The CONFIG_RCAR_GEN3 will never have SPL counterpart, so
the IS_ENABLED() macro is the right one here. No functional
change, except for improved build test coverage.

Signed-off-by: Marek Vasut 
---
 arch/arm/mach-rmobile/cpu_info-rcar.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-rmobile/cpu_info-rcar.c 
b/arch/arm/mach-rmobile/cpu_info-rcar.c
index 5bde24ae0e7..ac9c623eda7 100644
--- a/arch/arm/mach-rmobile/cpu_info-rcar.c
+++ b/arch/arm/mach-rmobile/cpu_info-rcar.c
@@ -14,11 +14,10 @@
 
 static u32 rmobile_get_prr(void)
 {
-#ifdef CONFIG_RCAR_GEN3
-   return readl(0xFFF00044);
-#else
+   if (IS_ENABLED(CONFIG_RCAR_GEN3))
+   return readl(0xFFF00044);
+
return readl(0xFF44);
-#endif
 }
 
 u32 rmobile_get_cpu_type(void)
-- 
2.39.2



[PATCH 1/4] ARM: rmobile: Sort R-Car Gen3 Kconfig lists

2023-02-27 Thread Marek Vasut
Sort the 'imply' and 'select' lists in R-Car Gen3 Kconfig options.
No functional change.

Signed-off-by: Marek Vasut 
---
 arch/arm/mach-rmobile/Kconfig| 10 +-
 arch/arm/mach-rmobile/Kconfig.64 | 22 +++---
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-rmobile/Kconfig b/arch/arm/mach-rmobile/Kconfig
index 0e9c0fa9962..9ff45f46313 100644
--- a/arch/arm/mach-rmobile/Kconfig
+++ b/arch/arm/mach-rmobile/Kconfig
@@ -11,19 +11,18 @@ config RCAR_32
 config RCAR_GEN3
bool "Renesas ARM SoCs R-Car Gen3 (64bit)"
select ARM64
-   select PHY
select CMD_CACHE
select OF_BOARD_SETUP
-   select PINCTRL
+   select PHY
select PINCONF
+   select PINCTRL
select PINCTRL_PFC
select POSITION_INDEPENDENT
select SUPPORT_SPL
imply CMD_FS_UUID
imply CMD_GPT
-   imply CMD_UUID
imply CMD_MMC_SWRITE if MMC
-   imply SUPPORT_EMMC_RPMB if MMC
+   imply CMD_UUID
imply SPL
imply SPL_BOARD_INIT
imply SPL_GZIP
@@ -32,8 +31,9 @@ config RCAR_GEN3
imply SPL_SERIAL
imply SPL_SYS_MALLOC_SIMPLE
imply SPL_TINY_MEMSET
-   imply SPL_YMODEM_SUPPORT
imply SPL_USE_TINY_PRINTF
+   imply SPL_YMODEM_SUPPORT
+   imply SUPPORT_EMMC_RPMB if MMC
 
 config RZA1
prompt "Renesas ARM SoCs RZ/A1 (32bit)"
diff --git a/arch/arm/mach-rmobile/Kconfig.64 b/arch/arm/mach-rmobile/Kconfig.64
index 554130b435b..33fd776f8af 100644
--- a/arch/arm/mach-rmobile/Kconfig.64
+++ b/arch/arm/mach-rmobile/Kconfig.64
@@ -87,17 +87,17 @@ choice
 
 config TARGET_BEACON_RZG2M
bool "Beacon EmbeddedWorks RZ/G2 Dev Kit"
+   select PINCTRL_PFC_R8A774A1
+   select PINCTRL_PFC_R8A774B1
+   select PINCTRL_PFC_R8A774E1
select R8A774A1
select R8A774B1
select R8A774E1
select RZ_G2
-   select PINCTRL_PFC_R8A774A1
-   select PINCTRL_PFC_R8A774B1
-   select PINCTRL_PFC_R8A774E1
+   imply CLK_CCF
+   imply CLK_VERSACLOCK
imply MULTI_DTB_FIT
imply MULTI_DTB_FIT_USER_DEFINED_AREA
-   imply CLK_VERSACLOCK
-   imply CLK_CCF
 
 config TARGET_CONDOR
bool "Condor board"
@@ -131,13 +131,13 @@ config TARGET_FALCON
 
 config TARGET_HIHOPE_RZG2
bool "HiHope RZ/G2 board"
+   imply MULTI_DTB_FIT
+   imply MULTI_DTB_FIT_USER_DEFINED_AREA
imply R8A774A1
imply R8A774B1
imply R8A774E1
imply RZ_G2
imply SYS_MALLOC_F
-   imply MULTI_DTB_FIT
-   imply MULTI_DTB_FIT_USER_DEFINED_AREA
help
   Support for RZG2 HiHope platform
 
@@ -150,23 +150,23 @@ config TARGET_SILINUX_EK874
 
 config TARGET_SALVATOR_X
bool "Salvator-X board"
+   imply MULTI_DTB_FIT
+   imply MULTI_DTB_FIT_USER_DEFINED_AREA
imply R8A7795
imply R8A7796
imply R8A77965
imply SYS_MALLOC_F
-   imply MULTI_DTB_FIT
-   imply MULTI_DTB_FIT_USER_DEFINED_AREA
help
   Support for Renesas R-Car Gen3 platform
 
 config TARGET_ULCB
bool "ULCB board"
+   imply MULTI_DTB_FIT
+   imply MULTI_DTB_FIT_USER_DEFINED_AREA
imply R8A7795
imply R8A7796
imply R8A77965
imply SYS_MALLOC_F
-   imply MULTI_DTB_FIT
-   imply MULTI_DTB_FIT_USER_DEFINED_AREA
help
   Support for Renesas R-Car Gen3 ULCB platform
 
-- 
2.39.2



[PATCH 2/4] ARM: rmobile: Factor out SYS_SOC Kconfig option

2023-02-27 Thread Marek Vasut
Pull the SYS_SOC Kconfig option to avoid duplication of this option
in Kconfig.{32,64,rza1} . The default value is the same, so just set
it in one location.

Signed-off-by: Marek Vasut 
---
 arch/arm/mach-rmobile/Kconfig  | 3 +++
 arch/arm/mach-rmobile/Kconfig.32   | 3 ---
 arch/arm/mach-rmobile/Kconfig.64   | 3 ---
 arch/arm/mach-rmobile/Kconfig.rza1 | 3 ---
 4 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-rmobile/Kconfig b/arch/arm/mach-rmobile/Kconfig
index 9ff45f46313..b69ccaee0a0 100644
--- a/arch/arm/mach-rmobile/Kconfig
+++ b/arch/arm/mach-rmobile/Kconfig
@@ -41,6 +41,9 @@ config RZA1
 
 endchoice
 
+config SYS_SOC
+   default "rmobile" if ARCH_RMOBILE
+
 source "arch/arm/mach-rmobile/Kconfig.32"
 source "arch/arm/mach-rmobile/Kconfig.64"
 source "arch/arm/mach-rmobile/Kconfig.rza1"
diff --git a/arch/arm/mach-rmobile/Kconfig.32 b/arch/arm/mach-rmobile/Kconfig.32
index 31badc5a47d..1ac31c29d82 100644
--- a/arch/arm/mach-rmobile/Kconfig.32
+++ b/arch/arm/mach-rmobile/Kconfig.32
@@ -125,9 +125,6 @@ endchoice
 config TMU_TIMER
bool
 
-config SYS_SOC
-   default "rmobile"
-
 config RMOBILE_EXTRAM_BOOT
bool "Enable boot from RAM"
depends on TARGET_ALT || TARGET_BLANCHE || TARGET_KOELSCH || 
TARGET_LAGER || TARGET_PORTER || TARGET_SILK || TARGET_STOUT
diff --git a/arch/arm/mach-rmobile/Kconfig.64 b/arch/arm/mach-rmobile/Kconfig.64
index 33fd776f8af..3ed5099c36e 100644
--- a/arch/arm/mach-rmobile/Kconfig.64
+++ b/arch/arm/mach-rmobile/Kconfig.64
@@ -172,9 +172,6 @@ config TARGET_ULCB
 
 endchoice
 
-config SYS_SOC
-   default "rmobile"
-
 source "board/renesas/condor/Kconfig"
 source "board/renesas/draak/Kconfig"
 source "board/renesas/eagle/Kconfig"
diff --git a/arch/arm/mach-rmobile/Kconfig.rza1 
b/arch/arm/mach-rmobile/Kconfig.rza1
index 8cf033fb13c..e88f9a2eedb 100644
--- a/arch/arm/mach-rmobile/Kconfig.rza1
+++ b/arch/arm/mach-rmobile/Kconfig.rza1
@@ -19,9 +19,6 @@ config TARGET_GRPEACH
 
 endchoice
 
-config SYS_SOC
-   default "rmobile"
-
 # Renesas Supported Boards
 source "board/renesas/grpeach/Kconfig"
 
-- 
2.39.2



[PATCH 3/4] ARM: rmobile: Introduce CONFIG_RCAR_64 symbol

2023-02-27 Thread Marek Vasut
Introduce common Kconfig symbol for 64bit R-Car platforms and move
common configuration options into it. This is preparatory patch to
prevent duplication of Kconfig lists later on, when Gen4 is added.

Signed-off-by: Marek Vasut 
---
 arch/arm/mach-rmobile/Kconfig | 29 +
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-rmobile/Kconfig b/arch/arm/mach-rmobile/Kconfig
index b69ccaee0a0..921153a8d9e 100644
--- a/arch/arm/mach-rmobile/Kconfig
+++ b/arch/arm/mach-rmobile/Kconfig
@@ -1,15 +1,8 @@
 if ARCH_RMOBILE
 
-choice
-   prompt "Target Renesas SoC select"
-   default RCAR_32
-
-config RCAR_32
-   bool "Renesas ARM SoCs R-Car Gen1/Gen2 (32bit)"
-   select CPU_V7A
-
-config RCAR_GEN3
-   bool "Renesas ARM SoCs R-Car Gen3 (64bit)"
+# Renesas ARM SoCs R-Car Gen3/Gen4 (64bit)
+config RCAR_64
+   bool
select ARM64
select CMD_CACHE
select OF_BOARD_SETUP
@@ -18,11 +11,24 @@ config RCAR_GEN3
select PINCTRL
select PINCTRL_PFC
select POSITION_INDEPENDENT
-   select SUPPORT_SPL
imply CMD_FS_UUID
imply CMD_GPT
imply CMD_MMC_SWRITE if MMC
imply CMD_UUID
+   imply SUPPORT_EMMC_RPMB if MMC
+
+choice
+   prompt "Target Renesas SoC select"
+   default RCAR_32
+
+config RCAR_32
+   bool "Renesas ARM SoCs R-Car Gen1/Gen2 (32bit)"
+   select CPU_V7A
+
+config RCAR_GEN3
+   bool "Renesas ARM SoCs R-Car Gen3 (64bit)"
+   select RCAR_64
+   select SUPPORT_SPL
imply SPL
imply SPL_BOARD_INIT
imply SPL_GZIP
@@ -33,7 +39,6 @@ config RCAR_GEN3
imply SPL_TINY_MEMSET
imply SPL_USE_TINY_PRINTF
imply SPL_YMODEM_SUPPORT
-   imply SUPPORT_EMMC_RPMB if MMC
 
 config RZA1
prompt "Renesas ARM SoCs RZ/A1 (32bit)"
-- 
2.39.2



[PATCH 4/4] ARM: rmobile: Split R-Car Gen3 into separate Kconfig from common 64bit options

2023-02-27 Thread Marek Vasut
There are multiple shared Kconfig options between R-Car Gen3 and Gen4.
Keep the common options in Kconfig.64 and move the R-Car Gen3 specific
options into separate Kconfig.rcar3 . The Kconfig.rcar3 contains SoC
and board list, which is limited to R-Car Gen3.

Signed-off-by: Marek Vasut 
---
 arch/arm/mach-rmobile/Kconfig.64| 206 +---
 arch/arm/mach-rmobile/Kconfig.rcar3 | 201 +++
 2 files changed, 206 insertions(+), 201 deletions(-)
 create mode 100644 arch/arm/mach-rmobile/Kconfig.rcar3

diff --git a/arch/arm/mach-rmobile/Kconfig.64 b/arch/arm/mach-rmobile/Kconfig.64
index 3ed5099c36e..3b14721dab5 100644
--- a/arch/arm/mach-rmobile/Kconfig.64
+++ b/arch/arm/mach-rmobile/Kconfig.64
@@ -1,207 +1,11 @@
-if RCAR_GEN3
-
-menu "Select Target SoC"
-
-config R8A774A1
-   bool "Renesas SoC R8A774A1"
-   select GICV2
-   imply CLK_R8A774A1
-   imply PINCTRL_PFC_R8A774A1
-
-config R8A774B1
-   bool "Renesas SoC R8A774B1"
-   select GICV2
-   imply CLK_R8A774B1
-   imply PINCTRL_PFC_R8A774B1
-
-config R8A774C0
-   bool "Renesas SoC R8A774C0"
-   select GICV2
-   imply CLK_R8A774C0
-   imply PINCTRL_PFC_R8A774C0
-
-config R8A774E1
-   bool "Renesas SoC R8A774E1"
-   select GICV2
-   imply CLK_R8A774E1
-   imply PINCTRL_PFC_R8A774E1
-
-config R8A7795
-   bool "Renesas SoC R8A7795"
-   select GICV2
-   imply CLK_R8A7795
-   imply PINCTRL_PFC_R8A77951
-
-config R8A7796
-   bool "Renesas SoC R8A7796"
-   select GICV2
-   imply CLK_R8A77960
-   imply CLK_R8A77961
-   imply PINCTRL_PFC_R8A77960
-   imply PINCTRL_PFC_R8A77961
-
-config R8A77965
-   bool "Renesas SoC R8A77965"
-   select GICV2
-   imply CLK_R8A77965
-   imply PINCTRL_PFC_R8A77965
-
-config R8A77970
-   bool "Renesas SoC R8A77970"
-   select GICV2
-   imply CLK_R8A77970
-   imply PINCTRL_PFC_R8A77970
-
-config R8A77980
-   bool "Renesas SoC R8A77980"
-   select GICV2
-   imply CLK_R8A77980
-   imply PINCTRL_PFC_R8A77980
-
-config R8A77990
-   bool "Renesas SoC R8A77990"
-   select GICV2
-   imply CLK_R8A77990
-   imply PINCTRL_PFC_R8A77990
-
-config R8A77995
-   bool "Renesas SoC R8A77995"
-   select GICV2
-   imply CLK_R8A77995
-   imply PINCTRL_PFC_R8A77995
-
-config R8A779A0
-   bool "Renesas SoC R8A779A0"
-   select GICV3
-   imply CLK_R8A779A0
-   imply PINCTRL_PFC_R8A779A0
-
-config RZ_G2
-   bool "Renesas ARM SoCs RZ/G2 (64bit)"
-
-endmenu
-
-choice
-   prompt "Renesas ARM64 SoCs board select"
-   optional
-
-config TARGET_BEACON_RZG2M
-   bool "Beacon EmbeddedWorks RZ/G2 Dev Kit"
-   select PINCTRL_PFC_R8A774A1
-   select PINCTRL_PFC_R8A774B1
-   select PINCTRL_PFC_R8A774E1
-   select R8A774A1
-   select R8A774B1
-   select R8A774E1
-   select RZ_G2
-   imply CLK_CCF
-   imply CLK_VERSACLOCK
-   imply MULTI_DTB_FIT
-   imply MULTI_DTB_FIT_USER_DEFINED_AREA
-
-config TARGET_CONDOR
-   bool "Condor board"
-   imply R8A77980
-   help
-  Support for Renesas R-Car Gen3 Condor platform
-
-config TARGET_DRAAK
-   bool "Draak board"
-   imply R8A77995
-   help
-  Support for Renesas R-Car Gen3 Draak platform
-
-config TARGET_EAGLE
-   bool "Eagle board"
-   imply R8A77970
-   help
-  Support for Renesas R-Car Gen3 Eagle platform
-
-config TARGET_EBISU
-   bool "Ebisu board"
-   imply R8A77990
-   help
-  Support for Renesas R-Car Gen3 Ebisu platform
-
-config TARGET_FALCON
-   bool "Falcon board"
-   imply R8A779A0
-   help
-  Support for Renesas R-Car Gen3 Falcon platform
-
-config TARGET_HIHOPE_RZG2
-   bool "HiHope RZ/G2 board"
-   imply MULTI_DTB_FIT
-   imply MULTI_DTB_FIT_USER_DEFINED_AREA
-   imply R8A774A1
-   imply R8A774B1
-   imply R8A774E1
-   imply RZ_G2
-   imply SYS_MALLOC_F
-   help
-  Support for RZG2 HiHope platform
-
-config TARGET_SILINUX_EK874
-   bool "Silicon Linux EK874 board"
-   imply R8A774C0
-   imply RZ_G2
-   help
-  Support for Silicon Linux EK874 platform
-
-config TARGET_SALVATOR_X
-   bool "Salvator-X board"
-   imply MULTI_DTB_FIT
-   imply MULTI_DTB_FIT_USER_DEFINED_AREA
-   imply R8A7795
-   imply R8A7796
-   imply R8A77965
-   imply SYS_MALLOC_F
-   help
-  Support for Renesas R-Car Gen3 platform
-
-config TARGET_ULCB
-   bool "ULCB board"
-   imply MULTI_DTB_FIT
-   imply MULTI_DTB_FIT_USER_DEFINED_AREA
-   imply R8A7795
-   imply R8A7796
- 

Re: [PATCH 1/2] ARM: dts: uniphier: Switch USB node to the original

2023-02-27 Thread Marek Vasut

On 2/28/23 03:37, Kunihiko Hayashi wrote:

UniPhier DT applies its own USB node for U-Boot due to the USB driver
constrains. After solving this issue, u-boot allows the original USB node.

After switching USB node, synchronization of USB node with Linux becomes
possible.

Signed-off-by: Kunihiko Hayashi 


Very nice

Acked-by: Marek Vasut 


Re: [PATCH 2/2] ARM: dts: uniphier: Sync DT with Linux v6.2

2023-02-27 Thread Marek Vasut

On 2/28/23 03:37, Kunihiko Hayashi wrote:

Synchronize devicetree sources with Linux v6.2.

- Use GIC interrupt definitions
- Add reg properties in USB-glue and SoC-glue node
- Fix node names to follow the generic names list in DT specification
- Add L2 cache and AHCI nodes
- Update nand and pcie nodes
- And some trivial fixes

Signed-off-by: Kunihiko Hayashi 


Acked-by: Marek Vasut 


[PATCH] clk: renesas: Always select DM_RESET to prevent inobvious failure of rst_gen3 subdriver

2023-02-28 Thread Marek Vasut
The CLK_RCAR_GEN3 registers two subdrivers, clk_gen3 and rst_gen3.
The former depends on the clock framework, which is always enabled
in this context of clock framework driver, while the later depends
on reset framework which may not always be enabled.

Ensure the reset framework is also always enabled to prevent inobvious
early boot time bind failure of the CPG driver, which leads to system
showing no activity and is difficult to debug.

Note that one possible approach to debug this is to use CONFIG_DEBUG_UART
and add debug printascii()s into the drivers/clk/renesas/clk-rcar-gen3.c .

Signed-off-by: Marek Vasut 
---
 drivers/clk/renesas/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/clk/renesas/Kconfig b/drivers/clk/renesas/Kconfig
index 1686410d6d3..d58e897ca1b 100644
--- a/drivers/clk/renesas/Kconfig
+++ b/drivers/clk/renesas/Kconfig
@@ -49,6 +49,7 @@ config CLK_RCAR_GEN3
def_bool y if RCAR_GEN3
depends on CLK_RENESAS
select CLK_RCAR_CPG_LIB
+   select DM_RESET
help
  Enable this to support the clocks on Renesas RCar Gen3 SoC.
 
-- 
2.39.2



[PATCH 1/2] serial: sh: Rename CONFIG_SCI and CONFIG_SCIF_USE_EXT_CLK to CFG_ variants

2023-02-28 Thread Marek Vasut
Both CONFIG_SCI and CONFIG_SCIF_USE_EXT_CLK options do not have a
matching Kconfig entry because they are internal to the SCIF driver.
Change their prefix to CFG_, i.e. CFG_SCIF_USE_EXT_CLK and CFG_SCI,
to reflect that and avoid interferring with Kconfig symbols. Since
neither of those options are defined elsewhere, no functional change.

Signed-off-by: Marek Vasut 
---
Cc: Samuel Holland 
Cc: Sean Anderson 
Cc: Simon Glass 
---
 drivers/serial/serial_sh.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c
index 4671217b59a..c3e3f257c65 100644
--- a/drivers/serial/serial_sh.c
+++ b/drivers/serial/serial_sh.c
@@ -276,7 +276,7 @@ U_BOOT_DRIVER(serial_sh) = {
 
 #if defined(CFG_SCIF_A)
#define SCIF_BASE_PORT  PORT_SCIFA
-#elif defined(CONFIG_SCI)
+#elif defined(CFG_SCI)
#define SCIF_BASE_PORT  PORT_SCI
 #else
#define SCIF_BASE_PORT  PORT_SCIF
@@ -286,7 +286,7 @@ static struct uart_port sh_sci = {
.membase= (unsigned char *)SCIF_BASE,
.mapbase= SCIF_BASE,
.type   = SCIF_BASE_PORT,
-#ifdef CONFIG_SCIF_USE_EXT_CLK
+#ifdef CFG_SCIF_USE_EXT_CLK
.clk_mode = EXT_CLK,
 #endif
 };
-- 
2.39.2



[PATCH 2/2] serial: sh: Add DEBUG_UART support

2023-02-28 Thread Marek Vasut
Add support for debug output very early during boot using the DEBUG_UART
mechanism. This uses a static fixed UART port configuration selected via
Kconfig options and dedicated print functions from debug_uart.h. This is
useful e.g. when debugging problems so early during boot, that not even
the DM is initialized at that point, and thus DM_SERIAL is not available
either.

This functionality is disabled by default. To activate it, define the
following Kconfig options and select SCIF type using CFG_SCI/CFG_SCIF_A/
CFG_HSCIF/:

CONFIG_DEBUG_UART=y
CONFIG_DEBUG_UART_SCIF=y
CONFIG_DEBUG_UART_BASE=0xe654
CONFIG_DEBUG_UART_CLOCK=2400

The later two options define the SCIF physical base address and SCIF
input clock in Hz. Optionally, to validate DEBUG_UART works, enable
the following as well to get early serial output message by default:

CONFIG_DEBUG_UART_ANNOUNCE=y

Signed-off-by: Marek Vasut 
---
Cc: Samuel Holland 
Cc: Sean Anderson 
Cc: Simon Glass 
---
 drivers/serial/Kconfig |  8 
 drivers/serial/serial_sh.c | 85 +++---
 2 files changed, 68 insertions(+), 25 deletions(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index bb5083201b3..10d07daf277 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -415,6 +415,14 @@ config DEBUG_UART_SEMIHOSTING
  start up driver model. The driver will be available until the real
  driver model serial is running.
 
+config DEBUG_UART_SCIF
+   bool "Renesas SCIF UART"
+   depends on SH || ARCH_RMOBILE
+   help
+ Select this to enable a debug UART using the serial_sh driver. You
+ will need to provide parameters to make this work. The driver will
+ be available until the real driver-model serial is running.
+
 config DEBUG_UART_SIFIVE
bool "SiFive UART"
depends on SIFIVE_SERIAL
diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c
index c3e3f257c65..e08bdcadc9c 100644
--- a/drivers/serial/serial_sh.c
+++ b/drivers/serial/serial_sh.c
@@ -249,9 +249,40 @@ U_BOOT_DRIVER(serial_sh) = {
 #endif
.priv_auto  = sizeof(struct uart_port),
 };
+#endif
+
+#if !CONFIG_IS_ENABLED(DM_SERIAL) || IS_ENABLED(CONFIG_DEBUG_UART_SCIF)
 
-#else /* CONFIG_DM_SERIAL */
+#if defined(CFG_SCIF_A)
+   #define SCIF_BASE_PORT  PORT_SCIFA
+#elif defined(CFG_SCI)
+   #define SCIF_BASE_PORT  PORT_SCI
+#else
+   #define SCIF_BASE_PORT  PORT_SCIF
+#endif
+
+static void sh_serial_init_nodm(struct uart_port *port)
+{
+   sh_serial_init_generic(port);
+   serial_setbrg();
+}
+
+static void sh_serial_putc_nondm(struct uart_port *port, const char c)
+{
+   if (c == '\n') {
+   while (1) {
+   if  (serial_raw_putc(port, '\r') != -EAGAIN)
+   break;
+   }
+   }
+   while (1) {
+   if  (serial_raw_putc(port, c) != -EAGAIN)
+   break;
+   }
+}
+#endif
 
+#if !CONFIG_IS_ENABLED(DM_SERIAL)
 #if defined(CONFIG_CONS_SCIF0)
 # define SCIF_BASE SCIF0_BASE
 #elif defined(CONFIG_CONS_SCIF1)
@@ -274,14 +305,6 @@ U_BOOT_DRIVER(serial_sh) = {
 # error "Default SCIF doesn't set."
 #endif
 
-#if defined(CFG_SCIF_A)
-   #define SCIF_BASE_PORT  PORT_SCIFA
-#elif defined(CFG_SCI)
-   #define SCIF_BASE_PORT  PORT_SCI
-#else
-   #define SCIF_BASE_PORT  PORT_SCIF
-#endif
-
 static struct uart_port sh_sci = {
.membase= (unsigned char *)SCIF_BASE,
.mapbase= SCIF_BASE,
@@ -301,28 +324,14 @@ static void sh_serial_setbrg(void)
 
 static int sh_serial_init(void)
 {
-   struct uart_port *port = &sh_sci;
-
-   sh_serial_init_generic(port);
-   serial_setbrg();
+   sh_serial_init_nodm(&sh_sci);
 
return 0;
 }
 
 static void sh_serial_putc(const char c)
 {
-   struct uart_port *port = &sh_sci;
-
-   if (c == '\n') {
-   while (1) {
-   if  (serial_raw_putc(port, '\r') != -EAGAIN)
-   break;
-   }
-   }
-   while (1) {
-   if  (serial_raw_putc(port, c) != -EAGAIN)
-   break;
-   }
+   sh_serial_putc_nondm(&sh_sci, c);
 }
 
 static int sh_serial_tstc(void)
@@ -367,3 +376,29 @@ __weak struct serial_device *default_serial_console(void)
return &sh_serial_drv;
 }
 #endif /* CONFIG_DM_SERIAL */
+
+#ifdef CONFIG_DEBUG_UART_SCIF
+#include 
+
+static struct uart_port debug_uart_sci = {
+   .membase= (unsigned char *)CONFIG_DEBUG_UART_BASE,
+   .mapbase= CONFIG_DEBUG_UART_BASE,
+   .type   = SCIF_BASE_PORT,
+#ifdef CFG_SCIF_USE_EXT_CLK
+   .clk_mode = EXT_CLK,
+#endif
+};
+
+static inline void _debug_uart_init(void)
+{
+   sh_serial_init_nodm(&debug_uart_sci);
+}
+
+static inline void _debug_uar

[PATCH v2 2/2] mmc: tmio: Replace ifdeffery with IS_ENABLED/CONFIG_IS_ENABLED macros

2023-02-28 Thread Marek Vasut
Instead of #if and #ifdef, use IS_ENABLED and CONFIG_IS_ENABLED macros.
This improves build test coverage. The CONFIG_SPL_BUILD must remain an
ifdef, as CONFIG_SPL_STACK may not always be defined, e.g. in U-Boot
proper build. No functional change.

Signed-off-by: Marek Vasut 
---
Cc: Jaehoon Chung 
Cc: Peng Fan 
---
V2: - Rebase on 1/2
- Drop DM_REGULATOR check from struct tmio_sd_priv in tmio-common.h
---
 drivers/mmc/tmio-common.c | 59 +++
 drivers/mmc/tmio-common.h |  2 --
 2 files changed, 29 insertions(+), 32 deletions(-)

diff --git a/drivers/mmc/tmio-common.c b/drivers/mmc/tmio-common.c
index 0b24a5a7bdb..d8b6a4a8821 100644
--- a/drivers/mmc/tmio-common.c
+++ b/drivers/mmc/tmio-common.c
@@ -369,22 +369,23 @@ static bool tmio_sd_addr_is_dmaable(struct mmc_data *data)
if (!IS_ALIGNED(addr, TMIO_SD_DMA_MINALIGN))
return false;
 
-#if defined(CONFIG_RCAR_GEN3)
-   if (!(data->flags & MMC_DATA_READ) && !IS_ALIGNED(addr, 128))
-   return false;
-   /* Gen3 DMA has 32bit limit */
-   if (sizeof(addr) > 4 && addr >> 32)
-   return false;
-#endif
+   if (IS_ENABLED(CONFIG_RCAR_GEN3)) {
+   if (!(data->flags & MMC_DATA_READ) && !IS_ALIGNED(addr, 128))
+   return false;
+   /* Gen3 DMA has 32bit limit */
+   if (sizeof(addr) > 4 && addr >> 32)
+   return false;
+   }
 
-#if defined(CONFIG_ARCH_UNIPHIER) && !defined(CONFIG_ARM64) && \
-   defined(CONFIG_SPL_BUILD)
-   /*
-* For UniPhier ARMv7 SoCs, the stack is allocated in the locked ways
-* of L2, which is unreachable from the DMA engine.
-*/
-   if (addr < CONFIG_SPL_STACK)
-   return false;
+#ifdef CONFIG_SPL_BUILD
+   if (IS_ENABLED(CONFIG_ARCH_UNIPHIER) && 
!CONFIG_IS_ENABLED(CONFIG_ARM64)) {
+   /*
+* For UniPhier ARMv7 SoCs, the stack is allocated in locked
+* ways of L2, which is unreachable from the DMA engine.
+*/
+   if (addr < CONFIG_SPL_STACK)
+   return false;
+   }
 #endif
 
return true;
@@ -622,25 +623,22 @@ static void tmio_sd_set_clk_rate(struct tmio_sd_priv 
*priv, struct mmc *mmc)
 static void tmio_sd_set_pins(struct udevice *dev)
 {
__maybe_unused struct mmc *mmc = mmc_get_mmc_dev(dev);
-
-#ifdef CONFIG_DM_REGULATOR
struct tmio_sd_priv *priv = dev_get_priv(dev);
 
-   if (priv->vqmmc_dev) {
+   if (CONFIG_IS_ENABLED(DM_REGULATOR) && priv->vqmmc_dev) {
if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
regulator_set_value(priv->vqmmc_dev, 180);
else
regulator_set_value(priv->vqmmc_dev, 330);
regulator_set_enable(priv->vqmmc_dev, true);
}
-#endif
 
-#ifdef CONFIG_PINCTRL
-   if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
-   pinctrl_select_state(dev, "state_uhs");
-   else
-   pinctrl_select_state(dev, "default");
-#endif
+   if (CONFIG_IS_ENABLED(PINCTRL)) {
+   if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
+   pinctrl_select_state(dev, "state_uhs");
+   else
+   pinctrl_select_state(dev, "default");
+   }
 }
 
 int tmio_sd_set_ios(struct udevice *dev)
@@ -734,11 +732,12 @@ int tmio_sd_probe(struct udevice *dev, u32 quirks)
if (!priv->regbase)
return -ENOMEM;
 
-#ifdef CONFIG_DM_REGULATOR
-   device_get_supply_regulator(dev, "vqmmc-supply", &priv->vqmmc_dev);
-   if (priv->vqmmc_dev)
-   regulator_set_value(priv->vqmmc_dev, 330);
-#endif
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
+   device_get_supply_regulator(dev, "vqmmc-supply",
+   &priv->vqmmc_dev);
+   if (priv->vqmmc_dev)
+   regulator_set_value(priv->vqmmc_dev, 330);
+   }
 
ret = mmc_of_parse(dev, &plat->cfg);
if (ret < 0) {
diff --git a/drivers/mmc/tmio-common.h b/drivers/mmc/tmio-common.h
index 4d717d85dec..f489fb70766 100644
--- a/drivers/mmc/tmio-common.h
+++ b/drivers/mmc/tmio-common.h
@@ -133,9 +133,7 @@ struct tmio_sd_priv {
 #define TMIO_SD_CAP_RCAR_UHS   BIT(7)  /* Renesas RCar UHS/SDR modes */
 #define TMIO_SD_CAP_RCAR   \
(TMIO_SD_CAP_RCAR_GEN2 | TMIO_SD_CAP_RCAR_GEN3)
-#ifdef CONFIG_DM_REGULATOR
struct udevice *vqmmc_dev;
-#endif
 #if CONFIG_IS_ENABLED(CLK)
struct clk  clk;
struct clk  clkh;
-- 
2.39.2



[PATCH v2 1/2] mmc: tmio: Check 'addr' width before checking for 64bit limitation

2023-02-28 Thread Marek Vasut
The 64bit limitation check is compiled and optimized out on 32bit
platforms, but generates a type width warning:

drivers/mmc/tmio-common.c: In function ‘tmio_sd_addr_is_dmaable’:
drivers/mmc/tmio-common.c:376:26: warning: right shift count >= width of type 
[-Wshift-count-overflow]
  376 | if (addr >> 32)
  |  ^~

Fix the warning by checking the addr type width to see whether the
shift even makes sense in the first place. The width check is also
optimized out at compile time.

Signed-off-by: Marek Vasut 
---
Cc: Jaehoon Chung 
Cc: Peng Fan 
---
V2: New patch
---
 drivers/mmc/tmio-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/tmio-common.c b/drivers/mmc/tmio-common.c
index e9c7d3a2e00..0b24a5a7bdb 100644
--- a/drivers/mmc/tmio-common.c
+++ b/drivers/mmc/tmio-common.c
@@ -373,7 +373,7 @@ static bool tmio_sd_addr_is_dmaable(struct mmc_data *data)
if (!(data->flags & MMC_DATA_READ) && !IS_ALIGNED(addr, 128))
return false;
/* Gen3 DMA has 32bit limit */
-   if (addr >> 32)
+   if (sizeof(addr) > 4 && addr >> 32)
return false;
 #endif
 
-- 
2.39.2



[PATCH] serial: sh: Make indent consistent

2023-02-28 Thread Marek Vasut
Make the indent of these macro elements consistent with the
rest of this table. No functional change.

Signed-off-by: Marek Vasut 
---
 drivers/serial/serial_sh.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/serial/serial_sh.h b/drivers/serial/serial_sh.h
index 660aaab6638..eb8523dde55 100644
--- a/drivers/serial/serial_sh.h
+++ b/drivers/serial/serial_sh.h
@@ -406,13 +406,13 @@ SCIF_FNS(SCSPTR,  0,  0, 0x24, 16)
 SCIF_FNS(SCLSR,0,  0, 0x28, 16)
 #else
 
-SCIF_FNS(SCFDR,  0x0e, 16, 0x1C, 16)
+SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
 #if defined(CONFIG_CPU_SH7722)
-SCIF_FNS(SCSPTR,0,  0, 0, 0)
+SCIF_FNS(SCSPTR,   0,  0, 0, 0)
 #else
-SCIF_FNS(SCSPTR,0,  0, 0x20, 16)
+SCIF_FNS(SCSPTR,   0,  0, 0x20, 16)
 #endif
-SCIF_FNS(SCLSR, 0,  0, 0x24, 16)
+SCIF_FNS(SCLSR,0,  0, 0x24, 16)
 #endif
 SCIF_FNS(DL,   0,  0, 0x0,  0) /* dummy */
 #endif
-- 
2.39.2



[PATCH] ARM: rmobile: Add R-Car Generation 4 support

2023-02-28 Thread Marek Vasut
From: Hai Pham 

This adds R-Car Generation 4 (Gen4) support as Renesas ARM64 SoC.

In this version, reusing R-Car Gen3 lowlevel initialize routine [1]
and R-Car Gen3 memory map tables [2] .

[1] arch/arm/mach-rmobile/lowlevel_init_gen3.S
[2] arch/arm/mach-rmobile/memmap-gen3.c

Reviewed-by: Marek Vasut 
Signed-off-by: Hai Pham 
Signed-off-by: Marek Vasut 
[Marek: - Enable DTO support by default
- Sort the Kconfig lists
- Select RCAR_64 Kconfig option to pull in all the shared
  Kconfig options with Gen3, and use where applicable to
  deduplicate entries.
- Fix reference [2] typo in commit message
- Drop config options moved to Kconfig, rename rest to CFG_
  accordingly to synchronize with upstream changes. Drop
  removed CONFIG_VERY_BIG_RAM.
- Move board size limit to arch/Kconfig
- Move GICR_BASE to headers instead of common config]
---
 Kconfig   |  6 +-
 arch/arm/mach-rmobile/Kconfig |  4 +
 arch/arm/mach-rmobile/Kconfig.64  |  1 +
 arch/arm/mach-rmobile/Kconfig.rcar4   |  8 ++
 arch/arm/mach-rmobile/Makefile|  2 +-
 arch/arm/mach-rmobile/cpu_info-rcar.c |  2 +-
 arch/arm/mach-rmobile/cpu_info.c  |  4 +-
 .../include/mach/rcar-gen4-base.h | 75 +++
 arch/arm/mach-rmobile/include/mach/rmobile.h  |  2 +
 board/renesas/rcar-common/common.c|  2 +-
 common/Kconfig|  2 +-
 include/configs/rcar-gen4-common.h| 30 
 12 files changed, 129 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/mach-rmobile/Kconfig.rcar4
 create mode 100644 arch/arm/mach-rmobile/include/mach/rcar-gen4-base.h
 create mode 100644 include/configs/rcar-gen4-common.h

diff --git a/Kconfig b/Kconfig
index 6dd524b0acb..eac480c956e 100644
--- a/Kconfig
+++ b/Kconfig
@@ -454,7 +454,7 @@ config REMAKE_ELF
 
 config BUILD_TARGET
string "Build target special images"
-   default "u-boot-elf.srec" if RCAR_GEN3
+   default "u-boot-elf.srec" if RCAR_64
default "u-boot-with-spl.bin" if ARCH_AT91 && SPL_NAND_SUPPORT
default "u-boot-with-spl.bin" if MPC85xx && !E500MC && !E5500 && !E6500 
&& SPL
default "u-boot-with-spl.imx" if ARCH_MX6 && SPL
@@ -473,14 +473,14 @@ config BUILD_TARGET
 
 config HAS_BOARD_SIZE_LIMIT
bool "Define a maximum size for the U-Boot image"
-   default y if RCAR_GEN3
+   default y if RCAR_64
help
  In some cases, we need to enforce a hard limit on how big the U-Boot
  image itself can be.
 
 config BOARD_SIZE_LIMIT
int "Maximum size of the U-Boot image in bytes"
-   default 1048576 if RCAR_GEN3
+   default 1048576 if RCAR_64
depends on HAS_BOARD_SIZE_LIMIT
help
  Maximum size of the U-Boot image. When defined, the build system
diff --git a/arch/arm/mach-rmobile/Kconfig b/arch/arm/mach-rmobile/Kconfig
index 921153a8d9e..1ef7d68bdf3 100644
--- a/arch/arm/mach-rmobile/Kconfig
+++ b/arch/arm/mach-rmobile/Kconfig
@@ -40,6 +40,10 @@ config RCAR_GEN3
imply SPL_USE_TINY_PRINTF
imply SPL_YMODEM_SUPPORT
 
+config RCAR_GEN4
+   bool "Renesas ARM SoCs R-Car Gen4 (64bit)"
+   select RCAR_64
+
 config RZA1
prompt "Renesas ARM SoCs RZ/A1 (32bit)"
select CPU_V7A
diff --git a/arch/arm/mach-rmobile/Kconfig.64 b/arch/arm/mach-rmobile/Kconfig.64
index 3b14721dab5..57ed1d6c50d 100644
--- a/arch/arm/mach-rmobile/Kconfig.64
+++ b/arch/arm/mach-rmobile/Kconfig.64
@@ -7,5 +7,6 @@ config OF_LIBFDT_OVERLAY
default y if RCAR_64
 
 source "arch/arm/mach-rmobile/Kconfig.rcar3"
+source "arch/arm/mach-rmobile/Kconfig.rcar4"
 
 endif
diff --git a/arch/arm/mach-rmobile/Kconfig.rcar4 
b/arch/arm/mach-rmobile/Kconfig.rcar4
new file mode 100644
index 000..6d9e16586d9
--- /dev/null
+++ b/arch/arm/mach-rmobile/Kconfig.rcar4
@@ -0,0 +1,8 @@
+if RCAR_GEN4
+
+choice
+   prompt "Renesas ARM64 SoCs board select"
+   optional
+endchoice
+
+endif
diff --git a/arch/arm/mach-rmobile/Makefile b/arch/arm/mach-rmobile/Makefile
index 5b86221bc25..fadb6eb0ab6 100644
--- a/arch/arm/mach-rmobile/Makefile
+++ b/arch/arm/mach-rmobile/Makefile
@@ -10,7 +10,7 @@ obj-$(CONFIG_DISPLAY_BOARDINFO) += board.o
 obj-$(CONFIG_TMU_TIMER) += ../../sh/lib/time.o
 obj-$(CONFIG_R8A7740) += lowlevel_init.o cpu_info-r8a7740.o pfc-r8a7740.o
 obj-$(CONFIG_RCAR_GEN2) += lowlevel_init_ca15.o cpu_info-rcar.o
-obj-$(CONFIG_RCAR_GEN3) += lowlevel_init_gen3.o cpu_info-rcar.o memmap-gen3.o
+obj-$(CONFIG_RCAR_64) += lowlevel_init_gen3.o cpu_info-rcar.o memmap-gen3.o
 obj-$(CONFIG_RZ_G2) += cpu_info-rzg.o
 
 ifneq ($(CONFIG_R8A779A0),)
diff --git a/arch/arm/mach-rmobile/cpu_

  1   2   3   4   5   6   7   8   9   10   >