Re: [PATCH 0/5] Add ESM driver support for AM64x R5

2022-02-22 Thread Christian Gmeiner
Hi Hari

Am Mi., 2. Feb. 2022 um 18:50 Uhr schrieb Hari Nagalla :
>
> AM64x devices have a main ESM and a MCU ESM. The ESM driver enables
> routing of the error events from various sources to different processors
> or to reset hardware logic. Only the MCU ESM's high output can trigger
> reset logic. The main RTI0 WWDT output can be routed to the MCU
> highoutput to trigger reset through the main ESM. For this reset to
> occur CTRLMMR_MCU_RST_CTRL:MCU_ESM_ERROR_RESET_EN_Z is set to '0'.
>
> AM64x Technical Reference Manual - https://www.ti.com/lit/pdf/spruim2


Are there any plans to send out a V2 of this patch series? If not I
can jump in (as I really
want to see in U-Boot sooner than later).

-- 
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info/privacypolicy


Re: [PATCH] board: st: common: update test on misc_read result in command stboard

2022-02-22 Thread Patrice CHOTARD
Hi Patrick

On 2/1/22 14:37, Patrick Delaunay wrote:
> Update management of misc_read/misc_write, which now returns length of
> data after the commit 8729b1ae2cbd ("misc: Update read() and write()
> methods to return bytes xfered"): raise a error when the result is not
> the expected length.
> 
> Fixes: 658fde8a36ff ("board: stm32mp1: stboard: lock the OTP after 
> programming")
> Signed-off-by: Patrick Delaunay 
> ---
> 
>  board/st/common/cmd_stboard.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/board/st/common/cmd_stboard.c b/board/st/common/cmd_stboard.c
> index 2fba383168..c1ecd643b0 100644
> --- a/board/st/common/cmd_stboard.c
> +++ b/board/st/common/cmd_stboard.c
> @@ -91,14 +91,14 @@ static int do_stboard(struct cmd_tbl *cmdtp, int flag, 
> int argc,
>   ret = misc_read(dev, STM32_BSEC_OTP(BSEC_OTP_BOARD),
>   , sizeof(otp));
>  
> - if (ret < 0) {
> + if (ret != sizeof(otp)) {
>   puts("OTP read error");
>   return CMD_RET_FAILURE;
>   }
>  
>   ret = misc_read(dev, STM32_BSEC_LOCK(BSEC_OTP_BOARD),
>   , sizeof(lock));
> - if (ret < 0) {
> + if (ret != sizeof(lock)) {
>   puts("LOCK read error");
>   return CMD_RET_FAILURE;
>   }
> @@ -172,7 +172,7 @@ static int do_stboard(struct cmd_tbl *cmdtp, int flag, 
> int argc,
>   ret = misc_write(dev, STM32_BSEC_OTP(BSEC_OTP_BOARD),
>, sizeof(otp));
>  
> - if (ret < 0) {
> + if (ret != sizeof(otp)) {
>   puts("BOARD programming error\n");
>   return CMD_RET_FAILURE;
>   }
> @@ -181,7 +181,7 @@ static int do_stboard(struct cmd_tbl *cmdtp, int flag, 
> int argc,
>   otp = 1;
>   ret = misc_write(dev, STM32_BSEC_LOCK(BSEC_OTP_BOARD),
>, sizeof(otp));
> - if (ret < 0) {
> + if (ret != sizeof(otp)) {
>   puts("BOARD lock error\n");
>   return CMD_RET_FAILURE;
>   }
Reviewed-by: Patrice Chotard 

Thanks
Patrice


Re: [PATCH] video: stm32: stm32_ltdc: fix the check of return value of clk_set_rate()

2022-02-22 Thread Patrice CHOTARD
Hi Patrick

On 2/1/22 14:02, Patrick Delaunay wrote:
> From: Gabriel Fernandez 
> 
> The clk_set_rate() function returns rate as an 'ulong' not
> an 'int' and rate > 0 by default.
> 
> This patch avoids to display the associated warning when
> the set rate function returns the new frequency.
> 
> Fixes: aeaf330649e8 ("video: stm32: stm32_ltdc: add bridge to display 
> controller")
> Signed-off-by: Gabriel Fernandez 
> Signed-off-by: Patrick Delaunay 
> ---
> 
>  drivers/video/stm32/stm32_ltdc.c | 11 ++-
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/video/stm32/stm32_ltdc.c 
> b/drivers/video/stm32/stm32_ltdc.c
> index 87e5fd54d9..e741e74739 100644
> --- a/drivers/video/stm32/stm32_ltdc.c
> +++ b/drivers/video/stm32/stm32_ltdc.c
> @@ -338,6 +338,7 @@ static int stm32_ltdc_probe(struct udevice *dev)
>   struct display_timing timings;
>   struct clk pclk;
>   struct reset_ctl rst;
> + ulong rate;
>   int ret;
>  
>   priv->regs = (void *)dev_read_addr(dev);
> @@ -375,13 +376,13 @@ static int stm32_ltdc_probe(struct udevice *dev)
>   }
>   }
>  
> - ret = clk_set_rate(, timings.pixelclock.typ);
> - if (ret)
> - dev_warn(dev, "fail to set pixel clock %d hz\n",
> -  timings.pixelclock.typ);
> + rate = clk_set_rate(, timings.pixelclock.typ);
> + if (IS_ERR_VALUE(rate))
> + dev_warn(dev, "fail to set pixel clock %d hz, ret=%ld\n",
> +  timings.pixelclock.typ, rate);
>  
>   dev_dbg(dev, "Set pixel clock req %d hz get %ld hz\n",
> - timings.pixelclock.typ, clk_get_rate());
> + timings.pixelclock.typ, rate);
>  
>   ret = reset_get_by_index(dev, 0, );
>   if (ret) {

Reviewed-by: Patrice Chotard 

Thanks
Patrice


Re: [PATCH v2] ARM: imx: imx8mn-*-evk: use DM settings for PHY configuration

2022-02-22 Thread Heiko Thiery
Hi Marek,

Am Di., 22. Feb. 2022 um 19:13 Uhr schrieb Marek Vasut :
>
> On 2/22/22 17:00, Michael Walle wrote:
> > Am 2022-02-22 16:19, schrieb Heiko Thiery:
> >> With the correct settings described in the device-tree the PHY settings
> >> in the board init are no longer required. The values are taken from the
> >> linux device tree.
> >>
> >> Suggested-by: Michael Walle 
> >> Signed-off-by: Heiko Thiery 
> >> ---
> >> v2:
> >>  - remove phy-reset-gpios node (thanks to Michael)
> >> When using DM_ETH_PHY the reset-gpios from the phy is used
> >>
> >>  arch/arm/dts/imx8mn-evk.dtsi| 10 +-
> >>  board/freescale/imx8mn_evk/imx8mn_evk.c | 16 
> >>  2 files changed, 9 insertions(+), 17 deletions(-)
>
> It seems someone was faster with this patch after all, thanks.
>
> >> diff --git a/arch/arm/dts/imx8mn-evk.dtsi b/arch/arm/dts/imx8mn-evk.dtsi
> >> index 416fadb22b..fd253f0042 100644
> >> --- a/arch/arm/dts/imx8mn-evk.dtsi
> >> +++ b/arch/arm/dts/imx8mn-evk.dtsi
> >> @@ -53,7 +53,6 @@
> >>  pinctrl-0 = <_fec1>;
> >>  phy-mode = "rgmii-id";
> >>  phy-handle = <>;
> >> -phy-reset-gpios = < 22 GPIO_ACTIVE_LOW>;
> >
> > This ...
>
> I'm afraid the phy reset in the phy node won't really end up toggling
> the PHY reset GPIO, would it ?

I think you're right. The "new" reset-gpios property is not supported
by the fec driver. I think this is also valid for the linux driver if
I'm not wrong. But then some boards in linux also cannot do a phy
reset at initialization/probing. Is that right?

-- 
Heiko


RE: [PATCH v2] mmc: fsl_esdhc_imx: use VENDORSPEC_FRC_SDCLK_ON when necessary

2022-02-22 Thread Peng Fan (OSS)
> Subject: [PATCH v2] mmc: fsl_esdhc_imx: use VENDORSPEC_FRC_SDCLK_ON
> when necessary
> 
> From: Haibo Chen 
> 
> After commit f132aab40327 ("Revert "mmc: fsl_esdhc_imx: use
> VENDORSPEC_FRC_SDCLK_ON to control card clock output""), it involve issue
> in mmc_switch_voltage(), because of the special design of usdhc.
> 
> For FSL_USDHC, it do not implement
> VENDORSPEC_CKEN/PEREN/HCKEN/IPGEN,
> these are reserved bits(Though RM contain the definition of these bits, but
> actually internal IC logic do not implement, already confirm with IC team).
> Instead, use VENDORSPEC_FRC_SDCLK_ON to gate on/off the card clock
> output. Here is the definition of this bit in RM:
> 
> [8] FRC_SDCLK_ON
> Force CLK output active
> Do not set this bit to 1 unless it is necessary. Also, make sure that this 
> bit is
> cleared when uSDHC’s clock is about to be changed (frequency change, clock
> source change, or delay chain tuning).
> 0b - CLK active or inactive is fully controlled by the hardware.
> 1b - Force CLK active
> 
> In default, the FRC_SDCLK_ON is 0. This means, when there is no command or
> data transfer on bus, hardware will gate off the card clock. But in some case,
> we need the card clock keep on. Take IO voltage 1.8v switch as example, after
> IO voltage change to 1.8v, spec require gate off the card clock for 5ms, and
> gate on the clock back, once detect the card clock on, then the card will draw
> the dat0 to high immediately. If there is not clock gate off/on behavior, some
> card will keep the dat0 to low level. This is the reason we fail in
> mmc_switch_voltage().
> 
> To fix this issue, and concern that this is only the fsl usdhc hardware design
> limitation, set the bit FRC_SDCLK_ON in the beginning of the
> wait_dat0() and clear it in the end. To make sure the 1.8v IO voltage switch
> process align with SD specification.
> 
> For standard tuning process, usdhc specification also require the card clock
> keep on, so also add these behavior in fsl_esdhc_execute_tuning().
> 
> Reviewed-by: Marek Vasut 
> Tested-by: Fabio Estevam 
> Signed-off-by: Haibo Chen 

Reviewed-by: Peng Fan 

> ---
>  drivers/mmc/fsl_esdhc_imx.c | 25 ++---
>  include/fsl_esdhc_imx.h |  2 ++
>  2 files changed, 24 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
> index 9299635f50..e0108144e7 100644
> --- a/drivers/mmc/fsl_esdhc_imx.c
> +++ b/drivers/mmc/fsl_esdhc_imx.c
> @@ -831,13 +831,16 @@ static int fsl_esdhc_execute_tuning(struct udevice
> *dev, uint32_t opcode)
>   struct mmc *mmc = >mmc;
>   u32 irqstaten = esdhc_read32(>irqstaten);
>   u32 irqsigen = esdhc_read32(>irqsigen);
> - int i, ret = -ETIMEDOUT;
> - u32 val, mixctrl;
> + int i, err, ret = -ETIMEDOUT;
> + u32 val, mixctrl, tmp;
> 
>   /* clock tuning is not needed for upto 52MHz */
>   if (mmc->clock <= 5200)
>   return 0;
> 
> + /* make sure the card clock keep on */
> + esdhc_setbits32(>vendorspec, VENDORSPEC_FRC_SDCLK_ON);
> +
>   /* This is readw/writew SDHCI_HOST_CONTROL2 when tuning */
>   if (priv->flags & ESDHC_FLAG_STD_TUNING) {
>   val = esdhc_read32(>autoc12err); @@ -897,6 +900,12 @@
> static int fsl_esdhc_execute_tuning(struct udevice *dev, uint32_t opcode)
> 
>   esdhc_stop_tuning(mmc);
> 
> + /* change to default setting, let host control the card clock */
> + esdhc_clrbits32(>vendorspec, VENDORSPEC_FRC_SDCLK_ON);
> + err = readx_poll_timeout(esdhc_read32, >prsstat, tmp, tmp &
> PRSSTAT_SDOFF, 100);
> + if (err)
> + dev_warn(dev, "card clock not gate off as expect.\n");
> +
>   return ret;
>  }
>  #endif
> @@ -1555,14 +1564,24 @@ static int __maybe_unused
> fsl_esdhc_set_enhanced_strobe(struct udevice *dev)  static int
> fsl_esdhc_wait_dat0(struct udevice *dev, int state,
>   int timeout_us)
>  {
> - int ret;
> + int ret, err;
>   u32 tmp;
>   struct fsl_esdhc_priv *priv = dev_get_priv(dev);
>   struct fsl_esdhc *regs = priv->esdhc_regs;
> 
> + /* make sure the card clock keep on */
> + esdhc_setbits32(>vendorspec, VENDORSPEC_FRC_SDCLK_ON);
> +
>   ret = readx_poll_timeout(esdhc_read32, >prsstat, tmp,
>   !!(tmp & PRSSTAT_DAT0) == !!state,
>   timeout_us);
> +
> + /* change to default setting, let host control the card clock */
> + esdhc_clrbits32(>vendorspec, VENDORSPEC_FRC_SDCLK_ON);
> + err = readx_poll_timeout(esdhc_read32, >prsstat, tmp, tmp &
> PRSSTAT_SDOFF, 100);
> + if (err)
> + dev_warn(dev, "card clock not gate off as expect.\n");
> +
>   return ret;
>  }
> 
> diff --git a/include/fsl_esdhc_imx.h b/include/fsl_esdhc_imx.h index
> 2153f29bef..b8efd2a166 100644
> --- a/include/fsl_esdhc_imx.h
> +++ b/include/fsl_esdhc_imx.h
> @@ -37,6 +37,7 @@
>  #define VENDORSPEC_HCKEN 0x1000
>  #define 

[PULL] u-boot-usb/master

2022-02-22 Thread Marek Vasut

This is likely the last bigger series for this cycle:

The following changes since commit 17a0dc6abfdbf392f6a27074f2633608038c4221:

  Merge branch '2022-02-21-platform-updates' (2022-02-21 08:53:24 -0500)

are available in the Git repository at:

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

for you to fetch changes up to 4cea6ed92da456fe234b4f3439707ff29c6a790e:

  configs: omap various: Remove OMAP_EHCI_PHY from defconfigs 
(2022-02-23 05:25:17 +0100)



Adam Ford (7):
  usb: ehci-omap: Drop dead code
  usb: ehci-omap: Move omap_ehci_hcd_init to omap_ehci_probe
  phy: nop-phy: Fix enabling reset
  usb: ehci-omap: Make Kconfig select PHY if USB_EHCI_OMAP
  usb: ehci-omap: Use PHY system to manage phy resets
  usb: ehci-omap: Remove OMAP_EHCI_PHYx_RESET_GPIO from Kconfig
  configs: omap various: Remove OMAP_EHCI_PHY from defconfigs

 arch/arm/include/asm/ehci-omap.h |  13 --
 configs/am3517_evm_defconfig |   2 --
 configs/omap35_logic_somlv_defconfig |   2 --
 configs/omap3_beagle_defconfig   |   2 --
 configs/omap3_logic_somlv_defconfig  |   2 --
 configs/omap4_panda_defconfig|   4 
 configs/omap5_uevm_defconfig |   4 
 drivers/phy/nop-phy.c|   5 ++--
 drivers/usb/host/Kconfig |  36 ++--
 drivers/usb/host/ehci-omap.c | 126 
++--

 10 files changed, 66 insertions(+), 130 deletions(-)


Re: [PATCH 0/7] Migrate omap_ehci to use phy driver

2022-02-22 Thread Marek Vasut

On 2/22/22 01:24, Derald Woods wrote:

On Sat, Feb 19, 2022 at 5:09 PM Adam Ford  wrote:


With the NOP PHY driver available, it can support toggling the
GPIOS to handle coming out of reset. This series cleans up
the OMAP EHCI host driver, enables PHY support, and removes
the code to toggle the reset GPIO's.

This series was tested on an OMAP3530, DM3730, and an AM3517.
Users of the omap4_panda, omap3_beagle, omap5_uevm, omap3_evm
are asked to test since I do not have that hardware available
to me and get_maintainer.pl doesn't list the owners of the
affected defconfig files.

Adam Ford (7):
   usb: ehci-omap: Drop dead code
   usb: ehci-omap: Move omap_ehci_hcd_init to omap_ehci_probe
   phy: nop-phy: Fix enabling reset
   usb: ehci-omap: Make Kconfig select PHY if USB_EHCI_OMAP
   usb: ehci-omap: Use PHY system to manage phy resets
   usb: ehci-omap: Remove OMAP_EHCI_PHYx_RESET_GPIO from Kconfig
   configs: omap various:  Remove OMAP_EHCI_PHY from defconfigs

  arch/arm/include/asm/ehci-omap.h |  13 ---
  configs/am3517_evm_defconfig |   2 -
  configs/omap35_logic_somlv_defconfig |   2 -
  configs/omap3_beagle_defconfig   |   2 -
  configs/omap3_logic_somlv_defconfig  |   2 -
  configs/omap4_panda_defconfig|   4 -
  configs/omap5_uevm_defconfig |   4 -
  drivers/phy/nop-phy.c|   5 +-
  drivers/usb/host/Kconfig |  36 +---
  drivers/usb/host/ehci-omap.c | 126 +--
  10 files changed, 66 insertions(+), 130 deletions(-)

--
2.32.0



Works for me using 'omap3_beagle_defconfig' on Beagle Rev. C4 (3530) and
Beagle xM (3730).

Tested-by: Derald D. Woods 


Thanks, applied all.


Re: [PATCH 5/7] usb: ehci-omap: Use PHY system to manage phy resets

2022-02-22 Thread Marek Vasut

On 2/20/22 00:08, Adam Ford wrote:

[...]


@@ -364,7 +356,21 @@ static int omap_ehci_probe(struct udevice *dev)
hccr = (struct ehci_hccr *)>ehci->hccapbase;
hcor = (struct ehci_hcor *)>ehci->usbcmd;
  
-	ret = omap_ehci_hcd_init(0, _bdata);

+   /* Identify Phys */
+   ret = omap_ehci_phy_get(dev);
+   if (ret) {
+   printf("Failed to get phys\n");
+   return ret;


It would be good to print the return values here (ret=%d), since in case 
there is an actual failure, you can infer what happened from that return 
value without having to patch the code to add that missing return value 
print.


Subsequent patch would be fine, assuming CI passes.

[...]


Re: [PATCH 01/24] moveconfig: Show the config name rather than the defconfig

2022-02-22 Thread Simon Glass
Hi Alper,

On Tue, 22 Feb 2022 at 19:35, Simon Glass  wrote:
>
> On 08/02/2022 21:49, Simon Glass wrote:
> > The _defconfig suffix is unnecessary when showing matching boards. Drop
> > it.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >  tools/moveconfig.py | 15 ++-
> >  1 file changed, 14 insertions(+), 1 deletion(-)
> >
> Applied to u-boot-dm, thanks!

Well I completely missed all your comments. If the pull request
doesn't work I'll give it another go, but for now I will do a few new
patches with your comments addressed. I haven't made much time for
things lately.

Regards,
Simon


Re: [PATCH 19/24] binman: Allow different operations in FIT generator nodes

2022-02-22 Thread Simon Glass
At present we only support expanding out FDT nodes. Make the operation
into an @operation property, so that others can be supported.

Re-arrange and tidy up the documentation so that it has separate
headings for each topic.

Signed-off-by: Simon Glass 
---

 tools/binman/entries.rst   |  85 +++-
 tools/binman/etype/fit.py  | 136 -
 tools/binman/ftest.py  |   7 ++
 tools/binman/test/220_fit_bad_oper.dts |  27 +
 4 files changed, 206 insertions(+), 49 deletions(-)
 create mode 100644 tools/binman/test/220_fit_bad_oper.dts

Applied to u-boot-dm, thanks!


Re: [u-boot PATCH v2] binman: Add support for TEE BL32

2022-02-22 Thread Simon Glass
On Sun, 20 Feb 2022 at 08:06, Roger Quadros  wrote:
>
>
> On 20/02/2022 00:12, Simon Glass wrote:
> > On Sat, 19 Feb 2022 at 11:50, Roger Quadros  wrote:
> >>
> >> Add an entry for OP-TEE Trusted OS 'BL32' payload.
> >> This is required by platforms using Cortex-A cores with TrustZone
> >> technology.
> >>
> >> Signed-off-by: Roger Quadros 
> >> ---
> >> Changelog:
> >> v2:
> >> - use 'tee-os' for entry name instead of 'bl32'
> >> - use ${TEE} instead of ${BL32} for environment variable
> >> - Use next available test file number for test device tree
> >> - drop size property from test device node.
> >>
> >>  Makefile |  1 +
> >>  tools/binman/entries.rst | 13 +
> >>  tools/binman/etype/tee_os.py | 22 ++
> >>  tools/binman/ftest.py|  7 +++
> >>  tools/binman/test/220_tee_os.dts | 14 ++
> >>  5 files changed, 57 insertions(+)
> >>  create mode 100644 tools/binman/etype/tee_os.py
> >>  create mode 100644 tools/binman/test/220_tee_os.dts
> >
> > Reviewed-by: Simon Glass 
> >
> > I will renumber the test file and add missing-blob-help when applying.
>
> Thank you Simon :)

Applied to u-boot/dm, thanks!


Re: [PATCH] phy: phy-uclass: check the parents for phys

2022-02-22 Thread Simon Glass
On Thu, 3 Feb 2022 at 11:08, Angus Ainslie  wrote:
>
> The port/hub leaf nodes don't contain the phy definitions in some dts
> files so check the parents.
>
> Signed-off-by: Angus Ainslie 
> ---
>  drivers/phy/phy-uclass.c | 20 ++--
>  1 file changed, 14 insertions(+), 6 deletions(-)

Reviewed-by: Simon Glass 


>
Applied to u-boot-dm, thanks!


Re: [PATCH 03/24] spl: x86: Correct the binman symbols for SPL

2022-02-22 Thread Simon Glass
On 08/02/2022 21:49, Simon Glass wrote:
> These symbols are incorrect, meaning that binman cannot find the
> associated entry. This leads to errors like:
>
> binman: Section '/binman/simple-bin': Symbol '_binman_spl_prop_size'
>in entry '/binman/simple-bin/u-boot-spl/u-boot-spl-nodtb':
>Entry 'spl' not found in list (mkimage,u-boot-spl-nodtb,
>u-boot-spl-bss-pad,u-boot-spl-dtb,u-boot-spl,u-boot-img,main-section)

I can't help but feel like this is a bug with entry expansion where the
name of the expanded node is ignored (and replaced by its type?) when it
comes to the symbols.

>
> Fix it.
>
> Signed-off-by: Simon Glass 
> ---
>
>  arch/x86/dts/u-boot.dtsi | 2 +-
>  common/spl/spl.c | 8 
>  include/spl.h| 4 ++--
>  3 files changed, 7 insertions(+), 7 deletions(-)
>
Applied to u-boot-dm, thanks!


Re: [PATCH 11/24] elf: Add a way to read segment information from an ELF file

2022-02-22 Thread Simon Glass
On 08/02/2022 21:49, Simon Glass wrote:
> Add a function which reads the segments and the entry address.
>
> Also fix a comment nit in the tests while we are here.
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/binman/elf.py  | 37 +
>  tools/binman/elf_test.py | 31 +--
>  2 files changed, 66 insertions(+), 2 deletions(-)
>
Applied to u-boot-dm, thanks!


Re: [PATCH 06/24] dtoc: Support adding a string list to a device tree

2022-02-22 Thread Simon Glass
On 08/02/2022 21:49, Simon Glass wrote:
> Add a new function to add a string list.
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/dtoc/fdt.py  | 18 ++
>  tools/dtoc/test_fdt.py |  8 
>  2 files changed, 26 insertions(+)
>
Applied to u-boot-dm, thanks!


Re: [PATCH v2 5/5] binman: Update image positions of FIT subentries

2022-02-22 Thread Simon Glass
Hi Alper,

On Mon, 7 Feb 2022 at 15:08, Alper Nebi Yasak  wrote:
>
> Binman keeps track of positions of each entry in the final image, but
> currently this data is wrong for things included in FIT entries,
> especially since a previous patch makes FIT a subclass of Section and
> inherit its implementation.
>
> There are three ways to put data into a FIT image. It can be directly
> included as a "data" property, or it can be external to the FIT image
> represented by an offset-size pair of properties. This external offset
> is either "data-position" from the start of the FIT or "data-offset"
> from the end of the FIT, and the size is "data-size" for both. However,
> binman doesn't use the "data-offset" method while building FIT entries.
>
> According to the Section docstring, its subclasses should calculate and
> set the correct offsets and sizes in SetImagePos() method. Do this for
> FIT subentries for the three ways mentioned above, and add tests for the
> two ways binman can pack them in.
>
> Signed-off-by: Alper Nebi Yasak 
> Reviewed-by: Simon Glass 
> ---
>
> Changes in v2:
> - Check missing_bintools list instead of catching Fdt exceptions
> - Add tag: "Reviewed-by: Simon Glass "
>
>  tools/binman/etype/fit.py |  51 +
>  tools/binman/ftest.py | 112 ++
>  2 files changed, 163 insertions(+)

As mentioned I had to change the previous patch in a minor way to get
it to apply.

I'd really like to get this in if possible, too. The issue is the
handling of hash nodes in a FIT, as I mentioned.

If you are able to rework this, please let me know.

I've gone ahead sent my fit series but will rebase it onto this patch
if you are able to fix it up.

Regards,
Simon

Applied to u-boot-dm, thanks!


Re: [PATCH] binman: Correct the error message for a bad hash algorithm

2022-02-22 Thread Simon Glass
Hi Alper,

On Tue, 8 Feb 2022 at 11:54, Alper Nebi Yasak  wrote:
>
> On 08/02/2022 20:59, Simon Glass wrote:
> > This shows an internal type at present, rather than the algorithm name.
> > Fix it and update the test to catch this.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >  tools/binman/ftest.py | 2 +-
> >  tools/binman/state.py | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
>
> Reviewed-by: Alper Nebi Yasak 
>
> I saw the failing build for my series [1]. Looks to me like binman
> doesn't support crc32 in hash nodes, and turning FIT into a Section
> simply exposed that. I tried a sloppy fix, see below.
>
> [1] https://source.denx.de/u-boot/custodians/u-boot-dm/-/jobs/388771
>
Applied to u-boot-dm, thanks!


Re: [PATCH 01/24] moveconfig: Show the config name rather than the defconfig

2022-02-22 Thread Simon Glass
On 08/02/2022 21:49, Simon Glass wrote:
> The _defconfig suffix is unnecessary when showing matching boards. Drop
> it.
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/moveconfig.py | 15 ++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
>
Applied to u-boot-dm, thanks!


Re: [PATCH 04/24] spl: Allow disabling binman symbols in SPL

2022-02-22 Thread Simon Glass
On 08/02/2022 21:49, Simon Glass wrote:
> When CONFIG_SPL_FIT is enabled we do not access U-Boot directly in
> the image, since it is embedded in a FIT which is parsed at runtime.
>
> Provide a CONFIG option to drop the symbols in this case.
>
> Signed-off-by: Simon Glass 
> ---
>
>  common/spl/Kconfig | 24 
>  common/spl/spl.c   |  4 
>  2 files changed, 28 insertions(+)
>
Applied to u-boot-dm, thanks!


Re: [PATCH 02/24] moveconfig: Allow regex matches when finding combinations

2022-02-22 Thread Simon Glass
On 08/02/2022 21:49, Simon Glass wrote:
> It is useful to be able to search for CONFIG options that match a regex,
> such as this, which lists boards which define SPL_FIT_GENERATOR and
> anything not starting with ROCKCHIP:
>
>./tools/moveconfig.py -f SPL_FIT_GENERATOR ~ROCKCHIP.*
>
> Add support for this.
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/moveconfig.py | 24 ++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
>
Applied to u-boot-dm, thanks!


Re: [PATCH 14/24] binman: Support a list of strings with the mkimage etype

2022-02-22 Thread Simon Glass
On 08/02/2022 21:49, Simon Glass wrote:
> At present the 'args' property of the mkimage entry type is a string. This
> makes it difficult to include CONFIG options in that property. In
> particular, this does not work:
>
>args = "-n CONFIG_SYS_SOC -E"
>
> since the preprocessor does not operate within strings, nor does this:
>
>args = "-n" CONFIG_SYS_SOC" "-E"
>
> since the device tree compiler does not understand string concatenation.

Fun fact, I got something like this roughly working:

#define _QUOTE(x) #x
#define QUOTE(x) _QUOTE(x)

#define MKIMAGE_ARGS QUOTE( \
   -A arm -T kernel -C none -O linux -n U-Boot \
   -a CONFIG_SYS_TEXT_BASE -e CONFIG_SYS_TEXT_BASE \
)

But obviously a string list is the better choice.

>
> With this new feature, we can do:
>
>args = "-n", CONFIG_SYS_SOC, "-E";
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/binman/entries.rst  | 11 +++
>  tools/binman/etype/mkimage.py | 13 -
>  2 files changed, 23 insertions(+), 1 deletion(-)
>
Applied to u-boot-dm, thanks!


Re: [PATCH 09/24] dtoc: Support reading a list of arguments

2022-02-22 Thread Simon Glass
On 08/02/2022 21:49, Simon Glass wrote:
> It is helpful to support a string or stringlist containing a list of
> space-separated arguments, for example:
>
>args = "-n fred", "-a", "123";
>
> This resolves to the list:
>
>-n fred -a 123

Would be clearer as ['-n', 'fred', '-a', '123']

>
> which can be passed to a program as arguments.
>
> Add a helper to do the required processing.
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/dtoc/fdt_util.py   | 12 
>  tools/dtoc/test/dtoc_test_simple.dts |  1 +
>  tools/dtoc/test_fdt.py   | 15 +++
>  3 files changed, 28 insertions(+)
>
Applied to u-boot-dm, thanks!


Re: [PATCH 10/24] binman: Update docs to indicate mkimage is supported

2022-02-22 Thread Simon Glass
Now that there is a mkimage entry-type, update the docs to remove the
future reference.

Signed-off-by: Simon Glass 
---

 tools/binman/binman.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied to u-boot-dm, thanks!


Re: [PATCH 16/24] binman: Move entry-data collection into a Entry method

2022-02-22 Thread Simon Glass
On 08/02/2022 21:50, Simon Glass wrote:
> Collecting the data from a list of entries and putting it in a file is
> a useful operation that will be needed by other entry types. Put this into
> a method in the Entry class.
>
> Add some documentation about how to collect data for an entry type.
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/binman/binman.rst   | 86 +++
>  tools/binman/entry.py | 28 
>  tools/binman/etype/mkimage.py | 14 ++
>  3 files changed, 118 insertions(+), 10 deletions(-)
>
Applied to u-boot-dm, thanks!


Re: [PATCH 17/24] binman: fit: Refactor to reduce function size

2022-02-22 Thread Simon Glass
On 08/02/2022 21:50, Simon Glass wrote:
> Split subnode and property processing into separate functions to make
> the _AddNode() function a little smaller. Tweak a few comments.
>
> This does not change any functionality.
>
> Signed-off-by: Simon Glass 
> ---

I know this just moves code around a bit, but I think the code here
could be cleaned up much further with a bit of redesign. I'm not sure of
the details, but was thinking of at least:

- self._add_fit_image() to handle image/* subnodes
- self._add_fit_config() to handle configuration/* subnodes
- self._gen_fdt_nodes() to handle template nodes by calling the above
- Switching away from recursion to iterating subnodes of fixed nodes

>
>  tools/binman/etype/fit.py | 116 --
>  1 file changed, 73 insertions(+), 43 deletions(-)
>
Applied to u-boot-dm, thanks!


Re: [PATCH v2] binman: Skip processing "hash" subnodes of FIT subsections

2022-02-22 Thread Simon Glass
On Wed, 9 Feb 2022 at 12:02, Alper Nebi Yasak  wrote:
>
> Binman's FIT entry type can have image subentries with "hash" subnodes
> intended to be processed by mkimage, but not binman. However, the Entry
> class and any subclass that reuses its implementation tries to process
> these unconditionally. This can lead to an error when boards specify
> hash algorithms that binman doesn't support, but mkimage supports.
>
> Let entries skip processing these "hash" subnodes based on an instance
> variable, and set this instance variable for FIT subsections. Also
> re-enable processing of calculated and missing properties of FIT entries
> which was disabled to mitigate this issue.
>
> Signed-off-by: Alper Nebi Yasak 
> ---
> This applies on top of u-boot-dm/master, and does not resend my
> "binman: Update image positions of FIT subentries" patch [1] which
> should be applied on top of this.
>
> [1] 
> https://patchwork.ozlabs.org/project/uboot/patch/20220207220809.4497-6-alpernebiya...@gmail.com/
>
> Changes in v2:
> - Set update_hash via a SetUpdateHash() method
> - Add a test using hash nodes in FIT subentries
>
> v1: 
> https://patchwork.ozlabs.org/project/uboot/patch/20220208230656.43504-1-alpernebiya...@gmail.com/
>
>  tools/binman/entry.py   | 23 +++--
>  tools/binman/etype/fit.py   | 12 +
>  tools/binman/ftest.py   | 24 ++
>  tools/binman/test/221_fit_subentry_hash.dts | 52 +
>  4 files changed, 97 insertions(+), 14 deletions(-)
>  create mode 100644 tools/binman/test/221_fit_subentry_hash.dts
>

Reviewed-by: Simon Glass 

Applied to u-boot-dm, thanks!


Re: [PATCH] scripts: dtc: libfdt: fdt_ro.c: always define fdt_check_full

2022-02-22 Thread Simon Glass
On Wed, 9 Feb 2022 at 10:01, Philippe Reynes
 wrote:
>
> On some configs (like stm32mp15_dhcom_basic_defconfig), if configs
> SPL_LOAD_FIT_FULL and SPL_FIT_FULL_CHECK are enabled. Then the compilatio
> fails with the following error:
>
> arm-linux-gnueabi-ld.bfd: boot/image-fit.o: in function `fit_check_format':
> /uboot/u-boot-stm/boot/image-fit.c:1641: undefined reference to 
> `fdt_check_full'
> scripts/Makefile.spl:509: recipe for target 'spl/u-boot-spl' failed
>
> This issue happens because the function fdt_check_full is only defined if
> "!defined(FDT_ASSUME_MASK) || FDT_ASSUME_MASK != 0xff". But this function
> may be called even if this condition are not verified. To avoid this issue,
> the function fdt_check_full is always defined.
>
> Signed-off-by: Philippe Reynes 
> ---
>  scripts/dtc/libfdt/fdt_ro.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass 

Applied to u-boot-dm, thanks!


Please pull u-boot-dm

2022-02-22 Thread Simon Glass
Hi Tom,

https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/11053


The following changes since commit 17a0dc6abfdbf392f6a27074f2633608038c4221:

  Merge branch '2022-02-21-platform-updates' (2022-02-21 08:53:24 -0500)

are available in the Git repository at:

  git://git.denx.de/u-boot-dm.git tags/dm-pull-2

for you to fetch changes up to 70f42e720c90faa2fa27836288559e0d647862b7:

  scripts: dtc: libfdt: fdt_ro.c: always define fdt_check_full (2022-02-22
10:05:44 -0700)


binman fixes/improvements to FIT generator
binman SPL fixes
moveconfig support regex matches


Alper Nebi Yasak (2):
  binman: Skip processing "hash" subnodes of FIT subsections
  binman: Update image positions of FIT subentries

Angus Ainslie (1):
  phy: phy-uclass: check the parents for phys

Philippe Reynes (1):
  scripts: dtc: libfdt: fdt_ro.c: always define fdt_check_full

Roger Quadros (1):
  binman: Add support for TEE BL32

Simon Glass (18):
  binman: Correct the error message for a bad hash algorithm
  moveconfig: Show the config name rather than the defconfig
  moveconfig: Allow regex matches when finding combinations
  spl: x86: Correct the binman symbols for SPL
  spl: Allow disabling binman symbols in SPL
  dtoc: Support adding a string list to a device tree
  dtoc: Support deleting a node
  dtoc: Allow deleting nodes and adding them in the same sync
  dtoc: Support reading a list of arguments
  binman: Update docs to indicate mkimage is supported
  elf: Add a way to read segment information from an ELF file
  binman: Add to the TODO
  binman: Support a list of strings with the mkimage etype
  binman: Add a ELF test file with disjoint text sections
  binman: Move entry-data collection into a Entry method
  binman: fit: Refactor to reduce function size
  binman: Tidy up the docs a little with fit
  binman: Allow different operations in FIT generator nodes

 Makefile|   1 +
 arch/x86/dts/u-boot.dtsi|   2 +-
 common/spl/Kconfig  |  24 
 common/spl/spl.c|  12 +-
 drivers/phy/phy-uclass.c|  20 +++-
 include/spl.h   |   4 +-
 scripts/dtc/libfdt/fdt_ro.c |   8 +-
 tools/binman/binman.rst |  98 +++-
 tools/binman/elf.py |  37 ++
 tools/binman/elf_test.py|  31 -
 tools/binman/entries.rst| 124 +++-
 tools/binman/entry.py   |  51 +++-
 tools/binman/etype/fit.py   | 323
++-
 tools/binman/etype/mkimage.py   |  27 +++--
 tools/binman/etype/tee_os.py|  22 
 tools/binman/ftest.py   | 164
+-
 tools/binman/missing-blob-help  |   4 +
 tools/binman/state.py   |   2 +-
 tools/binman/test/221_fit_subentry_hash.dts |  52 +
 tools/binman/test/222_tee_os.dts|  14 +++
 tools/binman/test/223_fit_fdt_oper.dts  |  56 +
 tools/binman/test/224_fit_bad_oper.dts  |  27 +
 tools/binman/test/Makefile  |   6 +-
 tools/binman/test/elf_sections.c|  20 
 tools/binman/test/elf_sections.lds  |  31 +
 tools/dtoc/fdt.py   |  37 ++
 tools/dtoc/fdt_util.py  |  12 ++
 tools/dtoc/test/dtoc_test_simple.dts|   1 +
 tools/dtoc/test_fdt.py  |  43 +++
 tools/moveconfig.py |  39 ++-
 30 files changed, 1140 insertions(+), 152 deletions(-)
 create mode 100644 tools/binman/etype/tee_os.py
 create mode 100644 tools/binman/test/221_fit_subentry_hash.dts
 create mode 100644 tools/binman/test/222_tee_os.dts
 create mode 100644 tools/binman/test/223_fit_fdt_oper.dts
 create mode 100644 tools/binman/test/224_fit_bad_oper.dts
 create mode 100644 tools/binman/test/elf_sections.c
 create mode 100644 tools/binman/test/elf_sections.lds

Regards,
Simon


Re: [PATCH u-boot-mvebu v2 5/5] arm: mvebu: a37xx: Add support for reading Security OTP values

2022-02-22 Thread Pali Rohár
On Thursday 17 February 2022 19:50:46 Pali Rohár wrote:
> It is not possible for the A53 core (on which U-Boot is running) to read it
> directly. For this purpose Marvell defined mbox API for sending OTP
> commands between CM3 and A53 cores.
> 
> Implement these Marvell fuse reading mbox commands via U-Boot fuse API.
> 
> Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 44
> banks and words 0-2).
> 
> Note that of the 67 bits, the 3 upper bits are: 1 lock bit and 2
> auxiliary bits (meant for testing during the manufacture of the SOC, as
> I understand it).
> 
> Also note that the lock bit and the auxiliary bits are not readable
> via Marvell commands.
> 
> With CZ.NIC's commands the lock bit is readable.
> 
> Write support is not implemented yet.
> 
> Signed-off-by: Pali Rohár 
> ---
>  arch/arm/mach-mvebu/armada3700/efuse.c | 38 --
>  1 file changed, 36 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-mvebu/armada3700/efuse.c 
> b/arch/arm/mach-mvebu/armada3700/efuse.c
> index 03778f17ea49..fcf6edd08ce1 100644
> --- a/arch/arm/mach-mvebu/armada3700/efuse.c
> +++ b/arch/arm/mach-mvebu/armada3700/efuse.c
> @@ -8,6 +8,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #define OTP_NB_REG_BASE  ((void __iomem 
> *)MVEBU_REGISTER(0x12600))
> @@ -77,6 +78,40 @@ static void otp_read_parallel(void __iomem *base, u32 
> *data, u32 count)
>   }
>  }
>  
> +static int rwtm_otp_read(u8 row, u32 word, u32 *data)
> +{
> + u32 out[3];
> + u32 in[2];
> + int res = -EINVAL;
> +
> + if (word < 2) {
> + /*
> +  * MBOX_CMD_OTP_READ_32B command is supported by Marvell
> +  * fuse.bin firmware and also by new CZ.NIC wtmi firmware.
> +  * This command returns raw bits without ECC corrections.
> +  * It does not provide access to the lock bit.
> +  */
> + in[0] = row;
> + in[1] = word * 32;
> + res = mbox_do_cmd(MBOX_CMD_OTP_READ_32B, in, 2, out, 2);
> + if (!res)
> + *data = out[0];
> + } else if (word == 2) {
> + /*
> +  * MBOX_CMD_OTP_READ command is supported only by CZ.NIC wtmi
> +  * firmware and provide access to all bits, including lock bit.
> +  * But this command does ECC correction of returned bits. So
> +  * use it only for accessing lock bit.

MBOX_CMD_OTP_READ (like MBOX_CMD_OTP_READ_32B) does not do ECC
correction, I have verified it. So above comment is not correct.

> +  */
> + in[0] = row;
> + res = mbox_do_cmd(MBOX_CMD_OTP_READ, in, 1, out, 3);
> + if (!res)
> + *data = out[2];
> + }
> +
> + return res;
> +}
> +
>  /*
>   * Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 
> 44 banks and words 0-2)
>   * Bank 44 is used for accessing North Bridge OTP (69 bits via words 0-2)
> @@ -96,8 +131,7 @@ int fuse_read(u32 bank, u32 word, u32 *val)
>   if (bank <= RWTM_MAX_BANK) {
>   if (word >= RWTM_ROW_WORDS)
>   return -EINVAL;
> - /* TODO: not implemented yet */
> - return -ENOSYS;
> + return rwtm_otp_read(bank, word, val);
>   } else if (bank == OTP_NB_BANK) {
>   u32 data[OTP_NB_WORDS];
>   if (word >= OTP_NB_WORDS)
> -- 
> 2.20.1
> 


Re: [PATCH u-boot-mvebu 5/5] arm: mvebu: a37xx: Add support for reading Security OTP values

2022-02-22 Thread Pali Rohár
On Thursday 17 February 2022 15:31:10 Marek Behún wrote:
> > +* But this command does not provide access to lock bit.
> > +*/
> > +   if (word < 2) {
> > +   in[0] = row;
> > +   in[1] = word * 32;
> > +   res = mbox_do_cmd(MBOX_CMD_OTP_READ_32B, in, 2, out, 2);
> > +   if (res != -ENOSYS) {
> > +   if (!res)
> > +   *data = out[0];
> > +   return res;
> > +   }
> > +   /* Fallback for old version of CZ.NIC wtmi firmware. */
> > +   }
> 
> I am afraid this is not correct, because Marvell's firmware reads the
> efuse without Error Correction. So it is possible for Marvell's command
> to return different value than CZ.NIC's command.

This is not truth. CZ.NIC firmware for MBOX_CMD_OTP_READ command calls
efuse_read_row_no_ecc which is not doing error correction too.

So both commands return same value, without error correction.


Re: [PATCH v2 4/5] binman: Convert FIT entry type to a subclass of Section entry type

2022-02-22 Thread Alper Nebi Yasak
On 21/02/2022 07:40, Simon Glass wrote:
> On Sat, 19 Feb 2022 at 08:53, Simon Glass  wrote:
>> On Fri, 18 Feb 2022 at 10:34, Alper Nebi Yasak  
>> wrote:
>>> I can reproduce this and tried a few things, but more issues just kept
>>> popping up (outside u-boot as well). I got it to a point where the
>>> command re-packs the FIT and the image but quite wrongly. The offset and
>>> image-pos properties get added in the FIT, and the image main-section
>>> just concatenates all entries without regard to set offsets. I'll
>>> need more time to work those out, then to add tests and send patches.
>>
>> I am going to try to merge my fit generator series today.
>>
>> One issue I notice is that the conversion to use entry_Section changes
>> the contents of the self._fit_entries dict. Before it was keyed by
>> relative path, but entry_section keys self._entries by node name.

Yeah, this causes an error in image.FindEntryPath() while trying to
replace e.g. "/fit@0x28/images/u-boot" since there is no "images"
entry in the FIT. Changing the key to the node name works, but then the
"binman replace" invocation needs to use e.g. "/fit@0x28/u-boot".

>>
>> We may need to split it up. I will see if I can at least merge my
>> series, which should not make things any worse, then see if I can come
>> up with ideas.
>>
>> Thanks for the diff.
> 
> I did a bit more fiddling and pushed a tree to u-boot-dm/fit-working
> 
> It refactors the fit implementation to separate scanning from emitting
> the tree and I think this might help quite a bit. I'll send out the
> series when I get a chance in the next few days or so.

I've also managed to somewhat fix the rest of the issues I wrote, so now
I can replace a FIT entry with a modified one (having a different u-boot
file), or replace a subentry of the FIT with an arbitrary file.

I couldn't look at your new version much but I'll try to see how good my
fixes apply on top of it, will probably take me longer to patchify things.


[PATCH 1/3 v3] arm: init: save previous bootloader data

2022-02-22 Thread Dzmitry Sankouski
When u-boot is used as a chain-loaded bootloader (replacing OS kernel),
previous bootloader leaves data in RAM, that can be reused.

For example, on recent arm linux system, when chainloading u-boot,
there are initramfs and fdt in RAM prepared for OS booting. Initramfs
may be modified to store u-boot's payload, thus providing the ability to
use chainloaded u-boot to boot OS without any storage support.

Two config options added:
- SAVE_PREV_BL_INITRAMFS_START_ADDR
  saves initramfs start address to 'prevbl_initrd_start_addr' environment
  variable
- SAVE_PREV_BL_FDT_ADDR
  saves fdt address to 'prevbl_fdt_addr' environment variable

Signed-off-by: Dzmitry Sankouski 
Cc: Tom Rini 
---
Changes for v2:
- change signed off line
Changes for v3:
- use if (CONFIG_IS_ENABLED... instead of #if defined
- fix save_prev_bl_data.o in Makefile
- add save_prev_bl_data call to env initialization

 arch/arm/lib/Makefile|  5 ++
 arch/arm/lib/save_prev_bl_data.c | 91 
 boot/Kconfig | 79 +--
 common/board_r.c |  5 ++
 include/init.h   | 13 +
 5 files changed, 166 insertions(+), 27 deletions(-)
 create mode 100644 arch/arm/lib/save_prev_bl_data.c

diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index c48e1f622d..f3c31c05e5 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -48,6 +48,11 @@ obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMCPY) += memcpy.o
 endif
 obj-$(CONFIG_SEMIHOSTING) += semihosting.o
 
+ifneq ($(filter y,$(CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR) 
$(CONFIG_SAVE_PREV_BL_FDT_ADDR)),)
+obj-y += save_prev_bl_data.o
+endif
+
+# obj-$(CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR) += save_prev_bl_data.o
 obj-y  += bdinfo.o
 obj-y  += sections.o
 CFLAGS_REMOVE_sections.o := $(LTO_CFLAGS)
diff --git a/arch/arm/lib/save_prev_bl_data.c b/arch/arm/lib/save_prev_bl_data.c
new file mode 100644
index 00..f4ee86a89c
--- /dev/null
+++ b/arch/arm/lib/save_prev_bl_data.c
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * save_prev_bl_data - saving previous bootloader data
+ * to environment variables.
+ *
+ * Copyright (c) 2022 Dzmitry Sankouski (dsankou...@gmail.com)
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static ulong reg0 __section(".data");
+
+/**
+ * Save x0 register value, assuming previous bootloader set it to
+ * point on loaded fdt or (for older linux kernels)atags.
+ */
+void save_boot_params(ulong r0)
+{
+   reg0 = r0;
+   save_boot_params_ret();
+}
+
+bool is_addr_accessible(phys_addr_t addr)
+{
+   struct mm_region *mem = mem_map;
+   phys_addr_t bank_start;
+   phys_addr_t bank_end;
+
+   while (mem->size) {
+   bank_start = mem->phys;
+   bank_end = bank_start + mem->size;
+   debug("check if block %pap - %pap includes %pap\n", 
_start, _end, );
+   if (addr > bank_start && addr < bank_end)
+   return true;
+   mem++;
+   }
+
+   return false;
+}
+
+int save_prev_bl_data(void)
+{
+   struct fdt_header *fdt_blob;
+   int node;
+   u64 initrd_start_prop;
+
+   if (!is_addr_accessible((phys_addr_t)reg0))
+   return -ENODATA;
+
+   fdt_blob = (struct fdt_header *)reg0;
+   if (!fdt_valid(_blob)) {
+   pr_warn("%s: address 0x%lx is not a valid fdt\n", __func__, 
reg0);
+   return -ENODATA;
+   }
+
+   if (CONFIG_IS_ENABLED(SAVE_PREV_BL_FDT_ADDR))
+   env_set_addr("prevbl_fdt_addr", (void *)reg0);
+   if (!CONFIG_IS_ENABLED(SAVE_PREV_BL_INITRAMFS_START_ADDR))
+   return 0;
+
+   node = fdt_path_offset(fdt_blob, "/chosen");
+   if (!node) {
+   pr_warn("%s: chosen node not found in device tree at addr: 
0x%lx\n",
+   __func__, reg0);
+   return -ENODATA;
+   }
+   /*
+* linux,initrd-start property might be either 64 or 32 bit,
+* depending on primary bootloader implementation.
+*/
+   initrd_start_prop = fdtdec_get_uint64(fdt_blob, node, 
"linux,initrd-start", 0);
+   if (!initrd_start_prop) {
+   debug("%s: attempt to get uint64 linux,initrd-start property 
failed, trying uint\n",
+   __func__);
+   initrd_start_prop = fdtdec_get_uint(fdt_blob, node, 
"linux,initrd-start", 0);
+   if (!initrd_start_prop) {
+   debug("%s: attempt to get uint failed, too\n", 
__func__);
+   return -ENODATA;
+   }
+   }
+   env_set_addr("prevbl_initrd_start_addr", (void *)initrd_start_prop);
+
+   return 0;
+}
diff --git a/boot/Kconfig b/boot/Kconfig
index c8d5906cd3..da2f0797e0 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -135,10 +135,10 @@ config FIT_IMAGE_POST_PROCESS
  

[PATCH 2/3 v4] board: starqltechn: get board usable - add bootcmd and docs

2022-02-22 Thread Dzmitry Sankouski
U-boot is intended to replace linux kernel in android boot image(ABL), and
it's FIT payload to replace initramfs file. The boot process is similar to
boot image with linux:
- android bootloader (ABL) unpacks android boot image
- ABL sets `linux,initrd-start property` in chosen node in unpacked FDT
- ABL sets x0 register to FDT address, and passes control to u-boot
- u-boot reads x0 register, and stores it in `prevbl_fdt_addr` env variable
- u-boot reads `linux,initrd-start` property,
and stores it in `prevbl_initrd_start_addr`

In this way, u-boot bootcmd relies on `prevbl_initrd_start_addr` env
variable, and boils down to `bootm $prevbl_initrd_start_addr`.
If more control on boot process is desired, pack a boot script in
FIT image, and put it to default configuration

What done:
- strip unneeded config options
- add FIT image support
- add framebuffer node, u-boot logo and video console
- increase LMB_MAX_REGIONS, to store all linux dtb reserved memory regions
- add linux kernel image header

Uart driver causes hang, when u-boot is used in android boot image instead
of linux. Temporary disable console driver, until investigated and fixed.

Signed-off-by: Dzmitry Sankouski 
Cc: Ramon Fried 
---
Changes for v2:
- change signed off line
- add CONFIG_SAVE_PREV_BL_FDT_ADDR. It's needed to boot
android stock kernel
- change bootcmd to source bootscript from FIT image
for more flexibility
Changes for v3:
- enable simple framebuffer
- enable video console
- add preboot variable
- remove 0x prefix in name in device tree
Changes for v4:
- fix uart driver pinmux
- remove serial from stdout and stderr env
- disable serial driver, because it's crashes autoboot

 arch/arm/dts/sdm845.dtsi|  6 ++--
 arch/arm/dts/starqltechn-uboot.dtsi |  9 --
 arch/arm/dts/starqltechn.dts| 13 ++--
 configs/starqltechn_defconfig   | 21 ++---
 doc/board/qualcomm/sdm845.rst   | 47 -
 include/configs/sdm845.h|  8 +
 6 files changed, 90 insertions(+), 14 deletions(-)

diff --git a/arch/arm/dts/sdm845.dtsi b/arch/arm/dts/sdm845.dtsi
index 1185b71216..6f2fb20d68 100644
--- a/arch/arm/dts/sdm845.dtsi
+++ b/arch/arm/dts/sdm845.dtsi
@@ -48,10 +48,8 @@
 
/* DEBUG UART */
qup_uart9: qup-uart9-default {
-   pinmux {
-   pins = "GPIO_4", "GPIO_5";
-   function = "qup9";
-   };
+   pins = "GPIO_4", "GPIO_5";
+   function = "gpio";
};
};
 
diff --git a/arch/arm/dts/starqltechn-uboot.dtsi 
b/arch/arm/dts/starqltechn-uboot.dtsi
index d8d75e018a..b55cccfe14 100644
--- a/arch/arm/dts/starqltechn-uboot.dtsi
+++ b/arch/arm/dts/starqltechn-uboot.dtsi
@@ -8,15 +8,18 @@
 
 /
 {
+   framebuffer@9D40 {
+   u-boot,dm-pre-reloc;
+   };
soc {
u-boot,dm-pre-reloc;
+   serial@a84000 {
+   u-boot,dm-pre-reloc;
+   };
gcc {
clock-controller@10 {
u-boot,dm-pre-reloc;
};
-   serial@0xa84000 {
-   u-boot,dm-pre-reloc;
-   };
gpio_north@390 {
u-boot,dm-pre-reloc;
};
diff --git a/arch/arm/dts/starqltechn.dts b/arch/arm/dts/starqltechn.dts
index 387420f30b..0261388319 100644
--- a/arch/arm/dts/starqltechn.dts
+++ b/arch/arm/dts/starqltechn.dts
@@ -34,9 +34,18 @@
method = "smc";
};
 
+   framebuffer: framebuffer@9D40 {
+   compatible = "simple-framebuffer";
+   reg = <0 0x9D40 0 (2960 * 1440 * 4)>;//240
+   width = <1440>;
+   height = <2960>;
+   stride = <(1440 * 4)>;
+   format = "a8r8g8b8";
+   };
+
soc: soc {
-   serial@0xa84000 {
-   status = "ok";
+   serial@a84000 {
+   status = "okay";
};
 
pinctrl@390 {
diff --git a/configs/starqltechn_defconfig b/configs/starqltechn_defconfig
index f57bb859cc..75e8409c4d 100644
--- a/configs/starqltechn_defconfig
+++ b/configs/starqltechn_defconfig
@@ -2,16 +2,18 @@ CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_POSITION_INDEPENDENT=y
 CONFIG_ARCH_SNAPDRAGON=y
-CONFIG_SYS_TEXT_BASE=0x8000
-CONFIG_SYS_MALLOC_LEN=0x81f000
 CONFIG_DEFAULT_DEVICE_TREE="starqltechn"
+CONFIG_BOOTDELAY=0
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
 CONFIG_TARGET_STARQLTECHN=y
 CONFIG_IDENT_STRING="\nSamsung S9 SM-G9600"
 CONFIG_SYS_LOAD_ADDR=0x8000
-CONFIG_USE_PREBOOT=y
+CONFIG_LMB_MAX_REGIONS=64
 # CONFIG_DISPLAY_CPUINFO is not set
 

[PATCH 3/3 v2] board: axy17lte: get board usable - add bootcmd and docs

2022-02-22 Thread Dzmitry Sankouski
U-boot is intended to replace linux kernel in android boot image(ABL), and
it's FIT payload to replace initramfs file. The boot process is similar to
boot image with linux:
- android bootloader (ABL) unpacks android boot image
- ABL sets `linux,initrd-start property` in chosen node in unpacked FDT
- ABL sets x0 register to FDT address, and passes control to u-boot
- u-boot reads x0 register, and stores it in `prevbl_fdt_addr` env variable
- u-boot reads `linux,initrd-start` property,
and stores it in `prevbl_initrd_start_addr`

In this way, u-boot bootcmd relies on `prevbl_initrd_start_addr` env
variable, and boils down to `bootm $prevbl_initrd_start_addr`.
If more control on boot process is desired, pack a boot script in
FIT image, and put it to default configuration

What done:
- Rearrange defconfig option order
- Add CONFIG_SAVE_PREV_BL_* options
- Doc updates:
  - remove wrong SBOOT memory corruption note, because
  memory is changed during u-boot bringup process,
  not by SBOOT
  - put payload on ramdisk place in abl boot image
  creation step

Signed-off-by: Dzmitry Sankouski 
---
Changes for v2:
- increase CONFIG_LMB_MAX_REGIONS and CONFIG_SYS_BOOTM_LEN
- change signed off line
- add CONFIG_SAVE_PREV_BL_FDT_ADDR. It's needed to boot
android
- change bootcmd to source bootscript from FIT image
for more flexibility

 configs/a3y17lte_defconfig  | 12 +++-
 configs/a5y17lte_defconfig  | 13 -
 configs/a7y17lte_defconfig  | 13 -
 doc/board/samsung/axy17lte.rst  | 15 +++
 include/configs/exynos78x0-common.h |  4 
 5 files changed, 30 insertions(+), 27 deletions(-)

diff --git a/configs/a3y17lte_defconfig b/configs/a3y17lte_defconfig
index ddc1801a59..e120263ec6 100644
--- a/configs/a3y17lte_defconfig
+++ b/configs/a3y17lte_defconfig
@@ -1,13 +1,13 @@
 CONFIG_ARM=y
-CONFIG_SYS_CONFIG_NAME="exynos78x0-common"
-CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_ARCH_EXYNOS=y
-CONFIG_SYS_TEXT_BASE=0x40001000
 CONFIG_ARCH_EXYNOS7=y
 CONFIG_TARGET_A3Y17LTE=y
+CONFIG_SYS_CONFIG_NAME="exynos78x0-common"
+CONFIG_SYS_TEXT_BASE=0x40001000
+CONFIG_SYS_LOAD_ADDR=0x40001000
+CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_NR_DRAM_BANKS=8
 CONFIG_DEFAULT_DEVICE_TREE="exynos78x0-axy17lte"
-CONFIG_SYS_LOAD_ADDR=0x40001000
 CONFIG_FIT=y
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="echo Read pressed buttons 
status;KEY_VOLUMEUP=gpa20;KEY_HOME=gpa17;KEY_VOLUMEDOWN=gpa21;KEY_POWER=gpa00;PRESSED=0;RELEASED=1;if
 gpio input $KEY_VOLUMEUP; then setenv VOLUME_UP $PRESSED; else setenv 
VOLUME_UP $RELEASED; fi;if gpio input $KEY_VOLUMEDOWN; then setenv VOLUME_DOWN 
$PRESSED; else setenv VOLUME_DOWN $RELEASED; fi;if gpio input $KEY_HOME; then 
setenv HOME $PRESSED; else setenv HOME $RELEASED; fi;if gpio input $KEY_POWER; 
then setenv POWER $PRESSED; else setenv POWER $RELEASED; fi;"
@@ -16,4 +16,6 @@ CONFIG_HUSH_PARSER=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_DM_I2C_GPIO=y
-CONFIG_PINCTRL_EXYNOS78x0=y
+CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR=y
+CONFIG_SAVE_PREV_BL_FDT_ADDR=y
+CONFIG_LMB_MAX_REGIONS=64
diff --git a/configs/a5y17lte_defconfig b/configs/a5y17lte_defconfig
index 2534ab0573..95fee179fd 100644
--- a/configs/a5y17lte_defconfig
+++ b/configs/a5y17lte_defconfig
@@ -1,18 +1,21 @@
 CONFIG_ARM=y
-CONFIG_SYS_CONFIG_NAME="exynos78x0-common"
-CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_ARCH_EXYNOS=y
-CONFIG_SYS_TEXT_BASE=0x40001000
 CONFIG_ARCH_EXYNOS7=y
 CONFIG_TARGET_A5Y17LTE=y
+CONFIG_SYS_CONFIG_NAME="exynos78x0-common"
+CONFIG_SYS_TEXT_BASE=0x40001000
+CONFIG_SYS_LOAD_ADDR=0x40001000
+CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_NR_DRAM_BANKS=12
 CONFIG_DEFAULT_DEVICE_TREE="exynos78x0-axy17lte"
-CONFIG_SYS_LOAD_ADDR=0x40001000
+CONFIG_HUSH_PARSER=y
 CONFIG_FIT=y
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="echo Read pressed buttons 
status;KEY_VOLUMEUP=gpa20;KEY_HOME=gpa17;KEY_VOLUMEDOWN=gpa21;KEY_POWER=gpa00;PRESSED=0;RELEASED=1;if
 gpio input $KEY_VOLUMEUP; then setenv VOLUME_UP $PRESSED; else setenv 
VOLUME_UP $RELEASED; fi;if gpio input $KEY_VOLUMEDOWN; then setenv VOLUME_DOWN 
$PRESSED; else setenv VOLUME_DOWN $RELEASED; fi;if gpio input $KEY_HOME; then 
setenv HOME $PRESSED; else setenv HOME $RELEASED; fi;if gpio input $KEY_POWER; 
then setenv POWER $PRESSED; else setenv POWER $RELEASED; fi;"
 # CONFIG_DISPLAY_CPUINFO is not set
-CONFIG_HUSH_PARSER=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_DM_I2C_GPIO=y
+CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR=y
+CONFIG_SAVE_PREV_BL_FDT_ADDR=y
+CONFIG_LMB_MAX_REGIONS=64
diff --git a/configs/a7y17lte_defconfig b/configs/a7y17lte_defconfig
index a2d76377ab..5564ab51a2 100644
--- a/configs/a7y17lte_defconfig
+++ b/configs/a7y17lte_defconfig
@@ -1,18 +1,21 @@
 CONFIG_ARM=y
-CONFIG_SYS_CONFIG_NAME="exynos78x0-common"
-CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_ARCH_EXYNOS=y
-CONFIG_SYS_TEXT_BASE=0x40001000
 CONFIG_ARCH_EXYNOS7=y
 CONFIG_TARGET_A7Y17LTE=y
+CONFIG_SYS_CONFIG_NAME="exynos78x0-common"
+CONFIG_SYS_TEXT_BASE=0x40001000
+CONFIG_SYS_LOAD_ADDR=0x40001000

[PATCH 0/3] save prev bootloader data, when u-boot chainloaded

2022-02-22 Thread Dzmitry Sankouski
When u-boot is used as a chain-loaded bootloader (replacing OS kernel),
previous bootloader leaves data in RAM, that can be reused.

For example, on recent arm linux system, when chainloading u-boot,
there are initramfs and fdt in RAM prepared for OS booting. Initramfs
may be modified to store u-boot's payload, thus providing the ability to
use chainloaded u-boot to boot OS without any storage support.

Two config options added:
- SAVE_PREV_BL_INITRAMFS_START_ADDR
  saves initramfs start address to 'prevbl_initrd_start_addr' environment
  variable
- SAVE_PREV_BL_FDT_ADDR
  saves fdt address to 'prevbl_fdt_addr' environment variable

This feature will be used for axy17lte and starqltechn boards for now,
and more phones in future.

Dzmitry Sankouski (3):
  arm: init: save previous bootloader data
  board: starqltechn: get board usable - add bootcmd and docs
  board: axy17lte: get board usable - add bootcmd and docs

 arch/arm/dts/starqltechn-uboot.dtsi |  9 ++-
 arch/arm/dts/starqltechn.dts| 13 -
 arch/arm/lib/Makefile   |  5 ++
 arch/arm/lib/save_prev_bl_data.c| 91 +
 boot/Kconfig| 79 -
 common/board_r.c|  5 ++
 configs/a3y17lte_defconfig  | 12 ++--
 configs/a5y17lte_defconfig  | 13 +++--
 configs/a7y17lte_defconfig  | 13 +++--
 configs/starqltechn_defconfig   | 18 +-
 doc/board/qualcomm/sdm845.rst   | 47 ++-
 doc/board/samsung/axy17lte.rst  | 15 +
 include/configs/exynos78x0-common.h |  4 ++
 include/configs/sdm845.h|  8 +++
 include/init.h  | 13 +
 15 files changed, 282 insertions(+), 63 deletions(-)
 create mode 100644 arch/arm/lib/save_prev_bl_data.c

-- 
2.20.1



[PATCH 2/2] arm: layerscape: Disable erratum A009007 on LS1021A, LS1043A, and LS1046A

2022-02-22 Thread Sean Anderson
This erratum is reported to cause problems on these processors [1-3].
The problem is usually with the clocking, which is supposed to be
configured by the RCW [4]. However, if it is not set, or if the default
clocking is not correct, then this erratum will cause an SError.
However, according to Ran Wang in [1]:

> ... this erratum is used to pass USB compliance test only, you could
> disable this workaround on your board if you don't any USB issue on
> normal use case, I think it's fine.

So just disable this erratum by default for these processors.

[1] https://lore.kernel.org/all/761ddd61-05c1-d9b8-ac90-b8f425afd...@denx.de/
[2] 
https://community.nxp.com/t5/Layerscape/LS1046A-U-BOOT-HALT-AT-ERRATUM-A0090078/m-p/742993
[3] 
https://community.nxp.com/t5/QorIQ/Why-does-the-LS1043A-U-Boot-hang-at-code-that-fixes-erratum/m-p/644412
[4] 
https://source.codeaurora.org/external/qoriq/qoriq-components/rcw/tree/ls1046ardb/usb_phy_freq.rcw

Signed-off-by: Sean Anderson 
---

 arch/arm/cpu/armv7/ls102xa/Kconfig| 1 -
 arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 2 --
 2 files changed, 3 deletions(-)

diff --git a/arch/arm/cpu/armv7/ls102xa/Kconfig 
b/arch/arm/cpu/armv7/ls102xa/Kconfig
index 6a948d7ba7..cec93a27db 100644
--- a/arch/arm/cpu/armv7/ls102xa/Kconfig
+++ b/arch/arm/cpu/armv7/ls102xa/Kconfig
@@ -7,7 +7,6 @@ config ARCH_LS1021A
select SYS_FSL_ERRATUM_A008407
select SYS_FSL_ERRATUM_A008850
select SYS_FSL_ERRATUM_A008997 if USB
-   select SYS_FSL_ERRATUM_A009007 if USB
select SYS_FSL_ERRATUM_A009008 if USB
select SYS_FSL_ERRATUM_A009663
select SYS_FSL_ERRATUM_A009798 if USB
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig 
b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
index 9bb870dcd8..f5a18053e6 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
+++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
@@ -74,7 +74,6 @@ config ARCH_LS1043A
select SYS_FSL_DDR_VER_50
select SYS_FSL_ERRATUM_A008850 if !TFABOOT
select SYS_FSL_ERRATUM_A008997
-   select SYS_FSL_ERRATUM_A009007
select SYS_FSL_ERRATUM_A009008
select SYS_FSL_ERRATUM_A009660 if !TFABOOT
select SYS_FSL_ERRATUM_A009663 if !TFABOOT
@@ -112,7 +111,6 @@ config ARCH_LS1046A
select SYS_FSL_ERRATUM_A008511 if !TFABOOT
select SYS_FSL_ERRATUM_A008850 if !TFABOOT
select SYS_FSL_ERRATUM_A008997
-   select SYS_FSL_ERRATUM_A009007
select SYS_FSL_ERRATUM_A009008
select SYS_FSL_ERRATUM_A009798
select SYS_FSL_ERRATUM_A009801
-- 
2.25.1



[PATCH 1/2] armv8: fsl-layerscape: Respect Kconfig for erratum A009007

2022-02-22 Thread Sean Anderson
There is a Kconfig for this erratum, but it is ignored for armv8.
Respect it.

Signed-off-by: Sean Anderson 
---

 arch/arm/cpu/armv8/fsl-layerscape/soc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c 
b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index d3a5cfaac1..926f8f21b6 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -206,6 +206,9 @@ static void erratum_a008997(void)
 
 static void erratum_a009007(void)
 {
+   if (!IS_ENABLED(CONFIG_SYS_FSL_ERRATUM_A009007))
+   return;
+
 #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
defined(CONFIG_ARCH_LS1012A)
void __iomem *usb_phy = (void __iomem *)SCFG_USB_PHY1;
-- 
2.25.1



Re: [PATCH v2] ARM: imx: imx8mn-*-evk: use DM settings for PHY configuration

2022-02-22 Thread Marek Vasut

On 2/22/22 17:00, Michael Walle wrote:

Am 2022-02-22 16:19, schrieb Heiko Thiery:

With the correct settings described in the device-tree the PHY settings
in the board init are no longer required. The values are taken from the
linux device tree.

Suggested-by: Michael Walle 
Signed-off-by: Heiko Thiery 
---
v2:
 - remove phy-reset-gpios node (thanks to Michael)
    When using DM_ETH_PHY the reset-gpios from the phy is used

 arch/arm/dts/imx8mn-evk.dtsi    | 10 +-
 board/freescale/imx8mn_evk/imx8mn_evk.c | 16 
 2 files changed, 9 insertions(+), 17 deletions(-)


It seems someone was faster with this patch after all, thanks.


diff --git a/arch/arm/dts/imx8mn-evk.dtsi b/arch/arm/dts/imx8mn-evk.dtsi
index 416fadb22b..fd253f0042 100644
--- a/arch/arm/dts/imx8mn-evk.dtsi
+++ b/arch/arm/dts/imx8mn-evk.dtsi
@@ -53,7 +53,6 @@
 pinctrl-0 = <_fec1>;
 phy-mode = "rgmii-id";
 phy-handle = <>;
-    phy-reset-gpios = < 22 GPIO_ACTIVE_LOW>;


This ...


I'm afraid the phy reset in the phy node won't really end up toggling 
the PHY reset GPIO, would it ?


[...]


[PATCH 1/2] Split CONFIG_CC_OPTIMIZE_FOR_SIZE into two configs

2022-02-22 Thread Sean Anderson
This adds a separate CONFIG_CC_OPTIMIZE_FOR_SPEED option in a choice,
in preparation for adding another optimization option. Also convert SH's
makefile to use this new option.

Signed-off-by: Sean Anderson 
---

 Kconfig  | 17 ++---
 Makefile |  4 +++-
 arch/sh/lib/Makefile |  2 +-
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/Kconfig b/Kconfig
index 9dd9ec7f6d..8159c596c0 100644
--- a/Kconfig
+++ b/Kconfig
@@ -72,15 +72,26 @@ config CLANG_VERSION
int
default $(shell,$(srctree)/scripts/clang-version.sh $(CC))
 
+choice
+   prompt "Optimization level"
+   default CC_OPTIMIZE_FOR_SIZE
+
 config CC_OPTIMIZE_FOR_SIZE
bool "Optimize for size"
-   default y
help
- Enabling this option will pass "-Os" instead of "-O2" to gcc
- resulting in a smaller U-Boot image.
+ Enabling this option will pass "-Os" to gcc, resulting in a smaller
+ U-Boot image.
 
  This option is enabled by default for U-Boot.
 
+config CC_OPTIMIZE_FOR_SPEED
+   bool "Optimize for speed"
+   help
+ Enabling this option will pass "-O2" to gcc, resulting in a faster
+ U-Boot image.
+
+endchoice
+
 config OPTIMIZE_INLINING
bool "Allow compiler to uninline functions marked 'inline' in full 
U-Boot"
help
diff --git a/Makefile b/Makefile
index 4b152249ca..1d3331c69f 100644
--- a/Makefile
+++ b/Makefile
@@ -682,7 +682,9 @@ endif
 
 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 KBUILD_CFLAGS  += -Os
-else
+endif
+
+ifdef CONFIG_CC_OPTIMIZE_FOR_SPEED
 KBUILD_CFLAGS  += -O2
 endif
 
diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile
index 9618da1cb3..e7520a328d 100644
--- a/arch/sh/lib/Makefile
+++ b/arch/sh/lib/Makefile
@@ -12,7 +12,7 @@ obj-$(CONFIG_CMD_SH_ZIMAGEBOOT) += zimageboot.o
 
 udivsi3-y  := udivsi3_i4i-Os.o
 
-ifneq ($(CONFIG_CC_OPTIMIZE_FOR_SIZE),y)
+ifeq ($(CONFIG_CC_OPTIMIZE_FOR_SPEED),y)
 udivsi3-$(CONFIG_CPU_SH4)  := udivsi3_i4i.o
 endif
 udivsi3-y  += udivsi3.o
-- 
2.25.1



[PATCH 2/2] Add option to use -Og

2022-02-22 Thread Sean Anderson
This adds support for using -Og when building U-Boot. According to the
gcc man page:

> -Og should be the optimization level of choice for the standard
> edit-compile-debug cycle, offering a reasonable level of optimization
> while maintaining fast compilation and a good debugging experience.

This optimization level is roughly -O1 minus a few additional
optimizations. It provides a noticably better debugging experience, with
many fewer variables .

Signed-off-by: Sean Anderson 
---

 Kconfig  | 6 ++
 Makefile | 4 
 2 files changed, 10 insertions(+)

diff --git a/Kconfig b/Kconfig
index 8159c596c0..112745440b 100644
--- a/Kconfig
+++ b/Kconfig
@@ -90,6 +90,12 @@ config CC_OPTIMIZE_FOR_SPEED
  Enabling this option will pass "-O2" to gcc, resulting in a faster
  U-Boot image.
 
+config CC_OPTIMIZE_FOR_DEBUG
+   bool "Optimize for debugging"
+   help
+ Enabling this option will pass "-Og" to gcc, enabling optimizations
+ which don't interfere with debugging.
+
 endchoice
 
 config OPTIMIZE_INLINING
diff --git a/Makefile b/Makefile
index 1d3331c69f..7242eafc1e 100644
--- a/Makefile
+++ b/Makefile
@@ -688,6 +688,10 @@ ifdef CONFIG_CC_OPTIMIZE_FOR_SPEED
 KBUILD_CFLAGS  += -O2
 endif
 
+ifdef CONFIG_CC_OPTIMIZE_FOR_DEBUG
+KBUILD_CFLAGS  += -Og
+endif
+
 LTO_CFLAGS :=
 LTO_FINAL_LDFLAGS :=
 export LTO_CFLAGS LTO_FINAL_LDFLAGS
-- 
2.25.1



[PATCH] mtd: rawnand: stm32_fmc2: add NAND Write Protect support

2022-02-22 Thread Christophe Kerello
This patch adds the support of the WP# signal. WP will be disabled
before the first access to the NAND flash.

Signed-off-by: Christophe Kerello 
---

 drivers/mtd/nand/raw/stm32_fmc2_nand.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c 
b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
index eee65949d77..fb3279b405e 100644
--- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c
+++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -149,6 +150,7 @@ struct stm32_fmc2_timings {
 struct stm32_fmc2_nand {
struct nand_chip chip;
struct stm32_fmc2_timings timings;
+   struct gpio_desc wp_gpio;
int ncs;
int cs_used[FMC2_MAX_CE];
 };
@@ -824,6 +826,9 @@ static int stm32_fmc2_nfc_parse_child(struct stm32_fmc2_nfc 
*nfc, ofnode node)
nand->cs_used[i] = cs[i];
}
 
+   gpio_request_by_name_nodev(node, "wp-gpios", 0, >wp_gpio,
+  GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
+
nand->chip.flash_node = node;
 
return 0;
@@ -972,6 +977,10 @@ static int stm32_fmc2_nfc_probe(struct udevice *dev)
chip->ecc.size = FMC2_ECC_STEP_SIZE;
chip->ecc.strength = FMC2_ECC_BCH8;
 
+   /* Disable Write Protect */
+   if (dm_gpio_is_valid(>wp_gpio))
+   dm_gpio_set_value(>wp_gpio, 0);
+
ret = nand_scan_ident(mtd, nand->ncs, NULL);
if (ret)
return ret;
-- 
2.25.1



[PATCH] spi: cadence-qspi: Make reset control optinal

2022-02-22 Thread Christian Gmeiner
In the TI am65 device tree files there is no reset defined. Also
the Linux kernel driver uses devm_reset_control_get_optional_exclusive(..)
to get the reset.

Lets do the same as the kernel does and make thr reset optinal.

Signed-off-by: Christian Gmeiner 
---
 drivers/spi/cadence_qspi.c | 14 --
 drivers/spi/cadence_qspi.h |  2 +-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c
index d1b3808c4d..db680618ee 100644
--- a/drivers/spi/cadence_qspi.c
+++ b/drivers/spi/cadence_qspi.c
@@ -201,11 +201,9 @@ static int cadence_spi_probe(struct udevice *bus)
}
}
 
-   ret = reset_get_bulk(bus, >resets);
-   if (ret)
-   dev_warn(bus, "Can't get reset: %d\n", ret);
-   else
-   reset_deassert_bulk(>resets);
+   priv->resets = devm_reset_bulk_get_optional(bus);
+   if (priv->resets)
+   reset_deassert_bulk(priv->resets);
 
if (!priv->qspi_is_init) {
cadence_qspi_apb_controller_init(plat);
@@ -220,8 +218,12 @@ static int cadence_spi_probe(struct udevice *bus)
 static int cadence_spi_remove(struct udevice *dev)
 {
struct cadence_spi_priv *priv = dev_get_priv(dev);
+   int ret = 0;
+
+   if (priv->resets)
+   ret = reset_release_bulk(priv->resets);
 
-   return reset_release_bulk(>resets);
+   return ret;
 }
 
 static int cadence_spi_set_mode(struct udevice *bus, uint mode)
diff --git a/drivers/spi/cadence_qspi.h b/drivers/spi/cadence_qspi.h
index 49b401168f..19345cac5a 100644
--- a/drivers/spi/cadence_qspi.h
+++ b/drivers/spi/cadence_qspi.h
@@ -56,7 +56,7 @@ struct cadence_spi_priv {
unsigned intqspi_calibrated_cs;
unsigned intprevious_hz;
 
-   struct reset_ctl_bulk resets;
+   struct reset_ctl_bulk *resets;
 };
 
 /* Functions call declaration */
-- 
2.35.1



[RFC PATCH v2 4/4] efi_loader: add menu-driven UEFI Boot Variable maintenance

2022-02-22 Thread Masahisa Kojima
This commit adds the menu-driven UEFI Boot Variable maintenance.
User can add and delete the Boot variable, and update the
BootOrder variable through menu operation.

Signed-off-by: Masahisa Kojima 
---
 include/efi_loader.h  |  27 ++
 lib/efi_loader/efi_bootmgr.c  | 687 ++
 lib/efi_loader/efi_boottime.c |  55 +--
 lib/efi_loader/efi_console.c  |  81 
 lib/efi_loader/efi_file.c |  74 ++--
 5 files changed, 876 insertions(+), 48 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index e390d323a9..0623e0a707 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -278,6 +278,7 @@ extern const efi_guid_t efi_guid_loaded_image;
 extern const efi_guid_t efi_guid_loaded_image_device_path;
 extern const efi_guid_t efi_guid_device_path_to_text_protocol;
 extern const efi_guid_t efi_simple_file_system_protocol_guid;
+extern const efi_guid_t efi_system_partition_guid;
 extern const efi_guid_t efi_file_info_guid;
 /* GUID for file system information */
 extern const efi_guid_t efi_file_system_info_guid;
@@ -310,6 +311,9 @@ extern const efi_guid_t 
efi_guid_firmware_management_protocol;
 extern const efi_guid_t efi_esrt_guid;
 /* GUID of the SMBIOS table */
 extern const efi_guid_t smbios_guid;
+/*GUID of console */
+extern const efi_guid_t efi_guid_text_input_protocol;
+extern const efi_guid_t efi_guid_text_output_protocol;
 
 extern char __efi_runtime_start[], __efi_runtime_stop[];
 extern char __efi_runtime_rel_start[], __efi_runtime_rel_stop[];
@@ -998,4 +1002,27 @@ efi_status_t efi_esrt_populate(void);
 efi_status_t efi_load_capsule_drivers(void);
 
 efi_status_t platform_get_eventlog(struct udevice *dev, u64 *addr, u32 *sz);
+
+efi_status_t efi_locate_handle_buffer_int(enum efi_locate_search_type 
search_type,
+ const efi_guid_t *protocol, void 
*search_key,
+ efi_uintn_t *no_handles, efi_handle_t 
**buffer);
+
+efi_status_t efi_open_volume_int(struct efi_simple_file_system_protocol *this,
+struct efi_file_handle **root);
+efi_status_t efi_file_open_int(struct efi_file_handle *this,
+  struct efi_file_handle **new_handle,
+  u16 *file_name, u64 open_mode,
+  u64 attributes);
+efi_status_t efi_file_close_int(struct efi_file_handle *file);
+efi_status_t efi_file_read_int(struct efi_file_handle *this,
+  efi_uintn_t *buffer_size, void *buffer);
+efi_status_t efi_file_setpos_int(struct efi_file_handle *file, u64 pos);
+
+typedef efi_status_t (*efi_console_filter_func)(struct efi_input_key *key);
+efi_status_t efi_console_get_u16_string
+   (struct efi_simple_text_input_protocol *cin,
+struct efi_simple_text_output_protocol *cout,
+u16 *buf, efi_uintn_t count, efi_console_filter_func 
filer_func,
+int row, int col);
+
 #endif /* _EFI_LOADER_H */
diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
index bbb3fac5bd..b7d1fa6f4b 100644
--- a/lib/efi_loader/efi_bootmgr.c
+++ b/lib/efi_loader/efi_bootmgr.c
@@ -20,6 +20,9 @@
 static const struct efi_boot_services *bs;
 static const struct efi_runtime_services *rs;
 
+static struct efi_simple_text_input_protocol *cin;
+static struct efi_simple_text_output_protocol *cout;
+
 /*
  * bootmgr implements the logic of trying to find a payload to boot
  * based on the BootOrder + Boot variables, and then loading it.
@@ -30,6 +33,9 @@ static const struct efi_runtime_services *rs;
  */
 
 #define EFI_BOOTMGR_MENU_ENTRY_NUM_MAX 1024
+#define EFI_BOOTMGR_FILE_PATH_MAX 512
+#define EFI_BOOTMGR_BOOT_NAME_MAX 32
+#define EFI_BOOT_ORDER_MAX_SIZE_IN_DECIMAL 6
 
 typedef efi_status_t (*efi_bootmenu_entry_func)(void *data, bool *exit);
 
@@ -83,12 +89,49 @@ struct efi_bootmgr_boot_selection_data {
 
 static efi_status_t efi_bootmgr_process_boot_selected(void *data, bool *exit);
 static efi_status_t efi_bootmgr_process_boot_selection(void *data, bool *exit);
+static efi_status_t efi_bootmgr_process_maintenance(void *data, bool *exit);
+static efi_status_t efi_bootmgr_process_add_boot_option(void *data, bool 
*exit);
+static efi_status_t efi_bootmgr_process_delete_boot_option(void *data, bool 
*exit);
+static efi_status_t efi_bootmgr_process_change_boot_order(void *data, bool 
*exit);
 
 static struct efi_bootmgr_menu_item bootmgr_menu_items[] = {
{u"Boot Manager", efi_bootmgr_process_boot_selection},
+   {u"Boot Manager maintenance", efi_bootmgr_process_maintenance},
{u"Quit", NULL},
 };
 
+static struct efi_bootmgr_menu_item maintenance_menu_items[] = {
+   {u"Add Boot Option", efi_bootmgr_process_add_boot_option},
+   {u"Delete Boot Option", efi_bootmgr_process_delete_boot_option},
+   {u"Change Boot Order", efi_bootmgr_process_change_boot_order},
+   {u"Quit", NULL},
+};
+

[RFC PATCH v2 3/4] test: unit test for u16_strlcat()

2022-02-22 Thread Masahisa Kojima
Provide a unit test for function u16_strlcat().

Signed-off-by: Masahisa Kojima 
---
 test/unicode_ut.c | 45 +
 1 file changed, 45 insertions(+)

diff --git a/test/unicode_ut.c b/test/unicode_ut.c
index f2f63d5367..f79b0439bc 100644
--- a/test/unicode_ut.c
+++ b/test/unicode_ut.c
@@ -758,6 +758,51 @@ static int unicode_test_efi_create_indexed_name(struct 
unit_test_state *uts)
 UNICODE_TEST(unicode_test_efi_create_indexed_name);
 #endif
 
+static int unicode_test_u16_strlcat(struct unit_test_state *uts)
+{
+   u16 buf[11];
+   u16 dest[] = u"U-Boot";
+   u16 src[] = u"test";
+   u16 expected[] = u"U-Boottest";
+   u16 null_src = u'\0';
+   size_t ret;
+
+   memcpy(buf, dest, sizeof(dest));
+   ret = u16_strlcat(buf, src, sizeof(buf));
+   ut_asserteq(20, ret);
+   ut_assert(!unicode_test_u16_strcmp(buf, expected, 11));
+
+   /* dest is empty string */
+   memset(buf, 0, sizeof(buf));
+   ret = u16_strlcat(buf, src, sizeof(buf));
+   ut_asserteq(8, ret);
+   ut_assert(!unicode_test_u16_strcmp(buf, src, 11));
+
+   /* src is empty string */
+   memset(buf, 0, sizeof(buf));
+   memcpy(buf, dest, sizeof(dest));
+   ret = u16_strlcat(buf, _src, sizeof(buf));
+   ut_asserteq(12, ret);
+   ut_assert(!unicode_test_u16_strcmp(buf, dest, 11));
+
+   /* size is smaller than dest size */
+   memset(buf, 0, sizeof(buf));
+   memcpy(buf, dest, sizeof(dest));
+   ret = u16_strlcat(buf, src, 6);
+   ut_asserteq(14, ret);
+   ut_assert(!unicode_test_u16_strcmp(buf, dest, 11));
+
+   /* size is insufficient to append src string */
+   memset(buf, 0, sizeof(buf));
+   memcpy(buf, dest, sizeof(dest));
+   ret = u16_strlcat(buf, src, 20);
+   ut_asserteq(20, ret);
+   ut_assert(!unicode_test_u16_strcmp(buf, u"U-Boottes", 11));
+
+   return 0;
+}
+UNICODE_TEST(unicode_test_u16_strlcat);
+
 int do_ut_unicode(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(unicode_test);
-- 
2.17.1



[RFC PATCH v2 1/4] efi_loader: add menu-driven boot device selection

2022-02-22 Thread Masahisa Kojima
This patch enables the menu-driven boot device selection.
User can select the Boot included in BootOrder variable.

If user quits thie menu, or the selected Boot fails to boot,
efi bootmgr continues to boot in accordance with BootOrder variable.

This commit also moves the user input handling from cmd/bootmenu.c
to common/menu.c to reuse it from efi boot menu.

Signed-off-by: Masahisa Kojima 
---
 cmd/bootmenu.c   | 145 
 common/menu.c| 137 
 include/menu.h   |  20 ++
 lib/efi_loader/Kconfig   |  20 ++
 lib/efi_loader/efi_bootmgr.c | 418 ++-
 5 files changed, 592 insertions(+), 148 deletions(-)

diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
index 409ef9a848..f9fdebc450 100644
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -33,21 +33,6 @@ struct bootmenu_entry {
struct bootmenu_entry *next;/* next menu entry (num+1) */
 };
 
-struct bootmenu_data {
-   int delay;  /* delay for autoboot */
-   int active; /* active menu entry */
-   int count;  /* total count of menu entries */
-   struct bootmenu_entry *first;   /* first menu entry */
-};
-
-enum bootmenu_key {
-   KEY_NONE = 0,
-   KEY_UP,
-   KEY_DOWN,
-   KEY_SELECT,
-   KEY_QUIT,
-};
-
 static char *bootmenu_getoption(unsigned short int n)
 {
char name[MAX_ENV_SIZE];
@@ -81,136 +66,6 @@ static void bootmenu_print_entry(void *data)
puts(ANSI_COLOR_RESET);
 }
 
-static void bootmenu_autoboot_loop(struct bootmenu_data *menu,
-   enum bootmenu_key *key, int *esc)
-{
-   int i, c;
-
-   if (menu->delay > 0) {
-   printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
-   printf("  Hit any key to stop autoboot: %2d ", menu->delay);
-   }
-
-   while (menu->delay > 0) {
-   for (i = 0; i < 100; ++i) {
-   if (!tstc()) {
-   WATCHDOG_RESET();
-   mdelay(10);
-   continue;
-   }
-
-   menu->delay = -1;
-   c = getchar();
-
-   switch (c) {
-   case '\e':
-   *esc = 1;
-   *key = KEY_NONE;
-   break;
-   case '\r':
-   *key = KEY_SELECT;
-   break;
-   case 0x3: /* ^C */
-   *key = KEY_QUIT;
-   break;
-   default:
-   *key = KEY_NONE;
-   break;
-   }
-
-   break;
-   }
-
-   if (menu->delay < 0)
-   break;
-
-   --menu->delay;
-   printf("\b\b\b%2d ", menu->delay);
-   }
-
-   printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
-   puts(ANSI_CLEAR_LINE);
-
-   if (menu->delay == 0)
-   *key = KEY_SELECT;
-}
-
-static void bootmenu_loop(struct bootmenu_data *menu,
-   enum bootmenu_key *key, int *esc)
-{
-   int c;
-
-   if (*esc == 1) {
-   if (tstc()) {
-   c = getchar();
-   } else {
-   WATCHDOG_RESET();
-   mdelay(10);
-   if (tstc())
-   c = getchar();
-   else
-   c = '\e';
-   }
-   } else {
-   while (!tstc()) {
-   WATCHDOG_RESET();
-   mdelay(10);
-   }
-   c = getchar();
-   }
-
-   switch (*esc) {
-   case 0:
-   /* First char of ANSI escape sequence '\e' */
-   if (c == '\e') {
-   *esc = 1;
-   *key = KEY_NONE;
-   }
-   break;
-   case 1:
-   /* Second char of ANSI '[' */
-   if (c == '[') {
-   *esc = 2;
-   *key = KEY_NONE;
-   } else {
-   /* Alone ESC key was pressed */
-   *key = KEY_QUIT;
-   *esc = (c == '\e') ? 1 : 0;
-   }
-   break;
-   case 2:
-   case 3:
-   /* Third char of ANSI (number '1') - optional */
-   if (*esc == 2 && c == '1') {
-   *esc = 3;
-   *key = KEY_NONE;
-   break;
-   }
-
-   *esc = 0;
-
-   /* ANSI 'A' - key up was pressed */
-   if (c == 'A')
-   *key = KEY_UP;
- 

[RFC PATCH v2 2/4] lib/charset: add u16_strlcat() function

2022-02-22 Thread Masahisa Kojima
Provide u16 string version of strlcat().

Signed-off-by: Masahisa Kojima 
---
 include/charset.h | 15 +++
 lib/charset.c | 20 
 2 files changed, 35 insertions(+)

diff --git a/include/charset.h b/include/charset.h
index b93d023092..dc5fc275ec 100644
--- a/include/charset.h
+++ b/include/charset.h
@@ -259,6 +259,21 @@ u16 *u16_strcpy(u16 *dest, const u16 *src);
  */
 u16 *u16_strdup(const void *src);
 
+/**
+ * u16_strlcat() - Append a length-limited, %NUL-terminated string to another
+ *
+ * Append the src string to the dest string, overwriting the terminating
+ * null word at the end of dest, and then adds a terminating null word.
+ * It will append at most size - u16_strlen(dst) - 1 bytes, NUL-terminating 
the result.
+ *
+ * @dest:  destination buffer (null terminated)
+ * @src:   source buffer (null terminated)
+ * @size:  destination buffer size in bytes
+ * Return: total size of the created string in bytes.
+ * If return value >= size, truncation occurred.
+ */
+size_t u16_strlcat(u16 *dest, const u16 *src, size_t size);
+
 /**
  * utf16_to_utf8() - Convert an utf16 string to utf8
  *
diff --git a/lib/charset.c b/lib/charset.c
index f44c58d9d8..f15d5df19a 100644
--- a/lib/charset.c
+++ b/lib/charset.c
@@ -428,6 +428,26 @@ u16 *u16_strdup(const void *src)
return new;
 }
 
+size_t u16_strlcat(u16 *dest, const u16 *src, size_t size)
+{
+   size_t dstrlen = u16_strnlen(dest, size >> 1);
+   size_t dlen = dstrlen * sizeof(u16);
+   size_t len = u16_strlen(src) * sizeof(u16);
+   size_t ret = dlen + len;
+
+   if (dlen >= size)
+   return ret;
+
+   dest += dstrlen;
+   size -= dlen;
+   if (len >= size)
+   len = size - sizeof(u16);
+
+   memcpy(dest, src, len);
+   dest[len >> 1] = u'\0';
+   return ret;
+}
+
 /* Convert UTF-16 to UTF-8.  */
 uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size)
 {
-- 
2.17.1



[RFC PATCH v2 0/4] enable menu-driven boot device selection

2022-02-22 Thread Masahisa Kojima
This patch series adds the menu-driven boot device selection.
This menu also provides the functionality to add and delete
Boot variable, and edit the BootOrder variable.

This menu appears with the command "bootefi bootmgr",
the menu structure is as follows.

* Menu structure
[Boot Manager]
-> select Boot to boot
[Boot Manager Maintenance]
- [Add Boot Option]
-> add new Boot variable
- [Delete Boot Option]
-> delete existing Boot variable
- [Change Boot Order]
-> update BootOrder variable

* Things to consider
 - eliminate EFI_CALLs
 - replacement of ANSI_CLEAR_CONSOLE

* Remaining items
 - Support of adding Boot other than block device(e.g. network)
 - error notification

Masahisa Kojima (4):
  efi_loader: add menu-driven boot device selection
  lib/charset: add u16_strlcat() function
  test: unit test for u16_strlcat()
  efi_loader: add menu-driven UEFI Boot Variable maintenance

 cmd/bootmenu.c|  145 -
 common/menu.c |  137 
 include/charset.h |   15 +
 include/efi_loader.h  |   27 +
 include/menu.h|   20 +
 lib/charset.c |   20 +
 lib/efi_loader/Kconfig|   20 +
 lib/efi_loader/efi_bootmgr.c  | 1105 -
 lib/efi_loader/efi_boottime.c |   55 +-
 lib/efi_loader/efi_console.c  |   81 +++
 lib/efi_loader/efi_file.c |   74 ++-
 test/unicode_ut.c |   45 ++
 12 files changed, 1548 insertions(+), 196 deletions(-)

-- 
2.17.1



Re: [PATCH v2] ARM: imx: imx8mn-*-evk: use DM settings for PHY configuration

2022-02-22 Thread Michael Walle

Am 2022-02-22 16:19, schrieb Heiko Thiery:

With the correct settings described in the device-tree the PHY settings
in the board init are no longer required. The values are taken from the
linux device tree.

Suggested-by: Michael Walle 
Signed-off-by: Heiko Thiery 
---
v2:
 - remove phy-reset-gpios node (thanks to Michael)
When using DM_ETH_PHY the reset-gpios from the phy is used

 arch/arm/dts/imx8mn-evk.dtsi| 10 +-
 board/freescale/imx8mn_evk/imx8mn_evk.c | 16 
 2 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/arch/arm/dts/imx8mn-evk.dtsi 
b/arch/arm/dts/imx8mn-evk.dtsi

index 416fadb22b..fd253f0042 100644
--- a/arch/arm/dts/imx8mn-evk.dtsi
+++ b/arch/arm/dts/imx8mn-evk.dtsi
@@ -53,7 +53,6 @@
pinctrl-0 = <_fec1>;
phy-mode = "rgmii-id";
phy-handle = <>;
-   phy-reset-gpios = < 22 GPIO_ACTIVE_LOW>;


This ...


fsl,magic-packet;
status = "okay";

@@ -64,6 +63,15 @@
ethphy0: ethernet-phy@0 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <0>;
+   reset-gpios = < 22 GPIO_ACTIVE_LOW>;
+   reset-assert-us = <1>;
+   qca,disable-smarteee;

.. and these three lines should probably be a separate patch.



+   vddio-supply = <>;
+
+   vddio: vddio-regulator {
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   };


This looks good. The rgmii pad delay is already handled by the
phy-mode.

Reviewed-by: Michael Walle 


};
};
 };
diff --git a/board/freescale/imx8mn_evk/imx8mn_evk.c
b/board/freescale/imx8mn_evk/imx8mn_evk.c
index b24342fd5c..e35d505aea 100644
--- a/board/freescale/imx8mn_evk/imx8mn_evk.c
+++ b/board/freescale/imx8mn_evk/imx8mn_evk.c
@@ -27,22 +27,6 @@ static void setup_fec(void)
clrsetbits_le32(>gpr[1], 0x2000, 0);
 }

-int board_phy_config(struct phy_device *phydev)
-{
-   /* enable rgmii rxc skew and phy mode select to RGMII copper */
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8);
-
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00);
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee);
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);
-
-   if (phydev->drv->config)
-   phydev->drv->config(phydev);
-   return 0;
-}
-
 int board_init(void)
 {
setup_fec();


Re: [PATCH 3/3] efi_loader: add menu-driven UEFI Boot Variable maintenance

2022-02-22 Thread Masahisa Kojima
Hi Heinrich,

On Mon, 14 Feb 2022 at 12:02, Masahisa Kojima
 wrote:
>
> On Sun, 13 Feb 2022 at 18:58, Heinrich Schuchardt  wrote:
> >
> > On 2/10/22 08:05, Masahisa Kojima wrote:
> > > This commit adds the menu-driven UEFI Boot Variable maintenance.
> > > User can add and delete the Boot variable, and update the
> > > BootOrder variable through menu operation.
> > >
> > > Signed-off-by: Masahisa Kojima 
> > > ---
> > >   lib/efi_loader/efi_bootmgr.c | 720 +++
> > >   1 file changed, 720 insertions(+)
> > >
> > > diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
> > > index 013d868f23..739140f742 100644
> > > --- a/lib/efi_loader/efi_bootmgr.c
> > > +++ b/lib/efi_loader/efi_bootmgr.c
> > > @@ -32,6 +32,8 @@ static const struct efi_runtime_services *rs;
> >
> > Where is the Kconfig entry to disable this code?
>
> The patch "[PATCH 1/3] efi_loader: add menu-driven boot device selection"[*1]
> has CONFIG_EFI_BOOT_MENU to enable/disable efi bootmenu.
>
> [*1] 
> https://lore.kernel.org/u-boot/cadq0-x-qenpzscso6emw52tbvg40q1yydkbjfbs2bz0xxas...@mail.gmail.com/T/#u
>
> >
> > >*/
> > >
> > >   #define EFI_BOOTMGR_MENU_ENTRY_NUM_MAX 1024
> > > +#define EFI_BOOTMGR_FILE_PATH_MAX 512
> > > +#define EFI_BOOTMGR_BOOT_NAME_MAX 64
> > >
> > >   typedef efi_status_t (*efi_bootmenu_entry_func)(void *data, bool *exit);
> > >
> > > @@ -95,12 +97,49 @@ struct efi_bootmgr_boot_selection_data {
> > >
> > >   static efi_status_t efi_bootmgr_process_boot_selected(void *data, bool 
> > > *exit);
> > >   static efi_status_t efi_bootmgr_process_boot_selection(void *data, bool 
> > > *exit);
> > > +static efi_status_t efi_bootmgr_process_maintenance(void *data, bool 
> > > *exit);
> > > +static efi_status_t efi_bootmgr_process_add_boot_option(void *data, bool 
> > > *exit);
> > > +static efi_status_t efi_bootmgr_process_delete_boot_option(void *data, 
> > > bool *exit);
> > > +static efi_status_t efi_bootmgr_process_change_boot_order(void *data, 
> > > bool *exit);
> > >
> > >   static struct efi_bootmgr_menu_item bootmgr_menu_items[] = {
> > >   {u"Boot Manager", efi_bootmgr_process_boot_selection},
> > > + {u"Boot Manager maintenance", efi_bootmgr_process_maintenance},
> > >   {u"Quit", NULL},
> > >   };
> > >
> > > +static struct efi_bootmgr_menu_item maintenance_menu_items[] = {
> > > + {u"Add Boot Option", efi_bootmgr_process_add_boot_option},
> > > + {u"Delete Boot Option", efi_bootmgr_process_delete_boot_option},
> > > + {u"Change Boot Order", efi_bootmgr_process_change_boot_order},
> > > + {u"Quit", NULL},
> > > +};
> > > +
> > > +struct efi_bootmgr_boot_option {
> > > + struct efi_simple_file_system_protocol *current_volume;
> > > + struct efi_device_path *dp_volume;
> > > + u16 *current_path;
> > > + u16 *boot_name;
> > > + bool file_selected;
> > > +};
> > > +
> > > +static const struct efi_device_path END = {
> > > + .type = DEVICE_PATH_TYPE_END,
> > > + .sub_type = DEVICE_PATH_SUB_TYPE_END,
> > > + .length   = sizeof(END),
> > > +};
> > > +
> > > +struct efi_bootmgr_volume_entry_data {
> > > + struct efi_bootmgr_boot_option *bo;
> > > + struct efi_simple_file_system_protocol *v;
> > > + struct efi_device_path *dp;
> > > +};
> > > +
> > > +struct efi_bootmgr_file_entry_data {
> > > + struct efi_bootmgr_boot_option *bo;
> > > + struct efi_file_info *f;
> > > +};
> > > +
> > >   static void efi_bootmgr_menu_print_entry(void *data)
> > >   {
> > >   struct efi_bootmgr_menu_entry *entry = data;
> > > @@ -558,6 +597,687 @@ static efi_status_t 
> > > efi_bootmgr_process_boot_selection(void *data, bool *exit)
> > >   return ret;
> > >   }
> > >
> > > +static efi_status_t efi_bootmgr_volume_selected(void *data, bool *exit)
> > > +{
> > > + struct efi_bootmgr_volume_entry_data *info = data;
> > > +
> > > + *exit = true;
> > > +
> > > + if (info) {
> > > + info->bo->current_volume = info->v;
> > > + info->bo->dp_volume = info->dp;
> > > + }
> > > +
> > > + return EFI_SUCCESS;
> > > +}
> > > +
> > > +static efi_status_t efi_bootmgr_file_selected(void *data, bool *exit)
> > > +{
> > > + struct efi_bootmgr_file_entry_data *info = data;
> > > +
> > > + *exit = true;
> > > +
> > > + if (!info)
> > > + return EFI_INVALID_PARAMETER;
> > > +
> > > + if (u16_strncmp(info->f->file_name, u".", 1) == 0 &&
> > > + u16_strlen(info->f->file_name) == 1) {
> > > + /* stay current path */
> > > + } else if (u16_strncmp(info->f->file_name, u"..", 2) == 0 &&
> > > +u16_strlen(info->f->file_name) == 2) {
> > > + u32 i;
> > > + int len = u16_strlen(info->bo->current_path);
> > > +
> > > + for (i = len - 2; i > 0; i--) {
> > > + if (info->bo->current_path[i] == u'\\')
> > > + break;
> > > + }
> > 

[PATCH v2] ARM: imx: imx8mn-*-evk: use DM settings for PHY configuration

2022-02-22 Thread Heiko Thiery
With the correct settings described in the device-tree the PHY settings
in the board init are no longer required. The values are taken from the
linux device tree.

Suggested-by: Michael Walle 
Signed-off-by: Heiko Thiery 
---
v2:
 - remove phy-reset-gpios node (thanks to Michael)
When using DM_ETH_PHY the reset-gpios from the phy is used

 arch/arm/dts/imx8mn-evk.dtsi| 10 +-
 board/freescale/imx8mn_evk/imx8mn_evk.c | 16 
 2 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/arch/arm/dts/imx8mn-evk.dtsi b/arch/arm/dts/imx8mn-evk.dtsi
index 416fadb22b..fd253f0042 100644
--- a/arch/arm/dts/imx8mn-evk.dtsi
+++ b/arch/arm/dts/imx8mn-evk.dtsi
@@ -53,7 +53,6 @@
pinctrl-0 = <_fec1>;
phy-mode = "rgmii-id";
phy-handle = <>;
-   phy-reset-gpios = < 22 GPIO_ACTIVE_LOW>;
fsl,magic-packet;
status = "okay";
 
@@ -64,6 +63,15 @@
ethphy0: ethernet-phy@0 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <0>;
+   reset-gpios = < 22 GPIO_ACTIVE_LOW>;
+   reset-assert-us = <1>;
+   qca,disable-smarteee;
+   vddio-supply = <>;
+
+   vddio: vddio-regulator {
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   };
};
};
 };
diff --git a/board/freescale/imx8mn_evk/imx8mn_evk.c 
b/board/freescale/imx8mn_evk/imx8mn_evk.c
index b24342fd5c..e35d505aea 100644
--- a/board/freescale/imx8mn_evk/imx8mn_evk.c
+++ b/board/freescale/imx8mn_evk/imx8mn_evk.c
@@ -27,22 +27,6 @@ static void setup_fec(void)
clrsetbits_le32(>gpr[1], 0x2000, 0);
 }
 
-int board_phy_config(struct phy_device *phydev)
-{
-   /* enable rgmii rxc skew and phy mode select to RGMII copper */
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8);
-
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00);
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee);
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);
-
-   if (phydev->drv->config)
-   phydev->drv->config(phydev);
-   return 0;
-}
-
 int board_init(void)
 {
setup_fec();
-- 
2.30.2



Re: [PATCH] ARM: imx: imx8mn-*-evk: use DM settings for PHY configuration

2022-02-22 Thread Michael Walle

Am 2022-02-22 15:47, schrieb Heiko Thiery:

With the correct settings described in the device-tree the PHY settings
in the board init are no longer required. The values are taken from the
linux device tree.

Suggested-by: Michael Walle 
Signed-off-by: Heiko Thiery 
---
 arch/arm/dts/imx8mn-evk.dtsi|  9 +
 board/freescale/imx8mn_evk/imx8mn_evk.c | 16 
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/arch/arm/dts/imx8mn-evk.dtsi 
b/arch/arm/dts/imx8mn-evk.dtsi

index 416fadb22b..4453a1a281 100644
--- a/arch/arm/dts/imx8mn-evk.dtsi
+++ b/arch/arm/dts/imx8mn-evk.dtsi
@@ -64,6 +64,15 @@
ethphy0: ethernet-phy@0 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <0>;
+   reset-gpios = < 22 GPIO_ACTIVE_LOW>;


u-boot already has this property in the fec node. So it is now
duplicated.

Both properties are documented in the bindings spec and it
seems u-boot also supports both. So to be aligned with the
linux dtb, I guess it should be kept here and the one in the
fec node should be removed (?).

-michael


[PATCH] imx8mn-*-evk: rename mkimage config

2022-02-22 Thread Heiko Thiery
Since this configuration is used for several imx8mn-evk boards the
suffix ddr4 is misleading.

Signed-off-by: Heiko Thiery 
---
 board/freescale/imx8mn_evk/Kconfig  | 2 +-
 .../imx8mn_evk/{imximage-8mn-ddr4.cfg => imximage-8mn.cfg}  | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename board/freescale/imx8mn_evk/{imximage-8mn-ddr4.cfg => imximage-8mn.cfg} 
(100%)

diff --git a/board/freescale/imx8mn_evk/Kconfig 
b/board/freescale/imx8mn_evk/Kconfig
index 80037c4401..38312a3662 100644
--- a/board/freescale/imx8mn_evk/Kconfig
+++ b/board/freescale/imx8mn_evk/Kconfig
@@ -13,7 +13,7 @@ config IMX8MN_LOW_DRIVE_MODE
bool "Enable the low drive mode of iMX8MN on EVK board"
 
 config IMX_CONFIG
-   default "board/freescale/imx8mn_evk/imximage-8mn-ddr4.cfg"
+   default "board/freescale/imx8mn_evk/imximage-8mn.cfg"
 
 source "board/freescale/common/Kconfig"
 
diff --git a/board/freescale/imx8mn_evk/imximage-8mn-ddr4.cfg 
b/board/freescale/imx8mn_evk/imximage-8mn.cfg
similarity index 100%
rename from board/freescale/imx8mn_evk/imximage-8mn-ddr4.cfg
rename to board/freescale/imx8mn_evk/imximage-8mn.cfg
-- 
2.30.2



[PATCH] ARM: imx: imx8mn-*-evk: use DM settings for PHY configuration

2022-02-22 Thread Heiko Thiery
With the correct settings described in the device-tree the PHY settings
in the board init are no longer required. The values are taken from the
linux device tree.

Suggested-by: Michael Walle 
Signed-off-by: Heiko Thiery 
---
 arch/arm/dts/imx8mn-evk.dtsi|  9 +
 board/freescale/imx8mn_evk/imx8mn_evk.c | 16 
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/arch/arm/dts/imx8mn-evk.dtsi b/arch/arm/dts/imx8mn-evk.dtsi
index 416fadb22b..4453a1a281 100644
--- a/arch/arm/dts/imx8mn-evk.dtsi
+++ b/arch/arm/dts/imx8mn-evk.dtsi
@@ -64,6 +64,15 @@
ethphy0: ethernet-phy@0 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <0>;
+   reset-gpios = < 22 GPIO_ACTIVE_LOW>;
+   reset-assert-us = <1>;
+   qca,disable-smarteee;
+   vddio-supply = <>;
+
+   vddio: vddio-regulator {
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   };
};
};
 };
