2 * LEDs driver for PCEngines ALIX 2/3 series
4 * Copyright (C) 2007 Petr Liebman
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/leds.h>
17 #include <linux/err.h>
20 #define DRVNAME "alix-led"
22 #define ALIX_LED1_PORT (0x6100)
23 #define ALIX_LED1_ON (1<<22)
24 #define ALIX_LED1_OFF (1<<6)
26 #define ALIX_LED2_PORT (0x6180)
27 #define ALIX_LED2_ON (1<<25)
28 #define ALIX_LED2_OFF (1<<9)
30 #define ALIX_LED3_PORT (0x6180)
31 #define ALIX_LED3_ON (1<<27)
32 #define ALIX_LED3_OFF (1<<11)
35 static struct platform_device
*pdev
;
37 static void alix_led_set_1(struct led_classdev
*led_cdev
,
38 enum led_brightness value
)
41 outl(ALIX_LED1_ON
, ALIX_LED1_PORT
);
43 outl(ALIX_LED1_OFF
, ALIX_LED1_PORT
);
46 static void alix_led_set_2(struct led_classdev
*led_cdev
,
47 enum led_brightness value
)
50 outl(ALIX_LED2_ON
, ALIX_LED2_PORT
);
52 outl(ALIX_LED2_OFF
, ALIX_LED2_PORT
);
55 static void alix_led_set_3(struct led_classdev
*led_cdev
,
56 enum led_brightness value
)
59 outl(ALIX_LED3_ON
, ALIX_LED3_PORT
);
61 outl(ALIX_LED3_OFF
, ALIX_LED3_PORT
);
64 static struct led_classdev alix_led_1
= {
66 .brightness_set
= alix_led_set_1
,
69 static struct led_classdev alix_led_2
= {
71 .brightness_set
= alix_led_set_2
,
74 static struct led_classdev alix_led_3
= {
76 .brightness_set
= alix_led_set_3
,
81 static int alix_led_suspend(struct platform_device
*dev
,
84 led_classdev_suspend(&alix_led_1
);
85 led_classdev_suspend(&alix_led_2
);
86 led_classdev_suspend(&alix_led_3
);
90 static int alix_led_resume(struct platform_device
*dev
)
92 led_classdev_resume(&alix_led_1
);
93 led_classdev_resume(&alix_led_2
);
94 led_classdev_resume(&alix_led_3
);
98 #define alix_led_suspend NULL
99 #define alix_led_resume NULL
102 static int alix_led_probe(struct platform_device
*pdev
)
106 ret
= led_classdev_register(&pdev
->dev
, &alix_led_1
);
109 ret
= led_classdev_register(&pdev
->dev
, &alix_led_2
);
112 ret
= led_classdev_register(&pdev
->dev
, &alix_led_3
);
114 led_classdev_unregister(&alix_led_2
);
117 led_classdev_unregister(&alix_led_1
);
122 static int alix_led_remove(struct platform_device
*pdev
)
124 led_classdev_unregister(&alix_led_1
);
125 led_classdev_unregister(&alix_led_2
);
126 led_classdev_unregister(&alix_led_3
);
130 static struct platform_driver alix_led_driver
= {
131 .probe
= alix_led_probe
,
132 .remove
= alix_led_remove
,
133 .suspend
= alix_led_suspend
,
134 .resume
= alix_led_resume
,
137 .owner
= THIS_MODULE
,
141 static int __init
alix_led_init(void)
145 ret
= platform_driver_register(&alix_led_driver
);
149 pdev
= platform_device_register_simple(DRVNAME
, -1, NULL
, 0);
152 platform_driver_unregister(&alix_led_driver
);
160 static void __exit
alix_led_exit(void)
162 platform_device_unregister(pdev
);
163 platform_driver_unregister(&alix_led_driver
);
166 module_init(alix_led_init
);
167 module_exit(alix_led_exit
);
169 MODULE_AUTHOR("Petr Liebman");
170 MODULE_DESCRIPTION("PCEngines ALIX LED driver");
171 MODULE_LICENSE("GPL");