aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/isp1704_charger.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/power/isp1704_charger.c b/drivers/power/isp1704_charger.c
index 2ad9b14a5ce3..f6d72b402a8e 100644
--- a/drivers/power/isp1704_charger.c
+++ b/drivers/power/isp1704_charger.c
@@ -33,6 +33,7 @@
33#include <linux/usb/ulpi.h> 33#include <linux/usb/ulpi.h>
34#include <linux/usb/ch9.h> 34#include <linux/usb/ch9.h>
35#include <linux/usb/gadget.h> 35#include <linux/usb/gadget.h>
36#include <linux/power/isp1704_charger.h>
36 37
37/* Vendor specific Power Control register */ 38/* Vendor specific Power Control register */
38#define ISP1704_PWR_CTRL 0x3d 39#define ISP1704_PWR_CTRL 0x3d
@@ -71,6 +72,18 @@ struct isp1704_charger {
71}; 72};
72 73
73/* 74/*
75 * Disable/enable the power from the isp1704 if a function for it
76 * has been provided with platform data.
77 */
78static void isp1704_charger_set_power(struct isp1704_charger *isp, bool on)
79{
80 struct isp1704_charger_data *board = isp->dev->platform_data;
81
82 if (board->set_power)
83 board->set_power(on);
84}
85
86/*
74 * Determine is the charging port DCP (dedicated charger) or CDP (Host/HUB 87 * Determine is the charging port DCP (dedicated charger) or CDP (Host/HUB
75 * chargers). 88 * chargers).
76 * 89 *
@@ -222,6 +235,9 @@ static void isp1704_charger_work(struct work_struct *data)
222 235
223 mutex_lock(&lock); 236 mutex_lock(&lock);
224 237
238 if (event != USB_EVENT_NONE)
239 isp1704_charger_set_power(isp, 1);
240
225 switch (event) { 241 switch (event) {
226 case USB_EVENT_VBUS: 242 case USB_EVENT_VBUS:
227 isp->online = true; 243 isp->online = true;
@@ -269,6 +285,8 @@ static void isp1704_charger_work(struct work_struct *data)
269 */ 285 */
270 if (isp->otg->gadget) 286 if (isp->otg->gadget)
271 usb_gadget_disconnect(isp->otg->gadget); 287 usb_gadget_disconnect(isp->otg->gadget);
288
289 isp1704_charger_set_power(isp, 0);
272 break; 290 break;
273 case USB_EVENT_ENUMERATED: 291 case USB_EVENT_ENUMERATED:
274 if (isp->present) 292 if (isp->present)
@@ -394,6 +412,8 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev)
394 isp->dev = &pdev->dev; 412 isp->dev = &pdev->dev;
395 platform_set_drvdata(pdev, isp); 413 platform_set_drvdata(pdev, isp);
396 414
415 isp1704_charger_set_power(isp, 1);
416
397 ret = isp1704_test_ulpi(isp); 417 ret = isp1704_test_ulpi(isp);
398 if (ret < 0) 418 if (ret < 0)
399 goto fail1; 419 goto fail1;
@@ -434,6 +454,7 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev)
434 454
435 /* Detect charger if VBUS is valid (the cable was already plugged). */ 455 /* Detect charger if VBUS is valid (the cable was already plugged). */
436 ret = otg_io_read(isp->otg, ULPI_USB_INT_STS); 456 ret = otg_io_read(isp->otg, ULPI_USB_INT_STS);
457 isp1704_charger_set_power(isp, 0);
437 if ((ret & ULPI_INT_VBUS_VALID) && !isp->otg->default_a) { 458 if ((ret & ULPI_INT_VBUS_VALID) && !isp->otg->default_a) {
438 isp->event = USB_EVENT_VBUS; 459 isp->event = USB_EVENT_VBUS;
439 schedule_work(&isp->work); 460 schedule_work(&isp->work);
@@ -459,6 +480,7 @@ static int __devexit isp1704_charger_remove(struct platform_device *pdev)
459 otg_unregister_notifier(isp->otg, &isp->nb); 480 otg_unregister_notifier(isp->otg, &isp->nb);
460 power_supply_unregister(&isp->psy); 481 power_supply_unregister(&isp->psy);
461 otg_put_transceiver(isp->otg); 482 otg_put_transceiver(isp->otg);
483 isp1704_charger_set_power(isp, 0);
462 kfree(isp); 484 kfree(isp);
463 485
464 return 0; 486 return 0;