Re: [PATCH 3/7] arc: Remove common.h usage

2023-10-13 Thread Alexey Brodkin
Hi Tom,

> We can remove common.h from most cases of the code here, and only a few
> places need an additional header instead.
> 
> Signed-off-by: Tom Rini 
> ---
> Cc: Alexey Brodkin 
> Cc: Eugeniy Paltsev 
> Cc: uboot-snps-...@synopsys.com
> ---
>  arch/arc/lib/bootm.c   | 1 -
>  arch/arc/lib/cache.c   | 1 -
>  arch/arc/lib/cpu.c | 1 -
>  arch/arc/lib/init_helpers.c| 1 -
>  arch/arc/lib/interrupts.c  | 2 +-
>  arch/arc/lib/relocate.c| 1 -
>  arch/arc/lib/reset.c   | 1 -
>  board/abilis/tb100/tb100.c | 1 -
>  board/synopsys/axs10x/axs10x.c | 1 -
>  board/synopsys/emsdp/emsdp.c   | 1 -
>  board/synopsys/hsdk/clk-lib.h  | 1 -
>  board/synopsys/hsdk/env-lib.c  | 2 ++
>  board/synopsys/hsdk/env-lib.h  | 1 -
>  board/synopsys/hsdk/hsdk.c | 1 -
>  board/synopsys/iot_devkit/iot_devkit.c | 1 -
>  board/synopsys/nsim/nsim.c | 1 -
>  16 files changed, 3 insertions(+), 15 deletions(-)

Thanks for the improvement!

Acked-by: Alexey Brodkin 

Re: [PATCH 4/5] CI: Update to gcc-13.1.0

2023-07-14 Thread Alexey Brodkin
Hi Tom,

> As this is the current version of the public cross toolchains we use,
> upgrade to this now.
> 
> Suggested-by: Alexey Brodkin 
> Signed-off-by: Tom Rini 
> ---
> Cc: Heinrich Schuchardt 
> 
> Heinrich, at this point is there a newer grub we should be testing?
> There's now 2 changes for RISC-V that we're cherry-picking for newer
> toolchains.

That's what I noticed as well - grub fails to build for RISCV
with the following message, I guess you saw that as well:
--->8--
./grub-mkimage: error: relocation 0x13 is not implemented yet.
--->8--

> ---
>  .azure-pipelines.yml|  2 +-
>  .gitlab-ci.yml  |  2 +-
>  tools/buildman/toolchain.py |  2 +-
>  tools/docker/Dockerfile | 57 +++--
>  4 files changed, 32 insertions(+), 31 deletions(-)
> 
> diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
> index 76982ec3e52e..83cc6176e7b4 100644
> --- a/.azure-pipelines.yml
> +++ b/.azure-pipelines.yml
> @@ -194,7 +194,7 @@ stages:
>ln -s /opt/nokia/libc6_2.5.1-1eglibc27+0m5_armel.deb 
> nokia_rx51_tmp/
>ln -s /opt/nokia/busybox_1.10.2.legal-1osso30+0m5_armel.deb 
> nokia_rx51_tmp/
>ln -s /opt/nokia/qemu-system-arm nokia_rx51_tmp/
> -  export PATH=/opt/gcc-12.2.0-nolibc/arm-linux-gnueabi/bin:$PATH
> +  export PATH=/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin:$PATH
>test/nokia_rx51_test.sh
>  
>- job: pylint
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index f7ffb8f5dfdc..5300813cf511 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -232,7 +232,7 @@ Run tests for Nokia RX-51 (aka N900):
>ln -s /opt/nokia/libc6_2.5.1-1eglibc27+0m5_armel.deb nokia_rx51_tmp/;
>ln -s /opt/nokia/busybox_1.10.2.legal-1osso30+0m5_armel.deb 
> nokia_rx51_tmp/;
>ln -s /opt/nokia/qemu-system-arm nokia_rx51_tmp/;
> -  export PATH=/opt/gcc-12.2.0-nolibc/arm-linux-gnueabi/bin:$PATH;
> +  export PATH=/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin:$PATH;
>test/nokia_rx51_test.sh
>  
>  # Check for any pylint regressions
> diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py
> index 0ecd8458b912..1001b612086f 100644
> --- a/tools/buildman/toolchain.py
> +++ b/tools/buildman/toolchain.py
> @@ -499,7 +499,7 @@ class Toolchains:
>  if arch == 'aarch64':
>  arch = 'arm64'
>  base = 'https://www.kernel.org/pub/tools/crosstool/files/bin'
> -versions = ['12.2.0', '11.1.0']
> +versions = ['13.1.0', '12.2.0']
>  links = []
>  for version in versions:
>  url = '%s/%s/%s/' % (base, arch, version)
> diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
> index f72cba0b8cc4..2f2ace2e6554 100644
> --- a/tools/docker/Dockerfile
> +++ b/tools/docker/Dockerfile
> @@ -14,18 +14,18 @@ RUN apt-get update && apt-get install -y gnupg2 wget 
> xz-utils && rm -rf /var/lib
>  RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
>  RUN echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main | tee 
> /etc/apt/sources.list.d/llvm.list
>  
> -# Manually install the kernel.org "Crosstool" based toolchains for gcc-12.2.0
> -RUN wget -O - 
> https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-aarch64-linux.tar.xz
>  | tar -C /opt -xJ
> -RUN wget -O - 
> https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-arm-linux-gnueabi.tar.xz
>  | tar -C /opt -xJ
> -RUN wget -O - 
> https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-i386-linux.tar.xz
>  | tar -C /opt -xJ
> -RUN wget -O - 
> https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-m68k-linux.tar.xz
>  | tar -C /opt -xJ
> -RUN wget -O - 
> https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-mips-linux.tar.xz
>  | tar -C /opt -xJ
> -RUN wget -O - 
> https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-microblaze-linux.tar.xz
>  | tar -C /opt -xJ
> -RUN wget -O - 
> https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-nios2-linux.tar.xz
>  | tar -C /opt -xJ
> -RUN wget -O - 
> https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-powerpc-linux.tar.xz
>  | tar -C /opt -xJ
> -RUN wget -O - 
> https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bi

Re: [PATCH] buildman: Switch ARC toolchain to the upstream version

2023-07-13 Thread Alexey Brodkin
Hi Tom,

> > Back in the day we relied a lot on Synopsys own build of the GNU tools
> > for ARC processors, but since then we worked hard on getting all our changes
> > upstream and for a couple of years now we have ARCompact (AKA ARCv1)
> > and ARCv2 processors supported very well in upstream GCC, Binutils, GDB etc.
> >
> > And so there's no need to use Synopsys forks any longer, thus we remove
> > all the references to that form and use upstream components as majority
> > of other architectures in U-Boot.
> >
> > Thanks to Tom for pointing to that left-over!
> >
> > Signed-off-by: Alexey Brodkin 
> > Cc: Simon Glass 
> > Cc: Tom Rini 
> > Reviewed-by: Tom Rini 
> > Reviewed-by: Simon Glass 
> 
> So I tested this locally and I have a problem:
> Building current source for 1 boards (1 thread, 16 jobs per thread)
>arc:  +   hsdk_4xd
> +(hsdk_4xd) arc-linux-gcc: error: unrecognized argument in option 
> '-mcpu=hs4x_rel31'
> +(hsdk_4xd) arc-linux-gcc: note: valid arguments to '-mcpu=' are: arc600 
> arc600_mul32x16 arc600_mul64 arc600_norm arc601 arc601_mul32x16 arc601_mul64 
> arc601_norm arc700 arcem archs em em4 em4_dmips em4_fpuda em4_fpus em_mini hs 
> hs34 hs38 hs38_linux hs4x hs4xd nps400 quarkse_em
> +(hsdk_4xd) make[2]: *** [scripts/Makefile.autoconf:82: u-boot.cfg] Error 1
> +(hsdk_4xd) make[2]: *** [scripts/Makefile.autoconf:52: 
> include/autoconf.mk.dep] Error 1
> +(hsdk_4xd) make[1]: *** No rule to make target 'include/config/auto.conf', 
> needed by 'include/config/uboot.release'.  Stop.
> +(hsdk_4xd) make: *** [Makefile:177: sub-make] Error 2
> 
> I assume it's a straight-forward fix.

Good catch. I did run test on most of ARC boards except this one
as I forgot that it really differs from the original "hsdk" :)

So, that failure happens because of missing patch on GCC12, which
adds that new "mcpu", see [1]. It's now a part of GCC 13 and so I would suggest
the following "fix":
>8---
diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py
index 0ecd8458b9..e34d8db25c 100644
--- a/tools/buildman/toolchain.py
+++ b/tools/buildman/toolchain.py
@@ -499,7 +499,7 @@ class Toolchains:
 if arch == 'aarch64':
 arch = 'arm64'
 base = 'https://www.kernel.org/pub/tools/crosstool/files/bin'
-versions = ['12.2.0', '11.1.0']
+versions = ['13.1.0', '12.2.0', '11.1.0']
 links = []
 for version in versions:
 url = '%s/%s/%s/' % (base, arch, version)
>8---

I.e. bumping default toolchains to GCC 13.x.
Do you think it's doable at this point?

[1] 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=7501eec65c60701f72621d04eeb5342bad2fe4fb

-Alexey

[PATCH] buildman: Switch ARC toolchain to the upstream version

2023-07-07 Thread Alexey Brodkin
Back in the day we relied a lot on Synopsys own build of the GNU tools
for ARC processors, but since then we worked hard on getting all our changes
upstream and for a couple of years now we have ARCompact (AKA ARCv1)
and ARCv2 processors supported very well in upstream GCC, Binutils, GDB etc.

And so there's no need to use Synopsys forks any longer, thus we remove
all the references to that form and use upstream components as majority
of other architectures in U-Boot.

Thanks to Tom for pointing to that left-over!

Signed-off-by: Alexey Brodkin 
Cc: Simon Glass 
Cc: Tom Rini 
---
 tools/buildman/bsettings.py | 1 -
 tools/buildman/buildman.rst | 6 --
 tools/docker/Dockerfile | 3 +--
 3 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/tools/buildman/bsettings.py b/tools/buildman/bsettings.py
index 0eb894a558..029c401fd2 100644
--- a/tools/buildman/bsettings.py
+++ b/tools/buildman/bsettings.py
@@ -91,7 +91,6 @@ other = /
 [toolchain-prefix]
 # name = path to prefix
 # e.g. x86 = /opt/gcc-4.6.3-nolibc/x86_64-linux/bin/x86_64-linux-
-# arc = /opt/arc/arc_gnu_2021.03_prebuilt_elf32_le_linux_install/bin/arc-elf32-
 
 [toolchain-alias]
 # arch = alias
diff --git a/tools/buildman/buildman.rst b/tools/buildman/buildman.rst
index c8b0db3d8b..6808727eb4 100644
--- a/tools/buildman/buildman.rst
+++ b/tools/buildman/buildman.rst
@@ -475,10 +475,6 @@ Setting up
   sudo mkdir -p /toolchains
   sudo mv ~/.buildman-toolchains/*/* /toolchains/
 
-   For those not available from kernel.org, download from the following links:
-
-   - `Arc Toolchain`_
-
Buildman should now be set up to use your new toolchain.
 
At the time of writing, U-Boot has these architectures:
@@ -1342,8 +1338,6 @@ Thanks to Grant Grundler  for his 
ideas for improving
 the build speed by building all commits for a board instead of the other
 way around.
 
-.. _`Arc Toolchain`: 
https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2021.03-release/arc_gnu_2021.03_prebuilt_elf32_le_linux_install.tar.gz
-
 .. sectionauthor:: Simon Glass
 .. sectionauthor:: Copyright (c) 2013 The Chromium OS Authors.
 .. sectionauthor:: s...@chromium.org
diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index 9804b55ddd..fa03f3f2a7 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -16,6 +16,7 @@ RUN echo deb http://apt.llvm.org/jammy/ 
llvm-toolchain-jammy-16 main | tee /etc/
 
 # Manually install the kernel.org "Crosstool" based toolchains for gcc-12.2.0
 RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-aarch64-linux.tar.xz
 | tar -C /opt -xJ
+RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-arc-linux.tar.xz
 | tar -C /opt -xJ
 RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-arm-linux-gnueabi.tar.xz
 | tar -C /opt -xJ
 RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-i386-linux.tar.xz
 | tar -C /opt -xJ
 RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-m68k-linux.tar.xz
 | tar -C /opt -xJ
@@ -29,7 +30,6 @@ RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_
 
 # Manually install other toolchains
 RUN wget -O - 
https://github.com/foss-xtensa/toolchain/releases/download/2020.07/x86_64-2020.07-xtensa-dc233c-elf.tar.gz
 | tar -C /opt -xz
-RUN wget -O - 
https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2021.03-release/arc_gnu_2021.03_prebuilt_uclibc_le_archs_linux_install.tar.gz
 | tar --no-same-owner -C /opt -xz
 
 # Update and install things from apt now
 RUN apt-get update && apt-get install -y \
@@ -279,7 +279,6 @@ RUN virtualenv -p /usr/bin/python3 /tmp/venv && \
 # Create the buildman config file
 RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
 RUN /bin/echo -e "kernelorg = /opt/gcc-12.2.0-nolibc/*" >> ~/.buildman
-RUN /bin/echo -e "arc = 
/opt/arc_gnu_2021.03_prebuilt_uclibc_le_archs_linux_install" >> ~/.buildman
 RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = 
/opt/2020.07/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman;
 RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
 RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman
-- 
2.34.1



Re: [PATCH 02/88] treewide: Correct invalid Kconfig syntax and warnings

2023-02-10 Thread Alexey Brodkin
Hi Tom, Daniel, all,

> On 1/27/23 14:45, Tom Rini wrote:
> > On Mon, Jan 23, 2023 at 02:59:05PM -0700, Simon Glass wrote:
> >
> >> In several places a 'select' is used to select a choice, which is not
> >> supported by Kconfig. In other places, the filename for the 'source'
> >> command is not in quites.
> >>
> >> Fix these two problems throughout the tree, so that kconfiglib does not
> >> show any more warnings.
> >>
> >> Signed-off-by: Simon Glass 
> >
> > OK, to summarize what I just said in another email and clarify future
> > work. Please first split this patch in to its own series that corrects
> > each type of problem, per commit. The missing quotes for example, and
> > then the extra whitespace ones. Next, commenting out a select is wrong,
> > and each case needs to be better understood / fixed. I'm honestly not
> > sure if asking endianness for MIPS is right and if we should select that
> > from boards too, like ARC, but probably. The ARC_MMU one also should
> > just not be asked, I suspect, but as a separate patch where you cc
> > Alexey, we'll find out :)  And so on, for each.  Thanks.
> >

Sorry for not chiming-in sooner, but I'm here now ;)

> For MIPS the endianess (and also architecture/ISA level) needs to be able to 
> be set
> by the user via menuconfig as most MIPS cores or SoCs can support multiple 
> variants.
> The idea is that the specific SoC or machine just sets the supported options 
> to
> restrict the options the user can choose. The board's defconfig should set the
> required default value for each option but must not *select* it.
> 
> See the Boston board for example:
> 
> config TARGET_BOSTON
> bool "Support Boston"
> ...
> select SUPPORTS_BIG_ENDIAN
> select SUPPORTS_CPU_MIPS32_R1
> select SUPPORTS_CPU_MIPS32_R2
> select SUPPORTS_CPU_MIPS32_R6
> select SUPPORTS_CPU_MIPS64_R1
> select SUPPORTS_CPU_MIPS64_R2
> select SUPPORTS_CPU_MIPS64_R6
> select SUPPORTS_LITTLE_ENDIAN
> 
> 
> 
> A possible fix for ARC could be:

To be honest I don't quite understand what's a problem which we try to fix here
and so it's not clear what to advise.

ARC cores as opposed to MIPS are configured in IP design process and so
if a particular chip is designed as little-endian and already produced in
silicon, it cannot be turned into big-endian.

Still ARCompact (AKA ARCv1) & ARCv2 processors could be configured as either
little- or big-endian, thus we used to support both variants in U-Boot.
And it's still there, so hopefully we may keep it.

> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -53,8 +53,6 @@ config ARC
>  select SUPPORT_OF_CONTROL
>  select SYS_CACHE_SHIFT_7
>  select TIMER
> -   select SYS_BIG_ENDIAN if CPU_BIG_ENDIAN
> -   select SYS_LITTLE_ENDIAN if !CPU_BIG_ENDIAN
>  
>   config ARM
>  bool "ARM architecture"
> @@ -490,7 +488,7 @@ endif
>  
>   source "board/keymile/Kconfig"
>  
> -if MIPS || MICROBLAZE
> +if MIPS || MICROBLAZE || ARC
>  
>   choice
>  prompt "Endianness selection"
> @@ -502,11 +500,11 @@ choice
>  
>   config SYS_BIG_ENDIAN
>  bool "Big endian"
> -   depends on (SUPPORTS_BIG_ENDIAN && MIPS) || MICROBLAZE
> +   depends on (SUPPORTS_BIG_ENDIAN && MIPS) || MICROBLAZE || 
> (CPU_BIG_ENDIAN && ARC)
>  
>   config SYS_LITTLE_ENDIAN
>  bool "Little endian"
> -   depends on (SUPPORTS_LITTLE_ENDIAN && MIPS) || MICROBLAZE
> +   depends on (SUPPORTS_LITTLE_ENDIAN && MIPS) || MICROBLAZE || 
> (CPU_LITTLE_ENDIAN && ARC)
>  
>   endchoice
> 
> 
> 
> A *make savedefconfig* should than automatically add 
> *CONFIG_SYS_LITTLE_ENDIAN=y* or
> *CONFIG_SYS_BIG_ENDIAN=y* to the ARC board defconfig's.

That proposal looks reasonable and allows to keep existing code as it is,
but can we just have only 1 config option which is used for endianess selection?
I.e. why having both "SYS_BIG_ENDIAN" & "CPU_BIG_ENDIAN"?

-Alexey

Re: Broken arc toolchain

2021-07-10 Thread Alexey Brodkin
Hi Tom and Simon,

So there're a couple of things involved indeed.

  1.  As Tom correctly mentioned we used to use SNSP pre-built tools for ARC in 
TravisCI previously. And frankly the reason was we needed something GCC 8.x 
based while on some other arches such a new GCC triggered extra problems, see 
https://lists.denx.de/pipermail/u-boot/2018-May/329577.html. So I updated ARC 
pre-built versions and we kept using it.
  2.  Now, that particular "mcpu" was never added into upstream GCC because we 
wanted to re-implement it a bit nicer, thus any up-to-date vanilla GCC won't 
accept it as opposed to tools built from SNPS' GCC port [which has it 
https://github.com/foss-for-synopsys-dwc-arc-processors/gcc/commit/84a3ee3844f9967a1b6c5923b9da4e6720c1d5bb].
  3.  IIRC "-mcpu=hs4x_rel31" is basically an umbrella option for some options 
combination based on generic "-mcpu=hs4x" so we may probably update HSDK-4xD 
flags to be buildable by vanialla GGC.

But anyways the simples short-term solution is to use our pre-built tools, 
latest of which are avaialble here 
https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/tag/arc-2021.03-release.
 And for U-Boot elf32 version is what I would suggest to use, so please use 
https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2021.03-release/arc_gnu_2021.03_prebuilt_elf32_le_linux_install.tar.gz.

Moreover since by default for ARC we use U-Boot built-in libgcc the same one 
little-endian toolchain might be safely used for building our big-endian 
configs equally well.

If more info or actions needed, please let me know.

-Alexey



From: Tom Rini
Sent: Saturday, July 10, 2021 11:22 PM
To: Simon Glass
Cc: U-Boot Mailing List; Alexey Brodkin; Eugeniy Paltsev
Subject: Re: Broken arc toolchain

On Sat, Jul 10, 2021 at 02:11:30PM -0600, Simon Glass wrote:

> Hi,
>
> I see this:
>
> $ buildman --fetch-arch arc
>
> Downloading toolchain for arch 'arc'
> Checking: https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/9.2.0/
> Downloading: 
> https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/9.2.0/x86_64-gcc-9.2.0-nolibc-arc-linux.tar.xz
>  Unpacking to: /home/sglass/.buildman-toolchains
> Testing
>   - looking in
> '/home/sglass/.buildman-toolchains/gcc-9.2.0-nolibc/arc-linux/.'
>   - looking in
> '/home/sglass/.buildman-toolchains/gcc-9.2.0-nolibc/arc-linux/bin'
>  - found
> '/home/sglass/.buildman-toolchains/gcc-9.2.0-nolibc/arc-linux/bin/arc-linux-gcc'
>   - looking in
> '/home/sglass/.buildman-toolchains/gcc-9.2.0-nolibc/arc-linux/usr/bin'
> Tool chain test:  OK, arch='arc', priority 5
>
> $ buildman -A hsdk_4xd
> /home/sglass/.buildman-toolchains/gcc-9.2.0-nolibc/arc-linux/bin/arc-linux-
> $ buildman hsdk_4xd
> ...
> arc-linux-gcc: error: unrecognized argument in option '-mcpu=hs4x_rel31
>
>
> Do you have any thoughts on what is wrong, please?

There's two parts.  The first part is I keep forgetting to update
buildman to fetch the latest toolchains from kernel.org, it should be
grabbing 11.1.0 now, not 9.2.0.  The second part is that arc, nds32 and
xtensa have non-standard toolchain locations, see
tools/docker/Dockerfile for where to fetch.

--
Tom


Re: [PATCH v4 08/17] board_f: Factor out bdinfo bi_mem{start, size} to setup_bdinfo

2020-07-24 Thread Alexey Brodkin
Hi Ovidiu,

> Move all assignments to gd->bd->bi_mem{start,size} to generic code in
> setup_bdinfo.
> 
> Xtensa architecture is special in this regard as it defines its own
> handling of gd->bd->bi_mem{start,size} fields. In order to avoid defining
> a weak SDRAM function, let arch_setup_bdinfo overwrite the generic flags.
> 
> For ARC architecture, remove ARCH_EARLY_INIT_R from Kconfig since it is
> not needed anymore.
> 
> Also, use gd->ram_base to populate bi_memstart to avoid an ifdef.
> 
> Signed-off-by: Ovidiu Panait 
> ---
> 
>  arch/Kconfig  |  1 -
>  arch/arc/lib/cpu.c|  7 ---
>  arch/xtensa/lib/Makefile  |  2 +-
>  arch/xtensa/lib/bdinfo.c  | 22 ++
>  board/cadence/xtfpga/xtfpga.c |  3 ---
>  common/board_f.c  | 11 +--
>  6 files changed, 28 insertions(+), 18 deletions(-)
>  create mode 100644 arch/xtensa/lib/bdinfo.c
> 
> diff --git a/arch/Kconfig b/arch/Kconfig
> index 9be02d1319..4d9557959c 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -10,7 +10,6 @@ choice
>  
>  config ARC
>  bool "ARC architecture"
> -   select ARCH_EARLY_INIT_R
>  select ARC_TIMER
>  select CLK
>  select HAVE_PRIVATE_LIBGCC
> diff --git a/arch/arc/lib/cpu.c b/arch/arc/lib/cpu.c
> index 27b5832a0c..d66a8c867a 100644
> --- a/arch/arc/lib/cpu.c
> +++ b/arch/arc/lib/cpu.c
> @@ -25,13 +25,6 @@ int arch_cpu_init(void)
>  return 0;
>  }
>  
> -int arch_early_init_r(void)
> -{
> -   gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
> -   gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
> -   return 0;
> -}
> -
>  /* This is a dummy function on arc */
>  int dram_init(void)
>  {

For ARC part...

Acked-by: Alexey Brodkin 

Re: [PATCH v3 08/17] board_f: Introduce board_setup_bdinfo_mem initcall

2020-07-21 Thread Alexey Brodkin
Hi Ovidiu,

[snip]

> diff --git a/arch/arc/lib/cpu.c b/arch/arc/lib/cpu.c
> index 27b5832a0c..ccb7e1b265 100644
> --- a/arch/arc/lib/cpu.c
> +++ b/arch/arc/lib/cpu.c
> @@ -27,8 +27,6 @@ int arch_cpu_init(void)
>  
>  int arch_early_init_r(void)
>  {
> -   gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
> -   gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
>  return 0;

Do we still need an empty arch_early_init_r()?
I.e. get rid of it and:
->8---
diff --git a/arch/Kconfig b/arch/Kconfig
index 91e049b322..2cc656b641 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -10,7 +10,6 @@ choice

 config ARC
bool "ARC architecture"
-   select ARCH_EARLY_INIT_R
select ARC_TIMER
select CLK
select HAVE_PRIVATE_LIBGCC
->8---

-Alexey

RE: Using gerrit or github for review?

2020-07-13 Thread Alexey Brodkin
Hi Heinrich,

> -Original Message-
> From: U-Boot  On Behalf Of Heinrich Schuchardt
> Sent: Monday, July 13, 2020 10:36 PM
> To: Simon Glass ; U-Boot Mailing List 
> 
> Cc: Tom Rini ; Bin Meng ; Masahiro 
> Yamada
> ; Marek Vasut ; Vignesh 
> R ;
> Michal Simek ; Igor Opaniuk 
> ; Heiko Schocher
> ; Fabio Estevam ; Jagan Teki 
> 
> Subject: Re: Using gerrit or github for review?
> 
> On 13.07.20 20:25, Simon Glass wrote:
> > Hi,
> >
> > At present U-Boot uses the mailing list for patch review. What do
> 
> Currently we are using Patchwork to keep track of the review process:
> 
> https://urldefense.com/v3/__https://patchwork.ozlabs.org/project/uboot/list/__;!!A4F2R9G_pg!M278QbuG4g
> 5GiXV1lWK3mAP9aDJsCGRoLe1F_6XLKUSPb0lwIfYEVIdA5gU-HTUX$
> 
> > people think about trying out geritt or github for this? I'd be
> > willing to do a trial with the -dm mailing list.
> >
> > My idea is that patman would email out the patches and also upload
> > them to one of these systems. With geritt, emails are sent every time
> > there is a review, but for github I'm not sure.
> 
> Do we need an new tool? Managing reviews it supported by Gitlab.
> 
> There is no need for patman in a process with any of the mentioned
> tools. Gitlab, Gerrit, and Github send out mails to reviewers.
> 
> The work flow with Gitlab and Gerrit that I have seen relied on a role
> concept where only specific users of the system are reviewers. - Our
> current process allows anybody to review. This is what I would like to keep.

Well anybody (I guess registered to the given instance users) may do a 
code-review, but only limited amount of people may vote for/against that change
and then even fewer people may press the "merge" button. But in case of
U-Boot only a tree maintainer may accept patches so that's OK.

What is not clear for me if and how multi-level source trees might
be implemented in either system. I mean so that the platform maintainer
accepts a patch for this particular platform, then sends a PR to the upstream
say arch maintainer and then arch maintainer sends PR to the Tom.

-Alexey


RE: Using gerrit or github for review?

2020-07-13 Thread Alexey Brodkin
Hi Simon,

> -Original Message-
> From: U-Boot  On Behalf Of Simon Glass
> Sent: Monday, July 13, 2020 9:26 PM
> To: U-Boot Mailing List 
> Cc: Tom Rini ; Bin Meng ; Masahiro 
> Yamada
> ; Heinrich Schuchardt ; 
> Marek Vasut
> ; Vignesh R ; Michal Simek 
> ; Igor
> Opaniuk ; Heiko Schocher ; Fabio 
> Estevam ;
> Jagan Teki 
> Subject: Using gerrit or github for review?
> 
> At present U-Boot uses the mailing list for patch review. What do
> people think about trying out geritt or github for this? I'd be
> willing to do a trial with the -dm mailing list.
> 
> My idea is that patman would email out the patches and also upload
> them to one of these systems. With geritt, emails are sent every time
> there is a review, but for github I'm not sure.

From my experience Gerrit's code-review interface is much less
human-friendly as compared to GitHub. Also GitHub has "Issues" which
are nicely integrated with "Pull-requests".

One good example you may look at is Zephyr RTOS, see
https://github.com/zephyrproject-rtos/zephyr/. They do use GitHub features
quite extensively.

But given U-Boot git repos are already hosted in GitLab instance why not
consider it instead of either GitHub or Gerrit? Review and issues are already
there as well as some other fancy features. Or I'm missing the main point of
the question?

-Alexey


RE: [ANN] U-Boot v2020.07-rc3 released

2020-05-26 Thread Alexey Brodkin
Hi Tom, Wolfgang,

> > In message 
> >  you 
> > wrote:
> > > >
> > > > I'm going to continue with the every-other-week RC schedule and release 
> > > > on
> > > > July 6th.  I'm currently planning to branch -next on June 8th but PRs
> > > > can be posted sooner and I'll get them queued up.  Thanks all!
> > >
> > > Is there a tar file?
> >
> > There is no need for (static) tarballs, as you can always download
> > one dynamically from the gitlab interface.
> >
> > Go to https://gitlab.denx.de/u-boot/u-boot , then clock on the
> > "Download" symbol, which looks something like this:
> >
> > ||
> > \/
> >   ||
> >
> > It's labeled "Download source code", and you can select for example
> > "tar.bz2" download format.
> 
> The problem is that unless this is unlike the github interface the
> tarballs are deleted / recreated at times and so the checksums change.
> In OpenEmbedded land this is worked around by using the githash for a
> specific tag and fetching that way.  I don't know if Fedora/etc support
> a similar mechanism.

That might be quite unfortunate if we stop producing "static" tarballs with
known checksums as in build-systems like Buildroot tarballs are still preferable
or at least simpler way of dealing with new versions.

Or at least if creation of "static tarballs" won't be supported looking forward
it might be good to make people aware of that somehow :)

Also cannot we use "Releases" feature of GitLab?
See https://gitlab.denx.de/help/user/project/releases/index.
Not sure if in case of "releases" tarballs could be still regenerated at some
point but even in that case we may "attach" "manually" created "assets" which 
will
have a known checksums and those are for sure as static as it can be.

-Alexey


[U-Boot] Please pull ARC fixes for v2020.07-rc3

2020-05-13 Thread Alexey Brodkin
Hi Tom,

The following changes since commit 10bca13ea6d9d4b85f80f02c8795227f63240f59:

  Merge https://gitlab.denx.de/u-boot/custodians/u-boot-usb (2020-05-12 
16:20:10 -0400)

are available in the Git repository at:

  g...@gitlab.denx.de:u-boot/custodians/u-boot-arc.git 
tags/arc-fixes-for-2020.07-rc3

for you to fetch changes up to bed6481940b1b9a2f3b48afeeced550dd84e2932:

  ARC: HSDK: add reset for EHCI (2020-05-13 18:18:09 +0300)


Here we improve clock support for recently introduced HSDK-4xD
board as well as finally enable external reset for the USB controller,
which is needed to recover USB functionality after "usb reset".


Eugeniy Paltsev (11):
  CLK: ARC: HSDK: avoid code duplication
  CLK: ARC: HSDK: drop unused offset
  CLK: ARC: HSDK: use appropriate config data types
  CLK: ARC: HSDK: driver cleanup
  CLK: ARC: HSDK: prepare for multiple clock maps support
  CLK: ARC: HSDK: make set_clock optional
  CLK: ARC: HSDK: define clock map with DT binding constants
  CLK: ARC: HSDK: add separate clock map for HSDK-4xD
  ARC: DTS: cleanup USB node names
  ARC: HSDK: anounce state of BIM switch
  ARC: HSDK: add reset for EHCI

 arch/arc/dts/axs10x_mb.dtsi   |   4 +--
 arch/arc/dts/hsdk-common.dtsi |  11 +--
 board/synopsys/hsdk/hsdk.c|   7 
 drivers/clk/Kconfig   |   7 ++--
 drivers/clk/clk-hsdk-cgu.c| 355 
+++
 5 files changed, 220 insertions(+), 164 deletions(-)

Regards,
Alexey


RE: [PATCH] BDINFO: ARC: print info about relocations

2020-05-13 Thread Alexey Brodkin
Hi Eugeniy,

> -Original Message-
> From: Eugeniy Paltsev 
> Sent: Saturday, April 25, 2020 12:11 AM
> To: Alexey Brodkin 
> Cc: u-boot@lists.denx.de; uboot-snps-...@synopsys.com; Eugeniy Paltsev 
> 
> Subject: [PATCH] BDINFO: ARC: print info about relocations
> 
> Print relocation information in bdinfo.
> NOTE: this patch changes only ARC part of bdinfo code.
> 
> Signed-off-by: Eugeniy Paltsev 
> ---