diff --git a/board/freescale/imx8mn_evk/imx8mn_evk.c 
b/board/freescale/imx8mn_evk/imx8mn_evk.c
index b24342fd5c..e35d505aea 100644
--- a/board/freescale/imx8mn_evk/imx8mn_evk.c
+++ b/board/freescale/imx8mn_evk/imx8mn_evk.c
@@ -27,22 +27,6 @@ static void setup_fec(void)
clrsetbits_le32(>gpr[1], 0x2000, 0);
 }
 
-int board_phy_config(struct phy_device *phydev)
-{
-   /* enable rgmii rxc skew and phy mode select to RGMII copper */
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8);
-
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00);
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee);
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
-   phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);
-
-   if (phydev->drv->config)
-   phydev->drv->config(phydev);
-   return 0;
-}
-
 int board_init(void)
 {
setup_fec();
-- 
2.30.2



[PATCH v3] scripts: Makefile.lib: generate dsdt_generated.c instead of dsdt.c

2022-02-22 Thread Philippe Reynes
There is a conflict between the static file
lib/acpi/dsdt.c and the file dsdt.c generated
dynamicaly by scripts/Makefile.lib. When a
mrproper is done, the static file dsdt.c is
removed. If a build with acpi enabled is
launched after, the following error is raised:

  CC  lib/acpi/acpi_table.o
make[2]: *** No rule to make target 'lib/acpi/dsdt.asl', needed by 
'lib/acpi/dsdt.c'.  Stop.
scripts/Makefile.build:394: recipe for target 'lib/acpi' failed

To avoid such error, the generated file is named
dsdt_generated.c instead of dstdt.c.

Signed-off-by: Philippe Reynes 
---

Changelog:
v3:
- update comments in file scripts/Makefile.lib
- add changelog
v2
- change generated file name (dsdt_generated.c)
  instead of changing the name of the static file
- NOTE : forgot to call it v2 and forgot changelog

Makefile| 3 ++-
 board/advantech/som-db5800-som-6867/Makefile| 2 +-
 board/congatec/conga-qeval20-qa3-e3845/Makefile | 2 +-
 board/dfi/dfi-bt700/Makefile| 2 +-
 board/google/chromebook_coral/Makefile  | 2 +-
 board/intel/bayleybay/Makefile  | 2 +-
 board/intel/edison/Makefile | 2 +-
 board/intel/galileo/Makefile| 2 +-
 board/intel/minnowmax/Makefile  | 2 +-
 scripts/Makefile.lib| 8 
 10 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile
index 4b152249ca..94bc48f00c 100644
--- a/Makefile
+++ b/Makefile
@@ -2226,7 +2226,8 @@ clean: $(clean-dirs)
-o -name '*.asn1.[ch]' \
-o -name '*.symtypes' -o -name 'modules.order' \
-o -name modules.builtin -o -name '.tmp_*.o.*' \
-   -o -name 'dsdt.aml' -o -name 'dsdt.asl.tmp' -o -name 'dsdt.c' \
+   -o -name 'dsdt_generated.aml' -o -name 'dsdt_generated.asl.tmp' 
\
+   -o -name 'dsdt_generated.c' \
-o -name '*.efi' -o -name '*.gcno' -o -name '*.so' \) \
-type f -print | xargs rm -f
 
