[PATCH v2 1/2] isp1704_charger: allow board specific powering routine

Subsystems: power supply class/subsystem and drivers, the rest

STALE5610d

5 messages, 3 authors, 2011-03-30 · open the first message on its own page

[PATCH v2 1/2] isp1704_charger: allow board specific powering routine

From: Kalle Jokiniemi <hidden>
Date: 2011-03-28 06:51:38

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.

These patches are preparatio 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 <redacted>
Cc: Heikki Krogerus <redacted>
---
 drivers/power/isp1704_charger.c       |   26 ++++++++++++++++++++++++++
 include/linux/power/isp1704_charger.h |   29 +++++++++++++++++++++++++++++
 2 files changed, 55 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..c796b9f 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
@@ -63,6 +64,7 @@ struct isp1704_charger {
 	char			model[8];
 	unsigned		present:1;
 	unsigned		online:1;
+	unsigned		init_done;
 	unsigned		current_max;
 
 	/* temp storage variables */
@@ -71,6 +73,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 +236,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 +286,9 @@ static void isp1704_charger_work(struct work_struct *data)
 		 */
 		if (isp->otg->gadget)
 			usb_gadget_disconnect(isp->otg->gadget);
+		/* If we're initialized, we can power down the isp */
+		if (isp->init_done)
+			isp1704_charger_set_power(isp, 0);
 		break;
 	case USB_EVENT_ENUMERATED:
 		if (isp->present)
@@ -394,6 +414,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;
@@ -437,8 +459,11 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev)
 	if ((ret & ULPI_INT_VBUS_VALID) && !isp->otg->default_a) {
 		isp->event = USB_EVENT_VBUS;
 		schedule_work(&isp->work);
+	} else {
+		isp1704_charger_set_power(isp, 0);
 	}
 
+	isp->init_done = 1;
 	return 0;
 fail2:
 	power_supply_unregister(&isp->psy);
@@ -459,6 +484,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

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Re: [PATCH v2 1/2] isp1704_charger: allow board specific powering routine

From: Sergei Shtylyov <hidden>
Date: 2011-03-28 08:19:15

Hello.

On 28-03-2011 10:51, Kalle Jokiniemi wrote:
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.
These patches are preparatio for enabling this powering
    Preparation.
routine in n900 (rx-51) devices.
Thanks to Heikki Krogerus for helping out with the patch.
Signed-off-by: Kalle Jokiniemi<redacted>
Cc: Heikki Krogerus<redacted>
[...]
quoted hunk
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
    There should be include/linux/platform_data/ directory now, specifically 
for such headers...

WBR, Sergei

RE: [PATCH v2 1/2] isp1704_charger: allow board specific powering routine

From: <hidden>
Date: 2011-03-28 10:00:54

Hi,

 > -----Original Message-----
 > From: ext Sergei Shtylyov [mailto:sshtylyov@mvista.com]
 > Sent: 28. maaliskuuta 2011 11:18
 > To: Jokiniemi Kalle (Nokia-MS/Tampere)
 > Cc: linux-usb@vger.kernel.org; linux-omap@vger.kernel.org; balbi@ti.com;
 > Krogerus Heikki (Nokia-MS/Helsinki); jhnikula@gmail.com; khilman@ti.com
 > Subject: Re: [PATCH v2 1/2] isp1704_charger: allow board specific powering
 > routine
 > 
 > Hello.
 > 
 > On 28-03-2011 10:51, Kalle Jokiniemi wrote:
 > 
 > > 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.
 > 
 > > These patches are preparatio for enabling this powering
 > 
 >     Preparation.
 > 
 > > routine in n900 (rx-51) devices.
 > 
 > > Thanks to Heikki Krogerus for helping out with the patch.
 > 
 > > Signed-off-by: Kalle Jokiniemi[off-list ref]
 > > Cc: Heikki Krogerus[off-list ref]
 > [...]
 > 
 > > 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
 > 
 >     There should be include/linux/platform_data/ directory now, specifically
 > for such headers...

Thanks for the pointer, I'll put it there.

- Kalle

 > 
 > WBR, Sergei

RE: [PATCH v2 1/2] isp1704_charger: allow board specific powering routine

From: <hidden>
Date: 2011-03-29 05:52:03

Hi,

 > -----Original Message-----
 > From: Jokiniemi Kalle (Nokia-MS/Tampere)

<snip>
 > > 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
 >  >
 >  >     There should be include/linux/platform_data/ directory now, specifically
 >  > for such headers...
 > 
 > Thanks for the pointer, I'll put it there.

There are things like msm-serial.h and tegra-usb.h there, but I'm not so convinced
that this isp1704_charger.h should be there. The isp1707 component on n900 is
a discrete chip, it's not part of the SoC, so in theory some other device or platform
could also use it as a charger. It's not even made by TI, so it's not related in that
sense to OMAP platform...

What do you think about keeping it still in /include/linux/power ?

- Kalle

 > 
 > - Kalle
 > 
 >  >
 >  > WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Re: [PATCH v2 1/2] isp1704_charger: allow board specific powering routine

From: Sergei Shtylyov <hidden>
Date: 2011-03-30 11:20:32

Hello.

On 29.03.2011 9:52, kalle.jokiniemi@nokia.com wrote:
quoted
  >  >  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
  >   >      There should be include/linux/platform_data/ directory now, specifically
  >   >  for such headers...
  >  Thanks for the pointer, I'll put it there.
There are things like msm-serial.h and tegra-usb.h there, but I'm not so convinced
that this isp1704_charger.h should be there. The isp1707 component on n900 is
a discrete chip, it's not part of the SoC, so in theory some other device or platform
could also use it as a charger. It's not even made by TI, so it's not related in that
sense to OMAP platform...
    This directory is very new, so there's not much there yet. I don't think 
it's dedicated to SoC devices. Frankly speaking, I didn't get your 
argumentation here...
What do you think about keeping it still in /include/linux/power ?
    Well, I wouldn't object. It seemed to me initially that you're going to 
put it into include/linux/, so I've pointed to a better place...
- Kalle
WBR, Sergei
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help