From 8ae84e64530e81f23066d86417b9225388ba96ae Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sun, 27 Nov 2022 15:31:52 +0100 Subject: [PATCH] usb: dwc3: Cache ref_clk pointer in struct dwc3 Cache ref_clk clock pointer in struct dwc3 . This is a preparatory patch for subsequent backports from Linux kernel which configure GFLADJ register content based on the ref_clk rate and therefore need access to the ref_clk pointer. It is possible to extract the clock pointer from existing clk_bulk list of already claimed clock, no need to call clk_get*() again. Reviewed-by: Sean Anderson Signed-off-by: Marek Vasut --- drivers/usb/dwc3/core.h | 3 +++ drivers/usb/dwc3/dwc3-generic.c | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index d7cce3a861..0d20fe285b 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -668,6 +668,7 @@ struct dwc3_scratchpad_array { * @event_buffer_list: a list of event buffers * @gadget: device side representation of the peripheral controller * @gadget_driver: pointer to the gadget driver + * @ref_clk: reference clock * @regs: base address for our registers * @regs_size: address space size * @nr_scratch: number of scratch buffers @@ -766,6 +767,8 @@ struct dwc3 { struct usb_gadget gadget; struct usb_gadget_driver *gadget_driver; + struct clk *ref_clk; + void __iomem *regs; size_t regs_size; diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index 466b25a0c3..78966718d0 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -59,12 +59,21 @@ static int dwc3_generic_probe(struct udevice *dev, struct dwc3_generic_plat *plat = dev_get_plat(dev); struct dwc3 *dwc3 = &priv->dwc3; struct dwc3_glue_data *glue = dev_get_plat(dev->parent); + int __maybe_unused index; + ofnode __maybe_unused node; dwc3->dev = dev; dwc3->maximum_speed = plat->maximum_speed; dwc3->dr_mode = plat->dr_mode; #if CONFIG_IS_ENABLED(OF_CONTROL) dwc3_of_parse(dwc3); + + 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) + dwc3->ref_clk = &glue->clks.clks[index]; #endif /* -- 2.39.5