/include/linux/mlx4/

ter LITMUS^RT and MC^2 V1 support for the i.MX6 processor family.Namhoon Kim
aboutsummaryrefslogblamecommitdiffstats
path: root/drivers/char/epca.c
blob: 9cad8501d62c9fca6a93656c204bb1dea1e09a15 (plain) (tree)
1
2
3
4
5
6
7
8
9
10







                                                                

                                                        




































                                                                              
                           

                      
 





                       

                                                                   
                                          












                                                                       





                                         




                                                                          








































                                                                                 







                                                              


                                                                          





                                                                    


                                                                        





                                                                   



                                                                              





                                                                   


                                                                            







                                                                    


                                                                         

                                                          

































                                                                          


                                                                     
                         
                          












                                                                            
                                                            



                              
                                                             



                               
                                           



                                     
                                       



                                 
                                       



                                 
                                      


                                
                                            



                                      
                                            








                                                               
                                                                  
 
                                        

 
                                                                   
 
                               

 
                                                 



                                                  
                                             



                                                    
                                             



                                                    
                                            





                                                                         
                                                                 
 
                                                 

 
                                                                  
 


                                      

 
                                                



                                                  
                                            



                                                            
                                            



                                                            
                                           






                                                                            
                                                                 
 
                                                      

 
                                                                  
 
                                                

 
                                                
 
                                        

 
                                            
 
                                                

 
                                            
 
                                                

 
                                           
 
                                   

 
                                                 
 
                                                                       

 
                                                 
 
                                                                  











                                                                               
                                                                  


 
                                                                   


 
                                                 


 
                                             


 
                                             


 
                                            


 
                                                  


 
                                                  



                                                                            
                                                            
                           




                                                                                



                                                                                        


                                                    
         





                                                                       

                                                         



                                                                                    

                                   




                                                                   
 
                                                                      
 


                                                                 
 

                            



                                                                        



                                                                           

                               
                                                                        

                                                                  



                                                                                            
                                                                  



                                                                        
                                      





                                                                                     
                                                

                                 


                                                          



                                                                                         




                                                       

                                                     


                                 
                                                          
 
                                                                    
                                             
                                                                                        
                                                              
                                           


                                                                              
                                 








                                                                  
                                      



                                                   
                                             
 
                        








                                                                                 
                                      





                                                                             
                                             


                                                                      









                                                                                  
                                                  






                                                                   






                                                                        
                                                                           

                                    




                                                       
                                                     


                                 
                                                                             
                                                          
                                                      








                                                                  



                                


                            
                                      





















                                                                              
                         
 
                                             

                        

                                            
 

                                        


                                                                 
                                                             






                                                                                       

                                                  
                                                    




                                           



                                                                                 
                                                     









                                                                                      
                                                            




                                          
                                   


                                       
                                                         

                                  
                               
 
                                                
                                           
                                     

                   
                                                  







                                                                     
                             










                                                                       
                                      







                                                                        

                                                     


                                   

                                                             
 

                                                





                                                    
                                                                 
                                                   
                                             

                           
                                                          
         














                                                                         
                                      








                                                                        
                                             


                         


                                          
 
                                                                                        
                          

                                                                   
                                            




                                                                                       

                                                    
                                                      






                                                                                    



                                                           
                   
                                                  












                                                                      
                                      



                                                                        


                                              
                                             
                        
                           
                                
                                                                              
                                                    
                   
                                                  

                                                





                                                                     
                            



                                                                        
                                                
                                    
                                                     



                                                                                      

                                                                                 
                                                          
         






                                                                      



                                        
                                  










                                                                               
                                             







                                                        
                                          



                                                                                       
                                                      

                         

                                           
                                                                              


                                              
 
                                             


                                                                         
                           

                                    
                                                      








                                                              


                                                                
                                              


                                              
                                                          






                                                                                       
                                                     




                                                 

                                 

                           

                                                  



                                              
                 









                                                              
                                      
                          

                          

                                       











                                                                                  
                                  
                                                          
                                                                                                            
                                                         
                                                                                                                 
                                                        
                                                                                                                      
                                                         
                                                                                                                    
                                                            
                                                                                                              
                                                      
                                                                                                              
                                                                           
                               
         
                                                                            



                                                                           
                                      
                                        
                               

         
                                             




                                                                                  
                    




                                                                             
                              



                                                                                 



                                              
                                       




                                                                            

                                








                                                                               

                                            
                                                  


                                                
                              



                                                                          
                                             
                      
                        
                                     
                              
                   
                                                  
                 

                   

                                        
                         


                              
 
                                     


                                         


                                     


                                    


                                                   
                                                                                               




                                  
                                                                          
                                  




                                                                                    
                                   

                                                                     
                                 



                                                            

                                         
                                             
 
 
                              






























                                                                
                               
                     



                                   


                                        
















                                                                                      
                                                                                 





















                                                                                
























                                                                                         





























                                                                               











































































































                                                                                         
                                                                                                                         


















                                                                                 









                                                                    

                                       
                              
                                      

















                                                                                     
                                                                     












                                                                                              

                                                                              

                                                                                        




                                                                   






                                                                             

                                                                        
                                     






                                                                               
                                  







                                                                                 
                              





                                                                                  
                                                                                       



                                                                            








                                                                                   

                                                                                   
                               





                                                       

                                                     































                                                                                              
                                         



                                                              
                      








                                            
                                



                                                           


                                        
                                   




                                                              



                                                                               





                                                                      



                                                                             



                                      



                                                                                                



                                      

                                                                                     





                                                          
                                                     

                                  
                                                     













                                                                              

                                         
        



                                                  













                                                     


                                                          
                                                                
                                   




                                                                                            
                      





                                                                                                






















                                                                                    














                                                                                          

                                                     








                                                                                        

                                                 




                                                                  

                           
                                                          
 
                                 
                                                    






                                                                   
                               

                                      
                              
                                      


                                




                                                                                



                                                                           
                            
                                                                                             
                                                    
                                    
                                                              
                                                           
                                          
                                                             
                                            




                                                                                        

                                            

                                     
                                                                








                                                    
                                                             

                                         

                                                                 
                                                                     
                                                                      
                                           
                                                               




                                                                                                   
                                        
                              

                                                                          
                                                                
                                                                        
                                                        
                                                                              

                                                               


                                                                                
                                                      
                                                                                  
                                                                                  
                                                           
                                                                                            

                                                                      
                                                                                
                                                        
                                               
                                        

                                


                                                                                
                                   
                                                  






                                                                  
                                






                                                                              
                       
                         
                                                                              
                                        
                                        
                                               




                                                                                
                                                            

                                            


                                                                                                                    

                       


                                                                       
                                                       
                                                                     
                                                  




                                                                       
         
                                                    
                                        

                           
                                            
                        
                                  


                                                                                      

                                                    
                                                               



                                                                                  

                                                            
                                












                                                                            

                         
                              


































                                                                     











                                                                     
                                                           
                                                    



                                                                                    
                                 

                                                   






                                                                                 


















                                                                                        

                                                                                    









                                                                                       
                                 
         





                                                                    
                                




                                                                 
                                      





                                              
                          

                                                                     
                                           
                                          




                                                                                          

                                                               
                                                



                                                                                          
                                                        
                                             



                                                                            




                                                                                      
                                         
                                                          
                    
                                                         
                                             
                                      
                                                
                                    
                                     
                                     




                                                                                        


                                                                                          




                                                                                    
                                   

                                                                               

                                             
                                                
                                  
                                  



                                                                                    

                                                        

                                                   
                                 
                                  










                                                                                       
         
                                                                        

                                           



                                                                                  

                                                                       
                                                                            

                                             



                                                                                     

                                                                            


                                                                       
                       





                                            
                                      

                                                
                              
 





                                                                              

                                        


                                  
                         
                    





                                                                                   
                               
                         
                                           

                                                  






                                                                                
                                                     
                                        


                       
                                                                  

                       


                                                                                      
                                                          
         
                    
                                                                                 
                                                                              




                                                                                    
                                                                                   


                                                                                    
                                                                             

                                    



                                                                                     
                                                                  

                                                      
                                                   
                        
                                


                                             






                                                                 

                                               


                                             



                                                                          






                                                            


                                                                            












                                                                               

                                                                                        

                                                 

                                                       



                                            





                                                                                             


                                                              
                                
                                          
                        
                                       







                                                                   
                                      





                                      
                               
 
                                             
                        
                                  
                   
                                                  


                                   

                                   

                                   

                                   

                                  

                                  








                                                                 

                               
 
                                             




















                                                                
                        



                                                                              

                          
                                                  











                                                               
                                      





                                                                 
                               










                                                                                      
                                                                                     
                                               
                                 

                                                     
                                                                             


                                                       
                                                                                         
                                                             
                                                                
                                                                  



                                                                              
                                                                     




                                                                                         
                                                             
                                                                
                                                                  


                                                                      



                                                                                     










                                                                     




                                                                          



                                                                     
                              
                                                             
                                                


                                                                  
                                                                  


                              
                                                             
                                                 


                                                                  
                                                                  
                              



                                                                             

                                
                                                
                                                                                                 
                                                                     
                                                                        
                                                                          
                                                            
                                 



                                                                      
                                       



                                                                               
                                                                    

                                                    
                                



                                                    
                                                             








                                                                                               
                                                                  



                                   
                                                             
                                        





                                                                   

                                   
                                                                  






                                                                      
                                                  

                                                    
                                






                                                                        

                                                                                                             

                                                
                                                          


                                                                                               
                                        




                                                                                                    
                                                                


                                                      
                                                                          

                                                      

                                            
                              
                 








                                                                               



                                                                        

                                                                              


                                   
                                                          








                                                                  







                                                                     
                                                         
                                                        
                                                                    

                                                 

                                                                                                         


                                                                                                    

                                                














                                                                   



                                                                        


                                                                                                 
                                        
                                                      
                                                        

                                                     
                                                      
                                                          
                                    





                                                                   
                           



                                                                        
                                                                             
                                    
                                                     
                                                                                      
                                                                                         
                                                      


                                                      
                                                     
                                                                       
                                                         

                                                      
                                                     
                                                          
                                    













                                                                         

                            



                                                                        


                                                                              

                                                        


                                                     
                                                          
                                    





                                                                     

                            



                                                                        
                                                                              
                                                                                      

                                                     
                                        
                                                         


                                                      
                                                          
                                    





                                                                          

                            
                                             
                        






                                                                                   

                                              
                                                  



                                                                            

                               


                                                                         
                                                    
 

                                     



                                                                                  
                               
                   







                                                                             
 


                                                                         




















                                                                                       

                                                           




                                                                                                
                                                                                                               




                                                                                      

                                                                                                                 





                                                                                 

                                                         

                                                                                                             





                                                                               

                                                           

                                                                                                                 








                                                                           

                                                                                                                     








                                                                              


                                                                                                                        







                                                                              


                                                                                                                              












                                                                                                  
                                                                      

                                                       


                                                                             



                                    








                                                                       
                                                                          
                                                         

                                                                                                







                                                                                 


                                                                               



                                                                                                    

                                                            

                                                                                                     










                                                                               
                                                                          
                                                         

                                                                                                











                                                                           

                                                                                                    



























                                                                                                        

                                                                                                     




                                                                              
                                                                           







                                                     

                                                                                                    



                                                                             
                                                                              

                                             
                                
                                                                                 


                                       

                                               

                                                                        



                                                     

                                                                         
                                                               


                                                                                         
                    


                      




















                                                                          
























                                                                               

                                                      



























































                                                                                   
                            





                                                       
 

                      
/*

 
	Copyright (C) 1996  Digi International.
 
	For technical support please email digiLinux@dgii.com or
	call Digi tech support at (612) 912-3456

	** This driver is no longer supported by Digi **

	Much of this design and code came from epca.c which was 
	copyright (C) 1994, 1995 Troy De Jongh, and subsquently 
	modified by David Nugent, Christoph Lameter, Mike McLagan. 
 
 	This program is free software; you can redistribute it and/or modify
 	it under the terms of the GNU General Public License as published by
 	the Free Software Foundation; either version 2 of the License, or
 	(at your option) any later version.

 	This program is distributed in the hope that it will be useful,
 	but WITHOUT ANY WARRANTY; without even the implied warranty of
 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 	GNU General Public License for more details.

 	You should have received a copy of the GNU General Public License
 	along with this program; if not, write to the Free Software
 	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

--------------------------------------------------------------------------- */
/* See README.epca for change history --DAT*/


