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>
26 * This driver is needed because a number of Samsung laptops do not hook
27 * their control settings through ACPI. So we have to poke around in the
28 * BIOS to do things like brightness values, and "special" key controls.
32 * We have 0 - 8 as valid brightness levels. The specs say that level 0 should
33 * be reserved by the BIOS (which really doesn't make much sense), we tell
34 * userspace that the value is 0 - 7 and then just tell the hardware 1 - 8
36 #define MAX_BRIGHT 0x07
39 #define SABI_IFACE_MAIN 0x00
40 #define SABI_IFACE_SUB 0x02
41 #define SABI_IFACE_COMPLETE 0x04
42 #define SABI_IFACE_DATA 0x05
44 /* Structure to get data back to the calling function */
49 struct sabi_header_offsets {
58 struct sabi_commands {
60 * Brightness is 0 - 8, as described above.
61 * Value 0 is for the BIOS to use
68 * 0x00 - wireless is off
69 * 0x01 - wireless is on
73 * TODO, verify 3G is correct, that doesn't seem right...
75 u8 get_wireless_button;
76 u8 set_wireless_button;
78 /* 0 is off, 1 is on */
83 * 0x80 or 0x00 - no action
84 * 0x81 - recovery key pressed
90 * on seclinux: 0 is low, 1 is high,
91 * on swsmi: 0 is normal, 1 is silent, 2 is turbo
93 u8 get_performance_level;
94 u8 set_performance_level;
97 * Tell the BIOS that Linux is running on this machine.
103 struct sabi_performance_level {
109 const char *test_string;
111 const struct sabi_header_offsets header_offsets;
112 const struct sabi_commands commands;
113 const struct sabi_performance_level performance_levels[4];
118 static const struct sabi_config sabi_configs[] = {
120 .test_string = "SECLINUX",
122 .main_function = 0x4c49,
130 .data_segment = 0x07,
134 .get_brightness = 0x00,
135 .set_brightness = 0x01,
137 .get_wireless_button = 0x02,
138 .set_wireless_button = 0x03,
140 .get_backlight = 0x04,
141 .set_backlight = 0x05,
143 .get_recovery_mode = 0x06,
144 .set_recovery_mode = 0x07,
146 .get_performance_level = 0x08,
147 .set_performance_level = 0x09,
152 .performance_levels = {
167 .test_string = "SwSmi@",
169 .main_function = 0x5843,
177 .data_segment = 0x07,
181 .get_brightness = 0x10,
182 .set_brightness = 0x11,
184 .get_wireless_button = 0x12,
185 .set_wireless_button = 0x13,
187 .get_backlight = 0x2d,
188 .set_backlight = 0x2e,
190 .get_recovery_mode = 0xff,
191 .set_recovery_mode = 0xff,
193 .get_performance_level = 0x31,
194 .set_performance_level = 0x32,
199 .performance_levels = {
220 struct samsung_laptop {
221 const struct sabi_config *config;
224 void __iomem *sabi_iface;
225 void __iomem *f0000_segment;
227 struct mutex sabi_mutex;
229 struct platform_device *pdev;
230 struct backlight_device *backlight_device;
233 bool has_stepping_quirk;
236 static struct samsung_laptop *samsung;
239 module_param(force, bool, 0);
240 MODULE_PARM_DESC(force,
241 "Disable the DMI check and forces the driver to be loaded");
244 module_param(debug, bool, S_IRUGO | S_IWUSR);
245 MODULE_PARM_DESC(debug, "Debug enabled or not");
247 static int sabi_get_command(u8 command, struct sabi_retval *sretval)
249 const struct sabi_config *config = samsung->config;
251 u16 port = readw(samsung->sabi + config->header_offsets.port);
252 u8 complete, iface_data;
254 mutex_lock(&samsung->sabi_mutex);
256 /* enable memory to be able to write to it */
257 outb(readb(samsung->sabi + config->header_offsets.en_mem), port);
259 /* write out the command */
260 writew(config->main_function, samsung->sabi_iface + SABI_IFACE_MAIN);
261 writew(command, samsung->sabi_iface + SABI_IFACE_SUB);
262 writeb(0, samsung->sabi_iface + SABI_IFACE_COMPLETE);
263 outb(readb(samsung->sabi + config->header_offsets.iface_func), port);
265 /* write protect memory to make it safe */
266 outb(readb(samsung->sabi + config->header_offsets.re_mem), port);
268 /* see if the command actually succeeded */
269 complete = readb(samsung->sabi_iface + SABI_IFACE_COMPLETE);
270 iface_data = readb(samsung->sabi_iface + SABI_IFACE_DATA);
271 if (complete != 0xaa || iface_data == 0xff) {
272 pr_warn("SABI get command 0x%02x failed with completion flag 0x%02x and data 0x%02x\n",
273 command, complete, iface_data);
278 * Save off the data into a structure so the caller use it.
279 * Right now we only want the first 4 bytes,
280 * There are commands that need more, but not for the ones we
281 * currently care about.
283 sretval->retval[0] = readb(samsung->sabi_iface + SABI_IFACE_DATA);
284 sretval->retval[1] = readb(samsung->sabi_iface + SABI_IFACE_DATA + 1);
285 sretval->retval[2] = readb(samsung->sabi_iface + SABI_IFACE_DATA + 2);
286 sretval->retval[3] = readb(samsung->sabi_iface + SABI_IFACE_DATA + 3);
289 mutex_unlock(&samsung->sabi_mutex);
294 static int sabi_set_command(u8 command, u8 data)
296 const struct sabi_config *config = samsung->config;
298 u16 port = readw(samsung->sabi + config->header_offsets.port);
299 u8 complete, iface_data;
301 mutex_lock(&samsung->sabi_mutex);
303 /* enable memory to be able to write to it */
304 outb(readb(samsung->sabi + config->header_offsets.en_mem), port);
306 /* write out the command */
307 writew(config->main_function, samsung->sabi_iface + SABI_IFACE_MAIN);
308 writew(command, samsung->sabi_iface + SABI_IFACE_SUB);
309 writeb(0, samsung->sabi_iface + SABI_IFACE_COMPLETE);
310 writeb(data, samsung->sabi_iface + SABI_IFACE_DATA);
311 outb(readb(samsung->sabi + config->header_offsets.iface_func), port);
313 /* write protect memory to make it safe */
314 outb(readb(samsung->sabi + config->header_offsets.re_mem), port);
316 /* see if the command actually succeeded */
317 complete = readb(samsung->sabi_iface + SABI_IFACE_COMPLETE);
318 iface_data = readb(samsung->sabi_iface + SABI_IFACE_DATA);
319 if (complete != 0xaa || iface_data == 0xff) {
320 pr_warn("SABI set command 0x%02x failed with completion flag 0x%02x and data 0x%02x\n",
321 command, complete, iface_data);
325 mutex_unlock(&samsung->sabi_mutex);
329 static void test_backlight(void)
331 const struct sabi_commands *commands = &samsung->config->commands;
332 struct sabi_retval sretval;
334 sabi_get_command(commands->get_backlight, &sretval);
335 printk(KERN_DEBUG "backlight = 0x%02x\n", sretval.retval[0]);
337 sabi_set_command(commands->set_backlight, 0);
338 printk(KERN_DEBUG "backlight should be off\n");
340 sabi_get_command(commands->get_backlight, &sretval);
341 printk(KERN_DEBUG "backlight = 0x%02x\n", sretval.retval[0]);
345 sabi_set_command(commands->set_backlight, 1);
346 printk(KERN_DEBUG "backlight should be on\n");
348 sabi_get_command(commands->get_backlight, &sretval);
349 printk(KERN_DEBUG "backlight = 0x%02x\n", sretval.retval[0]);
352 static void test_wireless(void)
354 const struct sabi_commands *commands = &samsung->config->commands;
355 struct sabi_retval sretval;
357 sabi_get_command(commands->get_wireless_button, &sretval);
358 printk(KERN_DEBUG "wireless led = 0x%02x\n", sretval.retval[0]);
360 sabi_set_command(commands->set_wireless_button, 0);
361 printk(KERN_DEBUG "wireless led should be off\n");
363 sabi_get_command(commands->get_wireless_button, &sretval);
364 printk(KERN_DEBUG "wireless led = 0x%02x\n", sretval.retval[0]);
368 sabi_set_command(commands->set_wireless_button, 1);
369 printk(KERN_DEBUG "wireless led should be on\n");
371 sabi_get_command(commands->get_wireless_button, &sretval);
372 printk(KERN_DEBUG "wireless led = 0x%02x\n", sretval.retval[0]);
375 static u8 read_brightness(void)
377 const struct sabi_config *config = samsung->config;
378 const struct sabi_commands *commands = &samsung->config->commands;
379 struct sabi_retval sretval;
380 int user_brightness = 0;
383 retval = sabi_get_command(commands->get_brightness,
386 user_brightness = sretval.retval[0];
387 if (user_brightness > config->min_brightness)
388 user_brightness -= config->min_brightness;
392 return user_brightness;
395 static void set_brightness(u8 user_brightness)
397 const struct sabi_config *config = samsung->config;
398 const struct sabi_commands *commands = &samsung->config->commands;
399 u8 user_level = user_brightness + config->min_brightness;
401 if (samsung->has_stepping_quirk && user_level != 0) {
403 * short circuit if the specified level is what's already set
404 * to prevent the screen from flickering needlessly
406 if (user_brightness == read_brightness())
409 sabi_set_command(commands->set_brightness, 0);
412 sabi_set_command(commands->set_brightness, user_level);
415 static int get_brightness(struct backlight_device *bd)
417 return (int)read_brightness();
420 static void check_for_stepping_quirk(void)
424 u8 orig_level = read_brightness();
427 * Some laptops exhibit the strange behaviour of stepping toward
428 * (rather than setting) the brightness except when changing to/from
429 * brightness level 0. This behaviour is checked for here and worked
430 * around in set_brightness.
436 initial_level = read_brightness();
438 if (initial_level <= 2)
439 check_level = initial_level + 2;
441 check_level = initial_level - 2;
443 samsung->has_stepping_quirk = false;
444 set_brightness(check_level);
446 if (read_brightness() != check_level) {
447 samsung->has_stepping_quirk = true;
448 pr_info("enabled workaround for brightness stepping quirk\n");
451 set_brightness(orig_level);
454 static int update_status(struct backlight_device *bd)
456 const struct sabi_commands *commands = &samsung->config->commands;
458 set_brightness(bd->props.brightness);
460 if (bd->props.power == FB_BLANK_UNBLANK)
461 sabi_set_command(commands->set_backlight, 1);
463 sabi_set_command(commands->set_backlight, 0);
467 static const struct backlight_ops backlight_ops = {
468 .get_brightness = get_brightness,
469 .update_status = update_status,
472 static int rfkill_set(void *data, bool blocked)
474 const struct sabi_commands *commands = &samsung->config->commands;
476 /* Do something with blocked...*/
478 * blocked == false is on
479 * blocked == true is off
482 sabi_set_command(commands->set_wireless_button, 0);
484 sabi_set_command(commands->set_wireless_button, 1);
489 static struct rfkill_ops rfkill_ops = {
490 .set_block = rfkill_set,
493 static int init_wireless(struct platform_device *pdev)
497 samsung->rfk = rfkill_alloc("samsung-wifi", &samsung->pdev->dev, RFKILL_TYPE_WLAN,
502 retval = rfkill_register(samsung->rfk);
504 rfkill_destroy(samsung->rfk);
511 static void destroy_wireless(void)
513 rfkill_unregister(samsung->rfk);
514 rfkill_destroy(samsung->rfk);
517 static ssize_t get_performance_level(struct device *dev,
518 struct device_attribute *attr, char *buf)
520 const struct sabi_config *config = samsung->config;
521 struct sabi_retval sretval;
526 retval = sabi_get_command(config->commands.get_performance_level,
531 /* The logic is backwards, yeah, lots of fun... */
532 for (i = 0; config->performance_levels[i].name; ++i) {
533 if (sretval.retval[0] == config->performance_levels[i].value)
534 return sprintf(buf, "%s\n", config->performance_levels[i].name);
536 return sprintf(buf, "%s\n", "unknown");
539 static ssize_t set_performance_level(struct device *dev,
540 struct device_attribute *attr, const char *buf,
543 const struct sabi_config *config = samsung->config;
547 for (i = 0; config->performance_levels[i].name; ++i) {
548 const struct sabi_performance_level *level =
549 &config->performance_levels[i];
550 if (!strncasecmp(level->name, buf, strlen(level->name))) {
551 sabi_set_command(config->commands.set_performance_level,
556 if (!config->performance_levels[i].name)
561 static DEVICE_ATTR(performance_level, S_IWUSR | S_IRUGO,
562 get_performance_level, set_performance_level);
565 static int __init dmi_check_cb(const struct dmi_system_id *id)
567 pr_info("found laptop model '%s'\n",
572 static struct dmi_system_id __initdata samsung_dmi_table[] = {
576 DMI_MATCH(DMI_SYS_VENDOR,
577 "SAMSUNG ELECTRONICS CO., LTD."),
578 DMI_MATCH(DMI_PRODUCT_NAME, "N128"),
579 DMI_MATCH(DMI_BOARD_NAME, "N128"),
581 .callback = dmi_check_cb,
586 DMI_MATCH(DMI_SYS_VENDOR,
587 "SAMSUNG ELECTRONICS CO., LTD."),
588 DMI_MATCH(DMI_PRODUCT_NAME, "N130"),
589 DMI_MATCH(DMI_BOARD_NAME, "N130"),
591 .callback = dmi_check_cb,
596 DMI_MATCH(DMI_SYS_VENDOR,
597 "SAMSUNG ELECTRONICS CO., LTD."),
598 DMI_MATCH(DMI_PRODUCT_NAME, "N510"),
599 DMI_MATCH(DMI_BOARD_NAME, "N510"),
601 .callback = dmi_check_cb,
606 DMI_MATCH(DMI_SYS_VENDOR,
607 "SAMSUNG ELECTRONICS CO., LTD."),
608 DMI_MATCH(DMI_PRODUCT_NAME, "X125"),
609 DMI_MATCH(DMI_BOARD_NAME, "X125"),
611 .callback = dmi_check_cb,
614 .ident = "X120/X170",
616 DMI_MATCH(DMI_SYS_VENDOR,
617 "SAMSUNG ELECTRONICS CO., LTD."),
618 DMI_MATCH(DMI_PRODUCT_NAME, "X120/X170"),
619 DMI_MATCH(DMI_BOARD_NAME, "X120/X170"),
621 .callback = dmi_check_cb,
626 DMI_MATCH(DMI_SYS_VENDOR,
627 "SAMSUNG ELECTRONICS CO., LTD."),
628 DMI_MATCH(DMI_PRODUCT_NAME, "NC10"),
629 DMI_MATCH(DMI_BOARD_NAME, "NC10"),
631 .callback = dmi_check_cb,
636 DMI_MATCH(DMI_SYS_VENDOR,
637 "SAMSUNG ELECTRONICS CO., LTD."),
638 DMI_MATCH(DMI_PRODUCT_NAME, "SQ45S70S"),
639 DMI_MATCH(DMI_BOARD_NAME, "SQ45S70S"),
641 .callback = dmi_check_cb,
646 DMI_MATCH(DMI_SYS_VENDOR,
647 "SAMSUNG ELECTRONICS CO., LTD."),
648 DMI_MATCH(DMI_PRODUCT_NAME, "X360"),
649 DMI_MATCH(DMI_BOARD_NAME, "X360"),
651 .callback = dmi_check_cb,
654 .ident = "R410 Plus",
656 DMI_MATCH(DMI_SYS_VENDOR,
657 "SAMSUNG ELECTRONICS CO., LTD."),
658 DMI_MATCH(DMI_PRODUCT_NAME, "R410P"),
659 DMI_MATCH(DMI_BOARD_NAME, "R460"),
661 .callback = dmi_check_cb,
666 DMI_MATCH(DMI_SYS_VENDOR,
667 "SAMSUNG ELECTRONICS CO., LTD."),
668 DMI_MATCH(DMI_PRODUCT_NAME, "R518"),
669 DMI_MATCH(DMI_BOARD_NAME, "R518"),
671 .callback = dmi_check_cb,
674 .ident = "R519/R719",
676 DMI_MATCH(DMI_SYS_VENDOR,
677 "SAMSUNG ELECTRONICS CO., LTD."),
678 DMI_MATCH(DMI_PRODUCT_NAME, "R519/R719"),
679 DMI_MATCH(DMI_BOARD_NAME, "R519/R719"),
681 .callback = dmi_check_cb,
684 .ident = "N150/N210/N220",
686 DMI_MATCH(DMI_SYS_VENDOR,
687 "SAMSUNG ELECTRONICS CO., LTD."),
688 DMI_MATCH(DMI_PRODUCT_NAME, "N150/N210/N220"),
689 DMI_MATCH(DMI_BOARD_NAME, "N150/N210/N220"),
691 .callback = dmi_check_cb,
696 DMI_MATCH(DMI_SYS_VENDOR,
697 "SAMSUNG ELECTRONICS CO., LTD."),
698 DMI_MATCH(DMI_PRODUCT_NAME, "N220"),
699 DMI_MATCH(DMI_BOARD_NAME, "N220"),
701 .callback = dmi_check_cb,
704 .ident = "N150/N210/N220/N230",
706 DMI_MATCH(DMI_SYS_VENDOR,
707 "SAMSUNG ELECTRONICS CO., LTD."),
708 DMI_MATCH(DMI_PRODUCT_NAME, "N150/N210/N220/N230"),
709 DMI_MATCH(DMI_BOARD_NAME, "N150/N210/N220/N230"),
711 .callback = dmi_check_cb,
714 .ident = "N150P/N210P/N220P",
716 DMI_MATCH(DMI_SYS_VENDOR,
717 "SAMSUNG ELECTRONICS CO., LTD."),
718 DMI_MATCH(DMI_PRODUCT_NAME, "N150P/N210P/N220P"),
719 DMI_MATCH(DMI_BOARD_NAME, "N150P/N210P/N220P"),
721 .callback = dmi_check_cb,
726 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
727 DMI_MATCH(DMI_PRODUCT_NAME, "SR700"),
728 DMI_MATCH(DMI_BOARD_NAME, "SR700"),
730 .callback = dmi_check_cb,
733 .ident = "R530/R730",
735 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
736 DMI_MATCH(DMI_PRODUCT_NAME, "R530/R730"),
737 DMI_MATCH(DMI_BOARD_NAME, "R530/R730"),
739 .callback = dmi_check_cb,
742 .ident = "NF110/NF210/NF310",
744 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
745 DMI_MATCH(DMI_PRODUCT_NAME, "NF110/NF210/NF310"),
746 DMI_MATCH(DMI_BOARD_NAME, "NF110/NF210/NF310"),
748 .callback = dmi_check_cb,
751 .ident = "N145P/N250P/N260P",
753 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
754 DMI_MATCH(DMI_PRODUCT_NAME, "N145P/N250P/N260P"),
755 DMI_MATCH(DMI_BOARD_NAME, "N145P/N250P/N260P"),
757 .callback = dmi_check_cb,
762 DMI_MATCH(DMI_SYS_VENDOR,
763 "SAMSUNG ELECTRONICS CO., LTD."),
764 DMI_MATCH(DMI_PRODUCT_NAME, "R70/R71"),
765 DMI_MATCH(DMI_BOARD_NAME, "R70/R71"),
767 .callback = dmi_check_cb,
772 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
773 DMI_MATCH(DMI_PRODUCT_NAME, "P460"),
774 DMI_MATCH(DMI_BOARD_NAME, "P460"),
776 .callback = dmi_check_cb,
779 .ident = "R528/R728",
781 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
782 DMI_MATCH(DMI_PRODUCT_NAME, "R528/R728"),
783 DMI_MATCH(DMI_BOARD_NAME, "R528/R728"),
785 .callback = dmi_check_cb,
788 .ident = "NC210/NC110",
790 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
791 DMI_MATCH(DMI_PRODUCT_NAME, "NC210/NC110"),
792 DMI_MATCH(DMI_BOARD_NAME, "NC210/NC110"),
794 .callback = dmi_check_cb,
799 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
800 DMI_MATCH(DMI_PRODUCT_NAME, "X520"),
801 DMI_MATCH(DMI_BOARD_NAME, "X520"),
803 .callback = dmi_check_cb,
807 MODULE_DEVICE_TABLE(dmi, samsung_dmi_table);
809 static int find_signature(void __iomem *memcheck, const char *testStr)
814 for (loca = 0; loca < 0xffff; loca++) {
815 char temp = readb(memcheck + loca);
817 if (temp == testStr[i]) {
818 if (i == strlen(testStr)-1)
828 static int __init samsung_init(void)
830 const struct sabi_config *config = NULL;
831 const struct sabi_commands *commands;
832 struct backlight_device *bd;
833 struct backlight_properties props;
834 struct sabi_retval sretval;
840 if (!force && !dmi_check_system(samsung_dmi_table))
843 samsung = kzalloc(sizeof(*samsung), GFP_KERNEL);
847 mutex_init(&samsung->sabi_mutex);
849 samsung->f0000_segment = ioremap_nocache(0xf0000, 0xffff);
850 if (!samsung->f0000_segment) {
851 pr_err("Can't map the segment at 0xf0000\n");
855 /* Try to find one of the signatures in memory to find the header */
856 for (i = 0; sabi_configs[i].test_string != 0; ++i) {
857 samsung->config = &sabi_configs[i];
858 loca = find_signature(samsung->f0000_segment,
859 samsung->config->test_string);
864 if (loca == 0xffff) {
865 pr_err("This computer does not support SABI\n");
866 goto error_no_signature;
869 config = samsung->config;
870 commands = &config->commands;
872 /* point to the SMI port Number */
874 samsung->sabi = (samsung->f0000_segment + loca);
877 printk(KERN_DEBUG "This computer supports SABI==%x\n",
879 printk(KERN_DEBUG "SABI header:\n");
880 printk(KERN_DEBUG " SMI Port Number = 0x%04x\n",
881 readw(samsung->sabi +
882 config->header_offsets.port));
883 printk(KERN_DEBUG " SMI Interface Function = 0x%02x\n",
884 readb(samsung->sabi +
885 config->header_offsets.iface_func));
886 printk(KERN_DEBUG " SMI enable memory buffer = 0x%02x\n",
887 readb(samsung->sabi +
888 config->header_offsets.en_mem));
889 printk(KERN_DEBUG " SMI restore memory buffer = 0x%02x\n",
890 readb(samsung->sabi +
891 config->header_offsets.re_mem));
892 printk(KERN_DEBUG " SABI data offset = 0x%04x\n",
893 readw(samsung->sabi +
894 config->header_offsets.data_offset));
895 printk(KERN_DEBUG " SABI data segment = 0x%04x\n",
896 readw(samsung->sabi +
897 config->header_offsets.data_segment));
900 /* Get a pointer to the SABI Interface */
901 ifaceP = (readw(samsung->sabi + config->header_offsets.data_segment) & 0x0ffff) << 4;
902 ifaceP += readw(samsung->sabi + config->header_offsets.data_offset) & 0x0ffff;
903 samsung->sabi_iface = ioremap_nocache(ifaceP, 16);
904 if (!samsung->sabi_iface) {
905 pr_err("Can't remap %x\n", ifaceP);
906 goto error_no_signature;
909 printk(KERN_DEBUG "ifaceP = 0x%08x\n", ifaceP);
910 printk(KERN_DEBUG "sabi_iface = %p\n", samsung->sabi_iface);
915 retval = sabi_get_command(commands->get_brightness,
917 printk(KERN_DEBUG "brightness = 0x%02x\n", sretval.retval[0]);
920 /* Turn on "Linux" mode in the BIOS */
921 if (commands->set_linux != 0xff) {
922 retval = sabi_set_command(commands->set_linux,
925 pr_warn("Linux mode was not set!\n");
926 goto error_no_platform;
930 /* Check for stepping quirk */
931 check_for_stepping_quirk();
933 /* knock up a platform device to hang stuff off of */
934 samsung->pdev = platform_device_register_simple("samsung", -1, NULL, 0);
935 if (IS_ERR(samsung->pdev))
936 goto error_no_platform;
938 /* create a backlight device to talk to this one */
939 memset(&props, 0, sizeof(struct backlight_properties));
940 props.type = BACKLIGHT_PLATFORM;
941 props.max_brightness = config->max_brightness -
942 config->min_brightness;
943 bd = backlight_device_register("samsung", &samsung->pdev->dev,
944 NULL, &backlight_ops,
947 goto error_no_backlight;
949 samsung->backlight_device = bd;
950 samsung->backlight_device->props.brightness = read_brightness();
951 samsung->backlight_device->props.power = FB_BLANK_UNBLANK;
952 backlight_update_status(samsung->backlight_device);
954 retval = init_wireless(samsung->pdev);
958 retval = device_create_file(&samsung->pdev->dev,
959 &dev_attr_performance_level);
961 goto error_file_create;
969 backlight_device_unregister(samsung->backlight_device);
972 platform_device_unregister(samsung->pdev);
975 iounmap(samsung->sabi_iface);
978 iounmap(samsung->f0000_segment);
986 static void __exit samsung_exit(void)
988 const struct sabi_commands *commands = &samsung->config->commands;
990 /* Turn off "Linux" mode in the BIOS */
991 if (commands->set_linux != 0xff)
992 sabi_set_command(commands->set_linux, 0x80);
994 device_remove_file(&samsung->pdev->dev, &dev_attr_performance_level);
995 backlight_device_unregister(samsung->backlight_device);
997 iounmap(samsung->sabi_iface);
998 iounmap(samsung->f0000_segment);
999 platform_device_unregister(samsung->pdev);
1004 module_init(samsung_init);
1005 module_exit(samsung_exit);
1007 MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@suse.de>");
1008 MODULE_DESCRIPTION("Samsung Backlight driver");
1009 MODULE_LICENSE("GPL");