Re: [PATCH] arm: sunxi: dram: restore previous value in DRAM

2022-04-23 Thread Samuel Holland
On 2/13/22 9:10 AM, Andrei Lalaev wrote:
> It's better to restore previous value at offset because otherwise the
> function can corrupt memory reserved by Linux (e.g. ramoops).

With this patch, does ramoops work for you? and on which hardware? If so, I am
definitely in favor of applying this patch.

I'm a bit surprised that DRAM contents are maintained (this isn't the only place
where they could be destroyed). I suppose the reset state of the PRCM enables
pad hold, which would put the DRAM in self-refresh. So we just have to be
careful during DRAM controller init.

Regards,
Samuel

> Signed-off-by: Andrei Lalaev 
> ---
>  arch/arm/mach-sunxi/dram_helpers.c | 14 +++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/mach-sunxi/dram_helpers.c 
> b/arch/arm/mach-sunxi/dram_helpers.c
> index 2c873192e6..ed6db14f3c 100644
> --- a/arch/arm/mach-sunxi/dram_helpers.c
> +++ b/arch/arm/mach-sunxi/dram_helpers.c
> @@ -32,12 +32,20 @@ void mctl_await_completion(u32 *reg, u32 mask, u32 val)
>  #ifndef CONFIG_MACH_SUNIV
>  bool mctl_mem_matches(u32 offset)
>  {
> + ulong addr = CONFIG_SYS_SDRAM_BASE + offset;
> + u32 prev_val = readl(addr);
> + bool ret = false;
> +
>   /* Try to write different values to RAM at two addresses */
>   writel(0, CONFIG_SYS_SDRAM_BASE);
> - writel(0xaa55aa55, (ulong)CONFIG_SYS_SDRAM_BASE + offset);
> + writel(0xaa55aa55, addr);
>   dsb();
>   /* Check if the same value is actually observed when reading back */
> - return readl(CONFIG_SYS_SDRAM_BASE) ==
> -readl((ulong)CONFIG_SYS_SDRAM_BASE + offset);
> + ret = readl(CONFIG_SYS_SDRAM_BASE) == readl(addr);
> +
> + /* Restore previous value */
> + writel(prev_val, addr);
> +
> + return ret;
>  }
>  #endif
> 



Re: [PATCH] clk: sunxi: h6_r: Correct the driver name

2022-04-23 Thread Heinrich Schuchardt

On 4/23/22 23:07, Samuel Holland wrote:

H6 is from the sun50i family, not sun6i.

Signed-off-by: Samuel Holland 


Cf. https://linux-sunxi.org/Allwinner_SoC_Family

Reviewed-by: Heinrich Schuchardt 


---

  drivers/clk/sunxi/clk_h6_r.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/sunxi/clk_h6_r.c b/drivers/clk/sunxi/clk_h6_r.c
index b9e527e16a..2e0bbaa903 100644
--- a/drivers/clk/sunxi/clk_h6_r.c
+++ b/drivers/clk/sunxi/clk_h6_r.c
@@ -50,8 +50,8 @@ static const struct udevice_id h6_r_clk_ids[] = {
{ }
  };

