[PATCH] [LEDS]: Remove GTA02 leds driver

Jonas Bonn jonas.bonn at gmail.com
Sun Oct 12 13:11:16 CEST 2008


This patch is motivation for the transition to generic GPIO's with
transparent shadowing.  The only difference between the generic GPIO
LED's driver and the GTA02-specific one is the use of
neo1973_gpb_setpin.  When gpio_set_value now handles the necessary
shadowing transparently, it should be possible to transition to the
generic LED driver and simplify the codebase a bit.

Note: this is not so well tested... I don't even have a GTA02.  I tested
the GPIO LED driver with my GTA01 (vibrator) and it works with code very
similar to this GTA02 code.  Someone with a GTA02 would be well-advised
to test.

Note also that this patch depends on the transparent GPIO shadowing
patch I sent earlier.

Signed-off-by: Jonas Bonn <jonas.bonn at gmail.com>
---
 arch/arm/gta02-moredrivers-defconfig |    1 -
 arch/arm/mach-s3c2440/mach-gta02.c   |   58 ++++++++----
 drivers/leds/Kconfig                 |    6 -
 drivers/leds/Makefile                |    1 -
 drivers/leds/leds-neo1973-gta02.c    |  178 ----------------------------------
 5 files changed, 39 insertions(+), 205 deletions(-)
 delete mode 100644 drivers/leds/leds-neo1973-gta02.c

diff --git a/arch/arm/gta02-moredrivers-defconfig b/arch/arm/gta02-moredrivers-defconfig
index 3c173f2..c820b35 100644
--- a/arch/arm/gta02-moredrivers-defconfig
+++ b/arch/arm/gta02-moredrivers-defconfig
@@ -1535,7 +1535,6 @@ CONFIG_LEDS_S3C24XX=m
 CONFIG_LEDS_GPIO=y
 # CONFIG_LEDS_PCA955X is not set
 CONFIG_LEDS_NEO1973_VIBRATOR=y
-CONFIG_LEDS_NEO1973_GTA02=y
 
 #
 # LED Triggers
diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
index 47d863b..391895e 100644
--- a/arch/arm/mach-s3c2440/mach-gta02.c
+++ b/arch/arm/mach-s3c2440/mach-gta02.c
@@ -38,6 +38,9 @@
 #include <linux/spi/glamo.h>
 #include <linux/spi/spi_bitbang.h>
 #include <linux/mmc/host.h>
+#include <linux/gpio.h>
+#include <linux/leds.h>
+
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
@@ -1253,28 +1256,46 @@ static struct platform_device s3c_device_spi_acc = {
 	},
 };
 
