Skip to content

Commit 4a3033e

Browse files
committed
Merge tag 'gpio-v5.5-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO fixes from Linus Walleij: "Here is a host of GPIO fixes for the v5.5 series. The ACPI fix is especially important, see summary below and in the commit for details: - Select GPIOLIB_IRQCHIP on the max77620 GPIO expander - Fix context restore in the Zynq driver - Create a new ACPI quirk handler for disabling wakeups on problematic hardware. - Fix a coding style issue on the mockup device" * tag 'gpio-v5.5-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: gpiolib: acpi: Add honor_wakeup module-option + quirk mechanism gpiolib: acpi: Turn dmi_system_id table into a generic quirk table gpio: zynq: Fix for bug in zynq_gpio_restore_context API gpio: max77620: Add missing dependency on GPIOLIB_IRQCHIP gpio: mockup: fix coding style
2 parents a6a55b5 + aa23ca3 commit 4a3033e

File tree

4 files changed

+54
-10
lines changed

4 files changed

+54
-10
lines changed

drivers/gpio/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,7 @@ config GPIO_MADERA
11481148
config GPIO_MAX77620
11491149
tristate "GPIO support for PMIC MAX77620 and MAX20024"
11501150
depends on MFD_MAX77620
1151+
select GPIOLIB_IRQCHIP
11511152
help
11521153
GPIO driver for MAX77620 and MAX20024 PMIC from Maxim Semiconductor.
11531154
MAX77620 PMIC has 8 pins that can be configured as GPIOs. The

drivers/gpio/gpio-mockup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static int gpio_mockup_apply_pull(struct gpio_mockup_chip *chip,
156156
mutex_lock(&chip->lock);
157157

158158
if (test_bit(FLAG_REQUESTED, &desc->flags) &&
159-
!test_bit(FLAG_IS_OUT, &desc->flags)) {
159+
!test_bit(FLAG_IS_OUT, &desc->flags)) {
160160
curr = __gpio_mockup_get(chip, offset);
161161
if (curr == value)
162162
goto out;
@@ -165,7 +165,7 @@ static int gpio_mockup_apply_pull(struct gpio_mockup_chip *chip,
165165
irq_type = irq_get_trigger_type(irq);
166166

167167
if ((value == 1 && (irq_type & IRQ_TYPE_EDGE_RISING)) ||
168-
(value == 0 && (irq_type & IRQ_TYPE_EDGE_FALLING)))
168+
(value == 0 && (irq_type & IRQ_TYPE_EDGE_FALLING)))
169169
irq_sim_fire(sim, offset);
170170
}
171171

drivers/gpio/gpio-zynq.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,8 @@ static void zynq_gpio_restore_context(struct zynq_gpio *gpio)
684684
unsigned int bank_num;
685685

686686
for (bank_num = 0; bank_num < gpio->p_data->max_bank; bank_num++) {
687+
writel_relaxed(ZYNQ_GPIO_IXR_DISABLE_ALL, gpio->base_addr +
688+
ZYNQ_GPIO_INTDIS_OFFSET(bank_num));
687689
writel_relaxed(gpio->context.datalsw[bank_num],
688690
gpio->base_addr +
689691
ZYNQ_GPIO_DATA_LSW_OFFSET(bank_num));
@@ -693,9 +695,6 @@ static void zynq_gpio_restore_context(struct zynq_gpio *gpio)
693695
writel_relaxed(gpio->context.dirm[bank_num],
694696
gpio->base_addr +
695697
ZYNQ_GPIO_DIRM_OFFSET(bank_num));
696-
writel_relaxed(gpio->context.int_en[bank_num],
697-
gpio->base_addr +
698-
ZYNQ_GPIO_INTEN_OFFSET(bank_num));
699698
writel_relaxed(gpio->context.int_type[bank_num],
700699
gpio->base_addr +
701700
ZYNQ_GPIO_INTTYPE_OFFSET(bank_num));
@@ -705,6 +704,9 @@ static void zynq_gpio_restore_context(struct zynq_gpio *gpio)
705704
writel_relaxed(gpio->context.int_any[bank_num],
706705
gpio->base_addr +
707706
ZYNQ_GPIO_INTANY_OFFSET(bank_num));
707+
writel_relaxed(~(gpio->context.int_en[bank_num]),
708+
gpio->base_addr +
709+
ZYNQ_GPIO_INTEN_OFFSET(bank_num));
708710
}
709711
}
710712

drivers/gpio/gpiolib-acpi.c

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,19 @@
2121
#include "gpiolib.h"
2222
#include "gpiolib-acpi.h"
2323

