Skip to content

Commit 4c99256

Browse files
Raul E Rangelrafaeljw
authored andcommitted
gpiolib: acpi: Add wake_capable variants of acpi_dev_gpio_irq_get
The ACPI spec defines the SharedAndWake and ExclusiveAndWake share type keywords. This is an indication that the GPIO IRQ can also be used as a wake source. This change exposes the wake_capable bit so drivers can correctly enable wake functionality instead of making an assumption. Signed-off-by: Raul E Rangel <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent f76349c commit 4c99256

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

drivers/gpio/gpiolib-acpi.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
741741
lookup->info.pin_config = agpio->pin_config;
742742
lookup->info.debounce = agpio->debounce_timeout;
743743
lookup->info.gpioint = gpioint;
744+
lookup->info.wake_capable = agpio->wake_capable == ACPI_WAKE_CAPABLE;
744745

745746
/*
746747
* Polarity and triggering are only specified for GpioInt
@@ -987,10 +988,11 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
987988
}
988989

989990
/**
990-
* acpi_dev_gpio_irq_get_by() - Find GpioInt and translate it to Linux IRQ number
991+
* acpi_dev_gpio_irq_wake_get_by() - Find GpioInt and translate it to Linux IRQ number
991992
* @adev: pointer to a ACPI device to get IRQ from
992993
* @name: optional name of GpioInt resource
993994
* @index: index of GpioInt resource (starting from %0)
995+
* @wake_capable: Set to true if the IRQ is wake capable
994996
*
995997
* If the device has one or more GpioInt resources, this function can be
996998
* used to translate from the GPIO offset in the resource to the Linux IRQ
@@ -1002,9 +1004,13 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
10021004
* The function takes optional @name parameter. If the resource has a property
10031005
* name, then only those will be taken into account.
10041006
*
1007+
* The GPIO is considered wake capable if the GpioInt resource specifies
1008+
* SharedAndWake or ExclusiveAndWake.
1009+
*
10051010
* Return: Linux IRQ number (> %0) on success, negative errno on failure.
10061011
*/
1007-
int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index)
1012+
int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, int index,
1013+
bool *wake_capable)
10081014
{
10091015
int idx, i;
10101016
unsigned int irq_flags;
@@ -1061,13 +1067,16 @@ int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int ind
10611067
dev_dbg(&adev->dev, "IRQ %d already in use\n", irq);
10621068
}
10631069

1070+
if (wake_capable)
1071+
*wake_capable = info.wake_capable;
1072+
10641073
return irq;
10651074
}
10661075

10671076
}
10681077
return -ENOENT;
10691078
}
1070-
EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_get_by);
1079+
EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_wake_get_by);
10711080

10721081
static acpi_status
10731082
acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,

drivers/gpio/gpiolib-acpi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct acpi_device;
1818
* @pin_config: pin bias as provided by ACPI
1919
* @polarity: interrupt polarity as provided by ACPI
2020
* @triggering: triggering type as provided by ACPI
21+
* @wake_capable: wake capability as provided by ACPI
2122
* @debounce: debounce timeout as provided by ACPI
2223
* @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping
2324
*/
@@ -28,6 +29,7 @@ struct acpi_gpio_info {
2829
int pin_config;
2930
int polarity;
3031
int triggering;
32+
bool wake_capable;
3133
unsigned int debounce;
3234
unsigned int quirks;
3335
};

include/linux/acpi.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,8 @@ bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
12021202
struct acpi_resource_gpio **agpio);
12031203
bool acpi_gpio_get_io_resource(struct acpi_resource *ares,
12041204
struct acpi_resource_gpio **agpio);
1205-
int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index);
1205+
int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, int index,
1206+
bool *wake_capable);
12061207
#else
12071208
static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
12081209
struct acpi_resource_gpio **agpio)
@@ -1214,16 +1215,28 @@ static inline bool acpi_gpio_get_io_resource(struct acpi_resource *ares,
12141215
{
12151216
return false;
12161217
}
1217-
static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev,
1218-
const char *name, int index)
1218+
static inline int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name,
1219+
int index, bool *wake_capable)
12191220
{
12201221
return -ENXIO;
12211222
}
12221223
#endif
12231224

1225+
static inline int acpi_dev_gpio_irq_wake_get(struct acpi_device *adev, int index,
1226+
bool *wake_capable)
1227+
{
1228+
return acpi_dev_gpio_irq_wake_get_by(adev, NULL, index, wake_capable);
1229+
}
1230+
1231+
static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name,
1232+
int index)
1233+
{
1234+
return acpi_dev_gpio_irq_wake_get_by(adev, name, index, NULL);
1235+
}
1236+
12241237
static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
12251238
{
1226-
return acpi_dev_gpio_irq_get_by(adev, NULL, index);
1239+
return acpi_dev_gpio_irq_wake_get_by(adev, NULL, index, NULL);
12271240
}
12281241

12291242
/* Device properties */

0 commit comments

Comments
 (0)