Blame view
drivers/leds/leds-clevo-mail.c
5.45 KB
cec035de8 leds: Add clevo n... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include <linux/module.h> #include <linux/platform_device.h> #include <linux/err.h> #include <linux/leds.h> #include <linux/io.h> #include <linux/dmi.h> #include <linux/i8042.h> #define CLEVO_MAIL_LED_OFF 0x0084 #define CLEVO_MAIL_LED_BLINK_1HZ 0x008A #define CLEVO_MAIL_LED_BLINK_0_5HZ 0x0083 |
4d404fd5c leds: Cleanup var... |
16 |
MODULE_AUTHOR("Márton Németh <nm127@freemail.hu>"); |
cec035de8 leds: Add clevo n... |
17 18 |
MODULE_DESCRIPTION("Clevo mail LED driver"); MODULE_LICENSE("GPL"); |
90ab5ee94 module_param: mak... |
19 |
static bool __initdata nodetect; |
cec035de8 leds: Add clevo n... |
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
module_param_named(nodetect, nodetect, bool, 0); MODULE_PARM_DESC(nodetect, "Skip DMI hardware detection"); static struct platform_device *pdev; static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id) { printk(KERN_INFO KBUILD_MODNAME ": '%s' found ", id->ident); return 1; } /* * struct mail_led_whitelist - List of known good models * * Contains the known good models this driver is compatible with. * When adding a new model try to be as strict as possible. This * makes it possible to keep the false positives (the model is * detected as working, but in reality it is not) as low as * possible. */ static struct dmi_system_id __initdata mail_led_whitelist[] = { { .callback = clevo_mail_led_dmi_callback, .ident = "Clevo D410J", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "VIA"), DMI_MATCH(DMI_PRODUCT_NAME, "K8N800"), DMI_MATCH(DMI_PRODUCT_VERSION, "VT8204B") } }, { .callback = clevo_mail_led_dmi_callback, .ident = "Clevo M5x0N", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."), DMI_MATCH(DMI_PRODUCT_NAME, "M5x0N") } }, { .callback = clevo_mail_led_dmi_callback, .ident = "Positivo Mobile", .matches = { DMI_MATCH(DMI_BOARD_VENDOR, "CLEVO Co. "), DMI_MATCH(DMI_BOARD_NAME, "M5X0V "), DMI_MATCH(DMI_PRODUCT_NAME, "Positivo Mobile"), DMI_MATCH(DMI_PRODUCT_VERSION, "VT6198") } }, { .callback = clevo_mail_led_dmi_callback, |
b3ba31f84 leds: Add mail LE... |
71 72 73 74 75 76 77 78 79 80 |
.ident = "Clevo D400P", .matches = { DMI_MATCH(DMI_BOARD_VENDOR, "Clevo"), DMI_MATCH(DMI_BOARD_NAME, "D400P"), DMI_MATCH(DMI_BOARD_VERSION, "Rev.A"), DMI_MATCH(DMI_PRODUCT_VERSION, "0106") } }, { .callback = clevo_mail_led_dmi_callback, |
cec035de8 leds: Add clevo n... |
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
.ident = "Clevo D410V", .matches = { DMI_MATCH(DMI_BOARD_VENDOR, "Clevo, Co."), DMI_MATCH(DMI_BOARD_NAME, "D400V/D470V"), DMI_MATCH(DMI_BOARD_VERSION, "SS78B"), DMI_MATCH(DMI_PRODUCT_VERSION, "Rev. A1") } }, { } }; static void clevo_mail_led_set(struct led_classdev *led_cdev, enum led_brightness value) { |
181d683d7 Input: libps2 - a... |
95 |
i8042_lock_chip(); |
cec035de8 leds: Add clevo n... |
96 97 98 99 100 101 |
if (value == LED_OFF) i8042_command(NULL, CLEVO_MAIL_LED_OFF); else if (value <= LED_HALF) i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ); else i8042_command(NULL, CLEVO_MAIL_LED_BLINK_1HZ); |
181d683d7 Input: libps2 - a... |
102 |
i8042_unlock_chip(); |
cec035de8 leds: Add clevo n... |
103 |
} |
92e015cb3 leds: hw accelera... |
104 |
static int clevo_mail_led_blink(struct led_classdev *led_cdev, |
4d404fd5c leds: Cleanup var... |
105 106 |
unsigned long *delay_on, unsigned long *delay_off) |
92e015cb3 leds: hw accelera... |
107 108 |
{ int status = -EINVAL; |
181d683d7 Input: libps2 - a... |
109 |
i8042_lock_chip(); |
92e015cb3 leds: hw accelera... |
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
if (*delay_on == 0 /* ms */ && *delay_off == 0 /* ms */) { /* Special case: the leds subsystem requested us to * chose one user friendly blinking of the LED, and * start it. Let's blink the led slowly (0.5Hz). */ *delay_on = 1000; /* ms */ *delay_off = 1000; /* ms */ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ); status = 0; } else if (*delay_on == 500 /* ms */ && *delay_off == 500 /* ms */) { /* blink the led with 1Hz */ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_1HZ); status = 0; } else if (*delay_on == 1000 /* ms */ && *delay_off == 1000 /* ms */) { /* blink the led with 0.5Hz */ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ); status = 0; } else { printk(KERN_DEBUG KBUILD_MODNAME ": clevo_mail_led_blink(..., %lu, %lu)," " returning -EINVAL (unsupported) ", *delay_on, *delay_off); } |
181d683d7 Input: libps2 - a... |
137 |
i8042_unlock_chip(); |
92e015cb3 leds: hw accelera... |
138 139 |
return status; } |
cec035de8 leds: Add clevo n... |
140 |
static struct led_classdev clevo_mail_led = { |
6c152beef leds: Standardise... |
141 |
.name = "clevo::mail", |
cec035de8 leds: Add clevo n... |
142 |
.brightness_set = clevo_mail_led_set, |
92e015cb3 leds: hw accelera... |
143 |
.blink_set = clevo_mail_led_blink, |
859cb7f2a leds: Add suspend... |
144 |
.flags = LED_CORE_SUSPENDRESUME, |
cec035de8 leds: Add clevo n... |
145 |
}; |
f16a5dba0 leds: move leds-c... |
146 |
static int __devinit clevo_mail_led_probe(struct platform_device *pdev) |
cec035de8 leds: Add clevo n... |
147 148 149 150 151 152 153 154 155 |
{ return led_classdev_register(&pdev->dev, &clevo_mail_led); } static int clevo_mail_led_remove(struct platform_device *pdev) { led_classdev_unregister(&clevo_mail_led); return 0; } |
cec035de8 leds: Add clevo n... |
156 157 158 |
static struct platform_driver clevo_mail_led_driver = { .probe = clevo_mail_led_probe, .remove = clevo_mail_led_remove, |
cec035de8 leds: Add clevo n... |
159 160 |
.driver = { .name = KBUILD_MODNAME, |
3c4ded971 leds: fix platfor... |
161 |
.owner = THIS_MODULE, |
cec035de8 leds: Add clevo n... |
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
}, }; static int __init clevo_mail_led_init(void) { int error = 0; int count = 0; /* Check with the help of DMI if we are running on supported hardware */ if (!nodetect) { count = dmi_check_system(mail_led_whitelist); } else { count = 1; printk(KERN_ERR KBUILD_MODNAME ": Skipping DMI detection. " "If the driver works on your hardware please " "report model and the output of dmidecode in tracker " "at http://sourceforge.net/projects/clevo-mailled/ "); } if (!count) return -ENODEV; pdev = platform_device_register_simple(KBUILD_MODNAME, -1, NULL, 0); if (!IS_ERR(pdev)) { error = platform_driver_probe(&clevo_mail_led_driver, clevo_mail_led_probe); if (error) { printk(KERN_ERR KBUILD_MODNAME ": Can't probe platform driver "); platform_device_unregister(pdev); } } else error = PTR_ERR(pdev); return error; } static void __exit clevo_mail_led_exit(void) { platform_device_unregister(pdev); platform_driver_unregister(&clevo_mail_led_driver); clevo_mail_led_set(NULL, LED_OFF); } module_init(clevo_mail_led_init); module_exit(clevo_mail_led_exit); |