Skip to content

Commit

Permalink
Merge tag 'platform-drivers-x86-v6.5-3' of git://git.kernel.org/pub/s…
Browse files Browse the repository at this point in the history
…cm/linux/kernel/git/pdx86/platform-drivers-x86

Pull x86 platform driver fixes from Hans de Goede:
 "Misc small fixes and hw-id additions"

* tag 'platform-drivers-x86-v6.5-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86:
  platform/x86: huawei-wmi: Silence ambient light sensor
  platform/x86: msi-laptop: Fix rfkill out-of-sync on MSI Wind U100
  platform/x86: asus-wmi: Fix setting RGB mode on some TUF laptops
  platform/x86: think-lmi: Use kfree_sensitive instead of kfree
  platform/x86/intel/hid: Add HP Dragonfly G2 to VGBS DMI quirks
  platform/x86: intel: hid: Always call BTNL ACPI method
  platform/x86/amd/pmf: Notify OS power slider update
  platform/x86/amd/pmf: reduce verbosity of apmf_get_system_params
  platform/x86: serial-multi-instantiate: Auto detect IRQ resource for CSC3551
  platform/x86/amd: pmc: Use release_mem_region() to undo request_mem_region_muxed()
  platform/x86: touchscreen_dmi.c: small changes for Archos 101 Cesium Educ tablet
  • Loading branch information
Linus Torvalds committed Jul 26, 2023
2 parents f40125c + c217337 commit 0a8db05
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 40 deletions.
8 changes: 2 additions & 6 deletions drivers/platform/x86/amd/pmc-quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <linux/dmi.h>
#include <linux/io.h>
#include <linux/ioport.h>
#include <linux/slab.h>

#include "pmc.h"

Expand Down Expand Up @@ -135,12 +134,10 @@ static const struct dmi_system_id fwbug_list[] = {
*/
static void amd_pmc_skip_nvme_smi_handler(u32 s2idle_bug_mmio)
{
struct resource *res;
void __iomem *addr;
u8 val;

res = request_mem_region_muxed(s2idle_bug_mmio, 1, "amd_pmc_pm80");
if (!res)
if (!request_mem_region_muxed(s2idle_bug_mmio, 1, "amd_pmc_pm80"))
return;

addr = ioremap(s2idle_bug_mmio, 1);
Expand All @@ -152,8 +149,7 @@ static void amd_pmc_skip_nvme_smi_handler(u32 s2idle_bug_mmio)

iounmap(addr);
cleanup_resource:
release_resource(res);
kfree(res);
release_mem_region(s2idle_bug_mmio, 1);
}

void amd_pmc_process_restore_quirks(struct amd_pmc_dev *dev)
Expand Down
23 changes: 22 additions & 1 deletion drivers/platform/x86/amd/pmf/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,27 @@ int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev,
data, sizeof(*data));
}

int apmf_os_power_slider_update(struct amd_pmf_dev *pdev, u8 event)
{
struct os_power_slider args;
struct acpi_buffer params;
union acpi_object *info;
int err = 0;

args.size = sizeof(args);
args.slider_event = event;

params.length = sizeof(args);
params.pointer = (void *)&args;

info = apmf_if_call(pdev, APMF_FUNC_OS_POWER_SLIDER_UPDATE, &params);
if (!info)
err = -EIO;

kfree(info);
return err;
}

static void apmf_sbios_heartbeat_notify(struct work_struct *work)
{
struct amd_pmf_dev *dev = container_of(work, struct amd_pmf_dev, heart_beat.work);
Expand Down Expand Up @@ -289,7 +310,7 @@ int apmf_acpi_init(struct amd_pmf_dev *pmf_dev)

ret = apmf_get_system_params(pmf_dev);
if (ret) {
dev_err(pmf_dev->dev, "APMF apmf_get_system_params failed :%d\n", ret);
dev_dbg(pmf_dev->dev, "APMF apmf_get_system_params failed :%d\n", ret);
goto out;
}

Expand Down
9 changes: 7 additions & 2 deletions drivers/platform/x86/amd/pmf/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ static int amd_pmf_pwr_src_notify_call(struct notifier_block *nb, unsigned long
return NOTIFY_DONE;
}

amd_pmf_set_sps_power_limits(pmf);
if (is_apmf_func_supported(pmf, APMF_FUNC_STATIC_SLIDER_GRANULAR))
amd_pmf_set_sps_power_limits(pmf);

if (is_apmf_func_supported(pmf, APMF_FUNC_OS_POWER_SLIDER_UPDATE))
amd_pmf_power_slider_update_event(pmf);

return NOTIFY_OK;
}
Expand Down Expand Up @@ -297,7 +301,8 @@ static void amd_pmf_init_features(struct amd_pmf_dev *dev)
int ret;

