#define pr_fmt(fmt) …
#define TOSHIBA_ACPI_VERSION …
#define PROC_INTERFACE_VERSION …
#include <linux/compiler.h>
#include <linux/dmi.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/backlight.h>
#include <linux/input.h>
#include <linux/input/sparse-keymap.h>
#include <linux/leds.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/i8042.h>
#include <linux/acpi.h>
#include <linux/uaccess.h>
#include <linux/miscdevice.h>
#include <linux/rfkill.h>
#include <linux/hwmon.h>
#include <linux/iio/iio.h>
#include <linux/toshiba.h>
#include <acpi/battery.h>
#include <acpi/video.h>
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
static int turn_on_panel_on_resume = …;
module_param(turn_on_panel_on_resume, int, 0644);
MODULE_PARM_DESC(…) …;
static int hci_hotkey_quickstart = …;
module_param(hci_hotkey_quickstart, int, 0644);
MODULE_PARM_DESC(…) …;
#define TOSHIBA_WMI_EVENT_GUID …
#define TOS1900_FN_SCAN …
#define METHOD_VIDEO_OUT …
#define TCI_WORDS …
#define HCI_SET …
#define HCI_GET …
#define SCI_OPEN …
#define SCI_CLOSE …
#define SCI_GET …
#define SCI_SET …
#define TOS_SUCCESS …
#define TOS_SUCCESS2 …
#define TOS_OPEN_CLOSE_OK …
#define TOS_FAILURE …
#define TOS_NOT_SUPPORTED …
#define TOS_ALREADY_OPEN …
#define TOS_NOT_OPENED …
#define TOS_INPUT_DATA_ERROR …
#define TOS_WRITE_PROTECTED …
#define TOS_NOT_PRESENT …
#define TOS_FIFO_EMPTY …
#define TOS_DATA_NOT_AVAILABLE …
#define TOS_NOT_INITIALIZED …
#define TOS_NOT_INSTALLED …
#define HCI_PANEL_POWER_ON …
#define HCI_FAN …
#define HCI_TR_BACKLIGHT …
#define HCI_SYSTEM_EVENT …
#define HCI_VIDEO_OUT …
#define HCI_HOTKEY_EVENT …
#define HCI_LCD_BRIGHTNESS …
#define HCI_FAN_RPM …
#define HCI_WIRELESS …
#define HCI_ACCELEROMETER …
#define HCI_COOLING_METHOD …
#define HCI_KBD_ILLUMINATION …
#define HCI_ECO_MODE …
#define HCI_ACCELEROMETER2 …
#define HCI_BATTERY_CHARGE_MODE …
#define HCI_SYSTEM_INFO …
#define SCI_PANEL_POWER_ON …
#define SCI_ILLUMINATION …
#define SCI_USB_SLEEP_CHARGE …
#define SCI_KBD_ILLUM_STATUS …
#define SCI_USB_SLEEP_MUSIC …
#define SCI_USB_THREE …
#define SCI_TOUCHPAD …
#define SCI_KBD_FUNCTION_KEYS …
#define HCI_ACCEL_MASK …
#define HCI_ACCEL_DIRECTION_MASK …
#define HCI_HOTKEY_DISABLE …
#define HCI_HOTKEY_ENABLE_QUICKSTART …
#define HCI_HOTKEY_ENABLE …
#define HCI_HOTKEY_SPECIAL_FUNCTIONS …
#define HCI_LCD_BRIGHTNESS_BITS …
#define HCI_LCD_BRIGHTNESS_SHIFT …
#define HCI_LCD_BRIGHTNESS_LEVELS …
#define HCI_MISC_SHIFT …
#define HCI_SYSTEM_TYPE1 …
#define HCI_SYSTEM_TYPE2 …
#define HCI_VIDEO_OUT_LCD …
#define HCI_VIDEO_OUT_CRT …
#define HCI_VIDEO_OUT_TV …
#define SCI_KBD_MODE_MASK …
#define SCI_KBD_MODE_FNZ …
#define SCI_KBD_MODE_AUTO …
#define SCI_KBD_MODE_ON …
#define SCI_KBD_MODE_OFF …
#define SCI_KBD_TIME_MAX …
#define HCI_WIRELESS_STATUS …
#define HCI_WIRELESS_WWAN …
#define HCI_WIRELESS_WWAN_STATUS …
#define HCI_WIRELESS_WWAN_POWER …
#define SCI_USB_CHARGE_MODE_MASK …
#define SCI_USB_CHARGE_DISABLED …
#define SCI_USB_CHARGE_ALTERNATE …
#define SCI_USB_CHARGE_TYPICAL …
#define SCI_USB_CHARGE_AUTO …
#define SCI_USB_CHARGE_BAT_MASK …
#define SCI_USB_CHARGE_BAT_LVL_OFF …
#define SCI_USB_CHARGE_BAT_LVL_ON …
#define SCI_USB_CHARGE_BAT_LVL …
#define SCI_USB_CHARGE_RAPID_DSP …
struct toshiba_acpi_dev { … };
static struct toshiba_acpi_dev *toshiba_acpi;
static bool disable_hotkeys;
module_param(disable_hotkeys, bool, 0444);
MODULE_PARM_DESC(…) …;
static const struct acpi_device_id toshiba_device_ids[] = …;
MODULE_DEVICE_TABLE(acpi, toshiba_device_ids);
static const struct key_entry toshiba_acpi_keymap[] = …;
static const struct key_entry toshiba_acpi_alt_keymap[] = …;
static inline void _set_bit(u32 *word, u32 mask, int value)
{ … }
static int write_acpi_int(const char *methodName, int val)
{ … }
static acpi_status tci_raw(struct toshiba_acpi_dev *dev,
const u32 in[TCI_WORDS], u32 out[TCI_WORDS])
{ … }
static u32 hci_write(struct toshiba_acpi_dev *dev, u32 reg, u32 in1)
{ … }
static u32 hci_read(struct toshiba_acpi_dev *dev, u32 reg, u32 *out1)
{ … }
static int sci_open(struct toshiba_acpi_dev *dev)
{ … }
static void sci_close(struct toshiba_acpi_dev *dev)
{ … }
static u32 sci_read(struct toshiba_acpi_dev *dev, u32 reg, u32 *out1)
{ … }
static u32 sci_write(struct toshiba_acpi_dev *dev, u32 reg, u32 in1)
{ … }
static void toshiba_illumination_available(struct toshiba_acpi_dev *dev)
{ … }
static void toshiba_illumination_set(struct led_classdev *cdev,
enum led_brightness brightness)
{ … }
static enum led_brightness toshiba_illumination_get(struct led_classdev *cdev)
{ … }
static void toshiba_kbd_illum_available(struct toshiba_acpi_dev *dev)
{ … }
static int toshiba_kbd_illum_status_set(struct toshiba_acpi_dev *dev, u32 time)
{ … }
static int toshiba_kbd_illum_status_get(struct toshiba_acpi_dev *dev, u32 *time)
{ … }
static enum led_brightness toshiba_kbd_backlight_get(struct led_classdev *cdev)
{ … }
static void toshiba_kbd_backlight_set(struct led_classdev *cdev,
enum led_brightness brightness)
{ … }
static int toshiba_touchpad_set(struct toshiba_acpi_dev *dev, u32 state)
{ … }
static int toshiba_touchpad_get(struct toshiba_acpi_dev *dev, u32 *state)
{ … }
static void toshiba_eco_mode_available(struct toshiba_acpi_dev *dev)
{ … }
static enum led_brightness
toshiba_eco_mode_get_status(struct led_classdev *cdev)
{ … }
static void toshiba_eco_mode_set_status(struct led_classdev *cdev,
enum led_brightness brightness)
{ … }
static void toshiba_accelerometer_available(struct toshiba_acpi_dev *dev)
{ … }
static int toshiba_accelerometer_get(struct toshiba_acpi_dev *dev,
u32 *xy, u32 *z)
{ … }
static void toshiba_usb_sleep_charge_available(struct toshiba_acpi_dev *dev)
{ … }
static int toshiba_usb_sleep_charge_get(struct toshiba_acpi_dev *dev,
u32 *mode)
{ … }
static int toshiba_usb_sleep_charge_set(struct toshiba_acpi_dev *dev,
u32 mode)
{ … }
static int toshiba_sleep_functions_status_get(struct toshiba_acpi_dev *dev,
u32 *mode)
{ … }
static int toshiba_sleep_functions_status_set(struct toshiba_acpi_dev *dev,
u32 mode)
{ … }
static int toshiba_usb_rapid_charge_get(struct toshiba_acpi_dev *dev,
u32 *state)
{ … }
static int toshiba_usb_rapid_charge_set(struct toshiba_acpi_dev *dev,
u32 state)
{ … }
static int toshiba_usb_sleep_music_get(struct toshiba_acpi_dev *dev, u32 *state)
{ … }
static int toshiba_usb_sleep_music_set(struct toshiba_acpi_dev *dev, u32 state)
{ … }
static int toshiba_function_keys_get(struct toshiba_acpi_dev *dev, u32 *mode)
{ … }
static int toshiba_function_keys_set(struct toshiba_acpi_dev *dev, u32 mode)
{ … }
static int toshiba_panel_power_on_get(struct toshiba_acpi_dev *dev, u32 *state)
{ … }
static int toshiba_panel_power_on_set(struct toshiba_acpi_dev *dev, u32 state)
{ … }
static int toshiba_usb_three_get(struct toshiba_acpi_dev *dev, u32 *state)
{ … }
static int toshiba_usb_three_set(struct toshiba_acpi_dev *dev, u32 state)
{ … }
static int toshiba_hotkey_event_type_get(struct toshiba_acpi_dev *dev,
u32 *type)
{ … }
static int toshiba_wireless_status(struct toshiba_acpi_dev *dev)
{ … }
static void toshiba_wwan_available(struct toshiba_acpi_dev *dev)
{ … }
static int toshiba_wwan_set(struct toshiba_acpi_dev *dev, u32 state)
{ … }
static void toshiba_cooling_method_available(struct toshiba_acpi_dev *dev)
{ … }
static int toshiba_cooling_method_get(struct toshiba_acpi_dev *dev, u32 *state)
{ … }
static int toshiba_cooling_method_set(struct toshiba_acpi_dev *dev, u32 state)
{ … }
static void toshiba_battery_charge_mode_available(struct toshiba_acpi_dev *dev)
{ … }
static int toshiba_battery_charge_mode_get(struct toshiba_acpi_dev *dev, u32 *state)
{ … }
static int toshiba_battery_charge_mode_set(struct toshiba_acpi_dev *dev, u32 state)
{ … }
static int get_tr_backlight_status(struct toshiba_acpi_dev *dev, u32 *status)
{ … }
static int set_tr_backlight_status(struct toshiba_acpi_dev *dev, u32 status)
{ … }
static struct proc_dir_entry *toshiba_proc_dir;
static int __get_lcd_brightness(struct toshiba_acpi_dev *dev)
{ … }
static int get_lcd_brightness(struct backlight_device *bd)
{ … }
static int lcd_proc_show(struct seq_file *m, void *v)
{ … }
static int lcd_proc_open(struct inode *inode, struct file *file)
{ … }
static int set_lcd_brightness(struct toshiba_acpi_dev *dev, int value)
{ … }
static int set_lcd_status(struct backlight_device *bd)
{ … }
static ssize_t lcd_proc_write(struct file *file, const char __user *buf,
size_t count, loff_t *pos)
{ … }
static const struct proc_ops lcd_proc_ops = …;
static int get_video_status(struct toshiba_acpi_dev *dev, u32 *status)
{ … }
static int video_proc_show(struct seq_file *m, void *v)
{ … }
static int video_proc_open(struct inode *inode, struct file *file)
{ … }
static ssize_t video_proc_write(struct file *file, const char __user *buf,
size_t count, loff_t *pos)
{ … }
static const struct proc_ops video_proc_ops = …;
static int get_fan_status(struct toshiba_acpi_dev *dev, u32 *status)
{ … }
static int set_fan_status(struct toshiba_acpi_dev *dev, u32 status)
{ … }
static int fan_proc_show(struct seq_file *m, void *v)
{ … }
static int fan_proc_open(struct inode *inode, struct file *file)
{ … }
static ssize_t fan_proc_write(struct file *file, const char __user *buf,
size_t count, loff_t *pos)
{ … }
static const struct proc_ops fan_proc_ops = …;
static int get_fan_rpm(struct toshiba_acpi_dev *dev, u32 *rpm)
{ … }
static int keys_proc_show(struct seq_file *m, void *v)
{ … }
static int keys_proc_open(struct inode *inode, struct file *file)
{ … }
static ssize_t keys_proc_write(struct file *file, const char __user *buf,
size_t count, loff_t *pos)
{ … }
static const struct proc_ops keys_proc_ops = …;
static int __maybe_unused version_proc_show(struct seq_file *m, void *v)
{ … }
#define PROC_TOSHIBA …
static void create_toshiba_proc_entries(struct toshiba_acpi_dev *dev)
{ … }
static void remove_toshiba_proc_entries(struct toshiba_acpi_dev *dev)
{ … }
static const struct backlight_ops toshiba_backlight_data = …;
static void toshiba_acpi_kbd_bl_work(struct work_struct *work);
static DECLARE_WORK(kbd_bl_work, toshiba_acpi_kbd_bl_work);
static DEVICE_STRING_ATTR_RO(version, 0444, TOSHIBA_ACPI_VERSION);
static ssize_t fan_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t fan_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RW(fan);
static ssize_t kbd_backlight_mode_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t kbd_backlight_mode_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RW(kbd_backlight_mode);
static ssize_t kbd_type_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(kbd_type);
static ssize_t available_kbd_modes_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(available_kbd_modes);
static ssize_t kbd_backlight_timeout_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t kbd_backlight_timeout_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RW(kbd_backlight_timeout);
static ssize_t touchpad_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t touchpad_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RW(touchpad);
static ssize_t usb_sleep_charge_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t usb_sleep_charge_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(usb_sleep_charge);
static ssize_t sleep_functions_on_battery_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t sleep_functions_on_battery_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(sleep_functions_on_battery);
static ssize_t usb_rapid_charge_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t usb_rapid_charge_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(usb_rapid_charge);
static ssize_t usb_sleep_music_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t usb_sleep_music_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(usb_sleep_music);
static ssize_t kbd_function_keys_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t kbd_function_keys_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(kbd_function_keys);
static ssize_t panel_power_on_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t panel_power_on_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(panel_power_on);
static ssize_t usb_three_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t usb_three_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(usb_three);
static ssize_t cooling_method_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t cooling_method_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(cooling_method);
static struct attribute *toshiba_attributes[] = …;
static umode_t toshiba_sysfs_is_visible(struct kobject *kobj,
struct attribute *attr, int idx)
{ … }
static const struct attribute_group toshiba_attr_group = …;
static void toshiba_acpi_kbd_bl_work(struct work_struct *work)
{ … }
enum toshiba_iio_accel_chan { … };
static int toshiba_iio_accel_get_axis(enum toshiba_iio_accel_chan chan)
{ … }
static int toshiba_iio_accel_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{ … }
#define TOSHIBA_IIO_ACCEL_CHANNEL(axis, chan) …
static const struct iio_chan_spec toshiba_iio_accel_channels[] = …;
static const struct iio_info toshiba_iio_accel_info = …;
static int toshiba_acpi_smm_bridge(SMMRegisters *regs)
{ … }
static long toshiba_acpi_ioctl(struct file *fp, unsigned int cmd,
unsigned long arg)
{ … }
static const struct file_operations toshiba_acpi_fops = …;
static int toshiba_acpi_wwan_set_block(void *data, bool blocked)
{ … }
static void toshiba_acpi_wwan_poll(struct rfkill *rfkill, void *data)
{ … }
static const struct rfkill_ops wwan_rfk_ops = …;
static int toshiba_acpi_setup_wwan_rfkill(struct toshiba_acpi_dev *dev)
{ … }
static int toshiba_acpi_enable_hotkeys(struct toshiba_acpi_dev *dev)
{ … }
static bool toshiba_acpi_i8042_filter(unsigned char data, unsigned char str,
struct serio *port)
{ … }
static void toshiba_acpi_hotkey_work(struct work_struct *work)
{ … }
static int toshiba_acpi_query_hotkey(struct toshiba_acpi_dev *dev)
{ … }
static void toshiba_acpi_report_hotkey(struct toshiba_acpi_dev *dev,
int scancode)
{ … }
static void toshiba_acpi_process_hotkeys(struct toshiba_acpi_dev *dev)
{ … }
static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
{ … }
static int toshiba_acpi_setup_backlight(struct toshiba_acpi_dev *dev)
{ … }
#if IS_ENABLED(CONFIG_HWMON)
static umode_t toshiba_acpi_hwmon_is_visible(const void *drvdata,
enum hwmon_sensor_types type,
u32 attr, int channel)
{ … }
static int toshiba_acpi_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *val)
{ … }
static const struct hwmon_channel_info * const toshiba_acpi_hwmon_info[] = …;
static const struct hwmon_ops toshiba_acpi_hwmon_ops = …;
static const struct hwmon_chip_info toshiba_acpi_hwmon_chip_info = …;
#endif
static ssize_t charge_control_end_threshold_show(struct device *device,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t charge_control_end_threshold_store(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{ … }
static DEVICE_ATTR_RW(charge_control_end_threshold);
static struct attribute *toshiba_acpi_battery_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static int toshiba_acpi_battery_add(struct power_supply *battery, struct acpi_battery_hook *hook)
{ … }
static int toshiba_acpi_battery_remove(struct power_supply *battery, struct acpi_battery_hook *hook)
{ … }
static struct acpi_battery_hook battery_hook = …;
static void print_supported_features(struct toshiba_acpi_dev *dev)
{ … }
static void toshiba_acpi_remove(struct acpi_device *acpi_dev)
{ … }
static const char *find_hci_method(acpi_handle handle)
{ … }
#define QUIRK_TURN_ON_PANEL_ON_RESUME …
#define QUIRK_HCI_HOTKEY_QUICKSTART …
static const struct dmi_system_id toshiba_dmi_quirks[] __initconst = …;
static int toshiba_acpi_add(struct acpi_device *acpi_dev)
{ … }
static void toshiba_acpi_notify(struct acpi_device *acpi_dev, u32 event)
{ … }
#ifdef CONFIG_PM_SLEEP
static int toshiba_acpi_suspend(struct device *device)
{ … }
static int toshiba_acpi_resume(struct device *device)
{ … }
#endif
static SIMPLE_DEV_PM_OPS(toshiba_acpi_pm,
toshiba_acpi_suspend, toshiba_acpi_resume);
static struct acpi_driver toshiba_acpi_driver = …;
static void __init toshiba_dmi_init(void)
{ … }
static int __init toshiba_acpi_init(void)
{ … }
static void __exit toshiba_acpi_exit(void)
{ … }
module_init(…) …;
module_exit(toshiba_acpi_exit);