Re: [PATCH v9 2/2] arm64: boot: Support Flat Image Tree

2024-02-01 Thread Masahiro Yamada
On Fri, Feb 2, 2024 at 6:03 AM Rob Herring  wrote:
>
> On Wed, Jan 31, 2024 at 8:09 PM Masahiro Yamada  wrote:
> >
> > On Thu, Feb 1, 2024 at 7:03 AM Rob Herring  wrote:
> > >
> > > On Tue, Jan 30, 2024 at 3:16 AM Masahiro Yamada  
> > > wrote:
> > > >
> > > > On Fri, Jan 26, 2024 at 1:04 AM Simon Glass  wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > On Wed, 17 Jan 2024 at 06:14, Simon Glass  wrote:
> > > > > >
> > > > > > Hi Masahiro, Tom,
> > > > > >
> > > > > > On Tue, 9 Jan 2024 at 07:33, Tom Rini  wrote:
> > > > > > >
> > > > > > > On Tue, Jan 09, 2024 at 11:01:42PM +0900, Masahiro Yamada wrote:
> > > > > > > > Hi Simon,
> > > > > > > >
> > > > > > > >
> > > > > > > > On Wed, Jan 3, 2024 at 8:47 AM Simon Glass  
> > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > Hi Masahiro,
> > > > > > > > >
> > > > > > > > > On Wed, Dec 13, 2023 at 5:14 AM Will Deacon  
> > > > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > On Fri, Dec 01, 2023 at 08:54:42PM -0700, Simon Glass wrote:
> > > > > > > > > > > Add a script which produces a Flat Image Tree (FIT), a 
> > > > > > > > > > > single file
> > > > > > > > > > > containing the built kernel and associated devicetree 
> > > > > > > > > > > files.
> > > > > > > > > > > Compression defaults to gzip which gives a good balance 
> > > > > > > > > > > of size and
> > > > > > > > > > > performance.
> > > > > > > > > > >
> > > > > > > > > > > The files compress from about 86MB to 24MB using this 
> > > > > > > > > > > approach.
> > > > > > > > > > >
> > > > > > > > > > > The FIT can be used by bootloaders which support it, such 
> > > > > > > > > > > as U-Boot
> > > > > > > > > > > and Linuxboot. It permits automatic selection of the 
> > > > > > > > > > > correct
> > > > > > > > > > > devicetree, matching the compatible string of the running 
> > > > > > > > > > > board with
> > > > > > > > > > > the closest compatible string in the FIT. There is no 
> > > > > > > > > > > need for
> > > > > > > > > > > filenames or other workarounds.
> > > > > > > > > > >
> > > > > > > > > > > Add a 'make image.fit' build target for arm64, as well. 
> > > > > > > > > > > Use
> > > > > > > > > > > FIT_COMPRESSION to select a different algorithm.
> > > > > > > > > > >
> > > > > > > > > > > The FIT can be examined using 'dumpimage -l'.
> > > > > > > > > > >
> > > > > > > > > > > This features requires pylibfdt (use 'pip install 
> > > > > > > > > > > libfdt'). It also
> > > > > > > > > > > requires compression utilities for the algorithm being 
> > > > > > > > > > > used. Supported
> > > > > > > > > > > compression options are the same as the Image.xxx files. 
> > > > > > > > > > > For now there
> > > > > > > > > > > is no way to change the compression other than by editing 
> > > > > > > > > > > the rule for
> > > > > > > > > > > $(obj)/image.fit
> > > > > > > > > > >
> > > > > > > > > > > While FIT supports a ramdisk / initrd, no attempt is made 
> > > > > > > > > > > to support
> > > > > > > > > > > this here, since it must be built separately from the 
> > > > > > > > > > > L

Re: [PATCH v9 2/2] arm64: boot: Support Flat Image Tree

2024-01-31 Thread Masahiro Yamada
On Thu, Feb 1, 2024 at 7:03 AM Rob Herring  wrote:
>
> On Tue, Jan 30, 2024 at 3:16 AM Masahiro Yamada  wrote:
> >
> > On Fri, Jan 26, 2024 at 1:04 AM Simon Glass  wrote:
> > >
> > > Hi,
> > >
> > > On Wed, 17 Jan 2024 at 06:14, Simon Glass  wrote:
> > > >
> > > > Hi Masahiro, Tom,
> > > >
> > > > On Tue, 9 Jan 2024 at 07:33, Tom Rini  wrote:
> > > > >
> > > > > On Tue, Jan 09, 2024 at 11:01:42PM +0900, Masahiro Yamada wrote:
> > > > > > Hi Simon,
> > > > > >
> > > > > >
> > > > > > On Wed, Jan 3, 2024 at 8:47 AM Simon Glass  
> > > > > > wrote:
> > > > > > >
> > > > > > > Hi Masahiro,
> > > > > > >
> > > > > > > On Wed, Dec 13, 2023 at 5:14 AM Will Deacon  
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > On Fri, Dec 01, 2023 at 08:54:42PM -0700, Simon Glass wrote:
> > > > > > > > > Add a script which produces a Flat Image Tree (FIT), a single 
> > > > > > > > > file
> > > > > > > > > containing the built kernel and associated devicetree files.
> > > > > > > > > Compression defaults to gzip which gives a good balance of 
> > > > > > > > > size and
> > > > > > > > > performance.
> > > > > > > > >
> > > > > > > > > The files compress from about 86MB to 24MB using this 
> > > > > > > > > approach.
> > > > > > > > >
> > > > > > > > > The FIT can be used by bootloaders which support it, such as 
> > > > > > > > > U-Boot
> > > > > > > > > and Linuxboot. It permits automatic selection of the correct
> > > > > > > > > devicetree, matching the compatible string of the running 
> > > > > > > > > board with
> > > > > > > > > the closest compatible string in the FIT. There is no need for
> > > > > > > > > filenames or other workarounds.
> > > > > > > > >
> > > > > > > > > Add a 'make image.fit' build target for arm64, as well. Use
> > > > > > > > > FIT_COMPRESSION to select a different algorithm.
> > > > > > > > >
> > > > > > > > > The FIT can be examined using 'dumpimage -l'.
> > > > > > > > >
> > > > > > > > > This features requires pylibfdt (use 'pip install libfdt'). 
> > > > > > > > > It also
> > > > > > > > > requires compression utilities for the algorithm being used. 
> > > > > > > > > Supported
> > > > > > > > > compression options are the same as the Image.xxx files. For 
> > > > > > > > > now there
> > > > > > > > > is no way to change the compression other than by editing the 
> > > > > > > > > rule for
> > > > > > > > > $(obj)/image.fit
> > > > > > > > >
> > > > > > > > > While FIT supports a ramdisk / initrd, no attempt is made to 
> > > > > > > > > support
> > > > > > > > > this here, since it must be built separately from the Linux 
> > > > > > > > > build.
> > > > > > > > >
> > > > > > > > > Signed-off-by: Simon Glass 
> > > > > > > > > ---
> > > > > > > > >
> > > > > > > > > Changes in v9:
> > > > > > > > > - Move the compression control into Makefile.lib
> > > > > > > > >
> > > > > > > > > Changes in v8:
> > > > > > > > > - Drop compatible string in FDT node
> > > > > > > > > - Correct sorting of MAINTAINERS to before ARM64 PORT
> > > > > > > > > - Turn compress part of the make_fit.py comment in to a 
> > > > > > > > > sentence
> > > > > > > > > - Add two blank lines before parse_args() and setup_fit()
> > > > > > > > > - Use 'image.fit: dtbs' instead of BUILD_DTBS var
&

Re: [PATCH v9 2/2] arm64: boot: Support Flat Image Tree

2024-01-30 Thread Masahiro Yamada
On Fri, Jan 26, 2024 at 1:04 AM Simon Glass  wrote:
>
> Hi,
>
> On Wed, 17 Jan 2024 at 06:14, Simon Glass  wrote:
> >
> > Hi Masahiro, Tom,
> >
> > On Tue, 9 Jan 2024 at 07:33, Tom Rini  wrote:
> > >
> > > On Tue, Jan 09, 2024 at 11:01:42PM +0900, Masahiro Yamada wrote:
> > > > Hi Simon,
> > > >
> > > >
> > > > On Wed, Jan 3, 2024 at 8:47 AM Simon Glass  wrote:
> > > > >
> > > > > Hi Masahiro,
> > > > >
> > > > > On Wed, Dec 13, 2023 at 5:14 AM Will Deacon  wrote:
> > > > > >
> > > > > > On Fri, Dec 01, 2023 at 08:54:42PM -0700, Simon Glass wrote:
> > > > > > > Add a script which produces a Flat Image Tree (FIT), a single file
> > > > > > > containing the built kernel and associated devicetree files.
> > > > > > > Compression defaults to gzip which gives a good balance of size 
> > > > > > > and
> > > > > > > performance.
> > > > > > >
> > > > > > > The files compress from about 86MB to 24MB using this approach.
> > > > > > >
> > > > > > > The FIT can be used by bootloaders which support it, such as 
> > > > > > > U-Boot
> > > > > > > and Linuxboot. It permits automatic selection of the correct
> > > > > > > devicetree, matching the compatible string of the running board 
> > > > > > > with
> > > > > > > the closest compatible string in the FIT. There is no need for
> > > > > > > filenames or other workarounds.
> > > > > > >
> > > > > > > Add a 'make image.fit' build target for arm64, as well. Use
> > > > > > > FIT_COMPRESSION to select a different algorithm.
> > > > > > >
> > > > > > > The FIT can be examined using 'dumpimage -l'.
> > > > > > >
> > > > > > > This features requires pylibfdt (use 'pip install libfdt'). It 
> > > > > > > also
> > > > > > > requires compression utilities for the algorithm being used. 
> > > > > > > Supported
> > > > > > > compression options are the same as the Image.xxx files. For now 
> > > > > > > there
> > > > > > > is no way to change the compression other than by editing the 
> > > > > > > rule for
> > > > > > > $(obj)/image.fit
> > > > > > >
> > > > > > > While FIT supports a ramdisk / initrd, no attempt is made to 
> > > > > > > support
> > > > > > > this here, since it must be built separately from the Linux build.
> > > > > > >
> > > > > > > Signed-off-by: Simon Glass 
> > > > > > > ---
> > > > > > >
> > > > > > > Changes in v9:
> > > > > > > - Move the compression control into Makefile.lib
> > > > > > >
> > > > > > > Changes in v8:
> > > > > > > - Drop compatible string in FDT node
> > > > > > > - Correct sorting of MAINTAINERS to before ARM64 PORT
> > > > > > > - Turn compress part of the make_fit.py comment in to a sentence
> > > > > > > - Add two blank lines before parse_args() and setup_fit()
> > > > > > > - Use 'image.fit: dtbs' instead of BUILD_DTBS var
> > > > > > > - Use '$( > > > > > > - Add 'mkimage' details Documentation/process/changes.rst
> > > > > > > - Allow changing the compression used
> > > > > > > - Tweak cover letter since there is only one clean-up patch
> > > > > > >
> > > > > > > Changes in v7:
> > > > > > > - Add Image as a dependency of image.fit
> > > > > > > - Drop kbuild tag
> > > > > > > - Add dependency on dtbs
> > > > > > > - Drop unnecessary path separator for dtbs
> > > > > > > - Rebase to -next
> > > > > > >
> > > > > > > Changes in v5:
> > > > > > > - Drop patch previously applied
> > > > > > > - Correct compression rule which was broken in v4
> > > > > > >
> > > > > > > Changes in v4:
> > > > > > 

Re: [PATCH v9 2/2] arm64: boot: Support Flat Image Tree

2024-01-09 Thread Masahiro Yamada
Hi Simon,


On Wed, Jan 3, 2024 at 8:47 AM Simon Glass  wrote:
>
> Hi Masahiro,
>
> On Wed, Dec 13, 2023 at 5:14 AM Will Deacon  wrote:
> >
> > On Fri, Dec 01, 2023 at 08:54:42PM -0700, Simon Glass wrote:
> > > Add a script which produces a Flat Image Tree (FIT), a single file
> > > containing the built kernel and associated devicetree files.
> > > Compression defaults to gzip which gives a good balance of size and
> > > performance.
> > >
> > > The files compress from about 86MB to 24MB using this approach.
> > >
> > > The FIT can be used by bootloaders which support it, such as U-Boot
> > > and Linuxboot. It permits automatic selection of the correct
> > > devicetree, matching the compatible string of the running board with
> > > the closest compatible string in the FIT. There is no need for
> > > filenames or other workarounds.
> > >
> > > Add a 'make image.fit' build target for arm64, as well. Use
> > > FIT_COMPRESSION to select a different algorithm.
> > >
> > > The FIT can be examined using 'dumpimage -l'.
> > >
> > > This features requires pylibfdt (use 'pip install libfdt'). It also
> > > requires compression utilities for the algorithm being used. Supported
> > > compression options are the same as the Image.xxx files. For now there
> > > is no way to change the compression other than by editing the rule for
> > > $(obj)/image.fit
> > >
> > > While FIT supports a ramdisk / initrd, no attempt is made to support
> > > this here, since it must be built separately from the Linux build.
> > >
> > > Signed-off-by: Simon Glass 
> > > ---
> > >
> > > Changes in v9:
> > > - Move the compression control into Makefile.lib
> > >
> > > Changes in v8:
> > > - Drop compatible string in FDT node
> > > - Correct sorting of MAINTAINERS to before ARM64 PORT
> > > - Turn compress part of the make_fit.py comment in to a sentence
> > > - Add two blank lines before parse_args() and setup_fit()
> > > - Use 'image.fit: dtbs' instead of BUILD_DTBS var
> > > - Use '$( > > - Add 'mkimage' details Documentation/process/changes.rst
> > > - Allow changing the compression used
> > > - Tweak cover letter since there is only one clean-up patch
> > >
> > > Changes in v7:
> > > - Add Image as a dependency of image.fit
> > > - Drop kbuild tag
> > > - Add dependency on dtbs
> > > - Drop unnecessary path separator for dtbs
> > > - Rebase to -next
> > >
> > > Changes in v5:
> > > - Drop patch previously applied
> > > - Correct compression rule which was broken in v4
> > >
> > > Changes in v4:
> > > - Use single quotes for UIMAGE_NAME
> > >
> > > Changes in v3:
> > > - Drop temporary file image.itk
> > > - Drop patch 'Use double quotes for image name'
> > > - Drop double quotes in use of UIMAGE_NAME
> > > - Drop unnecessary CONFIG_EFI_ZBOOT condition for help
> > > - Avoid hard-coding "arm64" for the DT architecture
> > >
> > > Changes in v2:
> > > - Drop patch previously applied
> > > - Add .gitignore file
> > > - Move fit rule to Makefile.lib using an intermediate file
> > > - Drop dependency on CONFIG_EFI_ZBOOT
> > > - Pick up .dtb files separately from the kernel
> > > - Correct pylint too-many-args warning for write_kernel()
> > > - Include the kernel image in the file count
> > > - Add a pointer to the FIT spec and mention of its wide industry usage
> > > - Mention the kernel version in the FIT description
> > >
> > >  Documentation/process/changes.rst |   9 +
> > >  MAINTAINERS   |   7 +
> > >  arch/arm64/Makefile   |   7 +-
> > >  arch/arm64/boot/.gitignore|   1 +
> > >  arch/arm64/boot/Makefile  |   6 +-
> > >  scripts/Makefile.lib  |  16 ++
> > >  scripts/make_fit.py   | 291 ++
> > >  7 files changed, 334 insertions(+), 3 deletions(-)
> > >  create mode 100755 scripts/make_fit.py
> >
> > I'll need Masahiro's Ack on the scripts/ changes before I can take this
> > one.
>
> Any thoughts on this request, please?
>
> Regards,
> Simon
>



As I mentioned before, I am concerned with having
the same "compatible" entries, with different contents,
as you use the "compatible" string as an ID to selecting
the target config node, right?





$ fdtdump  arch/arm64/boot/image.fit

...

conf-10 {
compatible = "tq,am642-tqma6442l-mbax4xxl",
"tq,am642-tqma6442l", "ti,am642";
description = "TQ-Systems TQMa64xxL SoM on MBax4xxL carrier board";
fdt = "fdt-10";
kernel = "kernel";
};

...

conf-25 {
compatible = "tq,am642-tqma6442l-mbax4xxl",
"tq,am642-tqma6442l", "ti,am642";
description = "TQ-Systems TQMa64xxL SoM on MBax4xxL carrier board";
fdt = "fdt-25";
kernel = "kernel";
};












-- 
Best Regards
Masahiro Yamada


Re: [PATCH v9 2/2] arm64: boot: Support Flat Image Tree

2024-01-09 Thread Masahiro Yamada
On Fri, Dec 29, 2023 at 3:39 PM Simon Glass  wrote:
>
> Hi Masahiro,
>
> On Thu, Dec 14, 2023 at 7:34 AM Masahiro Yamada  wrote:
> >
> > On Thu, Dec 14, 2023 at 3:12 PM Masahiro Yamada  
> > wrote:
> > >
> > > On Thu, Dec 14, 2023 at 1:03 PM Chen-Yu Tsai  wrote:
> > > >
> > > > On Sun, Dec 10, 2023 at 1:31 AM Geert Uytterhoeven 
> > > >  wrote:
> > > > >
> > > > > Hi Laurent,
> > > > >
> > > > > On Sat, Dec 9, 2023 at 4:29 PM Laurent Pinchart
> > > > >  wrote:
> > > > > > On Sat, Dec 09, 2023 at 10:13:59PM +0900, Chen-Yu Tsai wrote:
> > > > > > > On Thu, Dec 7, 2023 at 11:38 PM Laurent Pinchart
> > > > > > >  wrote:
> > > > > > > > On Thu, Dec 07, 2023 at 10:27:23PM +0800, Chen-Yu Tsai wrote:
> > > > > > > > > On Sun, Dec 03, 2023 at 05:34:01PM +0200, Laurent Pinchart 
> > > > > > > > > wrote:
> > > > > > > > > > On Fri, Dec 01, 2023 at 08:54:42PM -0700, Simon Glass wrote:
> > > > > > > > > > > Add a script which produces a Flat Image Tree (FIT), a 
> > > > > > > > > > > single file
> > > > > > > > > > > containing the built kernel and associated devicetree 
> > > > > > > > > > > files.
> > > > > > > > > > > Compression defaults to gzip which gives a good balance 
> > > > > > > > > > > of size and
> > > > > > > > > > > performance.
> > > > > > > > > > >
> > > > > > > > > > > The files compress from about 86MB to 24MB using this 
> > > > > > > > > > > approach.
> > > > > > > > > > >
> > > > > > > > > > > The FIT can be used by bootloaders which support it, such 
> > > > > > > > > > > as U-Boot
> > > > > > > > > > > and Linuxboot. It permits automatic selection of the 
> > > > > > > > > > > correct
> > > > > > > > > > > devicetree, matching the compatible string of the running 
> > > > > > > > > > > board with
> > > > > > > > > > > the closest compatible string in the FIT. There is no 
> > > > > > > > > > > need for
> > > > > > > > > > > filenames or other workarounds.
> > > > > > > > > > >
> > > > > > > > > > > Add a 'make image.fit' build target for arm64, as well. 
> > > > > > > > > > > Use
> > > > > > > > > > > FIT_COMPRESSION to select a different algorithm.
> > > > > > > > > > >
> > > > > > > > > > > The FIT can be examined using 'dumpimage -l'.
> > > > > > > > > > >
> > > > > > > > > > > This features requires pylibfdt (use 'pip install 
> > > > > > > > > > > libfdt'). It also
> > > > > > > > > > > requires compression utilities for the algorithm being 
> > > > > > > > > > > used. Supported
> > > > > > > > > > > compression options are the same as the Image.xxx files. 
> > > > > > > > > > > For now there
> > > > > > > > > > > is no way to change the compression other than by editing 
> > > > > > > > > > > the rule for
> > > > > > > > > > > $(obj)/image.fit
> > > > > > > > > > >
> > > > > > > > > > > While FIT supports a ramdisk / initrd, no attempt is made 
> > > > > > > > > > > to support
> > > > > > > > > > > this here, since it must be built separately from the 
> > > > > > > > > > > Linux build.
> > > > > > > > > >
> > > > > > > > > > FIT images are very useful, so I think this is a very 
> > > > > > > > > > welcome addition
> > > > > > > > > > to the kernel build system. It can get tricky though: given 
> >

Re: [PATCH v9 2/2] arm64: boot: Support Flat Image Tree

2023-12-13 Thread Masahiro Yamada
On Thu, Dec 14, 2023 at 3:12 PM Masahiro Yamada  wrote:
>
> On Thu, Dec 14, 2023 at 1:03 PM Chen-Yu Tsai  wrote:
> >
> > On Sun, Dec 10, 2023 at 1:31 AM Geert Uytterhoeven  
> > wrote:
> > >
> > > Hi Laurent,
> > >
> > > On Sat, Dec 9, 2023 at 4:29 PM Laurent Pinchart
> > >  wrote:
> > > > On Sat, Dec 09, 2023 at 10:13:59PM +0900, Chen-Yu Tsai wrote:
> > > > > On Thu, Dec 7, 2023 at 11:38 PM Laurent Pinchart
> > > > >  wrote:
> > > > > > On Thu, Dec 07, 2023 at 10:27:23PM +0800, Chen-Yu Tsai wrote:
> > > > > > > On Sun, Dec 03, 2023 at 05:34:01PM +0200, Laurent Pinchart wrote:
> > > > > > > > On Fri, Dec 01, 2023 at 08:54:42PM -0700, Simon Glass wrote:
> > > > > > > > > Add a script which produces a Flat Image Tree (FIT), a single 
> > > > > > > > > file
> > > > > > > > > containing the built kernel and associated devicetree files.
> > > > > > > > > Compression defaults to gzip which gives a good balance of 
> > > > > > > > > size and
> > > > > > > > > performance.
> > > > > > > > >
> > > > > > > > > The files compress from about 86MB to 24MB using this 
> > > > > > > > > approach.
> > > > > > > > >
> > > > > > > > > The FIT can be used by bootloaders which support it, such as 
> > > > > > > > > U-Boot
> > > > > > > > > and Linuxboot. It permits automatic selection of the correct
> > > > > > > > > devicetree, matching the compatible string of the running 
> > > > > > > > > board with
> > > > > > > > > the closest compatible string in the FIT. There is no need for
> > > > > > > > > filenames or other workarounds.
> > > > > > > > >
> > > > > > > > > Add a 'make image.fit' build target for arm64, as well. Use
> > > > > > > > > FIT_COMPRESSION to select a different algorithm.
> > > > > > > > >
> > > > > > > > > The FIT can be examined using 'dumpimage -l'.
> > > > > > > > >
> > > > > > > > > This features requires pylibfdt (use 'pip install libfdt'). 
> > > > > > > > > It also
> > > > > > > > > requires compression utilities for the algorithm being used. 
> > > > > > > > > Supported
> > > > > > > > > compression options are the same as the Image.xxx files. For 
> > > > > > > > > now there
> > > > > > > > > is no way to change the compression other than by editing the 
> > > > > > > > > rule for
> > > > > > > > > $(obj)/image.fit
> > > > > > > > >
> > > > > > > > > While FIT supports a ramdisk / initrd, no attempt is made to 
> > > > > > > > > support
> > > > > > > > > this here, since it must be built separately from the Linux 
> > > > > > > > > build.
> > > > > > > >
> > > > > > > > FIT images are very useful, so I think this is a very welcome 
> > > > > > > > addition
> > > > > > > > to the kernel build system. It can get tricky though: given the
> > > > > > > > versatile nature of FIT images, there can't be any
> > > > > > > > one-size-fits-them-all solution to build them, and striking the 
> > > > > > > > right
> > > > > > > > balance between what makes sense for the kernel and the 
> > > > > > > > features that
> > > > > > > > users may request will probably lead to bikeshedding. As we all 
> > > > > > > > love
> > > > > > > > bikeshedding, I thought I would start selfishly, with a 
> > > > > > > > personal use
> > > > > > > > case :-) This isn't a yak-shaving request though, I don't see 
> > > > > > > > any reason
> > > > > > > > to delay merging this series.
> > > > > > > >
> > > > > > > > Have you envisioned building FIT 

Re: [PATCH v9 2/2] arm64: boot: Support Flat Image Tree

2023-12-13 Thread Masahiro Yamada
ds me
> > > > > > > to a second question: would you consider merging extensions to 
> > > > > > > this
> > > > > > > script if they are not used by the kernel build system, but meant 
> > > > > > > for
> > > > > > > users who manually invoke the script ? More generally, is the 
> > > > > > > script
> > > > > >
> > > > > > We'd also be interested in some customization, though in a 
> > > > > > different way.
> > > > > > We imagine having a rule file that says X compatible string should 
> > > > > > map
> > > > > > to A base DTB, plus B and C DTBO for the configuration section. The 
> > > > > > base
> > > > > > DTB would carry all common elements of some device, while the DTBOs
> > > > > > carry all the possible second source components, like different 
> > > > > > display
> > > > > > panels or MIPI cameras for instance. This could drastically reduce 
> > > > > > the
> > > > > > size of FIT images in ChromeOS by deduplicating all the common 
> > > > > > stuff.
> > > > >
> > > > > Do you envision the "mapping" compatible string mapping to a config
> > > > > section in the FIT image, that would bundle the base DTB and the 
> > > > > DTBOs ?
> > > >
> > > > That's exactly the idea. The mapping compatible string could be untied
> > > > from the base board's compatible string if needed (which we probably 
> > > > do).
> > > >
> > > > So something like:
> > > >
> > > > config {
> > > > config-1 {
> > > > compatible = "google,krane-sku0";
> > > > fdt = "krane-baseboard", "krane-sku0-overlay";
> > > > };
> > > > };
> > > >
> > > > With "krane-sku0-overlay" being an overlay that holds the differences
> > > > between the SKUs, in this case the display panel and MIPI camera (not
> > > > upstreamed) that applies to SKU0 in particular.
> > >
> > > The kernel DT makefiles already contain information on what overlays to
> > > apply to what base boards, in order to test the overlays and produce
> > > "full" DTBs. Maybe that information could be leveraged to create the
> > > configurations in the FIT image ?
> >
> > Although the "full" DTBs created may only be a subset of all possible
> > combinations (I believe Rob just started with creating one "full" DTB
> > for each overlay, cfr. the additions I made in commit a09c3e105a208580
> > ("arm64: dts: renesas: Apply overlays to base dtbs")), that could
> > definitely be a start.
> >
> > Now, since the kernel build system already creates "full" DTBs, does
> > that mean that all of the base DTBs, overlays, and "full" DTBs will
> > end up in the FIT image?
>
> I suppose we could add an option to the packing tool to be able to _not_
> add the "full" DTBs if they can also be assembled with a base DTB and
> overlays. Think of it as a firmware compatibility option: if the firmware
> supports overlays, then you almost always want the deconstructed parts,
> not the fully assembled ones. Vice versa.
>
> If we don't we could end up with two configurations that have the same
> compatible string?


Right.

We would end up with such situations because applying
an overlay does not change the compatible string.



With this code in arch/arm64/boot/dts/ti/Makefile:

k3-am642-tqma64xxl-mbax4xxl-sdcard-dtbs := \
  k3-am642-tqma64xxl-mbax4xxl.dtb k3-am64-tqma64xxl-mbax4xxl-sdcard.dtbo
k3-am642-tqma64xxl-mbax4xxl-wlan-dtbs := \
  k3-am642-tqma64xxl-mbax4xxl.dtb k3-am64-tqma64xxl-mbax4xxl-wlan.dtbo




$ fdtdump  arch/arm64/boot/dts/ti/k3-am642-tqma64xxl-mbax4xxl-sdcard.dtb
2>/dev/null| head -n15 | tail -n2
model = "TQ-Systems TQMa64xxL SoM on MBax4xxL carrier board";
compatible = "tq,am642-tqma6442l-mbax4xxl", "tq,am642-tqma6442l",
"ti,am642";


$ fdtdump  arch/arm64/boot/dts/ti/k3-am642-tqma64xxl-mbax4xxl-wlan.dtb
2>/dev/null| head -n15 | tail -n2
model = "TQ-Systems TQMa64xxL SoM on MBax4xxL carrier board";
compatible = "tq,am642-tqma6442l-mbax4xxl", "tq,am642-tqma6442l",
"ti,am642";





These two go into image.fit, but one of them is completely dead
since there is no way to distinguish them.


$ fdtdump  arch/arm64/boot/image.fit

...

conf-10 {
compatible = "tq,am642-tqma6442l-mbax4xxl",
"tq,am642-tqma6442l", "ti,am642";
description = "TQ-Systems TQMa64xxL SoM on MBax4xxL carrier board";
fdt = "fdt-10";
kernel = "kernel";
};

...

conf-25 {
compatible = "tq,am642-tqma6442l-mbax4xxl",
"tq,am642-tqma6442l", "ti,am642";
description = "TQ-Systems TQMa64xxL SoM on MBax4xxL carrier board";
fdt = "fdt-25";
kernel = "kernel";
};





I agree with Chen-Yu.

FIT should not include full DTBs.

Bootloaders should assemble the final DTB
from base and overlays on-the-fly.


The FIT spec allows the "fdt" property to list
multiple image nodes.


o config-1
 |- description = "configuration description"
 |- kernel = "kernel sub-node unit name"
 |- fdt = "fdt sub-node unit-name" [, "fdt overlay sub-node unit-name", ...]
 |- loadables = "loadables sub-node unit-name"
 |- script = "
 |- compatible = "vendor











>
> ChenYu
>
>
> > Gr{oetje,eeting}s,
> >
> > Geert
> >
> > --
> > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> > ge...@linux-m68k.org
> >
> > In personal conversations with technical people, I call myself a hacker. But
> > when I'm talking to journalists I just say "programmer" or something like 
> > that.
> > -- Linus Torvalds



--
Best Regards
Masahiro Yamada


Re: [PATCH v8 2/2] arm64: boot: Support Flat Image Tree

