gpio: ep93xx: add DT support for gpio-ep93xx
Add OF ID match table. Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me> Tested-by: Alexander Sverdlin <alexander.sverdlin@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Mark Brown <broonie@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Acked-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
parent
177c20d761
commit
8f67b1f028
@ -12,13 +12,13 @@
|
|||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
|
#include <linux/interrupt.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/irq.h>
|
#include <linux/irq.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/gpio/driver.h>
|
#include <linux/gpio/driver.h>
|
||||||
#include <linux/bitops.h>
|
#include <linux/bitops.h>
|
||||||
#include <linux/seq_file.h>
|
#include <linux/seq_file.h>
|
||||||
#include <linux/interrupt.h>
|
|
||||||
|
|
||||||
struct ep93xx_gpio_irq_chip {
|
struct ep93xx_gpio_irq_chip {
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
@ -138,7 +138,8 @@ static void ep93xx_gpio_irq_mask_ack(struct irq_data *d)
|
|||||||
{
|
{
|
||||||
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
|
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
|
||||||
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
|
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
|
||||||
int port_mask = BIT(irqd_to_hwirq(d));
|
irq_hw_number_t hwirq = irqd_to_hwirq(d);
|
||||||
|
int port_mask = BIT(hwirq);
|
||||||
|
|
||||||
if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH)
|
if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH)
|
||||||
eic->int_type2 ^= port_mask; /* switch edge direction */
|
eic->int_type2 ^= port_mask; /* switch edge direction */
|
||||||
@ -147,26 +148,28 @@ static void ep93xx_gpio_irq_mask_ack(struct irq_data *d)
|
|||||||
ep93xx_gpio_update_int_params(eic);
|
ep93xx_gpio_update_int_params(eic);
|
||||||
|
|
||||||
writeb(port_mask, eic->base + EP93XX_INT_EOI_OFFSET);
|
writeb(port_mask, eic->base + EP93XX_INT_EOI_OFFSET);
|
||||||
gpiochip_disable_irq(gc, irqd_to_hwirq(d));
|
gpiochip_disable_irq(gc, hwirq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ep93xx_gpio_irq_mask(struct irq_data *d)
|
static void ep93xx_gpio_irq_mask(struct irq_data *d)
|
||||||
{
|
{
|
||||||
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
|
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
|
||||||
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
|
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
|
||||||
|
irq_hw_number_t hwirq = irqd_to_hwirq(d);
|
||||||
|
|
||||||
eic->int_unmasked &= ~BIT(irqd_to_hwirq(d));
|
eic->int_unmasked &= ~BIT(hwirq);
|
||||||
ep93xx_gpio_update_int_params(eic);
|
ep93xx_gpio_update_int_params(eic);
|
||||||
gpiochip_disable_irq(gc, irqd_to_hwirq(d));
|
gpiochip_disable_irq(gc, hwirq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ep93xx_gpio_irq_unmask(struct irq_data *d)
|
static void ep93xx_gpio_irq_unmask(struct irq_data *d)
|
||||||
{
|
{
|
||||||
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
|
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
|
||||||
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
|
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
|
||||||
|
irq_hw_number_t hwirq = irqd_to_hwirq(d);
|
||||||
|
|
||||||
gpiochip_enable_irq(gc, irqd_to_hwirq(d));
|
gpiochip_enable_irq(gc, hwirq);
|
||||||
eic->int_unmasked |= BIT(irqd_to_hwirq(d));
|
eic->int_unmasked |= BIT(hwirq);
|
||||||
ep93xx_gpio_update_int_params(eic);
|
ep93xx_gpio_update_int_params(eic);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,11 +182,11 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type)
|
|||||||
{
|
{
|
||||||
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
|
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
|
||||||
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
|
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
|
||||||
irq_hw_number_t offset = irqd_to_hwirq(d);
|
irq_hw_number_t hwirq = irqd_to_hwirq(d);
|
||||||
int port_mask = BIT(offset);
|
int port_mask = BIT(hwirq);
|
||||||
irq_flow_handler_t handler;
|
irq_flow_handler_t handler;
|
||||||
|
|
||||||
gc->direction_input(gc, offset);
|
gc->direction_input(gc, hwirq);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case IRQ_TYPE_EDGE_RISING:
|
case IRQ_TYPE_EDGE_RISING:
|
||||||
@ -209,7 +212,7 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type)
|
|||||||
case IRQ_TYPE_EDGE_BOTH:
|
case IRQ_TYPE_EDGE_BOTH:
|
||||||
eic->int_type1 |= port_mask;
|
eic->int_type1 |= port_mask;
|
||||||
/* set initial polarity based on current input level */
|
/* set initial polarity based on current input level */
|
||||||
if (gc->get(gc, offset))
|
if (gc->get(gc, hwirq))
|
||||||
eic->int_type2 &= ~port_mask; /* falling */
|
eic->int_type2 &= ~port_mask; /* falling */
|
||||||
else
|
else
|
||||||
eic->int_type2 |= port_mask; /* rising */
|
eic->int_type2 |= port_mask; /* rising */
|
||||||
@ -285,8 +288,7 @@ static int ep93xx_setup_irqs(struct platform_device *pdev,
|
|||||||
if (girq->num_parents == 0)
|
if (girq->num_parents == 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
girq->parents = devm_kcalloc(dev, girq->num_parents,
|
girq->parents = devm_kcalloc(dev, girq->num_parents, sizeof(*girq->parents),
|
||||||
sizeof(*girq->parents),
|
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!girq->parents)
|
if (!girq->parents)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -306,7 +308,7 @@ static int ep93xx_setup_irqs(struct platform_device *pdev,
|
|||||||
girq->parent_handler = ep93xx_gpio_f_irq_handler;
|
girq->parent_handler = ep93xx_gpio_f_irq_handler;
|
||||||
|
|
||||||
for (i = 0; i < girq->num_parents; i++) {
|
for (i = 0; i < girq->num_parents; i++) {
|
||||||
irq = platform_get_irq(pdev, i);
|
irq = platform_get_irq_optional(pdev, i);
|
||||||
if (irq < 0)
|
if (irq < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -359,9 +361,15 @@ static int ep93xx_gpio_probe(struct platform_device *pdev)
|
|||||||
return devm_gpiochip_add_data(&pdev->dev, gc, egc);
|
return devm_gpiochip_add_data(&pdev->dev, gc, egc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct of_device_id ep93xx_gpio_match[] = {
|
||||||
|
{ .compatible = "cirrus,ep9301-gpio" },
|
||||||
|
{ /* sentinel */ }
|
||||||
|
};
|
||||||
|
|
||||||
static struct platform_driver ep93xx_gpio_driver = {
|
static struct platform_driver ep93xx_gpio_driver = {
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "gpio-ep93xx",
|
.name = "gpio-ep93xx",
|
||||||
|
.of_match_table = ep93xx_gpio_match,
|
||||||
},
|
},
|
||||||
.probe = ep93xx_gpio_probe,
|
.probe = ep93xx_gpio_probe,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user