#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/init.h>
#include <linux/serial.h>
#include <linux/delay.h>
#include <linux/ctype.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/slab.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#include <linux/spinlock.h>
#include <linux/pci.h>
#include "digiPCI.h"


#include "digi1.h"
#include "digiFep1.h"
#include "epca.h"
#include "epcaconfig.h"

/* ---------------------- Begin defines ------------------------ */

#define VERSION            "1.3.0.1-LK2.6"

/* This major needs to be submitted to Linux to join the majors list */

#define DIGIINFOMAJOR       35  /* For Digi specific ioctl */ 


#define MAXCARDS 7
#define epcaassert(x, msg)  if (!(x)) epca_error(__LINE__, msg)

#define PFX "epca: "

/* ----------------- Begin global definitions ------------------- */

static int nbdevs, num_cards, liloconfig;
static int digi_poller_inhibited = 1 ;

static int setup_error_code;
static int invalid_lilo_config;

/* The ISA boards do window flipping into the same spaces so its only sane
   with a single lock. It's still pretty efficient */

static spinlock_t epca_lock = SPIN_LOCK_UNLOCKED;

/* -----------------------------------------------------------------------
	MAXBOARDS is typically 12, but ISA and EISA cards are restricted to 
	7 below.
--------------------------------------------------------------------------*/
static struct board_info boards[MAXBOARDS];