diff --git a/board/advantech/som-db5800-som-6867/Makefile 
b/board/advantech/som-db5800-som-6867/Makefile
index 7975547f41..95af6c4df7 100644
--- a/board/advantech/som-db5800-som-6867/Makefile
+++ b/board/advantech/som-db5800-som-6867/Makefile
@@ -3,4 +3,4 @@
 # Copyright (C) 2015, Google, Inc
 
 obj-y  += som-db5800-som-6867.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/congatec/conga-qeval20-qa3-e3845/Makefile 
b/board/congatec/conga-qeval20-qa3-e3845/Makefile
index 451a4fcd6c..215f5680dc 100644
--- a/board/congatec/conga-qeval20-qa3-e3845/Makefile
+++ b/board/congatec/conga-qeval20-qa3-e3845/Makefile
@@ -3,4 +3,4 @@
 # Copyright (C) 2015, Google, Inc
 
 obj-y  += conga-qeval20-qa3.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/dfi/dfi-bt700/Makefile b/board/dfi/dfi-bt700/Makefile
index 50d88f2954..1c4329a058 100644
--- a/board/dfi/dfi-bt700/Makefile
+++ b/board/dfi/dfi-bt700/Makefile
@@ -3,4 +3,4 @@
 # Copyright (C) 2015, Google, Inc
 
 obj-y  += dfi-bt700.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/google/chromebook_coral/Makefile 