I guess we're getting similar functionality with Simon's series,
see 
https://patchwork.ozlabs.org/project/uboot/patch/20200510201702.196031-9-...@chromium.org/

Thus marking this one as deferred.
Though thanks for the patch!

-Alexey


>  cmd/bdinfo.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
> index d6a7175b379..31ec4615641 100644
> --- a/cmd/bdinfo.c
> +++ b/cmd/bdinfo.c
> @@ -439,20 +439,24 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, 
> char * const argv[])
>   return 0;
>  }
> 
>  #elif defined(CONFIG_ARC)
> 
>  int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  {
>   bd_t *bd = gd->bd;
> 
>   print_bi_mem(bd);
> + if (!(gd->flags & GD_FLG_SKIP_RELOC)) {
> + print_num("relocaddr", gd->relocaddr);
> + print_num("reloc off", gd->reloc_off);
> + }
>   print_eth_ip_addr();
>   print_baudrate();
> 
>   return 0;
>  }
> 
>  #elif defined(CONFIG_XTENSA)
> 
>  int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  {
> --
> 2.21.1



RE: [PATCH v2 17/39] bdinfo: arc: Use the generic bd command

2020-05-12 Thread Alexey Brodkin
Hi Simon,

> -Original Message-
> From: Simon Glass 
> Sent: Sunday, May 10, 2020 11:17 PM
> To: U-Boot Mailing List 
> Cc: Bin Meng ; Stefan Roese ; Tom Rini 
> ; Daniel
> Schwierzeck ; Simon Glass ; 
> Alexey Brodkin
> 
> Subject: [PATCH v2 17/39] bdinfo: arc: Use the generic bd command
> 
> There is nothing new in the arc 'bd' command beyond what is already there.
> Switch it over to use the generic code.
> 
> Signed-off-by: Simon Glass 

Acked-by: Alexey Brodkin 



RE: [PATCH 00/36] Tidy up the 'bd' command.

2020-05-06 Thread Alexey Brodkin
Hi Simon,

> -Original Message-
> From: Simon Glass 
> Sent: Tuesday, May 5, 2020 2:17 AM
> To: U-Boot Mailing List 

[snip]

> Subject: [PATCH 00/36] Tidy up the 'bd' command.
> 
> The code for the 'bd' command never got the 'generic board' treatment many
> years ago when global_data and bd_info were converted. As a result it
> still has a lot of arch-specific duplication of generic code.
> 
> This series aims to make as much code in this file generic as possible, so
> that it is easy to add new info on all architectures.
> 
> For the three architectures that actually need additional code (ARM, PPC
> and m68k) this is moved into arch-specific files.
> 
> With this series, bdinfo.c drops from nearly 500 lines to just over 100.
> 
> It also makes x86 report the frame buffer address properly (the original
> goal of my effort).
> 
> Simon Glass (36):
>   bdinfo: nds32: Use generic bd_info
>   bdinfo: riscv: Use generic bd_info
>   bdinfo: m68k: Drop bd_info->bi_ipbfreq
>   bdinfo: xtensa: Create a generic do_bdinfo for xtensa
>   bdinfo: mips: Use the generic bd command
>   bdinfo: nios2: Use the generic bd command
>   bdinfo: microblaze: Use the generic bd command
>   bdinfo: sh: Use the generic bd command
>   bdinfo: x86: Use the generic bd command
>   bdinfo: sandbox: Use the generic bd command
>   bdinfo: nds32: Use the generic bd command
>   bdinfo: riscv: Use the generic bd command
>   bdinfo: arm: Use the generic bd command

Looks like this one contains much more than just ARM changes.
Instead it looks like a massive migration to a generic bdinfo.
So I would propose either split it into per-arch changes
(though given this series size it might not be a good idea) or
alternatively maybe just ask for affected architecture maintainers
for an ack?

Also IMHO it would be very convenient to have a link to a git tree
with all these changes - it will significantly simplify review process.

But regardless all my comments above I'd like to note that this series
is very welcome as a long needed clean-up of that per-arch nonsense.
Thanks for doing this significant and useful work!

-Alexey


RE: [PATCH 20/36] bdinfo: sh: arc: Drop arch-specific print_bi_mem()

2020-05-06 Thread Alexey Brodkin
Hi Simon,

> Subject: Re: [PATCH 20/36] bdinfo: sh: arc: Drop arch-specific print_bi_mem()
> 
> On Tue, May 5, 2020 at 7:19 AM Simon Glass  wrote:
> >
> > It isn't worth having arch-specific code for such minor output
> > differences. In fact it is better if all archs are consistent.
> >
> > Drop the arch-specific code in print_bi_mem() and inline it to avoid a
> > two-line function.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >  cmd/bdinfo.c | 17 ++---
> >  1 file changed, 2 insertions(+), 15 deletions(-)

I guess this entire series is available in the following tree, right?
https://gitlab.denx.de/u-boot/custodians/u-boot-dm/-/tree/bd-working

In that case I'm very happy with that change as well as removal
of the duplicated spaghetti-code - thanks for taking care of that!

Acked-by: Alexey Brodkin 


RE: [U-Boot] Please pull more ARC changes for v2020.07-rc1

2020-04-27 Thread Alexey Brodkin
Hi Tom,

> -Original Message-
> From: Tom Rini 
> Sent: Monday, April 27, 2020 9:11 PM
> To: Alexey Brodkin 
> Cc: u-boot@lists.denx.de; uboot-snps-...@synopsys.com
> Subject: Re: [U-Boot] Please pull more ARC changes for v2020.07-rc1
> 
> On Mon, Apr 27, 2020 at 12:13:39PM +, Alexey Brodkin wrote:
> 
> > Hi Tom,
> >
> > The following changes since commit d202f67db0771247de562af5d6a5df778702857b:
> >
> >   Merge branch '2020-04-25-master-imports' (2020-04-25 08:20:22 -0400)
> >
> > are available in the Git repository at:
> >
> >   g...@gitlab.denx.de:u-boot/custodians/u-boot-arc.git 
> > tags/arc-more-fixes-for-2020.07-rc1
> >
> > for you to fetch changes up to 73b3c23e4818334f1e4ca3901358a228cab7e736:
> >
> >   ARC: AXS10x: cleanup kconfig (2020-04-27 15:04:42 +0300)
> >
> > 
> > Here we introduce new development platfrom for ARC: HSDK 4xD.
> > That's pretty much the same base-board as in HSDK but with
> > very recent quad-core ARC HS47D in the ASIC.
> >
> > Thus we try to re-use existing code as much as possible while
> > inevitably add some pieces needed for the new ASIC.
> >
> > Also we drop selection of bounce buffers on AXS10x
> > as there's no use of them any longer.
> 
> Looks like this requires a newer toolchain in CI than we have been
> using:
> https://gitlab.denx.de/u-boot/u-boot/-/jobs/84350#L738
> 
> Can you point me at something?  I could make a guess off of
> https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/
> but I'm not sure if we should use the rc toolchains or not.  Thanks!

Ooops sorry! Once in a very while I didn't run buildman with older toolchain
before sending you my pull-request and immediately you hit this :)

See what self isolation makes to people - kids jumping all over the place 24/7
barely help to concentrate :)

What happened we did add new CPU support in starting from arc-2019.03 release
that said you may safely use our previous release which was arc-2019.09.

You may find the tarball here:
https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2019.09-release/arc_gnu_2019.09_prebuilt_uclibc_le_archs_linux_install.tar.gz

Also I'm wondering if .travis.yml still being used, i.e. should I update
ARC toolchain there as well?

-Alexey


[U-Boot] Please pull more ARC changes for v2020.07-rc1

2020-04-27 Thread Alexey Brodkin
Hi Tom,

The following changes since commit d202f67db0771247de562af5d6a5df778702857b:

  Merge branch '2020-04-25-master-imports' (2020-04-25 08:20:22 -0400)

are available in the Git repository at:

  g...@gitlab.denx.de:u-boot/custodians/u-boot-arc.git 
tags/arc-more-fixes-for-2020.07-rc1

for you to fetch changes up to 73b3c23e4818334f1e4ca3901358a228cab7e736:

  ARC: AXS10x: cleanup kconfig (2020-04-27 15:04:42 +0300)


Here we introduce new development platfrom for ARC: HSDK 4xD.
That's pretty much the same base-board as in HSDK but with
very recent quad-core ARC HS47D in the ASIC.

Thus we try to re-use existing code as much as possible while
inevitably add some pieces needed for the new ASIC.

Also we drop selection of bounce buffers on AXS10x
as there's no use of them any longer.


Eugeniy Paltsev (15):
  ARC: ARCv2: handle DSP presence in HW
  ARC: HSDK: CGU: add support for timer clock
  ARC: HSDK-4xD: add initial board support
  ARC: HSDK: split HSDK and HSDK-4xD DTS
  ARC: HSDK-4xD: use active low polarity of cpu_start pulse
  ARC: HSDK-4xD: fix headerize script for HSDK-4xD compatibility
  ARC: HSDK-4xD: print info about HDMI clocks
  ARC: HSDK-4xD: drop additional GPU clock info
  ARC: HSDK-4xD: print timer clock value
  ARC: HSDK-4xD: add support for SLC enable/disable
  ARC: HSDK-4xD: add CSM configuration support
  ARC: HSDK-4xD: tweak memory map
  ARC: HSDK-4xD: use separate config file
  ARC: HSDK-4xD: make init status resistant to U-boot reloading
  ARC: AXS10x: cleanup kconfig

 arch/arc/Kconfig  |   4 +--
 arch/arc/dts/Makefile |   2 +-
 arch/arc/dts/hsdk-4xd.dts |  12 +
 arch/arc/dts/hsdk-common.dtsi | 152 
+
 arch/arc/dts/hsdk.dts | 145 
+++-
 arch/arc/include/asm/arcregs.h|   4 +++
 arch/arc/lib/start.S  |  15 
 board/synopsys/hsdk/Kconfig   |  20 ++-
 board/synopsys/hsdk/MAINTAINERS   |   5 +++-
 board/synopsys/hsdk/config.mk |  16 
 board/synopsys/hsdk/headerize-hsdk.py |   2 +-
 board/synopsys/hsdk/hsdk.c| 251 
+--
 configs/hsdk_4xd_defconfig|  67 
++
 drivers/clk/clk-hsdk-cgu.c|   9 ---
 include/configs/hsdk-4xd.h| 120 
+
 include/dt-bindings/clock/snps,hsdk-cgu.h |   5 ++--
 16 files changed, 657 insertions(+), 172 deletions(-)
 create mode 100644 arch/arc/dts/hsdk-4xd.dts
 create mode 100644 arch/arc/dts/hsdk-common.dtsi
 create mode 100644 configs/hsdk_4xd_defconfig
 create mode 100644 include/configs/hsdk-4xd.h

Regards,
Alexey


[U-Boot] Please pull ARC changes for v2020.07-rc1

2020-04-16 Thread Alexey Brodkin
Hi Tom,

The following changes since commit dba0a6ae1907bbff3ebda06e4874d006f10db1bb:

  Merge https://gitlab.denx.de/u-boot/custodians/u-boot-x86 (2020-04-16 
08:56:37 -0400)

are available in the Git repository at:

  g...@gitlab.denx.de:u-boot/custodians/u-boot-arc.git 
tags/arc-fixes-for-2020.07-rc1

for you to fetch changes up to 7b50db8242b62c85a19da9521b703faa858f4a63:

  ARC: HSDK: CGU: fix tunnel clock calculation (2020-04-16 23:37:10 +0300)


This is pretty minor set of changes mostly touching HSDK board:

 * Enable on-chip reset controller on HSDK
 * Add possibility to turn-on & off L2$ on more
   recent ARC HS processors.
 * AXI tunnel clock calculation on HSDK


Eugeniy Paltsev (4):
  ARC: CACHE: add support for SL$ disable
  ARC: CACHE: mark IOC helper functions as inlined_cachefunc
  ARC: HSDK: Enable on-chip reset controller
  ARC: HSDK: CGU: fix tunnel clock calculation

 arch/arc/dts/hsdk.dts|   7 +++
 arch/arc/include/asm/cache.h |   7 +++
 arch/arc/lib/cache.c | 118 
+-
 configs/hsdk_defconfig   |   1 +
 drivers/clk/clk-hsdk-cgu.c   |   3 ++-
 5 files changed, 126 insertions(+), 10 deletions(-)

-Alexey


[U-Boot] Please pull last-minute fixes for ARC

2020-03-31 Thread Alexey Brodkin
Hi Tom,

The following changes since commit 93330d4ce416208fe202e304e5a18166c57ac569:

  Prepare v2020.04-rc4 (2020-03-30 19:29:27 -0400)

are available in the Git repository at:

  g...@gitlab.denx.de:u-boot/custodians/u-boot-arc.git 
tags/arc-last-minute-fixes-for-2020.04

for you to fetch changes up to 45bd649511155b5b5a40851ca96036636cb95e23:

  ARC: IO: add MB for __raw_* memory accessors (2020-03-31 18:31:53 +0300)


This last minute pull-request is intended to fix some drivers
when used on ARC boards. The problem was introduced by
https://gitlab.denx.de/u-boot/u-boot/-/commit/07906b3dad157bd58411664bcc6a2a7976d5e0a9

What happened while doing one pretty simple improvement to make
U-Boot port more flexible and portable (by switching accessors from
assembly-written to plain C version) we implicitly added 2 problems:

 1. Downgraded accessors from being volatile which signalled to
the compiler that it's now possible to do all kinds of optimizations
which may easily include merge of subsequent byte reads/writes into
word operations. Which is OK for accessing mormal memory but
breaks operation of peripherals if we access its memory-mapped regs
in such a "creative" manner.
 2. As a part of assembly-written implementation we had compiler barriers
in form of the following construction 'asm volatile("" : : : "memory")',
and we dropped it in C implemntation. This in its turn enabled compiler
to mess with instruction ordering. Guess what it gives us in the end :)

So with all that we had in some corner-cases veeery funny instruction flows
generated. And in particular it broke DW SPI functionality when we were
writing large amount of data. Funny enough our tests which were writing
small amount of data still worked and only by the chance we caught that
breakage and unrolled that quite interesting loop of unexpected
problems.

The road to hell is paved with good intentions. Amen :)


Eugeniy Paltsev (3):
  ARC: IO: add volatile to accessors
  ARC: IO: add compiler barriers to IO accessors
  ARC: IO: add MB for __raw_* memory accessors

 arch/arc/include/asm/io.h | 92 
+++-
 1 file changed, 59 insertions(+), 33 deletions(-)

Regards,
Alexey


RE: [PATCH v2 0/3] ARC: IO: rework IO accessors

2020-03-30 Thread Alexey Brodkin
Hi Tom,

> -Original Message-
> From: Eugeniy Paltsev 
> Sent: Monday, March 30, 2020 10:45 PM
> To: uboot-snps-...@synopsys.com; Alexey Brodkin 
> Cc: u-boot@lists.denx.de; Eugeniy Paltsev 
> Subject: [PATCH v2 0/3] ARC: IO: rework IO accessors
> 
> Fixing of DW SPI which was broken by
> commit 07906b3dad15 ("ARC: Switch to generic accessors")
> lead me to several fixes in ARC IO accessors code.
> 
> Eugeniy Paltsev (3):
>   ARC: IO: add volatile to accessors
>   ARC: IO: add compiler barriers to IO accessors
>   ARC: IO: add MB for __raw_* memory accessors
> 
>  arch/arc/include/asm/io.h | 93 +--
>  1 file changed, 60 insertions(+), 33 deletions(-)

Just a heads-up: that's an important last-minute fix which we need to get
some peripherals working on our boards.

So given we're 6 days before release and this is as usual only
touching ARC code I'm going to pull this series in ASAP
and then send you my pull-request if you don't mind.

-Alexey




[U-Boot] Please pull ARC changes for v2020.04-rc2

2020-02-12 Thread Alexey Brodkin
Hi Tom,

The following changes since commit 26d4d77035d20364afc08c3098581a638b4edda8:

  Revert "gitlab: Disable SDL when building sandbox" (2020-02-12 08:05:54 -0500)

are available in the Git repository at:

  g...@gitlab.denx.de:u-boot/custodians/u-boot-arc.git 
tags/arc-fixes-for-2020.04-rc2

for you to fetch changes up to 07906b3dad157bd58411664bcc6a2a7976d5e0a9:

  ARC: Switch to generic accessors (2020-02-12 21:11:13 +0300)


As usual a bit late a couple of tiny fixes and improvements for ARC.

1. Switch from ARC UART to a convenient DW UART on ARC
   simulation platforms. This became avaialble when nSIM got support
   of that much more standard UART (starting from nSIM v2019.06).
   FWIW also available now in Free nSIM [1].

   This among other things allows us finally to use the same one binary
   on all our simulators & FPGA-based emulators.

2. Disable networking support on simulated platforms as there's no
   network interface in them.

3. Add Virtio net & block devices for the configuration supported
   by QEMU so that we may leverage those virtual peripherals and
   in fact it's possible to load uImage from TFTP server and bootm it.

4. Minor fixes for HSDK clocks.

5. Rework of how we chose and use compiler options for ARC-based boards.
   In real world ARC-based designs are customized more or less but very
   rarely match any of our "templates" thus it makes not much sense to
   pretend we have some fixed configs, instead we now will fully reply
   on a SoC or even board on getting precise set of compiler options
   preferably even extracted from real HW via "tcfgen" utility.

6. Well and finally yet another simplification - switch to generic
   written in C accessors which are much more universal and just work
   for any target supported by the complier as compared to GAS
   implementation which is much more target-dependent.

   This one was heavily "inspired" by similar implementation for RISCV
   and ARM.

[1] https://www.synopsys.com/cgi-bin/dwarcnsim/req1.cgi

--------
Alexey Brodkin (4):
  ARC: nSIM: switch from ARC UART to DW UART
  ARC: nsim_{700|700be|hs38be}_defconfigs: Disable networking
  ARC: nsim_hs38: Add support of Virtio NET & BLK
  ARC: Switch to generic accessors

Eugeniy Paltsev (3):
  CLK: HSDK: Check for PLL bypass firstly
  CLK: HSDK: fix HDMI clock calculation
  ARC: rework setting of ARC CPU specific compiler options

 arch/arc/Kconfig|   4 +--
 arch/arc/config.mk  |  20 ---
 arch/arc/dts/nsim.dts   |  36 +---
 arch/arc/include/asm/io.h   | 204 
++---
 board/abilis/tb100/config.mk|   5 +++
 board/synopsys/Kconfig  |   9 -
 board/synopsys/axs10x/config.mk |   6 
 board/synopsys/emsdp/config.mk  |   2 +-
 board/synopsys/hsdk/config.mk   |   4 +++
 board/synopsys/iot_devkit/config.mk |   3 +-
 board/synopsys/nsim/Kconfig |  21 
 board/synopsys/nsim/MAINTAINERS |   6 
 board/synopsys/nsim/Makefile|   7 
 board/synopsys/nsim/config.mk   |   8 +
 board/synopsys/nsim/nsim.c  |  26 +++
 configs/nsim_700_defconfig  |  10 +++---
 configs/nsim_700be_defconfig|  10 +++---
 configs/nsim_hs38_defconfig |  18 +++---
 configs/nsim_hs38be_defconfig   |  10 +++---
 drivers/clk/clk-hsdk-cgu.c  |  37 +
 20 files changed, 250 insertions(+), 196 deletions(-)
 create mode 100644 board/abilis/tb100/config.mk
 delete mode 100644 board/synopsys/Kconfig
 create mode 100644 board/synopsys/nsim/Kconfig
 create mode 100644 board/synopsys/nsim/MAINTAINERS
 create mode 100644 board/synopsys/nsim/Makefile
 create mode 100644 board/synopsys/nsim/config.mk
 create mode 100644 board/synopsys/nsim/nsim.c

Regards,
Alexey


[PATCH 3/3 v2] ARC: nsim_hs38: Add support of Virtio NET & BLK

2020-02-12 Thread Alexey Brodkin
Given now nsim_hs38 configuration is usable on QEMU and in QEMU
we have Virtio working perfectly fine the next logical step
is to add support of supported & known to work net & bkl to this
config.

Signed-off-by: Alexey Brodkin 
---

Changes v1 -> v2:

 * Instead of adding IRQ parent it might be much cleaner solution
   to just get rid of "interrupt" properties in Virtio nodes.
   Again that's all OK for now since we don't really sync Linux .dts
   and U-Boot's ones. It's not that it's super good though but
   that's what we have today :)

 arch/arc/Kconfig  |  4 ++--
 arch/arc/dts/nsim.dts | 24 
 board/synopsys/{ => nsim}/Kconfig |  3 +++
 board/synopsys/nsim/MAINTAINERS   |  6 ++
 board/synopsys/nsim/Makefile  |  7 +++
 board/synopsys/nsim/nsim.c| 26 ++
 configs/nsim_hs38_defconfig   |  9 +
 7 files changed, 77 insertions(+), 2 deletions(-)
 rename board/synopsys/{ => nsim}/Kconfig (74%)
 create mode 100644 board/synopsys/nsim/MAINTAINERS
 create mode 100644 board/synopsys/nsim/Makefile
 create mode 100644 board/synopsys/nsim/nsim.c

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 0cb97207db..545fc3e243 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -160,7 +160,7 @@ config TARGET_TB100
bool "Support tb100"
 
 config TARGET_NSIM
-   bool "Support standalone nSIM & Free nSIM"
+   bool "Support ARC simulation & prototyping platforms"
 
 config TARGET_AXS101
bool "Support Synopsys Designware SDP board AXS101"
@@ -184,10 +184,10 @@ config TARGET_IOT_DEVKIT
 endchoice
 
 source "board/abilis/tb100/Kconfig"
-source "board/synopsys/Kconfig"
 source "board/synopsys/axs10x/Kconfig"
 source "board/synopsys/emsdp/Kconfig"
 source "board/synopsys/hsdk/Kconfig"
 source "board/synopsys/iot_devkit/Kconfig"
+source "board/synopsys/nsim/Kconfig"
 
 endmenu
diff --git a/arch/arc/dts/nsim.dts b/arch/arc/dts/nsim.dts
index 43f281dfec..c2899ef2ea 100644
--- a/arch/arc/dts/nsim.dts
+++ b/arch/arc/dts/nsim.dts
@@ -30,4 +30,28 @@
clock-frequency = <7000>;
};
 
+   virtio0: virtio@f010 {
+   compatible = "virtio,mmio";
+   reg = <0xf010 0x2000>;
+   };
+
+   virtio1: virtio@f0102000 {
+   compatible = "virtio,mmio";
+   reg = <0xf0102000 0x2000>;
+   };
+
+   virtio2: virtio@f0104000 {
+   compatible = "virtio,mmio";
+   reg = <0xf0104000 0x2000>;
+   };
+
+   virtio3: virtio@f0106000 {
+   compatible = "virtio,mmio";
+   reg = <0xf0106000 0x2000>;
+   };
+
+   virtio4: virtio@f0108000 {
+   compatible = "virtio,mmio";
+   reg = <0xf0108000 0x2000>;
+   };
 };
diff --git a/board/synopsys/Kconfig b/board/synopsys/nsim/Kconfig
similarity index 74%
rename from board/synopsys/Kconfig
rename to board/synopsys/nsim/Kconfig
index 27e5509b26..22287032bf 100644
--- a/board/synopsys/Kconfig
+++ b/board/synopsys/nsim/Kconfig
@@ -1,5 +1,8 @@
 if TARGET_NSIM
 
+config SYS_BOARD
+   default "nsim"
+
 config SYS_VENDOR
default "synopsys"
 
diff --git a/board/synopsys/nsim/MAINTAINERS b/board/synopsys/nsim/MAINTAINERS
new file mode 100644
index 00..ad23c8338e
--- /dev/null
+++ b/board/synopsys/nsim/MAINTAINERS
@@ -0,0 +1,6 @@
+ARC SIMULATION & PROTOTYPING PLATFORMS
+M: Alexey Brodkin 
+S: Maintained
+F: arch/arc/dts/nsim.dts
+F: board/synopsys/nsim/
+F: configs/nsim_*_defconfig
diff --git a/board/synopsys/nsim/Makefile b/board/synopsys/nsim/Makefile
new file mode 100644
index 00..6aaa73
--- /dev/null
+++ b/board/synopsys/nsim/Makefile
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2020 Synopsys, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-y  += nsim.o
diff --git a/board/synopsys/nsim/nsim.c b/board/synopsys/nsim/nsim.c
new file mode 100644
index 00..f384f707f6
--- /dev/null
+++ b/board/synopsys/nsim/nsim.c
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 Synopsys, Inc. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+int board_early_init_r(void)
+{
+   /*
+* Make sure virtio bus is enumerated so that peripherals
+* on the virtio bus can be discovered by their drivers
+*/
+   virtio_init();
+
+   return 0;
+}
+
+int checkboard(void)
+{
+   printf("Board: ARC virtual or prototyping platform\n");
+   return 0;
+};
diff --git a/configs/nsim_hs38_defconfig b/configs/nsim_hs38_defconfig
index ce68de3251..6cd01a505b 100644
--- a/configs/nsim_hs38_defconfi

[PATCH 1/3 v2] ARC: nSIM: switch from ARC UART to DW UART

2020-02-12 Thread Alexey Brodkin
Since v2019.06 DesingWare nSIM supports DesignWare UART simulation
and so we may switch from pretty unusual ARC UART to much more standard
DesignWare UART (which in case of U-Boot is just an ordinary 16650 UART).

This among other things makes built dinaries compatible with our other
platforms to name a few: FPGA-based HAPS boards, QEMU and even ZeBU.

Signed-off-by: Alexey Brodkin 
---

Changes v1 -> v2:

 * Copyright year bumped to 2020.

 arch/arc/dts/nsim.dts | 12 +++-
 configs/nsim_700_defconfig|  8 
 configs/nsim_700be_defconfig  |  8 
 configs/nsim_hs38_defconfig   |  8 
 configs/nsim_hs38be_defconfig |  8 
 5 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/arch/arc/dts/nsim.dts b/arch/arc/dts/nsim.dts
index 243ecb178e..43f281dfec 100644
--- a/arch/arc/dts/nsim.dts
+++ b/arch/arc/dts/nsim.dts
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ * Copyright (C) 2015-2016, 2020 Synopsys, Inc. (www.synopsys.com)
  */
 /dts-v1/;
 
@@ -10,7 +10,7 @@
model = "snps,nsim";
 
aliases {
-   console = 
+   console = 
};
 
cpu_card {
@@ -22,9 +22,11 @@
};
};
 
