Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 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> |
Corentin Chary | f34cd9c | 2011-11-26 11:00:00 +0100 | [diff] [blame] | 24 | #include <linux/acpi.h> |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 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 | |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 221 | struct samsung_laptop { |
| 222 | const struct sabi_config *config; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 223 | |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 224 | void __iomem *sabi; |
| 225 | void __iomem *sabi_iface; |
| 226 | void __iomem *f0000_segment; |
| 227 | |
| 228 | struct mutex sabi_mutex; |
| 229 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 230 | struct platform_device *platform_device; |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 231 | struct backlight_device *backlight_device; |
| 232 | struct rfkill *rfk; |
| 233 | |
Corentin Chary | f34cd9c | 2011-11-26 11:00:00 +0100 | [diff] [blame] | 234 | bool handle_backlight; |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 235 | bool has_stepping_quirk; |
| 236 | }; |
| 237 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 238 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 239 | |
Rusty Russell | 90ab5ee | 2012-01-13 09:32:20 +1030 | [diff] [blame] | 240 | static bool force; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 241 | module_param(force, bool, 0); |
| 242 | MODULE_PARM_DESC(force, |
| 243 | "Disable the DMI check and forces the driver to be loaded"); |
| 244 | |
Rusty Russell | 90ab5ee | 2012-01-13 09:32:20 +1030 | [diff] [blame] | 245 | static bool debug; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 246 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
| 247 | MODULE_PARM_DESC(debug, "Debug enabled or not"); |
| 248 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 249 | static int sabi_get_command(struct samsung_laptop *samsung, |
| 250 | u8 command, struct sabi_retval *sretval) |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 251 | { |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 252 | const struct sabi_config *config = samsung->config; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 253 | int retval = 0; |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 254 | u16 port = readw(samsung->sabi + config->header_offsets.port); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 255 | u8 complete, iface_data; |
| 256 | |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 257 | mutex_lock(&samsung->sabi_mutex); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 258 | |
| 259 | /* enable memory to be able to write to it */ |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 260 | outb(readb(samsung->sabi + config->header_offsets.en_mem), port); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 261 | |
| 262 | /* write out the command */ |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 263 | writew(config->main_function, samsung->sabi_iface + SABI_IFACE_MAIN); |
| 264 | writew(command, samsung->sabi_iface + SABI_IFACE_SUB); |
| 265 | writeb(0, samsung->sabi_iface + SABI_IFACE_COMPLETE); |
| 266 | outb(readb(samsung->sabi + config->header_offsets.iface_func), port); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 267 | |
| 268 | /* write protect memory to make it safe */ |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 269 | outb(readb(samsung->sabi + config->header_offsets.re_mem), port); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 270 | |
| 271 | /* see if the command actually succeeded */ |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 272 | complete = readb(samsung->sabi_iface + SABI_IFACE_COMPLETE); |
| 273 | iface_data = readb(samsung->sabi_iface + SABI_IFACE_DATA); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 274 | if (complete != 0xaa || iface_data == 0xff) { |
| 275 | pr_warn("SABI get command 0x%02x failed with completion flag 0x%02x and data 0x%02x\n", |
| 276 | command, complete, iface_data); |
| 277 | retval = -EINVAL; |
| 278 | goto exit; |
| 279 | } |
| 280 | /* |
| 281 | * Save off the data into a structure so the caller use it. |
| 282 | * Right now we only want the first 4 bytes, |
| 283 | * There are commands that need more, but not for the ones we |
| 284 | * currently care about. |
| 285 | */ |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 286 | sretval->retval[0] = readb(samsung->sabi_iface + SABI_IFACE_DATA); |
| 287 | sretval->retval[1] = readb(samsung->sabi_iface + SABI_IFACE_DATA + 1); |
| 288 | sretval->retval[2] = readb(samsung->sabi_iface + SABI_IFACE_DATA + 2); |
| 289 | sretval->retval[3] = readb(samsung->sabi_iface + SABI_IFACE_DATA + 3); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 290 | |
| 291 | exit: |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 292 | mutex_unlock(&samsung->sabi_mutex); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 293 | return retval; |
| 294 | |
| 295 | } |
| 296 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 297 | static int sabi_set_command(struct samsung_laptop *samsung, |
| 298 | u8 command, u8 data) |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 299 | { |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 300 | const struct sabi_config *config = samsung->config; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 301 | int retval = 0; |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 302 | u16 port = readw(samsung->sabi + config->header_offsets.port); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 303 | u8 complete, iface_data; |
| 304 | |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 305 | mutex_lock(&samsung->sabi_mutex); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 306 | |
| 307 | /* enable memory to be able to write to it */ |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 308 | outb(readb(samsung->sabi + config->header_offsets.en_mem), port); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 309 | |
| 310 | /* write out the command */ |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 311 | writew(config->main_function, samsung->sabi_iface + SABI_IFACE_MAIN); |
| 312 | writew(command, samsung->sabi_iface + SABI_IFACE_SUB); |
| 313 | writeb(0, samsung->sabi_iface + SABI_IFACE_COMPLETE); |
| 314 | writeb(data, samsung->sabi_iface + SABI_IFACE_DATA); |
| 315 | outb(readb(samsung->sabi + config->header_offsets.iface_func), port); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 316 | |
| 317 | /* write protect memory to make it safe */ |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 318 | outb(readb(samsung->sabi + config->header_offsets.re_mem), port); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 319 | |
| 320 | /* see if the command actually succeeded */ |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 321 | complete = readb(samsung->sabi_iface + SABI_IFACE_COMPLETE); |
| 322 | iface_data = readb(samsung->sabi_iface + SABI_IFACE_DATA); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 323 | if (complete != 0xaa || iface_data == 0xff) { |
| 324 | pr_warn("SABI set command 0x%02x failed with completion flag 0x%02x and data 0x%02x\n", |
| 325 | command, complete, iface_data); |
| 326 | retval = -EINVAL; |
| 327 | } |
| 328 | |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 329 | mutex_unlock(&samsung->sabi_mutex); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 330 | return retval; |
| 331 | } |
| 332 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 333 | static void test_backlight(struct samsung_laptop *samsung) |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 334 | { |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 335 | const struct sabi_commands *commands = &samsung->config->commands; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 336 | struct sabi_retval sretval; |
| 337 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 338 | sabi_get_command(samsung, commands->get_backlight, &sretval); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 339 | printk(KERN_DEBUG "backlight = 0x%02x\n", sretval.retval[0]); |
| 340 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 341 | sabi_set_command(samsung, commands->set_backlight, 0); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 342 | printk(KERN_DEBUG "backlight should be off\n"); |
| 343 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 344 | sabi_get_command(samsung, commands->get_backlight, &sretval); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 345 | printk(KERN_DEBUG "backlight = 0x%02x\n", sretval.retval[0]); |
| 346 | |
| 347 | msleep(1000); |
| 348 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 349 | sabi_set_command(samsung, commands->set_backlight, 1); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 350 | printk(KERN_DEBUG "backlight should be on\n"); |
| 351 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 352 | sabi_get_command(samsung, commands->get_backlight, &sretval); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 353 | printk(KERN_DEBUG "backlight = 0x%02x\n", sretval.retval[0]); |
| 354 | } |
| 355 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 356 | static void test_wireless(struct samsung_laptop *samsung) |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 357 | { |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 358 | const struct sabi_commands *commands = &samsung->config->commands; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 359 | struct sabi_retval sretval; |
| 360 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 361 | sabi_get_command(samsung, commands->get_wireless_button, &sretval); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 362 | printk(KERN_DEBUG "wireless led = 0x%02x\n", sretval.retval[0]); |
| 363 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 364 | sabi_set_command(samsung, commands->set_wireless_button, 0); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 365 | printk(KERN_DEBUG "wireless led should be off\n"); |
| 366 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 367 | sabi_get_command(samsung, commands->get_wireless_button, &sretval); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 368 | printk(KERN_DEBUG "wireless led = 0x%02x\n", sretval.retval[0]); |
| 369 | |
| 370 | msleep(1000); |
| 371 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 372 | sabi_set_command(samsung, commands->set_wireless_button, 1); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 373 | printk(KERN_DEBUG "wireless led should be on\n"); |
| 374 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 375 | sabi_get_command(samsung, commands->get_wireless_button, &sretval); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 376 | printk(KERN_DEBUG "wireless led = 0x%02x\n", sretval.retval[0]); |
| 377 | } |
| 378 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 379 | static int read_brightness(struct samsung_laptop *samsung) |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 380 | { |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 381 | const struct sabi_config *config = samsung->config; |
| 382 | const struct sabi_commands *commands = &samsung->config->commands; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 383 | struct sabi_retval sretval; |
| 384 | int user_brightness = 0; |
| 385 | int retval; |
| 386 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 387 | retval = sabi_get_command(samsung, commands->get_brightness, |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 388 | &sretval); |
| 389 | if (!retval) { |
| 390 | user_brightness = sretval.retval[0]; |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 391 | if (user_brightness > config->min_brightness) |
| 392 | user_brightness -= config->min_brightness; |
Jason Stubbs | bee460b | 2011-09-20 09:16:11 -0700 | [diff] [blame] | 393 | else |
| 394 | user_brightness = 0; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 395 | } |
| 396 | return user_brightness; |
| 397 | } |
| 398 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 399 | static void set_brightness(struct samsung_laptop *samsung, u8 user_brightness) |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 400 | { |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 401 | const struct sabi_config *config = samsung->config; |
| 402 | const struct sabi_commands *commands = &samsung->config->commands; |
| 403 | u8 user_level = user_brightness + config->min_brightness; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 404 | |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 405 | if (samsung->has_stepping_quirk && user_level != 0) { |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 406 | /* |
| 407 | * short circuit if the specified level is what's already set |
| 408 | * to prevent the screen from flickering needlessly |
| 409 | */ |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 410 | if (user_brightness == read_brightness(samsung)) |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 411 | return; |
| 412 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 413 | sabi_set_command(samsung, commands->set_brightness, 0); |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 414 | } |
| 415 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 416 | sabi_set_command(samsung, commands->set_brightness, user_level); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | static int get_brightness(struct backlight_device *bd) |
| 420 | { |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 421 | struct samsung_laptop *samsung = bl_get_data(bd); |
| 422 | |
| 423 | return read_brightness(samsung); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 424 | } |
| 425 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 426 | static void check_for_stepping_quirk(struct samsung_laptop *samsung) |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 427 | { |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 428 | int initial_level; |
| 429 | int check_level; |
| 430 | int orig_level = read_brightness(samsung); |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 431 | |
| 432 | /* |
| 433 | * Some laptops exhibit the strange behaviour of stepping toward |
| 434 | * (rather than setting) the brightness except when changing to/from |
| 435 | * brightness level 0. This behaviour is checked for here and worked |
| 436 | * around in set_brightness. |
| 437 | */ |
| 438 | |
John Serock | ba05b23 | 2011-10-13 06:42:01 -0400 | [diff] [blame] | 439 | if (orig_level == 0) |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 440 | set_brightness(samsung, 1); |
John Serock | ba05b23 | 2011-10-13 06:42:01 -0400 | [diff] [blame] | 441 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 442 | initial_level = read_brightness(samsung); |
John Serock | ba05b23 | 2011-10-13 06:42:01 -0400 | [diff] [blame] | 443 | |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 444 | if (initial_level <= 2) |
| 445 | check_level = initial_level + 2; |
| 446 | else |
| 447 | check_level = initial_level - 2; |
| 448 | |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 449 | samsung->has_stepping_quirk = false; |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 450 | set_brightness(samsung, check_level); |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 451 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 452 | if (read_brightness(samsung) != check_level) { |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 453 | samsung->has_stepping_quirk = true; |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 454 | pr_info("enabled workaround for brightness stepping quirk\n"); |
| 455 | } |
| 456 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 457 | set_brightness(samsung, orig_level); |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 458 | } |
| 459 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 460 | static int update_status(struct backlight_device *bd) |
| 461 | { |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 462 | struct samsung_laptop *samsung = bl_get_data(bd); |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 463 | const struct sabi_commands *commands = &samsung->config->commands; |
| 464 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 465 | set_brightness(samsung, bd->props.brightness); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 466 | |
| 467 | if (bd->props.power == FB_BLANK_UNBLANK) |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 468 | sabi_set_command(samsung, commands->set_backlight, 1); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 469 | else |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 470 | sabi_set_command(samsung, commands->set_backlight, 0); |
| 471 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 472 | return 0; |
| 473 | } |
| 474 | |
| 475 | static const struct backlight_ops backlight_ops = { |
| 476 | .get_brightness = get_brightness, |
| 477 | .update_status = update_status, |
| 478 | }; |
| 479 | |
| 480 | static int rfkill_set(void *data, bool blocked) |
| 481 | { |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 482 | struct samsung_laptop *samsung = data; |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 483 | const struct sabi_commands *commands = &samsung->config->commands; |
| 484 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 485 | /* Do something with blocked...*/ |
| 486 | /* |
| 487 | * blocked == false is on |
| 488 | * blocked == true is off |
| 489 | */ |
| 490 | if (blocked) |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 491 | sabi_set_command(samsung, commands->set_wireless_button, 0); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 492 | else |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 493 | sabi_set_command(samsung, commands->set_wireless_button, 1); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 494 | |
| 495 | return 0; |
| 496 | } |
| 497 | |
| 498 | static struct rfkill_ops rfkill_ops = { |
| 499 | .set_block = rfkill_set, |
| 500 | }; |
| 501 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 502 | static ssize_t get_performance_level(struct device *dev, |
| 503 | struct device_attribute *attr, char *buf) |
| 504 | { |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 505 | struct samsung_laptop *samsung = dev_get_drvdata(dev); |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 506 | const struct sabi_config *config = samsung->config; |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 507 | const struct sabi_commands *commands = &config->commands; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 508 | struct sabi_retval sretval; |
| 509 | int retval; |
| 510 | int i; |
| 511 | |
| 512 | /* Read the state */ |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 513 | retval = sabi_get_command(samsung, commands->get_performance_level, |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 514 | &sretval); |
| 515 | if (retval) |
| 516 | return retval; |
| 517 | |
| 518 | /* The logic is backwards, yeah, lots of fun... */ |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 519 | for (i = 0; config->performance_levels[i].name; ++i) { |
| 520 | if (sretval.retval[0] == config->performance_levels[i].value) |
| 521 | return sprintf(buf, "%s\n", config->performance_levels[i].name); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 522 | } |
| 523 | return sprintf(buf, "%s\n", "unknown"); |
| 524 | } |
| 525 | |
| 526 | static ssize_t set_performance_level(struct device *dev, |
| 527 | struct device_attribute *attr, const char *buf, |
| 528 | size_t count) |
| 529 | { |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 530 | struct samsung_laptop *samsung = dev_get_drvdata(dev); |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 531 | const struct sabi_config *config = samsung->config; |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 532 | const struct sabi_commands *commands = &config->commands; |
| 533 | int i; |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 534 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 535 | if (count < 1) |
| 536 | return count; |
| 537 | |
| 538 | for (i = 0; config->performance_levels[i].name; ++i) { |
| 539 | const struct sabi_performance_level *level = |
| 540 | &config->performance_levels[i]; |
| 541 | if (!strncasecmp(level->name, buf, strlen(level->name))) { |
| 542 | sabi_set_command(samsung, |
| 543 | commands->set_performance_level, |
| 544 | level->value); |
| 545 | break; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 546 | } |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 547 | } |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 548 | |
| 549 | if (!config->performance_levels[i].name) |
| 550 | return -EINVAL; |
| 551 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 552 | return count; |
| 553 | } |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 554 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 555 | static DEVICE_ATTR(performance_level, S_IWUSR | S_IRUGO, |
| 556 | get_performance_level, set_performance_level); |
| 557 | |
Corentin Chary | a66c166 | 2011-11-26 11:00:01 +0100 | [diff] [blame^] | 558 | static struct attribute *platform_attributes[] = { |
| 559 | &dev_attr_performance_level.attr, |
| 560 | NULL |
| 561 | }; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 562 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 563 | static int find_signature(void __iomem *memcheck, const char *testStr) |
| 564 | { |
| 565 | int i = 0; |
| 566 | int loca; |
| 567 | |
| 568 | for (loca = 0; loca < 0xffff; loca++) { |
| 569 | char temp = readb(memcheck + loca); |
| 570 | |
| 571 | if (temp == testStr[i]) { |
| 572 | if (i == strlen(testStr)-1) |
| 573 | break; |
| 574 | ++i; |
| 575 | } else { |
| 576 | i = 0; |
| 577 | } |
| 578 | } |
| 579 | return loca; |
| 580 | } |
| 581 | |
| 582 | static void samsung_rfkill_exit(struct samsung_laptop *samsung) |
| 583 | { |
| 584 | if (samsung->rfk) { |
| 585 | rfkill_unregister(samsung->rfk); |
| 586 | rfkill_destroy(samsung->rfk); |
| 587 | samsung->rfk = NULL; |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | static int __init samsung_rfkill_init(struct samsung_laptop *samsung) |
| 592 | { |
| 593 | int retval; |
| 594 | |
| 595 | samsung->rfk = rfkill_alloc("samsung-wifi", |
| 596 | &samsung->platform_device->dev, |
| 597 | RFKILL_TYPE_WLAN, |
| 598 | &rfkill_ops, samsung); |
| 599 | if (!samsung->rfk) |
| 600 | return -ENOMEM; |
| 601 | |
| 602 | retval = rfkill_register(samsung->rfk); |
| 603 | if (retval) { |
| 604 | rfkill_destroy(samsung->rfk); |
| 605 | samsung->rfk = NULL; |
| 606 | return -ENODEV; |
| 607 | } |
| 608 | |
| 609 | return 0; |
| 610 | } |
| 611 | |
| 612 | static void samsung_backlight_exit(struct samsung_laptop *samsung) |
| 613 | { |
| 614 | if (samsung->backlight_device) { |
| 615 | backlight_device_unregister(samsung->backlight_device); |
| 616 | samsung->backlight_device = NULL; |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | static int __init samsung_backlight_init(struct samsung_laptop *samsung) |
| 621 | { |
| 622 | struct backlight_device *bd; |
| 623 | struct backlight_properties props; |
| 624 | |
Corentin Chary | f34cd9c | 2011-11-26 11:00:00 +0100 | [diff] [blame] | 625 | if (!samsung->handle_backlight) |
| 626 | return 0; |
| 627 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 628 | memset(&props, 0, sizeof(struct backlight_properties)); |
| 629 | props.type = BACKLIGHT_PLATFORM; |
| 630 | props.max_brightness = samsung->config->max_brightness - |
| 631 | samsung->config->min_brightness; |
| 632 | |
| 633 | bd = backlight_device_register("samsung", |
| 634 | &samsung->platform_device->dev, |
| 635 | samsung, &backlight_ops, |
| 636 | &props); |
| 637 | if (IS_ERR(bd)) |
| 638 | return PTR_ERR(bd); |
| 639 | |
| 640 | samsung->backlight_device = bd; |
| 641 | samsung->backlight_device->props.brightness = read_brightness(samsung); |
| 642 | samsung->backlight_device->props.power = FB_BLANK_UNBLANK; |
| 643 | backlight_update_status(samsung->backlight_device); |
| 644 | |
| 645 | return 0; |
| 646 | } |
| 647 | |
Corentin Chary | a66c166 | 2011-11-26 11:00:01 +0100 | [diff] [blame^] | 648 | static mode_t samsung_sysfs_is_visible(struct kobject *kobj, |
| 649 | struct attribute *attr, int idx) |
| 650 | { |
| 651 | struct device *dev = container_of(kobj, struct device, kobj); |
| 652 | struct platform_device *pdev = to_platform_device(dev); |
| 653 | struct samsung_laptop *samsung = platform_get_drvdata(pdev); |
| 654 | bool ok = true; |
| 655 | |
| 656 | if (attr == &dev_attr_performance_level.attr) |
| 657 | ok = !!samsung->config->performance_levels[0].name; |
| 658 | |
| 659 | return ok ? attr->mode : 0; |
| 660 | } |
| 661 | |
| 662 | static struct attribute_group platform_attribute_group = { |
| 663 | .is_visible = samsung_sysfs_is_visible, |
| 664 | .attrs = platform_attributes |
| 665 | }; |
| 666 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 667 | static void samsung_sysfs_exit(struct samsung_laptop *samsung) |
| 668 | { |
Corentin Chary | a66c166 | 2011-11-26 11:00:01 +0100 | [diff] [blame^] | 669 | struct platform_device *device = samsung->platform_device; |
| 670 | |
| 671 | sysfs_remove_group(&device->dev.kobj, &platform_attribute_group); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | static int __init samsung_sysfs_init(struct samsung_laptop *samsung) |
| 675 | { |
Corentin Chary | a66c166 | 2011-11-26 11:00:01 +0100 | [diff] [blame^] | 676 | struct platform_device *device = samsung->platform_device; |
| 677 | |
| 678 | return sysfs_create_group(&device->dev.kobj, &platform_attribute_group); |
| 679 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 680 | } |
| 681 | |
| 682 | static void samsung_sabi_exit(struct samsung_laptop *samsung) |
| 683 | { |
| 684 | const struct sabi_config *config = samsung->config; |
| 685 | |
| 686 | /* Turn off "Linux" mode in the BIOS */ |
| 687 | if (config && config->commands.set_linux != 0xff) |
| 688 | sabi_set_command(samsung, config->commands.set_linux, 0x80); |
| 689 | |
| 690 | if (samsung->sabi_iface) { |
| 691 | iounmap(samsung->sabi_iface); |
| 692 | samsung->sabi_iface = NULL; |
| 693 | } |
| 694 | if (samsung->f0000_segment) { |
| 695 | iounmap(samsung->f0000_segment); |
| 696 | samsung->f0000_segment = NULL; |
| 697 | } |
| 698 | |
| 699 | samsung->config = NULL; |
| 700 | } |
| 701 | |
| 702 | static __init void samsung_sabi_infos(struct samsung_laptop *samsung, int loca) |
| 703 | { |
| 704 | const struct sabi_config *config = samsung->config; |
| 705 | |
| 706 | printk(KERN_DEBUG "This computer supports SABI==%x\n", |
| 707 | loca + 0xf0000 - 6); |
| 708 | printk(KERN_DEBUG "SABI header:\n"); |
| 709 | printk(KERN_DEBUG " SMI Port Number = 0x%04x\n", |
| 710 | readw(samsung->sabi + config->header_offsets.port)); |
| 711 | printk(KERN_DEBUG " SMI Interface Function = 0x%02x\n", |
| 712 | readb(samsung->sabi + config->header_offsets.iface_func)); |
| 713 | printk(KERN_DEBUG " SMI enable memory buffer = 0x%02x\n", |
| 714 | readb(samsung->sabi + config->header_offsets.en_mem)); |
| 715 | printk(KERN_DEBUG " SMI restore memory buffer = 0x%02x\n", |
| 716 | readb(samsung->sabi + config->header_offsets.re_mem)); |
| 717 | printk(KERN_DEBUG " SABI data offset = 0x%04x\n", |
| 718 | readw(samsung->sabi + config->header_offsets.data_offset)); |
| 719 | printk(KERN_DEBUG " SABI data segment = 0x%04x\n", |
| 720 | readw(samsung->sabi + config->header_offsets.data_segment)); |
| 721 | } |
| 722 | |
| 723 | static void __init samsung_sabi_selftest(struct samsung_laptop *samsung, |
| 724 | unsigned int ifaceP) |
| 725 | { |
| 726 | const struct sabi_config *config = samsung->config; |
| 727 | struct sabi_retval sretval; |
| 728 | |
| 729 | printk(KERN_DEBUG "ifaceP = 0x%08x\n", ifaceP); |
| 730 | printk(KERN_DEBUG "sabi_iface = %p\n", samsung->sabi_iface); |
| 731 | |
Corentin Chary | f34cd9c | 2011-11-26 11:00:00 +0100 | [diff] [blame] | 732 | if (samsung->handle_backlight) |
| 733 | test_backlight(samsung); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 734 | test_wireless(samsung); |
| 735 | |
| 736 | sabi_get_command(samsung, config->commands.get_brightness, &sretval); |
| 737 | printk(KERN_DEBUG "brightness = 0x%02x\n", sretval.retval[0]); |
| 738 | } |
| 739 | |
| 740 | static int __init samsung_sabi_init(struct samsung_laptop *samsung) |
| 741 | { |
| 742 | const struct sabi_config *config = NULL; |
| 743 | const struct sabi_commands *commands; |
| 744 | unsigned int ifaceP; |
| 745 | int ret = 0; |
| 746 | int i; |
| 747 | int loca; |
| 748 | |
| 749 | samsung->f0000_segment = ioremap_nocache(0xf0000, 0xffff); |
| 750 | if (!samsung->f0000_segment) { |
| 751 | pr_err("Can't map the segment at 0xf0000\n"); |
| 752 | ret = -EINVAL; |
| 753 | goto exit; |
| 754 | } |
| 755 | |
| 756 | /* Try to find one of the signatures in memory to find the header */ |
| 757 | for (i = 0; sabi_configs[i].test_string != 0; ++i) { |
| 758 | samsung->config = &sabi_configs[i]; |
| 759 | loca = find_signature(samsung->f0000_segment, |
| 760 | samsung->config->test_string); |
| 761 | if (loca != 0xffff) |
| 762 | break; |
| 763 | } |
| 764 | |
| 765 | if (loca == 0xffff) { |
| 766 | pr_err("This computer does not support SABI\n"); |
| 767 | ret = -ENODEV; |
| 768 | goto exit; |
| 769 | } |
| 770 | |
| 771 | config = samsung->config; |
| 772 | commands = &config->commands; |
| 773 | |
| 774 | /* point to the SMI port Number */ |
| 775 | loca += 1; |
| 776 | samsung->sabi = (samsung->f0000_segment + loca); |
| 777 | |
| 778 | if (debug) |
| 779 | samsung_sabi_infos(samsung, loca); |
| 780 | |
| 781 | /* Get a pointer to the SABI Interface */ |
| 782 | ifaceP = (readw(samsung->sabi + config->header_offsets.data_segment) & 0x0ffff) << 4; |
| 783 | ifaceP += readw(samsung->sabi + config->header_offsets.data_offset) & 0x0ffff; |
| 784 | samsung->sabi_iface = ioremap_nocache(ifaceP, 16); |
| 785 | if (!samsung->sabi_iface) { |
| 786 | pr_err("Can't remap %x\n", ifaceP); |
| 787 | ret = -EINVAL; |
| 788 | goto exit; |
| 789 | } |
| 790 | |
| 791 | if (debug) |
| 792 | samsung_sabi_selftest(samsung, ifaceP); |
| 793 | |
| 794 | /* Turn on "Linux" mode in the BIOS */ |
| 795 | if (commands->set_linux != 0xff) { |
| 796 | int retval = sabi_set_command(samsung, |
| 797 | commands->set_linux, 0x81); |
| 798 | if (retval) { |
| 799 | pr_warn("Linux mode was not set!\n"); |
| 800 | ret = -ENODEV; |
| 801 | goto exit; |
| 802 | } |
| 803 | } |
| 804 | |
| 805 | /* Check for stepping quirk */ |
Corentin Chary | f34cd9c | 2011-11-26 11:00:00 +0100 | [diff] [blame] | 806 | if (samsung->handle_backlight) |
| 807 | check_for_stepping_quirk(samsung); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 808 | |
| 809 | exit: |
| 810 | if (ret) |
| 811 | samsung_sabi_exit(samsung); |
| 812 | |
| 813 | return ret; |
| 814 | } |
| 815 | |
| 816 | static void samsung_platform_exit(struct samsung_laptop *samsung) |
| 817 | { |
| 818 | if (samsung->platform_device) { |
| 819 | platform_device_unregister(samsung->platform_device); |
| 820 | samsung->platform_device = NULL; |
| 821 | } |
| 822 | } |
| 823 | |
| 824 | static int __init samsung_platform_init(struct samsung_laptop *samsung) |
| 825 | { |
| 826 | struct platform_device *pdev; |
| 827 | |
| 828 | pdev = platform_device_register_simple("samsung", -1, NULL, 0); |
| 829 | if (IS_ERR(pdev)) |
| 830 | return PTR_ERR(pdev); |
| 831 | |
| 832 | samsung->platform_device = pdev; |
| 833 | platform_set_drvdata(samsung->platform_device, samsung); |
| 834 | return 0; |
| 835 | } |
| 836 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 837 | static int __init dmi_check_cb(const struct dmi_system_id *id) |
| 838 | { |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 839 | pr_info("found laptop model '%s'\n", id->ident); |
Axel Lin | 2783658 | 2011-03-14 18:56:18 +0800 | [diff] [blame] | 840 | return 1; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 841 | } |
| 842 | |
| 843 | static struct dmi_system_id __initdata samsung_dmi_table[] = { |
| 844 | { |
| 845 | .ident = "N128", |
| 846 | .matches = { |
| 847 | DMI_MATCH(DMI_SYS_VENDOR, |
| 848 | "SAMSUNG ELECTRONICS CO., LTD."), |
| 849 | DMI_MATCH(DMI_PRODUCT_NAME, "N128"), |
| 850 | DMI_MATCH(DMI_BOARD_NAME, "N128"), |
| 851 | }, |
| 852 | .callback = dmi_check_cb, |
| 853 | }, |
| 854 | { |
| 855 | .ident = "N130", |
| 856 | .matches = { |
| 857 | DMI_MATCH(DMI_SYS_VENDOR, |
| 858 | "SAMSUNG ELECTRONICS CO., LTD."), |
| 859 | DMI_MATCH(DMI_PRODUCT_NAME, "N130"), |
| 860 | DMI_MATCH(DMI_BOARD_NAME, "N130"), |
| 861 | }, |
| 862 | .callback = dmi_check_cb, |
| 863 | }, |
| 864 | { |
J Witteveen | 4e2441c | 2011-07-03 13:15:44 +0200 | [diff] [blame] | 865 | .ident = "N510", |
| 866 | .matches = { |
| 867 | DMI_MATCH(DMI_SYS_VENDOR, |
| 868 | "SAMSUNG ELECTRONICS CO., LTD."), |
| 869 | DMI_MATCH(DMI_PRODUCT_NAME, "N510"), |
| 870 | DMI_MATCH(DMI_BOARD_NAME, "N510"), |
| 871 | }, |
| 872 | .callback = dmi_check_cb, |
| 873 | }, |
| 874 | { |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 875 | .ident = "X125", |
| 876 | .matches = { |
| 877 | DMI_MATCH(DMI_SYS_VENDOR, |
| 878 | "SAMSUNG ELECTRONICS CO., LTD."), |
| 879 | DMI_MATCH(DMI_PRODUCT_NAME, "X125"), |
| 880 | DMI_MATCH(DMI_BOARD_NAME, "X125"), |
| 881 | }, |
| 882 | .callback = dmi_check_cb, |
| 883 | }, |
| 884 | { |
| 885 | .ident = "X120/X170", |
| 886 | .matches = { |
| 887 | DMI_MATCH(DMI_SYS_VENDOR, |
| 888 | "SAMSUNG ELECTRONICS CO., LTD."), |
| 889 | DMI_MATCH(DMI_PRODUCT_NAME, "X120/X170"), |
| 890 | DMI_MATCH(DMI_BOARD_NAME, "X120/X170"), |
| 891 | }, |
| 892 | .callback = dmi_check_cb, |
| 893 | }, |
| 894 | { |
| 895 | .ident = "NC10", |
| 896 | .matches = { |
| 897 | DMI_MATCH(DMI_SYS_VENDOR, |
| 898 | "SAMSUNG ELECTRONICS CO., LTD."), |
| 899 | DMI_MATCH(DMI_PRODUCT_NAME, "NC10"), |
| 900 | DMI_MATCH(DMI_BOARD_NAME, "NC10"), |
| 901 | }, |
| 902 | .callback = dmi_check_cb, |
| 903 | }, |
| 904 | { |
| 905 | .ident = "NP-Q45", |
| 906 | .matches = { |
| 907 | DMI_MATCH(DMI_SYS_VENDOR, |
| 908 | "SAMSUNG ELECTRONICS CO., LTD."), |
| 909 | DMI_MATCH(DMI_PRODUCT_NAME, "SQ45S70S"), |
| 910 | DMI_MATCH(DMI_BOARD_NAME, "SQ45S70S"), |
| 911 | }, |
| 912 | .callback = dmi_check_cb, |
| 913 | }, |
| 914 | { |
| 915 | .ident = "X360", |
| 916 | .matches = { |
| 917 | DMI_MATCH(DMI_SYS_VENDOR, |
| 918 | "SAMSUNG ELECTRONICS CO., LTD."), |
| 919 | DMI_MATCH(DMI_PRODUCT_NAME, "X360"), |
| 920 | DMI_MATCH(DMI_BOARD_NAME, "X360"), |
| 921 | }, |
| 922 | .callback = dmi_check_cb, |
| 923 | }, |
| 924 | { |
Alberto Mardegan | 3d536ed | 2011-04-08 17:02:03 +0200 | [diff] [blame] | 925 | .ident = "R410 Plus", |
| 926 | .matches = { |
| 927 | DMI_MATCH(DMI_SYS_VENDOR, |
| 928 | "SAMSUNG ELECTRONICS CO., LTD."), |
| 929 | DMI_MATCH(DMI_PRODUCT_NAME, "R410P"), |
| 930 | DMI_MATCH(DMI_BOARD_NAME, "R460"), |
| 931 | }, |
| 932 | .callback = dmi_check_cb, |
| 933 | }, |
| 934 | { |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 935 | .ident = "R518", |
| 936 | .matches = { |
| 937 | DMI_MATCH(DMI_SYS_VENDOR, |
| 938 | "SAMSUNG ELECTRONICS CO., LTD."), |
| 939 | DMI_MATCH(DMI_PRODUCT_NAME, "R518"), |
| 940 | DMI_MATCH(DMI_BOARD_NAME, "R518"), |
| 941 | }, |
| 942 | .callback = dmi_check_cb, |
| 943 | }, |
| 944 | { |
| 945 | .ident = "R519/R719", |
| 946 | .matches = { |
| 947 | DMI_MATCH(DMI_SYS_VENDOR, |
| 948 | "SAMSUNG ELECTRONICS CO., LTD."), |
| 949 | DMI_MATCH(DMI_PRODUCT_NAME, "R519/R719"), |
| 950 | DMI_MATCH(DMI_BOARD_NAME, "R519/R719"), |
| 951 | }, |
| 952 | .callback = dmi_check_cb, |
| 953 | }, |
| 954 | { |
Thomas Courbon | 78a7539 | 2011-07-20 22:57:44 +0200 | [diff] [blame] | 955 | .ident = "N150/N210/N220", |
| 956 | .matches = { |
| 957 | DMI_MATCH(DMI_SYS_VENDOR, |
| 958 | "SAMSUNG ELECTRONICS CO., LTD."), |
| 959 | DMI_MATCH(DMI_PRODUCT_NAME, "N150/N210/N220"), |
| 960 | DMI_MATCH(DMI_BOARD_NAME, "N150/N210/N220"), |
| 961 | }, |
| 962 | .callback = dmi_check_cb, |
| 963 | }, |
| 964 | { |
Raul Gutierrez Segales | f689c87 | 2011-09-20 09:16:15 -0700 | [diff] [blame] | 965 | .ident = "N220", |
| 966 | .matches = { |
| 967 | DMI_MATCH(DMI_SYS_VENDOR, |
| 968 | "SAMSUNG ELECTRONICS CO., LTD."), |
| 969 | DMI_MATCH(DMI_PRODUCT_NAME, "N220"), |
| 970 | DMI_MATCH(DMI_BOARD_NAME, "N220"), |
| 971 | }, |
| 972 | .callback = dmi_check_cb, |
| 973 | }, |
| 974 | { |
Greg Kroah-Hartman | 1016507 | 2011-04-08 17:02:04 +0200 | [diff] [blame] | 975 | .ident = "N150/N210/N220/N230", |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 976 | .matches = { |
| 977 | DMI_MATCH(DMI_SYS_VENDOR, |
| 978 | "SAMSUNG ELECTRONICS CO., LTD."), |
Greg Kroah-Hartman | 1016507 | 2011-04-08 17:02:04 +0200 | [diff] [blame] | 979 | DMI_MATCH(DMI_PRODUCT_NAME, "N150/N210/N220/N230"), |
| 980 | DMI_MATCH(DMI_BOARD_NAME, "N150/N210/N220/N230"), |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 981 | }, |
| 982 | .callback = dmi_check_cb, |
| 983 | }, |
| 984 | { |
| 985 | .ident = "N150P/N210P/N220P", |
| 986 | .matches = { |
| 987 | DMI_MATCH(DMI_SYS_VENDOR, |
| 988 | "SAMSUNG ELECTRONICS CO., LTD."), |
| 989 | DMI_MATCH(DMI_PRODUCT_NAME, "N150P/N210P/N220P"), |
| 990 | DMI_MATCH(DMI_BOARD_NAME, "N150P/N210P/N220P"), |
| 991 | }, |
| 992 | .callback = dmi_check_cb, |
| 993 | }, |
| 994 | { |
Stefan Beller | f87d029 | 2011-09-20 09:16:08 -0700 | [diff] [blame] | 995 | .ident = "R700", |
| 996 | .matches = { |
| 997 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), |
| 998 | DMI_MATCH(DMI_PRODUCT_NAME, "SR700"), |
| 999 | DMI_MATCH(DMI_BOARD_NAME, "SR700"), |
| 1000 | }, |
| 1001 | .callback = dmi_check_cb, |
| 1002 | }, |
| 1003 | { |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1004 | .ident = "R530/R730", |
| 1005 | .matches = { |
| 1006 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), |
| 1007 | DMI_MATCH(DMI_PRODUCT_NAME, "R530/R730"), |
| 1008 | DMI_MATCH(DMI_BOARD_NAME, "R530/R730"), |
| 1009 | }, |
| 1010 | .callback = dmi_check_cb, |
| 1011 | }, |
| 1012 | { |
| 1013 | .ident = "NF110/NF210/NF310", |
| 1014 | .matches = { |
| 1015 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), |
| 1016 | DMI_MATCH(DMI_PRODUCT_NAME, "NF110/NF210/NF310"), |
| 1017 | DMI_MATCH(DMI_BOARD_NAME, "NF110/NF210/NF310"), |
| 1018 | }, |
| 1019 | .callback = dmi_check_cb, |
| 1020 | }, |
| 1021 | { |
| 1022 | .ident = "N145P/N250P/N260P", |
| 1023 | .matches = { |
| 1024 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), |
| 1025 | DMI_MATCH(DMI_PRODUCT_NAME, "N145P/N250P/N260P"), |
| 1026 | DMI_MATCH(DMI_BOARD_NAME, "N145P/N250P/N260P"), |
| 1027 | }, |
| 1028 | .callback = dmi_check_cb, |
| 1029 | }, |
| 1030 | { |
| 1031 | .ident = "R70/R71", |
| 1032 | .matches = { |
| 1033 | DMI_MATCH(DMI_SYS_VENDOR, |
| 1034 | "SAMSUNG ELECTRONICS CO., LTD."), |
| 1035 | DMI_MATCH(DMI_PRODUCT_NAME, "R70/R71"), |
| 1036 | DMI_MATCH(DMI_BOARD_NAME, "R70/R71"), |
| 1037 | }, |
| 1038 | .callback = dmi_check_cb, |
| 1039 | }, |
| 1040 | { |
| 1041 | .ident = "P460", |
| 1042 | .matches = { |
| 1043 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), |
| 1044 | DMI_MATCH(DMI_PRODUCT_NAME, "P460"), |
| 1045 | DMI_MATCH(DMI_BOARD_NAME, "P460"), |
| 1046 | }, |
| 1047 | .callback = dmi_check_cb, |
| 1048 | }, |
Smelov Andrey | 093ed56 | 2011-09-20 09:16:10 -0700 | [diff] [blame] | 1049 | { |
| 1050 | .ident = "R528/R728", |
| 1051 | .matches = { |
| 1052 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), |
| 1053 | DMI_MATCH(DMI_PRODUCT_NAME, "R528/R728"), |
| 1054 | DMI_MATCH(DMI_BOARD_NAME, "R528/R728"), |
| 1055 | }, |
| 1056 | .callback = dmi_check_cb, |
| 1057 | }, |
Jason Stubbs | 7b3c257 | 2011-09-20 09:16:14 -0700 | [diff] [blame] | 1058 | { |
| 1059 | .ident = "NC210/NC110", |
| 1060 | .matches = { |
| 1061 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), |
| 1062 | DMI_MATCH(DMI_PRODUCT_NAME, "NC210/NC110"), |
| 1063 | DMI_MATCH(DMI_BOARD_NAME, "NC210/NC110"), |
| 1064 | }, |
| 1065 | .callback = dmi_check_cb, |
| 1066 | }, |
Tommaso Massimi | 7500eeb | 2011-09-20 09:16:09 -0700 | [diff] [blame] | 1067 | { |
| 1068 | .ident = "X520", |
| 1069 | .matches = { |
| 1070 | DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), |
| 1071 | DMI_MATCH(DMI_PRODUCT_NAME, "X520"), |
| 1072 | DMI_MATCH(DMI_BOARD_NAME, "X520"), |
| 1073 | }, |
| 1074 | .callback = dmi_check_cb, |
| 1075 | }, |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1076 | { }, |
| 1077 | }; |
| 1078 | MODULE_DEVICE_TABLE(dmi, samsung_dmi_table); |
| 1079 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1080 | static struct platform_device *samsung_platform_device; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1081 | |
| 1082 | static int __init samsung_init(void) |
| 1083 | { |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1084 | struct samsung_laptop *samsung; |
| 1085 | int ret; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1086 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1087 | if (!force && !dmi_check_system(samsung_dmi_table)) |
| 1088 | return -ENODEV; |
| 1089 | |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 1090 | samsung = kzalloc(sizeof(*samsung), GFP_KERNEL); |
| 1091 | if (!samsung) |
| 1092 | return -ENOMEM; |
| 1093 | |
| 1094 | mutex_init(&samsung->sabi_mutex); |
Corentin Chary | f34cd9c | 2011-11-26 11:00:00 +0100 | [diff] [blame] | 1095 | samsung->handle_backlight = true; |
| 1096 | |
| 1097 | #ifdef CONFIG_ACPI |
| 1098 | /* Don't handle backlight here if the acpi video already handle it */ |
| 1099 | if (acpi_video_backlight_support()) { |
| 1100 | pr_info("Backlight controlled by ACPI video driver\n"); |
| 1101 | samsung->handle_backlight = false; |
| 1102 | } |
| 1103 | #endif |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 1104 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1105 | ret = samsung_platform_init(samsung); |
| 1106 | if (ret) |
| 1107 | goto error_platform; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1108 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1109 | ret = samsung_sabi_init(samsung); |
| 1110 | if (ret) |
| 1111 | goto error_sabi; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1112 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1113 | ret = samsung_sysfs_init(samsung); |
| 1114 | if (ret) |
| 1115 | goto error_sysfs; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1116 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1117 | ret = samsung_backlight_init(samsung); |
| 1118 | if (ret) |
| 1119 | goto error_backlight; |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 1120 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1121 | ret = samsung_rfkill_init(samsung); |
| 1122 | if (ret) |
| 1123 | goto error_rfkill; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1124 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1125 | samsung_platform_device = samsung->platform_device; |
| 1126 | return ret; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1127 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1128 | error_rfkill: |
| 1129 | samsung_backlight_exit(samsung); |
| 1130 | error_backlight: |
| 1131 | samsung_sysfs_exit(samsung); |
| 1132 | error_sysfs: |
| 1133 | samsung_sabi_exit(samsung); |
| 1134 | error_sabi: |
| 1135 | samsung_platform_exit(samsung); |
| 1136 | error_platform: |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 1137 | kfree(samsung); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1138 | return ret; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1139 | } |
| 1140 | |
| 1141 | static void __exit samsung_exit(void) |
| 1142 | { |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1143 | struct samsung_laptop *samsung; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1144 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1145 | samsung = platform_get_drvdata(samsung_platform_device); |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 1146 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1147 | samsung_rfkill_exit(samsung); |
| 1148 | samsung_backlight_exit(samsung); |
| 1149 | samsung_sysfs_exit(samsung); |
| 1150 | samsung_sabi_exit(samsung); |
| 1151 | samsung_platform_exit(samsung); |
| 1152 | |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 1153 | kfree(samsung); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1154 | samsung_platform_device = NULL; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1155 | } |
| 1156 | |
| 1157 | module_init(samsung_init); |
| 1158 | module_exit(samsung_exit); |
| 1159 | |
| 1160 | MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@suse.de>"); |
| 1161 | MODULE_DESCRIPTION("Samsung Backlight driver"); |
| 1162 | MODULE_LICENSE("GPL"); |