Re: [U-Boot] [PATCH v2 3/6] usb: dwc3: Add generic DWC3 glue logic driver

2018-05-20 Thread Michal Simek
On 18.5.2018 15:26, Jean-Jacques Hiblot wrote:
> 
> 
> On 18/05/2018 15:24, Jean-Jacques Hiblot wrote:
>>
>>
>> On 18/05/2018 13:15, Michal Simek wrote:
>>> By enabling BLK by default this is the next driver which needs to get
>>> support for DM_USB. Adding generic DWC3 glue logic which only
>>> parse nodes and read device mode. Based on it probe proper
>>> host/peripheral DWC3 drivers for it.
>>>
>>> Signed-off-by: Michal Simek 
>>> ---
>>>
>>> Changes in v2:
>>> - Change style to avoid correct but not nice indentation by using char
>>>    *driver variable (suggested by Marek)
>>>
>>>   drivers/usb/dwc3/Kconfig    |   6 ++
>>>   drivers/usb/dwc3/Makefile   |   1 +
>>>   drivers/usb/dwc3/dwc3-generic.c | 157 
>>>   3 files changed, 164 insertions(+)
>>>   create mode 100644 drivers/usb/dwc3/dwc3-generic.c
>>>
>>> diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
>>> index ae7fc1c6304d..943b7630eba4 100644
>>> --- a/drivers/usb/dwc3/Kconfig
>>> +++ b/drivers/usb/dwc3/Kconfig
>>> @@ -37,6 +37,12 @@ config USB_DWC3_OMAP
>>>       Say 'Y' here if you have one such device
>>>   +config USB_DWC3_GENERIC
>>> +    bool "Xilinx ZynqMP and similar Platforms"
>>> +    depends on DM_USB && USB_DWC3
>>> +    help
>>> +  Some platforms can reuse this DWC3 generic implementation.
>>> +
>>>   config USB_DWC3_UNIPHIER
>>>   bool "DesignWare USB3 Host Support on UniPhier Platforms"
>>>   depends on ARCH_UNIPHIER && USB_XHCI_DWC3
>>> diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
>>> index cd18b8d9ec02..60b5515a67da 100644
>>> --- a/drivers/usb/dwc3/Makefile
>>> +++ b/drivers/usb/dwc3/Makefile
>>> @@ -7,6 +7,7 @@ dwc3-y    := core.o
>>>   obj-$(CONFIG_USB_DWC3_GADGET)    += gadget.o ep0.o
>>>     obj-$(CONFIG_USB_DWC3_OMAP)    += dwc3-omap.o
>>> +obj-$(CONFIG_USB_DWC3_GENERIC)    += dwc3-generic.o
>>>   obj-$(CONFIG_USB_DWC3_UNIPHIER)    += dwc3-uniphier.o
>>>   obj-$(CONFIG_USB_DWC3_PHY_OMAP)    += ti_usb_phy.o
>>>   obj-$(CONFIG_USB_DWC3_PHY_SAMSUNG)    += samsung_usb_phy.o
>>> diff --git a/drivers/usb/dwc3/dwc3-generic.c
>>> b/drivers/usb/dwc3/dwc3-generic.c
>>> new file mode 100644
>>> index ..ca63eac3d98e
>>> --- /dev/null
>>> +++ b/drivers/usb/dwc3/dwc3-generic.c
>>> @@ -0,0 +1,157 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +/*
>>> + * Generic DWC3 Glue layer
>>> + *
>>> + * Copyright (C) 2016 - 2018 Xilinx, Inc.
>>> + *
>>> + * Based on dwc3-omap.c.
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include "core.h"
>>> +#include "gadget.h"
>>> +#include "linux-compat.h"
>>> +
>>> +DECLARE_GLOBAL_DATA_PTR;
>>> +
>>> +int usb_gadget_handle_interrupts(int index)
>>> +{
>>> +    struct dwc3 *priv;
>>> +    struct udevice *dev;
>>> +    int ret;
>>> +
>>> +    ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, &dev);
>>> +    if (!dev || ret) {
>>> +    pr_err("No USB device found\n");
>>> +    return -ENODEV;
>>> +    }
>>> +
>>> +    priv = dev_get_priv(dev);
>>> +
>>> +    dwc3_gadget_uboot_handle_interrupt(priv);
>>> +
>>> +    return 0;
>>> +}
>>> +
>>> +static int dwc3_generic_peripheral_probe(struct udevice *dev)
>>> +{
>>> +    struct dwc3 *priv = dev_get_priv(dev);
>>> +
>>> +    return dwc3_init(priv);
>>> +}
>>> +
>>> +static int dwc3_generic_peripheral_remove(struct udevice *dev)
>>> +{
>>> +    struct dwc3 *priv = dev_get_priv(dev);
>>> +
>>> +    dwc3_remove(priv);
>>> +
>>> +    return 0;
>>> +}
>>> +
>>> +static int dwc3_generic_peripheral_ofdata_to_platdata(struct udevice
>>> *dev)
>>> +{
>>> +    struct dwc3 *priv = dev_get_priv(dev);
>>> +    int node = dev_of_offset(dev);
>>> +
>>> +    priv->regs = (void *)devfdt_get_addr(dev);
>>> +    priv->regs += DWC3_GLOBALS_REGS_START;
>>> +
>>> +    priv->maximum_speed = usb_get_maximum_speed(node);
>>> +    if (priv->maximum_speed == USB_SPEED_UNKNOWN) {
>>> +    pr_err("Invalid usb maximum speed\n");
>>> +    return -ENODEV;
>>> +    }
>>> +
>>> +    priv->dr_mode = usb_get_dr_mode(node);
>>> +    if (priv->dr_mode == USB_DR_MODE_UNKNOWN) {
>>> +    pr_err("Invalid usb mode setup\n");
>>> +    return -ENODEV;
>>> +    }
>>> +
>>> +    return 0;
>>> +}
>>> +
>>> +static int dwc3_generic_peripheral_bind(struct udevice *dev)
>>> +{
>>> +    return device_probe(dev);
>> This is wrong place to probe the device.
>> What must be done is to probe the device when it is first used.
>> I have a patch in progress for this. When it's cleaned up I'll share a
>> repo so that you can have look and maybe pick it up.
> Well the series is already applied. I'll send the patch to ML in this case.

Yes. Please cc me if you want to test something.

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


Re: [U-Boot] [PATCH v1] EHCI: Fix endian access issue on EHCI intinalization

2018-05-20 Thread Yinbo Zhu
+York Sun

-Original Message-
From: yinbo@nxp.com [mailto:yinbo@nxp.com] 
Sent: 2018年1月22日 15:22
To: u-boot@lists.denx.de
Cc: Xiaobo Xie ; Jerry Huang ; Ran 
Wang ; Yinbo Zhu 
Subject: [PATCH v1] EHCI: Fix endian access issue on EHCI intinalization

From: yinbo.zhu 

This issue is exposed after commit 9000eddbase0d
("drivers/usb/ehci: Use platform-specific accessors"), the wrong endian way of 
EHCI controller programing will cause USB function down.

Configs Affected: P2041-40-R2.0, P3041-R2.0, P4080-40-R3.0, P5040-21-R2.1, 
T1024-R1.0, T1040-42-20-22-R1.1, T2080-R1.1, T4240-4160-R2.0

Signed-off-by: yinbo.zhu 
---
 include/configs/P2041RDB.h   |1 +
 include/configs/T102xRDB.h   |1 +
 include/configs/T208xRDB.h   |1 +
 include/configs/T4240RDB.h   |1 +
 include/configs/corenet_ds.h |1 +
 5 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/include/configs/P2041RDB.h b/include/configs/P2041RDB.h index 
5f7ebe7..6b4c962 100644
--- a/include/configs/P2041RDB.h
+++ b/include/configs/P2041RDB.h
@@ -577,6 +577,7 @@ unsigned long get_board_sys_clk(unsigned long dummy);
 
 #if defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB)  #define 
CONFIG_USB_EHCI_FSL
+#define CONFIG_EHCI_DESC_BIG_ENDIAN
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET  #endif
 
diff --git a/include/configs/T102xRDB.h b/include/configs/T102xRDB.h index 
e1f2196..fad84d1 100644
--- a/include/configs/T102xRDB.h
+++ b/include/configs/T102xRDB.h
@@ -636,6 +636,7 @@ unsigned long get_board_ddr_clk(void);
 
 #ifdef CONFIG_HAS_FSL_DR_USB
 #define CONFIG_USB_EHCI_FSL
+#define CONFIG_EHCI_DESC_BIG_ENDIAN
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET  #endif
 
diff --git a/include/configs/T208xRDB.h b/include/configs/T208xRDB.h index 
eb9fe8d..0e0abca 100644
--- a/include/configs/T208xRDB.h
+++ b/include/configs/T208xRDB.h
@@ -644,6 +644,7 @@ unsigned long get_board_ddr_clk(void);
  */
 #ifdef CONFIG_USB_EHCI_HCD
 #define CONFIG_USB_EHCI_FSL
