Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a7f2766a authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

Merge branches 'acpi-gpio', 'acpi-button', 'acpi-battery' and 'acpi-video'

* acpi-gpio:
  gpio: merrifield: Add support of ACPI enabled platforms
  ACPI: utils: Introduce acpi_dev_get_first_match_name()

* acpi-button:
  ACPI: button: Add a LID switch blacklist and add 1 model to it
  ACPI: button: Add a debug message when we're sending a LID event

* acpi-battery:
  ACPI / battery: Add quirk for Asus GL502VSK and UX305LA
  ACPI: battery: Drop redundant test for failure

* acpi-video:
  ACPI / video: Default lcd_only to true on Win8-ready and newer machines
Loading
Loading
Loading
Loading
+12 −2
Original line number Original line Diff line number Diff line
@@ -80,8 +80,8 @@ MODULE_PARM_DESC(report_key_events,
static bool device_id_scheme = false;
static bool device_id_scheme = false;
module_param(device_id_scheme, bool, 0444);
module_param(device_id_scheme, bool, 0444);


static bool only_lcd = false;
static int only_lcd = -1;
module_param(only_lcd, bool, 0444);
module_param(only_lcd, int, 0444);


static int register_count;
static int register_count;
static DEFINE_MUTEX(register_count_mutex);
static DEFINE_MUTEX(register_count_mutex);
@@ -2136,6 +2136,16 @@ int acpi_video_register(void)
		goto leave;
		goto leave;
	}
	}


	/*
	 * We're seeing a lot of bogus backlight interfaces on newer machines
	 * without a LCD such as desktops, servers and HDMI sticks. Checking
	 * the lcd flag fixes this, so enable this on any machines which are
	 * win8 ready (where we also prefer the native backlight driver, so
	 * normally the acpi_video code should not register there anyways).
	 */
	if (only_lcd == -1)
		only_lcd = acpi_osi_is_win8();

	dmi_check_system(video_dmi_table);
	dmi_check_system(video_dmi_table);


	ret = acpi_bus_register_driver(&acpi_video_bus);
	ret = acpi_bus_register_driver(&acpi_video_bus);
+30 −6
Original line number Original line Diff line number Diff line
@@ -70,6 +70,7 @@ static async_cookie_t async_cookie;
static bool battery_driver_registered;
static bool battery_driver_registered;
static int battery_bix_broken_package;
static int battery_bix_broken_package;
static int battery_notification_delay_ms;
static int battery_notification_delay_ms;
static int battery_full_discharging;
static unsigned int cache_time = 1000;
static unsigned int cache_time = 1000;
module_param(cache_time, uint, 0644);
module_param(cache_time, uint, 0644);
MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
@@ -214,9 +215,12 @@ static int acpi_battery_get_property(struct power_supply *psy,
		return -ENODEV;
		return -ENODEV;
	switch (psp) {
	switch (psp) {
	case POWER_SUPPLY_PROP_STATUS:
	case POWER_SUPPLY_PROP_STATUS:
		if (battery->state & ACPI_BATTERY_STATE_DISCHARGING)
		if (battery->state & ACPI_BATTERY_STATE_DISCHARGING) {
			if (battery_full_discharging && battery->rate_now == 0)
				val->intval = POWER_SUPPLY_STATUS_FULL;
			else
				val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
				val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
		else if (battery->state & ACPI_BATTERY_STATE_CHARGING)
		} else if (battery->state & ACPI_BATTERY_STATE_CHARGING)
			val->intval = POWER_SUPPLY_STATUS_CHARGING;
			val->intval = POWER_SUPPLY_STATUS_CHARGING;
		else if (acpi_battery_is_charged(battery))
		else if (acpi_battery_is_charged(battery))
			val->intval = POWER_SUPPLY_STATUS_FULL;
			val->intval = POWER_SUPPLY_STATUS_FULL;
@@ -1166,6 +1170,12 @@ battery_notification_delay_quirk(const struct dmi_system_id *d)
	return 0;
	return 0;
}
}


static int __init battery_full_discharging_quirk(const struct dmi_system_id *d)
{
	battery_full_discharging = 1;
	return 0;
}

static const struct dmi_system_id bat_dmi_table[] __initconst = {
static const struct dmi_system_id bat_dmi_table[] __initconst = {
	{
	{
		.callback = battery_bix_broken_package_quirk,
		.callback = battery_bix_broken_package_quirk,
@@ -1183,6 +1193,22 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = {
			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"),
			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"),
		},
		},
	},
	},
	{
		.callback = battery_full_discharging_quirk,
		.ident = "ASUS GL502VSK",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
			DMI_MATCH(DMI_PRODUCT_NAME, "GL502VSK"),
		},
	},
	{
		.callback = battery_full_discharging_quirk,
		.ident = "ASUS UX305LA",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
			DMI_MATCH(DMI_PRODUCT_NAME, "UX305LA"),
		},
	},
	{},
	{},
};
};


