thinkpad_acpi.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. /*
  2. * thinkpad_acpi.h - ThinkPad ACPI Extras
  3. *
  4. *
  5. * Copyright (C) 2004-2005 Borislav Deianov <borislav@users.sf.net>
  6. * Copyright (C) 2006-2007 Henrique de Moraes Holschuh <hmh@hmh.eng.br>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  21. * 02110-1301, USA.
  22. */
  23. #ifndef __THINKPAD_ACPI_H__
  24. #define __THINKPAD_ACPI_H__
  25. #include <linux/kernel.h>
  26. #include <linux/module.h>
  27. #include <linux/init.h>
  28. #include <linux/types.h>
  29. #include <linux/string.h>
  30. #include <linux/list.h>
  31. #include <linux/mutex.h>
  32. #include <linux/kthread.h>
  33. #include <linux/freezer.h>
  34. #include <linux/delay.h>
  35. #include <linux/nvram.h>
  36. #include <linux/proc_fs.h>
  37. #include <linux/sysfs.h>
  38. #include <linux/backlight.h>
  39. #include <linux/fb.h>
  40. #include <linux/platform_device.h>
  41. #include <linux/hwmon.h>
  42. #include <linux/hwmon-sysfs.h>
  43. #include <linux/input.h>
  44. #include <asm/uaccess.h>
  45. #include <linux/dmi.h>
  46. #include <linux/jiffies.h>
  47. #include <linux/workqueue.h>
  48. #include <acpi/acpi_drivers.h>
  49. #include <acpi/acnamesp.h>
  50. #include <linux/pci_ids.h>
  51. /****************************************************************************
  52. * Main driver
  53. */
  54. #define IBM_NAME "thinkpad"
  55. #define IBM_DESC "ThinkPad ACPI Extras"
  56. #define IBM_FILE IBM_NAME "_acpi"
  57. #define IBM_URL "http://ibm-acpi.sf.net/"
  58. #define IBM_MAIL "ibm-acpi-devel@lists.sourceforge.net"
  59. #define IBM_PROC_DIR "ibm"
  60. #define IBM_ACPI_EVENT_PREFIX "ibm"
  61. #define IBM_DRVR_NAME IBM_FILE
  62. #define IBM_HWMON_DRVR_NAME IBM_NAME "_hwmon"
  63. #define IBM_LOG IBM_FILE ": "
  64. #define IBM_ERR KERN_ERR IBM_LOG
  65. #define IBM_NOTICE KERN_NOTICE IBM_LOG
  66. #define IBM_INFO KERN_INFO IBM_LOG
  67. #define IBM_DEBUG KERN_DEBUG IBM_LOG
  68. #define IBM_MAX_ACPI_ARGS 3
  69. /* ThinkPad CMOS commands */
  70. #define TP_CMOS_VOLUME_DOWN 0
  71. #define TP_CMOS_VOLUME_UP 1
  72. #define TP_CMOS_VOLUME_MUTE 2
  73. #define TP_CMOS_BRIGHTNESS_UP 4
  74. #define TP_CMOS_BRIGHTNESS_DOWN 5
  75. /* NVRAM Addresses */
  76. enum tp_nvram_addr {
  77. TP_NVRAM_ADDR_HK2 = 0x57,
  78. TP_NVRAM_ADDR_THINKLIGHT = 0x58,
  79. TP_NVRAM_ADDR_VIDEO = 0x59,
  80. TP_NVRAM_ADDR_BRIGHTNESS = 0x5e,
  81. TP_NVRAM_ADDR_MIXER = 0x60,
  82. };
  83. /* NVRAM bit masks */
  84. enum {
  85. TP_NVRAM_MASK_HKT_THINKPAD = 0x08,
  86. TP_NVRAM_MASK_HKT_ZOOM = 0x20,
  87. TP_NVRAM_MASK_HKT_DISPLAY = 0x40,
  88. TP_NVRAM_MASK_HKT_HIBERNATE = 0x80,
  89. TP_NVRAM_MASK_THINKLIGHT = 0x10,
  90. TP_NVRAM_MASK_HKT_DISPEXPND = 0x30,
  91. TP_NVRAM_MASK_HKT_BRIGHTNESS = 0x20,
  92. TP_NVRAM_MASK_LEVEL_BRIGHTNESS = 0x0f,
  93. TP_NVRAM_POS_LEVEL_BRIGHTNESS = 0,
  94. TP_NVRAM_MASK_MUTE = 0x40,
  95. TP_NVRAM_MASK_HKT_VOLUME = 0x80,
  96. TP_NVRAM_MASK_LEVEL_VOLUME = 0x0f,
  97. TP_NVRAM_POS_LEVEL_VOLUME = 0,
  98. };
  99. #define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off")
  100. #define enabled(status,bit) ((status) & (1 << (bit)) ? "enabled" : "disabled")
  101. #define strlencmp(a,b) (strncmp((a), (b), strlen(b)))
  102. /* Debugging */
  103. #define TPACPI_DBG_ALL 0xffff
  104. #define TPACPI_DBG_ALL 0xffff
  105. #define TPACPI_DBG_INIT 0x0001
  106. #define TPACPI_DBG_EXIT 0x0002
  107. #define dbg_printk(a_dbg_level, format, arg...) \
  108. do { if (dbg_level & a_dbg_level) \
  109. printk(IBM_DEBUG "%s: " format, __func__ , ## arg); } while (0)
  110. #ifdef CONFIG_THINKPAD_ACPI_DEBUG
  111. #define vdbg_printk(a_dbg_level, format, arg...) \
  112. dbg_printk(a_dbg_level, format, ## arg)
  113. static const char *str_supported(int is_supported);
  114. #else
  115. #define vdbg_printk(a_dbg_level, format, arg...)
  116. #endif
  117. /* Input IDs */
  118. #define TPACPI_HKEY_INPUT_VENDOR PCI_VENDOR_ID_IBM
  119. #define TPACPI_HKEY_INPUT_PRODUCT 0x5054 /* "TP" */
  120. #define TPACPI_HKEY_INPUT_VERSION 0x4101
  121. /* ACPI HIDs */
  122. #define IBM_HKEY_HID "IBM0068"
  123. /* ACPI helpers */
  124. static int __must_check acpi_evalf(acpi_handle handle,
  125. void *res, char *method, char *fmt, ...);
  126. static int __must_check acpi_ec_read(int i, u8 * p);
  127. static int __must_check acpi_ec_write(int i, u8 v);
  128. static int __must_check _sta(acpi_handle handle);
  129. /* ACPI handles */
  130. static acpi_handle root_handle; /* root namespace */
  131. static acpi_handle ec_handle; /* EC */
  132. static acpi_handle ecrd_handle, ecwr_handle; /* 570 EC access */
  133. static acpi_handle cmos_handle, hkey_handle; /* basic thinkpad handles */
  134. static void drv_acpi_handle_init(char *name,
  135. acpi_handle *handle, acpi_handle parent,
  136. char **paths, int num_paths, char **path);
  137. #define IBM_ACPIHANDLE_INIT(object) \
  138. drv_acpi_handle_init(#object, &object##_handle, *object##_parent, \
  139. object##_paths, ARRAY_SIZE(object##_paths), &object##_path)
  140. /* ThinkPad ACPI helpers */
  141. static int issue_thinkpad_cmos_command(int cmos_cmd);
  142. /* procfs support */
  143. static struct proc_dir_entry *proc_dir;
  144. /* procfs helpers */
  145. static int dispatch_procfs_read(char *page, char **start, off_t off,
  146. int count, int *eof, void *data);
  147. static int dispatch_procfs_write(struct file *file,
  148. const char __user * userbuf,
  149. unsigned long count, void *data);
  150. static char *next_cmd(char **cmds);
  151. /* sysfs support */
  152. struct attribute_set {
  153. unsigned int members, max_members;
  154. struct attribute_group group;
  155. };
  156. static struct attribute_set *create_attr_set(unsigned int max_members,
  157. const char* name);
  158. #define destroy_attr_set(_set) \
  159. kfree(_set);
  160. static int add_to_attr_set(struct attribute_set* s, struct attribute *attr);
  161. static int add_many_to_attr_set(struct attribute_set* s,
  162. struct attribute **attr,
  163. unsigned int count);
  164. #define register_attr_set_with_sysfs(_attr_set, _kobj) \
  165. sysfs_create_group(_kobj, &_attr_set->group)
  166. static void delete_attr_set(struct attribute_set* s, struct kobject *kobj);
  167. static int parse_strtoul(const char *buf, unsigned long max,
  168. unsigned long *value);
  169. /* Device model */
  170. static struct platform_device *tpacpi_pdev;
  171. static struct platform_device *tpacpi_sensors_pdev;
  172. static struct device *tpacpi_hwmon;
  173. static struct platform_driver tpacpi_pdriver;
  174. static struct input_dev *tpacpi_inputdev;
  175. static int tpacpi_create_driver_attributes(struct device_driver *drv);
  176. static void tpacpi_remove_driver_attributes(struct device_driver *drv);
  177. /* Module */
  178. static int experimental;
  179. static u32 dbg_level;
  180. static int force_load;
  181. static unsigned int hotkey_report_mode;
  182. static int thinkpad_acpi_module_init(void);
  183. static void thinkpad_acpi_module_exit(void);
  184. /****************************************************************************
  185. * Subdrivers
  186. */
  187. struct ibm_struct;
  188. struct tp_acpi_drv_struct {
  189. const struct acpi_device_id *hid;
  190. struct acpi_driver *driver;
  191. void (*notify) (struct ibm_struct *, u32);
  192. acpi_handle *handle;
  193. u32 type;
  194. struct acpi_device *device;
  195. };
  196. struct ibm_struct {
  197. char *name;
  198. int (*read) (char *);
  199. int (*write) (char *);
  200. void (*exit) (void);
  201. void (*resume) (void);
  202. struct list_head all_drivers;
  203. struct tp_acpi_drv_struct *acpi;
  204. struct {
  205. u8 acpi_driver_registered:1;
  206. u8 acpi_notify_installed:1;
  207. u8 proc_created:1;
  208. u8 init_called:1;
  209. u8 experimental:1;
  210. } flags;
  211. };
  212. struct ibm_init_struct {
  213. char param[32];
  214. int (*init) (struct ibm_init_struct *);
  215. struct ibm_struct *data;
  216. };
  217. static struct {
  218. #ifdef CONFIG_THINKPAD_ACPI_BAY
  219. u32 bay_status:1;
  220. u32 bay_eject:1;
  221. u32 bay_status2:1;
  222. u32 bay_eject2:1;
  223. #endif
  224. u32 bluetooth:1;
  225. u32 hotkey:1;
  226. u32 hotkey_mask:1;
  227. u32 hotkey_wlsw:1;
  228. u32 light:1;
  229. u32 light_status:1;
  230. u32 bright_16levels:1;
  231. u32 wan:1;
  232. u32 fan_ctrl_status_undef:1;
  233. u32 input_device_registered:1;
  234. u32 platform_drv_registered:1;
  235. u32 platform_drv_attrs_registered:1;
  236. u32 sensors_pdrv_registered:1;
  237. u32 sensors_pdrv_attrs_registered:1;
  238. u32 sensors_pdev_attrs_registered:1;
  239. u32 hotkey_poll_active:1;
  240. } tp_features;
  241. struct thinkpad_id_data {
  242. unsigned int vendor; /* ThinkPad vendor:
  243. * PCI_VENDOR_ID_IBM/PCI_VENDOR_ID_LENOVO */
  244. char *bios_version_str; /* Something like 1ZET51WW (1.03z) */
  245. char *ec_version_str; /* Something like 1ZHT51WW-1.04a */
  246. u16 bios_model; /* Big Endian, TP-1Y = 0x5931, 0 = unknown */
  247. u16 ec_model;
  248. char *model_str;
  249. };
  250. static struct thinkpad_id_data thinkpad_id;
  251. static struct list_head tpacpi_all_drivers;
  252. static struct ibm_init_struct ibms_init[];
  253. static int set_ibm_param(const char *val, struct kernel_param *kp);
  254. static int ibm_init(struct ibm_init_struct *iibm);
  255. static void ibm_exit(struct ibm_struct *ibm);
  256. /*
  257. * procfs master subdriver
  258. */
  259. static int thinkpad_acpi_driver_init(struct ibm_init_struct *iibm);
  260. static int thinkpad_acpi_driver_read(char *p);
  261. /*
  262. * Bay subdriver
  263. */
  264. #ifdef CONFIG_THINKPAD_ACPI_BAY
  265. static acpi_handle bay_handle, bay_ej_handle;
  266. static acpi_handle bay2_handle, bay2_ej_handle;
  267. static int bay_init(struct ibm_init_struct *iibm);
  268. static void bay_notify(struct ibm_struct *ibm, u32 event);
  269. static int bay_read(char *p);
  270. static int bay_write(char *buf);
  271. #endif /* CONFIG_THINKPAD_ACPI_BAY */
  272. /*
  273. * Beep subdriver
  274. */
  275. static acpi_handle beep_handle;
  276. static int beep_read(char *p);
  277. static int beep_write(char *buf);
  278. /*
  279. * Bluetooth subdriver
  280. */
  281. enum {
  282. /* ACPI GBDC/SBDC bits */
  283. TP_ACPI_BLUETOOTH_HWPRESENT = 0x01, /* Bluetooth hw available */
  284. TP_ACPI_BLUETOOTH_RADIOSSW = 0x02, /* Bluetooth radio enabled */
  285. TP_ACPI_BLUETOOTH_UNK = 0x04, /* unknown function */
  286. };
  287. static int bluetooth_init(struct ibm_init_struct *iibm);
  288. static int bluetooth_get_radiosw(void);
  289. static int bluetooth_set_radiosw(int radio_on);
  290. static int bluetooth_read(char *p);
  291. static int bluetooth_write(char *buf);
  292. /*
  293. * Brightness (backlight) subdriver
  294. */
  295. #define TPACPI_BACKLIGHT_DEV_NAME "thinkpad_screen"
  296. static struct backlight_device *ibm_backlight_device;
  297. static int brightness_offset = 0x31;
  298. static int brightness_mode;
  299. static unsigned int brightness_enable; /* 0 = no, 1 = yes, 2 = auto */
  300. static int brightness_init(struct ibm_init_struct *iibm);
  301. static void brightness_exit(void);
  302. static int brightness_get(struct backlight_device *bd);
  303. static int brightness_set(int value);
  304. static int brightness_update_status(struct backlight_device *bd);
  305. static int brightness_read(char *p);
  306. static int brightness_write(char *buf);
  307. /*
  308. * CMOS subdriver
  309. */
  310. static int cmos_read(char *p);
  311. static int cmos_write(char *buf);
  312. /*
  313. * Dock subdriver
  314. */
  315. #ifdef CONFIG_THINKPAD_ACPI_DOCK
  316. static acpi_handle pci_handle;
  317. static acpi_handle dock_handle;
  318. static void dock_notify(struct ibm_struct *ibm, u32 event);
  319. static int dock_read(char *p);
  320. static int dock_write(char *buf);
  321. #endif /* CONFIG_THINKPAD_ACPI_DOCK */
  322. /*
  323. * EC dump subdriver
  324. */
  325. static int ecdump_read(char *p) ;
  326. static int ecdump_write(char *buf);
  327. /*
  328. * Fan subdriver
  329. */
  330. enum { /* Fan control constants */
  331. fan_status_offset = 0x2f, /* EC register 0x2f */
  332. fan_rpm_offset = 0x84, /* EC register 0x84: LSB, 0x85 MSB (RPM)
  333. * 0x84 must be read before 0x85 */
  334. TP_EC_FAN_FULLSPEED = 0x40, /* EC fan mode: full speed */
  335. TP_EC_FAN_AUTO = 0x80, /* EC fan mode: auto fan control */
  336. TPACPI_FAN_LAST_LEVEL = 0x100, /* Use cached last-seen fan level */
  337. };
  338. enum fan_status_access_mode {
  339. TPACPI_FAN_NONE = 0, /* No fan status or control */
  340. TPACPI_FAN_RD_ACPI_GFAN, /* Use ACPI GFAN */
  341. TPACPI_FAN_RD_TPEC, /* Use ACPI EC regs 0x2f, 0x84-0x85 */
  342. };
  343. enum fan_control_access_mode {
  344. TPACPI_FAN_WR_NONE = 0, /* No fan control */
  345. TPACPI_FAN_WR_ACPI_SFAN, /* Use ACPI SFAN */
  346. TPACPI_FAN_WR_TPEC, /* Use ACPI EC reg 0x2f */
  347. TPACPI_FAN_WR_ACPI_FANS, /* Use ACPI FANS and EC reg 0x2f */
  348. };
  349. enum fan_control_commands {
  350. TPACPI_FAN_CMD_SPEED = 0x0001, /* speed command */
  351. TPACPI_FAN_CMD_LEVEL = 0x0002, /* level command */
  352. TPACPI_FAN_CMD_ENABLE = 0x0004, /* enable/disable cmd,
  353. * and also watchdog cmd */
  354. };
  355. static int fan_control_allowed;
  356. static enum fan_status_access_mode fan_status_access_mode;
  357. static enum fan_control_access_mode fan_control_access_mode;
  358. static enum fan_control_commands fan_control_commands;
  359. static u8 fan_control_initial_status;
  360. static u8 fan_control_desired_level;
  361. static int fan_watchdog_maxinterval;
  362. static struct mutex fan_mutex;
  363. static acpi_handle fans_handle, gfan_handle, sfan_handle;
  364. static int fan_init(struct ibm_init_struct *iibm);
  365. static void fan_exit(void);
  366. static int fan_get_status(u8 *status);
  367. static int fan_get_status_safe(u8 *status);
  368. static int fan_get_speed(unsigned int *speed);
  369. static void fan_update_desired_level(u8 status);
  370. static void fan_watchdog_fire(struct work_struct *ignored);
  371. static void fan_watchdog_reset(void);
  372. static int fan_set_level(int level);
  373. static int fan_set_level_safe(int level);
  374. static int fan_set_enable(void);
  375. static int fan_set_disable(void);
  376. static int fan_set_speed(int speed);
  377. static int fan_read(char *p);
  378. static int fan_write(char *buf);
  379. static int fan_write_cmd_level(const char *cmd, int *rc);
  380. static int fan_write_cmd_enable(const char *cmd, int *rc);
  381. static int fan_write_cmd_disable(const char *cmd, int *rc);
  382. static int fan_write_cmd_speed(const char *cmd, int *rc);
  383. static int fan_write_cmd_watchdog(const char *cmd, int *rc);
  384. /*
  385. * Hotkey subdriver
  386. */
  387. enum { /* hot key scan codes (derived from ACPI DSDT) */
  388. TP_ACPI_HOTKEYSCAN_FNF1 = 0,
  389. TP_ACPI_HOTKEYSCAN_FNF2,
  390. TP_ACPI_HOTKEYSCAN_FNF3,
  391. TP_ACPI_HOTKEYSCAN_FNF4,
  392. TP_ACPI_HOTKEYSCAN_FNF5,
  393. TP_ACPI_HOTKEYSCAN_FNF6,
  394. TP_ACPI_HOTKEYSCAN_FNF7,
  395. TP_ACPI_HOTKEYSCAN_FNF8,
  396. TP_ACPI_HOTKEYSCAN_FNF9,
  397. TP_ACPI_HOTKEYSCAN_FNF10,
  398. TP_ACPI_HOTKEYSCAN_FNF11,
  399. TP_ACPI_HOTKEYSCAN_FNF12,
  400. TP_ACPI_HOTKEYSCAN_FNBACKSPACE,
  401. TP_ACPI_HOTKEYSCAN_FNINSERT,
  402. TP_ACPI_HOTKEYSCAN_FNDELETE,
  403. TP_ACPI_HOTKEYSCAN_FNHOME,
  404. TP_ACPI_HOTKEYSCAN_FNEND,
  405. TP_ACPI_HOTKEYSCAN_FNPAGEUP,
  406. TP_ACPI_HOTKEYSCAN_FNPAGEDOWN,
  407. TP_ACPI_HOTKEYSCAN_FNSPACE,
  408. TP_ACPI_HOTKEYSCAN_VOLUMEUP,
  409. TP_ACPI_HOTKEYSCAN_VOLUMEDOWN,
  410. TP_ACPI_HOTKEYSCAN_MUTE,
  411. TP_ACPI_HOTKEYSCAN_THINKPAD,
  412. };
  413. static int hotkey_orig_status;
  414. static u32 hotkey_orig_mask;
  415. static struct mutex hotkey_mutex;
  416. static int hotkey_init(struct ibm_init_struct *iibm);
  417. static void hotkey_exit(void);
  418. static void hotkey_notify(struct ibm_struct *ibm, u32 event);
  419. static int hotkey_read(char *p);
  420. static int hotkey_write(char *buf);
  421. /*
  422. * LED subdriver
  423. */
  424. enum led_access_mode {
  425. TPACPI_LED_NONE = 0,
  426. TPACPI_LED_570, /* 570 */
  427. TPACPI_LED_OLD, /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
  428. TPACPI_LED_NEW, /* all others */
  429. };
  430. enum { /* For TPACPI_LED_OLD */
  431. TPACPI_LED_EC_HLCL = 0x0c, /* EC reg to get led to power on */
  432. TPACPI_LED_EC_HLBL = 0x0d, /* EC reg to blink a lit led */
  433. TPACPI_LED_EC_HLMS = 0x0e, /* EC reg to select led to command */
  434. };
  435. static enum led_access_mode led_supported;
  436. static acpi_handle led_handle;
  437. static int led_init(struct ibm_init_struct *iibm);
  438. static int led_read(char *p);
  439. static int led_write(char *buf);
  440. /*
  441. * Light (thinklight) subdriver
  442. */
  443. static acpi_handle lght_handle, ledb_handle;
  444. static int light_init(struct ibm_init_struct *iibm);
  445. static int light_read(char *p);
  446. static int light_write(char *buf);
  447. /*
  448. * Thermal subdriver
  449. */
  450. enum thermal_access_mode {
  451. TPACPI_THERMAL_NONE = 0, /* No thermal support */
  452. TPACPI_THERMAL_ACPI_TMP07, /* Use ACPI TMP0-7 */
  453. TPACPI_THERMAL_ACPI_UPDT, /* Use ACPI TMP0-7 with UPDT */
  454. TPACPI_THERMAL_TPEC_8, /* Use ACPI EC regs, 8 sensors */
  455. TPACPI_THERMAL_TPEC_16, /* Use ACPI EC regs, 16 sensors */
  456. };
  457. enum { /* TPACPI_THERMAL_TPEC_* */
  458. TP_EC_THERMAL_TMP0 = 0x78, /* ACPI EC regs TMP 0..7 */
  459. TP_EC_THERMAL_TMP8 = 0xC0, /* ACPI EC regs TMP 8..15 */
  460. TP_EC_THERMAL_TMP_NA = -128, /* ACPI EC sensor not available */
  461. };
  462. #define TPACPI_MAX_THERMAL_SENSORS 16 /* Max thermal sensors supported */
  463. struct ibm_thermal_sensors_struct {
  464. s32 temp[TPACPI_MAX_THERMAL_SENSORS];
  465. };
  466. static enum thermal_access_mode thermal_read_mode;
  467. static int thermal_init(struct ibm_init_struct *iibm);
  468. static int thermal_get_sensor(int idx, s32 *value);
  469. static int thermal_get_sensors(struct ibm_thermal_sensors_struct *s);
  470. static int thermal_read(char *p);
  471. /*
  472. * Video subdriver
  473. */
  474. enum video_access_mode {
  475. TPACPI_VIDEO_NONE = 0,
  476. TPACPI_VIDEO_570, /* 570 */
  477. TPACPI_VIDEO_770, /* 600e/x, 770e, 770x */
  478. TPACPI_VIDEO_NEW, /* all others */
  479. };
  480. enum { /* video status flags, based on VIDEO_570 */
  481. TP_ACPI_VIDEO_S_LCD = 0x01, /* LCD output enabled */
  482. TP_ACPI_VIDEO_S_CRT = 0x02, /* CRT output enabled */
  483. TP_ACPI_VIDEO_S_DVI = 0x08, /* DVI output enabled */
  484. };
  485. enum { /* TPACPI_VIDEO_570 constants */
  486. TP_ACPI_VIDEO_570_PHSCMD = 0x87, /* unknown magic constant :( */
  487. TP_ACPI_VIDEO_570_PHSMASK = 0x03, /* PHS bits that map to
  488. * video_status_flags */
  489. TP_ACPI_VIDEO_570_PHS2CMD = 0x8b, /* unknown magic constant :( */
  490. TP_ACPI_VIDEO_570_PHS2SET = 0x80, /* unknown magic constant :( */
  491. };
  492. static enum video_access_mode video_supported;
  493. static int video_orig_autosw;
  494. static acpi_handle vid_handle, vid2_handle;
  495. static int video_init(struct ibm_init_struct *iibm);
  496. static void video_exit(void);
  497. static int video_outputsw_get(void);
  498. static int video_outputsw_set(int status);
  499. static int video_autosw_get(void);
  500. static int video_autosw_set(int enable);
  501. static int video_outputsw_cycle(void);
  502. static int video_expand_toggle(void);
  503. static int video_read(char *p);
  504. static int video_write(char *buf);
  505. /*
  506. * Volume subdriver
  507. */
  508. static int volume_offset = 0x30;
  509. static int volume_read(char *p);
  510. static int volume_write(char *buf);
  511. /*
  512. * Wan subdriver
  513. */
  514. enum {
  515. /* ACPI GWAN/SWAN bits */
  516. TP_ACPI_WANCARD_HWPRESENT = 0x01, /* Wan hw available */
  517. TP_ACPI_WANCARD_RADIOSSW = 0x02, /* Wan radio enabled */
  518. TP_ACPI_WANCARD_UNK = 0x04, /* unknown function */
  519. };
  520. static int wan_init(struct ibm_init_struct *iibm);
  521. static int wan_get_radiosw(void);
  522. static int wan_set_radiosw(int radio_on);
  523. static int wan_read(char *p);
  524. static int wan_write(char *buf);
  525. #endif /* __THINKPAD_ACPI_H */