diff options
Diffstat (limited to 'drivers/acpi')
26 files changed, 336 insertions, 88 deletions
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 39ea5cfa8326..61ca4afe83dc 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -77,6 +77,7 @@ obj-$(CONFIG_ACPI_TINY_POWER_BUTTON) += tiny-power-button.o obj-$(CONFIG_ACPI_FAN) += fan.o fan-objs := fan_core.o fan-objs += fan_attr.o +fan-$(CONFIG_HWMON) += fan_hwmon.o obj-$(CONFIG_ACPI_VIDEO) += video.o obj-$(CONFIG_ACPI_TAD) += acpi_tad.o diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 09a87fa222c7..eaa70b23dd0b 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -112,7 +112,7 @@ static int get_ac_property(struct power_supply *psy, return 0; } -static enum power_supply_property ac_props[] = { +static const enum power_supply_property ac_props[] = { POWER_SUPPLY_PROP_ONLINE, }; diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c index bd1ad07f0290..350d3a892889 100644 --- a/drivers/acpi/acpi_pad.c +++ b/drivers/acpi/acpi_pad.c @@ -25,6 +25,10 @@ #define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad" #define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator" #define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80 + +#define ACPI_PROCESSOR_AGGREGATOR_STATUS_SUCCESS 0 +#define ACPI_PROCESSOR_AGGREGATOR_STATUS_NO_ACTION 1 + static DEFINE_MUTEX(isolated_cpus_lock); static DEFINE_MUTEX(round_robin_lock); @@ -382,16 +386,23 @@ static void acpi_pad_handle_notify(acpi_handle handle) .length = 4, .pointer = (void *)&idle_cpus, }; + u32 status; mutex_lock(&isolated_cpus_lock); num_cpus = acpi_pad_pur(handle); if (num_cpus < 0) { - mutex_unlock(&isolated_cpus_lock); - return; + /* The ACPI specification says that if no action was performed when + * processing the _PUR object, _OST should still be evaluated, albeit + * with a different status code. + */ + status = ACPI_PROCESSOR_AGGREGATOR_STATUS_NO_ACTION; + } else { + status = ACPI_PROCESSOR_AGGREGATOR_STATUS_SUCCESS; + acpi_pad_idle_cpus(num_cpus); } - acpi_pad_idle_cpus(num_cpus); + idle_cpus = acpi_pad_idle_cpus_num(); - acpi_evaluate_ost(handle, ACPI_PROCESSOR_AGGREGATOR_NOTIFY, 0, ¶m); + acpi_evaluate_ost(handle, ACPI_PROCESSOR_AGGREGATOR_NOTIFY, status, ¶m); mutex_unlock(&isolated_cpus_lock); } diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 64e10bad8072..9916cc7ced39 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -619,9 +619,9 @@ static bool __init acpi_early_processor_osc(void) void __init acpi_early_processor_control_setup(void) { if (acpi_early_processor_osc()) { - pr_info("_OSC evaluated successfully for all CPUs\n"); + pr_debug("_OSC evaluated successfully for all CPUs\n"); } else { - pr_info("_OSC evaluation for CPUs failed, trying _PDC\n"); + pr_debug("_OSC evaluation for CPUs failed, trying _PDC\n"); acpi_early_processor_set_pdc(); } } diff --git a/drivers/acpi/acpi_tad.c b/drivers/acpi/acpi_tad.c index 1d670dbe4d1d..b831cb8e53dc 100644 --- a/drivers/acpi/acpi_tad.c +++ b/drivers/acpi/acpi_tad.c @@ -27,6 +27,7 @@ #include <linux/pm_runtime.h> #include <linux/suspend.h> +MODULE_DESCRIPTION("ACPI Time and Alarm (TAD) Device Driver"); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Rafael J. Wysocki"); diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 1fda30388297..8274a17872ed 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -1128,8 +1128,8 @@ static int acpi_video_bus_get_one_device(struct acpi_device *device, void *arg) return -ENOMEM; } - strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME); - strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS); + strscpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME); + strscpy(acpi_device_class(device), ACPI_VIDEO_CLASS); data->device_id = device_id; data->video = video; @@ -2010,8 +2010,8 @@ static int acpi_video_bus_add(struct acpi_device *device) } video->device = device; - strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME); - strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS); + strscpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME); + strscpy(acpi_device_class(device), ACPI_VIDEO_CLASS); device->driver_data = video; acpi_video_bus_find_cap(video); diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 6ea979f76f84..da3a879d638a 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -38,9 +38,10 @@ /* Battery power unit: 0 means mW, 1 means mA */ #define ACPI_BATTERY_POWER_UNIT_MA 1 -#define ACPI_BATTERY_STATE_DISCHARGING 0x1 -#define ACPI_BATTERY_STATE_CHARGING 0x2 -#define ACPI_BATTERY_STATE_CRITICAL 0x4 +#define ACPI_BATTERY_STATE_DISCHARGING 0x1 +#define ACPI_BATTERY_STATE_CHARGING 0x2 +#define ACPI_BATTERY_STATE_CRITICAL 0x4 +#define ACPI_BATTERY_STATE_CHARGE_LIMITING 0x8 #define MAX_STRING_LENGTH 64 @@ -155,7 +156,7 @@ static int acpi_battery_get_state(struct acpi_battery *battery); static int acpi_battery_is_charged(struct acpi_battery *battery) { - /* charging, discharging or critical low */ + /* charging, discharging, critical low or charge limited */ if (battery->state != 0) return 0; @@ -215,6 +216,8 @@ static int acpi_battery_get_property(struct power_supply *psy, val->intval = acpi_battery_handle_discharging(battery); else if (battery->state & ACPI_BATTERY_STATE_CHARGING) val->intval = POWER_SUPPLY_STATUS_CHARGING; + else if (battery->state & ACPI_BATTERY_STATE_CHARGE_LIMITING) + val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; else if (acpi_battery_is_charged(battery)) val->intval = POWER_SUPPLY_STATUS_FULL; else @@ -308,7 +311,7 @@ static int acpi_battery_get_property(struct power_supply *psy, return ret; } -static enum power_supply_property charge_battery_props[] = { +static const enum power_supply_property charge_battery_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_TECHNOLOGY, @@ -326,7 +329,7 @@ static enum power_supply_property charge_battery_props[] = { POWER_SUPPLY_PROP_SERIAL_NUMBER, }; -static enum power_supply_property charge_battery_full_cap_broken_props[] = { +static const enum power_supply_property charge_battery_full_cap_broken_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_TECHNOLOGY, @@ -340,7 +343,7 @@ static enum power_supply_property charge_battery_full_cap_broken_props[] = { POWER_SUPPLY_PROP_SERIAL_NUMBER, }; -static enum power_supply_property energy_battery_props[] = { +static const enum power_supply_property energy_battery_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_TECHNOLOGY, @@ -358,7 +361,7 @@ static enum power_supply_property energy_battery_props[] = { POWER_SUPPLY_PROP_SERIAL_NUMBER, }; -static enum power_supply_property energy_battery_full_cap_broken_props[] = { +static const enum power_supply_property energy_battery_full_cap_broken_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_TECHNOLOGY, @@ -661,7 +664,7 @@ static ssize_t acpi_battery_alarm_show(struct device *dev, { struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); - return sprintf(buf, "%d\n", battery->alarm * 1000); + return sysfs_emit(buf, "%d\n", battery->alarm * 1000); } static ssize_t acpi_battery_alarm_store(struct device *dev, @@ -678,12 +681,18 @@ static ssize_t acpi_battery_alarm_store(struct device *dev, return count; } -static const struct device_attribute alarm_attr = { +static struct device_attribute alarm_attr = { .attr = {.name = "alarm", .mode = 0644}, .show = acpi_battery_alarm_show, .store = acpi_battery_alarm_store, }; +static struct attribute *acpi_battery_attrs[] = { + &alarm_attr.attr, + NULL +}; +ATTRIBUTE_GROUPS(acpi_battery); + /* * The Battery Hooking API * @@ -838,7 +847,10 @@ static void __exit battery_hook_exit(void) static int sysfs_add_battery(struct acpi_battery *battery) { - struct power_supply_config psy_cfg = { .drv_data = battery, }; + struct power_supply_config psy_cfg = { + .drv_data = battery, + .attr_grp = acpi_battery_groups, + }; bool full_cap_broken = false; if (!ACPI_BATTERY_CAPACITY_VALID(battery->full_charge_capacity) && @@ -883,7 +895,7 @@ static int sysfs_add_battery(struct acpi_battery *battery) return result; } battery_hook_add_battery(battery); - return device_create_file(&battery->bat->dev, &alarm_attr); + return 0; } static void sysfs_remove_battery(struct acpi_battery *battery) @@ -894,7 +906,6 @@ static void sysfs_remove_battery(struct acpi_battery *battery) return; } battery_hook_remove_battery(battery); - device_remove_file(&battery->bat->dev, &alarm_attr); power_supply_unregister(battery->bat); battery->bat = NULL; mutex_unlock(&battery->sysfs_lock); diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 787eca838410..bdbd60ae8897 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -329,6 +329,8 @@ static void acpi_bus_osc_negotiate_platform_control(void) capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PPC_OST_SUPPORT; if (IS_ENABLED(CONFIG_ACPI_THERMAL)) capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_FAST_THERMAL_SAMPLING_SUPPORT; + if (IS_ENABLED(CONFIG_ACPI_BATTERY)) + capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_BATTERY_CHARGE_LIMITING_SUPPORT; capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_HOTPLUG_OST_SUPPORT; capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_PCLPI_SUPPORT; diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 1d857978f5f4..dd3d3082c8c7 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -160,6 +160,7 @@ show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, highest_perf); show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, lowest_perf); show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, nominal_perf); show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, lowest_nonlinear_perf); +show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, guaranteed_perf); show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, lowest_freq); show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, nominal_freq); @@ -196,6 +197,7 @@ static struct attribute *cppc_attrs[] = { &highest_perf.attr, &lowest_perf.attr, &lowest_nonlinear_perf.attr, + &guaranteed_perf.attr, &nominal_perf.attr, &nominal_freq.attr, &lowest_freq.attr, @@ -1837,7 +1839,7 @@ static void cppc_find_dmi_mhz(const struct dmi_header *dm, void *private) dm->length >= DMI_ENTRY_PROCESSOR_MIN_LENGTH) { u16 val = (u16)get_unaligned((const u16 *) (dmi_data + DMI_PROCESSOR_MAX_SPEED)); - *mhz = val > *mhz ? val : *mhz; + *mhz = umax(val, *mhz); } } diff --git a/drivers/acpi/fan.h b/drivers/acpi/fan.h index f89d19c922dc..db25a3898af7 100644 --- a/drivers/acpi/fan.h +++ b/drivers/acpi/fan.h @@ -10,6 +10,8 @@ #ifndef _ACPI_FAN_H_ #define _ACPI_FAN_H_ +#include <linux/kconfig.h> + #define ACPI_FAN_DEVICE_IDS \ {"INT3404", }, /* Fan */ \ {"INTC1044", }, /* Fan for Tiger Lake generation */ \ @@ -57,4 +59,11 @@ struct acpi_fan { int acpi_fan_get_fst(struct acpi_device *device, struct acpi_fan_fst *fst); int acpi_fan_create_attributes(struct acpi_device *device); void acpi_fan_delete_attributes(struct acpi_device *device); + +#if IS_REACHABLE(CONFIG_HWMON) +int devm_acpi_fan_create_hwmon(struct acpi_device *device); +#else +static inline int devm_acpi_fan_create_hwmon(struct acpi_device *device) { return 0; }; +#endif + #endif diff --git a/drivers/acpi/fan_core.c b/drivers/acpi/fan_core.c index ff72e4ef8738..7cea4495f19b 100644 --- a/drivers/acpi/fan_core.c +++ b/drivers/acpi/fan_core.c @@ -336,6 +336,10 @@ static int acpi_fan_probe(struct platform_device *pdev) if (result) return result; + result = devm_acpi_fan_create_hwmon(device); + if (result) + return result; + result = acpi_fan_create_attributes(device); if (result) return result; diff --git a/drivers/acpi/fan_hwmon.c b/drivers/acpi/fan_hwmon.c new file mode 100644 index 000000000000..bd0d31a398fa --- /dev/null +++ b/drivers/acpi/fan_hwmon.c @@ -0,0 +1,170 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * hwmon interface for the ACPI Fan driver. + * + * Copyright (C) 2024 Armin Wolf <W_Armin@gmx.de> + */ + +#include <linux/acpi.h> +#include <linux/device.h> +#include <linux/err.h> +#include <linux/hwmon.h> +#include <linux/limits.h> +#include <linux/types.h> +#include <linux/units.h> + +#include "fan.h" + +/* Returned when the ACPI fan does not support speed reporting */ +#define FAN_SPEED_UNAVAILABLE U32_MAX +#define FAN_POWER_UNAVAILABLE U32_MAX + +static struct acpi_fan_fps *acpi_fan_get_current_fps(struct acpi_fan *fan, u64 control) +{ + unsigned int i; + + for (i = 0; i < fan->fps_count; i++) { + if (fan->fps[i].control == control) + return &fan->fps[i]; + } + + return NULL; +} + +static umode_t acpi_fan_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_types type, + u32 attr, int channel) +{ + const struct acpi_fan *fan = drvdata; + unsigned int i; + + switch (type) { + case hwmon_fan: + switch (attr) { + case hwmon_fan_input: + return 0444; + case hwmon_fan_target: + /* + * When in fine grain control mode, not every fan control value + * has an associated fan performance state. + */ + if (fan->fif.fine_grain_ctrl) + return 0; + + return 0444; + default: + return 0; + } + case hwmon_power: + switch (attr) { + case hwmon_power_input: + /* + * When in fine grain control mode, not every fan control value + * has an associated fan performance state. + */ + if (fan->fif.fine_grain_ctrl) + return 0; + + /* + * When all fan performance states contain no valid power data, + * when the associated attribute should not be created. + */ + for (i = 0; i < fan->fps_count; i++) { + if (fan->fps[i].power != FAN_POWER_UNAVAILABLE) + return 0444; + } + + return 0; + default: + return 0; + } + default: + return 0; + } +} + +static int acpi_fan_hwmon_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, + int channel, long *val) +{ + struct acpi_device *adev = to_acpi_device(dev->parent); + struct acpi_fan *fan = dev_get_drvdata(dev); + struct acpi_fan_fps *fps; + struct acpi_fan_fst fst; + int ret; + + ret = acpi_fan_get_fst(adev, &fst); + if (ret < 0) + return ret; + + switch (type) { + case hwmon_fan: + switch (attr) { + case hwmon_fan_input: + if (fst.speed == FAN_SPEED_UNAVAILABLE) + return -ENODEV; + + if (fst.speed > LONG_MAX) + return -EOVERFLOW; + + *val = fst.speed; + return 0; + case hwmon_fan_target: + fps = acpi_fan_get_current_fps(fan, fst.control); + if (!fps) + return -EIO; + + if (fps->speed > LONG_MAX) + return -EOVERFLOW; + + *val = fps->speed; + return 0; + default: + return -EOPNOTSUPP; + } + case hwmon_power: + switch (attr) { + case hwmon_power_input: + fps = acpi_fan_get_current_fps(fan, fst.control); + if (!fps) + return -EIO; + + if (fps->power == FAN_POWER_UNAVAILABLE) + return -ENODEV; + + if (fps->power > LONG_MAX / MICROWATT_PER_MILLIWATT) + return -EOVERFLOW; + + *val = fps->power * MICROWATT_PER_MILLIWATT; + return 0; + default: + return -EOPNOTSUPP; + } + default: + return -EOPNOTSUPP; + } +} + +static const struct hwmon_ops acpi_fan_hwmon_ops = { + .is_visible = acpi_fan_hwmon_is_visible, + .read = acpi_fan_hwmon_read, +}; + +static const struct hwmon_channel_info * const acpi_fan_hwmon_info[] = { + HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_TARGET), + HWMON_CHANNEL_INFO(power, HWMON_P_INPUT), + NULL +}; + +static const struct hwmon_chip_info acpi_fan_hwmon_chip_info = { + .ops = &acpi_fan_hwmon_ops, + .info = acpi_fan_hwmon_info, +}; + +int devm_acpi_fan_create_hwmon(struct acpi_device *device) +{ + struct acpi_fan *fan = acpi_driver_data(device); + struct device *hdev; + + hdev = devm_hwmon_device_register_with_info(&device->dev, "acpi_fan", fan, + &acpi_fan_hwmon_chip_info, NULL); + return PTR_ERR_OR_ZERO(hdev); +} diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c index 2c8ccc91ebe6..febd9e51350b 100644 --- a/drivers/acpi/numa/hmat.c +++ b/drivers/acpi/numa/hmat.c @@ -408,7 +408,7 @@ static __init void hmat_update_target(unsigned int tgt_pxm, unsigned int init_px if (target && target->processor_pxm == init_pxm) { hmat_update_target_access(target, type, value, ACCESS_COORDINATE_LOCAL); - /* If the node has a CPU, update access 1 */ + /* If the node has a CPU, update access ACCESS_COORDINATE_CPU */ if (node_state(pxm_to_node(init_pxm), N_CPU)) hmat_update_target_access(target, type, value, ACCESS_COORDINATE_CPU); @@ -948,7 +948,7 @@ static int hmat_set_default_dram_perf(void) target = find_mem_target(pxm); if (!target) continue; - attrs = &target->coord[1]; + attrs = &target->coord[ACCESS_COORDINATE_CPU]; rc = mt_set_default_dram_perf(nid, attrs, "ACPI HMAT"); if (rc) return rc; @@ -975,7 +975,7 @@ static int hmat_calculate_adistance(struct notifier_block *self, hmat_update_target_attrs(target, p_nodes, ACCESS_COORDINATE_CPU); mutex_unlock(&target_lock); - perf = &target->coord[1]; + perf = &target->coord[ACCESS_COORDINATE_CPU]; if (mt_perf_to_adistance(perf, adist)) return NOTIFY_OK; diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 4a9704730224..d2f7fd7743a1 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -217,4 +217,5 @@ int platform_profile_remove(void) EXPORT_SYMBOL_GPL(platform_profile_remove); MODULE_AUTHOR("Mark Pearson <markpearson@lenovo.com>"); +MODULE_DESCRIPTION("ACPI platform profile sysfs interface"); MODULE_LICENSE("GPL"); diff --git a/drivers/acpi/pmic/intel_pmic.c b/drivers/acpi/pmic/intel_pmic.c index f20dbda1a831..134e9ca8eaa2 100644 --- a/drivers/acpi/pmic/intel_pmic.c +++ b/drivers/acpi/pmic/intel_pmic.c @@ -31,7 +31,7 @@ struct intel_pmic_opregion { static struct intel_pmic_opregion *intel_pmic_opregion; -static int pmic_get_reg_bit(int address, struct pmic_table *table, +static int pmic_get_reg_bit(int address, const struct pmic_table *table, int count, int *reg, int *bit) { int i; diff --git a/drivers/acpi/pmic/intel_pmic.h b/drivers/acpi/pmic/intel_pmic.h index d956b03a6ca0..006f0780ffab 100644 --- a/drivers/acpi/pmic/intel_pmic.h +++ b/drivers/acpi/pmic/intel_pmic.h @@ -21,9 +21,9 @@ struct intel_pmic_opregion_data { u32 reg_address, u32 value, u32 mask); int (*lpat_raw_to_temp)(struct acpi_lpat_conversion_table *lpat_table, int raw); - struct pmic_table *power_table; + const struct pmic_table *power_table; int power_table_count; - struct pmic_table *thermal_table; + const struct pmic_table *thermal_table; int thermal_table_count; /* For generic exec_mipi_pmic_seq_element handling */ int pmic_i2c_address; diff --git a/drivers/acpi/pmic/intel_pmic_bxtwc.c b/drivers/acpi/pmic/intel_pmic_bxtwc.c index e247615189fa..c332afbf82bd 100644 --- a/drivers/acpi/pmic/intel_pmic_bxtwc.c +++ b/drivers/acpi/pmic/intel_pmic_bxtwc.c @@ -24,7 +24,7 @@ #define VSWITCH1_OUTPUT BIT(4) #define VUSBPHY_CHARGE BIT(1) -static struct pmic_table power_table[] = { +static const struct pmic_table power_table[] = { { .address = 0x0, .reg = 0x63, @@ -177,7 +177,7 @@ static struct pmic_table power_table[] = { } /* MOFF -> MODEMCTRL Bit 0 */ }; -static struct pmic_table thermal_table[] = { +static const struct pmic_table thermal_table[] = { { .address = 0x00, .reg = 0x4F39 diff --git a/drivers/acpi/pmic/intel_pmic_bytcrc.c b/drivers/acpi/pmic/intel_pmic_bytcrc.c index 2b09f8da5400..b4c21a75294a 100644 --- a/drivers/acpi/pmic/intel_pmic_bytcrc.c +++ b/drivers/acpi/pmic/intel_pmic_bytcrc.c @@ -16,7 +16,7 @@ #define PMIC_A0LOCK_REG 0xc5 -static struct pmic_table power_table[] = { +static const struct pmic_table power_table[] = { /* { .address = 0x00, .reg = ??, @@ -134,7 +134,7 @@ static struct pmic_table power_table[] = { }, /* V105 -> V1P05S, L2 SRAM */ }; -static struct pmic_table thermal_table[] = { +static const struct pmic_table thermal_table[] = { { .address = 0x00, .reg = 0x75 diff --git a/drivers/acpi/pmic/intel_pmic_chtdc_ti.c b/drivers/acpi/pmic/intel_pmic_chtdc_ti.c index c84ef3d15181..ecb36fbc1e7f 100644 --- a/drivers/acpi/pmic/intel_pmic_chtdc_ti.c +++ b/drivers/acpi/pmic/intel_pmic_chtdc_ti.c @@ -8,18 +8,22 @@ */ #include <linux/acpi.h> +#include <linux/bits.h> #include <linux/init.h> #include <linux/mfd/intel_soc_pmic.h> #include <linux/platform_device.h> +#include <asm/byteorder.h> #include "intel_pmic.h" /* registers stored in 16bit BE (high:low, total 10bit) */ +#define PMIC_REG_MASK GENMASK(9, 0) + #define CHTDC_TI_VBAT 0x54 #define CHTDC_TI_DIETEMP 0x56 #define CHTDC_TI_BPTHERM 0x58 #define CHTDC_TI_GPADC 0x5a -static struct pmic_table chtdc_ti_power_table[] = { +static const struct pmic_table chtdc_ti_power_table[] = { { .address = 0x00, .reg = 0x41 }, /* LDO1 */ { .address = 0x04, .reg = 0x42 }, /* LDO2 */ { .address = 0x08, .reg = 0x43 }, /* LDO3 */ @@ -35,7 +39,7 @@ static struct pmic_table chtdc_ti_power_table[] = { { .address = 0x30, .reg = 0x4e }, /* LD14 */ }; -static struct pmic_table chtdc_ti_thermal_table[] = { +static const struct pmic_table chtdc_ti_thermal_table[] = { { .address = 0x00, .reg = CHTDC_TI_GPADC @@ -73,7 +77,7 @@ static int chtdc_ti_pmic_get_power(struct regmap *regmap, int reg, int bit, if (regmap_read(regmap, reg, &data)) return -EIO; - *value = data & 1; + *value = data & BIT(0); return 0; } @@ -85,13 +89,12 @@ static int chtdc_ti_pmic_update_power(struct regmap *regmap, int reg, int bit, static int chtdc_ti_pmic_get_raw_temp(struct regmap *regmap, int reg) { - u8 buf[2]; + __be16 buf; - if (regmap_bulk_read(regmap, reg, buf, 2)) + if (regmap_bulk_read(regmap, reg, &buf, sizeof(buf))) return -EIO; - /* stored in big-endian */ - return ((buf[0] & 0x03) << 8) | buf[1]; + return be16_to_cpu(buf) & PMIC_REG_MASK; } static const struct intel_pmic_opregion_data chtdc_ti_pmic_opregion_data = { diff --git a/drivers/acpi/pmic/intel_pmic_chtwc.c b/drivers/acpi/pmic/intel_pmic_chtwc.c index f2c42f4c79ca..81caede51ca2 100644 --- a/drivers/acpi/pmic/intel_pmic_chtwc.c +++ b/drivers/acpi/pmic/intel_pmic_chtwc.c @@ -70,7 +70,7 @@ * "regulator: whiskey_cove: implements Whiskey Cove pmic VRF support" * https://github.com/intel-aero/meta-intel-aero/blob/master/recipes-kernel/linux/linux-yocto/0019-regulator-whiskey_cove-implements-WhiskeyCove-pmic-V.patch */ -static struct pmic_table power_table[] = { +static const struct pmic_table power_table[] = { { .address = 0x0, .reg = CHT_WC_V1P8A_CTRL, @@ -236,11 +236,12 @@ static int intel_cht_wc_exec_mipi_pmic_seq_element(struct regmap *regmap, u32 reg_address, u32 value, u32 mask) { + struct device *dev = regmap_get_device(regmap); u32 address; if (i2c_client_address > 0xff || reg_address > 0xff) { - pr_warn("%s warning addresses too big client 0x%x reg 0x%x\n", - __func__, i2c_client_address, reg_address); + dev_warn(dev, "warning addresses too big client 0x%x reg 0x%x\n", + i2c_client_address, reg_address); return -ERANGE; } diff --git a/drivers/acpi/pmic/intel_pmic_xpower.c b/drivers/acpi/pmic/intel_pmic_xpower.c index 61bbe4c24d87..49bda5e0c8aa 100644 --- a/drivers/acpi/pmic/intel_pmic_xpower.c +++ b/drivers/acpi/pmic/intel_pmic_xpower.c @@ -26,7 +26,7 @@ #define AXP288_ADC_TS_CURRENT_ON_ONDEMAND (2 << 0) #define AXP288_ADC_TS_CURRENT_ON (3 << 0) -static struct pmic_table power_table[] = { +static const struct pmic_table power_table[] = { { .address = 0x00, .reg = 0x13, @@ -129,7 +129,7 @@ static struct pmic_table power_table[] = { }; /* TMP0 - TMP5 are the same, all from GPADC */ -static struct pmic_table thermal_table[] = { +static const struct pmic_table thermal_table[] = { { .address = 0x00, .reg = XPOWER_GPADC_LOW @@ -255,7 +255,7 @@ static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg) if (ret) return ret; - ret = regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2); + ret = regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, sizeof(buf)); if (ret == 0) ret = (buf[0] << 4) + ((buf[1] >> 4) & 0x0f); @@ -274,11 +274,12 @@ static int intel_xpower_exec_mipi_pmic_seq_element(struct regmap *regmap, u16 i2c_address, u32 reg_address, u32 value, u32 mask) { + struct device *dev = regmap_get_device(regmap); int ret; if (i2c_address != 0x34) { - pr_err("%s: Unexpected i2c-addr: 0x%02x (reg-addr 0x%x value 0x%x mask 0x%x)\n", - __func__, i2c_address, reg_address, value, mask); + dev_err(dev, "Unexpected i2c-addr: 0x%02x (reg-addr 0x%x value 0x%x mask 0x%x)\n", + i2c_address, reg_address, value, mask); return -ENXIO; } diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c index b5bf8b81a050..df5d5a554b38 100644 --- a/drivers/acpi/resource.c +++ b/drivers/acpi/resource.c @@ -525,6 +525,20 @@ static const struct dmi_system_id irq1_level_low_skip_override[] = { }, }, { + /* Asus Vivobook Pro N6506MU */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_BOARD_NAME, "N6506MU"), + }, + }, + { + /* Asus Vivobook Pro N6506MJ */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_BOARD_NAME, "N6506MJ"), + }, + }, + { /* LG Electronics 17U70P */ .matches = { DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"), diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index dc8164b182dc..7a0914055fca 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c @@ -77,7 +77,6 @@ struct acpi_battery { u16 spec; u8 id; u8 present:1; - u8 have_sysfs_alarm:1; }; #define to_acpi_battery(x) power_supply_get_drvdata(x) @@ -241,11 +240,11 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy, return 0; } -static enum power_supply_property sbs_ac_props[] = { +static const enum power_supply_property sbs_ac_props[] = { POWER_SUPPLY_PROP_ONLINE, }; -static enum power_supply_property sbs_charge_battery_props[] = { +static const enum power_supply_property sbs_charge_battery_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_TECHNOLOGY, @@ -263,7 +262,7 @@ static enum power_supply_property sbs_charge_battery_props[] = { POWER_SUPPLY_PROP_MANUFACTURER, }; -static enum power_supply_property sbs_energy_battery_props[] = { +static const enum power_supply_property sbs_energy_battery_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_TECHNOLOGY, @@ -462,12 +461,18 @@ static ssize_t acpi_battery_alarm_store(struct device *dev, return count; } -static const struct device_attribute alarm_attr = { +static struct device_attribute alarm_attr = { .attr = {.name = "alarm", .mode = 0644}, .show = acpi_battery_alarm_show, .store = acpi_battery_alarm_store, }; +static struct attribute *acpi_battery_attrs[] = { + &alarm_attr.attr, + NULL +}; +ATTRIBUTE_GROUPS(acpi_battery); + /* -------------------------------------------------------------------------- Driver Interface -------------------------------------------------------------------------- */ @@ -518,7 +523,10 @@ static int acpi_battery_read(struct acpi_battery *battery) static int acpi_battery_add(struct acpi_sbs *sbs, int id) { struct acpi_battery *battery = &sbs->battery[id]; - struct power_supply_config psy_cfg = { .drv_data = battery, }; + struct power_supply_config psy_cfg = { + .drv_data = battery, + .attr_grp = acpi_battery_groups, + }; int result; battery->id = id; @@ -548,10 +556,6 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) goto end; } - result = device_create_file(&battery->bat->dev, &alarm_attr); - if (result) - goto end; - battery->have_sysfs_alarm = 1; end: pr_info("%s [%s]: Battery Slot [%s] (battery %s)\n", ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), @@ -563,11 +567,8 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id) { struct acpi_battery *battery = &sbs->battery[id]; - if (battery->bat) { - if (battery->have_sysfs_alarm) - device_remove_file(&battery->bat->dev, &alarm_attr); + if (battery->bat) power_supply_unregister(battery->bat); - } } static int acpi_charger_add(struct acpi_sbs *sbs) diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c index 2cc3821b2b16..c11cbe5b6eaa 100644 --- a/drivers/acpi/video_detect.c +++ b/drivers/acpi/video_detect.c @@ -540,6 +540,14 @@ static const struct dmi_system_id video_detect_dmi_table[] = { }, }, { + .callback = video_detect_force_native, + /* Apple MacBook Air 9,1 */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "MacBookAir9,1"), + }, + }, + { /* https://bugzilla.redhat.com/show_bug.cgi?id=1217249 */ .callback = video_detect_force_native, /* Apple MacBook Pro 12,1 */ @@ -550,6 +558,14 @@ static const struct dmi_system_id video_detect_dmi_table[] = { }, { .callback = video_detect_force_native, + /* Apple MacBook Pro 16,2 */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"), + }, + }, + { + .callback = video_detect_force_native, /* Dell Inspiron N4010 */ .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), diff --git a/drivers/acpi/x86/lpss.c b/drivers/acpi/x86/lpss.c index 148e29c2c526..258440b899a9 100644 --- a/drivers/acpi/x86/lpss.c +++ b/drivers/acpi/x86/lpss.c @@ -338,8 +338,8 @@ static const struct lpss_device_desc bsw_spi_dev_desc = { }; static const struct x86_cpu_id lpss_cpu_ids[] = { - X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT, NULL), - X86_MATCH_INTEL_FAM6_MODEL(ATOM_AIRMONT, NULL), + X86_MATCH_VFM(INTEL_ATOM_SILVERMONT, NULL), + X86_MATCH_VFM(INTEL_ATOM_AIRMONT, NULL), {} }; diff --git a/drivers/acpi/x86/utils.c b/drivers/acpi/x86/utils.c index 2fe0934dcd64..ab2b5fa83e1f 100644 --- a/drivers/acpi/x86/utils.c +++ b/drivers/acpi/x86/utils.c @@ -45,37 +45,37 @@ struct override_status_id { unsigned long long status; }; -#define ENTRY(status, hid, uid, path, cpu_model, dmi...) { \ +#define ENTRY(status, hid, uid, path, cpu_vfm, dmi...) { \ { { hid, }, {} }, \ - { X86_MATCH_INTEL_FAM6_MODEL(cpu_model, NULL), {} }, \ + { X86_MATCH_VFM(cpu_vfm, NULL), {} }, \ { { .matches = dmi }, {} }, \ uid, \ path, \ status, \ } -#define PRESENT_ENTRY_HID(hid, uid, cpu_model, dmi...) \ - ENTRY(ACPI_STA_DEFAULT, hid, uid, NULL, cpu_model, dmi) +#define PRESENT_ENTRY_HID(hid, uid, cpu_vfm, dmi...) \ + ENTRY(ACPI_STA_DEFAULT, hid, uid, NULL, cpu_vfm, dmi) -#define NOT_PRESENT_ENTRY_HID(hid, uid, cpu_model, dmi...) \ - ENTRY(0, hid, uid, NULL, cpu_model, dmi) +#define NOT_PRESENT_ENTRY_HID(hid, uid, cpu_vfm, dmi...) \ + ENTRY(0, hid, uid, NULL, cpu_vfm, dmi) -#define PRESENT_ENTRY_PATH(path, cpu_model, dmi...) \ - ENTRY(ACPI_STA_DEFAULT, "", NULL, path, cpu_model, dmi) +#define PRESENT_ENTRY_PATH(path, cpu_vfm, dmi...) \ + ENTRY(ACPI_STA_DEFAULT, "", NULL, path, cpu_vfm, dmi) -#define NOT_PRESENT_ENTRY_PATH(path, cpu_model, dmi...) \ - ENTRY(0, "", NULL, path, cpu_model, dmi) +#define NOT_PRESENT_ENTRY_PATH(path, cpu_vfm, dmi...) \ + ENTRY(0, "", NULL, path, cpu_vfm, dmi) static const struct override_status_id override_status_ids[] = { /* * Bay / Cherry Trail PWM directly poked by GPU driver in win10, * but Linux uses a separate PWM driver, harmless if not used. */ - PRESENT_ENTRY_HID("80860F09", "1", ATOM_SILVERMONT, {}), - PRESENT_ENTRY_HID("80862288", "1", ATOM_AIRMONT, {}), + PRESENT_ENTRY_HID("80860F09", "1", INTEL_ATOM_SILVERMONT, {}), + PRESENT_ENTRY_HID("80862288", "1", INTEL_ATOM_AIRMONT, {}), /* The Xiaomi Mi Pad 2 uses PWM2 for touchkeys backlight control */ - PRESENT_ENTRY_HID("80862289", "2", ATOM_AIRMONT, { + PRESENT_ENTRY_HID("80862289", "2", INTEL_ATOM_AIRMONT, { DMI_MATCH(DMI_SYS_VENDOR, "Xiaomi Inc"), DMI_MATCH(DMI_PRODUCT_NAME, "Mipad2"), }), @@ -84,18 +84,18 @@ static const struct override_status_id override_status_ids[] = { * The INT0002 device is necessary to clear wakeup interrupt sources * on Cherry Trail devices, without it we get nobody cared IRQ msgs. */ - PRESENT_ENTRY_HID("INT0002", "1", ATOM_AIRMONT, {}), + PRESENT_ENTRY_HID("INT0002", "1", INTEL_ATOM_AIRMONT, {}), /* * On the Dell Venue 11 Pro 7130 and 7139, the DSDT hides * the touchscreen ACPI device until a certain time * after _SB.PCI0.GFX0.LCD.LCD1._ON gets called has passed * *and* _STA has been called at least 3 times since. */ - PRESENT_ENTRY_HID("SYNA7500", "1", HASWELL_L, { + PRESENT_ENTRY_HID("SYNA7500", "1", INTEL_HASWELL_L, { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7130"), }), - PRESENT_ENTRY_HID("SYNA7500", "1", HASWELL_L, { + PRESENT_ENTRY_HID("SYNA7500", "1", INTEL_HASWELL_L, { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7139"), }), @@ -104,7 +104,7 @@ static const struct override_status_id override_status_ids[] = { * The Dell XPS 15 9550 has a SMO8110 accelerometer / * HDD freefall sensor which is wrongly marked as not present. */ - PRESENT_ENTRY_HID("SMO8810", "1", SKYLAKE, { + PRESENT_ENTRY_HID("SMO8810", "1", INTEL_SKYLAKE, { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "XPS 15 9550"), }), @@ -121,19 +121,19 @@ static const struct override_status_id override_status_ids[] = { * was copy-pasted from the GPD win, so it has a disabled KIOX000A * node which we should not enable, thus we also check the BIOS date. */ - PRESENT_ENTRY_HID("KIOX000A", "1", ATOM_AIRMONT, { + PRESENT_ENTRY_HID("KIOX000A", "1", INTEL_ATOM_AIRMONT, { DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), DMI_MATCH(DMI_BOARD_NAME, "Default string"), DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), DMI_MATCH(DMI_BIOS_DATE, "02/21/2017") }), - PRESENT_ENTRY_HID("KIOX000A", "1", ATOM_AIRMONT, { + PRESENT_ENTRY_HID("KIOX000A", "1", INTEL_ATOM_AIRMONT, { DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), DMI_MATCH(DMI_BOARD_NAME, "Default string"), DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), DMI_MATCH(DMI_BIOS_DATE, "03/20/2017") }), - PRESENT_ENTRY_HID("KIOX000A", "1", ATOM_AIRMONT, { + PRESENT_ENTRY_HID("KIOX000A", "1", INTEL_ATOM_AIRMONT, { DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), DMI_MATCH(DMI_BOARD_NAME, "Default string"), DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), @@ -146,7 +146,7 @@ static const struct override_status_id override_status_ids[] = { * method sets a GPIO causing the PCI wifi card to turn off. * See above remark about uniqueness of the DMI match. */ - NOT_PRESENT_ENTRY_PATH("\\_SB_.PCI0.SDHB.BRC1", ATOM_AIRMONT, { + NOT_PRESENT_ENTRY_PATH("\\_SB_.PCI0.SDHB.BRC1", INTEL_ATOM_AIRMONT, { DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), DMI_EXACT_MATCH(DMI_BOARD_NAME, "Default string"), DMI_EXACT_MATCH(DMI_BOARD_SERIAL, "Default string"), @@ -158,7 +158,7 @@ static const struct override_status_id override_status_ids[] = { * as both ACCL0001 and MAGN0001. As we can only ever register an * i2c client for one of them, ignore MAGN0001. */ - NOT_PRESENT_ENTRY_HID("MAGN0001", "1", ATOM_SILVERMONT, { + NOT_PRESENT_ENTRY_HID("MAGN0001", "1", INTEL_ATOM_SILVERMONT, { DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), DMI_MATCH(DMI_PRODUCT_FAMILY, "YOGATablet2"), }), |