-   arcuart0: serial@0xc0fc1000 {
-   compatible = "snps,arc-uart";
-   reg = <0xc0fc1000 0x100>;
+   uart0: serial@f000 {
+   compatible = "snps,dw-apb-uart";
+   reg = <0xf000 0x1000>;
+   reg-shift = <2>;
+   reg-io-width = <4>;
clock-frequency = <7000>;
};
 
diff --git a/configs/nsim_700_defconfig b/configs/nsim_700_defconfig
index 5633113b09..2d4a58b178 100644
--- a/configs/nsim_700_defconfig
+++ b/configs/nsim_700_defconfig
@@ -1,13 +1,13 @@
 CONFIG_ARC=y
 CONFIG_TARGET_NSIM=y
 CONFIG_SYS_TEXT_BASE=0x8100
-CONFIG_DEBUG_UART_BASE=0xc0fc1000
+CONFIG_DEBUG_UART_BASE=0xf000
 CONFIG_DEBUG_UART_CLOCK=7000
 CONFIG_SYS_CLK_FREQ=7000
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyARC0,115200n8"
+CONFIG_BOOTARGS="console=ttyS0,115200n8"
 CONFIG_SYS_PROMPT="nsim# "
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
@@ -16,6 +16,6 @@ CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
-CONFIG_DEBUG_ARC_SERIAL=y
-CONFIG_ARC_SERIAL=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYS_NS16550=y
 CONFIG_USE_PRIVATE_LIBGCC=y
diff --git a/configs/nsim_700be_defconfig b/configs/nsim_700be_defconfig
index 40f7ec7e1f..61eea91449 100644
--- a/configs/nsim_700be_defconfig
+++ b/configs/nsim_700be_defconfig
@@ -2,13 +2,13 @@ CONFIG_ARC=y
 CONFIG_CPU_BIG_ENDIAN=y
 CONFIG_TARGET_NSIM=y
 CONFIG_SYS_TEXT_BASE=0x8100
-CONFIG_DEBUG_UART_BASE=0xc0fc1000
+CONFIG_DEBUG_UART_BASE=0xf000
 CONFIG_DEBUG_UART_CLOCK=7000
 CONFIG_SYS_CLK_FREQ=7000
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyARC0,115200n8"
+CONFIG_BOOTARGS="console=ttyS0,115200n8"
 CONFIG_SYS_PROMPT="nsim# "
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
@@ -17,6 +17,6 @@ CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
-CONFIG_DEBUG_ARC_SERIAL=y
-CONFIG_ARC_SERIAL=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYS_NS16550=y
 CONFIG_USE_PRIVATE_LIBGCC=y
diff --git a/configs/nsim_hs38_defconfig b/configs/nsim_hs38_defconfig
index 2820a6fca3..ce68de3251 100644
--- a/configs/nsim_hs38_defconfig
+++ b/configs/nsim_hs38_defconfig
@@ -2,13 +2,13 @@ CONFIG_ARC=y
 CONFIG_ISA_ARCV2=y
 CONFIG_TARGET_NSIM=y
 CONFIG_SYS_TEXT_BASE=0x8100
-CONFIG_DEBUG_UART_BASE=0xc0fc1000
+CONFIG_DEBUG_UART_BASE=0xf000
 CONFIG_DEBUG_UART_CLOCK=7000
 CONFIG_SYS_CLK_FREQ=7000
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyARC0,115200n8"
+CONFIG_BOOTARGS="console=ttyS0,115200n8"
 CONFIG_SYS_PROMPT="nsim# "
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
@@ -17,6 +17,6 @@ CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
-CONFIG_DEBUG_ARC_SERIAL=y
-CONFIG_ARC_SERIAL=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYS_NS16550=y
 CONFIG_USE_PRIVATE_LIBGCC=y
diff --git a/configs/nsim_hs38be_defconfig b/configs/nsim_hs38be_defconfig
index e533fae2b1..5d2ea59d52 100644
--- a/configs/nsim_hs38be_defconfig
+++ b/configs/nsim_hs38be_defconfig
@@ -3,13 +3,13 @@ CONFIG_ISA_ARCV2=y
 CONFIG_CPU_BIG_ENDIAN=y
 CONFIG_TARGET_NSIM=y
 CONFIG_SYS_TEXT_BASE=0x8100
-CONFIG_DEBUG_UART_BASE=0xc0fc1000
+CONFIG_DEBUG_UART_BASE=0xf000
 CONFIG_DEBUG_UART_CLOCK=7000
 CONFIG_SYS_CLK_FREQ=7000
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOT

[PATCH 2/3 v2] ARC: nsim_{700|700be|hs38be}_defconfigs: Disable networking

2020-02-12 Thread Alexey Brodkin
We don't have yet any brc700 or big-enadian platforms with networking
support to run this particular configuration.

Whenever QEMU for ARC supports arc700 or big-endian targets we may revisit
this one.

Signed-off-by: Alexey Brodkin 
---

No changes v1 -> v2.

 configs/nsim_700_defconfig| 1 +
 configs/nsim_700be_defconfig  | 1 +
 configs/nsim_hs38be_defconfig | 1 +
 3 files changed, 3 insertions(+)

diff --git a/configs/nsim_700_defconfig b/configs/nsim_700_defconfig
index 2d4a58b178..6a38e2c246 100644
--- a/configs/nsim_700_defconfig
+++ b/configs/nsim_700_defconfig
@@ -14,6 +14,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_OF_EMBED=y
 CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_NET is not set
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_SHIFT=2
diff --git a/configs/nsim_700be_defconfig b/configs/nsim_700be_defconfig
index 61eea91449..d3ed84a415 100644
--- a/configs/nsim_700be_defconfig
+++ b/configs/nsim_700be_defconfig
@@ -15,6 +15,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_OF_EMBED=y
 CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_NET is not set
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_SHIFT=2
diff --git a/configs/nsim_hs38be_defconfig b/configs/nsim_hs38be_defconfig
index 5d2ea59d52..b074b4ca98 100644
--- a/configs/nsim_hs38be_defconfig
+++ b/configs/nsim_hs38be_defconfig
@@ -16,6 +16,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_OF_EMBED=y
 CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_NET is not set
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_SHIFT=2
-- 
2.16.2



[RFC 0/2] Import and use non-atomic bit-ops

2020-01-20 Thread Alexey Brodkin
The following bitops are implemented pretty similarly for many
arches and now when we faced a need in them on ARC I guess there's
no point in copy-pasting them yet another time but instead it might
be better re-use generic version from the Linux kernel.

Since we had non of those bitops for ARC inclusion of imported header
works perfectly fine. As for other arches I do see they use a bit different
implementation but those might be just older versions etc.

Sobefore breaking stuff for other arches I'd like to get some feedback
from maintainers. Or we may just import proposed header and switch to
its usage arch-by-arch whenever people feel kile cleaning-up their bitops.

Alexey Brodkin (2):
  include: Import non-atomic.h from Linux
  ARC: Add support of bitops via generic implementation

 arch/arc/include/asm/bitops.h   |   1 +
 include/asm-generic/bitops/non-atomic.h | 109 
 2 files changed, 110 insertions(+)
 create mode 100644 include/asm-generic/bitops/non-atomic.h

-- 
2.16.2



[RFC 2/2] ARC: Add support of bitops via generic implementation

2020-01-20 Thread Alexey Brodkin
This allows building more things. In particular with
CONFIG_PKCS7_MESSAGE_PARSER=y we saw this:
>8--
lib/crypto/pkcs7_parser.c: In function 'pkcs7_sig_note_authenticated_attr':
lib/crypto/pkcs7_parser.c:489:7: warning: implicit declaration of function 
'__test_and_set_bit' [-Wimplicit-function-declaration]
  489 |   if (__test_and_set_bit(sinfo_has_content_type, >aa_set))
  |   ^~
  CC  lib/crc32.o
  CC  lib/ctype.o
  DTB test/overlay/test-fdt-overlay-stacked.dtb.S
  CC  lib/div64.o
lib/crypto/pkcs7_parser.c: In function 'pkcs7_sig_note_set_of_authattrs':
lib/crypto/pkcs7_parser.c:572:7: warning: implicit declaration of function 
'test_bit' [-Wimplicit-function-declaration]
  572 |  if (!test_bit(sinfo_has_content_type, >aa_set) ||
...
  LD  u-boot
arc-elf32-ld.bfd: lib/built-in.o: in function 
'pkcs7_sig_note_authenticated_attr':
.../lib/crypto/pkcs7_parser.c:489: undefined reference to '__test_and_set_bit'
arc-elf32-ld.bfd: .../lib/crypto/pkcs7_parser.c:489: undefined reference to 
'__test_and_set_bit'
arc-elf32-ld.bfd: .../lib/crypto/pkcs7_parser.c:501: undefined reference to 
'__test_and_set_bit'
arc-elf32-ld.bfd: .../lib/crypto/pkcs7_parser.c:501: undefined reference to 
'__test_and_set_bit'
arc-elf32-ld.bfd: .../lib/crypto/pkcs7_parser.c:510: undefined reference to 
'__test_and_set_bit'
arc-elf32-ld.bfd: lib/built-in.o:.../lib/crypto/pkcs7_parser.c:510: more 
undefined references to '__test_and_set_bit' follow
arc-elf32-ld.bfd: lib/built-in.o: in function 'pkcs7_sig_note_set_of_authattrs':
.../lib/crypto/pkcs7_parser.c:572: undefined reference to `test_bit'
arc-elf32-ld.bfd: .../lib/crypto/pkcs7_parser.c:572: undefined reference to 
`test_bit'
arc-elf32-ld.bfd: .../lib/crypto/pkcs7_parser.c:573: undefined reference to 
`test_bit'
arc-elf32-ld.bfd: .../lib/crypto/pkcs7_parser.c:573: undefined reference to 
`test_bit'
arc-elf32-ld.bfd: .../lib/crypto/pkcs7_parser.c:579: undefined reference to 
`test_bit'
arc-elf32-ld.bfd: lib/built-in.o:.../lib/crypto/pkcs7_parser.c:579: more 
undefined references to 'test_bit' follow
>8--

Signed-off-by: Alexey Brodkin 
---
 arch/arc/include/asm/bitops.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arc/include/asm/bitops.h b/arch/arc/include/asm/bitops.h
index c6dd28ecef..daa07e80a8 100644
--- a/arch/arc/include/asm/bitops.h
+++ b/arch/arc/include/asm/bitops.h
@@ -19,5 +19,6 @@
 #include 
 #include 
 #include 
+#include 
 
 #endif /* __ASM_ARC_BITOPS_H */
-- 
2.16.2



[RFC 1/2] include: Import non-atomic.h from Linux

2020-01-20 Thread Alexey Brodkin
This header contains implementations of some common bit ops:
 * __set_bit()/__clear_bit()/__change_bit()/test_bit()
 * __test_and_set_bit()/__test_and_clear_bit()/__test_and_change_bit()

No point in copy-pasting that again & again.

Signed-off-by: Alexey Brodkin 
---
 include/asm-generic/bitops/non-atomic.h | 109 
 1 file changed, 109 insertions(+)
 create mode 100644 include/asm-generic/bitops/non-atomic.h

diff --git a/include/asm-generic/bitops/non-atomic.h 
b/include/asm-generic/bitops/non-atomic.h
new file mode 100644
index 00..9b3be37fff
--- /dev/null
+++ b/include/asm-generic/bitops/non-atomic.h
@@ -0,0 +1,109 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_GENERIC_BITOPS_NON_ATOMIC_H_
+#define _ASM_GENERIC_BITOPS_NON_ATOMIC_H_
+
+#include 
+
+/**
+ * __set_bit - Set a bit in memory
+ * @nr: the bit to set
+ * @addr: the address to start counting from
+ *
+ * Unlike set_bit(), this function is non-atomic and may be reordered.
+ * If it's called on the same region of memory simultaneously, the effect
+ * may be that only one operation succeeds.
+ */
+static inline void __set_bit(int nr, volatile unsigned long *addr)
+{
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+
+   *p  |= mask;
+}
+
+static inline void __clear_bit(int nr, volatile unsigned long *addr)
+{
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+
+   *p &= ~mask;
+}
+
+/**
+ * __change_bit - Toggle a bit in memory
+ * @nr: the bit to change
+ * @addr: the address to start counting from
+ *
+ * Unlike change_bit(), this function is non-atomic and may be reordered.
+ * If it's called on the same region of memory simultaneously, the effect
+ * may be that only one operation succeeds.
+ */
+static inline void __change_bit(int nr, volatile unsigned long *addr)
+{
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+
+   *p ^= mask;
+}
+
+/**
+ * __test_and_set_bit - Set a bit and return its old value
+ * @nr: Bit to set
+ * @addr: Address to count from
+ *
+ * This operation is non-atomic and can be reordered.
+ * If two examples of this operation race, one can appear to succeed
+ * but actually fail.  You must protect multiple accesses with a lock.
+ */
+static inline int __test_and_set_bit(int nr, volatile unsigned long *addr)
+{
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+   unsigned long old = *p;
+
+   *p = old | mask;
+   return (old & mask) != 0;
+}
+
+/**
+ * __test_and_clear_bit - Clear a bit and return its old value
+ * @nr: Bit to clear
+ * @addr: Address to count from
+ *
+ * This operation is non-atomic and can be reordered.
+ * If two examples of this operation race, one can appear to succeed
+ * but actually fail.  You must protect multiple accesses with a lock.
+ */
+static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr)
+{
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+   unsigned long old = *p;
+
+   *p = old & ~mask;
+   return (old & mask) != 0;
+}
+
+/* WARNING: non atomic and it can be reordered! */
+static inline int __test_and_change_bit(int nr,
+   volatile unsigned long *addr)
+{
+   unsigned long mask = BIT_MASK(nr);
+   unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+   unsigned long old = *p;
+
+   *p = old ^ mask;
+   return (old & mask) != 0;
+}
+
+/**
+ * test_bit - Determine whether a bit is set
+ * @nr: bit number to test
+ * @addr: Address to start counting from
+ */
+static inline int test_bit(int nr, const volatile unsigned long *addr)
+{
+   return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG - 1)));
+}
+
+#endif /* _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ */
-- 
2.16.2



[PATCH 1/3] ARC: nSIM: switch from ARC UART to DW UART

2020-01-20 Thread Alexey Brodkin
Since v2019.06 DesingWare nSIM supports DesignWare UART simulation
and so we may switch from pretty unusual ARC UART to much more standard
DesignWare UART (which in case of U-Boot is just an ordinary 16650 UART).

This among other things makes built dinaries compatible with our other
platforms to name a few: FPGA-based HAPS boards, QEMU and even ZeBU.

Signed-off-by: Alexey Brodkin 
---
 arch/arc/dts/nsim.dts | 12 +++-
 configs/nsim_700_defconfig|  8 
 configs/nsim_700be_defconfig  |  8 
 configs/nsim_hs38_defconfig   |  8 
 configs/nsim_hs38be_defconfig |  8 
 5 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/arch/arc/dts/nsim.dts b/arch/arc/dts/nsim.dts
index 243ecb178e..a3f3964d35 100644
--- a/arch/arc/dts/nsim.dts
+++ b/arch/arc/dts/nsim.dts
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ * Copyright (C) 2015-2016, 2019 Synopsys, Inc. (www.synopsys.com)
  */
 /dts-v1/;
 
@@ -10,7 +10,7 @@
model = "snps,nsim";
 
aliases {
-   console = 
+   console = 
};
 
cpu_card {
@@ -22,9 +22,11 @@
};
};
 
-   arcuart0: serial@0xc0fc1000 {
-   compatible = "snps,arc-uart";
-   reg = <0xc0fc1000 0x100>;
+   uart0: serial@f000 {
+   compatible = "snps,dw-apb-uart";
+   reg = <0xf000 0x1000>;
+   reg-shift = <2>;
+   reg-io-width = <4>;
clock-frequency = <7000>;
};
 
diff --git a/configs/nsim_700_defconfig b/configs/nsim_700_defconfig
index 5633113b09..2d4a58b178 100644
--- a/configs/nsim_700_defconfig
+++ b/configs/nsim_700_defconfig
@@ -1,13 +1,13 @@
 CONFIG_ARC=y
 CONFIG_TARGET_NSIM=y
 CONFIG_SYS_TEXT_BASE=0x8100
-CONFIG_DEBUG_UART_BASE=0xc0fc1000
+CONFIG_DEBUG_UART_BASE=0xf000
 CONFIG_DEBUG_UART_CLOCK=7000
 CONFIG_SYS_CLK_FREQ=7000
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyARC0,115200n8"
+CONFIG_BOOTARGS="console=ttyS0,115200n8"
 CONFIG_SYS_PROMPT="nsim# "
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
@@ -16,6 +16,6 @@ CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
-CONFIG_DEBUG_ARC_SERIAL=y
-CONFIG_ARC_SERIAL=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYS_NS16550=y
 CONFIG_USE_PRIVATE_LIBGCC=y
diff --git a/configs/nsim_700be_defconfig b/configs/nsim_700be_defconfig
index 40f7ec7e1f..61eea91449 100644
--- a/configs/nsim_700be_defconfig
+++ b/configs/nsim_700be_defconfig
@@ -2,13 +2,13 @@ CONFIG_ARC=y
 CONFIG_CPU_BIG_ENDIAN=y
 CONFIG_TARGET_NSIM=y
 CONFIG_SYS_TEXT_BASE=0x8100
-CONFIG_DEBUG_UART_BASE=0xc0fc1000
+CONFIG_DEBUG_UART_BASE=0xf000
 CONFIG_DEBUG_UART_CLOCK=7000
 CONFIG_SYS_CLK_FREQ=7000
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyARC0,115200n8"
+CONFIG_BOOTARGS="console=ttyS0,115200n8"
 CONFIG_SYS_PROMPT="nsim# "
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
@@ -17,6 +17,6 @@ CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
-CONFIG_DEBUG_ARC_SERIAL=y
-CONFIG_ARC_SERIAL=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYS_NS16550=y
 CONFIG_USE_PRIVATE_LIBGCC=y
diff --git a/configs/nsim_hs38_defconfig b/configs/nsim_hs38_defconfig
index 2820a6fca3..ce68de3251 100644
--- a/configs/nsim_hs38_defconfig
+++ b/configs/nsim_hs38_defconfig
@@ -2,13 +2,13 @@ CONFIG_ARC=y
 CONFIG_ISA_ARCV2=y
 CONFIG_TARGET_NSIM=y
 CONFIG_SYS_TEXT_BASE=0x8100
-CONFIG_DEBUG_UART_BASE=0xc0fc1000
+CONFIG_DEBUG_UART_BASE=0xf000
 CONFIG_DEBUG_UART_CLOCK=7000
 CONFIG_SYS_CLK_FREQ=7000
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyARC0,115200n8"
+CONFIG_BOOTARGS="console=ttyS0,115200n8"
 CONFIG_SYS_PROMPT="nsim# "
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
@@ -17,6 +17,6 @@ CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
-CONFIG_DEBUG_ARC_SERIAL=y
-CONFIG_ARC_SERIAL=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYS_NS16550=y
 CONFIG_USE_PRIVATE_LIBGCC=y
diff --git a/configs/nsim_hs38be_defconfig b/configs/nsim_hs38be_defconfig
index e533fae2b1..5d2ea59d52 100644
--- a/configs/nsim_hs38be_defconfig
+++ b/configs/nsim_hs38be_defconfig
@@ -3,13 +3,13 @@ CONFIG_ISA_ARCV2=y
 CONFIG_CPU_BIG_ENDIAN=y
 CONFIG_TARGET_NSIM=y
 CONFIG_SYS_TEXT_BASE=0x8100
-CONFIG_DEBUG_UART_BASE=0xc0fc1000
+CONFIG_DEBUG_UART_BASE=0xf000
 CONFIG_DEBUG_UART_CLOCK=7000
 CONFIG_SYS_CLK_FREQ=7000
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyARC0

[PATCH 0/3] Improvements for ARC simulation platform

2020-01-20 Thread Alexey Brodkin
Along with some clean-up we make 2 important changes:
 1. Switch to more standard 16550 UART instead of our custom "ARC UART".
This paves the way for using this board in QEMU.

 2. Now when nSIM virtual board is usable in QEMU we add support of Virtio
NIC & block device similarly as we did that in the Linux kernel [1].

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=94b8beb972c524f42078281c9950ed3a946455fa

Alexey Brodkin (3):
  ARC: nSIM: switch from ARC UART to DW UART
  ARC: nsim_{700|700be|hs38be}_defconfigs: Disable networking
  ARC: nsim_hs38: Add support of Virtio NET & BLK

 arch/arc/Kconfig  |  4 ++--
 arch/arc/dts/nsim.dts | 48 +++
 board/synopsys/{ => nsim}/Kconfig |  3 +++
 board/synopsys/nsim/MAINTAINERS   |  6 +
 board/synopsys/nsim/Makefile  |  7 ++
 board/synopsys/nsim/nsim.c| 26 +
 configs/nsim_700_defconfig|  9 
 configs/nsim_700be_defconfig  |  9 
 configs/nsim_hs38_defconfig   | 17 ++
 configs/nsim_hs38be_defconfig |  9 
 10 files changed, 115 insertions(+), 23 deletions(-)
 rename board/synopsys/{ => nsim}/Kconfig (74%)
 create mode 100644 board/synopsys/nsim/MAINTAINERS
 create mode 100644 board/synopsys/nsim/Makefile
 create mode 100644 board/synopsys/nsim/nsim.c

-- 
2.16.2



[PATCH 3/3] ARC: nsim_hs38: Add support of Virtio NET & BLK

2020-01-20 Thread Alexey Brodkin
Given now nsim_hs38 configuration is usable on QEMU and in QEMU
we have Virtio working perfectly fine the next logical step
is to add support of supported & known to work net & bkl to this
config.

Note so far we don't have device tree descriptions synced from
the mainline Linux kernel (which we'll need to do anyway at some point)
and as of now we keep U-Boot's device trees as minimalistic as possible
in nSIM description we had to add core's interrupt controller node and
set it as everyone's interrupt-parent. That's required to make buildman
happy. Otherwise it complains like that:
>8
w+arch/arc/dts/nsim.dtb: Warning (interrupts_property): /virtio@f010: 
Missing interrupt-parent
>8

Signed-off-by: Alexey Brodkin 
---
 arch/arc/Kconfig  |  4 ++--
 arch/arc/dts/nsim.dts | 36 
 board/synopsys/{ => nsim}/Kconfig |  3 +++
 board/synopsys/nsim/MAINTAINERS   |  6 ++
 board/synopsys/nsim/Makefile  |  7 +++
 board/synopsys/nsim/nsim.c| 26 ++
 configs/nsim_hs38_defconfig   |  9 +
 7 files changed, 89 insertions(+), 2 deletions(-)
 rename board/synopsys/{ => nsim}/Kconfig (74%)
 create mode 100644 board/synopsys/nsim/MAINTAINERS
 create mode 100644 board/synopsys/nsim/Makefile
 create mode 100644 board/synopsys/nsim/nsim.c

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 0cb97207db..545fc3e243 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -160,7 +160,7 @@ config TARGET_TB100
bool "Support tb100"
 
 config TARGET_NSIM
-   bool "Support standalone nSIM & Free nSIM"
+   bool "Support ARC simulation & prototyping platforms"
 
 config TARGET_AXS101
bool "Support Synopsys Designware SDP board AXS101"
@@ -184,10 +184,10 @@ config TARGET_IOT_DEVKIT
 endchoice
 
 source "board/abilis/tb100/Kconfig"
-source "board/synopsys/Kconfig"
 source "board/synopsys/axs10x/Kconfig"
 source "board/synopsys/emsdp/Kconfig"
 source "board/synopsys/hsdk/Kconfig"
 source "board/synopsys/iot_devkit/Kconfig"
+source "board/synopsys/nsim/Kconfig"
 
 endmenu
diff --git a/arch/arc/dts/nsim.dts b/arch/arc/dts/nsim.dts
index a3f3964d35..a902c4c4fa 100644
--- a/arch/arc/dts/nsim.dts
+++ b/arch/arc/dts/nsim.dts
@@ -8,6 +8,7 @@
 
 / {
model = "snps,nsim";
+   interrupt-parent = <_intc>;
 
aliases {
console = 
@@ -20,6 +21,12 @@
clock-frequency = <7000>;
u-boot,dm-pre-reloc;
};
+
+   core_intc: interrupt-controller {
+   compatible = "snps,archs-intc";
+   interrupt-controller;
+   #interrupt-cells = <1>;
+   };
};
 
uart0: serial@f000 {
@@ -30,4 +37,33 @@
clock-frequency = <7000>;
};
 
+   virtio0: virtio@f010 {
+   compatible = "virtio,mmio";
+   reg = <0xf010 0x2000>;
+   interrupts = <31>;
+   };
+
+   virtio1: virtio@f0102000 {
+   compatible = "virtio,mmio";
+   reg = <0xf0102000 0x2000>;
+   interrupts = <32>;
+   };
+
+   virtio2: virtio@f0104000 {
+   compatible = "virtio,mmio";
+   reg = <0xf0104000 0x2000>;
+   interrupts = <33>;
+   };
+
+   virtio3: virtio@f0106000 {
+   compatible = "virtio,mmio";
+   reg = <0xf0106000 0x2000>;
+   interrupts = <34>;
+   };
+
+   virtio4: virtio@f0108000 {
+   compatible = "virtio,mmio";
+   reg = <0xf0108000 0x2000>;
+   interrupts = <35>;
+   };
 };
diff --git a/board/synopsys/Kconfig b/board/synopsys/nsim/Kconfig
similarity index 74%
rename from board/synopsys/Kconfig
rename to board/synopsys/nsim/Kconfig
index 27e5509b26..22287032bf 100644
--- a/board/synopsys/Kconfig
+++ b/board/synopsys/nsim/Kconfig
@@ -1,5 +1,8 @@
 if TARGET_NSIM
 
+config SYS_BOARD
+   default "nsim"
+
 config SYS_VENDOR
default "synopsys"
 
diff --git a/board/synopsys/nsim/MAINTAINERS b/board/synopsys/nsim/MAINTAINERS
new file mode 100644
index 00..ed4b9a9e78
--- /dev/null
+++ b/board/synopsys/nsim/MAINTAINERS
@@ -0,0 +1,6 @@
+EM DEVELOPMENT KIT BOARD
+M: Alexey Brodkin 
+S: Maintained
+F: arch/arc/dts/nsim.dts
+F: board/synopsys/nsim/
+F: configs/nsim_*_defconfig
diff --git a/board/synopsys/nsim/Makefile b/board/synopsys/nsim/Makefile
new file mode 100644
index 00

[PATCH 2/3] ARC: nsim_{700|700be|hs38be}_defconfigs: Disable networking

2020-01-20 Thread Alexey Brodkin
We don't have yet any brc700 or big-enadian platforms with networking
support to run this particular configuration.

Whenever QEMU for ARC supports arc700 or big-endian targets we may revisit
this one.

Signed-off-by: Alexey Brodkin 
---
 configs/nsim_700_defconfig| 1 +
 configs/nsim_700be_defconfig  | 1 +
 configs/nsim_hs38be_defconfig | 1 +
 3 files changed, 3 insertions(+)

diff --git a/configs/nsim_700_defconfig b/configs/nsim_700_defconfig
index 2d4a58b178..6a38e2c246 100644
--- a/configs/nsim_700_defconfig
+++ b/configs/nsim_700_defconfig
@@ -14,6 +14,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_OF_EMBED=y
 CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_NET is not set
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_SHIFT=2
diff --git a/configs/nsim_700be_defconfig b/configs/nsim_700be_defconfig
index 61eea91449..d3ed84a415 100644
--- a/configs/nsim_700be_defconfig
+++ b/configs/nsim_700be_defconfig
@@ -15,6 +15,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_OF_EMBED=y
 CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_NET is not set
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_SHIFT=2
diff --git a/configs/nsim_hs38be_defconfig b/configs/nsim_hs38be_defconfig
index 5d2ea59d52..b074b4ca98 100644
--- a/configs/nsim_hs38be_defconfig
+++ b/configs/nsim_hs38be_defconfig
@@ -16,6 +16,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_OF_EMBED=y
 CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_NET is not set
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_SHIFT=2
-- 
2.16.2



[PATCH] ARC: Switch to generic accessors

2020-01-20 Thread Alexey Brodkin
First of all U-Boot is not that performance oriented as real run-time
software like OS or user bare-metal app so we may afford being not super
fast as we only being executed once. That in return allows us to be more
universal and support wider variety of devices.

And looking forward that will significantly reduce maintenance and simplify
support of newer architectures.

And while at it we add quad-word accessors like readq(), writeq() etc.

Signed-off-by: Alexey Brodkin 
---
 arch/arc/include/asm/io.h | 204 +-
 1 file changed, 75 insertions(+), 129 deletions(-)

diff --git a/arch/arc/include/asm/io.h b/arch/arc/include/asm/io.h
index fa844b54f4..70d050590d 100644
--- a/arch/arc/include/asm/io.h
+++ b/arch/arc/include/asm/io.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
+ * Copyright (C) 2013-2014, 2020 Synopsys, Inc. All rights reserved.
  */
 
 #ifndef __ASM_ARC_IO_H
@@ -54,135 +54,98 @@ static inline void sync(void)
/* Not yet implemented */
 }
 
-static inline u8 __raw_readb(const volatile void __iomem *addr)
-{
-   u8 b;
+#define __arch_getb(a) (*(unsigned char *)(a))
+#define __arch_getw(a) (*(unsigned short *)(a))
+#define __arch_getl(a) (*(unsigned int *)(a))
+#define __arch_getq(a) (*(unsigned long long *)(a))
 
-   __asm__ __volatile__("ldb%U1%0, %1\n"
-: "=r" (b)
-: "m" (*(volatile u8 __force *)addr)
-: "memory");
-   return b;
-}
+#define __arch_putb(v, a)  (*(unsigned char *)(a) = (v))
+#define __arch_putw(v, a)  (*(unsigned short *)(a) = (v))
+#define __arch_putl(v, a)  (*(unsigned int *)(a) = (v))
+#define __arch_putq(v, a)  (*(unsigned long long *)(a) = (v))
 
-static inline u16 __raw_readw(const volatile void __iomem *addr)
-{
-   u16 s;
+#define __raw_writeb(v, a) __arch_putb(v, a)
+#define __raw_writew(v, a) __arch_putw(v, a)
+#define __raw_writel(v, a) __arch_putl(v, a)
+#define __raw_writeq(v, a) __arch_putq(v, a)
 
-   __asm__ __volatile__("ldw%U1%0, %1\n"
-: "=r" (s)
-: "m" (*(volatile u16 __force *)addr)
-: "memory");
-   return s;
-}
+#define __raw_readb(a) __arch_getb(a)
+#define __raw_readw(a) __arch_getw(a)
+#define __raw_readl(a) __arch_getl(a)
+#define __raw_readq(a) __arch_getq(a)
 
-static inline u32 __raw_readl(const volatile void __iomem *addr)
+static inline void __raw_writesb(unsigned long addr, const void *data,
+int bytelen)
 {
-   u32 w;
+   u8 *buf = (uint8_t *)data;
 
-   __asm__ __volatile__("ld%U1 %0, %1\n"
-: "=r" (w)
-: "m" (*(volatile u32 __force *)addr)
-: "memory");
-   return w;
+   while (bytelen--)
+   __arch_putb(*buf++, addr);
 }
 
-static inline void __raw_writeb(u8 b, volatile void __iomem *addr)
+static inline void __raw_writesw(unsigned long addr, const void *data,
+int wordlen)
 {
-   __asm__ __volatile__("stb%U1%0, %1\n"
-:
-: "r" (b), "m" (*(volatile u8 __force *)addr)
-: "memory");
-}
+   u16 *buf = (uint16_t *)data;
 
-static inline void __raw_writew(u16 s, volatile void __iomem *addr)
-{
-   __asm__ __volatile__("stw%U1%0, %1\n"
-:
-: "r" (s), "m" (*(volatile u16 __force *)addr)
-: "memory");
+   while (wordlen--)
+   __arch_putw(*buf++, addr);
 }
 
-static inline void __raw_writel(u32 w, volatile void __iomem *addr)
+static inline void __raw_writesl(unsigned long addr, const void *data,
+int longlen)
 {
-   __asm__ __volatile__("st%U1 %0, %1\n"
-:
-: "r" (w), "m" (*(volatile u32 __force *)addr)
-: "memory");
-}
+   u32 *buf = (uint32_t *)data;
 
-static inline int __raw_readsb(unsigned int addr, void *data, int bytelen)
-{
-   __asm__ __volatile__ ("1:ld.di  r8, [r0]\n"
- "sub.fr2, r2, 1\n"
- "bnz.d1b\n"
- "stb.ab   r8, [r1, 1]\n"
- :
- : "r" (addr), "r" (data), &qu

[PATCH] ARC: Don't mess with endianess settings

2020-01-20 Thread Alexey Brodkin
There seem to be not that much sense in explicitly setting endianess
flags for the tools as we assume the tool with required endianess is
used. I.e. we use LE tools for building for LE targets and BE tools
for BE targets.

Signed-off-by: Alexey Brodkin 
---
 arch/arc/config.mk | 10 --
 1 file changed, 10 deletions(-)

diff --git a/arch/arc/config.mk b/arch/arc/config.mk
index 18005d9993..4b8a0870eb 100644
--- a/arch/arc/config.mk
+++ b/arch/arc/config.mk
@@ -8,16 +8,6 @@ else
 CONFIG_SYS_BIG_ENDIAN = 1
 endif
 
-ifdef CONFIG_SYS_LITTLE_ENDIAN
-PLATFORM_LDFLAGS += -EL
-PLATFORM_CPPFLAGS += -mlittle-endian
-endif
-
-ifdef CONFIG_SYS_BIG_ENDIAN
-PLATFORM_LDFLAGS += -EB
-PLATFORM_CPPFLAGS += -mbig-endian
-endif
-
 ifdef CONFIG_ARC_MMU_VER
 CONFIG_MMU = 1
 endif
-- 
2.16.2



[PATCH 3/3] ARC: nsim_hs38: Add support of Virtio NET & BLK

2019-12-26 Thread Alexey Brodkin
Given now nsim_hs38 configuration is usable on QEMU and in QEMU
we have Virtio working perfectly fine the next logical step
is to add support of supported & known to work net & bkl to this
config.

Signed-off-by: Alexey Brodkin 
---
 arch/arc/Kconfig  |  4 ++--
 arch/arc/dts/nsim.dts | 29 +
 board/synopsys/{ => nsim}/Kconfig |  3 +++
 board/synopsys/nsim/MAINTAINERS   |  6 ++
 board/synopsys/nsim/Makefile  |  7 +++
 board/synopsys/nsim/nsim.c| 26 ++
 configs/nsim_hs38_defconfig   |  9 +
 7 files changed, 82 insertions(+), 2 deletions(-)
 rename board/synopsys/{ => nsim}/Kconfig (74%)
 create mode 100644 board/synopsys/nsim/MAINTAINERS
 create mode 100644 board/synopsys/nsim/Makefile
 create mode 100644 board/synopsys/nsim/nsim.c

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 0cb97207db..545fc3e243 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -160,7 +160,7 @@ config TARGET_TB100
bool "Support tb100"
 
 config TARGET_NSIM
-   bool "Support standalone nSIM & Free nSIM"
+   bool "Support ARC simulation & prototyping platforms"
 
 config TARGET_AXS101
bool "Support Synopsys Designware SDP board AXS101"
@@ -184,10 +184,10 @@ config TARGET_IOT_DEVKIT
 endchoice
 
 source "board/abilis/tb100/Kconfig"
-source "board/synopsys/Kconfig"
 source "board/synopsys/axs10x/Kconfig"
 source "board/synopsys/emsdp/Kconfig"
 source "board/synopsys/hsdk/Kconfig"
 source "board/synopsys/iot_devkit/Kconfig"
+source "board/synopsys/nsim/Kconfig"
 
 endmenu
diff --git a/arch/arc/dts/nsim.dts b/arch/arc/dts/nsim.dts
index a3f3964d35..376a776a78 100644
--- a/arch/arc/dts/nsim.dts
+++ b/arch/arc/dts/nsim.dts
@@ -30,4 +30,33 @@
clock-frequency = <7000>;
};
 
+   virtio0: virtio@f010 {
+   compatible = "virtio,mmio";
+   reg = <0xf010 0x2000>;
+   interrupts = <31>;
+   };
+
+   virtio1: virtio@f0102000 {
+   compatible = "virtio,mmio";
+   reg = <0xf0102000 0x2000>;
+   interrupts = <32>;
+   };
+
+   virtio2: virtio@f0104000 {
+   compatible = "virtio,mmio";
+   reg = <0xf0104000 0x2000>;
+   interrupts = <33>;
+   };
+
+   virtio3: virtio@f0106000 {
+   compatible = "virtio,mmio";
+   reg = <0xf0106000 0x2000>;
+   interrupts = <34>;
+   };
+
+   virtio4: virtio@f0108000 {
+   compatible = "virtio,mmio";
+   reg = <0xf0108000 0x2000>;
+   interrupts = <35>;
+   };
 };
diff --git a/board/synopsys/Kconfig b/board/synopsys/nsim/Kconfig
similarity index 74%
rename from board/synopsys/Kconfig
rename to board/synopsys/nsim/Kconfig
index 27e5509b26..22287032bf 100644
--- a/board/synopsys/Kconfig
+++ b/board/synopsys/nsim/Kconfig
@@ -1,5 +1,8 @@
 if TARGET_NSIM
 
+config SYS_BOARD
+   default "nsim"
+
 config SYS_VENDOR
    default "synopsys"
 
diff --git a/board/synopsys/nsim/MAINTAINERS b/board/synopsys/nsim/MAINTAINERS
new file mode 100644
index 00..ed4b9a9e78
--- /dev/null
+++ b/board/synopsys/nsim/MAINTAINERS
@@ -0,0 +1,6 @@
+EM DEVELOPMENT KIT BOARD
+M: Alexey Brodkin 
+S: Maintained
+F: arch/arc/dts/nsim.dts
+F: board/synopsys/nsim/
+F: configs/nsim_*_defconfig
diff --git a/board/synopsys/nsim/Makefile b/board/synopsys/nsim/Makefile
new file mode 100644
index 00..f4bc65d213
--- /dev/null
+++ b/board/synopsys/nsim/Makefile
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2019 Synopsys, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-y  += nsim.o
diff --git a/board/synopsys/nsim/nsim.c b/board/synopsys/nsim/nsim.c
new file mode 100644
index 00..988ceabf30
--- /dev/null
+++ b/board/synopsys/nsim/nsim.c
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Synopsys, Inc. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+int board_early_init_r(void)
+{
+   /*
+* Make sure virtio bus is enumerated so that peripherals
+* on the virtio bus can be discovered by their drivers
+*/
+   virtio_init();
+
+   return 0;
+}
+
+int checkboard(void)
+{
+   printf("Board: ARC virtual or prototyping platform\n");
+   return 0;
+};
diff --git a/configs/nsim_hs38_defconfig b/configs/nsim_hs38_defconfig
index ce68de3251..6cd01a505b 100644
--- a/configs/nsim_hs38_defconfig
+++ b/configs/nsim_hs38_defconfig
@@ -9,14 +9,23 @@ CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="

[PATCH 2/3] ARC: nsim_{700|700be|hs38be}_defconfigs: Disable networking

2019-12-26 Thread Alexey Brodkin
We don't have yet any brc700 or big-enadian platforms with networking
support to run this particular configuration.

Whenever QEMU for ARC supports arc700 or big-endian targets we may revisit
this one.

Signed-off-by: Alexey Brodkin 
---
 configs/nsim_700_defconfig| 1 +
 configs/nsim_700be_defconfig  | 1 +
 configs/nsim_hs38be_defconfig | 1 +
 3 files changed, 3 insertions(+)

diff --git a/configs/nsim_700_defconfig b/configs/nsim_700_defconfig
index 2d4a58b178..6a38e2c246 100644
--- a/configs/nsim_700_defconfig
+++ b/configs/nsim_700_defconfig
@@ -14,6 +14,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_OF_EMBED=y
 CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_NET is not set
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_SHIFT=2
diff --git a/configs/nsim_700be_defconfig b/configs/nsim_700be_defconfig
index 61eea91449..d3ed84a415 100644
--- a/configs/nsim_700be_defconfig
+++ b/configs/nsim_700be_defconfig
@@ -15,6 +15,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_OF_EMBED=y
 CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_NET is not set
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_SHIFT=2
diff --git a/configs/nsim_hs38be_defconfig b/configs/nsim_hs38be_defconfig
index 5d2ea59d52..b074b4ca98 100644
--- a/configs/nsim_hs38be_defconfig
+++ b/configs/nsim_hs38be_defconfig
@@ -16,6 +16,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_OF_EMBED=y
 CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_NET is not set
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_SHIFT=2
-- 
2.16.2



[PATCH 0/3] ARC nSIM (AKA virtual & prototyping platform) updates

2019-12-26 Thread Alexey Brodkin
In this small series we refubrish olde good nSIM configs & platform
so that it no uses standard 16650 (in fact DesignWare) UART and
little-endian HS version also gets Virtio support (Net & BLK) for use
with QEMU.

Alexey Brodkin (3):
  ARC: nSIM: switch from ARC UART to DW UART
  ARC: nsim_{700|700be|hs38be}_defconfigs: Disable networking
  ARC: nsim_hs38: Add support of Virtio NET & BLK

 arch/arc/Kconfig  |  4 ++--
 arch/arc/dts/nsim.dts | 41 ++-
 board/synopsys/{ => nsim}/Kconfig |  3 +++
 board/synopsys/nsim/MAINTAINERS   |  6 ++
 board/synopsys/nsim/Makefile  |  7 +++
 board/synopsys/nsim/nsim.c| 26 +
 configs/nsim_700_defconfig|  9 +
 configs/nsim_700be_defconfig  |  9 +
 configs/nsim_hs38_defconfig   | 17 
 configs/nsim_hs38be_defconfig |  9 +
 10 files changed, 108 insertions(+), 23 deletions(-)
 rename board/synopsys/{ => nsim}/Kconfig (74%)
 create mode 100644 board/synopsys/nsim/MAINTAINERS
 create mode 100644 board/synopsys/nsim/Makefile
 create mode 100644 board/synopsys/nsim/nsim.c

-- 
2.16.2



[PATCH 1/3] ARC: nSIM: switch from ARC UART to DW UART

2019-12-26 Thread Alexey Brodkin
Since v2019.06 DesingWare nSIM supports DesignWare UART simulation
and so we may switch from pretty unusual ARC UART to much more standard
DesignWare UART (which in case of U-Boot is just an ordinary 16650 UART).

This among other things makes built dinaries compatible with our other
platforms to name a few: FPGA-based HAPS boards, QEMU and even ZeBU.

Signed-off-by: Alexey Brodkin 
---
 arch/arc/dts/nsim.dts | 12 +++-
 configs/nsim_700_defconfig|  8 
 configs/nsim_700be_defconfig  |  8 
 configs/nsim_hs38_defconfig   |  8 
 configs/nsim_hs38be_defconfig |  8 
 5 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/arch/arc/dts/nsim.dts b/arch/arc/dts/nsim.dts
index 243ecb178e..a3f3964d35 100644
--- a/arch/arc/dts/nsim.dts
+++ b/arch/arc/dts/nsim.dts
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ * Copyright (C) 2015-2016, 2019 Synopsys, Inc. (www.synopsys.com)
  */
 /dts-v1/;
 
@@ -10,7 +10,7 @@
model = "snps,nsim";
 
aliases {
-   console = 
+   console = 
};
 
cpu_card {
@@ -22,9 +22,11 @@
};
};
 
-   arcuart0: serial@0xc0fc1000 {
-   compatible = "snps,arc-uart";
-   reg = <0xc0fc1000 0x100>;
+   uart0: serial@f000 {
+   compatible = "snps,dw-apb-uart";
+   reg = <0xf000 0x1000>;
+   reg-shift = <2>;
+   reg-io-width = <4>;
clock-frequency = <7000>;
};
 
diff --git a/configs/nsim_700_defconfig b/configs/nsim_700_defconfig
index 5633113b09..2d4a58b178 100644
--- a/configs/nsim_700_defconfig
+++ b/configs/nsim_700_defconfig
@@ -1,13 +1,13 @@
 CONFIG_ARC=y
 CONFIG_TARGET_NSIM=y
 CONFIG_SYS_TEXT_BASE=0x8100
-CONFIG_DEBUG_UART_BASE=0xc0fc1000
+CONFIG_DEBUG_UART_BASE=0xf000
 CONFIG_DEBUG_UART_CLOCK=7000
 CONFIG_SYS_CLK_FREQ=7000
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyARC0,115200n8"
+CONFIG_BOOTARGS="console=ttyS0,115200n8"
 CONFIG_SYS_PROMPT="nsim# "
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
@@ -16,6 +16,6 @@ CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
-CONFIG_DEBUG_ARC_SERIAL=y
-CONFIG_ARC_SERIAL=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYS_NS16550=y
 CONFIG_USE_PRIVATE_LIBGCC=y
diff --git a/configs/nsim_700be_defconfig b/configs/nsim_700be_defconfig
index 40f7ec7e1f..61eea91449 100644
--- a/configs/nsim_700be_defconfig
+++ b/configs/nsim_700be_defconfig
@@ -2,13 +2,13 @@ CONFIG_ARC=y
 CONFIG_CPU_BIG_ENDIAN=y
 CONFIG_TARGET_NSIM=y
 CONFIG_SYS_TEXT_BASE=0x8100
-CONFIG_DEBUG_UART_BASE=0xc0fc1000
+CONFIG_DEBUG_UART_BASE=0xf000
 CONFIG_DEBUG_UART_CLOCK=7000
 CONFIG_SYS_CLK_FREQ=7000
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyARC0,115200n8"
+CONFIG_BOOTARGS="console=ttyS0,115200n8"
 CONFIG_SYS_PROMPT="nsim# "
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
@@ -17,6 +17,6 @@ CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
-CONFIG_DEBUG_ARC_SERIAL=y
-CONFIG_ARC_SERIAL=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYS_NS16550=y
 CONFIG_USE_PRIVATE_LIBGCC=y
diff --git a/configs/nsim_hs38_defconfig b/configs/nsim_hs38_defconfig
index 2820a6fca3..ce68de3251 100644
--- a/configs/nsim_hs38_defconfig
+++ b/configs/nsim_hs38_defconfig
@@ -2,13 +2,13 @@ CONFIG_ARC=y
 CONFIG_ISA_ARCV2=y
 CONFIG_TARGET_NSIM=y
 CONFIG_SYS_TEXT_BASE=0x8100
-CONFIG_DEBUG_UART_BASE=0xc0fc1000
+CONFIG_DEBUG_UART_BASE=0xf000
 CONFIG_DEBUG_UART_CLOCK=7000
 CONFIG_SYS_CLK_FREQ=7000
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyARC0,115200n8"
+CONFIG_BOOTARGS="console=ttyS0,115200n8"
 CONFIG_SYS_PROMPT="nsim# "
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
@@ -17,6 +17,6 @@ CONFIG_DEFAULT_DEVICE_TREE="nsim"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM=y
 CONFIG_DM_SERIAL=y
-CONFIG_DEBUG_ARC_SERIAL=y
-CONFIG_ARC_SERIAL=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYS_NS16550=y
 CONFIG_USE_PRIVATE_LIBGCC=y
diff --git a/configs/nsim_hs38be_defconfig b/configs/nsim_hs38be_defconfig
index e533fae2b1..5d2ea59d52 100644
--- a/configs/nsim_hs38be_defconfig
+++ b/configs/nsim_hs38be_defconfig
@@ -3,13 +3,13 @@ CONFIG_ISA_ARCV2=y
 CONFIG_CPU_BIG_ENDIAN=y
 CONFIG_TARGET_NSIM=y
 CONFIG_SYS_TEXT_BASE=0x8100
-CONFIG_DEBUG_UART_BASE=0xc0fc1000
+CONFIG_DEBUG_UART_BASE=0xf000
 CONFIG_DEBUG_UART_CLOCK=7000
 CONFIG_SYS_CLK_FREQ=7000
 CONFIG_DEBUG_UART=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyARC0

RE: [PATCH] ARC: enable unit tests on development platforms

2019-12-04 Thread Alexey Brodkin
Hi Eugeniy,

> 
> From: Eugeniy Paltsev 
> Sent: Friday, November 8, 2019 18:31
> To: uboot-snps-...@synopsys.com; Alexey Brodkin
> Cc: u-boot@lists.denx.de; Eugeniy Paltsev
> Subject: [PATCH] ARC: enable unit tests on development platforms
> 
> Enable unit tests on HSDK and AXS103 development platforms to
> run it in verification flow.
> 
> Signed-off-by: Eugeniy Paltsev 
> ---
>  configs/axs103_defconfig | 2 ++
>  configs/hsdk_defconfig   | 2 ++
>  2 files changed, 4 insertions(+)

Applied to u-boot-arc/next.

Thanks,
Alexey


[U-Boot] Please pull ARC fixes for v2020.01-rc2

2019-11-01 Thread Alexey Brodkin
Hi Tom,

The following changes since commit 82679624f9aa6d1be733c46f3555d5166b6f5b72:

  Merge branch '2019-10-30-master-imports' (2019-11-01 09:23:21 -0400)

are available in the Git repository at:

  g...@gitlab.denx.de:u-boot/custodians/u-boot-arc.git 
tags/arc-fixes-for-2020.01-rc2

for you to fetch changes up to 3f6b4ea225656b41613fd538925e29141f22c4a7:

  arc: emsdp: docs: Prefer Degilent over Opella-XD (2019-11-01 16:45:40 +0300)

Please note that there's something new in this pull-request which is
reset driver for ARC HSDK board. Due to ELCE and preparations [as always :(]
I completely forgot to send out ARC changes in time of merge window.

That said if you prefer I may re-send you the same pull-request with
HSDK reset driver removed so that only real fixes will be in.

Sorry for that anyways.


ARC fixes for v2020.01-rc2

The main change is move to DM_MMC of yet 2 another ARC boards:
AXS101 & IoTDK.

Among that we improve handling of stock-formatted SD-cards of high volume
on EM SDP as well as introduction of reset driver for HSDK which is required
for prepser reinitialization of some peripherals like USB etc.

----
Alexey Brodkin (3):
  arc: emsdp: Increase max FAT cluster size
  arc: emsdp/iotdk: Switch to DM_MMC
  arc: emsdp: docs: Prefer Degilent over Opella-XD

Eugeniy Paltsev (3):
  ARC: HSDK: introduce reset driver
  MAINTAINERS: add info about ARC HSDK reset driver
  ARC: [plat-axs101]: migrate to DM_MMC

 MAINTAINERS |   7 +++
 arch/arc/dts/emsdp.dts  |  23 +++
 arch/arc/dts/iot_devkit.dts |  22 ++
 board/synopsys/emsdp/README |   2 +-
 board/synopsys/emsdp/emsdp.c|  29 -
 board/synopsys/iot_devkit/iot_devkit.c  |  32 

 configs/axs101_defconfig|   2 ++
 configs/emsdp_defconfig |   4 +++-
 configs/iot_devkit_defconfig|   2 ++
 drivers/reset/Kconfig   |   7 +++
 drivers/reset/Makefile  |   1 +
 drivers/reset/reset-hsdk.c  | 116 

 include/dt-bindings/reset/snps,hsdk-reset.h |  17 +
 13 files changed, 201 insertions(+), 63 deletions(-)
 create mode 100644 drivers/reset/reset-hsdk.c
 create mode 100644 include/dt-bindings/reset/snps,hsdk-reset.h

Regards,
Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3] arc: emsdp/iotdk: Switch to DM_MMC

2019-10-09 Thread Alexey Brodkin
Somehow EMSDP & IoT DK boards were skipped on ARC boads conversion
to DM MMC. So doing it now.

Signed-off-by: Alexey Brodkin 
---

Changes v2 -> v3:
 * Fixed SDIO bus interface unit clock (BIU)
   According to the documentation SDIO BIU clock is just "apb_clk"
   which is 50 MHz by default while SDIO CIU clock is "sdio_ref_clk"
   and by default is 100 MHz.

Changes v1 -> v2:
 * FIFO size on IoTDK is 128 bytes as compared to 256 on EM SDP.
   That gave us timeouts on data read with some cards. Fixed now.

 arch/arc/dts/emsdp.dts | 23 ++
 arch/arc/dts/iot_devkit.dts| 22 ++
 board/synopsys/emsdp/emsdp.c   | 29 ---
 board/synopsys/iot_devkit/iot_devkit.c | 32 --
 configs/emsdp_defconfig|  2 ++
 configs/iot_devkit_defconfig   |  2 ++
 6 files changed, 49 insertions(+), 61 deletions(-)

diff --git a/arch/arc/dts/emsdp.dts b/arch/arc/dts/emsdp.dts
index d307b95d8e..dbebdb4e76 100644
--- a/arch/arc/dts/emsdp.dts
+++ b/arch/arc/dts/emsdp.dts
@@ -32,4 +32,27 @@
reg-shift = <2>;
reg-io-width = <4>;
};
+
+   mmcclk_biu: mmcclk-biu {
+   compatible = "fixed-clock";
+   clock-frequency = <5000>;
+   #clock-cells = <0>;
+   };
+
+   mmcclk_ciu: mmcclk-ciu {
+   compatible = "fixed-clock";
+   clock-frequency = <1>;
+   #clock-cells = <0>;
+   };
+
+   mmc: mmc0@f001 {
+   compatible = "snps,dw-mshc";
+   reg = <0xf001 0x400>;
+   bus-width = <4>;
+   fifo-depth = <256>;
+   clocks = <_biu>, <_ciu>;
+   clock-names = "biu", "ciu";
+   max-frequency = <2500>;
+   };
+
 };
diff --git a/arch/arc/dts/iot_devkit.dts b/arch/arc/dts/iot_devkit.dts
index ebf5a950f0..c0173fa5ab 100644
--- a/arch/arc/dts/iot_devkit.dts
+++ b/arch/arc/dts/iot_devkit.dts
@@ -42,4 +42,26 @@
compatible = "nop-phy";
#phy-cells = <0>;
};
+
+   mmcclk_biu: mmcclk-biu {
+   compatible = "fixed-clock";
+   clock-frequency = <5000>;
+   #clock-cells = <0>;
+   };
+
+   mmcclk_ciu: mmcclk-ciu {
+   compatible = "fixed-clock";
+   clock-frequency = <5000>;
+   #clock-cells = <0>;
+   };
+
+   mmc: mmc0@f000b000 {
+   compatible = "snps,dw-mshc";
+   reg = <0xf000b000 0x400>;
+   bus-width = <4>;
+   fifo-depth = <128>;
+   clocks = <_biu>, <_ciu>;
+   clock-names = "biu", "ciu";
+   max-frequency = <2500>;
+   };
 };
diff --git a/board/synopsys/emsdp/emsdp.c b/board/synopsys/emsdp/emsdp.c
index 7a3fd5b7f2..5ba9f862e1 100644
--- a/board/synopsys/emsdp/emsdp.c
+++ b/board/synopsys/emsdp/emsdp.c
@@ -85,35 +85,6 @@ int board_early_init_r(void)
return 0;
 }
 
-int board_mmc_init(bd_t *bis)
-{
-   struct dwmci_host *host = NULL;
-
-   host = malloc(sizeof(struct dwmci_host));
-   if (!host) {
-   printf("dwmci_host malloc fail!\n");
-   return 1;
-   }
-
-   memset(host, 0, sizeof(struct dwmci_host));
-   host->name = "Synopsys Mobile storage";
-   host->ioaddr = SDIO_BASE;
-   host->buswidth = 4;
-   host->dev_index = 0;
-   host->bus_hz = 5000;
-
-   add_dwmci(host, host->bus_hz / 2, 40);
-
-   return 0;
-}
-
-int board_mmc_getcd(struct mmc *mmc)
-{
-   struct dwmci_host *host = mmc->priv;
-
-   return !(dwmci_readl(host, DWMCI_CDETECT) & 1);
-}
-
 #define CREG_BASE  0xF0001000
 #define CREG_BOOT  (void *)(CREG_BASE + 0x0FF0)
 #define CREG_IP_SW_RESET   (void *)(CREG_BASE + 0x0FF0)
diff --git a/board/synopsys/iot_devkit/iot_devkit.c 
b/board/synopsys/iot_devkit/iot_devkit.c
index 8424e09bd3..9dbdc128f8 100644
--- a/board/synopsys/iot_devkit/iot_devkit.c
+++ b/board/synopsys/iot_devkit/iot_devkit.c
@@ -145,38 +145,6 @@ int mach_cpu_init(void)
return set_cpu_freq(gd->cpu_clk);
 }
 
-#define ARC_PERIPHERAL_BASE0xF000
-#define SDIO_BASE  (ARC_PERIPHERAL_BASE + 0xB000)
-
-int board_mmc_init(bd_t *bis)
-{
-   struct dwmci_host *host = NULL;
-
-   host = malloc(sizeof(struct dwmci_host));
-   if (!host) {
-   printf("dwmci_host malloc fail!\n");
-   return -ENOMEM;
-   }
-
-   memset(host, 0, sizeof(struct dwmci_host));
-   host->name = 

[U-Boot] [PATCH] arc: emsdp: docs: Prefer Degilent over Opella-XD

2019-10-09 Thread Alexey Brodkin
Back in the day on early board samples built-in Digilent JTAG probe
was not functional so we used externally attached Ashling Opella-XD
probe. But now with production units everything works as expected and
so we anybody may enjoy readily avaialble built-in JTAG probe so
we specify Digilent oprion on MDB's command line example.

Signed-off-by: Alexey Brodkin 
---
 board/synopsys/emsdp/README | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/synopsys/emsdp/README b/board/synopsys/emsdp/README
index 034062e397..036554c4d5 100644
--- a/board/synopsys/emsdp/README
+++ b/board/synopsys/emsdp/README
@@ -79,5 +79,5 @@ ARC EM Software Development Platform (AKA EMSDP)
 
   2.1. In case of proprietary MetaWare debugger run:
   ->8--
-  mdb -dll=opxdarc.so -OK -preloadexec="eval *(int*)0xf0001000=0" u-boot
+  mdb -digilent -OK -preloadexec="eval *(int*)0xf0001000=0" u-boot
   ->8--
-- 
2.17.1


___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2] arc: emsdp/iotdk: Switch to DM_MMC

2019-10-08 Thread Alexey Brodkin
Somehow EMSDP & IoT DK boards were skipped on ARC boads conversion
to DM MMC. So doing it now.

Signed-off-by: Alexey Brodkin 
---

Changes v1 -> v2:

 * FIFO size on IoTDK is 128 bytes as compared to 256 on EM SDP.
   That gave us timeouts on data read with some cards. Fixed now.

 arch/arc/dts/emsdp.dts | 23 ++
 arch/arc/dts/iot_devkit.dts| 22 ++
 board/synopsys/emsdp/emsdp.c   | 29 ---
 board/synopsys/iot_devkit/iot_devkit.c | 32 --
 configs/emsdp_defconfig|  2 ++
 configs/iot_devkit_defconfig   |  2 ++
 6 files changed, 49 insertions(+), 61 deletions(-)

diff --git a/arch/arc/dts/emsdp.dts b/arch/arc/dts/emsdp.dts
index d307b95d8e..77362354d5 100644
--- a/arch/arc/dts/emsdp.dts
+++ b/arch/arc/dts/emsdp.dts
@@ -32,4 +32,27 @@
reg-shift = <2>;
reg-io-width = <4>;
};
+
+   mmcclk_biu: mmcclk-biu {
+   compatible = "fixed-clock";
+   clock-frequency = <1>;
+   #clock-cells = <0>;
+   };
+
+   mmcclk_ciu: mmcclk-ciu {
+   compatible = "fixed-clock";
+   clock-frequency = <1>;
+   #clock-cells = <0>;
+   };
+
+   mmc: mmc0@f001 {
+   compatible = "snps,dw-mshc";
+   reg = <0xf001 0x400>;
+   bus-width = <4>;
+   fifo-depth = <256>;
+   clocks = <_biu>, <_ciu>;
+   clock-names = "biu", "ciu";
+   max-frequency = <2500>;
+   };
+
 };
diff --git a/arch/arc/dts/iot_devkit.dts b/arch/arc/dts/iot_devkit.dts
index ebf5a950f0..c0173fa5ab 100644
--- a/arch/arc/dts/iot_devkit.dts
+++ b/arch/arc/dts/iot_devkit.dts
@@ -42,4 +42,26 @@
compatible = "nop-phy";
#phy-cells = <0>;
};
+
+   mmcclk_biu: mmcclk-biu {
+   compatible = "fixed-clock";
+   clock-frequency = <5000>;
+   #clock-cells = <0>;
+   };
+
+   mmcclk_ciu: mmcclk-ciu {
+   compatible = "fixed-clock";
+   clock-frequency = <5000>;
+   #clock-cells = <0>;
+   };
+
+   mmc: mmc0@f000b000 {
+   compatible = "snps,dw-mshc";
+   reg = <0xf000b000 0x400>;
+   bus-width = <4>;
+   fifo-depth = <128>;
+   clocks = <_biu>, <_ciu>;
+   clock-names = "biu", "ciu";
+   max-frequency = <2500>;
+   };
 };
diff --git a/board/synopsys/emsdp/emsdp.c b/board/synopsys/emsdp/emsdp.c
index 7a3fd5b7f2..5ba9f862e1 100644
--- a/board/synopsys/emsdp/emsdp.c
+++ b/board/synopsys/emsdp/emsdp.c
@@ -85,35 +85,6 @@ int board_early_init_r(void)
return 0;
 }
 
-int board_mmc_init(bd_t *bis)
-{
-   struct dwmci_host *host = NULL;
-
-   host = malloc(sizeof(struct dwmci_host));
-   if (!host) {
-   printf("dwmci_host malloc fail!\n");
-   return 1;
-   }
-
-   memset(host, 0, sizeof(struct dwmci_host));
-   host->name = "Synopsys Mobile storage";
-   host->ioaddr = SDIO_BASE;
-   host->buswidth = 4;
-   host->dev_index = 0;
-   host->bus_hz = 5000;
-
-   add_dwmci(host, host->bus_hz / 2, 40);
-
-   return 0;
-}
-
-int board_mmc_getcd(struct mmc *mmc)
-{
-   struct dwmci_host *host = mmc->priv;
-
-   return !(dwmci_readl(host, DWMCI_CDETECT) & 1);
-}
-
 #define CREG_BASE  0xF0001000
 #define CREG_BOOT  (void *)(CREG_BASE + 0x0FF0)
 #define CREG_IP_SW_RESET   (void *)(CREG_BASE + 0x0FF0)
diff --git a/board/synopsys/iot_devkit/iot_devkit.c 
b/board/synopsys/iot_devkit/iot_devkit.c
index 8424e09bd3..9dbdc128f8 100644
--- a/board/synopsys/iot_devkit/iot_devkit.c
+++ b/board/synopsys/iot_devkit/iot_devkit.c
@@ -145,38 +145,6 @@ int mach_cpu_init(void)
return set_cpu_freq(gd->cpu_clk);
 }
 
-#define ARC_PERIPHERAL_BASE0xF000
-#define SDIO_BASE  (ARC_PERIPHERAL_BASE + 0xB000)
-
-int board_mmc_init(bd_t *bis)
-{
-   struct dwmci_host *host = NULL;
-
-   host = malloc(sizeof(struct dwmci_host));
-   if (!host) {
-   printf("dwmci_host malloc fail!\n");
-   return -ENOMEM;
-   }
-
-   memset(host, 0, sizeof(struct dwmci_host));
-   host->name = "Synopsys Mobile storage";
-   host->ioaddr = (void *)SDIO_BASE;
-   host->buswidth = 4;
-   host->dev_index = 0;
-   host->bus_hz = 5000;
-
-   add_dwmci(host, host->bus_hz / 2, 40);
-
-   re

[U-Boot] [PATCH] arc: emsdp: Increase max FAT cluster size

2019-10-08 Thread Alexey Brodkin
Some especially large SD-cards come from stock formatted with
larger FAT cluster size so to accommodate those we just increase
what we expect to have here in U-Boot given we have a plenty of
space on EM SDP (16 MiB).

Signed-off-by: Alexey Brodkin 
---
 configs/emsdp_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/emsdp_defconfig b/configs/emsdp_defconfig
index 42415ea713..09fe388e58 100644
--- a/configs/emsdp_defconfig
+++ b/configs/emsdp_defconfig
@@ -29,6 +29,6 @@ CONFIG_MMC_DW=y
 CONFIG_MMC_DW_SNPS=y
 CONFIG_DM_SERIAL=y
 CONFIG_SYS_NS16550=y
-CONFIG_FS_FAT_MAX_CLUSTSIZE=4096
+CONFIG_FS_FAT_MAX_CLUSTSIZE=32768
 CONFIG_USE_PRIVATE_LIBGCC=y
 CONFIG_PANIC_HANG=y
-- 
2.17.1


___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] arc: emsdp/iotdk: Switch to DM_MMC

2019-10-08 Thread Alexey Brodkin
Somehow EMSDP & IoT DK boards were skipped on ARC boads conversion
to DM MMC. So doing it now.

Signed-off-by: Alexey Brodkin 
---
 arch/arc/dts/emsdp.dts | 23 ++
 arch/arc/dts/iot_devkit.dts| 22 ++
 board/synopsys/emsdp/emsdp.c   | 29 ---
 board/synopsys/iot_devkit/iot_devkit.c | 32 --
 configs/emsdp_defconfig|  2 ++
 configs/iot_devkit_defconfig   |  2 ++
 6 files changed, 49 insertions(+), 61 deletions(-)

diff --git a/arch/arc/dts/emsdp.dts b/arch/arc/dts/emsdp.dts
index d307b95d8e..77362354d5 100644
--- a/arch/arc/dts/emsdp.dts
+++ b/arch/arc/dts/emsdp.dts
@@ -32,4 +32,27 @@
reg-shift = <2>;
reg-io-width = <4>;
};
+
+   mmcclk_biu: mmcclk-biu {
+   compatible = "fixed-clock";
+   clock-frequency = <1>;
+   #clock-cells = <0>;
+   };
+
+   mmcclk_ciu: mmcclk-ciu {
+   compatible = "fixed-clock";
+   clock-frequency = <1>;
+   #clock-cells = <0>;
+   };
+
+   mmc: mmc0@f001 {
+   compatible = "snps,dw-mshc";
+   reg = <0xf001 0x400>;
+   bus-width = <4>;
+   fifo-depth = <256>;
+   clocks = <_biu>, <_ciu>;
+   clock-names = "biu", "ciu";
+   max-frequency = <2500>;
+   };
+
 };
diff --git a/arch/arc/dts/iot_devkit.dts b/arch/arc/dts/iot_devkit.dts
index ebf5a950f0..e2cb602cae 100644
--- a/arch/arc/dts/iot_devkit.dts
+++ b/arch/arc/dts/iot_devkit.dts
@@ -42,4 +42,26 @@
compatible = "nop-phy";
#phy-cells = <0>;
};
+
+   mmcclk_biu: mmcclk-biu {
+   compatible = "fixed-clock";
+   clock-frequency = <5000>;
+   #clock-cells = <0>;
+   };
+
+   mmcclk_ciu: mmcclk-ciu {
+   compatible = "fixed-clock";
+   clock-frequency = <5000>;
+   #clock-cells = <0>;
+   };
+
+   mmc: mmc0@f000b000 {
+   compatible = "snps,dw-mshc";
+   reg = <0xf000b000 0x400>;
+   bus-width = <4>;
+   fifo-depth = <256>;
+   clocks = <_biu>, <_ciu>;
+   clock-names = "biu", "ciu";
+   max-frequency = <2500>;
+   };
 };
diff --git a/board/synopsys/emsdp/emsdp.c b/board/synopsys/emsdp/emsdp.c
index 7a3fd5b7f2..5ba9f862e1 100644
--- a/board/synopsys/emsdp/emsdp.c
+++ b/board/synopsys/emsdp/emsdp.c
@@ -85,35 +85,6 @@ int board_early_init_r(void)
return 0;
 }
 
-int board_mmc_init(bd_t *bis)
-{
-   struct dwmci_host *host = NULL;
-
-   host = malloc(sizeof(struct dwmci_host));
-   if (!host) {
-   printf("dwmci_host malloc fail!\n");
-   return 1;
-   }
-
-   memset(host, 0, sizeof(struct dwmci_host));
-   host->name = "Synopsys Mobile storage";
-   host->ioaddr = SDIO_BASE;
-   host->buswidth = 4;
-   host->dev_index = 0;
-   host->bus_hz = 5000;
-
-   add_dwmci(host, host->bus_hz / 2, 40);
-
-   return 0;
-}
-
-int board_mmc_getcd(struct mmc *mmc)
-{
-   struct dwmci_host *host = mmc->priv;
-
-   return !(dwmci_readl(host, DWMCI_CDETECT) & 1);
-}
-
 #define CREG_BASE  0xF0001000
 #define CREG_BOOT  (void *)(CREG_BASE + 0x0FF0)
 #define CREG_IP_SW_RESET   (void *)(CREG_BASE + 0x0FF0)
diff --git a/board/synopsys/iot_devkit/iot_devkit.c 
b/board/synopsys/iot_devkit/iot_devkit.c
index 8424e09bd3..9dbdc128f8 100644
--- a/board/synopsys/iot_devkit/iot_devkit.c
+++ b/board/synopsys/iot_devkit/iot_devkit.c
@@ -145,38 +145,6 @@ int mach_cpu_init(void)
return set_cpu_freq(gd->cpu_clk);
 }
 
-#define ARC_PERIPHERAL_BASE0xF000
-#define SDIO_BASE  (ARC_PERIPHERAL_BASE + 0xB000)
-
-int board_mmc_init(bd_t *bis)
-{
-   struct dwmci_host *host = NULL;
-
-   host = malloc(sizeof(struct dwmci_host));
-   if (!host) {
-   printf("dwmci_host malloc fail!\n");
-   return -ENOMEM;
-   }
-
-   memset(host, 0, sizeof(struct dwmci_host));
-   host->name = "Synopsys Mobile storage";
-   host->ioaddr = (void *)SDIO_BASE;
-   host->buswidth = 4;
-   host->dev_index = 0;
-   host->bus_hz = 5000;
-
-   add_dwmci(host, host->bus_hz / 2, 40);
-
-   return 0;
-}
-
-int board_mmc_getcd(struct mmc *mmc)
-{
-   struct dwmci_host *host = mmc->priv;
-
-   return !(dwmci_readl(host, DWMCI_CDETECT) &a

Re: [U-Boot] [PATCH] disk: part_dos: Allocate at least one block size for mbr

2019-09-04 Thread Alexey Brodkin
Hi Faiz,

> -Original Message-
> From: Faiz Abbas 
> Sent: Wednesday, September 4, 2019 5:40 PM
> To: u-boot@lists.denx.de
> Cc: tr...@konsulko.com; Alexey Brodkin ; 
> paule...@forallsecure.com;
> faiz_ab...@ti.com
> Subject: [PATCH] disk: part_dos: Allocate at least one block size for mbr
> 
> The blk_dread() following the mbr allocation reads one block from the
> device. This will lead to overflow if block size is greater than the
> size of legacy_mbr. Fix this by allocating at least one block size.
> 
> Signed-off-by: Faiz Abbas 

Acked-by: Alexey Brodkin 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] Revert "part: Allocate only one legacy_mbr buffer"

2019-09-04 Thread Alexey Brodkin
Hi Faiz,

> -Original Message-
> From: Alexey Brodkin
> Sent: Wednesday, September 4, 2019 4:23 PM
> To: Faiz Abbas 
> Cc: paule...@forallsecure.com; tr...@konsulko.com; u-boot@lists.denx.de
> Subject: RE: [PATCH] Revert "part: Allocate only one legacy_mbr buffer"
> 
> Hi Faiz,
> 
> > -Original Message-
> > From: Faiz Abbas 
> > Sent: Wednesday, September 4, 2019 4:09 PM
> > To: Alexey Brodkin 
> > Cc: paule...@forallsecure.com; tr...@konsulko.com; u-boot@lists.denx.de
> > Subject: Re: [PATCH] Revert "part: Allocate only one legacy_mbr buffer"
> >
> > Hi Alexey,
> >
> > On 04/09/19 6:27 PM, Alexey Brodkin wrote:
> > > Hi Faiz,
> > >
> > > [snip]
> > >
> > >>>>> I guess what you really want to do is to allocate buffer for "mbr"
> > >>>>> dynamically of size which is max(sizeof(legacy_mbr), dev_desc->blksz).
> > >>>>>
> > >>>>
> > >>>> With the assumption that blksz is always greater than
> > >>>> sizeof(legacy_mbr), this should work:
> > >>>>
> > >>>> ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, DIV_ROUND_UP(dev_desc->blksz,
> > >>>> sizeof(legacy_mbr)));
> > >>>
> > >>> No this won't work. See ALLOC_CACHE_ALIGN_BUFFER does static allocation
> > >>> in compile-time while blksz is set in runtime.
> > >>>
> > >>> That's why I mentioned switch to runtime allocation.
> > >>>
> > >>
> > >> Hmm. So the problem isn't as much about allocating too much in the
> > >> buffer but about using dynamically determined size for static array
> > >> declaration.
> > >
> > > In fact it was a problem of huge static allocation I discovered just by
> > > chance building U-Boot for a very memory-limited device, see [1].
> > >
> > >> This is being used all over this disk/part_dos.c file.
> > >> Shouldn't we fix all of that? Not sure how it has been working all along.
> > >
> > > That part I don't quite understand. What's being used, where and how?
> > > And what's the problem with dynamic allocation of the buffer for MBR?
> > >
> >
> > Isn't the following line (being used in different functions in
> > disk/part_dos.c) also problematic because we don't know the value of
> > blksz at compile time?
> >
> > ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
> 
> Ok I see now. Looks like I missed that Variable-Length Array (VLA) feature
> added to C99 so up-to-date GCC apparently supports it.
> 
> But I would strongly recommend to get rid of VLA usage by all means,
> see [1] & [2].
> 
> [1] https://lwn.net/Articles/749064/
> [2] https://lwn.net/Articles/749089/

So if I add "-Wvla" to CFLAGS I see 22 usages of them:
>8-
diff --git a/Makefile b/Makefile
index c02accfc26..c6e8d12809 100644
--- a/Makefile
+++ b/Makefile
@@ -389,7 +389,7 @@ CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix 
-D__unix__ \

 KBUILD_CPPFLAGS := -D__KERNEL__ -D__UBOOT__

-KBUILD_CFLAGS   := -Wall -Wstrict-prototypes \
+KBUILD_CFLAGS   := -Wvla -Wall -Wstrict-prototypes \
   -Wno-format-security \
   -fno-builtin -ffreestanding $(CSTD_FLAG)
 KBUILD_CFLAGS  += -fshort-wchar -fno-strict-aliasing
>8-

So that's what we have:
>8-
# make -j 48 2>&1 | grep "\-Wvla"
disk/part_dos.c:129:2: warning: ISO C90 forbids variable length array 
‘__buffer’ [-Wvla]
disk/part_dos.c:200:2: warning: ISO C90 forbids variable length array 
‘__buffer’ [-Wvla]
drivers/spi/spi-mem.c:350:2: warning: ISO C90 forbids variable length array 
‘op_buf’ [-Wvla]
drivers/input/input.c:341:2: warning: ISO C90 forbids variable length array 
‘temp’ [-Wvla]
drivers/input/input.c:513:2: warning: ISO C90 forbids variable length array 
‘ch’ [-Wvla]
env/attr.c:124:2: warning: ISO C90 forbids variable length array ‘regex’ [-Wvla]
env/attr.c:129:10: warning: ISO C90 forbids variable length array ‘caps’ [-Wvla]
common/command.c:29:3: warning: ISO C90 forbids variable length array 
‘cmd_array’ [-Wvla]
drivers/mmc/dw_mmc.c:248:34: warning: ISO C90 forbids variable length array 
‘__cur_idmac’ [-Wvla]
fs/fat/fat.c:61:2: warning: ISO C90 forbids variable length array ‘__buffer’ 
[-Wvla]
fs/fat/fat.c:262:3: warning: ISO C90 forbids variable length array ‘__tmpbuf’ 
[-Wvla]
fs/fat/fat.c:290:3: warning

Re: [U-Boot] [PATCH] Revert "part: Allocate only one legacy_mbr buffer"

2019-09-04 Thread Alexey Brodkin
Hi Faiz,

> -Original Message-
> From: Faiz Abbas 
> Sent: Wednesday, September 4, 2019 4:09 PM
> To: Alexey Brodkin 
> Cc: paule...@forallsecure.com; tr...@konsulko.com; u-boot@lists.denx.de
> Subject: Re: [PATCH] Revert "part: Allocate only one legacy_mbr buffer"
> 
> Hi Alexey,
> 
> On 04/09/19 6:27 PM, Alexey Brodkin wrote:
> > Hi Faiz,
> >
> > [snip]
> >
> >>>>> I guess what you really want to do is to allocate buffer for "mbr"
> >>>>> dynamically of size which is max(sizeof(legacy_mbr), dev_desc->blksz).
> >>>>>
> >>>>
> >>>> With the assumption that blksz is always greater than
> >>>> sizeof(legacy_mbr), this should work:
> >>>>
> >>>> ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, DIV_ROUND_UP(dev_desc->blksz,
> >>>> sizeof(legacy_mbr)));
> >>>
> >>> No this won't work. See ALLOC_CACHE_ALIGN_BUFFER does static allocation
> >>> in compile-time while blksz is set in runtime.
> >>>
> >>> That's why I mentioned switch to runtime allocation.
> >>>
> >>
> >> Hmm. So the problem isn't as much about allocating too much in the
> >> buffer but about using dynamically determined size for static array
> >> declaration.
> >
> > In fact it was a problem of huge static allocation I discovered just by
> > chance building U-Boot for a very memory-limited device, see [1].
> >
> >> This is being used all over this disk/part_dos.c file.
> >> Shouldn't we fix all of that? Not sure how it has been working all along.
> >
> > That part I don't quite understand. What's being used, where and how?
> > And what's the problem with dynamic allocation of the buffer for MBR?
> >
> 
> Isn't the following line (being used in different functions in
> disk/part_dos.c) also problematic because we don't know the value of
> blksz at compile time?
> 
> ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);

Ok I see now. Looks like I missed that Variable-Length Array (VLA) feature
added to C99 so up-to-date GCC apparently supports it.

But I would strongly recommend to get rid of VLA usage by all means,
see [1] & [2].

[1] https://lwn.net/Articles/749064/
[2] https://lwn.net/Articles/749089/

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] Revert "part: Allocate only one legacy_mbr buffer"

2019-09-04 Thread Alexey Brodkin
Hi Faiz,

[snip]

> >>> I guess what you really want to do is to allocate buffer for "mbr"
> >>> dynamically of size which is max(sizeof(legacy_mbr), dev_desc->blksz).
> >>>
> >>
> >> With the assumption that blksz is always greater than
> >> sizeof(legacy_mbr), this should work:
> >>
> >> ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, DIV_ROUND_UP(dev_desc->blksz,
> >> sizeof(legacy_mbr)));
> >
> > No this won't work. See ALLOC_CACHE_ALIGN_BUFFER does static allocation
> > in compile-time while blksz is set in runtime.
> >
> > That's why I mentioned switch to runtime allocation.
> >
> 
> Hmm. So the problem isn't as much about allocating too much in the
> buffer but about using dynamically determined size for static array
> declaration.

In fact it was a problem of huge static allocation I discovered just by
chance building U-Boot for a very memory-limited device, see [1].

> This is being used all over this disk/part_dos.c file.
> Shouldn't we fix all of that? Not sure how it has been working all along.

That part I don't quite understand. What's being used, where and how?
And what's the problem with dynamic allocation of the buffer for MBR?

[1] 
https://elinux.org/images/d/d6/U-Boot-Bootloader-for-IoT-Platform-Alexey-Brodkin-Synopsys-2.pdf

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] Revert "part: Allocate only one legacy_mbr buffer"

2019-09-04 Thread Alexey Brodkin
Hi Faiz,

> -Original Message-
> From: Faiz Abbas 
> Sent: Wednesday, September 4, 2019 2:44 PM
> To: Alexey Brodkin 
> Cc: paule...@forallsecure.com; tr...@konsulko.com; u-boot@lists.denx.de
> Subject: Re: [PATCH] Revert "part: Allocate only one legacy_mbr buffer"
> 
> Hi Alexey,
> 
> On 04/09/19 3:42 PM, Alexey Brodkin wrote:
> > Hi Faiz,
> >
> >> -Original Message-
> >> From: Faiz Abbas 
> >> Sent: Wednesday, September 4, 2019 12:22 PM
> >> To: u-boot@lists.denx.de
> >> Cc: paule...@forallsecure.com; faiz_ab...@ti.com; Alexey Brodkin 
> >> ;
> >> tr...@konsulko.com
> >> Subject: [PATCH] Revert "part: Allocate only one legacy_mbr buffer"
> >>
> >> This reverts commit 8639e34d2c5e12cc2e45c95b1a2e97c22bf6a711.
> >>
> >> The blk_dread() call following the allocation will read one block from
> >> the device. This will lead to overflow if the blocksize is greater than
> >> the size of legacy_mbr. Fix this by allocating one block size.
> >
> > Did you read justification of my change that you're reverting now?
> > With your change in place we'll allocate a buffer
> > of size = (sizeof(legacy_mbr) * dev_desc->blksz).
> >
> > Is that something you really want?
> 
> Oops. You're right. I thought your patch was changing buffer size from
> blksz to legacy_mbr.
> 
> >
> > I guess what you really want to do is to allocate buffer for "mbr"
> > dynamically of size which is max(sizeof(legacy_mbr), dev_desc->blksz).
> >
> 
> With the assumption that blksz is always greater than
> sizeof(legacy_mbr), this should work:
> 
> ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, DIV_ROUND_UP(dev_desc->blksz,
> sizeof(legacy_mbr)));

No this won't work. See ALLOC_CACHE_ALIGN_BUFFER does static allocation
in compile-time while blksz is set in runtime.

That's why I mentioned switch to runtime allocation.

-Alexey

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] Revert "part: Allocate only one legacy_mbr buffer"

2019-09-04 Thread Alexey Brodkin
Hi Faiz,

> -Original Message-
> From: Faiz Abbas 
> Sent: Wednesday, September 4, 2019 12:22 PM
> To: u-boot@lists.denx.de
> Cc: paule...@forallsecure.com; faiz_ab...@ti.com; Alexey Brodkin 
> ;
> tr...@konsulko.com
> Subject: [PATCH] Revert "part: Allocate only one legacy_mbr buffer"
> 
> This reverts commit 8639e34d2c5e12cc2e45c95b1a2e97c22bf6a711.
> 
> The blk_dread() call following the allocation will read one block from
> the device. This will lead to overflow if the blocksize is greater than
> the size of legacy_mbr. Fix this by allocating one block size.

Did you read justification of my change that you're reverting now?
With your change in place we'll allocate a buffer
of size = (sizeof(legacy_mbr) * dev_desc->blksz).

Is that something you really want?

I guess what you really want to do is to allocate buffer for "mbr"
dynamically of size which is max(sizeof(legacy_mbr), dev_desc->blksz).

-Alexey 

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [RFC PATCH] net: designware: drop compatible altr, socfpga-stmmac

2019-09-03 Thread Alexey Brodkin
Hi Joe,

> -Original Message-
> From: Joe Hershberger 
> Sent: Wednesday, September 4, 2019 1:10 AM
> To: Alexey Brodkin 
> Cc: Ralph Siemsen ; Joseph Hershberger 
> ; u-
> b...@lists.denx.de; linux-snps-...@lists.infradead.org; Eugeniy Paltsev 
> 
> Subject: Re: [U-Boot] [RFC PATCH] net: designware: drop compatible altr, 
> socfpga-stmmac
> 
> On Tue, Aug 20, 2019 at 3:07 AM Alexey Brodkin
>  wrote:
> >
> > Hi Ralph,
> >
> > > -Original Message-
> > > From: Ralph Siemsen 
> > > Sent: Monday, August 19, 2019 9:43 PM
> > > To: u-boot@lists.denx.de; Joe Hershberger ; 
> > > Alexey Brodkin
> > > ; Vlad Zakharov 
> > > Cc: Ralph Siemsen 
> > > Subject: [RFC PATCH] net: designware: drop compatible altr,socfpga-stmmac
> > >
> > > The same compatible = "altr,socfpga-stmmac" appears in both
> > > drivers/net/designware.c and drivers/net/dwmac_socfgpa.c,
> > > creating ambiguity in which driver will be bound.
> > >
> > > For Intel/Altera SoC devices, dwmac_socfpga.c is the correct driver.
> > > So drop the compatible string from designware.c.
> > >
> > > Signed-off-by: Ralph Siemsen 
> > > ---
> > > This compatible string also appears in: axs10x_mb.dtsi and hsdk.dts.
> > > Maintainers of those boards have been copied, kindly review.
> >
> > Thanks for this clean-up.
> >
> > Speaking about AXS10x board where we do have DW GMAC
> > I cannot recall the reason I chose to use "altr,socfpga-stmmac"
> > for the board here [1] 3 years ago.
> >
> > But given we don't have any special quirks implemented whatever
> > is the most generic DW GMAC compatible string is should be good for us.
> >
> > Joe, could you please suggest if we need to use just "st,stm32-dwmac"
> > or add our own compatible as the ASIC is not from ST obviously but
> > an FPGA with Synopsys ARC SoC?
> 
> I think we should only be using what Linux does, so I'm afraid I have
> to defer to what exists in the DTs there.

In the Linux kernel we use "snps,dwmac", see [1].
But maybe we need to switch to "snps,dwmac-3.70a" even as what we really have 
is 3.73a.

While in U-Boot we don't have either one, the most generic is "st,stm32-dwmac", 
see [2].
So maybe we want to add at least "snps,dwmac".

@Jose Abreu could you please confirm if "snps,dwmac-3.70a" is OK for GMAC IP 
v3.73a?

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arc/boot/dts/axs10x_mb.dtsi#n74
[2] 
https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/net/designware.c#L855

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] mmc: dw_mmc: fix timeout calculate method

2019-09-03 Thread Alexey Brodkin
H Tom,

[snip]

> > > This is the patch with problem, and here is the link on patchwork:
> > > https://patchwork.ozlabs.org/patch/1146845/
> >
> > Please find my fixes here:
> > https://patchwork.ozlabs.org/patch/1156541/
> > https://patchwork.ozlabs.org/patch/1156617/
> >
> > Tom do we want https://patchwork.ozlabs.org/patch/1146845/ and fixes for it
> > (see 2 items above) to become a part of upcoming v2019.10 release or
> > it will be slated for the next one?
> 
> I think we should aim to get all the fixes in for this release.

Done, see https://lists.denx.de/pipermail/u-boot/2019-September/382628.html

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] Please pull ARC fixes for 2019.10-rc4

2019-09-03 Thread Alexey Brodkin
Hi Tom,

The following changes since commit d22c8be964a870f59d2fdab6c67cefa0c4799364:

  Merge branch 'master' of git://git.denx.de/u-boot-sh (2019-09-01 13:33:12 
-0400)

are available in the Git repository at:

  g...@gitlab.denx.de:u-boot/custodians/u-boot-arc.git tags/arc-for-2019.10-rc4

for you to fetch changes up to 968b98bc27c2b228323c53761075422ebbb098bd:

  arc: emsdp: Add more platform-specific compiler options (2019-09-03 19:05:34 
+0300)


These are some very late changes mostly required to get 64-bit
division working on ARC boards.

For that we had to import missing parts of libgcc and add compiler
flags to EMSDP which otherwise used very simple profile for compliation.

And while at it another fix for EM SDP initialization is inluded as well.


Alexey Brodkin (3):
  arc: emsdp: Add initialization of PSRAM
  arc: libgcc: Import __udivdi3 & __udivmoddi4 to allow 64-bit division
  arc: emsdp: Add more platform-specific compiler options

 arch/arc/lib/libgcc2.c | 75 
+++
 board/synopsys/emsdp/config.mk |  2 ++
 board/synopsys/emsdp/emsdp.c   | 37 +
 configs/emsdp_defconfig|  1 +
 4 files changed, 115 insertions(+)
 create mode 100644 board/synopsys/emsdp/config.mk

Regards,
Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] mmc: dw_mmc: fix timeout calculate method

2019-09-02 Thread Alexey Brodkin
Hi Kever,

> -Original Message-
> From: Kever Yang 
> Sent: Monday, September 2, 2019 11:05 AM
> To: Alexey Brodkin 
> Cc: tr...@konsulko.com; eugeniy.palt...@synopsys.com; Simon Glass 
> ; Peng Fan
> ; u-boot@lists.denx.de
> Subject: Re: [PATCH] mmc: dw_mmc: fix timeout calculate method
> 
> Hi Alexey,
> 
> On 2019/8/30 下午9:28, Alexey Brodkin wrote:
> > Hi Kever,
> >
> > [snip]
> >
> >> I think this tree does not including this patch, Peng drop it because of
> >> this issue,
> >> so you need to apply this patch in your branch to reproduce the problem.
> >> I have send out V2 patch for this fix with only using 32bit variable
> > Could you please refer me to the problematic patch so I may try it?
> 
> This is the patch with problem, and here is the link on patchwork:
> https://patchwork.ozlabs.org/patch/1146845/

Please find my fixes here:
https://patchwork.ozlabs.org/patch/1156541/
https://patchwork.ozlabs.org/patch/1156617/

Tom do we want https://patchwork.ozlabs.org/patch/1146845/ and fixes for it
(see 2 items above) to become a part of upcoming v2019.10 release or
it will be slated for the next one?

-Alexey


___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] arc: emsdp: Add more platform-specific compiler options

2019-09-02 Thread Alexey Brodkin
Even though EM SDP is FPGA-based board and different FPGA
images (known as .bit-files) are awailable for the board still
there's a common subset of options we may rely on for all configs.

These are:
 * Normalizer
 * Swap instructions
 * Simple multiplier
 * Barrel-shifter
 * Floating-point unit
 * Shorter instructions (code density)

This among other improvements allows to compile code with
64-bit divisions, see [1].

[1] https://patchwork.ozlabs.org/patch/1156541/

Signed-off-by: Alexey Brodkin 
Cc: Kever Yang 
---
 board/synopsys/emsdp/config.mk | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 board/synopsys/emsdp/config.mk

diff --git a/board/synopsys/emsdp/config.mk b/board/synopsys/emsdp/config.mk
new file mode 100644
index 00..67fd7bf82a
--- /dev/null
+++ b/board/synopsys/emsdp/config.mk
@@ -0,0 +1,2 @@
+PLATFORM_CPPFLAGS += -mlittle-endian -mnorm -mswap -mmpy-option=3 \
+ -mbarrel-shifter -mfpu=fpuda_all -mcode-density
-- 
2.16.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] arc: libgcc: Import __udivdi3 & __udivmoddi4 to allow 64-bit division

2019-09-02 Thread Alexey Brodkin
Hi,

> -Original Message-
> From: Alexey Brodkin 
> Sent: Monday, September 2, 2019 12:43 PM
> To: u-boot@lists.denx.de
> Cc: uboot-snps-...@synopsys.com; linux-snps-...@lists.infradead.org; Alexey 
> Brodkin
> ; Kever Yang 
> Subject: [PATCH] arc: libgcc: Import __udivdi3 & __udivmoddi4 to allow 64-bit 
> division
> 
> As reported by Kever here [1] we were unable to compile 64-bit division
> code due to missing definition of __udivdi3().
> 
> Import its implementation and __udivmoddi4() as its direct dependency
> from today's libgcc [2].
> 
> [1] https://patchwork.ozlabs.org/patch/1146845/
> [2] 
> https://github.com/gcc-mirror/gcc/commit/5d8723600bc0eed41226b5a6785bc02a053b45d5
> 
> Signed-off-by: Alexey Brodkin 
> Cc: Kever Yang 

For the record for EM SDP (emsdp_defconfig) building still
fails this way:
->8-
arc-linux-ld.bfd: arch/arc/lib/lib.a(libgcc2.o): in function `__udivmoddi4':
.../arch/arc/lib/libgcc2.c:195: undefined reference to `__clzdi2'
arc-linux-ld.bfd: .../arch/arc/lib/libgcc2.c:195: undefined reference to 
`__clzdi2'
arc-linux-ld.bfd: .../arch/arc/lib/libgcc2.c:196: undefined reference to 
`__clzdi2'
arc-linux-ld.bfd: .../arch/arc/lib/libgcc2.c:196: undefined reference to 
`__clzdi2'
->8-

That happens because we use a very simple -mcpu=arcem which doesn't use
HW normalizer unit. I'm preparing a patch that will improve EM SDP's compiler
options.

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] arc: libgcc: Import __udivdi3 & __udivmoddi4 to allow 64-bit division

2019-09-02 Thread Alexey Brodkin
As reported by Kever here [1] we were unable to compile 64-bit division
code due to missing definition of __udivdi3().

Import its implementation and __udivmoddi4() as its direct dependency
from today's libgcc [2].

[1] https://patchwork.ozlabs.org/patch/1146845/
[2] 
https://github.com/gcc-mirror/gcc/commit/5d8723600bc0eed41226b5a6785bc02a053b45d5

Signed-off-by: Alexey Brodkin 
Cc: Kever Yang 
---
 arch/arc/lib/libgcc2.c | 75 ++
 1 file changed, 75 insertions(+)

diff --git a/arch/arc/lib/libgcc2.c b/arch/arc/lib/libgcc2.c
index b92a841a37..ab1dbe1c13 100644
--- a/arch/arc/lib/libgcc2.c
+++ b/arch/arc/lib/libgcc2.c
@@ -158,3 +158,78 @@ __umodsi3(long a, long b)
 {
return udivmodsi4(a, b, 1);
 }
+
+UDWtype
+__udivmoddi4(UDWtype n, UDWtype d, UDWtype *rp)
+{
+   UDWtype q = 0, r = n, y = d;
+   UWtype lz1, lz2, i, k;
+
+   /*
+* Implements align divisor shift dividend method. This algorithm
+* aligns the divisor under the dividend and then perform number of
+* test-subtract iterations which shift the dividend left. Number of
+* iterations is k + 1 where k is the number of bit positions the
+* divisor must be shifted left  to align it under the dividend.
+* quotient bits can be saved in the rightmost positions of the
+* dividend as it shifts left on each test-subtract iteration.
+*/
+
+   if (y <= r) {
+   lz1 = __builtin_clzll(d);
+   lz2 = __builtin_clzll(n);
+
+   k = lz1 - lz2;
+   y = (y << k);
+
+   /*
+* Dividend can exceed 2 ^ (width - 1) - 1 but still be less
+* than the aligned divisor. Normal iteration can drops the
+* high order bit of the dividend. Therefore, first
+* test-subtract iteration is a special case, saving its
+* quotient bit in a separate location and not shifting
+* the dividend.
+*/
+
+   if (r >= y) {
+   r = r - y;
+   q = (1ULL << k);
+   }
+
+   if (k > 0) {
+   y = y >> 1;
+
+   /*
+* k additional iterations where k regular test
+* subtract shift dividend iterations are done.
+*/
+   i = k;
+   do {
+   if (r >= y)
+   r = ((r - y) << 1) + 1;
+   else
+   r = (r << 1);
+   i = i - 1;
+   } while (i != 0);
+
+   /*
+* First quotient bit is combined with the quotient
+* bits resulting from the k regular iterations.
+*/
+   q = q + r;
+   r = r >> k;
+   q = q - (r << k);
+   }
+   }
+
+   if (rp)
+   *rp = r;
+
+   return q;
+}
+
+UDWtype
+__udivdi3(UDWtype n, UDWtype d)
+{
+   return __udivmoddi4(n, d, (UDWtype *)0);
+}
-- 
2.16.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] mmc: dw_mmc: fix timeout calculate method