24+
#define QUIRK_NO_EDGE_EVENTS_ON_BOOT 0x01l
25+
#define QUIRK_NO_WAKEUP 0x02l
26+
2427
static int run_edge_events_on_boot = -1;
2528
module_param(run_edge_events_on_boot, int, 0444);
2629
MODULE_PARM_DESC(run_edge_events_on_boot,
2730
"Run edge _AEI event-handlers at boot: 0=no, 1=yes, -1=auto");
2831

32+
static int honor_wakeup = -1;
33+
module_param(honor_wakeup, int, 0444);
34+
MODULE_PARM_DESC(honor_wakeup,
35+
"Honor the ACPI wake-capable flag: 0=no, 1=yes, -1=auto");
36+
2937
/**
3038
* struct acpi_gpio_event - ACPI GPIO event handler data
3139
*
@@ -281,7 +289,7 @@ static acpi_status acpi_gpiochip_alloc_event(struct acpi_resource *ares,
281289
event->handle = evt_handle;
282290
event->handler = handler;
283291
event->irq = irq;
284-
event->irq_is_wake = agpio->wake_capable == ACPI_WAKE_CAPABLE;
292+
event->irq_is_wake = honor_wakeup && agpio->wake_capable == ACPI_WAKE_CAPABLE;
285293
event->pin = pin;
286294
event->desc = desc;
287295

@@ -1309,7 +1317,7 @@ static int acpi_gpio_handle_deferred_request_irqs(void)
13091317
/* We must use _sync so that this runs after the first deferred_probe run */
13101318
late_initcall_sync(acpi_gpio_handle_deferred_request_irqs);
13111319

1312-
static const struct dmi_system_id run_edge_events_on_boot_blacklist[] = {
1320+
static const struct dmi_system_id gpiolib_acpi_quirks[] = {
13131321
{
13141322
/*
13151323
* The Minix Neo Z83-4 has a micro-USB-B id-pin handler for
@@ -1319,7 +1327,8 @@ static const struct dmi_system_id run_edge_events_on_boot_blacklist[] = {
13191327
.matches = {
13201328
DMI_MATCH(DMI_SYS_VENDOR, "MINIX"),
13211329
DMI_MATCH(DMI_PRODUCT_NAME, "Z83-4"),
1322-
}
1330+
},
1331+
.driver_data = (void *)QUIRK_NO_EDGE_EVENTS_ON_BOOT,
13231332
},
13241333
{
13251334
/*
@@ -1331,20 +1340,52 @@ static const struct dmi_system_id run_edge_events_on_boot_blacklist[] = {
13311340
.matches = {
13321341
DMI_MATCH(DMI_SYS_VENDOR, "Wortmann_AG"),
13331342
DMI_MATCH(DMI_PRODUCT_NAME, "TERRA_PAD_1061"),
1334-
}
1343+
},
1344+
.driver_data = (void *)QUIRK_NO_EDGE_EVENTS_ON_BOOT,
1345+
},
1346+
{
1347+
/*
1348+
* Various HP X2 10 Cherry Trail models use an external
1349+
* embedded-controller connected via I2C + an ACPI GPIO
1350+
* event handler. The embedded controller generates various
1351+
* spurious wakeup events when suspended. So disable wakeup
1352+
* for its handler (it uses the only ACPI GPIO event handler).
1353+
* This breaks wakeup when opening the lid, the user needs
1354+
* to press the power-button to wakeup the system. The
1355+
* alternative is suspend simply not working, which is worse.
1356+
*/
1357+
.matches = {
1358+
DMI_MATCH(DMI_SYS_VENDOR, "HP"),
1359+
DMI_MATCH(DMI_PRODUCT_NAME, "HP x2 Detachable 10-p0XX"),
1360+
},
1361+
.driver_data = (void *)QUIRK_NO_WAKEUP,
13351362
},
13361363
{} /* Terminating entry */
13371364
};
13381365

13391366
static int acpi_gpio_setup_params(void)
13401367
{
1368+
const struct dmi_system_id *id;
1369+
long quirks = 0;
1370+
1371+
id = dmi_first_match(gpiolib_acpi_quirks);
1372+
if (id)
1373+
quirks = (long)id->driver_data;
1374+
13411375
if (run_edge_events_on_boot < 0) {
1342-
if (dmi_check_system(run_edge_events_on_boot_blacklist))
1376+
if (quirks & QUIRK_NO_EDGE_EVENTS_ON_BOOT)
13431377
run_edge_events_on_boot = 0;
13441378
else
13451379
run_edge_events_on_boot = 1;
13461380
}
13471381

1382+
if (honor_wakeup < 0) {
1383+
if (quirks & QUIRK_NO_WAKEUP)
1384+
honor_wakeup = 0;
1385+
else
1386+
honor_wakeup = 1;
1387+
}
1388+
13481389
return 0;
13491390
}
13501391

0 commit comments

Comments
 (0)