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 */
768 return -EINVAL; in sony_nc_buffer_call()
772 } else if (object->type == ACPI_TYPE_BUFFER) { in sony_nc_buffer_call()
773 len = MIN(buflen, object->buffer.length); in sony_nc_buffer_call()
775 memcpy(buffer, object->buffer.pointer, len); in sony_nc_buffer_call()
777 } else if (object->type == ACPI_TYPE_INTEGER) { in sony_nc_buffer_call()
778 len = MIN(buflen, sizeof(object->integer.value)); in sony_nc_buffer_call()
780 memcpy(buffer, &object->integer.value, len); in sony_nc_buffer_call()
783 pr_warn("Unexpected acpi_object: 0x%x\n", object->type); in sony_nc_buffer_call()
784 ret = -EINVAL; in sony_nc_buffer_call()
821 for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { in sony_nc_handles_show()
822 len += sysfs_emit_at(buffer, len, "0x%.4x ", handles->cap[i]); in sony_nc_handles_show()
835 return -ENOMEM; in sony_nc_handles_setup()
837 for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { in sony_nc_handles_setup()
844 handles->cap[i] = result; in sony_nc_handles_setup()
849 sysfs_attr_init(&handles->devattr.attr); in sony_nc_handles_setup()
850 handles->devattr.attr.name = "handles"; in sony_nc_handles_setup()
851 handles->devattr.attr.mode = S_IRUGO; in sony_nc_handles_setup()
852 handles->devattr.show = sony_nc_handles_show; in sony_nc_handles_setup()
855 if (device_create_file(&pd->dev, &handles->devattr)) { in sony_nc_handles_setup()
858 return -1; in sony_nc_handles_setup()
869 device_remove_file(&pd->dev, &handles->devattr); in sony_nc_handles_cleanup()
882 return -EINVAL; in sony_find_snc_handle()
885 if (handles->cap[i] == handle) { in sony_find_snc_handle()
892 return -EINVAL; in sony_find_snc_handle()
916 * backlight framework for which brightness values are 0-based.
922 return value - 1; in brightness_default_validate()
927 return -EINVAL; in brightness_default_validate()
939 return -EINVAL; in boolean_validate()
954 if (!*item->acpiget) in sony_nc_sysfs_show()
955 return -EIO; in sony_nc_sysfs_show()
957 ret = sony_nc_int_call(sony_nc_acpi_handle, *item->acpiget, NULL, in sony_nc_sysfs_show()
960 return -EIO; in sony_nc_sysfs_show()
962 if (item->validate) in sony_nc_sysfs_show()
963 value = item->validate(SNC_VALIDATE_OUT, value); in sony_nc_sysfs_show()
977 if (!item->acpiset) in sony_nc_sysfs_store()
978 return -EIO; in sony_nc_sysfs_store()
981 return -EINVAL; in sony_nc_sysfs_store()
984 return -EINVAL; in sony_nc_sysfs_store()
986 if (item->validate) in sony_nc_sysfs_store()
987 value = item->validate(SNC_VALIDATE_IN, value); in sony_nc_sysfs_store()
992 ret = sony_nc_int_call(sony_nc_acpi_handle, *item->acpiset, in sony_nc_sysfs_store()
995 return -EIO; in sony_nc_sysfs_store()
997 item->value = value; in sony_nc_sysfs_store()
998 item->valid = 1; in sony_nc_sysfs_store()
1017 int arg = bd->props.brightness + 1; in sony_backlight_update_status()
1027 /* brightness levels are 1-based, while backlight ones are 0-based */ in sony_backlight_get_brightness()
1028 return value - 1; in sony_backlight_get_brightness()
1037 sony_call_snc_handle(sdev->handle, sdev->cmd_base + 0x100, &result); in sony_nc_get_brightness_ng()
1039 return (result & 0xff) - sdev->offset; in sony_nc_get_brightness_ng()
1048 value = bd->props.brightness + sdev->offset; in sony_nc_update_status_ng()
1049 if (sony_call_snc_handle(sdev->handle, sdev->cmd_base | (value << 0x10), in sony_nc_update_status_ng()
1051 return -EIO; in sony_nc_update_status_ng()
1068 * New SNC-only Vaios event mapping to driver known keys
1141 int ret = -EINVAL; in sony_nc_hotkeys_decode()
1148 return -EINVAL; in sony_nc_hotkeys_decode()
1158 for (; key_event->data; key_event++) { in sony_nc_hotkeys_decode()
1159 if (key_event->data == result) { in sony_nc_hotkeys_decode()
1160 ret = key_event->event; in sony_nc_hotkeys_decode()
1165 if (!key_event->data) in sony_nc_hotkeys_decode()
1192 unsigned int offset = event - 0x90; in sony_nc_notify()
1194 if (offset >= ARRAY_SIZE(handles->cap)) { in sony_nc_notify()
1199 handle = handles->cap[offset]; in sony_nc_notify()
1220 * switch changes position or for battery in sony_nc_notify()
1269 acpi_bus_generate_netlink_event(sony_nc_acpi_device->pnp.device_class, in sony_nc_notify()
1270 dev_name(&sony_nc_acpi_device->dev), ev_type, real_ev); in sony_nc_notify()
1280 (char *)&info->name, info->param_count); in sony_walk_callback()
1300 for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { in sony_nc_function_setup()
1301 unsigned int handle = handles->cap[i]; in sony_nc_function_setup()
1332 pr_err("couldn't set up battery care function (%d)\n", in sony_nc_function_setup()
1345 pr_err("couldn't set up thermal profile function (%d)\n", in sony_nc_function_setup()
1383 pr_err("couldn't set up low battery function (%d)\n", in sony_nc_function_setup()
1434 for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { in sony_nc_function_cleanup()
1436 handle = handles->cap[i]; in sony_nc_function_cleanup()
1509 for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { in sony_nc_function_resume()
1510 unsigned int handle = handles->cap[i]; in sony_nc_function_resume()
1519 /* re-enable hotkeys */ in sony_nc_function_resume()
1523 /* re-enable hotkeys */ in sony_nc_function_resume()
1549 for (item = sony_nc_values; item->name; item++) { in sony_nc_resume()
1552 if (!item->valid) in sony_nc_resume()
1554 ret = sony_nc_int_call(sony_nc_acpi_handle, *item->acpiset, in sony_nc_resume()
1555 &item->value, NULL); in sony_nc_resume()
1617 name = "sony-wifi"; in sony_nc_setup_rfkill()
1621 name = "sony-bluetooth"; in sony_nc_setup_rfkill()
1625 name = "sony-wwan"; in sony_nc_setup_rfkill()
1629 name = "sony-wimax"; in sony_nc_setup_rfkill()
1632 return -EINVAL; in sony_nc_setup_rfkill()
1635 rfk = rfkill_alloc(name, &device->dev, type, in sony_nc_setup_rfkill()
1638 return -ENOMEM; in sony_nc_setup_rfkill()
1716 * 0x20 WWAN GPRS-EDGE in sony_nc_rfkill_setup()
1718 * 0x22 WWAN EV-DO in sony_nc_rfkill_setup()
1772 return -EINVAL; in __sony_nc_kbd_backlight_mode_set()
1774 if (sony_call_snc_handle(kbdbl_ctl->handle, in __sony_nc_kbd_backlight_mode_set()
1775 (value << 0x10) | (kbdbl_ctl->base), &result)) in __sony_nc_kbd_backlight_mode_set()
1776 return -EIO; in __sony_nc_kbd_backlight_mode_set()
1780 sony_call_snc_handle(kbdbl_ctl->handle, in __sony_nc_kbd_backlight_mode_set()
1781 (value << 0x0f) | (kbdbl_ctl->base + 0x100), in __sony_nc_kbd_backlight_mode_set()
1784 kbdbl_ctl->mode = value; in __sony_nc_kbd_backlight_mode_set()
1797 return -EINVAL; in sony_nc_kbd_backlight_mode_store()
1800 return -EINVAL; in sony_nc_kbd_backlight_mode_store()
1812 return sysfs_emit(buffer, "%d\n", kbdbl_ctl->mode); in sony_nc_kbd_backlight_mode_show()
1820 return -EINVAL; in __sony_nc_kbd_backlight_timeout_set()
1822 if (sony_call_snc_handle(kbdbl_ctl->handle, (value << 0x10) | in __sony_nc_kbd_backlight_timeout_set()
1823 (kbdbl_ctl->base + 0x200), &result)) in __sony_nc_kbd_backlight_timeout_set()
1824 return -EIO; in __sony_nc_kbd_backlight_timeout_set()
1826 kbdbl_ctl->timeout = value; in __sony_nc_kbd_backlight_timeout_set()
1839 return -EINVAL; in sony_nc_kbd_backlight_timeout_store()
1842 return -EINVAL; in sony_nc_kbd_backlight_timeout_store()
1854 return sysfs_emit(buffer, "%d\n", kbdbl_ctl->timeout); in sony_nc_kbd_backlight_timeout_show()
1867 handle, kbdbl_ctl->handle); in sony_nc_kbd_backlight_setup()
1868 return -EBUSY; in sony_nc_kbd_backlight_setup()
1908 return -ENOMEM; in sony_nc_kbd_backlight_setup()
1910 kbdbl_ctl->mode = kbd_backlight; in sony_nc_kbd_backlight_setup()
1911 kbdbl_ctl->timeout = kbd_backlight_timeout; in sony_nc_kbd_backlight_setup()
1912 kbdbl_ctl->handle = handle; in sony_nc_kbd_backlight_setup()
1913 kbdbl_ctl->base = ctl_base; in sony_nc_kbd_backlight_setup()
1915 kbdbl_ctl->has_timeout = handle != 0x0153; in sony_nc_kbd_backlight_setup()
1917 sysfs_attr_init(&kbdbl_ctl->mode_attr.attr); in sony_nc_kbd_backlight_setup()
1918 kbdbl_ctl->mode_attr.attr.name = "kbd_backlight"; in sony_nc_kbd_backlight_setup()
1919 kbdbl_ctl->mode_attr.attr.mode = S_IRUGO | S_IWUSR; in sony_nc_kbd_backlight_setup()
1920 kbdbl_ctl->mode_attr.show = sony_nc_kbd_backlight_mode_show; in sony_nc_kbd_backlight_setup()
1921 kbdbl_ctl->mode_attr.store = sony_nc_kbd_backlight_mode_store; in sony_nc_kbd_backlight_setup()
1923 ret = device_create_file(&pd->dev, &kbdbl_ctl->mode_attr); in sony_nc_kbd_backlight_setup()
1927 __sony_nc_kbd_backlight_mode_set(kbdbl_ctl->mode); in sony_nc_kbd_backlight_setup()
1929 if (kbdbl_ctl->has_timeout) { in sony_nc_kbd_backlight_setup()
1930 sysfs_attr_init(&kbdbl_ctl->timeout_attr.attr); in sony_nc_kbd_backlight_setup()
1931 kbdbl_ctl->timeout_attr.attr.name = "kbd_backlight_timeout"; in sony_nc_kbd_backlight_setup()
1932 kbdbl_ctl->timeout_attr.attr.mode = S_IRUGO | S_IWUSR; in sony_nc_kbd_backlight_setup()
1933 kbdbl_ctl->timeout_attr.show = in sony_nc_kbd_backlight_setup()
1935 kbdbl_ctl->timeout_attr.store = in sony_nc_kbd_backlight_setup()
1938 ret = device_create_file(&pd->dev, &kbdbl_ctl->timeout_attr); in sony_nc_kbd_backlight_setup()
1942 __sony_nc_kbd_backlight_timeout_set(kbdbl_ctl->timeout); in sony_nc_kbd_backlight_setup()
1949 device_remove_file(&pd->dev, &kbdbl_ctl->mode_attr); in sony_nc_kbd_backlight_setup()
1959 if (kbdbl_ctl && handle == kbdbl_ctl->handle) { in sony_nc_kbd_backlight_cleanup()
1960 device_remove_file(&pd->dev, &kbdbl_ctl->mode_attr); in sony_nc_kbd_backlight_cleanup()
1961 if (kbdbl_ctl->has_timeout) in sony_nc_kbd_backlight_cleanup()
1962 device_remove_file(&pd->dev, &kbdbl_ctl->timeout_attr); in sony_nc_kbd_backlight_cleanup()
1982 return -EINVAL; in sony_nc_battery_care_limit_store()
1985 return -EINVAL; in sony_nc_battery_care_limit_store()
1988 * 00 - none in sony_nc_battery_care_limit_store()
1989 * 01 - 80% in sony_nc_battery_care_limit_store()
1990 * 10 - 50% in sony_nc_battery_care_limit_store()
1991 * 11 - 100% in sony_nc_battery_care_limit_store()
1994 * bit 1: 1 tell to store the battery limit (see bits 6,7) too in sony_nc_battery_care_limit_store()
1997 * bits 6,7: store the limit into the battery in sony_nc_battery_care_limit_store()
2012 return -EINVAL; in sony_nc_battery_care_limit_store()
2015 * handle 0x0115 should allow storing on battery too; in sony_nc_battery_care_limit_store()
2017 * handle 0x013f, same as 0x0136 but no storing on the battery in sony_nc_battery_care_limit_store()
2019 if (bcare_ctl->handle != 0x013f) in sony_nc_battery_care_limit_store()
2025 if (sony_call_snc_handle(bcare_ctl->handle, cmd | 0x0100, &result)) in sony_nc_battery_care_limit_store()
2026 return -EIO; in sony_nc_battery_care_limit_store()
2036 if (sony_call_snc_handle(bcare_ctl->handle, 0x0000, &result)) in sony_nc_battery_care_limit_show()
2037 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()
2076 return -ENOMEM; in sony_nc_battery_care_setup()
2078 bcare_ctl->handle = handle; in sony_nc_battery_care_setup()
2080 sysfs_attr_init(&bcare_ctl->attrs[0].attr); in sony_nc_battery_care_setup()
2081 bcare_ctl->attrs[0].attr.name = "battery_care_limiter"; in sony_nc_battery_care_setup()
2082 bcare_ctl->attrs[0].attr.mode = S_IRUGO | S_IWUSR; in sony_nc_battery_care_setup()
2083 bcare_ctl->attrs[0].show = sony_nc_battery_care_limit_show; in sony_nc_battery_care_setup()
2084 bcare_ctl->attrs[0].store = sony_nc_battery_care_limit_store; in sony_nc_battery_care_setup()
2086 ret = device_create_file(&pd->dev, &bcare_ctl->attrs[0]); in sony_nc_battery_care_setup()
2094 sysfs_attr_init(&bcare_ctl->attrs[1].attr); in sony_nc_battery_care_setup()
2095 bcare_ctl->attrs[1].attr.name = "battery_care_health"; in sony_nc_battery_care_setup()
2096 bcare_ctl->attrs[1].attr.mode = S_IRUGO; in sony_nc_battery_care_setup()
2097 bcare_ctl->attrs[1].show = sony_nc_battery_care_health_show; in sony_nc_battery_care_setup()
2099 ret = device_create_file(&pd->dev, &bcare_ctl->attrs[1]); in sony_nc_battery_care_setup()
2106 device_remove_file(&pd->dev, &bcare_ctl->attrs[0]); in sony_nc_battery_care_setup()
2118 device_remove_file(&pd->dev, &bcare_ctl->attrs[0]); in sony_nc_battery_care_cleanup()
2119 if (bcare_ctl->handle != 0x0115) in sony_nc_battery_care_cleanup()
2120 device_remove_file(&pd->dev, &bcare_ctl->attrs[1]); in sony_nc_battery_care_cleanup()
2146 /* the thermal profile seems to be a two bit bitmask: in sony_nc_thermal_mode_set()
2147 * lsb -> silent in sony_nc_thermal_mode_set()
2148 * msb -> performance in sony_nc_thermal_mode_set()
2152 if ((mode && !(th_handle->profiles & mode)) || mode >= THM_PROFILE_MAX) in sony_nc_thermal_mode_set()
2153 return -EINVAL; in sony_nc_thermal_mode_set()
2156 return -EIO; in sony_nc_thermal_mode_set()
2158 th_handle->mode = mode; in sony_nc_thermal_mode_set()
2168 return -EIO; in sony_nc_thermal_mode_get()
2180 if (!cnt || (th_handle->profiles & cnt)) in sony_nc_thermal_profiles_show()
2196 return -EINVAL; in sony_nc_thermal_mode_store()
2199 if (buffer[len - 1] == '\n') in sony_nc_thermal_mode_store()
2200 len--; in sony_nc_thermal_mode_store()
2207 return -EIO; in sony_nc_thermal_mode_store()
2228 return -ENOMEM; in sony_nc_thermal_setup()
2230 ret = sony_call_snc_handle(0x0122, 0x0000, &th_handle->profiles); in sony_nc_thermal_setup()
2238 pr_warn("couldn't to read the current thermal profile"); in sony_nc_thermal_setup()
2241 th_handle->mode = ret; in sony_nc_thermal_setup()
2243 sysfs_attr_init(&th_handle->profiles_attr.attr); in sony_nc_thermal_setup()
2244 th_handle->profiles_attr.attr.name = "thermal_profiles"; in sony_nc_thermal_setup()
2245 th_handle->profiles_attr.attr.mode = S_IRUGO; in sony_nc_thermal_setup()
2246 th_handle->profiles_attr.show = sony_nc_thermal_profiles_show; in sony_nc_thermal_setup()
2248 sysfs_attr_init(&th_handle->mode_attr.attr); in sony_nc_thermal_setup()
2249 th_handle->mode_attr.attr.name = "thermal_control"; in sony_nc_thermal_setup()
2250 th_handle->mode_attr.attr.mode = S_IRUGO | S_IWUSR; in sony_nc_thermal_setup()
2251 th_handle->mode_attr.show = sony_nc_thermal_mode_show; in sony_nc_thermal_setup()
2252 th_handle->mode_attr.store = sony_nc_thermal_mode_store; in sony_nc_thermal_setup()
2254 ret = device_create_file(&pd->dev, &th_handle->profiles_attr); in sony_nc_thermal_setup()
2258 ret = device_create_file(&pd->dev, &th_handle->mode_attr); in sony_nc_thermal_setup()
2265 device_remove_file(&pd->dev, &th_handle->profiles_attr); in sony_nc_thermal_setup()
2275 device_remove_file(&pd->dev, &th_handle->profiles_attr); in sony_nc_thermal_cleanup()
2276 device_remove_file(&pd->dev, &th_handle->mode_attr); in sony_nc_thermal_cleanup()
2292 if (status != th_handle->mode) in sony_nc_thermal_resume()
2293 sony_nc_thermal_mode_set(th_handle->mode); in sony_nc_thermal_resume()
2317 return -EINVAL; in sony_nc_lid_resume_store()
2320 return -EINVAL; in sony_nc_lid_resume_store()
2323 * +--------------+ in sony_nc_lid_resume_store()
2325 * +--------------+ in sony_nc_lid_resume_store()
2329 if (&lid_ctl->attrs[pos].attr == &attr->attr) in sony_nc_lid_resume_store()
2334 return -EINVAL; in sony_nc_lid_resume_store()
2337 value = lid_ctl->status | (1 << pos); in sony_nc_lid_resume_store()
2339 value = lid_ctl->status & ~(1 << pos); in sony_nc_lid_resume_store()
2341 if (sony_call_snc_handle(lid_ctl->handle, value << 0x10 | 0x0100, in sony_nc_lid_resume_store()
2343 return -EIO; in sony_nc_lid_resume_store()
2345 lid_ctl->status = value; in sony_nc_lid_resume_store()
2357 if (&lid_ctl->attrs[pos].attr == &attr->attr) in sony_nc_lid_resume_show()
2359 (lid_ctl->status >> pos) & 0x01); in sony_nc_lid_resume_show()
2362 return -EINVAL; in sony_nc_lid_resume_show()
2372 return -EIO; in sony_nc_lid_resume_setup()
2376 return -ENOMEM; in sony_nc_lid_resume_setup()
2378 lid_ctl->status = result & 0x7; in sony_nc_lid_resume_setup()
2379 lid_ctl->handle = handle; in sony_nc_lid_resume_setup()
2381 sysfs_attr_init(&lid_ctl->attrs[0].attr); in sony_nc_lid_resume_setup()
2382 lid_ctl->attrs[LID_RESUME_S5].attr.name = "lid_resume_S5"; in sony_nc_lid_resume_setup()
2383 lid_ctl->attrs[LID_RESUME_S5].attr.mode = S_IRUGO | S_IWUSR; in sony_nc_lid_resume_setup()
2384 lid_ctl->attrs[LID_RESUME_S5].show = sony_nc_lid_resume_show; in sony_nc_lid_resume_setup()
2385 lid_ctl->attrs[LID_RESUME_S5].store = sony_nc_lid_resume_store; in sony_nc_lid_resume_setup()
2388 sysfs_attr_init(&lid_ctl->attrs[1].attr); in sony_nc_lid_resume_setup()
2389 lid_ctl->attrs[LID_RESUME_S4].attr.name = "lid_resume_S4"; in sony_nc_lid_resume_setup()
2390 lid_ctl->attrs[LID_RESUME_S4].attr.mode = S_IRUGO | S_IWUSR; in sony_nc_lid_resume_setup()
2391 lid_ctl->attrs[LID_RESUME_S4].show = sony_nc_lid_resume_show; in sony_nc_lid_resume_setup()
2392 lid_ctl->attrs[LID_RESUME_S4].store = sony_nc_lid_resume_store; in sony_nc_lid_resume_setup()
2394 sysfs_attr_init(&lid_ctl->attrs[2].attr); in sony_nc_lid_resume_setup()
2395 lid_ctl->attrs[LID_RESUME_S3].attr.name = "lid_resume_S3"; in sony_nc_lid_resume_setup()
2396 lid_ctl->attrs[LID_RESUME_S3].attr.mode = S_IRUGO | S_IWUSR; in sony_nc_lid_resume_setup()
2397 lid_ctl->attrs[LID_RESUME_S3].show = sony_nc_lid_resume_show; in sony_nc_lid_resume_setup()
2398 lid_ctl->attrs[LID_RESUME_S3].store = sony_nc_lid_resume_store; in sony_nc_lid_resume_setup()
2401 lid_ctl->attrs[i].attr.name; i++) { in sony_nc_lid_resume_setup()
2402 result = device_create_file(&pd->dev, &lid_ctl->attrs[i]); in sony_nc_lid_resume_setup()
2410 for (i--; i >= 0; i--) in sony_nc_lid_resume_setup()
2411 device_remove_file(&pd->dev, &lid_ctl->attrs[i]); in sony_nc_lid_resume_setup()
2425 if (!lid_ctl->attrs[i].attr.name) in sony_nc_lid_resume_cleanup()
2428 device_remove_file(&pd->dev, &lid_ctl->attrs[i]); in sony_nc_lid_resume_cleanup()
2453 if (sony_call_snc_handle(gfxs_ctl->handle, in __sony_nc_gfx_switch_status_get()
2454 gfxs_ctl->handle == 0x015B ? 0x0000 : 0x0100, in __sony_nc_gfx_switch_status_get()
2456 return -EIO; in __sony_nc_gfx_switch_status_get()
2458 switch (gfxs_ctl->handle) { in __sony_nc_gfx_switch_status_get()
2478 return -EINVAL; in __sony_nc_gfx_switch_status_get()
2503 return -ENOMEM; in sony_nc_gfx_switch_setup()
2505 gfxs_ctl->handle = handle; in sony_nc_gfx_switch_setup()
2507 sysfs_attr_init(&gfxs_ctl->attr.attr); in sony_nc_gfx_switch_setup()
2508 gfxs_ctl->attr.attr.name = "gfx_switch_status"; in sony_nc_gfx_switch_setup()
2509 gfxs_ctl->attr.attr.mode = S_IRUGO; in sony_nc_gfx_switch_setup()
2510 gfxs_ctl->attr.show = sony_nc_gfx_switch_status_show; in sony_nc_gfx_switch_setup()
2512 result = device_create_file(&pd->dev, &gfxs_ctl->attr); in sony_nc_gfx_switch_setup()
2528 device_remove_file(&pd->dev, &gfxs_ctl->attr); in sony_nc_gfx_switch_cleanup()
2546 return -EINVAL; in sony_nc_highspeed_charging_store()
2549 return -EINVAL; in sony_nc_highspeed_charging_store()
2552 return -EIO; in sony_nc_highspeed_charging_store()
2563 return -EIO; in sony_nc_highspeed_charging_show()
2582 return -ENOMEM; in sony_nc_highspeed_charging_setup()
2584 sysfs_attr_init(&hsc_handle->attr); in sony_nc_highspeed_charging_setup()
2585 hsc_handle->attr.name = "battery_highspeed_charging"; in sony_nc_highspeed_charging_setup()
2586 hsc_handle->attr.mode = S_IRUGO | S_IWUSR; in sony_nc_highspeed_charging_setup()
2587 hsc_handle->show = sony_nc_highspeed_charging_show; in sony_nc_highspeed_charging_setup()
2588 hsc_handle->store = sony_nc_highspeed_charging_store; in sony_nc_highspeed_charging_setup()
2590 result = device_create_file(&pd->dev, hsc_handle); in sony_nc_highspeed_charging_setup()
2603 device_remove_file(&pd->dev, hsc_handle); in sony_nc_highspeed_charging_cleanup()
2609 /* low battery function */
2620 return -EINVAL; in sony_nc_lowbatt_store()
2623 return -EINVAL; in sony_nc_lowbatt_store()
2626 return -EIO; in sony_nc_lowbatt_store()
2637 return -EIO; in sony_nc_lowbatt_show()
2648 return -ENOMEM; in sony_nc_lowbatt_setup()
2650 sysfs_attr_init(&lowbatt_handle->attr); in sony_nc_lowbatt_setup()
2651 lowbatt_handle->attr.name = "lowbatt_hibernate"; in sony_nc_lowbatt_setup()
2652 lowbatt_handle->attr.mode = S_IRUGO | S_IWUSR; in sony_nc_lowbatt_setup()
2653 lowbatt_handle->show = sony_nc_lowbatt_show; in sony_nc_lowbatt_setup()
2654 lowbatt_handle->store = sony_nc_lowbatt_store; in sony_nc_lowbatt_setup()
2656 result = device_create_file(&pd->dev, lowbatt_handle); in sony_nc_lowbatt_setup()
2669 device_remove_file(&pd->dev, lowbatt_handle); in sony_nc_lowbatt_cleanup()
2686 return -EINVAL; in sony_nc_hsfan_store()
2689 return -EINVAL; in sony_nc_hsfan_store()
2692 return -EIO; in sony_nc_hsfan_store()
2703 return -EIO; in sony_nc_hsfan_show()
2714 return -EIO; in sony_nc_fanspeed_show()
2725 return -ENOMEM; in sony_nc_fanspeed_setup()
2729 result = -ENOMEM; in sony_nc_fanspeed_setup()
2733 sysfs_attr_init(&fan_handle->attr); in sony_nc_fanspeed_setup()
2734 fan_handle->attr.name = "fanspeed"; in sony_nc_fanspeed_setup()
2735 fan_handle->attr.mode = S_IRUGO; in sony_nc_fanspeed_setup()
2736 fan_handle->show = sony_nc_fanspeed_show; in sony_nc_fanspeed_setup()
2737 fan_handle->store = NULL; in sony_nc_fanspeed_setup()
2739 sysfs_attr_init(&hsf_handle->attr); in sony_nc_fanspeed_setup()
2740 hsf_handle->attr.name = "fan_forced"; in sony_nc_fanspeed_setup()
2741 hsf_handle->attr.mode = S_IRUGO | S_IWUSR; in sony_nc_fanspeed_setup()
2742 hsf_handle->show = sony_nc_hsfan_show; in sony_nc_fanspeed_setup()
2743 hsf_handle->store = sony_nc_hsfan_store; in sony_nc_fanspeed_setup()
2745 result = device_create_file(&pd->dev, fan_handle); in sony_nc_fanspeed_setup()
2749 result = device_create_file(&pd->dev, hsf_handle); in sony_nc_fanspeed_setup()
2756 device_remove_file(&pd->dev, fan_handle); in sony_nc_fanspeed_setup()
2771 device_remove_file(&pd->dev, fan_handle); in sony_nc_fanspeed_cleanup()
2776 device_remove_file(&pd->dev, hsf_handle); in sony_nc_fanspeed_cleanup()
2793 return -EINVAL; in sony_nc_usb_charge_store()
2796 return -EINVAL; in sony_nc_usb_charge_store()
2799 return -EIO; in sony_nc_usb_charge_store()
2810 return -EIO; in sony_nc_usb_charge_show()
2829 return -ENOMEM; in sony_nc_usb_charge_setup()
2831 sysfs_attr_init(&uc_handle->attr); in sony_nc_usb_charge_setup()
2832 uc_handle->attr.name = "usb_charge"; in sony_nc_usb_charge_setup()
2833 uc_handle->attr.mode = S_IRUGO | S_IWUSR; in sony_nc_usb_charge_setup()
2834 uc_handle->show = sony_nc_usb_charge_show; in sony_nc_usb_charge_setup()
2835 uc_handle->store = sony_nc_usb_charge_store; in sony_nc_usb_charge_setup()
2837 result = device_create_file(&pd->dev, uc_handle); in sony_nc_usb_charge_setup()
2850 device_remove_file(&pd->dev, uc_handle); in sony_nc_usb_charge_cleanup()
2865 return -EIO; in sony_nc_panelid_show()
2876 return -ENOMEM; in sony_nc_panelid_setup()
2878 sysfs_attr_init(&panel_handle->attr); in sony_nc_panelid_setup()
2879 panel_handle->attr.name = "panel_id"; in sony_nc_panelid_setup()
2880 panel_handle->attr.mode = S_IRUGO; in sony_nc_panelid_setup()
2881 panel_handle->show = sony_nc_panelid_show; in sony_nc_panelid_setup()
2882 panel_handle->store = NULL; in sony_nc_panelid_setup()
2884 result = device_create_file(&pd->dev, panel_handle); in sony_nc_panelid_setup()
2897 device_remove_file(&pd->dev, panel_handle); in sony_nc_panelid_cleanup()
2914 return -EINVAL; in sony_nc_smart_conn_store()
2917 return -EINVAL; in sony_nc_smart_conn_store()
2920 return -EIO; in sony_nc_smart_conn_store()
2931 return -ENOMEM; in sony_nc_smart_conn_setup()
2933 sysfs_attr_init(&sc_handle->attr); in sony_nc_smart_conn_setup()
2934 sc_handle->attr.name = "smart_connect"; in sony_nc_smart_conn_setup()
2935 sc_handle->attr.mode = S_IWUSR; in sony_nc_smart_conn_setup()
2936 sc_handle->show = NULL; in sony_nc_smart_conn_setup()
2937 sc_handle->store = sony_nc_smart_conn_store; in sony_nc_smart_conn_setup()
2939 result = device_create_file(&pd->dev, sc_handle); in sony_nc_smart_conn_setup()
2952 device_remove_file(&pd->dev, sc_handle); in sony_nc_smart_conn_cleanup()
2972 return -EINVAL; in sony_nc_touchpad_store()
2975 return -EINVAL; in sony_nc_touchpad_store()
2980 if (sony_call_snc_handle(tp_ctl->handle, in sony_nc_touchpad_store()
2982 return -EIO; in sony_nc_touchpad_store()
2992 if (sony_call_snc_handle(tp_ctl->handle, 0x000, &result)) in sony_nc_touchpad_show()
2993 return -EINVAL; in sony_nc_touchpad_show()
3005 return -ENOMEM; in sony_nc_touchpad_setup()
3007 tp_ctl->handle = handle; in sony_nc_touchpad_setup()
3009 sysfs_attr_init(&tp_ctl->attr.attr); in sony_nc_touchpad_setup()
3010 tp_ctl->attr.attr.name = "touchpad"; in sony_nc_touchpad_setup()
3011 tp_ctl->attr.attr.mode = S_IRUGO | S_IWUSR; in sony_nc_touchpad_setup()
3012 tp_ctl->attr.show = sony_nc_touchpad_show; in sony_nc_touchpad_setup()
3013 tp_ctl->attr.store = sony_nc_touchpad_store; in sony_nc_touchpad_setup()
3015 ret = device_create_file(&pd->dev, &tp_ctl->attr); in sony_nc_touchpad_setup()
3027 device_remove_file(&pd->dev, &tp_ctl->attr); in sony_nc_touchpad_cleanup()
3042 props->handle = handle; in sony_nc_backlight_ng_read_limits()
3043 props->offset = 0; in sony_nc_backlight_ng_read_limits()
3044 props->maxlvl = 0xff; in sony_nc_backlight_ng_read_limits()
3084 props->offset = min; in sony_nc_backlight_ng_read_limits()
3085 props->maxlvl = max; in sony_nc_backlight_ng_read_limits()
3086 dprintk("Brightness levels: min=%d max=%d\n", props->offset, in sony_nc_backlight_ng_read_limits()
3087 props->maxlvl); in sony_nc_backlight_ng_read_limits()
3100 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3106 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3112 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3118 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3124 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3128 max_brightness = SONY_MAX_BRIGHTNESS - 1; in sony_nc_backlight_setup()
3144 sony_bl_props.dev->props.brightness = in sony_nc_backlight_setup()
3145 ops->get_brightness(sony_bl_props.dev); in sony_nc_backlight_setup()
3162 sony_nc_acpi_handle = device->handle; in sony_nc_add()
3167 if (!result && !device->status.present) { in sony_nc_add()
3169 result = -ENODEV; in sony_nc_add()
3183 result = -ENODEV; in sony_nc_add()
3212 for (item = sony_nc_values; item->name; ++item) { in sony_nc_add()
3214 if (!debug && item->debug) in sony_nc_add()
3218 for (; item->acpiget && *item->acpiget; ++item->acpiget) { in sony_nc_add()
3220 *item->acpiget)) { in sony_nc_add()
3222 item->name, *item->acpiget); in sony_nc_add()
3223 item->devattr.attr.mode |= S_IRUGO; in sony_nc_add()
3229 for (; item->acpiset && *item->acpiset; ++item->acpiset) { in sony_nc_add()
3231 *item->acpiset)) { in sony_nc_add()
3233 item->name, *item->acpiset); in sony_nc_add()
3234 item->devattr.attr.mode |= S_IWUSR; in sony_nc_add()
3239 if (item->devattr.attr.mode != 0) { in sony_nc_add()
3241 device_create_file(&sony_pf_device->dev, in sony_nc_add()
3242 &item->devattr); in sony_nc_add()
3252 for (item = sony_nc_values; item->name; ++item) { in sony_nc_add()
3253 device_remove_file(&sony_pf_device->dev, &item->devattr); in sony_nc_add()
3278 for (item = sony_nc_values; item->name; ++item) { in sony_nc_remove()
3279 device_remove_file(&sony_pf_device->dev, &item->devattr); in sony_nc_remove()
3517 /* The set of possible battery events */
3587 while (--n && (command)) \
3598 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, in sony_pic_call1()
3600 outb(dev, spic_dev.cur_ioport->io1.minimum + 4); in sony_pic_call1()
3601 v1 = inb_p(spic_dev.cur_ioport->io1.minimum + 4); in sony_pic_call1()
3602 v2 = inb_p(spic_dev.cur_ioport->io1.minimum); in sony_pic_call1()
3611 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, in sony_pic_call2()
3613 outb(dev, spic_dev.cur_ioport->io1.minimum + 4); in sony_pic_call2()
3614 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, in sony_pic_call2()
3616 outb(fn, spic_dev.cur_ioport->io1.minimum); in sony_pic_call2()
3617 v1 = inb_p(spic_dev.cur_ioport->io1.minimum); in sony_pic_call2()
3618 dprintk("sony_pic_call2(0x%.2x - 0x%.2x): 0x%.4x\n", dev, fn, v1); in sony_pic_call2()
3626 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG); in sony_pic_call3()
3627 outb(dev, spic_dev.cur_ioport->io1.minimum + 4); in sony_pic_call3()
3628 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG); in sony_pic_call3()
3629 outb(fn, spic_dev.cur_ioport->io1.minimum); 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(v, spic_dev.cur_ioport->io1.minimum); in sony_pic_call3()
3632 v1 = inb_p(spic_dev.cur_ioport->io1.minimum); in sony_pic_call3()
3633 dprintk("sony_pic_call3(0x%.2x - 0x%.2x - 0x%.2x): 0x%.4x\n", in sony_pic_call3()
3647 * - 0x5c and 0x5f requires 0xA0 in type3_handle_irq()
3648 * - 0x61 requires 0xB3 in type3_handle_irq()
3667 dev->model = SONYPI_DEVICE_TYPE1; in sony_pic_detect_device_type()
3668 dev->evport_offset = SONYPI_TYPE1_OFFSET; in sony_pic_detect_device_type()
3669 dev->event_types = type1_events; in sony_pic_detect_device_type()
3676 dev->model = SONYPI_DEVICE_TYPE2; in sony_pic_detect_device_type()
3677 dev->evport_offset = SONYPI_TYPE2_OFFSET; in sony_pic_detect_device_type()
3678 dev->event_types = type2_events; in sony_pic_detect_device_type()
3685 dev->model = SONYPI_DEVICE_TYPE3; in sony_pic_detect_device_type()
3686 dev->handle_irq = type3_handle_irq; in sony_pic_detect_device_type()
3687 dev->evport_offset = SONYPI_TYPE3_OFFSET; in sony_pic_detect_device_type()
3688 dev->event_types = type3_events; in sony_pic_detect_device_type()
3695 dev->model = SONYPI_DEVICE_TYPE3; in sony_pic_detect_device_type()
3696 dev->handle_irq = type3_handle_irq; in sony_pic_detect_device_type()
3697 dev->evport_offset = SONYPI_TYPE3_OFFSET; in sony_pic_detect_device_type()
3698 dev->event_types = type3_events; in sony_pic_detect_device_type()
3705 dev->model = SONYPI_DEVICE_TYPE3; in sony_pic_detect_device_type()
3706 dev->handle_irq = type3_handle_irq; in sony_pic_detect_device_type()
3707 dev->evport_offset = SONYPI_TYPE3_OFFSET; in sony_pic_detect_device_type()
3708 dev->event_types = type3_events; in sony_pic_detect_device_type()
3713 dev->model = SONYPI_DEVICE_TYPE2; in sony_pic_detect_device_type()
3714 dev->evport_offset = SONYPI_TYPE2_OFFSET; in sony_pic_detect_device_type()
3715 dev->event_types = type2_events; in sony_pic_detect_device_type()
3721 dev->model == SONYPI_DEVICE_TYPE1 ? 1 : in sony_pic_detect_device_type()
3722 dev->model == SONYPI_DEVICE_TYPE2 ? 2 : 3); in sony_pic_detect_device_type()
3769 return -ENODEV; in __sony_pic_camera_off()
3789 return -ENODEV; in __sony_pic_camera_on()
3795 for (j = 5; j > 0; j--) { in __sony_pic_camera_on()
3801 for (i = 400; i > 0; i--) { in __sony_pic_camera_on()
3812 return -ENODEV; in __sony_pic_camera_on()
3827 return -EIO; in sony_pic_camera_command()
3892 return -EINVAL; in sony_pic_wwanpower_store()
3895 return -EINVAL; in sony_pic_wwanpower_store()
3931 return -EINVAL; in sony_pic_bluetoothpower_store()
3934 return -EINVAL; in sony_pic_bluetoothpower_store()
3972 return -EINVAL; in sony_pic_fanspeed_store()
3975 return -EINVAL; in sony_pic_fanspeed_store()
3978 return -EIO; in sony_pic_fanspeed_store()
3988 return -EIO; in sony_pic_fanspeed_show()
4016 /* battery / brightness / temperature addresses */
4075 (file->f_flags & O_NONBLOCK)) in sonypi_misc_read()
4076 return -EAGAIN; in sonypi_misc_read()
4087 return -EFAULT; in sonypi_misc_read()
4111 return -1; in ec_read16()
4113 return -1; in ec_read16()
4131 ret = -EIO; in sonypi_misc_ioctl()
4136 ret = -EIO; in sonypi_misc_ioctl()
4139 val8 = ((value & 0xff) - 1) << 5; in sonypi_misc_ioctl()
4141 ret = -EFAULT; in sonypi_misc_ioctl()
4145 ret = -EIO; in sonypi_misc_ioctl()
4149 ret = -EFAULT; in sonypi_misc_ioctl()
4155 ret = -EIO; in sonypi_misc_ioctl()
4159 sony_bl_props.dev->props.brightness = in sonypi_misc_ioctl()
4164 ret = -EIO; in sonypi_misc_ioctl()
4168 ret = -EFAULT; in sonypi_misc_ioctl()
4172 ret = -EIO; in sonypi_misc_ioctl()
4176 ret = -EFAULT; in sonypi_misc_ioctl()
4180 ret = -EIO; in sonypi_misc_ioctl()
4184 ret = -EFAULT; in sonypi_misc_ioctl()
4188 ret = -EIO; in sonypi_misc_ioctl()
4192 ret = -EFAULT; in sonypi_misc_ioctl()
4196 ret = -EIO; in sonypi_misc_ioctl()
4201 ret = -EFAULT; in sonypi_misc_ioctl()
4206 ret = -EFAULT; in sonypi_misc_ioctl()
4210 ret = -EFAULT; in sonypi_misc_ioctl()
4218 ret = -EIO; in sonypi_misc_ioctl()
4222 ret = -EFAULT; in sonypi_misc_ioctl()
4226 ret = -EFAULT; in sonypi_misc_ioctl()
4230 ret = -EIO; in sonypi_misc_ioctl()
4235 ret = -EIO; in sonypi_misc_ioctl()
4239 ret = -EFAULT; in sonypi_misc_ioctl()
4242 ret = -EINVAL; in sonypi_misc_ioctl()
4287 if (minor != -1) in sonypi_compat_init()
4294 if (minor == -1) in sonypi_compat_init()
4325 switch (resource->type) { in sony_pic_read_possible_resource()
4333 list_add(&ioport->list, &dev->ioports); in sony_pic_read_possible_resource()
4343 struct acpi_resource_irq *p = &resource->data.irq; in sony_pic_read_possible_resource()
4345 if (!p->interrupt_count) { in sony_pic_read_possible_resource()
4353 for (i = 0; i < p->interrupt_count; i++) { in sony_pic_read_possible_resource()
4354 if (!p->interrupts[i]) { in sony_pic_read_possible_resource()
4356 p->interrupts[i]); in sony_pic_read_possible_resource()
4364 list_add(&interrupt->list, &dev->interrupts); in sony_pic_read_possible_resource()
4365 interrupt->irq.triggering = p->triggering; in sony_pic_read_possible_resource()
4366 interrupt->irq.polarity = p->polarity; in sony_pic_read_possible_resource()
4367 interrupt->irq.shareable = p->shareable; in sony_pic_read_possible_resource()
4368 interrupt->irq.interrupt_count = 1; in sony_pic_read_possible_resource()
4369 interrupt->irq.interrupts[0] = p->interrupts[i]; in sony_pic_read_possible_resource()
4375 struct acpi_resource_io *io = &resource->data.io; in sony_pic_read_possible_resource()
4377 list_first_entry(&dev->ioports, struct sony_pic_ioport, list); in sony_pic_read_possible_resource()
4378 if (!ioport->io1.minimum) { in sony_pic_read_possible_resource()
4379 memcpy(&ioport->io1, io, sizeof(*io)); in sony_pic_read_possible_resource()
4380 dprintk("IO1 at 0x%.4x (0x%.2x)\n", ioport->io1.minimum, in sony_pic_read_possible_resource()
4381 ioport->io1.address_length); in sony_pic_read_possible_resource()
4383 else if (!ioport->io2.minimum) { in sony_pic_read_possible_resource()
4384 memcpy(&ioport->io2, io, sizeof(*io)); in sony_pic_read_possible_resource()
4385 dprintk("IO2 at 0x%.4x (0x%.2x)\n", ioport->io2.minimum, in sony_pic_read_possible_resource()
4386 ioport->io2.address_length); in sony_pic_read_possible_resource()
4400 resource->type); in sony_pic_read_possible_resource()
4412 return -EINVAL; in sony_pic_possible_resources()
4423 if (!device->status.enabled) in sony_pic_possible_resources()
4432 status = acpi_walk_resources(device->handle, METHOD_NAME__PRS, in sony_pic_possible_resources()
4436 result = -ENODEV; in sony_pic_possible_resources()
4447 acpi_status ret = acpi_evaluate_object(device->handle, "_DIS", NULL, in sony_pic_disable()
4451 return -ENXIO; in sony_pic_disable()
4488 return -EINVAL; in sony_pic_enable()
4493 return -ENOMEM; in sony_pic_enable()
4502 resource->res1.type = ACPI_RESOURCE_TYPE_IO; in sony_pic_enable()
4503 resource->res1.length = sizeof(struct acpi_resource); in sony_pic_enable()
4504 memcpy(&resource->res1.data.io, &ioport->io1, in sony_pic_enable()
4507 resource->res2.type = ACPI_RESOURCE_TYPE_IO; in sony_pic_enable()
4508 resource->res2.length = sizeof(struct acpi_resource); in sony_pic_enable()
4509 memcpy(&resource->res2.data.io, &ioport->io2, in sony_pic_enable()
4513 resource->res3.type = ACPI_RESOURCE_TYPE_IRQ; in sony_pic_enable()
4514 resource->res3.length = sizeof(struct acpi_resource); in sony_pic_enable()
4515 memcpy(&resource->res3.data.irq, &irq->irq, in sony_pic_enable()
4518 resource->res3.data.irq.shareable = ACPI_SHARED; in sony_pic_enable()
4520 resource->res4.type = ACPI_RESOURCE_TYPE_END_TAG; in sony_pic_enable()
4521 resource->res4.length = sizeof(struct acpi_resource); in sony_pic_enable()
4526 resource->res1.type = ACPI_RESOURCE_TYPE_IO; in sony_pic_enable()
4527 resource->res1.length = sizeof(struct acpi_resource); in sony_pic_enable()
4528 memcpy(&resource->res1.data.io, &ioport->io1, in sony_pic_enable()
4532 resource->res2.type = ACPI_RESOURCE_TYPE_IRQ; in sony_pic_enable()
4533 resource->res2.length = sizeof(struct acpi_resource); in sony_pic_enable()
4534 memcpy(&resource->res2.data.irq, &irq->irq, in sony_pic_enable()
4537 resource->res2.data.irq.shareable = ACPI_SHARED; in sony_pic_enable()
4539 resource->res3.type = ACPI_RESOURCE_TYPE_END_TAG; in sony_pic_enable()
4540 resource->res3.length = sizeof(struct acpi_resource); in sony_pic_enable()
4545 status = acpi_set_current_resources(device->handle, &buffer); in sony_pic_enable()
4550 result = -ENODEV; in sony_pic_enable()
4578 ev = inb_p(dev->cur_ioport->io1.minimum); in sony_pic_irq()
4579 if (dev->cur_ioport->io2.minimum) in sony_pic_irq()
4580 data_mask = inb_p(dev->cur_ioport->io2.minimum); in sony_pic_irq()
4582 data_mask = inb_p(dev->cur_ioport->io1.minimum + in sony_pic_irq()
4583 dev->evport_offset); in sony_pic_irq()
4586 ev, data_mask, dev->cur_ioport->io1.minimum, in sony_pic_irq()
4587 dev->evport_offset); in sony_pic_irq()
4592 for (i = 0; dev->event_types[i].mask; i++) { in sony_pic_irq()
4594 if ((data_mask & dev->event_types[i].data) != in sony_pic_irq()
4595 dev->event_types[i].data) in sony_pic_irq()
4598 if (!(mask & dev->event_types[i].mask)) in sony_pic_irq()
4601 for (j = 0; dev->event_types[i].events[j].event; j++) { in sony_pic_irq()
4602 if (ev == dev->event_types[i].events[j].data) { in sony_pic_irq()
4604 dev->event_types[i].events[j].event; in sony_pic_irq()
4615 if (dev->handle_irq && dev->handle_irq(data_mask, ev) == 0) in sony_pic_irq()
4619 ev, data_mask, dev->cur_ioport->io1.minimum, in sony_pic_irq()
4620 dev->evport_offset); in sony_pic_irq()
4644 free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev); in sony_pic_remove()
4645 release_region(spic_dev.cur_ioport->io1.minimum, in sony_pic_remove()
4646 spic_dev.cur_ioport->io1.address_length); in sony_pic_remove()
4647 if (spic_dev.cur_ioport->io2.minimum) in sony_pic_remove()
4648 release_region(spic_dev.cur_ioport->io2.minimum, in sony_pic_remove()
4649 spic_dev.cur_ioport->io2.address_length); in sony_pic_remove()
4656 sysfs_remove_group(&sony_pf_device->dev.kobj, &spic_attribute_group); in sony_pic_remove()
4660 list_del(&io->list); in sony_pic_remove()
4664 list_del(&irq->list); in sony_pic_remove()
4704 if (request_region(io->io1.minimum, io->io1.address_length, in sony_pic_add()
4707 io->io1.minimum, io->io1.maximum, in sony_pic_add()
4708 io->io1.address_length); in sony_pic_add()
4710 if (io->io2.minimum) { in sony_pic_add()
4711 if (request_region(io->io2.minimum, in sony_pic_add()
4712 io->io2.address_length, in sony_pic_add()
4715 io->io2.minimum, io->io2.maximum, in sony_pic_add()
4716 io->io2.address_length); in sony_pic_add()
4723 io->io2.minimum, io->io2.maximum, in sony_pic_add()
4724 io->io2.address_length); in sony_pic_add()
4725 release_region(io->io1.minimum, in sony_pic_add()
4726 io->io1.address_length); in sony_pic_add()
4737 result = -ENODEV; in sony_pic_add()
4743 if (!request_irq(irq->irq.interrupts[0], sony_pic_irq, in sony_pic_add()
4744 0, "sony-laptop", &spic_dev)) { in sony_pic_add()
4745 dprintk("IRQ: %d - triggering: %d - " in sony_pic_add()
4746 "polarity: %d - shr: %d\n", in sony_pic_add()
4747 irq->irq.interrupts[0], in sony_pic_add()
4748 irq->irq.triggering, in sony_pic_add()
4749 irq->irq.polarity, in sony_pic_add()
4750 irq->irq.shareable); in sony_pic_add()
4757 result = -ENODEV; in sony_pic_add()
4768 spic_dev.bluetooth_power = -1; in sony_pic_add()
4774 result = sysfs_create_group(&sony_pf_device->dev.kobj, &spic_attribute_group); in sony_pic_add()
4788 free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev); in sony_pic_add()
4791 release_region(spic_dev.cur_ioport->io1.minimum, in sony_pic_add()
4792 spic_dev.cur_ioport->io1.address_length); in sony_pic_add()
4793 if (spic_dev.cur_ioport->io2.minimum) in sony_pic_add()
4794 release_region(spic_dev.cur_ioport->io2.minimum, in sony_pic_add()
4795 spic_dev.cur_ioport->io2.address_length); in sony_pic_add()
4805 list_del(&io->list); in sony_pic_add()
4809 list_del(&irq->list); in sony_pic_add()
4822 return -ENXIO; in sony_pic_suspend()
4857 DMI_MATCH(DMI_PRODUCT_NAME, "PCG-"),
4864 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-"),