2019-08-30 Thread Alexey Brodkin
Hi Kever,

[snip]
 
> I think this tree does not including this patch, Peng drop it because of
> this issue,
> so you need to apply this patch in your branch to reproduce the problem.
> I have send out V2 patch for this fix with only using 32bit variable

Could you please refer me to the problematic patch so I may try it?

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] mmc: dw_mmc: fix timeout calculate method

2019-08-29 Thread Alexey Brodkin
Hi Kever,

> -Original Message-
> From: Kever Yang 
> Sent: Thursday, August 29, 2019 10:17 AM
> To: Peng Fan ; u-boot@lists.denx.de
> Cc: tr...@konsulko.com; eugeniy.palt...@synopsys.com; Alexey Brodkin 
> ; Simon
> Glass 
> Subject: Re: [PATCH] mmc: dw_mmc: fix timeout calculate method
> 
> Add ARC maintainers.

Thanks for adding us in the loop.

> On 2019/8/27 下午5:58, Peng Fan wrote:
> > Hi Kever,
> >
> >> -Original Message-
> >> From: U-Boot  On Behalf Of Peng Fan
> >> Sent: 2019年8月27日 15:40
> >> To: Kever Yang ; u-boot@lists.denx.de
> >> Cc: tr...@konsulko.com
> >> Subject: Re: [U-Boot] [PATCH] mmc: dw_mmc: fix timeout calculate method
> >>
> >>> Subject: [PATCH] mmc: dw_mmc: fix timeout calculate method
> >>>
> >>> There are two cases not been considered:
> >>> - use uint for timeout, it will overflow when size bigger than 512KB for
> >>>it *8*1000 at the beginning, but we may use size up to 32MB;
> >>> - The timeout is using clock speed for data rate, but the device may not
> >>>have such high speed, eg. clock is 52MHz while the device write speed
> >> may
> >>>be less than 10MB/s.
> >>>
> >>> Fix them in this patch, the max timeout is about 6500 when size is
> >>> 32MB after fix.
> >>>
> >>> Signed-off-by: Kever Yang 
> > This patch breaks build, I need drop it.
> > See build:
> > https://travis-ci.org/MrVan/u-boot/jobs/577210464
>
> The error happens only in ARC architecture, and seems like the arc
> compiler not support 64bit div?

