aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-09 17:28:38 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-09 17:28:38 -0500
commitdfc1ebe76663d582a01c9dc572395cf8086d01de (patch)
tree54a5ac91214a90f82c27b6e38099a4470837729e /drivers/gpio
parentacc952c1f373bf3f66cc7a10680eee1762bed40b (diff)
parentb001befe58691ef3627458cd814e8cee7f845c5f (diff)
Merge tag 'dt' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Device tree conversions for samsung and tegra Both platforms had some initial device tree support, but this adds much more to actually make it usable. * tag 'dt' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (45 commits) ARM: dts: Add intial dts file for EXYNOS4210 SoC, SMDKV310 and ORIGEN ARM: EXYNOS: Add Exynos4 device tree enabled board file rtc: rtc-s3c: Add device tree support input: samsung-keypad: Add device tree support ARM: S5PV210: Modify platform data for pl330 driver ARM: S5PC100: Modify platform data for pl330 driver ARM: S5P64x0: Modify platform data for pl330 driver ARM: EXYNOS: Add a alias for pdma clocks ARM: EXYNOS: Limit usage of pl330 device instance to non-dt build ARM: SAMSUNG: Add device tree support for pl330 dma engine wrappers DMA: PL330: Add device tree support ARM: EXYNOS: Modify platform data for pl330 driver DMA: PL330: Infer transfer direction from transfer request instead of platform data DMA: PL330: move filter function into driver serial: samsung: Fix build for non-Exynos4210 devices serial: samsung: add device tree support serial: samsung: merge probe() function from all SoC specific extensions serial: samsung: merge all SoC specific port reset functions ARM: SAMSUNG: register uart clocks to clock lookup list serial: samsung: remove all uses of get_clksrc and set_clksrc ... Fix up fairly trivial conflicts in arch/arm/mach-s3c2440/clock.c and drivers/tty/serial/Kconfig both due to just adding code close to changes.
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-samsung.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-samsung.c b/drivers/gpio/gpio-samsung.c
index ab098ba9f1dd..a7661773c052 100644
--- a/drivers/gpio/gpio-samsung.c
+++ b/drivers/gpio/gpio-samsung.c
@@ -24,6 +24,9 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/device.h> 25#include <linux/device.h>
26#include <linux/ioport.h> 26#include <linux/ioport.h>
27#include <linux/of.h>
28#include <linux/slab.h>
29#include <linux/of_address.h>
27 30
28#include <asm/irq.h> 31#include <asm/irq.h>
29 32
@@ -2383,6 +2386,63 @@ static struct samsung_gpio_chip exynos4_gpios_3[] = {
2383#endif 2386#endif
2384}; 2387};
2385 2388
2389#if defined(CONFIG_ARCH_EXYNOS4) && defined(CONFIG_OF)
2390static int exynos4_gpio_xlate(struct gpio_chip *gc, struct device_node *np,
2391 const void *gpio_spec, u32 *flags)
2392{
2393 const __be32 *gpio = gpio_spec;
2394 const u32 n = be32_to_cpup(gpio);
2395 unsigned int pin = gc->base + be32_to_cpu(gpio[0]);
2396
2397 if (WARN_ON(gc->of_gpio_n_cells < 4))
2398 return -EINVAL;
2399
2400 if (n > gc->ngpio)
2401 return -EINVAL;
2402
2403 if (s3c_gpio_cfgpin(pin, S3C_GPIO_SFN(be32_to_cpu(gpio[1]))))
2404 pr_warn("gpio_xlate: failed to set pin function\n");
2405 if (s3c_gpio_setpull(pin, be32_to_cpu(gpio[2])))
2406 pr_warn("gpio_xlate: failed to set pin pull up/down\n");
2407 if (s5p_gpio_set_drvstr(pin, be32_to_cpu(gpio[3])))
2408 pr_warn("gpio_xlate: failed to set pin drive strength\n");
2409
2410 return n;
2411}
2412
2413static const struct of_device_id exynos4_gpio_dt_match[] __initdata = {
2414 { .compatible = "samsung,exynos4-gpio", },
2415 {}
2416};
2417
2418static __init void exynos4_gpiolib_attach_ofnode(struct samsung_gpio_chip *chip,
2419 u64 base, u64 offset)
2420{
2421 struct gpio_chip *gc = &chip->chip;
2422 u64 address;
2423
2424 if (!of_have_populated_dt())
2425 return;
2426
2427 address = chip->base ? base + ((u32)chip->base & 0xfff) : base + offset;
2428 gc->of_node = of_find_matching_node_by_address(NULL,
2429 exynos4_gpio_dt_match, address);
2430 if (!gc->of_node) {
2431 pr_info("gpio: device tree node not found for gpio controller"
2432 " with base address %08llx\n", address);
2433 return;
2434 }
2435 gc->of_gpio_n_cells = 4;
2436 gc->of_xlate = exynos4_gpio_xlate;
2437}
2438#elif defined(CONFIG_ARCH_EXYNOS4)
2439static __init void exynos4_gpiolib_attach_ofnode(struct samsung_gpio_chip *chip,
2440 u64 base, u64 offset)
2441{
2442 return;
2443}
2444#endif /* defined(CONFIG_ARCH_EXYNOS4) && defined(CONFIG_OF) */
2445
2386/* TODO: cleanup soc_is_* */ 2446/* TODO: cleanup soc_is_* */
2387static __init int samsung_gpiolib_init(void) 2447static __init int samsung_gpiolib_init(void)
2388{ 2448{
@@ -2464,6 +2524,10 @@ static __init int samsung_gpiolib_init(void)
2464 chip->config = &exynos4_gpio_cfg; 2524 chip->config = &exynos4_gpio_cfg;
2465 chip->group = group++; 2525 chip->group = group++;
2466 } 2526 }
2527#ifdef CONFIG_CPU_EXYNOS4210
2528 exynos4_gpiolib_attach_ofnode(chip,
2529 EXYNOS4_PA_GPIO1, i * 0x20);
2530#endif
2467 } 2531 }
2468 samsung_gpiolib_add_4bit_chips(exynos4_gpios_1, nr_chips, S5P_VA_GPIO1); 2532 samsung_gpiolib_add_4bit_chips(exynos4_gpios_1, nr_chips, S5P_VA_GPIO1);
2469 2533
@@ -2476,6 +2540,10 @@ static __init int samsung_gpiolib_init(void)
2476 chip->config = &exynos4_gpio_cfg; 2540 chip->config = &exynos4_gpio_cfg;
2477 chip->group = group++; 2541 chip->group = group++;
2478 } 2542 }
2543#ifdef CONFIG_CPU_EXYNOS4210
2544 exynos4_gpiolib_attach_ofnode(chip,
2545 EXYNOS4_PA_GPIO2, i * 0x20);
2546#endif
2479 } 2547 }
2480 samsung_gpiolib_add_4bit_chips(exynos4_gpios_2, nr_chips, S5P_VA_GPIO2); 2548 samsung_gpiolib_add_4bit_chips(exynos4_gpios_2, nr_chips, S5P_VA_GPIO2);
2481 2549
@@ -2488,6 +2556,10 @@ static __init int samsung_gpiolib_init(void)
2488 chip->config = &exynos4_gpio_cfg; 2556 chip->config = &exynos4_gpio_cfg;
2489 chip->group = group++; 2557 chip->group = group++;
2490 } 2558 }
2559#ifdef CONFIG_CPU_EXYNOS4210
2560 exynos4_gpiolib_attach_ofnode(chip,
2561 EXYNOS4_PA_GPIO3, i * 0x20);
2562#endif
2491 } 2563 }
2492 samsung_gpiolib_add_4bit_chips(exynos4_gpios_3, nr_chips, S5P_VA_GPIO3); 2564 samsung_gpiolib_add_4bit_chips(exynos4_gpios_3, nr_chips, S5P_VA_GPIO3);
2493 2565