b/board/google/chromebook_coral/Makefile
index f7a0ca6cc0..846558d777 100644
--- a/board/google/chromebook_coral/Makefile
+++ b/board/google/chromebook_coral/Makefile
@@ -3,4 +3,4 @@
 # Copyright 2019 Google LLC
 
 obj-y  += coral.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/bayleybay/Makefile b/board/intel/bayleybay/Makefile
index d19447184a..fa263b7bf5 100644
--- a/board/intel/bayleybay/Makefile
+++ b/board/intel/bayleybay/Makefile
@@ -3,4 +3,4 @@
 # Copyright (C) 2015, Bin Meng 
 
 obj-y  += bayleybay.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/edison/Makefile b/board/intel/edison/Makefile
index 1eaf7ca7f8..f7f70dfaa7 100644
--- a/board/intel/edison/Makefile
+++ b/board/intel/edison/Makefile
@@ -5,4 +5,4 @@
 #
 
 obj-y  += edison.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/galileo/Makefile b/board/intel/galileo/Makefile
index 4130bb0236..7d5f4df0f9 100644
--- a/board/intel/galileo/Makefile
+++ b/board/intel/galileo/Makefile
@@ -3,4 +3,4 @@
 # Copyright (C) 2015, Bin Meng 
 
 obj-y  += galileo.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/minnowmax/Makefile b/board/intel/minnowmax/Makefile
