[PATCH 2/2] test: unit test for longjmp

2021-03-21 Thread Heinrich Schuchardt
Provide a unit test for the longjmp() library function

Signed-off-by: Heinrich Schuchardt 
---
 test/lib/Makefile  |  1 +
 test/lib/longjmp.c | 44 
 2 files changed, 45 insertions(+)
 create mode 100644 test/lib/longjmp.c

diff --git a/test/lib/Makefile b/test/lib/Makefile
index 97c11e35a8..a30f615aa9 100644
--- a/test/lib/Makefile
+++ b/test/lib/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_EFI_LOADER) += efi_device_path.o
 obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o
 obj-y += hexdump.o
 obj-y += lmb.o
+obj-y += longjmp.o
 obj-$(CONFIG_CONSOLE_RECORD) += test_print.o
 obj-$(CONFIG_SSCANF) += sscanf.o
 obj-y += string.o
diff --git a/test/lib/longjmp.c b/test/lib/longjmp.c
new file mode 100644
index 00..7571540ffc
--- /dev/null
+++ b/test/lib/longjmp.c
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test setjmp(), longjmp()
+ *
+ * Copyright (c) 2021, Heinrich Schuchardt 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/**
+ * test_longjmp_ret() - get longjmp() return value
+ *
+ * @i: value passed to longjmp()
+ * Return: value returned by longjmp()
+ */
+int test_longjmp_ret(int i)
+{
+   jmp_buf env;
+   int ret;
+
+   ret = setjmp(env);
+   if (ret)
+   return ret;
+   longjmp(env, i);
+   /* We should not arrive here */
+   return 0x1000;
+}
+
+static int lib_test_longjmp(struct unit_test_state *uts)
+{
+   int i;
+
+   for (i = -3; i < 0; ++i)
+   ut_asserteq(i, test_longjmp_ret(i));
+   ut_asserteq(1, test_longjmp_ret(0));
+   for (i = 1; i < 4; ++i)
+   ut_asserteq(i, test_longjmp_ret(i));
+   return 0;
+}
+LIB_TEST(lib_test_longjmp, 0);
--
2.30.2



[PATCH 1/2] riscv: simply longjmp

2021-03-21 Thread Heinrich Schuchardt
The value returned by setjmp must be nonzero. If zero is passed as
parameter it must be replaced by 1.

This patch reduces the code size a bit.

Signed-off-by: Heinrich Schuchardt 
---
 arch/riscv/lib/setjmp.S | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/riscv/lib/setjmp.S b/arch/riscv/lib/setjmp.S
index 72bc9241f6..99d6195827 100644
--- a/arch/riscv/lib/setjmp.S
+++ b/arch/riscv/lib/setjmp.S
@@ -54,12 +54,8 @@ ENTRY(longjmp)
LOAD_IDX(sp, 13)

/* Move the return value in place, but return 1 if passed 0. */
-   beq a1, zero, longjmp_1
-   mv a0, a1
-   ret
-
-   longjmp_1:
-   li a0, 1
+   seqz a0, a1
+   add a0, a0, a1
ret
 ENDPROC(longjmp)
 .popsection
--
2.30.2



[PATCH 0/2] riscv: simply longjmp()

2021-03-21 Thread Heinrich Schuchardt
The implementation of longjmp() is simplified.
A unit test for longjmp() is provided.

For testing use

CONFIG_UNIT_TEST=y
CONFIG_CMD_SETEXPR=n

and execute

ut lib

Heinrich Schuchardt (2):
  riscv: simply longjmp
  test: unit test for longjmp

 arch/riscv/lib/setjmp.S |  8 ++--
 test/lib/Makefile   |  1 +
 test/lib/longjmp.c  | 45 +
 3 files changed, 48 insertions(+), 6 deletions(-)
 create mode 100644 test/lib/longjmp.c

--
2.30.2



Re: Help needed with uboot for CHIP

2021-03-21 Thread Gunjan Gupta
I figured out the why SPL was not loading U-Boot from NAND.

Apparently the logic to use PIO instead of DMA that was introduced in
6ddbb1e936c78cdef1e7395039fa7020c5c75326

may
be was not as generic as it was supposed to be. I tried adding hexdump in
nand_read_page and found that on CHIP the logic was not reading and real
data. Instead all of the bytes were set to 0s.

I have created a patch to provide an option to use the older version of
nand_read_page function that was present just before the above mentioned
commit.

With the attached patches and some config changes the Upstream U-Boot works
fine on CHIP. I have tested the attached patches on CHIP with 8GB Hynix
nand along with the following extra configurations.

CONFIG_MTD=y
CONFIG_CMD_MTD=y
CONFIG_CMD_MTDPARTS=y
CONFIG_MTDIDS_DEFAULT="nand0=sunxi-nand.0"
CONFIG_MTDPARTS_DEFAULT="mtdparts=sunxi-nand.0:4m(spl),4m(spl-backup),4m(uboot),4m(env),-(yaffs2)"
CONFIG_MTD_RAW_NAND=y
CONFIG_SYS_NAND_BLOCK_SIZE=0x40
CONFIG_SYS_NAND_PAGE_SIZE=0x4000
CONFIG_SYS_NAND_OOBSIZE=0x680
CONFIG_ENV_IS_IN_NAND=y
CONFIG_ENV_SIZE=0x40
CONFIG_ENV_OFFSET=0xc0
CONFIG_FASTBOOT_FLASH_NAND=y
CONFIG_YAFFS2=y

@Andre will it be possible to get the attached patches merged into the
U-Boot?

Thanks & Regards
Gunjan Gupta

On Thu, Mar 18, 2021 at 1:25 AM Gunjan Gupta  wrote:

> Its not really like uboot is not working. Just spl fails to load it from
> nand. I tried replacing the 2021.01 spl with the original spl of chip's
> firmware(based on uboot 2016.01) and it loaded the 2021.01 u-boot
> correctly.
>
> On Thu, Mar 18, 2021, 1:20 AM Alexandre GRIVEAUX 
> wrote:
>
>> Hello,
>> Le 10/03/2021 à 19:58, Gunjan Gupta a écrit :
>>
>> PFA my dts file. I have added the nfc section there as without that U-Boot
>> was giving a message about nfc being disabled in the dts.
>>
>> Regarding trying the default config, I can't really do that as that doesn't
>> support booting from NAND and I want to be able to boot from NAND. Also I
>> don't think having different MTDPARTS value should create an issue, as I
>> didn't notice that being used in the SPL code. Please feel free to correct
>> me if I am wrong. Even if it was being used, I am flashing U-Boot to the
>> uboot partition and that is the same location that gets populated in
>> the CONFIG_SYS_NAND_U_BOOT_OFFS variable of the .config file.
>>
>>
>>
>>
>>
>> I've tried with a CHIP, same problem, the SPL work main u-boot not.
>>
>> I don't think it's a defconfig limitation, sadly i don't know how this
>> can be corrected.
>>
>>
>> Thanks.
>>
>
From 513117e4b4b96dc6985fc32452c2818e786cdf8f Mon Sep 17 00:00:00 2001
From: Gunjan Gupta 
Date: Sun, 21 Mar 2021 19:06:53 +0530
Subject: [PATCH 1/2] The generic PIO based nand_read_page function was not
 working on R8 based C.H.I.P. The SPL was failing to read the U-Boot correctly
 from nand. When I used hexdump, I found that all the U-Boot pages that SPL
 read was containing zero. The previous DMA based logic however worked fine.

This commit provides the option of using the legacy nand_read_page
function that was present removed in the following commit:-

https://github.com/u-boot/u-boot/commit/6ddbb1e936c78cdef1e7395039fa7020c5c75326
---
 drivers/mtd/nand/raw/Kconfig  |  5 ++
 drivers/mtd/nand/raw/sunxi_nand_spl.c | 91 +++
 2 files changed, 96 insertions(+)

diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index ed151ee0a5..1b985d9465 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -219,6 +219,11 @@ config NAND_SUNXI
 
 if NAND_SUNXI
 
+config NAND_SUNXI_SPL_LEGACY_DMA_READ_PAGE
+	bool "Use legacy DMA based read page logic instead of using PIO"
+	default ARCH_SUNXI
+	depends on MACH_SUN4I || MACH_SUN5I
+
 config NAND_SUNXI_SPL_ECC_STRENGTH
 	int "Allwinner NAND SPL ECC Strength"
 	default 64
diff --git a/drivers/mtd/nand/raw/sunxi_nand_spl.c b/drivers/mtd/nand/raw/sunxi_nand_spl.c
index 85d8013b1a..7df9bae5f2 100644
--- a/drivers/mtd/nand/raw/sunxi_nand_spl.c
+++ b/drivers/mtd/nand/raw/sunxi_nand_spl.c
@@ -84,6 +84,24 @@
 #define NFC_CMD_RNDOUT 0x05
 #define NFC_CMD_READSTART  0x30
 
+#ifdef CONFIG_NAND_SUNXI_SPL_LEGACY_DMA_READ_PAGE
+#define SUNXI_DMA_CFG_REG0  0x300
+#define SUNXI_DMA_SRC_START_ADDR_REG0   0x304
+#define SUNXI_DMA_DEST_START_ADDRR_REG0 0x308
+#define SUNXI_DMA_DDMA_BC_REG0  0x30C
+#define SUNXI_DMA_DDMA_PARA_REG00x318
+
+#define SUNXI_DMA_DDMA_CFG_REG_LOADING  (1 << 31)
+#define SUNXI_DMA_DDMA_CFG_REG_DMA_DEST_DATA_WIDTH_32 (2 << 25)
+#define SUNXI_DMA_DDMA_CFG_REG_DDMA_DST_DRQ_TYPE_DRAM (1 << 16)
+#define SUNXI_DMA_DDMA_CFG_REG_DMA_SRC_DATA_WIDTH_32 (2 << 9)
+#define SUNXI_DMA_DDMA_CFG_REG_DMA_SRC_ADDR_MODE_IO (1 << 5)
+#define SUNXI_DMA_DDMA_CFG_REG_DDMA_SRC_DRQ_TYPE_NFC (3 << 0)
+
+#define SUNXI_DMA_DDMA_PARA_REG_SRC_WAIT_CYC (0x0F << 0)
+#define SUNXI_DMA_DDM

Re: Please pull u-boot-dm/next take 2

2021-03-21 Thread Tom Rini
On Sun, Mar 21, 2021 at 03:36:41PM +1300, Simon Glass wrote:

> Hi Tom,
> 
> This is for the -next branch
> 
> https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/6849
> 
> 
> The following changes since commit f879f2621b42529cf5f88912a07d2866cfc8fd45:
> 
>   Merge branch 'next' of git://source.denx.de/u-boot-sh into next
> (2021-03-19 08:20:34 -0400)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-dm.git tags/dm-pull-21mar21-take2
> 
> for you to fetch changes up to 72f2592b113815039000e9b295a2ea6f2e9d4f2f:
> 
>   binman: Update various pieces of the documentation (2021-03-21 14:30:48 
> +1300)
> 

NAK, a few problems:
https://dev.azure.com/u-boot/u-boot/_build/results?buildId=2007&view=logs&j=f73ea7a0-90af-58b6-2b50-3c4e0acf30bb&t=9b3bb8b5-bfd3-5873-17a4-61c874b0d974
fails because previously "-w board_name" worked but now requires "-w
--board board_name" to work (which is why GitLab passed, it does -w
--board sandbox_spl").
https://source.denx.de/u-boot/u-boot/-/jobs/241881
and I don't know why that failed as it builds locally.  Maybe some odd
race?

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/2] of: addr: Abort address translation for parent nodes missing 'ranges'

2021-03-21 Thread Dario Binacchi
Hi Tom,

