diff -Naur linux-2.6.25.at91/drivers/misc/classes/lsi2esc_devices/Makefile linux-2.6/drivers/misc/classes/lsi2esc_devices/Makefile
--- linux-2.6.25.at91/drivers/misc/classes/lsi2esc_devices/Makefile	1969-12-31 18:00:00.000000000 -0600
+++ linux-2.6/drivers/misc/classes/lsi2esc_devices/Makefile	2008-12-30 10:38:39.000000000 -0600
@@ -0,0 +1,5 @@
+#
+# Makefile for the lsi2esc GPIO extensions.
+#
+
+obj-$(CONFIG_LSI2ESC_MCP3208)	+= mcp3208-gpio.o
diff -Naur linux-2.6.25.at91/drivers/misc/classes/lsi2esc_devices/mcp3208-gpio.c linux-2.6/drivers/misc/classes/lsi2esc_devices/mcp3208-gpio.c
--- linux-2.6.25.at91/drivers/misc/classes/lsi2esc_devices/mcp3208-gpio.c	1969-12-31 18:00:00.000000000 -0600
+++ linux-2.6/drivers/misc/classes/lsi2esc_devices/mcp3208-gpio.c	2008-12-30 10:38:39.000000000 -0600
@@ -0,0 +1,87 @@
+/*
+ * drivers/misc/classes/lsi2esc_devices/mcp3208-gpio.c
+ * EMAC.Inc support for indexed GPIO interface to the MCP3208
+ * ADC used on the SoM-150ES. Provides a generic wrapper to the
+ * LSI2ESC functions used to communicate to the device.
+ *
+ * Copyright (C) 2008 EMAC.Inc <support@emacinc.com>
+ */
+
+#include <linux/class/lsi2esc/mcp3208-gpio.h>
+#include <linux/class/spi.h>
+#include <asm/io.h>
+#include <asm/hardware.h>
+#include <linux/class/gpio.h>
+
+static struct spi_s *spi_dev;
+
+static u8 is_initialized = 0;
+
+/**
+ * function to initialize the settings for the interface.
+ * This cannot be called from the class create function because
+ * the LSI2ESC may not have been probed yet.
+ */
+static void mcp3208_init(void)
+{
+	static spi_control config = SPICL_EIGHTBIT;
+	spi_dev->confwrite(spi_dev, config);
+	is_initialized = 1;
+}
+
+/**
+ * function to read the value of the ADC at the current
+ * index.
+ */
+static gpio_data mcp3208_data_read(struct gpio_s *gpio)
+{
+	u32 size;
+	u8 reg = gpio->index;
+	u8 reg_msb;
+	u8 mosi[3];
+	u8 miso[3];
+
+	if (!is_initialized)
+		mcp3208_init();
+
+	/*
+	 * The command for the mcp3208 is as follows:
+	 * leading 0's
+	 * start bit
+	 * 1 to signal single mode
+	 * 3 bits to represent the channel to read
+	 */
+	size = 3;
+
+	reg_msb = (reg >> 2) & 0x01; /* XYZ >> 2 = X */
+	mosi[0] = reg_msb | 0x06;
+	/* the last 2 bits of the reg need to go into the top of the
+	 * second byte transmitted */
+	mosi[1] = reg << 6; /* 00000xxx << 6 = xx000000 */
+
+	memset(miso, 0x0, sizeof(miso));
+	spi_dev->xmit(spi_dev, mosi, miso, size);
+	return ((miso[1] & 0x0F) << 8) | (miso[2] & 0x00FF);
+}
+
+/**
+ * function to register the class
+ */
+struct class_device *mcp3208_gpio_class_create(struct spi_s *spi, const char *name)
+{
+	gpio_t *gpio = kmalloc(sizeof(gpio_t), GFP_KERNEL);
+	spi_dev = spi;
+
+	memset(gpio, 0, sizeof(gpio_t));
+	gpio->name = name;
+	gpio->subclass = GPI_SUBCLASS;
+	gpio->data_write = gpio_empty_write;
+	gpio->range = 7;
+	gpio->index_write = gpio_index_write;
+	gpio->index_read = gpio_index_read;
+	gpio->data_read = mcp3208_data_read;
+	printk("registering mcp3208 GPIO interface: %s\n", gpio->name);
+
+	return gpio_register_class_device(gpio);
+}
+
diff -Naur linux-2.6.25.at91/drivers/misc/classes/Makefile linux-2.6/drivers/misc/classes/Makefile
--- linux-2.6.25.at91/drivers/misc/classes/Makefile	2009-02-12 12:26:57.000000000 -0600
+++ linux-2.6/drivers/misc/classes/Makefile	2008-12-30 10:38:39.000000000 -0600
@@ -11,3 +11,4 @@
 mmc-y := mmcprot.o mmcblock.o
 obj-y += rtdm/
 obj-y += char/
