Re: [PATCH] regulator: fix: enable gpio when requested

2020-04-27 Thread Lukasz Majewski
Hi Mark,

> The fix in commit b7adcdd073c0 has the side-effect that the regulator
> will be disabled when requesting the relevant gpio in
> regulator_common_ofdata_to_platdata() and enabled in
> regulator_pre_probe() when the regulator was already enabled.
> This leads to a short interruption in the 3.3V power to the PCIe
> slot on the firefly-rk3399 which makes an ADATA SX8000NP NVMe SSD
> unhappy.
> 
> Fix this by setting the GPIOD_IS_OUT_ACTIVE flag again when the
> 'regulator-boot-on' property is set, but check for this property
> explicitly instead of relying on the "boot_on" member of
> the uclass platdata.
> 
> Signed-off-by: Mark Kettenis 
> ---
>  drivers/power/regulator/regulator-uclass.c | 3 ---
>  drivers/power/regulator/regulator_common.c | 2 ++
>  2 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/power/regulator/regulator-uclass.c
> b/drivers/power/regulator/regulator-uclass.c index
> c9d26344d7..90961de95c 100644 ---
> a/drivers/power/regulator/regulator-uclass.c +++
> b/drivers/power/regulator/regulator-uclass.c @@ -464,9 +464,6 @@
> static int regulator_pre_probe(struct udevice *dev) (uc_pdata->min_uA
> == uc_pdata->max_uA)) uc_pdata->flags |= REGULATOR_FLAG_AUTOSET_UA;
>  
> - if (uc_pdata->boot_on)
> - regulator_set_enable(dev, uc_pdata->boot_on);
> -
>   return 0;
>  }
>  
> diff --git a/drivers/power/regulator/regulator_common.c
> b/drivers/power/regulator/regulator_common.c index
> 33b73b7c2f..bc13b88476 100644 ---
> a/drivers/power/regulator/regulator_common.c +++
> b/drivers/power/regulator/regulator_common.c @@ -17,6 +17,8 @@ int
> regulator_common_ofdata_to_platdata(struct udevice *dev, 
>   if (!dev_read_bool(dev, "enable-active-high"))
>   flags |= GPIOD_ACTIVE_LOW;
> + if (dev_read_bool(dev, "regulator-boot-on"))
> + flags |= GPIOD_IS_OUT_ACTIVE;
>  
>   /* Get optional enable GPIO desc */
>   gpio = _pdata->gpio;

Sorry, but this is a simple revert of my commit and breaks use cases
described in the commit message of this fix.

Do you see some kind of "glitch" on the gpio in
regulator_common_of_platdata?

The regulator-boot-on property [1] shall prevent from the issue you
described in the commit message of this revert.

Links:
[1] -
https://elixir.bootlin.com/linux/latest/source/Documentation/devicetree/bindings/regulator/regulator.yaml#L40

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lu...@denx.de


pgprA5ljkft3e.pgp
Description: OpenPGP digital signature


Re: [PATCH v5 1/4] omap: mmc: Avoid using libfdt with of-platdata

2020-04-27 Thread Lokesh Vutla
+Faiz,

On 28/04/20 12:29 AM, Tom Rini wrote:
> On Mon, Apr 27, 2020 at 05:33:41AM +, Peng Fan wrote:
>>> Subject: [PATCH v5 1/4] omap: mmc: Avoid using libfdt with of-platdata
>>>
>>> At present this driver is enabled in SPL on omapl138_lcdk, which uses
>>> of-platdata. The driver needs to be ported to use of-platdata properly.
>>> For now, avoid a build error by returning an error.
>>>
>>> Signed-off-by: Simon Glass 

Does this break the boot on omap l138?

Thanks and regards,
Lokesh

>>
>> Acked-by: Peng Fan 
> 
> Since the board maintainer is on CC and I believe that platform is still
> actively used in testing, I want to see this fixed rather than turned in
> to a run-time error.  Thanks!
> 


Re: [PATCH 3/3] acpi: Fix-up patch to correct sandbox test errors

2020-04-27 Thread Bin Meng
Hi Simon,

On Tue, Apr 28, 2020 at 11:06 AM Simon Glass  wrote:
>
> Hi Bin,
>
> On Mon, 27 Apr 2020 at 20:42, Bin Meng  wrote:
> >
> > Hi Simon,
> >
> > On Tue, Apr 28, 2020 at 10:29 AM Simon Glass  wrote:
> > >
> > > Hi Bin,
> > >
> > > On Mon, 27 Apr 2020 at 19:30, Bin Meng  wrote:
> > > >
> > > > Hi Simon,
> > > >
> > > > On Tue, Apr 28, 2020 at 1:02 AM Simon Glass  wrote:
> > > > >
> > > > > Move the alignment code into acpi_setup_base_tables() so that test and
> > > > > production code are in alignment.
> > > > >
> > > > > This brings x86/master into line with patch series v8.
> > > > >
> > > > > Signed-off-by: Simon Glass 
> > > > > ---
> > > > >
> > > > >  arch/x86/lib/acpi_table.c | 5 -
> > > > >  lib/acpi/acpi_table.c | 7 ++-
> > > > >  2 files changed, 6 insertions(+), 6 deletions(-)
> > > > >
> > > > > diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
> > > > > index 600bde2f5f..13f1409de8 100644
> > > > > --- a/arch/x86/lib/acpi_table.c
> > > > > +++ b/arch/x86/lib/acpi_table.c
> > > > > @@ -375,11 +375,6 @@ ulong write_acpi_tables(ulong start_addr)
> > > > > debug("ACPI: Writing ACPI tables at %lx\n", start_addr);
> > > > >
> > > > > acpi_setup_base_tables(ctx, start);
> > > > > -   /*
> > > > > -* Per ACPI spec, the FACS table address must be aligned to a 
> > > > > 64 byte
> > > > > -* boundary (Windows checks this, but Linux does not).
> > > > > -*/
> > > > > -   acpi_align64(ctx);
> > > > >
> > > > > debug("ACPI:* FACS\n");
> > > > > facs = ctx->current;
> > > > > diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c
> > > > > index 5abf1cad50..1c253af3bf 100644
> > > > > --- a/lib/acpi/acpi_table.c
> > > > > +++ b/lib/acpi/acpi_table.c
> > > > > @@ -145,7 +145,7 @@ int acpi_add_table(struct acpi_ctx *ctx, void 
> > > > > *table)
> > > > > }
> > > > >
> > > > > if (i >= entries_num) {
> > > > > -   debug("ACPI: Error: too many tables\n");
> > > > > +   log_err("ACPI: Error: too many tables\n");
> > > > > return -E2BIG;
> > > > > }
> > > > >
> > > > > @@ -256,4 +256,9 @@ void acpi_setup_base_tables(struct acpi_ctx *ctx, 
> > > > > void *start)
> > > > > acpi_write_rsdp(ctx->rsdp, ctx->rsdt, ctx->xsdt);
> > > > > acpi_write_rsdt(ctx->rsdt);
> > > > > acpi_write_xsdt(ctx->xsdt);
> > > > > +   /*
> > > > > +* Per ACPI spec, the FACS table address must be aligned to a 
> > > > > 64 byte
> > > > > +* boundary (Windows checks this, but Linux does not).
> > > > > +*/
> > > > > +   acpi_align64(ctx);
> > > > >  }
> > > > > --
> > > >
> > > > Could you please point out which commit in u-boot-x86/master should
> > > > squash in this patch to fix the build error on sandbox?
> > >
> > > It might be easier to pick up v8 in that case. I think there are three
> > > patches that need to change because of conflicts caused by the first
> > > one.
> > >
> > > So can you pick up the v8 patches? Also you do need to rebase on
> > > master because of the str_to_upper patches.
> >
> > But v8 is a complete new series for part B? I think we'd better re-tag
> > v8 as v1. It's quite confusing.
>
> No I mean the part A series. Let's get that applied and then we will
> be in a brave new world.

Is the v8 this one?
http://patchwork.ozlabs.org/user/todo/uboot/?series=172777

The part A series are already applied, but it has a build error as I mentioned.

>
> I could resent part B as v1 if you like, but note that it has some
> reviewed-by tags and some v3, etc. comments. The patches languished
> for quite a while which is why I decided to try to split them up.


Regards,
Bin


Re: [PATCH 3/3] acpi: Fix-up patch to correct sandbox test errors

2020-04-27 Thread Simon Glass
Hi Bin,

On Mon, 27 Apr 2020 at 20:42, Bin Meng  wrote:
>
> Hi Simon,
>
> On Tue, Apr 28, 2020 at 10:29 AM Simon Glass  wrote:
> >
> > Hi Bin,
> >
> > On Mon, 27 Apr 2020 at 19:30, Bin Meng  wrote:
> > >
> > > Hi Simon,
> > >
> > > On Tue, Apr 28, 2020 at 1:02 AM Simon Glass  wrote:
> > > >
> > > > Move the alignment code into acpi_setup_base_tables() so that test and
> > > > production code are in alignment.
> > > >
> > > > This brings x86/master into line with patch series v8.
> > > >
> > > > Signed-off-by: Simon Glass 
> > > > ---
> > > >
> > > >  arch/x86/lib/acpi_table.c | 5 -
> > > >  lib/acpi/acpi_table.c | 7 ++-
> > > >  2 files changed, 6 insertions(+), 6 deletions(-)
> > > >
> > > > diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
> > > > index 600bde2f5f..13f1409de8 100644
> > > > --- a/arch/x86/lib/acpi_table.c
> > > > +++ b/arch/x86/lib/acpi_table.c
> > > > @@ -375,11 +375,6 @@ ulong write_acpi_tables(ulong start_addr)
> > > > debug("ACPI: Writing ACPI tables at %lx\n", start_addr);
> > > >
> > > > acpi_setup_base_tables(ctx, start);
> > > > -   /*
> > > > -* Per ACPI spec, the FACS table address must be aligned to a 
> > > > 64 byte
> > > > -* boundary (Windows checks this, but Linux does not).
> > > > -*/
> > > > -   acpi_align64(ctx);
> > > >
> > > > debug("ACPI:* FACS\n");
> > > > facs = ctx->current;
> > > > diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c
> > > > index 5abf1cad50..1c253af3bf 100644
> > > > --- a/lib/acpi/acpi_table.c
> > > > +++ b/lib/acpi/acpi_table.c
> > > > @@ -145,7 +145,7 @@ int acpi_add_table(struct acpi_ctx *ctx, void 
> > > > *table)
> > > > }
> > > >
> > > > if (i >= entries_num) {
> > > > -   debug("ACPI: Error: too many tables\n");
> > > > +   log_err("ACPI: Error: too many tables\n");
> > > > return -E2BIG;
> > > > }
> > > >
> > > > @@ -256,4 +256,9 @@ void acpi_setup_base_tables(struct acpi_ctx *ctx, 
> > > > void *start)
> > > > acpi_write_rsdp(ctx->rsdp, ctx->rsdt, ctx->xsdt);
> > > > acpi_write_rsdt(ctx->rsdt);
> > > > acpi_write_xsdt(ctx->xsdt);
> > > > +   /*
> > > > +* Per ACPI spec, the FACS table address must be aligned to a 
> > > > 64 byte
> > > > +* boundary (Windows checks this, but Linux does not).
> > > > +*/
> > > > +   acpi_align64(ctx);
> > > >  }
> > > > --
> > >
> > > Could you please point out which commit in u-boot-x86/master should
> > > squash in this patch to fix the build error on sandbox?
> >
> > It might be easier to pick up v8 in that case. I think there are three
> > patches that need to change because of conflicts caused by the first
> > one.
> >
> > So can you pick up the v8 patches? Also you do need to rebase on
> > master because of the str_to_upper patches.
>
> But v8 is a complete new series for part B? I think we'd better re-tag
> v8 as v1. It's quite confusing.

No I mean the part A series. Let's get that applied and then we will
be in a brave new world.

I could resent part B as v1 if you like, but note that it has some
reviewed-by tags and some v3, etc. comments. The patches languished
for quite a while which is why I decided to try to split them up.

Regards,
Simon


Re: [PATCH 3/3] acpi: Fix-up patch to correct sandbox test errors

2020-04-27 Thread Bin Meng
Hi Simon,

On Tue, Apr 28, 2020 at 10:29 AM Simon Glass  wrote:
>
> Hi Bin,
>
> On Mon, 27 Apr 2020 at 19:30, Bin Meng  wrote:
> >
> > Hi Simon,
> >
> > On Tue, Apr 28, 2020 at 1:02 AM Simon Glass  wrote:
> > >
> > > Move the alignment code into acpi_setup_base_tables() so that test and
> > > production code are in alignment.
> > >
> > > This brings x86/master into line with patch series v8.
> > >
> > > Signed-off-by: Simon Glass 
> > > ---
> > >
> > >  arch/x86/lib/acpi_table.c | 5 -
> > >  lib/acpi/acpi_table.c | 7 ++-
> > >  2 files changed, 6 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
> > > index 600bde2f5f..13f1409de8 100644
> > > --- a/arch/x86/lib/acpi_table.c
> > > +++ b/arch/x86/lib/acpi_table.c
> > > @@ -375,11 +375,6 @@ ulong write_acpi_tables(ulong start_addr)
> > > debug("ACPI: Writing ACPI tables at %lx\n", start_addr);
> > >
> > > acpi_setup_base_tables(ctx, start);
> > > -   /*
> > > -* Per ACPI spec, the FACS table address must be aligned to a 64 
> > > byte
> > > -* boundary (Windows checks this, but Linux does not).
> > > -*/
> > > -   acpi_align64(ctx);
> > >
> > > debug("ACPI:* FACS\n");
> > > facs = ctx->current;
> > > diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c
> > > index 5abf1cad50..1c253af3bf 100644
> > > --- a/lib/acpi/acpi_table.c
> > > +++ b/lib/acpi/acpi_table.c
> > > @@ -145,7 +145,7 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table)
> > > }
> > >
> > > if (i >= entries_num) {
> > > -   debug("ACPI: Error: too many tables\n");
> > > +   log_err("ACPI: Error: too many tables\n");
> > > return -E2BIG;
> > > }
> > >
> > > @@ -256,4 +256,9 @@ void acpi_setup_base_tables(struct acpi_ctx *ctx, 
> > > void *start)
> > > acpi_write_rsdp(ctx->rsdp, ctx->rsdt, ctx->xsdt);
> > > acpi_write_rsdt(ctx->rsdt);
> > > acpi_write_xsdt(ctx->xsdt);
> > > +   /*
> > > +* Per ACPI spec, the FACS table address must be aligned to a 64 
> > > byte
> > > +* boundary (Windows checks this, but Linux does not).
> > > +*/
> > > +   acpi_align64(ctx);
> > >  }
> > > --
> >
> > Could you please point out which commit in u-boot-x86/master should
> > squash in this patch to fix the build error on sandbox?
>
> It might be easier to pick up v8 in that case. I think there are three
> patches that need to change because of conflicts caused by the first
> one.
>
> So can you pick up the v8 patches? Also you do need to rebase on
> master because of the str_to_upper patches.

But v8 is a complete new series for part B? I think we'd better re-tag
v8 as v1. It's quite confusing.

Regards,
Bin


[PATCH 6/8] net: eqos: implement callbaks to get interface and set txclk rate

2020-04-27 Thread Peng Fan
From: Fugang Duan 

Implement the callbacks to get phy mode interface and txclk
rate configuration.

Reviewed-by: Ye Li 
Signed-off-by: Fugang Duan 
Signed-off-by: Peng Fan 
---
 drivers/net/dwc_eth_qos.c | 42 --
 1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
index d63ea5cfb4..85afaf124c 100644
--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -870,7 +871,7 @@ static ulong eqos_get_tick_clk_rate_stm32(struct udevice 
*dev)
 static ulong eqos_get_tick_clk_rate_imx(struct udevice *dev)
 {
/* TODO: retrieve from CSR clock */
-   return 100 * 100;
+   return imx_get_eqos_csr_clk();
 }
 
 static int eqos_calibrate_pads_stm32(struct udevice *dev)
@@ -996,6 +997,33 @@ static int eqos_set_tx_clk_speed_stm32(struct udevice *dev)
 
 static int eqos_set_tx_clk_speed_imx(struct udevice *dev)
 {
+   struct eqos_priv *eqos = dev_get_priv(dev);
+   ulong rate;
+   int ret;
+
+   debug("%s(dev=%p):\n", __func__, dev);
+
+   switch (eqos->phy->speed) {
+   case SPEED_1000:
+   rate = 125 * 1000 * 1000;
+   break;
+   case SPEED_100:
+   rate = 25 * 1000 * 1000;
+   break;
+   case SPEED_10:
+   rate = 2.5 * 1000 * 1000;
+   break;
+   default:
+   pr_err("invalid speed %d", eqos->phy->speed);
+   return -EINVAL;
+   }
+
+   ret = imx_eqos_txclk_set_rate(rate);
+   if (ret < 0) {
+   pr_err("imx (tx_clk, %lu) failed: %d", rate, ret);
+   return ret;
+   }
+
return 0;
 }
 
@@ -1865,7 +1893,17 @@ static int eqos_probe_resources_imx(struct udevice *dev)
 
 static phy_interface_t eqos_get_interface_imx(struct udevice *dev)
 {
-   return PHY_INTERFACE_MODE_RGMII;
+   const char *phy_mode;
+   phy_interface_t interface = PHY_INTERFACE_MODE_NONE;
+
+   debug("%s(dev=%p):\n", __func__, dev);
+
+   phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
+  NULL);
+   if (phy_mode)
+   interface = phy_get_interface_by_name(phy_mode);
+
+   return interface;
 }
 
 static int eqos_remove_resources_tegra186(struct udevice *dev)
-- 
2.16.4



[PATCH 8/8] eQos: Implement the read_rom_hwaddr callback

2020-04-27 Thread Peng Fan
From: Ye Li 

Implement the read_rom_hwaddr callback to load MAC address from fuse
for imx8m platforms.

Reviewed-by: Fugang Duan 
Signed-off-by: Ye Li 
Signed-off-by: Peng Fan 
---
 drivers/net/dwc_eth_qos.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
index 85afaf124c..37b279af35 100644
--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -43,6 +43,9 @@
 #include 
 #include 
 #include 
+#ifdef CONFIG_ARCH_IMX8M
+#include 
+#endif
 
 /* Core registers */
 
@@ -1134,6 +1137,16 @@ static int eqos_write_hwaddr(struct udevice *dev)
return 0;
 }
 
