aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorGeorge Cherian <george.cherian@ti.com>2014-07-16 09:07:07 -0400
committerFelipe Balbi <balbi@ti.com>2014-07-16 10:57:01 -0400
commitd2f0cf89ca2deca59cc4ca0c80c14100831428db (patch)
tree6446865fb8567184e64e860fb1284c97149c06d8 /drivers/usb
parent30fef1a97fb6551abb50b5208993726b878fe40f (diff)
usb: dwc3: omap: add dwc3_omap_set_utmi_mode() function
Move find and set the utmi mode to its own separate function. Improve code readability, decrease the dwc3_probe() size. Signed-off-by: George Cherian <george.cherian@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/dwc3/dwc3-omap.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 22fca6291ff5..6a90b96c9d14 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -399,6 +399,30 @@ static void dwc3_omap_map_offset(struct dwc3_omap *omap)
399 } 399 }
400} 400}
401 401
402static void dwc3_omap_set_utmi_mode(struct dwc3_omap *omap)
403{
404 u32 reg;
405 struct device_node *node = omap->dev->of_node;
406 int utmi_mode = 0;
407
408 reg = dwc3_omap_read_utmi_status(omap);
409
410 of_property_read_u32(node, "utmi-mode", &utmi_mode);
411
412 switch (utmi_mode) {
413 case DWC3_OMAP_UTMI_MODE_SW:
414 reg |= USBOTGSS_UTMI_OTG_STATUS_SW_MODE;
415 break;
416 case DWC3_OMAP_UTMI_MODE_HW:
417 reg &= ~USBOTGSS_UTMI_OTG_STATUS_SW_MODE;
418 break;
419 default:
420 dev_dbg(omap->dev, "UNKNOWN utmi mode %d\n", utmi_mode);
421 }
422
423 dwc3_omap_write_utmi_status(omap, reg);
424}
425
402static int dwc3_omap_probe(struct platform_device *pdev) 426static int dwc3_omap_probe(struct platform_device *pdev)
403{ 427{
404 struct device_node *node = pdev->dev.of_node; 428 struct device_node *node = pdev->dev.of_node;
@@ -412,8 +436,6 @@ static int dwc3_omap_probe(struct platform_device *pdev)
412 int ret; 436 int ret;
413 int irq; 437 int irq;
414 438
415 int utmi_mode = 0;
416
417 u32 reg; 439 u32 reg;
418 440
419 void __iomem *base; 441 void __iomem *base;
@@ -464,23 +486,7 @@ static int dwc3_omap_probe(struct platform_device *pdev)
464 } 486 }
465 487
466 dwc3_omap_map_offset(omap); 488 dwc3_omap_map_offset(omap);
467 489 dwc3_omap_set_utmi_mode(omap);
468 reg = dwc3_omap_read_utmi_status(omap);
469
470 of_property_read_u32(node, "utmi-mode", &utmi_mode);
471
472 switch (utmi_mode) {
473 case DWC3_OMAP_UTMI_MODE_SW:
474 reg |= USBOTGSS_UTMI_OTG_STATUS_SW_MODE;
475 break;
476 case DWC3_OMAP_UTMI_MODE_HW:
477 reg &= ~USBOTGSS_UTMI_OTG_STATUS_SW_MODE;
478 break;
479 default:
480 dev_dbg(dev, "UNKNOWN utmi mode %d\n", utmi_mode);
481 }
482
483 dwc3_omap_write_utmi_status(omap, reg);
484 490
485 /* check the DMA Status */ 491 /* check the DMA Status */
486 reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG); 492 reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG);