14 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
16 #include <linux/module.h>
17 #include <linux/kernel.h>
28 #include <linux/slab.h>
31 #include "../../firmware/dcdbas.h"
33 #define BRIGHTNESS_TOKEN 0x7d
68 static struct quirk_entry quirk_dell_vostro_v130 = {
74 quirks = dmi->driver_data;
78 static int da_command_address;
79 static int da_command_code;
80 static int da_num_tokens;
85 .name =
"dell-laptop",
95 .ident =
"Dell laptop",
108 .ident =
"Dell Computer Corporation",
120 .callback = dmi_matched,
121 .ident =
"Dell Vostro V130",
126 .driver_data = &quirk_dell_vostro_v130,
129 .callback = dmi_matched,
130 .ident =
"Dell Vostro V131",
135 .driver_data = &quirk_dell_vostro_v130,
138 .callback = dmi_matched,
139 .ident =
"Dell Vostro 3350",
144 .driver_data = &quirk_dell_vostro_v130,
147 .callback = dmi_matched,
148 .ident =
"Dell Vostro 3555",
153 .driver_data = &quirk_dell_vostro_v130,
156 .callback = dmi_matched,
157 .ident =
"Dell Inspiron N311z",
162 .driver_data = &quirk_dell_vostro_v130,
165 .callback = dmi_matched,
166 .ident =
"Dell Inspiron M5110",
171 .driver_data = &quirk_dell_vostro_v130,
174 .callback = dmi_matched,
175 .ident =
"Dell Vostro 3360",
180 .driver_data = &quirk_dell_vostro_v130,
183 .callback = dmi_matched,
184 .ident =
"Dell Vostro 3460",
189 .driver_data = &quirk_dell_vostro_v130,
192 .callback = dmi_matched,
193 .ident =
"Dell Vostro 3560",
198 .driver_data = &quirk_dell_vostro_v130,
201 .callback = dmi_matched,
202 .ident =
"Dell Vostro 3450",
207 .driver_data = &quirk_dell_vostro_v130,
210 .callback = dmi_matched,
211 .ident =
"Dell Inspiron 5420",
216 .driver_data = &quirk_dell_vostro_v130,
219 .callback = dmi_matched,
220 .ident =
"Dell Inspiron 5520",
225 .driver_data = &quirk_dell_vostro_v130,
228 .callback = dmi_matched,
229 .ident =
"Dell Inspiron 5720",
234 .driver_data = &quirk_dell_vostro_v130,
237 .callback = dmi_matched,
238 .ident =
"Dell Inspiron 7420",
243 .driver_data = &quirk_dell_vostro_v130,
246 .callback = dmi_matched,
247 .ident =
"Dell Inspiron 7520",
252 .driver_data = &quirk_dell_vostro_v130,
255 .callback = dmi_matched,
256 .ident =
"Dell Inspiron 7720",
261 .driver_data = &quirk_dell_vostro_v130,
267 static struct page *bufferpage;
270 static int hwswitch_state;
272 static void get_buffer(
void)
278 static void release_buffer(
void)
299 da_tokens =
krealloc(da_tokens, (da_num_tokens + tokens) *
325 static int find_token_location(
int tokenid)
328 for (i = 0; i < da_num_tokens; i++) {
329 if (da_tokens[i].tokenID == tokenid)
343 command.command_address = da_command_address;
344 command.command_code = da_command_code;
348 buffer->
class =
class;
356 static struct dentry *dell_laptop_dir;
363 dell_send_request(buffer, 17, 11);
364 status = buffer->
output[1];
368 seq_printf(s,
"Bit 0 : Hardware switch supported: %lu\n",
370 seq_printf(s,
"Bit 1 : Wifi locator supported: %lu\n",
371 (status &
BIT(1)) >> 1);
372 seq_printf(s,
"Bit 2 : Wifi is supported: %lu\n",
373 (status &
BIT(2)) >> 2);
374 seq_printf(s,
"Bit 3 : Bluetooth is supported: %lu\n",
375 (status &
BIT(3)) >> 3);
376 seq_printf(s,
"Bit 4 : WWAN is supported: %lu\n",
377 (status &
BIT(4)) >> 4);
378 seq_printf(s,
"Bit 5 : Wireless keyboard supported: %lu\n",
379 (status &
BIT(5)) >> 5);
380 seq_printf(s,
"Bit 8 : Wifi is installed: %lu\n",
381 (status &
BIT(8)) >> 8);
382 seq_printf(s,
"Bit 9 : Bluetooth is installed: %lu\n",
383 (status &
BIT(9)) >> 9);
384 seq_printf(s,
"Bit 10: WWAN is installed: %lu\n",
385 (status &
BIT(10)) >> 10);
386 seq_printf(s,
"Bit 16: Hardware switch is on: %lu\n",
387 (status &
BIT(16)) >> 16);
388 seq_printf(s,
"Bit 17: Wifi is blocked: %lu\n",
389 (status &
BIT(17)) >> 17);
390 seq_printf(s,
"Bit 18: Bluetooth is blocked: %lu\n",
391 (status &
BIT(18)) >> 18);
392 seq_printf(s,
"Bit 19: WWAN is blocked: %lu\n",
393 (status &
BIT(19)) >> 19);
395 seq_printf(s,
"\nhwswitch_state:\t0x%X\n", hwswitch_state);
396 seq_printf(s,
"Bit 0 : Wifi controlled by switch: %lu\n",
397 hwswitch_state &
BIT(0));
398 seq_printf(s,
"Bit 1 : Bluetooth controlled by switch: %lu\n",
399 (hwswitch_state &
BIT(1)) >> 1);
400 seq_printf(s,
"Bit 2 : WWAN controlled by switch: %lu\n",
401 (hwswitch_state &
BIT(2)) >> 2);
402 seq_printf(s,
"Bit 7 : Wireless switch config locked: %lu\n",
403 (hwswitch_state &
BIT(7)) >> 7);
404 seq_printf(s,
"Bit 8 : Wifi locator enabled: %lu\n",
405 (hwswitch_state &
BIT(8)) >> 8);
406 seq_printf(s,
"Bit 15: Wifi locator setting locked: %lu\n",
407 (hwswitch_state &
BIT(15)) >> 15);
419 .open = dell_debugfs_open,
433 if (buffer->
input[0] == -1) {
439 dell_send_request(buffer, 1, 2);
441 dell_send_request(buffer, 1, 1);
455 if (buffer->
input[0] == -1) {
461 dell_send_request(buffer, 0, 2);
463 dell_send_request(buffer, 0, 1);
473 .get_brightness = dell_get_intensity,
474 .update_status = dell_send_intensity,
477 static void touchpad_led_on(
void)
484 static void touchpad_led_off(
void)
491 static void touchpad_led_set(
struct led_classdev *led_cdev,
501 .name =
"dell-laptop::touchpad",
502 .brightness_set = touchpad_led_set,
511 static void touchpad_led_exit(
void)
516 static int __init dell_init(
void)
518 int max_intensity = 0;
531 pr_info(
"Unable to find dmi tokens\n");
537 goto fail_platform_driver;
539 if (!platform_device) {
541 goto fail_platform_device1;
545 goto fail_platform_device2;
558 touchpad_led_init(&platform_device->
dev);
572 if (buffer->
input[0] != -1) {
573 dell_send_request(buffer, 0, 2);
574 max_intensity = buffer->
output[3];
582 props.max_brightness = max_intensity;
584 &platform_device->
dev,
589 if (IS_ERR(dell_backlight_device)) {
590 ret = PTR_ERR(dell_backlight_device);
591 dell_backlight_device =
NULL;
595 dell_backlight_device->
props.brightness =
596 dell_get_intensity(dell_backlight_device);
597 backlight_update_status(dell_backlight_device);
606 fail_platform_device2:
608 fail_platform_device1:
610 fail_platform_driver:
615 static void __exit dell_exit(
void)
621 if (platform_device) {