2007-02-13 02:09:32 +03:00
|
|
|
/*
|
2007-05-09 09:51:49 +04:00
|
|
|
* drivers/leds/leds-h1940.c
|
2007-02-13 02:09:32 +03:00
|
|
|
* Copyright (c) Arnaud Patard <arnaud.patard@rtp-net.org>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* H1940 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>
|
2009-05-14 01:52:24 +04:00
|
|
|
#include <linux/gpio.h>
|
|
|
|
|
2008-08-05 19:14:15 +04:00
|
|
|
#include <mach/regs-gpio.h>
|
|
|
|
#include <mach/hardware.h>
|
|
|
|
#include <mach/h1940-latch.h>
|
2007-02-13 02:09:32 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Green led.
|
|
|
|
*/
|
2008-06-10 01:00:49 +04:00
|
|
|
static void h1940_greenled_set(struct led_classdev *led_dev,
|
|
|
|
enum led_brightness value)
|
2007-02-13 02:09:32 +03:00
|
|
|
{
|
|
|
|
switch (value) {
|
2008-03-09 23:59:57 +03:00
|
|
|
case LED_HALF:
|
|
|
|
h1940_latch_control(0, H1940_LATCH_LED_FLASH);
|
|
|
|
s3c2410_gpio_setpin(S3C2410_GPA7, 1);
|
|
|
|
break;
|
|
|
|
case LED_FULL:
|
|
|
|
h1940_latch_control(0, H1940_LATCH_LED_GREEN);
|
|
|
|
s3c2410_gpio_setpin(S3C2410_GPA7, 1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case LED_OFF:
|
|
|
|
h1940_latch_control(H1940_LATCH_LED_FLASH, 0);
|
|
|
|
h1940_latch_control(H1940_LATCH_LED_GREEN, 0);
|
|
|
|
s3c2410_gpio_setpin(S3C2410_GPA7, 0);
|
|
|
|
break;
|
2007-02-13 02:09:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct led_classdev h1940_greenled = {
|
|
|
|
.name = "h1940:green",
|
|
|
|
.brightness_set = h1940_greenled_set,
|
|
|
|
.default_trigger = "h1940-charger",
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Red led.
|
|
|
|
*/
|
2008-06-10 01:00:49 +04:00
|
|
|
static void h1940_redled_set(struct led_classdev *led_dev,
|
|
|
|
enum led_brightness value)
|
2007-02-13 02:09:32 +03:00
|
|
|
{
|
|
|
|
switch (value) {
|
2008-03-09 23:59:57 +03:00
|
|
|
case LED_HALF:
|
|
|
|
h1940_latch_control(0, H1940_LATCH_LED_FLASH);
|
|
|
|
s3c2410_gpio_setpin(S3C2410_GPA1, 1);
|
|
|
|
break;
|
|
|
|
case LED_FULL:
|
|
|
|
h1940_latch_control(0, H1940_LATCH_LED_RED);
|
|
|
|
s3c2410_gpio_setpin(S3C2410_GPA1, 1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case LED_OFF:
|
|
|
|
h1940_latch_control(H1940_LATCH_LED_FLASH, 0);
|
|
|
|
h1940_latch_control(H1940_LATCH_LED_RED, 0);
|
|
|
|
s3c2410_gpio_setpin(S3C2410_GPA1, 0);
|
|
|
|
break;
|
2007-02-13 02:09:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct led_classdev h1940_redled = {
|
|
|
|
.name = "h1940:red",
|
|
|
|
.brightness_set = h1940_redled_set,
|
|
|
|
.default_trigger = "h1940-charger",
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Blue led.
|
|
|
|
* (it can only be blue flashing led)
|
|
|
|
*/
|
2008-06-10 01:00:49 +04:00
|
|
|
static void h1940_blueled_set(struct led_classdev *led_dev,
|
|
|
|
enum led_brightness value)
|
2007-02-13 02:09:32 +03:00
|
|
|
{
|
|
|
|
if (value) {
|
|
|
|
/* flashing Blue */
|
2008-03-09 23:59:57 +03:00
|
|
|
h1940_latch_control(0, H1940_LATCH_LED_FLASH);
|
|
|
|
s3c2410_gpio_setpin(S3C2410_GPA3, 1);
|
2007-02-13 02:09:32 +03:00
|
|
|
} else {
|
2008-03-09 23:59:57 +03:00
|
|
|
h1940_latch_control(H1940_LATCH_LED_FLASH, 0);
|
|
|
|
s3c2410_gpio_setpin(S3C2410_GPA3, 0);
|
2007-02-13 02:09:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct led_classdev h1940_blueled = {
|
|
|
|
.name = "h1940:blue",
|
|
|
|
.brightness_set = h1940_blueled_set,
|
|
|
|
.default_trigger = "h1940-bluetooth",
|
|
|
|
};
|
|
|
|
|
2009-03-28 02:26:38 +03:00
|
|
|
static int __devinit h1940leds_probe(struct platform_device *pdev)
|
2007-02-13 02:09:32 +03:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = led_classdev_register(&pdev->dev, &h1940_greenled);
|
|
|
|
if (ret)
|
|
|
|
goto err_green;
|
|
|
|
|
|
|
|
ret = led_classdev_register(&pdev->dev, &h1940_redled);
|
|
|
|
if (ret)
|
|
|
|
goto err_red;
|
|
|
|
|
|
|
|
ret = led_classdev_register(&pdev->dev, &h1940_blueled);
|
|
|
|
if (ret)
|
|
|
|
goto err_blue;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_blue:
|
|
|
|
led_classdev_unregister(&h1940_redled);
|
|
|
|
err_red:
|
|
|
|
led_classdev_unregister(&h1940_greenled);
|
|
|
|
err_green:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int h1940leds_remove(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
led_classdev_unregister(&h1940_greenled);
|
|
|
|
led_classdev_unregister(&h1940_redled);
|
|
|
|
led_classdev_unregister(&h1940_blueled);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct platform_driver h1940leds_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "h1940-leds",
|
2008-04-16 01:34:30 +04:00
|
|
|
.owner = THIS_MODULE,
|
2007-02-13 02:09:32 +03:00
|
|
|
},
|
|
|
|
.probe = h1940leds_probe,
|
|
|
|
.remove = h1940leds_remove,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int __init h1940leds_init(void)
|
|
|
|
{
|
|
|
|
return platform_driver_register(&h1940leds_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit h1940leds_exit(void)
|
|
|
|
{
|
|
|
|
platform_driver_unregister(&h1940leds_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(h1940leds_init);
|
|
|
|
module_exit(h1940leds_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
|
|
|
|
MODULE_DESCRIPTION("LED driver for the iPAQ H1940");
|
|
|
|
MODULE_LICENSE("GPL");
|
2008-04-16 01:34:30 +04:00
|
|
|
MODULE_ALIAS("platform:h1940-leds");
|