/* Enable Static Slider */
if (is_apmf_func_supported(dev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) {
if (is_apmf_func_supported(dev, APMF_FUNC_STATIC_SLIDER_GRANULAR) ||
is_apmf_func_supported(dev, APMF_FUNC_OS_POWER_SLIDER_UPDATE)) {
amd_pmf_init_sps(dev);
dev->pwr_src_notifier.notifier_call = amd_pmf_pwr_src_notify_call;
power_supply_reg_notifier(&dev->pwr_src_notifier);
Expand Down
16 changes: 16 additions & 0 deletions drivers/platform/x86/amd/pmf/pmf.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define APMF_FUNC_SBIOS_HEARTBEAT 4
#define APMF_FUNC_AUTO_MODE 5
#define APMF_FUNC_SET_FAN_IDX 7
#define APMF_FUNC_OS_POWER_SLIDER_UPDATE 8
#define APMF_FUNC_STATIC_SLIDER_GRANULAR 9
#define APMF_FUNC_DYN_SLIDER_AC 11
#define APMF_FUNC_DYN_SLIDER_DC 12
Expand All @@ -44,6 +45,14 @@
#define GET_STT_LIMIT_APU 0x20
#define GET_STT_LIMIT_HS2 0x21

/* OS slider update notification */
#define DC_BEST_PERF 0
#define DC_BETTER_PERF 1
#define DC_BATTERY_SAVER 3
#define AC_BEST_PERF 4
#define AC_BETTER_PERF 5
#define AC_BETTER_BATTERY 6

/* Fan Index for Auto Mode */
#define FAN_INDEX_AUTO 0xFFFFFFFF

Expand Down Expand Up @@ -193,6 +202,11 @@ struct amd_pmf_static_slider_granular {
struct apmf_sps_prop_granular prop[POWER_SOURCE_MAX][POWER_MODE_MAX];
};

struct os_power_slider {
u16 size;
u8 slider_event;
} __packed;

struct fan_table_control {
bool manual;
unsigned long fan_id;
Expand Down Expand Up @@ -383,6 +397,7 @@ int amd_pmf_send_cmd(struct amd_pmf_dev *dev, u8 message, bool get, u32 arg, u32
int amd_pmf_init_metrics_table(struct amd_pmf_dev *dev);
int amd_pmf_get_power_source(void);
int apmf_install_handler(struct amd_pmf_dev *pmf_dev);
int apmf_os_power_slider_update(struct amd_pmf_dev *dev, u8 flag);

/* SPS Layer */
int amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf);
Expand All @@ -393,6 +408,7 @@ void amd_pmf_deinit_sps(struct amd_pmf_dev *dev);
int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev,
struct apmf_static_slider_granular_output *output);
bool is_pprof_balanced(struct amd_pmf_dev *pmf);
int amd_pmf_power_slider_update_event(struct amd_pmf_dev *dev);


int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx);
Expand Down
74 changes: 70 additions & 4 deletions drivers/platform/x86/amd/pmf/sps.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,25 +174,91 @@ int amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf)
return mode;
}

int amd_pmf_power_slider_update_event(struct amd_pmf_dev *dev)
{
u8 mode, flag = 0;
int src;

mode = amd_pmf_get_pprof_modes(dev);
if (mode < 0)
return mode;

src = amd_pmf_get_power_source();

if (src == POWER_SOURCE_AC) {
switch (mode) {
case POWER_MODE_PERFORMANCE:
flag |= BIT(AC_BEST_PERF);
break;
case POWER_MODE_BALANCED_POWER:
flag |= BIT(AC_BETTER_PERF);
break;
case POWER_MODE_POWER_SAVER:
flag |= BIT(AC_BETTER_BATTERY);
break;
default:
dev_err(dev->dev, "unsupported platform profile\n");
return -EOPNOTSUPP;
}

} else if (src == POWER_SOURCE_DC) {
switch (mode) {
case POWER_MODE_PERFORMANCE:
flag |= BIT(DC_BEST_PERF);
break;
case POWER_MODE_BALANCED_POWER:
flag |= BIT(DC_BETTER_PERF);
break;
case POWER_MODE_POWER_SAVER:
flag |= BIT(DC_BATTERY_SAVER);
break;
default:
dev_err(dev->dev, "unsupported platform profile\n");
return -EOPNOTSUPP;
}
}

apmf_os_power_slider_update(dev, flag);

return 0;
}

