diff options
author | David Brownell <dbrownell@users.sourceforge.net> | 2008-12-07 14:46:23 -0500 |
---|---|---|
committer | Kevin Hilman <khilman@deeprootsystems.com> | 2009-04-27 12:49:43 -0400 |
commit | 474dad54baee8f8abe63ac334357a37021147701 (patch) | |
tree | 1d8f57b71f2e36ac9442b9d6fad685234f1ae853 /arch/arm/mach-davinci/include/mach | |
parent | a4768d2275cb7c0d2a665b9ad4de07834be0714b (diff) |
davinci: gpio bugfixes
Update the DaVinci GPIO code to work better on non-dm6446 parts,
notably the dm355:
- Only handle the number of GPIOs the chip actually has. So
for example on dm6467, GPIO-42 is the last GPIO, and trying
to use GPIO-43 now fails cleanly; or GPIO-72 on dm6446.
- Enable GPIO interrupts on each 16-bit GPIO-irq bank ...
previously, only the first five were enabled, so GPIO-80
and above (on dm355) wouldn't trigger IRQs.
- Use the right IRQ for each GPIO bank. The wrong values were
used for dm355 chips, so GPIO IRQs got routed incorrectly.
- Handle up to four pairs of 16-bit GPIO banks ... previously
only three were handled, so accessing GPIO-96 and up (e.g. on
dm355) would oops.
- Update several comments that were dm6446-specific.
Verified by receiving GPIO-1 (dm9000) and GPIO-5 (msp430) IRQs
on the DM355 EVM.
One thing this doesn't do is handle the way some of the GPIO
numbers on dm6467 are reserved but aren't valid as GPIOs. Some
bitmap logic could fix that if needed.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch/arm/mach-davinci/include/mach')
-rw-r--r-- | arch/arm/mach-davinci/include/mach/gpio.h | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/arch/arm/mach-davinci/include/mach/gpio.h b/arch/arm/mach-davinci/include/mach/gpio.h index 5e7c36b202f1..efe3281364e6 100644 --- a/arch/arm/mach-davinci/include/mach/gpio.h +++ b/arch/arm/mach-davinci/include/mach/gpio.h | |||
@@ -28,23 +28,18 @@ | |||
28 | * go through boot loaders. | 28 | * go through boot loaders. |
29 | * | 29 | * |
30 | * the gpio clock will be turned on when gpios are used, and you may also | 30 | * the gpio clock will be turned on when gpios are used, and you may also |
31 | * need to pay attention to PINMUX0 and PINMUX1 to be sure those pins are | 31 | * need to pay attention to PINMUX registers to be sure those pins are |
32 | * used as gpios, not with other peripherals. | 32 | * used as gpios, not with other peripherals. |
33 | * | 33 | * |
34 | * On-chip GPIOs are numbered 0..(DAVINCI_N_GPIO-1). For documentation, | 34 | * On-chip GPIOs are numbered 0..(DAVINCI_N_GPIO-1). For documentation, |
35 | * and maybe for later updates, code should write GPIO(N) or: | 35 | * and maybe for later updates, code may write GPIO(N). These may be |
36 | * - GPIOV18(N) for 1.8V pins, N in 0..53; same as GPIO(0)..GPIO(53) | 36 | * all 1.8V signals, all 3.3V ones, or a mix of the two. A given chip |
37 | * - GPIOV33(N) for 3.3V pins, N in 0..17; same as GPIO(54)..GPIO(70) | 37 | * may not support all the GPIOs in that range. |
38 | * | ||
39 | * For GPIO IRQs use gpio_to_irq(GPIO(N)) or gpio_to_irq(GPIOV33(N)) etc | ||
40 | * for now, that's != GPIO(N) | ||
41 | * | 38 | * |
42 | * GPIOs can also be on external chips, numbered after the ones built-in | 39 | * GPIOs can also be on external chips, numbered after the ones built-in |
43 | * to the DaVinci chip. For now, they won't be usable as IRQ sources. | 40 | * to the DaVinci chip. For now, they won't be usable as IRQ sources. |
44 | */ | 41 | */ |
45 | #define GPIO(X) (X) /* 0 <= X <= 70 */ | 42 | #define GPIO(X) (X) /* 0 <= X <= (DAVINCI_N_GPIO - 1) */ |
46 | #define GPIOV18(X) (X) /* 1.8V i/o; 0 <= X <= 53 */ | ||
47 | #define GPIOV33(X) ((X)+54) /* 3.3V i/o; 0 <= X <= 17 */ | ||
48 | 43 | ||
49 | struct gpio_controller { | 44 | struct gpio_controller { |
50 | u32 dir; | 45 | u32 dir; |
@@ -73,12 +68,14 @@ __gpio_to_controller(unsigned gpio) | |||
73 | { | 68 | { |
74 | void *__iomem ptr; | 69 | void *__iomem ptr; |
75 | 70 | ||
76 | if (gpio < 32) | 71 | if (gpio < 32 * 1) |
77 | ptr = IO_ADDRESS(DAVINCI_GPIO_BASE + 0x10); | 72 | ptr = IO_ADDRESS(DAVINCI_GPIO_BASE + 0x10); |
78 | else if (gpio < 64) | 73 | else if (gpio < 32 * 2) |
79 | ptr = IO_ADDRESS(DAVINCI_GPIO_BASE + 0x38); | 74 | ptr = IO_ADDRESS(DAVINCI_GPIO_BASE + 0x38); |
80 | else if (gpio < DAVINCI_N_GPIO) | 75 | else if (gpio < 32 * 3) |
81 | ptr = IO_ADDRESS(DAVINCI_GPIO_BASE + 0x60); | 76 | ptr = IO_ADDRESS(DAVINCI_GPIO_BASE + 0x60); |
77 | else if (gpio < 32 * 4) | ||
78 | ptr = IO_ADDRESS(DAVINCI_GPIO_BASE + 0x88); | ||
82 | else | 79 | else |
83 | ptr = NULL; | 80 | ptr = NULL; |
84 | return ptr; | 81 | return ptr; |