diff options
author | Ben Dooks <ben-linux@fluff.org> | 2008-10-31 12:14:32 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2008-12-15 18:33:42 -0500 |
commit | 8a53bdb907cb924ed30f79bcfe7f4f15ff7de15e (patch) | |
tree | e2bca4f6a4988f4eeb79ff18ac782b2383d1cf92 /arch/arm/plat-s3c | |
parent | 7db6c82a37beabef7b76d232e3d20efacd74bd3a (diff) |
[ARM] S3C: Add GPIO chip tracking
The gpiolib driver keeps its chip array to itself
and having a separate array for s3c-only gpios stops
any non-s3c gpio being used in one of the s3c specific
configuration calls.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm/plat-s3c')
-rw-r--r-- | arch/arm/plat-s3c/Kconfig | 6 | ||||
-rw-r--r-- | arch/arm/plat-s3c/gpio.c | 21 | ||||
-rw-r--r-- | arch/arm/plat-s3c/include/plat/gpio-core.h | 23 |
3 files changed, 49 insertions, 1 deletions
diff --git a/arch/arm/plat-s3c/Kconfig b/arch/arm/plat-s3c/Kconfig index d7767e0305d0..77fc38f51874 100644 --- a/arch/arm/plat-s3c/Kconfig +++ b/arch/arm/plat-s3c/Kconfig | |||
@@ -114,6 +114,12 @@ config S3C_GPIO_SPACE | |||
114 | one bank to another to be caught, at the expense of using a little | 114 | one bank to another to be caught, at the expense of using a little |
115 | more memory. | 115 | more memory. |
116 | 116 | ||
117 | config S3C_GPIO_TRACK | ||
118 | bool | ||
119 | help | ||
120 | Internal configuration option to enable the s3c specific gpio | ||
121 | chip tracking if the platform requires it. | ||
122 | |||
117 | # device definitions to compile in | 123 | # device definitions to compile in |
118 | 124 | ||
119 | config S3C_DEV_HSMMC | 125 | config S3C_DEV_HSMMC |
diff --git a/arch/arm/plat-s3c/gpio.c b/arch/arm/plat-s3c/gpio.c index f035d4550c43..d71dd6d9ce5c 100644 --- a/arch/arm/plat-s3c/gpio.c +++ b/arch/arm/plat-s3c/gpio.c | |||
@@ -18,6 +18,22 @@ | |||
18 | 18 | ||
19 | #include <plat/gpio-core.h> | 19 | #include <plat/gpio-core.h> |
20 | 20 | ||
21 | #ifdef CONFIG_S3C_GPIO_TRACK | ||
22 | struct s3c_gpio_chip *s3c_gpios[S3C_GPIO_END]; | ||
23 | |||
24 | static __init void s3c_gpiolib_track(struct s3c_gpio_chip *chip) | ||
25 | { | ||
26 | unsigned int gpn; | ||
27 | int i; | ||
28 | |||
29 | gpn = chip->chip.base; | ||
30 | for (i = 0; i < chip->chip.ngpio; i++, gpn++) { | ||
31 | BUG_ON(gpn > ARRAY_SIZE(s3c_gpios)); | ||
32 | s3c_gpios[gpn] = chip; | ||
33 | } | ||
34 | } | ||
35 | #endif /* CONFIG_S3C_GPIO_TRACK */ | ||
36 | |||
21 | /* Default routines for controlling GPIO, based on the original S3C24XX | 37 | /* Default routines for controlling GPIO, based on the original S3C24XX |
22 | * GPIO functions which deal with the case where each gpio bank of the | 38 | * GPIO functions which deal with the case where each gpio bank of the |
23 | * chip is as following: | 39 | * chip is as following: |
@@ -109,6 +125,7 @@ static int s3c_gpiolib_get(struct gpio_chip *chip, unsigned offset) | |||
109 | __init void s3c_gpiolib_add(struct s3c_gpio_chip *chip) | 125 | __init void s3c_gpiolib_add(struct s3c_gpio_chip *chip) |
110 | { | 126 | { |
111 | struct gpio_chip *gc = &chip->chip; | 127 | struct gpio_chip *gc = &chip->chip; |
128 | int ret; | ||
112 | 129 | ||
113 | BUG_ON(!chip->base); | 130 | BUG_ON(!chip->base); |
114 | BUG_ON(!gc->label); | 131 | BUG_ON(!gc->label); |
@@ -124,5 +141,7 @@ __init void s3c_gpiolib_add(struct s3c_gpio_chip *chip) | |||
124 | gc->get = s3c_gpiolib_get; | 141 | gc->get = s3c_gpiolib_get; |
125 | 142 | ||
126 | /* gpiochip_add() prints own failure message on error. */ | 143 | /* gpiochip_add() prints own failure message on error. */ |
127 | gpiochip_add(gc); | 144 | ret = gpiochip_add(gc); |
145 | if (ret >= 0) | ||
146 | s3c_gpiolib_track(chip); | ||
128 | } | 147 | } |
diff --git a/arch/arm/plat-s3c/include/plat/gpio-core.h b/arch/arm/plat-s3c/include/plat/gpio-core.h index 3cb9105c4811..ad68b32a7f9d 100644 --- a/arch/arm/plat-s3c/include/plat/gpio-core.h +++ b/arch/arm/plat-s3c/include/plat/gpio-core.h | |||
@@ -47,3 +47,26 @@ static inline struct s3c_gpio_chip *to_s3c_gpio(struct gpio_chip *gpc) | |||
47 | * other parts of the system. | 47 | * other parts of the system. |
48 | */ | 48 | */ |
49 | extern void s3c_gpiolib_add(struct s3c_gpio_chip *chip); | 49 | extern void s3c_gpiolib_add(struct s3c_gpio_chip *chip); |
50 | |||
51 | |||
52 | /* CONFIG_S3C_GPIO_TRACK enables the tracking of the s3c specific gpios | ||
53 | * for use with the configuration calls, and other parts of the s3c gpiolib | ||
54 | * support code. | ||
55 | * | ||
56 | * Not all s3c support code will need this, as some configurations of cpu | ||
57 | * may only support one or two different configuration options and have an | ||
58 | * easy gpio to s3c_gpio_chip mapping function. If this is the case, then | ||
59 | * the machine support file should provide its own s3c_gpiolib_getchip() | ||
60 | * and any other necessary functions. | ||
61 | */ | ||
62 | |||
63 | #ifdef CONFIG_S3C_GPIO_TRACK | ||
64 | extern struct s3c_gpio_chip *s3c_gpios[S3C_GPIO_END]; | ||
65 | |||
66 | static inline struct s3c_gpio_chip *s3c_gpiolib_getchip(unsigned int chip) | ||
67 | { | ||
68 | return s3c_gpios[chip]; | ||
69 | } | ||
70 | #else | ||
71 | static inline void s3c_gpiolib_track(struct s3c_gpio_chip *chip) { } | ||
72 | #endif | ||