Re: [PATCH] spi: cadence-qspi: Move ref clock calculation to probe

2020-02-25 Thread Simon Goldschmidt
Vignesh Raghavendra  schrieb am Mi., 26. Feb. 2020, 08:29:

> +Simon who converted driver to use clk_get* APIs
>
> On 24/02/20 12:40 pm, Pratyush Yadav wrote:
> > "assigned-clock-parents" and "assigned-clock-rates" DT properties take
> > effect only after ofdata_to_platdata() when clk_set_defaults() is called
> > in device_probe(). Therefore clk get rate() would return a wrong value
> > in ofdata_to_platdata() when compared with probe. Hence it needs to be
> > moved to probe.
> >
> > Tested on u-boot-ti/next.
> >
>
> Acked-by: Vignesh Raghavendra 
>

Fine by me. I actually moved it there after someone requested me to :-) I
first had it in the set_rate function...

Acked-by: Simon Goldschmidt 

>
> Regards
> Vignesh
>
> > Signed-off-by: Pratyush Yadav 
> > ---
> >  drivers/spi/cadence_qspi.c | 33 +
> >  1 file changed, 17 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c
> > index 83b114ffe7..994a5948f1 100644
> > --- a/drivers/spi/cadence_qspi.c
> > +++ b/drivers/spi/cadence_qspi.c
> > @@ -166,11 +166,28 @@ static int cadence_spi_probe(struct udevice *bus)
> >  {
> >   struct cadence_spi_platdata *plat = bus->platdata;
> >   struct cadence_spi_priv *priv = dev_get_priv(bus);
> > + struct clk clk;
> >   int ret;
> >
> >   priv->regbase = plat->regbase;
> >   priv->ahbbase = plat->ahbbase;
> >
> > + if (plat->ref_clk_hz == 0) {
> > + ret = clk_get_by_index(bus, 0, );
> > + if (ret) {
> > +#ifdef CONFIG_CQSPI_REF_CLK
> > + plat->ref_clk_hz = CONFIG_CQSPI_REF_CLK;
> > +#else
> > + return ret;
> > +#endif
> > + } else {
> > + plat->ref_clk_hz = clk_get_rate();
> > + clk_free();
> > + if (IS_ERR_VALUE(plat->ref_clk_hz))
> > + return plat->ref_clk_hz;
> > + }
> > + }
> > +
> >   ret = reset_get_bulk(bus, >resets);
> >   if (ret)
> >   dev_warn(bus, "Can't get reset: %d\n", ret);
> > @@ -268,8 +285,6 @@ static int cadence_spi_ofdata_to_platdata(struct
> udevice *bus)
> >  {
> >   struct cadence_spi_platdata *plat = bus->platdata;
> >   ofnode subnode;
> > - struct clk clk;
> > - int ret;
> >
> >   plat->regbase = (void *)devfdt_get_addr_index(bus, 0);
> >   plat->ahbbase = (void *)devfdt_get_addr_size_index(bus, 1,
> > @@ -305,20 +320,6 @@ static int cadence_spi_ofdata_to_platdata(struct
> udevice *bus)
> >   plat->tchsh_ns = ofnode_read_u32_default(subnode, "cdns,tchsh-ns",
> 20);
> >   plat->tslch_ns = ofnode_read_u32_default(subnode, "cdns,tslch-ns",
> 20);
> >
> > - ret = clk_get_by_index(bus, 0, );
> > - if (ret) {
> > -#ifdef CONFIG_CQSPI_REF_CLK
> > - plat->ref_clk_hz = CONFIG_CQSPI_REF_CLK;
> > -#else
> > - return ret;
> > -#endif
> > - } else {
> > - plat->ref_clk_hz = clk_get_rate();
> > - clk_free();
> > - if (IS_ERR_VALUE(plat->ref_clk_hz))
> > - return plat->ref_clk_hz;
> > - }
> > -
> >   debug("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n",
> > __func__, plat->regbase, plat->ahbbase, plat->max_hz,
> > plat->page_size);
> >
>
>
>


Re: [PATCH] spi: cadence-qspi: Move ref clock calculation to probe

2020-02-25 Thread Vignesh Raghavendra
+Simon who converted driver to use clk_get* APIs

On 24/02/20 12:40 pm, Pratyush Yadav wrote:
> "assigned-clock-parents" and "assigned-clock-rates" DT properties take
> effect only after ofdata_to_platdata() when clk_set_defaults() is called
> in device_probe(). Therefore clk get rate() would return a wrong value
> in ofdata_to_platdata() when compared with probe. Hence it needs to be
> moved to probe.
> 
> Tested on u-boot-ti/next.
> 

Acked-by: Vignesh Raghavendra 

Regards
Vignesh

> Signed-off-by: Pratyush Yadav 
> ---
>  drivers/spi/cadence_qspi.c | 33 +
>  1 file changed, 17 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c
> index 83b114ffe7..994a5948f1 100644
> --- a/drivers/spi/cadence_qspi.c
> +++ b/drivers/spi/cadence_qspi.c
> @@ -166,11 +166,28 @@ static int cadence_spi_probe(struct udevice *bus)
>  {
>   struct cadence_spi_platdata *plat = bus->platdata;
>   struct cadence_spi_priv *priv = dev_get_priv(bus);
> + struct clk clk;
>   int ret;
>  
>   priv->regbase = plat->regbase;
>   priv->ahbbase = plat->ahbbase;
>  
> + if (plat->ref_clk_hz == 0) {
> + ret = clk_get_by_index(bus, 0, );
> + if (ret) {
> +#ifdef CONFIG_CQSPI_REF_CLK
> + plat->ref_clk_hz = CONFIG_CQSPI_REF_CLK;
> +#else
> + return ret;
> +#endif
> + } else {
> + plat->ref_clk_hz = clk_get_rate();
> + clk_free();
> + if (IS_ERR_VALUE(plat->ref_clk_hz))
> + return plat->ref_clk_hz;
> + }
> + }
> +
>   ret = reset_get_bulk(bus, >resets);
>   if (ret)
>   dev_warn(bus, "Can't get reset: %d\n", ret);
> @@ -268,8 +285,6 @@ static int cadence_spi_ofdata_to_platdata(struct udevice 
> *bus)
>  {
>   struct cadence_spi_platdata *plat = bus->platdata;
>   ofnode subnode;
> - struct clk clk;
> - int ret;
>  
>   plat->regbase = (void *)devfdt_get_addr_index(bus, 0);
>   plat->ahbbase = (void *)devfdt_get_addr_size_index(bus, 1,
> @@ -305,20 +320,6 @@ static int cadence_spi_ofdata_to_platdata(struct udevice 
> *bus)
>   plat->tchsh_ns = ofnode_read_u32_default(subnode, "cdns,tchsh-ns", 20);
>   plat->tslch_ns = ofnode_read_u32_default(subnode, "cdns,tslch-ns", 20);
>  
> - ret = clk_get_by_index(bus, 0, );
> - if (ret) {
> -#ifdef CONFIG_CQSPI_REF_CLK
> - plat->ref_clk_hz = CONFIG_CQSPI_REF_CLK;
> -#else
> - return ret;
> -#endif
> - } else {
> - plat->ref_clk_hz = clk_get_rate();
> - clk_free();
> - if (IS_ERR_VALUE(plat->ref_clk_hz))
> - return plat->ref_clk_hz;
> - }
> -
>   debug("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n",
> __func__, plat->regbase, plat->ahbbase, plat->max_hz,
> plat->page_size);
> 




[PATCH 1/1] block: ide: use definitions from include/libata.h

2020-02-25 Thread Heinrich Schuchardt
Currently ATA commands are defined both in include/libata.h and
include/ata.h. libata.h is included in ata.h. So this duplication does
not make much sense.

Use the command definitions from include/libata.h where applicable.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/block/ide.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/block/ide.c b/drivers/block/ide.c
index 4b8a4eac17..67cc4fbc02 100644
--- a/drivers/block/ide.c
+++ b/drivers/block/ide.c
@@ -231,7 +231,7 @@ unsigned char atapi_issue(int device, unsigned char *ccb, 
int ccblen,
 (unsigned char) ((buflen >> 8) & 0xFF));
ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));

-   ide_outb(device, ATA_COMMAND, ATAPI_CMD_PACKET);
+   ide_outb(device, ATA_COMMAND, ATA_CMD_PACKET);
udelay(50);

mask = ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR;
@@ -570,7 +570,7 @@ static void ide_ident(struct blk_desc *dev_desc)
/*
 * Start Ident Command
 */
-   ide_outb(device, ATA_COMMAND, ATAPI_CMD_IDENT);
+   ide_outb(device, ATA_COMMAND, ATA_CMD_ID_ATAPI);
/*
 * Wait for completion - ATAPI devices need more time
 * to become ready
@@ -582,7 +582,7 @@ static void ide_ident(struct blk_desc *dev_desc)
/*
 * Start Ident Command
 */
-   ide_outb(device, ATA_COMMAND, ATA_CMD_IDENT);
+   ide_outb(device, ATA_COMMAND, ATA_CMD_ID_ATA);

/*
 * Wait for completion
@@ -966,7 +966,7 @@ ulong ide_read(struct blk_desc *block_dev, lbaint_t blknr, 
lbaint_t blkcnt,

/* first check if the drive is in Powersaving mode, if yes,
 * increase the timeout value */
-   ide_outb(device, ATA_COMMAND, ATA_CMD_CHK_PWR);
+   ide_outb(device, ATA_COMMAND, ATA_CMD_CHK_POWER);
udelay(50);

c = ide_wait(device, IDE_TIME_OUT); /* can't take over 500 ms */
--
2.25.0



[PATCH v2] arm: mvebu: update RTC values for PCIe memory wrappers

2020-02-25 Thread Chris Packham
From: Chris Packham 

Update the RTC (Read Timing Control) values for PCIe memory wrappers
following an ERRATA (ERRATA# TDB). This means the PCIe accesses will
used slower memory Read Timing, to allow more efficient energy
consumption, in order to lower the minimum VDD of the memory.  Will lead
to more robust memory when voltage drop occurs (VDDSEG)

The code is based on changes from Marvell's U-Boot, specifically:

https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/20cd2704072512de176e048970f2883db901674b
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/eb608a7c8dd0d42b87601a61b9c0cc5615ab94b2
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/c4af19ae2bf08cf6e450e741ce4f04d402a5cb6b

Signed-off-by: Chris Packham 
Signed-off-by: Chris Packham 
---
I've signed-off using both my email addresses. I normally do u-boot
stuff via gmail for convenience but this is definitely a work thing.

Changes in v2:
- drop duplicated link in commit message

 arch/arm/mach-mvebu/include/mach/cpu.h|  2 ++
 arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c | 17 +
 arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h | 13 +
 arch/arm/mach-mvebu/spl.c |  3 +++
 4 files changed, 35 insertions(+)

diff --git a/arch/arm/mach-mvebu/include/mach/cpu.h 
b/arch/arm/mach-mvebu/include/mach/cpu.h
index 2e2d72aac892..fa7c81754b8f 100644
--- a/arch/arm/mach-mvebu/include/mach/cpu.h
+++ b/arch/arm/mach-mvebu/include/mach/cpu.h
@@ -166,8 +166,10 @@ int ddr3_init(void);
 /* Auto Voltage Scaling */
 #if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)
 void mv_avs_init(void);
+void mv_rtc_config(void);
 #else
 static inline void mv_avs_init(void) {}
+static inline void mv_rtc_config(void) {}
 #endif
 
 /*
diff --git a/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c 
b/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c
index e9dd096ad0f5..3c4c7e01a1cd 100644
--- a/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c
+++ b/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c
@@ -257,6 +257,23 @@ u8 sys_env_device_rev_get(void)
return (value & (REVISON_ID_MASK)) >> REVISON_ID_OFFS;
 }
 
+void mv_rtc_config(void)
+{
+   u32 i, val;
+
+   if (!(IS_ENABLED(CONFIG_ARMADA_38X) || IS_ENABLED(CONFIG_ARMADA_39X)))
+   return;
+
+   /* Activate pipe0 for read/write transaction, and set XBAR client 
number #1 */
+   val = 0x1 << DFX_PIPE_SELECT_PIPE0_ACTIVE_OFFS |
+ 0x1 << DFX_PIPE_SELECT_XBAR_CLIENT_SEL_OFFS;
+   writel(val, MVEBU_DFX_BASE);
+
+   /* Set new RTC value for all memory wrappers */
+   for (i = 0; i < RTC_MEMORY_WRAPPER_COUNT; i++)
+   reg_write(RTC_MEMORY_WRAPPER_REG(i), 
RTC_MEMORY_WRAPPER_CTRL_VAL);
+}
+
 void mv_avs_init(void)
 {
u32 sar_freq;
diff --git a/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h 
b/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h
index 1774a5b780ca..17cd811331d2 100644
--- a/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h
+++ b/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h
@@ -150,6 +150,19 @@
 #define MPP_UART1_SET_MASK (~(0xff000))
 #define MPP_UART1_SET_DATA (0x66000)
 
+#define DFX_PIPE_SELECT_PIPE0_ACTIVE_OFFS  0
+/* DFX_PIPE_SELECT_XBAR_CLIENT_SEL_OFFS: Since address completion in 14bit
+ * address mode, and given that [14:8] => [19:13], the 2 lower bits [9:8] =>
+ * [14:13] are dismissed. hence field offset is also shifted to 10
+ */
+#define DFX_PIPE_SELECT_XBAR_CLIENT_SEL_OFFS   10
+
+#define RTC_MEMORY_CTRL_REG_BASE   0xE6000
+#define RTC_MEMORY_WRAPPER_COUNT   8
+#define RTC_MEMORY_WRAPPER_REG(i)  (RTC_MEMORY_CTRL_REG_BASE + ((i) * 
0x40))
+#define RTC_MEMORY_CTRL_PDLVMC_FIELD_OFFS  6
+#define RTC_MEMORY_WRAPPER_CTRL_VAL(0x1 << 
RTC_MEMORY_CTRL_PDLVMC_FIELD_OFFS)
+
 #define AVS_DEBUG_CNTR_REG 0xe4124
 #define AVS_DEBUG_CNTR_DEFAULT_VALUE   0x08008073
 
diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index a99bf166fd85..70fef3b573d9 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -130,6 +130,9 @@ void board_init_f(ulong dummy)
/* Initialize Auto Voltage Scaling */
mv_avs_init();
 
+   /* Update read timing control for PCIe */
+   mv_rtc_config();
+
/*
 * Return to the BootROM to continue the Marvell xmodem
 * UART boot protocol. As initiated by the kwboot tool.
-- 
2.25.1



Re: [PATCH] arm: mvebu: update RTC values for PCIe memory wrappers

2020-02-25 Thread Chris Packham
On Wed, 2020-02-26 at 19:46 +1300, Chris Packham wrote:
> Hi Baruch,
> 
> On Wed, 2020-02-26 at 06:49 +0200, Baruch Siach wrote:
> > Hi Chris,
> > 
> > On Wed, Feb 26 2020, Chris Packham wrote:
> > > From: Chris Packham 
> > > 
> > > Update the RTC (Read Timing Control) values for PCIe memory
> > > wrappers
> > > following an ERRATA (ERRATA# TDB). This means the PCIe accesses
> > > will
> > > used slower memory Read Timing, to allow more efficient energy
> > > consumption, in order to lower the minimum VDD of the
> > > memory.  Will
> > > lead
> > > to more robust memory when voltage drop occurs (VDDSEG)
> > 
> > Have you seen memory access reliability problems because of this
> > issue?
> > 
> 
> We're seeing a few different symptoms but they all consist of a PCIe
> transfer failing in some way (as far as we can tell in the TX
> direction
> from the CPU).
> 
> > > The code is based on changes from Marvell's U-Boot, specifically:
> > > 
> > > 
> 
> 
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/20cd2704072512de176e048970f2883db901674b
> > > 
> 
> 
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/eb608a7c8dd0d42b87601a61b9c0cc5615ab94b2
> > > 
> 
> 
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/c4af19ae2bf08cf6e450e741ce4f04d402a5cb6b
> > > 
> 
> 
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/c4af19ae2bf08cf6e450e741ce4f04d402a5cb6b
> > 
> > The last link looks duplicated.
> 
> Hmm I was pretty sure there were 4 commits. I'll double check and
> either fix or remove the link.

Ah. There are 4 patches, but the last one isn't in the github repo for
some reason. I'll drop the link.

> 
> > 
> > baruch
> > 


Re: [PATCH] arm: mvebu: update RTC values for PCIe memory wrappers

2020-02-25 Thread Chris Packham
Hi Baruch,

On Wed, 2020-02-26 at 06:49 +0200, Baruch Siach wrote:
> Hi Chris,
> 
> On Wed, Feb 26 2020, Chris Packham wrote:
> > From: Chris Packham 
> > 
> > Update the RTC (Read Timing Control) values for PCIe memory
> > wrappers
> > following an ERRATA (ERRATA# TDB). This means the PCIe accesses
> > will
> > used slower memory Read Timing, to allow more efficient energy
> > consumption, in order to lower the minimum VDD of the memory.  Will
> > lead
> > to more robust memory when voltage drop occurs (VDDSEG)
> 
> Have you seen memory access reliability problems because of this
> issue?
> 

We're seeing a few different symptoms but they all consist of a PCIe
transfer failing in some way (as far as we can tell in the TX direction
from the CPU).

> > The code is based on changes from Marvell's U-Boot, specifically:
> > 
> > 
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/20cd2704072512de176e048970f2883db901674b
> > 
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/eb608a7c8dd0d42b87601a61b9c0cc5615ab94b2
> > 
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/c4af19ae2bf08cf6e450e741ce4f04d402a5cb6b
> > 
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/c4af19ae2bf08cf6e450e741ce4f04d402a5cb6b
> 
> The last link looks duplicated.

Hmm I was pretty sure there were 4 commits. I'll double check and
either fix or remove the link.

> 
> baruch
> 


[PATCH 1/1] cmd: fat: remove unused includes

2020-02-25 Thread Heinrich Schuchardt
Remove unused includes from cmd/fat.c.

Signed-off-by: Heinrich Schuchardt 
---
 cmd/fat.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/cmd/fat.c b/cmd/fat.c
index 50df127f6d..abce2f1e0c 100644
--- a/cmd/fat.c
+++ b/cmd/fat.c
@@ -8,13 +8,7 @@
  * Boot support
  */
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
-#include 
 #include 
 #include 

--
2.25.0



[PATCH 1/1] ata: sort ATA commands

2020-02-25 Thread Heinrich Schuchardt
Sort the ATA commands in include/libata.h by number.
Add a few more comments.

Signed-off-by: Heinrich Schuchardt 
---
 include/libata.h | 84 
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/include/libata.h b/include/libata.h
index 25296ac66d..fee2e78f01 100644
--- a/include/libata.h
+++ b/include/libata.h
@@ -133,49 +133,49 @@ enum {
ATA_REG_IRQ = ATA_REG_NSECT,

/* ATA device commands */
-   ATA_CMD_DEV_RESET   = 0x08, /* ATAPI device reset */
-   ATA_CMD_CHK_POWER   = 0xE5, /* check power mode */
-   ATA_CMD_STANDBY = 0xE2, /* place in standby power mode */
-   ATA_CMD_IDLE= 0xE3, /* place in idle power mode */
-   ATA_CMD_EDD = 0x90, /* execute device diagnostic */
-   ATA_CMD_FLUSH   = 0xE7,
-   ATA_CMD_FLUSH_EXT   = 0xEA,
-   ATA_CMD_ID_ATA  = 0xEC,
-   ATA_CMD_ID_ATAPI= 0xA1,
-   ATA_CMD_READ= 0xC8,
-   ATA_CMD_READ_EXT= 0x25,
-   ATA_CMD_WRITE   = 0xCA,
-   ATA_CMD_WRITE_EXT   = 0x35,
-   ATA_CMD_WRITE_FUA_EXT   = 0x3D,
-   ATA_CMD_FPDMA_READ  = 0x60,
-   ATA_CMD_FPDMA_WRITE = 0x61,
-   ATA_CMD_PIO_READ= 0x20,
-   ATA_CMD_PIO_READ_EXT= 0x24,
-   ATA_CMD_PIO_WRITE   = 0x30,
-   ATA_CMD_PIO_WRITE_EXT   = 0x34,
-   ATA_CMD_READ_MULTI  = 0xC4,
-   ATA_CMD_READ_MULTI_EXT  = 0x29,
-   ATA_CMD_WRITE_MULTI = 0xC5,
-   ATA_CMD_WRITE_MULTI_EXT = 0x39,
-   ATA_CMD_WRITE_MULTI_FUA_EXT = 0xCE,
-   ATA_CMD_SET_FEATURES= 0xEF,
-   ATA_CMD_SET_MULTI   = 0xC6,
-   ATA_CMD_PACKET  = 0xA0,
-   ATA_CMD_VERIFY  = 0x40,
-   ATA_CMD_VERIFY_EXT  = 0x42,
-   ATA_CMD_STANDBYNOW1 = 0xE0,
-   ATA_CMD_IDLEIMMEDIATE   = 0xE1,
-   ATA_CMD_SLEEP   = 0xE6,
-   ATA_CMD_INIT_DEV_PARAMS = 0x91,
-   ATA_CMD_READ_NATIVE_MAX = 0xF8,
+   ATA_CMD_DEV_RESET   = 0x08, /* ATAPI device reset */
+   ATA_CMD_PIO_READ= 0x20, /* Read sectors with retry */
+   ATA_CMD_PIO_READ_EXT= 0x24,
+   ATA_CMD_READ_EXT= 0x25,
ATA_CMD_READ_NATIVE_MAX_EXT = 0x27,
-   ATA_CMD_SET_MAX = 0xF9,
-   ATA_CMD_SET_MAX_EXT = 0x37,
-   ATA_CMD_READ_LOG_EXT= 0x2f,
-   ATA_CMD_PMP_READ= 0xE4,
-   ATA_CMD_PMP_WRITE   = 0xE8,
-   ATA_CMD_CONF_OVERLAY= 0xB1,
-   ATA_CMD_SEC_FREEZE_LOCK = 0xF5,
+   ATA_CMD_READ_MULTI_EXT  = 0x29,
+   ATA_CMD_READ_LOG_EXT= 0x2f,
+   ATA_CMD_PIO_WRITE   = 0x30, /* write sectors with retry */
+   ATA_CMD_PIO_WRITE_EXT   = 0x34,
+   ATA_CMD_WRITE_EXT   = 0x35,
+   ATA_CMD_SET_MAX_EXT = 0x37,
+   ATA_CMD_WRITE_MULTI_EXT = 0x39,
+   ATA_CMD_WRITE_FUA_EXT   = 0x3D,
+   ATA_CMD_VERIFY  = 0x40, /* read verify sectors with retry */
+   ATA_CMD_VERIFY_EXT  = 0x42,
+   ATA_CMD_FPDMA_READ  = 0x60,
+   ATA_CMD_FPDMA_WRITE = 0x61,
+   ATA_CMD_EDD = 0x90, /* execute device diagnostic */
+   ATA_CMD_INIT_DEV_PARAMS = 0x91, /* initialize device parameters */
+   ATA_CMD_PACKET  = 0xA0, /* ATAPI packet */
+   ATA_CMD_ID_ATAPI= 0xA1, /* ATAPI identify device */
+   ATA_CMD_CONF_OVERLAY= 0xB1,
+   ATA_CMD_READ_MULTI  = 0xC4, /* read multiple */
+   ATA_CMD_WRITE_MULTI = 0xC5, /* write multiple */
+   ATA_CMD_SET_MULTI   = 0xC6, /* set multiple mode */
+   ATA_CMD_READ= 0xC8, /* read DMA with retry */
+   ATA_CMD_WRITE   = 0xCA, /* write DMA with retry */
+   ATA_CMD_WRITE_MULTI_FUA_EXT = 0xCE,
+   ATA_CMD_STANDBYNOW1 = 0xE0, /* standby immediate */
+   ATA_CMD_IDLEIMMEDIATE   = 0xE1, /* idle immediate */
+   ATA_CMD_STANDBY = 0xE2, /* place in standby power mode */
+   ATA_CMD_IDLE= 0xE3, /* place in idle power mode */
+   ATA_CMD_PMP_READ= 0xE4, /* read buffer */
+   ATA_CMD_CHK_POWER   = 0xE5, /* check power mode */
+   ATA_CMD_SLEEP   = 0xE6, /* sleep */
+   ATA_CMD_FLUSH   = 0xE7,
+   ATA_CMD_PMP_WRITE   = 0xE8, /* write buffer */
+   ATA_CMD_FLUSH_EXT   = 0xEA,
+   ATA_CMD_ID_ATA  = 0xEC, /* identify device */
+   ATA_CMD_SET_FEATURES= 0xEF, /* set features */
+   ATA_CMD_SEC_FREEZE_LOCK = 0xF5, /* security freeze */
+   ATA_CMD_READ_NATIVE_MAX = 0xF8,
+   ATA_CMD_SET_MAX = 0xF9,

/* READ_LOG_EXT pages */
ATA_LOG_SATA_NCQ= 0x10,
--
2.25.0



[PATCH] lx2160a : Remove default VID setting

2020-02-25 Thread Meenakshi Aggarwal
Set VID to 800 mV for Rev1 and set VID as per switch settings
for Rev2.

Signed-off-by: Meenakshi Aggarwal 
---
 board/freescale/lx2160a/lx2160a.c | 9 -
 include/configs/lx2160aqds.h  | 1 -
 include/configs/lx2160ardb.h  | 1 -
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/board/freescale/lx2160a/lx2160a.c 
b/board/freescale/lx2160a/lx2160a.c
index 3deb76b..ba1cac2 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -297,7 +297,14 @@ int i2c_multiplexer_select_vid_channel(u8 channel)
 
 int init_func_vid(void)
 {
-   if (adjust_vdd(0) < 0)
+   int set_vid;
+
+   if (IS_SVR_REV(get_svr(), 1, 0))
+   set_vid = adjust_vdd(800);
+   else
+   set_vid = adjust_vdd(0);
+
+   if (set_vid < 0)
printf("core voltage not adjusted\n");
 
return 0;
diff --git a/include/configs/lx2160aqds.h b/include/configs/lx2160aqds.h
index 56a50d3..ddc76bd 100644
--- a/include/configs/lx2160aqds.h
+++ b/include/configs/lx2160aqds.h
@@ -127,7 +127,6 @@ u8 qixis_esdhc_detect_quirk(void);
 /* Initial environment variables */
 #define CONFIG_EXTRA_ENV_SETTINGS  \
EXTRA_ENV_SETTINGS  \
-   "lx2160aqds_vdd_mv=800\0"   \
"boot_scripts=lx2160aqds_boot.scr\0"\
"boot_script_hdr=hdr_lx2160aqds_bs.out\0"   \
"BOARD=lx2160aqds\0"\
diff --git a/include/configs/lx2160ardb.h b/include/configs/lx2160ardb.h
index 5b530f0..e86102a 100644
--- a/include/configs/lx2160ardb.h
+++ b/include/configs/lx2160ardb.h
@@ -99,7 +99,6 @@
EXTRA_ENV_SETTINGS  \
"boot_scripts=lx2160ardb_boot.scr\0"\
"boot_script_hdr=hdr_lx2160ardb_bs.out\0"   \
-   "lx2160ardb_vdd_mv=800\0"   \
"BOARD=lx2160ardb\0"\
"xspi_bootcmd=echo Trying load from flexspi..;" \
"sf probe 0:0 && sf read $load_addr "   \
-- 
1.9.1



[PATCH v6 15/16] sandbox: add extra configurations for UEFI and related tests

2020-02-25 Thread AKASHI Takahiro
Adding those extra configurations allows us to successfully run UEFI
secure boot pytest on Travis CI.

Signed-off-by: AKASHI Takahiro 
---
 configs/sandbox64_defconfig | 3 +++
 configs/sandbox_defconfig   | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index e96982402ba6..58c2c1e4db42 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -27,6 +27,7 @@ CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
 CONFIG_CMD_ENV_CALLBACK=y
 CONFIG_CMD_ENV_FLAGS=y
+CONFIG_CMD_NVEDIT_EFI=y
 CONFIG_LOOPW=y
 CONFIG_CMD_MD5SUM=y
 CONFIG_CMD_MEMINFO=y
@@ -53,6 +54,7 @@ CONFIG_CMD_DNS=y
 CONFIG_CMD_LINK_LOCAL=y
 CONFIG_CMD_ETHSW=y
 CONFIG_CMD_BMP=y
+CONFIG_CMD_EFIDEBUG=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_TIMER=y
 CONFIG_CMD_SOUND=y
@@ -204,6 +206,7 @@ CONFIG_RSA_VERIFY_WITH_PKEY=y
 CONFIG_TPM=y
 CONFIG_LZ4=y
 CONFIG_ERRNO_STR=y
+CONFIG_EFI_SECURE_BOOT=y
 CONFIG_TEST_FDTDEC=y
 CONFIG_UNIT_TEST=y
 CONFIG_UT_TIME=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 4e001fc650dc..c4c2261c946d 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -31,6 +31,7 @@ CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
 CONFIG_CMD_ENV_CALLBACK=y
 CONFIG_CMD_ENV_FLAGS=y
+CONFIG_CMD_NVEDIT_EFI=y
 CONFIG_LOOPW=y
 CONFIG_CMD_MD5SUM=y
 CONFIG_CMD_MEMINFO=y
@@ -62,6 +63,7 @@ CONFIG_CMD_LINK_LOCAL=y
 CONFIG_CMD_ETHSW=y
 CONFIG_CMD_BMP=y
 CONFIG_CMD_BOOTCOUNT=y
+CONFIG_CMD_EFIDEBUG=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_TIMER=y
 CONFIG_CMD_SOUND=y
@@ -230,6 +232,7 @@ CONFIG_RSA_VERIFY_WITH_PKEY=y
 CONFIG_TPM=y
 CONFIG_LZ4=y
 CONFIG_ERRNO_STR=y
+CONFIG_EFI_SECURE_BOOT=y
 CONFIG_TEST_FDTDEC=y
 CONFIG_UNIT_TEST=y
 CONFIG_UT_TIME=y
-- 
2.24.0



[PATCH v6 16/16] travis: add packages for UEFI secure boot test

2020-02-25 Thread AKASHI Takahiro
Pytest for UEFI secure boot will use several host commands.
In particular, Test setup relies on efitools, whose version must be v1.5.2
or later. So fetch a new version of deb package directly.
Please note it has a dependency on mtools, which must also be installed
along wih efitools.

In addition, the path, '/sbin', is added to PATH for use of sgdisk and
mkfs.

Signed-off-by: AKASHI Takahiro 
---
 .travis.yml | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 44e539038acd..36a0c4e1985e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -38,6 +38,14 @@ addons:
 - libisl15
 - clang-7
 - srecord
+- coreutils
+- util-linux
+- dosfstools
+- gdisk
+- mount
+- mtools
+- openssl
+- sbsigntool
 
 install:
  # Clone uboot-test-hooks
@@ -58,10 +66,11 @@ install:
  - mkdir ~/grub2-arm64
  - ( cd ~/grub2-arm64; wget -O - 
http://download.opensuse.org/ports/aarch64/distribution/leap/42.2/repo/oss/suse/aarch64/grub2-arm64-efi-2.02~beta2-87.1.aarch64.rpm
 | rpm2cpio | cpio -di )
  - wget 
http://mirrors.kernel.org/ubuntu/pool/main/m/mpfr4/libmpfr4_3.1.4-1_amd64.deb 
&& sudo dpkg -i libmpfr4_3.1.4-1_amd64.deb && rm libmpfr4_3.1.4-1_amd64.deb
+ - wget 
http://mirrors.kernel.org/ubuntu/pool/universe/e/efitools/efitools_1.8.1-0ubuntu2_amd64.deb
 && sudo dpkg -i efitools_1.8.1-0ubuntu2_amd64.deb && rm 
efitools_1.8.1-0ubuntu2_amd64.deb
 
 env:
   global:
-- 
PATH=/tmp/qemu-install/bin:/tmp/uboot-test-hooks/bin:/usr/bin:/bin:/usr/local/bin
+- 
PATH=/tmp/qemu-install/bin:/tmp/uboot-test-hooks/bin:/sbin:/usr/bin:/bin:/usr/local/bin
 - PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci
 - BUILD_DIR=build
 - HOSTCC="cc"
-- 
2.24.0



[PATCH v6 13/16] efi_loader, pytest: add UEFI secure boot tests (authenticated variables)

2020-02-25 Thread AKASHI Takahiro
Provide a couple of test cases for variable authentication.

Signed-off-by: AKASHI Takahiro 
---
 .../py/tests/test_efi_secboot/test_authvar.py | 282 ++
 1 file changed, 282 insertions(+)
 create mode 100644 test/py/tests/test_efi_secboot/test_authvar.py

diff --git a/test/py/tests/test_efi_secboot/test_authvar.py 
b/test/py/tests/test_efi_secboot/test_authvar.py
new file mode 100644
index ..55dcaa95f1ea
--- /dev/null
+++ b/test/py/tests/test_efi_secboot/test_authvar.py
@@ -0,0 +1,282 @@
+# SPDX-License-Identifier:  GPL-2.0+
+# Copyright (c) 2019, Linaro Limited
+# Author: AKASHI Takahiro 
+#
+# U-Boot UEFI: Variable Authentication Test
+
+"""
+This test verifies variable authentication
+"""
+
+import pytest
+import re
+from defs import *
+
+@pytest.mark.boardspec('sandbox')
+@pytest.mark.buildconfigspec('efi_secure_boot')
+@pytest.mark.buildconfigspec('cmd_fat')
+@pytest.mark.buildconfigspec('cmd_nvedit_efi')
+@pytest.mark.slow
+class TestEfiAuthVar(object):
+def test_efi_var_auth1(self, u_boot_console, efi_boot_env):
+"""
+Test Case 1 - Install signature database
+"""
+u_boot_console.restart_uboot()
+disk_img = efi_boot_env
+with u_boot_console.log.section('Test Case 1a'):
+# Test Case 1a, Initial secure state
+output = u_boot_console.run_command_list([
+'host bind 0 %s' % disk_img,
+'printenv -e SecureBoot'])
+assert(': 00' in ''.join(output))
+
+output = u_boot_console.run_command(
+'printenv -e SetupMode')
+assert(': 01' in output)
+
+with u_boot_console.log.section('Test Case 1b'):
+# Test Case 1b, PK without AUTHENTICATED_WRITE_ACCESS
+output = u_boot_console.run_command_list([
+'fatload host 0:1 400 PK.auth',
+'setenv -e -nv -bs -rt -i 400,$filesize PK'])
+assert(re.search('Failed to set EFI variable', ''.join(output)))
+
+with u_boot_console.log.section('Test Case 1c'):
+# Test Case 1c, install PK
+output = u_boot_console.run_command_list([
+'fatload host 0:1 400 PK.auth',
+'setenv -e -nv -bs -rt -at -i 400,$filesize PK',
+'printenv -e -n PK'])
+assert(re.search('PK:', ''.join(output)))
+
+output = u_boot_console.run_command(
+'printenv -e SecureBoot')
+assert(': 01' in output)
+output = u_boot_console.run_command(
+'printenv -e SetupMode')
+assert(': 00' in output)
+
+with u_boot_console.log.section('Test Case 1d'):
+# Test Case 1d, db/dbx without KEK
+output = u_boot_console.run_command_list([
+'fatload host 0:1 400 db.auth',
+'setenv -e -nv -bs -rt -at -i 400,$filesize db'])
+assert(re.search('Failed to set EFI variable', ''.join(output)))
+
+output = u_boot_console.run_command_list([
+'fatload host 0:1 400 db.auth',
+'setenv -e -nv -bs -rt -at -i 400,$filesize dbx'])
+assert(re.search('Failed to set EFI variable', ''.join(output)))
+
+with u_boot_console.log.section('Test Case 1e'):
+# Test Case 1e, install KEK
+output = u_boot_console.run_command_list([
+'fatload host 0:1 400 KEK.auth',
+'setenv -e -nv -bs -rt -i 400,$filesize KEK'])
+assert(re.search('Failed to set EFI variable', ''.join(output)))
+
+output = u_boot_console.run_command_list([
+'fatload host 0:1 400 KEK.auth',
+'setenv -e -nv -bs -rt -at -i 400,$filesize KEK',
+'printenv -e -n KEK'])
+assert(re.search('KEK:', ''.join(output)))
+
+output = u_boot_console.run_command(
+'printenv -e SecureBoot')
+assert(': 01' in output)
+
+with u_boot_console.log.section('Test Case 1f'):
+# Test Case 1f, install db
+output = u_boot_console.run_command_list([
+'fatload host 0:1 400 db.auth',
+'setenv -e -nv -bs -rt -i 400,$filesize db'])
+assert(re.search('Failed to set EFI variable', ''.join(output)))
+
+output = u_boot_console.run_command_list([
+'fatload host 0:1 400 db.auth',
+'setenv -e -nv -bs -rt -at -i 400,$filesize db',
+'printenv -e -n -guid d719b2cb-3d3a-4596-a3bc-dad00e67656f 
db'])
+assert(not re.search('Failed to set EFI variable', 
''.join(output)))
+assert(re.search('db:', ''.join(output)))
+
+output = u_boot_console.run_command(
+'printenv -e SecureBoot')
+assert(': 01' in 

[PATCH v6 14/16] efi_loader, pytest: add UEFI secure boot tests (image)

2020-02-25 Thread AKASHI Takahiro
Provide test cases for
 * image authentication for signed images
   (test_efi_secboot/test_signed.py)
 * image authentication for unsigned images
   (test_efi_secboot/test_unsigned.py)

Signed-off-by: AKASHI Takahiro 
---
 test/py/tests/test_efi_secboot/test_signed.py | 117 +
 .../tests/test_efi_secboot/test_unsigned.py   | 121 ++
 2 files changed, 238 insertions(+)
 create mode 100644 test/py/tests/test_efi_secboot/test_signed.py
 create mode 100644 test/py/tests/test_efi_secboot/test_unsigned.py

diff --git a/test/py/tests/test_efi_secboot/test_signed.py 
b/test/py/tests/test_efi_secboot/test_signed.py
new file mode 100644
index ..584282b338bc
--- /dev/null
+++ b/test/py/tests/test_efi_secboot/test_signed.py
@@ -0,0 +1,117 @@
+# SPDX-License-Identifier:  GPL-2.0+
+# Copyright (c) 2019, Linaro Limited
+# Author: AKASHI Takahiro 
+#
+# U-Boot UEFI: Signed Image Authentication Test
+
+"""
+This test verifies image authentication for signed images.
+"""
+
+import pytest
+import re
+from defs import *
+
+@pytest.mark.boardspec('sandbox')
+@pytest.mark.buildconfigspec('efi_secure_boot')
+@pytest.mark.buildconfigspec('cmd_efidebug')
+@pytest.mark.buildconfigspec('cmd_fat')
+@pytest.mark.buildconfigspec('cmd_nvedit_efi')
+@pytest.mark.slow
+class TestEfiSignedImage(object):
+def test_efi_signed_image_auth1(self, u_boot_console, efi_boot_env):
+"""
+Test Case 1 - authenticated by db
+"""
+u_boot_console.restart_uboot()
+disk_img = efi_boot_env
+with u_boot_console.log.section('Test Case 1a'):
+# Test Case 1a, run signed image if no db/dbx
+output = u_boot_console.run_command_list([
+'host bind 0 %s' % disk_img,
+'efidebug boot add 1 HELLO1 host 0:1 /helloworld.efi.signed 
""',
+'efidebug boot next 1',
+'bootefi bootmgr'])
+assert(re.search('Hello, world!', ''.join(output)))
+
+with u_boot_console.log.section('Test Case 1b'):
+# Test Case 1b, run unsigned image if no db/dbx
+output = u_boot_console.run_command_list([
+'efidebug boot add 2 HELLO2 host 0:1 /helloworld.efi ""',
+'efidebug boot next 2',
+'bootefi bootmgr'])
+assert(re.search('Hello, world!', ''.join(output)))
+
+with u_boot_console.log.section('Test Case 1c'):
+# Test Case 1c, not authenticated by db
+output = u_boot_console.run_command_list([
+'fatload host 0:1 400 db.auth',
+'setenv -e -nv -bs -rt -at -i 400,$filesize db',
+'fatload host 0:1 400 KEK.auth',
+'setenv -e -nv -bs -rt -at -i 400,$filesize KEK',
+'fatload host 0:1 400 PK.auth',
+'setenv -e -nv -bs -rt -at -i 400,$filesize PK'])
+assert(not re.search('Failed to set EFI variable', 
''.join(output)))
+output = u_boot_console.run_command_list([
+'efidebug boot next 2',
+'bootefi bootmgr'])
+assert(re.search('\'HELLO2\' failed', ''.join(output)))
+output = u_boot_console.run_command_list([
+'efidebug boot next 2',
+'efidebug test bootmgr'])
+assert(re.search('efi_start_image[(][)] returned: 26',
+''.join(output)))
+assert(not re.search('Hello, world!', ''.join(output)))
+
+with u_boot_console.log.section('Test Case 1d'):
+# Test Case 1d, authenticated by db
+output = u_boot_console.run_command_list([
+'efidebug boot next 1',
+'bootefi bootmgr'])
+assert(re.search('Hello, world!', ''.join(output)))
+
+def test_efi_signed_image_auth2(self, u_boot_console, efi_boot_env):
+"""
+Test Case 2 - rejected by dbx
+"""
+u_boot_console.restart_uboot()
+disk_img = efi_boot_env
+with u_boot_console.log.section('Test Case 2a'):
+# Test Case 2a, rejected by dbx
+output = u_boot_console.run_command_list([
+'host bind 0 %s' % disk_img,
+'fatload host 0:1 400 db.auth',
+'setenv -e -nv -bs -rt -at -i 400,$filesize dbx',
+'fatload host 0:1 400 KEK.auth',
+'setenv -e -nv -bs -rt -at -i 400,$filesize KEK',
+'fatload host 0:1 400 PK.auth',
+'setenv -e -nv -bs -rt -at -i 400,$filesize PK'])
+assert(not re.search('Failed to set EFI variable', 
''.join(output)))
+output = u_boot_console.run_command_list([
+'efidebug boot add 1 HELLO host 0:1 /helloworld.efi.signed ""',
+'efidebug boot next 1',
+'bootefi bootmgr'])
+assert(re.search('\'HELLO\' failed', ''.join(output)))

[PATCH v6 12/16] efi_loader, pytest: set up secure boot environment

2020-02-25 Thread AKASHI Takahiro
A fixture for UEFI secure boot tests (image authentication and variable
authentication) is defined. A small file system with test data in a single
partition formatted in fat is created.

This test requires efitools v1.5.2 or later. If the system's efitools
is older, you have to build it on your own and define EFITOOLS_PATH.

Signed-off-by: AKASHI Takahiro 
---
 test/py/README.md  |   8 ++
 test/py/tests/test_efi_secboot/conftest.py | 151 +
 test/py/tests/test_efi_secboot/defs.py |  21 +++
 3 files changed, 180 insertions(+)
 create mode 100644 test/py/tests/test_efi_secboot/conftest.py
 create mode 100644 test/py/tests/test_efi_secboot/defs.py

diff --git a/test/py/README.md b/test/py/README.md
index 3cbe01b73e28..aa8a5607b064 100644
--- a/test/py/README.md
+++ b/test/py/README.md
@@ -37,7 +37,15 @@ will be required.  The following is an incomplete list:
 | openssl|
 | sudo OR guestmount |
 | e2fsprogs  |
+| util-linux |
+| coreutils  |
 | dosfstools |
+| efitools   |
+| mount  |
+| mtools |
+| sbsigntool |
+| udisks2|
+
 
 Please use the apporirate commands for your distribution to match these tools
 up with the package that provides them.
diff --git a/test/py/tests/test_efi_secboot/conftest.py 
b/test/py/tests/test_efi_secboot/conftest.py
new file mode 100644
index ..e542fef6e819
--- /dev/null
+++ b/test/py/tests/test_efi_secboot/conftest.py
@@ -0,0 +1,151 @@
+# SPDX-License-Identifier:  GPL-2.0+
+# Copyright (c) 2019, Linaro Limited
+# Author: AKASHI Takahiro 
+
+import os
+import os.path
+import pytest
+import re
+from subprocess import call, check_call, check_output, CalledProcessError
+from defs import *
+
+# from test/py/conftest.py
+def tool_is_in_path(tool):
+for path in os.environ["PATH"].split(os.pathsep):
+fn = os.path.join(path, tool)
+if os.path.isfile(fn) and os.access(fn, os.X_OK):
+return True
+return False
+
+#
+# Fixture for UEFI secure boot test
+#
+@pytest.fixture(scope='session')
+def efi_boot_env(request, u_boot_config):
+"""Set up a file system to be used in UEFI secure boot test.
+
+Args:
+request: Pytest request object.
+   u_boot_config: U-boot configuration.
+
+Return:
+A path to disk image to be used for testing
+"""
+global HELLO_PATH
+
+image_path = u_boot_config.persistent_data_dir
+image_path = image_path + '/' + EFI_SECBOOT_IMAGE_NAME
+image_size = EFI_SECBOOT_IMAGE_SIZE
+part_size = EFI_SECBOOT_PART_SIZE
+fs_type = EFI_SECBOOT_FS_TYPE
+
+if HELLO_PATH == '':
+HELLO_PATH = u_boot_config.build_dir + '/lib/efi_loader/helloworld.efi'
+
+try:
+non_root = tool_is_in_path('udisksctl')
+
+# create a disk/partition
+check_call('dd if=/dev/zero of=%s bs=1MiB count=%d'
+% (image_path, image_size), shell=True)
+check_call('sgdisk %s -n 1:0:+%dMiB'
+% (image_path, part_size), shell=True)
+# create a file system
+check_call('dd if=/dev/zero of=%s.tmp bs=1MiB count=%d'
+% (image_path, part_size), shell=True)
+check_call('mkfs -t %s %s.tmp' % (fs_type, image_path), shell=True)
+check_call('dd if=%s.tmp of=%s bs=1MiB seek=1 count=%d conv=notrunc'
+% (image_path, image_path, 1), shell=True)
+check_call('rm %s.tmp' % image_path, shell=True)
+if non_root:
+out_data = check_output('udisksctl loop-setup -f %s -o %d'
+% (image_path, 1048576), shell=True).decode()
+m = re.search('(?<= as )(.*)\.', out_data)
+loop_dev = m.group(1)
+# print 'loop device is: %s' % loop_dev
+out_data = check_output('udisksctl info -b %s'
+% loop_dev, shell=True).decode()
+m = re.search('MountPoints:[ \t]+(.*)', out_data)
+mnt_point = m.group(1)
+else:
+loop_dev = check_output('sudo losetup -o 1MiB --sizelimit %dMiB 
--show -f %s | tr -d "\n"'
+% (part_size, image_path), shell=True).decode()
+mnt_point = '/mnt'
+check_output('sudo mount -t %s -o umask=000 %s %s'
+% (fs_type, loop_dev, mnt_point), shell=True)
+
+# print 'mount point is: %s' % mnt_point
+
+# suffix
+# *.key: RSA private key in PEM
+# *.crt: X509 certificate (self-signed) in PEM
+# *.esl: signature list
+# *.hash: message digest of image as signature list
+# *.auth: signed signature list in signature database format
+# *.efi: UEFI image
+# *.efi.signed: signed UEFI image
+
+# Create signature database
+## PK
+check_call('cd %s; openssl req -x509 -sha256 -newkey rsa:2048 -subj 
/CN=TEST_PK/ 

[PATCH v6 11/16] cmd: efidebug: add "test bootmgr" sub-command

2020-02-25 Thread AKASHI Takahiro
This sub-command will be used to test image authentication,
in particular, a case where efi_load_image() failed with
EFI_SECURITY_VIOLATION but we still want to try efi_start_image().
We won't run such a case under normal bootmgr because it simply
refuses to call efi_start_image() if anything but EFI_SUCCESS
is returned when loading an image.

Signed-off-by: AKASHI Takahiro 
---
 cmd/efidebug.c | 78 +-
 1 file changed, 77 insertions(+), 1 deletion(-)

diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index 576e95b395dc..8f3bf132aaad 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -1076,6 +1076,78 @@ static int do_efi_boot_opt(cmd_tbl_t *cmdtp, int flag,
return cp->cmd(cmdtp, flag, argc, argv);
 }
 
+/**
+ * do_efi_test_bootmgr() - run simple bootmgr for test
+ *
+ * @cmdtp: Command table
+ * @flag:  Command flag
+ * @argc:  Number of arguments
+ * @argv:  Argument array
+ * Return: CMD_RET_SUCCESS on success,
+ * CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure
+ *
+ * Implement efidebug "test bootmgr" sub-command.
+ * Run simple bootmgr for test.
+ *
+ * efidebug test bootmgr
+ */
+static int do_efi_test_bootmgr(cmd_tbl_t *cmdtp, int flag,
+  int argc, char * const argv[])
+{
+   efi_handle_t image;
+   efi_uintn_t exit_data_size = 0;
+   u16 *exit_data = NULL;
+   efi_status_t ret;
+
+   ret = efi_bootmgr_load();
+   printf("efi_bootmgr_load() returned: %ld\n", ret & ~EFI_ERROR_MASK);
+
+   /* We call efi_start_image() even if error for test purpose. */
+   ret = EFI_CALL(efi_start_image(image, _data_size, _data));
+   printf("efi_start_image() returned: %ld\n", ret & ~EFI_ERROR_MASK);
+   if (ret && exit_data)
+   efi_free_pool(exit_data);
+
+   efi_restore_gd();
+
+   return CMD_RET_SUCCESS;
+}
+
+static cmd_tbl_t cmd_efidebug_test_sub[] = {
+   U_BOOT_CMD_MKENT(bootmgr, CONFIG_SYS_MAXARGS, 1, do_efi_test_bootmgr,
+"", ""),
+};
+
+/**
+ * do_efi_test() - manage UEFI load options
+ *
+ * @cmdtp: Command table
+ * @flag:  Command flag
+ * @argc:  Number of arguments
+ * @argv:  Argument array
+ * Return: CMD_RET_SUCCESS on success,
+ * CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure
+ *
+ * Implement efidebug "test" sub-command.
+ */
+static int do_efi_test(cmd_tbl_t *cmdtp, int flag,
+  int argc, char * const argv[])
+{
+   cmd_tbl_t *cp;
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   argc--; argv++;
+
+   cp = find_cmd_tbl(argv[0], cmd_efidebug_test_sub,
+ ARRAY_SIZE(cmd_efidebug_test_sub));
+   if (!cp)
+   return CMD_RET_USAGE;
+
+   return cp->cmd(cmdtp, flag, argc, argv);
+}
+
 static cmd_tbl_t cmd_efidebug_sub[] = {
U_BOOT_CMD_MKENT(boot, CONFIG_SYS_MAXARGS, 1, do_efi_boot_opt, "", ""),
U_BOOT_CMD_MKENT(devices, CONFIG_SYS_MAXARGS, 1, do_efi_show_devices,
@@ -1090,6 +1162,8 @@ static cmd_tbl_t cmd_efidebug_sub[] = {
 "", ""),
U_BOOT_CMD_MKENT(tables, CONFIG_SYS_MAXARGS, 1, do_efi_show_tables,
 "", ""),
+   U_BOOT_CMD_MKENT(test, CONFIG_SYS_MAXARGS, 1, do_efi_test,
+"", ""),
 };
 
 /**
@@ -1159,7 +1233,9 @@ static char efidebug_help_text[] =
"efidebug memmap\n"
"  - show UEFI memory map\n"
"efidebug tables\n"
-   "  - show UEFI configuration tables\n";
+   "  - show UEFI configuration tables\n"
+   "efidebug test bootmgr\n"
+   "  - run simple bootmgr for test\n";
 #endif
 
 U_BOOT_CMD(
-- 
2.24.0



[PATCH v6 04/16] efi_loader: variable: support variable authentication

2020-02-25 Thread AKASHI Takahiro
With this commit, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
is supported for authenticated variables and the system secure state
will transfer between setup mode and user mode as UEFI specification
section 32.3 describes.

Internally, authentication data is stored as part of authenticated
variable's value. It is nothing but a pkcs7 message (but we need some
wrapper, see efi_variable_parse_signature()) and will be validated by
efi_variable_authenticate(), hence efi_signature_verify_with_db().

Associated time value will be encoded in "{...,time=...}" along with
other UEFI variable's attributes.

Signed-off-by: AKASHI Takahiro 
---
 include/efi_loader.h  |   3 +
 lib/efi_loader/efi_variable.c | 666 --
 2 files changed, 565 insertions(+), 104 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 34f7b8eec8cd..f461c6195834 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -184,6 +184,7 @@ extern const efi_guid_t efi_guid_image_security_database;
 extern const efi_guid_t efi_guid_sha256;
 extern const efi_guid_t efi_guid_cert_x509;
 extern const efi_guid_t efi_guid_cert_x509_sha256;
+extern const efi_guid_t efi_guid_cert_type_pkcs7;
 
 /* GUID of RNG protocol */
 extern const efi_guid_t efi_guid_rng_protocol;
@@ -738,6 +739,8 @@ efi_status_t efi_image_region_add(struct efi_image_regions 
*regs,
 
 void efi_sigstore_free(struct efi_signature_store *sigstore);
 struct efi_signature_store *efi_sigstore_parse_sigdb(u16 *name);
+
+bool efi_secure_boot_enabled(void);
 #endif /* CONFIG_EFI_SECURE_BOOT */
 
 #else /* CONFIG_IS_ENABLED(EFI_LOADER) */
diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
index c316bdfec0e4..c82128f0c9ad 100644
--- a/lib/efi_loader/efi_variable.c
+++ b/lib/efi_loader/efi_variable.c
@@ -10,8 +10,14 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
+#include "../lib/crypto/pkcs7_parser.h"
+
+const efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID;
+static bool efi_secure_boot;
 
 #define READ_ONLY BIT(31)
 
@@ -106,9 +112,10 @@ static const char *prefix(const char *str, const char 
*prefix)
  *
  * @str:   value of U-Boot variable
  * @attrp: pointer to UEFI attributes
+ * @timep: pointer to time attribute
  * Return: pointer to remainder of U-Boot variable value
  */
-static const char *parse_attr(const char *str, u32 *attrp)
+static const char *parse_attr(const char *str, u32 *attrp, u64 *timep)
 {
u32 attr = 0;
char sep = '{';
@@ -131,6 +138,12 @@ static const char *parse_attr(const char *str, u32 *attrp)
attr |= EFI_VARIABLE_BOOTSERVICE_ACCESS;
} else if ((s = prefix(str, "run"))) {
attr |= EFI_VARIABLE_RUNTIME_ACCESS;
+   } else if ((s = prefix(str, "time="))) {
+   attr |= 
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
+   hex2bin((u8 *)timep, s, sizeof(*timep));
+   s += sizeof(*timep) * 2;
+   } else if (*str == '}') {
+   break;
} else {
printf("invalid attribute: %s\n", str);
break;
@@ -148,48 +161,291 @@ static const char *parse_attr(const char *str, u32 
*attrp)
 }
 
 /**
- * efi_get_variable() - retrieve value of a UEFI variable
+ * efi_secure_boot_enabled - return if secure boot is enabled or not
  *
- * This function implements the GetVariable runtime service.
+ * Return: true if enabled, false if disabled
+ */
+bool efi_secure_boot_enabled(void)
+{
+   return efi_secure_boot;
+}
+
+#ifdef CONFIG_EFI_SECURE_BOOT
+static u8 pkcs7_hdr[] = {
+   /* SEQUENCE */
+   0x30, 0x82, 0x05, 0xc7,
+   /* OID: pkcs7-signedData */
+   0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02,
+   /* Context Structured? */
+   0xa0, 0x82, 0x05, 0xb8,
+};
+
+/**
+ * efi_variable_parse_signature - parse a signature in variable
+ * @buf:   Pointer to variable's value
+ * @buflen:Length of @buf
  *
- * See the Unified Extensible Firmware Interface (UEFI) specification for
- * details.
+ * Parse a signature embedded in variable's value and instantiate
+ * a pkcs7_message structure. Since pkcs7_parse_message() accepts only
+ * pkcs7's signedData, some header needed be prepended for correctly
+ * parsing authentication data, particularly for variable's.
  *
- * @variable_name: name of the variable
- * @vendor:vendor GUID
- * @attributes:attributes of the variable
- * @data_size: size of the buffer to which the variable value is copied
- * @data:  buffer to which the variable value is copied
- * Return: status code
+ * Return: Pointer to pkcs7_message structure on success, NULL on error
  */
-efi_status_t EFIAPI efi_get_variable(u16 *variable_name,
- 

[PATCH v6 09/16] cmd: env: use appropriate guid for authenticated UEFI variable

2020-02-25 Thread AKASHI Takahiro
A signature database variable is associated with a specific guid.
For convenience, if user doesn't supply any guid info, "env set|print -e"
should complement it.

Signed-off-by: AKASHI Takahiro 
---
 cmd/nvedit_efi.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c
index 8ea0da01283f..579cf430593c 100644
--- a/cmd/nvedit_efi.c
+++ b/cmd/nvedit_efi.c
@@ -41,6 +41,11 @@ static const struct {
 } efi_guid_text[] = {
/* signature database */
{EFI_GLOBAL_VARIABLE_GUID, "EFI_GLOBAL_VARIABLE_GUID"},
+   {EFI_IMAGE_SECURITY_DATABASE_GUID, "EFI_IMAGE_SECURITY_DATABASE_GUID"},
+   /* certificate type */
+   {EFI_CERT_SHA256_GUID, "EFI_CERT_SHA256_GUID"},
+   {EFI_CERT_X509_GUID, "EFI_CERT_X509_GUID"},
+   {EFI_CERT_TYPE_PKCS7_GUID, "EFI_CERT_TYPE_PKCS7_GUID"},
 };
 
 /* "----" */
@@ -525,9 +530,9 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
if (*ep != ',')
return CMD_RET_USAGE;
 
+   /* 0 should be allowed for delete */
size = simple_strtoul(++ep, NULL, 16);
-   if (!size)
-   return CMD_RET_FAILURE;
+
value_on_memory = true;
} else if (!strcmp(argv[0], "-v")) {
verbose = true;
@@ -539,8 +544,13 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
return CMD_RET_USAGE;
 
var_name = argv[0];
-   if (default_guid)
-   guid = efi_global_variable_guid;
+   if (default_guid) {
+   if (!strcmp(var_name, "db") || !strcmp(var_name, "dbx") ||
+   !strcmp(var_name, "dbt"))
+   guid = efi_guid_image_security_database;
+   else
+   guid = efi_global_variable_guid;
+   }
 
if (verbose) {
printf("GUID: %s\n", efi_guid_to_str((const efi_guid_t *)
-- 
2.24.0



[PATCH v6 07/16] efi_loader: image_loader: support image authentication

2020-02-25 Thread AKASHI Takahiro
With this commit, image validation can be enforced, as UEFI specification
section 32.5 describes, if CONFIG_EFI_SECURE_BOOT is enabled.

Currently we support
* authentication based on db and dbx,
  so dbx-validated image will always be rejected.
* following signature types:
EFI_CERT_SHA256_GUID (SHA256 digest for unsigned images)
EFI_CERT_X509_GUID (x509 certificate for signed images)
Timestamp-based certificate revocation is not supported here.

Internally, authentication data is stored in one of certificates tables
of PE image (See efi_image_parse()) and will be verified by
efi_image_authenticate() before loading a given image.

It seems that UEFI specification defines the verification process
in a bit ambiguous way. I tried to implement it as closely to as
EDK2 does.

Signed-off-by: AKASHI Takahiro 
---
 include/efi_loader.h  |  13 +-
 lib/efi_loader/efi_boottime.c |  10 +-
 lib/efi_loader/efi_image_loader.c | 459 +-
 3 files changed, 466 insertions(+), 16 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index f461c6195834..0e15470d9c17 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static inline int guidcmp(const void *g1, const void *g2)
 {
@@ -263,6 +264,11 @@ struct efi_object {
enum efi_object_type type;
 };
 
+enum efi_image_auth_status {
+   EFI_IMAGE_AUTH_FAILED = 0,
+   EFI_IMAGE_AUTH_PASSED,
+};
+
 /**
  * struct efi_loaded_image_obj - handle of a loaded image
  *
@@ -282,6 +288,7 @@ struct efi_loaded_image_obj {
EFIAPI efi_status_t (*entry)(efi_handle_t image_handle,
 struct efi_system_table *st);
u16 image_type;
+   enum efi_image_auth_status auth_status;
 };
 
 /**
@@ -414,7 +421,8 @@ efi_status_t efi_set_watchdog(unsigned long timeout);
 /* Called from places to check whether a timer expired */
 void efi_timer_check(void);
 /* PE loader implementation */
-efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle, void *efi,
+efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
+void *efi, size_t efi_size,
 struct efi_loaded_image *loaded_image_info);
 /* Called once to store the pristine gd pointer */
 void efi_save_gd(void);
@@ -741,6 +749,9 @@ void efi_sigstore_free(struct efi_signature_store 
*sigstore);
 struct efi_signature_store *efi_sigstore_parse_sigdb(u16 *name);
 
 bool efi_secure_boot_enabled(void);
+
+bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp,
+WIN_CERTIFICATE **auth, size_t *auth_len);
 #endif /* CONFIG_EFI_SECURE_BOOT */
 
 #else /* CONFIG_IS_ENABLED(EFI_LOADER) */
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 1f598b357a5c..cc8cc4cb5408 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1882,12 +1882,12 @@ efi_status_t EFIAPI efi_load_image(bool boot_policy,
efi_dp_split_file_path(file_path, , );
ret = efi_setup_loaded_image(dp, fp, image_obj, );
if (ret == EFI_SUCCESS)
-   ret = efi_load_pe(*image_obj, dest_buffer, info);
+   ret = efi_load_pe(*image_obj, dest_buffer, source_size, info);
if (!source_buffer)
/* Release buffer to which file was loaded */
efi_free_pages((uintptr_t)dest_buffer,
   efi_size_in_pages(source_size));
-   if (ret == EFI_SUCCESS) {
+   if (ret == EFI_SUCCESS || ret == EFI_SECURITY_VIOLATION) {
info->system_table = 
info->parent_handle = parent_image;
} else {
@@ -2885,10 +2885,16 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t 
image_handle,
 
EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data);
 
+   if (!efi_search_obj(image_handle))
+   return EFI_EXIT(EFI_INVALID_PARAMETER);
+
/* Check parameters */
if (image_obj->header.type != EFI_OBJECT_TYPE_LOADED_IMAGE)
return EFI_EXIT(EFI_INVALID_PARAMETER);
 
+   if (image_obj->auth_status != EFI_IMAGE_AUTH_PASSED)
+   return EFI_EXIT(EFI_SECURITY_VIOLATION);
+
ret = EFI_CALL(efi_open_protocol(image_handle, _guid_loaded_image,
 , NULL, NULL,
 EFI_OPEN_PROTOCOL_GET_PROTOCOL));
diff --git a/lib/efi_loader/efi_image_loader.c 
b/lib/efi_loader/efi_image_loader.c
index d5de6df16d84..f9c389e2fbcd 100644
--- a/lib/efi_loader/efi_image_loader.c
+++ b/lib/efi_loader/efi_image_loader.c
@@ -10,7 +10,10 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
+#include "../lib/crypto/pkcs7_parser.h"
 
 const efi_guid_t efi_global_variable_guid = EFI_GLOBAL_VARIABLE_GUID;
 const efi_guid_t efi_guid_device_path = EFI_DEVICE_PATH_PROTOCOL_GUID;
@@ -206,6 +209,383 @@ static 

[PATCH v6 10/16] cmd: env: add "-at" option to "env set -e" command

2020-02-25 Thread AKASHI Takahiro
With "-at" option, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
will be passed to SetVariable() to authenticate the variable.

Signed-off-by: AKASHI Takahiro 
---
 cmd/nvedit.c | 5 +++--
 cmd/nvedit_efi.c | 5 -
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 81d94cd193c6..966c13405956 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -1417,7 +1417,7 @@ static char env_help_text[] =
 #endif
 #endif
 #if defined(CONFIG_CMD_NVEDIT_EFI)
-   "env set -e [-nv][-bs][-rt][-a][-i addr,size][-v] name [arg ...]\n"
+   "env set -e [-nv][-bs][-rt][-at][-a][-i addr,size][-v] name [arg ...]\n"
"- set UEFI variable; unset if '-i' or 'arg' not specified\n"
 #endif
"env set [-f] name [arg ...]\n";
@@ -1479,13 +1479,14 @@ U_BOOT_CMD_COMPLETE(
setenv, CONFIG_SYS_MAXARGS, 0,  do_env_set,
"set environment variables",
 #if defined(CONFIG_CMD_NVEDIT_EFI)
-   "-e [-guid guid][-nv][-bs][-rt][-a][-v]\n"
+   "-e [-guid guid][-nv][-bs][-rt][-at][-a][-v]\n"
"[-i addr,size name], or [name [value ...]]\n"
"- set UEFI variable 'name' to 'value' ...'\n"
"  \"-guid\": set vendor guid\n"
"  \"-nv\": set non-volatile attribute\n"
"  \"-bs\": set boot-service attribute\n"
"  \"-rt\": set runtime attribute\n"
+   "  \"-at\": set time-based authentication attribute\n"
"  \"-a\": append-write\n"
"  \"-i addr,size\": use  as variable's value\n"
"  \"-v\": verbose message\n"
diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c
index 579cf430593c..837e39e02179 100644
--- a/cmd/nvedit_efi.c
+++ b/cmd/nvedit_efi.c
@@ -458,7 +458,7 @@ out:
  * Return: CMD_RET_SUCCESS on success, or CMD_RET_RET_FAILURE
  *
  * This function is for "env set -e" or "setenv -e" command:
- *   => env set -e [-guid guid][-nv][-bs][-rt][-a][-v]
+ *   => env set -e [-guid guid][-nv][-bs][-rt][-at][-a][-v]
  *[-i address,size] var, or
  * var [value ...]
  * Encode values specified and set given UEFI variable.
@@ -517,6 +517,9 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
attributes |= EFI_VARIABLE_RUNTIME_ACCESS;
} else if (!strcmp(argv[0], "-nv")) {
attributes |= EFI_VARIABLE_NON_VOLATILE;
+   } else if (!strcmp(argv[0], "-at")) {
+   attributes |=
+ EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
} else if (!strcmp(argv[0], "-a")) {
attributes |= EFI_VARIABLE_APPEND_WRITE;
} else if (!strcmp(argv[0], "-i")) {
-- 
2.24.0



[PATCH v6 05/16] efi_loader: variable: add secure boot state transition

2020-02-25 Thread AKASHI Takahiro
UEFI specification defines several global variables which are related to
the current secure boot state. In this commit, those values will be
maintained according to operations. Currently, AuditMode and DeployedMode
are defined but not implemented.

Signed-off-by: AKASHI Takahiro 
---
 lib/efi_loader/efi_variable.c | 231 +-
 1 file changed, 228 insertions(+), 3 deletions(-)

diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
index c82128f0c9ad..bf0ee486e4cf 100644
--- a/lib/efi_loader/efi_variable.c
+++ b/lib/efi_loader/efi_variable.c
@@ -16,8 +16,16 @@
 #include 
 #include "../lib/crypto/pkcs7_parser.h"
 
+enum efi_secure_mode {
+   EFI_MODE_SETUP,
+   EFI_MODE_USER,
+   EFI_MODE_AUDIT,
+   EFI_MODE_DEPLOYED,
+};
+
 const efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID;
 static bool efi_secure_boot;
+static int efi_secure_mode;
 
 #define READ_ONLY BIT(31)
 
@@ -160,6 +168,210 @@ static const char *parse_attr(const char *str, u32 
*attrp, u64 *timep)
return str;
 }
 
+static efi_status_t efi_set_variable_internal(u16 *variable_name,
+ const efi_guid_t *vendor,
+ u32 attributes,
+ efi_uintn_t data_size,
+ const void *data,
+ bool ro_check);
+
+/**
+ * efi_transfer_secure_state - handle a secure boot state transition
+ * @mode:  new state
+ *
+ * Depending on @mode, secure boot related variables are updated.
+ * Those variables are *read-only* for users, efi_set_variable_internal()
+ * is called here.
+ *
+ * Return: EFI_SUCCESS on success, status code (negative) on error
+ */
+static efi_status_t efi_transfer_secure_state(enum efi_secure_mode mode)
+{
+   u32 attributes;
+   u8 val;
+   efi_status_t ret;
+
+   debug("Secure state from %d to %d\n", efi_secure_mode, mode);
+
+   attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS |
+EFI_VARIABLE_RUNTIME_ACCESS;
+   if (mode == EFI_MODE_DEPLOYED) {
+   val = 1;
+   ret = efi_set_variable_internal(L"SecureBoot",
+   _global_variable_guid,
+   attributes | READ_ONLY,
+   sizeof(val), ,
+   false);
+   if (ret != EFI_SUCCESS)
+   goto err;
+   val = 0;
+   ret = efi_set_variable_internal(L"SetupMode",
+   _global_variable_guid,
+   attributes | READ_ONLY,
+   sizeof(val), ,
+   false);
+   if (ret != EFI_SUCCESS)
+   goto err;
+   val = 0;
+   ret = efi_set_variable_internal(L"AuditMode",
+   _global_variable_guid,
+   attributes | READ_ONLY,
+   sizeof(val), ,
+   false);
+   if (ret != EFI_SUCCESS)
+   goto err;
+   val = 1;
+   ret = efi_set_variable_internal(L"DeployedMode",
+   _global_variable_guid,
+   attributes | READ_ONLY,
+   sizeof(val), ,
+   false);
+   if (ret != EFI_SUCCESS)
+   goto err;
+
+   efi_secure_boot = true;
+   } else if (mode == EFI_MODE_AUDIT) {
+   ret = efi_set_variable_internal(L"PK",
+   _global_variable_guid,
+   attributes,
+   0, NULL,
+   false);
+   if (ret != EFI_SUCCESS)
+   goto err;
+   val = 0;
+   ret = efi_set_variable_internal(L"SecureBoot",
+   _global_variable_guid,
+   attributes | READ_ONLY,
+   sizeof(val), ,
+   false);
+   if (ret != EFI_SUCCESS)
+   goto err;
+   val = 1;
+   ret = efi_set_variable_internal(L"SetupMode",
+   _global_variable_guid,
+   attributes | READ_ONLY,
+  

[PATCH v6 08/16] efi_loader: set up secure boot

2020-02-25 Thread AKASHI Takahiro
The following variable is exported as UEFI specification defines:
SignatureSupport: array of GUIDs representing the type of signatures
  supported by the platform firmware

Signed-off-by: AKASHI Takahiro 
---
 lib/efi_loader/efi_setup.c | 38 ++
 1 file changed, 38 insertions(+)

diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index de7b616c6daa..50cef1b4dfde 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -82,6 +82,39 @@ out:
return ret;
 }
 
+#ifdef CONFIG_EFI_SECURE_BOOT
+/**
+ * efi_init_secure_boot - initialize secure boot state
+ *
+ * Return: EFI_SUCCESS on success, status code (negative) on error
+ */
+static efi_status_t efi_init_secure_boot(void)
+{
+   efi_guid_t signature_types[] = {
+   EFI_CERT_SHA256_GUID,
+   EFI_CERT_X509_GUID,
+   };
+   efi_status_t ret;
+
+   /* TODO: read-only */
+   ret = EFI_CALL(efi_set_variable(L"SignatureSupport",
+   _global_variable_guid,
+   EFI_VARIABLE_BOOTSERVICE_ACCESS
+| EFI_VARIABLE_RUNTIME_ACCESS,
+   sizeof(signature_types),
+   _types));
+   if (ret != EFI_SUCCESS)
+   printf("EFI: cannot initialize SignatureSupport variable\n");
+
+   return ret;
+}
+#else
+static efi_status_t efi_init_secure_boot(void)
+{
+   return EFI_SUCCESS;
+}
+#endif /* CONFIG_EFI_SECURE_BOOT */
+
 /**
  * efi_init_obj_list() - Initialize and populate EFI object list
  *
@@ -122,6 +155,11 @@ efi_status_t efi_init_obj_list(void)
if (ret != EFI_SUCCESS)
goto out;
 
+   /* Secure boot */
+   ret = efi_init_secure_boot();
+   if (ret != EFI_SUCCESS)
+   goto out;
+
/* Indicate supported runtime services */
ret = efi_init_runtime_supported();
if (ret != EFI_SUCCESS)
-- 
2.24.0



[PATCH v6 03/16] efi_loader: add signature database parser

2020-02-25 Thread AKASHI Takahiro
efi_signature_parse_sigdb() is a helper function will be used to parse
signature database variable and instantiate a signature store structure
in later patches.

Signed-off-by: AKASHI Takahiro 
---
 include/efi_loader.h   |   3 +
 lib/efi_loader/efi_signature.c | 226 +
 2 files changed, 229 insertions(+)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 5c8481e27920..34f7b8eec8cd 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -735,6 +735,9 @@ bool efi_signature_verify_with_sigdb(struct 
efi_image_regions *regs,
 efi_status_t efi_image_region_add(struct efi_image_regions *regs,
  const void *start, const void *end,
  int nocheck);
+
+void efi_sigstore_free(struct efi_signature_store *sigstore);
+struct efi_signature_store *efi_sigstore_parse_sigdb(u16 *name);
 #endif /* CONFIG_EFI_SECURE_BOOT */
 
 #else /* CONFIG_IS_ENABLED(EFI_LOADER) */
diff --git a/lib/efi_loader/efi_signature.c b/lib/efi_loader/efi_signature.c
index 23dac94c0593..2d1f38980e5f 100644
--- a/lib/efi_loader/efi_signature.c
+++ b/lib/efi_loader/efi_signature.c
@@ -580,4 +580,230 @@ efi_status_t efi_image_region_add(struct 
efi_image_regions *regs,
 
return EFI_SUCCESS;
 }
+
+/**
+ * efi_sigstore_free - free signature store
+ * @sigstore:  Pointer to signature store structure
+ *
+ * Feee all the memories held in signature store and itself,
+ * which were allocated by efi_sigstore_parse_sigdb().
+ */
+void efi_sigstore_free(struct efi_signature_store *sigstore)
+{
+   struct efi_signature_store *sigstore_next;
+   struct efi_sig_data *sig_data, *sig_data_next;
+
+   while (sigstore) {
+   sigstore_next = sigstore->next;
+
+   sig_data = sigstore->sig_data_list;
+   while (sig_data) {
+   sig_data_next = sig_data->next;
+   free(sig_data->data);
+   free(sig_data);
+   sig_data = sig_data_next;
+   }
+
+   free(sigstore);
+   sigstore = sigstore_next;
+   }
+}
+
+/**
+ * efi_sigstore_parse_siglist - parse a signature list
+ * @name:  Pointer to signature list
+ *
+ * Parse signature list and instantiate a signature store structure.
+ * Signature database is a simple concatenation of one or more
+ * signature list(s).
+ *
+ * Return: Pointer to signature store on success, NULL on error
+ */
+static struct efi_signature_store *
+efi_sigstore_parse_siglist(struct efi_signature_list *esl)
+{
+   struct efi_signature_store *siglist = NULL;
+   struct efi_sig_data *sig_data, *sig_data_next;
+   struct efi_signature_data *esd;
+   size_t left;
+
+   /*
+* UEFI specification defines certificate types:
+*   for non-signed images,
+*  EFI_CERT_SHA256_GUID
+*  EFI_CERT_RSA2048_GUID
+*  EFI_CERT_RSA2048_SHA256_GUID
+*  EFI_CERT_SHA1_GUID
+*  EFI_CERT_RSA2048_SHA_GUID
+*  EFI_CERT_SHA224_GUID
+*  EFI_CERT_SHA384_GUID
+*  EFI_CERT_SHA512_GUID
+*
+*   for signed images,
+*  EFI_CERT_X509_GUID
+*  NOTE: Each certificate will normally be in a separate
+*  EFI_SIGNATURE_LIST as the size may vary depending on
+*  its algo's.
+*
+*   for timestamp revocation of certificate,
+*  EFI_CERT_X509_SHA512_GUID
+*  EFI_CERT_X509_SHA256_GUID
+*  EFI_CERT_X509_SHA384_GUID
+*/
+
+   if (esl->signature_list_size
+   <= (sizeof(*esl) + esl->signature_header_size)) {
+   debug("Siglist in wrong format\n");
+   return NULL;
+   }
+
+   /* Create a head */
+   siglist = calloc(sizeof(*siglist), 1);
+   if (!siglist) {
+   debug("Out of memory\n");
+   goto err;
+   }
+   memcpy(>sig_type, >signature_type, sizeof(efi_guid_t));
+
+   /* Go through the list */
+   sig_data_next = NULL;
+   left = esl->signature_list_size
+   - (sizeof(*esl) + esl->signature_header_size);
+   esd = (struct efi_signature_data *)
+   ((u8 *)esl + sizeof(*esl) + esl->signature_header_size);
+
+   while ((left > 0) && left >= esl->signature_size) {
+   /* Signature must exist if there is remaining data. */
+   if (left < esl->signature_size) {
+   debug("Certificate is too small\n");
+   goto err;
+   }
+
+   sig_data = calloc(esl->signature_size
+   - sizeof(esd->signature_owner), 1);
+   if (!sig_data) {
+   debug("Out of memory\n");
+   goto err;
+   }
+
+   /* Append signature data */

[PATCH v6 00/16] efi_loader: add secure boot support

2020-02-25 Thread AKASHI Takahiro
# Documentation for UEFI secure boot on U-Boot will be submitted in
# a separate patch in near future.

One of major missing features in current UEFI implementation is "secure boot."
The ultimate goal of my attempt is to implement image authentication based
on signature and provide UEFI secure boot support which would be fully
compliant with UEFI specification, section 32[1].
(The code was originally developed by Patrick Wildt.)

This patch set requires one prerequisite[2]. For complete workable cod,
see my repository[3].

My "non-volatile" support[4], which is under discussion, is not mandatory
and so not included here, but this inevitably implies that, for example,
signature database variables, like db and dbx, won't be persistent unless
you explicitly run "env save" command.
Anyhow, Linaro is also working on implementing real "secure storage"
solution based on TF-A and OP-TEE.


Supported features:
* image authentication based on db and dbx
* supported signature types are
EFI_CERT_SHA256_GUID (SHA256 digest for unsigned images)
EFI_CERT_X509_GUID (x509 certificate for signed images)
* SecureBoot/SignatureSupport variables
* SetupMode and user mode
* variable authentication based on PK and KEK
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
* basic pytest test cases

Unsupported features: (marked as TODO in most cases in the source code,
and won't be included in this series)
* hash algorithms other than SHA256
* dbt: timestamp(RFC6131)-based certificate revocation
* dbr: OS recovery 
* xxxDefault: default values for signature stores
* transition to AuditMode and DeployedMode
* recording rejected images in EFI_IMAGE_EXECUTION_INFO_TABLE
* verification "policy", in particular, check against signature's owner
* private authenticated variables
* variable authentication with EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS
* real secure storage support, including hardware-specific PK (Platform Key)
  installation

TODO's other than "Unsupported features": (won't be included in this series)
* fail recovery, in particular, in modifying authenticated variables
* support read-only attributes of well-defined global variables
  in particular, "SignatureSupport"
* Extensive test suite (or more test cases) to confirm compatibility
  with EDK2
=> I requested EDK SCT community to add tests[5].

Test:
* My pytest, included in this patch set, passed.
* efi_selftest passed. (At least no regression.)
* Travis CI tests have passed.

Known issues:
* efitools is used in pytest, and its version must be v1.5.2 or later.
  (Solution: You can define EFITOOLS_PATH in defs.py for your own efitools.)


Hints about how to use:
(Please see other documents, or my pytest scripts, for details.)
* You can create your own certificates with openssl.
* You can sign your application with sbsign (on Ubuntu).
* You can create raw data for signature database with efitools, and
  install/manage authenticated variables with "env -set -e" command
  or efitools' "UpdateVars.efi" application.


[1] https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
[2] https://lists.denx.de/pipermail/u-boot/2020-January/398057.html
(extend rsa_verify() for UEFI secure boot)
[3] http://git.linaro.org/people/takahiro.akashi/u-boot.git/ efi/secboot
[4] https://lists.denx.de/pipermail/u-boot/2019-September/382835.html
(non-volatile variables support)
[5] https://bugzilla.tianocore.org/show_bug.cgi?id=2230


Changes in v6 (Feb 26, 2020)
* fix 'make htmldocs' warnings (patch#4,#7)
* refactor efi_load_pe() to avoid test_efi_fit.py error (patch#7)
* fix pytest warnings (patch#14)

Changes in v5 (Jan 28, 2020)
* rebased to pre-v2020.04-rc1 (fixed some merge conflicts)
* remove already-merged commits (v4's patch#1)
* fix a compile error caused by gcc 9.x (patch#4)
* return SECURITY_VIOLATION instead of ACCESS_DENIED if authentication fails
  (patch#7)
* use qsort() for section sorting (patch#7)
* add "efidebug test" sub-command (patch#11)
* add efi_start_image(SECURITY_VIOLATION) test (patch#14)

Changes in v4 (Dec 18, 2019)
* adjust EFI_SECURE_BOOT dependencies due to a change of RSA extension patch v5
  (patch#2)
* change "imply" to "select" against kconfig dependencies (patch#2)
* otherwise, no functional changes

Changes in v3 (Dec 9, 2019)
* allow for arbitrary number of regions in efi_image_region_add()
  (patch#3, #5 and #8)
* remove a redundant check in a while loop at efi_sigstore_free() (patch#4)

Changes in v2 (Nov 26, 2019)
* rebased to v2020.01-rc3
* rename IMAGE_DIRECTORY_ENTRY_CERTTABLE to IMAGE_DIRECTORY_ENTRY_SECURITY
  (patch#1,#9)
* add comments (patch#1)
* drop v1's patch#2 as it is no longer necessary
* drop v1's patch#3 as other "SECURE_BOOT" architectures have renamed
  this option and no longer use it
* add structure descriptions (patch#3)
* rework hash calculation code in efi_signature_verify() and remove
  an odd constant, WinIndrectSha256 (patch#3)
* move travis.yml changes to a 

[PATCH v6 01/16] efi_loader: add CONFIG_EFI_SECURE_BOOT config option

2020-02-25 Thread AKASHI Takahiro
Under this configuration, UEFI secure boot support will be added
in later patches.

Signed-off-by: AKASHI Takahiro 
---
 lib/efi_loader/Kconfig | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index a7afa3f29e88..4b09a07f1b0a 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -130,4 +130,22 @@ config EFI_RNG_PROTOCOL
  "Support for EFI_RNG_PROTOCOL implementation. Uses the rng
   device on the platform"
 
+config EFI_SECURE_BOOT
+   bool "Enable EFI secure boot support"
+   depends on EFI_LOADER
+   select SHA256
+   select RSA
+   select RSA_VERIFY_WITH_PKEY
+   select IMAGE_SIGN_INFO
+   select ASYMMETRIC_KEY_TYPE
+   select ASYMMETRIC_PUBLIC_KEY_SUBTYPE
+   select X509_CERTIFICATE_PARSER
+   select PKCS7_MESSAGE_PARSER
+   default n
+   help
+ Select this option to enable EFI secure boot support.
+ Once SecureBoot mode is enforced, any EFI binary can run only if
+ it is signed with a trusted key. To do that, you need to install,
+ at least, PK, KEK and db.
+
 endif
-- 
2.24.0



[PATCH v6 06/16] efi_loader: variable: add VendorKeys variable

2020-02-25 Thread AKASHI Takahiro
The following variable is exported as UEFI specification defines:
VendorKeys: whether the system is configured to use only vendor-provided
keys or not
The value will have to be modified if a platform has its own way of
initializing signature database, in particular, PK.

Signed-off-by: AKASHI Takahiro 
---
 lib/efi_loader/efi_variable.c | 69 ---
 1 file changed, 63 insertions(+), 6 deletions(-)

diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
index bf0ee486e4cf..3b6089e81be7 100644
--- a/lib/efi_loader/efi_variable.c
+++ b/lib/efi_loader/efi_variable.c
@@ -26,6 +26,7 @@ enum efi_secure_mode {
 const efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID;
 static bool efi_secure_boot;
 static int efi_secure_mode;
+static u8 efi_vendor_keys;
 
 #define READ_ONLY BIT(31)
 
@@ -344,6 +345,8 @@ static efi_status_t efi_transfer_secure_state(enum 
efi_secure_mode mode)
return EFI_INVALID_PARAMETER;
}
 
+   efi_secure_mode = mode;
+
return EFI_SUCCESS;
 
 err:
@@ -359,16 +362,46 @@ err:
  */
 static efi_status_t efi_init_secure_state(void)
 {
-   efi_uintn_t size = 0;
+   enum efi_secure_mode mode;
+   efi_uintn_t size;
efi_status_t ret;
 
+   /*
+* TODO:
+* Since there is currently no "platform-specific" installation
+* method of Platform Key, we can't say if VendorKeys is 0 or 1
+* precisely.
+*/
+
+   size = 0;
ret = EFI_CALL(efi_get_variable(L"PK", _global_variable_guid,
NULL, , NULL));
-   if (ret == EFI_BUFFER_TOO_SMALL && IS_ENABLED(CONFIG_EFI_SECURE_BOOT))
-   ret = efi_transfer_secure_state(EFI_MODE_USER);
-   else
-   ret = efi_transfer_secure_state(EFI_MODE_SETUP);
+   if (ret == EFI_BUFFER_TOO_SMALL) {
+   if (IS_ENABLED(CONFIG_EFI_SECURE_BOOT))
+   mode = EFI_MODE_USER;
+   else
+   mode = EFI_MODE_SETUP;
+
+   efi_vendor_keys = 0;
+   } else if (ret == EFI_NOT_FOUND) {
+   mode = EFI_MODE_SETUP;
+   efi_vendor_keys = 1;
+   } else {
+   goto err;
+   }
 
+   ret = efi_transfer_secure_state(mode);
+   if (ret == EFI_SUCCESS)
+   ret = efi_set_variable_internal(L"VendorKeys",
+   _global_variable_guid,
+   EFI_VARIABLE_BOOTSERVICE_ACCESS
+| EFI_VARIABLE_RUNTIME_ACCESS
+| READ_ONLY,
+   sizeof(efi_vendor_keys),
+   _vendor_keys,
+   false);
+
+err:
return ret;
 }
 
@@ -1124,6 +1157,8 @@ out:
if (env_set(native_name, val)) {
ret = EFI_DEVICE_ERROR;
} else {
+   bool vendor_keys_modified = false;
+
if ((u16_strcmp(variable_name, L"PK") == 0 &&
 guidcmp(vendor, _global_variable_guid) == 0)) {
ret = efi_transfer_secure_state(
@@ -1131,8 +1166,30 @@ out:
  EFI_MODE_USER));
if (ret != EFI_SUCCESS)
goto err;
+
+   if (efi_secure_mode != EFI_MODE_SETUP)
+   vendor_keys_modified = true;
+   } else if ((u16_strcmp(variable_name, L"KEK") == 0 &&
+guidcmp(vendor, _global_variable_guid) == 0)) {
+   if (efi_secure_mode != EFI_MODE_SETUP)
+   vendor_keys_modified = true;
+   }
+
+   /* update VendorKeys */
+   if (vendor_keys_modified & efi_vendor_keys) {
+   efi_vendor_keys = 0;
+   ret = efi_set_variable_internal(
+   L"VendorKeys",
+   _global_variable_guid,
+   EFI_VARIABLE_BOOTSERVICE_ACCESS
+| EFI_VARIABLE_RUNTIME_ACCESS
+| READ_ONLY,
+   sizeof(efi_vendor_keys),
+   _vendor_keys,
+   false);
+   } else {
+   ret = EFI_SUCCESS;
}
-   ret = EFI_SUCCESS;
}
 
 err:
-- 
2.24.0



[PATCH v6 02/16] efi_loader: add signature verification functions

2020-02-25 Thread AKASHI Takahiro
In this commit, implemented are a couple of helper functions which will be
used to materialize variable authentication as well as image authentication
in later patches.

Signed-off-by: AKASHI Takahiro 
---
 include/efi_api.h  |  87 +
 include/efi_loader.h   |  72 
 lib/efi_loader/Makefile|   1 +
 lib/efi_loader/efi_signature.c | 583 +
 4 files changed, 743 insertions(+)
 create mode 100644 lib/efi_loader/efi_signature.c

diff --git a/include/efi_api.h b/include/efi_api.h
index 22396172e15f..47f24fc90873 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -18,6 +18,7 @@
 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_EFI_LOADER
 #include 
@@ -307,6 +308,10 @@ struct efi_runtime_services {
EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, \
 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c)
 
+#define EFI_IMAGE_SECURITY_DATABASE_GUID \
+   EFI_GUID(0xd719b2cb, 0x3d3a, 0x4596, 0xa3, 0xbc, \
+0xda, 0xd0, 0x0e, 0x67, 0x65, 0x6f)
+
 #define EFI_FDT_GUID \
EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, \
 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0)
@@ -1616,4 +1621,86 @@ struct efi_unicode_collation_protocol {
 #define LOAD_OPTION_CATEGORY_BOOT  0x
 #define LOAD_OPTION_CATEGORY_APP   0x0100
 
+/* Certificate types in signature database */
+#define EFI_CERT_SHA256_GUID \
+   EFI_GUID(0xc1c41626, 0x504c, 0x4092, 0xac, 0xa9, \
+0x41, 0xf9, 0x36, 0x93, 0x43, 0x28)
+#define EFI_CERT_RSA2048_GUID \
+   EFI_GUID(0x3c5766e8, 0x269c, 0x4e34, 0xaa, 0x14, \
+0xed, 0x77, 0x6e, 0x85, 0xb3, 0xb6)
+#define EFI_CERT_X509_GUID \
+   EFI_GUID(0xa5c059a1, 0x94e4, 0x4aa7, 0x87, 0xb5, \
+0xab, 0x15, 0x5c, 0x2b, 0xf0, 0x72)
+#define EFI_CERT_X509_SHA256_GUID \
+   EFI_GUID(0x3bd2a492, 0x96c0, 0x4079, 0xb4, 0x20, \
+0xfc, 0xf9, 0x8e, 0xf1, 0x03, 0xed)
+#define EFI_CERT_TYPE_PKCS7_GUID \
+   EFI_GUID(0x4aafd29d, 0x68df, 0x49ee, 0x8a, 0xa9, \
+0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7)
+
+/**
+ * win_certificate_uefi_guid - A certificate that encapsulates
+ * a GUID-specific signature
+ *
+ * @hdr:   Windows certificate header
+ * @cert_type: Certificate type
+ * @cert_data: Certificate data
+ */
+struct win_certificate_uefi_guid {
+   WIN_CERTIFICATE hdr;
+   efi_guid_t  cert_type;
+   u8  cert_data[];
+} __attribute__((__packed__));
+
+/**
+ * efi_variable_authentication_2 - A time-based authentication method
+ * descriptor
+ *
+ * This structure describes an authentication information for
+ * a variable with EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
+ * and should be included as part of a variable's value.
+ * Only EFI_CERT_TYPE_PKCS7_GUID is accepted.
+ *
+ * @time_stamp:Descriptor's time stamp
+ * @auth_info: Authentication info
+ */
+struct efi_variable_authentication_2 {
+   struct efi_time  time_stamp;
+   struct win_certificate_uefi_guid auth_info;
+} __attribute__((__packed__));
+
+/**
+ * efi_signature_data - A format of signature
+ *
+ * This structure describes a single signature in signature database.
+ *
+ * @signature_owner:   Signature owner
+ * @signature_data:Signature data
+ */
+struct efi_signature_data {
+   efi_guid_t  signature_owner;
+   u8  signature_data[];
+} __attribute__((__packed__));
+
+/**
+ * efi_signature_list - A format of signature database
+ *
+ * This structure describes a list of signatures with the same type.
+ * An authenticated variable's value is a concatenation of one or more
+ * efi_signature_list's.
+ *
+ * @signature_type:Signature type
+ * @signature_list_size:   Size of signature list
+ * @signature_header_size: Size of signature header
+ * @signature_size:Size of signature
+ */
+struct efi_signature_list {
+   efi_guid_t  signature_type;
+   u32 signature_list_size;
+   u32 signature_header_size;
+   u32 signature_size;
+/* u8  signature_header[signature_header_size]; */
+/* struct efi_signature_data signatures[...][signature_size]; */
+} __attribute__((__packed__));
+
 #endif
diff --git a/include/efi_loader.h b/include/efi_loader.h
index d4c59b54c48b..5c8481e27920 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -26,6 +26,7 @@ static inline void *guidcpy(void *dst, const void *src)
 #if CONFIG_IS_ENABLED(EFI_LOADER)
 
 #include 
+#include 
 
 /* Maximum number of configuration tables */
 #define EFI_MAX_CONFIGURATION_TABLES 16
@@ -178,6 +179,11 @@ extern const efi_guid_t 
efi_guid_hii_config_routing_protocol;
 extern const efi_guid_t efi_guid_hii_config_access_protocol;
 extern const efi_guid_t efi_guid_hii_database_protocol;
 extern const efi_guid_t efi_guid_hii_string_protocol;
+/* GUIDs for authentication */
+extern const 

Re: [PATCH] arm: mvebu: update RTC values for PCIe memory wrappers

2020-02-25 Thread Baruch Siach
Hi Chris,

On Wed, Feb 26 2020, Chris Packham wrote:
> From: Chris Packham 
>
> Update the RTC (Read Timing Control) values for PCIe memory wrappers
> following an ERRATA (ERRATA# TDB). This means the PCIe accesses will
> used slower memory Read Timing, to allow more efficient energy
> consumption, in order to lower the minimum VDD of the memory.  Will lead
> to more robust memory when voltage drop occurs (VDDSEG)

Have you seen memory access reliability problems because of this issue?

> The code is based on changes from Marvell's U-Boot, specifically:
>
> https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/20cd2704072512de176e048970f2883db901674b
> https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/eb608a7c8dd0d42b87601a61b9c0cc5615ab94b2
> https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/c4af19ae2bf08cf6e450e741ce4f04d402a5cb6b
> https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/c4af19ae2bf08cf6e450e741ce4f04d402a5cb6b

The last link looks duplicated.

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


RE: [PATCH] ls1043a: Remove "fdt_high" environment variable

2020-02-25 Thread Priyanka Jain (OSS)
>-Original Message-
>From: U-Boot  On Behalf Of Tom Rini
>Sent: Tuesday, February 4, 2020 9:44 AM
>To: Wen He 
>Cc: u-boot@lists.denx.de; u-b...@linux.freescale.net
>Subject: Re: [PATCH] ls1043a: Remove "fdt_high" environment variable
>
>On Mon, Feb 03, 2020 at 05:32:27PM +0800, Wen He wrote:
>
>> Remove "fdt_high" environment variable to use the bootm_size(or set
>> CONFIG_SYS_BOOTMAPSZ) to amount of memory available to safely contain
>> a kernel, device tree and initrd for relocation.
>>
>> Signed-off-by: Wen He 
>> ---
>>  include/configs/ls1043a_common.h | 1 -
>>  1 file changed, 1 deletion(-)
>>
>> diff --git a/include/configs/ls1043a_common.h
>> b/include/configs/ls1043a_common.h
>> index 1670476..751117b 100644
>> --- a/include/configs/ls1043a_common.h
>> +++ b/include/configs/ls1043a_common.h
>> @@ -234,7 +234,6 @@
>>  /* Initial environment variables */
>>  #define CONFIG_EXTRA_ENV_SETTINGS   \
>>  "hwconfig=fsl_ddr:bank_intlv=auto\0"\
>> -"fdt_high=0x\0" \
>>  "initrd_high=0x\0"  \
>>  "fdt_addr=0x64f0\0" \
>>  "kernel_addr=0x6100\0"  \
>
>I don't see either bootm_size in context here nor CONFIG_SYS_BOOTMAPSZ,
>does this depend on some other patch?  Thanks!
>
>--
>Tom
Wen,
Kindly help to respond to Tom's query
Thanks
Priyanka


RE: [v4 1/4] Revert "ata: fsl_ahci: Add sata DM support for Freescale powerpc socs"

2020-02-25 Thread Priyanka Jain
>-Original Message-
>From: Peng Ma 
>Sent: Monday, December 23, 2019 2:58 PM
>To: s...@chromium.org; Priyanka Jain ; Marcel Ziswiler
>; Andy Tang 
>Cc: u-boot@lists.denx.de; Peng Ma 
>Subject: [v4 1/4] Revert "ata: fsl_ahci: Add sata DM support for Freescale
>powerpc socs"
>
>This reverts commit 1ee494291880fd51ef0c5f7342e072bdb069d7ff.
>
>Commit 1ee494291880 ("ata: fsl_ahci: Add sata DM support for Freescale
>powerpc socs") introduced SCSI layer to call AHCI private API in order to 
>support
>sata operations, In DM mode, This is not necessary for non-AHCI sata. So revert
>it and have already updated the driver itself to operate sata directly.
>
>Reviewed-by: Stefan Roese 
>Signed-off-by: Peng Ma 
>---
Series applied on u-boot-mpc85xx. Awaiting upstream.

Thanks
Priyanka


pull request of u-boot-fsl-mpc85xx

2020-02-25 Thread Priyanka Jain
Dear Tom,



Please find my pull-request for u-boot-mpc85xx/master

https://travis-ci.org/p-priyanka-jain/u-boot/builds/654734910



Summary

Update Sata node for T2080QDS and revert Sata related unrequired patches.



priyankajain

--
The following changes since commit 8e51bf746a11d7f67416859da73a83109af4e0a3:

  Merge tag 'u-boot-rockchip-20200220' of 
https://gitlab.denx.de/u-boot/custodians/u-boot-rockchip (2020-02-20 22:14:29 
-0500)

are available in the Git repository at:

  https://gitlab.denx.de/u-boot/custodians/u-boot-mpc85xx.git HEAD

for you to fetch changes up to ce92b89c4005d8c712e166fba98ea4207f1391e2:

  arch: powerpc: Rewrite the sata node to fit the driver (2020-02-25 10:16:05 
+0530)


Peng Ma (4):
  Revert "ata: fsl_ahci: Add sata DM support for Freescale powerpc socs"
  Revert "powerpc: mpc85xx: delete FSL_SATA for T2080QDS board."
  Revert "configs: enable sata device module in T2080QDS"
  arch: powerpc: Rewrite the sata node to fit the driver

arch/powerpc/cpu/mpc85xx/Kconfig  |4 +-
arch/powerpc/dts/t2080.dtsi   |   15 +-
configs/T2080QDS_NAND_defconfig   |4 -
configs/T2080QDS_SDCARD_defconfig |4 -
configs/T2080QDS_SECURE_BOOT_defconfig|4 +-
configs/T2080QDS_SPIFLASH_defconfig   |4 -
configs/T2080QDS_SRIO_PCIE_BOOT_defconfig |4 -
configs/T2080QDS_defconfig|4 -
drivers/ata/Kconfig   |   10 -
drivers/ata/Makefile  |1 -
drivers/ata/fsl_ahci.c| 1031 -
11 files changed, 8 insertions(+), 1077 deletions(-)
delete mode 100644 drivers/ata/fsl_ahci.c


[PATCH v2 1/1] include/ata.h: remove invalid links

2020-02-25 Thread Heinrich Schuchardt
Remove invalid URLs for "Information Technology - AT Attachment-3 Interface
(ATA-3)", point to ANSI X3.298-1997.

Signed-off-by: Heinrich Schuchardt 
---
v2:
refer to the ANSI standard
---
 include/ata.h | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/include/ata.h b/include/ata.h
index 3f4e4a0234..d8a0275630 100644
--- a/include/ata.h
+++ b/include/ata.h
@@ -6,11 +6,8 @@

 /*
  * Most of the following information was derived from the document
- * "Information Technology - AT Attachment-3 Interface (ATA-3)"
- * which can be found at:
- * http://www.dt.wdc.com/ata/ata-3/ata3r5v.zip
- * ftp://poctok.iae.nsk.su/pub/asm/Documents/IDE/ATA3R5V.ZIP
- * ftp://ftp.fee.vutbr.cz/pub/doc/io/ata/ata-3/ata3r5v.zip
+ * "Information Technology - AT Attachment-3 Interface (ATA-3)",
+ * ANSI X3.298-1997.
  */

 #ifndef_ATA_H
--
2.25.0



Re: [PATCH 1/1] include/ata.h: remove invalid links

2020-02-25 Thread Tom Rini
On Wed, Feb 26, 2020 at 04:57:51AM +0100, Heinrich Schuchardt wrote:
> On 2/25/20 10:30 PM, Tom Rini wrote:
> > On Tue, Feb 25, 2020 at 10:04:53PM +0100, Heinrich Schuchardt wrote:
> > 
> > > Remove invalid URLs for "Information Technology - AT Attachment-3 
> > > Interface
> > > (ATA-3)".
> > > 
> > > Signed-off-by: Heinrich Schuchardt 
> > > ---
> > >   include/ata.h | 4 
> > >   1 file changed, 4 deletions(-)
> > > 
> > > diff --git a/include/ata.h b/include/ata.h
> > > index 3f4e4a0234..aecb9cd589 100644
> > > --- a/include/ata.h
> > > +++ b/include/ata.h
> > > @@ -7,10 +7,6 @@
> > >   /*
> > >* Most of the following information was derived from the document
> > >* "Information Technology - AT Attachment-3 Interface (ATA-3)"
> > > - * which can be found at:
> > > - * http://www.dt.wdc.com/ata/ata-3/ata3r5v.zip
> > > - * ftp://poctok.iae.nsk.su/pub/asm/Documents/IDE/ATA3R5V.ZIP
> > > - * ftp://ftp.fee.vutbr.cz/pub/doc/io/ata/ata-3/ata3r5v.zip
> > >*/
> > > 
> > >   #ifndef _ATA_H
> > 
> > In this case, it looks like some of the relevant information about the
> > spec, "Revision 5v" is encoded in the URL.  I can't find a new link for
> > it, but we should keep that information in the comment.  Thanks!
> > 
> 
> Hello Tom,
> 
> revision 5v is an early draft of ANSI X3.298-1997. On Jan 27th, 1997
> there was a draft 7b. Google finds it when you look for 'ata-3-std.pdf
> site:github.com'.
> 
> The final standard ANSI X3.298-1997 is for sale here:
> https://webstore.ansi.org/standards/incits/ansix32981997

Yes.

> So I think we should simply point to the standard.

I think we need to note what revision of the standard we wrote to, for
future "hey, wait, there's a corner case we get wrong because we coded
to an old draft" issues.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/1] include/ata.h: remove invalid links

2020-02-25 Thread Heinrich Schuchardt

On 2/25/20 10:30 PM, Tom Rini wrote:

On Tue, Feb 25, 2020 at 10:04:53PM +0100, Heinrich Schuchardt wrote:


Remove invalid URLs for "Information Technology - AT Attachment-3 Interface
(ATA-3)".

Signed-off-by: Heinrich Schuchardt 
---
  include/ata.h | 4 
  1 file changed, 4 deletions(-)

diff --git a/include/ata.h b/include/ata.h
index 3f4e4a0234..aecb9cd589 100644
--- a/include/ata.h
+++ b/include/ata.h
@@ -7,10 +7,6 @@
  /*
   * Most of the following information was derived from the document
   * "Information Technology - AT Attachment-3 Interface (ATA-3)"
- * which can be found at:
- * http://www.dt.wdc.com/ata/ata-3/ata3r5v.zip
- * ftp://poctok.iae.nsk.su/pub/asm/Documents/IDE/ATA3R5V.ZIP
- * ftp://ftp.fee.vutbr.cz/pub/doc/io/ata/ata-3/ata3r5v.zip
   */

  #ifndef   _ATA_H


In this case, it looks like some of the relevant information about the
spec, "Revision 5v" is encoded in the URL.  I can't find a new link for
it, but we should keep that information in the comment.  Thanks!



Hello Tom,

revision 5v is an early draft of ANSI X3.298-1997. On Jan 27th, 1997
there was a draft 7b. Google finds it when you look for 'ata-3-std.pdf
site:github.com'.

The final standard ANSI X3.298-1997 is for sale here:
https://webstore.ansi.org/standards/incits/ansix32981997

So I think we should simply point to the standard.

Best regards

Heinrich


Re: [PATCH 7/7] kconfig / kbuild: re-sync with Linux 4.18

2020-02-25 Thread Tom Rini
On Wed, Feb 26, 2020 at 10:04:10AM +0900, Masahiro Yamada wrote:
> Hi Tom,
> 
> On Tue, Feb 25, 2020 at 3:05 AM Tom Rini  wrote:
> >
> > Align Kconfig and Kbuild logic to Linux 4.18 release with minimal impact
> > on files outside of this scope.
> >
> > Our previous Kconfig sync was done by commit e91610da7c8a ("kconfig:
> > re-sync with Linux 4.17-rc4").
> >
> > A very small number of changes upstream since our sync with v4.17-rc4
> > that exist in the v4.18 release have already been applied here and have
> > been omitted from the list in this commit (and are readily available in
> > our own git history).
> >
> > The imported Linux commits are:
> > b3aa58d2e85d fixdep: suppress consecutive / from file paths in dependency 
> > list files
> > 74656b682902 kbuild: disable new dtc graph and unit-address warnings
> > 74d931716151 genksyms: remove symbol prefix support
> > e6ecfb45072c kbuild: do not display CHK for filechk
> > 0b669a5076fd kconfig: refactor Qt package checks for building qconf
> > b464ef583dc7 kconfig: refactor GTK+ package checks for building gconf
> > 1c5af5cf9308 kconfig: refactor ncurses package checks for building mconf 
> > and nconf
> > 694c49a7c01c kconfig: drop localization support
> > 96f60dfa5819 trace: Use -mcount-record for dynamic ftrace
> > bb222ceeb327 kconfig: remove string expansion in file_lookup()
> > 96d8e48da55a kconfig: remove string expansion for mainmenu after yyparse()
> > 5b31a9746756 kconfig: remove sym_expand_string_value()
> > 137c0118a900 kconfig: make default prompt of mainmenu less specific
> > e298f3b49def kconfig: add built-in function support
> > 2fd5b09c201e kconfig: add 'shell' built-in function
> > 9de071536c87 kconfig: begin PARAM state only when seeing a command keyword
> > 9ced3bddec08 kconfig: support user-defined function and recursively 
> > expanded variable
> > 1175c02506ff kconfig: support simply expanded variable
> > ed2a22f277c6 kconfig: support append assignment operator
> > 82bc8bd82e5c kconfig: expand lefthand side of assignment statement
> > 1d6272e6fe43 kconfig: add 'info', 'warning-if', and 'error-if' built-in 
> > functions
> > a702a6176e2f kconfig: add 'filename' and 'lineno' built-in variables
> > 915f64901eb3 kconfig: error out if a recursive variable references itself
> > 2bece88f89fa kconfig: test: add Kconfig macro language tests
> > 21c54b774744 kconfig: show compiler version text in the top comment
> > 59f7b5847b0c kbuild: $(CHECK) doesnt need NOSTDINC_FLAGS twice
> > 145167650b96 kbuild: add endianness flag to CHEKCFLAGS
> > 1f2f01b122d7 kbuild: add machine size to CHECKFLAGS
> > d6a0c8a1326b kconfig: Add testconfig into make help output
> > bb6d83dde191 kbuild: Move last word of nconfig help to the previous line
> > 8593080c0fcf kconfig: fix localmodconfig
> > ed7d40bc67b8 tracing: Fix SKIP_STACK_VALIDATION=1 build due to bad merge 
> > with -mrecord-mcount
> > b2d00d7c61c8 kconfig: fix line numbers for if-entries in menu tree
> > ecd53ac2f2c6 kconfig: handle P_SYMBOL in print_symbol()
> > 73d1c580f92b kconfig: loop boundary condition fix
> > 48f6e3cf5bc6 kbuild: do not drop -I without parameter
> 
> 
> This is what I noted in another patch.
> 
> 48f6e3cf5bc6  depends on db547ef1906,
> which you silently, partially imported.

Thanks for catching that, I'll fix things up and drop some of the
changes.

> BTW, you can delete unused 'cc-option-align' if you like.
> (39a33ff80a259b2bddebb236549baee55f9b4f41)

Interesting, that's v4.12-rc2-..., I'll poke around and see if there's
anything else that got missed too.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 5/7] Azure / GitLab / Travis: Add Kconfig unit tests to a job

2020-02-25 Thread Masahiro Yamada
On Tue, Feb 25, 2020 at 3:06 AM Tom Rini  wrote:
>
> The Kconfig language provides a unit test that can be run.  As these
> require pytest to be installed and run very quickly, bundle them in to
> an existing CI job.
>
> Signed-off-by: Tom Rini 


Reviewed-by: Masahiro Yamada 


> ---
>  .azure-pipelines.yml | 5 +++--
>  .gitlab-ci.yml   | 7 ---
>  .travis.yml  | 3 ++-
>  3 files changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
> index c22095830c0c..89aa5e46e298 100644
> --- a/.azure-pipelines.yml
> +++ b/.azure-pipelines.yml
> @@ -110,7 +110,7 @@ jobs:
>make tools-only_config envtools -j$(nproc)
>
>- job: utils
> -displayName: 'Run binman, buildman, dtoc and patman testsuites'
> +displayName: 'Run binman, buildman, dtoc, Kconfig and patman testsuites'
>  pool:
>vmImage: $(ubuntu_vm)
>  steps:
> @@ -125,7 +125,7 @@ jobs:
>export USER=azure
>virtualenv -p /usr/bin/python3 /tmp/venv
>. /tmp/venv/bin/activate
> -  pip install pyelftools
> +  pip install pyelftools pytest
>export UBOOT_TRAVIS_BUILD_DIR=/tmp/.bm-work/sandbox_spl
>export PYTHONPATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt
>export PATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}
> @@ -134,6 +134,7 @@ jobs:
>./tools/buildman/buildman -t
>./tools/dtoc/dtoc -t
>./tools/patman/patman --test
> +  make testconfig
>EOF
>cat build.sh
># We cannot use "container" like other jobs above, as buildman
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index d486e72042fb..87231a039b48 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -150,7 +150,7 @@ Build envtools:
>script:
>  - make tools-only_config envtools -j$(nproc)
>
> -Run binman, buildman, dtoc and patman testsuites:
> +Run binman, buildman, dtoc, Kconfig and patman testsuites:
>tags: [ 'all' ]
>stage: testsuites
>script:
> @@ -159,7 +159,7 @@ Run binman, buildman, dtoc and patman testsuites:
>export USER=gitlab;
>virtualenv -p /usr/bin/python3 /tmp/venv;
>. /tmp/venv/bin/activate;
> -  pip install pyelftools;
> +  pip install pyelftools pytest;
>export UBOOT_TRAVIS_BUILD_DIR=/tmp/.bm-work/sandbox_spl;
>export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt";
>export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}";
> @@ -167,7 +167,8 @@ Run binman, buildman, dtoc and patman testsuites:
>./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test;
>./tools/buildman/buildman -t;
>./tools/dtoc/dtoc -t;
> -  ./tools/patman/patman --test
> +  ./tools/patman/patman --test;
> +  make testconfig
>
>  # Test sandbox with test.py
>  sandbox test.py:
> diff --git a/.travis.yml b/.travis.yml
> index e6db9d6a721a..53e4c2c12671 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -150,7 +150,8 @@ script:
> ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test 
> &&
> ./tools/patman/patman --test &&
> ./tools/buildman/buildman -t &&
> -   ./tools/dtoc/dtoc -t;
> +   ./tools/dtoc/dtoc -t &&
> +   make testconfig;
>   fi;
> fi
>
> --
> 2.17.1
>


-- 
Best Regards
Masahiro Yamada


Re: [PATCH 4/7] Kconfig: Remove redundant variable sets

2020-02-25 Thread Masahiro Yamada
On Tue, Feb 25, 2020 at 3:06 AM Tom Rini  wrote:
>
> In a few places we have Kconfig entries that set SPL_LDSCRIPT to what is
> the default value anyways.  Drop these.
>
> Cc: Michal Simek 
> Cc: Rick Chen 
> Cc: Philippe Reynes 
> Cc: Eric Jarrige 
> Signed-off-by: Tom Rini 
> ---

I see more in defconfig files.

$ cd configs
$ git grep SPL_LDSCRIPT
axm_defconfig:CONFIG_SPL_LDSCRIPT="arch/$(ARCH)/cpu/u-boot-spl.lds"
brppt2_defconfig:CONFIG_SPL_LDSCRIPT="arch/$(ARCH)/cpu/u-boot-spl.lds"
mx31pdk_defconfig:CONFIG_SPL_LDSCRIPT="arch/arm/cpu/u-boot-spl.lds"
taurus_defconfig:CONFIG_SPL_LDSCRIPT="arch/$(ARCH)/cpu/u-boot-spl.lds"


They are the same as the default.

Can you remove them too?



>  arch/microblaze/Kconfig  | 3 ---
>  arch/riscv/Kconfig   | 3 ---
>  board/armadeus/apf27/Kconfig | 3 ---
>  3 files changed, 9 deletions(-)
>
> diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
> index 5ce8261451d3..2bd260e5d76e 100644
> --- a/arch/microblaze/Kconfig
> +++ b/arch/microblaze/Kconfig
> @@ -30,7 +30,4 @@ config STACK_SIZE
>
>  source "board/xilinx/microblaze-generic/Kconfig"
>
> -config SPL_LDSCRIPT
> -   default "arch/microblaze/cpu/u-boot-spl.lds"
> -
>  endmenu
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 3338b788f84a..f49618d24d26 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -229,7 +229,4 @@ config STACK_SIZE_SHIFT
> int
> default 14
>
> -config SPL_LDSCRIPT
> -   default "arch/riscv/cpu/u-boot-spl.lds"
> -
>  endmenu
> diff --git a/board/armadeus/apf27/Kconfig b/board/armadeus/apf27/Kconfig
> index a342d2e05ec5..65544a844834 100644
> --- a/board/armadeus/apf27/Kconfig
> +++ b/board/armadeus/apf27/Kconfig
> @@ -1,8 +1,5 @@
>  if TARGET_APF27
>
> -config SPL_LDSCRIPT
> -   default "arch/$(ARCH)/cpu/u-boot-spl.lds"
> -
>  config SYS_BOARD
> default "apf27"
>
> --
> 2.17.1
>


-- 
Best Regards
Masahiro Yamada


Re: [PATCH 3/7] Kconfig: Escape variables to make in default strings

2020-02-25 Thread Masahiro Yamada
On Tue, Feb 25, 2020 at 3:05 AM Tom Rini  wrote:
>
> We have some variables that need to include a variable to pass to make
> to evaluate later, typically ARCH and BOARDDIR, to find a file to use.
> The way we're doing this today isn't correct but works.  With an update
> to Kconfig we will need to escape these properly, so do so.
>
> Cc: Masahiro Yamada 
> Signed-off-by: Tom Rini 
> ---
>  arch/arm/mach-davinci/Kconfig | 2 +-
>  arch/arm/mach-orion5x/Kconfig | 2 +-
>  common/spl/Kconfig| 4 ++--
>  3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
> index 8a81c078811d..83f749c0440a 100644
> --- a/arch/arm/mach-davinci/Kconfig
> +++ b/arch/arm/mach-davinci/Kconfig
> @@ -135,6 +135,6 @@ source "board/davinci/da8xxevm/Kconfig"
>  source "board/lego/ev3/Kconfig"
>
>  config SPL_LDSCRIPT
> -   default "board/$(BOARDDIR)/u-boot-spl-da850evm.lds"
> +   default "board/\$(BOARDDIR)/u-boot-spl-da850evm.lds"


Only one file path for this.

$ find  . -name  u-boot-spl-da850evm.lds
./board/davinci/da8xxevm/u-boot-spl-da850evm.lds


I prefer hard-coding.

default "board/davinci/da8xxevm/u-boot-spl-da850evm.lds"





>  endif
> diff --git a/arch/arm/mach-orion5x/Kconfig b/arch/arm/mach-orion5x/Kconfig
> index 2984a3edda21..c4bc524eb81e 100644
> --- a/arch/arm/mach-orion5x/Kconfig
> +++ b/arch/arm/mach-orion5x/Kconfig
> @@ -16,6 +16,6 @@ config SYS_SOC
>  source "board/LaCie/edminiv2/Kconfig"
>
>  config SPL_LDSCRIPT
> -   default "$(CPUDIR)/orion5x/u-boot-spl.lds" if ORION5X
> +   default "\$(CPUDIR)/orion5x/u-boot-spl.lds" if ORION5X

Ditto.

We know the directory path of orion5x.

$ find  . -name orion5x
./arch/arm/cpu/arm926ejs/orion5x

You can hard-code it.



>  endif
> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> index b03a476b9f69..9d52b75cb434 100644
> --- a/common/spl/Kconfig
> +++ b/common/spl/Kconfig
> @@ -139,7 +139,7 @@ config SPL_HANDOFF
>
>  config SPL_LDSCRIPT
> string "Linker script for the SPL stage"
> -   default "arch/$(ARCH)/cpu/u-boot-spl.lds"
> +   default "arch/\$(ARCH)/cpu/u-boot-spl.lds"
> help
>   The SPL stage will usually require a different linker-script
>   (as it runs from a different memory region) than the regular
> @@ -1306,7 +1306,7 @@ config TPL_LDSCRIPT
>  string "Linker script for the TPL stage"
> depends on TPL
> default "arch/arm/cpu/armv8/u-boot-spl.lds" if ARM64
> -   default "arch/$(ARCH)/cpu/u-boot-spl.lds"
> +   default "arch/\$(ARCH)/cpu/u-boot-spl.lds"
> help
>   The TPL stage will usually require a different linker-script
>   (as it runs from a different memory region) than the regular
> --
> 2.17.1
>


-- 
Best Regards
Masahiro Yamada


Re: [PATCH 7/7] kconfig / kbuild: re-sync with Linux 4.18

2020-02-25 Thread Masahiro Yamada
Hi Tom,

On Tue, Feb 25, 2020 at 3:05 AM Tom Rini  wrote:
>
> Align Kconfig and Kbuild logic to Linux 4.18 release with minimal impact
> on files outside of this scope.
>
> Our previous Kconfig sync was done by commit e91610da7c8a ("kconfig:
> re-sync with Linux 4.17-rc4").
>
> A very small number of changes upstream since our sync with v4.17-rc4
> that exist in the v4.18 release have already been applied here and have
> been omitted from the list in this commit (and are readily available in
> our own git history).
>
> The imported Linux commits are:
> b3aa58d2e85d fixdep: suppress consecutive / from file paths in dependency 
> list files
> 74656b682902 kbuild: disable new dtc graph and unit-address warnings
> 74d931716151 genksyms: remove symbol prefix support
> e6ecfb45072c kbuild: do not display CHK for filechk
> 0b669a5076fd kconfig: refactor Qt package checks for building qconf
> b464ef583dc7 kconfig: refactor GTK+ package checks for building gconf
> 1c5af5cf9308 kconfig: refactor ncurses package checks for building mconf and 
> nconf
> 694c49a7c01c kconfig: drop localization support
> 96f60dfa5819 trace: Use -mcount-record for dynamic ftrace
> bb222ceeb327 kconfig: remove string expansion in file_lookup()
> 96d8e48da55a kconfig: remove string expansion for mainmenu after yyparse()
> 5b31a9746756 kconfig: remove sym_expand_string_value()
> 137c0118a900 kconfig: make default prompt of mainmenu less specific
> e298f3b49def kconfig: add built-in function support
> 2fd5b09c201e kconfig: add 'shell' built-in function
> 9de071536c87 kconfig: begin PARAM state only when seeing a command keyword
> 9ced3bddec08 kconfig: support user-defined function and recursively expanded 
> variable
> 1175c02506ff kconfig: support simply expanded variable
> ed2a22f277c6 kconfig: support append assignment operator
> 82bc8bd82e5c kconfig: expand lefthand side of assignment statement
> 1d6272e6fe43 kconfig: add 'info', 'warning-if', and 'error-if' built-in 
> functions
> a702a6176e2f kconfig: add 'filename' and 'lineno' built-in variables
> 915f64901eb3 kconfig: error out if a recursive variable references itself
> 2bece88f89fa kconfig: test: add Kconfig macro language tests
> 21c54b774744 kconfig: show compiler version text in the top comment
> 59f7b5847b0c kbuild: $(CHECK) doesnt need NOSTDINC_FLAGS twice
> 145167650b96 kbuild: add endianness flag to CHEKCFLAGS
> 1f2f01b122d7 kbuild: add machine size to CHECKFLAGS
> d6a0c8a1326b kconfig: Add testconfig into make help output
> bb6d83dde191 kbuild: Move last word of nconfig help to the previous line
> 8593080c0fcf kconfig: fix localmodconfig
> ed7d40bc67b8 tracing: Fix SKIP_STACK_VALIDATION=1 build due to bad merge with 
> -mrecord-mcount
> b2d00d7c61c8 kconfig: fix line numbers for if-entries in menu tree
> ecd53ac2f2c6 kconfig: handle P_SYMBOL in print_symbol()
> 73d1c580f92b kconfig: loop boundary condition fix
> 48f6e3cf5bc6 kbuild: do not drop -I without parameter


This is what I noted in another patch.

48f6e3cf5bc6  depends on db547ef1906,
which you silently, partially imported.

That is why you ended up with -I$(objtee)/$(obj) everywhere.



BTW, you can delete unused 'cc-option-align' if you like.
(39a33ff80a259b2bddebb236549baee55f9b4f41)

This is a low-hanging fruit.


-- 
Best Regards
Masahiro Yamada


Re: [PATCH] efi_selftest: Ensure we include the object directory for generated headers

2020-02-25 Thread Masahiro Yamada
Hi Tom,


On Sat, Feb 22, 2020 at 6:52 AM Tom Rini  wrote:
>
> On Fri, Feb 21, 2020 at 10:34:01PM +0100, Heinrich Schuchardt wrote:
> > On 2/21/20 9:48 PM, Tom Rini wrote:
> > > The current rules for generating -I lines for objects gives us both
> > > -I/full/src/path/lib/efi_selftest and -Ilib/efi_selftest.  However, if
> > > we re-sync the Kbuild logic we no longer get the latter implicitly.  We
> > > will need to be explicit in such cases, so do so.
> > >
> > > Cc: Heinrich Schuchardt 
> > > Cc: Masahiro Yamada 
> > > Signed-off-by: Tom Rini 
> >
> > Hello Tom,
> >
> > yes, in lib/efi_selftest we have generated includes, so
> > -Ilib/efi_selftest is relevant.
> >
> > Do you have a git branch with the Kconfig changes for reference and testing?
>
> Currently WIP/kbuild-resync-v1-v4.18 but please bear in mind I'm (a)
> rebase it and (b) it doesn't even build sandbox_spl right now (more of
> this type of error, but my non-CI world build will finish up shortly and
> I'll grab all of the places I need to make a fix like this there).
>
> --
> Tom


This is one way to suppress the build error for O= builds.

But, please notice this is caused by the re-sync mistake.


You partially imported
commit db547ef1906400eb34682e43035dd4d81b9fdcfb
from Linux.

You imported the change in scripts/Kbuild.include
but did not the change in scripts/Makefile.lib

That's why you needed to add -I$(objtree)/$(obj)
all over the places.





-- 
Best Regards
Masahiro Yamada


Re: [PATCH v5 04/16] efi_loader: variable: support variable authentication

2020-02-25 Thread AKASHI Takahiro
On Tue, Feb 25, 2020 at 07:46:44AM +0100, Heinrich Schuchardt wrote:
> On 1/28/20 9:25 AM, AKASHI Takahiro wrote:
> > With this commit, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
> > is supported for authenticated variables and the system secure state
> > will transfer between setup mode and user mode as UEFI specification
> > section 32.3 describes.
> > 
> > Internally, authentication data is stored as part of authenticated
> > variable's value. It is nothing but a pkcs7 message (but we need some
> > wrapper, see efi_variable_parse_signature()) and will be validated by
> > efi_variable_authenticate(), hence efi_signature_verify_with_db().
> > 
> > Associated time value will be encoded in "{...,time=...}" along with
> > other UEFI variable's attributes.
> > 
> > Signed-off-by: AKASHI Takahiro 
> > ---
> >   include/efi_loader.h  |   3 +
> >   lib/efi_loader/efi_variable.c | 665 --
> >   2 files changed, 564 insertions(+), 104 deletions(-)
> > 
> > diff --git a/include/efi_loader.h b/include/efi_loader.h
> > index 34f7b8eec8cd..f461c6195834 100644
> > --- a/include/efi_loader.h
> > +++ b/include/efi_loader.h
> > @@ -184,6 +184,7 @@ extern const efi_guid_t 
> > efi_guid_image_security_database;
> >   extern const efi_guid_t efi_guid_sha256;
> >   extern const efi_guid_t efi_guid_cert_x509;
> >   extern const efi_guid_t efi_guid_cert_x509_sha256;
> > +extern const efi_guid_t efi_guid_cert_type_pkcs7;
> > 
> >   /* GUID of RNG protocol */
> >   extern const efi_guid_t efi_guid_rng_protocol;
> > @@ -738,6 +739,8 @@ efi_status_t efi_image_region_add(struct 
> > efi_image_regions *regs,
> > 
> >   void efi_sigstore_free(struct efi_signature_store *sigstore);
> >   struct efi_signature_store *efi_sigstore_parse_sigdb(u16 *name);
> > +
> > +bool efi_secure_boot_enabled(void);
> >   #endif /* CONFIG_EFI_SECURE_BOOT */
> > 
> >   #else /* CONFIG_IS_ENABLED(EFI_LOADER) */
> > diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
> > index c316bdfec0e4..2ae8222b1a94 100644
> > --- a/lib/efi_loader/efi_variable.c
> > +++ b/lib/efi_loader/efi_variable.c
> > @@ -10,8 +10,14 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> >   #include 
> > +#include 
> >   #include 
> > +#include "../lib/crypto/pkcs7_parser.h"
> > +
> > +const efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID;
> > +static bool efi_secure_boot;
> > 
> >   #define READ_ONLY BIT(31)
> > 
> > @@ -108,7 +114,7 @@ static const char *prefix(const char *str, const char 
> > *prefix)
> >* @attrp:pointer to UEFI attributes
> >* Return:pointer to remainder of U-Boot variable value
> >*/
> > -static const char *parse_attr(const char *str, u32 *attrp)
> > +static const char *parse_attr(const char *str, u32 *attrp, u64 *timep)
> 
> ./lib/efi_loader/efi_variable.c:128: warning: Function parameter or
> member 'timep' not described in 'parse_attr'
> 
> All 'make htmldocs' warnings will be treated as errors after upcoming
> Travis CI changes.

Okay, I fixed all of them.

Thanks,
-Takahiro Akashi


> Best regards
> 
> Heinrich
> 
> >   {
> > u32 attr = 0;
> > char sep = '{';
> > @@ -131,6 +137,12 @@ static const char *parse_attr(const char *str, u32 
> > *attrp)
> > attr |= EFI_VARIABLE_BOOTSERVICE_ACCESS;
> > } else if ((s = prefix(str, "run"))) {
> > attr |= EFI_VARIABLE_RUNTIME_ACCESS;
> > +   } else if ((s = prefix(str, "time="))) {
> > +   attr |= 
> > EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
> > +   hex2bin((u8 *)timep, s, sizeof(*timep));
> > +   s += sizeof(*timep) * 2;
> > +   } else if (*str == '}') {
> > +   break;
> > } else {
> > printf("invalid attribute: %s\n", str);
> > break;
> > @@ -148,48 +160,291 @@ static const char *parse_attr(const char *str, u32 
> > *attrp)
> >   }
> > 
> >   /**
> > - * efi_get_variable() - retrieve value of a UEFI variable
> > + * efi_secure_boot_enabled - return if secure boot is enabled or not
> >*
> > - * This function implements the GetVariable runtime service.
> > + * Return: true if enabled, false if disabled
> > + */
> > +bool efi_secure_boot_enabled(void)
> > +{
> > +   return efi_secure_boot;
> > +}
> > +
> > +#ifdef CONFIG_EFI_SECURE_BOOT
> > +static u8 pkcs7_hdr[] = {
> > +   /* SEQUENCE */
> > +   0x30, 0x82, 0x05, 0xc7,
> > +   /* OID: pkcs7-signedData */
> > +   0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02,
> > +   /* Context Structured? */
> > +   0xa0, 0x82, 0x05, 0xb8,
> > +};
> > +
> > +/**
> > + * efi_variable_parse_signature - parse a signature in variable
> > + * @buf:   Pointer to variable's value
> > + * @buflen:Length of @buf
> >*
> > - * See the Unified Extensible Firmware Interface (UEFI) specification for
> > - * details.
> > + * Parse a 

Re: [PATCH v5 07/16] efi_loader: image_loader: support image authentication

2020-02-25 Thread AKASHI Takahiro
On Tue, Feb 25, 2020 at 07:44:10AM +0100, Heinrich Schuchardt wrote:
> On 1/28/20 9:25 AM, AKASHI Takahiro wrote:
> > With this commit, image validation can be enforced, as UEFI specification
> > section 32.5 describes, if CONFIG_EFI_SECURE_BOOT is enabled.
> > 
> > Currently we support
> > * authentication based on db and dbx,
> >so dbx-validated image will always be rejected.
> > * following signature types:
> >  EFI_CERT_SHA256_GUID (SHA256 digest for unsigned images)
> >  EFI_CERT_X509_GUID (x509 certificate for signed images)
> > Timestamp-based certificate revocation is not supported here.
> > 
> > Internally, authentication data is stored in one of certificates tables
> > of PE image (See efi_image_parse()) and will be verified by
> > efi_image_authenticate() before loading a given image.
> > 
> > It seems that UEFI specification defines the verification process
> > in a bit ambiguous way. I tried to implement it as closely to as
> > EDK2 does.
> > 
> > Signed-off-by: AKASHI Takahiro 
> > ---
> >   include/efi_loader.h  |  13 +-
> >   lib/efi_loader/efi_boottime.c |  10 +-
> >   lib/efi_loader/efi_image_loader.c | 460 +-
> >   3 files changed, 467 insertions(+), 16 deletions(-)
> > 
> > diff --git a/include/efi_loader.h b/include/efi_loader.h
> > index f461c6195834..0e15470d9c17 100644
> > --- a/include/efi_loader.h
> > +++ b/include/efi_loader.h
> > @@ -11,6 +11,7 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> > 
> >   static inline int guidcmp(const void *g1, const void *g2)
> >   {
> > @@ -263,6 +264,11 @@ struct efi_object {
> > enum efi_object_type type;
> >   };
> > 
> > +enum efi_image_auth_status {
> > +   EFI_IMAGE_AUTH_FAILED = 0,
> > +   EFI_IMAGE_AUTH_PASSED,
> > +};
> > +
> >   /**
> >* struct efi_loaded_image_obj - handle of a loaded image
> >*
> > @@ -282,6 +288,7 @@ struct efi_loaded_image_obj {
> > EFIAPI efi_status_t (*entry)(efi_handle_t image_handle,
> >  struct efi_system_table *st);
> > u16 image_type;
> > +   enum efi_image_auth_status auth_status;
> >   };
> > 
> >   /**
> > @@ -414,7 +421,8 @@ efi_status_t efi_set_watchdog(unsigned long timeout);
> >   /* Called from places to check whether a timer expired */
> >   void efi_timer_check(void);
> >   /* PE loader implementation */
> > -efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle, void *efi,
> > +efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
> > +void *efi, size_t efi_size,
> >  struct efi_loaded_image *loaded_image_info);
> >   /* Called once to store the pristine gd pointer */
> >   void efi_save_gd(void);
> > @@ -741,6 +749,9 @@ void efi_sigstore_free(struct efi_signature_store 
> > *sigstore);
> >   struct efi_signature_store *efi_sigstore_parse_sigdb(u16 *name);
> > 
> >   bool efi_secure_boot_enabled(void);
> > +
> > +bool efi_image_parse(void *efi, size_t len, struct efi_image_regions 
> > **regp,
> > +WIN_CERTIFICATE **auth, size_t *auth_len);
> >   #endif /* CONFIG_EFI_SECURE_BOOT */
> > 
> >   #else /* CONFIG_IS_ENABLED(EFI_LOADER) */
> > diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> > index 1f598b357a5c..cc8cc4cb5408 100644
> > --- a/lib/efi_loader/efi_boottime.c
> > +++ b/lib/efi_loader/efi_boottime.c
> > @@ -1882,12 +1882,12 @@ efi_status_t EFIAPI efi_load_image(bool boot_policy,
> > efi_dp_split_file_path(file_path, , );
> > ret = efi_setup_loaded_image(dp, fp, image_obj, );
> > if (ret == EFI_SUCCESS)
> > -   ret = efi_load_pe(*image_obj, dest_buffer, info);
> > +   ret = efi_load_pe(*image_obj, dest_buffer, source_size, info);
> > if (!source_buffer)
> > /* Release buffer to which file was loaded */
> > efi_free_pages((uintptr_t)dest_buffer,
> >efi_size_in_pages(source_size));
> > -   if (ret == EFI_SUCCESS) {
> > +   if (ret == EFI_SUCCESS || ret == EFI_SECURITY_VIOLATION) {
> > info->system_table = 
> > info->parent_handle = parent_image;
> > } else {
> > @@ -2885,10 +2885,16 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t 
> > image_handle,
> > 
> > EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data);
> > 
> > +   if (!efi_search_obj(image_handle))
> > +   return EFI_EXIT(EFI_INVALID_PARAMETER);
> > +
> > /* Check parameters */
> > if (image_obj->header.type != EFI_OBJECT_TYPE_LOADED_IMAGE)
> > return EFI_EXIT(EFI_INVALID_PARAMETER);
> > 
> > +   if (image_obj->auth_status != EFI_IMAGE_AUTH_PASSED)
> > +   return EFI_EXIT(EFI_SECURITY_VIOLATION);
> > +
> > ret = EFI_CALL(efi_open_protocol(image_handle, _guid_loaded_image,
> >  , NULL, NULL,
> >  EFI_OPEN_PROTOCOL_GET_PROTOCOL));
> > diff --git 

RE: [PATCH v2 10/21] arm: socfpga: Add secure register access helper functions for SoC 64bits

2020-02-25 Thread Ang, Chee Hong
> On 2/24/20 3:21 AM, Ang, Chee Hong wrote:
> [...]
> 
> > Currently, we have like 20+ secure registers allowed access by
> > drivers running in non-secure mode (U-Boot proper / Linux).
> > I don't think we want to define and maintain those high level
> > interfaces for each of those secure register accesses in ATF and U-Boot.
> 
>  See above.
> >>> OK. Then these secure access register should be set up in SPL (EL3).
> >>> U-Boot drivers shouldn't access them at all because the driver may
> >>> be running in SPL(EL3) and in U-Boot proper (EL2) too.
> >>> I can take a look at those drivers accessing secure registers and
> >>> try to move/decouple those secure access from U-Boot drivers to SPL
> >>> (EL3) then we no longer need those secure register access functions.
> >>
> >> I think that would be great, no ?
> > Since the SDMMC/DWMAC drivers read the device tree to configure the
> > behaviour of the hardware via the secure registers. I think it should
> > still be part of the driver instead of configuring the hardware in
> > different places. I have proposed using ATF's high-level APIs to achieve 
> > this
> when the driver is running in EL2.
> > I have already proposed this in other email threads.
> > Are you OK with this approach ?
> 
> I think something more high level might be a good idea here.
What do you mean by 'more high level' ?
We handle this in SPL (EL3) ?

Since you are the author of this 'drivers/net/dwmac_socfpga.c':
https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/net/dwmac_socfpga.c#L101
https://gitlab.denx.de/u-boot/u-boot/blob/master/arch/arm/dts/socfpga_stratix10.dtsi#L98

Your driver selects the PHY interface (RGMII/RMII and etc) using the following 
register (part of System Manager):
https://www.intel.com/content/www/us/en/programmable/hps/stratix-10/hps.html#topic/jng1505406892594.html
 

I personally think this PHY interface select for EMACx shouldn't be part of 
System Manager.
I don't see the security benefits here by making this PHY interface select as 
'secure zone' register.

Same applies to DW MMC driver as well:
https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/mmc/socfpga_dw_mmc.c#L60

It sets the following register in System Manager (secure zone) to configure the 
SDMMC clocks:
https://www.intel.com/content/www/us/en/programmable/hps/stratix-10/hps.html#topic/gil1505406886282.html

Don't you think these things should be part of driver itself as what we are 
doing now instead
of removing these from drivers and place them in SPL (EL3)?


[PATCH] arm: mvebu: update RTC values for PCIe memory wrappers

2020-02-25 Thread Chris Packham
From: Chris Packham 

Update the RTC (Read Timing Control) values for PCIe memory wrappers
following an ERRATA (ERRATA# TDB). This means the PCIe accesses will
used slower memory Read Timing, to allow more efficient energy
consumption, in order to lower the minimum VDD of the memory.  Will lead
to more robust memory when voltage drop occurs (VDDSEG)

The code is based on changes from Marvell's U-Boot, specifically:

https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/20cd2704072512de176e048970f2883db901674b
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/eb608a7c8dd0d42b87601a61b9c0cc5615ab94b2
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/c4af19ae2bf08cf6e450e741ce4f04d402a5cb6b
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/c4af19ae2bf08cf6e450e741ce4f04d402a5cb6b

Signed-off-by: Chris Packham 
Signed-off-by: Chris Packham 
---
I've signed-off using both my email addresses. I normally do u-boot
stuff via gmail for convenience but this is definitely a work thing.

 arch/arm/mach-mvebu/include/mach/cpu.h|  2 ++
 arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c | 17 +
 arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h | 13 +
 arch/arm/mach-mvebu/spl.c |  3 +++
 4 files changed, 35 insertions(+)

diff --git a/arch/arm/mach-mvebu/include/mach/cpu.h 
b/arch/arm/mach-mvebu/include/mach/cpu.h
index 2e2d72aac892..fa7c81754b8f 100644
--- a/arch/arm/mach-mvebu/include/mach/cpu.h
+++ b/arch/arm/mach-mvebu/include/mach/cpu.h
@@ -166,8 +166,10 @@ int ddr3_init(void);
 /* Auto Voltage Scaling */
 #if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)
 void mv_avs_init(void);
+void mv_rtc_config(void);
 #else
 static inline void mv_avs_init(void) {}
+static inline void mv_rtc_config(void) {}
 #endif
 
 /*
diff --git a/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c 
b/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c
index e9dd096ad0f5..3c4c7e01a1cd 100644
--- a/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c
+++ b/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.c
@@ -257,6 +257,23 @@ u8 sys_env_device_rev_get(void)
return (value & (REVISON_ID_MASK)) >> REVISON_ID_OFFS;
 }
 
+void mv_rtc_config(void)
+{
+   u32 i, val;
+
+   if (!(IS_ENABLED(CONFIG_ARMADA_38X) || IS_ENABLED(CONFIG_ARMADA_39X)))
+   return;
+
+   /* Activate pipe0 for read/write transaction, and set XBAR client 
number #1 */
+   val = 0x1 << DFX_PIPE_SELECT_PIPE0_ACTIVE_OFFS |
+ 0x1 << DFX_PIPE_SELECT_XBAR_CLIENT_SEL_OFFS;
+   writel(val, MVEBU_DFX_BASE);
+
+   /* Set new RTC value for all memory wrappers */
+   for (i = 0; i < RTC_MEMORY_WRAPPER_COUNT; i++)
+   reg_write(RTC_MEMORY_WRAPPER_REG(i), 
RTC_MEMORY_WRAPPER_CTRL_VAL);
+}
+
 void mv_avs_init(void)
 {
u32 sar_freq;
diff --git a/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h 
b/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h
index 1774a5b780ca..17cd811331d2 100644
--- a/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h
+++ b/arch/arm/mach-mvebu/serdes/a38x/sys_env_lib.h
@@ -150,6 +150,19 @@
 #define MPP_UART1_SET_MASK (~(0xff000))
 #define MPP_UART1_SET_DATA (0x66000)
 
+#define DFX_PIPE_SELECT_PIPE0_ACTIVE_OFFS  0
+/* DFX_PIPE_SELECT_XBAR_CLIENT_SEL_OFFS: Since address completion in 14bit
+ * address mode, and given that [14:8] => [19:13], the 2 lower bits [9:8] =>
+ * [14:13] are dismissed. hence field offset is also shifted to 10
+ */
+#define DFX_PIPE_SELECT_XBAR_CLIENT_SEL_OFFS   10
+
+#define RTC_MEMORY_CTRL_REG_BASE   0xE6000
+#define RTC_MEMORY_WRAPPER_COUNT   8
+#define RTC_MEMORY_WRAPPER_REG(i)  (RTC_MEMORY_CTRL_REG_BASE + ((i) * 
0x40))
+#define RTC_MEMORY_CTRL_PDLVMC_FIELD_OFFS  6
+#define RTC_MEMORY_WRAPPER_CTRL_VAL(0x1 << 
RTC_MEMORY_CTRL_PDLVMC_FIELD_OFFS)
+
 #define AVS_DEBUG_CNTR_REG 0xe4124
 #define AVS_DEBUG_CNTR_DEFAULT_VALUE   0x08008073
 
diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index a99bf166fd85..70fef3b573d9 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -130,6 +130,9 @@ void board_init_f(ulong dummy)
/* Initialize Auto Voltage Scaling */
mv_avs_init();
 
+   /* Update read timing control for PCIe */
+   mv_rtc_config();
+
/*
 * Return to the BootROM to continue the Marvell xmodem
 * UART boot protocol. As initiated by the kwboot tool.
-- 
2.25.1



Re: [PATCHv2 4/4] scripts/Makefile.lib: Re-add -Wno-simple_bus_reg to DTC_FLAGS

2020-02-25 Thread Masahiro Yamada
On Tue, Feb 25, 2020 at 2:51 AM Tom Rini  wrote:
>
> This exists in Linux Kernel with commit 70523a3ce5ff so put it in the
> list of DTC_FLAGS that mirror Linux as we will catch up there.
>
> Signed-off-by: Tom Rini 

Reviewed-by: Masahiro Yamada 


> ---
>  scripts/Makefile.lib | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index a8196678b2e9..63d790e4e287 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -280,6 +280,7 @@ DTC_FLAGS += -Wno-unit_address_vs_reg \
> -Wno-unit_address_format \
> -Wno-avoid_unnecessary_addr_size \
> -Wno-alias_paths \
> +   -Wno-simple_bus_reg \
> -Wno-pci_device_reg
>
>  # U-Boot specific disables
> --
> 2.17.1
>


-- 
Best Regards
Masahiro Yamada


Re: [PATCHv2 3/4] scripts/Makefile.lib: Restore PCI related warnings to DTC_FLAGS

2020-02-25 Thread Masahiro Yamada
On Tue, Feb 25, 2020 at 2:51 AM Tom Rini  wrote:
>
> While we are working on correcting usage related to the pci_bridge and
> pci_device_bus_num warnings, disable these flags for now.
>
> Signed-off-by: Tom Rini 

Reviewed-by: Masahiro Yamada 


> ---
>  scripts/Makefile.lib | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index bfb5851e9bfa..a8196678b2e9 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -281,6 +281,10 @@ DTC_FLAGS += -Wno-unit_address_vs_reg \
> -Wno-avoid_unnecessary_addr_size \
> -Wno-alias_paths \
> -Wno-pci_device_reg
> +
> +# U-Boot specific disables
> +DTC_FLAGS += -Wno-pci_bridge \
> +-Wno-pci_device_bus_num
>  endif
>
>  ifneq ($(findstring 2,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> --
> 2.17.1
>


-- 
Best Regards
Masahiro Yamada


Re: [PATCHv2 1/4] kbuild: fixdep: Resync this with v4.17

2020-02-25 Thread Masahiro Yamada
On Tue, Feb 25, 2020 at 2:50 AM Tom Rini  wrote:
>
> The previous kbuild resync of e91610da7c8a ("kconfig: re-sync with Linux
> 4.17-rc4") accidentally did not sync the fixdep program.  This commit
> brings fixdep in line with the rest of that previous resync.
>
> This includes all of the following Linux kernel commits:
> fbfa9be9904e kbuild: move include/config/ksym/* to include/ksym/*
> 5b8ad96d1a44 fixdep: remove some false CONFIG_ matches
> 14a596a7e6fd fixdep: remove stale references to uml-config.h
> ab9ce9feed36 fixdep: use existing helper to check modular CONFIG options
> 87b95a81357d fixdep: refactor parse_dep_file()
> 5d1ef76f5a22 fixdep: move global variables to local variables of main()
> ccfe78873c22 fixdep: remove unneeded memcpy() in parse_dep_file()
> 4003fd80cba9 fixdep: factor out common code for reading files
> 01b5cbe7012f fixdep: use malloc() and read() to load dep_file to buffer
> 41f92cffba19 fixdep: remove unnecessary  inclusion
> 7c2ec43a2154 fixdep: exit with error code in error branches of 
> do_config_file()
> 4e433fc4d1a9 fixdep: trivial: typo fix and correction
> dee81e988674 fixdep: faster CONFIG_ search
> c1a95fda2a40 kbuild: add fine grained build dependencies for exported symbols
> d8329e35cc08 fixdep: accept extra dependencies on stdin
> 4c835b57b8de fixdep: constify strrcmp arguments
>
> Of note is that when applying dee81e988674 above our logic in that area
> required some careful consideration to continue to apply.
>
> [Fold in bugfix to allow us to include 638e69cf2230 from upstream]
> Signed-off-by: Masahiro Yamada 
>
> [Merge everything to U-Boot, rework dee81e988674]
> Signed-off-by: Tom Rini 


Reviewed-by: Masahiro Yamada 




-- 
Best Regards
Masahiro Yamada


Re: [PATCHv2 2/4] kbuild: Re-sync DTC flag logic with v4.17

2020-02-25 Thread Masahiro Yamada
Hi Tom,


On Tue, Feb 25, 2020 at 2:50 AM Tom Rini  wrote:
>
> The way that we have been handling additional DTC warning flags hasn't
> matched the way the Linux Kernel does.  Resync this logic with v4.17.
>
> Signed-off-by: Tom Rini 


If you entirely move DTC_FLAGS to scripts/Makefile.lib,
you can git rid of 'export DTC_FLAGS' from the top Makefile.


diff --git a/Makefile b/Makefile
index 66b72105c1..0b049e00d9 100644
--- a/Makefile
+++ b/Makefile
@@ -431,7 +431,7 @@ export ARCH CPU BOARD VENDOR SOC CPUDIR BOARDDIR
 export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
 export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
 export MAKE LEX YACC AWK PERL PYTHON PYTHON2 PYTHON3
-export HOSTCXX HOSTCXXFLAGS CHECK CHECKFLAGS DTC DTC_FLAGS
+export HOSTCXX HOSTCXXFLAGS CHECK CHECKFLAGS DTC

 export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE OBJCOPYFLAGS LDFLAGS
 export KBUILD_CFLAGS KBUILD_AFLAGS






> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 30f392fdfb08..bfb5851e9bfa 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -274,6 +274,22 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > 
> $@) || \
>  # DTC
>  # ---
>

If you want to re-sync this hunk completely,
you can move

DTC ?= $(objtree)/scripts/dtc/dtc

here from the top Makefile. I leave it up to you.

(You need to get rid of 'export DTC' in that case)



I just noticed $(DTC) is no longer used in the top Makefile.
Hence, this patch.

http://patchwork.ozlabs.org/patch/1244561/


> +# Disable noisy checks by default
> +ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> +DTC_FLAGS += -Wno-unit_address_vs_reg \
> +   -Wno-unit_address_format \
> +   -Wno-avoid_unnecessary_addr_size \
> +   -Wno-alias_paths \
> +   -Wno-pci_device_reg
> +endif
> +
> +ifneq ($(findstring 2,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> +DTC_FLAGS += -Wnode_name_chars_strict \
> +   -Wproperty_name_chars_strict
> +endif
> +
> +DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
> +
>  # Generate an assembly file to wrap the output of the device tree compiler
>  quiet_cmd_dt_S_dtb= DTB $@
>  # Modified for U-Boot
> --
> 2.17.1
>


-- 
Best Regards
Masahiro Yamada


[PATCH] kbuild: remove unused dtc-version.sh script

2020-02-25 Thread Masahiro Yamada
This is U-Boot own code, and no longer used since commit 36dd5f1b8abc
("dtc: Switch to building and using our own dtc unless provided").

Prior to that commit, U-Boot relied on an external dtc, so this script
was used to check the dtc version.

Now U-Boot bundles our own dtc in script/dtc/dtc like Linux kernel.

Users are still allowed to pass DTC= option from the command line,
but they are supposed to choose correct version of dtc in this case.
So, we do not check the dtc version any more.

Signed-off-by: Masahiro Yamada 
---

 scripts/Kbuild.include |  1 -
 scripts/dtc-version.sh | 21 -
 2 files changed, 22 deletions(-)
 delete mode 100755 scripts/dtc-version.sh

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 89f41ee39f..f9d118ad3d 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -147,7 +147,6 @@ cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo 
$(3) || echo $(4))
 
 # added for U-Boot
 binutils-version = $(shell $(CONFIG_SHELL) 
$(srctree)/scripts/binutils-version.sh $(AS))
-dtc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/dtc-version.sh $(DTC))
 
 # cc-ldoption
 # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
diff --git a/scripts/dtc-version.sh b/scripts/dtc-version.sh
deleted file mode 100755
index 0744c39eb0..00
--- a/scripts/dtc-version.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-#
-# dtc-version dtc-command
-#
-# Prints the dtc version of `dtc-command' in a canonical 6-digit form
-# such as `010404'  for dtc 1.4.4
-#
-
-dtc="$*"
-
-if [ ${#dtc} -eq 0 ]; then
-   echo "Error: No dtc command specified."
-   printf "Usage:\n\t$0 \n"
-   exit 1
-fi
-
-MAJOR=$($dtc -v | head -1 | awk '{print $NF}' | cut -d . -f 1)
-MINOR=$($dtc -v | head -1 | awk '{print $NF}' | cut -d . -f 2)
-PATCH=$($dtc -v | head -1 | awk '{print $NF}' | cut -d . -f 3 | cut -d - -f 1)
-
-printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCH
-- 
2.17.1



Re: [PATCH] mmc: make self-contained

2020-02-25 Thread Jaehoon Chung
On 2/25/20 2:25 AM, Masahiro Yamada wrote:
> This header uses bd_t without including its definition.
> 
> Change it to (struct bd_info), and add the forward declaration
> to specify it as a structure.
> 
> Signed-off-by: Masahiro Yamada 

Reviewed-by: Jaehoon Chung 

Best Regards,
Jaehoon Chung

> ---
> 
>  include/mmc.h | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/include/mmc.h b/include/mmc.h
> index 71e2e1735a..4bdeb929d7 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -15,6 +15,8 @@
>  #include 
>  #include 
>  
> +struct bd_info;
> +
>  #if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)
>  #define MMC_SUPPORTS_TUNING
>  #endif
> @@ -712,7 +714,7 @@ void mmc_destroy(struct mmc *mmc);
>   * @return 0 if OK, -ve on error
>   */
>  int mmc_unbind(struct udevice *dev);
> -int mmc_initialize(bd_t *bis);
> +int mmc_initialize(struct bd_info *bis);
>  int mmc_init_device(int num);
>  int mmc_init(struct mmc *mmc);
>  int mmc_send_tuning(struct mmc *mmc, u32 opcode, int *cmd_error);
> @@ -857,8 +859,8 @@ void mmc_set_preinit(struct mmc *mmc, int preinit);
>  #endif
>  
>  void board_mmc_power_init(void);
> -int board_mmc_init(bd_t *bis);
> -int cpu_mmc_init(bd_t *bis);
> +int board_mmc_init(struct bd_info *bis);
> +int cpu_mmc_init(struct bd_info *bis);
>  int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr);
>  # ifdef CONFIG_SYS_MMC_ENV_PART
>  extern uint mmc_get_env_part(struct mmc *mmc);
> 



Re: [PATCH 1/1] include/ata.h: remove invalid links

2020-02-25 Thread Tom Rini
On Tue, Feb 25, 2020 at 10:04:53PM +0100, Heinrich Schuchardt wrote:

> Remove invalid URLs for "Information Technology - AT Attachment-3 Interface
> (ATA-3)".
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
>  include/ata.h | 4 
>  1 file changed, 4 deletions(-)
> 
> diff --git a/include/ata.h b/include/ata.h
> index 3f4e4a0234..aecb9cd589 100644
> --- a/include/ata.h
> +++ b/include/ata.h
> @@ -7,10 +7,6 @@
>  /*
>   * Most of the following information was derived from the document
>   * "Information Technology - AT Attachment-3 Interface (ATA-3)"
> - * which can be found at:
> - * http://www.dt.wdc.com/ata/ata-3/ata3r5v.zip
> - * ftp://poctok.iae.nsk.su/pub/asm/Documents/IDE/ATA3R5V.ZIP
> - * ftp://ftp.fee.vutbr.cz/pub/doc/io/ata/ata-3/ata3r5v.zip
>   */
> 
>  #ifndef  _ATA_H

In this case, it looks like some of the relevant information about the
spec, "Revision 5v" is encoded in the URL.  I can't find a new link for
it, but we should keep that information in the comment.  Thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH 1/1] include/ata.h: remove invalid links

2020-02-25 Thread Heinrich Schuchardt
Remove invalid URLs for "Information Technology - AT Attachment-3 Interface
(ATA-3)".

Signed-off-by: Heinrich Schuchardt 
---
 include/ata.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/include/ata.h b/include/ata.h
index 3f4e4a0234..aecb9cd589 100644
--- a/include/ata.h
+++ b/include/ata.h
@@ -7,10 +7,6 @@
 /*
  * Most of the following information was derived from the document
  * "Information Technology - AT Attachment-3 Interface (ATA-3)"
- * which can be found at:
- * http://www.dt.wdc.com/ata/ata-3/ata3r5v.zip
- * ftp://poctok.iae.nsk.su/pub/asm/Documents/IDE/ATA3R5V.ZIP
- * ftp://ftp.fee.vutbr.cz/pub/doc/io/ata/ata-3/ata3r5v.zip
  */

 #ifndef_ATA_H
--
2.25.0



[PATCH 1/1] Kconfig: fix typos in CMD_BEDBUG description

2020-02-25 Thread Heinrich Schuchardt
Fix documentation bug reported by 'make refcheckdocs'.

Signed-off-by: Heinrich Schuchardt 
---
 cmd/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 6403bc45a5..c9ea11 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -2095,7 +2095,7 @@ config CMD_BEDBUG
help
  The bedbug (emBEDded deBUGger) command provides debugging features
  for some PowerPC processors. For details please see the
- docuemntation in doc/README.beddbug
+ documentation in doc/README.bedbug.

 config CMD_DIAG
bool "diag - Board diagnostics"
--
2.25.0



[PATCH 1/1] doc: fix references to driver-model

2020-02-25 Thread Heinrich Schuchardt
Fix some errors pointed out by 'make refcheckdocs'.

Signed-off-by: Heinrich Schuchardt 
---
 doc/README.drivers.eth | 2 +-
 doc/README.fdt-control | 2 +-
 drivers/i2c/davinci_i2c.c  | 2 +-
 drivers/i2c/kona_i2c.c | 2 +-
 drivers/i2c/sh_i2c.c   | 2 +-
 drivers/i2c/soft_i2c.c | 2 +-
 tools/dtoc/dtb_platdata.py | 4 ++--
 tools/dtoc/dtoc.py | 2 +-
 8 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/doc/README.drivers.eth b/doc/README.drivers.eth
index 1a9a23b51b..acaf11fea3 100644
--- a/doc/README.drivers.eth
+++ b/doc/README.drivers.eth
@@ -2,7 +2,7 @@

 This guide describes to the old way of doing things. No new Ethernet drivers
 should be implemented this way. All new drivers should be written against the
-U-Boot core driver model. See doc/driver-model/README.txt
+U-Boot core driver model. See doc/driver-model/index.rst.

 ---
  Ethernet Driver Guide
diff --git a/doc/README.fdt-control b/doc/README.fdt-control
index e53cf51875..424d13fc5b 100644
--- a/doc/README.fdt-control
+++ b/doc/README.fdt-control
@@ -182,7 +182,7 @@ U-Boot can be divided into three phases: TPL, SPL and 
U-Boot proper.

 The full device tree is available to U-Boot proper, but normally only a subset
 (or none at all) is available to TPL and SPL. See 'Pre-Relocation Support' and
-'SPL Support' in doc/driver-model/README.txt for more details.
+'SPL Support' in doc/driver-model/design.rst for more details.


 Using several DTBs in the SPL (CONFIG_SPL_MULTI_DTB)
diff --git a/drivers/i2c/davinci_i2c.c b/drivers/i2c/davinci_i2c.c
index 2c77234c60..edc40f706c 100644
--- a/drivers/i2c/davinci_i2c.c
+++ b/drivers/i2c/davinci_i2c.c
@@ -8,7 +8,7 @@
  * 
  *
  * NOTE: This driver should be converted to driver model before June 2017.
- * Please see doc/driver-model/i2c-howto.txt for instructions.
+ * Please see doc/driver-model/i2c-howto.rst for instructions.
  */

 #include 
diff --git a/drivers/i2c/kona_i2c.c b/drivers/i2c/kona_i2c.c
index 0726b4c956..8e31481c0f 100644
--- a/drivers/i2c/kona_i2c.c
+++ b/drivers/i2c/kona_i2c.c
@@ -3,7 +3,7 @@
  * Copyright 2013 Broadcom Corporation.
  *
  * NOTE: This driver should be converted to driver model before June 2017.
- * Please see doc/driver-model/i2c-howto.txt for instructions.
+ * Please see doc/driver-model/i2c-howto.rst for instructions.
  */

 #include 
diff --git a/drivers/i2c/sh_i2c.c b/drivers/i2c/sh_i2c.c
index b69d213593..834f1f2179 100644
--- a/drivers/i2c/sh_i2c.c
+++ b/drivers/i2c/sh_i2c.c
@@ -4,7 +4,7 @@
  * Copyright (C) 2011, 2013 Nobuhiro Iwamatsu 

  *
  * NOTE: This driver should be converted to driver model before June 2017.
- * Please see doc/driver-model/i2c-howto.txt for instructions.
+ * Please see doc/driver-model/i2c-howto.rst for instructions.
  */

 #include 
diff --git a/drivers/i2c/soft_i2c.c b/drivers/i2c/soft_i2c.c
index 7f0303cc05..9ad1c281ff 100644
--- a/drivers/i2c/soft_i2c.c
+++ b/drivers/i2c/soft_i2c.c
@@ -12,7 +12,7 @@
  * Neil Russell.
  *
  * NOTE: This driver should be converted to driver model before June 2017.
- * Please see doc/driver-model/i2c-howto.txt for instructions.
+ * Please see doc/driver-model/i2c-howto.rst for instructions.
  */

 #include 
diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 037e82c8bb..90a9e1a626 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -423,7 +423,7 @@ class DtbPlatdata(object):

 This writes out the body of a header file consisting of structure
 definitions for node in self._valid_nodes. See the documentation in
-README.of-plat for more information.
+doc/driver-model/of-plat.rst for more information.
 """
 self.out_header()
 self.out('#include \n')
@@ -527,7 +527,7 @@ class DtbPlatdata(object):
 U_BOOT_DEVICE() declarations for each valid node. Where a node has
 multiple compatible strings, a #define is used to make them equivalent.

-See the documentation in doc/driver-model/of-plat.txt for more
+See the documentation in doc/driver-model/of-plat.rst for more
 information.
 """
 self.out_header()
diff --git a/tools/dtoc/dtoc.py b/tools/dtoc/dtoc.py
index b3596a5918..f31cba900e 100755
--- a/tools/dtoc/dtoc.py
+++ b/tools/dtoc/dtoc.py
@@ -22,7 +22,7 @@ Dtoc produces two output files:
 This tool is used in U-Boot to provide device tree data to SPL without
 increasing the code size of SPL. This supports the CONFIG_SPL_OF_PLATDATA
 options. For more information about the use of this options and tool please
-see doc/driver-model/of-plat.txt
+see doc/driver-model/of-plat.rst
 """

 from __future__ import print_function
--
2.25.0



Fixing low-speed USB keyboard detection

2020-02-25 Thread Stefan
Hello!

I own a D-Link DBT-120 Bluetooth Adapter, which has a CSR firmware running in a 
so called “HID proxy mode”. This firmware pretends to be a USB keyboard (and 
mouse) and thus allows to use a Bluetooth keyboard in U-Boot.

Unfortunately it acts as a low-speed device and there seems to be some well 
known troubles about low-speed USB keyboards. There is a FAQ entry for openSUSE 
about this: 
https://en.opensuse.org/HCL:Raspberry_Pi3#I_cannot_use_keyboard_in_U-Boot_and_Grub_but_it_works_in_Linux

I spend some effort to solve this issue. There are three tiny changes to get my 
Bluetooth keyboard working reliably as a low-speed USB keyboard.

Sometimes the Bluetooth adapter needs a bit longer to power on and send its 
descriptor. As I use a Raspberry Pi 3b, I modified include/configs/rpi.h to add 
"usb_pgood_delay=100\0" to the CONFIG_EXTRA_ENV_SETTINGS define. However this 
is actually not a necessary change, even without it, most of the time there is 
no issue.

Then the Bluetooth adapter needs one millisecond delay before accepting a new 
address, to avoid the error “USB device not accepting new address”. This is in 
common/usb.c at line 1047:

https://github.com/u-boot/u-boot/blob/master/common/usb.c#L1047

dev->devnum = addr;
mdelay(1);
err = usb_set_address(dev); /* set address */

And finally, assuming the use of CONFIG_SYS_USB_EVENT_POLL=y (which is the 
default), in common/usb_kbd.c at line 520 this first interrupt IN message must 
not be send:

https://github.com/u-boot/u-boot/blob/master/common/usb_kbd.c#L520

if (usb_int_msg(dev, data->intpipe, data->new, data->intpktsize,
data->intinterval, false) < 0) {
#endif
printf("Failed to get keyboard state from device %04x:%04x\n",
   dev->descriptor.idVendor, dev->descriptor.idProduct);
/* Abort, we don't want to use that non-functional keyboard. */
return 0;
}

Due to the #if stuff around, its a bit ugly. I solved it simply by modifying 
the if-statement in line 520:

if (0) {

With these two fixes my keyboard is working reliably. There is no need to press 
a key upfront and no error message any longer, as described for openSUSE. A 
chain-loaded GRUB-EFI is always usable now. I’m pretty sure that these changes 
will solve the issues for other low-speed USB keyboards as well.


However, with that first interrupt IN message still sent, it seemed to me that 
there was a NYET loop in chunk_msg() in drivers/usb/host/dwc.c once 
complete_split got set. I guessed that “done += actual_len;” happens to often 
and possibly to early for an unfinished split transaction. With the recent fix 
9dcab2c4d2cb50ab1864c818b82a72393c160236 introducing the nonblock argument, a 
split transfer gets restarted at a higher level, once there were to many NYET 
responses. But for this first interrupt IN message this nonblock argument is 
set to false, and in _submit_int_msg() we run into the timeout.

If I understand it correctly, once a NYET message is received, it may take up 
to a millisecond before a response from a low-speed device is received (one 
low-speed frame). And a high-speed host has a frame length of 125 ms. That 
means that it can take up to 8 high-speed frames before a response from a 
low-speed device is received. Bit chunk_msg() returns already after > 4 
high-speed frames. I would expect to wait at least 8 frames.

The check after that first interrupt IN message got added by 
5da2dc9789abecb1b018beb0c93f4c38c2985bc6 to workaround non-working keyboards. 
My suggested change will kind of revert that workaround. So there is some 
trade-off.


Stefan

[PATCH 1/1] scripts: add documentation-file-ref-check

2020-02-25 Thread Heinrich Schuchardt
'make refcheckdocs' requires scripts/documentation-file-ref-check.
Adopt script from Linux v5.6-rc3.

Signed-off-by: Heinrich Schuchardt 
---
 scripts/documentation-file-ref-check | 226 +++
 1 file changed, 226 insertions(+)
 create mode 100755 scripts/documentation-file-ref-check

diff --git a/scripts/documentation-file-ref-check 
b/scripts/documentation-file-ref-check
new file mode 100755
index 00..9978fc9a91
--- /dev/null
+++ b/scripts/documentation-file-ref-check
@@ -0,0 +1,226 @@
+#!/usr/bin/env perl
+# SPDX-License-Identifier: GPL-2.0
+#
+# Treewide grep for references to files under doc, and report
+# non-existing files in stderr.
+
+use warnings;
+use strict;
+use Getopt::Long qw(:config no_auto_abbrev);
+
+# NOTE: only add things here when the file was gone, but the text wants
+# to mention a past documentation file, for example, to give credits for
+# the original work.
+my %false_positives = (
+);
+
+my $scriptname = $0;
+$scriptname =~ s,.*/([^/]+/),$1,;
+
+# Parse arguments
+my $help = 0;
+my $fix = 0;
+my $warn = 0;
+
+if (! -d ".git") {
+   printf "Warning: can't check if file exists, as this is not a git tree";
+   exit 0;
+}
+
+GetOptions(
+   'fix' => \$fix,
+   'warn' => \$warn,
+   'h|help|usage' => \$help,
+);
+
+if ($help != 0) {
+print "$scriptname [--help] [--fix]\n";
+exit -1;
+}
+
+# Step 1: find broken references
+print "Finding broken references. This may take a while...  " if ($fix);
+
+my %broken_ref;
+
+my $doc_fix = 0;
+
+open IN, "git grep ':doc:\`' doc/|"
+ or die "Failed to run git grep";
+while () {
+   next if (!m,^([^:]+):.*\:doc\:\`([^\`]+)\`,);
+
+   my $d = $1;
+   my $doc_ref = $2;
+
+   my $f = $doc_ref;
+
+   $d =~ s,(.*/).*,$1,;
+   $f =~ s,.*\<([^\>]+)\>,$1,;
+
+   $f ="$d$f.rst";
+
+   next if (grep -e, glob("$f"));
+
+   if ($fix && !$doc_fix) {
+   print STDERR "\nWARNING: Currently, can't fix broken :doc:`` 
fields\n";
+   }
+   $doc_fix++;
+
+   print STDERR "$f: :doc:`$doc_ref`\n";
+}
+close IN;
+
+open IN, "git grep 'doc/'|"
+ or die "Failed to run git grep";
+while () {
+   next if (!m/^([^:]+):(.*)/);
+
+   my $f = $1;
+   my $ln = $2;
+
+   # On linux-next, discard the Next/ directory
+   next if ($f =~ m,^Next/,);
+
+   # Makefiles and scripts contain nasty expressions to parse docs
+   next if ($f =~ m/Makefile/ || $f =~ m/\.sh$/);
+
+   # Skip this script
+   next if ($f eq $scriptname);
+
+   # Ignore the dir where documentation will be built
+   next if ($ln =~ m,\b(\S*)doc/output,);
+
+   if ($ln =~ m,\b(\S*)(doc/[A-Za-z0-9\_\.\,\~/\*\[\]\?+-]*)(.*),) {
+   my $prefix = $1;
+   my $ref = $2;
+   my $base = $2;
+   my $extra = $3;
+
+   # some file references are like:
+   # /usr/src/linux/doc/DMA-{API,mapping}.txt
+   # For now, ignore them
+   next if ($extra =~ m/^{/);
+
+   # Remove footnotes at the end like:
+   # doc/devicetree/dt-object-internal.txt[1]
+   $ref =~ s/(txt|rst)\[\d+]$/$1/;
+
+   # Remove ending ']' without any '['
+   $ref =~ s/\].*// if (!($ref =~ m/\[/));
+
+   # Remove puntuation marks at the end
+   $ref =~ s/[\,\.]+$//;
+
+   my $fulref = "$prefix$ref";
+
+   $fulref =~ s/^(\ 1) {
+   print STDERR "WARNING: Won't auto-replace, as found multiple 
files close to $ref:\n";
+   foreach my $j (@find) {
+   $j =~ s,^./,,;
+   print STDERR "$j\n";
+   }
+   } else {
+   $f = $find[0];
+   $f =~ s,^./,,;
+   print "INFO: Replacing $ref to $f\n";
+   foreach my $j (qx(git grep -l $ref)) {
+   qx(sed "s\@$ref\@$f\@g" -i $j);
+   }
+   }
+}
--
2.25.0



Re: [RFC PATCH 00/10] arm: add support for SoC S5P4418

2020-02-25 Thread Stefan B.

Hi Amit,

Am 22.02.20 um 14:06 schrieb Amit Tomer:

Hi,

On Tue, Feb 4, 2020 at 1:12 AM Stefan Bosch  wrote:



This patch adds support for SAMSUNG's/NEXELL's ARM Cortex-A9 based
S5P4418 SoC, especially FriendlyARM's NanoPi2 and NanoPC-T2 boards.
It is based on the following FriendlyARM's U-Boot version:
https://github.com/friendlyarm/u-boot/tree/nanopi2-v2016.01.


I don't think this is the right approach, i.e. to take everything from
BSP source as it is and put
it into mainline U-BOOT. AFAIR,  Some of the peripherals present on
these NEXELL SoC's are
compatible with SAMSUNG IP (for instance the UART).
So, are we sure that some of the already existing code in U-BOOT can't
be re-used to drive those
compatible peripherals at-least ?

Thanks
-Amit



You are right, already existing code in U-BOOT should be used where 
possible. So I have reviewed the code (and will review it further). Up 
to now, I have the following proposals for the peripherials indicated:


UART:
Actually the UARTs of the S5P4418 are Amba PrimeCell PL011 compatible, 
therefore the appropriate code is used. S5P6818 does have different 
UARTs which apparently arch/arm/mach-nexell/serial.c is for. Since 
S5P6818 is not supported (yet) I will remove this file.


TIMER:
Currently arch/arm/mach-nexell/timer.c is used. I will try to use 
arch/arm/cpu/armv7/s5p-common/timer.c instead. The timer-registers used 
seem to be the same, but the functions in timer.c are not which is a 
possible pitfall.


PWM:
Currently drivers/pwm/pwm-nexell.c is used. This is a extended version 
of arch/arm/cpu/armv7/s5p-common/pwm.c. I.e. pwm.c is adapted with
"#if defined(CONFIG_ARCH_NEXELL) ... #else" at some places. So my 
proposal is to change s5p-common/pwm.c appropriately to get rid of 
pwm-nexell.c.



Regards
Stefan


Re: [PATCH] tools: image-host.c: remove uboot_aes.h

2020-02-25 Thread Tom Rini
On Tue, Feb 18, 2020 at 05:23:20PM +0100, Philippe Reynes wrote:

> The include uboot_aes.h is not usefull and
> it breaks the compilation on android, so
> we remove it.
> 
> Signed-off-by: Philippe Reynes 
> Reported-by: Praneeth Bajjuri 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/1] MAINTAINERS: set maintainer for doc/api/efi.rst

2020-02-25 Thread Tom Rini
On Sat, Feb 22, 2020 at 07:45:50AM +0100, Heinrich Schuchardt wrote:

> doc/api/efi.rst belongs to the UEFI sub-system documentation.
> 
> Signed-off-by: Heinrich Schuchardt 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/2] moveconfig: replace unsafe eval with asteval

2020-02-25 Thread Tom Rini
On Wed, Feb 12, 2020 at 08:46:44PM +0100, Markus Klotzbuecher wrote:

> Commit b237d358b "moveconfig: expand simple expressions" added support
> for expanding expressions in configs, but used the unsafe python
> built-in "eval". This patch fixes this by replacing eval with the
> asteval module.
> 
> Signed-off-by: Markus Klotzbuecher 
> Cc: Heinrich Schuchardt 
> Cc: Heiko Schocher 
> Cc: Tom Rini 
> Cc: Simon Glass 
> Cc: Joe Hershberger 
> Cc: Masahiro Yamada 
> Reviewed-by: Heinrich Schuchardt 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 2/2] moveconfig: convert ps.stderr to string

2020-02-25 Thread Tom Rini
On Wed, Feb 12, 2020 at 08:46:45PM +0100, Markus Klotzbuecher wrote:

> Printing the error message in verbose mode fails, since python3
> doesn't implicitely convert bytes to strings.
> 
> Signed-off-by: Markus Klotzbuecher 
> Cc: Simon Glass 
> Cc: Tom Rini 
> Cc: Masahiro Yamada 
> Reviewed-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] arch: arm: Fix SZ_64K undeclared compilation error

2020-02-25 Thread Tom Rini
On Fri, Feb 14, 2020 at 11:00:52AM +0530, Wasim Khan wrote:

> Macro SZ_64K is undeclared. Include sizes.h to fix the compilation
> error.
> 
> Signed-off-by: Wasim Khan 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] board: novtech: meerkat96: use correct mmc driver

2020-02-25 Thread Tom Rini
On Wed, Jan 22, 2020 at 04:03:02PM -0500, Carl Gelfand wrote:

> When the board was originally submitted, it was attempting to use the
> ESDHC driver. The board uses the USDHC driver.
> 
> Signed-off-by: Carl Gelfand 
> Cc: Shawn Guo  (maintainer:MEERKAT96 BOARD)
> Acked-by: Shawn Guo 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 01/21] configs: agilex: Remove CONFIG_OF_EMBED

2020-02-25 Thread Westergreen, Dalon


On Tue, 2020-02-25 at 18:55 +0100, Marek Vasut wrote:
> On 2/24/20 3:26 AM, Ang, Chee Hong wrote:
> > > On 2/21/20 7:15 PM, Ang, Chee Hong wrote:
> > > > > On 2/20/20 6:04 PM, Westergreen, Dalon wrote:
> > > > > 
> > > > > Please fix your mailer, it makes your reply completely unreadable.
> > > > > 
> > > > > > On Thu, 2020-02-20 at 17:44 +0100, Marek Vasut wrote:
> > > > > > 
> > > > > > On 2/20/20 3:12 AM, Ang, Chee Hong wrote:
> > > > > > 
> > > > > > On 2/19/20 1:25 PM,
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > chee.hong@intel.com
> > > > > > 
> > > > > >  wrote:
> > > > > > 
> > > > > > From: Chee Hong Ang <
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > chee.hong@intel.com
> > > > > > 
> > > > > > 
> > > > > > CONFIG_OF_EMBED was primarily enabled to support the agilex spl hex
> > > > > > 
> > > > > > file requirements.  Since this option now produces a warning during
> > > > > > 
> > > > > > build, and the spl hex can be created using alternate methods,
> > > > > > 
> > > > > > CONFIG_OF_EMBED is no longer needed.
> > > > > 
> > > > > OK, so this patch removes functionality.
> > > > > Can that functionality be retained ? Or what can be done here?
> > > > The functionality is no longer required.
> > > 
> > > Because you always depend on ATF now ?
> > No. We have 2 different defconfigs in the patchset, one use ATF one without
> > ATF. Both no longer using CONFIG_OF_EMBED and they worked fine.
> 
> OK. So how is the .hex file generated now ?

Sorry, re-installed my OS and neglected to turn off HTML for my email default...

In our tree the patch i submitted to generate the hex file via objcopy is being
used. I can resubmit this?

Otherwise, people are just manually calling objcopy to convert the cat'ed spl-
dtb.bin to a hex file offset
to the appropriate address.

--dalon




Re: [PATCH] doc: Makefile: remove target refcheckdocs

2020-02-25 Thread Tom Rini
On Tue, Feb 25, 2020 at 07:10:01PM +0100, Heinrich Schuchardt wrote:
> On 2/25/20 7:00 PM, Patrick Delaunay wrote:
> > Remove the target refcheckdocs, based on the missing script
> > scripts/documentation-file-ref-check.
> > 
> > This script exists in Linux tree but wasn't imported when 'doc' move
> > to SPHINX in commit 78a88f7930be ("doc: Replace DocBook with
> > sphinx-based docs")
> > 
> > This patch avoids the error:
> > 
> > make refcheckdocs
> > /bin/sh: scripts/documentation-file-ref-check: No such file or directory
> > doc/Makefile:102: recipe for target 'refcheckdocs' failed
> > make[1]: *** [refcheckdocs] Error 127
> > Makefile:2094: recipe for target 'refcheckdocs' failed
> > make: *** [refcheckdocs] Error 2
> > 
> > Signed-off-by: Patrick Delaunay 
> 
> When we copy and adjust the missing script we can identify dozens of
> documentation errors, see below. So I think we should fix the make
> target instead of removing it.
> 
> arch/arm/mach-imx/Kconfig: doc/README.mxc_hab
> arch/arm/mach-imx/Kconfig: doc/README.mxc_hab
> board/advantech/dms-ba16/dms-ba16_1g.cfg: doc/README.imximage
> board/advantech/dms-ba16/dms-ba16_2g.cfg: doc/README.imximage
> board/aristainetos/aristainetos2.cfg: doc/README.imximage
> board/bachmann/ot1200/mx6q_4x_mt41j128.cfg: doc/README.imximage
> board/barco/titanium/imximage.cfg: doc/README.imximage
> board/boundary/nitrogen6x/nitrogen6dl.cfg: doc/README.imximage
> board/boundary/nitrogen6x/nitrogen6dl2g.cfg: doc/README.imximage
> board/boundary/nitrogen6x/nitrogen6q.cfg: doc/README.imximage
> board/boundary/nitrogen6x/nitrogen6q2g.cfg: doc/README.imximage
> board/boundary/nitrogen6x/nitrogen6s.cfg: doc/README.imximage
> board/boundary/nitrogen6x/nitrogen6s1g.cfg: doc/README.imximage
> board/ccv/xpress/imximage.cfg: doc/README.imximage
> board/cobra5272/README: u-boot-x-x-x/doc/README.COBRA5272
> board/freescale/imx8qxp_mek/imximage.cfg: doc/README.imx8image
> board/freescale/m52277evb/README: doc/README.m52277evb
> board/freescale/m53017evb/README: doc/README.m53017evb
> board/freescale/m5373evb/README: doc/README.m5373evb
> board/freescale/m54455evb/README: doc/README.m54455evb
> board/freescale/m547xevb/README: doc/README.m5475evb
> board/freescale/mx25pdk/imximage.cfg: doc/README.imximage
> board/freescale/mx51evk/imximage.cfg: doc/README.imximage
> board/freescale/mx53ard/imximage_dd3.cfg: doc/README.imximage
> board/freescale/mx53evk/imximage.cfg: doc/README.imximage
> board/freescale/mx53loco/imximage.cfg: doc/README.imximage
> board/freescale/mx53smd/imximage.cfg: doc/README.imximage
> board/freescale/mx6qarm2/imximage.cfg: doc/README.imximage
> board/freescale/mx6qarm2/imximage_mx6dl.cfg: doc/README.imximage
> board/freescale/mx6slevk/imximage.cfg: doc/README.imximage
> board/freescale/mx6ullevk/imximage.cfg: doc/README.imximage
> board/freescale/mx7dsabresd/imximage.cfg: doc/README.imximage
> board/freescale/s32v234evb/s32v234evb.cfg: doc/README.imximage
> board/freescale/vf610twr/imximage.cfg: doc/README.imximage
> board/ge/bx50v3/bx50v3.cfg: doc/README.imximage
> board/ge/mx53ppd/imximage.cfg: doc/README.imximage
> board/menlo/m53menlo/imximage.cfg: doc/README.imximage
> board/phytec/pcm052/imximage.cfg: doc/README.imximage
> board/seco/mx6quq7/mx6quq7-2g.cfg: doc/README.imximage
> board/siemens/capricorn/imximage.cfg: doc/README.imx8image
> board/technexion/pico-imx6ul/imximage.cfg: doc/README.imximage
> board/toradex/apalis-imx8/apalis-imx8qm-imximage.cfg: doc/README.imx8image
> board/toradex/colibri-imx6ull/imximage.cfg: doc/README.imximage
> board/toradex/colibri-imx8x/colibri-imx8qxp-imximage.cfg:
> doc/README.imx8image
> board/toradex/colibri_imx7/imximage.cfg: doc/README.imximage
> board/toradex/colibri_vf/imximage.cfg: doc/README.imximage
> board/tqc/tqma6/clocks.cfg: doc/README.imximage
> board/tqc/tqma6/tqma6dl.cfg: doc/README.imximage
> board/tqc/tqma6/tqma6q.cfg: doc/README.imximage
> board/tqc/tqma6/tqma6s.cfg: doc/README.imximage
> board/warp/imximage.cfg: doc/README.imximage
> board/warp7/imximage.cfg: doc/README.imximage
> cmd/Kconfig: doc/README.beddbug
> doc/README.drivers.eth: doc/driver-model/README.txt
> doc/README.fdt-control: doc/driver-model/README.txt
> doc/device-tree-bindings/net/ti,dp83867.txt:
> doc/devicetree/bindings/net/ethernet.txt
> doc/device-tree-bindings/video/rockchip-lvds.txt:
> doc/devicetree/device-tree-bindings/video/display-timing.txt
> doc/imx/misc/sdp.txt: doc/README.imximage
> doc/sphinx/parse-headers.pl: doc/doc-guide/parse-headers.rst
> doc/sphinx/rstFlatTable.py: doc/books/kernel-doc-HOWTO
> drivers/i2c/davinci_i2c.c: doc/driver-model/i2c-howto.txt
> drivers/i2c/kona_i2c.c: doc/driver-model/i2c-howto.txt
> drivers/i2c/sh_i2c.c: doc/driver-model/i2c-howto.txt
> drivers/i2c/soft_i2c.c: doc/driver-model/i2c-howto.txt
> drivers/rtc/ds1374.c: Watchdoc/Alarm
> include/ata.h: ftp://ftp.fee.vutbr.cz/pub/doc/io/ata/ata-3/ata3r5v.zip
> include/configs/sbc8548.h: doc/README.sbc8548
> include/fsl_qe.h: 

Re: [PATCH v2 01/21] configs: agilex: Remove CONFIG_OF_EMBED

2020-02-25 Thread Marek Vasut
On 2/25/20 7:26 PM, Westergreen, Dalon wrote:
> 
> 
> On Tue, 2020-02-25 at 18:55 +0100, Marek Vasut wrote:
> 
> On 2/24/20 3:26 AM, Ang, Chee Hong wrote:
> 
> On 2/21/20 7:15 PM, Ang, Chee Hong wrote:
> 
> On 2/20/20 6:04 PM, Westergreen, Dalon wrote:
> 
> 
> Please fix your mailer, it makes your reply completely unreadable.

Sorry, I'm not reading further, your reply is again completely
unreadable :-(

[...]


Re: [PATCH v2 01/21] configs: agilex: Remove CONFIG_OF_EMBED

2020-02-25 Thread Westergreen, Dalon


On Tue, 2020-02-25 at 18:55 +0100, Marek Vasut wrote:

On 2/24/20 3:26 AM, Ang, Chee Hong wrote:

On 2/21/20 7:15 PM, Ang, Chee Hong wrote:

On 2/20/20 6:04 PM, Westergreen, Dalon wrote:


Please fix your mailer, it makes your reply completely unreadable.


On Thu, 2020-02-20 at 17:44 +0100, Marek Vasut wrote:


On 2/20/20 3:12 AM, Ang, Chee Hong wrote:


On 2/19/20 1:25 PM,


mailto:chee.hong@intel.com>

chee.hong@intel.com

>




chee.hong@intel.com



 wrote:


From: Chee Hong Ang <


mailto:chee.hong@intel.com>

chee.hong@intel.com

>




chee.hong@intel.com






CONFIG_OF_EMBED was primarily enabled to support the agilex spl hex


file requirements.  Since this option now produces a warning during


build, and the spl hex can be created using alternate methods,


CONFIG_OF_EMBED is no longer needed.


OK, so this patch removes functionality.

Can that functionality be retained ? Or what can be done here?

The functionality is no longer required.


Because you always depend on ATF now ?

No. We have 2 different defconfigs in the patchset, one use ATF one without

ATF. Both no longer using CONFIG_OF_EMBED and they worked fine.


OK. So how is the .hex file generated now ?

In our tree the patch i submitted to generate the hex file via objcopy is being 
used. I can resubmit this?

Otherwise, people are just manually calling objcopy to convert the cat'ed 
spl-dtb.bin to a hex file offset
to the appropriate address.

--dalon


[PATCH] tiny-printf: revert patch to fix spl eth boot

2020-02-25 Thread Moses Christopher
From: Moses Christopher Bollavarapu 

  - Revert commit 831c16111959 ("tiny-printf: Reorder code to support %p")

The mentioned commit does not handle the ethaddr properly.
Hence, I tried to disable SPL_TINY_PRINTF, but then it was suggested
to keep using the tiny-printf library in SPL and revert the patch
that caused the issue.

  - The issue is observed in both Beaglebone Black and Guardian Board,
while trying to boot the board using USB-ETH in SPL stage.

Signed-off-by: Moses Christopher Bollavarapu 
---
 lib/tiny-printf.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
index 1138c7012a..8ee0ffb9ca 100644
--- a/lib/tiny-printf.c
+++ b/lib/tiny-printf.c
@@ -268,20 +268,10 @@ static int _vprintf(struct printf_info *info, const char 
*fmt, va_list va)
}
break;
case 'p':
-#ifdef DEBUG
pointer(info, fmt, va_arg(va, void *));
-   /*
-* Skip this because it pulls in _ctype which is
-* 256 bytes, and we don't generally implement
-* pointer anyway
-*/
while (isalnum(fmt[0]))
fmt++;
break;
-#else
-   islong = true;
-   /* no break */
-#endif
case 'x':
if (islong) {
num = va_arg(va, unsigned long);
-- 
2.20.1



Re: [U-Boot] [PATCH] usb: ehci-mx5: Fix bus enumeration for DM case

2020-02-25 Thread Marek Vasut
On 2/24/20 4:28 PM, Lukasz Majewski wrote:
> Hi Marek,

Hi,

>> On Thu, 20 Jun 2019 22:53:58 +0200
>> Marek Vasut  wrote:
>>
>>> It is likely that the DM conversion of EHCI iMX5 driver was a
>>> derivative of EHCI VF, however the conversion is incomplete and is
>>> missing the bind workaround, which updates dev->seq number. Without
>>> this, all controllers have dev->seq number 0 . Add this bind
>>> workaround into EHCI iMX5 driver as well.
>>>
>>> Signed-off-by: Marek Vasut 
>>> Cc: Abel Vesa 
>>> Cc: Adam Ford 
>>> Cc: Fabio Estevam 
>>> Cc: Ludwig Zenz 
>>> Cc: Peng Fan 
>>> Cc: Stefano Babic 
>>> Cc: Vagrant Cascadian 
>>> ---
>>>  drivers/usb/host/ehci-mx5.c | 17 +
>>>  1 file changed, 17 insertions(+)
>>>
>>> diff --git a/drivers/usb/host/ehci-mx5.c
>>> b/drivers/usb/host/ehci-mx5.c index 0b32728c57..4db513f4e5 100644
>>> --- a/drivers/usb/host/ehci-mx5.c
>>> +++ b/drivers/usb/host/ehci-mx5.c
>>> @@ -301,6 +301,22 @@ static int ehci_usb_ofdata_to_platdata(struct
>>> udevice *dev) return 0;
>>>  }
>>>  
>>> +static int ehci_usb_bind(struct udevice *dev)
>>> +{
>>> +   static int num_controllers;
>>> +
>>> +   /*
>>> +* Without this hack, if we return ENODEV for USB
>>> Controller 0, on
>>> +* probe for the next controller, USB Controller 1 will be
>>> given a
>>> +* sequence number of 0. This conflicts with our
>>> requirement of
>>> +* sequence numbers while initialising the peripherals.
>>> +*/
>>> +   dev->req_seq = num_controllers;
>>> +   num_controllers++;
>>> +
>>> +   return 0;
>>> +}
>>> +
>>>  static int ehci_usb_probe(struct udevice *dev)
>>>  {
>>> struct usb_platdata *plat = dev_get_platdata(dev);
>>> @@ -362,6 +378,7 @@ U_BOOT_DRIVER(usb_mx5) = {
>>> .id = UCLASS_USB,
>>> .of_match = mx5_usb_ids,
>>> .ofdata_to_platdata = ehci_usb_ofdata_to_platdata,
>>> +   .bind   = ehci_usb_bind,
>>> .probe  = ehci_usb_probe,
>>> .remove = ehci_deregister,
>>> .ops= _usb_ops,  
>>
>> Tested-by: Lukasz Majewski 
>>
>> Tested on HSC|DDC i.MX53 board (usb start works as previously).
>>
> 
> Gentle ping on this patch :-)

I think this approach doesn't work, there was a discussion about this
under a patch like this for ehci-mx6.c . Take a look at the patches for
the ehci-mx6.c in mainline and replicate the approach, or even better,
solve the TODO there altogether.

[...]


Re: [PATCH v2 10/21] arm: socfpga: Add secure register access helper functions for SoC 64bits

2020-02-25 Thread Marek Vasut
On 2/24/20 3:21 AM, Ang, Chee Hong wrote:
[...]

> Currently, we have like 20+ secure registers allowed access by
> drivers running in non-secure mode (U-Boot proper / Linux).
> I don't think we want to define and maintain those high level
> interfaces for each of those secure register accesses in ATF and U-Boot.

 See above.
>>> OK. Then these secure access register should be set up in SPL (EL3).
>>> U-Boot drivers shouldn't access them at all because the driver may be
>>> running in SPL(EL3) and in U-Boot proper (EL2) too.
>>> I can take a look at those drivers accessing secure registers and try
>>> to move/decouple those secure access from U-Boot drivers to SPL (EL3)
>>> then we no longer need those secure register access functions.
>>
>> I think that would be great, no ?
> Since the SDMMC/DWMAC drivers read the device tree to configure the behaviour
> of the hardware via the secure registers. I think it should still be part of 
> the
> driver instead of configuring the hardware in different places. I have 
> proposed
> using ATF's high-level APIs to achieve this when the driver is running in EL2.
> I have already proposed this in other email threads.
> Are you OK with this approach ?

I think something more high level might be a good idea here.


Re: [PATCH v2 01/21] configs: agilex: Remove CONFIG_OF_EMBED

2020-02-25 Thread Marek Vasut
On 2/24/20 3:26 AM, Ang, Chee Hong wrote:
>> On 2/21/20 7:15 PM, Ang, Chee Hong wrote:
 On 2/20/20 6:04 PM, Westergreen, Dalon wrote:

 Please fix your mailer, it makes your reply completely unreadable.

> On Thu, 2020-02-20 at 17:44 +0100, Marek Vasut wrote:
>
> On 2/20/20 3:12 AM, Ang, Chee Hong wrote:
>
> On 2/19/20 1:25 PM,
>
> 
>
> chee.hong@intel.com
>
>  wrote:
>
> From: Chee Hong Ang <
>
> 
>
> chee.hong@intel.com
>
>>
>
>
> CONFIG_OF_EMBED was primarily enabled to support the agilex spl hex
>
> file requirements.  Since this option now produces a warning during
>
> build, and the spl hex can be created using alternate methods,
>
> CONFIG_OF_EMBED is no longer needed.

 OK, so this patch removes functionality.
 Can that functionality be retained ? Or what can be done here?
>>> The functionality is no longer required.
>>
>> Because you always depend on ATF now ?
> No. We have 2 different defconfigs in the patchset, one use ATF one without
> ATF. Both no longer using CONFIG_OF_EMBED and they worked fine.

OK. So how is the .hex file generated now ?


Re: [PATCH] doc: Makefile: remove target refcheckdocs

2020-02-25 Thread Heinrich Schuchardt

On 2/25/20 7:00 PM, Patrick Delaunay wrote:

Remove the target refcheckdocs, based on the missing script
scripts/documentation-file-ref-check.

This script exists in Linux tree but wasn't imported when 'doc' move
to SPHINX in commit 78a88f7930be ("doc: Replace DocBook with
sphinx-based docs")

This patch avoids the error:

make refcheckdocs
/bin/sh: scripts/documentation-file-ref-check: No such file or directory
doc/Makefile:102: recipe for target 'refcheckdocs' failed
make[1]: *** [refcheckdocs] Error 127
Makefile:2094: recipe for target 'refcheckdocs' failed
make: *** [refcheckdocs] Error 2

Signed-off-by: Patrick Delaunay 


When we copy and adjust the missing script we can identify dozens of
documentation errors, see below. So I think we should fix the make
target instead of removing it.

arch/arm/mach-imx/Kconfig: doc/README.mxc_hab
arch/arm/mach-imx/Kconfig: doc/README.mxc_hab
board/advantech/dms-ba16/dms-ba16_1g.cfg: doc/README.imximage
board/advantech/dms-ba16/dms-ba16_2g.cfg: doc/README.imximage
board/aristainetos/aristainetos2.cfg: doc/README.imximage
board/bachmann/ot1200/mx6q_4x_mt41j128.cfg: doc/README.imximage
board/barco/titanium/imximage.cfg: doc/README.imximage
board/boundary/nitrogen6x/nitrogen6dl.cfg: doc/README.imximage
board/boundary/nitrogen6x/nitrogen6dl2g.cfg: doc/README.imximage
board/boundary/nitrogen6x/nitrogen6q.cfg: doc/README.imximage
board/boundary/nitrogen6x/nitrogen6q2g.cfg: doc/README.imximage
board/boundary/nitrogen6x/nitrogen6s.cfg: doc/README.imximage
board/boundary/nitrogen6x/nitrogen6s1g.cfg: doc/README.imximage
board/ccv/xpress/imximage.cfg: doc/README.imximage
board/cobra5272/README: u-boot-x-x-x/doc/README.COBRA5272
board/freescale/imx8qxp_mek/imximage.cfg: doc/README.imx8image
board/freescale/m52277evb/README: doc/README.m52277evb
board/freescale/m53017evb/README: doc/README.m53017evb
board/freescale/m5373evb/README: doc/README.m5373evb
board/freescale/m54455evb/README: doc/README.m54455evb
board/freescale/m547xevb/README: doc/README.m5475evb
board/freescale/mx25pdk/imximage.cfg: doc/README.imximage
board/freescale/mx51evk/imximage.cfg: doc/README.imximage
board/freescale/mx53ard/imximage_dd3.cfg: doc/README.imximage
board/freescale/mx53evk/imximage.cfg: doc/README.imximage
board/freescale/mx53loco/imximage.cfg: doc/README.imximage
board/freescale/mx53smd/imximage.cfg: doc/README.imximage
board/freescale/mx6qarm2/imximage.cfg: doc/README.imximage
board/freescale/mx6qarm2/imximage_mx6dl.cfg: doc/README.imximage
board/freescale/mx6slevk/imximage.cfg: doc/README.imximage
board/freescale/mx6ullevk/imximage.cfg: doc/README.imximage
board/freescale/mx7dsabresd/imximage.cfg: doc/README.imximage
board/freescale/s32v234evb/s32v234evb.cfg: doc/README.imximage
board/freescale/vf610twr/imximage.cfg: doc/README.imximage
board/ge/bx50v3/bx50v3.cfg: doc/README.imximage
board/ge/mx53ppd/imximage.cfg: doc/README.imximage
board/menlo/m53menlo/imximage.cfg: doc/README.imximage
board/phytec/pcm052/imximage.cfg: doc/README.imximage
board/seco/mx6quq7/mx6quq7-2g.cfg: doc/README.imximage
board/siemens/capricorn/imximage.cfg: doc/README.imx8image
board/technexion/pico-imx6ul/imximage.cfg: doc/README.imximage
board/toradex/apalis-imx8/apalis-imx8qm-imximage.cfg: doc/README.imx8image
board/toradex/colibri-imx6ull/imximage.cfg: doc/README.imximage
board/toradex/colibri-imx8x/colibri-imx8qxp-imximage.cfg:
doc/README.imx8image
board/toradex/colibri_imx7/imximage.cfg: doc/README.imximage
board/toradex/colibri_vf/imximage.cfg: doc/README.imximage
board/tqc/tqma6/clocks.cfg: doc/README.imximage
board/tqc/tqma6/tqma6dl.cfg: doc/README.imximage
board/tqc/tqma6/tqma6q.cfg: doc/README.imximage
board/tqc/tqma6/tqma6s.cfg: doc/README.imximage
board/warp/imximage.cfg: doc/README.imximage
board/warp7/imximage.cfg: doc/README.imximage
cmd/Kconfig: doc/README.beddbug
doc/README.drivers.eth: doc/driver-model/README.txt
doc/README.fdt-control: doc/driver-model/README.txt
doc/device-tree-bindings/net/ti,dp83867.txt:
doc/devicetree/bindings/net/ethernet.txt
doc/device-tree-bindings/video/rockchip-lvds.txt:
doc/devicetree/device-tree-bindings/video/display-timing.txt
doc/imx/misc/sdp.txt: doc/README.imximage
doc/sphinx/parse-headers.pl: doc/doc-guide/parse-headers.rst
doc/sphinx/rstFlatTable.py: doc/books/kernel-doc-HOWTO
drivers/i2c/davinci_i2c.c: doc/driver-model/i2c-howto.txt
drivers/i2c/kona_i2c.c: doc/driver-model/i2c-howto.txt
drivers/i2c/sh_i2c.c: doc/driver-model/i2c-howto.txt
drivers/i2c/soft_i2c.c: doc/driver-model/i2c-howto.txt
drivers/rtc/ds1374.c: Watchdoc/Alarm
include/ata.h: ftp://ftp.fee.vutbr.cz/pub/doc/io/ata/ata-3/ata3r5v.zip
include/configs/sbc8548.h: doc/README.sbc8548
include/fsl_qe.h: doc/README.qe_firmware
lib/zlib/trees.c: ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
tools/dtoc/dtb_platdata.py: doc/driver-model/of-plat.txt
tools/dtoc/dtoc.py: doc/driver-model/of-plat.txt

Best regards

Heinrich


[PATCH v3] doc: add board documentation for stm32mp1

2020-02-25 Thread Patrick Delaunay
Change plain test README to rst format and move this file
in documentation directory.

Signed-off-by: Patrick Delaunay 
Tested-by: Heinrich Schuchardt 
Reviewed-by: Patrice Chotard 
---
Hi,

it is V3 for the previous patch
http://patchwork.ozlabs.org/patch/1239891/

I check output with
$> make pdfdocs
$> make htmldocs

Patrick

Changes in v3:
- Add a empty line before some 'bullet list' to avoid bold in
  the pdf generated with 'make pdfdocs'

Changes in v2:
- remove extra line at the end of the rst file
- rebase after stm32 custodian pull request
- update MAINTAINERS file for doc/board/st

 MAINTAINERS   |   1 +
 board/st/stm32mp1/README  | 520 +---
 doc/board/index.rst   |   1 +
 doc/board/st/index.rst|   9 +
 doc/board/st/stm32mp1.rst | 611 ++
 5 files changed, 623 insertions(+), 519 deletions(-)
 create mode 100644 doc/board/st/index.rst
 create mode 100644 doc/board/st/stm32mp1.rst

diff --git a/MAINTAINERS b/MAINTAINERS
index 82e4159bec..4d297ae97f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -345,6 +345,7 @@ L:  uboot-st...@st-md-mailman.stormreply.com (moderated for 
non-subscribers)
 T: git https://gitlab.denx.de/u-boot/custodians/u-boot-stm.git
 S: Maintained
 F: arch/arm/mach-stm32mp/
+F: doc/board/st/
 F: drivers/adc/stm32-adc*
 F: drivers/clk/clk_stm32mp1.c
 F: drivers/gpio/stm32_gpio.c
diff --git a/board/st/stm32mp1/README b/board/st/stm32mp1/README
index 5d7465a8c8..8172d26a66 100644
--- a/board/st/stm32mp1/README
+++ b/board/st/stm32mp1/README
@@ -1,519 +1 @@
-SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
-#
-# Copyright (C) 2018 STMicroelectronics - All Rights Reserved
-#
-
-U-Boot on STMicroelectronics STM32MP15x
-===
-
-1. Summary
-==
-This is a quick instruction for setup stm32mp1 boards.
-
-2. Supported devices
-
-U-Boot supports STMP32MP15x SoCs: STM32MP157, STM32MP153 and STM32MP151
-
-The STM32MP15x is a Cortex-A MPU aimed at various applications.
-It features:
-- Dual core Cortex-A7 application core (Single on STM32MP151)
-- 2D/3D image composition with GPU (only on STM32MP157)
-- Standard memories interface support
-- Standard connectivity, widely inherited from the STM32 MCU family
-- Comprehensive security support
-
-Everything is supported in Linux but U-Boot is limited to:
-1. UART
-2. SDCard/MMC controller (SDMMC)
-3. NAND controller (FMC)
-4. NOR controller (QSPI)
-5. USB controller (OTG DWC2)
-6. Ethernet controller
-
-And the necessary drivers
-1. I2C
-2. STPMIC1 (PMIC and regulator)
-3. Clock, Reset, Sysreset
-4. Fuse
-
-Currently the following boards are supported:
-+ stm32mp157a-avenger96.dts
-+ stm32mp157a-dk1.dts
-+ stm32mp157c-dk2.dts
-+ stm32mp157c-ed1.dts
-+ stm32mp157c-ev1.dts
-
-3. Boot Sequences
-=
-
-BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel)
-
-with FSBL = First Stage Bootloader
- SSBL = Second Stage Bootloader
-
-3 boot configurations are supported:
-
-1) The "Trusted" boot chain (defconfig_file : stm32mp15_trusted_defconfig)
-   BootRom => FSBL = Trusted Firmware-A (TF-A) => SSBL = U-Boot
-   TF-A performs a full initialization of Secure peripherals and installs a
-   secure monitor.
-   U-Boot is running in normal world and uses TF-A monitor
-   to access to secure resources.
-
-2) The "Trusted" boot chain with OP-TEE
-   (defconfig_file : stm32mp15_optee_defconfig)
-   BootRom => FSBL = Trusted Firmware-A (TF-A) => SSBL = U-Boot
-   TF-A performs a full initialization of Secure peripherals and installs 
OP-TEE
-   from specific partitions (teeh, teed, teex).
-   U-Boot is running in normal world and uses OP-TEE monitor to access
-   to secure resources.
-
-3) The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig)
-   BootRom => FSBL = U-Boot SPL => SSBL = U-Boot
-   SPL has limited security initialisation
-   U-Boot is running in secure mode and provide a secure monitor to the kernel
-   with only PSCI support (Power State Coordination Interface defined by ARM).
-
-All the STM32MP15x boards supported by U-Boot use the same generic board
-stm32mp1 which support all the bootable devices.
-
-Each board is configurated only with the associated device tree.
-
-4. Device Tree Selection
-
-
-You need to select the appropriate device tree for your board,
-the supported device trees for stm32mp157 are:
-
-+ ev1: eval board with pmic stpmic1 (ev1 = mother board + daughter ed1)
-  dts: stm32mp157c-ev1
-
-+ ed1: daughter board with pmic stpmic1
-  dts: stm32mp157c-ed1
-
-+ dk1: Discovery board
-  dts: stm32mp157a-dk1
-
-+ dk2: Discovery board = dk1 with a BT/WiFI combo and a DSI panel
-  dts: stm32mp157c-dk2
-
-+ avenger96: Avenger96 board from Arrow Electronics
-  dts: stm32mp157a-avenger96
-
-5. Build Procedure
-==
-
-1. Install required tools for U-Boot
-
-   + install package needed in U-Boot 

[PATCH] doc: Makefile: remove target refcheckdocs

2020-02-25 Thread Patrick Delaunay
Remove the target refcheckdocs, based on the missing script
scripts/documentation-file-ref-check.

This script exists in Linux tree but wasn't imported when 'doc' move
to SPHINX in commit 78a88f7930be ("doc: Replace DocBook with
sphinx-based docs")

This patch avoids the error:

make refcheckdocs
/bin/sh: scripts/documentation-file-ref-check: No such file or directory
doc/Makefile:102: recipe for target 'refcheckdocs' failed
make[1]: *** [refcheckdocs] Error 127
Makefile:2094: recipe for target 'refcheckdocs' failed
make: *** [refcheckdocs] Error 2

Signed-off-by: Patrick Delaunay 
---

 doc/Makefile | 4 
 1 file changed, 4 deletions(-)

diff --git a/doc/Makefile b/doc/Makefile
index 0e0da5666f..2ef0be7c9b 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -98,9 +98,6 @@ endif # HAVE_SPHINX
 # The following targets are independent of HAVE_SPHINX, and the rules should
 # work or silently pass without Sphinx.
 
-refcheckdocs:
-   $(Q)cd $(srctree);scripts/documentation-file-ref-check
-
 cleandocs:
$(Q)rm -rf $(BUILDDIR)
$(Q)$(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=doc/media clean
@@ -113,7 +110,6 @@ dochelp:
@echo  '  epubdocs- EPUB'
@echo  '  xmldocs - XML'
@echo  '  linkcheckdocs   - check for broken external links (will 
connect to external hosts)'
-   @echo  '  refcheckdocs- check for references to non-existing files 
under Documentation'
@echo  '  cleandocs   - clean all generated files'
@echo
@echo  '  make SPHINXDIRS="s1 s2" [target] Generate only docs of folder 
s1, s2'
-- 
2.17.1



[PATCH 1/1] vexpress_ca9x4: Enable use of correct DTB file and restore EFI loader.

2020-02-25 Thread Kristian Amlie
EFI was disabled in f95b8a4b5f64f because of the missing DTB file,
and indeed, the DTB file is required to load recent versions of GRUB
(2.04) correctly.

Signed-off-by: Kristian Amlie 
---
 configs/vexpress_ca9x4_defconfig  | 2 +-
 include/configs/vexpress_common.h | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/configs/vexpress_ca9x4_defconfig b/configs/vexpress_ca9x4_defconfig
index 2119df6b10..6bd1f253b6 100644
--- a/configs/vexpress_ca9x4_defconfig
+++ b/configs/vexpress_ca9x4_defconfig
@@ -34,4 +34,4 @@ CONFIG_SMC911X_32_BIT=y
 CONFIG_BAUDRATE=38400
 CONFIG_CONS_INDEX=0
 CONFIG_OF_LIBFDT=y
-# CONFIG_EFI_LOADER is not set
+CONFIG_DEFAULT_FDT_FILE="vexpress-v2p-ca9.dtb"
diff --git a/include/configs/vexpress_common.h 
b/include/configs/vexpress_common.h
index 7f215a6707..e73658a9e6 100644
--- a/include/configs/vexpress_common.h
+++ b/include/configs/vexpress_common.h
@@ -207,7 +207,8 @@
"devtmpfs.mount=0  vmalloc=256M\0" \
"bootflash=run flashargs; " \
"cp ${ramdisk_addr} ${ramdisk_addr_r} ${maxramdisk}; " \
-   "bootm ${kernel_addr} ${ramdisk_addr_r}\0"
+   "bootm ${kernel_addr} ${ramdisk_addr_r}\0" \
+   "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0"
 
 /* FLASH and environment organization */
 #define PHYS_FLASH_SIZE0x0400  /* 64MB */
-- 
2.17.1



Re: [PATCH] watchdog: mpc8xx: Revert the 8xx watchdog back to CONFIG_HW_WATCHDOG

2020-02-25 Thread Tom Rini
On Thu, Feb 20, 2020 at 07:39:51AM +, Christophe Leroy wrote:

> Commit f3729ba6e7b2 ("watchdog: mpc8xx_wdt: Watchdog driver and macros
> cleanup") switched the watchdog to CONFIG_WATCHDOG. But this is not
> compatible with the 8xx because it starts the watchdog HW timer at
> reset and must be serviced from the very beginning including while
> U-boot is executed in the firmware before relocation in RAM.
> 
> Select CONFIG_HW_WATCHDOG and make hw_watchdog_reset() visible.
> 
> Meanwhile, finalise the cleanup of arch/powerpc/cpu/mpc8xx/Kconfig by
> removing the lines put in comment in that commit, and also remove
> again the selection of CONFIG_MPC8xx_WATCHDOG which was removed by
> that commit and brought back by mistake by commit b3134ffbd944
> ("watchdog: Kconfig: Sort entry alphabetically")
> 
> Note that there was an 'imply WATCHDOG' in the original commit but
> it disappeared in the Kconfig alphabetical sorting, so no need to
> remove it here.
> 
> Fixes: f3729ba6e7b2 ("watchdog: mpc8xx_wdt: Watchdog driver and macros 
> cleanup")
> Fixes: b3134ffbd944 ("watchdog: Kconfig: Sort entry alphabetically")
> Signed-off-by: Christophe Leroy 
> Cc: Stefan Roese 
> Cc: Patrice Chotard 
> Reviewed-by: Stefan Roese 

Please note that as-is this causes a build failure:
+(MCR3000) In file included from ../arch/powerpc/cpu/mpc8xx/cpu.c:23:0:
+(MCR3000) ../include/watchdog.h:32:4: error: #error "Configuration error: 
CONFIG_HW_WATCHDOG and CONFIG_WATCHDOG can't be used together."
+(MCR3000)  #  error "Configuration error: CONFIG_HW_WATCHDOG and 
CONFIG_WATCHDOG can't be used  together."
+(MCR3000) ^
+(MCR3000) make[2]: *** [arch/powerpc/cpu/mpc8xx/cpu.o] Error 1
+(MCR3000) make[1]: *** [arch/powerpc/cpu/mpc8xx] Error 2
+(MCR3000) make: *** [sub-make] Error 2

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] env: Make mmc as default option for CONFIG_ENV_FAT_INTERFACE

2020-02-25 Thread Michal Simek
All configs are using mmc as default fat interface. That's why make it
default for everybody.
The reason for this patch is to make it default for Xilinx Zynq platform
which is not listed there.

Signed-off-by: Michal Simek 
---

Defconfig resync will remove some lines when this patch is applied.
---
 env/Kconfig | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/env/Kconfig b/env/Kconfig
index 2d972a5d4f34..8ab7be11c5be 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -404,8 +404,7 @@ config SYS_REDUNDAND_ENVIRONMENT
 config ENV_FAT_INTERFACE
string "Name of the block device for the environment"
depends on ENV_IS_IN_FAT
-   default "mmc" if ARCH_SUNXI
-   default "mmc" if TI_COMMON_CMD_OPTIONS || ARCH_ZYNQMP || ARCH_AT91
+   default "mmc"
help
  Define this to a string that is the name of the block device.
 
-- 
2.25.1



[PATCH 3/4] ARM: zynq: Do not report NOR flash detection failure

2020-02-25 Thread Michal Simek
With multi defconfig targeting several board configurations bug report like
below is so verbose.
Flash: ## Unknown flash on Bank 1 - Size = 0x = 0 MB
0 Bytes

Do not report that message and simply say "Flash: 0 Bytes" because most of
Zynq boards are using different type of flashes than NOR.

Signed-off-by: Michal Simek 
---

 include/configs/zynq-common.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h
index b1cef4d4695f..33fac35f6e32 100644
--- a/include/configs/zynq-common.h
+++ b/include/configs/zynq-common.h
@@ -51,6 +51,7 @@
 # define CONFIG_SYS_FLASH_WRITE_TOUT   5000
 # define CONFIG_FLASH_SHOW_PROGRESS10
 # undef CONFIG_SYS_FLASH_EMPTY_INFO
+# define CONFIG_SYS_FLASH_QUIET_TEST
 #endif
 
 #ifdef CONFIG_NAND_ZYNQ
-- 
2.25.1



[PATCH 2/4] nand: raw: zynq: Do not try to probe driver if nand flash is disabled

2020-02-25 Thread Michal Simek
There is no reason to continue when DT status property indicates that NAND
flash is disabled. But that means that NOR flash should be present that's
why try it find it out.

Signed-off-by: Michal Simek 
---

 drivers/mtd/nand/raw/zynq_nand.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/mtd/nand/raw/zynq_nand.c b/drivers/mtd/nand/raw/zynq_nand.c
index 703914969289..0aea83dac0e6 100644
--- a/drivers/mtd/nand/raw/zynq_nand.c
+++ b/drivers/mtd/nand/raw/zynq_nand.c
@@ -1090,6 +1090,11 @@ static int zynq_nand_probe(struct udevice *dev)
return -ENODEV;
}
 
+   if (!ofnode_is_available(of_nand)) {
+   debug("Nand node in dt disabled\n");
+   return dm_scan_fdt_dev(dev);
+   }
+
if (ofnode_read_resource(of_nand, 0, )) {
printf("Failed to get nand resource\n");
return -ENODEV;
-- 
2.25.1



[PATCH 1/4] nand: raw: Do not free xnand structure

2020-02-25 Thread Michal Simek
xnand structure is private data structure and it is handled by core and
probe shouldn't touch it.

Signed-off-by: Michal Simek 
---

 drivers/mtd/nand/raw/zynq_nand.c | 20 +---
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/nand/raw/zynq_nand.c b/drivers/mtd/nand/raw/zynq_nand.c
index 28db4153f5e0..703914969289 100644
--- a/drivers/mtd/nand/raw/zynq_nand.c
+++ b/drivers/mtd/nand/raw/zynq_nand.c
@@ -1081,18 +1081,18 @@ static int zynq_nand_probe(struct udevice *dev)
u8 set_feature[4] = {ONDIE_ECC_FEATURE_ENABLE, 0x00, 0x00, 0x00};
unsigned long ecc_cfg;
int ondie_ecc_enabled = 0;
-   int err = -1;
int is_16bit_bw;
 
smc->reg = (struct zynq_nand_smc_regs *)dev_read_addr(dev);
of_nand = dev_read_subnode(dev, "flash@e100");
if (!ofnode_valid(of_nand)) {
printf("Failed to find nand node in dt\n");
-   goto fail;
+   return -ENODEV;
}
+
if (ofnode_read_resource(of_nand, 0, )) {
printf("Failed to get nand resource\n");
-   goto fail;
+   return -ENODEV;
}
 
xnand->nand_base = (void __iomem *)res.start;
@@ -1119,7 +1119,7 @@ static int zynq_nand_probe(struct udevice *dev)
if (is_16bit_bw == NAND_BW_UNKNOWN) {
printf("%s: Unable detect NAND based on MIO settings\n",
   __func__);
-   goto fail;
+   return -EINVAL;
}
 
if (is_16bit_bw == NAND_BW_16BIT)
@@ -1130,13 +1130,13 @@ static int zynq_nand_probe(struct udevice *dev)
/* Initialize the NAND flash interface on NAND controller */
if (zynq_nand_init_nand_flash(mtd, nand_chip->options) < 0) {
printf("%s: nand flash init failed\n", __func__);
-   goto fail;
+   return -EINVAL;
}
 
/* first scan to find the device and get the page size */
if (nand_scan_ident(mtd, 1, NULL)) {
printf("%s: nand_scan_ident failed\n", __func__);
-   goto fail;
+   return -EINVAL;
}
/* Send the command for reading device ID */
nand_chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
@@ -1261,14 +1261,12 @@ static int zynq_nand_probe(struct udevice *dev)
/* Second phase scan */
if (nand_scan_tail(mtd)) {
printf("%s: nand_scan_tail failed\n", __func__);
-   goto fail;
+   return -EINVAL;
}
if (nand_register(0, mtd))
-   goto fail;
+   return -EINVAL;
+
return 0;
-fail:
-   free(xnand);
-   return err;
 }
 
 static const struct udevice_id zynq_nand_dt_ids[] = {
-- 
2.25.1



[PATCH 4/4] ARM: zynq: Enable DM for CFI NOR flash

2020-02-25 Thread Michal Simek
With multi defconfig NOR flash information about NOR should be taken from
DT that's why there is no reason to specify address and sizes via fixed
config.

Signed-off-by: Michal Simek 
---

 configs/xilinx_zynq_virt_defconfig | 1 +
 include/configs/zynq-common.h  | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/configs/xilinx_zynq_virt_defconfig 
b/configs/xilinx_zynq_virt_defconfig
index 2e9f3a0f7508..08b43de103a1 100644
--- a/configs/xilinx_zynq_virt_defconfig
+++ b/configs/xilinx_zynq_virt_defconfig
@@ -61,6 +61,7 @@ CONFIG_MMC_SDHCI_ZYNQ=y
 CONFIG_MTD=y
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_FLASH_CFI_DRIVER=y
+CONFIG_CFI_FLASH=y
 CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
 CONFIG_SYS_FLASH_CFI=y
 CONFIG_MTD_RAW_NAND=y
diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h
index 33fac35f6e32..1eaf65b0a2a1 100644
--- a/include/configs/zynq-common.h
+++ b/include/configs/zynq-common.h
@@ -43,8 +43,6 @@
 
 /* NOR */
 #ifdef CONFIG_MTD_NOR_FLASH
-# define CONFIG_SYS_FLASH_BASE 0xE200
-# define CONFIG_SYS_FLASH_SIZE (16 * 1024 * 1024)
 # define CONFIG_SYS_MAX_FLASH_BANKS1
 # define CONFIG_SYS_MAX_FLASH_SECT 512
 # define CONFIG_SYS_FLASH_ERASE_TOUT   1000
-- 
2.25.1



[PATCH] ARM: zynq: Remove single comment about QSPI

2020-02-25 Thread Michal Simek
Very likely configs have been moved to Kconfig by scripts and this just
remains there that's why remove it.

Signed-off-by: Michal Simek 
---

 include/configs/zynq-common.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h
index 2d53237df433..b1cef4d4695f 100644
--- a/include/configs/zynq-common.h
+++ b/include/configs/zynq-common.h
@@ -41,8 +41,6 @@
 # define CONFIG_BOOTP_MAY_FAIL
 #endif
 
-/* QSPI */
-
 /* NOR */
 #ifdef CONFIG_MTD_NOR_FLASH
 # define CONFIG_SYS_FLASH_BASE 0xE200
-- 
2.25.1



Re: [PATCH v2 4/5] azure: build HTML documentation

2020-02-25 Thread Tom Rini
On Fri, Feb 21, 2020 at 06:24:02PM +0100, Heinrich Schuchardt wrote:

> Several patches delivered incorrect restructured text as documentation. We
> should be able to discover this in Azure CI.
> 
> Provide a build step for 'make htmldocs'.
> 
> Signed-off-by: Heinrich Schuchardt 
> Reviewed-by: Bin Meng 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 3/5] gitlab: build HTML documentation

2020-02-25 Thread Tom Rini
On Fri, Feb 21, 2020 at 06:24:01PM +0100, Heinrich Schuchardt wrote:

> Several patches delivered incorrect restructured text as documentation. We
> should be able to discover this in Gitlab CI.
> 
> Provide a build step for 'make htmldocs'.
> 
> Signed-off-by: Heinrich Schuchardt 
> Reviewed-by: Bin Meng 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 5/5] doc/Makefile: turn warnings into errors

2020-02-25 Thread Tom Rini
On Fri, Feb 21, 2020 at 06:24:03PM +0100, Heinrich Schuchardt wrote:

> Several patches delivered incorrect restructured text as documentation. We
> should be able to discover this in Travis CI, Gitlab CI, or Azure CI.
> 
> So let us turn all build warnings into errors.
> 
> Signed-off-by: Heinrich Schuchardt 
> Reviewed-by: Bin Meng 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 2/5] travis: build HTML docs

2020-02-25 Thread Tom Rini
On Fri, Feb 21, 2020 at 06:24:00PM +0100, Heinrich Schuchardt wrote:

> Several patches delivered incorrect restructured text as documentation.
> We should be able to discover this in Travis CI.
> 
> Provide a build step for 'make htmldocs'.
> 
> Add required package graphviz.
> 
> Signed-off-by: Heinrich Schuchardt 
> Reviewed-by: Bin Meng 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] Azure / GitLab: Update Docker image

2020-02-25 Thread Tom Rini
On Mon, Feb 24, 2020 at 11:04:58AM -0500, Tom Rini wrote:

> Bring in a newer Docker image to build on that has everything required
> for running 'make htmldocs'.
> 
> Signed-off-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 1/5] doc: update doc/sphinx/kerneldoc.py

2020-02-25 Thread Tom Rini
On Fri, Feb 21, 2020 at 06:23:59PM +0100, Heinrich Schuchardt wrote:

> Update doc/sphinx/kerneldoc.py from Linux next-20200219 to avoid warnings
> like:
> 
> doc/sphinx/kerneldoc.py:125: RemovedInSphinx20Warning:
> AutodocReporter is now deprecated. Use
> sphinx.util.docutils.switch_source_input() instead.
>   self.state.memo.reporter =
>   AutodocReporter(result, self.state.memo.reporter)
> 
> Signed-off-by: Heinrich Schuchardt 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 4/5] dt-bindings: pinctrl: add i.MXRT1020 pins definition

2020-02-25 Thread Giulio Benetti

On 2/20/20 11:51 PM, Lukasz Majewski wrote:

On Tue, 18 Feb 2020 20:02:54 +0100
Giulio Benetti  wrote:


Add i.MXRT1020 pins definition.


Are those definitions ported from Linux kernel?



Signed-off-by: Giulio Benetti 
---
  include/dt-bindings/pinctrl/pins-imxrt1020.h | 763
+++ 1 file changed, 763 insertions(+)
  create mode 100644 include/dt-bindings/pinctrl/pins-imxrt1020.h

diff --git a/include/dt-bindings/pinctrl/pins-imxrt1020.h
b/include/dt-bindings/pinctrl/pins-imxrt1020.h new file mode 100644
index 00..c6bacb7378
--- /dev/null
+++ b/include/dt-bindings/pinctrl/pins-imxrt1020.h
@@ -0,0 +1,763 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2020
+ * Author(s): Giulio Benetti 
+ */
+
+#ifndef _DT_BINDINGS_PINCTRL_IMXRT1020_PINFUNC_H
+#define _DT_BINDINGS_PINCTRL_IMXRT1020_PINFUNC_H
+
+/* TODO: continue from LPI2C4_SDA_SELECT_INPUT */


This line ^^ must be removed, it's only a comment to remind me, is 
it possible to remove it when applying? Or do I need to send a v2?


Best regards
--
Giulio Benetti
Benetti Engineering sas


+
+#define IMX_PAD_SION   0x4000
+
+/*
+ * The pin function ID is a tuple of
+ * 
+ */
+
+#define MXRT1020_IOMUXC_GPIO_EMC_00_SEMC_DA00
0x014 0x188 0x000 0x0 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_00_QTIMER2_TIMER0
0x014 0x188 0x420 0x1 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_00_LPUART4_CTS_B
0x014 0x188 0x3E0 0x2 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_00_SPDIF_SR_CLK0x014
0x188 0x000 0x3 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_00_LPSPI2_SCK
0x014 0x188 0x3B0 0x4 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_00_GPIO2_IO00
0x014 0x188 0x000 0x5 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_00_FLEXCAN1_TX
0x014 0x188 0x000 0x6 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_00_PIT_TRIGGER02
0x014 0x188 0x000 0x7 0x0 + +#define
MXRT1020_IOMUXC_GPIO_EMC_01_SEMC_DA01
0x018 0x18C 0x000 0x0 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_01_QTIMER2_TIMER1
0x018 0x18C 0x424 0x1 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_01_LPUART4_RTS_B
0x018 0x18C 0x000 0x2 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_01_SPDIF_OUT
0x018 0x18C 0x000 0x3 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_01_LPSPI2_PCS0
0x018 0x18C 0x3AC 0x4 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_01_GPIO2_IO01
0x018 0x18C 0x000 0x5 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_01_FLEXCAN1_RX
0x018 0x18C 0x320 0x6 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_01_PIT_TRIGGER03
0x018 0x18C 0x000 0x7 0x0 + +#define
MXRT1020_IOMUXC_GPIO_EMC_02_SEMC_DA02
0x01C 0x190 0x000 0x0 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_02_QTIMER2_TIMER2
0x01C 0x190 0x428 0x1 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_02_LPUART4_TX
0x01C 0x190 0x3E8 0x2 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_02_SPDIF_LOCK
0x01C 0x190 0x000 0x3 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_02_LPSPI2_SDO
0x01C 0x190 0x3B8 0x4 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_02_GPIO2_IO02
0x01C 0x190 0x000 0x5 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_02_LPI2C1_SCL
0x01C 0x190 0x37C 0x6 0x0 + +#define
MXRT1020_IOMUXC_GPIO_EMC_03_SEMC_DA03
0x020 0x194 0x000 0x0 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_03_QTIMER2_TIMER3
0x020 0x194 0x42C 0x1 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_03_LPUART4_RX
0x020 0x194 0x3E4 0x2 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_03_SPDIF_EXT_CLK
0x020 0x194 0x000 0x3 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_03_LPSPI2_SDI
0x020 0x194 0x3B4 0x4 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_03_GPIO2_IO03
0x020 0x194 0x000 0x5 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_03_LPI2C1_SDA
0x020 0x194 0x380 0x6 0x1 + +#define
MXRT1020_IOMUXC_GPIO_EMC_04_SEMC_DA04
0x024 0x198 0x000 0x0 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_04_XBAR1_INOUT04
0x024 0x198 0x000 0x1 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_04_SPDIF_OUT
0x024 0x198 0x000 0x2 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_04_SAI2_TX_BCLK0x024
0x198 0x464 0x3 0x1 +#define
MXRT1020_IOMUXC_GPIO_EMC_04_FLEXIO1_FLEXIO16
0x024 0x198 0x000 0x4 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_04_GPIO2_IO04
0x024 0x198 0x000 0x5 0x0 + +#define
MXRT1020_IOMUXC_GPIO_EMC_05_SEMC_DA05
0x028 0x19C 0x000 0x0 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_05_XBAR1_INOUT05
0x028 0x19C 0x000 0x1 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_05_SPDIF_IN
0x028 0x19C 0x488 0x2 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_05_SAI2_TX_SYNC0x028
0x19C 0x468 0x3 0x1 +#define
MXRT1020_IOMUXC_GPIO_EMC_05_FLEXIO1_FLEXIO17
0x028 0x19C 0x000 0x4 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_05_GPIO2_IO05
0x028 0x19C 0x000 0x5 0x0 + +#define
MXRT1020_IOMUXC_GPIO_EMC_06_SEMC_DA06
0x02C 0x1A0 0x000 0x0 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_06_XBAR1_INOUT06
0x02C 0x1A0 0x000 0x1 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_06_LPUART3_TX
0x02C 0x1A0 0x3DC 0x2 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_06_SAI2_TX_DATA0x02C
0x1A0 0x000 0x3 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_06_FLEXIO1_FLEXIO18
0x02C 0x1A0 0x000 0x4 0x0 +#define
MXRT1020_IOMUXC_GPIO_EMC_06_GPIO2_IO06
0x02C 0x1A0 0x000 0x5 0x0 + +#define
MXRT1020_IOMUXC_GPIO_EMC_07_SEMC_DA07
0x030 0x1A4 

Re: [PATCH] doc: Chromebook Coral: Fix typo for "Top of CAR region"

2020-02-25 Thread Bin Meng
On Fri, Feb 21, 2020 at 7:20 PM Wolfgang Wallner
 wrote:
>
> The value for "Top of CAR region" should be fefc, not
> fefc000. This matches the Kconfig default values, as
> SYS_CAR_ADDR and SYS_CAR_SIZE are 0xfef0 and 0xc
> respectively.
>
> Signed-off-by: Wolfgang Wallner 
>
> ---
>
>  doc/board/google/chromebook_coral.rst | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Bin Meng 


Re: [PATCH 2/2] x86: apl: Use cpu_x86_get_count() for cpu_ops.get_count

2020-02-25 Thread Bin Meng
On Tue, Feb 25, 2020 at 8:19 PM Wolfgang Wallner
 wrote:
>
> Use cpu_x86_get_count() to read the number of cores.
>
> cpu_x86_get_count() reads the number of CPUs from the device tree.
> Using this function we can support multiple Apollo Lake
> variants, e.g.: E3940 (4 cores) and E3930 (2 cores).
>
> This was tested on the E3940 and E3930 Apollo Lake variants.
>
> Signed-off-by: Wolfgang Wallner 
>
> ---
>
>  arch/x86/cpu/apollolake/cpu.c | 7 +--
>  1 file changed, 1 insertion(+), 6 deletions(-)
>

Reviewed-by: Bin Meng 


Re: [PATCH 1/2] x86: cpu_x86: Make cpu_x86_get_count() non-static

2020-02-25 Thread Bin Meng
On Tue, Feb 25, 2020 at 8:19 PM Wolfgang Wallner
 wrote:
>
> The function cpu_x86_get_count() is also useful for other modules.
> Make it non-static and add a prototype + description.
>
> Signed-off-by: Wolfgang Wallner 
> ---
>
>  arch/x86/cpu/cpu_x86.c |  2 +-
>  arch/x86/include/asm/cpu_x86.h | 12 
>  2 files changed, 13 insertions(+), 1 deletion(-)
>

Reviewed-by: Bin Meng 


[PATCH] configs: stm32mp1: Resync with savedefconfig

2020-02-25 Thread Patrick Delaunay
Rsync all stm32mp1 defconfig files using moveconfig.py

Signed-off-by: Patrick Delaunay 
---

 configs/stm32mp15_basic_defconfig   | 2 +-
 configs/stm32mp15_optee_defconfig   | 2 +-
 configs/stm32mp15_trusted_defconfig | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/configs/stm32mp15_basic_defconfig 
b/configs/stm32mp15_basic_defconfig
index f691306800..6d82365348 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -6,6 +6,7 @@ CONFIG_ENV_OFFSET=0x28
 CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_SPL=y
 CONFIG_TARGET_ST_STM32MP15x=y
+CONFIG_ENV_OFFSET_REDUND=0x2C
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI_SUPPORT=y
 # CONFIG_ARMV7_VIRT is not set
@@ -61,7 +62,6 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_ENV_EXT4_INTERFACE="mmc"
 CONFIG_ENV_EXT4_DEVICE_AND_PART="0:auto"
 CONFIG_ENV_EXT4_FILE="/uboot.env"
-CONFIG_ENV_OFFSET_REDUND=0x2C
 CONFIG_ENV_UBI_PART="UBI"
 CONFIG_ENV_UBI_VOLUME="uboot_config"
 CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
diff --git a/configs/stm32mp15_optee_defconfig 
b/configs/stm32mp15_optee_defconfig
index 521b24e2cb..298611776d 100644
--- a/configs/stm32mp15_optee_defconfig
+++ b/configs/stm32mp15_optee_defconfig
@@ -5,6 +5,7 @@ CONFIG_ENV_SECT_SIZE=0x4
 CONFIG_ENV_OFFSET=0x28
 CONFIG_TARGET_ST_STM32MP15x=y
 CONFIG_STM32MP1_OPTEE=y
+CONFIG_ENV_OFFSET_REDUND=0x2C
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_BOOTCOMMAND="run bootcmd_stm32mp"
@@ -48,7 +49,6 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_ENV_EXT4_INTERFACE="mmc"
 CONFIG_ENV_EXT4_DEVICE_AND_PART="0:auto"
 CONFIG_ENV_EXT4_FILE="/uboot.env"
-CONFIG_ENV_OFFSET_REDUND=0x2C
 CONFIG_ENV_UBI_PART="UBI"
 CONFIG_ENV_UBI_VOLUME="uboot_config"
 CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
diff --git a/configs/stm32mp15_trusted_defconfig 
b/configs/stm32mp15_trusted_defconfig
index c8b328d01a..6928e9a65c 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -4,6 +4,7 @@ CONFIG_SYS_MALLOC_F_LEN=0x3000
 CONFIG_ENV_SECT_SIZE=0x4
 CONFIG_ENV_OFFSET=0x28
 CONFIG_TARGET_ST_STM32MP15x=y
+CONFIG_ENV_OFFSET_REDUND=0x2C
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_BOOTCOMMAND="run bootcmd_stm32mp"
@@ -47,7 +48,6 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_ENV_EXT4_INTERFACE="mmc"
 CONFIG_ENV_EXT4_DEVICE_AND_PART="0:auto"
 CONFIG_ENV_EXT4_FILE="/uboot.env"
-CONFIG_ENV_OFFSET_REDUND=0x2C
 CONFIG_ENV_UBI_PART="UBI"
 CONFIG_ENV_UBI_VOLUME="uboot_config"
 CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
-- 
2.17.1



[PATCH 2/2] x86: apl: Use cpu_x86_get_count() for cpu_ops.get_count

2020-02-25 Thread Wolfgang Wallner
Use cpu_x86_get_count() to read the number of cores.

cpu_x86_get_count() reads the number of CPUs from the device tree.
Using this function we can support multiple Apollo Lake
variants, e.g.: E3940 (4 cores) and E3930 (2 cores).

This was tested on the E3940 and E3930 Apollo Lake variants.

Signed-off-by: Wolfgang Wallner 

---

 arch/x86/cpu/apollolake/cpu.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/x86/cpu/apollolake/cpu.c b/arch/x86/cpu/apollolake/cpu.c
index 3d05c82a5c..aa7a3dbd63 100644
--- a/arch/x86/cpu/apollolake/cpu.c
+++ b/arch/x86/cpu/apollolake/cpu.c
@@ -14,15 +14,10 @@ static int apl_get_info(struct udevice *dev, struct 
cpu_info *info)
return cpu_intel_get_info(info, INTEL_BCLK_MHZ);
 }
 
-static int apl_get_count(struct udevice *dev)
-{
-   return 4;
-}
-
 static const struct cpu_ops cpu_x86_apl_ops = {
.get_desc   = cpu_x86_get_desc,
.get_info   = apl_get_info,
-   .get_count  = apl_get_count,
+   .get_count  = cpu_x86_get_count,
.get_vendor = cpu_x86_get_vendor,
 };
 
-- 
2.25.1




[PATCH 0/2] x86: apl: Add support for different number of cores

2020-02-25 Thread Wolfgang Wallner


Currently the Apollo Lake implementation of cpu_ops.get_count returns
a hardcoded value of 4.

The function cpu_x86_get_count() provides a more generic implementation
that reads the number of cores from device tree. But this function is
currently static.

This series:
 - makes cpu_x86_get_count() non-static
 - drops the Apollo Lake specific get_count implementation and
   uses cpu_x86_get_count() instead

With the changes in this series also Apollo Lake variants with
a different number of cores boot correctly.


Wolfgang Wallner (2):
  x86: cpu_x86: Make cpu_x86_get_count() non-static
  x86: apl: Use cpu_x86_get_count() for cpu_ops.get_count

 arch/x86/cpu/apollolake/cpu.c  |  7 +--
 arch/x86/cpu/cpu_x86.c |  2 +-
 arch/x86/include/asm/cpu_x86.h | 12 
 3 files changed, 14 insertions(+), 7 deletions(-)

-- 
2.25.1




[PATCH 1/2] x86: cpu_x86: Make cpu_x86_get_count() non-static

2020-02-25 Thread Wolfgang Wallner
The function cpu_x86_get_count() is also useful for other modules.
Make it non-static and add a prototype + description.

Signed-off-by: Wolfgang Wallner 
---

 arch/x86/cpu/cpu_x86.c |  2 +-
 arch/x86/include/asm/cpu_x86.h | 12 
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/x86/cpu/cpu_x86.c b/arch/x86/cpu/cpu_x86.c
index 1aaf851bb4..3f2ba0881e 100644
--- a/arch/x86/cpu/cpu_x86.c
+++ b/arch/x86/cpu/cpu_x86.c
@@ -52,7 +52,7 @@ int cpu_x86_get_desc(struct udevice *dev, char *buf, int size)
return 0;
 }
 
-static int cpu_x86_get_count(struct udevice *dev)
+int cpu_x86_get_count(struct udevice *dev)
 {
int node, cpu;
int num = 0;
diff --git a/arch/x86/include/asm/cpu_x86.h b/arch/x86/include/asm/cpu_x86.h
index 19223f2c3b..ae8f4dcd5d 100644
--- a/arch/x86/include/asm/cpu_x86.h
+++ b/arch/x86/include/asm/cpu_x86.h
@@ -30,6 +30,18 @@ int cpu_x86_bind(struct udevice *dev);
  */
 int cpu_x86_get_desc(struct udevice *dev, char *buf, int size);
 
+/**
+ * cpu_x86_get_count() - Get the number of cores for an x86 CPU
+ *
+ * This function is suitable to use as the get_count() method for
+ * the CPU uclass.
+ *
+ * @dev:   Device to check (UCLASS_CPU)
+ * @return:Number of cores if successful,
+ * -ENOENT if not "/cpus" entry is found in the device tree
+ */
+int cpu_x86_get_count(struct udevice *dev);
+
 /**
  * cpu_x86_get_vendor() - Get a vendor string for an x86 CPU
  *
-- 
2.25.1




RE: [PATCH v4 01/14] misc: add driver for the SiFive otp controller

2020-02-25 Thread Pragnesh Patel
Hi Patrick,

>-Original Message-
>From: Patrick DELAUNAY 
>Sent: 24 February 2020 23:34
>To: Pragnesh Patel ; u-boot@lists.denx.de
>Cc: atish.pa...@wdc.com; palmerdabb...@google.com;
>bmeng...@gmail.com; Paul Walmsley ( Sifive) ;
>ja...@amarulasolutions.com; Troy Benjegerdes ( Sifive)
>; anup.pa...@wdc.com; Sagar Kadam
>; Simon Glass ; Finley Xiao
>; Marcel Ziswiler
>; Tero Kristo ; Adam Ford
>; Peng Fan ; Eugen Hristev
>; Keerthy 
>Subject: RE: [PATCH v4 01/14] misc: add driver for the SiFive otp controller
>
>Hi,
>
>> From: U-Boot  On Behalf Of Pragnesh
>> Patel
>> Sent: lundi 24 février 2020 09:33
>>
>> Added a misc driver to handle OTP memory in SiFive SoCs.
>>
>> Signed-off-by: Pragnesh Patel 
>> ---
>>  drivers/misc/Kconfig  |   7 ++
>>  drivers/misc/Makefile |   1 +
>>  drivers/misc/sifive-otp.c | 241
>> ++
>>  3 files changed, 249 insertions(+)
>>  create mode 100644 drivers/misc/sifive-otp.c
>>
>> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index
>> f18aa8f7ba..fcb45c63d4 100644
>> --- a/drivers/misc/Kconfig
>> +++ b/drivers/misc/Kconfig
>> @@ -68,6 +68,13 @@ config ROCKCHIP_OTP
>>addressing and a length or through child-nodes that are generated
>>based on the e-fuse map retrieved from the DTS.
>>
>> +config SIFIVE_OTP
>> +bool "SiFive Ememory OTP driver"
>> +depends on RISCV && MISC
>> +help
>> +  Enable support for reading and writing the ememory OTP on the
>> +  SiFive SoCs.
>> +
>>  config VEXPRESS_CONFIG
>>  bool "Enable support for Arm Versatile Express config bus"
>>  depends on MISC
>> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index
>> 2b843de93c..ee888631b6 100644
>> --- a/drivers/misc/Makefile
>> +++ b/drivers/misc/Makefile
>> @@ -58,6 +58,7 @@ obj-$(CONFIG_$(SPL_)PWRSEQ) += pwrseq-uclass.o
>>  obj-$(CONFIG_QFW) += qfw.o
>>  obj-$(CONFIG_ROCKCHIP_EFUSE) += rockchip-efuse.o
>>  obj-$(CONFIG_ROCKCHIP_OTP) += rockchip-otp.o
>> +obj-$(CONFIG_SIFIVE_OTP) += sifive-otp.o
>>  obj-$(CONFIG_SANDBOX) += syscon_sandbox.o misc_sandbox.o
>>  obj-$(CONFIG_SMSC_LPC47M) += smsc_lpc47m.o
>>  obj-$(CONFIG_SMSC_SIO1007) += smsc_sio1007.o diff --git
>> a/drivers/misc/sifive-otp.c b/drivers/misc/sifive-otp.c new file mode
>> 100644 index 00..6a39ec42df
>> --- /dev/null
>> +++ b/drivers/misc/sifive-otp.c
>> @@ -0,0 +1,241 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * This is a driver for the eMemory EG004K32TQ028XW01 NeoFuse
>> + * One-Time-Programmable (OTP) memory used within the SiFive FU540.
>> + * It is documented in the FU540 manual here:
>> + *
>> +https://www.sifive.com/documentation/chips/freedom-u540-c000-
>manual/
>> + *
>> + * Copyright (C) 2018 Philipp Hug 
>> + * Copyright (C) 2018 Joey Hewitt 
>> + *
>> + * Copyright (C) 2020 SiFive, Inc
>> + */
>> +
>> +/*
>> + * The FU540 stores 4096x32 bit (16KiB) values.
>> + * Index 0x00-0xff are reserved for SiFive internal use. (first 1KiB)
>> + * Right now first 1KB is used to store only serial number.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#define BYTES_PER_FUSE  4
>> +
>> +#define PA_RESET_VAL0x00
>> +#define PAS_RESET_VAL   0x00
>> +#define PAIO_RESET_VAL  0x00
>> +#define PDIN_RESET_VAL  0x00
>> +#define PTM_RESET_VAL   0x00
>> +
>> +#define PCLK_ENABLE_VAL BIT(0)
>> +#define PCLK_DISABLE_VAL0x00
>> +
>> +#define PWE_WRITE_ENABLEBIT(0)
>> +#define PWE_WRITE_DISABLE   0x00
>> +
>> +#define PTM_FUSE_PROGRAM_VALBIT(1)
>> +
>> +#define PCE_ENABLE_INPUTBIT(0)
>> +#define PCE_DISABLE_INPUT   0x00
>> +
>> +#define PPROG_ENABLE_INPUT  BIT(0)
>> +#define PPROG_DISABLE_INPUT 0x00
>> +
>> +#define PTRIM_ENABLE_INPUT  BIT(0)
>> +#define PTRIM_DISABLE_INPUT 0x00
>> +
>> +#define PDSTB_DEEP_STANDBY_ENABLE   BIT(0)
>> +#define PDSTB_DEEP_STANDBY_DISABLE  0x00
>> +
>> +struct sifive_otp_regs {
>> +u32 pa; /* Address input */
>> +u32 paio;   /* Program address input */
>> +u32 pas;/* Program redundancy cell selection input */
>> +u32 pce;/* OTP Macro enable input */
>> +u32 pclk;   /* Clock input */
>> +u32 pdin;   /* Write data input */
>> +u32 pdout;  /* Read data output */
>> +u32 pdstb;  /* Deep standby mode enable input (active low) */
>> +u32 pprog;  /* Program mode enable input */
>> +u32 ptc;/* Test column enable input */
>> +u32 ptm;/* Test mode enable input */
>> +u32 ptm_rep;/* Repair function test mode enable input */
>> +u32 ptr;/* Test row enable input */
>> +u32 ptrim;  /* Repair function enable input */
>> +u32 pwe;/* Write enable input (defines program cycle) */
>> +} __packed;
>> +
>> +struct sifive_otp_platdata {
>> +struct sifive_otp_regs __iomem *regs;
>> +u32 

[PATCH] net: zynq_gem: Add cache flush to zynq_gem_free_pkt

2020-02-25 Thread Michal Simek
From: Ashok Reddy Soma 

Add cache flush to zynq_gem_free_pkt. This is necessary
because some net routines would modify this buffer in place.
The cache_invalidate in the zynq_gem_recv function would cause
the modifications to the buffer to overwrite the DMA from the GEM,
if cache coherency is not enabled in the GEM, the next time the
buffer is in use.

Flushing the cache when the buffer is no longer in use by the
net functions ensures that the GEM DMA is going to take place
into a clean buffer.

Signed-off-by: Ashok Reddy Soma 
Signed-off-by: Michal Simek 
---

 drivers/net/zynq_gem.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c
index 5f2f87d352c4..cfd14665a70d 100644
--- a/drivers/net/zynq_gem.c
+++ b/drivers/net/zynq_gem.c
@@ -578,6 +578,7 @@ static int zynq_gem_free_pkt(struct udevice *dev, uchar 
*packet, int length)
struct zynq_gem_priv *priv = dev_get_priv(dev);
struct emac_bd *current_bd = >rx_bd[priv->rxbd_current];
struct emac_bd *first_bd;
+   dma_addr_t addr;
 
if (current_bd->status & ZYNQ_GEM_RXBUF_SOF_MASK) {
priv->rx_first_buf = priv->rxbd_current;
@@ -592,6 +593,17 @@ static int zynq_gem_free_pkt(struct udevice *dev, uchar 
*packet, int length)
first_bd->status = 0xF000;
}
 
+   /* Flush the cache for the packet as well */
+#if defined(CONFIG_PHYS_64BIT)
+   addr = (dma_addr_t)((current_bd->addr & ZYNQ_GEM_RXBUF_ADD_MASK)
+   | ((dma_addr_t)current_bd->addr_hi << 32));
+#else
+   addr = current_bd->addr & ZYNQ_GEM_RXBUF_ADD_MASK;
+#endif
+   flush_dcache_range(addr, addr + roundup(PKTSIZE_ALIGN,
+   ARCH_DMA_MINALIGN));
+   barrier();
+
if ((++priv->rxbd_current) >= RX_BUF)
priv->rxbd_current = 0;
 
-- 
2.25.1



RE: [PATCH v4 02/14] riscv: sifive: fu540: Use OTP DM driver for serial environment variable

2020-02-25 Thread Pragnesh Patel
Hi Patrick,

>-Original Message-
>From: Patrick DELAUNAY 
>Sent: 24 February 2020 23:30
>To: Pragnesh Patel ; u-boot@lists.denx.de
>Cc: atish.pa...@wdc.com; palmerdabb...@google.com;
>bmeng...@gmail.com; Paul Walmsley ( Sifive) ;
>ja...@amarulasolutions.com; Troy Benjegerdes ( Sifive)
>; anup.pa...@wdc.com; Sagar Kadam
>; Rick Chen 
>Subject: RE: [PATCH v4 02/14] riscv: sifive: fu540: Use OTP DM driver for 
>serial
>environment variable
>
>Hi,
>
>Just a warning as I had the same issue with 8729b1ae2cbd ("misc: Update
>read() and write()  methods to return bytes xfered")
>
>> From: U-Boot  On Behalf Of Pragnesh
>> Patel
>> Sent: lundi 24 février 2020 09:33
>>
>> Use the OTP DM driver to set the serial environment variable.
>>
>> Signed-off-by: Pragnesh Patel 
>> ---
>>  arch/riscv/dts/fu540-c000-u-boot.dtsi |  14 +++
>>  .../dts/hifive-unleashed-a00-u-boot.dtsi  |   6 +
>>  board/sifive/fu540/Kconfig|   2 +
>>  board/sifive/fu540/fu540.c| 113 +++---
>>  4 files changed, 62 insertions(+), 73 deletions(-)  create mode
>> 100644 arch/riscv/dts/fu540-c000-u-boot.dtsi
>>  create mode 100644 arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
>>
>> diff --git a/arch/riscv/dts/fu540-c000-u-boot.dtsi
>> b/arch/riscv/dts/fu540-c000-u- boot.dtsi new file mode 100644 index
>> 00..31fd113c7d
>> --- /dev/null
>> +++ b/arch/riscv/dts/fu540-c000-u-boot.dtsi
>> @@ -0,0 +1,14 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +/*
>> + * (C) Copyright 2019 SiFive, Inc
>> + */
>> +
>> +/ {
>> +soc {
>> +otp: otp@1007 {
>> +compatible = "sifive,fu540-otp";
>> +reg = <0x0 0x1007 0x0 0x0FFF>;
>> +fuse-count = <0x1000>;
>> +};
>> +};
>> +};
>> diff --git a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
>> b/arch/riscv/dts/hifive- unleashed-a00-u-boot.dtsi new file mode
>> 100644 index 00..bec0d19134
>> --- /dev/null
>> +++ b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
>> @@ -0,0 +1,6 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +/*
>> + * Copyright (C) 2019 SiFive, Inc
>> + */
>> +
>> +#include "fu540-c000-u-boot.dtsi"
>> diff --git a/board/sifive/fu540/Kconfig b/board/sifive/fu540/Kconfig
>> index
>> 5ca21474de..900197bbb2 100644
>> --- a/board/sifive/fu540/Kconfig
>> +++ b/board/sifive/fu540/Kconfig
>> @@ -48,5 +48,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
>>  imply SIFIVE_GPIO
>>  imply CMD_GPIO
>>  imply SMP
>> +imply MISC
>> +imply SIFIVE_OTP
>>
>>  endif
>> diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c
>> index 47a2090251..409471effc 100644
>> --- a/board/sifive/fu540/fu540.c
>> +++ b/board/sifive/fu540/fu540.c
>> @@ -10,94 +10,61 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>
>> -#ifdef CONFIG_MISC_INIT_R
>> -
>> -#define FU540_OTP_BASE_ADDR 0x1007
>> -
>> -struct fu540_otp_regs {
>> -u32 pa; /* Address input */
>> -u32 paio;   /* Program address input */
>> -u32 pas;/* Program redundancy cell selection input */
>> -u32 pce;/* OTP Macro enable input */
>> -u32 pclk;   /* Clock input */
>> -u32 pdin;   /* Write data input */
>> -u32 pdout;  /* Read data output */
>> -u32 pdstb;  /* Deep standby mode enable input (active low) */
>> -u32 pprog;  /* Program mode enable input */
>> -u32 ptc;/* Test column enable input */
>> -u32 ptm;/* Test mode enable input */
>> -u32 ptm_rep;/* Repair function test mode enable input */
>> -u32 ptr;/* Test row enable input */
>> -u32 ptrim;  /* Repair function enable input */
>> -u32 pwe;/* Write enable input (defines program cycle) */
>> -} __packed;
>> -
>> -#define BYTES_PER_FUSE  4
>> -#define NUM_FUSES   0x1000
>> -
>> -static int fu540_otp_read(int offset, void *buf, int size) -{
>> -struct fu540_otp_regs *regs = (void __iomem
>> *)FU540_OTP_BASE_ADDR;
>> -unsigned int i;
>> -int fuseidx = offset / BYTES_PER_FUSE;
>> -int fusecount = size / BYTES_PER_FUSE;
>> -u32 fusebuf[fusecount];
>> -
>> -/* check bounds */
>> -if (offset < 0 || size < 0)
>> -return -EINVAL;
>> -if (fuseidx >= NUM_FUSES)
>> -return -EINVAL;
>> -if ((fuseidx + fusecount) > NUM_FUSES)
>> -return -EINVAL;
>> -
>> -/* init OTP */
>> -writel(0x01, >pdstb); /* wake up from stand-by */
>> -writel(0x01, >ptrim); /* enable repair function */
>> -writel(0x01, >pce);   /* enable input */
>> -
>> -/* read all requested fuses */
>> -for (i = 0; i < fusecount; i++, fuseidx++) {
>> -writel(fuseidx, >pa);
>> -
>> -/* cycle clock to read */
>> -writel(0x01, >pclk);
>> -mdelay(1);
>> -writel(0x00, >pclk);
>> -mdelay(1);
>> -
>> -/* read the value */
>> -  

Re: [PATCH v2] arm: imx6: configure NoC on i.MX6DQP

2020-02-25 Thread Filip Brozović
On Mon, Feb 24, 2020 at 10:38 AM Bernhard Messerklinger
 wrote:
> My assumption would be that this can be solved by adding "Co-Developed-by:" 
> and
> "Signed-off-by:" lines to this patch for Filip Brozovic (see [1] for a
> discussion of this topic on LKML). Filip, would this be ok for you?

That's fine by me.

Best regards,
Filip Brozovic


RE: [U-Boot Patch v2 3/4] dts: u-boot.dtsi: override flash tx-rx width

2020-02-25 Thread Sagar Kadam
Hello Jagan,

> -Original Message-
> From: Bin Meng 
> Sent: Wednesday, February 19, 2020 9:59 PM
> To: Sagar Kadam 
> Cc: U-Boot Mailing List ; Rick Chen
> ; Paul Walmsley ( Sifive) ;
> Jagan Teki ; Anup Patel
> 
> Subject: Re: [U-Boot Patch v2 3/4] dts: u-boot.dtsi: override flash tx-rx 
> width
> 
> Hi Sagar,
> 
> On Fri, Feb 7, 2020 at 2:43 AM Sagar Kadam 
> wrote:
> >
> > Hello Bin,
> >
> > > -Original Message-
> > > From: Bin Meng 
> > > Sent: Tuesday, February 4, 2020 5:43 PM
> > > To: Sagar Kadam 
> > > Cc: U-Boot Mailing List ; Rick Chen
> > > ; Paul Walmsley ( Sifive)
> > > ; Jagan Teki
> ;
> > > Anup Patel 
> > > Subject: Re: [U-Boot Patch v2 3/4] dts: u-boot.dtsi: override flash
> > > tx-rx width
> > >
> > > Hi Sagar,
> > >
> > > On Wed, Jan 29, 2020 at 2:02 AM Sagar Shrikant Kadam
> > >  wrote:
> > > >
> > > > The hifive-unleashed-a00.dts has flash spi-tx/rx width set to
> > > > 4-bit mode. During sf probe, spi_nor_scan fails to read the JEDEC
> > > > ID with reg_proto set to SNOR_PROTO_1_1_1. Setting it to 1-bit
> > > > mode as of now will help read the JEDEC-ID and perform other flash
> operations.
> > >
> > > So previously with Jagan's series that did not have these changes in
> > > this commit, the flash driver worked well. I wonder what real issue
> > > was fixed in this commit?
> > >
> > Yes true, I had observed that flash device was working with Jagan's
> > series you are indicating here. The flash device was getting probed at cs
> 2/4/6/8 etc..
> > but it couldn't get detected on CS0 which is actually connected on the
> > board to the flash device.
> > With the check of spi->num_cs done in patch 2 of this series or the
> > one handled in commit 7bacce524d48 ("dm: spi: Check cs number before
> > accessing slaves") invalid chip select is taken care of and flash is
> > not detected on wrong chip selects, but spi transfer still fails as
> > the sifive-spi driver set's the SIFIVE_SPI_FMT_PROTO_QUAD mode based
> > on device tree information. While reading Device ID in spi_nor_scan
> > the reg proto is set to 1_1_1 bit mode and this contradicts here in the 
> > driver
> due to which spi_nor_scan fails, due to which one cannot use the flash.
> > So for now I have added this override here to 1 bit mode so that users can
> use it.
> > Maybe I will update the commit message to indicate that this is
> > workaround for a bug in SPI driver for FU540 which currently is not able to
> handle QUAD mode operation.
> > Please let me know your views here.
> >
> 
> Thanks for the details. Based on your description, I think there is something
> wrong with the SPI-NOR driver. Your change to 1 line only seems to be a
> workaround.
> 
> Jagan, would you please comment?
> 

It would be good if you could also share some input's here.

Thanks & BR,
Sagar Kadam

> Regards,
> Bin


  1   2   >