summaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorMichael Riesch <michael.riesch@wolfvision.net>2022-05-09 13:36:18 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-05-11 08:28:05 +0200
commit3804198cfd05a3b054db9c6a0e1631a0e933625f (patch)
tree8e41cc75b6e6d618e0497d3e8387d47a4a45bec7 /drivers/usb
parent7edf73d4b46faf42e6a783f63cda2aeb34151d13 (diff)
downloadbarebox-3804198cfd05a3b054db9c6a0e1631a0e933625f.tar.gz
barebox-3804198cfd05a3b054db9c6a0e1631a0e933625f.tar.xz
usb: dwc3: align dwc3 clocks with binding
The device tree bindings snps,dwc3.yaml and rockchip,dwc3.yaml specify different clock names. This inconsistency did not matter in the past as the snps,dwc3 used to be a subnode of the rockchip,rk3xyz-dwc3 glue node. For the RK356x, however, a different approach is used and the two nodes are merged. Therefore, the dwc3 driver must accept both groups of clock names. This step is a prerequisite for replacing the initial rk3568.dtsi in arch/arm/dts with the mainline Linux version. For compatibility, the former is updated accordingly. This also illustrates the migration from glue node and subnode to a single device tree node. Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net> Link: https://lore.barebox.org/20220509113618.1602657-3-michael.riesch@wolfvision.net Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/dwc3/core.c50
1 files changed, 40 insertions, 10 deletions
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index fd0ec754e0..30aaef90ac 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -23,6 +23,11 @@
#define DWC3_DEFAULT_AUTOSUSPEND_DELAY 5000 /* ms */
+struct dwc3_match_data {
+ const struct clk_bulk_data *clks;
+ const int num_clks;
+};
+
/**
* dwc3_get_dr_mode - Validates and sets dr_mode
* @dwc: pointer to our context structure
@@ -326,12 +331,6 @@ err0:
return ret;
}
-static const struct clk_bulk_data dwc3_core_clks[] = {
- { .id = "ref" },
- { .id = "bus_early" },
- { .id = "suspend" },
-};
-
/*
* dwc3_frame_length_adjustment - Adjusts frame length if required
* @dwc3: Pointer to our controller context structure
@@ -1098,20 +1097,23 @@ static void dwc3_coresoft_reset(struct dwc3 *dwc)
static int dwc3_probe(struct device_d *dev)
{
+ const struct dwc3_match_data *match;
struct dwc3 *dwc;
int ret;
dwc = xzalloc(sizeof(*dwc));
dev->priv = dwc;
- dwc->clks = xmemdup(dwc3_core_clks, sizeof(dwc3_core_clks));
+ match = device_get_match_data(dev);
+ dwc->clks = xmemdup(match->clks, match->num_clks *
+ sizeof(struct clk_bulk_data));
dwc->dev = dev;
dwc->regs = dev_get_mem_region(dwc->dev, 0) + DWC3_GLOBALS_REGS_START;
dwc3_get_properties(dwc);
if (dev->device_node) {
- dwc->num_clks = ARRAY_SIZE(dwc3_core_clks);
+ dwc->num_clks = match->num_clks;
if (of_find_property(dev->device_node, "clocks", NULL)) {
ret = clk_bulk_get(dev, dwc->num_clks, dwc->clks);
@@ -1176,12 +1178,40 @@ static void dwc3_remove(struct device_d *dev)
clk_bulk_put(dwc->num_clks, dwc->clks);
}
+static const struct clk_bulk_data dwc3_core_clks[] = {
+ { .id = "ref" },
+ { .id = "bus_early" },
+ { .id = "suspend" },
+};
+
+static const struct dwc3_match_data dwc3_default = {
+ .clks = dwc3_core_clks,
+ .num_clks = ARRAY_SIZE(dwc3_core_clks),
+};
+
+static const struct clk_bulk_data dwc3_core_clks_rk3568[] = {
+ { .id = "ref_clk" },
+ { .id = "bus_clk" },
+ { .id = "suspend_clk" },
+};
+
+static const struct dwc3_match_data dwc3_rk3568 = {
+ .clks = dwc3_core_clks_rk3568,
+ .num_clks = ARRAY_SIZE(dwc3_core_clks_rk3568),
+};
+
static const struct of_device_id of_dwc3_match[] = {
{
- .compatible = "snps,dwc3"
+ .compatible = "snps,dwc3",
+ .data = &dwc3_default,
+ },
+ {
+ .compatible = "synopsys,dwc3",
+ .data = &dwc3_default,
},
{
- .compatible = "synopsys,dwc3"
+ .compatible = "rockchip,rk3568-dwc3",
+ .data = &dwc3_rk3568,
},
{ },
};