diff options
Diffstat (limited to 'drivers/usb/otg/ulpi.c')
-rw-r--r-- | drivers/usb/otg/ulpi.c | 134 |
1 files changed, 120 insertions, 14 deletions
diff --git a/drivers/usb/otg/ulpi.c b/drivers/usb/otg/ulpi.c index d331b222ad21..ccc81950822b 100644 --- a/drivers/usb/otg/ulpi.c +++ b/drivers/usb/otg/ulpi.c | |||
@@ -31,30 +31,110 @@ | |||
31 | 31 | ||
32 | #define ULPI_ID(vendor, product) (((vendor) << 16) | (product)) | 32 | #define ULPI_ID(vendor, product) (((vendor) << 16) | (product)) |
33 | 33 | ||
34 | #define TR_FLAG(flags, a, b) (((flags) & a) ? b : 0) | ||
35 | |||
36 | /* ULPI hardcoded IDs, used for probing */ | 34 | /* ULPI hardcoded IDs, used for probing */ |
37 | static unsigned int ulpi_ids[] = { | 35 | static unsigned int ulpi_ids[] = { |
38 | ULPI_ID(0x04cc, 0x1504), /* NXP ISP1504 */ | 36 | ULPI_ID(0x04cc, 0x1504), /* NXP ISP1504 */ |
37 | ULPI_ID(0x0424, 0x0006), /* SMSC USB3319 */ | ||
39 | }; | 38 | }; |
40 | 39 | ||
41 | static int ulpi_set_flags(struct otg_transceiver *otg) | 40 | static int ulpi_set_otg_flags(struct otg_transceiver *otg) |
42 | { | 41 | { |
43 | unsigned int flags = 0; | 42 | unsigned int flags = ULPI_OTG_CTRL_DP_PULLDOWN | |
43 | ULPI_OTG_CTRL_DM_PULLDOWN; | ||
44 | 44 | ||
45 | if (otg->flags & USB_OTG_PULLUP_ID) | 45 | if (otg->flags & ULPI_OTG_ID_PULLUP) |
46 | flags |= ULPI_OTG_CTRL_ID_PULLUP; | 46 | flags |= ULPI_OTG_CTRL_ID_PULLUP; |
47 | 47 | ||
48 | if (otg->flags & USB_OTG_PULLDOWN_DM) | 48 | /* |
49 | flags |= ULPI_OTG_CTRL_DM_PULLDOWN; | 49 | * ULPI Specification rev.1.1 default |
50 | * for Dp/DmPulldown is enabled. | ||
51 | */ | ||
52 | if (otg->flags & ULPI_OTG_DP_PULLDOWN_DIS) | ||
53 | flags &= ~ULPI_OTG_CTRL_DP_PULLDOWN; | ||
50 | 54 | ||
51 | if (otg->flags & USB_OTG_PULLDOWN_DP) | 55 | if (otg->flags & ULPI_OTG_DM_PULLDOWN_DIS) |
52 | flags |= ULPI_OTG_CTRL_DP_PULLDOWN; | 56 | flags &= ~ULPI_OTG_CTRL_DM_PULLDOWN; |
53 | 57 | ||
54 | if (otg->flags & USB_OTG_EXT_VBUS_INDICATOR) | 58 | if (otg->flags & ULPI_OTG_EXTVBUSIND) |
55 | flags |= ULPI_OTG_CTRL_EXTVBUSIND; | 59 | flags |= ULPI_OTG_CTRL_EXTVBUSIND; |
56 | 60 | ||
57 | return otg_io_write(otg, flags, ULPI_SET(ULPI_OTG_CTRL)); | 61 | return otg_io_write(otg, flags, ULPI_OTG_CTRL); |
62 | } | ||
63 | |||
64 | static int ulpi_set_fc_flags(struct otg_transceiver *otg) | ||
65 | { | ||
66 | unsigned int flags = 0; | ||
67 | |||
68 | /* | ||
69 | * ULPI Specification rev.1.1 default | ||
70 | * for XcvrSelect is Full Speed. | ||
71 | */ | ||
72 | if (otg->flags & ULPI_FC_HS) | ||
73 | flags |= ULPI_FUNC_CTRL_HIGH_SPEED; | ||
74 | else if (otg->flags & ULPI_FC_LS) | ||
75 | flags |= ULPI_FUNC_CTRL_LOW_SPEED; | ||
76 | else if (otg->flags & ULPI_FC_FS4LS) | ||
77 | flags |= ULPI_FUNC_CTRL_FS4LS; | ||
78 | else | ||
79 | flags |= ULPI_FUNC_CTRL_FULL_SPEED; | ||
80 | |||
81 | if (otg->flags & ULPI_FC_TERMSEL) | ||
82 | flags |= ULPI_FUNC_CTRL_TERMSELECT; | ||
83 | |||
84 | /* | ||
85 | * ULPI Specification rev.1.1 default | ||
86 | * for OpMode is Normal Operation. | ||
87 | */ | ||
88 | if (otg->flags & ULPI_FC_OP_NODRV) | ||
89 | flags |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; | ||
90 | else if (otg->flags & ULPI_FC_OP_DIS_NRZI) | ||
91 | flags |= ULPI_FUNC_CTRL_OPMODE_DISABLE_NRZI; | ||
92 | else if (otg->flags & ULPI_FC_OP_NSYNC_NEOP) | ||
93 | flags |= ULPI_FUNC_CTRL_OPMODE_NOSYNC_NOEOP; | ||
94 | else | ||
95 | flags |= ULPI_FUNC_CTRL_OPMODE_NORMAL; | ||
96 | |||
97 | /* | ||
98 | * ULPI Specification rev.1.1 default | ||
99 | * for SuspendM is Powered. | ||
100 | */ | ||
101 | flags |= ULPI_FUNC_CTRL_SUSPENDM; | ||
102 | |||
103 | return otg_io_write(otg, flags, ULPI_FUNC_CTRL); | ||
104 | } | ||
105 | |||
106 | static int ulpi_set_ic_flags(struct otg_transceiver *otg) | ||
107 | { | ||
108 | unsigned int flags = 0; | ||
109 | |||
110 | if (otg->flags & ULPI_IC_AUTORESUME) | ||
111 | flags |= ULPI_IFC_CTRL_AUTORESUME; | ||
112 | |||
113 | if (otg->flags & ULPI_IC_EXTVBUS_INDINV) | ||
114 | flags |= ULPI_IFC_CTRL_EXTERNAL_VBUS; | ||
115 | |||
116 | if (otg->flags & ULPI_IC_IND_PASSTHRU) | ||
117 | flags |= ULPI_IFC_CTRL_PASSTHRU; | ||
118 | |||
119 | if (otg->flags & ULPI_IC_PROTECT_DIS) | ||
120 | flags |= ULPI_IFC_CTRL_PROTECT_IFC_DISABLE; | ||
121 | |||
122 | return otg_io_write(otg, flags, ULPI_IFC_CTRL); | ||
123 | } | ||
124 | |||
125 | static int ulpi_set_flags(struct otg_transceiver *otg) | ||
126 | { | ||
127 | int ret; | ||
128 | |||
129 | ret = ulpi_set_otg_flags(otg); | ||
130 | if (ret) | ||
131 | return ret; | ||
132 | |||
133 | ret = ulpi_set_ic_flags(otg); | ||
134 | if (ret) | ||
135 | return ret; | ||
136 | |||
137 | return ulpi_set_fc_flags(otg); | ||
58 | } | 138 | } |
59 | 139 | ||
60 | static int ulpi_init(struct otg_transceiver *otg) | 140 | static int ulpi_init(struct otg_transceiver *otg) |
@@ -81,6 +161,31 @@ static int ulpi_init(struct otg_transceiver *otg) | |||
81 | return -ENODEV; | 161 | return -ENODEV; |
82 | } | 162 | } |
83 | 163 | ||
164 | static int ulpi_set_host(struct otg_transceiver *otg, struct usb_bus *host) | ||
165 | { | ||
166 | unsigned int flags = otg_io_read(otg, ULPI_IFC_CTRL); | ||
167 | |||
168 | if (!host) { | ||
169 | otg->host = NULL; | ||
170 | return 0; | ||
171 | } | ||
172 | |||
173 | otg->host = host; | ||
174 | |||
175 | flags &= ~(ULPI_IFC_CTRL_6_PIN_SERIAL_MODE | | ||
176 | ULPI_IFC_CTRL_3_PIN_SERIAL_MODE | | ||
177 | ULPI_IFC_CTRL_CARKITMODE); | ||
178 | |||
179 | if (otg->flags & ULPI_IC_6PIN_SERIAL) | ||
180 | flags |= ULPI_IFC_CTRL_6_PIN_SERIAL_MODE; | ||
181 | else if (otg->flags & ULPI_IC_3PIN_SERIAL) | ||
182 | flags |= ULPI_IFC_CTRL_3_PIN_SERIAL_MODE; | ||
183 | else if (otg->flags & ULPI_IC_CARKIT) | ||
184 | flags |= ULPI_IFC_CTRL_CARKITMODE; | ||
185 | |||
186 | return otg_io_write(otg, flags, ULPI_IFC_CTRL); | ||
187 | } | ||
188 | |||
84 | static int ulpi_set_vbus(struct otg_transceiver *otg, bool on) | 189 | static int ulpi_set_vbus(struct otg_transceiver *otg, bool on) |
85 | { | 190 | { |
86 | unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL); | 191 | unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL); |
@@ -88,14 +193,14 @@ static int ulpi_set_vbus(struct otg_transceiver *otg, bool on) | |||
88 | flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT); | 193 | flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT); |
89 | 194 | ||
90 | if (on) { | 195 | if (on) { |
91 | if (otg->flags & USB_OTG_DRV_VBUS) | 196 | if (otg->flags & ULPI_OTG_DRVVBUS) |
92 | flags |= ULPI_OTG_CTRL_DRVVBUS; | 197 | flags |= ULPI_OTG_CTRL_DRVVBUS; |
93 | 198 | ||
94 | if (otg->flags & USB_OTG_DRV_VBUS_EXT) | 199 | if (otg->flags & ULPI_OTG_DRVVBUS_EXT) |
95 | flags |= ULPI_OTG_CTRL_DRVVBUS_EXT; | 200 | flags |= ULPI_OTG_CTRL_DRVVBUS_EXT; |
96 | } | 201 | } |
97 | 202 | ||
98 | return otg_io_write(otg, flags, ULPI_SET(ULPI_OTG_CTRL)); | 203 | return otg_io_write(otg, flags, ULPI_OTG_CTRL); |
99 | } | 204 | } |
100 | 205 | ||
101 | struct otg_transceiver * | 206 | struct otg_transceiver * |
@@ -112,6 +217,7 @@ otg_ulpi_create(struct otg_io_access_ops *ops, | |||
112 | otg->flags = flags; | 217 | otg->flags = flags; |
113 | otg->io_ops = ops; | 218 | otg->io_ops = ops; |
114 | otg->init = ulpi_init; | 219 | otg->init = ulpi_init; |
220 | otg->set_host = ulpi_set_host; | ||
115 | otg->set_vbus = ulpi_set_vbus; | 221 | otg->set_vbus = ulpi_set_vbus; |
116 | 222 | ||
117 | return otg; | 223 | return otg; |