Skip to content

Commit a7f2766

Browse files
committed
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
5 parents 0c81e26 + dd1dbf9 + 9e811e1 + c68f067 + 5928c28 commit a7f2766

File tree

7 files changed

+117
-16
lines changed

7 files changed

+117
-16
lines changed

drivers/acpi/acpi_video.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ MODULE_PARM_DESC(report_key_events,
8080
static bool device_id_scheme = false;
8181
module_param(device_id_scheme, bool, 0444);
8282

83-
static bool only_lcd = false;
84-
module_param(only_lcd, bool, 0444);
83+
static int only_lcd = -1;
84+
module_param(only_lcd, int, 0444);
8585

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

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

21412151
ret = acpi_bus_register_driver(&acpi_video_bus);

drivers/acpi/battery.c

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static async_cookie_t async_cookie;
7070
static bool battery_driver_registered;
7171
static int battery_bix_broken_package;
7272
static int battery_notification_delay_ms;
73+
static int battery_full_discharging;
7374
static unsigned int cache_time = 1000;
7475
module_param(cache_time, uint, 0644);
7576
MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
@@ -214,9 +215,12 @@ static int acpi_battery_get_property(struct power_supply *psy,
214215
return -ENODEV;
215216
switch (psp) {
216217
case POWER_SUPPLY_PROP_STATUS:
217-
if (battery->state & ACPI_BATTERY_STATE_DISCHARGING)
218-
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
219-
else if (battery->state & ACPI_BATTERY_STATE_CHARGING)
218+
if (battery->state & ACPI_BATTERY_STATE_DISCHARGING) {
219+
if (battery_full_discharging && battery->rate_now == 0)
220+
val->intval = POWER_SUPPLY_STATUS_FULL;
221+
else
222+
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
223+
} else if (battery->state & ACPI_BATTERY_STATE_CHARGING)
220224
val->intval = POWER_SUPPLY_STATUS_CHARGING;
221225
else if (acpi_battery_is_charged(battery))
222226
val->intval = POWER_SUPPLY_STATUS_FULL;
@@ -1166,6 +1170,12 @@ battery_notification_delay_quirk(const struct dmi_system_id *d)
11661170
return 0;
11671171
}
11681172

1173+
static int __init battery_full_discharging_quirk(const struct dmi_system_id *d)
1174+
{
1175+
battery_full_discharging = 1;
1176+
return 0;
1177+
}
1178+
11691179
static const struct dmi_system_id bat_dmi_table[] __initconst = {
11701180
{
11711181
.callback = battery_bix_broken_package_quirk,
@@ -1183,6 +1193,22 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = {
11831193
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"),
11841194
},
11851195
},
1196+
{
1197+
.callback = battery_full_discharging_quirk,
1198+
.ident = "ASUS GL502VSK",
1199+
.matches = {
1200+
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
1201+
DMI_MATCH(DMI_PRODUCT_NAME, "GL502VSK"),
1202+
},
1203+
},
1204+
{
1205+
.callback = battery_full_discharging_quirk,
1206+
.ident = "ASUS UX305LA",
1207+
.matches = {
1208+
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
1209+
DMI_MATCH(DMI_PRODUCT_NAME, "UX305LA"),
1210+
},
1211+
},
11861212
{},
11871213
};
11881214

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

12381264
#ifdef CONFIG_ACPI_PROCFS_POWER
12391265
result = acpi_battery_add_fs(device);
1240-
#endif
12411266
if (result) {
1242-
#ifdef CONFIG_ACPI_PROCFS_POWER
12431267
acpi_battery_remove_fs(device);
1244-
#endif
12451268
goto fail;
12461269
}
1270+
#endif
12471271

12481272
printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n",
12491273
ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),

drivers/acpi/button.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/input.h>
3131
#include <linux/slab.h>
3232
#include <linux/acpi.h>
33+
#include <linux/dmi.h>
3334
#include <acpi/button.h>
3435

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

80+
/*
81+
* Some devices which don't even have a lid in anyway have a broken _LID
82+
* method (e.g. pointing to a floating gpio pin) causing spurious LID events.
83+
*/
84+
static const struct dmi_system_id lid_blacklst[] = {
85+
{
86+
/* GP-electronic T701 */
87+
.matches = {
88+
DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
89+
DMI_MATCH(DMI_PRODUCT_NAME, "T701"),
90+
DMI_MATCH(DMI_BIOS_VERSION, "BYT70A.YNCHENG.WIN.007"),
91+
},
92+
},
93+
{}
94+
};
95+
7996
static int acpi_button_add(struct acpi_device *device);
8097
static int acpi_button_remove(struct acpi_device *device);
8198
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)
210227
}
211228
/* Send the platform triggered reliable event */
212229
if (do_update) {
230+
acpi_handle_debug(device->handle, "ACPI LID %s\n",
231+
state ? "open" : "closed");
213232
input_report_switch(button->input, SW_LID, !state);
214233
input_sync(button->input);
215234
button->last_state = !!state;
@@ -473,6 +492,9 @@ static int acpi_button_add(struct acpi_device *device)
473492
char *name, *class;
474493
int error;
475494

495+
if (!strcmp(hid, ACPI_BUTTON_HID_LID) && dmi_check_system(lid_blacklst))
496+
return -ENODEV;
497+
476498
button = kzalloc(sizeof(struct acpi_button), GFP_KERNEL);
477499
if (!button)
478500
return -ENOMEM;

drivers/acpi/utils.c

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -737,16 +737,17 @@ bool acpi_dev_found(const char *hid)
737737
}
738738
EXPORT_SYMBOL(acpi_dev_found);
739739