2023-12-01 Thread Masahiro Yamada
On Sat, Dec 2, 2023 at 3:09 AM Simon Glass  wrote:
>
> Hi Masahiro,
>
> On Fri, 1 Dec 2023 at 10:30, Masahiro Yamada  wrote:
> >
> > On Fri, Dec 1, 2023 at 5:34 AM Simon Glass  wrote:
> > >
> > > Add a script which produces a Flat Image Tree (FIT), a single file
> > > containing the built kernel and associated devicetree files.
> > > Compression defaults to gzip which gives a good balance of size and
> > > performance.
> > >
> > > The files compress from about 86MB to 24MB using this approach.
> > >
> > > The FIT can be used by bootloaders which support it, such as U-Boot
> > > and Linuxboot. It permits automatic selection of the correct
> > > devicetree, matching the compatible string of the running board with
> > > the closest compatible string in the FIT. There is no need for
> > > filenames or other workarounds.
> > >
> > > Add a 'make image.fit' build target for arm64, as well.
> > >
> > > The FIT can be examined using 'dumpimage -l'.
> > >
> > > This features requires pylibfdt (use 'pip install libfdt'). It also
> > > requires compression utilities for the algorithm being used. Supported
> > > compression options are the same as the Image.xxx files. For now there
> > > is no way to change the compression other than by editing the rule for
> > > $(obj)/image.fit
> > >
> > > While FIT supports a ramdisk / initrd, no attempt is made to support
> > > this here, since it must be built separately from the Linux build.
> > >
> > > Signed-off-by: Simon Glass 
> > > ---
> > >
> > > Changes in v8:
> > > - Drop compatible string in FDT node
> > > - Correct sorting of MAINTAINERS to before ARM64 PORT
> > > - Turn compress part of the make_fit.py comment in to a sentence
> > > - Add two blank lines before parse_args() and setup_fit()
> > > - Use 'image.fit: dtbs' instead of BUILD_DTBS var
> > > - Use '$( > > - Add 'mkimage' details Documentation/process/changes.rst
> > > - Allow changing the compression used
> > > - Tweak cover letter since there is only one clean-up patch
> > >
> > > Changes in v7:
> > > - Add Image as a dependency of image.fit
> > > - Drop kbuild tag
> > > - Add dependency on dtbs
> > > - Drop unnecessary path separator for dtbs
> > > - Rebase to -next
> > >
> > > Changes in v5:
> > > - Drop patch previously applied
> > > - Correct compression rule which was broken in v4
> > >
> > > Changes in v4:
> > > - Use single quotes for UIMAGE_NAME
> > >
> > > Changes in v3:
> > > - Drop temporary file image.itk
> > > - Drop patch 'Use double quotes for image name'
> > > - Drop double quotes in use of UIMAGE_NAME
> > > - Drop unnecessary CONFIG_EFI_ZBOOT condition for help
> > > - Avoid hard-coding "arm64" for the DT architecture
> > >
> > > Changes in v2:
> > > - Drop patch previously applied
> > > - Add .gitignore file
> > > - Move fit rule to Makefile.lib using an intermediate file
> > > - Drop dependency on CONFIG_EFI_ZBOOT
> > > - Pick up .dtb files separately from the kernel
> > > - Correct pylint too-many-args warning for write_kernel()
> > > - Include the kernel image in the file count
> > > - Add a pointer to the FIT spec and mention of its wide industry usage
> > > - Mention the kernel version in the FIT description
> > >
> > >  Documentation/process/changes.rst |   9 +
> > >  MAINTAINERS   |   7 +
> > >  arch/arm64/Makefile   |   7 +-
> > >  arch/arm64/boot/.gitignore|   1 +
> > >  arch/arm64/boot/Makefile  |   9 +-
> > >  scripts/Makefile.lib  |  13 ++
> > >  scripts/make_fit.py   | 291 ++
> > >  7 files changed, 334 insertions(+), 3 deletions(-)
> > >  create mode 100755 scripts/make_fit.py
> > >
> > > diff --git a/Documentation/process/changes.rst 
> > > b/Documentation/process/changes.rst
> > > index bb96ca0f774b..cad51bd5bd62 100644
> > > --- a/Documentation/process/changes.rst
> > > +++ b/Documentation/process/changes.rst
> > > @@ -62,6 +62,7 @@ Sphinx\ [#f1]_ 1.7  sphinx-build 
> > > --version
> > >  cpio   any  cpio --version
> > >  GNU tar1.28 tar --version
> >

Re: [PATCH v8 2/2] arm64: boot: Support Flat Image Tree

2023-12-01 Thread Masahiro Yamada
On Fri, Dec 1, 2023 at 5:34 AM Simon Glass  wrote:
>
> Add a script which produces a Flat Image Tree (FIT), a single file
> containing the built kernel and associated devicetree files.
> Compression defaults to gzip which gives a good balance of size and
> performance.
>
> The files compress from about 86MB to 24MB using this approach.
>
> The FIT can be used by bootloaders which support it, such as U-Boot
> and Linuxboot. It permits automatic selection of the correct
> devicetree, matching the compatible string of the running board with
> the closest compatible string in the FIT. There is no need for
> filenames or other workarounds.
>
> Add a 'make image.fit' build target for arm64, as well.
>
> The FIT can be examined using 'dumpimage -l'.
>
> This features requires pylibfdt (use 'pip install libfdt'). It also
> requires compression utilities for the algorithm being used. Supported
> compression options are the same as the Image.xxx files. For now there
> is no way to change the compression other than by editing the rule for
> $(obj)/image.fit
>
> While FIT supports a ramdisk / initrd, no attempt is made to support
> this here, since it must be built separately from the Linux build.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v8:
> - Drop compatible string in FDT node
> - Correct sorting of MAINTAINERS to before ARM64 PORT
> - Turn compress part of the make_fit.py comment in to a sentence
> - Add two blank lines before parse_args() and setup_fit()
> - Use 'image.fit: dtbs' instead of BUILD_DTBS var
> - Use '$( - Add 'mkimage' details Documentation/process/changes.rst
> - Allow changing the compression used
> - Tweak cover letter since there is only one clean-up patch
>
> Changes in v7:
> - Add Image as a dependency of image.fit
> - Drop kbuild tag
> - Add dependency on dtbs
> - Drop unnecessary path separator for dtbs
> - Rebase to -next
>
> Changes in v5:
> - Drop patch previously applied
> - Correct compression rule which was broken in v4
>
> Changes in v4:
> - Use single quotes for UIMAGE_NAME
>
> Changes in v3:
> - Drop temporary file image.itk
> - Drop patch 'Use double quotes for image name'
> - Drop double quotes in use of UIMAGE_NAME
> - Drop unnecessary CONFIG_EFI_ZBOOT condition for help
> - Avoid hard-coding "arm64" for the DT architecture
>
> Changes in v2:
> - Drop patch previously applied
> - Add .gitignore file
> - Move fit rule to Makefile.lib using an intermediate file
> - Drop dependency on CONFIG_EFI_ZBOOT
> - Pick up .dtb files separately from the kernel
> - Correct pylint too-many-args warning for write_kernel()
> - Include the kernel image in the file count
> - Add a pointer to the FIT spec and mention of its wide industry usage
> - Mention the kernel version in the FIT description
>
>  Documentation/process/changes.rst |   9 +
>  MAINTAINERS   |   7 +
>  arch/arm64/Makefile   |   7 +-
>  arch/arm64/boot/.gitignore|   1 +
>  arch/arm64/boot/Makefile  |   9 +-
>  scripts/Makefile.lib  |  13 ++
>  scripts/make_fit.py   | 291 ++
>  7 files changed, 334 insertions(+), 3 deletions(-)
>  create mode 100755 scripts/make_fit.py
>
> diff --git a/Documentation/process/changes.rst 
> b/Documentation/process/changes.rst
> index bb96ca0f774b..cad51bd5bd62 100644
> --- a/Documentation/process/changes.rst
> +++ b/Documentation/process/changes.rst
> @@ -62,6 +62,7 @@ Sphinx\ [#f1]_ 1.7  sphinx-build 
> --version
>  cpio   any  cpio --version
>  GNU tar1.28 tar --version
>  gtags (optional)   6.6.5gtags --version
> +mkimage (optional) 2017.01  mkimage --version
>  == ===  
> 
>
>  .. [#f1] Sphinx is needed only to build the Kernel documentation
> @@ -189,6 +190,14 @@ The kernel build requires GNU GLOBAL version 6.6.5 or 
> later to generate
>  tag files through ``make gtags``.  This is due to its use of the gtags
>  ``-C (--directory)`` flag.
>
> +mkimage
> +---
> +
> +This tool is used when building a Flat Image Tree (FIT), commonly used on ARM
> +platforms. The tool is available via the ``u-boot-tools`` package or can be
> +built from the U-Boot source code. See the instructions at
> +https://docs.u-boot.org/en/latest/build/tools.html#building-tools-for-linux
> +
>  System utilities
>  
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 14587be87a33..9f3eb476ece4 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -3037,6 +3037,13 @@ F:   drivers/mmc/host/sdhci-of-arasan.c
>  N: zynq
>  N: xilinx
>
> +ARM64 FIT SUPPORT
> +M: Simon Glass 
> +L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers)
> +S: Maintained
> +F: arch/arm64/boot/Makefile
> +F: scripts/make_fit.py
> +
>  ARM64 PORT (AARCH64 ARCHITECTURE)
>  M: Catalin Marinas 
>  M: Will 

Re: [PATCH v7 2/2] arm64: boot: Support Flat Image Tree

2023-11-30 Thread Masahiro Yamada
On Thu, Nov 30, 2023 at 2:22 AM Simon Glass  wrote:
>
> Add a script which produces a Flat Image Tree (FIT), a single file
> containing the built kernel and associated devicetree files.
> Compression defaults to gzip which gives a good balance of size and
> performance.
>
> The files compress from about 86MB to 24MB using this approach.
>
> The FIT can be used by bootloaders which support it, such as U-Boot
> and Linuxboot. It permits automatic selection of the correct
> devicetree, matching the compatible string of the running board with
> the closest compatible string in the FIT. There is no need for
> filenames or other workarounds.
>
> Add a 'make image.fit' build target for arm64, as well.
>
> The FIT can be examined using 'dumpimage -l'.
>
> This features requires pylibfdt (use 'pip install libfdt'). It also
> requires compression utilities for the algorithm being used. Supported
> compression options are the same as the Image.xxx files. For now there
> is no way to change the compression other than by editing the rule for
> $(obj)/image.fit
>
> While FIT supports a ramdisk / initrd, no attempt is made to support
> this here, since it must be built separately from the Linux build.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v7:
> - Add Image as a dependency of image.fit
> - Drop kbuild tag
> - Add dependency on dtbs
> - Drop unnecessary path separator for dtbs
> - Rebase to -next
>
> Changes in v5:
> - Drop patch previously applied
> - Correct compression rule which was broken in v4
>
> Changes in v4:
> - Use single quotes for UIMAGE_NAME
>
> Changes in v3:
> - Drop temporary file image.itk
> - Drop patch 'Use double quotes for image name'
> - Drop double quotes in use of UIMAGE_NAME
> - Drop unnecessary CONFIG_EFI_ZBOOT condition for help
> - Avoid hard-coding "arm64" for the DT architecture
>
> Changes in v2:
> - Drop patch previously applied
> - Add .gitignore file
> - Move fit rule to Makefile.lib using an intermediate file
> - Drop dependency on CONFIG_EFI_ZBOOT
> - Pick up .dtb files separately from the kernel
> - Correct pylint too-many-args warning for write_kernel()
> - Include the kernel image in the file count
> - Add a pointer to the FIT spec and mention of its wide industry usage
> - Mention the kernel version in the FIT description
>
>  MAINTAINERS|   7 +
>  arch/arm64/Makefile|   9 +-
>  arch/arm64/boot/.gitignore |   1 +
>  arch/arm64/boot/Makefile   |   6 +-
>  scripts/Makefile.lib   |  13 ++
>  scripts/make_fit.py| 289 +
>  6 files changed, 322 insertions(+), 3 deletions(-)
>  create mode 100755 scripts/make_fit.py
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 14587be87a33..d609f0e8deb3 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1585,6 +1585,13 @@ F:   Documentation/process/maintainer-soc*.rst
>  F: arch/arm/boot/dts/Makefile
>  F: arch/arm64/boot/dts/Makefile
>
> +ARM64 FIT SUPPORT
> +M: Simon Glass 
> +L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers)
> +S: Maintained
> +F: arch/arm64/boot/Makefile
> +F: scripts/make_fit.py
> +
>  ARM ARCHITECTED TIMER DRIVER
>  M: Mark Rutland 
>  M: Marc Zyngier 
> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> index 1bd4fae6e806..18e092de7cdb 100644
> --- a/arch/arm64/Makefile
> +++ b/arch/arm64/Makefile
> @@ -36,6 +36,8 @@ ifeq ($(CONFIG_BROKEN_GAS_INST),y)
>  $(warning Detected assembler with broken .inst; disassembly will be 
> unreliable)
>  endif
>
> +KBUILD_DTBS  := dtbs


Please remove this, and hard-code

 image.fit: dtbs



>
>  $(obj)/Image: vmlinux FORCE
> $(call if_changed,objcopy)
> @@ -39,6 +40,9 @@ $(obj)/Image.lzo: $(obj)/Image FORCE
>  $(obj)/Image.zst: $(obj)/Image FORCE
> $(call if_changed,zstd)
>
> +$(obj)/image.fit: $(obj)/Image FORCE
> +   $(call cmd,fit,gzip)


The gzip parameter is not used.
Please do

 $(call cmd,fit)





In the python script, functions are separated with two blank lines,
but there is only one blank line between parse_args() and setup_fit().


I do not mind either way because it does not contain any class,
but please keep consistency.







--
Best Regards
Masahiro Yamada


Re: [PATCH v7 2/2] arm64: boot: Support Flat Image Tree

2023-11-30 Thread Masahiro Yamada
On Thu, Nov 30, 2023 at 5:26 PM Nicolas Schier  wrote:
>
> Simon,
>
> thanks for the patch!  Below are some nitpicks and bike-shedding
> questions.
>
> On Wed 29 Nov 2023 10:21:53 GMT, Simon Glass wrote:
> > Add a script which produces a Flat Image Tree (FIT), a single file
> > containing the built kernel and associated devicetree files.
> > Compression defaults to gzip which gives a good balance of size and
> > performance.
> >
> > The files compress from about 86MB to 24MB using this approach.
> >
> > The FIT can be used by bootloaders which support it, such as U-Boot
> > and Linuxboot. It permits automatic selection of the correct
> > devicetree, matching the compatible string of the running board with
> > the closest compatible string in the FIT. There is no need for
> > filenames or other workarounds.
>
> Have you thought about updating the arch/mips ITB rules to also use the
> new scripts/make_fit.py?  Or is the FIT/ITB format for mips different
> from the one for arm64?



I recommend not touching MIPS at this moment
because this tool simply picks up *.dtb files
that exist under arch/*/boot/dts/, some of which
may be stale files.




Think of this scenario:


[1] Enable CONFIG_ARCH_FOO and build

   foo.dtb

will be created.


[2] Next, disable CONFIG_ARCH_FOO and
enable CONFIG_ARCH_BAR, and build.

   bar.dtb

will be created.


This script will pick up both foo.dtb and bar.dtb
although foo.dtb is a left-over from the previous build.



Without cleaning, stale *.dtb will accumulate
and unwanted files will be included in image.fit.



Currently, MIPS hard-codes its files.
It always works in a deterministic way.




I do not request Simon to implement everything perfectly
because I know that would require much more effort.

We could do something like modules.order to list out the
dtb files from the current build, but I am not asking for it
in this patchset.



But, you are right. This tool is not arm64-specific at all
(and that is the reason why I think the MAINTAINERS
entry is a little odd)
Perhaps it can be applicable to MIPS after everything
works correctly.







> >  ARM ARCHITECTED TIMER DRIVER
> >  M:   Mark Rutland 
> >  M:   Marc Zyngier 
> > diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> > index 1bd4fae6e806..18e092de7cdb 100644
> > --- a/arch/arm64/Makefile
> > +++ b/arch/arm64/Makefile
> > @@ -36,6 +36,8 @@ ifeq ($(CONFIG_BROKEN_GAS_INST),y)
> >  $(warning Detected assembler with broken .inst; disassembly will be 
> > unreliable)
> >  endif
> >
> > +KBUILD_DTBS  := dtbs
>
> Might you want to use tabs here as in the lines below?



This should not exist in the first place.


  image.fit: dtbs


is better.









--
Best Regards
Masahiro Yamada


Re: [PATCH v6 1/2] kbuild: arm64: Add BOOT_TARGETS variable

2023-11-21 Thread Masahiro Yamada
On Mon, Nov 20, 2023 at 12:02 AM Simon Glass  wrote:
>
> Add a new variable containing a list of possible targets. Mark them as
> phony. This matches the approach taken for arch/arm
>
> Signed-off-by: Simon Glass 



I encounter difficulty in understanding your subject prefix policy.


You used the "arm:" prefix for a patch irrelevant to arm:
https://lore.kernel.org/linux-kbuild/cak7lnaqn_qgyztwgdmqyfg+ez5p7rkm47mpgp0dqn_iuhvt...@mail.gmail.com/




And, the one for this patch.

"kbuild: arm64: Add BOOT_TARGETS variable"

Please do not add "kbuild:" for a patch
that modifies arch/arm64, and that was not even
submitted to kbuild ML.




> ---
>
> Changes in v6:
> - Drop the unwanted .gz suffix
>
>  arch/arm64/Makefile | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> index 4bd85cc0d32b..ae0c5ee8c78b 100644
> --- a/arch/arm64/Makefile
> +++ b/arch/arm64/Makefile
> @@ -150,6 +150,10 @@ libs-$(CONFIG_EFI_STUB) += 
> $(objtree)/drivers/firmware/efi/libstub/lib.a
>  # Default target when executing plain make
>  boot   := arch/arm64/boot
>
> +BOOT_TARGETS   := Image vmlinuz.efi
> +
> +PHONY += $(BOOT_TARGETS)
> +
>  ifeq ($(CONFIG_EFI_ZBOOT),)
>  KBUILD_IMAGE   := $(boot)/Image.gz
>  else
> @@ -159,7 +163,7 @@ endif
>  all:   $(notdir $(KBUILD_IMAGE))
>
>
> -Image vmlinuz.efi: vmlinux
> +$(BOOT_TARGETS): vmlinux
> $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
>
>  Image.%: Image
> --
> 2.43.0.rc0.421.g78406f8d94-goog
>


--
Best Regards
Masahiro Yamada


Re: [PATCH v6 2/2] arm64: boot: Support Flat Image Tree

2023-11-21 Thread Masahiro Yamada
> +data = inf.read()
> +fdt = libfdt.FdtRo(data)
> +model = fdt.getprop(0, 'model').as_str()
> +compat = fdt.getprop(0, 'compatible')
> +
> +fsw.property_string('description', model)
> +fsw.property_string('type', 'flat_dt')
> +fsw.property_string('arch', arch)
> +fsw.property_string('compression', compress)
> +fsw.property('compatible', bytes(compat))
> +
> +with open(fname, 'rb') as inf:
> +compressed = compress_data(inf, compress)
> +fsw.property('data', compressed)
> +return model, compat
> +
> +
> +def build_fit(args):
> +"""Build the FIT from the provided files and arguments
> +
> +Args:
> +args (Namespace): Program arguments
> +
> +Returns:
> +tuple:
> +bytes: FIT data
> +int: Number of configurations generated
> +size: Total uncompressed size of data
> +"""
> +fsw = libfdt.FdtSw()
> +setup_fit(fsw, args.name)
> +seq = 0
> +size = 0
> +entries = []
> +
> +# Handle the kernel
> +with open(args.kernel, 'rb') as inf:
> +comp_data = compress_data(inf, args.compress)
> +size += os.path.getsize(args.kernel)
> +write_kernel(fsw, comp_data, args)
> +
> +for path in args.srcdir:
> +# Handle devicetree files
> +if os.path.isdir(path):
> +for dirpath, _, fnames in os.walk(path):
> +for fname in fnames:
> +if os.path.splitext(fname)[1] != '.dtb':
> +continue
> +pathname = os.path.join(dirpath, fname)
> +seq += 1
> +size += os.path.getsize(pathname)
> +model, compat = output_dtb(fsw, seq, pathname,
> +   args.arch, args.compress)
> +entries.append([model, compat])
> +
> +finish_fit(fsw, entries)
> +
> +# Include the kernel itself in the returned file count
> +return fsw.as_fdt().as_bytearray(), seq + 1, size
> +
> +
> +def run_make_fit():
> +"""Run the tool's main logic"""
> +args = parse_args()
> +
> +out_data, count, size = build_fit(args)
> +with open(args.fit, 'wb') as outf:
> +outf.write(out_data)
> +
> +ext_fit_size = None
> +if args.external:
> +mkimage = os.environ.get('MKIMAGE', 'mkimage')
> +subprocess.check_call([mkimage, '-E', '-F', args.fit],
> +  stdout=subprocess.DEVNULL)
> +
> +with open(args.fit, 'rb') as inf:
> +data = inf.read()
> +ext_fit = libfdt.FdtRo(data)
> +ext_fit_size = ext_fit.totalsize()
> +
> +comp_size = len(out_data)
> +print(f'FIT size {comp_size:#x}/{comp_size / 1024 / 1024:.1f} MB', 
> end='')
> +if ext_fit_size:
> +print(f', header {ext_fit_size:#x}/{ext_fit_size / 1024:.1f} KB', 
> end='')
> +print(f', {count} files, uncompressed {size / 1024 / 1024:.1f} MB')
> +
> +
> +if __name__ == "__main__":
> +sys.exit(run_make_fit())
> --
> 2.43.0.rc0.421.g78406f8d94-goog
>


-- 
Best Regards
Masahiro Yamada


Re: [PATCH v5 2/3] arm: boot: Move the single quotes for image name

2023-11-16 Thread Masahiro Yamada
On Sat, Nov 11, 2023 at 9:29 AM Simon Glass  wrote:
>
> Add quotes where UIMAGE_NAME is used, rather than where it is defined.
> This allows the UIMAGE_NAME variable to be set by the user.
>
> Signed-off-by: Simon Glass 
> ---


I applied this to linux-kbuild/fixes.

I changed the subject to
"kbuild: Move the single quotes for image name"
because it is unrelated to arm.


Thanks.



> (no changes since v4)
>
> Changes in v4:
> - Add a patch to move the single quotes for image name
>
>  scripts/Makefile.lib | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 68d0134bdbf9..1a965fe68e01 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -487,14 +487,14 @@ UIMAGE_OPTS-y ?=
>  UIMAGE_TYPE ?= kernel
>  UIMAGE_LOADADDR ?= arch_must_set_this
>  UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR)
> -UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)'
> +UIMAGE_NAME ?= Linux-$(KERNELRELEASE)
>
>  quiet_cmd_uimage = UIMAGE  $@
>cmd_uimage = $(BASH) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \
> -C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \
> -T $(UIMAGE_TYPE) \
> -a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \
> -   -n $(UIMAGE_NAME) -d $< $@
> +   -n '$(UIMAGE_NAME)' -d $< $@
>
>  # XZ
>  # -------
> --
> 2.42.0.869.gea05f2083d-goog
>


--
Best Regards

Masahiro Yamada


Re: [PATCH v2 2/3] arm: boot: Use double quotes for image name

2023-11-07 Thread Masahiro Yamada
Hi Simon,


On Tue, Nov 7, 2023 at 3:11 PM Simon Glass  wrote:
>
> Hi Masahiro,
>
> On Tue, 7 Nov 2023 at 03:13, Masahiro Yamada  wrote:
> >
> > On Sat, Nov 4, 2023 at 9:42 PM Simon Glass  wrote:
> > >
> > > The use of single quotes in the image name causes them to appear in
> > > the image description when the uImage is created. Use double quotes, to
> > > avoid this.
> > >
> > > Signed-off-by: Simon Glass 
> > > ---
> > >
> > > Changes in v2:
> > > - Split double-quote change out into its own patch
> > >
> > >  scripts/Makefile.lib | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> > > index 68d0134bdbf9..03e79e319293 100644
> > > --- a/scripts/Makefile.lib
> > > +++ b/scripts/Makefile.lib
> > > @@ -487,7 +487,7 @@ UIMAGE_OPTS-y ?=
> > >  UIMAGE_TYPE ?= kernel
> > >  UIMAGE_LOADADDR ?= arch_must_set_this
> > >  UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR)
> > > -UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)'
> > > +UIMAGE_NAME ?= "Linux-$(KERNELRELEASE)"
> > >
> > >  quiet_cmd_uimage = UIMAGE  $@
> > >cmd_uimage = $(BASH) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \
> > > --
> > > 2.42.0.869.gea05f2083d-goog
> > >
> >
> >
> > NACK.
> >
> >
> > This is because you are doing *WRONG* in 3/3.
> >
> > Look at your code closely.
> >
> > https://lore.kernel.org/linux-kbuild/20231104194207.3370542-4-...@chromium.org/T/#me2fb68151d6f4f330808406f9a711fffee149529
> >
> >
> >
> > In the mainline kernel, the quotation appears
> > only in the definition of UIMAGE_NAME.
> >
> >
> > masahiro@zoe:~/ref/linux(master)$ git grep UIMAGE_NAME
> > scripts/Makefile.lib:UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)'
> > scripts/Makefile.lib:   -n $(UIMAGE_NAME) -d $< $@
> >
> >
> > The single quotes are consumed by shell.
> >
> >
> >
> >
> >
> >
> > This is mainline + your patch set.
> >
> > masahiro@zoe:~/ref/linux(simon-v2)$ git grep UIMAGE_NAME
> > scripts/Makefile.lib:UIMAGE_NAME ?= "Linux-$(KERNELRELEASE)"
> > scripts/Makefile.lib:   -n "$(UIMAGE_NAME)" -d $< $@
> > scripts/Makefile.lib:   --name "$(UIMAGE_NAME)" \
> >
> >
> > You quoted the definition of UIMAGE_NAME,
> > and also variable references.
> >
> >
> >
> >
> > See how it is expanded.
> >
> >
> > --name "$(UIMAGE_NAME)"
> >
> >
> >  ==>
> >
> >
> > --name ""Linux-$(KERNELRELEASE)""
> >
> >
> >  ==>
> >
> >
> > --name Linux-$(KERNELRELEASE)
> >
> >
> >
> >
> > You added double quotes in a row, just to cancel it.
>
> Yes, I understand that. But without the quotes in -n "$(UIMAGE_NAME)"
> then the name cannot contain spaces. So we do need some sort of
> quoting, right?


Yes.

If you move the quoting to the variable reference,
it is acceptable because there is a good reason to do so.



UIMAGE_NAME ?= Linux-$(KERNELRELEASE)


...
 -n '$(UIMAGE_NAME)' -d $< $@


This is the correct change.



>
> It just seems strange to use single quotes in a Makefile variable. I
> found it confusing.


Right. Why don't you remove it, then?


For clarification, there is no concept of quoting in GNU Make.

The single quote character ' and the double quote character " are
just normal characters for Make.

GNU Make handles them just like alphabets and numbers.

GNU Make just replaces $(UIMAGE_NAME)
with 'Linux-$(KERNELRELEASE)' verbatim.


It is the _shell_ that understands the quoting.

Just in case here is the spec for
"2.2.2 Single-Quotes" vs "2.2.3 Double-Quotes"

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html


Shell supports both single-quoting and double-quoting
for good reasons.

There is no good or bad because both of them are meaningful.






>
> I think you are saying you want to keep the single quotes in the var
> declaration and drop the quotes from the cmd_fit rule. I am OK with
> that, but I do think it is unusual not to quote something which might
> have spaces. It may cause confusion for others, as it did for me?
>
> Anyway, I'll send a new version with the quoting reverted.
>


Please move the single quotes as I suggested above.

The reason is because UIMAGE_NAME can be passed-in
by a user and it can contain whitespaces.





> Regards,
> Simon



-- 
Best Regards
Masahiro Yamada


Re: [PATCH v2 3/3] arm64: boot: Support Flat Image Tree

2023-11-07 Thread Masahiro Yamada
On Sat, Nov 4, 2023 at 9:42 PM Simon Glass  wrote:
>  PHONY += $(BOOT_TARGETS)
>
> @@ -215,6 +215,7 @@ virtconfig:
>  define archhelp
>echo  '* Image.gz  - Compressed kernel image 
> (arch/$(ARCH)/boot/Image.gz)'
>echo  '  Image - Uncompressed kernel image 
> (arch/$(ARCH)/boot/Image)'
> +$(if $(CONFIG_EFI_ZBOOT),,echo  '  image.fit - Flat Image Tree 
> (arch/$(ARCH)/boot/image.fit)')



Why should this be hidden when CONFIG_EFI_ZBOOT=y?




>echo  '  install   - Install uncompressed kernel'
>echo  '  zinstall  - Install compressed kernel'
>echo  '  Install using (your) ~/bin/installkernel or'
> diff --git a/arch/arm64/boot/.gitignore b/arch/arm64/boot/.gitignore
> index af5dc61f8b43..f84a7073dbcd 100644
> --- a/arch/arm64/boot/.gitignore
> +++ b/arch/arm64/boot/.gitignore
> @@ -2,3 +2,5 @@
>  Image
>  Image.gz
>  vmlinuz*
> +image.itk
> +image.fit
> diff --git a/arch/arm64/boot/Makefile b/arch/arm64/boot/Makefile
> index 1761f5972443..2681f54cd2c8 100644
> --- a/arch/arm64/boot/Makefile
> +++ b/arch/arm64/boot/Makefile
> @@ -16,7 +16,8 @@
>
>  OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S
>
> -targets := Image Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo Image.zst
> +targets := Image Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo \
> +   Image.zst image.fit
>
>  $(obj)/Image: vmlinux FORCE
> $(call if_changed,objcopy)
> @@ -39,6 +40,10 @@ $(obj)/Image.lzo: $(obj)/Image FORCE
>  $(obj)/Image.zst: $(obj)/Image FORCE
> $(call if_changed,zstd)
>
> +# Provide the kernel for the FIT
> +$(obj)/image.itk: $(obj)/Image FORCE
> +   $(call if_changed,copy)
> +
>  EFI_ZBOOT_PAYLOAD  := Image
>  EFI_ZBOOT_BFD_TARGET   := elf64-littleaarch64
>  EFI_ZBOOT_MACH_TYPE:= ARM64
> @@ -48,3 +53,5 @@ EFI_ZBOOT_OBJCOPY_FLAGS   = --add-symbol 
> zboot_code_size=0x$(shell \
> $(NM) vmlinux|grep _kernel_codesize|cut -d' ' 
> -f1)
>
>  include $(srctree)/drivers/firmware/efi/libstub/Makefile.zboot
> +
> +clean-files := image.itk
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 03e79e319293..1427dba4f0f9 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -494,7 +494,23 @@ quiet_cmd_uimage = UIMAGE  $@
> -C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \
> -T $(UIMAGE_TYPE) \
> -a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \
> -   -n $(UIMAGE_NAME) -d $< $@
> +   -n "$(UIMAGE_NAME)" -d $< $@


Please do not do this.
Just drop 2/3.




> +
> +# Flat Image Tree (FIT)
> +# This allows for packaging of a kernel and all devicetrees files, using
> +# compression.
> +# ---
> +
> +MAKE_FIT := $(srctree)/scripts/make_fit.py
> +
> +quiet_cmd_fit = FIT $@
> +  cmd_fit = $(MAKE_FIT) -f $@ --arch $(UIMAGE_ARCH) --os linux \
> +   --name "$(UIMAGE_NAME)" \
> +   --compress $(UIMAGE_COMPRESSION) -k $< \
> +   $(dir $<)/dts
> +
> +$(obj)/%.fit: $(obj)/%.itk $(MAKE_FIT) FORCE
> +   $(call if_changed,fit,gzip)


No. This is worse than v1.

Please do not create a silly copy.





As I said in v1, this if_changed does not catch the DTS updates.
So, there is no point in using it.

I recommend just use 'cmd'.


$(obj)/image.fit: $(obj)/Image FORCE
$(call cmd,fit)





> +
> +Returns:
> +tuple:
> +str: Model name
> +bytes: Compatible stringlist
> +"""
> +with fsw.add_node(f'fdt-{seq}'):
> +# Get the compatible / model information
> +with open(fname, 'rb') as inf:
> +data = inf.read()
> +fdt = libfdt.FdtRo(data)
> +model = fdt.getprop(0, 'model').as_str()
> +compat = fdt.getprop(0, 'compatible')
> +
> +fsw.property_string('description', model)
> +fsw.property_string('type', 'flat_dt')
> +fsw.property_string('arch', 'arm64')


Why hard-code 'arm64' ?





-- 
Best Regards
Masahiro Yamada


Re: [PATCH v2 2/3] arm: boot: Use double quotes for image name

2023-11-07 Thread Masahiro Yamada
On Sat, Nov 4, 2023 at 9:42 PM Simon Glass  wrote:
>
> The use of single quotes in the image name causes them to appear in
> the image description when the uImage is created. Use double quotes, to
> avoid this.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v2:
> - Split double-quote change out into its own patch
>
>  scripts/Makefile.lib | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 68d0134bdbf9..03e79e319293 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -487,7 +487,7 @@ UIMAGE_OPTS-y ?=
>  UIMAGE_TYPE ?= kernel
>  UIMAGE_LOADADDR ?= arch_must_set_this
>  UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR)
> -UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)'
> +UIMAGE_NAME ?= "Linux-$(KERNELRELEASE)"
>
>  quiet_cmd_uimage = UIMAGE  $@
>cmd_uimage = $(BASH) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \
> --
> 2.42.0.869.gea05f2083d-goog
>


NACK.


This is because you are doing *WRONG* in 3/3.

Look at your code closely.

https://lore.kernel.org/linux-kbuild/20231104194207.3370542-4-...@chromium.org/T/#me2fb68151d6f4f330808406f9a711fffee149529



In the mainline kernel, the quotation appears
only in the definition of UIMAGE_NAME.


masahiro@zoe:~/ref/linux(master)$ git grep UIMAGE_NAME
scripts/Makefile.lib:UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)'
scripts/Makefile.lib:   -n $(UIMAGE_NAME) -d $< $@


The single quotes are consumed by shell.






This is mainline + your patch set.

masahiro@zoe:~/ref/linux(simon-v2)$ git grep UIMAGE_NAME
scripts/Makefile.lib:UIMAGE_NAME ?= "Linux-$(KERNELRELEASE)"
scripts/Makefile.lib:   -n "$(UIMAGE_NAME)" -d $< $@
scripts/Makefile.lib:   --name "$(UIMAGE_NAME)" \


You quoted the definition of UIMAGE_NAME,
and also variable references.




See how it is expanded.


--name "$(UIMAGE_NAME)"


 ==>


--name ""Linux-$(KERNELRELEASE)""


 ==>


--name Linux-$(KERNELRELEASE)




You added double quotes in a row, just to cancel it.



-- 
Best Regards
Masahiro Yamada


Re: [PATCH 3/3] arm64: boot: Support Flat Image Tree

2023-10-31 Thread Masahiro Yamada
On Tue, Oct 31, 2023 at 1:12 AM Tom Rini  wrote:
>
> On Mon, Oct 30, 2023 at 03:35:34PM +, Russell King (Oracle) wrote:
> > On Sun, Oct 29, 2023 at 05:46:12AM +1300, Simon Glass wrote:
> > > Hi Masahiro,
> > >
> > > Sure, but that is a separate issue, isn't it? We already support
> > > various boot targets in arm64 but not one that includes the DTs, so
> > > far as I can see. The old arm 'uImage' target is pretty out-of-date
> > > now.
> >
> > Does that mean it can be removed? ;)
> >
> > I've NAK'd FIT support on 32-bit Arm in the past, and I remain of the
> > opinion that boot loader specific packaging of the kernel should not
> > be in the kernel but should be external to it - even more so given the
> > multi-platform nature of 32-bit Arm kernels.
>
> I'll point it out here rather than Simon. As part of
> https://github.com/open-source-firmware FIT is a standard and not "boot
> loader specific". And one of the points of a FIT image is that you can
> easily support multi-platform kernels in a single file (without
> optimizing things further, at a cost in tens of milliseconds on a Pi 3
> anyhow) and with user-controlled security.
>
> --
> Tom



It is a copy of the document in U-Boot.

The file was split into two, but the content is the same.


[original in U-Boot]
https://github.com/u-boot/u-boot/blob/v2023.10/doc/usage/fit/source_file_format.rst


[flat-image-tree]
https://github.com/open-source-firmware/flat-image-tree/blob/v0.8/source/chapter1-introduction.rst
https://github.com/open-source-firmware/flat-image-tree/blob/v0.8/source/chapter2-source-file-format.rst





--
Best Regards
Masahiro Yamada


Re: [PATCH 1/3] kbuild: Correct missing architecture-specific hyphens

2023-10-28 Thread Masahiro Yamada
On Thu, Oct 26, 2023 at 4:27 PM Simon Glass  wrote:
>
> These should add a hyphen to indicate that it makes a adjective. Fix
> them.
>
> Signed-off-by: Simon Glass 
> ---


This is trivial.
Applied to linux-kbuild. Thanks.


git grep -i 'arch specific'

 or

git grep -i 'architecture specific'

finds similar patterns, but presumably we are not
keen on fixing them tree-wide.





-- 
Best Regards
Masahiro Yamada


Re: [PATCH 3/3] arm64: boot: Support Flat Image Tree

2023-10-26 Thread Masahiro Yamada
On Thu, Oct 26, 2023 at 4:28 PM Simon Glass  wrote:
>
> Add a script which produces a Flat Image Tree (FIT), a single file
> containing the built kernel and associated devicetree files.
> Compression defaults to gzip which gives a good balance of size and
> performance.
>
> The files compress from about 85MB to 24MB using this approach.
>
> The FIT can be used by bootloaders which support it, such as U-Boot
> and Linuxboot. It permits automatic selection of the correct
> devicetree, matching the compatible string of the running board with
> the closest compatible string in the FIT. There is no need for
> filenames or other workarounds.
>
> Add a 'make image.fit' build target for arm64, as well.
>
> The FIT can be examined using 'dumpimage -l'.
>
> This features requires pylibfdt (use 'pip install libfdt'). It also
> requires compression utilities for the algorithm being used. Supported
> compression options are the same as the Image.xxx files. For now there
> is no way to change the compression other than by editing the rule for
> $(obj)/image.fit
>
> While FIT supports a ramdisk / initrd, no attempt is made to support
> this here, since it must be built separately from the Linux build.


Is this useful?
For arm64, initrd is likely used.

FIT should be created in unbrellea projects
such as OpenEmbedded,  Buildroot, etc.




> Signed-off-by: Simon Glass 
> ---
>
>  MAINTAINERS  |   7 +
>  arch/arm64/Makefile  |   3 +-
>  arch/arm64/boot/Makefile |   8 +-
>  scripts/Makefile.lib |  16 ++-
>  scripts/make_fit.py  | 285 +++
>  5 files changed, 315 insertions(+), 4 deletions(-)
>  create mode 100755 scripts/make_fit.py
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 2d13bbd69adb..d6955ebc3c24 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1575,6 +1575,13 @@ F:   Documentation/process/maintainer-soc*.rst
>  F: arch/arm/boot/dts/Makefile
>  F: arch/arm64/boot/dts/Makefile
>
> +ARM64 FIT SUPPORT
> +M: Simon Glass 
> +L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers)
> +S: Maintained
> +F: arch/arm64/boot/Makefile
> +F: scripts/make_fit.py
> +
>  ARM ARCHITECTED TIMER DRIVER
>  M: Mark Rutland 
>  M: Marc Zyngier 
> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> index 7b77b63e978f..d8290dcab6b6 100644
> --- a/arch/arm64/Makefile
> +++ b/arch/arm64/Makefile
> @@ -150,7 +150,7 @@ libs-$(CONFIG_EFI_STUB) += 
> $(objtree)/drivers/firmware/efi/libstub/lib.a
>  # Default target when executing plain make
>  boot   := arch/arm64/boot
>
> -BOOT_TARGETS   := Image.gz vmlinuz.efi
> +BOOT_TARGETS   := Image.gz vmlinuz.efi image.fit
>
>  PHONY += $(BOOT_TARGETS)
>
> @@ -215,6 +215,7 @@ virtconfig:
>  define archhelp
>echo  '* Image.gz  - Compressed kernel image 
> (arch/$(ARCH)/boot/Image.gz)'
>echo  '  Image - Uncompressed kernel image 
> (arch/$(ARCH)/boot/Image)'
> +$(if $(CONFIG_EFI_ZBOOT),,echo  '  image.fit - Flat Image Tree 
> (arch/$(ARCH)/boot/image.fit)')
>echo  '  install   - Install uncompressed kernel'
>echo  '  zinstall  - Install compressed kernel'
>echo  '  Install using (your) ~/bin/installkernel or'
> diff --git a/arch/arm64/boot/Makefile b/arch/arm64/boot/Makefile
> index 1761f5972443..a6e5b20b22bd 100644
> --- a/arch/arm64/boot/Makefile
> +++ b/arch/arm64/boot/Makefile
> @@ -16,7 +16,8 @@
>
>  OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S
>
> -targets := Image Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo Image.zst
> +targets := Image Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo \
> +   Image.zst image.fit
>
>  $(obj)/Image: vmlinux FORCE
> $(call if_changed,objcopy)
> @@ -39,6 +40,11 @@ $(obj)/Image.lzo: $(obj)/Image FORCE
>  $(obj)/Image.zst: $(obj)/Image FORCE
> $(call if_changed,zstd)
>
> +ifndef CONFIG_EFI_ZBOOT
> +$(obj)/image.fit: $(obj)/Image $(obj)/dts FORCE



This is wrong.

$(obj)/dts is a directory.

There is no point for comparing timestamps
between $(obj)/image.fit and $(obj)/dts.

Updates of *.dtb do not result in the
update of the $(obj)/dts timestamp.


if_changed never works correctly.








> +   $(call if_changed,fit,gzip)
> +endif
> +
>  EFI_ZBOOT_PAYLOAD  := Image
>  EFI_ZBOOT_BFD_TARGET   := elf64-littleaarch64
>  EFI_ZBOOT_MACH_TYPE:= ARM64
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 68d0134bdbf9..4e4364ad641a 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -487,14 +487,26 @@ UIMAGE_OPTS-y ?=
>  UIMAGE_TYPE ?= kernel
>  UIMAGE_LOADADDR ?= arch_must_set_this
>  UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR)
> -UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)'
> +UIMAGE_NAME ?= "Linux-$(KERNELRELEASE)"


Unneeded noise change.







--
Best Regards

Masahiro Yamada


Re: Question about boot failure of AM64-SK

2023-09-26 Thread Masahiro Yamada
On Mon, Sep 25, 2023 at 1:24 PM Vignesh Raghavendra  wrote:
>
> Hi Masahiro,
>
> On 21/09/23 20:33, Masahiro Yamada wrote:
> > Hi.
> [...]
>
> > spl: mmc boot mode: fs
> > Found FIT
> > Error reading cluster
> > fit read sector 0, sectors=985528, dst=, count=18446744073709551615,
> > size=0xf09b8
> > SPL: failed to boot from all boot devices
> > ### ERROR ### Please RESET the board ###
> >
>
> Looks like SD card incompatibility to me. Could you try couple of things:
>
> a) Different brand SD card

Hi Vignesh.

I tried Transcend and Lexar,
but both failed in the same way.


> b) Degrade speeds to non UHS mode:


I added no-1-8-v, but no luck either.




BTW, due to project shifting within my company,
this board is no longer a priority for me.

I will put AM64-SK on my shelf.  :)





-- 
Best Regards
Masahiro Yamada


Re: Question about boot failure of AM64-SK

2023-09-26 Thread Masahiro Yamada
On Mon, Sep 25, 2023 at 1:28 PM Vignesh Raghavendra  wrote:
>
> Hi,
>
> On 21/09/23 21:52, Masahiro Yamada wrote:
> > On Fri, Sep 22, 2023 at 12:03 AM Masahiro Yamada  
> > wrote:
> >>
> >> Hi.
> >>
> >> I am seeing a boot failure on AM64-SK.
> >>
> >>
> >> I got the following error in SPL of the main core.
> >> Do you have any clue?
> >
> >
> >
> > As a side-topic, I downloaded a prebuilt image
> > from https://www.ti.com/tool/SK-AM64
> >
> > It failed too (but in a different way).
> >
> > I flashed tisdk-debian-bookworm-am64xx-evm.wic
> > to a SD card by using the 'dd' command, then I got this:
> >
>
>
> Prebuilt images are targeted for High Secure (HS FS) devices. Looks like
> the board has a non HS Silicon (GP). Please overwrite the tiboot3.bin in
> boot partition with that of GP
>
> cp tiboot3-am64x-gp-evm.bin tiboot3.bin

Yeah, it made progress.

But, it failed in the same way as the latest U-Boot.






U-Boot SPL 2023.04 (Jul 14 2023 - 08:10:06 +)
EEPROM not available at 0x50, trying to read at 0x51
Resetting on cold boot to workaround ErrataID:i2331
Please resend tiboot3.bin in case of UART/DFU boot
resetting ...

U-Boot SPL 2023.04 (Jul 14 2023 - 08:10:06 +)
EEPROM not available at 0x50, trying to read at 0x51
SYSFW ABI: 3.1 (firmware rev 0x0009 '9.0.5--v09.00.05 (Kool Koala)')
SPL initial stack usage: 13376 bytes
Trying to boot from MMC2
Warning: Detected image signing certificate on GP device. Skipping
certificate to prevent boot failure. This will fail if the image was
also encrypted
Warning: Detected image signing certificate on GP device. Skipping
certificate to prevent boot failure. This will fail if the image was
also encrypted
Warning: Detected image signing certificate on GP device. Skipping
certificate to prevent boot failure. This will fail if the image was
also encrypted
Warning: Detected image signing certificate on GP device. Skipping
certificate to prevent boot failure. This will fail if the image was
also encrypted
Loading Environment from MMC... MMC Device 0 not found
*** Warning - No MMC card found, using default environment

Starting ATF on ARM64 core...

NOTICE:  BL31: v2.8(release):v2.8-226-g2fcd408bb
NOTICE:  BL31: Built : 08:09:13, Jul 14 2023
I/TC:
I/TC: OP-TEE version: 3.20.0 (gcc version 11.3.1 20220712 (Arm GNU
Toolchain 11.3.Rel1)) #1 Fri Jul 14 08:09:59 UTC 2023 aarch64
I/TC: WARNING: This OP-TEE configuration might be insecure!
I/TC: WARNING: Please check
https://optee.readthedocs.io/en/latest/architecture/porting_guidelines.html
I/TC: Primary CPU initializing
I/TC: SYSFW ABI: 3.1 (firmware rev 0x0009 '9.0.5--v09.00.05 (Kool Koala)')
I/TC: HUK Initialized
I/TC: Activated SA2UL device
I/TC: Fixing SA2UL firewall owner for GP device
I/TC: Enabled firewalls for SA2UL TRNG device
I/TC: SA2UL TRNG initialized
I/TC: SA2UL Drivers initialized
I/TC: Primary CPU switching to normal world boot

U-Boot SPL 2023.04 (Jul 14 2023 - 08:11:18 +)
SYSFW ABI: 3.1 (firmware rev 0x0009 '9.0.5--v09.00.05 (Kool Koala)')
Trying to boot from MMC2
Error reading cluster
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###








-- 
Best Regards
Masahiro Yamada


Re: [Question] TI's u-boot.img is built twice

2023-09-22 Thread Masahiro Yamada
On Fri, Sep 22, 2023 at 5:04 PM Neha Malcom Francis  wrote:
>
> Hi Masahiro
>
> On 22/09/23 12:48, Masahiro Yamada wrote:
> > On Fri, Sep 22, 2023 at 2:27 PM Neha Malcom Francis  
> > wrote:
> >>
> >> Hi Masahiro
> >>
> >> On 21/09/23 21:06, Masahiro Yamada wrote:
> >>> Hi.
> >>>
> >>> Since the TI platform migrated to binman,
> >>> u-boot.img is built twice.
> >>>
> >>> It is created by "mkimage -E",
> >>> then overwritten by binman.
> >>>
> >>>
> >>> So, the data are embedded in the FIT structure
> >>> instead of being appended.
> >>>
> >>> Is this intentional?
> >>>
> >>> To me, it looks weird.
> >>>
> >>>
> >>
> >> I haven't added the fit,external-offset property in the binman.dtsi so it 
> >> was
> >> not appended as external data and I did not find reason to. Is there any 
> >> benefit
> >> in having the data appended than embedded?
> >
> >
> >
> > Placing payload data outside the FIT structure is a U-Boot hack.
> >
> >
> > The motivation was explained in the commit log of
> > 722ebc8f84d5bccd2e70fad1079a0dd40cceddec
> >
> >
>
> Thanks for this! Makes sense, I think we should make it appended again in
> binman. Can reduce boot time.
> >
> > Before TI migrated to binman,
> > u-boot.img was the "payload outside" structure
> > but it is not any more.
> >
> > I do not mind the implementation details as long as
> > U-Boot is able to boot the Linux kernel.
> >
> >
> > I was just suffering from the AM64-SK boot failure
> > (as I asked in another thread) and just noticed
> > something odd when I was poking the SPL code.
> >
> >
> > At least, .u-boot.img.cmd is not telling the truth.
> >
> > Usually, the build command is saved in a *.cmd file
> > but this does not reflect the reality, because
> > it is binman that created the final u-boot.img
> >
> >
> > $ cat .u-boot.img.cmd
> > cmd_u-boot.img := ./tools/mkimage -f auto -A arm -T firmware -C none
> > -O u-boot -a 0x8080 -e 0x8080 -p 0x0 -n "U-Boot
> > 2023.10-rc4-00047-gb9b83a86f0-dirty for am64x board" -E  -b
> > arch/arm/dts/k3-am642-evm.dtb -b arch/arm/dts/k3-am642-sk.dtb  -d
> > u-boot-nodtb.bin u-boot.img >/dev/null
> >
> >
> > I will not track it down any further, though.
> > It is too complicated.
> >
> >
> >
>
> I am not too sure about the .cmd files but looks like its misleading probably
> because the replacing of the binman generated image takes under cmd_binman and
> not directly from the Makefile (just a guess).



>From my view as a user, building images without k3-image-gen
seems like a benefit, but binman is not mandatory for u-boot.img.

With line 255-339 of arch/arm/dts/k3-am64x-binman.dtsi deleted,
u-boot.img was still generated in the same structure as before.
(payload appended)


The confusion came from u-boot.img being first created by
line 1439 of the top Makefile  (mkimage),
then overwritten by line 1113 (binman).

If you use binman for u-boot.img, the line 1439 does not need to run,
but it runs because u-boot.img is added to INPUTS-y.


Perhaps, you may want to hack line 978 because
IMX is doing something there.


ifeq ($(CONFIG_MX7)$(CONFIG_IMX_HAB), yy)
INPUTS-$(CONFIG_SPL_FRAMEWORK) += u-boot-ivt.img
else
INPUTS-$(CONFIG_SPL_FRAMEWORK) += u-boot.img
endif





For the *.cmd files, the mkimage command is
saved in .u-boot.img.cmd and the binman command
is saved in ..binman_stamp.cmd




$ cat  .u-boot.img.cmd
cmd_u-boot.img := ./tools/mkimage -f auto -A arm -T firmware -C none
-O u-boot -a 0x8080 -e 0x8080 -p 0x0 -n "U-Boot
2023.10-rc4-00047-gb9b83a86f0-dirty for am64x board" -E  -b
arch/arm/dts/k3-am642-evm.dtb -b arch/arm/dts/k3-am642-sk.dtb  -d
u-boot-nodtb.bin u-boot.img >/dev/null

$ cat ..binman_stamp.cmd
cmd_.binman_stamp := ./tools/binman/binman   --toolpath ./tools  build
-u -d u-boot.dtb -O . -m --allow-missing  -I . -I . -I
./board/ti/am64x -I arch/arm/dts -a of-list="k3-am642-evm k3-am642-sk"
-I /home/masahiro/ref/ti-linux-firmware -a
atf-bl31-path=/home/masahiro/ref/trusted-firmware-a/build/k3/lite/release/bl31.bin
-a 
tee-os-path=/home/masahiro/ref/OP-TEE/optee_os/out/arm-plat-k3/core/tee-raw.bin
-a opensbi-path= -a default-dt="k3-am642-evm" -a scp-path= -a
rockchip-tpl-path= -a spl-bss-pad= -a tpl-bss-pad=1 -a spl-dtb=y -a
tpl-dtb= -a pre-load-key-path=






--
Best Regards
Masahiro Yamada


Re: [Question] TI's u-boot.img is built twice

2023-09-22 Thread Masahiro Yamada
On Fri, Sep 22, 2023 at 2:27 PM Neha Malcom Francis  wrote:
>
> Hi Masahiro
>
> On 21/09/23 21:06, Masahiro Yamada wrote:
> > Hi.
> >
> > Since the TI platform migrated to binman,
> > u-boot.img is built twice.
> >
> > It is created by "mkimage -E",
> > then overwritten by binman.
> >
> >
> > So, the data are embedded in the FIT structure
> > instead of being appended.
> >
> > Is this intentional?
> >
> > To me, it looks weird.
> >
> >
>
> I haven't added the fit,external-offset property in the binman.dtsi so it was
> not appended as external data and I did not find reason to. Is there any 
> benefit
> in having the data appended than embedded?



Placing payload data outside the FIT structure is a U-Boot hack.


The motivation was explained in the commit log of
722ebc8f84d5bccd2e70fad1079a0dd40cceddec



Before TI migrated to binman,
u-boot.img was the "payload outside" structure
but it is not any more.

I do not mind the implementation details as long as
U-Boot is able to boot the Linux kernel.


I was just suffering from the AM64-SK boot failure
(as I asked in another thread) and just noticed
something odd when I was poking the SPL code.


At least, .u-boot.img.cmd is not telling the truth.

Usually, the build command is saved in a *.cmd file
but this does not reflect the reality, because
it is binman that created the final u-boot.img


$ cat .u-boot.img.cmd
cmd_u-boot.img := ./tools/mkimage -f auto -A arm -T firmware -C none
-O u-boot -a 0x8080 -e 0x8080 -p 0x0 -n "U-Boot
2023.10-rc4-00047-gb9b83a86f0-dirty for am64x board" -E  -b
arch/arm/dts/k3-am642-evm.dtb -b arch/arm/dts/k3-am642-sk.dtb  -d
u-boot-nodtb.bin u-boot.img >/dev/null


I will not track it down any further, though.
It is too complicated.






> >
> >
> > To confirm it, apply the following hack.
> >
> > Since u-boot.img is overwritten by binman,
> > copy it to u-boot.img.backup.
> >
> >
> >
> >
> > diff --git a/Makefile b/Makefile
> > index 87f9fc786e..4cffa8a061 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1112,6 +1112,7 @@ endef
> >   # Timestamp file to make sure that binman always runs
> >   .binman_stamp: $(INPUTS-y) FORCE
> >   ifeq ($(CONFIG_BINMAN),y)
> > +   cp u-boot.img u-boot.img.backup
> >  $(call if_changed,binman)
> >   endif
> >  @touch $@
> >
> >
> >
> > Then, build it for the main core.
> >
> >
> > make -j$(nproc) CROSS_COMPILE=aarch64-linux-gnu-
> > am64x_evm_a53_defconfig all
> > TEE=~/ref/OP-TEE/optee_os/out/arm-plat-k3/core/tee-raw.bin
> > BL31=~/ref/trusted-firmware-a/build/k3/lite/release/bl31.bin
> > BINMAN_INDIRS=~/ref/ti-linux-firmware
> >
> >
> >
> >
> > Compare the two files.
> > Run fdtdump to see what happened to them.
> >
> >
> > $ diff -u u-boot.img  u-boot.img.backup
> > Binary files u-boot.img and u-boot.img.backup differ
> >
> >
> > $ fdtdump u-boot.img
> >  => u-boot and dt are embedded.
> >
> > $ fdtdump u-boot.img.backup
> >  => u-boot and dt are appended after the
> > FIT structure
> >
> >
> >
>
> --
> Thanking You
> Neha Malcom Francis



-- 
Best Regards
Masahiro Yamada


Re: Question about boot failure of AM64-SK

2023-09-21 Thread Masahiro Yamada
On Fri, Sep 22, 2023 at 12:03 AM Masahiro Yamada  wrote:
>
> Hi.
>
> I am seeing a boot failure on AM64-SK.
>
>
> I got the following error in SPL of the main core.
> Do you have any clue?



As a side-topic, I downloaded a prebuilt image
from https://www.ti.com/tool/SK-AM64

It failed too (but in a different way).

I flashed tisdk-debian-bookworm-am64xx-evm.wic
to a SD card by using the 'dd' command, then I got this:



U-Boot SPL 2023.04 (Jul 14 2023 - 08:10:06 +)
EEPROM not available at 0x50, trying to read at 0x51
k3_system_controller sysctrler: k3_sysctrler_start: Boot Notification
response failed. ret = -110
Firmware init failed on rproc (-110)

resetting ...
ti_sci system-controller@44043000: ti_sci_get_response: Message
receive failed. ret = -110
ti_sci system-controller@44043000: ti_sci_get_response: Message
receive failed. ret = -110
ti_sci system-controller@44043000: ti_sci_get_response: Message
receive failed. ret = -110
no sysreset
### ERROR ### Please RESET the board ###




Am I doing something wrong?






-- 
Best Regards
Masahiro Yamada


[Question] TI's u-boot.img is built twice

2023-09-21 Thread Masahiro Yamada
Hi.

Since the TI platform migrated to binman,
u-boot.img is built twice.

It is created by "mkimage -E",
then overwritten by binman.


So, the data are embedded in the FIT structure
instead of being appended.

Is this intentional?

To me, it looks weird.




To confirm it, apply the following hack.

Since u-boot.img is overwritten by binman,
copy it to u-boot.img.backup.




diff --git a/Makefile b/Makefile
index 87f9fc786e..4cffa8a061 100644
--- a/Makefile
+++ b/Makefile
@@ -1112,6 +1112,7 @@ endef
 # Timestamp file to make sure that binman always runs
 .binman_stamp: $(INPUTS-y) FORCE
 ifeq ($(CONFIG_BINMAN),y)
+   cp u-boot.img u-boot.img.backup
$(call if_changed,binman)
 endif
@touch $@



Then, build it for the main core.


make -j$(nproc) CROSS_COMPILE=aarch64-linux-gnu-
   am64x_evm_a53_defconfig all
   TEE=~/ref/OP-TEE/optee_os/out/arm-plat-k3/core/tee-raw.bin
   BL31=~/ref/trusted-firmware-a/build/k3/lite/release/bl31.bin
   BINMAN_INDIRS=~/ref/ti-linux-firmware




Compare the two files.
Run fdtdump to see what happened to them.


$ diff -u u-boot.img  u-boot.img.backup
Binary files u-boot.img and u-boot.img.backup differ


$ fdtdump u-boot.img
=> u-boot and dt are embedded.

$ fdtdump u-boot.img.backup
=> u-boot and dt are appended after the
   FIT structure



-- 
Best Regards
Masahiro Yamada


Question about boot failure of AM64-SK

2023-09-21 Thread Masahiro Yamada
Hi.

I am seeing a boot failure on AM64-SK.


I got the following error in SPL of the main core.
Do you have any clue?


Error reading cluster
fit read sector 0, sectors=985528, dst=, count=18446744073709551615,
size=0xf09b8


The resulting count looks crazy, but I imagine it was just
that the negative error code was converted to ulong.



For debugging, I enabled debug() under common/spl/.
The rest is the same as the latest mainline.

The full log is as follows:



U-Boot SPL 2023.10-rc4-00047-gb9b83a86f0-dirty (Sep 21 2023 - 14:38:15 +)
SYSFW ABI: 3.1 (firmware rev 0x0009 '9.0.7--v09.00.07 (Kool Koala)')
EEPROM not available at 0x50, trying to read at 0x51
SPL initial stack usage: 13384 bytes
SPL malloc() before relocation used 0x32ec bytes (12 KB)
>>SPL: board_init_r()
spl_init
Trying to boot from MMC2
spl: mmc boot mode: fs
Found FIT
fit read sector 0, sectors=874340, dst=, count=874339, size=0xd5764
firmware: 'atf'
Embedded data: dst=701c, size=b2a8
Warning: Detected image signing certificate on GP device. Skipping
certificate to prevent boot failure. This will fail if the image was
also encrypted
Image OS is ARM Trusted Firmware
loadables: 'tee'
Embedded data: dst=9e80, size=753e0
Warning: Detected image signing certificate on GP device. Skipping
certificate to prevent boot failure. This will fail if the image was
also encrypted
Loadable is Trusted Execution Environment
loadables: 'dm'
Embedded data: dst=8900, size=0
Loadable is Unknown OS
loadables: 'spl'
Embedded data: dst=8008, size=4ff18
Warning: Detected image signing certificate on GP device. Skipping
certificate to prevent boot failure. This will fail if the image was
also encrypted
Loadable is U-Boot
fdt: 'fdt-1'
Embedded data: dst=800cf888, size=2af2
Warning: Detected image signing certificate on GP device. Skipping
certificate to prevent boot failure. This will fail if the image was
also encrypted
loadables: 'spl'
no string for index 3
Unsupported OS image.. Jumping nevertheless..
Loading Environment from MMC... MMC Device 0 not found
*** Warning - No MMC card found, using default environment

Starting ATF on ARM64 core...

NOTICE:  BL31: v2.9(release):v2.9.0
NOTICE:  BL31: Built : 10:06:58, Sep 21 2023
I/TC:
I/TC: OP-TEE version: 3.22.0 (gcc version 11.4.0 (Ubuntu
11.4.0-1ubuntu1~22.04)) #1 Thu Sep 21 10:06:54 UTC 2023 aarch64
I/TC: WARNING: This OP-TEE configuration might be insecure!
I/TC: WARNING: Please check
https://optee.readthedocs.io/en/latest/architecture/porting_guidelines.html
I/TC: Primary CPU initializing
I/TC: SYSFW ABI: 3.1 (firmware rev 0x0009 '9.0.7--v09.00.07 (Kool Koala)')
I/TC: HUK Initialized
I/TC: Activated SA2UL device
I/TC: Fixing SA2UL firewall owner for GP device
I/TC: Enabled firewalls for SA2UL TRNG device
I/TC: SA2UL TRNG initialized
I/TC: SA2UL Drivers initialized
I/TC: Primary CPU switching to normal world boot

U-Boot SPL 2023.10-rc4-00047-gb9b83a86f0-dirty (Sep 21 2023 - 14:38:20 +)
SYSFW ABI: 3.1 (firmware rev 0x0009 '9.0.7--v09.00.07 (Kool Koala)')
SPL malloc() before relocation used 0x1f80 bytes (7 KB)
>>SPL: board_init_r()
spl_init
Trying to boot from MMC2
spl: mmc boot mode: fs
Found FIT
Error reading cluster
fit read sector 0, sectors=985528, dst=, count=18446744073709551615,
size=0xf09b8
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###





My build sequence is something like this:



  # for wakeup
  make -j "$(nproc)" O=build-wakeup CROSS_COMPILE=arm-linux-gnueabihf- \
  BINMAN_INDIRS="${SNAPCRAFT_STAGE}/ti-linux-firmware" \
  am64x_evm_r5_defconfig all
  cp build-wakeup/tiboot3-am64x-gp-evm.bin "${STAGE}/tiboot3.bin"

  # for main
  make -j "$(nproc)" O=build-main am64x_evm_a53_defconfig
  make -j "$(nproc)" O=build-main CROSS_COMPILE=aarch64-linux-gnu- \
  BINMAN_INDIRS="${STAGE}/ti-linux-firmware" \
  BL31="${STAGE}/bl31.bin" \
  TEE="${STAGE}/tee-raw.bin" \
  all
  cp build-main/tispl.bin build-main/u-boot.img "${STAGE}"






Strangely, AM62-SK booted successfully,
but AM64-SK failed.
I do not know why.


-- 
Best Regards
Masahiro Yamada


Re: [PATCH] stdio: Remove stdio_init()

2023-07-15 Thread Masahiro Yamada
On Thu, Jun 22, 2023 at 3:41 AM Tom Rini  wrote:
>
> On Tue, Jun 06, 2023 at 08:37:42PM +0900, Masahiro Yamada wrote:
>
> > This function is not used by anyone.
> >
> > Signed-off-by: Masahiro Yamada 
> > Reviewed-by: Simon Glass 
>
> Applied to u-boot/next, thanks!
>
> --
> Tom




I am pretty much sure I sent this patch
from .



Then, the Author: field was converted to
my old mail address, which is no longer working.
Why?





commit e0afedb64085d02c7a3b156f77f6c71d0836e583
Author: Masahiro Yamada 
Date:   Tue Jun 6 20:37:42 2023 +0900

stdio: Remove stdio_init()

This function is not used by anyone.

Signed-off-by: Masahiro Yamada 
Reviewed-by: Simon Glass 





-- 
Best Regards
Masahiro Yamada


[PATCH] stdio: Remove stdio_init()

2023-06-06 Thread Masahiro Yamada
This function is not used by anyone.

Signed-off-by: Masahiro Yamada 
---

 common/stdio.c  | 8 
 include/stdio_dev.h | 7 ---
 2 files changed, 15 deletions(-)

diff --git a/common/stdio.c b/common/stdio.c
index cbedfdda53..894cbd3fb4 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -386,11 +386,3 @@ int stdio_add_devices(void)
 
return 0;
 }
-
-int stdio_init(void)
-{
-   stdio_init_tables();
-   stdio_add_devices();
-
-   return 0;
-}
diff --git a/include/stdio_dev.h b/include/stdio_dev.h
index 3105928970..77bf8a8970 100644
--- a/include/stdio_dev.h
+++ b/include/stdio_dev.h
@@ -84,13 +84,6 @@ int stdio_init_tables(void);
  */
 int stdio_add_devices(void);
 
-/**
- * stdio_init() - Sets up stdio ready for use
- *
- * This calls stdio_init_tables() and stdio_add_devices()
- */
-int stdio_init(void);
-
 void stdio_print_current_devices(void);
 
 /**
-- 
2.39.2



Re: [RESEND PATCH] kconfig: Proposed language extension for multiple builds

2023-03-12 Thread Masahiro Yamada
On Sun, Mar 12, 2023 at 1:55 AM Tom Rini  wrote:
>
> On Fri, Mar 10, 2023 at 09:39:15PM -0800, Randy Dunlap wrote:
> > Hi--
> >
> > On 3/10/23 18:37, Simon Glass wrote:
> > > (I am sending this again to get more feedback)
> > >
> > > In the case of Linux, only one build is produced so there is only a
> > > single configuration. For other projects, such as U-Boot and Zephyr, the
> > > same code is used to produce multiple builds, each with related (but
> > > different) options enabled.
> > >
> > > This can be handled with the existing kconfig language, but it is quite
> > > verbose, somewhat tedious and very error-prone, since there is a lot of
> > > duplication. The result is hard to maintain.
> > >
> > > Describe an extension to the Kconfig language to support easier handling
> > > of this use case.
> > >
> > > Signed-off-by: Simon Glass 
> >
> > IMO Masahiro has already answered this multiple times and I agree with his 
> > answers.
> >
> > For others, the full previous thread is at
> >   
> > https://lore.kernel.org/all/20230219145453.1.Idaaf79c3e768b85750d5a7eb732052576c5e07e5@changeid/
>
> Well, I think what was unclear, or maybe we just wanted to confirm the
> answer was "none at all", was this. As good community neighbors, we see
> a generic issue in the Kconfig language, a tool used frequently outside
> of just the Linux kernel, and would like to contribute back. Ideally
> without having first gone off, designed and implemented something, and
> then been told it's all wrong and to rewrite it first. So what level of
> interest is there in this?

Sorry, no interest.
If you want to get a clear answer, NACK.

>
> As I pointed out in that thread, I believe barebox has examples where
> some keyword like we're proposing here would help them (and yes, there's
> only a dozen or so symbols so it's also manageable without anything
> special),

Barebox keeps PBL in very limited, ad-hoc implementation.
PBL has no more than 10 user-configurable options.
Sascha Hauer designed it this way.



Linux kernel also has a small loader (a.k.a decompressor) in
arch/*/boot/decompress/.

For example, CONFIG_KERNEL_GZIP is a CONFIG option
for the decompressor instead of the main kernel.

In this sense, you could apply your theory,
"Linux kernel is also multi build-phases, so Kconfig should have this
extension to move CONFIG_KERNEL_GZIP to another build phase".
No, no. The main kernel and the decompressor are well separated
and the latter is small and simple.

Barebox is the same - the main Barebox and PBL are well separated
and PBL is really small and simple.

The problems you are suffering from do not exist in Barebox.



> and Simon believes Zephyr will be in a similar situation soon
> enough (which doesn't use the kernel's implementation of the language).

Zephyr does not share any Kconfig code with Linux.
They use Python implementation, a.k.a. Kconfiglib.
It is up to the Zephyr community, but this requires extra effort.

> Frankly, I keep going back to "tristate" is just the original example of
> what we're talking about here (CONFIG_FOO=n, CONFIG_FOO_MODULE=y), not
> that I'm suggesting we would remove the tristate word.
> So we would really like to make sure as many people and projects are
> aware, as possible.

This is on the boundary.
We can make the tristate optional if it does not make the code too ugly.

But, if you do not add CONFIG_MODULES in your Kconfig file,
users will not see 'm' in the first place.

I know some help messages still mention 'm', but is this the problem
you want to solve?


> And as Simon asked in the thread, what about code refactoring that makes
> further maintenance easier? Clearly, such patches would need to be
> against the current appropriate tree.

If such patches clean up the code, they will be appreciated.

-- 
Best Regards
Masahiro Yamada


Re: [PATCH] kconfig: Proposed language extension for multiple builds

2023-02-27 Thread Masahiro Yamada
Hi Simon,

On Mon, Feb 27, 2023 at 1:00 PM Simon Glass  wrote:
>
> Hi Masahiro,
>
> On Sun, 26 Feb 2023 at 20:36, Masahiro Yamada  wrote:
> >
> > Hi Simon,
> >
> > On Mon, Feb 27, 2023 at 4:23 AM Simon Glass  wrote:
> > >
> > > Hi Masahiro,
> > >
> > > On Sun, 26 Feb 2023 at 10:36, Masahiro Yamada  
> > > wrote:
> > > >
> > > > On Sun, Feb 26, 2023 at 11:44 PM Tom Rini  wrote:
> > > > >
> > > > > On Sun, Feb 26, 2023 at 11:32:03PM +0900, Masahiro Yamada wrote:
> > > > > > On Sun, Feb 26, 2023 at 11:04 PM Simon Glass  
> > > > > > wrote:
> > > > > > >
> > > > > > > Hi Masahiro,
> > > > > > >
> > > > > > > On Sat, 25 Feb 2023 at 20:31, Masahiro Yamada 
> > > > > > >  wrote:
> > > > > > > >
> > > > > > > > On Sat, Feb 25, 2023 at 11:38 AM Simon Glass 
> > > > > > > >  wrote:
> > > > > > > > >
> > > > > > > > > +Masahiro Yamada
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > I do not know.
> > > > > > > > This seems a shorthand in Kconfig level.
> > > > > > > >
> > > > > > > >
> > > > > > > > masahiro@zoe:~/ref/u-boot(master)$ rgrep '^config SPL_' | wc
> > > > > > > > 5401080   24872
> > > > > > > > masahiro@zoe:~/ref/u-boot(master)$ rgrep '^config TPL_' | wc
> > > > > > > > 163 3267462
> > > > > > > >
> > > > > > > > If hundreds of duplications are not manageable,
> > > > > > > > go for it, but kconfig will be out-of-sync from the
> > > > > > > > upstream Kconfig.
> > > > > > >
> > > > > > > Yes that's right, it is a shorthand in Kconfig.
> > > > > > >
> > > > > > > The counts above understand the problem a little since quite a few
> > > > > > > CONFIG options without an SPL prefix are used in SPL. We don't 
> > > > > > > have
> > > > > > > tools to estimate how many, and we sometimes add a new symbol to 
> > > > > > > 'gain
> > > > > > > control' of a particular feature in a phase.
> > > > > > >
> > > > > > > My intent in sending this patch was to check whether this support 
> > > > > > > for
> > > > > > > configuring multiple related builds (or something like it) could 
> > > > > > > go
> > > > > > > upstream, which for Kconfig is Linux, I believe. What do you 
> > > > > > > think?
> > > > > >
> > > > > >
> > > > > > This complexity is absolutely unneeded for Linux.
> > > > > >
> > > > > > So, the answer is no.
> > > > >
> > > > > Well, I think Simon summarized himself a bit shorter here than he did 
> > > > > in
> > > > > the patch itself.  So, to what extent does the kernel want to consider
> > > > > all of the other projects using the Kconfig language and their needs /
> > > > > use cases?
> > > > >
> > > > > --
> > > > > Tom
> > > >
> > > >
> > > >
> > > > In principle, only features that are useful for Linux.
> > >
> > > I'm disappointed in this attitude. It is the same thing that we saw
> > > from the DT bindings until recently.
> >
> >
> > Sorry, but this is the maintainer's job.
> > Saying no is one of the most important jobs as a maintainer.
> >
> > I must avoid Kconfig getting Frankenstein mechanisms.
>
> Can you suggest a better approach?


No, I can't.

Kconfig is a configuration system of the Linux kernel, which is monolithic.
It was not designed with multi-phase images in mind.


Presumably, Kconfig is good for U-Boot proper, but not for SPL/TPL given
the limited memory. There is little room for user's configuration anyway.

U-Boot extended SPL too much.
On-chip RAM is not supposed to run DT, DM, FIT.
With SPL kept simple and ad-hoc, none of
CONFIG_SPL_OF_CONTROL, SPL_DM, SPL_FIT was unneeded.
"bootph-*" properties were unneeded either.

This is a U-Boot-specific problem.
Please solve it in U-Boot.


Masahiro Yamada






>
> > > >
> > > > Kconfig has small piece of code that is useful for other projects,
> > > > for example,
> > > >
> > > > #ifndef CONFIG_
> > > > #define CONFIG_ "CONFIG_"
> > > > #endif
> > > >
> > > > which might be useful for Buildroot, but this is exceptionally small.
> > >
> > > How about refactoring patches that would make a possible
> > > implementation easier to maintain, like [1] ? Would they be
> > > acceptable?
> >
> >
> > Code refactoring is welcome, but [1] is not applicable.
> > U-Boot kconfig is synced with Linux 4.20, way behind the mainline Linux.
>
> Sure, I wasn't suggesting that exact patch. It should be easy enough
> to move to the latest version. It sounds like it may be possible to
> make the Frankenstein patches easier to maintain out of tree, if we go
> that way.
>
> > > >
> > > >
> > > > The multi-phase is too cluttered, and that is not what Linux wants to 
> > > > have.
> > >
> > > Clearly it is not useful to Linux, which only has one build.
> > >
> > > [1] 
> > > https://patchwork.ozlabs.org/project/uboot/patch/20230212231638.1134219-61-...@chromium.org/
>
> Regards,
> Simon


--
Best Regards
Masahiro Yamada


Re: [PATCH] kconfig: Proposed language extension for multiple builds

2023-02-26 Thread Masahiro Yamada
Hi Simon,

On Mon, Feb 27, 2023 at 4:23 AM Simon Glass  wrote:
>
> Hi Masahiro,
>
> On Sun, 26 Feb 2023 at 10:36, Masahiro Yamada  wrote:
> >
> > On Sun, Feb 26, 2023 at 11:44 PM Tom Rini  wrote:
> > >
> > > On Sun, Feb 26, 2023 at 11:32:03PM +0900, Masahiro Yamada wrote:
> > > > On Sun, Feb 26, 2023 at 11:04 PM Simon Glass  wrote:
> > > > >
> > > > > Hi Masahiro,
> > > > >
> > > > > On Sat, 25 Feb 2023 at 20:31, Masahiro Yamada  
> > > > > wrote:
> > > > > >
> > > > > > On Sat, Feb 25, 2023 at 11:38 AM Simon Glass  
> > > > > > wrote:
> > > > > > >
> > > > > > > +Masahiro Yamada
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > I do not know.
> > > > > > This seems a shorthand in Kconfig level.
> > > > > >
> > > > > >
> > > > > > masahiro@zoe:~/ref/u-boot(master)$ rgrep '^config SPL_' | wc
> > > > > > 5401080   24872
> > > > > > masahiro@zoe:~/ref/u-boot(master)$ rgrep '^config TPL_' | wc
> > > > > > 163 3267462
> > > > > >
> > > > > > If hundreds of duplications are not manageable,
> > > > > > go for it, but kconfig will be out-of-sync from the
> > > > > > upstream Kconfig.
> > > > >
> > > > > Yes that's right, it is a shorthand in Kconfig.
> > > > >
> > > > > The counts above understand the problem a little since quite a few
> > > > > CONFIG options without an SPL prefix are used in SPL. We don't have
> > > > > tools to estimate how many, and we sometimes add a new symbol to 'gain
> > > > > control' of a particular feature in a phase.
> > > > >
> > > > > My intent in sending this patch was to check whether this support for
> > > > > configuring multiple related builds (or something like it) could go
> > > > > upstream, which for Kconfig is Linux, I believe. What do you think?
> > > >
> > > >
> > > > This complexity is absolutely unneeded for Linux.
> > > >
> > > > So, the answer is no.
> > >
> > > Well, I think Simon summarized himself a bit shorter here than he did in
> > > the patch itself.  So, to what extent does the kernel want to consider
> > > all of the other projects using the Kconfig language and their needs /
> > > use cases?
> > >
> > > --
> > > Tom
> >
> >
> >
> > In principle, only features that are useful for Linux.
>
> I'm disappointed in this attitude. It is the same thing that we saw
> from the DT bindings until recently.


Sorry, but this is the maintainer's job.
Saying no is one of the most important jobs as a maintainer.

I must avoid Kconfig getting Frankenstein mechanisms.





> >
> > Kconfig has small piece of code that is useful for other projects,
> > for example,
> >
> > #ifndef CONFIG_
> > #define CONFIG_ "CONFIG_"
> > #endif
> >
> > which might be useful for Buildroot, but this is exceptionally small.
>
> How about refactoring patches that would make a possible
> implementation easier to maintain, like [1] ? Would they be
> acceptable?


Code refactoring is welcome, but [1] is not applicable.
U-Boot kconfig is synced with Linux 4.20, way behind the mainline Linux.





> >
> >
> > The multi-phase is too cluttered, and that is not what Linux wants to have.
>
> Clearly it is not useful to Linux, which only has one build.
>
> Regards,
> Simon
>
> [1] 
> https://patchwork.ozlabs.org/project/uboot/patch/20230212231638.1134219-61-...@chromium.org/



-- 
Best Regards
Masahiro Yamada


Re: [PATCH] kconfig: Proposed language extension for multiple builds

2023-02-26 Thread Masahiro Yamada
On Sun, Feb 26, 2023 at 11:44 PM Tom Rini  wrote:
>
> On Sun, Feb 26, 2023 at 11:32:03PM +0900, Masahiro Yamada wrote:
> > On Sun, Feb 26, 2023 at 11:04 PM Simon Glass  wrote:
> > >
> > > Hi Masahiro,
> > >
> > > On Sat, 25 Feb 2023 at 20:31, Masahiro Yamada  
> > > wrote:
> > > >
> > > > On Sat, Feb 25, 2023 at 11:38 AM Simon Glass  wrote:
> > > > >
> > > > > +Masahiro Yamada
> > > >
> > > >
> > > >
> > > >
> > > > I do not know.
> > > > This seems a shorthand in Kconfig level.
> > > >
> > > >
> > > > masahiro@zoe:~/ref/u-boot(master)$ rgrep '^config SPL_' | wc
> > > > 5401080   24872
> > > > masahiro@zoe:~/ref/u-boot(master)$ rgrep '^config TPL_' | wc
> > > > 163 3267462
> > > >
> > > > If hundreds of duplications are not manageable,
> > > > go for it, but kconfig will be out-of-sync from the
> > > > upstream Kconfig.
> > >
> > > Yes that's right, it is a shorthand in Kconfig.
> > >
> > > The counts above understand the problem a little since quite a few
> > > CONFIG options without an SPL prefix are used in SPL. We don't have
> > > tools to estimate how many, and we sometimes add a new symbol to 'gain
> > > control' of a particular feature in a phase.
> > >
> > > My intent in sending this patch was to check whether this support for
> > > configuring multiple related builds (or something like it) could go
> > > upstream, which for Kconfig is Linux, I believe. What do you think?
> >
> >
> > This complexity is absolutely unneeded for Linux.
> >
> > So, the answer is no.
>
> Well, I think Simon summarized himself a bit shorter here than he did in
> the patch itself.  So, to what extent does the kernel want to consider
> all of the other projects using the Kconfig language and their needs /
> use cases?
>
> --
> Tom



In principle, only features that are useful for Linux.

Kconfig has small piece of code that is useful for other projects,
for example,

#ifndef CONFIG_
#define CONFIG_ "CONFIG_"
#endif

which might be useful for Buildroot, but this is exceptionally small.


The multi-phase is too cluttered, and that is not what Linux wants to have.




-- 
Best Regards
Masahiro Yamada


Re: [PATCH] kconfig: Proposed language extension for multiple builds

2023-02-26 Thread Masahiro Yamada
On Sun, Feb 26, 2023 at 11:04 PM Simon Glass  wrote:
>
> Hi Masahiro,
>
> On Sat, 25 Feb 2023 at 20:31, Masahiro Yamada  wrote:
> >
> > On Sat, Feb 25, 2023 at 11:38 AM Simon Glass  wrote:
> > >
> > > +Masahiro Yamada
> >
> >
> >
> >
> > I do not know.
> > This seems a shorthand in Kconfig level.
> >
> >
> > masahiro@zoe:~/ref/u-boot(master)$ rgrep '^config SPL_' | wc
> > 5401080   24872
> > masahiro@zoe:~/ref/u-boot(master)$ rgrep '^config TPL_' | wc
> > 163 3267462
> >
> > If hundreds of duplications are not manageable,
> > go for it, but kconfig will be out-of-sync from the
> > upstream Kconfig.
>
> Yes that's right, it is a shorthand in Kconfig.
>
> The counts above understand the problem a little since quite a few
> CONFIG options without an SPL prefix are used in SPL. We don't have
> tools to estimate how many, and we sometimes add a new symbol to 'gain
> control' of a particular feature in a phase.
>
> My intent in sending this patch was to check whether this support for
> configuring multiple related builds (or something like it) could go
> upstream, which for Kconfig is Linux, I believe. What do you think?


This complexity is absolutely unneeded for Linux.

So, the answer is no.



-- 
Best Regards
Masahiro Yamada


Re: [PATCH] kconfig: Proposed language extension for multiple builds

2023-02-25 Thread Masahiro Yamada
On Sat, Feb 25, 2023 at 11:38 AM Simon Glass  wrote:
>
> +Masahiro Yamada




I do not know.
This seems a shorthand in Kconfig level.


masahiro@zoe:~/ref/u-boot(master)$ rgrep '^config SPL_' | wc
5401080   24872
masahiro@zoe:~/ref/u-boot(master)$ rgrep '^config TPL_' | wc
163 3267462

If hundreds of duplications are not manageable,
go for it, but kconfig will be out-of-sync from the
upstream Kconfig.

Masahiro










> On Fri, 24 Feb 2023 at 19:04, Simon Glass  wrote:
>>
>> +lk
>>
>> On Sun, 19 Feb 2023 at 14:55, Simon Glass  wrote:
>> >
>> > In the case of Linux, only one build is produced so there is only a
>> > single configuration. For other projects, such as U-Boot and Zephyr, the
>> > same code is used to produce multiple builds, each with related (but
>> > different) options enabled.
>> >
>> > This can be handled with the existing kconfig language, but it is quite
>> > verbose, somewhat tedious and very error-prone, since there is a lot of
>> > duplication. The result is hard to maintain.
>> >
>> > Describe an extension to the Kconfig language to support easier handling
>> > of this use case.
>> >
>> > Signed-off-by: Simon Glass 
>> > ---
>> >
>> >  Documentation/kbuild/kconfig-language.rst | 134 ++
>> >  1 file changed, 134 insertions(+)
>> >
>> > diff --git a/Documentation/kbuild/kconfig-language.rst 
>> > b/Documentation/kbuild/kconfig-language.rst
>> > index 858ed5d80defe..73fb016a5533f 100644
>> > --- a/Documentation/kbuild/kconfig-language.rst
>> > +++ b/Documentation/kbuild/kconfig-language.rst
>> > @@ -228,6 +228,24 @@ applicable everywhere (see syntax).
>> >enables the third modular state for all config symbols.
>> >At most one symbol may have the "modules" option set.
>> >
>> > +- phase declaration: "defphase"
>> > +  This defines a new build phase. See `Build Phases`_.
>> > +
>> > +- default phase: "phasedefault"
>> > +  This indicates the default build phase. See `Build Phases`_.
>> > +
>> > +- add entries for phases: "addphases"
>> > +  This creates new phase-specific entries based on a template entry and 
>> > adds
>> > +  the same attributes to it. See `Build Phases`_.
>> > +
>> > +- set entries for phases: "setphases"
>> > +  This sets the phases which need an entry. This allows creating an entry 
>> > that
>> > +  only has a primary phase. See `Build Phases`_.
>> > +
>> > +- indicate a phase-specific attribute: "forphases"
>> > +  This marks an attribute as being applicable only to a particular phase 
>> > or
>> > +  group of phases.  See `Build Phases`_.
>> > +
>> >  Menu dependencies
>> >  -
>> >
>> > @@ -319,6 +337,119 @@ MODVERSIONS directly depends on MODULES, this means 
>> > it's only visible if
>> >  MODULES is different from 'n'. The comment on the other hand is only
>> >  visible when MODULES is set to 'n'.
>> >
>> > +Build Phases
>> > +
>> > +
>> > +Some projects use Kconfig to control multiple build phases, each phase
>> > +resulting in a separate set of object files and executable. This is the
>> > +case in U-Boot [12]_. Zephyr OS seems to be heading this way too [13]_.
>> > +
>> > +Generally the phases are related, so that enabling an entry in the primary
>> > +phase also enables it by default in the others. But in some cases it may
>> > +be desirable to use separate conditions for each phase.
>> > +
>> > +All phases have a phase name, for example `SPL`. This name is used as a
>> > +prefix to each entry used in that phase, with an underscore in between.
>> > +So if FOO is the primary entry, the equivalent entry for the SPL phase
>> > +is SPL_FOO. The primary phase is marked with a "phasedefault" entry.
>> > +
>> > +Phases are declared like any other menu entry except that also have a
>> > +"defphase" keyword. Phase entries are normally hidden so do not have a
>> > +prompt::
>> > +
>> > +config PPL
>> > +bool
>> > +defphase "Primary Program Loader"
>> > +phasedefault
>> > +help
>> > +  This is the primary bootloader.
>> > +
>> > +config SPL
>> > +bool
>

Re: [PATCH v2 2/5] Makefile: Correct a missing FORCE on the binman rule

2022-10-11 Thread Masahiro Yamada
On Tue, Oct 11, 2022 at 11:16 PM Simon Glass  wrote:
>
> This is required for if_changed to work correctly. Add it.
>
> Signed-off-by: Simon Glass 
> Reviewed-by: Pali Rohár 
> ---
>
> (no changes since v1)
>
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index 3866cc62f9a..d28e8b4e316 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -,7 +,7 @@ endef
>  PHONY += inputs
>  inputs: $(INPUTS-y)
>
> -all: .binman_stamp inputs
> +all: .binman_stamp inputs FORCE
>  ifeq ($(CONFIG_BINMAN),y)
> $(call if_changed,binman)



'all' is usually used as a phony target.


I think this went wrong.

if_changed should never be used for a phony target.
In other words, if_changed should produce a build artifact.



FORCE is never used for a phony target because
it is added to 'PHONY'.

PHONY += all






>  endif
> --
> 2.38.0.rc1.362.ged0d419d3c-goog
>


Re: [PATCH v5 02/29] kconfig: Add tools support to CONFIG_IS_ENABLED()

2021-09-27 Thread Masahiro Yamada
_IS_ENABLED(FOO, (abc)) expands to
> > + *  abc if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
> >*  abc if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
> >*  abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
> >*  abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
> >*  nothing otherwise.
> >*
> >* CONFIG_IS_ENABLED(FOO, (abc), (def)) expands to
> > + *  abc if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
> >*  abc if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
> >*  abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
> >*  abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
> >



-- 
Best Regards
Masahiro Yamada


Re: [PATCH 06/22] Makefile: Avoid rebuilding .dtb files each time

2021-07-18 Thread Masahiro Yamada
On Sun, Jul 18, 2021 at 5:41 AM Simon Glass  wrote:
>
> Drop the FORCE from the rule that builds .dtb files and let the normal
> dependency checking do its work. This should work correctly, at least
> for .dts files that don't use /include/.
>
> Signed-off-by: Simon Glass 
> ---
>
>  scripts/Makefile.lib | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Applied to u-boot-dm, thanks!


I am no longer working on U-Boot,
but this patch is obviously wrong.

if_changed_dep must always have FORCE
as the prerequisite.

If it is not working, you may miss adding
the objects to the 'targets'.

Somebody had broken the build system?


--
Best Regards
Masahiro Yamada


[PATCH] MAINTAINERS: step down as maintainer of UniPhier SoCs

2020-08-31 Thread Masahiro Yamada
I am leaving Socionext. Orphan the UniPhier platform until somebody
takes the role.

Signed-off-by: Masahiro Yamada 
---

 MAINTAINERS | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index bebe87b4d1..101f4e185d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -506,9 +506,7 @@ F:  arch/arm/mach-u8500/
 F: drivers/timer/nomadik-mtu-timer.c
 
 ARM UNIPHIER
-M: Masahiro Yamada 
-S: Maintained
-T: git https://gitlab.denx.de/u-boot/custodians/u-boot-uniphier.git
+S: Orphan (Since 2020-09)
 F: arch/arm/mach-uniphier/
 F: configs/uniphier_*_defconfig
 N: uniphier
-- 
2.25.1



[GIT PULL] UniPhier SoC updates for v2020.10-rc3

2020-08-17 Thread Masahiro Yamada
Hi Tom,

Please pull a little more for v2020.10.
Thanks.


The following changes since commit 789bfb52668ee609b2043de645e2f94bbd24fd1f:

  Merge tag 'efi-2020-10-rc3-2' of
https://gitlab.denx.de/u-boot/custodians/u-boot-efi (2020-08-15
09:01:01 -0400)