It's not a compiler problem but a subtle issue with libgcc.
To be independent from toolchain type (and we have quite a few flavors like
little- and big-endian, ARCv1 or ARCv2 etc) decision was made to move
libgcc into U-Boot but given full libgcc is quite large only primitives required
by up-to-date U-Boot were copied from GCC to U-Boot.

> Any idea on how to fix this?

Add missing primitives like __udivdi3() and their dependencies, see for example:
https://github.com/gcc-mirror/gcc/blob/master/libgcc/libgcc2.c#L1318.

And I'll happily do it myself but for some reason I cannot reproduce that 
problem locally.
I use the same pre-built arc-2018.09 toolchain:
>8---
# arc-linux-gcc -v
gcc version 8.2.1 20180814 (ARCv2 ISA Linux uClibc toolchain 2018.09)
>8---

And may successfully build U-Boot for HSDK from
https://github.com/MrVan/u-boot/commits/mmc-8-28-2019:
>8---
# git l
76c0bf2873 - (HEAD -> mrvan, github-mrvan/mmc-8-28-2019) ARM: dts: ast2500: Add 
SDHCI nodes (27 hours ago) 
07b000cd32 - configs: AST2500 EVB: Enable SD controller (27 hours ago) 
5f6a033f10 - mmc: Add Aspeed SD controller driver (27 hours ago) 
a6503eaa66 - clk: aspeed: Add support for SD clock (27 hours ago) 
c54e328452 - mmc: Rename timeout parameters for clarification (27 hours ago) 

be949bb19c - mmc: Fix timeout values passed to mmc_wait_dat0() (27 hours ago) 

49842f0edf - dm: mmc: remove unused U_BOOT_DRIVER(mmc) (27 hours ago) 
7b91b47f8f - Prepare v2019.10-rc3 (27 hours ago) 
>8---

That way:
>8---
./tools/buildman/buildman hsdk
boards.cfg is up to date. Nothing to do.
Building current source for 1 boards (1 thread, 48 jobs per thread)
   arc:  w+   hsdk
010 /1  hsdk
>8---

What do I do wrong?

-Alexey


___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] arc: emsdp: Add initialization of PSRAM

2019-08-29 Thread Alexey Brodkin
If the "Page Mode" is not enabled on the device,
read operations from PSRAM may result in incorrect data.

Signed-off-by: Alexey Brodkin 
---
 board/synopsys/emsdp/emsdp.c | 37 +
 configs/emsdp_defconfig  |  1 +
 2 files changed, 38 insertions(+)

diff --git a/board/synopsys/emsdp/emsdp.c b/board/synopsys/emsdp/emsdp.c
index c0770b58c1..3bf4a1879b 100644
--- a/board/synopsys/emsdp/emsdp.c
+++ b/board/synopsys/emsdp/emsdp.c
@@ -48,6 +48,43 @@ int mach_cpu_init(void)
return 0;
 }
 
