Re: [U-Boot] [UBOOT PATCH] usb: dwc3: convert to livetree

2018-07-11 Thread Michal Simek
On 11.7.2018 17:01, Marek Vasut wrote:
> On 06/11/2018 11:39 AM, Vipul Kumar wrote:
>> Update the DWC3 USB driver to support a live tree.
>>
>> Signed-off-by: Vipul Kumar 
> 
> What about systems which do not use live tree, does it work on those ?
> 

They are not affected because headers are pointing to right functions.

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


Re: [U-Boot] [UBOOT PATCH] usb: dwc3: convert to livetree

2018-07-11 Thread Marek Vasut
On 06/11/2018 11:39 AM, Vipul Kumar wrote:
> Update the DWC3 USB driver to support a live tree.
> 
> Signed-off-by: Vipul Kumar 

What about systems which do not use live tree, does it work on those ?

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


Re: [U-Boot] [UBOOT PATCH] usb: dwc3: convert to livetree

2018-06-11 Thread Michal Simek
On 11.6.2018 11:39, Vipul Kumar wrote:
> Update the DWC3 USB driver to support a live tree.
> 
> Signed-off-by: Vipul Kumar 
> ---
>  drivers/usb/common/common.c | 11 +--
>  drivers/usb/dwc3/dwc3-generic.c | 17 +++--
>  drivers/usb/host/xhci-dwc3.c|  3 ++-
>  drivers/usb/host/xhci-zynqmp.c  |  3 +--
>  include/linux/usb/otg.h |  6 --
>  5 files changed, 19 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
> index a55def5..3dea79b 100644
> --- a/drivers/usb/common/common.c
> +++ b/drivers/usb/common/common.c
> @@ -10,6 +10,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -20,13 +21,12 @@ static const char *const usb_dr_modes[] = {
>   [USB_DR_MODE_OTG]   = "otg",
>  };
>  
> -enum usb_dr_mode usb_get_dr_mode(int node)
> +enum usb_dr_mode usb_get_dr_mode(ofnode node)
>  {
> - const void *fdt = gd->fdt_blob;
>   const char *dr_mode;
>   int i;
>  
> - dr_mode = fdt_getprop(fdt, node, "dr_mode", NULL);
> + dr_mode = ofnode_get_property(node, "dr_mode", NULL);
>   if (!dr_mode) {
>   pr_err("usb dr_mode not found\n");
>   return USB_DR_MODE_UNKNOWN;
> @@ -48,13 +48,12 @@ static const char *const speed_names[] = {
>   [USB_SPEED_SUPER] = "super-speed",
>  };
>  
> -enum usb_device_speed usb_get_maximum_speed(int node)
> +enum usb_device_speed usb_get_maximum_speed(ofnode node)
>  {
> - const void *fdt = gd->fdt_blob;
>   const char *max_speed;
>   int i;
>  
> - max_speed = fdt_getprop(fdt, node, "maximum-speed", NULL);
> + max_speed = ofnode_get_property(node, "maximum-speed", NULL);
>   if (!max_speed) {
>   pr_err("usb maximum-speed not found\n");
>   return USB_SPEED_UNKNOWN;
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> index ca63eac..ef72c8c 100644
> --- a/drivers/usb/dwc3/dwc3-generic.c
> +++ b/drivers/usb/dwc3/dwc3-generic.c
> @@ -61,18 +61,17 @@ static int dwc3_generic_peripheral_remove(struct udevice 
> *dev)
>  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 = (void *)dev_read_addr(dev);
>   priv->regs += DWC3_GLOBALS_REGS_START;
>  
> - priv->maximum_speed = usb_get_maximum_speed(node);
> + priv->maximum_speed = usb_get_maximum_speed(dev->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);
> + priv->dr_mode = usb_get_dr_mode(dev->node);
>   if (priv->dr_mode == USB_DR_MODE_UNKNOWN) {
>   pr_err("Invalid usb mode setup\n");
>   return -ENODEV;
> @@ -100,13 +99,11 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = {
>  
>  static int dwc3_generic_bind(struct udevice *parent)
>  {
> - const void *fdt = gd->fdt_blob;
> - int node;
> + ofnode node;
>   int ret;
>  
> - for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
> -  node = fdt_next_subnode(fdt, node)) {
> - const char *name = fdt_get_name(fdt, node, NULL);
> + dev_for_each_subnode(node, parent) {
> + const char *name = (char *)ofnode_get_name(node);
>   enum usb_dr_mode dr_mode;
>   struct udevice *dev;
>   const char *driver;
> @@ -133,7 +130,7 @@ static int dwc3_generic_bind(struct udevice *parent)
>   };
>  
>   ret = device_bind_driver_to_node(parent, driver, name,
> -  offset_to_ofnode(node), );
> +  node, );
>   if (ret) {
>   debug("%s: not able to bind usb device mode\n",
> __func__);
> diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c
> index 80754d7..cbab436 100644
> --- a/drivers/usb/host/xhci-dwc3.c
> +++ b/drivers/usb/host/xhci-dwc3.c
> @@ -202,6 +202,7 @@ static int xhci_dwc3_probe(struct udevice *dev)
>   struct dwc3 *dwc3_reg;
>   enum usb_dr_mode dr_mode;
>   int ret;
> + ofnode node;
>  
>   hccr = (struct xhci_hccr *)((uintptr_t)dev_read_addr(dev));
>   hcor = (struct xhci_hcor *)((uintptr_t)hccr +
> @@ -215,7 +216,7 @@ static int xhci_dwc3_probe(struct udevice *dev)
>  
>   dwc3_core_init(dwc3_reg);
>  
> - dr_mode = usb_get_dr_mode(dev_of_offset(dev));
> + dr_mode = usb_get_dr_mode(node);
>   if (dr_mode == USB_DR_MODE_UNKNOWN)
>   /* by default set dual role mode to HOST */
>   dr_mode = USB_DR_MODE_HOST;
> diff --git a/drivers/usb/host/xhci-zynqmp.c b/drivers/usb/host/xhci-zynqmp.c
>