+static int eqos_read_rom_hwaddr(struct udevice *dev)
+{
+   struct eth_pdata *pdata = dev_get_platdata(dev);
+
+#ifdef CONFIG_ARCH_IMX8M
+   imx_get_mac_from_fuse(dev->req_seq, pdata->enetaddr);
+#endif
+   return !is_valid_ethaddr(pdata->enetaddr);
+}
+
 static int eqos_start(struct udevice *dev)
 {
struct eqos_priv *eqos = dev_get_priv(dev);
@@ -2047,6 +2060,7 @@ static const struct eth_ops eqos_ops = {
.recv = eqos_recv,
.free_pkt = eqos_free_pkt,
.write_hwaddr = eqos_write_hwaddr,
+   .read_rom_hwaddr= eqos_read_rom_hwaddr,
 };
 
 static struct eqos_ops eqos_tegra186_ops = {
-- 
2.16.4



[PATCH 7/8] fec: Move imx_get_mac_from_fuse declare to imx file

2020-04-27 Thread Peng Fan
From: Ye Li 

imx_get_mac_from_fuse is used to load MAC address from fuse. On imx8mp,
we have two different ENET controllers and both need to call this
function. So decouple its declare from fec driver.

Reviewed-by: Fugang Duan 
Signed-off-by: Ye Li 
Signed-off-by: Peng Fan 
---
 arch/arm/include/asm/mach-imx/sys_proto.h | 2 ++
 drivers/net/fec_mxc.h | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/mach-imx/sys_proto.h 
b/arch/arm/include/asm/mach-imx/sys_proto.h
index 35b39b1f86..ba930a2088 100644
--- a/arch/arm/include/asm/mach-imx/sys_proto.h
+++ b/arch/arm/include/asm/mach-imx/sys_proto.h
@@ -188,4 +188,6 @@ unsigned long call_imx_sip(unsigned long id, unsigned long 
reg0,
 unsigned long call_imx_sip_ret2(unsigned long id, unsigned long reg0,
unsigned long *reg1, unsigned long reg2,
unsigned long reg3);
+
+void imx_get_mac_from_fuse(int dev_id, unsigned char *mac);
 #endif
diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
index 159aec8967..18f7c727db 100644
--- a/drivers/net/fec_mxc.h
+++ b/drivers/net/fec_mxc.h
@@ -271,8 +271,6 @@ struct fec_priv {
u32 clk_rate;
 };
 
-void imx_get_mac_from_fuse(int dev_id, unsigned char *mac);
-
 /**
  * @brief Numbers of buffer descriptors for receiving
  *
-- 
2.16.4



[PATCH 5/8] net: dwc_eth_qos: add dwc eqos for imx support

2020-04-27 Thread Peng Fan
From: Fugang Duan 

Add dwc eqos for imx support.

Reviewed-by: Ye Li 
Signed-off-by: Fugang Duan 
Signed-off-by: Peng Fan 
---
 drivers/net/dwc_eth_qos.c | 187 ++
 1 file changed, 173 insertions(+), 14 deletions(-)

diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
index dc2299dd69..d63ea5cfb4 100644
--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -81,6 +81,7 @@ struct eqos_mac_regs {
 #define EQOS_MAC_CONFIGURATION_PS  BIT(15)
 #define EQOS_MAC_CONFIGURATION_FES BIT(14)
 #define EQOS_MAC_CONFIGURATION_DM  BIT(13)
+#define EQOS_MAC_CONFIGURATION_LM  BIT(12)
 #define EQOS_MAC_CONFIGURATION_TE  BIT(1)
 #define EQOS_MAC_CONFIGURATION_RE  BIT(0)
 
@@ -102,11 +103,19 @@ struct eqos_mac_regs {
 #define EQOS_MAC_RXQ_CTRL2_PSRQ0_SHIFT 0
 #define EQOS_MAC_RXQ_CTRL2_PSRQ0_MASK  0xff
 
+#define EQOS_MAC_HW_FEATURE0_MMCSEL_SHIFT  8
+#define EQOS_MAC_HW_FEATURE0_HDSEL_SHIFT   2
+#define EQOS_MAC_HW_FEATURE0_GMIISEL_SHIFT 1
+#define EQOS_MAC_HW_FEATURE0_MIISEL_SHIFT  0
+
 #define EQOS_MAC_HW_FEATURE1_TXFIFOSIZE_SHIFT  6
 #define EQOS_MAC_HW_FEATURE1_TXFIFOSIZE_MASK   0x1f
 #define EQOS_MAC_HW_FEATURE1_RXFIFOSIZE_SHIFT  0
 #define EQOS_MAC_HW_FEATURE1_RXFIFOSIZE_MASK   0x1f
 
+#define EQOS_MAC_HW_FEATURE3_ASP_SHIFT 28
+#define EQOS_MAC_HW_FEATURE3_ASP_MASK  0x3
+
 #define EQOS_MAC_MDIO_ADDRESS_PA_SHIFT 21
 #define EQOS_MAC_MDIO_ADDRESS_RDA_SHIFT16
 #define EQOS_MAC_MDIO_ADDRESS_CR_SHIFT 8
@@ -154,6 +163,8 @@ struct eqos_mtl_regs {
 #define EQOS_MTL_RXQ0_OPERATION_MODE_RFA_MASK  0x3f
 #define EQOS_MTL_RXQ0_OPERATION_MODE_EHFC  BIT(7)
 #define EQOS_MTL_RXQ0_OPERATION_MODE_RSF   BIT(5)
+#define EQOS_MTL_RXQ0_OPERATION_MODE_FEP   BIT(4)
+#define EQOS_MTL_RXQ0_OPERATION_MODE_FUP   BIT(3)
 
 #define EQOS_MTL_RXQ0_DEBUG_PRXQ_SHIFT 16
 #define EQOS_MTL_RXQ0_DEBUG_PRXQ_MASK  0x7fff
@@ -368,7 +379,7 @@ static void eqos_inval_desc_tegra186(void *desc)
 #endif
 }
 
-static void eqos_inval_desc_stm32(void *desc)
+static void eqos_inval_desc_generic(void *desc)
 {
 #ifndef CONFIG_SYS_NONCACHED_MEMORY
unsigned long start = rounddown((unsigned long)desc, ARCH_DMA_MINALIGN);
@@ -386,7 +397,7 @@ static void eqos_flush_desc_tegra186(void *desc)
 #endif
 }
 
-static void eqos_flush_desc_stm32(void *desc)
+static void eqos_flush_desc_generic(void *desc)
 {
 #ifndef CONFIG_SYS_NONCACHED_MEMORY
unsigned long start = rounddown((unsigned long)desc, ARCH_DMA_MINALIGN);
@@ -405,7 +416,7 @@ static void eqos_inval_buffer_tegra186(void *buf, size_t 
size)
invalidate_dcache_range(start, end);
 }
 
-static void eqos_inval_buffer_stm32(void *buf, size_t size)
+static void eqos_inval_buffer_generic(void *buf, size_t size)
 {
unsigned long start = rounddown((unsigned long)buf, ARCH_DMA_MINALIGN);
unsigned long end = roundup((unsigned long)buf + size,
@@ -419,7 +430,7 @@ static void eqos_flush_buffer_tegra186(void *buf, size_t 
size)
flush_cache((unsigned long)buf, size);
 }
 
-static void eqos_flush_buffer_stm32(void *buf, size_t size)
+static void eqos_flush_buffer_generic(void *buf, size_t size)
 {
unsigned long start = rounddown((unsigned long)buf, ARCH_DMA_MINALIGN);
unsigned long end = roundup((unsigned long)buf + size,
@@ -522,6 +533,7 @@ static int eqos_mdio_write(struct mii_dev *bus, int 
mdio_addr, int mdio_devad,
 
 static int eqos_start_clks_tegra186(struct udevice *dev)
 {
+#ifdef CONFIG_CLK
struct eqos_priv *eqos = dev_get_priv(dev);
int ret;
 
@@ -562,10 +574,12 @@ static int eqos_start_clks_tegra186(struct udevice *dev)
pr_err("clk_enable(clk_tx) failed: %d", ret);
goto err_disable_clk_ptp_ref;
}
+#endif
 
debug("%s: OK\n", __func__);
return 0;
 
+#ifdef CONFIG_CLK
 err_disable_clk_ptp_ref:
clk_disable(>clk_ptp_ref);
 err_disable_clk_rx:
@@ -577,10 +591,12 @@ err_disable_clk_slave_bus:
 err:
debug("%s: FAILED: %d\n", __func__, ret);
return ret;
+#endif
 }
 
 static int eqos_start_clks_stm32(struct udevice *dev)
 {
+#ifdef CONFIG_CLK
struct eqos_priv *eqos = dev_get_priv(dev);
int ret;
 
@@ -611,10 +627,12 @@ static int eqos_start_clks_stm32(struct udevice *dev)
goto err_disable_clk_tx;
}
}
+#endif
 
debug("%s: OK\n", __func__);
return 0;
 
+#ifdef CONFIG_CLK
 err_disable_clk_tx:
clk_disable(>clk_tx);
 err_disable_clk_rx:
@@ -624,10 +642,17 @@ err_disable_clk_master_bus:
 err:
debug("%s: FAILED: %d\n", 

[PATCH 2/8] net: Add eth phy generic driver for shared MDIO

2020-04-27 Thread Peng Fan
From: Ye Li 

For dual ethernet controllers, the HW design may connect ETH phys to
one MDIO ports. So two different ethernet drivers have to share MDIO bus.
Since two ethernet drivers are independent, we can't ensure their probe
order.

To resolve this problem, introduce an eth phy generic driver and uclass.

After eth-uclass binds, we search the mdio node and binds the phy node
with the eth-phy-generic driver.

When one eth driver get its phy device, the parent of phy device will
probe prior than phy device. So this ensure the eth driver ownes the
MDIO bus will be probed before using its MDIO.

Signed-off-by: Ye Li 
Signed-off-by: Peng Fan 
---
 drivers/net/Kconfig  |   6 +++
 drivers/net/Makefile |   1 +
 drivers/net/eth-phy-uclass.c | 122 ++
 include/dm/uclass-id.h   |   1 +
 include/eth_phy.h|  17 ++
 net/eth-uclass.c |   5 ++
 6 files changed, 152 insertions(+)
 create mode 100644 drivers/net/eth-phy-uclass.c
 create mode 100644 include/eth_phy.h

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 4d1013c984..d77bb221e0 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -57,6 +57,12 @@ config MDIO_MUX_SANDBOX
 
  This driver is used for testing in test/dm/mdio.c
 
+config DM_ETH_PHY
+   bool "Enable Driver Model for Ethernet Generic PHY drivers"
+   depends on DM
+   help
+ Enable driver model for Ethernet Generic PHY .
+
 menuconfig NETDEVICES
bool "Network device support"
depends on NET
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 6e0a68834d..f6c5ae4fe7 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_ETH_DESIGNWARE) += designware.o
 obj-$(CONFIG_ETH_DESIGNWARE_SOCFPGA) += dwmac_socfpga.o
 obj-$(CONFIG_DRIVER_DM9000) += dm9000x.o
 obj-$(CONFIG_DNET) += dnet.o
+obj-$(CONFIG_DM_ETH_PHY) += eth-phy-uclass.o
 obj-$(CONFIG_E1000) += e1000.o
 obj-$(CONFIG_E1000_SPI) += e1000_spi.o
 obj-$(CONFIG_EEPRO100) += eepro100.o
diff --git a/drivers/net/eth-phy-uclass.c b/drivers/net/eth-phy-uclass.c
new file mode 100644
index 00..e87c7aee80
--- /dev/null
+++ b/drivers/net/eth-phy-uclass.c
@@ -0,0 +1,122 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2020 NXP
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct eth_phy_device_priv {
+   struct mii_dev *mdio_bus;
+};
+
+int eth_phy_binds_nodes(struct udevice *eth_dev)
+{
+   ofnode mdio_node, phy_node;
+   const char *node_name;
+   int ret;
+
+   mdio_node = dev_read_subnode(eth_dev, "mdio");
+   if (!ofnode_valid(mdio_node)) {
+   debug("%s: %s mdio subnode not found!", __func__,
+ eth_dev->name);
+   return -ENXIO;
+   }
+
+   ofnode_for_each_subnode(phy_node, mdio_node) {
+   node_name = ofnode_get_name(phy_node);
+
+   debug("* Found child node: '%s'\n", node_name);
+
+   ret = device_bind_driver_to_node(eth_dev,
+"eth_phy_generic_drv",
+node_name, phy_node, NULL);
+   if (ret) {
+   debug("  - Eth phy binding error: %d\n", ret);
+   continue;
+   }
+
+   debug("  - bound phy device: '%s'\n", node_name);
+   }
+
+   return 0;
+}
+
+int eth_phy_set_mdio_bus(struct udevice *eth_dev, struct mii_dev *mdio_bus)
+{
+   struct udevice *dev;
+   struct eth_phy_device_priv *uc_priv;
+
+   for (uclass_first_device(UCLASS_ETH_PHY, ); dev;
+uclass_next_device()) {
+   if (dev->parent == eth_dev) {
+   uc_priv = (struct eth_phy_device_priv 
*)(dev->uclass_priv);
+
+   if (!uc_priv->mdio_bus)
+   uc_priv->mdio_bus = mdio_bus;
+   }
+   }
+
+   return 0;
+}
+
+struct mii_dev *eth_phy_get_mdio_bus(struct udevice *eth_dev)
+{
+   int ret;
+   struct udevice *phy_dev;
+   struct eth_phy_device_priv *uc_priv;
+
+   /* Will probe the parent of phy device, then phy device */
+   ret = uclass_get_device_by_phandle(UCLASS_ETH_PHY, eth_dev,
+  "phy-handle", _dev);
+   if (!ret) {
+   if (eth_dev != phy_dev->parent) {
+   /*
+* phy_dev is shared and controlled by
+* other eth controller
+*/
+   uc_priv = (struct eth_phy_device_priv 
*)(phy_dev->uclass_priv);
+   if (uc_priv->mdio_bus)
+   printf("Get shared mii bus on %s\n", 
eth_dev->name);
+   else
+   printf("Can't get shared mii bus on %s\n", 
eth_dev->name);
+
+   

[PATCH 3/8] net: Update eQos driver and FEC driver to use eth phy interfaces

2020-04-27 Thread Peng Fan
From: Ye Li 

Update eQoS and fec ethernet drivers to support shared MDIO framework

Signed-off-by: Ye Li 
Signed-off-by: Peng Fan 
---
 drivers/net/dwc_eth_qos.c | 45 +++--
 drivers/net/fec_mxc.c | 16 ++--
 2 files changed, 45 insertions(+), 16 deletions(-)

diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
index 63f2086dec..dc2299dd69 100644
--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* Core registers */
 
@@ -1083,7 +1084,14 @@ static int eqos_start(struct udevice *dev)
 * don't need to reconnect/reconfigure again
 */
if (!eqos->phy) {
-   eqos->phy = phy_connect(eqos->mii, eqos->phyaddr, dev,
+   int addr = -1;
+#ifdef CONFIG_DM_ETH_PHY
+   addr = eth_phy_get_addr(dev);
+#endif
+#ifdef DWC_NET_PHYADDR
+   addr = DWC_NET_PHYADDR;
+#endif
+   eqos->phy = phy_connect(eqos->mii, addr, dev,
eqos->config->interface(dev));
if (!eqos->phy) {
pr_err("phy_connect() failed");
@@ -1810,23 +1818,32 @@ static int eqos_probe(struct udevice *dev)
goto err_remove_resources_core;
}
 
-   eqos->mii = mdio_alloc();
+#ifdef CONFIG_DM_ETH_PHY
+   eqos->mii = eth_phy_get_mdio_bus(dev);
+#endif
if (!eqos->mii) {
-   pr_err("mdio_alloc() failed");
-   ret = -ENOMEM;
-   goto err_remove_resources_tegra;
-   }
-   eqos->mii->read = eqos_mdio_read;
-   eqos->mii->write = eqos_mdio_write;
-   eqos->mii->priv = eqos;
-   strcpy(eqos->mii->name, dev->name);
+   eqos->mii = mdio_alloc();
+   if (!eqos->mii) {
+   pr_err("mdio_alloc() failed");
+   ret = -ENOMEM;
+   goto err_remove_resources_tegra;
+   }
+   eqos->mii->read = eqos_mdio_read;
+   eqos->mii->write = eqos_mdio_write;
+   eqos->mii->priv = eqos;
+   strcpy(eqos->mii->name, dev->name);
 
-   ret = mdio_register(eqos->mii);
-   if (ret < 0) {
-   pr_err("mdio_register() failed: %d", ret);
-   goto err_free_mdio;
+   ret = mdio_register(eqos->mii);
+   if (ret < 0) {
+   pr_err("mdio_register() failed: %d", ret);
+   goto err_free_mdio;
+   }
}
 
+#ifdef CONFIG_DM_ETH_PHY
+   eth_phy_set_mdio_bus(dev, eqos->mii);
+#endif
+
debug("%s: OK\n", __func__);
return 0;
 
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index bc5b63d788..2c8f743a58 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -28,6 +28,7 @@
 #include 
 
 #include "fec_mxc.h"
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -1420,16 +1421,27 @@ static int fecmxc_probe(struct udevice *dev)
fec_reg_setup(priv);
 
priv->dev_id = dev->seq;
+
+#ifdef CONFIG_DM_ETH_PHY
+   bus = eth_phy_get_mdio_bus(dev);
+#endif
+
+   if (!bus) {
 #ifdef CONFIG_FEC_MXC_MDIO_BASE
-   bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE, dev->seq);
+   bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE, dev->seq);
 #else
-   bus = fec_get_miibus((ulong)priv->eth, dev->seq);
+   bus = fec_get_miibus((ulong)priv->eth, dev->seq);
 #endif
+   }
if (!bus) {
ret = -ENOMEM;
goto err_mii;
}
 
+#ifdef CONFIG_DM_ETH_PHY
+   eth_phy_set_mdio_bus(dev, bus);
+#endif
+
priv->bus = bus;
priv->interface = pdata->phy_interface;
switch (priv->interface) {
-- 
2.16.4



[PATCH 1/8] net: eth-uclass: add return value check

2020-04-27 Thread Peng Fan
Add return value check

Signed-off-by: Peng Fan 
---
 net/eth-uclass.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 8bf2eabe90..950a48d520 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -40,8 +40,12 @@ static int eth_errno;
 static struct eth_uclass_priv *eth_get_uclass_priv(void)
 {
struct uclass *uc;
+   int ret;
+
+   ret = uclass_get(UCLASS_ETH, );
+   if (ret)
+   return NULL;
 
-   uclass_get(UCLASS_ETH, );
assert(uc);
return uc->priv;
 }
@@ -102,6 +106,7 @@ struct udevice *eth_get_dev_by_name(const char *devname)
struct udevice *it;
struct uclass *uc;
int len = strlen("eth");
+   int ret;
 
/* Must be longer than 3 to be an alias */
if (!strncmp(devname, "eth", len) && strlen(devname) > len) {
@@ -109,7 +114,10 @@ struct udevice *eth_get_dev_by_name(const char *devname)
seq = simple_strtoul(startp, , 10);
}
 
-   uclass_get(UCLASS_ETH, );
+   ret = uclass_get(UCLASS_ETH, );
+   if (ret)
+   return NULL;
+
uclass_foreach_dev(it, uc) {
/*
 * We need the seq to be valid, so try to probe it.
-- 
2.16.4



[PATCH 4/8] net: phy: realtek: add rx delay support for RTL8211F

2020-04-27 Thread Peng Fan
From: Fugang Duan 

Add RX delay enable support for RTL8211F PHY.

Reviewed-by: Ye Li 
Signed-off-by: Fugang Duan 
Signed-off-by: Peng Fan 
---
 drivers/net/phy/realtek.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 8f1d759632..8f0a897a46 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -56,6 +56,7 @@
 
 #define MIIM_RTL8211F_PAGE_SELECT  0x1f
 #define MIIM_RTL8211F_TX_DELAY 0x100
+#define MIIM_RTL8211F_RX_DELAY 0x8
 #define MIIM_RTL8211F_LCR  0x10
 
 static int rtl8211f_phy_extread(struct phy_device *phydev, int addr,
@@ -183,6 +184,16 @@ static int rtl8211f_config(struct phy_device *phydev)
reg &= ~MIIM_RTL8211F_TX_DELAY;
 
phy_write(phydev, MDIO_DEVAD_NONE, 0x11, reg);
+
+   /* enable RX-delay for rgmii-id and rgmii-rxid, otherwise disable it */
+   reg = phy_read(phydev, MDIO_DEVAD_NONE, 0x15);
+   if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
+   phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID)
+   reg |= MIIM_RTL8211F_RX_DELAY;
+   else
+   reg &= ~MIIM_RTL8211F_RX_DELAY;
+   phy_write(phydev, MDIO_DEVAD_NONE, 0x15, reg);
+
/* restore to default page 0 */
phy_write(phydev, MDIO_DEVAD_NONE,
  MIIM_RTL8211F_PAGE_SELECT, 0x0);
-- 
2.16.4



[PATCH 0/8] net: several updates to support i.MX

2020-04-27 Thread Peng Fan
The patchset is to upstream NXP downstream network patches that
runs on i.MX platforms, including eqos update, sharded mdio support,
mac addr accessing and etc.

Fugang Duan (3):
  net: phy: realtek: add rx delay support for RTL8211F
  net: dwc_eth_qos: add dwc eqos for imx support
  net: eqos: implement callbaks to get interface and set txclk rate

Peng Fan (1):
  net: eth-uclass: add return value check

Ye Li (4):
  net: Add eth phy generic driver for shared MDIO
  net: Update eQos driver and FEC driver to use eth phy interfaces
  fec: Move imx_get_mac_from_fuse declare to imx file
  eQos: Implement the read_rom_hwaddr callback

 arch/arm/include/asm/mach-imx/sys_proto.h |   2 +
 drivers/net/Kconfig   |   6 +
 drivers/net/Makefile  |   1 +
 drivers/net/dwc_eth_qos.c | 284 +++---
 drivers/net/eth-phy-uclass.c  | 123 +
 drivers/net/fec_mxc.c |  16 +-
 drivers/net/fec_mxc.h |   2 -
 drivers/net/phy/realtek.c |  11 ++
 include/dm/uclass-id.h|   1 +
 include/eth_phy.h |  17 ++
 net/eth-uclass.c  |  17 +-
 11 files changed, 446 insertions(+), 34 deletions(-)
 create mode 100644 drivers/net/eth-phy-uclass.c
 create mode 100644 include/eth_phy.h

-- 
2.16.4



Re: [PATCH 3/3] acpi: Fix-up patch to correct sandbox test errors

2020-04-27 Thread Simon Glass
Hi Bin,

On Mon, 27 Apr 2020 at 19:30, Bin Meng  wrote:
>
> Hi Simon,
>
> On Tue, Apr 28, 2020 at 1:02 AM Simon Glass  wrote:
> >
> > Move the alignment code into acpi_setup_base_tables() so that test and
> > production code are in alignment.
> >
> > This brings x86/master into line with patch series v8.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >  arch/x86/lib/acpi_table.c | 5 -
> >  lib/acpi/acpi_table.c | 7 ++-
> >  2 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
> > index 600bde2f5f..13f1409de8 100644
> > --- a/arch/x86/lib/acpi_table.c
> > +++ b/arch/x86/lib/acpi_table.c
> > @@ -375,11 +375,6 @@ ulong write_acpi_tables(ulong start_addr)
> > debug("ACPI: Writing ACPI tables at %lx\n", start_addr);
> >
> > acpi_setup_base_tables(ctx, start);
> > -   /*
> > -* Per ACPI spec, the FACS table address must be aligned to a 64 
> > byte
> > -* boundary (Windows checks this, but Linux does not).
> > -*/
> > -   acpi_align64(ctx);
> >
> > debug("ACPI:* FACS\n");
> > facs = ctx->current;
> > diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c
> > index 5abf1cad50..1c253af3bf 100644
> > --- a/lib/acpi/acpi_table.c
> > +++ b/lib/acpi/acpi_table.c
> > @@ -145,7 +145,7 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table)
> > }
> >
> > if (i >= entries_num) {
> > -   debug("ACPI: Error: too many tables\n");
> > +   log_err("ACPI: Error: too many tables\n");
> > return -E2BIG;
> > }
> >
> > @@ -256,4 +256,9 @@ void acpi_setup_base_tables(struct acpi_ctx *ctx, void 
> > *start)
> > acpi_write_rsdp(ctx->rsdp, ctx->rsdt, ctx->xsdt);
> > acpi_write_rsdt(ctx->rsdt);
> > acpi_write_xsdt(ctx->xsdt);
> > +   /*
> > +* Per ACPI spec, the FACS table address must be aligned to a 64 
> > byte
> > +* boundary (Windows checks this, but Linux does not).
> > +*/
> > +   acpi_align64(ctx);
> >  }
> > --
>
> Could you please point out which commit in u-boot-x86/master should
> squash in this patch to fix the build error on sandbox?

It might be easier to pick up v8 in that case. I think there are three
patches that need to change because of conflicts caused by the first
one.

So can you pick up the v8 patches? Also you do need to rebase on
master because of the str_to_upper patches.

Regards,
Simon


[PATCHv3 8/8] configs: ls208xa: Enable GIC_V3_ITS config

2020-04-27 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Enable GIC_V3_ITS config to initialize the GIC redistributor
tables.

Signed-off-by: Hou Zhiqiang 
Reviewed-by: Wasim Khan 
---
V3:
 - No change.

 configs/ls2080aqds_SECURE_BOOT_defconfig  | 1 +
 configs/ls2080aqds_defconfig  | 1 +
 configs/ls2080aqds_nand_defconfig | 1 +
 configs/ls2080aqds_qspi_defconfig | 1 +
 configs/ls2080aqds_sdcard_defconfig   | 1 +
 configs/ls2080ardb_SECURE_BOOT_defconfig  | 1 +
 configs/ls2080ardb_defconfig  | 1 +
 configs/ls2080ardb_nand_defconfig | 1 +
 configs/ls2081ardb_defconfig  | 1 +
 configs/ls2088aqds_tfa_defconfig  | 1 +
 configs/ls2088ardb_qspi_SECURE_BOOT_defconfig | 1 +
 configs/ls2088ardb_qspi_defconfig | 1 +
 configs/ls2088ardb_tfa_SECURE_BOOT_defconfig  | 1 +
 configs/ls2088ardb_tfa_defconfig  | 1 +
 14 files changed, 14 insertions(+)

diff --git a/configs/ls2080aqds_SECURE_BOOT_defconfig 
b/configs/ls2080aqds_SECURE_BOOT_defconfig
index 8a792e449a..9039b252c1 100644
--- a/configs/ls2080aqds_SECURE_BOOT_defconfig
+++ b/configs/ls2080aqds_SECURE_BOOT_defconfig
@@ -62,3 +62,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2080aqds_defconfig b/configs/ls2080aqds_defconfig
index bc4c218c21..b14b3ca5e7 100644
--- a/configs/ls2080aqds_defconfig
+++ b/configs/ls2080aqds_defconfig
@@ -63,3 +63,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2080aqds_nand_defconfig 
b/configs/ls2080aqds_nand_defconfig
index e840cbf0ef..fac2b04068 100644
--- a/configs/ls2080aqds_nand_defconfig
+++ b/configs/ls2080aqds_nand_defconfig
@@ -70,3 +70,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2080aqds_qspi_defconfig 
b/configs/ls2080aqds_qspi_defconfig
index 861e652f7f..343c7675e0 100644
--- a/configs/ls2080aqds_qspi_defconfig
+++ b/configs/ls2080aqds_qspi_defconfig
@@ -62,3 +62,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2080aqds_sdcard_defconfig 
b/configs/ls2080aqds_sdcard_defconfig
index 864e70d334..dd2862ffe0 100644
--- a/configs/ls2080aqds_sdcard_defconfig
+++ b/configs/ls2080aqds_sdcard_defconfig
@@ -69,3 +69,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2080ardb_SECURE_BOOT_defconfig 
b/configs/ls2080ardb_SECURE_BOOT_defconfig
index 4abfc64705..743e25f7b7 100644
--- a/configs/ls2080ardb_SECURE_BOOT_defconfig
+++ b/configs/ls2080ardb_SECURE_BOOT_defconfig
@@ -64,3 +64,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2080ardb_defconfig b/configs/ls2080ardb_defconfig
index 0102e14ecb..e9dfc3603e 100644
--- a/configs/ls2080ardb_defconfig
+++ b/configs/ls2080ardb_defconfig
@@ -65,3 +65,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2080ardb_nand_defconfig 
b/configs/ls2080ardb_nand_defconfig
index 448e0fe58d..68ec26e405 100644
--- a/configs/ls2080ardb_nand_defconfig
+++ b/configs/ls2080ardb_nand_defconfig
@@ -70,3 +70,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2081ardb_defconfig b/configs/ls2081ardb_defconfig
index e446a1120b..4036ed94e5 100644
--- a/configs/ls2081ardb_defconfig
+++ b/configs/ls2081ardb_defconfig
@@ -62,3 +62,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2088aqds_tfa_defconfig b/configs/ls2088aqds_tfa_defconfig
index 9f49736b4f..d3ee37cabe 100644
--- a/configs/ls2088aqds_tfa_defconfig
+++ b/configs/ls2088aqds_tfa_defconfig
@@ -74,3 +74,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig 
b/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig
index ae4a6820ff..9b06bf4257 100644
--- a/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig
@@ -59,3 +59,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2088ardb_qspi_defconfig 
b/configs/ls2088ardb_qspi_defconfig
index 1ad5f3b367..3203384c5b 100644
--- a/configs/ls2088ardb_qspi_defconfig
+++ b/configs/ls2088ardb_qspi_defconfig
@@ -63,3 +63,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 

[PATCHv3 7/8] configs: ls1028a: Enable GIC_V3_ITS config

2020-04-27 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Enable GIC_V3_ITS config to initialize the GIC redistributor
tables.

Signed-off-by: Hou Zhiqiang 
Reviewed-by: Wasim Khan 
---
V3:
 - No change.

 configs/ls1028aqds_tfa_SECURE_BOOT_defconfig | 1 +
 configs/ls1028aqds_tfa_defconfig | 1 +
 configs/ls1028ardb_tfa_SECURE_BOOT_defconfig | 1 +
 configs/ls1028ardb_tfa_defconfig | 1 +
 4 files changed, 4 insertions(+)

diff --git a/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig 
b/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig
index c5f0bd85da..92b944f426 100644
--- a/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig
@@ -79,3 +79,4 @@ CONFIG_WDT_SP805=y
 CONFIG_RSA=y
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1028aqds_tfa_defconfig b/configs/ls1028aqds_tfa_defconfig
index 7085be77fe..66d3ee1761 100644
--- a/configs/ls1028aqds_tfa_defconfig
+++ b/configs/ls1028aqds_tfa_defconfig
@@ -84,3 +84,4 @@ CONFIG_WDT=y
 CONFIG_WDT_SP805=y
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig 
b/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig
index 6fa14af6af..c999f3e6ef 100644
--- a/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig
@@ -76,3 +76,4 @@ CONFIG_WDT_SP805=y
 CONFIG_RSA=y
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1028ardb_tfa_defconfig b/configs/ls1028ardb_tfa_defconfig
index 7ffd1c3bc6..2224a1554c 100644
--- a/configs/ls1028ardb_tfa_defconfig
+++ b/configs/ls1028ardb_tfa_defconfig
@@ -85,3 +85,4 @@ CONFIG_WDT=y
 CONFIG_WDT_SP805=y
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
-- 
2.17.1



[PATCHv3 6/8] configs: ls1088a: Enable GIC_V3_ITS config

2020-04-27 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Enable GIC_V3_ITS config to initialize the GIC redistributor
tables.

Signed-off-by: Hou Zhiqiang 
Reviewed-by: Wasim Khan 
---
V3:
 - No change.

 configs/ls1088aqds_defconfig | 1 +
 configs/ls1088aqds_qspi_SECURE_BOOT_defconfig| 1 +
 configs/ls1088aqds_qspi_defconfig| 1 +
 configs/ls1088aqds_sdcard_ifc_defconfig  | 1 +
 configs/ls1088aqds_sdcard_qspi_defconfig | 1 +
 configs/ls1088aqds_tfa_defconfig | 1 +
 configs/ls1088ardb_qspi_SECURE_BOOT_defconfig| 1 +
 configs/ls1088ardb_qspi_defconfig| 1 +
 configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig | 1 +
 configs/ls1088ardb_sdcard_qspi_defconfig | 1 +
 configs/ls1088ardb_tfa_SECURE_BOOT_defconfig | 1 +
 configs/ls1088ardb_tfa_defconfig | 1 +
 12 files changed, 12 insertions(+)

diff --git a/configs/ls1088aqds_defconfig b/configs/ls1088aqds_defconfig
index 7713e58bbe..b1b74f9af4 100644
--- a/configs/ls1088aqds_defconfig
+++ b/configs/ls1088aqds_defconfig
@@ -59,3 +59,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig 
b/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
index 242c40b8b5..943b914e01 100644
--- a/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
@@ -60,3 +60,4 @@ CONFIG_USB_GADGET=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088aqds_qspi_defconfig 
b/configs/ls1088aqds_qspi_defconfig
index 3649b06a75..490782ebfc 100644
--- a/configs/ls1088aqds_qspi_defconfig
+++ b/configs/ls1088aqds_qspi_defconfig
@@ -61,3 +61,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_GADGET=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088aqds_sdcard_ifc_defconfig 
b/configs/ls1088aqds_sdcard_ifc_defconfig
index 815ea5ce4a..a4c6b27a3d 100644
--- a/configs/ls1088aqds_sdcard_ifc_defconfig
+++ b/configs/ls1088aqds_sdcard_ifc_defconfig
@@ -67,3 +67,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088aqds_sdcard_qspi_defconfig 
b/configs/ls1088aqds_sdcard_qspi_defconfig
index 275dbf9e0e..435f704eb3 100644
--- a/configs/ls1088aqds_sdcard_qspi_defconfig
+++ b/configs/ls1088aqds_sdcard_qspi_defconfig
@@ -70,3 +70,4 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_GADGET=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088aqds_tfa_defconfig b/configs/ls1088aqds_tfa_defconfig
index 1144cba983..5c2a699849 100644
--- a/configs/ls1088aqds_tfa_defconfig
+++ b/configs/ls1088aqds_tfa_defconfig
@@ -78,3 +78,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_GADGET=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig 
b/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig
index 3f654e2e1d..89e9a46c4f 100644
--- a/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig
@@ -61,3 +61,4 @@ CONFIG_USB_GADGET=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088ardb_qspi_defconfig 
b/configs/ls1088ardb_qspi_defconfig
index 935d76b4be..3c2fda4593 100644
--- a/configs/ls1088ardb_qspi_defconfig
+++ b/configs/ls1088ardb_qspi_defconfig
@@ -62,3 +62,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_GADGET=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig 
b/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig
index 562cbdd3ab..da41ccaa29 100644
--- a/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig
@@ -70,3 +70,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_RSA=y
 CONFIG_SPL_RSA=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088ardb_sdcard_qspi_defconfig 
b/configs/ls1088ardb_sdcard_qspi_defconfig
index 1e6fdceca1..0483e5d8d2 100644
--- a/configs/ls1088ardb_sdcard_qspi_defconfig
+++ b/configs/ls1088ardb_sdcard_qspi_defconfig
@@ -71,3 +71,4 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_GADGET=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088ardb_tfa_SECURE_BOOT_defconfig 
b/configs/ls1088ardb_tfa_SECURE_BOOT_defconfig
index 0086039e52..079e6c53fb 100644
--- a/configs/ls1088ardb_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1088ardb_tfa_SECURE_BOOT_defconfig
@@ -71,3 +71,4 @@ CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088ardb_tfa_defconfig b/configs/ls1088ardb_tfa_defconfig
index a7908e95b5..e3d4b02d21 100644
--- a/configs/ls1088ardb_tfa_defconfig
+++ 

[PATCHv3 5/8] arm64: layerscape: Move GIC RD tables initialization to CPU setup function

2020-04-27 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Move GIC redistributor tables initialization to CPU setup function.

This patch introduces a GIC redistributor tables init function, and
moves the function of reserving memory for GIC redistributor tables
to soc.c and adds a argument for the memory size to reserve, BTW
rename the function so that it is more readable.

Signed-off-by: Hou Zhiqiang 
Reviewed-by: Wasim Khan 
---
V3:
 - No change.

 arch/arm/cpu/armv8/fsl-layerscape/fdt.c   |  4 ++
 arch/arm/cpu/armv8/fsl-layerscape/soc.c   | 44 +++
 .../arm/include/asm/arch-fsl-layerscape/soc.h |  4 ++
 board/freescale/lx2160a/lx2160a.c | 30 -
 4 files changed, 52 insertions(+), 30 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c 
b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
index 077438765c..3bbad827cb 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
@@ -471,6 +471,10 @@ void ft_cpu_setup(void *blob, bd_t *bd)
do_fixup_by_path_u32(blob, "/sysclk", "clock-frequency",
 CONFIG_SYS_CLK_FREQ, 1);
 
+#ifdef CONFIG_GIC_V3_ITS
+   ls_gic_rd_tables_init(blob);
+#endif
+
 #if defined(CONFIG_PCIE_LAYERSCAPE) || defined(CONFIG_PCIE_LAYERSCAPE_GEN4)
ft_pci_setup(blob, bd);
 #endif
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c 
b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index d0e10cb007..28bb1d7401 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -6,10 +6,12 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -17,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #ifdef CONFIG_LAYERSCAPE_NS_ACCESS
 #include 
 #endif
@@ -30,9 +33,50 @@
 #include 
 #ifdef CONFIG_TFABOOT
 #include 
+#endif
+#if defined(CONFIG_TFABOOT) || defined(CONFIG_GIC_V3_ITS)
 DECLARE_GLOBAL_DATA_PTR;
 #endif
 
+#ifdef CONFIG_GIC_V3_ITS
+#define PENDTABLE_MAX_SZ   ALIGN(BIT(ITS_MAX_LPI_NRBITS), SZ_64K)
+#define PROPTABLE_MAX_SZ   ALIGN(BIT(ITS_MAX_LPI_NRBITS) / 8, SZ_64K)
+#define GIC_LPI_SIZE   ALIGN(cpu_numcores() * PENDTABLE_MAX_SZ + \
+   PROPTABLE_MAX_SZ, SZ_1M)
+static int fdt_add_resv_mem_gic_rd_tables(void *blob, u64 base, size_t size)
+{
+   u32 phandle;
+   int err;
+   struct fdt_memory gic_rd_tables;
+
+   gic_rd_tables.start = base;
+   gic_rd_tables.end = base + size - 1;
+   err = fdtdec_add_reserved_memory(blob, "gic-rd-tables", _rd_tables,
+);
+   if (err < 0)
+   debug("%s: failed to add reserved memory: %d\n", __func__, err);
+
+   return err;
+}
+
+int ls_gic_rd_tables_init(void *blob)
+{
+   u64 gic_lpi_base;
+   int ret;
+
+   gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
+   ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, GIC_LPI_SIZE);
+   if (ret)
+   return ret;
+
+   ret = gic_lpi_tables_init(gic_lpi_base, cpu_numcores());
+   if (ret)
+   debug("%s: failed to init gic-lpi-tables\n", __func__);
+
+   return ret;
+}
+#endif
+
 bool soc_has_dp_ddr(void)
 {
struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/soc.h 
b/arch/arm/include/asm/arch-fsl-layerscape/soc.h
index c62d414aac..020548ac6c 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/soc.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/soc.h
@@ -158,6 +158,10 @@ void erratum_a010315(void);
 
 bool soc_has_dp_ddr(void);
 bool soc_has_aiop(void);
+
+#ifdef CONFIG_GIC_V3_ITS
+int ls_gic_rd_tables_init(void *blob);
+#endif
 #endif
 
 #endif /* _ASM_ARMV8_FSL_LAYERSCAPE_SOC_H_ */
diff --git a/board/freescale/lx2160a/lx2160a.c 
b/board/freescale/lx2160a/lx2160a.c
index 5da74aab3c..0d94107def 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -16,7 +16,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -30,14 +29,11 @@
 #include "../common/vid.h"
 #include 
 #include 
-#include 
-#include 
 
 #ifdef CONFIG_EMC2305
 #include "../common/emc2305.h"
 #endif
 
-#define GIC_LPI_SIZE 0x20
 #ifdef CONFIG_TARGET_LX2160AQDS
 #define CFG_MUX_I2C_SDHC(reg, value)   ((reg & 0x3f) | value)
 #define SET_CFG_MUX1_SDHC1_SDHC(reg)   (reg & 0x3f)
@@ -645,23 +641,6 @@ void board_quiesce_devices(void)
 }
 #endif
 
-#ifdef CONFIG_GIC_V3_ITS
-int fdt_fixup_gic_lpi_memory(void *blob, u64 gic_lpi_base)
-{
-   u32 phandle;
-   int err;
-   struct fdt_memory gic_lpi;
-
-   gic_lpi.start = gic_lpi_base;
-   gic_lpi.end = gic_lpi_base + GIC_LPI_SIZE - 1;
-   err = fdtdec_add_reserved_memory(blob, "gic-lpi", _lpi, );
-   if (err < 0)
-   debug("failed to add reserved memory: %d\n", err);
-
-   

[PATCHv3 4/8] fsl-layerscape: Kconfig: Select RESV_RAM config if GIC_V3_ITS is enabled

2020-04-27 Thread Zhiqiang Hou
From: Hou Zhiqiang 

The GIC redistributor tables initialization depends on RESV_RAM config,
so select RESV_RAM if GIC_V3_ITS is enabled.

Signed-off-by: Hou Zhiqiang 
Reviewed-by: Wasim Khan 
---
V3:
 - No change.

 arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig 
b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
index b25639183f..2f75b2cdd3 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
+++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
@@ -46,6 +46,7 @@ config ARCH_LS1028A
select SYS_FSL_ERRATUM_A009663 if !TFABOOT
select SYS_FSL_ERRATUM_A009942 if !TFABOOT
select SYS_FSL_ERRATUM_A050382
+   select RESV_RAM if GIC_V3_ITS
imply PANIC_HANG
 
 config ARCH_LS1043A
@@ -152,6 +153,7 @@ config ARCH_LS1088A
select SYS_I2C_MXC_I2C2 if !TFABOOT
select SYS_I2C_MXC_I2C3 if !TFABOOT
select SYS_I2C_MXC_I2C4 if !TFABOOT
+   select RESV_RAM if GIC_V3_ITS
imply SCSI
imply PANIC_HANG
 
@@ -202,6 +204,7 @@ config ARCH_LS2080A
select SYS_I2C_MXC_I2C2 if !TFABOOT
select SYS_I2C_MXC_I2C3 if !TFABOOT
select SYS_I2C_MXC_I2C4 if !TFABOOT
+   select RESV_RAM if GIC_V3_ITS
imply DISTRO_DEFAULTS
imply PANIC_HANG
 
@@ -229,6 +232,7 @@ config ARCH_LX2160A
select ARCH_EARLY_INIT_R
select BOARD_EARLY_INIT_F
select SYS_I2C_MXC
+   select RESV_RAM if GIC_V3_ITS
imply DISTRO_DEFAULTS
imply PANIC_HANG
imply SCSI
-- 
2.17.1



[PATCHv3 3/8] board: lx2160a: Make sure the RD tables address align to 64KB

2020-04-27 Thread Zhiqiang Hou
From: Hou Zhiqiang 

As the lower 16bit of the redistributor pending table is reserved
for describing the memory attributes, we must give a 64KB aligned
address to the GIC LPI initialization function.

Signed-off-by: Hou Zhiqiang 
Reviewed-by: Wasim Khan 
---
V3:
 - No change.

 board/freescale/lx2160a/lx2160a.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/board/freescale/lx2160a/lx2160a.c 
b/board/freescale/lx2160a/lx2160a.c
index eafd530763..5da74aab3c 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -694,7 +695,7 @@ int ft_board_setup(void *blob, bd_t *bd)
}
 
 #ifdef CONFIG_GIC_V3_ITS
-   gic_lpi_base = gd->arch.resv_ram - GIC_LPI_SIZE;
+   gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
ret = fdt_fixup_gic_lpi_memory(blob, gic_lpi_base);
if (!ret && gic_lpi_tables_init(gic_lpi_base, cpu_numcores()))
debug("%s: failed to init gic-lpi-tables\n", __func__);
-- 
2.17.1



[PATCHv3 0/8] fsl: layerscape: Initialize the GIC redistributor

2020-04-27 Thread Zhiqiang Hou
From: Hou Zhiqiang 

This patch set is to initialize the GIC redistributor tables and add the
tables to kernel DT's reserved memeory node.

Hou Zhiqiang (8):
  arm64: fsl-layerscape: Assign addr to resv_ram if enabled RESV_RAM
config
  board: lx2160a: Don't program the GIC RD tables if failed to reserve
memory
  board: lx2160a: Make sure the RD tables address align to 64KB
  fsl-layerscape: Kconfig: Select RESV_RAM config if GIC_V3_ITS is
enabled
  arm64: layerscape: Move GIC RD tables initialization to CPU setup
function
  configs: ls1088a: Enable GIC_V3_ITS config
  configs: ls1028a: Enable GIC_V3_ITS config
  configs: ls208xa: Enable GIC_V3_ITS config

 arch/arm/cpu/armv8/fsl-layerscape/Kconfig |  4 ++
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c   |  8 ++--
 arch/arm/cpu/armv8/fsl-layerscape/fdt.c   |  4 ++
 arch/arm/cpu/armv8/fsl-layerscape/soc.c   | 44 +++
 .../arm/include/asm/arch-fsl-layerscape/soc.h |  4 ++
 board/freescale/lx2160a/lx2160a.c | 25 ---
 configs/ls1028aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1028aqds_tfa_defconfig  |  1 +
 configs/ls1028ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1028ardb_tfa_defconfig  |  1 +
 configs/ls1088aqds_defconfig  |  1 +
 configs/ls1088aqds_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088aqds_qspi_defconfig |  1 +
 configs/ls1088aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1088aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1088aqds_tfa_defconfig  |  1 +
 configs/ls1088ardb_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088ardb_qspi_defconfig |  1 +
 ...1088ardb_sdcard_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088ardb_sdcard_qspi_defconfig  |  1 +
 configs/ls1088ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1088ardb_tfa_defconfig  |  1 +
 configs/ls2080aqds_SECURE_BOOT_defconfig  |  1 +
 configs/ls2080aqds_defconfig  |  1 +
 configs/ls2080aqds_nand_defconfig |  1 +
 configs/ls2080aqds_qspi_defconfig |  1 +
 configs/ls2080aqds_sdcard_defconfig   |  1 +
 configs/ls2080ardb_SECURE_BOOT_defconfig  |  1 +
 configs/ls2080ardb_defconfig  |  1 +
 configs/ls2080ardb_nand_defconfig |  1 +
 configs/ls2081ardb_defconfig  |  1 +
 configs/ls2088aqds_tfa_defconfig  |  1 +
 configs/ls2088ardb_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls2088ardb_qspi_defconfig |  1 +
 configs/ls2088ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls2088ardb_tfa_defconfig  |  1 +
 36 files changed, 90 insertions(+), 29 deletions(-)

-- 
2.17.1



[PATCHv3 2/8] board: lx2160a: Don't program the GIC RD tables if failed to reserve memory

2020-04-27 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Program the GIC redistributor tables only when succeeded to reserve memory
for them, otherwise kernel will lose the chance to program them using
allocated memory.

Signed-off-by: Hou Zhiqiang 
---
V3:
 - Change the return type to int of fdt_fixup_gic_lpi_memory().

 board/freescale/lx2160a/lx2160a.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/board/freescale/lx2160a/lx2160a.c 
b/board/freescale/lx2160a/lx2160a.c
index 23ea1b6f16..eafd530763 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -645,7 +645,7 @@ void board_quiesce_devices(void)
 #endif
 
 #ifdef CONFIG_GIC_V3_ITS
-void fdt_fixup_gic_lpi_memory(void *blob, u64 gic_lpi_base)
+int fdt_fixup_gic_lpi_memory(void *blob, u64 gic_lpi_base)
 {
u32 phandle;
int err;
@@ -656,6 +656,8 @@ void fdt_fixup_gic_lpi_memory(void *blob, u64 gic_lpi_base)
err = fdtdec_add_reserved_memory(blob, "gic-lpi", _lpi, );
if (err < 0)
debug("failed to add reserved memory: %d\n", err);
+
+   return err;
 }
 #endif
 
@@ -671,6 +673,7 @@ int ft_board_setup(void *blob, bd_t *bd)
u64 mc_memory_size = 0;
u16 total_memory_banks;
u64 __maybe_unused gic_lpi_base;
+   int ret;
 
ft_cpu_setup(blob, bd);
 
@@ -692,8 +695,9 @@ int ft_board_setup(void *blob, bd_t *bd)
 
 #ifdef CONFIG_GIC_V3_ITS
gic_lpi_base = gd->arch.resv_ram - GIC_LPI_SIZE;
-   gic_lpi_tables_init(gic_lpi_base, cpu_numcores());
-   fdt_fixup_gic_lpi_memory(blob, gic_lpi_base);
+   ret = fdt_fixup_gic_lpi_memory(blob, gic_lpi_base);
+   if (!ret && gic_lpi_tables_init(gic_lpi_base, cpu_numcores()))
+   debug("%s: failed to init gic-lpi-tables\n", __func__);
 #endif
 
 #ifdef CONFIG_RESV_RAM
-- 
2.17.1



[PATCHv3 1/8] arm64: fsl-layerscape: Assign addr to resv_ram if enabled RESV_RAM config

2020-04-27 Thread Zhiqiang Hou
From: Hou Zhiqiang 

The initialization of gd->arch.resv_ram pointer should depend on if the
RESV_RAM config is enabled.

Signed-off-by: Hou Zhiqiang 
---
V3:
 - No change.

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c 
b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index b443894453..1b7729c046 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -1379,7 +1379,7 @@ static int tfa_dram_init_banksize(void)
if (i > 0)
ret = 0;
 
-#if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
+#if defined(CONFIG_RESV_RAM) && !defined(CONFIG_SPL_BUILD)
/* Assign memory for MC */
 #ifdef CONFIG_SYS_DDR_BLOCK3_BASE
if (gd->bd->bi_dram[2].size >=
@@ -1402,7 +1402,7 @@ static int tfa_dram_init_banksize(void)
board_reserve_ram_top(gd->bd->bi_dram[0].size);
}
}
-#endif /* CONFIG_FSL_MC_ENET */
+#endif /* CONFIG_RESV_RAM */
 
