**************************************************************
*SoM-9260 board updates for power management
*NZG
*09/25/2007
*EMAC.Inc
************************************************************
diff -uprN linux-2.6.20-at92_e1.2/arch/arm/mach-at91rm9200/Kconfig linux-2.6.20.snap/arch/arm/mach-at91rm9200/Kconfig
--- linux-2.6.20-at92_e1.2/arch/arm/mach-at91rm9200/Kconfig	2007-09-25 13:09:18.000000000 -0400
+++ linux-2.6.20.snap/arch/arm/mach-at91rm9200/Kconfig	2007-09-24 17:53:39.000000000 -0400
@@ -179,6 +179,12 @@ config CSB300_WAKE_SW1
 	  If you have a CSB300 connected to your CSB337, this lets
 	  SW1 serve as a wakeup button.  It uses GPIO.
 
+config RTSCLS
+	bool "Enable gpio class for the RTS flow control line"
+	depends on (MACH_SOM9260M)
+	help
+	  Enable class based control of the RTS flow control line.
+
 # ----------------------------------------------------------
 
 comment "AT91 Feature Selections"
diff -uprN linux-2.6.20-at92_e1.2/arch/arm/mach-at91rm9200/Makefile linux-2.6.20.snap/arch/arm/mach-at91rm9200/Makefile
--- linux-2.6.20-at92_e1.2/arch/arm/mach-at91rm9200/Makefile	2007-09-25 13:09:18.000000000 -0400
+++ linux-2.6.20.snap/arch/arm/mach-at91rm9200/Makefile	2007-09-20 16:41:16.000000000 -0400
@@ -29,7 +29,7 @@ obj-$(CONFIG_MACH_KAFA)		+= board-kafa.o
 
 # AT91SAM9260 board-specific support
 obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o
-obj-$(CONFIG_MACH_SOM9260M) += board-som9260m.o
+obj-$(CONFIG_MACH_SOM9260M) += board-som9260m.o atod-som9260m.o led-som9260m.o
 
 # AT91SAM9261 board-specific support
 obj-$(CONFIG_MACH_AT91SAM9261EK) += board-sam9261ek.o
diff -uprN linux-2.6.20-at92_e1.2/arch/arm/mach-at91rm9200/board-som9260m.c linux-2.6.20.snap/arch/arm/mach-at91rm9200/board-som9260m.c
--- linux-2.6.20-at92_e1.2/arch/arm/mach-at91rm9200/board-som9260m.c	2007-09-25 13:09:18.000000000 -0400
+++ linux-2.6.20.snap/arch/arm/mach-at91rm9200/board-som9260m.c	2007-09-25 12:59:14.000000000 -0400
@@ -44,6 +44,7 @@
 #include <asm/arch/at91sam926x_mc.h>
 
 #include "generic.h"
+#include "atod-som9260m.h"
 
 
 /*
@@ -260,6 +261,7 @@ static struct at91_mmc_data __initdata e
 
 static struct ecoreex_data som9260m_ecoreex_data = {
 	.key_offset	= CPLDKEY,
+	.irq = AT91SAM9260_ID_IRQ1,
 };
 
 static struct resource som9260m_ecoreex_resource = {
@@ -337,10 +339,6 @@ static inline void set200kclock(void){
 	
 	clk_enable(tc1_clk);//enable tc1 clock in the pmc
 	
-	printk("pre AT91_TC_CMR = %x\n",at91_tc_read(tc1 + AT91_TC_CMR));
-	
-	printk("tc1 = %x\n",tc1);
-	
 	//if(tc1)
 	//tc1 setup for waveform on TCIOB1
 	at91_tc_write((tc1 + AT91_TC_CMR),
@@ -363,22 +361,107 @@ static inline void set200kclock(void){
 	
 	//enable timer functionality on PC7, TIOB1 
 	at91_set_A_periph(AT91_PIN_PC7, 1);		
-	
-	printk("post AT91_TC_CMR = %xl\n",at91_sys_read(tc1 + AT91_TC_CMR));
 
 }
 
+
+
+
 static inline void at91_add_device_ecoreex4(void){
-	printk("at91_add_device_ecoreex4\n");
 	cs4_setup();
 	set200kclock();
+	at91_set_A_periph(AT91_PIN_PC15, 1);//enable IRQ1 on PC15	
 	platform_device_register(&som9260m_ecoreex_device);
 }
 
+/************************************************************/
+#ifdef CONFIG_RTSCLS
 
