summaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>2024-06-24 11:39:33 +0200
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>2024-07-04 09:25:59 +0200
commit9d9c1796a6ae70290c2e013fe4d79e99039a1015 (patch)
tree896d3a5f47ccd0a8820775708aa6a177ef40a955 /drivers/gpio
parentgenirq/irq_sim: add an extended irq_sim initializer (diff)
downloadlinux-9d9c1796a6ae70290c2e013fe4d79e99039a1015.tar.xz
linux-9d9c1796a6ae70290c2e013fe4d79e99039a1015.zip
gpio: sim: lock GPIOs as interrupts when they are requested
Use the extended irq_sim interface to supply the simulated interrupt domain with callbacks allowing the GPIO sim to lock/unlock GPIOs requested as interrupts. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20240624093934.17089-3-brgl@bgdev.pl Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-sim.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index 4157735ea791..dcca1d7f173e 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -227,6 +227,27 @@ static void gpio_sim_free(struct gpio_chip *gc, unsigned int offset)
}
}
+static int gpio_sim_irq_requested(struct irq_domain *domain,
+ irq_hw_number_t hwirq, void *data)
+{
+ struct gpio_sim_chip *chip = data;
+
+ return gpiochip_lock_as_irq(&chip->gc, hwirq);
+}
+
+static void gpio_sim_irq_released(struct irq_domain *domain,
+ irq_hw_number_t hwirq, void *data)
+{
+ struct gpio_sim_chip *chip = data;
+
+ gpiochip_unlock_as_irq(&chip->gc, hwirq);
+}
+
+static const struct irq_sim_ops gpio_sim_irq_sim_ops = {
+ .irq_sim_irq_requested = gpio_sim_irq_requested,
+ .irq_sim_irq_released = gpio_sim_irq_released,
+};
+
static void gpio_sim_dbg_show(struct seq_file *seq, struct gpio_chip *gc)
{
struct gpio_sim_chip *chip = gpiochip_get_data(gc);
@@ -443,7 +464,9 @@ static int gpio_sim_add_bank(struct fwnode_handle *swnode, struct device *dev)
if (!chip->pull_map)
return -ENOMEM;
- chip->irq_sim = devm_irq_domain_create_sim(dev, swnode, num_lines);
+ chip->irq_sim = devm_irq_domain_create_sim_full(dev, swnode, num_lines,
+ &gpio_sim_irq_sim_ops,
+ chip);
if (IS_ERR(chip->irq_sim))
return PTR_ERR(chip->irq_sim);