return ret;
 }
@@ -1465,7 +1465,7 @@ int dram_init_banksize(void)
}
 #endif /* CONFIG_SYS_MEM_RESERVE_SECURE */
 
-#if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
+#if defined(CONFIG_RESV_RAM) && !defined(CONFIG_SPL_BUILD)
/* Assign memory for MC */
 #ifdef CONFIG_SYS_DDR_BLOCK3_BASE
if (gd->bd->bi_dram[2].size >=
@@ -1488,7 +1488,7 @@ int dram_init_banksize(void)
board_reserve_ram_top(gd->bd->bi_dram[0].size);
}
}
-#endif /* CONFIG_FSL_MC_ENET */
+#endif /* CONFIG_RESV_RAM */
 
 #ifdef CONFIG_SYS_DP_DDR_BASE_PHY
 #ifdef CONFIG_SYS_DDR_BLOCK3_BASE
-- 
2.17.1



Updating using FIT images to SPI NOR and eMMC

2020-04-27 Thread Aaron Williams
Hi all,

I am looking at using FIT images to update the various blobs in our SPI NOR 
and eMMC devices since various blobs must be placed at specific addresses. 
Right now it looks like this update support is limited to CFI flash. Does 
anyone have any thoughts on extending this to SPI NOR and eMMC?

Our SOCs have a specific flash layout with a number of blob locations dictated 
by hardware, especially for secure booting.

-Aaron




Re: [PATCH 09/10] tools: add mkeficapsule command for UEFI capsule update test

2020-04-27 Thread AKASHI Takahiro
On Mon, Apr 27, 2020 at 10:15:41PM +0200, Heinrich Schuchardt wrote:
> On 4/27/20 11:48 AM, AKASHI Takahiro wrote:
> > This is a utility mainly for test purpose.
> >   mkeficapsule -f: create a test capsule file for FIT image firmware
> >
> > Having said that, you will be able to customize the code to fit
> > your specific requirements for your platform.
> >
> > Signed-off-by: AKASHI Takahiro 
> > ---
> >  tools/Makefile   |   3 +
> >  tools/mkeficapsule.c | 209 +++
> >  2 files changed, 212 insertions(+)
> >  create mode 100644 tools/mkeficapsule.c
> >
> > diff --git a/tools/Makefile b/tools/Makefile
> > index c2b26340047a..08e97063d5fa 100644
> > --- a/tools/Makefile
> > +++ b/tools/Makefile
> > @@ -222,6 +222,9 @@ hostprogs-$(CONFIG_MIPS) += mips-relocs
> >  hostprogs-$(CONFIG_ASN1_COMPILER)  += asn1_compiler
> >  HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include
> >
> > +# TODO: only build this for capsule pytest
> 
> Do you plan to send a new version of the series to fix this issue?

No.

> We need a documentation page for this tool in doc/uefi/.

Even currently used only in a test?

> Best regards
> 
> Heinrich
> 
> > +hostprogs-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += mkeficapsule
> > +
> >  # We build some files with extra pedantic flags to try to minimize things
> >  # that won't build on some weird host compiler -- though there are lots of
> >  # exceptions for files that aren't complaint.
> > diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c
> > new file mode 100644
> > index ..b26c88e42020
> > --- /dev/null
> > +++ b/tools/mkeficapsule.c
> > @@ -0,0 +1,209 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright 2018 Linaro Limited
> > + * Author: AKASHI Takahiro
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +/*
> > + * TODO: use libefi/libgnuefi headers
> 
> Can't you use the definitions from include/efi_api.h?
> I would prefer if you could avoid duplicate definitions in this file.

Including efi.h and efi_api.h causes a bunch of compiler errors.
But now I could sort them out.
Will fix in the next version.

Thanks,
-Takahiro Akashi


> Best regards
> 
> Heinrich
> 
> > + */
> > +
> > +typedef u_int8_t u8;
> > +typedef u_int16_t u16;
> > +typedef u_int32_t u32;
> > +typedef u_int64_t u64;
> > +
> > +/* include/efi.h */
> > +typedef struct {
> > +   u8 b[16];
> > +} efi_guid_t;
> > +
> > +#define EFI_GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
> > +   {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, \
> > +   ((a) >> 24) & 0xff, \
> > +   (b) & 0xff, ((b) >> 8) & 0xff, \
> > +   (c) & 0xff, ((c) >> 8) & 0xff, \
> > +   (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) } }
> > +
> > +#define EFI_VARIABLE_NON_VOLATILE  0x0001
> > +#define EFI_VARIABLE_BOOTSERVICE_ACCESS0x0002
> > +#define EFI_VARIABLE_RUNTIME_ACCESS0x0004
> > +
> > +/* include/efi_api.h */
> > +#define EFI_GLOBAL_VARIABLE_GUID \
> > +   EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, \
> > +0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c)
> > +
> > +#define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x0001
> > +#define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE0x0002
> > +#define CAPSULE_FLAGS_INITIATE_RESET   0x0004
> > +
> > +#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID \
> > +   EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \
> > +0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47)
> > +
> > +#define EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID \
> > +   EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \
> > +0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)
> > +
> > +struct efi_capsule_header {
> > +   efi_guid_t capsule_guid;
> > +   u32 header_size;
> > +   u32 flags;
> > +   u32 capsule_image_size;
> > +} __attribute__((packed));
> > +
> > +struct efi_capsule_block_descriptor {
> > +   u64 length;
> > +   union {
> > +   u64 data_block;
> > +   u64 continuation_ptr;
> > +   };
> > +} __attribute__((packed));
> > +
> > +struct efi_firmware_management_capsule_header {
> > +   u32 version;
> > +   u16 embedded_driver_count;
> > +   u16 payload_item_count;
> > +   u64 item_offset_list[];
> > +} __attribute__((packed));
> > +
> > +struct efi_firmware_management_capsule_image_header {
> > +   u32 version;
> > +   efi_guid_t update_image_type_id;
> > +   u8 update_image_index;
> > +   u8 reserved[3];
> > +   u32 update_image_size;
> > +   u32 update_vendor_code_size;
> > +   u64 update_hardware_instance;
> > +} __attribute__((packed));
> > +
> > +efi_guid_t efi_guid_fm_capsule = EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID;
> > +efi_guid_t efi_guid_image_type_uboot_fit =
> > +   EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID;
> > +
> > +static int create_fwbin(char *bin, char *path)
> > +{
> > +   struct efi_capsule_header header;
> > +   struct efi_firmware_management_capsule_header capsule;
> > +   

Please pull NXP i.MX nxp-imx-4-28

2020-04-27 Thread Peng Fan
Hi Stefano,

Please pull this version nxp-imx-20200422, with patches sent out to ML.
Based on yours master branch. Please see whether you are ok with
this patchset. I take Marek's one patch in the patchset, and all
patches have Fabio's R-b tag applied.

CI: https://travis-ci.org/github/MrVan/u-boot/builds/679980391

Sorry for this late pull request.

---
SCFW API update, including seco/snvs
SNVS support for i.MX8
A53 clk fixes for i.MX8MQ
Speed grade updating
i.MX8M variants support
misc clk update
acquire ATF build info
---

Thanks,
Peng.


The following changes since commit d1bbf833aa7b45c00a42227b9563134643e44237:

  Merge branch 'master' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx 
(2020-04-20 08:45:27 -0400)

are available in the Git repository at:

  https://github.com/MrVan/u-boot.git tags/nxp-imx-4-28

for you to fetch changes up to 98555c2bd835254866581098f5b0fb8d6218e1b6:

  imx8: Configure SNVS (2020-04-28 10:00:36 +0800)


Breno Lima (2):
  doc: ahab: Add encrypted boot documentation for i.MX8/8x devices
  imx8: scu api: Add support for SECO manufacturing protection APIs

Franck LENORMAND (1):
  imx8: Configure SNVS

Marek Vasut (1):
  ARM: imx: imx8mm: Add missing clock entries for FEC clock

Peng Fan (13):
  imx: fix cpu_type helper
  imx8mn: Update speed grade
  imx: cpu: support speed grade for i.MX8MP
  imx: imx8m: add i.MX8MQ Dual and QuadLite support
  imx: imx8m: add i.MX8MN variants support
  imx: update is_imx6ull to include i.MX6ULZ
  imx8: move SIP macro to common header
  imx8m: acquire ATF commit hash
  imx8m: update clock root and fix core_sel
  imx8mq: Set ARM core clock directly from ARM PLL
  imx8: parser: fix 'end address' parameter of rm_find_memreg
  imx8: ahab: fix 'end address' parameter of rm_find_memreg
  imx8: parser: fix some bad debug message formating

Seb Fagard (1):
  imx8: ahab: fix some bad debug message formating

Ye Li (7):
  imx8mm: Update CPU speed grading
  imx8mq: Enable eMMC HS400 and SD UHS mode on EVK
  imx8m: Dump DRAM PLL rate by clocks command
  imx8: Change to use new SECO API commands
  imx8mm: clock: fix fracpll decode issue
  imx8m: Enable WDOG_B for timeout
  imx8: Update SCFW API to version 1.5

 arch/arm/include/asm/arch-imx/cpu.h   |   7 +
 arch/arm/include/asm/arch-imx8/sci/rpc.h  |  86 +---
 arch/arm/include/asm/arch-imx8/sci/sci.h  |  10 ++
 arch/arm/include/asm/arch-imx8/sci/svc/pad/api.h  |   3 +
 arch/arm/include/asm/arch-imx8/sci/types.h|   6 +
 arch/arm/include/asm/arch-imx8/snvs_security_sc.h |  11 ++
 arch/arm/include/asm/arch-imx8m/clock_imx8mm.h|   5 +-
 arch/arm/include/asm/arch-imx8m/clock_imx8mq.h|   3 +-
 arch/arm/include/asm/mach-imx/sys_proto.h |  17 ++-
 arch/arm/mach-imx/cpu.c   |  38 -
 arch/arm/mach-imx/imx8/Kconfig|  13 ++
 arch/arm/mach-imx/imx8/Makefile   |   1 +
 arch/arm/mach-imx/imx8/ahab.c |  15 +-
 arch/arm/mach-imx/imx8/misc.c |   8 +-
 arch/arm/mach-imx/imx8/parse-container.c  |  18 +--
 arch/arm/mach-imx/imx8/snvs_security_sc.c | 923 
++
 arch/arm/mach-imx/imx8m/clock_imx8mm.c|  73 --
 arch/arm/mach-imx/imx8m/clock_imx8mq.c|  57 +---
 arch/arm/mach-imx/imx8m/clock_slice.c | 824 
++---
 arch/arm/mach-imx/imx8m/soc.c |  73 --
 board/freescale/imx8qxp_mek/imx8qxp_mek.c |  10 ++
 doc/imx/ahab/csf_examples/csf_enc_boot_image.txt  |  27 
 doc/imx/ahab/guides/mx8_mx8x_encrypted_boot.txt   | 293 
+++
 drivers/misc/imx8/scu_api.c   | 194 
++
 include/imx_sip.h |   5 +-
 25 files changed, 2602 insertions(+), 118 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-imx8/snvs_security_sc.h
 create mode 100644 arch/arm/mach-imx/imx8/snvs_security_sc.c
 create mode 100644 doc/imx/ahab/csf_examples/csf_enc_boot_image.txt
 create mode 100644 doc/imx/ahab/guides/mx8_mx8x_encrypted_boot.txt


Re: [PATCH 3/3] acpi: Fix-up patch to correct sandbox test errors

2020-04-27 Thread Bin Meng
Hi Simon,

On Tue, Apr 28, 2020 at 1:02 AM Simon Glass  wrote:
>
> Move the alignment code into acpi_setup_base_tables() so that test and
> production code are in alignment.
>
> This brings x86/master into line with patch series v8.
>
> Signed-off-by: Simon Glass 
> ---
>
>  arch/x86/lib/acpi_table.c | 5 -
>  lib/acpi/acpi_table.c | 7 ++-
>  2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
> index 600bde2f5f..13f1409de8 100644
> --- a/arch/x86/lib/acpi_table.c
> +++ b/arch/x86/lib/acpi_table.c
> @@ -375,11 +375,6 @@ ulong write_acpi_tables(ulong start_addr)
> debug("ACPI: Writing ACPI tables at %lx\n", start_addr);
>
> acpi_setup_base_tables(ctx, start);
> -   /*
> -* Per ACPI spec, the FACS table address must be aligned to a 64 byte
> -* boundary (Windows checks this, but Linux does not).
> -*/
> -   acpi_align64(ctx);
>
> debug("ACPI:* FACS\n");
> facs = ctx->current;
> diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c
> index 5abf1cad50..1c253af3bf 100644
> --- a/lib/acpi/acpi_table.c
> +++ b/lib/acpi/acpi_table.c
> @@ -145,7 +145,7 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table)
> }
>
> if (i >= entries_num) {
> -   debug("ACPI: Error: too many tables\n");
> +   log_err("ACPI: Error: too many tables\n");
> return -E2BIG;
> }
>
> @@ -256,4 +256,9 @@ void acpi_setup_base_tables(struct acpi_ctx *ctx, void 
> *start)
> acpi_write_rsdp(ctx->rsdp, ctx->rsdt, ctx->xsdt);
> acpi_write_rsdt(ctx->rsdt);
> acpi_write_xsdt(ctx->xsdt);
> +   /*
> +* Per ACPI spec, the FACS table address must be aligned to a 64 byte
> +* boundary (Windows checks this, but Linux does not).
> +*/
> +   acpi_align64(ctx);
>  }
> --

Could you please point out which commit in u-boot-x86/master should
squash in this patch to fix the build error on sandbox?

Regards,
Bin


Re: [PATCH 04/10] efi_loader: capsule: add capsule_on_disk support

2020-04-27 Thread AKASHI Takahiro
Heinrich,

On Mon, Apr 27, 2020 at 10:28:35PM +0200, Heinrich Schuchardt wrote:
> On 4/27/20 11:48 AM, AKASHI Takahiro wrote:
> > Capsule data can be loaded into the system either via UpdateCapsule
> > runtime service or files on a file system (of boot device).
> > The latter case is called "capsules on disk", and actual updates will
> > take place at the next boot time.
> >
> > In this commit, we will support capsule on disk mechanism.
> >
> > Please note that U-Boot itself has no notion of "boot device" and
> > all the capsule files to be executed will be detected only if they
> > are located in a specific directory, \EFI\UpdateCapsule, on a device
> > that is identified as a boot device by "Boot" variables.
> >
> > Signed-off-by: AKASHI Takahiro 
> > ---
> >  common/main.c|   4 +
> >  include/efi_loader.h |  16 ++
> >  lib/efi_loader/Kconfig   |  22 ++
> >  lib/efi_loader/efi_capsule.c | 449 +++
> >  lib/efi_loader/efi_setup.c   |   9 +
> >  5 files changed, 500 insertions(+)
> >
> > diff --git a/common/main.c b/common/main.c
> > index 06d7ff56d60c..877ae63b708d 100644
> > --- a/common/main.c
> > +++ b/common/main.c
> > @@ -14,6 +14,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  static void run_preboot_environment_command(void)
> >  {
> > @@ -51,6 +52,9 @@ void main_loop(void)
> > if (IS_ENABLED(CONFIG_UPDATE_TFTP))
> > update_tftp(0UL, NULL, NULL);
> >
> > +   if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY))
> > +   efi_launch_capsules();
> > +
> 
> Can't we move this to efi_init_obj_list() and do away with
> CONFIG_EFI_CAPSULE_ON_DISK_EARLY?

With CONFIG_EFI_CAPSULE_ON_DISK_EARLY disabled,
efi_launch_capsules() will be called in efi_init_obj_list()
as you expect. See the code below in efi_setup.c.

> > s = bootdelay_process();
> > if (cli_process_fdt())
> > cli_secure_boot_cmd(s);
> > diff --git a/include/efi_loader.h b/include/efi_loader.h
> > index 19ffc027c171..d49ebcad53ec 100644
> > --- a/include/efi_loader.h
> > +++ b/include/efi_loader.h
> > @@ -793,6 +793,18 @@ efi_status_t EFIAPI efi_query_capsule_caps(
> > u32 *reset_type);
> >  #endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */
> >
> > +#ifdef CONFIG_EFI_CAPSULE_ON_DISK
> > +#define EFI_CAPSULE_DIR L"\\EFI\\UpdateCapsule\\"
> > +
> > +/* Hook at initialization */
> > +efi_status_t efi_launch_capsules(void);
> > +#else
> > +static inline efi_status_t efi_launch_capsules(void)
> > +{
> > +   return EFI_SUCCESS;
> > +}
> > +#endif /* CONFIG_EFI_CAPSULE_ON_DISK */
> > +
> >  #else /* CONFIG_IS_ENABLED(EFI_LOADER) */
> >
> >  /* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out 
> > */
> > @@ -809,6 +821,10 @@ static inline void efi_set_bootdev(const char *dev, 
> > const char *devnr,
> >const char *path) { }
> >  static inline void efi_net_set_dhcp_ack(void *pkt, int len) { }
> >  static inline void efi_print_image_infos(void *pc) { }
> > +static inline efi_status_t efi_launch_capsules(void)
> > +{
> > +   return EFI_SUCCESS;
> > +}
> >
> >  #endif /* CONFIG_IS_ENABLED(EFI_LOADER) */
> >
> > diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> > index e2b08251f26a..b48b95a32e03 100644
> > --- a/lib/efi_loader/Kconfig
> > +++ b/lib/efi_loader/Kconfig
> > @@ -56,6 +56,28 @@ config EFI_RUNTIME_UPDATE_CAPSULE
> >   Select this option if you want to use UpdateCapsule and
> >   QueryCapsuleCapabilities API's.
> >
> > +config EFI_CAPSULE_ON_DISK
> > +   bool "Enable capsule-on-disk support"
> > +   select EFI_HAVE_CAPSULE_SUPPORT
> > +   default n
> > +   help
> > + Select this option if you want to use capsule-on-disk feature,
> > + that is, capsules can be fetched and executed from files
> > + under a specific directory on UEFI system partition instead of
> > + via UpdateCapsule API.
> > +
> > +config EFI_CAPSULE_ON_DISK_EARLY
> > +   bool "Initiate capsule-on-disk at U-Boot boottime"
> > +   depends on EFI_CAPSULE_ON_DISK
> > +   default y
> > +   select EFI_SETUP_EARLY
> > +   help
> > + Normally, without this option enabled, capsules will be
> > + executed only at the first time of invoking one of efi command.
> > + If this option is enabled, capsules will be enforced to be
> > + executed as part of U-Boot initialisation so that they will
> > + surely take place whatever is set to distro_bootcmd.
> 
> Why do we need this Kconfig variable if we have EFI_SETUP_EARLY available?

