Commit d74da846 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'platform-drivers-x86-v6.11-3' of...

Merge tag 'platform-drivers-x86-v6.11-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86

Pull x86 platform driver fixes from Ilpo Järvinen:
 "While the ideapad concurrency fix itself is relatively
  straightforward, it required moving code around and adding a bit of
  supporting infrastructure to have a clean inter-driver interface. This
  shows up in the diffstats.

   - ideapad-laptop / lenovo-ymc: Protect VPC calls with a mutex

   - amd/pmf: Query HPD data also when ALS is disabled"

* tag 'platform-drivers-x86-v6.11-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86:
  platform/x86: ideapad-laptop: add a mutex to synchronize VPC commands
  platform/x86: ideapad-laptop: move ymc_trigger_ec from lenovo-ymc
  platform/x86: ideapad-laptop: introduce a generic notification chain
  platform/x86/amd/pmf: Fix to Update HPD Data When ALS is Disabled
parents a1460e45 7cc06e72
...@@ -477,6 +477,7 @@ config LENOVO_YMC ...@@ -477,6 +477,7 @@ config LENOVO_YMC
tristate "Lenovo Yoga Tablet Mode Control" tristate "Lenovo Yoga Tablet Mode Control"
depends on ACPI_WMI depends on ACPI_WMI
depends on INPUT depends on INPUT
depends on IDEAPAD_LAPTOP
select INPUT_SPARSEKMAP select INPUT_SPARSEKMAP
help help
This driver maps the Tablet Mode Control switch to SW_TABLET_MODE input This driver maps the Tablet Mode Control switch to SW_TABLET_MODE input
......
...@@ -150,36 +150,26 @@ static int amd_pmf_get_slider_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_ ...@@ -150,36 +150,26 @@ static int amd_pmf_get_slider_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_
return 0; return 0;
} }
static int amd_pmf_get_sensor_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) static void amd_pmf_get_sensor_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
{ {
struct amd_sfh_info sfh_info; struct amd_sfh_info sfh_info;
int ret;
/* Get the latest information from SFH */
in->ev_info.user_present = false;
/* Get ALS data */ /* Get ALS data */
ret = amd_get_sfh_info(&sfh_info, MT_ALS); if (!amd_get_sfh_info(&sfh_info, MT_ALS))
if (!ret)
in->ev_info.ambient_light = sfh_info.ambient_light; in->ev_info.ambient_light = sfh_info.ambient_light;
else else
return ret; dev_dbg(dev->dev, "ALS is not enabled/detected\n");
/* get HPD data */ /* get HPD data */
ret = amd_get_sfh_info(&sfh_info, MT_HPD); if (!amd_get_sfh_info(&sfh_info, MT_HPD)) {
if (ret) if (sfh_info.user_present == SFH_USER_PRESENT)
return ret; in->ev_info.user_present = true;
} else {
switch (sfh_info.user_present) { dev_dbg(dev->dev, "HPD is not enabled/detected\n");
case SFH_NOT_DETECTED:
in->ev_info.user_present = 0xff; /* assume no sensors connected */
break;
case SFH_USER_PRESENT:
in->ev_info.user_present = 1;
break;
case SFH_USER_AWAY:
in->ev_info.user_present = 0;
break;
} }
return 0;
} }
void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
......
...@@ -126,6 +126,7 @@ struct ideapad_rfk_priv { ...@@ -126,6 +126,7 @@ struct ideapad_rfk_priv {
struct ideapad_private { struct ideapad_private {
struct acpi_device *adev; struct acpi_device *adev;
struct mutex vpc_mutex; /* protects the VPC calls */
struct rfkill *rfk[IDEAPAD_RFKILL_DEV_NUM]; struct rfkill *rfk[IDEAPAD_RFKILL_DEV_NUM];
struct ideapad_rfk_priv rfk_priv[IDEAPAD_RFKILL_DEV_NUM]; struct ideapad_rfk_priv rfk_priv[IDEAPAD_RFKILL_DEV_NUM];
struct platform_device *platform_device; struct platform_device *platform_device;
...@@ -146,6 +147,7 @@ struct ideapad_private { ...@@ -146,6 +147,7 @@ struct ideapad_private {
bool touchpad_ctrl_via_ec : 1; bool touchpad_ctrl_via_ec : 1;
bool ctrl_ps2_aux_port : 1; bool ctrl_ps2_aux_port : 1;
bool usb_charging : 1; bool usb_charging : 1;
bool ymc_ec_trigger : 1;
} features; } features;
struct { struct {
bool initialized; bool initialized;
...@@ -194,6 +196,12 @@ MODULE_PARM_DESC(touchpad_ctrl_via_ec, ...@@ -194,6 +196,12 @@ MODULE_PARM_DESC(touchpad_ctrl_via_ec,
"Enable registering a 'touchpad' sysfs-attribute which can be used to manually " "Enable registering a 'touchpad' sysfs-attribute which can be used to manually "
"tell the EC to enable/disable the touchpad. This may not work on all models."); "tell the EC to enable/disable the touchpad. This may not work on all models.");
static bool ymc_ec_trigger __read_mostly;
module_param(ymc_ec_trigger, bool, 0444);
MODULE_PARM_DESC(ymc_ec_trigger,
"Enable EC triggering work-around to force emitting tablet mode events. "
"If you need this please report this to: platform-driver-x86@vger.kernel.org");
/* /*
* shared data * shared data
*/ */
...@@ -294,6 +302,8 @@ static int debugfs_status_show(struct seq_file *s, void *data) ...@@ -294,6 +302,8 @@ static int debugfs_status_show(struct seq_file *s, void *data)
struct ideapad_private *priv = s->private; struct ideapad_private *priv = s->private;
unsigned long value; unsigned long value;
guard(mutex)(&priv->vpc_mutex);
if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_MAX, &value)) if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_MAX, &value))
seq_printf(s, "Backlight max: %lu\n", value); seq_printf(s, "Backlight max: %lu\n", value);
if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL, &value)) if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL, &value))
...@@ -412,6 +422,7 @@ static ssize_t camera_power_show(struct device *dev, ...@@ -412,6 +422,7 @@ static ssize_t camera_power_show(struct device *dev,
unsigned long result; unsigned long result;
int err; int err;
scoped_guard(mutex, &priv->vpc_mutex)
err = read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &result); err = read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &result);
if (err) if (err)
return err; return err;
...@@ -431,6 +442,7 @@ static ssize_t camera_power_store(struct device *dev, ...@@ -431,6 +442,7 @@ static ssize_t camera_power_store(struct device *dev,
if (err) if (err)
return err; return err;
scoped_guard(mutex, &priv->vpc_mutex)
err = write_ec_cmd(priv->adev->handle, VPCCMD_W_CAMERA, state); err = write_ec_cmd(priv->adev->handle, VPCCMD_W_CAMERA, state);
if (err) if (err)
return err; return err;
...@@ -484,6 +496,7 @@ static ssize_t fan_mode_show(struct device *dev, ...@@ -484,6 +496,7 @@ static ssize_t fan_mode_show(struct device *dev,
unsigned long result; unsigned long result;
int err; int err;
scoped_guard(mutex, &priv->vpc_mutex)
err = read_ec_data(priv->adev->handle, VPCCMD_R_FAN, &result); err = read_ec_data(priv->adev->handle, VPCCMD_R_FAN, &result);
if (err) if (err)
return err; return err;
...@@ -506,6 +519,7 @@ static ssize_t fan_mode_store(struct device *dev, ...@@ -506,6 +519,7 @@ static ssize_t fan_mode_store(struct device *dev,
if (state > 4 || state == 3) if (state > 4 || state == 3)
return -EINVAL; return -EINVAL;
scoped_guard(mutex, &priv->vpc_mutex)
err = write_ec_cmd(priv->adev->handle, VPCCMD_W_FAN, state); err = write_ec_cmd(priv->adev->handle, VPCCMD_W_FAN, state);
if (err) if (err)
return err; return err;
...@@ -591,6 +605,7 @@ static ssize_t touchpad_show(struct device *dev, ...@@ -591,6 +605,7 @@ static ssize_t touchpad_show(struct device *dev,
unsigned long result; unsigned long result;
int err; int err;
scoped_guard(mutex, &priv->vpc_mutex)
err = read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &result); err = read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &result);
if (err) if (err)
return err; return err;
...@@ -612,6 +627,7 @@ static ssize_t touchpad_store(struct device *dev, ...@@ -612,6 +627,7 @@ static ssize_t touchpad_store(struct device *dev,
if (err) if (err)
return err; return err;
scoped_guard(mutex, &priv->vpc_mutex)
err = write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, state); err = write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, state);
if (err) if (err)
return err; return err;
...@@ -1005,6 +1021,8 @@ static int ideapad_rfk_set(void *data, bool blocked) ...@@ -1005,6 +1021,8 @@ static int ideapad_rfk_set(void *data, bool blocked)
struct ideapad_rfk_priv *priv = data; struct ideapad_rfk_priv *priv = data;
int opcode = ideapad_rfk_data[priv->dev].opcode; int opcode = ideapad_rfk_data[priv->dev].opcode;
guard(mutex)(&priv->priv->vpc_mutex);
return write_ec_cmd(priv->priv->adev->handle, opcode, !blocked); return write_ec_cmd(priv->priv->adev->handle, opcode, !blocked);
} }
...@@ -1018,6 +1036,8 @@ static void ideapad_sync_rfk_state(struct ideapad_private *priv) ...@@ -1018,6 +1036,8 @@ static void ideapad_sync_rfk_state(struct ideapad_private *priv)
int i; int i;
if (priv->features.hw_rfkill_switch) { if (priv->features.hw_rfkill_switch) {
guard(mutex)(&priv->vpc_mutex);
if (read_ec_data(priv->adev->handle, VPCCMD_R_RF, &hw_blocked)) if (read_ec_data(priv->adev->handle, VPCCMD_R_RF, &hw_blocked))
return; return;
hw_blocked = !hw_blocked; hw_blocked = !hw_blocked;
...@@ -1191,6 +1211,7 @@ static void ideapad_input_novokey(struct ideapad_private *priv) ...@@ -1191,6 +1211,7 @@ static void ideapad_input_novokey(struct ideapad_private *priv)
{ {
unsigned long long_pressed; unsigned long long_pressed;
scoped_guard(mutex, &priv->vpc_mutex)
if (read_ec_data(priv->adev->handle, VPCCMD_R_NOVO, &long_pressed)) if (read_ec_data(priv->adev->handle, VPCCMD_R_NOVO, &long_pressed))
return; return;
...@@ -1204,6 +1225,7 @@ static void ideapad_check_special_buttons(struct ideapad_private *priv) ...@@ -1204,6 +1225,7 @@ static void ideapad_check_special_buttons(struct ideapad_private *priv)
{ {
unsigned long bit, value; unsigned long bit, value;
scoped_guard(mutex, &priv->vpc_mutex)
if (read_ec_data(priv->adev->handle, VPCCMD_R_SPECIAL_BUTTONS, &value)) if (read_ec_data(priv->adev->handle, VPCCMD_R_SPECIAL_BUTTONS, &value))
return; return;
...@@ -1238,6 +1260,8 @@ static int ideapad_backlight_get_brightness(struct backlight_device *blightdev) ...@@ -1238,6 +1260,8 @@ static int ideapad_backlight_get_brightness(struct backlight_device *blightdev)
unsigned long now; unsigned long now;
int err; int err;
guard(mutex)(&priv->vpc_mutex);
err = read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now); err = read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now);
if (err) if (err)
return err; return err;
...@@ -1250,6 +1274,8 @@ static int ideapad_backlight_update_status(struct backlight_device *blightdev) ...@@ -1250,6 +1274,8 @@ static int ideapad_backlight_update_status(struct backlight_device *blightdev)
struct ideapad_private *priv = bl_get_data(blightdev); struct ideapad_private *priv = bl_get_data(blightdev);
int err; int err;
guard(mutex)(&priv->vpc_mutex);
err = write_ec_cmd(priv->adev->handle, VPCCMD_W_BL, err = write_ec_cmd(priv->adev->handle, VPCCMD_W_BL,
blightdev->props.brightness); blightdev->props.brightness);
if (err) if (err)
...@@ -1327,6 +1353,8 @@ static void ideapad_backlight_notify_power(struct ideapad_private *priv) ...@@ -1327,6 +1353,8 @@ static void ideapad_backlight_notify_power(struct ideapad_private *priv)
if (!blightdev) if (!blightdev)
return; return;
guard(mutex)(&priv->vpc_mutex);
if (read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &power)) if (read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &power))
return; return;
...@@ -1339,6 +1367,7 @@ static void ideapad_backlight_notify_brightness(struct ideapad_private *priv) ...@@ -1339,6 +1367,7 @@ static void ideapad_backlight_notify_brightness(struct ideapad_private *priv)
/* if we control brightness via acpi video driver */ /* if we control brightness via acpi video driver */
if (!priv->blightdev) if (!priv->blightdev)
scoped_guard(mutex, &priv->vpc_mutex)
read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now); read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now);
else else
backlight_force_update(priv->blightdev, BACKLIGHT_UPDATE_HOTKEY); backlight_force_update(priv->blightdev, BACKLIGHT_UPDATE_HOTKEY);
...@@ -1564,6 +1593,7 @@ static void ideapad_sync_touchpad_state(struct ideapad_private *priv, bool send_ ...@@ -1564,6 +1593,7 @@ static void ideapad_sync_touchpad_state(struct ideapad_private *priv, bool send_
int ret; int ret;
/* Without reading from EC touchpad LED doesn't switch state */ /* Without reading from EC touchpad LED doesn't switch state */
scoped_guard(mutex, &priv->vpc_mutex)
ret = read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value); ret = read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value);
if (ret) if (ret)
return; return;
...@@ -1592,16 +1622,92 @@ static void ideapad_sync_touchpad_state(struct ideapad_private *priv, bool send_ ...@@ -1592,16 +1622,92 @@ static void ideapad_sync_touchpad_state(struct ideapad_private *priv, bool send_
priv->r_touchpad_val = value; priv->r_touchpad_val = value;
} }
static const struct dmi_system_id ymc_ec_trigger_quirk_dmi_table[] = {
{
/* Lenovo Yoga 7 14ARB7 */
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "82QF"),
},
},
{
/* Lenovo Yoga 7 14ACN6 */
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "82N7"),
},
},
{ }
};
static void ideapad_laptop_trigger_ec(void)
{
struct ideapad_private *priv;
int ret;
guard(mutex)(&ideapad_shared_mutex);
priv = ideapad_shared;
if (!priv)
return;
if (!priv->features.ymc_ec_trigger)
return;
scoped_guard(mutex, &priv->vpc_mutex)
ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_YMC, 1);
if (ret)
dev_warn(&priv->platform_device->dev, "Could not write YMC: %d\n", ret);
}
static int ideapad_laptop_nb_notify(struct notifier_block *nb,
unsigned long action, void *data)
{
switch (action) {
case IDEAPAD_LAPTOP_YMC_EVENT:
ideapad_laptop_trigger_ec();
break;
}
return 0;
}
static struct notifier_block ideapad_laptop_notifier = {
.notifier_call = ideapad_laptop_nb_notify,
};
static BLOCKING_NOTIFIER_HEAD(ideapad_laptop_chain_head);
int ideapad_laptop_register_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_register(&ideapad_laptop_chain_head, nb);
}
EXPORT_SYMBOL_NS_GPL(ideapad_laptop_register_notifier, IDEAPAD_LAPTOP);
int ideapad_laptop_unregister_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_unregister(&ideapad_laptop_chain_head, nb);
}
EXPORT_SYMBOL_NS_GPL(ideapad_laptop_unregister_notifier, IDEAPAD_LAPTOP);
void ideapad_laptop_call_notifier(unsigned long action, void *data)
{
blocking_notifier_call_chain(&ideapad_laptop_chain_head, action, data);
}
EXPORT_SYMBOL_NS_GPL(ideapad_laptop_call_notifier, IDEAPAD_LAPTOP);
static void ideapad_acpi_notify(acpi_handle handle, u32 event, void *data) static void ideapad_acpi_notify(acpi_handle handle, u32 event, void *data)
{ {
struct ideapad_private *priv = data; struct ideapad_private *priv = data;
unsigned long vpc1, vpc2, bit; unsigned long vpc1, vpc2, bit;
scoped_guard(mutex, &priv->vpc_mutex) {
if (read_ec_data(handle, VPCCMD_R_VPC1, &vpc1)) if (read_ec_data(handle, VPCCMD_R_VPC1, &vpc1))
return; return;
if (read_ec_data(handle, VPCCMD_R_VPC2, &vpc2)) if (read_ec_data(handle, VPCCMD_R_VPC2, &vpc2))
return; return;
}
vpc1 = (vpc2 << 8) | vpc1; vpc1 = (vpc2 << 8) | vpc1;
...@@ -1728,6 +1834,8 @@ static void ideapad_check_features(struct ideapad_private *priv) ...@@ -1728,6 +1834,8 @@ static void ideapad_check_features(struct ideapad_private *priv)
priv->features.ctrl_ps2_aux_port = priv->features.ctrl_ps2_aux_port =
ctrl_ps2_aux_port || dmi_check_system(ctrl_ps2_aux_port_list); ctrl_ps2_aux_port || dmi_check_system(ctrl_ps2_aux_port_list);
priv->features.touchpad_ctrl_via_ec = touchpad_ctrl_via_ec; priv->features.touchpad_ctrl_via_ec = touchpad_ctrl_via_ec;
priv->features.ymc_ec_trigger =
ymc_ec_trigger || dmi_check_system(ymc_ec_trigger_quirk_dmi_table);
if (!read_ec_data(handle, VPCCMD_R_FAN, &val)) if (!read_ec_data(handle, VPCCMD_R_FAN, &val))
priv->features.fan_mode = true; priv->features.fan_mode = true;
...@@ -1906,6 +2014,10 @@ static int ideapad_acpi_add(struct platform_device *pdev) ...@@ -1906,6 +2014,10 @@ static int ideapad_acpi_add(struct platform_device *pdev)
priv->adev = adev; priv->adev = adev;
priv->platform_device = pdev; priv->platform_device = pdev;
err = devm_mutex_init(&pdev->dev, &priv->vpc_mutex);
if (err)
return err;
ideapad_check_features(priv); ideapad_check_features(priv);
err = ideapad_sysfs_init(priv); err = ideapad_sysfs_init(priv);
...@@ -1974,6 +2086,8 @@ static int ideapad_acpi_add(struct platform_device *pdev) ...@@ -1974,6 +2086,8 @@ static int ideapad_acpi_add(struct platform_device *pdev)
if (err) if (err)
goto shared_init_failed; goto shared_init_failed;
ideapad_laptop_register_notifier(&ideapad_laptop_notifier);
return 0; return 0;
shared_init_failed: shared_init_failed:
...@@ -2006,6 +2120,8 @@ static void ideapad_acpi_remove(struct platform_device *pdev) ...@@ -2006,6 +2120,8 @@ static void ideapad_acpi_remove(struct platform_device *pdev)
struct ideapad_private *priv = dev_get_drvdata(&pdev->dev); struct ideapad_private *priv = dev_get_drvdata(&pdev->dev);
int i; int i;
ideapad_laptop_unregister_notifier(&ideapad_laptop_notifier);
ideapad_shared_exit(priv); ideapad_shared_exit(priv);
acpi_remove_notify_handler(priv->adev->handle, acpi_remove_notify_handler(priv->adev->handle,
......
...@@ -12,6 +12,15 @@ ...@@ -12,6 +12,15 @@
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/notifier.h>
enum ideapad_laptop_notifier_actions {
IDEAPAD_LAPTOP_YMC_EVENT,
};
int ideapad_laptop_register_notifier(struct notifier_block *nb);
int ideapad_laptop_unregister_notifier(struct notifier_block *nb);
void ideapad_laptop_call_notifier(unsigned long action, void *data);
enum { enum {
VPCCMD_R_VPC1 = 0x10, VPCCMD_R_VPC1 = 0x10,
......
...@@ -20,32 +20,10 @@ ...@@ -20,32 +20,10 @@
#define LENOVO_YMC_QUERY_INSTANCE 0 #define LENOVO_YMC_QUERY_INSTANCE 0
#define LENOVO_YMC_QUERY_METHOD 0x01 #define LENOVO_YMC_QUERY_METHOD 0x01
static bool ec_trigger __read_mostly;
module_param(ec_trigger, bool, 0444);
MODULE_PARM_DESC(ec_trigger, "Enable EC triggering work-around to force emitting tablet mode events");
static bool force; static bool force;
module_param(force, bool, 0444); module_param(force, bool, 0444);
MODULE_PARM_DESC(force, "Force loading on boards without a convertible DMI chassis-type"); MODULE_PARM_DESC(force, "Force loading on boards without a convertible DMI chassis-type");
static const struct dmi_system_id ec_trigger_quirk_dmi_table[] = {
{
/* Lenovo Yoga 7 14ARB7 */
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "82QF"),
},
},
{
/* Lenovo Yoga 7 14ACN6 */
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "82N7"),
},
},
{ }
};
static const struct dmi_system_id allowed_chasis_types_dmi_table[] = { static const struct dmi_system_id allowed_chasis_types_dmi_table[] = {
{ {
.matches = { .matches = {
...@@ -62,21 +40,8 @@ static const struct dmi_system_id allowed_chasis_types_dmi_table[] = { ...@@ -62,21 +40,8 @@ static const struct dmi_system_id allowed_chasis_types_dmi_table[] = {
struct lenovo_ymc_private { struct lenovo_ymc_private {
struct input_dev *input_dev; struct input_dev *input_dev;
struct acpi_device *ec_acpi_dev;
}; };
static void lenovo_ymc_trigger_ec(struct wmi_device *wdev, struct lenovo_ymc_private *priv)
{
int err;
if (!priv->ec_acpi_dev)
return;
err = write_ec_cmd(priv->ec_acpi_dev->handle, VPCCMD_W_YMC, 1);
if (err)
dev_warn(&wdev->dev, "Could not write YMC: %d\n", err);
}
static const struct key_entry lenovo_ymc_keymap[] = { static const struct key_entry lenovo_ymc_keymap[] = {
/* Laptop */ /* Laptop */
{ KE_SW, 0x01, { .sw = { SW_TABLET_MODE, 0 } } }, { KE_SW, 0x01, { .sw = { SW_TABLET_MODE, 0 } } },
...@@ -125,11 +90,9 @@ static void lenovo_ymc_notify(struct wmi_device *wdev, union acpi_object *data) ...@@ -125,11 +90,9 @@ static void lenovo_ymc_notify(struct wmi_device *wdev, union acpi_object *data)
free_obj: free_obj:
kfree(obj); kfree(obj);
lenovo_ymc_trigger_ec(wdev, priv); ideapad_laptop_call_notifier(IDEAPAD_LAPTOP_YMC_EVENT, &code);
} }
static void acpi_dev_put_helper(void *p) { acpi_dev_put(p); }
static int lenovo_ymc_probe(struct wmi_device *wdev, const void *ctx) static int lenovo_ymc_probe(struct wmi_device *wdev, const void *ctx)
{ {
struct lenovo_ymc_private *priv; struct lenovo_ymc_private *priv;
...@@ -143,29 +106,10 @@ static int lenovo_ymc_probe(struct wmi_device *wdev, const void *ctx) ...@@ -143,29 +106,10 @@ static int lenovo_ymc_probe(struct wmi_device *wdev, const void *ctx)
return -ENODEV; return -ENODEV;
} }
ec_trigger |= dmi_check_system(ec_trigger_quirk_dmi_table);
priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
if (ec_trigger) {
pr_debug("Lenovo YMC enable EC triggering.\n");
priv->ec_acpi_dev = acpi_dev_get_first_match_dev("VPC2004", NULL, -1);
if (!priv->ec_acpi_dev) {
dev_err(&wdev->dev, "Could not find EC ACPI device.\n");
return -ENODEV;
}
err = devm_add_action_or_reset(&wdev->dev,
acpi_dev_put_helper, priv->ec_acpi_dev);
if (err) {
dev_err(&wdev->dev,
"Could not clean up EC ACPI device: %d\n", err);
return err;
}
}
input_dev = devm_input_allocate_device(&wdev->dev); input_dev = devm_input_allocate_device(&wdev->dev);
if (!input_dev) if (!input_dev)
return -ENOMEM; return -ENOMEM;
...@@ -192,7 +136,6 @@ static int lenovo_ymc_probe(struct wmi_device *wdev, const void *ctx) ...@@ -192,7 +136,6 @@ static int lenovo_ymc_probe(struct wmi_device *wdev, const void *ctx)
dev_set_drvdata(&wdev->dev, priv); dev_set_drvdata(&wdev->dev, priv);
/* Report the state for the first time on probe */ /* Report the state for the first time on probe */
lenovo_ymc_trigger_ec(wdev, priv);
lenovo_ymc_notify(wdev, NULL); lenovo_ymc_notify(wdev, NULL);
return 0; return 0;
} }
...@@ -217,3 +160,4 @@ module_wmi_driver(lenovo_ymc_driver); ...@@ -217,3 +160,4 @@ module_wmi_driver(lenovo_ymc_driver);
MODULE_AUTHOR("Gergo Koteles <soyer@irl.hu>"); MODULE_AUTHOR("Gergo Koteles <soyer@irl.hu>");
MODULE_DESCRIPTION("Lenovo Yoga Mode Control driver"); MODULE_DESCRIPTION("Lenovo Yoga Mode Control driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_IMPORT_NS(IDEAPAD_LAPTOP);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment