1 /* linux/arch/arm/plat-s3c24xx/gpiolib.c
3 * Copyright (c) 2008 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
7 * S3C24XX GPIOlib support
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License.
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/interrupt.h>
18 #include <linux/ioport.h>
20 #include <linux/gpio.h>
22 #include <plat/gpio-core.h>
23 #include <mach/hardware.h>
26 #include <mach/regs-gpio.h>
28 static int s3c24xx_gpiolib_banka_input(struct gpio_chip *chip, unsigned offset)
33 static int s3c24xx_gpiolib_banka_output(struct gpio_chip *chip,
34 unsigned offset, int value)
36 struct s3c_gpio_chip *ourchip = to_s3c_gpio(chip);
37 void __iomem *base = ourchip->base;
42 local_irq_save(flags);
44 con = __raw_readl(base + 0x00);
45 dat = __raw_readl(base + 0x04);
47 dat &= ~(1 << offset);
51 __raw_writel(dat, base + 0x04);
53 con &= ~(1 << offset);
55 __raw_writel(con, base + 0x00);
56 __raw_writel(dat, base + 0x04);
58 local_irq_restore(flags);
62 struct s3c_gpio_chip s3c24xx_gpios[] = {
64 .base = S3C24XX_GPIO_BASE(S3C2410_GPA0),
70 .direction_input = s3c24xx_gpiolib_banka_input,
71 .direction_output = s3c24xx_gpiolib_banka_output,
75 .base = S3C24XX_GPIO_BASE(S3C2410_GPB0),
84 .base = S3C24XX_GPIO_BASE(S3C2410_GPC0),
93 .base = S3C24XX_GPIO_BASE(S3C2410_GPD0),
102 .base = S3C24XX_GPIO_BASE(S3C2410_GPE0),
104 .base = S3C2410_GPE0,
106 .owner = THIS_MODULE,
111 .base = S3C24XX_GPIO_BASE(S3C2410_GPF0),
113 .base = S3C2410_GPF0,
114 .owner = THIS_MODULE,
120 .base = S3C24XX_GPIO_BASE(S3C2410_GPG0),
122 .base = S3C2410_GPG0,
123 .owner = THIS_MODULE,
130 static __init int s3c24xx_gpiolib_init(void)
132 struct s3c_gpio_chip *chip = s3c24xx_gpios;
135 for (gpn = 0; gpn < ARRAY_SIZE(s3c24xx_gpios); gpn++, chip++)
136 s3c_gpiolib_add(chip);
141 arch_initcall(s3c24xx_gpiolib_init);