index d339b5ad0a..a20322a1a1 100644
--- a/board/intel/minnowmax/Makefile
+++ b/board/intel/minnowmax/Makefile
@@ -3,4 +3,4 @@
 # Copyright (C) 2015, Google, Inc
 
 obj-y  += minnowmax.o

Re: [PATCH] gpio: rgpio2p: Enhance reading of GPIO pin value

2022-02-22 Thread Fabio Estevam
Hi Peng and Ye Li,

Could you please help reviewing this patch?

Thanks

On Mon, Jan 24, 2022 at 5:46 PM Christoph Fritz
 wrote:
>
> Add support for reading GPIO pin value when function is output.
> With this patch applied, gpio toggle command is working.
>
> Signed-off-by: Christoph Fritz 
> ---
>  drivers/gpio/imx_rgpio2p.c | 14 +-
>  1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/imx_rgpio2p.c b/drivers/gpio/imx_rgpio2p.c
> index 0e2874ca95c..175e460aff5 100644
> --- a/drivers/gpio/imx_rgpio2p.c
> +++ b/drivers/gpio/imx_rgpio2p.c
> @@ -39,6 +39,14 @@ static int imx_rgpio2p_is_output(struct gpio_regs *regs, 
> int offset)
> return val & (1 << offset) ? 1 : 0;
>  }
>
> +static int imx_rgpio2p_bank_get_direction(struct gpio_regs *regs, int offset)
> +{
> +   if ((readl(>gpio_pddr) >> offset) & 0x01)
> +   return IMX_RGPIO2P_DIRECTION_OUT;
> +
> +   return IMX_RGPIO2P_DIRECTION_IN;
> +}
> +
>  static void imx_rgpio2p_bank_direction(struct gpio_regs *regs, int offset,
> enum imx_rgpio2p_direction direction)
>  {
> @@ -67,7 +75,11 @@ static void imx_rgpio2p_bank_set_value(struct gpio_regs 
> *regs, int offset,
>
>  static int imx_rgpio2p_bank_get_value(struct gpio_regs *regs, int offset)
>  {
> -   return (readl(>gpio_pdir) >> offset) & 0x01;
> +   if (imx_rgpio2p_bank_get_direction(regs, offset) ==
> +   IMX_RGPIO2P_DIRECTION_IN)
> +   return (readl(>gpio_pdir) >> offset) & 0x01;
> +
> +   return (readl(>gpio_pdor) >> offset) & 0x01;
>  }
>
>  static int  imx_rgpio2p_direction_input(struct udevice *dev, unsigned offset)
> --
> 2.30.2
>
>
>


Re: [PATCH] scripts: Makefile.lib: generate dsdt_generated.c instead of dsdt.c

2022-02-22 Thread Philippe REYNES

Hi Heinrich,


Le 22/02/2022 à 10:40, Heinrich Schuchardt a écrit :

On 2/22/22 10:16, Philippe Reynes wrote:

There is a conflict between the static file
lib/acpi/dsdt.c and the file dsdt.c generated
dynamicaly by scripts/Makefile.lib. When a
mrproper is done, the static file dsdt.c is
removed. If a build with acpi enabled is
launched after, the following error is raised:

   CC  lib/acpi/acpi_table.o
make[2]: *** No rule to make target 'lib/acpi/dsdt.asl', needed by 
'lib/acpi/dsdt.c'.  Stop.

scripts/Makefile.build:394: recipe for target 'lib/acpi' failed

To avoid such error, the generated file is named
dsdt_generated.c instead of dstdt.c.

Signed-off-by: Philippe Reynes 


Marking the patch as v2 and adding a change history would have been 
preferable.



Oh yes, sorry, I forgot it ...

---
  Makefile    | 3 ++-
  board/advantech/som-db5800-som-6867/Makefile    | 2 +-
  board/congatec/conga-qeval20-qa3-e3845/Makefile | 2 +-
  board/dfi/dfi-bt700/Makefile    | 2 +-
  board/google/chromebook_coral/Makefile  | 2 +-
  board/intel/bayleybay/Makefile  | 2 +-
  board/intel/edison/Makefile | 2 +-
  board/intel/galileo/Makefile    | 2 +-
  board/intel/minnowmax/Makefile  | 2 +-
  scripts/Makefile.lib    | 4 ++--
  10 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index 4b152249ca..94bc48f00c 100644
--- a/Makefile
+++ b/Makefile
@@ -2226,7 +2226,8 @@ clean: $(clean-dirs)
  -o -name '*.asn1.[ch]' \
  -o -name '*.symtypes' -o -name 'modules.order' \
  -o -name modules.builtin -o -name '.tmp_*.o.*' \
-    -o -name 'dsdt.aml' -o -name 'dsdt.asl.tmp' -o -name 'dsdt.c' \
+    -o -name 'dsdt_generated.aml' -o -name 
'dsdt_generated.asl.tmp' \

+    -o -name 'dsdt_generated.c' \
  -o -name '*.efi' -o -name '*.gcno' -o -name '*.so' \) \
  -type f -print | xargs rm -f
  diff --git a/board/advantech/som-db5800-som-6867/Makefile 
b/board/advantech/som-db5800-som-6867/Makefile

index 7975547f41..95af6c4df7 100644
--- a/board/advantech/som-db5800-som-6867/Makefile
+++ b/board/advantech/som-db5800-som-6867/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Google, Inc
    obj-y    += som-db5800-som-6867.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/congatec/conga-qeval20-qa3-e3845/Makefile 
b/board/congatec/conga-qeval20-qa3-e3845/Makefile

index 451a4fcd6c..215f5680dc 100644
--- a/board/congatec/conga-qeval20-qa3-e3845/Makefile
+++ b/board/congatec/conga-qeval20-qa3-e3845/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Google, Inc
    obj-y    += conga-qeval20-qa3.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/dfi/dfi-bt700/Makefile b/board/dfi/dfi-bt700/Makefile
index 50d88f2954..1c4329a058 100644
--- a/board/dfi/dfi-bt700/Makefile
+++ b/board/dfi/dfi-bt700/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Google, Inc
    obj-y    += dfi-bt700.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/google/chromebook_coral/Makefile 
b/board/google/chromebook_coral/Makefile

index f7a0ca6cc0..846558d777 100644
--- a/board/google/chromebook_coral/Makefile
+++ b/board/google/chromebook_coral/Makefile
@@ -3,4 +3,4 @@
  # Copyright 2019 Google LLC
    obj-y    += coral.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/bayleybay/Makefile 
b/board/intel/bayleybay/Makefile

index d19447184a..fa263b7bf5 100644
--- a/board/intel/bayleybay/Makefile
+++ b/board/intel/bayleybay/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Bin Meng 
    obj-y    += bayleybay.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/edison/Makefile b/board/intel/edison/Makefile
index 1eaf7ca7f8..f7f70dfaa7 100644
--- a/board/intel/edison/Makefile
+++ b/board/intel/edison/Makefile
@@ -5,4 +5,4 @@
  #
    obj-y    += edison.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/galileo/Makefile b/board/intel/galileo/Makefile
index 4130bb0236..7d5f4df0f9 100644
--- a/board/intel/galileo/Makefile
+++ b/board/intel/galileo/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Bin Meng 
    obj-y    += galileo.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/minnowmax/Makefile 
b/board/intel/minnowmax/Makefile

index d339b5ad0a..a20322a1a1 100644
--- a/board/intel/minnowmax/Makefile
+++ b/board/intel/minnowmax/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Google, Inc
    obj-y    += minnowmax.o

Re: [PATCH v1 02/11] mmc: sdhci: allow disabling sdma in spl

2022-02-22 Thread Jaehoon Chung
On 2/22/22 10:31, Peter Geis wrote:
> Rockchip emmc devices have a similar issue to Rockchip dwmmc devices,
> where performing dma to sram causes errors with suspend/resume.
> Allow us to toggle sdma in spl for sdhci similar to adma support, so we
> can ensure dma is not used when loading the sram code.
> 
> Signed-off-by: Peter Geis 

Reviewed-by: Jaehoon Chung 

Best Regards,
Jaehoon Chung

> ---
>  drivers/mmc/Kconfig | 7 +++
>  drivers/mmc/sdhci.c | 6 +++---
>  2 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
> index f04cc44e1973..1e4342285ce7 100644
> --- a/drivers/mmc/Kconfig
> +++ b/drivers/mmc/Kconfig
> @@ -468,6 +468,13 @@ config MMC_SDHCI_SDMA
> This enables support for the SDMA (Single Operation DMA) defined
> in the SD Host Controller Standard Specification Version 1.00 .
>  
> +config SPL_MMC_SDHCI_SDMA
> + bool "Support SDHCI SDMA in SPL"
> + depends on MMC_SDHCI
> + help
> +   This enables support for the SDMA (Single Operation DMA) defined
> +   in the SD Host Controller Standard Specification Version 1.00 in SPL.
> +
>  config MMC_SDHCI_ADMA
>   bool "Support SDHCI ADMA2"
>   depends on MMC_SDHCI
> diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
> index 766e4a6b0c5e..6285e53d12a2 100644
> --- a/drivers/mmc/sdhci.c
> +++ b/drivers/mmc/sdhci.c
> @@ -70,7 +70,7 @@ static void sdhci_transfer_pio(struct sdhci_host *host, 
> struct mmc_data *data)
>   }
>  }
>  
> -#if (defined(CONFIG_MMC_SDHCI_SDMA) || CONFIG_IS_ENABLED(MMC_SDHCI_ADMA))
> +#if (CONFIG_IS_ENABLED(MMC_SDHCI_SDMA) || CONFIG_IS_ENABLED(MMC_SDHCI_ADMA))
>  static void sdhci_prepare_dma(struct sdhci_host *host, struct mmc_data *data,
> int *is_aligned, int trans_bytes)
>  {
> @@ -177,7 +177,7 @@ static int sdhci_transfer_data(struct sdhci_host *host, 
> struct mmc_data *data)
>   }
>   } while (!(stat & SDHCI_INT_DATA_END));
>  
> -#if (defined(CONFIG_MMC_SDHCI_SDMA) || CONFIG_IS_ENABLED(MMC_SDHCI_ADMA))
> +#if (CONFIG_IS_ENABLED(MMC_SDHCI_SDMA) || CONFIG_IS_ENABLED(MMC_SDHCI_ADMA))
>   dma_unmap_single(host->start_addr, data->blocks * data->blocksize,
>mmc_get_dma_dir(data));
>  #endif
> @@ -836,7 +836,7 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct 
> sdhci_host *host,
>  #endif
>   debug("%s, caps: 0x%x\n", __func__, caps);
>  
> -#ifdef CONFIG_MMC_SDHCI_SDMA
> +#if CONFIG_IS_ENABLED(MMC_SDHCI_SDMA)
>   if ((caps & SDHCI_CAN_DO_SDMA)) {
>   host->flags |= USE_SDMA;
>   } else {



Re: [PATCH v2] ARM: imx: imx8mn-ddr4-evk: Add ethernet support

2022-02-22 Thread Marek Vasut

On 2/22/22 08:35, Frieder Schrempf wrote:

Hi Marek,


Hi,


+int board_phy_config(struct phy_device *phydev)
+{
+    /* enable rgmii rxc skew and phy mode select to RGMII copper */
+    phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);
+    phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8);
+
+    phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00);
+    phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee);
+    phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
+    phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);


