1 // SPDX-License-Identifier: GPL-2.0
3 * OMAP ulpi viewport support
4 * Based on drivers/usb/ulpi/ulpi-viewport.c
6 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
7 * Author: Govindraj R <govindraj.raja@ti.com>
13 #include <linux/delay.h>
16 #define OMAP_ULPI_WR_OPSEL (2 << 22)
17 #define OMAP_ULPI_RD_OPSEL (3 << 22)
18 #define OMAP_ULPI_START (1 << 31)
21 * Wait for having ulpi in done state
23 static int ulpi_wait(struct ulpi_viewport *ulpi_vp, u32 mask)
25 int timeout = CONFIG_USB_ULPI_TIMEOUT;
28 if (!(readl(ulpi_vp->viewport_addr) & mask))
38 * Issue a ULPI read/write request
40 static int ulpi_request(struct ulpi_viewport *ulpi_vp, u32 value)
44 writel(value, ulpi_vp->viewport_addr);
46 err = ulpi_wait(ulpi_vp, OMAP_ULPI_START);
48 debug("ULPI request timed out\n");
53 int ulpi_write(struct ulpi_viewport *ulpi_vp, u8 *reg, u32 value)
55 u32 val = OMAP_ULPI_START | (((ulpi_vp->port_num + 1) & 0xf) << 24) |
56 OMAP_ULPI_WR_OPSEL | ((u32)reg << 16) | (value & 0xff);
58 return ulpi_request(ulpi_vp, val);
61 u32 ulpi_read(struct ulpi_viewport *ulpi_vp, u8 *reg)
64 u32 val = OMAP_ULPI_START | (((ulpi_vp->port_num + 1) & 0xf) << 24) |
65 OMAP_ULPI_RD_OPSEL | ((u32)reg << 16);
67 err = ulpi_request(ulpi_vp, val);
71 return readl(ulpi_vp->viewport_addr) & 0xff;