2006-06-23 17:05:33 +08:00
|
|
|
/*
|
|
|
|
* LEDs driver for Amstrad Delta (E3)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2011-08-26 06:59:15 +08:00
|
|
|
#include <linux/module.h>
|
2006-06-23 17:05:33 +08:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/leds.h>
|
2009-10-21 00:40:47 +08:00
|
|
|
#include <plat/board-ams-delta.h>
|
2006-06-23 17:05:33 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Our context
|
|
|
|
*/
|
|
|
|
struct ams_delta_led {
|
|
|
|
struct led_classdev cdev;
|
|
|
|
u8 bitmask;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void ams_delta_led_set(struct led_classdev *led_cdev,
|
|
|
|
enum led_brightness value)
|
|
|
|
{
|
|
|
|
struct ams_delta_led *led_dev =
|
|
|
|
container_of(led_cdev, struct ams_delta_led, cdev);
|
|
|
|
|
|
|
|
if (value)
|
|
|
|
ams_delta_latch1_write(led_dev->bitmask, led_dev->bitmask);
|
|
|
|
else
|
|
|
|
ams_delta_latch1_write(led_dev->bitmask, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ams_delta_led ams_delta_leds[] = {
|
|
|
|
{
|
|
|
|
.cdev = {
|
2007-10-31 22:00:07 +08:00
|
|
|
.name = "ams-delta::camera",
|
2006-06-23 17:05:33 +08:00
|
|
|
.brightness_set = ams_delta_led_set,
|
|
|
|
},
|
|
|
|
.bitmask = AMS_DELTA_LATCH1_LED_CAMERA,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.cdev = {
|
2007-10-31 22:00:07 +08:00
|
|
|
.name = "ams-delta::advert",
|
2006-06-23 17:05:33 +08:00
|
|
|
.brightness_set = ams_delta_led_set,
|
|
|
|
},
|
|
|
|
.bitmask = AMS_DELTA_LATCH1_LED_ADVERT,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.cdev = {
|
2007-10-31 22:00:07 +08:00
|
|
|
.name = "ams-delta::email",
|
2006-06-23 17:05:33 +08:00
|
|
|
.brightness_set = ams_delta_led_set,
|
|
|
|
},
|
|
|
|
.bitmask = AMS_DELTA_LATCH1_LED_EMAIL,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.cdev = {
|
2007-10-31 22:00:07 +08:00
|
|
|
.name = "ams-delta::handsfree",
|
2006-06-23 17:05:33 +08:00
|
|
|
.brightness_set = ams_delta_led_set,
|
|
|
|
},
|
|
|
|
.bitmask = AMS_DELTA_LATCH1_LED_HANDSFREE,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.cdev = {
|
2007-10-31 22:00:07 +08:00
|
|
|
.name = "ams-delta::voicemail",
|
2006-06-23 17:05:33 +08:00
|
|
|
.brightness_set = ams_delta_led_set,
|
|
|
|
},
|
|
|
|
.bitmask = AMS_DELTA_LATCH1_LED_VOICEMAIL,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.cdev = {
|
2007-10-31 22:00:07 +08:00
|
|
|
.name = "ams-delta::voice",
|
2006-06-23 17:05:33 +08:00
|
|
|
.brightness_set = ams_delta_led_set,
|
|
|
|
},
|
|
|
|
.bitmask = AMS_DELTA_LATCH1_LED_VOICE,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int ams_delta_led_probe(struct platform_device *pdev)
|
|
|
|
{
|
2008-10-21 06:46:15 +08:00
|
|
|
int i, ret;
|
2006-06-23 17:05:33 +08:00
|
|
|
|
2008-10-21 06:46:15 +08:00
|
|
|
for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++) {
|
2009-01-09 01:55:03 +08:00
|
|
|
ams_delta_leds[i].cdev.flags |= LED_CORE_SUSPENDRESUME;
|
2006-06-23 17:05:33 +08:00
|
|
|
ret = led_classdev_register(&pdev->dev,
|
|
|
|
&ams_delta_leds[i].cdev);
|
2008-10-21 06:46:15 +08:00
|
|
|
if (ret < 0)
|
|
|
|
goto fail;
|
2006-06-23 17:05:33 +08:00
|
|
|
}
|
|
|
|
|
2008-10-21 06:46:15 +08:00
|
|
|
return 0;
|
|
|
|
fail:
|
|
|
|
while (--i >= 0)
|
|
|
|
led_classdev_unregister(&ams_delta_leds[i].cdev);
|
|
|
|
return ret;
|
2006-06-23 17:05:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ams_delta_led_remove(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2008-12-03 16:11:17 +08:00
|
|
|
for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++)
|
2006-06-23 17:05:33 +08:00
|
|
|
led_classdev_unregister(&ams_delta_leds[i].cdev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver ams_delta_led_driver = {
|
|
|
|
.probe = ams_delta_led_probe,
|
|
|
|
.remove = ams_delta_led_remove,
|
|
|
|
.driver = {
|
|
|
|
.name = "ams-delta-led",
|
2008-04-16 05:34:30 +08:00
|
|
|
.owner = THIS_MODULE,
|
2006-06-23 17:05:33 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init ams_delta_led_init(void)
|
|
|
|
{
|
|
|
|
return platform_driver_register(&ams_delta_led_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit ams_delta_led_exit(void)
|
|
|
|
{
|
2008-12-03 16:06:42 +08:00
|
|
|
platform_driver_unregister(&ams_delta_led_driver);
|
2006-06-23 17:05:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(ams_delta_led_init);
|
|
|
|
module_exit(ams_delta_led_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Jonathan McDowell <noodles@earth.li>");
|
|
|
|
MODULE_DESCRIPTION("Amstrad Delta LED driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
2008-04-16 05:34:30 +08:00
|
|
|
MODULE_ALIAS("platform:ams-delta-led");
|