+obj-y += lsi2esc_devices/
diff -Naur linux-2.6.25.at91/drivers/misc/classes/spi_interface.c linux-2.6/drivers/misc/classes/spi_interface.c
--- linux-2.6.25.at91/drivers/misc/classes/spi_interface.c	2009-02-12 12:26:57.000000000 -0600
+++ linux-2.6/drivers/misc/classes/spi_interface.c	2008-12-30 10:38:39.000000000 -0600
@@ -157,6 +157,8 @@
         s->lsi->bits_per_word = 12;
     else if (config & SPICL_SIXTEENBIT)
         s->lsi->bits_per_word = 16;
+
+    DPRINTK("lsi2esc_spi_confwrite: calling spi_setup\r\n");
     
     return spi_setup(s->lsi);
 }
@@ -207,6 +209,7 @@
      * the board specific file */
     /* kind of creates a loop... but thats OK */
     esc = spi->dev.platform_data;
+    DPRINTK("lsi2esc_probe: %s\n", esc->name);
     esc->lsi = spi;
 
     if (!esc)
diff -Naur linux-2.6.25.at91/include/linux/class/gpio.h linux-2.6/include/linux/class/gpio.h
--- linux-2.6.25.at91/include/linux/class/gpio.h	2009-02-12 12:26:57.000000000 -0600
+++ linux-2.6/include/linux/class/gpio.h	2008-11-10 18:02:09.000000000 -0600
@@ -76,7 +76,7 @@
  * bit configurable gpio ports with a bidirectional data register
  * if the data register or ddr are NULL their interfaces are not created.
  */
-static inline struct class_device *gpio_device_create(void *data, void *ddr,const char *name){
+static inline struct class_device *gpio_device_create(void *data, void *ddr, const char *name){
 	gpio_t *gpio = kmalloc(sizeof(gpio_t),GFP_KERNEL);
 	memset(gpio,0,sizeof(gpio_t));
 	gpio->name = name;
diff -Naur linux-2.6.25.at91/include/linux/class/lsi2esc/mcp3208-gpio.h linux-2.6/include/linux/class/lsi2esc/mcp3208-gpio.h
--- linux-2.6.25.at91/include/linux/class/lsi2esc/mcp3208-gpio.h	1969-12-31 18:00:00.000000000 -0600
+++ linux-2.6/include/linux/class/lsi2esc/mcp3208-gpio.h	2009-01-27 13:12:55.000000000 -0600
@@ -0,0 +1,13 @@
+#ifndef MCP3208_GPIO_H_
+#define MCP3208_GPIO_H_
+
+#include <linux/class/spi_interface.h>
+
+#ifdef CONFIG_LSI2ESC_MCP3208
+struct class_device *mcp3208_gpio_class_create(struct spi_s *spi, const char *name);
+#else
+#define mcp3208_gpio_class_create(s,n) {}
+#endif
+
+#endif /* MCP3208_GPIO_H_ */
+
diff -Naur linux-2.6.25.at91/include/linux/class/spi.h linux-2.6/include/linux/class/spi.h
--- linux-2.6.25.at91/include/linux/class/spi.h	2009-02-12 12:26:57.000000000 -0600
+++ linux-2.6/include/linux/class/spi.h	2008-12-30 10:38:39.000000000 -0600
@@ -1,5 +1,5 @@
-#ifndef SPI_H_
-#define SPI_H_
+#ifndef SPI_CLASS_H_
+#define SPI_CLASS_H_
 #include <linux/autoconf.h>
 #include <linux/device.h>
 #if defined(CONFIG_LSI2ESC)
@@ -82,4 +82,4 @@
 
 #endif
 
-#endif /*SPI_H_*/
+#endif /*SPI_CLASS_H_*/

