Lines Matching refs:eeepc
2 * eeepc-laptop.c - Asus Eee PC extras
6 * Based on eee.c from eeepc-linux
44 #define EEEPC_LAPTOP_FILE "eeepc"
220 static int set_acpi(struct eeepc_laptop *eeepc, int cm, int value)
226 if ((eeepc->cm_supported & (0x1 << cm)) == 0)
229 if (write_acpi_int(eeepc->handle, method, value))
234 static int get_acpi(struct eeepc_laptop *eeepc, int cm)
241 if ((eeepc->cm_supported & (0x1 << cm)) == 0)
244 if (read_acpi_int(eeepc->handle, method, &value))
249 static int acpi_setter_handle(struct eeepc_laptop *eeepc, int cm,
257 if ((eeepc->cm_supported & (0x1 << cm)) == 0)
260 status = acpi_get_handle(eeepc->handle, (char *)method,
285 struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
290 value = set_acpi(eeepc, cm, value);
298 struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
299 int value = get_acpi(eeepc, cm);
336 static int get_cpufv(struct eeepc_laptop *eeepc, struct eeepc_cpufv *c)
338 c->cur = get_acpi(eeepc, CM_ASL_CPUFV);
350 struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
355 if (get_cpufv(eeepc, &c))
367 struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
370 if (get_cpufv(eeepc, &c))
379 struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
383 if (eeepc->cpufv_disabled)
385 if (get_cpufv(eeepc, &c))
392 set_acpi(eeepc, CM_ASL_CPUFV, value);
400 struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
402 return sprintf(buf, "%d\n", eeepc->cpufv_disabled);
409 struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
418 if (eeepc->cpufv_disabled)
421 eeepc->cpufv_disabled = false;
469 static int eeepc_platform_init(struct eeepc_laptop *eeepc)
473 eeepc->platform_device = platform_device_alloc(EEEPC_LAPTOP_FILE, -1);
474 if (!eeepc->platform_device)
476 platform_set_drvdata(eeepc->platform_device, eeepc);
478 result = platform_device_add(eeepc->platform_device);
482 result = sysfs_create_group(&eeepc->platform_device->dev.kobj,
489 platform_device_del(eeepc->platform_device);
491 platform_device_put(eeepc->platform_device);
495 static void eeepc_platform_exit(struct eeepc_laptop *eeepc)
497 sysfs_remove_group(&eeepc->platform_device->dev.kobj,
499 platform_device_unregister(eeepc->platform_device);
513 struct eeepc_laptop *eeepc;
515 eeepc = container_of(work, struct eeepc_laptop, tpd_led_work);
517 set_acpi(eeepc, CM_ASL_TPD, eeepc->tpd_led_wk);
523 struct eeepc_laptop *eeepc;
525 eeepc = container_of(led_cdev, struct eeepc_laptop, tpd_led);
527 eeepc->tpd_led_wk = (value > 0) ? 1 : 0;
528 queue_work(eeepc->led_workqueue, &eeepc->tpd_led_work);
531 static int eeepc_led_init(struct eeepc_laptop *eeepc)
535 if (get_acpi(eeepc, CM_ASL_TPD) == -ENODEV)
538 eeepc->led_workqueue = create_singlethread_workqueue("led_workqueue");
539 if (!eeepc->led_workqueue)
541 INIT_WORK(&eeepc->tpd_led_work, tpd_led_update);
543 eeepc->tpd_led.name = "eeepc::touchpad";
544 eeepc->tpd_led.brightness_set = tpd_led_set;
545 eeepc->tpd_led.max_brightness = 1;
547 rv = led_classdev_register(&eeepc->platform_device->dev,
548 &eeepc->tpd_led);
550 destroy_workqueue(eeepc->led_workqueue);
557 static void eeepc_led_exit(struct eeepc_laptop *eeepc)
559 if (eeepc->tpd_led.dev)
560 led_classdev_unregister(&eeepc->tpd_led);
561 if (eeepc->led_workqueue)
562 destroy_workqueue(eeepc->led_workqueue);
569 static bool eeepc_wlan_rfkill_blocked(struct eeepc_laptop *eeepc)
571 if (get_acpi(eeepc, CM_ASL_WLAN) == 1)
576 static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc)
580 bool blocked = eeepc_wlan_rfkill_blocked(eeepc);
584 if (eeepc->wlan_rfkill)
585 rfkill_set_sw_state(eeepc->wlan_rfkill, blocked);
587 mutex_lock(&eeepc->hotplug_lock);
589 if (eeepc->hotplug_slot) {
635 mutex_unlock(&eeepc->hotplug_lock);
640 struct eeepc_laptop *eeepc = data;
645 eeepc_rfkill_hotplug(eeepc);
648 static int eeepc_register_rfkill_notifier(struct eeepc_laptop *eeepc,
660 eeepc);
669 static void eeepc_unregister_rfkill_notifier(struct eeepc_laptop *eeepc,
690 struct eeepc_laptop *eeepc = hotplug_slot->private;
691 int val = get_acpi(eeepc, CM_ASL_WLAN);
713 static int eeepc_setup_pci_hotplug(struct eeepc_laptop *eeepc)
723 eeepc->hotplug_slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
724 if (!eeepc->hotplug_slot)
727 eeepc->hotplug_slot->info = kzalloc(sizeof(struct hotplug_slot_info),
729 if (!eeepc->hotplug_slot->info)
732 eeepc->hotplug_slot->private = eeepc;
733 eeepc->hotplug_slot->release = &eeepc_cleanup_pci_hotplug;
734 eeepc->hotplug_slot->ops = &eeepc_hotplug_slot_ops;
735 eeepc_get_adapter_status(eeepc->hotplug_slot,
736 &eeepc->hotplug_slot->info->adapter_status);
738 ret = pci_hp_register(eeepc->hotplug_slot, bus, 0, "eeepc-wifi");
747 kfree(eeepc->hotplug_slot->info);
749 kfree(eeepc->hotplug_slot);
750 eeepc->hotplug_slot = NULL;
769 static int eeepc_new_rfkill(struct eeepc_laptop *eeepc,
777 result = acpi_setter_handle(eeepc, cm, &handle);
781 *rfkill = rfkill_alloc(name, &eeepc->platform_device->dev, type,
787 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, "\\_SB.PCI0.P0P5");
800 eeepc_unregister_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P6");
801 eeepc_unregister_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P7");
802 if (eeepc->wlan_rfkill) {
803 rfkill_unregister(eeepc->wlan_rfkill);
804 rfkill_destroy(eeepc->wlan_rfkill);
805 eeepc->wlan_rfkill = NULL;
811 eeepc_rfkill_hotplug(eeepc);
812 if (eeepc->hotplug_slot)
813 pci_hp_deregister(eeepc->hotplug_slot);
815 if (eeepc->bluetooth_rfkill) {
816 rfkill_unregister(eeepc->bluetooth_rfkill);
817 rfkill_destroy(eeepc->bluetooth_rfkill);
818 eeepc->bluetooth_rfkill = NULL;
820 if (eeepc->wwan3g_rfkill) {
821 rfkill_unregister(eeepc->wwan3g_rfkill);
822 rfkill_destroy(eeepc->wwan3g_rfkill);
823 eeepc->wwan3g_rfkill = NULL;
825 if (eeepc->wimax_rfkill) {
826 rfkill_unregister(eeepc->wimax_rfkill);
827 rfkill_destroy(eeepc->wimax_rfkill);
828 eeepc->wimax_rfkill = NULL;
832 static int eeepc_rfkill_init(struct eeepc_laptop *eeepc)
836 mutex_init(&eeepc->hotplug_lock);
838 result = eeepc_new_rfkill(eeepc, &eeepc->wlan_rfkill,
839 "eeepc-wlan", RFKILL_TYPE_WLAN,
845 result = eeepc_new_rfkill(eeepc, &eeepc->bluetooth_rfkill,
846 "eeepc-bluetooth", RFKILL_TYPE_BLUETOOTH,
852 result = eeepc_new_rfkill(eeepc, &eeepc->wwan3g_rfkill,
853 "eeepc-wwan3g", RFKILL_TYPE_WWAN,
859 result = eeepc_new_rfkill(eeepc, &eeepc->wimax_rfkill,
860 "eeepc-wimax", RFKILL_TYPE_WIMAX,
866 if (eeepc->hotplug_disabled)
869 result = eeepc_setup_pci_hotplug(eeepc);
877 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P5");
878 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P6");
879 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P7");
884 eeepc_rfkill_hotplug(eeepc);
888 eeepc_rfkill_exit(eeepc);
897 struct eeepc_laptop *eeepc = dev_get_drvdata(device);
899 if (eeepc->wlan_rfkill) {
902 wlan = get_acpi(eeepc, CM_ASL_WLAN);
903 set_acpi(eeepc, CM_ASL_WLAN, wlan);
911 struct eeepc_laptop *eeepc = dev_get_drvdata(device);
914 if (eeepc->wlan_rfkill)
915 eeepc_rfkill_hotplug(eeepc);
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);
1042 return sprintf(buf, "eeepc\n");
1058 static void eeepc_hwmon_exit(struct eeepc_laptop *eeepc)
1062 hwmon = eeepc->hwmon_device;
1068 eeepc->hwmon_device = NULL;
1071 static int eeepc_hwmon_init(struct eeepc_laptop *eeepc)
1076 hwmon = hwmon_device_register(&eeepc->platform_device->dev);
1078 pr_err("Could not register eeepc hwmon device\n");
1079 eeepc->hwmon_device = NULL;
1082 eeepc->hwmon_device = hwmon;
1086 eeepc_hwmon_exit(eeepc);
1095 struct eeepc_laptop *eeepc = bl_get_data(bd);
1097 return get_acpi(eeepc, CM_ASL_PANELBRIGHT);
1102 struct eeepc_laptop *eeepc = bl_get_data(bd);
1104 return set_acpi(eeepc, CM_ASL_PANELBRIGHT, value);
1117 static int eeepc_backlight_notify(struct eeepc_laptop *eeepc)
1119 struct backlight_device *bd = eeepc->backlight_device;
1127 static int eeepc_backlight_init(struct eeepc_laptop *eeepc)
1135 &eeepc->platform_device->dev, eeepc,
1138 pr_err("Could not register eeepc backlight device\n");
1139 eeepc->backlight_device = NULL;
1142 eeepc->backlight_device = bd;
1149 static void eeepc_backlight_exit(struct eeepc_laptop *eeepc)
1151 if (eeepc->backlight_device)
1152 backlight_device_unregister(eeepc->backlight_device);
1153 eeepc->backlight_device = NULL;
1160 static int eeepc_input_init(struct eeepc_laptop *eeepc)
1174 input->dev.parent = &eeepc->platform_device->dev;
1188 eeepc->inputdev = input;
1198 static void eeepc_input_exit(struct eeepc_laptop *eeepc)
1200 if (eeepc->inputdev) {
1201 sparse_keymap_free(eeepc->inputdev);
1202 input_unregister_device(eeepc->inputdev);
1211 struct eeepc_laptop *eeepc = acpi_driver_data(device);
1216 count = eeepc->event_count[event % 128]++;
1226 if (eeepc->backlight_device != NULL) {
1230 old_brightness = eeepc_backlight_notify(eeepc);
1245 sparse_keymap_report_event(eeepc->inputdev, event,
1250 sparse_keymap_report_event(eeepc->inputdev, event, 1, true);
1254 static void eeepc_dmi_check(struct eeepc_laptop *eeepc)
1282 eeepc->cpufv_disabled = true;
1297 eeepc->hotplug_disabled = true;
1302 static void cmsg_quirk(struct eeepc_laptop *eeepc, int cm, const char *name)
1308 if (!(eeepc->cm_supported & (1 << cm))
1309 && !read_acpi_int(eeepc->handle, cm_getv[cm], &dummy)) {
1312 eeepc->cm_supported |= 1 << cm;
1316 static void cmsg_quirks(struct eeepc_laptop *eeepc)
1318 cmsg_quirk(eeepc, CM_ASL_LID, "LID");
1319 cmsg_quirk(eeepc, CM_ASL_TYPE, "TYPE");
1320 cmsg_quirk(eeepc, CM_ASL_PANELPOWER, "PANELPOWER");
1321 cmsg_quirk(eeepc, CM_ASL_TPD, "TPD");
1324 static int eeepc_acpi_init(struct eeepc_laptop *eeepc,
1341 if (write_acpi_int(eeepc->handle, "INIT", init_flags)) {
1347 if (read_acpi_int(eeepc->handle, "CMSG", &eeepc->cm_supported)) {
1351 cmsg_quirks(eeepc);
1352 pr_info("Get control methods supported: 0x%x\n", eeepc->cm_supported);
1357 static void __devinit eeepc_enable_camera(struct eeepc_laptop *eeepc)
1363 if (get_acpi(eeepc, CM_ASL_CAMERA) == 0)
1364 set_acpi(eeepc, CM_ASL_CAMERA, 1);
1371 struct eeepc_laptop *eeepc;
1375 eeepc = kzalloc(sizeof(struct eeepc_laptop), GFP_KERNEL);
1376 if (!eeepc)
1378 eeepc->handle = device->handle;
1381 device->driver_data = eeepc;
1383 eeepc->hotplug_disabled = hotplug_disabled;
1385 eeepc_dmi_check(eeepc);
1387 result = eeepc_acpi_init(eeepc, device);
1390 eeepc_enable_camera(eeepc);
1404 result = eeepc_platform_init(eeepc);
1409 result = eeepc_backlight_init(eeepc);
1415 result = eeepc_input_init(eeepc);
1419 result = eeepc_hwmon_init(eeepc);
1423 result = eeepc_led_init(eeepc);
1427 result = eeepc_rfkill_init(eeepc);
1435 eeepc_led_exit(eeepc);
1437 eeepc_hwmon_exit(eeepc);
1439 eeepc_input_exit(eeepc);
1441 eeepc_backlight_exit(eeepc);
1443 eeepc_platform_exit(eeepc);
1445 kfree(eeepc);
1452 struct eeepc_laptop *eeepc = acpi_driver_data(device);
1454 eeepc_backlight_exit(eeepc);
1455 eeepc_rfkill_exit(eeepc);
1456 eeepc_input_exit(eeepc);
1457 eeepc_hwmon_exit(eeepc);
1458 eeepc_led_exit(eeepc);
1459 eeepc_platform_exit(eeepc);
1461 kfree(eeepc);