+#define CONFIG_EHCI_DESC_BIG_ENDIAN
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET  #define CONFIG_HAS_FSL_DR_USB  
#endif diff --git a/include/configs/T4240RDB.h b/include/configs/T4240RDB.h 
index bdb9322..6bdc3a7 100644
--- a/include/configs/T4240RDB.h
+++ b/include/configs/T4240RDB.h
@@ -657,6 +657,7 @@ unsigned long get_board_ddr_clk(void);
 * USB
 */
 #define CONFIG_USB_EHCI_FSL
+#define CONFIG_EHCI_DESC_BIG_ENDIAN
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET  #define CONFIG_HAS_FSL_DR_USB
 
diff --git a/include/configs/corenet_ds.h b/include/configs/corenet_ds.h index 
2344bd3..0076df9 100644
--- a/include/configs/corenet_ds.h
+++ b/include/configs/corenet_ds.h
@@ -586,6 +586,7 @@
 
 #if defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB)  #define 
CONFIG_USB_EHCI_FSL
+#define CONFIG_EHCI_DESC_BIG_ENDIAN
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET  #endif
 
--
1.7.1

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


Re: [U-Boot] [PULL] Please pull u-boot-imx

2018-05-20 Thread Tom Rini
On Fri, May 18, 2018 at 10:23:18PM -0400, Tom Rini wrote:
> On Fri, May 18, 2018 at 08:51:42AM +0200, Stefano Babic wrote:
> 
> > Hi Tom,
> > 
> > please pull from u-boot-imx, thanks !
> > 
> > The following changes since commit f2d0f5e7ab3b8a7b4bf6e2ac499b4867c701d52d:
> > 
> >   ARM: re-enable MVGBE for edminiv2 (2018-05-16 11:38:08 -0400)
> > 
> > are available in the git repository at:
> > 
> >   git://www.denx.de/git/u-boot-imx.git master
> > 
> > for you to fetch changes up to ee943655576f4a9e0af832e00a682a8d9f425bb1:
> > 
> >   arm: imx53: Add support for imx53 boards from K+P (2018-05-18 08:29:38
> > +0200)
> > 
> 
> Applied to u-boot/master, along with a follow up to fix SDPX tags,
> thanks!

And, oops, I should have complained:
WARNING: no status info for 'ge_bx50v3'
WARNING: no maintainers for 'ge_bx50v3'

were introduced, please follow-up with a fix, 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] [RFC][PATCH] block: Enable block cache by default

2018-05-20 Thread Marek Vasut
On 05/21/2018 03:48 AM, Tom Rini wrote:
> On Sun, May 20, 2018 at 01:39:07AM +0200, Marek Vasut wrote:
>> On 05/20/2018 12:29 AM, Tom Rini wrote:
>>> On Sat, May 19, 2018 at 11:39:38PM +0200, Marek Vasut wrote:
 On 05/19/2018 10:50 PM, Tom Rini wrote:
> On Sat, May 19, 2018 at 08:20:30PM +0200, Marek Vasut wrote:
>> On 05/19/2018 04:36 PM, Simon Glass wrote:
>>> On 18 May 2018 at 03:22, Marek Vasut  wrote:

 The recent ext4 cache discussion would indicate that the block cache
 is a desired feature, yet hidden and not enabled most of the time.
 Enable the block cache by default since it provides significant block
 device access performance improvement and if there are some users who
 cannot enable it ie. due to size limitations, those should disable it
 explicitly in their board config.

 Signed-off-by: Marek Vasut 
 Cc: Simon Glass 
 Cc: Michal Simek 
 Cc: Tom Rini 
 ---
  drivers/block/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> Reviewed-by: Simon Glass 
>>
>> I was hoping to get some feedback ?
>
> So, as I was asking on IRC, can you show the code paths where this gets
> used outside of CONFIG_BLK and then really ext4/fat/btrfs as I do in my
> patch?

 Can you summarize that discussion for everyone who was not on IRC at
 that point ?
>>>
>>> So I posted https://patchwork.ozlabs.org/patch/913266/ and it depends on
>>> BLK, as without BLK it does compile but isn't useful, but also isn't
>>> wholly discarded (due to the invalidate call in disk/part.c).
>>
>> Maybe that is what needs fixing and then this patch can be applied ?
> 
> No, that's just the nature of the functionality.  We have an option for
> block cache for the DM based block class.

Then it should probably be enabled by default if block class is enabled ? :)

>>> AFIACT
>>> from a quick read of the code, block cache is only useful on filesystems
>>> that reside on block devices.  It won't help with "just" MMC reads for
>>> example.  So we should only enable it by default in the case of
>>> filesystems that are usually on block devices being enabled.
>>
>> I wonder if this not helping with raw block reads is fine or not.
>> Thoughts ?
> 
> So you got me to look at the code and it should be more widely enabled
> that I suggested as it is used on block devices even on raw reads.

Good!

>>> But I didn't dig through the code hard enough to see if it would be
>>> useful on say UBIFS or if I'm wrong about it not being in the code path
>>> of things like say NAND.
>>
>> I don't see why this won't be useful on UBI/UBIFS . It is probably just
>> not implemented yet.
> 
> It's not useful outside of "block" devices, of which NAND (and SPI and
> NOR and so forth) are not.

Don't we have mtdblock or somesuch ? (caching block access to MTD devices) ?

>>> But I also don't think just default y in all cases is right as that's
>>> adding non-trivial mounts of code on all of the platforms that don't /
>>> won't make use of it.
>>
>> So it should be discarded if there are no users ?
> 
> Yes, it is.  Based on confirming it is used on raw block reads, I don't
> think the cases I saw with growth, when we have BLK enabled, were a
> problem.

E, can you rephrase ?

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2] ehci: Replace board_prepare_usb with board_usb_init