static int amd_pmf_profile_set(struct platform_profile_handler *pprof,
enum platform_profile_option profile)
{
struct amd_pmf_dev *pmf = container_of(pprof, struct amd_pmf_dev, pprof);
int ret = 0;

pmf->current_profile = profile;

return amd_pmf_set_sps_power_limits(pmf);
/* Notify EC about the slider position change */
if (is_apmf_func_supported(pmf, APMF_FUNC_OS_POWER_SLIDER_UPDATE)) {
ret = amd_pmf_power_slider_update_event(pmf);
if (ret)
return ret;
}

if (is_apmf_func_supported(pmf, APMF_FUNC_STATIC_SLIDER_GRANULAR)) {
ret = amd_pmf_set_sps_power_limits(pmf);
if (ret)
return ret;
}

return 0;
}

int amd_pmf_init_sps(struct amd_pmf_dev *dev)
{
int err;

dev->current_profile = PLATFORM_PROFILE_BALANCED;
amd_pmf_load_defaults_sps(dev);

/* update SPS balanced power mode thermals */
amd_pmf_set_sps_power_limits(dev);
if (is_apmf_func_supported(dev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) {
amd_pmf_load_defaults_sps(dev);

/* update SPS balanced power mode thermals */
amd_pmf_set_sps_power_limits(dev);
}

dev->pprof.profile_get = amd_pmf_profile_get;
dev->pprof.profile_set = amd_pmf_profile_set;
Expand Down
14 changes: 12 additions & 2 deletions drivers/platform/x86/asus-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,13 +738,23 @@ static ssize_t kbd_rgb_mode_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
u32 cmd, mode, r, g, b, speed;
u32 cmd, mode, r, g, b, speed;
int err;

if (sscanf(buf, "%d %d %d %d %d %d", &cmd, &mode, &r, &g, &b, &speed) != 6)
return -EINVAL;

cmd = !!cmd;
/* B3 is set and B4 is save to BIOS */
switch (cmd) {
case 0:
cmd = 0xb3;
break;
case 1:
cmd = 0xb4;
break;
default:
return -EINVAL;
}

/* These are the known usable modes across all TUF/ROG */
if (mode >= 12 || mode == 9)
Expand Down
2 changes: 2 additions & 0 deletions drivers/platform/x86/huawei-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ static const struct key_entry huawei_wmi_keymap[] = {
{ KE_IGNORE, 0x293, { KEY_KBDILLUMTOGGLE } },
{ KE_IGNORE, 0x294, { KEY_KBDILLUMUP } },
{ KE_IGNORE, 0x295, { KEY_KBDILLUMUP } },
// Ignore Ambient Light Sensoring
{ KE_KEY, 0x2c1, { KEY_RESERVED } },
{ KE_END, 0 }
};

Expand Down
27 changes: 15 additions & 12 deletions drivers/platform/x86/intel/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ static const struct dmi_system_id dmi_vgbs_allow_list[] = {
DMI_MATCH(DMI_PRODUCT_NAME, "Surface Go"),
},
},
{
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "HP"),
DMI_MATCH(DMI_PRODUCT_NAME, "HP Elite Dragonfly G2 Notebook PC"),
},
},
{ }
};

