samsung-laptop: make the dmi check less strict (part 2)
[pandora-kernel.git] / drivers / platform / x86 / samsung-laptop.c
1 /*
2  * Samsung Laptop driver
3  *
4  * Copyright (C) 2009,2011 Greg Kroah-Hartman (gregkh@suse.de)
5  * Copyright (C) 2009,2011 Novell Inc.
6  *
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.
10  *
11  */
12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
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>
20 #include <linux/fb.h>
21 #include <linux/dmi.h>
22 #include <linux/platform_device.h>
23 #include <linux/rfkill.h>
24 #include <linux/acpi.h>
25
26 /*
27  * This driver is needed because a number of Samsung laptops do not hook
28  * their control settings through ACPI.  So we have to poke around in the
29  * BIOS to do things like brightness values, and "special" key controls.
30  */
31
32 /*
33  * We have 0 - 8 as valid brightness levels.  The specs say that level 0 should
34  * be reserved by the BIOS (which really doesn't make much sense), we tell
35  * userspace that the value is 0 - 7 and then just tell the hardware 1 - 8
36  */
37 #define MAX_BRIGHT      0x07
38
39
40 #define SABI_IFACE_MAIN                 0x00
41 #define SABI_IFACE_SUB                  0x02
42 #define SABI_IFACE_COMPLETE             0x04
43 #define SABI_IFACE_DATA                 0x05
44
45 /* Structure to get data back to the calling function */
46 struct sabi_retval {
47         u8 retval[20];
48 };
49
50 struct sabi_header_offsets {
51         u8 port;
52         u8 re_mem;
53         u8 iface_func;
54         u8 en_mem;
55         u8 data_offset;
56         u8 data_segment;
57 };
58
59 struct sabi_commands {
60         /*
61          * Brightness is 0 - 8, as described above.
62          * Value 0 is for the BIOS to use
63          */
64         u8 get_brightness;
65         u8 set_brightness;
66
67         /*
68          * first byte:
69          * 0x00 - wireless is off
70          * 0x01 - wireless is on
71          * second byte:
72          * 0x02 - 3G is off
73          * 0x03 - 3G is on
74          * TODO, verify 3G is correct, that doesn't seem right...
75          */
76         u8 get_wireless_button;
77         u8 set_wireless_button;
78
79         /* 0 is off, 1 is on */
80         u8 get_backlight;
81         u8 set_backlight;
82
83         /*
84          * 0x80 or 0x00 - no action
85          * 0x81 - recovery key pressed
86          */
87         u8 get_recovery_mode;
88         u8 set_recovery_mode;
89
90         /*
91          * on seclinux: 0 is low, 1 is high,
92          * on swsmi: 0 is normal, 1 is silent, 2 is turbo
93          */
94         u8 get_performance_level;
95         u8 set_performance_level;
96
97         /*
98          * Tell the BIOS that Linux is running on this machine.
99          * 81 is on, 80 is off
100          */
101         u8 set_linux;
102 };
103
104 struct sabi_performance_level {
105         const char *name;
106         u8 value;
107 };
108
109 struct sabi_config {
110         const char *test_string;
111         u16 main_function;
112         const struct sabi_header_offsets header_offsets;
113         const struct sabi_commands commands;
114         const struct sabi_performance_level performance_levels[4];
115         u8 min_brightness;
116         u8 max_brightness;
117 };
118
119 static const struct sabi_config sabi_configs[] = {
120         {
121                 .test_string = "SECLINUX",
122
123                 .main_function = 0x4c49,
124
125                 .header_offsets = {
126                         .port = 0x00,
127                         .re_mem = 0x02,
128                         .iface_func = 0x03,
129                         .en_mem = 0x04,
130                         .data_offset = 0x05,
131                         .data_segment = 0x07,
132                 },
133
134                 .commands = {
135                         .get_brightness = 0x00,
136                         .set_brightness = 0x01,
137
138                         .get_wireless_button = 0x02,
139                         .set_wireless_button = 0x03,
140
141                         .get_backlight = 0x04,
142                         .set_backlight = 0x05,
143
144                         .get_recovery_mode = 0x06,
145                         .set_recovery_mode = 0x07,
146
147                         .get_performance_level = 0x08,
148                         .set_performance_level = 0x09,
149
150                         .set_linux = 0x0a,
151                 },
152
153                 .performance_levels = {
154                         {
155                                 .name = "silent",
156                                 .value = 0,
157                         },
158                         {
159                                 .name = "normal",
160                                 .value = 1,
161                         },
162                         { },
163                 },
164                 .min_brightness = 1,
165                 .max_brightness = 8,
166         },
167         {
168                 .test_string = "SwSmi@",
169
170                 .main_function = 0x5843,
171
172                 .header_offsets = {
173                         .port = 0x00,
174                         .re_mem = 0x04,
175                         .iface_func = 0x02,
176                         .en_mem = 0x03,
177                         .data_offset = 0x05,
178                         .data_segment = 0x07,
179                 },
180
181                 .commands = {
182                         .get_brightness = 0x10,
183                         .set_brightness = 0x11,
184
185                         .get_wireless_button = 0x12,
186                         .set_wireless_button = 0x13,
187
188                         .get_backlight = 0x2d,
189                         .set_backlight = 0x2e,
190
191                         .get_recovery_mode = 0xff,
192                         .set_recovery_mode = 0xff,
193
194                         .get_performance_level = 0x31,
195                         .set_performance_level = 0x32,
196
197                         .set_linux = 0xff,
198                 },
199
200                 .performance_levels = {
201                         {
202                                 .name = "normal",
203                                 .value = 0,
204                         },
205                         {
206                                 .name = "silent",
207                                 .value = 1,
208                         },
209                         {
210                                 .name = "overclock",
211                                 .value = 2,
212                         },
213                         { },
214                 },
215                 .min_brightness = 0,
216                 .max_brightness = 8,
217         },
218         { },
219 };
220
221 static const struct sabi_config *sabi_config;
222
223 static void __iomem *sabi;
224 static void __iomem *sabi_iface;
225 static void __iomem *f0000_segment;
226 static struct backlight_device *backlight_device;
227 static struct mutex sabi_mutex;
228 static struct platform_device *sdev;
229 static struct rfkill *rfk;
230 static bool handle_backlight;
231 static bool has_stepping_quirk;
232
233 static int force;
234 module_param(force, bool, 0);
235 MODULE_PARM_DESC(force,
236                 "Disable the DMI check and forces the driver to be loaded");
237
238 static int debug;
239 module_param(debug, bool, S_IRUGO | S_IWUSR);
240 MODULE_PARM_DESC(debug, "Debug enabled or not");
241
242 static int sabi_get_command(u8 command, struct sabi_retval *sretval)
243 {
244         int retval = 0;
245         u16 port = readw(sabi + sabi_config->header_offsets.port);
246         u8 complete, iface_data;
247
248         mutex_lock(&sabi_mutex);
249
250         /* enable memory to be able to write to it */
251         outb(readb(sabi + sabi_config->header_offsets.en_mem), port);
252
253         /* write out the command */
254         writew(sabi_config->main_function, sabi_iface + SABI_IFACE_MAIN);
255         writew(command, sabi_iface + SABI_IFACE_SUB);
256         writeb(0, sabi_iface + SABI_IFACE_COMPLETE);
257         outb(readb(sabi + sabi_config->header_offsets.iface_func), port);
258
259         /* write protect memory to make it safe */
260         outb(readb(sabi + sabi_config->header_offsets.re_mem), port);
261
262         /* see if the command actually succeeded */
263         complete = readb(sabi_iface + SABI_IFACE_COMPLETE);
264         iface_data = readb(sabi_iface + SABI_IFACE_DATA);
265         if (complete != 0xaa || iface_data == 0xff) {
266                 pr_warn("SABI get command 0x%02x failed with completion flag 0x%02x and data 0x%02x\n",
267                         command, complete, iface_data);
268                 retval = -EINVAL;
269                 goto exit;
270         }
271         /*
272          * Save off the data into a structure so the caller use it.
273          * Right now we only want the first 4 bytes,
274          * There are commands that need more, but not for the ones we
275          * currently care about.
276          */
277         sretval->retval[0] = readb(sabi_iface + SABI_IFACE_DATA);
278         sretval->retval[1] = readb(sabi_iface + SABI_IFACE_DATA + 1);
279         sretval->retval[2] = readb(sabi_iface + SABI_IFACE_DATA + 2);
280         sretval->retval[3] = readb(sabi_iface + SABI_IFACE_DATA + 3);
281
282 exit:
283         mutex_unlock(&sabi_mutex);
284         return retval;
285
286 }
287
288 static int sabi_set_command(u8 command, u8 data)
289 {
290         int retval = 0;
291         u16 port = readw(sabi + sabi_config->header_offsets.port);
292         u8 complete, iface_data;
293
294         mutex_lock(&sabi_mutex);
295
296         /* enable memory to be able to write to it */
297         outb(readb(sabi + sabi_config->header_offsets.en_mem), port);
298
299         /* write out the command */
300         writew(sabi_config->main_function, sabi_iface + SABI_IFACE_MAIN);
301         writew(command, sabi_iface + SABI_IFACE_SUB);
302         writeb(0, sabi_iface + SABI_IFACE_COMPLETE);
303         writeb(data, sabi_iface + SABI_IFACE_DATA);
304         outb(readb(sabi + sabi_config->header_offsets.iface_func), port);
305
306         /* write protect memory to make it safe */
307         outb(readb(sabi + sabi_config->header_offsets.re_mem), port);
308
309         /* see if the command actually succeeded */
310         complete = readb(sabi_iface + SABI_IFACE_COMPLETE);
311         iface_data = readb(sabi_iface + SABI_IFACE_DATA);
312         if (complete != 0xaa || iface_data == 0xff) {
313                 pr_warn("SABI set command 0x%02x failed with completion flag 0x%02x and data 0x%02x\n",
314                        command, complete, iface_data);
315                 retval = -EINVAL;
316         }
317
318         mutex_unlock(&sabi_mutex);
319         return retval;
320 }
321
322 static void test_backlight(void)
323 {
324         struct sabi_retval sretval;
325
326         sabi_get_command(sabi_config->commands.get_backlight, &sretval);
327         printk(KERN_DEBUG "backlight = 0x%02x\n", sretval.retval[0]);
328
329         sabi_set_command(sabi_config->commands.set_backlight, 0);
330         printk(KERN_DEBUG "backlight should be off\n");
331
332         sabi_get_command(sabi_config->commands.get_backlight, &sretval);
333         printk(KERN_DEBUG "backlight = 0x%02x\n", sretval.retval[0]);
334
335         msleep(1000);
336
337         sabi_set_command(sabi_config->commands.set_backlight, 1);
338         printk(KERN_DEBUG "backlight should be on\n");
339
340         sabi_get_command(sabi_config->commands.get_backlight, &sretval);
341         printk(KERN_DEBUG "backlight = 0x%02x\n", sretval.retval[0]);
342 }
343
344 static void test_wireless(void)
345 {
346         struct sabi_retval sretval;
347
348         sabi_get_command(sabi_config->commands.get_wireless_button, &sretval);
349         printk(KERN_DEBUG "wireless led = 0x%02x\n", sretval.retval[0]);
350
351         sabi_set_command(sabi_config->commands.set_wireless_button, 0);
352         printk(KERN_DEBUG "wireless led should be off\n");
353
354         sabi_get_command(sabi_config->commands.get_wireless_button, &sretval);
355         printk(KERN_DEBUG "wireless led = 0x%02x\n", sretval.retval[0]);
356
357         msleep(1000);
358
359         sabi_set_command(sabi_config->commands.set_wireless_button, 1);
360         printk(KERN_DEBUG "wireless led should be on\n");
361
362         sabi_get_command(sabi_config->commands.get_wireless_button, &sretval);
363         printk(KERN_DEBUG "wireless led = 0x%02x\n", sretval.retval[0]);
364 }
365
366 static u8 read_brightness(void)
367 {
368         struct sabi_retval sretval;
369         int user_brightness = 0;
370         int retval;
371
372         retval = sabi_get_command(sabi_config->commands.get_brightness,
373                                   &sretval);
374         if (!retval) {
375                 user_brightness = sretval.retval[0];
376                 if (user_brightness > sabi_config->min_brightness)
377                         user_brightness -= sabi_config->min_brightness;
378                 else
379                         user_brightness = 0;
380         }
381         return user_brightness;
382 }
383
384 static void set_brightness(u8 user_brightness)
385 {
386         u8 user_level = user_brightness + sabi_config->min_brightness;
387
388         if (has_stepping_quirk && user_level != 0) {
389                 /*
390                  * short circuit if the specified level is what's already set
391                  * to prevent the screen from flickering needlessly
392                  */
393                 if (user_brightness == read_brightness())
394                         return;
395
396                 sabi_set_command(sabi_config->commands.set_brightness, 0);
397         }
398
399         sabi_set_command(sabi_config->commands.set_brightness, user_level);
400 }
401
402 static int get_brightness(struct backlight_device *bd)
403 {
404         return (int)read_brightness();
405 }
406
407 static void check_for_stepping_quirk(void)
408 {
409         u8 initial_level;
410         u8 check_level;
411         u8 orig_level = read_brightness();
412
413         /*
414          * Some laptops exhibit the strange behaviour of stepping toward
415          * (rather than setting) the brightness except when changing to/from
416          * brightness level 0. This behaviour is checked for here and worked
417          * around in set_brightness.
418          */
419
420         if (orig_level == 0)
421                 set_brightness(1);
422
423         initial_level = read_brightness();
424
425         if (initial_level <= 2)
426                 check_level = initial_level + 2;
427         else
428                 check_level = initial_level - 2;
429
430         has_stepping_quirk = false;
431         set_brightness(check_level);
432
433         if (read_brightness() != check_level) {
434                 has_stepping_quirk = true;
435                 pr_info("enabled workaround for brightness stepping quirk\n");
436         }
437
438         set_brightness(orig_level);
439 }
440
441 static int update_status(struct backlight_device *bd)
442 {
443         set_brightness(bd->props.brightness);
444
445         if (bd->props.power == FB_BLANK_UNBLANK)
446                 sabi_set_command(sabi_config->commands.set_backlight, 1);
447         else
448                 sabi_set_command(sabi_config->commands.set_backlight, 0);
449         return 0;
450 }
451
452 static const struct backlight_ops backlight_ops = {
453         .get_brightness = get_brightness,
454         .update_status  = update_status,
455 };
456
457 static int rfkill_set(void *data, bool blocked)
458 {
459         /* Do something with blocked...*/
460         /*
461          * blocked == false is on
462          * blocked == true is off
463          */
464         if (blocked)
465                 sabi_set_command(sabi_config->commands.set_wireless_button, 0);
466         else
467                 sabi_set_command(sabi_config->commands.set_wireless_button, 1);
468
469         return 0;
470 }
471
472 static struct rfkill_ops rfkill_ops = {
473         .set_block = rfkill_set,
474 };
475
476 static int init_wireless(struct platform_device *sdev)
477 {
478         int retval;
479
480         rfk = rfkill_alloc("samsung-wifi", &sdev->dev, RFKILL_TYPE_WLAN,
481                            &rfkill_ops, NULL);
482         if (!rfk)
483                 return -ENOMEM;
484
485         retval = rfkill_register(rfk);
486         if (retval) {
487                 rfkill_destroy(rfk);
488                 return -ENODEV;
489         }
490
491         return 0;
492 }
493
494 static void destroy_wireless(void)
495 {
496         rfkill_unregister(rfk);
497         rfkill_destroy(rfk);
498 }
499
500 static ssize_t get_performance_level(struct device *dev,
501                                      struct device_attribute *attr, char *buf)
502 {
503         struct sabi_retval sretval;
504         int retval;
505         int i;
506
507         /* Read the state */
508         retval = sabi_get_command(sabi_config->commands.get_performance_level,
509                                   &sretval);
510         if (retval)
511                 return retval;
512
513         /* The logic is backwards, yeah, lots of fun... */
514         for (i = 0; sabi_config->performance_levels[i].name; ++i) {
515                 if (sretval.retval[0] == sabi_config->performance_levels[i].value)
516                         return sprintf(buf, "%s\n", sabi_config->performance_levels[i].name);
517         }
518         return sprintf(buf, "%s\n", "unknown");
519 }
520
521 static ssize_t set_performance_level(struct device *dev,
522                                 struct device_attribute *attr, const char *buf,
523                                 size_t count)
524 {
525         if (count >= 1) {
526                 int i;
527                 for (i = 0; sabi_config->performance_levels[i].name; ++i) {
528                         const struct sabi_performance_level *level =
529                                 &sabi_config->performance_levels[i];
530                         if (!strncasecmp(level->name, buf, strlen(level->name))) {
531                                 sabi_set_command(sabi_config->commands.set_performance_level,
532                                                  level->value);
533                                 break;
534                         }
535                 }
536                 if (!sabi_config->performance_levels[i].name)
537                         return -EINVAL;
538         }
539         return count;
540 }
541 static DEVICE_ATTR(performance_level, S_IWUSR | S_IRUGO,
542                    get_performance_level, set_performance_level);
543
544
545 static struct dmi_system_id __initdata samsung_dmi_table[] = {
546         {
547                 .matches = {
548                         DMI_MATCH(DMI_SYS_VENDOR,
549                                         "SAMSUNG ELECTRONICS CO., LTD."),
550                         DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */
551                 },
552         },
553         {
554                 .matches = {
555                         DMI_MATCH(DMI_SYS_VENDOR,
556                                         "SAMSUNG ELECTRONICS CO., LTD."),
557                         DMI_MATCH(DMI_CHASSIS_TYPE, "9"), /* Laptop */
558                 },
559         },
560         {
561                 .matches = {
562                         DMI_MATCH(DMI_SYS_VENDOR,
563                                         "SAMSUNG ELECTRONICS CO., LTD."),
564                         DMI_MATCH(DMI_CHASSIS_TYPE, "10"), /* Notebook */
565                 },
566         },
567         {
568                 .matches = {
569                         DMI_MATCH(DMI_SYS_VENDOR,
570                                         "SAMSUNG ELECTRONICS CO., LTD."),
571                         DMI_MATCH(DMI_CHASSIS_TYPE, "14"), /* Sub-Notebook */
572                 },
573         },
574         { },
575 };
576 MODULE_DEVICE_TABLE(dmi, samsung_dmi_table);
577
578 static int find_signature(void __iomem *memcheck, const char *testStr)
579 {
580         int i = 0;
581         int loca;
582
583         for (loca = 0; loca < 0xffff; loca++) {
584                 char temp = readb(memcheck + loca);
585
586                 if (temp == testStr[i]) {
587                         if (i == strlen(testStr)-1)
588                                 break;
589                         ++i;
590                 } else {
591                         i = 0;
592                 }
593         }
594         return loca;
595 }
596
597 static int __init samsung_init(void)
598 {
599         struct backlight_properties props;
600         struct sabi_retval sretval;
601         unsigned int ifaceP;
602         int i;
603         int loca;
604         int retval;
605
606         mutex_init(&sabi_mutex);
607         handle_backlight = true;
608
609 #ifdef CONFIG_ACPI
610         /* Don't handle backlight here if the acpi video already handle it */
611         if (acpi_video_backlight_support())
612                 handle_backlight = false;
613 #endif
614
615         if (!force && !dmi_check_system(samsung_dmi_table))
616                 return -ENODEV;
617
618         f0000_segment = ioremap_nocache(0xf0000, 0xffff);
619         if (!f0000_segment) {
620                 if (debug || force)
621                         pr_err("Can't map the segment at 0xf0000\n");
622                 return -EINVAL;
623         }
624
625         /* Try to find one of the signatures in memory to find the header */
626         for (i = 0; sabi_configs[i].test_string != 0; ++i) {
627                 sabi_config = &sabi_configs[i];
628                 loca = find_signature(f0000_segment, sabi_config->test_string);
629                 if (loca != 0xffff)
630                         break;
631         }
632
633         if (loca == 0xffff) {
634                 if (debug || force)
635                         pr_err("This computer does not support SABI\n");
636                 goto error_no_signature;
637         }
638
639         /* point to the SMI port Number */
640         loca += 1;
641         sabi = (f0000_segment + loca);
642
643         if (debug) {
644                 printk(KERN_DEBUG "This computer supports SABI==%x\n",
645                         loca + 0xf0000 - 6);
646                 printk(KERN_DEBUG "SABI header:\n");
647                 printk(KERN_DEBUG " SMI Port Number = 0x%04x\n",
648                         readw(sabi + sabi_config->header_offsets.port));
649                 printk(KERN_DEBUG " SMI Interface Function = 0x%02x\n",
650                         readb(sabi + sabi_config->header_offsets.iface_func));
651                 printk(KERN_DEBUG " SMI enable memory buffer = 0x%02x\n",
652                         readb(sabi + sabi_config->header_offsets.en_mem));
653                 printk(KERN_DEBUG " SMI restore memory buffer = 0x%02x\n",
654                         readb(sabi + sabi_config->header_offsets.re_mem));
655                 printk(KERN_DEBUG " SABI data offset = 0x%04x\n",
656                         readw(sabi + sabi_config->header_offsets.data_offset));
657                 printk(KERN_DEBUG " SABI data segment = 0x%04x\n",
658                         readw(sabi + sabi_config->header_offsets.data_segment));
659         }
660
661         /* Get a pointer to the SABI Interface */
662         ifaceP = (readw(sabi + sabi_config->header_offsets.data_segment) & 0x0ffff) << 4;
663         ifaceP += readw(sabi + sabi_config->header_offsets.data_offset) & 0x0ffff;
664         sabi_iface = ioremap_nocache(ifaceP, 16);
665         if (!sabi_iface) {
666                 pr_err("Can't remap %x\n", ifaceP);
667                 goto error_no_signature;
668         }
669         if (debug) {
670                 printk(KERN_DEBUG "ifaceP = 0x%08x\n", ifaceP);
671                 printk(KERN_DEBUG "sabi_iface = %p\n", sabi_iface);
672
673                 if (handle_backlight)
674                         test_backlight();
675                 test_wireless();
676
677                 retval = sabi_get_command(sabi_config->commands.get_brightness,
678                                           &sretval);
679                 printk(KERN_DEBUG "brightness = 0x%02x\n", sretval.retval[0]);
680         }
681
682         /* Turn on "Linux" mode in the BIOS */
683         if (sabi_config->commands.set_linux != 0xff) {
684                 retval = sabi_set_command(sabi_config->commands.set_linux,
685                                           0x81);
686                 if (retval) {
687                         pr_warn("Linux mode was not set!\n");
688                         goto error_no_platform;
689                 }
690         }
691
692         /* Check for stepping quirk */
693         if (handle_backlight)
694                 check_for_stepping_quirk();
695
696 #ifdef CONFIG_ACPI
697         /* Only log that if we are really on a sabi platform */
698         if (acpi_video_backlight_support())
699                 pr_info("Backlight controlled by ACPI video driver\n");
700 #endif
701
702         /* knock up a platform device to hang stuff off of */
703         sdev = platform_device_register_simple("samsung", -1, NULL, 0);
704         if (IS_ERR(sdev))
705                 goto error_no_platform;
706
707         if (!handle_backlight)
708                 goto skip_backlight;
709
710         /* create a backlight device to talk to this one */
711         memset(&props, 0, sizeof(struct backlight_properties));
712         props.type = BACKLIGHT_PLATFORM;
713         props.max_brightness = sabi_config->max_brightness -
714                                 sabi_config->min_brightness;
715         backlight_device = backlight_device_register("samsung", &sdev->dev,
716                                                      NULL, &backlight_ops,
717                                                      &props);
718         if (IS_ERR(backlight_device))
719                 goto error_no_backlight;
720
721         backlight_device->props.brightness = read_brightness();
722         backlight_device->props.power = FB_BLANK_UNBLANK;
723         backlight_update_status(backlight_device);
724
725 skip_backlight:
726         retval = init_wireless(sdev);
727         if (retval)
728                 goto error_no_rfk;
729
730         retval = device_create_file(&sdev->dev, &dev_attr_performance_level);
731         if (retval)
732                 goto error_file_create;
733
734         return 0;
735
736 error_file_create:
737         destroy_wireless();
738
739 error_no_rfk:
740         backlight_device_unregister(backlight_device);
741
742 error_no_backlight:
743         platform_device_unregister(sdev);
744
745 error_no_platform:
746         iounmap(sabi_iface);
747
748 error_no_signature:
749         iounmap(f0000_segment);
750         return -EINVAL;
751 }
752
753 static void __exit samsung_exit(void)
754 {
755         /* Turn off "Linux" mode in the BIOS */
756         if (sabi_config->commands.set_linux != 0xff)
757                 sabi_set_command(sabi_config->commands.set_linux, 0x80);
758
759         device_remove_file(&sdev->dev, &dev_attr_performance_level);
760         backlight_device_unregister(backlight_device);
761         destroy_wireless();
762         iounmap(sabi_iface);
763         iounmap(f0000_segment);
764         platform_device_unregister(sdev);
765 }
766
767 module_init(samsung_init);
768 module_exit(samsung_exit);
769
770 MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@suse.de>");
771 MODULE_DESCRIPTION("Samsung Backlight driver");
772 MODULE_LICENSE("GPL");