-U_BOOT_DRIVER(clk_sun6i_h6_r) = {
-   .name   = "sun6i_h6_r_ccu",
+U_BOOT_DRIVER(clk_sun50i_h6_r) = {
+   .name   = "sun50i_h6_r_ccu",
.id = UCLASS_CLK,
.of_match   = h6_r_clk_ids,
.priv_auto  = sizeof(struct ccu_priv),




Pull request for efi-2022-07-rc1-3

2022-04-23 Thread Heinrich Schuchardt

Dear Tom,

The following changes since commit faeb5641131ba0bfafa5ed61dd03b98b1f2a5edb:

  Merge https://gitlab.denx.de/u-boot/custodians/u-boot-pmic 
(2022-04-22 11:06:38 -0400)


are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-efi.git 
tags/efi-2022-07-rc1-3


for you to fetch changes up to d97e98c887ed8fa4a339350c02f093f03cd1cf4d:

  efi_loader: disk: use udevice instead of blk_desc (2022-04-23 
22:05:41 +0200)


Gitlab CI showed no problem:
https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/11846


Pull request for efi-2022-07-rc1-3

Documentation:

* Document image size parameter of bootefi command

UEFI:

* avoid building partition support in SPL/TPL where not required
* improve integration of EFI subsystem and driver model
* restore ability to boot arbitrary blob


AKASHI Takahiro (19):
  disk: include errno.h explicitly in part.h
  disk: enable function prototypes in part.h for SPL/TPL
  disk: define nullified functions for !PARTITIONS
  sandbox: move a function prototype
  efi_loader: PARTITION_UUIDS should be optional
  efi_loader: disk: compile efi_disk when CONFIG_BLK
  disk: don't compile in partition support for spl/tpl if not 
really necessary

  dm: tag: change ENOSPC to ENOMEM
  dm: tag: add some document
  test: dm: add tests for tag support
  dm: disk: add UCLASS_PARTITION
  dm: blk: add a device-probe hook for scanning disk partitions
  efi_loader: split efi_init_obj_list() into two stages
  efi_loader: disk: a helper function to create efi_disk objects 
from udevice
  efi_loader: disk: not create BLK device for 
BLK(IF_TYPE_EFI_LOADER) devices

  efi_loader: disk: a helper function to delete efi_disk objects
  efi_loader: disk: not delete BLK device for 
BLK(IF_TYPE_EFI_LOADER) devices

  dm: disk: add read/write interfaces with udevice
  efi_loader: disk: use udevice instead of blk_desc

Heinrich Schuchardt (1):
  doc: update bootefi man-page

Kyle Evans (1):
  cmd: bootefi: restore ability to boot arbitrary blob

Mark Kettenis (1):
  doc: board: apple: Mention M1 Ultra support

Masahisa Kojima (1):
  bootmenu: fix menu API error handling

Vagrant Cascadian (1):
  tools: kwboot: Fix spelling of "followed" in kwboot.1

 cmd/bootefi.c   |  36 ++--
 cmd/bootmenu.c  |   4 +-
 common/board_r.c|   2 +-
 common/main.c   |   7 +-
 disk/Kconfig|  37 +++--
 disk/Makefile   |   3 +
 disk/disk-uclass.c  | 247 +++
 doc/board/apple/m1.rst  |   3 +-
 doc/develop/driver-model/design.rst |  21 +++
 doc/kwboot.1|   2 +-
 doc/usage/cmd/bootefi.rst   |  21 ++-
 drivers/block/blk-uclass.c  |   4 +
 drivers/core/tag.c  |   4 +-
 include/dm/uclass-id.h  |   1 +
 include/efi_loader.h|   6 +-
 include/part.h  |  39 -
 include/sandboxblockdev.h   |   2 +
 lib/efi_driver/efi_block_device.c   |  34 ++--
 lib/efi_loader/Kconfig  |   5 +-
 lib/efi_loader/Makefile |   2 +-
 lib/efi_loader/efi_device_path.c|   9 +-
 lib/efi_loader/efi_disk.c   | 321 
+++-

 lib/efi_loader/efi_setup.c  |  62 +--
 test/dm/Makefile|   1 +
 test/dm/tag.c   |  84 ++
 25 files changed, 789 insertions(+), 168 deletions(-)
 create mode 100644 disk/disk-uclass.c
 create mode 100644 test/dm/tag.c


[PATCH] clk: sunxi: h6_r: Correct the driver name

2022-04-23 Thread Samuel Holland
H6 is from the sun50i family, not sun6i.

Signed-off-by: Samuel Holland 
---

 drivers/clk/sunxi/clk_h6_r.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/sunxi/clk_h6_r.c b/drivers/clk/sunxi/clk_h6_r.c
index b9e527e16a..2e0bbaa903 100644
--- a/drivers/clk/sunxi/clk_h6_r.c
+++ b/drivers/clk/sunxi/clk_h6_r.c
@@ -50,8 +50,8 @@ static const struct udevice_id h6_r_clk_ids[] = {
{ }
 };
 
-U_BOOT_DRIVER(clk_sun6i_h6_r) = {
-   .name   = "sun6i_h6_r_ccu",
+U_BOOT_DRIVER(clk_sun50i_h6_r) = {
+   .name   = "sun50i_h6_r_ccu",
.id = UCLASS_CLK,
.of_match   = h6_r_clk_ids,
.priv_auto  = sizeof(struct ccu_priv),
-- 
2.35.1



Re: [PATCH] sunxi: fix initial environment loading without MMC

2022-04-23 Thread Samuel Holland
Hi Andre,

On 4/20/22 7:34 PM, Andre Przywara wrote:
> Commit e42dad4168fe ("sunxi: use boot source for determining environment
> location") changed our implementation of env_get_location() and enabled
> it for every board, even those without MMC support (like the C.H.I.P.
> boards). However the default fallback location of ENVL_FAT does not cope
> very well without MMC support compiled in, so the board hangs when trying
> to initially load the environment.
> 
> Change the default fallback location to be ENVL_FAT only when the FAT
> environment support is enabled, and use ENVL_NOWHERE and ENVL_UBI as
> alternative fallbacks, when those sources are enabled.
> 
> This fixes U-Boot loading on the C.H.I.P. boards.
> 
> Fixes: e42dad4168fe ("sunxi: use boot source for determining environment 
> location")
> Reported-by: Chris Morgan 
> Signed-off-by: Andre Przywara 
> ---
>  board/sunxi/board.c | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index 89324159d55..befb6076ca6 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -132,7 +132,14 @@ void i2c_init_board(void)
>   */
>  enum env_location env_get_location(enum env_operation op, int prio)
>  {
> - enum env_location boot_loc = ENVL_FAT;
> + enum env_location boot_loc;
> +
> + if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE))
> + boot_loc = ENVL_NOWHERE;
> + else if (IS_ENABLED(CONFIG_ENV_IS_IN_FAT))
> + boot_loc = ENVL_FAT;
> + else if (IS_ENABLED(CONFIG_ENV_IS_IN_UBI))
> + boot_loc = ENVL_UBI;

This could leave boot_loc uninitialized. And there is still an unconditional use
of ENVL_FAT in the BOOT_DEVICE_MMCx case.

>   gd->env_load_prio = prio;

I don't think the hook is supposed to change this variable.

I'm still a bit confused on the fallback logic you have in place. Splitting it
up into three blocks doesn't help. If the goal is to load the environment from
the boot device, while preferring filesystems over raw block devices, I propose
the following:

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 427113534b..27508bd306 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -129,26 +129,38 @@
  * Try to use the environment from the boot source first.
  * For MMC, this means a FAT partition on the boot device (SD or eMMC).
  * If the raw MMC environment is also enabled, this is tried next.
- * SPI flash falls back to FAT (on SD card).
  */
 enum env_location env_get_location(enum env_operation op, int prio)
 {
-   enum env_location boot_loc = ENVL_FAT;
+   if (prio > 1)
+   return ENVL_UNKNOWN;

-   gd->env_load_prio = prio;
+   if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE))
+   return ENVL_NOWHERE;

switch (sunxi_get_boot_device()) {
case BOOT_DEVICE_MMC1:
case BOOT_DEVICE_MMC2:
-   boot_loc = ENVL_FAT;
+   if (prio == 0) {
+   if (IS_ENABLED(CONFIG_ENV_IS_IN_EXT4))
+   return ENVL_EXT4;
+   if (IS_ENABLED(CONFIG_ENV_IS_IN_FAT))
+   return ENVL_FAT;
+   }
+   if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
+   return ENVL_MMC;
break;
case BOOT_DEVICE_NAND:
+   if (prio == 0 && IS_ENABLED(CONFIG_ENV_IS_IN_UBI))
+   return ENVL_UBI;
if (IS_ENABLED(CONFIG_ENV_IS_IN_NAND))
-   boot_loc = ENVL_NAND;
+   return ENVL_NAND;
break;
case BOOT_DEVICE_SPI:
+   if (prio == 0 && IS_ENABLED(CONFIG_ENV_IS_IN_UBI))
+   return ENVL_UBI;
if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
-   boot_loc = ENVL_SPI_FLASH;
+   return ENVL_SPI_FLASH;
break;
case BOOT_DEVICE_BOARD:
break;
@@ -156,23 +168,6 @@
break;
}

-   /* Always try to access the environment on the boot device first. */
-   if (prio == 0)
-   return boot_loc;
-
-   if (prio == 1) {
-   switch (boot_loc) {
-   case ENVL_SPI_FLASH:
-   return ENVL_FAT;
-   case ENVL_FAT:
-   if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
-   return ENVL_MMC;
-   break;
-   default:
-   break;
-   }
-   }
-
return ENVL_UNKNOWN;
 }


Regards,
Samuel


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

2022-04-23 Thread Christoph Fritz
Hello Stefano,

 could you please pick up this patch?

bye
 -- Christoph

On Tue, 2022-04-05 at 12:29 +0200, 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 
> Reviewed-by: Peng Fan 
> Reviewed-by: Fabio Estevam 
> ---
>  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(®s->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(®s->gpio_pdir) >> offset) & 0x01;
> +   if (imx_rgpio2p_bank_get_direction(regs, offset) ==
> +   IMX_RGPIO2P_DIRECTION_IN)
> +   return (readl(®s->gpio_pdir) >> offset) & 0x01;
> +
> +   return (readl(®s->gpio_pdor) >> offset) & 0x01;
>  }
>  
>  static int  imx_rgpio2p_direction_input(struct udevice *dev,
> unsigned offset)



Re: [PATCH 6/7] efi_loader: disk: compile efi_disk when CONFIG_BLK

2022-04-23 Thread Heinrich Schuchardt

On 4/21/22 02:30, AKASHI Takahiro wrote:

On Wed, Apr 20, 2022 at 09:42:00AM +0200, Heinrich Schuchardt wrote:

On 4/19/22 03:01, AKASHI Takahiro wrote:

Now we can build efi_loader with block device support (CONFIG_BLK) and
without CONFIG_PARTITIONS.
So change Makefile.

Signed-off-by: AKASHI Takahiro 
---
   lib/efi_loader/Makefile | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index 034d26cf0109..25cefe01 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -68,7 +68,7 @@ obj-y += efi_watchdog.o
   obj-$(CONFIG_EFI_ESRT) += efi_esrt.o
   obj-$(CONFIG_LCD) += efi_gop.o
   obj-$(CONFIG_DM_VIDEO) += efi_gop.o
-obj-$(CONFIG_PARTITIONS) += efi_disk.o
+obj-$(CONFIG_BLK) += efi_disk.o


Why do we need efi_disk.o if CONFIG_PARTITIONS=n?


Why do you think so?
As you admitted in your comment at:
https://lists.denx.de/pipermail/u-boot/2022-April/481546.html

GPT(EFI_PARTITION) is optional under the current implementation
("EFI_LOADER should imply EFI_PARTITION" in your words).
As a matter of fact, EFI_LOADER (and efi_disk.o) can be compiled in
even without any partition table types.

If you don't agree, please drop this patch.
I don't care because it won't help reducing SPL code size anyway.


Without this patch db-88f6720_defconfig does not build after applying
the rest of the series:

arm-linux-gnueabi-ld.bfd: lib/efi_loader/efi_file.o: in function
`efi_file_from_path':
lib/efi_loader/efi_file.c:1095: undefined reference to `efi_fs_from_path'
arm-linux-gnueabi-ld.bfd: lib/efi_loader/efi_var_file.o: in function
`efi_set_blk_dev_to_system_partition':
lib/efi_loader/efi_var_file.c:54: undefined reference to
`efi_system_partition'

Best regards

Heinrich



-Takahiro Akashi


How can we be UEFI compliant without partition support?

Best regards

Heinrich


   obj-$(CONFIG_NET) += efi_net.o
   obj-$(CONFIG_GENERATE_ACPI_TABLE) += efi_acpi.o
   obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o






Re: [PATCH 7/7] binman: Refuse to replace sections for now

2022-04-23 Thread Alper Nebi Yasak
On 20/04/2022 00:54, Simon Glass wrote:
> On Sun, 27 Mar 2022 at 09:32, Alper Nebi Yasak  
> wrote:
>>
>> Binman interfaces allow attempts to replace any entry in the image with
>> arbitrary data. When trying to replace sections, the changes in the
>> section entry's data are not propagated to its child entries. This,
>> combined with how sections rebuild their contents from its children,
>> eventually causes the replaced contents to be silently overwritten by
>> rebuilt contents equivalent to the original data.
>>
>> Add a simple test for replacing a section that is currently failing due
>> to this behaviour, and mark it as an expected failure. Also, raise an
>> error when replacing a section instead of silently pretending it was
>> replaced.
>>
>> Signed-off-by: Alper Nebi Yasak 
>> ---
>>
>>  tools/binman/etype/section.py |  3 +++
>>  tools/binman/ftest.py |  9 
>>  .../test/234_replace_section_simple.dts   | 23 +++
>>  3 files changed, 35 insertions(+)
>>  create mode 100644 tools/binman/test/234_replace_section_simple.dts
> 
> Reviewed-by: Simon Glass 
> 
> Is it not better to assertRaises() and check that the error message is
> as expected?

IMO, that would imply the tested 'binman replace' call should raise an
error instead of replacing the data. The test should work as-is, and
when section replacement is fixed we can just remove the expectedFailure
line to be strict about it.

> 
>>
>> diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
>> index ccac658c1831..bd67238b9199 100644
>> --- a/tools/binman/etype/section.py
>> +++ b/tools/binman/etype/section.py
>> @@ -788,6 +788,9 @@ def ReadChildData(self, child, decomp=True, 
>> alt_format=None):
>>  data = new_data
>>  return data
>>
>> +def WriteData(self, data, decomp=True):
>> +self.Raise("Replacing sections is not implemented yet")
>> +
>>  def WriteChildData(self, child):
>>  return True
>>
>> diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
>> index 43bec4a88841..058651cc18a0 100644
>> --- a/tools/binman/ftest.py
>> +++ b/tools/binman/ftest.py
>> @@ -5641,6 +5641,15 @@ def testReplaceFitSubentryLeafSmallerSize(self):
>>  self.assertIsNotNone(path)
>>  self.assertEqual(expected_fdtmap, fdtmap)
>>
>> +@unittest.expectedFailure
>> +def testReplaceSectionSimple(self):
>> +"""Test replacing a simple section with arbitrary data"""
>> +new_data = b'w' * len(COMPRESS_DATA + U_BOOT_DATA)
>> +data, expected_fdtmap, _ = self._RunReplaceCmd(
>> +'section', new_data,
>> +dts='234_replace_section_simple.dts')
>> +self.assertEqual(new_data, data)
>> +
>>
>>  if __name__ == "__main__":
>>  unittest.main()
>> diff --git a/tools/binman/test/234_replace_section_simple.dts 
>> b/tools/binman/test/234_replace_section_simple.dts
>> new file mode 100644
>> index ..c9d5c3285615
>> --- /dev/null
>> +++ b/tools/binman/test/234_replace_section_simple.dts
>> @@ -0,0 +1,23 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +/dts-v1/;
>> +
>> +/ {
>> +   binman {
>> +   allow-repack;
>> +
>> +   u-boot-dtb {
>> +   };
>> +
>> +   section {
>> +   blob {
>> +   filename = "compress";
>> +   };
>> +
>> +   u-boot {
>> +   };
>> +   };
>> +
>> +   fdtmap {
>> +   };
>> +   };
>> +};
>> --
>> 2.35.1
>>


Re: [PATCH] arm: apple: Point stdout-path to framebuffer when keyboard present

2022-04-23 Thread Tom Rini
On Tue, Apr 19, 2022 at 09:20:31PM +0200, Mark Kettenis wrote:

> Unless you have a spare Apple Silicon machine, getting access to
> the serial port on Apple Silicon machines requires special
> hardware. Given that most machines come with a built-in screen
> the framebuffer is likely to be the most convenient output device
> for most users. While U-Boot will output to both serial and
> framebuffer, OSes might not. Therefore set stdout-path to point
> at /chosen/framebuffer when a keyboard is connected to the machine.
> 
> This behaviour can be overridden by setting the "stdout" variable
> in the U-Boot environment. I addition to that keep the serial
> console as the default when running under the m1n1 hypervisor.
> The m1n1 hypervisor virtualizes the serial port such that it
> can be easily accessed from any other machine with a USB port.
> 
> Signed-off-by: Mark Kettenis 
> Reviewed-by: Janne Grunau 
> Tested-by: Janne Grunau 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] arm: apple: Don't clear framebuffer

2022-04-23 Thread Tom Rini
On Tue, Apr 19, 2022 at 09:10:29PM +0200, Mark Kettenis wrote:

> Enable CONFIG_NO_FB_CLEAR to preserve the Asahi logo. Since that
> logo is drawn on a black background also enable
> CONFIG_SYS_WHITE_ON_BLACK such that text printed by U-Boot is still
> visible.
> 
> Signed-off-by: Mark Kettenis 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v3] Allow colon in PXE bootfile URLs

