Commit 1f15318c authored by Hao Wu's avatar Hao Wu Committed by Greg Kroah-Hartman

USB OTG Langwell: use simple IPC command to control VBus power.

Direct access to PMIC register is not safe and will impact battery
charging. New IPC command supported in SCU FW for VBus power control.
USB OTG driver will switch to such commands instead of direct access
to PMIC register for safety and SCU FW will handle the actual work
after got the request(IPC command).

Due to this change, usb driver should wait more time for sync OTGSC
with USBCFG by SCU. Update wait time from 2ms to 5ms.
Signed-off-by: default avatarHao Wu <hao.wu@intel.com>
Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e27c3c5c
...@@ -174,50 +174,24 @@ static int langwell_otg_set_power(struct otg_transceiver *otg, ...@@ -174,50 +174,24 @@ static int langwell_otg_set_power(struct otg_transceiver *otg,
return 0; return 0;
} }
/* A-device drives vbus, controlled through PMIC CHRGCNTL register*/ /* A-device drives vbus, controlled through IPC commands */
static int langwell_otg_set_vbus(struct otg_transceiver *otg, bool enabled) static int langwell_otg_set_vbus(struct otg_transceiver *otg, bool enabled)
{ {
struct langwell_otg *lnw = the_transceiver; struct langwell_otg *lnw = the_transceiver;
u8 r; u8 sub_id;
dev_dbg(lnw->dev, "%s <--- %s\n", __func__, enabled ? "on" : "off"); dev_dbg(lnw->dev, "%s <--- %s\n", __func__, enabled ? "on" : "off");
/* FIXME: surely we should cache this on the first read. If not use if (enabled)
readv to avoid two transactions */ sub_id = 0x8; /* Turn on the VBus */
if (intel_scu_ipc_ioread8(0x00, &r) < 0) { else
dev_dbg(lnw->dev, "Failed to read PMIC register 0xD2"); sub_id = 0x9; /* Turn off the VBus */
return -EBUSY;
}
if ((r & 0x03) != 0x02) {
dev_dbg(lnw->dev, "not NEC PMIC attached\n");
return -EBUSY;
}
if (intel_scu_ipc_ioread8(0x20, &r) < 0) {
dev_dbg(lnw->dev, "Failed to read PMIC register 0xD2");
return -EBUSY;
}
if ((r & 0x20) == 0) {
dev_dbg(lnw->dev, "no battery attached\n");
return -EBUSY;
}
/* Workaround for battery attachment issue */ if (intel_scu_ipc_simple_command(0xef, sub_id)) {
if (r == 0x34) { dev_dbg(lnw->dev, "Failed to set Vbus via IPC commands\n");
dev_dbg(lnw->dev, "no battery attached on SH\n");
return -EBUSY; return -EBUSY;
} }
dev_dbg(lnw->dev, "battery attached. 2 reg = %x\n", r);
/* workaround: FW detect writing 0x20/0xc0 to d4 event.
* this is only for NEC PMIC.
*/
if (intel_scu_ipc_iowrite8(0xD4, enabled ? 0x20 : 0xC0))
dev_dbg(lnw->dev, "Failed to write PMIC.\n");
dev_dbg(lnw->dev, "%s --->\n", __func__); dev_dbg(lnw->dev, "%s --->\n", __func__);
return 0; return 0;
...@@ -394,14 +368,14 @@ static void langwell_otg_phy_low_power(int on) ...@@ -394,14 +368,14 @@ static void langwell_otg_phy_low_power(int on)
dev_dbg(lnw->dev, "%s <--- done\n", __func__); dev_dbg(lnw->dev, "%s <--- done\n", __func__);
} }
/* After drv vbus, add 2 ms delay to set PHCD */ /* After drv vbus, add 5 ms delay to set PHCD */
static void langwell_otg_phy_low_power_wait(int on) static void langwell_otg_phy_low_power_wait(int on)
{ {
struct langwell_otg *lnw = the_transceiver; struct langwell_otg *lnw = the_transceiver;
dev_dbg(lnw->dev, "add 2ms delay before programing PHCD\n"); dev_dbg(lnw->dev, "add 5ms delay before programing PHCD\n");
mdelay(2); mdelay(5);
langwell_otg_phy_low_power(on); langwell_otg_phy_low_power(on);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment