aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-langwell.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-10-29 07:27:45 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2011-10-29 07:27:45 -0700
commit41684f67af75b04152a1714e1a5375dfb00ee3da (patch)
tree3b0f51dd8103a4fd40ebb6cefeece7579e348cde /drivers/gpio/gpio-langwell.c
parentMerge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6 (diff)
parenth8300: Move gpio.h to gpio-internal.h (diff)
downloadlinux-dev-41684f67af75b04152a1714e1a5375dfb00ee3da.tar.xz
linux-dev-41684f67af75b04152a1714e1a5375dfb00ee3da.zip
Merge branch 'gpio/next' of git://git.secretlab.ca/git/linux-2.6
* 'gpio/next' of git://git.secretlab.ca/git/linux-2.6: h8300: Move gpio.h to gpio-internal.h gpio: pl061: add DT binding support gpio: fix build error in include/asm-generic/gpio.h gpiolib: Ensure struct gpio is always defined irq: Add EXPORT_SYMBOL_GPL to function of irq generic-chip gpio-ml-ioh: Use NUMA_NO_NODE not GFP_KERNEL gpio-pch: Use NUMA_NO_NODE not GFP_KERNEL gpio: langwell: ensure alternate function is cleared gpio-pch: Support interrupt function gpio-pch: Save register value in suspend() gpio-pch: modify gpio_nums and mask gpio-pch: support ML7223 IOH n-Bus gpio-pch: add spinlock in suspend/resume processing gpio-pch: Delete invalid "restore" code in suspend() gpio-ml-ioh: Fix suspend/resume issue gpio-ml-ioh: Support interrupt function gpio-ml-ioh: Delete unnecessary code gpio/mxc: add chained_irq_enter/exit() to mx3_gpio_irq_handler() gpio/nomadik: use genirq core to track enablement gpio/nomadik: disable clocks when unused
Diffstat (limited to 'drivers/gpio/gpio-langwell.c')
-rw-r--r--drivers/gpio/gpio-langwell.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-langwell.c b/drivers/gpio/gpio-langwell.c
index d2eb57c60e0e..00692e89ef87 100644
--- a/drivers/gpio/gpio-langwell.c
+++ b/drivers/gpio/gpio-langwell.c
@@ -59,6 +59,7 @@ enum GPIO_REG {
GRER, /* rising edge detect */
GFER, /* falling edge detect */
GEDR, /* edge detect result */
+ GAFR, /* alt function */
};
struct lnw_gpio {
@@ -81,6 +82,31 @@ static void __iomem *gpio_reg(struct gpio_chip *chip, unsigned offset,
return ptr;
}
+static void __iomem *gpio_reg_2bit(struct gpio_chip *chip, unsigned offset,
+ enum GPIO_REG reg_type)
+{
+ struct lnw_gpio *lnw = container_of(chip, struct lnw_gpio, chip);
+ unsigned nreg = chip->ngpio / 32;
+ u8 reg = offset / 16;
+ void __iomem *ptr;
+
+ ptr = (void __iomem *)(lnw->reg_base + reg_type * nreg * 4 + reg * 4);
+ return ptr;
+}
+
+static int lnw_gpio_request(struct gpio_chip *chip, unsigned offset)
+{
+ void __iomem *gafr = gpio_reg_2bit(chip, offset, GAFR);
+ u32 value = readl(gafr);
+ int shift = (offset % 16) << 1, af = (value >> shift) & 3;
+
+ if (af) {
+ value &= ~(3 << shift);
+ writel(value, gafr);
+ }
+ return 0;
+}
+
static int lnw_gpio_get(struct gpio_chip *chip, unsigned offset)
{
void __iomem *gplr = gpio_reg(chip, offset, GPLR);
@@ -321,6 +347,7 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
lnw->reg_base = base;
lnw->irq_base = irq_base;
lnw->chip.label = dev_name(&pdev->dev);
+ lnw->chip.request = lnw_gpio_request;
lnw->chip.direction_input = lnw_gpio_direction_input;
lnw->chip.direction_output = lnw_gpio_direction_output;
lnw->chip.get = lnw_gpio_get;