Skip to content

Commit ef74f70

Browse files
masneybLinus Walleij
authored andcommitted
gpio: add irq domain activate/deactivate functions
This adds the two new functions gpiochip_irq_domain_activate and gpiochip_irq_domain_deactivate that can be used as the activate and deactivate functions in the struct irq_domain_ops. This is for situations where only gpiochip_{lock,unlock}_as_irq needs to be called. SPMI and SSBI GPIO are two users that will initially use these functions. Signed-off-by: Brian Masney <masneyb@onstation.org> Suggested-by: Stephen Boyd <sboyd@kernel.org> Reviewed-by: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 12a9eea commit ef74f70

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

‎drivers/gpio/gpiolib.c‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,6 +1775,43 @@ static const struct irq_domain_ops gpiochip_domain_ops = {
17751775
.xlate = irq_domain_xlate_twocell,
17761776
};
17771777

1778+
/**
1779+
* gpiochip_irq_domain_activate() - Lock a GPIO to be used as an IRQ
1780+
* @domain: The IRQ domain used by this IRQ chip
1781+
* @data: Outermost irq_data associated with the IRQ
1782+
* @reserve: If set, only reserve an interrupt vector instead of assigning one
1783+
*
1784+
* This function is a wrapper that calls gpiochip_lock_as_irq() and is to be
1785+
* used as the activate function for the &struct irq_domain_ops. The host_data
1786+
* for the IRQ domain must be the &struct gpio_chip.
1787+
*/
1788+
int gpiochip_irq_domain_activate(struct irq_domain *domain,
1789+
struct irq_data *data, bool reserve)
1790+
{
1791+
struct gpio_chip *chip = domain->host_data;
1792+
1793+
return gpiochip_lock_as_irq(chip, data->hwirq);
1794+
}
1795+
EXPORT_SYMBOL_GPL(gpiochip_irq_domain_activate);
1796+
1797+
/**
1798+
* gpiochip_irq_domain_deactivate() - Unlock a GPIO used as an IRQ
1799+
* @domain: The IRQ domain used by this IRQ chip
1800+
* @data: Outermost irq_data associated with the IRQ
1801+
*
1802+
* This function is a wrapper that will call gpiochip_unlock_as_irq() and is to
1803+
* be used as the deactivate function for the &struct irq_domain_ops. The
1804+
* host_data for the IRQ domain must be the &struct gpio_chip.
1805+
*/
1806+
void gpiochip_irq_domain_deactivate(struct irq_domain *domain,
1807+
struct irq_data *data)
1808+
{
1809+
struct gpio_chip *chip = domain->host_data;
1810+
1811+
return gpiochip_unlock_as_irq(chip, data->hwirq);
1812+
}
1813+
EXPORT_SYMBOL_GPL(gpiochip_irq_domain_deactivate);
1814+
17781815
static int gpiochip_to_irq(struct gpio_chip *chip, unsigned offset)
17791816
{
17801817
if (!gpiochip_irqchip_irq_valid(chip, offset))

‎include/linux/gpio/driver.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,11 @@ int gpiochip_irq_map(struct irq_domain *d, unsigned int irq,
472472
irq_hw_number_t hwirq);
473473
void gpiochip_irq_unmap(struct irq_domain *d, unsigned int irq);
474474

475+
int gpiochip_irq_domain_activate(struct irq_domain *domain,
476+
struct irq_data *data, bool reserve);
477+
void gpiochip_irq_domain_deactivate(struct irq_domain *domain,
478+
struct irq_data *data);
479+
475480
void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip,
476481
struct irq_chip *irqchip,
477482
unsigned int parent_irq,

0 commit comments

Comments
 (0)