@@ -1237,13 +1263,11 @@ static int acpi_battery_add(struct acpi_device *device)


#ifdef CONFIG_ACPI_PROCFS_POWER
#ifdef CONFIG_ACPI_PROCFS_POWER
	result = acpi_battery_add_fs(device);
	result = acpi_battery_add_fs(device);
#endif
	if (result) {
	if (result) {
#ifdef CONFIG_ACPI_PROCFS_POWER
		acpi_battery_remove_fs(device);
		acpi_battery_remove_fs(device);
#endif
		goto fail;
		goto fail;
	}
	}
#endif


	printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n",
	printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n",
		ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),
		ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),
+22 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@
#include <linux/input.h>
#include <linux/input.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/acpi.h>
#include <linux/acpi.h>
#include <linux/dmi.h>
#include <acpi/button.h>
#include <acpi/button.h>


#define PREFIX "ACPI: "
#define PREFIX "ACPI: "
@@ -76,6 +77,22 @@ static const struct acpi_device_id button_device_ids[] = {
};
};
MODULE_DEVICE_TABLE(acpi, button_device_ids);
MODULE_DEVICE_TABLE(acpi, button_device_ids);


/*
 * Some devices which don't even have a lid in anyway have a broken _LID
 * method (e.g. pointing to a floating gpio pin) causing spurious LID events.
 */
static const struct dmi_system_id lid_blacklst[] = {
	{
		/* GP-electronic T701 */
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
			DMI_MATCH(DMI_PRODUCT_NAME, "T701"),
			DMI_MATCH(DMI_BIOS_VERSION, "BYT70A.YNCHENG.WIN.007"),
		},
	},
	{}
};

static int acpi_button_add(struct acpi_device *device);
static int acpi_button_add(struct acpi_device *device);
static int acpi_button_remove(struct acpi_device *device);
static int acpi_button_remove(struct acpi_device *device);
static void acpi_button_notify(struct acpi_device *device, u32 event);
static void acpi_button_notify(struct acpi_device *device, u32 event);
@@ -210,6 +227,8 @@ static int acpi_lid_notify_state(struct acpi_device *device, int state)
	}
	}
	/* Send the platform triggered reliable event */
	/* Send the platform triggered reliable event */
	if (do_update) {
	if (do_update) {
		acpi_handle_debug(device->handle, "ACPI LID %s\n",
				  state ? "open" : "closed");
		input_report_switch(button->input, SW_LID, !state);
		input_report_switch(button->input, SW_LID, !state);
		input_sync(button->input);
		input_sync(button->input);
		button->last_state = !!state;
		button->last_state = !!state;
@@ -473,6 +492,9 @@ static int acpi_button_add(struct acpi_device *device)
	char *name, *class;
	char *name, *class;
	int error;
	int error;


	if (!strcmp(hid, ACPI_BUTTON_HID_LID) && dmi_check_system(lid_blacklst))
		return -ENODEV;

	button = kzalloc(sizeof(struct acpi_button), GFP_KERNEL);
	button = kzalloc(sizeof(struct acpi_button), GFP_KERNEL);
	if (!button)
	if (!button)
		return -ENOMEM;
		return -ENOMEM;
+34 −7
Original line number Original line Diff line number Diff line
@@ -737,16 +737,17 @@ bool acpi_dev_found(const char *hid)
}
}
EXPORT_SYMBOL(acpi_dev_found);
EXPORT_SYMBOL(acpi_dev_found);


struct acpi_dev_present_info {
struct acpi_dev_match_info {
	const char *dev_name;
	struct acpi_device_id hid[2];
	struct acpi_device_id hid[2];
	const char *uid;
	const char *uid;
	s64 hrv;
	s64 hrv;
};
};