> Il 18/03/2021 20:51 Tom Rini  ha scritto:
> 
>  
> On Thu, Mar 18, 2021 at 08:27:49AM +0100, Dario Binacchi wrote:
> > Hi Bin,
> > 
> > > Il 17/03/2021 02:26 Bin Meng  ha scritto:
> > > 
> > >  
> > > Hi Dario,
> > > 
> > > On Wed, Mar 17, 2021 at 4:57 AM Dario Binacchi  wrote:
> > > >
> > > > Hi Bin,
> > > >
> > > > > Il 16/03/2021 02:28 Bin Meng  ha scritto:
> > > > >
> > > > >
> > > > > Hi Dario,
> > > > >
> > > > > On Tue, Mar 16, 2021 at 6:49 AM Dario Binacchi  
> > > > > wrote:
> > > > > >
> > > > > >
> > > > > > > Il 15/03/2021 19:23 Simon Glass  ha scritto:
> > > > > > >
> > > > > > >
> > > > > > > +Tom Rini too
> > > > > > >
> > > > > > >
> > > > > > > On Tue, 16 Mar 2021 at 03:48, Bin Meng  wrote:
> > > > > > > >
> > > > > > > > +Dario Binacchi
> > > > > > > >
> > > > > > > > On Mon, Mar 15, 2021 at 3:11 PM Simon Glass  
> > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > Hi Bin,
> > > > > > > > >
> > > > > > > > > On Wed, 3 Mar 2021 at 14:54, Simon Glass  
> > > > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > On Fri, 26 Feb 2021 at 00:36, Bin Meng  
> > > > > > > > > > wrote:
> > > > > > > > > > >
> > > > > > > > > > > The implementation of of_translate_one() was taken from 
> > > > > > > > > > > the one in
> > > > > > > > > > > Linux kernel drivers/of/address.c, and the Linux one 
> > > > > > > > > > > added a quirk
> > > > > > > > > > > for Apple Macs that don't have the  property in 
> > > > > > > > > > > the parent
> > > > > > > > > > > node. Since U-Boot does not support Apple Macs, remove 
> > > > > > > > > > > the comment
> > > > > > > > > > > block and adhere to the spec to abort the translation.
> > > > > > > > > > >
> > > > > > > > > > > Signed-off-by: Bin Meng 
> > > > > > > > > > > ---
> > > > > > > > > > >
> > > > > > > > > > >  drivers/core/of_addr.c | 24 ++--
> > > > > > > > > > >  1 file changed, 6 insertions(+), 18 deletions(-)
> > > > > > > > > >
> > > > > > > > > > Reviewed-by: Simon Glass 
> > > > > > > > >
> > > > > > > > > Unfortunately this seems to cause a test failure for
> > > > > > > > > ut_dm_fdt_translation. Can you please take a look?
> > > > > > > >
> > > > > > > > It seems the no "ranges" property was intentionally removed by 
> > > > > > > > the
> > > > > > > > following commit:
> > > > > > > >
> > > > > > > > commit d64b9cdcd475eb7f07b49741ded87e24dae4a5fc
> > > > > > > > Author: Dario Binacchi 
> > > > > > > > Date:   Wed Dec 30 00:16:21 2020 +0100
> > > > > > > >
> > > > > > > > fdt: translate address if #size-cells = <0>
> > > > > > > >
> > > > > > > > The __of_translate_address routine translates an address 
> > > > > > > > from the
> > > > > > > > device tree into a CPU physical address. A note in the 
> > > > > > > > description of
> > > > > > > > the routine explains that the crossing of any level with
> > > > > > > > since inherited from IBM. This does not happen for Texas 
> > > > > > > > Instruments, or
> > > > > > > > at least for the beaglebone device tree. Without this 
> > > > > > > > patch, in fact,
> > > > > > > > the translation into physical addresses of the registers 
> > > > > > > > contained in the
> > > > > > > > am33xx-clocks.dtsi nodes would not be possible. They all 
> > > > > > > > have a parent
> > > > > > > > with #size-cells = <0>.
> > > > > > > >
> > > > > > > > It looks the commit was needed for beaglebone board.
> > > > > > > >
> > > > > > > > Dario, could you please comment on why U-Boot needs to done 
> > > > > > > > like this,
> > > > > > > > while Linux kernel has this check? Is the beaglebone board not 
> > > > > > > > working
> > > > > > > > in Linux?
> > > > > > > >
> > > > > >
> > > > > > Beaglebone is working in Linux, but I think Linux walks the device 
> > > > > > tree less
> > > > > > fully than u-boot.
> > > > > > I was surprised by the address translation error when traversing 
> > > > > > nodes with
> > > > > > size cells 0. And for this reason I added the 
> > > > > > CONFIG_OF_TRANSLATE_ZERO_SIZE_CELLS
> > > > > > symbol to fix the issue, not enabled by default, thus making the 
> > > > > > change backwards
> > > > > > compatible.
> > > > >
> > > > > Could you please prepare a patch against upstream Linux kernel, so
> > > > > that U-Boot can be in sync with it?
> > > >
> > > > With pleasure. But how do I justify the patch since it doesn't fix any 
> > > > bugs?
> > > > Can I refer to the patches developed for U-boot?
> > > 
> > > Good question :)
> > > 
> > > If Linux does not have any issue, maybe U-Boot's fix is questionable?
> > > 
> > > Maybe the beagleboard needs to use another API to decode the address?
> > > What API is used in Linux?
> > 
> > I'll do some checking, although I think the Linux device binding / probing 
> > flow 
> > is more complex than u-boot.
> 
> I guess at the high level, we need to understand what's going on here
> and why.  With the whole "dt describes hardware", it shouldn't matter so
> much how Linux

Re: [PATCH 0/6] Use -ENOSYS consistently

2021-03-21 Thread Tom Rini
On Sun, Mar 21, 2021 at 04:18:18PM +1300, Simon Glass wrote:

> A few places use -ENOTSUPP when they should use -ENOSYS. In two cases both
> are used. This little series tidies this up.
> 
> 
> Simon Glass (6):
>   usb: Return -ENOSYS when system call is not available
>   spi: Return -ENOSYS when system call is not available
>   tlv_eeprom: Return -ENOSYS when system call is not available
>   clk: Return -ENOSYS when system call is not available
>   simple-pm-bus: Use -ENOSYS for checking missing system call
>   pinctrl: Return -ENOSYS when system call is not available
> 
>  drivers/clk/clk-composite.c |  8 
>  drivers/core/simple-pm-bus.c|  4 ++--
>  drivers/pinctrl/pinctrl-uclass.c| 10 ++
>  drivers/usb/gadget/udc/udc-uclass.c |  2 +-
>  include/spi-mem.h   |  2 +-
>  include/tlv_eeprom.h|  6 +++---
>  6 files changed, 17 insertions(+), 15 deletions(-)

I think we need to start this series with a doc update that makes it
clear why this is correct and when it should be used.   There's two
instances of "ENOSYS" in doc/driver-model/ today and neither explains
why this series is correct (which I'm sure it is).  Thanks.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/6] usb: Return -ENOSYS when system call is not available

2021-03-21 Thread Marek Vasut

On 3/21/21 5:12 AM, Simon Glass wrote:

Hi Marek,

On Sun, 21 Mar 2021 at 17:09, Marek Vasut  wrote:


On 3/21/21 4:18 AM, Simon Glass wrote:

Update usb_gadget_release() to use -ENOSYS, which is the correct error
code for U-Boot.


It would be good if you could explain _why_ this change is required. Why
is ENOSYS the correct return value ? It is not clear from the patch
description, sorry.


That is the value used throughout driver model, so it is a convention.
As per the cover letter and one on the patches, people are not sure
which one to use, because -ENOTSUPP has crept in in a few places.


I agree with Tom, this needs to be documented first, then the document 
should be agreed upon, and only then should these fixes follow.


[PATCH] azure: Use --board flag with sandbox_spl

2021-03-21 Thread Simon Glass
At present there is only one board which uses sandbox SPL. But with
sandbox_noinst being added, this is no longer true. Add a --board flag
so that we just build one board on azure, as is done in gitlab.

Signed-off-by: Simon Glass 
---

 .azure-pipelines.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 2d0b9cb469a..ec2f2609973 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -148,7 +148,7 @@ jobs:
   export UBOOT_TRAVIS_BUILD_DIR=/tmp/sandbox_spl
   export PYTHONPATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt
   export PATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}
-  ./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w 
sandbox_spl
+  ./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w 
--board sandbox_spl
   ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test
   ./tools/buildman/buildman -t
   ./tools/dtoc/dtoc -t
-- 
2.31.0.rc2.261.g7f71774620-goog



Re: [PATCH] azure: Use --board flag with sandbox_spl

2021-03-21 Thread Tom Rini
On Mon, Mar 22, 2021 at 08:22:53AM +1300, Simon Glass wrote:

> At present there is only one board which uses sandbox SPL. But with
> sandbox_noinst being added, this is no longer true. Add a --board flag
> so that we just build one board on azure, as is done in gitlab.
> 
> Signed-off-by: Simon Glass 

Ah, so that's why.

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 14/26] power: pca9450: add a new parameter for power_pca9450_init

2021-03-21 Thread Jaehoon Chung
On 3/19/21 4:57 PM, Peng Fan (OSS) wrote:
> From: Peng Fan 
> 
> Currently PCA9450 might have address 0x25 or 0x35, so let user
> choose the address.
> 
> Signed-off-by: Peng Fan 

Reviewed-by: Jaehoon Chung 

Best Regards,
Jaehoon Chung