+int board_early_init_r(void)
+{
+#define EMSDP_PSRAM_BASE   0xf2001000
+#define PSRAM_FLASH_CONFIG_REG_0   (void *)(EMSDP_PSRAM_BASE + 0x10)
+#define PSRAM_FLASH_CONFIG_REG_1   (void *)(EMSDP_PSRAM_BASE + 0x14)
+#define CRE_ENABLE BIT(31)
+#define CRE_DRIVE_CMD  BIT(6)
+
+#define PSRAM_RCR_DPD  BIT(4)
+#define PSRAM_RCR_PAGE_MODEBIT(7)
+
+/*
+ * PSRAM_FLASH_CONFIG_REG_x[30:15] to the address lines[16:1] of flash,
+ * thus "<< 1".
+ */
+#define PSRAM_RCR_SETUP((PSRAM_RCR_DPD | PSRAM_RCR_PAGE_MODE) 
<< 1)
+
+   // Switch PSRAM controller to command mode
+   writel(CRE_ENABLE | CRE_DRIVE_CMD, PSRAM_FLASH_CONFIG_REG_0);
+   // Program Refresh Configuration Register (RCR) for BANK0
+   writew(0, (void *)(0x1000 + PSRAM_RCR_SETUP));
+   // Switch PSRAM controller back to memory mode
+   writel(0, PSRAM_FLASH_CONFIG_REG_0);
+
+
+   // Switch PSRAM controller to command mode
+   writel(CRE_ENABLE | CRE_DRIVE_CMD, PSRAM_FLASH_CONFIG_REG_1);
+   // Program Refresh Configuration Register (RCR) for BANK1
+   writew(0, (void *)(0x1080 + PSRAM_RCR_SETUP));
+   // Switch PSRAM controller back to memory mode
+   writel(0, PSRAM_FLASH_CONFIG_REG_1);
+
+   printf("PSRAM initialized.\n");
+
+   return 0;
+}
+
 int board_mmc_init(bd_t *bis)
 {
struct dwmci_host *host = NULL;
diff --git a/configs/emsdp_defconfig b/configs/emsdp_defconfig
index 64281d0529..5e55e3e2b2 100644
--- a/configs/emsdp_defconfig
+++ b/configs/emsdp_defconfig
@@ -7,6 +7,7 @@ CONFIG_ENV_SIZE=0x1000
 CONFIG_SYS_CLK_FREQ=4000
 # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
 CONFIG_VERSION_VARIABLE=y
+CONFIG_BOARD_EARLY_INIT_R=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="emsdp# "
 # CONFIG_CMD_BOOTD is not set
-- 
2.16.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [RFC PATCH] net: designware: drop compatible altr, socfpga-stmmac

2019-08-20 Thread Alexey Brodkin
Hi Ralph,

> -Original Message-
> From: Ralph Siemsen 
> Sent: Monday, August 19, 2019 9:43 PM
> To: u-boot@lists.denx.de; Joe Hershberger ; Alexey 
> Brodkin
> ; Vlad Zakharov 
> Cc: Ralph Siemsen 
> Subject: [RFC PATCH] net: designware: drop compatible altr,socfpga-stmmac
> 
> The same compatible = "altr,socfpga-stmmac" appears in both
> drivers/net/designware.c and drivers/net/dwmac_socfgpa.c,
> creating ambiguity in which driver will be bound.
> 
> For Intel/Altera SoC devices, dwmac_socfpga.c is the correct driver.
> So drop the compatible string from designware.c.
> 
> Signed-off-by: Ralph Siemsen 
> ---
> This compatible string also appears in: axs10x_mb.dtsi and hsdk.dts.
> Maintainers of those boards have been copied, kindly review.

Thanks for this clean-up.

Speaking about AXS10x board where we do have DW GMAC
I cannot recall the reason I chose to use "altr,socfpga-stmmac"
for the board here [1] 3 years ago.

But given we don't have any special quirks implemented whatever
is the most generic DW GMAC compatible string is should be good for us.

Joe, could you please suggest if we need to use just "st,stm32-dwmac"
or add our own compatible as the ASIC is not from ST obviously but
an FPGA with Synopsys ARC SoC?

[1] 
https://gitlab.denx.de/u-boot/u-boot/commit/fb2dea60e8f355ae00d427db09112a90839c96ec

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v1 4/5] CONFIG_SYS_[DI]CACHE_OFF: convert to Kconfig

2019-04-18 Thread Alexey Brodkin
Hi Trevor,

> -Original Message-
 
> CONFIG_SYS_[DI]CACHE_OFF had been partially converted to Kconfig
> parameters; only for the ARC architecture. This patch turns these two
> parameters into Kconfig items everywhere else they are found.
> 
> All of the include/configs/* and defconfig changes in this patch are
> for arm machines only. The Kconfig changes for arc, nds32, riscv,
> and xtensa have been included since these symbols are found in code
> under arch/{arc,nds32,riscv,xtensa}, however, no currently-defined
> include/configs/* or defconfigs for these architectures exist which
> include these symbols.
> 
> These results have been confirmed with tools/moveconfig.py.
> 
> Signed-off-by: Trevor Woerner 
> 
> ---
> 
>  README   |  2 --
>  arch/arc/Kconfig |  8 ++--

Even though I'm ok with ARC changes (which are just
rephrases in help message) I'm wondering if we now may finally
move both items (for D$ & I$) to a higher level to reduce duplication?

Acked-by: Alexey Brodkin 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v1 5/5] CONFIG_SPL_SYS_[DI]CACHE_OFF: add

2019-04-18 Thread Alexey Brodkin
Hi Trevor,

> -Original Message-
> From: Trevor Woerner 
> Sent: Thursday, April 18, 2019 4:12 PM
> To: U-Boot Mailing List 

[snip]
 
> While converting CONFIG_SYS_[DI]CACHE_OFF to Kconfig, there are instances
> where these configuration items are conditional on SPL. This commit adds SPL
> variants of these configuration items, uses CONFIG_IS_ENABLED(), and updates
> the configurations as required.
> 
> Signed-off-by: Trevor Woerner 
> ---
> 
>  arch/arc/Kconfig| 14 ++
>  arch/arc/lib/start.S|  4 ++--

For ARC part...

Acked-by: Alexey Brodkin 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [uboot-snps-arc] ARC changes for 2019.07

2019-04-18 Thread Alexey Brodkin
Hi Tom,

> -Original Message-
> From: Tom Rini 
> Sent: Thursday, April 18, 2019 7:21 PM
> To: Alexey Brodkin 
> Cc: uboot-snps-...@synopsys.com; u-boot@lists.denx.de
> Subject: Re: [uboot-snps-arc] [U-Boot] ARC changes for 2019.07
> 
> On Thu, Apr 18, 2019 at 04:04:27PM +, Alexey Brodkin wrote:
> 
> > Hi Tom,
> >
> > The following changes since commit 75ce8c938d39bd22460be66e6bf318bd2410c17b:
> >
> >   Merge tag 'u-boot-imx-20190415' of git://git.denx.de/u-boot-imx 
> > (2019-04-15 07:31:14 -0400)
> >
> > are available in the Git repository at:
> >
> >   git://git.denx.de/u-boot-arc.git tags/arc-for-2019.07
> >
> > for you to fetch changes up to cc2f7b6c7d7d5adeedecdb6c058b2e40b3f4:
> >
> >   ARC: [plat-axs10x]: migrate to DM_MMC (2019-04-18 09:12:38 +0300)
> >
> 
> Note that iot_devkit, emsdp and axs101 aren't enabling DM_MMC yet.

Oops right. Since I run full build in Travis I missed that part sice
Travis job didn't flag anything, see
https://travis-ci.org/abrodkin/u-boot/builds/521638433

Sure we'll be doing that soonish!

> Also, I see a whole lot of the warning about using CONFIG_OF_EMBED and
> not CONFIG_OF_SEPARATE.  Are you looking into migrating that away or
> convincing Simon that no, this is when we really do need/want OF_EMBED?

Hm... that's an interesting one. I think we'll switch to CONFIG_OF_SEPARATE,
thanks for the reminder though!

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] ARC changes for 2019.07

2019-04-18 Thread Alexey Brodkin
Hi Tom,

The following changes since commit 75ce8c938d39bd22460be66e6bf318bd2410c17b:

  Merge tag 'u-boot-imx-20190415' of git://git.denx.de/u-boot-imx (2019-04-15 
07:31:14 -0400)

are available in the Git repository at:

  git://git.denx.de/u-boot-arc.git tags/arc-for-2019.07

for you to fetch changes up to cc2f7b6c7d7d5adeedecdb6c058b2e40b3f4:

  ARC: [plat-axs10x]: migrate to DM_MMC (2019-04-18 09:12:38 +0300)


In this small series we migrate ARC boards to DM_MMC
so we're hopefully are good now and our boards will be kept
in U-Boot for some more time :)


Eugeniy Paltsev (3):
  ARC: dwmmc: Adding DesignWare MMC driver support for ARC devboards
  ARC: [plat-hsdk]: migrate to DM_MMC
  ARC: [plat-axs10x]: migrate to DM_MMC

 MAINTAINERS  |   7 ++
 arch/arc/dts/axs10x_mb.dtsi  |  28 +++
 arch/arc/dts/hsdk.dts|  26 +
 board/synopsys/axs10x/axs10x.c   |  29 ---
 board/synopsys/hsdk/hsdk.c   |  41 
+
 configs/axs103_defconfig |   2 ++
 configs/hsdk_defconfig   |   2 ++
 doc/device-tree-bindings/mmc/snps,dw-mmc.txt |  33 +++
 drivers/mmc/Kconfig  |  10 
 drivers/mmc/Makefile |   1 +
 drivers/mmc/snps_dw_mmc.c| 199 
++
 11 files changed, 314 insertions(+), 64 deletions(-)
 create mode 100644 doc/device-tree-bindings/mmc/snps,dw-mmc.txt
 create mode 100644 drivers/mmc/snps_dw_mmc.c

Regards,
Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] Please pull ARC last minute changes for 2019.04

2019-03-28 Thread Alexey Brodkin
Hi Tom,

The following changes since commit 2b9b9cdd5f9ae1cbc786ba3c2255a51b3ea4a636:

  Merge branch '2019-03-25-master-imports' (2019-03-26 23:17:21 -0400)

are available in the Git repository at:

  git://git.denx.de/u-boot-arc.git tags/arc-last-minute-for-2019.04

for you to fetch changes up to 34d117b1fb055920e742baafdd9c1a390c480519:

  hsdk: readme: Suggest getting pyelftools with pip (2019-03-28 10:50:32 +0300)


This is last minute change which fixes problems in runtime on
AXS10x board caused by some changes in NAND framework and
tiny documentation improvement.

Anyways NAND flash storage was never really used on the board for various
reasons and now we decided to drop it for good.

Note this change only touches 1 ARC board so that should be safe for others.
As usual - build tested in TravisCI, see
https://travis-ci.org/abrodkin/u-boot/builds/512041342


Alexey Brodkin (1):
  hsdk: readme: Suggest getting pyelftools with pip

Eugeniy Paltsev (1):
  ARC: AXS10x: drop NAND support

 board/synopsys/axs10x/Makefile |   1 -
 board/synopsys/axs10x/nand.c   | 242 
--
 board/synopsys/hsdk/README |   7 ++--
 configs/axs101_defconfig   |   1 -
 configs/axs103_defconfig   |   1 -
 include/configs/axs10x.h   |   6 ---
 6 files changed, 4 insertions(+), 254 deletions(-)
 delete mode 100644 board/synopsys/axs10x/nand.c

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] hsdk: readme: Suggest getting pyelftools with pip

2019-02-18 Thread Alexey Brodkin
Signed-off-by: Alexey Brodkin 
Suggested-by: Yunir Salimzyanov 
---
 board/synopsys/hsdk/README | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/board/synopsys/hsdk/README b/board/synopsys/hsdk/README
index e29a6a1727..9155f17c6e 100644
--- a/board/synopsys/hsdk/README
+++ b/board/synopsys/hsdk/README
@@ -83,10 +83,11 @@ Useful notes on bulding and using of U-Boot on ARC HS 
Development Kit (AKA HSDK)
   HSDK board.
 
   Note that Python3 script is used for generation of a header, thus
-  to get that done it's required to have Python3 with elftools installed.
-  On CentOS/RHEL/Fedora this could be installed with:
+  to get that done it's required to have Python3 with "pyelftools" 
installed.
+
+  "pyelftools" could be installed with help of "pip" even w/o root rights:
   ->8--
-  sudo dnf install python3-pyelftools
+  python3 -m pip install --user pyelftools
   ->8--
 
EXECUTING U-BOOT
-- 
2.17.1


___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] Please pull ARC changes

2019-01-24 Thread Alexey Brodkin
Hi Tom,

The following changes since commit ce0d1e48165fdd3bde4bb431f1d2e100b1617a6e:

  Merge tag 'xilinx-for-v2019.04' of git://git.denx.de/u-boot-microblaze 
(2019-01-24 10:47:05 -0500)

are available in the Git repository at:

  git://git.denx.de/u-boot-arc.git tags/arc-fixes-for-2019.04-rc1

for you to fetch changes up to fae3798ac9f6de5a4cb1aa1e849d419a2bb8dbbe:

  ARC: cache: define CONFIG_SYS_CACHELINE_SIZE as ARCH_DMA_MINALIGN (2019-01-25 
08:41:09 +0300)


A couple of trivial fixes and improvements for ARC

Most notable are:
 * Move of ENV_SIZE/ENV_OFFSET to Kconfig
 * Fix with private structure allocation for arc_uart
 * Definition of CONFIG_SYS_CACHELINE_SIZE useful for building drivers


Alexey Brodkin (5):
  serial: Get rid of CONFIG_DW_SERIAL
  ARC: Move ENV_SIZE and ENV_OFFSET to Kconfig
  serial_arc: Allocate buffer for private data
  ARC: Fix iteration in arc_xx_version()
  ARC: cache: define CONFIG_SYS_CACHELINE_SIZE as ARCH_DMA_MINALIGN

 arch/arc/include/asm/cache.h | 3 +++
 arch/arc/lib/cpu.c   | 4 ++--
 configs/emsdp_defconfig  | 1 +
 configs/iot_devkit_defconfig | 1 +
 configs/tb100_defconfig  | 1 +
 drivers/serial/serial_arc.c  | 1 +
 env/Kconfig  | 4 +++-
 include/configs/axs10x.h | 2 --
 include/configs/emsdp.h  | 1 -
 include/configs/hsdk.h   | 3 ---
 include/configs/iot_devkit.h | 1 -
 include/configs/nsim.h   | 6 --
 include/configs/tb100.h  | 6 --
 scripts/config_whitelist.txt | 1 -
 14 files changed, 12 insertions(+), 23 deletions(-)

Regards,
Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] ARC: cache: define CONFIG_SYS_CACHELINE_SIZE as ARCH_DMA_MINALIGN

2019-01-22 Thread Alexey Brodkin
Even though we don't use CONFIG_SYS_CACHELINE_SIZE in ARC-specific code
it is used a lot in different drivers for alignment purposes.

So we define it and make much more drivers at least compilable for ARC.

Signed-off-by: Alexey Brodkin 
---
 arch/arc/include/asm/cache.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h
index 1604cd0b3e..0fdcf2d2dd 100644
--- a/arch/arc/include/asm/cache.h
+++ b/arch/arc/include/asm/cache.h
@@ -16,6 +16,9 @@
  */
 #define ARCH_DMA_MINALIGN  128
 
+/* CONFIG_SYS_CACHELINE_SIZE is used a lot in drivers */
+#define CONFIG_SYS_CACHELINE_SIZE  ARCH_DMA_MINALIGN
+
 #if defined(ARC_MMU_ABSENT)
 #define CONFIG_ARC_MMU_VER 0
 #elif defined(CONFIG_ARC_MMU_V2)
-- 
2.16.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] ARC: Fix iteration in arc_xx_version()

2019-01-22 Thread Alexey Brodkin
"i" gets incremented before we're entering loop body
and effectively we iterate from 1 to 8 instead of 0 to 7.

This way we:
 a) Skip the first line of struct hs_versions
 b) Go over it and access memory beyond the structure

Signed-off-by: Alexey Brodkin 
---
 arch/arc/lib/cpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arc/lib/cpu.c b/arch/arc/lib/cpu.c
index 07daaa8d15..01cca95d5b 100644
--- a/arch/arc/lib/cpu.c
+++ b/arch/arc/lib/cpu.c
@@ -87,7 +87,7 @@ const char *arc_em_version(int arcver, char *name, int 
name_len)
bool xymem = ARC_FEATURE_EXISTS(ARC_AUX_XY_BUILD);
int i;
 
-   for (i = 0; i++ < sizeof(em_versions) / sizeof(struct em_template_t);) {
+   for (i = 0; i < sizeof(em_versions) / sizeof(struct em_template_t); 
i++) {
if (em_versions[i].cache == cache &&
em_versions[i].dsp == dsp &&
em_versions[i].xymem == xymem) {
@@ -147,7 +147,7 @@ const char *arc_hs_version(int arcver, char *name, int 
name_len)
bool dual_issue = arcver == 0x54 ? true : false;
int i;
 
-   for (i = 0; i++ < sizeof(hs_versions) / sizeof(struct hs_template_t);) {
+   for (i = 0; i < sizeof(hs_versions) / sizeof(struct hs_template_t); 
i++) {
if (hs_versions[i].cache == cache &&
hs_versions[i].mmu == mmu &&
hs_versions[i].dual_issue == dual_issue &&
-- 
2.16.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] serial_arc: Allocate buffer for private data

2019-01-22 Thread Alexey Brodkin
Apparently we never allocated buffer for arc_serial_platdata
which for some reason never caused problems when executed in nSIM.
But in Qemu this causes expected problems.

Signed-off-by: Alexey Brodkin 
---
 drivers/serial/serial_arc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/serial/serial_arc.c b/drivers/serial/serial_arc.c
index 980b38d2a1..70dbc6d6b5 100644
--- a/drivers/serial/serial_arc.c
+++ b/drivers/serial/serial_arc.c
@@ -126,6 +126,7 @@ U_BOOT_DRIVER(serial_arc) = {
.id = UCLASS_SERIAL,
.of_match = arc_serial_ids,
.ofdata_to_platdata = arc_serial_ofdata_to_platdata,
+   .platdata_auto_alloc_size = sizeof(struct arc_serial_platdata),
.probe = arc_serial_probe,
.ops= _serial_ops,
 };
-- 
2.16.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2] ARC: Move ENV_SIZE and ENV_OFFSET to Kconfig

2019-01-16 Thread Alexey Brodkin
Join the party of some ARM boards and drop more
items from include/configs/xxx.h.

Signed-off-by: Alexey Brodkin 
Cc: Michal Simek 
Cc: Simon Glass 
Cc: Tom Rini 
---

Changes in v2:

 * Default ENV_OFFSET defined specially for ARC but not all

 configs/emsdp_defconfig  | 1 +
 configs/iot_devkit_defconfig | 1 +
 configs/tb100_defconfig  | 1 +
 env/Kconfig  | 4 +++-
 include/configs/axs10x.h | 1 -
 include/configs/emsdp.h  | 1 -
 include/configs/hsdk.h   | 2 --
 include/configs/iot_devkit.h | 1 -
 include/configs/nsim.h   | 6 --
 include/configs/tb100.h  | 6 --
 10 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/configs/emsdp_defconfig b/configs/emsdp_defconfig
index 273334b05d..64281d0529 100644
--- a/configs/emsdp_defconfig
+++ b/configs/emsdp_defconfig
@@ -3,6 +3,7 @@ CONFIG_ISA_ARCV2=y
 CONFIG_CPU_ARCEM6=y
 CONFIG_TARGET_EMSDP=y
 CONFIG_SYS_TEXT_BASE=0x
+CONFIG_ENV_SIZE=0x1000
 CONFIG_SYS_CLK_FREQ=4000
 # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
 CONFIG_VERSION_VARIABLE=y
diff --git a/configs/iot_devkit_defconfig b/configs/iot_devkit_defconfig
index 1b6dd9e55a..24bbe3fc5d 100644
--- a/configs/iot_devkit_defconfig
+++ b/configs/iot_devkit_defconfig
@@ -5,6 +5,7 @@ CONFIG_SYS_ICACHE_OFF=y
 CONFIG_SYS_DCACHE_OFF=y
 CONFIG_TARGET_IOT_DEVKIT=y
 CONFIG_SYS_TEXT_BASE=0x
+CONFIG_ENV_SIZE=0x1000
 CONFIG_SYS_CLK_FREQ=1600
 CONFIG_LOCALVERSION="-iotdk-1.0"
 # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
diff --git a/configs/tb100_defconfig b/configs/tb100_defconfig
index f30053d4de..e3837d92e7 100644
--- a/configs/tb100_defconfig
+++ b/configs/tb100_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARC=y
 CONFIG_TARGET_TB100=y
 CONFIG_SYS_TEXT_BASE=0x8400
+CONFIG_ENV_SIZE=0x800
 CONFIG_SYS_CLK_FREQ=5
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
diff --git a/env/Kconfig b/env/Kconfig
index 9011109b47..c22cbbdadc 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -431,7 +431,7 @@ config ENV_EXT4_FILE
  It's a string of the EXT4 file name. This file use to store the
  environment (explicit path to the file)
 
-if ARCH_ROCKCHIP || ARCH_SUNXI || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL
+if ARCH_ROCKCHIP || ARCH_SUNXI || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL || 
ARC
 
 config ENV_OFFSET
hex "Environment Offset"
@@ -441,6 +441,7 @@ config ENV_OFFSET
default 0x88000 if ARCH_SUNXI
default 0xE if ARCH_ZYNQ
default 0x1E0 if ARCH_ZYNQMP
+   default 0 if ARC
help
  Offset from the start of the device (or partition)
 
@@ -449,6 +450,7 @@ config ENV_SIZE
default 0x4 if ENV_IS_IN_SPI_FLASH && ARCH_ZYNQMP
default 0x2 if ARCH_SUNXI || ARCH_ZYNQ
default 0x8000 if ARCH_ROCKCHIP || ARCH_ZYNQMP || ARCH_VERSAL
+   default 0x4000 if ARC
help
  Size of the environment storage area
 
diff --git a/include/configs/axs10x.h b/include/configs/axs10x.h
index 9452b06771..24afbc8fe5 100644
--- a/include/configs/axs10x.h
+++ b/include/configs/axs10x.h
@@ -62,7 +62,6 @@
 /*
  * Environment settings
  */
-#define CONFIG_ENV_SIZESZ_16K
 #define CONFIG_EXTRA_ENV_SETTINGS \
"upgrade=if mmc rescan && " \
"fatload mmc 0:1 ${loadaddr} u-boot-update.img && " \
diff --git a/include/configs/emsdp.h b/include/configs/emsdp.h
index 9a205edc7c..44614138f8 100644
--- a/include/configs/emsdp.h
+++ b/include/configs/emsdp.h
@@ -24,7 +24,6 @@
 /*
  * Environment
  */
-#define CONFIG_ENV_SIZESZ_4K
 #define CONFIG_BOOTFILE"app.bin"
 #define CONFIG_LOADADDRCONFIG_SYS_LOAD_ADDR
 
diff --git a/include/configs/hsdk.h b/include/configs/hsdk.h
index 94c88b29f1..4755567a2d 100644
--- a/include/configs/hsdk.h
+++ b/include/configs/hsdk.h
@@ -57,8 +57,6 @@
 /*
  * Environment settings
  */
-#define CONFIG_ENV_SIZESZ_16K
-
 #define CONFIG_EXTRA_ENV_SETTINGS \
"upgrade=if mmc rescan && " \
"fatload mmc 0:1 ${loadaddr} u-boot-update.scr && " \
diff --git a/include/configs/iot_devkit.h b/include/configs/iot_devkit.h
index 4ffe1141d9..4b110bb9d8 100644
--- a/include/configs/iot_devkit.h
+++ b/include/configs/iot_devkit.h
@@ -77,7 +77,6 @@
 /*
  * Environment
  */
-#define CONFIG_ENV_SIZESZ_4K
 #define CONFIG_BOOTFILE"app.bin"
 #define CONFIG_LOADADDRCONFIG_SYS_LOAD_ADDR
 
diff --git a/include/configs/nsim.h b/include/configs/nsim.h
index c3f34a91e4..61217bbe79 100644
--- a/include/configs/nsim.h
+++ b/include/configs/nsim.h
@@ -24,12 +24,6 @@
 #define CONFIG_SYS_BOOTM_LEN   SZ_32M
 #define CONFIG_SYS_LOAD_ADDR   0x8200
 
-/*
- * Environment settings
- */
-#define CONFIG_ENV_SIZESZ_512

Re: [U-Boot] [PATCH] ARC: Move ENV_SIZE and ENV_OFFSET to Kconfig

2019-01-16 Thread Alexey Brodkin
Hi Tom,

> -Original Message-
> From: Tom Rini 
> Sent: Wednesday, January 16, 2019 7:25 PM
> To: Alexey Brodkin 
> Cc: u-boot@lists.denx.de; uboot-snps-...@synopsys.com; Michal Simek 
> ; Simon
> Glass 
> Subject: Re: [PATCH] ARC: Move ENV_SIZE and ENV_OFFSET to Kconfig
> 
> On Wed, Jan 16, 2019 at 04:22:22PM +, Alexey Brodkin wrote:
> > Hi Tom,
> >
> > > -Original Message-
> > > From: Tom Rini 
> > > Sent: Wednesday, January 16, 2019 7:19 PM
> > > To: Alexey Brodkin 
> > > Cc: u-boot@lists.denx.de; uboot-snps-...@synopsys.com; Michal Simek 
> > > ;
> Simon
> > > Glass 
> > > Subject: Re: [PATCH] ARC: Move ENV_SIZE and ENV_OFFSET to Kconfig
> > >
> > > On Wed, Jan 16, 2019 at 07:11:15PM +0300, Alexey Brodkin wrote:
> > >
> > > > Join the party of some ARM boards and drop more
> > > > items from include/configs/xxx.h.
> > > >
> > > > Signed-off-by: Alexey Brodkin 
> > > > Cc: Michal Simek 
> > > > Cc: Simon Glass 
> > > > Cc: Tom Rini 
> > > > ---
> >
> > [snip]
> >
> > > >  config ENV_OFFSET
> > > > hex "Environment Offset"
> > > > @@ -441,6 +441,7 @@ config ENV_OFFSET
> > > > default 0x88000 if ARCH_SUNXI
> > > > default 0xE if ARCH_ZYNQ
> > > > default 0x1E0 if ARCH_ZYNQMP
> > > > +   default 0
> > >
> > > Please make this "if ARC", thanks!
> >
> > Actually I don't like having here listed all the boards
> > because with more boards/arches moving ENV settings to Kconfig
> > we'll get here all of them listed at some point.
> > Why default ENV_OFFSET [as well as] ENV_SIZE are not set in
> > arch/soc/board top-level Kconfig?
> 
> I believe the answer is that having config FOO prompt in one place and N
> config FOO values results in lots of churn in the defconfig files when
> they get re-synced.  So yes, having N lines of default X if Y with the
> prompt is what we want, at least until everything is converted and then
> we can see if no, really, moving the defaults to some defined /
> consistent locations doesn't result in so much churn.

Ok that's fine by me.
Sending a re-spin.

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] ARC: Move ENV_SIZE and ENV_OFFSET to Kconfig

2019-01-16 Thread Alexey Brodkin
Hi Tom,

> -Original Message-
> From: Tom Rini 
> Sent: Wednesday, January 16, 2019 7:19 PM
> To: Alexey Brodkin 
> Cc: u-boot@lists.denx.de; uboot-snps-...@synopsys.com; Michal Simek 
> ; Simon
> Glass 
> Subject: Re: [PATCH] ARC: Move ENV_SIZE and ENV_OFFSET to Kconfig
> 
> On Wed, Jan 16, 2019 at 07:11:15PM +0300, Alexey Brodkin wrote:
> 
> > Join the party of some ARM boards and drop more
> > items from include/configs/xxx.h.
> >
> > Signed-off-by: Alexey Brodkin 
> > Cc: Michal Simek 
> > Cc: Simon Glass 
> > Cc: Tom Rini 
> > ---

[snip]

> >  config ENV_OFFSET
> > hex "Environment Offset"
> > @@ -441,6 +441,7 @@ config ENV_OFFSET
> > default 0x88000 if ARCH_SUNXI
> > default 0xE if ARCH_ZYNQ
> > default 0x1E0 if ARCH_ZYNQMP
> > +   default 0
> 
> Please make this "if ARC", thanks!

Actually I don't like having here listed all the boards
because with more boards/arches moving ENV settings to Kconfig
we'll get here all of them listed at some point.
Why default ENV_OFFSET [as well as] ENV_SIZE are not set in
arch/soc/board top-level Kconfig?

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] ARC: Move ENV_SIZE and ENV_OFFSET to Kconfig

2019-01-16 Thread Alexey Brodkin
Join the party of some ARM boards and drop more
items from include/configs/xxx.h.

Signed-off-by: Alexey Brodkin 
Cc: Michal Simek 
Cc: Simon Glass 
Cc: Tom Rini 
---
 configs/emsdp_defconfig  | 1 +
 configs/iot_devkit_defconfig | 1 +
 configs/tb100_defconfig  | 1 +
 env/Kconfig  | 4 +++-
 include/configs/axs10x.h | 1 -
 include/configs/emsdp.h  | 1 -
 include/configs/hsdk.h   | 2 --
 include/configs/iot_devkit.h | 1 -
 include/configs/nsim.h   | 6 --
 include/configs/tb100.h  | 6 --
 10 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/configs/emsdp_defconfig b/configs/emsdp_defconfig
index 273334b05d..64281d0529 100644
--- a/configs/emsdp_defconfig
+++ b/configs/emsdp_defconfig
@@ -3,6 +3,7 @@ CONFIG_ISA_ARCV2=y
 CONFIG_CPU_ARCEM6=y
 CONFIG_TARGET_EMSDP=y
 CONFIG_SYS_TEXT_BASE=0x
+CONFIG_ENV_SIZE=0x1000
 CONFIG_SYS_CLK_FREQ=4000
 # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
 CONFIG_VERSION_VARIABLE=y
diff --git a/configs/iot_devkit_defconfig b/configs/iot_devkit_defconfig
index 1b6dd9e55a..24bbe3fc5d 100644
--- a/configs/iot_devkit_defconfig
+++ b/configs/iot_devkit_defconfig
@@ -5,6 +5,7 @@ CONFIG_SYS_ICACHE_OFF=y
 CONFIG_SYS_DCACHE_OFF=y
 CONFIG_TARGET_IOT_DEVKIT=y
 CONFIG_SYS_TEXT_BASE=0x
+CONFIG_ENV_SIZE=0x1000
 CONFIG_SYS_CLK_FREQ=1600
 CONFIG_LOCALVERSION="-iotdk-1.0"
 # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
diff --git a/configs/tb100_defconfig b/configs/tb100_defconfig
index f30053d4de..e3837d92e7 100644
--- a/configs/tb100_defconfig
+++ b/configs/tb100_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARC=y
 CONFIG_TARGET_TB100=y
 CONFIG_SYS_TEXT_BASE=0x8400
+CONFIG_ENV_SIZE=0x800
 CONFIG_SYS_CLK_FREQ=5
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTARGS=y
diff --git a/env/Kconfig b/env/Kconfig
index 9011109b47..8beaa7249a 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -431,7 +431,7 @@ config ENV_EXT4_FILE
  It's a string of the EXT4 file name. This file use to store the
  environment (explicit path to the file)
 
-if ARCH_ROCKCHIP || ARCH_SUNXI || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL
+if ARCH_ROCKCHIP || ARCH_SUNXI || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL || 
ARC
 
 config ENV_OFFSET
hex "Environment Offset"
@@ -441,6 +441,7 @@ config ENV_OFFSET
default 0x88000 if ARCH_SUNXI
default 0xE if ARCH_ZYNQ
default 0x1E0 if ARCH_ZYNQMP
+   default 0
help
  Offset from the start of the device (or partition)
 
@@ -449,6 +450,7 @@ config ENV_SIZE
default 0x4 if ENV_IS_IN_SPI_FLASH && ARCH_ZYNQMP
default 0x2 if ARCH_SUNXI || ARCH_ZYNQ
default 0x8000 if ARCH_ROCKCHIP || ARCH_ZYNQMP || ARCH_VERSAL
+   default 0x4000 if ARC
help
  Size of the environment storage area
 
diff --git a/include/configs/axs10x.h b/include/configs/axs10x.h
index 9452b06771..24afbc8fe5 100644
--- a/include/configs/axs10x.h
+++ b/include/configs/axs10x.h
@@ -62,7 +62,6 @@
 /*
  * Environment settings
  */
-#define CONFIG_ENV_SIZESZ_16K
 #define CONFIG_EXTRA_ENV_SETTINGS \
"upgrade=if mmc rescan && " \
"fatload mmc 0:1 ${loadaddr} u-boot-update.img && " \
diff --git a/include/configs/emsdp.h b/include/configs/emsdp.h
index 9a205edc7c..44614138f8 100644
--- a/include/configs/emsdp.h
+++ b/include/configs/emsdp.h
@@ -24,7 +24,6 @@
 /*
  * Environment
  */
-#define CONFIG_ENV_SIZESZ_4K
 #define CONFIG_BOOTFILE"app.bin"
 #define CONFIG_LOADADDRCONFIG_SYS_LOAD_ADDR
 
diff --git a/include/configs/hsdk.h b/include/configs/hsdk.h
index 94c88b29f1..4755567a2d 100644
--- a/include/configs/hsdk.h
+++ b/include/configs/hsdk.h
@@ -57,8 +57,6 @@
 /*
  * Environment settings
  */
-#define CONFIG_ENV_SIZESZ_16K
-
 #define CONFIG_EXTRA_ENV_SETTINGS \
"upgrade=if mmc rescan && " \
"fatload mmc 0:1 ${loadaddr} u-boot-update.scr && " \
diff --git a/include/configs/iot_devkit.h b/include/configs/iot_devkit.h
index 4ffe1141d9..4b110bb9d8 100644
--- a/include/configs/iot_devkit.h
+++ b/include/configs/iot_devkit.h
@@ -77,7 +77,6 @@
 /*
  * Environment
  */
-#define CONFIG_ENV_SIZESZ_4K
 #define CONFIG_BOOTFILE"app.bin"
 #define CONFIG_LOADADDRCONFIG_SYS_LOAD_ADDR
 
diff --git a/include/configs/nsim.h b/include/configs/nsim.h
index c3f34a91e4..61217bbe79 100644
--- a/include/configs/nsim.h
+++ b/include/configs/nsim.h
@@ -24,12 +24,6 @@
 #define CONFIG_SYS_BOOTM_LEN   SZ_32M
 #define CONFIG_SYS_LOAD_ADDR   0x8200
 
-/*
- * Environment settings
- */
-#define CONFIG_ENV_SIZESZ_512
-#define CONFIG_ENV_OFFSET  0
-
 /*
  * Environment configuration
  */

Re: [U-Boot] [PATCH v3 01/10] Convert CONFIG_BOARD_TYPES to Kconfig

2019-01-16 Thread Alexey Brodkin
Hi Simon,

> -Original Message-
> From: Simon Glass 
> Sent: Saturday, January 12, 2019 4:37 AM
> To: U-Boot Mailing List 
> Cc: Simon Glass ; Lukasz Majewski ; Mario 
> Six ;
> Michal Simek ; Alexey Brodkin 
> ; Eugeniy Paltsev
> ; Jaehoon Chung ; Marek 
> Vasut
> ; Alex Kiernan ; Joe 
> Hershberger
> ; Jörg Krause ; Adam 
> Ford ;
> Stephen Warren ; Angelo Dureghello ; 
> Tuomas Tynkkynen
> ; Eugeniu Rosca 
> Subject: [PATCH v3 01/10] Convert CONFIG_BOARD_TYPES to Kconfig
> 
> This converts the following to Kconfig:
>CONFIG_BOARD_TYPES
> 
> Signed-off-by: Simon Glass 
> Reviewed-by: Lukasz Majewski 
> ---
> 
> Changes in v3: None
> Changes in v2:
> - Remove stranded comments in the header files
> 
>  common/Kconfig   | 8 
>  configs/axs101_defconfig | 1 +
>  configs/axs103_defconfig | 1 +

[snip]

>  include/configs/axs10x.h | 5 -
>  include/configs/hsdk.h   | 5 -

Acked-by: Alexey Brodkin 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] serial: Get rid of CONFIG_DW_SERIAL

2019-01-14 Thread Alexey Brodkin
Hi Simon, Tom,

> -Original Message-
> From: Simon Glass [mailto:s...@chromium.org]
> Sent: Thursday, January 10, 2019 3:57 PM
> To: Alexey Brodkin 
> Cc: U-Boot Mailing List ; uboot-snps-...@synopsys.com; 
> Tom Rini
> ; Adam Ford ; Mario Six 
> ; Tuomas Tynkkynen
> ; Alex Kiernan ; Jörg Krause
> ; Stephen Warren 
> Subject: Re: [PATCH] serial: Get rid of CONFIG_DW_SERIAL
> 
> On Wed, 9 Jan 2019 at 01:28, Alexey Brodkin  
> wrote:
> >
> > CONFIG_DW_SERIAL is no longer used anywhere so let's forget about it.
> >
> > Signed-off-by: Alexey Brodkin 
> > Cc: Tom Rini 
> > Cc: Adam Ford 
> > Cc: Mario Six 
> > Cc: Tuomas Tynkkynen 
> > Cc: Alex Kiernan 
> > Cc: Simon Glass 
> > Cc: "Jörg Krause" 
> > Cc: Stephen Warren 
> > ---
> >  include/configs/axs10x.h | 1 -
> >  include/configs/hsdk.h   | 1 -
> >  scripts/config_whitelist.txt | 1 -
> >  3 files changed, 3 deletions(-)
> 
> Reviewed-by: Simon Glass 

Should I apply it to my tree or either of you is
going to pick this one up as it's not strictly
ARC-related change (even though other arches are not affected)?

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v1 3/4] serial: add an of-platdata driver for "snps, dw-apb-uart"

