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