diff options
-rw-r--r-- | drivers/power/isp1704_charger.c | 22 | ||||
-rw-r--r-- | include/linux/power/isp1704_charger.h | 29 |
2 files changed, 51 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 | */ | ||
78 | static 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; |
diff --git a/include/linux/power/isp1704_charger.h b/include/linux/power/isp1704_charger.h new file mode 100644 index 000000000000..68096a6aa2d7 --- /dev/null +++ b/include/linux/power/isp1704_charger.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * ISP1704 USB Charger Detection driver | ||
3 | * | ||
4 | * Copyright (C) 2011 Nokia Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | |||
22 | #ifndef __ISP1704_CHARGER_H | ||
23 | #define __ISP1704_CHARGER_H | ||
24 | |||
25 | struct isp1704_charger_data { | ||
26 | void (*set_power)(bool on); | ||
27 | }; | ||
28 | |||
29 | #endif | ||