Skip to content

Commit

Permalink
usb: dwc3: omap: add dwc3_omap_readl/writel functions
Browse files Browse the repository at this point in the history
We separate between dwc3-omap helper functions to dwc3-core helper
functions. This will allow us to change the helper functions
implementation according to each module need.

Signed-off-by: Ido Shayevitz <idos@codeaurora.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Ido Shayevitz authored and Felipe Balbi committed Apr 24, 2012
1 parent 07e7f47 commit ab5e59d
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions drivers/usb/dwc3/dwc3-omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#include <linux/of.h>

#include "core.h"
#include "io.h"

/*
* All these registers belong to OMAP's Wrapper around the
Expand Down Expand Up @@ -143,14 +142,25 @@ struct dwc3_omap {
u32 dma_status:1;
};

static inline u32 dwc3_omap_readl(void __iomem *base, u32 offset)
{
return readl(base + offset);
}

static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value)
{
writel(value, base + offset);
}


static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap)
{
struct dwc3_omap *omap = _omap;
u32 reg;

spin_lock(&omap->lock);

reg = dwc3_readl(omap->base, USBOTGSS_IRQSTATUS_1);
reg = dwc3_omap_readl(omap->base, USBOTGSS_IRQSTATUS_1);

if (reg & USBOTGSS_IRQ1_DMADISABLECLR) {
dev_dbg(omap->dev, "DMA Disable was Cleared\n");
Expand Down Expand Up @@ -184,10 +194,10 @@ static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap)
if (reg & USBOTGSS_IRQ1_IDPULLUP_FALL)
dev_dbg(omap->dev, "IDPULLUP Fall\n");

dwc3_writel(omap->base, USBOTGSS_IRQSTATUS_1, reg);
dwc3_omap_writel(omap->base, USBOTGSS_IRQSTATUS_1, reg);

reg = dwc3_readl(omap->base, USBOTGSS_IRQSTATUS_0);
dwc3_writel(omap->base, USBOTGSS_IRQSTATUS_0, reg);
reg = dwc3_omap_readl(omap->base, USBOTGSS_IRQSTATUS_0);
dwc3_omap_writel(omap->base, USBOTGSS_IRQSTATUS_0, reg);

spin_unlock(&omap->lock);

Expand Down Expand Up @@ -270,7 +280,7 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
omap->base = base;
omap->dwc3 = dwc3;

reg = dwc3_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS);
reg = dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS);

utmi_mode = of_get_property(node, "utmi-mode", &size);
if (utmi_mode && size == sizeof(*utmi_mode)) {
Expand All @@ -293,10 +303,10 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
}
}

dwc3_writel(omap->base, USBOTGSS_UTMI_OTG_STATUS, reg);
dwc3_omap_writel(omap->base, USBOTGSS_UTMI_OTG_STATUS, reg);

/* check the DMA Status */
reg = dwc3_readl(omap->base, USBOTGSS_SYSCONFIG);
reg = dwc3_omap_readl(omap->base, USBOTGSS_SYSCONFIG);
omap->dma_status = !!(reg & USBOTGSS_SYSCONFIG_DMADISABLE);

/* Set No-Idle and No-Standby */
Expand All @@ -306,7 +316,7 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
reg |= (USBOTGSS_SYSCONFIG_STANDBYMODE(USBOTGSS_STANDBYMODE_NO_STANDBY)
| USBOTGSS_SYSCONFIG_IDLEMODE(USBOTGSS_IDLEMODE_NO_IDLE));

dwc3_writel(omap->base, USBOTGSS_SYSCONFIG, reg);
dwc3_omap_writel(omap->base, USBOTGSS_SYSCONFIG, reg);

ret = devm_request_irq(dev, omap->irq, dwc3_omap_interrupt, 0,
"dwc3-omap", omap);
Expand All @@ -318,7 +328,7 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)

/* enable all IRQs */
reg = USBOTGSS_IRQO_COREIRQ_ST;
dwc3_writel(omap->base, USBOTGSS_IRQENABLE_SET_0, reg);
dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_SET_0, reg);

reg = (USBOTGSS_IRQ1_OEVT |
USBOTGSS_IRQ1_DRVVBUS_RISE |
Expand All @@ -330,7 +340,7 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
USBOTGSS_IRQ1_DISCHRGVBUS_FALL |
USBOTGSS_IRQ1_IDPULLUP_FALL);

dwc3_writel(omap->base, USBOTGSS_IRQENABLE_SET_1, reg);
dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_SET_1, reg);

ret = platform_device_add_resources(dwc3, pdev->resource,
pdev->num_resources);
Expand Down

0 comments on commit ab5e59d

Please sign in to comment.