static int acpi_dev_present_cb(struct device *dev, void *data)
static int acpi_dev_match_cb(struct device *dev, void *data)
{
{
	struct acpi_device *adev = to_acpi_device(dev);
	struct acpi_device *adev = to_acpi_device(dev);
	struct acpi_dev_present_info *match = data;
	struct acpi_dev_match_info *match = data;
	unsigned long long hrv;
	unsigned long long hrv;
	acpi_status status;
	acpi_status status;


@@ -757,6 +758,8 @@ static int acpi_dev_present_cb(struct device *dev, void *data)
	    strcmp(adev->pnp.unique_id, match->uid)))
	    strcmp(adev->pnp.unique_id, match->uid)))
		return 0;
		return 0;


	match->dev_name = acpi_dev_name(adev);

	if (match->hrv == -1)
	if (match->hrv == -1)
		return 1;
		return 1;


@@ -789,20 +792,44 @@ static int acpi_dev_present_cb(struct device *dev, void *data)
 */
 */
bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
{
{
	struct acpi_dev_present_info match = {};
	struct acpi_dev_match_info match = {};
	struct device *dev;
	struct device *dev;


	strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
	strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
	match.uid = uid;
	match.uid = uid;
	match.hrv = hrv;
	match.hrv = hrv;


	dev = bus_find_device(&acpi_bus_type, NULL, &match,
	dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
			      acpi_dev_present_cb);

	return !!dev;
	return !!dev;
}
}
EXPORT_SYMBOL(acpi_dev_present);
EXPORT_SYMBOL(acpi_dev_present);


/**
 * acpi_dev_get_first_match_name - Return name of first match of ACPI device
 * @hid: Hardware ID of the device.
 * @uid: Unique ID of the device, pass NULL to not check _UID
 * @hrv: Hardware Revision of the device, pass -1 to not check _HRV
 *
 * Return device name if a matching device was present
 * at the moment of invocation, or NULL otherwise.
 *
 * See additional information in acpi_dev_present() as well.
 */
const char *
acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv)
{
	struct acpi_dev_match_info match = {};
	struct device *dev;

	strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
	match.uid = uid;
	match.hrv = hrv;

	dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
	return dev ? match.dev_name : NULL;
}
EXPORT_SYMBOL(acpi_dev_get_first_match_name);

/*
/*
 * acpi_backlight= handling, this is done here rather then in video_detect.c
 * acpi_backlight= handling, this is done here rather then in video_detect.c
 * because __setup cannot be used in modules.
 * because __setup cannot be used in modules.
+10 −1
Original line number Original line Diff line number Diff line
@@ -9,6 +9,7 @@
 * published by the Free Software Foundation.
 * published by the Free Software Foundation.
 */
 */


#include <linux/acpi.h>
#include <linux/bitops.h>
#include <linux/bitops.h>
#include <linux/gpio/driver.h>
#include <linux/gpio/driver.h>
#include <linux/init.h>
#include <linux/init.h>
@@ -380,9 +381,16 @@ static void mrfld_irq_init_hw(struct mrfld_gpio *priv)
	}
	}
}
}


static const char *mrfld_gpio_get_pinctrl_dev_name(void)
{
	const char *dev_name = acpi_dev_get_first_match_name("INTC1002", NULL, -1);
	return dev_name ? dev_name : "pinctrl-merrifield";
}

static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id)
static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
{
	const struct mrfld_gpio_pinrange *range;
	const struct mrfld_gpio_pinrange *range;
	const char *pinctrl_dev_name;
	struct mrfld_gpio *priv;
	struct mrfld_gpio *priv;
	u32 gpio_base, irq_base;
	u32 gpio_base, irq_base;
	void __iomem *base;
	void __iomem *base;
@@ -439,10 +447,11 @@ static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id
		return retval;
		return retval;
	}
	}


	pinctrl_dev_name = mrfld_gpio_get_pinctrl_dev_name();
	for (i = 0; i < ARRAY_SIZE(mrfld_gpio_ranges); i++) {
	for (i = 0; i < ARRAY_SIZE(mrfld_gpio_ranges); i++) {
		range = &mrfld_gpio_ranges[i];
		range = &mrfld_gpio_ranges[i];
		retval = gpiochip_add_pin_range(&priv->chip,
		retval = gpiochip_add_pin_range(&priv->chip,
						"pinctrl-merrifield",
						pinctrl_dev_name,
						range->gpio_base,
						range->gpio_base,
						range->pin_base,
						range->pin_base,
						range->npins);
						range->npins);
Loading