2018-05-20 Thread Marek Vasut
On 05/20/2018 10:12 PM, Ramon Fried wrote:
> On Sun, May 20, 2018 at 10:34 PM, Marek Vasut  wrote:
>> On 05/20/2018 09:15 PM, Ramon Fried wrote:
>>> Use standard board_usb_init() instead of the specific board_prepare_usb.
>>>
>>> Signed-off-by: Ramon Fried 
>>> ---
>>> v2: remove a line that sneaked in by mistake
>>>  board/qualcomm/dragonboard410c/dragonboard410c.c | 4 ++--
>>>  drivers/usb/host/ehci-msm.c  | 9 ++---
>>>  2 files changed, 4 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c 
>>> b/board/qualcomm/dragonboard410c/dragonboard410c.c
>>> index e7ead57f0d..679eab759a 100644
>>> --- a/board/qualcomm/dragonboard410c/dragonboard410c.c
>>> +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
>>> @@ -41,7 +41,7 @@ int dram_init_banksize(void)
>>>   return 0;
>>>  }
>>>
>>> -int board_prepare_usb(enum usb_init_type type)
>>> +int board_usb_init(int index, enum usb_init_type init)
>>>  {
>>>   static struct udevice *pmic_gpio;
>>>   static struct gpio_desc hub_reset, usb_sel;
>>> @@ -90,7 +90,7 @@ int board_prepare_usb(enum usb_init_type type)
>>>   }
>>>   }
>>>
>>> - if (type == USB_INIT_HOST) {
>>> + if (init == USB_INIT_HOST) {
>>>   /* Start USB Hub */
>>>   dm_gpio_set_dir_flags(&hub_reset,
>>> GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
>>
>> Obvious question -- can this not be started by some regulator ? Then
>> this board hook can go away altogether.
> By regulator do you mean pinctrl framework ?

Yes, something which would allow you to get rid of this board stuff
altogether.

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PULL] u-boot-sh/master

2018-05-20 Thread Tom Rini
On Sun, May 20, 2018 at 12:08:12PM +0200, Marek Vasut wrote:

> The following changes since commit 855ff8e6dd58b01930d8b8b726e65310d546a0c9:
> 
>   Fixup various SPDX tags from the latest merge (2018-05-18 17:56:50 -0400)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-sh.git master
> 
> for you to fetch changes up to 232a1a5f8f7318c56be4a193622b3b75c9260458:
> 
>   ARM: rmobile: Unify Gen2 Makefile entry (2018-05-20 12:06:55 +0200)
> 

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-usb/master

2018-05-20 Thread Tom Rini
On Sun, May 20, 2018 at 12:06:00PM +0200, Marek Vasut wrote:

> The following changes since commit 233719cc40b5a00f37949d4173c190edcb4491a1:
> 
>   Merge git://www.denx.de/git/u-boot-marvell (2018-05-17 12:38:30 -0400)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-usb.git master
> 
> for you to fetch changes up to 0ad3f771b69c0db837f40f6ffd5d41915fc07095:
> 
>   drivers: usb: dwc3: remove devm_zalloc from linux_compact (2018-05-18
> 13:37:02 +0200)
> 

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-socfpga/master

2018-05-20 Thread Tom Rini
On Sun, May 20, 2018 at 12:05:32PM +0200, Marek Vasut wrote:

> The following changes since commit 233719cc40b5a00f37949d4173c190edcb4491a1:
> 
>   Merge git://www.denx.de/git/u-boot-marvell (2018-05-17 12:38:30 -0400)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-socfpga.git master
> 
> for you to fetch changes up to 00f7ae6138ad8b9d859a70d022161297b1bb8049:
> 
>   arm: dts: socfpga: stratix10: update dtsi and dts (2018-05-18 10:30:48
> +0200)
> 

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] [RFC][PATCH] block: Enable block cache by default

2018-05-20 Thread Tom Rini
On Sun, May 20, 2018 at 01:39:07AM +0200, Marek Vasut wrote:
> On 05/20/2018 12:29 AM, Tom Rini wrote:
> > On Sat, May 19, 2018 at 11:39:38PM +0200, Marek Vasut wrote:
> >> On 05/19/2018 10:50 PM, Tom Rini wrote:
> >>> On Sat, May 19, 2018 at 08:20:30PM +0200, Marek Vasut wrote:
>  On 05/19/2018 04:36 PM, Simon Glass wrote:
> > On 18 May 2018 at 03:22, Marek Vasut  wrote:
> >>
> >> The recent ext4 cache discussion would indicate that the block cache
> >> is a desired feature, yet hidden and not enabled most of the time.
> >> Enable the block cache by default since it provides significant block
> >> device access performance improvement and if there are some users who
> >> cannot enable it ie. due to size limitations, those should disable it
> >> explicitly in their board config.
> >>
> >> Signed-off-by: Marek Vasut 
> >> Cc: Simon Glass 
> >> Cc: Michal Simek 
> >> Cc: Tom Rini 
> >> ---
> >>  drivers/block/Kconfig | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > Reviewed-by: Simon Glass 
> 
>  I was hoping to get some feedback ?
> >>>
> >>> So, as I was asking on IRC, can you show the code paths where this gets
> >>> used outside of CONFIG_BLK and then really ext4/fat/btrfs as I do in my
> >>> patch?
> >>
> >> Can you summarize that discussion for everyone who was not on IRC at
> >> that point ?
> > 
> > So I posted https://patchwork.ozlabs.org/patch/913266/ and it depends on
> > BLK, as without BLK it does compile but isn't useful, but also isn't
> > wholly discarded (due to the invalidate call in disk/part.c).
> 
> Maybe that is what needs fixing and then this patch can be applied ?

No, that's just the nature of the functionality.  We have an option for
block cache for the DM based block class.

> > AFIACT
> > from a quick read of the code, block cache is only useful on filesystems
> > that reside on block devices.  It won't help with "just" MMC reads for
> > example.  So we should only enable it by default in the case of
> > filesystems that are usually on block devices being enabled.
> 
> I wonder if this not helping with raw block reads is fine or not.
> Thoughts ?

So you got me to look at the code and it should be more widely enabled
that I suggested as it is used on block devices even on raw reads.

> > But I didn't dig through the code hard enough to see if it would be
> > useful on say UBIFS or if I'm wrong about it not being in the code path
> > of things like say NAND.
> 
> I don't see why this won't be useful on UBI/UBIFS . It is probably just
> not implemented yet.

It's not useful outside of "block" devices, of which NAND (and SPI and
NOR and so forth) are not.

> > But I also don't think just default y in all cases is right as that's
> > adding non-trivial mounts of code on all of the platforms that don't /
> > won't make use of it.
> 
> So it should be discarded if there are no users ?

Yes, it is.  Based on confirming it is used on raw block reads, I don't
think the cases I saw with growth, when we have BLK enabled, were a
problem.

-- 
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] SPDX header on .h files

2018-05-20 Thread Fabio Estevam
On Sun, May 20, 2018 at 8:15 PM, Duncan Hare  wrote:
> What's the correct format for this header?
> Patman is complaining about the SPDX header.

Please check:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/license-rules.rst?h=v4.17-rc6

For header files:

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


[U-Boot] [PATCH v11 3/3] Add wget, for fast file transfer.

2018-05-20 Thread DH
From: Duncan Hare 

>


Signed-off-by: Duncan Hare 
---
All the code is new, and not copied from any source.


Changes in v11:
Adding wget

 cmd/Kconfig|   7 +
 cmd/net.c  |  13 ++
 include/net.h  |   8 +-
 include/net/wget.h |  19 +++
 net/Makefile   |   1 +
 net/net.c  |  49 ++-
 net/wget.c | 418 +
 7 files changed, 508 insertions(+), 7 deletions(-)
 create mode 100644 include/net/wget.h
 create mode 100644 net/wget.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index eb14e08f77..9a76f42377 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1156,6 +1156,13 @@ config CMD_NFS
help
  Boot image via network using NFS protocol.
 
+config CMD_WGET
+bool "wget"
+select TCP
+help
+  Download kernel, or other files, from a web server over TCP.
+ Fast file transfer over networks with latency.
+
 config CMD_MII
bool "mii"
help
diff --git a/cmd/net.c b/cmd/net.c
index f83839c35e..f5fde849c4 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -113,6 +113,19 @@ U_BOOT_CMD(
 );
 #endif
 
+#if defined(CONFIG_CMD_WGET)
+static int do_wget(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+   return netboot_common(WGET, cmdtp, argc, argv);
+}
+
+U_BOOT_CMD(
+   wget,   3,  1,  do_wget,
+   "boot image via network using HTTP protocol",
+   "[loadAddress] [[hostIPaddr:]path and image name]"
+);
+#endif
+
 static void netboot_update_env(void)
 {
char tmp[22];
diff --git a/include/net.h b/include/net.h
index 47ef673f61..d94de7c62f 100644
--- a/include/net.h
+++ b/include/net.h
@@ -25,9 +25,7 @@
  * alignment in memory.
  *
  */
-#if defined(CONFIG_TCP)/* Protected becuse UDP uses less 
buffers */
-#define CONFIG_SYS_RX_ETH_BUFFER 12
-#endif
+
 #ifdef CONFIG_SYS_RX_ETH_BUFFER
 # define PKTBUFSRX CONFIG_SYS_RX_ETH_BUFFER
 #else
@@ -86,7 +84,7 @@ enum eth_state_t {
 };
 
 #ifdef CONFIG_DM_ETH
-/*
+/**
  * struct eth_pdata - Platform data for Ethernet MAC controllers
  *
  * @iobase: The base address of the hardware registers
@@ -538,7 +536,7 @@ extern int  net_restart_wrap;   /* Tried all 
network devices */
 
 enum proto_t {
BOOTP, RARP, ARP, TFTPGET, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP,
-   TFTPSRV, TFTPPUT, LINKLOCAL
+   TFTPSRV, TFTPPUT, LINKLOCAL, WGET
 };
 
 extern charnet_boot_file_name[1024];/* Boot File name */
diff --git a/include/net/wget.h b/include/net/wget.h
new file mode 100644
index 00..76d377fcd8
--- /dev/null
+++ b/include/net/wget.h
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Duncan Hare Copyright 2017
+ */
+
+void wget_start(void); /* Begin wget */
+
+enum WGET_STATE {
+   WGET_CLOSED,
+   WGET_CONNECTING,
+   WGET_CONNECTED,
+   WGET_TRANSFERRING,
+   WGET_TRANSFERRED
+};
+
+#defineDEBUG_WGET  0   /* Set to 1 for debug messges */
+#defineSERVER_PORT 80
+#defineWGET_RETRY_COUNT30
+#defineWGET_TIMEOUT2000UL
diff --git a/net/Makefile b/net/Makefile
index c2a7c2d990..882af145aa 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_CMD_RARP) += rarp.o
 obj-$(CONFIG_CMD_SNTP) += sntp.o
 obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o
 obj-$(CONFIG_TCP)  += tcp.o