740-
struct acpi_dev_present_info {
740+
struct acpi_dev_match_info {
741+
const char *dev_name;
741742
struct acpi_device_id hid[2];
742743
const char *uid;
743744
s64 hrv;
744745
};
745746

746-
static int acpi_dev_present_cb(struct device *dev, void *data)
747+
static int acpi_dev_match_cb(struct device *dev, void *data)
747748
{
748749
struct acpi_device *adev = to_acpi_device(dev);
749-
struct acpi_dev_present_info *match = data;
750+
struct acpi_dev_match_info *match = data;
750751
unsigned long long hrv;
751752
acpi_status status;
752753

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

761+
match->dev_name = acpi_dev_name(adev);
762+
760763
if (match->hrv == -1)
761764
return 1;
762765

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

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

799-
dev = bus_find_device(&acpi_bus_type, NULL, &match,
800-
acpi_dev_present_cb);
801-
802+
dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
802803
return !!dev;
803804
}
804805
EXPORT_SYMBOL(acpi_dev_present);
805806

807+
/**
808+
* acpi_dev_get_first_match_name - Return name of first match of ACPI device
809+
* @hid: Hardware ID of the device.
810+
* @uid: Unique ID of the device, pass NULL to not check _UID
811+
* @hrv: Hardware Revision of the device, pass -1 to not check _HRV
812+
*
813+
* Return device name if a matching device was present
814+
* at the moment of invocation, or NULL otherwise.
815+
*
816+
* See additional information in acpi_dev_present() as well.
817+
*/
818+
const char *
819+
acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv)
820+
{
821+
struct acpi_dev_match_info match = {};
822+
struct device *dev;
823+
824+
strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
825+
match.uid = uid;
826+
match.hrv = hrv;
827+
828+
dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
829+
return dev ? match.dev_name : NULL;
830+
}
831+
EXPORT_SYMBOL(acpi_dev_get_first_match_name);
832+
806833
/*
807834
* acpi_backlight= handling, this is done here rather then in video_detect.c
808835
* because __setup cannot be used in modules.

drivers/gpio/gpio-merrifield.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* published by the Free Software Foundation.
1010
*/
1111

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

384+
static const char *mrfld_gpio_get_pinctrl_dev_name(void)
385+
{
386+
const char *dev_name = acpi_dev_get_first_match_name("INTC1002", NULL, -1);
387+
return dev_name ? dev_name : "pinctrl-merrifield";
388+
}
389+
383390
static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id)
384391
{
385392
const struct mrfld_gpio_pinrange *range;
393+
const char *pinctrl_dev_name;
386394
struct mrfld_gpio *priv;
387395
u32 gpio_base, irq_base;
388396
void __iomem *base;
@@ -439,10 +447,11 @@ static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id
439447
return retval;
440448
}
441449

450+
pinctrl_dev_name = mrfld_gpio_get_pinctrl_dev_name();
442451
for (i = 0; i < ARRAY_SIZE(mrfld_gpio_ranges); i++) {
443452
range = &mrfld_gpio_ranges[i];
444453
retval = gpiochip_add_pin_range(&priv->chip,
445-
"pinctrl-merrifield",
454+
pinctrl_dev_name,
446455
range->gpio_base,
447456
range->pin_base,
448457
range->npins);

include/acpi/acpi_bus.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev,
9191
bool acpi_dev_found(const char *hid);
9292
bool acpi_dev_present(const char *hid, const char *uid, s64 hrv);
9393

94+
const char *
95+
acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv);
96+
9497
#ifdef CONFIG_ACPI
9598

9699
#include <linux/proc_fs.h>

include/linux/acpi.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,12 @@ static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
640640
return false;
641641
}
642642

643+
static inline const char *
644+
acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv)
645+
{
646+
return NULL;
647+
}
648+
643649
static inline bool is_acpi_node(struct fwnode_handle *fwnode)
644650
{
645651
return false;

0 commit comments

Comments
 (0)