summaryrefslogtreecommitdiff
path: root/drivers/usb/ulpi/ulpi-viewport.c
diff options
context:
space:
mode:
authorGovindraj.R <govindraj.raja@ti.com>2012-02-06 03:55:31 +0000
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>2012-02-12 10:11:30 +0100
commit3e6e809f56e0278d964d45e18e6665687d9c174b (patch)
tree4ab1d5268bc5d5711a044c31a64b9b9ae6a7fe74 /drivers/usb/ulpi/ulpi-viewport.c
parentdd54d3147ebc1f3c1fa78edc2ead9392a1432571 (diff)
usb: ulpi: Extend the existing ulpi framework.
Extend the existing ulpi viewport framework to pass the port number information for any ulpi ops. Fix the usage of ulpi api's accordingly. Tested-by: Stefano Babic <sbabic@denx.de> Acked-by: Igor Grinberg <grinberg@compulab.co.il> Signed-off-by: Govindraj.R <govindraj.raja@ti.com>
Diffstat (limited to 'drivers/usb/ulpi/ulpi-viewport.c')
-rw-r--r--drivers/usb/ulpi/ulpi-viewport.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/drivers/usb/ulpi/ulpi-viewport.c b/drivers/usb/ulpi/ulpi-viewport.c
index 490fb0e25d..b4974ed2a6 100644
--- a/drivers/usb/ulpi/ulpi-viewport.c
+++ b/drivers/usb/ulpi/ulpi-viewport.c
@@ -40,13 +40,13 @@
*
* returns 0 on mask match, ULPI_ERROR on time out.
*/
-static int ulpi_wait(u32 ulpi_viewport, u32 mask)
+static int ulpi_wait(struct ulpi_viewport *ulpi_vp, u32 mask)
{
int timeout = CONFIG_USB_ULPI_TIMEOUT;
/* Wait for the bits in mask to become zero. */
while (--timeout) {
- if ((readl(ulpi_viewport) & mask) == 0)
+ if ((readl(ulpi_vp->viewport_addr) & mask) == 0)
return 0;
udelay(1);
@@ -60,16 +60,16 @@ static int ulpi_wait(u32 ulpi_viewport, u32 mask)
*
* returns 0 on success.
*/
-static int ulpi_wakeup(u32 ulpi_viewport)
+static int ulpi_wakeup(struct ulpi_viewport *ulpi_vp)
{
int err;
- if (readl(ulpi_viewport) & ULPI_SS)
+ if (readl(ulpi_vp->viewport_addr) & ULPI_SS)
return 0; /* already awake */
- writel(ULPI_WU, ulpi_viewport);
+ writel(ULPI_WU, ulpi_vp->viewport_addr);
- err = ulpi_wait(ulpi_viewport, ULPI_WU);
+ err = ulpi_wait(ulpi_vp, ULPI_WU);
if (err)
printf("ULPI wakeup timed out\n");
@@ -81,38 +81,40 @@ static int ulpi_wakeup(u32 ulpi_viewport)
*
* @value - the ULPI request
*/
-static int ulpi_request(u32 ulpi_viewport, u32 value)
+static int ulpi_request(struct ulpi_viewport *ulpi_vp, u32 value)
{
int err;
- err = ulpi_wakeup(ulpi_viewport);
+ err = ulpi_wakeup(ulpi_vp);
if (err)
return err;
- writel(value, ulpi_viewport);
+ writel(value, ulpi_vp->viewport_addr);
- err = ulpi_wait(ulpi_viewport, ULPI_RWRUN);
+ err = ulpi_wait(ulpi_vp, ULPI_RWRUN);
if (err)
printf("ULPI request timed out\n");
return err;
}
-int ulpi_write(u32 ulpi_viewport, u8 *reg, u32 value)
+int ulpi_write(struct ulpi_viewport *ulpi_vp, u8 *reg, u32 value)
{
u32 val = ULPI_RWRUN | ULPI_RWCTRL | ((u32)reg << 16) | (value & 0xff);
- return ulpi_request(ulpi_viewport, val);
+ val |= (ulpi_vp->port_num & 0x7) << 24;
+ return ulpi_request(ulpi_vp, val);
}
-u32 ulpi_read(u32 ulpi_viewport, u8 *reg)
+u32 ulpi_read(struct ulpi_viewport *ulpi_vp, u8 *reg)
{
int err;
u32 val = ULPI_RWRUN | ((u32)reg << 16);
- err = ulpi_request(ulpi_viewport, val);
+ val |= (ulpi_vp->port_num & 0x7) << 24;
+ err = ulpi_request(ulpi_vp, val);
if (err)
return err;
- return (readl(ulpi_viewport) >> 8) & 0xff;
+ return (readl(ulpi_vp->viewport_addr) >> 8) & 0xff;
}