Re: [PATCH v2 1/1] Makefile: rework u-boot-initial-env target

2022-10-31 Thread Max Krummenacher
Hi

On Fri, Oct 28, 2022 at 6:40 PM Pali Rohár  wrote:
>
> Hello! This is really much better solution! Few comments are below.
>
> On Friday 28 October 2022 18:18:49 Max Krummenacher wrote:
> > From: Max Krummenacher 
> >
> > With LTO enabled the U-Boot initial environment is no longer stored
> > in an easy accessible section in env/common.o. I.e. the section name
> > changes from build to build, its content maybe compressed and it is
> > annotated with additional data.
> >
> > Drop trying to read the initial env with elf tools from the compiler
> > specific object file in favour of adding and using a host tool with
> > the only functionality of printing the initial env to stdout.
> >
> > See also:
> > https://lore.kernel.org/all/927b122e-1f62-e790-f5ca-30bae4332...@foss.st.com/
> >
> > Signed-off-by: Max Krummenacher 
> >
> > ---
> >
> > Changes in v2:
> > - reworked to build a host tool which prints the configured
> >   environment as proposed by Pali Rohár
> >   
> > https://lore.kernel.org/u-boot/20221018174827.1393211-1-max.oss...@gmail.com/
> > - renamed patch, v1 used "Makefile: fix u-boot-initial-env target if lto is 
> > enabled"
> >
> >  Makefile  |  7 ---
> >  scripts/.gitignore|  1 +
> >  scripts/Makefile  |  5 +
> >  scripts/printinitialenv.c | 44 +++
> >  4 files changed, 54 insertions(+), 3 deletions(-)
> >  create mode 100644 scripts/printinitialenv.c
> >
> > diff --git a/Makefile b/Makefile
> > index 0f1174718f7..2f97d63c398 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -2442,9 +2442,10 @@ endif
> >   $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
> >
> >  quiet_cmd_genenv = GENENV  $@
> > -cmd_genenv = $(OBJCOPY) --dump-section .rodata.default_environment=$@ 
> > env/common.o; \
> > - sed --in-place -e 's/\x00/\x0A/g' $@; sed --in-place -e '/^\s*$$/d' 
> > $@; \
> > - sort --field-separator== -k1,1 --stable $@ -o $@
> > +cmd_genenv = \
> > + scripts/printinitialenv | \
> > + sed -e 's/\x00/\x0A/g' -e '/^\s*$$/d' | \
>
> I think that you do not need this sed anymore as you print newline in
> host tool.

Missed that one, will change in a V3.

>
> > + sort --field-separator== -k1,1 --stable -o $@
> >
> >  u-boot-initial-env: u-boot.bin
>
> It is needed to update dependencies for u-boot-initial-env target. Now
> it does not depend on u-boot.bin but rather on printinitialenv tool.

I'm unsure if that is the best way forward. The initial solution would
also not need to depend on u-boot.bin but rather on env/common.o.

I guess that the intention was that the U-Boot binary and the
u-boot-initial-env file should not be out of sync.

Opinions?

>
> >   $(call if_changed,genenv)
> > diff --git a/scripts/.gitignore b/scripts/.gitignore
> > index 08cc824bac3..6068724a0d4 100644
> > --- a/scripts/.gitignore
> > +++ b/scripts/.gitignore
> > @@ -2,3 +2,4 @@
> >  # Generated files
> >  #
> >  bin2c
> > +printinitialenv
> > diff --git a/scripts/Makefile b/scripts/Makefile
> > index 8731e6cecd7..ba993820571 100644
> > --- a/scripts/Makefile
> > +++ b/scripts/Makefile
> > @@ -5,8 +5,13 @@
> >  # 
> > ---
> >
> >  hostprogs-$(CONFIG_BUILD_BIN2C)  += bin2c
> > +hostprogs-y  += printinitialenv
>
> I'm not sure if the scripts/ is the correct directory for the this tool.
> Maybe it should be in tools? Lets wait what maintainers or Tom say.

According to tools/Makefile tools should be used for tools which
are not dependent on any boards. This here is a helper during
the build of a particular U-Boot configuration. That is why I put it
into scripts/.

Max
>
> >
> >  always   := $(hostprogs-y)
> >
> > +HOSTCFLAGS_printinitialenv.o += \
> > + $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
> > + -DUSE_HOSTCC
> > +
> >  # Let clean descend into subdirs
> >  subdir-  += basic kconfig dtc
> > diff --git a/scripts/printinitialenv.c b/scripts/printinitialenv.c
> > new file mode 100644
> > index 000..c58b234d679
> > --- /dev/null
> > +++ b/scripts/printinitialenv.c
> > @@ -0,0 +1,44 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * (C) Copyright 2022
> > + * Max Krummenacher, Toradex
> > + *
> > + * Snippets taken from tools/env/fw_env.c
> > + *
> > + * This prints the list of default environment variables as currently
> > + * configured.
> > + *
> > + */
> > +
> > +#include 
> > +
> > +/* Pull in the current config to define the default environment */
> > +#include 
> > +
> > +#ifndef __ASSEMBLY__
> > +#define __ASSEMBLY__ /* get only #defines from config.h */
> > +#include 
> > +#undef   __ASSEMBLY__
> > +#else
> > +#include 
> > +#endif
> > +
> > +#define DEFAULT_ENV_INSTANCE_STATIC
> > +#include 
> > +#include 
> > +
> > +int main(void)
> > +{
> > + char *env, *nxt;
> > +
> > + for (env = default_environment; *env; env

Re: [PATCH] usb: ohci: Use a flexible array member for portstatus

2022-10-31 Thread Marek Vasut

On 10/31/22 05:15, Samuel Holland wrote:

The struct is only used to overlay the MMIO region, so the behavior is
the same. This obsoletes the Kconfig option for the number of ports.

Signed-off-by: Samuel Holland 
---

  configs/arbel_evb_defconfig|  1 -
  configs/at91sam9260ek_dataflash_cs0_defconfig  |  1 -
  configs/at91sam9260ek_dataflash_cs1_defconfig  |  1 -
  configs/at91sam9260ek_nandflash_defconfig  |  1 -
  configs/at91sam9261ek_dataflash_cs0_defconfig  |  1 -
  configs/at91sam9261ek_dataflash_cs3_defconfig  |  1 -
  configs/at91sam9261ek_nandflash_defconfig  |  1 -
  configs/at91sam9263ek_dataflash_cs0_defconfig  |  1 -
  configs/at91sam9263ek_dataflash_defconfig  |  1 -
  configs/at91sam9263ek_nandflash_defconfig  |  1 -
  configs/at91sam9263ek_norflash_boot_defconfig  |  1 -
  configs/at91sam9263ek_norflash_defconfig   |  1 -
  configs/at91sam9g10ek_dataflash_cs0_defconfig  |  1 -
  configs/at91sam9g10ek_dataflash_cs3_defconfig  |  1 -
  configs/at91sam9g10ek_nandflash_defconfig  |  1 -
  configs/at91sam9g20ek_2mmc_defconfig   |  1 -
  configs/at91sam9g20ek_2mmc_nandflash_defconfig |  1 -
  configs/at91sam9g20ek_dataflash_cs0_defconfig  |  1 -
  configs/at91sam9g20ek_dataflash_cs1_defconfig  |  1 -
  configs/at91sam9g20ek_nandflash_defconfig  |  1 -
  configs/at91sam9xeek_dataflash_cs0_defconfig   |  1 -
  configs/at91sam9xeek_dataflash_cs1_defconfig   |  1 -
  configs/at91sam9xeek_nandflash_defconfig   |  1 -
  configs/axs103_defconfig   |  1 -
  configs/chromebook_bob_defconfig   |  1 -
  configs/chromebook_kevin_defconfig |  1 -
  configs/comtrend_ar5315u_ram_defconfig |  1 -
  configs/comtrend_ar5387un_ram_defconfig|  1 -
  configs/comtrend_ct5361_ram_defconfig  |  1 -
  configs/comtrend_vr3032u_ram_defconfig |  1 -
  configs/comtrend_wap5813n_ram_defconfig|  1 -
  configs/da850evm_defconfig |  1 -
  configs/da850evm_direct_nor_defconfig  |  1 -
  configs/da850evm_nand_defconfig|  1 -
  configs/devkit3250_defconfig   |  1 -
  configs/elgin-rv1108_defconfig |  1 -
  configs/evb-rk3128_defconfig   |  1 -
  configs/evb-rk3328_defconfig   |  1 -
  configs/evb-rv1108_defconfig   |  1 -
  configs/hsdk_4xd_defconfig |  1 -
  configs/hsdk_defconfig |  1 -
  configs/huawei_hg556a_ram_defconfig|  1 -
  configs/khadas-edge-captain-rk3399_defconfig   |  1 -
  configs/khadas-edge-rk3399_defconfig   |  1 -
  configs/khadas-edge-v-rk3399_defconfig |  1 -
  configs/nanopi-r2s-rk3328_defconfig|  1 -
  configs/netgear_dgnd3700v2_ram_defconfig   |  1 -
  configs/omapl138_lcdk_defconfig|  1 -
  configs/pinebook-pro-rk3399_defconfig  |  1 -
  configs/pm9261_defconfig   |  1 -
  configs/pm9263_defconfig   |  1 -
  configs/roc-cc-rk3328_defconfig|  1 -
  configs/rock-pi-e-rk3328_defconfig |  1 -
  configs/rock64-rk3328_defconfig|  1 -
  configs/rock960-rk3399_defconfig   |  1 -
  configs/rockpro64-rk3399_defconfig |  1 -
  configs/sama5d3_xplained_mmc_defconfig |  1 -
  configs/sama5d3_xplained_nandflash_defconfig   |  1 -
  configs/sfr_nb4-ser_ram_defconfig  |  1 -
  configs/smartweb_defconfig |  1 -
  configs/socrates_defconfig |  1 -
  configs/stih410-b2260_defconfig|  1 -
  configs/taurus_defconfig   |  1 -
  configs/vexpress_aemv8a_juno_defconfig |  1 -
  doc/README.generic_usb_ohci|  4 
  drivers/usb/host/Kconfig   |  5 -
  drivers/usb/host/ohci.h| 10 +-
  67 files changed, 1 insertion(+), 82 deletions(-)


Applied, thanks.


Re: Please pull u-boot-video

2022-10-31 Thread Tom Rini
On Sun, Oct 30, 2022 at 10:16:06PM +0100, Anatolij Gustschin wrote:

> Hi Tom,
> 
> please pull video changes for v2023.01.
> 
> CI: https://source.denx.de/u-boot/custodians/u-boot-video/-/pipelines/13972
> 
> Thanks,
> Anatolij
> 
> The following changes since commit fb63362c63c7aeacb1dfde330ee8f692da7972f9:
> 
>   lib: fix buggy strcmp and strncmp (2022-10-27 09:10:08 -0400)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-video.git 
> tags/video-20221030
> 
> for you to fetch changes up to b86986c7b314f1378ca5be8df49310a6ce7302f8:
> 
>   video: Rename CONFIG_DM_VIDEO to CONFIG_VIDEO (2022-10-30 20:07:17 +0100)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: Binman entry 'u-boot-any' not found in list

2022-10-31 Thread Roger Quadros
Hi Neha,

On 31/10/2022 05:40, Neha Malcom Francis wrote:
> Hi Simon,
> 
> On 30/10/22 07:13, Simon Glass wrote:
>> Hi Neha,
>>
>> On Fri, 28 Oct 2022 at 04:58, Fabio Estevam  wrote:
>>>
>>> [Adding Alper - binmam maintainer and Oliver, who faced the same issue on 
>>> imx8]
>>>
>>> On Fri, Oct 28, 2022 at 7:56 AM Neha Malcom Francis  
>>> wrote:

 Hi!

 U-Boot build for J721E with binman enabled on the latest tip of the
 master branch throws an error when I try to use u-boot-spl-nodtb entry
 in my dtsi.

 What I'm trying to do is, to show I've made a small example
 (https://github.com/nehamalcom/u-boot/commit/f53dc83944f7774008afbb24fff42904862e9efe)
 that is:

 &binman {
  foo {
  filename = "foo.bin";
  u-boot-spl-nodtb {
  };
  };
 };

 which throws the error
 (https://gist.github.com/nehamalcom/4d855db7e4d5bd03aa29099b0e915e53):

 binman: Section '/binman/foo': Symbol '_binman_u_boot_any_prop_image_pos'
  in entry '/binman/foo/u-boot-spl-nodtb': Entry 'u-boot-any' not
 found in list (u-boot-spl-nodtb,main-section)


 This can be traced to the WriteSymbols() in etype/u_boot_spl_nodtb.py.
 On commenting out this function since it's not necessary in our
 use-case, the build was successful
 (https://github.com/nehamalcom/u-boot/commit/5666721860e1d2f759440a00c4aee8b6e89b54b3)

 Why is binman not picking up on the "any" and choosing u-boot-spl-nodtb
 from the list?
>>
>> You might need this patch?
>>
>> https://patchwork.ozlabs.org/project/uboot/patch/20221021002320.1169603-5-...@chromium.org/
> 
> Even after applying this patch, the entry is not working for me.

Probably because that patch doesn't deal with CONFIG_SPL case, only CONFIG_TPL 
and CONFIG_VPL?
Can you please try to do the same for CONFIG_SPL?

e.g.

#ifdef CONFIG_SPL
binman_sym_declare(ulong, u_boot_spl, image_pos);
binman_sym_declare(ulong, u_boot_spl, size);
#endif

cheers,
-roger


Re: [PATCH v2 0/2] splash: add more options/support

2022-10-31 Thread Anatolij Gustschin
On Mon, 17 Oct 2022 10:33:18 +0200
Julien Masson jmas...@baylibre.com wrote:
...
> Changes in v2:
> - splash_mmc_read_raw: return -EIO in case of errors
> - splash_mmc_read_raw: use IS_ENABLED(CONFIG_CMD_MMC) instead of #ifdef
> - rename local var env_splashdevpart_value to devpart
> 
> Julien Masson (2):
>   splash: support raw image from MMC
>   splash: get devpart from environment variable
> 
>  common/splash.c|  6 ++
>  common/splash_source.c | 31 +++
>  2 files changed, 37 insertions(+)
> 

Applied to u-boot-video/master, thanks!

--
Anatolij


Re: [PATCH v3] video: simplefb: add rotation support

2022-10-31 Thread Anatolij Gustschin
On Tue, 13 Sep 2022 18:32:42 +0900
Takumi Sueda puhit...@gmail.com wrote:

> It introduces the way to rotate the screen for boards with rotated screen.
> 
> Signed-off-by: Takumi Sueda 
> ---
>  drivers/video/simplefb.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Applied to u-boot-video/master, thanks!

--
Anatolij


Re: [PATCH v2] video: dw_mipi_dsi: fix [hv]sync active vs back porch

2022-10-31 Thread Anatolij Gustschin
On Wed,  7 Sep 2022 12:06:32 +0100
John Keeping j...@metanate.com wrote:

> The wrong fields are pulled out of the timings here so the values
> programmed into the DSI_VID_HSA_LINES/DSI_VID_HBP_LINES and
> DSI_VID_VSA_LINES/DSI_VID_VBP_LINES registers are swapped.
> 
> Use the right fields so that the correct values are programmed.
> 
> Fixes: d4f7ea83fc ("video: add MIPI DSI host controller bridge")
> Signed-off-by: John Keeping 
> ---
> v2:
> - Fix hsync/hbp as well as vsync/vbp
> 
>  drivers/video/dw_mipi_dsi.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 

Applied to u-boot-video/master, thanks!

--
Anatolij


Re: [PATCH 00/16] video: Enhancements to Truetype console

2022-10-31 Thread Anatolij Gustschin
On Thu,  6 Oct 2022 08:36:02 -0600
Simon Glass s...@chromium.org wrote:

> This series includes some minor enhancements to the Truetype console to
> allow it to support multiple fonts and sizes at the same time. This is
> useful for displays where the title needs to be in a larger font than the
> rest of the text on the display.
> 
> The fonts must still be compiled into U-Boot, but now it is possible to
> change fonts as needed.
> 
> Some other minor fixes and tweaks are included as well.
> 
> This is mostly in service of the upcoming VBE boot menu which needs to
> make better use of fonts.
...

Series applied to u-boot-video/master, thanks!

--
Anatolij


Re: [PATCH 00/16] video: Enhancements to Truetype console

2022-10-31 Thread Anatolij Gustschin
Hi Simon,

On Mon, 24 Oct 2022 05:45:34 -0600
Simon Glass s...@chromium.org wrote:

> Hi Anatolij,
> 
> On Thu, 6 Oct 2022 at 08:36, Simon Glass  wrote:
> >
> > This series includes some minor enhancements to the Truetype console to
> > allow it to support multiple fonts and sizes at the same time. This is
> > useful for displays where the title needs to be in a larger font than the
> > rest of the text on the display.
> >
> > The fonts must still be compiled into U-Boot, but now it is possible to
> > change fonts as needed.
> >
> > Some other minor fixes and tweaks are included as well.
> >
> > This is mostly in service of the upcoming VBE boot menu which needs to
> > make better use of fonts.
> >  
> 
> I sent this and another series with video patches. Any thoughts?

I've applied both series. When applying, I changed patch 

 [PATCH 04/16] video: Move the console commands to cmd/

to keep vidconsole_position_cursor() in vidconsole uclass to avoid
build errors in common/splash.c.

Thanks!

--
Anatolij


[PATCH 0/3] tools: mkimage: cleanups + allow to create legacy image with type flat_dt

2022-10-31 Thread Marc Kleine-Budde
Hello,

the first patch cleans up the error message output if struct
image_type_params::set_header is set, the remaining 2 add support for
creating legacy images with type flat_dt.

regards,
Marc





[PATCH 1/3] tools: mkimage: don't print error message "Success" in case of failure

2022-10-31 Thread Marc Kleine-Budde
In case there's no struct image_type_params::set_header callback, no
"errno" will be set. Don't fail with an error message, followed by
"Success". Remove the printing of the human readable "errno" value.

Signed-off-by: Marc Kleine-Budde 
---
 tools/mkimage.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/mkimage.c b/tools/mkimage.c
index 30c6df77081f..35a6b1fb799c 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -760,8 +760,8 @@ int main(int argc, char **argv)
if (tparams->set_header)
tparams->set_header (ptr, &sbuf, ifd, ¶ms);
else {
-   fprintf (stderr, "%s: Can't set header for %s: %s\n",
-   params.cmdname, tparams->name, strerror(errno));
+   fprintf (stderr, "%s: Can't set header for %s\n",
+   params.cmdname, tparams->name);
exit (EXIT_FAILURE);
}
 
-- 
2.35.1




[PATCH 2/3] tools: mkimage: pass legacy image option to struct image_type_params::check_image_type handlers

2022-10-31 Thread Marc Kleine-Budde
This is a preparation patch to allow legacy images with the
IH_TYPE_FLATDT ("flat_dt") image type.

Signed-off-by: Marc Kleine-Budde 
---
 tools/aisimage.c  | 2 +-
 tools/atmelimage.c| 2 +-
 tools/default_image.c | 2 +-
 tools/dumpimage.c | 2 +-
 tools/fit_common.c| 2 +-
 tools/fit_common.h| 2 +-
 tools/gpimage.c   | 2 +-
 tools/imagetool.c | 4 ++--
 tools/imagetool.h | 5 +++--
 tools/imx8image.c | 2 +-
 tools/imx8mimage.c| 2 +-
 tools/imximage.c  | 2 +-
 tools/kwbimage.c  | 2 +-
 tools/lpc32xximage.c  | 2 +-
 tools/mkimage.c   | 4 ++--
 tools/mtk_image.c | 2 +-
 tools/mxsimage.c  | 2 +-
 tools/omapimage.c | 2 +-
 tools/pblimage.c  | 2 +-
 tools/rkimage.c   | 2 +-
 tools/rksd.c  | 2 +-
 tools/rkspi.c | 2 +-
 tools/socfpgaimage.c  | 4 ++--
 tools/stm32image.c| 2 +-
 tools/sunxi_egon.c| 2 +-
 tools/sunxi_toc0.c| 2 +-
 tools/ublimage.c  | 2 +-
 tools/vybridimage.c   | 2 +-
 tools/zynqimage.c | 2 +-
 tools/zynqmpbif.c | 2 +-
 tools/zynqmpimage.c   | 2 +-
 31 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/tools/aisimage.c b/tools/aisimage.c
index b8b3ee32070f..21e5a8df8aad 100644
--- a/tools/aisimage.c
+++ b/tools/aisimage.c
@@ -360,7 +360,7 @@ static int aisimage_generate(struct image_tool_params 
*params,
return 0;
 }
 
-static int aisimage_check_image_types(uint8_t type)
+static int aisimage_check_image_types(uint8_t type, bool legacy)
 {
if (type == IH_TYPE_AISIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/atmelimage.c b/tools/atmelimage.c
index 7b3b243d58b7..3c084ba8b48d 100644
--- a/tools/atmelimage.c
+++ b/tools/atmelimage.c
@@ -11,7 +11,7 @@
 
 #define pr_err(fmt, args...) fprintf(stderr, "atmelimage Error: " fmt, ##args)
 
-static int atmel_check_image_type(uint8_t type)
+static int atmel_check_image_type(uint8_t type, bool legacy)
 {
if (type == IH_TYPE_ATMELIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/default_image.c b/tools/default_image.c
index 4a067e65862e..9a6b50a946ba 100644
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -24,7 +24,7 @@
 
 static struct legacy_img_hdr header;
 
-static int image_check_image_types(uint8_t type)
+static int image_check_image_types(uint8_t type, bool legacy)
 {
if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
(type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
diff --git a/tools/dumpimage.c b/tools/dumpimage.c
index 4791dd0dfe18..3c840985f2fe 100644
--- a/tools/dumpimage.c
+++ b/tools/dumpimage.c
@@ -119,7 +119,7 @@ int main(int argc, char **argv)
params.imagefile = argv[optind];
 
/* set tparams as per input type_id */
-   tparams = imagetool_get_type(params.type);
+   tparams = imagetool_get_type(¶ms);
if (!params.lflag && tparams == NULL) {
fprintf(stderr, "%s: unsupported type: %s\n",
params.cmdname, genimg_get_type_name(params.type));
diff --git a/tools/fit_common.c b/tools/fit_common.c
index 01649760ac00..b4aa89b53577 100644
--- a/tools/fit_common.c
+++ b/tools/fit_common.c
@@ -41,7 +41,7 @@ int fit_verify_header(unsigned char *ptr, int image_size,
return EXIT_SUCCESS;
 }
 
-int fit_check_image_types(uint8_t type)
+int fit_check_image_types(uint8_t type, bool legacy)
 {
if (type == IH_TYPE_FLATDT)
return EXIT_SUCCESS;
diff --git a/tools/fit_common.h b/tools/fit_common.h
index 920a16acfdb2..0fd7a504cf05 100644
--- a/tools/fit_common.h
+++ b/tools/fit_common.h
@@ -21,7 +21,7 @@
 int fit_verify_header(unsigned char *ptr, int image_size,
struct image_tool_params *params);
 
-int fit_check_image_types(uint8_t type);
+int fit_check_image_types(uint8_t type, bool legacy);
 
 /**
  * Map an FDT into memory, optionally increasing its size
diff --git a/tools/gpimage.c b/tools/gpimage.c
index 27de4cfaed77..eda2532ac87a 100644
--- a/tools/gpimage.c
+++ b/tools/gpimage.c
@@ -26,7 +26,7 @@
 static uint8_t gpimage_header[GPIMAGE_HDR_SIZE];
 
 /* to be in keystone gpimage */
-static int gpimage_check_image_types(uint8_t type)
+static int gpimage_check_image_types(uint8_t type, bool legacy)
 {
if (type == IH_TYPE_GPIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/imagetool.c b/tools/imagetool.c
index f14ca2fb979f..ff8a293f8a50 100644
--- a/tools/imagetool.c
+++ b/tools/imagetool.c
@@ -9,7 +9,7 @@
 
 #include 
 
-struct image_type_params *imagetool_get_type(int type)
+struct image_type_params *imagetool_get_type(const struct image_tool_params 
*params)
 {
struct image_type_params **curr;
INIT_SECTION(image_type);
@@ -19,7 +19,7 @@ struct image_type_params *imagetool_get_type(int type)
 
for (curr = start; curr != end; curr++) {
if ((*curr)->check_image_type) {
-   if (!(*curr)->check_image_type(type))
+   if (!(

[PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images

2022-10-31 Thread Marc Kleine-Budde
If the user select the image type "flat_dt" a FIT image will be build.
This breaks the legacy use case of putting a Flat Device Tree into a
legacy u-boot image.

Add command line options "-L" and "--legacy" to let the user force the
creation of a legacy u-boot image, even if "flat_dt" is selected.

Link: https://lore.kernel.org/all/20221028155205.ojw6tcso2fofg...@pengutronix.de
Signed-off-by: Marc Kleine-Budde 
---
 tools/default_image.c | 1 +
 tools/fit_common.c| 3 +++
 tools/mkimage.c   | 7 ++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/default_image.c b/tools/default_image.c
index 9a6b50a946ba..3673eaa63de2 100644
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -27,6 +27,7 @@ static struct legacy_img_hdr header;
 static int image_check_image_types(uint8_t type, bool legacy)
 {
if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
+   ((type == IH_TYPE_FLATDT) && legacy) ||
(type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
return EXIT_SUCCESS;
else
diff --git a/tools/fit_common.c b/tools/fit_common.c
index b4aa89b53577..eba13a789a72 100644
--- a/tools/fit_common.c
+++ b/tools/fit_common.c
@@ -43,6 +43,9 @@ int fit_verify_header(unsigned char *ptr, int image_size,
 
 int fit_check_image_types(uint8_t type, bool legacy)
 {
+   if (legacy)
+   return EXIT_FAILURE;
+
if (type == IH_TYPE_FLATDT)
return EXIT_SUCCESS;
else
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 6d029afab3a8..9e9edd65583e 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -91,6 +91,7 @@ static void usage(const char *msg)
fprintf(stderr,
"   %s [-x] -A arch -O os -T type -C comp -a addr -e ep -n 
name -d data_file[:data_file...] image\n"
"  -A ==> set architecture to 'arch'\n"
+   "  -L ==> force legacy image\n"
"  -O ==> set operating system to 'os'\n"
"  -T ==> set image type to 'type'\n"
"  -C ==> set compression type 'comp'\n"
@@ -159,7 +160,7 @@ static int add_content(int type, const char *fname)
 }
 
 static const char optstring[] =
-   "a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:ln:N:o:O:p:qrR:stT:vVx";
+   "a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:Lln:N:o:O:p:qrR:stT:vVx";
 
 static const struct option longopts[] = {
{ "load-address", required_argument, NULL, 'a' },
@@ -181,6 +182,7 @@ static const struct option longopts[] = {
{ "key-dir", required_argument, NULL, 'k' },
{ "key-dest", required_argument, NULL, 'K' },
{ "list", no_argument, NULL, 'l' },
+   { "legacy", no_argument, NULL, 'L' },
{ "config", required_argument, NULL, 'n' },
{ "engine", required_argument, NULL, 'N' },
{ "algo", required_argument, NULL, 'o' },
@@ -298,6 +300,9 @@ static void process_args(int argc, char **argv)
case 'l':
params.lflag = 1;
break;
+   case 'L':
+   params.Lflag = 1;
+   break;
case 'n':
params.imagename = optarg;
break;
-- 
2.35.1




Re: [PATCH 2/3] tools: mkimage: pass legacy image option to struct image_type_params::check_image_type handlers

2022-10-31 Thread Sean Anderson

On 10/31/22 10:13, Marc Kleine-Budde wrote:

This is a preparation patch to allow legacy images with the
IH_TYPE_FLATDT ("flat_dt") image type.

Signed-off-by: Marc Kleine-Budde 
---
  tools/aisimage.c  | 2 +-
  tools/atmelimage.c| 2 +-
  tools/default_image.c | 2 +-
  tools/dumpimage.c | 2 +-
  tools/fit_common.c| 2 +-
  tools/fit_common.h| 2 +-
  tools/gpimage.c   | 2 +-
  tools/imagetool.c | 4 ++--
  tools/imagetool.h | 5 +++--
  tools/imx8image.c | 2 +-
  tools/imx8mimage.c| 2 +-
  tools/imximage.c  | 2 +-
  tools/kwbimage.c  | 2 +-
  tools/lpc32xximage.c  | 2 +-
  tools/mkimage.c   | 4 ++--
  tools/mtk_image.c | 2 +-
  tools/mxsimage.c  | 2 +-
  tools/omapimage.c | 2 +-
  tools/pblimage.c  | 2 +-
  tools/rkimage.c   | 2 +-
  tools/rksd.c  | 2 +-
  tools/rkspi.c | 2 +-
  tools/socfpgaimage.c  | 4 ++--
  tools/stm32image.c| 2 +-
  tools/sunxi_egon.c| 2 +-
  tools/sunxi_toc0.c| 2 +-
  tools/ublimage.c  | 2 +-
  tools/vybridimage.c   | 2 +-
  tools/zynqimage.c | 2 +-
  tools/zynqmpbif.c | 2 +-
  tools/zynqmpimage.c   | 2 +-
  31 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/tools/aisimage.c b/tools/aisimage.c
index b8b3ee32070f..21e5a8df8aad 100644
--- a/tools/aisimage.c
+++ b/tools/aisimage.c
@@ -360,7 +360,7 @@ static int aisimage_generate(struct image_tool_params 
*params,
return 0;
  }
  
-static int aisimage_check_image_types(uint8_t type)

+static int aisimage_check_image_types(uint8_t type, bool legacy)
  {
if (type == IH_TYPE_AISIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/atmelimage.c b/tools/atmelimage.c
index 7b3b243d58b7..3c084ba8b48d 100644
--- a/tools/atmelimage.c
+++ b/tools/atmelimage.c
@@ -11,7 +11,7 @@
  
  #define pr_err(fmt, args...) fprintf(stderr, "atmelimage Error: " fmt, ##args)
  
-static int atmel_check_image_type(uint8_t type)

+static int atmel_check_image_type(uint8_t type, bool legacy)
  {
if (type == IH_TYPE_ATMELIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/default_image.c b/tools/default_image.c
index 4a067e65862e..9a6b50a946ba 100644
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -24,7 +24,7 @@
  
  static struct legacy_img_hdr header;
  
-static int image_check_image_types(uint8_t type)

+static int image_check_image_types(uint8_t type, bool legacy)
  {
if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
(type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
diff --git a/tools/dumpimage.c b/tools/dumpimage.c
index 4791dd0dfe18..3c840985f2fe 100644
--- a/tools/dumpimage.c
+++ b/tools/dumpimage.c
@@ -119,7 +119,7 @@ int main(int argc, char **argv)
params.imagefile = argv[optind];
  
  	/* set tparams as per input type_id */

-   tparams = imagetool_get_type(params.type);
+   tparams = imagetool_get_type(¶ms);
if (!params.lflag && tparams == NULL) {
fprintf(stderr, "%s: unsupported type: %s\n",
params.cmdname, genimg_get_type_name(params.type));
diff --git a/tools/fit_common.c b/tools/fit_common.c
index 01649760ac00..b4aa89b53577 100644
--- a/tools/fit_common.c
+++ b/tools/fit_common.c
@@ -41,7 +41,7 @@ int fit_verify_header(unsigned char *ptr, int image_size,
return EXIT_SUCCESS;
  }
  
-int fit_check_image_types(uint8_t type)

+int fit_check_image_types(uint8_t type, bool legacy)
  {
if (type == IH_TYPE_FLATDT)
return EXIT_SUCCESS;
diff --git a/tools/fit_common.h b/tools/fit_common.h
index 920a16acfdb2..0fd7a504cf05 100644
--- a/tools/fit_common.h
+++ b/tools/fit_common.h
@@ -21,7 +21,7 @@
  int fit_verify_header(unsigned char *ptr, int image_size,
struct image_tool_params *params);
  
-int fit_check_image_types(uint8_t type);

+int fit_check_image_types(uint8_t type, bool legacy);
  
  /**

   * Map an FDT into memory, optionally increasing its size
diff --git a/tools/gpimage.c b/tools/gpimage.c
index 27de4cfaed77..eda2532ac87a 100644
--- a/tools/gpimage.c
+++ b/tools/gpimage.c
@@ -26,7 +26,7 @@
  static uint8_t gpimage_header[GPIMAGE_HDR_SIZE];
  
  /* to be in keystone gpimage */

-static int gpimage_check_image_types(uint8_t type)
+static int gpimage_check_image_types(uint8_t type, bool legacy)
  {
if (type == IH_TYPE_GPIMAGE)
return EXIT_SUCCESS;
diff --git a/tools/imagetool.c b/tools/imagetool.c
index f14ca2fb979f..ff8a293f8a50 100644
--- a/tools/imagetool.c
+++ b/tools/imagetool.c
@@ -9,7 +9,7 @@
  
  #include 
  
-struct image_type_params *imagetool_get_type(int type)

+struct image_type_params *imagetool_get_type(const struct image_tool_params 
*params)
  {
struct image_type_params **curr;
INIT_SECTION(image_type);
@@ -19,7 +19,7 @@ struct image_type_params *imagetool_get_type(int type)
  
  	for (curr = start; curr != end; curr++) {

if ((*curr)->check

Re: [PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images

2022-10-31 Thread Sean Anderson

On 10/31/22 10:13, Marc Kleine-Budde wrote:

If the user select the image type "flat_dt" a FIT image will be build.
This breaks the legacy use case of putting a Flat Device Tree into a
legacy u-boot image.

Add command line options "-L" and "--legacy" to let the user force the
creation of a legacy u-boot image, even if "flat_dt" is selected.

Link: https://lore.kernel.org/all/20221028155205.ojw6tcso2fofg...@pengutronix.de
Signed-off-by: Marc Kleine-Budde 
---
  tools/default_image.c | 1 +
  tools/fit_common.c| 3 +++
  tools/mkimage.c   | 7 ++-
  3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/default_image.c b/tools/default_image.c
index 9a6b50a946ba..3673eaa63de2 100644
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -27,6 +27,7 @@ static struct legacy_img_hdr header;
  static int image_check_image_types(uint8_t type, bool legacy)
  {
if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
+   ((type == IH_TYPE_FLATDT) && legacy) ||
(type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
return EXIT_SUCCESS;
else
diff --git a/tools/fit_common.c b/tools/fit_common.c
index b4aa89b53577..eba13a789a72 100644
--- a/tools/fit_common.c
+++ b/tools/fit_common.c
@@ -43,6 +43,9 @@ int fit_verify_header(unsigned char *ptr, int image_size,
  
  int fit_check_image_types(uint8_t type, bool legacy)

  {
+   if (legacy)
+   return EXIT_FAILURE;
+
if (type == IH_TYPE_FLATDT)
return EXIT_SUCCESS;
else
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 6d029afab3a8..9e9edd65583e 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -91,6 +91,7 @@ static void usage(const char *msg)
fprintf(stderr,
"   %s [-x] -A arch -O os -T type -C comp -a addr -e ep -n name 
-d data_file[:data_file...] image\n"
"  -A ==> set architecture to 'arch'\n"
+   "  -L ==> force legacy image\n"
"  -O ==> set operating system to 'os'\n"
"  -T ==> set image type to 'type'\n"
"  -C ==> set compression type 'comp'\n"
@@ -159,7 +160,7 @@ static int add_content(int type, const char *fname)
  }
  
  static const char optstring[] =

-   "a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:ln:N:o:O:p:qrR:stT:vVx";
+   "a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:Lln:N:o:O:p:qrR:stT:vVx";
  
  static const struct option longopts[] = {

{ "load-address", required_argument, NULL, 'a' },
@@ -181,6 +182,7 @@ static const struct option longopts[] = {
{ "key-dir", required_argument, NULL, 'k' },
{ "key-dest", required_argument, NULL, 'K' },
{ "list", no_argument, NULL, 'l' },
+   { "legacy", no_argument, NULL, 'L' },
{ "config", required_argument, NULL, 'n' },
{ "engine", required_argument, NULL, 'N' },
{ "algo", required_argument, NULL, 'o' },
@@ -298,6 +300,9 @@ static void process_args(int argc, char **argv)
case 'l':
params.lflag = 1;
break;
+   case 'L':
+   params.Lflag = 1;
+   break;
case 'n':
params.imagename = optarg;
break;


Please add some documentation to the man page (doc/mkimage.1). And also 
consider not using a short option.

--Sean


Re: [PATCH v2 1/5] buildman: Handle the MAINTAINERS 'N' tag

2022-10-31 Thread Tom Rini
On Tue, Oct 11, 2022 at 08:15:37AM -0600, Simon Glass wrote:

> This is needed for some soon-to-be-applied patches. Scan the configs/
> directory to see if any of the files match.
> 
> Signed-off-by: Simon Glass 
> Tested-by: Tom Rini 
> Suggested-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 1/5] arm: bcmbca: add bcm63178 SoC support

2022-10-31 Thread Tom Rini
On Mon, Aug 01, 2022 at 11:39:21AM -0700, William Zhang wrote:

> BCM63178 is an ARM A7 based DSL Broadband SoC. It is part of the BCA
> (Broadband Carrier Access origin) chipset family so it's added under
> ARCH_BCMBCA platform. This initial support includes a bare-bone
> implementation and dts with CPU subsystem, memory and ARM PL011 uart.
> 
> This SoC is supported in the linux-next git repository so the dts and
> dtsi files are copied from linux with minor fix-up that needs to be
> upstreamed to linux as well.
> 
> The u-boot image can be loaded from flash or network to the entry
> point address in the memory and boot from there.
> 
> Signed-off-by: William Zhang 

For the series, applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2] arm: bcmbca: add bcm63138 SoC support

2022-10-31 Thread Tom Rini
On Fri, Aug 05, 2022 at 06:25:13PM -0700, William Zhang wrote:

> BCM63138 is an ARM A9 based DSL Broadband SoC. It is part of the BCA
> (Broadband Carrier Access origin) chipset family so it's added under
> ARCH_BCMBCA platform. This initial support includes a bare-bone
> implementation and dts with CPU subsystem, memory, ARM A9 global timer
> and Broadcom uart.
> 
> This SoC is supported in the linux-next git repository so the dts and
> dtsi files are stripped down version of linux copies with mininum blocks
> needed by u-boot.
> 
> The u-boot image can be loaded from flash or network to the entry point
> address in the memory and boot from there to the console.
> 
> This patch applies on top of the my previous patch [1].
> 
> [1] https://lists.denx.de/pipermail/u-boot/2022-August/490570.html
> 
> Signed-off-by: William Zhang 
> Reviewed-by: Florian Fainelli 
> Reviewed-by: Philippe Reynes 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH V3 1/2] dt-bindings: mtd: partitions: u-boot: allow dynamic subpartitions

2022-10-31 Thread Rob Herring


On Tue, 18 Oct 2022 17:42:01 +0200, Rafał Miłecki wrote:
> From: Rafał Miłecki 
> 
> U-Boot partition may contain subpartitions. For example Broadcom
> includes environment data block in the middle of its U-Boot partition.
> 
> This allows describing Broadcom's U-Boot env data and will allow
> referencing its NVMEM cell in the future.
> 
> Reg: 118f3fbe517f4 ("dt-bindings: mtd: partitions: support label/name only 
> partition")
> Ref: dd638202dfb65 ("dt-bindings: mtd: partitions: add additional example for 
> qcom,smem-part")
> Signed-off-by: Rafał Miłecki 
> ---
> V3: Add this patch as pre-requirement for u-boot,env.yaml & brcm,env
> ---
>  .../devicetree/bindings/mtd/partitions/u-boot.yaml | 7 +++
>  1 file changed, 7 insertions(+)
> 

Applied, thanks!


Re: [PATCH 1/4] arm: bcmbca: add bcm63146 SoC support

2022-10-31 Thread Tom Rini
On Fri, Aug 05, 2022 at 06:34:00PM -0700, William Zhang wrote:

> BCM63146 is a Broadcom B53 based DSL Broadband SoC. It is part of the
> BCA (Broadband Carrier Access origin) chipset family so it's added under
> ARCH_BCMBCA platform. This initial support includes a bare-bone
> implementation and dts with CPU subsystem, memory and ARM PL011 uart.
> 
> This SoC is supported in the linux-next git repository so the dts and
> dtsi files are copied from linux.
> 
> The u-boot image can be loaded from flash or network to the entry point
> address in the memory and boot from there to the console.
> 
> Signed-off-by: William Zhang 
> Reviewed-by: Florian Fainelli 

For the series, applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v3 1/5] arm: bcmbca: add bcm63158 SoC support under CONFIG_ARCH_BCMBCA

2022-10-31 Thread Tom Rini
On Mon, Aug 22, 2022 at 11:19:44AM -0700, William Zhang wrote:

> BCM63158 is a Broadcom B53 based DSL Gateway SoC. It is part of the
> BCA (Broadband Carrier Access origin) chipset family. Like other
> Broadband SoC, this patch adds it under CONFIG_BCM63158 chip
> config and CONFIG_ARCH_BCMBCA platform config.
> 
> This initial support includes a bare-bone implementation and dts with
> CPU subsystem, memory and ARM PL011 uart. This SoC is supported in the
> linux-next git repository so the dts and dtsi files are copied from
> linux.
> 
> The u-boot image can be loaded from flash or network to the entry
> point address in the memory and boot from there to the console.
> 
> Signed-off-by: William Zhang 
> Reviewed-by: Philippe Reynes 

For the series, applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH V3 2/2] dt-bindings: nvmem: u-boot,env: add Broadcom's variant binding

2022-10-31 Thread Rob Herring


On Tue, 18 Oct 2022 17:42:02 +0200, Rafał Miłecki wrote:
> From: Rafał Miłecki 
> 
> Broadcom uses U-Boot for a lot of their bcmbca familiy chipsets. U-Boot
> stores its configuration in an environment data block.
> 
> Such blocks are usually stored on flash as a separated partition at
> hardcoded address. Broadcom however decided to:
> 1. Store env data block inside U-Boot partition
> 2. Avoid sticking to hardcoded offsets
> 3. Use custom header with "uEnv" magic and env data length
> 
> Example (length 0x4000):
> $ hexdump -n 32 -C -s 0x4 /dev/mtdblock0
> 0004  76 6e 45 75 00 40 00 00  34 89 7a 82 49 4d 41 47  |vn...@..4.z.imag|
> 00040010  45 3d 4e 41 4e 44 3a 31  4d 2c 31 30 32 34 4d 00  |E=NAND:1M,1024M.|
> (0x4 offset is unit specific and can change)
> 
> Starting with the commit 118f3fbe517f4 ("dt-bindings: mtd: partitions:
> support label/name only partition") DT can describe partitions matching
> them by a name (without specifying actual address). With that feature
> and this binding change it's possible to:
> 1. Specify DT node for Broadcom's U-Boot env data subpartition
> 2. Add nodes for specific environment data variables
> 3. Reference them as NVMEM cells
> 
> This binding is unlikely to help Broadcom's U-Boot. U-Boot SPL needs to
> find environment data early (before it accesses DTB) and it does that by
> looking for an "uEnv" magic. Dirty way.
> 
> This binding can however be used by operating systems. It allows
> describing cleanly U-Boot, its env data and variables. It tells
> operating system about Broadcom-specific env data so it can parse it.
> 
> Signed-off-by: Rafał Miłecki 
> ---
> V2: Work on better commit body & add example
> V3: Avoid duplicated "mac" label
> ---
>  .../devicetree/bindings/nvmem/u-boot,env.yaml | 21 +++
>  1 file changed, 21 insertions(+)
> 

Applied, thanks!


Re: [PATCH v4 1/3] arm: bcmbca: add bcm6856 SoC support under CONFIG_ARCH_BCMBCA

2022-10-31 Thread Tom Rini
On Mon, Aug 22, 2022 at 11:31:41AM -0700, William Zhang wrote:

> BCM6856 is a Broadcom B53 based PON Gateway SoC. It is part of the BCA
> (Broadband Carrier Access origin) chipset family. Like other Broadband
> SoC, this patch adds it under CONFIG_BCM6856 chip config and
> CONFIG_ARCH_BCMBCA platform config.
> 
> This initial support includes a bare-bone implementation and dts with
> CPU subsystem, memory and Broadcom uart. This SoC is supported in the
> linux-next git repository so the dts and dtsi files are copied from
> linux.
> 
> The u-boot image can be loaded from flash or network to the entry point
> address in the memory and boot from there to the console.
> 
> Signed-off-by: William Zhang 
> Reviewed-by: Philippe Reynes 

For the series, applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 1/3] arm: bcmbca: add bcm6858 SoC support under CONFIG_ARCH_BCMBCA

2022-10-31 Thread Tom Rini
On Mon, Aug 22, 2022 at 11:39:43AM -0700, William Zhang wrote:

> BCM6858 is a Broadcom B53 based PON Gateway SoC. It is part of the BCA
> (Broadband Carrier Access origin) chipset family. Like other broadband
> SoC, this patch adds it under CONFIG_BCM6858 chip config and
> CONFIG_ARCH_BCMBCA platform config.
> 
> This initial support includes a bare-bone implementation and the
> original dts is updated with the one from linux next git repository.
> 
> The u-boot image can be loaded from flash or network to the entry point
> address in the memory and boot from there to the console.
> 
> Signed-off-by: William Zhang 
> Reviewed-by: Philippe Reynes 

For the series, applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 1/3] arm: bcmbca: add bcm6855 SoC support under CONFIG_ARCH_BCMBCA

2022-10-31 Thread Tom Rini
On Mon, Aug 22, 2022 at 11:49:06AM -0700, William Zhang wrote:

> BCM6855 is a Broadcom ARM A7 based PON Gateway SoC. It is part of the
> BCA (Broadband Carrier Access origin) chipset family. Like other
> broadband SoC, this patch adds it under CONFIG_BCM6855 chip config and
> CONFIG_ARCH_BCMBCA platform config.
> 
> This initial support includes a bare-bone implementation and dts with
> CPU subsystem, memory and ARM PL101 uart. This SoC is supported in the
> linux-next git repository so the dts and dtsi files are copied from linux.
> 
> The u-boot image can be loaded from flash or network to the entry point
> address in the memory and boot from there to the console.
> 
> Signed-off-by: William Zhang 
> Reviewed-by: Philippe Reynes 

For the series, applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 1/2] timer: sti: convert sti-timer to arm a9 global timer

2022-10-31 Thread Tom Rini
On Tue, Aug 23, 2022 at 09:44:32PM -0700, William Zhang wrote:

> STI timer is actually ARM Cortex A9 global timer. Convert the driver to
> use generic global timer name and make it consistent with Linux kernel
> global timer driver. This also allows any A9 based device to use this
> driver.
> 
> Signed-off-by: William Zhang 
> Reviewed-by: Patrice Chotard 
> Tested-by: Patrice Chotard 

For the series, applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v2 0/2] tools: mkimage: cleanups + allow to create legacy image with type flat_dt

2022-10-31 Thread Marc Kleine-Budde
Hello,

the first patch cleans up the error message output if struct
image_type_params::set_header is set, the other adds support for
creating legacy images with type flat_dt.

regards,
Marc

Changes since v1:
- introduce new image type (suggested by Sean Anderson)
  instead of adding new cmd line parameter





[PATCH v2 1/2] tools: mkimage: don't print error message "Success" in case of failure

2022-10-31 Thread Marc Kleine-Budde
In case there's no struct image_type_params::set_header callback, no
"errno" will be set. Don't fail with an error message, followed by
"Success". Remove the printing of the human readable "errno" value.

Signed-off-by: Marc Kleine-Budde 
---
 tools/mkimage.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/mkimage.c b/tools/mkimage.c
index 30c6df77081f..35a6b1fb799c 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -760,8 +760,8 @@ int main(int argc, char **argv)
if (tparams->set_header)
tparams->set_header (ptr, &sbuf, ifd, ¶ms);
else {
-   fprintf (stderr, "%s: Can't set header for %s: %s\n",
-   params.cmdname, tparams->name, strerror(errno));
+   fprintf (stderr, "%s: Can't set header for %s\n",
+   params.cmdname, tparams->name);
exit (EXIT_FAILURE);
}
 
-- 
2.35.1




[PATCH v2 2/2] tools: mkimage: add new image type "flat_dt_legacy"

2022-10-31 Thread Marc Kleine-Budde
If the user select the image type "flat_dt" a FIT image will be build.
This breaks the legacy use case of putting a Flat Device Tree into a
legacy u-boot image.

Add a new image type "flat_dt_legacy" to build a legacy u-boot image
with a "flat_dt" type.

Link: https://lore.kernel.org/all/20221028155205.ojw6tcso2fofg...@pengutronix.de
Signed-off-by: Marc Kleine-Budde 
---
 boot/image.c  |  1 +
 include/image.h   |  1 +
 tools/default_image.c | 11 +--
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/boot/image.c b/boot/image.c
index 9f95b3260a80..9d7e57dee985 100644
--- a/boot/image.c
+++ b/boot/image.c
@@ -180,6 +180,7 @@ static const table_entry_t uimage_type[] = {
{   IH_TYPE_COPRO, "copro", "Coprocessor Image"},
{   IH_TYPE_SUNXI_EGON, "sunxi_egon",  "Allwinner eGON Boot Image" 
},
{   IH_TYPE_SUNXI_TOC0, "sunxi_toc0",  "Allwinner TOC0 Boot Image" 
},
+   {   IH_TYPE_FLATDT_LEGACY, "flat_dt_legacy", "Flat Device Tree 
legacy Image", },
{   -1, "",   "",   },
 };
 
diff --git a/include/image.h b/include/image.h
index d7d6a3fe5b81..e578e2c5f1fd 100644
--- a/include/image.h
+++ b/include/image.h
@@ -229,6 +229,7 @@ enum {
IH_TYPE_COPRO,  /* Coprocessor Image for remoteproc*/
IH_TYPE_SUNXI_EGON, /* Allwinner eGON Boot Image */
IH_TYPE_SUNXI_TOC0, /* Allwinner TOC0 Boot Image */
+   IH_TYPE_FLATDT_LEGACY,  /* Binary Flat Device Tree Blob in a 
legacy image */
 
IH_TYPE_COUNT,  /* Number of image types */
 };
diff --git a/tools/default_image.c b/tools/default_image.c
index 4a067e65862e..3b49f0d70e29 100644
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -27,7 +27,8 @@ static struct legacy_img_hdr header;
 static int image_check_image_types(uint8_t type)
 {
if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
-   (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
+   (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT) ||
+   (type == IH_TYPE_FLATDT_LEGACY))
return EXIT_SUCCESS;
else
return EXIT_FAILURE;
@@ -94,6 +95,7 @@ static void image_set_header(void *ptr, struct stat *sbuf, 
int ifd,
uint32_t imagesize;
uint32_t ep;
uint32_t addr;
+   int type;
struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr;
 
checksum = crc32(0,
@@ -113,6 +115,11 @@ static void image_set_header(void *ptr, struct stat *sbuf, 
int ifd,
else
imagesize = sbuf->st_size - sizeof(struct legacy_img_hdr);
 
+   if (params->type == IH_TYPE_FLATDT_LEGACY)
+   type = IH_TYPE_FLATDT;
+   else
+   type = params->type;
+
if (params->os == IH_OS_TEE) {
addr = optee_image_get_load_addr(hdr);
ep = optee_image_get_entry_point(hdr);
@@ -127,7 +134,7 @@ static void image_set_header(void *ptr, struct stat *sbuf, 
int ifd,
image_set_dcrc(hdr, checksum);
image_set_os(hdr, params->os);
image_set_arch(hdr, params->arch);
-   image_set_type(hdr, params->type);
+   image_set_type(hdr, type);
image_set_comp(hdr, params->comp);
 
image_set_name(hdr, params->imagename);
-- 
2.35.1




Re: Binman entry 'u-boot-any' not found in list

2022-10-31 Thread Alper Nebi Yasak
On 31/10/2022 15:56, Roger Quadros wrote:> On 31/10/2022 05:40, Neha
Malcom Francis wrote:
>> On 30/10/22 07:13, Simon Glass wrote:
>>> On Fri, 28 Oct 2022 at 04:58, Fabio Estevam  wrote:
 [Adding Alper - binmam maintainer and Oliver, who faced the same issue on 
 imx8]

(Sorry I've been unavailable here for longer than I hoped for. Still
trying to get some other work into Debian before their freeze.)

 On Fri, Oct 28, 2022 at 7:56 AM Neha Malcom Francis  
 wrote:
>
> Hi!
>
> U-Boot build for J721E with binman enabled on the latest tip of the
> master branch throws an error when I try to use u-boot-spl-nodtb entry
> in my dtsi.
>
> What I'm trying to do is, to show I've made a small example
> (https://github.com/nehamalcom/u-boot/commit/f53dc83944f7774008afbb24fff42904862e9efe)
> that is:
>
> &binman {
>  foo {
>  filename = "foo.bin";
>  u-boot-spl-nodtb {
>  };
>  };
> };
>
> which throws the error
> (https://gist.github.com/nehamalcom/4d855db7e4d5bd03aa29099b0e915e53):
>
> binman: Section '/binman/foo': Symbol '_binman_u_boot_any_prop_image_pos'
>  in entry '/binman/foo/u-boot-spl-nodtb': Entry 'u-boot-any' not
> found in list (u-boot-spl-nodtb,main-section)
>
>
> This can be traced to the WriteSymbols() in etype/u_boot_spl_nodtb.py.
> On commenting out this function since it's not necessary in our
> use-case, the build was successful
> (https://github.com/nehamalcom/u-boot/commit/5666721860e1d2f759440a00c4aee8b6e89b54b3)
>
> Why is binman not picking up on the "any" and choosing u-boot-spl-nodtb
> from the list?

Binman is trying to embed into the SPL the position/size of U-Boot (its
next phase), but there's no U-Boot proper entry in the same binman
image, so it can't. Try disabling CONFIG_SPL_BINMAN_UBOOT_SYMBOLS to
stop writing these symbols since you said you don't need them, see
[1][2] merged since v2022.04 or so.

You can try putting everything into a monolithic binman image, but that
proved difficult to do for i.MX8M, so I added that config and disabled
it there. Maybe it should be disabled by default.


[1] spl: binman: Split binman symbols support from enabling binman
https://lore.kernel.org/u-boot/20220618121316.12061-5-alpernebiya...@gmail.com/

[2] spl: binman: Disable u_boot_any symbols for i.MX8M boards
https://lore.kernel.org/u-boot/20220618121316.12061-8-alpernebiya...@gmail.com/

>>>
>>> You might need this patch?
>>>
>>> https://patchwork.ozlabs.org/project/uboot/patch/20221021002320.1169603-5-...@chromium.org/
>>
>> Even after applying this patch, the entry is not working for me.
> 
> Probably because that patch doesn't deal with CONFIG_SPL case, only 
> CONFIG_TPL and CONFIG_VPL?
> Can you please try to do the same for CONFIG_SPL?

The "u-boot-any" ones are for SPL, and implicitly #ifdef CONFIG_SPL.
Those #ifdefs are a bit underspecified, but 'work' in the sense that for
any phase its next phase is declared.

> e.g.
> 
> #ifdef CONFIG_SPL
> binman_sym_declare(ulong, u_boot_spl, image_pos);
> binman_sym_declare(ulong, u_boot_spl, size);
> #endif
> 
> cheers,
> -roger


Re: Binman entry 'u-boot-any' not found in list

2022-10-31 Thread Neha Malcom Francis

Hi Roger, Alper,

Thank you for the help!

On 31/10/22 21:16, Alper Nebi Yasak wrote:

On 31/10/2022 15:56, Roger Quadros wrote:> On 31/10/2022 05:40, Neha
Malcom Francis wrote:

On 30/10/22 07:13, Simon Glass wrote:

On Fri, 28 Oct 2022 at 04:58, Fabio Estevam  wrote:

[Adding Alper - binmam maintainer and Oliver, who faced the same issue on imx8]


(Sorry I've been unavailable here for longer than I hoped for. Still
trying to get some other work into Debian before their freeze.)


On Fri, Oct 28, 2022 at 7:56 AM Neha Malcom Francis  wrote:


Hi!

U-Boot build for J721E with binman enabled on the latest tip of the
master branch throws an error when I try to use u-boot-spl-nodtb entry
in my dtsi.

What I'm trying to do is, to show I've made a small example
(https://github.com/nehamalcom/u-boot/commit/f53dc83944f7774008afbb24fff42904862e9efe)
that is:

&binman {
  foo {
  filename = "foo.bin";
  u-boot-spl-nodtb {
  };
  };
};

which throws the error
(https://gist.github.com/nehamalcom/4d855db7e4d5bd03aa29099b0e915e53):

binman: Section '/binman/foo': Symbol '_binman_u_boot_any_prop_image_pos'
  in entry '/binman/foo/u-boot-spl-nodtb': Entry 'u-boot-any' not
found in list (u-boot-spl-nodtb,main-section)


This can be traced to the WriteSymbols() in etype/u_boot_spl_nodtb.py.
On commenting out this function since it's not necessary in our
use-case, the build was successful
(https://github.com/nehamalcom/u-boot/commit/5666721860e1d2f759440a00c4aee8b6e89b54b3)

Why is binman not picking up on the "any" and choosing u-boot-spl-nodtb
from the list?


Binman is trying to embed into the SPL the position/size of U-Boot (its
next phase), but there's no U-Boot proper entry in the same binman
image, so it can't. Try disabling CONFIG_SPL_BINMAN_UBOOT_SYMBOLS to
stop writing these symbols since you said you don't need them, see
[1][2] merged since v2022.04 or so.

You can try putting everything into a monolithic binman image, but that
proved difficult to do for i.MX8M, so I added that config and disabled
it there. Maybe it should be disabled by default.


[1] spl: binman: Split binman symbols support from enabling binman
https://lore.kernel.org/u-boot/20220618121316.12061-5-alpernebiya...@gmail.com/

[2] spl: binman: Disable u_boot_any symbols for i.MX8M boards
https://lore.kernel.org/u-boot/20220618121316.12061-8-alpernebiya...@gmail.com/



Yes disabling the CONFIG_SPL_BINMAN_UBOOT_SYMBOLS worked, thank you for 
explaining what it was trying to do. Yes, if the use-case is lower, I 
think it can be 'n' by default.




You might need this patch?

https://patchwork.ozlabs.org/project/uboot/patch/20221021002320.1169603-5-...@chromium.org/


Even after applying this patch, the entry is not working for me.


Probably because that patch doesn't deal with CONFIG_SPL case, only CONFIG_TPL 
and CONFIG_VPL?
Can you please try to do the same for CONFIG_SPL?


The "u-boot-any" ones are for SPL, and implicitly #ifdef CONFIG_SPL.
Those #ifdefs are a bit underspecified, but 'work' in the sense that for
any phase its next phase is declared.


Okay, got it.




e.g.

#ifdef CONFIG_SPL
binman_sym_declare(ulong, u_boot_spl, image_pos);
binman_sym_declare(ulong, u_boot_spl, size);
#endif

cheers,
-roger


--
Thanking You
Neha Malcom Francis


Re: [PATCH v15 10/15] FWU: Add support for the FWU Multi Bank Update feature

2022-10-31 Thread Ilias Apalodimas
Hi Sughosh, 

Ideally this would be better of as a different FMP, but I understand we are
missing some information (the capsule header) on the FMP level.

I think we can include it as is for now and have another look when we add
support for more boards

On Fri, Oct 21, 2022 at 06:16:03PM +0530, Sughosh Ganu wrote:
> The FWU Multi Bank Update feature supports updating firmware images
> to one of multiple sets(also called banks) of images. The firmware
> images are clubbed together in banks, with the system booting images
> from the active bank. Information on the images such as which bank
> they belong to is stored as part of the metadata structure, which is
> stored on the same storage media as the firmware images on a dedicated
> partition.
> 
> At the time of update, the metadata is read to identify the bank to
> which the images need to be flashed(update bank). On a successful
> update, the metadata is modified to set the updated bank as active
> bank to subsequently boot from.
> 
> Signed-off-by: Sughosh Ganu 
> ---
> Changes since V14:
> * Initialise the return value to EFI_INVALID_PARAMETER in
>   fwu_empty_capsule_process() and get rid of the else part as
>   suggested by Ilias
> * Remove the superfluous assignment of EFI_SUCCESS in
>   fwu_post_update_process() as suggested by Ilias
> * Add a check for fwu_empty_capsule_checks_pass() to allow application
>   of empty capsules only in trial state
> 
>  drivers/Kconfig   |   2 +
>  drivers/Makefile  |   1 +
>  include/fwu.h |  30 +
>  lib/Kconfig   |   6 +
>  lib/Makefile  |   1 +
>  lib/efi_loader/efi_capsule.c  | 210 +-
>  lib/efi_loader/efi_firmware.c |  14 +++
>  lib/fwu_updates/Kconfig   |  33 ++
>  lib/fwu_updates/Makefile  |   7 ++
>  lib/fwu_updates/fwu.c |  22 
>  10 files changed, 324 insertions(+), 2 deletions(-)
>  create mode 100644 lib/fwu_updates/Kconfig
>  create mode 100644 lib/fwu_updates/Makefile
> 
> diff --git a/drivers/Kconfig b/drivers/Kconfig
> index 8b6fead351..75ac149d31 100644
> --- a/drivers/Kconfig
> +++ b/drivers/Kconfig
> @@ -44,6 +44,8 @@ source "drivers/fuzz/Kconfig"
>  
>  source "drivers/fpga/Kconfig"
>  
> +source "drivers/fwu-mdata/Kconfig"
> +
>  source "drivers/gpio/Kconfig"
>  
>  source "drivers/hwspinlock/Kconfig"
> diff --git a/drivers/Makefile b/drivers/Makefile
> index 9d9f69a3c9..253cbfb71d 100644
> --- a/drivers/Makefile
> +++ b/drivers/Makefile
> @@ -85,6 +85,7 @@ obj-y += cache/
>  obj-$(CONFIG_CPU) += cpu/
>  obj-y += crypto/
>  obj-$(CONFIG_FASTBOOT) += fastboot/
> +obj-$(CONFIG_FWU_MDATA) += fwu-mdata/
>  obj-y += misc/
>  obj-$(CONFIG_MMC) += mmc/
>  obj-$(CONFIG_NVME) += nvme/
> diff --git a/include/fwu.h b/include/fwu.h
> index a8ed67b0e0..0919ced812 100644
> --- a/include/fwu.h
> +++ b/include/fwu.h
> @@ -98,6 +98,7 @@ struct fwu_mdata_ops {
>  };
>  
>  #define FWU_MDATA_VERSION0x1
> +#define FWU_IMAGE_ACCEPTED   0x1
>  
>  /*
>  * GUID value defined in the FWU specification for identification
> @@ -107,6 +108,24 @@ struct fwu_mdata_ops {
>   EFI_GUID(0x8a7a84a0, 0x8387, 0x40f6, 0xab, 0x41, \
>0xa8, 0xb9, 0xa5, 0xa6, 0x0d, 0x23)
>  
> +/*
> +* GUID value defined in the Dependable Boot specification for
> +* identification of the revert capsule, used for reverting
> +* any image in the updated bank.
> +*/
> +#define FWU_OS_REQUEST_FW_REVERT_GUID \
> + EFI_GUID(0xacd58b4b, 0xc0e8, 0x475f, 0x99, 0xb5, \
> +  0x6b, 0x3f, 0x7e, 0x07, 0xaa, 0xf0)
> +
> +/*
> +* GUID value defined in the Dependable Boot specification for
> +* identification of the accept capsule, used for accepting
> +* an image in the updated bank.
> +*/
> +#define FWU_OS_REQUEST_FW_ACCEPT_GUID \
> + EFI_GUID(0x0c996046, 0xbcc0, 0x4d04, 0x85, 0xec, \
> +  0xe1, 0xfc, 0xed, 0xf1, 0xc6, 0xf8)
> +
>  /**
>   * fwu_check_mdata_validity() - Check for validity of the FWU metadata copies
>   *
> @@ -379,4 +398,15 @@ u8 fwu_update_checks_pass(void);
>   */
>  u8 fwu_empty_capsule_checks_pass(void);
>  
> +/**
> + * fwu_trial_state_ctr_start() - Start the Trial State counter
> + *
> + * Start the counter to identify the platform booting in the
> + * Trial State. The counter is implemented as an EFI variable.
> + *
> + * Return: 0 if OK, -ve on error
> + *
> + */
> +int fwu_trial_state_ctr_start(void);
> +
>  #endif /* _FWU_H_ */
> diff --git a/lib/Kconfig b/lib/Kconfig
> index 6121c80dc8..6abe1d0a86 100644
> --- a/lib/Kconfig
> +++ b/lib/Kconfig
> @@ -978,3 +978,9 @@ config LMB_RESERVED_REGIONS
> memory blocks.
>  
>  endmenu
> +
> +menu "FWU Multi Bank Updates"
> +
> +source lib/fwu_updates/Kconfig
> +
> +endmenu
> diff --git a/lib/Makefile b/lib/Makefile
> index e3deb15287..f2cfd1e428 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -9,6 +9,7 @@ obj-$(CONFIG_EFI) += efi/
>  obj-$(CONFIG_EFI_LOADER) += efi_driver/
>  obj-$(CONFIG_EFI_LOADER) +=

Re: [PATCH v3 02/43] Rename CONFIG_SYS_TEXT_BASE to CONFIG_TEXT_BASE

2022-10-31 Thread Tom Rini
On Thu, Oct 20, 2022 at 06:22:39PM -0600, Simon Glass wrote:

> The current name is inconsistent with SPL which uses CONFIG_SPL_TEXT_BASE
> and this makes it imposible to use CONFIG_VAL().
> 
> Rename it to resolve this problem.
> 
> Signed-off-by: Simon Glass 

For the series, and with a few small changes to apply cleanly again,
applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] usb: Add 1ms delay after first Get Descriptor request

2022-10-31 Thread Simon Glass
Hi Marek,

On Sun, 30 Oct 2022 at 16:38, Marek Vasut  wrote:
>
> Logitech Unifying Receiver 046d:c52b bcdDevice 12.10 seems
> sensitive about the first Get Descriptor request. If there
> are any other requests in the same microframe, the device
> reports bogus data, first of the descriptor parts is not
> sent to the host. Wait over one microframe duration before
> issuing subsequent requests to avoid probe failure with
> this device, since it can be used to connect USB keyboards.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Janne Grunau 
> Cc: Mark Kettenis 
> ---
>  common/usb.c | 11 +++
>  1 file changed, 11 insertions(+)

Is this device complying with the spec or is it broken?

In any case we need a way to enable/disable this as it will slow down
unaffected platforms.

I've also been wondering if (not with this patch) USB can move to
using the cyclic stuff to do its work, so we don't have to wait.

>
> diff --git a/common/usb.c b/common/usb.c
> index 6fcf1e8428e..ae9253dfc0e 100644
> --- a/common/usb.c
> +++ b/common/usb.c
> @@ -999,6 +999,17 @@ static int usb_setup_descriptor(struct usb_device *dev, 
> bool do_read)
> err = get_descriptor_len(dev, 64, 8);
> if (err)
> return err;
> +
> +   /*
> +* Logitech Unifying Receiver 046d:c52b bcdDevice 12.10 seems
> +* sensitive about the first Get Descriptor request. If there
> +* are any other requests in the same microframe, the device
> +* reports bogus data, first of the descriptor parts is not
> +* sent to the host. Wait over one microframe duration here
> +* (1mS for USB 1.x , 125uS for USB 2.0) to avoid triggering
> +* the issue.
> +*/
> +   mdelay(1);
> }
>
> dev->epmaxpacketin[0] = dev->descriptor.bMaxPacketSize0;
> --
> 2.35.1
>

Regards,
Simon


Re: Requiring SPL_DM for new boards?

2022-10-31 Thread Simon Glass
Hi Tom,

On Sun, 30 Oct 2022 at 11:53, Tom Rini  wrote:
>
> On Sat, Oct 29, 2022 at 07:44:01PM -0600, Simon Glass wrote:
> > Hi Tom,
> >
> > On Fri, 21 Oct 2022 at 10:26, Tom Rini  wrote:
> > >
> > > On Fri, Oct 14, 2022 at 09:56:44AM -0600, Simon Glass wrote:
> > >
> > > > Hi,
> > > >
> > > > What do people think about requiring SPL_DM for new boards? Would that
> > > > cause any problems?
> > > >
> > > > There is not much use of of-platdata (compiling the DT into C to save
> > > > space) - is that because it doesn't work for people?
> > > >
> > > > I am particularly keen to drop the old block interface from SPL. It
> > > > seems to me that boards that can use that might have enough space to
> > > > enable SPL_DM and SPL_DM_BLK? What do people think?
> > >
> > > I don't think this works. The problem is we aren't seeing new SoCs that
> > > have a large initial amount of memory but rather many continuing to have
> > > 32KiB or similar tiny sizes. So, I'd rather continue to go with saying
> > > it's optional, but that we won't introduce new SPL functionality that
> > > can be DM or not DM, but only new functionality that needs SPL_DM and
> > > if platforms want it, but have limited memory, we need to go TPL->SPL in
> > > that case.
> >
> > OK I see.
> >
> > What do you think of a migration method for boards which don't use
> > SPL_DM, so they migrate to TPL? Would that cause a lot of problems?
>
> I'm not sure what it gains us. Maybe the first step here is to see what
> the list of non-DM_SPL platforms / SoCs are?

OK:

$./tools/moveconfig.py -b

$ ./tools/moveconfig.py -f SPL ~SPL_DM
323 matches
...

$ ./tools/moveconfig.py -f SPL_DM
333 matches
...

Regards,
Simon


Re: [PATCH v2 4/4] cmd: source: Support specifying config name

2022-10-31 Thread Simon Glass
Hi Tom,

On Sun, 30 Oct 2022 at 08:40, Tom Rini  wrote:
>
> On Sat, Oct 29, 2022 at 07:44:00PM -0600, Simon Glass wrote:
> > Hi Sean,
> >
> > On Fri, 21 Oct 2022 at 15:04, Sean Anderson  wrote:
> > >
> > > On 10/21/22 4:17 PM, Simon Glass wrote:
> > > > On Thu, 20 Oct 2022 at 13:24, Sean Anderson  
> > > > wrote:
> > > >>
> > > >> As discussed previously [1,2], the source command is not safe to use 
> > > >> with
> > > >> verified boot unless there is a key with required = "images" (which 
> > > >> has its
> > > >> own problems). This is because if such a key is absent, signatures are
> > > >> verified but not required. It is assumed that configuration nodes will
> > > >> provide the signature. Because the source command does not use
> > > >> configurations to determine the image to source, effectively no
> > > >> verification takes place.
> > > >>
> > > >> To address this, allow specifying configuration nodes. We use the same
> > > >> syntax as the bootm command (helpfully provided for us by 
> > > >> fit_parse_conf).
> > > >> By default, we first try the default config and then the default 
> > > >> image. To
> > > >> force using a config, # must be present in the command (e.g. `source
> > > >> $loadaddr#my-conf`). For convenience, the config may be omitted, just 
> > > >> like
> > > >> the address may be (e.g. `source \#`). This also works for images
> > > >> (`source \:` behaves exactly like `source` currently does).
> > > >>
> > > >> [1] 
> > > >> https://lore.kernel.org/u-boot/7d711133-d513-5bcb-52f2-a9dbaa9ee...@prevas.dk/
> > > >> [2] 
> > > >> https://lore.kernel.org/u-boot/042dcb34-f85f-351e-1b0e-513f89005...@gmail.com/
> > > >>
> > > >> Signed-off-by: Sean Anderson 
> > > >> ---
> > > >>
> > > >> (no changes since v1)
> > > >>
> > > >>  .../cmd_stm32prog/cmd_stm32prog.c |  2 +-
> > > >>  boot/bootmeth_script.c|  2 +-
> > > >>  cmd/source.c  | 73 +--
> > > >>  doc/uImage.FIT/source_file_format.txt |  3 +
> > > >>  drivers/usb/gadget/f_sdp.c|  2 +-
> > > >>  include/image.h   | 19 +++--
> > > >>  test/py/tests/test_source.py  | 11 ++-
> > > >>  7 files changed, 82 insertions(+), 30 deletions(-)
> > > >
> > > > Reviewed-by: Simon Glass 
> > > >
> > > > But please use single quotes in Python. Double quotes should only be
> > > > used when the string includes single quotes.
> > > >
> > >
> > > Do we have a style guide for python? Judging by `git grep '"' '**.py'`,
> > > double quoting is endemic. IMO single quotes should be used for
> > > identifiers (or things which would be enums in C), and double quotes
> > > elsewhere. But if you want to go the other way, perhaps add something
> > > to checkpatch.
> >
> > Well we use PEP8, with single quotes used for nearly everything. The
> > exceptions are the one I mentioned, and module/function comments.
> >
> > Do we use checkpatch for Python?
>
> Is there a standard python PEP8 checking tool? We should see if
> upstream is interested in a flag or similar to call another tool for
> python linting.

Yes this is pylint and we do already use it, but not in patman so far.
It would be a good thing to add.

Regards,
Simon


Re: [PATCH 13/21] Convert CONFIG_SYS_MMC_MAX_DEVICE to Kconfig

2022-10-31 Thread Simon Glass
On Sun, 30 Oct 2022 at 10:37, Tom Rini  wrote:
>
> On Sat, Oct 29, 2022 at 07:43:36PM -0600, Simon Glass wrote:
> > Hi Tom,
> >
> > On Fri, 28 Oct 2022 at 18:29, Tom Rini  wrote:
> > >
> > > This converts the following to Kconfig:
> > >CONFIG_SYS_MMC_MAX_DEVICE
> > >
> > > Signed-off-by: Tom Rini 
> > > ---
> > >  api/Kconfig|  5 +
> > >  api/api_storage.c  |  4 
> > >  include/configs/am335x_evm.h   | 18 --
> > >  include/configs/stm32mp13_common.h |  3 ---
> > >  include/configs/stm32mp15_common.h |  3 ---
> > >  include/configs/sunxi-common.h |  2 --
> > >  include/configs/tegra-common.h |  7 ---
> > >  include/configs/zynq-common.h  |  3 ---
> > >  8 files changed, 5 insertions(+), 40 deletions(-)
> >
> > It seems odd that none of the boards end up with a defconfig setting
> > it to 2 or 3.
>
> What happened here is that boards were setting the value to something
> else, but never using it.

Ah OK, that's good to fix.

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] console: file should always be non-negative

2022-10-31 Thread Simon Glass
Hi Heinrich,

On Sat, 29 Oct 2022 at 20:47, Heinrich Schuchardt
 wrote:
>
>
>
> On 10/30/22 02:43, Simon Glass wrote:
> > Hi Heinrich,
> >
> > On Sat, 22 Oct 2022 at 03:49, Heinrich Schuchardt
> >  wrote:
> >>
> >> We use the parameter file in console function to choose from an array after
> >> checking against MAX_FILES but we never check if the value of file is
> >> negative.
> >>
> >> Running ./u-boot -T -l and issuing the poweroff command has resulted in
> >> crashes because
> >>
> >> os_exit() results in std::ostream::flush() calling U-Boot's fflush with
> >> file being a pointer which when converted to int may be represented by a
> >> negative number.
> >>
> >> This shows that checking against MAX_FILES is not enough we have to ensure
> >> that the file argument is always positive.
> >>
> >> Signed-off-by: Heinrich Schuchardt 
> >> ---
> >>   common/console.c | 10 +-
> >>   1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > How about changing the 'file' parameter to a uint? It seems that this
> > is what it is supposed to be, from your checks.
>
> As we support only 3 values the variable type should have been defined
> as an enum.
>
> Changing the parameter type would have meant to look at all callers and
> check if the value of file is stored in a variable and replace that
> variable type too.
>
> I just went for the least invasive change.

Well I don't really mind.

Reviewed-by: Simon Glass 


Re: [PATCH v2 1/2] tools: mkimage: don't print error message "Success" in case of failure

2022-10-31 Thread Simon Glass
On Mon, 31 Oct 2022 at 08:51, Marc Kleine-Budde  wrote:
>
> In case there's no struct image_type_params::set_header callback, no
> "errno" will be set. Don't fail with an error message, followed by
> "Success". Remove the printing of the human readable "errno" value.
>
> Signed-off-by: Marc Kleine-Budde 
> ---
>  tools/mkimage.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH] fdt: Fix bounds check in devfdt_get_addr_index

2022-10-31 Thread Simon Glass
On Sun, 30 Oct 2022 at 21:41, Samuel Holland  wrote:
>
> reg must contain enough cells for the entire next address/size pair
> after skipping `index` pairs. The previous code allows an out-of-bounds
> read when na + ns > 1.
>
> Fixes: 69b41388ba45 ("dm: core: Add a new api to get indexed device address")
> Signed-off-by: Samuel Holland 
> ---
>
>  drivers/core/fdtaddr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images

2022-10-31 Thread Simon Glass
Hi,

On Mon, 31 Oct 2022 at 08:21, Sean Anderson  wrote:
>
> On 10/31/22 10:13, Marc Kleine-Budde wrote:
> > If the user select the image type "flat_dt" a FIT image will be build.
> > This breaks the legacy use case of putting a Flat Device Tree into a
> > legacy u-boot image.
> >
> > Add command line options "-L" and "--legacy" to let the user force the
> > creation of a legacy u-boot image, even if "flat_dt" is selected.
> >
> > Link: 
> > https://lore.kernel.org/all/20221028155205.ojw6tcso2fofg...@pengutronix.de
> > Signed-off-by: Marc Kleine-Budde 
> > ---
> >   tools/default_image.c | 1 +
> >   tools/fit_common.c| 3 +++
> >   tools/mkimage.c   | 7 ++-
> >   3 files changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/default_image.c b/tools/default_image.c
> > index 9a6b50a946ba..3673eaa63de2 100644
> > --- a/tools/default_image.c
> > +++ b/tools/default_image.c
> > @@ -27,6 +27,7 @@ static struct legacy_img_hdr header;
> >   static int image_check_image_types(uint8_t type, bool legacy)
> >   {
> >   if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
> > + ((type == IH_TYPE_FLATDT) && legacy) ||
> >   (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
> >   return EXIT_SUCCESS;
> >   else
> > diff --git a/tools/fit_common.c b/tools/fit_common.c
> > index b4aa89b53577..eba13a789a72 100644
> > --- a/tools/fit_common.c
> > +++ b/tools/fit_common.c
> > @@ -43,6 +43,9 @@ int fit_verify_header(unsigned char *ptr, int image_size,
> >
> >   int fit_check_image_types(uint8_t type, bool legacy)
> >   {
> > + if (legacy)
> > + return EXIT_FAILURE;
> > +
> >   if (type == IH_TYPE_FLATDT)
> >   return EXIT_SUCCESS;
> >   else
> > diff --git a/tools/mkimage.c b/tools/mkimage.c
> > index 6d029afab3a8..9e9edd65583e 100644
> > --- a/tools/mkimage.c
> > +++ b/tools/mkimage.c
> > @@ -91,6 +91,7 @@ static void usage(const char *msg)
> >   fprintf(stderr,
> >   "   %s [-x] -A arch -O os -T type -C comp -a addr -e ep 
> > -n name -d data_file[:data_file...] image\n"
> >   "  -A ==> set architecture to 'arch'\n"
> > + "  -L ==> force legacy image\n"
> >   "  -O ==> set operating system to 'os'\n"
> >   "  -T ==> set image type to 'type'\n"
> >   "  -C ==> set compression type 'comp'\n"
> > @@ -159,7 +160,7 @@ static int add_content(int type, const char *fname)
> >   }
> >
> >   static const char optstring[] =
> > - "a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:ln:N:o:O:p:qrR:stT:vVx";
> > + "a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:Lln:N:o:O:p:qrR:stT:vVx";
> >
> >   static const struct option longopts[] = {
> >   { "load-address", required_argument, NULL, 'a' },
> > @@ -181,6 +182,7 @@ static const struct option longopts[] = {
> >   { "key-dir", required_argument, NULL, 'k' },
> >   { "key-dest", required_argument, NULL, 'K' },
> >   { "list", no_argument, NULL, 'l' },
> > + { "legacy", no_argument, NULL, 'L' },
> >   { "config", required_argument, NULL, 'n' },
> >   { "engine", required_argument, NULL, 'N' },
> >   { "algo", required_argument, NULL, 'o' },
> > @@ -298,6 +300,9 @@ static void process_args(int argc, char **argv)
> >   case 'l':
> >   params.lflag = 1;
> >   break;
> > + case 'L':
> > + params.Lflag = 1;
> > + break;
> >   case 'n':
> >   params.imagename = optarg;
> >   break;
>
> Please add some documentation to the man page (doc/mkimage.1). And also 
> consider not using a short option.

I like short options :-)

Regards,
Simon


Re: [PATCH 00/16] video: Enhancements to Truetype console

2022-10-31 Thread Simon Glass
Hi Anatolij,

On Mon, 31 Oct 2022 at 07:56, Anatolij Gustschin  wrote:
>
> Hi Simon,
>
> On Mon, 24 Oct 2022 05:45:34 -0600
> Simon Glass s...@chromium.org wrote:
>
> > Hi Anatolij,
> >
> > On Thu, 6 Oct 2022 at 08:36, Simon Glass  wrote:
> > >
> > > This series includes some minor enhancements to the Truetype console to
> > > allow it to support multiple fonts and sizes at the same time. This is
> > > useful for displays where the title needs to be in a larger font than the
> > > rest of the text on the display.
> > >
> > > The fonts must still be compiled into U-Boot, but now it is possible to
> > > change fonts as needed.
> > >
> > > Some other minor fixes and tweaks are included as well.
> > >
> > > This is mostly in service of the upcoming VBE boot menu which needs to
> > > make better use of fonts.
> > >
> >
> > I sent this and another series with video patches. Any thoughts?
>
> I've applied both series. When applying, I changed patch
>
>  [PATCH 04/16] video: Move the console commands to cmd/
>
> to keep vidconsole_position_cursor() in vidconsole uclass to avoid
> build errors in common/splash.c.

Thanks for fixing that!

- Simon

>
> Thanks!

>
> --
> Anatolij


Re: [PATCH 1/1] cli: always show cursor

2022-10-31 Thread Simon Glass
Hi Heinrich,

On Sat, 29 Oct 2022 at 20:56, Heinrich Schuchardt
 wrote:
>
>
>
> On 10/30/22 02:43, Simon Glass wrote:
> > Hi Heinrich,
> >
> > On Thu, 27 Oct 2022 at 10:41, Heinrich Schuchardt
> >  wrote:
> >>
> >>
> >>
> >> On 10/27/22 17:22, Simon Glass wrote:
> >>> Hi Heinrich,
> >>>
> >>> On Wed, 26 Oct 2022 at 00:13, Heinrich Schuchardt
> >>>  wrote:
> 
> 
> 
>  On 10/26/22 01:35, Simon Glass wrote:
> > Hi Heinrich,
> >
> > On Sat, 22 Oct 2022 at 03:21, Heinrich Schuchardt
> >  wrote:
> >>
> >> We may enter the command line interface in a state where on the remote
> >> console the cursor is not shown. Send an escape sequence to enable it.
> >>
> >> Signed-off-by: Heinrich Schuchardt 
> >> ---
> >> common/main.c | 4 
> >> 1 file changed, 4 insertions(+)
> >>
> >> diff --git a/common/main.c b/common/main.c
> >> index 682f3359ea..4e7e7b17d6 100644
> >> --- a/common/main.c
> >> +++ b/common/main.c
> >> @@ -7,6 +7,7 @@
> >> /* #define DEBUG   */
> >>
> >> #include 
> >> +#include 
> >> #include 
> >> #include 
> >> #include 
> >> @@ -66,6 +67,9 @@ void main_loop(void)
> >>
> >>autoboot_command(s);
> >>
> >> +   if (!CONFIG_IS_ENABLED(DM_VIDEO) || 
> >> CONFIG_IS_ENABLED(VIDEO_ANSI))
> >> +   printf(ANSI_CURSOR_SHOW "\n");
> >
> > Could we create a library which emits these codes? Like 
> > ansi_cursor_show() ?
> 
>  The question is not if we could but if we should.
> 
>  Up to now we tried to call printf() only once where ANSI_* is only one
>  part of the output string.
> 
>  E.g. cmd/eficonfig.c:415:
> printf(ANSI_CLEAR_CONSOLE
>    ANSI_CURSOR_POSITION
>    ANSI_CURSOR_SHOW, 1, 1);
> 
>  This minimizes the number of call library calls but may not be very 
>  elegant.
> 
>  Creating a library function for ANSI_CURSOR_SHOW alone does not make
>  much sense to me. Should you want to convert our code base from using
>  ANSI_* to library functions this should cover the whole code base.
> 
>  So I think we should let this patch pass as it solves a current problem
>  and leave creating a ANSI_* function library to a separate exercise.
> >>>
> >>> Then we should add this to the serial API...what we have here is quite
> >>> bizarre in a way, since it outputs escape characters as the default
> >>> for U-Boot. Mostly we don't need it.
> >>>
> >>> So add a set_cursor_visible() method to the serial API and allow it to
> >>> be controlled via platform data in the serial driver.
> >>
> >> I have no clue which platform data you might be thinking of.
> >>
> >> It is also not my intention to eject the escape sequence whenever a
> >> serial console is probed.
> >>
> >> Using serial_puts() in this patch instead of printf() would help to
> >> avoid the CONFIG dependency.
> >
> > Here's what should happen:
> >
> > 1. ANSI codes should not appear in logs or on CI (this is currently a
> > problem with EFI tests)
>
> A program outputting different things in continuous integration then in
> real live does not provide realistic testing.
>
> It is the CI that has to adapt not the program under test.
>
> Which logs are you talking about?
>
> > 2. We cannot show an ANSI code on boot by default, since that puts
> > ctrl characters into every start-up of U-Boot
>
> Why would that be a problem?
>
> >
> > So I think my suggestion makes sense. See drivers/serial/sandbox.c and
> > have a way of calling isatty() to check the terminal type (with a
> > cmdline flag to override it, see -t for example). Then we can get the
> > correct behaviour.
>
> isatty() is not a U-Boot function. So it is irrelevant in this context.
>
> You cannot detect if a serial console understands ANSI sequences without
> sending any.

NAK

Please try a little harder to understand my POV above.

Regards,
Simon


Re: [PATCH v2 4/4] cmd: source: Support specifying config name

2022-10-31 Thread Tom Rini
On Mon, Oct 31, 2022 at 01:27:08PM -0600, Simon Glass wrote:
> Hi Tom,
> 
> On Sun, 30 Oct 2022 at 08:40, Tom Rini  wrote:
> >
> > On Sat, Oct 29, 2022 at 07:44:00PM -0600, Simon Glass wrote:
> > > Hi Sean,
> > >
> > > On Fri, 21 Oct 2022 at 15:04, Sean Anderson  
> > > wrote:
> > > >
> > > > On 10/21/22 4:17 PM, Simon Glass wrote:
> > > > > On Thu, 20 Oct 2022 at 13:24, Sean Anderson  
> > > > > wrote:
> > > > >>
> > > > >> As discussed previously [1,2], the source command is not safe to use 
> > > > >> with
> > > > >> verified boot unless there is a key with required = "images" (which 
> > > > >> has its
> > > > >> own problems). This is because if such a key is absent, signatures 
> > > > >> are
> > > > >> verified but not required. It is assumed that configuration nodes 
> > > > >> will
> > > > >> provide the signature. Because the source command does not use
> > > > >> configurations to determine the image to source, effectively no
> > > > >> verification takes place.
> > > > >>
> > > > >> To address this, allow specifying configuration nodes. We use the 
> > > > >> same
> > > > >> syntax as the bootm command (helpfully provided for us by 
> > > > >> fit_parse_conf).
> > > > >> By default, we first try the default config and then the default 
> > > > >> image. To
> > > > >> force using a config, # must be present in the command (e.g. `source
> > > > >> $loadaddr#my-conf`). For convenience, the config may be omitted, 
> > > > >> just like
> > > > >> the address may be (e.g. `source \#`). This also works for images
> > > > >> (`source \:` behaves exactly like `source` currently does).
> > > > >>
> > > > >> [1] 
> > > > >> https://lore.kernel.org/u-boot/7d711133-d513-5bcb-52f2-a9dbaa9ee...@prevas.dk/
> > > > >> [2] 
> > > > >> https://lore.kernel.org/u-boot/042dcb34-f85f-351e-1b0e-513f89005...@gmail.com/
> > > > >>
> > > > >> Signed-off-by: Sean Anderson 
> > > > >> ---
> > > > >>
> > > > >> (no changes since v1)
> > > > >>
> > > > >>  .../cmd_stm32prog/cmd_stm32prog.c |  2 +-
> > > > >>  boot/bootmeth_script.c|  2 +-
> > > > >>  cmd/source.c  | 73 
> > > > >> +--
> > > > >>  doc/uImage.FIT/source_file_format.txt |  3 +
> > > > >>  drivers/usb/gadget/f_sdp.c|  2 +-
> > > > >>  include/image.h   | 19 +++--
> > > > >>  test/py/tests/test_source.py  | 11 ++-
> > > > >>  7 files changed, 82 insertions(+), 30 deletions(-)
> > > > >
> > > > > Reviewed-by: Simon Glass 
> > > > >
> > > > > But please use single quotes in Python. Double quotes should only be
> > > > > used when the string includes single quotes.
> > > > >
> > > >
> > > > Do we have a style guide for python? Judging by `git grep '"' '**.py'`,
> > > > double quoting is endemic. IMO single quotes should be used for
> > > > identifiers (or things which would be enums in C), and double quotes
> > > > elsewhere. But if you want to go the other way, perhaps add something
> > > > to checkpatch.
> > >
> > > Well we use PEP8, with single quotes used for nearly everything. The
> > > exceptions are the one I mentioned, and module/function comments.
> > >
> > > Do we use checkpatch for Python?
> >
> > Is there a standard python PEP8 checking tool? We should see if
> > upstream is interested in a flag or similar to call another tool for
> > python linting.
> 
> Yes this is pylint and we do already use it, but not in patman so far.
> It would be a good thing to add.

I'd start by trying to put it in checkpatch.pl and seeing if upstream is
interested, the kernel has a bunch of python tools too these days.

-- 
Tom


signature.asc
Description: PGP signature


Re: Requiring SPL_DM for new boards?

2022-10-31 Thread Tom Rini
On Mon, Oct 31, 2022 at 01:27:06PM -0600, Simon Glass wrote:
> Hi Tom,
> 
> On Sun, 30 Oct 2022 at 11:53, Tom Rini  wrote:
> >
> > On Sat, Oct 29, 2022 at 07:44:01PM -0600, Simon Glass wrote:
> > > Hi Tom,
> > >
> > > On Fri, 21 Oct 2022 at 10:26, Tom Rini  wrote:
> > > >
> > > > On Fri, Oct 14, 2022 at 09:56:44AM -0600, Simon Glass wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > What do people think about requiring SPL_DM for new boards? Would that
> > > > > cause any problems?
> > > > >
> > > > > There is not much use of of-platdata (compiling the DT into C to save
> > > > > space) - is that because it doesn't work for people?
> > > > >
> > > > > I am particularly keen to drop the old block interface from SPL. It
> > > > > seems to me that boards that can use that might have enough space to
> > > > > enable SPL_DM and SPL_DM_BLK? What do people think?
> > > >
> > > > I don't think this works. The problem is we aren't seeing new SoCs that
> > > > have a large initial amount of memory but rather many continuing to have
> > > > 32KiB or similar tiny sizes. So, I'd rather continue to go with saying
> > > > it's optional, but that we won't introduce new SPL functionality that
> > > > can be DM or not DM, but only new functionality that needs SPL_DM and
> > > > if platforms want it, but have limited memory, we need to go TPL->SPL in
> > > > that case.
> > >
> > > OK I see.
> > >
> > > What do you think of a migration method for boards which don't use
> > > SPL_DM, so they migrate to TPL? Would that cause a lot of problems?
> >
> > I'm not sure what it gains us. Maybe the first step here is to see what
> > the list of non-DM_SPL platforms / SoCs are?
> 
> OK:
> 
> $./tools/moveconfig.py -b
> 
> $ ./tools/moveconfig.py -f SPL ~SPL_DM
> 323 matches
> ...
> 
> $ ./tools/moveconfig.py -f SPL_DM
> 333 matches
> ...

OK, if we start parsing things out, PowerPC is one chunk of that and
won't change. Another chunk of that is sunxi which is a "still making
new SoCs with very small SRAM" and it's worth talking with Andre for
thoughts there. A large swath of the rest is layerscape / imx6/7/8 and
it's worth rfc'ing a patch or two to move their board-specific "select
SPL_DM if SPL" to a higher level ARCH_xxx line. Especially for the imx8*
ones.

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] efi: arm,arm64: Fix relocations from not being loaded

2022-10-31 Thread Patrick Zacharias
Prior to this commit, the relocations would not get loaded by the efi 
loader.


This lead to none of the relocations being applied.

Signed-off-by: Fighter19 <1475802+fighte...@users.noreply.github.com>
---
 arch/arm/lib/elf_aarch64_efi.lds | 2 +-
 arch/arm/lib/elf_arm_efi.lds | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/lib/elf_aarch64_efi.lds 
b/arch/arm/lib/elf_aarch64_efi.lds

index c0604dad46..1982864d17 100644
--- a/arch/arm/lib/elf_aarch64_efi.lds
+++ b/arch/arm/lib/elf_aarch64_efi.lds
@@ -46,12 +46,12 @@ SECTIONS
     *(COMMON)
     . = ALIGN(512);
     _bss_end = .;
-        _edata = .;
 }
 .rela.dyn : { *(.rela.dyn) }
 .rela.plt : { *(.rela.plt) }
 .rela.got : { *(.rela.got) }
 .rela.data : { *(.rela.data) *(.rela.data*) }
+    _edata = .;
 _data_size = . - _etext;

 . = ALIGN(4096);
diff --git a/arch/arm/lib/elf_arm_efi.lds b/arch/arm/lib/elf_arm_efi.lds
index 767ebda635..c1b58a8033 100644
--- a/arch/arm/lib/elf_arm_efi.lds
+++ b/arch/arm/lib/elf_arm_efi.lds
@@ -46,12 +46,12 @@ SECTIONS
     *(COMMON)
     . = ALIGN(512);
     _bss_end = .;
-        _edata = .;
 }
 .rel.dyn : { *(.rel.dyn) }
 .rel.plt : { *(.rel.plt) }
 .rel.got : { *(.rel.got) }
 .rel.data : { *(.rel.data) *(.rel.data*) }
+    _edata = .;
 _data_size = . - _etext;

 /DISCARD/ : {
--
2.25.1




Re: [PATCH] usb: Add 1ms delay after first Get Descriptor request

2022-10-31 Thread Marek Vasut

On 10/31/22 20:27, Simon Glass wrote:

Hi Marek,


Hi,


On Sun, 30 Oct 2022 at 16:38, Marek Vasut  wrote:


Logitech Unifying Receiver 046d:c52b bcdDevice 12.10 seems
sensitive about the first Get Descriptor request. If there
are any other requests in the same microframe, the device
reports bogus data, first of the descriptor parts is not
sent to the host. Wait over one microframe duration before
issuing subsequent requests to avoid probe failure with
this device, since it can be used to connect USB keyboards.

Signed-off-by: Marek Vasut 
---
Cc: Janne Grunau 
Cc: Mark Kettenis 
---
  common/usb.c | 11 +++
  1 file changed, 11 insertions(+)


Is this device complying with the spec or is it broken?

In any case we need a way to enable/disable this as it will slow down
unaffected platforms.


This makes little difference, since anyone can plug such device into a 
port and suddenly the platform is affected. We cannot really predict 
what users have on their desks.


Specifically for this case, the logitech receiver seems to be a rather 
common device.



I've also been wondering if (not with this patch) USB can move to
using the cyclic stuff to do its work, so we don't have to wait.


EHCI HCD already partly does, at least for storage, so yes, patches welcome.


Re: [PATCH 1/1] cli: always show cursor

2022-10-31 Thread Heinrich Schuchardt




On 10/31/22 20:27, Simon Glass wrote:

Hi Heinrich,

On Sat, 29 Oct 2022 at 20:56, Heinrich Schuchardt
 wrote:




On 10/30/22 02:43, Simon Glass wrote:

Hi Heinrich,

On Thu, 27 Oct 2022 at 10:41, Heinrich Schuchardt
 wrote:




On 10/27/22 17:22, Simon Glass wrote:

Hi Heinrich,

On Wed, 26 Oct 2022 at 00:13, Heinrich Schuchardt
 wrote:




On 10/26/22 01:35, Simon Glass wrote:

Hi Heinrich,

On Sat, 22 Oct 2022 at 03:21, Heinrich Schuchardt
 wrote:


We may enter the command line interface in a state where on the remote
console the cursor is not shown. Send an escape sequence to enable it.

Signed-off-by: Heinrich Schuchardt 
---
 common/main.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/common/main.c b/common/main.c
index 682f3359ea..4e7e7b17d6 100644
--- a/common/main.c
+++ b/common/main.c
@@ -7,6 +7,7 @@
 /* #define DEBUG   */

 #include 
+#include 
 #include 
 #include 
 #include 
@@ -66,6 +67,9 @@ void main_loop(void)

autoboot_command(s);

+   if (!CONFIG_IS_ENABLED(DM_VIDEO) || CONFIG_IS_ENABLED(VIDEO_ANSI))
+   printf(ANSI_CURSOR_SHOW "\n");


Could we create a library which emits these codes? Like ansi_cursor_show() ?


The question is not if we could but if we should.

Up to now we tried to call printf() only once where ANSI_* is only one
part of the output string.

E.g. cmd/eficonfig.c:415:
printf(ANSI_CLEAR_CONSOLE
   ANSI_CURSOR_POSITION
   ANSI_CURSOR_SHOW, 1, 1);

This minimizes the number of call library calls but may not be very elegant.

Creating a library function for ANSI_CURSOR_SHOW alone does not make
much sense to me. Should you want to convert our code base from using
ANSI_* to library functions this should cover the whole code base.

So I think we should let this patch pass as it solves a current problem
and leave creating a ANSI_* function library to a separate exercise.


Then we should add this to the serial API...what we have here is quite
bizarre in a way, since it outputs escape characters as the default
for U-Boot. Mostly we don't need it.

So add a set_cursor_visible() method to the serial API and allow it to
be controlled via platform data in the serial driver.


I have no clue which platform data you might be thinking of.

It is also not my intention to eject the escape sequence whenever a
serial console is probed.

Using serial_puts() in this patch instead of printf() would help to
avoid the CONFIG dependency.


Here's what should happen:

1. ANSI codes should not appear in logs or on CI (this is currently a
problem with EFI tests)


A program outputting different things in continuous integration then in
real live does not provide realistic testing.

It is the CI that has to adapt not the program under test.

Which logs are you talking about?


2. We cannot show an ANSI code on boot by default, since that puts
ctrl characters into every start-up of U-Boot


Why would that be a problem?



So I think my suggestion makes sense. See drivers/serial/sandbox.c and
have a way of calling isatty() to check the terminal type (with a
cmdline flag to override it, see -t for example). Then we can get the
correct behaviour.


isatty() is not a U-Boot function. So it is irrelevant in this context.

You cannot detect if a serial console understands ANSI sequences without
sending any.


NAK

Please try a little harder to understand my POV above.


I don't understand what your point of view as you did not answer my 
question.


The only case of logs being written in a production U-Boot is given by 
CONGIG_LOG_SYSLOG=y which is not affected by the patch. So no clue what 
logs you refer to.


Concerning CI it is clear that the CI has to handle ANSI sequences in 
the U-Boot output sensibly. The idea of U-Boot producing different 
output running in CI than outside CI would contradict the purpose of the CI.


I further have no clue what problem you face with the output of the EFI 
unit tests. Could you, please, be more specific.


Best regards

Heinrich


Re: [PATCHv2 1/5] FWU: Add FWU metadata access driver for MTD storage regions

2022-10-31 Thread Jassi Brar
On Fri, Oct 14, 2022 at 2:07 AM Ilias Apalodimas
 wrote:
>
> On Sun, Oct 02, 2022 at 06:51:32PM -0500, jassisinghb...@gmail.com wrote:
> > +
> > +static bool mtd_is_aligned_with_block_size(struct mtd_info *mtd, u64 size)
> > +{
> > + return !do_div(size, mtd->erasesize);
> > +}
> > +
>
> Can we please add some sphinx style documentation overall ?
>
I can but I thought that is for public api and not static helper functions?


> > +
> > +static int fwu_mtd_check_mdata(struct udevice *dev)
> > +{
> > + struct fwu_mdata_mtd_priv *mtd_priv = dev_get_priv(dev);
> > + struct fwu_mdata primary, secondary;
> > + bool pri = false, sec = false;
> > + int ret;
> > +
> > + ret = fwu_mtd_load_mdata(mtd_priv->mtd, &primary,
> > +  
> > mtd_priv->pri_offset, FWU_MDATA_PRIMARY);
> > + if (ret < 0)
> > + log_debug("Failed to read the primary mdata: %d\n", ret);
> > + else
> > + pri = true;
> > +
> > + ret = fwu_mtd_load_mdata(mtd_priv->mtd, &secondary,
> > +  
> > mtd_priv->sec_offset, FWU_MDATA_SECONDARY);
> > + if (ret < 0)
> > + log_debug("Failed to read the secondary mdata: %d\n", ret);
> > + else
> > + sec = true;
> > +
> > + if (pri && sec) {
> > + if (memcmp(&primary, &secondary, sizeof(struct fwu_mdata))) {
> > + log_debug("The primary and the secondary mdata are 
> > different\n");
> > + ret = -1;
> > + }
> > + } else if (pri) {
> > + ret = fwu_mtd_save_secondary_mdata(mtd_priv, &primary);
> > + if (ret < 0)
> > + log_debug("Restoring secondary mdata partition 
> > failed\n");
> > + } else if (sec) {
> > + ret = fwu_mtd_save_primary_mdata(mtd_priv, &secondary);
> > + if (ret < 0)
> > + log_debug("Restoring primary mdata partition 
> > failed\n");
> > + }
>
> Same on this one.  The requirements here are
> - Read our metadata
> - Compare the 2 partitions
>
> The only thing that's 'hardware' specific here is reading the metadata.  We
> should at least unify the comparing part and restoration in case of
> failures, no ?
>
Yes.  Since redundant copy of meta-data is a requirement of the spec,
we should maintain that in the fwu core code.
Maybe something like adding 'bool primary' argument to get_mdata() and
update_mdata()

thanks


Re: [PATCH 1/1] cli: always show cursor

2022-10-31 Thread Simon Glass
Hi Heinrich,

On Mon, 31 Oct 2022 at 15:58, Heinrich Schuchardt
 wrote:
>
>
>
> On 10/31/22 20:27, Simon Glass wrote:
> > Hi Heinrich,
> >
> > On Sat, 29 Oct 2022 at 20:56, Heinrich Schuchardt
> >  wrote:
> >>
> >>
> >>
> >> On 10/30/22 02:43, Simon Glass wrote:
> >>> Hi Heinrich,
> >>>
> >>> On Thu, 27 Oct 2022 at 10:41, Heinrich Schuchardt
> >>>  wrote:
> 
> 
> 
>  On 10/27/22 17:22, Simon Glass wrote:
> > Hi Heinrich,
> >
> > On Wed, 26 Oct 2022 at 00:13, Heinrich Schuchardt
> >  wrote:
> >>
> >>
> >>
> >> On 10/26/22 01:35, Simon Glass wrote:
> >>> Hi Heinrich,
> >>>
> >>> On Sat, 22 Oct 2022 at 03:21, Heinrich Schuchardt
> >>>  wrote:
> 
>  We may enter the command line interface in a state where on the 
>  remote
>  console the cursor is not shown. Send an escape sequence to enable 
>  it.
> 
>  Signed-off-by: Heinrich Schuchardt 
>  
>  ---
>   common/main.c | 4 
>   1 file changed, 4 insertions(+)
> 
>  diff --git a/common/main.c b/common/main.c
>  index 682f3359ea..4e7e7b17d6 100644
>  --- a/common/main.c
>  +++ b/common/main.c
>  @@ -7,6 +7,7 @@
>   /* #define DEBUG   */
> 
>   #include 
>  +#include 
>   #include 
>   #include 
>   #include 
>  @@ -66,6 +67,9 @@ void main_loop(void)
> 
>  autoboot_command(s);
> 
>  +   if (!CONFIG_IS_ENABLED(DM_VIDEO) || 
>  CONFIG_IS_ENABLED(VIDEO_ANSI))
>  +   printf(ANSI_CURSOR_SHOW "\n");
> >>>
> >>> Could we create a library which emits these codes? Like 
> >>> ansi_cursor_show() ?
> >>
> >> The question is not if we could but if we should.
> >>
> >> Up to now we tried to call printf() only once where ANSI_* is only one
> >> part of the output string.
> >>
> >> E.g. cmd/eficonfig.c:415:
> >> printf(ANSI_CLEAR_CONSOLE
> >>ANSI_CURSOR_POSITION
> >>ANSI_CURSOR_SHOW, 1, 1);
> >>
> >> This minimizes the number of call library calls but may not be very 
> >> elegant.
> >>
> >> Creating a library function for ANSI_CURSOR_SHOW alone does not make
> >> much sense to me. Should you want to convert our code base from using
> >> ANSI_* to library functions this should cover the whole code base.
> >>
> >> So I think we should let this patch pass as it solves a current problem
> >> and leave creating a ANSI_* function library to a separate exercise.
> >
> > Then we should add this to the serial API...what we have here is quite
> > bizarre in a way, since it outputs escape characters as the default
> > for U-Boot. Mostly we don't need it.
> >
> > So add a set_cursor_visible() method to the serial API and allow it to
> > be controlled via platform data in the serial driver.
> 
>  I have no clue which platform data you might be thinking of.
> 
>  It is also not my intention to eject the escape sequence whenever a
>  serial console is probed.
> 
>  Using serial_puts() in this patch instead of printf() would help to
>  avoid the CONFIG dependency.
> >>>
> >>> Here's what should happen:
> >>>
> >>> 1. ANSI codes should not appear in logs or on CI (this is currently a
> >>> problem with EFI tests)
> >>
> >> A program outputting different things in continuous integration then in
> >> real live does not provide realistic testing.
> >>
> >> It is the CI that has to adapt not the program under test.
> >>
> >> Which logs are you talking about?
> >>
> >>> 2. We cannot show an ANSI code on boot by default, since that puts
> >>> ctrl characters into every start-up of U-Boot
> >>
> >> Why would that be a problem?
> >>
> >>>
> >>> So I think my suggestion makes sense. See drivers/serial/sandbox.c and
> >>> have a way of calling isatty() to check the terminal type (with a
> >>> cmdline flag to override it, see -t for example). Then we can get the
> >>> correct behaviour.
> >>
> >> isatty() is not a U-Boot function. So it is irrelevant in this context.
> >>
> >> You cannot detect if a serial console understands ANSI sequences without
> >> sending any.
> >
> > NAK
> >
> > Please try a little harder to understand my POV above.
>
> I don't understand what your point of view as you did not answer my
> question.
>
> The only case of logs being written in a production U-Boot is given by
> CONGIG_LOG_SYSLOG=y which is not affected by the patch. So no clue what
> logs you refer to.

If you run the tests (e.g. make check) and get a failure you can see
the output from them on the console. At the moment some tests clear
the console, change colour and all sorts of things. That is not good
behaviour. Can you see that?

>
> Concerning

Re: [PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images

2022-10-31 Thread Sean Anderson

On 10/31/22 15:27, Simon Glass wrote:

Hi,

On Mon, 31 Oct 2022 at 08:21, Sean Anderson  wrote:


On 10/31/22 10:13, Marc Kleine-Budde wrote:

If the user select the image type "flat_dt" a FIT image will be build.
This breaks the legacy use case of putting a Flat Device Tree into a
legacy u-boot image.

Add command line options "-L" and "--legacy" to let the user force the
creation of a legacy u-boot image, even if "flat_dt" is selected.

Link: https://lore.kernel.org/all/20221028155205.ojw6tcso2fofg...@pengutronix.de
Signed-off-by: Marc Kleine-Budde 
---
   tools/default_image.c | 1 +
   tools/fit_common.c| 3 +++
   tools/mkimage.c   | 7 ++-
   3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/default_image.c b/tools/default_image.c
index 9a6b50a946ba..3673eaa63de2 100644
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -27,6 +27,7 @@ static struct legacy_img_hdr header;
   static int image_check_image_types(uint8_t type, bool legacy)
   {
   if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
+ ((type == IH_TYPE_FLATDT) && legacy) ||
   (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
   return EXIT_SUCCESS;
   else
diff --git a/tools/fit_common.c b/tools/fit_common.c
index b4aa89b53577..eba13a789a72 100644
--- a/tools/fit_common.c
+++ b/tools/fit_common.c
@@ -43,6 +43,9 @@ int fit_verify_header(unsigned char *ptr, int image_size,

   int fit_check_image_types(uint8_t type, bool legacy)
   {
+ if (legacy)
+ return EXIT_FAILURE;
+
   if (type == IH_TYPE_FLATDT)
   return EXIT_SUCCESS;
   else
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 6d029afab3a8..9e9edd65583e 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -91,6 +91,7 @@ static void usage(const char *msg)
   fprintf(stderr,
   "   %s [-x] -A arch -O os -T type -C comp -a addr -e ep -n name 
-d data_file[:data_file...] image\n"
   "  -A ==> set architecture to 'arch'\n"
+ "  -L ==> force legacy image\n"
   "  -O ==> set operating system to 'os'\n"
   "  -T ==> set image type to 'type'\n"
   "  -C ==> set compression type 'comp'\n"
@@ -159,7 +160,7 @@ static int add_content(int type, const char *fname)
   }

   static const char optstring[] =
- "a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:ln:N:o:O:p:qrR:stT:vVx";
+ "a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:Lln:N:o:O:p:qrR:stT:vVx";

   static const struct option longopts[] = {
   { "load-address", required_argument, NULL, 'a' },
@@ -181,6 +182,7 @@ static const struct option longopts[] = {
   { "key-dir", required_argument, NULL, 'k' },
   { "key-dest", required_argument, NULL, 'K' },
   { "list", no_argument, NULL, 'l' },
+ { "legacy", no_argument, NULL, 'L' },
   { "config", required_argument, NULL, 'n' },
   { "engine", required_argument, NULL, 'N' },
   { "algo", required_argument, NULL, 'o' },
@@ -298,6 +300,9 @@ static void process_args(int argc, char **argv)
   case 'l':
   params.lflag = 1;
   break;
+ case 'L':
+ params.Lflag = 1;
+ break;
   case 'n':
   params.imagename = optarg;
   break;


Please add some documentation to the man page (doc/mkimage.1). And also 
consider not using a short option.


I like short options :-)


So do I, but they are a bit of an endangered species for mkimage :)

--Sean


[PATCH v1] power: regulator: Add support for NPCM845

2022-10-31 Thread Jim Liu
Add support for setting NPCM845 voltage supply

regulator-force-microvolt is npcm proprietary property to
set the voltage level.

Signed-off-by: Jim Liu 
---
 drivers/power/regulator/Kconfig |   8 ++
 drivers/power/regulator/Makefile|   1 +
 drivers/power/regulator/npcm8xx_regulator.c | 133 
 3 files changed, 142 insertions(+)
 create mode 100644 drivers/power/regulator/npcm8xx_regulator.c

diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig
index c519e066ef..e5f06874de 100644
--- a/drivers/power/regulator/Kconfig
+++ b/drivers/power/regulator/Kconfig
@@ -128,6 +128,14 @@ config DM_REGULATOR_MAX77686
features for REGULATOR MAX77686. The driver implements get/set api for:
value, enable and mode.
 
+config DM_REGULATOR_NPCM8XX
+   bool "Enable driver for NPCM8xx voltage supply"
+   depends on DM_REGULATOR && ARCH_NPCM8XX
+   help
+ Enable support for configuring voltage supply on NPCM8XX SoC. The
+ voltage supplies support two voltage levels and the driver implements
+ get/set api for setting the value.
+
 config DM_REGULATOR_FAN53555
bool "Enable Driver Model for REGULATOR FAN53555"
depends on DM_PMIC_FAN53555
diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile
index bc736068bc..68e4c0f9dd 100644
--- a/drivers/power/regulator/Makefile
+++ b/drivers/power/regulator/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_REGULATOR_ACT8846) += act8846.o
 obj-$(CONFIG_REGULATOR_AS3722) += as3722_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_DA9063) += da9063.o
 obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o
+obj-$(CONFIG_DM_REGULATOR_NPCM8XX) += npcm8xx_regulator.o
 obj-$(CONFIG_$(SPL_)DM_PMIC_PFUZE100) += pfuze100.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_BD71837) += bd71837.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_PCA9450) += pca9450.o
diff --git a/drivers/power/regulator/npcm8xx_regulator.c 
b/drivers/power/regulator/npcm8xx_regulator.c
new file mode 100644
index 00..7903287132
--- /dev/null
+++ b/drivers/power/regulator/npcm8xx_regulator.c
@@ -0,0 +1,133 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2022 Nuvoton Technology Corp.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define REG_VSRCR  0xf08000e8  /* Voltage Supply Control Register */
+
+/* Supported voltage levels (uV) */
+static const u32 volts_type1[] = { 330, 180 };
+static const u32 volts_type2[] = { 100, 180 };
+#define VOLT_LEV0  0
+#define VOLT_LEV1  1
+
+struct volt_supply {
+   char *name;
+   const u32 *volts;
+   u32 reg_shift;  /* Register bit offset for setting voltage */
+};
+
+static const struct volt_supply npcm8xx_volt_supps[] = {
+   {"v1", volts_type1, 0},
+   {"v2", volts_type1, 1},
+   {"v3", volts_type1, 2},
+   {"v4", volts_type1, 3},
+   {"v5", volts_type1, 4},
+   {"v6", volts_type1, 5},
+   {"v7", volts_type1, 6},
+   {"v8", volts_type1, 7},
+   {"v9", volts_type1, 8},
+   {"v10", volts_type1, 9},
+   {"v11", volts_type2, 10},
+   {"v12", volts_type1, 11},
+   {"v13", volts_type1, 12},
+   {"v14", volts_type2, 13},
+   {"vsif", volts_type1, 14},
+   {"vr2", volts_type1, 30},
+};
+
+static const struct volt_supply *npcm8xx_volt_supply_get(const char *name)
+{
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(npcm8xx_volt_supps); i++) {
+   if (!strcmp(npcm8xx_volt_supps[i].name, name))
+   return &npcm8xx_volt_supps[i];
+   }
+
+   return NULL;
+}
+
+static int npcm8xx_regulator_set_value(struct udevice *dev, int uV)
+{
+   struct dm_regulator_uclass_plat *uc_pdata;
+   const struct volt_supply *supp;
+   u32 val, level;
+
+   uc_pdata = dev_get_uclass_plat(dev);
+   if (!uc_pdata)
+   return -ENXIO;
+
+   dev_dbg(dev, "%s set_value: %d\n", uc_pdata->name, uV);
+   supp = npcm8xx_volt_supply_get(uc_pdata->name);
+   if (!supp)
+   return -ENOENT;
+
+   if (uV == supp->volts[VOLT_LEV0])
+   level = VOLT_LEV0;
+   else if (uV == supp->volts[VOLT_LEV1])
+   level = VOLT_LEV1;
+   else
+   return -EINVAL;
+
+   /* Set voltage level */
+   val = readl(REG_VSRCR);
+   val &= ~BIT(supp->reg_shift);
+   val |= level << supp->reg_shift;
+   writel(val, REG_VSRCR);
+
+   return 0;
+}
+
+static int npcm8xx_regulator_get_value(struct udevice *dev)
+{
+   struct dm_regulator_uclass_plat *uc_pdata;
+   const struct volt_supply *supp;
+   u32 val;
+
+   uc_pdata = dev_get_uclass_plat(dev);
+   if (!uc_pdata)
+   return -ENXIO;
+
+   supp = npcm8xx_volt_supply_get(uc_pdata->name);
+   if (!supp)
+   return -ENOENT;
+
+   val = readl(REG_VSRCR) & BIT(supp->reg_shift);
+   dev_dbg(dev, "%s get_value: %d\n", uc_pdata->name,
+

[PATCH 01/22] sunxi: Fix default-enablement of USB host drivers

2022-10-31 Thread Samuel Holland
We tried to enable USB_EHCI_GENERIC and USB_OHCI_GENERIC by default.
This did not work because those symbols depend on USB_EHCI_HCD and
USB_OHCI_HCD, which were not enabled. Fix this by implying all four.

Signed-off-by: Samuel Holland 
---

 arch/arm/Kconfig | 4 
 drivers/usb/host/Kconfig | 2 --
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 710f171f87..d3a1f03b36 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1185,7 +1185,11 @@ config ARCH_SUNXI
imply SYSRESET
imply SYSRESET_WATCHDOG
imply SYSRESET_WATCHDOG_AUTO
+   imply USB_EHCI_GENERIC
+   imply USB_EHCI_HCD
imply USB_GADGET
+   imply USB_OHCI_GENERIC
+   imply USB_OHCI_HCD
imply WDT
 
 config ARCH_U8500
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 1aabe062fb..a4d62bc9e8 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -280,7 +280,6 @@ config USB_EHCI_ZYNQ
 config USB_EHCI_GENERIC
bool "Support for generic EHCI USB controller"
depends on DM_USB
-   default ARCH_SUNXI
---help---
  Enables support for generic EHCI controller.
 
@@ -342,7 +341,6 @@ config USB_OHCI_PCI
 
 config USB_OHCI_GENERIC
bool "Support for generic OHCI USB controller"
-   default ARCH_SUNXI
---help---
  Enables support for generic OHCI controller.
 
-- 
2.37.3



[PATCH 00/22] sunxi: Prepare platform Kconfig to support multiple architectures

2022-10-31 Thread Samuel Holland
sunxi is getting a new RISC-V platform, D1. We want to share as much of
the existing configuration as possible, to provide a familiar
environment, DRAM layout, partition layout, etc.

Because U-Boot includes all architecture Kconfig files at once, we must
use a symbol outside of both CONFIG_ARM and CONFIG_RISCV to contain
shared Kconfig options. I chose BOARD_SUNXI, corresponding to the file
location and somewhat following the BOARD_SPECIFIC_OPTIONS pattern.

I did a buildman run on this series. The only net option changes are the
expected ones:
 - Host-side USB gets enabled on several boards by the first patch
   (emlid_neutis_n5_devboard orangepi_zero2 pinephone pinetab tanix_tx6
   x96_mate teres_i)
 - CONFIG_BOARD_SUNXI gets added everywhere
 - CONFIG_SYS_I2C_MVTWSI gets enabled by the corresponding patch

Andre, please feel free to take any subset of these; they don't all have
to go in at once. And I'm open to suggestions about what instances of
ARCH_SUNXI should (not) be converted. Some of them are open to opinion.

I left alone the options in arch/arm/mach-sunxi/Kconfig that are covered
by other series (MMC CD/USB PHY/power pins, AXP GPIO).

After this series, the Kconfig changes needed for D1 support are quite
small, something like this commit:
https://github.com/smaeul/u-boot/commit/c12cf6c5d72f5327eff793518229ddbd41dcf729.patch

Adding SUNXI_MINIMUM_DRAM_MB certainly made things nicer. There are a
few options that probably still need some adjustment to respect it.


Samuel Holland (22):
  sunxi: Fix default-enablement of USB host drivers
  sunxi: Remove unnecessary Kconfig selections
  sunxi: Add missing dependencies to Kconfig selections
  sunxi: Hide image type selection if SPL is disabled
  sunxi: Share the board Kconfig across architectures
  sunxi: Move most Kconfig selections to the board Kconfig
  sunxi: Globally enable SUPPORT_SPL
  sunxi: Downgrade driver selections to implications
  sunxi: Enable the I2C driver by default
  sunxi: Move default values to the board Kconfig
  sunxi: Hide the SUNXI_MINIMUM_DRAM_MB symbol
  sunxi: Clean up the SPL_STACK_R_ADDR defaults
  sunxi: Move PRE_CON_BUF_ADDR to the board Kconfig
  sunxi: Move SPL_BSS_START_ADDR to the board Kconfig
  sunxi: Move SPL_TEXT_BASE to the board Kconfig
  sunxi: Move SYS_LOAD_ADDR to the board Kconfig
  sunxi: Move TEXT_BASE to the board Kconfig
  sunxi: Move most board options to the board Kconfig
  env: sunxi: Replace ARCH_SUNXI with BOARD_SUNXI
  drivers: sunxi: Replace ARCH_SUNXI with BOARD_SUNXI
  disk: sunxi: Replace ARCH_SUNXI with BOARD_SUNXI
  spl: sunxi: Replace ARCH_SUNXI with BOARD_SUNXI

 Kconfig   |   3 -
 arch/Kconfig  |   1 +
 arch/arm/Kconfig  |  48 +---
 arch/arm/mach-sunxi/Kconfig   | 154 ---
 board/sunxi/Kconfig   | 224 ++
 boot/Kconfig  |   4 -
 common/Kconfig|   2 -
 common/spl/Kconfig|  18 +--
 disk/Kconfig  |   6 +-
 drivers/clk/sunxi/Kconfig |   2 +-
 drivers/fastboot/Kconfig  |  13 +-
 drivers/gpio/Kconfig  |   2 +-
 drivers/mmc/Kconfig   |   2 +-
 drivers/net/phy/Kconfig   |   4 +-
 drivers/phy/allwinner/Kconfig |   2 +-
 drivers/pinctrl/sunxi/Kconfig |   2 +-
 drivers/reset/Kconfig |   2 +-
 drivers/spi/Kconfig   |   2 +-
 drivers/usb/Kconfig   |   2 +-
 drivers/usb/gadget/Kconfig|   8 +-
 drivers/usb/host/Kconfig  |   2 -
 drivers/usb/musb-new/Kconfig  |   2 +-
 drivers/video/Kconfig |   2 +-
 drivers/watchdog/Kconfig  |   4 +-
 env/Kconfig   |  12 +-
 scripts/Makefile.spl  |   2 +-
 26 files changed, 267 insertions(+), 258 deletions(-)

-- 
2.37.3



[PATCH 02/22] sunxi: Remove unnecessary Kconfig selections

2022-10-31 Thread Samuel Holland
Two of these selections are redundant and have no effect:
 - DM_KEYBOARD is selected by USB_KEYBOARD
 - DM_MMC is selected by MMC

This selection has no effect by default and is unnecessarily strong:
 - USB_STORAGE is implied by DISTRO_DEFAULTS

Signed-off-by: Samuel Holland 
---

 arch/arm/Kconfig | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index d3a1f03b36..939f76867e 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1144,8 +1144,6 @@ config ARCH_SUNXI
select DM_I2C if I2C
select DM_SPI if SPI
select DM_SPI_FLASH if SPI
-   select DM_KEYBOARD
-   select DM_MMC if MMC
select DM_SCSI if SCSI
select DM_SERIAL
select GPIO_EXTRA_HEADER
@@ -1163,7 +1161,6 @@ config ARCH_SUNXI
select SYS_THUMB_BUILD if !ARM64
select USB if DISTRO_DEFAULTS
select USB_KEYBOARD if DISTRO_DEFAULTS && USB_HOST
-   select USB_STORAGE if DISTRO_DEFAULTS && USB_HOST
select SPL_USE_TINY_PRINTF
select USE_PREBOOT
select SYS_RELOC_GD_ENV_ADDR
-- 
2.37.3



[PATCH 03/22] sunxi: Add missing dependencies to Kconfig selections

2022-10-31 Thread Samuel Holland
Some of the selected symbols have a user-visible dependency. Make the
selections conditional on that dependency to avoid creating invalid
configurations.

Signed-off-by: Samuel Holland 
---

 arch/arm/Kconfig | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 939f76867e..4e5daa9e7f 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1134,30 +1134,30 @@ config ARCH_SOCFPGA
 config ARCH_SUNXI
bool "Support sunxi (Allwinner) SoCs"
select BINMAN
-   select CMD_GPIO
+   select CMD_GPIO if GPIO
select CMD_MMC if MMC
select CMD_USB if DISTRO_DEFAULTS && USB_HOST
select CLK
select DM
-   select DM_ETH
-   select DM_GPIO
+   select DM_ETH if NET
+   select DM_GPIO if GPIO
select DM_I2C if I2C
+   select DM_SCSI if BLK && SCSI
+   select DM_SERIAL if SERIAL
select DM_SPI if SPI
select DM_SPI_FLASH if SPI
-   select DM_SCSI if SCSI
-   select DM_SERIAL
select GPIO_EXTRA_HEADER
select OF_BOARD_SETUP
select OF_CONTROL
select OF_SEPARATE
select PINCTRL
-   select SPECIFY_CONSOLE_INDEX
+   select SPECIFY_CONSOLE_INDEX if SERIAL
select SPL_SEPARATE_BSS if SPL
select SPL_STACK_R if SPL
select SPL_SYS_MALLOC_SIMPLE if SPL
select SPL_SYS_THUMB_BUILD if !ARM64
-   select SUNXI_GPIO
-   select SYS_NS16550
+   select SUNXI_GPIO if GPIO
+   select SYS_NS16550 if SERIAL
select SYS_THUMB_BUILD if !ARM64
select USB if DISTRO_DEFAULTS
select USB_KEYBOARD if DISTRO_DEFAULTS && USB_HOST
-- 
2.37.3



[PATCH 04/22] sunxi: Hide image type selection if SPL is disabled

2022-10-31 Thread Samuel Holland
This choice is meaningless when SPL is disabled. Hide it to avoid any
possible confusion.

Signed-off-by: Samuel Holland 
---

 board/sunxi/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 084a8b0c6c..42f61df5c5 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -1,5 +1,6 @@
 choice
prompt "SPL Image Type"
+   depends on SPL
default SPL_IMAGE_TYPE_SUNXI_EGON
 
 config SPL_IMAGE_TYPE_SUNXI_EGON
-- 
2.37.3



[PATCH 05/22] sunxi: Share the board Kconfig across architectures

2022-10-31 Thread Samuel Holland
With the introduction of the Allwinner D1, the sunxi board family now
spans multiple architectures (ARM and RISC-V). Since ARCH_SUNXI depends
on ARM, it cannot be used to gate architecture-independent options.
Specifically, this means the board Kconfig file cannot be sourced from
inside the "if ARCH_SUNXI" block.

Introduce a new BOARD_SUNXI symbol that can be selected by both
ARCH_SUNXI now and the new RISC-V SoC symbols when they are added, and
use it to gate the architecture-independent board options.

Signed-off-by: Samuel Holland 
---

 arch/Kconfig|  1 +
 arch/arm/Kconfig|  1 +
 arch/arm/mach-sunxi/Kconfig |  2 --
 board/sunxi/Kconfig | 11 +++
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index e3a456a98d..a77192096a 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -458,6 +458,7 @@ source "arch/Kconfig.nxp"
 endif
 
 source "board/keymile/Kconfig"
+source "board/sunxi/Kconfig"
 
 if MIPS || MICROBLAZE
 
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 4e5daa9e7f..f2852783d4 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1134,6 +1134,7 @@ config ARCH_SOCFPGA
 config ARCH_SUNXI
bool "Support sunxi (Allwinner) SoCs"
select BINMAN
+   select BOARD_SUNXI
select CMD_GPIO if GPIO
select CMD_MMC if MMC
select CMD_USB if DISTRO_DEFAULTS && USB_HOST
diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index dbe6005daa..a03e700a0b 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -1046,8 +1046,6 @@ config BLUETOOTH_DT_DEVICE_FIXUP
  The used address is "bdaddr" if set, and "ethaddr" with the LSB
  flipped elsewise.
 
-source "board/sunxi/Kconfig"
-
 endif
 
 config CHIP_DIP_SCAN
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 42f61df5c5..9010631b16 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -1,3 +1,10 @@
+config BOARD_SUNXI
+   bool
+
+if BOARD_SUNXI
+
+menu "sunxi board options"
+
 choice
prompt "SPL Image Type"
depends on SPL
@@ -23,3 +30,7 @@ config SPL_IMAGE_TYPE
string
default "sunxi_egon" if SPL_IMAGE_TYPE_SUNXI_EGON
default "sunxi_toc0" if SPL_IMAGE_TYPE_SUNXI_TOC0
+
+endmenu
+
+endif
-- 
2.37.3



[PATCH 06/22] sunxi: Move most Kconfig selections to the board Kconfig

2022-10-31 Thread Samuel Holland
To maintain consistent behavior across architectures, most of the
options selected by ARCH_SUNXI should be selected for the D1 SoC as
well. To accomplish this, select them from BOARD_SUNXI instead.

No functional change here. Lines are only moved and alphabetized.

Signed-off-by: Samuel Holland 
---

 arch/arm/Kconfig| 46 -
 board/sunxi/Kconfig | 46 +
 2 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index f2852783d4..2c32b419a8 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1133,62 +1133,16 @@ config ARCH_SOCFPGA
 
 config ARCH_SUNXI
bool "Support sunxi (Allwinner) SoCs"
-   select BINMAN
select BOARD_SUNXI
-   select CMD_GPIO if GPIO
-   select CMD_MMC if MMC
-   select CMD_USB if DISTRO_DEFAULTS && USB_HOST
-   select CLK
-   select DM
-   select DM_ETH if NET
-   select DM_GPIO if GPIO
-   select DM_I2C if I2C
-   select DM_SCSI if BLK && SCSI
-   select DM_SERIAL if SERIAL
-   select DM_SPI if SPI
-   select DM_SPI_FLASH if SPI
select GPIO_EXTRA_HEADER
-   select OF_BOARD_SETUP
select OF_CONTROL
select OF_SEPARATE
-   select PINCTRL
select SPECIFY_CONSOLE_INDEX if SERIAL
-   select SPL_SEPARATE_BSS if SPL
select SPL_STACK_R if SPL
select SPL_SYS_MALLOC_SIMPLE if SPL
select SPL_SYS_THUMB_BUILD if !ARM64
-   select SUNXI_GPIO if GPIO
-   select SYS_NS16550 if SERIAL
select SYS_THUMB_BUILD if !ARM64
-   select USB if DISTRO_DEFAULTS
-   select USB_KEYBOARD if DISTRO_DEFAULTS && USB_HOST
select SPL_USE_TINY_PRINTF
-   select USE_PREBOOT
-   select SYS_RELOC_GD_ENV_ADDR
-   imply BOARD_LATE_INIT
-   imply CMD_DM
-   imply CMD_GPT
-   imply CMD_UBI if MTD_RAW_NAND
-   imply DISTRO_DEFAULTS
-   imply FAT_WRITE
-   imply FIT
-   imply OF_LIBFDT_OVERLAY
-   imply PRE_CONSOLE_BUFFER
-   imply SPL_GPIO
-   imply SPL_LIBCOMMON_SUPPORT
-   imply SPL_LIBGENERIC_SUPPORT
-   imply SPL_MMC if MMC
-   imply SPL_POWER
-   imply SPL_SERIAL
-   imply SYSRESET
-   imply SYSRESET_WATCHDOG
-   imply SYSRESET_WATCHDOG_AUTO
-   imply USB_EHCI_GENERIC
-   imply USB_EHCI_HCD
-   imply USB_GADGET
-   imply USB_OHCI_GENERIC
-   imply USB_OHCI_HCD
-   imply WDT
 
 config ARCH_U8500
bool "ST-Ericsson U8500 Series"
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 9010631b16..1d0700fe5f 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -1,5 +1,51 @@
 config BOARD_SUNXI
bool
+   select BINMAN
+   select CLK
+   select CMD_GPIO if GPIO
+   select CMD_MMC if MMC
+   select CMD_USB if DISTRO_DEFAULTS && USB_HOST
+   select DM
+   select DM_ETH if NET
+   select DM_GPIO if GPIO
+   select DM_I2C if I2C
+   select DM_SCSI if BLK && SCSI
+   select DM_SERIAL if SERIAL
+   select DM_SPI if SPI
+   select DM_SPI_FLASH if SPI
+   select OF_BOARD_SETUP
+   select PINCTRL
+   select SPL_SEPARATE_BSS if SPL
+   select SUNXI_GPIO if GPIO
+   select SYS_NS16550 if SERIAL
+   select SYS_RELOC_GD_ENV_ADDR
+   select USB if DISTRO_DEFAULTS
+   select USB_KEYBOARD if DISTRO_DEFAULTS && USB_HOST
+   select USE_PREBOOT
+   imply BOARD_LATE_INIT
+   imply CMD_DM
+   imply CMD_GPT
+   imply CMD_UBI if MTD_RAW_NAND
+   imply DISTRO_DEFAULTS
+   imply FAT_WRITE
+   imply FIT
+   imply OF_LIBFDT_OVERLAY
+   imply PRE_CONSOLE_BUFFER
+   imply SPL_GPIO
+   imply SPL_LIBCOMMON_SUPPORT
+   imply SPL_LIBGENERIC_SUPPORT
+   imply SPL_MMC if MMC
+   imply SPL_POWER
+   imply SPL_SERIAL
+   imply SYSRESET
+   imply SYSRESET_WATCHDOG
+   imply SYSRESET_WATCHDOG_AUTO
+   imply USB_EHCI_GENERIC
+   imply USB_EHCI_HCD
+   imply USB_GADGET
+   imply USB_OHCI_GENERIC
+   imply USB_OHCI_HCD
+   imply WDT
 
 if BOARD_SUNXI
 
-- 
2.37.3



[PATCH 07/22] sunxi: Globally enable SUPPORT_SPL

2022-10-31 Thread Samuel Holland
This was already supported by every machine type. It is unlikely that
any new SoC support will be added without SPL support.

Signed-off-by: Samuel Holland 
---

 arch/arm/mach-sunxi/Kconfig | 14 --
 board/sunxi/Kconfig |  2 ++
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index a03e700a0b..73097e5a40 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -133,7 +133,6 @@ config SUN50I_GEN_H6
select FIT
select SPL_LOAD_FIT
select MMC_SUNXI_HAS_NEW_MODE
-   select SUPPORT_SPL
---help---
Select this for sunxi SoCs which have H6 like peripherals, clocks
and memory map.
@@ -167,7 +166,6 @@ config MACH_SUNXI_H3_H5
select SUNXI_DRAM_DW
select SUNXI_DRAM_DW_32BIT
select SUNXI_GEN_SUN6I
-   select SUPPORT_SPL
 
 # TODO: try out A80's 8GiB DRAM space
 config SUNXI_DRAM_MAX_SIZE
@@ -184,7 +182,6 @@ config MACH_SUNIV
bool "suniv (Allwinner F1C100s/F1C200s/F1C600/R6)"
select CPU_ARM926EJS
select SUNXI_GEN_SUN6I
-   select SUPPORT_SPL
select SKIP_LOWLEVEL_INIT_ONLY
select SPL_SKIP_LOWLEVEL_INIT_ONLY
 
@@ -194,7 +191,6 @@ config MACH_SUN4I
select PHY_SUN4I_USB
select DRAM_SUN4I
select SUNXI_GEN_SUN4I
-   select SUPPORT_SPL
imply SPL_SYS_I2C_LEGACY
imply SYS_I2C_LEGACY
 
@@ -204,7 +200,6 @@ config MACH_SUN5I
select DRAM_SUN4I
select PHY_SUN4I_USB
select SUNXI_GEN_SUN4I
-   select SUPPORT_SPL
imply SPL_SYS_I2C_LEGACY
imply SYS_I2C_LEGACY
 
@@ -220,7 +215,6 @@ config MACH_SUN6I
select SPL_I2C
select SUN6I_PRCM
select SUNXI_GEN_SUN6I
-   select SUPPORT_SPL
select SYS_I2C_SUN6I_P2WI
select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
 
@@ -234,7 +228,6 @@ config MACH_SUN7I
select DRAM_SUN4I
select PHY_SUN4I_USB
select SUNXI_GEN_SUN4I
-   select SUPPORT_SPL
select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
imply SPL_SYS_I2C_LEGACY
imply SYS_I2C_LEGACY
@@ -249,7 +242,6 @@ config MACH_SUN8I_A23
select PHY_SUN4I_USB
select SPL_I2C
select SUNXI_GEN_SUN6I
-   select SUPPORT_SPL
select SYS_I2C_SUN8I_RSB
select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
 
@@ -263,7 +255,6 @@ config MACH_SUN8I_A33
select PHY_SUN4I_USB
select SPL_I2C
select SUNXI_GEN_SUN6I
-   select SUPPORT_SPL
select SYS_I2C_SUN8I_RSB
select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
 
@@ -276,7 +267,6 @@ config MACH_SUN8I_A83T
select SUNXI_GEN_SUN6I
select MMC_SUNXI_HAS_NEW_MODE
select MMC_SUNXI_HAS_MODE_SWITCH
-   select SUPPORT_SPL
select SYS_I2C_SUN8I_RSB
 
 config MACH_SUN8I_H3
@@ -296,7 +286,6 @@ config MACH_SUN8I_R40
select ARCH_SUPPORT_PSCI
select SUNXI_GEN_SUN6I
select MMC_SUNXI_HAS_NEW_MODE
-   select SUPPORT_SPL
select SUNXI_DRAM_DW
select SUNXI_DRAM_DW_32BIT
select PHY_SUN4I_USB
@@ -311,7 +300,6 @@ config MACH_SUN8I_V3S
select SUNXI_GEN_SUN6I
select SUNXI_DRAM_DW
select SUNXI_DRAM_DW_16BIT
-   select SUPPORT_SPL
select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
 
 config MACH_SUN9I
@@ -322,7 +310,6 @@ config MACH_SUN9I
select SPL_I2C
select SUN6I_PRCM
select SUNXI_GEN_SUN6I
-   select SUPPORT_SPL
 
 config MACH_SUN50I
bool "sun50i (Allwinner A64)"
@@ -332,7 +319,6 @@ config MACH_SUN50I
select SUNXI_DE2
select SUNXI_GEN_SUN6I
select MMC_SUNXI_HAS_NEW_MODE
-   select SUPPORT_SPL
select SUNXI_DRAM_DW
select SUNXI_DRAM_DW_32BIT
select FIT
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 1d0700fe5f..056ccb6f74 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -18,6 +18,7 @@ config BOARD_SUNXI
select SPL_SEPARATE_BSS if SPL
select SUNXI_GPIO if GPIO
select SYS_NS16550 if SERIAL
+   select SUPPORT_SPL
select SYS_RELOC_GD_ENV_ADDR
select USB if DISTRO_DEFAULTS
select USB_KEYBOARD if DISTRO_DEFAULTS && USB_HOST
@@ -31,6 +32,7 @@ config BOARD_SUNXI
imply FIT
imply OF_LIBFDT_OVERLAY
imply PRE_CONSOLE_BUFFER
+   imply SPL
imply SPL_GPIO
imply SPL_LIBCOMMON_SUPPORT
imply SPL_LIBGENERIC_SUPPORT
-- 
2.37.3



[PATCH 08/22] sunxi: Downgrade driver selections to implications

2022-10-31 Thread Samuel Holland
While not especially likely, it is plausible that someone wants to build
U-Boot without GPIO or UART support. Don't force building these drivers.

Signed-off-by: Samuel Holland 
---

 board/sunxi/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 056ccb6f74..b301ba998e 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -16,8 +16,6 @@ config BOARD_SUNXI
select OF_BOARD_SETUP
select PINCTRL
select SPL_SEPARATE_BSS if SPL
-   select SUNXI_GPIO if GPIO
-   select SYS_NS16550 if SERIAL
select SUPPORT_SPL
select SYS_RELOC_GD_ENV_ADDR
select USB if DISTRO_DEFAULTS
@@ -39,6 +37,8 @@ config BOARD_SUNXI
imply SPL_MMC if MMC
imply SPL_POWER
imply SPL_SERIAL
+   imply SUNXI_GPIO
+   imply SYS_NS16550
imply SYSRESET
imply SYSRESET_WATCHDOG
imply SYSRESET_WATCHDOG_AUTO
-- 
2.37.3



[PATCH 09/22] sunxi: Enable the I2C driver by default

2022-10-31 Thread Samuel Holland
This is used by quite a large number of boards, for PMIC/regulator or
LCD panel control.

Signed-off-by: Samuel Holland 
---

 board/sunxi/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index b301ba998e..809cd17f54 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -38,6 +38,7 @@ config BOARD_SUNXI
imply SPL_POWER
imply SPL_SERIAL
imply SUNXI_GPIO
+   imply SYS_I2C_MVTWSI
imply SYS_NS16550
imply SYSRESET
imply SYSRESET_WATCHDOG
-- 
2.37.3



[PATCH 10/22] sunxi: Move default values to the board Kconfig

2022-10-31 Thread Samuel Holland
This keeps all of the defaults for sunxi platforms in one place. Most of
these only depend on architecture-independent features of the SoC (clock
tree or SRAM layout) anyway.

No functional change; just some minor help text cleanup.

Signed-off-by: Samuel Holland 
---

 arch/arm/mach-sunxi/Kconfig | 67 
 board/sunxi/Kconfig | 68 +
 2 files changed, 68 insertions(+), 67 deletions(-)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index 73097e5a40..24840f6d7e 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -1,8 +1,5 @@
 if ARCH_SUNXI
 
-config IDENT_STRING
-   default " Allwinner Technology"
-
 config DRAM_SUN4I
bool
help
@@ -99,17 +96,6 @@ config AXP_PMIC_BUS
  Select this PMIC bus access helpers for Sunxi platform PRCM or other
  AXP family PMIC devices.
 
-config SUNXI_SRAM_ADDRESS
-   hex
-   default 0x1 if MACH_SUN9I || MACH_SUN50I || MACH_SUN50I_H5
-   default 0x2 if SUN50I_GEN_H6
-   default 0x0
-   ---help---
-   Older Allwinner SoCs have their mask boot ROM mapped just below 4GB,
-   with the first SRAM region being located at address 0.
-   Some newer SoCs map the boot ROM at address 0 instead and move the
-   SRAM to a different address.
-
 config SUNXI_A64_TIMER_ERRATUM
bool
 
@@ -573,48 +559,6 @@ config DRAM_ODT_CORRECTION
then the correction is negative. Usually the value for this is 0.
 endif
 
-config SYS_CLK_FREQ
-   default 40800 if MACH_SUNIV
-   default 100800 if MACH_SUN4I
-   default 100800 if MACH_SUN5I
-   default 100800 if MACH_SUN6I
-   default 91200 if MACH_SUN7I
-   default 81600 if MACH_SUN50I || MACH_SUN50I_H5
-   default 100800 if MACH_SUN8I
-   default 100800 if MACH_SUN9I
-   default 88800 if MACH_SUN50I_H6
-   default 100800 if MACH_SUN50I_H616
-
-config SYS_CONFIG_NAME
-   default "suniv" if MACH_SUNIV
-   default "sun4i" if MACH_SUN4I
-   default "sun5i" if MACH_SUN5I
-   default "sun6i" if MACH_SUN6I
-   default "sun7i" if MACH_SUN7I
-   default "sun8i" if MACH_SUN8I
-   default "sun9i" if MACH_SUN9I
-   default "sun50i" if MACH_SUN50I
-   default "sun50i" if MACH_SUN50I_H6
-   default "sun50i" if MACH_SUN50I_H616
-
-config SYS_BOARD
-   default "sunxi"
-
-config SYS_SOC
-   default "sunxi"
-
-config SUNXI_MINIMUM_DRAM_MB
-   int "minimum DRAM size"
-   default 32 if MACH_SUNIV
-   default 64 if MACH_SUN8I_V3S
-   default 256
-   ---help---
-   Minimum DRAM size expected on the board. Traditionally we assumed
-   256 MB, so that U-Boot would load at 160MB. With co-packaged DRAM
-   we have smaller sizes, though, so that U-Boot's own load address and
-   the default payload addresses must be shifted down.
-   This is expected to be fixed by the SoC selection.
-
 config UART0_PORT_F
bool "UART0 on MicroSD breakout board"
---help---
@@ -985,17 +929,6 @@ config GMAC_TX_DELAY
---help---
Set the GMAC Transmit Clock Delay Chain value.
 
-config SPL_STACK_R_ADDR
-   default 0x81e0 if MACH_SUNIV
-   default 0x4fe0 if MACH_SUN4I
-   default 0x4fe0 if MACH_SUN5I
-   default 0x4fe0 if MACH_SUN6I
-   default 0x4fe0 if MACH_SUN7I
-   default 0x4fe0 if MACH_SUN8I
-   default 0x2fe0 if MACH_SUN9I
-   default 0x4fe0 if MACH_SUN50I
-   default 0x4fe0 if SUN50I_GEN_H6
-
 config SPL_SPI_SUNXI
bool "Support for SPI Flash on Allwinner SoCs in SPL"
depends on MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || MACH_SUNXI_H3_H5 
|| MACH_SUN50I || MACH_SUN8I_R40 || SUN50I_GEN_H6 || MACH_SUNIV
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 809cd17f54..105c902036 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -52,6 +52,74 @@ config BOARD_SUNXI
 
 if BOARD_SUNXI
 
+config IDENT_STRING
+   default " Allwinner Technology"
+
+config SPL_STACK_R_ADDR
+   default 0x81e0 if MACH_SUNIV
+   default 0x4fe0 if MACH_SUN4I
+   default 0x4fe0 if MACH_SUN5I
+   default 0x4fe0 if MACH_SUN6I
+   default 0x4fe0 if MACH_SUN7I
+   default 0x4fe0 if MACH_SUN8I
+   default 0x2fe0 if MACH_SUN9I
+   default 0x4fe0 if MACH_SUN50I
+   default 0x4fe0 if SUN50I_GEN_H6
+
+config SUNXI_MINIMUM_DRAM_MB
+   int "minimum DRAM size"
+   default 32 if MACH_SUNIV
+   default 64 if MACH_SUN8I_V3S
+   default 256
+   help
+ Minimum DRAM size expected on the board. Traditionally we
+ assumed 256 MB, so that U-Boot would load at 160MB. With
+ co-packaged DRAM we have smaller sizes, though, so U-Boot's
+ own load address and the default payload addresses must be
+ shifted down. 

[PATCH 11/22] sunxi: Hide the SUNXI_MINIMUM_DRAM_MB symbol

2022-10-31 Thread Samuel Holland
This option affects the ABI between SPL/U-Boot and U-Boot/scripts, so it
should not normally be changed by the user.

Signed-off-by: Samuel Holland 
---

 board/sunxi/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 105c902036..d686d84170 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -67,7 +67,7 @@ config SPL_STACK_R_ADDR
default 0x4fe0 if SUN50I_GEN_H6
 
 config SUNXI_MINIMUM_DRAM_MB
-   int "minimum DRAM size"
+   int
default 32 if MACH_SUNIV
default 64 if MACH_SUN8I_V3S
default 256
-- 
2.37.3



[PATCH 12/22] sunxi: Clean up the SPL_STACK_R_ADDR defaults

2022-10-31 Thread Samuel Holland
Update this option to be based on SUNXI_MINIMUM_DRAM_MB. This corrects
the value used on V3s, which previously was the MACH_SUN8I default, and
so relied on addresses wrapping modulo the DRAM size.

Signed-off-by: Samuel Holland 
---

 board/sunxi/Kconfig | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index d686d84170..7d678108a0 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -57,14 +57,9 @@ config IDENT_STRING
 
 config SPL_STACK_R_ADDR
default 0x81e0 if MACH_SUNIV
-   default 0x4fe0 if MACH_SUN4I
-   default 0x4fe0 if MACH_SUN5I
-   default 0x4fe0 if MACH_SUN6I
-   default 0x4fe0 if MACH_SUN7I
-   default 0x4fe0 if MACH_SUN8I
default 0x2fe0 if MACH_SUN9I
-   default 0x4fe0 if MACH_SUN50I
-   default 0x4fe0 if SUN50I_GEN_H6
+   default 0x4fe0 if SUNXI_MINIMUM_DRAM_MB >= 256
+   default 0x43e0 if SUNXI_MINIMUM_DRAM_MB >= 64
 
 config SUNXI_MINIMUM_DRAM_MB
int
-- 
2.37.3



[PATCH 13/22] sunxi: Move PRE_CON_BUF_ADDR to the board Kconfig

2022-10-31 Thread Samuel Holland
This provides a default value for RISC-V when that is added, and it
makes sense to put this option next to the other DRAM layout options.

While at it, provide sensible values for platforms with less DRAM.

Signed-off-by: Samuel Holland 
---

 board/sunxi/Kconfig | 6 ++
 common/Kconfig  | 2 --
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 7d678108a0..704535d467 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -55,6 +55,12 @@ if BOARD_SUNXI
 config IDENT_STRING
default " Allwinner Technology"
 
+config PRE_CON_BUF_ADDR
+   default 0x8100 if MACH_SUNIV
+   default 0x2f00 if MACH_SUN9I
+   default 0x4f00 if SUNXI_MINIMUM_DRAM_MB >= 256
+   default 0x4300 if SUNXI_MINIMUM_DRAM_MB >= 64
+
 config SPL_STACK_R_ADDR
default 0x81e0 if MACH_SUNIV
default 0x2fe0 if MACH_SUN9I
diff --git a/common/Kconfig b/common/Kconfig
index 21434c5cf1..bc2c078d4a 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -195,8 +195,6 @@ config PRE_CON_BUF_SZ
 config PRE_CON_BUF_ADDR
hex "Address of the pre-console buffer"
depends on PRE_CONSOLE_BUFFER
-   default 0x2f00 if ARCH_SUNXI && MACH_SUN9I
-   default 0x4f00 if ARCH_SUNXI && !MACH_SUN9I
default 0x0f00 if ROCKCHIP_RK3288
default 0x0f20 if ROCKCHIP_RK3399
help
-- 
2.37.3



[PATCH 14/22] sunxi: Move SPL_BSS_START_ADDR to the board Kconfig

2022-10-31 Thread Samuel Holland
This provides a default value for RISC-V when that is added, and it
makes sense to put this option next to the other DRAM layout options.

While at it, provide sensible values for platforms with less DRAM.

Signed-off-by: Samuel Holland 
---

 board/sunxi/Kconfig | 6 ++
 common/spl/Kconfig  | 3 ---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 704535d467..1abb3e1816 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -61,6 +61,12 @@ config PRE_CON_BUF_ADDR
default 0x4f00 if SUNXI_MINIMUM_DRAM_MB >= 256
default 0x4300 if SUNXI_MINIMUM_DRAM_MB >= 64
 
+config SPL_BSS_START_ADDR
+   default 0x81f8 if MACH_SUNIV
+   default 0x2ff8 if MACH_SUN9I
+   default 0x4ff8 if SUNXI_MINIMUM_DRAM_MB >= 256
+   default 0x43f8 if SUNXI_MINIMUM_DRAM_MB >= 64
+
 config SPL_STACK_R_ADDR
default 0x81e0 if MACH_SUNIV
default 0x2fe0 if MACH_SUN9I
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index b738c749ff..b1e9926e68 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -118,9 +118,6 @@ config SPL_BSS_START_ADDR
default 0x8820 if (ARCH_MX6 && (MX6SX || MX6SL || MX6UL || MX6ULL)) 
|| ARCH_MX7
default 0x1820 if ARCH_MX6 && !(MX6SX || MX6SL || MX6UL || MX6ULL)
default 0x80a0 if ARCH_OMAP2PLUS
-   default 0x81f8 if ARCH_SUNXI && MACH_SUNIV
-   default 0x4ff8 if ARCH_SUNXI && !(MACH_SUN9I || MACH_SUNIV)
-   default 0x2ff8 if ARCH_SUNXI && MACH_SUN9I
default 0x1000 if ARCH_ZYNQMP
 
 choice
-- 
2.37.3



[PATCH 16/22] sunxi: Move SYS_LOAD_ADDR to the board Kconfig

2022-10-31 Thread Samuel Holland
This will provide a default value for RISC-V when that is added, and it
makes sense to put this option next to the other DRAM layout options.

Signed-off-by: Samuel Holland 
---

 Kconfig | 3 ---
 board/sunxi/Kconfig | 5 +
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/Kconfig b/Kconfig
index ef94f88adc..70e159221c 100644
--- a/Kconfig
+++ b/Kconfig
@@ -508,9 +508,6 @@ config SYS_LOAD_ADDR
hex "Address in memory to use by default"
default 0x0100 if ARCH_SOCFPGA
default 0x0200 if PPC || X86
-   default 0x8100 if MACH_SUNIV
-   default 0x2200 if MACH_SUN9I
-   default 0x4200 if ARCH_SUNXI
default 0x8200 if ARCH_KEYSTONE || ARCH_OMAP2PLUS || ARCH_K3
default 0x8200 if ARCH_MX6 && (MX6SL || MX6SLL  || MX6SX || MX6UL 
|| MX6ULL)
default 0x1200 if ARCH_MX6 && !(MX6SL || MX6SLL  || MX6SX || MX6UL 
|| MX6ULL)
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index b561dd467f..d463474535 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -129,6 +129,11 @@ config SYS_CONFIG_NAME
default "sun50i" if MACH_SUN50I_H6
default "sun50i" if MACH_SUN50I_H616
 
+config SYS_LOAD_ADDR
+   default 0x8100 if MACH_SUNIV
+   default 0x2200 if MACH_SUN9I
+   default 0x4200
+
 config SYS_SOC
default "sunxi"
 
-- 
2.37.3



[PATCH 15/22] sunxi: Move SPL_TEXT_BASE to the board Kconfig

2022-10-31 Thread Samuel Holland
It makes sense to put this near the definition of SUNXI_SRAM_ADDRESS.

Signed-off-by: Samuel Holland 
---

 board/sunxi/Kconfig | 5 +
 common/spl/Kconfig  | 3 ---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 1abb3e1816..b561dd467f 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -73,6 +73,11 @@ config SPL_STACK_R_ADDR
default 0x4fe0 if SUNXI_MINIMUM_DRAM_MB >= 256
default 0x43e0 if SUNXI_MINIMUM_DRAM_MB >= 64
 
+config SPL_TEXT_BASE
+   default 0x10060 if MACH_SUN9I || MACH_SUN50I || MACH_SUN50I_H5
+   default 0x20060 if SUN50I_GEN_H6
+   default 0x00060
+
 config SUNXI_MINIMUM_DRAM_MB
int
default 32 if MACH_SUNIV
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index b1e9926e68..930028b5af 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -260,9 +260,6 @@ config SPL_TEXT_BASE
default 0x402F4000 if AM43XX
default 0x402F0400 if AM33XX
default 0x40301350 if OMAP54XX
-   default 0x10060 if MACH_SUN50I || MACH_SUN50I_H5 || MACH_SUN9I
-   default 0x20060 if SUN50I_GEN_H6
-   default 0x00060 if ARCH_SUNXI
default 0xfffc if ARCH_ZYNQMP
default 0x0
help
-- 
2.37.3



[PATCH 17/22] sunxi: Move TEXT_BASE to the board Kconfig

2022-10-31 Thread Samuel Holland
This is how the vast majority of platforms provided TEXT_BASE.
sunxi was the exception here.

Signed-off-by: Samuel Holland 
---

 board/sunxi/Kconfig | 6 ++
 boot/Kconfig| 4 
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index d463474535..7ff0275ae4 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -137,6 +137,12 @@ config SYS_LOAD_ADDR
 config SYS_SOC
default "sunxi"
 
+config TEXT_BASE
+   default 0x8170 if MACH_SUNIV
+   default 0x2a00 if MACH_SUN9I
+   default 0x4a00 if SUNXI_MINIMUM_DRAM_MB >= 256
+   default 0x42e0 if SUNXI_MINIMUM_DRAM_MB >= 64
+
 menu "sunxi board options"
 
 choice
diff --git a/boot/Kconfig b/boot/Kconfig
index d5c582ebe8..b650a0b052 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -633,10 +633,6 @@ config TEXT_BASE
depends on HAVE_TEXT_BASE
default 0x0 if POSITION_INDEPENDENT
default 0x8080 if ARCH_OMAP2PLUS || ARCH_K3
-   default 0x8170 if MACH_SUNIV
-   default 0x2a00 if MACH_SUN9I
-   default 0x4a00 if SUNXI_MINIMUM_DRAM_MB >= 256
-   default 0x42e0 if SUNXI_MINIMUM_DRAM_MB >= 64
hex "Text Base"
help
  The address in memory that U-Boot will be running from, initially.
-- 
2.37.3



[PATCH 18/22] sunxi: Move most board options to the board Kconfig

2022-10-31 Thread Samuel Holland
This excludes options that are inherently ARM-specific or are specific
to legacy non-DM drivers.

Some help text is cleaned up along the way.

Signed-off-by: Samuel Holland 
---

 arch/arm/mach-sunxi/Kconfig | 71 
 board/sunxi/Kconfig | 72 +
 2 files changed, 72 insertions(+), 71 deletions(-)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index 24840f6d7e..ff21d94842 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -559,16 +559,6 @@ config DRAM_ODT_CORRECTION
then the correction is negative. Usually the value for this is 0.
 endif
 
-config UART0_PORT_F
-   bool "UART0 on MicroSD breakout board"
-   ---help---
-   Repurpose the SD card slot for getting access to the UART0 serial
-   console. Primarily useful only for low level u-boot debugging on
-   tablets, where normal UART0 is difficult to access and requires
-   device disassembly and/or soldering. As the SD card can't be used
-   at the same time, the system can be only booted in the FEL mode.
-   Only enable this if you really know what you are doing.
-
 config OLD_SUNXI_KERNEL_COMPAT
bool "Enable workarounds for booting old kernels"
---help---
@@ -609,20 +599,6 @@ config MMC3_CD_PIN
---help---
See MMC0_CD_PIN help text.
 
-config MMC1_PINS_PH
-   bool "Pins for mmc1 are on Port H"
-   depends on MACH_SUN4I || MACH_SUN7I || MACH_SUN8I_R40
-   ---help---
-   Select this option for boards where mmc1 uses the Port H pinmux.
-
-config MMC_SUNXI_SLOT_EXTRA
-   int "mmc extra slot number"
-   default -1
-   ---help---
-   sunxi builds always enable mmc0, some boards also have a second sdcard
-   slot or emmc on mmc1 - mmc3. Setting this to 1, 2 or 3 will enable
-   support for this.
-
 config USB0_VBUS_PIN
string "Vbus enable pin for usb0 (otg)"
default ""
@@ -699,16 +675,6 @@ config AXP_GPIO
---help---
Say Y here to enable support for the gpio pins of the axp PMIC ICs.
 
-config AXP_DISABLE_BOOT_ON_POWERON
-   bool "Disable device boot on power plug-in"
-   depends on AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER
-   default n
-   ---help---
- Say Y here to prevent the device from booting up because of a plug-in
- event. When set, the device will boot into the SPL briefly to
- determine why it was powered on, and if it was determined because of
- a plug-in event instead of a button press event it will shut back off.
-
 config VIDEO_SUNXI
bool "Enable graphical uboot console on HDMI, LCD or VGA"
depends on !MACH_SUN8I_A83T
@@ -937,41 +903,4 @@ config SPL_SPI_SUNXI
  sunxi SPI Flash. It uses the same method as the boot ROM, so does
  not need any extra configuration.
 
-config PINE64_DT_SELECTION
-   bool "Enable Pine64 device tree selection code"
-   depends on MACH_SUN50I
-   help
- The original Pine A64 and Pine A64+ are similar but different
- boards and can be differed by the DRAM size. Pine A64 has
- 512MiB DRAM, and Pine A64+ has 1GiB or 2GiB. By selecting this
- option, the device tree selection code specific to Pine64 which
- utilizes the DRAM size will be enabled.
-
-config PINEPHONE_DT_SELECTION
-   bool "Enable PinePhone device tree selection code"
-   depends on MACH_SUN50I
-   help
- Enable this option to automatically select the device tree for the
- correct PinePhone hardware revision during boot.
-
-config BLUETOOTH_DT_DEVICE_FIXUP
-   string "Fixup the Bluetooth controller address"
-   default ""
-   help
- This option specifies the DT compatible name of the Bluetooth
- controller for which to set the "local-bd-address" property.
- Set this option if your device ships with the Bluetooth controller
- default address.
- The used address is "bdaddr" if set, and "ethaddr" with the LSB
- flipped elsewise.
-
 endif
-
-config CHIP_DIP_SCAN
-   bool "Enable DIPs detection for CHIP board"
-   select SUPPORT_EXTENSION_SCAN
-   select W1
-   select W1_GPIO
-   select W1_EEPROM
-   select W1_EEPROM_DS24XXX
-   select CMD_EXTENSION
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 7ff0275ae4..f5e5c3770f 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -171,6 +171,78 @@ config SPL_IMAGE_TYPE
default "sunxi_egon" if SPL_IMAGE_TYPE_SUNXI_EGON
default "sunxi_toc0" if SPL_IMAGE_TYPE_SUNXI_TOC0
 
+config MMC_SUNXI_SLOT_EXTRA
+   int "MMC extra slot number"
+   default -1
+   help
+ sunxi builds always enable mmc0. Some boards also have a
+ second SD card slot or eMMC on mmc1 - mmc3. Setting this to 1,
+ 2 or 3 will enable support for this.
+
+config MM

[PATCH 19/22] env: sunxi: Replace ARCH_SUNXI with BOARD_SUNXI

2022-10-31 Thread Samuel Holland
This ensures the same environment layout will be used across all sunxi
boards, regardless of CPU architecture.

Signed-off-by: Samuel Holland 
---

 env/Kconfig | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/env/Kconfig b/env/Kconfig
index 24111dfaf4..ae28e4e3e6 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -92,7 +92,7 @@ config ENV_IS_IN_FAT
bool "Environment is in a FAT filesystem"
depends on !CHAIN_OF_TRUST
default y if ARCH_BCM283X
-   default y if ARCH_SUNXI && MMC
+   default y if BOARD_SUNXI && MMC
default y if MMC_OMAP_HS && TI_COMMON_CMD_OPTIONS
select FS_FAT
select FAT_WRITE
@@ -338,7 +338,7 @@ config ENV_IS_IN_SPI_FLASH
default y if NORTHBRIDGE_INTEL_IVYBRIDGE
default y if INTEL_QUARK
default y if INTEL_QUEENSBAY
-   default y if ARCH_SUNXI
+   default y if BOARD_SUNXI
help
  Define this if you have a SPI Flash memory device which you
  want to use for the environment.
@@ -461,7 +461,7 @@ config ENV_FAT_DEVICE_AND_PART
depends on ENV_IS_IN_FAT
default "0:1" if TI_COMMON_CMD_OPTIONS
default "0:auto" if ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL
-   default ":auto" if ARCH_SUNXI
+   default ":auto" if BOARD_SUNXI
default "0" if ARCH_AT91
help
  Define this to a string to specify the partition of the device. It can
@@ -555,7 +555,7 @@ config ENV_OFFSET
ENV_IS_IN_SPI_FLASH
default 0x3f8000 if ARCH_ROCKCHIP && ENV_IS_IN_MMC
default 0x14 if ARCH_ROCKCHIP && ENV_IS_IN_SPI_FLASH
-   default 0xF if ARCH_SUNXI
+   default 0xF if BOARD_SUNXI
default 0xE if ARCH_ZYNQ
default 0x1E0 if ARCH_ZYNQMP
default 0x7F4 if ARCH_VERSAL || ARCH_VERSAL_NET
@@ -580,7 +580,7 @@ config ENV_SIZE
hex "Environment Size"
default 0x4 if ENV_IS_IN_SPI_FLASH && ARCH_ZYNQMP
default 0x2 if ARCH_ZYNQ || ARCH_OMAP2PLUS || ARCH_AT91
-   default 0x1 if ARCH_SUNXI
+   default 0x1 if BOARD_SUNXI
default 0x8000 if ARCH_ROCKCHIP && ENV_IS_IN_MMC
default 0x2000 if ARCH_ROCKCHIP && ENV_IS_IN_SPI_FLASH
default 0x8000 if ARCH_ZYNQMP || ARCH_VERSAL || ARCH_VERSAL_NET
@@ -596,7 +596,7 @@ config ENV_SECT_SIZE
default 0x4 if ARCH_ZYNQMP || ARCH_VERSAL || ARCH_VERSAL_NET
default 0x2 if ARCH_ZYNQ || ARCH_OMAP2PLUS || ARCH_AT91
default 0x2 if MICROBLAZE && ENV_IS_IN_SPI_FLASH
-   default 0x1 if ARCH_SUNXI && ENV_IS_IN_SPI_FLASH
+   default 0x1 if BOARD_SUNXI && ENV_IS_IN_SPI_FLASH
help
  Size of the sector containing the environment.
 
-- 
2.37.3



[PATCH 20/22] drivers: sunxi: Replace ARCH_SUNXI with BOARD_SUNXI

2022-10-31 Thread Samuel Holland
This provides a unified configuration across all sunxi boards,
regardless of CPU architecture.

Signed-off-by: Samuel Holland 
---

 drivers/clk/sunxi/Kconfig |  2 +-
 drivers/fastboot/Kconfig  | 13 ++---
 drivers/gpio/Kconfig  |  2 +-
 drivers/mmc/Kconfig   |  2 +-
 drivers/net/phy/Kconfig   |  4 ++--
 drivers/phy/allwinner/Kconfig |  2 +-
 drivers/pinctrl/sunxi/Kconfig |  2 +-
 drivers/reset/Kconfig |  2 +-
 drivers/spi/Kconfig   |  2 +-
 drivers/usb/Kconfig   |  2 +-
 drivers/usb/gadget/Kconfig|  8 
 drivers/usb/musb-new/Kconfig  |  2 +-
 drivers/video/Kconfig |  2 +-
 drivers/watchdog/Kconfig  |  4 ++--
 14 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig
index bf11fad6ee..72310e231d 100644
--- a/drivers/clk/sunxi/Kconfig
+++ b/drivers/clk/sunxi/Kconfig
@@ -1,6 +1,6 @@
 config CLK_SUNXI
bool "Clock support for Allwinner SoCs"
-   depends on CLK && ARCH_SUNXI
+   depends on CLK && BOARD_SUNXI
select DM_RESET
select SPL_DM_RESET if SPL_CLK
default y
diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index b97c67bf60..a55fdac370 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -8,7 +8,7 @@ config FASTBOOT
 config USB_FUNCTION_FASTBOOT
bool "Enable USB fastboot gadget"
depends on USB_GADGET
-   default y if ARCH_SUNXI && USB_MUSB_GADGET
+   default y if BOARD_SUNXI && USB_MUSB_GADGET
select FASTBOOT
select USB_GADGET_DOWNLOAD
help
@@ -32,10 +32,9 @@ if FASTBOOT
 
 config FASTBOOT_BUF_ADDR
hex "Define FASTBOOT buffer address"
+   default SYS_LOAD_ADDR if BOARD_SUNXI
default 0x8200 if MX6SX || MX6SL || MX6UL || MX6SLL
default 0x8100 if ARCH_OMAP2PLUS
-   default 0x4200 if ARCH_SUNXI && !MACH_SUN9I
-   default 0x2200 if ARCH_SUNXI && MACH_SUN9I
default 0x60800800 if ROCKCHIP_RK3036 || ROCKCHIP_RK3188 || \
ROCKCHIP_RK322X
default 0x800800 if ROCKCHIP_RK3288 || ROCKCHIP_RK3329 || \
@@ -52,7 +51,7 @@ config FASTBOOT_BUF_SIZE
hex "Define FASTBOOT buffer size"
default 0x800 if ARCH_ROCKCHIP
default 0x600 if ARCH_ZYNQMP
-   default 0x200 if ARCH_SUNXI
+   default 0x200 if BOARD_SUNXI
default 0x8192 if SANDBOX
default 0x700
help
@@ -71,7 +70,7 @@ config FASTBOOT_USB_DEV
 
 config FASTBOOT_FLASH
bool "Enable FASTBOOT FLASH command"
-   default y if ARCH_SUNXI || ARCH_ROCKCHIP
+   default y if BOARD_SUNXI || ARCH_ROCKCHIP
depends on MMC || (MTD_RAW_NAND && CMD_MTDPARTS)
select IMAGE_SPARSE
help
@@ -105,8 +104,8 @@ config FASTBOOT_FLASH_MMC_DEV
int "Define FASTBOOT MMC FLASH default device"
depends on FASTBOOT_FLASH_MMC
default 0 if ARCH_ROCKCHIP
-   default 0 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1
-   default 1 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1
+   default 0 if BOARD_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1
+   default 1 if BOARD_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1
help
  The fastboot "flash" command requires additional information
  regarding the non-volatile storage device. Define this to
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index ff87fbfb39..defdb91368 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -363,7 +363,7 @@ config SANDBOX_GPIO_COUNT
 
 config SUNXI_GPIO
bool "Allwinner GPIO driver"
-   depends on ARCH_SUNXI
+   depends on BOARD_SUNXI
select SPL_STRTO if SPL
help
  Support the GPIO device in Allwinner SoCs.
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 56f42820c7..6a7271de75 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -749,7 +749,7 @@ config ZYNQ_HISPD_BROKEN
 
 config MMC_SUNXI
bool "Allwinner sunxi SD/MMC Host Controller support"
-   depends on ARCH_SUNXI
+   depends on BOARD_SUNXI
default y
help
  This selects support for the SD/MMC Host Controller on
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 52ce08b3b3..a68298fa08 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -19,14 +19,14 @@ if PHYLIB
 
 config PHY_ADDR_ENABLE
bool "Limit phy address"
-   default y if ARCH_SUNXI
+   default y if BOARD_SUNXI
help
  Select this if you want to control which phy address is used
 
 if PHY_ADDR_ENABLE
 config PHY_ADDR
int "PHY address"
-   default 1 if ARCH_SUNXI
+   default 1 if BOARD_SUNXI
default 0
help
  The address of PHY on MII bus. Usually in range of 0 to 31.
diff --git a/drivers/phy/allwinner/Kconfig b/drivers/phy/allwinner/Kconfig
index f8f1e99c4f..ab43681f0c 100644
--- a/drivers/phy/allwinner/

[PATCH 22/22] spl: sunxi: Replace ARCH_SUNXI with BOARD_SUNXI

2022-10-31 Thread Samuel Holland
This provides a unified configuration across all sunxi boards,
regardless of CPU architecture.

Signed-off-by: Samuel Holland 
---

 common/spl/Kconfig   | 12 ++--
 scripts/Makefile.spl |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 930028b5af..5ff75aad9f 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -110,7 +110,7 @@ config SPL_PAD_TO
 config SPL_HAS_BSS_LINKER_SECTION
depends on SPL_FRAMEWORK
bool "Use a specific address for the BSS via the linker script"
-   default y if ARCH_SUNXI || ARCH_MX6 || ARCH_OMAP2PLUS || MIPS || RISCV 
|| ARCH_ZYNQMP
+   default y if ARCH_MX6 || ARCH_OMAP2PLUS || ARCH_ZYNQMP || BOARD_SUNXI 
|| MIPS || RISCV
 
 config SPL_BSS_START_ADDR
hex "Link address for the BSS within the SPL binary"
@@ -334,7 +334,7 @@ config SPL_SYS_MALLOC_SIMPLE
 config SPL_SHARES_INIT_SP_ADDR
bool "SPL and U-Boot use the same initial stack pointer location"
depends on (ARM || ARCH_JZ47XX || MICROBLAZE || RISCV) && SPL_FRAMEWORK
-   default n if ARCH_SUNXI || ARCH_MX6 || ARCH_MX7
+   default n if BOARD_SUNXI || ARCH_MX6 || ARCH_MX7
default y
help
  In many cases, we can use the same initial stack pointer address for
@@ -452,7 +452,7 @@ config SPL_DISPLAY_PRINT
 
 config SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
bool "MMC raw mode: by sector"
-   default y if ARCH_SUNXI || ARCH_DAVINCI || ARCH_UNIPHIER || \
+   default y if BOARD_SUNXI || ARCH_DAVINCI || ARCH_UNIPHIER || \
 ARCH_MX6 || ARCH_MX7 || \
 ARCH_ROCKCHIP || ARCH_MVEBU ||  ARCH_SOCFPGA || \
 ARCH_AT91 || ARCH_ZYNQ || ARCH_KEYSTONE || OMAP34XX || \
@@ -465,7 +465,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
 config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
hex "Address on the MMC to load U-Boot from"
depends on SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
-   default 0x40 if ARCH_SUNXI
+   default 0x40 if BOARD_SUNXI
default 0x75 if ARCH_DAVINCI
default 0x8a if ARCH_MX6 || ARCH_MX7
default 0x100 if ARCH_UNIPHIER
@@ -482,7 +482,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
 config SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET
hex "U-Boot main hardware partition image offset"
depends on SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
-   default 0x10 if ARCH_SUNXI
+   default 0x10 if BOARD_SUNXI
default 0x0
help
  On some platforms SPL location depends on hardware partition. The ROM
@@ -1308,7 +1308,7 @@ endif # SPL_SPI_FLASH_SUPPORT
 
 config SYS_SPI_U_BOOT_OFFS
hex "address of u-boot payload in SPI flash"
-   default 0x8000 if ARCH_SUNXI
+   default 0x8000 if BOARD_SUNXI
default 0x0
depends on SPL_SPI_LOAD || SPL_SPI_SUNXI
help
diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index 15ac87286d..819050dd4d 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -264,7 +264,7 @@ endif
 
 INPUTS-$(CONFIG_TARGET_SOCFPGA_SOC64) += $(obj)/u-boot-spl-dtb.hex
 
-ifdef CONFIG_ARCH_SUNXI
+ifdef CONFIG_BOARD_SUNXI
 INPUTS-y   += $(obj)/sunxi-spl.bin
 
 ifdef CONFIG_NAND_SUNXI
-- 
2.37.3



[PATCH 21/22] disk: sunxi: Replace ARCH_SUNXI with BOARD_SUNXI

2022-10-31 Thread Samuel Holland
This provides a unified configuration across all sunxi boards,
regardless of CPU architecture.

Signed-off-by: Samuel Holland 
---

 disk/Kconfig | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/disk/Kconfig b/disk/Kconfig
index c9b9dbaf1a..b9d3625dc2 100644
--- a/disk/Kconfig
+++ b/disk/Kconfig
@@ -61,7 +61,7 @@ config SPL_DOS_PARTITION
bool "Enable MS Dos partition table for SPL"
depends on SPL
default n if ARCH_MVEBU
-   default n if ARCH_SUNXI
+   default n if BOARD_SUNXI
default y if DOS_PARTITION
select SPL_PARTITIONS
 
@@ -104,7 +104,7 @@ config EFI_PARTITION
 config EFI_PARTITION_ENTRIES_NUMBERS
int "Number of the EFI partition entries"
depends on EFI_PARTITION
-   default 56 if ARCH_SUNXI
+   default 56 if BOARD_SUNXI
default 128
help
  Specify the number of partition entries in the GPT. This is
@@ -132,7 +132,7 @@ config SPL_EFI_PARTITION
bool "Enable EFI GPT partition table for SPL"
depends on  SPL
default n if ARCH_MVEBU
-   default n if ARCH_SUNXI
+   default n if BOARD_SUNXI
default y if EFI_PARTITION
select SPL_PARTITIONS
 
-- 
2.37.3