+obj-$(CONFIG_CMD_WGET) += wget.o
 
 # Disable this warning as it is triggered by:
 # sprintf(buf, index ? "foo%d" : "foo", index)
diff --git a/net/net.c b/net/net.c
index 607f0fe865..30db8d6ceb 100644
--- a/net/net.c
+++ b/net/net.c
@@ -78,6 +78,11 @@
  * - own IP address
  * We want:- network time
  * Next step:  none
+ * Prequisites:- own ethernet address
+ * - own IP address
+ * - TCP stack
+ * - name and path of bootfile
+ * - load the bootfile
  */
 
 
@@ -107,6 +112,9 @@
 #if defined(CONFIG_CMD_SNTP)
 #include "sntp.h"
 #endif
+#include 
+#include 
+
 
 /** BOOTP EXTENTIONS **/
 
@@ -379,6 +387,9 @@ void net_init(void)
 
/* Only need to setup buffer pointers once. */
first_call = 0;
+#if defined(CONFIG_TCP)
+   tcp_set_tcp_state(TCP_CLOSED);
+#endif
}
 
net_init_loop();
@@ -482,6 +493,11 @@ restart:
nfs_start();
break;
 #endif
+#if defined(CONFIG_CMD_WGET)
+   case WGET:
+   wget_start();
+   break;
+#endif
 #if defined(CONFIG_CMD_CDP)
case CDP:
cdp_start();
@@ -781,6 +797,16 @@ int net_send_udp_packet(uchar *ether, struct in_addr dest, 
int dport, int sport,
  IPPROTO_UDP, 0, 0, 0);
 }
 