2022-04-23 Thread Tom Rini
On Sat, Apr 16, 2022 at 11:36:43AM -0400, Lyle Franklin wrote:

> - U-boot's PXE flow supports prefixing your bootfile name with an
>   IP address to fetch from a server other than the DHCP server,
>   e.g. `hostIPaddr:bootfilename`:
>   
> https://github.com/u-boot/u-boot/commit/a93907c43f847f076dd0e34ee3b69b5e8e6d0d29
> - However, this breaks bootfile paths which contain a colon, e.g.
>   `f0:ad:4e:10:1b:87/7/pxelinux.cfg/default`
> - This patch checks whether the `hostIPaddr` prefix is a valid
>   IP address before overriding the serverIP otherwise the whole
>   bootfile path is preserved
> 
> Signed-off-by: Lyle Franklin 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] fdt: Fix TPL SEPARATE_BSS check when locating DTB

2022-04-23 Thread Tom Rini
On Sat, Apr 16, 2022 at 10:12:31AM +1000, Andrew Abbott wrote:

> Commit 690af71850149bf242502f688eca80fb302d1f76 changed this condition
> from an explicit
> 
> IS_ENABLED(CONFIG_SPL_SEPARATE_BSS)
> 
> to
> 
> CONFIG_IS_ENABLED(SEPARATE_BSS)
> 
> The documentation for CONFIG_IS_ENABLED() in include/linux/kconfig.h
> implies that we will get the correct behaviour, but the actual behaviour
> differs such that this condition is now always false.
> 
> This stopped TPL being able to load the device tree blob at least on the
> ROCKPro64 board (RK3399 SoC), since the wrong device tree location was
> chosen.
> 
> The issues causing this behaviour with CONFIG_IS_ENABLED() are:
> 
> 1. The documentation implies that CONFIG_SPL_BUILD =>
>CONFIG_SPL_ is considered before the TPL equivalent.
> 
>Actually, the TPL options have higher priority - see definition of
>_CONFIG_PREFIX.
> 
> 2. The documentation implies a fallthrough, eg. if CONFIG_SPL_BUILD is
>defined but the CONFIG_SPL_ is not, then it will proceed to
>check if CONFIG_TPL_BUILD
> 
>Actually, if CONFIG_TPL_BUILD is defined, then it stops there
>and CONFIG_SPL_BUILD is not considered - see definition of
>_CONFIG_PREFIX.
> 
>During TPL build, at least for the ROCKPro64, both CONFIG_TPL_BUILD
>and CONFIG_SPL_BUILD are defined, but because of the above, only TPL
>options are considered. Since there is no CONFIG_TPL_SEPARATE_BSS,
>this fails.
> 
> Fixes: 690af71850 ("fdt: Correct condition for SEPARATE_BSS")
> Signed-off-by: Andrew Abbott 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2] cmd: adc: Add support for storing ADC result in env variable

