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", PLATFORM_DEVID_NONE); 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 += sysfs_emit_at(buffer, len, "0x%.4x ", handles->cap[i]); in sony_nc_handles_show()
836 return -ENOMEM; in sony_nc_handles_setup()
838 for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { in sony_nc_handles_setup()
845 handles->cap[i] = result; in sony_nc_handles_setup()
850 sysfs_attr_init(&handles->devattr.attr); in sony_nc_handles_setup()
851 handles->devattr.attr.name = "handles"; in sony_nc_handles_setup()
852 handles->devattr.attr.mode = S_IRUGO; in sony_nc_handles_setup()
853 handles->devattr.show = sony_nc_handles_show; in sony_nc_handles_setup()
856 if (device_create_file(&pd->dev, &handles->devattr)) { in sony_nc_handles_setup()
859 return -1; in sony_nc_handles_setup()
870 device_remove_file(&pd->dev, &handles->devattr); in sony_nc_handles_cleanup()
883 return -EINVAL; in sony_find_snc_handle()
886 if (handles->cap[i] == handle) { in sony_find_snc_handle()
893 return -EINVAL; in sony_find_snc_handle()
917 * backlight framework for which brightness values are 0-based.
923 return value - 1; in brightness_default_validate()
928 return -EINVAL; in brightness_default_validate()
940 return -EINVAL; in boolean_validate()
955 if (!*item->acpiget) in sony_nc_sysfs_show()
956 return -EIO; in sony_nc_sysfs_show()
958 ret = sony_nc_int_call(sony_nc_acpi_handle, *item->acpiget, NULL, in sony_nc_sysfs_show()
961 return -EIO; in sony_nc_sysfs_show()
963 if (item->validate) in sony_nc_sysfs_show()
964 value = item->validate(SNC_VALIDATE_OUT, value); in sony_nc_sysfs_show()
978 if (!item->acpiset) in sony_nc_sysfs_store()
979 return -EIO; in sony_nc_sysfs_store()
982 return -EINVAL; in sony_nc_sysfs_store()
985 return -EINVAL; in sony_nc_sysfs_store()
987 if (item->validate) in sony_nc_sysfs_store()
988 value = item->validate(SNC_VALIDATE_IN, value); in sony_nc_sysfs_store()
993 ret = sony_nc_int_call(sony_nc_acpi_handle, *item->acpiset, in sony_nc_sysfs_store()
996 return -EIO; in sony_nc_sysfs_store()
998 item->value = value; in sony_nc_sysfs_store()
999 item->valid = 1; in sony_nc_sysfs_store()
1018 int arg = bd->props.brightness + 1; in sony_backlight_update_status()
1028 /* brightness levels are 1-based, while backlight ones are 0-based */ in sony_backlight_get_brightness()
1029 return value - 1; in sony_backlight_get_brightness()
1038 sony_call_snc_handle(sdev->handle, sdev->cmd_base + 0x100, &result); in sony_nc_get_brightness_ng()
1040 return (result & 0xff) - sdev->offset; in sony_nc_get_brightness_ng()
1049 value = bd->props.brightness + sdev->offset; in sony_nc_update_status_ng()
1050 if (sony_call_snc_handle(sdev->handle, sdev->cmd_base | (value << 0x10), in sony_nc_update_status_ng()
1052 return -EIO; in sony_nc_update_status_ng()
1069 * New SNC-only Vaios event mapping to driver known keys
1142 int ret = -EINVAL; in sony_nc_hotkeys_decode()
1149 return -EINVAL; in sony_nc_hotkeys_decode()
1159 for (; key_event->data; key_event++) { in sony_nc_hotkeys_decode()
1160 if (key_event->data == result) { in sony_nc_hotkeys_decode()
1161 ret = key_event->event; in sony_nc_hotkeys_decode()
1166 if (!key_event->data) in sony_nc_hotkeys_decode()
1193 unsigned int offset = event - 0x90; in sony_nc_notify()
1195 if (offset >= ARRAY_SIZE(handles->cap)) { in sony_nc_notify()
1200 handle = handles->cap[offset]; in sony_nc_notify()
1221 * switch changes position or for battery in sony_nc_notify()
1270 acpi_bus_generate_netlink_event(sony_nc_acpi_device->pnp.device_class, in sony_nc_notify()
1271 dev_name(&sony_nc_acpi_device->dev), ev_type, real_ev); in sony_nc_notify()
1281 (char *)&info->name, info->param_count); in sony_walk_callback()
1301 for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { in sony_nc_function_setup()
1302 unsigned int handle = handles->cap[i]; in sony_nc_function_setup()
1333 pr_err("couldn't set up battery care function (%d)\n", in sony_nc_function_setup()
1346 pr_err("couldn't set up thermal profile function (%d)\n", in sony_nc_function_setup()
1384 pr_err("couldn't set up low battery function (%d)\n", in sony_nc_function_setup()
1435 for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { in sony_nc_function_cleanup()
1437 handle = handles->cap[i]; in sony_nc_function_cleanup()
1510 for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { in sony_nc_function_resume()
1511 unsigned int handle = handles->cap[i]; in sony_nc_function_resume()
1520 /* re-enable hotkeys */ in sony_nc_function_resume()
1524 /* re-enable hotkeys */ in sony_nc_function_resume()
1550 for (item = sony_nc_values; item->name; item++) { in sony_nc_resume()
1553 if (!item->valid) in sony_nc_resume()
1555 ret = sony_nc_int_call(sony_nc_acpi_handle, *item->acpiset, in sony_nc_resume()
1556 &item->value, NULL); in sony_nc_resume()
1618 name = "sony-wifi"; in sony_nc_setup_rfkill()
1622 name = "sony-bluetooth"; in sony_nc_setup_rfkill()
1626 name = "sony-wwan"; in sony_nc_setup_rfkill()
1630 name = "sony-wimax"; in sony_nc_setup_rfkill()
1633 return -EINVAL; in sony_nc_setup_rfkill()
1636 rfk = rfkill_alloc(name, &device->dev, type, in sony_nc_setup_rfkill()
1639 return -ENOMEM; in sony_nc_setup_rfkill()
1717 * 0x20 WWAN GPRS-EDGE in sony_nc_rfkill_setup()
1719 * 0x22 WWAN EV-DO in sony_nc_rfkill_setup()
1773 return -EINVAL; in __sony_nc_kbd_backlight_mode_set()
1775 if (sony_call_snc_handle(kbdbl_ctl->handle, in __sony_nc_kbd_backlight_mode_set()
1776 (value << 0x10) | (kbdbl_ctl->base), &result)) in __sony_nc_kbd_backlight_mode_set()
1777 return -EIO; in __sony_nc_kbd_backlight_mode_set()
1781 sony_call_snc_handle(kbdbl_ctl->handle, in __sony_nc_kbd_backlight_mode_set()
1782 (value << 0x0f) | (kbdbl_ctl->base + 0x100), in __sony_nc_kbd_backlight_mode_set()
1785 kbdbl_ctl->mode = value; in __sony_nc_kbd_backlight_mode_set()
1798 return -EINVAL; in sony_nc_kbd_backlight_mode_store()
1801 return -EINVAL; in sony_nc_kbd_backlight_mode_store()
1813 return sysfs_emit(buffer, "%d\n", kbdbl_ctl->mode); in sony_nc_kbd_backlight_mode_show()
1821 return -EINVAL; in __sony_nc_kbd_backlight_timeout_set()
1823 if (sony_call_snc_handle(kbdbl_ctl->handle, (value << 0x10) | in __sony_nc_kbd_backlight_timeout_set()
1824 (kbdbl_ctl->base + 0x200), &result)) in __sony_nc_kbd_backlight_timeout_set()
1825 return -EIO; in __sony_nc_kbd_backlight_timeout_set()
1827 kbdbl_ctl->timeout = value; in __sony_nc_kbd_backlight_timeout_set()
1840 return -EINVAL; in sony_nc_kbd_backlight_timeout_store()
1843 return -EINVAL; in sony_nc_kbd_backlight_timeout_store()
1855 return sysfs_emit(buffer, "%d\n", kbdbl_ctl->timeout); in sony_nc_kbd_backlight_timeout_show()
1868 handle, kbdbl_ctl->handle); in sony_nc_kbd_backlight_setup()
1869 return -EBUSY; in sony_nc_kbd_backlight_setup()
1909 return -ENOMEM; in sony_nc_kbd_backlight_setup()
1911 kbdbl_ctl->mode = kbd_backlight; in sony_nc_kbd_backlight_setup()
1912 kbdbl_ctl->timeout = kbd_backlight_timeout; in sony_nc_kbd_backlight_setup()
1913 kbdbl_ctl->handle = handle; in sony_nc_kbd_backlight_setup()
1914 kbdbl_ctl->base = ctl_base; in sony_nc_kbd_backlight_setup()
1916 kbdbl_ctl->has_timeout = handle != 0x0153; in sony_nc_kbd_backlight_setup()
1918 sysfs_attr_init(&kbdbl_ctl->mode_attr.attr); in sony_nc_kbd_backlight_setup()
1919 kbdbl_ctl->mode_attr.attr.name = "kbd_backlight"; in sony_nc_kbd_backlight_setup()
1920 kbdbl_ctl->mode_attr.attr.mode = S_IRUGO | S_IWUSR; in sony_nc_kbd_backlight_setup()
1921 kbdbl_ctl->mode_attr.show = sony_nc_kbd_backlight_mode_show; in sony_nc_kbd_backlight_setup()
1922 kbdbl_ctl->mode_attr.store = sony_nc_kbd_backlight_mode_store; in sony_nc_kbd_backlight_setup()
1924 ret = device_create_file(&pd->dev, &kbdbl_ctl->mode_attr); in sony_nc_kbd_backlight_setup()
1928 __sony_nc_kbd_backlight_mode_set(kbdbl_ctl->mode); in sony_nc_kbd_backlight_setup()
1930 if (kbdbl_ctl->has_timeout) { in sony_nc_kbd_backlight_setup()
1931 sysfs_attr_init(&kbdbl_ctl->timeout_attr.attr); in sony_nc_kbd_backlight_setup()
1932 kbdbl_ctl->timeout_attr.attr.name = "kbd_backlight_timeout"; in sony_nc_kbd_backlight_setup()
1933 kbdbl_ctl->timeout_attr.attr.mode = S_IRUGO | S_IWUSR; in sony_nc_kbd_backlight_setup()
1934 kbdbl_ctl->timeout_attr.show = in sony_nc_kbd_backlight_setup()
1936 kbdbl_ctl->timeout_attr.store = in sony_nc_kbd_backlight_setup()
1939 ret = device_create_file(&pd->dev, &kbdbl_ctl->timeout_attr); in sony_nc_kbd_backlight_setup()
1943 __sony_nc_kbd_backlight_timeout_set(kbdbl_ctl->timeout); in sony_nc_kbd_backlight_setup()
1950 device_remove_file(&pd->dev, &kbdbl_ctl->mode_attr); in sony_nc_kbd_backlight_setup()
1960 if (kbdbl_ctl && handle == kbdbl_ctl->handle) { in sony_nc_kbd_backlight_cleanup()
1961 device_remove_file(&pd->dev, &kbdbl_ctl->mode_attr); in sony_nc_kbd_backlight_cleanup()
1962 if (kbdbl_ctl->has_timeout) in sony_nc_kbd_backlight_cleanup()
1963 device_remove_file(&pd->dev, &kbdbl_ctl->timeout_attr); in sony_nc_kbd_backlight_cleanup()
1983 return -EINVAL; in sony_nc_battery_care_limit_store()
1986 return -EINVAL; in sony_nc_battery_care_limit_store()
1989 * 00 - none in sony_nc_battery_care_limit_store()
1990 * 01 - 80% in sony_nc_battery_care_limit_store()
1991 * 10 - 50% in sony_nc_battery_care_limit_store()
1992 * 11 - 100% in sony_nc_battery_care_limit_store()
1995 * bit 1: 1 tell to store the battery limit (see bits 6,7) too in sony_nc_battery_care_limit_store()
1998 * bits 6,7: store the limit into the battery in sony_nc_battery_care_limit_store()
2013 return -EINVAL; in sony_nc_battery_care_limit_store()
2016 * handle 0x0115 should allow storing on battery too; in sony_nc_battery_care_limit_store()
2018 * handle 0x013f, same as 0x0136 but no storing on the battery in sony_nc_battery_care_limit_store()
2020 if (bcare_ctl->handle != 0x013f) in sony_nc_battery_care_limit_store()
2026 if (sony_call_snc_handle(bcare_ctl->handle, cmd | 0x0100, &result)) in sony_nc_battery_care_limit_store()
2027 return -EIO; in sony_nc_battery_care_limit_store()
2037 if (sony_call_snc_handle(bcare_ctl->handle, 0x0000, &result)) in sony_nc_battery_care_limit_show()
2038 return -EIO; in sony_nc_battery_care_limit_show()
2064 if (sony_call_snc_handle(bcare_ctl->handle, 0x0200, &health)) in sony_nc_battery_care_health_show()
2065 return -EIO; in sony_nc_battery_care_health_show()
2077 return -ENOMEM; in sony_nc_battery_care_setup()
2079 bcare_ctl->handle = handle; in sony_nc_battery_care_setup()
2081 sysfs_attr_init(&bcare_ctl->attrs[0].attr); in sony_nc_battery_care_setup()
2082 bcare_ctl->attrs[0].attr.name = "battery_care_limiter"; in sony_nc_battery_care_setup()
2083 bcare_ctl->attrs[0].attr.mode = S_IRUGO | S_IWUSR; in sony_nc_battery_care_setup()
2084 bcare_ctl->attrs[0].show = sony_nc_battery_care_limit_show; in sony_nc_battery_care_setup()
2085 bcare_ctl->attrs[0].store = sony_nc_battery_care_limit_store; in sony_nc_battery_care_setup()
2087 ret = device_create_file(&pd->dev, &bcare_ctl->attrs[0]); in sony_nc_battery_care_setup()
2095 sysfs_attr_init(&bcare_ctl->attrs[1].attr); in sony_nc_battery_care_setup()
2096 bcare_ctl->attrs[1].attr.name = "battery_care_health"; in sony_nc_battery_care_setup()
2097 bcare_ctl->attrs[1].attr.mode = S_IRUGO; in sony_nc_battery_care_setup()
2098 bcare_ctl->attrs[1].show = sony_nc_battery_care_health_show; in sony_nc_battery_care_setup()
2100 ret = device_create_file(&pd->dev, &bcare_ctl->attrs[1]); in sony_nc_battery_care_setup()
2107 device_remove_file(&pd->dev, &bcare_ctl->attrs[0]); in sony_nc_battery_care_setup()
2119 device_remove_file(&pd->dev, &bcare_ctl->attrs[0]); in sony_nc_battery_care_cleanup()
2120 if (bcare_ctl->handle != 0x0115) in sony_nc_battery_care_cleanup()
2121 device_remove_file(&pd->dev, &bcare_ctl->attrs[1]); in sony_nc_battery_care_cleanup()
2147 /* the thermal profile seems to be a two bit bitmask: in sony_nc_thermal_mode_set()
2148 * lsb -> silent in sony_nc_thermal_mode_set()
2149 * msb -> performance in sony_nc_thermal_mode_set()
2153 if ((mode && !(th_handle->profiles & mode)) || mode >= THM_PROFILE_MAX) in sony_nc_thermal_mode_set()
2154 return -EINVAL; in sony_nc_thermal_mode_set()
2157 return -EIO; in sony_nc_thermal_mode_set()
2159 th_handle->mode = mode; in sony_nc_thermal_mode_set()
2169 return -EIO; in sony_nc_thermal_mode_get()
2181 if (!cnt || (th_handle->profiles & cnt)) in sony_nc_thermal_profiles_show()
2197 return -EINVAL; in sony_nc_thermal_mode_store()
2200 if (buffer[len - 1] == '\n') in sony_nc_thermal_mode_store()
2201 len--; in sony_nc_thermal_mode_store()
2208 return -EIO; in sony_nc_thermal_mode_store()
2229 return -ENOMEM; in sony_nc_thermal_setup()
2231 ret = sony_call_snc_handle(0x0122, 0x0000, &th_handle->profiles); in sony_nc_thermal_setup()
2239 pr_warn("couldn't to read the current thermal profile"); in sony_nc_thermal_setup()
2242 th_handle->mode = ret; in sony_nc_thermal_setup()
2244 sysfs_attr_init(&th_handle->profiles_attr.attr); in sony_nc_thermal_setup()
2245 th_handle->profiles_attr.attr.name = "thermal_profiles"; in sony_nc_thermal_setup()
2246 th_handle->profiles_attr.attr.mode = S_IRUGO; in sony_nc_thermal_setup()
2247 th_handle->profiles_attr.show = sony_nc_thermal_profiles_show; in sony_nc_thermal_setup()
2249 sysfs_attr_init(&th_handle->mode_attr.attr); in sony_nc_thermal_setup()
2250 th_handle->mode_attr.attr.name = "thermal_control"; in sony_nc_thermal_setup()
2251 th_handle->mode_attr.attr.mode = S_IRUGO | S_IWUSR; in sony_nc_thermal_setup()
2252 th_handle->mode_attr.show = sony_nc_thermal_mode_show; in sony_nc_thermal_setup()
2253 th_handle->mode_attr.store = sony_nc_thermal_mode_store; in sony_nc_thermal_setup()
2255 ret = device_create_file(&pd->dev, &th_handle->profiles_attr); in sony_nc_thermal_setup()
2259 ret = device_create_file(&pd->dev, &th_handle->mode_attr); in sony_nc_thermal_setup()
2266 device_remove_file(&pd->dev, &th_handle->profiles_attr); in sony_nc_thermal_setup()
2276 device_remove_file(&pd->dev, &th_handle->profiles_attr); in sony_nc_thermal_cleanup()
2277 device_remove_file(&pd->dev, &th_handle->mode_attr); in sony_nc_thermal_cleanup()
2293 if (status != th_handle->mode) in sony_nc_thermal_resume()
2294 sony_nc_thermal_mode_set(th_handle->mode); in sony_nc_thermal_resume()
2318 return -EINVAL; in sony_nc_lid_resume_store()
2321 return -EINVAL; in sony_nc_lid_resume_store()
2324 * +--------------+ in sony_nc_lid_resume_store()
2326 * +--------------+ in sony_nc_lid_resume_store()
2330 if (&lid_ctl->attrs[pos].attr == &attr->attr) in sony_nc_lid_resume_store()
2335 return -EINVAL; in sony_nc_lid_resume_store()
2338 value = lid_ctl->status | (1 << pos); in sony_nc_lid_resume_store()
2340 value = lid_ctl->status & ~(1 << pos); in sony_nc_lid_resume_store()
2342 if (sony_call_snc_handle(lid_ctl->handle, value << 0x10 | 0x0100, in sony_nc_lid_resume_store()
2344 return -EIO; in sony_nc_lid_resume_store()
2346 lid_ctl->status = value; in sony_nc_lid_resume_store()
2358 if (&lid_ctl->attrs[pos].attr == &attr->attr) in sony_nc_lid_resume_show()
2360 (lid_ctl->status >> pos) & 0x01); in sony_nc_lid_resume_show()
2363 return -EINVAL; in sony_nc_lid_resume_show()
2373 return -EIO; in sony_nc_lid_resume_setup()
2377 return -ENOMEM; in sony_nc_lid_resume_setup()
2379 lid_ctl->status = result & 0x7; in sony_nc_lid_resume_setup()
2380 lid_ctl->handle = handle; in sony_nc_lid_resume_setup()
2382 sysfs_attr_init(&lid_ctl->attrs[0].attr); in sony_nc_lid_resume_setup()
2383 lid_ctl->attrs[LID_RESUME_S5].attr.name = "lid_resume_S5"; in sony_nc_lid_resume_setup()
2384 lid_ctl->attrs[LID_RESUME_S5].attr.mode = S_IRUGO | S_IWUSR; in sony_nc_lid_resume_setup()
2385 lid_ctl->attrs[LID_RESUME_S5].show = sony_nc_lid_resume_show; in sony_nc_lid_resume_setup()
2386 lid_ctl->attrs[LID_RESUME_S5].store = sony_nc_lid_resume_store; in sony_nc_lid_resume_setup()
2389 sysfs_attr_init(&lid_ctl->attrs[1].attr); in sony_nc_lid_resume_setup()
2390 lid_ctl->attrs[LID_RESUME_S4].attr.name = "lid_resume_S4"; in sony_nc_lid_resume_setup()
2391 lid_ctl->attrs[LID_RESUME_S4].attr.mode = S_IRUGO | S_IWUSR; in sony_nc_lid_resume_setup()
2392 lid_ctl->attrs[LID_RESUME_S4].show = sony_nc_lid_resume_show; in sony_nc_lid_resume_setup()
2393 lid_ctl->attrs[LID_RESUME_S4].store = sony_nc_lid_resume_store; in sony_nc_lid_resume_setup()
2395 sysfs_attr_init(&lid_ctl->attrs[2].attr); in sony_nc_lid_resume_setup()
2396 lid_ctl->attrs[LID_RESUME_S3].attr.name = "lid_resume_S3"; in sony_nc_lid_resume_setup()
2397 lid_ctl->attrs[LID_RESUME_S3].attr.mode = S_IRUGO | S_IWUSR; in sony_nc_lid_resume_setup()
2398 lid_ctl->attrs[LID_RESUME_S3].show = sony_nc_lid_resume_show; in sony_nc_lid_resume_setup()
2399 lid_ctl->attrs[LID_RESUME_S3].store = sony_nc_lid_resume_store; in sony_nc_lid_resume_setup()
2402 lid_ctl->attrs[i].attr.name; i++) { in sony_nc_lid_resume_setup()
2403 result = device_create_file(&pd->dev, &lid_ctl->attrs[i]); in sony_nc_lid_resume_setup()
2411 for (i--; i >= 0; i--) in sony_nc_lid_resume_setup()
2412 device_remove_file(&pd->dev, &lid_ctl->attrs[i]); in sony_nc_lid_resume_setup()
2426 if (!lid_ctl->attrs[i].attr.name) in sony_nc_lid_resume_cleanup()
2429 device_remove_file(&pd->dev, &lid_ctl->attrs[i]); in sony_nc_lid_resume_cleanup()
2454 if (sony_call_snc_handle(gfxs_ctl->handle, in __sony_nc_gfx_switch_status_get()
2455 gfxs_ctl->handle == 0x015B ? 0x0000 : 0x0100, in __sony_nc_gfx_switch_status_get()
2457 return -EIO; in __sony_nc_gfx_switch_status_get()
2459 switch (gfxs_ctl->handle) { in __sony_nc_gfx_switch_status_get()
2479 return -EINVAL; in __sony_nc_gfx_switch_status_get()
2504 return -ENOMEM; in sony_nc_gfx_switch_setup()
2506 gfxs_ctl->handle = handle; in sony_nc_gfx_switch_setup()
2508 sysfs_attr_init(&gfxs_ctl->attr.attr); in sony_nc_gfx_switch_setup()
2509 gfxs_ctl->attr.attr.name = "gfx_switch_status"; in sony_nc_gfx_switch_setup()
2510 gfxs_ctl->attr.attr.mode = S_IRUGO; in sony_nc_gfx_switch_setup()
2511 gfxs_ctl->attr.show = sony_nc_gfx_switch_status_show; in sony_nc_gfx_switch_setup()
2513 result = device_create_file(&pd->dev, &gfxs_ctl->attr); in sony_nc_gfx_switch_setup()
2529 device_remove_file(&pd->dev, &gfxs_ctl->attr); in sony_nc_gfx_switch_cleanup()
2547 return -EINVAL; in sony_nc_highspeed_charging_store()
2550 return -EINVAL; in sony_nc_highspeed_charging_store()
2553 return -EIO; in sony_nc_highspeed_charging_store()
2564 return -EIO; in sony_nc_highspeed_charging_show()
2583 return -ENOMEM; in sony_nc_highspeed_charging_setup()
2585 sysfs_attr_init(&hsc_handle->attr); in sony_nc_highspeed_charging_setup()
2586 hsc_handle->attr.name = "battery_highspeed_charging"; in sony_nc_highspeed_charging_setup()
2587 hsc_handle->attr.mode = S_IRUGO | S_IWUSR; in sony_nc_highspeed_charging_setup()
2588 hsc_handle->show = sony_nc_highspeed_charging_show; in sony_nc_highspeed_charging_setup()
2589 hsc_handle->store = sony_nc_highspeed_charging_store; in sony_nc_highspeed_charging_setup()
2591 result = device_create_file(&pd->dev, hsc_handle); in sony_nc_highspeed_charging_setup()
2604 device_remove_file(&pd->dev, hsc_handle); in sony_nc_highspeed_charging_cleanup()
2610 /* low battery function */
2621 return -EINVAL; in sony_nc_lowbatt_store()
2624 return -EINVAL; in sony_nc_lowbatt_store()
2627 return -EIO; in sony_nc_lowbatt_store()
2638 return -EIO; in sony_nc_lowbatt_show()
2649 return -ENOMEM; in sony_nc_lowbatt_setup()
2651 sysfs_attr_init(&lowbatt_handle->attr); in sony_nc_lowbatt_setup()
2652 lowbatt_handle->attr.name = "lowbatt_hibernate"; in sony_nc_lowbatt_setup()
2653 lowbatt_handle->attr.mode = S_IRUGO | S_IWUSR; in sony_nc_lowbatt_setup()
2654 lowbatt_handle->show = sony_nc_lowbatt_show; in sony_nc_lowbatt_setup()
2655 lowbatt_handle->store = sony_nc_lowbatt_store; in sony_nc_lowbatt_setup()
2657 result = device_create_file(&pd->dev, lowbatt_handle); in sony_nc_lowbatt_setup()
2670 device_remove_file(&pd->dev, lowbatt_handle); in sony_nc_lowbatt_cleanup()
2687 return -EINVAL; in sony_nc_hsfan_store()
2690 return -EINVAL; in sony_nc_hsfan_store()
2693 return -EIO; in sony_nc_hsfan_store()
2704 return -EIO; in sony_nc_hsfan_show()
2715 return -EIO; in sony_nc_fanspeed_show()
2726 return -ENOMEM; in sony_nc_fanspeed_setup()
2730 result = -ENOMEM; in sony_nc_fanspeed_setup()
2734 sysfs_attr_init(&fan_handle->attr); in sony_nc_fanspeed_setup()
2735 fan_handle->attr.name = "fanspeed"; in sony_nc_fanspeed_setup()
2736 fan_handle->attr.mode = S_IRUGO; in sony_nc_fanspeed_setup()
2737 fan_handle->show = sony_nc_fanspeed_show; in sony_nc_fanspeed_setup()
2738 fan_handle->store = NULL; in sony_nc_fanspeed_setup()
2740 sysfs_attr_init(&hsf_handle->attr); in sony_nc_fanspeed_setup()
2741 hsf_handle->attr.name = "fan_forced"; in sony_nc_fanspeed_setup()
2742 hsf_handle->attr.mode = S_IRUGO | S_IWUSR; in sony_nc_fanspeed_setup()
2743 hsf_handle->show = sony_nc_hsfan_show; in sony_nc_fanspeed_setup()
2744 hsf_handle->store = sony_nc_hsfan_store; in sony_nc_fanspeed_setup()
2746 result = device_create_file(&pd->dev, fan_handle); in sony_nc_fanspeed_setup()
2750 result = device_create_file(&pd->dev, hsf_handle); in sony_nc_fanspeed_setup()
2757 device_remove_file(&pd->dev, fan_handle); in sony_nc_fanspeed_setup()
2772 device_remove_file(&pd->dev, fan_handle); in sony_nc_fanspeed_cleanup()
2777 device_remove_file(&pd->dev, hsf_handle); in sony_nc_fanspeed_cleanup()
2794 return -EINVAL; in sony_nc_usb_charge_store()
2797 return -EINVAL; in sony_nc_usb_charge_store()
2800 return -EIO; in sony_nc_usb_charge_store()
2811 return -EIO; in sony_nc_usb_charge_show()
2830 return -ENOMEM; in sony_nc_usb_charge_setup()
2832 sysfs_attr_init(&uc_handle->attr); in sony_nc_usb_charge_setup()
2833 uc_handle->attr.name = "usb_charge"; in sony_nc_usb_charge_setup()
2834 uc_handle->attr.mode = S_IRUGO | S_IWUSR; in sony_nc_usb_charge_setup()
2835 uc_handle->show = sony_nc_usb_charge_show; in sony_nc_usb_charge_setup()
2836 uc_handle->store = sony_nc_usb_charge_store; in sony_nc_usb_charge_setup()
2838 result = device_create_file(&pd->dev, uc_handle); in sony_nc_usb_charge_setup()
2851 device_remove_file(&pd->dev, uc_handle); in sony_nc_usb_charge_cleanup()
2866 return -EIO; in sony_nc_panelid_show()
2877 return -ENOMEM; in sony_nc_panelid_setup()
2879 sysfs_attr_init(&panel_handle->attr); in sony_nc_panelid_setup()
2880 panel_handle->attr.name = "panel_id"; in sony_nc_panelid_setup()
2881 panel_handle->attr.mode = S_IRUGO; in sony_nc_panelid_setup()
2882 panel_handle->show = sony_nc_panelid_show; in sony_nc_panelid_setup()
2883 panel_handle->store = NULL; in sony_nc_panelid_setup()
2885 result = device_create_file(&pd->dev, panel_handle); in sony_nc_panelid_setup()
2898 device_remove_file(&pd->dev, panel_handle); in sony_nc_panelid_cleanup()
2915 return -EINVAL; in sony_nc_smart_conn_store()
2918 return -EINVAL; in sony_nc_smart_conn_store()
2921 return -EIO; in sony_nc_smart_conn_store()
2932 return -ENOMEM; in sony_nc_smart_conn_setup()
2934 sysfs_attr_init(&sc_handle->attr); in sony_nc_smart_conn_setup()
2935 sc_handle->attr.name = "smart_connect"; in sony_nc_smart_conn_setup()
2936 sc_handle->attr.mode = S_IWUSR; in sony_nc_smart_conn_setup()
2937 sc_handle->show = NULL; in sony_nc_smart_conn_setup()
2938 sc_handle->store = sony_nc_smart_conn_store; in sony_nc_smart_conn_setup()
2940 result = device_create_file(&pd->dev, sc_handle); in sony_nc_smart_conn_setup()
2953 device_remove_file(&pd->dev, sc_handle); in sony_nc_smart_conn_cleanup()
2973 return -EINVAL; in sony_nc_touchpad_store()
2976 return -EINVAL; in sony_nc_touchpad_store()
2981 if (sony_call_snc_handle(tp_ctl->handle, in sony_nc_touchpad_store()
2983 return -EIO; in sony_nc_touchpad_store()
2993 if (sony_call_snc_handle(tp_ctl->handle, 0x000, &result)) in sony_nc_touchpad_show()
2994 return -EINVAL; in sony_nc_touchpad_show()
3006 return -ENOMEM; in sony_nc_touchpad_setup()
3008 tp_ctl->handle = handle; in sony_nc_touchpad_setup()
3010 sysfs_attr_init(&tp_ctl->attr.attr); in sony_nc_touchpad_setup()
3011 tp_ctl->attr.attr.name = "touchpad"; in sony_nc_touchpad_setup()
3012 tp_ctl->attr.attr.mode = S_IRUGO | S_IWUSR; in sony_nc_touchpad_setup()
3013 tp_ctl->attr.show = sony_nc_touchpad_show; in sony_nc_touchpad_setup()
3014 tp_ctl->attr.store = sony_nc_touchpad_store; in sony_nc_touchpad_setup()
3016 ret = device_create_file(&pd->dev, &tp_ctl->attr); in sony_nc_touchpad_setup()
3028 device_remove_file(&pd->dev, &tp_ctl->attr); in sony_nc_touchpad_cleanup()
3043 props->handle = handle; in sony_nc_backlight_ng_read_limits()
3044 props->offset = 0; in sony_nc_backlight_ng_read_limits()
3045 props->maxlvl = 0xff; in sony_nc_backlight_ng_read_limits()
3085 props->offset = min; in sony_nc_backlight_ng_read_limits()
3086 props->maxlvl = max; in sony_nc_backlight_ng_read_limits()
3087 dprintk("Brightness levels: min=%d max=%d\n", props->offset, in sony_nc_backlight_ng_read_limits()
3088 props->maxlvl); in sony_nc_backlight_ng_read_limits()
3101 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3107 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3113 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3119 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3125 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3129 max_brightness = SONY_MAX_BRIGHTNESS - 1; in sony_nc_backlight_setup()
3145 sony_bl_props.dev->props.brightness = in sony_nc_backlight_setup()
3146 ops->get_brightness(sony_bl_props.dev); in sony_nc_backlight_setup()
3163 sony_nc_acpi_handle = device->handle; in sony_nc_add()
3168 if (!result && !device->status.present) { in sony_nc_add()
3170 result = -ENODEV; in sony_nc_add()
3184 result = -ENODEV; in sony_nc_add()
3213 for (item = sony_nc_values; item->name; ++item) { in sony_nc_add()
3215 if (!debug && item->debug) in sony_nc_add()
3219 for (; item->acpiget && *item->acpiget; ++item->acpiget) { in sony_nc_add()
3221 *item->acpiget)) { in sony_nc_add()
3223 item->name, *item->acpiget); in sony_nc_add()
3224 item->devattr.attr.mode |= S_IRUGO; in sony_nc_add()
3230 for (; item->acpiset && *item->acpiset; ++item->acpiset) { in sony_nc_add()
3232 *item->acpiset)) { in sony_nc_add()
3234 item->name, *item->acpiset); in sony_nc_add()
3235 item->devattr.attr.mode |= S_IWUSR; in sony_nc_add()
3240 if (item->devattr.attr.mode != 0) { in sony_nc_add()
3242 device_create_file(&sony_pf_device->dev, in sony_nc_add()
3243 &item->devattr); in sony_nc_add()
3253 for (item = sony_nc_values; item->name; ++item) { in sony_nc_add()
3254 device_remove_file(&sony_pf_device->dev, &item->devattr); in sony_nc_add()
3279 for (item = sony_nc_values; item->name; ++item) { in sony_nc_remove()
3280 device_remove_file(&sony_pf_device->dev, &item->devattr); in sony_nc_remove()
3519 /* The set of possible battery events */
3589 while (--n && (command)) \
3600 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, in sony_pic_call1()
3602 outb(dev, spic_dev.cur_ioport->io1.minimum + 4); in sony_pic_call1()
3603 v1 = inb_p(spic_dev.cur_ioport->io1.minimum + 4); in sony_pic_call1()
3604 v2 = inb_p(spic_dev.cur_ioport->io1.minimum); in sony_pic_call1()
3613 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, in sony_pic_call2()
3615 outb(dev, spic_dev.cur_ioport->io1.minimum + 4); in sony_pic_call2()
3616 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, in sony_pic_call2()
3618 outb(fn, spic_dev.cur_ioport->io1.minimum); in sony_pic_call2()
3619 v1 = inb_p(spic_dev.cur_ioport->io1.minimum); in sony_pic_call2()
3620 dprintk("sony_pic_call2(0x%.2x - 0x%.2x): 0x%.4x\n", dev, fn, v1); in sony_pic_call2()
3628 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG); in sony_pic_call3()
3629 outb(dev, spic_dev.cur_ioport->io1.minimum + 4); in sony_pic_call3()
3630 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG); in sony_pic_call3()
3631 outb(fn, spic_dev.cur_ioport->io1.minimum); in sony_pic_call3()
3632 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG); in sony_pic_call3()
3633 outb(v, spic_dev.cur_ioport->io1.minimum); in sony_pic_call3()
3634 v1 = inb_p(spic_dev.cur_ioport->io1.minimum); in sony_pic_call3()
3635 dprintk("sony_pic_call3(0x%.2x - 0x%.2x - 0x%.2x): 0x%.4x\n", in sony_pic_call3()
3649 * - 0x5c and 0x5f requires 0xA0 in type3_handle_irq()
3650 * - 0x61 requires 0xB3 in type3_handle_irq()
3669 dev->model = SONYPI_DEVICE_TYPE1; in sony_pic_detect_device_type()
3670 dev->evport_offset = SONYPI_TYPE1_OFFSET; in sony_pic_detect_device_type()
3671 dev->event_types = type1_events; in sony_pic_detect_device_type()
3678 dev->model = SONYPI_DEVICE_TYPE2; in sony_pic_detect_device_type()
3679 dev->evport_offset = SONYPI_TYPE2_OFFSET; in sony_pic_detect_device_type()
3680 dev->event_types = type2_events; in sony_pic_detect_device_type()
3687 dev->model = SONYPI_DEVICE_TYPE3; in sony_pic_detect_device_type()
3688 dev->handle_irq = type3_handle_irq; in sony_pic_detect_device_type()
3689 dev->evport_offset = SONYPI_TYPE3_OFFSET; in sony_pic_detect_device_type()
3690 dev->event_types = type3_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()
3715 dev->model = SONYPI_DEVICE_TYPE2; in sony_pic_detect_device_type()
3716 dev->evport_offset = SONYPI_TYPE2_OFFSET; in sony_pic_detect_device_type()
3717 dev->event_types = type2_events; in sony_pic_detect_device_type()
3723 dev->model == SONYPI_DEVICE_TYPE1 ? 1 : in sony_pic_detect_device_type()
3724 dev->model == SONYPI_DEVICE_TYPE2 ? 2 : 3); in sony_pic_detect_device_type()
3771 return -ENODEV; in __sony_pic_camera_off()
3791 return -ENODEV; in __sony_pic_camera_on()
3797 for (j = 5; j > 0; j--) { in __sony_pic_camera_on()
3803 for (i = 400; i > 0; i--) { in __sony_pic_camera_on()
3814 return -ENODEV; in __sony_pic_camera_on()
3829 return -EIO; in sony_pic_camera_command()
3894 return -EINVAL; in sony_pic_wwanpower_store()
3897 return -EINVAL; in sony_pic_wwanpower_store()
3933 return -EINVAL; in sony_pic_bluetoothpower_store()
3936 return -EINVAL; in sony_pic_bluetoothpower_store()
3974 return -EINVAL; in sony_pic_fanspeed_store()
3977 return -EINVAL; in sony_pic_fanspeed_store()
3980 return -EIO; in sony_pic_fanspeed_store()
3990 return -EIO; in sony_pic_fanspeed_show()
4018 /* battery / brightness / temperature addresses */
4077 (file->f_flags & O_NONBLOCK)) in sonypi_misc_read()
4078 return -EAGAIN; in sonypi_misc_read()
4089 return -EFAULT; in sonypi_misc_read()
4095 inode->i_atime = current_time(inode); in sonypi_misc_read()
4113 return -1; in ec_read16()
4115 return -1; in ec_read16()
4133 ret = -EIO; in sonypi_misc_ioctl()
4138 ret = -EIO; in sonypi_misc_ioctl()
4141 val8 = ((value & 0xff) - 1) << 5; in sonypi_misc_ioctl()
4143 ret = -EFAULT; in sonypi_misc_ioctl()
4147 ret = -EIO; in sonypi_misc_ioctl()
4151 ret = -EFAULT; in sonypi_misc_ioctl()
4157 ret = -EIO; in sonypi_misc_ioctl()
4161 sony_bl_props.dev->props.brightness = in sonypi_misc_ioctl()
4166 ret = -EIO; in sonypi_misc_ioctl()
4170 ret = -EFAULT; in sonypi_misc_ioctl()
4174 ret = -EIO; in sonypi_misc_ioctl()
4178 ret = -EFAULT; in sonypi_misc_ioctl()
4182 ret = -EIO; in sonypi_misc_ioctl()
4186 ret = -EFAULT; in sonypi_misc_ioctl()
4190 ret = -EIO; in sonypi_misc_ioctl()
4194 ret = -EFAULT; in sonypi_misc_ioctl()
4198 ret = -EIO; in sonypi_misc_ioctl()
4203 ret = -EFAULT; in sonypi_misc_ioctl()
4208 ret = -EFAULT; in sonypi_misc_ioctl()
4212 ret = -EFAULT; in sonypi_misc_ioctl()
4220 ret = -EIO; in sonypi_misc_ioctl()
4224 ret = -EFAULT; in sonypi_misc_ioctl()
4228 ret = -EFAULT; in sonypi_misc_ioctl()
4232 ret = -EIO; in sonypi_misc_ioctl()
4237 ret = -EIO; in sonypi_misc_ioctl()
4241 ret = -EFAULT; in sonypi_misc_ioctl()
4244 ret = -EINVAL; in sonypi_misc_ioctl()
4289 if (minor != -1) in sonypi_compat_init()
4296 if (minor == -1) in sonypi_compat_init()
4327 switch (resource->type) { in sony_pic_read_possible_resource()
4335 list_add(&ioport->list, &dev->ioports); in sony_pic_read_possible_resource()
4345 struct acpi_resource_irq *p = &resource->data.irq; in sony_pic_read_possible_resource()
4347 if (!p->interrupt_count) { in sony_pic_read_possible_resource()
4355 for (i = 0; i < p->interrupt_count; i++) { in sony_pic_read_possible_resource()
4356 if (!p->interrupts[i]) { in sony_pic_read_possible_resource()
4358 p->interrupts[i]); in sony_pic_read_possible_resource()
4366 list_add(&interrupt->list, &dev->interrupts); in sony_pic_read_possible_resource()
4367 interrupt->irq.triggering = p->triggering; in sony_pic_read_possible_resource()
4368 interrupt->irq.polarity = p->polarity; in sony_pic_read_possible_resource()
4369 interrupt->irq.shareable = p->shareable; in sony_pic_read_possible_resource()
4370 interrupt->irq.interrupt_count = 1; in sony_pic_read_possible_resource()
4371 interrupt->irq.interrupts[0] = p->interrupts[i]; in sony_pic_read_possible_resource()
4377 struct acpi_resource_io *io = &resource->data.io; in sony_pic_read_possible_resource()
4379 list_first_entry(&dev->ioports, struct sony_pic_ioport, list); in sony_pic_read_possible_resource()
4380 if (!ioport->io1.minimum) { in sony_pic_read_possible_resource()
4381 memcpy(&ioport->io1, io, sizeof(*io)); in sony_pic_read_possible_resource()
4382 dprintk("IO1 at 0x%.4x (0x%.2x)\n", ioport->io1.minimum, in sony_pic_read_possible_resource()
4383 ioport->io1.address_length); in sony_pic_read_possible_resource()
4385 else if (!ioport->io2.minimum) { in sony_pic_read_possible_resource()
4386 memcpy(&ioport->io2, io, sizeof(*io)); in sony_pic_read_possible_resource()
4387 dprintk("IO2 at 0x%.4x (0x%.2x)\n", ioport->io2.minimum, in sony_pic_read_possible_resource()
4388 ioport->io2.address_length); in sony_pic_read_possible_resource()
4402 resource->type); in sony_pic_read_possible_resource()
4414 return -EINVAL; in sony_pic_possible_resources()
4425 if (!device->status.enabled) in sony_pic_possible_resources()
4434 status = acpi_walk_resources(device->handle, METHOD_NAME__PRS, in sony_pic_possible_resources()
4438 result = -ENODEV; in sony_pic_possible_resources()
4449 acpi_status ret = acpi_evaluate_object(device->handle, "_DIS", NULL, in sony_pic_disable()
4453 return -ENXIO; in sony_pic_disable()
4490 return -EINVAL; in sony_pic_enable()
4495 return -ENOMEM; in sony_pic_enable()
4504 resource->res1.type = ACPI_RESOURCE_TYPE_IO; in sony_pic_enable()
4505 resource->res1.length = sizeof(struct acpi_resource); in sony_pic_enable()
4506 memcpy(&resource->res1.data.io, &ioport->io1, in sony_pic_enable()
4509 resource->res2.type = ACPI_RESOURCE_TYPE_IO; in sony_pic_enable()
4510 resource->res2.length = sizeof(struct acpi_resource); in sony_pic_enable()
4511 memcpy(&resource->res2.data.io, &ioport->io2, in sony_pic_enable()
4515 resource->res3.type = ACPI_RESOURCE_TYPE_IRQ; in sony_pic_enable()
4516 resource->res3.length = sizeof(struct acpi_resource); in sony_pic_enable()
4517 memcpy(&resource->res3.data.irq, &irq->irq, in sony_pic_enable()
4520 resource->res3.data.irq.shareable = ACPI_SHARED; in sony_pic_enable()
4522 resource->res4.type = ACPI_RESOURCE_TYPE_END_TAG; in sony_pic_enable()
4523 resource->res4.length = sizeof(struct acpi_resource); in sony_pic_enable()
4528 resource->res1.type = ACPI_RESOURCE_TYPE_IO; in sony_pic_enable()
4529 resource->res1.length = sizeof(struct acpi_resource); in sony_pic_enable()
4530 memcpy(&resource->res1.data.io, &ioport->io1, in sony_pic_enable()
4534 resource->res2.type = ACPI_RESOURCE_TYPE_IRQ; in sony_pic_enable()
4535 resource->res2.length = sizeof(struct acpi_resource); in sony_pic_enable()
4536 memcpy(&resource->res2.data.irq, &irq->irq, in sony_pic_enable()
4539 resource->res2.data.irq.shareable = ACPI_SHARED; in sony_pic_enable()
4541 resource->res3.type = ACPI_RESOURCE_TYPE_END_TAG; in sony_pic_enable()
4542 resource->res3.length = sizeof(struct acpi_resource); in sony_pic_enable()
4547 status = acpi_set_current_resources(device->handle, &buffer); in sony_pic_enable()
4552 result = -ENODEV; in sony_pic_enable()
4580 ev = inb_p(dev->cur_ioport->io1.minimum); in sony_pic_irq()
4581 if (dev->cur_ioport->io2.minimum) in sony_pic_irq()
4582 data_mask = inb_p(dev->cur_ioport->io2.minimum); in sony_pic_irq()
4584 data_mask = inb_p(dev->cur_ioport->io1.minimum + in sony_pic_irq()
4585 dev->evport_offset); in sony_pic_irq()
4588 ev, data_mask, dev->cur_ioport->io1.minimum, in sony_pic_irq()
4589 dev->evport_offset); in sony_pic_irq()
4594 for (i = 0; dev->event_types[i].mask; i++) { in sony_pic_irq()
4596 if ((data_mask & dev->event_types[i].data) != in sony_pic_irq()
4597 dev->event_types[i].data) in sony_pic_irq()
4600 if (!(mask & dev->event_types[i].mask)) in sony_pic_irq()
4603 for (j = 0; dev->event_types[i].events[j].event; j++) { in sony_pic_irq()
4604 if (ev == dev->event_types[i].events[j].data) { in sony_pic_irq()
4606 dev->event_types[i].events[j].event; in sony_pic_irq()
4617 if (dev->handle_irq && dev->handle_irq(data_mask, ev) == 0) in sony_pic_irq()
4621 ev, data_mask, dev->cur_ioport->io1.minimum, in sony_pic_irq()
4622 dev->evport_offset); in sony_pic_irq()
4646 free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev); in sony_pic_remove()
4647 release_region(spic_dev.cur_ioport->io1.minimum, in sony_pic_remove()
4648 spic_dev.cur_ioport->io1.address_length); in sony_pic_remove()
4649 if (spic_dev.cur_ioport->io2.minimum) in sony_pic_remove()
4650 release_region(spic_dev.cur_ioport->io2.minimum, in sony_pic_remove()
4651 spic_dev.cur_ioport->io2.address_length); in sony_pic_remove()
4658 sysfs_remove_group(&sony_pf_device->dev.kobj, &spic_attribute_group); in sony_pic_remove()
4662 list_del(&io->list); in sony_pic_remove()
4666 list_del(&irq->list); in sony_pic_remove()
4706 if (request_region(io->io1.minimum, io->io1.address_length, in sony_pic_add()
4709 io->io1.minimum, io->io1.maximum, in sony_pic_add()
4710 io->io1.address_length); in sony_pic_add()
4712 if (io->io2.minimum) { in sony_pic_add()
4713 if (request_region(io->io2.minimum, in sony_pic_add()
4714 io->io2.address_length, in sony_pic_add()
4717 io->io2.minimum, io->io2.maximum, in sony_pic_add()
4718 io->io2.address_length); in sony_pic_add()
4725 io->io2.minimum, io->io2.maximum, in sony_pic_add()
4726 io->io2.address_length); in sony_pic_add()
4727 release_region(io->io1.minimum, in sony_pic_add()
4728 io->io1.address_length); in sony_pic_add()
4739 result = -ENODEV; in sony_pic_add()
4745 if (!request_irq(irq->irq.interrupts[0], sony_pic_irq, in sony_pic_add()
4746 0, "sony-laptop", &spic_dev)) { in sony_pic_add()
4747 dprintk("IRQ: %d - triggering: %d - " in sony_pic_add()
4748 "polarity: %d - shr: %d\n", in sony_pic_add()
4749 irq->irq.interrupts[0], in sony_pic_add()
4750 irq->irq.triggering, in sony_pic_add()
4751 irq->irq.polarity, in sony_pic_add()
4752 irq->irq.shareable); in sony_pic_add()
4759 result = -ENODEV; in sony_pic_add()
4770 spic_dev.bluetooth_power = -1; in sony_pic_add()
4776 result = sysfs_create_group(&sony_pf_device->dev.kobj, &spic_attribute_group); in sony_pic_add()
4790 free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev); in sony_pic_add()
4793 release_region(spic_dev.cur_ioport->io1.minimum, in sony_pic_add()
4794 spic_dev.cur_ioport->io1.address_length); in sony_pic_add()
4795 if (spic_dev.cur_ioport->io2.minimum) in sony_pic_add()
4796 release_region(spic_dev.cur_ioport->io2.minimum, in sony_pic_add()
4797 spic_dev.cur_ioport->io2.address_length); in sony_pic_add()
4807 list_del(&io->list); in sony_pic_add()
4811 list_del(&irq->list); in sony_pic_add()
4824 return -ENXIO; in sony_pic_suspend()
4860 DMI_MATCH(DMI_PRODUCT_NAME, "PCG-"),
4867 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-"),