**************************************************************
*DENM support for experimental 1.6 and interrupt registration
*NZG
*09/25/2007
*EMAC.Inc
**************************************************************
diff -uprN linux-2.6.20-at92_e1.2/drivers/ioex/ecoreex.c linux-2.6.20.snap/drivers/ioex/ecoreex.c
--- linux-2.6.20-at92_e1.2/drivers/ioex/ecoreex.c	2007-09-25 13:09:49.000000000 -0400
+++ linux-2.6.20.snap/drivers/ioex/ecoreex.c	2007-09-25 12:55:00.000000000 -0400
@@ -18,7 +18,10 @@
 #include <linux/class/mmcprot.h>
 #include <linux/ioex/ecoreex.h>
 #include <linux/ioex/pwmd.h>
+#include <linux/interrupt.h>
 #include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/mach/irq.h>
 
 //---------------------------------------------------------------------------------
 #ifdef CONFIG_ECOREEX_TGPIO
@@ -142,9 +145,11 @@ return 0;
 #define CPLD_DENM_NAME_12 "DENM CPLD expansion R1.2/R1.3"
 #define CPLD_DENM_NAME_14 "DENM CPLD expansion R1.4"
 #define CPLD_DENM_NAME_15 "DENM CPLD expansion R1.5"
+#define CPLD_DENM_NAME_16 "DENM CPLD expansion R1.6"
 #define CPLD_DENM 0x92
 #define CPLD_DENM14 0x93
 #define CPLD_DENM15 0x94
+#define CPLD_DENM16 0x95
 
 static inline int CPLD_DENM_map(unsigned long phys_addr,u8 *virt_addr,unsigned long size,const char *name){
 	
@@ -207,7 +212,16 @@ static inline int CPLD_DENM14_map(unsign
 return 0;
 }
 
-static inline int CPLD_DENM15_map(unsigned long phys_addr,u8 *virt_addr,unsigned long size,const char *name){
+/**
+ * handler currently just indicates the that interrupt was handled and returns
+ */
+static irqreturn_t denm_interrupt(int irq, void *na){
+	//printk("denm interrupt\n");
+	return IRQ_HANDLED;
+}
+
+
+static inline int CPLD_DENM15_map(unsigned long phys_addr,u8 *virt_addr,unsigned long size,const char *name,struct ecoreex_data *e){
 	
 	if(request_mem_region(phys_addr,size,name)==NULL){
 		printk("could not obtain physical memory at %lx for EMAC core\n",phys_addr);
@@ -233,6 +247,18 @@ static inline int CPLD_DENM15_map(unsign
 	gpio_device_create(&virt_addr[3], NULL,"rollover");
 	gpio_device_create(&virt_addr[1],NULL,"debounce");
 	
+	/*
+		 * Allocate the IRQ
+		 */
+	if(e->irq){
+		int err = request_irq(e->irq, denm_interrupt,IRQT_RISING,name, NULL);
+		if(err<0)
+			printk("ecoreex request for irq %d failed with %d\n",e->irq,err);
+			//printk("ecoreex request for irq %d failed\n",e->irq);
+		
+		else set_irq_wake(e->irq,1);//if the board provides an irq, register it to wake up pm.
+	}
+	
 #endif	//CONFIG_GPIOCLASS
 
 return 0;
@@ -288,7 +314,9 @@ static inline void map_core(unsigned lon
 				CPLD_DENM14_map(phys_addr,virt_addr,size,CPLD_DENM_NAME_14);
 			break;
 			case CPLD_DENM15:
-				CPLD_DENM15_map(phys_addr,virt_addr,size,CPLD_DENM_NAME_15);
+				CPLD_DENM15_map(phys_addr,virt_addr,size,CPLD_DENM_NAME_15,data);
+			case CPLD_DENM16:
+				CPLD_DENM15_map(phys_addr,virt_addr,size,CPLD_DENM_NAME_16,data);	
 			break;
 			#endif //CONFIG_ECOREEX_DENM
 			//--------------------------------------------------------
diff -uprN linux-2.6.20-at92_e1.2/include/linux/ioex/ecoreex.h linux-2.6.20.snap/include/linux/ioex/ecoreex.h
--- linux-2.6.20-at92_e1.2/include/linux/ioex/ecoreex.h	2007-09-25 13:09:18.000000000 -0400
+++ linux-2.6.20.snap/include/linux/ioex/ecoreex.h	2007-09-25 12:55:00.000000000 -0400
@@ -9,6 +9,7 @@ struct ecoreex_data
 	int	key_offset;
 	__u32 (*read_periodusa)(pwm_t *pwm);//a pwm input clock, defined as a period to minimize calculation
 	mmcslot_t *mmcslot;//structure for implementing mmc connections.
+	unsigned int irq;//irq number, 0 if no irq is used. 
 };
 
 #endif /*ECOREEX_H_*/