are available in the Git repository at:

  https://gitlab.denx.de/u-boot/custodians/u-boot-uniphier.git
tags/uniphier-v2020.10-2

for you to fetch changes up to 65282edbdf2f30e97c1680e856e6e9fb7af26f8b:

  ARM: dts: uniphier: resync DT with Linux 5.9-rc1 (2020-08-18 02:01:14 +0900)


UniPhier SoC updates for v2020.10 (2nd)

 - minor code cleanups

 - sync DT with Linux


Masahiro Yamada (6):
  ARM: uniphier: rename include guard of include/configs/uniphier.h
  ARM: uniphier: remove unused uniphier_pin_init()
  ARM: uniphier: remove unneeded header inclusion from board_late_init.c
  serial: uniphier: fix typo in comment
  ARM: uniphier: use FIELD_GET() to get access to revision register fields
  ARM: dts: uniphier: resync DT with Linux 5.9-rc1

 arch/arm/dts/uniphier-ld11-global.dts|   2 +-
 arch/arm/dts/uniphier-ld11-ref.dts   |   8 +-
 arch/arm/dts/uniphier-ld20-global.dts|   2 +-
 arch/arm/dts/uniphier-ld20-ref.dts   |   8 +-
 arch/arm/dts/uniphier-ld20.dtsi  |   2 +
 arch/arm/dts/uniphier-ld4-ref.dts|   6 +-
 arch/arm/dts/uniphier-ld6b-ref.dts   |   7 +-
 arch/arm/dts/uniphier-pinctrl.dtsi   |   5 +
 arch/arm/dts/uniphier-pro4-ace.dts   |   2 +-
 arch/arm/dts/uniphier-pro4-ref.dts   |   8 +-
 arch/arm/dts/uniphier-pro4-sanji.dts |   3 +-
 arch/arm/dts/uniphier-pro5.dtsi  | 190 +++---
 arch/arm/dts/uniphier-pxs2-gentil.dts|   2 +-
 arch/arm/dts/uniphier-pxs2-vodka.dts |   2 +-
 arch/arm/dts/uniphier-pxs3-ref.dts   |  10 +-
 arch/arm/dts/uniphier-pxs3.dtsi  |   2 +
 arch/arm/dts/uniphier-sld8-ref.dts   |   6 +-
 arch/arm/dts/uniphier-support-card.dtsi  |  31 ++-
 arch/arm/mach-uniphier/Makefile  |   1 -
 arch/arm/mach-uniphier/board_late_init.c |   3 +-
 arch/arm/mach-uniphier/init.h|   1 -
 arch/arm/mach-uniphier/pinctrl-glue.c|  30 ---
 arch/arm/mach-uniphier/sg-regs.h |   5 +
 arch/arm/mach-uniphier/soc-info.c|  21 +-
 drivers/serial/serial_uniphier.c |   2 +-
 include/configs/uniphier.h   |   6 +-
 26 files changed, 255 insertions(+), 110 deletions(-)
 delete mode 100644 arch/arm/mach-uniphier/pinctrl-glue.c


