From: anarsoul@gmail.com (Vasily Khoruzhick)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/3] rx1950: add rx1950 LEDs driver
Date: Sat, 10 Jul 2010 19:57:47 +0300 [thread overview]
Message-ID: <1278781069-30521-2-git-send-email-anarsoul@gmail.com> (raw)
In-Reply-To: <1278781069-30521-1-git-send-email-anarsoul@gmail.com>
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
arch/arm/mach-s3c2440/mach-rx1950.c | 6 +
drivers/leds/Kconfig | 6 +
drivers/leds/Makefile | 1 +
drivers/leds/leds-rx1950.c | 206 +++++++++++++++++++++++++++++++++++
4 files changed, 219 insertions(+), 0 deletions(-)
create mode 100644 drivers/leds/leds-rx1950.c
diff --git a/arch/arm/mach-s3c2440/mach-rx1950.c b/arch/arm/mach-s3c2440/mach-rx1950.c
index 8603b57..55b806a 100644
--- a/arch/arm/mach-s3c2440/mach-rx1950.c
+++ b/arch/arm/mach-s3c2440/mach-rx1950.c
@@ -126,6 +126,11 @@ static struct s3c2410fb_display rx1950_display = {
};
+static struct platform_device rx1950_device_leds = {
+ .name = "rx1950-leds",
+ .id = -1,
+};
+
static struct s3c2410fb_mach_info rx1950_lcd_cfg = {
.displays = &rx1950_display,
.num_displays = 1,
@@ -502,6 +507,7 @@ static struct platform_device *rx1950_devices[] __initdata = {
&s3c_device_timer[1],
&rx1950_backlight,
&rx1950_device_gpiokeys,
+ &rx1950_device_leds,
};
static struct clk *rx1950_clocks[] __initdata = {
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 81bf25e..f986825 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -102,6 +102,12 @@ config LEDS_H1940
help
This option enables support for the LEDs on the h1940.
+config LEDS_RX1950
+ tristate "LED Support for iPAQ RX1950 device"
+ depends on MACH_RX1950
+ help
+ This option enables support for the LEDs on the rx1950.
+
config LEDS_COBALT_QUBE
tristate "LED Support for the Cobalt Qube series front LED"
depends on MIPS_COBALT
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 2493de4..faa0d5d 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_LEDS_NET5501) += leds-net5501.o
obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o
obj-$(CONFIG_LEDS_ALIX2) += leds-alix2.o
obj-$(CONFIG_LEDS_H1940) += leds-h1940.o
+obj-$(CONFIG_LEDS_RX1950) += leds-rx1950.o
obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o
obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o
obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o
diff --git a/drivers/leds/leds-rx1950.c b/drivers/leds/leds-rx1950.c
new file mode 100644
index 0000000..1eed583
--- /dev/null
+++ b/drivers/leds/leds-rx1950.c
@@ -0,0 +1,206 @@
+/*
+ * drivers/leds/leds-rx1950.c
+ *
+ * Based on leds-h1940 by Arnaud Patard <arnaud.patard@rtp-net.org>
+ * Copyright (c) Vasily Khoruzhick <anarsoul@gmail.com>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file COPYING in the main directory of this archive for
+ * more details.
+ *
+ * RX1950 leds driver
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/string.h>
+#include <linux/ctype.h>
+#include <linux/leds.h>
+#include <linux/gpio.h>
+
+#include <mach/regs-gpio.h>
+#include <mach/regs-gpioj.h>
+#include <mach/hardware.h>
+
+/*
+ * Green led.
+ */
+static void rx1950_greenled_set(struct led_classdev *led_dev,
+ enum led_brightness value)
+{
+ switch (value) {
+ case LED_HALF:
+ gpio_direction_output(S3C2410_GPA(4), 1);
+ gpio_direction_output(S3C2410_GPA(6), 0);
+ gpio_direction_output(S3C2410_GPJ(6), 1);
+ break;
+ case LED_FULL:
+ gpio_direction_output(S3C2410_GPA(4), 0);
+ gpio_direction_output(S3C2410_GPA(6), 1);
+ gpio_direction_output(S3C2410_GPJ(6), 0);
+ break;
+ default:
+ case LED_OFF:
+ gpio_direction_output(S3C2410_GPA(4), 0);
+ gpio_direction_output(S3C2410_GPA(6), 0);
+ gpio_direction_output(S3C2410_GPJ(6), 0);
+ break;
+ }
+}
+
+static struct led_classdev rx1950_greenled = {
+ .name = "rx1950:green",
+ .brightness_set = rx1950_greenled_set,
+ .default_trigger = "s3c-adc-charger",
+};
+
+static void rx1950_redled_set(struct led_classdev *led_dev,
+ enum led_brightness value)
+{
+ switch (value) {
+ case LED_HALF:
+ gpio_direction_output(S3C2410_GPA(3), 1);
+ gpio_direction_output(S3C2410_GPA(7), 0);
+ gpio_direction_output(S3C2410_GPJ(6), 1);
+ break;
+ case LED_FULL:
+ gpio_direction_output(S3C2410_GPA(3), 0);
+ gpio_direction_output(S3C2410_GPA(7), 1);
+ gpio_direction_output(S3C2410_GPJ(6), 0);
+ break;
+ default:
+ case LED_OFF:
+ gpio_direction_output(S3C2410_GPA(3), 0);
+ gpio_direction_output(S3C2410_GPA(7), 0);
+ gpio_direction_output(S3C2410_GPJ(6), 0);
+ break;
+ }
+}
+
+static struct led_classdev rx1950_redled = {
+ .name = "rx1950:red",
+ .brightness_set = rx1950_redled_set,
+ .default_trigger = "s3c-adc-charger",
+};
+
+/*
+ * Blue led.
+ */
+static void rx1950_blueled_set(struct led_classdev *led_dev,
+ enum led_brightness value)
+{
+ if (value)
+ gpio_direction_output(S3C2410_GPA(11), 1);
+ else
+ gpio_direction_output(S3C2410_GPA(11), 0);
+}
+
+static struct led_classdev rx1950_blueled = {
+ .name = "rx1950:blue",
+ .brightness_set = rx1950_blueled_set,
+ .default_trigger = "rx1950-acx-mem",
+};
+
+static int __devinit rx1950leds_probe(struct platform_device *pdev)
+{
+ int ret;
+
+ ret = gpio_request(S3C2410_GPA(3), "rx1950:red_led_blink");
+ if (ret)
+ goto err_blink_red;
+
+ ret = gpio_request(S3C2410_GPA(4), "rx1950:green_led_blink");
+ if (ret)
+ goto err_blink_green;
+
+ ret = gpio_request(S3C2410_GPJ(6), "rx1950:led_blink");
+ if (ret)
+ goto err_blink;
+
+ ret = gpio_request(S3C2410_GPA(6), "rx1950:green_led");
+ if (ret)
+ goto err_green;
+ ret = led_classdev_register(&pdev->dev, &rx1950_greenled);
+ if (ret)
+ goto err_green_gpio;
+
+ ret = gpio_request(S3C2410_GPA(7), "rx1950:red_led");
+ if (ret)
+ goto err_red;
+ ret = led_classdev_register(&pdev->dev, &rx1950_redled);
+ if (ret)
+ goto err_red_gpio;
+
+ ret = gpio_request(S3C2410_GPA(11), "rx1950:blue_led");
+ if (ret)
+ goto err_blue;
+ ret = led_classdev_register(&pdev->dev, &rx1950_blueled);
+ if (ret)
+ goto err_blue_gpio;
+
+ return 0;
+
+err_blue_gpio:
+ gpio_free(S3C2410_GPA(11));
+err_blue:
+ led_classdev_unregister(&rx1950_redled);
+err_red_gpio:
+ gpio_free(S3C2410_GPA(6));
+err_red:
+ led_classdev_unregister(&rx1950_greenled);
+err_green_gpio:
+ gpio_free(S3C2410_GPA7);
+err_green:
+ gpio_free(S3C2410_GPJ(6));
+err_blink:
+ gpio_free(S3C2410_GPA(4));
+err_blink_green:
+ gpio_free(S3C2410_GPA(3));
+err_blink_red:
+ return ret;
+}
+
+static int rx1950leds_remove(struct platform_device *pdev)
+{
+ led_classdev_unregister(&rx1950_greenled);
+ led_classdev_unregister(&rx1950_redled);
+ led_classdev_unregister(&rx1950_blueled);
+ gpio_free(S3C2410_GPA(11));
+ gpio_free(S3C2410_GPA(6));
+ gpio_free(S3C2410_GPA(7));
+ gpio_free(S3C2410_GPJ(6));
+ gpio_free(S3C2410_GPA(3));
+ gpio_free(S3C2410_GPA(4));
+ return 0;
+}
+
+
+static struct platform_driver rx1950leds_driver = {
+ .driver = {
+ .name = "rx1950-leds",
+ .owner = THIS_MODULE,
+ },
+ .probe = rx1950leds_probe,
+ .remove = rx1950leds_remove,
+};
+
+
+static int __init rx1950leds_init(void)
+{
+ return platform_driver_register(&rx1950leds_driver);
+}
+
+static void __exit rx1950leds_exit(void)
+{
+ platform_driver_unregister(&rx1950leds_driver);
+}
+
+module_init(rx1950leds_init);
+module_exit(rx1950leds_exit);
+
+MODULE_AUTHOR("Vasily Khoruzhick <anarsoul@gmail.com>");
+MODULE_DESCRIPTION("LED driver for the iPAQ RX1950");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:rx1950-leds");
--
1.7.1
next prev parent reply other threads:[~2010-07-10 16:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-10 16:57 [PATCH v2 0/3] s3c24xx: iPAQ rx1950 series Vasily Khoruzhick
2010-07-10 16:57 ` Vasily Khoruzhick [this message]
2010-07-10 16:57 ` [PATCH v2 2/3] Add s3c-adc-battery driver Vasily Khoruzhick
2010-07-13 18:27 ` Anton Vorontsov
2010-07-10 16:57 ` [PATCH v2 3/3] rx1950: add battery support Vasily Khoruzhick
2010-07-12 13:28 ` [PATCH v2 0/3] s3c24xx: iPAQ rx1950 series Vasily Khoruzhick
2010-07-13 15:13 ` Anton Vorontsov
2010-07-13 15:45 ` Vasily Khoruzhick
2010-07-13 15:58 ` Mark Brown
2010-07-13 17:05 ` Vasily Khoruzhick
2010-07-13 18:03 ` Mark Brown
2010-07-13 18:29 ` Vasily Khoruzhick
2010-07-13 20:08 ` Mark Brown
2010-07-13 20:11 ` Vasily Khoruzhick
2010-07-13 16:27 ` Anton Vorontsov
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=1278781069-30521-2-git-send-email-anarsoul@gmail.com \
--to=anarsoul@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.