1 // SPDX-License-Identifier: GPL-2.0-only
3 * Samsung Laptop driver
5 * Copyright (C) 2009,2011 Greg Kroah-Hartman (gregkh@suse.de)
6 * Copyright (C) 2009,2011 Novell Inc.
8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/module.h>
13 #include <linux/delay.h>
14 #include <linux/pci.h>
15 #include <linux/backlight.h>
16 #include <linux/leds.h>
18 #include <linux/dmi.h>
19 #include <linux/platform_device.h>
20 #include <linux/rfkill.h>
21 #include <linux/acpi.h>
22 #include <linux/seq_file.h>
23 #include <linux/debugfs.h>
24 #include <linux/ctype.h>
25 #include <linux/efi.h>
26 #include <linux/suspend.h>
27 #include <acpi/video.h>
30 * This driver is needed because a number of Samsung laptops do not hook
31 * their control settings through ACPI. So we have to poke around in the
32 * BIOS to do things like brightness values, and "special" key controls.
36 * We have 0 - 8 as valid brightness levels. The specs say that level 0 should
37 * be reserved by the BIOS (which really doesn't make much sense), we tell
38 * userspace that the value is 0 - 7 and then just tell the hardware 1 - 8
40 #define MAX_BRIGHT 0x07
43 #define SABI_IFACE_MAIN 0x00
44 #define SABI_IFACE_SUB 0x02
45 #define SABI_IFACE_COMPLETE 0x04
46 #define SABI_IFACE_DATA 0x05
48 #define WL_STATUS_WLAN 0x0
49 #define WL_STATUS_BT 0x2
51 /* Structure get/set data using sabi */
64 struct sabi_header_offsets
{
73 struct sabi_commands
{
75 * Brightness is 0 - 8, as described above.
76 * Value 0 is for the BIOS to use
83 * 0x00 - wireless is off
84 * 0x01 - wireless is on
88 * TODO, verify 3G is correct, that doesn't seem right...
90 u16 get_wireless_button
;
91 u16 set_wireless_button
;
93 /* 0 is off, 1 is on */
98 * 0x80 or 0x00 - no action
99 * 0x81 - recovery key pressed
101 u16 get_recovery_mode
;
102 u16 set_recovery_mode
;
105 * on seclinux: 0 is low, 1 is high,
106 * on swsmi: 0 is normal, 1 is silent, 2 is turbo
108 u16 get_performance_level
;
109 u16 set_performance_level
;
111 /* 0x80 is off, 0x81 is on */
112 u16 get_battery_life_extender
;
113 u16 set_battery_life_extender
;
115 /* 0x80 is off, 0x81 is on */
119 /* the first byte is for bluetooth and the third one is for wlan */
120 u16 get_wireless_status
;
121 u16 set_wireless_status
;
123 /* 0x80 is off, 0x81 is on */
124 u16 get_lid_handling
;
125 u16 set_lid_handling
;
127 /* 0x81 to read, (0x82 | level << 8) to set, 0xaabb to enable */
131 * Tell the BIOS that Linux is running on this machine.
132 * 81 is on, 80 is off
137 struct sabi_performance_level
{
144 const char *test_string
;
146 const struct sabi_header_offsets header_offsets
;
147 const struct sabi_commands commands
;
148 const struct sabi_performance_level performance_levels
[4];
153 static const struct sabi_config sabi_configs
[] = {
155 /* I don't know if it is really 2, but it it is
156 * less than 3 anyway */
159 .test_string
= "SECLINUX",
161 .main_function
= 0x4c49,
169 .data_segment
= 0x07,
173 .get_brightness
= 0x00,
174 .set_brightness
= 0x01,
176 .get_wireless_button
= 0x02,
177 .set_wireless_button
= 0x03,
179 .get_backlight
= 0x04,
180 .set_backlight
= 0x05,
182 .get_recovery_mode
= 0x06,
183 .set_recovery_mode
= 0x07,
185 .get_performance_level
= 0x08,
186 .set_performance_level
= 0x09,
188 .get_battery_life_extender
= 0xFFFF,
189 .set_battery_life_extender
= 0xFFFF,
191 .get_usb_charge
= 0xFFFF,
192 .set_usb_charge
= 0xFFFF,
194 .get_wireless_status
= 0xFFFF,
195 .set_wireless_status
= 0xFFFF,
197 .get_lid_handling
= 0xFFFF,
198 .set_lid_handling
= 0xFFFF,
200 .kbd_backlight
= 0xFFFF,
205 .performance_levels
= {
222 .test_string
= "SwSmi@",
224 .main_function
= 0x5843,
232 .data_segment
= 0x07,
236 .get_brightness
= 0x10,
237 .set_brightness
= 0x11,
239 .get_wireless_button
= 0x12,
240 .set_wireless_button
= 0x13,
242 .get_backlight
= 0x2d,
243 .set_backlight
= 0x2e,
245 .get_recovery_mode
= 0xff,
246 .set_recovery_mode
= 0xff,
248 .get_performance_level
= 0x31,
249 .set_performance_level
= 0x32,
251 .get_battery_life_extender
= 0x65,
252 .set_battery_life_extender
= 0x66,
254 .get_usb_charge
= 0x67,
255 .set_usb_charge
= 0x68,
257 .get_wireless_status
= 0x69,
258 .set_wireless_status
= 0x6a,
260 .get_lid_handling
= 0x6d,
261 .set_lid_handling
= 0x6e,
263 .kbd_backlight
= 0x78,
268 .performance_levels
= {
290 * samsung-laptop/ - debugfs root directory
291 * f0000_segment - dump f0000 segment
292 * command - current command
293 * data - current data
294 * d0, d1, d2, d3 - data fields
295 * call - call SABI using command and data
297 * This allow to call arbitrary sabi commands wihout
298 * modifying the driver at all.
299 * For example, setting the keyboard backlight brightness to 5
301 * echo 0x78 > command
309 struct samsung_laptop_debug
{
311 struct sabi_data data
;
314 struct debugfs_blob_wrapper f0000_wrapper
;
315 struct debugfs_blob_wrapper data_wrapper
;
316 struct debugfs_blob_wrapper sdiag_wrapper
;
319 struct samsung_laptop
;
321 struct samsung_rfkill
{
322 struct samsung_laptop
*samsung
;
323 struct rfkill
*rfkill
;
324 enum rfkill_type type
;
327 struct samsung_laptop
{
328 const struct sabi_config
*config
;
331 void __iomem
*sabi_iface
;
332 void __iomem
*f0000_segment
;
334 struct mutex sabi_mutex
;
336 struct platform_device
*platform_device
;
337 struct backlight_device
*backlight_device
;
339 struct samsung_rfkill wlan
;
340 struct samsung_rfkill bluetooth
;
342 struct led_classdev kbd_led
;
344 struct workqueue_struct
*led_workqueue
;
345 struct work_struct kbd_led_work
;
347 struct samsung_laptop_debug debug
;
348 struct samsung_quirks
*quirks
;
350 struct notifier_block pm_nb
;
352 bool handle_backlight
;
353 bool has_stepping_quirk
;
358 struct samsung_quirks
{
359 bool broken_acpi_video
;
360 bool four_kbd_backlight_levels
;
361 bool enable_kbd_backlight
;
362 bool use_native_backlight
;
366 static struct samsung_quirks samsung_unknown
= {};
368 static struct samsung_quirks samsung_broken_acpi_video
= {
369 .broken_acpi_video
= true,
372 static struct samsung_quirks samsung_use_native_backlight
= {
373 .use_native_backlight
= true,
376 static struct samsung_quirks samsung_np740u3e
= {
377 .four_kbd_backlight_levels
= true,
378 .enable_kbd_backlight
= true,
381 static struct samsung_quirks samsung_lid_handling
= {
382 .lid_handling
= true,
386 module_param(force
, bool, 0);
387 MODULE_PARM_DESC(force
,
388 "Disable the DMI check and forces the driver to be loaded");
391 module_param(debug
, bool, S_IRUGO
| S_IWUSR
);
392 MODULE_PARM_DESC(debug
, "Debug enabled or not");
394 static int sabi_command(struct samsung_laptop
*samsung
, u16 command
,
395 struct sabi_data
*in
,
396 struct sabi_data
*out
)
398 const struct sabi_config
*config
= samsung
->config
;
400 u16 port
= readw(samsung
->sabi
+ config
->header_offsets
.port
);
401 u8 complete
, iface_data
;
403 mutex_lock(&samsung
->sabi_mutex
);
407 pr_info("SABI command:0x%04x "
408 "data:{0x%08x, 0x%08x, 0x%04x, 0x%02x}",
409 command
, in
->d0
, in
->d1
, in
->d2
, in
->d3
);
411 pr_info("SABI command:0x%04x", command
);
414 /* enable memory to be able to write to it */
415 outb(readb(samsung
->sabi
+ config
->header_offsets
.en_mem
), port
);
417 /* write out the command */
418 writew(config
->main_function
, samsung
->sabi_iface
+ SABI_IFACE_MAIN
);
419 writew(command
, samsung
->sabi_iface
+ SABI_IFACE_SUB
);
420 writeb(0, samsung
->sabi_iface
+ SABI_IFACE_COMPLETE
);
422 writel(in
->d0
, samsung
->sabi_iface
+ SABI_IFACE_DATA
);
423 writel(in
->d1
, samsung
->sabi_iface
+ SABI_IFACE_DATA
+ 4);
424 writew(in
->d2
, samsung
->sabi_iface
+ SABI_IFACE_DATA
+ 8);
425 writeb(in
->d3
, samsung
->sabi_iface
+ SABI_IFACE_DATA
+ 10);
427 outb(readb(samsung
->sabi
+ config
->header_offsets
.iface_func
), port
);
429 /* write protect memory to make it safe */
430 outb(readb(samsung
->sabi
+ config
->header_offsets
.re_mem
), port
);
432 /* see if the command actually succeeded */
433 complete
= readb(samsung
->sabi_iface
+ SABI_IFACE_COMPLETE
);
434 iface_data
= readb(samsung
->sabi_iface
+ SABI_IFACE_DATA
);
436 /* iface_data = 0xFF happens when a command is not known
437 * so we only add a warning in debug mode since we will
438 * probably issue some unknown command at startup to find
439 * out which features are supported */
440 if (complete
!= 0xaa || (iface_data
== 0xff && debug
))
441 pr_warn("SABI command 0x%04x failed with"
442 " completion flag 0x%02x and interface data 0x%02x",
443 command
, complete
, iface_data
);
445 if (complete
!= 0xaa || iface_data
== 0xff) {
451 out
->d0
= readl(samsung
->sabi_iface
+ SABI_IFACE_DATA
);
452 out
->d1
= readl(samsung
->sabi_iface
+ SABI_IFACE_DATA
+ 4);
453 out
->d2
= readw(samsung
->sabi_iface
+ SABI_IFACE_DATA
+ 2);
454 out
->d3
= readb(samsung
->sabi_iface
+ SABI_IFACE_DATA
+ 1);
458 pr_info("SABI return data:{0x%08x, 0x%08x, 0x%04x, 0x%02x}",
459 out
->d0
, out
->d1
, out
->d2
, out
->d3
);
463 mutex_unlock(&samsung
->sabi_mutex
);
467 /* simple wrappers usable with most commands */
468 static int sabi_set_commandb(struct samsung_laptop
*samsung
,
469 u16 command
, u8 data
)
471 struct sabi_data in
= { { { .d0
= 0, .d1
= 0, .d2
= 0, .d3
= 0 } } };
474 return sabi_command(samsung
, command
, &in
, NULL
);
477 static int read_brightness(struct samsung_laptop
*samsung
)
479 const struct sabi_config
*config
= samsung
->config
;
480 const struct sabi_commands
*commands
= &samsung
->config
->commands
;
481 struct sabi_data sretval
;
482 int user_brightness
= 0;
485 retval
= sabi_command(samsung
, commands
->get_brightness
,
490 user_brightness
= sretval
.data
[0];
491 if (user_brightness
> config
->min_brightness
)
492 user_brightness
-= config
->min_brightness
;
496 return user_brightness
;
499 static void set_brightness(struct samsung_laptop
*samsung
, u8 user_brightness
)
501 const struct sabi_config
*config
= samsung
->config
;
502 const struct sabi_commands
*commands
= &samsung
->config
->commands
;
503 u8 user_level
= user_brightness
+ config
->min_brightness
;
505 if (samsung
->has_stepping_quirk
&& user_level
!= 0) {
507 * short circuit if the specified level is what's already set
508 * to prevent the screen from flickering needlessly
510 if (user_brightness
== read_brightness(samsung
))
513 sabi_set_commandb(samsung
, commands
->set_brightness
, 0);
516 sabi_set_commandb(samsung
, commands
->set_brightness
, user_level
);
519 static int get_brightness(struct backlight_device
*bd
)
521 struct samsung_laptop
*samsung
= bl_get_data(bd
);
523 return read_brightness(samsung
);
526 static void check_for_stepping_quirk(struct samsung_laptop
*samsung
)
530 int orig_level
= read_brightness(samsung
);
533 * Some laptops exhibit the strange behaviour of stepping toward
534 * (rather than setting) the brightness except when changing to/from
535 * brightness level 0. This behaviour is checked for here and worked
536 * around in set_brightness.
540 set_brightness(samsung
, 1);
542 initial_level
= read_brightness(samsung
);
544 if (initial_level
<= 2)
545 check_level
= initial_level
+ 2;
547 check_level
= initial_level
- 2;
549 samsung
->has_stepping_quirk
= false;
550 set_brightness(samsung
, check_level
);
552 if (read_brightness(samsung
) != check_level
) {
553 samsung
->has_stepping_quirk
= true;
554 pr_info("enabled workaround for brightness stepping quirk\n");
557 set_brightness(samsung
, orig_level
);
560 static int update_status(struct backlight_device
*bd
)
562 struct samsung_laptop
*samsung
= bl_get_data(bd
);
563 const struct sabi_commands
*commands
= &samsung
->config
->commands
;
565 set_brightness(samsung
, bd
->props
.brightness
);
567 if (bd
->props
.power
== FB_BLANK_UNBLANK
)
568 sabi_set_commandb(samsung
, commands
->set_backlight
, 1);
570 sabi_set_commandb(samsung
, commands
->set_backlight
, 0);
575 static const struct backlight_ops backlight_ops
= {
576 .get_brightness
= get_brightness
,
577 .update_status
= update_status
,
580 static int seclinux_rfkill_set(void *data
, bool blocked
)
582 struct samsung_rfkill
*srfkill
= data
;
583 struct samsung_laptop
*samsung
= srfkill
->samsung
;
584 const struct sabi_commands
*commands
= &samsung
->config
->commands
;
586 return sabi_set_commandb(samsung
, commands
->set_wireless_button
,
590 static const struct rfkill_ops seclinux_rfkill_ops
= {
591 .set_block
= seclinux_rfkill_set
,
594 static int swsmi_wireless_status(struct samsung_laptop
*samsung
,
595 struct sabi_data
*data
)
597 const struct sabi_commands
*commands
= &samsung
->config
->commands
;
599 return sabi_command(samsung
, commands
->get_wireless_status
,
603 static int swsmi_rfkill_set(void *priv
, bool blocked
)
605 struct samsung_rfkill
*srfkill
= priv
;
606 struct samsung_laptop
*samsung
= srfkill
->samsung
;
607 const struct sabi_commands
*commands
= &samsung
->config
->commands
;
608 struct sabi_data data
;
611 ret
= swsmi_wireless_status(samsung
, &data
);
615 /* Don't set the state for non-present devices */
616 for (i
= 0; i
< 4; i
++)
617 if (data
.data
[i
] == 0x02)
620 if (srfkill
->type
== RFKILL_TYPE_WLAN
)
621 data
.data
[WL_STATUS_WLAN
] = !blocked
;
622 else if (srfkill
->type
== RFKILL_TYPE_BLUETOOTH
)
623 data
.data
[WL_STATUS_BT
] = !blocked
;
625 return sabi_command(samsung
, commands
->set_wireless_status
,
629 static void swsmi_rfkill_query(struct rfkill
*rfkill
, void *priv
)
631 struct samsung_rfkill
*srfkill
= priv
;
632 struct samsung_laptop
*samsung
= srfkill
->samsung
;
633 struct sabi_data data
;
636 ret
= swsmi_wireless_status(samsung
, &data
);
640 if (srfkill
->type
== RFKILL_TYPE_WLAN
)
641 ret
= data
.data
[WL_STATUS_WLAN
];
642 else if (srfkill
->type
== RFKILL_TYPE_BLUETOOTH
)
643 ret
= data
.data
[WL_STATUS_BT
];
647 rfkill_set_sw_state(rfkill
, !ret
);
650 static const struct rfkill_ops swsmi_rfkill_ops
= {
651 .set_block
= swsmi_rfkill_set
,
652 .query
= swsmi_rfkill_query
,
655 static ssize_t
get_performance_level(struct device
*dev
,
656 struct device_attribute
*attr
, char *buf
)
658 struct samsung_laptop
*samsung
= dev_get_drvdata(dev
);
659 const struct sabi_config
*config
= samsung
->config
;
660 const struct sabi_commands
*commands
= &config
->commands
;
661 struct sabi_data sretval
;
666 retval
= sabi_command(samsung
, commands
->get_performance_level
,
671 /* The logic is backwards, yeah, lots of fun... */
672 for (i
= 0; config
->performance_levels
[i
].name
; ++i
) {
673 if (sretval
.data
[0] == config
->performance_levels
[i
].value
)
674 return sprintf(buf
, "%s\n", config
->performance_levels
[i
].name
);
676 return sprintf(buf
, "%s\n", "unknown");
679 static ssize_t
set_performance_level(struct device
*dev
,
680 struct device_attribute
*attr
, const char *buf
,
683 struct samsung_laptop
*samsung
= dev_get_drvdata(dev
);
684 const struct sabi_config
*config
= samsung
->config
;
685 const struct sabi_commands
*commands
= &config
->commands
;
691 for (i
= 0; config
->performance_levels
[i
].name
; ++i
) {
692 const struct sabi_performance_level
*level
=
693 &config
->performance_levels
[i
];
694 if (!strncasecmp(level
->name
, buf
, strlen(level
->name
))) {
695 sabi_set_commandb(samsung
,
696 commands
->set_performance_level
,
702 if (!config
->performance_levels
[i
].name
)
708 static DEVICE_ATTR(performance_level
, S_IWUSR
| S_IRUGO
,
709 get_performance_level
, set_performance_level
);
711 static int read_battery_life_extender(struct samsung_laptop
*samsung
)
713 const struct sabi_commands
*commands
= &samsung
->config
->commands
;
714 struct sabi_data data
;
717 if (commands
->get_battery_life_extender
== 0xFFFF)
720 memset(&data
, 0, sizeof(data
));
722 retval
= sabi_command(samsung
, commands
->get_battery_life_extender
,
728 if (data
.data
[0] != 0 && data
.data
[0] != 1)
734 static int write_battery_life_extender(struct samsung_laptop
*samsung
,
737 const struct sabi_commands
*commands
= &samsung
->config
->commands
;
738 struct sabi_data data
;
740 memset(&data
, 0, sizeof(data
));
741 data
.data
[0] = 0x80 | enabled
;
742 return sabi_command(samsung
, commands
->set_battery_life_extender
,
746 static ssize_t
get_battery_life_extender(struct device
*dev
,
747 struct device_attribute
*attr
,
750 struct samsung_laptop
*samsung
= dev_get_drvdata(dev
);
753 ret
= read_battery_life_extender(samsung
);
757 return sprintf(buf
, "%d\n", ret
);
760 static ssize_t
set_battery_life_extender(struct device
*dev
,
761 struct device_attribute
*attr
,
762 const char *buf
, size_t count
)
764 struct samsung_laptop
*samsung
= dev_get_drvdata(dev
);
767 if (!count
|| kstrtoint(buf
, 0, &value
) != 0)
770 ret
= write_battery_life_extender(samsung
, !!value
);
777 static DEVICE_ATTR(battery_life_extender
, S_IWUSR
| S_IRUGO
,
778 get_battery_life_extender
, set_battery_life_extender
);
780 static int read_usb_charge(struct samsung_laptop
*samsung
)
782 const struct sabi_commands
*commands
= &samsung
->config
->commands
;
783 struct sabi_data data
;
786 if (commands
->get_usb_charge
== 0xFFFF)
789 memset(&data
, 0, sizeof(data
));
791 retval
= sabi_command(samsung
, commands
->get_usb_charge
,
797 if (data
.data
[0] != 0 && data
.data
[0] != 1)
803 static int write_usb_charge(struct samsung_laptop
*samsung
,
806 const struct sabi_commands
*commands
= &samsung
->config
->commands
;
807 struct sabi_data data
;
809 memset(&data
, 0, sizeof(data
));
810 data
.data
[0] = 0x80 | enabled
;
811 return sabi_command(samsung
, commands
->set_usb_charge
,
815 static ssize_t
get_usb_charge(struct device
*dev
,
816 struct device_attribute
*attr
,
819 struct samsung_laptop
*samsung
= dev_get_drvdata(dev
);
822 ret
= read_usb_charge(samsung
);
826 return sprintf(buf
, "%d\n", ret
);
829 static ssize_t
set_usb_charge(struct device
*dev
,
830 struct device_attribute
*attr
,
831 const char *buf
, size_t count
)
833 struct samsung_laptop
*samsung
= dev_get_drvdata(dev
);
836 if (!count
|| kstrtoint(buf
, 0, &value
) != 0)
839 ret
= write_usb_charge(samsung
, !!value
);
846 static DEVICE_ATTR(usb_charge
, S_IWUSR
| S_IRUGO
,
847 get_usb_charge
, set_usb_charge
);
849 static int read_lid_handling(struct samsung_laptop
*samsung
)
851 const struct sabi_commands
*commands
= &samsung
->config
->commands
;
852 struct sabi_data data
;
855 if (commands
->get_lid_handling
== 0xFFFF)
858 memset(&data
, 0, sizeof(data
));
859 retval
= sabi_command(samsung
, commands
->get_lid_handling
,
865 return data
.data
[0] & 0x1;
868 static int write_lid_handling(struct samsung_laptop
*samsung
,
871 const struct sabi_commands
*commands
= &samsung
->config
->commands
;
872 struct sabi_data data
;
874 memset(&data
, 0, sizeof(data
));
875 data
.data
[0] = 0x80 | enabled
;
876 return sabi_command(samsung
, commands
->set_lid_handling
,
880 static ssize_t
get_lid_handling(struct device
*dev
,
881 struct device_attribute
*attr
,
884 struct samsung_laptop
*samsung
= dev_get_drvdata(dev
);
887 ret
= read_lid_handling(samsung
);
891 return sprintf(buf
, "%d\n", ret
);
894 static ssize_t
set_lid_handling(struct device
*dev
,
895 struct device_attribute
*attr
,
896 const char *buf
, size_t count
)
898 struct samsung_laptop
*samsung
= dev_get_drvdata(dev
);
901 if (!count
|| kstrtoint(buf
, 0, &value
) != 0)
904 ret
= write_lid_handling(samsung
, !!value
);
911 static DEVICE_ATTR(lid_handling
, S_IWUSR
| S_IRUGO
,
912 get_lid_handling
, set_lid_handling
);
914 static struct attribute
*platform_attributes
[] = {
915 &dev_attr_performance_level
.attr
,
916 &dev_attr_battery_life_extender
.attr
,
917 &dev_attr_usb_charge
.attr
,
918 &dev_attr_lid_handling
.attr
,
922 static int find_signature(void __iomem
*memcheck
, const char *testStr
)
927 for (loca
= 0; loca
< 0xffff; loca
++) {
928 char temp
= readb(memcheck
+ loca
);
930 if (temp
== testStr
[i
]) {
931 if (i
== strlen(testStr
)-1)
941 static void samsung_rfkill_exit(struct samsung_laptop
*samsung
)
943 if (samsung
->wlan
.rfkill
) {
944 rfkill_unregister(samsung
->wlan
.rfkill
);
945 rfkill_destroy(samsung
->wlan
.rfkill
);
946 samsung
->wlan
.rfkill
= NULL
;
948 if (samsung
->bluetooth
.rfkill
) {
949 rfkill_unregister(samsung
->bluetooth
.rfkill
);
950 rfkill_destroy(samsung
->bluetooth
.rfkill
);
951 samsung
->bluetooth
.rfkill
= NULL
;
955 static int samsung_new_rfkill(struct samsung_laptop
*samsung
,
956 struct samsung_rfkill
*arfkill
,
957 const char *name
, enum rfkill_type type
,
958 const struct rfkill_ops
*ops
,
961 struct rfkill
**rfkill
= &arfkill
->rfkill
;
964 arfkill
->type
= type
;
965 arfkill
->samsung
= samsung
;
967 *rfkill
= rfkill_alloc(name
, &samsung
->platform_device
->dev
,
974 rfkill_init_sw_state(*rfkill
, blocked
);
976 ret
= rfkill_register(*rfkill
);
978 rfkill_destroy(*rfkill
);
985 static int __init
samsung_rfkill_init_seclinux(struct samsung_laptop
*samsung
)
987 return samsung_new_rfkill(samsung
, &samsung
->wlan
, "samsung-wlan",
988 RFKILL_TYPE_WLAN
, &seclinux_rfkill_ops
, -1);
991 static int __init
samsung_rfkill_init_swsmi(struct samsung_laptop
*samsung
)
993 struct sabi_data data
;
996 ret
= swsmi_wireless_status(samsung
, &data
);
998 /* Some swsmi laptops use the old seclinux way to control
999 * wireless devices */
1001 ret
= samsung_rfkill_init_seclinux(samsung
);
1005 /* 0x02 seems to mean that the device is no present/available */
1007 if (data
.data
[WL_STATUS_WLAN
] != 0x02)
1008 ret
= samsung_new_rfkill(samsung
, &samsung
->wlan
,
1012 !data
.data
[WL_STATUS_WLAN
]);
1016 if (data
.data
[WL_STATUS_BT
] != 0x02)
1017 ret
= samsung_new_rfkill(samsung
, &samsung
->bluetooth
,
1018 "samsung-bluetooth",
1019 RFKILL_TYPE_BLUETOOTH
,
1021 !data
.data
[WL_STATUS_BT
]);
1027 samsung_rfkill_exit(samsung
);
1032 static int __init
samsung_rfkill_init(struct samsung_laptop
*samsung
)
1034 if (samsung
->config
->sabi_version
== 2)
1035 return samsung_rfkill_init_seclinux(samsung
);
1036 if (samsung
->config
->sabi_version
== 3)
1037 return samsung_rfkill_init_swsmi(samsung
);
1041 static void samsung_lid_handling_exit(struct samsung_laptop
*samsung
)
1043 if (samsung
->quirks
->lid_handling
)
1044 write_lid_handling(samsung
, 0);
1047 static int __init
samsung_lid_handling_init(struct samsung_laptop
*samsung
)
1051 if (samsung
->quirks
->lid_handling
)
1052 retval
= write_lid_handling(samsung
, 1);
1057 static int kbd_backlight_enable(struct samsung_laptop
*samsung
)
1059 const struct sabi_commands
*commands
= &samsung
->config
->commands
;
1060 struct sabi_data data
;
1063 if (commands
->kbd_backlight
== 0xFFFF)
1066 memset(&data
, 0, sizeof(data
));
1068 retval
= sabi_command(samsung
, commands
->kbd_backlight
,
1074 if (data
.d0
!= 0xccdd)
1079 static int kbd_backlight_read(struct samsung_laptop
*samsung
)
1081 const struct sabi_commands
*commands
= &samsung
->config
->commands
;
1082 struct sabi_data data
;
1085 memset(&data
, 0, sizeof(data
));
1086 data
.data
[0] = 0x81;
1087 retval
= sabi_command(samsung
, commands
->kbd_backlight
,
1093 return data
.data
[0];
1096 static int kbd_backlight_write(struct samsung_laptop
*samsung
, int brightness
)
1098 const struct sabi_commands
*commands
= &samsung
->config
->commands
;
1099 struct sabi_data data
;
1101 memset(&data
, 0, sizeof(data
));
1102 data
.d0
= 0x82 | ((brightness
& 0xFF) << 8);
1103 return sabi_command(samsung
, commands
->kbd_backlight
,
1107 static void kbd_led_update(struct work_struct
*work
)
1109 struct samsung_laptop
*samsung
;
1111 samsung
= container_of(work
, struct samsung_laptop
, kbd_led_work
);
1112 kbd_backlight_write(samsung
, samsung
->kbd_led_wk
);
1115 static void kbd_led_set(struct led_classdev
*led_cdev
,
1116 enum led_brightness value
)
1118 struct samsung_laptop
*samsung
;
1120 samsung
= container_of(led_cdev
, struct samsung_laptop
, kbd_led
);
1122 if (value
> samsung
->kbd_led
.max_brightness
)
1123 value
= samsung
->kbd_led
.max_brightness
;
1127 samsung
->kbd_led_wk
= value
;
1128 queue_work(samsung
->led_workqueue
, &samsung
->kbd_led_work
);
1131 static enum led_brightness
kbd_led_get(struct led_classdev
*led_cdev
)
1133 struct samsung_laptop
*samsung
;
1135 samsung
= container_of(led_cdev
, struct samsung_laptop
, kbd_led
);
1136 return kbd_backlight_read(samsung
);
1139 static void samsung_leds_exit(struct samsung_laptop
*samsung
)
1141 led_classdev_unregister(&samsung
->kbd_led
);
1142 if (samsung
->led_workqueue
)
1143 destroy_workqueue(samsung
->led_workqueue
);
1146 static int __init
samsung_leds_init(struct samsung_laptop
*samsung
)
1150 samsung
->led_workqueue
= create_singlethread_workqueue("led_workqueue");
1151 if (!samsung
->led_workqueue
)
1154 if (kbd_backlight_enable(samsung
) >= 0) {
1155 INIT_WORK(&samsung
->kbd_led_work
, kbd_led_update
);
1157 samsung
->kbd_led
.name
= "samsung::kbd_backlight";
1158 samsung
->kbd_led
.brightness_set
= kbd_led_set
;
1159 samsung
->kbd_led
.brightness_get
= kbd_led_get
;
1160 samsung
->kbd_led
.max_brightness
= 8;
1161 if (samsung
->quirks
->four_kbd_backlight_levels
)
1162 samsung
->kbd_led
.max_brightness
= 4;
1164 ret
= led_classdev_register(&samsung
->platform_device
->dev
,
1169 samsung_leds_exit(samsung
);
1174 static void samsung_backlight_exit(struct samsung_laptop
*samsung
)
1176 if (samsung
->backlight_device
) {
1177 backlight_device_unregister(samsung
->backlight_device
);
1178 samsung
->backlight_device
= NULL
;
1182 static int __init
samsung_backlight_init(struct samsung_laptop
*samsung
)
1184 struct backlight_device
*bd
;
1185 struct backlight_properties props
;
1187 if (!samsung
->handle_backlight
)
1190 memset(&props
, 0, sizeof(struct backlight_properties
));
1191 props
.type
= BACKLIGHT_PLATFORM
;
1192 props
.max_brightness
= samsung
->config
->max_brightness
-
1193 samsung
->config
->min_brightness
;
1195 bd
= backlight_device_register("samsung",
1196 &samsung
->platform_device
->dev
,
1197 samsung
, &backlight_ops
,
1202 samsung
->backlight_device
= bd
;
1203 samsung
->backlight_device
->props
.brightness
= read_brightness(samsung
);
1204 samsung
->backlight_device
->props
.power
= FB_BLANK_UNBLANK
;
1205 backlight_update_status(samsung
->backlight_device
);
1210 static umode_t
samsung_sysfs_is_visible(struct kobject
*kobj
,
1211 struct attribute
*attr
, int idx
)
1213 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
1214 struct samsung_laptop
*samsung
= dev_get_drvdata(dev
);
1217 if (attr
== &dev_attr_performance_level
.attr
)
1218 ok
= !!samsung
->config
->performance_levels
[0].name
;
1219 if (attr
== &dev_attr_battery_life_extender
.attr
)
1220 ok
= !!(read_battery_life_extender(samsung
) >= 0);
1221 if (attr
== &dev_attr_usb_charge
.attr
)
1222 ok
= !!(read_usb_charge(samsung
) >= 0);
1223 if (attr
== &dev_attr_lid_handling
.attr
)
1224 ok
= !!(read_lid_handling(samsung
) >= 0);
1226 return ok
? attr
->mode
: 0;
1229 static const struct attribute_group platform_attribute_group
= {
1230 .is_visible
= samsung_sysfs_is_visible
,
1231 .attrs
= platform_attributes
1234 static void samsung_sysfs_exit(struct samsung_laptop
*samsung
)
1236 struct platform_device
*device
= samsung
->platform_device
;
1238 sysfs_remove_group(&device
->dev
.kobj
, &platform_attribute_group
);
1241 static int __init
samsung_sysfs_init(struct samsung_laptop
*samsung
)
1243 struct platform_device
*device
= samsung
->platform_device
;
1245 return sysfs_create_group(&device
->dev
.kobj
, &platform_attribute_group
);
1249 static int samsung_laptop_call_show(struct seq_file
*m
, void *data
)
1251 struct samsung_laptop
*samsung
= m
->private;
1252 struct sabi_data
*sdata
= &samsung
->debug
.data
;
1255 seq_printf(m
, "SABI 0x%04x {0x%08x, 0x%08x, 0x%04x, 0x%02x}\n",
1256 samsung
->debug
.command
,
1257 sdata
->d0
, sdata
->d1
, sdata
->d2
, sdata
->d3
);
1259 ret
= sabi_command(samsung
, samsung
->debug
.command
, sdata
, sdata
);
1262 seq_printf(m
, "SABI command 0x%04x failed\n",
1263 samsung
->debug
.command
);
1267 seq_printf(m
, "SABI {0x%08x, 0x%08x, 0x%04x, 0x%02x}\n",
1268 sdata
->d0
, sdata
->d1
, sdata
->d2
, sdata
->d3
);
1271 DEFINE_SHOW_ATTRIBUTE(samsung_laptop_call
);
1273 static void samsung_debugfs_exit(struct samsung_laptop
*samsung
)
1275 debugfs_remove_recursive(samsung
->debug
.root
);
1278 static void samsung_debugfs_init(struct samsung_laptop
*samsung
)
1280 struct dentry
*root
;
1282 root
= debugfs_create_dir("samsung-laptop", NULL
);
1283 samsung
->debug
.root
= root
;
1285 samsung
->debug
.f0000_wrapper
.data
= samsung
->f0000_segment
;
1286 samsung
->debug
.f0000_wrapper
.size
= 0xffff;
1288 samsung
->debug
.data_wrapper
.data
= &samsung
->debug
.data
;
1289 samsung
->debug
.data_wrapper
.size
= sizeof(samsung
->debug
.data
);
1291 samsung
->debug
.sdiag_wrapper
.data
= samsung
->sdiag
;
1292 samsung
->debug
.sdiag_wrapper
.size
= strlen(samsung
->sdiag
);
1294 debugfs_create_u16("command", S_IRUGO
| S_IWUSR
, root
,
1295 &samsung
->debug
.command
);
1296 debugfs_create_u32("d0", S_IRUGO
| S_IWUSR
, root
,
1297 &samsung
->debug
.data
.d0
);
1298 debugfs_create_u32("d1", S_IRUGO
| S_IWUSR
, root
,
1299 &samsung
->debug
.data
.d1
);
1300 debugfs_create_u16("d2", S_IRUGO
| S_IWUSR
, root
,
1301 &samsung
->debug
.data
.d2
);
1302 debugfs_create_u8("d3", S_IRUGO
| S_IWUSR
, root
,
1303 &samsung
->debug
.data
.d3
);
1304 debugfs_create_blob("data", S_IRUGO
| S_IWUSR
, root
,
1305 &samsung
->debug
.data_wrapper
);
1306 debugfs_create_blob("f0000_segment", S_IRUSR
| S_IWUSR
, root
,
1307 &samsung
->debug
.f0000_wrapper
);
1308 debugfs_create_file("call", S_IFREG
| S_IRUGO
, root
, samsung
,
1309 &samsung_laptop_call_fops
);
1310 debugfs_create_blob("sdiag", S_IRUGO
| S_IWUSR
, root
,
1311 &samsung
->debug
.sdiag_wrapper
);
1314 static void samsung_sabi_exit(struct samsung_laptop
*samsung
)
1316 const struct sabi_config
*config
= samsung
->config
;
1318 /* Turn off "Linux" mode in the BIOS */
1319 if (config
&& config
->commands
.set_linux
!= 0xff)
1320 sabi_set_commandb(samsung
, config
->commands
.set_linux
, 0x80);
1322 if (samsung
->sabi_iface
) {
1323 iounmap(samsung
->sabi_iface
);
1324 samsung
->sabi_iface
= NULL
;
1326 if (samsung
->f0000_segment
) {
1327 iounmap(samsung
->f0000_segment
);
1328 samsung
->f0000_segment
= NULL
;
1331 samsung
->config
= NULL
;
1334 static __init
void samsung_sabi_infos(struct samsung_laptop
*samsung
, int loca
,
1335 unsigned int ifaceP
)
1337 const struct sabi_config
*config
= samsung
->config
;
1339 printk(KERN_DEBUG
"This computer supports SABI==%x\n",
1340 loca
+ 0xf0000 - 6);
1342 printk(KERN_DEBUG
"SABI header:\n");
1343 printk(KERN_DEBUG
" SMI Port Number = 0x%04x\n",
1344 readw(samsung
->sabi
+ config
->header_offsets
.port
));
1345 printk(KERN_DEBUG
" SMI Interface Function = 0x%02x\n",
1346 readb(samsung
->sabi
+ config
->header_offsets
.iface_func
));
1347 printk(KERN_DEBUG
" SMI enable memory buffer = 0x%02x\n",
1348 readb(samsung
->sabi
+ config
->header_offsets
.en_mem
));
1349 printk(KERN_DEBUG
" SMI restore memory buffer = 0x%02x\n",
1350 readb(samsung
->sabi
+ config
->header_offsets
.re_mem
));
1351 printk(KERN_DEBUG
" SABI data offset = 0x%04x\n",
1352 readw(samsung
->sabi
+ config
->header_offsets
.data_offset
));
1353 printk(KERN_DEBUG
" SABI data segment = 0x%04x\n",
1354 readw(samsung
->sabi
+ config
->header_offsets
.data_segment
));
1356 printk(KERN_DEBUG
" SABI pointer = 0x%08x\n", ifaceP
);
1359 static void __init
samsung_sabi_diag(struct samsung_laptop
*samsung
)
1361 int loca
= find_signature(samsung
->f0000_segment
, "SDiaG@");
1368 * Ident: @SDiaG@686XX-N90X3A/966-SEC-07HL-S90X3A
1370 * Product name: 90X3A
1371 * BIOS Version: 07HL
1374 for (i
= 0; loca
< 0xffff && i
< sizeof(samsung
->sdiag
) - 1; loca
++) {
1375 char temp
= readb(samsung
->f0000_segment
+ loca
);
1377 if (isalnum(temp
) || temp
== '/' || temp
== '-')
1378 samsung
->sdiag
[i
++] = temp
;
1383 if (debug
&& samsung
->sdiag
[0])
1384 pr_info("sdiag: %s", samsung
->sdiag
);
1387 static int __init
samsung_sabi_init(struct samsung_laptop
*samsung
)
1389 const struct sabi_config
*config
= NULL
;
1390 const struct sabi_commands
*commands
;
1391 unsigned int ifaceP
;
1396 samsung
->f0000_segment
= ioremap(0xf0000, 0xffff);
1397 if (!samsung
->f0000_segment
) {
1399 pr_err("Can't map the segment at 0xf0000\n");
1404 samsung_sabi_diag(samsung
);
1406 /* Try to find one of the signatures in memory to find the header */
1407 for (i
= 0; sabi_configs
[i
].test_string
!= NULL
; ++i
) {
1408 samsung
->config
= &sabi_configs
[i
];
1409 loca
= find_signature(samsung
->f0000_segment
,
1410 samsung
->config
->test_string
);
1415 if (loca
== 0xffff) {
1417 pr_err("This computer does not support SABI\n");
1422 config
= samsung
->config
;
1423 commands
= &config
->commands
;
1425 /* point to the SMI port Number */
1427 samsung
->sabi
= (samsung
->f0000_segment
+ loca
);
1429 /* Get a pointer to the SABI Interface */
1430 ifaceP
= (readw(samsung
->sabi
+ config
->header_offsets
.data_segment
) & 0x0ffff) << 4;
1431 ifaceP
+= readw(samsung
->sabi
+ config
->header_offsets
.data_offset
) & 0x0ffff;
1434 samsung_sabi_infos(samsung
, loca
, ifaceP
);
1436 samsung
->sabi_iface
= ioremap(ifaceP
, 16);
1437 if (!samsung
->sabi_iface
) {
1438 pr_err("Can't remap %x\n", ifaceP
);
1443 /* Turn on "Linux" mode in the BIOS */
1444 if (commands
->set_linux
!= 0xff) {
1445 int retval
= sabi_set_commandb(samsung
,
1446 commands
->set_linux
, 0x81);
1448 pr_warn("Linux mode was not set!\n");
1454 /* Check for stepping quirk */
1455 if (samsung
->handle_backlight
)
1456 check_for_stepping_quirk(samsung
);
1458 pr_info("detected SABI interface: %s\n",
1459 samsung
->config
->test_string
);
1463 samsung_sabi_exit(samsung
);
1468 static void samsung_platform_exit(struct samsung_laptop
*samsung
)
1470 if (samsung
->platform_device
) {
1471 platform_device_unregister(samsung
->platform_device
);
1472 samsung
->platform_device
= NULL
;
1476 static int samsung_pm_notification(struct notifier_block
*nb
,
1477 unsigned long val
, void *ptr
)
1479 struct samsung_laptop
*samsung
;
1481 samsung
= container_of(nb
, struct samsung_laptop
, pm_nb
);
1482 if (val
== PM_POST_HIBERNATION
&&
1483 samsung
->quirks
->enable_kbd_backlight
)
1484 kbd_backlight_enable(samsung
);
1486 if (val
== PM_POST_HIBERNATION
&& samsung
->quirks
->lid_handling
)
1487 write_lid_handling(samsung
, 1);
1492 static int __init
samsung_platform_init(struct samsung_laptop
*samsung
)
1494 struct platform_device
*pdev
;
1496 pdev
= platform_device_register_simple("samsung", -1, NULL
, 0);
1498 return PTR_ERR(pdev
);
1500 samsung
->platform_device
= pdev
;
1501 platform_set_drvdata(samsung
->platform_device
, samsung
);
1505 static struct samsung_quirks
*quirks
;
1507 static int __init
samsung_dmi_matched(const struct dmi_system_id
*d
)
1509 quirks
= d
->driver_data
;
1513 static const struct dmi_system_id samsung_dmi_table
[] __initconst
= {
1516 DMI_MATCH(DMI_SYS_VENDOR
,
1517 "SAMSUNG ELECTRONICS CO., LTD."),
1518 DMI_MATCH(DMI_CHASSIS_TYPE
, "8"), /* Portable */
1523 DMI_MATCH(DMI_SYS_VENDOR
,
1524 "SAMSUNG ELECTRONICS CO., LTD."),
1525 DMI_MATCH(DMI_CHASSIS_TYPE
, "9"), /* Laptop */
1530 DMI_MATCH(DMI_SYS_VENDOR
,
1531 "SAMSUNG ELECTRONICS CO., LTD."),
1532 DMI_MATCH(DMI_CHASSIS_TYPE
, "10"), /* Notebook */
1537 DMI_MATCH(DMI_SYS_VENDOR
,
1538 "SAMSUNG ELECTRONICS CO., LTD."),
1539 DMI_MATCH(DMI_CHASSIS_TYPE
, "14"), /* Sub-Notebook */
1542 /* DMI ids for laptops with bad Chassis Type */
1546 DMI_MATCH(DMI_SYS_VENDOR
, "SAMSUNG ELECTRONICS CO., LTD."),
1547 DMI_MATCH(DMI_PRODUCT_NAME
, "R40/R41"),
1548 DMI_MATCH(DMI_BOARD_NAME
, "R40/R41"),
1551 /* Specific DMI ids for laptop with quirks */
1553 .callback
= samsung_dmi_matched
,
1556 DMI_MATCH(DMI_SYS_VENDOR
, "SAMSUNG ELECTRONICS CO., LTD."),
1557 DMI_MATCH(DMI_PRODUCT_NAME
, "N150P"),
1558 DMI_MATCH(DMI_BOARD_NAME
, "N150P"),
1560 .driver_data
= &samsung_use_native_backlight
,
1563 .callback
= samsung_dmi_matched
,
1564 .ident
= "N145P/N250P/N260P",
1566 DMI_MATCH(DMI_SYS_VENDOR
, "SAMSUNG ELECTRONICS CO., LTD."),
1567 DMI_MATCH(DMI_PRODUCT_NAME
, "N145P/N250P/N260P"),
1568 DMI_MATCH(DMI_BOARD_NAME
, "N145P/N250P/N260P"),
1570 .driver_data
= &samsung_use_native_backlight
,
1573 .callback
= samsung_dmi_matched
,
1574 .ident
= "N150/N210/N220",
1576 DMI_MATCH(DMI_SYS_VENDOR
, "SAMSUNG ELECTRONICS CO., LTD."),
1577 DMI_MATCH(DMI_PRODUCT_NAME
, "N150/N210/N220"),
1578 DMI_MATCH(DMI_BOARD_NAME
, "N150/N210/N220"),
1580 .driver_data
= &samsung_broken_acpi_video
,
1583 .callback
= samsung_dmi_matched
,
1584 .ident
= "NF110/NF210/NF310",
1586 DMI_MATCH(DMI_SYS_VENDOR
, "SAMSUNG ELECTRONICS CO., LTD."),
1587 DMI_MATCH(DMI_PRODUCT_NAME
, "NF110/NF210/NF310"),
1588 DMI_MATCH(DMI_BOARD_NAME
, "NF110/NF210/NF310"),
1590 .driver_data
= &samsung_broken_acpi_video
,
1593 .callback
= samsung_dmi_matched
,
1596 DMI_MATCH(DMI_SYS_VENDOR
, "SAMSUNG ELECTRONICS CO., LTD."),
1597 DMI_MATCH(DMI_PRODUCT_NAME
, "X360"),
1598 DMI_MATCH(DMI_BOARD_NAME
, "X360"),
1600 .driver_data
= &samsung_broken_acpi_video
,
1603 .callback
= samsung_dmi_matched
,
1606 DMI_MATCH(DMI_SYS_VENDOR
, "SAMSUNG ELECTRONICS CO., LTD."),
1607 DMI_MATCH(DMI_PRODUCT_NAME
, "N250P"),
1608 DMI_MATCH(DMI_BOARD_NAME
, "N250P"),
1610 .driver_data
= &samsung_use_native_backlight
,
1613 .callback
= samsung_dmi_matched
,
1616 DMI_MATCH(DMI_SYS_VENDOR
, "SAMSUNG ELECTRONICS CO., LTD."),
1617 DMI_MATCH(DMI_PRODUCT_NAME
, "NC210/NC110"),
1618 DMI_MATCH(DMI_BOARD_NAME
, "NC210/NC110"),
1620 .driver_data
= &samsung_broken_acpi_video
,
1623 .callback
= samsung_dmi_matched
,
1624 .ident
= "730U3E/740U3E",
1626 DMI_MATCH(DMI_SYS_VENDOR
, "SAMSUNG ELECTRONICS CO., LTD."),
1627 DMI_MATCH(DMI_PRODUCT_NAME
, "730U3E/740U3E"),
1629 .driver_data
= &samsung_np740u3e
,
1632 .callback
= samsung_dmi_matched
,
1633 .ident
= "300V3Z/300V4Z/300V5Z",
1635 DMI_MATCH(DMI_SYS_VENDOR
, "SAMSUNG ELECTRONICS CO., LTD."),
1636 DMI_MATCH(DMI_PRODUCT_NAME
, "300V3Z/300V4Z/300V5Z"),
1638 .driver_data
= &samsung_lid_handling
,
1642 MODULE_DEVICE_TABLE(dmi
, samsung_dmi_table
);
1644 static struct platform_device
*samsung_platform_device
;
1646 static int __init
samsung_init(void)
1648 struct samsung_laptop
*samsung
;
1651 if (efi_enabled(EFI_BOOT
))
1654 quirks
= &samsung_unknown
;
1655 if (!force
&& !dmi_check_system(samsung_dmi_table
))
1658 samsung
= kzalloc(sizeof(*samsung
), GFP_KERNEL
);
1662 mutex_init(&samsung
->sabi_mutex
);
1663 samsung
->handle_backlight
= true;
1664 samsung
->quirks
= quirks
;
1667 if (samsung
->quirks
->broken_acpi_video
)
1668 acpi_video_set_dmi_backlight_type(acpi_backlight_vendor
);
1669 if (samsung
->quirks
->use_native_backlight
)
1670 acpi_video_set_dmi_backlight_type(acpi_backlight_native
);
1672 if (acpi_video_get_backlight_type() != acpi_backlight_vendor
)
1673 samsung
->handle_backlight
= false;
1676 ret
= samsung_platform_init(samsung
);
1678 goto error_platform
;
1680 ret
= samsung_sabi_init(samsung
);
1684 ret
= samsung_sysfs_init(samsung
);
1688 ret
= samsung_backlight_init(samsung
);
1690 goto error_backlight
;
1692 ret
= samsung_rfkill_init(samsung
);
1696 ret
= samsung_leds_init(samsung
);
1700 ret
= samsung_lid_handling_init(samsung
);
1702 goto error_lid_handling
;
1704 samsung_debugfs_init(samsung
);
1706 samsung
->pm_nb
.notifier_call
= samsung_pm_notification
;
1707 register_pm_notifier(&samsung
->pm_nb
);
1709 samsung_platform_device
= samsung
->platform_device
;
1713 samsung_leds_exit(samsung
);
1715 samsung_rfkill_exit(samsung
);
1717 samsung_backlight_exit(samsung
);
1719 samsung_sysfs_exit(samsung
);
1721 samsung_sabi_exit(samsung
);
1723 samsung_platform_exit(samsung
);
1729 static void __exit
samsung_exit(void)
1731 struct samsung_laptop
*samsung
;
1733 samsung
= platform_get_drvdata(samsung_platform_device
);
1734 unregister_pm_notifier(&samsung
->pm_nb
);
1736 samsung_debugfs_exit(samsung
);
1737 samsung_lid_handling_exit(samsung
);
1738 samsung_leds_exit(samsung
);
1739 samsung_rfkill_exit(samsung
);
1740 samsung_backlight_exit(samsung
);
1741 samsung_sysfs_exit(samsung
);
1742 samsung_sabi_exit(samsung
);
1743 samsung_platform_exit(samsung
);
1746 samsung_platform_device
= NULL
;
1749 module_init(samsung_init
);
1750 module_exit(samsung_exit
);
1752 MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@suse.de>");
1753 MODULE_DESCRIPTION("Samsung Backlight driver");
1754 MODULE_LICENSE("GPL");