linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>,
	Linus Walleij <linus.walleij@linaro.org>,
	Dmitry Artamonow <mad_soft@inbox.ru>
Subject: [PATCH 1/9] ARM: sa1100 collie: use gpio-charger instead of pda-power
Date: Fri, 15 Nov 2013 12:47:52 +0400	[thread overview]
Message-ID: <1384505280-25389-2-git-send-email-dbaryshkov@gmail.com> (raw)
In-Reply-To: <1384505280-25389-1-git-send-email-dbaryshkov@gmail.com>

Use gpio-charger driver instead of pda-power: it automatically cares
about used gpio and since collie does not differentiate between usb and
ac chargers, pda-power is an overkill for it.

As a bonus this allows us to remove gpio_to_irq calls from machine init
call - it is fragile. These gpio_to_irq calls will fail if gpios are
registered later, via device driver mechanisms.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 arch/arm/mach-sa1100/collie.c | 55 ++++++-------------------------------------
 1 file changed, 7 insertions(+), 48 deletions(-)

diff --git a/arch/arm/mach-sa1100/collie.c b/arch/arm/mach-sa1100/collie.c
index 7fb96eb..f902b8e 100644
--- a/arch/arm/mach-sa1100/collie.c
+++ b/arch/arm/mach-sa1100/collie.c
@@ -28,7 +28,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/timer.h>
 #include <linux/gpio.h>
-#include <linux/pda_power.h>
+#include <linux/power/gpio-charger.h>
 
 #include <video/sa1100fb.h>
 
@@ -97,62 +97,24 @@ static struct mcp_plat_data collie_mcp_data = {
 /*
  * Collie AC IN
  */
-static int collie_power_init(struct device *dev)
-{
-	int ret = gpio_request(COLLIE_GPIO_AC_IN, "ac in");
-	if (ret)
-		goto err_gpio_req;
-
-	ret = gpio_direction_input(COLLIE_GPIO_AC_IN);
-	if (ret)
-		goto err_gpio_in;
-
-	return 0;
-
-err_gpio_in:
-	gpio_free(COLLIE_GPIO_AC_IN);
-err_gpio_req:
-	return ret;
-}
-
-static void collie_power_exit(struct device *dev)
-{
-	gpio_free(COLLIE_GPIO_AC_IN);
-}
-
-static int collie_power_ac_online(void)
-{
-	return gpio_get_value(COLLIE_GPIO_AC_IN) == 2;
-}
-
 static char *collie_ac_supplied_to[] = {
 	"main-battery",
 	"backup-battery",
 };
 
-static struct pda_power_pdata collie_power_data = {
-	.init			= collie_power_init,
-	.is_ac_online		= collie_power_ac_online,
-	.exit			= collie_power_exit,
+
+static struct gpio_charger_platform_data collie_power_data = {
+	.name			= "charger",
+	.type			= POWER_SUPPLY_TYPE_MAINS,
+	.gpio			= COLLIE_GPIO_AC_IN,
 	.supplied_to		= collie_ac_supplied_to,
 	.num_supplicants	= ARRAY_SIZE(collie_ac_supplied_to),
 };
 
-static struct resource collie_power_resource[] = {
-	{
-		.name		= "ac",
-		.flags		= IORESOURCE_IRQ |
-				  IORESOURCE_IRQ_HIGHEDGE |
-				  IORESOURCE_IRQ_LOWEDGE,
-	},
-};
-
 static struct platform_device collie_power_device = {
-	.name			= "pda-power",
+	.name			= "gpio-charger",
 	.id			= -1,
 	.dev.platform_data	= &collie_power_data,
-	.resource		= collie_power_resource,
-	.num_resources		= ARRAY_SIZE(collie_power_resource),
 };
 
 #ifdef CONFIG_SHARP_LOCOMO
@@ -348,9 +310,6 @@ static void __init collie_init(void)
 
 	GPSR |= _COLLIE_GPIO_UCB1x00_RESET;
 
-	collie_power_resource[0].start = gpio_to_irq(COLLIE_GPIO_AC_IN);
-	collie_power_resource[0].end = gpio_to_irq(COLLIE_GPIO_AC_IN);
-
 	sa11x0_ppc_configure_mcp();
 
 
-- 
1.8.4.2


  reply	other threads:[~2013-11-15  8:48 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-15  8:47 [PATCH 0/9] ARM: sa1100: Rework IRQ handling Dmitry Eremin-Solenikov
2013-11-15  8:47 ` Dmitry Eremin-Solenikov [this message]
2013-11-15  8:47 ` [PATCH 2/9] ARM: locomo: don't clobber chip data for chained irq Dmitry Eremin-Solenikov
2013-11-15  8:47 ` [PATCH 3/9] ARM: sa1100: switch to MULTI_IRQ_HANDLER Dmitry Eremin-Solenikov
2013-11-15  8:47 ` [PATCH 4/9] ARM: sa1100: convert gpio driver to be a proper platform driver Dmitry Eremin-Solenikov
2013-11-19 10:08   ` Linus Walleij
2013-11-15  8:47 ` [PATCH 5/9] ARM: sa1100: add platform functions to handle PWER settings Dmitry Eremin-Solenikov
2013-11-15  8:47 ` [PATCH 6/9] ARM: sa1100: enable IRQ domains Dmitry Eremin-Solenikov
2013-11-15  8:47 ` [PATCH 7/9] ARM: sa1100: move gpio irq handling to GPIO driver Dmitry Eremin-Solenikov
2013-11-22 17:45   ` Russell King - ARM Linux
2013-11-22 19:46     ` Dmitry Eremin-Solenikov
2013-11-22 20:02       ` Russell King - ARM Linux
2013-11-22 21:20         ` Dmitry Eremin-Solenikov
2013-11-15  8:47 ` [PATCH 8/9] ARM: sa1100: move per-IRQ PWER settings to core code Dmitry Eremin-Solenikov
2013-11-15  8:48 ` [PATCH 9/9] ARM: sa1100: refactor irq driver Dmitry Eremin-Solenikov
2013-11-19 13:00 ` [PATCH 0/9] ARM: sa1100: Rework IRQ handling Linus Walleij
2013-11-19 15:17   ` Dmitry Eremin-Solenikov
2013-11-19 20:24     ` Linus Walleij
2013-11-20  0:20       ` Russell King - ARM Linux
2013-11-20  0:45         ` Dmitry Eremin-Solenikov
2013-11-20  7:43           ` Dmitry Artamonow
2013-11-22 17:58           ` Russell King - ARM Linux
2013-11-22 19:12             ` Dmitry Eremin-Solenikov
2013-11-22 19:51               ` Russell King - ARM Linux
2013-11-22 21:23                 ` Dmitry Eremin-Solenikov
2013-11-20  0:40       ` Dmitry Eremin-Solenikov
2013-11-22 17:33       ` Dmitry Eremin-Solenikov
2013-11-22 21:35 ` Dmitry Eremin-Solenikov

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=1384505280-25389-2-git-send-email-dbaryshkov@gmail.com \
    --to=dbaryshkov@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mad_soft@inbox.ru \
    /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).