2022-04-23 Thread Tom Rini
On Thu, Apr 14, 2022 at 06:52:25PM +0200, Marek Vasut wrote:

> Add the ability to save ADC conversion result in an environment
> variable. This is useful for further arbitrary processing by the
> U-Boot scripts.
> 
> Signed-off-by: Marek Vasut 
> Cc: Fabrice Gasnier 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Simon Glass 
> Reviewed-by: Patrick Delaunay 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] fdt: Add -q option to fdt addr for distro_bootcmd

2022-04-23 Thread Tom Rini
On Thu, Mar 31, 2022 at 11:53:22AM +0100, Peter Hoyes wrote:

> From: Peter Hoyes 
> 
> distro_bootcmd uses this construct a few times to test $fdt_addr_r,
> and fall back on $fdtcontroladdr if not set/invalid:
> 
> if fdt addr ${fdt_addr_r}; then
> ...
> else
> ...
> fi
> 
> If the `fdt addr` test fails, it prints the following  message on the
> console, suggesting there is an error when there is not:
> 
> libfdt fdt_check_header(): FDT_ERR_BADMAGIC
> 
> To remove this potentially confusing error message, this patch adds -q
> as a 'quiet' option for fdt addr, and uses this flag in
> config_distro_bootcmd.h
> 
> Signed-off-by: Peter Hoyes 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[RFC PATCH] spl: spl_nand: Fix bad block handling in fitImage