Expand Down Expand Up @@ -620,7 +626,7 @@ static bool button_array_present(struct platform_device *device)
static int intel_hid_probe(struct platform_device *device)
{
acpi_handle handle = ACPI_HANDLE(&device->dev);
unsigned long long mode;
unsigned long long mode, dummy;
struct intel_hid_priv *priv;
acpi_status status;
int err;
Expand Down Expand Up @@ -692,18 +698,15 @@ static int intel_hid_probe(struct platform_device *device)
if (err)
goto err_remove_notify;

if (priv->array) {
unsigned long long dummy;
intel_button_array_enable(&device->dev, true);

intel_button_array_enable(&device->dev, true);

/* Call button load method to enable HID power button */
if (!intel_hid_evaluate_method(handle, INTEL_HID_DSM_BTNL_FN,
&dummy)) {
dev_warn(&device->dev,
"failed to enable HID power button\n");
}
}
/*
* Call button load method to enable HID power button
* Always do this since it activates events on some devices without
* a button array too.
*/
if (!intel_hid_evaluate_method(handle, INTEL_HID_DSM_BTNL_FN, &dummy))
dev_warn(&device->dev, "failed to enable HID power button\n");

device_init_wakeup(&device->dev, true);
/*
Expand Down
8 changes: 4 additions & 4 deletions drivers/platform/x86/msi-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static ssize_t set_device_state(const char *buf, size_t count, u8 mask)
return -EINVAL;

if (quirks->ec_read_only)
return -EOPNOTSUPP;
return 0;

/* read current device state */
result = ec_read(MSI_STANDARD_EC_COMMAND_ADDRESS, &rdata);
Expand Down Expand Up @@ -838,15 +838,15 @@ static bool msi_laptop_i8042_filter(unsigned char data, unsigned char str,
static void msi_init_rfkill(struct work_struct *ignored)
{
if (rfk_wlan) {
rfkill_set_sw_state(rfk_wlan, !wlan_s);
msi_rfkill_set_state(rfk_wlan, !wlan_s);
rfkill_wlan_set(NULL, !wlan_s);
}
if (rfk_bluetooth) {
rfkill_set_sw_state(rfk_bluetooth, !bluetooth_s);
msi_rfkill_set_state(rfk_bluetooth, !bluetooth_s);
rfkill_bluetooth_set(NULL, !bluetooth_s);
}
if (rfk_threeg) {
rfkill_set_sw_state(rfk_threeg, !threeg_s);
msi_rfkill_set_state(rfk_threeg, !threeg_s);
rfkill_threeg_set(NULL, !threeg_s);
}
}
Expand Down
21 changes: 17 additions & 4 deletions drivers/platform/x86/serial-multi-instantiate.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define IRQ_RESOURCE_NONE 0
#define IRQ_RESOURCE_GPIO 1
#define IRQ_RESOURCE_APIC 2
#define IRQ_RESOURCE_AUTO 3

enum smi_bus_type {
SMI_I2C,
Expand Down Expand Up @@ -52,6 +53,18 @@ static int smi_get_irq(struct platform_device *pdev, struct acpi_device *adev,
int ret;

switch (inst->flags & IRQ_RESOURCE_TYPE) {
case IRQ_RESOURCE_AUTO:
ret = acpi_dev_gpio_irq_get(adev, inst->irq_idx);
if (ret > 0) {
dev_dbg(&pdev->dev, "Using gpio irq\n");
break;
}
ret = platform_get_irq(pdev, inst->irq_idx);
if (ret > 0) {
dev_dbg(&pdev->dev, "Using platform irq\n");
break;
}
break;
case IRQ_RESOURCE_GPIO:
ret = acpi_dev_gpio_irq_get(adev, inst->irq_idx);
break;
Expand Down Expand Up @@ -307,10 +320,10 @@ static const struct smi_node int3515_data = {

static const struct smi_node cs35l41_hda = {
.instances = {
{ "cs35l41-hda", IRQ_RESOURCE_GPIO, 0 },
{ "cs35l41-hda", IRQ_RESOURCE_GPIO, 0 },
{ "cs35l41-hda", IRQ_RESOURCE_GPIO, 0 },
{ "cs35l41-hda", IRQ_RESOURCE_GPIO, 0 },
{ "cs35l41-hda", IRQ_RESOURCE_AUTO, 0 },
{ "cs35l41-hda", IRQ_RESOURCE_AUTO, 0 },
{ "cs35l41-hda", IRQ_RESOURCE_AUTO, 0 },
{ "cs35l41-hda", IRQ_RESOURCE_AUTO, 0 },
{}
},
.bus_type = SMI_AUTO_DETECT,
Expand Down
Loading

0 comments on commit 0a8db05

Please sign in to comment.