1 diff -urN linux-2.6.25.10.old/arch/arm/mach-at91/board-vlink.c linux-2.6.25.10/arch/arm/mach-at91/board-vlink.c
2 --- linux-2.6.25.10.old/arch/arm/mach-at91/board-vlink.c 2008-07-07 11:20:21.000000000 +0200
3 +++ linux-2.6.25.10/arch/arm/mach-at91/board-vlink.c 2008-07-07 12:11:40.000000000 +0200
7 static struct at91_mmc_data __initdata vlink_mmc_data = {
8 -// .det_pin = AT91_PIN_PB27,
9 +// .det_pin = AT91_PIN_PC10,
12 // .wp_pin = AT91_PIN_PA17,
15 static void __init vlink_board_init(void)
19 at91_add_device_serial();
22 // at91_set_gpio_output(AT91_PIN_PB22, 1); /* this MMC card slot can optionally use SPI signaling (CS3). */
23 at91_add_device_mmc(0, &vlink_mmc_data);
26 +// Set VLink version PIN as an input with pull-up (V1.5 = GND)
27 + at91_set_gpio_input(AT91_PIN_PC2, 1);
28 + v100 = at91_get_gpio_value(AT91_PIN_PC2);
31 // at91_gpio_leds(vlink_leds, ARRAY_SIZE(vlink_leds));
34 - at91_set_gpio_output(AT91_PIN_PC7, 1); // LED FRONT AP1
35 - at91_set_gpio_output(AT91_PIN_PC8, 1); // LED FRONT BP1
36 - at91_set_gpio_output(AT91_PIN_PB14, 1); // LED BACK AP1
37 - at91_set_gpio_output(AT91_PIN_PB15, 1); // LED BACK BP1
38 - at91_set_gpio_output(AT91_PIN_PB16, 1); // LED BACK AP2
39 - at91_set_gpio_output(AT91_PIN_PB17, 1); // LED BACK BP2
40 + at91_set_gpio_output(AT91_PIN_PC7, 1); // LED FRONT AP1
41 + at91_set_gpio_output(AT91_PIN_PC8, 1); // LED FRONT BP1
42 + at91_set_gpio_output(AT91_PIN_PB14, 1); // LED BACK AP1
43 + at91_set_gpio_output(AT91_PIN_PB15, 1); // LED BACK BP1
44 + at91_set_gpio_output(AT91_PIN_PB16, 1); // LED BACK AP2
45 + at91_set_gpio_output(AT91_PIN_PB17, 1); // LED BACK BP2
47 +/* Test jig presence detection */
48 + at91_set_gpio_input(AT91_PIN_PB8, 1); // JIGPRESENT
51 - at91_set_gpio_output(AT91_PIN_PB9, 1); // ENBSC3
52 - at91_set_gpio_output(AT91_PIN_PB10, 1); // ENBSC2
53 - at91_set_gpio_output(AT91_PIN_PB11, 1); // ENBSC1
54 + if (at91_get_gpio_value(AT91_PIN_PB8)) {
55 + at91_set_gpio_output(AT91_PIN_PB11, 0);
57 + at91_set_gpio_output(AT91_PIN_PB9, 1);
59 + at91_set_gpio_output(AT91_PIN_PC13, 1);
61 + at91_set_gpio_output(AT91_PIN_PB11, 1);
63 + at91_set_gpio_output(AT91_PIN_PB9, 0);
65 + at91_set_gpio_output(AT91_PIN_PC13, 0);
68 -/* GSM Module Control */
69 - at91_set_gpio_output(AT91_PIN_PB12, 1); // GSMONOFF
70 + at91_set_gpio_output(AT91_PIN_PB10, 1); // ENBSC2
72 -/* Test jig presence detection */
73 - at91_set_gpio_input(AT91_PIN_PB8, 1); // JIGPRESENT
74 +/* GSM Module Control */
75 + at91_set_gpio_output(AT91_PIN_PB12, 1); // GSMONOFF
78 - at91_set_gpio_input(AT91_PIN_PB22, 1); // PWR_IND
79 + at91_set_gpio_input(AT91_PIN_PB22, 1); // PWR_IND
81 /* USB Device control */
82 - at91_set_gpio_input(AT91_PIN_PB27, 1); // UDB_CNX
83 - at91_set_gpio_output(AT91_PIN_PB28, 1); // UDB_PUP
84 - at91_set_multi_drive(AT91_PIN_PB28, 1); // Set to multi-drive
86 + at91_set_gpio_input(AT91_PIN_PB27, 1); // UDB_CNX
87 + at91_set_gpio_output(AT91_PIN_PB28, 1); // UDB_PUP
88 + at91_set_multi_drive(AT91_PIN_PB28, 1); // Set to multi-drive
90 +/* USB Power controls */
94 + at91_set_gpio_input (AT91_PIN_PC12, 1); // SD Card present
97 + { // DO special things for V1.5
98 + at91_set_gpio_output(AT91_PIN_PB9 , 0); // USB suspend
99 + at91_set_gpio_input (AT91_PIN_PC10, 1); // SD Card present
100 + at91_set_gpio_output(AT91_PIN_PC11, 0); // USB Vin CTRL for modules onboard
101 + at91_set_gpio_output(AT91_PIN_PC12, 0); // SIM control
105 MACHINE_START(VLINK, "FDL VersaLink")
106 diff -urN linux-2.6.25.10.old/arch/arm/mach-at91/gpio.c linux-2.6.25.10/arch/arm/mach-at91/gpio.c
107 --- linux-2.6.25.10.old/arch/arm/mach-at91/gpio.c 2008-07-07 11:20:21.000000000 +0200
108 +++ linux-2.6.25.10/arch/arm/mach-at91/gpio.c 2008-07-07 11:42:33.000000000 +0200
111 static struct at91_gpio_bank *gpio;
112 static int gpio_banks;
113 +static u32 pio_gpio_pin[4] = { 0, 0, 0, 0 };
116 static inline void __iomem *pin_to_controller(unsigned pin)
119 void __iomem *pio = pin_to_controller(pin);
120 unsigned mask = pin_to_mask(pin);
121 + int bank = (pin - PIN_BASE) / 32;
126 + pio_gpio_pin[bank] |= mask;
128 __raw_writel(mask, pio + PIO_IDR);
129 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
130 __raw_writel(mask, pio + PIO_PER);
131 @@ -130,10 +135,13 @@
133 void __iomem *pio = pin_to_controller(pin);
134 unsigned mask = pin_to_mask(pin);
135 + int bank = (pin - PIN_BASE) / 32;
140 + pio_gpio_pin[bank] |= mask;
142 __raw_writel(mask, pio + PIO_IDR);
143 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
144 __raw_writel(mask, pio + PIO_ODR);
145 @@ -151,10 +159,13 @@
147 void __iomem *pio = pin_to_controller(pin);
148 unsigned mask = pin_to_mask(pin);
149 + int bank = (pin - PIN_BASE) / 32;
154 + pio_gpio_pin[bank] |= mask;
156 __raw_writel(mask, pio + PIO_IDR);
157 __raw_writel(mask, pio + PIO_PUDR);
158 __raw_writel(mask, pio + (value ? PIO_SODR : PIO_CODR));
161 EXPORT_SYMBOL(at91_get_gpio_value);
163 +int at91_is_pin_gpio(unsigned pin)
165 + void __iomem *pio = pin_to_controller(pin);
166 + unsigned mask = pin_to_mask(pin);
167 + int bank = (pin - PIN_BASE) / 32;
171 + return (pio_gpio_pin[bank] & mask) != 0;
173 +EXPORT_SYMBOL(at91_is_pin_gpio);
175 /*--------------------------------------------------------------------------*/
178 diff -urN linux-2.6.25.10.old/drivers/char/Kconfig linux-2.6.25.10/drivers/char/Kconfig
179 --- linux-2.6.25.10.old/drivers/char/Kconfig 2008-07-07 11:20:21.000000000 +0200
180 +++ linux-2.6.25.10/drivers/char/Kconfig 2008-07-07 11:42:33.000000000 +0200
181 @@ -1072,5 +1072,12 @@
182 The SPI driver gives user mode access to this serial
183 bus on the AT91RM9200 processor.
186 + tristate "Versalink LED and GPIO interface"
187 + depends on ARCH_AT91RM9200 && MACH_VLINK
190 + Provides a handler GPIO's in userspace
194 diff -urN linux-2.6.25.10.old/drivers/char/Makefile linux-2.6.25.10/drivers/char/Makefile
195 --- linux-2.6.25.10.old/drivers/char/Makefile 2008-07-07 11:20:21.000000000 +0200
196 +++ linux-2.6.25.10/drivers/char/Makefile 2008-07-07 11:42:33.000000000 +0200
198 obj-$(CONFIG_TELCLOCK) += tlclk.o
199 obj-$(CONFIG_AT91_SPI) += at91_spi.o
200 obj-$(CONFIG_AT91_SPIDEV) += at91_spidev.o
201 +obj-$(CONFIG_AT91_VLIO) += vlink_giu.o
203 obj-$(CONFIG_MWAVE) += mwave/
204 obj-$(CONFIG_AGP) += agp/
205 diff -urN linux-2.6.25.10.old/drivers/char/vlink_giu.c linux-2.6.25.10/drivers/char/vlink_giu.c
206 --- linux-2.6.25.10.old/drivers/char/vlink_giu.c 1970-01-01 01:00:00.000000000 +0100
207 +++ linux-2.6.25.10/drivers/char/vlink_giu.c 2008-07-07 13:41:51.000000000 +0200
210 + * Driver for FDL Versalink GPIO
212 + * Copyright (C) 2005 Guthrie Consulting
213 + * Author: Hamish Guthrie <hamish@prodigi.ch>
215 + * This program is free software; you can redistribute it and/or modify
216 + * it under the terms of the GNU General Public License as published by
217 + * the Free Software Foundation; either version 2 of the License, or
218 + * (at your option) any later version.
220 + * This program is distributed in the hope that it will be useful,
221 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
222 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
223 + * GNU General Public License for more details.
225 + * You should have received a copy of the GNU General Public License
226 + * along with this program; if not, write to the Free Software
227 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
230 +#include <linux/module.h>
231 +#include <linux/moduleparam.h>
232 +#include <linux/init.h>
233 +#include <linux/platform_device.h>
235 +#include <linux/kernel.h>
236 +#include <linux/slab.h>
237 +#include <linux/fs.h>
238 +#include <linux/errno.h>
239 +#include <linux/init.h>
240 +#include <linux/types.h>
241 +#include <linux/proc_fs.h>
242 +#include <linux/fcntl.h>
243 +#include <linux/seq_file.h>
244 +#include <linux/cdev.h>
245 +#include <asm/arch/gpio.h>
246 +#include <asm/uaccess.h>
248 +static int major; /* default is dynamic major device number */
249 +module_param(major, int, 0);
250 +MODULE_PARM_DESC(major, "Major device number");
252 +#define VIO_NR_DEVS 96
258 +struct vio_dev *vio_devices;
259 +static struct class *vio_class;
261 +#define MAX_VIO_NAMES 24
270 +VIO_NAMES VioName[MAX_VIO_NAMES] =
271 +{ // Port, Pin, V100, V150
272 + {'A',19,"port1DTR" ,"port1DTR"},
273 + {'A',24,"port2DTR" ,"port2DTR"},
274 + {'B',8, "jigOn" ,"jigOn"} ,
275 + {'B',9, "enbSC3" ,"usbSUSPND"},
276 + {'B',10,"enbSC2" ,"enbSC2"},
277 + {'B',11,"enbSC1" ,"enbSC1"},
278 + {'B',12,"gsmONOFF" ,"gsmONOFF"},
279 + {'B',14,"ledBAP1" ,"ledBAP1"},
280 + {'B',15,"ledBBP1" ,"ledBBP1"},
281 + {'B',16,"ledBAP2" ,"ledBAP2"},
282 + {'B',17,"ledBBP2" ,"ledBBP2"},
283 + {'B',27,"udpCNX" ,"udpCNX"},
284 + {'B',28,"udpPUP" ,"udpPUP"},
285 + {'B',29,"port2DCD" ,"port2DCD"},
286 + {'C',2, "vlVer100" ,"vlVer150"},
287 + {'C',7, "ledFAP1" ,"ledFAP1"},
288 + {'C',8, "ledFBP1" ,"ledFBP1"},
289 + {'C',10,"vioC10" ,"sdCardON"},
290 + {'C',11,"vioC11" ,"vusbCTRL"},
291 + {'C',12,"sdCardON" ,"simCTRL"},
292 + {'C',13,"vioC13" ,"enbSC3"},
293 + {'C',14,"ledFBP2" ,"ledFBP2"},
294 + {'C',15,"ledFAP2" ,"ledFAP2"},
299 +{'B',18,"gsmRIO" ,"gsmRIO"},
300 +{'B',20,"gsmTX" ,"gsmTX"},
301 +{'B',21,"gsmRX" ,"gsmRX"},
302 +{'B',22,"gsmPIND" ,"gsmPIND"},
303 +{'B',23,"gsmDCD" ,"gsmDCD"},
304 +{'B',24,"gsmCTS" ,"gsmCTS"},
305 +{'B',25,"gsmDSR" ,"gsmDSR"},
306 +{'B',26,"gsmRTS" ,"gsmRTS"},
308 +static void lookupPINName(char version100, char *devName, char port, char pin);
311 +static ssize_t gpio_read(struct file *file, char __user *buf, size_t len,
318 + pin = iminor(file->f_dentry->d_inode);
320 + retval = at91_get_gpio_value(PIN_BASE + pin);
324 + value = retval + 0x30;
325 + if (put_user(value, buf))
331 +static ssize_t gpio_write(struct file *file, const char __user *data,
332 + size_t len, loff_t *ppos)
339 + pin = iminor(file->f_dentry->d_inode);
341 + for (i = 0; i < len; i++) {
342 + if (get_user(c, data + i))
348 + retval = at91_set_gpio_value(PIN_BASE + pin, (int)c - 0x30);
363 +static int gpio_open(struct inode *inode, struct file *file)
365 + return nonseekable_open(inode, file);
368 +static int gpio_release(struct inode *inode, struct file *file)
373 +static struct file_operations vio_fops = {
374 + .owner = THIS_MODULE,
376 + .write = gpio_write,
378 + .release = gpio_release,
381 +static void vio_setup_cdev(struct vio_dev *dev, int index)
383 + int err, devno = MKDEV(major, index);
385 + cdev_init(&dev->cdev, &vio_fops);
386 + dev->cdev.owner = THIS_MODULE;
387 + dev->cdev.ops = &vio_fops;
388 + err = cdev_add (&dev->cdev, devno, 1);
390 + printk(KERN_NOTICE "vio: Error %d adding vio%d", err, index);
393 +static int vio_remove(struct platform_device *dev)
396 + dev_t devno = MKDEV(major, 0);
399 + for(i=0; i<VIO_NR_DEVS; i++) {
400 + int iodev = at91_is_pin_gpio(PIN_BASE + i);
402 + cdev_del(&vio_devices[i].cdev);
403 + class_device_destroy(vio_class, MKDEV(major, i));
406 + kfree(vio_devices);
409 + class_destroy(vio_class);
410 + unregister_chrdev_region(devno, VIO_NR_DEVS);
412 + platform_set_drvdata(dev, NULL);
417 +static int vio_probe(struct platform_device *dev)
425 + vdev = MKDEV(major, 0);
426 + retval = register_chrdev_region(vdev, VIO_NR_DEVS, "vio");
428 + retval = alloc_chrdev_region(&vdev, 0, VIO_NR_DEVS, "vio");
429 + major = MAJOR(vdev);
432 + printk(KERN_WARNING "vio: can't get major %d\n", major);
438 + printk(KERN_INFO "vio: major number %d\n", major);
441 + vio_class = class_create(THIS_MODULE, "vio");
443 + if (IS_ERR(vio_class)) {
444 + printk(KERN_ERR "vio: Error creating vio class\n");
446 + return PTR_ERR(vio_class);
449 + vlinkV100 = at91_get_gpio_value(AT91_PIN_PC2); // Denotes V1.5 if GND
451 + vio_devices = kmalloc(VIO_NR_DEVS * sizeof(struct vio_dev), GFP_KERNEL);
452 + if (!vio_devices) {
456 + memset(vio_devices, 0, VIO_NR_DEVS * sizeof(struct vio_dev));
458 + for (i=0; i<VIO_NR_DEVS/32; i++)
459 + for(j=0; j<32; j++) {
460 + int iodev = at91_is_pin_gpio(PIN_BASE + i*32 + j);
462 + vio_setup_cdev(&vio_devices[i*32 + j], i*32 + j);
463 + // Lookup name of vio to create
464 + lookupPINName(vlinkV100, devName, i, j);
465 + class_device_create(vio_class, NULL, MKDEV(major, i*32 + j), NULL, devName);
469 + platform_set_drvdata(dev, vio_devices);
478 +static void lookupPINName(char version100, char *devName, char port, char pin)
485 + if (i >= MAX_VIO_NAMES)
487 + if (VioName[i].port == port+'A' && VioName[i].pin == pin)
489 + printk(KERN_ERR "vio++: %c%d=%s\n",VioName[i].port,VioName[i].pin,VioName[i].name150);
491 + strcpy(devName, VioName[i].name100);
493 + strcpy(devName, VioName[i].name150);
498 + sprintf(devName, "vio%c%d", port + 'A', pin);
501 +static struct platform_device *vio_platform_device;
503 +static struct platform_driver vio_driver = {
504 + .probe = vio_probe,
505 + .remove = vio_remove,
508 + .owner = THIS_MODULE,
512 +static int __init vio_init(void)
516 + vio_platform_device = platform_device_register_simple("vio", -1, NULL, 0);
517 + if (IS_ERR(vio_platform_device)) {
518 + printk(KERN_WARNING "vio: device registration failed\n");
519 + return PTR_ERR(vio_platform_device);
522 + retval = platform_driver_register(&vio_driver);
524 + printk(KERN_WARNING "vio: driver registration failed\n");
525 + platform_device_unregister(vio_platform_device);
531 +static void __exit vio_exit(void)
533 + platform_driver_unregister(&vio_driver);
534 + platform_device_unregister(vio_platform_device);
537 +module_init(vio_init);
538 +module_exit(vio_exit);
540 +MODULE_AUTHOR("Hamish Guthrie <hamish@prodigi.ch>");
541 +MODULE_DESCRIPTION("FDL Versalink GPIO Driver");
542 +MODULE_LICENSE("GPL");
543 --- linux-2.6.25.10.old/include/asm-arm/arch-at91/gpio.h 2008-07-03 05:46:47.000000000 +0200
544 +++ linux-2.6.25.10/include/asm-arm/arch-at91/gpio.h 2008-07-07 17:03:03.000000000 +0200
546 /* callable at any time */
547 extern int at91_set_gpio_value(unsigned pin, int value);
548 extern int at91_get_gpio_value(unsigned pin);
549 +extern int at91_is_pin_gpio(unsigned pin);
551 /* callable only from core power-management code */
552 extern void at91_gpio_suspend(void);