[PATCH] ARM: dts: uniphier: resync DT with Linux 5.9-rc1

2020-08-03 Thread Masahiro Yamada
Signed-off-by: Masahiro Yamada 
---

 arch/arm/dts/uniphier-ld11-global.dts   |   2 +-
 arch/arm/dts/uniphier-ld11-ref.dts  |   8 +-
 arch/arm/dts/uniphier-ld20-global.dts   |   2 +-
 arch/arm/dts/uniphier-ld20-ref.dts  |   8 +-
 arch/arm/dts/uniphier-ld20.dtsi |   2 +
 arch/arm/dts/uniphier-ld4-ref.dts   |   6 +-
 arch/arm/dts/uniphier-ld6b-ref.dts  |   7 +-
 arch/arm/dts/uniphier-pinctrl.dtsi  |   5 +
 arch/arm/dts/uniphier-pro4-ace.dts  |   2 +-
 arch/arm/dts/uniphier-pro4-ref.dts  |   8 +-
 arch/arm/dts/uniphier-pro4-sanji.dts|   3 +-
 arch/arm/dts/uniphier-pro5.dtsi | 190 +---
 arch/arm/dts/uniphier-pxs2-gentil.dts   |   2 +-
 arch/arm/dts/uniphier-pxs2-vodka.dts|   2 +-
 arch/arm/dts/uniphier-pxs3-ref.dts  |  10 +-
 arch/arm/dts/uniphier-pxs3.dtsi |   2 +
 arch/arm/dts/uniphier-sld8-ref.dts  |   6 +-
 arch/arm/dts/uniphier-support-card.dtsi |  31 ++--
 18 files changed, 235 insertions(+), 61 deletions(-)

diff --git a/arch/arm/dts/uniphier-ld11-global.dts 
b/arch/arm/dts/uniphier-ld11-global.dts
index 670e1a76db..644ffb9707 100644
--- a/arch/arm/dts/uniphier-ld11-global.dts
+++ b/arch/arm/dts/uniphier-ld11-global.dts
@@ -157,7 +157,7 @@
 };
 
  {
-   ethphy: ethphy@1 {
+   ethphy: ethernet-phy@1 {
reg = <1>;
};
 };
diff --git a/arch/arm/dts/uniphier-ld11-ref.dts 
b/arch/arm/dts/uniphier-ld11-ref.dts
index 693171f82f..617d2b1e9b 100644
--- a/arch/arm/dts/uniphier-ld11-ref.dts
+++ b/arch/arm/dts/uniphier-ld11-ref.dts
@@ -20,7 +20,7 @@
 
aliases {
serial0 = 
-   serial1 = 
+   serial1 = 
serial2 = 
serial3 = 
i2c0 = 
@@ -42,6 +42,10 @@
interrupts = <0 8>;
 };
 
+ {
+   interrupts = <0 8>;
+};
+
  {
status = "okay";
 };
@@ -76,7 +80,7 @@
 };
 
  {
-   ethphy: ethphy@1 {
+   ethphy: ethernet-phy@1 {
reg = <1>;
};
 };
diff --git a/arch/arm/dts/uniphier-ld20-global.dts 
b/arch/arm/dts/uniphier-ld20-global.dts
index 2c8266..a01579cb3b 100644
--- a/arch/arm/dts/uniphier-ld20-global.dts
+++ b/arch/arm/dts/uniphier-ld20-global.dts
@@ -141,7 +141,7 @@
 };
 
  {
-   ethphy: ethphy@1 {
+   ethphy: ethernet-phy@1 {
reg = <1>;
};
 };
diff --git a/arch/arm/dts/uniphier-ld20-ref.dts 
b/arch/arm/dts/uniphier-ld20-ref.dts
index eeb976e789..39ee279a1e 100644
--- a/arch/arm/dts/uniphier-ld20-ref.dts
+++ b/arch/arm/dts/uniphier-ld20-ref.dts
@@ -20,7 +20,7 @@
 
aliases {
serial0 = 
-   serial1 = 
+   serial1 = 
serial2 = 
serial3 = 
i2c0 = 
@@ -42,6 +42,10 @@
interrupts = <0 8>;
 };
 
+ {
+   interrupts = <0 8>;
+};
+
  {
status = "okay";
 };
@@ -64,7 +68,7 @@
 };
 
  {
-   ethphy: ethphy@0 {
+   ethphy: ethernet-phy@0 {
reg = <0>;
};
 };
diff --git a/arch/arm/dts/uniphier-ld20.dtsi b/arch/arm/dts/uniphier-ld20.dtsi
index a5cd026838..5e7143ed01 100644
--- a/arch/arm/dts/uniphier-ld20.dtsi
+++ b/arch/arm/dts/uniphier-ld20.dtsi
@@ -955,7 +955,9 @@
compatible = "socionext,uniphier-ld20-pcie-phy";
reg = <0x66038000 0x4000>;
#phy-cells = <0>;
+   clock-names = "link";
clocks = <_clk 24>;
+   reset-names = "link";
resets = <_rst 24>;
socionext,syscon = <_glue>;
};
diff --git a/arch/arm/dts/uniphier-ld4-ref.dts 
b/arch/arm/dts/uniphier-ld4-ref.dts
index 3aaca10f66..03fe696668 100644
--- a/arch/arm/dts/uniphier-ld4-ref.dts
+++ b/arch/arm/dts/uniphier-ld4-ref.dts
@@ -20,7 +20,7 @@
 
aliases {
serial0 = 
-   serial1 = 
+   serial1 = 
serial2 = 
serial3 = 
i2c0 = 
@@ -39,6 +39,10 @@
interrupts = <1 8>;
 };
 
+ {
+   interrupts = <1 8>;
+};
+
  {
status = "okay";
 };
diff --git a/arch/arm/dts/uniphier-ld6b-ref.dts 
b/arch/arm/dts/uniphier-ld6b-ref.dts
index f1a3b29bac..08943aa376 100644
--- a/arch/arm/dts/uniphier-ld6b-ref.dts
+++ b/arch/arm/dts/uniphier-ld6b-ref.dts
@@ -22,6 +22,7 @@
serial0 = 
serial1 = 
serial2 = 
+   serial3 = 
i2c0 = 
i2c1 = 
i2c2 = 
@@ -42,6 +43,10 @@
interrupts = <4 8>;
 };
 
+ {
+   interrupts = <4 8>;
+};
+
  {
status = "okay";
 };
@@ -76,7 +81,7 @@
 };
 
  {
-   ethphy: ethphy@0 {
+   ethphy: ethernet-phy@0 {
reg = <0>;
};

[PATCH 3/3] treewide: convert devfdt_get_addr_ptr() to dev_read_addr_ptr()

2020-08-03 Thread Masahiro Yamada
When you enable CONFIG_OF_LIVE, you will end up with a lot of
conversions.

To help this tedious work, this commit converts devfdt_get_addr_ptr()
to dev_read_addr_ptr() by coccinelle. I also removed redundant casts
because dev_read_addr_ptr() returns an opaque pointer.

To generate this commit, I ran the following semantic patch
excluding include/dm/.

  
  @@
  type T;
  expression dev;
  @@
  -(T *)devfdt_get_addr_ptr(dev)
  +dev_read_addr_ptr(dev)
  @@
  expression dev;
  @@
  -devfdt_get_addr_ptr(dev)
  +dev_read_addr_ptr(dev)
  

Signed-off-by: Masahiro Yamada 
---

 drivers/clk/aspeed/clk_ast2500.c  | 2 +-
 drivers/clk/at91/pmc.c| 4 ++--
 drivers/gpio/hsdk-creg-gpio.c | 2 +-
 drivers/i2c/ast_i2c.c | 2 +-
 drivers/i2c/designware_i2c.c  | 2 +-
 drivers/i2c/mv_i2c.c  | 2 +-
 drivers/i2c/mvtwsi.c  | 4 ++--
 drivers/mmc/gen_atmel_mci.c   | 2 +-
 drivers/mmc/snps_dw_mmc.c | 2 +-
 drivers/pinctrl/mvebu/pinctrl-mvebu.c | 2 +-
 drivers/reset/reset-socfpga.c | 2 +-
 drivers/serial/serial_mvebu_a3700.c   | 2 +-
 drivers/spi/uniphier_spi.c| 2 +-
 drivers/sysreset/sysreset_socfpga.c   | 2 +-
 drivers/timer/ast_timer.c | 2 +-
 drivers/timer/atmel_pit_timer.c   | 2 +-
 drivers/usb/host/ehci-zynq.c  | 2 +-
 drivers/watchdog/ast_wdt.c| 2 +-
 18 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/clk/aspeed/clk_ast2500.c b/drivers/clk/aspeed/clk_ast2500.c
index ccfeded30c..1414d26a53 100644
--- a/drivers/clk/aspeed/clk_ast2500.c
+++ b/drivers/clk/aspeed/clk_ast2500.c
@@ -497,7 +497,7 @@ static int ast2500_clk_ofdata_to_platdata(struct udevice 
*dev)
 {
struct ast2500_clk_priv *priv = dev_get_priv(dev);
 
-   priv->scu = devfdt_get_addr_ptr(dev);
+   priv->scu = dev_read_addr_ptr(dev);
if (IS_ERR(priv->scu))
return PTR_ERR(priv->scu);
 
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 54ae0d281d..ca90abef2d 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -41,7 +41,7 @@ int at91_pmc_core_probe(struct udevice *dev)
 
dev = dev_get_parent(dev);
 
-   plat->reg_base = (struct at91_pmc *)devfdt_get_addr_ptr(dev);
+   plat->reg_base = dev_read_addr_ptr(dev);
 
return 0;
 }
@@ -116,7 +116,7 @@ int at91_clk_probe(struct udevice *dev)
dev_periph_container = dev_get_parent(dev);
dev_pmc = dev_get_parent(dev_periph_container);
 
-   plat->reg_base = (struct at91_pmc *)devfdt_get_addr_ptr(dev_pmc);
+   plat->reg_base = dev_read_addr_ptr(dev_pmc);
 
return 0;
 }
diff --git a/drivers/gpio/hsdk-creg-gpio.c b/drivers/gpio/hsdk-creg-gpio.c
index d9df804f63..35b114904d 100644
--- a/drivers/gpio/hsdk-creg-gpio.c
+++ b/drivers/gpio/hsdk-creg-gpio.c
@@ -83,7 +83,7 @@ static int hsdk_creg_gpio_probe(struct udevice *dev)
u32 shift, bit_per_gpio, activate, deactivate, gpio_count;
const u8 *defaults;
 
-   hcg->regs = (u32 *)devfdt_get_addr_ptr(dev);
+   hcg->regs = dev_read_addr_ptr(dev);
gpio_count = dev_read_u32_default(dev, "gpio-count", 1);
shift = dev_read_u32_default(dev, "gpio-first-shift", 0);
bit_per_gpio = dev_read_u32_default(dev, "gpio-bit-per-line", 1);
diff --git a/drivers/i2c/ast_i2c.c b/drivers/i2c/ast_i2c.c
index 214362d04b..d122157591 100644
--- a/drivers/i2c/ast_i2c.c
+++ b/drivers/i2c/ast_i2c.c
@@ -92,7 +92,7 @@ static int ast_i2c_ofdata_to_platdata(struct udevice *dev)
struct ast_i2c_priv *priv = dev_get_priv(dev);
int ret;
 
-   priv->regs = devfdt_get_addr_ptr(dev);
+   priv->regs = dev_read_addr_ptr(dev);
if (IS_ERR(priv->regs))
return PTR_ERR(priv->regs);
 
diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c
index cf892c69d9..569a5d39b4 100644
--- a/drivers/i2c/designware_i2c.c
+++ b/drivers/i2c/designware_i2c.c
@@ -768,7 +768,7 @@ int designware_i2c_ofdata_to_platdata(struct udevice *bus)
int ret;
 
if (!priv->regs)
-   priv->regs = (struct i2c_regs *)devfdt_get_addr_ptr(bus);
+   priv->regs = dev_read_addr_ptr(bus);
dev_read_u32(bus, "i2c-scl-rising-time-ns", >scl_rise_time_ns);
dev_read_u32(bus, "i2c-scl-falling-time-ns", >scl_fall_time_ns);
dev_read_u32(bus, "i2c-sda-hold-time-ns", >sda_hold_time_ns);
diff --git a/drivers/i2c/mv_i2c.c b/drivers/i2c/mv_i2c.c
index 59675d8d57..82e8fdac41 100644
--- a/drivers/i2c/mv_i2c.c
+++ b/drivers/i2c/mv_i2c.c
@@ -580,7 +580,7 @@ static int mv_i2c_probe(struct udevice *bus)
 {
struct mv_i2c_priv *priv = dev_get_priv(bus);
 
-   priv->base = (void *)devfdt_get_addr_ptr(bus);
+   priv->base = dev_read_addr_ptr(bus);
 
return 0;
 }
diff --git 

[PATCH 1/3] gpio: at91: use dev_read_addr() to get base address

2020-08-03 Thread Masahiro Yamada
It is strange to use devfdt_get_addr_ptr(), then cast the pointer
back to uint32 because you could use devfdt_get_addr() without casting.

Convert it to dev_read_addr(), which is capable to CONFIG_OF_LIVE.

Signed-off-by: Masahiro Yamada 
---

 drivers/gpio/at91_gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c
index 4a8b2e6ff6..ef7984374b 100644
--- a/drivers/gpio/at91_gpio.c
+++ b/drivers/gpio/at91_gpio.c
@@ -606,7 +606,7 @@ static int at91_gpio_probe(struct udevice *dev)
clk_free();
 
 #if CONFIG_IS_ENABLED(OF_CONTROL)
-   plat->base_addr = (uint32_t)devfdt_get_addr_ptr(dev);
+   plat->base_addr = dev_read_addr(dev);
 #endif
plat->bank_name = at91_get_bank_name(plat->base_addr);
port->regs = (struct at91_port *)plat->base_addr;
-- 
2.25.1



[PATCH 2/3] ata: mvebu: use dev_read_addr() to get base address

2020-08-03 Thread Masahiro Yamada
It is strange to use devfdt_get_addr_ptr(), then cast the pointer
back to ulong because you could use devfdt_get_addr() without casting.

Convert it to dev_read_addr(), which is capable to CONFIG_OF_LIVE.

Signed-off-by: Masahiro Yamada 
---

 drivers/ata/ahci_mvebu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ata/ahci_mvebu.c b/drivers/ata/ahci_mvebu.c
index 8be1826d40..7d82d2ea3f 100644
--- a/drivers/ata/ahci_mvebu.c
+++ b/drivers/ata/ahci_mvebu.c
@@ -39,7 +39,7 @@ static int mvebu_ahci_probe(struct udevice *dev)
 */
board_ahci_enable();
 
-   ahci_probe_scsi(dev, (ulong)devfdt_get_addr_ptr(dev));
+   ahci_probe_scsi(dev, dev_read_addr(dev));
 
return 0;
 }
-- 
2.25.1



[PATCH 1/5] ARM: uniphier: rename include guard of include/configs/uniphier.h

2020-07-30 Thread Masahiro Yamada
Make the include guard match to the file name.

Signed-off-by: Masahiro Yamada 
---

 include/configs/uniphier.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h
index d0841a7d55f9..1b942cf657db 100644
--- a/include/configs/uniphier.h
+++ b/include/configs/uniphier.h
@@ -7,8 +7,8 @@
 
 /* U-Boot - Common settings for UniPhier Family */
 
-#ifndef __CONFIG_UNIPHIER_COMMON_H__
-#define __CONFIG_UNIPHIER_COMMON_H__
+#ifndef __CONFIG_UNIPHIER_H__
+#define __CONFIG_UNIPHIER_H__
 
 #ifndef CONFIG_SPL_BUILD
 #include 
@@ -213,4 +213,4 @@
 
 #define CONFIG_SPL_PAD_TO  0x2
 
-#endif /* __CONFIG_UNIPHIER_COMMON_H__ */
+#endif /* __CONFIG_UNIPHIER_H__ */
-- 
2.17.1



[PATCH 3/5] ARM: uniphier: remove unneeded header inclusion from board_late_init.c

