aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
Diffstat (limited to 'target')
-rw-r--r--target/linux/at91-2.6/patches-2.6.22/001-vlink-machine.patch246
-rw-r--r--target/linux/at91-2.6/patches-2.6.22/002-led-driver.patch121
-rw-r--r--target/linux/at91-2.6/patches-2.6.22/003-gpio-driver.patch359
-rw-r--r--target/linux/at91-2.6/patches-2.6.22/007-mtd-partition.patch39
-rw-r--r--target/linux/at91-2.6/patches-2.6.22/008-fdl-serial.patch160
-rw-r--r--target/linux/at91-2.6/patches-2.6.22/009-fdl-uartinit.patch27
-rw-r--r--target/linux/at91-2.6/patches-2.6.22/010-dm9161a-phyfix.patch28
-rw-r--r--target/linux/at91-2.6/patches-2.6.22/014-initpartition.patch19
8 files changed, 999 insertions, 0 deletions
diff --git a/target/linux/at91-2.6/patches-2.6.22/001-vlink-machine.patch b/target/linux/at91-2.6/patches-2.6.22/001-vlink-machine.patch
new file mode 100644
index 0000000000..d52c4526ec
--- /dev/null
+++ b/target/linux/at91-2.6/patches-2.6.22/001-vlink-machine.patch
@@ -0,0 +1,246 @@
+diff -urN linux-2.6.22.1.old/arch/arm/boot/compressed/head-at91rm9200.S linux-2.6.22.1/arch/arm/boot/compressed/head-at91rm9200.S
+--- linux-2.6.22.1.old/arch/arm/boot/compressed/head-at91rm9200.S 2007-07-29 06:33:09.000000000 +0200
++++ linux-2.6.22.1/arch/arm/boot/compressed/head-at91rm9200.S 2007-07-29 06:39:45.000000000 +0200
+@@ -67,6 +67,12 @@
+ cmp r7, r3
+ beq 99f
+
++ @ FDL Versalink : 1053
++ mov r3, #(MACH_TYPE_VLINK & 0xff)
++ orr r3, r3, #(MACH_TYPE_VLINK & 0xff00)
++ cmp r7, r3
++ beq 99f
++
+ @ Ajeco 1ARM : 1075
+ mov r3, #(MACH_TYPE_ONEARM & 0xff)
+ orr r3, r3, #(MACH_TYPE_ONEARM & 0xff00)
+diff -urN linux-2.6.22.1.old/arch/arm/mach-at91/board-vlink.c linux-2.6.22.1/arch/arm/mach-at91/board-vlink.c
+--- linux-2.6.22.1.old/arch/arm/mach-at91/board-vlink.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/arch/arm/mach-at91/board-vlink.c 2007-07-29 06:40:47.000000000 +0200
+@@ -0,0 +1,191 @@
++/*
++ * linux/arch/arm/mach-at91/board-vlink.c
++ *
++ * Copyright (C) 2005 SAN People
++ * Copyright (C) 2006,2007 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.
++ *
++ * 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/types.h>
++#include <linux/init.h>
++#include <linux/mm.h>
++#include <linux/module.h>
++#include <linux/platform_device.h>
++#include <linux/spi/spi.h>
++#include <linux/mtd/physmap.h>
++
++#include <asm/hardware.h>
++#include <asm/setup.h>
++#include <asm/mach-types.h>
++#include <asm/irq.h>
++
++#include <asm/mach/arch.h>
++#include <asm/mach/map.h>
++#include <asm/mach/irq.h>
++
++#include <asm/arch/board.h>
++#include <asm/arch/gpio.h>
++#include <asm/arch/at91rm9200_mc.h>
++
++#include "generic.h"
++
++
++/*
++ * Serial port configuration.
++ * 0 .. 3 = USART0 .. USART3
++ * 4 = DBGU
++ */
++static struct at91_uart_config __initdata vlink_uart_config = {
++ .console_tty = 0, /* ttyS0 */
++ .nr_tty = 5,
++ .tty_map = { 4, 1, 0, 3, 2 } /* ttyS0, ..., ttyS4 */
++};
++
++static void __init vlink_map_io(void)
++{
++ /* Initialize processor: 18.432 MHz crystal */
++ at91rm9200_initialize(18432000, AT91RM9200_PQFP);
++
++ /* Setup the LEDs */
++ at91_init_leds(AT91_PIN_PC14, AT91_PIN_PC15);
++
++ /* Setup the serial ports and console */
++ at91_init_serial(&vlink_uart_config);
++}
++
++static void __init vlink_init_irq(void)
++{
++ at91rm9200_init_interrupts(NULL);
++}
++
++static struct at91_eth_data __initdata vlink_eth_data = {
++ .phy_irq_pin = AT91_PIN_PC4,
++ .is_rmii = 1,
++};
++
++static struct at91_usbh_data __initdata vlink_usbh_data = {
++ .ports = 1,
++};
++
++/*
++static struct at91_udc_data __initdata vlink_udc_data = {
++ .vbus_pin = AT91_PIN_PD4,
++ .pullup_pin = AT91_PIN_PD5,
++};
++*/
++
++static struct at91_mmc_data __initdata vlink_mmc_data = {
++// .det_pin = AT91_PIN_PB27,
++ .slot_b = 0,
++ .wire4 = 1,
++// .wp_pin = AT91_PIN_PA17,
++};
++
++static struct spi_board_info vlink_spi_devices[] = {
++ { /* DataFlash chip */
++ .modalias = "mtd_dataflash",
++ .chip_select = 0,
++ .max_speed_hz = 15 * 1000 * 1000,
++ },
++#ifdef CONFIG_MTD_AT91_DATAFLASH_CARD
++ { /* DataFlash card */
++ .modalias = "mtd_dataflash",
++ .chip_select = 3,
++ .max_speed_hz = 15 * 1000 * 1000,
++ },
++#endif
++};
++
++/*static struct at91_gpio_led vlink_leds[] = {
++ {
++ .name = "led0",
++ .gpio = AT91_PIN_PC14,
++ .trigger = "heartbeat",
++ },
++ {
++ .name = "led1",
++ .gpio = AT91_PIN_PC15,
++ .trigger = "timer",
++ }
++};
++*/
++
++static void __init vlink_board_init(void)
++{
++ /* Serial */
++ at91_add_device_serial();
++ /* Ethernet */
++ at91_add_device_eth(&vlink_eth_data);
++ /* USB Host */
++ at91_add_device_usbh(&vlink_usbh_data);
++ /* USB Device */
++// at91_add_device_udc(&vlink_udc_data);
++// at91_set_multi_drive(vlink_udc_data.pullup_pin, 1); /* pullup_pin is connected to reset */
++ /* I2C */
++ at91_add_device_i2c();
++ /* SPI */
++ at91_add_device_spi(vlink_spi_devices, ARRAY_SIZE(vlink_spi_devices));
++#ifdef CONFIG_MTD_AT91_DATAFLASH_CARD
++ /* DataFlash card */
++// at91_set_gpio_output(AT91_PIN_PB22, 0);
++#else
++ /* MMC */
++// 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
++ /* 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
++
++/* 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
++
++/* GSM Module Control */
++ at91_set_gpio_output(AT91_PIN_PB12, 1); // GSMONOFF
++
++/* Test jig presence detection */
++ at91_set_gpio_input(AT91_PIN_PB8, 1); // JIGPRESENT
++
++/* Power indicator */
++ 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
++
++}
++
++MACHINE_START(VLINK, "FDL VersaLink")
++ /* Maintainer: Guthrie Consulting */
++ .phys_io = AT91_BASE_SYS,
++ .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
++ .boot_params = AT91_SDRAM_BASE + 0x100,
++ .timer = &at91rm9200_timer,
++ .map_io = vlink_map_io,
++ .init_irq = vlink_init_irq,
++ .init_machine = vlink_board_init,
++MACHINE_END
+diff -urN linux-2.6.22.1.old/arch/arm/mach-at91/Kconfig linux-2.6.22.1/arch/arm/mach-at91/Kconfig
+--- linux-2.6.22.1.old/arch/arm/mach-at91/Kconfig 2007-07-29 06:33:09.000000000 +0200
++++ linux-2.6.22.1/arch/arm/mach-at91/Kconfig 2007-07-29 06:42:19.000000000 +0200
+@@ -103,6 +103,12 @@
+ help
+ Select this if you are using Promwad's Chub board.
+
++config MACH_VLINK
++ bool "Figment Design Labs VersaLink"
++ depends on ARCH_AT91RM9200
++ help
++ Select this if you are using FDL's VersaLink board
++
+ endif
+
+ # ----------------------------------------------------------
+diff -urN linux-2.6.22.1.old/arch/arm/mach-at91/Makefile linux-2.6.22.1/arch/arm/mach-at91/Makefile
+--- linux-2.6.22.1.old/arch/arm/mach-at91/Makefile 2007-07-29 06:33:09.000000000 +0200
++++ linux-2.6.22.1/arch/arm/mach-at91/Makefile 2007-07-29 06:43:36.000000000 +0200
+@@ -29,6 +29,7 @@
+ obj-$(CONFIG_MACH_ATEB9200) += board-eb9200.o
+ obj-$(CONFIG_MACH_KAFA) += board-kafa.o
+ obj-$(CONFIG_MACH_CHUB) += board-chub.o
++obj-$(CONFIG_MACH_VLINK) += board-vlink.o
+ obj-$(CONFIG_MACH_PICOTUX2XX) += board-picotux200.o
+
+ # AT91SAM9260 board-specific support
+@@ -52,6 +53,7 @@
+ led-$(CONFIG_MACH_CSB637) += leds.o
+ led-$(CONFIG_MACH_KB9200) += leds.o
+ led-$(CONFIG_MACH_KAFA) += leds.o
++led-$(CONFIG_MACH_VLINK) += leds.o
+ obj-$(CONFIG_LEDS) += $(led-y)
+
+ # VGA support
diff --git a/target/linux/at91-2.6/patches-2.6.22/002-led-driver.patch b/target/linux/at91-2.6/patches-2.6.22/002-led-driver.patch
new file mode 100644
index 0000000000..29956f4268
--- /dev/null
+++ b/target/linux/at91-2.6/patches-2.6.22/002-led-driver.patch
@@ -0,0 +1,121 @@
+diff -urN linux-2.6.22.1.old/arch/arm/mach-at91/Makefile linux-2.6.22.1/arch/arm/mach-at91/Makefile
+--- linux-2.6.22.1.old/arch/arm/mach-at91/Makefile 2007-07-29 06:46:13.000000000 +0200
++++ linux-2.6.22.1/arch/arm/mach-at91/Makefile 2007-07-29 06:54:19.000000000 +0200
+@@ -53,7 +53,7 @@
+ led-$(CONFIG_MACH_CSB637) += leds.o
+ led-$(CONFIG_MACH_KB9200) += leds.o
+ led-$(CONFIG_MACH_KAFA) += leds.o
+-led-$(CONFIG_MACH_VLINK) += leds.o
++led-$(CONFIG_MACH_VLINK) += vlink_leds.o
+ obj-$(CONFIG_LEDS) += $(led-y)
+
+ # VGA support
+diff -urN linux-2.6.22.1.old/arch/arm/mach-at91/vlink_leds.c linux-2.6.22.1/arch/arm/mach-at91/vlink_leds.c
+--- linux-2.6.22.1.old/arch/arm/mach-at91/vlink_leds.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/arch/arm/mach-at91/vlink_leds.c 2007-07-29 06:54:58.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 --git a/target/linux/at91-2.6/patches-2.6.22/003-gpio-driver.patch b/target/linux/at91-2.6/patches-2.6.22/003-gpio-driver.patch
new file mode 100644
index 0000000000..766f962291
--- /dev/null
+++ b/target/linux/at91-2.6/patches-2.6.22/003-gpio-driver.patch
@@ -0,0 +1,359 @@
+diff -urN linux-2.6.22.1.old/arch/arm/mach-at91/gpio.c linux-2.6.22.1/arch/arm/mach-at91/gpio.c
+--- linux-2.6.22.1.old/arch/arm/mach-at91/gpio.c 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/arch/arm/mach-at91/gpio.c 2007-07-29 07:03:30.000000000 +0200
+@@ -27,6 +27,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.22.1.old/drivers/char/Kconfig linux-2.6.22.1/drivers/char/Kconfig
+--- linux-2.6.22.1.old/drivers/char/Kconfig 2007-07-29 06:46:13.000000000 +0200
++++ linux-2.6.22.1/drivers/char/Kconfig 2007-07-29 07:05:30.000000000 +0200
+@@ -1099,5 +1099,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.22.1.old/drivers/char/Makefile linux-2.6.22.1/drivers/char/Makefile
+--- linux-2.6.22.1.old/drivers/char/Makefile 2007-07-29 06:46:13.000000000 +0200
++++ linux-2.6.22.1/drivers/char/Makefile 2007-07-29 07:06:06.000000000 +0200
+@@ -95,6 +95,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_WATCHDOG) += watchdog/
+ obj-$(CONFIG_MWAVE) += mwave/
+diff -urN linux-2.6.22.1.old/drivers/char/vlink_giu.c linux-2.6.22.1/drivers/char/vlink_giu.c
+--- linux-2.6.22.1.old/drivers/char/vlink_giu.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.22.1/drivers/char/vlink_giu.c 2007-07-29 07:06:33.000000000 +0200
+@@ -0,0 +1,256 @@
++/*
++ * 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;
++
++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;
++
++ 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);
++ }
++
++ 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);
++ class_device_create(vio_class, NULL, MKDEV(major, i*32 + j), NULL,
++ "vio%c%d", i + 'A', j);
++ }
++ }
++
++ platform_set_drvdata(dev, vio_devices);
++
++ return 0;
++
++fail:
++ vio_remove(dev);
++ return retval;
++}
++
++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");
diff --git a/target/linux/at91-2.6/patches-2.6.22/007-mtd-partition.patch b/target/linux/at91-2.6/patches-2.6.22/007-mtd-partition.patch
new file mode 100644
index 0000000000..cd074cc025
--- /dev/null
+++ b/target/linux/at91-2.6/patches-2.6.22/007-mtd-partition.patch
@@ -0,0 +1,39 @@
+diff -urN linux-2.6.22.1.old/drivers/mtd/devices/at91_dataflash.c linux-2.6.22.1/drivers/mtd/devices/at91_dataflash.c
+--- linux-2.6.22.1.old/drivers/mtd/devices/at91_dataflash.c 2007-07-29 07:50:05.000000000 +0200
++++ linux-2.6.22.1/drivers/mtd/devices/at91_dataflash.c 2007-07-29 07:56:11.000000000 +0200
+@@ -173,7 +173,7 @@
+ };
+ #endif
+
+-static const char *part_probes[] = { "cmdlinepart", NULL, };
++static const char *part_probes[] = { "cmdlinepart", "at91part", NULL, };
+
+ #endif
+
+diff -urN linux-2.6.22.1.old/drivers/mtd/Kconfig linux-2.6.22.1/drivers/mtd/Kconfig
+--- linux-2.6.22.1.old/drivers/mtd/Kconfig 2007-07-29 07:54:27.000000000 +0200
++++ linux-2.6.22.1/drivers/mtd/Kconfig 2007-07-29 07:55:21.000000000 +0200
+@@ -160,6 +160,12 @@
+ for your particular device. It won't happen automatically. The
+ 'armflash' map driver (CONFIG_MTD_ARMFLASH) does this, for example.
+
++config MTD_AT91_PARTS
++ tristate "Atmel AT91 partitioning support"
++ depends on MTD_PARTITIONS && ARCH_AT91RM9200 && AT91_SPI
++ ---help---
++ Atmel AT91 partitioning support
++
+ comment "User Modules And Translation Layers"
+
+ config MTD_CHAR
+diff -urN linux-2.6.22.1.old/drivers/mtd/Makefile linux-2.6.22.1/drivers/mtd/Makefile
+--- linux-2.6.22.1.old/drivers/mtd/Makefile 2007-07-10 20:56:30.000000000 +0200
++++ linux-2.6.22.1/drivers/mtd/Makefile 2007-07-29 07:55:39.000000000 +0200
+@@ -11,6 +11,7 @@
+ obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
+ obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o
+ obj-$(CONFIG_MTD_AFS_PARTS) += afs.o
++obj-$(CONFIG_MTD_AT91_PARTS) += at91part.o
+
+ # 'Users' - code which presents functionality to userspace.
+ obj-$(CONFIG_MTD_CHAR) += mtdchar.o
diff --git a/target/linux/at91-2.6/patches-2.6.22/008-fdl-serial.patch b/target/linux/at91-2.6/patches-2.6.22/008-fdl-serial.patch
new file mode 100644
index 0000000000..42589197be
--- /dev/null
+++ b/target/linux/at91-2.6/patches-2.6.22/008-fdl-serial.patch
@@ -0,0 +1,160 @@
+--- linux-2.6.21.1.orig/drivers/serial/atmel_serial.c 2007-05-28 12:22:29.000000000 +0200
++++ linux-2.6.21.1/drivers/serial/atmel_serial.c 2007-05-28 16:39:09.000000000 +0200
+@@ -174,7 +174,35 @@
+ at91_set_gpio_value(AT91_PIN_PA21, 0);
+ else
+ at91_set_gpio_value(AT91_PIN_PA21, 1);
++
++ /*
++ * FDL VersaLink adds GPIOS to provide full modem control on
++ * USART 0 - Drive DTR and RI pins manually
++ */
++ if (mctrl & TIOCM_DTR)
++ at91_set_gpio_value(AT91_PIN_PB6, 0);
++ else
++ at91_set_gpio_value(AT91_PIN_PB6, 1);
++ if (mctrl & TIOCM_RI)
++ at91_set_gpio_value(AT91_PIN_PB7, 0);
++ else
++ at91_set_gpio_value(AT91_PIN_PB7, 1);
+ }
++
++ /*
++ * FDL VersaLink adds GPIOS to provide full modem control on
++ * USART 3 - Drive DTR and RI pins manually
++ */
++ if (port->mapbase == AT91RM9200_BASE_US3) {
++ if (mctrl & TIOCM_DTR)
++ at91_set_gpio_value(AT91_PIN_PB29, 0);
++ else
++ at91_set_gpio_value(AT91_PIN_PB29, 1);
++ if (mctrl & TIOCM_RI)
++ at91_set_gpio_value(AT91_PIN_PB2, 0);
++ else
++ at91_set_gpio_value(AT91_PIN_PB2, 1);
++ }
+ }
+ #endif
+
+@@ -211,8 +239,10 @@
+ /*
+ * The control signals are active low.
+ */
+- if (!(status & ATMEL_US_DCD))
+- ret |= TIOCM_CD;
++
++ if (!(port->mapbase == AT91RM9200_BASE_US0 || port->mapbase == AT91RM9200_BASE_US3))
++ if (!(status & ATMEL_US_DCD))
++ ret |= TIOCM_CD;
+ if (!(status & ATMEL_US_CTS))
+ ret |= TIOCM_CTS;
+ if (!(status & ATMEL_US_DSR))
+@@ -220,6 +250,16 @@
+ if (!(status & ATMEL_US_RI))
+ ret |= TIOCM_RI;
+
++ /*
++ * Read the GPIO's for the FDL VersaLink special case
++ */
++ if (port->mapbase == AT91RM9200_BASE_US0)
++ if (!(at91_get_gpio_value(AT91_PIN_PA19)))
++ ret |= TIOCM_CD;
++ if (port->mapbase == AT91RM9200_BASE_US3)
++ if (!(at91_get_gpio_value(AT91_PIN_PA24)))
++ ret |= TIOCM_CD;
++
+ return ret;
+ }
+
+@@ -511,6 +551,34 @@
+ }
+
+ /*
++ * USART0 DCD Interrupt handler
++ */
++
++static irqreturn_t atmel_u0_DCD_interrupt(int irq, void *dev_id)
++{
++ struct uart_port *port = dev_id;
++ int status = at91_get_gpio_value(irq);
++
++ uart_handle_dcd_change(port, !(status));
++
++ return IRQ_HANDLED;
++}
++
++/*
++ * USART3 DCD Interrupt handler
++ */
++
++static irqreturn_t atmel_u3_DCD_interrupt(int irq, void *dev_id)
++{
++ struct uart_port *port = dev_id;
++ int status = at91_get_gpio_value(irq);
++
++ uart_handle_dcd_change(port, !(status));
++
++ return IRQ_HANDLED;
++}
++
++/*
+ * Interrupt handler
+ */
+ static irqreturn_t atmel_interrupt(int irq, void *dev_id)
+@@ -587,6 +655,23 @@
+ return retval;
+ }
+
++ if (port->mapbase == AT91RM9200_BASE_US0) {
++ retval = request_irq(AT91_PIN_PA19, atmel_u0_DCD_interrupt, 0, "atmel_serial", port);
++ if (retval) {
++ printk("atmel_serial: atmel_startup - Can't get u0DCD irq\n");
++ free_irq(port->irq, port);
++ return retval;
++ }
++ }
++ if (port->mapbase == AT91RM9200_BASE_US3) {
++ retval = request_irq(AT91_PIN_PA24, atmel_u3_DCD_interrupt, 0, "atmel_serial", port);
++ if (retval) {
++ printk("atmel_serial: atmel_startup - Can't get u3DCD irq\n");
++ free_irq(port->irq, port);
++ return retval;
++ }
++ }
++
+ /*
+ * Initialize DMA (if necessary)
+ */
+@@ -603,6 +688,10 @@
+ kfree(atmel_port->pdc_rx[0].buf);
+ }
+ free_irq(port->irq, port);
++ if (port->mapbase == AT91RM9200_BASE_US0)
++ free_irq(AT91_PIN_PA19, port);
++ if (port->mapbase == AT91RM9200_BASE_US3)
++ free_irq(AT91_PIN_PA24, port);
+ return -ENOMEM;
+ }
+ pdc->dma_addr = dma_map_single(port->dev, pdc->buf, PDC_BUFFER_SIZE, DMA_FROM_DEVICE);
+@@ -636,6 +725,10 @@
+ retval = atmel_open_hook(port);
+ if (retval) {
+ free_irq(port->irq, port);
++ if (port->mapbase == AT91RM9200_BASE_US0)
++ free_irq(AT91_PIN_PA19, port);
++ if (port->mapbase == AT91RM9200_BASE_US3)
++ free_irq(AT91_PIN_PA24, port);
+ return retval;
+ }
+ }
+@@ -701,6 +794,10 @@
+ * Free the interrupt
+ */
+ free_irq(port->irq, port);
++ if (port->mapbase == AT91RM9200_BASE_US0)
++ free_irq(AT91_PIN_PA19, port);
++ if (port->mapbase == AT91RM9200_BASE_US3)
++ free_irq(AT91_PIN_PA24, port);
+
+ /*
+ * If there is a specific "close" function (to unregister
diff --git a/target/linux/at91-2.6/patches-2.6.22/009-fdl-uartinit.patch b/target/linux/at91-2.6/patches-2.6.22/009-fdl-uartinit.patch
new file mode 100644
index 0000000000..f36f386824
--- /dev/null
+++ b/target/linux/at91-2.6/patches-2.6.22/009-fdl-uartinit.patch
@@ -0,0 +1,27 @@
+diff -urN linux-2.6.22.1.old/arch/arm/mach-at91/at91rm9200_devices.c linux-2.6.22.1/arch/arm/mach-at91/at91rm9200_devices.c
+--- linux-2.6.22.1.old/arch/arm/mach-at91/at91rm9200_devices.c 2007-07-29 06:46:13.000000000 +0200
++++ linux-2.6.22.1/arch/arm/mach-at91/at91rm9200_devices.c 2007-07-29 07:23:35.000000000 +0200
+@@ -721,6 +721,10 @@
+ * We need to drive the pin manually. Default is off (RTS is active low).
+ */
+ at91_set_gpio_output(AT91_PIN_PA21, 1);
++ at91_set_gpio_output(AT91_PIN_PB6, 1); /* DTR0 */
++ at91_set_gpio_output(AT91_PIN_PB7, 1); /* RI0 */
++ at91_set_gpio_input(AT91_PIN_PA19, 1); /* DCD0 */
++ at91_set_deglitch(AT91_PIN_PA19, 1);
+ }
+
+ static struct resource uart1_resources[] = {
+@@ -832,6 +836,12 @@
+ {
+ at91_set_B_periph(AT91_PIN_PA5, 1); /* TXD3 */
+ at91_set_B_periph(AT91_PIN_PA6, 0); /* RXD3 */
++ at91_set_B_periph(AT91_PIN_PB0, 0); /* RTS3 */
++ at91_set_B_periph(AT91_PIN_PB1, 0); /* CTS3 */
++ at91_set_gpio_output(AT91_PIN_PB29, 1); /* DTR0 */
++ at91_set_gpio_output(AT91_PIN_PB2, 1); /* RI0 */
++ at91_set_gpio_input(AT91_PIN_PA24, 1); /* DCD0 */
++ at91_set_deglitch(AT91_PIN_PA24, 1);
+ }
+
+ struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
diff --git a/target/linux/at91-2.6/patches-2.6.22/010-dm9161a-phyfix.patch b/target/linux/at91-2.6/patches-2.6.22/010-dm9161a-phyfix.patch
new file mode 100644
index 0000000000..9ad8c42530
--- /dev/null
+++ b/target/linux/at91-2.6/patches-2.6.22/010-dm9161a-phyfix.patch
@@ -0,0 +1,28 @@
+--- linux-2.6.21.1/drivers/net/arm/at91_ether.c.old 2007-06-04 18:15:49.000000000 +0200
++++ linux-2.6.21.1/drivers/net/arm/at91_ether.c 2007-06-04 18:10:36.000000000 +0200
+@@ -146,6 +146,7 @@
+ struct at91_private *lp = netdev_priv(dev);
+ unsigned int bmsr, bmcr, lpa, mac_cfg;
+ unsigned int speed, duplex;
++ unsigned long timeout = jiffies + HZ;
+
+ if (!mii_link_ok(&lp->mii)) { /* no link */
+ netif_carrier_off(dev);
+@@ -158,8 +159,15 @@
+ read_phy(lp->phy_address, MII_BMSR, &bmsr);
+ read_phy(lp->phy_address, MII_BMCR, &bmcr);
+ if (bmcr & BMCR_ANENABLE) { /* AutoNegotiation is enabled */
+- if (!(bmsr & BMSR_ANEGCOMPLETE))
+- return; /* Do nothing - another interrupt generated when negotiation complete */
++ while (!(bmsr & BMSR_ANEGCOMPLETE)) {
++ if (time_after(jiffies, timeout)) {
++ printk("at91_ether: Auto-negotiate timeout\n");
++ return;
++ }
++ read_phy(lp->phy_address, MII_BMSR, &bmsr);
++ read_phy(lp->phy_address, MII_BMCR, &bmcr);
++ cpu_relax();
++ }
+
+ read_phy(lp->phy_address, MII_LPA, &lpa);
+ if ((lpa & LPA_100FULL) || (lpa & LPA_100HALF)) speed = SPEED_100;
diff --git a/target/linux/at91-2.6/patches-2.6.22/014-initpartition.patch b/target/linux/at91-2.6/patches-2.6.22/014-initpartition.patch
new file mode 100644
index 0000000000..cfcd062fce
--- /dev/null
+++ b/target/linux/at91-2.6/patches-2.6.22/014-initpartition.patch
@@ -0,0 +1,19 @@
+diff -urN linux-2.6.22.1.old/drivers/mtd/devices/at91_dataflash.c linux-2.6.22.1/drivers/mtd/devices/at91_dataflash.c
+--- linux-2.6.22.1.old/drivers/mtd/devices/at91_dataflash.c 2007-07-29 07:18:10.000000000 +0200
++++ linux-2.6.22.1/drivers/mtd/devices/at91_dataflash.c 2007-07-29 07:32:52.000000000 +0200
+@@ -161,12 +161,12 @@
+ .mask_flags = MTD_WRITEABLE, /* read-only */
+ },
+ {
+- .name = "kernel",
++ .name = "knlroot",
+ .offset = MTDPART_OFS_NXTBLK,
+- .size = 5 * 32 * 8 * 1056, /* 5 sectors */
++ .size = 0x320400,
+ },
+ {
+- .name = "filesystem",
++ .name = "jffs2",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = MTDPART_SIZ_FULL, /* rest = 26 sectors */
+ }