Re: [U-Boot] [PATCH v2 3/3] spi-nor: spi-nor-ids: Add USE_FSR flag for mt25qu512a entry

2019-09-30 Thread Tudor.Ambarus


On 09/27/2019 07:43 AM, Vignesh Raghavendra wrote:
> External E-Mail
> 
> 
> mt25qu512a flash has Flag status register that indicates various errors
> that may be encountered during erase/write operations. Therefore add
> USE_FSR flag to the entry
> 
n25q256 & 512  support flag status register command. Would you add the flag for
them too? mtq256 probably too.

> Signed-off-by: Vignesh Raghavendra 

anyway, looks good:
Reviewed-by: Tudor Ambarus 

> ---
>  drivers/mtd/spi/spi-nor-ids.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c
> index c7b6cf002c54..2e0aebbc44aa 100644
> --- a/drivers/mtd/spi/spi-nor-ids.c
> +++ b/drivers/mtd/spi/spi-nor-ids.c
> @@ -166,7 +166,8 @@ const struct flash_info spi_nor_ids[] = {
>   { INFO6("mt25qu256a",  0x20bb19, 0x104400, 64 * 1024,  512, SECT_4K | 
> SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
>   { INFO("n25q256ax1",  0x20bb19, 0, 64 * 1024,  512, SECT_4K | 
> SPI_NOR_QUAD_READ) },
>   { INFO6("mt25qu512a",  0x20bb20, 0x104400, 64 * 1024, 1024,
> -  SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
> +  SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES |
> +  USE_FSR) },
>   { INFO("n25q512a",0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | 
> SPI_NOR_QUAD_READ) },
>   { INFO6("mt25ql512a",  0x20ba20, 0x104400, 64 * 1024, 1024, SECT_4K | 
> USE_FSR | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
>   { INFO("n25q512ax3",  0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | 
> SPI_NOR_QUAD_READ) },
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH RFT v2 2/3] spi-nor: spi-nor-ids: Add entries for mt25q variants

2019-09-30 Thread Tudor.Ambarus


On 09/27/2019 07:43 AM, Vignesh Raghavendra wrote:
> External E-Mail
> 
> 
> Newer variants of mt25q* flashes support 4 Byte addressing opcodes. Add

nit: "drop newer variants of"

> entries for the same. These flashes have bit 6 set in 5th byte of READ ID
> response.
> 
> Signed-off-by: Vignesh Raghavendra 

Reviewed-by: Tudor Ambarus 

I'm thinking out loud. If just the 6th bit of the 5th byte of the device ID is
the differentiator between the n25q and the mt25q flavors, maybe in future we
should introduce a mask to INFO6. But it's ok for now.

> ---
>  drivers/mtd/spi/spi-nor-ids.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c
> index bb67661b40d2..c7b6cf002c54 100644
> --- a/drivers/mtd/spi/spi-nor-ids.c
> +++ b/drivers/mtd/spi/spi-nor-ids.c
> @@ -161,11 +161,14 @@ const struct flash_info spi_nor_ids[] = {
>   { INFO("n25q064a",0x20bb17, 0, 64 * 1024,  128, SECT_4K | 
> SPI_NOR_QUAD_READ) },
>   { INFO("n25q128a11",  0x20bb18, 0, 64 * 1024,  256, SECT_4K | 
> SPI_NOR_QUAD_READ) },
>   { INFO("n25q128a13",  0x20ba18, 0, 64 * 1024,  256, SECT_4K | 
> SPI_NOR_QUAD_READ) },
> + { INFO6("mt25ql256a",0x20ba19, 0x104400, 64 * 1024,  512, SECT_4K | 
> SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
>   { INFO("n25q256a",0x20ba19, 0, 64 * 1024,  512, SECT_4K | 
> SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
> + { INFO6("mt25qu256a",  0x20bb19, 0x104400, 64 * 1024,  512, SECT_4K | 
> SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
>   { INFO("n25q256ax1",  0x20bb19, 0, 64 * 1024,  512, SECT_4K | 
> SPI_NOR_QUAD_READ) },
>   { INFO6("mt25qu512a",  0x20bb20, 0x104400, 64 * 1024, 1024,
>SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
>   { INFO("n25q512a",0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | 
> SPI_NOR_QUAD_READ) },
> + { INFO6("mt25ql512a",  0x20ba20, 0x104400, 64 * 1024, 1024, SECT_4K | 
> USE_FSR | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
>   { INFO("n25q512ax3",  0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | 
> SPI_NOR_QUAD_READ) },
>   { INFO("n25q00",  0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | 
> SPI_NOR_QUAD_READ | NO_CHIP_ERASE) },
>   { INFO("n25q00a", 0x20bb21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | 
> SPI_NOR_QUAD_READ | NO_CHIP_ERASE) },
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/2] arm: dra7xx: Fix error path in iodelay recalibration

2019-09-30 Thread Lokesh Vutla
When an error is reported in __recalibrate_iodelay_start(), de-isolation
of IO doesn't happen. Because of this, undefined behaviour is observed
on many peripherals without any error. So make sure io is out of isolation
at the end of iodelay recalibration.

Reported-by: Richard Woodruff 
Signed-off-by: Lokesh Vutla 
---
 arch/arm/mach-omap2/omap5/dra7xx_iodelay.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/omap5/dra7xx_iodelay.c 
b/arch/arm/mach-omap2/omap5/dra7xx_iodelay.c
index e2abb7d058..9bd7051786 100644
--- a/arch/arm/mach-omap2/omap5/dra7xx_iodelay.c
+++ b/arch/arm/mach-omap2/omap5/dra7xx_iodelay.c
@@ -202,8 +202,9 @@ void __recalibrate_iodelay_end(int ret)
return;
}
 
-   if (!ret)
-   ret = isolate_io(DEISOLATE_IO);
+   /* Deisolate IO if it is already isolated */
+   if (readl((*ctrl)->ctrl_core_sma_sw_0) & CTRL_ISOLATE_MASK)
+   isolate_io(DEISOLATE_IO);
 
/* lock IODELAY CONFIG registers */
writel(CFG_IODELAY_LOCK_KEY, (*ctrl)->iodelay_config_base +
-- 
2.23.0

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


[U-Boot] [PATCH 2/2] arm: dra7xx: Hang on any failure during IOdelay recalibration

2019-09-30 Thread Lokesh Vutla
If there is any failure during IOdelay recalibration sequence, IOs are
not guaranteed to behave as expected. So hang on any failure during the
sequence.

Signed-off-by: Lokesh Vutla 
---
 arch/arm/mach-omap2/omap5/dra7xx_iodelay.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/mach-omap2/omap5/dra7xx_iodelay.c 
b/arch/arm/mach-omap2/omap5/dra7xx_iodelay.c
index 9bd7051786..9eda57c450 100644
--- a/arch/arm/mach-omap2/omap5/dra7xx_iodelay.c
+++ b/arch/arm/mach-omap2/omap5/dra7xx_iodelay.c
@@ -241,6 +241,12 @@ void __recalibrate_iodelay_end(int ret)
debug("IODELAY: IO delay recalibration successfully 
completed\n");
}
 
+   /* If there is an error during iodelay recalibration, SoC is in a bad
+* state. Do not progress any further.
+*/
+   if (ret)
+   hang();
+
return;
 }
 
-- 
2.23.0

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


Re: [U-Boot] [PATCH RFT v2 1/3] spi-nor: spi-nor-ids: Disable SPI_NOR_4B_OPCODES for n25q512* and n25q256*

2019-09-30 Thread Tudor.Ambarus


On 09/27/2019 07:43 AM, Vignesh Raghavendra wrote:
> External E-Mail
> 
> 
> Older variants of n25q256* and n25q512* do not support 4 Byte stateless

nit: drop "older variants of". Looks like the latest datasheet still require
ENTER and EXIT 4-byte address mode commands.

> addressing opcodes. Therefore drop SPI_NOR_4B_OPCODES flag from these
> entries.
> 
> Signed-off-by: Vignesh Raghavendra 

Reviewed-by: Tudor Ambarus 

> ---
>  drivers/mtd/spi/spi-nor-ids.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c
> index df0643ed1d47..bb67661b40d2 100644
> --- a/drivers/mtd/spi/spi-nor-ids.c
> +++ b/drivers/mtd/spi/spi-nor-ids.c
> @@ -161,12 +161,12 @@ const struct flash_info spi_nor_ids[] = {
>   { INFO("n25q064a",0x20bb17, 0, 64 * 1024,  128, SECT_4K | 
> SPI_NOR_QUAD_READ) },
>   { INFO("n25q128a11",  0x20bb18, 0, 64 * 1024,  256, SECT_4K | 
> SPI_NOR_QUAD_READ) },
>   { INFO("n25q128a13",  0x20ba18, 0, 64 * 1024,  256, SECT_4K | 
> SPI_NOR_QUAD_READ) },
> - { INFO("n25q256a",0x20ba19, 0, 64 * 1024,  512, SECT_4K | 
> SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
> - { INFO("n25q256ax1",  0x20bb19, 0, 64 * 1024,  512, SECT_4K | 
> SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
> + { INFO("n25q256a",0x20ba19, 0, 64 * 1024,  512, SECT_4K | 
> SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
> + { INFO("n25q256ax1",  0x20bb19, 0, 64 * 1024,  512, SECT_4K | 
> SPI_NOR_QUAD_READ) },
>   { INFO6("mt25qu512a",  0x20bb20, 0x104400, 64 * 1024, 1024,
>SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
> - { INFO("n25q512a",0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | 
> SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
> - { INFO("n25q512ax3",  0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | 
> SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
> + { INFO("n25q512a",0x20bb20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | 
> SPI_NOR_QUAD_READ) },
> + { INFO("n25q512ax3",  0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | 
> SPI_NOR_QUAD_READ) },
>   { INFO("n25q00",  0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | 
> SPI_NOR_QUAD_READ | NO_CHIP_ERASE) },
>   { INFO("n25q00a", 0x20bb21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | 
> SPI_NOR_QUAD_READ | NO_CHIP_ERASE) },
>   { INFO("mt25qu02g",   0x20bb22, 0, 64 * 1024, 4096, SECT_4K | USE_FSR | 
> SPI_NOR_QUAD_READ | NO_CHIP_ERASE) },
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 39/41] common: Move trap_init() out of common.h

2019-09-30 Thread Simon Glass
Hi Daniel,

On Mon, 30 Sep 2019 at 09:43, Daniel Schwierzeck
 wrote:
>
> On Mon, Sep 30, 2019 at 5:37 PM Simon Glass  wrote:
> >
> > Hi Daniel,
> >
> > On Mon, 30 Sep 2019 at 09:13, Daniel Schwierzeck
> >  wrote:
> > >
> > > On Mon, Sep 30, 2019 at 4:58 PM Simon Glass  wrote:
> > > >
> > > > Move this function into the irq_legacy.h header file.
> > > >
> > > > Signed-off-by: Simon Glass 
> > > > ---
> > > >
> > > >  arch/m68k/lib/traps.c | 1 +
> > > >  arch/mips/lib/traps.c | 1 +
> > > >  include/common.h  | 1 -
> > > >  include/irq_legacy.h  | 2 ++
> > > >  4 files changed, 4 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/arch/m68k/lib/traps.c b/arch/m68k/lib/traps.c
> > > > index 5d802077453..b2e7e9fe407 100644
> > > > --- a/arch/m68k/lib/traps.c
> > > > +++ b/arch/m68k/lib/traps.c
> > > > @@ -8,6 +8,7 @@
> > > >   */
> > > >
> > > >  #include 
> > > > +#include 
> > > >  #include 
> > > >  #include 
> > > >  #include 
> > > > diff --git a/arch/mips/lib/traps.c b/arch/mips/lib/traps.c
> > > > index ff02d437a87..d173a1b0134 100644
> > > > --- a/arch/mips/lib/traps.c
> > > > +++ b/arch/mips/lib/traps.c
> > > > @@ -12,6 +12,7 @@
> > > >
> > > >  #include 
> > > >  #include 
> > > > +#include 
> > > >  #include 
> > > >  #include 
> > > >  #include 
> > > > diff --git a/include/common.h b/include/common.h
> > > > index a292d919390..e946e4d9b7f 100644
> > > > --- a/include/common.h
> > > > +++ b/include/common.h
> > > > @@ -145,7 +145,6 @@ voidrelocate_code(ulong);
> > > >  void   relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn));
> > > >  #endif
> > > >  ulong  get_endaddr   (void);
> > > > -void   trap_init (ulong);
> > > >
> > > >  void s_init(void);
> > > >
> > > > diff --git a/include/irq_legacy.h b/include/irq_legacy.h
> > > > index 91b523d043a..a029c54b702 100644
> > > > --- a/include/irq_legacy.h
> > > > +++ b/include/irq_legacy.h
> > > > @@ -21,4 +21,6 @@ void reset_timer(void);
> > > >  void enable_interrupts(void);
> > > >  int disable_interrupts(void);
> > > >
> > > > +void trap_init(unsigned long reloc_addr);
> > > > +
> > > >  #endif
> > > > --
> > >
> > > hm, at least on MIPS this is regular CPU exception handling and has
> > > nothing to do with interrupts nor with DM. I don't know about M68 but
> > > there it looks like traps are used for exceptions and interrupts. I
> > > think it would better fit into a include/traps.h or so.
> >
> > I think we tend to think of interrupts and exceptions as being similar.
> >
> > Are you suggesting creating a new traps_legacy.h?
> >
>
> either traps.h without _legacy because this code is not legacy at all.
> As far as I understand from your patch series, you're mainly using
> _legacy to separate non-DM code?

Yes that's right. It makes it clear what needs changing. It would be
worth thinking about how to include traps_init() into a driver
somewhere.

>
> Another option would be init.h because board_init_r.c:initr_trap() is
> the only caller.

That sounds good.

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


[U-Boot] arm am335x: SATA Drive connectivity over USB interface

2019-09-30 Thread Adarsh Babu Kalepalli
Hi,

u-boot Version: 2019.10-rc4
u-boot config : am335x-evm-defconfig
h/w Board: Beaglebone Black

Using a SATA-USB converter, 180GB SATA disk is interfaced with Beaglebone
Black.
Unable to initialze and access the device with "usb start" and other usb
command options.

Serial Console output of 'usb start' command:

---
BBB=> usb start
starting USB...
Bus usb@47401800: Port not available.
---

Beaglebone Linux environment identifies this SATA disk over USB interface.

Are additional config options required by u-boot??If yes, please let us
know.

Regards,
Adarsh


I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Vulnerability in UBOOT ping_reveive()

2019-09-30 Thread Simon Goldschmidt
Hi,

Jordy  schrieb am Mo., 30. Sep. 2019, 19:02:

> Hey Joe & U-BOOT-lists,
>
>
> I think I found a security vulnerability in U-BOOT and I figured I'd
> report it to you, if this is the wrong channel please let me know.
>
>
> So in https://github.com/u-boot/u-boot/blob/master/net/ping.c#L108
> https://github.com/u-boot/u-boot/blob/master/net/ping.c#L108 in the
> ping_receive() function the ethernet header gets copied for eth_hdr_size +
> len to tx_packet. (No boundary checks)
>
> if CONFIG_CMD_PING is defined in receive_icmp() in
> https://github.com/u-boot/u-boot/blob/master/net/net.c#L1068 it will call
> ping_receive with the ethernet header, ip header and length. (Still no
> boundary checks)
>

Isn't the length checked at line 1204 right when IP processing starts?

Regards,
Simon


>
> Then on net_process_received_packet() it will call receive_icmp()
> https://github.com/u-boot/u-boot/blob/master/net/net.c#L1261 with a
> lenght from ntohs(ip->ip_len)
> https://github.com/u-boot/u-boot/blob/master/net/net.c#L1208 since an
> attacker could control this size it could trigger a straight forward memcpy
> overflow.
>
>
> To fix it I'd probably just add some boundary checks in ping_receive() so
> that the amount written doesn't exceed the buffer boundaries.
>
>
> Kind Regards,
>
> Jordy Zomer
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2] tao3530: Fix usage of mmc rescan

2019-09-30 Thread Jarkko Nikula
Currently "bootcmd" does not work as intended but instead prints MMC usage
information and goes directly to "nandboot".

Follow what the commit 669681104daa ("configs: Fix usage of mmc rescan")
does for other boards prior to support for TechNexion TAO3530 SoM was
added.

Signed-off-by: Jarkko Nikula 
---
v2: s/$(mmcdev)/${mmcdev}/
---
 include/configs/tao3530.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/tao3530.h b/include/configs/tao3530.h
index c34e785d9e55..7a54fe3e1e37 100644
--- a/include/configs/tao3530.h
+++ b/include/configs/tao3530.h
@@ -114,7 +114,7 @@
"bootm ${loadaddr}\0" \
 
 #define CONFIG_BOOTCOMMAND \
-   "if mmc rescan ${mmcdev}; then " \
+   "mmc dev ${mmcdev}; if mmc rescan; then " \
"if run loadbootscript; then " \
"run bootscript; " \
"else " \
-- 
2.23.0

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


Re: [U-Boot] [PATCH] tao3530: Fix usage of mmc rescan

2019-09-30 Thread Jarkko Nikula
On 9/29/19 8:33 PM, Jarkko Nikula wrote:
> Currently "bootcmd" does not work as intended but instead prints MMC usage
> information and goes directly to "nandboot".
> 
> Follow what the commit 669681104daa ("configs: Fix usage of mmc rescan")
> does for other boards prior to support for TechNexion TAO3530 SoM was
> added.
> 
> Signed-off-by: Jarkko Nikula 
> ---
>  include/configs/tao3530.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/configs/tao3530.h b/include/configs/tao3530.h
> index c34e785d9e55..5f75eed4c0e7 100644
> --- a/include/configs/tao3530.h
> +++ b/include/configs/tao3530.h
> @@ -114,7 +114,7 @@
>   "bootm ${loadaddr}\0" \
>  
>  #define CONFIG_BOOTCOMMAND \
> - "if mmc rescan ${mmcdev}; then " \
> + "mmc dev $(mmcdev); if mmc rescan; then " \

Please discard this, by some reason I managed to put round brackets
here. Will resend.

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


[U-Boot] Vulnerability in UBOOT ping_reveive()

2019-09-30 Thread Jordy
Hey Joe & U-BOOT-lists,


I think I found a security vulnerability in U-BOOT and I figured I'd report it 
to you, if this is the wrong channel please let me know.


So in https://github.com/u-boot/u-boot/blob/master/net/ping.c#L108  
https://github.com/u-boot/u-boot/blob/master/net/ping.c#L108 in the 
ping_receive() function the ethernet header gets copied for eth_hdr_size + len 
to tx_packet. (No boundary checks)

if CONFIG_CMD_PING is defined in receive_icmp() in 
https://github.com/u-boot/u-boot/blob/master/net/net.c#L1068 it will call 
ping_receive with the ethernet header, ip header and length. (Still no boundary 
checks)


Then on net_process_received_packet() it will call receive_icmp() 
https://github.com/u-boot/u-boot/blob/master/net/net.c#L1261 with a lenght from 
ntohs(ip->ip_len) https://github.com/u-boot/u-boot/blob/master/net/net.c#L1208 
since an attacker could control this size it could trigger a straight forward 
memcpy overflow.


To fix it I'd probably just add some boundary checks in ping_receive() so that 
the amount written doesn't exceed the buffer boundaries.


Kind Regards,

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


Re: [U-Boot] Pull request: u-boot-rockchip-20190828

2019-09-30 Thread Tom Rini
On Sun, Sep 29, 2019 at 02:50:54PM +0800, Kever Yang wrote:

> Hi Tom,
> 
> Please pull the rockchip update:
> - Fix efuse read data number for rk3399
> - make_fit_atf.py: fix .its generation for a single atf image
> 
> Travis:
> https://travis-ci.org/keveryang/u-boot/builds/590954707
> 
> Thanks,
> - Kever
> 
> The following changes since commit dfd590075ca263d6b3ed22465a94d33a8ee93e07:
> 
>   Merge tag 'efi-2019-10-rc5' of 
> https://gitlab.denx.de/u-boot/custodians/u-boot-efi (2019-09-26 17:22:22 
> -0400)
> 
> are available in the Git repository at:
> 
>   https://gitlab.denx.de/u-boot/custodians/u-boot-rockchip.git 
> tags/u-boot-rockchip-20190928
> 
> for you to fetch changes up to d46b548290042a248216cbaed99964dc77a26bf4:
> 
>   rockchip: make_fit_atf.py: fix .its generation for a single atf image 
> (2019-09-28 22:26:32 +0800)
> 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [PULL] u-boot-atmel-fixes-2019.10-a

2019-09-30 Thread Tom Rini
On Mon, Sep 30, 2019 at 09:07:55AM +, eugen.hris...@microchip.com wrote:

> Hello Tom,
> 
> Please pull tag u-boot-atmel-fixes-2019.10-a , the first set (hopefully 
> the only one) of fixes for the 2019.10 release.
> 
> This includes only tiny cleanups on env changes related to 2019.10 new 
> features: removal of duplicate env settings (otherwise there may be 
> warnings in building..) and a small fix for flashes on Gardena smart 
> gateway (requires nand bad block tables).
> 
> Thanks,
> Eugen
> 
> 
> The following changes since commit 31e086e460fb5de6dd42559babdc1e027ed2fe96:
> 
>Prepare v2019.10-rc4 (2019-09-23 12:24:39 -0400)
> 
> are available in the git repository at:
> 
>https://gitlab.denx.de/u-boot/custodians/u-boot-atmel.git 
> tags/u-boot-atmel-fixes-2019.10-a
> 
> for you to fetch changes up to 27a5d628275f9cdd2ca221f560a19d3dea4753f3:
> 
>at91: configs: Drop duplication of defconfig macros (2019-09-30 
> 09:15:23 +0300)
> 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [PATCH 39/41] common: Move trap_init() out of common.h

2019-09-30 Thread Tom Rini
On Mon, Sep 30, 2019 at 05:43:29PM +0200, Daniel Schwierzeck wrote:
> On Mon, Sep 30, 2019 at 5:37 PM Simon Glass  wrote:
> >
> > Hi Daniel,
> >
> > On Mon, 30 Sep 2019 at 09:13, Daniel Schwierzeck
> >  wrote:
> > >
> > > On Mon, Sep 30, 2019 at 4:58 PM Simon Glass  wrote:
> > > >
> > > > Move this function into the irq_legacy.h header file.
> > > >
> > > > Signed-off-by: Simon Glass 
> > > > ---
> > > >
> > > >  arch/m68k/lib/traps.c | 1 +
> > > >  arch/mips/lib/traps.c | 1 +
> > > >  include/common.h  | 1 -
> > > >  include/irq_legacy.h  | 2 ++
> > > >  4 files changed, 4 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/arch/m68k/lib/traps.c b/arch/m68k/lib/traps.c
> > > > index 5d802077453..b2e7e9fe407 100644
> > > > --- a/arch/m68k/lib/traps.c
> > > > +++ b/arch/m68k/lib/traps.c
> > > > @@ -8,6 +8,7 @@
> > > >   */
> > > >
> > > >  #include 
> > > > +#include 
> > > >  #include 
> > > >  #include 
> > > >  #include 
> > > > diff --git a/arch/mips/lib/traps.c b/arch/mips/lib/traps.c
> > > > index ff02d437a87..d173a1b0134 100644
> > > > --- a/arch/mips/lib/traps.c
> > > > +++ b/arch/mips/lib/traps.c
> > > > @@ -12,6 +12,7 @@
> > > >
> > > >  #include 
> > > >  #include 
> > > > +#include 
> > > >  #include 
> > > >  #include 
> > > >  #include 
> > > > diff --git a/include/common.h b/include/common.h
> > > > index a292d919390..e946e4d9b7f 100644
> > > > --- a/include/common.h
> > > > +++ b/include/common.h
> > > > @@ -145,7 +145,6 @@ voidrelocate_code(ulong);
> > > >  void   relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn));
> > > >  #endif
> > > >  ulong  get_endaddr   (void);
> > > > -void   trap_init (ulong);
> > > >
> > > >  void s_init(void);
> > > >
> > > > diff --git a/include/irq_legacy.h b/include/irq_legacy.h
> > > > index 91b523d043a..a029c54b702 100644
> > > > --- a/include/irq_legacy.h
> > > > +++ b/include/irq_legacy.h
> > > > @@ -21,4 +21,6 @@ void reset_timer(void);
> > > >  void enable_interrupts(void);
> > > >  int disable_interrupts(void);
> > > >
> > > > +void trap_init(unsigned long reloc_addr);
> > > > +
> > > >  #endif
> > > > --
> > >
> > > hm, at least on MIPS this is regular CPU exception handling and has
> > > nothing to do with interrupts nor with DM. I don't know about M68 but
> > > there it looks like traps are used for exceptions and interrupts. I
> > > think it would better fit into a include/traps.h or so.
> >
> > I think we tend to think of interrupts and exceptions as being similar.
> >
> > Are you suggesting creating a new traps_legacy.h?
> >
> 
> either traps.h without _legacy because this code is not legacy at all.
> As far as I understand from your patch series, you're mainly using
> _legacy to separate non-DM code?
> 
> Another option would be init.h because board_init_r.c:initr_trap() is
> the only caller.

Yes, we need to be careful when calling something legacy or not.  init.h
also sounds like a good place in this case, thanks!

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


Re: [U-Boot] [PATCH v2] arm: dts: sync dts for Allwinner H6

2019-09-30 Thread Jagan Teki
On Sat, Sep 28, 2019 at 2:54 AM Maxime Ripard  wrote:
>
> Hi,
>
> On Fri, Sep 06, 2019 at 09:53:33AM +0200, Clément Péron wrote:
> > Hi,
> >
> > On Sun, 25 Aug 2019 at 18:04, Clément Péron  wrote:
> > >
> > > Sync Kernel DTS for Allwinner H6 boards.
> >
> > This sync avoid the random mac on the beelink GS1.
> >
> > Could you check if it's ok for you ?
>
> Acked-by: Maxime Ripard 
>
> Jagan, could we merge this?

Since it is sync change, I would like to merge in coming MW. let me
know if it urgent or required for the release?

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


Re: [U-Boot] [PATCH 39/41] common: Move trap_init() out of common.h

2019-09-30 Thread Daniel Schwierzeck
On Mon, Sep 30, 2019 at 5:37 PM Simon Glass  wrote:
>
> Hi Daniel,
>
> On Mon, 30 Sep 2019 at 09:13, Daniel Schwierzeck
>  wrote:
> >
> > On Mon, Sep 30, 2019 at 4:58 PM Simon Glass  wrote:
> > >
> > > Move this function into the irq_legacy.h header file.
> > >
> > > Signed-off-by: Simon Glass 
> > > ---
> > >
> > >  arch/m68k/lib/traps.c | 1 +
> > >  arch/mips/lib/traps.c | 1 +
> > >  include/common.h  | 1 -
> > >  include/irq_legacy.h  | 2 ++
> > >  4 files changed, 4 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/arch/m68k/lib/traps.c b/arch/m68k/lib/traps.c
> > > index 5d802077453..b2e7e9fe407 100644
> > > --- a/arch/m68k/lib/traps.c
> > > +++ b/arch/m68k/lib/traps.c
> > > @@ -8,6 +8,7 @@
> > >   */
> > >
> > >  #include 
> > > +#include 
> > >  #include 
> > >  #include 
> > >  #include 
> > > diff --git a/arch/mips/lib/traps.c b/arch/mips/lib/traps.c
> > > index ff02d437a87..d173a1b0134 100644
> > > --- a/arch/mips/lib/traps.c
> > > +++ b/arch/mips/lib/traps.c
> > > @@ -12,6 +12,7 @@
> > >
> > >  #include 
> > >  #include 
> > > +#include 
> > >  #include 
> > >  #include 
> > >  #include 
> > > diff --git a/include/common.h b/include/common.h
> > > index a292d919390..e946e4d9b7f 100644
> > > --- a/include/common.h
> > > +++ b/include/common.h
> > > @@ -145,7 +145,6 @@ voidrelocate_code(ulong);
> > >  void   relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn));
> > >  #endif
> > >  ulong  get_endaddr   (void);
> > > -void   trap_init (ulong);
> > >
> > >  void s_init(void);
> > >
> > > diff --git a/include/irq_legacy.h b/include/irq_legacy.h
> > > index 91b523d043a..a029c54b702 100644
> > > --- a/include/irq_legacy.h
> > > +++ b/include/irq_legacy.h
> > > @@ -21,4 +21,6 @@ void reset_timer(void);
> > >  void enable_interrupts(void);
> > >  int disable_interrupts(void);
> > >
> > > +void trap_init(unsigned long reloc_addr);
> > > +
> > >  #endif
> > > --
> >
> > hm, at least on MIPS this is regular CPU exception handling and has
> > nothing to do with interrupts nor with DM. I don't know about M68 but
> > there it looks like traps are used for exceptions and interrupts. I
> > think it would better fit into a include/traps.h or so.
>
> I think we tend to think of interrupts and exceptions as being similar.
>
> Are you suggesting creating a new traps_legacy.h?
>

either traps.h without _legacy because this code is not legacy at all.
As far as I understand from your patch series, you're mainly using
_legacy to separate non-DM code?

Another option would be init.h because board_init_r.c:initr_trap() is
the only caller.

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


Re: [U-Boot] [PATCH 39/41] common: Move trap_init() out of common.h

2019-09-30 Thread Simon Glass
Hi Daniel,

On Mon, 30 Sep 2019 at 09:13, Daniel Schwierzeck
 wrote:
>
> On Mon, Sep 30, 2019 at 4:58 PM Simon Glass  wrote:
> >
> > Move this function into the irq_legacy.h header file.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >  arch/m68k/lib/traps.c | 1 +
> >  arch/mips/lib/traps.c | 1 +
> >  include/common.h  | 1 -
> >  include/irq_legacy.h  | 2 ++
> >  4 files changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/m68k/lib/traps.c b/arch/m68k/lib/traps.c
> > index 5d802077453..b2e7e9fe407 100644
> > --- a/arch/m68k/lib/traps.c
> > +++ b/arch/m68k/lib/traps.c
> > @@ -8,6 +8,7 @@
> >   */
> >
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > diff --git a/arch/mips/lib/traps.c b/arch/mips/lib/traps.c
> > index ff02d437a87..d173a1b0134 100644
> > --- a/arch/mips/lib/traps.c
> > +++ b/arch/mips/lib/traps.c
> > @@ -12,6 +12,7 @@
> >
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > diff --git a/include/common.h b/include/common.h
> > index a292d919390..e946e4d9b7f 100644
> > --- a/include/common.h
> > +++ b/include/common.h
> > @@ -145,7 +145,6 @@ voidrelocate_code(ulong);
> >  void   relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn));
> >  #endif
> >  ulong  get_endaddr   (void);
> > -void   trap_init (ulong);
> >
> >  void s_init(void);
> >
> > diff --git a/include/irq_legacy.h b/include/irq_legacy.h
> > index 91b523d043a..a029c54b702 100644
> > --- a/include/irq_legacy.h
> > +++ b/include/irq_legacy.h
> > @@ -21,4 +21,6 @@ void reset_timer(void);
> >  void enable_interrupts(void);
> >  int disable_interrupts(void);
> >
> > +void trap_init(unsigned long reloc_addr);
> > +
> >  #endif
> > --
>
> hm, at least on MIPS this is regular CPU exception handling and has
> nothing to do with interrupts nor with DM. I don't know about M68 but
> there it looks like traps are used for exceptions and interrupts. I
> think it would better fit into a include/traps.h or so.

I think we tend to think of interrupts and exceptions as being similar.

Are you suggesting creating a new traps_legacy.h?

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


[U-Boot] Error when replacing SPI NOR Flash IC

2019-09-30 Thread RUSSELL Ryan
Hello All,

We are currently having issues with a product after we replaced an obsolete SPI 
Flash IC with what we thought was a drop-in replacement part. Unfortunately we 
had this product designed by a third part company so I don't have all of the 
important details but I will try to get any additional information needed.

Our current circuit uses a ADSP-BF609BBCZ-5 Blackfin. We are using a NOR SPI 
Flash to boot the Blackfin. Initially in our design we used a N25Q128A13ESE40 
flash from Micron but when it became obsolete we switched to S25FL127SABMFI101 
from Cypress. The Cypress part appeared to be functional but after 6 weeks in 
the field we are seeing a high level of failures due to this part. As far as we 
can tell there are no environmental differences between products that have each 
part but products that contain the Cypress part are failing. When we take off 
the 'broken' part and replace it the board becomes functional again.

Is there something different about these parts that require a slightly 
different u-boot configuration that could cause the Flash to function initially 
but later become corrupt?

Best Regards,
Ryan J. Russell
Hardware Designer
Alstom Signaling



CONFIDENTIALITY : This e-mail and any attachments are confidential and may be 
privileged. If you are not a named recipient, please notify the sender 
immediately and do not disclose the contents to another person, use it for any 
purpose or store or copy the information in any medium.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] imx: add support for i.MX8MQ power domain controller

2019-09-30 Thread Patrick Wildt
Add support for the power domain controller that's used on the
i.MX8MQ.  This will be needed to be able to power on the PCIe
controller.  Bindings taken from Linux, driver implementation
taken from the i.MX8 power domain controller and adjusted for
the i.MX8M SoC.

Signed-off-by: Patrick Wildt 

diff --git a/arch/arm/dts/fsl-imx8mq.dtsi b/arch/arm/dts/fsl-imx8mq.dtsi
index 814a1b7df4..fbf5009886 100644
--- a/arch/arm/dts/fsl-imx8mq.dtsi
+++ b/arch/arm/dts/fsl-imx8mq.dtsi
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 / {
@@ -71,12 +72,6 @@
interrupt-parent = <>;
};
 
-   power: power-controller {
-   compatible = "fsl,imx8mq-pm-domain";
-   num-domains = <11>;
-   #power-domain-cells = <1>;
-   };
-
pwm2: pwm@3067 {
compatible = "fsl,imx8mq-pwm", "fsl,imx27-pwm";
reg = <0x0 0x3067 0x0 0x1>;
@@ -276,6 +271,37 @@
interrupts = ;
#interrupt-cells = <3>;
interrupt-parent = <>;
+
+   pgc {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   /*
+* As per comment in ATF source code:
+*
+* PCIE1 and PCIE2 share the
+* same reset signal, if we
+* power down PCIE2, PCIE1
+* will be held in reset too.
+*
+* So instead of creating two
+* separate power domains for
+* PCIE1 and PCIE2 we create a
+* link between both and use
+* it as a shared PCIE power
+* domain.
+*/
+   pgc_pcie: power-domain@1 {
+   #power-domain-cells = <0>;
+   reg = ;
+   power-domains = <_pcie2>;
+   };
+
+   pgc_pcie2: power-domain@a {
+   #power-domain-cells = <0>;
+   reg = ;
+   };
+   };
};
 
usdhc1: usdhc@30b4 {
diff --git a/arch/arm/include/asm/arch-imx8m/power-domain.h 
b/arch/arm/include/asm/arch-imx8m/power-domain.h
new file mode 100644
index 00..0f94945894
--- /dev/null
+++ b/arch/arm/include/asm/arch-imx8m/power-domain.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2017 NXP
+ */
+
+#ifndef _ASM_ARCH_IMX8M_POWER_DOMAIN_H
+#define _ASM_ARCH_IMX8M_POWER_DOMAIN_H
+
+struct imx8m_power_domain_platdata {
+   int resource_id;
+   int has_pd;
+   struct power_domain pd;
+};
+
+#endif
diff --git a/configs/imx8mq_evk_defconfig b/configs/imx8mq_evk_defconfig
index e45731edda..6c87a8a1ef 100644
--- a/configs/imx8mq_evk_defconfig
+++ b/configs/imx8mq_evk_defconfig
@@ -35,6 +35,8 @@ CONFIG_FSL_USDHC=y
 CONFIG_DM_ETH=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX8M=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_IMX8M_POWER_DOMAIN=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
diff --git a/drivers/power/domain/Kconfig b/drivers/power/domain/Kconfig
index 06bba6220b..7e2d6a90bf 100644
--- a/drivers/power/domain/Kconfig
+++ b/drivers/power/domain/Kconfig
@@ -23,6 +23,13 @@ config IMX8_POWER_DOMAIN
   Enable support for manipulating NXP i.MX8 on-SoC power domains via 
IPC
   requests to the SCU.
 
+config IMX8M_POWER_DOMAIN
+   bool "Enable i.MX8M power domain driver"
+   depends on POWER_DOMAIN && ARCH_IMX8M
+   help
+ Enable support for manipulating NXP i.MX8M on-SoC power domains via
+ requests to the ATF.
+
 config MTK_POWER_DOMAIN
bool "Enable the MediaTek power domain driver"
depends on POWER_DOMAIN && ARCH_MEDIATEK
diff --git a/drivers/power/domain/Makefile b/drivers/power/domain/Makefile
index 695aafe17d..4d87d7c7f9 100644
--- a/drivers/power/domain/Makefile
+++ b/drivers/power/domain/Makefile
@@ -6,6 +6,7 @@
 obj-$(CONFIG_$(SPL_)POWER_DOMAIN) += power-domain-uclass.o
 obj-$(CONFIG_BCM6328_POWER_DOMAIN) += bcm6328-power-domain.o
 obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain.o
+obj-$(CONFIG_IMX8M_POWER_DOMAIN) += imx8m-power-domain.o
 obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o
 obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o
 obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain.o
diff --git a/drivers/power/domain/imx8m-power-domain.c 
b/drivers/power/domain/imx8m-power-domain.c
new file mode 100644
index 00..164fb3d31d
--- /dev/null
+++ b/drivers/power/domain/imx8m-power-domain.c
@@ -0,0 +1,137 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2017 NXP
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 

[U-Boot] [PATCH 3/3] video: mxsfb: set gd->fb_base

2019-09-30 Thread Sébastien Szymanski
Set gd->fb_base so it can be shown with bdinfo command.

Signed-off-by: Sébastien Szymanski 
---
 drivers/video/mxsfb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 6922a130c6..ce67f3f32b 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -367,6 +367,7 @@ static int mxs_video_probe(struct udevice *dev)
mmu_set_region_dcache_behaviour(fb_start, fb_end - fb_start,
DCACHE_WRITEBACK);
video_set_flush_dcache(dev, true);
+   gd->fb_base = fb_start;
 
return ret;
 }
-- 
2.21.0

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


[U-Boot] [PATCH 2/3] opos6uldev: migrate to DM_VIDEO

2019-09-30 Thread Sébastien Szymanski
Migrate to DM_VIDEO, update the device tree and remove code that is no
longer necessary.

Signed-off-by: Sébastien Szymanski 
---
 arch/arm/dts/imx6ul-opos6uldev-u-boot.dtsi | 10 ++
 arch/arm/dts/imx6ul-opos6uldev.dts |  4 +--
 board/armadeus/opos6uldev/board.c  | 36 --
 configs/opos6uldev_defconfig   |  3 +-
 include/configs/opos6uldev.h   |  6 +++-
 5 files changed, 19 insertions(+), 40 deletions(-)

diff --git a/arch/arm/dts/imx6ul-opos6uldev-u-boot.dtsi 
b/arch/arm/dts/imx6ul-opos6uldev-u-boot.dtsi
index da8b0392ef..3f351ef0c4 100644
--- a/arch/arm/dts/imx6ul-opos6uldev-u-boot.dtsi
+++ b/arch/arm/dts/imx6ul-opos6uldev-u-boot.dtsi
@@ -7,6 +7,12 @@
 
 #include "imx6ul-opos6ul-u-boot.dtsi"
 
+/ {
+   aliases {
+   display0 = 
+   };
+};
+
  {
u-boot,dm-spl;
 
@@ -15,6 +21,10 @@
};
 };
 
+ {
+   u-boot,dm-pre-proper;
+};
+
 _uart1 {
u-boot,dm-spl;
 };
diff --git a/arch/arm/dts/imx6ul-opos6uldev.dts 
b/arch/arm/dts/imx6ul-opos6uldev.dts
index 0e59ee57fd..4a541be6b0 100644
--- a/arch/arm/dts/imx6ul-opos6uldev.dts
+++ b/arch/arm/dts/imx6ul-opos6uldev.dts
@@ -187,7 +187,7 @@
status = "okay";
 
display0: display0 {
-   bits-per-pixel = <32>;
+   bits-per-pixel = <18>;
bus-width = <18>;
 
display-timings {
@@ -202,7 +202,7 @@
hsync-len = <64>;
vsync-len = <4>;
de-active = <1>;
-   pixelclk-active = <0>;
+   pixelclk-active = <1>;
};
};
};
diff --git a/board/armadeus/opos6uldev/board.c 
b/board/armadeus/opos6uldev/board.c
index cbf40d5c4a..ade155c5ad 100644
--- a/board/armadeus/opos6uldev/board.c
+++ b/board/armadeus/opos6uldev/board.c
@@ -3,53 +3,17 @@
  * Copyright (C) 2018 Armadeus Systems
  */
 
-#include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
 #ifdef CONFIG_VIDEO_MXS
-#define LCD_PAD_CTRL ( \
-   PAD_CTL_HYS | PAD_CTL_PUS_100K_UP | PAD_CTL_PUE | \
-   PAD_CTL_PKE | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm \
-)
-
-static iomux_v3_cfg_t const lcd_pads[] = {
-   MX6_PAD_LCD_CLK__LCDIF_CLK | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_ENABLE__LCDIF_ENABLE | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_HSYNC__LCDIF_HSYNC | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_VSYNC__LCDIF_VSYNC | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA00__LCDIF_DATA00 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA01__LCDIF_DATA01 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA02__LCDIF_DATA02 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA03__LCDIF_DATA03 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA04__LCDIF_DATA04 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA05__LCDIF_DATA05 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA06__LCDIF_DATA06 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA07__LCDIF_DATA07 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA08__LCDIF_DATA08 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA09__LCDIF_DATA09 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA10__LCDIF_DATA10 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA11__LCDIF_DATA11 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA12__LCDIF_DATA12 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA13__LCDIF_DATA13 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA14__LCDIF_DATA14 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA15__LCDIF_DATA15 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA16__LCDIF_DATA16 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX6_PAD_LCD_DATA17__LCDIF_DATA17 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-
-   MX6_PAD_NAND_ALE__GPIO4_IO10 | MUX_PAD_CTRL(NO_PAD_CTRL)
-};
-
 int setup_lcd(void)
 {
struct gpio_desc backlight;
int ret;
 
-   imx_iomux_v3_setup_multiple_pads(lcd_pads, ARRAY_SIZE(lcd_pads));
-
/* Set Brightness to high */
ret = dm_gpio_lookup_name("GPIO4_10", );
if (ret) {
diff --git a/configs/opos6uldev_defconfig b/configs/opos6uldev_defconfig
index 44236e99bc..352d10a0d8 100644
--- a/configs/opos6uldev_defconfig
+++ b/configs/opos6uldev_defconfig
@@ -95,6 +95,7 @@ CONFIG_USB_GADGET_VENDOR_NUM=0x0525
 CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
-CONFIG_VIDEO=y
+CONFIG_DM_VIDEO=y
+CONFIG_SYS_WHITE_ON_BLACK=y
 CONFIG_OF_LIBFDT_OVERLAY=y
 # CONFIG_EFI_LOADER is not set
diff --git a/include/configs/opos6uldev.h b/include/configs/opos6uldev.h
index b10071eaaf..11face21a1 100644
--- a/include/configs/opos6uldev.h
+++ b/include/configs/opos6uldev.h
@@ -43,7 +43,7 @@
 
 /* LCD */
 #ifndef CONFIG_SPL_BUILD
-#ifdef CONFIG_VIDEO
+#ifdef CONFIG_DM_VIDEO
 #define CONFIG_VIDEO_LOGO
 #define CONFIG_SPLASH_SCREEN
 #define CONFIG_SPLASH_SCREEN_ALIGN
@@ 

[U-Boot] [PATCH 1/3] imx6ul: opos6ul: migrate to DM_ETH

2019-09-30 Thread Sébastien Szymanski
Migrate to DM_ETH and remove code that is no longer necessary.

Signed-off-by: Sébastien Szymanski 
---
 arch/arm/mach-imx/mx6/opos6ul.c | 76 +++--
 configs/opos6uldev_defconfig|  2 +
 include/configs/opos6uldev.h|  8 
 3 files changed, 8 insertions(+), 78 deletions(-)

diff --git a/arch/arm/mach-imx/mx6/opos6ul.c b/arch/arm/mach-imx/mx6/opos6ul.c
index c5fafb9f8e..50aec5171c 100644
--- a/arch/arm/mach-imx/mx6/opos6ul.c
+++ b/arch/arm/mach-imx/mx6/opos6ul.c
@@ -6,11 +6,7 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -20,43 +16,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #ifdef CONFIG_FEC_MXC
 #include 
 
-#define MDIO_PAD_CTRL ( \
-   PAD_CTL_HYS | PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
-   PAD_CTL_DSE_40ohm \
-)
-
-#define ENET_PAD_CTRL_PU ( \
-   PAD_CTL_HYS | PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
-   PAD_CTL_DSE_40ohm \
-)
-
-#define ENET_PAD_CTRL_PD ( \
-   PAD_CTL_HYS | PAD_CTL_PUS_100K_DOWN | PAD_CTL_SPEED_MED | \
-   PAD_CTL_DSE_40ohm \
-)
-
-#define ENET_CLK_PAD_CTRL ( \
-   PAD_CTL_HYS | PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_LOW | \
-   PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST \
-)
-
-static iomux_v3_cfg_t const fec1_pads[] = {
-   MX6_PAD_GPIO1_IO06__ENET1_MDIO| MUX_PAD_CTRL(MDIO_PAD_CTRL),
-   MX6_PAD_GPIO1_IO07__ENET1_MDC | MUX_PAD_CTRL(MDIO_PAD_CTRL),
-   MX6_PAD_ENET1_RX_ER__ENET1_RX_ER  | MUX_PAD_CTRL(ENET_PAD_CTRL_PD),
-   MX6_PAD_ENET1_RX_EN__ENET1_RX_EN  | MUX_PAD_CTRL(ENET_PAD_CTRL_PD),
-   MX6_PAD_ENET1_RX_DATA1__ENET1_RDATA01 | MUX_PAD_CTRL(ENET_PAD_CTRL_PD),
-   MX6_PAD_ENET1_RX_DATA0__ENET1_RDATA00 | MUX_PAD_CTRL(ENET_PAD_CTRL_PD),
-   MX6_PAD_ENET1_TX_DATA0__ENET1_TDATA00 | MUX_PAD_CTRL(ENET_PAD_CTRL_PU),
-   MX6_PAD_ENET1_TX_DATA1__ENET1_TDATA01 | MUX_PAD_CTRL(ENET_PAD_CTRL_PU),
-   MX6_PAD_ENET1_TX_EN__ENET1_TX_EN  | MUX_PAD_CTRL(ENET_PAD_CTRL_PU),
-   /* PHY Int */
-   MX6_PAD_NAND_DQS__GPIO4_IO16  | MUX_PAD_CTRL(ENET_PAD_CTRL_PU),
-   /* PHY Reset */
-   MX6_PAD_NAND_DATA00__GPIO4_IO02   | MUX_PAD_CTRL(ENET_PAD_CTRL_PD),
-   MX6_PAD_ENET1_TX_CLK__ENET1_REF_CLK1  | MUX_PAD_CTRL(ENET_CLK_PAD_CTRL),
-};
-
 int board_phy_config(struct phy_device *phydev)
 {
phy_write(phydev, MDIO_DEVAD_NONE, 0x1f, 0x8190);
@@ -67,43 +26,16 @@ int board_phy_config(struct phy_device *phydev)
return 0;
 }
 
-int board_eth_init(bd_t *bis)
+static int setup_fec(void)
 {
struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
-   struct gpio_desc rst;
-   int ret;
 
/* Use 50M anatop loopback REF_CLK1 for ENET1,
 * clear gpr1[13], set gpr1[17] */
clrsetbits_le32(_regs->gpr[1], IOMUX_GPR1_FEC1_MASK,
IOMUX_GPR1_FEC1_CLOCK_MUX1_SEL_MASK);
 
-   ret = enable_fec_anatop_clock(0, ENET_50MHZ);
-   if (ret)
-   return ret;
-
-   enable_enet_clk(1);
-
-   imx_iomux_v3_setup_multiple_pads(fec1_pads, ARRAY_SIZE(fec1_pads));
-
-   ret = dm_gpio_lookup_name("GPIO4_2", );
-   if (ret) {
-   printf("Cannot get GPIO4_2\n");
-   return ret;
-   }
-
-   ret = dm_gpio_request(, "phy-rst");
-   if (ret) {
-   printf("Cannot request GPIO4_2\n");
-   return ret;
-   }
-
-   dm_gpio_set_dir_flags(, GPIOD_IS_OUT);
-   dm_gpio_set_value(, 0);
-   udelay(1000);
-   dm_gpio_set_value(, 1);
-
-   return fecmxc_initialize(bis);
+   return enable_fec_anatop_clock(0, ENET_50MHZ);
 }
 #endif /* CONFIG_FEC_MXC */
 
@@ -112,6 +44,10 @@ int board_init(void)
/* Address of boot parameters */
gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
 
+#ifdef CONFIG_FEC_MXC
+   setup_fec();
+#endif
+
return 0;
 }
 
diff --git a/configs/opos6uldev_defconfig b/configs/opos6uldev_defconfig
index 5eef6527cd..44236e99bc 100644
--- a/configs/opos6uldev_defconfig
+++ b/configs/opos6uldev_defconfig
@@ -73,6 +73,8 @@ CONFIG_FSL_USDHC=y
 CONFIG_PHYLIB=y
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ8XXX=y
+CONFIG_DM_ETH=y
+CONFIG_DM_MDIO=y
 CONFIG_FEC_MXC=y
 CONFIG_MII=y
 CONFIG_PINCTRL=y
diff --git a/include/configs/opos6uldev.h b/include/configs/opos6uldev.h
index b13e476027..b10071eaaf 100644
--- a/include/configs/opos6uldev.h
+++ b/include/configs/opos6uldev.h
@@ -41,14 +41,6 @@
 #define CONFIG_USB_MAX_CONTROLLER_COUNT2
 #endif
 
-/* Ethernet */
-#ifdef CONFIG_FEC_MXC
-#define IMX_FEC_BASE   ENET_BASE_ADDR
-#define CONFIG_FEC_MXC_PHYADDR  0x1
-#define CONFIG_FEC_XCV_TYPE RMII
-#define CONFIG_ETHPRIME"FEC"
-#endif
-
 /* LCD */
 #ifndef CONFIG_SPL_BUILD
 #ifdef CONFIG_VIDEO
-- 
2.21.0

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

Re: [U-Boot] [PATCH 39/41] common: Move trap_init() out of common.h

2019-09-30 Thread Daniel Schwierzeck
On Mon, Sep 30, 2019 at 4:58 PM Simon Glass  wrote:
>
> Move this function into the irq_legacy.h header file.
>
> Signed-off-by: Simon Glass 
> ---
>
>  arch/m68k/lib/traps.c | 1 +
>  arch/mips/lib/traps.c | 1 +
>  include/common.h  | 1 -
>  include/irq_legacy.h  | 2 ++
>  4 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/m68k/lib/traps.c b/arch/m68k/lib/traps.c
> index 5d802077453..b2e7e9fe407 100644
> --- a/arch/m68k/lib/traps.c
> +++ b/arch/m68k/lib/traps.c
> @@ -8,6 +8,7 @@
>   */
>
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/arch/mips/lib/traps.c b/arch/mips/lib/traps.c
> index ff02d437a87..d173a1b0134 100644
> --- a/arch/mips/lib/traps.c
> +++ b/arch/mips/lib/traps.c
> @@ -12,6 +12,7 @@
>
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/include/common.h b/include/common.h
> index a292d919390..e946e4d9b7f 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -145,7 +145,6 @@ voidrelocate_code(ulong);
>  void   relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn));
>  #endif
>  ulong  get_endaddr   (void);
> -void   trap_init (ulong);
>
>  void s_init(void);
>
> diff --git a/include/irq_legacy.h b/include/irq_legacy.h
> index 91b523d043a..a029c54b702 100644
> --- a/include/irq_legacy.h
> +++ b/include/irq_legacy.h
> @@ -21,4 +21,6 @@ void reset_timer(void);
>  void enable_interrupts(void);
>  int disable_interrupts(void);
>
> +void trap_init(unsigned long reloc_addr);
> +
>  #endif
> --

hm, at least on MIPS this is regular CPU exception handling and has
nothing to do with interrupts nor with DM. I don't know about M68 but
there it looks like traps are used for exceptions and interrupts. I
think it would better fit into a include/traps.h or so.


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


[U-Boot] [PATCH] imx: add support for i.MX7/i.MX8MQ reset controller

2019-09-30 Thread Patrick Wildt
Add support for the reset controller that's used on the i.MX7D
and i.MX8MQ.  This will be needed to be able to assert the PCIe
reset pins.  Bindings taken from Linux, driver implementation
mostly taken from Linux and adjusted to U-Boot infrastructure.

Signed-off-by: Patrick Wildt 

diff --git a/arch/arm/dts/fsl-imx8mq.dtsi b/arch/arm/dts/fsl-imx8mq.dtsi
index 814a1b7df4..52a76b4ba4 100644
--- a/arch/arm/dts/fsl-imx8mq.dtsi
+++ b/arch/arm/dts/fsl-imx8mq.dtsi
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 / {
@@ -269,6 +270,12 @@
#clock-cells = <1>;
};
 
+   src: reset-controller@3039 {
+   compatible = "fsl,imx8mq-src", "syscon";
+   reg = <0x0 0x3039 0x0 0x1>;
+   #reset-cells = <1>;
+   };
+
gpc: gpc@303a {
compatible = "fsl,imx8mq-gpc", "fsl,imx7d-gpc", "syscon";
reg = <0x0 0x303a 0x0 0x1>;
diff --git a/configs/imx8mq_evk_defconfig b/configs/imx8mq_evk_defconfig
index e45731edda..c0e5860e85 100644
--- a/configs/imx8mq_evk_defconfig
+++ b/configs/imx8mq_evk_defconfig
@@ -38,4 +38,5 @@ CONFIG_PINCTRL_IMX8M=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_RESET=y
 CONFIG_DM_THERMAL=y
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index 6ec6f39c85..976f3a701c 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -127,4 +127,11 @@ config RESET_HISILICON
help
  Support for reset controller on HiSilicon SoCs.
 
+config RESET_IMX7
+   bool "i.MX7/8 Reset Driver"
+   depends on DM_RESET && (ARCH_MX7 || ARCH_IMX8M)
+   default y
+   help
+ Support for reset controller on i.MX7/8 SoCs.
+
 endmenu
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index 7fec75bb49..f5875fce09 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -20,3 +20,4 @@ obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o
 obj-$(CONFIG_RESET_MEDIATEK) += reset-mediatek.o
 obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o
 obj-$(CONFIG_RESET_HISILICON) += reset-hisilicon.o
+obj-$(CONFIG_RESET_IMX7) += reset-imx7.o
diff --git a/drivers/reset/reset-imx7.c b/drivers/reset/reset-imx7.c
new file mode 100644
index 00..f2ca5cf801
--- /dev/null
+++ b/drivers/reset/reset-imx7.c
@@ -0,0 +1,312 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2017, Impinj, Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct imx7_reset_priv {
+   void __iomem *base;
+   struct reset_ops ops;
+};
+
+struct imx7_src_signal {
+   unsigned int offset, bit;
+};
+
+enum imx7_src_registers {
+   SRC_A7RCR0  = 0x0004,
+   SRC_M4RCR   = 0x000c,
+   SRC_ERCR= 0x0014,
+   SRC_HSICPHY_RCR = 0x001c,
+   SRC_USBOPHY1_RCR= 0x0020,
+   SRC_USBOPHY2_RCR= 0x0024,
+   SRC_MIPIPHY_RCR = 0x0028,
+   SRC_PCIEPHY_RCR = 0x002c,
+   SRC_DDRC_RCR= 0x1000,
+};
+
+static const struct imx7_src_signal imx7_src_signals[IMX7_RESET_NUM] = {
+   [IMX7_RESET_A7_CORE_POR_RESET0] = { SRC_A7RCR0, BIT(0) },
+   [IMX7_RESET_A7_CORE_POR_RESET1] = { SRC_A7RCR0, BIT(1) },
+   [IMX7_RESET_A7_CORE_RESET0] = { SRC_A7RCR0, BIT(4) },
+   [IMX7_RESET_A7_CORE_RESET1] = { SRC_A7RCR0, BIT(5) },
+   [IMX7_RESET_A7_DBG_RESET0]  = { SRC_A7RCR0, BIT(8) },
+   [IMX7_RESET_A7_DBG_RESET1]  = { SRC_A7RCR0, BIT(9) },
+   [IMX7_RESET_A7_ETM_RESET0]  = { SRC_A7RCR0, BIT(12) },
+   [IMX7_RESET_A7_ETM_RESET1]  = { SRC_A7RCR0, BIT(13) },
+   [IMX7_RESET_A7_SOC_DBG_RESET]   = { SRC_A7RCR0, BIT(20) },
+   [IMX7_RESET_A7_L2RESET] = { SRC_A7RCR0, BIT(21) },
+   [IMX7_RESET_SW_M4C_RST] = { SRC_M4RCR, BIT(1) },
+   [IMX7_RESET_SW_M4P_RST] = { SRC_M4RCR, BIT(2) },
+   [IMX7_RESET_EIM_RST]= { SRC_ERCR, BIT(0) },
+   [IMX7_RESET_HSICPHY_PORT_RST]   = { SRC_HSICPHY_RCR, BIT(1) },
+   [IMX7_RESET_USBPHY1_POR]= { SRC_USBOPHY1_RCR, BIT(0) },
+   [IMX7_RESET_USBPHY1_PORT_RST]   = { SRC_USBOPHY1_RCR, BIT(1) },
+   [IMX7_RESET_USBPHY2_POR]= { SRC_USBOPHY2_RCR, BIT(0) },
+   [IMX7_RESET_USBPHY2_PORT_RST]   = { SRC_USBOPHY2_RCR, BIT(1) },
+   [IMX7_RESET_MIPI_PHY_MRST]  = { SRC_MIPIPHY_RCR, BIT(1) },
+   [IMX7_RESET_MIPI_PHY_SRST]  = { SRC_MIPIPHY_RCR, BIT(2) },
+   [IMX7_RESET_PCIEPHY]= { SRC_PCIEPHY_RCR, BIT(2) | BIT(1) },
+   [IMX7_RESET_PCIEPHY_PERST]  = { SRC_PCIEPHY_RCR, BIT(3) },
+   [IMX7_RESET_PCIE_CTRL_APPS_EN]  = { SRC_PCIEPHY_RCR, BIT(6) },
+   [IMX7_RESET_PCIE_CTRL_APPS_TURNOFF] = { SRC_PCIEPHY_RCR, BIT(11) },
+   [IMX7_RESET_DDRC_PRST]  = { SRC_DDRC_RCR, BIT(0) },
+   [IMX7_RESET_DDRC_CORE_RST]  = { SRC_DDRC_RCR, BIT(1) },
+};
+
+static int 

[U-Boot] [PATCH 41/41] common: Move old EEPROM functions into a new header

2019-09-30 Thread Simon Glass
These functions do not use driver model but are still used. Move them to a
new eeprom_legacy.h header file.

Signed-off-by: Simon Glass 
---

 board/atmel/common/mac_eeprom.c   |  1 +
 board/compulab/common/eeprom.c|  1 +
 board/corscience/tricorder/tricorder-eeprom.c |  1 +
 board/dhelectronics/dh_imx6/dh_imx6.c |  1 +
 board/freescale/mpc8323erdb/mpc8323erdb.c |  1 +
 board/kosagi/novena/novena.c  |  1 +
 board/phytec/phycore_rk3288/phycore-rk3288.c  |  1 +
 board/rockchip/tinker_rk3288/tinker-rk3288.c  |  1 +
 board/samtec/vining_fpga/socfpga.c|  1 +
 board/ti/am43xx/board.c   |  1 +
 board/ti/common/board_detect.c|  1 +
 board/ti/ks2_evm/board_k2g.c  |  1 +
 cmd/eeprom.c  |  1 +
 drivers/misc/i2c_eeprom.c |  1 +
 drivers/mtd/mw_eeprom.c   |  1 +
 drivers/rtc/rv3029.c  |  1 +
 env/eeprom.c  |  1 +
 include/common.h  | 15 
 include/eeprom_legacy.h   | 24 +++
 19 files changed, 41 insertions(+), 15 deletions(-)
 create mode 100644 include/eeprom_legacy.h

diff --git a/board/atmel/common/mac_eeprom.c b/board/atmel/common/mac_eeprom.c
index 83a7778e995..cb9df31a6aa 100644
--- a/board/atmel/common/mac_eeprom.c
+++ b/board/atmel/common/mac_eeprom.c
@@ -6,6 +6,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/compulab/common/eeprom.c b/board/compulab/common/eeprom.c
index 81f69d38502..7e4ce893672 100644
--- a/board/compulab/common/eeprom.c
+++ b/board/compulab/common/eeprom.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/corscience/tricorder/tricorder-eeprom.c 
b/board/corscience/tricorder/tricorder-eeprom.c
index b28189dafdc..faec265fd93 100644
--- a/board/corscience/tricorder/tricorder-eeprom.c
+++ b/board/corscience/tricorder/tricorder-eeprom.c
@@ -5,6 +5,7 @@
  * Andreas Bießmann 
  */
 #include 
+#include 
 #include 
 #include 
 
diff --git a/board/dhelectronics/dh_imx6/dh_imx6.c 
b/board/dhelectronics/dh_imx6/dh_imx6.c
index 85e281ebb9c..3abfcc6694e 100644
--- a/board/dhelectronics/dh_imx6/dh_imx6.c
+++ b/board/dhelectronics/dh_imx6/dh_imx6.c
@@ -7,6 +7,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/freescale/mpc8323erdb/mpc8323erdb.c 
b/board/freescale/mpc8323erdb/mpc8323erdb.c
index cbec8a44e4d..a6f4dd06c25 100644
--- a/board/freescale/mpc8323erdb/mpc8323erdb.c
+++ b/board/freescale/mpc8323erdb/mpc8323erdb.c
@@ -10,6 +10,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/kosagi/novena/novena.c b/board/kosagi/novena/novena.c
index e4f0e81004e..9b2bd8f1dcf 100644
--- a/board/kosagi/novena/novena.c
+++ b/board/kosagi/novena/novena.c
@@ -7,6 +7,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/phytec/phycore_rk3288/phycore-rk3288.c 
b/board/phytec/phycore_rk3288/phycore-rk3288.c
index dac59cd55df..da3119d3cec 100644
--- a/board/phytec/phycore_rk3288/phycore-rk3288.c
+++ b/board/phytec/phycore_rk3288/phycore-rk3288.c
@@ -4,6 +4,7 @@
  * Author: Wadim Egorov 
  */
 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/rockchip/tinker_rk3288/tinker-rk3288.c 
b/board/rockchip/tinker_rk3288/tinker-rk3288.c
index 93e9d2f4653..740d309747d 100644
--- a/board/rockchip/tinker_rk3288/tinker-rk3288.c
+++ b/board/rockchip/tinker_rk3288/tinker-rk3288.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/samtec/vining_fpga/socfpga.c 
b/board/samtec/vining_fpga/socfpga.c
index 1ea89063889..9a57b3deefb 100644
--- a/board/samtec/vining_fpga/socfpga.c
+++ b/board/samtec/vining_fpga/socfpga.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c
index c4018498aad..99ab7c86cc9 100644
--- a/board/ti/am43xx/board.c
+++ b/board/ti/am43xx/board.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index bc89cc57bd7..79f6ea423d6 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index a0fd03a39fb..05f17727251 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -6,6 +6,7 @@
  * Texas Instruments Incorporated, 
  */
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/cmd/eeprom.c b/cmd/eeprom.c
index 19953df082f..8ed27a66215 100644
--- a/cmd/eeprom.c
+++ b/cmd/eeprom.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 

[U-Boot] [PATCH 29/41] common: Drop checkicache() and checkdcache()

2019-09-30 Thread Simon Glass
These are used by only one arch and only within a single file. Drop the
declarations from the common file.

Signed-off-by: Simon Glass 
---

 arch/powerpc/cpu/mpc8xx/cpu.c | 130 +-
 include/common.h  |   2 -
 2 files changed, 65 insertions(+), 67 deletions(-)

diff --git a/arch/powerpc/cpu/mpc8xx/cpu.c b/arch/powerpc/cpu/mpc8xx/cpu.c
index 36af7c16125..787c1bdc11d 100644
--- a/arch/powerpc/cpu/mpc8xx/cpu.c
+++ b/arch/powerpc/cpu/mpc8xx/cpu.c
@@ -35,70 +35,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int check_CPU(long clock, uint pvr, uint immr)
-{
-   immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR;
-   uint k;
-   char buf[32];
-
-   /* the highest 16 bits should be 0x0050 for a 860 */
-
-   if (PVR_VER(pvr) != PVR_VER(PVR_8xx))
-   return -1;
-
-   k = (immr << 16) |
-   in_be16(>im_cpm.cp_dparam16[PROFF_REVNUM / sizeof(u16)]);
-
-   /*
-* Some boards use sockets so different CPUs can be used.
-* We have to check chip version in run time.
-*/
-   switch (k) {
-   /* MPC866P/MPC866T/MPC859T/MPC859DSL/MPC852T */
-   case 0x08010004:/* Rev. A.0 */
-   printf("MPC866xxxZPnnA");
-   break;
-   case 0x0803:/* Rev. 0.3 */
-   printf("MPC866xxxZPnn");
-   break;
-   case 0x0900:/* 870/875/880/885 */
-   puts("MPC885ZPnn");
-   break;
-
-   default:
-   printf("unknown MPC86x (0x%08x)", k);
-   break;
-   }
-
-   printf(" at %s MHz: ", strmhz(buf, clock));
-
-   print_size(checkicache(), " I-Cache ");
-   print_size(checkdcache(), " D-Cache");
-
-   /* do we have a FEC (860T/P or 852/859/866/885)? */
-
-   out_be32(>im_cpm.cp_fec.fec_addr_low, 0x12345678);
-   if (in_be32(>im_cpm.cp_fec.fec_addr_low) == 0x12345678)
-   printf(" FEC present");
-
-   putc('\n');
-
-   return 0;
-}
-
-/* - */
-
-int checkcpu(void)
-{
-   ulong clock = gd->cpu_clk;
-   uint immr = get_immr(); /* Return full IMMR contents */
-   uint pvr = get_pvr();
-
-   puts("CPU:   ");
-
-   return check_CPU(clock, pvr, immr);
-}
-
 /* - */
 /* L1 i-cache*/
 
@@ -143,7 +79,7 @@ int checkicache(void)
 /* L1 d-cache*/
 /* call with cache disabled  */
 
-int checkdcache(void)
+static int checkdcache(void)
 {
immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR;
memctl8xx_t __iomem *memctl = >im_memctl;
@@ -175,6 +111,70 @@ int checkdcache(void)
return lines << 4;
 };
 
+static int check_CPU(long clock, uint pvr, uint immr)
+{
+   immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR;
+   uint k;
+   char buf[32];
+
+   /* the highest 16 bits should be 0x0050 for a 860 */
+
+   if (PVR_VER(pvr) != PVR_VER(PVR_8xx))
+   return -1;
+
+   k = (immr << 16) |
+   in_be16(>im_cpm.cp_dparam16[PROFF_REVNUM / sizeof(u16)]);
+
+   /*
+* Some boards use sockets so different CPUs can be used.
+* We have to check chip version in run time.
+*/
+   switch (k) {
+   /* MPC866P/MPC866T/MPC859T/MPC859DSL/MPC852T */
+   case 0x08010004:/* Rev. A.0 */
+   printf("MPC866xxxZPnnA");
+   break;
+   case 0x0803:/* Rev. 0.3 */
+   printf("MPC866xxxZPnn");
+   break;
+   case 0x0900:/* 870/875/880/885 */
+   puts("MPC885ZPnn");
+   break;
+
+   default:
+   printf("unknown MPC86x (0x%08x)", k);
+   break;
+   }
+
+   printf(" at %s MHz: ", strmhz(buf, clock));
+
+   print_size(checkicache(), " I-Cache ");
+   print_size(checkdcache(), " D-Cache");
+
+   /* do we have a FEC (860T/P or 852/859/866/885)? */
+
+   out_be32(>im_cpm.cp_fec.fec_addr_low, 0x12345678);
+   if (in_be32(>im_cpm.cp_fec.fec_addr_low) == 0x12345678)
+   printf(" FEC present");
+
+   putc('\n');
+
+   return 0;
+}
+
+/* - */
+
+int checkcpu(void)
+{
+   ulong clock = gd->cpu_clk;
+   uint immr = get_immr(); /* Return full IMMR contents */
+   uint pvr = get_pvr();
+
+   puts("CPU:   ");
+
+   return check_CPU(clock, pvr, immr);
+}
+
 /* - */
 
 void upmconfig(uint upm, uint *table, uint size)
diff --git a/include/common.h 

[U-Boot] [PATCH 40/41] common: Drop get_endaddr()

2019-09-30 Thread Simon Glass
This is not used in U-Boot. Drop it.

Signed-off-by: Simon Glass 
---

 include/common.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/common.h b/include/common.h
index e946e4d9b7f..64d0cf542e8 100644
--- a/include/common.h
+++ b/include/common.h
@@ -144,7 +144,6 @@ voidrelocate_code(ulong);
 #else
 void   relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn));
 #endif
-ulong  get_endaddr   (void);
 
 void s_init(void);
 
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 36/41] common: Move board_get_usable_ram_top() out of common.h

2019-09-30 Thread Simon Glass
Move this function into init.h which seems to be designed for this sort
of thing. Also update the header to declare struct global_data so that it
can be included without global_data.h being needed.

Signed-off-by: Simon Glass 
---

 arch/arm/mach-mvebu/arm64-common.c|  1 +
 arch/arm/mach-rockchip/sdram_common.c |  1 +
 arch/arm/mach-tegra/board2.c  |  1 +
 arch/mips/mach-jz47xx/jz4780/jz4780.c |  1 +
 arch/riscv/cpu/generic/dram.c |  1 +
 arch/x86/cpu/broadwell/sdram.c|  1 +
 arch/x86/cpu/coreboot/sdram.c |  1 +
 arch/x86/cpu/efi/payload.c|  1 +
 arch/x86/cpu/efi/sdram.c  |  1 +
 arch/x86/cpu/intel_common/mrc.c   |  1 +
 arch/x86/cpu/ivybridge/sdram.c|  1 +
 arch/x86/cpu/qemu/dram.c  |  1 +
 arch/x86/cpu/quark/dram.c |  1 +
 arch/x86/cpu/slimbootloader/sdram.c   |  1 +
 arch/x86/lib/fsp/fsp_dram.c   |  1 +
 arch/x86/lib/init_helpers.c   |  1 +
 board/armadeus/apf27/apf27.c  |  1 +
 board/imgtec/boston/ddr.c |  1 +
 board/menlo/m53menlo/m53menlo.c   |  1 +
 board/raspberrypi/rpi/rpi.c   |  1 +
 board/ti/am65x/evm.c  |  1 +
 board/ti/j721e/evm.c  |  1 +
 common/board_f.c  |  1 +
 drivers/video/fsl_dcu_fb.c|  1 +
 drivers/video/sunxi/sunxi_display.c   |  1 +
 include/common.h  | 11 ---
 include/init.h| 20 ++--
 lib/efi_loader/efi_memory.c   |  1 +
 28 files changed, 44 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-mvebu/arm64-common.c 
b/arch/arm/mach-mvebu/arm64-common.c
index aaf7b7c4472..40b98dbf08b 100644
--- a/arch/arm/mach-mvebu/arm64-common.c
+++ b/arch/arm/mach-mvebu/arm64-common.c
@@ -6,6 +6,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-rockchip/sdram_common.c 
b/arch/arm/mach-rockchip/sdram_common.c
index 22a4aca9402..74a1223532e 100644
--- a/arch/arm/mach-rockchip/sdram_common.c
+++ b/arch/arm/mach-rockchip/sdram_common.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-tegra/board2.c b/arch/arm/mach-tegra/board2.c
index f13bd256cc2..46491a1d43f 100644
--- a/arch/arm/mach-tegra/board2.c
+++ b/arch/arm/mach-tegra/board2.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/mips/mach-jz47xx/jz4780/jz4780.c 
b/arch/mips/mach-jz47xx/jz4780/jz4780.c
index 0949cbc3d09..967fc41be49 100644
--- a/arch/mips/mach-jz47xx/jz4780/jz4780.c
+++ b/arch/mips/mach-jz47xx/jz4780/jz4780.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/riscv/cpu/generic/dram.c b/arch/riscv/cpu/generic/dram.c
index b7b12072351..1dc77efeca5 100644
--- a/arch/riscv/cpu/generic/dram.c
+++ b/arch/riscv/cpu/generic/dram.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/arch/x86/cpu/broadwell/sdram.c b/arch/x86/cpu/broadwell/sdram.c
index b31d78c092a..dfd8afc35f5 100644
--- a/arch/x86/cpu/broadwell/sdram.c
+++ b/arch/x86/cpu/broadwell/sdram.c
@@ -7,6 +7,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/x86/cpu/coreboot/sdram.c b/arch/x86/cpu/coreboot/sdram.c
index 664817feffd..27e859885e8 100644
--- a/arch/x86/cpu/coreboot/sdram.c
+++ b/arch/x86/cpu/coreboot/sdram.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/arch/x86/cpu/efi/payload.c b/arch/x86/cpu/efi/payload.c
index 019e312527e..8f8a9331944 100644
--- a/arch/x86/cpu/efi/payload.c
+++ b/arch/x86/cpu/efi/payload.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/x86/cpu/efi/sdram.c b/arch/x86/cpu/efi/sdram.c
index a45525f842e..3143c079adb 100644
--- a/arch/x86/cpu/efi/sdram.c
+++ b/arch/x86/cpu/efi/sdram.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/arch/x86/cpu/intel_common/mrc.c b/arch/x86/cpu/intel_common/mrc.c
index b35102a3f08..755670a847e 100644
--- a/arch/x86/cpu/intel_common/mrc.c
+++ b/arch/x86/cpu/intel_common/mrc.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/x86/cpu/ivybridge/sdram.c b/arch/x86/cpu/ivybridge/sdram.c
index 8a58d0383d5..51ca4ad3017 100644
--- a/arch/x86/cpu/ivybridge/sdram.c
+++ b/arch/x86/cpu/ivybridge/sdram.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/x86/cpu/qemu/dram.c b/arch/x86/cpu/qemu/dram.c
index 6707b7b3634..19d92f27d80 100644
--- a/arch/x86/cpu/qemu/dram.c
+++ b/arch/x86/cpu/qemu/dram.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/arch/x86/cpu/quark/dram.c b/arch/x86/cpu/quark/dram.c
index 

[U-Boot] [PATCH 33/41] common: Move enable/disable_interrupts out of common.h

2019-09-30 Thread Simon Glass
Move these two functions into the irq_legacy.h header file.
Also move interrupt_handler_t as this is used by the irq_install_handler()
function.

Signed-off-by: Simon Glass 
---

 arch/arc/lib/bootm.c  | 1 +
 arch/arm/cpu/arm11/cpu.c  | 1 +
 arch/arm/cpu/arm920t/cpu.c| 1 +
 arch/arm/cpu/arm926ejs/cpu.c  | 1 +
 arch/arm/cpu/arm946es/cpu.c   | 1 +
 arch/arm/cpu/armv7/cpu.c  | 1 +
 arch/arm/cpu/armv7m/cpu.c | 1 +
 arch/arm/cpu/armv8/cpu.c  | 1 +
 arch/arm/cpu/pxa/pxa2xx.c | 1 +
 arch/arm/cpu/sa1100/cpu.c | 1 +
 arch/arm/lib/reset.c  | 1 +
 arch/arm/mach-tegra/cmd_enterrcm.c| 1 +
 arch/microblaze/include/asm/microblaze_intc.h | 2 ++
 arch/nds32/cpu/n1213/ag101/cpu.c  | 1 +
 arch/nios2/cpu/cpu.c  | 1 +
 arch/nios2/lib/bootm.c| 1 +
 arch/powerpc/cpu/mpc83xx/cpu.c| 1 +
 arch/powerpc/cpu/mpc83xx/ecc.c| 1 +
 arch/powerpc/cpu/mpc85xx/cpu.c| 1 +
 arch/riscv/cpu/generic/cpu.c  | 1 +
 arch/sh/cpu/sh4/cpu.c | 1 +
 arch/sh/lib/zimageboot.c  | 1 +
 arch/x86/lib/zimage.c | 1 +
 board/bosch/shc/board.c   | 1 +
 board/cobra5272/flash.c   | 1 +
 board/freescale/b4860qds/b4860qds.c   | 1 +
 board/freescale/common/vid.c  | 1 +
 board/freescale/m5253demo/flash.c | 1 +
 board/freescale/t4qds/t4240qds.c  | 1 +
 board/synopsys/hsdk/hsdk.c| 1 +
 cmd/booti.c   | 1 +
 cmd/bootz.c   | 1 +
 cmd/fdc.c | 1 +
 cmd/irq.c | 1 +
 common/board_r.c  | 1 +
 common/bootm.c| 1 +
 drivers/firmware/psci.c   | 1 +
 drivers/mtd/pic32_flash.c | 1 +
 include/common.h  | 6 --
 include/exports.h | 2 ++
 include/irq_legacy.h  | 9 -
 lib/efi_loader/efi_boottime.c | 1 +
 post/cpu/mpc83xx/ecc.c| 1 +
 post/lib_powerpc/andi.c   | 1 +
 post/lib_powerpc/b.c  | 1 +
 post/lib_powerpc/cmp.c| 1 +
 post/lib_powerpc/cmpi.c   | 1 +
 post/lib_powerpc/complex.c| 1 +
 post/lib_powerpc/cr.c | 1 +
 post/lib_powerpc/load.c   | 1 +
 post/lib_powerpc/multi.c  | 1 +
 post/lib_powerpc/rlwimi.c | 1 +
 post/lib_powerpc/rlwinm.c | 1 +
 post/lib_powerpc/rlwnm.c  | 1 +
 post/lib_powerpc/srawi.c  | 1 +
 post/lib_powerpc/store.c  | 1 +
 post/lib_powerpc/string.c | 1 +
 post/lib_powerpc/three.c  | 1 +
 post/lib_powerpc/threei.c | 1 +
 post/lib_powerpc/threex.c | 1 +
 post/lib_powerpc/two.c| 1 +
 post/lib_powerpc/twox.c   | 1 +
 62 files changed, 70 insertions(+), 7 deletions(-)

diff --git a/arch/arc/lib/bootm.c b/arch/arc/lib/bootm.c
index 254e0284b3f..15764093c42 100644
--- a/arch/arc/lib/bootm.c
+++ b/arch/arc/lib/bootm.c
@@ -3,6 +3,7 @@
  * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
  */
 
+#include 
 #include 
 #include 
 
diff --git a/arch/arm/cpu/arm11/cpu.c b/arch/arm/cpu/arm11/cpu.c
index 280622fe33a..9aa410458ef 100644
--- a/arch/arm/cpu/arm11/cpu.c
+++ b/arch/arm/cpu/arm11/cpu.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 static void cache_flush(void);
diff --git a/arch/arm/cpu/arm920t/cpu.c b/arch/arm/cpu/arm920t/cpu.c
index e632aa52f8c..ccdb9f8d5e7 100644
--- a/arch/arm/cpu/arm920t/cpu.c
+++ b/arch/arm/cpu/arm920t/cpu.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 static void cache_flush(void);
diff --git a/arch/arm/cpu/arm926ejs/cpu.c b/arch/arm/cpu/arm926ejs/cpu.c
index f4b27d93be6..a5911d904d9 100644
--- a/arch/arm/cpu/arm926ejs/cpu.c
+++ b/arch/arm/cpu/arm926ejs/cpu.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 static void cache_flush(void);
diff --git a/arch/arm/cpu/arm946es/cpu.c b/arch/arm/cpu/arm946es/cpu.c
index 19b805096f4..24efd186bba 100644
--- a/arch/arm/cpu/arm946es/cpu.c
+++ b/arch/arm/cpu/arm946es/cpu.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/arch/arm/cpu/armv7/cpu.c b/arch/arm/cpu/armv7/cpu.c
index 

[U-Boot] [PATCH 35/41] common: Drop board_show_dram()

2019-09-30 Thread Simon Glass
This function is not defined by any boards so the feature is not used.
Drop it.

Signed-off-by: Simon Glass 
---

 cmd/mem.c| 9 ++---
 include/common.h | 9 -
 2 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/cmd/mem.c b/cmd/mem.c
index c6b8038fc9d..545534b1fc7 100644
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -1212,16 +1212,11 @@ U_BOOT_CMD(
 #endif
 
 #ifdef CONFIG_CMD_MEMINFO
-__weak void board_show_dram(phys_size_t size)
-{
-   puts("DRAM:  ");
-   print_size(size, "\n");
-}
-
 static int do_mem_info(cmd_tbl_t *cmdtp, int flag, int argc,
   char * const argv[])
 {
-   board_show_dram(gd->ram_size);
+   puts("DRAM:  ");
+   print_size(gd->ram_size, "\n");
 
return 0;
 }
diff --git a/include/common.h b/include/common.h
index 5bd778a4f46..16d4b0612f8 100644
--- a/include/common.h
+++ b/include/common.h
@@ -73,15 +73,6 @@ extern u8 __dtb_dt_begin[];  /* embedded device tree blob */
 extern u8 __dtb_dt_spl_begin[];/* embedded device tree blob for 
SPL/TPL */
 int mdm_init(void);
 
-/**
- * Show the DRAM size in a board-specific way
- *
- * This is used by boards to display DRAM information in their own way.
- *
- * @param size Size of DRAM (which should be displayed along with other info)
- */
-void board_show_dram(phys_size_t size);
-
 /**
  * Get the uppermost pointer that is valid to access
  *
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 34/41] common: Move command functions out of common.h

2019-09-30 Thread Simon Glass
Move these functions into the command.h header file which is a better fit.

Signed-off-by: Simon Glass 
---

 arch/arm/mach-kirkwood/cpu.c|  1 +
 arch/sandbox/cpu/start.c|  1 +
 board/engicam/common/board.c|  1 +
 board/gdsys/a38x/keyprogram.c   |  1 +
 board/gdsys/p1022/controlcenterd-id.c   |  1 +
 board/grinn/liteboard/board.c   |  1 +
 board/inversepath/usbarmory/usbarmory.c |  1 +
 board/samsung/common/misc.c |  1 +
 common/autoboot.c   |  1 +
 common/cli.c|  1 +
 common/cli_simple.c |  1 +
 common/main.c   |  1 +
 common/splash_source.c  |  1 +
 drivers/fastboot/fb_command.c   |  1 +
 drivers/fastboot/fb_common.c|  1 +
 drivers/mtd/nand/raw/fsl_elbc_nand.c|  1 +
 drivers/mtd/nand/raw/fsl_ifc_nand.c |  1 +
 drivers/net/fsl-mc/mc.c |  1 +
 drivers/usb/gadget/f_thor.c |  1 +
 include/command.h   | 16 
 include/common.h| 17 +
 test/command_ut.c   |  1 +
 test/dm/sf.c|  1 +
 23 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-kirkwood/cpu.c b/arch/arm/mach-kirkwood/cpu.c
index 6ad25434386..29c0e592e42 100644
--- a/arch/arm/mach-kirkwood/cpu.c
+++ b/arch/arm/mach-kirkwood/cpu.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 82828f0c1d4..d6797ba8435 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/engicam/common/board.c b/board/engicam/common/board.c
index 0c47afe5b56..31ff297b756 100644
--- a/board/engicam/common/board.c
+++ b/board/engicam/common/board.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/gdsys/a38x/keyprogram.c b/board/gdsys/a38x/keyprogram.c
index 000897984a6..853981aadbb 100644
--- a/board/gdsys/a38x/keyprogram.c
+++ b/board/gdsys/a38x/keyprogram.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/gdsys/p1022/controlcenterd-id.c 
b/board/gdsys/p1022/controlcenterd-id.c
index d6798bd3382..04d38095665 100644
--- a/board/gdsys/p1022/controlcenterd-id.c
+++ b/board/gdsys/p1022/controlcenterd-id.c
@@ -11,6 +11,7 @@
 #endif
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/grinn/liteboard/board.c b/board/grinn/liteboard/board.c
index 1558ea4b84f..151041a789e 100644
--- a/board/grinn/liteboard/board.c
+++ b/board/grinn/liteboard/board.c
@@ -4,6 +4,7 @@
  * Copyright (C) 2016 Grinn
  */
 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/inversepath/usbarmory/usbarmory.c 
b/board/inversepath/usbarmory/usbarmory.c
index de4ad832268..19510184d8a 100644
--- a/board/inversepath/usbarmory/usbarmory.c
+++ b/board/inversepath/usbarmory/usbarmory.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c
index 3ef1e799801..9117669f715 100644
--- a/board/samsung/common/misc.c
+++ b/board/samsung/common/misc.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/common/autoboot.c b/common/autoboot.c
index 8faac2005df..94a1b4abeba 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/common/cli.c b/common/cli.c
index 49b910666b9..67ceb635a67 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/common/cli_simple.c b/common/cli_simple.c
index 6c881c133c6..358e9b7fe11 100644
--- a/common/cli_simple.c
+++ b/common/cli_simple.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/common/main.c b/common/main.c
index 3a657c3d9a3..a94df7ae042 100644
--- a/common/main.c
+++ b/common/main.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/common/splash_source.c b/common/splash_source.c
index d37b4b304c2..2ff15208a70 100644
--- a/common/splash_source.c
+++ b/common/splash_source.c
@@ -7,6 +7,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
index 4864344853c..3c4acfecf6d 100644
--- a/drivers/fastboot/fb_command.c
+++ b/drivers/fastboot/fb_command.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index e76af8ecc32..c3735a44af7 100644
--- 

[U-Boot] [PATCH 25/41] common: Move checkcpu() out of common.h

2019-09-30 Thread Simon Glass
This function belongs in cpu.h so move it over.

Signed-off-by: Simon Glass 
---

 arch/powerpc/cpu/mpc83xx/cpu.c   |  1 +
 arch/powerpc/cpu/mpc8xx/cpu.c|  1 +
 arch/sh/cpu/sh4/cpu.c|  1 +
 arch/x86/cpu/broadwell/cpu_from_spl.c|  1 +
 arch/x86/cpu/coreboot/coreboot.c |  1 +
 arch/x86/cpu/efi/app.c   |  1 +
 arch/x86/cpu/efi/payload.c   |  1 +
 arch/x86/cpu/ivybridge/cpu.c |  1 +
 arch/x86/cpu/qemu/qemu.c |  1 +
 arch/x86/cpu/quark/quark.c   |  1 +
 arch/x86/cpu/slimbootloader/slimbootloader.c |  1 +
 arch/x86/cpu/tangier/tangier.c   |  1 +
 arch/x86/cpu/x86_64/cpu.c|  1 +
 arch/x86/lib/fsp/fsp_common.c|  1 +
 common/board_f.c |  1 +
 include/common.h |  1 -
 include/cpu_legacy.h | 10 ++
 17 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/cpu/mpc83xx/cpu.c b/arch/powerpc/cpu/mpc83xx/cpu.c
index 363c0ffd285..1c0d0d26320 100644
--- a/arch/powerpc/cpu/mpc83xx/cpu.c
+++ b/arch/powerpc/cpu/mpc83xx/cpu.c
@@ -10,6 +10,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/powerpc/cpu/mpc8xx/cpu.c b/arch/powerpc/cpu/mpc8xx/cpu.c
index 6ad86e9a1d7..36af7c16125 100644
--- a/arch/powerpc/cpu/mpc8xx/cpu.c
+++ b/arch/powerpc/cpu/mpc8xx/cpu.c
@@ -17,6 +17,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/sh/cpu/sh4/cpu.c b/arch/sh/cpu/sh4/cpu.c
index a8b50a9ff5c..d79e6ea71d5 100644
--- a/arch/sh/cpu/sh4/cpu.c
+++ b/arch/sh/cpu/sh4/cpu.c
@@ -6,6 +6,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/arch/x86/cpu/broadwell/cpu_from_spl.c 
b/arch/x86/cpu/broadwell/cpu_from_spl.c
index c3d4a8d5477..feb0732ee9b 100644
--- a/arch/x86/cpu/broadwell/cpu_from_spl.c
+++ b/arch/x86/cpu/broadwell/cpu_from_spl.c
@@ -6,6 +6,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/x86/cpu/coreboot/coreboot.c b/arch/x86/cpu/coreboot/coreboot.c
index 9686f8ed5b4..67cfcb72d7a 100644
--- a/arch/x86/cpu/coreboot/coreboot.c
+++ b/arch/x86/cpu/coreboot/coreboot.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/x86/cpu/efi/app.c b/arch/x86/cpu/efi/app.c
index ba7c02bd7e8..34bdc40e396 100644
--- a/arch/x86/cpu/efi/app.c
+++ b/arch/x86/cpu/efi/app.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/arch/x86/cpu/efi/payload.c b/arch/x86/cpu/efi/payload.c
index 225aef7bf6a..019e312527e 100644
--- a/arch/x86/cpu/efi/payload.c
+++ b/arch/x86/cpu/efi/payload.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/x86/cpu/ivybridge/cpu.c b/arch/x86/cpu/ivybridge/cpu.c
index c8b16e32c03..f95178b8319 100644
--- a/arch/x86/cpu/ivybridge/cpu.c
+++ b/arch/x86/cpu/ivybridge/cpu.c
@@ -11,6 +11,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/x86/cpu/qemu/qemu.c b/arch/x86/cpu/qemu/qemu.c
index 5e8b4f068e1..c76868fa90f 100644
--- a/arch/x86/cpu/qemu/qemu.c
+++ b/arch/x86/cpu/qemu/qemu.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/x86/cpu/quark/quark.c b/arch/x86/cpu/quark/quark.c
index d39edb2271b..f598666a6b0 100644
--- a/arch/x86/cpu/quark/quark.c
+++ b/arch/x86/cpu/quark/quark.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/x86/cpu/slimbootloader/slimbootloader.c 
b/arch/x86/cpu/slimbootloader/slimbootloader.c
index e6b174ca886..16dd4d73813 100644
--- a/arch/x86/cpu/slimbootloader/slimbootloader.c
+++ b/arch/x86/cpu/slimbootloader/slimbootloader.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/arch/x86/cpu/tangier/tangier.c b/arch/x86/cpu/tangier/tangier.c
index df2c600be33..a758ac4f1ed 100644
--- a/arch/x86/cpu/tangier/tangier.c
+++ b/arch/x86/cpu/tangier/tangier.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 
 /*
diff --git a/arch/x86/cpu/x86_64/cpu.c b/arch/x86/cpu/x86_64/cpu.c
index 42abb23a9ed..7d291f60f5b 100644
--- a/arch/x86/cpu/x86_64/cpu.c
+++ b/arch/x86/cpu/x86_64/cpu.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 
 /*
diff --git a/arch/x86/lib/fsp/fsp_common.c b/arch/x86/lib/fsp/fsp_common.c
index ed0827c6e92..b981590917a 100644
--- a/arch/x86/lib/fsp/fsp_common.c
+++ b/arch/x86/lib/fsp/fsp_common.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/common/board_f.c b/common/board_f.c
index 9cfa465ac17..ca26375cdb2 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/include/common.h b/include/common.h
index ce08bfe11fe..96bb42ce71c 

[U-Boot] [PATCH 37/41] common: Move some board functions out of common.h

2019-09-30 Thread Simon Glass
A number of board function belong in init.h with the others. Move them.

Signed-off-by: Simon Glass 
---

 arch/arm/cpu/armv8/fsl-layerscape/soc.c   | 1 +
 arch/arm/mach-imx/mx6/opos6ul.c   | 1 +
 arch/arm/mach-imx/mx6/soc.c   | 1 +
 arch/arm/mach-imx/mx7ulp/soc.c| 1 +
 arch/arm/mach-meson/board-common.c| 1 +
 arch/arm/mach-rockchip/board.c| 1 +
 arch/arm/mach-rockchip/rk3288/rk3288.c| 1 +
 arch/arm/mach-uniphier/board_late_init.c  | 1 +
 arch/arm/mach-zynqmp/spl.c| 1 +
 arch/powerpc/cpu/mpc85xx/cpu_init.c   | 1 +
 board/Arcturus/ucp1020/ucp1020.c  | 1 +
 board/BuR/brppt1/board.c  | 1 +
 board/BuR/brsmarc1/board.c| 1 +
 board/BuR/brxre1/board.c  | 1 +
 board/CZ.NIC/turris_mox/turris_mox.c  | 1 +
 board/CZ.NIC/turris_omnia/turris_omnia.c  | 1 +
 board/Marvell/mvebu_armada-8k/board.c | 1 +
 board/advantech/dms-ba16/dms-ba16.c   | 1 +
 board/aristainetos/aristainetos-v2.c  | 1 +
 board/armadeus/opos6uldev/board.c | 1 +
 board/atmark-techno/armadillo-800eva/armadillo-800eva.c   | 1 +
 board/atmel/at91sam9x5ek/at91sam9x5ek.c   | 1 +
 board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c   | 1 +
 board/atmel/sama5d2_icp/sama5d2_icp.c | 1 +
 board/atmel/sama5d2_ptc_ek/sama5d2_ptc_ek.c   | 1 +
 board/atmel/sama5d2_xplained/sama5d2_xplained.c   | 1 +
 board/atmel/sama5d3_xplained/sama5d3_xplained.c   | 1 +
 board/atmel/sama5d3xek/sama5d3xek.c   | 1 +
 board/atmel/sama5d4_xplained/sama5d4_xplained.c   | 1 +
 board/atmel/sama5d4ek/sama5d4ek.c | 1 +
 board/beckhoff/mx53cx9020/mx53cx9020.c| 1 +
 board/birdland/bav335x/board.c| 1 +
 board/bluewater/gurnard/gurnard.c | 1 +
 board/bosch/shc/board.c   | 1 +
 board/broadcom/bcmstb/bcmstb.c| 1 +
 board/cadence/xtfpga/xtfpga.c | 1 +
 board/ccv/xpress/xpress.c | 1 +
 board/chipspark/popmetal_rk3288/popmetal-rk3288.c | 1 +
 board/compulab/cl-som-imx7/cl-som-imx7.c  | 1 +
 board/compulab/cm_fx6/cm_fx6.c| 1 +
 board/congatec/cgtqmx6eval/cgtqmx6eval.c  | 1 +
 .../congatec/conga-qeval20-qa3-e3845/conga-qeval20-qa3.c  | 1 +
 board/coreboot/coreboot/coreboot.c| 1 +
 board/cssi/MCR3000/MCR3000.c  | 1 +
 board/dfi/dfi-bt700/dfi-bt700.c   | 1 +
 board/dhelectronics/dh_imx6/dh_imx6.c | 1 +
 board/eets/pdu001/board.c | 1 +
 board/efi/efi-x86_payload/payload.c   | 1 +
 board/el/el6x/el6x.c  | 1 +
 board/embest/mx6boards/mx6boards.c| 1 +
 board/emulation/qemu-riscv/qemu-riscv.c   | 1 +
 board/engicam/common/board.c  | 1 +
 board/freescale/b4860qds/b4860qds.c   | 1 +
 board/freescale/bsc9132qds/bsc9132qds.c   | 1 +
 board/freescale/c29xpcie/c29xpcie.c   | 1 +
 board/freescale/corenet_ds/corenet_ds.c   | 1 +
 board/freescale/imx8mq_evk/imx8mq_evk.c   | 1 +
 board/freescale/imx8qm_mek/imx8qm_mek.c   | 1 +
 board/freescale/imx8qxp_mek/imx8qxp_mek.c | 1 +
 board/freescale/ls1021aiot/ls1021aiot.c   | 1 +
 board/freescale/ls1021aqds/ls1021aqds.c   | 1 +
 board/freescale/ls1021atsn/ls1021atsn.c   | 1 +
 board/freescale/ls1021atwr/ls1021atwr.c   | 1 +
 board/freescale/mpc8313erdb/mpc8313erdb.c | 1 +
 board/freescale/mpc832xemds/mpc832xemds.c | 1 +
 board/freescale/mpc837xemds/mpc837xemds.c | 1 +
 board/freescale/mpc8536ds/mpc8536ds.c | 1 +
 board/freescale/mpc8569mds/mpc8569mds.c   | 1 +
 board/freescale/mpc8572ds/mpc8572ds.c | 1 +
 board/freescale/mx25pdk/mx25pdk.c | 1 +
 board/freescale/mx31pdk/mx31pdk.c | 1 +
 board/freescale/mx35pdk/mx35pdk.c | 1 +
 board/freescale/mx51evk/mx51evk.c | 1 +
 board/freescale/mx53evk/mx53evk.c | 1 +
 board/freescale/mx53loco/mx53loco.c   | 1 +
 

[U-Boot] [PATCH 20/41] common: Move timer_get_us() function out of common.h

2019-09-30 Thread Simon Glass
This function belongs in time.h so move it over and update the comment
style.

Signed-off-by: Simon Glass 
---

 include/common.h | 3 ---
 include/time.h   | 7 +++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/common.h b/include/common.h
index 091b54787f7..e68bed64078 100644
--- a/include/common.h
+++ b/include/common.h
@@ -251,9 +251,6 @@ voidirq_install_handler(int, interrupt_handler_t *, 
void *);
 void   irq_free_handler   (int);
 void   reset_timer(void);
 
-/* Return value of monotonic microsecond timer */
-unsigned long timer_get_us(void);
-
 void   enable_interrupts  (void);
 intdisable_interrupts (void);
 
diff --git a/include/time.h b/include/time.h
index e740858f816..4d16f12d76a 100644
--- a/include/time.h
+++ b/include/time.h
@@ -94,4 +94,11 @@ ulong ticks2usec(unsigned long ticks);
  */
 void wait_ticks(unsigned long ticks);
 
+/**
+ * timer_get_us() - Get monotonic microsecond timer
+ *
+ * @return value of monotonic microsecond timer
+ */
+unsigned long timer_get_us(void);
+
 #endif /* _TIME_H */
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 26/41] common: Move some SMP functions out of common.h

2019-09-30 Thread Simon Glass
These functions belong in cpu_legacy.h so move them over.

Signed-off-by: Simon Glass 
---

 arch/arm/cpu/armv7/ls102xa/cpu.c| 1 +
 arch/arm/cpu/armv7/virt-v7.c| 1 +
 arch/arm/lib/bootm.c| 1 +
 arch/arm/mach-uniphier/arm32/psci.c | 1 +
 board/armltd/vexpress/vexpress_common.c | 1 +
 board/broadcom/bcm_ep/board.c   | 1 +
 board/samsung/arndale/arndale.c | 1 +
 board/synopsys/axs10x/axs10x.c  | 1 +
 board/xilinx/zynqmp/zynqmp.c| 1 +
 cmd/elf.c   | 1 +
 include/common.h| 3 ---
 include/cpu_legacy.h| 3 +++
 12 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/armv7/ls102xa/cpu.c b/arch/arm/cpu/armv7/ls102xa/cpu.c
index ec9984db795..0c61f31516d 100644
--- a/arch/arm/cpu/armv7/ls102xa/cpu.c
+++ b/arch/arm/cpu/armv7/ls102xa/cpu.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/cpu/armv7/virt-v7.c b/arch/arm/cpu/armv7/virt-v7.c
index be14eb9376f..1f01a7fd197 100644
--- a/arch/arm/cpu/armv7/virt-v7.c
+++ b/arch/arm/cpu/armv7/virt-v7.c
@@ -9,6 +9,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 1638f1e81d7..af774a53c27 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -13,6 +13,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-uniphier/arm32/psci.c 
b/arch/arm/mach-uniphier/arm32/psci.c
index ef35923f6ac..7f9c9d1fe59 100644
--- a/arch/arm/mach-uniphier/arm32/psci.c
+++ b/arch/arm/mach-uniphier/arm32/psci.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/armltd/vexpress/vexpress_common.c 
b/board/armltd/vexpress/vexpress_common.c
index 30b9dbbe8a7..25da4c39046 100644
--- a/board/armltd/vexpress/vexpress_common.c
+++ b/board/armltd/vexpress/vexpress_common.c
@@ -16,6 +16,7 @@
  * Philippe Robin, 
  */
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/broadcom/bcm_ep/board.c b/board/broadcom/bcm_ep/board.c
index b2469dcb52a..0c3aa3b05f5 100644
--- a/board/broadcom/bcm_ep/board.c
+++ b/board/broadcom/bcm_ep/board.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/samsung/arndale/arndale.c b/board/samsung/arndale/arndale.c
index d06ab8f3c0c..0d33f5c4491 100644
--- a/board/samsung/arndale/arndale.c
+++ b/board/samsung/arndale/arndale.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/synopsys/axs10x/axs10x.c b/board/synopsys/axs10x/axs10x.c
index 7c4fcf281cb..bd39d0c7d81 100644
--- a/board/synopsys/axs10x/axs10x.c
+++ b/board/synopsys/axs10x/axs10x.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index d649daba96d..babec5f34fd 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/cmd/elf.c b/cmd/elf.c
index 538562fda58..690c61791d4 100644
--- a/cmd/elf.c
+++ b/cmd/elf.c
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/include/common.h b/include/common.h
index 96bb42ce71c..3f6a95d7e02 100644
--- a/include/common.h
+++ b/include/common.h
@@ -212,9 +212,6 @@ voidreset_cpu (ulong addr);
 void ft_cpu_setup(void *blob, bd_t *bd);
 void ft_pci_setup(void *blob, bd_t *bd);
 
-void smp_set_core_boot_addr(unsigned long addr, int corenr);
-void smp_kick_all_cpus(void);
-
 /* $(CPU)/speed.c */
 intget_clocks (void);
 ulong  get_bus_freq  (ulong);
diff --git a/include/cpu_legacy.h b/include/cpu_legacy.h
index 03feaa63e96..1741f7f7a63 100644
--- a/include/cpu_legacy.h
+++ b/include/cpu_legacy.h
@@ -49,4 +49,7 @@ int is_core_valid(unsigned int core);
  */
 int checkcpu(void);
 
+void smp_set_core_boot_addr(unsigned long addr, int corenr);
+void smp_kick_all_cpus(void);
+
 #endif
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 22/41] common: Move mii_init() function out of common.h

2019-09-30 Thread Simon Glass
This function belongs in mii.h so move it over.

Signed-off-by: Simon Glass 
---

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 1 +
 drivers/net/fsl_mcdmafec.c  | 1 +
 drivers/net/ldpaa_eth/ls1088a.c | 1 +
 drivers/net/ldpaa_eth/lx2160a.c | 1 +
 drivers/net/mcffec.c| 1 +
 drivers/net/mcfmii.c| 1 +
 drivers/net/mpc8xx_fec.c| 1 +
 drivers/net/pic32_eth.c | 1 +
 include/common.h| 3 ---
 include/linux/mii.h | 2 ++
 10 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c 
b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index fbbabc23a77..705b66cd2a3 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -39,6 +39,7 @@
 #include 
 #endif
 #endif
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/drivers/net/fsl_mcdmafec.c b/drivers/net/fsl_mcdmafec.c
index e66fb16de87..b2936b78d7b 100644
--- a/drivers/net/fsl_mcdmafec.c
+++ b/drivers/net/fsl_mcdmafec.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #undef ET_DEBUG
 #undef MII_DEBUG
diff --git a/drivers/net/ldpaa_eth/ls1088a.c b/drivers/net/ldpaa_eth/ls1088a.c
index c3260d318cc..54cb16e51b1 100644
--- a/drivers/net/ldpaa_eth/ls1088a.c
+++ b/drivers/net/ldpaa_eth/ls1088a.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 
 u32 dpmac_to_devdisr[] = {
[WRIOP1_DPMAC1] = FSL_CHASSIS3_DEVDISR2_DPMAC1,
diff --git a/drivers/net/ldpaa_eth/lx2160a.c b/drivers/net/ldpaa_eth/lx2160a.c
index 1fbeb0d14b6..9432b6eb85c 100644
--- a/drivers/net/ldpaa_eth/lx2160a.c
+++ b/drivers/net/ldpaa_eth/lx2160a.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 
 u32 dpmac_to_devdisr[] = {
[WRIOP1_DPMAC1] = FSL_CHASSIS3_DEVDISR2_DPMAC1,
diff --git a/drivers/net/mcffec.c b/drivers/net/mcffec.c
index fb930412569..9a3a8455a11 100644
--- a/drivers/net/mcffec.c
+++ b/drivers/net/mcffec.c
@@ -18,6 +18,7 @@
 
 #include 
 #include 
+#include 
 
 #undef ET_DEBUG
 #undef MII_DEBUG
diff --git a/drivers/net/mcfmii.c b/drivers/net/mcfmii.c
index 961618b4109..b8af2cc44be 100644
--- a/drivers/net/mcfmii.c
+++ b/drivers/net/mcfmii.c
@@ -15,6 +15,7 @@
 #include 
 #endif
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/drivers/net/mpc8xx_fec.c b/drivers/net/mpc8xx_fec.c
index f45f1e46773..0a809851922 100644
--- a/drivers/net/mpc8xx_fec.c
+++ b/drivers/net/mpc8xx_fec.c
@@ -13,6 +13,7 @@
 #include 
 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/drivers/net/pic32_eth.c b/drivers/net/pic32_eth.c
index b0f76771545..39c4b10ab83 100644
--- a/drivers/net/pic32_eth.c
+++ b/drivers/net/pic32_eth.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "pic32_eth.h"
 
diff --git a/include/common.h b/include/common.h
index cc5f13ec7e7..992675100d5 100644
--- a/include/common.h
+++ b/include/common.h
@@ -254,9 +254,6 @@ voidreset_timer(void);
 void   enable_interrupts  (void);
 intdisable_interrupts (void);
 
-/* $(CPU)/.../ */
-void mii_init (void);
-
 /* arch/$(ARCH)/lib/cache.c */
 void   enable_caches(void);
 void   flush_cache   (unsigned long, unsigned long);
diff --git a/include/linux/mii.h b/include/linux/mii.h
index 21db032340e..49e29ac314a 100644
--- a/include/linux/mii.h
+++ b/include/linux/mii.h
@@ -225,4 +225,6 @@ static inline u8 mii_resolve_flowctrl_fdx(u16 lcladv, u16 
rmtadv)
return cap;
 }
 
+void mii_init(void);
+
 #endif /* __LINUX_MII_H__ */
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 39/41] common: Move trap_init() out of common.h

2019-09-30 Thread Simon Glass
Move this function into the irq_legacy.h header file.

Signed-off-by: Simon Glass 
---

 arch/m68k/lib/traps.c | 1 +
 arch/mips/lib/traps.c | 1 +
 include/common.h  | 1 -
 include/irq_legacy.h  | 2 ++
 4 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/m68k/lib/traps.c b/arch/m68k/lib/traps.c
index 5d802077453..b2e7e9fe407 100644
--- a/arch/m68k/lib/traps.c
+++ b/arch/m68k/lib/traps.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/mips/lib/traps.c b/arch/mips/lib/traps.c
index ff02d437a87..d173a1b0134 100644
--- a/arch/mips/lib/traps.c
+++ b/arch/mips/lib/traps.c
@@ -12,6 +12,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/include/common.h b/include/common.h
index a292d919390..e946e4d9b7f 100644
--- a/include/common.h
+++ b/include/common.h
@@ -145,7 +145,6 @@ voidrelocate_code(ulong);
 void   relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn));
 #endif
 ulong  get_endaddr   (void);
-void   trap_init (ulong);
 
 void s_init(void);
 
diff --git a/include/irq_legacy.h b/include/irq_legacy.h
index 91b523d043a..a029c54b702 100644
--- a/include/irq_legacy.h
+++ b/include/irq_legacy.h
@@ -21,4 +21,6 @@ void reset_timer(void);
 void enable_interrupts(void);
 int disable_interrupts(void);
 
+void trap_init(unsigned long reloc_addr);
+
 #endif
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 21/41] common: Move get_ticks() function out of common.h

2019-09-30 Thread Simon Glass
This function belongs in time.h so move it over and add a comment.

Signed-off-by: Simon Glass 
---

 arch/arm/cpu/arm920t/ep93xx/timer.c|  1 +
 arch/arm/cpu/arm920t/imx/timer.c   |  1 +
 arch/arm/cpu/arm926ejs/armada100/timer.c   |  1 +
 arch/arm/cpu/arm926ejs/lpc32xx/timer.c |  1 +
 arch/arm/cpu/arm926ejs/mx27/timer.c|  1 +
 arch/arm/cpu/arm926ejs/mxs/timer.c |  1 +
 arch/arm/cpu/arm926ejs/spear/timer.c   |  1 +
 arch/arm/cpu/armv7/arch_timer.c|  1 +
 arch/arm/cpu/armv7/iproc-common/timer.c|  1 +
 arch/arm/cpu/armv7/s5p-common/timer.c  |  1 +
 arch/arm/cpu/armv7/stv0991/timer.c |  1 +
 arch/arm/cpu/armv7/sunxi/timer.c   |  1 +
 arch/arm/cpu/armv7/vf610/timer.c   |  1 +
 arch/arm/cpu/armv7m/systick-timer.c|  1 +
 arch/arm/cpu/sa1100/timer.c|  1 +
 arch/arm/mach-at91/arm920t/timer.c |  1 +
 arch/arm/mach-davinci/timer.c  |  1 +
 arch/arm/mach-omap2/timer.c|  1 +
 arch/arm/mach-orion5x/timer.c  |  1 +
 arch/arm/mach-rmobile/timer.c  |  1 +
 arch/arm/mach-socfpga/clock_manager_gen5.c |  1 +
 arch/arm/mach-sunxi/dram_helpers.c |  1 +
 arch/arm/mach-sunxi/p2wi.c |  1 +
 arch/arm/mach-sunxi/rsb.c  |  1 +
 arch/arm/mach-tegra/clock.c|  1 +
 arch/microblaze/cpu/timer.c|  1 +
 arch/mips/mach-jz47xx/jz4780/timer.c   |  1 +
 arch/nds32/cpu/n1213/ag101/timer.c |  1 +
 arch/sh/lib/time_sh2.c |  1 +
 arch/xtensa/lib/time.c |  1 +
 board/armltd/integrator/timer.c|  1 +
 board/broadcom/bcmstb/bcmstb.c |  1 +
 board/xilinx/versal/board.c|  1 +
 common/autoboot.c  |  1 +
 common/bootretry.c |  1 +
 common/cli_readline.c  |  1 +
 common/iotrace.c   |  1 +
 drivers/clk/clk_stm32mp1.c |  1 +
 drivers/mailbox/mailbox-uclass.c   |  1 +
 drivers/misc/tegra186_bpmp.c   |  1 +
 drivers/mmc/bcm2835_sdhci.c|  1 +
 drivers/mmc/mxcmmc.c   |  1 +
 drivers/net/pic32_eth.c|  1 +
 drivers/nvme/nvme.c|  1 +
 drivers/power/pmic/stpmic1.c   |  1 +
 drivers/sound/broadwell_i2s.c  |  1 +
 drivers/spi/ath79_spi.c|  1 +
 drivers/spi/exynos_spi.c   |  1 +
 drivers/spi/rk_spi.c   |  1 +
 drivers/spi/tegra114_spi.c |  1 +
 drivers/spi/tegra20_sflash.c   |  1 +
 drivers/spi/tegra20_slink.c|  1 +
 drivers/spi/tegra210_qspi.c|  1 +
 drivers/spi/uniphier_spi.c |  1 +
 drivers/spi/zynq_spi.c |  1 +
 drivers/timer/tsc_timer.c  |  1 +
 drivers/video/sunxi/sunxi_display.c|  1 +
 drivers/video/sunxi/sunxi_dw_hdmi.c|  1 +
 include/common.h   |  7 ++-
 include/time.h | 10 ++
 lib/efi_loader/efi_boottime.c  |  1 +
 lib/efi_loader/efi_console.c   |  1 +
 lib/time.c |  1 +
 lib/trace.c|  1 +
 lib/uuid.c |  1 +
 net/nfs.c  |  1 +
 post/post.c|  1 +
 test/time_ut.c |  1 +
 68 files changed, 78 insertions(+), 5 deletions(-)

diff --git a/arch/arm/cpu/arm920t/ep93xx/timer.c 
b/arch/arm/cpu/arm920t/ep93xx/timer.c
index 49bf49bbd36..4829c996be8 100644
--- a/arch/arm/cpu/arm920t/ep93xx/timer.c
+++ b/arch/arm/cpu/arm920t/ep93xx/timer.c
@@ -12,6 +12,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/cpu/arm920t/imx/timer.c b/arch/arm/cpu/arm920t/imx/timer.c
index 96fff3f683f..17081ddb6d8 100644
--- a/arch/arm/cpu/arm920t/imx/timer.c
+++ b/arch/arm/cpu/arm920t/imx/timer.c
@@ -13,6 +13,7 @@
  */
 
 #include 
+#include 
 #if defined (CONFIG_IMX)
 
 #include 
diff --git a/arch/arm/cpu/arm926ejs/armada100/timer.c 
b/arch/arm/cpu/arm926ejs/armada100/timer.c
index d2ecbd07e2f..6c6948a8ef4 100644
--- a/arch/arm/cpu/arm926ejs/armada100/timer.c
+++ b/arch/arm/cpu/arm926ejs/armada100/timer.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/arch/arm/cpu/arm926ejs/lpc32xx/timer.c 
b/arch/arm/cpu/arm926ejs/lpc32xx/timer.c
index b3ca6860409..3a896d10ca5 100644
--- a/arch/arm/cpu/arm926ejs/lpc32xx/timer.c
+++ b/arch/arm/cpu/arm926ejs/lpc32xx/timer.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/cpu/arm926ejs/mx27/timer.c 
b/arch/arm/cpu/arm926ejs/mx27/timer.c
index 94b5d454e92..f51f0df8ec7 100644
--- a/arch/arm/cpu/arm926ejs/mx27/timer.c
+++ 

[U-Boot] [PATCH 38/41] common: Move pci_init_board() out of common.h

2019-09-30 Thread Simon Glass
This function can be dropped when all boards use driver model for PCI. For
now, move it into init.h with a comment.

Signed-off-by: Simon Glass 
---

 board/armltd/integrator/pci.c   | 1 +
 board/cavium/thunderx/thunderx.c| 1 +
 board/esd/vme8349/pci.c | 1 +
 board/freescale/b4860qds/pci.c  | 1 +
 board/freescale/common/p_corenet/pci.c  | 1 +
 board/freescale/m54455evb/m54455evb.c   | 1 +
 board/freescale/m547xevb/m547xevb.c | 1 +
 board/freescale/m548xevb/m548xevb.c | 1 +
 board/freescale/mpc8308rdb/mpc8308rdb.c | 1 +
 board/freescale/mpc8315erdb/mpc8315erdb.c   | 1 +
 board/freescale/mpc8323erdb/mpc8323erdb.c   | 1 +
 board/freescale/mpc832xemds/pci.c   | 1 +
 board/freescale/mpc8349emds/pci.c   | 1 +
 board/freescale/mpc8349itx/pci.c| 1 +
 board/freescale/mpc837xemds/pci.c   | 1 +
 board/freescale/mpc837xerdb/pci.c   | 1 +
 board/freescale/mpc8541cds/mpc8541cds.c | 1 +
 board/freescale/mpc8544ds/mpc8544ds.c   | 1 +
 board/freescale/mpc8548cds/mpc8548cds.c | 1 +
 board/freescale/mpc8555cds/mpc8555cds.c | 1 +
 board/freescale/mpc8568mds/mpc8568mds.c | 1 +
 board/freescale/mpc8610hpcd/mpc8610hpcd.c   | 1 +
 board/freescale/mpc8641hpcn/mpc8641hpcn.c   | 1 +
 board/freescale/qemu-ppce500/qemu-ppce500.c | 1 +
 board/freescale/t102xqds/pci.c  | 1 +
 board/freescale/t102xrdb/pci.c  | 1 +
 board/freescale/t1040qds/pci.c  | 1 +
 board/freescale/t104xrdb/pci.c  | 1 +
 board/freescale/t208xqds/pci.c  | 1 +
 board/freescale/t208xrdb/pci.c  | 1 +
 board/freescale/t4qds/pci.c | 1 +
 board/freescale/t4rdb/pci.c | 1 +
 board/gdsys/mpc8308/hrcon.c | 1 +
 board/gdsys/mpc8308/strider.c   | 1 +
 board/imgtec/malta/malta.c  | 1 +
 board/keymile/kmp204x/pci.c | 1 +
 board/mpc8308_p1m/mpc8308_p1m.c | 1 +
 board/renesas/r7780mp/r7780mp.c | 1 +
 board/sbc8349/pci.c | 1 +
 board/sbc8548/sbc8548.c | 1 +
 board/sbc8641d/sbc8641d.c   | 1 +
 board/tqc/tqm834x/pci.c | 1 +
 board/varisys/cyrus/pci.c   | 1 +
 board/ve8313/ve8313.c   | 1 +
 board/xes/common/fsl_8xxx_pci.c | 1 +
 drivers/pci/pci.c   | 1 +
 drivers/pci/pcie_imx.c  | 1 +
 include/common.h| 2 --
 include/init.h  | 3 +++
 49 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/board/armltd/integrator/pci.c b/board/armltd/integrator/pci.c
index 5e57f7f4c96..c189d23eecd 100644
--- a/board/armltd/integrator/pci.c
+++ b/board/armltd/integrator/pci.c
@@ -20,6 +20,7 @@
  * Linus Walleij 
  */
 #include 
+#include 
 #include 
 #include 
 #include "integrator-sc.h"
diff --git a/board/cavium/thunderx/thunderx.c b/board/cavium/thunderx/thunderx.c
index cf55b633c3e..940455de5b2 100644
--- a/board/cavium/thunderx/thunderx.c
+++ b/board/cavium/thunderx/thunderx.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/esd/vme8349/pci.c b/board/esd/vme8349/pci.c
index 82347f258c9..349e7b567c4 100644
--- a/board/esd/vme8349/pci.c
+++ b/board/esd/vme8349/pci.c
@@ -10,6 +10,7 @@
  * Based on MPC8349 PCI support but w/o PIB related code.
  */
 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/freescale/b4860qds/pci.c b/board/freescale/b4860qds/pci.c
index 3663b14bc37..45dd461e772 100644
--- a/board/freescale/b4860qds/pci.c
+++ b/board/freescale/b4860qds/pci.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/freescale/common/p_corenet/pci.c 
b/board/freescale/common/p_corenet/pci.c
index a6abe66dc0e..94e4715f1c9 100644
--- a/board/freescale/common/p_corenet/pci.c
+++ b/board/freescale/common/p_corenet/pci.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/freescale/m54455evb/m54455evb.c 
b/board/freescale/m54455evb/m54455evb.c
index 98af3be595b..146cd918c4d 100644
--- a/board/freescale/m54455evb/m54455evb.c
+++ b/board/freescale/m54455evb/m54455evb.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/freescale/m547xevb/m547xevb.c 
b/board/freescale/m547xevb/m547xevb.c
index 9e1aa99bbcf..e8d86113d64 100644
--- a/board/freescale/m547xevb/m547xevb.c
+++ b/board/freescale/m547xevb/m547xevb.c
@@ -9,6 +9,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/freescale/m548xevb/m548xevb.c 
b/board/freescale/m548xevb/m548xevb.c
index b4915184681..40e01c6f24f 100644
--- a/board/freescale/m548xevb/m548xevb.c
+++ b/board/freescale/m548xevb/m548xevb.c
@@ -9,6 +9,7 @@
 
 #include 
 #include 

[U-Boot] [PATCH 15/41] common: Move serial_printf() to the serial header

2019-09-30 Thread Simon Glass
Move this function header to serial.h since this function is clearly
related to serial. The function itself stays in console.c since we don't
have a single serial file. DM and non-DM each has a separate file so we
would have to either create a new common serial file, or repeat the
function in both serial.c and serial-uclass.c, neither of which seem
worthwhile.

Signed-off-by: Simon Glass 
---

 drivers/usb/gadget/core.c   |  1 +
 drivers/usb/gadget/designware_udc.c |  1 +
 drivers/usb/gadget/ep0.c|  3 ++-
 drivers/usb/musb-new/omap2430.c |  1 +
 drivers/usb/musb/musb_udc.c |  1 +
 drivers/usb/musb/omap3.c|  1 +
 include/common.h|  7 ---
 include/serial.h| 11 +++
 8 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/core.c b/drivers/usb/gadget/core.c
index ffaf161fb7e..7e1e51db967 100644
--- a/drivers/usb/gadget/core.c
+++ b/drivers/usb/gadget/core.c
@@ -16,6 +16,7 @@
  */
 
 #include 
+#include 
 #include 
 
 #define MAX_INTERFACES 2
diff --git a/drivers/usb/gadget/designware_udc.c 
b/drivers/usb/gadget/designware_udc.c
index 432f312cee4..70c5c678c3b 100644
--- a/drivers/usb/gadget/designware_udc.c
+++ b/drivers/usb/gadget/designware_udc.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 
 #include 
diff --git a/drivers/usb/gadget/ep0.c b/drivers/usb/gadget/ep0.c
index a36d9ec03d8..6fabee24ce9 100644
--- a/drivers/usb/gadget/ep0.c
+++ b/drivers/usb/gadget/ep0.c
@@ -37,6 +37,7 @@
  */
 
 #include 
+#include 
 #include 
 
 #if 0
@@ -581,7 +582,7 @@ int ep0_recv_setup (struct urb *urb)
device->interface = le16_to_cpu (request->wIndex);
device->alternate = le16_to_cpu (request->wValue);
/*dbg_ep0(2, "set interface: %d alternate: %d", 
device->interface, device->alternate); */
-   serial_printf ("DEVICE_SET_INTERFACE.. event?\n");
+   serial_printf("DEVICE_SET_INTERFACE.. event?\n");
return 0;
 
case USB_REQ_GET_STATUS:
diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c
index cca1653f1e2..05059ce3cbd 100644
--- a/drivers/usb/musb-new/omap2430.c
+++ b/drivers/usb/musb-new/omap2430.c
@@ -10,6 +10,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/usb/musb/musb_udc.c b/drivers/usb/musb/musb_udc.c
index 7620114bec4..584564bac2b 100644
--- a/drivers/usb/musb/musb_udc.c
+++ b/drivers/usb/musb/musb_udc.c
@@ -38,6 +38,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include "../gadget/ep0.h"
diff --git a/drivers/usb/musb/omap3.c b/drivers/usb/musb/omap3.c
index b2e4c32baff..080bd78523c 100644
--- a/drivers/usb/musb/omap3.c
+++ b/drivers/usb/musb/omap3.c
@@ -16,6 +16,7 @@
  * 
  */
 
+#include 
 #include 
 #include 
 #include 
diff --git a/include/common.h b/include/common.h
index 4fda40cc1d6..f97a7b6e14d 100644
--- a/include/common.h
+++ b/include/common.h
@@ -310,13 +310,6 @@ int ulz4fn(const void *src, size_t srcn, void *dst, size_t 
*dstn);
 /* lib/vsprintf.c */
 #include 
 
-/*
- * STDIO based functions (can always be used)
- */
-/* serial stuff */
-intserial_printf (const char *fmt, ...)
-   __attribute__ ((format (__printf__, 1, 2)));
-
 /* lib/net_utils.c */
 #include 
 
diff --git a/include/serial.h b/include/serial.h
index 38a1cc99ae2..8d1803c8003 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -324,4 +324,15 @@ void pl01x_serial_initialize(void);
 void pxa_serial_initialize(void);
 void sh_serial_initialize(void);
 
+/**
+ * serial_printf() - Write a formatted string to the serial console
+ *
+ * The total size of the output must be less than CONFIG_SYS_PBSIZE.
+ *
+ * @fmt: Printf format string, followed by format arguments
+ * @return number of characters written
+ */
+int serial_printf(const char *fmt, ...)
+   __attribute__ ((format (__printf__, 1, 2)));
+
 #endif
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 31/41] arm: powerpc: Tidy up code style for interrupt functions

2019-09-30 Thread Simon Glass
Remove the unwanted space before the bracket.

Signed-off-by: Simon Glass 
---

 arch/arm/cpu/arm11/cpu.c  |  2 +-
 arch/arm/cpu/arm920t/cpu.c|  2 +-
 arch/arm/cpu/arm926ejs/cpu.c  |  2 +-
 arch/arm/cpu/arm946es/cpu.c   |  2 +-
 arch/arm/cpu/sa1100/cpu.c |  2 +-
 arch/arm/lib/interrupts.c |  6 +++---
 arch/m68k/lib/interrupts.c|  8 
 arch/nios2/cpu/interrupts.c   | 14 +++---
 arch/powerpc/cpu/mpc83xx/cpu.c|  2 +-
 arch/powerpc/cpu/mpc83xx/interrupts.c |  6 +++---
 arch/powerpc/cpu/mpc86xx/interrupts.c |  2 +-
 arch/powerpc/lib/interrupts.c |  8 
 arch/sh/cpu/sh4/interrupts.c  |  6 +++---
 board/cobra5272/flash.c   |  8 
 14 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/arch/arm/cpu/arm11/cpu.c b/arch/arm/cpu/arm11/cpu.c
index a546ec21de4..280622fe33a 100644
--- a/arch/arm/cpu/arm11/cpu.c
+++ b/arch/arm/cpu/arm11/cpu.c
@@ -30,7 +30,7 @@ int cleanup_before_linux (void)
 * we turn off caches etc ...
 */
 
-   disable_interrupts ();
+   disable_interrupts();
 
/* turn off I/D-cache */
icache_disable();
diff --git a/arch/arm/cpu/arm920t/cpu.c b/arch/arm/cpu/arm920t/cpu.c
index a98c86eaf3f..e632aa52f8c 100644
--- a/arch/arm/cpu/arm920t/cpu.c
+++ b/arch/arm/cpu/arm920t/cpu.c
@@ -28,7 +28,7 @@ int cleanup_before_linux (void)
 * we turn off caches etc ...
 */
 
-   disable_interrupts ();
+   disable_interrupts();
 
/* turn off I/D-cache */
icache_disable();
diff --git a/arch/arm/cpu/arm926ejs/cpu.c b/arch/arm/cpu/arm926ejs/cpu.c
index 6d06fb758ab..f4b27d93be6 100644
--- a/arch/arm/cpu/arm926ejs/cpu.c
+++ b/arch/arm/cpu/arm926ejs/cpu.c
@@ -28,7 +28,7 @@ int cleanup_before_linux (void)
 * we turn off caches etc ...
 */
 
-   disable_interrupts ();
+   disable_interrupts();
 
 
/* turn off I/D-cache */
diff --git a/arch/arm/cpu/arm946es/cpu.c b/arch/arm/cpu/arm946es/cpu.c
index 0a78ffbae1a..19b805096f4 100644
--- a/arch/arm/cpu/arm946es/cpu.c
+++ b/arch/arm/cpu/arm946es/cpu.c
@@ -29,7 +29,7 @@ int cleanup_before_linux (void)
 * we turn off caches etc ...
 */
 
-   disable_interrupts ();
+   disable_interrupts();
 
/* ARM926E-S needs the protection unit enabled for the icache to have
 * been enabled  - left for possible later use
diff --git a/arch/arm/cpu/sa1100/cpu.c b/arch/arm/cpu/sa1100/cpu.c
index 8ef9f294f23..ec408564c1e 100644
--- a/arch/arm/cpu/sa1100/cpu.c
+++ b/arch/arm/cpu/sa1100/cpu.c
@@ -30,7 +30,7 @@ int cleanup_before_linux (void)
 * just disable everything that can disturb booting linux
 */
 
-   disable_interrupts ();
+   disable_interrupts();
 
/* turn off I-cache */
icache_disable();
diff --git a/arch/arm/lib/interrupts.c b/arch/arm/lib/interrupts.c
index ee775ce5d26..e78ca56d253 100644
--- a/arch/arm/lib/interrupts.c
+++ b/arch/arm/lib/interrupts.c
@@ -25,7 +25,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-int interrupt_init (void)
+int interrupt_init(void)
 {
/*
 * setup up stacks if necessary
@@ -35,11 +35,11 @@ int interrupt_init (void)
return 0;
 }
 
-void enable_interrupts (void)
+void enable_interrupts(void)
 {
return;
 }
-int disable_interrupts (void)
+int disable_interrupts(void)
 {
return 0;
 }
diff --git a/arch/m68k/lib/interrupts.c b/arch/m68k/lib/interrupts.c
index 2d1c6136a11..85ae3b4ee07 100644
--- a/arch/m68k/lib/interrupts.c
+++ b/arch/m68k/lib/interrupts.c
@@ -42,7 +42,7 @@ static __inline__ void set_sr (unsigned short sr)
 /*
  * Install and free an interrupt handler
  */
-void irq_install_handler (int vec, interrupt_handler_t * handler, void *arg)
+void irq_install_handler(int vec, interrupt_handler_t * handler, void *arg)
 {
if ((vec < 0) || (vec >= NR_IRQS)) {
printf ("irq_install_handler: wrong interrupt vector %d\n",
@@ -54,7 +54,7 @@ void irq_install_handler (int vec, interrupt_handler_t * 
handler, void *arg)
irq_vecs[vec].arg = arg;
 }
 
-void irq_free_handler (int vec)
+void irq_free_handler(int vec)
 {
if ((vec < 0) || (vec >= NR_IRQS)) {
return;
@@ -64,7 +64,7 @@ void irq_free_handler (int vec)
irq_vecs[vec].arg = NULL;
 }
 
-void enable_interrupts (void)
+void enable_interrupts(void)
 {
unsigned short sr;
 
@@ -72,7 +72,7 @@ void enable_interrupts (void)
set_sr (sr & ~0x0700);
 }
 
-int disable_interrupts (void)
+int disable_interrupts(void)
 {
unsigned short sr;
 
diff --git a/arch/nios2/cpu/interrupts.c b/arch/nios2/cpu/interrupts.c
index 6b5d0724e34..96c30209353 100644
--- a/arch/nios2/cpu/interrupts.c
+++ b/arch/nios2/cpu/interrupts.c
@@ -23,7 +23,7 @@ structirq_action {
 
 static struct irq_action vecs[32];
 
-int disable_interrupts (void)
+int disable_interrupts(void)
 {
int val 

[U-Boot] [PATCH 10/41] common: Move bootcount functions to their header file

2019-09-30 Thread Simon Glass
These don't need to be in common.h so move them out.

Signed-off-by: Simon Glass 
---

 board/BuR/brppt1/board.c |  1 +
 include/bootcount.h  | 10 ++
 include/common.h |  4 
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/board/BuR/brppt1/board.c b/board/BuR/brppt1/board.c
index ef4f5c95014..e0d1707ac13 100644
--- a/board/BuR/brppt1/board.c
+++ b/board/BuR/brppt1/board.c
@@ -10,6 +10,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/include/bootcount.h b/include/bootcount.h
index a26a3852338..cd304039849 100644
--- a/include/bootcount.h
+++ b/include/bootcount.h
@@ -59,6 +59,16 @@ int dm_bootcount_set(struct udevice *dev, u32 bootcount);
 
 #endif
 
+/** bootcount_store() - store the current bootcount */
+void bootcount_store(ulong);
+
+/**
+ * bootcount_load() - load the current bootcount
+ *
+ * @return bootcount, read from the appropriate location
+ */
+ulong bootcount_load(void);
+
 #if defined(CONFIG_SPL_BOOTCOUNT_LIMIT) || defined(CONFIG_BOOTCOUNT_LIMIT)
 
 #if !defined(CONFIG_SYS_BOOTCOUNT_LE) && !defined(CONFIG_SYS_BOOTCOUNT_BE)
diff --git a/include/common.h b/include/common.h
index 9c454fb1c83..97b661181b0 100644
--- a/include/common.h
+++ b/include/common.h
@@ -266,10 +266,6 @@ unsigned long timer_get_us(void);
 void   enable_interrupts  (void);
 intdisable_interrupts (void);
 
-/* $(CPU)/.../commproc.c */
-void   bootcount_store (ulong);
-ulong  bootcount_load (void);
-
 /* $(CPU)/.../ */
 void mii_init (void);
 
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 07/41] crc: Fix code style with crc functions

2019-09-30 Thread Simon Glass
Some of these have a space before the bracket. Drop it to fix the style.
Add some missing function comments while here.

Note that u32 and u8 cannot be used here since crc.h is included on the
host side.

Signed-off-by: Simon Glass 
---

 cmd/i2c.c|  2 +-
 include/u-boot/crc.h | 75 +++-
 lib/crc32.c  |  4 +--
 tools/envcrc.c   |  4 +--
 4 files changed, 73 insertions(+), 12 deletions(-)

diff --git a/cmd/i2c.c b/cmd/i2c.c
index e0f8ece597c..038f97c261b 100644
--- a/cmd/i2c.c
+++ b/cmd/i2c.c
@@ -768,7 +768,7 @@ static int do_i2c_crc (cmd_tbl_t *cmdtp, int flag, int 
argc, char * const argv[]
 #endif
if (ret)
err++;
-   crc = crc32 (crc, , 1);
+   crc = crc32(crc, , 1);
addr++;
}
if (err > 0)
diff --git a/include/u-boot/crc.h b/include/u-boot/crc.h
index b42bcda2b31..1086d2168ce 100644
--- a/include/u-boot/crc.h
+++ b/include/u-boot/crc.h
@@ -38,9 +38,47 @@ void crc16_ccitt_wd_buf(const uint8_t *in, uint len,
uint8_t *out, uint chunk_sz);
 
 /* lib/crc32.c */
-uint32_t crc32 (uint32_t, const unsigned char *, uint);
-uint32_t crc32_wd (uint32_t, const unsigned char *, uint, uint);
-uint32_t crc32_no_comp (uint32_t, const unsigned char *, uint);
+
+/**
+ * crc32 - Calculate the CRC32 for a block of data
+ *
+ * @crc: Input crc to chain from a previous calculution (use 0 to start a new
+ * calculation)
+ * @buf: Bytes to checksum
+ * @len: Number of bytes to checksum
+ * @return checksum value
+ */
+uint32_t crc32(uint32_t crc, const unsigned char *buf, uint len);
+
+/**
+ * crc32_wd - Calculate the CRC32 for a block of data (watchdog version)
+ *
+ * This checksums the data @chunk_sz bytes at a time, calling WATCHDOG_RESET()
+ * after each chunk, to prevent the watchdog from firing.
+ *
+ * @crc: Input crc to chain from a previous calculution (use 0 to start a new
+ * calculation)
+ * @buf: Bytes to checksum
+ * @len: Number of bytes to checksum
+ * @chunk_sz: Chunk size to use between watchdog resets
+ * @return checksum
+ */
+uint32_t crc32_wd(uint32_t crc, const unsigned char *buf, uint len,
+ uint chunk_sz);
+
+/**
+ * crc32_no_comp - Calculate the CRC32 for a block of data (no one's 
compliment)
+ *
+ * This version uses a different algorithm which doesn't use one's compliment.
+ * JFFS2 (and other things?) use this.
+ *
+ * @crc: Input crc to chain from a previous calculution (use 0 to start a new
+ * calculation)
+ * @buf: Bytes to checksum
+ * @len: Number of bytes to checksum
+ * @return checksum value
+ */
+uint32_t crc32_no_comp(uint32_t crc, const unsigned char *buf, uint len);
 
 /**
  * crc32_wd_buf - Perform CRC32 on a buffer and return result in buffer
@@ -50,11 +88,34 @@ uint32_t crc32_no_comp (uint32_t, const unsigned char *, 
uint);
  * @output:Place to put checksum result (4 bytes)
  * @chunk_sz:  Trigger watchdog after processing this many bytes
  */
-void crc32_wd_buf(const unsigned char *input, uint ilen,
-   unsigned char *output, uint chunk_sz);
+void crc32_wd_buf(const uint8_t *input, uint ilen, uint8_t *output,
+ uint chunk_sz);
 
 /* lib/crc32c.c */
-void crc32c_init(uint32_t *, uint32_t);
-uint32_t crc32c_cal(uint32_t, const char *, int, uint32_t *);
+
+/**
+ * crc32c_init() - Set up a the CRC32 table
+ *
+ * This sets up 256-item table to aid in CRC32 calculation
+ *
+ * @crc32c_table: Place to put table
+ * @pol: polynomial to use
+ */
+void crc32c_init(uint32_t *crc32c_table, uint32_t pol);
+
+/**
+ * crc32c_cal() - Perform CRC32 on a buffer given a table
+ *
+ * This algorithm uses the table (set up by crc32c_init() to speed up
+ * processing.
+ *
+ * @crc: Previous crc (use 0 at start)
+ * @data: Data bytes to checksum
+ * @length: Number of bytes to process
+ * @crc32c_table:: CRC table
+ * @return checksum value
+ */
+uint32_t crc32c_cal(uint32_t crc, const char *data, int length,
+   uint32_t *crc32c_table);
 
 #endif /* _UBOOT_CRC_H */
diff --git a/lib/crc32.c b/lib/crc32.c
index eee21f8d739..dc7e183f181 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -244,12 +244,12 @@ uint32_t crc32_wd(uint32_t crc, const unsigned char *buf, 
uInt len,
chunk = end - curr;
if (chunk > chunk_sz)
chunk = chunk_sz;
-   crc = crc32 (crc, curr, chunk);
+   crc = crc32(crc, curr, chunk);
curr += chunk;
WATCHDOG_RESET ();
}
 #else
-   crc = crc32 (crc, buf, len);
+   crc = crc32(crc, buf, len);
 #endif
 
return crc;
diff --git a/tools/envcrc.c b/tools/envcrc.c
index 672ef4d675e..09b49b49f9d 100644
--- a/tools/envcrc.c
+++ b/tools/envcrc.c
@@ -64,7 +64,7 @@ extern unsigned int env_size;
 extern env_t embedded_environment;
 #endif /* CONFIG_BUILD_ENVCRC */
 
-extern uint32_t crc32 (uint32_t, const unsigned 

[U-Boot] [PATCH 23/41] common: Move some CPU functions out of common.h

2019-09-30 Thread Simon Glass
These functions belong in cpu_legacy.h since they do not use driver model.
Move them over. Don't bother adding comments since these functions should
be deleted.

Signed-off-by: Simon Glass 
---

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c   |  1 +
 .../armv8/fsl-layerscape/fsl_lsch2_speed.c|  1 +
 .../armv8/fsl-layerscape/fsl_lsch3_speed.c|  1 +
 arch/arm/cpu/armv8/s32v234/cpu.c  |  1 +
 arch/powerpc/cpu/mpc85xx/speed.c  |  1 +
 arch/powerpc/cpu/mpc86xx/cpu.c|  1 +
 arch/powerpc/cpu/mpc8xxx/cpu.c|  1 +
 arch/powerpc/cpu/mpc8xxx/fdt.c|  1 +
 board/freescale/qemu-ppce500/qemu-ppce500.c   |  1 +
 include/common.h  | 20 ---
 include/cpu_legacy.h  | 19 ++
 11 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c 
b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index 705b66cd2a3..b52f3694e05 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch2_speed.c 
b/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch2_speed.c
index df4df9aca79..500c06642bd 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch2_speed.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch2_speed.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch3_speed.c 
b/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch3_speed.c
index b3e67321b48..d14b3087181 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch3_speed.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch3_speed.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/cpu/armv8/s32v234/cpu.c b/arch/arm/cpu/armv8/s32v234/cpu.c
index b4cb67a66a3..bc4b8bf86f1 100644
--- a/arch/arm/cpu/armv8/s32v234/cpu.c
+++ b/arch/arm/cpu/armv8/s32v234/cpu.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/powerpc/cpu/mpc85xx/speed.c b/arch/powerpc/cpu/mpc85xx/speed.c
index acc2f2bb818..c6026f33811 100644
--- a/arch/powerpc/cpu/mpc85xx/speed.c
+++ b/arch/powerpc/cpu/mpc85xx/speed.c
@@ -10,6 +10,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/powerpc/cpu/mpc86xx/cpu.c b/arch/powerpc/cpu/mpc86xx/cpu.c
index 1c3c78217cb..5ee3a56b47b 100644
--- a/arch/powerpc/cpu/mpc86xx/cpu.c
+++ b/arch/powerpc/cpu/mpc86xx/cpu.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/powerpc/cpu/mpc8xxx/cpu.c b/arch/powerpc/cpu/mpc8xxx/cpu.c
index 467eac4a2e2..333dfa30904 100644
--- a/arch/powerpc/cpu/mpc8xxx/cpu.c
+++ b/arch/powerpc/cpu/mpc8xxx/cpu.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/powerpc/cpu/mpc8xxx/fdt.c b/arch/powerpc/cpu/mpc8xxx/fdt.c
index 0d877c43be8..40ee46c24a0 100644
--- a/arch/powerpc/cpu/mpc8xxx/fdt.c
+++ b/arch/powerpc/cpu/mpc8xxx/fdt.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/freescale/qemu-ppce500/qemu-ppce500.c 
b/board/freescale/qemu-ppce500/qemu-ppce500.c
index fb36d8366c9..6814bed27c7 100644
--- a/board/freescale/qemu-ppce500/qemu-ppce500.c
+++ b/board/freescale/qemu-ppce500/qemu-ppce500.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/include/common.h b/include/common.h
index 992675100d5..4de05032b2b 100644
--- a/include/common.h
+++ b/include/common.h
@@ -203,26 +203,6 @@ void   relocate_code(ulong, gd_t *, ulong) 
__attribute__ ((noreturn));
 ulong  get_endaddr   (void);
 void   trap_init (ulong);
 
-/* $(CPU)/cpu.c */
-static inline int cpumask_next(int cpu, unsigned int mask)
-{
-   for (cpu++; !((1 << cpu) & mask); cpu++)
-   ;
-
-   return cpu;
-}
-
-#define for_each_cpu(iter, cpu, num_cpus, mask) \
-   for (iter = 0, cpu = cpumask_next(-1, mask); \
-   iter < num_cpus; \
-   iter++, cpu = cpumask_next(cpu, mask)) \
-
-intcpu_numcores  (void);
-intcpu_num_dspcores(void);
-u32cpu_mask  (void);
-u32cpu_dsp_mask(void);
-intis_core_valid (unsigned int);
-
 void s_init(void);
 
 intcheckcpu  (void);
diff --git a/include/cpu_legacy.h b/include/cpu_legacy.h
index a99b69b9764..75b93bc11ee 100644
--- a/include/cpu_legacy.h
+++ b/include/cpu_legacy.h
@@ -20,4 +20,23 @@ int cpu_reset(u32 nr);
 int cpu_disable(u32 nr);
 int cpu_release(u32 nr, int argc, char * const argv[]);
 
+static inline int cpumask_next(int cpu, unsigned int mask)
+{
+   for (cpu++; !((1 << cpu) & mask); cpu++)
+   ;
+
+   return cpu;
+}
+
+#define for_each_cpu(iter, cpu, num_cpus, mask) \
+   for (iter = 0, cpu = cpumask_next(-1, 

[U-Boot] [PATCH 28/41] common: Move some cache and MMU functions out of common.h

2019-09-30 Thread Simon Glass
These functions belong in cpu_legacy.h. Another option would be cache.h
but that code uses driver model and we have not moved these cache
functions to use driver model. Since they are CPU-related it seems
reasonable to put them here.

Move them over.

Signed-off-by: Simon Glass 
---

 arch/arc/lib/cache.c|  1 +
 arch/arm/cpu/arm11/cpu.c|  1 +
 arch/arm/cpu/arm920t/cpu.c  |  1 +
 arch/arm/cpu/arm926ejs/armada100/cpu.c  |  1 +
 arch/arm/cpu/arm926ejs/cache.c  |  1 +
 arch/arm/cpu/arm926ejs/cpu.c|  1 +
 arch/arm/cpu/arm926ejs/spear/spr_misc.c |  1 +
 arch/arm/cpu/arm946es/cpu.c |  1 +
 arch/arm/cpu/armv7/cpu.c|  1 +
 arch/arm/cpu/armv7/exception_level.c|  1 +
 arch/arm/cpu/armv7/iproc-common/hwinit-common.c |  1 +
 arch/arm/cpu/armv7/kona-common/hwinit-common.c  |  1 +
 arch/arm/cpu/armv7/mpu_v7r.c|  1 +
 arch/arm/cpu/armv7/vf610/generic.c  |  1 +
 arch/arm/cpu/armv7m/cache.c |  1 +
 arch/arm/cpu/armv7m/cpu.c   |  1 +
 arch/arm/cpu/armv8/cache_v8.c   |  1 +
 arch/arm/cpu/armv8/cpu.c|  1 +
 arch/arm/cpu/armv8/exception_level.c|  1 +
 arch/arm/cpu/armv8/fsl-layerscape/spl.c |  1 +
 arch/arm/cpu/pxa/pxa2xx.c   |  1 +
 arch/arm/cpu/sa1100/cpu.c   |  1 +
 arch/arm/lib/cache-cp15.c   |  1 +
 arch/arm/mach-at91/armv7/cpu.c  |  1 +
 arch/arm/mach-bcm283x/init.c|  1 +
 arch/arm/mach-exynos/soc.c  |  1 +
 arch/arm/mach-imx/cache.c   |  1 +
 arch/arm/mach-imx/imx8/cpu.c|  1 +
 arch/arm/mach-imx/mx5/soc.c |  1 +
 arch/arm/mach-keystone/init.c   |  1 +
 arch/arm/mach-mediatek/cpu.c|  1 +
 arch/arm/mach-mvebu/armada8k/cpu.c  |  1 +
 arch/arm/mach-mvebu/cpu.c   |  1 +
 arch/arm/mach-omap2/omap-cache.c|  1 +
 arch/arm/mach-orion5x/cpu.c |  1 +
 arch/arm/mach-rmobile/cpu_info.c|  1 +
 arch/arm/mach-rmobile/memmap-gen3.c |  1 +
 arch/arm/mach-rockchip/board.c  |  1 +
 arch/arm/mach-s5pc1xx/cache.c   |  1 +
 arch/arm/mach-socfpga/misc.c|  1 +
 arch/arm/mach-socfpga/spl_a10.c |  1 +
 arch/arm/mach-stm32mp/cpu.c |  1 +
 arch/arm/mach-sunxi/board.c |  1 +
 arch/arm/mach-tegra/board.c |  1 +
 arch/arm/mach-uniphier/arm32/cache-uniphier.c   |  1 +
 arch/arm/mach-zynq/cpu.c|  1 +
 arch/m68k/cpu/mcf5227x/cpu_init.c   |  1 +
 arch/m68k/cpu/mcf523x/cpu_init.c|  1 +
 arch/m68k/cpu/mcf52x2/cpu_init.c|  1 +
 arch/m68k/cpu/mcf530x/cpu_init.c|  1 +
 arch/m68k/cpu/mcf532x/cpu_init.c|  1 +
 arch/m68k/cpu/mcf5445x/cpu_init.c   |  1 +
 arch/m68k/cpu/mcf547x_8x/cpu_init.c |  1 +
 arch/m68k/lib/cache.c   |  1 +
 arch/microblaze/cpu/cache.c |  1 +
 arch/mips/lib/cache.c   |  1 +
 arch/nds32/cpu/n1213/ae3xx/cpu.c|  1 +
 arch/nds32/cpu/n1213/ag101/cpu.c|  1 +
 arch/nds32/lib/cache.c  |  1 +
 arch/nios2/lib/cache.c  |  1 +
 arch/powerpc/cpu/mpc83xx/spd_sdram.c|  1 +
 arch/powerpc/cpu/mpc8xx/cache.c |  1 +
 arch/riscv/cpu/ax25/cache.c |  1 +
 arch/riscv/cpu/ax25/cpu.c   |  1 +
 arch/riscv/lib/cache.c  |  1 +
 arch/sh/cpu/sh4/cache.c |  1 +
 arch/x86/cpu/cpu.c  |  1 +
 arch/x86/cpu/i386/cpu.c |  1 +
 arch/x86/cpu/mtrr.c |  1 +
 arch/x86/cpu/x86_64/cpu.c   |  1 +
 arch/x86/lib/spl.c  |  1 +
 arch/xtensa/lib/cache.c |  1 +
 board/armltd/integrator/integrator.c|  1 +
 board/cirrus/edb93xx/edb93xx.c  |  1 +
 board/cobra5272/flash.c |  1 +
 board/h2200/h2200.c |  1 +
 board/highbank/highbank.c   |  1 +
 board/st/stih410-b2260/board.c  |  1 +
 board/synopsys/hsdk/hsdk.c  |  1 +
 board/syteco/zmx25/zmx25.c  |  1 +
 board/toradex/colibri_pxa270/colibri_pxa270.c   |  1 +
 board/xilinx/zynqmp/cmds.c  |  1 +
 cmd/cache.c |  1 +
 cmd/ti/ddr3.c   |  1 +
 

[U-Boot] [PATCH 32/41] common: Move interrupt functions into a new header

2019-09-30 Thread Simon Glass
These functions do not use driver model but are fairly widely used in
U-Boot. Move them to a new irq_legacy.h header file.

Signed-off-by: Simon Glass 
---

 arch/arc/lib/interrupts.c |  1 +
 arch/arm/lib/interrupts.c |  1 +
 arch/arm/lib/interrupts_64.c  |  1 +
 arch/arm/lib/interrupts_m.c   |  1 +
 arch/m68k/cpu/mcf5227x/interrupts.c   |  1 +
 arch/m68k/cpu/mcf523x/interrupts.c|  1 +
 arch/m68k/cpu/mcf52x2/interrupts.c|  1 +
 arch/m68k/cpu/mcf530x/interrupts.c|  1 +
 arch/m68k/cpu/mcf532x/interrupts.c|  1 +
 arch/m68k/cpu/mcf5445x/interrupts.c   |  1 +
 arch/m68k/cpu/mcf547x_8x/interrupts.c |  1 +
 arch/m68k/cpu/mcf547x_8x/slicetimer.c |  1 +
 arch/m68k/lib/interrupts.c|  1 +
 arch/m68k/lib/time.c  |  1 +
 arch/microblaze/cpu/interrupts.c  |  1 +
 arch/mips/cpu/interrupts.c|  1 +
 arch/mips/mach-jz47xx/jz4780/timer.c  |  1 +
 arch/nds32/cpu/n1213/ag101/timer.c|  1 +
 arch/nds32/lib/interrupts.c   |  1 +
 arch/nios2/cpu/interrupts.c   |  1 +
 arch/powerpc/cpu/mpc83xx/interrupts.c |  1 +
 arch/powerpc/cpu/mpc85xx/interrupts.c |  1 +
 arch/powerpc/cpu/mpc85xx/traps.c  |  1 +
 arch/powerpc/cpu/mpc86xx/interrupts.c |  1 +
 arch/powerpc/cpu/mpc8xx/interrupts.c  |  1 +
 arch/powerpc/lib/interrupts.c |  1 +
 arch/riscv/lib/interrupts.c   |  1 +
 arch/sandbox/lib/interrupts.c |  1 +
 arch/sh/cpu/sh4/interrupts.c  |  1 +
 arch/x86/cpu/i386/interrupt.c |  1 +
 arch/x86/cpu/x86_64/interrupts.c  |  1 +
 arch/x86/lib/bios.c   |  1 +
 arch/x86/lib/interrupts.c |  1 +
 arch/x86/lib/spl.c|  1 +
 arch/xtensa/cpu/exceptions.c  |  1 +
 common/board_r.c  |  1 +
 common/spl/spl.c  |  1 +
 drivers/mtd/cfi_flash.c   |  1 +
 drivers/timer/mpc83xx_timer.c |  1 +
 include/common.h  |  7 ---
 include/exports.h |  2 ++
 include/irq_legacy.h  | 17 +
 42 files changed, 58 insertions(+), 7 deletions(-)
 create mode 100644 include/irq_legacy.h

diff --git a/arch/arc/lib/interrupts.c b/arch/arc/lib/interrupts.c
index 24ff7512209..4aef49aea3d 100644
--- a/arch/arc/lib/interrupts.c
+++ b/arch/arc/lib/interrupts.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/arch/arm/lib/interrupts.c b/arch/arm/lib/interrupts.c
index e78ca56d253..82802c0004c 100644
--- a/arch/arm/lib/interrupts.c
+++ b/arch/arm/lib/interrupts.c
@@ -20,6 +20,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/arch/arm/lib/interrupts_64.c b/arch/arm/lib/interrupts_64.c
index 0bfdb8d93d2..f2694779dc0 100644
--- a/arch/arm/lib/interrupts_64.c
+++ b/arch/arm/lib/interrupts_64.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/arch/arm/lib/interrupts_m.c b/arch/arm/lib/interrupts_m.c
index 95df6cb1eb8..6a4beaf3ece 100644
--- a/arch/arm/lib/interrupts_m.c
+++ b/arch/arm/lib/interrupts_m.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 
 /*
  * Upon exception entry ARMv7-M processors automatically save stack
diff --git a/arch/m68k/cpu/mcf5227x/interrupts.c 
b/arch/m68k/cpu/mcf5227x/interrupts.c
index d38f01950b1..0d0ad5ed022 100644
--- a/arch/m68k/cpu/mcf5227x/interrupts.c
+++ b/arch/m68k/cpu/mcf5227x/interrupts.c
@@ -10,6 +10,7 @@
 
 /* CPU specific interrupt routine */
 #include 
+#include 
 #include 
 #include 
 
diff --git a/arch/m68k/cpu/mcf523x/interrupts.c 
b/arch/m68k/cpu/mcf523x/interrupts.c
index 1d03724f15c..a524801151d 100644
--- a/arch/m68k/cpu/mcf523x/interrupts.c
+++ b/arch/m68k/cpu/mcf523x/interrupts.c
@@ -7,6 +7,7 @@
 
 /* CPU specific interrupt routine */
 #include 
+#include 
 #include 
 #include 
 
diff --git a/arch/m68k/cpu/mcf52x2/interrupts.c 
b/arch/m68k/cpu/mcf52x2/interrupts.c
index f874675b12f..4b20cf5751b 100644
--- a/arch/m68k/cpu/mcf52x2/interrupts.c
+++ b/arch/m68k/cpu/mcf52x2/interrupts.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/m68k/cpu/mcf530x/interrupts.c 
b/arch/m68k/cpu/mcf530x/interrupts.c
index cd85c69f129..9e61de7d952 100644
--- a/arch/m68k/cpu/mcf530x/interrupts.c
+++ b/arch/m68k/cpu/mcf530x/interrupts.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/arch/m68k/cpu/mcf532x/interrupts.c 
b/arch/m68k/cpu/mcf532x/interrupts.c
index 43a903ed72e..83c9c2e1b35 100644
--- a/arch/m68k/cpu/mcf532x/interrupts.c
+++ b/arch/m68k/cpu/mcf532x/interrupts.c
@@ -7,6 +7,7 @@
 
 /* CPU specific interrupt routine */
 #include 
+#include 
 #include 
 #include 
 
diff --git a/arch/m68k/cpu/mcf5445x/interrupts.c 
b/arch/m68k/cpu/mcf5445x/interrupts.c
index d38f01950b1..0d0ad5ed022 100644
--- a/arch/m68k/cpu/mcf5445x/interrupts.c
+++ b/arch/m68k/cpu/mcf5445x/interrupts.c
@@ -10,6 +10,7 @@
 
 /* CPU specific interrupt routine */
 

[U-Boot] [PATCH 30/41] common: Move ARM cache operations out of common.h

2019-09-30 Thread Simon Glass
These functions are CPU-related and do not use driver model. Move them to
cpu_legacy.h

Signed-off-by: Simon Glass 
---

 arch/arm/cpu/arm926ejs/lpc32xx/cpu.c   |  1 +
 arch/arm/cpu/armv7/cache_v7.c  |  1 +
 arch/arm/cpu/armv7/ls102xa/ls102xa_psci.c  |  1 +
 arch/arm/cpu/armv8/sec_firmware.c  |  1 +
 arch/arm/cpu/pxa/cache.c   |  1 +
 arch/arm/lib/cache.c   |  1 +
 arch/arm/mach-bcm283x/mbox.c   |  1 +
 arch/arm/mach-imx/mx7/psci-mx7.c   |  1 +
 arch/arm/mach-omap2/sec-common.c   |  1 +
 arch/arm/mach-tegra/ivc.c  |  1 +
 arch/microblaze/lib/bootm.c|  1 +
 arch/mips/lib/reloc.c  |  1 +
 arch/mips/lib/traps.c  |  1 +
 arch/mips/mach-jz47xx/jz4780/jz4780.c  |  1 +
 arch/mips/mach-mtmips/ddr_calibrate.c  |  1 +
 arch/nds32/cpu/n1213/ae3xx/cpu.c   |  1 +
 arch/nios2/cpu/cpu.c   |  1 +
 arch/nios2/lib/bootm.c |  1 +
 arch/powerpc/lib/bootm.c   |  1 +
 arch/powerpc/lib/cache.c   |  1 +
 arch/riscv/cpu/ax25/cpu.c  |  1 +
 arch/riscv/lib/smp.c   |  1 +
 arch/riscv/lib/spl.c   |  1 +
 arch/sandbox/cpu/cpu.c |  1 +
 arch/x86/cpu/quark/dram.c  |  1 +
 arch/x86/cpu/quark/quark.c |  1 +
 arch/xtensa/lib/bootm.c|  1 +
 board/Arcturus/ucp1020/cmd_arc.c   |  1 +
 board/beckhoff/mx53cx9020/mx53cx9020.c |  1 +
 board/broadcom/bcmstb/bcmstb.c |  1 +
 board/cirrus/edb93xx/edb93xx.c |  1 +
 board/phytec/pfla02/pfla02.c   |  1 +
 board/sandbox/sandbox.c|  1 +
 cmd/disk.c |  1 +
 cmd/load.c |  1 +
 cmd/ximg.c |  1 +
 common/avb_verify.c|  1 +
 common/board_r.c   |  1 +
 common/bootm.c |  1 +
 common/bouncebuf.c |  1 +
 common/image.c |  1 +
 common/lcd.c   |  1 +
 common/spl/spl_opensbi.c   |  1 +
 common/update.c|  1 +
 drivers/ata/ahci.c |  1 +
 drivers/ata/dwc_ahsata.c   |  1 +
 drivers/ata/fsl_ahci.c |  1 +
 drivers/ata/fsl_sata.c |  1 +
 drivers/ata/sata_mv.c  |  1 +
 drivers/ata/sata_sil.c |  1 +
 drivers/bootcount/bootcount.c  |  1 +
 drivers/bootcount/bootcount_ram.c  |  1 +
 drivers/core/device.c  |  1 +
 drivers/crypto/fsl/fsl_blob.c  |  1 +
 drivers/crypto/fsl/fsl_hash.c  |  1 +
 drivers/crypto/fsl/jobdesc.c   |  1 +
 drivers/crypto/fsl/jr.c|  1 +
 drivers/dma/apbh_dma.c |  1 +
 drivers/dma/bcm6348-iudma.c|  1 +
 drivers/dma/dma-uclass.c   |  1 +
 drivers/dma/ti/k3-udma.c   |  1 +
 drivers/fpga/zynqmppl.c|  1 +
 drivers/mmc/dw_mmc.c   |  1 +
 drivers/mmc/fsl_esdhc.c|  1 +
 drivers/mmc/fsl_esdhc_imx.c|  1 +
 drivers/mmc/fsl_esdhc_spl.c|  1 +
 drivers/mmc/meson_gx_mmc.c |  1 +
 drivers/mmc/omap_hsmmc.c   |  1 +
 drivers/mmc/sdhci.c|  1 +
 drivers/mmc/stm32_sdmmc2.c |  1 +
 drivers/mmc/tmio-common.c  |  1 +
 drivers/mtd/nand/raw/denali.c  |  1 +
 drivers/mtd/nand/raw/fsl_elbc_spl.c|  1 +
 drivers/mtd/nand/raw/fsl_ifc_spl.c |  1 +
 drivers/mtd/nand/raw/mxs_nand.c|  1 +
 drivers/mtd/pic32_flash.c  |  1 +
 drivers/mtd/spi/fsl_espi_spl.c |  1 +
 drivers/net/ag7xxx.c   |  1 +
 drivers/net/altera_tse.c   |  1 +
 drivers/net/bcm-sf2-eth-gmac.c |  1 +
 drivers/net/designware.c   |  1 +
 drivers/net/dwc_eth_qos.c  |  1 +
 drivers/net/e1000.c|  1 +
 drivers/net/ethoc.c|  1 +
 drivers/net/fec_mxc.c  |  1 +
 drivers/net/fsl-mc/mc.c|  1 +
 drivers/net/ftgmac100.c|  1 +
 drivers/net/ftmac100.c |  1 +
 drivers/net/higmacv300.c   |  1 +
 drivers/net/ldpaa_eth/ldpaa_eth.c  |  1 +
 drivers/net/macb.c |  1 +
 drivers/net/mt7628-eth.c   |  1 +
 drivers/net/mtk_eth.c  |  1 +
 drivers/net/mvneta.c   |  1 +
 drivers/net/mvpp2.c|  1 +
 drivers/net/pch_gbe.c   

[U-Boot] [PATCH 24/41] common: Drop cpu_init()

2019-09-30 Thread Simon Glass
This function is not defined anywhere. Drop it.

Signed-off-by: Simon Glass 
---

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

diff --git a/include/common.h b/include/common.h
index 4de05032b2b..ce08bfe11fe 100644
--- a/include/common.h
+++ b/include/common.h
@@ -64,8 +64,6 @@ typedef void (interrupt_handler_t)(void *);
  */
 void   hang(void) __attribute__ ((noreturn));
 
-intcpu_init(void);
-
 #include 
 
 /* common/main.c */
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 17/41] common: Add a new lz4.h header file

2019-09-30 Thread Simon Glass
Add a header file to house the lz4 compression function. Add a comment
while we are here, since it not even clear from the name what the function
actuall does.

Signed-off-by: Simon Glass 
---

 common/image.c |  1 +
 include/common.h   |  3 ---
 include/lz4.h  | 24 
 lib/lz4_wrapper.c  |  1 +
 test/compression.c |  1 +
 5 files changed, 27 insertions(+), 3 deletions(-)
 create mode 100644 include/lz4.h

diff --git a/common/image.c b/common/image.c
index dc16f4429f8..70be47e2518 100644
--- a/common/image.c
+++ b/common/image.c
@@ -20,6 +20,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #if IMAGE_ENABLE_FIT || IMAGE_ENABLE_OF_LIBFDT
diff --git a/include/common.h b/include/common.h
index f433db17aef..1e77ed393e4 100644
--- a/include/common.h
+++ b/include/common.h
@@ -292,9 +292,6 @@ voidwait_ticks(unsigned long);
 ulong  usec2ticks(unsigned long usec);
 ulong  ticks2usec(unsigned long ticks);
 
-/* lib/lz4_wrapper.c */
-int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn);
-
 /* lib/uuid.c */
 #include 
 
diff --git a/include/lz4.h b/include/lz4.h
new file mode 100644
index 000..1276fb98a34
--- /dev/null
+++ b/include/lz4.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2019 Google LLC
+ */
+
+#ifndef __LZ4_H
+#define __LZ4_H
+
+/**
+ * ulz4fn() - Decompress LZ4 data
+ *
+ * @src: Source data to decompress
+ * @srcn: Length of source data
+ * @dst: Destination for uncompressed data
+ * @dstn: Returns length of uncompressed data
+ * @return 0 if OK, -EPROTONOSUPPORT if the magic number or version number are
+ * not recognised or independent blocks are used, -EINVAL if the reserved
+ * fields are non-zero, or input is overrun, -EENOBUFS if the destination
+ * buffer is overrun, -EEPROTO if the compressed data causes an error in
+ * the decompression algorithm
+ */
+int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn);
+
+#endif
diff --git a/lib/lz4_wrapper.c b/lib/lz4_wrapper.c
index 1c68e67452d..1e1e8d50853 100644
--- a/lib/lz4_wrapper.c
+++ b/lib/lz4_wrapper.c
@@ -6,6 +6,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/test/compression.c b/test/compression.c
index 08fef59d0aa..48dccc0e891 100644
--- a/test/compression.c
+++ b/test/compression.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 04/41] status_led: Tidy up the code style

2019-09-30 Thread Simon Glass
There are a few whitespace problems with this code. Tidy them up.

Signed-off-by: Simon Glass 
---

 arch/powerpc/lib/interrupts.c | 2 +-
 drivers/misc/status_led.c | 8 
 include/status_led.h  | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/lib/interrupts.c b/arch/powerpc/lib/interrupts.c
index e589933f565..4b7f543a180 100644
--- a/arch/powerpc/lib/interrupts.c
+++ b/arch/powerpc/lib/interrupts.c
@@ -83,7 +83,7 @@ void timer_interrupt (struct pt_regs *regs)
 #endif/* CONFIG_WATCHDOG || CONFIG_HW_WATCHDOG */
 
 #ifdef CONFIG_LED_STATUS
-   status_led_tick (timestamp);
+   status_led_tick(timestamp);
 #endif /* CONFIG_LED_STATUS */
 }
 
diff --git a/drivers/misc/status_led.c b/drivers/misc/status_led.c
index 8983ab40e46..a6e9c03a02e 100644
--- a/drivers/misc/status_led.c
+++ b/drivers/misc/status_led.c
@@ -82,13 +82,13 @@ void status_led_init(void)
status_led_init_done = 1;
 }
 
-void status_led_tick (ulong timestamp)
+void status_led_tick(ulong timestamp)
 {
led_dev_t *ld;
int i;
 
if (!status_led_init_done)
-   status_led_init ();
+   status_led_init();
 
for (i = 0, ld = led_dev; i < MAX_LED_DEV; i++, ld++) {
 
@@ -103,7 +103,7 @@ void status_led_tick (ulong timestamp)
}
 }
 
-void status_led_set (int led, int state)
+void status_led_set(int led, int state)
 {
led_dev_t *ld;
 
@@ -111,7 +111,7 @@ void status_led_set (int led, int state)
return;
 
if (!status_led_init_done)
-   status_led_init ();
+   status_led_init();
 
ld = _dev[led];
 
diff --git a/include/status_led.h b/include/status_led.h
index 5b3570166db..6707ab1d29d 100644
--- a/include/status_led.h
+++ b/include/status_led.h
@@ -36,8 +36,8 @@
 #endif /* CONFIG_LED_STATUS5 */
 
 void status_led_init(void);
-void status_led_tick (unsigned long timestamp);
-void status_led_set  (int led, int state);
+void status_led_tick(unsigned long timestamp);
+void status_led_set(int led, int state);
 
 /*  MVS v1  **/
 #if (defined(CONFIG_MVS) && CONFIG_MVS < 2)
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 12/41] Move strtomhz() to vsprintf.h

2019-09-30 Thread Simon Glass
At present this function sits in its own file but it does not really
justify it. There are similar string functions in vsprintf.h, so move it
there. Also add the missing function comment.

Use the vsprintf.h include file explicitly where needed.

Signed-off-by: Simon Glass 
---

 arch/arc/lib/cpu.c|  1 +
 arch/arm/cpu/arm926ejs/mx25/generic.c |  1 +
 arch/arm/cpu/arm926ejs/mx27/generic.c |  1 +
 arch/arm/cpu/armv7/ls102xa/cpu.c  |  1 +
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c   |  1 +
 arch/arm/mach-at91/arm926ejs/cpu.c|  1 +
 arch/arm/mach-at91/armv7/cpu.c|  1 +
 arch/m68k/cpu/mcf5227x/cpu.c  |  1 +
 arch/m68k/cpu/mcf523x/cpu.c   |  1 +
 arch/m68k/cpu/mcf52x2/cpu.c   |  1 +
 arch/m68k/cpu/mcf530x/cpu.c   |  1 +
 arch/m68k/cpu/mcf532x/cpu.c   |  1 +
 arch/m68k/cpu/mcf5445x/cpu.c  |  1 +
 arch/m68k/cpu/mcf547x_8x/cpu.c|  1 +
 arch/powerpc/cpu/mpc83xx/cpu.c|  1 +
 arch/powerpc/cpu/mpc83xx/spd_sdram.c  |  1 +
 arch/powerpc/cpu/mpc83xx/speed.c  |  1 +
 arch/powerpc/cpu/mpc85xx/cpu.c|  1 +
 arch/powerpc/cpu/mpc86xx/cpu.c|  1 +
 arch/powerpc/cpu/mpc8xx/cpu.c |  1 +
 arch/xtensa/cpu/cpu.c |  1 +
 board/Arcturus/ucp1020/ddr.c  |  1 +
 board/atmel/at91sam9261ek/at91sam9261ek.c |  1 +
 board/atmel/at91sam9263ek/at91sam9263ek.c |  1 +
 .../atmel/at91sam9m10g45ek/at91sam9m10g45ek.c |  1 +
 board/atmel/at91sam9n12ek/at91sam9n12ek.c |  1 +
 board/atmel/at91sam9rlek/at91sam9rlek.c   |  1 +
 board/atmel/common/video_display.c|  1 +
 board/esd/meesc/meesc.c   |  1 +
 board/freescale/bsc9131rdb/ddr.c  |  1 +
 board/freescale/bsc9132qds/ddr.c  |  1 +
 board/freescale/corenet_ds/ddr.c  |  1 +
 board/freescale/ls1043ardb/ddr.c  |  1 +
 board/freescale/mpc8541cds/mpc8541cds.c   |  1 +
 board/freescale/mpc8548cds/mpc8548cds.c   |  1 +
 board/freescale/mpc8555cds/mpc8555cds.c   |  1 +
 board/freescale/p1010rdb/ddr.c|  1 +
 board/freescale/p1_p2_rdb_pc/ddr.c|  1 +
 board/freescale/p1_twr/ddr.c  |  1 +
 board/mini-box/picosam9g45/picosam9g45.c  |  1 +
 board/ronetix/pm9261/pm9261.c |  1 +
 cmd/bdinfo.c  |  1 +
 drivers/clk/clk_stm32mp1.c|  1 +
 drivers/clk/mpc83xx_clk.c |  1 +
 drivers/cpu/mpc83xx_cpu.c |  1 +
 include/common.h  |  3 ---
 include/vsprintf.h| 10 +
 lib/Makefile  |  4 ++--
 lib/strmhz.c  | 21 ---
 lib/vsprintf.c| 17 +++
 50 files changed, 74 insertions(+), 26 deletions(-)
 delete mode 100644 lib/strmhz.c

diff --git a/arch/arc/lib/cpu.c b/arch/arc/lib/cpu.c
index 01cca95d5b1..83246550ec1 100644
--- a/arch/arc/lib/cpu.c
+++ b/arch/arc/lib/cpu.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/arch/arm/cpu/arm926ejs/mx25/generic.c 
b/arch/arm/cpu/arm926ejs/mx25/generic.c
index 5fcf06ae1a8..eeb61d0d102 100644
--- a/arch/arm/cpu/arm926ejs/mx25/generic.c
+++ b/arch/arm/cpu/arm926ejs/mx25/generic.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/cpu/arm926ejs/mx27/generic.c 
b/arch/arm/cpu/arm926ejs/mx27/generic.c
index 08b1b4de717..9bed0e91bea 100644
--- a/arch/arm/cpu/arm926ejs/mx27/generic.c
+++ b/arch/arm/cpu/arm926ejs/mx27/generic.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/cpu/armv7/ls102xa/cpu.c b/arch/arm/cpu/armv7/ls102xa/cpu.c
index 9ccfe1042ce..ec9984db795 100644
--- a/arch/arm/cpu/armv7/ls102xa/cpu.c
+++ b/arch/arm/cpu/armv7/ls102xa/cpu.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c 
b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index a5d0b5370f8..fbbabc23a77 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-at91/arm926ejs/cpu.c 
b/arch/arm/mach-at91/arm926ejs/cpu.c
index 6f5aa4274b5..e9b4e06595e 100644
--- a/arch/arm/mach-at91/arm926ejs/cpu.c
+++ b/arch/arm/mach-at91/arm926ejs/cpu.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-at91/armv7/cpu.c b/arch/arm/mach-at91/armv7/cpu.c
index 5da067cda10..638645c7e40 100644
--- a/arch/arm/mach-at91/armv7/cpu.c
+++ 

[U-Boot] [PATCH 19/41] common: Move wait_ticks functions out of common.h

2019-09-30 Thread Simon Glass
This function belongs in time.h so move it over and add a comment.

Signed-off-by: Simon Glass 
---

 arch/arm/cpu/pxa/pxa2xx.c | 1 +
 drivers/timer/mpc83xx_timer.c | 1 +
 include/common.h  | 1 -
 include/time.h| 9 +
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/arm/cpu/pxa/pxa2xx.c b/arch/arm/cpu/pxa/pxa2xx.c
index 0b28f0a3ef6..43c206b2459 100644
--- a/arch/arm/cpu/pxa/pxa2xx.c
+++ b/arch/arm/cpu/pxa/pxa2xx.c
@@ -10,6 +10,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/timer/mpc83xx_timer.c b/drivers/timer/mpc83xx_timer.c
index dfbc8672b29..69949d53338 100644
--- a/drivers/timer/mpc83xx_timer.c
+++ b/drivers/timer/mpc83xx_timer.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/include/common.h b/include/common.h
index 20d143deb81..091b54787f7 100644
--- a/include/common.h
+++ b/include/common.h
@@ -286,7 +286,6 @@ int cleanup_before_linux_select(int flags);
 
 /* arch/$(ARCH)/lib/ticks.S */
 uint64_t get_ticks(void);
-void   wait_ticks(unsigned long);
 
 /* lib/uuid.c */
 #include 
diff --git a/include/time.h b/include/time.h
index 5c6a0fd032c..e740858f816 100644
--- a/include/time.h
+++ b/include/time.h
@@ -85,4 +85,13 @@ ulong usec2ticks(unsigned long usec);
  */
 ulong ticks2usec(unsigned long ticks);
 
+/**
+ * wait_ticks() - waits a given number of ticks
+ *
+ * This is an internal funciton. Normally you should use udelay() or mdelay()
+ *
+ * @ticks: Number of ticks to wait
+ */
+void wait_ticks(unsigned long ticks);
+
 #endif /* _TIME_H */
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 14/41] serial: usb: Correct the usbtty_...() prototypes

2019-09-30 Thread Simon Glass
The function declarations in serial.h are not in sync with what is
currently used in usbtty. Fix this by updating the header and including
it, to help catch future such problems.

Signed-off-by: Simon Glass 
---

 drivers/serial/usbtty.c |  1 +
 include/serial.h| 18 ++
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/serial/usbtty.c b/drivers/serial/usbtty.c
index 76d9c8a3a6d..f1c1a260da5 100644
--- a/drivers/serial/usbtty.c
+++ b/drivers/serial/usbtty.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "usbtty.h"
diff --git a/include/serial.h b/include/serial.h
index c1368c68b64..38a1cc99ae2 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -50,18 +50,20 @@ extern void serial_reinit_all(void);
 /* For usbtty */
 #ifdef CONFIG_USB_TTY
 
-extern int usbtty_getc(void);
-extern void usbtty_putc(const char c);
-extern void usbtty_puts(const char *str);
-extern int usbtty_tstc(void);
+struct stdio_dev;
+
+int usbtty_getc(struct stdio_dev *dev);
+void usbtty_putc(struct stdio_dev *dev, const char c);
+void usbtty_puts(struct stdio_dev *dev, const char *str);
+int usbtty_tstc(struct stdio_dev *dev);
 
 #else
 
 /* stubs */
-#define usbtty_getc() 0
-#define usbtty_putc(a)
-#define usbtty_puts(a)
-#define usbtty_tstc() 0
+#define usbtty_getc(dev) 0
+#define usbtty_putc(dev, a)
+#define usbtty_puts(dev, a)
+#define usbtty_tstc(dev) 0
 
 #endif /* CONFIG_USB_TTY */
 
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 08/41] crc32: Use the crc.h header for crc functions

2019-09-30 Thread Simon Glass
Drop inclusion of crc.h in common.h and use the correct header directly
instead.

With this we can drop the conflicting definition in fw_env.h and rely on
the crc.h header, which is already included.

Signed-off-by: Simon Glass 
---

 api/api.c | 1 +
 arch/arm/mach-meson/board-common.c| 1 +
 board/CZ.NIC/turris_omnia/turris_omnia.c  | 1 +
 board/corscience/tricorder/tricorder-eeprom.c | 1 +
 board/freescale/common/sys_eeprom.c   | 1 +
 board/freescale/mpc8323erdb/mpc8323erdb.c | 1 +
 board/gardena/smart-gateway-mt7688/board.c| 1 +
 board/gdsys/a38x/hre.c| 1 +
 board/gdsys/p1022/controlcenterd-id.c | 1 +
 board/sunxi/board.c   | 1 +
 board/theobroma-systems/puma_rk3399/puma-rk3399.c | 1 +
 board/varisys/common/sys_eeprom.c | 1 +
 cmd/i2c.c | 1 +
 cmd/nvedit.c  | 1 +
 common/android_ab.c   | 1 +
 common/bloblist.c | 1 +
 common/board_r.c  | 1 +
 common/hash.c | 1 +
 common/image-fit.c| 1 +
 common/image.c| 1 +
 common/iotrace.c  | 1 +
 common/spl/spl.c  | 1 +
 disk/part_efi.c   | 1 +
 drivers/misc/atsha204a-i2c.c  | 1 +
 drivers/mtd/ubi/attach.c  | 1 +
 drivers/mtd/ubi/crc32.c   | 1 +
 drivers/mtd/ubi/eba.c | 1 +
 drivers/mtd/ubi/fastmap.c | 1 +
 drivers/mtd/ubi/io.c  | 1 +
 drivers/mtd/ubi/vtbl.c| 1 +
 drivers/mtd/ubispl/ubispl.c   | 1 +
 drivers/net/fm/fdt.c  | 1 +
 drivers/net/fm/fm.c   | 1 +
 drivers/qe/qe.c   | 1 +
 env/common.c  | 1 +
 env/eeprom.c  | 1 +
 env/flash.c   | 1 +
 env/nand.c| 1 +
 env/nvram.c   | 1 +
 env/remote.c  | 1 +
 env/sf.c  | 1 +
 examples/api/glue.c   | 1 +
 fs/jffs2/jffs2_1pass.c| 1 +
 fs/ubifs/io.c | 1 +
 fs/ubifs/recovery.c   | 1 +
 fs/ubifs/tnc.c| 1 +
 include/common.h  | 3 ---
 lib/crc32.c   | 1 +
 lib/efi_loader/efi_boottime.c | 1 +
 lib/efi_loader/efi_runtime.c  | 1 +
 lib/efi_loader/efi_variable.c | 1 +
 lib/efi_selftest/efi_selftest_config_table.c  | 1 +
 lib/efi_selftest/efi_selftest_crc32.c | 1 +
 lib/gunzip.c  | 1 +
 lib/zlib/deflate.c| 1 +
 tools/default_image.c | 1 +
 tools/env/fw_env.c| 1 +
 tools/env/fw_env.h| 2 --
 tools/envcrc.c| 1 +
 tools/mkenvimage.c| 1 +
 tools/mxsimage.c  | 1 +
 tools/pbl_crc32.c | 1 +
 tools/pblimage.c  | 1 +
 tools/socfpgaimage.c  | 1 +
 64 files changed, 62 insertions(+), 5 deletions(-)

diff --git a/api/api.c b/api/api.c
index bc9454eb4b6..278b1ed4a34 100644
--- a/api/api.c
+++ b/api/api.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "api_private.h"
 
diff --git a/arch/arm/mach-meson/board-common.c 
b/arch/arm/mach-meson/board-common.c
index d261b4ea331..6c77e379669 100644
--- a/arch/arm/mach-meson/board-common.c
+++ b/arch/arm/mach-meson/board-common.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #if CONFIG_IS_ENABLED(FASTBOOT)
 #include 
diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c 
b/board/CZ.NIC/turris_omnia/turris_omnia.c
index 1d8d08a847d..4d21e62e733 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 # include 
 
 #include "../drivers/ddr/marvell/a38x/ddr3_init.h"
diff --git a/board/corscience/tricorder/tricorder-eeprom.c 
b/board/corscience/tricorder/tricorder-eeprom.c
index 16bceea7ba7..b28189dafdc 100644
--- 

[U-Boot] [PATCH 27/41] arm: powerpc: Tidy up code style for cache functions

2019-09-30 Thread Simon Glass
Remove the unwanted space before the bracket.

Signed-off-by: Simon Glass 
---

 arch/arm/lib/cache-cp15.c| 12 ++--
 arch/microblaze/cpu/cache.c  | 18 +++---
 board/armltd/integrator/integrator.c |  2 +-
 board/cobra5272/flash.c  | 12 ++--
 include/common.h |  2 +-
 post/lib_powerpc/cpu.c   |  6 +++---
 6 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/arch/arm/lib/cache-cp15.c b/arch/arm/lib/cache-cp15.c
index b2913e8165a..fc6d69134ce 100644
--- a/arch/arm/lib/cache-cp15.c
+++ b/arch/arm/lib/cache-cp15.c
@@ -247,17 +247,17 @@ static void cache_disable(uint32_t cache_bit)
 #endif
 
 #if CONFIG_IS_ENABLED(SYS_ICACHE_OFF)
-void icache_enable (void)
+void icache_enable(void)
 {
return;
 }
 
-void icache_disable (void)
+void icache_disable(void)
 {
return;
 }
 
-int icache_status (void)
+int icache_status(void)
 {
return 0;   /* always off */
 }
@@ -279,17 +279,17 @@ int icache_status(void)
 #endif
 
 #if CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
-void dcache_enable (void)
+void dcache_enable(void)
 {
return;
 }
 
-void dcache_disable (void)
+void dcache_disable(void)
 {
return;
 }
 
-int dcache_status (void)
+int dcache_status(void)
 {
return 0;   /* always off */
 }
diff --git a/arch/microblaze/cpu/cache.c b/arch/microblaze/cpu/cache.c
index eebeb37830b..94114555ff5 100644
--- a/arch/microblaze/cpu/cache.c
+++ b/arch/microblaze/cpu/cache.c
@@ -8,7 +8,7 @@
 #include 
 #include 
 
-int dcache_status (void)
+int dcache_status(void)
 {
int i = 0;
int mask = 0x80;
@@ -18,7 +18,7 @@ int dcache_status (void)
return i;
 }
 
-int icache_status (void)
+int icache_status(void)
 {
int i = 0;
int mask = 0x20;
@@ -28,28 +28,32 @@ int icache_status (void)
return i;
 }
 
-void   icache_enable (void) {
+void icache_enable(void)
+{
MSRSET(0x20);
 }
 
-void   icache_disable(void) {
+void icache_disable(void)
+{
/* we are not generate ICACHE size -> flush whole cache */
flush_cache(0, 32768);
MSRCLR(0x20);
 }
 
-void   dcache_enable (void) {
+void dcache_enable(void)
+{
MSRSET(0x80);
 }
 
-void   dcache_disable(void) {
+void dcache_disable(void)
+{
 #ifdef XILINX_USE_DCACHE
flush_cache(0, XILINX_DCACHE_BYTE_SIZE);
 #endif
MSRCLR(0x80);
 }
 
-void flush_cache (ulong addr, ulong size)
+void flush_cache(ulong addr, ulong size)
 {
int i;
for (i = 0; i < size; i += 4)
diff --git a/board/armltd/integrator/integrator.c 
b/board/armltd/integrator/integrator.c
index 0a2baa72976..f0fbe2b4176 100644
--- a/board/armltd/integrator/integrator.c
+++ b/board/armltd/integrator/integrator.c
@@ -109,7 +109,7 @@ extern void cm_remap(void);
writel(SC_CTRL_FLASHVPP | SC_CTRL_FLASHWP, SC_CTRLS);
 #endif
 
-   icache_enable ();
+   icache_enable();
 
return 0;
 }
diff --git a/board/cobra5272/flash.c b/board/cobra5272/flash.c
index e5edc2a0401..9bf824889a1 100644
--- a/board/cobra5272/flash.c
+++ b/board/cobra5272/flash.c
@@ -164,8 +164,8 @@ int flash_erase (flash_info_t * info, int s_first, int 
s_last)
 * chip is in programming mode.
 */
 
-   cflag = icache_status ();
-   icache_disable ();
+   cflag = icache_status();
+   icache_disable();
iflag = disable_interrupts ();
 
printf ("\n");
@@ -237,7 +237,7 @@ int flash_erase (flash_info_t * info, int s_first, int 
s_last)
enable_interrupts ();
 
if (cflag)
-   icache_enable ();
+   icache_enable();
 
return rc;
 }
@@ -267,8 +267,8 @@ static int write_word (flash_info_t * info, ulong dest, 
ulong data)
 * chip is in programming mode.
 */
 
-   cflag = icache_status ();
-   icache_disable ();
+   cflag = icache_status();
+   icache_disable();
iflag = disable_interrupts ();
 
MEM_FLASH_ADDR1 = CMD_UNLOCK1;
@@ -303,7 +303,7 @@ static int write_word (flash_info_t * info, ulong dest, 
ulong data)
enable_interrupts ();
 
if (cflag)
-   icache_enable ();
+   icache_enable();
 
return rc;
 }
diff --git a/include/common.h b/include/common.h
index 3f6a95d7e02..82b1abe698d 100644
--- a/include/common.h
+++ b/include/common.h
@@ -189,7 +189,7 @@ int testdram(void);
 inticache_status (void);
 void   icache_enable (void);
 void   icache_disable(void);
-intdcache_status (void);
+intdcache_status(void);
 void   dcache_enable (void);
 void   dcache_disable(void);
 void   mmu_disable(void);
diff --git a/post/lib_powerpc/cpu.c b/post/lib_powerpc/cpu.c
index 109be38e166..67130393307 100644
--- a/post/lib_powerpc/cpu.c
+++ b/post/lib_powerpc/cpu.c
@@ -57,12 +57,12 @@ ulong cpu_post_makecr (long v)
 
 int cpu_post_test (int flags)
 {
-   int ic = 

[U-Boot] [PATCH 11/41] common: Move sorting functions to their own header file

2019-09-30 Thread Simon Glass
These don't need to be in common.h so move them out into a new header.
Also add some missing comments.

Signed-off-by: Simon Glass 
---

 cmd/efi.c   |  1 +
 common/bootstage.c  |  1 +
 env/common.c|  1 +
 fs/yaffs2/yaffs_qsort.c |  1 +
 include/common.h|  5 -
 include/sort.h  | 34 ++
 lib/hashtable.c |  1 +
 lib/qsort.c |  1 +
 8 files changed, 40 insertions(+), 5 deletions(-)
 create mode 100644 include/sort.h

diff --git a/cmd/efi.c b/cmd/efi.c
index 919cb2fcfd5..ea239a01f0b 100644
--- a/cmd/efi.c
+++ b/cmd/efi.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static const char *const type_name[] = {
"reserved",
diff --git a/common/bootstage.c b/common/bootstage.c
index 56ef91ad859..d6744ee5bac 100644
--- a/common/bootstage.c
+++ b/common/bootstage.c
@@ -10,6 +10,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/env/common.c b/env/common.c
index a23732bfd8b..d6c86a7e6e6 100644
--- a/env/common.c
+++ b/env/common.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/fs/yaffs2/yaffs_qsort.c b/fs/yaffs2/yaffs_qsort.c
index b463569815d..32c767f3599 100644
--- a/fs/yaffs2/yaffs_qsort.c
+++ b/fs/yaffs2/yaffs_qsort.c
@@ -5,6 +5,7 @@
  */
 
 #include "yportenv.h"
+#include 
 /* #include  */
 
 /*
diff --git a/include/common.h b/include/common.h
index 97b661181b0..d17a2b2642c 100644
--- a/include/common.h
+++ b/include/common.h
@@ -304,11 +304,6 @@ ulong  ticks2usec(unsigned long ticks);
 /* lib/lz4_wrapper.c */
 int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn);
 
-/* lib/qsort.c */
-void qsort(void *base, size_t nmemb, size_t size,
-  int(*compar)(const void *, const void *));
-int strcmp_compar(const void *, const void *);
-
 /* lib/uuid.c */
 #include 
 
diff --git a/include/sort.h b/include/sort.h
new file mode 100644
index 000..0c6b588fcb0
--- /dev/null
+++ b/include/sort.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2019 Google LLC
+ */
+
+#ifndef __SORT_H
+#define __SORT_H
+
+/**
+ * qsort() - Use the quicksort algorithm to sort some values
+ *
+ * @base: Base address of array to sort
+ * @nmemb: Number of members to sort
+ * @size: Size of each member in bytes
+ * @compar: Comparison function which should return:
+ * < 0 if element at s1 < element at s2,
+ *   0 if element at s1 == element at s2,
+ * > 0 if element at s1 > element at s2,
+ */
+void qsort(void *base, size_t nmemb, size_t size,
+  int (*compar)(const void *s1, const void *s2));
+
+/**
+ * strcmp_compar() - compar function for string arrays
+ *
+ * This can be passed to qsort when a string array is being sorted
+ *
+ * @s1: First string to compare
+ * @s2: Second string to compare
+ * @return comparison value (less than, equal to, or greater than 0)
+ */
+int strcmp_compar(const void *s1, const void *s2);
+
+#endif
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 2caab0a4c6d..907e8a642f3 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -14,6 +14,7 @@
 
 #include 
 #include 
+#include 
 
 #ifdef USE_HOSTCC  /* HOST build */
 # include 
diff --git a/lib/qsort.c b/lib/qsort.c
index 57098841f9a..f63d4ef7268 100644
--- a/lib/qsort.c
+++ b/lib/qsort.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 void qsort(void  *base,
   size_t nel,
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 16/41] common: Move serial functions out of common.h

2019-09-30 Thread Simon Glass
These functions belong in serial.h so move them over.

Signed-off-by: Simon Glass 
---

 arch/arm/cpu/arm926ejs/mxs/spl_boot.c  | 1 +
 board/amarula/vyasa-rk3288/vyasa-rk3288.c  | 1 +
 board/astro/mcf5373l/mcf5373l.c| 1 +
 board/birdland/bav335x/board.c | 1 +
 board/bticino/mamoj/spl.c  | 1 +
 board/cssi/MCR3000/MCR3000.c   | 1 +
 board/engicam/common/spl.c | 1 +
 board/esd/meesc/meesc.c| 1 +
 board/gumstix/pepper/board.c   | 1 +
 board/isee/igep003x/board.c| 1 +
 board/isee/igep00x0/spl.c  | 1 +
 board/liebherr/display5/spl.c  | 1 +
 board/liebherr/mccmon6/mccmon6.c   | 1 +
 board/logicpd/am3517evm/am3517evm.c| 1 +
 board/logicpd/imx6/imx6logic.c | 1 +
 board/logicpd/omap3som/omap3logic.c| 1 +
 board/overo/common.c   | 1 +
 board/siemens/common/board.c   | 1 +
 board/silica/pengwyn/board.c   | 1 +
 board/st/stm32f746-disco/stm32f746-disco.c | 1 +
 board/tcl/sl50/board.c | 1 +
 board/ti/am57xx/board.c| 1 +
 board/ti/beagle/beagle.c   | 1 +
 board/ti/dra7xx/evm.c  | 1 +
 board/ti/evm/evm.c | 1 +
 board/vscom/baltos/board.c | 1 +
 cmd/load.c | 1 +
 common/board_f.c   | 1 +
 common/kgdb_stubs.c| 1 +
 common/lcd_console.c   | 1 +
 common/spl/spl.c   | 1 +
 include/common.h   | 9 -
 include/serial.h   | 8 
 33 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c 
b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
index cb361ac65c3..5b3b51ce15f 100644
--- a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
+++ b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
@@ -8,6 +8,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/amarula/vyasa-rk3288/vyasa-rk3288.c 
b/board/amarula/vyasa-rk3288/vyasa-rk3288.c
index baf197c4851..92e0698c534 100644
--- a/board/amarula/vyasa-rk3288/vyasa-rk3288.c
+++ b/board/amarula/vyasa-rk3288/vyasa-rk3288.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 
 #ifndef CONFIG_TPL_BUILD
 
diff --git a/board/astro/mcf5373l/mcf5373l.c b/board/astro/mcf5373l/mcf5373l.c
index 759ff495621..db157a83c8f 100644
--- a/board/astro/mcf5373l/mcf5373l.c
+++ b/board/astro/mcf5373l/mcf5373l.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/birdland/bav335x/board.c b/board/birdland/bav335x/board.c
index 8811583ac62..1f3f44a8675 100644
--- a/board/birdland/bav335x/board.c
+++ b/board/birdland/bav335x/board.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/bticino/mamoj/spl.c b/board/bticino/mamoj/spl.c
index c53bdce0ceb..620e4d1de0c 100644
--- a/board/bticino/mamoj/spl.c
+++ b/board/bticino/mamoj/spl.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 
 #include 
diff --git a/board/cssi/MCR3000/MCR3000.c b/board/cssi/MCR3000/MCR3000.c
index 445b84c180f..dcd2c1c9753 100644
--- a/board/cssi/MCR3000/MCR3000.c
+++ b/board/cssi/MCR3000/MCR3000.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/engicam/common/spl.c b/board/engicam/common/spl.c
index 4d293c8032d..a9820a9028e 100644
--- a/board/engicam/common/spl.c
+++ b/board/engicam/common/spl.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 
 #include 
diff --git a/board/esd/meesc/meesc.c b/board/esd/meesc/meesc.c
index 221048a91f1..4271b0db19c 100644
--- a/board/esd/meesc/meesc.c
+++ b/board/esd/meesc/meesc.c
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/gumstix/pepper/board.c b/board/gumstix/pepper/board.c
index f5beb8c940e..65e5e1e60f2 100644
--- a/board/gumstix/pepper/board.c
+++ b/board/gumstix/pepper/board.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/isee/igep003x/board.c b/board/isee/igep003x/board.c
index a8c2b121a47..d59121296e4 100644
--- a/board/isee/igep003x/board.c
+++ b/board/isee/igep003x/board.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/isee/igep00x0/spl.c b/board/isee/igep00x0/spl.c
index e092e1a418b..f814fe13542 100644
--- a/board/isee/igep00x0/spl.c
+++ b/board/isee/igep00x0/spl.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/liebherr/display5/spl.c b/board/liebherr/display5/spl.c
index 354b63e431f..be154e2dd64 100644
--- a/board/liebherr/display5/spl.c
+++ b/board/liebherr/display5/spl.c
@@ -6,6 +6,7 @@
 
 

[U-Boot] [PATCH 13/41] common: Move env_get_ip() to net.h

2019-09-30 Thread Simon Glass
This function relates to networking, so move it out of the common.h
header file.

Signed-off-by: Simon Glass 
---

 include/common.h |  4 
 include/net.h| 21 -
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/include/common.h b/include/common.h
index f993e4bef33..4fda40cc1d6 100644
--- a/include/common.h
+++ b/include/common.h
@@ -319,10 +319,6 @@ intserial_printf (const char *fmt, ...)
 
 /* lib/net_utils.c */
 #include 
-static inline struct in_addr env_get_ip(char *var)
-{
-   return string_to_ip(env_get(var));
-}
 
 #include 
 
diff --git a/include/net.h b/include/net.h
index d8d187d8af9..11eca1bc6c3 100644
--- a/include/net.h
+++ b/include/net.h
@@ -829,7 +829,13 @@ static inline void net_random_ethaddr(uchar *addr)
 /* Convert an IP address to a string */
 void ip_to_string(struct in_addr x, char *s);
 
-/* Convert a string to ip address */
+/**
+ * string_to_ip() - Convert a string to ip address
+ *
+ * @s: String to conver, in the format format a.b.c.d, where each value is a
+ * decimal number from 0 to 255
+ * @return IP address, or 0 if invalid
+ */
 struct in_addr string_to_ip(const char *s);
 
 /* Convert a VLAN id to a string */
@@ -887,4 +893,17 @@ int update_tftp(ulong addr, char *interface, char 
*devstring);
  */
 void eth_parse_enetaddr(const char *addr, uint8_t *enetaddr);
 
+/**
+ * env_get_ip() - Convert an environment value to to an ip address
+ *
+ * @var: Environment variable to convert. The value of this variable must be
+ * in the format format a.b.c.d, where each value is a decimal number from
+ * 0 to 255
+ * @return IP address, or 0 if invalid
+ */
+static inline struct in_addr env_get_ip(char *var)
+{
+   return string_to_ip(env_get(var));
+}
+
 #endif /* __NET_H__ */
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 09/41] spl: bootcount: Move code out of header file

2019-09-30 Thread Simon Glass
It is not good practice to write code in a header file. If it is included
multiple times then the code can cause duplicate functions.

Move the bootcount_store() and bootcount_load() functions into SPL.

Note: bootcount is a bit strange in that it uses driver model but does not
define proper drivers. This should be fixed.

Signed-off-by: Simon Glass 
---

 common/spl/spl.c| 11 +++
 include/bootcount.h |  4 
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 7a443a0f322..6e3d4bd599d 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -790,3 +790,14 @@ ulong spl_relocate_stack_gd(void)
return 0;
 #endif
 }
+
+#if defined(CONFIG_BOOTCOUNT_LIMIT) && !defined(CONFIG_SPL_BOOTCOUNT_LIMIT)
+void bootcount_store(ulong a)
+{
+}
+
+ulong bootcount_load(void)
+{
+   return 0;
+}
+#endif
diff --git a/include/bootcount.h b/include/bootcount.h
index 8fa8cf82181..a26a3852338 100644
--- a/include/bootcount.h
+++ b/include/bootcount.h
@@ -127,10 +127,6 @@ static inline void bootcount_inc(void)
 #endif /* !CONFIG_SPL_BUILD */
 }
 
-#if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_BOOTCOUNT_LIMIT)
-void bootcount_store(ulong a) {};
-ulong bootcount_load(void) { return 0; }
-#endif /* CONFIG_SPL_BUILD && !CONFIG_SPL_BOOTCOUNT_LIMIT */
 #else
 static inline int bootcount_error(void) { return 0; }
 static inline void bootcount_inc(void) {}
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 18/41] common: Move some time functions out of common.h

2019-09-30 Thread Simon Glass
These functions belong in time.h so move them over and add comments.

Signed-off-by: Simon Glass 
---

 arch/arm/cpu/armv7/ls102xa/timer.c|  1 +
 arch/arm/cpu/armv8/generic_timer.c|  1 +
 arch/arm/mach-imx/syscounter.c|  1 +
 arch/arm/mach-imx/timer.c |  1 +
 arch/m68k/lib/time.c  |  1 +
 arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c |  1 +
 arch/powerpc/cpu/mpc8xxx/srio.c   |  1 +
 arch/powerpc/lib/time.c   |  1 +
 drivers/crypto/fsl/jr.c   |  1 +
 drivers/i2c/fsl_i2c.c |  1 +
 include/common.h  |  4 
 include/time.h| 16 
 12 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/arch/arm/cpu/armv7/ls102xa/timer.c 
b/arch/arm/cpu/armv7/ls102xa/timer.c
index e79360ada88..a5f4e31ac70 100644
--- a/arch/arm/cpu/armv7/ls102xa/timer.c
+++ b/arch/arm/cpu/armv7/ls102xa/timer.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/cpu/armv8/generic_timer.c 
b/arch/arm/cpu/armv8/generic_timer.c
index c1706dcec18..46e63294fef 100644
--- a/arch/arm/cpu/armv8/generic_timer.c
+++ b/arch/arm/cpu/armv8/generic_timer.c
@@ -6,6 +6,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/arch/arm/mach-imx/syscounter.c b/arch/arm/mach-imx/syscounter.c
index c888a939385..5a292c39643 100644
--- a/arch/arm/mach-imx/syscounter.c
+++ b/arch/arm/mach-imx/syscounter.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-imx/timer.c b/arch/arm/mach-imx/timer.c
index ed5eb1c8a77..5fe5c51f6a6 100644
--- a/arch/arm/mach-imx/timer.c
+++ b/arch/arm/mach-imx/timer.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/m68k/lib/time.c b/arch/m68k/lib/time.c
index a6345a0bc9c..c76c5fedc99 100644
--- a/arch/m68k/lib/time.c
+++ b/arch/m68k/lib/time.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c 
b/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
index fcfa7302334..ebdcd29c13d 100644
--- a/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
+++ b/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #ifdef CONFIG_SYS_P4080_ERRATUM_SERDES8
 #include 
 #endif
diff --git a/arch/powerpc/cpu/mpc8xxx/srio.c b/arch/powerpc/cpu/mpc8xxx/srio.c
index ea7dac6e668..a1f94035596 100644
--- a/arch/powerpc/cpu/mpc8xxx/srio.c
+++ b/arch/powerpc/cpu/mpc8xxx/srio.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/powerpc/lib/time.c b/arch/powerpc/lib/time.c
index a22a73abfa5..e1494fa1292 100644
--- a/arch/powerpc/lib/time.c
+++ b/arch/powerpc/lib/time.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 
 /* - */
diff --git a/drivers/crypto/fsl/jr.c b/drivers/crypto/fsl/jr.c
index 31217623649..1ea9db6850f 100644
--- a/drivers/crypto/fsl/jr.c
+++ b/drivers/crypto/fsl/jr.c
@@ -11,6 +11,7 @@
 #include "jr.h"
 #include "jobdesc.h"
 #include "desc_constr.h"
+#include 
 #ifdef CONFIG_FSL_CORENET
 #include 
 #endif
diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c
index bf8d52d5ad5..bbbd6ef5bfd 100644
--- a/drivers/i2c/fsl_i2c.c
+++ b/drivers/i2c/fsl_i2c.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include/* Functional interface */
+#include 
 #include 
 #include/* HW definitions */
 #include 
diff --git a/include/common.h b/include/common.h
index 1e77ed393e4..20d143deb81 100644
--- a/include/common.h
+++ b/include/common.h
@@ -288,10 +288,6 @@ int cleanup_before_linux_select(int flags);
 uint64_t get_ticks(void);
 void   wait_ticks(unsigned long);
 
-/* arch/$(ARCH)/lib/time.c */
-ulong  usec2ticks(unsigned long usec);
-ulong  ticks2usec(unsigned long ticks);
-
 /* lib/uuid.c */
 #include 
 
diff --git a/include/time.h b/include/time.h
index 1e9b369be7c..5c6a0fd032c 100644
--- a/include/time.h
+++ b/include/time.h
@@ -69,4 +69,20 @@ uint64_t usec_to_tick(unsigned long usec);
(time_after_eq(a,b) && \
 time_before(a,c))
 
+/**
+ * usec2ticks() - Convert microseconds to internal ticks
+ *
+ * @usec: Value of microseconds to convert
+ * @return Corresponding internal ticks value, calculated using get_tbclk()
+ */
+ulong usec2ticks(unsigned long usec);
+
+/**
+ * ticks2usec() - Convert internal ticks to microseconds
+ *
+ * @ticks: Value of ticks to convert
+ * @return Corresponding microseconds value, calculated using get_tbclk()
+ */
+ulong ticks2usec(unsigned long ticks);
+
 #endif /* _TIME_H */
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 05/41] common: Move random-number functions into their own header

2019-09-30 Thread Simon Glass
Create a new rand.h header file and move functions into it, to reduce
the size of common.h

Signed-off-by: Simon Glass 
---

 include/common.h |  6 --
 include/net.h|  1 +
 include/rand.h   | 40 
 lib/rand.c   |  1 +
 net/link_local.c |  1 +
 5 files changed, 43 insertions(+), 6 deletions(-)
 create mode 100644 include/rand.h

diff --git a/include/common.h b/include/common.h
index 52bcc2e591e..b09c7aeddd4 100644
--- a/include/common.h
+++ b/include/common.h
@@ -325,12 +325,6 @@ char * strmhz(char *buf, unsigned long hz);
 /* lib/crc32.c */
 #include 
 
-/* lib/rand.c */
-#define RAND_MAX -1U
-void srand(unsigned int seed);
-unsigned int rand(void);
-unsigned int rand_r(unsigned int *seedp);
-
 /*
  * STDIO based functions (can always be used)
  */
diff --git a/include/net.h b/include/net.h
index 75a16e4c8f8..d8d187d8af9 100644
--- a/include/net.h
+++ b/include/net.h
@@ -16,6 +16,7 @@
 #include  /* for nton* / ntoh* stuff */
 #include 
 #include 
+#include 
 
 #define DEBUG_LL_STATE 0   /* Link local state machine changes */
 #define DEBUG_DEV_PKT 0/* Packets or info directed to the 
device */
diff --git a/include/rand.h b/include/rand.h
new file mode 100644
index 000..c9d15f50a13
--- /dev/null
+++ b/include/rand.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+ */
+
+#ifndef __RAND_H
+#define __RAND_H
+
+#define RAND_MAX -1U
+
+/**
+ * srand() - Set the random-number seed value
+ *
+ * This can be used to restart the pseudo-random-number sequence from a known
+ * point. This affects future calls to rand() to start from that point
+ *
+ * @seed: New seed
+ */
+void srand(unsigned int seed);
+
+/**
+ * rand() - Get a 32-bit pseudo-random number
+ *
+ * @returns next random number in the sequence
+ */
+unsigned int rand(void);
+
+/**
+ * rand_r() - Get a 32-bit pseudo-random number
+ *
+ * This version of the function allows multiple sequences to be used at the
+ * same time, since it requires the caller to store the seed value.
+ *
+ * @seed value to use, updated on exit
+ * @returns next random number in the sequence
+ */
+unsigned int rand_r(unsigned int *seedp);
+
+#endif
diff --git a/lib/rand.c b/lib/rand.c
index af4cf3a0e8c..d256baf5cee 100644
--- a/lib/rand.c
+++ b/lib/rand.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 
 static unsigned int y = 1U;
 
diff --git a/net/link_local.c b/net/link_local.c
index dd9fcad0874..1986b9b9d3b 100644
--- a/net/link_local.c
+++ b/net/link_local.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "arp.h"
 #include "net_rand.h"
 
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 06/41] common: Drop linux/crc8.h

2019-09-30 Thread Simon Glass
We have an existing U-Boot header for the one function that this defines.
Use that instead of the linux/ one. Move over the nice comment.

Signed-off-by: Simon Glass 
---

 board/theadorable/theadorable.c |  2 +-
 drivers/tpm/tpm2_tis_sandbox.c  |  2 +-
 drivers/tpm/tpm_tis_sandbox.c   |  2 +-
 include/linux/crc8.h| 23 ---
 include/u-boot/crc.h| 14 +-
 lib/crc8.c  |  7 ++-
 6 files changed, 22 insertions(+), 28 deletions(-)
 delete mode 100644 include/linux/crc8.h

diff --git a/board/theadorable/theadorable.c b/board/theadorable/theadorable.c
index d42350319cc..2958d5ff882 100644
--- a/board/theadorable/theadorable.c
+++ b/board/theadorable/theadorable.c
@@ -14,11 +14,11 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #ifdef CONFIG_NET
 #include 
 #endif
+#include 
 #include "theadorable.h"
 
 #include "../drivers/ddr/marvell/axp/ddr3_hw_training.h"
diff --git a/drivers/tpm/tpm2_tis_sandbox.c b/drivers/tpm/tpm2_tis_sandbox.c
index f282ea6adf9..522988795c0 100644
--- a/drivers/tpm/tpm2_tis_sandbox.c
+++ b/drivers/tpm/tpm2_tis_sandbox.c
@@ -9,7 +9,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 /* Hierarchies */
 enum tpm2_hierarchy {
diff --git a/drivers/tpm/tpm_tis_sandbox.c b/drivers/tpm/tpm_tis_sandbox.c
index 3336f559e57..2dff0d3eee9 100644
--- a/drivers/tpm/tpm_tis_sandbox.c
+++ b/drivers/tpm/tpm_tis_sandbox.c
@@ -8,7 +8,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 /* TPM NVRAM location indices. */
 #define FIRMWARE_NV_INDEX  0x1007
diff --git a/include/linux/crc8.h b/include/linux/crc8.h
deleted file mode 100644
index 0ab5b9ab219..000
--- a/include/linux/crc8.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (c) 2013 Google, Inc
- */
-
-
-#ifndef __linux_crc8_h
-#define __linux_crc8_h
-
-/**
- * crc8() - Calculate and return CRC-8 of the data
- *
- * This uses an x^8 + x^2 + x + 1 polynomial.  A table-based algorithm would
- * be faster, but for only a few bytes it isn't worth the code size
- *
- * @crc_start: CRC8 start value
- * @vptr: Buffer to checksum
- * @len: Length of buffer in bytes
- * @return CRC8 checksum
- */
-unsigned int crc8(unsigned int crc_start, const unsigned char *vptr, int len);
-
-#endif
diff --git a/include/u-boot/crc.h b/include/u-boot/crc.h
index 788ef29a17b..b42bcda2b31 100644
--- a/include/u-boot/crc.h
+++ b/include/u-boot/crc.h
@@ -8,7 +8,19 @@
 #ifndef _UBOOT_CRC_H
 #define _UBOOT_CRC_H
 
-/* lib/crc8.c */
+/**
+ * crc8() - Calculate and return CRC-8 of the data
+ *
+ * This uses an x^8 + x^2 + x + 1 polynomial.  A table-based algorithm would
+ * be faster, but for only a few bytes it isn't worth the code size
+ *
+ * lib/crc8.c
+ *
+ * @crc_start: CRC8 start value
+ * @vptr: Buffer to checksum
+ * @len: Length of buffer in bytes
+ * @return CRC8 checksum
+ */
 unsigned int crc8(unsigned int crc_start, const unsigned char *vptr, int len);
 
 /* lib/crc16.c - 16 bit CRC with polynomial x^16+x^12+x^5+1 (CRC-CCITT) */
diff --git a/lib/crc8.c b/lib/crc8.c
index 55f7c07285c..87b87b675b2 100644
--- a/lib/crc8.c
+++ b/lib/crc8.c
@@ -3,7 +3,12 @@
  * Copyright (c) 2013 Google, Inc
  */
 
-#include "linux/crc8.h"
+#ifdef USE_HOSTCC
+#include 
+#else
+#include 
+#endif
+#include 
 
 #define POLY   (0x1070U << 3)
 
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 03/41] common: Drop global inclusion of status_led.h

2019-09-30 Thread Simon Glass
This is only used by a few files so it should not be in the common header.
Move it out.

Signed-off-by: Simon Glass 
---

 board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c | 1 +
 board/atmel/at91sam9261ek/led.c | 1 +
 board/atmel/at91sam9263ek/led.c | 1 +
 board/atmel/at91sam9m10g45ek/led.c  | 1 +
 board/atmel/at91sam9rlek/led.c  | 1 +
 board/cirrus/edb93xx/edb93xx.c  | 1 +
 board/compulab/cm_t335/cm_t335.c| 1 +
 board/corscience/tricorder/tricorder.c  | 1 +
 board/mini-box/picosam9g45/led.c| 1 +
 board/ronetix/pm9261/led.c  | 1 +
 board/ronetix/pm9263/led.c  | 1 +
 board/samtec/vining_fpga/socfpga.c  | 1 +
 board/st/stm32f429-discovery/led.c  | 1 +
 common/board_r.c| 1 +
 drivers/misc/pca9551_led.c  | 1 +
 drivers/timer/mpc83xx_timer.c   | 1 +
 include/common.h| 4 
 17 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c 
b/board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c
index e58bbf07ef1..0eac10d9113 100644
--- a/board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c
+++ b/board/alliedtelesis/SBx81LIFKW/sbx81lifkw.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/atmel/at91sam9261ek/led.c b/board/atmel/at91sam9261ek/led.c
index 81967864cf4..a1aab98d587 100644
--- a/board/atmel/at91sam9261ek/led.c
+++ b/board/atmel/at91sam9261ek/led.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/atmel/at91sam9263ek/led.c b/board/atmel/at91sam9263ek/led.c
index 55fb80dc8d7..849501ec36b 100644
--- a/board/atmel/at91sam9263ek/led.c
+++ b/board/atmel/at91sam9263ek/led.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/atmel/at91sam9m10g45ek/led.c 
b/board/atmel/at91sam9m10g45ek/led.c
index feef2308715..f44a09623fa 100644
--- a/board/atmel/at91sam9m10g45ek/led.c
+++ b/board/atmel/at91sam9m10g45ek/led.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/atmel/at91sam9rlek/led.c b/board/atmel/at91sam9rlek/led.c
index c2df6efd18e..6dd19aea150 100644
--- a/board/atmel/at91sam9rlek/led.c
+++ b/board/atmel/at91sam9rlek/led.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/cirrus/edb93xx/edb93xx.c b/board/cirrus/edb93xx/edb93xx.c
index 8a72fa7a423..88fac76ea52 100644
--- a/board/cirrus/edb93xx/edb93xx.c
+++ b/board/cirrus/edb93xx/edb93xx.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/compulab/cm_t335/cm_t335.c b/board/compulab/cm_t335/cm_t335.c
index 6e38745191c..561f2f30bb2 100644
--- a/board/compulab/cm_t335/cm_t335.c
+++ b/board/compulab/cm_t335/cm_t335.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
diff --git a/board/corscience/tricorder/tricorder.c 
b/board/corscience/tricorder/tricorder.c
index 27e6066575e..da33f8441ce 100644
--- a/board/corscience/tricorder/tricorder.c
+++ b/board/corscience/tricorder/tricorder.c
@@ -11,6 +11,7 @@
  */
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/mini-box/picosam9g45/led.c b/board/mini-box/picosam9g45/led.c
index 2e32b7fb363..8ce8b6bbeac 100644
--- a/board/mini-box/picosam9g45/led.c
+++ b/board/mini-box/picosam9g45/led.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/ronetix/pm9261/led.c b/board/ronetix/pm9261/led.c
index 2a53b2e6bd2..df955830b1b 100644
--- a/board/ronetix/pm9261/led.c
+++ b/board/ronetix/pm9261/led.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/ronetix/pm9263/led.c b/board/ronetix/pm9263/led.c
index 683e151a4fe..524b4afcbd2 100644
--- a/board/ronetix/pm9263/led.c
+++ b/board/ronetix/pm9263/led.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/samtec/vining_fpga/socfpga.c 
b/board/samtec/vining_fpga/socfpga.c
index 1e095a4e7db..2d32ad94571 100644
--- a/board/samtec/vining_fpga/socfpga.c
+++ b/board/samtec/vining_fpga/socfpga.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/board/st/stm32f429-discovery/led.c 
b/board/st/stm32f429-discovery/led.c
index ae6df78f56f..539c139bb5d 100644
--- a/board/st/stm32f429-discovery/led.c
+++ b/board/st/stm32f429-discovery/led.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 
 void coloured_LED_init(void)
diff --git a/common/board_r.c b/common/board_r.c
index d6fb5047a26..646b99ba963 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/misc/pca9551_led.c 

[U-Boot] [PATCH 02/41] Drop CONFIG_SHOW_ACTIVITY

2019-09-30 Thread Simon Glass
This feature is not enabled by any board. Drop it.

Signed-off-by: Simon Glass 
---

 arch/powerpc/lib/interrupts.c | 13 -
 common/cli_readline.c |  6 --
 drivers/timer/mpc83xx_timer.c |  4 
 include/common.h  |  4 
 net/net.c |  3 ---
 scripts/config_whitelist.txt  |  1 -
 6 files changed, 31 deletions(-)

diff --git a/arch/powerpc/lib/interrupts.c b/arch/powerpc/lib/interrupts.c
index 19682cfcfad..e589933f565 100644
--- a/arch/powerpc/lib/interrupts.c
+++ b/arch/powerpc/lib/interrupts.c
@@ -15,15 +15,6 @@
 #endif
 
 #ifndef CONFIG_MPC83XX_TIMER
-#ifdef CONFIG_SHOW_ACTIVITY
-void board_show_activity (ulong) __attribute__((weak, 
alias("__board_show_activity")));
-
-void __board_show_activity (ulong dummy)
-{
-   return;
-}
-#endif /* CONFIG_SHOW_ACTIVITY */
-
 #ifndef CONFIG_SYS_WATCHDOG_FREQ
 #define CONFIG_SYS_WATCHDOG_FREQ (CONFIG_SYS_HZ / 2)
 #endif
@@ -94,10 +85,6 @@ void timer_interrupt (struct pt_regs *regs)
 #ifdef CONFIG_LED_STATUS
status_led_tick (timestamp);
 #endif /* CONFIG_LED_STATUS */
-
-#ifdef CONFIG_SHOW_ACTIVITY
-   board_show_activity (timestamp);
-#endif /* CONFIG_SHOW_ACTIVITY */
 }
 
 ulong get_timer (ulong base)
diff --git a/common/cli_readline.c b/common/cli_readline.c
index 99b631720e1..ea510ed6395 100644
--- a/common/cli_readline.c
+++ b/common/cli_readline.c
@@ -569,12 +569,6 @@ int cli_readline_into_buffer(const char *const prompt, 
char *buffer,
return -2;  /* timed out */
WATCHDOG_RESET();   /* Trigger watchdog, if needed */
 
-#ifdef CONFIG_SHOW_ACTIVITY
-   while (!tstc()) {
-   show_activity(0);
-   WATCHDOG_RESET();
-   }
-#endif
c = getc();
 
/*
diff --git a/drivers/timer/mpc83xx_timer.c b/drivers/timer/mpc83xx_timer.c
index 8e541109d4e..9bc32f9b281 100644
--- a/drivers/timer/mpc83xx_timer.c
+++ b/drivers/timer/mpc83xx_timer.c
@@ -171,10 +171,6 @@ void timer_interrupt(struct pt_regs *regs)
 #ifdef CONFIG_LED_STATUS
status_led_tick(priv->timestamp);
 #endif /* CONFIG_LED_STATUS */
-
-#ifdef CONFIG_SHOW_ACTIVITY
-   board_show_activity(priv->timestamp);
-#endif /* CONFIG_SHOW_ACTIVITY */
 }
 
 void wait_ticks(ulong ticks)
diff --git a/include/common.h b/include/common.h
index 16c885dd3ff..4b84969ad3d 100644
--- a/include/common.h
+++ b/include/common.h
@@ -351,10 +351,6 @@ static inline struct in_addr env_get_ip(char *var)
 
 #include 
 
-#ifdef CONFIG_SHOW_ACTIVITY
-void show_activity(int arg);
-#endif
-
 #else  /* __ASSEMBLY__ */
 
 #endif /* __ASSEMBLY__ */
diff --git a/net/net.c b/net/net.c
index ded86e74567..0513444eb78 100644
--- a/net/net.c
+++ b/net/net.c
@@ -561,9 +561,6 @@ restart:
 */
for (;;) {
WATCHDOG_RESET();
-#ifdef CONFIG_SHOW_ACTIVITY
-   show_activity(1);
-#endif
if (arp_timeout_check() > 0)
time_start = get_timer(0);
 
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index b06a77ebd66..dbe7c102532 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -1582,7 +1582,6 @@ CONFIG_SHARP_LM8V31
 CONFIG_SHARP_LQ035Q7DH06
 CONFIG_SHEEVA_88SV131
 CONFIG_SHEEVA_88SV331xV5
-CONFIG_SHOW_ACTIVITY
 CONFIG_SH_CMT_CLK_FREQ
 CONFIG_SH_DSP
 CONFIG_SH_ETHER_ALIGNE_SIZE
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH 00/41] common: Further reduce common.h

2019-09-30 Thread Simon Glass
(I meant to send this a few months ago but forgot about it)

This series drops the size of common.h down further, by moving things out
into existing and new header files.

It is now down to about 200 lines.


Simon Glass (41):
  common: Move legacy CPU functions to their own header
  Drop CONFIG_SHOW_ACTIVITY
  common: Drop global inclusion of status_led.h
  status_led: Tidy up the code style
  common: Move random-number functions into their own header
  common: Drop linux/crc8.h
  crc: Fix code style with crc functions
  crc32: Use the crc.h header for crc functions
  spl: bootcount: Move code out of header file
  common: Move bootcount functions to their header file
  common: Move sorting functions to their own header file
  Move strtomhz() to vsprintf.h
  common: Move env_get_ip() to net.h
  serial: usb: Correct the usbtty_...() prototypes
  common: Move serial_printf() to the serial header
  common: Move serial functions out of common.h
  common: Add a new lz4.h header file
  common: Move some time functions out of common.h
  common: Move wait_ticks functions out of common.h
  common: Move timer_get_us() function out of common.h
  common: Move get_ticks() function out of common.h
  common: Move mii_init() function out of common.h
  common: Move some CPU functions out of common.h
  common: Drop cpu_init()
  common: Move checkcpu() out of common.h
  common: Move some SMP functions out of common.h
  arm: powerpc: Tidy up code style for cache functions
  common: Move some cache and MMU functions out of common.h
  common: Drop checkicache() and checkdcache()
  common: Move ARM cache operations out of common.h
  arm: powerpc: Tidy up code style for interrupt functions
  common: Move interrupt functions into a new header
  common: Move enable/disable_interrupts out of common.h
  common: Move command functions out of common.h
  common: Drop board_show_dram()
  common: Move board_get_usable_ram_top() out of common.h
  common: Move some board functions out of common.h
  common: Move pci_init_board() out of common.h
  common: Move trap_init() out of common.h
  common: Drop get_endaddr()
  common: Move old EEPROM functions into a new header

 README|   2 +-
 api/api.c |   1 +
 arch/arc/lib/bootm.c  |   1 +
 arch/arc/lib/cache.c  |   1 +
 arch/arc/lib/cpu.c|   1 +
 arch/arc/lib/interrupts.c |   1 +
 arch/arm/cpu/arm11/cpu.c  |   4 +-
 arch/arm/cpu/arm920t/cpu.c|   4 +-
 arch/arm/cpu/arm920t/ep93xx/timer.c   |   1 +
 arch/arm/cpu/arm920t/imx/timer.c  |   1 +
 arch/arm/cpu/arm926ejs/armada100/cpu.c|   1 +
 arch/arm/cpu/arm926ejs/armada100/timer.c  |   1 +
 arch/arm/cpu/arm926ejs/cache.c|   1 +
 arch/arm/cpu/arm926ejs/cpu.c  |   4 +-
 arch/arm/cpu/arm926ejs/lpc32xx/cpu.c  |   1 +
 arch/arm/cpu/arm926ejs/lpc32xx/timer.c|   1 +
 arch/arm/cpu/arm926ejs/mx25/generic.c |   1 +
 arch/arm/cpu/arm926ejs/mx27/generic.c |   1 +
 arch/arm/cpu/arm926ejs/mx27/timer.c   |   1 +
 arch/arm/cpu/arm926ejs/mxs/spl_boot.c |   1 +
 arch/arm/cpu/arm926ejs/mxs/timer.c|   1 +
 arch/arm/cpu/arm926ejs/spear/spr_misc.c   |   1 +
 arch/arm/cpu/arm926ejs/spear/timer.c  |   1 +
 arch/arm/cpu/arm946es/cpu.c   |   4 +-
 arch/arm/cpu/armv7/arch_timer.c   |   1 +
 arch/arm/cpu/armv7/cache_v7.c |   1 +
 arch/arm/cpu/armv7/cpu.c  |   2 +
 arch/arm/cpu/armv7/exception_level.c  |   1 +
 .../cpu/armv7/iproc-common/hwinit-common.c|   1 +
 arch/arm/cpu/armv7/iproc-common/timer.c   |   1 +
 .../arm/cpu/armv7/kona-common/hwinit-common.c |   1 +
 arch/arm/cpu/armv7/ls102xa/cpu.c  |   2 +
 arch/arm/cpu/armv7/ls102xa/ls102xa_psci.c |   1 +
 arch/arm/cpu/armv7/ls102xa/timer.c|   1 +
 arch/arm/cpu/armv7/mpu_v7r.c  |   1 +
 arch/arm/cpu/armv7/s5p-common/timer.c |   1 +
 arch/arm/cpu/armv7/stv0991/timer.c|   1 +
 arch/arm/cpu/armv7/sunxi/timer.c  |   1 +
 arch/arm/cpu/armv7/vf610/generic.c|   1 +
 arch/arm/cpu/armv7/vf610/timer.c  |   1 +
 arch/arm/cpu/armv7/virt-v7.c  |   1 +
 arch/arm/cpu/armv7m/cache.c   |   1 +
 arch/arm/cpu/armv7m/cpu.c |   2 +
 arch/arm/cpu/armv7m/systick-timer.c   |   1 +
 arch/arm/cpu/armv8/cache_v8.c |   1 +
 arch/arm/cpu/armv8/cpu.c  |   2 +
 arch/arm/cpu/armv8/exception_level.c  |   1 +
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c   |   3 +
 .../armv8/fsl-layerscape/fsl_lsch2_speed.c|   1 +
 .../armv8/fsl-layerscape/fsl_lsch3_speed.c|   1 +
 arch/arm/cpu/armv8/fsl-layerscape/mp.c|   1 +
 

[U-Boot] [PATCH 01/41] common: Move legacy CPU functions to their own header

2019-09-30 Thread Simon Glass
These should be moved to driver model, but in the meantime, move them
out of the common header to help reduce its size.

Signed-off-by: Simon Glass 
---

 README |  2 +-
 arch/arm/cpu/armv8/fsl-layerscape/mp.c |  1 +
 arch/arm/mach-imx/mx6/mp.c |  1 +
 arch/arm/mach-zynqmp/mp.c  |  1 +
 arch/powerpc/cpu/mpc85xx/cpu.c |  1 +
 arch/powerpc/cpu/mpc85xx/mp.c  |  1 +
 arch/powerpc/cpu/mpc86xx/mp.c  |  1 +
 cmd/mp.c   |  1 +
 include/common.h   |  8 
 include/cpu_legacy.h   | 23 +++
 10 files changed, 31 insertions(+), 9 deletions(-)
 create mode 100644 include/cpu_legacy.h

diff --git a/README b/README
index 1389e8ff127..107e67fdda5 100644
--- a/README
+++ b/README
@@ -2983,7 +2983,7 @@ Low Level (hardware related) configuration options:
 - CONFIG_SYS_SRIOn_MEM_VIRT:
Virtual Address of SRIO port 'n' memory region
 
-- CONFIG_SYS_SRIOn_MEM_PHYS:
+- CONFIG_SYS_SRIOn_MEM_PHYxS:
Physical Address of SRIO port 'n' memory region
 
 - CONFIG_SYS_SRIOn_MEM_SIZE:
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/mp.c 
b/arch/arm/cpu/armv8/fsl-layerscape/mp.c
index 7627fd13e7d..1c878bc9ab6 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/mp.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/mp.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-imx/mx6/mp.c b/arch/arm/mach-imx/mx6/mp.c
index eda168d8671..36f1dc8f923 100644
--- a/arch/arm/mach-imx/mx6/mp.c
+++ b/arch/arm/mach-imx/mx6/mp.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-zynqmp/mp.c b/arch/arm/mach-zynqmp/mp.c
index 2a71870ae7b..691c86a4b00 100644
--- a/arch/arm/mach-zynqmp/mp.c
+++ b/arch/arm/mach-zynqmp/mp.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/powerpc/cpu/mpc85xx/cpu.c b/arch/powerpc/cpu/mpc85xx/cpu.c
index bf48836036b..bba71813bcb 100644
--- a/arch/powerpc/cpu/mpc85xx/cpu.c
+++ b/arch/powerpc/cpu/mpc85xx/cpu.c
@@ -10,6 +10,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/powerpc/cpu/mpc85xx/mp.c b/arch/powerpc/cpu/mpc85xx/mp.c
index 3882c95f92e..d4077a09202 100644
--- a/arch/powerpc/cpu/mpc85xx/mp.c
+++ b/arch/powerpc/cpu/mpc85xx/mp.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/arch/powerpc/cpu/mpc86xx/mp.c b/arch/powerpc/cpu/mpc86xx/mp.c
index ce300eac5b0..40499ef9471 100644
--- a/arch/powerpc/cpu/mpc86xx/mp.c
+++ b/arch/powerpc/cpu/mpc86xx/mp.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/cmd/mp.c b/cmd/mp.c
index 01d30c1ccb7..5d77c3a78d7 100644
--- a/cmd/mp.c
+++ b/cmd/mp.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 
 static int cpu_status_all(void)
 {
diff --git a/include/common.h b/include/common.h
index d8f302ea92f..16c885dd3ff 100644
--- a/include/common.h
+++ b/include/common.h
@@ -355,14 +355,6 @@ static inline struct in_addr env_get_ip(char *var)
 void show_activity(int arg);
 #endif
 
-/* Multicore arch functions */
-#ifdef CONFIG_MP
-int cpu_status(u32 nr);
-int cpu_reset(u32 nr);
-int cpu_disable(u32 nr);
-int cpu_release(u32 nr, int argc, char * const argv[]);
-#endif
-
 #else  /* __ASSEMBLY__ */
 
 #endif /* __ASSEMBLY__ */
diff --git a/include/cpu_legacy.h b/include/cpu_legacy.h
new file mode 100644
index 000..a99b69b9764
--- /dev/null
+++ b/include/cpu_legacy.h
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+ * Copyright 2019 Google LLC
+ */
+
+#ifndef __CPU_LEGACY_H
+#define __CPU_LEGACY_H
+
+#include 
+
+/*
+ * Multicore arch functions
+ *
+ * These should be moved to use the CPU uclass.
+ */
+int cpu_status(u32 nr);
+int cpu_reset(u32 nr);
+int cpu_disable(u32 nr);
+int cpu_release(u32 nr, int argc, char * const argv[]);
+
+#endif
-- 
2.23.0.444.g18eeb5a265-goog

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


[U-Boot] [PATCH v1 3/3] test: reset: Add tests for the managed API

2019-09-30 Thread Jean-Jacques Hiblot
The tests are basically the same as for the regular API. Except that
the reset are initialized using the managed API, and no freed manually.

Signed-off-by: Jean-Jacques Hiblot 

---

 arch/sandbox/include/asm/reset.h   |  1 +
 drivers/reset/sandbox-reset-test.c | 50 ++---
 drivers/reset/sandbox-reset.c  | 19 ++
 test/dm/reset.c| 59 ++
 4 files changed, 123 insertions(+), 6 deletions(-)

diff --git a/arch/sandbox/include/asm/reset.h b/arch/sandbox/include/asm/reset.h
index c4205eabef..a0065b96ad 100644
--- a/arch/sandbox/include/asm/reset.h
+++ b/arch/sandbox/include/asm/reset.h
@@ -11,6 +11,7 @@
 struct udevice;
 
 int sandbox_reset_query(struct udevice *dev, unsigned long id);
+int sandbox_reset_is_requested(struct udevice *dev, unsigned long id);
 
 int sandbox_reset_test_get(struct udevice *dev);
 int sandbox_reset_test_get_bulk(struct udevice *dev);
diff --git a/drivers/reset/sandbox-reset-test.c 
b/drivers/reset/sandbox-reset-test.c
index 95ce2ca117..e6e976ea11 100644
--- a/drivers/reset/sandbox-reset-test.c
+++ b/drivers/reset/sandbox-reset-test.c
@@ -12,62 +12,100 @@
 struct sandbox_reset_test {
struct reset_ctl ctl;
struct reset_ctl_bulk bulk;
+
+   struct reset_ctl *ctlp;
+   struct reset_ctl_bulk *bulkp;
 };
 
 int sandbox_reset_test_get(struct udevice *dev)
 {
struct sandbox_reset_test *sbrt = dev_get_priv(dev);
 
+   sbrt->ctlp = >ctl;
return reset_get_by_name(dev, "test", >ctl);
 }
 
+int sandbox_reset_test_get_devm(struct udevice *dev)
+{
+   struct sandbox_reset_test *sbrt = dev_get_priv(dev);
+   struct reset_ctl *r;
+
+   r = devm_reset_control_get(dev, "not-a-valid-reset-ctl");
+   if (!IS_ERR(r))
+   return -EINVAL;
+
+   r = devm_reset_control_get_optional(dev, "not-a-valid-reset-ctl");
+   if (r)
+   return -EINVAL;
+
+   sbrt->ctlp = devm_reset_control_get(dev, "test");
+   if (IS_ERR(sbrt->ctlp))
+   return PTR_ERR(sbrt->ctlp);
+
+   return 0;
+}
+
 int sandbox_reset_test_get_bulk(struct udevice *dev)
 {
struct sandbox_reset_test *sbrt = dev_get_priv(dev);
 
+   sbrt->bulkp = >bulk;
return reset_get_bulk(dev, >bulk);
 }
 
+int sandbox_reset_test_get_bulk_devm(struct udevice *dev)
+{
+   struct sandbox_reset_test *sbrt = dev_get_priv(dev);
+   struct reset_ctl_bulk *r;
+
+   r = devm_reset_bulk_get_optional(dev);
+   if (IS_ERR(r))
+   return PTR_ERR(r);
+
+   sbrt->bulkp = r;
+   return 0;
+}
+
 int sandbox_reset_test_assert(struct udevice *dev)
 {
struct sandbox_reset_test *sbrt = dev_get_priv(dev);
 
-   return reset_assert(>ctl);
+   return reset_assert(sbrt->ctlp);
 }
 
 int sandbox_reset_test_assert_bulk(struct udevice *dev)
 {
struct sandbox_reset_test *sbrt = dev_get_priv(dev);
 
-   return reset_assert_bulk(>bulk);
+   return reset_assert_bulk(sbrt->bulkp);
 }
 
 int sandbox_reset_test_deassert(struct udevice *dev)
 {
struct sandbox_reset_test *sbrt = dev_get_priv(dev);
 
-   return reset_deassert(>ctl);
+   return reset_deassert(sbrt->ctlp);
 }
 
 int sandbox_reset_test_deassert_bulk(struct udevice *dev)
 {
struct sandbox_reset_test *sbrt = dev_get_priv(dev);
 
-   return reset_deassert_bulk(>bulk);
+   return reset_deassert_bulk(sbrt->bulkp);
 }
 
 int sandbox_reset_test_free(struct udevice *dev)
 {
struct sandbox_reset_test *sbrt = dev_get_priv(dev);
 
-   return reset_free(>ctl);
+   return reset_free(sbrt->ctlp);
 }
 
 int sandbox_reset_test_release_bulk(struct udevice *dev)
 {
struct sandbox_reset_test *sbrt = dev_get_priv(dev);
 
-   return reset_release_bulk(>bulk);
+   return reset_release_bulk(sbrt->bulkp);
 }
 
 static const struct udevice_id sandbox_reset_test_ids[] = {
diff --git a/drivers/reset/sandbox-reset.c b/drivers/reset/sandbox-reset.c
index 40f2654d8e..2b5ae88187 100644
--- a/drivers/reset/sandbox-reset.c
+++ b/drivers/reset/sandbox-reset.c
@@ -13,6 +13,7 @@
 
 struct sandbox_reset_signal {
bool asserted;
+   bool requested;
 };
 
 struct sandbox_reset {
@@ -21,18 +22,24 @@ struct sandbox_reset {
 
 static int sandbox_reset_request(struct reset_ctl *reset_ctl)
 {
+   struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
+
debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
 
if (reset_ctl->id >= SANDBOX_RESET_SIGNALS)
return -EINVAL;
 
+   sbr->signals[reset_ctl->id].requested = true;
return 0;
 }
 
 static int sandbox_reset_free(struct reset_ctl *reset_ctl)
 {
+   struct sandbox_reset *sbr = dev_get_priv(reset_ctl->dev);
+
debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
 
+   sbr->signals[reset_ctl->id].requested = false;
return 0;
 }
 
@@ -105,3 +112,15 @@ int sandbox_reset_query(struct udevice *dev, unsigned long 
id)
 
   

[U-Boot] [PATCH v1 1/3] drivers: reset: Handle gracefully NULL pointers

2019-09-30 Thread Jean-Jacques Hiblot
Prepare the way for a managed reset API by handling NULL pointers without
crashing nor failing.

Signed-off-by: Jean-Jacques Hiblot 
---

 drivers/reset/reset-uclass.c | 30 +-
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index ee1a423ffb..1cfcc8b367 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -9,9 +9,12 @@
 #include 
 #include 
 
-static inline struct reset_ops *reset_dev_ops(struct udevice *dev)
+struct reset_ops nop_reset_ops = {
+};
+
+static inline struct reset_ops *reset_dev_ops(struct reset_ctl *r)
 {
-   return (struct reset_ops *)dev->driver->ops;
+   return r ? (struct reset_ops *)r->dev->driver->ops : _reset_ops;
 }
 
 static int reset_of_xlate_default(struct reset_ctl *reset_ctl,
@@ -50,9 +53,10 @@ static int reset_get_by_index_tail(int ret, ofnode node,
debug("%s %d\n", ofnode_get_name(args->node), args->args[0]);
return ret;
}
-   ops = reset_dev_ops(dev_reset);
 
reset_ctl->dev = dev_reset;
+   ops = reset_dev_ops(reset_ctl);
+
if (ops->of_xlate)
ret = ops->of_xlate(reset_ctl, args);
else
@@ -151,29 +155,29 @@ int reset_get_by_name(struct udevice *dev, const char 
*name,
 
 int reset_request(struct reset_ctl *reset_ctl)
 {
-   struct reset_ops *ops = reset_dev_ops(reset_ctl->dev);
+   struct reset_ops *ops = reset_dev_ops(reset_ctl);
 
debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
 
-   return ops->request(reset_ctl);
+   return ops->request ? ops->request(reset_ctl) : 0;
 }
 
 int reset_free(struct reset_ctl *reset_ctl)
 {
-   struct reset_ops *ops = reset_dev_ops(reset_ctl->dev);
+   struct reset_ops *ops = reset_dev_ops(reset_ctl);
 
debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
 
-   return ops->free(reset_ctl);
+   return ops->free ? ops->free(reset_ctl) : 0;
 }
 
 int reset_assert(struct reset_ctl *reset_ctl)
 {
-   struct reset_ops *ops = reset_dev_ops(reset_ctl->dev);
+   struct reset_ops *ops = reset_dev_ops(reset_ctl);
 
debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
 
-   return ops->rst_assert(reset_ctl);
+   return ops->rst_assert ? ops->rst_assert(reset_ctl) : 0;
 }
 
 int reset_assert_bulk(struct reset_ctl_bulk *bulk)
@@ -191,11 +195,11 @@ int reset_assert_bulk(struct reset_ctl_bulk *bulk)
 
 int reset_deassert(struct reset_ctl *reset_ctl)
 {
-   struct reset_ops *ops = reset_dev_ops(reset_ctl->dev);
+   struct reset_ops *ops = reset_dev_ops(reset_ctl);
 
debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
 
-   return ops->rst_deassert(reset_ctl);
+   return ops->rst_deassert ? ops->rst_deassert(reset_ctl) : 0;
 }
 
 int reset_deassert_bulk(struct reset_ctl_bulk *bulk)
@@ -213,11 +217,11 @@ int reset_deassert_bulk(struct reset_ctl_bulk *bulk)
 
 int reset_status(struct reset_ctl *reset_ctl)
 {
-   struct reset_ops *ops = reset_dev_ops(reset_ctl->dev);
+   struct reset_ops *ops = reset_dev_ops(reset_ctl);
 
debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
 
-   return ops->rst_status(reset_ctl);
+   return ops->rst_status ? ops->rst_status(reset_ctl) : 0;
 }
 
 int reset_release_all(struct reset_ctl *reset_ctl, int count)
-- 
2.17.1

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


[U-Boot] [PATCH v1 2/3] drivers: reset: Add a managed API to get reset controllers from the DT

2019-09-30 Thread Jean-Jacques Hiblot
Add managed functions to get a reset_ctl from the device-tree, based on a
name or an index.
Also add a managed functions to get a reset_ctl_bulk (array of reset_ctl)
from the device-tree.

When the device is unbound, the reset controllers are automatically
released and the data structure is freed.

Signed-off-by: Jean-Jacques Hiblot 
---

 drivers/reset/reset-uclass.c | 116 +-
 include/reset.h  | 135 ++-
 2 files changed, 247 insertions(+), 4 deletions(-)

diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index 1cfcc8b367..ae8395a5e9 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct reset_ops nop_reset_ops = {
 };
@@ -101,13 +102,14 @@ int reset_get_by_index_nodev(ofnode node, int index,
   index > 0, reset_ctl);
 }
 
-int reset_get_bulk(struct udevice *dev, struct reset_ctl_bulk *bulk)
+static int __reset_get_bulk(struct udevice *dev, ofnode node,
+   struct reset_ctl_bulk *bulk)
 {
int i, ret, err, count;

bulk->count = 0;
 
-   count = dev_count_phandle_with_args(dev, "resets", "#reset-cells");
+   count = ofnode_count_phandle_with_args(node, "resets", "#reset-cells");
if (count < 1)
return count;
 
@@ -117,7 +119,7 @@ int reset_get_bulk(struct udevice *dev, struct 
reset_ctl_bulk *bulk)
return -ENOMEM;
 
for (i = 0; i < count; i++) {
-   ret = reset_get_by_index(dev, i, >resets[i]);
+   ret = reset_get_by_index_nodev(node, i, >resets[i]);
if (ret < 0)
goto bulk_get_err;
 
@@ -135,6 +137,11 @@ bulk_get_err:
return ret;
 }
 
+int reset_get_bulk(struct udevice *dev, struct reset_ctl_bulk *bulk)
+{
+   return __reset_get_bulk(dev, dev_ofnode(dev), bulk);
+}
+
 int reset_get_by_name(struct udevice *dev, const char *name,
 struct reset_ctl *reset_ctl)
 {
@@ -247,6 +254,109 @@ int reset_release_all(struct reset_ctl *reset_ctl, int 
count)
return 0;
 }
 
+static void devm_reset_release(struct udevice *dev, void *res)
+{
+   reset_free(res);
+}
+
+struct reset_ctl *devm_reset_control_get_by_index(struct udevice *dev,
+ int index)
+{
+   int rc;
+   struct reset_ctl *reset_ctl;
+
+   reset_ctl = devres_alloc(devm_reset_release, sizeof(struct reset_ctl),
+__GFP_ZERO);
+   if (unlikely(!reset_ctl))
+   return ERR_PTR(-ENOMEM);
+
+   rc = reset_get_by_index(dev, index, reset_ctl);
+   if (rc)
+   return ERR_PTR(rc);
+
+   devres_add(dev, reset_ctl);
+   return reset_ctl;
+}
+
+struct reset_ctl *devm_reset_control_get(struct udevice *dev, const char *id)
+{
+   int rc;
+   struct reset_ctl *reset_ctl;
+
+   reset_ctl = devres_alloc(devm_reset_release, sizeof(struct reset_ctl),
+__GFP_ZERO);
+   if (unlikely(!reset_ctl))
+   return ERR_PTR(-ENOMEM);
+
+   rc = reset_get_by_name(dev, id, reset_ctl);
+   if (rc)
+   return ERR_PTR(rc);
+
+   devres_add(dev, reset_ctl);
+   return reset_ctl;
+}
+
+struct reset_ctl *devm_reset_control_get_optional(struct udevice *dev,
+ const char *id)
+{
+   struct reset_ctl *r = devm_reset_control_get(dev, id);
+
+   if (IS_ERR(r))
+   return NULL;
+
+   return r;
+}
+
+static void devm_reset_bulk_release(struct udevice *dev, void *res)
+{
+   struct reset_ctl_bulk *bulk = res;
+
+   reset_release_all(bulk->resets, bulk->count);
+}
+
+struct reset_ctl_bulk *devm_reset_bulk_get_by_node(struct udevice *dev,
+  ofnode node)
+{
+   int rc;
+   struct reset_ctl_bulk *bulk;
+
+   bulk = devres_alloc(devm_reset_bulk_release,
+   sizeof(struct reset_ctl_bulk),
+   __GFP_ZERO);
+   if (unlikely(!bulk))
+   return ERR_PTR(-ENOMEM);
+
+   rc = __reset_get_bulk(dev, node, bulk);
+   if (rc)
+   return ERR_PTR(rc);
+
+   devres_add(dev, bulk);
+   return bulk;
+}
+
+struct reset_ctl_bulk *devm_reset_bulk_get_optional_by_node(struct udevice 
*dev,
+   ofnode node)
+{
+   struct reset_ctl_bulk *bulk;
+
+   bulk = devm_reset_bulk_get_by_node(dev, node);
+
+   if (IS_ERR(bulk))
+   return NULL;
+
+   return bulk;
+}
+
+struct reset_ctl_bulk *devm_reset_bulk_get(struct udevice *dev)
+{
+   return devm_reset_bulk_get_by_node(dev, dev_ofnode(dev));
+}
+
+struct reset_ctl_bulk *devm_reset_bulk_get_optional(struct udevice *dev)
+{
+   

[U-Boot] [PATCH v1 0/3] reset: Add a managed API

2019-09-30 Thread Jean-Jacques Hiblot

This is the 3rd of a few series, the goal of which is to facilitate
porting drivers from the linux kernel. Most of the series will be about
adding managed API to existing infrastructure (GPIO, reset, phy,...)

This particular series is about reset controllers. It adds a managed API,
close to that of linux. The main difference is that bulk and reset_ctl
are handled with different functions.


Jean-Jacques Hiblot (3):
  drivers: reset: Handle gracefully NULL pointers
  drivers: reset: Add a managed API to get reset controllers from the DT
  test: reset: Add tests for the managed API

 arch/sandbox/include/asm/reset.h   |   1 +
 drivers/reset/reset-uclass.c   | 146 +
 drivers/reset/sandbox-reset-test.c |  50 --
 drivers/reset/sandbox-reset.c  |  19 
 include/reset.h| 135 +-
 test/dm/reset.c|  59 
 6 files changed, 387 insertions(+), 23 deletions(-)

-- 
2.17.1

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


[U-Boot] [PATCH v2 08/16] dfu: add partition support for MTD backend

2019-09-30 Thread Patrick Delaunay
Add the support of MTD partition for the MTD backend.

The expected dfu_alt_info for one alternate on the mtd device :
 part 
 partubi 

"partubi" also erase up to the end of the partition after write operation.

For example: dfu_alt_info = "spl part 1;u-boot part 2; UBI partubi 3"

U-Boot> dfu 0 mtd nand0

Acked-by: Lukasz Majewski 
Signed-off-by: Patrick Delaunay 
---

Changes in v2:
- Update dfu documentation for MTD

 doc/README.dfu| 21 
 drivers/dfu/dfu_mtd.c | 78 ++-
 include/dfu.h |  2 ++
 3 files changed, 100 insertions(+), 1 deletion(-)

diff --git a/doc/README.dfu b/doc/README.dfu
index 423d4fa28a..34bb25a2fc 100644
--- a/doc/README.dfu
+++ b/doc/README.dfu
@@ -111,6 +111,10 @@ Commands:
   (nand0, nor0, spi-nand0,...)
 each element in "dfu_alt_info" =
rawraw access to mtd device
+   partraw acces to partition
+   partubiraw acces to ubi partition
+
+  with  is the MTD partition index
 
and  are absent:
 the dfu command to use multiple devices
@@ -208,3 +212,20 @@ Usage:
  intf=0, alt=1, name="u-boot", serial="00270038511934383330"
   Found DFU: [0483:5720] ver=, devnum=96, cfg=1,\
  intf=0, alt=0, name="spl", serial="00270038511934383330"
+
+  Same example with MTD backend
+
+   U-Boot> env set dfu_alt_info \
+  "mtd nor0=spl part 1;u-boot part 2;u-boot-env part 3&"\
+  "mtd nand0=UBI partubi 1"
+
+  U-Boot> dfu 0 list
+  using id 'nor0,0'
+  using id 'nor0,1'
+  using id 'nor0,2'
+  using id 'nand0,0'
+  DFU alt settings list:
+  dev: MTD alt: 0 name: spl layout: RAW_ADDR
+  dev: MTD alt: 1 name: u-boot layout: RAW_ADDR
+  dev: MTD alt: 2 name: u-boot-env layout: RAW_ADDR
+  dev: MTD alt: 3 name: UBI layout: RAW_ADDR
diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c
index 1168a6e278..223b0fe977 100644
--- a/drivers/dfu/dfu_mtd.c
+++ b/drivers/dfu/dfu_mtd.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static bool mtd_is_aligned_with_block_size(struct mtd_info *mtd, u64 size)
 {
@@ -181,11 +182,49 @@ static int dfu_write_medium_mtd(struct dfu_entity *dfu,
 
 static int dfu_flush_medium_mtd(struct dfu_entity *dfu)
 {
+   struct mtd_info *mtd = dfu->data.mtd.info;
+   int ret;
+
+   /* in case of ubi partition, erase rest of the partition */
+   if (dfu->data.nand.ubi) {
+   struct erase_info erase_op = {};
+
+   erase_op.mtd = dfu->data.mtd.info;
+   erase_op.addr = round_up(dfu->data.mtd.start + dfu->offset +
+dfu->bad_skip, mtd->erasesize);
+   erase_op.len = dfu->data.mtd.start + dfu->data.mtd.size -
+  erase_op.addr;
+   erase_op.scrub = 0;
+
+   while (erase_op.len) {
+   ret = mtd_erase(mtd, _op);
+   /* Abort if its not a bad block error */
+   if (ret != -EIO)
+   break;
+
+   printf("Skipping bad block at 0x%08llx\n",
+  erase_op.fail_addr);
+
+   /* Skip bad block and continue behind it */
+   erase_op.addr = erase_op.fail_addr + mtd->erasesize;
+   erase_op.len = dfu->data.mtd.start +
+  dfu->data.mtd.size -
+  erase_op.addr;
+   }
+   }
return 0;
 }
 
 static unsigned int dfu_polltimeout_mtd(struct dfu_entity *dfu)
 {
+   /*
+* Currently, Poll Timeout != 0 is only needed on nand
+* ubi partition, as sectors which are not used need
+* to be erased
+*/
+   if (dfu->data.nand.ubi)
+   return DFU_MANIFEST_POLL_TIMEOUT;
+
return DFU_DEFAULT_POLL_TIMEOUT;
 }
 
@@ -194,6 +233,7 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char 
*devstr, char *s)
char *st;
struct mtd_info *mtd;
bool has_pages;
+   int ret, part;
 
mtd = get_mtd_device_nm(devstr);
if (IS_ERR_OR_NULL(mtd))
@@ -212,11 +252,47 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char 
*devstr, char *s)
dfu->data.mtd.start = simple_strtoul(s, , 16);
s++;
dfu->data.mtd.size = simple_strtoul(s, , 16);
+   } else if ((!strcmp(st, "part")) || (!strcmp(st, "partubi"))) {
+   char mtd_id[32];
+   struct mtd_device *mtd_dev;
+   u8 part_num;
+   struct part_info *pi;
+
+   dfu->layout = DFU_RAW_ADDR;
+
+   part = simple_strtoul(s, , 10);
+
+   sprintf(mtd_id, "%s,%d", devstr, part - 1);
+   printf("using id '%s'\n", mtd_id);
+
+   mtdparts_init();
+
+   ret = find_dev_and_part(mtd_id, _dev, _num, );
+   if (ret != 0) {
+   

[U-Boot] [PATCH v2 11/16] stm32mp1: activate DFU support and command MTD

2019-09-30 Thread Patrick Delaunay
Add support of DFU for MMC, MTD, RAM and MTD command.

Signed-off-by: Patrick Delaunay 
---

Changes in v2: None

 configs/stm32mp15_basic_defconfig   | 4 
 configs/stm32mp15_optee_defconfig   | 4 
 configs/stm32mp15_trusted_defconfig | 4 
 3 files changed, 12 insertions(+)

diff --git a/configs/stm32mp15_basic_defconfig 
b/configs/stm32mp15_basic_defconfig
index f6c68feb6f..cd4fc20ca5 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -34,6 +34,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_SPI=y
@@ -62,6 +63,9 @@ CONFIG_ENV_UBI_PART="UBI"
 CONFIG_ENV_UBI_VOLUME="uboot_config"
 CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
 CONFIG_STM32_ADC=y
+CONFIG_DFU_MMC=y
+CONFIG_DFU_RAM=y
+CONFIG_DFU_MTD=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC000
 CONFIG_FASTBOOT_BUF_SIZE=0x0200
diff --git a/configs/stm32mp15_optee_defconfig 
b/configs/stm32mp15_optee_defconfig
index 177cbc7d5f..8d3d2e8508 100644
--- a/configs/stm32mp15_optee_defconfig
+++ b/configs/stm32mp15_optee_defconfig
@@ -23,6 +23,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_SPI=y
@@ -49,6 +50,9 @@ CONFIG_ENV_UBI_PART="UBI"
 CONFIG_ENV_UBI_VOLUME="uboot_config"
 CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
 CONFIG_STM32_ADC=y
+CONFIG_DFU_MMC=y
+CONFIG_DFU_RAM=y
+CONFIG_DFU_MTD=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC000
 CONFIG_FASTBOOT_BUF_SIZE=0x0200
diff --git a/configs/stm32mp15_trusted_defconfig 
b/configs/stm32mp15_trusted_defconfig
index 71ad1157ec..8da8c4e22a 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -22,6 +22,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_SPI=y
@@ -48,6 +49,9 @@ CONFIG_ENV_UBI_PART="UBI"
 CONFIG_ENV_UBI_VOLUME="uboot_config"
 CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
 CONFIG_STM32_ADC=y
+CONFIG_DFU_MMC=y
+CONFIG_DFU_RAM=y
+CONFIG_DFU_MTD=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC000
 CONFIG_FASTBOOT_BUF_SIZE=0x0200
-- 
2.17.1

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


[U-Boot] [PATCH v2 07/16] dfu: add backend for MTD device

2019-09-30 Thread Patrick Delaunay
Add DFU backend for MTD device: allow to read
and write on all MTD device (NAND, SPI-NOR,
SPI-NAND,...)

For example :
> set dfu_alt_info "nand_raw raw 0x0 0x10"
> dfu 0 mtd nand0

This MTD backend provides the same level than dfu nand
backend for NAND and dfu sf backend for SPI-NOR;
So it can replace booth of them but it also
add support of spi-nand.

> set dfu_alt_info "nand_raw raw 0x0 0x10"
> dfu 0 mtd spi-nand0

The backend code is based on the "mtd" command
introduced by commit 5db66b3aee6f ("cmd: mtd:
add 'mtd' command")

Signed-off-by: Patrick Delaunay 
---

Changes in v2:
- Update commit message
- Update dfu documentation for MTD

 doc/README.dfu|  10 ++
 drivers/dfu/Kconfig   |   6 ++
 drivers/dfu/Makefile  |   1 +
 drivers/dfu/dfu.c |   5 +-
 drivers/dfu/dfu_mtd.c | 230 ++
 include/dfu.h |  21 
 6 files changed, 272 insertions(+), 1 deletion(-)
 create mode 100644 drivers/dfu/dfu_mtd.c

diff --git a/doc/README.dfu b/doc/README.dfu
index 0adff1603f..423d4fa28a 100644
--- a/doc/README.dfu
+++ b/doc/README.dfu
@@ -21,6 +21,7 @@ Overview:
   - NAND
   - RAM
   - SF (serial flash)
+  - MTD (all MTD device: NAND, SPI-NOR, SPI-NAND,...)
 
   These DFU backends are also used by
   - the dfutftp (see README.dfutftp)
@@ -30,6 +31,7 @@ Configuration Options:
   CONFIG_DFU
   CONFIG_DFU_OVER_USB
   CONFIG_DFU_MMC
+  CONFIG_DFU_MTD
   CONFIG_DFU_NAND
   CONFIG_DFU_RAM
   CONFIG_DFU_SF
@@ -103,6 +105,13 @@ Commands:
 
   with  is the MTD partition index
 
+  "mtd" (all MTD device: NAND, SPI-NOR, SPI-NAND,...)
+cmd: dfu 0 mtd 
+  with  the mtd identifier as defined in mtd command
+  (nand0, nor0, spi-nand0,...)
+each element in "dfu_alt_info" =
+   rawraw access to mtd device
+
and  are absent:
 the dfu command to use multiple devices
 cmd: dfu 0 list
@@ -113,6 +122,7 @@ Commands:
nand =;;
ram =;;
sf =;;
+   mtd =;;
 
 
 Host tools:
diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig
index 4692736c9d..ee664a331b 100644
--- a/drivers/dfu/Kconfig
+++ b/drivers/dfu/Kconfig
@@ -46,5 +46,11 @@ config DFU_SF
  This option enables using DFU to read and write to SPI flash based
  storage.
 
+config DFU_MTD
+   bool "MTD back end for DFU"
+   depends on MTD
+   help
+ This option enables using DFU to read and write to on any MTD device.
+
 endif
 endmenu
diff --git a/drivers/dfu/Makefile b/drivers/dfu/Makefile
index 4164f342ac..ebb119f398 100644
--- a/drivers/dfu/Makefile
+++ b/drivers/dfu/Makefile
@@ -5,6 +5,7 @@
 
 obj-$(CONFIG_$(SPL_)DFU) += dfu.o
 obj-$(CONFIG_$(SPL_)DFU_MMC) += dfu_mmc.o
+obj-$(CONFIG_$(SPL_)DFU_MTD) += dfu_mtd.o
 obj-$(CONFIG_$(SPL_)DFU_NAND) += dfu_nand.o
 obj-$(CONFIG_$(SPL_)DFU_RAM) += dfu_ram.o
 obj-$(CONFIG_$(SPL_)DFU_SF) += dfu_sf.o
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 50919fcae9..4f4a07b790 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -462,6 +462,9 @@ static int dfu_fill_entity(struct dfu_entity *dfu, char *s, 
int alt,
if (strcmp(interface, "mmc") == 0) {
if (dfu_fill_entity_mmc(dfu, devstr, s))
return -1;
+   } else if (strcmp(interface, "mtd") == 0) {
+   if (dfu_fill_entity_mtd(dfu, devstr, s))
+   return -1;
} else if (strcmp(interface, "nand") == 0) {
if (dfu_fill_entity_nand(dfu, devstr, s))
return -1;
@@ -566,7 +569,7 @@ int dfu_config_entities(char *env, char *interface, char 
*devstr)
 const char *dfu_get_dev_type(enum dfu_device_type t)
 {
const char *const dev_t[] = {NULL, "eMMC", "OneNAND", "NAND", "RAM",
-"SF"};
+"SF", "MTD"};
return dev_t[t];
 }
 
diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c
new file mode 100644
index 00..1168a6e278
--- /dev/null
+++ b/drivers/dfu/dfu_mtd.c
@@ -0,0 +1,230 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * dfu_mtd.c -- DFU for MTD device.
+ *
+ * Copyright (C) 2019,STMicroelectronics - All Rights Reserved
+ *
+ * Based on dfu_nand.c
+ */
+
+#include 
+#include 
+#include 
+
+static bool mtd_is_aligned_with_block_size(struct mtd_info *mtd, u64 size)
+{
+   return !do_div(size, mtd->erasesize);
+}
+
+static int mtd_block_op(enum dfu_op op, struct dfu_entity *dfu,
+   u64 offset, void *buf, long *len)
+{
+   u64 off, lim, remaining;
+   struct mtd_info *mtd = dfu->data.mtd.info;
+   struct mtd_oob_ops io_op = {};
+   int ret = 0;
+   bool has_pages = mtd->type == MTD_NANDFLASH ||
+mtd->type == MTD_MLCNANDFLASH;
+
+   /* if buf == NULL return total size of the area */
+   if (!buf) {
+   *len = dfu->data.mtd.size;
+   return 0;
+   }
+
+   off = dfu->data.mtd.start + offset + 

[U-Boot] [PATCH v2 15/16] stm32mp1: add support for virtual partition read

2019-09-30 Thread Patrick Delaunay
Add read for OTP and PMIC NVM with alternates
on virtual DFU device.

Serie-cc: Boris Brezillon 
Signed-off-by: Patrick Delaunay 
---

Changes in v2:
- Update after Lukasz Majewski comments

 board/st/stm32mp1/stm32mp1.c| 83 +
 configs/stm32mp15_basic_defconfig   |  1 +
 configs/stm32mp15_optee_defconfig   |  1 +
 configs/stm32mp15_trusted_defconfig |  1 +
 4 files changed, 86 insertions(+)

diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index e4bdf05cd7..6045850c05 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -975,9 +975,92 @@ void set_dfu_alt_info(char *interface, char *devstr)
if (!IS_ERR_OR_NULL(mtd))
board_get_alt_info("spi-nand0", buf);
 
+#ifdef CONFIG_DFU_VIRT
+   strncat(buf, " 0=OTP", DFU_ALT_BUF_LEN);
+
+   if (IS_ENABLED(CONFIG_PMIC_STPMIC1))
+   strncat(buf, " 1=PMIC", DFU_ALT_BUF_LEN);
+#endif
+
env_set("dfu_alt_info", buf);
puts("DFU alt info setting: done\n");
 }
+
+#if CONFIG_IS_ENABLED(DFU_VIRT)
+#include 
+#include 
+
+int dfu_otp_read(u64 offset, u8 *buffer, long *size)
+{
+   struct udevice *dev;
+   int ret;
+
+   ret = uclass_get_device_by_driver(UCLASS_MISC,
+ DM_GET_DRIVER(stm32mp_bsec),
+ );
+   if (ret)
+   return ret;
+
+   ret = misc_read(dev, offset + STM32_BSEC_OTP_OFFSET, buffer, *size);
+   if (ret >= 0) {
+   *size = ret;
+   ret = 0;
+   }
+
+   return 0;
+}
+
+int dfu_pmic_read(u64 offset, u8 *buffer, long *size)
+{
+   int ret;
+#ifdef CONFIG_PMIC_STPMIC1
+   struct udevice *dev;
+
+   ret = uclass_get_device_by_driver(UCLASS_MISC,
+ DM_GET_DRIVER(stpmic1_nvm),
+ );
+   if (ret)
+   return ret;
+
+   ret = misc_read(dev, 0xF8 + offset, buffer, *size);
+   if (ret >= 0) {
+   *size = ret;
+   ret = 0;
+   }
+   if (ret == -EACCES) {
+   *size = 0;
+   ret = 0;
+   }
+#else
+   pr_err("PMIC update not supported");
+   ret = -EOPNOTSUPP;
+#endif
+
+   return ret;
+}
+
+int dfu_read_medium_virt(struct dfu_entity *dfu, u64 offset,
+void *buf, long *len)
+{
+   switch (dfu->data.virt.dev_num) {
+   case 0x0:
+   return dfu_otp_read(offset, buf, len);
+   case 0x1:
+   return dfu_pmic_read(offset, buf, len);
+   }
+   *len = 0;
+   return 0;
+}
+
+int __weak dfu_get_medium_size_virt(struct dfu_entity *dfu, u64 *size)
+{
+   *size = SZ_1K;
+
+   return 0;
+}
+
+#endif
+
 #endif
 
 static void board_copro_image_process(ulong fw_image, size_t fw_size)
diff --git a/configs/stm32mp15_basic_defconfig 
b/configs/stm32mp15_basic_defconfig
index 699e687891..29e697ee67 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -66,6 +66,7 @@ CONFIG_STM32_ADC=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DFU_MTD=y
+CONFIG_DFU_VIRT=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC000
 CONFIG_FASTBOOT_BUF_SIZE=0x0200
diff --git a/configs/stm32mp15_optee_defconfig 
b/configs/stm32mp15_optee_defconfig
index 387de0ad35..3b8a90de2d 100644
--- a/configs/stm32mp15_optee_defconfig
+++ b/configs/stm32mp15_optee_defconfig
@@ -53,6 +53,7 @@ CONFIG_STM32_ADC=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DFU_MTD=y
+CONFIG_DFU_VIRT=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC000
 CONFIG_FASTBOOT_BUF_SIZE=0x0200
diff --git a/configs/stm32mp15_trusted_defconfig 
b/configs/stm32mp15_trusted_defconfig
index 29c23c634d..bcbd8a5c4e 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -52,6 +52,7 @@ CONFIG_STM32_ADC=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_DFU_MTD=y
+CONFIG_DFU_VIRT=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC000
 CONFIG_FASTBOOT_BUF_SIZE=0x0200
-- 
2.17.1

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


[U-Boot] [PATCH v2 10/16] dfu: add callback for flush and initiated operation

2019-09-30 Thread Patrick Delaunay
Add weak callback to allow board specific behavior
- flush
- initiated

This patch prepare usage of DFU back end for communication with
STM32CubeProgrammer on stm32mp1 platform with stm32prog command.

Signed-off-by: Patrick Delaunay 
---

Changes in v2:
- Update dfu documentation for callbacks
- Update callbacks comment after Lukasz review

 doc/README.dfu|  8 
 drivers/dfu/dfu.c | 19 +++
 include/dfu.h | 22 ++
 3 files changed, 49 insertions(+)

diff --git a/doc/README.dfu b/doc/README.dfu
index 7b293fc08d..f3ac9a5375 100644
--- a/doc/README.dfu
+++ b/doc/README.dfu
@@ -142,6 +142,14 @@ Commands:
mtd =;;
virt =;;
 
+Callbacks:
+  The weak callback functions can be implemented to manage specific behavior
+  - dfu_initiated_callback  : called when the DFU transaction is started,
+  used to initiase the device
+  - dfu_flush_callback  : called at the end of the DFU write after DFU
+  manifestation, used to manage the device when
+  DFU transaction is closed
+
 Host tools:
   When U-Boot runs the dfu stack, the DFU host tools can be used
   to send/receive firmwares on each configurated alternate.
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 2697235c24..38aecd3a05 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -22,6 +22,22 @@ static int dfu_alt_num;
 static int alt_num_cnt;
 static struct hash_algo *dfu_hash_algo;
 
+/*
+ * The purpose of the dfu_flush_callback() function is to
+ * provide callback for dfu user
+ */
+__weak void dfu_flush_callback(struct dfu_entity *dfu)
+{
+}
+
+/*
+ * The purpose of the dfu_initiated_callback() function is to
+ * provide callback for dfu user
+ */
+__weak void dfu_initiated_callback(struct dfu_entity *dfu)
+{
+}
+
 /*
  * The purpose of the dfu_usb_get_reset() function is to
  * provide information if after USB_DETACH request
@@ -263,6 +279,7 @@ int dfu_transaction_initiate(struct dfu_entity *dfu, bool 
read)
}
 
dfu->inited = 1;
+   dfu_initiated_callback(dfu);
 
return 0;
 }
@@ -282,6 +299,8 @@ int dfu_flush(struct dfu_entity *dfu, void *buf, int size, 
int blk_seq_num)
printf("\nDFU complete %s: 0x%08x\n", dfu_hash_algo->name,
   dfu->crc);
 
+   dfu_flush_callback(dfu);
+
dfu_transaction_cleanup(dfu);
 
return ret;
diff --git a/include/dfu.h b/include/dfu.h
index 4de7d35914..564966333f 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -183,6 +183,28 @@ int dfu_read(struct dfu_entity *de, void *buf, int size, 
int blk_seq_num);
 int dfu_write(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
 int dfu_flush(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
 
+/**
+ * dfu_initiated_callback - weak callback called on DFU transaction start
+ *
+ * It is a callback function called by DFU stack when a DFU transaction is
+ * initiated. This function allows to manage some board specific behavior on
+ * DFU targets.
+ *
+ * @param dfu - pointer to the dfu_entity, which should be initialized
+ *
+ */
+void dfu_initiated_callback(struct dfu_entity *dfu);
+/**
+ * dfu_flush_callback - weak callback called at the end of the DFU write
+ *
+ * It is a callback function called by DFU stack after DFU manifestation.
+ * This function allows to manage some board specific behavior on DFU targets
+ *
+ * @param dfu - pointer to the dfu_entity, which should be flushed
+ *
+ */
+void dfu_flush_callback(struct dfu_entity *dfu);
+
 /*
  * dfu_defer_flush - pointer to store dfu_entity for deferred flashing.
  *  It should be NULL when not used.
-- 
2.17.1

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


[U-Boot] [PATCH v2 06/16] dfu: allow read with no data without error for EOF indication

2019-09-30 Thread Patrick Delaunay
This patch allows the DFU backend to indicate that that it can't
provide no more data to fill the DFU buffer, by setting b_left =0
without error, even if the size of received data is lower of the
expected total size indicated by get_medium_size.

For USB DFU stack point of view, it is acceptable:
the read length < requested size in DFU_UPLOAD and the
transaction is stopped.

That avoid infinite loop issue in dfu_read_buffer_fill because the
size for the DFU read is limited by get_medium_size = r_left
and the DFU stack expects that read is allowed up to this size.

This issue never occurs for current flash device (where chunk are
always completely read, and b_left will be never 0) but it is useful for
virtual partition when the backend only know the max size of this
alternate, the real size of the data are only known in the read
treatment.

PS: for file access on mmc, EOF is never reached as
dfu_get_medium_size_mmc returns the exact size of the file.

Signed-off-by: Patrick Delaunay 
---

Changes in v2:
- Update commit message

 drivers/dfu/dfu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 8bd5216017..50919fcae9 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -396,6 +396,8 @@ static int dfu_read_buffer_fill(struct dfu_entity *dfu, 
void *buf, int size)
debug("%s: Read error!\n", __func__);
return ret;
}
+   if (dfu->b_left == 0)
+   break;
dfu->offset += dfu->b_left;
dfu->r_left -= dfu->b_left;
 
-- 
2.17.1

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


[U-Boot] [PATCH v2 12/16] stm32mp1: activate SET_DFU_ALT_INFO

2019-09-30 Thread Patrick Delaunay
Generate automatically dfu_alt_info for the supported device.
The simple command "dfu 0" allows to start the dfu stack on usb 0
for the supported devices:
- dfu mtd for nand0
- dfu mtd for nor0
- dfu mmc for SDCard
- dfu mmc for eMMC
- dfu ram for images in DDR

The DUF alternate use the "part", "partubi" and "mmcpart" options
to select the correct MTD or GPT partition or the eMMC hw boot partition.

Signed-off-by: Patrick Delaunay 
---

Changes in v2: None

 board/st/stm32mp1/README | 111 +++
 board/st/stm32mp1/stm32mp1.c |  51 
 include/configs/stm32mp1.h   |  32 ++
 3 files changed, 194 insertions(+)

diff --git a/board/st/stm32mp1/README b/board/st/stm32mp1/README
index c807e0842e..f2069bcefa 100644
--- a/board/st/stm32mp1/README
+++ b/board/st/stm32mp1/README
@@ -390,3 +390,114 @@ B/ Automatically by using FIT feature and generic DISTRO 
bootcmd
 the correct configuration
=> stm32mp157c-ev1-m4
=> stm32mp157c-dk2-m4
+
+11. DFU support
+===
+
+The DFU is supported on ST board.
+The env variable dfu_alt_info is automatically build, and all
+the memory present on the ST boards are exported.
+
+The mode is started by
+
+STM32MP> dfu 0
+
+On EV1 board:
+
+STM32MP> dfu 0 list
+
+DFU alt settings list:
+dev: RAM alt: 0 name: uImage layout: RAM_ADDR
+dev: RAM alt: 1 name: devicetree.dtb layout: RAM_ADDR
+dev: RAM alt: 2 name: uramdisk.image.gz layout: RAM_ADDR
+dev: eMMC alt: 3 name: sdcard_fsbl1 layout: RAW_ADDR
+dev: eMMC alt: 4 name: sdcard_fsbl2 layout: RAW_ADDR
+dev: eMMC alt: 5 name: sdcard_ssbl layout: RAW_ADDR
+dev: eMMC alt: 6 name: sdcard_bootfs layout: RAW_ADDR
+dev: eMMC alt: 7 name: sdcard_vendorfs layout: RAW_ADDR
+dev: eMMC alt: 8 name: sdcard_rootfs layout: RAW_ADDR
+dev: eMMC alt: 9 name: sdcard_userfs layout: RAW_ADDR
+dev: eMMC alt: 10 name: emmc_fsbl1 layout: RAW_ADDR
+dev: eMMC alt: 11 name: emmc_fsbl2 layout: RAW_ADDR
+dev: eMMC alt: 12 name: emmc_ssbl layout: RAW_ADDR
+dev: eMMC alt: 13 name: emmc_bootfs layout: RAW_ADDR
+dev: eMMC alt: 14 name: emmc_vendorfs layout: RAW_ADDR
+dev: eMMC alt: 15 name: emmc_rootfs layout: RAW_ADDR
+dev: eMMC alt: 16 name: emmc_userfs layout: RAW_ADDR
+dev: MTD alt: 17 name: nor_fsbl1 layout: RAW_ADDR
+dev: MTD alt: 18 name: nor_fsbl2 layout: RAW_ADDR
+dev: MTD alt: 19 name: nor_ssbl layout: RAW_ADDR
+dev: MTD alt: 20 name: nor_env layout: RAW_ADDR
+dev: MTD alt: 21 name: nand_fsbl layout: RAW_ADDR
+dev: MTD alt: 22 name: nand_ssbl1 layout: RAW_ADDR
+dev: MTD alt: 23 name: nand_ssbl2 layout: RAW_ADDR
+dev: MTD alt: 24 name: nand_UBI layout: RAW_ADDR
+dev: VIRT alt: 25 name: OTP layout: RAW_ADDR
+dev: VIRT alt: 26 name: PMIC layout: RAW_ADDR
+
+All the supported device are exported for dfu-util tool:
+
+$> dfu-util -l
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=26, 
name="PMIC", serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=25, name="OTP", 
serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=24, 
name="nand_UBI", serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=23, 
name="nand_ssbl2", serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=22, 
name="nand_ssbl1", serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=21, 
name="nand_fsbl", serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=20, 
name="nor_env", serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=19, 
name="nor_ssbl", serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=18, 
name="nor_fsbl2", serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=17, 
name="nor_fsbl1", serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=16, 
name="emmc_userfs", serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=15, 
name="emmc_rootfs", serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=14, 
name="emmc_vendorfs", serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=13, 
name="emmc_bootfs", serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=12, 
name="emmc_ssbl", serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=11, 
name="emmc_fsbl2", serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=10, 
name="emmc_fsbl1", serial="00270038511934383330"
+Found DFU: [0483:5720] ver=, devnum=99, cfg=1, intf=0, alt=9, 
name="sdcard_userfs", serial="00270038511934383330"
+Found DFU: 

[U-Boot] [PATCH v2 16/16] board: stm32mp1: fixup the usb product id for USB download gadget

2019-09-30 Thread Patrick Delaunay
Select the correct USB product id used by the download gadget
for ST stm32mp1 boards.

The board stm32mp1 select the correct product id, as defined in
http://www.linux-usb.org/usb.ids for the STMicroelectronics
vendor id = 0x0483 (CONFIG_USB_GADGET_VENDOR_NUM):
- dfu = 0xdf11 : STM Device in DFU mode
  it is the value used by ROM code and reused for stm32prog
  command
- fasboot = 0x0afb : Android Fastboot device
- others = 0x5720 (CONFIG_USB_GADGET_PRODUCT_NUM)
  Mass Storage Device
  it is used for UMS command / usb_dnl_ums

This patch avoid conflict when the same USB VID/PID is used for
ums, fastboot or dfu command (two different protocols associated
to the same PID).

Signed-off-by: Patrick Delaunay 
---

Changes in v2: None

 board/st/stm32mp1/stm32mp1.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 6045850c05..4ed2d88849 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -234,6 +234,23 @@ int g_dnl_board_usb_cable_connected(void)
 
return dwc2_udc_B_session_valid(dwc2_udc_otg);
 }
+
+#define STM32MP1_G_DNL_DFU_PRODUCT_NUM 0xdf11
+#define STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM 0x0afb
+
+int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
+{
+   if (!strcmp(name, "usb_dnl_dfu"))
+   put_unaligned(STM32MP1_G_DNL_DFU_PRODUCT_NUM, >idProduct);
+   else if (!strcmp(name, "usb_dnl_fastboot"))
+   put_unaligned(STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM,
+ >idProduct);
+   else
+   put_unaligned(CONFIG_USB_GADGET_PRODUCT_NUM, >idProduct);
+
+   return 0;
+}
+
 #endif /* CONFIG_USB_GADGET */
 
 #ifdef CONFIG_LED
-- 
2.17.1

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


[U-Boot] [PATCH v2 09/16] dfu: add DFU virtual backend

2019-09-30 Thread Patrick Delaunay
Add a virtual DFU backend to allow board specific read and write
(for OTP update for example).

Acked-by: Lukasz Majewski 
Signed-off-by: Patrick Delaunay 
---

Changes in v2:
- Update dfu documentation for virtual backend

 doc/README.dfu | 32 ++-
 drivers/dfu/Kconfig|  7 ++
 drivers/dfu/Makefile   |  1 +
 drivers/dfu/dfu.c  |  5 -
 drivers/dfu/dfu_virt.c | 49 ++
 include/dfu.h  | 22 +++
 6 files changed, 114 insertions(+), 2 deletions(-)
 create mode 100644 drivers/dfu/dfu_virt.c

diff --git a/doc/README.dfu b/doc/README.dfu
index 34bb25a2fc..7b293fc08d 100644
--- a/doc/README.dfu
+++ b/doc/README.dfu
@@ -22,11 +22,18 @@ Overview:
   - RAM
   - SF (serial flash)
   - MTD (all MTD device: NAND, SPI-NOR, SPI-NAND,...)
+  - virtual
 
   These DFU backends are also used by
   - the dfutftp (see README.dfutftp)
   - the thordown command (cmd/thordown.c and gadget/f_thor.c)
 
+  The "virtual" backend is a generic DFU backend to support a board specific
+  target (for example OTP), only based on the weak functions:
+  - dfu_write_medium_virt
+  - dfu_get_medium_size_virt
+  - dfu_read_medium_virt
+
 Configuration Options:
   CONFIG_DFU
   CONFIG_DFU_OVER_USB
@@ -35,6 +42,7 @@ Configuration Options:
   CONFIG_DFU_NAND
   CONFIG_DFU_RAM
   CONFIG_DFU_SF
+  CONFIG_DFU_VIRTUAL
   CONFIG_CMD_DFU
 
 Environment variables:
@@ -116,6 +124,11 @@ Commands:
 
   with  is the MTD partition index
 
+  "virt"
+cmd: dfu 0 virt 
+each element in "dfu_alt_info" =
+  
+
and  are absent:
 the dfu command to use multiple devices
 cmd: dfu 0 list
@@ -127,7 +140,7 @@ Commands:
ram =;;
sf =;;
mtd =;;
-
+   virt =;;
 
 Host tools:
   When U-Boot runs the dfu stack, the DFU host tools can be used
@@ -229,3 +242,20 @@ Usage:
   dev: MTD alt: 1 name: u-boot layout: RAW_ADDR
   dev: MTD alt: 2 name: u-boot-env layout: RAW_ADDR
   dev: MTD alt: 3 name: UBI layout: RAW_ADDR
+
+  Example 3: firmware located in SD Card (mmc) and virtual partition on
+ OTP and PMIC not volatile memory
+  - alternate 1 (alt=1) for scard
+  - alternate 2 (alt=2) for OTP (virtual)
+  - alternate 3 (alt=3) for PMIC NVM (virtual)
+
+   U-Boot> env set dfu_alt_info \
+  "mmc 0=sdcard raw 0 0x10&"\
+  "virt 0=otp" \
+  "virt 1=pmic"
+
+   U-Boot> dfu 0 list
+   DFU alt settings list:
+   dev: eMMC alt: 0 name: sdcard layout: RAW_ADDR
+   dev: VIRT alt: 1 name: otp layout: RAW_ADDR
+   dev: VIRT alt: 2 name: pmic layout: RAW_ADDR
diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig
index ee664a331b..c0e6e5d8f0 100644
--- a/drivers/dfu/Kconfig
+++ b/drivers/dfu/Kconfig
@@ -52,5 +52,12 @@ config DFU_MTD
help
  This option enables using DFU to read and write to on any MTD device.
 
+config DFU_VIRT
+   bool "VIRTUAL flash back end for DFU"
+   help
+ This option enables using DFU to read and write to VIRTUAL device
+ used at board level to manage specific behavior
+ (OTP update for example).
+
 endif
 endmenu
diff --git a/drivers/dfu/Makefile b/drivers/dfu/Makefile
index ebb119f398..0d7925c083 100644
--- a/drivers/dfu/Makefile
+++ b/drivers/dfu/Makefile
@@ -10,3 +10,4 @@ obj-$(CONFIG_$(SPL_)DFU_NAND) += dfu_nand.o
 obj-$(CONFIG_$(SPL_)DFU_RAM) += dfu_ram.o
 obj-$(CONFIG_$(SPL_)DFU_SF) += dfu_sf.o
 obj-$(CONFIG_$(SPL_)DFU_TFTP) += dfu_tftp.o
+obj-$(CONFIG_$(SPL_)DFU_VIRT) += dfu_virt.o
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 4f4a07b790..2697235c24 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -474,6 +474,9 @@ static int dfu_fill_entity(struct dfu_entity *dfu, char *s, 
int alt,
} else if (strcmp(interface, "sf") == 0) {
if (dfu_fill_entity_sf(dfu, devstr, s))
return -1;
+   } else if (strcmp(interface, "virt") == 0) {
+   if (dfu_fill_entity_virt(dfu, devstr, s))
+   return -1;
} else {
printf("%s: Device %s not (yet) supported!\n",
   __func__,  interface);
@@ -569,7 +572,7 @@ int dfu_config_entities(char *env, char *interface, char 
*devstr)
 const char *dfu_get_dev_type(enum dfu_device_type t)
 {
const char *const dev_t[] = {NULL, "eMMC", "OneNAND", "NAND", "RAM",
-"SF", "MTD"};
+"SF", "MTD", "VIRT"};
return dev_t[t];
 }
 
diff --git a/drivers/dfu/dfu_virt.c b/drivers/dfu/dfu_virt.c
new file mode 100644
index 00..ea8c71f100
--- /dev/null
+++ b/drivers/dfu/dfu_virt.c
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+/*
+ * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
+ */
+#include 
+#include 
+#include 
+#include 
+
+int __weak dfu_write_medium_virt(struct dfu_entity *dfu, u64 offset,
+void 

[U-Boot] [PATCH v2 04/16] dfu: prepare the support of multiple interface

2019-09-30 Thread Patrick Delaunay
Split the function dfu_config_entities with 2 new functions
- dfu_alt_init
- dfu_alt_add

Signed-off-by: Patrick Delaunay 
---

Changes in v2: None

 drivers/dfu/dfu.c | 51 ---
 include/dfu.h |  2 ++
 2 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index e9db7f8d66..900a844d15 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -439,13 +439,12 @@ void dfu_free_entities(void)
alt_num_cnt = 0;
 }
 
-int dfu_config_entities(char *env, char *interface, char *devstr)
+int dfu_alt_init(int num, struct dfu_entity **dfu)
 {
-   struct dfu_entity *dfu;
-   int i, ret;
char *s;
+   int ret;
 
-   dfu_alt_num = dfu_find_alt_num(env);
+   dfu_alt_num = num;
debug("%s: dfu_alt_num=%d\n", __func__, dfu_alt_num);
 
dfu_hash_algo = NULL;
@@ -456,21 +455,49 @@ int dfu_config_entities(char *env, char *interface, char 
*devstr)
pr_err("Hash algorithm %s not supported\n", s);
}
 
-   dfu = calloc(sizeof(*dfu), dfu_alt_num);
-   if (!dfu)
+   *dfu = calloc(sizeof(struct dfu_entity), dfu_alt_num);
+   if (!*dfu)
+   return -1;
+
+   return 0;
+}
+
+int dfu_alt_add(struct dfu_entity *dfu, char *interface, char *devstr, char *s)
+{
+   struct dfu_entity *p_dfu;
+   int ret;
+
+   if (alt_num_cnt >= dfu_alt_num)
+   return -1;
+
+   p_dfu = [alt_num_cnt];
+   ret = dfu_fill_entity(p_dfu, s, alt_num_cnt, interface, devstr);
+   if (ret)
return -1;
-   for (i = 0; i < dfu_alt_num; i++) {
 
+   list_add_tail(_dfu->list, _list);
+   alt_num_cnt++;
+
+   return 0;
+}
+
+int dfu_config_entities(char *env, char *interface, char *devstr)
+{
+   struct dfu_entity *dfu;
+   int i, ret;
+   char *s;
+
+   ret = dfu_alt_init(dfu_find_alt_num(env), );
+   if (ret)
+   return -1;
+
+   for (i = 0; i < dfu_alt_num; i++) {
s = strsep(, ";");
-   ret = dfu_fill_entity([i], s, alt_num_cnt, interface,
- devstr);
+   ret = dfu_alt_add(dfu, interface, devstr, s);
if (ret) {
/* We will free "dfu" in dfu_free_entities() */
return -1;
}
-
-   list_add_tail([i].list, _list);
-   alt_num_cnt++;
}
 
return 0;
diff --git a/include/dfu.h b/include/dfu.h
index bf51ab74a5..7d60ffc228 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -143,6 +143,8 @@ struct dfu_entity {
 #ifdef CONFIG_SET_DFU_ALT_INFO
 void set_dfu_alt_info(char *interface, char *devstr);
 #endif
+int dfu_alt_init(int num, struct dfu_entity **dfu);
+int dfu_alt_add(struct dfu_entity *dfu, char *interface, char *devstr, char 
*s);
 int dfu_config_entities(char *s, char *interface, char *devstr);
 void dfu_free_entities(void);
 void dfu_show_entities(void);
-- 
2.17.1

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


[U-Boot] [PATCH v2 14/16] stm32mp1: board: add spi nand support

2019-09-30 Thread Patrick Delaunay
This patch adds the support of the spi nand device in mtdparts command
and in dfu_alt_info.

Signed-off-by: Patrick Delaunay 
---

Changes in v2: None

 board/st/stm32mp1/stm32mp1.c | 32 +---
 include/configs/stm32mp1.h   | 10 --
 2 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 62855988e9..e4bdf05cd7 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -862,8 +862,9 @@ static void board_get_mtdparts(const char *dev,
 
 void board_mtdparts_default(const char **mtdids, const char **mtdparts)
 {
+   struct mtd_info *mtd;
struct udevice *dev;
-   static char parts[2 * MTDPARTS_LEN + 1];
+   static char parts[3 * MTDPARTS_LEN + 1];
static char ids[MTDIDS_LEN + 1];
static bool mtd_initialized;
 
@@ -876,8 +877,24 @@ void board_mtdparts_default(const char **mtdids, const 
char **mtdparts)
memset(parts, 0, sizeof(parts));
memset(ids, 0, sizeof(ids));
 
-   if (!uclass_get_device(UCLASS_MTD, 0, ))
+   /* probe all MTD devices */
+   for (uclass_first_device(UCLASS_MTD, );
+dev;
+uclass_next_device()) {
+   pr_debug("mtd device = %s\n", dev->name);
+   }
+
+   mtd = get_mtd_device_nm("nand0");
+   if (!IS_ERR_OR_NULL(mtd)) {
board_get_mtdparts("nand0", ids, parts);
+   put_mtd_device(mtd);
+   }
+
+   mtd = get_mtd_device_nm("spi-nand0");
+   if (!IS_ERR_OR_NULL(mtd)) {
+   board_get_mtdparts("spi-nand0", ids, parts);
+   put_mtd_device(mtd);
+   }
 
if (!uclass_get_device(UCLASS_SPI_FLASH, 0, ))
board_get_mtdparts("nor0", ids, parts);
@@ -927,6 +944,7 @@ static void board_get_alt_info(const char *dev, char *buff)
 void set_dfu_alt_info(char *interface, char *devstr)
 {
struct udevice *dev;
+   struct mtd_info *mtd;
 
ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
 
@@ -935,6 +953,9 @@ void set_dfu_alt_info(char *interface, char *devstr)
 
memset(buf, 0, sizeof(buf));
 
+   /* probe all MTD devices */
+   mtd_probe_devices();
+
board_get_alt_info("ram", buf);
 
if (!uclass_get_device(UCLASS_MMC, 0, ))
@@ -946,9 +967,14 @@ void set_dfu_alt_info(char *interface, char *devstr)
if (!uclass_get_device(UCLASS_SPI_FLASH, 0, ))
board_get_alt_info("nor0", buf);
 
-   if (!uclass_get_device(UCLASS_MTD, 0, ))
+   mtd = get_mtd_device_nm("nand0");
+   if (!IS_ERR_OR_NULL(mtd))
board_get_alt_info("nand0", buf);
 
+   mtd = get_mtd_device_nm("spi-nand0");
+   if (!IS_ERR_OR_NULL(mtd))
+   board_get_alt_info("spi-nand0", buf);
+
env_set("dfu_alt_info", buf);
puts("DFU alt info setting: done\n");
 }
diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
index 4f9024229e..145a644efa 100644
--- a/include/configs/stm32mp1.h
+++ b/include/configs/stm32mp1.h
@@ -124,12 +124,15 @@
 /* with OPTEE: define specific MTD partitions = teeh, teed, teex */
 #define STM32MP_MTDPARTS \

"mtdparts_nor0=256k(fsbl1),256k(fsbl2),2m(ssbl),256k(u-boot-env),256k(teeh),256k(teed),256k(teex),-(nor_user)\0"
 \
-   
"mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),512k(teeh),512k(teed),512k(teex),-(UBI)\0"
+   
"mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),512k(teeh),512k(teed),512k(teex),-(UBI)\0"
 \
+   "mtdparts_spi-nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),"\
+   "512k(teeh),512k(teed),512k(teex),-(UBI)\0"
 
 #else /* CONFIG_STM32MP1_OPTEE */
 #define STM32MP_MTDPARTS \

"mtdparts_nor0=256k(fsbl1),256k(fsbl2),2m(ssbl),256k(u-boot-env),-(nor_user)\0" 
\
-   "mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0"
+   "mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0" \
+   "mtdparts_spi-nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0"
 
 #endif /* CONFIG_STM32MP1_OPTEE */
 
@@ -152,6 +155,9 @@
"dfu_alt_info_nand0=mtd nand0="\
"nand_fsbl part 1;nand_ssbl1 part 2;" \
"nand_ssbl2 part 3;nand_UBI partubi 4\0" \
+   "dfu_alt_info_spi-nand0=mtd spi-nand0="\
+   "spi-nand_fsbl part 1;spi-nand_ssbl1 part 2;" \
+   "spi-nand_ssbl2 part 3;spi-nand_UBI partubi 4\0" \
"dfu_alt_info_mmc0=mmc 0=" \
"sdcard_fsbl1 part 0 1;sdcard_fsbl2 part 0 2;" \
"sdcard_ssbl part 0 3;sdcard_bootfs part 0 4;" \
-- 
2.17.1

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


[U-Boot] [PATCH v2 13/16] stm32mp1: configs: activate CONFIG_MTD_SPI_NAND

2019-09-30 Thread Patrick Delaunay
Activate the support of SPI NAND in stm32mp1 U-Boot.

Signed-off-by: Patrick Delaunay 
---

Changes in v2: None

 configs/stm32mp15_basic_defconfig   | 1 +
 configs/stm32mp15_optee_defconfig   | 1 +
 configs/stm32mp15_trusted_defconfig | 1 +
 3 files changed, 3 insertions(+)

diff --git a/configs/stm32mp15_basic_defconfig 
b/configs/stm32mp15_basic_defconfig
index cd4fc20ca5..699e687891 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -86,6 +86,7 @@ CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_NAND=y
 CONFIG_NAND_STM32_FMC2=y
+CONFIG_MTD_SPI_NAND=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_MACRONIX=y
diff --git a/configs/stm32mp15_optee_defconfig 
b/configs/stm32mp15_optee_defconfig
index 8d3d2e8508..387de0ad35 100644
--- a/configs/stm32mp15_optee_defconfig
+++ b/configs/stm32mp15_optee_defconfig
@@ -73,6 +73,7 @@ CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_NAND=y
 CONFIG_NAND_STM32_FMC2=y
+CONFIG_MTD_SPI_NAND=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_MACRONIX=y
diff --git a/configs/stm32mp15_trusted_defconfig 
b/configs/stm32mp15_trusted_defconfig
index 8da8c4e22a..29c23c634d 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -72,6 +72,7 @@ CONFIG_STM32_SDMMC2=y
 CONFIG_MTD=y
 CONFIG_NAND=y
 CONFIG_NAND_STM32_FMC2=y
+CONFIG_MTD_SPI_NAND=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_MACRONIX=y
-- 
2.17.1

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


[U-Boot] [PATCH v2 02/16] doc: dfu: Add dfu documentation

2019-09-30 Thread Patrick Delaunay
Add documentation for dfu stack and "dfu" command.

Signed-off-by: Patrick Delaunay 
---

Changes in v2:
- Add dfu documentation

 doc/README.dfu | 144 +
 1 file changed, 144 insertions(+)
 create mode 100644 doc/README.dfu

diff --git a/doc/README.dfu b/doc/README.dfu
new file mode 100644
index 00..f5344e236c
--- /dev/null
+++ b/doc/README.dfu
@@ -0,0 +1,144 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+Device Firmware Upgrade (DFU)
+
+Overview:
+
+  The Device Firmware Upgrade (DFU) allows to download and upload firmware
+  to/from U-Boot connected over USB.
+
+  U-boot follows the Universal Serial Bus Device Class Specification for
+  Device Firmware Upgrade Version 1.1 the USB forum (DFU v1.1 in www.usb.org).
+
+  U-Boot implements this DFU capability (CONFIG_DFU) with the command dfu
+  (cmd/dfu.c / CONFIG_CMD_DFU) based on:
+  - the DFU stack (common/dfu.c and common/spl/spl_dfu.c), based on the
+USB DFU download gadget (drivers/usb/gadget/f_dfu.c)
+  - The access to mediums is done in DFU backends (driver/dfu)
+
+  Today the supported DFU backends are:
+  - MMC (RAW or FAT / EXT2 / EXT3 / EXT4 file system)
+  - NAND
+  - RAM
+  - SF (serial flash)
+
+  These DFU backends are also used by
+  - the dfutftp (see README.dfutftp)
+  - the thordown command (cmd/thordown.c and gadget/f_thor.c)
+
+Configuration Options:
+  CONFIG_DFU
+  CONFIG_DFU_OVER_USB
+  CONFIG_DFU_MMC
+  CONFIG_DFU_NAND
+  CONFIG_DFU_RAM
+  CONFIG_DFU_SF
+  CONFIG_CMD_DFU
+
+Environment variables:
+  the dfu command use 3 environments variables:
+  "dfu_alt_info" : the DFU setting for the USB download gadget with a comma
+   separated string of information on each alternate:
+   dfu_alt_info=";;;"
+
+  "dfu_bufsiz" : size of the DFU buffer, when absent, use
+ CONFIG_SYS_DFU_DATA_BUF_SIZE (8MiB by default)
+
+  "dfu_hash_algo" : name of the hash algorithm to use
+
+Commands:
+  dfulist
+list the alternate device defined in "dfu_alt_info"
+
+  dfu   
+start the dfu stack on the USB instance with the selected medium
+backend and use the "dfu_alt_info" variable to configure the
+alternate setting and link each one with the medium
+The dfu command continue until receive a ^C in console or
+a DFU detach transaction from HOST.
+
+  The possible values of  are :
+  (with  = 0 in the dfu command example)
+
+  "mmc" (for eMMC and SD card)
+cmd: dfu 0 mmc 
+each element in "dfu_alt_info" =
+   raw raw access to mmc device
+   partraw acces to partition
+   fat file in FAT partition
+   ext4file in EXT4 partition
+
+  with  is the GPT or DOS partition index
+
+  "nand" (raw slc nand device)
+cmd: dfu 0 nand 
+each element in "dfu_alt_info" =
+   raw raw access to mmc device
+   partraw acces to partition
+   partubiraw acces to ubi partition
+
+  with  is the MTD partition index
+
+  "ram"
+cmd: dfu 0 ram 
+( is not used for RAM target)
+each element in "dfu_alt_info" =
+   ramraw access to ram
+
+  "sf" (serial flash : NOR)
+cmd: dfu 0 sf 
+each element in "dfu_alt_info" =
+   ramraw access to sf device
+
+Host tools:
+  When U-Boot runs the dfu stack, the DFU host tools can be used
+  to send/receive firmwares on each configurated alternate.
+
+  For example dfu-util is a host side implementation of the DFU 1.1
+  specifications(http://dfu-util.sourceforge.net/) which works with U-Boot.
+
+Usage:
+  Example for firmware located in eMMC or SD card, with:
+  - alternate 1 (alt=1) for SPL partition (GPT partition 1)
+  - alternate 2 (alt=2) for U-Boot partition (GPT partition 2)
+
+  The U-Boot configuration is:
+
+  U-Boot> env set dfu_alt_info "spl part 0 1;u-boot part 0 2"
+
+  U-Boot> dfu 0 mmc 0 list
+  DFU alt settings list:
+  dev: eMMC alt: 0 name: spl layout: RAW_ADDR
+  dev: eMMC alt: 1 name: u-boot layout: RAW_ADDR
+
+  Boot> dfu 0 mmc 0
+
+  On the Host side:
+
+  list the available alternate setting:
+
+  $> dfu-util -l
+  dfu-util 0.9
+
+  Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
+  Copyright 2010-2016 Tormod Volden and Stefan Schmidt
+  This program is Free Software and has ABSOLUTELY NO WARRANTY
+  Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
+
+  Found DFU: [0483:5720] ver=0200, devnum=45, cfg=1, intf=0, path="3-1.3.1", \
+ alt=1, name="u-boot", serial="003A00203438510D36383238"
+  Found DFU: [0483:5720] ver=0200, devnum=45, cfg=1, intf=0, path="3-1.3.1", \
+ alt=0, name="spl", serial="003A00203438510D36383238"
+
+  To download to U-Boot, use -D option
+
+  $> dfu-util -a 0 -D u-boot-spl.bin
+  $> dfu-util -a 1 -D u-boot.bin
+
+  To upload from U-Boot, use -U option
+
+  $> dfu-util -a 0 -U u-boot-spl.bin
+  $> dfu-util -a 1 -U u-boot.bin
+
+  To request a DFU detach and reset the USB connection:
+  $> dfu-util -a 0 -e  -R
-- 

[U-Boot] [PATCH v2 01/16] dfu: cosmetic: cleanup sf to avoid checkpatch error

2019-09-30 Thread Patrick Delaunay
Signed-off-by: Patrick Delaunay 
Acked-by: Lukasz Majewski 
---

Changes in v2: None

 drivers/dfu/dfu.c| 7 ---
 drivers/dfu/dfu_sf.c | 4 ++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index d2b67b18cf..e9db7f8d66 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -478,14 +478,15 @@ int dfu_config_entities(char *env, char *interface, char 
*devstr)
 
 const char *dfu_get_dev_type(enum dfu_device_type t)
 {
-   const char *dev_t[] = {NULL, "eMMC", "OneNAND", "NAND", "RAM", "SF" };
+   const char *const dev_t[] = {NULL, "eMMC", "OneNAND", "NAND", "RAM",
+"SF"};
return dev_t[t];
 }
 
 const char *dfu_get_layout(enum dfu_layout l)
 {
-   const char *dfu_layout[] = {NULL, "RAW_ADDR", "FAT", "EXT2",
-  "EXT3", "EXT4", "RAM_ADDR" };
+   const char *const dfu_layout[] = {NULL, "RAW_ADDR", "FAT", "EXT2",
+ "EXT3", "EXT4", "RAM_ADDR" };
return dfu_layout[l];
 }
 
diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c
index 066e7670d1..b78fcfd3a1 100644
--- a/drivers/dfu/dfu_sf.c
+++ b/drivers/dfu/dfu_sf.c
@@ -19,7 +19,7 @@ static int dfu_get_medium_size_sf(struct dfu_entity *dfu, u64 
*size)
 }
 
 static int dfu_read_medium_sf(struct dfu_entity *dfu, u64 offset, void *buf,
-   long *len)
+ long *len)
 {
return spi_flash_read(dfu->data.sf.dev, dfu->data.sf.start + offset,
*len, buf);
@@ -32,7 +32,7 @@ static u64 find_sector(struct dfu_entity *dfu, u64 start, u64 
offset)
 }
 
 static int dfu_write_medium_sf(struct dfu_entity *dfu,
-   u64 offset, void *buf, long *len)
+  u64 offset, void *buf, long *len)
 {
int ret;
 
-- 
2.17.1

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


[U-Boot] [PATCH v2 05/16] dfu: allow to manage DFU on several devices

2019-09-30 Thread Patrick Delaunay
Add support of DFU for several interface/device
with one command.

The format for "dfu_alt_info" in this case is :
-  '='alternate list (';' separated)
- each interface is separated by '&'

The previous behavior is always supported.

One example for NOR (bootloaders) + NAND (rootfs in UBI):

U-Boot> env set dfu_alt_info \
"sf 0:0:1000:0=spl part 0 1;u-boot part 0 2; \
u-boot-env part 0 3 0=UBI partubi 0,3"

U-Boot> dfu 0 list

DFU alt settings list:
dev: SF alt: 0 name: spl layout: RAW_ADDR
dev: SF alt: 1 name: ssbl layout: RAW_ADDR
dev: SF alt: 2 name: u-boot-env layout: RAW_ADDR
dev: NAND alt: 3 name: UBI layout: RAW_ADDR

U-Boot> dfu 0

$> dfu-util -l

Found DFU: [0483:5720] ver=, devnum=96, cfg=1,\
 intf=0, alt=3, name="UBI", serial="00270038511934383330"
Found DFU: [0483:5720] ver=, devnum=96, cfg=1,\
 intf=0, alt=2, name="u-boot-env", serial="00270038511934383330"
Found DFU: [0483:5720] ver=, devnum=96, cfg=1,\
 intf=0, alt=1, name="u-boot", serial="00270038511934383330"
Found DFU: [0483:5720] ver=, devnum=96, cfg=1,\
 intf=0, alt=0, name="spl", serial="00270038511934383330"

Signed-off-by: Patrick Delaunay 
---

Changes in v2:
- Add dfu documentation for several device

 cmd/dfu.c | 21 ++---
 doc/README.dfu| 58 ++---
 drivers/dfu/dfu.c | 60 ++-
 3 files changed, 127 insertions(+), 12 deletions(-)

diff --git a/cmd/dfu.c b/cmd/dfu.c
index 91a750a4fc..33491d0bc9 100644
--- a/cmd/dfu.c
+++ b/cmd/dfu.c
@@ -21,23 +21,28 @@
 static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 
-   if (argc < 4)
+   if (argc < 2)
return CMD_RET_USAGE;
 
 #ifdef CONFIG_DFU_OVER_USB
char *usb_controller = argv[1];
 #endif
 #if defined(CONFIG_DFU_OVER_USB) || defined(CONFIG_DFU_OVER_TFTP)
-   char *interface = argv[2];
-   char *devstring = argv[3];
+   char *interface = NULL;
+   char *devstring = NULL;
+
+   if (argc >= 4) {
+   interface = argv[2];
+   devstring = argv[3];
+   }
 #endif
 
int ret = 0;
 #ifdef CONFIG_DFU_OVER_TFTP
unsigned long addr = 0;
if (!strcmp(argv[1], "tftp")) {
-   if (argc == 5)
-   addr = simple_strtoul(argv[4], NULL, 0);
+   if (argc == 5 || argc == 3)
+   addr = simple_strtoul(argv[argc - 1], NULL, 0);
 
return update_tftp(addr, interface, devstring);
}
@@ -48,7 +53,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
goto done;
 
ret = CMD_RET_SUCCESS;
-   if (argc > 4 && strcmp(argv[4], "list") == 0) {
+   if (strcmp(argv[argc - 1], "list") == 0) {
dfu_show_entities();
goto done;
}
@@ -67,7 +72,7 @@ U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
"Device Firmware Upgrade",
""
 #ifdef CONFIG_DFU_OVER_USB
-   "   [list]\n"
+   " [ ] [list]\n"
"  - device firmware upgrade via \n"
"on device , attached to interface\n"
"\n"
@@ -77,7 +82,7 @@ U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
 #ifdef CONFIG_DFU_OVER_USB
"dfu "
 #endif
-   "tftp   []\n"
+   "tftp [ ] []\n"
"  - device firmware upgrade via TFTP\n"
"on device , attached to interface\n"
"\n"
diff --git a/doc/README.dfu b/doc/README.dfu
index cf5de28b01..0adff1603f 100644
--- a/doc/README.dfu
+++ b/doc/README.dfu
@@ -41,16 +41,25 @@ Environment variables:
separated string of information on each alternate:
dfu_alt_info=";;;"
 
+   when only several device are used, the format is:
+   -  '='alternate list (';' separated)
+   - each interface is separated by '&'
+dfu_alt_info=\
+   " =;;&"\
+   " =;;&"\
+   ...\
+   " =;;&"
+
   "dfu_bufsiz" : size of the DFU buffer, when absent, use
  CONFIG_SYS_DFU_DATA_BUF_SIZE (8MiB by default)
 
   "dfu_hash_algo" : name of the hash algorithm to use
 
 Commands:
-  dfulist
+  dfu  [ ] list
 list the alternate device defined in "dfu_alt_info"
 
-  dfu   
+  dfu  [ ]
 start the dfu stack on the USB instance with the selected medium
 backend and use the "dfu_alt_info" variable to configure the
 alternate setting and link each one with the medium
@@ -94,6 +103,18 @@ Commands:
 
   with  is the MTD partition index
 
+   and  are absent:
+the dfu command to use multiple devices
+cmd: dfu 0 list
+cmd: dfu 0
+   "dfu_alt_info" variable provides the list of   with
+   alternate list separated by '&' with the same format for each 
+   mmc =;;
+   nand =;;
+   ram =;;
+   sf =;;
+
+
 Host 

[U-Boot] [PATCH v2 00/16] dfu: update dfu stack and add MTD backend

2019-09-30 Thread Patrick Delaunay

This serie based on v2019.10-rc3 propose updates on the DFU stack:
- add capability to have several DFU backend running in parallel
- add MTD backend for update of NAND, NOR or SPI-NAND
- add VIRTUAL backend for board/command specific behavior
- add some weak callback

It is the same content that the previous RFC:
http://patchwork.ozlabs.org/project/uboot/list/?series=120375
"dfu: update dfu stack and use them for stm32mp1"

To test the new features and as example, I update the stm32mp1 board
to use the new features; I test them with the command "dfu 0"
(for test I have dependency with patch
 http://patchwork.ozlabs.org/patch/1162076/)

The expected target of the dfu part for this serie is v2020.01.
I will merge the stm32mp1 part when they will be accepted by dfu
maintainers.

This serie prepares the DFU backend for the coming 'stm32prog' command
and for STM32CubeProgrammer on stm32mp1 platform.
This STMicroelectronics tool is based on DFU protocol and allows to
update all the boot devices and the OTPs on the ST boards
(so several DFU target in parallel, including spi nand).


Changes in v2:
- Add dfu documentation
- Update dfu documentation for callbacks
- Add dfu documentation for several device
- Update commit message
- Update commit message
- Update dfu documentation for MTD
- Update dfu documentation for MTD
- Update dfu documentation for virtual backend
- Update dfu documentation for callbacks
- Update callbacks comment after Lukasz review
- Update after Lukasz Majewski comments

Patrick Delaunay (16):
  dfu: cosmetic: cleanup sf to avoid checkpatch error
  doc: dfu: Add dfu documentation
  dfu: sf: add partition support for nor backend
  dfu: prepare the support of multiple interface
  dfu: allow to manage DFU on several devices
  dfu: allow read with no data without error for EOF indication
  dfu: add backend for MTD device
  dfu: add partition support for MTD backend
  dfu: add DFU virtual backend
  dfu: add callback for flush and initiated operation
  stm32mp1: activate DFU support and command MTD
  stm32mp1: activate SET_DFU_ALT_INFO
  stm32mp1: configs: activate CONFIG_MTD_SPI_NAND
  stm32mp1: board: add spi nand support
  stm32mp1: add support for virtual partition read
  board: stm32mp1: fixup the usb product id for USB download gadget

 board/st/stm32mp1/README| 111 ++
 board/st/stm32mp1/stm32mp1.c| 181 +++-
 cmd/dfu.c   |  21 +-
 configs/stm32mp15_basic_defconfig   |   6 +
 configs/stm32mp15_optee_defconfig   |   6 +
 configs/stm32mp15_trusted_defconfig |   6 +
 doc/README.dfu  | 269 
 drivers/dfu/Kconfig |  13 ++
 drivers/dfu/Makefile|   2 +
 drivers/dfu/dfu.c   | 145 +++--
 drivers/dfu/dfu_mtd.c   | 306 
 drivers/dfu/dfu_sf.c|  55 -
 drivers/dfu/dfu_virt.c  |  49 +
 include/configs/stm32mp1.h  |  42 +++-
 include/dfu.h   |  71 +++
 15 files changed, 1253 insertions(+), 30 deletions(-)
 create mode 100644 doc/README.dfu
 create mode 100644 drivers/dfu/dfu_mtd.c
 create mode 100644 drivers/dfu/dfu_virt.c

-- 
2.17.1

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


[U-Boot] [PATCH v2 03/16] dfu: sf: add partition support for nor backend

2019-09-30 Thread Patrick Delaunay
Copy the partition support from NAND backend to SF,
support part and partubi option.
In case of ubi partition, erase the rest of the
partition as it is mandatory for UBI.

for example:

U-Boot> env set dfu_alt_info "spl part 0 1;\
u-boot part 0 2;u-boot-env part 0 3;UBI partubi 0 4"
U-Boot> dfu 0 sf 0:0:1000:0

Acked-by: Lukasz Majewski 
Signed-off-by: Patrick Delaunay 
---

Changes in v2:
- Update dfu documentation for callbacks

 doc/README.dfu   |  4 
 drivers/dfu/dfu_sf.c | 51 
 include/dfu.h|  2 ++
 3 files changed, 57 insertions(+)

diff --git a/doc/README.dfu b/doc/README.dfu
index f5344e236c..cf5de28b01 100644
--- a/doc/README.dfu
+++ b/doc/README.dfu
@@ -89,6 +89,10 @@ Commands:
 cmd: dfu 0 sf 
 each element in "dfu_alt_info" =
ramraw access to sf device
+   partraw acces to partition
+   partubiraw acces to ubi partition
+
+  with  is the MTD partition index
 
 Host tools:
   When U-Boot runs the dfu stack, the DFU host tools can be used
diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c
index b78fcfd3a1..d401b76c2e 100644
--- a/drivers/dfu/dfu_sf.c
+++ b/drivers/dfu/dfu_sf.c
@@ -10,6 +10,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 static int dfu_get_medium_size_sf(struct dfu_entity *dfu, u64 *size)
 {
@@ -52,11 +54,33 @@ static int dfu_write_medium_sf(struct dfu_entity *dfu,
 
 static int dfu_flush_medium_sf(struct dfu_entity *dfu)
 {
+   u64 off, length;
+
+   if (!dfu->data.sf.ubi)
+   return 0;
+
+   /* in case of ubi partition, erase rest of the partition */
+   off = find_sector(dfu, dfu->data.sf.start, dfu->offset);
+   /* last write ended with unaligned length jump to next */
+   if (off != dfu->data.sf.start + dfu->offset)
+   off += dfu->data.sf.dev->sector_size;
+   length = dfu->data.sf.start + dfu->data.sf.size - off;
+   if (length)
+   return spi_flash_erase(dfu->data.sf.dev, off, length);
+
return 0;
 }
 
 static unsigned int dfu_polltimeout_sf(struct dfu_entity *dfu)
 {
+   /*
+* Currently, Poll Timeout != 0 is only needed on nand
+* ubi partition, as sectors which are not used need
+* to be erased
+*/
+   if (dfu->data.sf.ubi)
+   return DFU_MANIFEST_POLL_TIMEOUT;
+
return DFU_DEFAULT_POLL_TIMEOUT;
 }
 
@@ -133,6 +157,33 @@ int dfu_fill_entity_sf(struct dfu_entity *dfu, char 
*devstr, char *s)
dfu->data.sf.start = simple_strtoul(s, , 16);
s++;
dfu->data.sf.size = simple_strtoul(s, , 16);
+   } else if ((!strcmp(st, "part")) || (!strcmp(st, "partubi"))) {
+   char mtd_id[32];
+   struct mtd_device *mtd_dev;
+   u8 part_num;
+   struct part_info *pi;
+   int ret, dev, part;
+
+   dfu->layout = DFU_RAW_ADDR;
+
+   dev = simple_strtoul(s, , 10);
+   s++;
+   part = simple_strtoul(s, , 10);
+
+   sprintf(mtd_id, "%s%d,%d", "nor", dev, part - 1);
+   printf("using id '%s'\n", mtd_id);
+
+   mtdparts_init();
+
+   ret = find_dev_and_part(mtd_id, _dev, _num, );
+   if (ret != 0) {
+   printf("Could not locate '%s'\n", mtd_id);
+   return -1;
+   }
+   dfu->data.sf.start = pi->offset;
+   dfu->data.sf.size = pi->size;
+   if (!strcmp(st, "partubi"))
+   dfu->data.sf.ubi = 1;
} else {
printf("%s: Memory layout (%s) not supported!\n", __func__, st);
spi_flash_free(dfu->data.sf.dev);
diff --git a/include/dfu.h b/include/dfu.h
index 145a1576a3..bf51ab74a5 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -77,6 +77,8 @@ struct sf_internal_data {
/* RAW programming */
u64 start;
u64 size;
+   /* for sf/ubi use */
+   unsigned int ubi;
 };
 
 #define DFU_NAME_SIZE  32
-- 
2.17.1

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


[U-Boot] [PATCH] configs: am43xx_evm: Enable USB support

2019-09-30 Thread Lokesh Vutla
spl_dm_init is failing as usb to be probed with the following error:
"omap_dwc3@483c: ret=-2"
Enable usb to make spl boot on am43xx devices

Reported-by: Tero Kristo 
Signed-off-by: Lokesh Vutla 
---
 configs/am43xx_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/am43xx_evm_defconfig b/configs/am43xx_evm_defconfig
index 7c74047f3a..0c187b4802 100644
--- a/configs/am43xx_evm_defconfig
+++ b/configs/am43xx_evm_defconfig
@@ -18,6 +18,7 @@ CONFIG_SPL_MTD_SUPPORT=y
 CONFIG_SPL_NET_SUPPORT=y
 CONFIG_SPL_NET_VCI_STRING="AM43xx U-Boot SPL"
 CONFIG_SPL_OS_BOOT=y
+CONFIG_SPL_USB_HOST_SUPPORT=y
 CONFIG_SPL_USB_GADGET=y
 CONFIG_SPL_USB_ETHER=y
 CONFIG_CMD_SPL=y
-- 
2.23.0

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


[U-Boot] [PATCH v1 4/5] drivers: clk: Fix using assigned-clocks in the node of the clock it sets up

2019-09-30 Thread Jean-Jacques Hiblot
This fixes the case where assigned-clocks is used to define a clock
defaults inside this same clock's node. This is used sometimes to setup a
default parents and/or rate for a clock.

example:
muxed_clock: muxed_clock {
clocks = <_provider 0>, <_provider 1>;
#clock-cells = <0>;
assigned-clocks = <_clock>;
assigned-clock-parents = <_provider 1>;
};

It doesn't work in u-boot because the assigned-clocks are setup *before*
the clock is probed. (clk_set_parent() will likely crash or fail if called
before the device probe function)
Making it work by handling "assigned-clocks" in 2 steps: first before the
clk device is probed, and then after the clk device is probed.

Signed-off-by: Jean-Jacques Hiblot 
---

 drivers/clk/clk-uclass.c | 48 +++-
 drivers/core/device.c|  2 +-
 include/clk.h|  7 --
 3 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index e7ec6347de..75d618a47b 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -178,7 +178,7 @@ bulk_get_err:
return ret;
 }
 
-static int clk_set_default_parents(struct udevice *dev)
+static int clk_set_default_parents(struct udevice *dev, int stage)
 {
struct clk clk, parent_clk;
int index;
@@ -214,8 +214,18 @@ static int clk_set_default_parents(struct udevice *dev)
return ret;
}
 
-   ret = clk_set_parent(, _clk);
+   /* This is clk provider device trying to reparent itself
+* It cannot be done right now but need to wait after the
+* device is probed
+*/
+   if (stage == 0 && clk.dev == dev)
+   continue;
+
+   if (stage > 0 && clk.dev != dev)
+   /* do not setup twice the parent clocks */
+   continue;
 
+   ret = clk_set_parent(, _clk);
/*
 * Not all drivers may support clock-reparenting (as of now).
 * Ignore errors due to this.
@@ -233,7 +243,7 @@ static int clk_set_default_parents(struct udevice *dev)
return 0;
 }
 
-static int clk_set_default_rates(struct udevice *dev)
+static int clk_set_default_rates(struct udevice *dev, int stage)
 {
struct clk clk;
int index;
@@ -268,7 +278,19 @@ static int clk_set_default_rates(struct udevice *dev)
continue;
}
 
+   /* This is clk provider device trying to program itself
+* It cannot be done right now but need to wait after the
+* device is probed
+*/
+   if (stage == 0 && clk.dev == dev)
+   continue;
+
+   if (stage > 0 && clk.dev != dev)
+   /* do not setup twice the parent clocks */
+   continue;
+
ret = clk_set_rate(, rates[index]);
+
if (ret < 0) {
debug("%s: failed to set rate on clock index %d (%ld) 
for %s\n",
  __func__, index, clk.id, dev_read_name(dev));
@@ -281,7 +303,7 @@ fail:
return ret;
 }
 
-int clk_set_defaults(struct udevice *dev)
+int clk_set_defaults(struct udevice *dev, int stage)
 {
int ret;
 
@@ -294,11 +316,11 @@ int clk_set_defaults(struct udevice *dev)
 
debug("%s(%s)\n", __func__, dev_read_name(dev));
 
-   ret = clk_set_default_parents(dev);
+   ret = clk_set_default_parents(dev, stage);
if (ret)
return ret;
 
-   ret = clk_set_default_rates(dev);
+   ret = clk_set_default_rates(dev, stage);
if (ret < 0)
return ret;
 
@@ -673,7 +695,21 @@ void devm_clk_put(struct udevice *dev, struct clk *clk)
WARN_ON(rc);
 }
 
+int clk_uclass_post_probe(struct udevice *dev)
+{
+   /*
+* when a clock provider is probed. Call clk_set_defaults()
+* also after the device is probed. This takes care of cases
+* where the DT is used to setup default parents and rates
+* using assigned-clocks
+*/
+   clk_set_defaults(dev, 1);
+
+   return 0;
+}
+
 UCLASS_DRIVER(clk) = {
.id = UCLASS_CLK,
.name   = "clk",
+   .post_probe = clk_uclass_post_probe,
 };
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 05dadf98f9..cbcbb1b15d 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -416,7 +416,7 @@ int device_probe(struct udevice *dev)
 * Process 'assigned-{clocks/clock-parents/clock-rates}'
 * properties
 */
-   ret = clk_set_defaults(dev);
+   ret = clk_set_defaults(dev, 0);
if (ret)
goto fail;
}
diff --git a/include/clk.h b/include/clk.h
index 

[U-Boot] [PATCH v1 5/5] test: clk: test clock self assignment

2019-09-30 Thread Jean-Jacques Hiblot
Make sure that the clock self-assignment works by having a clock of
clk-sbox be configured automatically when clk-sbox is probed.

Signed-off-by: Jean-Jacques Hiblot 

---

 arch/sandbox/dts/test.dts |  2 ++
 drivers/clk/clk_sandbox.c | 22 ++
 test/dm/clk.c |  4 ++--
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 25c238d8e5..0917255476 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -222,6 +222,8 @@
clk_sandbox: clk-sbox {
compatible = "sandbox,clk";
#clock-cells = <1>;
+   assigned-clocks = <_sandbox 3>;
+   assigned-clock-rates = <321>;
};
 
clk-test {
diff --git a/drivers/clk/clk_sandbox.c b/drivers/clk/clk_sandbox.c
index d152fd7e5b..de6b2f7c82 100644
--- a/drivers/clk/clk_sandbox.c
+++ b/drivers/clk/clk_sandbox.c
@@ -10,6 +10,7 @@
 #include 
 
 struct sandbox_clk_priv {
+   bool probed;
ulong rate[SANDBOX_CLK_ID_COUNT];
bool enabled[SANDBOX_CLK_ID_COUNT];
bool requested[SANDBOX_CLK_ID_COUNT];
@@ -19,6 +20,9 @@ static ulong sandbox_clk_get_rate(struct clk *clk)
 {
struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
 
+   if (!priv->probed)
+   return -ENODEV;
+
if (clk->id >= SANDBOX_CLK_ID_COUNT)
return -EINVAL;
 
@@ -30,6 +34,9 @@ static ulong sandbox_clk_set_rate(struct clk *clk, ulong rate)
struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
ulong old_rate;
 
+   if (!priv->probed)
+   return -ENODEV;
+
if (clk->id >= SANDBOX_CLK_ID_COUNT)
return -EINVAL;
 
@@ -46,6 +53,9 @@ static int sandbox_clk_enable(struct clk *clk)
 {
struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
 
+   if (!priv->probed)
+   return -ENODEV;
+
if (clk->id >= SANDBOX_CLK_ID_COUNT)
return -EINVAL;
 
@@ -58,6 +68,9 @@ static int sandbox_clk_disable(struct clk *clk)
 {
struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
 
+   if (!priv->probed)
+   return -ENODEV;
+
if (clk->id >= SANDBOX_CLK_ID_COUNT)
return -EINVAL;
 
@@ -97,6 +110,14 @@ static struct clk_ops sandbox_clk_ops = {
.free   = sandbox_clk_free,
 };
 
+static int sandbox_clk_probe(struct udevice *dev)
+{
+   struct sandbox_clk_priv *priv = dev_get_priv(dev);
+
+   priv->probed = true;
+   return 0;
+}
+
 static const struct udevice_id sandbox_clk_ids[] = {
{ .compatible = "sandbox,clk" },
{ }
@@ -107,6 +128,7 @@ U_BOOT_DRIVER(clk_sandbox) = {
.id = UCLASS_CLK,
.of_match   = sandbox_clk_ids,
.ops= _clk_ops,
+   .probe  = sandbox_clk_probe,
.priv_auto_alloc_size = sizeof(struct sandbox_clk_priv),
 };
 
diff --git a/test/dm/clk.c b/test/dm/clk.c
index 3ad0ad8ca3..31335a543f 100644
--- a/test/dm/clk.c
+++ b/test/dm/clk.c
@@ -74,8 +74,8 @@ static int dm_test_clk(struct unit_test_state *uts)
 SANDBOX_CLK_TEST_ID_SPI));
ut_asserteq(0, sandbox_clk_test_get_rate(dev_test,
 SANDBOX_CLK_TEST_ID_I2C));
-   ut_asserteq(0, sandbox_clk_test_get_rate(dev_test,
-SANDBOX_CLK_TEST_ID_DEVM1));
+   ut_asserteq(321, sandbox_clk_test_get_rate(dev_test,
+  SANDBOX_CLK_TEST_ID_DEVM1));
ut_asserteq(0, sandbox_clk_test_get_rate(dev_test,
 SANDBOX_CLK_TEST_ID_DEVM2));
 
-- 
2.17.1

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


[U-Boot] [PATCH v1 1/5] drivers: clk: Handle gracefully NULL pointers

2019-09-30 Thread Jean-Jacques Hiblot
Prepare the way for a managed CLK API by handling NULL pointers without
crashing nor failing.

Signed-off-by: Jean-Jacques Hiblot 
---

 drivers/clk/clk-uclass.c | 43 +---
 include/clk.h|  2 +-
 2 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 64c181f4ad..dff395fedb 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -349,9 +349,12 @@ int clk_release_all(struct clk *clk, int count)
 
 int clk_request(struct udevice *dev, struct clk *clk)
 {
-   const struct clk_ops *ops = clk_dev_ops(dev);
+   const struct clk_ops *ops;
 
debug("%s(dev=%p, clk=%p)\n", __func__, dev, clk);
+   if (!clk)
+   return 0;
+   ops = clk_dev_ops(dev);
 
clk->dev = dev;
 
@@ -363,9 +366,12 @@ int clk_request(struct udevice *dev, struct clk *clk)
 
 int clk_free(struct clk *clk)
 {
-   const struct clk_ops *ops = clk_dev_ops(clk->dev);
+   const struct clk_ops *ops;
 
debug("%s(clk=%p)\n", __func__, clk);
+   if (!clk)
+   return 0;
+   ops = clk_dev_ops(clk->dev);
 
if (!ops->free)
return 0;
@@ -375,9 +381,12 @@ int clk_free(struct clk *clk)
 
 ulong clk_get_rate(struct clk *clk)
 {
-   const struct clk_ops *ops = clk_dev_ops(clk->dev);
+   const struct clk_ops *ops;
 
debug("%s(clk=%p)\n", __func__, clk);
+   if (!clk)
+   return 0;
+   ops = clk_dev_ops(clk->dev);
 
if (!ops->get_rate)
return -ENOSYS;
@@ -391,6 +400,8 @@ struct clk *clk_get_parent(struct clk *clk)
struct clk *pclk;
 
debug("%s(clk=%p)\n", __func__, clk);
+   if (!clk)
+   return NULL;
 
pdev = dev_get_parent(clk->dev);
pclk = dev_get_clk_ptr(pdev);
@@ -406,6 +417,8 @@ long long clk_get_parent_rate(struct clk *clk)
struct clk *pclk;
 
debug("%s(clk=%p)\n", __func__, clk);
+   if (!clk)
+   return 0;
 
pclk = clk_get_parent(clk);
if (IS_ERR(pclk))
@@ -424,9 +437,12 @@ long long clk_get_parent_rate(struct clk *clk)
 
 ulong clk_set_rate(struct clk *clk, ulong rate)
 {
-   const struct clk_ops *ops = clk_dev_ops(clk->dev);
+   const struct clk_ops *ops;
 
debug("%s(clk=%p, rate=%lu)\n", __func__, clk, rate);
+   if (!clk)
+   return 0;
+   ops = clk_dev_ops(clk->dev);
 
if (!ops->set_rate)
return -ENOSYS;
@@ -436,9 +452,12 @@ ulong clk_set_rate(struct clk *clk, ulong rate)
 
 int clk_set_parent(struct clk *clk, struct clk *parent)
 {
-   const struct clk_ops *ops = clk_dev_ops(clk->dev);
+   const struct clk_ops *ops;
 
debug("%s(clk=%p, parent=%p)\n", __func__, clk, parent);
+   if (!clk)
+   return 0;
+   ops = clk_dev_ops(clk->dev);
 
if (!ops->set_parent)
return -ENOSYS;
@@ -448,11 +467,14 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
 
 int clk_enable(struct clk *clk)
 {
-   const struct clk_ops *ops = clk_dev_ops(clk->dev);
+   const struct clk_ops *ops;
struct clk *clkp = NULL;
int ret;
 
debug("%s(clk=%p)\n", __func__, clk);
+   if (!clk)
+   return 0;
+   ops = clk_dev_ops(clk->dev);
 
if (CONFIG_IS_ENABLED(CLK_CCF)) {
/* Take id 0 as a non-valid clk, such as dummy */
@@ -505,11 +527,14 @@ int clk_enable_bulk(struct clk_bulk *bulk)
 
 int clk_disable(struct clk *clk)
 {
-   const struct clk_ops *ops = clk_dev_ops(clk->dev);
+   const struct clk_ops *ops;
struct clk *clkp = NULL;
int ret;
 
debug("%s(clk=%p)\n", __func__, clk);
+   if (!clk)
+   return 0;
+   ops = clk_dev_ops(clk->dev);
 
if (CONFIG_IS_ENABLED(CLK_CCF)) {
if (clk->id && !clk_get_by_id(clk->id, )) {
@@ -589,6 +614,10 @@ bool clk_is_match(const struct clk *p, const struct clk *q)
if (p == q)
return true;
 
+   /* trivial case #2: on the clk pointer is NULL */
+   if (!p || !q)
+   return false;
+
/* same device, id and data */
if (p->dev == q->dev && p->id == q->id && p->data == q->data)
return true;
diff --git a/include/clk.h b/include/clk.h
index 18b2e3ca54..6568865d40 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -356,7 +356,7 @@ int soc_clk_dump(void);
  */
 static inline bool clk_valid(struct clk *clk)
 {
-   return !!clk->dev;
+   return clk && !!clk->dev;
 }
 
 /**
-- 
2.17.1

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


[U-Boot] [PATCH v1 0/5] clk: Add a managed API and fix clock self-assignment

2019-09-30 Thread Jean-Jacques Hiblot

This is the second of a few series, the goal of which is to facilitate
porting drivers from the linux kernel. Most of the series will be about
adding managed API to existing infrastructure (GPIO, reset, phy,...)

This particular series is about clocks. It adds a managed API, using
the same API as linux. It also fix a use-case where the clock is
initialized (rate and/or mux) when it is probed using the
assigned-clocks-* properties.

JJ

Jean-Jacques Hiblot (5):
  drivers: clk: Handle gracefully NULL pointers
  drivers: clk: Add a managed API to get clocks from the device-tree
  test: clk: Update tests to also check the managed API
  drivers: clk: Fix using assigned-clocks in the node of the clock it
sets up
  test: clk: test clock self assignment

 arch/sandbox/dts/test.dts  |   8 +-
 arch/sandbox/include/asm/clk.h |  33 
 drivers/clk/clk-uclass.c   | 139 ++---
 drivers/clk/clk_sandbox.c  |  56 +
 drivers/clk/clk_sandbox_test.c |  66 +---
 drivers/core/device.c  |   2 +-
 include/clk.h  |  53 -
 test/dm/clk.c  |  36 -
 8 files changed, 364 insertions(+), 29 deletions(-)

-- 
2.17.1

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


[U-Boot] [PATCH v1 2/5] drivers: clk: Add a managed API to get clocks from the device-tree

2019-09-30 Thread Jean-Jacques Hiblot
Add devm_clk_get(), devm_clk_get_optional() to get clocks from the
device-tree. The clocks is automatically released and the data structure
freed when the device is unbound.
Also add devm_clk_put() to release the clock and free the data structure
manually.

Signed-off-by: Jean-Jacques Hiblot 
---

 drivers/clk/clk-uclass.c | 48 
 include/clk.h| 44 
 2 files changed, 92 insertions(+)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index dff395fedb..e7ec6347de 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -625,6 +625,54 @@ bool clk_is_match(const struct clk *p, const struct clk *q)
return false;
 }
 
+static void devm_clk_release(struct udevice *dev, void *res)
+{
+   clk_free(res);
+}
+
+static int devm_clk_match(struct udevice *dev, void *res, void *data)
+{
+   return res == data;
+}
+
+struct clk *devm_clk_get(struct udevice *dev, const char *id)
+{
+   int rc;
+   struct clk *clk;
+
+   clk = devres_alloc(devm_clk_release, sizeof(struct clk), __GFP_ZERO);
+   if (unlikely(!clk))
+   return ERR_PTR(-ENOMEM);
+
+   rc = clk_get_by_name(dev, id, clk);
+   if (rc)
+   return ERR_PTR(rc);
+
+   devres_add(dev, clk);
+   return clk;
+}
+
+struct clk *devm_clk_get_optional(struct udevice *dev, const char *id)
+{
+   struct clk *clk = devm_clk_get(dev, id);
+
+   if (IS_ERR(clk))
+   return NULL;
+
+   return clk;
+}
+
+void devm_clk_put(struct udevice *dev, struct clk *clk)
+{
+   int rc;
+
+   if (!clk)
+   return;
+
+   rc = devres_release(dev, devm_clk_release, devm_clk_match, clk);
+   WARN_ON(rc);
+}
+
 UCLASS_DRIVER(clk) = {
.id = UCLASS_CLK,
.name   = "clk",
diff --git a/include/clk.h b/include/clk.h
index 6568865d40..6c5bf8ad67 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -154,6 +154,37 @@ int clk_get_bulk(struct udevice *dev, struct clk_bulk 
*bulk);
  */
 int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk);
 
+/**
+ * devm_clk_get - lookup and obtain a managed reference to a clock producer.
+ * @dev: device for clock "consumer"
+ * @id: clock consumer ID
+ *
+ * Returns a struct clk corresponding to the clock producer, or
+ * valid IS_ERR() condition containing errno.  The implementation
+ * uses @dev and @id to determine the clock consumer, and thereby
+ * the clock producer.  (IOW, @id may be identical strings, but
+ * clk_get may return different clock producers depending on @dev.)
+ *
+ * Drivers must assume that the clock source is not enabled.
+ *
+ * devm_clk_get should not be called from within interrupt context.
+ *
+ * The clock will automatically be freed when the device is unbound
+ * from the bus.
+ */
+struct clk *devm_clk_get(struct udevice *dev, const char *id);
+
+/**
+ * devm_clk_get_optional - lookup and obtain a managed reference to an optional
+ *clock producer.
+ * @dev: device for clock "consumer"
+ * @id: clock consumer ID
+ *
+ * Behaves the same as devm_clk_get() except where there is no clock producer.
+ * In this case, instead of returning -ENOENT, the function returns NULL.
+ */
+struct clk *devm_clk_get_optional(struct udevice *dev, const char *id);
+
 /**
  * clk_release_all() - Disable (turn off)/Free an array of previously
  * requested clocks.
@@ -168,6 +199,19 @@ int clk_get_by_name(struct udevice *dev, const char *name, 
struct clk *clk);
  */
 int clk_release_all(struct clk *clk, int count);
 
+/**
+ * devm_clk_put- "free" a managed clock source
+ * @dev: device used to acquire the clock
+ * @clk: clock source acquired with devm_clk_get()
+ *
+ * Note: drivers must ensure that all clk_enable calls made on this
+ * clock source are balanced by clk_disable calls prior to calling
+ * this function.
+ *
+ * clk_put should not be called from within interrupt context.
+ */
+void devm_clk_put(struct udevice *dev, struct clk *clk);
+
 #else
 static inline int clk_get_by_index(struct udevice *dev, int index,
   struct clk *clk)
-- 
2.17.1

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


[U-Boot] [PATCH v1 3/5] test: clk: Update tests to also check the managed API

2019-09-30 Thread Jean-Jacques Hiblot
Add a few more clocks the clk_sandbox clock provider and get them using
the managed API.
Make sure they are released when the device is removed.

Signed-off-by: Jean-Jacques Hiblot 
---

 arch/sandbox/dts/test.dts  |  6 ++--
 arch/sandbox/include/asm/clk.h | 33 +
 drivers/clk/clk_sandbox.c  | 34 ++
 drivers/clk/clk_sandbox_test.c | 66 +-
 test/dm/clk.c  | 36 ++-
 5 files changed, 163 insertions(+), 12 deletions(-)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 27b0baab27..25c238d8e5 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -228,8 +228,10 @@
compatible = "sandbox,clk-test";
clocks = <_fixed>,
 <_sandbox 1>,
-<_sandbox 0>;
-   clock-names = "fixed", "i2c", "spi";
+<_sandbox 0>,
+<_sandbox 3>,
+<_sandbox 2>;
+   clock-names = "fixed", "i2c", "spi", "uart2", "uart1";
};
 
ccf: clk-ccf {
diff --git a/arch/sandbox/include/asm/clk.h b/arch/sandbox/include/asm/clk.h
index 2b1c49f783..1573e4a134 100644
--- a/arch/sandbox/include/asm/clk.h
+++ b/arch/sandbox/include/asm/clk.h
@@ -19,6 +19,8 @@ struct udevice;
 enum sandbox_clk_id {
SANDBOX_CLK_ID_SPI,
SANDBOX_CLK_ID_I2C,
+   SANDBOX_CLK_ID_UART1,
+   SANDBOX_CLK_ID_UART2,
 
SANDBOX_CLK_ID_COUNT,
 };
@@ -33,10 +35,15 @@ enum sandbox_clk_test_id {
SANDBOX_CLK_TEST_ID_FIXED,
SANDBOX_CLK_TEST_ID_SPI,
SANDBOX_CLK_TEST_ID_I2C,
+   SANDBOX_CLK_TEST_ID_DEVM1,
+   SANDBOX_CLK_TEST_ID_DEVM2,
+   SANDBOX_CLK_TEST_ID_DEVM_NULL,
 
SANDBOX_CLK_TEST_ID_COUNT,
 };
 
+#define SANDBOX_CLK_TEST_NON_DEVM_COUNT SANDBOX_CLK_TEST_ID_DEVM1
+
 /**
  * sandbox_clk_query_rate - Query the current rate of a sandbox clock.
  *
@@ -53,6 +60,14 @@ ulong sandbox_clk_query_rate(struct udevice *dev, int id);
  * @return:The rate of the clock.
  */
 int sandbox_clk_query_enable(struct udevice *dev, int id);
+/**
+ * sandbox_clk_query_requested - Query the requested state of a sandbox clock.
+ *
+ * @dev:   The sandbox clock provider device.
+ * @id:The clock to query.
+ * @return:The rate of the clock.
+ */
+int sandbox_clk_query_requested(struct udevice *dev, int id);
 
 /**
  * sandbox_clk_test_get - Ask the sandbox clock test device to request its
@@ -62,6 +77,16 @@ int sandbox_clk_query_enable(struct udevice *dev, int id);
  * @return:0 if OK, or a negative error code.
  */
 int sandbox_clk_test_get(struct udevice *dev);
+
+/**
+ * sandbox_clk_test_devm_get - Ask the sandbox clock test device to request its
+ * clocks using the managed API.
+ *
+ * @dev:   The sandbox clock test (client) devivce.
+ * @return:0 if OK, or a negative error code.
+ */
+int sandbox_clk_test_devm_get(struct udevice *dev);
+
 /**
  * sandbox_clk_test_get_bulk - Ask the sandbox clock test device to request its
  * clocks with the bulk clk API.
@@ -146,5 +171,13 @@ int sandbox_clk_test_release_bulk(struct udevice *dev);
  * @return:0 if OK, or a negative error code.
  */
 int sandbox_clk_test_valid(struct udevice *dev);
+/**
+ * sandbox_clk_test_valid - Ask the sandbox clock test device to check its
+ * clocks are valid.
+ *
+ * @dev:   The sandbox clock test (client) devivce.
+ * @return:0 if OK, or a negative error code.
+ */
+struct clk *sandbox_clk_test_get_devm_clk(struct udevice *dev, int id);
 
 #endif
diff --git a/drivers/clk/clk_sandbox.c b/drivers/clk/clk_sandbox.c
index 1d5cbb589a..d152fd7e5b 100644
--- a/drivers/clk/clk_sandbox.c
+++ b/drivers/clk/clk_sandbox.c
@@ -12,6 +12,7 @@
 struct sandbox_clk_priv {
ulong rate[SANDBOX_CLK_ID_COUNT];
bool enabled[SANDBOX_CLK_ID_COUNT];
+   bool requested[SANDBOX_CLK_ID_COUNT];
 };
 
 static ulong sandbox_clk_get_rate(struct clk *clk)
@@ -65,11 +66,35 @@ static int sandbox_clk_disable(struct clk *clk)
return 0;
 }
 
+static int sandbox_clk_request(struct clk *clk)
+{
+   struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
+
+   if (clk->id >= SANDBOX_CLK_ID_COUNT)
+   return -EINVAL;
+
+   priv->requested[clk->id] = true;
+   return 0;
+}
+
+static int sandbox_clk_free(struct clk *clk)
+{
+   struct sandbox_clk_priv *priv = dev_get_priv(clk->dev);
+
+   if (clk->id >= SANDBOX_CLK_ID_COUNT)
+   return -EINVAL;
+
+   priv->requested[clk->id] = false;
+   return 0;
+}
+
 static struct clk_ops sandbox_clk_ops = {
.get_rate   = sandbox_clk_get_rate,
.set_rate   = sandbox_clk_set_rate,
.enable = sandbox_clk_enable,
.disable= sandbox_clk_disable,
+   .request= sandbox_clk_request,
+   .free   = sandbox_clk_free,
 };
 
 static const struct 

[U-Boot] [PATCH] cmd: memio: Add support functions to read/write data

2019-09-30 Thread kameyama eiji
The existing source code (binop.c) includes read/write function to
read/write data on DDR. To use these functions and avoid duplicate code,
based on the existing functions, move and update the read/write function
to a public file which is memio file.
- New memio includes support functions to read/write data from/to DDR.
- Update binop.c file to use read/write functions.

Signed-off-by: Dao Van Trung 
Signed-off-by: Pham Duc Tung 
Signed-off-by: kameyama eiji 
---
 cmd/Makefile|  1 +
 cmd/binop.c | 24 +++-
 cmd/memio.c | 42 ++
 include/memio.h | 16 
 4 files changed, 62 insertions(+), 21 deletions(-)
 create mode 100644 cmd/memio.c
 create mode 100644 include/memio.h

diff --git a/cmd/Makefile b/cmd/Makefile
index ac843b4b16..8c241b256e 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -86,6 +86,7 @@ obj-$(CONFIG_CMD_LOG) += log.o
 obj-$(CONFIG_ID_EEPROM) += mac.o
 obj-$(CONFIG_CMD_MD5SUM) += md5sum.o
 obj-$(CONFIG_CMD_MEMORY) += mem.o
+obj-y += memio.o
 obj-$(CONFIG_CMD_IO) += io.o
 obj-$(CONFIG_CMD_MFSL) += mfsl.o
 obj-$(CONFIG_CMD_MII) += mii.o
diff --git a/cmd/binop.c b/cmd/binop.c
index 6d2df5f3dd..c14ca09fc3 100644
--- a/cmd/binop.c
+++ b/cmd/binop.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 
 enum {
OP_ID_XOR,
@@ -44,26 +45,6 @@ void read_from_env_var(char *varname, u8 *result)
hex2bin(result, varname, strlen(varname) / 2);
 }
 
-void read_from_mem(ulong addr, u8 *result, ulong len)
-{
-   u8 *src;
-
-   src = map_sysmem(addr, len);
-   memcpy(result, src, len);
-   unmap_sysmem(src);
-}
-
-void write_to_mem(char *varname, u8 *result, ulong len)
-{
-   ulong addr;
-   u8 *buf;
-
-   addr = simple_strtoul(varname, NULL, 16);
-   buf = map_sysmem(addr, len);
-   memcpy(buf, result, len);
-   unmap_sysmem(buf);
-}
-
 static int do_binop(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
ulong len;
@@ -134,7 +115,8 @@ static int do_binop(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
destarg = argv[5];
 
if (*destarg == '*')
-   write_to_mem(destarg + 1, result, len); /* Skip asterisk */
+   write_to_mem(simple_strtoul(destarg + 1, NULL, 16),
+result, len); /* Skip asterisk */
else
write_to_env_var(destarg, result, len);
 exit:
diff --git a/cmd/memio.c b/cmd/memio.c
new file mode 100644
index 00..b9da5e5294
--- /dev/null
+++ b/cmd/memio.c
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * cmd/memio.c
+ * Support functions to read/write data from/to DDR
+ * physical address.
+ *
+ * Copyright (C) 2019 FUJITSU VIETNAM LIMITED and FUJITSU COMPUTER
+ * TECHNOLOGIES LIMITED. All rights reserved.
+ */
+#include 
+#include 
+#include 
+
+/**
+ * read_from_mem() - Read data from DDR
+ * @addr:  Physical address on DDR
+ * @result:Buffer for read data
+ * @len:   Data length
+ */
+void read_from_mem(ulong addr, u8 *result, ulong len)
+{
+   u8 *src;
+
+   src = map_sysmem(addr, len);
+   memcpy(result, src, len);
+   unmap_sysmem(src);
+}
+
+/**
+ * write_to_mem() - Write data to DDR
+ * @addr:  Physical address on DDR
+ * @result:Buffer of write data
+ * @len:   Data length
+ */
+void write_to_mem(ulong addr, u8 *result, ulong len)
+{
+   u8 *buf;
+
+   buf = map_sysmem(addr, len);
+   memcpy(buf, result, len);
+   unmap_sysmem(buf);
+}
diff --git a/include/memio.h b/include/memio.h
new file mode 100644
index 00..c5f397393b
--- /dev/null
+++ b/include/memio.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * include/memio.h
+ * This file declares support functions to read/write from/to
+ * DDR physical address.
+ *
+ * Copyright (C) 2019 FUJITSU VIETNAM LIMITED and FUJITSU COMPUTER
+ * TECHNOLOGIES LIMITED. All rights reserved.
+ */
+#ifndef _MEMIO_H_
+#define _MEMIO_H_
+
+void read_from_mem(ulong addr, u8 *result, ulong len);
+void write_to_mem(ulong addr, u8 *result, ulong len);
+
+#endif /* _MEMIO_H_ */
-- 
2.20.1

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


[U-Boot] [PATCH v2] watchdog: move WATCHDOG_TIMEOUT_MSECS to Kconfig

2019-09-30 Thread Heiko Schocher
move WATCHDOG_TIMEOUT_MSECS to Kconfig and fix
all board defconfigs.

Signed-off-by: Heiko Schocher 
Reviewed-by: Stefan Roese 
Acked-by: Lukasz Majewski 
Acked-by: Martyn Welch 
---

Patchseries build fine on travis see:
https://travis-ci.org/hsdenx/u-boot-test/builds/591305674

Based on mainline commit:
d88eab4bcc: ("efi_loader: SetVariable() deleting variables")


Changes in v2:
- add Reviewed-by tag from Stefan
- add Acked-by tag from Lukasz and Martin
- rebased to
  d88eab4bcc: ("efi_loader: SetVariable() deleting variables")
  Sorry to Stefan, who had requested a rebase and I missed
  the EMail...

 arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 | 1 -
 configs/dh_imx6_defconfig  | 1 +
 configs/display5_defconfig | 1 +
 configs/display5_factory_defconfig | 1 +
 configs/ge_bx50v3_defconfig| 1 +
 configs/kp_imx6q_tpc_defconfig | 1 +
 configs/m53menlo_defconfig | 1 +
 configs/mx53ppd_defconfig  | 1 +
 configs/tqma6s_wru4_mmc_defconfig  | 1 +
 configs/warp_defconfig | 1 +
 drivers/watchdog/Kconfig   | 9 +
 include/configs/dh_imx6.h  | 1 -
 include/configs/display5.h | 1 -
 include/configs/ge_bx50v3.h| 2 --
 include/configs/kp_imx6q_tpc.h | 1 -
 include/configs/m53menlo.h | 1 -
 include/configs/mx53ppd.h  | 2 --
 include/configs/socfpga_common.h   | 1 -
 include/configs/socfpga_stratix10_socdk.h  | 1 -
 include/configs/tqma6_wru4.h   | 1 -
 include/configs/warp.h | 1 -
 scripts/config_whitelist.txt   | 1 -
 22 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2 
b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2
index 9583bf743e..d7f7b9f111 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2
+++ b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.lsch2
@@ -16,6 +16,5 @@ You can enable it by setting CONFIG_IMX_WATCHDOG.
 Use following config to set watchdog timeout, if this config is not defined,
 the default timeout value is 128s which is the maximum. Set 10 seconds for
 example:
-#define CONFIG_WATCHDOG_TIMEOUT_MSECS 1
 Set CONFIG_WATCHDOG_RESET_DISABLE to disable reset watchdog, so that the
 watchdog will not be fed in u-boot.
diff --git a/configs/dh_imx6_defconfig b/configs/dh_imx6_defconfig
index f459af07f8..db4753c5c7 100644
--- a/configs/dh_imx6_defconfig
+++ b/configs/dh_imx6_defconfig
@@ -85,4 +85,5 @@ CONFIG_USB_GADGET_VENDOR_NUM=0x0525
 CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_WATCHDOG_TIMEOUT_MSECS=6
 CONFIG_IMX_WATCHDOG=y
diff --git a/configs/display5_defconfig b/configs/display5_defconfig
index e48b6467e6..fdabd31c90 100644
--- a/configs/display5_defconfig
+++ b/configs/display5_defconfig
@@ -82,4 +82,5 @@ CONFIG_MII=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_MXC_SPI=y
+CONFIG_WATCHDOG_TIMEOUT_MSECS=15000
 CONFIG_IMX_WATCHDOG=y
diff --git a/configs/display5_factory_defconfig 
b/configs/display5_factory_defconfig
index 5b79057074..d403ad9480 100644
--- a/configs/display5_factory_defconfig
+++ b/configs/display5_factory_defconfig
@@ -87,5 +87,6 @@ CONFIG_USB_GADGET_VENDOR_NUM=0x1b67
 CONFIG_USB_GADGET_PRODUCT_NUM=0x4000
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_WATCHDOG_TIMEOUT_MSECS=15000
 CONFIG_IMX_WATCHDOG=y
 CONFIG_OF_LIBFDT=y
diff --git a/configs/ge_bx50v3_defconfig b/configs/ge_bx50v3_defconfig
index 735165916a..75fdbf7e72 100644
--- a/configs/ge_bx50v3_defconfig
+++ b/configs/ge_bx50v3_defconfig
@@ -61,5 +61,6 @@ CONFIG_DM_SPI=y
 CONFIG_MXC_SPI=y
 CONFIG_DM_VIDEO=y
 CONFIG_VIDEO_IPUV3=y
+CONFIG_WATCHDOG_TIMEOUT_MSECS=6000
 CONFIG_IMX_WATCHDOG=y
 # CONFIG_EFI_LOADER is not set
diff --git a/configs/kp_imx6q_tpc_defconfig b/configs/kp_imx6q_tpc_defconfig
index 75dd9d7c7a..fdfb899903 100644
--- a/configs/kp_imx6q_tpc_defconfig
+++ b/configs/kp_imx6q_tpc_defconfig
@@ -41,5 +41,6 @@ CONFIG_FEC_MXC=y
 CONFIG_MII=y
 CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
+CONFIG_WATCHDOG_TIMEOUT_MSECS=6
 CONFIG_IMX_WATCHDOG=y
 CONFIG_OF_LIBFDT=y
diff --git a/configs/m53menlo_defconfig b/configs/m53menlo_defconfig
index 50047952a7..7e5bcf94b9 100644
--- a/configs/m53menlo_defconfig
+++ b/configs/m53menlo_defconfig
@@ -89,4 +89,5 @@ CONFIG_DM_VIDEO=y
 CONFIG_SYS_WHITE_ON_BLACK=y
 CONFIG_VIDEO_IPUV3=y
 CONFIG_IMX_WATCHDOG=y
+CONFIG_WATCHDOG_TIMEOUT_MSECS=8000
 CONFIG_FAT_WRITE=y
diff --git a/configs/mx53ppd_defconfig b/configs/mx53ppd_defconfig
index cad798a416..7f293c8e9a 100644
--- a/configs/mx53ppd_defconfig
+++ b/configs/mx53ppd_defconfig
@@ -50,4 +50,5 @@ CONFIG_USB_EHCI_MX5=y
 CONFIG_VIDEO_IPUV3=y
 

[U-Boot] [PATCH] tao3530: Fix usage of mmc rescan

2019-09-30 Thread Jarkko Nikula
Currently "bootcmd" does not work as intended but instead prints MMC usage
information and goes directly to "nandboot".

Follow what the commit 669681104daa ("configs: Fix usage of mmc rescan")
does for other boards prior to support for TechNexion TAO3530 SoM was
added.

Signed-off-by: Jarkko Nikula 
---
 include/configs/tao3530.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/tao3530.h b/include/configs/tao3530.h
index c34e785d9e55..5f75eed4c0e7 100644
--- a/include/configs/tao3530.h
+++ b/include/configs/tao3530.h
@@ -114,7 +114,7 @@
"bootm ${loadaddr}\0" \
 
 #define CONFIG_BOOTCOMMAND \
-   "if mmc rescan ${mmcdev}; then " \
+   "mmc dev $(mmcdev); if mmc rescan; then " \
"if run loadbootscript; then " \
"run bootscript; " \
"else " \
-- 
2.23.0

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


[U-Boot] [PATCH 1/1] board/freescale/ls1028a: Secure boot: Adds sec_init call.

2019-09-30 Thread Udit Agarwal
Adds sec_init call to initialise the job ring parameters
for secure boot operations.

Signed-off-by: Udit Agarwal 
---
 board/freescale/ls1028a/ls1028a.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/board/freescale/ls1028a/ls1028a.c 
b/board/freescale/ls1028a/ls1028a.c
index 6b126bcf44..a92b5b1079 100644
--- a/board/freescale/ls1028a/ls1028a.c
+++ b/board/freescale/ls1028a/ls1028a.c
@@ -64,6 +64,10 @@ int board_init(void)
gd->env_addr = (ulong)_environment[0];
 #endif
 
+#ifdef CONFIG_FSL_CAAM
+   sec_init();
+#endif
+
 #ifdef CONFIG_FSL_LS_PPA
ppa_init();
 #endif
-- 
2.17.1

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


Re: [U-Boot] [PATCH 3/5] mtd: spi-nor: ids: Add is25wp256 chip

2019-09-30 Thread Bin Meng
On Sun, Sep 29, 2019 at 3:43 PM Jagan Teki  wrote:
>
> Add is25wp256, chip to spi-nor id table.
>
> Tested on Sifive fuse540 board.

Should be: SiFive FU540

>
> Signed-off-by: Jagan Teki 
> ---
>  drivers/mtd/spi/spi-nor-ids.c | 2 ++
>  1 file changed, 2 insertions(+)
>

Reviewed-by: Bin Meng 
Tested-by: Bin Meng 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 4/5] riscv: dts: hifive-unleashed-a00: Add -u-boot.dtsi

2019-09-30 Thread Bin Meng
Hi Jagan,

On Sun, Sep 29, 2019 at 3:43 PM Jagan Teki  wrote:
>
> Add u-boot specific dts file for hifive-unleashed-a00, this
> would help to add u-boot specific properties and other node
> changes without touching the base dts(i) files which are easy
> to sync from Linux.
>
> Added spi2 alias for qspi2 as an initial u-boot specific
> property change.
>
> spi probing in current dm model is very much rely on aliases
> numbering. even though the qspi2 can't comes under any associated
> spi nor flash it would require to specify the same to make proper
> binding happen for other spi slaves.
>
> Signed-off-by: Jagan Teki 
> ---
>  arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi | 10 ++
>  1 file changed, 10 insertions(+)
>  create mode 100644 arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
>
> 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..25ec8265a5
> --- /dev/null
> +++ b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi
> @@ -0,0 +1,10 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2019 Jagan Teki 
> + */
> +
> +/ {
> +   aliases {
> +   spi2 = 

With the following 2 patches, this is no longer needed for SPI.

http://patchwork.ozlabs.org/patch/1158960/
http://patchwork.ozlabs.org/patch/1158961/

> +   };
> +};
> --

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


  1   2   >