This is a AR8031, correct?  Is there a reason why you don't use the
device tree binding to set RGMII voltage, and RX and tx delays?


I quickly cobbled this together from another board, since I needed
ethernet to do other tests with this board and the ethernet support was
missing. If you can send subsequent patch to flip this to DT-only setup,
I can test the patch on the board.


So why don't you post it as RFC?
To be honest it seems a bit contradictory that you normally take a
critical position on other people's patches when they use legacy code
instead of DM/DT (which is alright) and then send a half-baked approach
yourself and expect other people to fix it for you afterwards.

I don't want to complain, it just occurred to me.


It's just a patch I had half-baked in a tree for over a year, so I sent 
it. It didn't occur to me there is now a way to do this in DT, since the 
patch was in my tree for so long and I only dealt with the ar803x PHY 
recently. I will try and convert this to DT next time I have the board 
on my desk, but if someone is faster ... even better.


Re: [PATCH v2] ARM: imx: imx8mn-ddr4-evk: Add ethernet support

2022-02-22 Thread Marek Vasut

On 2/22/22 08:49, Michael Walle wrote:

Hi Marek,


Hi,


Am 2022-02-21 17:49, schrieb Marek Vasut:

On 2/21/22 11:10, Michael Walle wrote:

+int board_phy_config(struct phy_device *phydev)
+{
+    /* enable rgmii rxc skew and phy mode select to RGMII copper */
+    phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);
+    phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8);
+
+    phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00);
+    phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee);
+    phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
+    phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);


