usb: dwc3: Initialize Xilinx glue registers
Subsystems (2)
PATCH 1/1 usb: dwc3: Initialize Xilinx glue registers
These registers may have been initialized by SPL/FSBL, but program them in case they have not. If they are left at their default values, the controller will never exit reset.
---
drivers/usb/dwc3/dwc3-generic.c | 32 ++++++++++++++++++++++++++------ drivers/usb/dwc3/dwc3-generic.h | 2 ++ 2 files changed, 28 insertions(+), 6 deletions(-)
drivers/usb/dwc3/dwc3-generic.c +26 -6
@@ -501,6 +501,27 @@ struct dwc3_glue_ops rk_ops = { .glue_get_ctrl_dev = dwc3_rk_glue_get_ctrl_dev, }; +void dwc3_xlnx_glue_configure (struct udevice *dev,int index, +enum usb_dr_mode mode) +{ +/* USB glue registers */ +#define USB3_FPD_PIPE_CLK 0x7c +#define USB3_FPD_POWER_PRSNT 0x80 +struct dwc3_glue_data *glue =dev_get_plat (dev); +void *base =map_physmem (glue->regs,0x10000 ,MAP_NOCACHE ); + +if (generic_phy_valid (&glue->phy)) { +writel (0 , base +USB3_FPD_PIPE_CLK ); +writel (1 , base +USB3_FPD_POWER_PRSNT ); + }else { +writel (1 , base +USB3_FPD_PIPE_CLK ); + } +} + +struct dwc3_glue_ops xlnx_ops = { + .glue_configure = dwc3_xlnx_glue_configure, +}; +static int dwc3_glue_bind_common (struct udevice *parent,ofnode node) {const char *name =ofnode_get_name (node);
@@ -621,11 +642,10 @@ int dwc3_glue_probe(struct udevice *dev)struct udevice *child =NULL ;int index =0 ;int ret; -struct phy phy; - ret =generic_phy_get_by_name (dev,"usb3-phy" , &phy); + ret =generic_phy_get_by_name (dev,"usb3-phy" , &glue->phy);if (!ret) { - ret =generic_phy_init (&phy); + ret =generic_phy_init (&glue->phy);if (ret)return ret; }else if (ret != -ENOENT && ret != -ENODATA ) {
@@ -643,8 +663,8 @@ int dwc3_glue_probe(struct udevice *dev)if (ret)return ret; -if (generic_phy_valid (&phy)) { - ret =generic_phy_power_on (&phy); +if (generic_phy_valid (&glue->phy)) { + ret =generic_phy_power_on (&glue->phy);if (ret)return ret; }
@@ -690,7 +710,7 @@ int dwc3_glue_remove(struct udevice *dev) }static const struct udevice_id dwc3_glue_ids[] = { - { .compatible ="xlnx,zynqmp-dwc3" }, + { .compatible ="xlnx,zynqmp-dwc3" , .data = (ulong)&xlnx_ops }, { .compatible ="xlnx,versal-dwc3" }, { .compatible ="ti,keystone-dwc3" }, { .compatible ="ti,dwc3" , .data = (ulong)&ti_ops },
drivers/usb/dwc3/dwc3-generic.h +2 -0
@@ -10,12 +10,14 @@#define __DRIVERS_USB_DWC3_GENERIC_H#include <clk.h> +#include <generic-phy.h> #include <reset.h> #include <dwc3-uboot.h> struct dwc3_glue_data {struct clk_bulk clks;struct reset_ctl_bulk resets; +struct phy phy;fdt_addr_t regs;fdt_size_t size; };
Signature · 4 lines
2.35.1.1320.gc452695387.dirty base-commit: beab3fe49e1e9209dd32fe2791e7ac706038460f branch: dwc3_xlnx_glue
Quoted 87 lines · Sean Anderson
These registers may have been initialized by SPL/FSBL, but program them in case they have not. If they are left at their default values, the controller will never exit reset.
Signed-off-by Sean Anderson <[email protected]>---
drivers/usb/dwc3/dwc3-generic.c | 32 ++++++++++++++++++++++++++------ drivers/usb/dwc3/dwc3-generic.h | 2 ++ 2 files changed, 28 insertions(+), 6 deletions(-)drivers/usb/dwc3/dwc3-generic.c +26
-6@@ -501,6 +501,27 @@ struct dwc3_glue_ops rk_ops = { .glue_get_ctrl_dev = dwc3_rk_glue_get_ctrl_dev, }; +void dwc3_xlnx_glue_configure (struct udevice *dev,int index, +enum usb_dr_mode mode) +{ +/* USB glue registers */ +#define USB3_FPD_PIPE_CLK 0x7c +#define USB3_FPD_POWER_PRSNT 0x80 +struct dwc3_glue_data *glue =dev_get_plat (dev); +void *base =map_physmem (glue->regs,0x10000 ,MAP_NOCACHE ); + +if (generic_phy_valid (&glue->phy)) { +writel (0 , base +USB3_FPD_PIPE_CLK ); +writel (1 , base +USB3_FPD_POWER_PRSNT ); + }else { +writel (1 , base +USB3_FPD_PIPE_CLK ); + } +} + +struct dwc3_glue_ops xlnx_ops = { + .glue_configure = dwc3_xlnx_glue_configure, +}; +static int dwc3_glue_bind_common (struct udevice *parent,ofnode node) {const char *name =ofnode_get_name (node);@@ -621,11 +642,10 @@ int dwc3_glue_probe(struct udevice *dev)struct udevice *child =NULL ;int index =0 ;int ret; -struct phy phy; - ret =generic_phy_get_by_name (dev,"usb3-phy" , &phy); + ret =generic_phy_get_by_name (dev,"usb3-phy" , &glue->phy);if (!ret) { - ret =generic_phy_init (&phy); + ret =generic_phy_init (&glue->phy);if (ret)return ret; }else if (ret != -ENOENT && ret != -ENODATA ) {@@ -643,8 +663,8 @@ int dwc3_glue_probe(struct udevice *dev)if (ret)return ret; -if (generic_phy_valid (&phy)) { - ret =generic_phy_power_on (&phy); +if (generic_phy_valid (&glue->phy)) { + ret =generic_phy_power_on (&glue->phy);if (ret)return ret; }@@ -690,7 +710,7 @@ int dwc3_glue_remove(struct udevice *dev) }static const struct udevice_id dwc3_glue_ids[] = { - { .compatible ="xlnx,zynqmp-dwc3" }, + { .compatible ="xlnx,zynqmp-dwc3" , .data = (ulong)&xlnx_ops }, { .compatible ="xlnx,versal-dwc3" }, { .compatible ="ti,keystone-dwc3" }, { .compatible ="ti,dwc3" , .data = (ulong)&ti_ops },drivers/usb/dwc3/dwc3-generic.h +1
-0@@ -10,12 +10,14 @@#define __DRIVERS_USB_DWC3_GENERIC_H#include <clk.h> +#include <generic-phy.h>
drivers/usb/dwc3/dwc3-generic.h line 23
Quoted 10 lines
drivers/usb/dwc3/dwc3-generic.h +1
-0#include <reset.h> #include <dwc3-uboot.h> struct dwc3_glue_data {struct clk_bulk clks;struct reset_ctl_bulk resets; +struct phy phy;fdt_addr_t regs;fdt_size_t size; };
I will let Marek to handle this. From my perspective we should take Jerome's patchset to update usb stack and then add this on the top.
Thanks,
Michal
Quoted 88 lines · Michal Simek
Quoted 85 lines · Sean Anderson
These registers may have been initialized by SPL/FSBL, but program them in case they have not. If they are left at their default values, the controller will never exit reset.
Signed-off-by Sean Anderson <[email protected]>---
drivers/usb/dwc3/dwc3-generic.c| 32 ++++++++++++++++++++++++++------drivers/usb/dwc3/dwc3-generic.h| 2 ++2 files changed, 28 insertions(+), 6 deletions(-)drivers/usb/dwc3/dwc3-generic.c +26
-6@@ -501,6 +501,27 @@ struct dwc3_glue_ops rk_ops = { .glue_get_ctrl_dev = dwc3_rk_glue_get_ctrl_dev, }; +void dwc3_xlnx_glue_configure (struct udevice *dev,int index, + enum usb_dr_mode mode) +{ +/* USB glue registers */ +#define USB3_FPD_PIPE_CLK 0x7c +#define USB3_FPD_POWER_PRSNT 0x80 + struct dwc3_glue_data *glue = dev_get_plat(dev); + void *base = map_physmem(glue->regs, 0x10000, MAP_NOCACHE); + + if (generic_phy_valid(&glue->phy)) { + writel(0, base + USB3_FPD_PIPE_CLK); + writel(1, base + USB3_FPD_POWER_PRSNT); + } else { + writel(1, base + USB3_FPD_PIPE_CLK); + } +} + +struct dwc3_glue_ops xlnx_ops = { + .glue_configure = dwc3_xlnx_glue_configure, +}; + static int dwc3_glue_bind_common(struct udevice *parent, ofnode node) { const char *name = ofnode_get_name(node);@@ -621,11 +642,10 @@ int dwc3_glue_probe(struct udevice *dev) struct udevice *child = NULL; int index = 0; int ret; - struct phy phy; - ret = generic_phy_get_by_name(dev, "usb3-phy", &phy); + ret = generic_phy_get_by_name(dev, "usb3-phy", &glue->phy); if (!ret) { - ret = generic_phy_init(&phy); + ret = generic_phy_init(&glue->phy); if (ret) return ret; } else if (ret != -ENOENT && ret != -ENODATA) {@@ -643,8 +663,8 @@ int dwc3_glue_probe(struct udevice *dev) if (ret) return ret; - if (generic_phy_valid(&phy)) { - ret = generic_phy_power_on(&phy); + if (generic_phy_valid(&glue->phy)) { + ret = generic_phy_power_on(&glue->phy); if (ret) return ret; }@@ -690,7 +710,7 @@ int dwc3_glue_remove(struct udevice *dev) } static const struct udevice_id dwc3_glue_ids[] = { - { .compatible = "xlnx,zynqmp-dwc3" }, + { .compatible = "xlnx,zynqmp-dwc3", .data = (ulong)&xlnx_ops }, { .compatible = "xlnx,versal-dwc3" }, { .compatible = "ti,keystone-dwc3"}, { .compatible = "ti,dwc3", .data = (ulong)&ti_ops },drivers/usb/dwc3/dwc3-generic.h +1
-0@@ -10,12 +10,14 @@ #define __DRIVERS_USB_DWC3_GENERIC_H #include <clk.h> +#include <generic-phy.h> #include <reset.h> #include <dwc3-uboot.h> struct dwc3_glue_data {
Quoted 8 lines
drivers/usb/dwc3/dwc3-generic.h line 23
Quoted 6 lines
drivers/usb/dwc3/dwc3-generic.h +1
-0struct clk_bulk clks; struct reset_ctl_bulk resets; + struct phy phy; fdt_addr_t regs; fdt_size_t size; };I will let Marek to handle this. From my perspective we should take Jerome's patchset to update usb stack and then add this on the top.
Since this fixes a real bug and is isolated to xilinx platform, it would be good if xilinx at least provided feedback on this patch.
+CC Ilias
Quoted 97 lines · Marek Vasut
Quoted 88 lines · Michal Simek
Quoted 85 lines · Sean Anderson
These registers may have been initialized by SPL/FSBL, but program them in case they have not. If they are left at their default values, the controller will never exit reset.
Signed-off-by Sean Anderson <[email protected]>---
drivers/usb/dwc3/dwc3-generic.c| 32 ++++++++++++++++++++++++++------drivers/usb/dwc3/dwc3-generic.h| 2 ++2 files changed, 28 insertions(+), 6 deletions(-)drivers/usb/dwc3/dwc3-generic.c +26
-6@@ -501,6 +501,27 @@ struct dwc3_glue_ops rk_ops = { .glue_get_ctrl_dev = dwc3_rk_glue_get_ctrl_dev, }; +void dwc3_xlnx_glue_configure (struct udevice *dev,int index, + enum usb_dr_mode mode) +{ +/* USB glue registers */ +#define USB3_FPD_PIPE_CLK 0x7c +#define USB3_FPD_POWER_PRSNT 0x80 + struct dwc3_glue_data *glue = dev_get_plat(dev); + void *base = map_physmem(glue->regs, 0x10000, MAP_NOCACHE); + + if (generic_phy_valid(&glue->phy)) { + writel(0, base + USB3_FPD_PIPE_CLK); + writel(1, base + USB3_FPD_POWER_PRSNT); + } else { + writel(1, base + USB3_FPD_PIPE_CLK); + } +} + +struct dwc3_glue_ops xlnx_ops = { + .glue_configure = dwc3_xlnx_glue_configure, +}; + static int dwc3_glue_bind_common(struct udevice *parent, ofnode node) { const char *name = ofnode_get_name(node);@@ -621,11 +642,10 @@ int dwc3_glue_probe(struct udevice *dev) struct udevice *child = NULL; int index = 0; int ret; - struct phy phy; - ret = generic_phy_get_by_name(dev, "usb3-phy", &phy); + ret = generic_phy_get_by_name(dev, "usb3-phy", &glue->phy); if (!ret) { - ret = generic_phy_init(&phy); + ret = generic_phy_init(&glue->phy); if (ret) return ret; } else if (ret != -ENOENT && ret != -ENODATA) {@@ -643,8 +663,8 @@ int dwc3_glue_probe(struct udevice *dev) if (ret) return ret; - if (generic_phy_valid(&phy)) { - ret = generic_phy_power_on(&phy); + if (generic_phy_valid(&glue->phy)) { + ret = generic_phy_power_on(&glue->phy); if (ret) return ret; }@@ -690,7 +710,7 @@ int dwc3_glue_remove(struct udevice *dev) } static const struct udevice_id dwc3_glue_ids[] = { - { .compatible = "xlnx,zynqmp-dwc3" }, + { .compatible = "xlnx,zynqmp-dwc3", .data = (ulong)&xlnx_ops }, { .compatible = "xlnx,versal-dwc3" }, { .compatible = "ti,keystone-dwc3"}, { .compatible = "ti,dwc3", .data = (ulong)&ti_ops },drivers/usb/dwc3/dwc3-generic.h +1
-0@@ -10,12 +10,14 @@ #define __DRIVERS_USB_DWC3_GENERIC_H #include <clk.h> +#include <generic-phy.h> #include <reset.h> #include <dwc3-uboot.h> struct dwc3_glue_data {Quoted 8 lines
drivers/usb/dwc3/dwc3-generic.h line 23
Quoted 6 lines
drivers/usb/dwc3/dwc3-generic.h +1
-0struct clk_bulk clks; struct reset_ctl_bulk resets; + struct phy phy; fdt_addr_t regs; fdt_size_t size; };I will let Marek to handle this. From my perspective we should take Jerome's patchset to update usb stack and then add this on the top.
Quoted 3 lines
Since this fixes a real bug and is isolated to xilinx platform, it would be good if xilinx at least provided feedback on this patch.
+CC Ilias
It's not a bug fix (hence no fixes tag). See [1,2] for details.
--Sean
[1] https://lore.kernel.org/linux-usb/[email protected]/
[2] https://lore.kernel.org/linux-usb/[email protected]/
+Love
Quoted 100 lines · Sean Anderson
Quoted 99 lines · Marek Vasut
Quoted 88 lines · Michal Simek
Quoted 85 lines · Sean Anderson
These registers may have been initialized by SPL/FSBL, but program them in case they have not. If they are left at their default values, the controller will never exit reset.
Signed-off-by Sean Anderson <[email protected]>---
drivers/usb/dwc3/dwc3-generic.c | 32 ++++++++++++++++++++++++++------ drivers/usb/dwc3/dwc3-generic.h | 2 ++ 2 files changed, 28 insertions(+), 6 deletions(-)drivers/usb/dwc3/dwc3-generic.c +26
-6@@ -501,6 +501,27 @@ struct dwc3_glue_ops rk_ops = { .glue_get_ctrl_dev = dwc3_rk_glue_get_ctrl_dev, }; +void dwc3_xlnx_glue_configure (struct udevice *dev,int index, + enum usb_dr_mode mode) +{ +/* USB glue registers */ +#define USB3_FPD_PIPE_CLK 0x7c +#define USB3_FPD_POWER_PRSNT 0x80 + struct dwc3_glue_data *glue = dev_get_plat(dev); + void *base = map_physmem(glue->regs, 0x10000, MAP_NOCACHE); + + if (generic_phy_valid(&glue->phy)) { + writel(0, base + USB3_FPD_PIPE_CLK); + writel(1, base + USB3_FPD_POWER_PRSNT); + } else { + writel(1, base + USB3_FPD_PIPE_CLK); + } +} + +struct dwc3_glue_ops xlnx_ops = { + .glue_configure = dwc3_xlnx_glue_configure, +}; + static int dwc3_glue_bind_common(struct udevice *parent, ofnode node) { const char *name = ofnode_get_name(node);@@ -621,11 +642,10 @@ int dwc3_glue_probe(struct udevice *dev) struct udevice *child = NULL; int index = 0; int ret; - struct phy phy; - ret = generic_phy_get_by_name(dev, "usb3-phy", &phy); + ret = generic_phy_get_by_name(dev, "usb3-phy", &glue->phy); if (!ret) { - ret = generic_phy_init(&phy); + ret = generic_phy_init(&glue->phy); if (ret) return ret; } else if (ret != -ENOENT && ret != -ENODATA) {@@ -643,8 +663,8 @@ int dwc3_glue_probe(struct udevice *dev) if (ret) return ret; - if (generic_phy_valid(&phy)) { - ret = generic_phy_power_on(&phy); + if (generic_phy_valid(&glue->phy)) { + ret = generic_phy_power_on(&glue->phy); if (ret) return ret; }@@ -690,7 +710,7 @@ int dwc3_glue_remove(struct udevice *dev) } static const struct udevice_id dwc3_glue_ids[] = { - { .compatible = "xlnx,zynqmp-dwc3" }, + { .compatible = "xlnx,zynqmp-dwc3", .data = (ulong)&xlnx_ops }, { .compatible = "xlnx,versal-dwc3" }, { .compatible = "ti,keystone-dwc3"}, { .compatible = "ti,dwc3", .data = (ulong)&ti_ops },drivers/usb/dwc3/dwc3-generic.h +1
-0@@ -10,12 +10,14 @@ #define __DRIVERS_USB_DWC3_GENERIC_H #include <clk.h> +#include <generic-phy.h> #include <reset.h> #include <dwc3-uboot.h> struct dwc3_glue_data {Quoted 8 lines
drivers/usb/dwc3/dwc3-generic.h line 23
Quoted 6 lines
drivers/usb/dwc3/dwc3-generic.h +1
-0struct clk_bulk clks; struct reset_ctl_bulk resets; + struct phy phy; fdt_addr_t regs; fdt_size_t size; };I will let Marek to handle this. From my perspective we should take Jerome's patchset to update usb stack and then add this on the top.
Since this fixes a real bug and is isolated to xilinx platform, it would be good if xilinx at least provided feedback on this patch.
Quoted 8 lines
Quoted 1 line
+CC Ilias
It's not a bug fix (hence no fixes tag). See [1,2] for details.
--Sean
[1] https://lore.kernel.org/linux-usb/[email protected]/
[2] https://lore.kernel.org/linux-usb/[email protected]/
Love: Can you please test this patch and provide your tested-by flag if it is working.
Thanks,
Michal
Kumar, Love
Tested-byHi,
Quoted 13 lines · Michal Simek
+Love
Quoted 10 lines · Sean Anderson
Quoted 9 lines · Marek Vasut
Quoted 8 lines · Michal Simek
Quoted 5 lines · Sean Anderson
These registers may have been initialized by SPL/FSBL, but program them in case they have not. If they are left at their default values, the controller will never exit reset.
Signed-off-by Sean Anderson <[email protected]>
Verified it on AMD platforms and not seeing any issue.
Regards,
Love Kumar
Quoted 104 lines
Quoted 90 lines
Quoted 90 lines
Quoted 80 lines
Quoted 80 lines
---
drivers/usb/dwc3/dwc3-generic.c| 32 ++++++++++++++++++++++++++------drivers/usb/dwc3/dwc3-generic.h| 2 ++2 files changed, 28 insertions(+), 6 deletions(-)drivers/usb/dwc3/dwc3-generic.c +26
-6@@ -501,6 +501,27 @@ struct dwc3_glue_ops rk_ops = { .glue_get_ctrl_dev = dwc3_rk_glue_get_ctrl_dev, }; +void dwc3_xlnx_glue_configure (struct udevice *dev,int index, + enum usb_dr_mode mode) +{ +/* USB glue registers */ +#define USB3_FPD_PIPE_CLK 0x7c +#define USB3_FPD_POWER_PRSNT 0x80 + struct dwc3_glue_data *glue = dev_get_plat(dev); + void *base = map_physmem(glue->regs, 0x10000, MAP_NOCACHE); + + if (generic_phy_valid(&glue->phy)) { + writel(0, base + USB3_FPD_PIPE_CLK); + writel(1, base + USB3_FPD_POWER_PRSNT); + } else { + writel(1, base + USB3_FPD_PIPE_CLK); + } +} + +struct dwc3_glue_ops xlnx_ops = { + .glue_configure = dwc3_xlnx_glue_configure, +}; + static int dwc3_glue_bind_common(struct udevice *parent, ofnode node) { const char *name = ofnode_get_name(node);@@ -621,11 +642,10 @@ int dwc3_glue_probe(struct udevice *dev) struct udevice *child = NULL; int index = 0; int ret; - struct phy phy; - ret = generic_phy_get_by_name(dev, "usb3-phy", &phy); + ret = generic_phy_get_by_name(dev, "usb3-phy", &glue->phy); if (!ret) { - ret = generic_phy_init(&phy); + ret = generic_phy_init(&glue->phy); if (ret) return ret; } else if (ret != -ENOENT && ret != -ENODATA) {@@ -643,8 +663,8 @@ int dwc3_glue_probe(struct udevice *dev) if (ret) return ret; - if (generic_phy_valid(&phy)) { - ret = generic_phy_power_on(&phy); + if (generic_phy_valid(&glue->phy)) { + ret = generic_phy_power_on(&glue->phy); if (ret) return ret; }@@ -690,7 +710,7 @@ int dwc3_glue_remove(struct udevice *dev) } static const struct udevice_id dwc3_glue_ids[] = { - { .compatible = "xlnx,zynqmp-dwc3" }, + { .compatible = "xlnx,zynqmp-dwc3", .data = (ulong)&xlnx_ops }, { .compatible = "xlnx,versal-dwc3" }, { .compatible = "ti,keystone-dwc3"}, { .compatible = "ti,dwc3", .data = (ulong)&ti_ops },drivers/usb/dwc3/dwc3-generic.h +1
-0@@ -10,12 +10,14 @@ #define __DRIVERS_USB_DWC3_GENERIC_H #include <clk.h> +#include <generic-phy.h> #include <reset.h> #include <dwc3-uboot.h> struct dwc3_glue_data {Quoted 8 lines
drivers/usb/dwc3/dwc3-generic.h line 23
Quoted 6 lines
drivers/usb/dwc3/dwc3-generic.h +1
-0struct clk_bulk clks; struct reset_ctl_bulk resets; + struct phy phy; fdt_addr_t regs; fdt_size_t size; };I will let Marek to handle this. From my perspective we should take Jerome's patchset to update usb stack and then add this on the top.
Since this fixes a real bug and is isolated to xilinx platform, it would be good if xilinx at least provided feedback on this patch.
Quoted 8 lines
Quoted 1 line
+CC Ilias
It's not a bug fix (hence no fixes tag). See [1,2] for details.
--Sean
[1] https://lore.kernel.org/linux-usb/[email protected]/
[2] https://lore.kernel.org/linux-usb/[email protected]/Love: Can you please test this patch and provide your tested-by flag if it is working.
Thanks,
Michal
Quoted 98 lines · Sean Anderson
Quoted 97 lines · Marek Vasut
Quoted 96 lines · Michal Simek
Quoted 81 lines · Sean Anderson
These registers may have been initialized by SPL/FSBL, but program them in case they have not. If they are left at their default values, the controller will never exit reset.
Signed-off-by Sean Anderson <[email protected]>---
drivers/usb/dwc3/dwc3-generic.c | 32 ++++++++++++++++++++++++++------ drivers/usb/dwc3/dwc3-generic.h | 2 ++ 2 files changed, 28 insertions(+), 6 deletions(-)drivers/usb/dwc3/dwc3-generic.c +26
-6@@ -501,6 +501,27 @@ struct dwc3_glue_ops rk_ops = { .glue_get_ctrl_dev = dwc3_rk_glue_get_ctrl_dev, }; +void dwc3_xlnx_glue_configure (struct udevice *dev,int index, + enum usb_dr_mode mode) +{ +/* USB glue registers */ +#define USB3_FPD_PIPE_CLK 0x7c +#define USB3_FPD_POWER_PRSNT 0x80 + struct dwc3_glue_data *glue = dev_get_plat(dev); + void *base = map_physmem(glue->regs, 0x10000, MAP_NOCACHE); + + if (generic_phy_valid(&glue->phy)) { + writel(0, base + USB3_FPD_PIPE_CLK); + writel(1, base + USB3_FPD_POWER_PRSNT); + } else { + writel(1, base + USB3_FPD_PIPE_CLK); + } +} + +struct dwc3_glue_ops xlnx_ops = { + .glue_configure = dwc3_xlnx_glue_configure, +}; + static int dwc3_glue_bind_common(struct udevice *parent, ofnode node) { const char *name = ofnode_get_name(node);@@ -621,11 +642,10 @@ int dwc3_glue_probe(struct udevice *dev) struct udevice *child = NULL; int index = 0; int ret; - struct phy phy; - ret = generic_phy_get_by_name(dev, "usb3-phy", &phy); + ret = generic_phy_get_by_name(dev, "usb3-phy", &glue->phy); if (!ret) { - ret = generic_phy_init(&phy); + ret = generic_phy_init(&glue->phy); if (ret) return ret; } else if (ret != -ENOENT && ret != -ENODATA) {@@ -643,8 +663,8 @@ int dwc3_glue_probe(struct udevice *dev) if (ret) return ret; - if (generic_phy_valid(&phy)) { - ret = generic_phy_power_on(&phy); + if (generic_phy_valid(&glue->phy)) { + ret = generic_phy_power_on(&glue->phy); if (ret) return ret; }@@ -690,7 +710,7 @@ int dwc3_glue_remove(struct udevice *dev) } static const struct udevice_id dwc3_glue_ids[] = { - { .compatible = "xlnx,zynqmp-dwc3" }, + { .compatible = "xlnx,zynqmp-dwc3", .data = (ulong)&xlnx_ops }, { .compatible = "xlnx,versal-dwc3" }, { .compatible = "ti,keystone-dwc3"}, { .compatible = "ti,dwc3", .data = (ulong)&ti_ops },drivers/usb/dwc3/dwc3-generic.h +0
-0@@ -10,12 +10,14 @@ #define __DRIVERS_USB_DWC3_GENERIC_H #include <clk.h>drivers/usb/dwc3/dwc3-generic.h line 21
Quoted 10 lines
drivers/usb/dwc3/dwc3-generic.h +2
-0+#include <generic-phy.h> #include <reset.h> #include <dwc3-uboot.h> struct dwc3_glue_data { struct clk_bulk clks; struct reset_ctl_bulk resets; + struct phy phy; fdt_addr_t regs; fdt_size_t size; };I will let Marek to handle this. From my perspective we should take Jerome's patchset to update usb stack and then add this on the top.
Quoted 6 lines
Quoted 3 lines
Since this fixes a real bug and is isolated to xilinx platform, it would be good if xilinx at least provided feedback on this patch.
+CC Ilias
It's not a bug fix (hence no fixes tag). See [1,2] for details.
Please hold on this patch. I got information that we see some issues on one board when this patch is applied. We will get back to you.
Thanks,
Michal
Quoted 103 lines · Michal Simek
Quoted 100 lines · Sean Anderson
Quoted 99 lines · Marek Vasut
Quoted 88 lines · Michal Simek
Quoted 85 lines · Sean Anderson
These registers may have been initialized by SPL/FSBL, but program them in case they have not. If they are left at their default values, the controller will never exit reset.
Signed-off-by Sean Anderson <[email protected]>---
drivers/usb/dwc3/dwc3-generic.c| 32 ++++++++++++++++++++++++++------drivers/usb/dwc3/dwc3-generic.h| 2 ++2 files changed, 28 insertions(+), 6 deletions(-)drivers/usb/dwc3/dwc3-generic.c +26
-6@@ -501,6 +501,27 @@ struct dwc3_glue_ops rk_ops = { .glue_get_ctrl_dev = dwc3_rk_glue_get_ctrl_dev, }; +void dwc3_xlnx_glue_configure (struct udevice *dev,int index, + enum usb_dr_mode mode) +{ +/* USB glue registers */ +#define USB3_FPD_PIPE_CLK 0x7c +#define USB3_FPD_POWER_PRSNT 0x80 + struct dwc3_glue_data *glue = dev_get_plat(dev); + void *base = map_physmem(glue->regs, 0x10000, MAP_NOCACHE); + + if (generic_phy_valid(&glue->phy)) { + writel(0, base + USB3_FPD_PIPE_CLK); + writel(1, base + USB3_FPD_POWER_PRSNT); + } else { + writel(1, base + USB3_FPD_PIPE_CLK); + } +} + +struct dwc3_glue_ops xlnx_ops = { + .glue_configure = dwc3_xlnx_glue_configure, +}; + static int dwc3_glue_bind_common(struct udevice *parent, ofnode node) { const char *name = ofnode_get_name(node);@@ -621,11 +642,10 @@ int dwc3_glue_probe(struct udevice *dev) struct udevice *child = NULL; int index = 0; int ret; - struct phy phy; - ret = generic_phy_get_by_name(dev, "usb3-phy", &phy); + ret = generic_phy_get_by_name(dev, "usb3-phy", &glue->phy); if (!ret) { - ret = generic_phy_init(&phy); + ret = generic_phy_init(&glue->phy); if (ret) return ret; } else if (ret != -ENOENT && ret != -ENODATA) {@@ -643,8 +663,8 @@ int dwc3_glue_probe(struct udevice *dev) if (ret) return ret; - if (generic_phy_valid(&phy)) { - ret = generic_phy_power_on(&phy); + if (generic_phy_valid(&glue->phy)) { + ret = generic_phy_power_on(&glue->phy); if (ret) return ret; }@@ -690,7 +710,7 @@ int dwc3_glue_remove(struct udevice *dev) } static const struct udevice_id dwc3_glue_ids[] = { - { .compatible = "xlnx,zynqmp-dwc3" }, + { .compatible = "xlnx,zynqmp-dwc3", .data = (ulong)&xlnx_ops }, { .compatible = "xlnx,versal-dwc3" }, { .compatible = "ti,keystone-dwc3"}, { .compatible = "ti,dwc3", .data = (ulong)&ti_ops },drivers/usb/dwc3/dwc3-generic.h +1
-0@@ -10,12 +10,14 @@ #define __DRIVERS_USB_DWC3_GENERIC_H #include <clk.h> +#include <generic-phy.h> #include <reset.h> #include <dwc3-uboot.h> struct dwc3_glue_data {Quoted 8 lines
drivers/usb/dwc3/dwc3-generic.h line 23
Quoted 6 lines
drivers/usb/dwc3/dwc3-generic.h +1
-0struct clk_bulk clks; struct reset_ctl_bulk resets; + struct phy phy; fdt_addr_t regs; fdt_size_t size; };I will let Marek to handle this. From my perspective we should take Jerome's patchset to update usb stack and then add this on the top.
Since this fixes a real bug and is isolated to xilinx platform, it would be good if xilinx at least provided feedback on this patch.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
+CC Ilias
It's not a bug fix (hence no fixes tag). See [1,2] for details.
Please hold on this patch. I got information that we see some issues on one board when this patch is applied. We will get back to you.
ok. No problem from our side.
M