aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k
diff options
context:
space:
mode:
authorGreg Ungerer <gerg@uclinux.org>2012-04-16 01:59:29 -0400
committerGreg Ungerer <gerg@uclinux.org>2012-05-20 07:21:35 -0400
commitc269d4efaab0847947e87df7a5a8b6c5817d9f1d (patch)
tree462f4d72a6bbedcdb52e633b0ff28af4840cb794 /arch/m68k
parentf106eac91edbd28de23b0bc58be82f68d976e24f (diff)
m68knommu: introduce macros to simplify ColdFire GPIO table initialization
We have very large tables in the ColdFire CPU GPIO setup code that essentially boil down to 2 distinct types of GPIO pin initiaization. Using 2 macros we can reduce these large tables to at most a dozen lines of setup code, and in quite a few cases a single table entry. Introduce these 2 macros into the existing mcfgpio.h header. Signed-off-by: Greg Ungerer <gerg@uclinux.org> Acked-by: Steven King <sfking@fdwdc.com>
Diffstat (limited to 'arch/m68k')
-rw-r--r--arch/m68k/include/asm/mcfgpio.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/arch/m68k/include/asm/mcfgpio.h b/arch/m68k/include/asm/mcfgpio.h
index ee5e4ccce89e..1bc877b45554 100644
--- a/arch/m68k/include/asm/mcfgpio.h
+++ b/arch/m68k/include/asm/mcfgpio.h
@@ -37,4 +37,58 @@ void mcf_gpio_set_value_fast(struct gpio_chip *, unsigned, int);
37int mcf_gpio_request(struct gpio_chip *, unsigned); 37int mcf_gpio_request(struct gpio_chip *, unsigned);
38void mcf_gpio_free(struct gpio_chip *, unsigned); 38void mcf_gpio_free(struct gpio_chip *, unsigned);
39 39
40/*
41 * Define macros to ease the pain of setting up the GPIO tables. There
42 * are two cases we need to deal with here, they cover all currently
43 * available ColdFire GPIO hardware. There are of course minor differences
44 * in the layout and number of bits in each ColdFire part, but the macros
45 * take all that in.
46 *
47 * Firstly is the conventional GPIO registers where we toggle individual
48 * bits in a register, preserving the other bits in the register. For
49 * lack of a better term I have called this the slow method.
50 */
51#define MCFGPS(mlabel, mbase, mngpio, mpddr, mpodr, mppdr) \
52 { \
53 .gpio_chip = { \
54 .label = #mlabel, \
55 .request = mcf_gpio_request, \
56 .free = mcf_gpio_free, \
57 .direction_input = mcf_gpio_direction_input, \
58 .direction_output = mcf_gpio_direction_output,\
59 .get = mcf_gpio_get_value, \
60 .set = mcf_gpio_set_value, \
61 .base = mbase, \
62 .ngpio = mngpio, \
63 }, \
64 .pddr = (void __iomem *) mpddr, \
65 .podr = (void __iomem *) mpodr, \
66 .ppdr = (void __iomem *) mppdr, \
67 }
68
69/*
70 * Secondly is the faster case, where we have set and clear registers
71 * that allow us to set or clear a bit with a single write, not having
72 * to worry about preserving other bits.
73 */
74#define MCFGPF(mlabel, mbase, mngpio) \
75 { \
76 .gpio_chip = { \
77 .label = #mlabel, \
78 .request = mcf_gpio_request, \
79 .free = mcf_gpio_free, \
80 .direction_input = mcf_gpio_direction_input, \
81 .direction_output = mcf_gpio_direction_output,\
82 .get = mcf_gpio_get_value, \
83 .set = mcf_gpio_set_value_fast, \
84 .base = mbase, \
85 .ngpio = mngpio, \
86 }, \
87 .pddr = (void __iomem *) MCFGPIO_PDDR_##mlabel, \
88 .podr = (void __iomem *) MCFGPIO_PODR_##mlabel, \
89 .ppdr = (void __iomem *) MCFGPIO_PPDSDR_##mlabel, \
90 .setr = (void __iomem *) MCFGPIO_PPDSDR_##mlabel, \
91 .clrr = (void __iomem *) MCFGPIO_PCLRR_##mlabel, \
92 }
93
40#endif 94#endif