diff options
author | codeworkx <daniel.hillenbrand@codeworkx.de> | 2012-06-02 13:09:29 +0200 |
---|---|---|
committer | codeworkx <daniel.hillenbrand@codeworkx.de> | 2012-06-02 13:09:29 +0200 |
commit | c6da2cfeb05178a11c6d062a06f8078150ee492f (patch) | |
tree | f3b4021d252c52d6463a9b3c1bb7245e399b009c /drivers/gpio/gpio-exynos4.c | |
parent | c6d7c4dbff353eac7919342ae6b3299a378160a6 (diff) | |
download | kernel_samsung_smdk4412-c6da2cfeb05178a11c6d062a06f8078150ee492f.zip kernel_samsung_smdk4412-c6da2cfeb05178a11c6d062a06f8078150ee492f.tar.gz kernel_samsung_smdk4412-c6da2cfeb05178a11c6d062a06f8078150ee492f.tar.bz2 |
samsung update 1
Diffstat (limited to 'drivers/gpio/gpio-exynos4.c')
-rw-r--r-- | drivers/gpio/gpio-exynos4.c | 467 |
1 files changed, 378 insertions, 89 deletions
diff --git a/drivers/gpio/gpio-exynos4.c b/drivers/gpio/gpio-exynos4.c index 9029835..01b827b 100644 --- a/drivers/gpio/gpio-exynos4.c +++ b/drivers/gpio/gpio-exynos4.c @@ -1,4 +1,4 @@ -/* linux/arch/arm/mach-exynos4/gpiolib.c +/* linux/drivers/gpio/gpio-exynos4.c * * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. * http://www.samsung.com @@ -20,6 +20,7 @@ #include <plat/gpio-core.h> #include <plat/gpio-cfg.h> #include <plat/gpio-cfg-helpers.h> +#include <plat/cpu.h> int s3c_gpio_setpull_exynos4(struct s3c_gpio_chip *chip, unsigned int off, s3c_gpio_pull_t pull) @@ -55,7 +56,7 @@ static struct s3c_gpio_cfg gpio_cfg_noint = { }; /* - * Following are the gpio banks in v310. + * Following are the gpio banks in exynos4. * * The 'config' member when left to NULL, is initialized to the default * structure gpio_cfg in the init function below. @@ -64,162 +65,176 @@ static struct s3c_gpio_cfg gpio_cfg_noint = { * Note: The initialization of 'base' member of s3c_gpio_chip structure * uses the above macro and depends on the banks being listed in order here. */ -static struct s3c_gpio_chip exynos4_gpio_part1_4bit[] = { +static struct s3c_gpio_pm s3c_gpio_pm_nop = { NULL, NULL }; + +static struct s3c_gpio_chip exynos4_gpio_common_4bit[] = { { + .base = S5P_VA_GPIO1, + .eint_offset = 0x0, + .group = 0, .chip = { .base = EXYNOS4_GPA0(0), .ngpio = EXYNOS4_GPIO_A0_NR, .label = "GPA0", }, }, { + .base = (S5P_VA_GPIO1 + 0x20), + .eint_offset = 0x4, + .group = 1, .chip = { .base = EXYNOS4_GPA1(0), .ngpio = EXYNOS4_GPIO_A1_NR, .label = "GPA1", }, }, { + .base = (S5P_VA_GPIO1 + 0x40), + .eint_offset = 0x8, + .group = 2, .chip = { .base = EXYNOS4_GPB(0), .ngpio = EXYNOS4_GPIO_B_NR, .label = "GPB", }, }, { + .base = (S5P_VA_GPIO1 + 0x60), + .eint_offset = 0xC, + .group = 3, .chip = { .base = EXYNOS4_GPC0(0), .ngpio = EXYNOS4_GPIO_C0_NR, .label = "GPC0", }, }, { + .base = (S5P_VA_GPIO1 + 0x80), + .eint_offset = 0x10, + .group = 4, .chip = { .base = EXYNOS4_GPC1(0), .ngpio = EXYNOS4_GPIO_C1_NR, .label = "GPC1", }, }, { + .base = (S5P_VA_GPIO1 + 0xA0), + .eint_offset = 0x14, + .group = 5, .chip = { .base = EXYNOS4_GPD0(0), .ngpio = EXYNOS4_GPIO_D0_NR, .label = "GPD0", }, }, { + .base = (S5P_VA_GPIO1 + 0xC0), + .eint_offset = 0x18, + .group = 6, .chip = { .base = EXYNOS4_GPD1(0), .ngpio = EXYNOS4_GPIO_D1_NR, .label = "GPD1", }, }, { - .chip = { - .base = EXYNOS4_GPE0(0), - .ngpio = EXYNOS4_GPIO_E0_NR, - .label = "GPE0", - }, - }, { - .chip = { - .base = EXYNOS4_GPE1(0), - .ngpio = EXYNOS4_GPIO_E1_NR, - .label = "GPE1", - }, - }, { - .chip = { - .base = EXYNOS4_GPE2(0), - .ngpio = EXYNOS4_GPIO_E2_NR, - .label = "GPE2", - }, - }, { - .chip = { - .base = EXYNOS4_GPE3(0), - .ngpio = EXYNOS4_GPIO_E3_NR, - .label = "GPE3", - }, - }, { - .chip = { - .base = EXYNOS4_GPE4(0), - .ngpio = EXYNOS4_GPIO_E4_NR, - .label = "GPE4", - }, - }, { + .base = (S5P_VA_GPIO1 + 0x180), + .eint_offset = 0x30, + .group = 7, .chip = { .base = EXYNOS4_GPF0(0), .ngpio = EXYNOS4_GPIO_F0_NR, .label = "GPF0", }, }, { + .base = (S5P_VA_GPIO1 + 0x1A0), + .eint_offset = 0x34, + .group = 8, .chip = { .base = EXYNOS4_GPF1(0), .ngpio = EXYNOS4_GPIO_F1_NR, .label = "GPF1", }, }, { + .base = (S5P_VA_GPIO1 + 0x1C0), + .eint_offset = 0x38, + .group = 9, .chip = { .base = EXYNOS4_GPF2(0), .ngpio = EXYNOS4_GPIO_F2_NR, .label = "GPF2", }, }, { + .base = (S5P_VA_GPIO1 + 0x1E0), + .eint_offset = 0x3C, + .group = 10, .chip = { .base = EXYNOS4_GPF3(0), .ngpio = EXYNOS4_GPIO_F3_NR, .label = "GPF3", }, - }, -}; - -static struct s3c_gpio_chip exynos4_gpio_part2_4bit[] = { - { - .chip = { - .base = EXYNOS4_GPJ0(0), - .ngpio = EXYNOS4_GPIO_J0_NR, - .label = "GPJ0", - }, - }, { - .chip = { - .base = EXYNOS4_GPJ1(0), - .ngpio = EXYNOS4_GPIO_J1_NR, - .label = "GPJ1", - }, }, { + .base = (S5P_VA_GPIO2 + 0x40), + .eint_offset = 0x8, + .group = 16, .chip = { .base = EXYNOS4_GPK0(0), .ngpio = EXYNOS4_GPIO_K0_NR, .label = "GPK0", }, +#ifdef CONFIG_MACH_MIDAS + .pm = &s3c_gpio_pm_nop, +#endif }, { + .base = (S5P_VA_GPIO2 + 0x60), + .eint_offset = 0xC, + .group = 17, .chip = { .base = EXYNOS4_GPK1(0), .ngpio = EXYNOS4_GPIO_K1_NR, .label = "GPK1", }, }, { + .base = (S5P_VA_GPIO2 + 0x80), + .eint_offset = 0x10, + .group = 18, .chip = { .base = EXYNOS4_GPK2(0), .ngpio = EXYNOS4_GPIO_K2_NR, .label = "GPK2", }, }, { + .base = (S5P_VA_GPIO2 + 0xA0), + .eint_offset = 0x14, + .group = 19, .chip = { .base = EXYNOS4_GPK3(0), .ngpio = EXYNOS4_GPIO_K3_NR, .label = "GPK3", }, }, { + .base = (S5P_VA_GPIO2 + 0xC0), + .eint_offset = 0x18, + .group = 20, .chip = { .base = EXYNOS4_GPL0(0), .ngpio = EXYNOS4_GPIO_L0_NR, .label = "GPL0", }, }, { + .base = (S5P_VA_GPIO2 + 0xE0), + .eint_offset = 0x1C, + .group = 21, .chip = { .base = EXYNOS4_GPL1(0), .ngpio = EXYNOS4_GPIO_L1_NR, .label = "GPL1", }, }, { + .base = (S5P_VA_GPIO2 + 0x100), + .eint_offset = 0x20, + .group = 22, .chip = { .base = EXYNOS4_GPL2(0), .ngpio = EXYNOS4_GPIO_L2_NR, .label = "GPL2", }, }, { + .base = (S5P_VA_GPIO2 + 0x120), .config = &gpio_cfg_noint, .chip = { .base = EXYNOS4_GPY0(0), @@ -227,6 +242,7 @@ static struct s3c_gpio_chip exynos4_gpio_part2_4bit[] = { .label = "GPY0", }, }, { + .base = (S5P_VA_GPIO2 + 0x140), .config = &gpio_cfg_noint, .chip = { .base = EXYNOS4_GPY1(0), @@ -234,6 +250,7 @@ static struct s3c_gpio_chip exynos4_gpio_part2_4bit[] = { .label = "GPY1", }, }, { + .base = (S5P_VA_GPIO2 + 0x160), .config = &gpio_cfg_noint, .chip = { .base = EXYNOS4_GPY2(0), @@ -241,6 +258,7 @@ static struct s3c_gpio_chip exynos4_gpio_part2_4bit[] = { .label = "GPY2", }, }, { + .base = (S5P_VA_GPIO2 + 0x180), .config = &gpio_cfg_noint, .chip = { .base = EXYNOS4_GPY3(0), @@ -248,6 +266,7 @@ static struct s3c_gpio_chip exynos4_gpio_part2_4bit[] = { .label = "GPY3", }, }, { + .base = (S5P_VA_GPIO2 + 0x1A0), .config = &gpio_cfg_noint, .chip = { .base = EXYNOS4_GPY4(0), @@ -255,6 +274,7 @@ static struct s3c_gpio_chip exynos4_gpio_part2_4bit[] = { .label = "GPY4", }, }, { + .base = (S5P_VA_GPIO2 + 0x1C0), .config = &gpio_cfg_noint, .chip = { .base = EXYNOS4_GPY5(0), @@ -262,6 +282,7 @@ static struct s3c_gpio_chip exynos4_gpio_part2_4bit[] = { .label = "GPY5", }, }, { + .base = (S5P_VA_GPIO2 + 0x1E0), .config = &gpio_cfg_noint, .chip = { .base = EXYNOS4_GPY6(0), @@ -308,76 +329,344 @@ static struct s3c_gpio_chip exynos4_gpio_part2_4bit[] = { .label = "GPX3", .to_irq = samsung_gpiolib_to_irq, }, + }, { + .base = S5P_VA_GPIO3, + .chip = { + .base = EXYNOS4_GPZ(0), + .ngpio = EXYNOS4_GPIO_Z_NR, + .label = "GPZ", + }, }, }; -static struct s3c_gpio_chip exynos4_gpio_part3_4bit[] = { +static struct s3c_gpio_chip exynos4210_gpio_4bit[] = { { + .base = (S5P_VA_GPIO1 + 0xE0), + .eint_offset = 0x1C, + .group = 11, .chip = { - .base = EXYNOS4_GPZ(0), - .ngpio = EXYNOS4_GPIO_Z_NR, - .label = "GPZ", + .base = EXYNOS4210_GPE0(0), + .ngpio = EXYNOS4210_GPIO_E0_NR, + .label = "GPE0", + }, + }, { + .base = (S5P_VA_GPIO1 + 0x100), + .eint_offset = 0x20, + .group = 12, + .chip = { + .base = EXYNOS4210_GPE1(0), + .ngpio = EXYNOS4210_GPIO_E1_NR, + .label = "GPE1", + }, + }, { + .base = (S5P_VA_GPIO1 + 0x120), + .eint_offset = 0x24, + .group = 13, + .chip = { + .base = EXYNOS4210_GPE2(0), + .ngpio = EXYNOS4210_GPIO_E2_NR, + .label = "GPE2", + }, + }, { + .base = (S5P_VA_GPIO1 + 0x140), + .eint_offset = 0x28, + .group = 14, + .chip = { + .base = EXYNOS4210_GPE3(0), + .ngpio = EXYNOS4210_GPIO_E3_NR, + .label = "GPE3", + }, + }, { + .base = (S5P_VA_GPIO1 + 0x160), + .eint_offset = 0x2C, + .group = 15, + .chip = { + .base = EXYNOS4210_GPE4(0), + .ngpio = EXYNOS4210_GPIO_E4_NR, + .label = "GPE4", + }, + }, { + .base = S5P_VA_GPIO2, + .group = 23, + .eint_offset = 0x0, + .chip = { + .base = EXYNOS4210_GPJ0(0), + .ngpio = EXYNOS4210_GPIO_J0_NR, + .label = "GPJ0", + }, + }, { + .base = (S5P_VA_GPIO2 + 0x20), + .eint_offset = 0x4, + .group = 24, + .chip = { + .base = EXYNOS4210_GPJ1(0), + .ngpio = EXYNOS4210_GPIO_J1_NR, + .label = "GPJ1", }, }, }; +static struct s3c_gpio_chip exynos4212_gpio_4bit[] = { + { + .base = (S5P_VA_GPIO1 + 0x240), + .eint_offset = 0x40, + .group = 11, + .chip = { + .base = EXYNOS4212_GPJ0(0), + .ngpio = EXYNOS4212_GPIO_J0_NR, + .label = "GPJ0", + }, + }, { + .base = (S5P_VA_GPIO1 + 0x260), + .eint_offset = 0x44, + .group = 12, + .chip = { + .base = EXYNOS4212_GPJ1(0), + .ngpio = EXYNOS4212_GPIO_J1_NR, + .label = "GPJ1", + } + }, { + .base = (S5P_VA_GPIO2 + 0x260), + .eint_offset = 0x24, + .group = 23, + .chip = { + .base = EXYNOS4212_GPM0(0), + .ngpio = EXYNOS4212_GPIO_M0_NR, + .label = "GPM0", + }, + }, { + .base = (S5P_VA_GPIO2 + 0x280), + .eint_offset = 0x28, + .group = 24, + .chip = { + .base = EXYNOS4212_GPM1(0), + .ngpio = EXYNOS4212_GPIO_M1_NR, + .label = "GPM1", + }, + }, { + .base = (S5P_VA_GPIO2 + 0x2A0), + .eint_offset = 0x2C, + .group = 25, + .chip = { + .base = EXYNOS4212_GPM2(0), + .ngpio = EXYNOS4212_GPIO_M2_NR, + .label = "GPM2", + }, + }, { + .base = (S5P_VA_GPIO2 + 0x2C0), + .eint_offset = 0x30, + .group = 26, + .chip = { + .base = EXYNOS4212_GPM3(0), + .ngpio = EXYNOS4212_GPIO_M3_NR, + .label = "GPM3", + }, + }, { + .base = (S5P_VA_GPIO2 + 0x2E0), + .eint_offset = 0x34, + .group = 27, + .chip = { + .base = EXYNOS4212_GPM4(0), + .ngpio = EXYNOS4212_GPIO_M4_NR, + .label = "GPM4", + }, + }, { + .base = S5P_VA_GPIO4, + .eint_offset = 0x00, + .group = 28, + .chip = { + .base = EXYNOS4212_GPV0(0), + .ngpio = EXYNOS4212_GPIO_V0_NR, + .label = "GPV0", + }, + }, { + .base = (S5P_VA_GPIO4 + 0x20), + .eint_offset = 0x04, + .group = 29, + .chip = { + .base = EXYNOS4212_GPV1(0), + .ngpio = EXYNOS4212_GPIO_V1_NR, + .label = "GPV1", + }, + }, { + .base = (S5P_VA_GPIO4 + 0x60), + .eint_offset = 0x08, + .group = 30, + .chip = { + .base = EXYNOS4212_GPV2(0), + .ngpio = EXYNOS4212_GPIO_V2_NR, + .label = "GPV2", + }, + }, { + .base = (S5P_VA_GPIO4 + 0x80), + .eint_offset = 0x0C, + .group = 31, + .chip = { + .base = EXYNOS4212_GPV3(0), + .ngpio = EXYNOS4212_GPIO_V3_NR, + .label = "GPV3", + }, + }, { + .base = (S5P_VA_GPIO4 + 0xC0), + .eint_offset = 0x10, + .group = 32, + .chip = { + .base = EXYNOS4212_GPV4(0), + .ngpio = EXYNOS4212_GPIO_V4_NR, + .label = "GPV4", + }, + }, +}; + +/* EXYNOS4 machine dependent GPIO help function */ +int s3c_gpio_slp_cfgpin(unsigned int pin, unsigned int config) +{ + struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin); + void __iomem *reg; + unsigned long flags; + int offset; + u32 con; + int shift; + + if (!chip) + return -EINVAL; + + if ((pin >= EXYNOS4_GPX0(0)) && (pin <= EXYNOS4_GPX3(7))) + return -EINVAL; + + if (config > S3C_GPIO_SLP_PREV) + return -EINVAL; + + reg = chip->base + 0x10; + + offset = pin - chip->chip.base; + shift = offset * 2; + + local_irq_save(flags); + + con = __raw_readl(reg); + con &= ~(3 << shift); + con |= config << shift; + __raw_writel(con, reg); + + local_irq_restore(flags); + return 0; +} + +s3c_gpio_pull_t s3c_gpio_get_slp_cfgpin(unsigned int pin) +{ + struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin); + void __iomem *reg; + unsigned long flags; + int offset; + u32 con; + int shift; + + if (!chip) + return -EINVAL; + + if ((pin >= EXYNOS4_GPX0(0)) && (pin <= EXYNOS4_GPX3(7))) + return -EINVAL; + + reg = chip->base + 0x10; + + offset = pin - chip->chip.base; + shift = offset * 2; + + local_irq_save(flags); + + con = __raw_readl(reg); + con >>= shift; + con &= 0x3; + + local_irq_restore(flags); + + return (__force s3c_gpio_pull_t)con; +} + +int s3c_gpio_slp_setpull_updown(unsigned int pin, unsigned int config) +{ + struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin); + void __iomem *reg; + unsigned long flags; + int offset; + u32 con; + int shift; + + if (!chip) + return -EINVAL; + + if ((pin >= EXYNOS4_GPX0(0)) && (pin <= EXYNOS4_GPX3(7))) + return -EINVAL; + + if (config > S3C_GPIO_PULL_UP) + return -EINVAL; + + reg = chip->base + 0x14; + + offset = pin - chip->chip.base; + shift = offset * 2; + + local_irq_save(flags); + + con = __raw_readl(reg); + con &= ~(3 << shift); + con |= config << shift; + __raw_writel(con, reg); + + local_irq_restore(flags); + + return 0; +} + static __init int exynos4_gpiolib_init(void) { struct s3c_gpio_chip *chip; int i; - int group = 0; int nr_chips; - /* GPIO part 1 */ + /* GPIO common part */ - chip = exynos4_gpio_part1_4bit; - nr_chips = ARRAY_SIZE(exynos4_gpio_part1_4bit); + chip = exynos4_gpio_common_4bit; + nr_chips = ARRAY_SIZE(exynos4_gpio_common_4bit); for (i = 0; i < nr_chips; i++, chip++) { - if (chip->config == NULL) { + if (chip->config == NULL) chip->config = &gpio_cfg; - /* Assign the GPIO interrupt group */ - chip->group = group++; - } if (chip->base == NULL) - chip->base = S5P_VA_GPIO1 + (i) * 0x20; + pr_err("No allocation of base address for [common gpio]"); } - samsung_gpiolib_add_4bit_chips(exynos4_gpio_part1_4bit, nr_chips); + samsung_gpiolib_add_4bit_chips(exynos4_gpio_common_4bit, nr_chips); - /* GPIO part 2 */ + /* Only 4210 GPIO part */ + if (soc_is_exynos4210()) { + chip = exynos4210_gpio_4bit; + nr_chips = ARRAY_SIZE(exynos4210_gpio_4bit); - chip = exynos4_gpio_part2_4bit; - nr_chips = ARRAY_SIZE(exynos4_gpio_part2_4bit); - - for (i = 0; i < nr_chips; i++, chip++) { - if (chip->config == NULL) { - chip->config = &gpio_cfg; - /* Assign the GPIO interrupt group */ - chip->group = group++; + for (i = 0; i < nr_chips; i++, chip++) { + if (chip->config == NULL) + chip->config = &gpio_cfg; + if (chip->base == NULL) + pr_err("No allocation of base address [4210 gpio]"); } - if (chip->base == NULL) - chip->base = S5P_VA_GPIO2 + (i) * 0x20; - } - - samsung_gpiolib_add_4bit_chips(exynos4_gpio_part2_4bit, nr_chips); - - /* GPIO part 3 */ - chip = exynos4_gpio_part3_4bit; - nr_chips = ARRAY_SIZE(exynos4_gpio_part3_4bit); + samsung_gpiolib_add_4bit_chips(exynos4210_gpio_4bit, nr_chips); + } else { + /* Only 4212/4412 GPIO part */ + chip = exynos4212_gpio_4bit; + nr_chips = ARRAY_SIZE(exynos4212_gpio_4bit); - for (i = 0; i < nr_chips; i++, chip++) { - if (chip->config == NULL) { - chip->config = &gpio_cfg; - /* Assign the GPIO interrupt group */ - chip->group = group++; + for (i = 0; i < nr_chips; i++, chip++) { + if (chip->config == NULL) + chip->config = &gpio_cfg; + if (chip->base == NULL) + pr_err("No allocation of base address [4212 gpio]"); } - if (chip->base == NULL) - chip->base = S5P_VA_GPIO3 + (i) * 0x20; + + samsung_gpiolib_add_4bit_chips(exynos4212_gpio_4bit, nr_chips); } - samsung_gpiolib_add_4bit_chips(exynos4_gpio_part3_4bit, nr_chips); s5p_register_gpioint_bank(IRQ_GPIO_XA, 0, IRQ_GPIO1_NR_GROUPS); s5p_register_gpioint_bank(IRQ_GPIO_XB, IRQ_GPIO1_NR_GROUPS, IRQ_GPIO2_NR_GROUPS); |