2 * Samsung Laptop driver
4 * Copyright (C) 2009,2011 Greg Kroah-Hartman (gregkh@suse.de)
5 * Copyright (C) 2009,2011 Novell Inc.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/delay.h>
18 #include <linux/pci.h>
19 #include <linux/backlight.h>
21 #include <linux/dmi.h>
22 #include <linux/platform_device.h>
23 #include <linux/rfkill.h>
24 #include <linux/acpi.h>
25 #include <linux/seq_file.h>
26 #include <linux/debugfs.h>
29 * This driver is needed because a number of Samsung laptops do not hook
30 * their control settings through ACPI. So we have to poke around in the
31 * BIOS to do things like brightness values, and "special" key controls.
35 * We have 0 - 8 as valid brightness levels. The specs say that level 0 should
36 * be reserved by the BIOS (which really doesn't make much sense), we tell
37 * userspace that the value is 0 - 7 and then just tell the hardware 1 - 8
39 #define MAX_BRIGHT 0x07
42 #define SABI_IFACE_MAIN 0x00
43 #define SABI_IFACE_SUB 0x02
44 #define SABI_IFACE_COMPLETE 0x04
45 #define SABI_IFACE_DATA 0x05
47 /* Structure get/set data using sabi */
60 struct sabi_header_offsets {
69 struct sabi_commands {
71 * Brightness is 0 - 8, as described above.
72 * Value 0 is for the BIOS to use
79 * 0x00 - wireless is off
80 * 0x01 - wireless is on
84 * TODO, verify 3G is correct, that doesn't seem right...
86 u16 get_wireless_button;
87 u16 set_wireless_button;
89 /* 0 is off, 1 is on */
94 * 0x80 or 0x00 - no action
95 * 0x81 - recovery key pressed
97 u16 get_recovery_mode;
98 u16 set_recovery_mode;
101 * on seclinux: 0 is low, 1 is high,
102 * on swsmi: 0 is normal, 1 is silent, 2 is turbo
104 u16 get_performance_level;
105 u16 set_performance_level;
107 /* 0x80 is off, 0x81 is on */
108 u16 get_battery_life_extender;
109 u16 set_battery_life_extender;
112 * Tell the BIOS that Linux is running on this machine.
113 * 81 is on, 80 is off
118 struct sabi_performance_level {
124 const char *test_string;
126 const struct sabi_header_offsets header_offsets;
127 const struct sabi_commands commands;
128 const struct sabi_performance_level performance_levels[4];
133 static const struct sabi_config sabi_configs[] = {
135 .test_string = "SECLINUX",
137 .main_function = 0x4c49,
145 .data_segment = 0x07,
149 .get_brightness = 0x00,
150 .set_brightness = 0x01,
152 .get_wireless_button = 0x02,
153 .set_wireless_button = 0x03,
155 .get_backlight = 0x04,
156 .set_backlight = 0x05,
158 .get_recovery_mode = 0x06,
159 .set_recovery_mode = 0x07,
161 .get_performance_level = 0x08,
162 .set_performance_level = 0x09,
164 .get_battery_life_extender = 0xFFFF,
165 .set_battery_life_extender = 0xFFFF,
170 .performance_levels = {
185 .test_string = "SwSmi@",
187 .main_function = 0x5843,
195 .data_segment = 0x07,
199 .get_brightness = 0x10,
200 .set_brightness = 0x11,
202 .get_wireless_button = 0x12,
203 .set_wireless_button = 0x13,
205 .get_backlight = 0x2d,
206 .set_backlight = 0x2e,
208 .get_recovery_mode = 0xff,
209 .set_recovery_mode = 0xff,
211 .get_performance_level = 0x31,
212 .set_performance_level = 0x32,
214 .get_battery_life_extender = 0x65,
215 .set_battery_life_extender = 0x66,
220 .performance_levels = {
242 * samsung-laptop/ - debugfs root directory
243 * f0000_segment - dump f0000 segment
244 * command - current command
245 * data - current data
246 * d0, d1, d2, d3 - data fields
247 * call - call SABI using command and data
249 * This allow to call arbitrary sabi commands wihout
250 * modifying the driver at all.
251 * For example, setting the keyboard backlight brightness to 5
253 * echo 0x78 > command
261 struct samsung_laptop_debug {
263 struct sabi_data data;
266 struct debugfs_blob_wrapper f0000_wrapper;
267 struct debugfs_blob_wrapper data_wrapper;
270 struct samsung_laptop {
271 const struct sabi_config *config;
274 void __iomem *sabi_iface;
275 void __iomem *f0000_segment;
277 struct mutex sabi_mutex;
279 struct platform_device *platform_device;
280 struct backlight_device *backlight_device;
283 struct samsung_laptop_debug debug;
285 bool handle_backlight;
286 bool has_stepping_quirk;
292 module_param(force, bool, 0);
293 MODULE_PARM_DESC(force,
294 "Disable the DMI check and forces the driver to be loaded");
297 module_param(debug, bool, S_IRUGO | S_IWUSR);
298 MODULE_PARM_DESC(debug, "Debug enabled or not");
300 static int sabi_command(struct samsung_laptop *samsung, u16 command,
301 struct sabi_data *in,
302 struct sabi_data *out)
304 const struct sabi_config *config = samsung->config;
306 u16 port = readw(samsung->sabi + config->header_offsets.port);
307 u8 complete, iface_data;
309 mutex_lock(&samsung->sabi_mutex);
313 pr_info("SABI 0x%04x {0x%08x, 0x%08x, 0x%04x, 0x%02x}",
314 command, in->d0, in->d1, in->d2, in->d3);
316 pr_info("SABI 0x%04x", command);
319 /* enable memory to be able to write to it */
320 outb(readb(samsung->sabi + config->header_offsets.en_mem), port);
322 /* write out the command */
323 writew(config->main_function, samsung->sabi_iface + SABI_IFACE_MAIN);
324 writew(command, samsung->sabi_iface + SABI_IFACE_SUB);
325 writeb(0, samsung->sabi_iface + SABI_IFACE_COMPLETE);
327 writel(in->d0, samsung->sabi_iface + SABI_IFACE_DATA);
328 writel(in->d1, samsung->sabi_iface + SABI_IFACE_DATA + 4);
329 writew(in->d2, samsung->sabi_iface + SABI_IFACE_DATA + 8);
330 writeb(in->d3, samsung->sabi_iface + SABI_IFACE_DATA + 10);
332 outb(readb(samsung->sabi + config->header_offsets.iface_func), port);
334 /* write protect memory to make it safe */
335 outb(readb(samsung->sabi + config->header_offsets.re_mem), port);
337 /* see if the command actually succeeded */
338 complete = readb(samsung->sabi_iface + SABI_IFACE_COMPLETE);
339 iface_data = readb(samsung->sabi_iface + SABI_IFACE_DATA);
340 if (complete != 0xaa || iface_data == 0xff) {
341 pr_warn("SABI command 0x%04x failed with"
342 " completion flag 0x%02x and interface data 0x%02x",
343 command, complete, iface_data);
349 out->d0 = readl(samsung->sabi_iface + SABI_IFACE_DATA);
350 out->d1 = readl(samsung->sabi_iface + SABI_IFACE_DATA + 4);
351 out->d2 = readw(samsung->sabi_iface + SABI_IFACE_DATA + 2);
352 out->d3 = readb(samsung->sabi_iface + SABI_IFACE_DATA + 1);
356 pr_info("SABI {0x%08x, 0x%08x, 0x%04x, 0x%02x}",
357 out->d0, out->d1, out->d2, out->d3);
361 mutex_unlock(&samsung->sabi_mutex);
365 /* simple wrappers usable with most commands */
366 static int sabi_set_commandb(struct samsung_laptop *samsung,
367 u16 command, u8 data)
369 struct sabi_data in = { .d0 = 0, .d1 = 0, .d2 = 0, .d3 = 0 };
372 return sabi_command(samsung, command, &in, NULL);
375 static int read_brightness(struct samsung_laptop *samsung)
377 const struct sabi_config *config = samsung->config;
378 const struct sabi_commands *commands = &samsung->config->commands;
379 struct sabi_data sretval;
380 int user_brightness = 0;
383 retval = sabi_command(samsung, commands->get_brightness,
388 user_brightness = sretval.data[0];
389 if (user_brightness > config->min_brightness)
390 user_brightness -= config->min_brightness;
394 return user_brightness;
397 static void set_brightness(struct samsung_laptop *samsung, u8 user_brightness)
399 const struct sabi_config *config = samsung->config;
400 const struct sabi_commands *commands = &samsung->config->commands;
401 u8 user_level = user_brightness + config->min_brightness;
403 if (samsung->has_stepping_quirk && user_level != 0) {
405 * short circuit if the specified level is what's already set
406 * to prevent the screen from flickering needlessly
408 if (user_brightness == read_brightness(samsung))
411 sabi_set_commandb(samsung, commands->set_brightness, 0);
414 sabi_set_commandb(samsung, commands->set_brightness, user_level);
417 static int get_brightness(struct backlight_device *bd)
419 struct samsung_laptop *samsung = bl_get_data(bd);
421 return read_brightness(samsung);
424 static void check_for_stepping_quirk(struct samsung_laptop *samsung)
428 int orig_level = read_brightness(samsung);
431 * Some laptops exhibit the strange behaviour of stepping toward
432 * (rather than setting) the brightness except when changing to/from
433 * brightness level 0. This behaviour is checked for here and worked
434 * around in set_brightness.
438 set_brightness(samsung, 1);
440 initial_level = read_brightness(samsung);
442 if (initial_level <= 2)
443 check_level = initial_level + 2;
445 check_level = initial_level - 2;
447 samsung->has_stepping_quirk = false;
448 set_brightness(samsung, check_level);
450 if (read_brightness(samsung) != check_level) {
451 samsung->has_stepping_quirk = true;
452 pr_info("enabled workaround for brightness stepping quirk\n");
455 set_brightness(samsung, orig_level);
458 static int update_status(struct backlight_device *bd)
460 struct samsung_laptop *samsung = bl_get_data(bd);
461 const struct sabi_commands *commands = &samsung->config->commands;
463 set_brightness(samsung, bd->props.brightness);
465 if (bd->props.power == FB_BLANK_UNBLANK)
466 sabi_set_commandb(samsung, commands->set_backlight, 1);
468 sabi_set_commandb(samsung, commands->set_backlight, 0);
473 static const struct backlight_ops backlight_ops = {
474 .get_brightness = get_brightness,
475 .update_status = update_status,
478 static int rfkill_set(void *data, bool blocked)
480 struct samsung_laptop *samsung = data;
481 const struct sabi_commands *commands = &samsung->config->commands;
483 /* Do something with blocked...*/
485 * blocked == false is on
486 * blocked == true is off
489 sabi_set_commandb(samsung, commands->set_wireless_button, 0);
491 sabi_set_commandb(samsung, commands->set_wireless_button, 1);
496 static struct rfkill_ops rfkill_ops = {
497 .set_block = rfkill_set,
500 static ssize_t get_performance_level(struct device *dev,
501 struct device_attribute *attr, char *buf)
503 struct samsung_laptop *samsung = dev_get_drvdata(dev);
504 const struct sabi_config *config = samsung->config;
505 const struct sabi_commands *commands = &config->commands;
506 struct sabi_data sretval;
511 retval = sabi_command(samsung, commands->get_performance_level,
516 /* The logic is backwards, yeah, lots of fun... */
517 for (i = 0; config->performance_levels[i].name; ++i) {
518 if (sretval.data[0] == config->performance_levels[i].value)
519 return sprintf(buf, "%s\n", config->performance_levels[i].name);
521 return sprintf(buf, "%s\n", "unknown");
524 static ssize_t set_performance_level(struct device *dev,
525 struct device_attribute *attr, const char *buf,
528 struct samsung_laptop *samsung = dev_get_drvdata(dev);
529 const struct sabi_config *config = samsung->config;
530 const struct sabi_commands *commands = &config->commands;
536 for (i = 0; config->performance_levels[i].name; ++i) {
537 const struct sabi_performance_level *level =
538 &config->performance_levels[i];
539 if (!strncasecmp(level->name, buf, strlen(level->name))) {
540 sabi_set_commandb(samsung,
541 commands->set_performance_level,
547 if (!config->performance_levels[i].name)
553 static DEVICE_ATTR(performance_level, S_IWUSR | S_IRUGO,
554 get_performance_level, set_performance_level);
556 static int read_battery_life_extender(struct samsung_laptop *samsung)
558 const struct sabi_commands *commands = &samsung->config->commands;
559 struct sabi_data data;
562 if (commands->get_battery_life_extender == 0xFFFF)
565 memset(&data, 0, sizeof(data));
567 retval = sabi_command(samsung, commands->get_battery_life_extender,
573 if (data.data[0] != 0 && data.data[0] != 1)
579 static int write_battery_life_extender(struct samsung_laptop *samsung,
582 const struct sabi_commands *commands = &samsung->config->commands;
583 struct sabi_data data;
585 memset(&data, 0, sizeof(data));
586 data.data[0] = 0x80 | enabled;
587 return sabi_command(samsung, commands->set_battery_life_extender,
591 static ssize_t get_battery_life_extender(struct device *dev,
592 struct device_attribute *attr,
595 struct samsung_laptop *samsung = dev_get_drvdata(dev);
598 ret = read_battery_life_extender(samsung);
602 return sprintf(buf, "%d\n", ret);
605 static ssize_t set_battery_life_extender(struct device *dev,
606 struct device_attribute *attr,
607 const char *buf, size_t count)
609 struct samsung_laptop *samsung = dev_get_drvdata(dev);
612 if (!count || sscanf(buf, "%i", &value) != 1)
615 ret = write_battery_life_extender(samsung, !!value);
622 static DEVICE_ATTR(battery_life_extender, S_IWUSR | S_IRUGO,
623 get_battery_life_extender, set_battery_life_extender);
625 static struct attribute *platform_attributes[] = {
626 &dev_attr_performance_level.attr,
627 &dev_attr_battery_life_extender.attr,
631 static int find_signature(void __iomem *memcheck, const char *testStr)
636 for (loca = 0; loca < 0xffff; loca++) {
637 char temp = readb(memcheck + loca);
639 if (temp == testStr[i]) {
640 if (i == strlen(testStr)-1)
650 static void samsung_rfkill_exit(struct samsung_laptop *samsung)
653 rfkill_unregister(samsung->rfk);
654 rfkill_destroy(samsung->rfk);
659 static int __init samsung_rfkill_init(struct samsung_laptop *samsung)
663 samsung->rfk = rfkill_alloc("samsung-wifi",
664 &samsung->platform_device->dev,
666 &rfkill_ops, samsung);
670 retval = rfkill_register(samsung->rfk);
672 rfkill_destroy(samsung->rfk);
680 static void samsung_backlight_exit(struct samsung_laptop *samsung)
682 if (samsung->backlight_device) {
683 backlight_device_unregister(samsung->backlight_device);
684 samsung->backlight_device = NULL;
688 static int __init samsung_backlight_init(struct samsung_laptop *samsung)
690 struct backlight_device *bd;
691 struct backlight_properties props;
693 if (!samsung->handle_backlight)
696 memset(&props, 0, sizeof(struct backlight_properties));
697 props.type = BACKLIGHT_PLATFORM;
698 props.max_brightness = samsung->config->max_brightness -
699 samsung->config->min_brightness;
701 bd = backlight_device_register("samsung",
702 &samsung->platform_device->dev,
703 samsung, &backlight_ops,
708 samsung->backlight_device = bd;
709 samsung->backlight_device->props.brightness = read_brightness(samsung);
710 samsung->backlight_device->props.power = FB_BLANK_UNBLANK;
711 backlight_update_status(samsung->backlight_device);
716 static mode_t samsung_sysfs_is_visible(struct kobject *kobj,
717 struct attribute *attr, int idx)
719 struct device *dev = container_of(kobj, struct device, kobj);
720 struct platform_device *pdev = to_platform_device(dev);
721 struct samsung_laptop *samsung = platform_get_drvdata(pdev);
724 if (attr == &dev_attr_performance_level.attr)
725 ok = !!samsung->config->performance_levels[0].name;
726 if (attr == &dev_attr_battery_life_extender.attr)
727 ok = !!(read_battery_life_extender(samsung) >= 0);
729 return ok ? attr->mode : 0;
732 static struct attribute_group platform_attribute_group = {
733 .is_visible = samsung_sysfs_is_visible,
734 .attrs = platform_attributes
737 static void samsung_sysfs_exit(struct samsung_laptop *samsung)
739 struct platform_device *device = samsung->platform_device;
741 sysfs_remove_group(&device->dev.kobj, &platform_attribute_group);
744 static int __init samsung_sysfs_init(struct samsung_laptop *samsung)
746 struct platform_device *device = samsung->platform_device;
748 return sysfs_create_group(&device->dev.kobj, &platform_attribute_group);
752 static int show_call(struct seq_file *m, void *data)
754 struct samsung_laptop *samsung = m->private;
755 struct sabi_data *sdata = &samsung->debug.data;
758 seq_printf(m, "SABI 0x%04x {0x%08x, 0x%08x, 0x%04x, 0x%02x}\n",
759 samsung->debug.command,
760 sdata->d0, sdata->d1, sdata->d2, sdata->d3);
762 ret = sabi_command(samsung, samsung->debug.command, sdata, sdata);
765 seq_printf(m, "SABI command 0x%04x failed\n",
766 samsung->debug.command);
770 seq_printf(m, "SABI {0x%08x, 0x%08x, 0x%04x, 0x%02x}\n",
771 sdata->d0, sdata->d1, sdata->d2, sdata->d3);
775 static int samsung_debugfs_open(struct inode *inode, struct file *file)
777 return single_open(file, show_call, inode->i_private);
780 static const struct file_operations samsung_laptop_call_io_ops = {
781 .owner = THIS_MODULE,
782 .open = samsung_debugfs_open,
785 .release = single_release,
788 static void samsung_debugfs_exit(struct samsung_laptop *samsung)
790 debugfs_remove_recursive(samsung->debug.root);
793 static int samsung_debugfs_init(struct samsung_laptop *samsung)
797 samsung->debug.root = debugfs_create_dir("samsung-laptop", NULL);
798 if (!samsung->debug.root) {
799 pr_err("failed to create debugfs directory");
803 samsung->debug.f0000_wrapper.data = samsung->f0000_segment;
804 samsung->debug.f0000_wrapper.size = 0xffff;
806 samsung->debug.data_wrapper.data = &samsung->debug.data;
807 samsung->debug.data_wrapper.size = sizeof(samsung->debug.data);
809 dent = debugfs_create_u16("command", S_IRUGO | S_IWUSR,
810 samsung->debug.root, &samsung->debug.command);
814 dent = debugfs_create_u32("d0", S_IRUGO | S_IWUSR, samsung->debug.root,
815 &samsung->debug.data.d0);
819 dent = debugfs_create_u32("d1", S_IRUGO | S_IWUSR, samsung->debug.root,
820 &samsung->debug.data.d1);
824 dent = debugfs_create_u16("d2", S_IRUGO | S_IWUSR, samsung->debug.root,
825 &samsung->debug.data.d2);
829 dent = debugfs_create_u8("d3", S_IRUGO | S_IWUSR, samsung->debug.root,
830 &samsung->debug.data.d3);
834 dent = debugfs_create_blob("data", S_IRUGO | S_IWUSR,
836 &samsung->debug.data_wrapper);
840 dent = debugfs_create_blob("f0000_segment", S_IRUSR | S_IWUSR,
842 &samsung->debug.f0000_wrapper);
846 dent = debugfs_create_file("call", S_IFREG | S_IRUGO,
847 samsung->debug.root, samsung,
848 &samsung_laptop_call_io_ops);
855 samsung_debugfs_exit(samsung);
859 static void samsung_sabi_exit(struct samsung_laptop *samsung)
861 const struct sabi_config *config = samsung->config;
863 /* Turn off "Linux" mode in the BIOS */
864 if (config && config->commands.set_linux != 0xff)
865 sabi_set_commandb(samsung, config->commands.set_linux, 0x80);
867 if (samsung->sabi_iface) {
868 iounmap(samsung->sabi_iface);
869 samsung->sabi_iface = NULL;
871 if (samsung->f0000_segment) {
872 iounmap(samsung->f0000_segment);
873 samsung->f0000_segment = NULL;
876 samsung->config = NULL;
879 static __init void samsung_sabi_infos(struct samsung_laptop *samsung, int loca,
882 const struct sabi_config *config = samsung->config;
884 printk(KERN_DEBUG "This computer supports SABI==%x\n",
887 printk(KERN_DEBUG "SABI header:\n");
888 printk(KERN_DEBUG " SMI Port Number = 0x%04x\n",
889 readw(samsung->sabi + config->header_offsets.port));
890 printk(KERN_DEBUG " SMI Interface Function = 0x%02x\n",
891 readb(samsung->sabi + config->header_offsets.iface_func));
892 printk(KERN_DEBUG " SMI enable memory buffer = 0x%02x\n",
893 readb(samsung->sabi + config->header_offsets.en_mem));
894 printk(KERN_DEBUG " SMI restore memory buffer = 0x%02x\n",
895 readb(samsung->sabi + config->header_offsets.re_mem));
896 printk(KERN_DEBUG " SABI data offset = 0x%04x\n",
897 readw(samsung->sabi + config->header_offsets.data_offset));
898 printk(KERN_DEBUG " SABI data segment = 0x%04x\n",
899 readw(samsung->sabi + config->header_offsets.data_segment));
901 printk(KERN_DEBUG " SABI pointer = 0x%08x\n", ifaceP);
904 static int __init samsung_sabi_init(struct samsung_laptop *samsung)
906 const struct sabi_config *config = NULL;
907 const struct sabi_commands *commands;
913 samsung->f0000_segment = ioremap_nocache(0xf0000, 0xffff);
914 if (!samsung->f0000_segment) {
915 pr_err("Can't map the segment at 0xf0000\n");
920 /* Try to find one of the signatures in memory to find the header */
921 for (i = 0; sabi_configs[i].test_string != 0; ++i) {
922 samsung->config = &sabi_configs[i];
923 loca = find_signature(samsung->f0000_segment,
924 samsung->config->test_string);
929 if (loca == 0xffff) {
930 pr_err("This computer does not support SABI\n");
935 config = samsung->config;
936 commands = &config->commands;
938 /* point to the SMI port Number */
940 samsung->sabi = (samsung->f0000_segment + loca);
942 /* Get a pointer to the SABI Interface */
943 ifaceP = (readw(samsung->sabi + config->header_offsets.data_segment) & 0x0ffff) << 4;
944 ifaceP += readw(samsung->sabi + config->header_offsets.data_offset) & 0x0ffff;
947 samsung_sabi_infos(samsung, loca, ifaceP);
949 samsung->sabi_iface = ioremap_nocache(ifaceP, 16);
950 if (!samsung->sabi_iface) {
951 pr_err("Can't remap %x\n", ifaceP);
956 /* Turn on "Linux" mode in the BIOS */
957 if (commands->set_linux != 0xff) {
958 int retval = sabi_set_commandb(samsung,
959 commands->set_linux, 0x81);
961 pr_warn("Linux mode was not set!\n");
967 /* Check for stepping quirk */
968 if (samsung->handle_backlight)
969 check_for_stepping_quirk(samsung);
973 samsung_sabi_exit(samsung);
978 static void samsung_platform_exit(struct samsung_laptop *samsung)
980 if (samsung->platform_device) {
981 platform_device_unregister(samsung->platform_device);
982 samsung->platform_device = NULL;
986 static int __init samsung_platform_init(struct samsung_laptop *samsung)
988 struct platform_device *pdev;
990 pdev = platform_device_register_simple("samsung", -1, NULL, 0);
992 return PTR_ERR(pdev);
994 samsung->platform_device = pdev;
995 platform_set_drvdata(samsung->platform_device, samsung);
999 static int __init dmi_check_cb(const struct dmi_system_id *id)
1001 pr_info("found laptop model '%s'\n", id->ident);
1005 static struct dmi_system_id __initdata samsung_dmi_table[] = {
1009 DMI_MATCH(DMI_SYS_VENDOR,
1010 "SAMSUNG ELECTRONICS CO., LTD."),
1011 DMI_MATCH(DMI_PRODUCT_NAME, "N128"),
1012 DMI_MATCH(DMI_BOARD_NAME, "N128"),
1014 .callback = dmi_check_cb,
1019 DMI_MATCH(DMI_SYS_VENDOR,
1020 "SAMSUNG ELECTRONICS CO., LTD."),
1021 DMI_MATCH(DMI_PRODUCT_NAME, "N130"),
1022 DMI_MATCH(DMI_BOARD_NAME, "N130"),
1024 .callback = dmi_check_cb,
1029 DMI_MATCH(DMI_SYS_VENDOR,
1030 "SAMSUNG ELECTRONICS CO., LTD."),
1031 DMI_MATCH(DMI_PRODUCT_NAME, "N510"),
1032 DMI_MATCH(DMI_BOARD_NAME, "N510"),
1034 .callback = dmi_check_cb,
1039 DMI_MATCH(DMI_SYS_VENDOR,
1040 "SAMSUNG ELECTRONICS CO., LTD."),
1041 DMI_MATCH(DMI_PRODUCT_NAME, "X125"),
1042 DMI_MATCH(DMI_BOARD_NAME, "X125"),
1044 .callback = dmi_check_cb,
1047 .ident = "X120/X170",
1049 DMI_MATCH(DMI_SYS_VENDOR,
1050 "SAMSUNG ELECTRONICS CO., LTD."),
1051 DMI_MATCH(DMI_PRODUCT_NAME, "X120/X170"),
1052 DMI_MATCH(DMI_BOARD_NAME, "X120/X170"),
1054 .callback = dmi_check_cb,
1059 DMI_MATCH(DMI_SYS_VENDOR,
1060 "SAMSUNG ELECTRONICS CO., LTD."),
1061 DMI_MATCH(DMI_PRODUCT_NAME, "NC10"),
1062 DMI_MATCH(DMI_BOARD_NAME, "NC10"),
1064 .callback = dmi_check_cb,
1069 DMI_MATCH(DMI_SYS_VENDOR,
1070 "SAMSUNG ELECTRONICS CO., LTD."),
1071 DMI_MATCH(DMI_PRODUCT_NAME, "SQ45S70S"),
1072 DMI_MATCH(DMI_BOARD_NAME, "SQ45S70S"),
1074 .callback = dmi_check_cb,
1079 DMI_MATCH(DMI_SYS_VENDOR,
1080 "SAMSUNG ELECTRONICS CO., LTD."),
1081 DMI_MATCH(DMI_PRODUCT_NAME, "X360"),
1082 DMI_MATCH(DMI_BOARD_NAME, "X360"),
1084 .callback = dmi_check_cb,
1087 .ident = "R410 Plus",
1089 DMI_MATCH(DMI_SYS_VENDOR,
1090 "SAMSUNG ELECTRONICS CO., LTD."),
1091 DMI_MATCH(DMI_PRODUCT_NAME, "R410P"),
1092 DMI_MATCH(DMI_BOARD_NAME, "R460"),
1094 .callback = dmi_check_cb,
1099 DMI_MATCH(DMI_SYS_VENDOR,
1100 "SAMSUNG ELECTRONICS CO., LTD."),
1101 DMI_MATCH(DMI_PRODUCT_NAME, "R518"),
1102 DMI_MATCH(DMI_BOARD_NAME, "R518"),
1104 .callback = dmi_check_cb,
1107 .ident = "R519/R719",
1109 DMI_MATCH(DMI_SYS_VENDOR,
1110 "SAMSUNG ELECTRONICS CO., LTD."),
1111 DMI_MATCH(DMI_PRODUCT_NAME, "R519/R719"),
1112 DMI_MATCH(DMI_BOARD_NAME, "R519/R719"),
1114 .callback = dmi_check_cb,
1117 .ident = "N150/N210/N220",
1119 DMI_MATCH(DMI_SYS_VENDOR,
1120 "SAMSUNG ELECTRONICS CO., LTD."),
1121 DMI_MATCH(DMI_PRODUCT_NAME, "N150/N210/N220"),
1122 DMI_MATCH(DMI_BOARD_NAME, "N150/N210/N220"),
1124 .callback = dmi_check_cb,
1129 DMI_MATCH(DMI_SYS_VENDOR,
1130 "SAMSUNG ELECTRONICS CO., LTD."),
1131 DMI_MATCH(DMI_PRODUCT_NAME, "N220"),
1132 DMI_MATCH(DMI_BOARD_NAME, "N220"),
1134 .callback = dmi_check_cb,
1137 .ident = "N150/N210/N220/N230",
1139 DMI_MATCH(DMI_SYS_VENDOR,
1140 "SAMSUNG ELECTRONICS CO., LTD."),
1141 DMI_MATCH(DMI_PRODUCT_NAME, "N150/N210/N220/N230"),
1142 DMI_MATCH(DMI_BOARD_NAME, "N150/N210/N220/N230"),
1144 .callback = dmi_check_cb,
1147 .ident = "N150P/N210P/N220P",
1149 DMI_MATCH(DMI_SYS_VENDOR,
1150 "SAMSUNG ELECTRONICS CO., LTD."),
1151 DMI_MATCH(DMI_PRODUCT_NAME, "N150P/N210P/N220P"),
1152 DMI_MATCH(DMI_BOARD_NAME, "N150P/N210P/N220P"),
1154 .callback = dmi_check_cb,
1159 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1160 DMI_MATCH(DMI_PRODUCT_NAME, "SR700"),
1161 DMI_MATCH(DMI_BOARD_NAME, "SR700"),
1163 .callback = dmi_check_cb,
1166 .ident = "R530/R730",
1168 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1169 DMI_MATCH(DMI_PRODUCT_NAME, "R530/R730"),
1170 DMI_MATCH(DMI_BOARD_NAME, "R530/R730"),
1172 .callback = dmi_check_cb,
1175 .ident = "NF110/NF210/NF310",
1177 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1178 DMI_MATCH(DMI_PRODUCT_NAME, "NF110/NF210/NF310"),
1179 DMI_MATCH(DMI_BOARD_NAME, "NF110/NF210/NF310"),
1181 .callback = dmi_check_cb,
1184 .ident = "N145P/N250P/N260P",
1186 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1187 DMI_MATCH(DMI_PRODUCT_NAME, "N145P/N250P/N260P"),
1188 DMI_MATCH(DMI_BOARD_NAME, "N145P/N250P/N260P"),
1190 .callback = dmi_check_cb,
1195 DMI_MATCH(DMI_SYS_VENDOR,
1196 "SAMSUNG ELECTRONICS CO., LTD."),
1197 DMI_MATCH(DMI_PRODUCT_NAME, "R70/R71"),
1198 DMI_MATCH(DMI_BOARD_NAME, "R70/R71"),
1200 .callback = dmi_check_cb,
1205 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1206 DMI_MATCH(DMI_PRODUCT_NAME, "P460"),
1207 DMI_MATCH(DMI_BOARD_NAME, "P460"),
1209 .callback = dmi_check_cb,
1212 .ident = "R528/R728",
1214 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1215 DMI_MATCH(DMI_PRODUCT_NAME, "R528/R728"),
1216 DMI_MATCH(DMI_BOARD_NAME, "R528/R728"),
1218 .callback = dmi_check_cb,
1221 .ident = "NC210/NC110",
1223 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1224 DMI_MATCH(DMI_PRODUCT_NAME, "NC210/NC110"),
1225 DMI_MATCH(DMI_BOARD_NAME, "NC210/NC110"),
1227 .callback = dmi_check_cb,
1232 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1233 DMI_MATCH(DMI_PRODUCT_NAME, "X520"),
1234 DMI_MATCH(DMI_BOARD_NAME, "X520"),
1236 .callback = dmi_check_cb,
1240 MODULE_DEVICE_TABLE(dmi, samsung_dmi_table);
1242 static struct platform_device *samsung_platform_device;
1244 static int __init samsung_init(void)
1246 struct samsung_laptop *samsung;
1249 if (!force && !dmi_check_system(samsung_dmi_table))
1252 samsung = kzalloc(sizeof(*samsung), GFP_KERNEL);
1256 mutex_init(&samsung->sabi_mutex);
1257 samsung->handle_backlight = true;
1260 /* Don't handle backlight here if the acpi video already handle it */
1261 if (acpi_video_backlight_support()) {
1262 pr_info("Backlight controlled by ACPI video driver\n");
1263 samsung->handle_backlight = false;
1267 ret = samsung_platform_init(samsung);
1269 goto error_platform;
1271 ret = samsung_sabi_init(samsung);
1275 ret = samsung_sysfs_init(samsung);
1279 ret = samsung_backlight_init(samsung);
1281 goto error_backlight;
1283 ret = samsung_rfkill_init(samsung);
1287 ret = samsung_debugfs_init(samsung);
1291 samsung_platform_device = samsung->platform_device;
1295 samsung_rfkill_exit(samsung);
1297 samsung_backlight_exit(samsung);
1299 samsung_sysfs_exit(samsung);
1301 samsung_sabi_exit(samsung);
1303 samsung_platform_exit(samsung);
1309 static void __exit samsung_exit(void)
1311 struct samsung_laptop *samsung;
1313 samsung = platform_get_drvdata(samsung_platform_device);
1315 samsung_debugfs_exit(samsung);
1316 samsung_rfkill_exit(samsung);
1317 samsung_backlight_exit(samsung);
1318 samsung_sysfs_exit(samsung);
1319 samsung_sabi_exit(samsung);
1320 samsung_platform_exit(samsung);
1323 samsung_platform_device = NULL;
1326 module_init(samsung_init);
1327 module_exit(samsung_exit);
1329 MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@suse.de>");
1330 MODULE_DESCRIPTION("Samsung Backlight driver");
1331 MODULE_LICENSE("GPL");