Commit 2785cefc98051646bd1d36a627822a3f43736697
Committed by
Anton Vorontsov
1 parent
f10513de2a
isp1704_charger: Allow board specific powering routine
The ISP1704/1707 chip can be put to full power down state by asserting the CHIP_SEL line. This patch enables platform or board specific hooks to put the device into power down mode in case not needed. This patch is a preparation for enabling this powering routine in n900 (rx-51) devices. Thanks to Heikki Krogerus for helping out with the patch. Signed-off-by: Kalle Jokiniemi <kalle.jokiniemi@nokia.com> Acked-By: Heikki Krogerus <heikki.krogerus@nokia.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
Showing 2 changed files with 51 additions and 0 deletions Side-by-side Diff
drivers/power/isp1704_charger.c
... | ... | @@ -33,6 +33,7 @@ |
33 | 33 | #include <linux/usb/ulpi.h> |
34 | 34 | #include <linux/usb/ch9.h> |
35 | 35 | #include <linux/usb/gadget.h> |
36 | +#include <linux/power/isp1704_charger.h> | |
36 | 37 | |
37 | 38 | /* Vendor specific Power Control register */ |
38 | 39 | #define ISP1704_PWR_CTRL 0x3d |
... | ... | @@ -71,6 +72,18 @@ |
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 | 87 | * Determine is the charging port DCP (dedicated charger) or CDP (Host/HUB |
75 | 88 | * chargers). |
76 | 89 | * |
... | ... | @@ -222,6 +235,9 @@ |
222 | 235 | |
223 | 236 | mutex_lock(&lock); |
224 | 237 | |
238 | + if (event != USB_EVENT_NONE) | |
239 | + isp1704_charger_set_power(isp, 1); | |
240 | + | |
225 | 241 | switch (event) { |
226 | 242 | case USB_EVENT_VBUS: |
227 | 243 | isp->online = true; |
... | ... | @@ -269,6 +285,8 @@ |
269 | 285 | */ |
270 | 286 | if (isp->otg->gadget) |
271 | 287 | usb_gadget_disconnect(isp->otg->gadget); |
288 | + | |
289 | + isp1704_charger_set_power(isp, 0); | |
272 | 290 | break; |
273 | 291 | case USB_EVENT_ENUMERATED: |
274 | 292 | if (isp->present) |
... | ... | @@ -394,6 +412,8 @@ |
394 | 412 | isp->dev = &pdev->dev; |
395 | 413 | platform_set_drvdata(pdev, isp); |
396 | 414 | |
415 | + isp1704_charger_set_power(isp, 1); | |
416 | + | |
397 | 417 | ret = isp1704_test_ulpi(isp); |
398 | 418 | if (ret < 0) |
399 | 419 | goto fail1; |
... | ... | @@ -434,6 +454,7 @@ |
434 | 454 | |
435 | 455 | /* Detect charger if VBUS is valid (the cable was already plugged). */ |
436 | 456 | ret = otg_io_read(isp->otg, ULPI_USB_INT_STS); |
457 | + isp1704_charger_set_power(isp, 0); | |
437 | 458 | if ((ret & ULPI_INT_VBUS_VALID) && !isp->otg->default_a) { |
438 | 459 | isp->event = USB_EVENT_VBUS; |
439 | 460 | schedule_work(&isp->work); |
... | ... | @@ -459,6 +480,7 @@ |
459 | 480 | otg_unregister_notifier(isp->otg, &isp->nb); |
460 | 481 | power_supply_unregister(&isp->psy); |
461 | 482 | otg_put_transceiver(isp->otg); |
483 | + isp1704_charger_set_power(isp, 0); | |
462 | 484 | kfree(isp); |
463 | 485 | |
464 | 486 | return 0; |
include/linux/power/isp1704_charger.h
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 |