/* ------------- Begin structures used for driver registeration ---------- */

static struct tty_driver *pc_driver;
static struct tty_driver *pc_info;

/* ------------------ Begin Digi specific structures -------------------- */

/* ------------------------------------------------------------------------
	digi_channels represents an array of structures that keep track of
	each channel of the Digi product.  Information such as transmit and
	receive pointers, termio data, and signal definitions (DTR, CTS, etc ...)
	are stored here.  This structure is NOT used to overlay the cards 
	physical channel structure.
-------------------------------------------------------------------------- */
  
static struct channel digi_channels[MAX_ALLOC];

/* ------------------------------------------------------------------------
	card_ptr is an array used to hold the address of the
	first channel structure of each card.  This array will hold
	the addresses of various channels located in digi_channels.
-------------------------------------------------------------------------- */
static struct channel *card_ptr[MAXCARDS];

static struct timer_list epca_timer;

/* ---------------------- Begin function prototypes --------------------- */

/* ----------------------------------------------------------------------
	Begin generic memory functions.  These functions will be alias
	(point at) more specific functions dependent on the board being
	configured.
----------------------------------------------------------------------- */
	
static void memwinon(struct board_info *b, unsigned int win);
static void memwinoff(struct board_info *b, unsigned int win);
static void globalwinon(struct channel *ch);
static void rxwinon(struct channel *ch);
static void txwinon(struct channel *ch);
static void memoff(struct channel *ch);
static void assertgwinon(struct channel *ch);
static void assertmemoff(struct channel *ch);

/* ---- Begin more 'specific' memory functions for cx_like products --- */

static void pcxem_memwinon(struct board_info *b, unsigned int win);
static void pcxem_memwinoff(struct board_info *b, unsigned int win);
static void pcxem_globalwinon(struct channel *ch);
static void pcxem_rxwinon(struct channel *ch);
static void pcxem_txwinon(struct channel *ch);
static void pcxem_memoff(struct channel *ch);

/* ------ Begin more 'specific' memory functions for the pcxe ------- */

static void pcxe_memwinon(struct board_info *b, unsigned int win);
static void pcxe_memwinoff(struct board_info *b, unsigned int win);
static void pcxe_globalwinon(struct channel *ch);
static void pcxe_rxwinon(struct channel *ch);
static void pcxe_txwinon(struct channel *ch);
static void pcxe_memoff(struct channel *ch);

/* ---- Begin more 'specific' memory functions for the pc64xe and pcxi ---- */
/* Note : pc64xe and pcxi share the same windowing routines */

static void pcxi_memwinon(struct board_info *b, unsigned int win);
static void pcxi_memwinoff(struct board_info *b, unsigned int win);
static void pcxi_globalwinon(struct channel *ch);
static void pcxi_rxwinon(struct channel *ch);
static void pcxi_txwinon(struct channel *ch);
static void pcxi_memoff(struct channel *ch);

/* - Begin 'specific' do nothing memory functions needed for some cards - */

static void dummy_memwinon(struct board_info *b, unsigned int win);
static void dummy_memwinoff(struct board_info *b, unsigned int win);
static void dummy_globalwinon(struct channel *ch);
static void dummy_rxwinon(struct channel *ch);
static void dummy_txwinon(struct channel *ch);
static void dummy_memoff(struct channel *ch);
static void dummy_assertgwinon(struct channel *ch);
static void dummy_assertmemoff(struct channel *ch);

/* ------------------- Begin declare functions ----------------------- */

static struct channel *verifyChannel(struct tty_struct *);
static void pc_sched_event(struct channel *, int);
static void epca_error(int, char *);
static void pc_close(struct tty_struct *, struct file *);
static void shutdown(struct channel *);
static void pc_hangup(struct tty_struct *);
static void pc_put_char(struct tty_struct *, unsigned char);
static int pc_write_room(struct tty_struct *);
static int pc_chars_in_buffer(struct tty_struct *);
static void pc_flush_buffer(struct tty_struct *);
static void pc_flush_chars(struct tty_struct *);
static int block_til_ready(struct tty_struct *, struct file *,
                           struct channel *);
static int pc_open(struct tty_struct *, struct file *);
static void post_fep_init(unsigned int crd);
static void epcapoll(unsigned long);
static void doevent(int);
static void fepcmd(struct channel *, int, int, int, int, int);
static unsigned termios2digi_h(struct channel *ch, unsigned);
static unsigned termios2digi_i(struct channel *ch, unsigned);
static unsigned termios2digi_c(struct channel *ch, unsigned);
static void epcaparam(struct tty_struct *, struct channel *);
static void receive_data(struct channel *);
static int pc_ioctl(struct tty_struct *, struct file *,
                    unsigned int, unsigned long);
static int info_ioctl(struct tty_struct *, struct file *,
                    unsigned int, unsigned long);
static void pc_set_termios(struct tty_struct *, struct termios *);
static void do_softint(void *);
static void pc_stop(struct tty_struct *);
static void pc_start(struct tty_struct *);
static void pc_throttle(struct tty_struct * tty);