+static int rts_data_write(struct gpio_s *gpio,gpio_data data){
+	at91_set_gpio_output(AT91_PIN_PB28,(char)data);
+	return 0;
+}
 
-/************************************************************/
+static gpio_data rts_data_read(struct gpio_s *gpio)
+	return at91_get_gpio_value(AT91_PIN_PB28);
+}
 
+static inline void som9260m_rtscls(void){
+	gpio_t *gpio = kmalloc(sizeof(gpio_t),GFP_KERNEL);
+	memset(gpio,0,sizeof(gpio_t));
+	at91_set_gpio_output(AT91_PIN_PB28,1);//rts line
+	gpio->name = "rtstest";
+	gpio->subclass = GPIO_SUBCLASS;
+	gpio->data_write = rts_data_write;
+	gpio->data_read = rts_data_read;
+	printk("registering gpio device: %s\n",gpio->name);
+	return gpio_register_class_device(gpio);	
+}
+
+#else//CONFIG_RTSCLS
+#define som9260m_rtscls()
+#endif
+
+static int physw_write(struct gpio_s *gpio,gpio_data data){
+	at91_set_gpio_output(AT91_PIN_PA31,(char)data);
+	return 0;
+}
+
+static gpio_data physw_read(struct gpio_s *gpio){
+	return at91_get_gpio_value(AT91_PIN_PA31);
+}
+
+static inline void som9260m_physw(void){
+	gpio_t *gpio = kmalloc(sizeof(gpio_t),GFP_KERNEL);
+	memset(gpio,0,sizeof(gpio_t));
+	at91_set_gpio_output(AT91_PIN_PB28,1);//rts line
+	gpio->name = "physw";
+	gpio->subclass = GPIO_SUBCLASS;
+	gpio->data_write = physw_write;
+	gpio->data_read = physw_read;
+	printk("registering gpio device: %s\n",gpio->name);
+	return gpio_register_class_device(gpio);
+}
+
+/************************************************************
+ * device registrations from the arch go here, 
+ * which are called by the boardspec ioex driver
+ */
+static int som9260m_classes(void)
+{
+	som9260m_atod_init();
+	som9260m_atod_class_create("indexed_atod");
+	
+	som9260m_led_init();
+	som9260m_led_class_create("indexed_led");
+	
+	som9260m_rtscls();
+	
+	som9260m_physw();
+	
+	//set wakeup mask to all uarts
+	set_irq_wake(AT91SAM9260_ID_US0,1);
+	set_irq_wake(AT91SAM9260_ID_US1,1);
+	set_irq_wake(AT91SAM9260_ID_US2,1);
+	set_irq_wake(AT91SAM9260_ID_US3,1);
+	set_irq_wake(AT91SAM9260_ID_US4,1);
+	set_irq_wake(AT91SAM9260_ID_US5,1);
+	
+	return 0;
+}
+
+static struct platform_device boardspec_device = {
+	.name = "boardspec",
+	.id = 1,
+	.dev		= {
+		.platform_data	= &som9260m_classes,
+	},
+};
+
+static inline void at91_add_device_boardspec(void){
+	platform_device_register(&boardspec_device);
+}
+/************************************************************/
 
 static void __init ek_board_init(void)
 {
@@ -398,8 +481,10 @@ static void __init ek_board_init(void)
 	at91_add_device_mmc(0, &ek_mmc_data);
 	/* AT73C213 & SSC port */
 	at91_add_device_ssc_at73c213();
-	
+	/* EMAC Core Extensions */
 	at91_add_device_ecoreex4();
+	/* Board Specific */
+	at91_add_device_boardspec();
 	
 }
 

