2019-05-28 16:57:08 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2012-05-17 06:22:23 +00:00
|
|
|
/*
|
|
|
|
* Emma Mobile GPIO Support - GIO
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Magnus Damm
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
#include <linux/irqdomain.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include <linux/err.h>
|
2018-02-08 23:45:50 +00:00
|
|
|
#include <linux/gpio/driver.h>
|
2012-05-17 06:22:23 +00:00
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/module.h>
|
2013-07-03 04:14:32 +00:00
|
|
|
#include <linux/pinctrl/consumer.h>
|
2012-05-17 06:22:23 +00:00
|
|
|
|
|
|
|
struct em_gio_priv {
|
|
|
|
void __iomem *base0;
|
|
|
|
void __iomem *base1;
|
|
|
|
spinlock_t sense_lock;
|
|
|
|
struct platform_device *pdev;
|
|
|
|
struct gpio_chip gpio_chip;
|
|
|
|
struct irq_chip irq_chip;
|
|
|
|
struct irq_domain *irq_domain;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define GIO_E1 0x00
|
|
|
|
#define GIO_E0 0x04
|
|
|
|
#define GIO_EM 0x04
|
|
|
|
#define GIO_OL 0x08
|
|
|
|
#define GIO_OH 0x0c
|
|
|
|
#define GIO_I 0x10
|
|
|
|
#define GIO_IIA 0x14
|
|
|
|
#define GIO_IEN 0x18
|
|
|
|
#define GIO_IDS 0x1c
|
|
|
|
#define GIO_IIM 0x1c
|
|
|
|
#define GIO_RAW 0x20
|
|
|
|
#define GIO_MST 0x24
|
|
|
|
#define GIO_IIR 0x28
|
|
|
|
|
|
|
|
#define GIO_IDT0 0x40
|
|
|
|
#define GIO_IDT1 0x44
|
|
|
|
#define GIO_IDT2 0x48
|
|
|
|
#define GIO_IDT3 0x4c
|
|
|
|
#define GIO_RAWBL 0x50
|
|
|
|
#define GIO_RAWBH 0x54
|
|
|
|
#define GIO_IRBL 0x58
|
|
|
|
#define GIO_IRBH 0x5c
|
|
|
|
|
|
|
|
#define GIO_IDT(n) (GIO_IDT0 + ((n) * 4))
|
|
|
|
|
|
|
|
static inline unsigned long em_gio_read(struct em_gio_priv *p, int offs)
|
|
|
|
{
|
|
|
|
if (offs < GIO_IDT0)
|
|
|
|
return ioread32(p->base0 + offs);
|
|
|
|
else
|
|
|
|
return ioread32(p->base1 + (offs - GIO_IDT0));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void em_gio_write(struct em_gio_priv *p, int offs,
|
|
|
|
unsigned long value)
|
|
|
|
{
|
|
|
|
if (offs < GIO_IDT0)
|
|
|
|
iowrite32(value, p->base0 + offs);
|
|
|
|
else
|
|
|
|
iowrite32(value, p->base1 + (offs - GIO_IDT0));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void em_gio_irq_disable(struct irq_data *d)
|
|
|
|
{
|
2012-09-04 13:58:33 +00:00
|
|
|
struct em_gio_priv *p = irq_data_get_irq_chip_data(d);
|
2012-05-17 06:22:23 +00:00
|
|
|
|
|
|
|
em_gio_write(p, GIO_IDS, BIT(irqd_to_hwirq(d)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void em_gio_irq_enable(struct irq_data *d)
|
|
|
|
{
|
2012-09-04 13:58:33 +00:00
|
|
|
struct em_gio_priv *p = irq_data_get_irq_chip_data(d);
|
2012-05-17 06:22:23 +00:00
|
|
|
|
|
|
|
em_gio_write(p, GIO_IEN, BIT(irqd_to_hwirq(d)));
|
|
|
|
}
|
|
|
|
|
2014-03-14 17:16:20 +00:00
|
|
|
static int em_gio_irq_reqres(struct irq_data *d)
|
2013-11-20 09:16:54 +00:00
|
|
|
{
|
|
|
|
struct em_gio_priv *p = irq_data_get_irq_chip_data(d);
|
2018-07-30 12:38:34 +00:00
|
|
|
int ret;
|
2013-11-20 09:16:54 +00:00
|
|
|
|
2018-07-30 12:38:34 +00:00
|
|
|
ret = gpiochip_lock_as_irq(&p->gpio_chip, irqd_to_hwirq(d));
|
|
|
|
if (ret) {
|
2015-11-04 08:56:26 +00:00
|
|
|
dev_err(p->gpio_chip.parent,
|
2013-11-20 09:16:54 +00:00
|
|
|
"unable to lock HW IRQ %lu for IRQ\n",
|
|
|
|
irqd_to_hwirq(d));
|
2018-07-30 12:38:34 +00:00
|
|
|
return ret;
|
2014-03-14 17:16:20 +00:00
|
|
|
}
|
2013-11-20 09:16:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-14 17:16:20 +00:00
|
|
|
static void em_gio_irq_relres(struct irq_data *d)
|
2013-11-20 09:16:54 +00:00
|
|
|
{
|
|
|
|
struct em_gio_priv *p = irq_data_get_irq_chip_data(d);
|
|
|
|
|
2014-10-23 08:27:07 +00:00
|
|
|
gpiochip_unlock_as_irq(&p->gpio_chip, irqd_to_hwirq(d));
|
2013-11-20 09:16:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-17 06:22:23 +00:00
|
|
|
#define GIO_ASYNC(x) (x + 8)
|
|
|
|
|
|
|
|
static unsigned char em_gio_sense_table[IRQ_TYPE_SENSE_MASK + 1] = {
|
|
|
|
[IRQ_TYPE_EDGE_RISING] = GIO_ASYNC(0x00),
|
|
|
|
[IRQ_TYPE_EDGE_FALLING] = GIO_ASYNC(0x01),
|
|
|
|
[IRQ_TYPE_LEVEL_HIGH] = GIO_ASYNC(0x02),
|
|
|
|
[IRQ_TYPE_LEVEL_LOW] = GIO_ASYNC(0x03),
|
|
|
|
[IRQ_TYPE_EDGE_BOTH] = GIO_ASYNC(0x04),
|
|
|
|
};
|
|
|
|
|
|
|
|
static int em_gio_irq_set_type(struct irq_data *d, unsigned int type)
|
|
|
|
{
|
|
|
|
unsigned char value = em_gio_sense_table[type & IRQ_TYPE_SENSE_MASK];
|
2012-09-04 13:58:33 +00:00
|
|
|
struct em_gio_priv *p = irq_data_get_irq_chip_data(d);
|
2012-05-17 06:22:23 +00:00
|
|
|
unsigned int reg, offset, shift;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned long tmp;
|
|
|
|
|
|
|
|
if (!value)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
offset = irqd_to_hwirq(d);
|
|
|
|
|
|
|
|
pr_debug("gio: sense irq = %d, mode = %d\n", offset, value);
|
|
|
|
|
|
|
|
/* 8 x 4 bit fields in 4 IDT registers */
|
|
|
|
reg = GIO_IDT(offset >> 3);
|
|
|
|
shift = (offset & 0x07) << 4;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&p->sense_lock, flags);
|
|
|
|
|
|
|
|
/* disable the interrupt in IIA */
|
|
|
|
tmp = em_gio_read(p, GIO_IIA);
|
|
|
|
tmp &= ~BIT(offset);
|
|
|
|
em_gio_write(p, GIO_IIA, tmp);
|
|
|
|
|
|
|
|
/* change the sense setting in IDT */
|
|
|
|
tmp = em_gio_read(p, reg);
|
|
|
|
tmp &= ~(0xf << shift);
|
|
|
|
tmp |= value << shift;
|
|
|
|
em_gio_write(p, reg, tmp);
|
|
|
|
|
|
|
|
/* clear pending interrupts */
|
|
|
|
em_gio_write(p, GIO_IIR, BIT(offset));
|
|
|
|
|
|
|
|
/* enable the interrupt in IIA */
|
|
|
|
tmp = em_gio_read(p, GIO_IIA);
|
|
|
|
tmp |= BIT(offset);
|
|
|
|
em_gio_write(p, GIO_IIA, tmp);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&p->sense_lock, flags);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t em_gio_irq_handler(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
struct em_gio_priv *p = dev_id;
|
|
|
|
unsigned long pending;
|
|
|
|
unsigned int offset, irqs_handled = 0;
|
|
|
|
|
|
|
|
while ((pending = em_gio_read(p, GIO_MST))) {
|
|
|
|
offset = __ffs(pending);
|
|
|
|
em_gio_write(p, GIO_IIR, BIT(offset));
|
2021-05-04 16:42:18 +00:00
|
|
|
generic_handle_domain_irq(p->irq_domain, offset);
|
2012-05-17 06:22:23 +00:00
|
|
|
irqs_handled++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return irqs_handled ? IRQ_HANDLED : IRQ_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct em_gio_priv *gpio_to_priv(struct gpio_chip *chip)
|
|
|
|
{
|
2015-12-05 23:36:39 +00:00
|
|
|
return gpiochip_get_data(chip);
|
2012-05-17 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int em_gio_direction_input(struct gpio_chip *chip, unsigned offset)
|
|
|
|
{
|
|
|
|
em_gio_write(gpio_to_priv(chip), GIO_E0, BIT(offset));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int em_gio_get(struct gpio_chip *chip, unsigned offset)
|
|
|
|
{
|
2015-12-21 09:46:18 +00:00
|
|
|
return !!(em_gio_read(gpio_to_priv(chip), GIO_I) & BIT(offset));
|
2012-05-17 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __em_gio_set(struct gpio_chip *chip, unsigned int reg,
|
|
|
|
unsigned shift, int value)
|
|
|
|
{
|
|
|
|
/* upper 16 bits contains mask and lower 16 actual value */
|
|
|
|
em_gio_write(gpio_to_priv(chip), reg,
|
2014-04-27 00:00:47 +00:00
|
|
|
(BIT(shift + 16)) | (value << shift));
|
2012-05-17 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void em_gio_set(struct gpio_chip *chip, unsigned offset, int value)
|
|
|
|
{
|
|
|
|
/* output is split into two registers */
|
|
|
|
if (offset < 16)
|
|
|
|
__em_gio_set(chip, GIO_OL, offset, value);
|
|
|
|
else
|
|
|
|
__em_gio_set(chip, GIO_OH, offset - 16, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int em_gio_direction_output(struct gpio_chip *chip, unsigned offset,
|
|
|
|
int value)
|
|
|
|
{
|
|
|
|
/* write GPIO value to output before selecting output mode of pin */
|
|
|
|
em_gio_set(chip, offset, value);
|
|
|
|
em_gio_write(gpio_to_priv(chip), GIO_E1, BIT(offset));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int em_gio_to_irq(struct gpio_chip *chip, unsigned offset)
|
|
|
|
{
|
2012-10-16 18:15:02 +00:00
|
|
|
return irq_create_mapping(gpio_to_priv(chip)->irq_domain, offset);
|
2012-05-17 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
2013-07-03 04:14:32 +00:00
|
|
|
static void em_gio_free(struct gpio_chip *chip, unsigned offset)
|
|
|
|
{
|
2023-10-03 09:57:17 +00:00
|
|
|
pinctrl_gpio_free(chip, offset);
|
2013-07-03 04:14:32 +00:00
|
|
|
|
|
|
|
/* Set the GPIO as an input to ensure that the next GPIO request won't
|
|
|
|
* drive the GPIO pin as an output.
|
|
|
|
*/
|
|
|
|
em_gio_direction_input(chip, offset);
|
|
|
|
}
|
|
|
|
|
2013-10-11 17:21:34 +00:00
|
|
|
static int em_gio_irq_domain_map(struct irq_domain *h, unsigned int irq,
|
|
|
|
irq_hw_number_t hwirq)
|
2012-05-17 06:22:23 +00:00
|
|
|
{
|
|
|
|
struct em_gio_priv *p = h->host_data;
|
|
|
|
|
2013-10-11 17:21:34 +00:00
|
|
|
pr_debug("gio: map hw irq = %d, irq = %d\n", (int)hwirq, irq);
|
2012-05-17 06:22:23 +00:00
|
|
|
|
2013-10-11 17:21:34 +00:00
|
|
|
irq_set_chip_data(irq, h->host_data);
|
|
|
|
irq_set_chip_and_handler(irq, &p->irq_chip, handle_level_irq);
|
2012-05-17 06:22:23 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-04-27 12:54:07 +00:00
|
|
|
static const struct irq_domain_ops em_gio_irq_domain_ops = {
|
2012-05-17 06:22:23 +00:00
|
|
|
.map = em_gio_irq_domain_map,
|
2013-02-26 13:26:23 +00:00
|
|
|
.xlate = irq_domain_xlate_twocell,
|
2012-05-17 06:22:23 +00:00
|
|
|
};
|
|
|
|
|
2019-07-11 08:29:35 +00:00
|
|
|
static void em_gio_irq_domain_remove(void *data)
|
|
|
|
{
|
|
|
|
struct irq_domain *domain = data;
|
|
|
|
|
|
|
|
irq_domain_remove(domain);
|
|
|
|
}
|
|
|
|
|
2012-11-19 18:22:34 +00:00
|
|
|
static int em_gio_probe(struct platform_device *pdev)
|
2012-05-17 06:22:23 +00:00
|
|
|
{
|
|
|
|
struct em_gio_priv *p;
|
|
|
|
struct gpio_chip *gpio_chip;
|
|
|
|
struct irq_chip *irq_chip;
|
2019-07-11 08:29:36 +00:00
|
|
|
struct device *dev = &pdev->dev;
|
|
|
|
const char *name = dev_name(dev);
|
2015-06-23 13:48:02 +00:00
|
|
|
unsigned int ngpios;
|
2019-11-13 10:11:03 +00:00
|
|
|
int irq[2], ret;
|
2012-05-17 06:22:23 +00:00
|
|
|
|
2019-07-11 08:29:36 +00:00
|
|
|
p = devm_kzalloc(dev, sizeof(*p), GFP_KERNEL);
|
2019-05-27 12:40:51 +00:00
|
|
|
if (!p)
|
|
|
|
return -ENOMEM;
|
2012-05-17 06:22:23 +00:00
|
|
|
|
|
|
|
p->pdev = pdev;
|
|
|
|
platform_set_drvdata(pdev, p);
|
|
|
|
spin_lock_init(&p->sense_lock);
|
|
|
|
|
2019-11-13 10:11:03 +00:00
|
|
|
irq[0] = platform_get_irq(pdev, 0);
|
|
|
|
if (irq[0] < 0)
|
|
|
|
return irq[0];
|
2012-05-17 06:22:23 +00:00
|
|
|
|
2019-11-13 10:11:03 +00:00
|
|
|
irq[1] = platform_get_irq(pdev, 1);
|
|
|
|
if (irq[1] < 0)
|
|
|
|
return irq[1];
|
2012-05-17 06:22:23 +00:00
|
|
|
|
2019-10-02 16:33:48 +00:00
|
|
|
p->base0 = devm_platform_ioremap_resource(pdev, 0);
|
|
|
|
if (IS_ERR(p->base0))
|
|
|
|
return PTR_ERR(p->base0);
|
2012-05-17 06:22:23 +00:00
|
|
|
|
2019-10-02 16:33:48 +00:00
|
|
|
p->base1 = devm_platform_ioremap_resource(pdev, 1);
|
|
|
|
if (IS_ERR(p->base1))
|
|
|
|
return PTR_ERR(p->base1);
|
2012-05-17 06:22:23 +00:00
|
|
|
|
2019-07-11 08:29:36 +00:00
|
|
|
if (of_property_read_u32(dev->of_node, "ngpios", &ngpios)) {
|
|
|
|
dev_err(dev, "Missing ngpios OF property\n");
|
2019-05-27 12:40:51 +00:00
|
|
|
return -EINVAL;
|
2013-02-26 13:26:23 +00:00
|
|
|
}
|
|
|
|
|
2012-05-17 06:22:23 +00:00
|
|
|
gpio_chip = &p->gpio_chip;
|
|
|
|
gpio_chip->direction_input = em_gio_direction_input;
|
|
|
|
gpio_chip->get = em_gio_get;
|
|
|
|
gpio_chip->direction_output = em_gio_direction_output;
|
|
|
|
gpio_chip->set = em_gio_set;
|
|
|
|
gpio_chip->to_irq = em_gio_to_irq;
|
2023-10-10 12:33:08 +00:00
|
|
|
gpio_chip->request = pinctrl_gpio_request;
|
2013-07-03 04:14:32 +00:00
|
|
|
gpio_chip->free = em_gio_free;
|
2012-05-17 06:22:23 +00:00
|
|
|
gpio_chip->label = name;
|
2019-07-11 08:29:36 +00:00
|
|
|
gpio_chip->parent = dev;
|
2012-05-17 06:22:23 +00:00
|
|
|
gpio_chip->owner = THIS_MODULE;
|
2015-06-23 13:48:02 +00:00
|
|
|
gpio_chip->base = -1;
|
|
|
|
gpio_chip->ngpio = ngpios;
|
2012-05-17 06:22:23 +00:00
|
|
|
|
|
|
|
irq_chip = &p->irq_chip;
|
2019-10-24 12:22:23 +00:00
|
|
|
irq_chip->name = "gpio-em";
|
2012-05-17 06:22:23 +00:00
|
|
|
irq_chip->irq_mask = em_gio_irq_disable;
|
|
|
|
irq_chip->irq_unmask = em_gio_irq_enable;
|
|
|
|
irq_chip->irq_set_type = em_gio_irq_set_type;
|
2014-03-14 17:16:20 +00:00
|
|
|
irq_chip->irq_request_resources = em_gio_irq_reqres;
|
|
|
|
irq_chip->irq_release_resources = em_gio_irq_relres;
|
2013-11-20 00:23:44 +00:00
|
|
|
irq_chip->flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_MASK_ON_SUSPEND;
|
2012-05-17 06:22:23 +00:00
|
|
|
|
2019-07-11 08:29:36 +00:00
|
|
|
p->irq_domain = irq_domain_add_simple(dev->of_node, ngpios, 0,
|
2012-10-16 18:15:02 +00:00
|
|
|
&em_gio_irq_domain_ops, p);
|
gpio: em: Fix build errors
Fix below build errors:
CC [M] drivers/gpio/gpio-em.o
drivers/gpio/gpio-em.c: In function 'em_gio_probe':
drivers/gpio/gpio-em.c:306: error: 'err' undeclared (first use in this function)
drivers/gpio/gpio-em.c:306: error: (Each undeclared identifier is reported only once
drivers/gpio/gpio-em.c:306: error: for each function it appears in.)
drivers/gpio/gpio-em.c:308: error: label 'err3' used but not defined
drivers/gpio/gpio-em.c:279: error: label 'err2' used but not defined
drivers/gpio/gpio-em.c:265: error: label 'err1' used but not defined
drivers/gpio/gpio-em.c:250: error: label 'err0' used but not defined
drivers/gpio/gpio-em.c:309: warning: no return statement in function returning non-void
drivers/gpio/gpio-em.c: At top level:
drivers/gpio/gpio-em.c:311: error: expected identifier or '(' before 'if'
drivers/gpio/gpio-em.c:317: error: expected identifier or '(' before 'if'
drivers/gpio/gpio-em.c:323: warning: data definition has no type or storage class
drivers/gpio/gpio-em.c:323: warning: type defaults to 'int' in declaration of 'ret'
drivers/gpio/gpio-em.c:323: error: 'gpio_chip' undeclared here (not in a function)
drivers/gpio/gpio-em.c:323: error: initializer element is not constant
drivers/gpio/gpio-em.c:324: error: expected identifier or '(' before 'if'
drivers/gpio/gpio-em.c:328: error: expected identifier or '(' before 'return'
drivers/gpio/gpio-em.c:330: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
drivers/gpio/gpio-em.c:332: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
drivers/gpio/gpio-em.c:334: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
drivers/gpio/gpio-em.c:336: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
drivers/gpio/gpio-em.c:338: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
drivers/gpio/gpio-em.c:340: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
drivers/gpio/gpio-em.c:342: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
drivers/gpio/gpio-em.c:344: error: expected identifier or '(' before '}' token
drivers/gpio/gpio-em.c: In function 'em_gio_remove':
drivers/gpio/gpio-em.c:361: error: implicit declaration of function 'em_gio_irq_domain_cleanup'
make[2]: *** [drivers/gpio/gpio-em.o] Error 1
make[1]: *** [drivers/gpio] Error 2
make: *** [drivers] Error 2
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2012-10-31 09:03:33 +00:00
|
|
|
if (!p->irq_domain) {
|
2019-07-11 08:29:36 +00:00
|
|
|
dev_err(dev, "cannot initialize irq domain\n");
|
2019-05-27 12:40:51 +00:00
|
|
|
return -ENXIO;
|
2012-05-17 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
2019-07-11 08:29:36 +00:00
|
|
|
ret = devm_add_action_or_reset(dev, em_gio_irq_domain_remove,
|
2019-07-11 08:29:35 +00:00
|
|
|
p->irq_domain);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2019-11-13 10:11:03 +00:00
|
|
|
if (devm_request_irq(dev, irq[0], em_gio_irq_handler, 0, name, p)) {
|
2019-07-11 08:29:36 +00:00
|
|
|
dev_err(dev, "failed to request low IRQ\n");
|
2019-07-11 08:29:35 +00:00
|
|
|
return -ENOENT;
|
2012-05-17 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
2019-11-13 10:11:03 +00:00
|
|
|
if (devm_request_irq(dev, irq[1], em_gio_irq_handler, 0, name, p)) {
|
2019-07-11 08:29:36 +00:00
|
|
|
dev_err(dev, "failed to request high IRQ\n");
|
2019-07-11 08:29:35 +00:00
|
|
|
return -ENOENT;
|
2012-05-17 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
2019-07-11 08:29:36 +00:00
|
|
|
ret = devm_gpiochip_add_data(dev, gpio_chip, p);
|
2012-05-17 06:22:23 +00:00
|
|
|
if (ret) {
|
2019-07-11 08:29:36 +00:00
|
|
|
dev_err(dev, "failed to add GPIO controller\n");
|
2019-07-11 08:29:35 +00:00
|
|
|
return ret;
|
2012-05-17 06:22:23 +00:00
|
|
|
}
|
2013-07-03 04:14:32 +00:00
|
|
|
|
2012-05-17 06:22:23 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-02-26 13:26:23 +00:00
|
|
|
static const struct of_device_id em_gio_dt_ids[] = {
|
|
|
|
{ .compatible = "renesas,em-gio", },
|
|
|
|
{},
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, em_gio_dt_ids);
|
|
|
|
|
2012-05-17 06:22:23 +00:00
|
|
|
static struct platform_driver em_gio_device_driver = {
|
|
|
|
.probe = em_gio_probe,
|
|
|
|
.driver = {
|
|
|
|
.name = "em_gio",
|
2013-02-26 13:26:23 +00:00
|
|
|
.of_match_table = em_gio_dt_ids,
|
2012-05-17 06:22:23 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-02-26 13:26:23 +00:00
|
|
|
static int __init em_gio_init(void)
|
|
|
|
{
|
|
|
|
return platform_driver_register(&em_gio_device_driver);
|
|
|
|
}
|
|
|
|
postcore_initcall(em_gio_init);
|
|
|
|
|
|
|
|
static void __exit em_gio_exit(void)
|
|
|
|
{
|
|
|
|
platform_driver_unregister(&em_gio_device_driver);
|
|
|
|
}
|
|
|
|
module_exit(em_gio_exit);
|
2012-05-17 06:22:23 +00:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Magnus Damm");
|
|
|
|
MODULE_DESCRIPTION("Renesas Emma Mobile GIO Driver");
|
|
|
|
MODULE_LICENSE("GPL v2");
|