diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2011-08-22 03:40:38 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2011-08-22 04:12:56 -0400 |
commit | 5f3fcf9649dbb010ccac41259d04147775ec8fc2 (patch) | |
tree | 9ca8442e7702631929289966054d52871a98207e /arch/arm | |
parent | bd08d709c4a44089a9d87a3b402a54c1d6b8890b (diff) |
ARM: 7040/1: mach-davinci: break out GPIO driver specifics
The <mach/gpio.h> file is included from upper directories
and deal with generic GPIO and gpiolib stuff. Break out the
platform and driver specific defines and functions into its own
header file.
Cc: Sekhar Nori <nsekhar@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-davinci/da830.c | 1 | ||||
-rw-r--r-- | arch/arm/mach-davinci/da850.c | 1 | ||||
-rw-r--r-- | arch/arm/mach-davinci/dm355.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-davinci/dm365.c | 3 | ||||
-rw-r--r-- | arch/arm/mach-davinci/dm644x.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-davinci/dm646x.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-davinci/include/mach/gpio-davinci.h | 91 | ||||
-rw-r--r-- | arch/arm/mach-davinci/include/mach/gpio.h | 76 | ||||
-rw-r--r-- | arch/arm/mach-davinci/tnetv107x.c | 1 |
9 files changed, 100 insertions, 79 deletions
diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c index 358ed0df6d20..a6bf5dcaef13 100644 --- a/arch/arm/mach-davinci/da830.c +++ b/arch/arm/mach-davinci/da830.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <mach/common.h> | 20 | #include <mach/common.h> |
21 | #include <mach/time.h> | 21 | #include <mach/time.h> |
22 | #include <mach/da8xx.h> | 22 | #include <mach/da8xx.h> |
23 | #include <mach/gpio-davinci.h> | ||
23 | 24 | ||
24 | #include "clock.h" | 25 | #include "clock.h" |
25 | #include "mux.h" | 26 | #include "mux.h" |
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c index 71a4aa263fb0..4aae01576aab 100644 --- a/arch/arm/mach-davinci/da850.c +++ b/arch/arm/mach-davinci/da850.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <mach/da8xx.h> | 28 | #include <mach/da8xx.h> |
29 | #include <mach/cpufreq.h> | 29 | #include <mach/cpufreq.h> |
30 | #include <mach/pm.h> | 30 | #include <mach/pm.h> |
31 | #include <mach/gpio-davinci.h> | ||
31 | 32 | ||
32 | #include "clock.h" | 33 | #include "clock.h" |
33 | #include "mux.h" | 34 | #include "mux.h" |
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c index a3a94e9c9378..c143f43addcc 100644 --- a/arch/arm/mach-davinci/dm355.c +++ b/arch/arm/mach-davinci/dm355.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/serial_8250.h> | 13 | #include <linux/serial_8250.h> |
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/dma-mapping.h> | 15 | #include <linux/dma-mapping.h> |
16 | #include <linux/gpio.h> | ||
17 | 16 | ||
18 | #include <linux/spi/spi.h> | 17 | #include <linux/spi/spi.h> |
19 | 18 | ||
@@ -30,6 +29,7 @@ | |||
30 | #include <mach/common.h> | 29 | #include <mach/common.h> |
31 | #include <mach/asp.h> | 30 | #include <mach/asp.h> |
32 | #include <mach/spi.h> | 31 | #include <mach/spi.h> |
32 | #include <mach/gpio-davinci.h> | ||
33 | 33 | ||
34 | #include "clock.h" | 34 | #include "clock.h" |
35 | #include "mux.h" | 35 | #include "mux.h" |
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c index 4604e72d7d99..679e168dce34 100644 --- a/arch/arm/mach-davinci/dm365.c +++ b/arch/arm/mach-davinci/dm365.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/serial_8250.h> | 17 | #include <linux/serial_8250.h> |
18 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
19 | #include <linux/dma-mapping.h> | 19 | #include <linux/dma-mapping.h> |
20 | #include <linux/gpio.h> | ||
21 | #include <linux/spi/spi.h> | 20 | #include <linux/spi/spi.h> |
22 | 21 | ||
23 | #include <asm/mach/map.h> | 22 | #include <asm/mach/map.h> |
@@ -34,7 +33,7 @@ | |||
34 | #include <mach/asp.h> | 33 | #include <mach/asp.h> |
35 | #include <mach/keyscan.h> | 34 | #include <mach/keyscan.h> |
36 | #include <mach/spi.h> | 35 | #include <mach/spi.h> |
37 | 36 | #include <mach/gpio-davinci.h> | |
38 | 37 | ||
39 | #include "clock.h" | 38 | #include "clock.h" |
40 | #include "mux.h" | 39 | #include "mux.h" |
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c index 4c82c2716293..9a274665edc5 100644 --- a/arch/arm/mach-davinci/dm644x.c +++ b/arch/arm/mach-davinci/dm644x.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/clk.h> | 12 | #include <linux/clk.h> |
13 | #include <linux/serial_8250.h> | 13 | #include <linux/serial_8250.h> |
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/gpio.h> | ||
16 | 15 | ||
17 | #include <asm/mach/map.h> | 16 | #include <asm/mach/map.h> |
18 | 17 | ||
@@ -26,6 +25,7 @@ | |||
26 | #include <mach/serial.h> | 25 | #include <mach/serial.h> |
27 | #include <mach/common.h> | 26 | #include <mach/common.h> |
28 | #include <mach/asp.h> | 27 | #include <mach/asp.h> |
28 | #include <mach/gpio-davinci.h> | ||
29 | 29 | ||
30 | #include "clock.h" | 30 | #include "clock.h" |
31 | #include "mux.h" | 31 | #include "mux.h" |
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c index 1802e711a2b8..03e5f4931b42 100644 --- a/arch/arm/mach-davinci/dm646x.c +++ b/arch/arm/mach-davinci/dm646x.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/clk.h> | 13 | #include <linux/clk.h> |
14 | #include <linux/serial_8250.h> | 14 | #include <linux/serial_8250.h> |
15 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/gpio.h> | ||
17 | 16 | ||
18 | #include <asm/mach/map.h> | 17 | #include <asm/mach/map.h> |
19 | 18 | ||
@@ -27,6 +26,7 @@ | |||
27 | #include <mach/serial.h> | 26 | #include <mach/serial.h> |
28 | #include <mach/common.h> | 27 | #include <mach/common.h> |
29 | #include <mach/asp.h> | 28 | #include <mach/asp.h> |
29 | #include <mach/gpio-davinci.h> | ||
30 | 30 | ||
31 | #include "clock.h" | 31 | #include "clock.h" |
32 | #include "mux.h" | 32 | #include "mux.h" |
diff --git a/arch/arm/mach-davinci/include/mach/gpio-davinci.h b/arch/arm/mach-davinci/include/mach/gpio-davinci.h new file mode 100644 index 000000000000..1fdd1fd35448 --- /dev/null +++ b/arch/arm/mach-davinci/include/mach/gpio-davinci.h | |||
@@ -0,0 +1,91 @@ | |||
1 | /* | ||
2 | * TI DaVinci GPIO Support | ||
3 | * | ||
4 | * Copyright (c) 2006 David Brownell | ||
5 | * Copyright (c) 2007, MontaVista Software, Inc. <source@mvista.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #ifndef __DAVINCI_DAVINCI_GPIO_H | ||
14 | #define __DAVINCI_DAVINCI_GPIO_H | ||
15 | |||
16 | #include <linux/io.h> | ||
17 | #include <linux/spinlock.h> | ||
18 | |||
19 | #include <asm-generic/gpio.h> | ||
20 | |||
21 | #include <mach/irqs.h> | ||
22 | #include <mach/common.h> | ||
23 | |||
24 | #define DAVINCI_GPIO_BASE 0x01C67000 | ||
25 | |||
26 | enum davinci_gpio_type { | ||
27 | GPIO_TYPE_DAVINCI = 0, | ||
28 | GPIO_TYPE_TNETV107X, | ||
29 | }; | ||
30 | |||
31 | /* | ||
32 | * basic gpio routines | ||
33 | * | ||
34 | * board-specific init should be done by arch/.../.../board-XXX.c (maybe | ||
35 | * initializing banks together) rather than boot loaders; kexec() won't | ||
36 | * go through boot loaders. | ||
37 | * | ||
38 | * the gpio clock will be turned on when gpios are used, and you may also | ||
39 | * need to pay attention to PINMUX registers to be sure those pins are | ||
40 | * used as gpios, not with other peripherals. | ||
41 | * | ||
42 | * On-chip GPIOs are numbered 0..(DAVINCI_N_GPIO-1). For documentation, | ||
43 | * and maybe for later updates, code may write GPIO(N). These may be | ||
44 | * all 1.8V signals, all 3.3V ones, or a mix of the two. A given chip | ||
45 | * may not support all the GPIOs in that range. | ||
46 | * | ||
47 | * GPIOs can also be on external chips, numbered after the ones built-in | ||
48 | * to the DaVinci chip. For now, they won't be usable as IRQ sources. | ||
49 | */ | ||
50 | #define GPIO(X) (X) /* 0 <= X <= (DAVINCI_N_GPIO - 1) */ | ||
51 | |||
52 | /* Convert GPIO signal to GPIO pin number */ | ||
53 | #define GPIO_TO_PIN(bank, gpio) (16 * (bank) + (gpio)) | ||
54 | |||
55 | struct davinci_gpio_controller { | ||
56 | struct gpio_chip chip; | ||
57 | int irq_base; | ||
58 | spinlock_t lock; | ||
59 | void __iomem *regs; | ||
60 | void __iomem *set_data; | ||
61 | void __iomem *clr_data; | ||
62 | void __iomem *in_data; | ||
63 | }; | ||
64 | |||
65 | /* The __gpio_to_controller() and __gpio_mask() functions inline to constants | ||
66 | * with constant parameters; or in outlined code they execute at runtime. | ||
67 | * | ||
68 | * You'd access the controller directly when reading or writing more than | ||
69 | * one gpio value at a time, and to support wired logic where the value | ||
70 | * being driven by the cpu need not match the value read back. | ||
71 | * | ||
72 | * These are NOT part of the cross-platform GPIO interface | ||
73 | */ | ||
74 | static inline struct davinci_gpio_controller * | ||
75 | __gpio_to_controller(unsigned gpio) | ||
76 | { | ||
77 | struct davinci_gpio_controller *ctlrs = davinci_soc_info.gpio_ctlrs; | ||
78 | int index = gpio / 32; | ||
79 | |||
80 | if (!ctlrs || index >= davinci_soc_info.gpio_ctlrs_num) | ||
81 | return NULL; | ||
82 | |||
83 | return ctlrs + index; | ||
84 | } | ||
85 | |||
86 | static inline u32 __gpio_mask(unsigned gpio) | ||
87 | { | ||
88 | return 1 << (gpio % 32); | ||
89 | } | ||
90 | |||
91 | #endif /* __DAVINCI_DAVINCI_GPIO_H */ | ||
diff --git a/arch/arm/mach-davinci/include/mach/gpio.h b/arch/arm/mach-davinci/include/mach/gpio.h index 14e7bb20a33a..fbaae4772b91 100644 --- a/arch/arm/mach-davinci/include/mach/gpio.h +++ b/arch/arm/mach-davinci/include/mach/gpio.h | |||
@@ -13,82 +13,10 @@ | |||
13 | #ifndef __DAVINCI_GPIO_H | 13 | #ifndef __DAVINCI_GPIO_H |
14 | #define __DAVINCI_GPIO_H | 14 | #define __DAVINCI_GPIO_H |
15 | 15 | ||
16 | #include <linux/io.h> | ||
17 | #include <linux/spinlock.h> | ||
18 | |||
19 | #include <asm-generic/gpio.h> | 16 | #include <asm-generic/gpio.h> |
20 | 17 | ||
21 | #include <mach/irqs.h> | 18 | /* The inline versions use the static inlines in the driver header */ |
22 | #include <mach/common.h> | 19 | #include "gpio-davinci.h" |
23 | |||
24 | #define __ARM_GPIOLIB_COMPLEX | ||
25 | |||
26 | #define DAVINCI_GPIO_BASE 0x01C67000 | ||
27 | |||
28 | enum davinci_gpio_type { | ||
29 | GPIO_TYPE_DAVINCI = 0, | ||
30 | GPIO_TYPE_TNETV107X, | ||
31 | }; | ||
32 | |||
33 | /* | ||
34 | * basic gpio routines | ||
35 | * | ||
36 | * board-specific init should be done by arch/.../.../board-XXX.c (maybe | ||
37 | * initializing banks together) rather than boot loaders; kexec() won't | ||
38 | * go through boot loaders. | ||
39 | * | ||
40 | * the gpio clock will be turned on when gpios are used, and you may also | ||
41 | * need to pay attention to PINMUX registers to be sure those pins are | ||
42 | * used as gpios, not with other peripherals. | ||
43 | * | ||
44 | * On-chip GPIOs are numbered 0..(DAVINCI_N_GPIO-1). For documentation, | ||
45 | * and maybe for later updates, code may write GPIO(N). These may be | ||
46 | * all 1.8V signals, all 3.3V ones, or a mix of the two. A given chip | ||
47 | * may not support all the GPIOs in that range. | ||
48 | * | ||
49 | * GPIOs can also be on external chips, numbered after the ones built-in | ||
50 | * to the DaVinci chip. For now, they won't be usable as IRQ sources. | ||
51 | */ | ||
52 | #define GPIO(X) (X) /* 0 <= X <= (DAVINCI_N_GPIO - 1) */ | ||
53 | |||
54 | /* Convert GPIO signal to GPIO pin number */ | ||
55 | #define GPIO_TO_PIN(bank, gpio) (16 * (bank) + (gpio)) | ||
56 | |||
57 | struct davinci_gpio_controller { | ||
58 | struct gpio_chip chip; | ||
59 | int irq_base; | ||
60 | spinlock_t lock; | ||
61 | void __iomem *regs; | ||
62 | void __iomem *set_data; | ||
63 | void __iomem *clr_data; | ||
64 | void __iomem *in_data; | ||
65 | }; | ||
66 | |||
67 | /* The __gpio_to_controller() and __gpio_mask() functions inline to constants | ||
68 | * with constant parameters; or in outlined code they execute at runtime. | ||
69 | * | ||
70 | * You'd access the controller directly when reading or writing more than | ||
71 | * one gpio value at a time, and to support wired logic where the value | ||
72 | * being driven by the cpu need not match the value read back. | ||
73 | * | ||
74 | * These are NOT part of the cross-platform GPIO interface | ||
75 | */ | ||
76 | static inline struct davinci_gpio_controller * | ||
77 | __gpio_to_controller(unsigned gpio) | ||
78 | { | ||
79 | struct davinci_gpio_controller *ctlrs = davinci_soc_info.gpio_ctlrs; | ||
80 | int index = gpio / 32; | ||
81 | |||
82 | if (!ctlrs || index >= davinci_soc_info.gpio_ctlrs_num) | ||
83 | return NULL; | ||
84 | |||
85 | return ctlrs + index; | ||
86 | } | ||
87 | |||
88 | static inline u32 __gpio_mask(unsigned gpio) | ||
89 | { | ||
90 | return 1 << (gpio % 32); | ||
91 | } | ||
92 | 20 | ||
93 | /* | 21 | /* |
94 | * The get/set/clear functions will inline when called with constant | 22 | * The get/set/clear functions will inline when called with constant |
diff --git a/arch/arm/mach-davinci/tnetv107x.c b/arch/arm/mach-davinci/tnetv107x.c index c92641a8cafe..409bb869c7c7 100644 --- a/arch/arm/mach-davinci/tnetv107x.c +++ b/arch/arm/mach-davinci/tnetv107x.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <mach/irqs.h> | 30 | #include <mach/irqs.h> |
31 | #include <mach/hardware.h> | 31 | #include <mach/hardware.h> |
32 | #include <mach/tnetv107x.h> | 32 | #include <mach/tnetv107x.h> |
33 | #include <mach/gpio-davinci.h> | ||
33 | 34 | ||
34 | #include "clock.h" | 35 | #include "clock.h" |
35 | #include "mux.h" | 36 | #include "mux.h" |