2019-01-11 Thread Alexey Brodkin
Hi Simon,

> -Original Message-
> From: Simon Goldschmidt [mailto:simon.k.r.goldschm...@gmail.com]
> Sent: Friday, January 11, 2019 11:41 AM
> To: Alexey Brodkin 
> Cc: Patrice Chotard ; Simon Glass 
> ; Anup Patel
> ; Lokesh Vutla ; Patrick Delaunay 
> ;
> Marek Vasut ; u-boot@lists.denx.de; Álvaro Fernández 
> Rojas ;
> Ryder Lee ; Vikas Manocha ; 
> Alexander Graf
> ; Weijie Gao ; Marek Vasut 
> 
> Subject: Re: [PATCH v1 3/4] serial: add an of-platdata driver for 
> "snps,dw-apb-uart"
> 
> On Fri, Jan 11, 2019 at 9:33 AM Alexey Brodkin
>  wrote:
> >
> > Hi Simon,
> >
> > [snip]
> >
> > > >> +config DESIGNWARE_SERIAL
> > > >> +  bool "DesignWare UART support"
> > > >> +  depends on DM_SERIAL && SPL_OF_PLATDATA
> > > >
> > > > Might be a bit naïve question but why depend on SPL_OF_PLATDATA only?
> > > > What about CONFIG_OF_EMBED?
> >
> > Ok I completely forgot that standard ns16550 driver already covers DW APB 
> > UART,
> > see 
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__elixir.bootlin.com_u-
> 2Dboot_latest_source_drivers_serial_ns16550.c-
> 23L456=DwIFaQ=DPL6_X_6JkXFx7AXWqB0tg=lqdeeSSEes0GFDDl656eViXO7breS55ytWkhpk5R81I=wyhoU5_3rGv5y
> 373_cpetmUHK9_ALMCC29QnKS2As5k=uMDuaOZ__YoyqakveKqByAtb1lfRQBYktcVgGH3oawE=
> >
> > > > I'd happily switch my ARC boards on this driver and get rid of all
> > > > CONFIG_SYS_NS16550_xxx nonsense in include/configs/myboardname.h
> > >
> > > I checked include/configs/socfpga_common.h again and by its using
> > > Kconfig and DM_SERIAL, there are no CONFIG_SYS_NS16550_xxx defines left
> > > (other than CONFIG_SYS_NS16550_SERIAL, which I will remove).
> >
> > So it's not that easy apparently :)
> > At least CONFIG_SYS_NS16550_MEM32 is still used really required
> > for getting correct accessor used, see implementation of
> > serial_{in|out}_shift() in drivers/serial/ns16550.c.
> >
> > If CONFIG_SYS_NS16550_MEM32 is not set then simple readb() is used so
> > that 8-bit data offset in 32-bit word is lost and we're dead in the water.
> 
> Isn't that covered by 'plat->reg_shift' which is read from dts property
> "reg-shift = <2>"?

Well actually CONFIG_SYS_NS16550_MEM32 is an alias to "reg-io-width = <4>"
which selects exactly accessor (right as CONFIG_SYS_NS16550_MEM32 in
serial_{in|out}_shift()). But even though we do read "reg-io-width"
from .dtb it is not used in the driver. It was added by Andy Shevchenko
recently, see 
http://git.denx.de/?p=u-boot.git;a=commit;h=4e7207791c05b3ecff916c1b1b1b21401ec29b0b

BTW as I may see some SoCFPGA configs do mention this define:
-->8-
# git grep CONFIG_SYS_NS16550_MEM32 | grep socfpga
include/configs/socfpga_arria10_socdk.h:33:#define CONFIG_SYS_NS16550_MEM32
include/configs/socfpga_stratix10_socdk.h:146:#define CONFIG_SYS_NS16550_MEM32
-->8-

as well as this DT property:
-->8-
# git grep reg-io-width | grep socfpga
arch/arm/dts/socfpga.dtsi:877:  reg-io-width = <4>;
arch/arm/dts/socfpga.dtsi:889:  reg-io-width = <4>;
arch/arm/dts/socfpga_arria10.dtsi:829:  reg-io-width = <4>;
arch/arm/dts/socfpga_arria10.dtsi:840:  reg-io-width = <4>;
arch/arm/dts/socfpga_stratix10.dtsi:252:reg-io-width = 
<4>;
arch/arm/dts/socfpga_stratix10.dtsi:265:reg-io-width = 
<4>;
arch/arm/dts/socfpga_stratix10.dtsi:314:reg-io-width = 
<4>;
arch/arm/dts/socfpga_stratix10.dtsi:326:reg-io-width = 
<4>;
-->8-

So I guess you may experiment with it a bit.

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v1 3/4] serial: add an of-platdata driver for "snps, dw-apb-uart"

2019-01-11 Thread Alexey Brodkin
Hi Simon,

[snip]

> >> +config DESIGNWARE_SERIAL
> >> +  bool "DesignWare UART support"
> >> +  depends on DM_SERIAL && SPL_OF_PLATDATA
> >
> > Might be a bit naïve question but why depend on SPL_OF_PLATDATA only?
> > What about CONFIG_OF_EMBED?

Ok I completely forgot that standard ns16550 driver already covers DW APB UART,
see 
https://elixir.bootlin.com/u-boot/latest/source/drivers/serial/ns16550.c#L456

> > I'd happily switch my ARC boards on this driver and get rid of all
> > CONFIG_SYS_NS16550_xxx nonsense in include/configs/myboardname.h
> 
> I checked include/configs/socfpga_common.h again and by its using
> Kconfig and DM_SERIAL, there are no CONFIG_SYS_NS16550_xxx defines left
> (other than CONFIG_SYS_NS16550_SERIAL, which I will remove).

So it's not that easy apparently :)
At least CONFIG_SYS_NS16550_MEM32 is still used really required
for getting correct accessor used, see implementation of
serial_{in|out}_shift() in drivers/serial/ns16550.c.

If CONFIG_SYS_NS16550_MEM32 is not set then simple readb() is used so
that 8-bit data offset in 32-bit word is lost and we're dead in the water.

That said accessors in ns16550 are begging for significant rework to make
the driver completely OF-driven.

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v1 3/4] serial: add an of-platdata driver for "snps, dw-apb-uart"

2019-01-09 Thread Alexey Brodkin
Hi Simon,

> -Original Message-
> From: Simon Goldschmidt [mailto:simon.k.r.goldschm...@gmail.com]
> Sent: Tuesday, January 8, 2019 12:14 AM
> To: Marek Vasut 
> Cc: Simon Goldschmidt ; Patrice Chotard 
> ;
> Simon Glass ; Anup Patel ; Lokesh 
> Vutla ;
> Alexey Brodkin ; Patrick Delaunay 
> ; Marek Vasut
> ; u-boot@lists.denx.de; Álvaro Fernández Rojas 
> ; Ryder Lee
> ; Vikas Manocha ; Alexander 
> Graf ; Weijie
> Gao 
> Subject: [PATCH v1 3/4] serial: add an of-platdata driver for 
> "snps,dw-apb-uart"
> 
> Add a driver for the "snps,dw-apb-uart" used in socfpga and others.
> 
> This driver is required to get OF_PLATDATA to work for socfpga.
> It uses the ns16550 driver, converting the platdata from of-platdata
> go the ns16550 format.
> 
> Signed-off-by: Simon Goldschmidt 
> ---
> 
>  drivers/serial/Kconfig | 10 
>  drivers/serial/Makefile|  1 +
>  drivers/serial/serial_dw_apb.c | 42 ++
>  3 files changed, 53 insertions(+)
>  create mode 100644 drivers/serial/serial_dw_apb.c
> 
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> index b7ff2960ab..10addd3309 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -511,6 +511,16 @@ config BCM283X_PL011_SERIAL
> that supports automatic disable, so that it only gets used when
> the UART is actually muxed.
> 
> +config DESIGNWARE_SERIAL
> + bool "DesignWare UART support"
> + depends on DM_SERIAL && SPL_OF_PLATDATA

Might be a bit naïve question but why depend on SPL_OF_PLATDATA only?
What about CONFIG_OF_EMBED?

I'd happily switch my ARC boards on this driver and get rid of all
CONFIG_SYS_NS16550_xxx nonsense in include/configs/myboardname.h

-Alexey

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] serial: Get rid of CONFIG_DW_SERIAL

2019-01-09 Thread Alexey Brodkin
CONFIG_DW_SERIAL is no longer used anywhere so let's forget about it.

Signed-off-by: Alexey Brodkin 
Cc: Tom Rini 
Cc: Adam Ford 
Cc: Mario Six 
Cc: Tuomas Tynkkynen 
Cc: Alex Kiernan 
Cc: Simon Glass 
Cc: "Jörg Krause" 
Cc: Stephen Warren 
---
 include/configs/axs10x.h | 1 -
 include/configs/hsdk.h   | 1 -
 scripts/config_whitelist.txt | 1 -
 3 files changed, 3 deletions(-)

diff --git a/include/configs/axs10x.h b/include/configs/axs10x.h
index 1b2966fd61..9452b06771 100644
--- a/include/configs/axs10x.h
+++ b/include/configs/axs10x.h
@@ -45,7 +45,6 @@
 /*
  * UART configuration
  */
-#define CONFIG_DW_SERIAL
 #define CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_NS16550_CLK 
 #define CONFIG_SYS_NS16550_MEM32
diff --git a/include/configs/hsdk.h b/include/configs/hsdk.h
index cdf4fddd94..94c88b29f1 100644
--- a/include/configs/hsdk.h
+++ b/include/configs/hsdk.h
@@ -40,7 +40,6 @@
 /*
  * UART configuration
  */
-#define CONFIG_DW_SERIAL
 #define CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_NS16550_CLK 
 #define CONFIG_SYS_NS16550_MEM32
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 527050de97..8d381788ca 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -429,7 +429,6 @@ CONFIG_DW_ALTDESCRIPTOR
 CONFIG_DW_AXI_BURST_LEN
 CONFIG_DW_GMAC_DEFAULT_DMA_PBL
 CONFIG_DW_MAC_FORCE_THRESHOLD_MODE
-CONFIG_DW_SERIAL
 CONFIG_DW_UDC
 CONFIG_DW_WDT_BASE
 CONFIG_DW_WDT_CLOCK_KHZ
-- 
2.16.2

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/4] Convert CONFIG_BOARD_TYPES to Kconfig

2018-12-09 Thread Alexey Brodkin
Hi Simon,

On Sun, 2018-12-09 at 18:44 -0700, Simon Glass wrote:
> This converts the following to Kconfig:
>CONFIG_BOARD_TYPES
> 
> Signed-off-by: Simon Glass 
> ---
> 
>  arch/arm/mach-exynos/Kconfig | 8 
>  configs/odroid-xu3_defconfig | 2 +-
>  configs/odroid_defconfig | 2 +-
>  include/configs/axs10x.h | 1 -
>  include/configs/hsdk.h   | 1 -

Please note ARC boards have nothing to do with Samsung Exynos.
They are based on ARC cores and "arch/arm/mach-exynos/Kconfig"
makes no sense for them.

Moreover I'm not sure why CONFIG_BOARD_TYPES is an
Exynos-specific option. That said why don't we move CONFIG_BOARD_TYPES
to the generic Kconfig?

>  include/configs/odroid.h | 1 -
>  include/configs/odroid_xu3.h | 1 -
>  scripts/config_whitelist.txt | 1 -
>  8 files changed, 10 insertions(+), 7 deletions(-)

[snip]

> diff --git a/include/configs/axs10x.h b/include/configs/axs10x.h
> index 1b2966fd612..a1b9e7b21d9 100644
> --- a/include/configs/axs10x.h
> +++ b/include/configs/axs10x.h
> @@ -34,7 +34,6 @@
>  /*
>   * This board might be of different versions so handle it
>   */

There's no reason to keep above comment if "#define" below is gone.

> -#define CONFIG_BOARD_TYPES
>  
>  /*
>   * NAND Flash configuration
> diff --git a/include/configs/hsdk.h b/include/configs/hsdk.h
> index cdf4fddd940..b1af1271777 100644
> --- a/include/configs/hsdk.h
> +++ b/include/configs/hsdk.h
> @@ -35,7 +35,6 @@
>  /*
>   * This board might be of different versions so handle it
>   */

Ditto. But then it turned out in case of HSDK CONFIG_BOARD_TYPES
is just a copy-paste from AXS10x and "gd->board_type" is not used.
That said this hunk is applicable but I may do it myself separately.

> -#define CONFIG_BOARD_TYPES
>  
>  /*
>   * UART configuration

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] travis: Bump ARC tools to arc-2018.09

2018-12-03 Thread Alexey Brodkin
Build tested in Travis, see:
https://travis-ci.org/abrodkin/u-boot/jobs/462808237

Signed-off-by: Alexey Brodkin 
---
 .travis.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a061f02399c0..ed07d817fa47 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -42,7 +42,7 @@ install:
  - ln -s travis-ci /tmp/uboot-test-hooks/py/`hostname`
  # prepare buildman environment
  - echo -e "[toolchain]\nroot = /usr" > ~/.buildman
- - echo -e "arc = /tmp/arc_gnu_2017.09_prebuilt_uclibc_le_archs_linux_install" 
>> ~/.buildman
+ - echo -e "arc = /tmp/arc_gnu_2018.09_prebuilt_uclibc_le_archs_linux_install" 
>> ~/.buildman
  - echo -e "\n[toolchain-alias]\nsh = sh2\n" >> ~/.buildman
  - cat ~/.buildman
  - virtualenv /tmp/venv
@@ -75,8 +75,8 @@ before_script:
   echo -e "\n[toolchain-alias]\nx86 = i386" >> ~/.buildman;
 fi
   - if [[ "${TOOLCHAIN}" == arc ]]; then
-   wget 
https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2017.09-release/arc_gnu_2017.09_prebuilt_uclibc_le_archs_linux_install.tar.gz
 &&
-   tar -C /tmp -xf 
arc_gnu_2017.09_prebuilt_uclibc_le_archs_linux_install.tar.gz;
+   wget 
https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2018.09-release/arc_gnu_2018.09_prebuilt_uclibc_le_archs_linux_install.tar.gz
 &&
+   tar -C /tmp -xf 
arc_gnu_2018.09_prebuilt_uclibc_le_archs_linux_install.tar.gz;
 fi
   - if [[ "${TOOLCHAIN}" == *xtensa* ]]; then
wget 
https://github.com/foss-xtensa/toolchain/releases/download/2018.02/x86_64-2018.02-${TOOLCHAIN}.tar.gz
 &&
-- 
2.19.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 1/5] Kconfig: Migrate BOUNCE_BUFFER

2018-12-03 Thread Alexey Brodkin
Hi Philipp,

On Mon, 2018-12-03 at 13:38 +0100, Philipp Tomsich wrote:
Alexey,

On 03.12.2018, at 13:35, Alexey Brodkin 
mailto:alexey.brod...@synopsys.com>> wrote:
Hi Philipp,

On Mon, 2018-12-03 at 13:32 +0100, Philipp Tomsich wrote:
Alexey,

On 03.12.2018, at 12:17, Alexey Brodkin 
mailto:alexey.brod...@synopsys.com>> wrote:
Hi Philipp,

On Fri, 2018-11-30 at 22:13 +0100, Philipp Tomsich wrote:
The bounce buffer is used by a few drivers (most of the MMC drivers)
to overcome limitations in their respective DMA implementation.

This moves the configuration to Kconfig and makes it user-selectable
(even though it will be a required feature to make those drivers
work): the expected usage is for drivers depending on this to 'select'
it unconditionally from their respective Kconfig (see follow-up
patches).

This commit includes a full migration using moveconfig.py to ensure
that each commit compiles; successive commits will introduce
individual dependencies for drivers and then undo some of the changes
to the defconfig files.

Signed-off-by: Philipp Tomsich 
mailto:philipp.toms...@theobroma-systems.com>>

---

[snip]

diff --git a/common/Kconfig b/common/Kconfig
index 57bd16d..5bbd00a 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -645,6 +645,17 @@ config DISPLAY_BOARDINFO_LATE
  the relocation phase. The board function checkboard() is called to do
  this.

+config BOUNCE_BUFFER
+ bool "Include bounce buffer API"
+ help
+   Some peripherals support DMA from a subset of physically
+   addressable memory only.  To support such peripherals, the
+   bounce buffer API uses a temporary buffer: it copies data
+   to/from DMA regions while managing cache operations.
+
+   A second possible use of bounce buffers is their ability to
+   provide aligned buffers for DMA operations.
+

Here you only add BOUNCE_BUFFER option and yet it is not dependent
on anything, right?

diff --git a/include/configs/axs10x.h b/include/configs/axs10x.h
index 1b2966f..8febe09 100644
--- a/include/configs/axs10x.h
+++ b/include/configs/axs10x.h
@@ -85,6 +85,5 @@
/*
 * Misc utility configuration
 */
-#define CONFIG_BOUNCE_BUFFER

#endif /* _CONFIG_AXS10X_H_ */

...

diff --git a/include/configs/emsdp.h b/include/configs/emsdp.h
index 385d59e..a77f262 100644
--- a/include/configs/emsdp.h
+++ b/include/configs/emsdp.h
@@ -19,7 +19,6 @@
#define CONFIG_SYS_LOAD_ADDR CONFIG_SYS_SDRAM_BASE

/* Required by DW MMC driver */
-#define CONFIG_BOUNCE_BUFFER

/*
 * Environment

...

diff --git a/include/configs/hsdk.h b/include/configs/hsdk.h
index cdf4fdd..bafd8d0 100644
--- a/include/configs/hsdk.h
+++ b/include/configs/hsdk.h
@@ -119,7 +119,6 @@ setenv core_iccm_3 0x6; setenv core_dccm_3 0x6;\0"
/*
 * Misc utility configuration
 */
-#define CONFIG_BOUNCE_BUFFER

/* Cli configuration */
#define CONFIG_SYS_CBSIZE SZ_2K
diff --git a/include/configs/iot_devkit.h b/include/configs/iot_devkit.h
index 4ffe114..1f40d61 100644
--- a/include/configs/iot_devkit.h
+++ b/include/configs/iot_devkit.h
@@ -72,7 +72,6 @@
CONFIG_ENV_SIZE

/* Required by DW MMC driver */
-#define CONFIG_BOUNCE_BUFFER

/*
 * Environment

And here in xxx.h files you unconditionally remove CONFIG_BOUNCE_BUFFER
which breaks MMC on these boards.

I understand that you're fixing that in the subsequent commit but
I'd prefer all changes to be bisectable, i.e. have normally working system
on each and every commit.

Moreover IMHO it doesn't look logical to remove "#define CONFIG_BOUNCE_BUFFER" 
here
while remove comment which is clearly bounded to CONFIG_BOUNCE_BUFFER in the 
next commit.

In this patch, moveconfig has moved the selction this into the respective 
_defconfig files
for the  AXS10x boards.

But still if CONFIG_BOUNCE_BUFFER is gone shouldn't we remove a relevant 
comment as well?


Hm... are you sure axs101_defconfig & axs103_defconfig were updated in this 
patch?
I didn't see them there.

You are right: my ARC toolchain wasn’t configured …
I’ll need to debug my toolchain configs and rerun my moveconfig.

You may want to see how ARC toolchain is retrieved by TravisCI job:
http://git.denx.de/?p=u-boot.git;a=blob;f=.travis.yml#l78

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 1/5] Kconfig: Migrate BOUNCE_BUFFER

2018-12-03 Thread Alexey Brodkin
Hi Philipp,

On Mon, 2018-12-03 at 13:32 +0100, Philipp Tomsich wrote:
Alexey,

On 03.12.2018, at 12:17, Alexey Brodkin 
mailto:alexey.brod...@synopsys.com>> wrote:

Hi Philipp,

On Fri, 2018-11-30 at 22:13 +0100, Philipp Tomsich wrote:
The bounce buffer is used by a few drivers (most of the MMC drivers)
to overcome limitations in their respective DMA implementation.

This moves the configuration to Kconfig and makes it user-selectable
(even though it will be a required feature to make those drivers
work): the expected usage is for drivers depending on this to 'select'
it unconditionally from their respective Kconfig (see follow-up
patches).

This commit includes a full migration using moveconfig.py to ensure
that each commit compiles; successive commits will introduce
individual dependencies for drivers and then undo some of the changes
to the defconfig files.

Signed-off-by: Philipp Tomsich 
mailto:philipp.toms...@theobroma-systems.com>>

---

[snip]

diff --git a/common/Kconfig b/common/Kconfig
index 57bd16d..5bbd00a 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -645,6 +645,17 @@ config DISPLAY_BOARDINFO_LATE
  the relocation phase. The board function checkboard() is called to do
  this.

+config BOUNCE_BUFFER
+ bool "Include bounce buffer API"
+ help
+   Some peripherals support DMA from a subset of physically
+   addressable memory only.  To support such peripherals, the
+   bounce buffer API uses a temporary buffer: it copies data
+   to/from DMA regions while managing cache operations.
+
+   A second possible use of bounce buffers is their ability to
+   provide aligned buffers for DMA operations.
+

Here you only add BOUNCE_BUFFER option and yet it is not dependent
on anything, right?

diff --git a/include/configs/axs10x.h b/include/configs/axs10x.h
index 1b2966f..8febe09 100644
--- a/include/configs/axs10x.h
+++ b/include/configs/axs10x.h
@@ -85,6 +85,5 @@
/*
 * Misc utility configuration
 */
-#define CONFIG_BOUNCE_BUFFER

#endif /* _CONFIG_AXS10X_H_ */

...

diff --git a/include/configs/emsdp.h b/include/configs/emsdp.h
index 385d59e..a77f262 100644
--- a/include/configs/emsdp.h
+++ b/include/configs/emsdp.h
@@ -19,7 +19,6 @@
#define CONFIG_SYS_LOAD_ADDR CONFIG_SYS_SDRAM_BASE

/* Required by DW MMC driver */
-#define CONFIG_BOUNCE_BUFFER

/*
 * Environment

...

diff --git a/include/configs/hsdk.h b/include/configs/hsdk.h
index cdf4fdd..bafd8d0 100644
--- a/include/configs/hsdk.h
+++ b/include/configs/hsdk.h
@@ -119,7 +119,6 @@ setenv core_iccm_3 0x6; setenv core_dccm_3 0x6;\0"
/*
 * Misc utility configuration
 */
-#define CONFIG_BOUNCE_BUFFER

/* Cli configuration */
#define CONFIG_SYS_CBSIZE SZ_2K
diff --git a/include/configs/iot_devkit.h b/include/configs/iot_devkit.h
index 4ffe114..1f40d61 100644
--- a/include/configs/iot_devkit.h
+++ b/include/configs/iot_devkit.h
@@ -72,7 +72,6 @@
CONFIG_ENV_SIZE

/* Required by DW MMC driver */
-#define CONFIG_BOUNCE_BUFFER

/*
 * Environment

And here in xxx.h files you unconditionally remove CONFIG_BOUNCE_BUFFER
which breaks MMC on these boards.

I understand that you're fixing that in the subsequent commit but
I'd prefer all changes to be bisectable, i.e. have normally working system
on each and every commit.

Moreover IMHO it doesn't look logical to remove "#define CONFIG_BOUNCE_BUFFER" 
here
while remove comment which is clearly bounded to CONFIG_BOUNCE_BUFFER in the 
next commit.

In this patch, moveconfig has moved the selction this into the respective 
_defconfig files
for the  AXS10x boards.

Hm... are you sure axs101_defconfig & axs103_defconfig were updated in this 
patch?
I didn't see them there.

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 5/5] arc: select BOUNCE_BUFFER for CMD_NAND on AXS10x

2018-12-03 Thread Alexey Brodkin
Hi Philipp,

On Mon, 2018-12-03 at 13:28 +0100, Philipp Tomsich wrote:
Alexey,

On 03.12.2018, at 12:20, Alexey Brodkin 
mailto:alexey.brod...@synopsys.com>> wrote:
Hi Philipp,

On Fri, 2018-11-30 at 22:13 +0100, Philipp Tomsich wrote:
The NAND driver of AXS10x depends on the availability of the bounce
buffer.  As the NAND driver is gated by CMD_NAND only, we need to
select BOUNCE_BUFFER conditionally (on CMD_NAND) for TARGET_AXS101 and
TARGET_AXS103.

Signed-off-by: Philipp Tomsich 
mailto:philipp.toms...@theobroma-systems.com>>
---

Changes in v3: None
Changes in v2: None

arch/arc/Kconfig | 2 ++
include/configs/axs10x.h | 4 
2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index fa6b344..50369d5 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -146,9 +146,11 @@ config TARGET_NSIM

config TARGET_AXS101
bool "Support Synopsys Designware SDP board AXS101"
+ select BOUNCE_BUFFER if CMD_NAND

config TARGET_AXS103
bool "Support Synopsys Designware SDP board AXS103"
+ select BOUNCE_BUFFER if CMD_NAND

I'd say that more appropriate place is "board/synopsys/axs10x/Kconfig".
Because:
- This is related to the particular board, architecture has nothing to
  do with this
- Only 1 line of change will be required as both boards use the same
  Kconfig file

Happily, if you tell me how I can add a ‘select’ for this config-option in
board/synopsys/axs10x/Kconfig w/o unintended side-effects …
In other words: I failed when I tried to override CMD_NAND in that file.

Ok I see now. We need to have either "bool" or "tristate" Kconfig entry to
specify "select". So we'll need to introduce another hidden variable in
board/synopsys/axs10x/Kconfig to get it working... in that case I think your
initial proposal looks better.

Sorry for the noise then.

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 1/5] Kconfig: Migrate BOUNCE_BUFFER

2018-12-03 Thread Alexey Brodkin
Hi Philipp,

On Fri, 2018-11-30 at 22:13 +0100, Philipp Tomsich wrote:
> The bounce buffer is used by a few drivers (most of the MMC drivers)
> to overcome limitations in their respective DMA implementation.
> 
> This moves the configuration to Kconfig and makes it user-selectable
> (even though it will be a required feature to make those drivers
> work): the expected usage is for drivers depending on this to 'select'
> it unconditionally from their respective Kconfig (see follow-up
> patches).
> 
> This commit includes a full migration using moveconfig.py to ensure
> that each commit compiles; successive commits will introduce
> individual dependencies for drivers and then undo some of the changes
> to the defconfig files.
> 
> Signed-off-by: Philipp Tomsich 
> 
> ---

[snip]

> diff --git a/common/Kconfig b/common/Kconfig
> index 57bd16d..5bbd00a 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -645,6 +645,17 @@ config DISPLAY_BOARDINFO_LATE
> the relocation phase. The board function checkboard() is called to do
> this.
>  
> +config BOUNCE_BUFFER
> + bool "Include bounce buffer API"
> + help
> +   Some peripherals support DMA from a subset of physically
> +   addressable memory only.  To support such peripherals, the
> +   bounce buffer API uses a temporary buffer: it copies data
> +   to/from DMA regions while managing cache operations.
> +
> +   A second possible use of bounce buffers is their ability to
> +   provide aligned buffers for DMA operations.
> +

Here you only add BOUNCE_BUFFER option and yet it is not dependent
on anything, right?

> diff --git a/include/configs/axs10x.h b/include/configs/axs10x.h
> index 1b2966f..8febe09 100644
> --- a/include/configs/axs10x.h
> +++ b/include/configs/axs10x.h
> @@ -85,6 +85,5 @@
>  /*
>   * Misc utility configuration
>   */
> -#define CONFIG_BOUNCE_BUFFER
>  
>  #endif /* _CONFIG_AXS10X_H_ */

