Lines Matching refs:eeepc
3 * eeepc-laptop.c - Asus Eee PC extras
7 * Based on eee.c from eeepc-linux
35 #define EEEPC_LAPTOP_FILE "eeepc"
207 static int set_acpi(struct eeepc_laptop *eeepc, int cm, int value)
213 if ((eeepc->cm_supported & (0x1 << cm)) == 0)
216 if (write_acpi_int(eeepc->handle, method, value))
221 static int get_acpi(struct eeepc_laptop *eeepc, int cm)
228 if ((eeepc->cm_supported & (0x1 << cm)) == 0)
231 if (read_acpi_int(eeepc->handle, method, &value))
236 static int acpi_setter_handle(struct eeepc_laptop *eeepc, int cm,
244 if ((eeepc->cm_supported & (0x1 << cm)) == 0)
247 status = acpi_get_handle(eeepc->handle, (char *)method,
270 struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
276 rv = set_acpi(eeepc, cm, value);
284 struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
285 int value = get_acpi(eeepc, cm);
326 static int get_cpufv(struct eeepc_laptop *eeepc, struct eeepc_cpufv *c)
328 c->cur = get_acpi(eeepc, CM_ASL_CPUFV);
343 struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
348 if (get_cpufv(eeepc, &c))
360 struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
363 if (get_cpufv(eeepc, &c))
372 struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
376 if (eeepc->cpufv_disabled)
378 if (get_cpufv(eeepc, &c))
385 rv = set_acpi(eeepc, CM_ASL_CPUFV, value);
395 struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
397 return sprintf(buf, "%d\n", eeepc->cpufv_disabled);
404 struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
413 if (eeepc->cpufv_disabled)
415 eeepc->cpufv_disabled = false;
443 static int eeepc_platform_init(struct eeepc_laptop *eeepc)
447 eeepc->platform_device = platform_device_alloc(EEEPC_LAPTOP_FILE, PLATFORM_DEVID_NONE);
448 if (!eeepc->platform_device)
450 platform_set_drvdata(eeepc->platform_device, eeepc);
452 result = platform_device_add(eeepc->platform_device);
456 result = sysfs_create_group(&eeepc->platform_device->dev.kobj,
463 platform_device_del(eeepc->platform_device);
465 platform_device_put(eeepc->platform_device);
469 static void eeepc_platform_exit(struct eeepc_laptop *eeepc)
471 sysfs_remove_group(&eeepc->platform_device->dev.kobj,
473 platform_device_unregister(eeepc->platform_device);
487 struct eeepc_laptop *eeepc;
489 eeepc = container_of(work, struct eeepc_laptop, tpd_led_work);
491 set_acpi(eeepc, CM_ASL_TPD, eeepc->tpd_led_wk);
497 struct eeepc_laptop *eeepc;
499 eeepc = container_of(led_cdev, struct eeepc_laptop, tpd_led);
501 eeepc->tpd_led_wk = (value > 0) ? 1 : 0;
502 queue_work(eeepc->led_workqueue, &eeepc->tpd_led_work);
507 struct eeepc_laptop *eeepc;
509 eeepc = container_of(led_cdev, struct eeepc_laptop, tpd_led);
511 return get_acpi(eeepc, CM_ASL_TPD);
514 static int eeepc_led_init(struct eeepc_laptop *eeepc)
518 if (get_acpi(eeepc, CM_ASL_TPD) == -ENODEV)
521 eeepc->led_workqueue = create_singlethread_workqueue("led_workqueue");
522 if (!eeepc->led_workqueue)
524 INIT_WORK(&eeepc->tpd_led_work, tpd_led_update);
526 eeepc->tpd_led.name = "eeepc::touchpad";
527 eeepc->tpd_led.brightness_set = tpd_led_set;
528 if (get_acpi(eeepc, CM_ASL_TPD) >= 0) /* if method is available */
529 eeepc->tpd_led.brightness_get = tpd_led_get;
530 eeepc->tpd_led.max_brightness = 1;
532 rv = led_classdev_register(&eeepc->platform_device->dev,
533 &eeepc->tpd_led);
535 destroy_workqueue(eeepc->led_workqueue);
542 static void eeepc_led_exit(struct eeepc_laptop *eeepc)
544 led_classdev_unregister(&eeepc->tpd_led);
545 if (eeepc->led_workqueue)
546 destroy_workqueue(eeepc->led_workqueue);
552 static bool eeepc_wlan_rfkill_blocked(struct eeepc_laptop *eeepc)
554 if (get_acpi(eeepc, CM_ASL_WLAN) == 1)
559 static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc, acpi_handle handle)
564 bool blocked = eeepc_wlan_rfkill_blocked(eeepc);
568 if (eeepc->wlan_rfkill)
569 rfkill_set_sw_state(eeepc->wlan_rfkill, blocked);
571 mutex_lock(&eeepc->hotplug_lock);
574 if (!eeepc->hotplug_slot.ops)
629 mutex_unlock(&eeepc->hotplug_lock);
632 static void eeepc_rfkill_hotplug_update(struct eeepc_laptop *eeepc, char *node)
640 eeepc_rfkill_hotplug(eeepc, handle);
645 struct eeepc_laptop *eeepc = data;
650 eeepc_rfkill_hotplug(eeepc, handle);
653 static int eeepc_register_rfkill_notifier(struct eeepc_laptop *eeepc,
667 eeepc);
675 eeepc_rfkill_hotplug(eeepc, handle);
679 static void eeepc_unregister_rfkill_notifier(struct eeepc_laptop *eeepc,
701 eeepc_rfkill_hotplug(eeepc, handle);
707 struct eeepc_laptop *eeepc;
710 eeepc = container_of(hotplug_slot, struct eeepc_laptop, hotplug_slot);
711 val = get_acpi(eeepc, CM_ASL_WLAN);
726 static int eeepc_setup_pci_hotplug(struct eeepc_laptop *eeepc)
736 eeepc->hotplug_slot.ops = &eeepc_hotplug_slot_ops;
738 ret = pci_hp_register(&eeepc->hotplug_slot, bus, 0, "eeepc-wifi");
747 eeepc->hotplug_slot.ops = NULL;
765 static int eeepc_new_rfkill(struct eeepc_laptop *eeepc,
773 result = acpi_setter_handle(eeepc, cm, &handle);
777 *rfkill = rfkill_alloc(name, &eeepc->platform_device->dev, type,
783 rfkill_init_sw_state(*rfkill, get_acpi(eeepc, cm) != 1);
797 static void eeepc_rfkill_exit(struct eeepc_laptop *eeepc)
799 eeepc_unregister_rfkill_notifier(eeepc, EEEPC_RFKILL_NODE_1);
800 eeepc_unregister_rfkill_notifier(eeepc, EEEPC_RFKILL_NODE_2);
801 eeepc_unregister_rfkill_notifier(eeepc, EEEPC_RFKILL_NODE_3);
802 if (eeepc->wlan_rfkill) {
803 rfkill_unregister(eeepc->wlan_rfkill);
804 rfkill_destroy(eeepc->wlan_rfkill);
805 eeepc->wlan_rfkill = NULL;
808 if (eeepc->hotplug_slot.ops)
809 pci_hp_deregister(&eeepc->hotplug_slot);
811 if (eeepc->bluetooth_rfkill) {
812 rfkill_unregister(eeepc->bluetooth_rfkill);
813 rfkill_destroy(eeepc->bluetooth_rfkill);
814 eeepc->bluetooth_rfkill = NULL;
816 if (eeepc->wwan3g_rfkill) {
817 rfkill_unregister(eeepc->wwan3g_rfkill);
818 rfkill_destroy(eeepc->wwan3g_rfkill);
819 eeepc->wwan3g_rfkill = NULL;
821 if (eeepc->wimax_rfkill) {
822 rfkill_unregister(eeepc->wimax_rfkill);
823 rfkill_destroy(eeepc->wimax_rfkill);
824 eeepc->wimax_rfkill = NULL;
828 static int eeepc_rfkill_init(struct eeepc_laptop *eeepc)
832 mutex_init(&eeepc->hotplug_lock);
834 result = eeepc_new_rfkill(eeepc, &eeepc->wlan_rfkill,
835 "eeepc-wlan", RFKILL_TYPE_WLAN,
841 result = eeepc_new_rfkill(eeepc, &eeepc->bluetooth_rfkill,
842 "eeepc-bluetooth", RFKILL_TYPE_BLUETOOTH,
848 result = eeepc_new_rfkill(eeepc, &eeepc->wwan3g_rfkill,
849 "eeepc-wwan3g", RFKILL_TYPE_WWAN,
855 result = eeepc_new_rfkill(eeepc, &eeepc->wimax_rfkill,
856 "eeepc-wimax", RFKILL_TYPE_WIMAX,
862 if (eeepc->hotplug_disabled)
865 result = eeepc_setup_pci_hotplug(eeepc);
873 eeepc_register_rfkill_notifier(eeepc, EEEPC_RFKILL_NODE_1);
874 eeepc_register_rfkill_notifier(eeepc, EEEPC_RFKILL_NODE_2);
875 eeepc_register_rfkill_notifier(eeepc, EEEPC_RFKILL_NODE_3);
879 eeepc_rfkill_exit(eeepc);
888 struct eeepc_laptop *eeepc = dev_get_drvdata(device);
890 if (eeepc->wlan_rfkill) {
898 wlan = get_acpi(eeepc, CM_ASL_WLAN);
900 set_acpi(eeepc, CM_ASL_WLAN, wlan);
908 struct eeepc_laptop *eeepc = dev_get_drvdata(device);
911 if (eeepc->wlan_rfkill) {
912 eeepc_rfkill_hotplug_update(eeepc, EEEPC_RFKILL_NODE_1);
913 eeepc_rfkill_hotplug_update(eeepc, EEEPC_RFKILL_NODE_2);
914 eeepc_rfkill_hotplug_update(eeepc, EEEPC_RFKILL_NODE_3);
917 if (eeepc->bluetooth_rfkill)
918 rfkill_set_sw_state(eeepc->bluetooth_rfkill,
919 get_acpi(eeepc, CM_ASL_BLUETOOTH) != 1);
920 if (eeepc->wwan3g_rfkill)
921 rfkill_set_sw_state(eeepc->wwan3g_rfkill,
922 get_acpi(eeepc, CM_ASL_3G) != 1);
923 if (eeepc->wimax_rfkill)
924 rfkill_set_sw_state(eeepc->wimax_rfkill,
925 get_acpi(eeepc, CM_ASL_WIMAX) != 1);
1071 static int eeepc_hwmon_init(struct eeepc_laptop *eeepc)
1073 struct device *dev = &eeepc->platform_device->dev;
1076 hwmon = devm_hwmon_device_register_with_groups(dev, "eeepc", NULL,
1079 pr_err("Could not register eeepc hwmon device\n");
1090 struct eeepc_laptop *eeepc = bl_get_data(bd);
1092 return get_acpi(eeepc, CM_ASL_PANELBRIGHT);
1097 struct eeepc_laptop *eeepc = bl_get_data(bd);
1099 return set_acpi(eeepc, CM_ASL_PANELBRIGHT, value);
1112 static int eeepc_backlight_notify(struct eeepc_laptop *eeepc)
1114 struct backlight_device *bd = eeepc->backlight_device;
1122 static int eeepc_backlight_init(struct eeepc_laptop *eeepc)
1131 &eeepc->platform_device->dev, eeepc,
1134 pr_err("Could not register eeepc backlight device\n");
1135 eeepc->backlight_device = NULL;
1138 eeepc->backlight_device = bd;
1145 static void eeepc_backlight_exit(struct eeepc_laptop *eeepc)
1147 backlight_device_unregister(eeepc->backlight_device);
1148 eeepc->backlight_device = NULL;
1155 static int eeepc_input_init(struct eeepc_laptop *eeepc)
1167 input->dev.parent = &eeepc->platform_device->dev;
1181 eeepc->inputdev = input;
1189 static void eeepc_input_exit(struct eeepc_laptop *eeepc)
1191 if (eeepc->inputdev)
1192 input_unregister_device(eeepc->inputdev);
1193 eeepc->inputdev = NULL;
1199 static void eeepc_input_notify(struct eeepc_laptop *eeepc, int event)
1201 if (!eeepc->inputdev)
1203 if (!sparse_keymap_report_event(eeepc->inputdev, event, 1, true))
1209 struct eeepc_laptop *eeepc = acpi_driver_data(device);
1215 count = eeepc->event_count[event % 128]++;
1222 eeepc_input_notify(eeepc, event);
1227 if (!eeepc->backlight_device)
1231 old_brightness = eeepc_backlight_notify(eeepc);
1246 eeepc_input_notify(eeepc, event);
1249 static void eeepc_dmi_check(struct eeepc_laptop *eeepc)
1277 eeepc->cpufv_disabled = true;
1292 eeepc->hotplug_disabled = true;
1297 static void cmsg_quirk(struct eeepc_laptop *eeepc, int cm, const char *name)
1303 if (!(eeepc->cm_supported & (1 << cm))
1304 && !read_acpi_int(eeepc->handle, cm_getv[cm], &dummy)) {
1307 eeepc->cm_supported |= 1 << cm;
1311 static void cmsg_quirks(struct eeepc_laptop *eeepc)
1313 cmsg_quirk(eeepc, CM_ASL_LID, "LID");
1314 cmsg_quirk(eeepc, CM_ASL_TYPE, "TYPE");
1315 cmsg_quirk(eeepc, CM_ASL_PANELPOWER, "PANELPOWER");
1316 cmsg_quirk(eeepc, CM_ASL_TPD, "TPD");
1319 static int eeepc_acpi_init(struct eeepc_laptop *eeepc)
1324 result = acpi_bus_get_status(eeepc->device);
1327 if (!eeepc->device->status.present) {
1335 if (write_acpi_int(eeepc->handle, "INIT", init_flags)) {
1341 if (read_acpi_int(eeepc->handle, "CMSG", &eeepc->cm_supported)) {
1345 cmsg_quirks(eeepc);
1346 pr_info("Get control methods supported: 0x%x\n", eeepc->cm_supported);
1351 static void eeepc_enable_camera(struct eeepc_laptop *eeepc)
1357 if (get_acpi(eeepc, CM_ASL_CAMERA) == 0)
1358 set_acpi(eeepc, CM_ASL_CAMERA, 1);
1365 struct eeepc_laptop *eeepc;
1369 eeepc = kzalloc(sizeof(struct eeepc_laptop), GFP_KERNEL);
1370 if (!eeepc)
1372 eeepc->handle = device->handle;
1375 device->driver_data = eeepc;
1376 eeepc->device = device;
1378 eeepc->hotplug_disabled = hotplug_disabled;
1380 eeepc_dmi_check(eeepc);
1382 result = eeepc_acpi_init(eeepc);
1385 eeepc_enable_camera(eeepc);
1399 result = eeepc_platform_init(eeepc);
1404 result = eeepc_backlight_init(eeepc);
1409 result = eeepc_input_init(eeepc);
1413 result = eeepc_hwmon_init(eeepc);
1417 result = eeepc_led_init(eeepc);
1421 result = eeepc_rfkill_init(eeepc);
1429 eeepc_led_exit(eeepc);
1432 eeepc_input_exit(eeepc);
1434 eeepc_backlight_exit(eeepc);
1436 eeepc_platform_exit(eeepc);
1438 kfree(eeepc);
1445 struct eeepc_laptop *eeepc = acpi_driver_data(device);
1447 eeepc_backlight_exit(eeepc);
1448 eeepc_rfkill_exit(eeepc);
1449 eeepc_input_exit(eeepc);
1450 eeepc_led_exit(eeepc);
1451 eeepc_platform_exit(eeepc);
1453 kfree(eeepc);