2022-04-23 Thread Michael Trimarchi
If the fitImage has some bad block in fit image area, the
offset must be recalulcated. This should be done always.
After implementing it in mxs now is possible to call the function
even for that platform

Signed-off-by: Michael Trimarchi 
---
 common/spl/spl_nand.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index fc61b447a5..82a10ffa63 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -43,15 +43,12 @@ static ulong spl_nand_fit_read(struct spl_load_info *load, 
ulong offs,
   ulong size, void *dst)
 {
int err;
-#ifdef CONFIG_SYS_NAND_BLOCK_SIZE
ulong sector;
 
sector = *(int *)load->priv;
-   offs = sector + nand_spl_adjust_offset(sector, offs - sector);
-#else
offs *= load->bl_len;
size *= load->bl_len;
-#endif
+   offs = sector + nand_spl_adjust_offset(sector, offs - sector);
err = nand_spl_load_image(offs, size, dst);
if (err)
return 0;
-- 
2.25.1



[PATCH 2/2] mtd: nand: mxs_nand_spl: Fix bad block skipping

2022-04-23 Thread Michael Trimarchi
The file was fill of problems and bugs. The bad block are marked
beginning of erase block. The first erase block was never checked
and the specific function to skip bad block in fit image was never
implemented. The imx8mn bootrom seems that not handle the bad
block as expected so this needed later to switch from boot rom
loader to uboot spl one

Signed-off-by: Michael Trimarchi 
---
 drivers/mtd/nand/raw/mxs_nand_spl.c | 90 -
 1 file changed, 49 insertions(+), 41 deletions(-)

diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c 
b/drivers/mtd/nand/raw/mxs_nand_spl.c
index 59a67ee414..c1a833d6c8 100644
--- a/drivers/mtd/nand/raw/mxs_nand_spl.c
+++ b/drivers/mtd/nand/raw/mxs_nand_spl.c
@@ -218,14 +218,14 @@ void nand_init(void)
mxs_nand_setup_ecc(mtd);
 }
 