...

> diff --git a/include/configs/emsdp.h b/include/configs/emsdp.h
> index 385d59e..a77f262 100644
> --- a/include/configs/emsdp.h
> +++ b/include/configs/emsdp.h
> @@ -19,7 +19,6 @@
>  #define CONFIG_SYS_LOAD_ADDR CONFIG_SYS_SDRAM_BASE
>  
>  /* Required by DW MMC driver */
> -#define CONFIG_BOUNCE_BUFFER
>  
>  /*
>   * Environment

...
 
> diff --git a/include/configs/hsdk.h b/include/configs/hsdk.h
> index cdf4fdd..bafd8d0 100644
> --- a/include/configs/hsdk.h
> +++ b/include/configs/hsdk.h
> @@ -119,7 +119,6 @@ setenv core_iccm_3 0x6; setenv core_dccm_3 0x6;\0"
>  /*
>   * Misc utility configuration
>   */
> -#define CONFIG_BOUNCE_BUFFER
>  
>  /* Cli configuration */
>  #define CONFIG_SYS_CBSIZESZ_2K
> diff --git a/include/configs/iot_devkit.h b/include/configs/iot_devkit.h
> index 4ffe114..1f40d61 100644
> --- a/include/configs/iot_devkit.h
> +++ b/include/configs/iot_devkit.h
> @@ -72,7 +72,6 @@
>   CONFIG_ENV_SIZE
>  
>  /* Required by DW MMC driver */
> -#define CONFIG_BOUNCE_BUFFER
>  
>  /*
>   * Environment

And here in xxx.h files you unconditionally remove CONFIG_BOUNCE_BUFFER
which breaks MMC on these boards.

I understand that you're fixing that in the subsequent commit but
I'd prefer all changes to be bisectable, i.e. have normally working system
on each and every commit.

Moreover IMHO it doesn't look logical to remove "#define CONFIG_BOUNCE_BUFFER" 
here
while remove comment which is clearly bounded to CONFIG_BOUNCE_BUFFER in the 
next commit.

So maybe we need to split this first commit in 3 parts and
squash it with 2, 3 and 4.

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] Please pull ARC changes

2018-12-03 Thread Alexey Brodkin
Hi Tom,

The following changes since commit 952061352acfd24034e6990b6b7d32cded020c0a:

  drivers: rtc: correctly convert seconds to time structure (2018-12-01 
18:03:14 -0500)

are available in the Git repository at:

  git://git.denx.de/u-boot-arc.git tags/arc-updates-for-2019.01-rc1

for you to fetch changes up to 6ef705b1575045f7b63bf011a0774228159715b2:

  arc: devboards: Implement checkboard() (2018-12-03 14:26:53 +0300)


We introduce much better automatic identification of ARC cores.

 1. Try to match found HW features to known ARC core templates
 2. Print CPU frequency for all ARC boards
 3. Add more board-specific info


Alexey Brodkin (6):
  arc: emsdp: Bump RAM size to 16 Mb
  ARC: Improve identification of ARC cores
  arc: Get rid of board-specific print_cpuinfo()
  arc: emsdp: Read real CPU clock value from hardware
  arc: emsdp: Refactor register and bit accesses
  arc: devboards: Implement checkboard()

 arch/arc/include/asm/arcregs.h |  25 +-
 arch/arc/lib/cpu.c | 200 
+++-
---
 board/synopsys/axs10x/axs10x.c |   8 +
 board/synopsys/emsdp/emsdp.c   |  70 
---
 board/synopsys/hsdk/hsdk.c |   8 ++---
 board/synopsys/iot_devkit/iot_devkit.c |  10 --
 include/configs/emsdp.h|   2 +-
 7 files changed, 274 insertions(+), 49 deletions(-)

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 5/5] arc: select BOUNCE_BUFFER for CMD_NAND on AXS10x

2018-12-03 Thread Alexey Brodkin
Hi Philipp,

On Fri, 2018-11-30 at 22:13 +0100, Philipp Tomsich wrote:
> The NAND driver of AXS10x depends on the availability of the bounce
> buffer.  As the NAND driver is gated by CMD_NAND only, we need to
> select BOUNCE_BUFFER conditionally (on CMD_NAND) for TARGET_AXS101 and
> TARGET_AXS103.
> 
> Signed-off-by: Philipp Tomsich 
> ---
> 
> Changes in v3: None
> Changes in v2: None
> 
>  arch/arc/Kconfig | 2 ++
>  include/configs/axs10x.h | 4 
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
> index fa6b344..50369d5 100644
> --- a/arch/arc/Kconfig
> +++ b/arch/arc/Kconfig
> @@ -146,9 +146,11 @@ config TARGET_NSIM
>  
>  config TARGET_AXS101
>   bool "Support Synopsys Designware SDP board AXS101"
> + select BOUNCE_BUFFER if CMD_NAND
>  
>  config TARGET_AXS103
>   bool "Support Synopsys Designware SDP board AXS103"
> + select BOUNCE_BUFFER if CMD_NAND

I'd say that more appropriate place is "board/synopsys/axs10x/Kconfig".
Because:
 - This is related to the particular board, architecture has nothing to
   do with this
 - Only 1 line of change will be required as both boards use the same
   Kconfig file

>  config TARGET_EMSDP
>   bool "Synopsys EM Software Development Platform"
> diff --git a/include/configs/axs10x.h b/include/configs/axs10x.h
> index 8febe09..bd1c902 100644
> --- a/include/configs/axs10x.h
> +++ b/include/configs/axs10x.h
> @@ -82,8 +82,4 @@
>   * Console configuration
>   */
>  
> -/*
> - * Misc utility configuration
> - */
> -
>  #endif /* _CONFIG_AXS10X_H_ */

As already mentioned maybe move it to the patch which moves
the option to Kconfig?

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/6] Kconfig: Migrate BOUNCE_BUFFER

2018-11-30 Thread Alexey Brodkin
Hi Philipp,

> -Original Message-
> From: Philipp Tomsich [mailto:philipp.toms...@theobroma-systems.com]
> Sent: Friday, November 30, 2018 2:40 PM
> To: u-boot@lists.denx.de
> Cc: Tom Rini ; Philipp Tomsich 
> ; Mario Six ;
> Michal Simek ; Simon Glass ; 
> Masahiro Yamada
> ; Alexey Brodkin 
> ; Alex Kiernan ; Eric
> Nelson ; Marek Vasut ; Jörg Krause 
> ; Adam Ford
> ; Stephen Warren ; Angelo Dureghello 
> ; Tuomas Tynkkynen
> ; Eugeniu Rosca 
> Subject: [PATCH 1/6] Kconfig: Migrate BOUNCE_BUFFER
> 
> The bounce buffer is used by a few drivers (most of the MMC drivers)
> to overcome limitations in their respective DMA implementation.
> 
> This moves the configuration to Kconfig and makes it user-selectable
> (even though it will be a required feature to make those drivers
> work): the expected usage is for drivers depending on this to 'select'
> it unconditionally from their respective Kconfig.
> 
> Signed-off-by: Philipp Tomsich 
> 
> ---
> 
>  common/Kconfig   | 8 
>  scripts/config_whitelist.txt | 1 -
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/common/Kconfig b/common/Kconfig
> index 57bd16d..f45e066 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -645,6 +645,14 @@ config DISPLAY_BOARDINFO_LATE
> the relocation phase. The board function checkboard() is called to do
> this.
> 
> +config BOUNCE_BUFFER
> + bool "Include bounce buffer API"
> + help
> +   Some peripherals support DMA from a subset of physically
> +   addressable memory only.  To support such peripherals, the
> +   bounce buffer API uses a temporary buffer: it copies data
> +   to/from DMA regions while managing cache operations.

IIRC I decided to use bounce buffer just to make sure data we pass to the DMA is
properly aligned. Not sure though if that's a valid use-case for it but if it is
IMHO it worth mentioning here in this help message.

-Alexey

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 4/5] arc: emsdp: Refactor register and bit accesses

2018-11-26 Thread Alexey Brodkin
Instead of "base + offset" define all registers right away
and access them later via direct defines.

Generate bit masks with "BIT" macro.

Signed-off-by: Alexey Brodkin 
---
 board/synopsys/emsdp/emsdp.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/board/synopsys/emsdp/emsdp.c b/board/synopsys/emsdp/emsdp.c
index 5ab44353746b..3d05f7a8a5e4 100644
--- a/board/synopsys/emsdp/emsdp.c
+++ b/board/synopsys/emsdp/emsdp.c
@@ -78,31 +78,31 @@ int board_mmc_getcd(struct mmc *mmc)
 }
 
 #define CREG_BASE  0xF0001000
-#define CREG_BOOT_OFFSET   0
-#define CREG_BOOT_WP_OFFSET8
+#define CREG_BOOT  (void *)(CREG_BASE + 0x0FF0)
+#define CREG_IP_SW_RESET   (void *)(CREG_BASE + 0x0FF0)
 
-#define CGU_BASE   0xF000
-#define CGU_IP_SW_RESET0x0FF0
+/* Bits in CREG_BOOT register */
+#define CREG_BOOT_WP_BIT   BIT(8)
 
 void reset_cpu(ulong addr)
 {
-   writel(1, (u32 *)(CGU_BASE + CGU_IP_SW_RESET));
+   writel(1, CREG_IP_SW_RESET);
while (1)
; /* loop forever till reset */
 }
 
 static int do_emsdp_rom(cmd_tbl_t *cmdtp, int flag, int argc, char *const 
argv[])
 {
-   u32 creg_boot = readl((u32 *)(CREG_BASE + CREG_BOOT_OFFSET));
+   u32 creg_boot = readl(CREG_BOOT);
 
if (!strcmp(argv[1], "unlock"))
-   creg_boot &= ~BIT(CREG_BOOT_WP_OFFSET);
+   creg_boot &= ~CREG_BOOT_WP_BIT;
else if (!strcmp(argv[1], "lock"))
-   creg_boot |= BIT(CREG_BOOT_WP_OFFSET);
+   creg_boot |= CREG_BOOT_WP_BIT;
else
return CMD_RET_USAGE;
 
-   writel(creg_boot, (u32 *)(CREG_BASE + CREG_BOOT_OFFSET));
+   writel(creg_boot, CREG_BOOT);
 
return CMD_RET_SUCCESS;
 }
-- 
2.19.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 5/5] arc: devboards: Implement checkboard()

2018-11-26 Thread Alexey Brodkin
This allows us to print nice board name on boot.

Signed-off-by: Alexey Brodkin 
---
 board/synopsys/axs10x/axs10x.c |  8 
 board/synopsys/emsdp/emsdp.c   | 10 ++
 board/synopsys/hsdk/hsdk.c |  6 ++
 3 files changed, 24 insertions(+)

diff --git a/board/synopsys/axs10x/axs10x.c b/board/synopsys/axs10x/axs10x.c
index c95f7af7a768..ffa7c154b544 100644
--- a/board/synopsys/axs10x/axs10x.c
+++ b/board/synopsys/axs10x/axs10x.c
@@ -109,3 +109,11 @@ void smp_kick_all_cpus(void)
writel(cmd, (void __iomem *)AXC003_CREG_CPU_START);
 }
 #endif
+
+int checkboard(void)
+{
+   printf("Board: ARC Software Development Platform AXS%s\n",
+is_isa_arcv2() ? "103" : "101");
+
+   return 0;
+};
diff --git a/board/synopsys/emsdp/emsdp.c b/board/synopsys/emsdp/emsdp.c
index 3d05f7a8a5e4..c0770b58c1f5 100644
--- a/board/synopsys/emsdp/emsdp.c
+++ b/board/synopsys/emsdp/emsdp.c
@@ -80,6 +80,7 @@ int board_mmc_getcd(struct mmc *mmc)
 #define CREG_BASE  0xF0001000
 #define CREG_BOOT  (void *)(CREG_BASE + 0x0FF0)
 #define CREG_IP_SW_RESET   (void *)(CREG_BASE + 0x0FF0)
+#define CREG_IP_VERSION(void *)(CREG_BASE + 0x0FF8)
 
 /* Bits in CREG_BOOT register */
 #define CREG_BOOT_WP_BIT   BIT(8)
@@ -133,3 +134,12 @@ U_BOOT_CMD(
"rom unlock - Unlock non-volatile memory for writing\n"
"emsdp rom lock - Lock non-volatile memory to prevent writing\n"
 );
+
+int checkboard(void)
+{
+   int version = readl(CREG_IP_VERSION);
+
+   printf("Board: ARC EM Software Development Platform v%d.%d\n",
+  (version >> 16) & 0xff, version & 0xff);
+   return 0;
+};
diff --git a/board/synopsys/hsdk/hsdk.c b/board/synopsys/hsdk/hsdk.c
index ff343599b092..8a2c201477c0 100644
--- a/board/synopsys/hsdk/hsdk.c
+++ b/board/synopsys/hsdk/hsdk.c
@@ -1053,3 +1053,9 @@ int board_mmc_init(bd_t *bis)
 
return 0;
 }
+
+int checkboard(void)
+{
+   puts("Board: Synopsys ARC HS Development Kit\n");
+   return 0;
+};
-- 
2.19.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/5] arc: Get rid of board-specific print_cpuinfo()

2018-11-26 Thread Alexey Brodkin
Since we now do advanced CPU identification in
generic ARC code there's no need to have per-board
hardcoded data.

Signed-off-by: Alexey Brodkin 
---
 board/synopsys/hsdk/hsdk.c |  8 
 board/synopsys/iot_devkit/iot_devkit.c | 10 --
 2 files changed, 18 deletions(-)

diff --git a/board/synopsys/hsdk/hsdk.c b/board/synopsys/hsdk/hsdk.c
index b6aefdbe6d6a..ff343599b092 100644
--- a/board/synopsys/hsdk/hsdk.c
+++ b/board/synopsys/hsdk/hsdk.c
@@ -1053,11 +1053,3 @@ int board_mmc_init(bd_t *bis)
 
return 0;
 }
-
-#ifdef CONFIG_DISPLAY_CPUINFO
-int print_cpuinfo(void)
-{
-   printf("CPU:   ARC HS38 v2.1c\n");
-   return 0;
-}
-#endif /* CONFIG_DISPLAY_CPUINFO */
diff --git a/board/synopsys/iot_devkit/iot_devkit.c 
b/board/synopsys/iot_devkit/iot_devkit.c
index f8838fb3ce87..8424e09bd3cf 100644
--- a/board/synopsys/iot_devkit/iot_devkit.c
+++ b/board/synopsys/iot_devkit/iot_devkit.c
@@ -189,13 +189,3 @@ int checkboard(void)
puts("Board: Synopsys IoT Development Kit\n");
return 0;
 };
-
-#ifdef CONFIG_DISPLAY_CPUINFO
-int print_cpuinfo(void)
-{
-   char mhz[8];
-
-   printf("CPU:   ARC EM9D at %s MHz\n", strmhz(mhz, gd->cpu_clk));
-   return 0;
-}
-#endif /* CONFIG_DISPLAY_CPUINFO */
-- 
2.19.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 3/5] arc: emsdp: Read real CPU clock value from hardware

2018-11-26 Thread Alexey Brodkin
We do real CPU clock measurement with help of built-in
counters. Thus we may accommodate different real clock values
that appear in different FPA images instead of relying on
something hard-coded in the .dtb.

And while at it make make SDIO base address define
look similar to others with casting to "(void *)".

Signed-off-by: Alexey Brodkin 
---
 board/synopsys/emsdp/emsdp.c | 42 +---
 1 file changed, 39 insertions(+), 3 deletions(-)

diff --git a/board/synopsys/emsdp/emsdp.c b/board/synopsys/emsdp/emsdp.c
index b5ec7f17ec1b..5ab44353746b 100644
--- a/board/synopsys/emsdp/emsdp.c
+++ b/board/synopsys/emsdp/emsdp.c
@@ -7,10 +7,46 @@
 #include 
 #include 
 
+#include 
+
 DECLARE_GLOBAL_DATA_PTR;
 
-#define ARC_PERIPHERAL_BASE0xF000
-#define SDIO_BASE  (ARC_PERIPHERAL_BASE + 0x1)
+#define ARC_PERIPHERAL_BASE0xF000
+
+#define CGU_ARC_FMEAS_ARC  (void *)(ARC_PERIPHERAL_BASE + 0x84)
+#define CGU_ARC_FMEAS_ARC_STARTBIT(31)
+#define CGU_ARC_FMEAS_ARC_DONE BIT(30)
+#define CGU_ARC_FMEAS_ARC_CNT_MASK GENMASK(14, 0)
+#define CGU_ARC_FMEAS_ARC_RCNT_OFFSET  0
+#define CGU_ARC_FMEAS_ARC_FCNT_OFFSET  15
+
+#define SDIO_BASE  (void *)(ARC_PERIPHERAL_BASE + 0x1)
+
+int mach_cpu_init(void)
+{
+   int rcnt, fcnt;
+   u32 data;
+
+   /* Start frequency measurement */
+   writel(CGU_ARC_FMEAS_ARC_START, CGU_ARC_FMEAS_ARC);
+
+   /* Poll DONE bit */
+   do {
+   data = readl(CGU_ARC_FMEAS_ARC);
+   } while (!(data & CGU_ARC_FMEAS_ARC_DONE));
+
+   /* Amount of reference 100 MHz clocks */
+   rcnt = ((data >> CGU_ARC_FMEAS_ARC_RCNT_OFFSET) &
+  CGU_ARC_FMEAS_ARC_CNT_MASK);
+
+   /* Amount of CPU clocks */
+   fcnt = ((data >> CGU_ARC_FMEAS_ARC_FCNT_OFFSET) &
+  CGU_ARC_FMEAS_ARC_CNT_MASK);
+
+   gd->cpu_clk = ((100 * fcnt) / rcnt) * 100;
+
+   return 0;
+}
 
 int board_mmc_init(bd_t *bis)
 {
@@ -24,7 +60,7 @@ int board_mmc_init(bd_t *bis)
 
memset(host, 0, sizeof(struct dwmci_host));
host->name = "Synopsys Mobile storage";
-   host->ioaddr = (void *)SDIO_BASE;
+   host->ioaddr = SDIO_BASE;
host->buswidth = 4;
host->dev_index = 0;
host->bus_hz = 5000;
-- 
2.19.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/5] ARC: Improve identification of ARC cores

2018-11-26 Thread Alexey Brodkin
1. Try to guess a ARC core template that was used
   i.e. not just name a core family but something more
   menaingful like "ARC HS38", "ARC EM11D" etc.

   We do it checking availability of the key differentiation
   features like:
- Caches (we actually only check for L1 I$ fpr simplicity)
- XY-memory
- DSP extensions etc.

2. Identify ARC subsystems

3. Print core clock frequency

Signed-off-by: Alexey Brodkin 
---
 arch/arc/include/asm/arcregs.h |  25 -
 arch/arc/lib/cpu.c | 200 +
 2 files changed, 204 insertions(+), 21 deletions(-)

diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h
index 9920d2e71952..fff6591c681d 100644
--- a/arch/arc/include/asm/arcregs.h
+++ b/arch/arc/include/asm/arcregs.h
@@ -16,6 +16,20 @@
  * access: "lr"/"sr".
  */
 
+/*
+ * Typically 8 least significant bits of Build Configuration Register (BCR)
+ * describe version of the HW block in question. Moreover if decoded version
+ * is 0 this means given HW block is absent - this is especially useful because
+ * we may safely read BRC regardless HW block existence while an attempt to
+ * access any other AUX regs associated with this HW block lead to imediate
+ * "instruction error" exception.
+ *
+ * I.e. before using any cofigurable HW block it's required to make sure it
+ * exists at all, and for that we introduce a special macro below.
+ */
+#define ARC_BCR_VERSION_MASK   GENMASK(7, 0)
+#define ARC_FEATURE_EXISTS(bcr)!!(__builtin_arc_lr(bcr) & 
ARC_BCR_VERSION_MASK)
+
 #define ARC_AUX_IDENTITY   0x04
 #define ARC_AUX_STATUS32   0x0a
 
@@ -73,7 +87,7 @@
 #define ARC_BCR_CLUSTER0xcf
 
 /* MMU Management regs */
-#define ARC_AUX_MMU_BCR0x06f
+#define ARC_AUX_MMU_BCR0x6f
 
 /* IO coherency related auxiliary registers */
 #define ARC_AUX_IO_COH_ENABLE  0x500
@@ -81,6 +95,15 @@
 #define ARC_AUX_IO_COH_AP0_BASE0x508
 #define ARC_AUX_IO_COH_AP0_SIZE0x509
 
+/* XY-memory related */
+#define ARC_AUX_XY_BUILD   0x79
+
+/* DSP-extensions related auxiliary registers */
+#define ARC_AUX_DSP_BUILD  0x7A
+
+/* ARC Subsystems related auxiliary registers */
+#define ARC_AUX_SUBSYS_BUILD   0xF0
+
 #ifndef __ASSEMBLY__
 /* Accessors for auxiliary registers */
 #define read_aux_reg(reg)  __builtin_arc_lr(reg)
diff --git a/arch/arc/lib/cpu.c b/arch/arc/lib/cpu.c
index a969a167228d..07daaa8d1551 100644
--- a/arch/arc/lib/cpu.c
+++ b/arch/arc/lib/cpu.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
@@ -35,34 +36,193 @@ int dram_init(void)
 }
 
 #ifdef CONFIG_DISPLAY_CPUINFO
-const char *decode_identity(void)
+const char *arc_700_version(int arcver, char *name, int name_len)
 {
-   int arcver = read_aux_reg(ARC_AUX_IDENTITY) & 0xff;
+   const char *arc_ver;
+
+   switch (arcver) {
+   case 0x32:
+   arc_ver = "v4.4-4.5";
+   break;
+   case 0x33:
+   arc_ver = "v4.6-v4.9";
+   break;
+   case 0x34:
+   arc_ver = "v4.10";
+   break;
+   case 0x35:
+   arc_ver = "v4.11";
+   break;
+   default:
+   arc_ver = "unknown version";
+   }
+
+   snprintf(name, name_len, "ARC 700 %s", arc_ver);
+
+   return name;
+}
+
+struct em_template_t {
+   const bool cache;
+   const bool dsp;
+   const bool xymem;
+   const char name[8];
+};
+
+static const struct em_template_t em_versions[] = {
+   {false, false,  false,  "EM4"},
+   {true,  false,  false,  "EM6"},
+   {false, true,   false,  "EM5D"},
+   {true,  true,   false,  "EM7D"},
+   {false, true,   true,   "EM9D"},
+   {true,  true,   true,   "EM11D"},
+};
+
+const char *arc_em_version(int arcver, char *name, int name_len)
+{
+   const char *arc_name = "EM";
+   const char *arc_ver;
+   bool cache = ARC_FEATURE_EXISTS(ARC_BCR_IC_BUILD);
+   bool dsp = ARC_FEATURE_EXISTS(ARC_AUX_DSP_BUILD);
+   bool xymem = ARC_FEATURE_EXISTS(ARC_AUX_XY_BUILD);
+   int i;
+
+   for (i = 0; i++ < sizeof(em_versions) / sizeof(struct em_template_t);) {
+   if (em_versions[i].cache == cache &&
+   em_versions[i].dsp == dsp &&
+   em_versions[i].xymem == xymem) {
+   arc_name = em_versions[i].name;
+   break;
+   }
+   }
+
+   switch (arcver) {
+   case 0x41:
+   arc_ver = "v1.1a";
+   break;
+   case 0x42:
+   arc_ver = "v3.0";
+   break;
+   case 0x43:
+   arc_ver = "v4.0";
+   break;
+   case 0

[U-Boot] [PATCH 0/5] Improve identification of ARC cores

2018-11-26 Thread Alexey Brodkin
Print more complex information about ARC core we're running on.
This includes smarts for ARC core template detection,
CPU clock frequency, human-readable board·description etc.

Alexey Brodkin (5):
  ARC: Improve identification of ARC cores
  arc: Get rid of board-specific print_cpuinfo()
  arc: emsdp: Read real CPU clock value from hardware
  arc: emsdp: Refactor register and bit accesses
  arc: devboards: Implement checkboard()

 arch/arc/include/asm/arcregs.h |  25 +++-
 arch/arc/lib/cpu.c | 200 ++---
 board/synopsys/axs10x/axs10x.c |   8 +
 board/synopsys/emsdp/emsdp.c   |  70 +++--
 board/synopsys/hsdk/hsdk.c |   8 +-
 board/synopsys/iot_devkit/iot_devkit.c |  10 --
 6 files changed, 273 insertions(+), 48 deletions(-)

-- 
2.19.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] arc: emsdp: Bump RAM size to 16 Mb

2018-11-26 Thread Alexey Brodkin
On v2 boards that will hit real stock we'll have 16 Mb of RAM.

Note on v1 boards (if anybody ever get one out of trash bin)
this leads to U-Boot execution freeze in the middle ofthe relocation
so don't be surprised.

Signed-off-by: Alexey Brodkin 
---
 include/configs/emsdp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/emsdp.h b/include/configs/emsdp.h
index 385d59e33875..9a205edc7c0d 100644
--- a/include/configs/emsdp.h
+++ b/include/configs/emsdp.h
@@ -11,7 +11,7 @@
 #define CONFIG_SYS_MONITOR_BASECONFIG_SYS_TEXT_BASE
 
 #define CONFIG_SYS_SDRAM_BASE  0x1000
-#define CONFIG_SYS_SDRAM_SIZE  SZ_8M
+#define CONFIG_SYS_SDRAM_SIZE  SZ_16M
 
 #define CONFIG_SYS_INIT_SP_ADDR(CONFIG_SYS_SDRAM_BASE + SZ_1M)
 
-- 
2.19.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] Please pull ARC changes

2018-11-01 Thread Alexey Brodkin
Hi Tom,

The following changes since commit fdaccfeb5e03e18c05be386b8a7c6be02be2cf15:

  Merge branch 'master' of git://git.denx.de/u-boot-socfpga (2018-10-31 
17:15:55 -0400)

are available in the Git repository at:

  git://git.denx.de/u-boot-arc.git tags/arc-for-2018.11

for you to fetch changes up to a6b8c29fb8fce8f063a4709ce0df3f862b316b95:

  iot_dk: Add README (2018-11-01 23:04:05 +0300)


Just 2 non-functinal changes:

 1. Rename of EMDK to EMSDP so it matches real marketing name
 2. Add essential README for IoTDK


Alexey Brodkin (2):
  emdk->emsdp: Rename board
  iot_dk: Add README

 arch/arc/Kconfig  |   6 +++---
 arch/arc/dts/Makefile |   2 +-
 arch/arc/dts/{emdk.dts => emsdp.dts}  |   2 +-
 board/synopsys/{emdk => emsdp}/Kconfig|   6 +++---
 board/synopsys/{emdk => emsdp}/MAINTAINERS|   5 +++--
 board/synopsys/{emdk => emsdp}/Makefile   |   2 +-
 board/synopsys/{emdk => emsdp}/README |  11 ++-
 board/synopsys/{emdk/emdk.c => emsdp/emsdp.c} |  18 +-
 board/synopsys/iot_devkit/README  | 145 
+
 configs/{emdk_defconfig => emsdp_defconfig}   |   6 +++---
 include/configs/{emdk.h => emsdp.h}   |  10 +-
 11 files changed, 180 insertions(+), 33 deletions(-)
 rename arch/arc/dts/{emdk.dts => emsdp.dts} (96%)
 rename board/synopsys/{emdk => emsdp}/Kconfig (63%)
 rename board/synopsys/{emdk => emsdp}/MAINTAINERS (50%)
 rename board/synopsys/{emdk => emsdp}/Makefile (85%)
 rename board/synopsys/{emdk => emsdp}/README (90%)
 rename board/synopsys/{emdk/emdk.c => emsdp/emsdp.c} (77%)
 create mode 100644 board/synopsys/iot_devkit/README
 rename configs/{emdk_defconfig => emsdp_defconfig} (88%)
 rename include/configs/{emdk.h => emsdp.h} (85%)

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] iot_dk: Add README

2018-10-31 Thread Alexey Brodkin
Signed-off-by: Alexey Brodkin 
---
 board/synopsys/iot_devkit/README | 145 +++
 1 file changed, 145 insertions(+)
 create mode 100644 board/synopsys/iot_devkit/README

diff --git a/board/synopsys/iot_devkit/README b/board/synopsys/iot_devkit/README
new file mode 100644
index ..20c140d93cd3
--- /dev/null
+++ b/board/synopsys/iot_devkit/README
@@ -0,0 +1,145 @@
+
+Useful notes on bulding and using of U-Boot on
+ARC IoT Development Kit (AKA IoTDK)
+
+
+   BOARD OVERVIEW
+
+   The DesignWare ARC IoT Development Kit is a versatile platform that includes
+   the necessary hardware and software to accelerate software development and
+   debugging of sensor fusion, voice recognition and face detection designs.
+
+   The ARC IoT Development Kit includes a silicon implementation of the
+   ARC Data Fusion IP Subsystem running at 144 MHz on SMIC's
+   55-nm ultra-low power process, and a rich set of peripherals commonly used
+   in IoT designs such as USB, UART, SPI, I2C, PWM, SDIO and ADCs.
+
+   The board is shipped with pre-installed U-Boot in non-volatile memory
+   (eFlash) so on power-on user sees U-Boot start header and command line
+   prompt which might be used for U-Boot environment fine-tuning, manual
+   loading and execution of user application binaries etc.
+
+   The board has the following features useful for U-Boot:
+* On-board 2-channel FTDI TTL-to-USB converter
+  - The first channel is used for serial debug port (which makes it 
possible
+to use a serial connection on pretty much any host machine be it
+Windows, Linux or Mac).
+On Linux machine typucally FTDI serial port would be /dev/ttyUSB0.
+There's no HW flow-control and baud-rate is 115200.
+
+  - The second channel is used for built-in Digilent USB JTAG probe.
+That means no extra hardware is required to access ARC core from a
+debugger on development host. Both proprietary MetaWare debugger and
+open source OpenOCD + GDB client are supported.
+
+  - Also with help of this FTDI chip it is possible to reset entire
+board with help of a special `rff-ftdi-reset` utility, see:
+https://github.com/foss-for-synopsys-dwc-arc-processors/rff-ftdi-reset
+
+* Micro SD-card slot
+  - U-Boot expects to see the very first partition on the card formatted as
+FAT file-system and uses it for keeping its environment in `uboot.env`
+file. Note uboot.env is not just a text file but it is auto-generated
+file created by U-Boot on invocation of `saveenv` command.
+It contains a checksum which makes this saved environment invalid in
+case of maual modification.
+
+  - There might be more useful files on that first FAT partition like
+user applications, data files etc.
+
+* USB OTG connector
+  - U-Boot may access USB mass-storage devices attached to this connector.
+Note only FAT file-system is supported. It might be used for storing
+user application binaries as well as micro SD-card mentioned above.
+
+* The following memories are avaialble on the board:
+  - eFlash:256 KiB @ 0x_
+A non-volatile memory from which ARC core may execute code directly.
+Still is is not direcly writable, thus this is not an ordinary RAM.
+
+  - ICCM:  256 KiB @ 0x2000_
+Instruction Closely Coupled Memory - fast on-chip memory primary used
+for code being executed, still data could be placed in this memory too.
+In that sense it's just a general purpose RAM.
+
+  - SRAM:  128 KiB @ 0x3000_
+On-chip SRAM. From user perspective is the same as ICCM above.
+
+  - DCCM:  128 KiB @ 0x8000_
+Data Closely Coupled Memory is similar to ICCM with a major difference 
-
+ARC core cannot execute code from DCCM. So this is very special RAM
+only suitable for data.
+
+   BUILDING U-BOOT
+
+   1. Configure U-Boot:
+  ->8--
+  make iot_devkit_defconfig
+  ->8--
+
+   2. To build Elf file (for example to be used with host debugger via JTAG
+  connection to the target board):
+  ->8--
+  make mdbtrick
+  ->8--
+
+  This will produce `u-boot` Elf file.
+
+   3. To build binary image to be put in "ROM":
+  ->8--
+  make u-boot.bin
+  ->8--
+
+
+   EXECUTING U-BOOT
+
+   1. The IoTDK board is supposed to auto-start U-Boot image stored in eFlash 
on
+  power-on. Note it's possible t

  1   2   3   4   5   6   7   8   >