toshiba_acpi.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272
  1. /*
  2. * toshiba_acpi.c - Toshiba Laptop ACPI Extras
  3. *
  4. *
  5. * Copyright (C) 2002-2004 John Belmonte
  6. * Copyright (C) 2008 Philip Langdale
  7. * Copyright (C) 2010 Pierre Ducroquet
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. *
  24. * The devolpment page for this driver is located at
  25. * http://memebeam.org/toys/ToshibaAcpiDriver.
  26. *
  27. * Credits:
  28. * Jonathan A. Buzzard - Toshiba HCI info, and critical tips on reverse
  29. * engineering the Windows drivers
  30. * Yasushi Nagato - changes for linux kernel 2.4 -> 2.5
  31. * Rob Miller - TV out and hotkeys help
  32. *
  33. *
  34. * TODO
  35. *
  36. */
  37. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  38. #define TOSHIBA_ACPI_VERSION "0.19"
  39. #define PROC_INTERFACE_VERSION 1
  40. #include <linux/kernel.h>
  41. #include <linux/module.h>
  42. #include <linux/init.h>
  43. #include <linux/types.h>
  44. #include <linux/proc_fs.h>
  45. #include <linux/seq_file.h>
  46. #include <linux/backlight.h>
  47. #include <linux/rfkill.h>
  48. #include <linux/input.h>
  49. #include <linux/input/sparse-keymap.h>
  50. #include <linux/leds.h>
  51. #include <linux/slab.h>
  52. #include <linux/workqueue.h>
  53. #include <linux/i8042.h>
  54. #include <asm/uaccess.h>
  55. #include <acpi/acpi_drivers.h>
  56. MODULE_AUTHOR("John Belmonte");
  57. MODULE_DESCRIPTION("Toshiba Laptop ACPI Extras Driver");
  58. MODULE_LICENSE("GPL");
  59. /* Scan code for Fn key on TOS1900 models */
  60. #define TOS1900_FN_SCAN 0x6e
  61. /* Toshiba ACPI method paths */
  62. #define METHOD_VIDEO_OUT "\\_SB_.VALX.DSSX"
  63. /* Toshiba HCI interface definitions
  64. *
  65. * HCI is Toshiba's "Hardware Control Interface" which is supposed to
  66. * be uniform across all their models. Ideally we would just call
  67. * dedicated ACPI methods instead of using this primitive interface.
  68. * However the ACPI methods seem to be incomplete in some areas (for
  69. * example they allow setting, but not reading, the LCD brightness value),
  70. * so this is still useful.
  71. */
  72. #define HCI_WORDS 6
  73. /* operations */
  74. #define HCI_SET 0xff00
  75. #define HCI_GET 0xfe00
  76. /* return codes */
  77. #define HCI_SUCCESS 0x0000
  78. #define HCI_FAILURE 0x1000
  79. #define HCI_NOT_SUPPORTED 0x8000
  80. #define HCI_EMPTY 0x8c00
  81. /* registers */
  82. #define HCI_FAN 0x0004
  83. #define HCI_SYSTEM_EVENT 0x0016
  84. #define HCI_VIDEO_OUT 0x001c
  85. #define HCI_HOTKEY_EVENT 0x001e
  86. #define HCI_LCD_BRIGHTNESS 0x002a
  87. #define HCI_WIRELESS 0x0056
  88. /* field definitions */
  89. #define HCI_HOTKEY_DISABLE 0x0b
  90. #define HCI_HOTKEY_ENABLE 0x09
  91. #define HCI_LCD_BRIGHTNESS_BITS 3
  92. #define HCI_LCD_BRIGHTNESS_SHIFT (16-HCI_LCD_BRIGHTNESS_BITS)
  93. #define HCI_LCD_BRIGHTNESS_LEVELS (1 << HCI_LCD_BRIGHTNESS_BITS)
  94. #define HCI_VIDEO_OUT_LCD 0x1
  95. #define HCI_VIDEO_OUT_CRT 0x2
  96. #define HCI_VIDEO_OUT_TV 0x4
  97. #define HCI_WIRELESS_KILL_SWITCH 0x01
  98. #define HCI_WIRELESS_BT_PRESENT 0x0f
  99. #define HCI_WIRELESS_BT_ATTACH 0x40
  100. #define HCI_WIRELESS_BT_POWER 0x80
  101. struct toshiba_acpi_dev {
  102. struct acpi_device *acpi_dev;
  103. const char *method_hci;
  104. struct rfkill *bt_rfk;
  105. struct input_dev *hotkey_dev;
  106. struct work_struct hotkey_work;
  107. struct backlight_device *backlight_dev;
  108. struct led_classdev led_dev;
  109. int force_fan;
  110. int last_key_event;
  111. int key_event_valid;
  112. unsigned int illumination_supported:1;
  113. unsigned int video_supported:1;
  114. unsigned int fan_supported:1;
  115. unsigned int system_event_supported:1;
  116. unsigned int ntfy_supported:1;
  117. unsigned int info_supported:1;
  118. struct mutex mutex;
  119. };
  120. static struct toshiba_acpi_dev *toshiba_acpi;
  121. static const struct acpi_device_id toshiba_device_ids[] = {
  122. {"TOS6200", 0},
  123. {"TOS6208", 0},
  124. {"TOS1900", 0},
  125. {"", 0},
  126. };
  127. MODULE_DEVICE_TABLE(acpi, toshiba_device_ids);
  128. static const struct key_entry toshiba_acpi_keymap[] __devinitconst = {
  129. { KE_KEY, 0x101, { KEY_MUTE } },
  130. { KE_KEY, 0x102, { KEY_ZOOMOUT } },
  131. { KE_KEY, 0x103, { KEY_ZOOMIN } },
  132. { KE_KEY, 0x13b, { KEY_COFFEE } },
  133. { KE_KEY, 0x13c, { KEY_BATTERY } },
  134. { KE_KEY, 0x13d, { KEY_SLEEP } },
  135. { KE_KEY, 0x13e, { KEY_SUSPEND } },
  136. { KE_KEY, 0x13f, { KEY_SWITCHVIDEOMODE } },
  137. { KE_KEY, 0x140, { KEY_BRIGHTNESSDOWN } },
  138. { KE_KEY, 0x141, { KEY_BRIGHTNESSUP } },
  139. { KE_KEY, 0x142, { KEY_WLAN } },
  140. { KE_KEY, 0x143, { KEY_PROG1 } },
  141. { KE_KEY, 0x17f, { KEY_FN } },
  142. { KE_KEY, 0xb05, { KEY_PROG2 } },
  143. { KE_KEY, 0xb06, { KEY_WWW } },
  144. { KE_KEY, 0xb07, { KEY_MAIL } },
  145. { KE_KEY, 0xb30, { KEY_STOP } },
  146. { KE_KEY, 0xb31, { KEY_PREVIOUSSONG } },
  147. { KE_KEY, 0xb32, { KEY_NEXTSONG } },
  148. { KE_KEY, 0xb33, { KEY_PLAYPAUSE } },
  149. { KE_KEY, 0xb5a, { KEY_MEDIA } },
  150. { KE_END, 0 },
  151. };
  152. /* utility
  153. */
  154. static __inline__ void _set_bit(u32 * word, u32 mask, int value)
  155. {
  156. *word = (*word & ~mask) | (mask * value);
  157. }
  158. /* acpi interface wrappers
  159. */
  160. static int write_acpi_int(const char *methodName, int val)
  161. {
  162. struct acpi_object_list params;
  163. union acpi_object in_objs[1];
  164. acpi_status status;
  165. params.count = ARRAY_SIZE(in_objs);
  166. params.pointer = in_objs;
  167. in_objs[0].type = ACPI_TYPE_INTEGER;
  168. in_objs[0].integer.value = val;
  169. status = acpi_evaluate_object(NULL, (char *)methodName, &params, NULL);
  170. return (status == AE_OK) ? 0 : -EIO;
  171. }
  172. /* Perform a raw HCI call. Here we don't care about input or output buffer
  173. * format.
  174. */
  175. static acpi_status hci_raw(struct toshiba_acpi_dev *dev,
  176. const u32 in[HCI_WORDS], u32 out[HCI_WORDS])
  177. {
  178. struct acpi_object_list params;
  179. union acpi_object in_objs[HCI_WORDS];
  180. struct acpi_buffer results;
  181. union acpi_object out_objs[HCI_WORDS + 1];
  182. acpi_status status;
  183. int i;
  184. params.count = HCI_WORDS;
  185. params.pointer = in_objs;
  186. for (i = 0; i < HCI_WORDS; ++i) {
  187. in_objs[i].type = ACPI_TYPE_INTEGER;
  188. in_objs[i].integer.value = in[i];
  189. }
  190. results.length = sizeof(out_objs);
  191. results.pointer = out_objs;
  192. status = acpi_evaluate_object(dev->acpi_dev->handle,
  193. (char *)dev->method_hci, &params,
  194. &results);
  195. if ((status == AE_OK) && (out_objs->package.count <= HCI_WORDS)) {
  196. for (i = 0; i < out_objs->package.count; ++i) {
  197. out[i] = out_objs->package.elements[i].integer.value;
  198. }
  199. }
  200. return status;
  201. }
  202. /* common hci tasks (get or set one or two value)
  203. *
  204. * In addition to the ACPI status, the HCI system returns a result which
  205. * may be useful (such as "not supported").
  206. */
  207. static acpi_status hci_write1(struct toshiba_acpi_dev *dev, u32 reg,
  208. u32 in1, u32 *result)
  209. {
  210. u32 in[HCI_WORDS] = { HCI_SET, reg, in1, 0, 0, 0 };
  211. u32 out[HCI_WORDS];
  212. acpi_status status = hci_raw(dev, in, out);
  213. *result = (status == AE_OK) ? out[0] : HCI_FAILURE;
  214. return status;
  215. }
  216. static acpi_status hci_read1(struct toshiba_acpi_dev *dev, u32 reg,
  217. u32 *out1, u32 *result)
  218. {
  219. u32 in[HCI_WORDS] = { HCI_GET, reg, 0, 0, 0, 0 };
  220. u32 out[HCI_WORDS];
  221. acpi_status status = hci_raw(dev, in, out);
  222. *out1 = out[2];
  223. *result = (status == AE_OK) ? out[0] : HCI_FAILURE;
  224. return status;
  225. }
  226. static acpi_status hci_write2(struct toshiba_acpi_dev *dev, u32 reg,
  227. u32 in1, u32 in2, u32 *result)
  228. {
  229. u32 in[HCI_WORDS] = { HCI_SET, reg, in1, in2, 0, 0 };
  230. u32 out[HCI_WORDS];
  231. acpi_status status = hci_raw(dev, in, out);
  232. *result = (status == AE_OK) ? out[0] : HCI_FAILURE;
  233. return status;
  234. }
  235. static acpi_status hci_read2(struct toshiba_acpi_dev *dev, u32 reg,
  236. u32 *out1, u32 *out2, u32 *result)
  237. {
  238. u32 in[HCI_WORDS] = { HCI_GET, reg, *out1, *out2, 0, 0 };
  239. u32 out[HCI_WORDS];
  240. acpi_status status = hci_raw(dev, in, out);
  241. *out1 = out[2];
  242. *out2 = out[3];
  243. *result = (status == AE_OK) ? out[0] : HCI_FAILURE;
  244. return status;
  245. }
  246. /* Illumination support */
  247. static int toshiba_illumination_available(struct toshiba_acpi_dev *dev)
  248. {
  249. u32 in[HCI_WORDS] = { 0, 0, 0, 0, 0, 0 };
  250. u32 out[HCI_WORDS];
  251. acpi_status status;
  252. in[0] = 0xf100;
  253. status = hci_raw(dev, in, out);
  254. if (ACPI_FAILURE(status)) {
  255. pr_info("Illumination device not available\n");
  256. return 0;
  257. }
  258. in[0] = 0xf400;
  259. status = hci_raw(dev, in, out);
  260. return 1;
  261. }
  262. static void toshiba_illumination_set(struct led_classdev *cdev,
  263. enum led_brightness brightness)
  264. {
  265. struct toshiba_acpi_dev *dev = container_of(cdev,
  266. struct toshiba_acpi_dev, led_dev);
  267. u32 in[HCI_WORDS] = { 0, 0, 0, 0, 0, 0 };
  268. u32 out[HCI_WORDS];
  269. acpi_status status;
  270. /* First request : initialize communication. */
  271. in[0] = 0xf100;
  272. status = hci_raw(dev, in, out);
  273. if (ACPI_FAILURE(status)) {
  274. pr_info("Illumination device not available\n");
  275. return;
  276. }
  277. if (brightness) {
  278. /* Switch the illumination on */
  279. in[0] = 0xf400;
  280. in[1] = 0x14e;
  281. in[2] = 1;
  282. status = hci_raw(dev, in, out);
  283. if (ACPI_FAILURE(status)) {
  284. pr_info("ACPI call for illumination failed\n");
  285. return;
  286. }
  287. } else {
  288. /* Switch the illumination off */
  289. in[0] = 0xf400;
  290. in[1] = 0x14e;
  291. in[2] = 0;
  292. status = hci_raw(dev, in, out);
  293. if (ACPI_FAILURE(status)) {
  294. pr_info("ACPI call for illumination failed.\n");
  295. return;
  296. }
  297. }
  298. /* Last request : close communication. */
  299. in[0] = 0xf200;
  300. in[1] = 0;
  301. in[2] = 0;
  302. hci_raw(dev, in, out);
  303. }
  304. static enum led_brightness toshiba_illumination_get(struct led_classdev *cdev)
  305. {
  306. struct toshiba_acpi_dev *dev = container_of(cdev,
  307. struct toshiba_acpi_dev, led_dev);
  308. u32 in[HCI_WORDS] = { 0, 0, 0, 0, 0, 0 };
  309. u32 out[HCI_WORDS];
  310. acpi_status status;
  311. enum led_brightness result;
  312. /* First request : initialize communication. */
  313. in[0] = 0xf100;
  314. status = hci_raw(dev, in, out);
  315. if (ACPI_FAILURE(status)) {
  316. pr_info("Illumination device not available\n");
  317. return LED_OFF;
  318. }
  319. /* Check the illumination */
  320. in[0] = 0xf300;
  321. in[1] = 0x14e;
  322. status = hci_raw(dev, in, out);
  323. if (ACPI_FAILURE(status)) {
  324. pr_info("ACPI call for illumination failed.\n");
  325. return LED_OFF;
  326. }
  327. result = out[2] ? LED_FULL : LED_OFF;
  328. /* Last request : close communication. */
  329. in[0] = 0xf200;
  330. in[1] = 0;
  331. in[2] = 0;
  332. hci_raw(dev, in, out);
  333. return result;
  334. }
  335. /* Bluetooth rfkill handlers */
  336. static u32 hci_get_bt_present(struct toshiba_acpi_dev *dev, bool *present)
  337. {
  338. u32 hci_result;
  339. u32 value, value2;
  340. value = 0;
  341. value2 = 0;
  342. hci_read2(dev, HCI_WIRELESS, &value, &value2, &hci_result);
  343. if (hci_result == HCI_SUCCESS)
  344. *present = (value & HCI_WIRELESS_BT_PRESENT) ? true : false;
  345. return hci_result;
  346. }
  347. static u32 hci_get_radio_state(struct toshiba_acpi_dev *dev, bool *radio_state)
  348. {
  349. u32 hci_result;
  350. u32 value, value2;
  351. value = 0;
  352. value2 = 0x0001;
  353. hci_read2(dev, HCI_WIRELESS, &value, &value2, &hci_result);
  354. *radio_state = value & HCI_WIRELESS_KILL_SWITCH;
  355. return hci_result;
  356. }
  357. static int bt_rfkill_set_block(void *data, bool blocked)
  358. {
  359. struct toshiba_acpi_dev *dev = data;
  360. u32 result1, result2;
  361. u32 value;
  362. int err;
  363. bool radio_state;
  364. value = (blocked == false);
  365. mutex_lock(&dev->mutex);
  366. if (hci_get_radio_state(dev, &radio_state) != HCI_SUCCESS) {
  367. err = -EIO;
  368. goto out;
  369. }
  370. if (!radio_state) {
  371. err = 0;
  372. goto out;
  373. }
  374. hci_write2(dev, HCI_WIRELESS, value, HCI_WIRELESS_BT_POWER, &result1);
  375. hci_write2(dev, HCI_WIRELESS, value, HCI_WIRELESS_BT_ATTACH, &result2);
  376. if (result1 != HCI_SUCCESS || result2 != HCI_SUCCESS)
  377. err = -EIO;
  378. else
  379. err = 0;
  380. out:
  381. mutex_unlock(&dev->mutex);
  382. return err;
  383. }
  384. static void bt_rfkill_poll(struct rfkill *rfkill, void *data)
  385. {
  386. bool new_rfk_state;
  387. bool value;
  388. u32 hci_result;
  389. struct toshiba_acpi_dev *dev = data;
  390. mutex_lock(&dev->mutex);
  391. hci_result = hci_get_radio_state(dev, &value);
  392. if (hci_result != HCI_SUCCESS) {
  393. /* Can't do anything useful */
  394. mutex_unlock(&dev->mutex);
  395. return;
  396. }
  397. new_rfk_state = value;
  398. mutex_unlock(&dev->mutex);
  399. if (rfkill_set_hw_state(rfkill, !new_rfk_state))
  400. bt_rfkill_set_block(data, true);
  401. }
  402. static const struct rfkill_ops toshiba_rfk_ops = {
  403. .set_block = bt_rfkill_set_block,
  404. .poll = bt_rfkill_poll,
  405. };
  406. static struct proc_dir_entry *toshiba_proc_dir /*= 0*/ ;
  407. static int get_lcd(struct backlight_device *bd)
  408. {
  409. struct toshiba_acpi_dev *dev = bl_get_data(bd);
  410. u32 hci_result;
  411. u32 value;
  412. hci_read1(dev, HCI_LCD_BRIGHTNESS, &value, &hci_result);
  413. if (hci_result == HCI_SUCCESS)
  414. return (value >> HCI_LCD_BRIGHTNESS_SHIFT);
  415. return -EIO;
  416. }
  417. static int lcd_proc_show(struct seq_file *m, void *v)
  418. {
  419. struct toshiba_acpi_dev *dev = m->private;
  420. int value;
  421. if (!dev->backlight_dev)
  422. return -ENODEV;
  423. value = get_lcd(dev->backlight_dev);
  424. if (value >= 0) {
  425. seq_printf(m, "brightness: %d\n", value);
  426. seq_printf(m, "brightness_levels: %d\n",
  427. HCI_LCD_BRIGHTNESS_LEVELS);
  428. return 0;
  429. }
  430. pr_err("Error reading LCD brightness\n");
  431. return -EIO;
  432. }
  433. static int lcd_proc_open(struct inode *inode, struct file *file)
  434. {
  435. return single_open(file, lcd_proc_show, PDE(inode)->data);
  436. }
  437. static int set_lcd(struct toshiba_acpi_dev *dev, int value)
  438. {
  439. u32 hci_result;
  440. value = value << HCI_LCD_BRIGHTNESS_SHIFT;
  441. hci_write1(dev, HCI_LCD_BRIGHTNESS, value, &hci_result);
  442. return hci_result == HCI_SUCCESS ? 0 : -EIO;
  443. }
  444. static int set_lcd_status(struct backlight_device *bd)
  445. {
  446. struct toshiba_acpi_dev *dev = bl_get_data(bd);
  447. return set_lcd(dev, bd->props.brightness);
  448. }
  449. static ssize_t lcd_proc_write(struct file *file, const char __user *buf,
  450. size_t count, loff_t *pos)
  451. {
  452. struct toshiba_acpi_dev *dev = PDE(file->f_path.dentry->d_inode)->data;
  453. char cmd[42];
  454. size_t len;
  455. int value;
  456. int ret;
  457. len = min(count, sizeof(cmd) - 1);
  458. if (copy_from_user(cmd, buf, len))
  459. return -EFAULT;
  460. cmd[len] = '\0';
  461. if (sscanf(cmd, " brightness : %i", &value) == 1 &&
  462. value >= 0 && value < HCI_LCD_BRIGHTNESS_LEVELS) {
  463. ret = set_lcd(dev, value);
  464. if (ret == 0)
  465. ret = count;
  466. } else {
  467. ret = -EINVAL;
  468. }
  469. return ret;
  470. }
  471. static const struct file_operations lcd_proc_fops = {
  472. .owner = THIS_MODULE,
  473. .open = lcd_proc_open,
  474. .read = seq_read,
  475. .llseek = seq_lseek,
  476. .release = single_release,
  477. .write = lcd_proc_write,
  478. };
  479. static int get_video_status(struct toshiba_acpi_dev *dev, u32 *status)
  480. {
  481. u32 hci_result;
  482. hci_read1(dev, HCI_VIDEO_OUT, status, &hci_result);
  483. return hci_result == HCI_SUCCESS ? 0 : -EIO;
  484. }
  485. static int video_proc_show(struct seq_file *m, void *v)
  486. {
  487. struct toshiba_acpi_dev *dev = m->private;
  488. u32 value;
  489. int ret;
  490. ret = get_video_status(dev, &value);
  491. if (!ret) {
  492. int is_lcd = (value & HCI_VIDEO_OUT_LCD) ? 1 : 0;
  493. int is_crt = (value & HCI_VIDEO_OUT_CRT) ? 1 : 0;
  494. int is_tv = (value & HCI_VIDEO_OUT_TV) ? 1 : 0;
  495. seq_printf(m, "lcd_out: %d\n", is_lcd);
  496. seq_printf(m, "crt_out: %d\n", is_crt);
  497. seq_printf(m, "tv_out: %d\n", is_tv);
  498. }
  499. return ret;
  500. }
  501. static int video_proc_open(struct inode *inode, struct file *file)
  502. {
  503. return single_open(file, video_proc_show, PDE(inode)->data);
  504. }
  505. static ssize_t video_proc_write(struct file *file, const char __user *buf,
  506. size_t count, loff_t *pos)
  507. {
  508. struct toshiba_acpi_dev *dev = PDE(file->f_path.dentry->d_inode)->data;
  509. char *cmd, *buffer;
  510. int ret;
  511. int value;
  512. int remain = count;
  513. int lcd_out = -1;
  514. int crt_out = -1;
  515. int tv_out = -1;
  516. u32 video_out;
  517. cmd = kmalloc(count + 1, GFP_KERNEL);
  518. if (!cmd)
  519. return -ENOMEM;
  520. if (copy_from_user(cmd, buf, count)) {
  521. kfree(cmd);
  522. return -EFAULT;
  523. }
  524. cmd[count] = '\0';
  525. buffer = cmd;
  526. /* scan expression. Multiple expressions may be delimited with ;
  527. *
  528. * NOTE: to keep scanning simple, invalid fields are ignored
  529. */
  530. while (remain) {
  531. if (sscanf(buffer, " lcd_out : %i", &value) == 1)
  532. lcd_out = value & 1;
  533. else if (sscanf(buffer, " crt_out : %i", &value) == 1)
  534. crt_out = value & 1;
  535. else if (sscanf(buffer, " tv_out : %i", &value) == 1)
  536. tv_out = value & 1;
  537. /* advance to one character past the next ; */
  538. do {
  539. ++buffer;
  540. --remain;
  541. }
  542. while (remain && *(buffer - 1) != ';');
  543. }
  544. kfree(cmd);
  545. ret = get_video_status(dev, &video_out);
  546. if (!ret) {
  547. unsigned int new_video_out = video_out;
  548. if (lcd_out != -1)
  549. _set_bit(&new_video_out, HCI_VIDEO_OUT_LCD, lcd_out);
  550. if (crt_out != -1)
  551. _set_bit(&new_video_out, HCI_VIDEO_OUT_CRT, crt_out);
  552. if (tv_out != -1)
  553. _set_bit(&new_video_out, HCI_VIDEO_OUT_TV, tv_out);
  554. /* To avoid unnecessary video disruption, only write the new
  555. * video setting if something changed. */
  556. if (new_video_out != video_out)
  557. ret = write_acpi_int(METHOD_VIDEO_OUT, new_video_out);
  558. }
  559. return ret ? ret : count;
  560. }
  561. static const struct file_operations video_proc_fops = {
  562. .owner = THIS_MODULE,
  563. .open = video_proc_open,
  564. .read = seq_read,
  565. .llseek = seq_lseek,
  566. .release = single_release,
  567. .write = video_proc_write,
  568. };
  569. static int get_fan_status(struct toshiba_acpi_dev *dev, u32 *status)
  570. {
  571. u32 hci_result;
  572. hci_read1(dev, HCI_FAN, status, &hci_result);
  573. return hci_result == HCI_SUCCESS ? 0 : -EIO;
  574. }
  575. static int fan_proc_show(struct seq_file *m, void *v)
  576. {
  577. struct toshiba_acpi_dev *dev = m->private;
  578. int ret;
  579. u32 value;
  580. ret = get_fan_status(dev, &value);
  581. if (!ret) {
  582. seq_printf(m, "running: %d\n", (value > 0));
  583. seq_printf(m, "force_on: %d\n", dev->force_fan);
  584. }
  585. return ret;
  586. }
  587. static int fan_proc_open(struct inode *inode, struct file *file)
  588. {
  589. return single_open(file, fan_proc_show, PDE(inode)->data);
  590. }
  591. static ssize_t fan_proc_write(struct file *file, const char __user *buf,
  592. size_t count, loff_t *pos)
  593. {
  594. struct toshiba_acpi_dev *dev = PDE(file->f_path.dentry->d_inode)->data;
  595. char cmd[42];
  596. size_t len;
  597. int value;
  598. u32 hci_result;
  599. len = min(count, sizeof(cmd) - 1);
  600. if (copy_from_user(cmd, buf, len))
  601. return -EFAULT;
  602. cmd[len] = '\0';
  603. if (sscanf(cmd, " force_on : %i", &value) == 1 &&
  604. value >= 0 && value <= 1) {
  605. hci_write1(dev, HCI_FAN, value, &hci_result);
  606. if (hci_result != HCI_SUCCESS)
  607. return -EIO;
  608. else
  609. dev->force_fan = value;
  610. } else {
  611. return -EINVAL;
  612. }
  613. return count;
  614. }
  615. static const struct file_operations fan_proc_fops = {
  616. .owner = THIS_MODULE,
  617. .open = fan_proc_open,
  618. .read = seq_read,
  619. .llseek = seq_lseek,
  620. .release = single_release,
  621. .write = fan_proc_write,
  622. };
  623. static int keys_proc_show(struct seq_file *m, void *v)
  624. {
  625. struct toshiba_acpi_dev *dev = m->private;
  626. u32 hci_result;
  627. u32 value;
  628. if (!dev->key_event_valid && dev->system_event_supported) {
  629. hci_read1(dev, HCI_SYSTEM_EVENT, &value, &hci_result);
  630. if (hci_result == HCI_SUCCESS) {
  631. dev->key_event_valid = 1;
  632. dev->last_key_event = value;
  633. } else if (hci_result == HCI_EMPTY) {
  634. /* better luck next time */
  635. } else if (hci_result == HCI_NOT_SUPPORTED) {
  636. /* This is a workaround for an unresolved issue on
  637. * some machines where system events sporadically
  638. * become disabled. */
  639. hci_write1(dev, HCI_SYSTEM_EVENT, 1, &hci_result);
  640. pr_notice("Re-enabled hotkeys\n");
  641. } else {
  642. pr_err("Error reading hotkey status\n");
  643. return -EIO;
  644. }
  645. }
  646. seq_printf(m, "hotkey_ready: %d\n", dev->key_event_valid);
  647. seq_printf(m, "hotkey: 0x%04x\n", dev->last_key_event);
  648. return 0;
  649. }
  650. static int keys_proc_open(struct inode *inode, struct file *file)
  651. {
  652. return single_open(file, keys_proc_show, PDE(inode)->data);
  653. }
  654. static ssize_t keys_proc_write(struct file *file, const char __user *buf,
  655. size_t count, loff_t *pos)
  656. {
  657. struct toshiba_acpi_dev *dev = PDE(file->f_path.dentry->d_inode)->data;
  658. char cmd[42];
  659. size_t len;
  660. int value;
  661. len = min(count, sizeof(cmd) - 1);
  662. if (copy_from_user(cmd, buf, len))
  663. return -EFAULT;
  664. cmd[len] = '\0';
  665. if (sscanf(cmd, " hotkey_ready : %i", &value) == 1 && value == 0) {
  666. dev->key_event_valid = 0;
  667. } else {
  668. return -EINVAL;
  669. }
  670. return count;
  671. }
  672. static const struct file_operations keys_proc_fops = {
  673. .owner = THIS_MODULE,
  674. .open = keys_proc_open,
  675. .read = seq_read,
  676. .llseek = seq_lseek,
  677. .release = single_release,
  678. .write = keys_proc_write,
  679. };
  680. static int version_proc_show(struct seq_file *m, void *v)
  681. {
  682. seq_printf(m, "driver: %s\n", TOSHIBA_ACPI_VERSION);
  683. seq_printf(m, "proc_interface: %d\n", PROC_INTERFACE_VERSION);
  684. return 0;
  685. }
  686. static int version_proc_open(struct inode *inode, struct file *file)
  687. {
  688. return single_open(file, version_proc_show, PDE(inode)->data);
  689. }
  690. static const struct file_operations version_proc_fops = {
  691. .owner = THIS_MODULE,
  692. .open = version_proc_open,
  693. .read = seq_read,
  694. .llseek = seq_lseek,
  695. .release = single_release,
  696. };
  697. /* proc and module init
  698. */
  699. #define PROC_TOSHIBA "toshiba"
  700. static void __devinit
  701. create_toshiba_proc_entries(struct toshiba_acpi_dev *dev)
  702. {
  703. if (dev->backlight_dev)
  704. proc_create_data("lcd", S_IRUGO | S_IWUSR, toshiba_proc_dir,
  705. &lcd_proc_fops, dev);
  706. if (dev->video_supported)
  707. proc_create_data("video", S_IRUGO | S_IWUSR, toshiba_proc_dir,
  708. &video_proc_fops, dev);
  709. if (dev->fan_supported)
  710. proc_create_data("fan", S_IRUGO | S_IWUSR, toshiba_proc_dir,
  711. &fan_proc_fops, dev);
  712. if (dev->hotkey_dev)
  713. proc_create_data("keys", S_IRUGO | S_IWUSR, toshiba_proc_dir,
  714. &keys_proc_fops, dev);
  715. proc_create_data("version", S_IRUGO, toshiba_proc_dir,
  716. &version_proc_fops, dev);
  717. }
  718. static void remove_toshiba_proc_entries(struct toshiba_acpi_dev *dev)
  719. {
  720. if (dev->backlight_dev)
  721. remove_proc_entry("lcd", toshiba_proc_dir);
  722. if (dev->video_supported)
  723. remove_proc_entry("video", toshiba_proc_dir);
  724. if (dev->fan_supported)
  725. remove_proc_entry("fan", toshiba_proc_dir);
  726. if (dev->hotkey_dev)
  727. remove_proc_entry("keys", toshiba_proc_dir);
  728. remove_proc_entry("version", toshiba_proc_dir);
  729. }
  730. static const struct backlight_ops toshiba_backlight_data = {
  731. .get_brightness = get_lcd,
  732. .update_status = set_lcd_status,
  733. };
  734. static bool toshiba_acpi_i8042_filter(unsigned char data, unsigned char str,
  735. struct serio *port)
  736. {
  737. if (str & 0x20)
  738. return false;
  739. if (unlikely(data == 0xe0))
  740. return false;
  741. if ((data & 0x7f) == TOS1900_FN_SCAN) {
  742. schedule_work(&toshiba_acpi->hotkey_work);
  743. return true;
  744. }
  745. return false;
  746. }
  747. static void toshiba_acpi_hotkey_work(struct work_struct *work)
  748. {
  749. acpi_handle ec_handle = ec_get_handle();
  750. acpi_status status;
  751. if (!ec_handle)
  752. return;
  753. status = acpi_evaluate_object(ec_handle, "NTFY", NULL, NULL);
  754. if (ACPI_FAILURE(status))
  755. pr_err("ACPI NTFY method execution failed\n");
  756. }
  757. /*
  758. * Returns hotkey scancode, or < 0 on failure.
  759. */
  760. static int toshiba_acpi_query_hotkey(struct toshiba_acpi_dev *dev)
  761. {
  762. struct acpi_buffer buf;
  763. union acpi_object out_obj;
  764. acpi_status status;
  765. buf.pointer = &out_obj;
  766. buf.length = sizeof(out_obj);
  767. status = acpi_evaluate_object(dev->acpi_dev->handle, "INFO",
  768. NULL, &buf);
  769. if (ACPI_FAILURE(status) || out_obj.type != ACPI_TYPE_INTEGER) {
  770. pr_err("ACPI INFO method execution failed\n");
  771. return -EIO;
  772. }
  773. return out_obj.integer.value;
  774. }
  775. static void toshiba_acpi_report_hotkey(struct toshiba_acpi_dev *dev,
  776. int scancode)
  777. {
  778. if (scancode == 0x100)
  779. return;
  780. /* act on key press; ignore key release */
  781. if (scancode & 0x80)
  782. return;
  783. if (!sparse_keymap_report_event(dev->hotkey_dev, scancode, 1, true))
  784. pr_info("Unknown key %x\n", scancode);
  785. }
  786. static int __devinit toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
  787. {
  788. acpi_status status;
  789. acpi_handle ec_handle, handle;
  790. int error;
  791. u32 hci_result;
  792. dev->hotkey_dev = input_allocate_device();
  793. if (!dev->hotkey_dev) {
  794. pr_info("Unable to register input device\n");
  795. return -ENOMEM;
  796. }
  797. dev->hotkey_dev->name = "Toshiba input device";
  798. dev->hotkey_dev->phys = "toshiba_acpi/input0";
  799. dev->hotkey_dev->id.bustype = BUS_HOST;
  800. error = sparse_keymap_setup(dev->hotkey_dev, toshiba_acpi_keymap, NULL);
  801. if (error)
  802. goto err_free_dev;
  803. /*
  804. * For some machines the SCI responsible for providing hotkey
  805. * notification doesn't fire. We can trigger the notification
  806. * whenever the Fn key is pressed using the NTFY method, if
  807. * supported, so if it's present set up an i8042 key filter
  808. * for this purpose.
  809. */
  810. status = AE_ERROR;
  811. ec_handle = ec_get_handle();
  812. if (ec_handle)
  813. status = acpi_get_handle(ec_handle, "NTFY", &handle);
  814. if (ACPI_SUCCESS(status)) {
  815. INIT_WORK(&dev->hotkey_work, toshiba_acpi_hotkey_work);
  816. error = i8042_install_filter(toshiba_acpi_i8042_filter);
  817. if (error) {
  818. pr_err("Error installing key filter\n");
  819. goto err_free_keymap;
  820. }
  821. dev->ntfy_supported = 1;
  822. }
  823. /*
  824. * Determine hotkey query interface. Prefer using the INFO
  825. * method when it is available.
  826. */
  827. status = acpi_get_handle(dev->acpi_dev->handle, "INFO", &handle);
  828. if (ACPI_SUCCESS(status)) {
  829. dev->info_supported = 1;
  830. } else {
  831. hci_write1(dev, HCI_SYSTEM_EVENT, 1, &hci_result);
  832. if (hci_result == HCI_SUCCESS)
  833. dev->system_event_supported = 1;
  834. }
  835. if (!dev->info_supported && !dev->system_event_supported) {
  836. pr_warn("No hotkey query interface found\n");
  837. goto err_remove_filter;
  838. }
  839. status = acpi_evaluate_object(dev->acpi_dev->handle, "ENAB", NULL, NULL);
  840. if (ACPI_FAILURE(status)) {
  841. pr_info("Unable to enable hotkeys\n");
  842. error = -ENODEV;
  843. goto err_remove_filter;
  844. }
  845. error = input_register_device(dev->hotkey_dev);
  846. if (error) {
  847. pr_info("Unable to register input device\n");
  848. goto err_remove_filter;
  849. }
  850. hci_write1(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_ENABLE, &hci_result);
  851. return 0;
  852. err_remove_filter:
  853. if (dev->ntfy_supported)
  854. i8042_remove_filter(toshiba_acpi_i8042_filter);
  855. err_free_keymap:
  856. sparse_keymap_free(dev->hotkey_dev);
  857. err_free_dev:
  858. input_free_device(dev->hotkey_dev);
  859. dev->hotkey_dev = NULL;
  860. return error;
  861. }
  862. static int toshiba_acpi_remove(struct acpi_device *acpi_dev, int type)
  863. {
  864. struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
  865. remove_toshiba_proc_entries(dev);
  866. if (dev->ntfy_supported) {
  867. i8042_remove_filter(toshiba_acpi_i8042_filter);
  868. cancel_work_sync(&dev->hotkey_work);
  869. }
  870. if (dev->hotkey_dev) {
  871. input_unregister_device(dev->hotkey_dev);
  872. sparse_keymap_free(dev->hotkey_dev);
  873. }
  874. if (dev->bt_rfk) {
  875. rfkill_unregister(dev->bt_rfk);
  876. rfkill_destroy(dev->bt_rfk);
  877. }
  878. if (dev->backlight_dev)
  879. backlight_device_unregister(dev->backlight_dev);
  880. if (dev->illumination_supported)
  881. led_classdev_unregister(&dev->led_dev);
  882. if (toshiba_acpi)
  883. toshiba_acpi = NULL;
  884. kfree(dev);
  885. return 0;
  886. }
  887. static const char * __devinit find_hci_method(acpi_handle handle)
  888. {
  889. acpi_status status;
  890. acpi_handle hci_handle;
  891. status = acpi_get_handle(handle, "GHCI", &hci_handle);
  892. if (ACPI_SUCCESS(status))
  893. return "GHCI";
  894. status = acpi_get_handle(handle, "SPFC", &hci_handle);
  895. if (ACPI_SUCCESS(status))
  896. return "SPFC";
  897. return NULL;
  898. }
  899. static int __devinit toshiba_acpi_add(struct acpi_device *acpi_dev)
  900. {
  901. struct toshiba_acpi_dev *dev;
  902. const char *hci_method;
  903. u32 dummy;
  904. bool bt_present;
  905. int ret = 0;
  906. struct backlight_properties props;
  907. if (toshiba_acpi)
  908. return -EBUSY;
  909. pr_info("Toshiba Laptop ACPI Extras version %s\n",
  910. TOSHIBA_ACPI_VERSION);
  911. hci_method = find_hci_method(acpi_dev->handle);
  912. if (!hci_method) {
  913. pr_err("HCI interface not found\n");
  914. return -ENODEV;
  915. }
  916. dev = kzalloc(sizeof(*dev), GFP_KERNEL);
  917. if (!dev)
  918. return -ENOMEM;
  919. dev->acpi_dev = acpi_dev;
  920. dev->method_hci = hci_method;
  921. acpi_dev->driver_data = dev;
  922. if (toshiba_acpi_setup_keyboard(dev))
  923. pr_info("Unable to activate hotkeys\n");
  924. mutex_init(&dev->mutex);
  925. props.type = BACKLIGHT_PLATFORM;
  926. props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1;
  927. dev->backlight_dev = backlight_device_register("toshiba",
  928. &acpi_dev->dev,
  929. dev,
  930. &toshiba_backlight_data,
  931. &props);
  932. if (IS_ERR(dev->backlight_dev)) {
  933. ret = PTR_ERR(dev->backlight_dev);
  934. pr_err("Could not register toshiba backlight device\n");
  935. dev->backlight_dev = NULL;
  936. goto error;
  937. }
  938. dev->backlight_dev->props.brightness = get_lcd(dev->backlight_dev);
  939. /* Register rfkill switch for Bluetooth */
  940. if (hci_get_bt_present(dev, &bt_present) == HCI_SUCCESS && bt_present) {
  941. dev->bt_rfk = rfkill_alloc("Toshiba Bluetooth",
  942. &acpi_dev->dev,
  943. RFKILL_TYPE_BLUETOOTH,
  944. &toshiba_rfk_ops,
  945. dev);
  946. if (!dev->bt_rfk) {
  947. pr_err("unable to allocate rfkill device\n");
  948. ret = -ENOMEM;
  949. goto error;
  950. }
  951. ret = rfkill_register(dev->bt_rfk);
  952. if (ret) {
  953. pr_err("unable to register rfkill device\n");
  954. rfkill_destroy(dev->bt_rfk);
  955. goto error;
  956. }
  957. }
  958. if (toshiba_illumination_available(dev)) {
  959. dev->led_dev.name = "toshiba::illumination";
  960. dev->led_dev.max_brightness = 1;
  961. dev->led_dev.brightness_set = toshiba_illumination_set;
  962. dev->led_dev.brightness_get = toshiba_illumination_get;
  963. if (!led_classdev_register(&acpi_dev->dev, &dev->led_dev))
  964. dev->illumination_supported = 1;
  965. }
  966. /* Determine whether or not BIOS supports fan and video interfaces */
  967. ret = get_video_status(dev, &dummy);
  968. dev->video_supported = !ret;
  969. ret = get_fan_status(dev, &dummy);
  970. dev->fan_supported = !ret;
  971. create_toshiba_proc_entries(dev);
  972. toshiba_acpi = dev;
  973. return 0;
  974. error:
  975. toshiba_acpi_remove(acpi_dev, 0);
  976. return ret;
  977. }
  978. static void toshiba_acpi_notify(struct acpi_device *acpi_dev, u32 event)
  979. {
  980. struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
  981. u32 hci_result, value;
  982. int retries = 3;
  983. int scancode;
  984. if (event != 0x80)
  985. return;
  986. if (dev->info_supported) {
  987. scancode = toshiba_acpi_query_hotkey(dev);
  988. if (scancode < 0)
  989. pr_err("Failed to query hotkey event\n");
  990. else if (scancode != 0)
  991. toshiba_acpi_report_hotkey(dev, scancode);
  992. } else if (dev->system_event_supported) {
  993. do {
  994. hci_read1(dev, HCI_SYSTEM_EVENT, &value, &hci_result);
  995. switch (hci_result) {
  996. case HCI_SUCCESS:
  997. toshiba_acpi_report_hotkey(dev, (int)value);
  998. break;
  999. case HCI_NOT_SUPPORTED:
  1000. /*
  1001. * This is a workaround for an unresolved
  1002. * issue on some machines where system events
  1003. * sporadically become disabled.
  1004. */
  1005. hci_write1(dev, HCI_SYSTEM_EVENT, 1,
  1006. &hci_result);
  1007. pr_notice("Re-enabled hotkeys\n");
  1008. /* fall through */
  1009. default:
  1010. retries--;
  1011. break;
  1012. }
  1013. } while (retries && hci_result != HCI_EMPTY);
  1014. }
  1015. }
  1016. static int toshiba_acpi_suspend(struct acpi_device *acpi_dev,
  1017. pm_message_t state)
  1018. {
  1019. struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
  1020. u32 result;
  1021. if (dev->hotkey_dev)
  1022. hci_write1(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_DISABLE, &result);
  1023. return 0;
  1024. }
  1025. static int toshiba_acpi_resume(struct acpi_device *acpi_dev)
  1026. {
  1027. struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
  1028. u32 result;
  1029. if (dev->hotkey_dev)
  1030. hci_write1(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_ENABLE, &result);
  1031. return 0;
  1032. }
  1033. static struct acpi_driver toshiba_acpi_driver = {
  1034. .name = "Toshiba ACPI driver",
  1035. .owner = THIS_MODULE,
  1036. .ids = toshiba_device_ids,
  1037. .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
  1038. .ops = {
  1039. .add = toshiba_acpi_add,
  1040. .remove = toshiba_acpi_remove,
  1041. .notify = toshiba_acpi_notify,
  1042. .suspend = toshiba_acpi_suspend,
  1043. .resume = toshiba_acpi_resume,
  1044. },
  1045. };
  1046. static int __init toshiba_acpi_init(void)
  1047. {
  1048. int ret;
  1049. toshiba_proc_dir = proc_mkdir(PROC_TOSHIBA, acpi_root_dir);
  1050. if (!toshiba_proc_dir) {
  1051. pr_err("Unable to create proc dir " PROC_TOSHIBA "\n");
  1052. return -ENODEV;
  1053. }
  1054. ret = acpi_bus_register_driver(&toshiba_acpi_driver);
  1055. if (ret) {
  1056. pr_err("Failed to register ACPI driver: %d\n", ret);
  1057. remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
  1058. }
  1059. return ret;
  1060. }
  1061. static void __exit toshiba_acpi_exit(void)
  1062. {
  1063. acpi_bus_unregister_driver(&toshiba_acpi_driver);
  1064. if (toshiba_proc_dir)
  1065. remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
  1066. }
  1067. module_init(toshiba_acpi_init);
  1068. module_exit(toshiba_acpi_exit);