-int nand_spl_load_image(uint32_t offs, unsigned int size, void *buf)
+int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst)
 {
-   struct nand_chip *chip;
-   unsigned int page;
+   unsigned int sz;
+   unsigned int block, lastblock;
+   unsigned int page, page_offset;
unsigned int nand_page_per_block;
-   unsigned int sz = 0;
+   struct nand_chip *chip;
u8 *page_buf = NULL;
-   u32 page_off;
 
chip = mtd_to_nand(mtd);
if (!chip->numchips)
@@ -235,47 +235,42 @@ int nand_spl_load_image(uint32_t offs, unsigned int size, 
void *buf)
if (!page_buf)
return -ENOMEM;
 
-   page = offs >> chip->page_shift;
-   page_off = offs & (mtd->writesize - 1);
+   /* offs has to be aligned to a page address! */
+   block = offs / mtd->erasesize;
+   lastblock = (offs + size - 1) / mtd->erasesize;
+   page = (offs % mtd->erasesize) / mtd->writesize;
+   page_offset = offs % mtd->writesize;
nand_page_per_block = mtd->erasesize / mtd->writesize;
 
-   debug("%s offset:0x%08x len:%d page:%x\n", __func__, offs, size, page);
-
-   while (size) {
-   if (mxs_read_page_ecc(mtd, page_buf, page) < 0)
-   return -1;
-
-   if (size > (mtd->writesize - page_off))
-   sz = (mtd->writesize - page_off);
-   else
-   sz = size;
-
-   memcpy(buf, page_buf + page_off, sz);
-
-   offs += mtd->writesize;
-   page++;
-   buf += (mtd->writesize - page_off);
-   page_off = 0;
-   size -= sz;
-
-   /*
-* Check if we have crossed a block boundary, and if so
-* check for bad block.
-*/
-   if (!(page % nand_page_per_block)) {
-   /*
-* Yes, new block. See if this block is good. If not,
-* loop until we find a good block.
-*/
-   while (is_badblock(mtd, offs, 1)) {
-   page = page + nand_page_per_block;
-   /* Check i we've reached the end of flash. */
-   if (page >= mtd->size >> chip->page_shift) {
+   while (block <= lastblock && size >= 0) {
+   if (!is_badblock(mtd, mtd->erasesize * block, 1)) {
+   /* Skip bad blocks */
+   while (page < nand_page_per_block) {
+   int curr_page = nand_page_per_block * block + 
page;
+
+   if (mxs_read_page_ecc(mtd, page_buf, curr_page) 
< 0) {
free(page_buf);
-   return -ENOMEM;
+   return -EIO;
}
+
+   if (size > (mtd->writesize - page_offset))
+   sz = (mtd->writesize - page_offset);
+   else
+   sz = size;
+
+   memcpy(dst, page_buf + page_offset, sz);
+   dst += sz;
+   size -= sz;
+   page_offset = 0;
+   page++;
}
+
+   page = 0;
+   } else {
+   lastblock++;
}
+
+   block++;
}
 
free(page_buf);
@@ -294,6 +289,19 @@ void nand_deselect(void)
 
 u32 nand_spl_adjust_offset(u32 sector, u32 offs)
 {
-   /* Handle the offset adjust in nand_spl_load_image,*/
+   unsigned int block, lastblock;
+
+   block = sector / mtd->erasesize;
+   lastblock = (sector + offs) / mtd->erasesize;
+
+   while (block <= lastblock) {
+   if (is_badblock(mtd, block * mtd->erasesize, 1)) {
+   offs += mtd->erasesize;
+   lastblock++;
+   }
+
+   block++;

[PATCH 1/2] nand: raw: mxs_nand: Fix specific hook registration

2022-04-23 Thread Michael Trimarchi
Move the hook after nand_scan_tail is called. The hook must be replaced
to the mxs specific one but those must to be assignment later in the
probe function.

With this fix markbad is working

Signed-off-by: Michael Trimarchi 
---
 drivers/mtd/nand/raw/mxs_nand.c | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/mtd/nand/raw/mxs_nand.c b/drivers/mtd/nand/raw/mxs_nand.c
index ee5d7fde9c..53f24b9c4b 100644
--- a/drivers/mtd/nand/raw/mxs_nand.c
+++ b/drivers/mtd/nand/raw/mxs_nand.c
@@ -1246,22 +1246,6 @@ int mxs_nand_setup_ecc(struct mtd_info *mtd)
/* Enable BCH complete interrupt */
writel(BCH_CTRL_COMPLETE_IRQ_EN, &bch_regs->hw_bch_ctrl_set);
 
-   /* Hook some operations at the MTD level. */
-   if (mtd->_read_oob != mxs_nand_hook_read_oob) {
-   nand_info->hooked_read_oob = mtd->_read_oob;
-   mtd->_read_oob = mxs_nand_hook_read_oob;
-   }
-
-   if (mtd->_write_oob != mxs_nand_hook_write_oob) {
-   nand_info->hooked_write_oob = mtd->_write_oob;
-   mtd->_write_oob = mxs_nand_hook_write_oob;
-   }
-
-   if (mtd->_block_markbad != mxs_nand_hook_block_markbad) {
-   nand_info->hooked_block_markbad = mtd->_block_markbad;
-   mtd->_block_markbad = mxs_nand_hook_block_markbad;
-   }
-
return 0;
 }
 
@@ -1467,6 +1451,22 @@ int mxs_nand_init_ctrl(struct mxs_nand_info *nand_info)
if (err)
goto err_free_buffers;
 
+   /* Hook some operations at the MTD level. */
+   if (mtd->_read_oob != mxs_nand_hook_read_oob) {
+   nand_info->hooked_read_oob = mtd->_read_oob;
+   mtd->_read_oob = mxs_nand_hook_read_oob;
+   }
+
+   if (mtd->_write_oob != mxs_nand_hook_write_oob) {
+   nand_info->hooked_write_oob = mtd->_write_oob;
+   mtd->_write_oob = mxs_nand_hook_write_oob;
+   }
+
+   if (mtd->_block_markbad != mxs_nand_hook_block_markbad) {
+   nand_info->hooked_block_markbad = mtd->_block_markbad;
+   mtd->_block_markbad = mxs_nand_hook_block_markbad;
+   }
+
err = nand_register(0, mtd);
if (err)
goto err_free_buffers;
-- 
2.25.1



[PATCH 0/2] MXS nand fixes in SPL

2022-04-23 Thread Michael Trimarchi
Those patches come after some testing of failing in factory on some
unit. We found out that the bootrom imx loader was not able to handling
badblock. This can be a limit of the implementation right now in imx8mn.
Anyway not all the imx platform has the support of this loader. I found
some problems on the implementation so I have fixed it up according the
experience of Sitara. I tested only using a Fit Image as a flash
container

Michael Trimarchi (2):
  nand: raw: mxs_nand: Fix specific hook registration
  mtd: nand: mxs_nand_spl: Fix bad block skipping

 drivers/mtd/nand/raw/mxs_nand.c | 32 +-
 drivers/mtd/nand/raw/mxs_nand_spl.c | 90 -
 2 files changed, 65 insertions(+), 57 deletions(-)

-- 
2.25.1



Re: [PATCH v2 5/6] board: amlogic: jethub j100: enable saradc in dts

2022-04-23 Thread Vyacheslav




22.04.2022 16:26, Neil Armstrong wrote:

On 22/04/2022 07:29, Vyacheslav Bocharov wrote:

Prepare to use ADC channel 1 to check the hardware revision of the board.

Signed-off-by: Vyacheslav Bocharov 
---
  arch/arm/dts/meson-axg-jethome-jethub-j100.dts | 5 +
  1 file changed, 5 insertions(+)

diff --git a/arch/arm/dts/meson-axg-jethome-jethub-j100.dts 
b/arch/arm/dts/meson-axg-jethome-jethub-j100.dts

index 5783732dc6..00a0b268af 100644
--- a/arch/arm/dts/meson-axg-jethome-jethub-j100.dts
+++ b/arch/arm/dts/meson-axg-jethome-jethub-j100.dts
@@ -359,3 +359,8 @@
  &cpu3 {
  #cooling-cells = <2>;
  };
+
+&saradc {
+    status = "okay";
+    vref-supply = <&vddio_ao18>;
+};


Please move this in a -u-boot.dtsi file to keep the main DT in sync with 
Linux.


Thanks. Anyway, I will submit patch to the kernel later.


Neil


Re: [PATCH v2 1/6] clk: meson: add minimal driver for axg-ao clocks

2022-04-23 Thread Vyacheslav




23.04.2022 1:55, Sean Anderson wrote:

On 4/22/22 1:29 AM, Vyacheslav Bocharov wrote:

Add minimal driver AO clocks on meson AXG family. Only ADC related clocks
are supported.

Signed-off-by: Vyacheslav Bocharov 
---
  drivers/clk/meson/Makefile |  1 +
  drivers/clk/meson/axg-ao.c | 89 ++
  2 files changed, 90 insertions(+)
  create mode 100644 drivers/clk/meson/axg-ao.c

diff --git a/drivers/clk/meson/Makefile b/drivers/clk/meson/Makefile
index b9c6bd66cf..a486b13e9c 100644
--- a/drivers/clk/meson/Makefile
+++ b/drivers/clk/meson/Makefile
@@ -5,5 +5,6 @@
  obj-$(CONFIG_CLK_MESON_GX) += gxbb.o
  obj-$(CONFIG_CLK_MESON_AXG) += axg.o
+obj-$(CONFIG_CLK_MESON_AXG) += axg-ao.o
  obj-$(CONFIG_CLK_MESON_G12A) += g12a.o
  obj-$(CONFIG_CLK_MESON_G12A) += g12a-ao.o
diff --git a/drivers/clk/meson/axg-ao.c b/drivers/clk/meson/axg-ao.c
new file mode 100644
index 00..3f9617e9f7
--- /dev/null
+++ b/drivers/clk/meson/axg-ao.c
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "clk_meson.h"
+
+struct meson_clk {
+    struct regmap *map;
+};
+
+#define AO_CLK_GATE0    0x40
+#define AO_SAR_CLK    0x90
+
+static struct meson_gate gates[] = {
+    MESON_GATE(CLKID_AO_SAR_ADC, AO_CLK_GATE0, 7),
+    MESON_GATE(CLKID_AO_SAR_ADC_CLK, AO_SAR_CLK, 7),
+};
+
+static int meson_set_gate(struct clk *clk, bool on)
+{
+    struct meson_clk *priv = dev_get_priv(clk->dev);
+    struct meson_gate *gate;
+
+    gate = &gates[clk->id];
+
+    if (gate->reg == 0)
+    return 0;


I don't think you need this.
Hmm. You're right. The gates is all predefined. Therefore zero values 
cannot be there. I will fix it in g12-ao-clk as well.





+
+    regmap_update_bits(priv->map, gate->reg,
+   BIT(gate->bit), on ? BIT(gate->bit) : 0);
+
+    return 0;
+}
+
+static int meson_clk_enable(struct clk *clk)
+{
+    return meson_set_gate(clk, true);
+}
+
+static int meson_clk_disable(struct clk *clk)
+{
+    return meson_set_gate(clk, false);
+}
+
+static int meson_clk_probe(struct udevice *dev)
+{
+    struct meson_clk *priv = dev_get_priv(dev);
+
+    priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
+    if (IS_ERR(priv->map))
+    return PTR_ERR(priv->map);
+
+    return 0;
+}
+
+static int meson_clk_request(struct clk *clk)
+{
+    if (clk->id >= ARRAY_SIZE(gates))
+    return -ENOENT;
+
+    return 0;
+}
+
+static struct clk_ops meson_clk_ops = {
+    .disable    = meson_clk_disable,
+    .enable    = meson_clk_enable,
+    .request    = meson_clk_request,
+};
+
+static const struct udevice_id meson_clk_ids[] = {
+    { .compatible = "amlogic,meson-axg-aoclkc" },
+    { }
+};
+
+U_BOOT_DRIVER(meson_clk_axg_ao) = {
+    .name    = "meson_clk_axg_ao",
+    .id    = UCLASS_CLK,
+    .of_match    = meson_clk_ids,
+    .priv_auto    = sizeof(struct meson_clk),
+    .ops    = &meson_clk_ops,
+    .probe    = meson_clk_probe,
+};



Reviewed-by: Sean Anderson