Skip to content

Commit 3ae2da7

Browse files
gclementgregkh
authored andcommitted
usb: host: xhci-plat: Fix clock resource by adding a register clock
On Armada 7K/8K we need to explicitly enable the register clock. This clock is optional because not all the SoCs using this IP need it but at least for Armada 7K/8K it is actually mandatory. The change was done at xhci-plat level and not at a xhci-mvebu.c because, it is expected that other SoC would have this kind of constraint. The binding documentation is updating accordingly. Signed-off-by: Gregory CLEMENT <[email protected]> Signed-off-by: Mathias Nyman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2d79609 commit 3ae2da7

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

Documentation/devicetree/bindings/usb/usb-xhci.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ Required properties:
2828
- interrupts: one XHCI interrupt should be described here.
2929

3030
Optional properties:
31-
- clocks: reference to a clock
31+
- clocks: reference to the clocks
32+
- clock-names: mandatory if there is a second clock, in this case
33+
the name must be "core" for the first clock and "reg" for the
34+
second one
3235
- usb2-lpm-disable: indicate if we don't want to enable USB2 HW LPM
3336
- usb3-lpm-capable: determines if platform is USB3 LPM capable
3437
- quirk-broken-port-ped: set if the controller has broken port disable mechanism

drivers/usb/host/xhci-plat.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
157157
struct resource *res;
158158
struct usb_hcd *hcd;
159159
struct clk *clk;
160+
struct clk *reg_clk;
160161
int ret;
161162
int irq;
162163

@@ -226,17 +227,27 @@ static int xhci_plat_probe(struct platform_device *pdev)
226227
hcd->rsrc_len = resource_size(res);
227228

228229
/*
229-
* Not all platforms have a clk so it is not an error if the
230-
* clock does not exists.
230+
* Not all platforms have clks so it is not an error if the
231+
* clock do not exist.
231232
*/
233+
reg_clk = devm_clk_get(&pdev->dev, "reg");
234+
if (!IS_ERR(reg_clk)) {
235+
ret = clk_prepare_enable(reg_clk);
236+
if (ret)
237+
goto put_hcd;
238+
} else if (PTR_ERR(reg_clk) == -EPROBE_DEFER) {
239+
ret = -EPROBE_DEFER;
240+
goto put_hcd;
241+
}
242+
232243
clk = devm_clk_get(&pdev->dev, NULL);
233244
if (!IS_ERR(clk)) {
234245
ret = clk_prepare_enable(clk);
235246
if (ret)
236-
goto put_hcd;
247+
goto disable_reg_clk;
237248
} else if (PTR_ERR(clk) == -EPROBE_DEFER) {
238249
ret = -EPROBE_DEFER;
239-
goto put_hcd;
250+
goto disable_reg_clk;
240251
}
241252

242253
xhci = hcd_to_xhci(hcd);
@@ -252,6 +263,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
252263
device_wakeup_enable(hcd->self.controller);
253264

254265
xhci->clk = clk;
266+
xhci->reg_clk = reg_clk;
255267
xhci->main_hcd = hcd;
256268
xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
257269
dev_name(&pdev->dev), hcd);
@@ -322,6 +334,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
322334
disable_clk:
323335
clk_disable_unprepare(clk);
324336

337+
disable_reg_clk:
338+
clk_disable_unprepare(reg_clk);
339+
325340
put_hcd:
326341
usb_put_hcd(hcd);
327342

@@ -337,6 +352,7 @@ static int xhci_plat_remove(struct platform_device *dev)
337352
struct usb_hcd *hcd = platform_get_drvdata(dev);
338353
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
339354
struct clk *clk = xhci->clk;
355+
struct clk *reg_clk = xhci->reg_clk;
340356

341357
xhci->xhc_state |= XHCI_STATE_REMOVING;
342358

@@ -347,6 +363,7 @@ static int xhci_plat_remove(struct platform_device *dev)
347363
usb_put_hcd(xhci->shared_hcd);
348364

349365
clk_disable_unprepare(clk);
366+
clk_disable_unprepare(reg_clk);
350367
usb_put_hcd(hcd);
351368

352369
pm_runtime_set_suspended(&dev->dev);

drivers/usb/host/xhci.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1729,8 +1729,9 @@ struct xhci_hcd {
17291729
int page_shift;
17301730
/* msi-x vectors */
17311731
int msix_count;
1732-
/* optional clock */
1732+
/* optional clocks */
17331733
struct clk *clk;
1734+
struct clk *reg_clk;
17341735
/* data structures */
17351736
struct xhci_device_context_array *dcbaa;
17361737
struct xhci_ring *cmd_ring;

0 commit comments

Comments
 (0)