> ---
>  board/freescale/imx8mp_evk/spl.c  | 2 +-
>  board/phytec/phycore_imx8mp/spl.c | 2 +-
>  drivers/power/pmic/pmic_pca9450.c | 4 ++--
>  include/power/pca9450.h   | 2 +-
>  4 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/board/freescale/imx8mp_evk/spl.c 
> b/board/freescale/imx8mp_evk/spl.c
> index 6ccf5ac8fa..a7564e9b1a 100644
> --- a/board/freescale/imx8mp_evk/spl.c
> +++ b/board/freescale/imx8mp_evk/spl.c
> @@ -70,7 +70,7 @@ int power_init_board(void)
>   struct pmic *p;
>   int ret;
>  
> - ret = power_pca9450_init(I2C_PMIC);
> + ret = power_pca9450_init(I2C_PMIC, 0x25);
>   if (ret)
>   printf("power init failed");
>   p = pmic_get("PCA9450");
> diff --git a/board/phytec/phycore_imx8mp/spl.c 
> b/board/phytec/phycore_imx8mp/spl.c
> index eefdd7fdda..f9fa8d1e12 100644
> --- a/board/phytec/phycore_imx8mp/spl.c
> +++ b/board/phytec/phycore_imx8mp/spl.c
> @@ -53,7 +53,7 @@ int power_init_board(void)
>   struct pmic *p;
>   int ret;
>  
> - ret = power_pca9450_init(0);
> + ret = power_pca9450_init(0, 0x25);
>   if (ret)
>   printf("power init failed");
>   p = pmic_get("PCA9450");
> diff --git a/drivers/power/pmic/pmic_pca9450.c 
> b/drivers/power/pmic/pmic_pca9450.c
> index d4f27428bd..8c4d0a9230 100644
> --- a/drivers/power/pmic/pmic_pca9450.c
> +++ b/drivers/power/pmic/pmic_pca9450.c
> @@ -11,7 +11,7 @@
>  
>  static const char pca9450_name[] = "PCA9450";
>  
> -int power_pca9450_init(unsigned char bus)
> +int power_pca9450_init(unsigned char bus, unsigned char addr)
>  {
>   struct pmic *p = pmic_alloc();
>  
> @@ -23,7 +23,7 @@ int power_pca9450_init(unsigned char bus)
>   p->name = pca9450_name;
>   p->interface = PMIC_I2C;
>   p->number_of_regs = PCA9450_REG_NUM;
> - p->hw.i2c.addr = 0x25;
> + p->hw.i2c.addr = addr;
>   p->hw.i2c.tx_num = 1;
>   p->bus = bus;
>  
> diff --git a/include/power/pca9450.h b/include/power/pca9450.h
> index 5a9a697d62..27703bb1f9 100644
> --- a/include/power/pca9450.h
> +++ b/include/power/pca9450.h
> @@ -54,6 +54,6 @@ enum {
>   PCA9450_REG_NUM,
>  };
>  
> -int power_pca9450_init(unsigned char bus);
> +int power_pca9450_init(unsigned char bus, unsigned char addr);
>  
>  #endif
> 



Re: [ANN] U-Boot v2021.04-rc4 released

2021-03-21 Thread Trevor Woerner
On Wed 2021-03-17 @ 10:37:18 AM, Fabio Estevam wrote:
> On Wed, Mar 17, 2021 at 10:22 AM Trevor Woerner  wrote:
> > However, I am interested in preserving the olimex board (i.e.
> > configs/mx23_olinuxino_defconfig). So I could take a look at that one first
> > unless, Marek, you would like to take a look?
> 
> I have recently converted imx23-evk to DM, so hopefully, the imx23
> olinuxino transition will be smooth too:
> https://source.denx.de/u-boot/u-boot/-/commit/23013aa9619881290dbeb6217f1fab863869050e
> 
> I don't have the imx23 olinuxino board handy, but let us know if you
> face any issues in the DM conversion.

Fabio: your imx23-evk patch provided an excellent example for me to follow, 
thanks!

Tom: I have the MMC conversion to DM completed and tested for the Olimex
Olinuxino board. But this board is still missing DM conversions for USB and
ETH. Should I go ahead and send in just the MMC conversion to save it from the
immediate chopping block, or would you rather wait until I've at least had a
chance to look at the USB and ETH conversions in order to send all of them
together in one patch set?

Best regards,
Trevor


Re: [PATCH v4 2/2] x86: coral: Show memory config and SKU ID on startup

2021-03-21 Thread Bin Meng
Hi Simon,

On Sun, Mar 21, 2021 at 11:51 AM Simon Glass  wrote:
>
> Hi Bin,
>
> On Mon, 15 Mar 2021 at 18:30, Simon Glass  wrote:
> >
> > Hi Bin,
> >
> > On Tue, 9 Mar 2021 at 15:34, Bin Meng  wrote:
> > >
> > > Hi Simon,
> > >
> > > On Sun, Feb 7, 2021 at 12:13 AM Simon Glass  wrote:
> > > >
> > > > Provide the model information through sysinfo so that it shows up on
> > > > boot. For memconfig 4 pins are provided, for 16 combinations. For SKU
> > > > ID there are two options:
> > > >
> > > >- two pins provided in a ternary arrangement, for 9 combinations.
> > > >- reading from the EC
> > > >
> > > > Add a binding doc and drop the unused #defines as well.
> > > >
> > > > Example:
> > > >
> > > >U-Boot 2021.01-rc5
> > > >
> > > >CPU:   Intel(R) Celeron(R) CPU N3450 @ 1.10GHz
> > > >DRAM:  3.9 GiB
> > > >MMC:   sdmmc@1b,0: 1, emmc@1c,0: 2
> > > >Video: 1024x768x32 @ b000
> > > >Model: Google Coral (memconfig 5, SKU 3)
> > > >
> > > > This depends on the GPIO series:
> > > >
> > > >http://patchwork.ozlabs.org/project/uboot/list/?series=228126
> > >
> > > It looks this series is applied as patchwork returns nothing?
> > >
> > > But the CI still fails
> > > https://source.denx.de/u-boot/custodians/u-boot-x86/-/jobs/235619
> >
> > Can you apply it to u-boot-x86/next perhaps? The GPIO series was
> > applied to -next, not -master.
>
> I've sent a new version, v5, which should apply on the U-Boot -next
> branch. Are you keeping a -next for x86? If not I am happy to apply it
> via dm.

No, I did not track u-boot/next in the x86 repo. Feel free to apply
this series via dm.

Regards,
Bin


Re: [PATCH 1/2] of: addr: Abort address translation for parent nodes missing 'ranges'

2021-03-21 Thread Bin Meng
Hi Dario,

On Sun, Mar 21, 2021 at 11:19 PM Dario Binacchi  wrote:
>
> Hi Tom,
>
> > Il 18/03/2021 20:51 Tom Rini  ha scritto:
> >
> >
> > On Thu, Mar 18, 2021 at 08:27:49AM +0100, Dario Binacchi wrote:
> > > Hi Bin,
> > >
> > > > Il 17/03/2021 02:26 Bin Meng  ha scritto:
> > > >
> > > >
> > > > Hi Dario,
> > > >
> > > > On Wed, Mar 17, 2021 at 4:57 AM Dario Binacchi  
> > > > wrote:
> > > > >
> > > > > Hi Bin,
> > > > >
> > > > > > Il 16/03/2021 02:28 Bin Meng  ha scritto:
> > > > > >
> > > > > >
> > > > > > Hi Dario,
> > > > > >
> > > > > > On Tue, Mar 16, 2021 at 6:49 AM Dario Binacchi  
> > > > > > wrote:
> > > > > > >
> > > > > > >
> > > > > > > > Il 15/03/2021 19:23 Simon Glass  ha scritto:
> > > > > > > >
> > > > > > > >
> > > > > > > > +Tom Rini too
> > > > > > > >
> > > > > > > >
> > > > > > > > On Tue, 16 Mar 2021 at 03:48, Bin Meng  
> > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > +Dario Binacchi
> > > > > > > > >
> > > > > > > > > On Mon, Mar 15, 2021 at 3:11 PM Simon Glass 
> > > > > > > > >  wrote:
> > > > > > > > > >
> > > > > > > > > > Hi Bin,
> > > > > > > > > >
> > > > > > > > > > On Wed, 3 Mar 2021 at 14:54, Simon Glass 
> > > > > > > > > >  wrote:
> > > > > > > > > > >
> > > > > > > > > > > On Fri, 26 Feb 2021 at 00:36, Bin Meng 
> > > > > > > > > > >  wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > The implementation of of_translate_one() was taken from 
> > > > > > > > > > > > the one in
> > > > > > > > > > > > Linux kernel drivers/of/address.c, and the Linux one 
> > > > > > > > > > > > added a quirk
> > > > > > > > > > > > for Apple Macs that don't have the  property in 
> > > > > > > > > > > > the parent
> > > > > > > > > > > > node. Since U-Boot does not support Apple Macs, remove 
> > > > > > > > > > > > the comment
> > > > > > > > > > > > block and adhere to the spec to abort the translation.
> > > > > > > > > > > >
> > > > > > > > > > > > Signed-off-by: Bin Meng 
> > > > > > > > > > > > ---
> > > > > > > > > > > >
> > > > > > > > > > > >  drivers/core/of_addr.c | 24 ++--
> > > > > > > > > > > >  1 file changed, 6 insertions(+), 18 deletions(-)
> > > > > > > > > > >
> > > > > > > > > > > Reviewed-by: Simon Glass 
> > > > > > > > > >
> > > > > > > > > > Unfortunately this seems to cause a test failure for
> > > > > > > > > > ut_dm_fdt_translation. Can you please take a look?
> > > > > > > > >
> > > > > > > > > It seems the no "ranges" property was intentionally removed 
> > > > > > > > > by the
> > > > > > > > > following commit:
> > > > > > > > >
> > > > > > > > > commit d64b9cdcd475eb7f07b49741ded87e24dae4a5fc
> > > > > > > > > Author: Dario Binacchi 
> > > > > > > > > Date:   Wed Dec 30 00:16:21 2020 +0100
> > > > > > > > >
> > > > > > > > > fdt: translate address if #size-cells = <0>
> > > > > > > > >
> > > > > > > > > The __of_translate_address routine translates an address 
> > > > > > > > > from the
> > > > > > > > > device tree into a CPU physical address. A note in the 
> > > > > > > > > description of
> > > > > > > > > the routine explains that the crossing of any level with
> > > > > > > > > since inherited from IBM. This does not happen for Texas 
> > > > > > > > > Instruments, or
> > > > > > > > > at least for the beaglebone device tree. Without this 
> > > > > > > > > patch, in fact,
> > > > > > > > > the translation into physical addresses of the registers 
> > > > > > > > > contained in the
> > > > > > > > > am33xx-clocks.dtsi nodes would not be possible. They all 
> > > > > > > > > have a parent
> > > > > > > > > with #size-cells = <0>.
> > > > > > > > >
> > > > > > > > > It looks the commit was needed for beaglebone board.
> > > > > > > > >
> > > > > > > > > Dario, could you please comment on why U-Boot needs to done 
> > > > > > > > > like this,
> > > > > > > > > while Linux kernel has this check? Is the beaglebone board 
> > > > > > > > > not working
> > > > > > > > > in Linux?
> > > > > > > > >
> > > > > > >
> > > > > > > Beaglebone is working in Linux, but I think Linux walks the 
> > > > > > > device tree less
> > > > > > > fully than u-boot.
> > > > > > > I was surprised by the address translation error when traversing 
> > > > > > > nodes with
> > > > > > > size cells 0. And for this reason I added the 
> > > > > > > CONFIG_OF_TRANSLATE_ZERO_SIZE_CELLS
> > > > > > > symbol to fix the issue, not enabled by default, thus making the 
> > > > > > > change backwards
> > > > > > > compatible.
> > > > > >
> > > > > > Could you please prepare a patch against upstream Linux kernel, so
> > > > > > that U-Boot can be in sync with it?
> > > > >
> > > > > With pleasure. But how do I justify the patch since it doesn't fix 
> > > > > any bugs?
> > > > > Can I refer to the patches developed for U-boot?
> > > >
> > > > Good question :)
> > > >
> > > > If Linux does not have any issue, maybe U-Boot's fix is questionable?
> > > >
> > > > Maybe the beagleboard needs to use another API to decode the add

Re: [ANN] U-Boot v2021.04-rc4 released

2021-03-21 Thread Tom Rini
On Sun, Mar 21, 2021 at 09:09:46PM -0400, Trevor Woerner wrote:
> On Wed 2021-03-17 @ 10:37:18 AM, Fabio Estevam wrote:
> > On Wed, Mar 17, 2021 at 10:22 AM Trevor Woerner  wrote:
> > > However, I am interested in preserving the olimex board (i.e.
> > > configs/mx23_olinuxino_defconfig). So I could take a look at that one 
> > > first
> > > unless, Marek, you would like to take a look?
> > 
> > I have recently converted imx23-evk to DM, so hopefully, the imx23
> > olinuxino transition will be smooth too:
> > https://source.denx.de/u-boot/u-boot/-/commit/23013aa9619881290dbeb6217f1fab863869050e
> > 
> > I don't have the imx23 olinuxino board handy, but let us know if you
> > face any issues in the DM conversion.
> 
> Fabio: your imx23-evk patch provided an excellent example for me to follow, 
> thanks!
> 
> Tom: I have the MMC conversion to DM completed and tested for the Olimex
> Olinuxino board. But this board is still missing DM conversions for USB and
> ETH. Should I go ahead and send in just the MMC conversion to save it from the
> immediate chopping block, or would you rather wait until I've at least had a
> chance to look at the USB and ETH conversions in order to send all of them
> together in one patch set?

Immediate needs please, thanks.  Due note that USB will have it back on
the chopping block quickly, so to speak :)

-- 
Tom


signature.asc
Description: PGP signature


[PATCH 1/2] mx23_olinuxino: enable device tree

2021-03-21 Thread Trevor Woerner
Add the dts file for the Olimex Olinuxino from the linux kernel, and enable
its use in this machine's defconfig.

Signed-off-by: Trevor Woerner 
---
 arch/arm/dts/Makefile|   3 +
 arch/arm/dts/imx23-olinuxino.dts | 131 +++
 configs/mx23_olinuxino_defconfig |   3 +-
 3 files changed, 136 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/imx23-olinuxino.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index c6710826a0..d5cffc90d4 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -651,6 +651,9 @@ dtb-$(CONFIG_VF610) += vf500-colibri.dtb \
 dtb-$(CONFIG_MX23) += \
imx23-evk.dtb
 
+dtb-$(CONFIG_TARGET_MX23_OLINUXINO) += \
+   imx23-olinuxino.dtb
+
 dtb-$(CONFIG_MX28) += \
imx28-xea.dtb
 
