| 
									
										
										
										
											2007-05-01 09:45:29 +09:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * linux/arch/sh/boards/se/7722/irq.c | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2007  Nobuhiro Iwamatsu | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Hitachi UL SolutionEngine 7722 Support. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This file is subject to the terms and conditions of the GNU General Public | 
					
						
							|  |  |  |  * License.  See the file "COPYING" in the main directory of this archive | 
					
						
							|  |  |  |  * for more details. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #include <linux/init.h>
 | 
					
						
							|  |  |  | #include <linux/irq.h>
 | 
					
						
							|  |  |  | #include <linux/interrupt.h>
 | 
					
						
							|  |  |  | #include <asm/irq.h>
 | 
					
						
							|  |  |  | #include <asm/io.h>
 | 
					
						
							| 
									
										
										
										
											2008-07-29 21:41:37 +09:00
										 |  |  | #include <mach-se/mach/se7722.h>
 | 
					
						
							| 
									
										
										
										
											2007-05-01 09:45:29 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-04 11:44:21 +09:00
										 |  |  | unsigned int se7722_fpga_irq[SE7722_FPGA_IRQ_NR] = { 0, }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-01 09:45:29 +09:00
										 |  |  | static void disable_se7722_irq(unsigned int irq) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-11-04 11:44:21 +09:00
										 |  |  | 	unsigned int bit = (unsigned int)get_irq_chip_data(irq); | 
					
						
							| 
									
										
										
										
											2010-01-26 12:58:40 +09:00
										 |  |  | 	__raw_writew(__raw_readw(IRQ01_MASK) | 1 << bit, IRQ01_MASK); | 
					
						
							| 
									
										
										
										
											2007-05-01 09:45:29 +09:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void enable_se7722_irq(unsigned int irq) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-11-04 11:44:21 +09:00
										 |  |  | 	unsigned int bit = (unsigned int)get_irq_chip_data(irq); | 
					
						
							| 
									
										
										
										
											2010-01-26 12:58:40 +09:00
										 |  |  | 	__raw_writew(__raw_readw(IRQ01_MASK) & ~(1 << bit), IRQ01_MASK); | 
					
						
							| 
									
										
										
										
											2007-05-01 09:45:29 +09:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct irq_chip se7722_irq_chip __read_mostly = { | 
					
						
							| 
									
										
										
										
											2007-07-18 17:54:10 +09:00
										 |  |  | 	.name           = "SE7722-FPGA", | 
					
						
							| 
									
										
										
										
											2007-05-01 09:45:29 +09:00
										 |  |  | 	.mask           = disable_se7722_irq, | 
					
						
							|  |  |  | 	.unmask         = enable_se7722_irq, | 
					
						
							|  |  |  | 	.mask_ack       = disable_se7722_irq, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-07-18 17:54:10 +09:00
										 |  |  | static void se7722_irq_demux(unsigned int irq, struct irq_desc *desc) | 
					
						
							| 
									
										
										
										
											2007-05-01 09:45:29 +09:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-01-26 12:58:40 +09:00
										 |  |  | 	unsigned short intv = __raw_readw(IRQ01_STS); | 
					
						
							| 
									
										
										
										
											2009-11-04 11:44:21 +09:00
										 |  |  | 	unsigned int ext_irq = 0; | 
					
						
							| 
									
										
										
										
											2007-07-18 17:54:10 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	intv &= (1 << SE7722_FPGA_IRQ_NR) - 1; | 
					
						
							| 
									
										
										
										
											2007-05-01 09:45:29 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-04 11:44:21 +09:00
										 |  |  | 	for (; intv; intv >>= 1, ext_irq++) { | 
					
						
							|  |  |  | 		if (!(intv & 1)) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		generic_handle_irq(se7722_fpga_irq[ext_irq]); | 
					
						
							| 
									
										
										
										
											2007-05-01 09:45:29 +09:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2007-07-18 17:54:10 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-01 09:45:29 +09:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Initialize IRQ setting | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | void __init init_se7722_IRQ(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-12-15 16:36:34 +00:00
										 |  |  | 	int i, irq; | 
					
						
							| 
									
										
										
										
											2007-07-18 17:54:10 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-26 12:58:40 +09:00
										 |  |  | 	__raw_writew(0, IRQ01_MASK);       /* disable all irqs */ | 
					
						
							|  |  |  | 	__raw_writew(0x2000, 0xb03fffec);  /* mrshpc irq enable */ | 
					
						
							| 
									
										
										
										
											2007-05-01 09:45:29 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-04 11:44:21 +09:00
										 |  |  | 	for (i = 0; i < SE7722_FPGA_IRQ_NR; i++) { | 
					
						
							| 
									
										
										
										
											2009-12-15 16:36:34 +00:00
										 |  |  | 		irq = create_irq(); | 
					
						
							|  |  |  | 		if (irq < 0) | 
					
						
							| 
									
										
										
										
											2009-11-04 11:44:21 +09:00
										 |  |  | 			return; | 
					
						
							| 
									
										
										
										
											2009-12-15 16:36:34 +00:00
										 |  |  | 		se7722_fpga_irq[i] = irq; | 
					
						
							| 
									
										
										
										
											2009-11-04 11:44:21 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		set_irq_chip_and_handler_name(se7722_fpga_irq[i], | 
					
						
							| 
									
										
										
										
											2007-07-18 17:54:10 +09:00
										 |  |  | 					      &se7722_irq_chip, | 
					
						
							|  |  |  | 					      handle_level_irq, "level"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-04 11:44:21 +09:00
										 |  |  | 		set_irq_chip_data(se7722_fpga_irq[i], (void *)i); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-07-18 17:54:10 +09:00
										 |  |  | 	set_irq_chained_handler(IRQ0_IRQ, se7722_irq_demux); | 
					
						
							|  |  |  | 	set_irq_type(IRQ0_IRQ, IRQ_TYPE_LEVEL_LOW); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	set_irq_chained_handler(IRQ1_IRQ, se7722_irq_demux); | 
					
						
							|  |  |  | 	set_irq_type(IRQ1_IRQ, IRQ_TYPE_LEVEL_LOW); | 
					
						
							| 
									
										
										
										
											2007-05-01 09:45:29 +09:00
										 |  |  | } |