Skip to content

Commit 26c5027

Browse files
ozbenhgregkh
authored andcommitted
usb: uhci: Add clk support to uhci-platform
The Aspeed SoCs use uhci-platform. With the new dynamic clock control framework, the corresponding IP block clock must be properly enabled. This is a simplified variant of what ehci-platform does, it looks for *one* clock attached to the device, and if it's there, enables it. Signed-off-by: Benjamin Herrenschmidt <[email protected]> Acked-by: Alan Stern <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent cbeef22 commit 26c5027

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

drivers/usb/host/uhci-hcd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <linux/list.h>
66
#include <linux/usb.h>
7+
#include <linux/clk.h>
78

89
#define usb_packetid(pipe) (usb_pipein(pipe) ? USB_PID_IN : USB_PID_OUT)
910
#define PIPE_DEVEP_MASK 0x0007ff00
@@ -447,6 +448,8 @@ struct uhci_hcd {
447448
int total_load; /* Sum of array values */
448449
short load[MAX_PHASE]; /* Periodic allocations */
449450

451+
struct clk *clk; /* (optional) clock source */
452+
450453
/* Reset host controller */
451454
void (*reset_hc) (struct uhci_hcd *uhci);
452455
int (*check_and_reset_hc) (struct uhci_hcd *uhci);

drivers/usb/host/uhci-platform.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ static int uhci_hcd_platform_probe(struct platform_device *pdev)
8989
if (!hcd)
9090
return -ENOMEM;
9191

92+
uhci = hcd_to_uhci(hcd);
93+
9294
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
9395
hcd->regs = devm_ioremap_resource(&pdev->dev, res);
9496
if (IS_ERR(hcd->regs)) {
@@ -98,8 +100,6 @@ static int uhci_hcd_platform_probe(struct platform_device *pdev)
98100
hcd->rsrc_start = res->start;
99101
hcd->rsrc_len = resource_size(res);
100102

101-
uhci = hcd_to_uhci(hcd);
102-
103103
uhci->regs = hcd->regs;
104104

105105
/* Grab some things from the device-tree */
@@ -119,13 +119,28 @@ static int uhci_hcd_platform_probe(struct platform_device *pdev)
119119
"Enabled Aspeed implementation workarounds\n");
120120
}
121121
}
122+
123+
/* Get and enable clock if any specified */
124+
uhci->clk = devm_clk_get(&pdev->dev, NULL);
125+
if (IS_ERR(uhci->clk)) {
126+
ret = PTR_ERR(uhci->clk);
127+
goto err_rmr;
128+
}
129+
ret = clk_prepare_enable(uhci->clk);
130+
if (ret) {
131+
dev_err(&pdev->dev, "Error couldn't enable clock (%d)\n", ret);
132+
goto err_rmr;
133+
}
134+
122135
ret = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_SHARED);
123136
if (ret)
124-
goto err_rmr;
137+
goto err_clk;
125138

126139
device_wakeup_enable(hcd->self.controller);
127140
return 0;
128141

142+
err_clk:
143+
clk_disable_unprepare(uhci->clk);
129144
err_rmr:
130145
usb_put_hcd(hcd);
131146

@@ -135,7 +150,9 @@ static int uhci_hcd_platform_probe(struct platform_device *pdev)
135150
static int uhci_hcd_platform_remove(struct platform_device *pdev)
136151
{
137152
struct usb_hcd *hcd = platform_get_drvdata(pdev);
153+
struct uhci_hcd *uhci = hcd_to_uhci(hcd);
138154

155+
clk_disable_unprepare(uhci->clk);
139156
usb_remove_hcd(hcd);
140157
usb_put_hcd(hcd);
141158

0 commit comments

Comments
 (0)