2020-07-30 Thread Masahiro Yamada
 is unneeded since commit 9248a78f40d6 ("ARM: UniPhier: remove
Denali NAND controller fixup code").

 is uneeded since commit 1320fa2e55d2 ("ARM: uniphier:
remove workaround for the NAND write protect").

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/board_late_init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/mach-uniphier/board_late_init.c 
b/arch/arm/mach-uniphier/board_late_init.c
index b800e8b8c6be..8c5e5bb58f65 100644
--- a/arch/arm/mach-uniphier/board_late_init.c
+++ b/arch/arm/mach-uniphier/board_late_init.c
@@ -9,9 +9,7 @@
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
 #include 
 
 #include "init.h"
@@ -53,6 +51,7 @@ fail:
 
 static void uniphier_set_env_addr(const char *env, const char *offset_env)
 {
+   DECLARE_GLOBAL_DATA_PTR;
unsigned long offset = 0;
const char *str;
char *end;
-- 
2.17.1



[PATCH 5/5] ARM: uniphier: use FIELD_GET() to get access to revision register fields

2020-07-30 Thread Masahiro Yamada
Define register fields as macros, and use FIELD_GET().

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/sg-regs.h  |  5 +
 arch/arm/mach-uniphier/soc-info.c | 21 ++---
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-uniphier/sg-regs.h b/arch/arm/mach-uniphier/sg-regs.h
index f47d10194987..a0fa51a8b7be 100644
--- a/arch/arm/mach-uniphier/sg-regs.h
+++ b/arch/arm/mach-uniphier/sg-regs.h
@@ -10,6 +10,8 @@
 #ifndef UNIPHIER_SG_REGS_H
 #define UNIPHIER_SG_REGS_H
 
+#include 
+
 #ifndef __ASSEMBLY__
 #include 
 #ifdef CONFIG_ARCH_UNIPHIER_V8_MULTI
@@ -24,6 +26,9 @@ extern void __iomem *sg_base;
 
 /* Revision */
 #define SG_REVISION0x
+#define   SG_REVISION_TYPE_MASKGENMASK(23, 16)
+#define   SG_REVISION_MODEL_MASK   GENMASK(10, 8)
+#define   SG_REVISION_REV_MASK GENMASK(4, 0)
 
 /* Memory Configuration */
 #define SG_MEMCONF 0x0400
diff --git a/arch/arm/mach-uniphier/soc-info.c 
b/arch/arm/mach-uniphier/soc-info.c
index f021a8cab330..b0221016d1ef 100644
--- a/arch/arm/mach-uniphier/soc-info.c
+++ b/arch/arm/mach-uniphier/soc-info.c
@@ -4,31 +4,30 @@
  *   Author: Masahiro Yamada 
  */
 
+#include 
 #include 
 #include 
 
 #include "sg-regs.h"
 #include "soc-info.h"
 
-static unsigned int __uniphier_get_revision_field(unsigned int mask,
- unsigned int shift)
-{
-   u32 revision = readl(sg_base + SG_REVISION);
-
-   return (revision >> shift) & mask;
-}
-
 unsigned int uniphier_get_soc_id(void)
 {
-   return __uniphier_get_revision_field(0xff, 16);
+   u32 rev = readl(sg_base + SG_REVISION);
+
+   return FIELD_GET(SG_REVISION_TYPE_MASK, rev);
 }
 
 unsigned int uniphier_get_soc_model(void)
 {
-   return __uniphier_get_revision_field(0x7, 8);
+   u32 rev = readl(sg_base + SG_REVISION);
+
+   return FIELD_GET(SG_REVISION_MODEL_MASK, rev);
 }
 
 unsigned int uniphier_get_soc_revision(void)
 {
-   return __uniphier_get_revision_field(0x1f, 0);
+   u32 rev = readl(sg_base + SG_REVISION);
+
+   return FIELD_GET(SG_REVISION_REV_MASK, rev);
 }
-- 
2.17.1



[PATCH 2/5] ARM: uniphier: remove unused uniphier_pin_init()

2020-07-30 Thread Masahiro Yamada
This function is unused since commit 862274913f8f ("bus:
uniphier-system-bus: move hardware init from board files").

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/Makefile   |  1 -
 arch/arm/mach-uniphier/init.h |  1 -
 arch/arm/mach-uniphier/pinctrl-glue.c | 30 ---
 3 files changed, 32 deletions(-)
 delete mode 100644 arch/arm/mach-uniphier/pinctrl-glue.c

diff --git a/arch/arm/mach-uniphier/Makefile b/arch/arm/mach-uniphier/Makefile
index 38b6d904f466..d333b7091d4b 100644
--- a/arch/arm/mach-uniphier/Makefile
+++ b/arch/arm/mach-uniphier/Makefile
@@ -20,7 +20,6 @@ obj-y += reset.o
 endif
 
 obj-$(CONFIG_MICRO_SUPPORT_CARD) += micro-support-card.o
-obj-y += pinctrl-glue.o
 obj-$(CONFIG_MMC) += mmc-first-dev.o
 obj-y += fdt-fixup.o
 
diff --git a/arch/arm/mach-uniphier/init.h b/arch/arm/mach-uniphier/init.h
index dd978c020804..535c06343d81 100644
--- a/arch/arm/mach-uniphier/init.h
+++ b/arch/arm/mach-uniphier/init.h
@@ -73,7 +73,6 @@ void uniphier_pxs3_clk_init(void);
 unsigned int uniphier_boot_device_raw(void);
 int uniphier_have_internal_stm(void);
 int uniphier_boot_from_backend(void);
-int uniphier_pin_init(const char *pinconfig_name);
 
 #ifdef CONFIG_ARM64
 void uniphier_mem_map_init(unsigned long dram_base, unsigned long dram_size);
diff --git a/arch/arm/mach-uniphier/pinctrl-glue.c 
b/arch/arm/mach-uniphier/pinctrl-glue.c
deleted file mode 100644
index 2e0726469595..
--- a/arch/arm/mach-uniphier/pinctrl-glue.c
+++ /dev/null
@@ -1,30 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2016 Socionext Inc.
- *   Author: Masahiro Yamada 
- */
-
-#include 
-#include 
-#include 
-
-#include "init.h"
-
-int uniphier_pin_init(const char *pinconfig_name)
-{
-   struct udevice *pctldev, *config;
-   int ret;
-
-   ret = uclass_first_device(UCLASS_PINCTRL, );
-   if (ret)
-   return ret;
-
-   device_foreach_child(config, pctldev) {
-   if (strcmp(config->name, pinconfig_name))
-   continue;
-
-   return pinctrl_generic_set_state(pctldev, config);
-   }
-
-   return -ENODEV;
-}
-- 
2.17.1



[PATCH 4/5] serial: uniphier: fix typo in comment

2020-07-30 Thread Masahiro Yamada
Signed-off-by: Masahiro Yamada 
---

 drivers/serial/serial_uniphier.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c
index 4004cb8d48a4..a098028ca001 100644
--- a/drivers/serial/serial_uniphier.c
+++ b/drivers/serial/serial_uniphier.c
@@ -137,7 +137,7 @@ static int uniphier_serial_probe(struct udevice *dev)
 
priv->uartclk = clk_data->clk_rate;
 
-   /* flush the trasmitter empty before changing hw setting */
+   /* flush the trasmitter before changing hw setting */
while (!(readl(priv->membase + UNIPHIER_UART_LSR) & UART_LSR_TEMT))
;
 
-- 
2.17.1



Re: [PATCH] fixdep: fix CONFIG_IS_ENABLED etc. handling

2020-07-17 Thread Masahiro Yamada
On Thu, Jul 9, 2020 at 6:53 AM Stephen Warren  wrote:
>
> From: Stephen Warren 
>
> When fixdep detects CONFIG_IS_ENABLED and other similar macros, it must
> parse the macro parameter to determine which actual CONFIG_ option is
> being referenced. This involves moving a pointer forward through the
> entire CONFIG_ option "word". Currently, the code uses variable q to walk
> through the word, but doesn't actually initialize it to point at the
> parameter before doing so. Consequently, the walking process immediately
> fails since it sees the macro invocatoins's ( rather than the expected
> alpha-numeric characters in the macro parameter. Fix this by adding the
> missing initialization.
>
> Fixes: 67f2ee86ccbe ("kbuild: fixdep: Resync this with v4.17")
> Fixes: 7012865e961c ("gpio: fix test.py for gpio label lookup")
> Signed-off-by: Stephen Warren 
> ---
>  scripts/basic/fixdep.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
> index 24be244d5e6a..958668df5546 100644
> --- a/scripts/basic/fixdep.c
> +++ b/scripts/basic/fixdep.c
> @@ -266,6 +266,7 @@ static void parse_config_file(const char *p)
> (q - p == 9 && !memcmp(p, "IS_MODULE(", 10)) ||
> (q - p == 3 && !memcmp(p, "VAL(", 4))) {
> p = q + 1;
> +   q  = p;
> while (isalnum(*q) || *q == '_')
> q++;
> r = q;
> --
> 2.25.1
>


Sorry, I missed this patch.
Yes, this fixes the bug. Thanks.


Just a nit about the coding style:
There are two spaces after 'q'.




-- 
Best Regards
Masahiro Yamada


[PATCH 1/3] treewide: convert (void *)devfdt_get_addr() to dev_read_addr_ptr()

2020-07-16 Thread Masahiro Yamada
Use the _ptr suffixed variant instead of casting. Also, convert it to
dev_read_addr_ptr(), which is safe to CONFIG_OF_LIVE.

One curious part is an error check like follows in
drivers/watchdog/omap_wdt.c:

priv->regs = (struct wd_timer *)devfdt_get_addr(dev);
if (!priv->regs)
return -EINVAL;

devfdt_get_addr() returns FDT_ADDR_T_NONE (i.e. -1) on error.
So, this code does not catch any error in DT parsing.

dev_read_addr_ptr() returns NULL on error, so this error check
will work.

I generated this commit by the following command:

 $ find . -name .git -prune -o -name '*.[ch]' -type f -print | \
   xargs sed -i -e 's/([^*)]*\*)devfdt_get_addr(/dev_read_addr_ptr(/'

I manually fixed drivers/usb/host/ehci-mx6.c

Signed-off-by: Masahiro Yamada 
---

 drivers/adc/exynos-adc.c| 2 +-
 drivers/clk/renesas/clk-rcar-gen2.c | 2 +-
 drivers/clk/renesas/clk-rcar-gen3.c | 2 +-
 drivers/gpio/gpio-rcar.c| 2 +-
 drivers/gpio/mvebu_gpio.c   | 2 +-
 drivers/gpio/s5p_gpio.c | 2 +-
 drivers/gpio/sunxi_gpio.c   | 2 +-
 drivers/i2c/at91_i2c.c  | 2 +-
 drivers/i2c/davinci_i2c.c   | 2 +-
 drivers/i2c/exynos_hs_i2c.c | 2 +-
 drivers/i2c/s3c24x0_i2c.c   | 2 +-
 drivers/input/tegra-kbc.c   | 2 +-
 drivers/mmc/aspeed_sdhci.c  | 2 +-
 drivers/mmc/atmel_sdhci.c   | 2 +-
 drivers/mmc/ftsdc010_mci.c  | 2 +-
 drivers/mmc/hi6220_dw_mmc.c | 2 +-
 drivers/mmc/iproc_sdhci.c   | 2 +-
 drivers/mmc/msm_sdhci.c | 2 +-
 drivers/mmc/mv_sdhci.c  | 2 +-
 drivers/mmc/socfpga_dw_mmc.c| 2 +-
 drivers/mmc/sti_sdhci.c | 2 +-
 drivers/mmc/xenon_sdhci.c   | 2 +-
 drivers/pci_endpoint/pcie-cadence-ep.c  | 2 +-
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 2 +-
 drivers/pwm/exynos_pwm.c| 2 +-
 drivers/pwm/pwm-imx.c   | 2 +-
 drivers/pwm/pwm-mtk.c   | 2 +-
 drivers/pwm/sunxi_pwm.c | 2 +-
 drivers/serial/serial_arc.c | 2 +-
 drivers/serial/serial_xuartlite.c   | 2 +-
 drivers/spi/atmel_spi.c | 2 +-
 drivers/spi/designware_spi.c| 2 +-
 drivers/spi/exynos_spi.c| 2 +-
 drivers/spi/kirkwood_spi.c  | 2 +-
 drivers/spi/mtk_snfi_spi.c  | 2 +-
 drivers/spi/mvebu_a3700_spi.c   | 2 +-
 drivers/spi/zynq_spi.c  | 2 +-
 drivers/usb/host/ehci-mx5.c | 2 +-
 drivers/usb/host/ehci-mx6.c | 4 ++--
 drivers/usb/host/ehci-omap.c| 2 +-
 drivers/usb/host/ehci-vf.c  | 2 +-
 drivers/usb/host/ohci-da8xx.c   | 2 +-
 drivers/usb/host/ohci-generic.c | 2 +-
 drivers/video/atmel_hlcdfb.c| 2 +-
 drivers/video/tegra.c   | 2 +-
 drivers/watchdog/omap_wdt.c | 2 +-
 46 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/drivers/adc/exynos-adc.c b/drivers/adc/exynos-adc.c
index 12c49fc8ce..b459b57050 100644
--- a/drivers/adc/exynos-adc.c
+++ b/drivers/adc/exynos-adc.c
@@ -106,7 +106,7 @@ int exynos_adc_ofdata_to_platdata(struct udevice *dev)
struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev);
struct exynos_adc_priv *priv = dev_get_priv(dev);
 
-   priv->regs = (struct exynos_adc_v2 *)devfdt_get_addr(dev);
+   priv->regs = dev_read_addr_ptr(dev);
if (priv->regs == (struct exynos_adc_v2 *)FDT_ADDR_T_NONE) {
pr_err("Dev: %s - can't get address!", dev->name);
return -ENODATA;
diff --git a/drivers/clk/renesas/clk-rcar-gen2.c 
b/drivers/clk/renesas/clk-rcar-gen2.c
index 3ed0aa92cb..16da10c8dd 100644
--- a/drivers/clk/renesas/clk-rcar-gen2.c
+++ b/drivers/clk/renesas/clk-rcar-gen2.c
@@ -283,7 +283,7 @@ int gen2_clk_probe(struct udevice *dev)
u32 cpg_mode;
int ret;
 
-   priv->base = (struct gen2_base *)devfdt_get_addr(dev);
+   priv->base = dev_read_addr_ptr(dev);
if (!priv->base)
return -EINVAL;
 
diff --git a/drivers/clk/renesas/clk-rcar-gen3.c 
b/drivers/clk/renesas/clk-rcar-gen3.c
index 15e3833756..30a101fe86 100644
--- a/drivers/clk/renesas/clk-rcar-gen3.c
+++ b/drivers/clk/renesas/clk-rcar-gen3.c
@@ -359,7 +359,7 @@ int gen3_clk_probe(struct udevice *dev)
u32 cpg_mode;
int ret;
 
-   priv->base = (struct gen3_base *)devfdt_get_addr(dev);
+   priv->base = dev_read_addr_ptr(dev);
if (!priv->base)
return -EINVAL;
 
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index c49a041059..a993fd4d70 100644
--- a/drivers/g

[PATCH 2/3] treewide: remove (phys_addr_t) casts from devfdt_get_addr()

2020-07-16 Thread Masahiro Yamada
This cast is unneeded.

Signed-off-by: Masahiro Yamada 
---

 drivers/net/fec_mxc.c | 2 +-
 drivers/net/fsl_mcdmafec.c| 2 +-
 drivers/net/mcffec.c  | 2 +-
 drivers/net/xilinx_axi_emac.c | 2 +-
 drivers/net/xilinx_emaclite.c | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 992180df86..3244b15c1d 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1533,7 +1533,7 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)
struct fec_priv *priv = dev_get_priv(dev);
const char *phy_mode;
 
-   pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
+   pdata->iobase = devfdt_get_addr(dev);
priv->eth = (struct ethernet_regs *)pdata->iobase;
 
pdata->phy_interface = -1;
diff --git a/drivers/net/fsl_mcdmafec.c b/drivers/net/fsl_mcdmafec.c
index 73e92b7a0d..712071cc2b 100644
--- a/drivers/net/fsl_mcdmafec.c
+++ b/drivers/net/fsl_mcdmafec.c
@@ -570,7 +570,7 @@ static int mcdmafec_ofdata_to_platdata(struct udevice *dev)
struct eth_pdata *pdata = dev_get_platdata(dev);
const u32 *val;
 
-   pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
+   pdata->iobase = devfdt_get_addr(dev);
/* Default to 10Mbit/s */
pdata->max_speed = 10;
 
diff --git a/drivers/net/mcffec.c b/drivers/net/mcffec.c
index 697549301f..aef3c09b2c 100644
--- a/drivers/net/mcffec.c
+++ b/drivers/net/mcffec.c
@@ -589,7 +589,7 @@ static int mcffec_ofdata_to_platdata(struct udevice *dev)
struct eth_pdata *pdata = dev_get_platdata(dev);
const u32 *val;
 
-   pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
+   pdata->iobase = devfdt_get_addr(dev);
/* Default to 10Mbit/s */
pdata->max_speed = 10;
 
diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c
index 2cd5596768..35176c545e 100644
--- a/drivers/net/xilinx_axi_emac.c
+++ b/drivers/net/xilinx_axi_emac.c
@@ -722,7 +722,7 @@ static int axi_emac_ofdata_to_platdata(struct udevice *dev)
int offset = 0;
const char *phy_mode;
 
-   pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
+   pdata->iobase = devfdt_get_addr(dev);
priv->iobase = (struct axi_regs *)pdata->iobase;
 
offset = fdtdec_lookup_phandle(gd->fdt_blob, node,
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index 9bdb6798b6..e7f7e6ad1d 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -599,7 +599,7 @@ static int emaclite_ofdata_to_platdata(struct udevice *dev)
struct xemaclite *emaclite = dev_get_priv(dev);
int offset = 0;
 
-   pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
+   pdata->iobase = devfdt_get_addr(dev);
emaclite->regs = (struct emaclite_regs *)ioremap_nocache(pdata->iobase,
 0x1);
 
-- 
2.25.1



[PATCH 3/3] treewide: convert devfdt_get_addr() to dev_read_addr()

2020-07-16 Thread Masahiro Yamada
When you enable CONFIG_OF_LIVE, you will end up with a lot of
conversions.

To generate this commit, I used coccinelle excluding drivers/core/,
include/dm/, and test/

The semantic patch that makes this change is as follows:

  
  @@
  expression dev;
  @@
  -devfdt_get_addr(dev)
  +dev_read_addr(dev)
  

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-snapdragon/clock-snapdragon.c  | 2 +-
 arch/arm/mach-snapdragon/pinctrl-snapdragon.c| 2 +-
 drivers/ata/dwc_ahci.c   | 2 +-
 drivers/clk/altera/clk-agilex.c  | 2 +-
 drivers/clk/altera/clk-arria10.c | 2 +-
 drivers/clk/exynos/clk-exynos7420.c  | 4 ++--
 drivers/clk/uniphier/clk-uniphier-core.c | 2 +-
 drivers/dma/ti-edma3.c   | 2 +-
 drivers/gpio/altera_pio.c| 2 +-
 drivers/gpio/atmel_pio4.c| 2 +-
 drivers/gpio/bcm2835_gpio.c  | 2 +-
 drivers/gpio/da8xx_gpio.c| 2 +-
 drivers/gpio/gpio-rza1.c | 2 +-
 drivers/gpio/gpio-uniphier.c | 2 +-
 drivers/gpio/msm_gpio.c  | 2 +-
 drivers/gpio/mxc_gpio.c  | 2 +-
 drivers/gpio/mxs_gpio.c  | 2 +-
 drivers/gpio/omap_gpio.c | 4 ++--
 drivers/gpio/pm8916_gpio.c   | 2 +-
 drivers/gpio/s5p_gpio.c  | 2 +-
 drivers/gpio/sifive-gpio.c   | 2 +-
 drivers/gpio/vybrid_gpio.c   | 2 +-
 drivers/i2c/i2c-uniphier-f.c | 2 +-
 drivers/i2c/i2c-uniphier.c   | 2 +-
 drivers/i2c/imx_lpi2c.c  | 2 +-
 drivers/i2c/iproc_i2c.c  | 2 +-
 drivers/i2c/mxc_i2c.c| 2 +-
 drivers/i2c/omap24xx_i2c.c   | 2 +-
 drivers/mailbox/tegra-hsp.c  | 2 +-
 drivers/misc/altera_sysid.c  | 2 +-
 drivers/misc/imx8/scu.c  | 2 +-
 drivers/misc/microchip_flexcom.c | 2 +-
 drivers/mmc/bcm2835_sdhci.c  | 2 +-
 drivers/mmc/bcm2835_sdhost.c | 2 +-
 drivers/mmc/bcmstb_sdhci.c   | 2 +-
 drivers/mmc/jz_mmc.c | 2 +-
 drivers/mmc/meson_gx_mmc.c   | 2 +-
 drivers/mmc/omap_hsmmc.c | 4 ++--
 drivers/mmc/sdhci-cadence.c  | 2 +-
 drivers/mmc/sh_mmcif.c   | 2 +-
 drivers/mmc/sh_sdhi.c| 2 +-
 drivers/mmc/tangier_sdhci.c  | 2 +-
 drivers/mmc/tmio-common.c| 2 +-
 drivers/net/ag7xxx.c | 2 +-
 drivers/net/dwc_eth_qos.c| 2 +-
 drivers/net/ethoc.c  | 2 +-
 drivers/net/fec_mxc.c| 2 +-
 drivers/net/fsl_mcdmafec.c   | 2 +-
 drivers/net/ftgmac100.c  | 2 +-
 drivers/net/ftmac100.c   | 2 +-
 drivers/net/ks8851_mll.c | 2 +-
 drivers/net/mcffec.c | 2 +-
 drivers/net/mtk_eth.c| 2 +-
 drivers/net/mvgbe.c  | 2 +-
 drivers/net/mvneta.c | 2 +-
 drivers/net/ravb.c   | 2 +-
 drivers/net/sh_eth.c | 2 +-
 drivers/net/sni_ave.c| 2 +-
 drivers/net/sun8i_emac.c | 2 +-
 drivers/net/sunxi_emac.c | 2 +-
 drivers/net/ti/keystone_net.c| 2 +-
 drivers/net/xilinx_axi_emac.c| 2 +-
 drivers/net/xilinx_emaclite.c| 2 +-
 drivers/pinctrl/ath79/pinctrl_ar933x.c   | 2 +-
 drivers/pinctrl/ath79/pinctrl_qca953x.c  | 2 +-
 drivers/pinctrl/exynos/pinctrl-exynos.c  | 2 +-
 drivers/pinctrl/pinctrl-at91-pio4.c  | 2 +-
 drivers/pinctrl/renesas/pfc-r7s72100.c   | 2 +-
 drivers/pinctrl/renesas/pfc.c| 2 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier-core.c | 2 +-
 drivers/reset/reset-uniphier.c   | 2 +-
 drivers/rtc/mvrtc.c  | 2 +-
 drivers/serial/altera_jtag_uart.c| 2 +-
 drivers/serial/altera_uart.c | 2 +-
 drivers/serial/atmel_usart.c | 2 +-
 drivers/serial/serial_ar933x.c   | 2 +-
 drivers/serial/serial_bcm283x_mu.c   | 2 +-
 drivers/serial/serial_lpuart.c   | 2 +-
 drivers/serial/serial_mcf.c  | 2 +-
 drivers/serial/serial_meson.c| 2 +-
 drivers/serial/serial_msm.c  | 2 +-
 drivers/serial/serial_mxc.c

[PATCH v2 2/2] fdt_support: skip MTD node with "disabled" in fdt_fixup_mtdparts()

2020-07-16 Thread Masahiro Yamada
Currently, fdt_fixup_mtdparts() only checks the compatible property.
It is pointless to fix up the disabled node.

Skip the node if it has the property:

  status = "disabled"

Signed-off-by: Masahiro Yamada 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 common/fdt_support.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index cf09c3c5fb..1ddcc53556 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -955,9 +955,16 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info 
*node_info,
 
for (i = 0; i < node_info_size; i++) {
idx = 0;
-   noff = fdt_node_offset_by_compatible(blob, -1,
-node_info[i].compat);
-   while (noff != -FDT_ERR_NOTFOUND) {
+   noff = -1;
+
+   while ((noff = fdt_node_offset_by_compatible(blob, noff,
+   node_info[i].compat)) >= 0) {
+   const char *prop;
+
+   prop = fdt_getprop(blob, noff, "status", NULL);
+   if (prop && !strcmp(prop, "disabled"))
+   continue;
+
debug("%s: %s, mtd dev type %d\n",
fdt_get_name(blob, noff, 0),
node_info[i].compat, node_info[i].type);
@@ -973,10 +980,6 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info 
*node_info,
if (fdt_node_set_part_info(blob, noff, dev))
return; /* return on error */
}
-
-   /* Jump to next flash node */
-   noff = fdt_node_offset_by_compatible(blob, noff,
-
node_info[i].compat);
}
}
 }
-- 
2.25.1



[PATCH v2 1/2] fdt_support: call mtdparts_init() after finding MTD node to fix up

2020-07-16 Thread Masahiro Yamada
Platform code can call fdt_fixup_mtdparts() in order to hand U-Boot's
MTD partitions over to the Linux device tree.

Currently, fdt_fixup_mtdparts() calls mtdparts_init() in its entry.
If no target MTD device is found, an error message like follows is
displayed:

Device nand0 not found!

This occurs when the same code (e.g. arch/arm/mach-uniphier/fdt-fixup.c)
is shared among several boards, but not all of them support an MTD device.

Parse the DT first, then call mtdparts_init() only when the target MTD
node is found.

Yet, you still need to call mtdparts_init() before device_find().

Signed-off-by: Masahiro Yamada 
Reviewed-by: Simon Glass 
---

Changes in v2:
  - rename 'initialized' to 'inited'

 common/fdt_support.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 3778de5368..cf09c3c5fb 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -951,9 +951,7 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info 
*node_info,
struct mtd_device *dev;
int i, idx;
int noff;
-
-   if (mtdparts_init() != 0)
-   return;
+   bool inited = false;
 
for (i = 0; i < node_info_size; i++) {
idx = 0;
@@ -963,6 +961,13 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info 
*node_info,
debug("%s: %s, mtd dev type %d\n",
fdt_get_name(blob, noff, 0),
node_info[i].compat, node_info[i].type);
+
+   if (!inited) {
+   if (mtdparts_init() != 0)
+   return;
+   inited = true;
+   }
+
dev = device_find(node_info[i].type, idx++);
if (dev) {
if (fdt_node_set_part_info(blob, noff, dev))
-- 
2.25.1



Re: [PATCH 2/2] fdt_support: skip MTD node with "disabled" in fdt_fixup_mtdparts()

2020-07-16 Thread Masahiro Yamada
On Fri, Jul 17, 2020 at 12:44 AM Simon Glass  wrote:
>
> On Wed, 15 Jul 2020 at 04:57, Masahiro Yamada
>  wrote:
> >
> > Currently, fdt_fixup_mtdparts() only checks the compatible property.
> > It is pointless to fix up the disabled node.
> >
> > Skip the node if it has the property:
> >
> >   status = "disabled"
> >
> > Signed-off-by: Masahiro Yamada 
> > ---
> >
> >  common/fdt_support.c | 17 ++---
> >  1 file changed, 10 insertions(+), 7 deletions(-)
>
> Reviewed-by: Simon Glass 
>
> Are there any tests for this code?

No test code.

It makes more effort since
testing this would need to probe an MTD device
as well as parsing DT.



> I am thinking we should migrate fdt_support to use livetree...

One important thing we should notice is we have
two different DT instances:

[1] DT blob for U-Boot   - used for U-Boot driver model
[2] DT blob for Linux- passed when booting Linux


In my understanding, the livetree
is supposed to unflatten [1].

fdt_fixup_mtdparts() is obviously fixing [2].


I do not know how livetree would work
for this function.

-- 
Best Regards
Masahiro Yamada


[PATCH 2/2] fdt_support: skip MTD node with "disabled" in fdt_fixup_mtdparts()

2020-07-15 Thread Masahiro Yamada
Currently, fdt_fixup_mtdparts() only checks the compatible property.
It is pointless to fix up the disabled node.

Skip the node if it has the property:

  status = "disabled"

Signed-off-by: Masahiro Yamada 
---

 common/fdt_support.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 717b2b6354c0..9e7191e22f70 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -955,9 +955,16 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info 
*node_info,
 
for (i = 0; i < node_info_size; i++) {
idx = 0;
-   noff = fdt_node_offset_by_compatible(blob, -1,
-node_info[i].compat);
-   while (noff != -FDT_ERR_NOTFOUND) {
+   noff = -1;
+
+   while ((noff = fdt_node_offset_by_compatible(blob, noff,
+   node_info[i].compat)) >= 0) {
+   const char *prop;
+
+   prop = fdt_getprop(blob, noff, "status", NULL);
+   if (prop && !strcmp(prop, "disabled"))
+   continue;
+
debug("%s: %s, mtd dev type %d\n",
fdt_get_name(blob, noff, 0),
node_info[i].compat, node_info[i].type);
@@ -973,10 +980,6 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info 
*node_info,
if (fdt_node_set_part_info(blob, noff, dev))
return; /* return on error */
}
-
-   /* Jump to next flash node */
-   noff = fdt_node_offset_by_compatible(blob, noff,
-
node_info[i].compat);
}
}
 }
-- 
2.17.1



[PATCH 1/2] fdt_support: call mtdparts_init() after finding MTD node to fix up

2020-07-15 Thread Masahiro Yamada
Platform code can call fdt_fixup_mtdparts() in order to hand U-Boot's
MTD partitions over to the Linux device tree.

Currently, fdt_fixup_mtdparts() calls mtdparts_init() in its entry.
If no target MTD device is found, an error message like follows is
displayed:

Device nand0 not found!

This occurs when the same code (e.g. arch/arm/mach-uniphier/fdt-fixup.c)
is shared among several boards, but not all boards support an MTD device.

Parse the DT first, then call mtdparts_init() only when the target MTD
node is found.

Yet, you still need to call mtdparts_init() before device_find().

Signed-off-by: Masahiro Yamada 
---

 common/fdt_support.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index b010d0b552ad..717b2b6354c0 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -951,9 +951,7 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info 
*node_info,
struct mtd_device *dev;
int i, idx;
int noff;
-
-   if (mtdparts_init() != 0)
-   return;
+   bool initialized = false;
 
for (i = 0; i < node_info_size; i++) {
idx = 0;
@@ -963,6 +961,13 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info 
*node_info,
debug("%s: %s, mtd dev type %d\n",
fdt_get_name(blob, noff, 0),
node_info[i].compat, node_info[i].type);
+
+   if (!initialized) {
+   if (mtdparts_init() != 0)
+   return;
+   initialized = true;
+   }
+
dev = device_find(node_info[i].type, idx++);
if (dev) {
if (fdt_node_set_part_info(blob, noff, dev))
-- 
2.17.1



[PATCH] fdt_support: add static to fdt_node_set_part_info()

2020-07-15 Thread Masahiro Yamada
This function is only called from fdt_fixup_mtdpart() in the same file.

Signed-off-by: Masahiro Yamada 
---

 common/fdt_support.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 3778de536866..b010d0b552ad 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -816,8 +816,8 @@ static int fdt_del_partitions(void *blob, int parent_offset)
return 0;
 }
 
-int fdt_node_set_part_info(void *blob, int parent_offset,
-  struct mtd_device *dev)
+static int fdt_node_set_part_info(void *blob, int parent_offset,
+ struct mtd_device *dev)
 {
struct list_head *pentry;
struct part_info *part;
-- 
2.17.1



[GIT PULL] UniPhier SoC updates for v2020.10

2020-07-11 Thread Masahiro Yamada
Hi Tom,

Please pull changes for v2020.10
Thanks.



The following changes since commit 3113c84ba25ec3ceae072cc5ad450c4238425939:

  Merge tag 'rpi-next-2020.10' of
https://gitlab.denx.de/u-boot/custodians/u-boot-raspberrypi
(2020-07-10 14:31:22 -0400)

are available in the Git repository at:

  https://gitlab.denx.de/u-boot/custodians/u-boot-uniphier.git
tags/uniphier-v2020.10

for you to fetch changes up to 5785950369cd68d4409bf4d0e34d4b1894e5d0e9:

  ARM: uniphier: remove NAND reset code (2020-07-11 21:56:51 +0900)


UniPhier SoC updates for v2020.10

 - remove workaround for Cortex-A72

 - increase U-Boot proper size to 2MB

 - sync DT with Linux

 - add system bus controller driver

 - improve serial driver

 - add reset assertion to Denali NAND driver


Ley Foon Tan (2):
  mtd: nand: raw: denali: Assert reset before deassert
  mtd: nand: raw: denali: Wait for reset completion status

Masahiro Yamada (14):
  Revert "ARM: uniphier: add weird workaround code for LD20"
  ARM: uniphier: increase CONFIG_SYS_MONITOR_LEN to 2MB
  ARM: uniphier: consolidate SoC select menu
  ARM: uniphier: sync with Linux 5.8-rc4
  ARM: uniphier: fix build error when CONFIG_MICRO_SUPPORT_CARD=n
  ARM: uniphier: remove unused uniphier_sbc_init_admulti()
  ARM: uniphier: remove support for NOR Flash on support card
  bus: uniphier-system-bus: add UniPhier System Bus driver
  bus: uniphier-system-bus: move hardware init from board files
  ARM: uniphier: remove sbc/ directory
  serial: uniphier: use register macros instead of structure
  serial: uniphier: flush transmitter before changing hardware settings
  serial: uniphier: enable FIFO
  ARM: uniphier: remove NAND reset code

 arch/arm/dts/uniphier-ld11-global.dts|   1 +
 arch/arm/dts/uniphier-ld11-ref.dts   |   1 +
 arch/arm/dts/uniphier-ld11.dtsi  |  16 ++-
 arch/arm/dts/uniphier-ld20-global.dts|   1 +
 arch/arm/dts/uniphier-ld20-ref.dts   |   1 +
 arch/arm/dts/uniphier-ld20.dtsi  |  28 +---
 arch/arm/dts/uniphier-ld4.dtsi   |   2 +
 arch/arm/dts/uniphier-ld6b-ref.dts   |   1 +
 arch/arm/dts/uniphier-pro4-ace.dts   |   1 +
 arch/arm/dts/uniphier-pro4-ref.dts   |   1 +
 arch/arm/dts/uniphier-pro4.dtsi  |  10 +
 arch/arm/dts/uniphier-pro5.dtsi  |  16 ++-
 arch/arm/dts/uniphier-pxs2-gentil.dts|   1 +
 arch/arm/dts/uniphier-pxs2-vodka.dts |   1 +
 arch/arm/dts/uniphier-pxs2.dtsi  |  16 ++-
 arch/arm/dts/uniphier-pxs3-ref.dts   |  28 
 arch/arm/dts/uniphier-pxs3.dtsi  |  59 +++-
 arch/arm/dts/uniphier-sld8.dtsi  |   2 +
 arch/arm/mach-uniphier/Kconfig   |  34 +++---
 arch/arm/mach-uniphier/Makefile  |   2 -
 arch/arm/mach-uniphier/arm64/Makefile|   1 -
 arch/arm/mach-uniphier/arm64/lowlevel_init.S |  13 --
 arch/arm/mach-uniphier/board_init.c  |  44 --
 arch/arm/mach-uniphier/boot-device/boot-device.c |   9 +++-
 arch/arm/mach-uniphier/init.h|  35 ---
 arch/arm/mach-uniphier/micro-support-card.c  | 110
+
 arch/arm/mach-uniphier/nand-reset.c  |  43 --
 arch/arm/mach-uniphier/sbc/Makefile  |  15 ---
 arch/arm/mach-uniphier/sbc/sbc-boot.c|  13 --
 arch/arm/mach-uniphier/sbc/sbc-ld11.c|  26 ---
 arch/arm/mach-uniphier/sbc/sbc-ld4.c |  25 ---
 arch/arm/mach-uniphier/sbc/sbc-pxs2.c|  23 --
 arch/arm/mach-uniphier/sbc/sbc-regs.h|  82
-
 arch/arm/mach-uniphier/sbc/sbc.c |  95
---
 configs/uniphier_ld4_sld8_defconfig  |   4 --
 configs/uniphier_v7_defconfig|   3 --
 configs/uniphier_v8_defconfig|   3 --
 drivers/Kconfig  |   2 +
 drivers/Makefile |   1 +
 drivers/bus/Kconfig  |  16 +++
 drivers/bus/Makefile |   6 +++
 drivers/bus/uniphier-system-bus.c| 100
+
 drivers/mtd/nand/raw/denali.c|  11 +
 drivers/mtd/nand/raw/denali.h|   1 +
 drivers/mtd/nand/raw/denali_dt.c |   8 +++-
 drivers/serial/serial_uniphier.c |  90
+++--
 include/configs/uniphier.h   |  24 +---

Re: [PATCH 01/10] Revert "ARM: uniphier: add weird workaround code for LD20"

2020-07-11 Thread Masahiro Yamada
On Thu, Jul 9, 2020 at 3:09 PM Masahiro Yamada
 wrote:
>
> This reverts commit 45f41c134baf5ff1bbf59d33027f6c79884fa4d9.
>
> This weird workaround was the best I came up with at that time
> to boot U-Boot from TF-A.
>
> I noticed U-Boot successfully boots on LD20 (i.e. CA72 CPU) by using
> the latest TF-A.
>
> Specifically, since the following TF-A commit, U-Boot runs at EL2
> instead of EL1, and this issue went away as a side-effect.
>
> |commit f998a052fd94ea082833109f25b94ed5bfa24e8b
> |Author: Masahiro Yamada 
> |Date:   Thu Jul 25 10:57:38 2019 +0900
> |
> |uniphier: run BL33 at EL2
> |
> |All the SoCs in 64-bit UniPhier SoC family support EL2.
> |
> |Just hard-code MODE_EL2 instead of using el_implemented() helper.
> |
> |Change-Id: I7ab48002c5205bc8c013e1b46313b57d6c431db0
> |Signed-off-by: Masahiro Yamada 
>
> However, if I reverted that, this problem would come back, presumably
> because some EL1 code in U-Boot triggers this issue.
>
> Now that commit f8ddd8cbb513 ("arm64: issue ISB after updating system
> registers") fixed this issue properly, this weird workaround is no
> longer needed irrespective of the exception level at which U-Boot runs.
>
> Signed-off-by: Masahiro Yamada 
> ---


Series, applied to u-boot-uniphier.



-- 
Best Regards
Masahiro Yamada


Re: [PATCH] ARM: uniphier: remove NAND reset code

2020-07-11 Thread Masahiro Yamada
On Fri, Jul 10, 2020 at 10:32 PM Masahiro Yamada
 wrote:
>
> Now that commit fceee65c878c ("mtd: nand: raw: denali: Assert reset
> before deassert") added the reset assertion, this code in the board
> file is unneeded.
>
> Signed-off-by: Masahiro Yamada 
> ---

Applied to u-boot-uniphier.


>  arch/arm/mach-uniphier/Makefile |  1 -
>  arch/arm/mach-uniphier/board_init.c |  4 ---
>  arch/arm/mach-uniphier/init.h   |  7 -
>  arch/arm/mach-uniphier/nand-reset.c | 43 -
>  4 files changed, 55 deletions(-)
>  delete mode 100644 arch/arm/mach-uniphier/nand-reset.c
>
> diff --git a/arch/arm/mach-uniphier/Makefile b/arch/arm/mach-uniphier/Makefile
> index e7eba75eed..38b6d904f4 100644
> --- a/arch/arm/mach-uniphier/Makefile
> +++ b/arch/arm/mach-uniphier/Makefile
> @@ -22,7 +22,6 @@ endif
>  obj-$(CONFIG_MICRO_SUPPORT_CARD) += micro-support-card.o
>  obj-y += pinctrl-glue.o
>  obj-$(CONFIG_MMC) += mmc-first-dev.o
> -obj-$(CONFIG_NAND_DENALI) += nand-reset.o
>  obj-y += fdt-fixup.o
>
>  endif
> diff --git a/arch/arm/mach-uniphier/board_init.c 
> b/arch/arm/mach-uniphier/board_init.c
> index 39df91982c..528074f547 100644
> --- a/arch/arm/mach-uniphier/board_init.c
> +++ b/arch/arm/mach-uniphier/board_init.c
> @@ -125,10 +125,6 @@ int board_init(void)
> if (initdata->misc_init)
> initdata->misc_init();
>
> -   led_puts("U3");
> -
> -   uniphier_nand_reset_assert();
> -
> led_puts("Uboo");
>
> return 0;
> diff --git a/arch/arm/mach-uniphier/init.h b/arch/arm/mach-uniphier/init.h
> index a20cafdfad..dd978c0208 100644
> --- a/arch/arm/mach-uniphier/init.h
> +++ b/arch/arm/mach-uniphier/init.h
> @@ -75,13 +75,6 @@ int uniphier_have_internal_stm(void);
>  int uniphier_boot_from_backend(void);
>  int uniphier_pin_init(const char *pinconfig_name);
>
> -#ifdef CONFIG_NAND_DENALI
> -void uniphier_nand_reset_assert(void);
> -#else
> -static inline void uniphier_nand_reset_assert(void)
> -{
> -}
> -#endif
>  #ifdef CONFIG_ARM64
>  void uniphier_mem_map_init(unsigned long dram_base, unsigned long dram_size);
>  #else
> diff --git a/arch/arm/mach-uniphier/nand-reset.c 
> b/arch/arm/mach-uniphier/nand-reset.c
> deleted file mode 100644
> index 11cadaabd8..00
> --- a/arch/arm/mach-uniphier/nand-reset.c
> +++ /dev/null
> @@ -1,43 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0 or later
> -/*
> - * Copyright (C) 2020 Socionext Inc.
> - *   Author: Masahiro Yamada 
> - */
> -
> -#include 
> -#include 
> -#include 
> -#include 
> -
> -#include "init.h"
> -
> -/*
> - * Assert the Denali NAND controller reset if found.
> - *
> - * On LD4, the bootstrap process starts running after power-on reset 
> regardless
> - * of the boot mode, here the pin-mux is not necessarily set up for NAND, 
> then
> - * the controller is stuck. Assert the controller reset here, and should be
> - * deasserted in the driver after the pin-mux is correctly handled. For other
> - * SoCs, the bootstrap runs only when the boot mode selects ONFi, but it is 
> yet
> - * effective when the boot swap is on. So, the reset should be asserted 
> anyway.
> - */
> -void uniphier_nand_reset_assert(void)
> -{
> -   struct udevice *dev;
> -   struct reset_ctl_bulk resets;
> -   int ret;
> -
> -   ret = uclass_find_first_device(UCLASS_MTD, );
> -   if (ret || !dev)
> -   return;
> -
> -   /* make sure this is the Denali NAND controller */
> -   if (strcmp(dev->driver->name, "denali-nand-dt"))
> -   return;
> -
> -   ret = reset_get_bulk(dev, );
> -   if (ret)
> -   return;
> -
> -   reset_assert_bulk();
> -}
> --
> 2.25.1
>


-- 
Best Regards
Masahiro Yamada


Re: [PATCH 1/3] serial: uniphier: use register macros instead of structure

2020-07-11 Thread Masahiro Yamada
On Fri, Jul 10, 2020 at 1:13 AM Masahiro Yamada
 wrote:
>
> After all, I am not a big fan of using a structure to represent the
> hardware register map.
>
> You do not need to know the entire register map.
>
> Add only necessary register macros.
>
> Use FIELD_PREP() instead of maintaining a pair of shift and mask.
>
> Signed-off-by: Masahiro Yamada 
> ---

Series, applied to u-boot-uniphier.



>  drivers/serial/serial_uniphier.c | 75 ++--
>  1 file changed, 32 insertions(+), 43 deletions(-)
>
> diff --git a/drivers/serial/serial_uniphier.c 
> b/drivers/serial/serial_uniphier.c
> index c7f46e5598..2ffab004bd 100644
> --- a/drivers/serial/serial_uniphier.c
> +++ b/drivers/serial/serial_uniphier.c
> @@ -7,6 +7,8 @@
>
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -15,77 +17,67 @@
>  #include 
>  #include 
>
> -/*
> - * Note: Register map is slightly different from that of 16550.
> - */
> -struct uniphier_serial {
> -   u32 rx; /* In:  Receive buffer */
> -#define tx rx  /* Out: Transmit buffer */
> -   u32 ier;/* Interrupt Enable Register */
> -   u32 iir;/* In: Interrupt ID Register */
> -   u32 char_fcr;   /* Charactor / FIFO Control Register */
> -   u32 lcr_mcr;/* Line/Modem Control Register */
> -#define LCR_SHIFT  8
> -#define LCR_MASK   (0xff << (LCR_SHIFT))
> -   u32 lsr;/* In: Line Status Register */
> -   u32 msr;/* In: Modem Status Register */
> -   u32 __rsv0;
> -   u32 __rsv1;
> -   u32 dlr;/* Divisor Latch Register */
> -};
> +#define UNIPHIER_UART_REGSHIFT 2
> +
> +#define UNIPHIER_UART_RX   (0 << (UNIPHIER_UART_REGSHIFT))
> +#define UNIPHIER_UART_TX   UNIPHIER_UART_RX
> +/* bit[15:8] = CHAR, bit[7:0] = FCR */
> +#define UNIPHIER_UART_CHAR_FCR (3 << (UNIPHIER_UART_REGSHIFT))
> +/* bit[15:8] = LCR, bit[7:0] = MCR */
> +#define UNIPHIER_UART_LCR_MCR  (4 << (UNIPHIER_UART_REGSHIFT))
> +#define   UNIPHIER_UART_LCR_MASK   GENMASK(15, 8)
> +#define UNIPHIER_UART_LSR  (5 << (UNIPHIER_UART_REGSHIFT))
> +/* Divisor Latch Register */
> +#define UNIPHIER_UART_DLR  (9 << (UNIPHIER_UART_REGSHIFT))
>
>  struct uniphier_serial_priv {
> -   struct uniphier_serial __iomem *membase;
> +   void __iomem *membase;
> unsigned int uartclk;
>  };
>
> -#define uniphier_serial_port(dev)  \
> -   ((struct uniphier_serial_priv *)dev_get_priv(dev))->membase
> -
>  static int uniphier_serial_setbrg(struct udevice *dev, int baudrate)
>  {
> struct uniphier_serial_priv *priv = dev_get_priv(dev);
> -   struct uniphier_serial __iomem *port = uniphier_serial_port(dev);
> -   const unsigned int mode_x_div = 16;
> +   static const unsigned int mode_x_div = 16;
> unsigned int divisor;
>
> divisor = DIV_ROUND_CLOSEST(priv->uartclk, mode_x_div * baudrate);
>
> -   writel(divisor, >dlr);
> +   writel(divisor, priv->membase + UNIPHIER_UART_DLR);
>
> return 0;
>  }
>
>  static int uniphier_serial_getc(struct udevice *dev)
>  {
> -   struct uniphier_serial __iomem *port = uniphier_serial_port(dev);
> +   struct uniphier_serial_priv *priv = dev_get_priv(dev);
>
> -   if (!(readl(>lsr) & UART_LSR_DR))
> +   if (!(readl(priv->membase + UNIPHIER_UART_LSR) & UART_LSR_DR))
> return -EAGAIN;
>
> -   return readl(>rx);
> +   return readl(priv->membase + UNIPHIER_UART_RX);
>  }
>
>  static int uniphier_serial_putc(struct udevice *dev, const char c)
>  {
> -   struct uniphier_serial __iomem *port = uniphier_serial_port(dev);
> +   struct uniphier_serial_priv *priv = dev_get_priv(dev);
>
> -   if (!(readl(>lsr) & UART_LSR_THRE))
> +   if (!(readl(priv->membase + UNIPHIER_UART_LSR) & UART_LSR_THRE))
> return -EAGAIN;
>
> -   writel(c, >tx);
> +   writel(c, priv->membase + UNIPHIER_UART_TX);
>
> return 0;
>  }
>
>  static int uniphier_serial_pending(struct udevice *dev, bool input)
>  {
> -   struct uniphier_serial __iomem *port = uniphier_serial_port(dev);
> +   struct uniphier_serial_priv *priv = dev_get_priv(dev);
>
> if (input)
> -   return readl(>lsr) & UART_LSR_DR;
> +   return readl(priv->membase + UNIPHIER_UART_LSR) & UART_LSR

[PATCH] ARM: uniphier: remove NAND reset code

2020-07-10 Thread Masahiro Yamada
Now that commit fceee65c878c ("mtd: nand: raw: denali: Assert reset
before deassert") added the reset assertion, this code in the board
file is unneeded.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/Makefile |  1 -
 arch/arm/mach-uniphier/board_init.c |  4 ---
 arch/arm/mach-uniphier/init.h   |  7 -
 arch/arm/mach-uniphier/nand-reset.c | 43 -
 4 files changed, 55 deletions(-)
 delete mode 100644 arch/arm/mach-uniphier/nand-reset.c

diff --git a/arch/arm/mach-uniphier/Makefile b/arch/arm/mach-uniphier/Makefile
index e7eba75eed..38b6d904f4 100644
--- a/arch/arm/mach-uniphier/Makefile
+++ b/arch/arm/mach-uniphier/Makefile
@@ -22,7 +22,6 @@ endif
 obj-$(CONFIG_MICRO_SUPPORT_CARD) += micro-support-card.o
 obj-y += pinctrl-glue.o
 obj-$(CONFIG_MMC) += mmc-first-dev.o
-obj-$(CONFIG_NAND_DENALI) += nand-reset.o
 obj-y += fdt-fixup.o
 
 endif
diff --git a/arch/arm/mach-uniphier/board_init.c 
b/arch/arm/mach-uniphier/board_init.c
index 39df91982c..528074f547 100644
--- a/arch/arm/mach-uniphier/board_init.c
+++ b/arch/arm/mach-uniphier/board_init.c
@@ -125,10 +125,6 @@ int board_init(void)
if (initdata->misc_init)
initdata->misc_init();
 
-   led_puts("U3");
-
-   uniphier_nand_reset_assert();
-
led_puts("Uboo");
 
return 0;
diff --git a/arch/arm/mach-uniphier/init.h b/arch/arm/mach-uniphier/init.h
index a20cafdfad..dd978c0208 100644
--- a/arch/arm/mach-uniphier/init.h
+++ b/arch/arm/mach-uniphier/init.h
@@ -75,13 +75,6 @@ int uniphier_have_internal_stm(void);
 int uniphier_boot_from_backend(void);
 int uniphier_pin_init(const char *pinconfig_name);
 
-#ifdef CONFIG_NAND_DENALI
-void uniphier_nand_reset_assert(void);
-#else
-static inline void uniphier_nand_reset_assert(void)
-{
-}
-#endif
 #ifdef CONFIG_ARM64
 void uniphier_mem_map_init(unsigned long dram_base, unsigned long dram_size);
 #else
diff --git a/arch/arm/mach-uniphier/nand-reset.c 
b/arch/arm/mach-uniphier/nand-reset.c
deleted file mode 100644
index 11cadaabd8..00
--- a/arch/arm/mach-uniphier/nand-reset.c
+++ /dev/null
@@ -1,43 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0 or later
-/*
- * Copyright (C) 2020 Socionext Inc.
- *   Author: Masahiro Yamada 
- */
-
-#include 
-#include 
-#include 
-#include 
-
-#include "init.h"
-
-/*
- * Assert the Denali NAND controller reset if found.
- *
- * On LD4, the bootstrap process starts running after power-on reset regardless
- * of the boot mode, here the pin-mux is not necessarily set up for NAND, then
- * the controller is stuck. Assert the controller reset here, and should be
- * deasserted in the driver after the pin-mux is correctly handled. For other
- * SoCs, the bootstrap runs only when the boot mode selects ONFi, but it is yet
- * effective when the boot swap is on. So, the reset should be asserted anyway.
- */
-void uniphier_nand_reset_assert(void)
-{
-   struct udevice *dev;
-   struct reset_ctl_bulk resets;
-   int ret;
-
-   ret = uclass_find_first_device(UCLASS_MTD, );
-   if (ret || !dev)
-   return;
-
-   /* make sure this is the Denali NAND controller */
-   if (strcmp(dev->driver->name, "denali-nand-dt"))
-   return;
-
-   ret = reset_get_bulk(dev, );
-   if (ret)
-   return;
-
-   reset_assert_bulk();
-}
-- 
2.25.1



Re: [PATCH v2 2/2] mtd: nand: raw: denali: Wait for reset completion status

2020-07-10 Thread Masahiro Yamada
On Fri, Jul 10, 2020 at 3:58 PM Ley Foon Tan  wrote:
>
> Fixed delay 200us is not working in certain platforms. Change to
> poll for reset completion status to have more reliable reset process.
>
> Controller will set the rst_comp bit in intr_status register after
> controller has completed its reset and initialization process.
>
> Tested-by: Masahiro Yamada 
> Signed-off-by: Radu Bacrau 
> Signed-off-by: Ley Foon Tan 
>
> ---
> v2:
> - Added "Tested-by" in commit message.
> - Restore "bootstrap process" in comment.
> ---
>  drivers/mtd/nand/raw/denali.c| 11 +++
>  drivers/mtd/nand/raw/denali.h|  1 +
>  drivers/mtd/nand/raw/denali_dt.c | 11 ---
>  3 files changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c
> index 15e90291de09..ab91db85467d 100644
> --- a/drivers/mtd/nand/raw/denali.c
> +++ b/drivers/mtd/nand/raw/denali.c
> @@ -1220,6 +1220,17 @@ static int denali_multidev_fixup(struct 
> denali_nand_info *denali)
> return 0;
>  }
>
> +int denali_wait_reset_complete(struct denali_nand_info *denali)
> +{
> +   u32 irq_status;
> +
> +   irq_status = denali_wait_for_irq(denali, INTR__RST_COMP);
> +   if (!(irq_status & INTR__RST_COMP))
> +   return -EIO;
> +
> +   return 0;
> +}
> +
>  int denali_init(struct denali_nand_info *denali)
>  {
> struct nand_chip *chip = >nand;
> diff --git a/drivers/mtd/nand/raw/denali.h b/drivers/mtd/nand/raw/denali.h
> index 019deda094e5..6cd02b2e26ee 100644
> --- a/drivers/mtd/nand/raw/denali.h
> +++ b/drivers/mtd/nand/raw/denali.h
> @@ -321,6 +321,7 @@ struct denali_nand_info {
>  #define DENALI_CAP_DMA_64BIT   BIT(1)
>
>  int denali_calc_ecc_bytes(int step_size, int strength);
> +int denali_wait_reset_complete(struct denali_nand_info *denali);
>  int denali_init(struct denali_nand_info *denali);
>
>  #endif /* __DENALI_H__ */
> diff --git a/drivers/mtd/nand/raw/denali_dt.c 
> b/drivers/mtd/nand/raw/denali_dt.c
> index 75ad15b0758c..c22b05940df6 100644
> --- a/drivers/mtd/nand/raw/denali_dt.c
> +++ b/drivers/mtd/nand/raw/denali_dt.c
> @@ -154,10 +154,15 @@ static int denali_dt_probe(struct udevice *dev)
>
> /*
>  * When the reset is deasserted, the initialization sequence 
> is
> -* kicked (bootstrap process). The driver must wait until it 
> is
> -* finished. Otherwise, it will result in unpredictable 
> behavior.
> +* kicked (bootstrap proccess). The driver must wait until it


Again, you are touching this comment line with no good reason.
"proccess" is a typo.


I fixed it up and applied.
Thanks.





> +* is finished. Otherwise, it will result in unpredictable
> +* behavior.
>  */
> -   udelay(200);
> +   ret = denali_wait_reset_complete(denali);
> +   if (ret) {
> +   dev_err(denali->dev, "reset not completed.\n");
> +   return ret;
> +   }
> }
>
> return denali_init(denali);
> --
> 2.19.0
>


-- 
Best Regards
Masahiro Yamada


Re: [PATCH v2 1/2] mtd: nand: raw: denali: Assert reset before deassert

2020-07-10 Thread Masahiro Yamada
On Fri, Jul 10, 2020 at 3:58 PM Ley Foon Tan  wrote:
>
> Always put the controller in reset, then take it out of reset.
> This is to make sure controller always in reset state in both SPL and
> proper Uboot.
>
> This is preparation for the next patch to poll for reset completion
> (rst_comp) bit after reset.
>
> Tested-by: Masahiro Yamada 
> Signed-off-by: Radu Bacrau 
> Signed-off-by: Ley Foon Tan 


I will include this in my next pull request.

Applied.
Thanks.




-- 
Best Regards
Masahiro Yamada


Re: [PATCH 1/2] mtd: nand: raw: denali: Assert reset before deassert

2020-07-09 Thread Masahiro Yamada
On Mon, Jun 29, 2020 at 7:11 PM Ley Foon Tan  wrote:
>
> Always put the controller in reset, then take it out of reset.
> This is to make sure controller always in reset state in both SPL and
> proper Uboot.
>
> This is preparation for the next patch to poll for reset completion
> (rst_comp) bit after reset.
>
> Signed-off-by: Radu Bacrau 
> Signed-off-by: Ley Foon Tan 
> ---
>  drivers/mtd/nand/raw/denali_dt.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/mtd/nand/raw/denali_dt.c 
> b/drivers/mtd/nand/raw/denali_dt.c
> index 2728e8098faa..75ad15b0758c 100644
> --- a/drivers/mtd/nand/raw/denali_dt.c
> +++ b/drivers/mtd/nand/raw/denali_dt.c
> @@ -148,6 +148,8 @@ static int denali_dt_probe(struct udevice *dev)
> if (ret) {
> dev_warn(dev, "Can't get reset: %d\n", ret);
> } else {
> +   reset_assert_bulk();
> +   udelay(2);
>     reset_deassert_bulk();
>
> /*


Tested-by: Masahiro Yamada 


-- 
Best Regards
Masahiro Yamada


Re: [PATCH 2/2] mtd: nand: raw: denali: Wait for reset completion status

2020-07-09 Thread Masahiro Yamada
On Mon, Jun 29, 2020 at 7:12 PM Ley Foon Tan  wrote:
>
> Fixed delay 200us is not working in certain platforms. Change to
> poll for reset completion status to have more reliable reset process.
>
> Controller will set the rst_comp bit in intr_status register after
> controller has completed its reset and initialization process.
>
> Signed-off-by: Radu Bacrau 
> Signed-off-by: Ley Foon Tan 
> ---
>  drivers/mtd/nand/raw/denali.c| 11 +++
>  drivers/mtd/nand/raw/denali.h|  1 +
>  drivers/mtd/nand/raw/denali_dt.c | 10 +++---
>  3 files changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c
> index 15e90291de09..ab91db85467d 100644
> --- a/drivers/mtd/nand/raw/denali.c
> +++ b/drivers/mtd/nand/raw/denali.c
> @@ -1220,6 +1220,17 @@ static int denali_multidev_fixup(struct 
> denali_nand_info *denali)
> return 0;
>  }
>
> +int denali_wait_reset_complete(struct denali_nand_info *denali)
> +{
> +   u32 irq_status;
> +
> +   irq_status = denali_wait_for_irq(denali, INTR__RST_COMP);
> +   if (!(irq_status & INTR__RST_COMP))
> +   return -EIO;
> +
> +   return 0;
> +}
> +
>  int denali_init(struct denali_nand_info *denali)
>  {
> struct nand_chip *chip = >nand;
> diff --git a/drivers/mtd/nand/raw/denali.h b/drivers/mtd/nand/raw/denali.h
> index 019deda094e5..6cd02b2e26ee 100644
> --- a/drivers/mtd/nand/raw/denali.h
> +++ b/drivers/mtd/nand/raw/denali.h
> @@ -321,6 +321,7 @@ struct denali_nand_info {
>  #define DENALI_CAP_DMA_64BIT   BIT(1)
>
>  int denali_calc_ecc_bytes(int step_size, int strength);
> +int denali_wait_reset_complete(struct denali_nand_info *denali);
>  int denali_init(struct denali_nand_info *denali);
>
>  #endif /* __DENALI_H__ */
> diff --git a/drivers/mtd/nand/raw/denali_dt.c 
> b/drivers/mtd/nand/raw/denali_dt.c
> index 75ad15b0758c..8a6950f8a39f 100644
> --- a/drivers/mtd/nand/raw/denali_dt.c
> +++ b/drivers/mtd/nand/raw/denali_dt.c
> @@ -154,10 +154,14 @@ static int denali_dt_probe(struct udevice *dev)
>
> /*
>  * When the reset is deasserted, the initialization sequence 
> is
> -* kicked (bootstrap process). The driver must wait until it 
> is
> -* finished. Otherwise, it will result in unpredictable 
> behavior.
> +* kicked. The driver must wait until it is finished. 
> Otherwise,
> +* it will result in unpredictable behavior.


What is your motivation for this hunk of change?
(removal of "bootstrap process")

What was wrong with the current comment block?

The term "bootstrap" appears in the
Cadence (Denali) Flash Controller User Guide.




>  */
> -   udelay(200);
> +   ret = denali_wait_reset_complete(denali);
> +   if (ret) {
> +   dev_err(denali->dev, "reset not completed.\n");
> +   return ret;
> +   }
> }
>
> return denali_init(denali);
> --
> 2.19.0
>


I tested this patch on some of my socionext SoC boards,
and I did not see regression.

Tested-by: Masahiro Yamada 


But, please note this code will diverge from the Linux code.


-- 
Best Regards
Masahiro Yamada


[PATCH 1/3] serial: uniphier: use register macros instead of structure

2020-07-09 Thread Masahiro Yamada
After all, I am not a big fan of using a structure to represent the
hardware register map.

You do not need to know the entire register map.

Add only necessary register macros.

Use FIELD_PREP() instead of maintaining a pair of shift and mask.

Signed-off-by: Masahiro Yamada 
---

 drivers/serial/serial_uniphier.c | 75 ++--
 1 file changed, 32 insertions(+), 43 deletions(-)

diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c
index c7f46e5598..2ffab004bd 100644
--- a/drivers/serial/serial_uniphier.c
+++ b/drivers/serial/serial_uniphier.c
@@ -7,6 +7,8 @@
 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -15,77 +17,67 @@
 #include 
 #include 
 
-/*
- * Note: Register map is slightly different from that of 16550.
- */
-struct uniphier_serial {
-   u32 rx; /* In:  Receive buffer */
-#define tx rx  /* Out: Transmit buffer */
-   u32 ier;/* Interrupt Enable Register */
-   u32 iir;/* In: Interrupt ID Register */
-   u32 char_fcr;   /* Charactor / FIFO Control Register */
-   u32 lcr_mcr;/* Line/Modem Control Register */
-#define LCR_SHIFT  8
-#define LCR_MASK   (0xff << (LCR_SHIFT))
-   u32 lsr;/* In: Line Status Register */
-   u32 msr;/* In: Modem Status Register */
-   u32 __rsv0;
-   u32 __rsv1;
-   u32 dlr;/* Divisor Latch Register */
-};
+#define UNIPHIER_UART_REGSHIFT 2
+
+#define UNIPHIER_UART_RX   (0 << (UNIPHIER_UART_REGSHIFT))
+#define UNIPHIER_UART_TX   UNIPHIER_UART_RX
+/* bit[15:8] = CHAR, bit[7:0] = FCR */
+#define UNIPHIER_UART_CHAR_FCR (3 << (UNIPHIER_UART_REGSHIFT))
+/* bit[15:8] = LCR, bit[7:0] = MCR */
+#define UNIPHIER_UART_LCR_MCR  (4 << (UNIPHIER_UART_REGSHIFT))
+#define   UNIPHIER_UART_LCR_MASK   GENMASK(15, 8)
+#define UNIPHIER_UART_LSR  (5 << (UNIPHIER_UART_REGSHIFT))
+/* Divisor Latch Register */
+#define UNIPHIER_UART_DLR  (9 << (UNIPHIER_UART_REGSHIFT))
 
 struct uniphier_serial_priv {
-   struct uniphier_serial __iomem *membase;
+   void __iomem *membase;
unsigned int uartclk;
 };
 
-#define uniphier_serial_port(dev)  \
-   ((struct uniphier_serial_priv *)dev_get_priv(dev))->membase
-
 static int uniphier_serial_setbrg(struct udevice *dev, int baudrate)
 {
struct uniphier_serial_priv *priv = dev_get_priv(dev);
-   struct uniphier_serial __iomem *port = uniphier_serial_port(dev);
-   const unsigned int mode_x_div = 16;
+   static const unsigned int mode_x_div = 16;
unsigned int divisor;
 
divisor = DIV_ROUND_CLOSEST(priv->uartclk, mode_x_div * baudrate);
 
-   writel(divisor, >dlr);
+   writel(divisor, priv->membase + UNIPHIER_UART_DLR);
 
return 0;
 }
 
 static int uniphier_serial_getc(struct udevice *dev)
 {
-   struct uniphier_serial __iomem *port = uniphier_serial_port(dev);
+   struct uniphier_serial_priv *priv = dev_get_priv(dev);
 
-   if (!(readl(>lsr) & UART_LSR_DR))
+   if (!(readl(priv->membase + UNIPHIER_UART_LSR) & UART_LSR_DR))
return -EAGAIN;
 
-   return readl(>rx);
+   return readl(priv->membase + UNIPHIER_UART_RX);
 }
 
 static int uniphier_serial_putc(struct udevice *dev, const char c)
 {
-   struct uniphier_serial __iomem *port = uniphier_serial_port(dev);
+   struct uniphier_serial_priv *priv = dev_get_priv(dev);
 
-   if (!(readl(>lsr) & UART_LSR_THRE))
+   if (!(readl(priv->membase + UNIPHIER_UART_LSR) & UART_LSR_THRE))
return -EAGAIN;
 
-   writel(c, >tx);
+   writel(c, priv->membase + UNIPHIER_UART_TX);
 
return 0;
 }
 
 static int uniphier_serial_pending(struct udevice *dev, bool input)
 {
-   struct uniphier_serial __iomem *port = uniphier_serial_port(dev);
+   struct uniphier_serial_priv *priv = dev_get_priv(dev);
 
if (input)
-   return readl(>lsr) & UART_LSR_DR;
+   return readl(priv->membase + UNIPHIER_UART_LSR) & UART_LSR_DR;
else
-   return !(readl(>lsr) & UART_LSR_THRE);
+   return !(readl(priv->membase + UNIPHIER_UART_LSR) & 
UART_LSR_THRE);
 }
 
 /*
@@ -113,7 +105,6 @@ static const struct uniphier_serial_clk_data 
uniphier_serial_clk_data[] = {
 static int uniphier_serial_probe(struct udevice *dev)
 {
struct uniphier_serial_priv *priv = dev_get_priv(dev);
-   struct uniphier_serial __iomem *port;
const struct uniphier_serial_clk_data *clk_data;
ofnode root_node;
fdt_addr_t base;
@@ -123,12 +114,10 @@ static int uniphier_serial_probe(struct udevice *dev)
if (base == FDT_ADDR_T_NONE)
return -EINVAL

[PATCH 2/3] serial: uniphier: flush transmitter before changing hardware settings

2020-07-09 Thread Masahiro Yamada
Ensure the transmitter is empty when chaining the baudrate or any
hardware settings. If a character is remaining in the transmitter,
the console will be garbled.

Signed-off-by: Masahiro Yamada 
---

 drivers/serial/serial_uniphier.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c
index 2ffab004bd..aaf8657ee1 100644
--- a/drivers/serial/serial_uniphier.c
+++ b/drivers/serial/serial_uniphier.c
@@ -43,6 +43,10 @@ static int uniphier_serial_setbrg(struct udevice *dev, int 
baudrate)
 
divisor = DIV_ROUND_CLOSEST(priv->uartclk, mode_x_div * baudrate);
 
+   /* flush the trasmitter before changing hw setting */
+   while (!(readl(priv->membase + UNIPHIER_UART_LSR) & UART_LSR_TEMT))
+   ;
+
writel(divisor, priv->membase + UNIPHIER_UART_DLR);
 
return 0;
@@ -132,6 +136,10 @@ static int uniphier_serial_probe(struct udevice *dev)
 
priv->uartclk = clk_data->clk_rate;
 
+   /* flush the trasmitter empty before changing hw setting */
+   while (!(readl(priv->membase + UNIPHIER_UART_LSR) & UART_LSR_TEMT))
+   ;
+
tmp = readl(priv->membase + UNIPHIER_UART_LCR_MCR);
tmp &= ~UNIPHIER_UART_LCR_MASK;
tmp |= FIELD_PREP(UNIPHIER_UART_LCR_MASK, UART_LCR_WLEN8);
-- 
2.25.1



[PATCH 3/3] serial: uniphier: enable FIFO

2020-07-09 Thread Masahiro Yamada
This UART controller is integrated with a FIFO. Enable it.

You can put the next character into the FIFO while the transmitter
is sending out the current character. This works slightly faster.

Signed-off-by: Masahiro Yamada 
---

 drivers/serial/serial_uniphier.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c
index aaf8657ee1..ad691b66da 100644
--- a/drivers/serial/serial_uniphier.c
+++ b/drivers/serial/serial_uniphier.c
@@ -23,6 +23,7 @@
 #define UNIPHIER_UART_TX   UNIPHIER_UART_RX
 /* bit[15:8] = CHAR, bit[7:0] = FCR */
 #define UNIPHIER_UART_CHAR_FCR (3 << (UNIPHIER_UART_REGSHIFT))
+#define   UNIPHIER_UART_FCR_MASK   GENMASK(7, 0)
 /* bit[15:8] = LCR, bit[7:0] = MCR */
 #define UNIPHIER_UART_LCR_MCR  (4 << (UNIPHIER_UART_REGSHIFT))
 #define   UNIPHIER_UART_LCR_MASK   GENMASK(15, 8)
@@ -140,6 +141,12 @@ static int uniphier_serial_probe(struct udevice *dev)
while (!(readl(priv->membase + UNIPHIER_UART_LSR) & UART_LSR_TEMT))
;
 
+   /* enable FIFO */
+   tmp = readl(priv->membase + UNIPHIER_UART_CHAR_FCR);
+   tmp &= ~UNIPHIER_UART_FCR_MASK;
+   tmp |= FIELD_PREP(UNIPHIER_UART_FCR_MASK, UART_FCR_ENABLE_FIFO);
+   writel(tmp, priv->membase + UNIPHIER_UART_CHAR_FCR);
+
tmp = readl(priv->membase + UNIPHIER_UART_LCR_MCR);
tmp &= ~UNIPHIER_UART_LCR_MASK;
tmp |= FIELD_PREP(UNIPHIER_UART_LCR_MASK, UART_LCR_WLEN8);
-- 
2.25.1



[PATCH 02/10] ARM: uniphier: increase CONFIG_SYS_MONITOR_LEN to 2MB

2020-07-09 Thread Masahiro Yamada
I increased the maximum U-Boot proper size from time to time, but
configs/uniphier_v7_defconfig hit the current limit 832KB.

Some historical info:

In the initial support, the max size was 512MB.

Commit 58d702274c09 ("ARM: uniphier: increase CONFIG_SYS_MONITOR_LEN")
increased it to 576KB, and commit 3ce5b1a8d86d ("ARM: uniphier: move
SPL stack address") moved the SPL stack location to avoid the memory
map conflict. It was the solution to increase the size without changing
the NOR boot image map.

commit 1a4bd3a095b2 ("ARM: uniphier: increase CONFIG_SYS_MONITOR_LEN
again") ended up with increasing the max size again, breaking the NOR
boot image map. The limit was set to 832KB, otherwise the SPL stack
would overwrite the U-Boot proper image:
 CONFIG_SPL_STACK - CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header) = 
0xd

To increase CONFIG_SYS_MONITOR_LEN even more, the SPL stack must be
moved somewhere. I put it back to the original location prior to
commit 3ce5b1a8d86d.

With this change, there is no more practical size limit.

Signed-off-by: Masahiro Yamada 
---

 include/configs/uniphier.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h
index 55fa85ed62..2e1204fc86 100644
--- a/include/configs/uniphier.h
+++ b/include/configs/uniphier.h
@@ -53,7 +53,7 @@
 
 #define CONFIG_SYS_MAX_FLASH_SECT  256
 #define CONFIG_SYS_MONITOR_BASE0
-#define CONFIG_SYS_MONITOR_LEN 0x000d  /* 832KB */
+#define CONFIG_SYS_MONITOR_LEN 0x0020  /* 2MB */
 #define CONFIG_SYS_FLASH_BASE  0
 
 /*
@@ -221,7 +221,7 @@
 #define CONFIG_SYS_INIT_SP_ADDR(CONFIG_SYS_TEXT_BASE)
 
 /* only for SPL */
-#define CONFIG_SPL_STACK   (0x0020)
+#define CONFIG_SPL_STACK   (0x0010)
 
 #define CONFIG_SYS_NAND_U_BOOT_OFFS0x2
 
-- 
2.25.1



[PATCH 07/10] ARM: uniphier: remove support for NOR Flash on support card

2020-07-09 Thread Masahiro Yamada
I actually do not see this used these days because eMMC or NAND is used
for non-volatile devices. Dump the burden to maintain this crappy code.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/board_init.c |  4 -
 arch/arm/mach-uniphier/micro-support-card.c | 97 -
 arch/arm/mach-uniphier/sbc/sbc.c|  1 -
 configs/uniphier_ld4_sld8_defconfig |  3 -
 configs/uniphier_v7_defconfig   |  3 -
 configs/uniphier_v8_defconfig   |  3 -
 include/configs/uniphier.h  | 20 -
 7 files changed, 131 deletions(-)

diff --git a/arch/arm/mach-uniphier/board_init.c 
b/arch/arm/mach-uniphier/board_init.c
index 4f9cd6e722..73b0f133ce 100644
--- a/arch/arm/mach-uniphier/board_init.c
+++ b/arch/arm/mach-uniphier/board_init.c
@@ -139,10 +139,6 @@ int board_init(void)
 
led_puts("U3");
 
-   support_card_late_init();
-
-   led_puts("U4");
-
uniphier_nand_reset_assert();
 
led_puts("Uboo");
diff --git a/arch/arm/mach-uniphier/micro-support-card.c 
b/arch/arm/mach-uniphier/micro-support-card.c
index b09ec54e1f..fc266aae98 100644
--- a/arch/arm/mach-uniphier/micro-support-card.c
+++ b/arch/arm/mach-uniphier/micro-support-card.c
@@ -5,7 +5,6 @@
  *   Author: Masahiro Yamada 
  */
 
-#include 
 #include 
 #include 
 #include 
@@ -107,102 +106,6 @@ void support_card_init(void)
support_card_show_revision();
 }
 
-#if defined(CONFIG_MTD_NOR_FLASH)
-
-#include 
-
-struct memory_bank {
-   phys_addr_t base;
-   unsigned long size;
-};
-
-static int mem_is_flash(const struct memory_bank *mem)
-{
-   const int loop = 128;
-   u32 *scratch_addr;
-   u32 saved_value;
-   int ret = 1;
-   int i;
-
-   /* just in case, use the tail of the memory bank */
-   scratch_addr = map_physmem(mem->base + mem->size - sizeof(u32) * loop,
-  sizeof(u32) * loop, MAP_NOCACHE);
-
-   for (i = 0; i < loop; i++, scratch_addr++) {
-   saved_value = readl(scratch_addr);
-   writel(~saved_value, scratch_addr);
-   if (readl(scratch_addr) != saved_value) {
-   /* We assume no memory or SRAM here. */
-   writel(saved_value, scratch_addr);
-   ret = 0;
-   break;
-   }
-   }
-
-   unmap_physmem(scratch_addr, MAP_NOCACHE);
-
-   return ret;
-}
-
-/* {address, size} */
-static const struct memory_bank memory_banks[] = {
-   {0x4200, 0x01f0},
-};
-
-static const struct memory_bank
-*flash_banks_list[CONFIG_SYS_MAX_FLASH_BANKS_DETECT];
-
-phys_addr_t cfi_flash_bank_addr(int i)
-{
-   return flash_banks_list[i]->base;
-}
-
-unsigned long cfi_flash_bank_size(int i)
-{
-   return flash_banks_list[i]->size;
-}
-
-static void detect_num_flash_banks(void)
-{
-   const struct memory_bank *memory_bank, *end;
-
-   cfi_flash_num_flash_banks = 0;
-
-   memory_bank = memory_banks;
-   end = memory_bank + ARRAY_SIZE(memory_banks);
-
-   for (; memory_bank < end; memory_bank++) {
-   if (cfi_flash_num_flash_banks >=
-   CONFIG_SYS_MAX_FLASH_BANKS_DETECT)
-   break;
-
-   if (mem_is_flash(memory_bank)) {
-   flash_banks_list[cfi_flash_num_flash_banks] =
-   memory_bank;
-
-   debug("flash bank found: base = 0x%lx, size = 0x%lx\n",
- (unsigned long)memory_bank->base,
- (unsigned long)memory_bank->size);
-   cfi_flash_num_flash_banks++;
-   }
-   }
-
-   debug("number of flash banks: %d\n", cfi_flash_num_flash_banks);
-}
-#else /* CONFIG_MTD_NOR_FLASH */
-static void detect_num_flash_banks(void)
-{
-};
-#endif /* CONFIG_MTD_NOR_FLASH */
-
-void support_card_late_init(void)
-{
-   if (!support_card_found)
-   return;
-
-   detect_num_flash_banks();
-}
-
 static const u8 ledval_num[] = {
0x7e, /* 0 */
0x0c, /* 1 */
diff --git a/arch/arm/mach-uniphier/sbc/sbc.c b/arch/arm/mach-uniphier/sbc/sbc.c
index 04ed539819..519e67e367 100644
--- a/arch/arm/mach-uniphier/sbc/sbc.c
+++ b/arch/arm/mach-uniphier/sbc/sbc.c
@@ -20,7 +20,6 @@
 /* faster but LED does not work */
 #define SBCTRL0_SAVEPIN_MEM_VALUE  0x5545
 #define SBCTRL1_SAVEPIN_MEM_VALUE  0x06057700
-/* NOR flash needs more wait counts than SRAM */
 #define SBCTRL2_SAVEPIN_MEM_VALUE  0x3409
 #define SBCTRL4_SAVEPIN_MEM_VALUE  0x02110210
 
diff --git a/configs/uniphier_ld4_sld8_defconfig 
b/configs/uniphier_ld4_sld8_defconfig
index cb1e8c9bb7..3c9cab05fa 100644
--- a/configs/uniphier_ld4_sld8_defconfig
+++ b/configs/uniphier_ld4_sld8_defconfig
@@ -17,7 +1

[PATCH 10/10] ARM: uniphier: remove sbc/ directory

2020-07-09 Thread Masahiro Yamada
Now that this directory contains only uniphier_sbc_boot_is_swapped(),
move it to boot-device.c and delete the sbc/ directory entirely.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/Makefile  |  1 -
 arch/arm/mach-uniphier/boot-device/boot-device.c |  9 -
 arch/arm/mach-uniphier/sbc/Makefile  |  3 ---
 arch/arm/mach-uniphier/sbc/sbc-boot.c| 14 --
 arch/arm/mach-uniphier/sbc/sbc-regs.h| 14 --
 5 files changed, 8 insertions(+), 33 deletions(-)
 delete mode 100644 arch/arm/mach-uniphier/sbc/Makefile
 delete mode 100644 arch/arm/mach-uniphier/sbc/sbc-boot.c
 delete mode 100644 arch/arm/mach-uniphier/sbc/sbc-regs.h

diff --git a/arch/arm/mach-uniphier/Makefile b/arch/arm/mach-uniphier/Makefile
index 769778cf50..e7eba75eed 100644
--- a/arch/arm/mach-uniphier/Makefile
+++ b/arch/arm/mach-uniphier/Makefile
@@ -27,7 +27,6 @@ obj-y += fdt-fixup.o
 
 endif
 
-obj-y += sbc/
 obj-y += soc-info.o
 obj-y += boot-device/
 obj-y += clk/
diff --git a/arch/arm/mach-uniphier/boot-device/boot-device.c 
b/arch/arm/mach-uniphier/boot-device/boot-device.c
index 69a35f5fb8..98ff34cfa7 100644
--- a/arch/arm/mach-uniphier/boot-device/boot-device.c
+++ b/arch/arm/mach-uniphier/boot-device/boot-device.c
@@ -14,11 +14,18 @@
 #include 
 
 #include "../init.h"
-#include "../sbc/sbc-regs.h"
 #include "../sg-regs.h"
 #include "../soc-info.h"
 #include "boot-device.h"
 
+#define SBBASE00x58c00100
+#define SBBASE_BANK_ENABLE BIT(0)
+
+static int uniphier_sbc_boot_is_swapped(void)
+{
+   return !(readl(SBBASE0) & SBBASE_BANK_ENABLE);
+}
+
 struct uniphier_boot_device_info {
unsigned int soc_id;
unsigned int boot_device_sel_shift;
diff --git a/arch/arm/mach-uniphier/sbc/Makefile 
b/arch/arm/mach-uniphier/sbc/Makefile
deleted file mode 100644
index 1303c36c89..00
--- a/arch/arm/mach-uniphier/sbc/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-
-obj-y  += sbc-boot.o
diff --git a/arch/arm/mach-uniphier/sbc/sbc-boot.c 
b/arch/arm/mach-uniphier/sbc/sbc-boot.c
deleted file mode 100644
index 4d04c97764..00
--- a/arch/arm/mach-uniphier/sbc/sbc-boot.c
+++ /dev/null
@@ -1,14 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-//
-// Copyright (C) 2011-2014 Panasonic Corporation
-// Copyright (C) 2015-2019 Socionext Inc.
-
-#include 
-
-#define SBBASE00x58c00100
-#define SBBASE_BANK_ENABLE (0x0001)
-
-int uniphier_sbc_boot_is_swapped(void)
-{
-   return !(readl(SBBASE0) & SBBASE_BANK_ENABLE);
-}
diff --git a/arch/arm/mach-uniphier/sbc/sbc-regs.h 
b/arch/arm/mach-uniphier/sbc/sbc-regs.h
deleted file mode 100644
index 3a54b0e68d..00
--- a/arch/arm/mach-uniphier/sbc/sbc-regs.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * UniPhier SBC (System Bus Controller) registers
- *
- * Copyright (C) 2011-2014 Panasonic Corporation
- * Copyright (C) 2015-2016 Socionext Inc.
- */
-
-#ifndef ARCH_SBC_REGS_H
-#define ARCH_SBC_REGS_H
-
-int uniphier_sbc_boot_is_swapped(void);
-
-#endif /* ARCH_SBC_REGS_H */
-- 
2.25.1



[PATCH 06/10] ARM: uniphier: remove unused uniphier_sbc_init_admulti()

2020-07-09 Thread Masahiro Yamada
This was used by the old sLD3 SoC, the support of which was removed
by commit 00aa453ebf56 ("ARM: uniphier: remove sLD3 SoC support").

There is no more user of this function.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/init.h|  5 -
 arch/arm/mach-uniphier/sbc/sbc.c | 34 +---
 2 files changed, 5 insertions(+), 34 deletions(-)

diff --git a/arch/arm/mach-uniphier/init.h b/arch/arm/mach-uniphier/init.h
index 622303786c..ee4605487f 100644
--- a/arch/arm/mach-uniphier/init.h
+++ b/arch/arm/mach-uniphier/init.h
@@ -35,16 +35,11 @@ int uniphier_pro5_init(const struct uniphier_board_data 
*bd);
 int uniphier_pxs2_init(const struct uniphier_board_data *bd);
 
 #if defined(CONFIG_MICRO_SUPPORT_CARD)
-void uniphier_sbc_init_admulti(void);
 void uniphier_sbc_init_savepin(void);
 void uniphier_ld4_sbc_init(void);
 void uniphier_pxs2_sbc_init(void);
 void uniphier_ld11_sbc_init(void);
 #else
-static inline void uniphier_sbc_init_admulti(void)
-{
-}
-
 static inline void uniphier_sbc_init_savepin(void)
 {
 }
diff --git a/arch/arm/mach-uniphier/sbc/sbc.c b/arch/arm/mach-uniphier/sbc/sbc.c
index 2100f49a08..04ed539819 100644
--- a/arch/arm/mach-uniphier/sbc/sbc.c
+++ b/arch/arm/mach-uniphier/sbc/sbc.c
@@ -11,14 +11,6 @@
 #include "../init.h"
 #include "sbc-regs.h"
 
-#define SBCTRL0_ADMULTIPLX_PERI_VALUE  0x3312
-#define SBCTRL1_ADMULTIPLX_PERI_VALUE  0x03005500
-#define SBCTRL2_ADMULTIPLX_PERI_VALUE  0x1420
-
-#define SBCTRL0_ADMULTIPLX_MEM_VALUE   0x3312
-#define SBCTRL1_ADMULTIPLX_MEM_VALUE   0x03005500
-#define SBCTRL2_ADMULTIPLX_MEM_VALUE   0x1410
-
 /* slower but LED works */
 #define SBCTRL0_SAVEPIN_PERI_VALUE 0x5545
 #define SBCTRL1_SAVEPIN_PERI_VALUE 0x07168d00
@@ -46,22 +38,16 @@ int uniphier_sbc_is_enabled(void)
return fdtdec_get_is_enabled(fdt, offset);
 }
 
-static void __uniphier_sbc_init(int savepin)
+void uniphier_sbc_init_savepin(void)
 {
/*
 * Only CS1 is connected to support card.
 * BKSZ[1:0] should be set to "01".
 */
-   if (savepin) {
-   writel(SBCTRL0_SAVEPIN_PERI_VALUE, SBCTRL10);
-   writel(SBCTRL1_SAVEPIN_PERI_VALUE, SBCTRL11);
-   writel(SBCTRL2_SAVEPIN_PERI_VALUE, SBCTRL12);
-   writel(SBCTRL4_SAVEPIN_PERI_VALUE, SBCTRL14);
-   } else {
-   writel(SBCTRL0_ADMULTIPLX_MEM_VALUE, SBCTRL10);
-   writel(SBCTRL1_ADMULTIPLX_MEM_VALUE, SBCTRL11);
-   writel(SBCTRL2_ADMULTIPLX_MEM_VALUE, SBCTRL12);
-   }
+   writel(SBCTRL0_SAVEPIN_PERI_VALUE, SBCTRL10);
+   writel(SBCTRL1_SAVEPIN_PERI_VALUE, SBCTRL11);
+   writel(SBCTRL2_SAVEPIN_PERI_VALUE, SBCTRL12);
+   writel(SBCTRL4_SAVEPIN_PERI_VALUE, SBCTRL14);
 
if (uniphier_sbc_boot_is_swapped()) {
/*
@@ -83,13 +69,3 @@ static void __uniphier_sbc_init(int savepin)
writel(0x0200be01, SBBASE1);
}
 }
-
-void uniphier_sbc_init_admulti(void)
-{
-   __uniphier_sbc_init(0);
-}
-
-void uniphier_sbc_init_savepin(void)
-{
-   __uniphier_sbc_init(1);
-}
-- 
2.25.1



[PATCH 08/10] bus: uniphier-system-bus: add UniPhier System Bus driver

2020-07-09 Thread Masahiro Yamada
Since commit 1517126fdac2 ("ARM: uniphier: select DM_ETH"), DM-based
drivers/net/smc911x.c is compiled, but it is never probed because the
parent node lacks the DM-based driver.

I need a skeleton driver to populate child devices (but the next commit
will move more hardware settings to the this driver).

I put this to drivers/bus/uniphier-system-bus.c because this is the
same path as the driver in Linux kernel.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/Kconfig|  1 +
 drivers/Kconfig   |  2 ++
 drivers/Makefile  |  1 +
 drivers/bus/Kconfig   | 16 
 drivers/bus/Makefile  |  6 ++
 drivers/bus/uniphier-system-bus.c | 14 ++
 6 files changed, 40 insertions(+)
 create mode 100644 drivers/bus/Kconfig
 create mode 100644 drivers/bus/Makefile
 create mode 100644 drivers/bus/uniphier-system-bus.c

diff --git a/arch/arm/mach-uniphier/Kconfig b/arch/arm/mach-uniphier/Kconfig
index e125f50fa6..3a8eee7b84 100644
--- a/arch/arm/mach-uniphier/Kconfig
+++ b/arch/arm/mach-uniphier/Kconfig
@@ -83,6 +83,7 @@ config CACHE_UNIPHIER
 
 config MICRO_SUPPORT_CARD
bool "Use Micro Support Card"
+   depends on UNIPHIER_SYSTEM_BUS
help
  This option provides support for the expansion board, available
  on some UniPhier reference boards.
diff --git a/drivers/Kconfig b/drivers/Kconfig
index e34a22708c..7a839fa1aa 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -10,6 +10,8 @@ source "drivers/ata/Kconfig"
 
 source "drivers/axi/Kconfig"
 
+source "drivers/bus/Kconfig"
+
 source "drivers/block/Kconfig"
 
 source "drivers/bootcount/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index 94e8c5da17..afd159e903 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -74,6 +74,7 @@ ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
 
 obj-y += adc/
 obj-y += ata/
+obj-y += bus/
 obj-$(CONFIG_DM_DEMO) += demo/
 obj-$(CONFIG_BIOSEMU) += bios_emulator/
 obj-y += block/
diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig
new file mode 100644
index 00..07a33c6287
--- /dev/null
+++ b/drivers/bus/Kconfig
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Bus Devices
+#
+
+menu "Bus devices"
+
+config UNIPHIER_SYSTEM_BUS
+   bool "UniPhier System Bus driver"
+   depends on ARCH_UNIPHIER
+   default y
+   help
+ Support for UniPhier System Bus, a simple external bus.  This is
+ needed to use on-board devices connected to UniPhier SoCs.
+
+endmenu
diff --git a/drivers/bus/Makefile b/drivers/bus/Makefile
new file mode 100644
index 00..0b97fc1f8b
--- /dev/null
+++ b/drivers/bus/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for the bus drivers.
+#
+
+obj-$(CONFIG_UNIPHIER_SYSTEM_BUS) += uniphier-system-bus.o
diff --git a/drivers/bus/uniphier-system-bus.c 
b/drivers/bus/uniphier-system-bus.c
new file mode 100644
index 00..c61d795bac
--- /dev/null
+++ b/drivers/bus/uniphier-system-bus.c
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include 
+
+static const struct udevice_id uniphier_system_bus_match[] = {
+   { .compatible = "socionext,uniphier-system-bus" },
+   { /* sentinel */ }
+};
+
+U_BOOT_DRIVER(uniphier_system_bus_driver) = {
+   .name   = "uniphier-system-bus",
+   .id = UCLASS_SIMPLE_BUS,
+   .of_match = uniphier_system_bus_match,
+};
-- 
2.25.1



[PATCH 04/10] ARM: uniphier: sync with Linux 5.8-rc4

2020-07-09 Thread Masahiro Yamada
Signed-off-by: Masahiro Yamada 
---

 arch/arm/dts/uniphier-ld11-global.dts |  1 +
 arch/arm/dts/uniphier-ld11-ref.dts|  1 +
 arch/arm/dts/uniphier-ld11.dtsi   | 16 +++-
 arch/arm/dts/uniphier-ld20-global.dts |  1 +
 arch/arm/dts/uniphier-ld20-ref.dts|  1 +
 arch/arm/dts/uniphier-ld20.dtsi   | 28 ++---
 arch/arm/dts/uniphier-ld4.dtsi|  2 +
 arch/arm/dts/uniphier-ld6b-ref.dts|  1 +
 arch/arm/dts/uniphier-pro4-ace.dts|  1 +
 arch/arm/dts/uniphier-pro4-ref.dts|  1 +
 arch/arm/dts/uniphier-pro4.dtsi   | 10 +
 arch/arm/dts/uniphier-pro5.dtsi   | 16 +++-
 arch/arm/dts/uniphier-pxs2-gentil.dts |  1 +
 arch/arm/dts/uniphier-pxs2-vodka.dts  |  1 +
 arch/arm/dts/uniphier-pxs2.dtsi   | 16 +++-
 arch/arm/dts/uniphier-pxs3-ref.dts| 28 +
 arch/arm/dts/uniphier-pxs3.dtsi   | 59 ++-
 arch/arm/dts/uniphier-sld8.dtsi   |  2 +
 18 files changed, 172 insertions(+), 14 deletions(-)

diff --git a/arch/arm/dts/uniphier-ld11-global.dts 
b/arch/arm/dts/uniphier-ld11-global.dts
index 7968d52435..670e1a76db 100644
--- a/arch/arm/dts/uniphier-ld11-global.dts
+++ b/arch/arm/dts/uniphier-ld11-global.dts
@@ -30,6 +30,7 @@
i2c3 = 
i2c4 = 
i2c5 = 
+   ethernet0 = 
};
 
memory@8000 {
diff --git a/arch/arm/dts/uniphier-ld11-ref.dts 
b/arch/arm/dts/uniphier-ld11-ref.dts
index b8f6273484..693171f82f 100644
--- a/arch/arm/dts/uniphier-ld11-ref.dts
+++ b/arch/arm/dts/uniphier-ld11-ref.dts
@@ -29,6 +29,7 @@
i2c3 = 
i2c4 = 
i2c5 = 
+   ethernet0 = 
};
 
memory@8000 {
diff --git a/arch/arm/dts/uniphier-ld11.dtsi b/arch/arm/dts/uniphier-ld11.dtsi
index e0737ac7f0..104d56d625 100644
--- a/arch/arm/dts/uniphier-ld11.dtsi
+++ b/arch/arm/dts/uniphier-ld11.dtsi
@@ -129,6 +129,8 @@
compatible = "socionext,uniphier-scssi";
status = "disabled";
reg = <0x54006000 0x100>;
+   #address-cells = <1>;
+   #size-cells = <0>;
interrupts = <0 39 4>;
pinctrl-names = "default";
pinctrl-0 = <_spi0>;
@@ -140,11 +142,13 @@
compatible = "socionext,uniphier-scssi";
status = "disabled";
reg = <0x54006100 0x100>;
+   #address-cells = <1>;
+   #size-cells = <0>;
interrupts = <0 216 4>;
pinctrl-names = "default";
pinctrl-0 = <_spi1>;
-   clocks = <_clk 11>;
-   resets = <_rst 11>;
+   clocks = <_clk 12>;
+   resets = <_rst 12>;
};
 
serial0: serial@54006800 {
@@ -566,6 +570,14 @@
};
};
 
+   xdmac: dma-controller@5fc1 {
+   compatible = "socionext,uniphier-xdmac";
+   reg = <0x5fc1 0x5300>;
+   interrupts = <0 188 4>;
+   dma-channels = <16>;
+   #dma-cells = <2>;
+   };
+
aidet: interrupt-controller@5fc2 {
compatible = "socionext,uniphier-ld11-aidet";
reg = <0x5fc2 0x200>;
diff --git a/arch/arm/dts/uniphier-ld20-global.dts 
b/arch/arm/dts/uniphier-ld20-global.dts
index 9ca692ed1b..2c8266 100644
--- a/arch/arm/dts/uniphier-ld20-global.dts
+++ b/arch/arm/dts/uniphier-ld20-global.dts
@@ -30,6 +30,7 @@
i2c3 = 
i2c4 = 
i2c5 = 
+   ethernet0 = 
};
 
memory@8000 {
diff --git a/arch/arm/dts/uniphier-ld20-ref.dts 
b/arch/arm/dts/uniphier-ld20-ref.dts
index 406244a5c8..eeb976e789 100644
--- a/arch/arm/dts/uniphier-ld20-ref.dts
+++ b/arch/arm/dts/uniphier-ld20-ref.dts
@@ -29,6 +29,7 @@
i2c3 = 
i2c4 = 
i2c5 = 
+   ethernet0 = 
};
 
memory@8000 {
diff --git a/arch/arm/dts/uniphier-ld20.dtsi b/arch/arm/dts/uniphier-ld20.dtsi
index 59e4191dfc..a5cd026838 100644
--- a/arch/arm/dts/uniphier-ld20.dtsi
+++ b/arch/arm/dts/uniphier-ld20.dtsi
@@ -234,6 +234,8 @@
compatible = "socionext,uniphier-scssi";
status = "disabled";
reg = <0x54006000 0x100>;
+   #address-cells = <1>;
+   #size-cells = <0&

[PATCH 09/10] bus: uniphier-system-bus: move hardware init from board files

2020-07-09 Thread Masahiro Yamada
Move the bus initialization code to this driver from board files.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/board_init.c |  12 --
 arch/arm/mach-uniphier/init.h   |  23 ---
 arch/arm/mach-uniphier/micro-support-card.c |  13 +-
 arch/arm/mach-uniphier/sbc/Makefile |  14 --
 arch/arm/mach-uniphier/sbc/sbc-boot.c   |   3 +-
 arch/arm/mach-uniphier/sbc/sbc-ld11.c   |  26 
 arch/arm/mach-uniphier/sbc/sbc-ld4.c|  25 
 arch/arm/mach-uniphier/sbc/sbc-pxs2.c   |  23 ---
 arch/arm/mach-uniphier/sbc/sbc-regs.h   |  68 -
 arch/arm/mach-uniphier/sbc/sbc.c|  70 -
 drivers/bus/uniphier-system-bus.c   | 156 
 11 files changed, 170 insertions(+), 263 deletions(-)
 delete mode 100644 arch/arm/mach-uniphier/sbc/sbc-ld11.c
 delete mode 100644 arch/arm/mach-uniphier/sbc/sbc-ld4.c
 delete mode 100644 arch/arm/mach-uniphier/sbc/sbc-pxs2.c
 delete mode 100644 arch/arm/mach-uniphier/sbc/sbc.c

diff --git a/arch/arm/mach-uniphier/board_init.c 
b/arch/arm/mach-uniphier/board_init.c
index 73b0f133ce..39df91982c 100644
--- a/arch/arm/mach-uniphier/board_init.c
+++ b/arch/arm/mach-uniphier/board_init.c
@@ -28,7 +28,6 @@ static void uniphier_ld20_misc_init(void)
 
 struct uniphier_initdata {
unsigned int soc_id;
-   void (*sbc_init)(void);
void (*pll_init)(void);
void (*clk_init)(void);
void (*misc_init)(void);
@@ -38,14 +37,12 @@ static const struct uniphier_initdata uniphier_initdata[] = 
{
 #if defined(CONFIG_ARCH_UNIPHIER_LD4)
{
.soc_id = UNIPHIER_LD4_ID,
-   .sbc_init = uniphier_ld4_sbc_init,
.pll_init = uniphier_ld4_pll_init,
},
 #endif
 #if defined(CONFIG_ARCH_UNIPHIER_PRO4)
{
.soc_id = UNIPHIER_PRO4_ID,
-   .sbc_init = uniphier_sbc_init_savepin,
.pll_init = uniphier_pro4_pll_init,
.clk_init = uniphier_pro4_clk_init,
},
@@ -53,35 +50,30 @@ static const struct uniphier_initdata uniphier_initdata[] = 
{
 #if defined(CONFIG_ARCH_UNIPHIER_SLD8)
{
.soc_id = UNIPHIER_SLD8_ID,
-   .sbc_init = uniphier_ld4_sbc_init,
.pll_init = uniphier_ld4_pll_init,
},
 #endif
 #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
{
.soc_id = UNIPHIER_PRO5_ID,
-   .sbc_init = uniphier_sbc_init_savepin,
.clk_init = uniphier_pro5_clk_init,
},
 #endif
 #if defined(CONFIG_ARCH_UNIPHIER_PXS2)
{
.soc_id = UNIPHIER_PXS2_ID,
-   .sbc_init = uniphier_pxs2_sbc_init,
.clk_init = uniphier_pxs2_clk_init,
},
 #endif
 #if defined(CONFIG_ARCH_UNIPHIER_LD6B)
{
.soc_id = UNIPHIER_LD6B_ID,
-   .sbc_init = uniphier_pxs2_sbc_init,
.clk_init = uniphier_pxs2_clk_init,
},
 #endif
 #if defined(CONFIG_ARCH_UNIPHIER_LD11)
{
.soc_id = UNIPHIER_LD11_ID,
-   .sbc_init = uniphier_ld11_sbc_init,
.pll_init = uniphier_ld11_pll_init,
.clk_init = uniphier_ld11_clk_init,
},
@@ -89,7 +81,6 @@ static const struct uniphier_initdata uniphier_initdata[] = {
 #if defined(CONFIG_ARCH_UNIPHIER_LD20)
{
.soc_id = UNIPHIER_LD20_ID,
-   .sbc_init = uniphier_ld11_sbc_init,
.pll_init = uniphier_ld20_pll_init,
.clk_init = uniphier_ld20_clk_init,
.misc_init = uniphier_ld20_misc_init,
@@ -98,7 +89,6 @@ static const struct uniphier_initdata uniphier_initdata[] = {
 #if defined(CONFIG_ARCH_UNIPHIER_PXS3)
{
.soc_id = UNIPHIER_PXS3_ID,
-   .sbc_init = uniphier_pxs2_sbc_init,
.pll_init = uniphier_pxs3_pll_init,
.clk_init = uniphier_pxs3_clk_init,
},
@@ -118,8 +108,6 @@ int board_init(void)
return -EINVAL;
}
 
-   initdata->sbc_init();
-
support_card_init();
 
led_puts("U0");
diff --git a/arch/arm/mach-uniphier/init.h b/arch/arm/mach-uniphier/init.h
index ee4605487f..a20cafdfad 100644
--- a/arch/arm/mach-uniphier/init.h
+++ b/arch/arm/mach-uniphier/init.h
@@ -34,29 +34,6 @@ int uniphier_sld8_init(const struct uniphier_board_data *bd);
 int uniphier_pro5_init(const struct uniphier_board_data *bd);
 int uniphier_pxs2_init(const struct uniphier_board_data *bd);
 
-#if defined(CONFIG_MICRO_SUPPORT_CARD)
-void uniphier_sbc_init_savepin(void);
-void uniphier_ld4_sbc_init(void);
-void uniphier_pxs2_sbc_init(void);
-void uniphier_ld11_sbc_init(void);
-#else
-static inline void uniphier_sbc_init_savepin(void)
-{
-}
-
-static inline void uniphier_ld4_sbc_init(void)
-{
-}
-
-static inline void uniphier_pxs2_sbc_init(void)
-{
-}
-
-static inline void uniphier_ld11_sbc_init(void)
-{
-}
-#endif
-
 void uniphier

[PATCH 03/10] ARM: uniphier: consolidate SoC select menu

2020-07-09 Thread Masahiro Yamada
Currently, the supports for the following two ARMv7 SoC groups
are exclusive, because the boot ROM loads the SPL to a different
address:

 - LD4, sLD8 (SPL is loaded at 0x0004)
 - Pro4, Pro5, PXs2, LD6b(SPL is loaded at 0x0010)

This limitation exists only when CONFIG_SPL=y.

Instead of using crappy CONFIG options, checking SPL and SPL_TEXT_BASE
is cleaner.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/Kconfig  | 33 +
 configs/uniphier_ld4_sld8_defconfig |  1 -
 2 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/arch/arm/mach-uniphier/Kconfig b/arch/arm/mach-uniphier/Kconfig
index bfb445a602..e125f50fa6 100644
--- a/arch/arm/mach-uniphier/Kconfig
+++ b/arch/arm/mach-uniphier/Kconfig
@@ -3,24 +3,15 @@ if ARCH_UNIPHIER
 config SYS_CONFIG_NAME
default "uniphier"
 
-config ARCH_UNIPHIER_32BIT
-   bool
-   select ARCH_SUPPORT_PSCI
-   select ARMV7_NONSEC
-   select CPU_V7A
-   select CPU_V7_HAS_NONSEC
-
 choice
 prompt "UniPhier SoC select"
-default ARCH_UNIPHIER_V7_MULTI
-
-config ARCH_UNIPHIER_LD4_SLD8
-   bool "UniPhier LD4/sLD8 SoCs"
-   select ARCH_UNIPHIER_32BIT
 
 config ARCH_UNIPHIER_V7_MULTI
-   bool "UniPhier Pro4/Pro5/PXs2/LD6b SoCs"
-   select ARCH_UNIPHIER_32BIT
+   bool "UniPhier V7 SoCs"
+   select ARCH_SUPPORT_PSCI
+   select ARMV7_NONSEC
+   select CPU_V7A
+   select CPU_V7_HAS_NONSEC
 
 config ARCH_UNIPHIER_V8_MULTI
bool "UniPhier V8 SoCs"
@@ -32,32 +23,38 @@ endchoice
 
 config ARCH_UNIPHIER_LD4
bool "Enable UniPhier LD4 SoC support"
-   depends on ARCH_UNIPHIER_LD4_SLD8
+   depends on ARCH_UNIPHIER_V7_MULTI
+   depends on !SPL || SPL_TEXT_BASE = 0x0004
default y
 
 config ARCH_UNIPHIER_SLD8
bool "Enable UniPhier sLD8 SoC support"
-   depends on ARCH_UNIPHIER_LD4_SLD8
+   depends on ARCH_UNIPHIER_V7_MULTI
+   depends on !SPL || SPL_TEXT_BASE = 0x0004
default y
 
 config ARCH_UNIPHIER_PRO4
bool "Enable UniPhier Pro4 SoC support"
depends on ARCH_UNIPHIER_V7_MULTI
+   depends on !SPL || SPL_TEXT_BASE = 0x0010
default y
 
 config ARCH_UNIPHIER_PRO5
bool "Enable UniPhier Pro5 SoC support"
depends on ARCH_UNIPHIER_V7_MULTI
+   depends on !SPL || SPL_TEXT_BASE = 0x0010
default y
 
 config ARCH_UNIPHIER_PXS2
bool "Enable UniPhier Pxs2 SoC support"
depends on ARCH_UNIPHIER_V7_MULTI
+   depends on !SPL || SPL_TEXT_BASE = 0x0010
default y
 
 config ARCH_UNIPHIER_LD6B
bool "Enable UniPhier LD6b SoC support"
depends on ARCH_UNIPHIER_V7_MULTI
+   depends on !SPL || SPL_TEXT_BASE = 0x0010
default y
 
 config ARCH_UNIPHIER_LD11
@@ -78,7 +75,7 @@ config ARCH_UNIPHIER_PXS3
 
 config CACHE_UNIPHIER
bool "Enable the UniPhier L2 cache controller"
-   depends on ARCH_UNIPHIER_32BIT
+   depends on ARCH_UNIPHIER_V7_MULTI
default y
select SYS_CACHE_SHIFT_7
help
@@ -118,5 +115,5 @@ config CMD_DDRMPHY_DUMP
  training; it is useful for the evaluation of DDR Multi PHY training.
 
 config SYS_SOC
-   default "uniphier-v7" if ARCH_UNIPHIER_LD4_SLD8 || 
ARCH_UNIPHIER_V7_MULTI
+   default "uniphier-v7" if ARCH_UNIPHIER_V7_MULTI
 endif
diff --git a/configs/uniphier_ld4_sld8_defconfig 
b/configs/uniphier_ld4_sld8_defconfig
index 2e809cacb5..cb1e8c9bb7 100644
--- a/configs/uniphier_ld4_sld8_defconfig
+++ b/configs/uniphier_ld4_sld8_defconfig
@@ -8,7 +8,6 @@ CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=3
 CONFIG_SPL=y
-CONFIG_ARCH_UNIPHIER_LD4_SLD8=y
 CONFIG_MICRO_SUPPORT_CARD=y
 # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
 CONFIG_BOOTCOMMAND="run ${bootdev}script; run ${bootdev}boot"
-- 
2.25.1



[PATCH 05/10] ARM: uniphier: fix build error when CONFIG_MICRO_SUPPORT_CARD=n

2020-07-09 Thread Masahiro Yamada
If CONFIG_MICRO_SUPPORT_CARD is unset, the build fails due to
function redefinition.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/sbc/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-uniphier/sbc/Makefile 
b/arch/arm/mach-uniphier/sbc/Makefile
index 6c698a3922..1bc912c939 100644
--- a/arch/arm/mach-uniphier/sbc/Makefile
+++ b/arch/arm/mach-uniphier/sbc/Makefile
@@ -3,6 +3,7 @@
 obj-y  += sbc-boot.o
 
 ifndef CONFIG_SPL_BUILD
+ifdef CONFIG_MICRO_SUPPORT_CARD
 obj-y  += sbc.o
 
 obj-$(CONFIG_ARCH_UNIPHIER_LD4)+= sbc-ld4.o
@@ -13,3 +14,4 @@ obj-$(CONFIG_ARCH_UNIPHIER_LD11)  += sbc-ld11.o
 obj-$(CONFIG_ARCH_UNIPHIER_LD20)   += sbc-ld11.o
 obj-$(CONFIG_ARCH_UNIPHIER_PXS3)   += sbc-pxs2.o
 endif
+endif
-- 
2.25.1



[PATCH 01/10] Revert "ARM: uniphier: add weird workaround code for LD20"

2020-07-09 Thread Masahiro Yamada
This reverts commit 45f41c134baf5ff1bbf59d33027f6c79884fa4d9.

This weird workaround was the best I came up with at that time
to boot U-Boot from TF-A.

I noticed U-Boot successfully boots on LD20 (i.e. CA72 CPU) by using
the latest TF-A.

Specifically, since the following TF-A commit, U-Boot runs at EL2
instead of EL1, and this issue went away as a side-effect.

|commit f998a052fd94ea082833109f25b94ed5bfa24e8b
|Author: Masahiro Yamada 
|Date:   Thu Jul 25 10:57:38 2019 +0900
|
|uniphier: run BL33 at EL2
|
|All the SoCs in 64-bit UniPhier SoC family support EL2.
|
|Just hard-code MODE_EL2 instead of using el_implemented() helper.
|
|Change-Id: I7ab48002c5205bc8c013e1b46313b57d6c431db0
|Signed-off-by: Masahiro Yamada 

However, if I reverted that, this problem would come back, presumably
because some EL1 code in U-Boot triggers this issue.

Now that commit f8ddd8cbb513 ("arm64: issue ISB after updating system
registers") fixed this issue properly, this weird workaround is no
longer needed irrespective of the exception level at which U-Boot runs.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/arm64/Makefile|  1 -
 arch/arm/mach-uniphier/arm64/lowlevel_init.S | 13 -
 2 files changed, 14 deletions(-)
 delete mode 100644 arch/arm/mach-uniphier/arm64/lowlevel_init.S

diff --git a/arch/arm/mach-uniphier/arm64/Makefile 
b/arch/arm/mach-uniphier/arm64/Makefile
index c569551120..750c4f756e 100644
--- a/arch/arm/mach-uniphier/arm64/Makefile
+++ b/arch/arm/mach-uniphier/arm64/Makefile
@@ -1,4 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 obj-y += mem_map.o
-obj-$(CONFIG_ARCH_UNIPHIER_LD20) += lowlevel_init.o
diff --git a/arch/arm/mach-uniphier/arm64/lowlevel_init.S 
b/arch/arm/mach-uniphier/arm64/lowlevel_init.S
deleted file mode 100644
index f4e5cbbbd1..00
--- a/arch/arm/mach-uniphier/arm64/lowlevel_init.S
+++ /dev/null
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2017 Socionext Inc.
- */
-
-#include 
-
-ENTRY(lowlevel_init)
-   /* LD20 needs the following code to boot.  I do not know why. */
-   mrs x0, sctlr_el1
-   msr sctlr_el1, x0
-   ret
-ENDPROC(lowlevel_init)
-- 
2.25.1



Re: [PATCH v2] arm64: issue ISB after updating system registers

2020-07-07 Thread Masahiro Yamada
On Mon, Jul 6, 2020 at 1:33 PM Masahiro Yamada
 wrote:
>
> Hi.
>
> On Mon, Jun 29, 2020 at 12:29 AM Masahiro Yamada  wrote:
> >
> > On Wed, Jun 24, 2020 at 11:07 AM Volodymyr Babchuk
> >  wrote:
> > >
> > > ARM Architecture reference manual clearly states that PE pipeline
> > > should be flushed after any change to system registers. Refer to
> > > paragraph "B2.3.5 Memory Barriers" at page B2-92 of "Arm Architecture
> > > Reference Manual ARMv8 for ARMv8-A Architecture Profile" (ARM DDI
> > > 0487B.a).
> > >
> > > Failing to issue instruction memory synchronization barrier can lead
> > > to spurious errors, like synchronous exception when accessing FPU
> > > registers. This is very prominent on CPUs with long instruction
> > > pipeline, like ARM Cortex A72.
> > >
> > > This change fixes the following U-Boot panic:
> > >
> > >  "Synchronous Abort" handler, esr 0x1fe0
> > >  elr: 800948cc lr : 80091e04
> > >  x0 : 801ffdc8 x1 : 00c8
> > >  x2 : 800979d4 x3 : 801ffc60
> > >  x4 : 801ffd40 x5 : ff80ffd8
> > >  x6 : 801ffd70 x7 : 801ffd70
> > >  x8 : 000a x9 : 
> > >  x10: 0044 x11: 
> > >  x12:  x13: 
> > >  x14:  x15: 
> > >  x16: 8008b2e0 x17: 
> > >  x18: 801ffec0 x19: 800957b0
> > >  x20: 00c8 x21: 801ffdc8
> > >  x22: 8009909e x23: 
> > >  x24:  x25: 
> > >  x26:  x27: 
> > >  x28:  x29: 801ffc50
> > >
> > >  Code: a94417e4 a90217e4 a9051fe6 a90617e4 (3d801fe0)
> > >
> > > While executing instruction
> > >
> > >  str q0, [sp, #112]
> > >
> > > in vsnprintf() prologue. This panic was observed only on Cortex A72 so
> > > far.
> > >
> > > This patch places ISBs on other strategic places as well.
> > >
> > > Also, this probably is the right fix for the issue workarounded in the
> > > commit 45f41c13 ("ARM: uniphier: add weird workaround code for LD20")
> >
> >
> > Thanks for addressing this issue.
> > Currently, I do not have a board in hand to test this.
> > (I do not commute to the office due to COVID-19 these days...)
> >
> > I have another SoC board, but it does not integrate CA72.
> > I have ever seen this problem only on CA72.
> >
> > Eventually, I will go to the office, and I can test this.
> > But, you do not need to wait for my test if other people
> > review it.
> >
> > Thank you.
> >
>
>
> Today I tested this patch.
>
> Yes, it fixes the CA72 problem on my board.
>
> Tested-by: Masahiro Yamada 
>


Now that MW is open, I want to see this patch in mainline
because it fixes the CA-72 problem in the right way.


There was no object except two minor comments from Andre.


Can Tom fix up the commit description when he picks it up?


  "... after any change to system registers."
 --->
  "... after changes to some system registers."


  "instruction memory synchronization barrier"
--->
  "instruction synchronization barrier"


Thanks.
-- 
Best Regards
Masahiro Yamada


Re: [PATCH] x86: remove unused setup_pcat_compatibility() stub

2020-07-06 Thread Masahiro Yamada
Simon,

On Tue, Jul 7, 2020 at 3:44 AM Simon Glass  wrote:
>
> Hi Masahiro,
>
> On Sat, 4 Jul 2020 at 11:43, Masahiro Yamada  wrote:
> >
> > 'git grep' did not find any user of this stub.
> >
> > Signed-off-by: Masahiro Yamada 
> > ---
> >
> >  arch/x86/include/asm/u-boot-x86.h |  2 --
> >  arch/x86/lib/zimage.c | 10 --
> >  2 files changed, 12 deletions(-)
> >
>
> See also: 
> http://patchwork.ozlabs.org/project/uboot/patch/20200615035738.248710-21-...@chromium.org/


That's fine if you are removing this function.

Thanks.


-- 
Best Regards
Masahiro Yamada


Re: [PATCH v2] arm64: issue ISB after updating system registers

2020-07-05 Thread Masahiro Yamada
Hi.

On Mon, Jun 29, 2020 at 12:29 AM Masahiro Yamada  wrote:
>
> On Wed, Jun 24, 2020 at 11:07 AM Volodymyr Babchuk
>  wrote:
> >
> > ARM Architecture reference manual clearly states that PE pipeline
> > should be flushed after any change to system registers. Refer to
> > paragraph "B2.3.5 Memory Barriers" at page B2-92 of "Arm Architecture
> > Reference Manual ARMv8 for ARMv8-A Architecture Profile" (ARM DDI
> > 0487B.a).
> >
> > Failing to issue instruction memory synchronization barrier can lead
> > to spurious errors, like synchronous exception when accessing FPU
> > registers. This is very prominent on CPUs with long instruction
> > pipeline, like ARM Cortex A72.
> >
> > This change fixes the following U-Boot panic:
> >
> >  "Synchronous Abort" handler, esr 0x1fe0
> >  elr: 800948cc lr : 80091e04
> >  x0 : 801ffdc8 x1 : 00c8
> >  x2 : 800979d4 x3 : 801ffc60
> >  x4 : 801ffd40 x5 : ff80ffd8
> >  x6 : 801ffd70 x7 : 801ffd70
> >  x8 : 000a x9 : 
> >  x10: 0044 x11: 
> >  x12:  x13: 
> >  x14:  x15: 
> >  x16: 8008b2e0 x17: 
> >  x18: 801ffec0 x19: 800957b0
> >  x20: 00c8 x21: 801ffdc8
> >  x22: 8009909e x23: 
> >  x24:  x25: 
> >  x26:  x27: 
> >  x28:  x29: 801ffc50
> >
> >  Code: a94417e4 a90217e4 a9051fe6 a90617e4 (3d801fe0)
> >
> > While executing instruction
> >
> >  str q0, [sp, #112]
> >
> > in vsnprintf() prologue. This panic was observed only on Cortex A72 so
> > far.
> >
> > This patch places ISBs on other strategic places as well.
> >
> > Also, this probably is the right fix for the issue workarounded in the
> > commit 45f41c13 ("ARM: uniphier: add weird workaround code for LD20")
>
>
> Thanks for addressing this issue.
> Currently, I do not have a board in hand to test this.
> (I do not commute to the office due to COVID-19 these days...)
>
> I have another SoC board, but it does not integrate CA72.
> I have ever seen this problem only on CA72.
>
> Eventually, I will go to the office, and I can test this.
> But, you do not need to wait for my test if other people
> review it.
>
> Thank you.
>


Today I tested this patch.

Yes, it fixes the CA72 problem on my board.

Tested-by: Masahiro Yamada 



After this patch is picked up,
I will revert the ugly workaround:

http://patchwork.ozlabs.org/project/uboot/patch/20200706042304.15853-1-yamada.masah...@socionext.com/

Interestingly, I observe this problem
only on U-Boot running at EL1.

Anyway, this fix makes it work at
any exception level.

--
Best Regards
Masahiro Yamada


[PATCH] Revert "ARM: uniphier: add weird workaround code for LD20"

2020-07-05 Thread Masahiro Yamada
This reverts commit 45f41c134baf5ff1bbf59d33027f6c79884fa4d9.

This weird workaround was the best I came up with at that time
to boot U-Boot from TF-A.

I noticed U-Boot successfully boots on LD20 (i.e. CA72 CPU) by using
the latest TF-A.

Specifically, since the following TF-A commit, U-Boot runs at EL2
instead of EL1, and this issue does not happen:

|commit f998a052fd94ea082833109f25b94ed5bfa24e8b
|Author: Masahiro Yamada 
|Date:   Thu Jul 25 10:57:38 2019 +0900
|
|uniphier: run BL33 at EL2
|
|All the SoCs in 64-bit UniPhier SoC family support EL2.
|
|Just hard-code MODE_EL2 instead of using el_implemented() helper.
|
|Change-Id: I7ab48002c5205bc8c013e1b46313b57d6c431db0
|Signed-off-by: Masahiro Yamada 

However, if I revert that, U-Boot hangs on LD20, presumably because
some EL1 code in U-Boot triggers this issue.

Now that commit "arm64: issue ISB after updating system registers"
fixes this issue properly, this weird workaround is unneeded
irrespective of the exception level at which U-Boot runs.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/arm64/Makefile|  1 -
 arch/arm/mach-uniphier/arm64/lowlevel_init.S | 13 -
 2 files changed, 14 deletions(-)
 delete mode 100644 arch/arm/mach-uniphier/arm64/lowlevel_init.S

diff --git a/arch/arm/mach-uniphier/arm64/Makefile 
b/arch/arm/mach-uniphier/arm64/Makefile
index c569551120c7..750c4f756edb 100644
--- a/arch/arm/mach-uniphier/arm64/Makefile
+++ b/arch/arm/mach-uniphier/arm64/Makefile
@@ -1,4 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 obj-y += mem_map.o
-obj-$(CONFIG_ARCH_UNIPHIER_LD20) += lowlevel_init.o
diff --git a/arch/arm/mach-uniphier/arm64/lowlevel_init.S 
b/arch/arm/mach-uniphier/arm64/lowlevel_init.S
deleted file mode 100644
index f4e5cbbbd1cc..
--- a/arch/arm/mach-uniphier/arm64/lowlevel_init.S
+++ /dev/null
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2017 Socionext Inc.
- */
-
-#include 
-
-ENTRY(lowlevel_init)
-   /* LD20 needs the following code to boot.  I do not know why. */
-   mrs x0, sctlr_el1
-   msr sctlr_el1, x0
-   ret
-ENDPROC(lowlevel_init)
-- 
2.17.1



[PATCH] x86: remove unused setup_pcat_compatibility() stub

2020-07-04 Thread Masahiro Yamada
'git grep' did not find any user of this stub.

Signed-off-by: Masahiro Yamada 
---

 arch/x86/include/asm/u-boot-x86.h |  2 --
 arch/x86/lib/zimage.c | 10 --
 2 files changed, 12 deletions(-)

diff --git a/arch/x86/include/asm/u-boot-x86.h 
b/arch/x86/include/asm/u-boot-x86.h
index 3e5d56d075..054203584b 100644
--- a/arch/x86/include/asm/u-boot-x86.h
+++ b/arch/x86/include/asm/u-boot-x86.h
@@ -75,8 +75,6 @@ int default_print_cpuinfo(void);
 /* Set up a UART which can be used with printch(), printhex8(), etc. */
 int setup_internal_uart(int enable);
 
-void setup_pcat_compatibility(void);
-
 void isa_unmap_rom(u32 addr);
 u32 isa_map_rom(u32 bus_addr, int size);
 
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index 64d14e8911..d2b6002008 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -304,13 +304,6 @@ int setup_zimage(struct boot_params *setup_base, char 
*cmd_line, int auto_boot,
return 0;
 }
 
-void setup_pcat_compatibility(void)
-   __attribute__((weak, alias("__setup_pcat_compatibility")));
-
-void __setup_pcat_compatibility(void)
-{
-}
-
 int do_zboot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct boot_params *base_ptr;
@@ -323,9 +316,6 @@ int do_zboot(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
 
disable_interrupts();
 
-   /* Setup board for maximum PC/AT Compatibility */
-   setup_pcat_compatibility();
-
if (argc >= 2) {
/* argv[1] holds the address of the bzImage */
s = argv[1];
-- 
2.25.1



Re: [PATCH v2] arm64: issue ISB after updating system registers

2020-06-28 Thread Masahiro Yamada
On Wed, Jun 24, 2020 at 11:07 AM Volodymyr Babchuk
 wrote:
>
> ARM Architecture reference manual clearly states that PE pipeline
> should be flushed after any change to system registers. Refer to
> paragraph "B2.3.5 Memory Barriers" at page B2-92 of "Arm Architecture
> Reference Manual ARMv8 for ARMv8-A Architecture Profile" (ARM DDI
> 0487B.a).
>
> Failing to issue instruction memory synchronization barrier can lead
> to spurious errors, like synchronous exception when accessing FPU
> registers. This is very prominent on CPUs with long instruction
> pipeline, like ARM Cortex A72.
>
> This change fixes the following U-Boot panic:
>
>  "Synchronous Abort" handler, esr 0x1fe0
>  elr: 800948cc lr : 80091e04
>  x0 : 801ffdc8 x1 : 00c8
>  x2 : 800979d4 x3 : 801ffc60
>  x4 : 801ffd40 x5 : ff80ffd8
>  x6 : 801ffd70 x7 : 801ffd70
>  x8 : 000a x9 : 
>  x10: 0044 x11: 
>  x12:  x13: 
>  x14:  x15: 
>  x16: 8008b2e0 x17: 
>  x18: 801ffec0 x19: 800957b0
>  x20: 00c8 x21: 801ffdc8
>  x22: 8009909e x23: 
>  x24:  x25: 
>  x26:  x27: 
>  x28:  x29: 801ffc50
>
>  Code: a94417e4 a90217e4 a9051fe6 a90617e4 (3d801fe0)
>
> While executing instruction
>
>  str q0, [sp, #112]
>
> in vsnprintf() prologue. This panic was observed only on Cortex A72 so
> far.
>
> This patch places ISBs on other strategic places as well.
>
> Also, this probably is the right fix for the issue workarounded in the
> commit 45f41c13 ("ARM: uniphier: add weird workaround code for LD20")


Thanks for addressing this issue.
Currently, I do not have a board in hand to test this.
(I do not commute to the office due to COVID-19 these days...)

I have another SoC board, but it does not integrate CA72.
I have ever seen this problem only on CA72.

Eventually, I will go to the office, and I can test this.
But, you do not need to wait for my test if other people
review it.

Thank you.







> Reported-by: Oleksandr Andrushchenko 
> Suggested-by: Julien Grall 
> Signed-off-by: Volodymyr Babchuk 
> CC: Tom Rini 
> CC: Masahiro Yamada 
> CC: Stefano Stabellini 
>
> --
>
> Changes from v1:
>  - Added ISBs under CONFIG_ARMV8_SET_SMPEN and erratas.
>  - Added Stefano, Julien and Oleksandr
> ---
>  arch/arm/cpu/armv8/start.S | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S
> index 99d126660d..002698b501 100644
> --- a/arch/arm/cpu/armv8/start.S
> +++ b/arch/arm/cpu/armv8/start.S
> @@ -120,6 +120,7 @@ pie_fixup_done:
> mov x0, #3 << 20
> msr cpacr_el1, x0   /* Enable FP/SIMD */
>  0:
> +   isb
>
> /*
>  * Enable SMPEN bit for coherency.
> @@ -132,6 +133,7 @@ pie_fixup_done:
> mrs x0, S3_1_c15_c2_1   /* cpuectlr_el1 */
> orr x0, x0, #0x40
> msr S3_1_c15_c2_1, x0
> +   isb
>  1:
>  #endif
>
> @@ -233,6 +235,7 @@ apply_a53_core_errata:
> /* Enable data cache clean as data cache clean/invalidate */
> orr x0, x0, #1 << 44
> msr S3_1_c15_c2_0, x0   /* cpuactlr_el1 */
> +   isb
>  #endif
> b 0b
>
> @@ -247,6 +250,7 @@ apply_a57_core_errata:
> /* Disable write streaming no-allocate threshold */
> orr x0, x0, #3 << 27
> msr S3_1_c15_c2_0, x0   /* cpuactlr_el1 */
> +   isb
>  #endif
>
>  #ifdef CONFIG_ARM_ERRATA_826974
> @@ -254,6 +258,7 @@ apply_a57_core_errata:
> /* Disable speculative load execution ahead of a DMB */
> orr x0, x0, #1 << 59
> msr S3_1_c15_c2_0, x0   /* cpuactlr_el1 */
> +   isb
>  #endif
>
>  #ifdef CONFIG_ARM_ERRATA_833471
> @@ -263,6 +268,7 @@ apply_a57_core_errata:
> could impact performance. */
> orr x0, x0, #1 << 38
> msr S3_1_c15_c2_0, x0   /* cpuactlr_el1 */
> +   isb
>  #endif
>
>  #ifdef CONFIG_ARM_ERRATA_829520
> @@ -273,6 +279,7 @@ apply_a57_core_errata:
> could impact performance. */
> orr x0, x0, #1 << 4
>     msr S3_1_c15_c2_0, x0   /* cpuactlr_el1 */
> +   isb
>  #endif
>
>  #ifdef CONFIG_ARM_ERRATA_833069
> @@ -280,6 +287,7 @@ apply_a57_core_errata:
> /* Disable Enable Invalidates of BTB bit */
> and x0, x0, #0xE
> msr S3_1_c15_c2_0, x0   /* cpuactlr_el1 */
> +   isb
>  #endif
> b 0b
>  ENDPROC(apply_core_errata)
> --
> 2.27.0



--
Best Regards
Masahiro Yamada


[PATCH 3/3] asm/u-boot.h: remove bd_t definitions

2020-06-26 Thread Masahiro Yamada
All the users of bd_t were converted to struct bd_info.

Remove the definitions.

Signed-off-by: Masahiro Yamada 
---

 arch/nds32/include/asm/u-boot.h | 5 ++---
 arch/riscv/include/asm/u-boot.h | 5 ++---
 include/asm-generic/u-boot.h| 4 ++--
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/arch/nds32/include/asm/u-boot.h b/arch/nds32/include/asm/u-boot.h
index 8c949e7fb7..815cb93030 100644
--- a/arch/nds32/include/asm/u-boot.h
+++ b/arch/nds32/include/asm/u-boot.h
@@ -21,8 +21,7 @@
 
 #include 
 
-
-typedef struct bd_info {
+struct bd_info {
unsigned long   bi_arch_number; /* unique id for this board */
unsigned long   bi_boot_params; /* where this board expects params */
unsigned long   bi_memstart;/* start of DRAM memory */
@@ -37,7 +36,7 @@ typedef struct bd_info {
unsigned long start;
unsigned long size;
} bi_dram[CONFIG_NR_DRAM_BANKS];
-} bd_t;
+};
 
 /* For image.h:image_check_target_arch() */
 #define IH_ARCH_DEFAULT IH_ARCH_NDS32
diff --git a/arch/riscv/include/asm/u-boot.h b/arch/riscv/include/asm/u-boot.h
index 5ba8e77812..dac20bffda 100644
--- a/arch/riscv/include/asm/u-boot.h
+++ b/arch/riscv/include/asm/u-boot.h
@@ -20,8 +20,7 @@
 
 #include 
 
-
-typedef struct bd_info {
+struct bd_info {
unsigned long   bi_boot_params; /* where this board expects params */
unsigned long   bi_memstart;/* start of DRAM memory */
unsigned long   bi_memsize; /* size  of DRAM memory in bytes */
@@ -35,7 +34,7 @@ typedef struct bd_info {
unsigned long start;
unsigned long size;
} bi_dram[CONFIG_NR_DRAM_BANKS];
-} bd_t;
+};
 
 /* For image.h:image_check_target_arch() */
 #define IH_ARCH_DEFAULT IH_ARCH_RISCV
diff --git a/include/asm-generic/u-boot.h b/include/asm-generic/u-boot.h
index 6f749736f1..4bf06fb379 100644
--- a/include/asm-generic/u-boot.h
+++ b/include/asm-generic/u-boot.h
@@ -26,7 +26,7 @@
 #include 
 #include 
 
-typedef struct bd_info {
+struct bd_info {
unsigned long   bi_memstart;/* start of DRAM memory */
phys_size_t bi_memsize; /* size  of DRAM memory in bytes */
unsigned long   bi_flashstart;  /* start of FLASH memory */
@@ -94,7 +94,7 @@ typedef struct bd_info {
phys_size_t size;
} bi_dram[CONFIG_NR_DRAM_BANKS];
 #endif /* CONFIG_NR_DRAM_BANKS */
-} bd_t;
+};
 
 #endif /* __ASSEMBLY__ */
 
-- 
2.25.1



[PATCH 2/3] treewide: convert bd_t to struct bd_info manually

2020-06-26 Thread Masahiro Yamada
Some code was not converted by coccinelle, somehow.

I manually fixed up the remaining, and comments, README docs.

Signed-off-by: Masahiro Yamada 
---

 arch/m68k/cpu/mcf523x/cpu.c   | 2 +-
 arch/m68k/cpu/mcf52x2/cpu.c   | 2 +-
 arch/m68k/cpu/mcf532x/cpu.c   | 2 +-
 arch/m68k/cpu/mcf5445x/cpu.c  | 2 +-
 arch/m68k/cpu/mcf547x_8x/cpu.c| 2 +-
 cmd/bootm.c   | 2 +-
 doc/README.POST   | 6 +++---
 doc/README.arm-relocation | 4 ++--
 doc/README.atmel_mci  | 2 +-
 doc/README.console| 2 +-
 doc/README.generic-board  | 2 +-
 doc/driver-model/ethernet.rst | 2 +-
 drivers/net/fec_mxc.c | 4 ++--
 drivers/net/ldpaa_eth/ldpaa_eth.c | 2 +-
 drivers/net/smc911x.c | 2 +-
 15 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/arch/m68k/cpu/mcf523x/cpu.c b/arch/m68k/cpu/mcf523x/cpu.c
index a3a79fb4d2..8664231b5a 100644
--- a/arch/m68k/cpu/mcf523x/cpu.c
+++ b/arch/m68k/cpu/mcf523x/cpu.c
@@ -105,7 +105,7 @@ int watchdog_init(void)
 #if defined(CONFIG_MCFFEC)
 /* Default initializations for MCFFEC controllers.  To override,
  * create a board-specific function called:
- * int board_eth_init(bd_t *bis)
+ * int board_eth_init(struct bd_info *bis)
  */
 
 int cpu_eth_init(struct bd_info *bis)
diff --git a/arch/m68k/cpu/mcf52x2/cpu.c b/arch/m68k/cpu/mcf52x2/cpu.c
index 1ca28e46ce..8898a7562a 100644
--- a/arch/m68k/cpu/mcf52x2/cpu.c
+++ b/arch/m68k/cpu/mcf52x2/cpu.c
@@ -420,7 +420,7 @@ int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
 #if defined(CONFIG_MCFFEC)
 /* Default initializations for MCFFEC controllers.  To override,
  * create a board-specific function called:
- * int board_eth_init(bd_t *bis)
+ * int board_eth_init(struct bd_info *bis)
  */
 
 int cpu_eth_init(struct bd_info *bis)
diff --git a/arch/m68k/cpu/mcf532x/cpu.c b/arch/m68k/cpu/mcf532x/cpu.c
index 805108f7ac..f1e6f734eb 100644
--- a/arch/m68k/cpu/mcf532x/cpu.c
+++ b/arch/m68k/cpu/mcf532x/cpu.c
@@ -147,7 +147,7 @@ int watchdog_init(void)
 #if defined(CONFIG_MCFFEC)
 /* Default initializations for MCFFEC controllers.  To override,
  * create a board-specific function called:
- * int board_eth_init(bd_t *bis)
+ * int board_eth_init(struct bd_info *bis)
  */
 int cpu_eth_init(struct bd_info *bis)
 {
diff --git a/arch/m68k/cpu/mcf5445x/cpu.c b/arch/m68k/cpu/mcf5445x/cpu.c
index f5c1947b22..ebe15ca518 100644
--- a/arch/m68k/cpu/mcf5445x/cpu.c
+++ b/arch/m68k/cpu/mcf5445x/cpu.c
@@ -109,7 +109,7 @@ int print_cpuinfo(void)
 #if defined(CONFIG_MCFFEC)
 /* Default initializations for MCFFEC controllers.  To override,
  * create a board-specific function called:
- * int board_eth_init(bd_t *bis)
+ * int board_eth_init(struct bd_info *bis)
  */
 
 int cpu_eth_init(struct bd_info *bis)
diff --git a/arch/m68k/cpu/mcf547x_8x/cpu.c b/arch/m68k/cpu/mcf547x_8x/cpu.c
index 76d2e77fc0..e53adeb46b 100644
--- a/arch/m68k/cpu/mcf547x_8x/cpu.c
+++ b/arch/m68k/cpu/mcf547x_8x/cpu.c
@@ -136,7 +136,7 @@ int watchdog_init(void)
 #if defined(CONFIG_FSLDMAFEC) || defined(CONFIG_MCFFEC)
 /* Default initializations for MCFFEC controllers.  To override,
  * create a board-specific function called:
- * int board_eth_init(bd_t *bis)
+ * int board_eth_init(struct bd_info *bis)
  */
 
 int cpu_eth_init(struct bd_info *bis)
diff --git a/cmd/bootm.c b/cmd/bootm.c
index d5f877cb54..e6b0e04413 100644
--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -185,7 +185,7 @@ static char bootm_help_text[] =
"\tfdt - relocate flat device tree\n"
 #endif
"\tcmdline - OS specific command line processing/setup\n"
-   "\tbdt - OS specific bd_t processing\n"
+   "\tbdt - OS specific bd_info processing\n"
"\tprep- OS specific prep before relocation or go\n"
 #if defined(CONFIG_TRACE)
"\tfake- OS specific fake start without go\n"
diff --git a/doc/README.POST b/doc/README.POST
index 43f424f60f..1d1c25bdf9 100644
--- a/doc/README.POST
+++ b/doc/README.POST
@@ -126,7 +126,7 @@ The following flags will be defined:
 
 The POST layer will export the following interface routines:
 
-  o) int post_run(bd_t *bd, char *name, int flags);
+  o) int post_run(struct bd_info *bd, char *name, int flags);
 
  This routine will run the test (or the group of tests) specified
  by the name and flag arguments. More specifically, if the name
@@ -175,7 +175,7 @@ struct post_test {
 char *cmd;
 char *desc;
 int flags;
-int (*test)(bd_t *bd, int flags);
+int (*test)(struct bd_info *bd, int flags);
 };
 
   o) name
@@ -364,7 +364,7 @@ declaration/body:
 ...
 
 ...
-int watchdog_post_test(bd_t *bd, int flags)
+int watchdog_post_test(struct bd_info *bd, int flags)
 {
unsigned long start_time;
 
diff --git a/doc/README.arm-relocation b/doc/README.arm-relocation
index d2a7e8122e..bc6644911b 100644
---

[GIT PULL] UniPhier SoC updates for v2020.07

2020-05-21 Thread Masahiro Yamada
Hi Tom,

Please pull changes for v2020.07
Thanks.



The following changes since commit 2fa581ba910368d0f7f995fb906d6c5e4218b594:

  Merge git://git.denx.de/u-boot-sh (2020-05-21 08:26:40 -0400)

are available in the Git repository at:

  https://gitlab.denx.de/u-boot/custodians/u-boot-uniphier.git
tags/uniphier-v2020.07

for you to fetch changes up to 6cbe90486c581db5be84f0a0d9384705f54edabc:

  ARM: uniphier: remove board_eth_init() (2020-05-22 11:21:06 +0900)


UniPhier SoC updates for v2020.07

 - De-assert write protect for Denali NAND driver

 - Clean up include directives

 - Migrate to DM_ETH, and remove legacy board_eth_init()


Masahiro Yamada (9):
  mtd: rawnand: denali: configure SPARE_AREA_SKIP_BYTES only for denali_spl
  ARM: uniphier: select DM_ETH
  mtd: rawnand: denali: deassert write protect pin
  ARM: uniphier: include  instead of  from psci.c
  ARM: uniphier: remove #include  again from micro-support-card.c
  ARM: uniphier: drop #include  again from umc-pxs2.c
  ARM: uniphier: drop #include  again
  ARM: uniphier: delete or replace  includes
  ARM: uniphier: remove board_eth_init()

 arch/arm/Kconfig   |  1 +
 .../arm32/cache-uniphier.c |  1 -
 arch/arm/mach-uniphier/arm32/psci.c|  3 +--
 arch/arm/mach-uniphier/arm32/timer.c   |  2 +-
 arch/arm/mach-uniphier/arm64/mem_map.c |  1 -
 arch/arm/mach-uniphier/base-address.c  |  2 +-
 arch/arm/mach-uniphier/board_init.c|  1 -
 .../mach-uniphier/board_late_init.c|  1 -
 arch/arm/mach-uniphier/boards.c|  2 +-
 .../boot-device/boot-device-ld11.c |  1 -
 .../boot-device/boot-device-ld4.c  |  1 -
 .../boot-device/boot-device-pro5.c |  1 -
 .../boot-device/boot-device-pxs2.c |  1 -
 .../boot-device/boot-device-pxs3.c |  1 -
 .../boot-device/boot-device.c  |  2 +-
 .../mach-uniphier/clk/clk-dram-ld4.c   |  1 -
 .../mach-uniphier/clk/clk-dram-pxs2.c  |  1 -
 .../mach-uniphier/clk/clk-early-ld4.c  |  1 -
 arch/arm/mach-uniphier/clk/clk-ld11.c  |  1 -
 arch/arm/mach-uniphier/clk/dpll-ld4.c  |  1 -
 arch/arm/mach-uniphier/clk/dpll-pro4.c |  1 -
 .../debug-uart/debug-uart.c|  1 -
 .../mach-uniphier/dram/cmd_ddrmphy.c   |  1 -
 .../mach-uniphier/dram/cmd_ddrphy.c|  1 -
 .../dram/ddrphy-training.c |  1 -
 arch/arm/mach-uniphier/dram/umc-ld4.c  |  1 -
 arch/arm/mach-uniphier/dram/umc-pro4.c |  1 -
 arch/arm/mach-uniphier/dram/umc-pxs2.c |  2 --
 arch/arm/mach-uniphier/dram/umc-sld8.c |  1 -
 arch/arm/mach-uniphier/dram_init.c |  2 +-
 arch/arm/mach-uniphier/fdt-fixup.c |  2 +-
 arch/arm/mach-uniphier/memconf.c   |  1 -
 .../mach-uniphier/micro-support-card.c | 19 +++---
 arch/arm/mach-uniphier/mmc-boot-mode.c |  1 -
 arch/arm/mach-uniphier/mmc-first-dev.c |  1 -
 arch/arm/mach-uniphier/nand-reset.c|  1 -
 arch/arm/mach-uniphier/pinctrl-glue.c  |  1 -
 arch/arm/mach-uniphier/reset.c |  1 -
 arch/arm/mach-uniphier/sbc/sbc-ld11.c  |  1 -
 arch/arm/mach-uniphier/sbc/sbc.c   |  1 -
 .../arm/mach-uniphier/spl_board_init.c |  1 -
 configs/uniphier_ld4_sld8_defconfig|  1 -
 configs/uniphier_v7_defconfig  |  1 -
 configs/uniphier_v8_defconfig  |  1 -
 drivers/mtd/nand/raw/Kconfig   | 18 ++---
 drivers/mtd/nand/raw/denali.c  |  1 +
 46 files changed, 21 insertions(+), 69 deletions(-)


Re: [PATCH 2/6] kconfig: Add support for conditional values

2020-05-21 Thread Masahiro Yamada
On Fri, May 22, 2020 at 11:02 AM Simon Glass  wrote:
>
> At present if an optional Kconfig value needs to be used it must be
> bracketed by #ifdef. For example, with this Kconfig setup:
>
> config WIBBLE
> bool "Support wibbles, the world needs more wibbles"
>
> config WIBBLE_ADDR
> hex "Address of the wibble"
> depends on WIBBLE




I am not sure if this is a good idea.


If you want to always use CONFIG_WIBBLE_ADDR,
you can get rid of 'depends on WIBBLE'.




> then the following code must be used:
>
>  #ifdef CONFIG_WIBBLE
>  static void handle_wibble(void)
>  {
> int val = CONFIG_WIBBLE_ADDR;
>
> ...
>  }
>  #endif
>
>  static void init_machine()
>  {
>  ...
>  #ifdef CONFIG_WIBBLE
> handle_wibble();
>  #endif
>  }
>
> Add a new IF_ENABLED_INT() to help with this. So now it is possible to
> write, without #ifdefs:
>
>  static void handle_wibble(void)
>  {
> int val = IF_ENABLED_INT(CONFIG_WIBBLE, CONFIG_WIBBLE_ADDR);
>
> ...
>  }
>
>  static void init_machine()
>  {
>  ...
>  if (IS_ENABLED(CONFIG_WIBBLE))
> handle_wibble();
>  }
>
> The value will be 0 if CONFIG_WIBBLE is not defined, and
> CONFIG_WIBBLE_ADDR if it is. This allows us to reduce the use of #ifdef in
> the code, ensuring that the compiler still checks the code even if it is
> not ultimately used for a particular build.
>
> Signed-off-by: Simon Glass 
> ---
>
>  include/linux/kconfig.h | 12 
>  1 file changed, 12 insertions(+)
>
> diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
> index 3a2da738c4..86cd266540 100644
> --- a/include/linux/kconfig.h
> +++ b/include/linux/kconfig.h
> @@ -79,6 +79,18 @@
>   */
>  #define CONFIG_VAL(option)  config_val(option)
>
> +/* This use a similar mechanism to config_enabled() above */
> +#define config_opt_enabled(cfg, opt_cfg) _config_opt_enabled(cfg, opt_cfg)
> +#define _config_opt_enabled(cfg_val, opt_value) \
> +   __config_opt_enabled(__ARG_PLACEHOLDER_##cfg_val, opt_value)
> +#define __config_opt_enabled(arg1_or_junk, arg2) \
> +   ___config_opt_enabled(arg1_or_junk arg2, 0)
> +#define ___config_opt_enabled(__ignored, val, ...) val
> +
> +/* Evaluates to 0 if option is not defined, int_option if it is defined */
> +#define IF_ENABLED_INT(option, int_option) \
> +   config_opt_enabled(option, int_option)
> +
>  /*
>   * CONFIG_IS_ENABLED(FOO) evaluates to
>   *  1 if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y' or 'm',
> --
> 2.27.0.rc0.183.gde8f92d652-goog
>


-- 
Best Regards
Masahiro Yamada


Re: Regression when building with DEVICE_TREE parameter

2020-05-20 Thread Masahiro Yamada
On Wed, May 20, 2020 at 10:50 PM Patrice CHOTARD  wrote:
>
> Hi Masahiro
>
> As indicated into doc/README.fdt-control, it's possible build U-boot with 
> specifying dts-file-name using
> $ make DEVICE_TREE=


I think this doc might be misleading.

The intended usage is like this.


If you see arch/arm/dts/Makefile,
each platform typically has multiple DTBs.


dtb-$(CONFIG_ARCH_FOO) +=  \
   foo-board1.dtb \
   foo-board2.dtb \
   foo-board3.dtb


When you build for CONFIG_ARCH_FOO,
all of the three are compiled,
but U-Boot needs to pick one to bind.

If you have
CONFIG_DEFAULT_DEVICE_TREE=foo-board1.dtb
in the configuration, foo-board1.dtb is
appended to the final u-boot binary.


If you want to choose a different DTB,
you can also do  "make DEVICE_TREE=foo-board2.dtb"
from the command line, but it must be chosen
from the DTBs added to dtb-y.


DEVICE_TREE=foo-board4.dtb just fails because
there is no dtb-y entry for that.




> But since your commit a3444bd09af9 ("Revert "Ensure device tree DTS is 
> compiled") it's no more possible:

Right.
Before a3444bd09af9, you was able to build whichever
device tree without having the correct entry to Makefile.

As 89c2b5c02049aea pointed out, people really did not care
(or even notice) whether arch/arm/dts/Makefile is correct or not.


That was why DEVICE_TREE=trial was previously working.



> make ARCH=arm CROSS_COMPILE=$CROSS_COMPILE -j 16 DEVICE_TREE="trial"
>
> Device Tree Source is not correctly specified.
> Please define 'CONFIG_DEFAULT_DEVICE_TREE'
> or build with 'DEVICE_TREE=' argument
>
> dts/Makefile:28: recipe for target 'arch/arm/dts/trial.dtb' failed
> make[1]: *** [arch/arm/dts/trial.dtb] Error 1
> Makefile:1087: recipe for target 'dts/dt.dtb' failed


This is because there is no entry for trial.dtb
in arch/arm/dts/Makefile.


You need to add "dtb-y += trial.dtb"
to arch/arm/dts/Makefile.




Please let me know what you want to do.

Your device tree is not upstreamed.
You want to drop it in the tree,
and build it without modifying the source tree.
Is this correct?

The current U-Boot cannot do that.

Each device tree needs to be wired up
to arch//dts/Makefile.


I know a counter approach was proposed in the past.

See this patch:
http://patchwork.ozlabs.org/project/uboot/patch/1451223875-20914-3-git-send-email-tho...@wytron.com.tw/

It stops maintaining arch//dts/Makefile,
then people can set CONFIG_DEFAULT_DEVICE_TREE
to compile whatever device tree.
I think it was one idea, but not adopted.



If you want to separate your DT from
upstream code, EXT_DTB might be used
to append externally built DTB.

See these commits:

63b4b5bae52e48528876e13e858ef934ac2e4a3b
d18926af30d111362c6262c356feb768d7a367a3






> make: *** [dts/dt.dtb] Error 2
>
> By reverting the above patch, it's restoring the attended behavior. But In 
> your commit you indicated several issues.
>
> Unfortunately, i am not a Makefile "expert", can anybody have a look at it ?
>
> Thanks
>
> Patrice










-- 
Best Regards
Masahiro Yamada


Re: [PATCH] ARM: add psci_arch_init() declaration for CONFIG_ARMV7_PSCI

2020-05-19 Thread Masahiro Yamada
On Wed, May 20, 2020 at 12:09 PM Simon Glass  wrote:
>
> HI Masahiro,
>
> On Tue, 19 May 2020 at 20:44, Masahiro Yamada
>  wrote:
> >
> > arch/arm/include/asm/system.h declares psci_arch_init(), but it is
> > surrounded by #ifdef CONFIG_ARMV8_PSCI.
> >
> > psci_arch_init() is called for CONFIG_ARMV7_PSCI too. Add the missing
> > function declaration.
> >
> > Signed-off-by: Masahiro Yamada 
> > ---
> >
> >  arch/arm/include/asm/system.h | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
> > index 1e3f574403..7a40b56acd 100644
> > --- a/arch/arm/include/asm/system.h
> > +++ b/arch/arm/include/asm/system.h
> > @@ -528,6 +528,7 @@ void mmu_page_table_flush(unsigned long start, unsigned 
> > long stop);
> >
> >  #ifdef CONFIG_ARMV7_PSCI
> >  void psci_arch_cpu_entry(void);
> > +void psci_arch_init(void);
>
> Could you add a function comment too?


Sorry, I can't.

It was a long time ago that I worked on the psci implementation
for my board, so I forgot what psci_arch_init() was actually intended.


I was only interested in fixing
-Wmissing-prototypes warning here.


None of the remaining functions are documented,
so "please also do this while you are here" is not
a reasonable request, I think.


If people are happy with not fixing the warning,
please feel free to ignore this patch.





> >  u32 psci_version(void);
> >  s32 psci_features(u32 function_id, u32 psci_fid);
> >  s32 psci_cpu_off(void);
> > --
> > 2.25.1
> >
>
> Regards,
> Simon



--
Best Regards
Masahiro Yamada


[PATCH 5/6] ARM: uniphier: delete or replace includes

2020-05-19 Thread Masahiro Yamada
 pulls in a lot of bloat.  is unneeded in most of
places.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/arm32/cache-uniphier.c | 1 -
 arch/arm/mach-uniphier/arm32/psci.c   | 1 -
 arch/arm/mach-uniphier/arm32/timer.c  | 2 +-
 arch/arm/mach-uniphier/arm64/mem_map.c| 1 -
 arch/arm/mach-uniphier/base-address.c | 2 +-
 arch/arm/mach-uniphier/board_late_init.c  | 1 -
 arch/arm/mach-uniphier/boards.c   | 2 +-
 arch/arm/mach-uniphier/boot-device/boot-device-ld11.c | 1 -
 arch/arm/mach-uniphier/boot-device/boot-device-ld4.c  | 1 -
 arch/arm/mach-uniphier/boot-device/boot-device-pro5.c | 1 -
 arch/arm/mach-uniphier/boot-device/boot-device-pxs2.c | 1 -
 arch/arm/mach-uniphier/boot-device/boot-device-pxs3.c | 1 -
 arch/arm/mach-uniphier/boot-device/boot-device.c  | 2 +-
 arch/arm/mach-uniphier/clk/clk-dram-ld4.c | 1 -
 arch/arm/mach-uniphier/clk/clk-dram-pxs2.c| 1 -
 arch/arm/mach-uniphier/clk/clk-early-ld4.c| 1 -
 arch/arm/mach-uniphier/clk/clk-ld11.c | 1 -
 arch/arm/mach-uniphier/clk/dpll-ld4.c | 1 -
 arch/arm/mach-uniphier/clk/dpll-pro4.c| 1 -
 arch/arm/mach-uniphier/debug-uart/debug-uart.c| 1 -
 arch/arm/mach-uniphier/dram/cmd_ddrmphy.c | 1 -
 arch/arm/mach-uniphier/dram/cmd_ddrphy.c  | 1 -
 arch/arm/mach-uniphier/dram/umc-ld4.c | 1 -
 arch/arm/mach-uniphier/dram/umc-pro4.c| 1 -
 arch/arm/mach-uniphier/dram/umc-sld8.c| 1 -
 arch/arm/mach-uniphier/dram_init.c| 2 +-
 arch/arm/mach-uniphier/fdt-fixup.c| 2 +-
 arch/arm/mach-uniphier/memconf.c  | 1 -
 arch/arm/mach-uniphier/micro-support-card.c   | 3 ++-
 arch/arm/mach-uniphier/mmc-boot-mode.c| 1 -
 arch/arm/mach-uniphier/mmc-first-dev.c| 1 -
 arch/arm/mach-uniphier/pinctrl-glue.c | 1 -
 arch/arm/mach-uniphier/reset.c| 1 -
 arch/arm/mach-uniphier/sbc/sbc-ld11.c | 1 -
 arch/arm/mach-uniphier/sbc/sbc.c  | 1 -
 arch/arm/mach-uniphier/spl_board_init.c   | 1 -
 36 files changed, 8 insertions(+), 36 deletions(-)

diff --git a/arch/arm/mach-uniphier/arm32/cache-uniphier.c 
b/arch/arm/mach-uniphier/arm32/cache-uniphier.c
index b6e4abbad0..cde2a8124f 100644
--- a/arch/arm/mach-uniphier/arm32/cache-uniphier.c
+++ b/arch/arm/mach-uniphier/arm32/cache-uniphier.c
@@ -5,7 +5,6 @@
  *   Author: Masahiro Yamada 
  */
 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-uniphier/arm32/psci.c 
b/arch/arm/mach-uniphier/arm32/psci.c
index b54dc3979d..a4d260aece 100644
--- a/arch/arm/mach-uniphier/arm32/psci.c
+++ b/arch/arm/mach-uniphier/arm32/psci.c
@@ -4,7 +4,6 @@
  *   Author: Masahiro Yamada 
  */
 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-uniphier/arm32/timer.c 
b/arch/arm/mach-uniphier/arm32/timer.c
index b3c907b508..a40bdf1705 100644
--- a/arch/arm/mach-uniphier/arm32/timer.c
+++ b/arch/arm/mach-uniphier/arm32/timer.c
@@ -3,7 +3,7 @@
  * Copyright (C) 2012-2015 Masahiro Yamada 
  */
 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/arch/arm/mach-uniphier/arm64/mem_map.c 
b/arch/arm/mach-uniphier/arm64/mem_map.c
index 7653bd2d3c..a8bd4eee89 100644
--- a/arch/arm/mach-uniphier/arm64/mem_map.c
+++ b/arch/arm/mach-uniphier/arm64/mem_map.c
@@ -3,7 +3,6 @@
  * Copyright (C) 2016 Masahiro Yamada 
  */
 
-#include 
 #include 
 #include 
 
diff --git a/arch/arm/mach-uniphier/base-address.c 
b/arch/arm/mach-uniphier/base-address.c
index 5ee742e363..d7456f8df6 100644
--- a/arch/arm/mach-uniphier/base-address.c
+++ b/arch/arm/mach-uniphier/base-address.c
@@ -3,9 +3,9 @@
 // Copyright (C) 2019 Socionext Inc.
 //   Author: Masahiro Yamada 
 
-#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-uniphier/board_late_init.c 
b/arch/arm/mach-uniphier/board_late_init.c
index 378aad0c9c..b800e8b8c6 100644
--- a/arch/arm/mach-uniphier/board_late_init.c
+++ b/arch/arm/mach-uniphier/board_late_init.c
@@ -5,7 +5,6 @@
  *   Author: Masahiro Yamada 
  */
 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-uniphier/boards.c b/arch/arm/mach-uniphier/boards.c
index d9a8d2f28a..3e2ec9b26a 100644
--- a/arch/arm/mach-uniphier/boards.c
+++ b/arch/arm/mach-uniphier/boards.c
@@ -4,9 +4,9 @@
  *   Author: Masahiro Yamada 
  */
 
-#include 
 #include 
 #include 
+#include 
 
 #include "init.h"
 
diff --git a/arch/arm/mach-uniphier/boot-device/boot-device-ld11.c 
b/arch/arm/mach-uniphier/boot-device/boot-device-ld11.c
index 11e70a926f..4689ed79fd 100644
--- a/arch/arm/mach-uniphier/boot-device/boot-device-ld11.c
+++ b/arch/arm/mach-uniphier/boot-device/boot-device-ld11.c
@@ -4,7 +4,6 @@
  *   Author: Masah

[PATCH 3/6] ARM: uniphier: drop #include again from umc-pxs2.c

2020-05-19 Thread Masahiro Yamada
I do not understand the change made to this file by
commit 691d719db718 ("common: Drop init.h from common header").

  git show 691d719db718 -- arch/arm/mach-uniphier/dram/umc-pxs2.c

This file does not call or define any functions declared in 

Simply revert the change made to this file.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/dram/umc-pxs2.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/mach-uniphier/dram/umc-pxs2.c 
b/arch/arm/mach-uniphier/dram/umc-pxs2.c
index 3f7e5f30ba..24c6802a27 100644
--- a/arch/arm/mach-uniphier/dram/umc-pxs2.c
+++ b/arch/arm/mach-uniphier/dram/umc-pxs2.c
@@ -7,7 +7,6 @@
  * Copyright (C) 2015 Socionext Inc.
  */
 
-#include 
 #include 
 #include 
 #include 
-- 
2.25.1



[PATCH 1/6] ARM: uniphier: include instead of from psci.c

2020-05-19 Thread Masahiro Yamada
I do not understand the change made to this file by
commit 90526e9fbac4 ("common: Drop net.h from common header").

  git show 90526e9fbac4 -- arch/arm/mach-uniphier/arm32/psci.c

It added  while this file does not call the standard cache
functions at all.

All the uniphier-specific cache functions, uniphier_cache_*() are
declared in cache-uniphier.h, which is already included from this file.

Including  is sensible to fix the -Wmissing-prototypes
warnings because this file defines psci_cpu_on and psci_system_reset().

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/arm32/psci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-uniphier/arm32/psci.c 
b/arch/arm/mach-uniphier/arm32/psci.c
index e231e7b60b..b54dc3979d 100644
--- a/arch/arm/mach-uniphier/arm32/psci.c
+++ b/arch/arm/mach-uniphier/arm32/psci.c
@@ -6,7 +6,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -17,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "../debug.h"
 #include "../soc-info.h"
-- 
2.25.1



[PATCH 6/6] ARM: uniphier: remove board_eth_init()

2020-05-19 Thread Masahiro Yamada
This platform completely migrated to CONFIG_DM_ETH.

board_eth_init() is only called from net/eth_legacy.c

Remove the legacy hook.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/micro-support-card.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/arch/arm/mach-uniphier/micro-support-card.c 
b/arch/arm/mach-uniphier/micro-support-card.c
index 3bd26f26db..b09ec54e1f 100644
--- a/arch/arm/mach-uniphier/micro-support-card.c
+++ b/arch/arm/mach-uniphier/micro-support-card.c
@@ -107,18 +107,6 @@ void support_card_init(void)
support_card_show_revision();
 }
 
-#if defined(CONFIG_SMC911X)
-#include 
-
-int board_eth_init(bd_t *bis)
-{
-   if (!support_card_found)
-   return 0;
-
-   return smc911x_initialize(0, (unsigned long)support_card_base + 
SMC911X_OFFSET);
-}
-#endif
-
 #if defined(CONFIG_MTD_NOR_FLASH)
 
 #include 
-- 
2.25.1



[PATCH 4/6] ARM: uniphier: drop #include again

2020-05-19 Thread Masahiro Yamada
I do not understand the changes made to these files by
commit f7ae49fc4f36 ("common: Drop log.h from common header").

  git show f7ae49fc4f36 -- arch/arm/mach-uniphier/

None of them uses the log function feature.

Simply revert the changes made to these files.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/board_init.c   | 1 -
 arch/arm/mach-uniphier/dram/ddrphy-training.c | 1 -
 arch/arm/mach-uniphier/dram/umc-pxs2.c| 1 -
 arch/arm/mach-uniphier/micro-support-card.c   | 1 -
 arch/arm/mach-uniphier/nand-reset.c   | 1 -
 5 files changed, 5 deletions(-)

diff --git a/arch/arm/mach-uniphier/board_init.c 
b/arch/arm/mach-uniphier/board_init.c
index 6bf0811edb..4f9cd6e722 100644
--- a/arch/arm/mach-uniphier/board_init.c
+++ b/arch/arm/mach-uniphier/board_init.c
@@ -5,7 +5,6 @@
  *   Author: Masahiro Yamada 
  */
 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-uniphier/dram/ddrphy-training.c 
b/arch/arm/mach-uniphier/dram/ddrphy-training.c
index c26f56367e..1decdf1cbf 100644
--- a/arch/arm/mach-uniphier/dram/ddrphy-training.c
+++ b/arch/arm/mach-uniphier/dram/ddrphy-training.c
@@ -4,7 +4,6 @@
  * Copyright (C) 2015-2016 Socionext Inc.
  */
 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-uniphier/dram/umc-pxs2.c 
b/arch/arm/mach-uniphier/dram/umc-pxs2.c
index 24c6802a27..73574201e3 100644
--- a/arch/arm/mach-uniphier/dram/umc-pxs2.c
+++ b/arch/arm/mach-uniphier/dram/umc-pxs2.c
@@ -7,7 +7,6 @@
  * Copyright (C) 2015 Socionext Inc.
  */
 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-uniphier/micro-support-card.c 
b/arch/arm/mach-uniphier/micro-support-card.c
index d23c0bd129..84c377766a 100644
--- a/arch/arm/mach-uniphier/micro-support-card.c
+++ b/arch/arm/mach-uniphier/micro-support-card.c
@@ -8,7 +8,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-uniphier/nand-reset.c 
b/arch/arm/mach-uniphier/nand-reset.c
index dbf54aa910..11cadaabd8 100644
--- a/arch/arm/mach-uniphier/nand-reset.c
+++ b/arch/arm/mach-uniphier/nand-reset.c
@@ -4,7 +4,6 @@
  *   Author: Masahiro Yamada 
  */
 
-#include 
 #include 
 #include 
 #include 
-- 
2.25.1



[PATCH 2/6] ARM: uniphier: remove #include again from micro-support-card.c

2020-05-19 Thread Masahiro Yamada
I do not understand the changes made to this file by
commit 90526e9fbac4 ("common: Drop net.h from common header").

  git show 90526e9fbac4 -- arch/arm/mach-uniphier/micro-support-card.c

The necessary declaration is already included by  at line 112.
It also moved the  inclusion, but I do not understand the
motivation of doing so, either.

Simply revert the changes made to this file.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/mach-uniphier/micro-support-card.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/mach-uniphier/micro-support-card.c 
b/arch/arm/mach-uniphier/micro-support-card.c
index 18435dc361..d23c0bd129 100644
--- a/arch/arm/mach-uniphier/micro-support-card.c
+++ b/arch/arm/mach-uniphier/micro-support-card.c
@@ -6,10 +6,9 @@
  */
 
 #include 
+#include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
-- 
2.25.1



[PATCH] ARM: add psci_arch_init() declaration for CONFIG_ARMV7_PSCI

2020-05-19 Thread Masahiro Yamada
arch/arm/include/asm/system.h declares psci_arch_init(), but it is
surrounded by #ifdef CONFIG_ARMV8_PSCI.

psci_arch_init() is called for CONFIG_ARMV7_PSCI too. Add the missing
function declaration.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/include/asm/system.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 1e3f574403..7a40b56acd 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -528,6 +528,7 @@ void mmu_page_table_flush(unsigned long start, unsigned 
long stop);
 
 #ifdef CONFIG_ARMV7_PSCI
 void psci_arch_cpu_entry(void);
+void psci_arch_init(void);
 u32 psci_version(void);
 s32 psci_features(u32 function_id, u32 psci_fid);
 s32 psci_cpu_off(void);
-- 
2.25.1



  1   2   3   4   5   6   7   8   9   10   >