Lines Matching +full:led +full:- +full:cur

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * eeepc-laptop.c - Asus Eee PC extras
7 * Based on eee.c from eeepc-linux
20 #include <linux/hwmon-sysfs.h>
25 #include <linux/input/sparse-keymap.h>
51 "acpi4asus-user@lists.sourceforge.net.");
189 return (status == AE_OK ? 0 : -1); in write_acpi_int()
199 *val = -1; in read_acpi_int()
200 return -1; in read_acpi_int()
212 return -ENODEV; in set_acpi()
213 if ((eeepc->cm_supported & (0x1 << cm)) == 0) in set_acpi()
214 return -ENODEV; in set_acpi()
216 if (write_acpi_int(eeepc->handle, method, value)) in set_acpi()
227 return -ENODEV; in get_acpi()
228 if ((eeepc->cm_supported & (0x1 << cm)) == 0) in get_acpi()
229 return -ENODEV; in get_acpi()
231 if (read_acpi_int(eeepc->handle, method, &value)) in get_acpi()
243 return -ENODEV; in acpi_setter_handle()
244 if ((eeepc->cm_supported & (0x1 << cm)) == 0) in acpi_setter_handle()
245 return -ENODEV; in acpi_setter_handle()
247 status = acpi_get_handle(eeepc->handle, (char *)method, in acpi_setter_handle()
251 return -ENODEV; in acpi_setter_handle()
263 return -EINVAL; in parse_arg()
278 return -EIO; in store_sys_acpi()
288 return -EIO; in show_sys_acpi()
323 int cur; member
328 c->cur = get_acpi(eeepc, CM_ASL_CPUFV); in get_cpufv()
329 if (c->cur < 0) in get_cpufv()
330 return -ENODEV; in get_cpufv()
332 c->num = (c->cur >> 8) & 0xff; in get_cpufv()
333 c->cur &= 0xff; in get_cpufv()
334 if (c->num == 0 || c->num > 12) in get_cpufv()
335 return -ENODEV; in get_cpufv()
349 return -ENODEV; in available_cpufv_show()
364 return -ENODEV; in cpufv_show()
365 return sprintf(buf, "%#x\n", (c.num << 8) | c.cur); in cpufv_show()
376 if (eeepc->cpufv_disabled) in cpufv_store()
377 return -EPERM; in cpufv_store()
379 return -ENODEV; in cpufv_store()
384 return -EINVAL; in cpufv_store()
397 return sprintf(buf, "%d\n", eeepc->cpufv_disabled); in cpufv_disabled_show()
413 if (eeepc->cpufv_disabled) in cpufv_disabled_store()
415 eeepc->cpufv_disabled = false; in cpufv_disabled_store()
418 return -EPERM; in cpufv_disabled_store()
420 return -EINVAL; in cpufv_disabled_store()
447 eeepc->platform_device = platform_device_alloc(EEEPC_LAPTOP_FILE, PLATFORM_DEVID_NONE); in eeepc_platform_init()
448 if (!eeepc->platform_device) in eeepc_platform_init()
449 return -ENOMEM; in eeepc_platform_init()
450 platform_set_drvdata(eeepc->platform_device, eeepc); in eeepc_platform_init()
452 result = platform_device_add(eeepc->platform_device); in eeepc_platform_init()
456 result = sysfs_create_group(&eeepc->platform_device->dev.kobj, in eeepc_platform_init()
463 platform_device_del(eeepc->platform_device); in eeepc_platform_init()
465 platform_device_put(eeepc->platform_device); in eeepc_platform_init()
471 sysfs_remove_group(&eeepc->platform_device->dev.kobj, in eeepc_platform_exit()
473 platform_device_unregister(eeepc->platform_device); in eeepc_platform_exit()
480 * These functions actually update the LED's, and are called from a
481 * workqueue. By doing this as separate work rather than when the LED
491 set_acpi(eeepc, CM_ASL_TPD, eeepc->tpd_led_wk); in tpd_led_update()
501 eeepc->tpd_led_wk = (value > 0) ? 1 : 0; in tpd_led_set()
502 queue_work(eeepc->led_workqueue, &eeepc->tpd_led_work); in tpd_led_set()
518 if (get_acpi(eeepc, CM_ASL_TPD) == -ENODEV) in eeepc_led_init()
521 eeepc->led_workqueue = create_singlethread_workqueue("led_workqueue"); in eeepc_led_init()
522 if (!eeepc->led_workqueue) in eeepc_led_init()
523 return -ENOMEM; in eeepc_led_init()
524 INIT_WORK(&eeepc->tpd_led_work, tpd_led_update); in eeepc_led_init()
526 eeepc->tpd_led.name = "eeepc::touchpad"; in eeepc_led_init()
527 eeepc->tpd_led.brightness_set = tpd_led_set; in eeepc_led_init()
529 eeepc->tpd_led.brightness_get = tpd_led_get; in eeepc_led_init()
530 eeepc->tpd_led.max_brightness = 1; in eeepc_led_init()
532 rv = led_classdev_register(&eeepc->platform_device->dev, in eeepc_led_init()
533 &eeepc->tpd_led); in eeepc_led_init()
535 destroy_workqueue(eeepc->led_workqueue); in eeepc_led_init()
544 led_classdev_unregister(&eeepc->tpd_led); in eeepc_led_exit()
545 if (eeepc->led_workqueue) in eeepc_led_exit()
546 destroy_workqueue(eeepc->led_workqueue); in eeepc_led_exit()
568 if (eeepc->wlan_rfkill) in eeepc_rfkill_hotplug()
569 rfkill_set_sw_state(eeepc->wlan_rfkill, blocked); in eeepc_rfkill_hotplug()
571 mutex_lock(&eeepc->hotplug_lock); in eeepc_rfkill_hotplug()
574 if (!eeepc->hotplug_slot.ops) in eeepc_rfkill_hotplug()
583 bus = port->subordinate; in eeepc_rfkill_hotplug()
629 mutex_unlock(&eeepc->hotplug_lock); in eeepc_rfkill_hotplug()
662 return -ENODEV; in eeepc_register_rfkill_notifier()
716 return -EINVAL; in eeepc_get_adapter_status()
728 int ret = -ENOMEM; in eeepc_setup_pci_hotplug()
733 return -ENODEV; in eeepc_setup_pci_hotplug()
736 eeepc->hotplug_slot.ops = &eeepc_hotplug_slot_ops; in eeepc_setup_pci_hotplug()
738 ret = pci_hp_register(&eeepc->hotplug_slot, bus, 0, "eeepc-wifi"); in eeepc_setup_pci_hotplug()
740 pr_err("Unable to register hotplug slot - %d\n", ret); in eeepc_setup_pci_hotplug()
747 eeepc->hotplug_slot.ops = NULL; in eeepc_setup_pci_hotplug()
777 *rfkill = rfkill_alloc(name, &eeepc->platform_device->dev, type, in eeepc_new_rfkill()
781 return -EINVAL; in eeepc_new_rfkill()
802 if (eeepc->wlan_rfkill) { in eeepc_rfkill_exit()
803 rfkill_unregister(eeepc->wlan_rfkill); in eeepc_rfkill_exit()
804 rfkill_destroy(eeepc->wlan_rfkill); in eeepc_rfkill_exit()
805 eeepc->wlan_rfkill = NULL; in eeepc_rfkill_exit()
808 if (eeepc->hotplug_slot.ops) in eeepc_rfkill_exit()
809 pci_hp_deregister(&eeepc->hotplug_slot); in eeepc_rfkill_exit()
811 if (eeepc->bluetooth_rfkill) { in eeepc_rfkill_exit()
812 rfkill_unregister(eeepc->bluetooth_rfkill); in eeepc_rfkill_exit()
813 rfkill_destroy(eeepc->bluetooth_rfkill); in eeepc_rfkill_exit()
814 eeepc->bluetooth_rfkill = NULL; in eeepc_rfkill_exit()
816 if (eeepc->wwan3g_rfkill) { in eeepc_rfkill_exit()
817 rfkill_unregister(eeepc->wwan3g_rfkill); in eeepc_rfkill_exit()
818 rfkill_destroy(eeepc->wwan3g_rfkill); in eeepc_rfkill_exit()
819 eeepc->wwan3g_rfkill = NULL; in eeepc_rfkill_exit()
821 if (eeepc->wimax_rfkill) { in eeepc_rfkill_exit()
822 rfkill_unregister(eeepc->wimax_rfkill); in eeepc_rfkill_exit()
823 rfkill_destroy(eeepc->wimax_rfkill); in eeepc_rfkill_exit()
824 eeepc->wimax_rfkill = NULL; in eeepc_rfkill_exit()
832 mutex_init(&eeepc->hotplug_lock); in eeepc_rfkill_init()
834 result = eeepc_new_rfkill(eeepc, &eeepc->wlan_rfkill, in eeepc_rfkill_init()
835 "eeepc-wlan", RFKILL_TYPE_WLAN, in eeepc_rfkill_init()
838 if (result && result != -ENODEV) in eeepc_rfkill_init()
841 result = eeepc_new_rfkill(eeepc, &eeepc->bluetooth_rfkill, in eeepc_rfkill_init()
842 "eeepc-bluetooth", RFKILL_TYPE_BLUETOOTH, in eeepc_rfkill_init()
845 if (result && result != -ENODEV) in eeepc_rfkill_init()
848 result = eeepc_new_rfkill(eeepc, &eeepc->wwan3g_rfkill, in eeepc_rfkill_init()
849 "eeepc-wwan3g", RFKILL_TYPE_WWAN, in eeepc_rfkill_init()
852 if (result && result != -ENODEV) in eeepc_rfkill_init()
855 result = eeepc_new_rfkill(eeepc, &eeepc->wimax_rfkill, in eeepc_rfkill_init()
856 "eeepc-wimax", RFKILL_TYPE_WIMAX, in eeepc_rfkill_init()
859 if (result && result != -ENODEV) in eeepc_rfkill_init()
862 if (eeepc->hotplug_disabled) in eeepc_rfkill_init()
867 * If we get -EBUSY then something else is handling the PCI hotplug - in eeepc_rfkill_init()
870 if (result == -EBUSY) in eeepc_rfkill_init()
878 if (result && result != -ENODEV) in eeepc_rfkill_init()
884 * Platform driver - hibernate/resume callbacks
890 if (eeepc->wlan_rfkill) { in eeepc_hotk_thaw()
894 * Work around bios bug - acpi _PTS turns off the wireless led in eeepc_hotk_thaw()
911 if (eeepc->wlan_rfkill) { in eeepc_hotk_restore()
917 if (eeepc->bluetooth_rfkill) in eeepc_hotk_restore()
918 rfkill_set_sw_state(eeepc->bluetooth_rfkill, in eeepc_hotk_restore()
920 if (eeepc->wwan3g_rfkill) in eeepc_hotk_restore()
921 rfkill_set_sw_state(eeepc->wwan3g_rfkill, in eeepc_hotk_restore()
923 if (eeepc->wimax_rfkill) in eeepc_hotk_restore()
924 rfkill_set_sw_state(eeepc->wimax_rfkill, in eeepc_hotk_restore()
1073 struct device *dev = &eeepc->platform_device->dev; in eeepc_hwmon_init()
1104 return set_brightness(bd, bd->props.brightness); in update_bl_status()
1114 struct backlight_device *bd = eeepc->backlight_device; in eeepc_backlight_notify()
1115 int old = bd->props.brightness; in eeepc_backlight_notify()
1131 &eeepc->platform_device->dev, eeepc, in eeepc_backlight_init()
1135 eeepc->backlight_device = NULL; in eeepc_backlight_init()
1138 eeepc->backlight_device = bd; in eeepc_backlight_init()
1139 bd->props.brightness = read_brightness(bd); in eeepc_backlight_init()
1140 bd->props.power = FB_BLANK_UNBLANK; in eeepc_backlight_init()
1147 backlight_device_unregister(eeepc->backlight_device); in eeepc_backlight_exit()
1148 eeepc->backlight_device = NULL; in eeepc_backlight_exit()
1162 return -ENOMEM; in eeepc_input_init()
1164 input->name = "Asus EeePC extra buttons"; in eeepc_input_init()
1165 input->phys = EEEPC_LAPTOP_FILE "/input0"; in eeepc_input_init()
1166 input->id.bustype = BUS_HOST; in eeepc_input_init()
1167 input->dev.parent = &eeepc->platform_device->dev; in eeepc_input_init()
1181 eeepc->inputdev = input; in eeepc_input_init()
1191 if (eeepc->inputdev) in eeepc_input_exit()
1192 input_unregister_device(eeepc->inputdev); in eeepc_input_exit()
1193 eeepc->inputdev = NULL; in eeepc_input_exit()
1201 if (!eeepc->inputdev) in eeepc_input_notify()
1203 if (!sparse_keymap_report_event(eeepc->inputdev, event, 1, true)) in eeepc_input_notify()
1215 count = eeepc->event_count[event % 128]++; in eeepc_acpi_notify()
1216 acpi_bus_generate_netlink_event(device->pnp.device_class, in eeepc_acpi_notify()
1217 dev_name(&device->dev), event, in eeepc_acpi_notify()
1227 if (!eeepc->backlight_device) in eeepc_acpi_notify()
1234 new_brightness = event - NOTIFY_BRN_MIN; in eeepc_acpi_notify()
1242 * no change in brightness - already at min/max, in eeepc_acpi_notify()
1261 * by the pre-installed OS, and the original option to change it in eeepc_dmi_check()
1277 eeepc->cpufv_disabled = true; in eeepc_dmi_check()
1292 eeepc->hotplug_disabled = true; in eeepc_dmi_check()
1303 if (!(eeepc->cm_supported & (1 << cm)) in cmsg_quirk()
1304 && !read_acpi_int(eeepc->handle, cm_getv[cm], &dummy)) { in cmsg_quirk()
1307 eeepc->cm_supported |= 1 << cm; in cmsg_quirk()
1324 result = acpi_bus_get_status(eeepc->device); in eeepc_acpi_init()
1327 if (!eeepc->device->status.present) { in eeepc_acpi_init()
1329 return -ENODEV; in eeepc_acpi_init()
1335 if (write_acpi_int(eeepc->handle, "INIT", init_flags)) { in eeepc_acpi_init()
1337 return -ENODEV; in eeepc_acpi_init()
1341 if (read_acpi_int(eeepc->handle, "CMSG", &eeepc->cm_supported)) { in eeepc_acpi_init()
1343 return -ENODEV; in eeepc_acpi_init()
1346 pr_info("Get control methods supported: 0x%x\n", eeepc->cm_supported); in eeepc_acpi_init()
1371 return -ENOMEM; in eeepc_acpi_add()
1372 eeepc->handle = device->handle; in eeepc_acpi_add()
1375 device->driver_data = eeepc; in eeepc_acpi_add()
1376 eeepc->device = device; in eeepc_acpi_add()
1378 eeepc->hotplug_disabled = hotplug_disabled; in eeepc_acpi_add()
1389 * sub-devices below. in eeepc_acpi_add()
1394 * and machine-specific scripts find the fixed name convenient. But in eeepc_acpi_add()
1491 result = -ENODEV; in eeepc_laptop_init()