Commit f5e4e20f authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'gpio-for-linus' of git://git.secretlab.ca/git/linux-2.6

2nd round of GPIO changes for v3.3 merge window

* tag 'gpio-for-linus' of git://git.secretlab.ca/git/linux-2.6:
  GPIO: sa1100: implement proper gpiolib gpio_to_irq conversion
  gpio: pl061: remove combined interrupt
  gpio: pl061: convert to use generic irq chip
  GPIO: add bindings for managed devices
  ARM: realview: convert pl061 no irq to 0 instead of -1
  gpio: pl061: convert to use 0 for no irq
  gpio: pl061: use chained_irq_* functions in irq handler
  GPIO/pl061: Add suspend resume capability
  drivers/gpio/gpio-tegra.c: use devm_request_and_ioremap
parents 4964e066 f408c985
...@@ -117,17 +117,14 @@ static void __init realview_eb_map_io(void) ...@@ -117,17 +117,14 @@ static void __init realview_eb_map_io(void)
static struct pl061_platform_data gpio0_plat_data = { static struct pl061_platform_data gpio0_plat_data = {
.gpio_base = 0, .gpio_base = 0,
.irq_base = -1,
}; };
static struct pl061_platform_data gpio1_plat_data = { static struct pl061_platform_data gpio1_plat_data = {
.gpio_base = 8, .gpio_base = 8,
.irq_base = -1,
}; };
static struct pl061_platform_data gpio2_plat_data = { static struct pl061_platform_data gpio2_plat_data = {
.gpio_base = 16, .gpio_base = 16,
.irq_base = -1,
}; };
static struct pl022_ssp_controller ssp0_plat_data = { static struct pl022_ssp_controller ssp0_plat_data = {
......
...@@ -113,17 +113,14 @@ static void __init realview_pb1176_map_io(void) ...@@ -113,17 +113,14 @@ static void __init realview_pb1176_map_io(void)
static struct pl061_platform_data gpio0_plat_data = { static struct pl061_platform_data gpio0_plat_data = {
.gpio_base = 0, .gpio_base = 0,
.irq_base = -1,
}; };
static struct pl061_platform_data gpio1_plat_data = { static struct pl061_platform_data gpio1_plat_data = {
.gpio_base = 8, .gpio_base = 8,
.irq_base = -1,
}; };
static struct pl061_platform_data gpio2_plat_data = { static struct pl061_platform_data gpio2_plat_data = {
.gpio_base = 16, .gpio_base = 16,
.irq_base = -1,
}; };
static struct pl022_ssp_controller ssp0_plat_data = { static struct pl022_ssp_controller ssp0_plat_data = {
......
...@@ -112,17 +112,14 @@ static void __init realview_pb11mp_map_io(void) ...@@ -112,17 +112,14 @@ static void __init realview_pb11mp_map_io(void)
static struct pl061_platform_data gpio0_plat_data = { static struct pl061_platform_data gpio0_plat_data = {
.gpio_base = 0, .gpio_base = 0,
.irq_base = -1,
}; };
static struct pl061_platform_data gpio1_plat_data = { static struct pl061_platform_data gpio1_plat_data = {
.gpio_base = 8, .gpio_base = 8,
.irq_base = -1,
}; };
static struct pl061_platform_data gpio2_plat_data = { static struct pl061_platform_data gpio2_plat_data = {
.gpio_base = 16, .gpio_base = 16,
.irq_base = -1,
}; };
static struct pl022_ssp_controller ssp0_plat_data = { static struct pl022_ssp_controller ssp0_plat_data = {
......
...@@ -102,17 +102,14 @@ static void __init realview_pba8_map_io(void) ...@@ -102,17 +102,14 @@ static void __init realview_pba8_map_io(void)
static struct pl061_platform_data gpio0_plat_data = { static struct pl061_platform_data gpio0_plat_data = {
.gpio_base = 0, .gpio_base = 0,
.irq_base = -1,
}; };
static struct pl061_platform_data gpio1_plat_data = { static struct pl061_platform_data gpio1_plat_data = {
.gpio_base = 8, .gpio_base = 8,
.irq_base = -1,
}; };
static struct pl061_platform_data gpio2_plat_data = { static struct pl061_platform_data gpio2_plat_data = {
.gpio_base = 16, .gpio_base = 16,
.irq_base = -1,
}; };
static struct pl022_ssp_controller ssp0_plat_data = { static struct pl022_ssp_controller ssp0_plat_data = {
......
...@@ -124,17 +124,14 @@ static void __init realview_pbx_map_io(void) ...@@ -124,17 +124,14 @@ static void __init realview_pbx_map_io(void)
static struct pl061_platform_data gpio0_plat_data = { static struct pl061_platform_data gpio0_plat_data = {
.gpio_base = 0, .gpio_base = 0,
.irq_base = -1,
}; };
static struct pl061_platform_data gpio1_plat_data = { static struct pl061_platform_data gpio1_plat_data = {
.gpio_base = 8, .gpio_base = 8,
.irq_base = -1,
}; };
static struct pl061_platform_data gpio2_plat_data = { static struct pl061_platform_data gpio2_plat_data = {
.gpio_base = 16, .gpio_base = 16,
.irq_base = -1,
}; };
static struct pl022_ssp_controller ssp0_plat_data = { static struct pl022_ssp_controller ssp0_plat_data = {
......
...@@ -51,7 +51,4 @@ static inline void gpio_set_value(unsigned gpio, int value) ...@@ -51,7 +51,4 @@ static inline void gpio_set_value(unsigned gpio, int value)
#define gpio_cansleep __gpio_cansleep #define gpio_cansleep __gpio_cansleep
#define gpio_to_irq(gpio) ((gpio < 11) ? (IRQ_GPIO0 + gpio) : \
(IRQ_GPIO11 - 11 + gpio))
#endif #endif
...@@ -138,6 +138,7 @@ config GPIO_MXS ...@@ -138,6 +138,7 @@ config GPIO_MXS
config GPIO_PL061 config GPIO_PL061
bool "PrimeCell PL061 GPIO support" bool "PrimeCell PL061 GPIO support"
depends on ARM_AMBA depends on ARM_AMBA
select GENERIC_IRQ_CHIP
help help
Say yes here to support the PrimeCell PL061 GPIO device Say yes here to support the PrimeCell PL061 GPIO device
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG
obj-$(CONFIG_GPIOLIB) += gpiolib.o obj-$(CONFIG_GPIOLIB) += gpiolib.o devres.o
# Device drivers. Generally keep list sorted alphabetically # Device drivers. Generally keep list sorted alphabetically
obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o
......
/*
* drivers/gpio/devres.c - managed gpio resources
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* This file is based on kernel/irq/devres.c
*
* Copyright (c) 2011 John Crispin <blogic@openwrt.org>
*/
#include <linux/module.h>
#include <linux/gpio.h>
#include <linux/device.h>
#include <linux/gfp.h>
static void devm_gpio_release(struct device *dev, void *res)
{
unsigned *gpio = res;
gpio_free(*gpio);
}
static int devm_gpio_match(struct device *dev, void *res, void *data)
{
unsigned *this = res, *gpio = data;
return *this == *gpio;
}
/**
* devm_gpio_request - request a gpio for a managed device
* @dev: device to request the gpio for
* @gpio: gpio to allocate
* @label: the name of the requested gpio
*
* Except for the extra @dev argument, this function takes the
* same arguments and performs the same function as
* gpio_request(). GPIOs requested with this function will be
* automatically freed on driver detach.
*
* If an GPIO allocated with this function needs to be freed
* separately, devm_gpio_free() must be used.
*/
int devm_gpio_request(struct device *dev, unsigned gpio, const char *label)
{
unsigned *dr;
int rc;
dr = devres_alloc(devm_gpio_release, sizeof(unsigned), GFP_KERNEL);
if (!dr)
return -ENOMEM;
rc = gpio_request(gpio, label);
if (rc) {
devres_free(dr);
return rc;
}
*dr = gpio;
devres_add(dev, dr);
return 0;
}
EXPORT_SYMBOL(devm_gpio_request);
/**
* devm_gpio_free - free an interrupt
* @dev: device to free gpio for
* @gpio: gpio to free
*
* Except for the extra @dev argument, this function takes the
* same arguments and performs the same function as gpio_free().
* This function instead of gpio_free() should be used to manually
* free GPIOs allocated with devm_gpio_request().
*/
void devm_gpio_free(struct device *dev, unsigned int gpio)
{
WARN_ON(devres_destroy(dev, devm_gpio_release, devm_gpio_match,
&gpio));
gpio_free(gpio);
}
EXPORT_SYMBOL(devm_gpio_free);
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/list.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/irq.h> #include <linux/irq.h>
...@@ -23,6 +22,8 @@ ...@@ -23,6 +22,8 @@
#include <linux/amba/bus.h> #include <linux/amba/bus.h>
#include <linux/amba/pl061.h> #include <linux/amba/pl061.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pm.h>
#include <asm/mach/irq.h>
#define GPIODIR 0x400 #define GPIODIR 0x400
#define GPIOIS 0x404 #define GPIOIS 0x404
...@@ -35,25 +36,33 @@ ...@@ -35,25 +36,33 @@
#define PL061_GPIO_NR 8 #define PL061_GPIO_NR 8
struct pl061_gpio { #ifdef CONFIG_PM
/* We use a list of pl061_gpio structs for each trigger IRQ in the main struct pl061_context_save_regs {
* interrupts controller of the system. We need this to support systems u8 gpio_data;
* in which more that one PL061s are connected to the same IRQ. The ISR u8 gpio_dir;
* interates through this list to find the source of the interrupt. u8 gpio_is;
*/ u8 gpio_ibe;
struct list_head list; u8 gpio_iev;
u8 gpio_ie;
};
#endif
struct pl061_gpio {
/* Each of the two spinlocks protects a different set of hardware /* Each of the two spinlocks protects a different set of hardware
* regiters and data structurs. This decouples the code of the IRQ from * regiters and data structurs. This decouples the code of the IRQ from
* the GPIO code. This also makes the case of a GPIO routine call from * the GPIO code. This also makes the case of a GPIO routine call from
* the IRQ code simpler. * the IRQ code simpler.
*/ */
spinlock_t lock; /* GPIO registers */ spinlock_t lock; /* GPIO registers */
spinlock_t irq_lock; /* IRQ registers */
void __iomem *base; void __iomem *base;
unsigned irq_base; int irq_base;
struct irq_chip_generic *irq_gc;
struct gpio_chip gc; struct gpio_chip gc;
#ifdef CONFIG_PM
struct pl061_context_save_regs csave_regs;
#endif
}; };
static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
...@@ -118,46 +127,16 @@ static int pl061_to_irq(struct gpio_chip *gc, unsigned offset) ...@@ -118,46 +127,16 @@ static int pl061_to_irq(struct gpio_chip *gc, unsigned offset)
{ {
struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
if (chip->irq_base == NO_IRQ) if (chip->irq_base <= 0)
return -EINVAL; return -EINVAL;
return chip->irq_base + offset; return chip->irq_base + offset;
} }
/*
* PL061 GPIO IRQ
*/
static void pl061_irq_disable(struct irq_data *d)
{
struct pl061_gpio *chip = irq_data_get_irq_chip_data(d);
int offset = d->irq - chip->irq_base;
unsigned long flags;
u8 gpioie;
spin_lock_irqsave(&chip->irq_lock, flags);
gpioie = readb(chip->base + GPIOIE);
gpioie &= ~(1 << offset);
writeb(gpioie, chip->base + GPIOIE);
spin_unlock_irqrestore(&chip->irq_lock, flags);
}
static void pl061_irq_enable(struct irq_data *d)
{
struct pl061_gpio *chip = irq_data_get_irq_chip_data(d);
int offset = d->irq - chip->irq_base;
unsigned long flags;
u8 gpioie;
spin_lock_irqsave(&chip->irq_lock, flags);
gpioie = readb(chip->base + GPIOIE);
gpioie |= 1 << offset;
writeb(gpioie, chip->base + GPIOIE);
spin_unlock_irqrestore(&chip->irq_lock, flags);
}
static int pl061_irq_type(struct irq_data *d, unsigned trigger) static int pl061_irq_type(struct irq_data *d, unsigned trigger)
{ {
struct pl061_gpio *chip = irq_data_get_irq_chip_data(d); struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
struct pl061_gpio *chip = gc->private;
int offset = d->irq - chip->irq_base; int offset = d->irq - chip->irq_base;
unsigned long flags; unsigned long flags;
u8 gpiois, gpioibe, gpioiev; u8 gpiois, gpioibe, gpioiev;
...@@ -165,7 +144,7 @@ static int pl061_irq_type(struct irq_data *d, unsigned trigger) ...@@ -165,7 +144,7 @@ static int pl061_irq_type(struct irq_data *d, unsigned trigger)
if (offset < 0 || offset >= PL061_GPIO_NR) if (offset < 0 || offset >= PL061_GPIO_NR)
return -EINVAL; return -EINVAL;
spin_lock_irqsave(&chip->irq_lock, flags); raw_spin_lock_irqsave(&gc->lock, flags);
gpioiev = readb(chip->base + GPIOIEV); gpioiev = readb(chip->base + GPIOIEV);
...@@ -194,49 +173,54 @@ static int pl061_irq_type(struct irq_data *d, unsigned trigger) ...@@ -194,49 +173,54 @@ static int pl061_irq_type(struct irq_data *d, unsigned trigger)
writeb(gpioiev, chip->base + GPIOIEV); writeb(gpioiev, chip->base + GPIOIEV);
spin_unlock_irqrestore(&chip->irq_lock, flags); raw_spin_unlock_irqrestore(&gc->lock, flags);
return 0; return 0;
} }
static struct irq_chip pl061_irqchip = {
.name = "GPIO",
.irq_enable = pl061_irq_enable,
.irq_disable = pl061_irq_disable,
.irq_set_type = pl061_irq_type,
};
static void pl061_irq_handler(unsigned irq, struct irq_desc *desc) static void pl061_irq_handler(unsigned irq, struct irq_desc *desc)
{ {
struct list_head *chip_list = irq_get_handler_data(irq);
struct list_head *ptr;
struct pl061_gpio *chip;
desc->irq_data.chip->irq_ack(&desc->irq_data);
list_for_each(ptr, chip_list) {
unsigned long pending; unsigned long pending;
int offset; int offset;
struct pl061_gpio *chip = irq_desc_get_handler_data(desc);
struct irq_chip *irqchip = irq_desc_get_chip(desc);
chained_irq_enter(irqchip, desc);
chip = list_entry(ptr, struct pl061_gpio, list);
pending = readb(chip->base + GPIOMIS); pending = readb(chip->base + GPIOMIS);
writeb(pending, chip->base + GPIOIC); writeb(pending, chip->base + GPIOIC);
if (pending) {
if (pending == 0)
continue;
for_each_set_bit(offset, &pending, PL061_GPIO_NR) for_each_set_bit(offset, &pending, PL061_GPIO_NR)
generic_handle_irq(pl061_to_irq(&chip->gc, offset)); generic_handle_irq(pl061_to_irq(&chip->gc, offset));
} }
desc->irq_data.chip->irq_unmask(&desc->irq_data);
chained_irq_exit(irqchip, desc);
}
static void __init pl061_init_gc(struct pl061_gpio *chip, int irq_base)
{
struct irq_chip_type *ct;
chip->irq_gc = irq_alloc_generic_chip("gpio-pl061", 1, irq_base,
chip->base, handle_simple_irq);
chip->irq_gc->private = chip;
ct = chip->irq_gc->chip_types;
ct->chip.irq_mask = irq_gc_mask_clr_bit;
ct->chip.irq_unmask = irq_gc_mask_set_bit;
ct->chip.irq_set_type = pl061_irq_type;
ct->chip.irq_set_wake = irq_gc_set_wake;
ct->regs.mask = GPIOIE;
irq_setup_generic_chip(chip->irq_gc, IRQ_MSK(PL061_GPIO_NR),
IRQ_GC_INIT_NESTED_LOCK, IRQ_NOREQUEST, 0);
} }
static int pl061_probe(struct amba_device *dev, const struct amba_id *id) static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
{ {
struct pl061_platform_data *pdata; struct pl061_platform_data *pdata;
struct pl061_gpio *chip; struct pl061_gpio *chip;
struct list_head *chip_list;
int ret, irq, i; int ret, irq, i;
static DECLARE_BITMAP(init_irq, NR_IRQS);
chip = kzalloc(sizeof(*chip), GFP_KERNEL); chip = kzalloc(sizeof(*chip), GFP_KERNEL);
if (chip == NULL) if (chip == NULL)
...@@ -248,7 +232,7 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id) ...@@ -248,7 +232,7 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
chip->irq_base = pdata->irq_base; chip->irq_base = pdata->irq_base;
} else if (dev->dev.of_node) { } else if (dev->dev.of_node) {
chip->gc.base = -1; chip->gc.base = -1;
chip->irq_base = NO_IRQ; chip->irq_base = 0;
} else { } else {
ret = -ENODEV; ret = -ENODEV;
goto free_mem; goto free_mem;
...@@ -267,8 +251,6 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id) ...@@ -267,8 +251,6 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
} }
spin_lock_init(&chip->lock); spin_lock_init(&chip->lock);
spin_lock_init(&chip->irq_lock);
INIT_LIST_HEAD(&chip->list);
chip->gc.direction_input = pl061_direction_input; chip->gc.direction_input = pl061_direction_input;
chip->gc.direction_output = pl061_direction_output; chip->gc.direction_output = pl061_direction_output;
...@@ -288,9 +270,11 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id) ...@@ -288,9 +270,11 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
* irq_chip support * irq_chip support
*/ */
if (chip->irq_base == NO_IRQ) if (chip->irq_base <= 0)
return 0; return 0;
pl061_init_gc(chip, chip->irq_base);
writeb(0, chip->base + GPIOIE); /* disable irqs */ writeb(0, chip->base + GPIOIE); /* disable irqs */
irq = dev->irq[0]; irq = dev->irq[0];
if (irq < 0) { if (irq < 0) {
...@@ -298,18 +282,7 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id) ...@@ -298,18 +282,7 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
goto iounmap; goto iounmap;
} }
irq_set_chained_handler(irq, pl061_irq_handler); irq_set_chained_handler(irq, pl061_irq_handler);
if (!test_and_set_bit(irq, init_irq)) { /* list initialized? */ irq_set_handler_data(irq, chip);
chip_list = kmalloc(sizeof(*chip_list), GFP_KERNEL);
if (chip_list == NULL) {
clear_bit(irq, init_irq);
ret = -ENOMEM;
goto iounmap;
}
INIT_LIST_HEAD(chip_list);
irq_set_handler_data(irq, chip_list);
} else
chip_list = irq_get_handler_data(irq);
list_add(&chip->list, chip_list);
for (i = 0; i < PL061_GPIO_NR; i++) { for (i = 0; i < PL061_GPIO_NR; i++) {
if (pdata) { if (pdata) {
...@@ -319,13 +292,10 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id) ...@@ -319,13 +292,10 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
else else
pl061_direction_input(&chip->gc, i); pl061_direction_input(&chip->gc, i);
} }
irq_set_chip_and_handler(i + chip->irq_base, &pl061_irqchip,
handle_simple_irq);
set_irq_flags(i+chip->irq_base, IRQF_VALID);
irq_set_chip_data(i + chip->irq_base, chip);
} }
amba_set_drvdata(dev, chip);
return 0; return 0;
iounmap: iounmap:
...@@ -338,6 +308,53 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id) ...@@ -338,6 +308,53 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
return ret; return ret;
} }
#ifdef CONFIG_PM
static int pl061_suspend(struct device *dev)
{
struct pl061_gpio *chip = dev_get_drvdata(dev);
int offset;
chip->csave_regs.gpio_data = 0;
chip->csave_regs.gpio_dir = readb(chip->base + GPIODIR);
chip->csave_regs.gpio_is = readb(chip->base + GPIOIS);
chip->csave_regs.gpio_ibe = readb(chip->base + GPIOIBE);
chip->csave_regs.gpio_iev = readb(chip->base + GPIOIEV);
chip->csave_regs.gpio_ie = readb(chip->base + GPIOIE);
for (offset = 0; offset < PL061_GPIO_NR; offset++) {
if (chip->csave_regs.gpio_dir & (1 << offset))
chip->csave_regs.gpio_data |=
pl061_get_value(&chip->gc, offset) << offset;
}
return 0;
}
static int pl061_resume(struct device *dev)
{
struct pl061_gpio *chip = dev_get_drvdata(dev);
int offset;
for (offset = 0; offset < PL061_GPIO_NR; offset++) {
if (chip->csave_regs.gpio_dir & (1 << offset))
pl061_direction_output(&chip->gc, offset,
chip->csave_regs.gpio_data &
(1 << offset));
else
pl061_direction_input(&chip->gc, offset);
}
writeb(chip->csave_regs.gpio_is, chip->base + GPIOIS);
writeb(chip->csave_regs.gpio_ibe, chip->base + GPIOIBE);
writeb(chip->csave_regs.gpio_iev, chip->base + GPIOIEV);
writeb(chip->csave_regs.gpio_ie, chip->base + GPIOIE);
return 0;
}
static SIMPLE_DEV_PM_OPS(pl061_dev_pm_ops, pl061_suspend, pl061_resume);
#endif
static struct amba_id pl061_ids[] = { static struct amba_id pl061_ids[] = {
{ {
.id = 0x00041061, .id = 0x00041061,
...@@ -351,6 +368,9 @@ MODULE_DEVICE_TABLE(amba, pl061_ids); ...@@ -351,6 +368,9 @@ MODULE_DEVICE_TABLE(amba, pl061_ids);
static struct amba_driver pl061_gpio_driver = { static struct amba_driver pl061_gpio_driver = {
.drv = { .drv = {
.name = "pl061_gpio", .name = "pl061_gpio",
#ifdef CONFIG_PM
.pm = &pl061_dev_pm_ops,
#endif
}, },
.id_table = pl061_ids, .id_table = pl061_ids,
.probe = pl061_probe, .probe = pl061_probe,
......
...@@ -47,12 +47,18 @@ static int sa1100_direction_output(struct gpio_chip *chip, unsigned offset, int ...@@ -47,12 +47,18 @@ static int sa1100_direction_output(struct gpio_chip *chip, unsigned offset, int
return 0; return 0;
} }
static int sa1100_to_irq(struct gpio_chip *chip, unsigned offset)
{
return offset < 11 ? (IRQ_GPIO0 + offset) : (IRQ_GPIO11 - 11 + offset);
}
static struct gpio_chip sa1100_gpio_chip = { static struct gpio_chip sa1100_gpio_chip = {
.label = "gpio", .label = "gpio",
.direction_input = sa1100_direction_input, .direction_input = sa1100_direction_input,
.direction_output = sa1100_direction_output, .direction_output = sa1100_direction_output,
.set = sa1100_gpio_set, .set = sa1100_gpio_set,
.get = sa1100_gpio_get, .get = sa1100_gpio_get,
.to_irq = sa1100_to_irq,
.base = 0, .base = 0,
.ngpio = GPIO_MAX + 1, .ngpio = GPIO_MAX + 1,
}; };
......
...@@ -361,14 +361,7 @@ static int __devinit tegra_gpio_probe(struct platform_device *pdev) ...@@ -361,14 +361,7 @@ static int __devinit tegra_gpio_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
if (!devm_request_mem_region(&pdev->dev, res->start, regs = devm_request_and_ioremap(&pdev->dev, res);
resource_size(res),
dev_name(&pdev->dev))) {
dev_err(&pdev->dev, "Couldn't request MEM resource\n");
return -ENODEV;
}
regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
if (!regs) { if (!regs) {
dev_err(&pdev->dev, "Couldn't ioremap regs\n"); dev_err(&pdev->dev, "Couldn't ioremap regs\n");
return -ENODEV; return -ENODEV;
......
...@@ -177,6 +177,10 @@ extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *labe ...@@ -177,6 +177,10 @@ extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *labe
extern int gpio_request_array(const struct gpio *array, size_t num); extern int gpio_request_array(const struct gpio *array, size_t num);
extern void gpio_free_array(const struct gpio *array, size_t num); extern void gpio_free_array(const struct gpio *array, size_t num);
/* bindings for managed devices that want to request gpios */
int devm_gpio_request(struct device *dev, unsigned gpio, const char *label);
void devm_gpio_free(struct device *dev, unsigned int gpio);
#ifdef CONFIG_GPIO_SYSFS #ifdef CONFIG_GPIO_SYSFS
/* /*
......
...@@ -7,7 +7,7 @@ struct pl061_platform_data { ...@@ -7,7 +7,7 @@ struct pl061_platform_data {
unsigned gpio_base; unsigned gpio_base;
/* number of the first IRQ. /* number of the first IRQ.
* If the IRQ functionality in not desired this must be set to NO_IRQ. * If the IRQ functionality in not desired this must be set to 0.
*/ */
unsigned irq_base; unsigned irq_base;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment