[PATCH] dwc3: Get the ref clock from the child node(dwc3)

Currently the parent node(dwc3) ref_clk is updated to the dwc3->ref_clk, but we need to update the child node(dwc3) "ref" clock to the dwc3->ref_clk. For versal SOC, the parent node(usb) ref_clk is updated to dwc3->ref_clk which is USB3_DUAL_REF, whereas it should contain the child node(dwc3) "ref" clk i.e., USB0_BUS_REF. With this once we trigger "usb start" the device is crashing. For ZynqMP SOC, crash is not observed because the parent node(usb) ref_clk and the child node(dwc3) "ref" clk is pointing to same USB3_DUAL_REF clock. Fix this by directly updating the child node(dwc3) "ref" clk to dwc3->ref_clk from the dwc3_of_parse() function.
Signed-off-by: Venkatesh Yadav Abbarapu venkatesh.abbarapu@amd.com --- TBD: Need to port the clocks patch from linux kernel [ Sean Anderson:Ported from Linux kernel commit 33fb697ec7e5 ("usb: dwc3: Get clocks individually") ] --- drivers/usb/dwc3/core.c | 4 +++- drivers/usb/dwc3/dwc3-generic.c | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index c80f2d0a53..3667691651 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1105,7 +1105,9 @@ void dwc3_of_parse(struct dwc3 *dwc) | (dwc->is_utmi_l1_suspend << 4);
dev_read_u32(dev, "snps,quirk-frame-length-adjustment", &dwc->fladj); - + dwc->ref_clk = devm_clk_get_optional(dev, "ref"); + if (IS_ERR(dwc->ref_clk)) + dev_err(dev, "dwc3 ref clock not found\n"); /* * Handle property "snps,incr-burst-type-adjustment". * Get the number of value from this property: diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index 66da5a8d6f..f2c512715c 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -75,18 +75,20 @@ static int dwc3_generic_probe(struct udevice *dev, * with the top level node as that seems to be used in majority of DTs * to reference the clock. */ - node = dev_ofnode(dev->parent); - index = ofnode_stringlist_search(node, "clock-names", "ref"); - if (index < 0) - index = ofnode_stringlist_search(node, "clock-names", "ref_clk"); - if (index < 0) { - node = dev_ofnode(dev); + if (!IS_ENABLED(CONFIG_ARCH_VERSAL)) { + node = dev_ofnode(dev->parent); index = ofnode_stringlist_search(node, "clock-names", "ref"); if (index < 0) index = ofnode_stringlist_search(node, "clock-names", "ref_clk"); + if (index < 0) { + node = dev_ofnode(dev); + index = ofnode_stringlist_search(node, "clock-names", "ref"); + if (index < 0) + index = ofnode_stringlist_search(node, "clock-names", "ref_clk"); + } + if (index >= 0) + dwc3->ref_clk = &glue->clks.clks[index]; } - if (index >= 0) - dwc3->ref_clk = &glue->clks.clks[index]; #endif
/*

On 5/9/23 06:11, Venkatesh Yadav Abbarapu wrote:
Currently the parent node(dwc3) ref_clk is updated to the dwc3->ref_clk, but we need to update the child node(dwc3) "ref" clock to the dwc3->ref_clk. For versal SOC, the parent node(usb) ref_clk is updated to dwc3->ref_clk which is USB3_DUAL_REF, whereas it should contain the child node(dwc3) "ref" clk i.e., USB0_BUS_REF. With this once we trigger "usb start" the device is crashing. For ZynqMP SOC, crash is not observed because the parent node(usb) ref_clk and the child node(dwc3) "ref" clk is pointing to same USB3_DUAL_REF clock. Fix this by directly updating the child node(dwc3) "ref" clk to dwc3->ref_clk from the dwc3_of_parse() function.
Signed-off-by: Venkatesh Yadav Abbarapu venkatesh.abbarapu@amd.com
TBD: Need to port the clocks patch from linux kernel
I will wait for a proper backport of all the missing patches, not just a subset.
Also, this is clearly a work-in-progress patch, please mark it as "[RFC]" next time.
participants (2)
-
Marek Vasut
-
Venkatesh Yadav Abbarapu