diff --git a/arch/arm/dts/imx23-olinuxino.dts b/arch/arm/dts/imx23-olinuxino.dts
new file mode 100644
index 00..0729e72f22
--- /dev/null
+++ b/arch/arm/dts/imx23-olinuxino.dts
@@ -0,0 +1,131 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * Author: Fabio Estevam 
+ */
+
+/dts-v1/;
+#include 
+#include "imx23.dtsi"
+
+/ {
+   model = "i.MX23 Olinuxino Low Cost Board";
+   compatible = "olimex,imx23-olinuxino", "fsl,imx23";
+
+   memory@4000 {
+   device_type = "memory";
+   reg = <0x4000 0x0400>;
+   };
+
+   apb@8000 {
+   apbh@8000 {
+   ssp0: spi@8001 {
+   compatible = "fsl,imx23-mmc";
+   pinctrl-names = "default";
+   pinctrl-0 = <&mmc0_4bit_pins_a &mmc0_sck_cfg>;
+   bus-width = <4>;
+   broken-cd;
+   status = "okay";
+   };
+
+   pinctrl@80018000 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&hog_pins_a>;
+
+   hog_pins_a: hog@0 {
+   reg = <0>;
+   fsl,pinmux-ids = <
+   MX23_PAD_GPMI_ALE__GPIO_0_17
+   >;
+   fsl,drive-strength = ;
+   fsl,voltage = ;
+   fsl,pull-up = ;
+   };
+
+   led_pin_gpio2_1: led_gpio2_1@0 {
+   reg = <0>;
+   fsl,pinmux-ids = <
+   MX23_PAD_SSP1_DETECT__GPIO_2_1
+   >;
+   fsl,drive-strength = ;
+   fsl,voltage = ;
+   fsl,pull-up = ;
+   };
+   };
+
+   ssp1: spi@80034000 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "fsl,imx23-spi";
+   pinctrl-names = "default";
+   pinctrl-0 = <&spi2_pins_a>;
+   status = "okay";
+   };
+   };
+
+   apbx@8004 {
+   lradc@8005 {
+   status = "okay";
+   };
+
+   i2c: i2c@80058000 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c_pins_b>;
+   status = "okay";
+   };
+
+   duart: serial@8007 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&duart_pins_a>;
+   status = "okay";
+   };
+
+   auart0: serial@8006c000 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&auart0_2pins_a>;
+   status = "okay";
+   };
+
+   usbphy0: usbphy@8007c000 {
+   status = "okay";
+   };
+   };
+   };
+
+   ahb@8008 {
+   usb0: usb@8008 {
+   dr_mode = "host";
+   vbus-supply = <®_usb0_vbus>;
+   status = "okay";
+   };
+   };
+
+   regulators {
+   compatible = "simple-bus";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   reg_usb0_vbus: regulator@0 {
+   

[PATCH 2/2] mx23_olinuxino: convert MMC to driver model

2021-03-21 Thread Trevor Woerner
Convert the Olimex Olinuxino board's support for MMC to driver model
following Fabio Estevam's excellent example from:

commit: 23013aa9619881290dbeb6217f1fab863869050e:
mx23evk: Convert to driver model

Signed-off-by: Trevor Woerner 
---
 arch/arm/dts/imx23-olinuxino.dts |  1 +
 board/olimex/mx23_olinuxino/mx23_olinuxino.c | 12 
 configs/mx23_olinuxino_defconfig |  4 +++-
 3 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/arch/arm/dts/imx23-olinuxino.dts b/arch/arm/dts/imx23-olinuxino.dts
index 0729e72f22..ce368d44a0 100644
--- a/arch/arm/dts/imx23-olinuxino.dts
+++ b/arch/arm/dts/imx23-olinuxino.dts
@@ -26,6 +26,7 @@
pinctrl-0 = <&mmc0_4bit_pins_a &mmc0_sck_cfg>;
bus-width = <4>;
broken-cd;
+   non-removable;
status = "okay";
};
 
diff --git a/board/olimex/mx23_olinuxino/mx23_olinuxino.c 
b/board/olimex/mx23_olinuxino/mx23_olinuxino.c
index d1e189cbb6..bdd5fcd76a 100644
--- a/board/olimex/mx23_olinuxino/mx23_olinuxino.c
+++ b/board/olimex/mx23_olinuxino/mx23_olinuxino.c
@@ -57,18 +57,6 @@ int dram_init(void)
return mxs_dram_init();
 }
 
-#ifdef CONFIG_CMD_MMC
-static int mx23_olx_mmc_cd(int id)
-{
-   return 1;   /* Card always present */
-}
-
-int board_mmc_init(struct bd_info *bis)
-{
-   return mxsmmc_initialize(bis, 0, NULL, mx23_olx_mmc_cd);
-}
-#endif
-
 int board_init(void)
 {
/* Adress of boot parameters */
diff --git a/configs/mx23_olinuxino_defconfig b/configs/mx23_olinuxino_defconfig
index 2bf6818ee3..680611cd01 100644
--- a/configs/mx23_olinuxino_defconfig
+++ b/configs/mx23_olinuxino_defconfig
@@ -12,6 +12,7 @@ CONFIG_TARGET_MX23_OLINUXINO=y
 CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL=y
 CONFIG_DEFAULT_DEVICE_TREE="imx23-olinuxino"
+# CONFIG_SYS_MALLOC_F is not set
 CONFIG_BOOTDELAY=3
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_ARCH_MISC_INIT=y
@@ -30,6 +31,7 @@ CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_VERSION_VARIABLE=y
+CONFIG_DM=y
 CONFIG_MXS_GPIO=y
 CONFIG_LED_STATUS=y
 CONFIG_LED_STATUS_GPIO=y
@@ -39,10 +41,10 @@ CONFIG_LED_STATUS_STATE=2
 CONFIG_LED_STATUS_BOOT_ENABLE=y
 CONFIG_LED_STATUS_BOOT=0
 CONFIG_LED_STATUS_CMD=y
+CONFIG_DM_MMC=y
 CONFIG_MMC_MXS=y
 CONFIG_CONS_INDEX=0
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
-CONFIG_USB_STORAGE=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_SMSC95XX=y
-- 
2.30.0.rc0



Re: [ANN] U-Boot v2021.04-rc4 released

2021-03-21 Thread Trevor Woerner
On Sun 2021-03-21 @ 09:28:21 PM, Tom Rini wrote:
> On Sun, Mar 21, 2021 at 09:09:46PM -0400, Trevor Woerner wrote:
> > On Wed 2021-03-17 @ 10:37:18 AM, Fabio Estevam wrote:
> > > On Wed, Mar 17, 2021 at 10:22 AM Trevor Woerner  
> > > wrote:
> > > > However, I am interested in preserving the olimex board (i.e.
> > > > configs/mx23_olinuxino_defconfig). So I could take a look at that one 
> > > > first
> > > > unless, Marek, you would like to take a look?
> > > 
> > > I have recently converted imx23-evk to DM, so hopefully, the imx23
> > > olinuxino transition will be smooth too:
> > > https://source.denx.de/u-boot/u-boot/-/commit/23013aa9619881290dbeb6217f1fab863869050e
> > > 
> > > I don't have the imx23 olinuxino board handy, but let us know if you
> > > face any issues in the DM conversion.
> > 
> > Fabio: your imx23-evk patch provided an excellent example for me to follow, 
> > thanks!
> > 
> > Tom: I have the MMC conversion to DM completed and tested for the Olimex
> > Olinuxino board. But this board is still missing DM conversions for USB and
> > ETH. Should I go ahead and send in just the MMC conversion to save it from 
> > the
> > immediate chopping block, or would you rather wait until I've at least had a
> > chance to look at the USB and ETH conversions in order to send all of them
> > together in one patch set?
> 
> Immediate needs please, thanks.  Due note that USB will have it back on
> the chopping block quickly, so to speak :)

Okay, sent:

https://patchwork.ozlabs.org/project/uboot/patch/20210322013454.13782-1-twoer...@gmail.com/
https://patchwork.ozlabs.org/project/uboot/patch/20210322013454.13782-2-twoer...@gmail.com/


RE: [PATCH] imx8mn_ddr4_evk: Allow booting the kernel by default

2021-03-21 Thread Peng Fan
> Subject: [PATCH] imx8mn_ddr4_evk: Allow booting the kernel by default
> 
> Currently it is not possible to boot Linux from the SD card by default.
> 
> Make the necessary adjustments to allow it.
> 
> Reported-by: Peter Bergin 
> Signed-off-by: Fabio Estevam 
> ---
>  configs/imx8mn_ddr4_evk_defconfig | 1 +
>  include/configs/imx8mn_evk.h  | 4 ++--
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/configs/imx8mn_ddr4_evk_defconfig
> b/configs/imx8mn_ddr4_evk_defconfig
> index f7ea65886d51..2c12bdabe0a0 100644
> --- a/configs/imx8mn_ddr4_evk_defconfig
> +++ b/configs/imx8mn_ddr4_evk_defconfig
> @@ -54,6 +54,7 @@ CONFIG_SPL_OF_CONTROL=y
> CONFIG_ENV_OVERWRITE=y  CONFIG_ENV_IS_IN_MMC=y
> CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> +CONFIG_SYS_MMC_ENV_DEV=1
>  CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
>  CONFIG_SPL_DM=y
>  CONFIG_SPL_CLK_COMPOSITE_CCF=y
> diff --git a/include/configs/imx8mn_evk.h b/include/configs/imx8mn_evk.h
> index 1e2825337e2d..596e255ca6de 100644
> --- a/include/configs/imx8mn_evk.h
> +++ b/include/configs/imx8mn_evk.h
> @@ -34,10 +34,10 @@
>  /* Initial environment variables */
>  #define CONFIG_EXTRA_ENV_SETTINGS\
>   "script=boot.scr\0" \
> - "image=Image.itb\0" \
> + "image=Image\0" \
>   "console=ttymxc1,115200\0" \
>   "fdt_addr=0x4300\0" \
> - "boot_fit=try\0" \
> + "boot_fit=no\0" \
>   "fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
>   "initrd_addr=0x4380\0"  \
>   "bootm_size=0x1000\0" \
> --

Reviewed-by: Peng Fan 


Re: [PATCH 1/2] mx23_olinuxino: enable device tree

2021-03-21 Thread Sean Anderson

On 3/21/21 9:34 PM, Trevor Woerner wrote:

Add the dts file for the Olimex Olinuxino from the linux kernel, and enable
its use in this machine's defconfig.

Signed-off-by: Trevor Woerner 
---
  arch/arm/dts/Makefile|   3 +
  arch/arm/dts/imx23-olinuxino.dts | 131 +++
  configs/mx23_olinuxino_defconfig |   3 +-
  3 files changed, 136 insertions(+), 1 deletion(-)
  create mode 100644 arch/arm/dts/imx23-olinuxino.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index c6710826a0..d5cffc90d4 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -651,6 +651,9 @@ dtb-$(CONFIG_VF610) += vf500-colibri.dtb \
  dtb-$(CONFIG_MX23) += \
imx23-evk.dtb
  
+dtb-$(CONFIG_TARGET_MX23_OLINUXINO) += \

+   imx23-olinuxino.dtb
+
  dtb-$(CONFIG_MX28) += \
imx28-xea.dtb
  
diff --git a/arch/arm/dts/imx23-olinuxino.dts b/arch/arm/dts/imx23-olinuxino.dts

