diff options
Diffstat (limited to 'drivers/usb/otg/langwell_otg.c')
-rw-r--r-- | drivers/usb/otg/langwell_otg.c | 48 |
1 files changed, 11 insertions, 37 deletions
diff --git a/drivers/usb/otg/langwell_otg.c b/drivers/usb/otg/langwell_otg.c index 9fea48264fa2..7f9b8cd4514b 100644 --- a/drivers/usb/otg/langwell_otg.c +++ b/drivers/usb/otg/langwell_otg.c | |||
@@ -174,50 +174,24 @@ static int langwell_otg_set_power(struct otg_transceiver *otg, | |||
174 | return 0; | 174 | return 0; |
175 | } | 175 | } |
176 | 176 | ||
177 | /* A-device drives vbus, controlled through PMIC CHRGCNTL register*/ | 177 | /* A-device drives vbus, controlled through IPC commands */ |
178 | static int langwell_otg_set_vbus(struct otg_transceiver *otg, bool enabled) | 178 | static int langwell_otg_set_vbus(struct otg_transceiver *otg, bool enabled) |
179 | { | 179 | { |
180 | struct langwell_otg *lnw = the_transceiver; | 180 | struct langwell_otg *lnw = the_transceiver; |
181 | u8 r; | 181 | u8 sub_id; |
182 | 182 | ||
183 | dev_dbg(lnw->dev, "%s <--- %s\n", __func__, enabled ? "on" : "off"); | 183 | dev_dbg(lnw->dev, "%s <--- %s\n", __func__, enabled ? "on" : "off"); |
184 | 184 | ||
185 | /* FIXME: surely we should cache this on the first read. If not use | 185 | if (enabled) |
186 | readv to avoid two transactions */ | 186 | sub_id = 0x8; /* Turn on the VBus */ |
187 | if (intel_scu_ipc_ioread8(0x00, &r) < 0) { | 187 | else |
188 | dev_dbg(lnw->dev, "Failed to read PMIC register 0xD2"); | 188 | sub_id = 0x9; /* Turn off the VBus */ |
189 | return -EBUSY; | ||
190 | } | ||
191 | if ((r & 0x03) != 0x02) { | ||
192 | dev_dbg(lnw->dev, "not NEC PMIC attached\n"); | ||
193 | return -EBUSY; | ||
194 | } | ||
195 | |||
196 | if (intel_scu_ipc_ioread8(0x20, &r) < 0) { | ||
197 | dev_dbg(lnw->dev, "Failed to read PMIC register 0xD2"); | ||
198 | return -EBUSY; | ||
199 | } | ||
200 | |||
201 | if ((r & 0x20) == 0) { | ||
202 | dev_dbg(lnw->dev, "no battery attached\n"); | ||
203 | return -EBUSY; | ||
204 | } | ||
205 | 189 | ||
206 | /* Workaround for battery attachment issue */ | 190 | if (intel_scu_ipc_simple_command(0xef, sub_id)) { |
207 | if (r == 0x34) { | 191 | dev_dbg(lnw->dev, "Failed to set Vbus via IPC commands\n"); |
208 | dev_dbg(lnw->dev, "no battery attached on SH\n"); | ||
209 | return -EBUSY; | 192 | return -EBUSY; |
210 | } | 193 | } |
211 | 194 | ||
212 | dev_dbg(lnw->dev, "battery attached. 2 reg = %x\n", r); | ||
213 | |||
214 | /* workaround: FW detect writing 0x20/0xc0 to d4 event. | ||
215 | * this is only for NEC PMIC. | ||
216 | */ | ||
217 | |||
218 | if (intel_scu_ipc_iowrite8(0xD4, enabled ? 0x20 : 0xC0)) | ||
219 | dev_dbg(lnw->dev, "Failed to write PMIC.\n"); | ||
220 | |||
221 | dev_dbg(lnw->dev, "%s --->\n", __func__); | 195 | dev_dbg(lnw->dev, "%s --->\n", __func__); |
222 | 196 | ||
223 | return 0; | 197 | return 0; |
@@ -394,14 +368,14 @@ static void langwell_otg_phy_low_power(int on) | |||
394 | dev_dbg(lnw->dev, "%s <--- done\n", __func__); | 368 | dev_dbg(lnw->dev, "%s <--- done\n", __func__); |
395 | } | 369 | } |
396 | 370 | ||
397 | /* After drv vbus, add 2 ms delay to set PHCD */ | 371 | /* After drv vbus, add 5 ms delay to set PHCD */ |
398 | static void langwell_otg_phy_low_power_wait(int on) | 372 | static void langwell_otg_phy_low_power_wait(int on) |
399 | { | 373 | { |
400 | struct langwell_otg *lnw = the_transceiver; | 374 | struct langwell_otg *lnw = the_transceiver; |
401 | 375 | ||
402 | dev_dbg(lnw->dev, "add 2ms delay before programing PHCD\n"); | 376 | dev_dbg(lnw->dev, "add 5ms delay before programing PHCD\n"); |
403 | 377 | ||
404 | mdelay(2); | 378 | mdelay(5); |
405 | langwell_otg_phy_low_power(on); | 379 | langwell_otg_phy_low_power(on); |
406 | } | 380 | } |
407 | 381 | ||