X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=arch%2Farm%2Fplat-s3c24xx%2Fgpiolib.c;h=f95c6c9d9f1a95ad93d64bc17ca8f7f9b894b59f;hb=ab70537c32a3245325b48774664da588904e47f2;hp=825d8d0c5ca20f5730c4d9ae42202ddc483d6465;hpb=9b610fda0df5d0f0b0c64242e37441ad1b384aac;p=linux-2.6-omap-h63xx.git diff --git a/arch/arm/plat-s3c24xx/gpiolib.c b/arch/arm/plat-s3c24xx/gpiolib.c index 825d8d0c5ca..f95c6c9d9f1 100644 --- a/arch/arm/plat-s3c24xx/gpiolib.c +++ b/arch/arm/plat-s3c24xx/gpiolib.c @@ -19,102 +19,11 @@ #include #include -#include +#include +#include #include -#include - -struct s3c24xx_gpio_chip { - struct gpio_chip chip; - void __iomem *base; -}; - -static inline struct s3c24xx_gpio_chip *to_s3c_chip(struct gpio_chip *gpc) -{ - return container_of(gpc, struct s3c24xx_gpio_chip, chip); -} - -/* these routines are exported for use by other parts of the platform - * and system support, but are not intended to be used directly by the - * drivers themsevles. - */ - -int s3c24xx_gpiolib_input(struct gpio_chip *chip, unsigned offset) -{ - struct s3c24xx_gpio_chip *ourchip = to_s3c_chip(chip); - void __iomem *base = ourchip->base; - unsigned long flags; - unsigned long con; - - local_irq_save(flags); - - con = __raw_readl(base + 0x00); - con &= ~(3 << (offset * 2)); - con |= (S3C2410_GPIO_OUTPUT & 0xf) << (offset * 2); - - __raw_writel(con, base + 0x00); - - local_irq_restore(flags); - return 0; -} - -int s3c24xx_gpiolib_output(struct gpio_chip *chip, - unsigned offset, int value) -{ - struct s3c24xx_gpio_chip *ourchip = to_s3c_chip(chip); - void __iomem *base = ourchip->base; - unsigned long flags; - unsigned long dat; - unsigned long con; - - local_irq_save(flags); - - dat = __raw_readl(base + 0x04); - dat &= ~(1 << offset); - if (value) - dat |= 1 << offset; - __raw_writel(dat, base + 0x04); - - con = __raw_readl(base + 0x00); - con &= ~(3 << (offset * 2)); - con |= (S3C2410_GPIO_OUTPUT & 0xf) << (offset * 2); - - __raw_writel(con, base + 0x00); - __raw_writel(dat, base + 0x04); - - local_irq_restore(flags); - return 0; -} - -void s3c24xx_gpiolib_set(struct gpio_chip *chip, unsigned offset, int value) -{ - struct s3c24xx_gpio_chip *ourchip = to_s3c_chip(chip); - void __iomem *base = ourchip->base; - unsigned long flags; - unsigned long dat; - - local_irq_save(flags); - - dat = __raw_readl(base + 0x04); - dat &= ~(1 << offset); - if (value) - dat |= 1 << offset; - __raw_writel(dat, base + 0x04); - - local_irq_restore(flags); -} - -int s3c24xx_gpiolib_get(struct gpio_chip *chip, unsigned offset) -{ - struct s3c24xx_gpio_chip *ourchip = to_s3c_chip(chip); - unsigned long val; - - val = __raw_readl(ourchip->base + 0x04); - val >>= offset; - val &= 1; - - return val; -} +#include static int s3c24xx_gpiolib_banka_input(struct gpio_chip *chip, unsigned offset) { @@ -124,7 +33,7 @@ static int s3c24xx_gpiolib_banka_input(struct gpio_chip *chip, unsigned offset) static int s3c24xx_gpiolib_banka_output(struct gpio_chip *chip, unsigned offset, int value) { - struct s3c24xx_gpio_chip *ourchip = to_s3c_chip(chip); + struct s3c_gpio_chip *ourchip = to_s3c_gpio(chip); void __iomem *base = ourchip->base; unsigned long flags; unsigned long dat; @@ -150,8 +59,7 @@ static int s3c24xx_gpiolib_banka_output(struct gpio_chip *chip, return 0; } - -struct s3c24xx_gpio_chip gpios[] = { +struct s3c_gpio_chip s3c24xx_gpios[] = { [0] = { .base = S3C24XX_GPIO_BASE(S3C2410_GPA0), .chip = { @@ -161,8 +69,6 @@ struct s3c24xx_gpio_chip gpios[] = { .ngpio = 24, .direction_input = s3c24xx_gpiolib_banka_input, .direction_output = s3c24xx_gpiolib_banka_output, - .set = s3c24xx_gpiolib_set, - .get = s3c24xx_gpiolib_get, }, }, [1] = { @@ -172,10 +78,6 @@ struct s3c24xx_gpio_chip gpios[] = { .owner = THIS_MODULE, .label = "GPIOB", .ngpio = 16, - .direction_input = s3c24xx_gpiolib_input, - .direction_output = s3c24xx_gpiolib_output, - .set = s3c24xx_gpiolib_set, - .get = s3c24xx_gpiolib_get, }, }, [2] = { @@ -185,10 +87,6 @@ struct s3c24xx_gpio_chip gpios[] = { .owner = THIS_MODULE, .label = "GPIOC", .ngpio = 16, - .direction_input = s3c24xx_gpiolib_input, - .direction_output = s3c24xx_gpiolib_output, - .set = s3c24xx_gpiolib_set, - .get = s3c24xx_gpiolib_get, }, }, [3] = { @@ -198,10 +96,6 @@ struct s3c24xx_gpio_chip gpios[] = { .owner = THIS_MODULE, .label = "GPIOD", .ngpio = 16, - .direction_input = s3c24xx_gpiolib_input, - .direction_output = s3c24xx_gpiolib_output, - .set = s3c24xx_gpiolib_set, - .get = s3c24xx_gpiolib_get, }, }, [4] = { @@ -211,10 +105,6 @@ struct s3c24xx_gpio_chip gpios[] = { .label = "GPIOE", .owner = THIS_MODULE, .ngpio = 16, - .direction_input = s3c24xx_gpiolib_input, - .direction_output = s3c24xx_gpiolib_output, - .set = s3c24xx_gpiolib_set, - .get = s3c24xx_gpiolib_get, }, }, [5] = { @@ -224,10 +114,6 @@ struct s3c24xx_gpio_chip gpios[] = { .owner = THIS_MODULE, .label = "GPIOF", .ngpio = 8, - .direction_input = s3c24xx_gpiolib_input, - .direction_output = s3c24xx_gpiolib_output, - .set = s3c24xx_gpiolib_set, - .get = s3c24xx_gpiolib_get, }, }, [6] = { @@ -237,21 +123,17 @@ struct s3c24xx_gpio_chip gpios[] = { .owner = THIS_MODULE, .label = "GPIOG", .ngpio = 10, - .direction_input = s3c24xx_gpiolib_input, - .direction_output = s3c24xx_gpiolib_output, - .set = s3c24xx_gpiolib_set, - .get = s3c24xx_gpiolib_get, }, }, }; static __init int s3c24xx_gpiolib_init(void) { - struct s3c24xx_gpio_chip *chip = gpios; + struct s3c_gpio_chip *chip = s3c24xx_gpios; int gpn; - for (gpn = 0; gpn < ARRAY_SIZE(gpios); gpn++, chip++) - gpiochip_add(&chip->chip); + for (gpn = 0; gpn < ARRAY_SIZE(s3c24xx_gpios); gpn++, chip++) + s3c_gpiolib_add(chip); return 0; }