new file mode 100644
index 00..0729e72f22
--- /dev/null
+++ b/arch/arm/dts/imx23-olinuxino.dts
@@ -0,0 +1,131 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * Author: Fabio Estevam 
+ */
+
+/dts-v1/;
+#include 
+#include "imx23.dtsi"
+
+/ {
+   model = "i.MX23 Olinuxino Low Cost Board";
+   compatible = "olimex,imx23-olinuxino", "fsl,imx23";
+
+   memory@4000 {
+   device_type = "memory";
+   reg = <0x4000 0x0400>;
+   };
+
+   apb@8000 {
+   apbh@8000 {
+   ssp0: spi@8001 {
+   compatible = "fsl,imx23-mmc";
+   pinctrl-names = "default";
+   pinctrl-0 = <&mmc0_4bit_pins_a &mmc0_sck_cfg>;
+   bus-width = <4>;
+   broken-cd;
+   status = "okay";
+   };
+
+   pinctrl@80018000 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&hog_pins_a>;
+
+   hog_pins_a: hog@0 {
+   reg = <0>;
+   fsl,pinmux-ids = <
+   MX23_PAD_GPMI_ALE__GPIO_0_17
+   >;
+   fsl,drive-strength = ;
+   fsl,voltage = ;
+   fsl,pull-up = ;
+   };
+
+   led_pin_gpio2_1: led_gpio2_1@0 {
+   reg = <0>;
+   fsl,pinmux-ids = <
+   MX23_PAD_SSP1_DETECT__GPIO_2_1
+   >;
+   fsl,drive-strength = ;
+   fsl,voltage = ;
+   fsl,pull-up = ;
+   };
+   };
+
+   ssp1: spi@80034000 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "fsl,imx23-spi";
+   pinctrl-names = "default";
+   pinctrl-0 = <&spi2_pins_a>;
+   status = "okay";
+   };
+   };
+
+   apbx@8004 {
+   lradc@8005 {
+   status = "okay";
+   };
+
+   i2c: i2c@80058000 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c_pins_b>;
+   status = "okay";
+   };
+
+   duart: serial@8007 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&duart_pins_a>;
+   status = "okay";
+   };
+
+   auart0: serial@8006c000 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&auart0_2pins_a>;
+   status = "okay";
+   };
+
+   usbphy0: usbphy@8007c000 {
+   status = "okay";
+   };
+   };
+   };
+
+   ahb@8008 {
+   usb0: usb@8008 {
+   dr_mode = "host";
+   vbus-supply = <®_usb0_vbus>;
+   status = "okay";
+   };
+   };
+
+   regulators {


Does this need to be on a separate bus? Can't you just add the regulator
at the top-level with no register?

--Sean


+   

Re: [PATCH 1/2] riscv: simply longjmp

2021-03-21 Thread Sean Anderson

On 3/21/21 6:19 AM, Heinrich Schuchardt wrote:

The value returned by setjmp must be nonzero. If zero is passed as
parameter it must be replaced by 1.

This patch reduces the code size a bit.

Signed-off-by: Heinrich Schuchardt 
---
  arch/riscv/lib/setjmp.S | 8 ++--
  1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/riscv/lib/setjmp.S b/arch/riscv/lib/setjmp.S
index 72bc9241f6..99d6195827 100644
--- a/arch/riscv/lib/setjmp.S
+++ b/arch/riscv/lib/setjmp.S
@@ -54,12 +54,8 @@ ENTRY(longjmp)
LOAD_IDX(sp, 13)

/* Move the return value in place, but return 1 if passed 0. */
-   beq a1, zero, longjmp_1
-   mv a0, a1
-   ret
-
-   longjmp_1:
-   li a0, 1
+   seqz a0, a1
+   add a0, a0, a1
ret
  ENDPROC(longjmp)
  .popsection
--
2.30.2



Reviewed-by: Sean Anderson 


[PATCH] patman: Continue on if warnings are found outside a commit

2021-03-21 Thread Simon Glass
While we cannot know which commit the warning relates to, this should not
be fatal. Print the warning and carry on.

Signed-off-by: Simon Glass 
---

 tools/patman/patchstream.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index cdcd50a8499..a44cd861afc 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -133,8 +133,8 @@ class PatchStream:
 ValueError: Warning is generated with no commit associated
 """
 if not self.commit:
-raise ValueError('Warning outside commit: %s' % warn)
-if warn not in self.commit.warn:
+print('Warning outside commit: %s' % warn)
+elif warn not in self.commit.warn:
 self.commit.warn.append(warn)
 
 def _add_to_series(self, line, name, value):
-- 
2.31.0.rc2.261.g7f71774620-goog



Re: [PATCH 01/16] dm: core: Add helper to compare node names

2021-03-21 Thread Kishon Vijay Abraham I
Hi Simon,

On 12/03/21 10:15 am, Simon Glass wrote:
> Hi Kishon,
> 
> On Tue, 9 Mar 2021 at 05:27, Kishon Vijay Abraham I  wrote:
>>
>> Add helper to compare node names.
>>
>> Signed-off-by: Kishon Vijay Abraham I 
>> ---
>>  drivers/core/ofnode.c | 13 +
>>  include/dm/ofnode.h   |  9 +
>>  2 files changed, 22 insertions(+)
>>
>> diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
>> index fa0bd2a9c4..4e196d680e 100644
>> --- a/drivers/core/ofnode.c
>> +++ b/drivers/core/ofnode.c
>> @@ -18,6 +18,19 @@
>>  #include 
>>  #include 
>>
>> +bool ofnode_name_eq(ofnode node, const char *name)
>> +{
>> +   const char *node_name;
>> +   size_t len;
>> +
>> +   assert(ofnode_valid(node));
>> +
>> +   node_name = ofnode_get_name(node);
>> +   len = strchrnul(node_name, '@') - node_name;
>> +
>> +   return (strlen(name) == len) && (strncmp(node_name, name, len) == 0);
> 
> Can you use !strncmp() instead of == 0 ?
> 
>> +}
>> +
>>  int ofnode_read_u32(ofnode node, const char *propname, u32 *outp)
>>  {
>> return ofnode_read_u32_index(node, propname, 0, outp);
>> diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
>> index 2c0597c407..86a139276b 100644
>> --- a/include/dm/ofnode.h
>> +++ b/include/dm/ofnode.h
>> @@ -231,6 +231,15 @@ static inline ofnode ofnode_root(void)
>> return node;
>>  }
>>
>> +/**
>> + * ofnode_name_eq() - Check if the node name is equivalent to a given name
>> + *
> 
> How about a comment indicating this ignores the unit address?
> 
>> + * @node:  valid node reference that has to be compared
>> + * @name:  name that has to be compared with the node name
>> + * @return 1 if matches, 0 if it doesn't match
>> + */
>> +bool ofnode_name_eq(ofnode node, const char *name);
>> +
>>  /**
>>   * ofnode_read_u32() - Read a 32-bit integer from a property
>>   *
>> --
>> 2.17.1
>>
> 
> Please add a test for this in test/dm

Thanks for reviewing! Will fix it in my next revision.

Thanks
Kishon


Re: [PATCH 02/16] drivers: reset: Handle gracefully NULL pointers

2021-03-21 Thread Kishon Vijay Abraham I
Hi Simon,

On 12/03/21 10:15 am, Simon Glass wrote:
> Hi Kishon,
> 
> On Tue, 9 Mar 2021 at 05:27, Kishon Vijay Abraham I  wrote:
>>
>> From: Jean-Jacques Hiblot 
>>
>> Prepare the way for a managed reset API by handling NULL pointers without
>> crashing nor failing.
>>
>> Signed-off-by: Jean-Jacques Hiblot 
>> Signed-off-by: Vignesh Raghavendra 
>> Signed-off-by: Kishon Vijay Abraham I 
>> ---
>>  drivers/reset/reset-uclass.c | 30 +-
>>  1 file changed, 17 insertions(+), 13 deletions(-)
> 
> Why do you want this? This patch is missing the motivation which
> should be at the start of the commit message.

This is for "optional" reset controllers used by peripheral drivers.
This will help avoid adding checks in peripheral drivers.

Thanks
Kishon


[PATCH 0/5] misc: Various misc patches

2021-03-21 Thread Simon Glass
This series includes some minor tools updates and conversion of
CONFIG_MISC_INIT_F to Kconfig.


Simon Glass (5):
  dtoc: Show driver warnings once at the end
  dtoc: Improve handling of reg properties
  log: Fix up debug_cond() when LOG is enabled
  moveconfig: Handle binary files cleanly
  Convert CONFIG_MISC_INIT_F to Kconfig

 common/Kconfig   |  6 +
 configs/MPC8349ITXGP_defconfig   |  1 +
 configs/MPC8349ITX_LOWBOOT_defconfig |  1 +
 configs/MPC8349ITX_defconfig |  1 +
 configs/kmcoge4_defconfig|  1 +
 configs/sandbox64_defconfig  |  2 +-
 configs/sandbox_defconfig|  1 +
 configs/sandbox_flattree_defconfig   |  2 +-
 configs/sandbox_spl_defconfig|  2 ++
 configs/tools-only_defconfig |  1 +
 include/configs/MPC8349ITX.h |  2 --
 include/configs/kmp204x.h|  2 --
 include/configs/sandbox.h|  2 --
 include/log.h| 11 +---
 scripts/config_whitelist.txt |  1 -
 tools/dtoc/dtb_platdata.py   | 20 ++-
 tools/dtoc/src_scan.py   | 15 ++-
 tools/dtoc/test_dtoc.py  |  4 +--
 tools/dtoc/test_src_scan.py  | 38 ++--
 tools/moveconfig.py  | 16 ++--
 20 files changed, 81 insertions(+), 48 deletions(-)

-- 
2.31.0.rc2.261.g7f71774620-goog



[PATCH 2/5] dtoc: Improve handling of reg properties

2021-03-21 Thread Simon Glass
This existing code assumes that a reg property is larger than one cell,
but this is not always the case. Fix this assumption.

Also if a node's parent is missing the #address-cells and #size-cells
properties we use 2 as a default for each. But this should not happen in
practice. More likely the properties were removed for SPL due to there
being no 'u-boot,dm-pre-reloc' property, or similar. Add a warning for
this as the failure can be very confusing.

Signed-off-by: Simon Glass 
---

 tools/dtoc/dtb_platdata.py | 14 ++
 tools/dtoc/test_dtoc.py|  2 +-
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 27e88e75173..57a45170a26 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -440,6 +440,9 @@ class DtbPlatdata():
 Number of size cells for this node
 """
 parent = node.parent
+if parent and not parent.props:
+raise ValueError("Parent node '%s' has no properties - do you need 
u-boot,dm-spl or similar?" %
+ parent.path)
 num_addr, num_size = 2, 2
 if parent:
 addr_prop = parent.props.get('#address-cells')
@@ -467,18 +470,21 @@ class DtbPlatdata():
 if reg.type != fdt.Type.INT:
 raise ValueError("Node '%s' reg property is not an int" %
  node.name)
-if len(reg.value) % total:
+reg_val = reg.value
+if not isinstance(reg_val, list):
+reg_val = [reg_val]
+if len(reg_val) % total:
 raise ValueError(
-"Node '%s' reg property has %d cells "
+"Node '%s' (parent '%s') reg property has %d cells "
 'which is not a multiple of na + ns = %d + %d)' %
-(node.name, len(reg.value), num_addr, num_size))
+(node.name, node.parent.name, len(reg_val), num_addr, 
num_size))
 reg.num_addr = num_addr
 reg.num_size = num_size
 if num_addr != 1 or num_size != 1:
 reg.type = fdt.Type.INT64
 i = 0
 new_value = []
-val = reg.value
+val = reg_val
 if not isinstance(val, list):
 val = [val]
 while i < len(val):
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index 62fcab74178..c856ea41681 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -1462,7 +1462,7 @@ U_BOOT_DRVINFO(test3) = {
 with self.assertRaises(ValueError) as exc:
 self.run_test(['struct'], dtb_file, output)
 self.assertIn(
-"Node 'spl-test' reg property has 3 cells which is not a multiple 
of na + ns = 1 + 1)",
+"Node 'spl-test' (parent '/') reg property has 3 cells which is 
not a multiple of na + ns = 1 + 1)",
 str(exc.exception))
 
 def test_add_prop(self):
-- 
2.31.0.rc2.261.g7f71774620-goog



[PATCH 1/5] dtoc: Show driver warnings once at the end

2021-03-21 Thread Simon Glass
At present warnings are shown as soon as they are discovered in the
source scannner. But the function that detects them may be called multiple
times.

Collect all the warnings and show them at the end.