This is a AR8031, correct?  Is there a reason why you don't use the
device tree binding to set RGMII voltage, and RX and tx delays?


I quickly cobbled this together from another board, since I needed
ethernet to do other tests with this board and the ethernet support
was missing. If you can send subsequent patch to flip this to DT-only
setup, I can test the patch on the board.


I neither have this board, nor do I care much about it. I just saw
the usual hardcoded atheros phy settings being done in the board
setup. That being said, you can find an example in:
  arch/arm/dts/fsl-ls1028a-kontron-sl28-var4.dts

But you have to figure out what you need. I guess the last four
writes are the rgmii delays which are handled by
   phy-mode = "rgmii-id";

The 0x8 to 0x1f is 1.8V RGMII voltage, you'd need to look at
the schematics if that voltage is actually used. A Zero means
1.5V. If it's using 2.5V then you don't have to do anything
because an external regulator is used.


One might almost think that's what NXP should've done for a while, 
considering this is a devkit and missing ethernet is a problem for any 
network boot.


So unless NXP is faster, I will try and convert this to DT next time I 
have the board on my desk.


Re: [PATCH] scripts: Makefile.lib: generate dsdt_generated.c instead of dsdt.c

2022-02-22 Thread Heinrich Schuchardt

On 2/22/22 10:16, Philippe Reynes wrote:

There is a conflict between the static file
lib/acpi/dsdt.c and the file dsdt.c generated
dynamicaly by scripts/Makefile.lib. When a
mrproper is done, the static file dsdt.c is
removed. If a build with acpi enabled is
launched after, the following error is raised:

   CC  lib/acpi/acpi_table.o
make[2]: *** No rule to make target 'lib/acpi/dsdt.asl', needed by 
'lib/acpi/dsdt.c'.  Stop.
scripts/Makefile.build:394: recipe for target 'lib/acpi' failed

To avoid such error, the generated file is named
dsdt_generated.c instead of dstdt.c.

Signed-off-by: Philippe Reynes 


Marking the patch as v2 and adding a change history would have been 
preferable.



---
  Makefile| 3 ++-
  board/advantech/som-db5800-som-6867/Makefile| 2 +-
  board/congatec/conga-qeval20-qa3-e3845/Makefile | 2 +-
  board/dfi/dfi-bt700/Makefile| 2 +-
  board/google/chromebook_coral/Makefile  | 2 +-
  board/intel/bayleybay/Makefile  | 2 +-
  board/intel/edison/Makefile | 2 +-
  board/intel/galileo/Makefile| 2 +-
  board/intel/minnowmax/Makefile  | 2 +-
  scripts/Makefile.lib| 4 ++--
  10 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index 4b152249ca..94bc48f00c 100644
--- a/Makefile
+++ b/Makefile
@@ -2226,7 +2226,8 @@ clean: $(clean-dirs)
-o -name '*.asn1.[ch]' \
-o -name '*.symtypes' -o -name 'modules.order' \
-o -name modules.builtin -o -name '.tmp_*.o.*' \
-   -o -name 'dsdt.aml' -o -name 'dsdt.asl.tmp' -o -name 'dsdt.c' \
+   -o -name 'dsdt_generated.aml' -o -name 'dsdt_generated.asl.tmp' 
\
+   -o -name 'dsdt_generated.c' \
-o -name '*.efi' -o -name '*.gcno' -o -name '*.so' \) \
-type f -print | xargs rm -f
  
diff --git a/board/advantech/som-db5800-som-6867/Makefile b/board/advantech/som-db5800-som-6867/Makefile

index 7975547f41..95af6c4df7 100644
--- a/board/advantech/som-db5800-som-6867/Makefile
+++ b/board/advantech/som-db5800-som-6867/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Google, Inc
  
  obj-y	+= som-db5800-som-6867.o

-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/congatec/conga-qeval20-qa3-e3845/Makefile 
b/board/congatec/conga-qeval20-qa3-e3845/Makefile
index 451a4fcd6c..215f5680dc 100644
--- a/board/congatec/conga-qeval20-qa3-e3845/Makefile
+++ b/board/congatec/conga-qeval20-qa3-e3845/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Google, Inc
  
  obj-y	+= conga-qeval20-qa3.o

-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/dfi/dfi-bt700/Makefile b/board/dfi/dfi-bt700/Makefile
index 50d88f2954..1c4329a058 100644
--- a/board/dfi/dfi-bt700/Makefile
+++ b/board/dfi/dfi-bt700/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Google, Inc
  
  obj-y	+= dfi-bt700.o

-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/google/chromebook_coral/Makefile 
b/board/google/chromebook_coral/Makefile
index f7a0ca6cc0..846558d777 100644
--- a/board/google/chromebook_coral/Makefile
+++ b/board/google/chromebook_coral/Makefile
@@ -3,4 +3,4 @@
  # Copyright 2019 Google LLC
  
  obj-y	+= coral.o

-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/bayleybay/Makefile b/board/intel/bayleybay/Makefile
index d19447184a..fa263b7bf5 100644
--- a/board/intel/bayleybay/Makefile
+++ b/board/intel/bayleybay/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Bin Meng 
  
  obj-y	+= bayleybay.o

-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/edison/Makefile b/board/intel/edison/Makefile
index 1eaf7ca7f8..f7f70dfaa7 100644
--- a/board/intel/edison/Makefile
+++ b/board/intel/edison/Makefile
@@ -5,4 +5,4 @@
  #
  
  obj-y	+= edison.o

-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/galileo/Makefile b/board/intel/galileo/Makefile
index 4130bb0236..7d5f4df0f9 100644
--- a/board/intel/galileo/Makefile
+++ b/board/intel/galileo/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Bin Meng 
  
  obj-y	+= galileo.o

-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/minnowmax/Makefile b/board/intel/minnowmax/Makefile
index d339b5ad0a..a20322a1a1 100644
--- a/board/intel/minnowmax/Makefile
+++ b/board/intel/minnowmax/Makefile
@@ -3,4 +3,4 @@
  # Copyright (C) 2015, Google, Inc
  
  obj-y	+= minnowmax.o

-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += 

Re: [PATCH] gpio: rgpio2p: Enhance reading of GPIO pin value

2022-02-22 Thread Christoph Fritz
*ping*, any objections getting this patch applied?

