diff options
author | Jonathan Corbet <corbet@lwn.net> | 2010-04-22 19:39:34 -0400 |
---|---|---|
committer | Jonathan Corbet <corbet@lwn.net> | 2010-05-07 19:17:37 -0400 |
commit | 7582eb9be85f35271fd2569681a88a5b243e9380 (patch) | |
tree | 84a234364b9e314e7b25800d473e6047da379a56 /drivers/video/via/via-gpio.c | |
parent | 75b035ace904761b8a340b524533a36e37313b29 (diff) |
viafb: Turn GPIO and i2c into proper platform devices
Another step toward making this thing a real multifunction device driver.
Cc: ScottFang@viatech.com.cn
Cc: JosephChan@via.com.tw
Cc: Harald Welte <laforge@gnumonks.org>
Acked-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'drivers/video/via/via-gpio.c')
-rw-r--r-- | drivers/video/via/via-gpio.c | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/drivers/video/via/via-gpio.c b/drivers/video/via/via-gpio.c index 6b361177bf03..44537be1f070 100644 --- a/drivers/video/via/via-gpio.c +++ b/drivers/video/via/via-gpio.c | |||
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | #include <linux/spinlock.h> | 8 | #include <linux/spinlock.h> |
9 | #include <linux/gpio.h> | 9 | #include <linux/gpio.h> |
10 | #include <linux/platform_device.h> | ||
10 | #include "via-core.h" | 11 | #include "via-core.h" |
11 | #include "via-gpio.h" | 12 | #include "via-gpio.h" |
12 | #include "global.h" | 13 | #include "global.h" |
@@ -172,12 +173,27 @@ static void viafb_gpio_disable(struct viafb_gpio *gpio) | |||
172 | via_write_reg_mask(VIASR, gpio->vg_port_index, 0, 0x02); | 173 | via_write_reg_mask(VIASR, gpio->vg_port_index, 0, 0x02); |
173 | } | 174 | } |
174 | 175 | ||
176 | /* | ||
177 | * Look up a specific gpio and return the number it was assigned. | ||
178 | */ | ||
179 | int viafb_gpio_lookup(const char *name) | ||
180 | { | ||
181 | int i; | ||
175 | 182 | ||
183 | for (i = 0; i < gpio_config.gpio_chip.ngpio; i++) | ||
184 | if (!strcmp(name, gpio_config.active_gpios[i]->vg_name)) | ||
185 | return gpio_config.gpio_chip.base + i; | ||
186 | return -1; | ||
187 | } | ||
188 | EXPORT_SYMBOL_GPL(viafb_gpio_lookup); | ||
176 | 189 | ||
177 | 190 | /* | |
178 | int viafb_create_gpios(struct viafb_dev *vdev, | 191 | * Platform device stuff. |
179 | const struct via_port_cfg *port_cfg) | 192 | */ |
193 | static __devinit int viafb_gpio_probe(struct platform_device *platdev) | ||
180 | { | 194 | { |
195 | struct viafb_dev *vdev = platdev->dev.platform_data; | ||
196 | struct via_port_cfg *port_cfg = vdev->port_cfg; | ||
181 | int i, ngpio = 0, ret; | 197 | int i, ngpio = 0, ret; |
182 | struct viafb_gpio *gpio; | 198 | struct viafb_gpio *gpio; |
183 | unsigned long flags; | 199 | unsigned long flags; |
@@ -222,11 +238,10 @@ int viafb_create_gpios(struct viafb_dev *vdev, | |||
222 | gpio_config.gpio_chip.ngpio = 0; | 238 | gpio_config.gpio_chip.ngpio = 0; |
223 | } | 239 | } |
224 | return ret; | 240 | return ret; |
225 | /* Port enable ? */ | ||
226 | } | 241 | } |
227 | 242 | ||
228 | 243 | ||
229 | int viafb_destroy_gpios(void) | 244 | static int viafb_gpio_remove(struct platform_device *platdev) |
230 | { | 245 | { |
231 | unsigned long flags; | 246 | unsigned long flags; |
232 | int ret = 0, i; | 247 | int ret = 0, i; |
@@ -253,16 +268,20 @@ out: | |||
253 | return ret; | 268 | return ret; |
254 | } | 269 | } |
255 | 270 | ||
256 | /* | 271 | static struct platform_driver via_gpio_driver = { |
257 | * Look up a specific gpio and return the number it was assigned. | 272 | .driver = { |
258 | */ | 273 | .name = "viafb-gpio", |
259 | int viafb_gpio_lookup(const char *name) | 274 | }, |
275 | .probe = viafb_gpio_probe, | ||
276 | .remove = viafb_gpio_remove, | ||
277 | }; | ||
278 | |||
279 | int viafb_gpio_init(void) | ||
260 | { | 280 | { |
261 | int i; | 281 | return platform_driver_register(&via_gpio_driver); |
282 | } | ||
262 | 283 | ||
263 | for (i = 0; i < gpio_config.gpio_chip.ngpio; i++) | 284 | void viafb_gpio_exit(void) |
264 | if (!strcmp(name, gpio_config.active_gpios[i]->vg_name)) | 285 | { |
265 | return gpio_config.gpio_chip.base + i; | 286 | platform_driver_unregister(&via_gpio_driver); |
266 | return -1; | ||
267 | } | 287 | } |
268 | EXPORT_SYMBOL_GPL(viafb_gpio_lookup); | ||