-static struct resource gta02_led_resources[] = {
-	{
-		.name	= "gta02-power:orange",
-		.start	= GTA02_GPIO_PWR_LED1,
-		.end	= GTA02_GPIO_PWR_LED1,
-	}, {
-		.name	= "gta02-power:blue",
-		.start	= GTA02_GPIO_PWR_LED2,
-		.end	= GTA02_GPIO_PWR_LED2,
-	}, {
-		.name	= "gta02-aux:red",
-		.start	= GTA02_GPIO_AUX_LED,
-		.end	= GTA02_GPIO_AUX_LED,
-	},
+/* 
+ * LEDS
+ * This uses the generic gpio_keys driver.
+ */
+
+static struct gpio_led gta02_gpio_leds[] = {
+        {
+                .name                   = "gta02-power:orange",
+                .default_trigger        = "none",
+                .gpio                   = GTA02_GPIO_PWR_LED1
+        },
+        {
+                .name                   = "gta02-power:blue",
+                .default_trigger        = "none",
+                .gpio                   = GTA02_GPIO_PWR_LED2
+        },
+        {
+                .name                   = "gta02-aux:red",
+                .default_trigger        = "none",
+                .gpio                   = GTA02_GPIO_AUX_LED
+        }
 };
 
-struct platform_device gta02_led_dev = {
-	.name		= "gta02-led",
-	.num_resources	= ARRAY_SIZE(gta02_led_resources),
-	.resource	= gta02_led_resources,
+static struct gpio_led_platform_data gta02_gpio_leds_platform_data = {
+        .leds           = gta02_gpio_leds,
+        .num_leds       = ARRAY_SIZE(gta02_gpio_leds),
+};
+
+static struct platform_device gta02_led_dev = {
+        .name   = "leds-gpio",
+        .id     = -1,
+        .dev    = {
+                .platform_data  = &gta02_gpio_leds_platform_data,
+        },
 };
 
+/*
+ * Buttons
+ */
+
 static struct resource gta02_button_resources[] = {
 	[0] = {
 		.start = GTA02_GPIO_AUX_KEY,
@@ -1642,7 +1663,6 @@ static void __init gta02_machine_init(void)
 	platform_device_register(&gta02_vibrator_dev);
 	platform_device_register(&gta02_led_dev);
 
-
 	platform_device_register(&gta02_sdio_dev);
 
 	platform_add_devices(gta02_devices, ARRAY_SIZE(gta02_devices));
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 7d822d0..8e483df 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -170,12 +170,6 @@ config LEDS_NEO1973_VIBRATOR
 	help
 	  This option enables support for the vibrator on the FIC Neo1973.
 
-config LEDS_NEO1973_GTA02
-	tristate "LED Support for the FIC Neo1973 (GTA02)"
-	depends on LEDS_CLASS && MACH_NEO1973_GTA02
-	help
-	  This option enables support for the LEDs on the FIC Neo1973.
-
 comment "LED Triggers"
 
 config LEDS_TRIGGERS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index b77d411..44c2c95 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -24,7 +24,6 @@ obj-$(CONFIG_LEDS_HP6XX)		+= leds-hp6xx.o
 obj-$(CONFIG_LEDS_FSG)			+= leds-fsg.o
 obj-$(CONFIG_LEDS_PCA955X)		+= leds-pca955x.o
 obj-$(CONFIG_LEDS_NEO1973_VIBRATOR)	+= leds-neo1973-vibrator.o
-obj-$(CONFIG_LEDS_NEO1973_GTA02)	+= leds-neo1973-gta02.o
 
 # LED Triggers
 obj-$(CONFIG_LEDS_TRIGGER_TIMER)	+= ledtrig-timer.o
diff --git a/drivers/leds/leds-neo1973-gta02.c b/drivers/leds/leds-neo1973-gta02.c
deleted file mode 100644
index 9eb8cb4..0000000
--- a/drivers/leds/leds-neo1973-gta02.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * LED driver for the FIC Neo1973 GTA02 GSM phone
- *
- * (C) 2006-2007 by Openmoko, Inc.
- * Author: Harald Welte <laforge at openmoko.org>
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/leds.h>
-#include <mach/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/arch/gta02.h>
-#include <asm/plat-s3c/regs-timer.h>
-#include <asm/plat-s3c24xx/neo1973.h>
-
-#define MAX_LEDS 3
-#define COUNTER 256
-
-struct gta02_led_priv
-{
-	spinlock_t lock;
-	struct led_classdev cdev;
-	unsigned int gpio;
-};
-
-struct gta02_led_bundle
-{
-	int num_leds;
-	struct gta02_led_priv led[MAX_LEDS];
-};
-
-static inline struct gta02_led_priv *to_priv(struct led_classdev *led_cdev)
-{
-	return container_of(led_cdev, struct gta02_led_priv, cdev);
-}
-
-static inline struct gta02_led_bundle *to_bundle(struct led_classdev *led_cdev)
-{
-	return dev_get_drvdata(led_cdev->dev->parent);
-}
-
-static void gta02led_set(struct led_classdev *led_cdev,
-		enum led_brightness value)
-{
-	unsigned long flags;
-	struct gta02_led_priv *lp = to_priv(led_cdev);
-
-	spin_lock_irqsave(&lp->lock, flags);
-	neo1973_gpb_setpin(lp->gpio, value ? 1 : 0);
-	spin_unlock_irqrestore(&lp->lock, flags);
-}
-
-#ifdef CONFIG_PM
-static int gta02led_suspend(struct platform_device *pdev, pm_message_t state)
-{
-	struct gta02_led_bundle *bundle = platform_get_drvdata(pdev);
-	int i;
-
-	for (i = 0; i < bundle->num_leds; i++)
-		led_classdev_suspend(&bundle->led[i].cdev);
-
-	return 0;
-}
-
-static int gta02led_resume(struct platform_device *pdev)
-{
-	struct gta02_led_bundle *bundle = platform_get_drvdata(pdev);
-	int i;
-
-	for (i = 0; i < bundle->num_leds; i++)
-		led_classdev_resume(&bundle->led[i].cdev);
-
-	return 0;
-}
-#endif
-
-static int __init gta02led_probe(struct platform_device *pdev)
-{
-	int i, rc;
-	struct gta02_led_bundle *bundle;
-
-	if (!machine_is_neo1973_gta02())
-		return -EIO;
-
-	bundle = kzalloc(sizeof(struct gta02_led_bundle), GFP_KERNEL);
-	if (!bundle)
-		return -ENOMEM;
-	platform_set_drvdata(pdev, bundle);
-
-	for (i = 0; i < pdev->num_resources; i++) {
-		struct gta02_led_priv *lp;
-		struct resource *r;
-
-		if (i >= MAX_LEDS)
-			break;
-
-		r = platform_get_resource(pdev, 0, i);
-		if (!r || !r->start || !r->name)
-			continue;
-
-		lp = &bundle->led[i];
-
-		lp->gpio = r->start;
-		lp->cdev.name = r->name;
-		lp->cdev.brightness_set = gta02led_set;
-
-		switch (lp->gpio) {
-		case S3C2410_GPB0:
-		case S3C2410_GPB1:
-		case S3C2410_GPB2:
-			s3c2410_gpio_cfgpin(lp->gpio, S3C2410_GPIO_OUTPUT);
-			break;
-		default:
-			break;
-		}
-
-		spin_lock_init(&lp->lock);
-		rc = led_classdev_register(&pdev->dev, &lp->cdev);
-	}
-
-	bundle->num_leds = i;
-
-	return 0;
-}
-
-static int gta02led_remove(struct platform_device *pdev)
-{
-	struct gta02_led_bundle *bundle = platform_get_drvdata(pdev);
-	int i;
-
-	for (i = 0; i < bundle->num_leds; i++) {
-		struct gta02_led_priv *lp = &bundle->led[i];
-		gta02led_set(&lp->cdev, 0);
-		led_classdev_unregister(&lp->cdev);
-	}
-
-	platform_set_drvdata(pdev, NULL);
-	kfree(bundle);
-
-	return 0;
-}
-
-static struct platform_driver gta02led_driver = {
-	.probe		= gta02led_probe,
-	.remove		= gta02led_remove,
-#ifdef CONFIG_PM
-	.suspend	= gta02led_suspend,
-	.resume		= gta02led_resume,
-#endif
-	.driver		= {
-		.name		= "gta02-led",
-	},
-};
-
-static int __init gta02led_init(void)
-{
-	return platform_driver_register(&gta02led_driver);
-}
-
-static void __exit gta02led_exit(void)
-{
- 	platform_driver_unregister(&gta02led_driver);
-}
-
-module_init(gta02led_init);
-module_exit(gta02led_exit);
-
-MODULE_AUTHOR("Harald Welte <laforge at openmoko.org>");
-MODULE_DESCRIPTION("FIC Neo1973 GTA02 LED driver");
-MODULE_LICENSE("GPL");
-- 
1.5.6.3




More information about the openmoko-kernel mailing list