Skip to content

Commit

Permalink
ARM: S5PC1xx: add gpiolib and external/gpio interrupt support
Browse files Browse the repository at this point in the history
Add support for gpiolib calls. This is based on the gpiolib implementation
from plat-s3c64xx tree.
Add support for external interrupts for GPIO H banks.
Add support for GPIO interrupts for all banks.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
  • Loading branch information
Kyungmin Park authored and Ben Dooks committed Dec 1, 2009
1 parent d7b9ace commit b0d5217
Show file tree
Hide file tree
Showing 13 changed files with 1,288 additions and 5 deletions.
6 changes: 6 additions & 0 deletions arch/arm/plat-s3c/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ config S3C_GPIO_CFG_S3C64XX
Internal configuration to enable S3C64XX style GPIO configuration
functions.

config S5P_GPIO_CFG_S5PC1XX
bool
help
Internal configuration to enable S5PC1XX style GPIO configuration
functions.

# DMA

config S3C_DMA
Expand Down
3 changes: 3 additions & 0 deletions arch/arm/plat-s5pc1xx/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ config PLAT_S5PC1XX
select ARCH_REQUIRE_GPIOLIB
select S3C_GPIO_TRACK
select S3C_GPIO_PULL_UPDOWN
select S3C_GPIO_CFG_S3C24XX
select S3C_GPIO_CFG_S3C64XX
select S5P_GPIO_CFG_S5PC1XX
help
Base platform code for any Samsung S5PC1XX device

Expand Down
4 changes: 3 additions & 1 deletion arch/arm/plat-s5pc1xx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ obj- :=

obj-y += dev-uart.o
obj-y += cpu.o
obj-y += irq.o
obj-y += irq.o irq-gpio.o irq-eint.o
obj-y += clock.o
obj-y += gpiolib.o

# CPU support

Expand All @@ -23,5 +24,6 @@ obj-$(CONFIG_CPU_S5PC100_CLOCK) += s5pc100-clock.o

# Device setup

obj-$(CONFIG_S5P_GPIO_CFG_S5PC1XX) += gpio-config.o
obj-$(CONFIG_S5PC100_SETUP_I2C0) += setup-i2c0.o
obj-$(CONFIG_S5PC100_SETUP_I2C1) += setup-i2c1.o
5 changes: 5 additions & 0 deletions arch/arm/plat-s5pc1xx/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ static struct map_desc s5pc1xx_iodesc[] __initdata = {
.pfn = __phys_to_pfn(S5PC1XX_PA_CLK_OTHER),
.length = SZ_4K,
.type = MT_DEVICE,
}, {
.virtual = (unsigned long)S5PC1XX_VA_GPIO,
.pfn = __phys_to_pfn(S5PC100_PA_GPIO),
.length = SZ_4K,
.type = MT_DEVICE,
}, {
.virtual = (unsigned long)S5PC1XX_VA_CHIPID,
.pfn = __phys_to_pfn(S5PC1XX_PA_CHIPID),
Expand Down
62 changes: 62 additions & 0 deletions arch/arm/plat-s5pc1xx/gpio-config.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* linux/arch/arm/plat-s5pc1xx/gpio-config.c
*
* Copyright 2009 Samsung Electronics
*
* S5PC1XX GPIO Configuration.
*
* Based on plat-s3c64xx/gpio-config.c
*
* 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.
*/

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/gpio.h>
#include <linux/io.h>

#include <mach/gpio-core.h>
#include <plat/gpio-cfg-s5pc1xx.h>

s5p_gpio_drvstr_t s5p_gpio_get_drvstr(unsigned int pin, unsigned int off)
{
struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin);
void __iomem *reg;
int shift = off * 2;
u32 drvstr;

if (!chip)
return -EINVAL;

reg = chip->base + 0x0C;

drvstr = __raw_readl(reg);
drvstr = 0xffff & (0x3 << shift);
drvstr = drvstr >> shift;

return (__force s5p_gpio_drvstr_t)drvstr;
}
EXPORT_SYMBOL(s5p_gpio_get_drvstr);

int s5p_gpio_set_drvstr(unsigned int pin, unsigned int off,
s5p_gpio_drvstr_t drvstr)
{
struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin);
void __iomem *reg;
int shift = off * 2;
u32 tmp;

if (!chip)
return -EINVAL;

reg = chip->base + 0x0C;

tmp = __raw_readl(reg);
tmp |= drvstr << shift;

__raw_writel(tmp, reg);

return 0;
}
EXPORT_SYMBOL(s5p_gpio_set_drvstr);
Loading

0 comments on commit b0d5217

Please sign in to comment.