2 * LEDs driver for Amstrad Delta (E3)
4 * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/leds.h>
15 #include <mach/board-ams-delta.h>
20 struct ams_delta_led {
21 struct led_classdev cdev;
25 static void ams_delta_led_set(struct led_classdev *led_cdev,
26 enum led_brightness value)
28 struct ams_delta_led *led_dev =
29 container_of(led_cdev, struct ams_delta_led, cdev);
32 ams_delta_latch1_write(led_dev->bitmask, led_dev->bitmask);
34 ams_delta_latch1_write(led_dev->bitmask, 0);
37 static struct ams_delta_led ams_delta_leds[] = {
40 .name = "ams-delta::camera",
41 .brightness_set = ams_delta_led_set,
43 .bitmask = AMS_DELTA_LATCH1_LED_CAMERA,
47 .name = "ams-delta::advert",
48 .brightness_set = ams_delta_led_set,
50 .bitmask = AMS_DELTA_LATCH1_LED_ADVERT,
54 .name = "ams-delta::email",
55 .brightness_set = ams_delta_led_set,
57 .bitmask = AMS_DELTA_LATCH1_LED_EMAIL,
61 .name = "ams-delta::handsfree",
62 .brightness_set = ams_delta_led_set,
64 .bitmask = AMS_DELTA_LATCH1_LED_HANDSFREE,
68 .name = "ams-delta::voicemail",
69 .brightness_set = ams_delta_led_set,
71 .bitmask = AMS_DELTA_LATCH1_LED_VOICEMAIL,
75 .name = "ams-delta::voice",
76 .brightness_set = ams_delta_led_set,
78 .bitmask = AMS_DELTA_LATCH1_LED_VOICE,
83 static int ams_delta_led_suspend(struct platform_device *dev,
88 for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++)
89 led_classdev_suspend(&ams_delta_leds[i].cdev);
94 static int ams_delta_led_resume(struct platform_device *dev)
98 for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++)
99 led_classdev_resume(&ams_delta_leds[i].cdev);
104 #define ams_delta_led_suspend NULL
105 #define ams_delta_led_resume NULL
108 static int ams_delta_led_probe(struct platform_device *pdev)
112 for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++) {
113 ret = led_classdev_register(&pdev->dev,
114 &ams_delta_leds[i].cdev);
122 led_classdev_unregister(&ams_delta_leds[i].cdev);
126 static int ams_delta_led_remove(struct platform_device *pdev)
130 for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i--)
131 led_classdev_unregister(&ams_delta_leds[i].cdev);
136 static struct platform_driver ams_delta_led_driver = {
137 .probe = ams_delta_led_probe,
138 .remove = ams_delta_led_remove,
139 .suspend = ams_delta_led_suspend,
140 .resume = ams_delta_led_resume,
142 .name = "ams-delta-led",
143 .owner = THIS_MODULE,
147 static int __init ams_delta_led_init(void)
149 return platform_driver_register(&ams_delta_led_driver);
152 static void __exit ams_delta_led_exit(void)
154 return platform_driver_unregister(&ams_delta_led_driver);
157 module_init(ams_delta_led_init);
158 module_exit(ams_delta_led_exit);
160 MODULE_AUTHOR("Jonathan McDowell <noodles@earth.li>");
161 MODULE_DESCRIPTION("Amstrad Delta LED driver");
162 MODULE_LICENSE("GPL");
163 MODULE_ALIAS("platform:ams-delta-led");