aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/otg/ulpi.c
diff options
context:
space:
mode:
authorHeikki Krogerus <ext-heikki.krogerus@nokia.com>2010-05-03 02:13:02 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-20 16:21:36 -0400
commitfc567f06def35427ba830649eb6acbb72ac2790c (patch)
tree78f759945f425fb960ffacae10f75c85990444b4 /drivers/usb/otg/ulpi.c
parent3a229eb13984a2950ee47fb827c8ed1d654b9d68 (diff)
USB: otg: ulpi: use the global ULPI register definitions
Rely on the global ULPI register definitions Signed-off-by: Heikki Krogerus <ext-heikki.krogerus@nokia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/otg/ulpi.c')
-rw-r--r--drivers/usb/otg/ulpi.c50
1 files changed, 14 insertions, 36 deletions
diff --git a/drivers/usb/otg/ulpi.c b/drivers/usb/otg/ulpi.c
index 9010225e0d06..b1b346932946 100644
--- a/drivers/usb/otg/ulpi.c
+++ b/drivers/usb/otg/ulpi.c
@@ -29,28 +29,6 @@
29#include <linux/usb/otg.h> 29#include <linux/usb/otg.h>
30#include <linux/usb/ulpi.h> 30#include <linux/usb/ulpi.h>
31 31
32/* ULPI register addresses */
33#define ULPI_VID_LOW 0x00 /* Vendor ID low */
34#define ULPI_VID_HIGH 0x01 /* Vendor ID high */
35#define ULPI_PID_LOW 0x02 /* Product ID low */
36#define ULPI_PID_HIGH 0x03 /* Product ID high */
37#define ULPI_ITFCTL 0x07 /* Interface Control */
38#define ULPI_OTGCTL 0x0A /* OTG Control */
39
40/* add to above register address to access Set/Clear functions */
41#define ULPI_REG_SET 0x01
42#define ULPI_REG_CLEAR 0x02
43
44/* ULPI OTG Control Register bits */
45#define ID_PULL_UP (1 << 0) /* enable ID Pull Up */
46#define DP_PULL_DOWN (1 << 1) /* enable DP Pull Down */
47#define DM_PULL_DOWN (1 << 2) /* enable DM Pull Down */
48#define DISCHRG_VBUS (1 << 3) /* Discharge Vbus */
49#define CHRG_VBUS (1 << 4) /* Charge Vbus */
50#define DRV_VBUS (1 << 5) /* Drive Vbus */
51#define DRV_VBUS_EXT (1 << 6) /* Drive Vbus external */
52#define USE_EXT_VBUS_IND (1 << 7) /* Use ext. Vbus indicator */
53
54#define ULPI_ID(vendor, product) (((vendor) << 16) | (product)) 32#define ULPI_ID(vendor, product) (((vendor) << 16) | (product))
55 33
56#define TR_FLAG(flags, a, b) (((flags) & a) ? b : 0) 34#define TR_FLAG(flags, a, b) (((flags) & a) ? b : 0)
@@ -65,28 +43,28 @@ static int ulpi_set_flags(struct otg_transceiver *otg)
65 unsigned int flags = 0; 43 unsigned int flags = 0;
66 44
67 if (otg->flags & USB_OTG_PULLUP_ID) 45 if (otg->flags & USB_OTG_PULLUP_ID)
68 flags |= ID_PULL_UP; 46 flags |= ULPI_OTG_CTRL_ID_PULLUP;
69 47
70 if (otg->flags & USB_OTG_PULLDOWN_DM) 48 if (otg->flags & USB_OTG_PULLDOWN_DM)
71 flags |= DM_PULL_DOWN; 49 flags |= ULPI_OTG_CTRL_DM_PULLDOWN;
72 50
73 if (otg->flags & USB_OTG_PULLDOWN_DP) 51 if (otg->flags & USB_OTG_PULLDOWN_DP)
74 flags |= DP_PULL_DOWN; 52 flags |= ULPI_OTG_CTRL_DP_PULLDOWN;
75 53
76 if (otg->flags & USB_OTG_EXT_VBUS_INDICATOR) 54 if (otg->flags & USB_OTG_EXT_VBUS_INDICATOR)
77 flags |= USE_EXT_VBUS_IND; 55 flags |= ULPI_OTG_CTRL_EXTVBUSIND;
78 56
79 return otg_io_write(otg, flags, ULPI_OTGCTL + ULPI_REG_SET); 57 return otg_io_write(otg, flags, ULPI_SET(ULPI_OTG_CTRL));
80} 58}
81 59
82static int ulpi_init(struct otg_transceiver *otg) 60static int ulpi_init(struct otg_transceiver *otg)
83{ 61{
84 int i, vid, pid; 62 int i, vid, pid;
85 63
86 vid = (otg_io_read(otg, ULPI_VID_HIGH) << 8) | 64 vid = (otg_io_read(otg, ULPI_VENDOR_ID_HIGH) << 8) |
87 otg_io_read(otg, ULPI_VID_LOW); 65 otg_io_read(otg, ULPI_VENDOR_ID_LOW);
88 pid = (otg_io_read(otg, ULPI_PID_HIGH) << 8) | 66 pid = (otg_io_read(otg, ULPI_PRODUCT_ID_HIGH) << 8) |
89 otg_io_read(otg, ULPI_PID_LOW); 67 otg_io_read(otg, ULPI_PRODUCT_ID_LOW);
90 68
91 pr_info("ULPI transceiver vendor/product ID 0x%04x/0x%04x\n", vid, pid); 69 pr_info("ULPI transceiver vendor/product ID 0x%04x/0x%04x\n", vid, pid);
92 70
@@ -100,19 +78,19 @@ static int ulpi_init(struct otg_transceiver *otg)
100 78
101static int ulpi_set_vbus(struct otg_transceiver *otg, bool on) 79static int ulpi_set_vbus(struct otg_transceiver *otg, bool on)
102{ 80{
103 unsigned int flags = otg_io_read(otg, ULPI_OTGCTL); 81 unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL);
104 82
105 flags &= ~(DRV_VBUS | DRV_VBUS_EXT); 83 flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT);
106 84
107 if (on) { 85 if (on) {
108 if (otg->flags & USB_OTG_DRV_VBUS) 86 if (otg->flags & USB_OTG_DRV_VBUS)
109 flags |= DRV_VBUS; 87 flags |= ULPI_OTG_CTRL_DRVVBUS;
110 88
111 if (otg->flags & USB_OTG_DRV_VBUS_EXT) 89 if (otg->flags & USB_OTG_DRV_VBUS_EXT)
112 flags |= DRV_VBUS_EXT; 90 flags |= ULPI_OTG_CTRL_DRVVBUS_EXT;
113 } 91 }
114 92
115 return otg_io_write(otg, flags, ULPI_OTGCTL + ULPI_REG_SET); 93 return otg_io_write(otg, flags, ULPI_SET(ULPI_OTG_CTRL));
116} 94}
117 95
118struct otg_transceiver * 96struct otg_transceiver *