Release 4.7 drivers/gpio/gpio-davinci.c
/*
* TI DaVinci GPIO Support
*
* Copyright (c) 2006-2007 David Brownell
* Copyright (c) 2007, MontaVista Software, Inc. <source@mvista.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <linux/gpio.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/irqdomain.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/platform_data/gpio-davinci.h>
#include <linux/irqchip/chained_irq.h>
struct davinci_gpio_regs {
u32 dir;
u32 out_data;
u32 set_data;
u32 clr_data;
u32 in_data;
u32 set_rising;
u32 clr_rising;
u32 set_falling;
u32 clr_falling;
u32 intstat;
};
typedef struct irq_chip *(*gpio_get_irq_chip_cb_t)(unsigned int irq);
#define BINTEN 0x8
/* GPIO Interrupt Per-Bank Enable Register */
static void __iomem *gpio_base;
static struct davinci_gpio_regs __iomem *gpio2regs(unsigned gpio)
{
void __iomem *ptr;
if (gpio < 32 * 1)
ptr = gpio_base + 0x10;
else if (gpio < 32 * 2)
ptr = gpio_base + 0x38;
else if (gpio < 32 * 3)
ptr = gpio_base + 0x60;
else if (gpio < 32 * 4)
ptr = gpio_base + 0x88;
else if (gpio < 32 * 5)
ptr = gpio_base + 0xb0;
else
ptr = NULL;
return ptr;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
cyril chemparathy | cyril chemparathy | 87 | 87.88% | 3 | 60.00% |
vladimir barinov | vladimir barinov | 11 | 11.11% | 1 | 20.00% |
kevin hilman | kevin hilman | 1 | 1.01% | 1 | 20.00% |
| Total | 99 | 100.00% | 5 | 100.00% |
static inline struct davinci_gpio_regs __iomem *irq2regs(struct irq_data *d)
{
struct davinci_gpio_regs __iomem *g;
g = (__force struct davinci_gpio_regs __iomem *)irq_data_get_irq_chip_data(d);
return g;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
kevin hilman | kevin hilman | 28 | 73.68% | 1 | 33.33% |
thomas gleixner | thomas gleixner | 6 | 15.79% | 1 | 33.33% |
cyril chemparathy | cyril chemparathy | 4 | 10.53% | 1 | 33.33% |
| Total | 38 | 100.00% | 3 | 100.00% |
static int davinci_gpio_irq_setup(struct platform_device *pdev);
/*--------------------------------------------------------------------------*/
/* board setup code *MUST* setup pinmux and enable the GPIO clock. */
static inline int __davinci_direction(struct gpio_chip *chip,
unsigned offset, bool out, int value)
{
struct davinci_gpio_controller *d = gpiochip_get_data(chip);
struct davinci_gpio_regs __iomem *g = d->regs;
unsigned long flags;
u32 temp;
u32 mask = 1 << offset;
spin_lock_irqsave(&d->lock, flags);
temp = readl_relaxed(&g->dir);
if (out) {
temp &= ~mask;
writel_relaxed(mask, value ? &g->set_data : &g->clr_data);
} else {
temp |= mask;
}
writel_relaxed(temp, &g->dir);
spin_unlock_irqrestore(&d->lock, flags);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
cyril chemparathy | cyril chemparathy | 64 | 48.12% | 3 | 37.50% |
david brownell | david brownell | 42 | 31.58% | 1 | 12.50% |
vladimir barinov | vladimir barinov | 22 | 16.54% | 1 | 12.50% |
prabhakar lad | prabhakar lad | 3 | 2.26% | 1 | 12.50% |
kevin hilman | kevin hilman | 1 | 0.75% | 1 | 12.50% |
linus walleij | linus walleij | 1 | 0.75% | 1 | 12.50% |
| Total | 133 | 100.00% | 8 | 100.00% |
static int davinci_direction_in(struct gpio_chip *chip, unsigned offset)
{
return __davinci_direction(chip, offset, false, 0);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 11 | 42.31% | 1 | 33.33% |
vladimir barinov | vladimir barinov | 8 | 30.77% | 1 | 33.33% |
cyril chemparathy | cyril chemparathy | 7 | 26.92% | 1 | 33.33% |
| Total | 26 | 100.00% | 3 | 100.00% |
static int
davinci_direction_out(struct gpio_chip *chip, unsigned offset, int value)
{
return __davinci_direction(chip, offset, true, value);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
cyril chemparathy | cyril chemparathy | 13 | 44.83% | 1 | 33.33% |
david brownell | david brownell | 11 | 37.93% | 1 | 33.33% |
vladimir barinov | vladimir barinov | 5 | 17.24% | 1 | 33.33% |
| Total | 29 | 100.00% | 3 | 100.00% |
/*
* Read the pin's value (works even if it's set up as output);
* returns zero/nonzero.
*
* Note that changes are synched to the GPIO clock, so reading values back
* right after you've set them may give old values.
*/
static int davinci_gpio_get(struct gpio_chip *chip, unsigned offset)
{
struct davinci_gpio_controller *d = gpiochip_get_data(chip);
struct davinci_gpio_regs __iomem *g = d->regs;
return !!((1 << offset) & readl_relaxed(&g->in_data));
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
cyril chemparathy | cyril chemparathy | 19 | 35.85% | 2 | 25.00% |
david brownell | david brownell | 14 | 26.42% | 1 | 12.50% |
vladimir barinov | vladimir barinov | 13 | 24.53% | 1 | 12.50% |
linus walleij | linus walleij | 5 | 9.43% | 2 | 25.00% |
kevin hilman | kevin hilman | 1 | 1.89% | 1 | 12.50% |
prabhakar lad | prabhakar lad | 1 | 1.89% | 1 | 12.50% |
| Total | 53 | 100.00% | 8 | 100.00% |
/*
* Assuming the pin is muxed as a gpio output, set its output value.
*/
static void
davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
{
struct davinci_gpio_controller *d = gpiochip_get_data(chip);
struct davinci_gpio_regs __iomem *g = d->regs;
writel_relaxed((1 << offset), value ? &g->set_data : &g->clr_data);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
vladimir barinov | vladimir barinov | 30 | 51.72% | 1 | 16.67% |
david brownell | david brownell | 23 | 39.66% | 1 | 16.67% |
cyril chemparathy | cyril chemparathy | 2 | 3.45% | 1 | 16.67% |
linus walleij | linus walleij | 1 | 1.72% | 1 | 16.67% |
kevin hilman | kevin hilman | 1 | 1.72% | 1 | 16.67% |
prabhakar lad | prabhakar lad | 1 | 1.72% | 1 | 16.67% |
| Total | 58 | 100.00% | 6 | 100.00% |
static struct davinci_gpio_platform_data *
davinci_gpio_get_pdata(struct platform_device *pdev)
{
struct device_node *dn = pdev->dev.of_node;
struct davinci_gpio_platform_data *pdata;
int ret;
u32 val;
if (!IS_ENABLED(CONFIG_OF) || !pdev->dev.of_node)
return dev_get_platdata(&pdev->dev);
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return NULL;
ret = of_property_read_u32(dn, "ti,ngpio", &val);
if (ret)
goto of_err;
pdata->ngpio = val;
ret = of_property_read_u32(dn, "ti,davinci-gpio-unbanked", &val);
if (ret)
goto of_err;
pdata->gpio_unbanked = val;
return pdata;
of_err:
dev_err(&pdev->dev, "Populating pdata from DT failed: err %d\n", ret);
return NULL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
kv sujith | kv sujith | 151 | 97.42% | 1 | 50.00% |
nizam haider | nizam haider | 4 | 2.58% | 1 | 50.00% |
| Total | 155 | 100.00% | 2 | 100.00% |
#ifdef CONFIG_OF_GPIO
static int davinci_gpio_of_xlate(struct gpio_chip *gc,
const struct of_phandle_args *gpiospec,
u32 *flags)
{
struct davinci_gpio_controller *chips = dev_get_drvdata(gc->parent);
struct davinci_gpio_platform_data *pdata = dev_get_platdata(gc->parent);
if (gpiospec->args[0] > pdata->ngpio)
return -EINVAL;
if (gc != &chips[gpiospec->args[0] / 32].chip)
return -EINVAL;
if (flags)
*flags = gpiospec->args[1];
return gpiospec->args[0] % 32;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
alexander holler | alexander holler | 107 | 98.17% | 1 | 50.00% |
linus walleij | linus walleij | 2 | 1.83% | 1 | 50.00% |
| Total | 109 | 100.00% | 2 | 100.00% |
#endif
static int davinci_gpio_probe(struct platform_device *pdev)
{
int i, base;
unsigned ngpio, nbank;
struct davinci_gpio_controller *chips;
struct davinci_gpio_platform_data *pdata;
struct davinci_gpio_regs __iomem *regs;
struct device *dev = &pdev->dev;
struct resource *res;
pdata = davinci_gpio_get_pdata(pdev);
if (!pdata) {
dev_err(dev, "No platform data found\n");
return -EINVAL;
}
dev->platform_data = pdata;
/*
* The gpio banks conceptually expose a segmented bitmap,
* and "ngpio" is one more than the largest zero-based
* bit index that's valid.
*/
ngpio = pdata->ngpio;
if (ngpio == 0) {
dev_err(dev, "How many GPIOs?\n");
return -EINVAL;
}
if (WARN_ON(ARCH_NR_GPIOS < ngpio))
ngpio = ARCH_NR_GPIOS;
nbank = DIV_ROUND_UP(ngpio, 32);
chips = devm_kzalloc(dev,
nbank * sizeof(struct davinci_gpio_controller),
GFP_KERNEL);
if (!chips)
return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
gpio_base = devm_ioremap_resource(dev, res);
if (IS_ERR(gpio_base))
return PTR_ERR(gpio_base);
for (i = 0, base = 0; base < ngpio; i++, base += 32) {
chips[i].chip.label = "DaVinci";
chips[i].chip.direction_input = davinci_direction_in;
chips[i].chip.get = davinci_gpio_get;
chips[i].chip.direction_output = davinci_direction_out;
chips[i].chip.set = davinci_gpio_set;
chips[i].chip.base = base;
chips[i].chip.ngpio = ngpio - base;
if (chips[i].chip.ngpio > 32)
chips[i].chip.ngpio = 32;
#ifdef CONFIG_OF_GPIO
chips[i].chip.of_gpio_n_cells = 2;
chips[i].chip.of_xlate = davinci_gpio_of_xlate;
chips[i].chip.parent = dev;
chips[i].chip.of_node = dev->of_node;
#endif
spin_lock_init(&chips[i].lock);
regs = gpio2regs(base);
if (!regs)
return -ENXIO;
chips[i].regs = regs;
chips[i].set_data = ®s->set_data;
chips[i].clr_data = ®s->clr_data;
chips[i].in_data = ®s->in_data;
gpiochip_add_data(&chips[i].chip, &chips[i]);
}
platform_set_drvdata(pdev, chips);
davinci_gpio_irq_setup(pdev);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 175 | 37.15% | 2 | 11.76% |
kv sujith | kv sujith | 130 | 27.60% | 2 | 11.76% |
cyril chemparathy | cyril chemparathy | 81 | 17.20% | 4 | 23.53% |
alexander holler | alexander holler | 32 | 6.79% | 1 | 5.88% |
lokesh vutla | lokesh vutla | 12 | 2.55% | 1 | 5.88% |
mark a. greer | mark a. greer | 10 | 2.12% | 1 | 5.88% |
vladimir barinov | vladimir barinov | 10 | 2.12% | 1 | 5.88% |
nicholas krause | nicholas krause | 9 | 1.91% | 1 | 5.88% |
linus walleij | linus walleij | 8 | 1.70% | 2 | 11.76% |
kevin hilman | kevin hilman | 2 | 0.42% | 1 | 5.88% |
grygorii strashko | grygorii strashko | 2 | 0.42% | 1 | 5.88% |
| Total | 471 | 100.00% | 17 | 100.00% |
/*--------------------------------------------------------------------------*/
/*
* We expect irqs will normally be set up as input pins, but they can also be
* used as output pins ... which is convenient for testing.
*
* NOTE: The first few GPIOs also have direct INTC hookups in addition
* to their GPIOBNK0 irq, with a bit less overhead.
*
* All those INTC hookups (direct, plus several IRQ banks) can also
* serve as EDMA event triggers.
*/
static void gpio_irq_disable(struct irq_data *d)
{
struct davinci_gpio_regs __iomem *g = irq2regs(d);
u32 mask = (u32) irq_data_get_irq_handler_data(d);
writel_relaxed(mask, &g->clr_falling);
writel_relaxed(mask, &g->clr_rising);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
vladimir barinov | vladimir barinov | 38 | 71.70% | 1 | 14.29% |
lennert buytenhek | lennert buytenhek | 6 | 11.32% | 1 | 14.29% |
david brownell | david brownell | 3 | 5.66% | 1 | 14.29% |
cyril chemparathy | cyril chemparathy | 2 | 3.77% | 1 | 14.29% |
prabhakar lad | prabhakar lad | 2 | 3.77% | 1 | 14.29% |
thomas gleixner | thomas gleixner | 1 | 1.89% | 1 | 14.29% |
kevin hilman | kevin hilman | 1 | 1.89% | 1 | 14.29% |
| Total | 53 | 100.00% | 7 | 100.00% |
static void gpio_irq_enable(struct irq_data *d)
{
struct davinci_gpio_regs __iomem *g = irq2regs(d);
u32 mask = (u32) irq_data_get_irq_handler_data(d);
unsigned status = irqd_get_trigger_type(d);
status &= IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING;
if (!status)
status = IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING;
if (status & IRQ_TYPE_EDGE_FALLING)
writel_relaxed(mask, &g->set_falling);
if (status & IRQ_TYPE_EDGE_RISING)
writel_relaxed(mask, &g->set_rising);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
vladimir barinov | vladimir barinov | 47 | 52.22% | 1 | 11.11% |
david brownell | david brownell | 27 | 30.00% | 2 | 22.22% |
lennert buytenhek | lennert buytenhek | 7 | 7.78% | 1 | 11.11% |
thomas gleixner | thomas gleixner | 4 | 4.44% | 2 | 22.22% |
cyril chemparathy | cyril chemparathy | 2 | 2.22% | 1 | 11.11% |
prabhakar lad | prabhakar lad | 2 | 2.22% | 1 | 11.11% |
kevin hilman | kevin hilman | 1 | 1.11% | 1 | 11.11% |
| Total | 90 | 100.00% | 9 | 100.00% |
static int gpio_irq_type(struct irq_data *d, unsigned trigger)
{
if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
return -EINVAL;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
vladimir barinov | vladimir barinov | 28 | 87.50% | 1 | 50.00% |
lennert buytenhek | lennert buytenhek | 4 | 12.50% | 1 | 50.00% |
| Total | 32 | 100.00% | 2 | 100.00% |
static struct irq_chip gpio_irqchip = {
.name = "GPIO",
.irq_enable = gpio_irq_enable,
.irq_disable = gpio_irq_disable,
.irq_set_type = gpio_irq_type,
.flags = IRQCHIP_SET_TYPE_MASKED,
};
static void gpio_irq_handler(struct irq_desc *desc)
{
unsigned int irq = irq_desc_get_irq(desc);
struct davinci_gpio_regs __iomem *g;
u32 mask = 0xffff;
struct davinci_gpio_controller *d;
d = (struct davinci_gpio_controller *)irq_desc_get_handler_data(desc);
g = (struct davinci_gpio_regs __iomem *)d->regs;
/* we only care about one bank */
if (irq & 1)
mask <<= 16;
/* temporarily mask (level sensitive) parent IRQ */
chained_irq_enter(irq_desc_get_chip(desc), desc);
while (1) {
u32 status;
int bit;
/* ack any irqs */
status = readl_relaxed(&g->intstat) & mask;
if (!status)
break;
writel_relaxed(status, &g->intstat);
/* now demux them to the right lowlevel handler */
while (status) {
bit = __ffs(status);
status &= ~BIT(bit);
generic_handle_irq(
irq_find_mapping(d->irq_domain,
d->chip.base + bit));
}
}
chained_irq_exit(irq_desc_get_chip(desc), desc);
/* now it may re-trigger */
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
vladimir barinov | vladimir barinov | 91 | 52.30% | 1 | 8.33% |
prabhakar lad | prabhakar lad | 26 | 14.94% | 2 | 16.67% |
ido yariv | ido yariv | 20 | 11.49% | 1 | 8.33% |
thomas gleixner | thomas gleixner | 19 | 10.92% | 2 | 16.67% |
grygorii strashko | grygorii strashko | 10 | 5.75% | 1 | 8.33% |
kevin hilman | kevin hilman | 3 | 1.72% | 2 | 16.67% |
lennert buytenhek | lennert buytenhek | 3 | 1.72% | 1 | 8.33% |
cyril chemparathy | cyril chemparathy | 1 | 0.57% | 1 | 8.33% |
dmitry eremin-baryshkov | dmitry eremin-baryshkov | 1 | 0.57% | 1 | 8.33% |
| Total | 174 | 100.00% | 12 | 100.00% |
static int gpio_to_irq_banked(struct gpio_chip *chip, unsigned offset)
{
struct davinci_gpio_controller *d = gpiochip_get_data(chip);
if (d->irq_domain)
return irq_create_mapping(d->irq_domain, d->chip.base + offset);
else
return -ENXIO;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 29 | 56.86% | 1 | 20.00% |
grygorii strashko | grygorii strashko | 11 | 21.57% | 1 | 20.00% |
prabhakar lad | prabhakar lad | 9 | 17.65% | 1 | 20.00% |
cyril chemparathy | cyril chemparathy | 1 | 1.96% | 1 | 20.00% |
linus walleij | linus walleij | 1 | 1.96% | 1 | 20.00% |
| Total | 51 | 100.00% | 5 | 100.00% |
static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset)
{
struct davinci_gpio_controller *d = gpiochip_get_data(chip);
/*
* NOTE: we assume for now that only irqs in the first gpio_chip
* can provide direct-mapped IRQs to AINTC (up to 32 GPIOs).
*/
if (offset < d->gpio_unbanked)
return d->gpio_irq + offset;
else
return -ENODEV;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 35 | 77.78% | 1 | 20.00% |
kv sujith | kv sujith | 7 | 15.56% | 1 | 20.00% |
avinash philip | avinash philip | 1 | 2.22% | 1 | 20.00% |
prabhakar lad | prabhakar lad | 1 | 2.22% | 1 | 20.00% |
linus walleij | linus walleij | 1 | 2.22% | 1 | 20.00% |
| Total | 45 | 100.00% | 5 | 100.00% |
static int gpio_irq_type_unbanked(struct irq_data *data, unsigned trigger)
{
struct davinci_gpio_controller *d;
struct davinci_gpio_regs __iomem *g;
u32 mask;
d = (struct davinci_gpio_controller *)irq_data_get_irq_handler_data(data);
g = (struct davinci_gpio_regs __iomem *)d->regs;
mask = __gpio_mask(data->irq - d->gpio_irq);
if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
return -EINVAL;
writel_relaxed(mask, (trigger & IRQ_TYPE_EDGE_FALLING)
? &g->set_falling : &g->clr_falling);
writel_relaxed(mask, (trigger & IRQ_TYPE_EDGE_RISING)
? &g->set_rising : &g->clr_rising);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 76 | 60.80% | 1 | 12.50% |
sekhar nori | sekhar nori | 37 | 29.60% | 1 | 12.50% |
lennert buytenhek | lennert buytenhek | 4 | 3.20% | 1 | 12.50% |
jiang liu | jiang liu | 3 | 2.40% | 1 | 12.50% |
prabhakar lad | prabhakar lad | 2 | 1.60% | 1 | 12.50% |
kevin hilman | kevin hilman | 1 | 0.80% | 1 | 12.50% |
cyril chemparathy | cyril chemparathy | 1 | 0.80% | 1 | 12.50% |
kv sujith | kv sujith | 1 | 0.80% | 1 | 12.50% |
| Total | 125 | 100.00% | 8 | 100.00% |
static int
davinci_gpio_irq_map(struct irq_domain *d, unsigned int irq,
irq_hw_number_t hw)
{
struct davinci_gpio_regs __iomem *g = gpio2regs(hw);
irq_set_chip_and_handler_name(irq, &gpio_irqchip, handle_simple_irq,
"davinci_gpio");
irq_set_irq_type(irq, IRQ_TYPE_NONE);
irq_set_chip_data(irq, (__force void *)g);
irq_set_handler_data(irq, (void *)__gpio_mask(hw));
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
prabhakar lad | prabhakar lad | 77 | 100.00% | 1 | 100.00% |
| Total | 77 | 100.00% | 1 | 100.00% |
static const struct irq_domain_ops davinci_gpio_irq_ops = {
.map = davinci_gpio_irq_map,
.xlate = irq_domain_xlate_onetwocell,
};
static struct irq_chip *davinci_gpio_get_irq_chip(unsigned int irq)
{
static struct irq_chip_type gpio_unbanked;
gpio_unbanked = *irq_data_get_chip_type(irq_get_irq_data(irq));
return &gpio_unbanked.chip;
}Contributors
| Person | Tokens | Prop | Commits | CommitProp |
grygorii strashko | grygorii strashko | 32 | 94.12% | 1 | 50.00% |
geliang tang | geliang tang | 2 | 5.88% | 1 | 50.00% |
| Total | 34 | 100.00% | 2 | 100.00% |
;
static struct irq_chip *keystone_gpio_get_irq_chip(unsigned int irq)
{
static struct irq_chip gpio_unbanked;
gpio_unbanked = *irq_get_chip(irq);
return &gpio_unbanked;
}Contributors
| Person | Tokens | Prop | Commits | CommitProp |
grygorii strashko | grygorii strashko | 29 | 100.00% | 1 | 100.00% |
| Total | 29 | 100.00% | 1 | 100.00% |
;
static const struct of_device_id davinci_gpio_ids[];
/*
* NOTE: for suspend/resume, probably best to make a platform_device with
* suspend_late/resume_resume calls hooking into results of the set_wake()
* calls ... so if no gpios are wakeup events the clock can be disabled,
* with outputs left at previously set levels, and so that VDD3P3V.IOPWDN0
* (dm6446) can be set appropriately for GPIOV33 pins.
*/
static int davinci_gpio_irq_setup(struct platform_device *pdev)
{
unsigned gpio, bank;
int irq;
struct clk *clk;
u32 binten = 0;
unsigned ngpio, bank_irq;
struct device *dev = &pdev->dev;
struct resource *res;
struct davinci_gpio_controller *chips = platform_get_drvdata(pdev);
struct davinci_gpio_platform_data *pdata = dev->platform_data;
struct davinci_gpio_regs __iomem *g;
struct irq_domain *irq_domain = NULL;
const struct of_device_id *match;
struct irq_chip *irq_chip;
gpio_get_irq_chip_cb_t gpio_get_irq_chip;
/*
* Use davinci_gpio_get_irq_chip by default to handle non DT cases
*/
gpio_get_irq_chip = davinci_gpio_get_irq_chip;
match = of_match_device(of_match_ptr(davinci_gpio_ids),
dev);
if (match)
gpio_get_irq_chip = (gpio_get_irq_chip_cb_t)match->data;
ngpio = pdata->ngpio;
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res) {
dev_err(dev, "Invalid IRQ resource\n");
return -EBUSY;
}
bank_irq = res->start;
if (!bank_irq) {
dev_err(dev, "Invalid IRQ resource\n");
return -ENODEV;
}
clk = devm_clk_get(dev, "gpio");
if (IS_ERR(clk)) {
printk(KERN_ERR "Error %ld getting gpio clock?\n",
PTR_ERR(clk));
return PTR_ERR(clk);
}
clk_prepare_enable(clk);
if (!pdata->gpio_unbanked) {
irq = irq_alloc_descs(-1, 0, ngpio, 0);
if (irq < 0) {
dev_err(dev, "Couldn't allocate IRQ numbers\n");
return irq;
}
irq_domain = irq_domain_add_legacy(dev->of_node, ngpio, irq, 0,
&davinci_gpio_irq_ops,
chips);
if (!irq_domain) {
dev_err(dev, "Couldn't register an IRQ domain\n");
return -ENODEV;
}
}
/*
* Arrange gpio_to_irq() support, handling either direct IRQs or
* banked IRQs. Having GPIOs in the first GPIO bank use direct
* IRQs, while the others use banked IRQs, would need some setup
* tweaks to recognize hardware which can do that.
*/
for (gpio = 0, bank = 0; gpio < ngpio; bank++, gpio += 32) {
chips[bank].chip.to_irq = gpio_to_irq_banked;
chips[bank].irq_domain = irq_domain;
}
/*
* AINTC can handle direct/unbanked IRQs for GPIOs, with the GPIO
* controller only handling trigger modes. We currently assume no
* IRQ mux conflicts; gpio_irq_type_unbanked() is only for GPIOs.
*/
if (pdata->gpio_unbanked) {
/* pass "bank 0" GPIO IRQs to AINTC */
chips[0].chip.to_irq = gpio_to_irq_unbanked;
chips[0].gpio_irq = bank_irq;
chips[0].gpio_unbanked = pdata->gpio_unbanked;
binten = GENMASK(pdata->gpio_unbanked / 16, 0);
/* AINTC handles mask/unmask; GPIO handles triggering */
irq = bank_irq;
irq_chip = gpio_get_irq_chip(irq);
irq_chip->name = "GPIO-AINTC";
irq_chip->irq_set_type = gpio_irq_type_unbanked;
/* default trigger: both edges */
g = gpio2regs(0);
writel_relaxed(~0, &g->set_falling);
writel_relaxed(~0, &g->set_rising);
/* set the direct IRQs up to use that irqchip */
for (gpio = 0; gpio < pdata->gpio_unbanked; gpio++, irq++) {
irq_set_chip(irq, irq_chip);
irq_set_handler_data(irq, &chips[gpio / 32]);
irq_set_status_flags(irq, IRQ_TYPE_EDGE_BOTH);
}
goto done;
}
/*
* Or, AINTC can handle IRQs for banks of 16 GPIO IRQs, which we
* then chain through our own handler.
*/
for (gpio = 0, bank = 0; gpio < ngpio; bank++, bank_irq++, gpio += 16) {
/* disabled by default, enabled only as needed */
g = gpio2regs(gpio);
writel_relaxed(~0, &g->clr_falling);
writel_relaxed(~0, &g->clr_rising);
/*
* Each chip handles 32 gpios, and each irq bank consists of 16
* gpio irqs. Pass the irq bank's corresponding controller to
* the chained irq handler.
*/
irq_set_chained_handler_and_data(bank_irq, gpio_irq_handler,
&chips[gpio / 32]);
binten |= BIT(bank);
}
done:
/*
* BINTEN -- per-bank interrupt enable. genirq would also let these
* bits be set/cleared dynamically.
*/
writel_relaxed(binten, gpio_base + BINTEN);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 198 | 32.95% | 2 | 8.70% |
vladimir barinov | vladimir barinov | 105 | 17.47% | 1 | 4.35% |
prabhakar lad | prabhakar lad | 103 | 17.14% | 3 | 13.04% |
kv sujith | kv sujith | 76 | 12.65% | 1 | 4.35% |
grygorii strashko | grygorii strashko | 62 | 10.32% | 2 | 8.70% |
mark a. greer | mark a. greer | 14 | 2.33% | 1 | 4.35% |
thomas gleixner | thomas gleixner | 8 | 1.33% | 3 | 13.04% |
vitaly andrianov | vitaly andrianov | 7 | 1.16% | 1 | 4.35% |
ido yariv | ido yariv | 7 | 1.16% | 1 | 4.35% |
sekhar nori | sekhar nori | 6 | 1.00% | 1 | 4.35% |
alexander shiyan | alexander shiyan | 3 | 0.50% | 1 | 4.35% |
avinash philip | avinash philip | 3 | 0.50% | 1 | 4.35% |
cyril chemparathy | cyril chemparathy | 3 | 0.50% | 1 | 4.35% |
j keerthy | j keerthy | 3 | 0.50% | 1 | 4.35% |
murali karicheri | murali karicheri | 1 | 0.17% | 1 | 4.35% |
lennert buytenhek | lennert buytenhek | 1 | 0.17% | 1 | 4.35% |
kevin hilman | kevin hilman | 1 | 0.17% | 1 | 4.35% |
| Total | 601 | 100.00% | 23 | 100.00% |
#if IS_ENABLED(CONFIG_OF)
static const struct of_device_id davinci_gpio_ids[] = {
{ .compatible = "ti,keystone-gpio", keystone_gpio_get_irq_chip},
{ .compatible = "ti,dm6441-gpio", davinci_gpio_get_irq_chip},
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, davinci_gpio_ids);
#endif
static struct platform_driver davinci_gpio_driver = {
.probe = davinci_gpio_probe,
.driver = {
.name = "davinci_gpio",
.of_match_table = of_match_ptr(davinci_gpio_ids),
},
};
/**
* GPIO driver registration needs to be done before machine_init functions
* access GPIO. Hence davinci_gpio_drv_reg() is a postcore_initcall.
*/
static int __init davinci_gpio_drv_reg(void)
{
return platform_driver_register(&davinci_gpio_driver);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
kv sujith | kv sujith | 16 | 100.00% | 1 | 100.00% |
| Total | 16 | 100.00% | 1 | 100.00% |
postcore_initcall(davinci_gpio_drv_reg);
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david brownell | david brownell | 650 | 23.52% | 4 | 7.84% |
kv sujith | kv sujith | 471 | 17.04% | 2 | 3.92% |
vladimir barinov | vladimir barinov | 449 | 16.24% | 1 | 1.96% |
cyril chemparathy | cyril chemparathy | 330 | 11.94% | 7 | 13.73% |
prabhakar lad | prabhakar lad | 248 | 8.97% | 3 | 5.88% |
grygorii strashko | grygorii strashko | 184 | 6.66% | 4 | 7.84% |
alexander holler | alexander holler | 144 | 5.21% | 1 | 1.96% |
kevin hilman | kevin hilman | 47 | 1.70% | 3 | 5.88% |
sekhar nori | sekhar nori | 43 | 1.56% | 1 | 1.96% |
thomas gleixner | thomas gleixner | 43 | 1.56% | 6 | 11.76% |
lennert buytenhek | lennert buytenhek | 28 | 1.01% | 1 | 1.96% |
ido yariv | ido yariv | 27 | 0.98% | 1 | 1.96% |
mark a. greer | mark a. greer | 24 | 0.87% | 1 | 1.96% |
linus walleij | linus walleij | 19 | 0.69% | 4 | 7.84% |
lokesh vutla | lokesh vutla | 12 | 0.43% | 1 | 1.96% |
avinash philip | avinash philip | 9 | 0.33% | 1 | 1.96% |
nicholas krause | nicholas krause | 9 | 0.33% | 1 | 1.96% |
vitaly andrianov | vitaly andrianov | 7 | 0.25% | 1 | 1.96% |
nizam haider | nizam haider | 4 | 0.14% | 1 | 1.96% |
alexander shiyan | alexander shiyan | 3 | 0.11% | 1 | 1.96% |
russell king | russell king | 3 | 0.11% | 1 | 1.96% |
jiang liu | jiang liu | 3 | 0.11% | 1 | 1.96% |
j keerthy | j keerthy | 3 | 0.11% | 1 | 1.96% |
geliang tang | geliang tang | 2 | 0.07% | 1 | 1.96% |
dmitry eremin-baryshkov | dmitry eremin-baryshkov | 1 | 0.04% | 1 | 1.96% |
murali karicheri | murali karicheri | 1 | 0.04% | 1 | 1.96% |
| Total | 2764 | 100.00% | 51 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.