2 V0 support for the pandaboard.
aboutsummaryrefslogblamecommitdiffstats
path: root/drivers/sh/intc.c
blob: 58d24c5a76cea5732d9a8b13cca5294dc95700a0 (plain) (tree)
1
2
3
4


                                                                  
                                       

















                                                                             
                          
                          















                                                                    
 

                           


                           






                                      
 









                                                                    
                                                           
                                                       

                                         
 
                                                                   

                                                  
                                                                             



                                                              
                                                         
 


                                                 




                                                
                                                                            
 
                                                  

 
                                                                             
 
                                                  

 
                                                                             
 
                                                  

 
                                                                             
 

                              
                                                                  
                                 

 
                                                                              
 

                              
                                                                  
                                 

 
                                                                              
 

                              
                                                                  
                                 

 











                                                                        
 





                                                                               
 





                                                      
 
                                                           

 





                                                      
 
                            

 





                                                      
 
                                               

 











                                                           
 











                                                            
 
                                                                       
 
                                                     

                           
 




                                                                               

 

                                         
                                                                 



                                          
                                                     
                                                                      

                           
 




                                                                               

 
                                                       











                                                                     

                                                          

                                                                           

                                                           

                                                                             

                                                           

                                                                                 




                              



         


                                                                        
 

              











                                                                        





                                         
 
                    

 
                                                          
 







                                                      
                                                            
                                       
 







                                                                       
                                                        


                                                       







                                                                      



                                                                           
                                         
      



                                                              
                                                     
                                                                               

                                    
 
                   

                               

                                                        
                                                                 
                                                                              
         
                 

 

                                                                
 
                       
 


                                         


              
                 

 

                                                           

















                                                               
                                                                 
                                                                  
                                                                         
 
                                                   

                                    
 

                                                                   




                                                                















                                                               

                         





                                                                 


                 
                    
                                                                              
 



                                                                 
                                                                  
                                                                         
 
                                                   

                                         
 

                                                                   




                                                                












                                                         
 
                                                       
 


                                                                          
 



                                                               


                 
                    




                                                                              
                                                       
































                                                                  















                                                                    
 


                                                                          




                                                                        
 


                 


                                                             

                                                      
                                   







                                                                         
 

                                                      




                                

                                                                          




                                                                      

                                
                                                    
                                                                 
                                                      
 



                                                                     
 

                                                        



                                                              












                                                                               









                                                            

                                               
                          
 
                                                       


                                                                  

 
















                                                            

                                                            
                               







                                                                  
                                                       

                                                            
                                                            


                                                            



                                                          


                                                                             






                                                                             


                                                                             






                                                                               
                                                                        


                 




                                          
 
                                                       









                                                                           


                                                           
                                                                               

         
/*
 * Shared interrupt handling code for IPR and INTC2 types of IRQs.
 *
 * Copyright (C) 2007, 2008 Magnus Damm
 *
 * Based on intc2.c and ipr.c
 *
 * Copyright (C) 1999  Niibe Yutaka & Takeshi Yaegashi
 * Copyright (C) 2000  Kazumoto Kojima
 * Copyright (C) 2001  David J. Mckay (david.mckay@st.com)
 * Copyright (C) 2003  Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
 * Copyright (C) 2005, 2006  Paul Mundt
 *
 * 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/module.h>
#include <linux/io.h>
#include <linux/interrupt.h>
#include <linux/bootmem.h>
#include <linux/sh_intc.h>

#define _INTC_MK(fn, mode, addr_e, addr_d, width, shift) \
	((shift) | ((width) << 5) | ((fn) << 9) | ((mode) << 13) | \
	 ((addr_e) << 16) | ((addr_d << 24)))

#define _INTC_SHIFT(h) (h & 0x1f)
#define _INTC_WIDTH(h) ((h >> 5) & 0xf)
#define _INTC_FN(h) ((h >> 9) & 0xf)
#define _INTC_MODE(h) ((h >> 13) & 0x7)
#define _INTC_ADDR_E(h) ((h >> 16) & 0xff)
#define _INTC_ADDR_D(h) ((h >> 24) & 0xff)

struct intc_handle_int {
	unsigned int irq;
	unsigned long handle;
};

struct intc_desc_int {
	unsigned long *reg;
#ifdef CONFIG_SMP
	unsigned long *smp;
#endif
	unsigned int nr_reg;
	struct intc_handle_int *prio;
	unsigned int nr_prio;
	struct intc_handle_int *sense;
	unsigned int nr_sense;
	struct irq_chip chip;
};

#ifdef CONFIG_SMP
#define IS_SMP(x) x.smp
#define INTC_REG(d, x, c) (d->reg[(x)] + ((d->smp[(x)] & 0xff) * c))
#define SMP_NR(d, x) ((d->smp[(x)] >> 8) ? (d->smp[(x)] >> 8) : 1)
#else
#define IS_SMP(x) 0
#define INTC_REG(d, x, c) (d->reg[(x)])
#define SMP_NR(d, x) 1
#endif

static unsigned int intc_prio_level[NR_IRQS]; /* for now */
#if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A)
static unsigned long ack_handle[NR_IRQS];
#endif

static inline struct intc_desc_int *get_intc_desc(unsigned int irq)
{
	struct irq_chip *chip = get_irq_chip(irq);
	return (void *)((char *)chip - offsetof(struct intc_desc_int, chip));
}

static inline unsigned int set_field(unsigned int value,
				     unsigned int field_value,
				     unsigned int handle)
{
	unsigned int width = _INTC_WIDTH(handle);
	unsigned int shift = _INTC_SHIFT(handle);

	value &= ~(((1 << width) - 1) << shift);
	value |= field_value << shift;
	return value;
}

static void write_8(unsigned long addr, unsigned long h, unsigned long data)
{
	__raw_writeb(set_field(0, data, h), addr);
}

static void write_16(unsigned long addr, unsigned long h, unsigned long data)
{
	__raw_writew(set_field(0, data, h), addr);
}

static void write_32(unsigned long addr, unsigned long h, unsigned long data)
{
	__raw_writel(set_field(0, data, h), addr);
}

static void modify_8(unsigned long addr, unsigned long h, unsigned long data)
{
	unsigned long flags;
	local_irq_save(flags);
	__raw_writeb(set_field(__raw_readb(addr), data, h), addr);
	local_irq_restore(flags);
}

static void modify_16(unsigned long addr, unsigned long h, unsigned long data)
{
	unsigned long flags;
	local_irq_save(flags);
	__raw_writew(set_field(__raw_readw(addr), data, h), addr);
	local_irq_restore(flags);
}

static void modify_32(unsigned long addr, unsigned long h, unsigned long data)
{
	unsigned long flags;
	local_irq_save(flags);
	__raw_writel(set_field(__raw_readl(addr), data, h), addr);
	local_irq_restore(flags);
}

enum {	REG_FN_ERR = 0, REG_FN_WRITE_BASE = 1, REG_FN_MODIFY_BASE = 5 };

static void (*intc_reg_fns[])(unsigned long addr,
			      unsigned long h,