Commit 664e3e5a authored by Mika Westerberg's avatar Mika Westerberg Committed by Linus Walleij

gpio / ACPI: register to ACPI events automatically

Instead of asking each driver to register to ACPI events we can just call
acpi_gpiochip_register_interrupts() for each chip that has an ACPI handle.
The function checks chip->to_irq and if it is set to NULL (a GPIO driver
that doesn't do interrupts) the function does nothing.

We also add the a new header drivers/gpio/gpiolib.h that is used for
functions internal to gpiolib and add ACPI GPIO chip registering functions
to that header.

Once that is done we can remove call to acpi_gpiochip_register_interrupts()
from its only user, pinctrl-baytrail.c
Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 87875655
...@@ -94,7 +94,7 @@ static void acpi_gpio_evt_dh(acpi_handle handle, void *data) ...@@ -94,7 +94,7 @@ static void acpi_gpio_evt_dh(acpi_handle handle, void *data)
* gpio pins have acpi event methods and assigns interrupt handlers that calls * gpio pins have acpi event methods and assigns interrupt handlers that calls
* the acpi event methods for those pins. * the acpi event methods for those pins.
*/ */
void acpi_gpiochip_request_interrupts(struct gpio_chip *chip) static void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
{ {
struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL}; struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL};
struct acpi_resource *res; struct acpi_resource *res;
...@@ -192,7 +192,6 @@ void acpi_gpiochip_request_interrupts(struct gpio_chip *chip) ...@@ -192,7 +192,6 @@ void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
irq); irq);
} }
} }
EXPORT_SYMBOL(acpi_gpiochip_request_interrupts);
/** /**
* acpi_gpiochip_free_interrupts() - Free GPIO _EVT ACPI event interrupts. * acpi_gpiochip_free_interrupts() - Free GPIO _EVT ACPI event interrupts.
...@@ -203,7 +202,7 @@ EXPORT_SYMBOL(acpi_gpiochip_request_interrupts); ...@@ -203,7 +202,7 @@ EXPORT_SYMBOL(acpi_gpiochip_request_interrupts);
* The remaining ACPI event interrupts associated with the chip are freed * The remaining ACPI event interrupts associated with the chip are freed
* automatically. * automatically.
*/ */
void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) static void acpi_gpiochip_free_interrupts(struct gpio_chip *chip)
{ {
acpi_handle handle; acpi_handle handle;
acpi_status status; acpi_status status;
...@@ -230,7 +229,6 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) ...@@ -230,7 +229,6 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip)
acpi_detach_data(handle, acpi_gpio_evt_dh); acpi_detach_data(handle, acpi_gpio_evt_dh);
kfree(evt_pins); kfree(evt_pins);
} }
EXPORT_SYMBOL(acpi_gpiochip_free_interrupts);
struct acpi_gpio_lookup { struct acpi_gpio_lookup {
struct acpi_gpio_info info; struct acpi_gpio_info info;
...@@ -310,3 +308,13 @@ struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index, ...@@ -310,3 +308,13 @@ struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index,
return lookup.desc ? lookup.desc : ERR_PTR(-ENOENT); return lookup.desc ? lookup.desc : ERR_PTR(-ENOENT);
} }
EXPORT_SYMBOL_GPL(acpi_get_gpiod_by_index); EXPORT_SYMBOL_GPL(acpi_get_gpiod_by_index);
void acpi_gpiochip_add(struct gpio_chip *chip)
{
acpi_gpiochip_request_interrupts(chip);
}
void acpi_gpiochip_remove(struct gpio_chip *chip)
{
acpi_gpiochip_free_interrupts(chip);
}
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/gpio/driver.h> #include <linux/gpio/driver.h>
#include "gpiolib.h"
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include <trace/events/gpio.h> #include <trace/events/gpio.h>
...@@ -1226,6 +1228,7 @@ int gpiochip_add(struct gpio_chip *chip) ...@@ -1226,6 +1228,7 @@ int gpiochip_add(struct gpio_chip *chip)
#endif #endif
of_gpiochip_add(chip); of_gpiochip_add(chip);
acpi_gpiochip_add(chip);
if (status) if (status)
goto fail; goto fail;
...@@ -1267,6 +1270,7 @@ int gpiochip_remove(struct gpio_chip *chip) ...@@ -1267,6 +1270,7 @@ int gpiochip_remove(struct gpio_chip *chip)
gpiochip_remove_pin_ranges(chip); gpiochip_remove_pin_ranges(chip);
of_gpiochip_remove(chip); of_gpiochip_remove(chip);
acpi_gpiochip_remove(chip);
for (id = 0; id < chip->ngpio; id++) { for (id = 0; id < chip->ngpio; id++) {
if (test_bit(FLAG_REQUESTED, &chip->desc[id].flags)) { if (test_bit(FLAG_REQUESTED, &chip->desc[id].flags)) {
......
/*
* Internal GPIO functions.
*
* Copyright (C) 2013, Intel Corporation
* Author: Mika Westerberg <mika.westerberg@linux.intel.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef GPIOLIB_H
#define GPIOLIB_H
#ifdef CONFIG_ACPI
void acpi_gpiochip_add(struct gpio_chip *chip);
void acpi_gpiochip_remove(struct gpio_chip *chip);
#else
static inline void acpi_gpiochip_add(struct gpio_chip *chip) { }
static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { }
#endif
#endif /* GPIOLIB_H */
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/irqdomain.h> #include <linux/irqdomain.h>
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/acpi_gpio.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/io.h> #include <linux/io.h>
...@@ -485,9 +484,6 @@ static int byt_gpio_probe(struct platform_device *pdev) ...@@ -485,9 +484,6 @@ static int byt_gpio_probe(struct platform_device *pdev)
irq_set_handler_data(hwirq, vg); irq_set_handler_data(hwirq, vg);
irq_set_chained_handler(hwirq, byt_gpio_irq_handler); irq_set_chained_handler(hwirq, byt_gpio_irq_handler);
/* Register interrupt handlers for gpio signaled acpi events */
acpi_gpiochip_request_interrupts(gc);
} }
pm_runtime_enable(dev); pm_runtime_enable(dev);
......
...@@ -21,9 +21,6 @@ struct acpi_gpio_info { ...@@ -21,9 +21,6 @@ struct acpi_gpio_info {
struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index, struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index,
struct acpi_gpio_info *info); struct acpi_gpio_info *info);
void acpi_gpiochip_request_interrupts(struct gpio_chip *chip);
void acpi_gpiochip_free_interrupts(struct gpio_chip *chip);
#else /* CONFIG_GPIO_ACPI */ #else /* CONFIG_GPIO_ACPI */
static inline struct gpio_desc * static inline struct gpio_desc *
...@@ -33,9 +30,6 @@ acpi_get_gpiod_by_index(struct device *dev, int index, ...@@ -33,9 +30,6 @@ acpi_get_gpiod_by_index(struct device *dev, int index,
return ERR_PTR(-ENOSYS); return ERR_PTR(-ENOSYS);
} }
static inline void acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { }
static inline void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { }
#endif /* CONFIG_GPIO_ACPI */ #endif /* CONFIG_GPIO_ACPI */
static inline int acpi_get_gpio_by_index(struct device *dev, int index, static inline int acpi_get_gpio_by_index(struct device *dev, int index,
......
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