aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/omap-usb-tll.c
diff options
context:
space:
mode:
authorRoger Quadros <rogerq@ti.com>2012-11-08 07:40:45 -0500
committerRoger Quadros <rogerq@ti.com>2013-02-13 06:22:40 -0500
commit32a51f2a536fd045c472779c13ac09e9e80ac3cc (patch)
tree60a4f1cdde1bf6b1c50221be9a4d7c8b28439855 /drivers/mfd/omap-usb-tll.c
parent0bde3e9fee74b668857b1664a70998d02807fb5b (diff)
mfd: omap-usb-tll: introduce and use mode_needs_tll()
This is a handy macro to check if the port requires the USB TLL module or not. Use it to Enable the TLL module and manage the clocks. Signed-off-by: Roger Quadros <rogerq@ti.com> Reviewed-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/mfd/omap-usb-tll.c')
-rw-r--r--drivers/mfd/omap-usb-tll.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index bf7355e1126d..af67b96ded0f 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -95,6 +95,10 @@
95 95
96#define is_ehci_tll_mode(x) (x == OMAP_EHCI_PORT_MODE_TLL) 96#define is_ehci_tll_mode(x) (x == OMAP_EHCI_PORT_MODE_TLL)
97 97
98/* only PHY and UNUSED modes don't need TLL */
99#define omap_usb_mode_needs_tll(x) ((x) != OMAP_USBHS_PORT_MODE_UNUSED &&\
100 (x) != OMAP_EHCI_PORT_MODE_PHY)
101
98struct usbtll_omap { 102struct usbtll_omap {
99 int nch; /* num. of channels */ 103 int nch; /* num. of channels */
100 struct usbhs_omap_platform_data *pdata; 104 struct usbhs_omap_platform_data *pdata;
@@ -211,6 +215,7 @@ static int usbtll_omap_probe(struct platform_device *pdev)
211 unsigned long flags; 215 unsigned long flags;
212 int ret = 0; 216 int ret = 0;
213 int i, ver; 217 int i, ver;
218 bool needs_tll;
214 219
215 dev_dbg(dev, "starting TI HSUSB TLL Controller\n"); 220 dev_dbg(dev, "starting TI HSUSB TLL Controller\n");
216 221
@@ -278,12 +283,11 @@ static int usbtll_omap_probe(struct platform_device *pdev)
278 283
279 spin_lock_irqsave(&tll->lock, flags); 284 spin_lock_irqsave(&tll->lock, flags);
280 285
281 if (is_ehci_tll_mode(pdata->port_mode[0]) || 286 needs_tll = false;
282 is_ehci_tll_mode(pdata->port_mode[1]) || 287 for (i = 0; i < tll->nch; i++)
283 is_ehci_tll_mode(pdata->port_mode[2]) || 288 needs_tll |= omap_usb_mode_needs_tll(pdata->port_mode[i]);
284 is_ohci_port(pdata->port_mode[0]) || 289
285 is_ohci_port(pdata->port_mode[1]) || 290 if (needs_tll) {
286 is_ohci_port(pdata->port_mode[2])) {
287 291
288 /* Program Common TLL register */ 292 /* Program Common TLL register */
289 reg = usbtll_read(base, OMAP_TLL_SHARED_CONF); 293 reg = usbtll_read(base, OMAP_TLL_SHARED_CONF);
@@ -372,7 +376,7 @@ static int usbtll_runtime_resume(struct device *dev)
372 spin_lock_irqsave(&tll->lock, flags); 376 spin_lock_irqsave(&tll->lock, flags);
373 377
374 for (i = 0; i < tll->nch; i++) { 378 for (i = 0; i < tll->nch; i++) {
375 if (is_ehci_tll_mode(pdata->port_mode[i])) { 379 if (omap_usb_mode_needs_tll(pdata->port_mode[i])) {
376 int r; 380 int r;
377 381
378 if (IS_ERR(tll->ch_clk[i])) 382 if (IS_ERR(tll->ch_clk[i]))
@@ -408,7 +412,7 @@ static int usbtll_runtime_suspend(struct device *dev)
408 spin_lock_irqsave(&tll->lock, flags); 412 spin_lock_irqsave(&tll->lock, flags);
409 413
410 for (i = 0; i < tll->nch; i++) { 414 for (i = 0; i < tll->nch; i++) {
411 if (is_ehci_tll_mode(pdata->port_mode[i])) { 415 if (omap_usb_mode_needs_tll(pdata->port_mode[i])) {
412 if (!IS_ERR(tll->ch_clk[i])) 416 if (!IS_ERR(tll->ch_clk[i]))
413 clk_disable(tll->ch_clk[i]); 417 clk_disable(tll->ch_clk[i]);
414 } 418 }