On Mon, 2022-01-24 at 17:51 -0300, Fabio Estevam wrote:
> On Mon, Jan 24, 2022 at 5:50 PM Fabio Estevam 
> wrote:
> > 
> > [Adding the NXP folks to help reviewing it]
> 
> Sorry, added the NXP Linux folks instead of the NXP U-Boot folks.
> 
> > 
> > On Mon, Jan 24, 2022 at 5:46 PM Christoph Fritz
> >  wrote:
> > > 
> > > Add support for reading GPIO pin value when function is output.
> > > With this patch applied, gpio toggle command is working.
> > > 
> > > Signed-off-by: Christoph Fritz 
> > > ---
> > >  drivers/gpio/imx_rgpio2p.c | 14 +-
> > >  1 file changed, 13 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpio/imx_rgpio2p.c
> > > b/drivers/gpio/imx_rgpio2p.c
> > > index 0e2874ca95c..175e460aff5 100644
> > > --- a/drivers/gpio/imx_rgpio2p.c
> > > +++ b/drivers/gpio/imx_rgpio2p.c
> > > @@ -39,6 +39,14 @@ static int imx_rgpio2p_is_output(struct
> > > gpio_regs *regs, int offset)
> > >     return val & (1 << offset) ? 1 : 0;
> > >  }
> > > 
> > > +static int imx_rgpio2p_bank_get_direction(struct gpio_regs
> > > *regs, int offset)
> > > +{
> > > +   if ((readl(>gpio_pddr) >> offset) & 0x01)
> > > +   return IMX_RGPIO2P_DIRECTION_OUT;
> > > +
> > > +   return IMX_RGPIO2P_DIRECTION_IN;
> > > +}
> > > +
> > >  static void imx_rgpio2p_bank_direction(struct gpio_regs *regs,
> > > int offset,
> > >     enum imx_rgpio2p_direction
> > > direction)
> > >  {
> > > @@ -67,7 +75,11 @@ static void imx_rgpio2p_bank_set_value(struct
> > > gpio_regs *regs, int offset,
> > > 
> > >  static int imx_rgpio2p_bank_get_value(struct gpio_regs *regs,
> > > int offset)
> > >  {
> > > -   return (readl(>gpio_pdir) >> offset) & 0x01;
> > > +   if (imx_rgpio2p_bank_get_direction(regs, offset) ==
> > > +   IMX_RGPIO2P_DIRECTION_IN)
> > > +   return (readl(>gpio_pdir) >> offset) &
> > > 0x01;
> > > +
> > > +   return (readl(>gpio_pdor) >> offset) & 0x01;
> > >  }
> > > 
> > >  static int  imx_rgpio2p_direction_input(struct udevice *dev,
> > > unsigned offset)
> > > --
> > > 2.30.2
> > > 
> > > 
> > > 



[PATCH] scripts: Makefile.lib: generate dsdt_generated.c instead of dsdt.c

2022-02-22 Thread Philippe Reynes
There is a conflict between the static file
lib/acpi/dsdt.c and the file dsdt.c generated
dynamicaly by scripts/Makefile.lib. When a
mrproper is done, the static file dsdt.c is
removed. If a build with acpi enabled is
launched after, the following error is raised:

  CC  lib/acpi/acpi_table.o
make[2]: *** No rule to make target 'lib/acpi/dsdt.asl', needed by 
'lib/acpi/dsdt.c'.  Stop.
scripts/Makefile.build:394: recipe for target 'lib/acpi' failed

To avoid such error, the generated file is named
dsdt_generated.c instead of dstdt.c.

Signed-off-by: Philippe Reynes 
---
 Makefile| 3 ++-
 board/advantech/som-db5800-som-6867/Makefile| 2 +-
 board/congatec/conga-qeval20-qa3-e3845/Makefile | 2 +-
 board/dfi/dfi-bt700/Makefile| 2 +-
 board/google/chromebook_coral/Makefile  | 2 +-
 board/intel/bayleybay/Makefile  | 2 +-
 board/intel/edison/Makefile | 2 +-
 board/intel/galileo/Makefile| 2 +-
 board/intel/minnowmax/Makefile  | 2 +-
 scripts/Makefile.lib| 4 ++--
 10 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index 4b152249ca..94bc48f00c 100644
--- a/Makefile
+++ b/Makefile
@@ -2226,7 +2226,8 @@ clean: $(clean-dirs)
-o -name '*.asn1.[ch]' \
-o -name '*.symtypes' -o -name 'modules.order' \
-o -name modules.builtin -o -name '.tmp_*.o.*' \
-   -o -name 'dsdt.aml' -o -name 'dsdt.asl.tmp' -o -name 'dsdt.c' \
+   -o -name 'dsdt_generated.aml' -o -name 'dsdt_generated.asl.tmp' 
\
+   -o -name 'dsdt_generated.c' \
-o -name '*.efi' -o -name '*.gcno' -o -name '*.so' \) \
-type f -print | xargs rm -f
 
diff --git a/board/advantech/som-db5800-som-6867/Makefile 
b/board/advantech/som-db5800-som-6867/Makefile
index 7975547f41..95af6c4df7 100644
--- a/board/advantech/som-db5800-som-6867/Makefile
+++ b/board/advantech/som-db5800-som-6867/Makefile
@@ -3,4 +3,4 @@
 # Copyright (C) 2015, Google, Inc
 
 obj-y  += som-db5800-som-6867.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/congatec/conga-qeval20-qa3-e3845/Makefile 
b/board/congatec/conga-qeval20-qa3-e3845/Makefile
index 451a4fcd6c..215f5680dc 100644
--- a/board/congatec/conga-qeval20-qa3-e3845/Makefile
+++ b/board/congatec/conga-qeval20-qa3-e3845/Makefile
@@ -3,4 +3,4 @@
 # Copyright (C) 2015, Google, Inc
 
 obj-y  += conga-qeval20-qa3.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/dfi/dfi-bt700/Makefile b/board/dfi/dfi-bt700/Makefile
index 50d88f2954..1c4329a058 100644
--- a/board/dfi/dfi-bt700/Makefile
+++ b/board/dfi/dfi-bt700/Makefile
@@ -3,4 +3,4 @@
 # Copyright (C) 2015, Google, Inc
 
 obj-y  += dfi-bt700.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/google/chromebook_coral/Makefile 
b/board/google/chromebook_coral/Makefile
index f7a0ca6cc0..846558d777 100644
--- a/board/google/chromebook_coral/Makefile
+++ b/board/google/chromebook_coral/Makefile
@@ -3,4 +3,4 @@
 # Copyright 2019 Google LLC
 
 obj-y  += coral.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/bayleybay/Makefile b/board/intel/bayleybay/Makefile
index d19447184a..fa263b7bf5 100644
--- a/board/intel/bayleybay/Makefile
+++ b/board/intel/bayleybay/Makefile
@@ -3,4 +3,4 @@
 # Copyright (C) 2015, Bin Meng 
 
 obj-y  += bayleybay.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/edison/Makefile b/board/intel/edison/Makefile
index 1eaf7ca7f8..f7f70dfaa7 100644
--- a/board/intel/edison/Makefile
+++ b/board/intel/edison/Makefile
@@ -5,4 +5,4 @@
 #
 
 obj-y  += edison.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/galileo/Makefile b/board/intel/galileo/Makefile
index 4130bb0236..7d5f4df0f9 100644
--- a/board/intel/galileo/Makefile
+++ b/board/intel/galileo/Makefile
@@ -3,4 +3,4 @@
 # Copyright (C) 2015, Bin Meng 
 
 obj-y  += galileo.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/board/intel/minnowmax/Makefile b/board/intel/minnowmax/Makefile
index d339b5ad0a..a20322a1a1 100644
--- a/board/intel/minnowmax/Makefile
+++ b/board/intel/minnowmax/Makefile
@@ -3,4 +3,4 @@
 # Copyright (C) 2015, Google, Inc
 
 obj-y  += minnowmax.o
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 93cb09ac61..8a8aa46c18 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -468,9 

Re: [PATCH] lib: acpi: rename dsdt.c to acpi_write_dsdt.c

2022-02-22 Thread Philippe REYNES

Hi Simon,


Le 17/02/2022 à 18:55, Simon Glass a écrit :

Hi Philippe,

On Thu, 17 Feb 2022 at 09:10, Philippe Reynes
 wrote:

There is a conflict between the static file
lib/acpi/dsdt.c and the file dsdt.c generated
dynamicaly by scripts/Makefile.lib. When a
mrproper is done, the static file dsdt.c is
removed. If a build with acpi enabled is
launched after, the following error is raised:

   CC  lib/acpi/acpi_table.o
make[2]: *** No rule to make target 'lib/acpi/dsdt.asl', needed by 
'lib/acpi/dsdt.c'.  Stop.
scripts/Makefile.build:394: recipe for target 'lib/acpi' failed

To avoid such error, the static file dsdt.c
is renamed to acpi_write_dsdt.c.

Signed-off-by: Philippe Reynes 
---
  lib/acpi/Makefile  | 2 +-
  lib/acpi/{dsdt.c => acpi_write_dsdt.c} | 0
  2 files changed, 1 insertion(+), 1 deletion(-)
  rename lib/acpi/{dsdt.c => acpi_write_dsdt.c} (100%)

Reviewed-by: Simon Glass 

I would prefer that we change the 'rm' to be deterministic in this
case, as we do with other filenames. One way would be to change the
Makefile.lib rule to:

$(obj)/dsdt_generated.c:$(src)/dsdt.asl

then at least the generated file has a name that distinguishes it.


it may become a rule that all generated file should have "generated" in 
the name.

I have done this change. I send the patch to the ML.


Regards,
Simon

Regards,
Philippe




[PATCH] arm: Add AM335x based CBC board

2022-02-22 Thread Lukasz Majewski
This commit adds CBC board to U-Boot.

U-Boot 2022.04-rc1-00271-g930634a4c9 (Feb 21 2022 - 15:08:13 +0100)

CPU  : AM335X-GP rev 2.1
Model: AM335x Bosch CBC
DRAM:  512 MiB
Core:  198 devices, 14 uclasses, devicetree: separate
MMC:   OMAP SD/MMC: 2, OMAP SD/MMC: 0, OMAP SD/MMC: 1
Loading Environment from MMC... OK
Boot Device is eMMC
CBC Variant found: BCT531
Net:   eth2: ethernet@4a10
Hit any key to stop autoboot:  0

Signed-off-by: Lukasz Majewski 

---

 arch/arm/Kconfig|   1 +
 arch/arm/dts/Makefile   |   1 +
 arch/arm/dts/am335x-cbc-u-boot.dtsi |  18 ++
 arch/arm/dts/am335x-cbc.dts | 309 
 arch/arm/dts/am335x-cbc.dtsi| 136 +
 arch/arm/mach-omap2/am33xx/Kconfig  |   8 +
 board/bosch/cbc/Kconfig |  15 +
 board/bosch/cbc/MAINTAINERS |   6 +
 board/bosch/cbc/Makefile|   9 +
 board/bosch/cbc/README  |  17 ++
 board/bosch/cbc/board.c | 437 
 board/bosch/cbc/board.h |  71 +
 board/bosch/cbc/mux.c   | 171 +++
 configs/am335x_cbc_defconfig|  81 ++
 include/configs/am335x_cbc.h|  84 ++
 15 files changed, 1364 insertions(+)
 create mode 100644 arch/arm/dts/am335x-cbc-u-boot.dtsi
 create mode 100644 arch/arm/dts/am335x-cbc.dts
 create mode 100644 arch/arm/dts/am335x-cbc.dtsi
 create mode 100644 board/bosch/cbc/Kconfig
 create mode 100644 board/bosch/cbc/MAINTAINERS
 create mode 100644 board/bosch/cbc/Makefile
 create mode 100644 board/bosch/cbc/README
 create mode 100644 board/bosch/cbc/board.c
 create mode 100644 board/bosch/cbc/board.h
 create mode 100644 board/bosch/cbc/mux.c
 create mode 100644 configs/am335x_cbc_defconfig
 create mode 100644 include/configs/am335x_cbc.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 9a62b55786..4c6ab18e7c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -2194,6 +2194,7 @@ source "arch/arm/mach-nexell/Kconfig"
 
 source "board/armltd/total_compute/Kconfig"
 
+source "board/bosch/cbc/Kconfig"
 source "board/bosch/shc/Kconfig"
 source "board/bosch/guardian/Kconfig"
 source "board/Marvell/octeontx/Kconfig"
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 5a5706918a..a5f31f0b45 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -378,6 +378,7 @@ dtb-$(CONFIG_AM33XX) += \
am335x-brppt1-spi.dtb \
am335x-brxre1.dtb \
am335x-brsmarc1.dtb \
+   am335x-cbc.dtb \
am335x-draco.dtb \
am335x-evm.dtb \
am335x-evmsk.dtb \
diff --git a/arch/arm/dts/am335x-cbc-u-boot.dtsi 
b/arch/arm/dts/am335x-cbc-u-boot.dtsi
new file mode 100644
index 00..1d33b45acd
--- /dev/null
+++ b/arch/arm/dts/am335x-cbc-u-boot.dtsi
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+ or X11
+/*
+ * Copyright 2022
+ * Lukasz Majewski, DENX Software Engineering, lu...@denx.de
+ */
+
+#include "am33xx-u-boot.dtsi"
+
+/ {
+   chosen {
+   stdout-path = 
+   tick-timer = 
+   };
+};
+
+ {
+   u-boot,dm-pre-reloc;
+};
diff --git a/arch/arm/dts/am335x-cbc.dts b/arch/arm/dts/am335x-cbc.dts
new file mode 100644
index 00..15ce0475ee
--- /dev/null
+++ b/arch/arm/dts/am335x-cbc.dts
@@ -0,0 +1,309 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2022
+ * Lukasz Majewski, DENX Software Engineering, lu...@denx.de
+ */
+
+/dts-v1/;
+#include "am335x-cbc.dtsi"
+
+/ {
+   model = "AM335x Bosch CBC";
+   compatible = "bosch,am335x-cbc", "ti,am33xx";
+
+   gpio_keys {
+   compatible = "gpio-keys";
+   pinctrl-names = "default";
+   pinctrl-0 = <_gpio_pins>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   key@1 {
+   label = "Hand";
+   linux,code = <0x100>;
+   gpios = < 23 GPIO_ACTIVE_LOW>;
+   debounce-interval = <20>;
+   };
+   key@2 {
+   label = "Reset";
+   linux,code = <0x101>;
+   gpios = < 24 GPIO_ACTIVE_LOW>;
+   debounce-interval = <20>;
+   };
+   key@3 {
+   label = "Service";
+   linux,code = <0x102>;
+   gpios = < 22 GPIO_ACTIVE_LOW>;
+   debounce-interval = <20>;
+   };
+   key@4 {
+   label = "B1";
+   gpios = < 3 GPIO_ACTIVE_HIGH>;
+   debounce-interval = <20>;
+   };
+   key@5 {
+   label = "B2";
+   gpios = < 2 GPIO_ACTIVE_HIGH>;
+   debounce-interval = <20>;
+   };
+   key@6 {
+   label = "B3";
+   gpios = < 4 GPIO_ACTIVE_HIGH>;
+

[PATCH v1 1/1] clk: nuvoton: Add support for NPCM845

2022-02-22 Thread Stanley Chu
Add clock controller driver for NPCM845

Signed-off-by: Stanley Chu 
---
 drivers/clk/Makefile  |   1 +
 drivers/clk/nuvoton/Makefile  |   1 +
 drivers/clk/nuvoton/clk_npcm8xx.c | 470 ++
 .../dt-bindings/clock/nuvoton,npcm8xx-clock.h |  27 +
 4 files changed, 499 insertions(+)
 create mode 100644 drivers/clk/nuvoton/Makefile
 create mode 100644 drivers/clk/nuvoton/clk_npcm8xx.c
 create mode 100644 include/dt-bindings/clock/nuvoton,npcm8xx-clock.h

diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 711ae5bc29..21e60bae0c 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_ARCH_ASPEED) += aspeed/
 obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/
 obj-$(CONFIG_ARCH_MTMIPS) += mtmips/
 obj-$(CONFIG_ARCH_MESON) += meson/
+obj-$(CONFIG_ARCH_NPCM) += nuvoton/
 obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/
 obj-$(CONFIG_ARCH_SOCFPGA) += altera/
 obj-$(CONFIG_CLK_AT91) += at91/
diff --git a/drivers/clk/nuvoton/Makefile b/drivers/clk/nuvoton/Makefile
new file mode 100644
index 00..998e5329bb
--- /dev/null
+++ b/drivers/clk/nuvoton/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_ARCH_NPCM8XX) += clk_npcm8xx.o
diff --git a/drivers/clk/nuvoton/clk_npcm8xx.c 
b/drivers/clk/nuvoton/clk_npcm8xx.c
new file mode 100644
index 00..cdb5af5d9f
--- /dev/null
+++ b/drivers/clk/nuvoton/clk_npcm8xx.c
@@ -0,0 +1,470 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2022 Nuvoton Technology Corp.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Register offsets */
+#define CLKSEL 0x04/* clock source selection */
+#define CLKDIV10x08/* clock divider 1 */
+#define CLKDIV20x2C/* clock divider 2 */
+#define CLKDIV30x58/* clock divider 3 */
+#define PLLCON00x0C/* pll0 control */
+#define PLLCON10x10/* pll1 control */
+#define PLLCON20x54/* pll2 control */
+
+/* PLLCON bit filed */
+#define PLLCON_INDVGENMASK(5, 0)
+#define PLLCON_OTDV1   GENMASK(10, 8)
+#define PLLCON_OTDV2   GENMASK(15, 13)
+#define PLLCON_FBDVGENMASK(27, 16)
+
+/* CLKSEL bit filed */
+#define CPUCKSEL   GENMASK(2, 0)
+#define SDCKSELGENMASK(7, 6)
+#define UARTCKSEL  GENMASK(9, 8)
+
+/* CLKDIV1 bit filed */
+#define SPI3CKDIV  GENMASK(10, 6)
+#define MMCCKDIV   GENMASK(15, 11)
+#define UARTDIV1   GENMASK(20, 16)
+#define CLK4DIVGENMASK(27, 26)
+
+/* CLKDIV2 bit filed */
+#define APB5CKDIV  GENMASK(23, 22)
+#define APB2CKDIV  GENMASK(27, 26)
+
+/* CLKDIV3 bit filed */
+#define SPIXCKDIV  GENMASK(5, 1)
+#define SPI0CKDIV  GENMASK(10, 6)
+#define UARTDIV2   GENMASK(15, 11)
+#define SPI1CKDIV  GENMASK(23, 16)
+
+/* Flags */
+#define DIV_TYPE1  BIT(0)  /* div = clkdiv + 1 */
+#define DIV_TYPE2  BIT(1)  /* div = 1 << clkdiv */
+#define PRE_DIV2   BIT(2)  /* Pre divisor = 2 */
+#define POST_DIV2  BIT(3)  /* Post divisor = 2 */
+#define FIXED_PARENT   BIT(4)  /* clock source is fixed */
+
+struct npcm_clk_priv {
+   struct udevice *dev;
+   void __iomem *base;
+};
+
+/* Parameters of PLL configuration */
+struct npcm_clk_pll {
+   const int id;
+   const int parent_id;
+   u32 reg;
+   u32 flags;
+};
+
+/* Parent clock id to clksel mapping */
+struct parent_data {
+   int id;
+   int clksel;
+};
+
+/* Parameters of parent selection */
+struct npcm_clk_select {
+   const int id;
+   const struct parent_data *parents;
+   u32 reg;
+   u32 mask;
+   u8 num_parents;
+   u32 flags;
+};
+
+/* Parameters of clock divider */
+struct npcm_clk_div {
+   const int id;
+   u32 reg;
+   u32 mask;
+   u32 flags;
+};
+
+/* Parent clock map */
+static const struct parent_data pll_parents[] = {
+   {NPCM8XX_CLK_PLL0, 0},
+   {NPCM8XX_CLK_PLL1, 1},
+   {NPCM8XX_CLK_REFCLK, 2},
+   {NPCM8XX_CLK_PLL2DIV2, 3}
+};
+
+static const struct parent_data cpuck_parents[] = {
+   {NPCM8XX_CLK_PLL0, 0},
+   {NPCM8XX_CLK_PLL1, 1},
+   {NPCM8XX_CLK_REFCLK, 2},
+   {NPCM8XX_CLK_PLL2, 7}
+};
+
+static const struct parent_data apb_parent[] = {{NPCM8XX_CLK_AHB, 0}};
+
+static struct npcm_clk_pll npcm8xx_clk_plls[] = {
+   {NPCM8XX_CLK_PLL0, NPCM8XX_CLK_REFCLK, PLLCON0, 0},
+   {NPCM8XX_CLK_PLL1, NPCM8XX_CLK_REFCLK, PLLCON1, 0},
+   {NPCM8XX_CLK_PLL2, NPCM8XX_CLK_REFCLK, PLLCON2, 0},
+   {NPCM8XX_CLK_PLL2DIV2, NPCM8XX_CLK_REFCLK, PLLCON2, POST_DIV2}
+};
+
+static struct npcm_clk_select npcm8xx_clk_selectors[] = {
+   {NPCM8XX_CLK_AHB, cpuck_parents, CLKSEL, CPUCKSEL, 4, 0},
+   {NPCM8XX_CLK_APB2, apb_parent, 0, 0, 1, FIXED_PARENT},
+   {NPCM8XX_CLK_APB5, apb_parent, 0, 0, 1, FIXED_PARENT},
+   {NPCM8XX_CLK_SPI0, apb_parent, 0, 0, 1, FIXED_PARENT},
+   {NPCM8XX_CLK_SPI1, 

[PATCH 3/3] defconfig: Enable DM_PMIC and DM PMIC_TPS65217 on AM335x EVM board

2022-02-22 Thread Lukasz Majewski
As this board now supports DM_I2C, it is safe for it to also use the
DM converted PMIC tps65217 driver.

Signed-off-by: Lukasz Majewski 

---

 configs/am335x_boneblack_vboot_defconfig | 3 +++
 configs/am335x_evm_defconfig | 3 +++
 configs/am335x_evm_spiboot_defconfig | 3 +++
 configs/am335x_hs_evm_defconfig  | 3 +++
 configs/am335x_hs_evm_uart_defconfig | 3 +++
 include/configs/am335x_evm.h | 1 -
 6 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/configs/am335x_boneblack_vboot_defconfig 
b/configs/am335x_boneblack_vboot_defconfig
index c79ffde91c..d46b2ac470 100644
--- a/configs/am335x_boneblack_vboot_defconfig
+++ b/configs/am335x_boneblack_vboot_defconfig
@@ -64,6 +64,9 @@ CONFIG_DM_ETH=y
 CONFIG_PHY_GIGE=y
 CONFIG_MII=y
 CONFIG_DRIVER_TI_CPSW=y
+CONFIG_DM_PMIC=y
+# CONFIG_SPL_DM_PMIC is not set
+CONFIG_PMIC_TPS65217=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_OMAP3_SPI=y
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig
index 33d0fb818f..7f7556971b 100644
--- a/configs/am335x_evm_defconfig
+++ b/configs/am335x_evm_defconfig
@@ -83,6 +83,9 @@ CONFIG_DM_ETH=y
 CONFIG_PHY_GIGE=y
 CONFIG_MII=y
 CONFIG_DRIVER_TI_CPSW=y
+CONFIG_DM_PMIC=y
+# CONFIG_SPL_DM_PMIC is not set
+CONFIG_PMIC_TPS65217=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_OMAP3_SPI=y
diff --git a/configs/am335x_evm_spiboot_defconfig 
b/configs/am335x_evm_spiboot_defconfig
index f8acb7e1a9..f7be718b58 100644
--- a/configs/am335x_evm_spiboot_defconfig
+++ b/configs/am335x_evm_spiboot_defconfig
@@ -77,6 +77,9 @@ CONFIG_PHY_SMSC=y
 CONFIG_DM_ETH=y
 CONFIG_MII=y
 CONFIG_DRIVER_TI_CPSW=y
+CONFIG_DM_PMIC=y
+# CONFIG_SPL_DM_PMIC is not set
+CONFIG_PMIC_TPS65217=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_OMAP3_SPI=y
diff --git a/configs/am335x_hs_evm_defconfig b/configs/am335x_hs_evm_defconfig
index 993fbbcd39..fbb2d1f382 100644
--- a/configs/am335x_hs_evm_defconfig
+++ b/configs/am335x_hs_evm_defconfig
@@ -70,6 +70,9 @@ CONFIG_PHY_SMSC=y
 CONFIG_DM_ETH=y
 CONFIG_MII=y
 CONFIG_DRIVER_TI_CPSW=y
+CONFIG_DM_PMIC=y
+# CONFIG_SPL_DM_PMIC is not set
+CONFIG_PMIC_TPS65217=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_OMAP3_SPI=y
diff --git a/configs/am335x_hs_evm_uart_defconfig 
b/configs/am335x_hs_evm_uart_defconfig
index ecb0526c33..b7008025de 100644
--- a/configs/am335x_hs_evm_uart_defconfig
+++ b/configs/am335x_hs_evm_uart_defconfig
@@ -72,6 +72,9 @@ CONFIG_PHY_SMSC=y
 CONFIG_DM_ETH=y
 CONFIG_MII=y
 CONFIG_DRIVER_TI_CPSW=y
+CONFIG_DM_PMIC=y
+# CONFIG_SPL_DM_PMIC is not set
+CONFIG_PMIC_TPS65217=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_OMAP3_SPI=y
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index 7b02d91e47..42660f09d6 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -166,7 +166,6 @@
 #define CONFIG_SYS_NS16550_COM60x481aa000  /* UART5 */
 
 /* PMIC support */
-#define CONFIG_PMIC_TPS65217
 #define CONFIG_POWER_TPS65910
 
 /* SPL */
-- 
2.20.1



[PATCH 2/3] power: pmic: Provide DM_PMIC support for tps65217 driver

2022-02-22 Thread Lukasz Majewski
The tps65217 PMIC driver is used with am335x SoC based designs.

It is used in the SPL (MLO) as well, so the DM conversion only is
for u-boot proper.

This driver only allows simple reading/writing/dumping of the content
of its registers and requires the DM_I2C for proper operation.

Moreover, new CONFIG_PMIC_TPS65217 has been introduced in Kconfig
to be used with boards, which both support DM_PMIC and DM_I2C.

Signed-off-by: Lukasz Majewski 
---

 drivers/power/pmic/Kconfig |  8 +++
 drivers/power/pmic/pmic_tps65217.c | 82 ++
 2 files changed, 90 insertions(+)

diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig
index ce0adb18a4..c7739228da 100644
--- a/drivers/power/pmic/Kconfig
+++ b/drivers/power/pmic/Kconfig
@@ -306,6 +306,14 @@ config PMIC_TPS65090
only, and you can enable the regulator/charger drivers separately if
required.
 
+config PMIC_TPS65217
+   bool "Enable driver for Texas Instruments TPS65217 PMIC"
+   ---help---
+   The TPS65217 is a PMIC containing several LDOs, DC to DC convertors,
+   FETs and a battery charger. This driver provides register access
+   only, and you can enable the regulator/charger drivers separately if
+   required.
+
 config PMIC_PALMAS
bool "Enable driver for Texas Instruments PALMAS PMIC"
---help---
diff --git a/drivers/power/pmic/pmic_tps65217.c 
b/drivers/power/pmic/pmic_tps65217.c
index c7f532df4d..ccbf223593 100644
--- a/drivers/power/pmic/pmic_tps65217.c
+++ b/drivers/power/pmic/pmic_tps65217.c
@@ -6,8 +6,13 @@
 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include 
 
+#if !CONFIG_IS_ENABLED(DM_PMIC)
 struct udevice *tps65217_dev __section(".data") = NULL;
 
 /**
@@ -148,3 +153,80 @@ int power_tps65217_init(unsigned char bus)
 #endif
return 0;
 }
+#else /* CONFIG_IS_ENABLED(DM_PMIC) */
+static const struct pmic_child_info pmic_children_info[] = {
+   { .prefix = "ldo", .driver = "tps65217_ldo" },
+   { },
+};
+
+static int tps65217_reg_count(struct udevice *dev)
+{
+   return TPS65217_PMIC_NUM_OF_REGS;
+}
+
+static int tps65217_write(struct udevice *dev, uint reg, const uint8_t *buff,
+ int len)
+{
+   if (dm_i2c_write(dev, reg, buff, len)) {
+   pr_err("write error to device: %p register: %#x!\n", dev, reg);
+   return -EIO;
+   }
+
+   return 0;
+}
+
+static int tps65217_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
+{
+   int ret;
+
+   ret = dm_i2c_read(dev, reg, buff, len);
+   if (ret) {
+   pr_err("read error %d from device: %p register: %#x!\n", ret,
+  dev, reg);
+   return -EIO;
+   }
+
+   return 0;
+}
+
+static int tps65217_bind(struct udevice *dev)
+{
+   ofnode regulators_node;
+   int children;
+
+   regulators_node = dev_read_subnode(dev, "regulators");
+   if (!ofnode_valid(regulators_node)) {
+   debug("%s: %s regulators subnode not found!\n", __func__,
+ dev->name);
+   return -ENXIO;
+   }
+
+   debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
+
+   children = pmic_bind_children(dev, regulators_node, pmic_children_info);
+   if (!children)
+   debug("%s: %s - no child found\n", __func__, dev->name);
+
+   /* Always return success for this device */
+   return 0;
+}
+
+static struct dm_pmic_ops tps65217_ops = {
+   .reg_count = tps65217_reg_count,
+   .read = tps65217_read,
+   .write = tps65217_write,
+};
+
+static const struct udevice_id tps65217_ids[] = {
+   { .compatible = "ti,tps65217" },
+   { }
+};
+
+U_BOOT_DRIVER(pmic_tps65217) = {
+   .name = "tps65217 pmic",
+   .id = UCLASS_PMIC,
+   .of_match = tps65217_ids,
+   .bind = tps65217_bind,
+   .ops = _ops,
+};
+#endif
-- 
2.20.1



[PATCH 1/3] power: Rename CONFIG_POWER_TPS65217 with CONFIG_PMIC_TPS65217

2022-02-22 Thread Lukasz Majewski
Up till now the CONFIG_POWER_TPS65217 has been defined in several header
files for am335x SoC.

This patch renames it to CONFIG_PMIC_TPS65217, which better reflects the
role of this IC circuit.

Signed-off-by: Lukasz Majewski 
---

 drivers/power/pmic/Makefile | 2 +-
 include/configs/am335x_evm.h| 2 +-
 include/configs/am335x_guardian.h   | 2 +-
 include/configs/am335x_shc.h| 2 +-
 include/configs/am335x_sl50.h   | 2 +-
 include/configs/brppt1.h| 2 +-
 include/configs/bur_am335x_common.h | 2 +-
 include/configs/chiliboard.h| 2 +-
 scripts/config_whitelist.txt| 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile
index 401cde32cf..584d6e0e78 100644
--- a/drivers/power/pmic/Makefile
+++ b/drivers/power/pmic/Makefile
@@ -36,7 +36,7 @@ obj-$(CONFIG_POWER_MUIC_MAX8997) += muic_max8997.o
 obj-$(CONFIG_POWER_PCA9450) += pmic_pca9450.o
 obj-$(CONFIG_POWER_PFUZE100) += pmic_pfuze100.o
 obj-$(CONFIG_POWER_PFUZE3000) += pmic_pfuze3000.o
-obj-$(CONFIG_POWER_TPS65217) += pmic_tps65217.o
+obj-$(CONFIG_PMIC_TPS65217) += pmic_tps65217.o
 obj-$(CONFIG_POWER_TPS65218) += pmic_tps62362.o
 obj-$(CONFIG_POWER_TPS65218) += pmic_tps65218.o
 obj-$(CONFIG_POWER_TPS65910) += pmic_tps65910.o
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index 9070845b7a..7b02d91e47 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -166,7 +166,7 @@
 #define CONFIG_SYS_NS16550_COM60x481aa000  /* UART5 */
 
 /* PMIC support */
-#define CONFIG_POWER_TPS65217
+#define CONFIG_PMIC_TPS65217
 #define CONFIG_POWER_TPS65910
 
 /* SPL */
diff --git a/include/configs/am335x_guardian.h 
b/include/configs/am335x_guardian.h
index 10a95a10a0..e6e7000529 100644
--- a/include/configs/am335x_guardian.h
+++ b/include/configs/am335x_guardian.h
@@ -95,7 +95,7 @@
 #define CONFIG_SYS_NS16550_COM60x481aa000  /* UART5 */
 
 /* PMIC support */
-#define CONFIG_POWER_TPS65217
+#define CONFIG_PMIC_TPS65217
 
 /* Bootcount using the RTC block */
 #define CONFIG_SYS_BOOTCOUNT_LE
diff --git a/include/configs/am335x_shc.h b/include/configs/am335x_shc.h
index 5ed4eb3b3c..5ac46bf42b 100644
--- a/include/configs/am335x_shc.h
+++ b/include/configs/am335x_shc.h
@@ -156,7 +156,7 @@
 #define CONFIG_SYS_NS16550_COM60x481aa000  /* UART5 */
 
 /* PMIC support */
-#define CONFIG_POWER_TPS65217
+#define CONFIG_PMIC_TPS65217
 
 /* SPL */
 
diff --git a/include/configs/am335x_sl50.h b/include/configs/am335x_sl50.h
index 0da98975ad..e8233c6cca 100644
--- a/include/configs/am335x_sl50.h
+++ b/include/configs/am335x_sl50.h
@@ -50,7 +50,7 @@
 #define CONFIG_SYS_NS16550_COM60x481aa000  /* UART5 */
 
 /* PMIC support */
-#define CONFIG_POWER_TPS65217
+#define CONFIG_PMIC_TPS65217
 #define CONFIG_POWER_TPS65910
 
 /* SPL */
diff --git a/include/configs/brppt1.h b/include/configs/brppt1.h
index d5458edbdb..a9d4b84873 100644
--- a/include/configs/brppt1.h
+++ b/include/configs/brppt1.h
@@ -22,7 +22,7 @@
 #define V_OSCK 2600  /* Clock output from T2 */
 #define V_SCLK (V_OSCK)
 
-#define CONFIG_POWER_TPS65217
+#define CONFIG_PMIC_TPS65217
 
 /*
  * When we have NAND flash we expect to be making use of mtdparts,
diff --git a/include/configs/bur_am335x_common.h 
b/include/configs/bur_am335x_common.h
index 9b2e8b5c6e..129356b87f 100644
--- a/include/configs/bur_am335x_common.h
+++ b/include/configs/bur_am335x_common.h
@@ -26,7 +26,7 @@
 /* Timer information */
 #define CONFIG_SYS_PTV 2   /* Divisor: 2^(PTV+1) => 8 */
 #define CONFIG_SYS_TIMERBASE   0x4804  /* Use Timer2 */
-#define CONFIG_POWER_TPS65217
+#define CONFIG_PMIC_TPS65217
 
 #include 
 
diff --git a/include/configs/chiliboard.h b/include/configs/chiliboard.h
index fe49627263..85e8edab23 100644
--- a/include/configs/chiliboard.h
+++ b/include/configs/chiliboard.h
@@ -107,7 +107,7 @@
 #define CONFIG_SYS_NS16550_COM60x481aa000  /* UART5 */
 
 /* PMIC support */
-#define CONFIG_POWER_TPS65217
+#define CONFIG_PMIC_TPS65217
 
 /* SPL */
 /* Bootcount using the RTC block */
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 6b21e3918d..cf007c08a5 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -640,6 +640,7 @@ CONFIG_PM
 CONFIG_PMC_BR_PRELIM
 CONFIG_PMC_OR_PRELIM
 CONFIG_PME_PLAT_CLK_DIV
+CONFIG_PMIC_TPS65217
 CONFIG_PMU
 CONFIG_PMW_BASE
 CONFIG_POST
@@ -658,7 +659,6 @@ CONFIG_POWER_PFUZE3000_I2C_ADDR
 CONFIG_POWER_SPI
 CONFIG_POWER_TPS62362
 CONFIG_POWER_TPS65090_EC
-CONFIG_POWER_TPS65217
 CONFIG_POWER_TPS65218
 CONFIG_POWER_TPS65910
 CONFIG_PPC_CLUSTER_START
-- 
2.20.1