1 --- linux-2.6.21.1.orig/arch/arm/mach-at91/gpio.c 2007-04-27 23:49:26.000000000 +0200
2 +++ linux-2.6.21.1/arch/arm/mach-at91/gpio.c 2007-05-28 15:30:48.000000000 +0200
5 static struct at91_gpio_bank *gpio;
7 +static u32 pio_gpio_pin[4] = { 0, 0, 0, 0 };
10 static inline void __iomem *pin_to_controller(unsigned pin)
13 void __iomem *pio = pin_to_controller(pin);
14 unsigned mask = pin_to_mask(pin);
15 + int bank = (pin - PIN_BASE) / 32;
20 + pio_gpio_pin[bank] |= mask;
22 __raw_writel(mask, pio + PIO_IDR);
23 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
24 __raw_writel(mask, pio + PIO_PER);
27 void __iomem *pio = pin_to_controller(pin);
28 unsigned mask = pin_to_mask(pin);
29 + int bank = (pin - PIN_BASE) / 32;
34 + pio_gpio_pin[bank] |= mask;
36 __raw_writel(mask, pio + PIO_IDR);
37 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
38 __raw_writel(mask, pio + PIO_ODR);
41 void __iomem *pio = pin_to_controller(pin);
42 unsigned mask = pin_to_mask(pin);
43 + int bank = (pin - PIN_BASE) / 32;
48 + pio_gpio_pin[bank] |= mask;
50 __raw_writel(mask, pio + PIO_IDR);
51 __raw_writel(mask, pio + PIO_PUDR);
52 __raw_writel(mask, pio + (value ? PIO_SODR : PIO_CODR));
55 EXPORT_SYMBOL(at91_get_gpio_value);
57 +int at91_is_pin_gpio(unsigned pin)
59 + void __iomem *pio = pin_to_controller(pin);
60 + unsigned mask = pin_to_mask(pin);
61 + int bank = (pin - PIN_BASE) / 32;
65 + return (pio_gpio_pin[bank] & mask) != 0;
67 +EXPORT_SYMBOL(at91_is_pin_gpio);
69 /*--------------------------------------------------------------------------*/
72 --- linux-2.6.21.1.orig/drivers/char/Kconfig 2007-05-28 12:22:29.000000000 +0200
73 +++ linux-2.6.21.1/drivers/char/Kconfig 2007-05-28 15:37:43.000000000 +0200
74 @@ -1087,5 +1087,12 @@
75 The SPI driver gives user mode access to this serial
76 bus on the AT91RM9200 processor.
79 + tristate "Versalink LED and GPIO interface"
80 + depends on ARCH_AT91RM9200 && MACH_VLINK
83 + Provides a handler GPIO's in userspace
87 --- linux-2.6.21.1.orig/drivers/char/Makefile 2007-05-28 12:22:29.000000000 +0200
88 +++ linux-2.6.21.1/drivers/char/Makefile 2007-05-28 15:38:11.000000000 +0200
90 obj-$(CONFIG_TELCLOCK) += tlclk.o
91 obj-$(CONFIG_AT91_SPI) += at91_spi.o
92 obj-$(CONFIG_AT91_SPIDEV) += at91_spidev.o
93 +obj-$(CONFIG_AT91_VLIO) += vlink_giu.o
95 obj-$(CONFIG_WATCHDOG) += watchdog/
96 obj-$(CONFIG_MWAVE) += mwave/
97 --- linux-2.6.21.1.orig/drivers/char/vlink_giu.c 1970-01-01 01:00:00.000000000 +0100
98 +++ linux-2.6.21.1/drivers/char/vlink_giu.c 2007-05-28 15:39:47.000000000 +0200
101 + * Driver for FDL Versalink GPIO
103 + * Copyright (C) 2005 Guthrie Consulting
104 + * Author: Hamish Guthrie <hamish@prodigi.ch>
106 + * This program is free software; you can redistribute it and/or modify
107 + * it under the terms of the GNU General Public License as published by
108 + * the Free Software Foundation; either version 2 of the License, or
109 + * (at your option) any later version.
111 + * This program is distributed in the hope that it will be useful,
112 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
113 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
114 + * GNU General Public License for more details.
116 + * You should have received a copy of the GNU General Public License
117 + * along with this program; if not, write to the Free Software
118 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
121 +#include <linux/module.h>
122 +#include <linux/moduleparam.h>
123 +#include <linux/init.h>
124 +#include <linux/platform_device.h>
126 +#include <linux/kernel.h>
127 +#include <linux/slab.h>
128 +#include <linux/fs.h>
129 +#include <linux/errno.h>
130 +#include <linux/init.h>
131 +#include <linux/types.h>
132 +#include <linux/proc_fs.h>
133 +#include <linux/fcntl.h>
134 +#include <linux/seq_file.h>
135 +#include <linux/cdev.h>
136 +#include <asm/arch/gpio.h>
137 +#include <asm/uaccess.h>
139 +static int major; /* default is dynamic major device number */
140 +module_param(major, int, 0);
141 +MODULE_PARM_DESC(major, "Major device number");
143 +#define VIO_NR_DEVS 96
149 +struct vio_dev *vio_devices;
150 +static struct class *vio_class;
152 +static ssize_t gpio_read(struct file *file, char __user *buf, size_t len,
159 + pin = iminor(file->f_dentry->d_inode);
161 + retval = at91_get_gpio_value(PIN_BASE + pin);
165 + value = retval + 0x30;
166 + if (put_user(value, buf))
172 +static ssize_t gpio_write(struct file *file, const char __user *data,
173 + size_t len, loff_t *ppos)
180 + pin = iminor(file->f_dentry->d_inode);
182 + for (i = 0; i < len; i++) {
183 + if (get_user(c, data + i))
189 + retval = at91_set_gpio_value(PIN_BASE + pin, (int)c - 0x30);
204 +static int gpio_open(struct inode *inode, struct file *file)
206 + return nonseekable_open(inode, file);
209 +static int gpio_release(struct inode *inode, struct file *file)
214 +static struct file_operations vio_fops = {
215 + .owner = THIS_MODULE,
217 + .write = gpio_write,
219 + .release = gpio_release,
222 +static void vio_setup_cdev(struct vio_dev *dev, int index)
224 + int err, devno = MKDEV(major, index);
226 + cdev_init(&dev->cdev, &vio_fops);
227 + dev->cdev.owner = THIS_MODULE;
228 + dev->cdev.ops = &vio_fops;
229 + err = cdev_add (&dev->cdev, devno, 1);
231 + printk(KERN_NOTICE "vio: Error %d adding vio%d", err, index);
234 +static int vio_remove(struct platform_device *dev)
237 + dev_t devno = MKDEV(major, 0);
240 + for(i=0; i<VIO_NR_DEVS; i++) {
241 + int iodev = at91_is_pin_gpio(PIN_BASE + i);
243 + cdev_del(&vio_devices[i].cdev);
244 + class_device_destroy(vio_class, MKDEV(major, i));
247 + kfree(vio_devices);
250 + class_destroy(vio_class);
251 + unregister_chrdev_region(devno, VIO_NR_DEVS);
253 + platform_set_drvdata(dev, NULL);
258 +static int vio_probe(struct platform_device *dev)
264 + vdev = MKDEV(major, 0);
265 + retval = register_chrdev_region(vdev, VIO_NR_DEVS, "vio");
267 + retval = alloc_chrdev_region(&vdev, 0, VIO_NR_DEVS, "vio");
268 + major = MAJOR(vdev);
271 + printk(KERN_WARNING "vio: can't get major %d\n", major);
277 + printk(KERN_INFO "vio: major number %d\n", major);
280 + vio_class = class_create(THIS_MODULE, "vio");
282 + if (IS_ERR(vio_class)) {
283 + printk(KERN_ERR "vio: Error creating vio class\n");
285 + return PTR_ERR(vio_class);
288 + vio_devices = kmalloc(VIO_NR_DEVS * sizeof(struct vio_dev), GFP_KERNEL);
289 + if (!vio_devices) {
293 + memset(vio_devices, 0, VIO_NR_DEVS * sizeof(struct vio_dev));
295 + for (i=0; i<VIO_NR_DEVS/32; i++)
296 + for(j=0; j<32; j++) {
297 + int iodev = at91_is_pin_gpio(PIN_BASE + i*32 + j);
299 + vio_setup_cdev(&vio_devices[i*32 + j], i*32 + j);
300 + class_device_create(vio_class, NULL, MKDEV(major, i*32 + j), NULL,
301 + "vio%c%d", i + 'A', j);
305 + platform_set_drvdata(dev, vio_devices);
314 +static struct platform_device *vio_platform_device;
316 +static struct platform_driver vio_driver = {
317 + .probe = vio_probe,
318 + .remove = vio_remove,
321 + .owner = THIS_MODULE,
325 +static int __init vio_init(void)
329 + vio_platform_device = platform_device_register_simple("vio", -1, NULL, 0);
330 + if (IS_ERR(vio_platform_device)) {
331 + printk(KERN_WARNING "vio: device registration failed\n");
332 + return PTR_ERR(vio_platform_device);
335 + retval = platform_driver_register(&vio_driver);
337 + printk(KERN_WARNING "vio: driver registration failed\n");
338 + platform_device_unregister(vio_platform_device);
344 +static void __exit vio_exit(void)
346 + platform_driver_unregister(&vio_driver);
347 + platform_device_unregister(vio_platform_device);
350 +module_init(vio_init);
351 +module_exit(vio_exit);
353 +MODULE_AUTHOR("Hamish Guthrie <hamish@prodigi.ch>");
354 +MODULE_DESCRIPTION("FDL Versalink GPIO Driver");
355 +MODULE_LICENSE("GPL");