[PATCH v2 1/5] usb: dwc3: Cache ref_clk pointer in struct dwc3
Marek Vasut
marex at denx.de
Tue Nov 8 02:40:09 CET 2022
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.
Signed-off-by: Marek Vasut <marex at denx.de>
---
Cc: Angus Ainslie <angus at akkea.ca>
Cc: Bin Meng <bmeng.cn at gmail.com>
Cc: Fabio Estevam <festevam at gmail.com>
Cc: Kunihiko Hayashi <hayashi.kunihiko at socionext.com>
Cc: Michal Simek <michal.simek at xilinx.com>
Cc: Peng Fan <peng.fan at nxp.com>
Cc: Sean Anderson <sean.anderson at seco.com>
Cc: Stefano Babic <sbabic at denx.de>
---
V2: Add paragraph on clk_get into commit message
---
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 d7cce3a861a..0d20fe285b0 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 466b25a0c38..78966718d01 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.35.1
More information about the U-Boot
mailing list