Good point.
My intent here was to split efi_launch_capsules() from
efi_init_obj_list() so that users can start UEFI early
for some reason without enabling capsule feature in the future.
EFI_SETUP_EARLY is the hook for that.

> > +
> >  config EFI_DEVICE_PATH_TO_TEXT
> > bool "Device path to text protocol"
> > default y
> > diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
> > index 

Re: [PATCH 02/10] efi_loader: add option to initialise EFI subsystem early

2020-04-27 Thread AKASHI Takahiro
Heinrich,

On Mon, Apr 27, 2020 at 10:09:11PM +0200, Heinrich Schuchardt wrote:
> On 4/27/20 11:48 AM, AKASHI Takahiro wrote:
> > If this option is enabled, the initialisation of UEFI subsystem will be
> > done as part of U-Boot initialisation.
> >
> > This feature will be utilised in implementing capsule-on-disk feature.
> 
> This would mean that we allow unaligned access very early. Something
> Siarhei was against:

?
Even with CONFIG_EFI_CAPSULE_ON_DISK_EARLY enabled,
efi_init_obj_list() is called at the last of "init" list
and efi_launch_capsules() is called just before the main
command loop.
So "unalignment" issue won't happen.

> https://lists.denx.de/pipermail/u-boot/2018-March/324242.html
> https://patchwork.ozlabs.org/project/uboot/patch/20180329213350.7868-1-xypron.g...@gmx.de/
> 
> Why can't you wait with the capsule update until any command initializes
> the UEFI sub-system.

This topic is the one the I mentioned in RFC's cover letter
and asked you for comments several time.
Anyway, there are a couple of reasons:
1. Updated firmware may have some effects on not only UEFI
   subsystem but also U-Boot's other features.
2. Firmware update should surely take place after reboot
   as UEFI specification expects.
3. Firmware update should not rely on user's interactions
   or whatever "bootcmd" is set to.
4. In case of failure of firmware update, some recovery should
   be automatically taken "before" the command line is handed over
   to users. (The feature is not implemented yet though.)

-Takahiro Akashi


> Best regards
> 
> Heinrich
> 
> >
> > Signed-off-by: AKASHI Takahiro 
> > ---
> >  common/board_r.c   | 6 ++
> >  lib/efi_loader/Kconfig | 4 
> >  2 files changed, 10 insertions(+)
> >
> > diff --git a/common/board_r.c b/common/board_r.c
> > index 0bbeaa7594c6..7cf21a6078f9 100644
> > --- a/common/board_r.c
> > +++ b/common/board_r.c
> > @@ -64,6 +64,9 @@
> >  #if defined(CONFIG_GPIO_HOG)
> >  #include 
> >  #endif
> > +#ifdef CONFIG_EFI_SETUP_EARLY
> > +#include 
> > +#endif
> >
> >  DECLARE_GLOBAL_DATA_PTR;
> >
> > @@ -867,6 +870,9 @@ static init_fnc_t init_sequence_r[] = {
> >  #endif
> >  #if defined(CONFIG_M68K) && defined(CONFIG_BLOCK_CACHE)
> > blkcache_init,
> > +#endif
> > +#ifdef CONFIG_EFI_SETUP_EARLY
> > +   (init_fnc_t)efi_init_obj_list,
> >  #endif
> > run_main_loop,
> >  };
> > diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> > index 1cfa24ffcf72..7cc2d940f848 100644
> > --- a/lib/efi_loader/Kconfig
> > +++ b/lib/efi_loader/Kconfig
> > @@ -25,6 +25,10 @@ config EFI_LOADER
> >
> >  if EFI_LOADER
> >
> > +config EFI_SETUP_EARLY
> > +   bool
> > +   default n
> > +
> >  config EFI_GET_TIME
> > bool "GetTime() runtime service"
> > depends on DM_RTC
> >
> 


Re: [PATCH 01/10] efi_loader: disk: add efi_disk_is_system_part()

2020-04-27 Thread AKASHI Takahiro
Heinrich,

On Mon, Apr 27, 2020 at 09:57:25PM +0200, Heinrich Schuchardt wrote:
> On 4/27/20 11:48 AM, AKASHI Takahiro wrote:
> > This function will check if a given handle to device is a EFI system
> > partition. It will be utilised in implementing capsule-on-disk feature.
> >
> > Signed-off-by: AKASHI Takahiro 
> 
> Just a reminder for me:
> 
> This patch depends on
> "part: detect EFI system partition"
> https://lists.denx.de/pipermail/u-boot/2020-April/408150.html

Yes, and I explicitly mentioned it in "prerequisite patches"
of the cover letter.
(I objected to the patch 2/2 though.)

> > ---
> >  include/efi_loader.h  |  2 ++
> >  lib/efi_loader/efi_disk.c | 22 ++
> >  2 files changed, 24 insertions(+)
> >
> > diff --git a/include/efi_loader.h b/include/efi_loader.h
> > index b7bccf50b30c..d4510462d616 100644
> > --- a/include/efi_loader.h
> > +++ b/include/efi_loader.h
> > @@ -393,6 +393,8 @@ efi_status_t efi_disk_register(void);
> >  int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
> >const char *if_typename, int diskid,
> >const char *pdevname);
> > +/* Check if it is EFI system partition */
> > +bool efi_disk_is_system_part(efi_handle_t handle);
> >  /* Called by bootefi to make GOP (graphical) interface available */
> >  efi_status_t efi_gop_register(void);
> >  /* Called by bootefi to make the network interface available */
> > diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
> > index fd3df80b0b96..9f58a8642c85 100644
> > --- a/lib/efi_loader/efi_disk.c
> > +++ b/lib/efi_loader/efi_disk.c
> > @@ -588,3 +588,25 @@ efi_status_t efi_disk_register(void)
> >
> > return EFI_SUCCESS;
> >  }
> > +
> 
> Please, provide a function description, cf.
> https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation

That is the thing that I've forgot to address in this version.

> > +bool efi_disk_is_system_part(efi_handle_t handle)
> > +{
> > +   struct efi_handler *handler;
> > +   struct efi_disk_obj *diskobj;
> > +   disk_partition_t info;
> > +   efi_status_t ret;
> > +   int r;
> > +
> > +   /* check if this is a block device */
> > +   ret = efi_search_protocol(handle, _block_io_guid, );
> > +   if (ret != EFI_SUCCESS)
> > +   return false;
> > +
> > +   diskobj = container_of(handle, struct efi_disk_obj, header);
> 
> This is just a complicated way of saying:
> 
> diskobj = (struct efi_disk_obj *)handle;
> 
> I would rather avoid container_of() here though it is not wrong.

My code doesn't rely on the fact that 'handle' is the first
element of 'struct efi_disk_obj'
So use of container_of has no disadvantage.

Thanks,
-Takahiro Akashi


> Best regards
> 
> Heinrich
> 
> > +
> > +   r = part_get_info(diskobj->desc, diskobj->part, );
> > +   if (r)
> > +   return false;
> > +
> > +   return info.bootable & PART_EFI_SYSTEM_PARTITION;
> > +}
> >


Re: [PATCH 00/10] efi_loader: add capsule update support

2020-04-27 Thread AKASHI Takahiro
Heinrich,

On Mon, Apr 27, 2020 at 10:33:41PM +0200, Heinrich Schuchardt wrote:
> On 4/27/20 11:48 AM, AKASHI Takahiro wrote:
> > Summary
> > ===
> > 'UpdateCapsule' is one of runtime services defined in UEFI specification
> > and its aim is to allow a caller (OS) to pass information to the firmware,
> > i.e. U-Boot. This is mostly used to update firmware binary on devices by
> > instructions from OS.
> >
> > While 'UpdateCapsule' is a runtime services function, it is, at least
> > initially, suported only before exiting boot services alike other runtime
> > functions, [Get/]SetVariable. This is because modifying storage which may
> > be shared with OS must be carefully designed and there is no general
> > assumption that we can do it.
> >
> > Therefore, we practically support only "capsule on disk"; any capsule can
> > be handed over to UEFI subsystem as a file on a specific file system.
> >
> > In this patch series, all the related definitions and structures are given
> > as UEFI specification describes, and basic framework for capsule support
> > is provided. Currently supported is
> >  * firmware update (Firmware Management Protocol or simply FMP)
> >
> > Most of functionality of firmware update is provided by FMP driver and
> > it will be, by nature, system/platform-specific. So you can and should
> > implement your own FMP driver(s) based on your system requirements.
> > Only a simple FMP driver based on FIT image for a single region is
> > provided here.  (So it is "for reference only")
> 
> Do think this FMP driver will be actually used?

It's totally up to users (and their requirements).

> Or should it be moved to lib/efi_selftest?

Well, I hope that someone will come in and add more features
that will meet additional requirements.
So I would like you to keep it under lib/efi_loader for now.

> >^^
> > See more details in the commit, "efi_loader: capsule: add simple firmware
> > management protocol."
> 
> In this patch series I am missing the update of the documentation in
> doc/uefi/.

Okay.

-Takahiro Akashi


> Best regards
> 
> Heinrich
> 
> >
> > Patch structure
> > ===
> > Patch#1-#2: preparatory patches
> > Patch#3-#7: main part of implementation
> > Patch#8-#10: utilities and tests
> >
> > [1] https://git.linaro.org/people/takahiro.akashi/u-boot.git efi/capsule
> >
> > Prerequisite patches
> > 
> > [2] part: detect EFI system partition
> > https://lists.denx.de/pipermail/u-boot/2020-March/403562.html
> > [3] common: update_tftp: remove unnecessary build check
> > https://lists.denx.de/pipermail/u-boot/2020-March/401727.html
> > [4] sandbox: drop CONFIG_SYS_RELOC_GD_ENV_ADDR
> > https://lists.denx.de/pipermail/u-boot/2020-April/408711.html
> >
> > Test
> > 
> > * passed all the pytests which are included in this patch series
> >   on sandbox build.
> > * passed Travis CI.
> >
> > Please note that, while Travic CI passed, the capsule pytest
> > itself won't be run in the CI because some specific configuration
> > for sandbox build is required. See test_efi_capsule_firmware.py.
> >
> > Issues
> > ==
> > * Timing of executing capsules-on-disk
> >   Currently, processing a capsule is triggered only as part of
> >   UEFI subsystem initialization. This means that, for example,
> >   firmware update, may not take place at system booting time and
> >   will potentially be delayed until a first call of any UEFI functions.
> >
> > => See patch#4 for my proposal
> >
> > TODO's
> > ==
> > (May not be addressed in future versions of this series.)
> > * capsule authentication
> > * capsule dependency (dependency expression instruction set)
> > * loading drivers in a capsule
> > * handling RESET flag in a capsule and QeuryCapsuleCaps
> > * full semantics of ESRT (EFI System Resource Table)
> > * enabling capsule API at runtime
> > * json capsule
> > * recovery from update failure
> >
> > Changes
> > ===
> > v1 (April 27, 2020)
> > * rebased to v2020.07-rc
> > * removed already-merged patches (RFC's #1 to #4)
> > * dropped 'variable update' capsule support (RFC's patch#10)
> > * dropped 'variable configuration table' support (RFC's patch#11)
> >   (Those two should be discussed separately.)
> > * add preparatory patches (patch#1/#2)
> > * fix several build errors
> > * rename some Kconfig options to be aligned with UEFI specification's terms
> >   (patch#3,4,6,7)
> > * enforce UpdateCapsule API to be disabled after ExitBootServices (patch#3)
> > * use config table, runtime_services_supported, instead of variable 
> > (patch#3)
> > * make EFI_CAPSULE_ON_DISK buildable even if UpdateCapsule API is disabled
> >   (patch4)
> > * support OsIndications, invoking capsule-on-disk only if the variable
> >   indicates so (patch#4)
> > * introduced EFI_CAPSULE_ON_DISK_EARLY to invoke capsule-on-disk in U-Boot
> >   initialization (patch#4)
> > * detect capsule files only if they are on EFI system 

Re: [PATCH v2 2/2] Makefile: Only build dtc if needed

2020-04-27 Thread Vagrant Cascadian
On 2020-04-27, Simon Glass wrote:
> On Sun, 26 Apr 2020 at 18:58, Heinrich Schuchardt  wrote:
>>
>> Am April 27, 2020 12:29:29 AM UTC schrieb Simon Glass :
>> >At present U-Boot always builds dtc if CONFIG_OF_CONTROL is defined.
>> >This
>> >is wasteful when the system already has a suitable version available.
>> >
>> >Update the Makefile logic to build dtc only if the version available is
>> >too old.
>> >
>> >This saves about 2.5 seconds of elapsed time on a clean build for me.
>> >
>> >- Add a patch to bring back the dtc-version.sh script
>> >- Update the check to make sure libfdt is available if needed
>>
>> U -Boot has been set up to create reproducible builds. With this
>> patch dtc will have to be made a build dependency to provide
>> reproducibility. Cf. 
>> https://www.debian.org/doc/debian-policy/ch-source.html#reproducibility
>>
>> This may require changes in the packaging of U-Boot in Linux
>> distributions. Nothing to stop this patch, just something to keep in
>> mind.
>>
>> You presume that future versions of dtc will always be backward
>> compatible with U-Boot. Ok, we do the same for other tools like gcc
>> too (with surprises at each new major release).

In general when packaging for Debian, the preference is to not use
embedded code copies if at all possible. This does require paying
attention to backwards and forwards compatibility issues a bit.

A simple example: The security team in Debian generally likes to fix a
problem in a single source package, rather than an arbitrary number of
source packages that happen to share some embedded copy of the code from
who knows when...

So at least from my perspective, I'd be happy to use the Debian packaged
dtc (a.k.a. device-tree-compiler), rather than the one embedded in
u-boot sources.

Silently switching to the embedded copy sounds a little scary; I would
prefer for that to be explicit... a build flag to specify one way or the
other and failing is better that being too clever about autodetecting.


> Should we disable this check (and always build dtc) when doing a
> repeatable build? Is that SOURCE_DATE_EPOCH?

And with my Reproducible Builds hat on, builds would ideally *always* be
reproducible, given the same sources and toolchain... several
distributions and software projects provide information sufficient to
reproduce the build environment:

  https://reproducible-builds.org/docs/recording/


While SOURCE_DATE_EPOCH is definitely one sign that the builder is
explicitly attempting to be reproducible; It's a bit of a kludge to try
and be more reproducible just because SOURCE_DATE_EPOCH is
set. SOURCE_DATE_EPOCH should really only affect the behavior of date or
time related things; even better would be to not embded time related
information at all!


live well,
  vagrant


signature.asc
Description: PGP signature


Re: [PATCH] sandbox: update documents regarding spi_sf

2020-04-27 Thread Simon Glass
On Mon, 27 Apr 2020 at 00:47, AKASHI Takahiro
 wrote:
>
> Since the commit 1289e96797bf ("sandbox: spi: Drop command-line SPI
> option"), "--spi_sf" command line option is no longer supported.
>
> So update the following documents to sync them up with the change.
> doc/arch/sandbox.rst
> doc/SPI/README.sandbox-spi
>
> Signed-off-by: AKASHI Takahiro 
> ---
>  doc/SPI/README.sandbox-spi | 58 --
>  doc/arch/sandbox.rst   | 52 +++---
>  2 files changed, 41 insertions(+), 69 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [U-Boot] Makefile: Only build dtc if needed

2020-04-27 Thread Simon Glass
Hi Tom,

On Mon, 27 Apr 2020 at 12:59, Tom Rini  wrote:
>
> On Sun, Apr 26, 2020 at 06:34:48PM -0600, Simon Glass wrote:
> > Hi Tom,
> >
> > On Sat, 26 Jan 2019 at 20:51, Tom Rini  wrote:
> > >
> > > On Tue, Nov 13, 2018 at 03:43:07PM -0700, Simon Glass wrote:
> > >
> > > > At present U-Boot always builds dtc if CONFIG_OF_CONTROL is defined. 
> > > > This
> > > > is wasteful when the system already has a suitable version available.
> > > >
> > > > Update the Makefile logic to build dtc only if the version available is
> > > > too old.
> > > >
> > > > This saves about 3 seconds of CPU time on a clean build for me.
> > > >
> > > > Signed-off-by: Simon Glass 
> > > > Reviewed-by: Marek Vasut 
> > >
> > > In the case of new enough host dtc this then fails on sandbox_spl,
> > > chromebook_minnie and others where we need to build
> > > spl/dts/dt-platdata.c with a python import error over lacking _libfdt.
> >
> > I'm not sure if it has been long enough, but have the packages been
> > updated to include pylibfdt?
> >
> > I'm sending a new version of this patch that checks for that.
>
> I honestly don't know how far behind distributions lag here and then in
> turn how old something is before we say "sorry, you can't build there
> easily".

I think we should be able to deal with this with respect to dtc at
least, since we can always build it if needed. We just need to get the
conditions right.

Regards,
SImon


Re: Build error in u-boot-dm/master

2020-04-27 Thread Simon Glass
Hi Stephen,

On Mon, 27 Apr 2020 at 12:44, Stephen Warren  wrote:
>
> On 4/27/20 11:02 AM, Simon Glass wrote:
> > Hi Stephen,
> >
> > On Mon, 27 Apr 2020 at 10:04, Stephen Warren  wrote:
> >>
> >> Simon,
> >>
> >> All 32-bit Tegra builds of u-boot-dm/master are failing with the
> >> following (this log is from Harmony):
> >>
> >>>   CC  spl/common/spl/spl.o
> >>>   CC  spl/lib/display_options.o
> >>>   LD  spl/common/spl/built-in.o
> >>>   LD  spl/lib/built-in.o
> >>>   LD  spl/u-boot-spl
> >>>   OBJCOPY spl/u-boot-spl-nodtb.bin
> >>>   COPYspl/u-boot-spl.bin
> >>>   BINMAN  u-boot-tegra.bin
> >>> binman: bad magic number in 'binman.etype': b'\x03\xf3\r\n'
> >>> /var/lib/jenkins/workspace/u-boot-denx_uboot_dm-master-build/src/u-boot/Makefile:1619:
> >>>  recipe for target 'u-boot-tegra.bin' failed
> >>> make[1]: *** [u-boot-tegra.bin] Error 1
> >
> > Oh wow, that is a strange one. Could it be bad Python cache files again?
>
> Ah yes, so it is. I'd forgotten about that, and initially thought it
> couldn't be the issue, since the problem only affects some boards not
> all, and on my system they're all built in the same source tree
> (serially). However, I guess our 64-bit builds don't run the tool that
> triggers the problem, so that explains the differences.
>
> Deleting tools/binman/etype/__init__.pyc did solve the issue, and that
> file doesn't get re-created if 16287933a8 "binman: Move to absolute
> imports" is applied.
>
> Do you know what causes the issue, or how it can be avoided?
>
> Maybe running "git clean -fdx" on the source tree before building would
> be a workaround, but I'd rather solve the root-cause if possible.

Actually I don't know. But the file you mention looks like something
that Python 2 would create. So perhaps it is not allowed to run Python
2 on a project, then remove a file, then run Python 3. Since the file
is removed (but not the .pyc), perhaps Python 3 gets confused? This
seems like a bug though, since Python 3 really should not be looking
at pyc files created by Python 2.

Regards,
Simon


Re: libfdt issue - key verification fails with longer key-name

2020-04-27 Thread Simon Glass
Hi Heiko,

On Sun, 26 Apr 2020 at 17:55, Heiko Stuebner
 wrote:
>
> Hi,
>
> I've encountered a strange issue that happens depending on the
> length of the used key-name. Naming it "integrity" works,
> "integrity-uboot" or even "integrity-ub" does not.
> With the resulting key-node of course then being "key-integrity-uboot".
>
>
> On the upper levels everything looks great, it finds the signatures and
> correct key-node,  but when the spl reaches the
> rsa_verify_with_keynode() function it falls apart and libfdt seems to read
> strange values from the fdt.
>
> Single values seem to be read back correctly, as can be seen with
> rsa,n0-inverse and rsa,num-bits values that are correct with both
> key-names (for the same base key).
>
> But it's different with the public exponent rsa,exponent:
> Where it reads back in the correct case as 0x  0001 0001
> with the longer keyname the result is i.e. 0x44b2 0100  
> (or similar, depending on the length of the keyname it seems).
> The 0x0100 part stays the same always, but the 0x44b2 can also be
> a 0xecb1
>
>
> Is this some alignment issue somewhere, or do you have a hint
> what I should poke?

Not really, but can you repeat it with sandbox? It sounds like it
could be a bug?

Regards,
Simon


Re: [PATCH 1/3] [RFC] dm: core: Add late driver remove option

2020-04-27 Thread Simon Glass
Hi Marek,

On Sun, 26 Apr 2020 at 04:52, Marek Vasut  wrote:
>
> Add another flag to the DM core which could be assigned to drivers and
> which makes those drivers call their remove callbacks last, just before
> booting OS and after all the other drivers finished with their remove
> callbacks. This is necessary for things like clock drivers, where the
> other drivers might depend on the clock driver in their remove callbacks.
> Prime example is the mmc subsystem, which can reconfigure a card from HS
> mode to slower modes in the remove callback and for that it needs to
> reconfigure the controller clock.
>
> Signed-off-by: Marek Vasut 
> Cc: Simon Glass 
> Cc: Tom Rini 
> ---
>  arch/arm/lib/bootm.c |  1 +
>  drivers/core/device-remove.c | 11 ---
>  drivers/core/root.c  |  2 ++
>  include/dm/device.h  |  4 
>  4 files changed, 15 insertions(+), 3 deletions(-)

I think this solution is simpler than trying to track device
dependencies, something that driver model currently makes no attempt
to do.

It does need a test though.

Regards,
Simon


Re: [PATCH] sandbox: drop CONFIG_SYS_RELOC_GD_ENV_ADDR

2020-04-27 Thread Simon Glass
On Sun, 26 Apr 2020 at 22:22, AKASHI Takahiro
 wrote:
>
> As we discussed in [1], this option is not needed for sandbox build.
>
> [1] https://lists.denx.de/pipermail/u-boot/2020-February/400182.html
>
> Signed-off-by: AKASHI Takahiro 
> ---
>  configs/sandbox64_defconfig| 1 -
>  configs/sandbox_defconfig  | 1 -
>  configs/sandbox_flattree_defconfig | 1 -
>  configs/sandbox_spl_defconfig  | 1 -
>  4 files changed, 4 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH v1 00/49] add support for broadcom NS3 soc

2020-04-27 Thread Simon Glass
Hi Rayagonda,

On Mon, 27 Apr 2020 at 07:29, Rayagonda Kokatanur
 wrote:
>
>
>
> On Mon, Apr 27, 2020, 6:55 PM Marek Vasut  wrote:
>>
>> On 4/27/20 3:13 PM, Andy Shevchenko wrote:
>> > On Mon, Apr 27, 2020 at 2:12 PM Marek Vasut  wrote:
>> >>
>> >> On 4/27/20 12:47 PM, Rayagonda Kokatanur wrote:
>> >>> This patch series adds support for Broadcom Northstar 3 SoC.
>> >>
>> >> Please, do keep the CC sane, don't CC everyone.
>> >
>> > +1!
>> >
>> > Please, learn how not to spam people with the crazy patch bomb.
>> > Next time I will simple mark this as a spam.
>>
>> I think this is more of a fault of the scripts/get_maintainer or patman,
>> which just blindly added all the addresses. If the series was split in
>> smaller parts, the CC list would probably be smaller too.
>
>
> I ran get_maintainer script on my patch set and got all these email id.

You can use 'patman' which will do this automatically. Also it only
does the get_maintainers separately for each patch. Perhaps that is
what you are missing here?

> Next time I will send only to u-boot@lists.denx.de

As a counterpoint, I don't tend to see patches that just go there, so
I like the cc. I have a tag so it doesn't clog up my inbox.

But it is strange that I got every single patch. Perhaps using patman
will fix that.

Also two general comments on the series:

- please add a board maintainer
- please enable CONFIG_DM_ETH

Regards,
Simon


Re: [PATCH] regulator: fix: enable gpio when requested

2020-04-27 Thread Simon Glass
Hi Mark,

On Mon, 27 Apr 2020 at 03:09, Mark Kettenis  wrote:
>
> The fix in commit b7adcdd073c0 has the side-effect that the regulator
> will be disabled when requesting the relevant gpio in
> regulator_common_ofdata_to_platdata() and enabled in
> regulator_pre_probe() when the regulator was already enabled.
> This leads to a short interruption in the 3.3V power to the PCIe
> slot on the firefly-rk3399 which makes an ADATA SX8000NP NVMe SSD
> unhappy.
>
> Fix this by setting the GPIOD_IS_OUT_ACTIVE flag again when the
> 'regulator-boot-on' property is set, but check for this property
> explicitly instead of relying on the "boot_on" member of
> the uclass platdata.
>
> Signed-off-by: Mark Kettenis 
> ---
>  drivers/power/regulator/regulator-uclass.c | 3 ---
>  drivers/power/regulator/regulator_common.c | 2 ++
>  2 files changed, 2 insertions(+), 3 deletions(-)

Should this have a Fixed: tag?

Regards,
Simon


Re: [PATCH v2 2/2] Makefile: Only build dtc if needed

2020-04-27 Thread Simon Glass
Hi Heinrich,

On Sun, 26 Apr 2020 at 18:58, Heinrich Schuchardt  wrote:
>
> Am April 27, 2020 12:29:29 AM UTC schrieb Simon Glass :
> >At present U-Boot always builds dtc if CONFIG_OF_CONTROL is defined.
> >This
> >is wasteful when the system already has a suitable version available.
> >
> >Update the Makefile logic to build dtc only if the version available is
> >too old.
> >
> >This saves about 2.5 seconds of elapsed time on a clean build for me.
> >
> >- Add a patch to bring back the dtc-version.sh script
> >- Update the check to make sure libfdt is available if needed
>
> U -Boot has been set up to create reproducible builds. With this patch dtc 
> will have to be made a build dependency to provide reproducibility. Cf. 
> https://www.debian.org/doc/debian-policy/ch-source.html#reproducibility
>
> This may require changes in the packaging of U-Boot in Linux distributions. 
> Nothing to stop this patch, just something to keep in mind.
>
> You presume that future versions of dtc will always be backward compatible 
> with  U-Boot. Ok, we do the same for other tools like gcc too (with surprises 
> at each new major release).
>
> Cc: Vagrant

Should we disable this check (and always build dtc) when doing a
repeatable build? Is that SOURCE_DATE_EPOCH?

Regards,
SImon


Regards,
Simon


Re: ZynqMP boot: no messages from SPL other than "Debug uart enabled"

2020-04-27 Thread Major A

Hi Michal,

Thanks for your script, I tried it, it can extract the PMU config object 
from the FSBL generated by Vitis, but the SD card I prepare this way 
still doesn't boot.


It does one thing differently than before, though: the line

   ### ERROR ### Please RESET the board ###

appears EVERY time, not just occasionally.

Any ideas what I'm doing wrong?

Cheers,

  András


On 24/04/2020 14:14, Michal Simek wrote:

Hi,

On 23. 04. 20 11:02, Major A wrote:

Hi Michal,

I've had to take a break because, as it turned out, my ZCU102 was
defective.  Now that I have a working one, I can go on with my
frustrating quest for a bootable image.

So now that the patches to u-boot for the ZCU102 Rev. 1.1 are in git
master, I started again from scratch, building ATF, PMUFW with patch and
config object, and u-boot.

Once the builds finish, I place the files

   spl/boot.bin

and

   u-boot.itb

on the SD card and try to boot.  Sadly, as before, the only result I get
on the first UART channel is a line

   Debug uart enabled

sometimes followed by

   ### ERROR ### Please RESET the board ###

but nothing else.

My suspicion is that the PMUFW or its configuration object isn't right.
I use Luca's code from here to build both:

   https://github.com/lucaceresoli/zynqmp-pmufw-builder.git

I also found an issue here:


https://forums.xilinx.com/t5/ACAP-and-SoC-Boot-and/Booting-ZCU-102-from-SD-Card/td-p/926649


It appears that there are at least two incompatible subrevisions of the
board, both labeled Rev. 1.1.  Could it be that the current PMUFW (or
whatever) just won't work with the current revision?

How do I figure out what the h*** is going on?


That boards should have just different DDR memory because origin was EOL.

Take a look at this mainline commit.
commit 47cc45a91ccc86c718fef7e8a00188e1047cf3dd
 arm64: zynqmp Add support for zcu102 rev1.1

You need to also add pmu.bin and pmu_obj.bin

CONFIG_PMUFW_INIT_FILE="pmu.bin"
CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE="pmu_obj.bin"


pmu.bin is just binary from pmu.elf which you can take from petalinux or
build it yourself.
pmu_obj.bin based on Luca's way. I personally is taking it from
petalinux fsbl.
I didn't try it for a while but this was sort of latest version.

$ cat extract-pmufw
#!/bin/bash
# Written by Michal Simek

FSBL=fsbl
PMCFG=pmu_obj.bin

PM_END=`aarch64-linux-gnu-objdump -D ${FSBL}.elf | sed -n
'/:/,/^$/p' | tail -n 2 | head -n 1 | cut -c 5-12 |
awk '{printf ("0x%s",$1)}'`
PM_START=`aarch64-linux-gnu-objdump -D ${FSBL}.elf | sed -n
'/:/,/^$/p' | head -n 1 | awk '{printf ("0x%s",$1)}'`

FSBL_START=`aarch64-linux-gnu-readelf -a ${FSBL}.elf | grep "Entry point
address" | awk '{print $4}'`

PM_OBJECT_START=`echo $((${PM_START} - ${FSBL_START}))`
PM_OBJECT_SIZE=`echo $((${PM_END} - ${PM_START}))`
PM_OBJECT_SIZE=`echo $((${PM_OBJECT_SIZE} + 4))`

echo "FSBL starting address ${FSBL_START}"
echo "FSBL object addresses ${PM_START} ${PM_END}"
echo "OBJECT start ${PM_OBJECT_START} size ${PM_OBJECT_SIZE}"

aarch64-linux-gnu-objcopy -O binary ${FSBL}.elf ${FSBL}.bin

# Extracting config object
dd if=${FSBL}.bin of=${PMCFG} bs=1 skip=${PM_OBJECT_START}
count=${PM_OBJECT_SIZE} > /dev/null 2>&1



And then simply build it like this.
export DEVICE_TREE=zynqmp-zcu102-rev1.1
make xilinx_zynqmp_virt_defconfig
make -j8

If you want to have ATF just copy bl31.bin to u-boot root ro use BL31
variable to generate u-boot.itb with it.

And that should be it.

Thanks,
Michal






[PATCH] Azure/GitLab: Update to latest Docker image

2020-04-27 Thread Tom Rini
This provides a newer ARC toolchain along with being based on a newer
Ubuntu bionic tag.

Signed-off-by: Tom Rini 
---
 .azure-pipelines.yml | 2 +-
 .gitlab-ci.yml   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index d3e7b4dd0209..a043d2922bb1 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -1,7 +1,7 @@
 variables:
   windows_vm: vs2017-win2016
   ubuntu_vm: ubuntu-18.04
-  ci_runner_image: trini/u-boot-gitlab-ci-runner:bionic-20200311-10Apr2020
+  ci_runner_image: trini/u-boot-gitlab-ci-runner:bionic-20200403-27Apr2020
   # Add '-u 0' options for Azure pipelines, otherwise we get "permission
   # denied" error when it tries to "useradd -m -u 1001 vsts_azpcontainer",
   # since our $(ci_runner_image) user is not root.
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 08bdf81e74d3..55bde3d86bf5 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,7 @@
 
 # Grab our configured image.  The source for this is found at:
 # https://gitlab.denx.de/u-boot/gitlab-ci-runner
-image: trini/u-boot-gitlab-ci-runner:bionic-20200311-10Apr2020
+image: trini/u-boot-gitlab-ci-runner:bionic-20200403-27Apr2020
 
 # We run some tests in different order, to catch some failures quicker.
 stages:
-- 
2.17.1



[PATCH] travis: Update ARC toolchain to 2019.09

2020-04-27 Thread Tom Rini
Per Alexey Brodkin, this is the current toolchain we should use when
building for ARC, update.

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

diff --git a/.travis.yml b/.travis.yml
index 82e3b9152375..d9dadc6ba7c3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -57,7 +57,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_2018.09_prebuilt_uclibc_le_archs_linux_install" 
>> ~/.buildman
+ - echo -e "arc = /tmp/arc_gnu_2019.09_prebuilt_uclibc_le_archs_linux_install" 
>> ~/.buildman
  - echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
  - echo -e "x86 = i386" >> ~/.buildman;
  - echo -e "riscv = riscv64" >> ~/.buildman;
@@ -86,8 +86,8 @@ before_script:
   ./tools/buildman/buildman --fetch-arch i386;
 fi
   - if [[ "${TOOLCHAIN}" == arc ]]; then
-   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;
+   wget 
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
 &&
+   tar -C /tmp -xf 
arc_gnu_2019.09_prebuilt_uclibc_le_archs_linux_install.tar.gz;
 fi
   - if [[ "${TOOLCHAIN}" == "nds32" ]]; then
wget 
https://github.com/vincentzwc/prebuilt-nds32-toolchain/releases/download/20180521/nds32le-linux-glibc-v3-upstream.tar.gz
 &&
-- 
2.17.1



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

2020-04-27 Thread Tom Rini
On Mon, Apr 27, 2020 at 08:32:45PM +, Alexey Brodkin wrote:
> 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 :)

I understand :)

> 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?

Travis, Azure and GitLab are all used.  I'll update things, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 00/10] efi_loader: add capsule update support

2020-04-27 Thread Heinrich Schuchardt
On 4/27/20 11:48 AM, AKASHI Takahiro wrote:
> Summary
> ===
> 'UpdateCapsule' is one of runtime services defined in UEFI specification
> and its aim is to allow a caller (OS) to pass information to the firmware,
> i.e. U-Boot. This is mostly used to update firmware binary on devices by
> instructions from OS.
>
> While 'UpdateCapsule' is a runtime services function, it is, at least
> initially, suported only before exiting boot services alike other runtime
> functions, [Get/]SetVariable. This is because modifying storage which may
> be shared with OS must be carefully designed and there is no general
> assumption that we can do it.
>
> Therefore, we practically support only "capsule on disk"; any capsule can
> be handed over to UEFI subsystem as a file on a specific file system.
>
> In this patch series, all the related definitions and structures are given
> as UEFI specification describes, and basic framework for capsule support
> is provided. Currently supported is
>  * firmware update (Firmware Management Protocol or simply FMP)
>
> Most of functionality of firmware update is provided by FMP driver and
> it will be, by nature, system/platform-specific. So you can and should
> implement your own FMP driver(s) based on your system requirements.
> Only a simple FMP driver based on FIT image for a single region is
> provided here.  (So it is "for reference only")

Do think this FMP driver will be actually used?
Or should it be moved to lib/efi_selftest?

>^^
> See more details in the commit, "efi_loader: capsule: add simple firmware
> management protocol."

In this patch series I am missing the update of the documentation in
doc/uefi/.

Best regards

Heinrich

>
> Patch structure
> ===
> Patch#1-#2: preparatory patches
> Patch#3-#7: main part of implementation
> Patch#8-#10: utilities and tests
>
> [1] https://git.linaro.org/people/takahiro.akashi/u-boot.git efi/capsule
>
> Prerequisite patches
> 
> [2] part: detect EFI system partition
> https://lists.denx.de/pipermail/u-boot/2020-March/403562.html
> [3] common: update_tftp: remove unnecessary build check
> https://lists.denx.de/pipermail/u-boot/2020-March/401727.html
> [4] sandbox: drop CONFIG_SYS_RELOC_GD_ENV_ADDR
> https://lists.denx.de/pipermail/u-boot/2020-April/408711.html
>
> Test
> 
> * passed all the pytests which are included in this patch series
>   on sandbox build.
> * passed Travis CI.
>
> Please note that, while Travic CI passed, the capsule pytest
> itself won't be run in the CI because some specific configuration
> for sandbox build is required. See test_efi_capsule_firmware.py.
>
> Issues
> ==
> * Timing of executing capsules-on-disk
>   Currently, processing a capsule is triggered only as part of
>   UEFI subsystem initialization. This means that, for example,
>   firmware update, may not take place at system booting time and
>   will potentially be delayed until a first call of any UEFI functions.
>
> => See patch#4 for my proposal
>
> TODO's
> ==
> (May not be addressed in future versions of this series.)
> * capsule authentication
> * capsule dependency (dependency expression instruction set)
> * loading drivers in a capsule
> * handling RESET flag in a capsule and QeuryCapsuleCaps
> * full semantics of ESRT (EFI System Resource Table)
> * enabling capsule API at runtime
> * json capsule
> * recovery from update failure
>
> Changes
> ===
> v1 (April 27, 2020)
> * rebased to v2020.07-rc
> * removed already-merged patches (RFC's #1 to #4)
> * dropped 'variable update' capsule support (RFC's patch#10)
> * dropped 'variable configuration table' support (RFC's patch#11)
>   (Those two should be discussed separately.)
> * add preparatory patches (patch#1/#2)
> * fix several build errors
> * rename some Kconfig options to be aligned with UEFI specification's terms
>   (patch#3,4,6,7)
> * enforce UpdateCapsule API to be disabled after ExitBootServices (patch#3)
> * use config table, runtime_services_supported, instead of variable (patch#3)
> * make EFI_CAPSULE_ON_DISK buildable even if UpdateCapsule API is disabled
>   (patch4)
> * support OsIndications, invoking capsule-on-disk only if the variable
>   indicates so (patch#4)
> * introduced EFI_CAPSULE_ON_DISK_EARLY to invoke capsule-on-disk in U-Boot
>   initialization (patch#4)
> * detect capsule files only if they are on EFI system partition (patch#4)
> * use printf, rather than EFI_PRINT, in error cases (patch#4)
> * use 'header_size' field to retrieve capsule data, adding sanity checks
>   against capsule size (patch#6)
> * call fmpt driver interfaces with EFI_CALL (patch#6)
> * remove 'variable update capsule'-related code form mkeficapsule (patch#9)
> * add a test case of OsIndications not being set properly (patch#10)
> * adjust test scenario for EFI_CAPSULE_ON_DISK_EARLY (patch#10)
> * revise pytest scripts (patch#10)
>
> Initial release as RFC (March 17, 2020)
>
> AKASHI 

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


[PULL] u-boot-mips

2020-04-27 Thread Daniel Schwierzeck
Hi Tom,

please pull MIPS updates for 2020.07, thanks.

https://gitlab.denx.de/u-boot/custodians/u-boot-mips/pipelines/2966
https://travis-ci.org/github/danielschwierzeck/u-boot/builds/680241185


The following changes since commit d16d37bcd4087b8ea0f66cb76a73edad182d151a:

  Merge tag 'video-for-v2020.07-rc1' of 
https://gitlab.denx.de/u-boot/custodians/u-boot-video (2020-04-27 09:41:51 
-0400)

are available in the Git repository at:

  git://git.denx.de/u-boot-mips.git tags/mips-pull-2020-04-27

for you to fetch changes up to 3fd023143237a5271a21ccec4b94440df257a5a7:

  mips: Add support for SoM "VoCore2". (2020-04-27 20:30:14 +0200)


- brcmnand: fix missing code path from Linux driver
- bmips: fix build error when disabling USB
- mips: add option to restore original exception vector base
- mips: fix off-by-one error when clearing gd_data
- mips: minor fixes for compatibility with generic SPL framework
- spl: refactor legacy image loading
- spl: add LZMA decompression support for legacy images
- Makefile: add target to build LZMA compressed U-Boot images
- mtmips: refactor and rewrite low-level init code
- mtmips: add and enable SPL support with LZMA
- mtmips: add support for MT7628 reference board
- mtmips: add support for VoCore/VoCore2 board


Mauro Condarelli (1):
  mips: Add support for SoM "VoCore2".

Stefan Roese (9):
  mips: spl: Flush cache before jumping to U-Boot proper
  spl: Extract legacy image handling into separate file
  spl: spl_legacy: Use IS_ENABLED() to remove #ifdef
  spl: spl_nor: Move legacy image loading into spl_legacy.c
  spl: spl_nor: Remove unused variable 'ret' warning
  mips: mtmips: Increase CONFIG_SPL_SYS_MALLOC_F_LEN
  mips: mt76x8: ddr_cal: Rename dqs_test_valid() to dqs_test_error()
  mips: mt76x8: ddr_cal: Change types from u32 to int in dqs_find_min/max
  mips: mt76x8: ddr_cal: Correct dqs_find_min/max implementations

Weijie Gao (19):
  mips: add support to restore exception vector base before booting linux
  configs: enable CONFIG_RESTORE_EXCEPTION_VECTOR_BASE for all mtmips boards
  mips: mtmips: add predefined i-cache/d-cache size and linesize
  mips: start.S: avoid overwriting outside gd when clearing global data in 
stack
  mips: enable support for appending dtb to spl binary
  mips: add an option to enable u_boot_list section for SPL loaders in 
u-boot-spl.lds
  sysreset: add reset controller based reboot driver
  mips: mtmips: make use of sysreset-resetctrl for mt7628 soc
  mips: add a mtmips-specific field to architecture-specific global data
  dts: mtmips: add alternative pinmux node for uart2
  lib: enable lzma decompression support for SPL build
  Makefile: add support to generate LZMA compressed u-boot image
  spl: spl_legacy: Add lzma decompression support for legacy image
  mips: add an option to support initialize SRAM for initial stack
  mips: add a option to support not reserving malloc space on initial stack
  mips: mtmips: rewrite lowlevel codes of mt7628
  mips: mtmips: add SPL support
  mips: mtmips: enable SPL for all boards
  mips: mtmips: add support for mt7628-rfb

Álvaro Fernández Rojas (2):
  nand: brcmnand: return without disabling clock
  bmips: allow disabling usb support

 Makefile   |  13 +
 arch/mips/Kconfig  |  64 
 arch/mips/cpu/start.S  |  16 +-
 arch/mips/cpu/u-boot-spl.lds   |   4 +-
 arch/mips/dts/Makefile |   2 +
 arch/mips/dts/mediatek,mt7628-rfb.dts  |  67 +
 arch/mips/dts/mt7628-u-boot.dtsi   |  38 +++
 arch/mips/dts/mt7628a.dtsi |  17 +-
 arch/mips/dts/vocore_vocore2.dts   |  85 ++
 arch/mips/include/asm/global_data.h|   3 +
 arch/mips/include/asm/u-boot-mips.h|   2 +
 arch/mips/lib/Makefile |   1 +
 arch/mips/lib/bootm.c  |   3 +
 arch/mips/lib/spl.c|  21 ++
 arch/mips/lib/traps.c  |  19 ++
 arch/mips/mach-mtmips/Kconfig  | 142 -
 arch/mips/mach-mtmips/Makefile |   8 +-
 arch/mips/mach-mtmips/cpu.c|  58 +---
 arch/mips/mach-mtmips/ddr_cal.c| 205 +
 arch/mips/mach-mtmips/ddr_calibrate.c  | 309 ---
 arch/mips/mach-mtmips/ddr_init.c   | 194 
 arch/mips/mach-mtmips/include/mach/ddr.h   |  52 
 arch/mips/mach-mtmips/include/mach/mc.h| 180 +++
 arch/mips/mach-mtmips/include/mach/serial.h|  13 +
 

Re: [PATCH 04/10] efi_loader: capsule: add capsule_on_disk support

2020-04-27 Thread Heinrich Schuchardt
On 4/27/20 11:48 AM, AKASHI Takahiro wrote:
> Capsule data can be loaded into the system either via UpdateCapsule
> runtime service or files on a file system (of boot device).
> The latter case is called "capsules on disk", and actual updates will
> take place at the next boot time.
>
> In this commit, we will support capsule on disk mechanism.
>
> Please note that U-Boot itself has no notion of "boot device" and
> all the capsule files to be executed will be detected only if they
> are located in a specific directory, \EFI\UpdateCapsule, on a device
> that is identified as a boot device by "Boot" variables.
>
> Signed-off-by: AKASHI Takahiro 
> ---
>  common/main.c|   4 +
>  include/efi_loader.h |  16 ++
>  lib/efi_loader/Kconfig   |  22 ++
>  lib/efi_loader/efi_capsule.c | 449 +++
>  lib/efi_loader/efi_setup.c   |   9 +
>  5 files changed, 500 insertions(+)
>
> diff --git a/common/main.c b/common/main.c
> index 06d7ff56d60c..877ae63b708d 100644
> --- a/common/main.c
> +++ b/common/main.c
> @@ -14,6 +14,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  static void run_preboot_environment_command(void)
>  {
> @@ -51,6 +52,9 @@ void main_loop(void)
>   if (IS_ENABLED(CONFIG_UPDATE_TFTP))
>   update_tftp(0UL, NULL, NULL);
>
> + if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY))
> + efi_launch_capsules();
> +

Can't we move this to efi_init_obj_list() and do away with
CONFIG_EFI_CAPSULE_ON_DISK_EARLY?

>   s = bootdelay_process();
>   if (cli_process_fdt())
>   cli_secure_boot_cmd(s);
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 19ffc027c171..d49ebcad53ec 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -793,6 +793,18 @@ efi_status_t EFIAPI efi_query_capsule_caps(
>   u32 *reset_type);
>  #endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */
>
> +#ifdef CONFIG_EFI_CAPSULE_ON_DISK
> +#define EFI_CAPSULE_DIR L"\\EFI\\UpdateCapsule\\"
> +
> +/* Hook at initialization */
> +efi_status_t efi_launch_capsules(void);
> +#else
> +static inline efi_status_t efi_launch_capsules(void)
> +{
> + return EFI_SUCCESS;
> +}
> +#endif /* CONFIG_EFI_CAPSULE_ON_DISK */
> +
>  #else /* CONFIG_IS_ENABLED(EFI_LOADER) */
>
>  /* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out */
> @@ -809,6 +821,10 @@ static inline void efi_set_bootdev(const char *dev, 
> const char *devnr,
>  const char *path) { }
>  static inline void efi_net_set_dhcp_ack(void *pkt, int len) { }
>  static inline void efi_print_image_infos(void *pc) { }
> +static inline efi_status_t efi_launch_capsules(void)
> +{
> + return EFI_SUCCESS;
> +}
>
>  #endif /* CONFIG_IS_ENABLED(EFI_LOADER) */
>
> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> index e2b08251f26a..b48b95a32e03 100644
> --- a/lib/efi_loader/Kconfig
> +++ b/lib/efi_loader/Kconfig
> @@ -56,6 +56,28 @@ config EFI_RUNTIME_UPDATE_CAPSULE
> Select this option if you want to use UpdateCapsule and
> QueryCapsuleCapabilities API's.
>
> +config EFI_CAPSULE_ON_DISK
> + bool "Enable capsule-on-disk support"
> + select EFI_HAVE_CAPSULE_SUPPORT
> + default n
> + help
> +   Select this option if you want to use capsule-on-disk feature,
> +   that is, capsules can be fetched and executed from files
> +   under a specific directory on UEFI system partition instead of
> +   via UpdateCapsule API.
> +
> +config EFI_CAPSULE_ON_DISK_EARLY
> + bool "Initiate capsule-on-disk at U-Boot boottime"
> + depends on EFI_CAPSULE_ON_DISK
> + default y
> + select EFI_SETUP_EARLY
> + help
> +   Normally, without this option enabled, capsules will be
> +   executed only at the first time of invoking one of efi command.
> +   If this option is enabled, capsules will be enforced to be
> +   executed as part of U-Boot initialisation so that they will
> +   surely take place whatever is set to distro_bootcmd.

Why do we need this Kconfig variable if we have EFI_SETUP_EARLY available?

> +
>  config EFI_DEVICE_PATH_TO_TEXT
>   bool "Device path to text protocol"
>   default y
> diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
> index fb104bb92a6c..938129a41934 100644
> --- a/lib/efi_loader/efi_capsule.c
> +++ b/lib/efi_loader/efi_capsule.c
> @@ -10,10 +10,16 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>
>  const efi_guid_t efi_guid_capsule_report = EFI_CAPSULE_REPORT_GUID;
>
> +#ifdef CONFIG_EFI_CAPSULE_ON_DISK
> +/* for file system access */
> +static struct efi_file_handle *bootdev_root;
> +#endif
> +
>  static __maybe_unused int get_last_capsule(void)
>  {
>   u16 value16[11]; /* "Capsule": non-null-terminated */
> @@ -151,3 +157,446 @@ efi_status_t EFIAPI efi_query_capsule_caps(
>  out:
>   return EFI_EXIT(ret);
>  }
> +
> +#ifdef 

Re: [PATCH 09/10] tools: add mkeficapsule command for UEFI capsule update test

2020-04-27 Thread Heinrich Schuchardt
On 4/27/20 11:48 AM, AKASHI Takahiro wrote:
> This is a utility mainly for test purpose.
>   mkeficapsule -f: create a test capsule file for FIT image firmware
>
> Having said that, you will be able to customize the code to fit
> your specific requirements for your platform.
>
> Signed-off-by: AKASHI Takahiro 
> ---
>  tools/Makefile   |   3 +
>  tools/mkeficapsule.c | 209 +++
>  2 files changed, 212 insertions(+)
>  create mode 100644 tools/mkeficapsule.c
>
> diff --git a/tools/Makefile b/tools/Makefile
> index c2b26340047a..08e97063d5fa 100644
> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -222,6 +222,9 @@ hostprogs-$(CONFIG_MIPS) += mips-relocs
>  hostprogs-$(CONFIG_ASN1_COMPILER)+= asn1_compiler
>  HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include
>
> +# TODO: only build this for capsule pytest

Do you plan to send a new version of the series to fix this issue?

We need a documentation page for this tool in doc/uefi/.

Best regards

Heinrich

> +hostprogs-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += mkeficapsule
> +
>  # We build some files with extra pedantic flags to try to minimize things
>  # that won't build on some weird host compiler -- though there are lots of
>  # exceptions for files that aren't complaint.
> diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c
> new file mode 100644
> index ..b26c88e42020
> --- /dev/null
> +++ b/tools/mkeficapsule.c
> @@ -0,0 +1,209 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright 2018 Linaro Limited
> + *   Author: AKASHI Takahiro
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +/*
> + * TODO: use libefi/libgnuefi headers

Can't you use the definitions from include/efi_api.h?
I would prefer if you could avoid duplicate definitions in this file.

Best regards

Heinrich

> + */
> +
> +typedef u_int8_t u8;
> +typedef u_int16_t u16;
> +typedef u_int32_t u32;
> +typedef u_int64_t u64;
> +
> +/* include/efi.h */
> +typedef struct {
> + u8 b[16];
> +} efi_guid_t;
> +
> +#define EFI_GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
> + {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, \
> + ((a) >> 24) & 0xff, \
> + (b) & 0xff, ((b) >> 8) & 0xff, \
> + (c) & 0xff, ((c) >> 8) & 0xff, \
> + (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) } }
> +
> +#define EFI_VARIABLE_NON_VOLATILE0x0001
> +#define EFI_VARIABLE_BOOTSERVICE_ACCESS  0x0002
> +#define EFI_VARIABLE_RUNTIME_ACCESS  0x0004
> +
> +/* include/efi_api.h */
> +#define EFI_GLOBAL_VARIABLE_GUID \
> + EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, \
> +  0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c)
> +
> +#define CAPSULE_FLAGS_PERSIST_ACROSS_RESET   0x0001
> +#define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE  0x0002
> +#define CAPSULE_FLAGS_INITIATE_RESET 0x0004
> +
> +#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID \
> + EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \
> +  0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47)
> +
> +#define EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID \
> + EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \
> +  0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)
> +
> +struct efi_capsule_header {
> + efi_guid_t capsule_guid;
> + u32 header_size;
> + u32 flags;
> + u32 capsule_image_size;
> +} __attribute__((packed));
> +
> +struct efi_capsule_block_descriptor {
> + u64 length;
> + union {
> + u64 data_block;
> + u64 continuation_ptr;
> + };
> +} __attribute__((packed));
> +
> +struct efi_firmware_management_capsule_header {
> + u32 version;
> + u16 embedded_driver_count;
> + u16 payload_item_count;
> + u64 item_offset_list[];
> +} __attribute__((packed));
> +
> +struct efi_firmware_management_capsule_image_header {
> + u32 version;
> + efi_guid_t update_image_type_id;
> + u8 update_image_index;
> + u8 reserved[3];
> + u32 update_image_size;
> + u32 update_vendor_code_size;
> + u64 update_hardware_instance;
> +} __attribute__((packed));
> +
> +efi_guid_t efi_guid_fm_capsule = EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID;
> +efi_guid_t efi_guid_image_type_uboot_fit =
> + EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID;
> +
> +static int create_fwbin(char *bin, char *path)
> +{
> + struct efi_capsule_header header;
> + struct efi_firmware_management_capsule_header capsule;
> + struct efi_firmware_management_capsule_image_header image;
> + FILE *f, *g;
> + struct stat bin_stat;
> + u8 *data;
> + size_t size;
> +
> + g = fopen(bin, "r");
> + if (!g) {
> + printf("cannot open %s\n", bin);
> + return -1;
> + }
> + if (stat(bin, _stat) < 0) {
> + printf("cannot determine the size of %s\n", bin);
> + goto err_1;
> + }
> + data = malloc(bin_stat.st_size);
> + if 

Re: [PATCH 02/10] efi_loader: add option to initialise EFI subsystem early

2020-04-27 Thread Heinrich Schuchardt
On 4/27/20 11:48 AM, AKASHI Takahiro wrote:
> If this option is enabled, the initialisation of UEFI subsystem will be
> done as part of U-Boot initialisation.
>
> This feature will be utilised in implementing capsule-on-disk feature.

This would mean that we allow unaligned access very early. Something
Siarhei was against:

https://lists.denx.de/pipermail/u-boot/2018-March/324242.html
https://patchwork.ozlabs.org/project/uboot/patch/20180329213350.7868-1-xypron.g...@gmx.de/

Why can't you wait with the capsule update until any command initializes
the UEFI sub-system.

Best regards

Heinrich

>
> Signed-off-by: AKASHI Takahiro 
> ---
>  common/board_r.c   | 6 ++
>  lib/efi_loader/Kconfig | 4 
>  2 files changed, 10 insertions(+)
>
> diff --git a/common/board_r.c b/common/board_r.c
> index 0bbeaa7594c6..7cf21a6078f9 100644
> --- a/common/board_r.c
> +++ b/common/board_r.c
> @@ -64,6 +64,9 @@
>  #if defined(CONFIG_GPIO_HOG)
>  #include 
>  #endif
> +#ifdef CONFIG_EFI_SETUP_EARLY
> +#include 
> +#endif
>
>  DECLARE_GLOBAL_DATA_PTR;
>
> @@ -867,6 +870,9 @@ static init_fnc_t init_sequence_r[] = {
>  #endif
>  #if defined(CONFIG_M68K) && defined(CONFIG_BLOCK_CACHE)
>   blkcache_init,
> +#endif
> +#ifdef CONFIG_EFI_SETUP_EARLY
> + (init_fnc_t)efi_init_obj_list,
>  #endif
>   run_main_loop,
>  };
> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> index 1cfa24ffcf72..7cc2d940f848 100644
> --- a/lib/efi_loader/Kconfig
> +++ b/lib/efi_loader/Kconfig
> @@ -25,6 +25,10 @@ config EFI_LOADER
>
>  if EFI_LOADER
>
> +config EFI_SETUP_EARLY
> + bool
> + default n
> +
>  config EFI_GET_TIME
>   bool "GetTime() runtime service"
>   depends on DM_RTC
>



Re: [PATCH 01/10] efi_loader: disk: add efi_disk_is_system_part()

2020-04-27 Thread Heinrich Schuchardt
On 4/27/20 11:48 AM, AKASHI Takahiro wrote:
> This function will check if a given handle to device is a EFI system
> partition. It will be utilised in implementing capsule-on-disk feature.
>
> Signed-off-by: AKASHI Takahiro 

Just a reminder for me:

This patch depends on
"part: detect EFI system partition"
https://lists.denx.de/pipermail/u-boot/2020-April/408150.html

> ---
>  include/efi_loader.h  |  2 ++
>  lib/efi_loader/efi_disk.c | 22 ++
>  2 files changed, 24 insertions(+)
>
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index b7bccf50b30c..d4510462d616 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -393,6 +393,8 @@ efi_status_t efi_disk_register(void);
>  int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
>  const char *if_typename, int diskid,
>  const char *pdevname);
> +/* Check if it is EFI system partition */
> +bool efi_disk_is_system_part(efi_handle_t handle);
>  /* Called by bootefi to make GOP (graphical) interface available */
>  efi_status_t efi_gop_register(void);
>  /* Called by bootefi to make the network interface available */
> diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
> index fd3df80b0b96..9f58a8642c85 100644
> --- a/lib/efi_loader/efi_disk.c
> +++ b/lib/efi_loader/efi_disk.c
> @@ -588,3 +588,25 @@ efi_status_t efi_disk_register(void)
>
>   return EFI_SUCCESS;
>  }
> +

Please, provide a function description, cf.
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation

> +bool efi_disk_is_system_part(efi_handle_t handle)
> +{
> + struct efi_handler *handler;
> + struct efi_disk_obj *diskobj;
> + disk_partition_t info;
> + efi_status_t ret;
> + int r;
> +
> + /* check if this is a block device */
> + ret = efi_search_protocol(handle, _block_io_guid, );
> + if (ret != EFI_SUCCESS)
> + return false;
> +
> + diskobj = container_of(handle, struct efi_disk_obj, header);

This is just a complicated way of saying:

diskobj = (struct efi_disk_obj *)handle;

I would rather avoid container_of() here though it is not wrong.

Best regards

Heinrich

> +
> + r = part_get_info(diskobj->desc, diskobj->part, );
> + if (r)
> + return false;
> +
> + return info.bootable & PART_EFI_SYSTEM_PARTITION;
> +}
>


Re: [U-Boot] Makefile: Only build dtc if needed

2020-04-27 Thread Tom Rini
On Sun, Apr 26, 2020 at 06:34:48PM -0600, Simon Glass wrote:
> Hi Tom,
> 
> On Sat, 26 Jan 2019 at 20:51, Tom Rini  wrote:
> >
> > On Tue, Nov 13, 2018 at 03:43:07PM -0700, Simon Glass wrote:
> >
> > > At present U-Boot always builds dtc if CONFIG_OF_CONTROL is defined. This
> > > is wasteful when the system already has a suitable version available.
> > >
> > > Update the Makefile logic to build dtc only if the version available is
> > > too old.
> > >
> > > This saves about 3 seconds of CPU time on a clean build for me.
> > >
> > > Signed-off-by: Simon Glass 
> > > Reviewed-by: Marek Vasut 
> >
> > In the case of new enough host dtc this then fails on sandbox_spl,
> > chromebook_minnie and others where we need to build
> > spl/dts/dt-platdata.c with a python import error over lacking _libfdt.
> 
> I'm not sure if it has been long enough, but have the packages been
> updated to include pylibfdt?
> 
> I'm sending a new version of this patch that checks for that.

I honestly don't know how far behind distributions lag here and then in
turn how old something is before we say "sorry, you can't build there
easily".

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 1/4] omap: mmc: Avoid using libfdt with of-platdata

2020-04-27 Thread Tom Rini
On Mon, Apr 27, 2020 at 05:33:41AM +, Peng Fan wrote:
> > Subject: [PATCH v5 1/4] omap: mmc: Avoid using libfdt with of-platdata
> > 
> > At present this driver is enabled in SPL on omapl138_lcdk, which uses
> > of-platdata. The driver needs to be ported to use of-platdata properly.
> > For now, avoid a build error by returning an error.
> > 
> > Signed-off-by: Simon Glass 
> 
> Acked-by: Peng Fan 

Since the board maintainer is on CC and I believe that platform is still
actively used in testing, I want to see this fixed rather than turned in
to a run-time error.  Thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: Build error in u-boot-dm/master

2020-04-27 Thread Stephen Warren
On 4/27/20 11:02 AM, Simon Glass wrote:
> Hi Stephen,
> 
> On Mon, 27 Apr 2020 at 10:04, Stephen Warren  wrote:
>>
>> Simon,
>>
>> All 32-bit Tegra builds of u-boot-dm/master are failing with the
>> following (this log is from Harmony):
>>
>>>   CC  spl/common/spl/spl.o
>>>   CC  spl/lib/display_options.o
>>>   LD  spl/common/spl/built-in.o
>>>   LD  spl/lib/built-in.o
>>>   LD  spl/u-boot-spl
>>>   OBJCOPY spl/u-boot-spl-nodtb.bin
>>>   COPYspl/u-boot-spl.bin
>>>   BINMAN  u-boot-tegra.bin
>>> binman: bad magic number in 'binman.etype': b'\x03\xf3\r\n'
>>> /var/lib/jenkins/workspace/u-boot-denx_uboot_dm-master-build/src/u-boot/Makefile:1619:
>>>  recipe for target 'u-boot-tegra.bin' failed
>>> make[1]: *** [u-boot-tegra.bin] Error 1
> 
> Oh wow, that is a strange one. Could it be bad Python cache files again?

Ah yes, so it is. I'd forgotten about that, and initially thought it
couldn't be the issue, since the problem only affects some boards not
all, and on my system they're all built in the same source tree
(serially). However, I guess our 64-bit builds don't run the tool that
triggers the problem, so that explains the differences.

Deleting tools/binman/etype/__init__.pyc did solve the issue, and that
file doesn't get re-created if 16287933a8 "binman: Move to absolute
imports" is applied.

Do you know what causes the issue, or how it can be avoided?

Maybe running "git clean -fdx" on the source tree before building would
be a workaround, but I'd rather solve the root-cause if possible.


[PATCH 1/2] JFFS2: Process obsolete nodes as well as accurate ones

2020-04-27 Thread petr . borsodi
From: Petr Borsodi 

Obsolete nodes (ie. without the JFFS2_NODE_ACCURATE flag) were ignored because
they had seemingly invalid crc. This could lead to finding the phantom node
header in obsolete node data.

Signed-off-by: Petr Borsodi 
---

 fs/jffs2/jffs2_1pass.c | 67 +++---
 1 file changed, 43 insertions(+), 24 deletions(-)

diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
index 5912cde838..819a44eeeb 100644
--- a/fs/jffs2/jffs2_1pass.c
+++ b/fs/jffs2/jffs2_1pass.c
@@ -1471,7 +1471,7 @@ static u32
 jffs2_1pass_build_lists(struct part_info * part)
 {
struct b_lists *pL;
-   struct jffs2_unknown_node *node;
+   union jffs2_node_union *node;
u32 nr_sectors;
u32 i;
u32 counter4 = 0;
@@ -1507,6 +1507,7 @@ jffs2_1pass_build_lists(struct part_info * part)
 #endif
/* Indicates a sector with a CLEANMARKER was found */
int clean_sector = 0;
+   struct jffs2_unknown_node crcnode;
 
/* Set buf_size to maximum length */
buf_size = DEFAULT_EMPTY_SCAN_SIZE;
@@ -1600,9 +1601,9 @@ jffs2_1pass_build_lists(struct part_info * part)
}
prevofs = ofs;
if (sector_ofs + part->sector_size <
-   ofs + sizeof(*node))
+   ofs + sizeof(struct jffs2_unknown_node))
break;
-   if (buf_ofs + buf_len < ofs + sizeof(*node)) {
+   if (buf_ofs + buf_len < ofs + sizeof(struct 
jffs2_unknown_node)) {
buf_len = min_t(uint32_t, buf_size, sector_ofs
+ part->sector_size - ofs);
get_fl_mem((u32)part->offset + ofs, buf_len,
@@ -1610,7 +1611,7 @@ jffs2_1pass_build_lists(struct part_info * part)
buf_ofs = ofs;
}
 
-   node = (struct jffs2_unknown_node *)[ofs-buf_ofs];
+   node = (union jffs2_node_union *)[ofs-buf_ofs];
 
if (*(uint32_t *)([ofs-buf_ofs]) == 0x) {
uint32_t inbuf_ofs;
@@ -1665,23 +1666,41 @@ jffs2_1pass_build_lists(struct part_info * part)
 * the 'clean_sector' flag.
 */
clean_sector = 0;
-   if (node->magic != JFFS2_MAGIC_BITMASK ||
-   !hdr_crc(node)) {
+   if (node->u.magic != JFFS2_MAGIC_BITMASK) {
+   ofs += 4;
+   counter4++;
+   continue;
+   }
+
+   crcnode.magic = node->u.magic;
+   crcnode.nodetype = node->u.nodetype | 
JFFS2_NODE_ACCURATE;
+   crcnode.totlen = node->u.totlen;
+   crcnode.hdr_crc = node->u.hdr_crc;
+   if (!hdr_crc()) {
ofs += 4;
counter4++;
continue;
}
-   if (ofs + node->totlen >
-   sector_ofs + part->sector_size) {
+
+   if (ofs + node->u.totlen > sector_ofs + 
part->sector_size) {
ofs += 4;
counter4++;
continue;
}
+
+   if (!(node->u.nodetype & JFFS2_NODE_ACCURATE)) {
+   DEBUGF("Obsolete node type: %x len %d offset 
0x%x\n",
+   node->u.nodetype,
+   node->u.totlen, ofs);
+   ofs += ((node->u.totlen + 3) & ~3);
+   counterF++;
+   continue;
+   }
+
/* if its a fragment add it */
-   switch (node->nodetype) {
+   switch (node->u.nodetype) {
case JFFS2_NODETYPE_INODE:
-   if (buf_ofs + buf_len < ofs + sizeof(struct
-   jffs2_raw_inode)) {
+   if (buf_ofs + buf_len < ofs + sizeof(struct 
jffs2_raw_inode)) {
buf_len = min_t(uint32_t,
sizeof(struct 
jffs2_raw_inode),
sector_ofs +
@@ -1701,8 +1720,8 @@ jffs2_1pass_build_lists(struct part_info * part)
jffs2_free_cache(part);

[PATCH 2/2] JFFS2: Add useful fields into lists

2020-04-27 Thread petr . borsodi
From: Petr Borsodi 

The inode list uses version and ino, the dirent list uses version and pino.
This information is collected during scanning, reducing accesses to flash
and significantly speeding up ls and read.

Signed-off-by: Petr Borsodi 
---

 fs/jffs2/jffs2_1pass.c   | 154 +++
 fs/jffs2/jffs2_private.h |   5 ++
 2 files changed, 81 insertions(+), 78 deletions(-)

diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
index 819a44eeeb..3b98384b8b 100644
--- a/fs/jffs2/jffs2_1pass.c
+++ b/fs/jffs2/jffs2_1pass.c
@@ -549,7 +549,7 @@ add_node(struct b_list *list)
 }
 
 static struct b_node *
-insert_node(struct b_list *list, u32 offset)
+insert_node(struct b_list *list)
 {
struct b_node *new;
 
@@ -557,7 +557,6 @@ insert_node(struct b_list *list, u32 offset)
putstr("add_node failed!\r\n");
return NULL;
}
-   new->offset = offset;
new->next = NULL;
 
if (list->listTail != NULL)
@@ -575,18 +574,7 @@ insert_node(struct b_list *list, u32 offset)
  */
 static int compare_inodes(struct b_node *new, struct b_node *old)
 {
-   /*
-* Only read in the version info from flash, not the entire inode.
-* This can make a big difference to speed if flash is slow.
-*/
-   u32 new_version;
-   u32 old_version;
-   get_fl_mem(new->offset + offsetof(struct jffs2_raw_inode, version),
-  sizeof(new_version), _version);
-   get_fl_mem(old->offset + offsetof(struct jffs2_raw_inode, version),
-  sizeof(old_version), _version);
-
-   return new_version > old_version;
+   return new->version > old->version;
 }
 
 /* Sort directory entries so all entries in the same directory
@@ -683,7 +671,7 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 inode, char 
*dest)
uchar *src;
int i;
u32 counter = 0;
-#ifdef CONFIG_SYS_JFFS2_SORT_FRAGMENTS
+
/* Find file size before loading any data, so fragments that
 * start past the end of file can be ignored. A fragment
 * that is partially in the file is loaded, so extra data may
@@ -691,35 +679,40 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 inode, 
char *dest)
 * This shouldn't cause trouble when loading kernel images, so
 * we will live with it.
 */
+   int latestOffset = -1;
for (b = pL->frag.listHead; b != NULL; b = b->next) {
-   jNode = (struct jffs2_raw_inode *) get_fl_mem(b->offset,
-   sizeof(struct jffs2_raw_inode), pL->readbuf);
-   if ((inode == jNode->ino)) {
+   if ((inode == b->ino)) {
/* get actual file length from the newest node */
-   if (jNode->version >= latestVersion) {
-   totalSize = jNode->isize;
-   latestVersion = jNode->version;
+   if (b->version >= latestVersion) {
+   latestVersion = b->version;
+   latestOffset = b->offset;
}
}
+   }
+
+   if (latestOffset >= 0) {
+   jNode = (struct jffs2_raw_inode *) get_fl_mem(latestOffset,
+   sizeof(struct jffs2_raw_inode), pL->readbuf);
+   totalSize = jNode->isize;
put_fl_mem(jNode, pL->readbuf);
}
+
/*
 * If no destination is provided, we are done.
 * Just return the total size.
 */
if (!dest)
return totalSize;
-#endif
 
for (b = pL->frag.listHead; b != NULL; b = b->next) {
-   /*
-* Copy just the node and not the data at this point,
-* since we don't yet know if we need this data.
-*/
-   jNode = (struct jffs2_raw_inode *)get_fl_mem(b->offset,
-   sizeof(struct jffs2_raw_inode),
-   pL->readbuf);
-   if (inode == jNode->ino) {
+   if (inode == b->ino) {
+   /*
+* Copy just the node and not the data at this point,
+* since we don't yet know if we need this data.
+*/
+   jNode = (struct jffs2_raw_inode *)get_fl_mem(b->offset,
+   sizeof(struct jffs2_raw_inode),
+   pL->readbuf);
 #if 0
putLabeledWord("\r\n\r\nread_inode: totlen = ", 
jNode->totlen);
putLabeledWord("read_inode: inode = ", jNode->ino);
@@ -733,14 +726,6 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 inode, char 
*dest)
putLabeledWord("read_inode: flags = ", jNode->flags);
 #endif
 
-#ifndef CONFIG_SYS_JFFS2_SORT_FRAGMENTS
-   /* get actual file length 

[PATCH v3 4/7] arm: juno: Enable OF_CONTROL

2020-04-27 Thread Andre Przywara
The Arm Juno board was still somewhat stuck in "hardcoded land", even
though there are stable DTs around, and one happens to actually be on
the memory mapped NOR flash.

Enable the configuration options to let the board use OF_CONTROL, and
add a routine to find the address of the DTB partition in NOR
flash, to use that for U-Boot's own purposes.
This can also passed on via $fdtcontroladdr to any kernel or EFI
application, removing the need to actually load a device tree.

Since the existing "afs" command and its flash routines require
flash_init() to be called before being usable, and this is done much
later in the boot process, we introduce a stripped-down partition finder
routine in vexpress64.c, to scan the NOR flash partitions for the
DT partition. This location is then used for U-Boot to find and probe
devices.

The name of the partition can be configured, if needed, but defaults
to "board.dtb", which is used by Linaro's firmware image provided.

Signed-off-by: Andre Przywara 
Reviewed-by: Linus Walleij 
---
 arch/arm/Kconfig   |  5 +++
 board/armltd/vexpress64/Kconfig|  7 
 board/armltd/vexpress64/vexpress64.c   | 57 ++
 configs/vexpress_aemv8a_juno_defconfig |  4 +-
 4 files changed, 70 insertions(+), 3 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 1bcf345028..cf8b629c0e 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1133,6 +1133,11 @@ config TARGET_VEXPRESS64_JUNO
bool "Support Versatile Express Juno Development Platform"
select ARM64
select PL01X_SERIAL
+   select DM
+   select OF_CONTROL
+   select OF_BOARD
+   select CLK
+   select DM_SERIAL
 
 config TARGET_LS2080A_EMU
bool "Support ls2080a_emu"
diff --git a/board/armltd/vexpress64/Kconfig b/board/armltd/vexpress64/Kconfig
index 9014418433..1d13f542e6 100644
--- a/board/armltd/vexpress64/Kconfig
+++ b/board/armltd/vexpress64/Kconfig
@@ -9,4 +9,11 @@ config SYS_VENDOR
 config SYS_CONFIG_NAME
default "vexpress_aemv8a"
 
+config JUNO_DTB_PART
+   string "NOR flash partition holding DTB"
+   default "board.dtb"
+   help
+ The ARM partition name in the NOR flash memory holding the
+ device tree blob to configure U-Boot.
+
 endif
diff --git a/board/armltd/vexpress64/vexpress64.c 
b/board/armltd/vexpress64/vexpress64.c
index dd0ebdd303..ba49b32e58 100644
--- a/board/armltd/vexpress64/vexpress64.c
+++ b/board/armltd/vexpress64/vexpress64.c
@@ -82,6 +82,63 @@ int dram_init_banksize(void)
return 0;
 }
 
+#ifdef CONFIG_OF_BOARD
+#define JUNO_FLASH_SEC_SIZE(256 * 1024)
+static phys_addr_t find_dtb_in_nor_flash(const char *partname)
+{
+   phys_addr_t sector = CONFIG_SYS_FLASH_BASE;
+   int i;
+
+   for (i = 0;
+i < CONFIG_SYS_MAX_FLASH_SECT;
+i++, sector += JUNO_FLASH_SEC_SIZE) {
+   int len = strlen(partname) + 1;
+   int offs;
+   phys_addr_t imginfo;
+   u32 reg;
+
+   reg = readl(sector + JUNO_FLASH_SEC_SIZE - 0x04);
+/* This makes up the string "HSLFTOOF" flash footer */
+   if (reg != 0x464F4F54U)
+   continue;
+   reg = readl(sector + JUNO_FLASH_SEC_SIZE - 0x08);
+if (reg != 0x464C5348U)
+   continue;
+
+   for (offs = 0; offs < 32; offs += 4, len -= 4) {
+   reg = readl(sector + JUNO_FLASH_SEC_SIZE - 0x30 + offs);
+   if (strncmp(partname + offs, (char *),
+   len > 4 ? 4 : len))
+   break;
+
+   if (len > 4)
+   continue;
+
+   reg = readl(sector + JUNO_FLASH_SEC_SIZE - 0x10);
+   imginfo = sector + JUNO_FLASH_SEC_SIZE - 0x30 - reg;
+   reg = readl(imginfo + 0x54);
+
+   return CONFIG_SYS_FLASH_BASE +
+  reg * JUNO_FLASH_SEC_SIZE;
+   }
+   }
+
+   printf("No DTB found\n");
+
+   return ~0;
+}
+
+void *board_fdt_blob_setup(void)
+{
+   phys_addr_t fdt_rom_addr = find_dtb_in_nor_flash(CONFIG_JUNO_DTB_PART);
+
+   if (fdt_rom_addr == ~0UL)
+   return NULL;
+
+   return (void *)fdt_rom_addr;
+}
+#endif
+
 /*
  * Board specific reset that is system reset.
  */
diff --git a/configs/vexpress_aemv8a_juno_defconfig 
b/configs/vexpress_aemv8a_juno_defconfig
index 8628d05e68..6cb21e7a1b 100644
--- a/configs/vexpress_aemv8a_juno_defconfig
+++ b/configs/vexpress_aemv8a_juno_defconfig
@@ -10,6 +10,7 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTDELAY=1
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyAMA0,115200n8 root=/dev/sda2 rw rootwait 
earlycon=pl011,0x7ff8 debug user_debug=31 androidboot.hardware=juno 
loglevel=9"
+CONFIG_OF_BOARD=y
 # CONFIG_USE_BOOTCOMMAND is not 

[PATCH v3 2/7] uart: pl011: Add proper DM clock support

2020-04-27 Thread Andre Przywara
Even though the PL011 UART driver claims to be DM compliant, it does not
really a good job with parsing DT nodes. U-Boot seems to adhere to a
non-standard binding, either requiring to have a "skip-init" property in
the node, or to have an extra "clock" property holding the base
*frequency* value for the baud rate generator.
DTs in the U-Boot tree seem to have been hacked to match this
requirement.

The official binding does not mention any of these properties, instead
recommends a standard "clocks" property to point to the baud base clock.

Some boards use simple "fixed-clock" providers, which U-Boot readily
supports, so let's add some simple DM clock code to the PL011 driver to
learn the rate of the first clock, as described by the official binding.

These clock nodes seem to be not ready very early in the boot process,
so provide a fallback value, by re-using the already existing
CONFIG_PL011_CLOCK variable.

Signed-off-by: Andre Przywara 
---
 drivers/serial/serial_pl01x.c | 47 +++
 1 file changed, 31 insertions(+), 16 deletions(-)

diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c
index 2a5f256184..14040f32ef 100644
--- a/drivers/serial/serial_pl01x.c
+++ b/drivers/serial/serial_pl01x.c
@@ -12,6 +12,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -149,21 +150,24 @@ static int pl01x_generic_setbrg(struct pl01x_regs *regs, 
enum pl01x_type type,
unsigned int remainder;
unsigned int fraction;
 
-   /*
-   * Set baud rate
-   *
-   * IBRD = UART_CLK / (16 * BAUD_RATE)
-   * FBRD = RND((64 * MOD(UART_CLK,(16 * BAUD_RATE)))
-   *   / (16 * BAUD_RATE))
-   */
-   temp = 16 * baudrate;
-   divider = clock / temp;
-   remainder = clock % temp;
-   temp = (8 * remainder) / baudrate;
-   fraction = (temp >> 1) + (temp & 1);
-
-   writel(divider, >pl011_ibrd);
-   writel(fraction, >pl011_fbrd);
+   /* Without a valid clock rate we cannot set up the baudrate. */
+   if (clock) {
+   /*
+* Set baud rate
+*
+* IBRD = UART_CLK / (16 * BAUD_RATE)
+* FBRD = RND((64 * MOD(UART_CLK,(16 * BAUD_RATE)))
+*  / (16 * BAUD_RATE))
+*/
+   temp = 16 * baudrate;
+   divider = clock / temp;
+   remainder = clock % temp;
+   temp = (8 * remainder) / baudrate;
+   fraction = (temp >> 1) + (temp & 1);
+
+   writel(divider, >pl011_ibrd);
+   writel(fraction, >pl011_fbrd);
+   }
 
pl011_set_line_control(regs);
/* Finally, enable the UART */
@@ -337,17 +341,28 @@ static const struct udevice_id pl01x_serial_id[] ={
{}
 };
 
+#ifndef CONFIG_PL011_CLOCK
+#define CONFIG_PL011_CLOCK 0
+#endif
+
 int pl01x_serial_ofdata_to_platdata(struct udevice *dev)
 {
struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
+   struct clk clk;
fdt_addr_t addr;
+   int ret;
 
addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
return -EINVAL;
 
plat->base = addr;
-   plat->clock = dev_read_u32_default(dev, "clock", 1);
+   plat->clock = dev_read_u32_default(dev, "clock", CONFIG_PL011_CLOCK);
+   ret = clk_get_by_index(dev, 0, );
+   if (!ret) {
+   clk_enable();
+   plat->clock = clk_get_rate();
+   }
plat->type = dev_get_driver_data(dev);
plat->skip_init = dev_read_bool(dev, "skip-init");
 
-- 
2.17.5



[PATCH v3 6/7] arm: juno: enable USB

2020-04-27 Thread Andre Przywara
The Juno board features a standard compliant EHCI/OHCI USB host
controller pair, which we can just enable.
The platform data is taken from the device tree.

This allows to use USB mass storage (the only storage on a Juno r0)
for loading.

At least on my board USB seems a bit flaky, I need two "usb reset"
sequences after the "usb start" to detect an USB hard drive.

Signed-off-by: Andre Przywara 
Acked-by: Liviu Dudau 
Reviewed-by: Linus Walleij 
---
 arch/arm/Kconfig   | 4 
 configs/vexpress_aemv8a_juno_defconfig | 5 +
 include/configs/vexpress_aemv8a.h  | 5 +
 3 files changed, 14 insertions(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 449ef06be5..d582281e40 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1140,6 +1140,10 @@ config TARGET_VEXPRESS64_JUNO
select DM_SERIAL
select ARM_PSCI_FW
select PSCI_RESET
+   select DM
+   select BLK
+   select USB
+   select DM_USB
 
 config TARGET_LS2080A_EMU
bool "Support ls2080a_emu"
diff --git a/configs/vexpress_aemv8a_juno_defconfig 
b/configs/vexpress_aemv8a_juno_defconfig
index 6cb21e7a1b..ca7aa5ab02 100644
--- a/configs/vexpress_aemv8a_juno_defconfig
+++ b/configs/vexpress_aemv8a_juno_defconfig
@@ -27,6 +27,7 @@ CONFIG_CMD_ARMFLASH=y
 CONFIG_CMD_CACHE=y
 # CONFIG_CMD_MISC is not set
 CONFIG_CMD_UBI=y
+CONFIG_CMD_USB=y
 # CONFIG_ISO_PARTITION is not set
 # CONFIG_EFI_PARTITION is not set
 CONFIG_ENV_IS_IN_FLASH=y
@@ -41,3 +42,7 @@ CONFIG_SYS_FLASH_CFI=y
 CONFIG_SMC911X=y
 CONFIG_SMC911X_BASE=0x01800
 CONFIG_SMC911X_32_BIT=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_GENERIC=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_OHCI_GENERIC=y
diff --git a/include/configs/vexpress_aemv8a.h 
b/include/configs/vexpress_aemv8a.h
index 3c85c93a5c..08ad368dbb 100644
--- a/include/configs/vexpress_aemv8a.h
+++ b/include/configs/vexpress_aemv8a.h
@@ -219,6 +219,11 @@
 #define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_32BIT
 #define CONFIG_SYS_MAX_FLASH_BANKS 1
 
+#ifdef CONFIG_USB_EHCI_HCD
+#define CONFIG_USB_OHCI_NEW
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 1
+#endif
+
 #define CONFIG_SYS_FLASH_EMPTY_INFO/* flinfo indicates empty blocks */
 #define FLASH_MAX_SECTOR_SIZE  0x0004
 
-- 
2.17.5



[PATCH v3 5/7] arm: juno: Use PSCI based reset

2020-04-27 Thread Andre Przywara
So far the Juno board wasn't implementing reset. Let's just use the
already existing PSCI_RESET based method to avoid any extra code.

Signed-off-by: Andre Przywara 
Acked-by: Liviu Dudau 
---
 arch/arm/Kconfig | 2 ++
 board/armltd/vexpress64/vexpress64.c | 4 +---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index cf8b629c0e..449ef06be5 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1138,6 +1138,8 @@ config TARGET_VEXPRESS64_JUNO
select OF_BOARD
select CLK
select DM_SERIAL
+   select ARM_PSCI_FW
+   select PSCI_RESET
 
 config TARGET_LS2080A_EMU
bool "Support ls2080a_emu"
diff --git a/board/armltd/vexpress64/vexpress64.c 
b/board/armltd/vexpress64/vexpress64.c
index ba49b32e58..5c7a8f55f0 100644
--- a/board/armltd/vexpress64/vexpress64.c
+++ b/board/armltd/vexpress64/vexpress64.c
@@ -139,9 +139,7 @@ void *board_fdt_blob_setup(void)
 }
 #endif
 
-/*
- * Board specific reset that is system reset.
- */
+/* Actual reset is done via PSCI. */
 void reset_cpu(ulong addr)
 {
 }
-- 
2.17.5



[PATCH v3 7/7] arm: vexpress64: Remove unneeded CONFIG_ check

2020-04-27 Thread Andre Przywara
CONFIG_SEMIHOSTING is selected for the VFP target by the means of
Kconfig already, there is no need to check this in the header file.

Signed-off-by: Andre Przywara 
Reviewed-by: Linus Walleij 
---
 include/configs/vexpress_aemv8a.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/include/configs/vexpress_aemv8a.h 
b/include/configs/vexpress_aemv8a.h
index 08ad368dbb..3d63897054 100644
--- a/include/configs/vexpress_aemv8a.h
+++ b/include/configs/vexpress_aemv8a.h
@@ -7,12 +7,6 @@
 #ifndef __VEXPRESS_AEMV8A_H
 #define __VEXPRESS_AEMV8A_H
 
-#ifdef CONFIG_TARGET_VEXPRESS64_BASE_FVP
-#ifndef CONFIG_SEMIHOSTING
-#error CONFIG_TARGET_VEXPRESS64_BASE_FVP requires CONFIG_SEMIHOSTING
-#endif
-#endif
-
 #define CONFIG_REMAKE_ELF
 
 /* Link Definitions */
-- 
2.17.5



[PATCH v3 0/7] Arm Juno board OF_CONTROL upgrade

2020-04-27 Thread Andre Przywara
Hi,

another small update, fixing the Raspberry Pi breakage from the previous
version. Only patch 2/7 has changed.
I added Linus' Reviewed-by: to patch 7/7 and dropped Simon's R-b: to
patch 2/7, because of the changes.

Cheers,
Andre


The Juno port in U-Boot didn't see much love lately, so it has fallen
a bit behind. We already get a build warning for using an old network
driver, but there is more:
- The port is using hardcoded information, even though we have quite
  decent DTs available to find things at runtime.
- There is no support for USB or PCI, which pretty much limits the board
  to load a kernel from flash (yuck!) or TFTP (at least!).
- Probably because of this, newer features like UEFI support don't work
  properly.
- There are minor things like less-than-ideal default load addresses and
  missing reset support.

This series is the first part of fixing this. The main part is to switch
the board port to use OF_CONTROL, so U-Boot will use a DT to configure
itself at runtime. This requires some update to the PL011 driver first
(patch 2/7), and allows us to simply enable USB in the defconfig (patch
6/7). USB requires two "usb reset" calls after the initial "usb start" to
recognise any devices, not sure why this is.
But eventually I am able to load grub from a USB hard drive and do a full
featured Ubuntu UEFI boot from there (with a distro kernel).

Patches 1, 3, and 7 are mere fixes, patch 4/7 does the actual OF_CONTROL
conversion.

I also have some proper DM_PCI compliant driver in an advanced state,
which allows to load from a SATA hard disk. Unfortunately there is no
sky2 network driver in U-Boot, so the Gigabit Ethernet chip connected
to PCI will not work easily.
I will post this once this is cleaned up and tested.

Converting the smc network driver to DM_ETH is on my list as well, but
the code is shared with some U-Boot *application* code, also used by
some PowerPC boards, so that's not really a low hanging fruit.
But it would remove the deprecation warning.

Cheers,
Andre

Changelog v2 ... v3:
- cope with platforms not defining CONFIG_PL011_CLOCK

Changelog v1 ... v2:
- drop fdt_high and initrd_high variables
- rename initrd_addr to ramdisk_addr_r

P.S. In case you want to test this without flashing it, you can
chainload U-Boot from an existing U-Boot installation:
$ mkimage -A arm64 -O u-boot -T standalone -C none -a 0xe000 -e 0xe000
  -d u-boot.bin -n U-Boot /srv/tftp/u-boot-juno.img
VExpress64# tftpboot 0xe000 u-boot-juno.img
VExpress64# bootm

Andre Przywara (7):
  arm: juno: Fix Juno address variables
  uart: pl011: Add proper DM clock support
  arm: juno: Fix UART clock rate
  arm: juno: Enable OF_CONTROL
  arm: juno: Use PSCI based reset
  arm: juno: enable USB
  arm: vexpress64: Remove unneeded CONFIG_ check

 arch/arm/Kconfig   | 11 +
 board/armltd/vexpress64/Kconfig|  7 +++
 board/armltd/vexpress64/vexpress64.c   | 61 --
 configs/vexpress_aemv8a_juno_defconfig |  9 ++--
 drivers/serial/serial_pl01x.c  | 47 +---
 include/configs/vexpress_aemv8a.h  | 41 -
 6 files changed, 132 insertions(+), 44 deletions(-)

-- 
2.17.5



[PATCH v3 1/7] arm: juno: Fix Juno address variables

2020-04-27 Thread Andre Przywara
The U-Boot documentation explains that variables ending with "_r" hold
addresses in DRAM, while those without that ending point to flash/ROM.
The default variables for the Juno board pointing to the kernel and DTB
load addresses were not complying with this scheme: they lack the
extension, but point to DRAM. This is particularly confusing since the
Juno board features parallel NOR flash, so there *is* a memory mapped
NOR address holding a DTB, for instance.

Fix the variables to use the proper names, changing initrd_addr to
ramdisk_addr_r on the way, which seems to be more prevelant and
documented. On the way adjust the FDT load address to be situated
*before* the kernel, since users happened to overwrite the DTB by the
kernel clearing its .BSS section during initialisation.
Also remove the fdt_high and initrd_high variables (which were set
to -1), to allow U-Boot moving those images around.

This should avoid many problems in the future, but breaks loading
Linux kernels < v4.2, since they expect the DTB to be loaded in the same
512MB region as the kernel. If you need to load such an old kernel,
please set fdt_high to either 0x or 0xa000 (if you
load the kernel to the beginning of DRAM).

That fixes loading debug kernels, which happened to overwrite the DTB on
certain setups.

Signed-off-by: Andre Przywara 
---
 include/configs/vexpress_aemv8a.h | 28 +---
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/include/configs/vexpress_aemv8a.h 
b/include/configs/vexpress_aemv8a.h
index 4f3a792f49..6f81760612 100644
--- a/include/configs/vexpress_aemv8a.h
+++ b/include/configs/vexpress_aemv8a.h
@@ -138,35 +138,33 @@
 #define CONFIG_EXTRA_ENV_SETTINGS  \
"kernel_name=norkern\0" \
"kernel_alt_name=Image\0"   \
-   "kernel_addr=0x8008\0" \
-   "initrd_name=ramdisk.img\0" \
-   "initrd_addr=0x8400\0"  \
+   "kernel_addr_r=0x8008\0" \
+   "ramdisk_name=ramdisk.img\0"\
+   "ramdisk_addr_r=0x8800\0"   \
"fdtfile=board.dtb\0" \
"fdt_alt_name=juno\0" \
-   "fdt_addr=0x8300\0" \
-   "fdt_high=0x\0" \
-   "initrd_high=0x\0" \
+   "fdt_addr_r=0x8000\0" \
 
 /* Copy the kernel and FDT to DRAM memory and boot */
-#define CONFIG_BOOTCOMMAND "afs load ${kernel_name} ${kernel_addr} ; " \
+#define CONFIG_BOOTCOMMAND "afs load ${kernel_name} ${kernel_addr_r} ;"\
"if test $? -eq 1; then "\
"  echo Loading ${kernel_alt_name} instead of "\
"${kernel_name}; "\
-   "  afs load ${kernel_alt_name} ${kernel_addr};"\
+   "  afs load ${kernel_alt_name} 
${kernel_addr_r};"\
"fi ; "\
-   "afs load  ${fdtfile} ${fdt_addr} ; " \
+   "afs load ${fdtfile} ${fdt_addr_r} ;"\
"if test $? -eq 1; then "\
"  echo Loading ${fdt_alt_name} instead of "\
"${fdtfile}; "\
-   "  afs load ${fdt_alt_name} ${fdt_addr}; "\
+   "  afs load ${fdt_alt_name} ${fdt_addr_r}; "\
"fi ; "\
-   "fdt addr ${fdt_addr}; fdt resize; " \
-   "if afs load  ${initrd_name} ${initrd_addr} ; "\
+   "fdt addr ${fdt_addr_r}; fdt resize; " \
+   "if afs load  ${ramdisk_name} ${ramdisk_addr_r} 
; "\
"then "\
-   "  setenv initrd_param ${initrd_addr}; "\
-   "  else setenv initrd_param -; "\
+   "  setenv ramdisk_param ${ramdisk_addr_r}; "\
+   "  else setenv ramdisk_param -; "\
"fi ; " \
-   "booti ${kernel_addr} ${initrd_param} 
${fdt_addr}"
+   "booti ${kernel_addr_r} ${ramdisk_param} 
${fdt_addr_r}"
 
 
 #elif CONFIG_TARGET_VEXPRESS64_BASE_FVP
-- 
2.17.5



[PATCH v3 3/7] arm: juno: Fix UART clock rate

2020-04-27 Thread Andre Przywara
The UART base clock rate was typo-ed in the header file, probably because
the reference (the Linux .dts) was also wrong[1].

Fix the number to make the baud rate more correct.

Signed-off-by: Andre Przywara 
Reviewed-by: Linus Walleij 

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=39a1a8941b2
---
 include/configs/vexpress_aemv8a.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/vexpress_aemv8a.h 
b/include/configs/vexpress_aemv8a.h
index 6f81760612..3c85c93a5c 100644
--- a/include/configs/vexpress_aemv8a.h
+++ b/include/configs/vexpress_aemv8a.h
@@ -102,7 +102,7 @@
 
 /* PL011 Serial Configuration */
 #ifdef CONFIG_TARGET_VEXPRESS64_JUNO
-#define CONFIG_PL011_CLOCK 7273800
+#define CONFIG_PL011_CLOCK 7372800
 #else
 #define CONFIG_PL011_CLOCK 2400
 #endif
-- 
2.17.5



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

2020-04-27 Thread Tom Rini
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!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2] Nokia RX-51: Add automated test for running RX-51 build in qemu

2020-04-27 Thread Tom Rini
On Sat, Apr 25, 2020 at 11:00:06AM +0200, Pali Rohár wrote:
> This patch contains test/nokia_rx51_test.sh script which automatically
> download and compile all needed tools in local temporary directory to
> generate a simple MTD images for booting Maemo kernel image by U-Boot from
> RAM, eMMC and OneNAND. MTD images are then run in virtual n900 machine
> provided by qemu-linaro project.
> 
> This script does not need any special privileges, so it can be run as
> non-root nobody user.
> 
> It can be used to check that U-Boot for Nokia N900 is not broken and can be
> successfully booted in emulator.
> 
> Script is registered to .azure-pipelines.yml, .gitlab-ci.yml and
> .travis.yml so it would be automatically run on those CI services.
> 
> Signed-off-by: Pali Rohár 
> ---
> Changes in v2:
> * Fix apt dependences for Travis CI
> * Move definition of Travis job into own section
> * Add definition for Azure and Gitlab CI services
> * Add script to MAINTAINERS file
> * Build U-Boot binary in test script too
> * Show error message when some dependency for script is missing
> * Fix addresses for booting kernel from OneNAND
> * Do all stuff in nokia_rx51_tmp temporary directory
> * Use upstream mformat (from mtools) for generating FAT32 MBR filesystems
>   (instead of mkfs.fat from dosfstools with custom patches)
> * Show more verbose log messages
> * Do not use sudo, instead run parts of script under fakeroot
>   (fakeroot just run binary with own LD_PRELOAD library which emulates
>mknod() function for later usage by stat() function)
> * So script can be now run as non-root nobody user and it put all stuff
>   in nokia_rx51_tmp temporary directory, so can be run locally without
>   any issue.
> ---
>  .azure-pipelines.yml |   7 +
>  .gitlab-ci.yml   |   6 +
>  .travis.yml  |   7 +
>  board/nokia/rx51/MAINTAINERS |   1 +
>  test/nokia_rx51_test.sh  | 262 +++
>  5 files changed, 283 insertions(+)
>  create mode 100755 test/nokia_rx51_test.sh
> 
> diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
> index d3e7b4dd02..a812f7f906 100644
> --- a/.azure-pipelines.yml
> +++ b/.azure-pipelines.yml
> @@ -151,6 +151,13 @@ jobs:
># seems to hang forever with pre-configured "container" environment
>docker run -v $PWD:$(work_dir) $(ci_runner_image) /bin/bash 
> $(work_dir)/build.sh
>  
> +  - job: nokia_rx51_test
> +displayName: 'Run tests for Nokia RX-51 (aka N900)'
> +pool:
> +  vmImage: $(ubuntu_vm)
> +steps:
> +  - script: test/nokia_rx51_test.sh
> +
>- job: test_py
>  displayName: 'test.py'
>  pool:
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index 08bdf81e74..678f4323a0 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -170,6 +170,12 @@ Run binman, buildman, dtoc, Kconfig and patman 
> testsuites:
>./tools/patman/patman --test;
>make testconfig
>  
> +Run tests for Nokia RX-51 (aka N900):
> +  tags: [ 'all' ]
> +  stage: testsuites
> +  script:
> +- test/nokia_rx51_test.sh
> +
>  # Test sandbox with test.py
>  sandbox test.py:
>tags: [ 'all' ]
> diff --git a/.travis.yml b/.travis.yml
> index 82e3b91523..b32555d89f 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -49,6 +49,8 @@ addons:
>  - mtools
>  - openssl
>  - sbsigntool
> +- fakeroot
> +- mtd-utils

So the Docker container for Azure/GitLab will need an update too.  I'll
take care of that shortly.  Otherwise:

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 5/8] pci: Add Rockchip PCIe controller driver

2020-04-27 Thread Robin Murphy

On 2020-04-25 8:36 pm, Jagan Teki wrote:

On Sun, Apr 26, 2020 at 12:23 AM Mark Kettenis  wrote:



From: Jagan Teki 
Date: Sat, 25 Apr 2020 16:33:51 +0530

Add Rockchip PCIe controller driver for rk3399 platform.

Driver support Gen1 by operating as a Root complex.

Thanks to Patrick for initial work.


Tried to get this to work on my firefly-rk3399 which made me notice
some shortcomings:

1. The vpcie1v8 and vpcie0v9 supplies are optional, just like the
vpcie3v3 supply.


FWIW those are "non-optional" in Linux in the sense that supplies to the 
PCIE_AVDD_0V9 and PCIE_AVDD_1V8 pins of the SoC must physically exist, 
even if they aren't described. If U-Boot doesn't have the same "create a 
dummy regulator if none is specified" behaviour then you might need some 
slightly different logic there.


The 3.3V and 12V supplies on the other hand may legitimately not be part 
of the board at all, depending on whether it implements a full-size 
slot, a mini-PCI/M.2 socket, a hard-wired endpoint chip, or just the 
data and clock signal pairs exposed on some non-standard connector.


Robin.


[PATCH 2/3] lib: Add a function to convert a string to upper case

2020-04-27 Thread Simon Glass
Add a helper function for this operation. Update the strtoul() tests to
check upper case as well.

Signed-off-by: Simon Glass 
Reviewed-by: Heinrich Schuchardt 
---

 include/vsprintf.h | 12 +++
 lib/strto.c|  8 +
 test/str_ut.c  | 78 +-
 3 files changed, 83 insertions(+), 15 deletions(-)

diff --git a/include/vsprintf.h b/include/vsprintf.h
index 56844dd2de..d9fb68add0 100644
--- a/include/vsprintf.h
+++ b/include/vsprintf.h
@@ -222,4 +222,16 @@ bool str2long(const char *p, ulong *num);
  * @hz: Value to convert
  */
 char *strmhz(char *buf, unsigned long hz);
+
+/**
+ * str_to_upper() - Convert a string to upper case
+ *
+ * This simply uses toupper() on each character of the string.
+ *
+ * @in: String to convert (must be large enough to hold the output string)
+ * @out: Buffer to put converted string
+ * @len: Number of bytes available in @out (SIZE_MAX for all)
+ */
+void str_to_upper(const char *in, char *out, size_t len);
+
 #endif
diff --git a/lib/strto.c b/lib/strto.c
index 1ac2b09c72..37e1fbe63f 100644
--- a/lib/strto.c
+++ b/lib/strto.c
@@ -176,3 +176,11 @@ long trailing_strtol(const char *str)
 {
return trailing_strtoln(str, NULL);
 }
+
+void str_to_upper(const char *in, char *out, size_t len)
+{
+   for (; len > 0 && *in; len--)
+   *out++ = toupper(*in++);
+   if (len)
+   *out = '\0';
+}
diff --git a/test/str_ut.c b/test/str_ut.c
index fab8de595c..7c8015050a 100644
--- a/test/str_ut.c
+++ b/test/str_ut.c
@@ -19,36 +19,84 @@ static const char str3[] = "0xbI'm sorry you're alive.";
 /* Declare a new str test */
 #define STR_TEST(_name, _flags)UNIT_TEST(_name, _flags, 
str_test)
 
+static int str_test_upper(struct unit_test_state *uts)
+{
+   char out[TEST_STR_SIZE];
+
+   /* Make sure it adds a terminator */
+   out[strlen(str1)] = 'a';
+   str_to_upper(str1, out, SIZE_MAX);
+   ut_asserteq_str("I'M SORRY I'M LATE.", out);
+
+   /* In-place operation */
+   strcpy(out, str2);
+   str_to_upper(out, out, SIZE_MAX);
+   ut_asserteq_str("1099ABNO, DON'T BOTHER APOLOGISING.", out);
+
+   /* Limited length */
+   str_to_upper(str1, out, 7);
+   ut_asserteq_str("I'M SORO, DON'T BOTHER APOLOGISING.", out);
+
+   /* In-place with limited length */
+   strcpy(out, str2);
+   str_to_upper(out, out, 7);
+   ut_asserteq_str("1099ABNo, don't bother apologising.", out);
+
+   /* Copy an empty string to a buffer with space*/
+   out[1] = 0x7f;
+   str_to_upper("", out, SIZE_MAX);
+   ut_asserteq('\0', *out);
+   ut_asserteq(0x7f, out[1]);
+
+   /* Copy an empty string to a buffer with no space*/
+   out[0] = 0x7f;
+   str_to_upper("", out, 0);
+   ut_asserteq(0x7f, out[0]);
+
+   return 0;
+}
+STR_TEST(str_test_upper, 0);
+
 static int run_strtoul(struct unit_test_state *uts, const char *str, int base,
-  ulong expect_val, int expect_endp_offset)
+  ulong expect_val, int expect_endp_offset, bool upper)
 {
+   char out[TEST_STR_SIZE];
char *endp;
ulong val;
 
-   val = simple_strtoul(str, , base);
+   strcpy(out, str);
+   if (upper)
+   str_to_upper(out, out, -1);
+
+   val = simple_strtoul(out, , base);
ut_asserteq(expect_val, val);
-   ut_asserteq(expect_endp_offset, endp - str);
+   ut_asserteq(expect_endp_offset, endp - out);
 
return 0;
 }
 
 static int str_simple_strtoul(struct unit_test_state *uts)
 {
-   /* Base 10 and base 16 */
-   ut_assertok(run_strtoul(uts, str2, 10, 1099, 4));
-   ut_assertok(run_strtoul(uts, str2, 16, 0x1099ab, 6));
+   int upper;
+
+   /* Check that it is case-insentive */
+   for (upper = 0; upper < 2; upper++) {
+   /* Base 10 and base 16 */
+   ut_assertok(run_strtoul(uts, str2, 10, 1099, 4, upper));
+   ut_assertok(run_strtoul(uts, str2, 16, 0x1099ab, 6, upper));
 
-   /* Invalid string */
-   ut_assertok(run_strtoul(uts, str1, 10, 0, 0));
+   /* Invalid string */
+   ut_assertok(run_strtoul(uts, str1, 10, 0, 0, upper));
 
-   /* Base 0 */
-   ut_assertok(run_strtoul(uts, str1, 0, 0, 0));
-   ut_assertok(run_strtoul(uts, str2, 0, 1099, 4));
-   ut_assertok(run_strtoul(uts, str3, 0, 0xb, 3));
+   /* Base 0 */
+   ut_assertok(run_strtoul(uts, str1, 0, 0, 0, upper));
+   ut_assertok(run_strtoul(uts, str2, 0, 1099, 4, upper));
+   ut_assertok(run_strtoul(uts, str3, 0, 0xb, 3, upper));
 
-   /* Base 2 */
-   ut_assertok(run_strtoul(uts, str1, 2, 0, 0));
-   ut_assertok(run_strtoul(uts, str2, 2, 2, 2));
+   /* Base 2 */
+   ut_assertok(run_strtoul(uts, str1, 2, 0, 0, upper));
+   ut_assertok(run_strtoul(uts, str2, 2, 2, 2, upper));
+   }
 
 

[PATCH 3/3] acpi: Fix-up patch to correct sandbox test errors

2020-04-27 Thread Simon Glass
Move the alignment code into acpi_setup_base_tables() so that test and
production code are in alignment.

This brings x86/master into line with patch series v8.

Signed-off-by: Simon Glass 
---

 arch/x86/lib/acpi_table.c | 5 -
 lib/acpi/acpi_table.c | 7 ++-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
index 600bde2f5f..13f1409de8 100644
--- a/arch/x86/lib/acpi_table.c
+++ b/arch/x86/lib/acpi_table.c
@@ -375,11 +375,6 @@ ulong write_acpi_tables(ulong start_addr)
debug("ACPI: Writing ACPI tables at %lx\n", start_addr);
 
acpi_setup_base_tables(ctx, start);
-   /*
-* Per ACPI spec, the FACS table address must be aligned to a 64 byte
-* boundary (Windows checks this, but Linux does not).
-*/
-   acpi_align64(ctx);
 
debug("ACPI:* FACS\n");
facs = ctx->current;
diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c
index 5abf1cad50..1c253af3bf 100644
--- a/lib/acpi/acpi_table.c
+++ b/lib/acpi/acpi_table.c
@@ -145,7 +145,7 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table)
}
 
if (i >= entries_num) {
-   debug("ACPI: Error: too many tables\n");
+   log_err("ACPI: Error: too many tables\n");
return -E2BIG;
}
 
@@ -256,4 +256,9 @@ void acpi_setup_base_tables(struct acpi_ctx *ctx, void 
*start)
acpi_write_rsdp(ctx->rsdp, ctx->rsdt, ctx->xsdt);
acpi_write_rsdt(ctx->rsdt);
acpi_write_xsdt(ctx->xsdt);
+   /*
+* Per ACPI spec, the FACS table address must be aligned to a 64 byte
+* boundary (Windows checks this, but Linux does not).
+*/
+   acpi_align64(ctx);
 }
-- 
2.26.2.303.gf8c07b1a785-goog



[PATCH 0/3] Fix-up series for x86/master

2020-04-27 Thread Simon Glass
Note that this includes two patches which are in mainline but not in
x86/master


Simon Glass (3):
  test: Add the beginnings of some string tests
  lib: Add a function to convert a string to upper case
  acpi: Fix-up patch to correct sandbox test errors

 arch/x86/lib/acpi_table.c |   5 --
 include/test/suites.h |   1 +
 include/vsprintf.h|  12 
 lib/acpi/acpi_table.c |   7 ++-
 lib/strto.c   |   8 +++
 test/Makefile |   1 +
 test/cmd_ut.c |   5 ++
 test/str_ut.c | 115 ++
 8 files changed, 148 insertions(+), 6 deletions(-)
 create mode 100644 test/str_ut.c

-- 
2.26.2.303.gf8c07b1a785-goog



Re: Build error in u-boot-dm/master

2020-04-27 Thread Simon Glass
Hi Stephen,

On Mon, 27 Apr 2020 at 10:04, Stephen Warren  wrote:
>
> Simon,
>
> All 32-bit Tegra builds of u-boot-dm/master are failing with the
> following (this log is from Harmony):
>
> >   CC  spl/common/spl/spl.o
> >   CC  spl/lib/display_options.o
> >   LD  spl/common/spl/built-in.o
> >   LD  spl/lib/built-in.o
> >   LD  spl/u-boot-spl
> >   OBJCOPY spl/u-boot-spl-nodtb.bin
> >   COPYspl/u-boot-spl.bin
> >   BINMAN  u-boot-tegra.bin
> > binman: bad magic number in 'binman.etype': b'\x03\xf3\r\n'
> > /var/lib/jenkins/workspace/u-boot-denx_uboot_dm-master-build/src/u-boot/Makefile:1619:
> >  recipe for target 'u-boot-tegra.bin' failed
> > make[1]: *** [u-boot-tegra.bin] Error 1

Oh wow, that is a strange one. Could it be bad Python cache files again?

Regards,
Simon


Re: [PATCH v7 0/9] dm: Add programmatic generation of ACPI tables (part A)

2020-04-27 Thread Simon Glass
Hi Bin,

On Sun, 26 Apr 2020 at 23:58, Bin Meng  wrote:
>
> Hi Simon,
>
> On Thu, Apr 23, 2020 at 5:58 PM Bin Meng  wrote:
> >
> > Hi Simon,
> >
> > On Thu, Apr 23, 2020 at 5:46 PM Bin Meng  wrote:
> > >
> > > Hi Simon,
> > >
> > > On Wed, Apr 22, 2020 at 5:37 AM Simon Glass  wrote:
> > > >
> > > > Hi Andy,
> > > >
> > > > On Tue, 21 Apr 2020 at 11:43, Andy Shevchenko
> > > >  wrote:
> > > > >
> > > > > On Sun, Apr 19, 2020 at 02:36:48PM -0600, Simon Glass wrote:
> > > > > > This is split from the original series in an attempt to get things 
> > > > > > applied
> > > > > > in chunks.
> > > > > >
> > > > > > v7 is just a rebase as requested
> > > > >
> > > > > So, overall I have no concerns, except that compatible string in ACPI 
> > > > > seems
> > > > > half-baked solution and, due to PRP0001 awareness (my understanding 
> > > > > that it
> > > > > should not be part of production devices), seems not needed right now.
> > > > > It means we should require to have _HID and/or _CID.
> > > >
> > > > OK I am really not sure what to say about this. Let's deal with it
> > > > when we see the use of it later.
> > > >
> > > > >
> > > > > Code looks fine to me, though.
> > > > >
> > > >
> > > > OK good. I will send part B soon.
> > > >
> > >
> > > v7 has been applied to u-boot-x86, thanks!
> > >
> >
> > Unfortunately this series breaks sandbox_spl, please take a look.
> >
> > https://gitlab.denx.de/u-boot/custodians/u-boot-x86/-/jobs/81615
> >
>
> Did you send out a fix for this series so that I can squash in?

Oops, no, I sent out a new series. I will send a fixup patch.

Regards,
Simon


[PATCH 1/3] test: Add the beginnings of some string tests

2020-04-27 Thread Simon Glass
There are quite a few string functions in U-Boot with no tests. Make a
start by adding a test for strtoul().

Signed-off-by: Simon Glass 
---

 include/test/suites.h |  1 +
 test/Makefile |  1 +
 test/cmd_ut.c |  5 
 test/str_ut.c | 67 +++
 4 files changed, 74 insertions(+)
 create mode 100644 test/str_ut.c

diff --git a/include/test/suites.h b/include/test/suites.h
index 39ad81a90f..213e3cee77 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -33,6 +33,7 @@ int do_ut_lib(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[]);
 int do_ut_log(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_optee(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+int do_ut_str(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_unicode(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 
diff --git a/test/Makefile b/test/Makefile
index 2971d0d87f..bab8f1a5c2 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_UNIT_TEST) += ut.o
 obj-$(CONFIG_SANDBOX) += command_ut.o
 obj-$(CONFIG_SANDBOX) += compression.o
 obj-$(CONFIG_SANDBOX) += print_ut.o
+obj-$(CONFIG_SANDBOX) += str_ut.o
 obj-$(CONFIG_UT_TIME) += time_ut.o
 obj-$(CONFIG_UT_UNICODE) += unicode_ut.o
 obj-y += log/
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 7fdcdbb1a6..bd20a69c55 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -74,6 +74,8 @@ static cmd_tbl_t cmd_ut_sub[] = {
 "", ""),
U_BOOT_CMD_MKENT(bloblist, CONFIG_SYS_MAXARGS, 1, do_ut_bloblist,
 "", ""),
+   U_BOOT_CMD_MKENT(str, CONFIG_SYS_MAXARGS, 1, do_ut_str,
+"", ""),
 #endif
 };
 
@@ -137,6 +139,9 @@ static char ut_help_text[] =
 #ifdef CONFIG_UT_OVERLAY
"ut overlay [test-name]\n"
 #endif
+#ifdef CONFIG_SANDBOX
+   "ut str - Basic test of string functions\n"
+#endif
 #ifdef CONFIG_UT_TIME
"ut time - Very basic test of time functions\n"
 #endif
diff --git a/test/str_ut.c b/test/str_ut.c
new file mode 100644
index 00..fab8de595c
--- /dev/null
+++ b/test/str_ut.c
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2020 Google LLC
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* This is large enough for any of the test strings */
+#define TEST_STR_SIZE  200
+
+static const char str1[] = "I'm sorry I'm late.";
+static const char str2[] = "1099abNo, don't bother apologising.";
+static const char str3[] = "0xbI'm sorry you're alive.";
+
+/* Declare a new str test */
+#define STR_TEST(_name, _flags)UNIT_TEST(_name, _flags, 
str_test)
+
+static int run_strtoul(struct unit_test_state *uts, const char *str, int base,
+  ulong expect_val, int expect_endp_offset)
+{
+   char *endp;
+   ulong val;
+
+   val = simple_strtoul(str, , base);
+   ut_asserteq(expect_val, val);
+   ut_asserteq(expect_endp_offset, endp - str);
+
+   return 0;
+}
+
+static int str_simple_strtoul(struct unit_test_state *uts)
+{
+   /* Base 10 and base 16 */
+   ut_assertok(run_strtoul(uts, str2, 10, 1099, 4));
+   ut_assertok(run_strtoul(uts, str2, 16, 0x1099ab, 6));
+
+   /* Invalid string */
+   ut_assertok(run_strtoul(uts, str1, 10, 0, 0));
+
+   /* Base 0 */
+   ut_assertok(run_strtoul(uts, str1, 0, 0, 0));
+   ut_assertok(run_strtoul(uts, str2, 0, 1099, 4));
+   ut_assertok(run_strtoul(uts, str3, 0, 0xb, 3));
+
+   /* Base 2 */
+   ut_assertok(run_strtoul(uts, str1, 2, 0, 0));
+   ut_assertok(run_strtoul(uts, str2, 2, 2, 2));
+
+   /* Check endp being NULL */
+   ut_asserteq(1099, simple_strtoul(str2, NULL, 0));
+
+   return 0;
+}
+STR_TEST(str_simple_strtoul, 0);
+
+int do_ut_str(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+{
+   struct unit_test *tests = ll_entry_start(struct unit_test,
+str_test);
+   const int n_ents = ll_entry_count(struct unit_test, str_test);
+
+   return cmd_ut_category("str", "str_", tests, n_ents, argc, argv);
+}
-- 
2.26.2.303.gf8c07b1a785-goog



Re: Please pull u-boot-video

2020-04-27 Thread Tom Rini
On Mon, Apr 27, 2020 at 10:32:22AM +0200, Anatolij Gustschin 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:
> 
>   https://gitlab.denx.de/u-boot/custodians/u-boot-video.git 
> tags/video-for-v2020.07-rc1
> 
> for you to fetch changes up to ea16637525ad6a49626de3fbf01e29e1af08d29f:
> 
>   video: simple_panel: add boe,nv140fhmn49 display (2020-04-26 23:04:49 +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom



signature.asc
Description: PGP signature


Build error in u-boot-dm/master

2020-04-27 Thread Stephen Warren
Simon,

All 32-bit Tegra builds of u-boot-dm/master are failing with the
following (this log is from Harmony):

>   CC  spl/common/spl/spl.o
>   CC  spl/lib/display_options.o
>   LD  spl/common/spl/built-in.o
>   LD  spl/lib/built-in.o
>   LD  spl/u-boot-spl
>   OBJCOPY spl/u-boot-spl-nodtb.bin
>   COPYspl/u-boot-spl.bin
>   BINMAN  u-boot-tegra.bin
> binman: bad magic number in 'binman.etype': b'\x03\xf3\r\n'
> /var/lib/jenkins/workspace/u-boot-denx_uboot_dm-master-build/src/u-boot/Makefile:1619:
>  recipe for target 'u-boot-tegra.bin' failed
> make[1]: *** [u-boot-tegra.bin] Error 1


Re: [PATCH v3 0/4] Various i.MXRT bug/typo fixes

2020-04-27 Thread Giulio Benetti

On 4/27/20 5:57 PM, Fabio Estevam wrote:

Hi Giulio,

On Mon, Apr 27, 2020 at 12:53 PM Giulio Benetti
 wrote:


Hi Anatolij, Lukasz, Stefano, Fabio, All,

this patchset fix 2 bugs preventing from LCDIF to work when booting from
sd-card. There are also 2 little typo fixes for boards READMEs.

V1->V2:
* modify mxfsb.c patch as suggested by Fabio
V2->V3:
* change /dev/sdb into /dev/sdX as suggested by Fabio


For the whole series:

Reviewed-by: Fabio Estevam 

Just a hint for future submissions: when you re-submit a series,
please keep the Reviewed-by tags that you received.


Yes, I've missed it sorry and re-sent 2 answers to integrate.

Thank you very much

Best regards
--
Giulio Benetti
Benetti Engineering sas


Re: [PATCH v3 4/4] clk: imx: clk-imxrt1050: fix lcdif clock gate

2020-04-27 Thread Giulio Benetti

Forgotten to add

On 4/27/20 5:53 PM, Giulio Benetti wrote:

LCDIF clock gate was wrong so set it according to RM.

Signed-off-by: Giulio Benetti 


Reviewed-by: Anatolij Gustschin 
Reviewed-by: Fabio Estevam 


---
  drivers/clk/imx/clk-imxrt1050.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/imx/clk-imxrt1050.c b/drivers/clk/imx/clk-imxrt1050.c
index 329f4580c5..8279e784fe 100644
--- a/drivers/clk/imx/clk-imxrt1050.c
+++ b/drivers/clk/imx/clk-imxrt1050.c
@@ -255,7 +255,7 @@ static int imxrt1050_clk_probe(struct udevice *dev)
clk_dm(IMXRT1050_CLK_SEMC,
   imx_clk_gate2("semc", "semc_podf", base + 0x74, 4));
clk_dm(IMXRT1050_CLK_LCDIF,
-  imx_clk_gate2("lcdif", "lcdif_podf", base + 0x70, 28));
+  imx_clk_gate2("lcdif", "lcdif_podf", base + 0x74, 10));
  
  	struct clk *clk, *clk1;
  



--
Giulio Benetti
Benetti Engineering sas


Re: [PATCH v3 3/4] video: mxsfb: add clk_enable()

2020-04-27 Thread Giulio Benetti

Forgotten to add

On 4/27/20 5:53 PM, Giulio Benetti wrote:

BROM doesn't enable lcdif by default so add clk_enable() after
clk_set_rate().

Signed-off-by: Giulio Benetti 


Reviewed-by: Anatolij Gustschin 
Reviewed-by: Fabio Estevam 


---
V1->V2:
* call clk_enable() after clk_set_rate() as suggested by Fabio
---
  drivers/video/mxsfb.c | 6 ++
  1 file changed, 6 insertions(+)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 8a5a61c9fb..12d00b4689 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -77,6 +77,12 @@ static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
dev_err(dev, "Failed to set mxs clk: %d\n", ret);
return;
}
+
+   ret = clk_enable(_clk);
+   if (ret < 0) {
+   dev_err(dev, "Failed to enable mxs clk: %d\n", ret);
+   return;
+   }
  #else
/* Kick in the LCDIF clock */
mxs_set_lcdclk(MXS_LCDIF_BASE, timings->pixelclock.typ / 1000);



--
Giulio Benetti
Benetti Engineering sas


Re: [PATCH v3 0/4] Various i.MXRT bug/typo fixes

2020-04-27 Thread Fabio Estevam
Hi Giulio,

On Mon, Apr 27, 2020 at 12:53 PM Giulio Benetti
 wrote:
>
> Hi Anatolij, Lukasz, Stefano, Fabio, All,
>
> this patchset fix 2 bugs preventing from LCDIF to work when booting from
> sd-card. There are also 2 little typo fixes for boards READMEs.
>
> V1->V2:
> * modify mxfsb.c patch as suggested by Fabio
> V2->V3:
> * change /dev/sdb into /dev/sdX as suggested by Fabio

For the whole series:

Reviewed-by: Fabio Estevam 

Just a hint for future submissions: when you re-submit a series,
please keep the Reviewed-by tags that you received.

Thanks


[PATCH v3 1/4] imxrt1050-evk: README: change dd command destination

2020-04-27 Thread Giulio Benetti
Set dd "of=" to "of=/dev/sdX" to be generic and prevent host hard drive
damage.

Signed-off-by: Giulio Benetti 
---
V2->V3:
* change /dev/sdb to /dev/sdX as suggested by Fabio
---
 board/freescale/imxrt1050-evk/README | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/board/freescale/imxrt1050-evk/README 
b/board/freescale/imxrt1050-evk/README
index f7e2894025..a7e68fa9b3 100644
--- a/board/freescale/imxrt1050-evk/README
+++ b/board/freescale/imxrt1050-evk/README
@@ -11,11 +11,11 @@ This will generate the SPL image called SPL and the 
u-boot.img.
 
 - Flash the SPL image into the micro SD card:
 
-sudo dd if=SPL of=/dev/mmcblk0 bs=1k seek=1; sync
+sudo dd if=SPL of=/dev/sdX bs=1k seek=1; sync
 
 - Flash the u-boot.img image into the micro SD card:
 
-sudo dd if=u-boot.img of=/dev/sdb bs=1k seek=128; sync
+sudo dd if=u-boot.img of=/dev/sdX bs=1k seek=128; sync
 
 - Jumper settings:
 
-- 
2.20.1



[PATCH v3 4/4] clk: imx: clk-imxrt1050: fix lcdif clock gate

2020-04-27 Thread Giulio Benetti
LCDIF clock gate was wrong so set it according to RM.

Signed-off-by: Giulio Benetti 
---
 drivers/clk/imx/clk-imxrt1050.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/imx/clk-imxrt1050.c b/drivers/clk/imx/clk-imxrt1050.c
index 329f4580c5..8279e784fe 100644
--- a/drivers/clk/imx/clk-imxrt1050.c
+++ b/drivers/clk/imx/clk-imxrt1050.c
@@ -255,7 +255,7 @@ static int imxrt1050_clk_probe(struct udevice *dev)
clk_dm(IMXRT1050_CLK_SEMC,
   imx_clk_gate2("semc", "semc_podf", base + 0x74, 4));
clk_dm(IMXRT1050_CLK_LCDIF,
-  imx_clk_gate2("lcdif", "lcdif_podf", base + 0x70, 28));
+  imx_clk_gate2("lcdif", "lcdif_podf", base + 0x74, 10));
 
struct clk *clk, *clk1;
 
-- 
2.20.1



[PATCH v3 2/4] imxrt1020-evk: README: change dd command destination

2020-04-27 Thread Giulio Benetti
Set dd "of=" to "of=/dev/sdX" to be generic and prevent host hard drive
damage.

Signed-off-by: Giulio Benetti 
---
V2->V3:
* change /dev/sdb to /dev/sdX as suggested by Fabio
---
 board/freescale/imxrt1020-evk/README | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/board/freescale/imxrt1020-evk/README 
b/board/freescale/imxrt1020-evk/README
index 3da72fdad2..abee7ca5f3 100644
--- a/board/freescale/imxrt1020-evk/README
+++ b/board/freescale/imxrt1020-evk/README
@@ -11,11 +11,11 @@ This will generate the SPL image called SPL and the 
u-boot.img.
 
 - Flash the SPL image into the micro SD card:
 
-sudo dd if=SPL of=/dev/mmcblk0 bs=1k seek=1; sync
+sudo dd if=SPL of=/dev/sdX bs=1k seek=1; sync
 
 - Flash the u-boot.img image into the micro SD card:
 
-sudo dd if=u-boot.img of=/dev/sdb bs=1k seek=128; sync
+sudo dd if=u-boot.img of=/dev/sdX bs=1k seek=128; sync
 
 - Jumper settings:
 
-- 
2.20.1



[PATCH v3 0/4] Various i.MXRT bug/typo fixes

2020-04-27 Thread Giulio Benetti
Hi Anatolij, Lukasz, Stefano, Fabio, All,

this patchset fix 2 bugs preventing from LCDIF to work when booting from
sd-card. There are also 2 little typo fixes for boards READMEs.

V1->V2:
* modify mxfsb.c patch as suggested by Fabio
V2->V3:
* change /dev/sdb into /dev/sdX as suggested by Fabio

Giulio Benetti (4):
  imxrt1050-evk: README: change dd command destination
  imxrt1020-evk: README: change dd command destination
  video: mxsfb: add clk_enable()
  clk: imx: clk-imxrt1050: fix lcdif clock gate

 board/freescale/imxrt1020-evk/README | 4 ++--
 board/freescale/imxrt1050-evk/README | 4 ++--
 drivers/clk/imx/clk-imxrt1050.c  | 2 +-
 drivers/video/mxsfb.c| 6 ++
 4 files changed, 11 insertions(+), 5 deletions(-)

-- 
2.20.1



[PATCH v3 3/4] video: mxsfb: add clk_enable()

2020-04-27 Thread Giulio Benetti
BROM doesn't enable lcdif by default so add clk_enable() after
clk_set_rate().

Signed-off-by: Giulio Benetti 
---
V1->V2:
* call clk_enable() after clk_set_rate() as suggested by Fabio
---
 drivers/video/mxsfb.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 8a5a61c9fb..12d00b4689 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -77,6 +77,12 @@ static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
dev_err(dev, "Failed to set mxs clk: %d\n", ret);
return;
}
+
+   ret = clk_enable(_clk);
+   if (ret < 0) {
+   dev_err(dev, "Failed to enable mxs clk: %d\n", ret);
+   return;
+   }
 #else
/* Kick in the LCDIF clock */
mxs_set_lcdclk(MXS_LCDIF_BASE, timings->pixelclock.typ / 1000);
-- 
2.20.1



Re: [PATCH v2 1/4] imxrt1050-evk: README: fix dd command destination

2020-04-27 Thread Giulio Benetti

On 4/27/20 5:34 PM, Fabio Estevam wrote:

Hi Giulio,

On Mon, Apr 27, 2020 at 12:11 PM Giulio Benetti
 wrote:


Make "of=" the same for the 2 commands since we're writing to the same
sd-card.

Signed-off-by: Giulio Benetti 
---
  board/freescale/imxrt1050-evk/README | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/freescale/imxrt1050-evk/README 
b/board/freescale/imxrt1050-evk/README
index f7e2894025..55b6a0877a 100644
--- a/board/freescale/imxrt1050-evk/README
+++ b/board/freescale/imxrt1050-evk/README
@@ -11,7 +11,7 @@ This will generate the SPL image called SPL and the 
u-boot.img.

  - Flash the SPL image into the micro SD card:

-sudo dd if=SPL of=/dev/mmcblk0 bs=1k seek=1; sync
+sudo dd if=SPL of=/dev/sdb bs=1k seek=1; sync


I usually prefer to write /dev/sdX instead because someone may follow
the instructions as is and inadvertently kill their hard disk or
another device that may appear at /dev/sdb.


Oh, that's right.

I send V3 with that corrected.

Thank you
--
Giulio Benetti
Benetti Engineering sas


Re: [PATCH v2 4/4] clk: imx: clk-imxrt1050: fix lcdif clock gate

2020-04-27 Thread Fabio Estevam
On Mon, Apr 27, 2020 at 12:11 PM Giulio Benetti
 wrote:
>
> LCDIF clock gate was wrong so set it according to RM.
>
> Signed-off-by: Giulio Benetti 

Reviewed-by: Fabio Estevam 


Re: [PATCH v2 3/4] video: mxsfb: add clk_enable()

2020-04-27 Thread Fabio Estevam
Hi Giulio,

On Mon, Apr 27, 2020 at 12:11 PM Giulio Benetti
 wrote:
>
> BROM doesn't enable lcdif by default so add clk_enable() after
> clk_set_rate().
>
> Signed-off-by: Giulio Benetti 
> ---
> V1->V2:
> * call clk_enable() after clk_set_rate() as suggested by Fabio

Thanks for the respin:

Reviewed-by: Fabio Estevam 


Re: [PATCH v2 1/4] imxrt1050-evk: README: fix dd command destination

2020-04-27 Thread Fabio Estevam
Hi Giulio,

On Mon, Apr 27, 2020 at 12:11 PM Giulio Benetti
 wrote:
>
> Make "of=" the same for the 2 commands since we're writing to the same
> sd-card.
>
> Signed-off-by: Giulio Benetti 
> ---
>  board/freescale/imxrt1050-evk/README | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/board/freescale/imxrt1050-evk/README 
> b/board/freescale/imxrt1050-evk/README
> index f7e2894025..55b6a0877a 100644
> --- a/board/freescale/imxrt1050-evk/README
> +++ b/board/freescale/imxrt1050-evk/README
> @@ -11,7 +11,7 @@ This will generate the SPL image called SPL and the 
> u-boot.img.
>
>  - Flash the SPL image into the micro SD card:
>
> -sudo dd if=SPL of=/dev/mmcblk0 bs=1k seek=1; sync
> +sudo dd if=SPL of=/dev/sdb bs=1k seek=1; sync

I usually prefer to write /dev/sdX instead because someone may follow
the instructions as is and inadvertently kill their hard disk or
another device that may appear at /dev/sdb.


Re: [PATCH v2 4/4] clk: imx: clk-imxrt1050: fix lcdif clock gate

2020-04-27 Thread Anatolij Gustschin
On Mon, 27 Apr 2020 17:11:07 +0200
Giulio Benetti giulio.bene...@benettiengineering.com wrote:

> LCDIF clock gate was wrong so set it according to RM.
> 
> Signed-off-by: Giulio Benetti 

Reviewed-by: Anatolij Gustschin 

--
Anatolij


Please pull u-boot-dm

2020-04-27 Thread Simon Glass
Hi Tom,

https://gitlab.denx.de/u-boot/custodians/u-boot-dm/pipelines/2949

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:

  git://git.denx.de/u-boot-dm.git tags/dm-pull-27apr20

for you to fetch changes up to c1f39edc62adc81775e750957aa557bcf994e607:

  log: remove useless cast (2020-04-26 14:25:21 -0600)


Move Python tools to use absolute paths
Minor buildman fixes for new features
Make libfdt code more similar to upsteam


Heinrich Schuchardt (1):
  log: remove useless cast

Masahiro Yamada (3):
  libfdt: migrate fdt_ro.c to a wrapper of scripts/dtc/libfdt/fdt_ro.c
  fdt_region: move fdt_region.c to common/ from lib/libfdt/
  libfdt: split fdt_region declarations out to 

Simon Glass (19):
  buildman: Fix test for new 9.2 kernel
  buildman: Correct operation of -A flag
  buildman: Make sure that -o is given with -w
  buildman: Use out-env for environment output
  buildman: Write output files when using -w
  patman: Rename the main module
  rmboard: Move to Python 3
  patman: Drop references to __future__
  patman: Drop Python 2 StringIO code
  buildman: Rename the main module
  dtoc: Rename the main module
  binman: Rename the main module
  Add a 'make tcheck' option to test tools
  patman: Drop the python2 code in test coverage
  patman: Move test running/reporting to test_util
  buildman: Move to absolute imports
  binman: Move to absolute imports
  patman: Move to absolute imports
  patman: Tidy up sys.path changes

 Makefile  |   6 +-
 common/Makefile   |   1 +
 {lib/libfdt => common}/fdt_region.c   |   1 +
 common/image-fit-sig.c|   1 +
 common/log.c  |   2 +-
 include/fdt_region.h  | 304 
 include/linux/libfdt.h| 299 ---
 lib/libfdt/Makefile   |   9 +-
 lib/libfdt/fdt_ro.c   | 925
+--
 test/run  |  26 +-
 tools/Makefile|  13 +-
 tools/binman/binman   |   2 +-
 tools/binman/cbfs_util.py |   8 +-
 tools/binman/cbfs_util_test.py|  12 +-
 tools/binman/control.py   |  20 +-
 tools/binman/elf.py   |   8 +-
 tools/binman/elf_test.py  |  10 +-
 tools/binman/entry.py |  22 +-
 tools/binman/entry_test.py|  12 +-
 tools/binman/etype/__init__.py|   0
 tools/binman/etype/_testing.py|   6 +-
 tools/binman/etype/blob.py|   8 +-
 tools/binman/etype/blob_dtb.py|   6 +-
 tools/binman/etype/blob_named_by_arg.py   |   4 +-
 tools/binman/etype/cbfs.py|  10 +-
 tools/binman/etype/cros_ec_rw.py  |   2 +-
 tools/binman/etype/fdtmap.py  |  10 +-
 tools/binman/etype/files.py   |   8 +-
 tools/binman/etype/fill.py|   6 +-
 tools/binman/etype/fmap.py|  10 +-
 tools/binman/etype/gbb.py |   8 +-
 tools/binman/etype/image_header.py|   4 +-
 tools/binman/etype/intel_cmc.py   |   4 +-
 tools/binman/etype/intel_descriptor.py|   4 +-
 tools/binman/etype/intel_fit.py   |   2 +-
 tools/binman/etype/intel_fit_ptr.py   |   2 +-
 tools/binman/etype/intel_fsp.py   |   4 +-
 tools/binman/etype/intel_fsp_m.py |   4 +-
 tools/binman/etype/intel_fsp_s.py |   4 +-
 tools/binman/etype/intel_fsp_t.py |   4 +-
 tools/binman/etype/intel_ifwi.py  |   8 +-
 tools/binman/etype/intel_me.py|   4 +-
 tools/binman/etype/intel_mrc.py   |   4 +-
 tools/binman/etype/intel_refcode.py   |   4 +-
 tools/binman/etype/intel_vbt.py   |   4 +-
 tools/binman/etype/intel_vga.py   |   4 +-
 tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py |   4 +-
 tools/binman/etype/section.py |  10 +-
 tools/binman/etype/text.py|   6 +-
 

Re: [PATCH v2 3/4] video: mxsfb: add clk_enable()

2020-04-27 Thread Anatolij Gustschin
On Mon, 27 Apr 2020 17:11:06 +0200
Giulio Benetti giulio.bene...@benettiengineering.com wrote:

> BROM doesn't enable lcdif by default so add clk_enable() after
> clk_set_rate().
> 
> Signed-off-by: Giulio Benetti 

Reviewed-by: Anatolij Gustschin 

--
Anatolij



[PATCH v2 0/4] Various i.MXRT bug/typo fixes

2020-04-27 Thread Giulio Benetti
Hi Anatolij, Lukasz, Stefano, Fabio, All,

this patchset fix 2 bugs preventing from LCDIF to work when booting from
sd-card. There are also 2 little typo fixes for boards READMEs.

V1->V2:
* modify mxfsb.c patch as suggested by Fabio

Giulio Benetti (4):
  imxrt1050-evk: README: fix dd command destination
  imxrt1020-evk: README: fix dd command destination
  video: mxsfb: add clk_enable()
  clk: imx: clk-imxrt1050: fix lcdif clock gate

 board/freescale/imxrt1020-evk/README | 2 +-
 board/freescale/imxrt1050-evk/README | 2 +-
 drivers/clk/imx/clk-imxrt1050.c  | 2 +-
 drivers/video/mxsfb.c| 6 ++
 4 files changed, 9 insertions(+), 3 deletions(-)

-- 
2.20.1



[PATCH v2 3/4] video: mxsfb: add clk_enable()

2020-04-27 Thread Giulio Benetti
BROM doesn't enable lcdif by default so add clk_enable() after
clk_set_rate().

Signed-off-by: Giulio Benetti 
---
V1->V2:
* call clk_enable() after clk_set_rate() as suggested by Fabio
---
 drivers/video/mxsfb.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 8a5a61c9fb..12d00b4689 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -77,6 +77,12 @@ static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
dev_err(dev, "Failed to set mxs clk: %d\n", ret);
return;
}
+
+   ret = clk_enable(_clk);
+   if (ret < 0) {
+   dev_err(dev, "Failed to enable mxs clk: %d\n", ret);
+   return;
+   }
 #else
/* Kick in the LCDIF clock */
mxs_set_lcdclk(MXS_LCDIF_BASE, timings->pixelclock.typ / 1000);
-- 
2.20.1



[PATCH v2 4/4] clk: imx: clk-imxrt1050: fix lcdif clock gate

2020-04-27 Thread Giulio Benetti
LCDIF clock gate was wrong so set it according to RM.

Signed-off-by: Giulio Benetti 
---
 drivers/clk/imx/clk-imxrt1050.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/imx/clk-imxrt1050.c b/drivers/clk/imx/clk-imxrt1050.c
index 329f4580c5..8279e784fe 100644
--- a/drivers/clk/imx/clk-imxrt1050.c
+++ b/drivers/clk/imx/clk-imxrt1050.c
@@ -255,7 +255,7 @@ static int imxrt1050_clk_probe(struct udevice *dev)
clk_dm(IMXRT1050_CLK_SEMC,
   imx_clk_gate2("semc", "semc_podf", base + 0x74, 4));
clk_dm(IMXRT1050_CLK_LCDIF,
-  imx_clk_gate2("lcdif", "lcdif_podf", base + 0x70, 28));
+  imx_clk_gate2("lcdif", "lcdif_podf", base + 0x74, 10));
 
struct clk *clk, *clk1;
 
-- 
2.20.1



[PATCH v2 1/4] imxrt1050-evk: README: fix dd command destination

2020-04-27 Thread Giulio Benetti
Make "of=" the same for the 2 commands since we're writing to the same
sd-card.

Signed-off-by: Giulio Benetti 
---
 board/freescale/imxrt1050-evk/README | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/freescale/imxrt1050-evk/README 
b/board/freescale/imxrt1050-evk/README
index f7e2894025..55b6a0877a 100644
--- a/board/freescale/imxrt1050-evk/README
+++ b/board/freescale/imxrt1050-evk/README
@@ -11,7 +11,7 @@ This will generate the SPL image called SPL and the 
u-boot.img.
 
 - Flash the SPL image into the micro SD card:
 
-sudo dd if=SPL of=/dev/mmcblk0 bs=1k seek=1; sync
+sudo dd if=SPL of=/dev/sdb bs=1k seek=1; sync
 
 - Flash the u-boot.img image into the micro SD card:
 
-- 
2.20.1



[PATCH v2 2/4] imxrt1020-evk: README: fix dd command destination

2020-04-27 Thread Giulio Benetti
Make "of=" the same for the 2 commands since we're writing to the
same sd-card.

Signed-off-by: Giulio Benetti 
---
 board/freescale/imxrt1020-evk/README | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/freescale/imxrt1020-evk/README 
b/board/freescale/imxrt1020-evk/README
index 3da72fdad2..bcb3683163 100644
--- a/board/freescale/imxrt1020-evk/README
+++ b/board/freescale/imxrt1020-evk/README
@@ -11,7 +11,7 @@ This will generate the SPL image called SPL and the 
u-boot.img.
 
 - Flash the SPL image into the micro SD card:
 
-sudo dd if=SPL of=/dev/mmcblk0 bs=1k seek=1; sync
+sudo dd if=SPL of=/dev/sdb bs=1k seek=1; sync
 
 - Flash the u-boot.img image into the micro SD card:
 
-- 
2.20.1



Re: [PATCH 3/4] video: mxsfb: add clk_enable()

2020-04-27 Thread Giulio Benetti

Hi Fabio,

On 4/27/20 1:48 AM, Fabio Estevam wrote:

Hi Giulio,

On Sun, Apr 26, 2020 at 8:43 PM Giulio Benetti
 wrote:


+   ret = clk_enable(_clk);
+   if (ret < 0) {
+   dev_err(dev, "Failed to enable mxs clk: %d\n", ret);
+   return;
+   }
+
 ret = clk_set_rate(_clk, timings->pixelclock.typ);
 if (ret < 0) {
 dev_err(dev, "Failed to set mxs clk: %d\n", ret);


Usually it is safer to configure the clock rate first and then enable
the clock to avoid glitches.

Could you try to call clk_enable() after clk_set_rate() here?


Sure, I'm going to send it for V2.

Thanks for reviewing
--
Giulio Benetti
Benetti Engineering sas


Re: [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL

2020-04-27 Thread Bin Meng
Hi Tom,

On Mon, Apr 27, 2020 at 9:37 PM Tom Rini  wrote:
>
> On Mon, Apr 27, 2020 at 09:37:28AM +0800, Bin Meng wrote:
> > Hi Tom,
> >
> > On Sat, Apr 18, 2020 at 8:37 PM Bin Meng  wrote:
> > >
> > > On Fri, Apr 17, 2020 at 3:22 PM Masahiro Yamada  
> > > wrote:
> > > >
> > > > Currently generic-asm-offsets.h and asm-offsets.h are generated based
> > > > on U-Boot proper config options. The same asm-offsets headers are used
> > > > for building U-Boot SPL/TPL, which causes potential offset mismatch if
> > > > U-Boot proper has different config options from U-Boot SPL/TPL.
> > > >
> > > > This commit adds:
> > > >   spl/include/generated/(generic-)asm-offsets.h
> > > >   tpl/include/generated/(generic-)asm-offsets.h
> > > >
> > > > spl/include/generated/(generic-)asm-offsets.h is generated if
> > > > CONFIG_SPL=y, and included when building SPL.
> > > >
> > > > tpl/include/generated/(generic-)asm-offsets.h is generated if
> > > > CONFIG_TPL=y, and included when building TPL.
> > > >
> > > > They are created before Kbuild descends into SPL/TPL object directories
> > > > and builds $(obj)/dts/dt-platdata.o because $(obj)/dts/dt-platdata.c
> > > > includes a bunch of headers.
> > > >
> > > > Prepend -I$(obj)/include to $(UBOOTINCLUDE) so (generic-)asm-offsets.h
> > > > is searched in {spl,tpl}/include/generated/.
> > > >
> > > > Requested-by: Bin Meng 
> > > > Signed-off-by: Masahiro Yamada 
> > > > ---
> > > >
> > > > Changes in v2: None
> > > >
> > > >  Kbuild   |  4 ++--
> > > >  scripts/Makefile.spl | 10 --
> > > >  2 files changed, 10 insertions(+), 4 deletions(-)
> > > >
> > >
> > > It works like a charm. Thanks!
> > >
> > > Tested-by: Bin Meng 
> >
> > It looks only patch 1 and 2 in this series were applied. This patch was 
> > missed.
>
> So, I was going to ask and forgot, sorry.  Why do we need to have these
> differ between TPL/SPL/U-Boot itself, and then why is that good?  I

Because currently the offsets
{spl,tpl}/include/generated/(generic-)asm-offsets.h are generated per
the U-Boot config options. But SPL and TPL are not guaranteed to have
the same config options.

For example it's possible to have SPL/TPL turned on
{SPL,TPL}_CONFIG_XXX but U-Boot to turn off CONFIG_XXX, or vice verse.

To me this is more like a bug fix other than a feature.

> thought this was something we wanted to ensure was consistent from stage
> to stage to facilitate sharing of information.  But I also am happy to
> assume I just missed an explanation along the way.  Thanks!

Regards,
Bin


  1   2   3   >