Signed-off-by: Simon Glass 
---

 tools/dtoc/dtb_platdata.py  |  6 --
 tools/dtoc/src_scan.py  | 15 +--
 tools/dtoc/test_dtoc.py |  2 +-
 tools/dtoc/test_src_scan.py | 38 ++---
 4 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index b5c449ebb47..27e88e75173 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -1186,8 +1186,7 @@ def run_steps(args, dtb_file, include_disabled, output, 
output_dirs, phase,
 raise ValueError('Must specify either output or output_dirs, not both')
 
 if not scan:
-scan = src_scan.Scanner(basedir, warning_disabled, drivers_additional,
-phase)
+scan = src_scan.Scanner(basedir, drivers_additional, phase)
 scan.scan_drivers()
 do_process = True
 else:
@@ -1217,4 +1216,7 @@ def run_steps(args, dtb_file, include_disabled, output, 
output_dirs, phase,
 plat.out_header(outfile)
 outfile.method(plat)
 plat.finish_output()
+
+if not warning_disabled:
+scan.show_warnings()
 return plat
diff --git a/tools/dtoc/src_scan.py b/tools/dtoc/src_scan.py
index 114212cfe2d..2db96884c85 100644
--- a/tools/dtoc/src_scan.py
+++ b/tools/dtoc/src_scan.py
@@ -188,7 +188,6 @@ class Scanner:
 key: Driver alias declared with
 DM_DRIVER_ALIAS(driver_alias, driver_name)
 value: Driver name declared with U_BOOT_DRIVER(driver_name)
-_warning_disabled: true to disable warnings about driver names not 
found
 _drivers_additional (list or str): List of additional drivers to use
 during scanning
 _of_match: Dict holding information about compatible strings
@@ -206,7 +205,7 @@ class Scanner:
 _phase: The phase of U-Boot that we are generating data for, e.g. 'spl'
  or 'tpl'. None if not known
 """
-def __init__(self, basedir, warning_disabled, drivers_additional, 
phase=''):
+def __init__(self, basedir, drivers_additional, phase=''):
 """Set up a new Scanner
 """
 if not basedir:
@@ -217,7 +216,7 @@ class Scanner:
 self._drivers = {}
 self._driver_aliases = {}
 self._drivers_additional = drivers_additional or []
-self._warning_disabled = warning_disabled
+self._missing_drivers = set()
 self._of_match = {}
 self._compat_to_driver = {}
 self._uclass = {}
@@ -268,9 +267,7 @@ class Scanner:
 aliases_c.remove(compat_c)
 return compat_c, aliases_c
 
-if not self._warning_disabled:
-print('WARNING: the driver %s was not found in the driver list'
-  % (compat_list_c[0]))
+self._missing_drivers.add(compat_list_c[0])
 
 return compat_list_c[0], compat_list_c[1:]
 
@@ -578,6 +575,12 @@ class Scanner:
 self._drivers[driver.name] = driver
 self._of_match.update(of_match)
 
+def show_warnings(self):
+"""Show any warnings that have been collected"""
+for name in sorted(list(self._missing_drivers)):
+print('WARNING: the driver %s was not found in the driver list'
+  % name)
+
 def scan_driver(self, fname):
 """Scan a driver file to build a list of driver names and aliases
 
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index 1912a8723f2..62fcab74178 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -104,7 +104,7 @@ def setup():
 
 # Disable warnings so that calls to get_normalized_compat_name() will not
 # output things.
-saved_scan = src_scan.Scanner(None, True, False)
+saved_scan = src_scan.Scanner(None, False)
 saved_scan.scan_drivers()
 
 def copy_scan():
diff --git a/tools/dtoc/test_src_scan.py b/tools/dtoc/test_src_scan.py
index 0af86dcf0c3..d6da03849f9 100644
--- a/tools/dtoc/test_src_scan.py
+++ b/tools/dtoc/test_src_scan.py
@@ -48,7 +48,7 @@ class TestSrcScan(unittest.TestCase):
 
 def test_simple(self):
 """Simple test of scanning drivers"""
-scan = src_scan.Scanner(None, True, None)
+scan = src_scan.Scanner(None, None)
 scan.scan_drivers()
 self.assertIn('sandbox_gpio', scan._drivers)
 self.assertIn('sandbox_gpio_alias', scan._driver_aliases)
@@ -59,8 +59,7 @@ class TestSrcScan(unittest.TestCase):
 def test_additional(self):
 """Test with additional drivers to scan"""
 scan = src_scan.Scanner(
-None, True,
-[None, '', 'tools/dtoc/test/dtoc_test_scan_drivers.cxx'])
+None, [None, '', 'tools/dtoc/test/dtoc_test_scan_drivers.cxx'])
 scan.scan_driv

[PATCH 3/5] log: Fix up debug_cond() when LOG is enabled

2021-03-21 Thread Simon Glass
At present debug() statements can cause debuf output to appear when LOG is
enabled but DEBUG is not. This is not intended and it seems that the
condition is wrong.

Fix it.

Signed-off-by: Simon Glass 
---

 include/log.h | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/log.h b/include/log.h
index ed7ba6d705a..f5288c549b8 100644
--- a/include/log.h
+++ b/include/log.h
@@ -234,11 +234,14 @@ int _log_buffer(enum log_category_t cat, enum log_level_t 
level,
 #define _SPL_BUILD 0
 #endif
 
-#if !_DEBUG && CONFIG_IS_ENABLED(LOG)
+#if CONFIG_IS_ENABLED(LOG)
 
-#define debug_cond(cond, fmt, args...) \
-({ \
-   log(LOG_CATEGORY, LOGL_DEBUG, fmt, ##args); \
+#define debug_cond(cond, fmt, args...) \
+({ \
+   if (cond)   \
+   log(LOG_CATEGORY,   \
+   (enum log_level_t)(LOGL_FORCE_DEBUG | _LOG_DEBUG),  \
+   fmt, ##args);   \
 })
 
 #else /* _DEBUG */
-- 
2.31.0.rc2.261.g7f71774620-goog



[PATCH 4/5] moveconfig: Handle binary files cleanly

2021-03-21 Thread Simon Glass
Some files are not actually source code and thus can produce unicode
errors. Report this and continue.

Signed-off-by: Simon Glass 
---

 tools/moveconfig.py | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index 9514d9a00cb..1ac30c00281 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -12,6 +12,10 @@ config options from headers to Kconfig (defconfig).
 
 This tool intends to help this tremendous work.
 
+Installing
+--
+
+You may need to install 'python3-asteval' for the 'asteval' module.
 
 Usage
 -
@@ -573,7 +577,11 @@ def cleanup_empty_blocks(header_path, options):
 """
 pattern = re.compile(r'^\s*#\s*if.*$\n^\s*#\s*endif.*$\n*', flags=re.M)
 with open(header_path) as f:
-data = f.read()
+try:
+data = f.read()
+except UnicodeDecodeError as e:
+print("Failed on file %s': %s" % (header_path, e))
+return
 
 new_data = pattern.sub('\n', data)
 
@@ -596,7 +604,11 @@ def cleanup_one_header(header_path, patterns, options):
   options: option flags.
 """
 with open(header_path) as f:
-lines = f.readlines()
+try:
+lines = f.readlines()
+except UnicodeDecodeError as e:
+print("Failed on file %s': %s" % (header_path, e))
+return
 
 matched = []
 for i, line in enumerate(lines):
-- 
2.31.0.rc2.261.g7f71774620-goog



[PATCH 5/5] Convert CONFIG_MISC_INIT_F to Kconfig

2021-03-21 Thread Simon Glass
This converts the following to Kconfig:
   CONFIG_MISC_INIT_F

Signed-off-by: Simon Glass 
---

 common/Kconfig   | 6 ++
 configs/MPC8349ITXGP_defconfig   | 1 +
 configs/MPC8349ITX_LOWBOOT_defconfig | 1 +
 configs/MPC8349ITX_defconfig | 1 +
 configs/kmcoge4_defconfig| 1 +
 configs/sandbox64_defconfig  | 2 +-
 configs/sandbox_defconfig| 1 +
 configs/sandbox_flattree_defconfig   | 2 +-
 configs/sandbox_spl_defconfig| 2 ++
 configs/tools-only_defconfig | 1 +
 include/configs/MPC8349ITX.h | 2 --
 include/configs/kmp204x.h| 2 --
 include/configs/sandbox.h| 2 --
 scripts/config_whitelist.txt | 1 -
 14 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 482f1235347..0e36dfd2368 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -527,6 +527,12 @@ config LAST_STAGE_INIT
  U-Boot calls last_stage_init() before the command-line interpreter is
  started.
 
+config MISC_INIT_F
+   bool "Execute pre-relocation misc init"
+   help
+ Enabling this option calls the 'misc_init_f' function in the init
+ sequence just before DRAM is inited.
+
 config MISC_INIT_R
bool "Execute Misc Init"
default y if ARCH_KEYSTONE || ARCH_SUNXI || MPC85xx
diff --git a/configs/MPC8349ITXGP_defconfig b/configs/MPC8349ITXGP_defconfig
index 28e4ebf06f5..92f2093bb65 100644
--- a/configs/MPC8349ITXGP_defconfig
+++ b/configs/MPC8349ITXGP_defconfig
@@ -154,6 +154,7 @@ CONFIG_SYS_EXTRA_OPTIONS="SYS_TEXT_BASE=0xFE00"
 CONFIG_BOOTDELAY=6
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="root=/dev/nfs rw nfsroot=:/nfsroot/rootfs 
ip=mpc8349emitxgp:eth0:off console=ttyS0,115200"
+CONFIG_MISC_INIT_F=y
 CONFIG_MISC_INIT_R=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="MPC8349E-mITX-GP> "
diff --git a/configs/MPC8349ITX_LOWBOOT_defconfig 
b/configs/MPC8349ITX_LOWBOOT_defconfig
index 46f7afc071f..cf1e90d6190 100644
--- a/configs/MPC8349ITX_LOWBOOT_defconfig
+++ b/configs/MPC8349ITX_LOWBOOT_defconfig
@@ -153,6 +153,7 @@ CONFIG_OF_STDOUT_VIA_ALIAS=y
 CONFIG_BOOTDELAY=6
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="root=/dev/nfs rw nfsroot=:/nfsroot/rootfs 
ip=mpc8349emitx:eth0:off console=ttyS0,115200"
+CONFIG_MISC_INIT_F=y
 CONFIG_MISC_INIT_R=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="MPC8349E-mITX> "
diff --git a/configs/MPC8349ITX_defconfig b/configs/MPC8349ITX_defconfig
index 1f70b756b0c..733e5d35996 100644
--- a/configs/MPC8349ITX_defconfig
+++ b/configs/MPC8349ITX_defconfig
@@ -152,6 +152,7 @@ CONFIG_OF_STDOUT_VIA_ALIAS=y
 CONFIG_BOOTDELAY=6
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="root=/dev/nfs rw nfsroot=:/nfsroot/rootfs 
ip=mpc8349emitx:eth0:off console=ttyS0,115200"
+CONFIG_MISC_INIT_F=y
 CONFIG_MISC_INIT_R=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="MPC8349E-mITX> "
diff --git a/configs/kmcoge4_defconfig b/configs/kmcoge4_defconfig
index ddc8f8a7f98..462e5677964 100644
--- a/configs/kmcoge4_defconfig
+++ b/configs/kmcoge4_defconfig
@@ -20,6 +20,7 @@ CONFIG_AUTOBOOT_STOP_STR=" "
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_BOARD_EARLY_INIT_R=y
 CONFIG_LAST_STAGE_INIT=y
+CONFIG_MISC_INIT_F=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index cfda83474b6..4648808d516 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -20,8 +20,8 @@ CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
 CONFIG_CONSOLE_RECORD=y
 CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
 CONFIG_PRE_CONSOLE_BUFFER=y
-CONFIG_LOG_SYSLOG=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_MISC_INIT_F=y
 CONFIG_CMD_CPU=y
 CONFIG_CMD_LICENSE=y
 CONFIG_CMD_BOOTZ=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 713708e01c2..c9515a44783 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -25,6 +25,7 @@ CONFIG_LOG=y
 CONFIG_LOG_SYSLOG=y
 CONFIG_LOG_ERROR_RETURN=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_MISC_INIT_F=y
 CONFIG_ANDROID_AB=y
 CONFIG_CMD_CPU=y
 CONFIG_CMD_LICENSE=y
diff --git a/configs/sandbox_flattree_defconfig 
b/configs/sandbox_flattree_defconfig
index 4401f33f0ba..b68f938cb37 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -17,8 +17,8 @@ CONFIG_BOOTSTAGE_STASH=y
 CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
 CONFIG_CONSOLE_RECORD=y
 CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
-CONFIG_LOG_SYSLOG=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_MISC_INIT_F=y
 CONFIG_CMD_CPU=y
 CONFIG_CMD_LICENSE=y
 CONFIG_CMD_BOOTZ=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index ac71cab5f1e..0e40b17c624 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -11,6 +11,7 @@ CONFIG_SPL_SYS_MALLOC_F_LEN=0x8000
 CONFIG_SPL=y
 CONFIG_BOOTSTAGE_STASH_ADDR=0x0
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
+CONFIG_TARGET_SANDBOX_SPL=y
 CONFIG_SANDBOX_SPL=y
 CONFIG_DEBUG_UART=y
 CONFIG_DIS

[PATCH] sandbox: Support signal handling only when requested

2021-03-21 Thread Simon Glass
At present if sandbox crashes it prints a message and tries to exit. But
with the recently introduced signal handler, it often seems to get stuck
in a loop until the stack overflows:

Segmentation violation

Segmentation violation

Segmentation violation

Segmentation violation

Segmentation violation

Segmentation violation

Segmentation violation
...

The signal handler is only useful for a few tests, as I understand it.
Make it optional.

Signed-off-by: Simon Glass 
---

 arch/sandbox/cpu/start.c | 18 +++---
 arch/sandbox/include/asm/state.h |  1 +
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index e87365e800d..72fe293e8bc 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -389,6 +389,16 @@ static int sandbox_cmdline_cb_select_unittests(struct 
sandbox_state *state,
 }
 SANDBOX_CMDLINE_OPT_SHORT(select_unittests, 'k', 1, "Select unit tests to 
run");
 
+static int sandbox_cmdline_cb_signals(struct sandbox_state *state,
+ const char *arg)
+{
+   state->handle_signals = true;
+
+   return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(signals, 'S', 0,
+ "Handle signals (such as SIGSEGV) in sandbox");
+
 static void setup_ram_buf(struct sandbox_state *state)
 {
/* Zero the RAM buffer if we didn't read it, to keep valgrind happy */
@@ -472,9 +482,11 @@ int main(int argc, char *argv[])
if (ret)
goto err;
 
-   ret = os_setup_signal_handlers();
-   if (ret)
-   goto err;
+   if (state->handle_signals) {
+   ret = os_setup_signal_handlers();
+   if (ret)
+   goto err;
+   }
 
 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
gd->malloc_base = CONFIG_MALLOC_F_ADDR;
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index bca13069824..1c4c571e28d 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -93,6 +93,7 @@ struct sandbox_state {
bool ram_buf_read;  /* true if we read the RAM buffer */
bool run_unittests; /* Run unit tests */
const char *select_unittests;   /* Unit test to run */
+   bool handle_signals;/* Handle signals within sandbox */
 
/* Pointer to information for each SPI bus/cs */
struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]
-- 
2.31.0.rc2.261.g7f71774620-goog



Re: [PATCH 5/5] Convert CONFIG_MISC_INIT_F to Kconfig

2021-03-21 Thread Stefan Roese

On 22.03.21 06:13, Simon Glass wrote:

This converts the following to Kconfig:
CONFIG_MISC_INIT_F

Signed-off-by: Simon Glass 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---

  common/Kconfig   | 6 ++
  configs/MPC8349ITXGP_defconfig   | 1 +
  configs/MPC8349ITX_LOWBOOT_defconfig | 1 +
  configs/MPC8349ITX_defconfig | 1 +
  configs/kmcoge4_defconfig| 1 +
  configs/sandbox64_defconfig  | 2 +-
  configs/sandbox_defconfig| 1 +
  configs/sandbox_flattree_defconfig   | 2 +-
  configs/sandbox_spl_defconfig| 2 ++
  configs/tools-only_defconfig | 1 +
  include/configs/MPC8349ITX.h | 2 --
  include/configs/kmp204x.h| 2 --
  include/configs/sandbox.h| 2 --
  scripts/config_whitelist.txt | 1 -
  14 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 482f1235347..0e36dfd2368 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -527,6 +527,12 @@ config LAST_STAGE_INIT
  U-Boot calls last_stage_init() before the command-line interpreter is
  started.
  
+config MISC_INIT_F

+   bool "Execute pre-relocation misc init"
+   help
+ Enabling this option calls the 'misc_init_f' function in the init
+ sequence just before DRAM is inited.
+
  config MISC_INIT_R
bool "Execute Misc Init"
default y if ARCH_KEYSTONE || ARCH_SUNXI || MPC85xx
diff --git a/configs/MPC8349ITXGP_defconfig b/configs/MPC8349ITXGP_defconfig
index 28e4ebf06f5..92f2093bb65 100644
--- a/configs/MPC8349ITXGP_defconfig
+++ b/configs/MPC8349ITXGP_defconfig
@@ -154,6 +154,7 @@ CONFIG_SYS_EXTRA_OPTIONS="SYS_TEXT_BASE=0xFE00"
  CONFIG_BOOTDELAY=6
  CONFIG_USE_BOOTARGS=y
  CONFIG_BOOTARGS="root=/dev/nfs rw nfsroot=:/nfsroot/rootfs 
ip=mpc8349emitxgp:eth0:off console=ttyS0,115200"
+CONFIG_MISC_INIT_F=y
  CONFIG_MISC_INIT_R=y
  CONFIG_HUSH_PARSER=y
  CONFIG_SYS_PROMPT="MPC8349E-mITX-GP> "
diff --git a/configs/MPC8349ITX_LOWBOOT_defconfig 
b/configs/MPC8349ITX_LOWBOOT_defconfig
index 46f7afc071f..cf1e90d6190 100644
--- a/configs/MPC8349ITX_LOWBOOT_defconfig
+++ b/configs/MPC8349ITX_LOWBOOT_defconfig
@@ -153,6 +153,7 @@ CONFIG_OF_STDOUT_VIA_ALIAS=y
  CONFIG_BOOTDELAY=6
  CONFIG_USE_BOOTARGS=y
  CONFIG_BOOTARGS="root=/dev/nfs rw nfsroot=:/nfsroot/rootfs 
ip=mpc8349emitx:eth0:off console=ttyS0,115200"
+CONFIG_MISC_INIT_F=y
  CONFIG_MISC_INIT_R=y
  CONFIG_HUSH_PARSER=y
  CONFIG_SYS_PROMPT="MPC8349E-mITX> "
diff --git a/configs/MPC8349ITX_defconfig b/configs/MPC8349ITX_defconfig
index 1f70b756b0c..733e5d35996 100644
--- a/configs/MPC8349ITX_defconfig
+++ b/configs/MPC8349ITX_defconfig
@@ -152,6 +152,7 @@ CONFIG_OF_STDOUT_VIA_ALIAS=y
  CONFIG_BOOTDELAY=6
  CONFIG_USE_BOOTARGS=y
  CONFIG_BOOTARGS="root=/dev/nfs rw nfsroot=:/nfsroot/rootfs 
ip=mpc8349emitx:eth0:off console=ttyS0,115200"
+CONFIG_MISC_INIT_F=y
  CONFIG_MISC_INIT_R=y
  CONFIG_HUSH_PARSER=y
  CONFIG_SYS_PROMPT="MPC8349E-mITX> "
diff --git a/configs/kmcoge4_defconfig b/configs/kmcoge4_defconfig
index ddc8f8a7f98..462e5677964 100644
--- a/configs/kmcoge4_defconfig
+++ b/configs/kmcoge4_defconfig
@@ -20,6 +20,7 @@ CONFIG_AUTOBOOT_STOP_STR=" "
  CONFIG_BOARD_EARLY_INIT_F=y
  CONFIG_BOARD_EARLY_INIT_R=y
  CONFIG_LAST_STAGE_INIT=y
+CONFIG_MISC_INIT_F=y
  CONFIG_HUSH_PARSER=y
  CONFIG_CMD_ASKENV=y
  CONFIG_CMD_GREPENV=y
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index cfda83474b6..4648808d516 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -20,8 +20,8 @@ CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
  CONFIG_CONSOLE_RECORD=y
  CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
  CONFIG_PRE_CONSOLE_BUFFER=y
-CONFIG_LOG_SYSLOG=y
  CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_MISC_INIT_F=y
  CONFIG_CMD_CPU=y
  CONFIG_CMD_LICENSE=y
  CONFIG_CMD_BOOTZ=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 713708e01c2..c9515a44783 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -25,6 +25,7 @@ CONFIG_LOG=y
  CONFIG_LOG_SYSLOG=y
  CONFIG_LOG_ERROR_RETURN=y
  CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_MISC_INIT_F=y
  CONFIG_ANDROID_AB=y
  CONFIG_CMD_CPU=y
  CONFIG_CMD_LICENSE=y
diff --git a/configs/sandbox_flattree_defconfig 
b/configs/sandbox_flattree_defconfig
index 4401f33f0ba..b68f938cb37 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -17,8 +17,8 @@ CONFIG_BOOTSTAGE_STASH=y
  CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
  CONFIG_CONSOLE_RECORD=y
  CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
-CONFIG_LOG_SYSLOG=y
  CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_MISC_INIT_F=y
  CONFIG_CMD_CPU=y
  CONFIG_CMD_LICENSE=y
  CONFIG_CMD_BOOTZ=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index ac71cab5f1e..0e40b17c624 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -11,6 +11,7 @@ CONFIG_SPL_SYS_MALLOC_F_LEN=0x8000
  CONFIG_SPL=y
  C

[PATCH 1/2] spi: nxp-fspi: Add support for IP read only

2021-03-21 Thread Kuldeep Singh
Add support for disabling AHB bus and read entire flash contents via IP
bus only. Please note, this enables IP bus read using a quirk which can
be enabled directly in device-type data or in existence of an errata
where AHB bus may need to be disabled.

Signed-off-by: Kuldeep Singh 
---
 drivers/spi/nxp_fspi.c | 24 
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/nxp_fspi.c b/drivers/spi/nxp_fspi.c
index 6c5bad4c2c..e1b3d2d77b 100644
--- a/drivers/spi/nxp_fspi.c
+++ b/drivers/spi/nxp_fspi.c
@@ -304,6 +304,9 @@
 #define POLL_TOUT  5000
 #define NXP_FSPI_MAX_CHIPSELECT4
 
+/* Access flash memory using IP bus only */
+#define FSPI_QUIRK_USE_IP_ONLY BIT(0)
+
 struct nxp_fspi_devtype_data {
unsigned int rxfifo;
unsigned int txfifo;
@@ -338,6 +341,11 @@ struct nxp_fspi {
const struct nxp_fspi_devtype_data *devtype_data;
 };
 
+static inline int needs_ip_only(struct nxp_fspi *f)
+{
+   return f->devtype_data->quirks & FSPI_QUIRK_USE_IP_ONLY;
+}
+
 /*
  * R/W functions for big- or little-endian registers:
  * The FSPI controller's endianness is independent of
@@ -769,12 +777,14 @@ static int nxp_fspi_exec_op(struct spi_slave *slave,
 
nxp_fspi_prepare_lut(f, op);
/*
-* If we have large chunks of data, we read them through the AHB bus
-* by accessing the mapped memory. In all other cases we use
-* IP commands to access the flash.
+* If we have large chunks of data, we read them through the AHB bus by
+* accessing the mapped memory. In all other cases we use IP commands
+* to access the flash. Read via AHB bus may be corrupted due to
+* existence of an errata and therefore discard AHB read in such cases.
 */
if (op->data.nbytes > (f->devtype_data->rxfifo - 4) &&
-   op->data.dir == SPI_MEM_DATA_IN) {
+   op->data.dir == SPI_MEM_DATA_IN &&
+   !needs_ip_only(f)) {
nxp_fspi_read_ahb(f, op);
} else {
if (op->data.nbytes && op->data.dir == SPI_MEM_DATA_OUT)
@@ -808,6 +818,12 @@ static int nxp_fspi_adjust_op_size(struct spi_slave *slave,
op->data.nbytes = ALIGN_DOWN(op->data.nbytes, 8);
}
 
+   /* Limit data bytes to RX FIFO in case of IP read only */
+   if (needs_ip_only(f) &&
+   op->data.dir == SPI_MEM_DATA_IN &&
+   op->data.nbytes > f->devtype_data->rxfifo)
+   op->data.nbytes = f->devtype_data->rxfifo;
+
return 0;
 }
 
-- 
2.25.1



[PATCH 2/2] spi: nxp_fspi: Implement errata workaround for LS1028A

2021-03-21 Thread Kuldeep Singh
Errata ERR050568 description says that "Flash access by FlexSPI AHB
command may not work with platform frequency equal to 300 MHz" on
LS1028A.

By default, smaller length reads(equal to RX FIFO size) are done by IP
bus and larger length reads using AHB bus. For adding errata workaround,
use IP bus to read entire flash contents and disable AHB path when
platform frequency is 300Mhz.

Signed-off-by: Kuldeep Singh 
---
 drivers/spi/nxp_fspi.c | 49 +-
 1 file changed, 44 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/nxp_fspi.c b/drivers/spi/nxp_fspi.c
index e1b3d2d77b..7ba3a72223 100644
--- a/drivers/spi/nxp_fspi.c
+++ b/drivers/spi/nxp_fspi.c
@@ -41,6 +41,11 @@
 #include 
 #include 
 #include 
+#ifdef CONFIG_FSL_LAYERSCAPE
+#include 
+#include 
+#include 
+#endif
 #include 
 #include 
 #include 
@@ -315,7 +320,7 @@ struct nxp_fspi_devtype_data {
bool little_endian;
 };
 
-static const struct nxp_fspi_devtype_data lx2160a_data = {
+static struct nxp_fspi_devtype_data lx2160a_data = {
.rxfifo = SZ_512,   /* (64  * 64 bits)  */
.txfifo = SZ_1K,/* (128 * 64 bits)  */
.ahb_buf_size = SZ_2K,  /* (256 * 64 bits)  */
@@ -323,7 +328,7 @@ static const struct nxp_fspi_devtype_data lx2160a_data = {
.little_endian = true,  /* little-endian*/
 };
 
-static const struct nxp_fspi_devtype_data imx8mm_data = {
+static struct nxp_fspi_devtype_data imx8mm_data = {
.rxfifo = SZ_512,   /* (64  * 64 bits)  */
.txfifo = SZ_1K,/* (128 * 64 bits)  */
.ahb_buf_size = SZ_2K,  /* (256 * 64 bits)  */
@@ -338,7 +343,7 @@ struct nxp_fspi {
u32 memmap_phy;
u32 memmap_phy_size;
struct clk clk, clk_en;
-   const struct nxp_fspi_devtype_data *devtype_data;
+   struct nxp_fspi_devtype_data *devtype_data;
 };
 
 static inline int needs_ip_only(struct nxp_fspi *f)
@@ -529,8 +534,8 @@ static void nxp_fspi_prepare_lut(struct nxp_fspi *f,
for (i = 0; i < ARRAY_SIZE(lutval); i++)
fspi_writel(f, lutval[i], base + FSPI_LUT_REG(i));
 
-   dev_dbg(f->dev, "CMD[%x] lutval[0:%x \t 1:%x \t 2:%x \t 3:%x]\n",
-   op->cmd.opcode, lutval[0], lutval[1], lutval[2], lutval[3]);
+   dev_dbg(f->dev, "CMD[%x] lutval[0:%x \t 1:%x \t 2:%x \t 3:%x], size: 
0x%08x\n",
+   op->cmd.opcode, lutval[0], lutval[1], lutval[2], lutval[3], 
op->data.nbytes);
 
/* lock LUT */
fspi_writel(f, FSPI_LUTKEY_VALUE, f->iobase + FSPI_LUTKEY);
@@ -827,6 +832,31 @@ static int nxp_fspi_adjust_op_size(struct spi_slave *slave,
return 0;
 }
 
+static void erratum_err050568(struct nxp_fspi *f)
+{
+   struct sys_info sysinfo;
+   u32 svr = 0, freq = 0;
+
+   /* Check for LS1028A variants */
+   svr = SVR_SOC_VER(get_svr());
+   if (svr != SVR_LS1017A ||
+   svr != SVR_LS1018A ||
+   svr != SVR_LS1027A ||
+   svr != SVR_LS1028A) {
+   dev_dbg(f->dev, "Errata applicable only for LS1028A 
variants\n");
+   return;
+   }
+
+   /* Read PLL frequency */
+   get_sys_info(&sysinfo);
+   freq = sysinfo.freq_systembus / 100; /* Convert to MHz */
+   dev_dbg(f->dev, "svr: %08x, Frequency: %dMhz\n", svr, freq);
+
+   /* Use IP bus only if PLL is 300MHz */
+   if (freq == 300)
+   f->devtype_data->quirks |= FSPI_QUIRK_USE_IP_ONLY;
+}
+
 static int nxp_fspi_default_setup(struct nxp_fspi *f)
 {
void __iomem *base = f->iobase;
@@ -847,6 +877,15 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f)
return ret;
 #endif
 
+   /*
+* ERR050568: Flash access by FlexSPI AHB command may not work with
+* platform frequency equal to 300 MHz on LS1028A.
+* LS1028A reuses LX2160A compatible entry. Make errata applicable for
+* Layerscape LS1028A platform family.
+*/
+   if (device_is_compatible(f->dev, "nxp,lx2160a-fspi"))
+   erratum_err050568(f);
+
/* Reset the module */
/* w1c register, wait unit clear */
ret = fspi_readl_poll_tout(f, f->iobase + FSPI_MCR0,
-- 
2.25.1



RE: [PATCH 2/2] spi: nxp_fspi: Implement errata workaround for LS1028A

2021-03-21 Thread Kuldeep Singh
+ Ye Li

> -Original Message-
> From: Kuldeep Singh 
> Sent: Monday, March 22, 2021 12:00 PM
> To: Jagan Teki ; u-boot@lists.denx.de
> Cc: Kuldeep Singh 
> Subject: [PATCH 2/2] spi: nxp_fspi: Implement errata workaround for LS1028A
> 
> Errata ERR050568 description says that "Flash access by FlexSPI AHB
> command may not work with platform frequency equal to 300 MHz" on
> LS1028A.
> 
> By default, smaller length reads(equal to RX FIFO size) are done by IP bus and
> larger length reads using AHB bus. For adding errata workaround, use IP bus
> to read entire flash contents and disable AHB path when platform frequency
> is 300Mhz.
> 
> Signed-off-by: Kuldeep Singh 

Hi Ye,
Please confirm and let me know if this patch breaks imx platforms.

Regards
Kuldeep
> ---
>  drivers/spi/nxp_fspi.c | 49 +-
>  1 file changed, 44 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/spi/nxp_fspi.c b/drivers/spi/nxp_fspi.c index
> e1b3d2d77b..7ba3a72223 100644
> --- a/drivers/spi/nxp_fspi.c
> +++ b/drivers/spi/nxp_fspi.c
> @@ -41,6 +41,11 @@
>  #include 
>  #include 
>  #include 
> +#ifdef CONFIG_FSL_LAYERSCAPE
> +#include 
> +#include 
> +#include 
> +#endif
>  #include 
>  #include 
>  #include 
> @@ -315,7 +320,7 @@ struct nxp_fspi_devtype_data {
>   bool little_endian;
>  };
> 
> -static const struct nxp_fspi_devtype_data lx2160a_data = {
> +static struct nxp_fspi_devtype_data lx2160a_data = {
>   .rxfifo = SZ_512,   /* (64  * 64 bits)  */
>   .txfifo = SZ_1K,/* (128 * 64 bits)  */
>   .ahb_buf_size = SZ_2K,  /* (256 * 64 bits)  */ @@ -323,7 +328,7 @@
> static const struct nxp_fspi_devtype_data lx2160a_data = {
>   .little_endian = true,  /* little-endian*/
>  };
> 
> -static const struct nxp_fspi_devtype_data imx8mm_data = {
> +static struct nxp_fspi_devtype_data imx8mm_data = {
>   .rxfifo = SZ_512,   /* (64  * 64 bits)  */
>   .txfifo = SZ_1K,/* (128 * 64 bits)  */
>   .ahb_buf_size = SZ_2K,  /* (256 * 64 bits)  */ @@ -338,7 +343,7 @@
> struct nxp_fspi {
>   u32 memmap_phy;
>   u32 memmap_phy_size;
>   struct clk clk, clk_en;
> - const struct nxp_fspi_devtype_data *devtype_data;
> + struct nxp_fspi_devtype_data *devtype_data;
>  };
> 
>  static inline int needs_ip_only(struct nxp_fspi *f) @@ -529,8 +534,8 @@
> static void nxp_fspi_prepare_lut(struct nxp_fspi *f,
>   for (i = 0; i < ARRAY_SIZE(lutval); i++)
>   fspi_writel(f, lutval[i], base + FSPI_LUT_REG(i));
> 
> - dev_dbg(f->dev, "CMD[%x] lutval[0:%x \t 1:%x \t 2:%x \t 3:%x]\n",
> - op->cmd.opcode, lutval[0], lutval[1], lutval[2], lutval[3]);
> + dev_dbg(f->dev, "CMD[%x] lutval[0:%x \t 1:%x \t 2:%x \t 3:%x], size:
> 0x%08x\n",
> + op->cmd.opcode, lutval[0], lutval[1], lutval[2], lutval[3],
> +op->data.nbytes);
> 
>   /* lock LUT */
>   fspi_writel(f, FSPI_LUTKEY_VALUE, f->iobase + FSPI_LUTKEY); @@ -
> 827,6 +832,31 @@ static int nxp_fspi_adjust_op_size(struct spi_slave *slave,
>   return 0;
>  }
> 
> +static void erratum_err050568(struct nxp_fspi *f) {
> + struct sys_info sysinfo;
> + u32 svr = 0, freq = 0;
> +
> + /* Check for LS1028A variants */
> + svr = SVR_SOC_VER(get_svr());
> + if (svr != SVR_LS1017A ||
> + svr != SVR_LS1018A ||
> + svr != SVR_LS1027A ||
> + svr != SVR_LS1028A) {
> + dev_dbg(f->dev, "Errata applicable only for LS1028A
> variants\n");
> + return;
> + }
> +
> + /* Read PLL frequency */
> + get_sys_info(&sysinfo);
> + freq = sysinfo.freq_systembus / 100; /* Convert to MHz */
> + dev_dbg(f->dev, "svr: %08x, Frequency: %dMhz\n", svr, freq);
> +
> + /* Use IP bus only if PLL is 300MHz */
> + if (freq == 300)
> + f->devtype_data->quirks |= FSPI_QUIRK_USE_IP_ONLY; }
> +
>  static int nxp_fspi_default_setup(struct nxp_fspi *f)  {
>   void __iomem *base = f->iobase;
> @@ -847,6 +877,15 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f)
>   return ret;
>  #endif
> 
> + /*
> +  * ERR050568: Flash access by FlexSPI AHB command may not work
> with
> +  * platform frequency equal to 300 MHz on LS1028A.
> +  * LS1028A reuses LX2160A compatible entry. Make errata applicable
> for
> +  * Layerscape LS1028A platform family.
> +  */
> + if (device_is_compatible(f->dev, "nxp,lx2160a-fspi"))
> + erratum_err050568(f);
> +
>   /* Reset the module */
>   /* w1c register, wait unit clear */
>   ret = fspi_readl_poll_tout(f, f->iobase + FSPI_MCR0,
> --
> 2.25.1