gpio: altera: Drop legacy-of-mm-gpiochip.h header
Remove legacy-of-mm-gpiochip.h header file, replace of_* functions and structs with appropriate alternatives. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20241031101836.2434308-1-andriy.shevchenko@linux.intel.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
09db69a84e
commit
50dded8d9d
2 changed files with 78 additions and 102 deletions
|
@ -148,9 +148,7 @@ config GPIO_74XX_MMIO
|
||||||
|
|
||||||
config GPIO_ALTERA
|
config GPIO_ALTERA
|
||||||
tristate "Altera GPIO"
|
tristate "Altera GPIO"
|
||||||
depends on OF_GPIO
|
|
||||||
select GPIOLIB_IRQCHIP
|
select GPIOLIB_IRQCHIP
|
||||||
select OF_GPIO_MM_GPIOCHIP
|
|
||||||
help
|
help
|
||||||
Say Y or M here to build support for the Altera PIO device.
|
Say Y or M here to build support for the Altera PIO device.
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,19 @@
|
||||||
* Based on gpio-mpc8xxx.c
|
* Based on gpio-mpc8xxx.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <linux/bitops.h>
|
||||||
|
#include <linux/device.h>
|
||||||
|
#include <linux/err.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
|
#include <linux/irq.h>
|
||||||
|
#include <linux/mod_devicetable.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/gpio/driver.h>
|
|
||||||
#include <linux/gpio/legacy-of-mm-gpiochip.h>
|
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
|
#include <linux/property.h>
|
||||||
|
#include <linux/spinlock.h>
|
||||||
|
#include <linux/types.h>
|
||||||
|
|
||||||
|
#include <linux/gpio/driver.h>
|
||||||
|
|
||||||
#define ALTERA_GPIO_MAX_NGPIO 32
|
#define ALTERA_GPIO_MAX_NGPIO 32
|
||||||
#define ALTERA_GPIO_DATA 0x0
|
#define ALTERA_GPIO_DATA 0x0
|
||||||
|
@ -18,7 +26,8 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct altera_gpio_chip
|
* struct altera_gpio_chip
|
||||||
* @mmchip : memory mapped chip structure.
|
* @gc : GPIO chip structure.
|
||||||
|
* @regs : memory mapped IO address for the controller registers.
|
||||||
* @gpio_lock : synchronization lock so that new irq/set/get requests
|
* @gpio_lock : synchronization lock so that new irq/set/get requests
|
||||||
* will be blocked until the current one completes.
|
* will be blocked until the current one completes.
|
||||||
* @interrupt_trigger : specifies the hardware configured IRQ trigger type
|
* @interrupt_trigger : specifies the hardware configured IRQ trigger type
|
||||||
|
@ -26,7 +35,8 @@
|
||||||
* @mapped_irq : kernel mapped irq number.
|
* @mapped_irq : kernel mapped irq number.
|
||||||
*/
|
*/
|
||||||
struct altera_gpio_chip {
|
struct altera_gpio_chip {
|
||||||
struct of_mm_gpio_chip mmchip;
|
struct gpio_chip gc;
|
||||||
|
void __iomem *regs;
|
||||||
raw_spinlock_t gpio_lock;
|
raw_spinlock_t gpio_lock;
|
||||||
int interrupt_trigger;
|
int interrupt_trigger;
|
||||||
int mapped_irq;
|
int mapped_irq;
|
||||||
|
@ -34,40 +44,36 @@ struct altera_gpio_chip {
|
||||||
|
|
||||||
static void altera_gpio_irq_unmask(struct irq_data *d)
|
static void altera_gpio_irq_unmask(struct irq_data *d)
|
||||||
{
|
{
|
||||||
struct altera_gpio_chip *altera_gc;
|
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
|
||||||
struct of_mm_gpio_chip *mm_gc;
|
struct altera_gpio_chip *altera_gc = gpiochip_get_data(gc);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
u32 intmask;
|
u32 intmask;
|
||||||
|
|
||||||
altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d));
|
gpiochip_enable_irq(gc, irqd_to_hwirq(d));
|
||||||
mm_gc = &altera_gc->mmchip;
|
|
||||||
gpiochip_enable_irq(&mm_gc->gc, irqd_to_hwirq(d));
|
|
||||||
|
|
||||||
raw_spin_lock_irqsave(&altera_gc->gpio_lock, flags);
|
raw_spin_lock_irqsave(&altera_gc->gpio_lock, flags);
|
||||||
intmask = readl(mm_gc->regs + ALTERA_GPIO_IRQ_MASK);
|
intmask = readl(altera_gc->regs + ALTERA_GPIO_IRQ_MASK);
|
||||||
/* Set ALTERA_GPIO_IRQ_MASK bit to unmask */
|
/* Set ALTERA_GPIO_IRQ_MASK bit to unmask */
|
||||||
intmask |= BIT(irqd_to_hwirq(d));
|
intmask |= BIT(irqd_to_hwirq(d));
|
||||||
writel(intmask, mm_gc->regs + ALTERA_GPIO_IRQ_MASK);
|
writel(intmask, altera_gc->regs + ALTERA_GPIO_IRQ_MASK);
|
||||||
raw_spin_unlock_irqrestore(&altera_gc->gpio_lock, flags);
|
raw_spin_unlock_irqrestore(&altera_gc->gpio_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void altera_gpio_irq_mask(struct irq_data *d)
|
static void altera_gpio_irq_mask(struct irq_data *d)
|
||||||
{
|
{
|
||||||
struct altera_gpio_chip *altera_gc;
|
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
|
||||||
struct of_mm_gpio_chip *mm_gc;
|
struct altera_gpio_chip *altera_gc = gpiochip_get_data(gc);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
u32 intmask;
|
u32 intmask;
|
||||||
|
|
||||||
altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d));
|
|
||||||
mm_gc = &altera_gc->mmchip;
|
|
||||||
|
|
||||||
raw_spin_lock_irqsave(&altera_gc->gpio_lock, flags);
|
raw_spin_lock_irqsave(&altera_gc->gpio_lock, flags);
|
||||||
intmask = readl(mm_gc->regs + ALTERA_GPIO_IRQ_MASK);
|
intmask = readl(altera_gc->regs + ALTERA_GPIO_IRQ_MASK);
|
||||||
/* Clear ALTERA_GPIO_IRQ_MASK bit to mask */
|
/* Clear ALTERA_GPIO_IRQ_MASK bit to mask */
|
||||||
intmask &= ~BIT(irqd_to_hwirq(d));
|
intmask &= ~BIT(irqd_to_hwirq(d));
|
||||||
writel(intmask, mm_gc->regs + ALTERA_GPIO_IRQ_MASK);
|
writel(intmask, altera_gc->regs + ALTERA_GPIO_IRQ_MASK);
|
||||||
raw_spin_unlock_irqrestore(&altera_gc->gpio_lock, flags);
|
raw_spin_unlock_irqrestore(&altera_gc->gpio_lock, flags);
|
||||||
gpiochip_disable_irq(&mm_gc->gc, irqd_to_hwirq(d));
|
|
||||||
|
gpiochip_disable_irq(gc, irqd_to_hwirq(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -77,9 +83,8 @@ static void altera_gpio_irq_mask(struct irq_data *d)
|
||||||
static int altera_gpio_irq_set_type(struct irq_data *d,
|
static int altera_gpio_irq_set_type(struct irq_data *d,
|
||||||
unsigned int type)
|
unsigned int type)
|
||||||
{
|
{
|
||||||
struct altera_gpio_chip *altera_gc;
|
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
|
||||||
|
struct altera_gpio_chip *altera_gc = gpiochip_get_data(gc);
|
||||||
altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d));
|
|
||||||
|
|
||||||
if (type == IRQ_TYPE_NONE) {
|
if (type == IRQ_TYPE_NONE) {
|
||||||
irq_set_handler_locked(d, handle_bad_irq);
|
irq_set_handler_locked(d, handle_bad_irq);
|
||||||
|
@ -105,49 +110,39 @@ static unsigned int altera_gpio_irq_startup(struct irq_data *d)
|
||||||
|
|
||||||
static int altera_gpio_get(struct gpio_chip *gc, unsigned offset)
|
static int altera_gpio_get(struct gpio_chip *gc, unsigned offset)
|
||||||
{
|
{
|
||||||
struct of_mm_gpio_chip *mm_gc;
|
struct altera_gpio_chip *altera_gc = gpiochip_get_data(gc);
|
||||||
|
|
||||||
mm_gc = to_of_mm_gpio_chip(gc);
|
return !!(readl(altera_gc->regs + ALTERA_GPIO_DATA) & BIT(offset));
|
||||||
|
|
||||||
return !!(readl(mm_gc->regs + ALTERA_GPIO_DATA) & BIT(offset));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void altera_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
|
static void altera_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
|
||||||
{
|
{
|
||||||
struct of_mm_gpio_chip *mm_gc;
|
struct altera_gpio_chip *altera_gc = gpiochip_get_data(gc);
|
||||||
struct altera_gpio_chip *chip;
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
unsigned int data_reg;
|
unsigned int data_reg;
|
||||||
|
|
||||||
mm_gc = to_of_mm_gpio_chip(gc);
|
raw_spin_lock_irqsave(&altera_gc->gpio_lock, flags);
|
||||||
chip = gpiochip_get_data(gc);
|
data_reg = readl(altera_gc->regs + ALTERA_GPIO_DATA);
|
||||||
|
|
||||||
raw_spin_lock_irqsave(&chip->gpio_lock, flags);
|
|
||||||
data_reg = readl(mm_gc->regs + ALTERA_GPIO_DATA);
|
|
||||||
if (value)
|
if (value)
|
||||||
data_reg |= BIT(offset);
|
data_reg |= BIT(offset);
|
||||||
else
|
else
|
||||||
data_reg &= ~BIT(offset);
|
data_reg &= ~BIT(offset);
|
||||||
writel(data_reg, mm_gc->regs + ALTERA_GPIO_DATA);
|
writel(data_reg, altera_gc->regs + ALTERA_GPIO_DATA);
|
||||||
raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
|
raw_spin_unlock_irqrestore(&altera_gc->gpio_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int altera_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
|
static int altera_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
|
||||||
{
|
{
|
||||||
struct of_mm_gpio_chip *mm_gc;
|
struct altera_gpio_chip *altera_gc = gpiochip_get_data(gc);
|
||||||
struct altera_gpio_chip *chip;
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
unsigned int gpio_ddr;
|
unsigned int gpio_ddr;
|
||||||
|
|
||||||
mm_gc = to_of_mm_gpio_chip(gc);
|
raw_spin_lock_irqsave(&altera_gc->gpio_lock, flags);
|
||||||
chip = gpiochip_get_data(gc);
|
|
||||||
|
|
||||||
raw_spin_lock_irqsave(&chip->gpio_lock, flags);
|
|
||||||
/* Set pin as input, assumes software controlled IP */
|
/* Set pin as input, assumes software controlled IP */
|
||||||
gpio_ddr = readl(mm_gc->regs + ALTERA_GPIO_DIR);
|
gpio_ddr = readl(altera_gc->regs + ALTERA_GPIO_DIR);
|
||||||
gpio_ddr &= ~BIT(offset);
|
gpio_ddr &= ~BIT(offset);
|
||||||
writel(gpio_ddr, mm_gc->regs + ALTERA_GPIO_DIR);
|
writel(gpio_ddr, altera_gc->regs + ALTERA_GPIO_DIR);
|
||||||
raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
|
raw_spin_unlock_irqrestore(&altera_gc->gpio_lock, flags);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -155,53 +150,46 @@ static int altera_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
|
||||||
static int altera_gpio_direction_output(struct gpio_chip *gc,
|
static int altera_gpio_direction_output(struct gpio_chip *gc,
|
||||||
unsigned offset, int value)
|
unsigned offset, int value)
|
||||||
{
|
{
|
||||||
struct of_mm_gpio_chip *mm_gc;
|
struct altera_gpio_chip *altera_gc = gpiochip_get_data(gc);
|
||||||
struct altera_gpio_chip *chip;
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
unsigned int data_reg, gpio_ddr;
|
unsigned int data_reg, gpio_ddr;
|
||||||
|
|
||||||
mm_gc = to_of_mm_gpio_chip(gc);
|
raw_spin_lock_irqsave(&altera_gc->gpio_lock, flags);
|
||||||
chip = gpiochip_get_data(gc);
|
|
||||||
|
|
||||||
raw_spin_lock_irqsave(&chip->gpio_lock, flags);
|
|
||||||
/* Sets the GPIO value */
|
/* Sets the GPIO value */
|
||||||
data_reg = readl(mm_gc->regs + ALTERA_GPIO_DATA);
|
data_reg = readl(altera_gc->regs + ALTERA_GPIO_DATA);
|
||||||
if (value)
|
if (value)
|
||||||
data_reg |= BIT(offset);
|
data_reg |= BIT(offset);
|
||||||
else
|
else
|
||||||
data_reg &= ~BIT(offset);
|
data_reg &= ~BIT(offset);
|
||||||
writel(data_reg, mm_gc->regs + ALTERA_GPIO_DATA);
|
writel(data_reg, altera_gc->regs + ALTERA_GPIO_DATA);
|
||||||
|
|
||||||
/* Set pin as output, assumes software controlled IP */
|
/* Set pin as output, assumes software controlled IP */
|
||||||
gpio_ddr = readl(mm_gc->regs + ALTERA_GPIO_DIR);
|
gpio_ddr = readl(altera_gc->regs + ALTERA_GPIO_DIR);
|
||||||
gpio_ddr |= BIT(offset);
|
gpio_ddr |= BIT(offset);
|
||||||
writel(gpio_ddr, mm_gc->regs + ALTERA_GPIO_DIR);
|
writel(gpio_ddr, altera_gc->regs + ALTERA_GPIO_DIR);
|
||||||
raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
|
raw_spin_unlock_irqrestore(&altera_gc->gpio_lock, flags);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void altera_gpio_irq_edge_handler(struct irq_desc *desc)
|
static void altera_gpio_irq_edge_handler(struct irq_desc *desc)
|
||||||
{
|
{
|
||||||
struct altera_gpio_chip *altera_gc;
|
struct gpio_chip *gc = irq_desc_get_handler_data(desc);
|
||||||
|
struct altera_gpio_chip *altera_gc = gpiochip_get_data(gc);
|
||||||
|
struct irq_domain *irqdomain = gc->irq.domain;
|
||||||
struct irq_chip *chip;
|
struct irq_chip *chip;
|
||||||
struct of_mm_gpio_chip *mm_gc;
|
|
||||||
struct irq_domain *irqdomain;
|
|
||||||
unsigned long status;
|
unsigned long status;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
altera_gc = gpiochip_get_data(irq_desc_get_handler_data(desc));
|
|
||||||
chip = irq_desc_get_chip(desc);
|
chip = irq_desc_get_chip(desc);
|
||||||
mm_gc = &altera_gc->mmchip;
|
|
||||||
irqdomain = altera_gc->mmchip.gc.irq.domain;
|
|
||||||
|
|
||||||
chained_irq_enter(chip, desc);
|
chained_irq_enter(chip, desc);
|
||||||
|
|
||||||
while ((status =
|
while ((status =
|
||||||
(readl(mm_gc->regs + ALTERA_GPIO_EDGE_CAP) &
|
(readl(altera_gc->regs + ALTERA_GPIO_EDGE_CAP) &
|
||||||
readl(mm_gc->regs + ALTERA_GPIO_IRQ_MASK)))) {
|
readl(altera_gc->regs + ALTERA_GPIO_IRQ_MASK)))) {
|
||||||
writel(status, mm_gc->regs + ALTERA_GPIO_EDGE_CAP);
|
writel(status, altera_gc->regs + ALTERA_GPIO_EDGE_CAP);
|
||||||
for_each_set_bit(i, &status, mm_gc->gc.ngpio)
|
for_each_set_bit(i, &status, gc->ngpio)
|
||||||
generic_handle_domain_irq(irqdomain, i);
|
generic_handle_domain_irq(irqdomain, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,24 +198,21 @@ static void altera_gpio_irq_edge_handler(struct irq_desc *desc)
|
||||||
|
|
||||||
static void altera_gpio_irq_leveL_high_handler(struct irq_desc *desc)
|
static void altera_gpio_irq_leveL_high_handler(struct irq_desc *desc)
|
||||||
{
|
{
|
||||||
struct altera_gpio_chip *altera_gc;
|
struct gpio_chip *gc = irq_desc_get_handler_data(desc);
|
||||||
|
struct altera_gpio_chip *altera_gc = gpiochip_get_data(gc);
|
||||||
|
struct irq_domain *irqdomain = gc->irq.domain;
|
||||||
struct irq_chip *chip;
|
struct irq_chip *chip;
|
||||||
struct of_mm_gpio_chip *mm_gc;
|
|
||||||
struct irq_domain *irqdomain;
|
|
||||||
unsigned long status;
|
unsigned long status;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
altera_gc = gpiochip_get_data(irq_desc_get_handler_data(desc));
|
|
||||||
chip = irq_desc_get_chip(desc);
|
chip = irq_desc_get_chip(desc);
|
||||||
mm_gc = &altera_gc->mmchip;
|
|
||||||
irqdomain = altera_gc->mmchip.gc.irq.domain;
|
|
||||||
|
|
||||||
chained_irq_enter(chip, desc);
|
chained_irq_enter(chip, desc);
|
||||||
|
|
||||||
status = readl(mm_gc->regs + ALTERA_GPIO_DATA);
|
status = readl(altera_gc->regs + ALTERA_GPIO_DATA);
|
||||||
status &= readl(mm_gc->regs + ALTERA_GPIO_IRQ_MASK);
|
status &= readl(altera_gc->regs + ALTERA_GPIO_IRQ_MASK);
|
||||||
|
|
||||||
for_each_set_bit(i, &status, mm_gc->gc.ngpio)
|
for_each_set_bit(i, &status, gc->ngpio)
|
||||||
generic_handle_domain_irq(irqdomain, i);
|
generic_handle_domain_irq(irqdomain, i);
|
||||||
|
|
||||||
chained_irq_exit(chip, desc);
|
chained_irq_exit(chip, desc);
|
||||||
|
@ -246,7 +231,7 @@ static const struct irq_chip altera_gpio_irq_chip = {
|
||||||
|
|
||||||
static int altera_gpio_probe(struct platform_device *pdev)
|
static int altera_gpio_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device_node *node = pdev->dev.of_node;
|
struct device *dev = &pdev->dev;
|
||||||
int reg, ret;
|
int reg, ret;
|
||||||
struct altera_gpio_chip *altera_gc;
|
struct altera_gpio_chip *altera_gc;
|
||||||
struct gpio_irq_chip *girq;
|
struct gpio_irq_chip *girq;
|
||||||
|
@ -257,39 +242,42 @@ static int altera_gpio_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
raw_spin_lock_init(&altera_gc->gpio_lock);
|
raw_spin_lock_init(&altera_gc->gpio_lock);
|
||||||
|
|
||||||
if (of_property_read_u32(node, "altr,ngpio", ®))
|
if (device_property_read_u32(dev, "altr,ngpio", ®))
|
||||||
/* By default assume maximum ngpio */
|
/* By default assume maximum ngpio */
|
||||||
altera_gc->mmchip.gc.ngpio = ALTERA_GPIO_MAX_NGPIO;
|
altera_gc->gc.ngpio = ALTERA_GPIO_MAX_NGPIO;
|
||||||
else
|
else
|
||||||
altera_gc->mmchip.gc.ngpio = reg;
|
altera_gc->gc.ngpio = reg;
|
||||||
|
|
||||||
if (altera_gc->mmchip.gc.ngpio > ALTERA_GPIO_MAX_NGPIO) {
|
if (altera_gc->gc.ngpio > ALTERA_GPIO_MAX_NGPIO) {
|
||||||
dev_warn(&pdev->dev,
|
dev_warn(&pdev->dev,
|
||||||
"ngpio is greater than %d, defaulting to %d\n",
|
"ngpio is greater than %d, defaulting to %d\n",
|
||||||
ALTERA_GPIO_MAX_NGPIO, ALTERA_GPIO_MAX_NGPIO);
|
ALTERA_GPIO_MAX_NGPIO, ALTERA_GPIO_MAX_NGPIO);
|
||||||
altera_gc->mmchip.gc.ngpio = ALTERA_GPIO_MAX_NGPIO;
|
altera_gc->gc.ngpio = ALTERA_GPIO_MAX_NGPIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
altera_gc->mmchip.gc.direction_input = altera_gpio_direction_input;
|
altera_gc->gc.direction_input = altera_gpio_direction_input;
|
||||||
altera_gc->mmchip.gc.direction_output = altera_gpio_direction_output;
|
altera_gc->gc.direction_output = altera_gpio_direction_output;
|
||||||
altera_gc->mmchip.gc.get = altera_gpio_get;
|
altera_gc->gc.get = altera_gpio_get;
|
||||||
altera_gc->mmchip.gc.set = altera_gpio_set;
|
altera_gc->gc.set = altera_gpio_set;
|
||||||
altera_gc->mmchip.gc.owner = THIS_MODULE;
|
altera_gc->gc.owner = THIS_MODULE;
|
||||||
altera_gc->mmchip.gc.parent = &pdev->dev;
|
altera_gc->gc.parent = &pdev->dev;
|
||||||
|
|
||||||
|
altera_gc->regs = devm_platform_ioremap_resource(pdev, 0);
|
||||||
|
if (IS_ERR(altera_gc->regs))
|
||||||
|
return dev_err_probe(dev, PTR_ERR(altera_gc->regs), "failed to ioremap memory resource\n");
|
||||||
|
|
||||||
altera_gc->mapped_irq = platform_get_irq_optional(pdev, 0);
|
altera_gc->mapped_irq = platform_get_irq_optional(pdev, 0);
|
||||||
|
|
||||||
if (altera_gc->mapped_irq < 0)
|
if (altera_gc->mapped_irq < 0)
|
||||||
goto skip_irq;
|
goto skip_irq;
|
||||||
|
|
||||||
if (of_property_read_u32(node, "altr,interrupt-type", ®)) {
|
if (device_property_read_u32(dev, "altr,interrupt-type", ®)) {
|
||||||
dev_err(&pdev->dev,
|
dev_err(&pdev->dev,
|
||||||
"altr,interrupt-type value not set in device tree\n");
|
"altr,interrupt-type value not set in device tree\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
altera_gc->interrupt_trigger = reg;
|
altera_gc->interrupt_trigger = reg;
|
||||||
|
|
||||||
girq = &altera_gc->mmchip.gc.irq;
|
girq = &altera_gc->gc.irq;
|
||||||
gpio_irq_chip_set_chip(girq, &altera_gpio_irq_chip);
|
gpio_irq_chip_set_chip(girq, &altera_gpio_irq_chip);
|
||||||
|
|
||||||
if (altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH)
|
if (altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH)
|
||||||
|
@ -306,24 +294,15 @@ static int altera_gpio_probe(struct platform_device *pdev)
|
||||||
girq->parents[0] = altera_gc->mapped_irq;
|
girq->parents[0] = altera_gc->mapped_irq;
|
||||||
|
|
||||||
skip_irq:
|
skip_irq:
|
||||||
ret = of_mm_gpiochip_add_data(node, &altera_gc->mmchip, altera_gc);
|
ret = devm_gpiochip_add_data(dev, &altera_gc->gc, altera_gc);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "Failed adding memory mapped gpiochip\n");
|
dev_err(&pdev->dev, "Failed adding memory mapped gpiochip\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_set_drvdata(pdev, altera_gc);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void altera_gpio_remove(struct platform_device *pdev)
|
|
||||||
{
|
|
||||||
struct altera_gpio_chip *altera_gc = platform_get_drvdata(pdev);
|
|
||||||
|
|
||||||
of_mm_gpiochip_remove(&altera_gc->mmchip);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct of_device_id altera_gpio_of_match[] = {
|
static const struct of_device_id altera_gpio_of_match[] = {
|
||||||
{ .compatible = "altr,pio-1.0", },
|
{ .compatible = "altr,pio-1.0", },
|
||||||
{},
|
{},
|
||||||
|
@ -336,7 +315,6 @@ static struct platform_driver altera_gpio_driver = {
|
||||||
.of_match_table = altera_gpio_of_match,
|
.of_match_table = altera_gpio_of_match,
|
||||||
},
|
},
|
||||||
.probe = altera_gpio_probe,
|
.probe = altera_gpio_probe,
|
||||||
.remove = altera_gpio_remove,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init altera_gpio_init(void)
|
static int __init altera_gpio_init(void)
|
||||||
|
|
Loading…
Add table
Reference in a new issue