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 += 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()
1814 return sysfs_emit(buffer, "%d\n", kbdbl_ctl->mode); in sony_nc_kbd_backlight_mode_show()
1822 return -EINVAL; in __sony_nc_kbd_backlight_timeout_set()
1824 if (sony_call_snc_handle(kbdbl_ctl->handle, (value << 0x10) | in __sony_nc_kbd_backlight_timeout_set()
1825 (kbdbl_ctl->base + 0x200), &result)) in __sony_nc_kbd_backlight_timeout_set()
1826 return -EIO; in __sony_nc_kbd_backlight_timeout_set()
1828 kbdbl_ctl->timeout = value; in __sony_nc_kbd_backlight_timeout_set()
1841 return -EINVAL; in sony_nc_kbd_backlight_timeout_store()
1844 return -EINVAL; in sony_nc_kbd_backlight_timeout_store()
1856 return sysfs_emit(buffer, "%d\n", kbdbl_ctl->timeout); in sony_nc_kbd_backlight_timeout_show()
1869 handle, kbdbl_ctl->handle); in sony_nc_kbd_backlight_setup()
1870 return -EBUSY; in sony_nc_kbd_backlight_setup()
1903 return -ENOMEM; in sony_nc_kbd_backlight_setup()
1905 kbdbl_ctl->mode = kbd_backlight; in sony_nc_kbd_backlight_setup()
1906 kbdbl_ctl->timeout = kbd_backlight_timeout; in sony_nc_kbd_backlight_setup()
1907 kbdbl_ctl->handle = handle; in sony_nc_kbd_backlight_setup()
1908 kbdbl_ctl->base = ctl_base; in sony_nc_kbd_backlight_setup()
1910 kbdbl_ctl->has_timeout = handle != 0x0153; in sony_nc_kbd_backlight_setup()
1912 sysfs_attr_init(&kbdbl_ctl->mode_attr.attr); in sony_nc_kbd_backlight_setup()
1913 kbdbl_ctl->mode_attr.attr.name = "kbd_backlight"; in sony_nc_kbd_backlight_setup()
1914 kbdbl_ctl->mode_attr.attr.mode = S_IRUGO | S_IWUSR; in sony_nc_kbd_backlight_setup()
1915 kbdbl_ctl->mode_attr.show = sony_nc_kbd_backlight_mode_show; in sony_nc_kbd_backlight_setup()
1916 kbdbl_ctl->mode_attr.store = sony_nc_kbd_backlight_mode_store; in sony_nc_kbd_backlight_setup()
1918 ret = device_create_file(&pd->dev, &kbdbl_ctl->mode_attr); in sony_nc_kbd_backlight_setup()
1922 __sony_nc_kbd_backlight_mode_set(kbdbl_ctl->mode); in sony_nc_kbd_backlight_setup()
1924 if (kbdbl_ctl->has_timeout) { in sony_nc_kbd_backlight_setup()
1925 sysfs_attr_init(&kbdbl_ctl->timeout_attr.attr); in sony_nc_kbd_backlight_setup()
1926 kbdbl_ctl->timeout_attr.attr.name = "kbd_backlight_timeout"; in sony_nc_kbd_backlight_setup()
1927 kbdbl_ctl->timeout_attr.attr.mode = S_IRUGO | S_IWUSR; in sony_nc_kbd_backlight_setup()
1928 kbdbl_ctl->timeout_attr.show = in sony_nc_kbd_backlight_setup()
1930 kbdbl_ctl->timeout_attr.store = in sony_nc_kbd_backlight_setup()
1933 ret = device_create_file(&pd->dev, &kbdbl_ctl->timeout_attr); in sony_nc_kbd_backlight_setup()
1937 __sony_nc_kbd_backlight_timeout_set(kbdbl_ctl->timeout); in sony_nc_kbd_backlight_setup()
1944 device_remove_file(&pd->dev, &kbdbl_ctl->mode_attr); in sony_nc_kbd_backlight_setup()
1954 if (kbdbl_ctl && handle == kbdbl_ctl->handle) { in sony_nc_kbd_backlight_cleanup()
1955 device_remove_file(&pd->dev, &kbdbl_ctl->mode_attr); in sony_nc_kbd_backlight_cleanup()
1956 if (kbdbl_ctl->has_timeout) in sony_nc_kbd_backlight_cleanup()
1957 device_remove_file(&pd->dev, &kbdbl_ctl->timeout_attr); in sony_nc_kbd_backlight_cleanup()
1977 return -EINVAL; in sony_nc_battery_care_limit_store()
1980 return -EINVAL; in sony_nc_battery_care_limit_store()
1983 * 00 - none in sony_nc_battery_care_limit_store()
1984 * 01 - 80% in sony_nc_battery_care_limit_store()
1985 * 10 - 50% in sony_nc_battery_care_limit_store()
1986 * 11 - 100% in sony_nc_battery_care_limit_store()
1989 * bit 1: 1 tell to store the battery limit (see bits 6,7) too in sony_nc_battery_care_limit_store()
1992 * bits 6,7: store the limit into the battery in sony_nc_battery_care_limit_store()
2007 return -EINVAL; in sony_nc_battery_care_limit_store()
2010 * handle 0x0115 should allow storing on battery too; in sony_nc_battery_care_limit_store()
2012 * handle 0x013f, same as 0x0136 but no storing on the battery in sony_nc_battery_care_limit_store()
2014 if (bcare_ctl->handle != 0x013f) in sony_nc_battery_care_limit_store()
2020 if (sony_call_snc_handle(bcare_ctl->handle, cmd | 0x0100, &result)) in sony_nc_battery_care_limit_store()
2021 return -EIO; in sony_nc_battery_care_limit_store()
2031 if (sony_call_snc_handle(bcare_ctl->handle, 0x0000, &result)) in sony_nc_battery_care_limit_show()
2032 return -EIO; in sony_nc_battery_care_limit_show()
2058 if (sony_call_snc_handle(bcare_ctl->handle, 0x0200, &health)) in sony_nc_battery_care_health_show()
2059 return -EIO; in sony_nc_battery_care_health_show()
2071 return -ENOMEM; in sony_nc_battery_care_setup()
2073 bcare_ctl->handle = handle; in sony_nc_battery_care_setup()
2075 sysfs_attr_init(&bcare_ctl->attrs[0].attr); in sony_nc_battery_care_setup()
2076 bcare_ctl->attrs[0].attr.name = "battery_care_limiter"; in sony_nc_battery_care_setup()
2077 bcare_ctl->attrs[0].attr.mode = S_IRUGO | S_IWUSR; in sony_nc_battery_care_setup()
2078 bcare_ctl->attrs[0].show = sony_nc_battery_care_limit_show; in sony_nc_battery_care_setup()
2079 bcare_ctl->attrs[0].store = sony_nc_battery_care_limit_store; in sony_nc_battery_care_setup()
2081 ret = device_create_file(&pd->dev, &bcare_ctl->attrs[0]); in sony_nc_battery_care_setup()
2089 sysfs_attr_init(&bcare_ctl->attrs[1].attr); in sony_nc_battery_care_setup()
2090 bcare_ctl->attrs[1].attr.name = "battery_care_health"; in sony_nc_battery_care_setup()
2091 bcare_ctl->attrs[1].attr.mode = S_IRUGO; in sony_nc_battery_care_setup()
2092 bcare_ctl->attrs[1].show = sony_nc_battery_care_health_show; in sony_nc_battery_care_setup()
2094 ret = device_create_file(&pd->dev, &bcare_ctl->attrs[1]); in sony_nc_battery_care_setup()
2101 device_remove_file(&pd->dev, &bcare_ctl->attrs[0]); in sony_nc_battery_care_setup()
2113 device_remove_file(&pd->dev, &bcare_ctl->attrs[0]); in sony_nc_battery_care_cleanup()
2114 if (bcare_ctl->handle != 0x0115) in sony_nc_battery_care_cleanup()
2115 device_remove_file(&pd->dev, &bcare_ctl->attrs[1]); in sony_nc_battery_care_cleanup()
2141 /* the thermal profile seems to be a two bit bitmask: in sony_nc_thermal_mode_set()
2142 * lsb -> silent in sony_nc_thermal_mode_set()
2143 * msb -> performance in sony_nc_thermal_mode_set()
2147 if ((mode && !(th_handle->profiles & mode)) || mode >= THM_PROFILE_MAX) in sony_nc_thermal_mode_set()
2148 return -EINVAL; in sony_nc_thermal_mode_set()
2151 return -EIO; in sony_nc_thermal_mode_set()
2153 th_handle->mode = mode; in sony_nc_thermal_mode_set()
2163 return -EIO; in sony_nc_thermal_mode_get()
2175 if (!cnt || (th_handle->profiles & cnt)) in sony_nc_thermal_profiles_show()
2176 idx += scnprintf(buffer + idx, PAGE_SIZE - idx, "%s ", in sony_nc_thermal_profiles_show()
2179 idx += scnprintf(buffer + idx, PAGE_SIZE - idx, "\n"); in sony_nc_thermal_profiles_show()
2192 return -EINVAL; in sony_nc_thermal_mode_store()
2195 if (buffer[len - 1] == '\n') in sony_nc_thermal_mode_store()
2196 len--; in sony_nc_thermal_mode_store()
2203 return -EIO; in sony_nc_thermal_mode_store()
2224 return -ENOMEM; in sony_nc_thermal_setup()
2226 ret = sony_call_snc_handle(0x0122, 0x0000, &th_handle->profiles); in sony_nc_thermal_setup()
2234 pr_warn("couldn't to read the current thermal profile"); in sony_nc_thermal_setup()
2237 th_handle->mode = ret; in sony_nc_thermal_setup()
2239 sysfs_attr_init(&th_handle->profiles_attr.attr); in sony_nc_thermal_setup()
2240 th_handle->profiles_attr.attr.name = "thermal_profiles"; in sony_nc_thermal_setup()
2241 th_handle->profiles_attr.attr.mode = S_IRUGO; in sony_nc_thermal_setup()
2242 th_handle->profiles_attr.show = sony_nc_thermal_profiles_show; in sony_nc_thermal_setup()
2244 sysfs_attr_init(&th_handle->mode_attr.attr); in sony_nc_thermal_setup()
2245 th_handle->mode_attr.attr.name = "thermal_control"; in sony_nc_thermal_setup()
2246 th_handle->mode_attr.attr.mode = S_IRUGO | S_IWUSR; in sony_nc_thermal_setup()
2247 th_handle->mode_attr.show = sony_nc_thermal_mode_show; in sony_nc_thermal_setup()
2248 th_handle->mode_attr.store = sony_nc_thermal_mode_store; in sony_nc_thermal_setup()
2250 ret = device_create_file(&pd->dev, &th_handle->profiles_attr); in sony_nc_thermal_setup()
2254 ret = device_create_file(&pd->dev, &th_handle->mode_attr); in sony_nc_thermal_setup()
2261 device_remove_file(&pd->dev, &th_handle->profiles_attr); in sony_nc_thermal_setup()
2271 device_remove_file(&pd->dev, &th_handle->profiles_attr); in sony_nc_thermal_cleanup()
2272 device_remove_file(&pd->dev, &th_handle->mode_attr); in sony_nc_thermal_cleanup()
2288 if (status != th_handle->mode) in sony_nc_thermal_resume()
2289 sony_nc_thermal_mode_set(th_handle->mode); in sony_nc_thermal_resume()
2313 return -EINVAL; in sony_nc_lid_resume_store()
2316 return -EINVAL; in sony_nc_lid_resume_store()
2319 * +--------------+ in sony_nc_lid_resume_store()
2321 * +--------------+ in sony_nc_lid_resume_store()
2325 if (&lid_ctl->attrs[pos].attr == &attr->attr) in sony_nc_lid_resume_store()
2330 return -EINVAL; in sony_nc_lid_resume_store()
2333 value = lid_ctl->status | (1 << pos); in sony_nc_lid_resume_store()
2335 value = lid_ctl->status & ~(1 << pos); in sony_nc_lid_resume_store()
2337 if (sony_call_snc_handle(lid_ctl->handle, value << 0x10 | 0x0100, in sony_nc_lid_resume_store()
2339 return -EIO; in sony_nc_lid_resume_store()
2341 lid_ctl->status = value; in sony_nc_lid_resume_store()
2353 if (&lid_ctl->attrs[pos].attr == &attr->attr) in sony_nc_lid_resume_show()
2355 (lid_ctl->status >> pos) & 0x01); in sony_nc_lid_resume_show()
2358 return -EINVAL; in sony_nc_lid_resume_show()
2368 return -EIO; in sony_nc_lid_resume_setup()
2372 return -ENOMEM; in sony_nc_lid_resume_setup()
2374 lid_ctl->status = result & 0x7; in sony_nc_lid_resume_setup()
2375 lid_ctl->handle = handle; in sony_nc_lid_resume_setup()
2377 sysfs_attr_init(&lid_ctl->attrs[0].attr); in sony_nc_lid_resume_setup()
2378 lid_ctl->attrs[LID_RESUME_S5].attr.name = "lid_resume_S5"; in sony_nc_lid_resume_setup()
2379 lid_ctl->attrs[LID_RESUME_S5].attr.mode = S_IRUGO | S_IWUSR; in sony_nc_lid_resume_setup()
2380 lid_ctl->attrs[LID_RESUME_S5].show = sony_nc_lid_resume_show; in sony_nc_lid_resume_setup()
2381 lid_ctl->attrs[LID_RESUME_S5].store = sony_nc_lid_resume_store; in sony_nc_lid_resume_setup()
2384 sysfs_attr_init(&lid_ctl->attrs[1].attr); in sony_nc_lid_resume_setup()
2385 lid_ctl->attrs[LID_RESUME_S4].attr.name = "lid_resume_S4"; in sony_nc_lid_resume_setup()
2386 lid_ctl->attrs[LID_RESUME_S4].attr.mode = S_IRUGO | S_IWUSR; in sony_nc_lid_resume_setup()
2387 lid_ctl->attrs[LID_RESUME_S4].show = sony_nc_lid_resume_show; in sony_nc_lid_resume_setup()
2388 lid_ctl->attrs[LID_RESUME_S4].store = sony_nc_lid_resume_store; in sony_nc_lid_resume_setup()
2390 sysfs_attr_init(&lid_ctl->attrs[2].attr); in sony_nc_lid_resume_setup()
2391 lid_ctl->attrs[LID_RESUME_S3].attr.name = "lid_resume_S3"; in sony_nc_lid_resume_setup()
2392 lid_ctl->attrs[LID_RESUME_S3].attr.mode = S_IRUGO | S_IWUSR; in sony_nc_lid_resume_setup()
2393 lid_ctl->attrs[LID_RESUME_S3].show = sony_nc_lid_resume_show; in sony_nc_lid_resume_setup()
2394 lid_ctl->attrs[LID_RESUME_S3].store = sony_nc_lid_resume_store; in sony_nc_lid_resume_setup()
2397 lid_ctl->attrs[i].attr.name; i++) { in sony_nc_lid_resume_setup()
2398 result = device_create_file(&pd->dev, &lid_ctl->attrs[i]); in sony_nc_lid_resume_setup()
2406 for (i--; i >= 0; i--) in sony_nc_lid_resume_setup()
2407 device_remove_file(&pd->dev, &lid_ctl->attrs[i]); in sony_nc_lid_resume_setup()
2421 if (!lid_ctl->attrs[i].attr.name) in sony_nc_lid_resume_cleanup()
2424 device_remove_file(&pd->dev, &lid_ctl->attrs[i]); in sony_nc_lid_resume_cleanup()
2449 if (sony_call_snc_handle(gfxs_ctl->handle, in __sony_nc_gfx_switch_status_get()
2450 gfxs_ctl->handle == 0x015B ? 0x0000 : 0x0100, in __sony_nc_gfx_switch_status_get()
2452 return -EIO; in __sony_nc_gfx_switch_status_get()
2454 switch (gfxs_ctl->handle) { in __sony_nc_gfx_switch_status_get()
2474 return -EINVAL; in __sony_nc_gfx_switch_status_get()
2499 return -ENOMEM; in sony_nc_gfx_switch_setup()
2501 gfxs_ctl->handle = handle; in sony_nc_gfx_switch_setup()
2503 sysfs_attr_init(&gfxs_ctl->attr.attr); in sony_nc_gfx_switch_setup()
2504 gfxs_ctl->attr.attr.name = "gfx_switch_status"; in sony_nc_gfx_switch_setup()
2505 gfxs_ctl->attr.attr.mode = S_IRUGO; in sony_nc_gfx_switch_setup()
2506 gfxs_ctl->attr.show = sony_nc_gfx_switch_status_show; in sony_nc_gfx_switch_setup()
2508 result = device_create_file(&pd->dev, &gfxs_ctl->attr); in sony_nc_gfx_switch_setup()
2524 device_remove_file(&pd->dev, &gfxs_ctl->attr); in sony_nc_gfx_switch_cleanup()
2542 return -EINVAL; in sony_nc_highspeed_charging_store()
2545 return -EINVAL; in sony_nc_highspeed_charging_store()
2548 return -EIO; in sony_nc_highspeed_charging_store()
2559 return -EIO; in sony_nc_highspeed_charging_show()
2578 return -ENOMEM; in sony_nc_highspeed_charging_setup()
2580 sysfs_attr_init(&hsc_handle->attr); in sony_nc_highspeed_charging_setup()
2581 hsc_handle->attr.name = "battery_highspeed_charging"; in sony_nc_highspeed_charging_setup()
2582 hsc_handle->attr.mode = S_IRUGO | S_IWUSR; in sony_nc_highspeed_charging_setup()
2583 hsc_handle->show = sony_nc_highspeed_charging_show; in sony_nc_highspeed_charging_setup()
2584 hsc_handle->store = sony_nc_highspeed_charging_store; in sony_nc_highspeed_charging_setup()
2586 result = device_create_file(&pd->dev, hsc_handle); in sony_nc_highspeed_charging_setup()
2599 device_remove_file(&pd->dev, hsc_handle); in sony_nc_highspeed_charging_cleanup()
2605 /* low battery function */
2616 return -EINVAL; in sony_nc_lowbatt_store()
2619 return -EINVAL; in sony_nc_lowbatt_store()
2622 return -EIO; in sony_nc_lowbatt_store()
2633 return -EIO; in sony_nc_lowbatt_show()
2644 return -ENOMEM; in sony_nc_lowbatt_setup()
2646 sysfs_attr_init(&lowbatt_handle->attr); in sony_nc_lowbatt_setup()
2647 lowbatt_handle->attr.name = "lowbatt_hibernate"; in sony_nc_lowbatt_setup()
2648 lowbatt_handle->attr.mode = S_IRUGO | S_IWUSR; in sony_nc_lowbatt_setup()
2649 lowbatt_handle->show = sony_nc_lowbatt_show; in sony_nc_lowbatt_setup()
2650 lowbatt_handle->store = sony_nc_lowbatt_store; in sony_nc_lowbatt_setup()
2652 result = device_create_file(&pd->dev, lowbatt_handle); in sony_nc_lowbatt_setup()
2665 device_remove_file(&pd->dev, lowbatt_handle); in sony_nc_lowbatt_cleanup()
2682 return -EINVAL; in sony_nc_hsfan_store()
2685 return -EINVAL; in sony_nc_hsfan_store()
2688 return -EIO; in sony_nc_hsfan_store()
2699 return -EIO; in sony_nc_hsfan_show()
2710 return -EIO; in sony_nc_fanspeed_show()
2721 return -ENOMEM; in sony_nc_fanspeed_setup()
2725 result = -ENOMEM; in sony_nc_fanspeed_setup()
2729 sysfs_attr_init(&fan_handle->attr); in sony_nc_fanspeed_setup()
2730 fan_handle->attr.name = "fanspeed"; in sony_nc_fanspeed_setup()
2731 fan_handle->attr.mode = S_IRUGO; in sony_nc_fanspeed_setup()
2732 fan_handle->show = sony_nc_fanspeed_show; in sony_nc_fanspeed_setup()
2733 fan_handle->store = NULL; in sony_nc_fanspeed_setup()
2735 sysfs_attr_init(&hsf_handle->attr); in sony_nc_fanspeed_setup()
2736 hsf_handle->attr.name = "fan_forced"; in sony_nc_fanspeed_setup()
2737 hsf_handle->attr.mode = S_IRUGO | S_IWUSR; in sony_nc_fanspeed_setup()
2738 hsf_handle->show = sony_nc_hsfan_show; in sony_nc_fanspeed_setup()
2739 hsf_handle->store = sony_nc_hsfan_store; in sony_nc_fanspeed_setup()
2741 result = device_create_file(&pd->dev, fan_handle); in sony_nc_fanspeed_setup()
2745 result = device_create_file(&pd->dev, hsf_handle); in sony_nc_fanspeed_setup()
2752 device_remove_file(&pd->dev, fan_handle); in sony_nc_fanspeed_setup()
2767 device_remove_file(&pd->dev, fan_handle); in sony_nc_fanspeed_cleanup()
2772 device_remove_file(&pd->dev, hsf_handle); in sony_nc_fanspeed_cleanup()
2789 return -EINVAL; in sony_nc_usb_charge_store()
2792 return -EINVAL; in sony_nc_usb_charge_store()
2795 return -EIO; in sony_nc_usb_charge_store()
2806 return -EIO; in sony_nc_usb_charge_show()
2825 return -ENOMEM; in sony_nc_usb_charge_setup()
2827 sysfs_attr_init(&uc_handle->attr); in sony_nc_usb_charge_setup()
2828 uc_handle->attr.name = "usb_charge"; in sony_nc_usb_charge_setup()
2829 uc_handle->attr.mode = S_IRUGO | S_IWUSR; in sony_nc_usb_charge_setup()
2830 uc_handle->show = sony_nc_usb_charge_show; in sony_nc_usb_charge_setup()
2831 uc_handle->store = sony_nc_usb_charge_store; in sony_nc_usb_charge_setup()
2833 result = device_create_file(&pd->dev, uc_handle); in sony_nc_usb_charge_setup()
2846 device_remove_file(&pd->dev, uc_handle); in sony_nc_usb_charge_cleanup()
2861 return -EIO; in sony_nc_panelid_show()
2872 return -ENOMEM; in sony_nc_panelid_setup()
2874 sysfs_attr_init(&panel_handle->attr); in sony_nc_panelid_setup()
2875 panel_handle->attr.name = "panel_id"; in sony_nc_panelid_setup()
2876 panel_handle->attr.mode = S_IRUGO; in sony_nc_panelid_setup()
2877 panel_handle->show = sony_nc_panelid_show; in sony_nc_panelid_setup()
2878 panel_handle->store = NULL; in sony_nc_panelid_setup()
2880 result = device_create_file(&pd->dev, panel_handle); in sony_nc_panelid_setup()
2893 device_remove_file(&pd->dev, panel_handle); in sony_nc_panelid_cleanup()
2910 return -EINVAL; in sony_nc_smart_conn_store()
2913 return -EINVAL; in sony_nc_smart_conn_store()
2916 return -EIO; in sony_nc_smart_conn_store()
2927 return -ENOMEM; in sony_nc_smart_conn_setup()
2929 sysfs_attr_init(&sc_handle->attr); in sony_nc_smart_conn_setup()
2930 sc_handle->attr.name = "smart_connect"; in sony_nc_smart_conn_setup()
2931 sc_handle->attr.mode = S_IWUSR; in sony_nc_smart_conn_setup()
2932 sc_handle->show = NULL; in sony_nc_smart_conn_setup()
2933 sc_handle->store = sony_nc_smart_conn_store; in sony_nc_smart_conn_setup()
2935 result = device_create_file(&pd->dev, sc_handle); in sony_nc_smart_conn_setup()
2948 device_remove_file(&pd->dev, sc_handle); in sony_nc_smart_conn_cleanup()
2968 return -EINVAL; in sony_nc_touchpad_store()
2971 return -EINVAL; in sony_nc_touchpad_store()
2976 if (sony_call_snc_handle(tp_ctl->handle, in sony_nc_touchpad_store()
2978 return -EIO; in sony_nc_touchpad_store()
2988 if (sony_call_snc_handle(tp_ctl->handle, 0x000, &result)) in sony_nc_touchpad_show()
2989 return -EINVAL; in sony_nc_touchpad_show()
3001 return -ENOMEM; in sony_nc_touchpad_setup()
3003 tp_ctl->handle = handle; in sony_nc_touchpad_setup()
3005 sysfs_attr_init(&tp_ctl->attr.attr); in sony_nc_touchpad_setup()
3006 tp_ctl->attr.attr.name = "touchpad"; in sony_nc_touchpad_setup()
3007 tp_ctl->attr.attr.mode = S_IRUGO | S_IWUSR; in sony_nc_touchpad_setup()
3008 tp_ctl->attr.show = sony_nc_touchpad_show; in sony_nc_touchpad_setup()
3009 tp_ctl->attr.store = sony_nc_touchpad_store; in sony_nc_touchpad_setup()
3011 ret = device_create_file(&pd->dev, &tp_ctl->attr); in sony_nc_touchpad_setup()
3023 device_remove_file(&pd->dev, &tp_ctl->attr); in sony_nc_touchpad_cleanup()
3038 props->handle = handle; in sony_nc_backlight_ng_read_limits()
3039 props->offset = 0; in sony_nc_backlight_ng_read_limits()
3040 props->maxlvl = 0xff; in sony_nc_backlight_ng_read_limits()
3080 props->offset = min; in sony_nc_backlight_ng_read_limits()
3081 props->maxlvl = max; in sony_nc_backlight_ng_read_limits()
3082 dprintk("Brightness levels: min=%d max=%d\n", props->offset, in sony_nc_backlight_ng_read_limits()
3083 props->maxlvl); in sony_nc_backlight_ng_read_limits()
3096 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3102 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3108 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3114 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3120 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset; in sony_nc_backlight_setup()
3124 max_brightness = SONY_MAX_BRIGHTNESS - 1; in sony_nc_backlight_setup()
3140 sony_bl_props.dev->props.brightness = in sony_nc_backlight_setup()
3141 ops->get_brightness(sony_bl_props.dev); in sony_nc_backlight_setup()
3158 sony_nc_acpi_handle = device->handle; in sony_nc_add()
3163 if (!result && !device->status.present) { in sony_nc_add()
3165 result = -ENODEV; in sony_nc_add()
3179 result = -ENODEV; in sony_nc_add()
3208 for (item = sony_nc_values; item->name; ++item) { in sony_nc_add()
3210 if (!debug && item->debug) in sony_nc_add()
3214 for (; item->acpiget && *item->acpiget; ++item->acpiget) { in sony_nc_add()
3216 *item->acpiget)) { in sony_nc_add()
3218 item->name, *item->acpiget); in sony_nc_add()
3219 item->devattr.attr.mode |= S_IRUGO; in sony_nc_add()
3225 for (; item->acpiset && *item->acpiset; ++item->acpiset) { in sony_nc_add()
3227 *item->acpiset)) { in sony_nc_add()
3229 item->name, *item->acpiset); in sony_nc_add()
3230 item->devattr.attr.mode |= S_IWUSR; in sony_nc_add()
3235 if (item->devattr.attr.mode != 0) { in sony_nc_add()
3237 device_create_file(&sony_pf_device->dev, in sony_nc_add()
3238 &item->devattr); in sony_nc_add()
3248 for (item = sony_nc_values; item->name; ++item) { in sony_nc_add()
3249 device_remove_file(&sony_pf_device->dev, &item->devattr); in sony_nc_add()
3274 for (item = sony_nc_values; item->name; ++item) { in sony_nc_remove()
3275 device_remove_file(&sony_pf_device->dev, &item->devattr); in sony_nc_remove()
3516 /* The set of possible battery events */
3586 while (--n && (command)) \
3597 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, in sony_pic_call1()
3599 outb(dev, spic_dev.cur_ioport->io1.minimum + 4); in sony_pic_call1()
3600 v1 = inb_p(spic_dev.cur_ioport->io1.minimum + 4); in sony_pic_call1()
3601 v2 = inb_p(spic_dev.cur_ioport->io1.minimum); in sony_pic_call1()
3610 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, in sony_pic_call2()
3612 outb(dev, spic_dev.cur_ioport->io1.minimum + 4); in sony_pic_call2()
3613 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, in sony_pic_call2()
3615 outb(fn, spic_dev.cur_ioport->io1.minimum); in sony_pic_call2()
3616 v1 = inb_p(spic_dev.cur_ioport->io1.minimum); in sony_pic_call2()
3617 dprintk("sony_pic_call2(0x%.2x - 0x%.2x): 0x%.4x\n", dev, fn, v1); in sony_pic_call2()
3625 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG); in sony_pic_call3()
3626 outb(dev, spic_dev.cur_ioport->io1.minimum + 4); in sony_pic_call3()
3627 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG); in sony_pic_call3()
3628 outb(fn, spic_dev.cur_ioport->io1.minimum); in sony_pic_call3()
3629 wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG); in sony_pic_call3()
3630 outb(v, spic_dev.cur_ioport->io1.minimum); in sony_pic_call3()
3631 v1 = inb_p(spic_dev.cur_ioport->io1.minimum); in sony_pic_call3()
3632 dprintk("sony_pic_call3(0x%.2x - 0x%.2x - 0x%.2x): 0x%.4x\n", in sony_pic_call3()
3646 * - 0x5c and 0x5f requires 0xA0 in type3_handle_irq()
3647 * - 0x61 requires 0xB3 in type3_handle_irq()
3666 dev->model = SONYPI_DEVICE_TYPE1; in sony_pic_detect_device_type()
3667 dev->evport_offset = SONYPI_TYPE1_OFFSET; in sony_pic_detect_device_type()
3668 dev->event_types = type1_events; in sony_pic_detect_device_type()
3675 dev->model = SONYPI_DEVICE_TYPE2; in sony_pic_detect_device_type()
3676 dev->evport_offset = SONYPI_TYPE2_OFFSET; in sony_pic_detect_device_type()
3677 dev->event_types = type2_events; in sony_pic_detect_device_type()
3684 dev->model = SONYPI_DEVICE_TYPE3; in sony_pic_detect_device_type()
3685 dev->handle_irq = type3_handle_irq; in sony_pic_detect_device_type()
3686 dev->evport_offset = SONYPI_TYPE3_OFFSET; in sony_pic_detect_device_type()
3687 dev->event_types = type3_events; in sony_pic_detect_device_type()
3694 dev->model = SONYPI_DEVICE_TYPE3; in sony_pic_detect_device_type()
3695 dev->handle_irq = type3_handle_irq; in sony_pic_detect_device_type()
3696 dev->evport_offset = SONYPI_TYPE3_OFFSET; in sony_pic_detect_device_type()
3697 dev->event_types = type3_events; in sony_pic_detect_device_type()
3704 dev->model = SONYPI_DEVICE_TYPE3; in sony_pic_detect_device_type()
3705 dev->handle_irq = type3_handle_irq; in sony_pic_detect_device_type()
3706 dev->evport_offset = SONYPI_TYPE3_OFFSET; in sony_pic_detect_device_type()
3707 dev->event_types = type3_events; in sony_pic_detect_device_type()
3712 dev->model = SONYPI_DEVICE_TYPE2; in sony_pic_detect_device_type()
3713 dev->evport_offset = SONYPI_TYPE2_OFFSET; in sony_pic_detect_device_type()
3714 dev->event_types = type2_events; in sony_pic_detect_device_type()
3720 dev->model == SONYPI_DEVICE_TYPE1 ? 1 : in sony_pic_detect_device_type()
3721 dev->model == SONYPI_DEVICE_TYPE2 ? 2 : 3); in sony_pic_detect_device_type()
3768 return -ENODEV; in __sony_pic_camera_off()
3788 return -ENODEV; in __sony_pic_camera_on()
3794 for (j = 5; j > 0; j--) { in __sony_pic_camera_on()
3800 for (i = 400; i > 0; i--) { in __sony_pic_camera_on()
3811 return -ENODEV; in __sony_pic_camera_on()
3826 return -EIO; in sony_pic_camera_command()
3891 return -EINVAL; in sony_pic_wwanpower_store()
3894 return -EINVAL; in sony_pic_wwanpower_store()
3930 return -EINVAL; in sony_pic_bluetoothpower_store()
3933 return -EINVAL; in sony_pic_bluetoothpower_store()
3971 return -EINVAL; in sony_pic_fanspeed_store()
3974 return -EINVAL; in sony_pic_fanspeed_store()
3977 return -EIO; in sony_pic_fanspeed_store()
3987 return -EIO; in sony_pic_fanspeed_show()
4015 /* battery / brightness / temperature addresses */
4074 (file->f_flags & O_NONBLOCK)) in sonypi_misc_read()
4075 return -EAGAIN; in sonypi_misc_read()
4086 return -EFAULT; in sonypi_misc_read()
4092 inode->i_atime = current_time(inode); in sonypi_misc_read()
4110 return -1; in ec_read16()
4112 return -1; in ec_read16()
4130 ret = -EIO; in sonypi_misc_ioctl()
4135 ret = -EIO; in sonypi_misc_ioctl()
4138 val8 = ((value & 0xff) - 1) << 5; in sonypi_misc_ioctl()
4140 ret = -EFAULT; in sonypi_misc_ioctl()
4144 ret = -EIO; in sonypi_misc_ioctl()
4148 ret = -EFAULT; in sonypi_misc_ioctl()
4154 ret = -EIO; in sonypi_misc_ioctl()
4158 sony_bl_props.dev->props.brightness = in sonypi_misc_ioctl()
4163 ret = -EIO; in sonypi_misc_ioctl()
4167 ret = -EFAULT; in sonypi_misc_ioctl()
4171 ret = -EIO; in sonypi_misc_ioctl()
4175 ret = -EFAULT; in sonypi_misc_ioctl()
4179 ret = -EIO; in sonypi_misc_ioctl()
4183 ret = -EFAULT; in sonypi_misc_ioctl()
4187 ret = -EIO; in sonypi_misc_ioctl()
4191 ret = -EFAULT; in sonypi_misc_ioctl()
4195 ret = -EIO; in sonypi_misc_ioctl()
4200 ret = -EFAULT; in sonypi_misc_ioctl()
4205 ret = -EFAULT; in sonypi_misc_ioctl()
4209 ret = -EFAULT; in sonypi_misc_ioctl()
4217 ret = -EIO; in sonypi_misc_ioctl()
4221 ret = -EFAULT; in sonypi_misc_ioctl()
4225 ret = -EFAULT; in sonypi_misc_ioctl()
4229 ret = -EIO; in sonypi_misc_ioctl()
4234 ret = -EIO; in sonypi_misc_ioctl()
4238 ret = -EFAULT; in sonypi_misc_ioctl()
4241 ret = -EINVAL; in sonypi_misc_ioctl()
4286 if (minor != -1) in sonypi_compat_init()
4293 if (minor == -1) in sonypi_compat_init()
4324 switch (resource->type) { in sony_pic_read_possible_resource()
4332 list_add(&ioport->list, &dev->ioports); in sony_pic_read_possible_resource()
4342 struct acpi_resource_irq *p = &resource->data.irq; in sony_pic_read_possible_resource()
4344 if (!p->interrupt_count) { in sony_pic_read_possible_resource()
4352 for (i = 0; i < p->interrupt_count; i++) { in sony_pic_read_possible_resource()
4353 if (!p->interrupts[i]) { in sony_pic_read_possible_resource()
4355 p->interrupts[i]); in sony_pic_read_possible_resource()
4363 list_add(&interrupt->list, &dev->interrupts); in sony_pic_read_possible_resource()
4364 interrupt->irq.triggering = p->triggering; in sony_pic_read_possible_resource()
4365 interrupt->irq.polarity = p->polarity; in sony_pic_read_possible_resource()
4366 interrupt->irq.shareable = p->shareable; in sony_pic_read_possible_resource()
4367 interrupt->irq.interrupt_count = 1; in sony_pic_read_possible_resource()
4368 interrupt->irq.interrupts[0] = p->interrupts[i]; in sony_pic_read_possible_resource()
4374 struct acpi_resource_io *io = &resource->data.io; in sony_pic_read_possible_resource()
4376 list_first_entry(&dev->ioports, struct sony_pic_ioport, list); in sony_pic_read_possible_resource()
4377 if (!ioport->io1.minimum) { in sony_pic_read_possible_resource()
4378 memcpy(&ioport->io1, io, sizeof(*io)); in sony_pic_read_possible_resource()
4379 dprintk("IO1 at 0x%.4x (0x%.2x)\n", ioport->io1.minimum, in sony_pic_read_possible_resource()
4380 ioport->io1.address_length); in sony_pic_read_possible_resource()
4382 else if (!ioport->io2.minimum) { in sony_pic_read_possible_resource()
4383 memcpy(&ioport->io2, io, sizeof(*io)); in sony_pic_read_possible_resource()
4384 dprintk("IO2 at 0x%.4x (0x%.2x)\n", ioport->io2.minimum, in sony_pic_read_possible_resource()
4385 ioport->io2.address_length); in sony_pic_read_possible_resource()
4399 resource->type); in sony_pic_read_possible_resource()
4411 return -EINVAL; in sony_pic_possible_resources()
4422 if (!device->status.enabled) in sony_pic_possible_resources()
4431 status = acpi_walk_resources(device->handle, METHOD_NAME__PRS, in sony_pic_possible_resources()
4435 result = -ENODEV; in sony_pic_possible_resources()
4446 acpi_status ret = acpi_evaluate_object(device->handle, "_DIS", NULL, in sony_pic_disable()
4450 return -ENXIO; in sony_pic_disable()
4487 return -EINVAL; in sony_pic_enable()
4492 return -ENOMEM; in sony_pic_enable()
4501 resource->res1.type = ACPI_RESOURCE_TYPE_IO; in sony_pic_enable()
4502 resource->res1.length = sizeof(struct acpi_resource); in sony_pic_enable()
4503 memcpy(&resource->res1.data.io, &ioport->io1, in sony_pic_enable()
4506 resource->res2.type = ACPI_RESOURCE_TYPE_IO; in sony_pic_enable()
4507 resource->res2.length = sizeof(struct acpi_resource); in sony_pic_enable()
4508 memcpy(&resource->res2.data.io, &ioport->io2, in sony_pic_enable()
4512 resource->res3.type = ACPI_RESOURCE_TYPE_IRQ; in sony_pic_enable()
4513 resource->res3.length = sizeof(struct acpi_resource); in sony_pic_enable()
4514 memcpy(&resource->res3.data.irq, &irq->irq, in sony_pic_enable()
4517 resource->res3.data.irq.shareable = ACPI_SHARED; in sony_pic_enable()
4519 resource->res4.type = ACPI_RESOURCE_TYPE_END_TAG; in sony_pic_enable()
4520 resource->res4.length = sizeof(struct acpi_resource); in sony_pic_enable()
4525 resource->res1.type = ACPI_RESOURCE_TYPE_IO; in sony_pic_enable()
4526 resource->res1.length = sizeof(struct acpi_resource); in sony_pic_enable()
4527 memcpy(&resource->res1.data.io, &ioport->io1, in sony_pic_enable()
4531 resource->res2.type = ACPI_RESOURCE_TYPE_IRQ; in sony_pic_enable()
4532 resource->res2.length = sizeof(struct acpi_resource); in sony_pic_enable()
4533 memcpy(&resource->res2.data.irq, &irq->irq, in sony_pic_enable()
4536 resource->res2.data.irq.shareable = ACPI_SHARED; in sony_pic_enable()
4538 resource->res3.type = ACPI_RESOURCE_TYPE_END_TAG; in sony_pic_enable()
4539 resource->res3.length = sizeof(struct acpi_resource); in sony_pic_enable()
4544 status = acpi_set_current_resources(device->handle, &buffer); in sony_pic_enable()
4549 result = -ENODEV; in sony_pic_enable()
4577 ev = inb_p(dev->cur_ioport->io1.minimum); in sony_pic_irq()
4578 if (dev->cur_ioport->io2.minimum) in sony_pic_irq()
4579 data_mask = inb_p(dev->cur_ioport->io2.minimum); in sony_pic_irq()
4581 data_mask = inb_p(dev->cur_ioport->io1.minimum + in sony_pic_irq()
4582 dev->evport_offset); in sony_pic_irq()
4585 ev, data_mask, dev->cur_ioport->io1.minimum, in sony_pic_irq()
4586 dev->evport_offset); in sony_pic_irq()
4591 for (i = 0; dev->event_types[i].mask; i++) { in sony_pic_irq()
4593 if ((data_mask & dev->event_types[i].data) != in sony_pic_irq()
4594 dev->event_types[i].data) in sony_pic_irq()
4597 if (!(mask & dev->event_types[i].mask)) in sony_pic_irq()
4600 for (j = 0; dev->event_types[i].events[j].event; j++) { in sony_pic_irq()
4601 if (ev == dev->event_types[i].events[j].data) { in sony_pic_irq()
4603 dev->event_types[i].events[j].event; in sony_pic_irq()
4614 if (dev->handle_irq && dev->handle_irq(data_mask, ev) == 0) in sony_pic_irq()
4618 ev, data_mask, dev->cur_ioport->io1.minimum, in sony_pic_irq()
4619 dev->evport_offset); in sony_pic_irq()
4640 return -ENXIO; in sony_pic_remove()
4643 free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev); in sony_pic_remove()
4644 release_region(spic_dev.cur_ioport->io1.minimum, in sony_pic_remove()
4645 spic_dev.cur_ioport->io1.address_length); in sony_pic_remove()
4646 if (spic_dev.cur_ioport->io2.minimum) in sony_pic_remove()
4647 release_region(spic_dev.cur_ioport->io2.minimum, in sony_pic_remove()
4648 spic_dev.cur_ioport->io2.address_length); in sony_pic_remove()
4655 sysfs_remove_group(&sony_pf_device->dev.kobj, &spic_attribute_group); in sony_pic_remove()
4659 list_del(&io->list); in sony_pic_remove()
4663 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()
4858 DMI_MATCH(DMI_PRODUCT_NAME, "PCG-"),
4865 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-"),