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> |
Corentin Chary | f674ebf | 2011-11-26 11:00:08 +0100 | [diff] [blame] | 20 | #include <linux/leds.h> |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 21 | #include <linux/fb.h> |
| 22 | #include <linux/dmi.h> |
| 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/rfkill.h> |
Corentin Chary | f34cd9c | 2011-11-26 11:00:00 +0100 | [diff] [blame] | 25 | #include <linux/acpi.h> |
Corentin Chary | 5b80fc4 | 2011-11-26 11:00:03 +0100 | [diff] [blame] | 26 | #include <linux/seq_file.h> |
| 27 | #include <linux/debugfs.h> |
David Rientjes | 82c333a | 2012-03-20 09:53:06 +0100 | [diff] [blame] | 28 | #include <linux/ctype.h> |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 29 | |
| 30 | /* |
| 31 | * This driver is needed because a number of Samsung laptops do not hook |
| 32 | * their control settings through ACPI. So we have to poke around in the |
| 33 | * BIOS to do things like brightness values, and "special" key controls. |
| 34 | */ |
| 35 | |
| 36 | /* |
| 37 | * We have 0 - 8 as valid brightness levels. The specs say that level 0 should |
| 38 | * be reserved by the BIOS (which really doesn't make much sense), we tell |
| 39 | * userspace that the value is 0 - 7 and then just tell the hardware 1 - 8 |
| 40 | */ |
| 41 | #define MAX_BRIGHT 0x07 |
| 42 | |
| 43 | |
| 44 | #define SABI_IFACE_MAIN 0x00 |
| 45 | #define SABI_IFACE_SUB 0x02 |
| 46 | #define SABI_IFACE_COMPLETE 0x04 |
| 47 | #define SABI_IFACE_DATA 0x05 |
| 48 | |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 49 | #define WL_STATUS_WLAN 0x0 |
| 50 | #define WL_STATUS_BT 0x2 |
| 51 | |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 52 | /* Structure get/set data using sabi */ |
| 53 | struct sabi_data { |
| 54 | union { |
| 55 | struct { |
| 56 | u32 d0; |
| 57 | u32 d1; |
| 58 | u16 d2; |
| 59 | u8 d3; |
| 60 | }; |
| 61 | u8 data[11]; |
| 62 | }; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | struct sabi_header_offsets { |
| 66 | u8 port; |
| 67 | u8 re_mem; |
| 68 | u8 iface_func; |
| 69 | u8 en_mem; |
| 70 | u8 data_offset; |
| 71 | u8 data_segment; |
| 72 | }; |
| 73 | |
| 74 | struct sabi_commands { |
| 75 | /* |
| 76 | * Brightness is 0 - 8, as described above. |
| 77 | * Value 0 is for the BIOS to use |
| 78 | */ |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 79 | u16 get_brightness; |
| 80 | u16 set_brightness; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 81 | |
| 82 | /* |
| 83 | * first byte: |
| 84 | * 0x00 - wireless is off |
| 85 | * 0x01 - wireless is on |
| 86 | * second byte: |
| 87 | * 0x02 - 3G is off |
| 88 | * 0x03 - 3G is on |
| 89 | * TODO, verify 3G is correct, that doesn't seem right... |
| 90 | */ |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 91 | u16 get_wireless_button; |
| 92 | u16 set_wireless_button; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 93 | |
| 94 | /* 0 is off, 1 is on */ |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 95 | u16 get_backlight; |
| 96 | u16 set_backlight; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 97 | |
| 98 | /* |
| 99 | * 0x80 or 0x00 - no action |
| 100 | * 0x81 - recovery key pressed |
| 101 | */ |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 102 | u16 get_recovery_mode; |
| 103 | u16 set_recovery_mode; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 104 | |
| 105 | /* |
| 106 | * on seclinux: 0 is low, 1 is high, |
| 107 | * on swsmi: 0 is normal, 1 is silent, 2 is turbo |
| 108 | */ |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 109 | u16 get_performance_level; |
| 110 | u16 set_performance_level; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 111 | |
Corentin Chary | cb5b5c9 | 2011-11-26 11:00:05 +0100 | [diff] [blame] | 112 | /* 0x80 is off, 0x81 is on */ |
| 113 | u16 get_battery_life_extender; |
| 114 | u16 set_battery_life_extender; |
| 115 | |
Corentin Chary | 3a75d37 | 2011-11-26 11:00:06 +0100 | [diff] [blame] | 116 | /* 0x80 is off, 0x81 is on */ |
| 117 | u16 get_usb_charge; |
| 118 | u16 set_usb_charge; |
| 119 | |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 120 | /* the first byte is for bluetooth and the third one is for wlan */ |
| 121 | u16 get_wireless_status; |
| 122 | u16 set_wireless_status; |
| 123 | |
Corentin Chary | f674ebf | 2011-11-26 11:00:08 +0100 | [diff] [blame] | 124 | /* 0x81 to read, (0x82 | level << 8) to set, 0xaabb to enable */ |
| 125 | u16 kbd_backlight; |
| 126 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 127 | /* |
| 128 | * Tell the BIOS that Linux is running on this machine. |
| 129 | * 81 is on, 80 is off |
| 130 | */ |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 131 | u16 set_linux; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | struct sabi_performance_level { |
| 135 | const char *name; |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 136 | u16 value; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 137 | }; |
| 138 | |
| 139 | struct sabi_config { |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 140 | int sabi_version; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 141 | const char *test_string; |
| 142 | u16 main_function; |
| 143 | const struct sabi_header_offsets header_offsets; |
| 144 | const struct sabi_commands commands; |
| 145 | const struct sabi_performance_level performance_levels[4]; |
| 146 | u8 min_brightness; |
| 147 | u8 max_brightness; |
| 148 | }; |
| 149 | |
| 150 | static const struct sabi_config sabi_configs[] = { |
| 151 | { |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 152 | /* I don't know if it is really 2, but it it is |
| 153 | * less than 3 anyway */ |
| 154 | .sabi_version = 2, |
| 155 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 156 | .test_string = "SECLINUX", |
| 157 | |
| 158 | .main_function = 0x4c49, |
| 159 | |
| 160 | .header_offsets = { |
| 161 | .port = 0x00, |
| 162 | .re_mem = 0x02, |
| 163 | .iface_func = 0x03, |
| 164 | .en_mem = 0x04, |
| 165 | .data_offset = 0x05, |
| 166 | .data_segment = 0x07, |
| 167 | }, |
| 168 | |
| 169 | .commands = { |
| 170 | .get_brightness = 0x00, |
| 171 | .set_brightness = 0x01, |
| 172 | |
| 173 | .get_wireless_button = 0x02, |
| 174 | .set_wireless_button = 0x03, |
| 175 | |
| 176 | .get_backlight = 0x04, |
| 177 | .set_backlight = 0x05, |
| 178 | |
| 179 | .get_recovery_mode = 0x06, |
| 180 | .set_recovery_mode = 0x07, |
| 181 | |
| 182 | .get_performance_level = 0x08, |
| 183 | .set_performance_level = 0x09, |
| 184 | |
Corentin Chary | cb5b5c9 | 2011-11-26 11:00:05 +0100 | [diff] [blame] | 185 | .get_battery_life_extender = 0xFFFF, |
| 186 | .set_battery_life_extender = 0xFFFF, |
| 187 | |
Corentin Chary | 3a75d37 | 2011-11-26 11:00:06 +0100 | [diff] [blame] | 188 | .get_usb_charge = 0xFFFF, |
| 189 | .set_usb_charge = 0xFFFF, |
| 190 | |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 191 | .get_wireless_status = 0xFFFF, |
| 192 | .set_wireless_status = 0xFFFF, |
| 193 | |
Corentin Chary | f674ebf | 2011-11-26 11:00:08 +0100 | [diff] [blame] | 194 | .kbd_backlight = 0xFFFF, |
| 195 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 196 | .set_linux = 0x0a, |
| 197 | }, |
| 198 | |
| 199 | .performance_levels = { |
| 200 | { |
| 201 | .name = "silent", |
| 202 | .value = 0, |
| 203 | }, |
| 204 | { |
| 205 | .name = "normal", |
| 206 | .value = 1, |
| 207 | }, |
| 208 | { }, |
| 209 | }, |
| 210 | .min_brightness = 1, |
| 211 | .max_brightness = 8, |
| 212 | }, |
| 213 | { |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 214 | .sabi_version = 3, |
| 215 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 216 | .test_string = "SwSmi@", |
| 217 | |
| 218 | .main_function = 0x5843, |
| 219 | |
| 220 | .header_offsets = { |
| 221 | .port = 0x00, |
| 222 | .re_mem = 0x04, |
| 223 | .iface_func = 0x02, |
| 224 | .en_mem = 0x03, |
| 225 | .data_offset = 0x05, |
| 226 | .data_segment = 0x07, |
| 227 | }, |
| 228 | |
| 229 | .commands = { |
| 230 | .get_brightness = 0x10, |
| 231 | .set_brightness = 0x11, |
| 232 | |
| 233 | .get_wireless_button = 0x12, |
| 234 | .set_wireless_button = 0x13, |
| 235 | |
| 236 | .get_backlight = 0x2d, |
| 237 | .set_backlight = 0x2e, |
| 238 | |
| 239 | .get_recovery_mode = 0xff, |
| 240 | .set_recovery_mode = 0xff, |
| 241 | |
| 242 | .get_performance_level = 0x31, |
| 243 | .set_performance_level = 0x32, |
| 244 | |
Corentin Chary | cb5b5c9 | 2011-11-26 11:00:05 +0100 | [diff] [blame] | 245 | .get_battery_life_extender = 0x65, |
| 246 | .set_battery_life_extender = 0x66, |
| 247 | |
Corentin Chary | 3a75d37 | 2011-11-26 11:00:06 +0100 | [diff] [blame] | 248 | .get_usb_charge = 0x67, |
| 249 | .set_usb_charge = 0x68, |
| 250 | |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 251 | .get_wireless_status = 0x69, |
| 252 | .set_wireless_status = 0x6a, |
| 253 | |
Corentin Chary | f674ebf | 2011-11-26 11:00:08 +0100 | [diff] [blame] | 254 | .kbd_backlight = 0x78, |
| 255 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 256 | .set_linux = 0xff, |
| 257 | }, |
| 258 | |
| 259 | .performance_levels = { |
| 260 | { |
| 261 | .name = "normal", |
| 262 | .value = 0, |
| 263 | }, |
| 264 | { |
| 265 | .name = "silent", |
| 266 | .value = 1, |
| 267 | }, |
| 268 | { |
| 269 | .name = "overclock", |
| 270 | .value = 2, |
| 271 | }, |
| 272 | { }, |
| 273 | }, |
| 274 | .min_brightness = 0, |
| 275 | .max_brightness = 8, |
| 276 | }, |
| 277 | { }, |
| 278 | }; |
| 279 | |
Corentin Chary | 5b80fc4 | 2011-11-26 11:00:03 +0100 | [diff] [blame] | 280 | /* |
| 281 | * samsung-laptop/ - debugfs root directory |
| 282 | * f0000_segment - dump f0000 segment |
| 283 | * command - current command |
| 284 | * data - current data |
| 285 | * d0, d1, d2, d3 - data fields |
| 286 | * call - call SABI using command and data |
| 287 | * |
| 288 | * This allow to call arbitrary sabi commands wihout |
| 289 | * modifying the driver at all. |
| 290 | * For example, setting the keyboard backlight brightness to 5 |
| 291 | * |
| 292 | * echo 0x78 > command |
| 293 | * echo 0x0582 > d0 |
| 294 | * echo 0 > d1 |
| 295 | * echo 0 > d2 |
| 296 | * echo 0 > d3 |
| 297 | * cat call |
| 298 | */ |
| 299 | |
| 300 | struct samsung_laptop_debug { |
| 301 | struct dentry *root; |
| 302 | struct sabi_data data; |
| 303 | u16 command; |
| 304 | |
| 305 | struct debugfs_blob_wrapper f0000_wrapper; |
| 306 | struct debugfs_blob_wrapper data_wrapper; |
Corentin Chary | 6f6ae06 | 2011-11-26 11:00:11 +0100 | [diff] [blame] | 307 | struct debugfs_blob_wrapper sdiag_wrapper; |
Corentin Chary | 5b80fc4 | 2011-11-26 11:00:03 +0100 | [diff] [blame] | 308 | }; |
| 309 | |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 310 | struct samsung_laptop; |
| 311 | |
| 312 | struct samsung_rfkill { |
| 313 | struct samsung_laptop *samsung; |
| 314 | struct rfkill *rfkill; |
| 315 | enum rfkill_type type; |
| 316 | }; |
| 317 | |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 318 | struct samsung_laptop { |
| 319 | const struct sabi_config *config; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 320 | |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 321 | void __iomem *sabi; |
| 322 | void __iomem *sabi_iface; |
| 323 | void __iomem *f0000_segment; |
| 324 | |
| 325 | struct mutex sabi_mutex; |
| 326 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 327 | struct platform_device *platform_device; |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 328 | struct backlight_device *backlight_device; |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 329 | |
| 330 | struct samsung_rfkill wlan; |
| 331 | struct samsung_rfkill bluetooth; |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 332 | |
Corentin Chary | f674ebf | 2011-11-26 11:00:08 +0100 | [diff] [blame] | 333 | struct led_classdev kbd_led; |
| 334 | int kbd_led_wk; |
| 335 | struct workqueue_struct *led_workqueue; |
| 336 | struct work_struct kbd_led_work; |
| 337 | |
Corentin Chary | 5b80fc4 | 2011-11-26 11:00:03 +0100 | [diff] [blame] | 338 | struct samsung_laptop_debug debug; |
| 339 | |
Corentin Chary | f34cd9c | 2011-11-26 11:00:00 +0100 | [diff] [blame] | 340 | bool handle_backlight; |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 341 | bool has_stepping_quirk; |
Corentin Chary | 6f6ae06 | 2011-11-26 11:00:11 +0100 | [diff] [blame] | 342 | |
| 343 | char sdiag[64]; |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 344 | }; |
| 345 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 346 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 347 | |
Rusty Russell | 90ab5ee | 2012-01-13 09:32:20 +1030 | [diff] [blame] | 348 | static bool force; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 349 | module_param(force, bool, 0); |
| 350 | MODULE_PARM_DESC(force, |
| 351 | "Disable the DMI check and forces the driver to be loaded"); |
| 352 | |
Rusty Russell | 90ab5ee | 2012-01-13 09:32:20 +1030 | [diff] [blame] | 353 | static bool debug; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 354 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
| 355 | MODULE_PARM_DESC(debug, "Debug enabled or not"); |
| 356 | |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 357 | static int sabi_command(struct samsung_laptop *samsung, u16 command, |
| 358 | struct sabi_data *in, |
| 359 | struct sabi_data *out) |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 360 | { |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 361 | const struct sabi_config *config = samsung->config; |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 362 | int ret = 0; |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 363 | u16 port = readw(samsung->sabi + config->header_offsets.port); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 364 | u8 complete, iface_data; |
| 365 | |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 366 | mutex_lock(&samsung->sabi_mutex); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 367 | |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 368 | if (debug) { |
| 369 | if (in) |
Corentin Chary | 2e77718 | 2011-11-26 11:00:12 +0100 | [diff] [blame] | 370 | pr_info("SABI command:0x%04x " |
| 371 | "data:{0x%08x, 0x%08x, 0x%04x, 0x%02x}", |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 372 | command, in->d0, in->d1, in->d2, in->d3); |
| 373 | else |
Corentin Chary | 2e77718 | 2011-11-26 11:00:12 +0100 | [diff] [blame] | 374 | pr_info("SABI command:0x%04x", command); |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 375 | } |
| 376 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 377 | /* enable memory to be able to write to it */ |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 378 | outb(readb(samsung->sabi + config->header_offsets.en_mem), port); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 379 | |
| 380 | /* write out the command */ |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 381 | writew(config->main_function, samsung->sabi_iface + SABI_IFACE_MAIN); |
| 382 | writew(command, samsung->sabi_iface + SABI_IFACE_SUB); |
| 383 | writeb(0, samsung->sabi_iface + SABI_IFACE_COMPLETE); |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 384 | if (in) { |
| 385 | writel(in->d0, samsung->sabi_iface + SABI_IFACE_DATA); |
| 386 | writel(in->d1, samsung->sabi_iface + SABI_IFACE_DATA + 4); |
| 387 | writew(in->d2, samsung->sabi_iface + SABI_IFACE_DATA + 8); |
| 388 | writeb(in->d3, samsung->sabi_iface + SABI_IFACE_DATA + 10); |
| 389 | } |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 390 | outb(readb(samsung->sabi + config->header_offsets.iface_func), port); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 391 | |
| 392 | /* write protect memory to make it safe */ |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 393 | outb(readb(samsung->sabi + config->header_offsets.re_mem), port); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 394 | |
| 395 | /* see if the command actually succeeded */ |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 396 | complete = readb(samsung->sabi_iface + SABI_IFACE_COMPLETE); |
| 397 | iface_data = readb(samsung->sabi_iface + SABI_IFACE_DATA); |
Corentin Chary | 2e77718 | 2011-11-26 11:00:12 +0100 | [diff] [blame] | 398 | |
| 399 | /* iface_data = 0xFF happens when a command is not known |
| 400 | * so we only add a warning in debug mode since we will |
| 401 | * probably issue some unknown command at startup to find |
| 402 | * out which features are supported */ |
| 403 | if (complete != 0xaa || (iface_data == 0xff && debug)) |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 404 | pr_warn("SABI command 0x%04x failed with" |
| 405 | " completion flag 0x%02x and interface data 0x%02x", |
| 406 | command, complete, iface_data); |
Corentin Chary | 2e77718 | 2011-11-26 11:00:12 +0100 | [diff] [blame] | 407 | |
| 408 | if (complete != 0xaa || iface_data == 0xff) { |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 409 | ret = -EINVAL; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 410 | goto exit; |
| 411 | } |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 412 | |
| 413 | if (out) { |
| 414 | out->d0 = readl(samsung->sabi_iface + SABI_IFACE_DATA); |
| 415 | out->d1 = readl(samsung->sabi_iface + SABI_IFACE_DATA + 4); |
| 416 | out->d2 = readw(samsung->sabi_iface + SABI_IFACE_DATA + 2); |
| 417 | out->d3 = readb(samsung->sabi_iface + SABI_IFACE_DATA + 1); |
| 418 | } |
| 419 | |
| 420 | if (debug && out) { |
Corentin Chary | 2e77718 | 2011-11-26 11:00:12 +0100 | [diff] [blame] | 421 | pr_info("SABI return data:{0x%08x, 0x%08x, 0x%04x, 0x%02x}", |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 422 | out->d0, out->d1, out->d2, out->d3); |
| 423 | } |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 424 | |
| 425 | exit: |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 426 | mutex_unlock(&samsung->sabi_mutex); |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 427 | return ret; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 428 | } |
| 429 | |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 430 | /* simple wrappers usable with most commands */ |
| 431 | static int sabi_set_commandb(struct samsung_laptop *samsung, |
| 432 | u16 command, u8 data) |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 433 | { |
David Rientjes | 8522944 | 2012-03-20 09:53:05 +0100 | [diff] [blame] | 434 | struct sabi_data in = { { { .d0 = 0, .d1 = 0, .d2 = 0, .d3 = 0 } } }; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 435 | |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 436 | in.data[0] = data; |
| 437 | return sabi_command(samsung, command, &in, NULL); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 438 | } |
| 439 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 440 | static int read_brightness(struct samsung_laptop *samsung) |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 441 | { |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 442 | const struct sabi_config *config = samsung->config; |
| 443 | const struct sabi_commands *commands = &samsung->config->commands; |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 444 | struct sabi_data sretval; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 445 | int user_brightness = 0; |
| 446 | int retval; |
| 447 | |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 448 | retval = sabi_command(samsung, commands->get_brightness, |
| 449 | NULL, &sretval); |
| 450 | if (retval) |
| 451 | return retval; |
| 452 | |
| 453 | user_brightness = sretval.data[0]; |
| 454 | if (user_brightness > config->min_brightness) |
| 455 | user_brightness -= config->min_brightness; |
| 456 | else |
| 457 | user_brightness = 0; |
| 458 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 459 | return user_brightness; |
| 460 | } |
| 461 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 462 | static void set_brightness(struct samsung_laptop *samsung, u8 user_brightness) |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 463 | { |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 464 | const struct sabi_config *config = samsung->config; |
| 465 | const struct sabi_commands *commands = &samsung->config->commands; |
| 466 | u8 user_level = user_brightness + config->min_brightness; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 467 | |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 468 | if (samsung->has_stepping_quirk && user_level != 0) { |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 469 | /* |
| 470 | * short circuit if the specified level is what's already set |
| 471 | * to prevent the screen from flickering needlessly |
| 472 | */ |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 473 | if (user_brightness == read_brightness(samsung)) |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 474 | return; |
| 475 | |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 476 | sabi_set_commandb(samsung, commands->set_brightness, 0); |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 477 | } |
| 478 | |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 479 | sabi_set_commandb(samsung, commands->set_brightness, user_level); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | static int get_brightness(struct backlight_device *bd) |
| 483 | { |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 484 | struct samsung_laptop *samsung = bl_get_data(bd); |
| 485 | |
| 486 | return read_brightness(samsung); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 487 | } |
| 488 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 489 | static void check_for_stepping_quirk(struct samsung_laptop *samsung) |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 490 | { |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 491 | int initial_level; |
| 492 | int check_level; |
| 493 | int orig_level = read_brightness(samsung); |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 494 | |
| 495 | /* |
| 496 | * Some laptops exhibit the strange behaviour of stepping toward |
| 497 | * (rather than setting) the brightness except when changing to/from |
| 498 | * brightness level 0. This behaviour is checked for here and worked |
| 499 | * around in set_brightness. |
| 500 | */ |
| 501 | |
John Serock | ba05b23 | 2011-10-13 06:42:01 -0400 | [diff] [blame] | 502 | if (orig_level == 0) |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 503 | set_brightness(samsung, 1); |
John Serock | ba05b23 | 2011-10-13 06:42:01 -0400 | [diff] [blame] | 504 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 505 | initial_level = read_brightness(samsung); |
John Serock | ba05b23 | 2011-10-13 06:42:01 -0400 | [diff] [blame] | 506 | |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 507 | if (initial_level <= 2) |
| 508 | check_level = initial_level + 2; |
| 509 | else |
| 510 | check_level = initial_level - 2; |
| 511 | |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 512 | samsung->has_stepping_quirk = false; |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 513 | set_brightness(samsung, check_level); |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 514 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 515 | if (read_brightness(samsung) != check_level) { |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 516 | samsung->has_stepping_quirk = true; |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 517 | pr_info("enabled workaround for brightness stepping quirk\n"); |
| 518 | } |
| 519 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 520 | set_brightness(samsung, orig_level); |
Jason Stubbs | ac08052 | 2011-09-20 09:16:13 -0700 | [diff] [blame] | 521 | } |
| 522 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 523 | static int update_status(struct backlight_device *bd) |
| 524 | { |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 525 | struct samsung_laptop *samsung = bl_get_data(bd); |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 526 | const struct sabi_commands *commands = &samsung->config->commands; |
| 527 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 528 | set_brightness(samsung, bd->props.brightness); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 529 | |
| 530 | if (bd->props.power == FB_BLANK_UNBLANK) |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 531 | sabi_set_commandb(samsung, commands->set_backlight, 1); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 532 | else |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 533 | sabi_set_commandb(samsung, commands->set_backlight, 0); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 534 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 535 | return 0; |
| 536 | } |
| 537 | |
| 538 | static const struct backlight_ops backlight_ops = { |
| 539 | .get_brightness = get_brightness, |
| 540 | .update_status = update_status, |
| 541 | }; |
| 542 | |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 543 | static int seclinux_rfkill_set(void *data, bool blocked) |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 544 | { |
Corentin Chary | 20db88e | 2011-12-15 08:27:39 +0100 | [diff] [blame] | 545 | struct samsung_rfkill *srfkill = data; |
| 546 | struct samsung_laptop *samsung = srfkill->samsung; |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 547 | const struct sabi_commands *commands = &samsung->config->commands; |
| 548 | |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 549 | return sabi_set_commandb(samsung, commands->set_wireless_button, |
| 550 | !blocked); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 551 | } |
| 552 | |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 553 | static struct rfkill_ops seclinux_rfkill_ops = { |
| 554 | .set_block = seclinux_rfkill_set, |
| 555 | }; |
| 556 | |
| 557 | static int swsmi_wireless_status(struct samsung_laptop *samsung, |
| 558 | struct sabi_data *data) |
| 559 | { |
| 560 | const struct sabi_commands *commands = &samsung->config->commands; |
| 561 | |
| 562 | return sabi_command(samsung, commands->get_wireless_status, |
| 563 | NULL, data); |
| 564 | } |
| 565 | |
| 566 | static int swsmi_rfkill_set(void *priv, bool blocked) |
| 567 | { |
| 568 | struct samsung_rfkill *srfkill = priv; |
| 569 | struct samsung_laptop *samsung = srfkill->samsung; |
| 570 | const struct sabi_commands *commands = &samsung->config->commands; |
| 571 | struct sabi_data data; |
| 572 | int ret, i; |
| 573 | |
| 574 | ret = swsmi_wireless_status(samsung, &data); |
| 575 | if (ret) |
| 576 | return ret; |
| 577 | |
| 578 | /* Don't set the state for non-present devices */ |
| 579 | for (i = 0; i < 4; i++) |
| 580 | if (data.data[i] == 0x02) |
| 581 | data.data[1] = 0; |
| 582 | |
| 583 | if (srfkill->type == RFKILL_TYPE_WLAN) |
| 584 | data.data[WL_STATUS_WLAN] = !blocked; |
| 585 | else if (srfkill->type == RFKILL_TYPE_BLUETOOTH) |
| 586 | data.data[WL_STATUS_BT] = !blocked; |
| 587 | |
| 588 | return sabi_command(samsung, commands->set_wireless_status, |
| 589 | &data, &data); |
| 590 | } |
| 591 | |
| 592 | static void swsmi_rfkill_query(struct rfkill *rfkill, void *priv) |
| 593 | { |
| 594 | struct samsung_rfkill *srfkill = priv; |
| 595 | struct samsung_laptop *samsung = srfkill->samsung; |
| 596 | struct sabi_data data; |
| 597 | int ret; |
| 598 | |
| 599 | ret = swsmi_wireless_status(samsung, &data); |
| 600 | if (ret) |
| 601 | return ; |
| 602 | |
| 603 | if (srfkill->type == RFKILL_TYPE_WLAN) |
| 604 | ret = data.data[WL_STATUS_WLAN]; |
| 605 | else if (srfkill->type == RFKILL_TYPE_BLUETOOTH) |
| 606 | ret = data.data[WL_STATUS_BT]; |
| 607 | else |
| 608 | return ; |
| 609 | |
| 610 | rfkill_set_sw_state(rfkill, !ret); |
| 611 | } |
| 612 | |
| 613 | static struct rfkill_ops swsmi_rfkill_ops = { |
| 614 | .set_block = swsmi_rfkill_set, |
| 615 | .query = swsmi_rfkill_query, |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 616 | }; |
| 617 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 618 | static ssize_t get_performance_level(struct device *dev, |
| 619 | struct device_attribute *attr, char *buf) |
| 620 | { |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 621 | struct samsung_laptop *samsung = dev_get_drvdata(dev); |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 622 | const struct sabi_config *config = samsung->config; |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 623 | const struct sabi_commands *commands = &config->commands; |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 624 | struct sabi_data sretval; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 625 | int retval; |
| 626 | int i; |
| 627 | |
| 628 | /* Read the state */ |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 629 | retval = sabi_command(samsung, commands->get_performance_level, |
| 630 | NULL, &sretval); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 631 | if (retval) |
| 632 | return retval; |
| 633 | |
| 634 | /* The logic is backwards, yeah, lots of fun... */ |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 635 | for (i = 0; config->performance_levels[i].name; ++i) { |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 636 | if (sretval.data[0] == config->performance_levels[i].value) |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 637 | return sprintf(buf, "%s\n", config->performance_levels[i].name); |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 638 | } |
| 639 | return sprintf(buf, "%s\n", "unknown"); |
| 640 | } |
| 641 | |
| 642 | static ssize_t set_performance_level(struct device *dev, |
| 643 | struct device_attribute *attr, const char *buf, |
| 644 | size_t count) |
| 645 | { |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 646 | struct samsung_laptop *samsung = dev_get_drvdata(dev); |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 647 | const struct sabi_config *config = samsung->config; |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 648 | const struct sabi_commands *commands = &config->commands; |
| 649 | int i; |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 650 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 651 | if (count < 1) |
| 652 | return count; |
| 653 | |
| 654 | for (i = 0; config->performance_levels[i].name; ++i) { |
| 655 | const struct sabi_performance_level *level = |
| 656 | &config->performance_levels[i]; |
| 657 | if (!strncasecmp(level->name, buf, strlen(level->name))) { |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 658 | sabi_set_commandb(samsung, |
| 659 | commands->set_performance_level, |
| 660 | level->value); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 661 | break; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 662 | } |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 663 | } |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 664 | |
| 665 | if (!config->performance_levels[i].name) |
| 666 | return -EINVAL; |
| 667 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 668 | return count; |
| 669 | } |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 670 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 671 | static DEVICE_ATTR(performance_level, S_IWUSR | S_IRUGO, |
| 672 | get_performance_level, set_performance_level); |
| 673 | |
Corentin Chary | cb5b5c9 | 2011-11-26 11:00:05 +0100 | [diff] [blame] | 674 | static int read_battery_life_extender(struct samsung_laptop *samsung) |
| 675 | { |
| 676 | const struct sabi_commands *commands = &samsung->config->commands; |
| 677 | struct sabi_data data; |
| 678 | int retval; |
| 679 | |
| 680 | if (commands->get_battery_life_extender == 0xFFFF) |
| 681 | return -ENODEV; |
| 682 | |
| 683 | memset(&data, 0, sizeof(data)); |
| 684 | data.data[0] = 0x80; |
| 685 | retval = sabi_command(samsung, commands->get_battery_life_extender, |
| 686 | &data, &data); |
| 687 | |
| 688 | if (retval) |
| 689 | return retval; |
| 690 | |
| 691 | if (data.data[0] != 0 && data.data[0] != 1) |
| 692 | return -ENODEV; |
| 693 | |
| 694 | return data.data[0]; |
| 695 | } |
| 696 | |
| 697 | static int write_battery_life_extender(struct samsung_laptop *samsung, |
| 698 | int enabled) |
| 699 | { |
| 700 | const struct sabi_commands *commands = &samsung->config->commands; |
| 701 | struct sabi_data data; |
| 702 | |
| 703 | memset(&data, 0, sizeof(data)); |
| 704 | data.data[0] = 0x80 | enabled; |
| 705 | return sabi_command(samsung, commands->set_battery_life_extender, |
| 706 | &data, NULL); |
| 707 | } |
| 708 | |
| 709 | static ssize_t get_battery_life_extender(struct device *dev, |
| 710 | struct device_attribute *attr, |
| 711 | char *buf) |
| 712 | { |
| 713 | struct samsung_laptop *samsung = dev_get_drvdata(dev); |
| 714 | int ret; |
| 715 | |
| 716 | ret = read_battery_life_extender(samsung); |
| 717 | if (ret < 0) |
| 718 | return ret; |
| 719 | |
| 720 | return sprintf(buf, "%d\n", ret); |
| 721 | } |
| 722 | |
| 723 | static ssize_t set_battery_life_extender(struct device *dev, |
| 724 | struct device_attribute *attr, |
| 725 | const char *buf, size_t count) |
| 726 | { |
| 727 | struct samsung_laptop *samsung = dev_get_drvdata(dev); |
| 728 | int ret, value; |
| 729 | |
| 730 | if (!count || sscanf(buf, "%i", &value) != 1) |
| 731 | return -EINVAL; |
| 732 | |
| 733 | ret = write_battery_life_extender(samsung, !!value); |
| 734 | if (ret < 0) |
| 735 | return ret; |
| 736 | |
| 737 | return count; |
| 738 | } |
| 739 | |
| 740 | static DEVICE_ATTR(battery_life_extender, S_IWUSR | S_IRUGO, |
| 741 | get_battery_life_extender, set_battery_life_extender); |
| 742 | |
Corentin Chary | 3a75d37 | 2011-11-26 11:00:06 +0100 | [diff] [blame] | 743 | static int read_usb_charge(struct samsung_laptop *samsung) |
| 744 | { |
| 745 | const struct sabi_commands *commands = &samsung->config->commands; |
| 746 | struct sabi_data data; |
| 747 | int retval; |
| 748 | |
| 749 | if (commands->get_usb_charge == 0xFFFF) |
| 750 | return -ENODEV; |
| 751 | |
| 752 | memset(&data, 0, sizeof(data)); |
| 753 | data.data[0] = 0x80; |
| 754 | retval = sabi_command(samsung, commands->get_usb_charge, |
| 755 | &data, &data); |
| 756 | |
| 757 | if (retval) |
| 758 | return retval; |
| 759 | |
| 760 | if (data.data[0] != 0 && data.data[0] != 1) |
| 761 | return -ENODEV; |
| 762 | |
| 763 | return data.data[0]; |
| 764 | } |
| 765 | |
| 766 | static int write_usb_charge(struct samsung_laptop *samsung, |
| 767 | int enabled) |
| 768 | { |
| 769 | const struct sabi_commands *commands = &samsung->config->commands; |
| 770 | struct sabi_data data; |
| 771 | |
| 772 | memset(&data, 0, sizeof(data)); |
| 773 | data.data[0] = 0x80 | enabled; |
| 774 | return sabi_command(samsung, commands->set_usb_charge, |
| 775 | &data, NULL); |
| 776 | } |
| 777 | |
| 778 | static ssize_t get_usb_charge(struct device *dev, |
| 779 | struct device_attribute *attr, |
| 780 | char *buf) |
| 781 | { |
| 782 | struct samsung_laptop *samsung = dev_get_drvdata(dev); |
| 783 | int ret; |
| 784 | |
| 785 | ret = read_usb_charge(samsung); |
| 786 | if (ret < 0) |
| 787 | return ret; |
| 788 | |
| 789 | return sprintf(buf, "%d\n", ret); |
| 790 | } |
| 791 | |
| 792 | static ssize_t set_usb_charge(struct device *dev, |
| 793 | struct device_attribute *attr, |
| 794 | const char *buf, size_t count) |
| 795 | { |
| 796 | struct samsung_laptop *samsung = dev_get_drvdata(dev); |
| 797 | int ret, value; |
| 798 | |
| 799 | if (!count || sscanf(buf, "%i", &value) != 1) |
| 800 | return -EINVAL; |
| 801 | |
| 802 | ret = write_usb_charge(samsung, !!value); |
| 803 | if (ret < 0) |
| 804 | return ret; |
| 805 | |
| 806 | return count; |
| 807 | } |
| 808 | |
| 809 | static DEVICE_ATTR(usb_charge, S_IWUSR | S_IRUGO, |
| 810 | get_usb_charge, set_usb_charge); |
| 811 | |
Corentin Chary | a66c166 | 2011-11-26 11:00:01 +0100 | [diff] [blame] | 812 | static struct attribute *platform_attributes[] = { |
| 813 | &dev_attr_performance_level.attr, |
Corentin Chary | cb5b5c9 | 2011-11-26 11:00:05 +0100 | [diff] [blame] | 814 | &dev_attr_battery_life_extender.attr, |
Corentin Chary | 3a75d37 | 2011-11-26 11:00:06 +0100 | [diff] [blame] | 815 | &dev_attr_usb_charge.attr, |
Corentin Chary | a66c166 | 2011-11-26 11:00:01 +0100 | [diff] [blame] | 816 | NULL |
| 817 | }; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 818 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 819 | static int find_signature(void __iomem *memcheck, const char *testStr) |
| 820 | { |
| 821 | int i = 0; |
| 822 | int loca; |
| 823 | |
| 824 | for (loca = 0; loca < 0xffff; loca++) { |
| 825 | char temp = readb(memcheck + loca); |
| 826 | |
| 827 | if (temp == testStr[i]) { |
| 828 | if (i == strlen(testStr)-1) |
| 829 | break; |
| 830 | ++i; |
| 831 | } else { |
| 832 | i = 0; |
| 833 | } |
| 834 | } |
| 835 | return loca; |
| 836 | } |
| 837 | |
| 838 | static void samsung_rfkill_exit(struct samsung_laptop *samsung) |
| 839 | { |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 840 | if (samsung->wlan.rfkill) { |
| 841 | rfkill_unregister(samsung->wlan.rfkill); |
| 842 | rfkill_destroy(samsung->wlan.rfkill); |
| 843 | samsung->wlan.rfkill = NULL; |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 844 | } |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 845 | if (samsung->bluetooth.rfkill) { |
| 846 | rfkill_unregister(samsung->bluetooth.rfkill); |
| 847 | rfkill_destroy(samsung->bluetooth.rfkill); |
| 848 | samsung->bluetooth.rfkill = NULL; |
| 849 | } |
| 850 | } |
| 851 | |
| 852 | static int samsung_new_rfkill(struct samsung_laptop *samsung, |
| 853 | struct samsung_rfkill *arfkill, |
| 854 | const char *name, enum rfkill_type type, |
| 855 | const struct rfkill_ops *ops, |
| 856 | int blocked) |
| 857 | { |
| 858 | struct rfkill **rfkill = &arfkill->rfkill; |
| 859 | int ret; |
| 860 | |
| 861 | arfkill->type = type; |
| 862 | arfkill->samsung = samsung; |
| 863 | |
| 864 | *rfkill = rfkill_alloc(name, &samsung->platform_device->dev, |
| 865 | type, ops, arfkill); |
| 866 | |
| 867 | if (!*rfkill) |
| 868 | return -EINVAL; |
| 869 | |
| 870 | if (blocked != -1) |
| 871 | rfkill_init_sw_state(*rfkill, blocked); |
| 872 | |
| 873 | ret = rfkill_register(*rfkill); |
| 874 | if (ret) { |
| 875 | rfkill_destroy(*rfkill); |
| 876 | *rfkill = NULL; |
| 877 | return ret; |
| 878 | } |
| 879 | return 0; |
| 880 | } |
| 881 | |
| 882 | static int __init samsung_rfkill_init_seclinux(struct samsung_laptop *samsung) |
| 883 | { |
| 884 | return samsung_new_rfkill(samsung, &samsung->wlan, "samsung-wlan", |
| 885 | RFKILL_TYPE_WLAN, &seclinux_rfkill_ops, -1); |
| 886 | } |
| 887 | |
| 888 | static int __init samsung_rfkill_init_swsmi(struct samsung_laptop *samsung) |
| 889 | { |
| 890 | struct sabi_data data; |
| 891 | int ret; |
| 892 | |
| 893 | ret = swsmi_wireless_status(samsung, &data); |
Corentin Chary | 20db88e | 2011-12-15 08:27:39 +0100 | [diff] [blame] | 894 | if (ret) { |
| 895 | /* Some swsmi laptops use the old seclinux way to control |
| 896 | * wireless devices */ |
| 897 | if (ret == -EINVAL) |
| 898 | ret = samsung_rfkill_init_seclinux(samsung); |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 899 | return ret; |
Corentin Chary | 20db88e | 2011-12-15 08:27:39 +0100 | [diff] [blame] | 900 | } |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 901 | |
| 902 | /* 0x02 seems to mean that the device is no present/available */ |
| 903 | |
| 904 | if (data.data[WL_STATUS_WLAN] != 0x02) |
| 905 | ret = samsung_new_rfkill(samsung, &samsung->wlan, |
| 906 | "samsung-wlan", |
| 907 | RFKILL_TYPE_WLAN, |
| 908 | &swsmi_rfkill_ops, |
| 909 | !data.data[WL_STATUS_WLAN]); |
| 910 | if (ret) |
| 911 | goto exit; |
| 912 | |
| 913 | if (data.data[WL_STATUS_BT] != 0x02) |
| 914 | ret = samsung_new_rfkill(samsung, &samsung->bluetooth, |
| 915 | "samsung-bluetooth", |
| 916 | RFKILL_TYPE_BLUETOOTH, |
| 917 | &swsmi_rfkill_ops, |
| 918 | !data.data[WL_STATUS_BT]); |
| 919 | if (ret) |
| 920 | goto exit; |
| 921 | |
| 922 | exit: |
| 923 | if (ret) |
| 924 | samsung_rfkill_exit(samsung); |
| 925 | |
| 926 | return ret; |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 927 | } |
| 928 | |
| 929 | static int __init samsung_rfkill_init(struct samsung_laptop *samsung) |
| 930 | { |
Corentin Chary | 84d482f | 2011-11-26 11:00:09 +0100 | [diff] [blame] | 931 | if (samsung->config->sabi_version == 2) |
| 932 | return samsung_rfkill_init_seclinux(samsung); |
| 933 | if (samsung->config->sabi_version == 3) |
| 934 | return samsung_rfkill_init_swsmi(samsung); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 935 | return 0; |
| 936 | } |
| 937 | |
Corentin Chary | f674ebf | 2011-11-26 11:00:08 +0100 | [diff] [blame] | 938 | static int kbd_backlight_enable(struct samsung_laptop *samsung) |
| 939 | { |
| 940 | const struct sabi_commands *commands = &samsung->config->commands; |
| 941 | struct sabi_data data; |
| 942 | int retval; |
| 943 | |
| 944 | if (commands->kbd_backlight == 0xFFFF) |
| 945 | return -ENODEV; |
| 946 | |
| 947 | memset(&data, 0, sizeof(data)); |
| 948 | data.d0 = 0xaabb; |
| 949 | retval = sabi_command(samsung, commands->kbd_backlight, |
| 950 | &data, &data); |
| 951 | |
| 952 | if (retval) |
| 953 | return retval; |
| 954 | |
| 955 | if (data.d0 != 0xccdd) |
| 956 | return -ENODEV; |
| 957 | return 0; |
| 958 | } |
| 959 | |
| 960 | static int kbd_backlight_read(struct samsung_laptop *samsung) |
| 961 | { |
| 962 | const struct sabi_commands *commands = &samsung->config->commands; |
| 963 | struct sabi_data data; |
| 964 | int retval; |
| 965 | |
| 966 | memset(&data, 0, sizeof(data)); |
| 967 | data.data[0] = 0x81; |
| 968 | retval = sabi_command(samsung, commands->kbd_backlight, |
| 969 | &data, &data); |
| 970 | |
| 971 | if (retval) |
| 972 | return retval; |
| 973 | |
| 974 | return data.data[0]; |
| 975 | } |
| 976 | |
| 977 | static int kbd_backlight_write(struct samsung_laptop *samsung, int brightness) |
| 978 | { |
| 979 | const struct sabi_commands *commands = &samsung->config->commands; |
| 980 | struct sabi_data data; |
| 981 | |
| 982 | memset(&data, 0, sizeof(data)); |
| 983 | data.d0 = 0x82 | ((brightness & 0xFF) << 8); |
| 984 | return sabi_command(samsung, commands->kbd_backlight, |
| 985 | &data, NULL); |
| 986 | } |
| 987 | |
| 988 | static void kbd_led_update(struct work_struct *work) |
| 989 | { |
| 990 | struct samsung_laptop *samsung; |
| 991 | |
| 992 | samsung = container_of(work, struct samsung_laptop, kbd_led_work); |
| 993 | kbd_backlight_write(samsung, samsung->kbd_led_wk); |
| 994 | } |
| 995 | |
| 996 | static void kbd_led_set(struct led_classdev *led_cdev, |
| 997 | enum led_brightness value) |
| 998 | { |
| 999 | struct samsung_laptop *samsung; |
| 1000 | |
| 1001 | samsung = container_of(led_cdev, struct samsung_laptop, kbd_led); |
| 1002 | |
| 1003 | if (value > samsung->kbd_led.max_brightness) |
| 1004 | value = samsung->kbd_led.max_brightness; |
| 1005 | else if (value < 0) |
| 1006 | value = 0; |
| 1007 | |
| 1008 | samsung->kbd_led_wk = value; |
| 1009 | queue_work(samsung->led_workqueue, &samsung->kbd_led_work); |
| 1010 | } |
| 1011 | |
| 1012 | static enum led_brightness kbd_led_get(struct led_classdev *led_cdev) |
| 1013 | { |
| 1014 | struct samsung_laptop *samsung; |
| 1015 | |
| 1016 | samsung = container_of(led_cdev, struct samsung_laptop, kbd_led); |
| 1017 | return kbd_backlight_read(samsung); |
| 1018 | } |
| 1019 | |
| 1020 | static void samsung_leds_exit(struct samsung_laptop *samsung) |
| 1021 | { |
| 1022 | if (!IS_ERR_OR_NULL(samsung->kbd_led.dev)) |
| 1023 | led_classdev_unregister(&samsung->kbd_led); |
| 1024 | if (samsung->led_workqueue) |
| 1025 | destroy_workqueue(samsung->led_workqueue); |
| 1026 | } |
| 1027 | |
| 1028 | static int __init samsung_leds_init(struct samsung_laptop *samsung) |
| 1029 | { |
| 1030 | int ret = 0; |
| 1031 | |
| 1032 | samsung->led_workqueue = create_singlethread_workqueue("led_workqueue"); |
| 1033 | if (!samsung->led_workqueue) |
| 1034 | return -ENOMEM; |
| 1035 | |
| 1036 | if (kbd_backlight_enable(samsung) >= 0) { |
| 1037 | INIT_WORK(&samsung->kbd_led_work, kbd_led_update); |
| 1038 | |
| 1039 | samsung->kbd_led.name = "samsung::kbd_backlight"; |
| 1040 | samsung->kbd_led.brightness_set = kbd_led_set; |
| 1041 | samsung->kbd_led.brightness_get = kbd_led_get; |
| 1042 | samsung->kbd_led.max_brightness = 8; |
| 1043 | |
| 1044 | ret = led_classdev_register(&samsung->platform_device->dev, |
| 1045 | &samsung->kbd_led); |
| 1046 | } |
| 1047 | |
| 1048 | if (ret) |
| 1049 | samsung_leds_exit(samsung); |
| 1050 | |
| 1051 | return ret; |
| 1052 | } |
| 1053 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1054 | static void samsung_backlight_exit(struct samsung_laptop *samsung) |
| 1055 | { |
| 1056 | if (samsung->backlight_device) { |
| 1057 | backlight_device_unregister(samsung->backlight_device); |
| 1058 | samsung->backlight_device = NULL; |
| 1059 | } |
| 1060 | } |
| 1061 | |
| 1062 | static int __init samsung_backlight_init(struct samsung_laptop *samsung) |
| 1063 | { |
| 1064 | struct backlight_device *bd; |
| 1065 | struct backlight_properties props; |
| 1066 | |
Corentin Chary | f34cd9c | 2011-11-26 11:00:00 +0100 | [diff] [blame] | 1067 | if (!samsung->handle_backlight) |
| 1068 | return 0; |
| 1069 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1070 | memset(&props, 0, sizeof(struct backlight_properties)); |
| 1071 | props.type = BACKLIGHT_PLATFORM; |
| 1072 | props.max_brightness = samsung->config->max_brightness - |
| 1073 | samsung->config->min_brightness; |
| 1074 | |
| 1075 | bd = backlight_device_register("samsung", |
| 1076 | &samsung->platform_device->dev, |
| 1077 | samsung, &backlight_ops, |
| 1078 | &props); |
| 1079 | if (IS_ERR(bd)) |
| 1080 | return PTR_ERR(bd); |
| 1081 | |
| 1082 | samsung->backlight_device = bd; |
| 1083 | samsung->backlight_device->props.brightness = read_brightness(samsung); |
| 1084 | samsung->backlight_device->props.power = FB_BLANK_UNBLANK; |
| 1085 | backlight_update_status(samsung->backlight_device); |
| 1086 | |
| 1087 | return 0; |
| 1088 | } |
| 1089 | |
Dan Carpenter | bde9e50 | 2012-03-20 09:53:07 +0100 | [diff] [blame^] | 1090 | static umode_t samsung_sysfs_is_visible(struct kobject *kobj, |
Corentin Chary | a66c166 | 2011-11-26 11:00:01 +0100 | [diff] [blame] | 1091 | struct attribute *attr, int idx) |
| 1092 | { |
| 1093 | struct device *dev = container_of(kobj, struct device, kobj); |
| 1094 | struct platform_device *pdev = to_platform_device(dev); |
| 1095 | struct samsung_laptop *samsung = platform_get_drvdata(pdev); |
| 1096 | bool ok = true; |
| 1097 | |
| 1098 | if (attr == &dev_attr_performance_level.attr) |
| 1099 | ok = !!samsung->config->performance_levels[0].name; |
Corentin Chary | cb5b5c9 | 2011-11-26 11:00:05 +0100 | [diff] [blame] | 1100 | if (attr == &dev_attr_battery_life_extender.attr) |
| 1101 | ok = !!(read_battery_life_extender(samsung) >= 0); |
Corentin Chary | 3a75d37 | 2011-11-26 11:00:06 +0100 | [diff] [blame] | 1102 | if (attr == &dev_attr_usb_charge.attr) |
| 1103 | ok = !!(read_usb_charge(samsung) >= 0); |
Corentin Chary | a66c166 | 2011-11-26 11:00:01 +0100 | [diff] [blame] | 1104 | |
| 1105 | return ok ? attr->mode : 0; |
| 1106 | } |
| 1107 | |
| 1108 | static struct attribute_group platform_attribute_group = { |
| 1109 | .is_visible = samsung_sysfs_is_visible, |
| 1110 | .attrs = platform_attributes |
| 1111 | }; |
| 1112 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1113 | static void samsung_sysfs_exit(struct samsung_laptop *samsung) |
| 1114 | { |
Corentin Chary | a66c166 | 2011-11-26 11:00:01 +0100 | [diff] [blame] | 1115 | struct platform_device *device = samsung->platform_device; |
| 1116 | |
| 1117 | sysfs_remove_group(&device->dev.kobj, &platform_attribute_group); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1118 | } |
| 1119 | |
| 1120 | static int __init samsung_sysfs_init(struct samsung_laptop *samsung) |
| 1121 | { |
Corentin Chary | a66c166 | 2011-11-26 11:00:01 +0100 | [diff] [blame] | 1122 | struct platform_device *device = samsung->platform_device; |
| 1123 | |
| 1124 | return sysfs_create_group(&device->dev.kobj, &platform_attribute_group); |
| 1125 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1126 | } |
| 1127 | |
Corentin Chary | 5b80fc4 | 2011-11-26 11:00:03 +0100 | [diff] [blame] | 1128 | static int show_call(struct seq_file *m, void *data) |
| 1129 | { |
| 1130 | struct samsung_laptop *samsung = m->private; |
| 1131 | struct sabi_data *sdata = &samsung->debug.data; |
| 1132 | int ret; |
| 1133 | |
| 1134 | seq_printf(m, "SABI 0x%04x {0x%08x, 0x%08x, 0x%04x, 0x%02x}\n", |
| 1135 | samsung->debug.command, |
| 1136 | sdata->d0, sdata->d1, sdata->d2, sdata->d3); |
| 1137 | |
| 1138 | ret = sabi_command(samsung, samsung->debug.command, sdata, sdata); |
| 1139 | |
| 1140 | if (ret) { |
| 1141 | seq_printf(m, "SABI command 0x%04x failed\n", |
| 1142 | samsung->debug.command); |
| 1143 | return ret; |
| 1144 | } |
| 1145 | |
| 1146 | seq_printf(m, "SABI {0x%08x, 0x%08x, 0x%04x, 0x%02x}\n", |
| 1147 | sdata->d0, sdata->d1, sdata->d2, sdata->d3); |
| 1148 | return 0; |
| 1149 | } |
| 1150 | |
| 1151 | static int samsung_debugfs_open(struct inode *inode, struct file *file) |
| 1152 | { |
| 1153 | return single_open(file, show_call, inode->i_private); |
| 1154 | } |
| 1155 | |
| 1156 | static const struct file_operations samsung_laptop_call_io_ops = { |
| 1157 | .owner = THIS_MODULE, |
| 1158 | .open = samsung_debugfs_open, |
| 1159 | .read = seq_read, |
| 1160 | .llseek = seq_lseek, |
| 1161 | .release = single_release, |
| 1162 | }; |
| 1163 | |
| 1164 | static void samsung_debugfs_exit(struct samsung_laptop *samsung) |
| 1165 | { |
| 1166 | debugfs_remove_recursive(samsung->debug.root); |
| 1167 | } |
| 1168 | |
| 1169 | static int samsung_debugfs_init(struct samsung_laptop *samsung) |
| 1170 | { |
| 1171 | struct dentry *dent; |
| 1172 | |
| 1173 | samsung->debug.root = debugfs_create_dir("samsung-laptop", NULL); |
| 1174 | if (!samsung->debug.root) { |
| 1175 | pr_err("failed to create debugfs directory"); |
| 1176 | goto error_debugfs; |
| 1177 | } |
| 1178 | |
| 1179 | samsung->debug.f0000_wrapper.data = samsung->f0000_segment; |
| 1180 | samsung->debug.f0000_wrapper.size = 0xffff; |
| 1181 | |
| 1182 | samsung->debug.data_wrapper.data = &samsung->debug.data; |
| 1183 | samsung->debug.data_wrapper.size = sizeof(samsung->debug.data); |
| 1184 | |
Corentin Chary | 6f6ae06 | 2011-11-26 11:00:11 +0100 | [diff] [blame] | 1185 | samsung->debug.sdiag_wrapper.data = samsung->sdiag; |
| 1186 | samsung->debug.sdiag_wrapper.size = strlen(samsung->sdiag); |
| 1187 | |
Corentin Chary | 5b80fc4 | 2011-11-26 11:00:03 +0100 | [diff] [blame] | 1188 | dent = debugfs_create_u16("command", S_IRUGO | S_IWUSR, |
| 1189 | samsung->debug.root, &samsung->debug.command); |
| 1190 | if (!dent) |
| 1191 | goto error_debugfs; |
| 1192 | |
| 1193 | dent = debugfs_create_u32("d0", S_IRUGO | S_IWUSR, samsung->debug.root, |
| 1194 | &samsung->debug.data.d0); |
| 1195 | if (!dent) |
| 1196 | goto error_debugfs; |
| 1197 | |
| 1198 | dent = debugfs_create_u32("d1", S_IRUGO | S_IWUSR, samsung->debug.root, |
| 1199 | &samsung->debug.data.d1); |
| 1200 | if (!dent) |
| 1201 | goto error_debugfs; |
| 1202 | |
| 1203 | dent = debugfs_create_u16("d2", S_IRUGO | S_IWUSR, samsung->debug.root, |
| 1204 | &samsung->debug.data.d2); |
| 1205 | if (!dent) |
| 1206 | goto error_debugfs; |
| 1207 | |
| 1208 | dent = debugfs_create_u8("d3", S_IRUGO | S_IWUSR, samsung->debug.root, |
| 1209 | &samsung->debug.data.d3); |
| 1210 | if (!dent) |
| 1211 | goto error_debugfs; |
| 1212 | |
| 1213 | dent = debugfs_create_blob("data", S_IRUGO | S_IWUSR, |
| 1214 | samsung->debug.root, |
| 1215 | &samsung->debug.data_wrapper); |
| 1216 | if (!dent) |
| 1217 | goto error_debugfs; |
| 1218 | |
| 1219 | dent = debugfs_create_blob("f0000_segment", S_IRUSR | S_IWUSR, |
| 1220 | samsung->debug.root, |
| 1221 | &samsung->debug.f0000_wrapper); |
| 1222 | if (!dent) |
| 1223 | goto error_debugfs; |
| 1224 | |
| 1225 | dent = debugfs_create_file("call", S_IFREG | S_IRUGO, |
| 1226 | samsung->debug.root, samsung, |
| 1227 | &samsung_laptop_call_io_ops); |
| 1228 | if (!dent) |
| 1229 | goto error_debugfs; |
| 1230 | |
Corentin Chary | 6f6ae06 | 2011-11-26 11:00:11 +0100 | [diff] [blame] | 1231 | dent = debugfs_create_blob("sdiag", S_IRUGO | S_IWUSR, |
| 1232 | samsung->debug.root, |
| 1233 | &samsung->debug.sdiag_wrapper); |
| 1234 | if (!dent) |
| 1235 | goto error_debugfs; |
| 1236 | |
Corentin Chary | 5b80fc4 | 2011-11-26 11:00:03 +0100 | [diff] [blame] | 1237 | return 0; |
| 1238 | |
| 1239 | error_debugfs: |
| 1240 | samsung_debugfs_exit(samsung); |
| 1241 | return -ENOMEM; |
| 1242 | } |
| 1243 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1244 | static void samsung_sabi_exit(struct samsung_laptop *samsung) |
| 1245 | { |
| 1246 | const struct sabi_config *config = samsung->config; |
| 1247 | |
| 1248 | /* Turn off "Linux" mode in the BIOS */ |
| 1249 | if (config && config->commands.set_linux != 0xff) |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 1250 | sabi_set_commandb(samsung, config->commands.set_linux, 0x80); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1251 | |
| 1252 | if (samsung->sabi_iface) { |
| 1253 | iounmap(samsung->sabi_iface); |
| 1254 | samsung->sabi_iface = NULL; |
| 1255 | } |
| 1256 | if (samsung->f0000_segment) { |
| 1257 | iounmap(samsung->f0000_segment); |
| 1258 | samsung->f0000_segment = NULL; |
| 1259 | } |
| 1260 | |
| 1261 | samsung->config = NULL; |
| 1262 | } |
| 1263 | |
Corentin Chary | 49dd773 | 2011-11-26 11:00:04 +0100 | [diff] [blame] | 1264 | static __init void samsung_sabi_infos(struct samsung_laptop *samsung, int loca, |
| 1265 | unsigned int ifaceP) |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1266 | { |
| 1267 | const struct sabi_config *config = samsung->config; |
| 1268 | |
| 1269 | printk(KERN_DEBUG "This computer supports SABI==%x\n", |
| 1270 | loca + 0xf0000 - 6); |
Corentin Chary | 49dd773 | 2011-11-26 11:00:04 +0100 | [diff] [blame] | 1271 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1272 | printk(KERN_DEBUG "SABI header:\n"); |
| 1273 | printk(KERN_DEBUG " SMI Port Number = 0x%04x\n", |
| 1274 | readw(samsung->sabi + config->header_offsets.port)); |
| 1275 | printk(KERN_DEBUG " SMI Interface Function = 0x%02x\n", |
| 1276 | readb(samsung->sabi + config->header_offsets.iface_func)); |
| 1277 | printk(KERN_DEBUG " SMI enable memory buffer = 0x%02x\n", |
| 1278 | readb(samsung->sabi + config->header_offsets.en_mem)); |
| 1279 | printk(KERN_DEBUG " SMI restore memory buffer = 0x%02x\n", |
| 1280 | readb(samsung->sabi + config->header_offsets.re_mem)); |
| 1281 | printk(KERN_DEBUG " SABI data offset = 0x%04x\n", |
| 1282 | readw(samsung->sabi + config->header_offsets.data_offset)); |
| 1283 | printk(KERN_DEBUG " SABI data segment = 0x%04x\n", |
| 1284 | readw(samsung->sabi + config->header_offsets.data_segment)); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1285 | |
Corentin Chary | 49dd773 | 2011-11-26 11:00:04 +0100 | [diff] [blame] | 1286 | printk(KERN_DEBUG " SABI pointer = 0x%08x\n", ifaceP); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1287 | } |
| 1288 | |
Corentin Chary | 6f6ae06 | 2011-11-26 11:00:11 +0100 | [diff] [blame] | 1289 | static void __init samsung_sabi_diag(struct samsung_laptop *samsung) |
| 1290 | { |
| 1291 | int loca = find_signature(samsung->f0000_segment, "SDiaG@"); |
| 1292 | int i; |
| 1293 | |
| 1294 | if (loca == 0xffff) |
| 1295 | return ; |
| 1296 | |
| 1297 | /* Example: |
| 1298 | * Ident: @SDiaG@686XX-N90X3A/966-SEC-07HL-S90X3A |
| 1299 | * |
| 1300 | * Product name: 90X3A |
| 1301 | * BIOS Version: 07HL |
| 1302 | */ |
| 1303 | loca += 1; |
| 1304 | for (i = 0; loca < 0xffff && i < sizeof(samsung->sdiag) - 1; loca++) { |
| 1305 | char temp = readb(samsung->f0000_segment + loca); |
| 1306 | |
| 1307 | if (isalnum(temp) || temp == '/' || temp == '-') |
| 1308 | samsung->sdiag[i++] = temp; |
| 1309 | else |
| 1310 | break ; |
| 1311 | } |
| 1312 | |
| 1313 | if (debug && samsung->sdiag[0]) |
| 1314 | pr_info("sdiag: %s", samsung->sdiag); |
| 1315 | } |
| 1316 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1317 | static int __init samsung_sabi_init(struct samsung_laptop *samsung) |
| 1318 | { |
| 1319 | const struct sabi_config *config = NULL; |
| 1320 | const struct sabi_commands *commands; |
| 1321 | unsigned int ifaceP; |
| 1322 | int ret = 0; |
| 1323 | int i; |
| 1324 | int loca; |
| 1325 | |
| 1326 | samsung->f0000_segment = ioremap_nocache(0xf0000, 0xffff); |
| 1327 | if (!samsung->f0000_segment) { |
Corentin Chary | 3be324a | 2011-11-26 11:00:10 +0100 | [diff] [blame] | 1328 | if (debug || force) |
| 1329 | pr_err("Can't map the segment at 0xf0000\n"); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1330 | ret = -EINVAL; |
| 1331 | goto exit; |
| 1332 | } |
| 1333 | |
Corentin Chary | 6f6ae06 | 2011-11-26 11:00:11 +0100 | [diff] [blame] | 1334 | samsung_sabi_diag(samsung); |
| 1335 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1336 | /* Try to find one of the signatures in memory to find the header */ |
| 1337 | for (i = 0; sabi_configs[i].test_string != 0; ++i) { |
| 1338 | samsung->config = &sabi_configs[i]; |
| 1339 | loca = find_signature(samsung->f0000_segment, |
| 1340 | samsung->config->test_string); |
| 1341 | if (loca != 0xffff) |
| 1342 | break; |
| 1343 | } |
| 1344 | |
| 1345 | if (loca == 0xffff) { |
Corentin Chary | 3be324a | 2011-11-26 11:00:10 +0100 | [diff] [blame] | 1346 | if (debug || force) |
| 1347 | pr_err("This computer does not support SABI\n"); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1348 | ret = -ENODEV; |
| 1349 | goto exit; |
| 1350 | } |
| 1351 | |
| 1352 | config = samsung->config; |
| 1353 | commands = &config->commands; |
| 1354 | |
| 1355 | /* point to the SMI port Number */ |
| 1356 | loca += 1; |
| 1357 | samsung->sabi = (samsung->f0000_segment + loca); |
| 1358 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1359 | /* Get a pointer to the SABI Interface */ |
| 1360 | ifaceP = (readw(samsung->sabi + config->header_offsets.data_segment) & 0x0ffff) << 4; |
| 1361 | ifaceP += readw(samsung->sabi + config->header_offsets.data_offset) & 0x0ffff; |
Corentin Chary | 49dd773 | 2011-11-26 11:00:04 +0100 | [diff] [blame] | 1362 | |
| 1363 | if (debug) |
| 1364 | samsung_sabi_infos(samsung, loca, ifaceP); |
| 1365 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1366 | samsung->sabi_iface = ioremap_nocache(ifaceP, 16); |
| 1367 | if (!samsung->sabi_iface) { |
| 1368 | pr_err("Can't remap %x\n", ifaceP); |
| 1369 | ret = -EINVAL; |
| 1370 | goto exit; |
| 1371 | } |
| 1372 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1373 | /* Turn on "Linux" mode in the BIOS */ |
| 1374 | if (commands->set_linux != 0xff) { |
Corentin Chary | 7e96071 | 2011-11-26 11:00:02 +0100 | [diff] [blame] | 1375 | int retval = sabi_set_commandb(samsung, |
| 1376 | commands->set_linux, 0x81); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1377 | if (retval) { |
| 1378 | pr_warn("Linux mode was not set!\n"); |
| 1379 | ret = -ENODEV; |
| 1380 | goto exit; |
| 1381 | } |
| 1382 | } |
| 1383 | |
| 1384 | /* Check for stepping quirk */ |
Corentin Chary | f34cd9c | 2011-11-26 11:00:00 +0100 | [diff] [blame] | 1385 | if (samsung->handle_backlight) |
| 1386 | check_for_stepping_quirk(samsung); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1387 | |
Corentin Chary | 2e77718 | 2011-11-26 11:00:12 +0100 | [diff] [blame] | 1388 | pr_info("detected SABI interface: %s\n", |
| 1389 | samsung->config->test_string); |
| 1390 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1391 | exit: |
| 1392 | if (ret) |
| 1393 | samsung_sabi_exit(samsung); |
| 1394 | |
| 1395 | return ret; |
| 1396 | } |
| 1397 | |
| 1398 | static void samsung_platform_exit(struct samsung_laptop *samsung) |
| 1399 | { |
| 1400 | if (samsung->platform_device) { |
| 1401 | platform_device_unregister(samsung->platform_device); |
| 1402 | samsung->platform_device = NULL; |
| 1403 | } |
| 1404 | } |
| 1405 | |
| 1406 | static int __init samsung_platform_init(struct samsung_laptop *samsung) |
| 1407 | { |
| 1408 | struct platform_device *pdev; |
| 1409 | |
| 1410 | pdev = platform_device_register_simple("samsung", -1, NULL, 0); |
| 1411 | if (IS_ERR(pdev)) |
| 1412 | return PTR_ERR(pdev); |
| 1413 | |
| 1414 | samsung->platform_device = pdev; |
| 1415 | platform_set_drvdata(samsung->platform_device, samsung); |
| 1416 | return 0; |
| 1417 | } |
| 1418 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1419 | static struct dmi_system_id __initdata samsung_dmi_table[] = { |
| 1420 | { |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1421 | .matches = { |
| 1422 | DMI_MATCH(DMI_SYS_VENDOR, |
| 1423 | "SAMSUNG ELECTRONICS CO., LTD."), |
Corentin Chary | 3be324a | 2011-11-26 11:00:10 +0100 | [diff] [blame] | 1424 | DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */ |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1425 | }, |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1426 | }, |
| 1427 | { |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1428 | .matches = { |
| 1429 | DMI_MATCH(DMI_SYS_VENDOR, |
| 1430 | "SAMSUNG ELECTRONICS CO., LTD."), |
Corentin Chary | 3be324a | 2011-11-26 11:00:10 +0100 | [diff] [blame] | 1431 | DMI_MATCH(DMI_CHASSIS_TYPE, "9"), /* Laptop */ |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1432 | }, |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1433 | }, |
| 1434 | { |
J Witteveen | 4e2441c | 2011-07-03 13:15:44 +0200 | [diff] [blame] | 1435 | .matches = { |
| 1436 | DMI_MATCH(DMI_SYS_VENDOR, |
| 1437 | "SAMSUNG ELECTRONICS CO., LTD."), |
Corentin Chary | 3be324a | 2011-11-26 11:00:10 +0100 | [diff] [blame] | 1438 | DMI_MATCH(DMI_CHASSIS_TYPE, "10"), /* Notebook */ |
J Witteveen | 4e2441c | 2011-07-03 13:15:44 +0200 | [diff] [blame] | 1439 | }, |
J Witteveen | 4e2441c | 2011-07-03 13:15:44 +0200 | [diff] [blame] | 1440 | }, |
| 1441 | { |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1442 | .matches = { |
| 1443 | DMI_MATCH(DMI_SYS_VENDOR, |
| 1444 | "SAMSUNG ELECTRONICS CO., LTD."), |
Corentin Chary | 3be324a | 2011-11-26 11:00:10 +0100 | [diff] [blame] | 1445 | DMI_MATCH(DMI_CHASSIS_TYPE, "14"), /* Sub-Notebook */ |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1446 | }, |
Tommaso Massimi | 7500eeb | 2011-09-20 09:16:09 -0700 | [diff] [blame] | 1447 | }, |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1448 | { }, |
| 1449 | }; |
| 1450 | MODULE_DEVICE_TABLE(dmi, samsung_dmi_table); |
| 1451 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1452 | static struct platform_device *samsung_platform_device; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1453 | |
| 1454 | static int __init samsung_init(void) |
| 1455 | { |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1456 | struct samsung_laptop *samsung; |
| 1457 | int ret; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1458 | |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1459 | if (!force && !dmi_check_system(samsung_dmi_table)) |
| 1460 | return -ENODEV; |
| 1461 | |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 1462 | samsung = kzalloc(sizeof(*samsung), GFP_KERNEL); |
| 1463 | if (!samsung) |
| 1464 | return -ENOMEM; |
| 1465 | |
| 1466 | mutex_init(&samsung->sabi_mutex); |
Corentin Chary | f34cd9c | 2011-11-26 11:00:00 +0100 | [diff] [blame] | 1467 | samsung->handle_backlight = true; |
| 1468 | |
| 1469 | #ifdef CONFIG_ACPI |
| 1470 | /* Don't handle backlight here if the acpi video already handle it */ |
Corentin Chary | 3be324a | 2011-11-26 11:00:10 +0100 | [diff] [blame] | 1471 | if (acpi_video_backlight_support()) |
Corentin Chary | f34cd9c | 2011-11-26 11:00:00 +0100 | [diff] [blame] | 1472 | samsung->handle_backlight = false; |
Corentin Chary | f34cd9c | 2011-11-26 11:00:00 +0100 | [diff] [blame] | 1473 | #endif |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1474 | ret = samsung_platform_init(samsung); |
| 1475 | if (ret) |
| 1476 | goto error_platform; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1477 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1478 | ret = samsung_sabi_init(samsung); |
| 1479 | if (ret) |
| 1480 | goto error_sabi; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1481 | |
Corentin Chary | 3be324a | 2011-11-26 11:00:10 +0100 | [diff] [blame] | 1482 | #ifdef CONFIG_ACPI |
| 1483 | /* Only log that if we are really on a sabi platform */ |
| 1484 | if (acpi_video_backlight_support()) |
| 1485 | pr_info("Backlight controlled by ACPI video driver\n"); |
| 1486 | #endif |
| 1487 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1488 | ret = samsung_sysfs_init(samsung); |
| 1489 | if (ret) |
| 1490 | goto error_sysfs; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1491 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1492 | ret = samsung_backlight_init(samsung); |
| 1493 | if (ret) |
| 1494 | goto error_backlight; |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 1495 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1496 | ret = samsung_rfkill_init(samsung); |
| 1497 | if (ret) |
| 1498 | goto error_rfkill; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1499 | |
Corentin Chary | f674ebf | 2011-11-26 11:00:08 +0100 | [diff] [blame] | 1500 | ret = samsung_leds_init(samsung); |
| 1501 | if (ret) |
| 1502 | goto error_leds; |
| 1503 | |
Corentin Chary | 5b80fc4 | 2011-11-26 11:00:03 +0100 | [diff] [blame] | 1504 | ret = samsung_debugfs_init(samsung); |
| 1505 | if (ret) |
| 1506 | goto error_debugfs; |
| 1507 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1508 | samsung_platform_device = samsung->platform_device; |
| 1509 | return ret; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1510 | |
Corentin Chary | 5b80fc4 | 2011-11-26 11:00:03 +0100 | [diff] [blame] | 1511 | error_debugfs: |
Corentin Chary | f674ebf | 2011-11-26 11:00:08 +0100 | [diff] [blame] | 1512 | samsung_leds_exit(samsung); |
| 1513 | error_leds: |
Corentin Chary | 5b80fc4 | 2011-11-26 11:00:03 +0100 | [diff] [blame] | 1514 | samsung_rfkill_exit(samsung); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1515 | error_rfkill: |
| 1516 | samsung_backlight_exit(samsung); |
| 1517 | error_backlight: |
| 1518 | samsung_sysfs_exit(samsung); |
| 1519 | error_sysfs: |
| 1520 | samsung_sabi_exit(samsung); |
| 1521 | error_sabi: |
| 1522 | samsung_platform_exit(samsung); |
| 1523 | error_platform: |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 1524 | kfree(samsung); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1525 | return ret; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1526 | } |
| 1527 | |
| 1528 | static void __exit samsung_exit(void) |
| 1529 | { |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1530 | struct samsung_laptop *samsung; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1531 | |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1532 | samsung = platform_get_drvdata(samsung_platform_device); |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 1533 | |
Corentin Chary | 5b80fc4 | 2011-11-26 11:00:03 +0100 | [diff] [blame] | 1534 | samsung_debugfs_exit(samsung); |
Corentin Chary | f674ebf | 2011-11-26 11:00:08 +0100 | [diff] [blame] | 1535 | samsung_leds_exit(samsung); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1536 | samsung_rfkill_exit(samsung); |
| 1537 | samsung_backlight_exit(samsung); |
| 1538 | samsung_sysfs_exit(samsung); |
| 1539 | samsung_sabi_exit(samsung); |
| 1540 | samsung_platform_exit(samsung); |
| 1541 | |
Corentin Chary | a6df489 | 2011-11-26 10:59:58 +0100 | [diff] [blame] | 1542 | kfree(samsung); |
Corentin Chary | 5dea7a2 | 2011-11-26 10:59:59 +0100 | [diff] [blame] | 1543 | samsung_platform_device = NULL; |
Greg Kroah-Hartman | 2d70b73 | 2011-03-11 12:41:19 -0500 | [diff] [blame] | 1544 | } |
| 1545 | |
| 1546 | module_init(samsung_init); |
| 1547 | module_exit(samsung_exit); |
| 1548 | |
| 1549 | MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@suse.de>"); |
| 1550 | MODULE_DESCRIPTION("Samsung Backlight driver"); |
| 1551 | MODULE_LICENSE("GPL"); |