Lines Matching +full:battery +full:- +full:profile

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2004-2005 Stelian Pop <stelian@popies.net>
6 * Copyright (C) 2007-2009 Mattia Dongili <malattia@linux.it>
14 * Copyright (C) 2001-2005 Stelian Pop <stelian@popies.net>
18 * Copyright (C) 2001-2002 Alcôve <www.alcove.com>
24 * Copyright (C) 2000 Takaya Kinjo <t-kinjo@tc4.so-net.ne.jp>
51 #include <linux/sony-laptop.h>
66 #define SONY_NC_CLASS "sony-nc"
70 #define SONY_PIC_CLASS "sony-pic"
105 static int minor = -1;
109 "default is -1 (automatic)");
112 static int kbd_backlight = -1;
119 static int kbd_backlight_timeout = -1;
212 -1, /* 0 no event */
213 -1, /* 1 SONYPI_EVENT_JOGDIAL_DOWN */
214 -1, /* 2 SONYPI_EVENT_JOGDIAL_UP */
215 -1, /* 3 SONYPI_EVENT_JOGDIAL_DOWN_PRESSED */
216 -1, /* 4 SONYPI_EVENT_JOGDIAL_UP_PRESSED */
217 -1, /* 5 SONYPI_EVENT_JOGDIAL_PRESSED */
218 -1, /* 6 SONYPI_EVENT_JOGDIAL_RELEASED */
248 -1, /* 36 SONYPI_EVENT_LID_CLOSED */
249 -1, /* 37 SONYPI_EVENT_LID_OPENED */
268 -1, /* 56 SONYPI_EVENT_ANYBUTTON_RELEASED */
269 -1, /* 57 SONYPI_EVENT_BATTERY_INSERT */
270 -1, /* 58 SONYPI_EVENT_BATTERY_REMOVE */
271 -1, /* 59 SONYPI_EVENT_FNKEY_RELEASED */
283 -1, /* 71 SONYPI_EVENT_BRIGHTNESS_PRESSED */
379 int scancode = -1; in sony_laptop_report_input_event()
398 input_report_rel(jog_dev, REL_WHEEL, -1); in sony_laptop_report_input_event()
413 if ((scancode = sony_laptop_input_index[event]) != -1) { in sony_laptop_report_input_event()
424 if (scancode != -1) in sony_laptop_report_input_event()
465 error = -ENOMEM; in sony_laptop_setup_input()
469 key_dev->name = "Sony Vaio Keys"; in sony_laptop_setup_input()
470 key_dev->id.bustype = BUS_ISA; in sony_laptop_setup_input()
471 key_dev->id.vendor = PCI_VENDOR_ID_SONY; in sony_laptop_setup_input()
472 key_dev->dev.parent = &acpi_device->dev; in sony_laptop_setup_input()
477 __set_bit(EV_KEY, key_dev->evbit); in sony_laptop_setup_input()
478 key_dev->keycodesize = sizeof(sony_laptop_input_keycode_map[0]); in sony_laptop_setup_input()
479 key_dev->keycodemax = ARRAY_SIZE(sony_laptop_input_keycode_map); in sony_laptop_setup_input()
480 key_dev->keycode = &sony_laptop_input_keycode_map; in sony_laptop_setup_input()
482 __set_bit(sony_laptop_input_keycode_map[i], key_dev->keybit); in sony_laptop_setup_input()
483 __clear_bit(KEY_RESERVED, key_dev->keybit); in sony_laptop_setup_input()
494 error = -ENOMEM; in sony_laptop_setup_input()
498 jog_dev->name = "Sony Vaio Jogdial"; in sony_laptop_setup_input()
499 jog_dev->id.bustype = BUS_ISA; in sony_laptop_setup_input()
500 jog_dev->id.vendor = PCI_VENDOR_ID_SONY; in sony_laptop_setup_input()
501 jog_dev->dev.parent = &acpi_device->dev; in sony_laptop_setup_input()
544 * Generate key-up events for remaining keys. Note that we don't in sony_laptop_remove_input()
570 .name = "sony-laptop",
587 sony_pf_device = platform_device_alloc("sony-laptop", -1); in sony_pf_add()
589 ret = -ENOMEM; in sony_pf_add()
621 /* the device uses 1-based values, while the backlight subsystem uses
622 0-based values */
769 return -EINVAL; in sony_nc_buffer_call()
773 } else if (object->type == ACPI_TYPE_BUFFER) { in sony_nc_buffer_call()
774 len = MIN(buflen, object->buffer.length); in sony_nc_buffer_call()
776 memcpy(buffer, object->buffer.pointer, len); in sony_nc_buffer_call()
778 } else if (object->type == ACPI_TYPE_INTEGER) { in sony_nc_buffer_call()
779 len = MIN(buflen, sizeof(object->integer.value)); in sony_nc_buffer_call()
781 memcpy(buffer, &object->integer.value, len); in sony_nc_buffer_call()
784 pr_warn("Unexpected acpi_object: 0x%x\n", object->type); in sony_nc_buffer_call()
785 ret = -EINVAL; in sony_nc_buffer_call()
822 for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { in sony_nc_handles_show()
823 len += scnprintf(buffer + len, PAGE_SIZE - len, "0x%.4x ", in sony_nc_handles_show()
824 handles->cap[i]); in sony_nc_handles_show()
826 len += scnprintf(buffer + len, PAGE_SIZE - len, "\n"); in sony_nc_handles_show()
837 return -ENOMEM; in sony_nc_handles_setup()
839 for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { in sony_nc_handles_setup()
846 handles->cap[i] = result; in sony_nc_handles_setup()
851 sysfs_attr_init(&handles->devattr.attr); in sony_nc_handles_setup()
852 handles->devattr.attr.name = "handles"; in sony_nc_handles_setup()
853 handles->devattr.attr.mode = S_IRUGO; in sony_nc_handles_setup()
854 handles->devattr.show = sony_nc_handles_show; in sony_nc_handles_setup()
857 if (device_create_file(&pd->dev, &handles->devattr)) { in sony_nc_handles_setup()
860 return -1; in sony_nc_handles_setup()
871 device_remove_file(&pd->dev, &handles->devattr); in sony_nc_handles_cleanup()
884 return -EINVAL; in sony_find_snc_handle()
887 if (handles->cap[i] == handle) { in sony_find_snc_handle()
894 return -EINVAL; in sony_find_snc_handle()
918 * backlight framework for which brightness values are 0-based.
924 return value - 1; in brightness_default_validate()
929 return -EINVAL; in brightness_default_validate()
941 return -EINVAL; in boolean_validate()
956 if (!*item->acpiget) in sony_nc_sysfs_show()
957 return -EIO; in sony_nc_sysfs_show()
959 ret = sony_nc_int_call(sony_nc_acpi_handle, *item->acpiget, NULL, in sony_nc_sysfs_show()
962 return -EIO; in sony_nc_sysfs_show()
964 if (item->validate) in sony_nc_sysfs_show()
965 value = item->validate(SNC_VALIDATE_OUT, value); in sony_nc_sysfs_show()
979 if (!item->acpiset) in sony_nc_sysfs_store()
980 return -EIO; in sony_nc_sysfs_store()
983 return -EINVAL; in sony_nc_sysfs_store()
986 return -EINVAL; in sony_nc_sysfs_store()
988 if (item->validate) in sony_nc_sysfs_store()
989 value = item->validate(SNC_VALIDATE_IN, value); in sony_nc_sysfs_store()
994 ret = sony_nc_int_call(sony_nc_acpi_handle, *item->acpiset, in sony_nc_sysfs_store()
997 return -EIO; in sony_nc_sysfs_store()
999 item->value = value; in sony_nc_sysfs_store()
1000 item->valid = 1; in sony_nc_sysfs_store()
1019 int arg = bd->props.brightness + 1; in sony_backlight_update_status()
1029 /* brightness levels are 1-based, while backlight ones are 0-based */ in sony_backlight_get_brightness()
1030 return value - 1; in sony_backlight_get_brightness()
1039 sony_call_snc_handle(sdev->handle, sdev->cmd_base + 0x100, &result); in sony_nc_get_brightness_ng()
1041 return (result & 0xff) - sdev->offset; in sony_nc_get_brightness_ng()
1050 value = bd->props.brightness + sdev->offset; in sony_nc_update_status_ng()
1051 if (sony_call_snc_handle(sdev->handle, sdev->cmd_base | (value << 0x10), in sony_nc_update_status_ng()
1053 return -EIO; in sony_nc_update_status_ng()
1070 * New SNC-only Vaios event mapping to driver known keys
1143 int ret = -EINVAL; in sony_nc_hotkeys_decode()
1150 return -EINVAL; in sony_nc_hotkeys_decode()
1160 for (; key_event->data; key_event++) { in sony_nc_hotkeys_decode()
1161 if (key_event->data == result) { in sony_nc_hotkeys_decode()
1162 ret = key_event->event; in sony_nc_hotkeys_decode()
1167 if (!key_event->data) in sony_nc_hotkeys_decode()
1194 unsigned int offset = event - 0x90; in sony_nc_notify()
1196 if (offset >= ARRAY_SIZE(handles->cap)) { in sony_nc_notify()
1201 handle = handles->cap[offset]; in sony_nc_notify()
1222 * switch changes position or for battery in sony_nc_notify()
1271 acpi_bus_generate_netlink_event(sony_nc_acpi_device->pnp.device_class, in sony_nc_notify()
1272 dev_name(&sony_nc_acpi_device->dev), ev_type, real_ev); in sony_nc_notify()
1282 (char *)&info->name, info->param_count); in sony_walk_callback()
1302 for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { in sony_nc_function_setup()
1303 unsigned int handle = handles->cap[i]; in sony_nc_function_setup()
1334 pr_err("couldn't set up battery care function (%d)\n", in sony_nc_function_setup()
1347 pr_err("couldn't set up thermal profile function (%d)\n", in sony_nc_function_setup()
1385 pr_err("couldn't set up low battery function (%d)\n", in sony_nc_function_setup()
1436 for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { in sony_nc_function_cleanup()
1438 handle = handles->cap[i]; in sony_nc_function_cleanup()
1511 for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { in sony_nc_function_resume()
1512 unsigned int handle = handles->cap[i]; in sony_nc_function_resume()
1521 /* re-enable hotkeys */ in sony_nc_function_resume()
1525 /* re-enable hotkeys */ in sony_nc_function_resume()
1551 for (item = sony_nc_values; item->name; item++) { in sony_nc_resume()
1554 if (!item->valid) in sony_nc_resume()
1556 ret = sony_nc_int_call(sony_nc_acpi_handle, *item->acpiset, in sony_nc_resume()
1557 &item->value, NULL); in sony_nc_resume()
1619 name = "sony-wifi"; in sony_nc_setup_rfkill()
1623 name = "sony-bluetooth"; in sony_nc_setup_rfkill()
1627 name = "sony-wwan"; in sony_nc_setup_rfkill()
1631 name = "sony-wimax"; in sony_nc_setup_rfkill()
1634 return -EINVAL; in sony_nc_setup_rfkill()
1637 rfk = rfkill_alloc(name, &device->dev, type, in sony_nc_setup_rfkill()
1640 return -ENOMEM; in sony_nc_setup_rfkill()
1718 * 0x20 WWAN GPRS-EDGE in sony_nc_rfkill_setup()
1720 * 0x22 WWAN EV-DO in sony_nc_rfkill_setup()
1774 return -EINVAL; in __sony_nc_kbd_backlight_mode_set()
1776 if (sony_call_snc_handle(kbdbl_ctl->handle, in __sony_nc_kbd_backlight_mode_set()
1777 (value << 0x10) | (kbdbl_ctl->base), &result)) in __sony_nc_kbd_backlight_mode_set()
1778 return -EIO; in __sony_nc_kbd_backlight_mode_set()
1782 sony_call_snc_handle(kbdbl_ctl->handle, in __sony_nc_kbd_backlight_mode_set()
1783 (value << 0x0f) | (kbdbl_ctl->base + 0x100), in __sony_nc_kbd_backlight_mode_set()
1786 kbdbl_ctl->mode = value; in __sony_nc_kbd_backlight_mode_set()
1799 return -EINVAL; in sony_nc_kbd_backlight_mode_store()
1802 return -EINVAL; in sony_nc_kbd_backlight_mode_store()
1815 count = snprintf(buffer, PAGE_SIZE, "%d\n", kbdbl_ctl->mode); in sony_nc_kbd_backlight_mode_show()
1824 return -EINVAL; in __sony_nc_kbd_backlight_timeout_set()
1826 if (sony_call_snc_handle(kbdbl_ctl->handle, (value << 0x10) | in __sony_nc_kbd_backlight_timeout_set()
1827 (kbdbl_ctl->base + 0x200), &result)) in __sony_nc_kbd_backlight_timeout_set()
1828 return -EIO; in __sony_nc_kbd_backlight_timeout_set()
1830 kbdbl_ctl->timeout = value; in __sony_nc_kbd_backlight_timeout_set()
1843 return -EINVAL; in sony_nc_kbd_backlight_timeout_store()
1846 return -EINVAL; in sony_nc_kbd_backlight_timeout_store()
1859 count = snprintf(buffer, PAGE_SIZE, "%d\n", kbdbl_ctl->timeout); in sony_nc_kbd_backlight_timeout_show()
1873 handle, kbdbl_ctl->handle); in sony_nc_kbd_backlight_setup()
1874 return -EBUSY; in sony_nc_kbd_backlight_setup()
1907 return -ENOMEM; in sony_nc_kbd_backlight_setup()
1909 kbdbl_ctl->mode = kbd_backlight; in sony_nc_kbd_backlight_setup()
1910 kbdbl_ctl->timeout = kbd_backlight_timeout; in sony_nc_kbd_backlight_setup()
1911 kbdbl_ctl->handle = handle; in sony_nc_kbd_backlight_setup()
1912 kbdbl_ctl->base = ctl_base; in sony_nc_kbd_backlight_setup()
1914 kbdbl_ctl->has_timeout = handle != 0x0153; in sony_nc_kbd_backlight_setup()
1916 sysfs_attr_init(&kbdbl_ctl->mode_attr.attr); in sony_nc_kbd_backlight_setup()
1917 kbdbl_ctl->mode_attr.attr.name = "kbd_backlight"; in sony_nc_kbd_backlight_setup()
1918 kbdbl_ctl->mode_attr.attr.mode = S_IRUGO | S_IWUSR; in sony_nc_kbd_backlight_setup()
1919 kbdbl_ctl->mode_attr.show = sony_nc_kbd_backlight_mode_show; in sony_nc_kbd_backlight_setup()
1920 kbdbl_ctl->mode_attr.store = sony_nc_kbd_backlight_mode_store; in sony_nc_kbd_backlight_setup()
1922 ret = device_create_file(&pd->dev, &kbdbl_ctl->mode_attr); in sony_nc_kbd_backlight_setup()
1926 __sony_nc_kbd_backlight_mode_set(kbdbl_ctl->mode); in sony_nc_kbd_backlight_setup()
1928 if (kbdbl_ctl->has_timeout) { in sony_nc_kbd_backlight_setup()
1929 sysfs_attr_init(&kbdbl_ctl->timeout_attr.attr); in sony_nc_kbd_backlight_setup()
1930 kbdbl_ctl->timeout_attr.attr.name = "kbd_backlight_timeout"; in sony_nc_kbd_backlight_setup()
1931 kbdbl_ctl->timeout_attr.attr.mode = S_IRUGO | S_IWUSR; in sony_nc_kbd_backlight_setup()
1932 kbdbl_ctl->timeout_attr.show = in sony_nc_kbd_backlight_setup()
1934 kbdbl_ctl->timeout_attr.store = in sony_nc_kbd_backlight_setup()
1937 ret = device_create_file(&pd->dev, &kbdbl_ctl->timeout_attr); in sony_nc_kbd_backlight_setup()
1941 __sony_nc_kbd_backlight_timeout_set(kbdbl_ctl->timeout); in sony_nc_kbd_backlight_setup()
1948 device_remove_file(&pd->dev, &kbdbl_ctl->mode_attr); in sony_nc_kbd_backlight_setup()
1958 if (kbdbl_ctl && handle == kbdbl_ctl->handle) { in sony_nc_kbd_backlight_cleanup()
1959 device_remove_file(&pd->dev, &kbdbl_ctl->mode_attr); in sony_nc_kbd_backlight_cleanup()
1960 if (kbdbl_ctl->has_timeout) in sony_nc_kbd_backlight_cleanup()
1961 device_remove_file(&pd->dev, &kbdbl_ctl->timeout_attr); in sony_nc_kbd_backlight_cleanup()
1981 return -EINVAL; in sony_nc_battery_care_limit_store()
1984 return -EINVAL; in sony_nc_battery_care_limit_store()
1987 * 00 - none in sony_nc_battery_care_limit_store()
1988 * 01 - 80% in sony_nc_battery_care_limit_store()
1989 * 10 - 50% in sony_nc_battery_care_limit_store()
1990 * 11 - 100% in sony_nc_battery_care_limit_store()
1993 * bit 1: 1 tell to store the battery limit (see bits 6,7) too in sony_nc_battery_care_limit_store()
1996 * bits 6,7: store the limit into the battery in sony_nc_battery_care_limit_store()
2011 return -EINVAL; in sony_nc_battery_care_limit_store()
2014 * handle 0x0115 should allow storing on battery too; in sony_nc_battery_care_limit_store()
2016 * handle 0x013f, same as 0x0136 but no storing on the battery in sony_nc_battery_care_limit_store()
2018 if (bcare_ctl->handle != 0x013f) in sony_nc_battery_care_limit_store()
2024 if (sony_call_snc_handle(bcare_ctl->handle, cmd | 0x0100, &result)) in sony_nc_battery_care_limit_store()
2025 return -EIO; in sony_nc_battery_care_limit_store()
2035 if (sony_call_snc_handle(bcare_ctl->handle, 0x0000, &result)) in sony_nc_battery_care_limit_show()
2036 return -EIO; in sony_nc_battery_care_limit_show()
2063 if (sony_call_snc_handle(bcare_ctl->handle, 0x0200, &health)) in sony_nc_battery_care_health_show()
2064 return -EIO; in sony_nc_battery_care_health_show()
2078 return -ENOMEM; in sony_nc_battery_care_setup()
2080 bcare_ctl->handle = handle; in sony_nc_battery_care_setup()
2082 sysfs_attr_init(&bcare_ctl->attrs[0].attr); in sony_nc_battery_care_setup()
2083 bcare_ctl->attrs[0].attr.name = "battery_care_limiter"; in sony_nc_battery_care_setup()
2084 bcare_ctl->attrs[0].attr.mode = S_IRUGO | S_IWUSR; in sony_nc_battery_care_setup()
2085 bcare_ctl->attrs[0].show = sony_nc_battery_care_limit_show; in sony_nc_battery_care_setup()
2086 bcare_ctl->attrs[0].store = sony_nc_battery_care_limit_store; in sony_nc_battery_care_setup()
2088 ret = device_create_file(&pd->dev, &bcare_ctl->attrs[0]); in sony_nc_battery_care_setup()
2096 sysfs_attr_init(&bcare_ctl->attrs[1].attr); in sony_nc_battery_care_setup()
2097 bcare_ctl->attrs[1].attr.name = "battery_care_health"; in sony_nc_battery_care_setup()
2098 bcare_ctl->attrs[1].attr.mode = S_IRUGO; in sony_nc_battery_care_setup()
2099 bcare_ctl->attrs[1].show = sony_nc_battery_care_health_show; in sony_nc_battery_care_setup()
2101 ret = device_create_file(&pd->dev, &bcare_ctl->attrs[1]); in sony_nc_battery_care_setup()
2108 device_remove_file(&pd->dev, &bcare_ctl->attrs[0]); in sony_nc_battery_care_setup()
2120 device_remove_file(&pd->dev, &bcare_ctl->attrs[0]); in sony_nc_battery_care_cleanup()
2121 if (bcare_ctl->handle != 0x0115) in sony_nc_battery_care_cleanup()
2122 device_remove_file(&pd->dev, &bcare_ctl->attrs[1]); in sony_nc_battery_care_cleanup()
2148 /* the thermal profile seems to be a two bit bitmask: in sony_nc_thermal_mode_set()
2149 * lsb -> silent in sony_nc_thermal_mode_set()
2150 * msb -> performance in sony_nc_thermal_mode_set()
2154 if ((mode && !(th_handle->profiles & mode)) || mode >= THM_PROFILE_MAX) in sony_nc_thermal_mode_set()
2155 return -EINVAL; in sony_nc_thermal_mode_set()
2158 return -EIO; in sony_nc_thermal_mode_set()
2160 th_handle->mode = mode; in sony_nc_thermal_mode_set()
2170 return -EIO; in sony_nc_thermal_mode_get()
2182 if (!cnt || (th_handle->profiles & cnt)) in sony_nc_thermal_profiles_show()
2183 idx += scnprintf(buffer + idx, PAGE_SIZE - idx, "%s ", in sony_nc_thermal_profiles_show()
2186 idx += scnprintf(buffer + idx, PAGE_SIZE - idx, "\n"); in sony_nc_thermal_profiles_show()
2199 return -EINVAL; in sony_nc_thermal_mode_store()
2202 if (buffer[len - 1] == '\n') in sony_nc_thermal_mode_store()
2203 len--; in sony_nc_thermal_mode_store()
2210 return -EIO; in sony_nc_thermal_mode_store()
2234 return -ENOMEM; in sony_nc_thermal_setup()
2236 ret = sony_call_snc_handle(0x0122, 0x0000, &th_handle->profiles); in sony_nc_thermal_setup()
2244 pr_warn("couldn't to read the current thermal profile"); in sony_nc_thermal_setup()
2247 th_handle->mode = ret; in sony_nc_thermal_setup()
2249 sysfs_attr_init(&th_handle->profiles_attr.attr); in sony_nc_thermal_setup()
2250 th_handle->profiles_attr.attr.name = "thermal_profiles"; in sony_nc_thermal_setup()
2251 th_handle->profiles_attr.attr.mode = S_IRUGO; in sony_nc_thermal_setup()
2252 th_handle->profiles_attr.show = sony_nc_thermal_profiles_show; in sony_nc_thermal_setup()
2254 sysfs_attr_init(&th_handle->mode_attr.attr); in sony_nc_thermal_setup()
2255 th_handle->mode_attr.attr.name = "thermal_control"; in sony_nc_thermal_setup()
2256 th_handle->mode_attr.attr.mode = S_IRUGO | S_IWUSR; in sony_nc_thermal_setup()
2257 th_handle->mode_attr.show = sony_nc_thermal_mode_show; in sony_nc_thermal_setup()
2258 th_handle->mode_attr.store = sony_nc_thermal_mode_store; in sony_nc_thermal_setup()
2260 ret = device_create_file(&pd->dev, &th_handle->profiles_attr); in sony_nc_thermal_setup()
2264 ret = device_create_file(&pd->dev, &th_handle->mode_attr); in sony_nc_thermal_setup()
2271 device_remove_file(&pd->dev, &th_handle->profiles_attr); in sony_nc_thermal_setup()
2281 device_remove_file(&pd->dev, &th_handle->profiles_attr); in sony_nc_thermal_cleanup()
2282 device_remove_file(&pd->dev, &th_handle->mode_attr); in sony_nc_thermal_cleanup()
2298 if (status != th_handle->mode) in sony_nc_thermal_resume()
2299 sony_nc_thermal_mode_set(th_handle->mode); in sony_nc_thermal_resume()
2323 return -EINVAL; in sony_nc_lid_resume_store()
2326 return -EINVAL; in sony_nc_lid_resume_store()
2329 * +--------------+ in sony_nc_lid_resume_store()
2331 * +--------------+ in sony_nc_lid_resume_store()
2335 if (&lid_ctl->attrs[pos].attr == &attr->attr) in sony_nc_lid_resume_store()
2340 return -EINVAL; in sony_nc_lid_resume_store()
2343 value = lid_ctl->status | (1 << pos); in sony_nc_lid_resume_store()
2345 value = lid_ctl->status & ~(1 << pos); in sony_nc_lid_resume_store()
2347 if (sony_call_snc_handle(lid_ctl->handle, value << 0x10 | 0x0100, in sony_nc_lid_resume_store()
2349 return -EIO; in sony_nc_lid_resume_store()
2351 lid_ctl->status = value; in sony_nc_lid_resume_store()
2363 if (&lid_ctl->attrs[pos].attr == &attr->attr) in sony_nc_lid_resume_show()
2365 (lid_ctl->status >> pos) & 0x01); in sony_nc_lid_resume_show()
2368 return -EINVAL; in sony_nc_lid_resume_show()
2378 return -EIO; in sony_nc_lid_resume_setup()
2382 return -ENOMEM; in sony_nc_lid_resume_setup()
2384 lid_ctl->status = result & 0x7; in sony_nc_lid_resume_setup()
2385 lid_ctl->handle = handle; in sony_nc_lid_resume_setup()
2387 sysfs_attr_init(&lid_ctl->attrs[0].attr); in sony_nc_lid_resume_setup()
2388 lid_ctl->attrs[LID_RESUME_S5].attr.name = "lid_resume_S5"; in sony_nc_lid_resume_setup()
2389 lid_ctl->attrs[LID_RESUME_S5].attr.mode = S_IRUGO | S_IWUSR; in sony_nc_lid_resume_setup()
2390 lid_ctl->attrs[LID_RESUME_S5].show = sony_nc_lid_resume_show; in sony_nc_lid_resume_setup()
2391 lid_ctl->attrs[LID_RESUME_S5].store = sony_nc_lid_resume_store; in sony_nc_lid_resume_setup()
2394 sysfs_attr_init(&lid_ctl->attrs[1].attr); in sony_nc_lid_resume_setup()
2395 lid_ctl->attrs[LID_RESUME_S4].attr.name = "lid_resume_S4"; in sony_nc_lid_resume_setup()
2396 lid_ctl->attrs[LID_RESUME_S4].attr.mode = S_IRUGO | S_IWUSR; in sony_nc_lid_resume_setup()
2397 lid_ctl->attrs[LID_RESUME_S4].show = sony_nc_lid_resume_show; in sony_nc_lid_resume_setup()
2398 lid_ctl->attrs[LID_RESUME_S4].store = sony_nc_lid_resume_store; in sony_nc_lid_resume_setup()
2400 sysfs_attr_init(&lid_ctl->attrs[2].attr); in sony_nc_lid_resume_setup()
2401 lid_ctl->attrs[LID_RESUME_S3].attr.name = "lid_resume_S3"; in sony_nc_lid_resume_setup()
2402 lid_ctl->attrs[LID_RESUME_S3].attr.mode = S_IRUGO | S_IWUSR; in sony_nc_lid_resume_setup()
2403 lid_ctl->attrs[LID_RESUME_S3].show = sony_nc_lid_resume_show; in sony_nc_lid_resume_setup()
2404 lid_ctl->attrs[LID_RESUME_S3].store = sony_nc_lid_resume_store; in sony_nc_lid_resume_setup()
2407 lid_ctl->attrs[i].attr.name; i++) { in sony_nc_lid_resume_setup()
2408 result = device_create_file(&pd->dev, &lid_ctl->attrs[i]); in sony_nc_lid_resume_setup()
2416 for (i--; i >= 0; i--) in sony_nc_lid_resume_setup()
2417 device_remove_file(&pd->dev, &lid_ctl->attrs[i]); in sony_nc_lid_resume_setup()
2431 if (!lid_ctl->attrs[i].attr.name) in sony_nc_lid_resume_cleanup()
2434 device_remove_file(&pd->dev, &lid_ctl->attrs[i]); in sony_nc_lid_resume_cleanup()
2459 if (sony_call_snc_handle(gfxs_ctl->handle, in __sony_nc_gfx_switch_status_get()
2460 gfxs_ctl->handle == 0x015B ? 0x0000 : 0x0100, in __sony_nc_gfx_switch_status_get()
2462 return -EIO; in __sony_nc_gfx_switch_status_get()
2464 switch (gfxs_ctl->handle) { in __sony_nc_gfx_switch_status_get()
2487 return -EINVAL; in __sony_nc_gfx_switch_status_get()
2512 return -ENOMEM; in sony_nc_gfx_switch_setup()
2514 gfxs_ctl->handle = handle; in sony_nc_gfx_switch_setup()
2516 sysfs_attr_init(&gfxs_ctl->attr.attr); in sony_nc_gfx_switch_setup()
2517 gfxs_ctl->attr.attr.name = "gfx_switch_status"; in sony_nc_gfx_switch_setup()
2518 gfxs_ctl->attr.attr.mode = S_IRUGO; in sony_nc_gfx_switch_setup()
2519 gfxs_ctl->attr.show = sony_nc_gfx_switch_status_show; in sony_nc_gfx_switch_setup()
2521 result = device_create_file(&pd->dev, &gfxs_ctl->attr); in sony_nc_gfx_switch_setup()
2537 device_remove_file(&pd->dev, &gfxs_ctl->attr); in sony_nc_gfx_switch_cleanup()
2555 return -EINVAL; in sony_nc_highspeed_charging_store()
2558 return -EINVAL; in sony_nc_highspeed_charging_store()
2561 return -EIO; in sony_nc_highspeed_charging_store()
2572 return -EIO; in sony_nc_highspeed_charging_show()
2591 return -ENOMEM; in sony_nc_highspeed_charging_setup()
2593 sysfs_attr_init(&hsc_handle->attr); in sony_nc_highspeed_charging_setup()
2594 hsc_handle->attr.name = "battery_highspeed_charging"; in sony_nc_highspeed_charging_setup()
2595 hsc_handle->attr.mode = S_IRUGO | S_IWUSR; in sony_nc_highspeed_charging_setup()
2596 hsc_handle->show = sony_nc_highspeed_charging_show; in sony_nc_highspeed_charging_setup()
2597 hsc_handle->store = sony_nc_highspeed_charging_store; in sony_nc_highspeed_charging_setup()
2599 result = device_create_file(&pd->dev, hsc_handle); in sony_nc_highspeed_charging_setup()
2612 device_remove_file(&pd->dev, hsc_handle); in sony_nc_highspeed_charging_cleanup()
2618 /* low battery function */
2629 return -EINVAL; in sony_nc_lowbatt_store()
2632 return -EINVAL; in sony_nc_lowbatt_store()
2635 return -EIO; in sony_nc_lowbatt_store()
2646 return -EIO; in sony_nc_lowbatt_show()
2657 return -ENOMEM; in sony_nc_lowbatt_setup()
2659 sysfs_attr_init(&lowbatt_handle->attr); in sony_nc_lowbatt_setup()
2660 lowbatt_handle->attr.name = "lowbatt_hibernate"; in sony_nc_lowbatt_setup()
2661 lowbatt_handle->attr.mode = S_IRUGO | S_IWUSR; in sony_nc_lowbatt_setup()
2662 lowbatt_handle->show = sony_nc_lowbatt_show; in sony_nc_lowbatt_setup()
2663 lowbatt_handle->store = sony_nc_lowbatt_store; in sony_nc_lowbatt_setup()
2665 result = device_create_file(&pd->dev, lowbatt_handle); in sony_nc_lowbatt_setup()
2678 device_remove_file(&pd->dev, lowbatt_handle); in sony_nc_lowbatt_cleanup()
2695 return -EINVAL; in sony_nc_hsfan_store()
2698 return -EINVAL; in sony_nc_hsfan_store()
2701 return -EIO; in sony_nc_hsfan_store()
2712 return -EIO; in sony_nc_hsfan_show()
2723 return -EIO; in sony_nc_fanspeed_show()
2734 return -ENOMEM; in sony_nc_fanspeed_setup()
2738 result = -ENOMEM; in sony_nc_fanspeed_setup()
2742 sysfs_attr_init(&fan_handle->attr); in sony_nc_fanspeed_setup()
2743 fan_handle->attr.name = "fanspeed"; in sony_nc_fanspeed_setup()
2744 fan_handle->attr.mode = S_IRUGO; in sony_nc_fanspeed_setup()
2745 fan_handle->show = sony_nc_fanspeed_show; in sony_nc_fanspeed_setup()
2746 fan_handle->store = NULL; in sony_nc_fanspeed_setup()
2748 sysfs_attr_init(&hsf_handle->attr); in sony_nc_fanspeed_setup()
2749 hsf_handle->attr.name = "fan_forced"; in sony_nc_fanspeed_setup()
2750 hsf_handle->attr.mode = S_IRUGO | S_IWUSR; in sony_nc_fanspeed_setup()
2751 hsf_handle->show = sony_nc_hsfan_show; in sony_nc_fanspeed_setup()
2752 hsf_handle->store = sony_nc_hsfan_store; in sony_nc_fanspeed_setup()
2754 result = device_create_file(&pd->dev, fan_handle); in sony_nc_fanspeed_setup()
2758 result = device_create_file(&pd->dev, hsf_handle); in sony_nc_fanspeed_setup()
2765 device_remove_file(&pd->dev, fan_handle); in sony_nc_fanspeed_setup()
2780 device_remove_file(&pd->dev, fan_handle); in sony_nc_fanspeed_cleanup()
2785 device_remove_file(&pd->dev, hsf_handle); in sony_nc_fanspeed_cleanup()
2802 return -EINVAL; in sony_nc_usb_charge_store()
2805 return -EINVAL; in sony_nc_usb_charge_store()
2808 return -EIO; in sony_nc_usb_charge_store()
2819 return -EIO; in sony_nc_usb_charge_show()
2838 return -ENOMEM; in sony_nc_usb_charge_setup()
2840 sysfs_attr_init(&uc_handle->attr); in sony_nc_usb_charge_setup()
2841 uc_handle->attr.name = "usb_charge"; in sony_nc_usb_charge_setup()
2842 uc_handle->attr.mode = S_IRUGO | S_IWUSR; in sony_nc_usb_charge_setup()
2843 uc_handle->show = sony_nc_usb_charge_show; in sony_nc_usb_charge_setup()
2844 uc_handle->store = sony_nc_usb_charge_store; in sony_nc_usb_charge_setup()
2846 result = device_create_file(&pd->dev, uc_handle); in sony_nc_usb_charge_setup()
2859 device_remove_file(&pd->dev, uc_handle); in sony_nc_usb_charge_cleanup()
2874 return -EIO; in sony_nc_panelid_show()
2885 return -ENOMEM; in sony_nc_panelid_setup()
2887 sysfs_attr_init(&panel_handle->attr); in sony_nc_panelid_setup()
2888 panel_handle->attr.name = "panel_id"; in sony_nc_panelid_setup()
2889 panel_handle->attr.mode = S_IRUGO; in sony_nc_panelid_setup()
2890 panel_handle->show = sony_nc_panelid_show; in sony_nc_panelid_setup()
2891 panel_handle->store = NULL; in sony_nc_panelid_setup()
2893 result = device_create_file(&pd->dev, panel_handle); in sony_nc_panelid_setup()
2906 device_remove_file(&pd->dev, panel_handle); in sony_nc_panelid_cleanup()
2923 return -EINVAL; in sony_nc_smart_conn_store()
2926 return -EINVAL; in sony_nc_smart_conn_store()
2929 return -EIO; in sony_nc_smart_conn_store()
2940 return -ENOMEM; in sony_nc_smart_conn_setup()
2942 sysfs_attr_init(&sc_handle->attr); in sony_nc_smart_conn_setup()
2943 sc_handle->attr.name = "smart_connect"; in sony_nc_smart_conn_setup()
2944 sc_handle->attr.mode = S_IWUSR; in sony_nc_smart_conn_setup()
2945 sc_handle->show = NULL; in sony_nc_smart_conn_setup()
2946 sc_handle->store = sony_nc_smart_conn_store; in sony_nc_smart_conn_setup()
2948 result = device_create_file(&pd->dev, sc_handle); in sony_nc_smart_conn_setup()
2961 device_remove_file(&pd->dev, sc_handle); in sony_nc_smart_conn_cleanup()
2981 return -EINVAL; in sony_nc_touchpad_store()
2984 return -EINVAL; in sony_nc_touchpad_store()
2989 if (sony_call_snc_handle(tp_ctl->handle, in sony_nc_touchpad_store()
2991 return -EIO; in sony_nc_touchpad_store()
3001 if (sony_call_snc_handle(tp_ctl->handle, 0x000, &result)) in sony_nc_touchpad_show()
3002 return -EINVAL; in sony_nc_touchpad_show()
3014 return -ENOMEM; in sony_nc_touchpad_setup()
3016 tp_ctl->handle = handle; in sony_nc_touchpad_setup()
3018 sysfs_attr_init(&tp_ctl->attr.attr); in sony_nc_touchpad_setup()
3019 tp_ctl->attr.attr.name = "touchpad"; in sony_nc_touchpad_setup()
3020 tp_ctl->attr.attr.mode = S_IRUGO | S_IWUSR; in sony_nc_touchpad_setup()
3021 tp_ctl->attr.show = sony_nc_touchpad_show; in sony_nc_touchpad_setup()
3022 tp_ctl->attr.store = sony_nc_touchpad_store; in sony_nc_touchpad_setup()
3024 ret = device_create_file(&pd->dev, &tp_ctl->attr); in sony_nc_touchpad_setup()
3036 device_remove_file(&pd->dev, &tp_ctl->attr); in sony_nc_touchpad_cleanup()
3051 props->handle = handle; in sony_nc_backlight_ng_read_limits()
3052 props->offset = 0; in sony_nc_backlight_ng_read_limits()
3053 props->maxlvl = 0xff; in sony_nc_backlight_ng_read_limits()
3093 props->offset = min; in sony_nc_backlight_ng_read_limits()
3094 props->maxlvl = max; in sony_nc_backlight_ng_read_limits()
3095 dprintk("Brightness levels: min=%d max=%d\n", props->offset, in sony_nc_backlight_ng_read_limits()
3096 props->maxlvl); in sony_nc_backlight_ng_read_limits()
3109 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3115 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3121 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3127 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3133 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3137 max_brightness = SONY_MAX_BRIGHTNESS - 1; in sony_nc_backlight_setup()
3153 sony_bl_props.dev->props.brightness = in sony_nc_backlight_setup()
3154 ops->get_brightness(sony_bl_props.dev); in sony_nc_backlight_setup()
3171 sony_nc_acpi_handle = device->handle; in sony_nc_add()
3176 if (!result && !device->status.present) { in sony_nc_add()
3178 result = -ENODEV; in sony_nc_add()
3192 result = -ENODEV; in sony_nc_add()
3221 for (item = sony_nc_values; item->name; ++item) { in sony_nc_add()
3223 if (!debug && item->debug) in sony_nc_add()
3227 for (; item->acpiget && *item->acpiget; ++item->acpiget) { in sony_nc_add()
3229 *item->acpiget)) { in sony_nc_add()
3231 item->name, *item->acpiget); in sony_nc_add()
3232 item->devattr.attr.mode |= S_IRUGO; in sony_nc_add()
3238 for (; item->acpiset && *item->acpiset; ++item->acpiset) { in sony_nc_add()
3240 *item->acpiset)) { in sony_nc_add()
3242 item->name, *item->acpiset); in sony_nc_add()
3243 item->devattr.attr.mode |= S_IWUSR; in sony_nc_add()
3248 if (item->devattr.attr.mode != 0) { in sony_nc_add()
3250 device_create_file(&sony_pf_device->dev, in sony_nc_add()
3251 &item->devattr); in sony_nc_add()
3261 for (item = sony_nc_values; item->name; ++item) { in sony_nc_add()
3262 device_remove_file(&sony_pf_device->dev, &item->devattr); in sony_nc_add()
3287 for (item = sony_nc_values; item->name; ++item) { in sony_nc_remove()
3288 device_remove_file(&sony_pf_device->dev, &item->devattr); in sony_nc_remove()
3529 /* The set of possible battery events */
3599 while (--n && (command)) \
3610 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, in sony_pic_call1()
3612 outb(dev, spic_dev.cur_ioport->io1.minimum + 4); in sony_pic_call1()
3613 v1 = inb_p(spic_dev.cur_ioport->io1.minimum + 4); in sony_pic_call1()
3614 v2 = inb_p(spic_dev.cur_ioport->io1.minimum); in sony_pic_call1()
3623 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, in sony_pic_call2()
3625 outb(dev, spic_dev.cur_ioport->io1.minimum + 4); in sony_pic_call2()
3626 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, in sony_pic_call2()
3628 outb(fn, spic_dev.cur_ioport->io1.minimum); in sony_pic_call2()
3629 v1 = inb_p(spic_dev.cur_ioport->io1.minimum); in sony_pic_call2()
3630 dprintk("sony_pic_call2(0x%.2x - 0x%.2x): 0x%.4x\n", dev, fn, v1); in sony_pic_call2()
3638 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG); in sony_pic_call3()
3639 outb(dev, spic_dev.cur_ioport->io1.minimum + 4); in sony_pic_call3()
3640 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG); in sony_pic_call3()
3641 outb(fn, spic_dev.cur_ioport->io1.minimum); in sony_pic_call3()
3642 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG); in sony_pic_call3()
3643 outb(v, spic_dev.cur_ioport->io1.minimum); in sony_pic_call3()
3644 v1 = inb_p(spic_dev.cur_ioport->io1.minimum); in sony_pic_call3()
3645 dprintk("sony_pic_call3(0x%.2x - 0x%.2x - 0x%.2x): 0x%.4x\n", in sony_pic_call3()
3659 * - 0x5c and 0x5f requires 0xA0 in type3_handle_irq()
3660 * - 0x61 requires 0xB3 in type3_handle_irq()
3679 dev->model = SONYPI_DEVICE_TYPE1; in sony_pic_detect_device_type()
3680 dev->evport_offset = SONYPI_TYPE1_OFFSET; in sony_pic_detect_device_type()
3681 dev->event_types = type1_events; in sony_pic_detect_device_type()
3688 dev->model = SONYPI_DEVICE_TYPE2; in sony_pic_detect_device_type()
3689 dev->evport_offset = SONYPI_TYPE2_OFFSET; in sony_pic_detect_device_type()
3690 dev->event_types = type2_events; in sony_pic_detect_device_type()
3697 dev->model = SONYPI_DEVICE_TYPE3; in sony_pic_detect_device_type()
3698 dev->handle_irq = type3_handle_irq; in sony_pic_detect_device_type()
3699 dev->evport_offset = SONYPI_TYPE3_OFFSET; in sony_pic_detect_device_type()
3700 dev->event_types = type3_events; in sony_pic_detect_device_type()
3707 dev->model = SONYPI_DEVICE_TYPE3; in sony_pic_detect_device_type()
3708 dev->handle_irq = type3_handle_irq; in sony_pic_detect_device_type()
3709 dev->evport_offset = SONYPI_TYPE3_OFFSET; in sony_pic_detect_device_type()
3710 dev->event_types = type3_events; in sony_pic_detect_device_type()
3717 dev->model = SONYPI_DEVICE_TYPE3; in sony_pic_detect_device_type()
3718 dev->handle_irq = type3_handle_irq; in sony_pic_detect_device_type()
3719 dev->evport_offset = SONYPI_TYPE3_OFFSET; in sony_pic_detect_device_type()
3720 dev->event_types = type3_events; in sony_pic_detect_device_type()
3725 dev->model = SONYPI_DEVICE_TYPE2; in sony_pic_detect_device_type()
3726 dev->evport_offset = SONYPI_TYPE2_OFFSET; in sony_pic_detect_device_type()
3727 dev->event_types = type2_events; in sony_pic_detect_device_type()
3733 dev->model == SONYPI_DEVICE_TYPE1 ? 1 : in sony_pic_detect_device_type()
3734 dev->model == SONYPI_DEVICE_TYPE2 ? 2 : 3); in sony_pic_detect_device_type()
3781 return -ENODEV; in __sony_pic_camera_off()
3801 return -ENODEV; in __sony_pic_camera_on()
3807 for (j = 5; j > 0; j--) { in __sony_pic_camera_on()
3813 for (i = 400; i > 0; i--) { in __sony_pic_camera_on()
3824 return -ENODEV; in __sony_pic_camera_on()
3839 return -EIO; in sony_pic_camera_command()
3904 return -EINVAL; in sony_pic_wwanpower_store()
3907 return -EINVAL; in sony_pic_wwanpower_store()
3943 return -EINVAL; in sony_pic_bluetoothpower_store()
3946 return -EINVAL; in sony_pic_bluetoothpower_store()
3984 return -EINVAL; in sony_pic_fanspeed_store()
3987 return -EINVAL; in sony_pic_fanspeed_store()
3990 return -EIO; in sony_pic_fanspeed_store()
4000 return -EIO; in sony_pic_fanspeed_show()
4028 /* battery / brightness / temperature addresses */
4087 (file->f_flags & O_NONBLOCK)) in sonypi_misc_read()
4088 return -EAGAIN; in sonypi_misc_read()
4099 return -EFAULT; in sonypi_misc_read()
4105 inode->i_atime = current_time(inode); in sonypi_misc_read()
4123 return -1; in ec_read16()
4125 return -1; in ec_read16()
4143 ret = -EIO; in sonypi_misc_ioctl()
4148 ret = -EIO; in sonypi_misc_ioctl()
4151 val8 = ((value & 0xff) - 1) << 5; in sonypi_misc_ioctl()
4153 ret = -EFAULT; in sonypi_misc_ioctl()
4157 ret = -EIO; in sonypi_misc_ioctl()
4161 ret = -EFAULT; in sonypi_misc_ioctl()
4167 ret = -EIO; in sonypi_misc_ioctl()
4171 sony_bl_props.dev->props.brightness = in sonypi_misc_ioctl()
4176 ret = -EIO; in sonypi_misc_ioctl()
4180 ret = -EFAULT; in sonypi_misc_ioctl()
4184 ret = -EIO; in sonypi_misc_ioctl()
4188 ret = -EFAULT; in sonypi_misc_ioctl()
4192 ret = -EIO; in sonypi_misc_ioctl()
4196 ret = -EFAULT; in sonypi_misc_ioctl()
4200 ret = -EIO; in sonypi_misc_ioctl()
4204 ret = -EFAULT; in sonypi_misc_ioctl()
4208 ret = -EIO; in sonypi_misc_ioctl()
4213 ret = -EFAULT; in sonypi_misc_ioctl()
4218 ret = -EFAULT; in sonypi_misc_ioctl()
4222 ret = -EFAULT; in sonypi_misc_ioctl()
4230 ret = -EIO; in sonypi_misc_ioctl()
4234 ret = -EFAULT; in sonypi_misc_ioctl()
4238 ret = -EFAULT; in sonypi_misc_ioctl()
4242 ret = -EIO; in sonypi_misc_ioctl()
4247 ret = -EIO; in sonypi_misc_ioctl()
4251 ret = -EFAULT; in sonypi_misc_ioctl()
4254 ret = -EINVAL; in sonypi_misc_ioctl()
4299 if (minor != -1) in sonypi_compat_init()
4306 if (minor == -1) in sonypi_compat_init()
4337 switch (resource->type) { in sony_pic_read_possible_resource()
4345 list_add(&ioport->list, &dev->ioports); in sony_pic_read_possible_resource()
4355 struct acpi_resource_irq *p = &resource->data.irq; in sony_pic_read_possible_resource()
4357 if (!p || !p->interrupt_count) { in sony_pic_read_possible_resource()
4365 for (i = 0; i < p->interrupt_count; i++) { in sony_pic_read_possible_resource()
4366 if (!p->interrupts[i]) { in sony_pic_read_possible_resource()
4368 p->interrupts[i]); in sony_pic_read_possible_resource()
4376 list_add(&interrupt->list, &dev->interrupts); in sony_pic_read_possible_resource()
4377 interrupt->irq.triggering = p->triggering; in sony_pic_read_possible_resource()
4378 interrupt->irq.polarity = p->polarity; in sony_pic_read_possible_resource()
4379 interrupt->irq.shareable = p->shareable; in sony_pic_read_possible_resource()
4380 interrupt->irq.interrupt_count = 1; in sony_pic_read_possible_resource()
4381 interrupt->irq.interrupts[0] = p->interrupts[i]; in sony_pic_read_possible_resource()
4387 struct acpi_resource_io *io = &resource->data.io; in sony_pic_read_possible_resource()
4389 list_first_entry(&dev->ioports, struct sony_pic_ioport, list); in sony_pic_read_possible_resource()
4395 if (!ioport->io1.minimum) { in sony_pic_read_possible_resource()
4396 memcpy(&ioport->io1, io, sizeof(*io)); in sony_pic_read_possible_resource()
4397 dprintk("IO1 at 0x%.4x (0x%.2x)\n", ioport->io1.minimum, in sony_pic_read_possible_resource()
4398 ioport->io1.address_length); in sony_pic_read_possible_resource()
4400 else if (!ioport->io2.minimum) { in sony_pic_read_possible_resource()
4401 memcpy(&ioport->io2, io, sizeof(*io)); in sony_pic_read_possible_resource()
4402 dprintk("IO2 at 0x%.4x (0x%.2x)\n", ioport->io2.minimum, in sony_pic_read_possible_resource()
4403 ioport->io2.address_length); in sony_pic_read_possible_resource()
4417 resource->type); in sony_pic_read_possible_resource()
4429 return -EINVAL; in sony_pic_possible_resources()
4440 if (!device->status.enabled) in sony_pic_possible_resources()
4449 status = acpi_walk_resources(device->handle, METHOD_NAME__PRS, in sony_pic_possible_resources()
4453 result = -ENODEV; in sony_pic_possible_resources()
4464 acpi_status ret = acpi_evaluate_object(device->handle, "_DIS", NULL, in sony_pic_disable()
4468 return -ENXIO; in sony_pic_disable()
4505 return -EINVAL; in sony_pic_enable()
4510 return -ENOMEM; in sony_pic_enable()
4519 resource->res1.type = ACPI_RESOURCE_TYPE_IO; in sony_pic_enable()
4520 resource->res1.length = sizeof(struct acpi_resource); in sony_pic_enable()
4521 memcpy(&resource->res1.data.io, &ioport->io1, in sony_pic_enable()
4524 resource->res2.type = ACPI_RESOURCE_TYPE_IO; in sony_pic_enable()
4525 resource->res2.length = sizeof(struct acpi_resource); in sony_pic_enable()
4526 memcpy(&resource->res2.data.io, &ioport->io2, in sony_pic_enable()
4530 resource->res3.type = ACPI_RESOURCE_TYPE_IRQ; in sony_pic_enable()
4531 resource->res3.length = sizeof(struct acpi_resource); in sony_pic_enable()
4532 memcpy(&resource->res3.data.irq, &irq->irq, in sony_pic_enable()
4535 resource->res3.data.irq.shareable = ACPI_SHARED; in sony_pic_enable()
4537 resource->res4.type = ACPI_RESOURCE_TYPE_END_TAG; in sony_pic_enable()
4538 resource->res4.length = sizeof(struct acpi_resource); in sony_pic_enable()
4543 resource->res1.type = ACPI_RESOURCE_TYPE_IO; in sony_pic_enable()
4544 resource->res1.length = sizeof(struct acpi_resource); in sony_pic_enable()
4545 memcpy(&resource->res1.data.io, &ioport->io1, in sony_pic_enable()
4549 resource->res2.type = ACPI_RESOURCE_TYPE_IRQ; in sony_pic_enable()
4550 resource->res2.length = sizeof(struct acpi_resource); in sony_pic_enable()
4551 memcpy(&resource->res2.data.irq, &irq->irq, in sony_pic_enable()
4554 resource->res2.data.irq.shareable = ACPI_SHARED; in sony_pic_enable()
4556 resource->res3.type = ACPI_RESOURCE_TYPE_END_TAG; in sony_pic_enable()
4557 resource->res3.length = sizeof(struct acpi_resource); in sony_pic_enable()
4562 status = acpi_set_current_resources(device->handle, &buffer); in sony_pic_enable()
4567 result = -ENODEV; in sony_pic_enable()
4595 ev = inb_p(dev->cur_ioport->io1.minimum); in sony_pic_irq()
4596 if (dev->cur_ioport->io2.minimum) in sony_pic_irq()
4597 data_mask = inb_p(dev->cur_ioport->io2.minimum); in sony_pic_irq()
4599 data_mask = inb_p(dev->cur_ioport->io1.minimum + in sony_pic_irq()
4600 dev->evport_offset); in sony_pic_irq()
4603 ev, data_mask, dev->cur_ioport->io1.minimum, in sony_pic_irq()
4604 dev->evport_offset); in sony_pic_irq()
4609 for (i = 0; dev->event_types[i].mask; i++) { in sony_pic_irq()
4611 if ((data_mask & dev->event_types[i].data) != in sony_pic_irq()
4612 dev->event_types[i].data) in sony_pic_irq()
4615 if (!(mask & dev->event_types[i].mask)) in sony_pic_irq()
4618 for (j = 0; dev->event_types[i].events[j].event; j++) { in sony_pic_irq()
4619 if (ev == dev->event_types[i].events[j].data) { in sony_pic_irq()
4621 dev->event_types[i].events[j].event; in sony_pic_irq()
4632 if (dev->handle_irq && dev->handle_irq(data_mask, ev) == 0) in sony_pic_irq()
4636 ev, data_mask, dev->cur_ioport->io1.minimum, in sony_pic_irq()
4637 dev->evport_offset); in sony_pic_irq()
4658 return -ENXIO; in sony_pic_remove()
4661 free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev); in sony_pic_remove()
4662 release_region(spic_dev.cur_ioport->io1.minimum, in sony_pic_remove()
4663 spic_dev.cur_ioport->io1.address_length); in sony_pic_remove()
4664 if (spic_dev.cur_ioport->io2.minimum) in sony_pic_remove()
4665 release_region(spic_dev.cur_ioport->io2.minimum, in sony_pic_remove()
4666 spic_dev.cur_ioport->io2.address_length); in sony_pic_remove()
4673 sysfs_remove_group(&sony_pf_device->dev.kobj, &spic_attribute_group); in sony_pic_remove()
4677 list_del(&io->list); in sony_pic_remove()
4681 list_del(&irq->list); in sony_pic_remove()
4722 if (request_region(io->io1.minimum, io->io1.address_length, in sony_pic_add()
4725 io->io1.minimum, io->io1.maximum, in sony_pic_add()
4726 io->io1.address_length); in sony_pic_add()
4728 if (io->io2.minimum) { in sony_pic_add()
4729 if (request_region(io->io2.minimum, in sony_pic_add()
4730 io->io2.address_length, in sony_pic_add()
4733 io->io2.minimum, io->io2.maximum, in sony_pic_add()
4734 io->io2.address_length); in sony_pic_add()
4741 io->io2.minimum, io->io2.maximum, in sony_pic_add()
4742 io->io2.address_length); in sony_pic_add()
4743 release_region(io->io1.minimum, in sony_pic_add()
4744 io->io1.address_length); in sony_pic_add()
4755 result = -ENODEV; in sony_pic_add()
4761 if (!request_irq(irq->irq.interrupts[0], sony_pic_irq, in sony_pic_add()
4762 0, "sony-laptop", &spic_dev)) { in sony_pic_add()
4763 dprintk("IRQ: %d - triggering: %d - " in sony_pic_add()
4764 "polarity: %d - shr: %d\n", in sony_pic_add()
4765 irq->irq.interrupts[0], in sony_pic_add()
4766 irq->irq.triggering, in sony_pic_add()
4767 irq->irq.polarity, in sony_pic_add()
4768 irq->irq.shareable); in sony_pic_add()
4775 result = -ENODEV; in sony_pic_add()
4786 spic_dev.bluetooth_power = -1; in sony_pic_add()
4792 result = sysfs_create_group(&sony_pf_device->dev.kobj, &spic_attribute_group); in sony_pic_add()
4806 free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev); in sony_pic_add()
4809 release_region(spic_dev.cur_ioport->io1.minimum, in sony_pic_add()
4810 spic_dev.cur_ioport->io1.address_length); in sony_pic_add()
4811 if (spic_dev.cur_ioport->io2.minimum) in sony_pic_add()
4812 release_region(spic_dev.cur_ioport->io2.minimum, in sony_pic_add()
4813 spic_dev.cur_ioport->io2.address_length); in sony_pic_add()
4823 list_del(&io->list); in sony_pic_add()
4827 list_del(&irq->list); in sony_pic_add()
4840 return -ENXIO; in sony_pic_suspend()
4876 DMI_MATCH(DMI_PRODUCT_NAME, "PCG-"),
4883 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-"),