+#if defined(CONFIG_TCP)
+int net_send_tcp_packet(int payload_len, int dport, int sport, u8 actio

[U-Boot] [PATCH v11 1/3] Adding TCP and wget into u-boot

2018-05-20 Thread DH
From: Duncan Hare 

>
Initial changes for adding TCP
Meet change control standards after review



Signed-off-by: Duncan Hare 
---

Consolidatind UDP header functions to make it easier to add TCP
versions of the same, while reusing IP portions. This patch
should not change any behaviors.

Add a protocol parameter to ip packet sending in net.c
Add UDP protocol for current applications to minimize
code changes to existing ping.c

All the code is new, and not copied from any source.

Changes in v11: None

 include/net.h |  7 ++-
 net/net.c | 32 +++-
 net/ping.c|  9 ++---
 3 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/include/net.h b/include/net.h
index 65f51d77a5..ac80aaddd8 100644
--- a/include/net.h
+++ b/include/net.h
@@ -593,7 +593,8 @@ int net_set_ether(uchar *xet, const uchar *dest_ethaddr, 
uint prot);
 int net_update_ether(struct ethernet_hdr *et, uchar *addr, uint prot);
 
 /* Set IP header */
-void net_set_ip_header(uchar *pkt, struct in_addr dest, struct in_addr source);
+void net_set_ip_header(uchar *pkt, struct in_addr dest, struct in_addr source,
+  u16  pkt_len, u8 prot);
 void net_set_udp_header(uchar *pkt, struct in_addr dest, int dport,
int sport, int len);
 
@@ -667,6 +668,10 @@ static inline void net_send_packet(uchar *pkt, int len)
  * @param sport Source UDP port
  * @param payload_len Length of data after the UDP header
  */
+int net_send_ip_packet(uchar *ether, struct in_addr dest, int dport, int sport,
+  int payload_len, int proto, u8 action, u32 tcp_seq_num,
+  u32 tcp_ack_num);
+
 int net_send_udp_packet(uchar *ether, struct in_addr dest, int dport,
int sport, int payload_len);
 
diff --git a/net/net.c b/net/net.c
index 7f85211442..607f0fe865 100644
--- a/net/net.c
+++ b/net/net.c
@@ -777,6 +777,14 @@ void net_set_timeout_handler(ulong iv, thand_f *f)
 int net_send_udp_packet(uchar *ether, struct in_addr dest, int dport, int 
sport,
int payload_len)
 {
+   return net_send_ip_packet(ether, dest, dport, sport, payload_len,
+ IPPROTO_UDP, 0, 0, 0);
+}
+
+int net_send_ip_packet(uchar *ether, struct in_addr dest, int dport, int sport,
+  int payload_len, int proto, u8 action, u32 tcp_seq_num,
+  u32 tcp_ack_num)
+{
uchar *pkt;
int eth_hdr_size;
int pkt_hdr_size;
@@ -797,9 +805,14 @@ int net_send_udp_packet(uchar *ether, struct in_addr dest, 
int dport, int sport,
pkt = (uchar *)net_tx_packet;
 
eth_hdr_size = net_set_ether(pkt, ether, PROT_IP);
-   pkt += eth_hdr_size;
-   net_set_udp_header(pkt, dest, dport, sport, payload_len);
-   pkt_hdr_size = eth_hdr_size + IP_UDP_HDR_SIZE;
+   switch (proto) {
+   case IPPROTO_UDP:
+   net_set_udp_header(pkt + eth_hdr_size, dest,
+  dport, sport, payload_len);
+   pkt_hdr_size = eth_hdr_size + IP_UDP_HDR_SIZE;
+   break;
+   default: return -EINVAL;
+   }
 
/* if MAC address was not discovered yet, do an ARP request */
if (memcmp(ether, net_null_ethaddr, 6) == 0) {
@@ -1424,7 +1437,8 @@ int net_update_ether(struct ethernet_hdr *et, uchar 
*addr, uint prot)
}
 }
 
-void net_set_ip_header(uchar *pkt, struct in_addr dest, struct in_addr source)
+void net_set_ip_header(uchar *pkt, struct in_addr dest, struct in_addr source,
+  u16  pkt_len, u8 prot)
 {
struct ip_udp_hdr *ip = (struct ip_udp_hdr *)pkt;
 
@@ -1434,15 +1448,17 @@ void net_set_ip_header(uchar *pkt, struct in_addr dest, 
struct in_addr source)
/* IP_HDR_SIZE / 4 (not including UDP) */
ip->ip_hl_v  = 0x45;
ip->ip_tos   = 0;
-   ip->ip_len   = htons(IP_HDR_SIZE);
+   ip->ip_len   = htons(pkt_len);
ip->ip_id= htons(net_ip_id++);
ip->ip_off   = htons(IP_FLAGS_DFRAG);   /* Don't fragment */
ip->ip_ttl   = 255;
+   ip->ip_p = prot;
ip->ip_sum   = 0;
/* already in network byte order */
net_copy_ip((void *)&ip->ip_src, &source);
/* already in network byte order */
net_copy_ip((void *)&ip->ip_dst, &dest);
+   ip->ip_sum  = compute_ip_checksum(ip, IP_HDR_SIZE);
 }
 
 void net_set_udp_header(uchar *pkt, struct in_addr dest, int dport, int sport,
@@ -1458,10 +1474,8 @@ void net_set_udp_header(uchar *pkt, struct in_addr dest, 
int dport, int sport,
if (len & 1)
pkt[IP_UDP_HDR_SIZE + len] = 0;
 
-   net_set_ip_header(pkt, dest, net_ip);
-   ip->ip_len   = htons(IP_UDP_HDR_SIZE + len);
-   ip->ip_p = IPPROTO_UDP;
-   ip->ip_sum   = compute_ip_checksum(ip, IP_HDR_SIZE);
+   net_set_ip_header(pkt, dest, net_ip, IP_UDP_HDR_SIZE + len,
+ IPPROTO_UDP);
 
ip->udp

[U-Boot] [PATCH v11 2/3] Adding TCP

2018-05-20 Thread DH
From: Duncan Hare 

All the code is new, and not copied from any source.

>
For Multi-hop fast netwoks, (aka Long Fat networks)
SACK provides continued stream teansfer without delaying
the transfer for a misssing packet.



Signed-off-by: Duncan Hare 
Signed-off-by: Duncan Hare 
---
Clean code post review.

Changes in v11:
Add TCP with Selective Acknowledgement (SACK)

 include/net.h |  12 +-
 include/net/tcp.h | 227 ++
 net/Kconfig   |   6 +
 net/Makefile  |   1 +
 net/tcp.c | 700 ++
 5 files changed, 943 insertions(+), 3 deletions(-)
 create mode 100644 include/net/tcp.h
 create mode 100644 net/tcp.c

diff --git a/include/net.h b/include/net.h
index ac80aaddd8..47ef673f61 100644
--- a/include/net.h
+++ b/include/net.h
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: GPL-2.0 */
+// SPDX-License-Identifier: GPL-2.0
 /*
  * LiMon Monitor (LiMon) - Network.
  *
@@ -25,7 +25,9 @@
  * alignment in memory.
  *
  */
-
+#if defined(CONFIG_TCP)/* Protected becuse UDP uses less 
buffers */
+#define CONFIG_SYS_RX_ETH_BUFFER 12
+#endif
 #ifdef CONFIG_SYS_RX_ETH_BUFFER
 # define PKTBUFSRX CONFIG_SYS_RX_ETH_BUFFER
 #else
@@ -84,7 +86,7 @@ enum eth_state_t {
 };
 
 #ifdef CONFIG_DM_ETH
-/**
+/*
  * struct eth_pdata - Platform data for Ethernet MAC controllers
  *
  * @iobase: The base address of the hardware registers
@@ -350,6 +352,7 @@ struct vlan_ethernet_hdr {
 #define PROT_PPP_SES   0x8864  /* PPPoE session messages   */
 
 #define IPPROTO_ICMP1  /* Internet Control Message Protocol*/
+#define IPPROTO_TCP  6  /* Transmission Control Protocol*/
 #define IPPROTO_UDP17  /* User Datagram Protocol   */
 
 /*
@@ -675,6 +678,9 @@ int net_send_ip_packet(uchar *ether, struct in_addr dest, 
int dport, int sport,
 int net_send_udp_packet(uchar *ether, struct in_addr dest, int dport,
int sport, int payload_len);
 
+int net_send_tcp_packet(int payload_len, int dport, int sport, u8 action,
+   u32 tcp_seq_num, u32 tcp_ack_num);
+
 /* Processes a received packet */
 void net_process_received_packet(uchar *in_packet, int len);
 
diff --git a/include/net/tcp.h b/include/net/tcp.h
new file mode 100644
index 00..9be8623c85
--- /dev/null
+++ b/include/net/tcp.h
@@ -0,0 +1,227 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * TCP Support with SACK for file transfer.
+ *
+ * Copyright 2017 Duncan Hare, All rights reserved.
+ */
+
+#define TCP_ACTIVITY 127   /* Number of packets received   */
+   /* before console progress mark */
+
+struct ip_tcp_hdr {
+   u8  ip_hl_v;/* header length and version*/
+   u8  ip_tos; /* type of service  */
+   u16 ip_len; /* total length */
+   u16 ip_id;  /* identification   */
+   u16 ip_off; /* fragment offset field*/
+   u8  ip_ttl; /* time to live */
+   u8  ip_p;   /* protocol */
+   u16 ip_sum; /* checksum */
+   struct in_addr  ip_src; /* Source IP address*/
+   struct in_addr  ip_dst; /* Destination IP address   */
+   u16 tcp_src;/* TCP source port  */
+   u16 tcp_dst;/* TCP destination port */
+   u32 tcp_seq;/* TCP sequence number  */
+   u32 tcp_ack;/* TCP Acknowledgment number*/
+   u8  tcp_hlen;   /* 4 bits TCP header Length/4   */
+   /* 4 bits Reserved  */
+   /* 2 more bits reserved */
+   u8  tcp_flags;  /* see defines  */
+   u16 tcp_win;/* TCP windows size */
+   u16 tcp_xsum;   /* Checksum */
+   u16 tcp_ugr;/* Pointer to urgent data   */
+} __packed;
+
+#define IP_TCP_HDR_SIZE(sizeof(struct ip_tcp_hdr))
+#define TCP_HDR_SIZE   (IP_TCP_HDR_SIZE  - IP_HDR_SIZE)
+
+#define TCP_DATA   0x00/* Data Packet - internal use only  */
+#define TCP_FIN0x01/* Finish flag  
*/
+#define TCP_SYN0x02/* Synch (start) flag   
*/
+#define TCP_RST0x04/* reset flag   
*/
+#define TCP_PUSH   0x08/* Push - Notify app*/
+#define TCP_ACK0x10/* Acknowledgment of data received  
*/
+#define TCP_URG0x20

[U-Boot] [PATCH v11 0/3] Why netboot:

2018-05-20 Thread DH
From: Duncan Hare 

Central management, including logs and change control,
coupled with with enhanced security and unauthorized
change detection and remediation by exposing a
small attack surface.

Why TCP with Selective Acknowledgement:

Currently file transfer are done using tftp or NFS both
over udp. This requires a request to be sent from client
(u-boot) to the boot server.

For a 4 Mbyte kernel, with a 1k block size this requires
4,000 request for a block.

Using a large block size, one greater than the Ethernet
maximum frame size limitation, would require fragmentation,
which u-boot supports. However missing fragment recovery
requires timeout detection and re-transmission requests
for missing fragments.

UDP is ideally suited to fast single packet exchanges,
inquiry/response, for example dns, becuse of the lack of
connection overhead.

UDP as a file transport mechanism is slow, even in low
latency networks, because file transfer with udp requires
poll/response mechanism to provide transfer integrity.

In networks with large latency, for example: the internet,
UDP is even slower. What is a 30 second transfer on a local
boot server and LAN increase to over 3 minutes, because of
all the requests/response traffic.

This was anticipated in the evolution of the IP protocols
and TCP was developed and then enhanced for high latency high
bandwidth networks.

The current standard is TCP with selective acknowledgment.

In our testing we have reduce kernel transmission time to
around 0.4 seconds for a 4Mbyte kernel, with a 100 Mbps
downlink.

Why http and wget:

HTTP is the most efficient file retrieval protocol in common
use. The client send a single request, after TCP connection,
to receive a file of any length.

WGET is the application which implements http file transfer
outside browsers as a file transfer protocol. Versions of
wget exists on many operating systems.

Changes in v11:
Add TCP with Selective Acknowledgement (SACK)
Adding wget

Duncan Hare (3):
  Adding TCP and wget into u-boot
  Adding TCP
  Add wget, for fast file transfer.

 cmd/Kconfig|   7 +
 cmd/net.c  |  13 +
 include/net.h  |  15 +-
 include/net/tcp.h  | 227 +
 include/net/wget.h |  19 ++
 net/Kconfig|   6 +
 net/Makefile   |   2 +
 net/net.c  |  79 +-
 net/ping.c |   9 +-
 net/tcp.c  | 700 +
 net/wget.c | 418 
 11 files changed, 1475 insertions(+), 20 deletions(-)
 create mode 100644 include/net/tcp.h
 create mode 100644 include/net/wget.h
 create mode 100644 net/tcp.c
 create mode 100644 net/wget.c

-- 
2.11.0

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


[U-Boot] SPDX header on .h files

2018-05-20 Thread Duncan Hare
What's the correct format for this header?
Patman is complaining about the SPDX header.
 Duncan Hare

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


[U-Boot] Patman - How to send patched with errors

2018-05-20 Thread Duncan Hare
Hi Simon
I have forgotten how to override the on errors do not sent patchesoption.
tools/patman/patman -c3  -?
What's the "?"
Thanks
 Duncan Hare

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


Re: [U-Boot] [PATCH v2] ehci: Replace board_prepare_usb with board_usb_init

2018-05-20 Thread Ramon Fried
On Sun, May 20, 2018 at 10:34 PM, Marek Vasut  wrote:
> On 05/20/2018 09:15 PM, Ramon Fried wrote:
>> Use standard board_usb_init() instead of the specific board_prepare_usb.
>>
>> Signed-off-by: Ramon Fried 
>> ---
>> v2: remove a line that sneaked in by mistake
>>  board/qualcomm/dragonboard410c/dragonboard410c.c | 4 ++--
>>  drivers/usb/host/ehci-msm.c  | 9 ++---
>>  2 files changed, 4 insertions(+), 9 deletions(-)
>>
>> diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c 
>> b/board/qualcomm/dragonboard410c/dragonboard410c.c
>> index e7ead57f0d..679eab759a 100644
>> --- a/board/qualcomm/dragonboard410c/dragonboard410c.c
>> +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
>> @@ -41,7 +41,7 @@ int dram_init_banksize(void)
>>   return 0;
>>  }
>>
>> -int board_prepare_usb(enum usb_init_type type)
>> +int board_usb_init(int index, enum usb_init_type init)
>>  {
>>   static struct udevice *pmic_gpio;
>>   static struct gpio_desc hub_reset, usb_sel;
>> @@ -90,7 +90,7 @@ int board_prepare_usb(enum usb_init_type type)
>>   }
>>   }
>>
>> - if (type == USB_INIT_HOST) {
>> + if (init == USB_INIT_HOST) {
>>   /* Start USB Hub */
>>   dm_gpio_set_dir_flags(&hub_reset,
>> GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
>
> Obvious question -- can this not be started by some regulator ? Then
> this board hook can go away altogether.
By regulator do you mean pinctrl framework ?
>
> [...]
>
> --
> Best regards,
> Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2] ehci: Replace board_prepare_usb with board_usb_init

2018-05-20 Thread Marek Vasut
On 05/20/2018 09:15 PM, Ramon Fried wrote:
> Use standard board_usb_init() instead of the specific board_prepare_usb.
> 
> Signed-off-by: Ramon Fried 
> ---
> v2: remove a line that sneaked in by mistake
>  board/qualcomm/dragonboard410c/dragonboard410c.c | 4 ++--
>  drivers/usb/host/ehci-msm.c  | 9 ++---
>  2 files changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c 
> b/board/qualcomm/dragonboard410c/dragonboard410c.c
> index e7ead57f0d..679eab759a 100644
> --- a/board/qualcomm/dragonboard410c/dragonboard410c.c
> +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
> @@ -41,7 +41,7 @@ int dram_init_banksize(void)
>   return 0;
>  }
>  
> -int board_prepare_usb(enum usb_init_type type)
> +int board_usb_init(int index, enum usb_init_type init)
>  {
>   static struct udevice *pmic_gpio;
>   static struct gpio_desc hub_reset, usb_sel;
> @@ -90,7 +90,7 @@ int board_prepare_usb(enum usb_init_type type)
>   }
>   }
>  
> - if (type == USB_INIT_HOST) {
> + if (init == USB_INIT_HOST) {
>   /* Start USB Hub */
>   dm_gpio_set_dir_flags(&hub_reset,
> GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);

Obvious question -- can this not be started by some regulator ? Then
this board hook can go away altogether.

[...]

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2] ehci: Replace board_prepare_usb with board_usb_init

2018-05-20 Thread Ramon Fried
Use standard board_usb_init() instead of the specific board_prepare_usb.

Signed-off-by: Ramon Fried 
---
v2: remove a line that sneaked in by mistake
 board/qualcomm/dragonboard410c/dragonboard410c.c | 4 ++--
 drivers/usb/host/ehci-msm.c  | 9 ++---
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c 
b/board/qualcomm/dragonboard410c/dragonboard410c.c
index e7ead57f0d..679eab759a 100644
--- a/board/qualcomm/dragonboard410c/dragonboard410c.c
+++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
@@ -41,7 +41,7 @@ int dram_init_banksize(void)
return 0;
 }
 
-int board_prepare_usb(enum usb_init_type type)
+int board_usb_init(int index, enum usb_init_type init)
 {
static struct udevice *pmic_gpio;
static struct gpio_desc hub_reset, usb_sel;
@@ -90,7 +90,7 @@ int board_prepare_usb(enum usb_init_type type)
}
}
 
-   if (type == USB_INIT_HOST) {
+   if (init == USB_INIT_HOST) {
/* Start USB Hub */
dm_gpio_set_dir_flags(&hub_reset,
  GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index 17bfa7c02f..db982624dc 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -38,11 +38,6 @@ struct msm_ehci_priv {
struct ulpi_viewport ulpi_vp; /* ULPI Viewport */
 };
 
-int __weak board_prepare_usb(enum usb_init_type type)
-{
-   return 0;
-}
-
 static void setup_usb_phy(struct msm_ehci_priv *priv)
 {
/* Select and enable external configuration with USB PHY */
@@ -102,7 +97,7 @@ static int ehci_usb_probe(struct udevice *dev)
hcor = (struct ehci_hcor *)((phys_addr_t)hccr +
HC_LENGTH(ehci_readl(&(hccr)->cr_capbase)));
 
-   ret = board_prepare_usb(USB_INIT_HOST);
+   ret = board_usb_init(0, USB_INIT_HOST);
if (ret < 0)
return ret;
 
@@ -124,7 +119,7 @@ static int ehci_usb_remove(struct udevice *dev)
 
reset_usb_phy(p);
 
-   ret = board_prepare_usb(USB_INIT_DEVICE); /* Board specific hook */
+   ret = board_usb_init(0, USB_INIT_DEVICE); /* Board specific hook */
if (ret < 0)
return ret;
 
-- 
2.17.0

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


[U-Boot] [PATCH] ehci: msm: Replace board_prepare_usb with board_usb_init

2018-05-20 Thread Ramon Fried
Use standard board_usb_init() instead of the specific board_prepare_usb.

Signed-off-by: Ramon Fried 
---
 board/qualcomm/dragonboard410c/dragonboard410c.c |  4 ++--
 drivers/usb/host/ehci-msm.c  | 11 ---
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c 
b/board/qualcomm/dragonboard410c/dragonboard410c.c
index e7ead57f0d..679eab759a 100644
--- a/board/qualcomm/dragonboard410c/dragonboard410c.c
+++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
@@ -41,7 +41,7 @@ int dram_init_banksize(void)
return 0;
 }
 
-int board_prepare_usb(enum usb_init_type type)
+int board_usb_init(int index, enum usb_init_type init)
 {
static struct udevice *pmic_gpio;
static struct gpio_desc hub_reset, usb_sel;
@@ -90,7 +90,7 @@ int board_prepare_usb(enum usb_init_type type)
}
}
 
-   if (type == USB_INIT_HOST) {
+   if (init == USB_INIT_HOST) {
/* Start USB Hub */
dm_gpio_set_dir_flags(&hub_reset,
  GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index 17bfa7c02f..9ecd8d6732 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -38,11 +38,6 @@ struct msm_ehci_priv {
struct ulpi_viewport ulpi_vp; /* ULPI Viewport */
 };
 
-int __weak board_prepare_usb(enum usb_init_type type)
-{
-   return 0;
-}
-
 static void setup_usb_phy(struct msm_ehci_priv *priv)
 {
/* Select and enable external configuration with USB PHY */
@@ -102,7 +97,7 @@ static int ehci_usb_probe(struct udevice *dev)
hcor = (struct ehci_hcor *)((phys_addr_t)hccr +
HC_LENGTH(ehci_readl(&(hccr)->cr_capbase)));
 
-   ret = board_prepare_usb(USB_INIT_HOST);
+   ret = board_usb_init(0, USB_INIT_HOST);
if (ret < 0)
return ret;
 
@@ -124,7 +119,7 @@ static int ehci_usb_remove(struct udevice *dev)
 
reset_usb_phy(p);
 
-   ret = board_prepare_usb(USB_INIT_DEVICE); /* Board specific hook */
+   ret = board_usb_init(0, USB_INIT_DEVICE); /* Board specific hook */
if (ret < 0)
return ret;
 
@@ -150,6 +145,8 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
if (priv->ehci == (void *)FDT_ADDR_T_NONE)
return -EINVAL;
 
+   dev->req_seq = 0;
+
/* Warning: this will not work if viewport address is > 64 bit due to
 * ULPI design.
 */
-- 
2.17.0

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


Re: [U-Boot] [PATCH v2 1/2] cmd: nvedit: add whitelist option for env import

2018-05-20 Thread Lothar Waßmann
Hi,

On Fri, 18 May 2018 16:44:59 +0200 Quentin Schulz wrote:
> While the `env export` can take as parameters variables to be exported,
> `env import` does not have such a mechanism of variable selection.
> 
> Let's add a `-w` option that asks `env import` to look for the
> `whitelisted_vars` env variable for a space-separated list of variables
> that are whitelisted.
> 
> Every env variable present in env at `addr` and in `whitelisted_vars`
> env variable will override the value of the variable in the current env.
> All the remaining variables are left untouched.
> 
> One of its use case could be to load a secure environment from the
> signed U-Boot binary and load only a handful of variables from an
> other, unsecure, environment without completely losing control of
> U-Boot.
> 
> Signed-off-by: Quentin Schulz 
> ---
> 
> v2:
>   - use strdup instead of malloc + strcpy,
>   - NULL-check the result of strdup,
>   - add common exit path for freeing memory in one unique place,
>   - store token pointer from strtok within the char** array instead of
>   strdup-ing token within elements of array,
> 
>  cmd/nvedit.c | 79 
> +++-
>  1 file changed, 68 insertions(+), 11 deletions(-)
> 
> diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> index 4e79d03856..1e33a26f4c 100644
> --- a/cmd/nvedit.c
> +++ b/cmd/nvedit.c
> @@ -971,7 +971,7 @@ sep_err:
>  
>  #ifdef CONFIG_CMD_IMPORTENV
>  /*
> - * env import [-d] [-t [-r] | -b | -c] addr [size]
> + * env import [-d] [-t [-r] | -b | -c] [-w] addr [size]
>   *   -d: delete existing environment before importing;
>   *   otherwise overwrite / append to existing definitions
>   *   -t: assume text format; either "size" must be given or the
> @@ -982,6 +982,10 @@ sep_err:
>   *   for line endings. Only effective in addition to -t.
>   *   -b: assume binary format ('\0' separated, "\0\0" terminated)
>   *   -c: assume checksum protected environment format
> + *   -w: specify that whitelisting of variables should be used when
> + *   importing environment. The space-separated list of variables
> + *   that should override the ones in current environment is stored
> + *   in `whitelisted_vars`.
>   *   addr:   memory address to read from
>   *   size:   length of input data; if missing, proper '\0'
>   *   termination is mandatory
> @@ -990,18 +994,22 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
>int argc, char * const argv[])
>  {
>   ulong   addr;
> - char*cmd, *ptr;
> + char*cmd, *ptr, *tmp;
> + char**array = NULL;
>   charsep = '\n';
>   int chk = 0;
>   int fmt = 0;
>   int del = 0;
>   int crlf_is_lf = 0;
> + int wl = 0;
> + int wl_count = 0;
> + int ret = 0;
>   size_t  size;
>  
>   cmd = *argv;
>  
>   while (--argc > 0 && **++argv == '-') {
> - char *arg = *argv;
> + char *arg = *argv, *str, *token;
>   while (*++arg) {
>   switch (*arg) {
>   case 'b':   /* raw binary format */
> @@ -1025,6 +1033,43 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
>   break;
>   case 'd':
>   del = 1;
> + break;
> + case 'w':
> + wl = 1;
> + wl_count = 1;
> +
> + str = env_get("whitelisted_vars");
> + if (!str) {
> + puts("## Error: whitelisted_vars is not 
> set.\n");
> + return CMD_RET_USAGE;
> + }
> +
> + tmp = strdup(str);
> + if (!tmp)
> + return CMD_RET_FAILURE;
> +
> + token = strchr(tmp, ' ');
> + while (!token) {
> + wl_count++;
> + token = strchr(token + 1, ' ');
> + }
> +
> + strcpy(tmp, str);
>
This is redundant. strchr() doesn't modify the array.

> + wl_count = 0;
> + array = malloc(sizeof(char *) * wl_count);
>
You have juste before reset wl_count to 0 are mallocing a zero sized
array here!

> + if (!array) {
> + free(tmp);
> + return CMD_RET_FAILURE;
> + }
> +
>
wl_count should probably be zeroed here...
But I would keep the predetermined vlaue of wl_count and check against
it in the following loop to be sure not to overflow the allocated
array, ev

[U-Boot] [PULL] u-boot-sh/master

2018-05-20 Thread Marek Vasut
The following changes since commit 855ff8e6dd58b01930d8b8b726e65310d546a0c9:

  Fixup various SPDX tags from the latest merge (2018-05-18 17:56:50 -0400)

are available in the Git repository at:

  git://git.denx.de/u-boot-sh.git master

for you to fetch changes up to 232a1a5f8f7318c56be4a193622b3b75c9260458:

  ARM: rmobile: Unify Gen2 Makefile entry (2018-05-20 12:06:55 +0200)


Marek Vasut (11):
  i2c: rcar_i2c: Remove the driver
  i2c: rcar_i2c: Add DM and DT capable I2C driver
  ARM: rmobile: Enable DM capable RCar I2C driver on Lager
  ARM: rmobile: Enable DM capable RCar I2C driver on Silk
  ARM: rmobile: Update V2H Blanche
  ARM: rmobile: Drop old R8A7790 PFC tables
  ARM: rmobile: Drop old R8A7791 PFC tables
  ARM: rmobile: Drop old R8A7792 PFC tables
  ARM: rmobile: Drop old R8A7793 PFC tables
  ARM: rmobile: Drop old R8A7794 PFC tables
  ARM: rmobile: Unify Gen2 Makefile entry

 arch/arm/dts/r8a7792-blanche-u-boot.dts   |4 +
 arch/arm/mach-rmobile/Kconfig.32  |1 +
 arch/arm/mach-rmobile/Makefile|   10 +-
 arch/arm/mach-rmobile/include/mach/gpio.h |   15 -
 arch/arm/mach-rmobile/include/mach/r8a7790-gpio.h |  387
---
 arch/arm/mach-rmobile/include/mach/r8a7791-gpio.h |  438
--
 arch/arm/mach-rmobile/include/mach/r8a7792-gpio.h |  220 -
 arch/arm/mach-rmobile/include/mach/r8a7793-gpio.h |  438
--
 arch/arm/mach-rmobile/include/mach/r8a7794-gpio.h |  276 -
 arch/arm/mach-rmobile/pfc-r8a7790.c   | 1813
---
 arch/arm/mach-rmobile/pfc-r8a7791.c   | 1116
--
 arch/arm/mach-rmobile/pfc-r8a7792.c   | 2301

 arch/arm/mach-rmobile/pfc-r8a7793.c   | 1925
-
 arch/arm/mach-rmobile/pfc-r8a7794.c   | 1650
-
 board/renesas/blanche/Makefile|2 +-
 board/renesas/blanche/blanche.c   |  633
+++---
 configs/blanche_defconfig |   42 ++-
 configs/lager_defconfig   |1 +
 configs/silk_defconfig|1 +
 drivers/i2c/Kconfig   |6 +
 drivers/i2c/Makefile  |2 +-
 drivers/i2c/rcar_i2c.c|  513
+--
 include/configs/blanche.h |   30 +-
 23 files changed, 601 insertions(+), 11223 deletions(-)
 delete mode 100644 arch/arm/mach-rmobile/include/mach/r8a7790-gpio.h
 delete mode 100644 arch/arm/mach-rmobile/include/mach/r8a7791-gpio.h
 delete mode 100644 arch/arm/mach-rmobile/include/mach/r8a7792-gpio.h
 delete mode 100644 arch/arm/mach-rmobile/include/mach/r8a7793-gpio.h
 delete mode 100644 arch/arm/mach-rmobile/include/mach/r8a7794-gpio.h
 delete mode 100644 arch/arm/mach-rmobile/pfc-r8a7790.c
 delete mode 100644 arch/arm/mach-rmobile/pfc-r8a7791.c
 delete mode 100644 arch/arm/mach-rmobile/pfc-r8a7792.c
 delete mode 100644 arch/arm/mach-rmobile/pfc-r8a7793.c
 delete mode 100644 arch/arm/mach-rmobile/pfc-r8a7794.c
-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PULL] u-boot-usb/master

2018-05-20 Thread Marek Vasut
The following changes since commit 233719cc40b5a00f37949d4173c190edcb4491a1:

  Merge git://www.denx.de/git/u-boot-marvell (2018-05-17 12:38:30 -0400)

are available in the Git repository at:

  git://git.denx.de/u-boot-usb.git master

for you to fetch changes up to 0ad3f771b69c0db837f40f6ffd5d41915fc07095:

  drivers: usb: dwc3: remove devm_zalloc from linux_compact (2018-05-18
13:37:02 +0200)


Michal Simek (4):
  usb: dwc3: Add generic DWC3 glue logic driver
  usb: xhci: zynqmp: Add support for DM_USB
  arm64: zynqmp: Use DWC3 generic driver and DM_USB
  usb: xhci: zynqmp: Remove support for !DM_USB

Mugunthan V N (3):
  usb: dwc3: Add dwc3_init/remove with DM_USB
  usb: common: add support to get maximum speed from dt
  drivers: usb: dwc3: remove devm_zalloc from linux_compact

Patrice Chotard (1):
  phy: add support for STM32 usb phy controller

Seung-Woo Kim (2):
  gadget: f_thor: fix filename overflow
  gadget: f_thor: update to support more than 4GB file as thor 5.0

 Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.txt |  73
+++
 arch/arm/include/asm/arch-zynqmp/hardware.h |   3 -
 board/xilinx/zynqmp/zynqmp.c|  46
---
 configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig|   1 +
 configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig|   1 +
 configs/xilinx_zynqmp_zc1751_xm017_dc3_defconfig|   1 +
 configs/xilinx_zynqmp_zcu100_revC_defconfig |   1 +
 configs/xilinx_zynqmp_zcu102_rev1_0_defconfig   |   1 +
 configs/xilinx_zynqmp_zcu102_revA_defconfig |   1 +
 configs/xilinx_zynqmp_zcu102_revB_defconfig |   1 +
 configs/xilinx_zynqmp_zcu104_revA_defconfig |   1 +
 configs/xilinx_zynqmp_zcu104_revC_defconfig |   1 +
 configs/xilinx_zynqmp_zcu106_revA_defconfig |   1 +
 configs/xilinx_zynqmp_zcu111_revA_defconfig |   1 +
 drivers/phy/Kconfig |  13 +
 drivers/phy/Makefile|   1 +
 drivers/phy/phy-stm32-usbphyc.c | 402
+++
 drivers/usb/common/common.c |  29
++
 drivers/usb/dwc3/Kconfig|   6 ++
 drivers/usb/dwc3/Makefile   |   1 +
 drivers/usb/dwc3/core.c |  62
+++-
 drivers/usb/dwc3/core.h |   6 ++
 drivers/usb/dwc3/dwc3-generic.c | 157
++
 drivers/usb/dwc3/dwc3-omap.c|   3 +-
 drivers/usb/dwc3/gadget.c   |   2 +-
 drivers/usb/dwc3/linux-compat.h |   5 --
 drivers/usb/dwc3/ti_usb_phy.c   |   1 +
 drivers/usb/gadget/f_thor.c |  13 +++--
 drivers/usb/gadget/f_thor.h |   2 +-
 drivers/usb/host/Kconfig|   1 +
 drivers/usb/host/xhci-zynqmp.c  |  85
+--
 include/configs/xilinx_zynqmp_zc1751_xm015_dc1.h|   1 -
 include/configs/xilinx_zynqmp_zc1751_xm016_dc2.h|   2 -
 include/configs/xilinx_zynqmp_zc1751_xm017_dc3.h|   3 -
 include/configs/xilinx_zynqmp_zcu100.h  |   3 -
 include/configs/xilinx_zynqmp_zcu102.h  |   2 -
 include/configs/xilinx_zynqmp_zcu104.h  |   2 -
 include/configs/xilinx_zynqmp_zcu106.h  |   2 -
 include/configs/xilinx_zynqmp_zcu111.h  |   2 -
 include/linux/usb/otg.h |   9 +++
 scripts/config_whitelist.txt|   1 -
 41 files changed, 837 insertions(+), 112 deletions(-)
 create mode 100644
Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.txt
 create mode 100644 drivers/phy/phy-stm32-usbphyc.c
 create mode 100644 drivers/usb/dwc3/dwc3-generic.c
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PULL] u-boot-socfpga/master

2018-05-20 Thread Marek Vasut
The following changes since commit 233719cc40b5a00f37949d4173c190edcb4491a1:

  Merge git://www.denx.de/git/u-boot-marvell (2018-05-17 12:38:30 -0400)

are available in the Git repository at:

  git://git.denx.de/u-boot-socfpga.git master

for you to fetch changes up to 00f7ae6138ad8b9d859a70d022161297b1bb8049:

  arm: dts: socfpga: stratix10: update dtsi and dts (2018-05-18 10:30:48
+0200)


Ben Kalo (1):
  ARM: socfpga: Fix Documentation errors in scu_registers

Ley Foon Tan (6):
  arm: socfpga: stratix10: Add watchdog and firewall base addresses
  arm: socfpga: stratix10: Add clock manager driver for Stratix10 SoC
  arm: socfpga: stratix10: Add reset manager driver for Stratix10 SoC
  arm: socfpga: stratix10: Add pinmux support for Stratix10 SoC
  arm: socfpga: misc: Add CONFIG_SYS_L2_PL310 switch
  arm: dts: socfpga: stratix10: update dtsi and dts

Marek Vasut (10):
  fdt: Add another Altera Arria10 clock init compatible
  ARM: socfpga: Put stack at the end of SRAM
  ARM: socfpga: Zap CONFIG_SOCFPGA_VIRTUAL_TARGET
  ARM: socfpga: Clean up Kconfig entries
  ARM: socfpga: Convert to DM serial
  ARM: socfpga: Sync A10 clock manager binding parser
  ARM: socfpga: Sort the DT Makefile
  ARM: socfpga: Synchronize Arria10 DTs
  ARM: socfpga: Synchronize Arria10 SoCDK SDMMC handoff
  ARM: socfpga: Repair A10 EMAC reset handling

Tien Fong Chee (7):
  ARM: socfpga: Rename the gen5 sdram driver to more specific name
  ARM: socfpga: Add DRAM bank size initialization function


  ARM: socfpga: Add DDR driver for Arria 10


  configs: Add DDR Kconfig support for Arria 10


  ARM: socfpga: Enable SPL memory allocation


  ARM: socfpga: Adding clock frequency info for U-Boot


  ARM: socfpga: Adding SoCFPGA info for both SPL and U-Boot





 arch/arm/Kconfig   |  23 +++-


 arch/arm/dts/Makefile  |   8 +-


 arch/arm/dts/socfpga.dtsi  |   2 +


 arch/arm/dts/socfpga_arria10.dtsi  | 594
+++---

 arch/arm/dts/socfpga_arria10_socdk.dtsi| 167
+

 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  44


 arch/arm/dts/socfpga_arria10_socdk_sdmmc_handoff.dtsi  | 734
--

 arch/arm/dts/socfpga_stratix10.dtsi|  22 +++-


 arch/arm/dts/socfpga_stratix10_socdk.dts   |   3 +
 arch/arm/mach-socfpga/Kconfig  |  31 +-
 arch/arm/mach-socfpga/Makefile |   7 ++
 arch/arm/mach-socfpga/board.c  |  18 
 arch/arm/mach-socfpga/clock_manager.c  |   4 +-
 arch/arm/mach-socfpga/clock_manager_arria10.c  | 158
+++-
 arch/arm/mach-socfpga/clock_manager_s10.c  | 380
++
 arch/arm/mach-socfpga/include/mach/base_addr_s10.h |  11 ++
 arch/arm/mach-socfpga/include/mach/clock_manager.h |   2 +
 arch/arm/mach-socfpga/include/mach/clock_manager_arria10.h |   2 +-
 arch/arm/mach-socfpga/include/mach/clock_manager_s10.h | 210

 arch/arm/mach-socfpga/include/mach/handoff_s10.h   |  34 ++
 arch/arm/mach-socfpga/include/mach/reset_manager.h |   8 +-
 arch/arm/mach-socfpga/include/mach/reset_manager_s10.h | 116

 arch/arm/mach-socfpga/include/mach/scu.h   |   4 +-
 arch/arm/mach-socfpga/include/mach/sdram.h | 434
+--
 arch/arm/mach-socfpga/include/mach/sdram_arria10.h |   2 +
 arch/arm/mach-socfpga/include/mach/sdram_gen5.h| 442

 arch/arm/mach-socfpga/include/mach/system_manager.h|   5 +-
 arch/arm/mach-socfpga/include/mach/system_manager_s10.h| 176
+++
 arch/arm/mach-socfpga/misc.c   |  69

 arch/arm/mach-socfpga/misc_arria10.c   |  24 +++--
 arch/arm/mach-socfpga/misc_gen5.c  |  71
+
 arch/arm/mach-socfpga/reset_manager.c  |  13 +++
 arch/arm/mach-socfpga/reset_manager_arria10.c  |   8 --
 arch/arm/mach-socfpga/reset_manager_gen5.c |   9 --
 arch/arm/mach-socfpga/reset_manager_s10.c  | 140

 arch/arm/mach-socfp