summaryrefslogtreecommitdiff
path: root/target/linux/at91
diff options
context:
space:
mode:
authorHamish Guthrie <hcg@openwrt.org>2008-07-08 06:10:59 +0000
committerHamish Guthrie <hcg@openwrt.org>2008-07-08 06:10:59 +0000
commit22754b63e7ac756b14d753fc61c6795004f79690 (patch)
treecf4d4a5b6eac561ab8d5de6712788df30ca2e4f5 /target/linux/at91
parentefd3eac055b1504ab362f2cc2874539a63d7f7bc (diff)
downloadmtk-20170518-22754b63e7ac756b14d753fc61c6795004f79690.zip
mtk-20170518-22754b63e7ac756b14d753fc61c6795004f79690.tar.gz
mtk-20170518-22754b63e7ac756b14d753fc61c6795004f79690.tar.bz2
Added gpio and led drivers for 2.6.25.10 kernel
SVN-Revision: 11745
Diffstat (limited to 'target/linux/at91')
-rw-r--r--target/linux/at91/config-2.6.2515
-rw-r--r--target/linux/at91/patches-2.6.25/002-led-driver.patch171
-rw-r--r--target/linux/at91/patches-2.6.25/003-gpio-driver.patch552
3 files changed, 734 insertions, 4 deletions
diff --git a/target/linux/at91/config-2.6.25 b/target/linux/at91/config-2.6.25
index 495706f..68faf0d 100644
--- a/target/linux/at91/config-2.6.25
+++ b/target/linux/at91/config-2.6.25
@@ -50,7 +50,7 @@ CONFIG_ARCH_SUPPORTS_AOUT=y
CONFIG_ARCH_SUSPEND_POSSIBLE=y
# CONFIG_ARCH_VERSATILE is not set
CONFIG_ARM=y
-CONFIG_ARM_AT91_ETHER=m
+CONFIG_ARM_AT91_ETHER=y
CONFIG_ARM_THUMB=y
# CONFIG_ARPD is not set
# CONFIG_ARTHUR is not set
@@ -66,6 +66,7 @@ CONFIG_AT91_PMC_UNIT=y
CONFIG_AT91_SPI=y
# CONFIG_AT91_SPIDEV is not set
CONFIG_AT91_TIMER_HZ=128
+CONFIG_AT91_VLIO=y
# CONFIG_ATMEL_PWM is not set
# CONFIG_ATMEL_SSC is not set
CONFIG_BASE_SMALL=0
@@ -77,6 +78,7 @@ CONFIG_BLK_DEV_RAM_SIZE=4096
# CONFIG_BLK_DEV_XIP is not set
# CONFIG_BONDING is not set
CONFIG_BOUNCE=y
+# CONFIG_BROADCOM_PHY is not set
# CONFIG_BSD_PROCESS_ACCT is not set
# CONFIG_BT is not set
CONFIG_CLASSIC_RCU=y
@@ -97,11 +99,13 @@ CONFIG_CRYPTO_AEAD=m
CONFIG_CRYPTO_AUTHENC=m
CONFIG_CRYPTO_GF128MUL=m
# CONFIG_DATAFLASH_ALWAYS_ADD_DEVICE is not set
+CONFIG_DAVICOM_PHY=y
# CONFIG_DEBUG_BUGVERBOSE is not set
# CONFIG_DEBUG_USER is not set
# CONFIG_DM9000 is not set
CONFIG_DUMMY_CONSOLE=y
# CONFIG_E1000E_ENABLED is not set
+# CONFIG_FIXED_PHY is not set
# CONFIG_FPE_FASTFPE is not set
CONFIG_FPE_NWFPE=y
# CONFIG_FPE_NWFPE_XP is not set
@@ -133,9 +137,7 @@ CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m
CONFIG_INITRAMFS_SOURCE=""
CONFIG_INPUT=y
CONFIG_LEDS=y
-# CONFIG_LEDS_ALIX is not set
CONFIG_LEDS_CPU=y
-# CONFIG_LEDS_GPIO is not set
CONFIG_LEGACY_PTYS=y
CONFIG_LEGACY_PTY_COUNT=32
# CONFIG_LLC2 is not set
@@ -157,7 +159,7 @@ CONFIG_LZO_DECOMPRESS=m
# CONFIG_MACH_SWEDATMS is not set
# CONFIG_MACH_TT9200 is not set
CONFIG_MACH_VLINK=y
-CONFIG_MII=m
+# CONFIG_MDIO_BITBANG is not set
CONFIG_MMC=m
CONFIG_MMC_AT91=m
CONFIG_MMC_BLOCK=m
@@ -205,6 +207,7 @@ CONFIG_MTD_PARTITIONS=y
# CONFIG_MTD_SLRAM is not set
# CONFIG_NET_IPGRE_BROADCAST is not set
# CONFIG_NET_PKTGEN is not set
+# CONFIG_NEW_LEDS is not set
# CONFIG_NF_CONNTRACK_AMANDA is not set
# CONFIG_NF_CONNTRACK_PPTP is not set
# CONFIG_NF_CONNTRACK_RTSP is not set
@@ -217,10 +220,13 @@ CONFIG_MTD_PARTITIONS=y
# CONFIG_NVRAM is not set
# CONFIG_OUTER_CACHE is not set
# CONFIG_PCI_SYSCALL is not set
+CONFIG_PHYLIB=y
# CONFIG_PPPOATM is not set
# CONFIG_PPPOL2TP is not set
# CONFIG_PPP_MULTILINK is not set
# CONFIG_PPP_SYNC_TTY is not set
+# CONFIG_QSEMI_PHY is not set
+# CONFIG_REALTEK_PHY is not set
CONFIG_RTC_LIB=y
CONFIG_RWSEM_GENERIC_SPINLOCK=y
CONFIG_SCSI_WAIT_SCAN=m
@@ -236,6 +242,7 @@ CONFIG_SERIO_RAW=y
CONFIG_SERIO_SERPORT=y
CONFIG_SLABINFO=y
# CONFIG_SMC91X is not set
+# CONFIG_SMSC_PHY is not set
# CONFIG_SOUND is not set
# CONFIG_SPARSEMEM_STATIC is not set
# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
diff --git a/target/linux/at91/patches-2.6.25/002-led-driver.patch b/target/linux/at91/patches-2.6.25/002-led-driver.patch
new file mode 100644
index 0000000..8c08c89
--- /dev/null
+++ b/target/linux/at91/patches-2.6.25/002-led-driver.patch
@@ -0,0 +1,171 @@
+diff -urN linux-2.6.25.10.old/arch/arm/mach-at91/at91rm9200_devices.c linux-2.6.25.10/arch/arm/mach-at91/at91rm9200_devices.c
+--- linux-2.6.25.10.old/arch/arm/mach-at91/at91rm9200_devices.c 2008-07-06 09:01:53.000000000 +0200
++++ linux-2.6.25.10/arch/arm/mach-at91/at91rm9200_devices.c 2008-07-06 09:47:54.000000000 +0200
+@@ -717,6 +717,26 @@
+ static void __init at91_add_device_watchdog(void) {}
+ #endif
+
++/* --------------------------------------------------------------------
++ * LEDs
++ * -------------------------------------------------------------------- */
++
++#if defined(CONFIG_LEDS)
++u8 at91_leds_cpu;
++u8 at91_leds_timer;
++
++void __init at91_init_leds(u8 cpu_led, u8 timer_led)
++{
++ /* Enable GPIO to access the LEDs */
++ at91_set_gpio_output(cpu_led, 1);
++ at91_set_gpio_output(timer_led, 1);
++
++ at91_leds_cpu = cpu_led;
++ at91_leds_timer = timer_led;
++}
++#else
++void __init at91_init_leds(u8 cpu_led, u8 timer_led) {}
++#endif
+
+ /* --------------------------------------------------------------------
+ * SSC -- Synchronous Serial Controller
+diff -urN linux-2.6.25.10.old/arch/arm/mach-at91/Makefile linux-2.6.25.10/arch/arm/mach-at91/Makefile
+--- linux-2.6.25.10.old/arch/arm/mach-at91/Makefile 2008-07-06 09:01:54.000000000 +0200
++++ linux-2.6.25.10/arch/arm/mach-at91/Makefile 2008-07-06 09:45:08.000000000 +0200
+@@ -60,7 +60,12 @@
+ obj-$(CONFIG_MACH_AT91EB01) += board-eb01.o
+
+ # Drivers
+-obj-y += leds.o
++ifeq ($(CONFIG_MACH_VLINK),y)
++led-$(CONFIG_MACH_VLINK) += vlink_leds.o
++else
++led-y += leds.o
++endif
++obj-y += $(led-y)
+ obj-$(CONFIG_FB_S1D13XXX) += ics1523.o
+
+ # Power Management
+diff -urN linux-2.6.25.10.old/arch/arm/mach-at91/vlink_leds.c linux-2.6.25.10/arch/arm/mach-at91/vlink_leds.c
+--- linux-2.6.25.10.old/arch/arm/mach-at91/vlink_leds.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.25.10/arch/arm/mach-at91/vlink_leds.c 2008-07-06 09:40:37.000000000 +0200
+@@ -0,0 +1,105 @@
++/*
++ * LED driver for Atmel AT91-based boards.
++ *
++ * Copyright (C) SAN People (Pty) Ltd
++ * Modified for FDL VersaLink Copyright (C) Guthrie Consulting
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version
++ * 2 of the License, or (at your option) any later version.
++*/
++
++#include <linux/kernel.h>
++#include <linux/module.h>
++#include <linux/init.h>
++
++#include <asm/mach-types.h>
++#include <asm/leds.h>
++#include <asm/arch/board.h>
++#include <asm/arch/gpio.h>
++
++
++static inline void at91_led_on(unsigned int led)
++{
++ at91_set_gpio_value(led, 0);
++}
++
++static inline void at91_led_off(unsigned int led)
++{
++ at91_set_gpio_value(led, 1);
++}
++
++static inline void at91_led_toggle(unsigned int led)
++{
++ unsigned long is_off = at91_get_gpio_value(led);
++ if (is_off) {
++ at91_led_on(led);
++ at91_led_off(at91_leds_cpu);
++ }
++ else {
++ at91_led_on(at91_leds_cpu);
++ at91_led_off(led);
++ }
++}
++
++
++/*
++ * Handle LED events.
++ */
++
++/*
++ * VersaLink has a single bi-coloured LED which changes colour when the
++ * polarity is reversed
++ */
++static void at91_leds_event(led_event_t evt)
++{
++ unsigned long flags;
++
++ local_irq_save(flags);
++
++ switch(evt) {
++ case led_start: /* System startup */
++ at91_led_toggle(at91_leds_timer);
++ break;
++
++ case led_stop: /* System stop / suspend */
++ at91_led_toggle(at91_leds_timer);
++ break;
++
++#ifdef CONFIG_LEDS_TIMER
++ case led_timer: /* Every 50 timer ticks */
++ at91_led_toggle(at91_leds_timer);
++ break;
++#endif
++
++#ifdef CONFIG_LEDS_CPU
++ case led_idle_start: /* Entering idle state */
++ at91_led_toggle(at91_leds_timer);
++ break;
++
++ case led_idle_end: /* Exit idle state */
++ at91_led_toggle(at91_leds_timer);
++ break;
++#endif
++
++ default:
++ break;
++ }
++
++ local_irq_restore(flags);
++}
++
++
++static int __init leds_init(void)
++{
++ if (!at91_leds_timer || !at91_leds_cpu)
++ return -ENODEV;
++
++ leds_event = at91_leds_event;
++
++ leds_event(led_start);
++ return 0;
++}
++
++__initcall(leds_init);
+diff -urN linux-2.6.25.10.old/include/asm-arm/arch-at91/board.h linux-2.6.25.10/include/asm-arm/arch-at91/board.h
+--- linux-2.6.25.10.old/include/asm-arm/arch-at91/board.h 2008-07-06 09:01:54.000000000 +0200
++++ linux-2.6.25.10/include/asm-arm/arch-at91/board.h 2008-07-06 09:56:31.000000000 +0200
+@@ -162,6 +162,11 @@
+ /* ISI */
+ extern void __init at91_add_device_isi(void);
+
++ /* LEDs */
++extern u8 at91_leds_cpu;
++extern u8 at91_leds_timer;
++extern void __init at91_init_leds(u8 cpu_led, u8 timer_led);
++
+ /* Touchscreen Controller */
+ extern void __init at91_add_device_tsadcc(void);
+
diff --git a/target/linux/at91/patches-2.6.25/003-gpio-driver.patch b/target/linux/at91/patches-2.6.25/003-gpio-driver.patch
new file mode 100644
index 0000000..e81c771
--- /dev/null
+++ b/target/linux/at91/patches-2.6.25/003-gpio-driver.patch
@@ -0,0 +1,552 @@
+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
+--- linux-2.6.25.10.old/arch/arm/mach-at91/board-vlink.c 2008-07-07 11:20:21.000000000 +0200
++++ linux-2.6.25.10/arch/arm/mach-at91/board-vlink.c 2008-07-07 12:11:40.000000000 +0200
+@@ -99,7 +99,7 @@
+ */
+
+ static struct at91_mmc_data __initdata vlink_mmc_data = {
+-// .det_pin = AT91_PIN_PB27,
++// .det_pin = AT91_PIN_PC10,
+ .slot_b = 0,
+ .wire4 = 1,
+ // .wp_pin = AT91_PIN_PA17,
+@@ -136,6 +136,7 @@
+
+ static void __init vlink_board_init(void)
+ {
++ int v100;
+ /* Serial */
+ at91_add_device_serial();
+ /* Ethernet */
+@@ -157,36 +158,66 @@
+ // at91_set_gpio_output(AT91_PIN_PB22, 1); /* this MMC card slot can optionally use SPI signaling (CS3). */
+ at91_add_device_mmc(0, &vlink_mmc_data);
+ #endif
++
++// Set VLink version PIN as an input with pull-up (V1.5 = GND)
++ at91_set_gpio_input(AT91_PIN_PC2, 1);
++ v100 = at91_get_gpio_value(AT91_PIN_PC2);
++
+ /* LEDs */
+ // at91_gpio_leds(vlink_leds, ARRAY_SIZE(vlink_leds));
+
+ /* Other LED's */
+- at91_set_gpio_output(AT91_PIN_PC7, 1); // LED FRONT AP1
+- at91_set_gpio_output(AT91_PIN_PC8, 1); // LED FRONT BP1
+- at91_set_gpio_output(AT91_PIN_PB14, 1); // LED BACK AP1
+- at91_set_gpio_output(AT91_PIN_PB15, 1); // LED BACK BP1
+- at91_set_gpio_output(AT91_PIN_PB16, 1); // LED BACK AP2
+- at91_set_gpio_output(AT91_PIN_PB17, 1); // LED BACK BP2
++ at91_set_gpio_output(AT91_PIN_PC7, 1); // LED FRONT AP1
++ at91_set_gpio_output(AT91_PIN_PC8, 1); // LED FRONT BP1
++ at91_set_gpio_output(AT91_PIN_PB14, 1); // LED BACK AP1
++ at91_set_gpio_output(AT91_PIN_PB15, 1); // LED BACK BP1
++ at91_set_gpio_output(AT91_PIN_PB16, 1); // LED BACK AP2
++ at91_set_gpio_output(AT91_PIN_PB17, 1); // LED BACK BP2
++
++/* Test jig presence detection */
++ at91_set_gpio_input(AT91_PIN_PB8, 1); // JIGPRESENT
+
+ /* SIM Cards */
+- at91_set_gpio_output(AT91_PIN_PB9, 1); // ENBSC3
+- at91_set_gpio_output(AT91_PIN_PB10, 1); // ENBSC2
+- at91_set_gpio_output(AT91_PIN_PB11, 1); // ENBSC1
++ if (at91_get_gpio_value(AT91_PIN_PB8)) {
++ at91_set_gpio_output(AT91_PIN_PB11, 0);
++ if (v100)
++ at91_set_gpio_output(AT91_PIN_PB9, 1);
++ else
++ at91_set_gpio_output(AT91_PIN_PC13, 1);
++ } else {
++ at91_set_gpio_output(AT91_PIN_PB11, 1);
++ if (v100)
++ at91_set_gpio_output(AT91_PIN_PB9, 0);
++ else
++ at91_set_gpio_output(AT91_PIN_PC13, 0);
++ }
+
+-/* GSM Module Control */
+- at91_set_gpio_output(AT91_PIN_PB12, 1); // GSMONOFF
++ at91_set_gpio_output(AT91_PIN_PB10, 1); // ENBSC2
+
+-/* Test jig presence detection */
+- at91_set_gpio_input(AT91_PIN_PB8, 1); // JIGPRESENT
++/* GSM Module Control */
++ at91_set_gpio_output(AT91_PIN_PB12, 1); // GSMONOFF
+
+ /* Power indicator */
+- at91_set_gpio_input(AT91_PIN_PB22, 1); // PWR_IND
++ at91_set_gpio_input(AT91_PIN_PB22, 1); // PWR_IND
+
+ /* USB Device control */
+- at91_set_gpio_input(AT91_PIN_PB27, 1); // UDB_CNX
+- at91_set_gpio_output(AT91_PIN_PB28, 1); // UDB_PUP
+- at91_set_multi_drive(AT91_PIN_PB28, 1); // Set to multi-drive
+-
++ at91_set_gpio_input(AT91_PIN_PB27, 1); // UDB_CNX
++ at91_set_gpio_output(AT91_PIN_PB28, 1); // UDB_PUP
++ at91_set_multi_drive(AT91_PIN_PB28, 1); // Set to multi-drive
++
++/* USB Power controls */
++
++ if (v100)
++ { // V100
++ at91_set_gpio_input (AT91_PIN_PC12, 1); // SD Card present
++ }
++ else
++ { // DO special things for V1.5
++ at91_set_gpio_output(AT91_PIN_PB9 , 0); // USB suspend
++ at91_set_gpio_input (AT91_PIN_PC10, 1); // SD Card present
++ at91_set_gpio_output(AT91_PIN_PC11, 0); // USB Vin CTRL for modules onboard
++ at91_set_gpio_output(AT91_PIN_PC12, 0); // SIM control
++ }
+ }
+
+ MACHINE_START(VLINK, "FDL VersaLink")
+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
+--- linux-2.6.25.10.old/arch/arm/mach-at91/gpio.c 2008-07-07 11:20:21.000000000 +0200
++++ linux-2.6.25.10/arch/arm/mach-at91/gpio.c 2008-07-07 11:42:33.000000000 +0200
+@@ -29,6 +29,7 @@
+
+ static struct at91_gpio_bank *gpio;
+ static int gpio_banks;
++static u32 pio_gpio_pin[4] = { 0, 0, 0, 0 };
+
+
+ static inline void __iomem *pin_to_controller(unsigned pin)
+@@ -71,9 +72,13 @@
+ {
+ void __iomem *pio = pin_to_controller(pin);
+ unsigned mask = pin_to_mask(pin);
++ int bank = (pin - PIN_BASE) / 32;
+
+ if (!pio)
+ return -EINVAL;
++
++ pio_gpio_pin[bank] |= mask;
++
+ __raw_writel(mask, pio + PIO_IDR);
+ __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
+ __raw_writel(mask, pio + PIO_PER);
+@@ -130,10 +135,13 @@
+ {
+ void __iomem *pio = pin_to_controller(pin);
+ unsigned mask = pin_to_mask(pin);
++ int bank = (pin - PIN_BASE) / 32;
+
+ if (!pio)
+ return -EINVAL;
+
++ pio_gpio_pin[bank] |= mask;
++
+ __raw_writel(mask, pio + PIO_IDR);
+ __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
+ __raw_writel(mask, pio + PIO_ODR);
+@@ -151,10 +159,13 @@
+ {
+ void __iomem *pio = pin_to_controller(pin);
+ unsigned mask = pin_to_mask(pin);
++ int bank = (pin - PIN_BASE) / 32;
+
+ if (!pio)
+ return -EINVAL;
+
++ pio_gpio_pin[bank] |= mask;
++
+ __raw_writel(mask, pio + PIO_IDR);
+ __raw_writel(mask, pio + PIO_PUDR);
+ __raw_writel(mask, pio + (value ? PIO_SODR : PIO_CODR));
+@@ -262,6 +273,18 @@
+ }
+ EXPORT_SYMBOL(at91_get_gpio_value);
+
++int at91_is_pin_gpio(unsigned pin)
++{
++ void __iomem *pio = pin_to_controller(pin);
++ unsigned mask = pin_to_mask(pin);
++ int bank = (pin - PIN_BASE) / 32;
++
++ if (!pio)
++ return -EINVAL;
++ return (pio_gpio_pin[bank] & mask) != 0;
++}
++EXPORT_SYMBOL(at91_is_pin_gpio);
++
+ /*--------------------------------------------------------------------------*/
+
+ #ifdef CONFIG_PM
+diff -urN linux-2.6.25.10.old/drivers/char/Kconfig linux-2.6.25.10/drivers/char/Kconfig
+--- linux-2.6.25.10.old/drivers/char/Kconfig 2008-07-07 11:20:21.000000000 +0200
++++ linux-2.6.25.10/drivers/char/Kconfig 2008-07-07 11:42:33.000000000 +0200
+@@ -1072,5 +1072,12 @@
+ The SPI driver gives user mode access to this serial
+ bus on the AT91RM9200 processor.
+
++config AT91_VLIO
++ tristate "Versalink LED and GPIO interface"
++ depends on ARCH_AT91RM9200 && MACH_VLINK
++ default n
++ help
++ Provides a handler GPIO's in userspace
++
+ endmenu
+
+diff -urN linux-2.6.25.10.old/drivers/char/Makefile linux-2.6.25.10/drivers/char/Makefile
+--- linux-2.6.25.10.old/drivers/char/Makefile 2008-07-07 11:20:21.000000000 +0200
++++ linux-2.6.25.10/drivers/char/Makefile 2008-07-07 11:42:33.000000000 +0200
+@@ -100,6 +100,7 @@
+ obj-$(CONFIG_TELCLOCK) += tlclk.o
+ obj-$(CONFIG_AT91_SPI) += at91_spi.o
+ obj-$(CONFIG_AT91_SPIDEV) += at91_spidev.o
++obj-$(CONFIG_AT91_VLIO) += vlink_giu.o
+
+ obj-$(CONFIG_MWAVE) += mwave/
+ obj-$(CONFIG_AGP) += agp/
+diff -urN linux-2.6.25.10.old/drivers/char/vlink_giu.c linux-2.6.25.10/drivers/char/vlink_giu.c
+--- linux-2.6.25.10.old/drivers/char/vlink_giu.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.25.10/drivers/char/vlink_giu.c 2008-07-07 13:41:51.000000000 +0200
+@@ -0,0 +1,333 @@
++/*
++ * Driver for FDL Versalink GPIO
++ *
++ * Copyright (C) 2005 Guthrie Consulting
++ * Author: Hamish Guthrie <hamish@prodigi.ch>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++ */
++
++#include <linux/module.h>
++#include <linux/moduleparam.h>
++#include <linux/init.h>
++#include <linux/platform_device.h>
++
++#include <linux/kernel.h>
++#include <linux/slab.h>
++#include <linux/fs.h>
++#include <linux/errno.h>
++#include <linux/init.h>
++#include <linux/types.h>
++#include <linux/proc_fs.h>
++#include <linux/fcntl.h>
++#include <linux/seq_file.h>
++#include <linux/cdev.h>
++#include <asm/arch/gpio.h>
++#include <asm/uaccess.h>
++
++static int major; /* default is dynamic major device number */
++module_param(major, int, 0);
++MODULE_PARM_DESC(major, "Major device number");
++
++#define VIO_NR_DEVS 96
++
++struct vio_dev {
++ struct cdev cdev;
++};
++
++struct vio_dev *vio_devices;
++static struct class *vio_class;
++
++#define MAX_VIO_NAMES 24
++typedef struct
++{
++ char port;
++ char pin;
++ char name100[10];
++ char name150[10];
++} VIO_NAMES;
++
++VIO_NAMES VioName[MAX_VIO_NAMES] =
++{ // Port, Pin, V100, V150
++ {'A',19,"port1DTR" ,"port1DTR"},
++ {'A',24,"port2DTR" ,"port2DTR"},
++ {'B',8, "jigOn" ,"jigOn"} ,
++ {'B',9, "enbSC3" ,"usbSUSPND"},
++ {'B',10,"enbSC2" ,"enbSC2"},
++ {'B',11,"enbSC1" ,"enbSC1"},
++ {'B',12,"gsmONOFF" ,"gsmONOFF"},
++ {'B',14,"ledBAP1" ,"ledBAP1"},
++ {'B',15,"ledBBP1" ,"ledBBP1"},
++ {'B',16,"ledBAP2" ,"ledBAP2"},
++ {'B',17,"ledBBP2" ,"ledBBP2"},
++ {'B',27,"udpCNX" ,"udpCNX"},
++ {'B',28,"udpPUP" ,"udpPUP"},
++ {'B',29,"port2DCD" ,"port2DCD"},
++ {'C',2, "vlVer100" ,"vlVer150"},
++ {'C',7, "ledFAP1" ,"ledFAP1"},
++ {'C',8, "ledFBP1" ,"ledFBP1"},
++ {'C',10,"vioC10" ,"sdCardON"},
++ {'C',11,"vioC11" ,"vusbCTRL"},
++ {'C',12,"sdCardON" ,"simCTRL"},
++ {'C',13,"vioC13" ,"enbSC3"},
++ {'C',14,"ledFBP2" ,"ledFBP2"},
++ {'C',15,"ledFAP2" ,"ledFAP2"},
++ {0,0,"",""}
++};
++
++/*
++{'B',18,"gsmRIO" ,"gsmRIO"},
++{'B',20,"gsmTX" ,"gsmTX"},
++{'B',21,"gsmRX" ,"gsmRX"},
++{'B',22,"gsmPIND" ,"gsmPIND"},
++{'B',23,"gsmDCD" ,"gsmDCD"},
++{'B',24,"gsmCTS" ,"gsmCTS"},
++{'B',25,"gsmDSR" ,"gsmDSR"},
++{'B',26,"gsmRTS" ,"gsmRTS"},
++*/
++static void lookupPINName(char version100, char *devName, char port, char pin);
++// EOF KWJ + AJE
++
++static ssize_t gpio_read(struct file *file, char __user *buf, size_t len,
++ loff_t *ppos)
++{
++ unsigned int pin;
++ int retval;
++ char value = '0';
++
++ pin = iminor(file->f_dentry->d_inode);
++
++ retval = at91_get_gpio_value(PIN_BASE + pin);
++ if (retval < 0)
++ return -EFAULT;
++
++ value = retval + 0x30;
++ if (put_user(value, buf))
++ return -EFAULT;
++
++ return 1;
++}
++
++static ssize_t gpio_write(struct file *file, const char __user *data,
++ size_t len, loff_t *ppos)
++{
++ unsigned int pin;
++ size_t i;
++ char c;
++ int retval = 0;
++
++ pin = iminor(file->f_dentry->d_inode);
++
++ for (i = 0; i < len; i++) {
++ if (get_user(c, data + i))
++ return -EFAULT;
++
++ switch (c) {
++ case '0':
++ case '1':
++ retval = at91_set_gpio_value(PIN_BASE + pin, (int)c - 0x30);
++ if (retval < 0)
++ return -EFAULT;
++ break;
++ default:
++ break;
++ }
++
++ if (retval < 0)
++ break;
++ }
++
++ return i;
++}
++
++static int gpio_open(struct inode *inode, struct file *file)
++{
++ return nonseekable_open(inode, file);
++}
++
++static int gpio_release(struct inode *inode, struct file *file)
++{
++ return 0;
++}
++
++static struct file_operations vio_fops = {
++ .owner = THIS_MODULE,
++ .read = gpio_read,
++ .write = gpio_write,
++ .open = gpio_open,
++ .release = gpio_release,
++};
++
++static void vio_setup_cdev(struct vio_dev *dev, int index)
++{
++ int err, devno = MKDEV(major, index);
++
++ cdev_init(&dev->cdev, &vio_fops);
++ dev->cdev.owner = THIS_MODULE;
++ dev->cdev.ops = &vio_fops;
++ err = cdev_add (&dev->cdev, devno, 1);
++ if (err)
++ printk(KERN_NOTICE "vio: Error %d adding vio%d", err, index);
++}
++
++static int vio_remove(struct platform_device *dev)
++{
++ int i;
++ dev_t devno = MKDEV(major, 0);
++
++ if (vio_devices) {
++ for(i=0; i<VIO_NR_DEVS; i++) {
++ int iodev = at91_is_pin_gpio(PIN_BASE + i);
++ if (iodev) {
++ cdev_del(&vio_devices[i].cdev);
++ class_device_destroy(vio_class, MKDEV(major, i));
++ }
++ }
++ kfree(vio_devices);
++ }
++
++ class_destroy(vio_class);
++ unregister_chrdev_region(devno, VIO_NR_DEVS);
++
++ platform_set_drvdata(dev, NULL);
++
++ return 0;
++}
++
++static int vio_probe(struct platform_device *dev)
++{
++ int retval, i, j;
++ dev_t vdev = 0;
++ char devName[30];
++ int vlinkV100;
++
++ if (major) {
++ vdev = MKDEV(major, 0);
++ retval = register_chrdev_region(vdev, VIO_NR_DEVS, "vio");
++ } else {
++ retval = alloc_chrdev_region(&vdev, 0, VIO_NR_DEVS, "vio");
++ major = MAJOR(vdev);
++ }
++ if (retval < 0) {
++ printk(KERN_WARNING "vio: can't get major %d\n", major);
++ return retval;
++ }
++
++ if (major == 0) {
++ major = retval;
++ printk(KERN_INFO "vio: major number %d\n", major);
++ }
++
++ vio_class = class_create(THIS_MODULE, "vio");
++
++ if (IS_ERR(vio_class)) {
++ printk(KERN_ERR "vio: Error creating vio class\n");
++ vio_remove(dev);
++ return PTR_ERR(vio_class);
++ }
++
++ vlinkV100 = at91_get_gpio_value(AT91_PIN_PC2); // Denotes V1.5 if GND
++
++ vio_devices = kmalloc(VIO_NR_DEVS * sizeof(struct vio_dev), GFP_KERNEL);
++ if (!vio_devices) {
++ retval = -ENOMEM;
++ goto fail;
++ }
++ memset(vio_devices, 0, VIO_NR_DEVS * sizeof(struct vio_dev));
++
++ for (i=0; i<VIO_NR_DEVS/32; i++)
++ for(j=0; j<32; j++) {
++ int iodev = at91_is_pin_gpio(PIN_BASE + i*32 + j);
++ if (iodev) {
++ vio_setup_cdev(&vio_devices[i*32 + j], i*32 + j);
++ // Lookup name of vio to create
++ lookupPINName(vlinkV100, devName, i, j);
++ class_device_create(vio_class, NULL, MKDEV(major, i*32 + j), NULL, devName);
++ }
++ }
++
++ platform_set_drvdata(dev, vio_devices);
++
++ return 0;
++
++fail:
++ vio_remove(dev);
++ return retval;
++}
++
++static void lookupPINName(char version100, char *devName, char port, char pin)
++{
++ int i = -1;
++ char found = 0;
++ while (!found)
++ {
++ i++;
++ if (i >= MAX_VIO_NAMES)
++ break;
++ if (VioName[i].port == port+'A' && VioName[i].pin == pin)
++ {
++ printk(KERN_ERR "vio++: %c%d=%s\n",VioName[i].port,VioName[i].pin,VioName[i].name150);
++ if (version100)
++ strcpy(devName, VioName[i].name100);
++ else
++ strcpy(devName, VioName[i].name150);
++ found = 1;
++ }
++ }
++ if (!found)
++ sprintf(devName, "vio%c%d", port + 'A', pin);
++}
++
++static struct platform_device *vio_platform_device;
++
++static struct platform_driver vio_driver = {
++ .probe = vio_probe,
++ .remove = vio_remove,
++ .driver = {
++ .name = "vio",
++ .owner = THIS_MODULE,
++ },
++};
++
++static int __init vio_init(void)
++{
++ int retval;
++
++ vio_platform_device = platform_device_register_simple("vio", -1, NULL, 0);
++ if (IS_ERR(vio_platform_device)) {
++ printk(KERN_WARNING "vio: device registration failed\n");
++ return PTR_ERR(vio_platform_device);
++ }
++
++ retval = platform_driver_register(&vio_driver);
++ if (retval < 0) {
++ printk(KERN_WARNING "vio: driver registration failed\n");
++ platform_device_unregister(vio_platform_device);
++ }
++
++ return retval;
++}
++
++static void __exit vio_exit(void)
++{
++ platform_driver_unregister(&vio_driver);
++ platform_device_unregister(vio_platform_device);
++}
++
++module_init(vio_init);
++module_exit(vio_exit);
++
++MODULE_AUTHOR("Hamish Guthrie <hamish@prodigi.ch>");
++MODULE_DESCRIPTION("FDL Versalink GPIO Driver");
++MODULE_LICENSE("GPL");
+--- linux-2.6.25.10.old/include/asm-arm/arch-at91/gpio.h 2008-07-03 05:46:47.000000000 +0200
++++ linux-2.6.25.10/include/asm-arm/arch-at91/gpio.h 2008-07-07 17:03:03.000000000 +0200
+@@ -199,6 +199,7 @@
+ /* callable at any time */
+ extern int at91_set_gpio_value(unsigned pin, int value);
+ extern int at91_get_gpio_value(unsigned pin);
++extern int at91_is_pin_gpio(unsigned pin);
+
+ /* callable only from core power-management code */
+ extern void at91_gpio_suspend(void);