From: Kalle Jokiniemi <kalle.jokiniemi@nokia.com>
To: linux-usb@vger.kernel.org, cbouatmailru@gmail.com
Cc: balbi@ti.com, heikki.krogerus@nokia.com, sshtylyov@mvista.com,
tony@atomide.com, khilman@ti.com, linux-omap@vger.kernel.org,
jhnikula@gmail.com, Kalle Jokiniemi <kalle.jokiniemi@nokia.com>
Subject: [PATCH v3 1/2] isp1704_charger: allow board specific powering routine
Date: Tue, 29 Mar 2011 16:27:59 +0300 [thread overview]
Message-ID: <1301405280-16899-2-git-send-email-kalle.jokiniemi@nokia.com> (raw)
In-Reply-To: <1301405280-16899-1-git-send-email-kalle.jokiniemi@nokia.com>
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>
Cc: Heikki Krogerus <heikki.krogerus@nokia.com>
---
drivers/power/isp1704_charger.c | 22 ++++++++++++++++++++++
include/linux/power/isp1704_charger.h | 29 +++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 0 deletions(-)
create mode 100644 include/linux/power/isp1704_charger.h
diff --git a/drivers/power/isp1704_charger.c b/drivers/power/isp1704_charger.c
index 2ad9b14..f6d72b4 100644
--- a/drivers/power/isp1704_charger.c
+++ b/drivers/power/isp1704_charger.c
@@ -33,6 +33,7 @@
#include <linux/usb/ulpi.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
+#include <linux/power/isp1704_charger.h>
/* Vendor specific Power Control register */
#define ISP1704_PWR_CTRL 0x3d
@@ -71,6 +72,18 @@ struct isp1704_charger {
};
/*
+ * Disable/enable the power from the isp1704 if a function for it
+ * has been provided with platform data.
+ */
+static void isp1704_charger_set_power(struct isp1704_charger *isp, bool on)
+{
+ struct isp1704_charger_data *board = isp->dev->platform_data;
+
+ if (board->set_power)
+ board->set_power(on);
+}
+
+/*
* Determine is the charging port DCP (dedicated charger) or CDP (Host/HUB
* chargers).
*
@@ -222,6 +235,9 @@ static void isp1704_charger_work(struct work_struct *data)
mutex_lock(&lock);
+ if (event != USB_EVENT_NONE)
+ isp1704_charger_set_power(isp, 1);
+
switch (event) {
case USB_EVENT_VBUS:
isp->online = true;
@@ -269,6 +285,8 @@ static void isp1704_charger_work(struct work_struct *data)
*/
if (isp->otg->gadget)
usb_gadget_disconnect(isp->otg->gadget);
+
+ isp1704_charger_set_power(isp, 0);
break;
case USB_EVENT_ENUMERATED:
if (isp->present)
@@ -394,6 +412,8 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev)
isp->dev = &pdev->dev;
platform_set_drvdata(pdev, isp);
+ isp1704_charger_set_power(isp, 1);
+
ret = isp1704_test_ulpi(isp);
if (ret < 0)
goto fail1;
@@ -434,6 +454,7 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev)
/* Detect charger if VBUS is valid (the cable was already plugged). */
ret = otg_io_read(isp->otg, ULPI_USB_INT_STS);
+ isp1704_charger_set_power(isp, 0);
if ((ret & ULPI_INT_VBUS_VALID) && !isp->otg->default_a) {
isp->event = USB_EVENT_VBUS;
schedule_work(&isp->work);
@@ -459,6 +480,7 @@ static int __devexit isp1704_charger_remove(struct platform_device *pdev)
otg_unregister_notifier(isp->otg, &isp->nb);
power_supply_unregister(&isp->psy);
otg_put_transceiver(isp->otg);
+ isp1704_charger_set_power(isp, 0);
kfree(isp);
return 0;
diff --git a/include/linux/power/isp1704_charger.h b/include/linux/power/isp1704_charger.h
new file mode 100644
index 0000000..68096a6
--- /dev/null
+++ b/include/linux/power/isp1704_charger.h
@@ -0,0 +1,29 @@
+/*
+ * ISP1704 USB Charger Detection driver
+ *
+ * Copyright (C) 2011 Nokia Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef __ISP1704_CHARGER_H
+#define __ISP1704_CHARGER_H
+
+struct isp1704_charger_data {
+ void (*set_power)(bool on);
+};
+
+#endif
--
1.7.1
next prev parent reply other threads:[~2011-03-29 13:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-29 13:27 [PATCH v3 0/2] isp1704_charger: fix powering for N900 Kalle Jokiniemi
2011-03-29 13:27 ` Kalle Jokiniemi [this message]
2011-03-30 5:08 ` [PATCH v3 1/2] isp1704_charger: allow board specific powering routine Heikki Krogerus
2011-03-29 13:28 ` [PATCH v3 2/2] RX-51: Enable isp1704 power on/off Kalle Jokiniemi
2011-03-30 5:08 ` Heikki Krogerus
2011-04-13 5:10 ` Heikki Krogerus
2011-04-13 6:28 ` Tony Lindgren
2011-04-20 10:38 ` kalle.jokiniemi
[not found] ` <9D0D31AA57AAF5499AFDC63D6472631B084995-vKHveGmogcsbcE5WFD5oKCw+Ng1cvSfHNLMJvB61ksU@public.gmane.org>
2011-04-20 10:56 ` kalle.jokiniemi-xNZwKgViW5gAvxtiuMwx3w
2011-04-20 17:24 ` Anton Vorontsov
[not found] ` <1301405280-16899-3-git-send-email-kalle.jokiniemi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2011-03-30 6:38 ` Keshava Munegowda
[not found] ` <a5285450b1fc92da8a42cc0733360a30-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-03-30 6:41 ` kalle.jokiniemi-xNZwKgViW5gAvxtiuMwx3w
2011-03-30 6:44 ` Keshava Munegowda
2011-03-30 7:00 ` kalle.jokiniemi
[not found] ` <1301405280-16899-1-git-send-email-kalle.jokiniemi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2011-04-07 7:13 ` [PATCH v3 0/2] isp1704_charger: fix powering for N900 kalle.jokiniemi-xNZwKgViW5gAvxtiuMwx3w
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1301405280-16899-2-git-send-email-kalle.jokiniemi@nokia.com \
--to=kalle.jokiniemi@nokia.com \
--cc=balbi@ti.com \
--cc=cbouatmailru@gmail.com \
--cc=heikki.krogerus@nokia.com \
--cc=jhnikula@gmail.com \
--cc=khilman@ti.com \
--cc=linux-omap@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sshtylyov@mvista.com \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).