aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorNeilBrown <neil@brown.name>2015-07-29 20:11:24 -0400
committerSebastian Reichel <sre@kernel.org>2015-08-04 23:12:42 -0400
commit6e37ec8c77e3e6580cbb844dfeea0fb3970c0a35 (patch)
treee43fe55e8e54f1b3864fafefefb92c47344bb6d0 /drivers/power
parent3fc3895e4fe17ee92ae1d1bb9f04da6069e8c370 (diff)
twl4030_charger: trust phy to determine when USB power is available.
The usb phy driver already determines when VBUS is available, so repeating the test in the charger driver is pointless duplication. On probe, process the last event from the phy, and from then on, do whatever the phy tells us without double-checking. Signed-off-by: NeilBrown <neil@brown.name> Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/twl4030_charger.c33
1 files changed, 6 insertions, 27 deletions
diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c
index ffc123fb7158..a075216d65ed 100644
--- a/drivers/power/twl4030_charger.c
+++ b/drivers/power/twl4030_charger.c
@@ -178,28 +178,6 @@ static int twl4030_is_battery_present(struct twl4030_bci *bci)
178} 178}
179 179
180/* 180/*
181 * Check if VBUS power is present
182 */
183static int twl4030_bci_have_vbus(struct twl4030_bci *bci)
184{
185 int ret;
186 u8 hwsts;
187
188 ret = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &hwsts,
189 TWL4030_PM_MASTER_STS_HW_CONDITIONS);
190 if (ret < 0)
191 return 0;
192
193 dev_dbg(bci->dev, "check_vbus: HW_CONDITIONS %02x\n", hwsts);
194
195 /* in case we also have STS_USB_ID, VBUS is driven by TWL itself */
196 if ((hwsts & TWL4030_STS_VBUS) && !(hwsts & TWL4030_STS_USB_ID))
197 return 1;
198
199 return 0;
200}
201
202/*
203 * Enable/Disable USB Charge functionality. 181 * Enable/Disable USB Charge functionality.
204 */ 182 */
205static int twl4030_charger_enable_usb(struct twl4030_bci *bci, bool enable) 183static int twl4030_charger_enable_usb(struct twl4030_bci *bci, bool enable)
@@ -207,10 +185,6 @@ static int twl4030_charger_enable_usb(struct twl4030_bci *bci, bool enable)
207 int ret; 185 int ret;
208 186
209 if (enable && !IS_ERR_OR_NULL(bci->transceiver)) { 187 if (enable && !IS_ERR_OR_NULL(bci->transceiver)) {
210 /* Check for USB charger connected */
211 if (!twl4030_bci_have_vbus(bci))
212 return -ENODEV;
213
214 /* 188 /*
215 * Until we can find out what current the device can provide, 189 * Until we can find out what current the device can provide,
216 * require a module param to enable USB charging. 190 * require a module param to enable USB charging.
@@ -662,7 +636,12 @@ static int twl4030_bci_probe(struct platform_device *pdev)
662 dev_warn(&pdev->dev, "failed to unmask interrupts: %d\n", ret); 636 dev_warn(&pdev->dev, "failed to unmask interrupts: %d\n", ret);
663 637
664 twl4030_charger_enable_ac(true); 638 twl4030_charger_enable_ac(true);
665 twl4030_charger_enable_usb(bci, true); 639 if (!IS_ERR_OR_NULL(bci->transceiver))
640 twl4030_bci_usb_ncb(&bci->usb_nb,
641 bci->transceiver->last_event,
642 NULL);
643 else
644 twl4030_charger_enable_usb(bci, false);
666 if (pdata) 645 if (pdata)
667 twl4030_charger_enable_backup(pdata->bb_uvolt, 646 twl4030_charger_enable_backup(pdata->bb_uvolt,
668 pdata->bb_uamp); 647 pdata->bb_uamp);