1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * A hwmon driver for ACPI 4.0 power meters
4 * Copyright (C) 2009 IBM
9 #include <linux/module.h>
10 #include <linux/hwmon.h>
11 #include <linux/hwmon-sysfs.h>
12 #include <linux/jiffies.h>
13 #include <linux/mutex.h>
14 #include <linux/dmi.h>
15 #include <linux/slab.h>
16 #include <linux/kdev_t.h>
17 #include <linux/sched.h>
18 #include <linux/time.h>
19 #include <linux/err.h>
20 #include <linux/acpi.h>
22 #define ACPI_POWER_METER_NAME "power_meter"
23 #define ACPI_POWER_METER_DEVICE_NAME "Power Meter"
24 #define ACPI_POWER_METER_CLASS "pwr_meter_resource"
26 #define NUM_SENSORS 17
28 #define POWER_METER_CAN_MEASURE (1 << 0)
29 #define POWER_METER_CAN_TRIP (1 << 1)
30 #define POWER_METER_CAN_CAP (1 << 2)
31 #define POWER_METER_CAN_NOTIFY (1 << 3)
32 #define POWER_METER_IS_BATTERY (1 << 8)
33 #define UNKNOWN_HYSTERESIS 0xFFFFFFFF
34 #define UNKNOWN_POWER 0xFFFFFFFF
36 #define METER_NOTIFY_CONFIG 0x80
37 #define METER_NOTIFY_TRIP 0x81
38 #define METER_NOTIFY_CAP 0x82
39 #define METER_NOTIFY_CAPPING 0x83
40 #define METER_NOTIFY_INTERVAL 0x84
42 #define POWER_AVERAGE_NAME "power1_average"
43 #define POWER_CAP_NAME "power1_cap"
44 #define POWER_AVG_INTERVAL_NAME "power1_average_interval"
45 #define POWER_ALARM_NAME "power1_alarm"
47 static int cap_in_hardware;
48 static bool force_cap_on;
50 static int can_cap_in_hardware(void)
52 return force_cap_on || cap_in_hardware;
55 static const struct acpi_device_id power_meter_ids[] = {
59 MODULE_DEVICE_TABLE(acpi, power_meter_ids);
61 struct acpi_power_meter_capabilities {
75 struct acpi_power_meter_resource {
76 struct acpi_device *acpi_dev;
79 struct device *hwmon_dev;
80 struct acpi_power_meter_capabilities caps;
81 acpi_string model_number;
82 acpi_string serial_number;
89 unsigned long sensors_last_updated;
90 struct sensor_device_attribute sensors[NUM_SENSORS];
93 int num_domain_devices;
94 struct acpi_device **domain_devices;
95 struct kobject *holders_dir;
98 struct sensor_template {
100 ssize_t (*show)(struct device *dev,
101 struct device_attribute *devattr,
103 ssize_t (*set)(struct device *dev,
104 struct device_attribute *devattr,
105 const char *buf, size_t count);
109 /* Averaging interval */
110 static int update_avg_interval(struct acpi_power_meter_resource *resource)
112 unsigned long long data;
115 status = acpi_evaluate_integer(resource->acpi_dev->handle, "_GAI",
117 if (ACPI_FAILURE(status)) {
118 acpi_evaluation_failure_warn(resource->acpi_dev->handle, "_GAI",
123 resource->avg_interval = data;
127 static ssize_t show_avg_interval(struct device *dev,
128 struct device_attribute *devattr,
131 struct acpi_device *acpi_dev = to_acpi_device(dev);
132 struct acpi_power_meter_resource *resource = acpi_dev->driver_data;
134 mutex_lock(&resource->lock);
135 update_avg_interval(resource);
136 mutex_unlock(&resource->lock);
138 return sprintf(buf, "%llu\n", resource->avg_interval);
141 static ssize_t set_avg_interval(struct device *dev,
142 struct device_attribute *devattr,
143 const char *buf, size_t count)
145 struct acpi_device *acpi_dev = to_acpi_device(dev);
146 struct acpi_power_meter_resource *resource = acpi_dev->driver_data;
147 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
148 struct acpi_object_list args = { 1, &arg0 };
151 unsigned long long data;
154 res = kstrtoul(buf, 10, &temp);
158 if (temp > resource->caps.max_avg_interval ||
159 temp < resource->caps.min_avg_interval)
161 arg0.integer.value = temp;
163 mutex_lock(&resource->lock);
164 status = acpi_evaluate_integer(resource->acpi_dev->handle, "_PAI",
166 if (ACPI_SUCCESS(status))
167 resource->avg_interval = temp;
168 mutex_unlock(&resource->lock);
170 if (ACPI_FAILURE(status)) {
171 acpi_evaluation_failure_warn(resource->acpi_dev->handle, "_PAI",
176 /* _PAI returns 0 on success, nonzero otherwise */
184 static int update_cap(struct acpi_power_meter_resource *resource)
186 unsigned long long data;
189 status = acpi_evaluate_integer(resource->acpi_dev->handle, "_GHL",
191 if (ACPI_FAILURE(status)) {
192 acpi_evaluation_failure_warn(resource->acpi_dev->handle, "_GHL",
197 resource->cap = data;
201 static ssize_t show_cap(struct device *dev,
202 struct device_attribute *devattr,
205 struct acpi_device *acpi_dev = to_acpi_device(dev);
206 struct acpi_power_meter_resource *resource = acpi_dev->driver_data;
208 mutex_lock(&resource->lock);
209 update_cap(resource);
210 mutex_unlock(&resource->lock);
212 return sprintf(buf, "%llu\n", resource->cap * 1000);
215 static ssize_t set_cap(struct device *dev, struct device_attribute *devattr,
216 const char *buf, size_t count)
218 struct acpi_device *acpi_dev = to_acpi_device(dev);
219 struct acpi_power_meter_resource *resource = acpi_dev->driver_data;
220 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
221 struct acpi_object_list args = { 1, &arg0 };
224 unsigned long long data;
227 res = kstrtoul(buf, 10, &temp);
231 temp = DIV_ROUND_CLOSEST(temp, 1000);
232 if (temp > resource->caps.max_cap || temp < resource->caps.min_cap)
234 arg0.integer.value = temp;
236 mutex_lock(&resource->lock);
237 status = acpi_evaluate_integer(resource->acpi_dev->handle, "_SHL",
239 if (ACPI_SUCCESS(status))
240 resource->cap = temp;
241 mutex_unlock(&resource->lock);
243 if (ACPI_FAILURE(status)) {
244 acpi_evaluation_failure_warn(resource->acpi_dev->handle, "_SHL",
249 /* _SHL returns 0 on success, nonzero otherwise */
256 /* Power meter trip points */
257 static int set_acpi_trip(struct acpi_power_meter_resource *resource)
259 union acpi_object arg_objs[] = {
263 struct acpi_object_list args = { 2, arg_objs };
264 unsigned long long data;
267 /* Both trip levels must be set */
268 if (resource->trip[0] < 0 || resource->trip[1] < 0)
271 /* This driver stores min, max; ACPI wants max, min. */
272 arg_objs[0].integer.value = resource->trip[1];
273 arg_objs[1].integer.value = resource->trip[0];
275 status = acpi_evaluate_integer(resource->acpi_dev->handle, "_PTP",
277 if (ACPI_FAILURE(status)) {
278 acpi_evaluation_failure_warn(resource->acpi_dev->handle, "_PTP",
283 /* _PTP returns 0 on success, nonzero otherwise */
290 static ssize_t set_trip(struct device *dev, struct device_attribute *devattr,
291 const char *buf, size_t count)
293 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
294 struct acpi_device *acpi_dev = to_acpi_device(dev);
295 struct acpi_power_meter_resource *resource = acpi_dev->driver_data;
296 unsigned long temp, trip_bk;
299 res = kstrtoul(buf, 10, &temp);
303 temp = DIV_ROUND_CLOSEST(temp, 1000);
305 guard(mutex)(&resource->lock);
307 trip_bk = resource->trip[attr->index - 7];
308 resource->trip[attr->index - 7] = temp;
309 res = set_acpi_trip(resource);
311 resource->trip[attr->index - 7] = trip_bk;
319 static int update_meter(struct acpi_power_meter_resource *resource)
321 unsigned long long data;
323 unsigned long local_jiffies = jiffies;
325 if (time_before(local_jiffies, resource->sensors_last_updated +
326 msecs_to_jiffies(resource->caps.sampling_time)) &&
327 resource->sensors_valid)
330 status = acpi_evaluate_integer(resource->acpi_dev->handle, "_PMM",
332 if (ACPI_FAILURE(status)) {
333 acpi_evaluation_failure_warn(resource->acpi_dev->handle, "_PMM",
338 resource->power = data;
339 resource->sensors_valid = 1;
340 resource->sensors_last_updated = jiffies;
344 static ssize_t show_power(struct device *dev,
345 struct device_attribute *devattr,
348 struct acpi_device *acpi_dev = to_acpi_device(dev);
349 struct acpi_power_meter_resource *resource = acpi_dev->driver_data;
351 mutex_lock(&resource->lock);
352 update_meter(resource);
353 mutex_unlock(&resource->lock);
355 if (resource->power == UNKNOWN_POWER)
358 return sprintf(buf, "%llu\n", resource->power * 1000);
362 static ssize_t show_str(struct device *dev,
363 struct device_attribute *devattr,
366 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
367 struct acpi_device *acpi_dev = to_acpi_device(dev);
368 struct acpi_power_meter_resource *resource = acpi_dev->driver_data;
372 mutex_lock(&resource->lock);
373 switch (attr->index) {
375 val = resource->model_number;
378 val = resource->serial_number;
381 val = resource->oem_info;
384 WARN(1, "Implementation error: unexpected attribute index %d\n",
389 ret = sprintf(buf, "%s\n", val);
390 mutex_unlock(&resource->lock);
394 static ssize_t show_val(struct device *dev,
395 struct device_attribute *devattr,
398 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
399 struct acpi_device *acpi_dev = to_acpi_device(dev);
400 struct acpi_power_meter_resource *resource = acpi_dev->driver_data;
404 guard(mutex)(&resource->lock);
406 switch (attr->index) {
408 val = resource->caps.min_avg_interval;
411 val = resource->caps.max_avg_interval;
414 val = resource->caps.min_cap * 1000;
417 val = resource->caps.max_cap * 1000;
420 if (resource->caps.hysteresis == UNKNOWN_HYSTERESIS)
421 return sprintf(buf, "unknown\n");
423 val = resource->caps.hysteresis * 1000;
426 if (resource->caps.flags & POWER_METER_IS_BATTERY)
432 ret = update_meter(resource);
435 /* need to update cap if not to support the notification. */
436 if (!(resource->caps.flags & POWER_METER_CAN_NOTIFY)) {
437 ret = update_cap(resource);
441 val = resource->power_alarm || resource->power > resource->cap;
442 resource->power_alarm = resource->power > resource->cap;
446 if (resource->trip[attr->index - 7] < 0)
447 return sprintf(buf, "unknown\n");
449 val = resource->trip[attr->index - 7] * 1000;
452 WARN(1, "Implementation error: unexpected attribute index %d\n",
457 return sprintf(buf, "%llu\n", val);
460 static ssize_t show_accuracy(struct device *dev,
461 struct device_attribute *devattr,
464 struct acpi_device *acpi_dev = to_acpi_device(dev);
465 struct acpi_power_meter_resource *resource = acpi_dev->driver_data;
466 unsigned int acc = resource->caps.accuracy;
468 return sprintf(buf, "%u.%u%%\n", acc / 1000, acc % 1000);
471 static ssize_t show_name(struct device *dev,
472 struct device_attribute *devattr,
475 return sprintf(buf, "%s\n", ACPI_POWER_METER_NAME);
478 #define RO_SENSOR_TEMPLATE(_label, _show, _index) \
485 #define RW_SENSOR_TEMPLATE(_label, _show, _set, _index) \
493 /* Sensor descriptions. If you add a sensor, update NUM_SENSORS above! */
494 static struct sensor_template meter_attrs[] = {
495 RO_SENSOR_TEMPLATE(POWER_AVERAGE_NAME, show_power, 0),
496 RO_SENSOR_TEMPLATE("power1_accuracy", show_accuracy, 0),
497 RO_SENSOR_TEMPLATE("power1_average_interval_min", show_val, 0),
498 RO_SENSOR_TEMPLATE("power1_average_interval_max", show_val, 1),
499 RO_SENSOR_TEMPLATE("power1_is_battery", show_val, 5),
500 RW_SENSOR_TEMPLATE(POWER_AVG_INTERVAL_NAME, show_avg_interval,
501 set_avg_interval, 0),
505 static struct sensor_template misc_cap_attrs[] = {
506 RO_SENSOR_TEMPLATE("power1_cap_min", show_val, 2),
507 RO_SENSOR_TEMPLATE("power1_cap_max", show_val, 3),
508 RO_SENSOR_TEMPLATE("power1_cap_hyst", show_val, 4),
509 RO_SENSOR_TEMPLATE(POWER_ALARM_NAME, show_val, 6),
513 static struct sensor_template ro_cap_attrs[] = {
514 RO_SENSOR_TEMPLATE(POWER_CAP_NAME, show_cap, 0),
518 static struct sensor_template rw_cap_attrs[] = {
519 RW_SENSOR_TEMPLATE(POWER_CAP_NAME, show_cap, set_cap, 0),
523 static struct sensor_template trip_attrs[] = {
524 RW_SENSOR_TEMPLATE("power1_average_min", show_val, set_trip, 7),
525 RW_SENSOR_TEMPLATE("power1_average_max", show_val, set_trip, 8),
529 static struct sensor_template misc_attrs[] = {
530 RO_SENSOR_TEMPLATE("name", show_name, 0),
531 RO_SENSOR_TEMPLATE("power1_model_number", show_str, 0),
532 RO_SENSOR_TEMPLATE("power1_oem_info", show_str, 2),
533 RO_SENSOR_TEMPLATE("power1_serial_number", show_str, 1),
537 #undef RO_SENSOR_TEMPLATE
538 #undef RW_SENSOR_TEMPLATE
540 /* Read power domain data */
541 static void remove_domain_devices(struct acpi_power_meter_resource *resource)
545 if (!resource->num_domain_devices)
548 for (i = 0; i < resource->num_domain_devices; i++) {
549 struct acpi_device *obj = resource->domain_devices[i];
554 sysfs_remove_link(resource->holders_dir,
555 kobject_name(&obj->dev.kobj));
559 kfree(resource->domain_devices);
560 kobject_put(resource->holders_dir);
561 resource->num_domain_devices = 0;
564 static int read_domain_devices(struct acpi_power_meter_resource *resource)
568 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
569 union acpi_object *pss;
572 status = acpi_evaluate_object(resource->acpi_dev->handle, "_PMD", NULL,
574 if (ACPI_FAILURE(status)) {
575 acpi_evaluation_failure_warn(resource->acpi_dev->handle, "_PMD",
580 pss = buffer.pointer;
582 pss->type != ACPI_TYPE_PACKAGE) {
583 dev_err(&resource->acpi_dev->dev, ACPI_POWER_METER_NAME
584 "Invalid _PMD data\n");
589 if (!pss->package.count)
592 resource->domain_devices = kcalloc(pss->package.count,
593 sizeof(struct acpi_device *),
595 if (!resource->domain_devices) {
600 resource->holders_dir = kobject_create_and_add("measures",
601 &resource->acpi_dev->dev.kobj);
602 if (!resource->holders_dir) {
607 resource->num_domain_devices = pss->package.count;
609 for (i = 0; i < pss->package.count; i++) {
610 struct acpi_device *obj;
611 union acpi_object *element = &pss->package.elements[i];
613 /* Refuse non-references */
614 if (element->type != ACPI_TYPE_LOCAL_REFERENCE)
617 /* Create a symlink to domain objects */
618 obj = acpi_get_acpi_dev(element->reference.handle);
619 resource->domain_devices[i] = obj;
623 res = sysfs_create_link(resource->holders_dir, &obj->dev.kobj,
624 kobject_name(&obj->dev.kobj));
627 resource->domain_devices[i] = NULL;
635 kfree(resource->domain_devices);
637 kfree(buffer.pointer);
641 /* Registration and deregistration */
642 static int register_attrs(struct acpi_power_meter_resource *resource,
643 struct sensor_template *attrs)
645 struct device *dev = &resource->acpi_dev->dev;
646 struct sensor_device_attribute *sensors =
647 &resource->sensors[resource->num_sensors];
650 while (attrs->label) {
651 sensors->dev_attr.attr.name = attrs->label;
652 sensors->dev_attr.attr.mode = 0444;
653 sensors->dev_attr.show = attrs->show;
654 sensors->index = attrs->index;
657 sensors->dev_attr.attr.mode |= 0200;
658 sensors->dev_attr.store = attrs->set;
661 sysfs_attr_init(&sensors->dev_attr.attr);
662 res = device_create_file(dev, &sensors->dev_attr);
664 sensors->dev_attr.attr.name = NULL;
668 resource->num_sensors++;
676 static void remove_attrs(struct acpi_power_meter_resource *resource)
680 for (i = 0; i < resource->num_sensors; i++) {
681 if (!resource->sensors[i].dev_attr.attr.name)
683 device_remove_file(&resource->acpi_dev->dev,
684 &resource->sensors[i].dev_attr);
687 remove_domain_devices(resource);
689 resource->num_sensors = 0;
692 static int setup_attrs(struct acpi_power_meter_resource *resource)
696 /* _PMD method is optional. */
697 res = read_domain_devices(resource);
698 if (res && res != -ENODEV)
701 if (resource->caps.flags & POWER_METER_CAN_MEASURE) {
702 res = register_attrs(resource, meter_attrs);
707 if (resource->caps.flags & POWER_METER_CAN_CAP) {
708 if (!can_cap_in_hardware()) {
709 dev_warn(&resource->acpi_dev->dev,
710 "Ignoring unsafe software power cap!\n");
711 goto skip_unsafe_cap;
714 if (resource->caps.configurable_cap)
715 res = register_attrs(resource, rw_cap_attrs);
717 res = register_attrs(resource, ro_cap_attrs);
722 res = register_attrs(resource, misc_cap_attrs);
728 if (resource->caps.flags & POWER_METER_CAN_TRIP) {
729 res = register_attrs(resource, trip_attrs);
734 res = register_attrs(resource, misc_attrs);
740 remove_attrs(resource);
744 static void free_capabilities(struct acpi_power_meter_resource *resource)
749 str = &resource->model_number;
750 for (i = 0; i < 3; i++, str++) {
756 static int read_capabilities(struct acpi_power_meter_resource *resource)
760 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
761 struct acpi_buffer state = { 0, NULL };
762 struct acpi_buffer format = { sizeof("NNNNNNNNNNN"), "NNNNNNNNNNN" };
763 union acpi_object *pss;
767 status = acpi_evaluate_object(resource->acpi_dev->handle, "_PMC", NULL,
769 if (ACPI_FAILURE(status)) {
770 acpi_evaluation_failure_warn(resource->acpi_dev->handle, "_PMC",
775 pss = buffer.pointer;
777 pss->type != ACPI_TYPE_PACKAGE ||
778 pss->package.count != 14) {
779 dev_err(&resource->acpi_dev->dev, ACPI_POWER_METER_NAME
780 "Invalid _PMC data\n");
785 /* Grab all the integer data at once */
786 state.length = sizeof(struct acpi_power_meter_capabilities);
787 state.pointer = &resource->caps;
789 status = acpi_extract_package(pss, &format, &state);
790 if (ACPI_FAILURE(status)) {
791 dev_err(&resource->acpi_dev->dev, ACPI_POWER_METER_NAME
792 "_PMC package parsing failed: %s\n",
793 acpi_format_exception(status));
798 if (resource->caps.units) {
799 dev_err(&resource->acpi_dev->dev, ACPI_POWER_METER_NAME
800 "Unknown units %llu.\n",
801 resource->caps.units);
806 /* Grab the string data */
807 str = &resource->model_number;
809 for (i = 11; i < 14; i++) {
810 union acpi_object *element = &pss->package.elements[i];
812 if (element->type != ACPI_TYPE_STRING) {
817 *str = kmemdup_nul(element->string.pointer, element->string.length,
827 dev_info(&resource->acpi_dev->dev, "Found ACPI power meter.\n");
830 free_capabilities(resource);
832 kfree(buffer.pointer);
836 /* Handle ACPI event notifications */
837 static void acpi_power_meter_notify(struct acpi_device *device, u32 event)
839 struct acpi_power_meter_resource *resource;
842 if (!device || !acpi_driver_data(device))
845 resource = acpi_driver_data(device);
848 case METER_NOTIFY_CONFIG:
849 mutex_lock(&resource->lock);
850 free_capabilities(resource);
851 res = read_capabilities(resource);
852 mutex_unlock(&resource->lock);
856 remove_attrs(resource);
857 setup_attrs(resource);
859 case METER_NOTIFY_TRIP:
860 sysfs_notify(&device->dev.kobj, NULL, POWER_AVERAGE_NAME);
862 case METER_NOTIFY_CAP:
863 mutex_lock(&resource->lock);
864 res = update_cap(resource);
866 dev_err_once(&device->dev, "update cap failed when capping value is changed.\n");
867 mutex_unlock(&resource->lock);
868 sysfs_notify(&device->dev.kobj, NULL, POWER_CAP_NAME);
870 case METER_NOTIFY_INTERVAL:
871 sysfs_notify(&device->dev.kobj, NULL, POWER_AVG_INTERVAL_NAME);
873 case METER_NOTIFY_CAPPING:
874 mutex_lock(&resource->lock);
875 resource->power_alarm = true;
876 mutex_unlock(&resource->lock);
877 sysfs_notify(&device->dev.kobj, NULL, POWER_ALARM_NAME);
878 dev_info(&device->dev, "Capping in progress.\n");
881 WARN(1, "Unexpected event %d\n", event);
885 acpi_bus_generate_netlink_event(ACPI_POWER_METER_CLASS,
886 dev_name(&device->dev), event, 0);
889 static int acpi_power_meter_add(struct acpi_device *device)
892 struct acpi_power_meter_resource *resource;
897 resource = kzalloc(sizeof(*resource), GFP_KERNEL);
901 resource->sensors_valid = 0;
902 resource->acpi_dev = device;
903 mutex_init(&resource->lock);
904 strcpy(acpi_device_name(device), ACPI_POWER_METER_DEVICE_NAME);
905 strcpy(acpi_device_class(device), ACPI_POWER_METER_CLASS);
906 device->driver_data = resource;
908 #if IS_REACHABLE(CONFIG_ACPI_IPMI)
910 * On Dell systems several methods of acpi_power_meter access
911 * variables in IPMI region, so wait until IPMI space handler is
912 * installed by acpi_ipmi and also wait until SMI is selected to make
913 * the space handler fully functional.
915 if (dmi_match(DMI_SYS_VENDOR, "Dell Inc.")) {
916 struct acpi_device *ipi_device = acpi_dev_get_first_match_dev("IPI0001", NULL, -1);
918 if (ipi_device && acpi_wait_for_acpi_ipmi())
919 dev_warn(&device->dev, "Waiting for ACPI IPMI timeout");
920 acpi_dev_put(ipi_device);
924 res = read_capabilities(resource);
928 resource->trip[0] = -1;
929 resource->trip[1] = -1;
931 res = setup_attrs(resource);
933 goto exit_free_capability;
935 resource->hwmon_dev = hwmon_device_register(&device->dev);
936 if (IS_ERR(resource->hwmon_dev)) {
937 res = PTR_ERR(resource->hwmon_dev);
945 remove_attrs(resource);
946 exit_free_capability:
947 free_capabilities(resource);
954 static void acpi_power_meter_remove(struct acpi_device *device)
956 struct acpi_power_meter_resource *resource;
958 if (!device || !acpi_driver_data(device))
961 resource = acpi_driver_data(device);
962 hwmon_device_unregister(resource->hwmon_dev);
964 remove_attrs(resource);
965 free_capabilities(resource);
970 static int acpi_power_meter_resume(struct device *dev)
972 struct acpi_power_meter_resource *resource;
977 resource = acpi_driver_data(to_acpi_device(dev));
981 free_capabilities(resource);
982 read_capabilities(resource);
987 static DEFINE_SIMPLE_DEV_PM_OPS(acpi_power_meter_pm, NULL,
988 acpi_power_meter_resume);
990 static struct acpi_driver acpi_power_meter_driver = {
991 .name = "power_meter",
992 .class = ACPI_POWER_METER_CLASS,
993 .ids = power_meter_ids,
995 .add = acpi_power_meter_add,
996 .remove = acpi_power_meter_remove,
997 .notify = acpi_power_meter_notify,
999 .drv.pm = pm_sleep_ptr(&acpi_power_meter_pm),
1002 /* Module init/exit routines */
1003 static int __init enable_cap_knobs(const struct dmi_system_id *d)
1005 cap_in_hardware = 1;
1009 static const struct dmi_system_id pm_dmi_table[] __initconst = {
1011 enable_cap_knobs, "IBM Active Energy Manager",
1013 DMI_MATCH(DMI_SYS_VENDOR, "IBM")
1019 static int __init acpi_power_meter_init(void)
1026 dmi_check_system(pm_dmi_table);
1028 result = acpi_bus_register_driver(&acpi_power_meter_driver);
1035 static void __exit acpi_power_meter_exit(void)
1037 acpi_bus_unregister_driver(&acpi_power_meter_driver);
1041 MODULE_DESCRIPTION("ACPI 4.0 power meter driver");
1042 MODULE_LICENSE("GPL");
1044 module_param(force_cap_on, bool, 0644);
1045 MODULE_PARM_DESC(force_cap_on, "Enable power cap even it is unsafe to do so.");
1047 module_init(acpi_power_meter_init);
1048 module_exit(acpi_power_meter_exit);