diff options
author | Arnd Bergmann <arnd@arndb.de> | 2012-01-09 12:06:36 -0500 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2012-01-09 12:06:36 -0500 |
commit | 421b759b86eb8a914cbbd11f6d09a74f411762c6 (patch) | |
tree | 505ca7f23987d8eaaa519a7e8506b854e2c0d030 /arch/arm/mach-at91/gpio.c | |
parent | e067096c8d57d191f29d734cd5692695c95cc36e (diff) | |
parent | a07613a54d700a974f3a4a657da78ef5d097315d (diff) |
Merge branch 'samsung/cleanup' into next/boards
Conflicts:
arch/arm/mach-imx/mach-imx6q.c
arch/arm/mach-omap2/board-ti8168evm.c
arch/arm/mach-s3c64xx/Kconfig
arch/arm/mach-tegra/Makefile
arch/arm/mach-tegra/board-dt-tegra20.c
arch/arm/mach-tegra/common.c
Lots of relatively simple conflicts between the board
changes and stuff from the arm tree. This pulls in
the resolution from the samsung/cleanup tree, so we
don't get conflicting merges.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/arm/mach-at91/gpio.c')
-rw-r--r-- | arch/arm/mach-at91/gpio.c | 85 |
1 files changed, 49 insertions, 36 deletions
diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c index 224e9e2f867..74d6783eeab 100644 --- a/arch/arm/mach-at91/gpio.c +++ b/arch/arm/mach-at91/gpio.c | |||
@@ -29,8 +29,9 @@ | |||
29 | struct at91_gpio_chip { | 29 | struct at91_gpio_chip { |
30 | struct gpio_chip chip; | 30 | struct gpio_chip chip; |
31 | struct at91_gpio_chip *next; /* Bank sharing same clock */ | 31 | struct at91_gpio_chip *next; /* Bank sharing same clock */ |
32 | struct at91_gpio_bank *bank; /* Bank definition */ | 32 | int id; /* ID of register bank */ |
33 | void __iomem *regbase; /* Base of register bank */ | 33 | void __iomem *regbase; /* Base of register bank */ |
34 | struct clk *clock; /* associated clock */ | ||
34 | }; | 35 | }; |
35 | 36 | ||
36 | #define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip) | 37 | #define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip) |
@@ -58,18 +59,17 @@ static int at91_gpiolib_direction_input(struct gpio_chip *chip, | |||
58 | } | 59 | } |
59 | 60 | ||
60 | static struct at91_gpio_chip gpio_chip[] = { | 61 | static struct at91_gpio_chip gpio_chip[] = { |
61 | AT91_GPIO_CHIP("A", 0x00 + PIN_BASE, 32), | 62 | AT91_GPIO_CHIP("pioA", 0x00, 32), |
62 | AT91_GPIO_CHIP("B", 0x20 + PIN_BASE, 32), | 63 | AT91_GPIO_CHIP("pioB", 0x20, 32), |
63 | AT91_GPIO_CHIP("C", 0x40 + PIN_BASE, 32), | 64 | AT91_GPIO_CHIP("pioC", 0x40, 32), |
64 | AT91_GPIO_CHIP("D", 0x60 + PIN_BASE, 32), | 65 | AT91_GPIO_CHIP("pioD", 0x60, 32), |
65 | AT91_GPIO_CHIP("E", 0x80 + PIN_BASE, 32), | 66 | AT91_GPIO_CHIP("pioE", 0x80, 32), |
66 | }; | 67 | }; |
67 | 68 | ||
68 | static int gpio_banks; | 69 | static int gpio_banks; |
69 | 70 | ||
70 | static inline void __iomem *pin_to_controller(unsigned pin) | 71 | static inline void __iomem *pin_to_controller(unsigned pin) |
71 | { | 72 | { |
72 | pin -= PIN_BASE; | ||
73 | pin /= 32; | 73 | pin /= 32; |
74 | if (likely(pin < gpio_banks)) | 74 | if (likely(pin < gpio_banks)) |
75 | return gpio_chip[pin].regbase; | 75 | return gpio_chip[pin].regbase; |
@@ -79,7 +79,6 @@ static inline void __iomem *pin_to_controller(unsigned pin) | |||
79 | 79 | ||
80 | static inline unsigned pin_to_mask(unsigned pin) | 80 | static inline unsigned pin_to_mask(unsigned pin) |
81 | { | 81 | { |
82 | pin -= PIN_BASE; | ||
83 | return 1 << (pin % 32); | 82 | return 1 << (pin % 32); |
84 | } | 83 | } |
85 | 84 | ||
@@ -274,8 +273,9 @@ static u32 backups[MAX_GPIO_BANKS]; | |||
274 | 273 | ||
275 | static int gpio_irq_set_wake(struct irq_data *d, unsigned state) | 274 | static int gpio_irq_set_wake(struct irq_data *d, unsigned state) |
276 | { | 275 | { |
277 | unsigned mask = pin_to_mask(d->irq); | 276 | unsigned pin = irq_to_gpio(d->irq); |
278 | unsigned bank = (d->irq - PIN_BASE) / 32; | 277 | unsigned mask = pin_to_mask(pin); |
278 | unsigned bank = pin / 32; | ||
279 | 279 | ||
280 | if (unlikely(bank >= MAX_GPIO_BANKS)) | 280 | if (unlikely(bank >= MAX_GPIO_BANKS)) |
281 | return -EINVAL; | 281 | return -EINVAL; |
@@ -285,7 +285,7 @@ static int gpio_irq_set_wake(struct irq_data *d, unsigned state) | |||
285 | else | 285 | else |
286 | wakeups[bank] &= ~mask; | 286 | wakeups[bank] &= ~mask; |
287 | 287 | ||
288 | irq_set_irq_wake(gpio_chip[bank].bank->id, state); | 288 | irq_set_irq_wake(gpio_chip[bank].id, state); |
289 | 289 | ||
290 | return 0; | 290 | return 0; |
291 | } | 291 | } |
@@ -302,7 +302,7 @@ void at91_gpio_suspend(void) | |||
302 | __raw_writel(wakeups[i], pio + PIO_IER); | 302 | __raw_writel(wakeups[i], pio + PIO_IER); |
303 | 303 | ||
304 | if (!wakeups[i]) | 304 | if (!wakeups[i]) |
305 | clk_disable(gpio_chip[i].bank->clock); | 305 | clk_disable(gpio_chip[i].clock); |
306 | else { | 306 | else { |
307 | #ifdef CONFIG_PM_DEBUG | 307 | #ifdef CONFIG_PM_DEBUG |
308 | printk(KERN_DEBUG "GPIO-%c may wake for %08x\n", 'A'+i, wakeups[i]); | 308 | printk(KERN_DEBUG "GPIO-%c may wake for %08x\n", 'A'+i, wakeups[i]); |
@@ -319,7 +319,7 @@ void at91_gpio_resume(void) | |||
319 | void __iomem *pio = gpio_chip[i].regbase; | 319 | void __iomem *pio = gpio_chip[i].regbase; |
320 | 320 | ||
321 | if (!wakeups[i]) | 321 | if (!wakeups[i]) |
322 | clk_enable(gpio_chip[i].bank->clock); | 322 | clk_enable(gpio_chip[i].clock); |
323 | 323 | ||
324 | __raw_writel(wakeups[i], pio + PIO_IDR); | 324 | __raw_writel(wakeups[i], pio + PIO_IDR); |
325 | __raw_writel(backups[i], pio + PIO_IER); | 325 | __raw_writel(backups[i], pio + PIO_IER); |
@@ -344,8 +344,9 @@ void at91_gpio_resume(void) | |||
344 | 344 | ||
345 | static void gpio_irq_mask(struct irq_data *d) | 345 | static void gpio_irq_mask(struct irq_data *d) |
346 | { | 346 | { |
347 | void __iomem *pio = pin_to_controller(d->irq); | 347 | unsigned pin = irq_to_gpio(d->irq); |
348 | unsigned mask = pin_to_mask(d->irq); | 348 | void __iomem *pio = pin_to_controller(pin); |
349 | unsigned mask = pin_to_mask(pin); | ||
349 | 350 | ||
350 | if (pio) | 351 | if (pio) |
351 | __raw_writel(mask, pio + PIO_IDR); | 352 | __raw_writel(mask, pio + PIO_IDR); |
@@ -353,8 +354,9 @@ static void gpio_irq_mask(struct irq_data *d) | |||
353 | 354 | ||
354 | static void gpio_irq_unmask(struct irq_data *d) | 355 | static void gpio_irq_unmask(struct irq_data *d) |
355 | { | 356 | { |
356 | void __iomem *pio = pin_to_controller(d->irq); | 357 | unsigned pin = irq_to_gpio(d->irq); |
357 | unsigned mask = pin_to_mask(d->irq); | 358 | void __iomem *pio = pin_to_controller(pin); |
359 | unsigned mask = pin_to_mask(pin); | ||
358 | 360 | ||
359 | if (pio) | 361 | if (pio) |
360 | __raw_writel(mask, pio + PIO_IER); | 362 | __raw_writel(mask, pio + PIO_IER); |
@@ -382,7 +384,7 @@ static struct irq_chip gpio_irqchip = { | |||
382 | 384 | ||
383 | static void gpio_irq_handler(unsigned irq, struct irq_desc *desc) | 385 | static void gpio_irq_handler(unsigned irq, struct irq_desc *desc) |
384 | { | 386 | { |
385 | unsigned pin; | 387 | unsigned irq_pin; |
386 | struct irq_data *idata = irq_desc_get_irq_data(desc); | 388 | struct irq_data *idata = irq_desc_get_irq_data(desc); |
387 | struct irq_chip *chip = irq_data_get_irq_chip(idata); | 389 | struct irq_chip *chip = irq_data_get_irq_chip(idata); |
388 | struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(idata); | 390 | struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(idata); |
@@ -405,12 +407,12 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc) | |||
405 | continue; | 407 | continue; |
406 | } | 408 | } |
407 | 409 | ||
408 | pin = at91_gpio->chip.base; | 410 | irq_pin = gpio_to_irq(at91_gpio->chip.base); |
409 | 411 | ||
410 | while (isr) { | 412 | while (isr) { |
411 | if (isr & 1) | 413 | if (isr & 1) |
412 | generic_handle_irq(pin); | 414 | generic_handle_irq(irq_pin); |
413 | pin++; | 415 | irq_pin++; |
414 | isr >>= 1; | 416 | isr >>= 1; |
415 | } | 417 | } |
416 | } | 418 | } |
@@ -438,7 +440,7 @@ static int at91_gpio_show(struct seq_file *s, void *unused) | |||
438 | seq_printf(s, "%i:\t", j); | 440 | seq_printf(s, "%i:\t", j); |
439 | 441 | ||
440 | for (bank = 0; bank < gpio_banks; bank++) { | 442 | for (bank = 0; bank < gpio_banks; bank++) { |
441 | unsigned pin = PIN_BASE + (32 * bank) + j; | 443 | unsigned pin = (32 * bank) + j; |
442 | void __iomem *pio = pin_to_controller(pin); | 444 | void __iomem *pio = pin_to_controller(pin); |
443 | unsigned mask = pin_to_mask(pin); | 445 | unsigned mask = pin_to_mask(pin); |
444 | 446 | ||
@@ -491,27 +493,28 @@ static struct lock_class_key gpio_lock_class; | |||
491 | */ | 493 | */ |
492 | void __init at91_gpio_irq_setup(void) | 494 | void __init at91_gpio_irq_setup(void) |
493 | { | 495 | { |
494 | unsigned pioc, pin; | 496 | unsigned pioc, irq = gpio_to_irq(0); |
495 | struct at91_gpio_chip *this, *prev; | 497 | struct at91_gpio_chip *this, *prev; |
496 | 498 | ||
497 | for (pioc = 0, pin = PIN_BASE, this = gpio_chip, prev = NULL; | 499 | for (pioc = 0, this = gpio_chip, prev = NULL; |
498 | pioc++ < gpio_banks; | 500 | pioc++ < gpio_banks; |
499 | prev = this, this++) { | 501 | prev = this, this++) { |
500 | unsigned id = this->bank->id; | 502 | unsigned id = this->id; |
501 | unsigned i; | 503 | unsigned i; |
502 | 504 | ||
503 | __raw_writel(~0, this->regbase + PIO_IDR); | 505 | __raw_writel(~0, this->regbase + PIO_IDR); |
504 | 506 | ||
505 | for (i = 0, pin = this->chip.base; i < 32; i++, pin++) { | 507 | for (i = 0, irq = gpio_to_irq(this->chip.base); i < 32; |
506 | irq_set_lockdep_class(pin, &gpio_lock_class); | 508 | i++, irq++) { |
509 | irq_set_lockdep_class(irq, &gpio_lock_class); | ||
507 | 510 | ||
508 | /* | 511 | /* |
509 | * Can use the "simple" and not "edge" handler since it's | 512 | * Can use the "simple" and not "edge" handler since it's |
510 | * shorter, and the AIC handles interrupts sanely. | 513 | * shorter, and the AIC handles interrupts sanely. |
511 | */ | 514 | */ |
512 | irq_set_chip_and_handler(pin, &gpio_irqchip, | 515 | irq_set_chip_and_handler(irq, &gpio_irqchip, |
513 | handle_simple_irq); | 516 | handle_simple_irq); |
514 | set_irq_flags(pin, IRQF_VALID); | 517 | set_irq_flags(irq, IRQF_VALID); |
515 | } | 518 | } |
516 | 519 | ||
517 | /* The toplevel handler handles one bank of GPIOs, except | 520 | /* The toplevel handler handles one bank of GPIOs, except |
@@ -524,7 +527,7 @@ void __init at91_gpio_irq_setup(void) | |||
524 | irq_set_chip_data(id, this); | 527 | irq_set_chip_data(id, this); |
525 | irq_set_chained_handler(id, gpio_irq_handler); | 528 | irq_set_chained_handler(id, gpio_irq_handler); |
526 | } | 529 | } |
527 | pr_info("AT91: %d gpio irqs in %d banks\n", pin - PIN_BASE, gpio_banks); | 530 | pr_info("AT91: %d gpio irqs in %d banks\n", irq - gpio_to_irq(0), gpio_banks); |
528 | } | 531 | } |
529 | 532 | ||
530 | /* gpiolib support */ | 533 | /* gpiolib support */ |
@@ -612,16 +615,26 @@ void __init at91_gpio_init(struct at91_gpio_bank *data, int nr_banks) | |||
612 | for (i = 0; i < nr_banks; i++) { | 615 | for (i = 0; i < nr_banks; i++) { |
613 | at91_gpio = &gpio_chip[i]; | 616 | at91_gpio = &gpio_chip[i]; |
614 | 617 | ||
615 | at91_gpio->bank = &data[i]; | 618 | at91_gpio->id = data[i].id; |
616 | at91_gpio->chip.base = PIN_BASE + i * 32; | 619 | at91_gpio->chip.base = i * 32; |
617 | at91_gpio->regbase = at91_gpio->bank->offset + | 620 | |
618 | (void __iomem *)AT91_VA_BASE_SYS; | 621 | at91_gpio->regbase = ioremap(data[i].regbase, 512); |
622 | if (!at91_gpio->regbase) { | ||
623 | pr_err("at91_gpio.%d, failed to map registers, ignoring.\n", i); | ||
624 | continue; | ||
625 | } | ||
626 | |||
627 | at91_gpio->clock = clk_get_sys(NULL, at91_gpio->chip.label); | ||
628 | if (!at91_gpio->clock) { | ||
629 | pr_err("at91_gpio.%d, failed to get clock, ignoring.\n", i); | ||
630 | continue; | ||
631 | } | ||
619 | 632 | ||
620 | /* enable PIO controller's clock */ | 633 | /* enable PIO controller's clock */ |
621 | clk_enable(at91_gpio->bank->clock); | 634 | clk_enable(at91_gpio->clock); |
622 | 635 | ||
623 | /* AT91SAM9263_ID_PIOCDE groups PIOC, PIOD, PIOE */ | 636 | /* AT91SAM9263_ID_PIOCDE groups PIOC, PIOD, PIOE */ |
624 | if (last && last->bank->id == at91_gpio->bank->id) | 637 | if (last && last->id == at91_gpio->id) |
625 | last->next = at91_gpio; | 638 | last->next = at91_gpio; |
626 | last = at91_gpio; | 639 | last = at91_gpio; |
627 | 640 | ||