| 
									
										
										
										
											2009-12-04 05:04:18 -03:00
										 |  |  | /*
 | 
					
						
							|  |  |  | 	Mantis PCI bridge driver | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-15 09:13:49 -03:00
										 |  |  | 	Copyright (C) Manu Abraham (abraham.manu@gmail.com) | 
					
						
							| 
									
										
										
										
											2009-12-04 05:04:18 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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. | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-04 05:41:11 -03:00
										 |  |  | #include <linux/kernel.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/signal.h>
 | 
					
						
							|  |  |  | #include <linux/sched.h>
 | 
					
						
							|  |  |  | #include <linux/interrupt.h>
 | 
					
						
							| 
									
										
										
										
											2011-06-16 11:01:34 +00:00
										 |  |  | #include <asm/io.h>
 | 
					
						
							| 
									
										
										
										
											2009-12-04 05:41:11 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "dmxdev.h"
 | 
					
						
							|  |  |  | #include "dvbdev.h"
 | 
					
						
							|  |  |  | #include "dvb_demux.h"
 | 
					
						
							|  |  |  | #include "dvb_frontend.h"
 | 
					
						
							|  |  |  | #include "dvb_net.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-04 05:04:18 -03:00
										 |  |  | #include "mantis_common.h"
 | 
					
						
							|  |  |  | #include "mantis_link.h"
 | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | #include "mantis_hif.h"
 | 
					
						
							| 
									
										
										
										
											2009-12-04 05:41:11 -03:00
										 |  |  | #include "mantis_reg.h"
 | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-04 05:09:04 -03:00
										 |  |  | static void mantis_hifevm_work(struct work_struct *work) | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-12-04 05:09:04 -03:00
										 |  |  | 	struct mantis_ca *ca = container_of(work, struct mantis_ca, hif_evm_work); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | 	struct mantis_pci *mantis = ca->ca_priv; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-14 10:22:58 -03:00
										 |  |  | 	u32 gpif_stat; | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	gpif_stat = mmread(MANTIS_GPIF_STATUS); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (gpif_stat & MANTIS_GPIF_DETSTAT) { | 
					
						
							|  |  |  | 		if (gpif_stat & MANTIS_CARD_PLUGIN) { | 
					
						
							| 
									
										
										
										
											2009-12-04 05:41:11 -03:00
										 |  |  | 			dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | 			mmwrite(0xdada0000, MANTIS_CARD_RESET); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:09:04 -03:00
										 |  |  | 			mantis_event_cam_plugin(ca); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:19:26 -03:00
										 |  |  | 			dvb_ca_en50221_camchange_irq(&ca->en50221, | 
					
						
							|  |  |  | 						     0, | 
					
						
							|  |  |  | 						     DVB_CA_EN50221_CAMCHANGE_INSERTED); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		if (gpif_stat & MANTIS_CARD_PLUGOUT) { | 
					
						
							| 
									
										
										
										
											2009-12-04 05:41:11 -03:00
										 |  |  | 			dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | 			mmwrite(0xdada0000, MANTIS_CARD_RESET); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:09:04 -03:00
										 |  |  | 			mantis_event_cam_unplug(ca); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:19:26 -03:00
										 |  |  | 			dvb_ca_en50221_camchange_irq(&ca->en50221, | 
					
						
							|  |  |  | 						     0, | 
					
						
							|  |  |  | 						     DVB_CA_EN50221_CAMCHANGE_REMOVED); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-04 05:26:46 -03:00
										 |  |  | 	if (mantis->gpif_status & MANTIS_GPIF_EXTIRQ) | 
					
						
							| 
									
										
										
										
											2009-12-04 05:41:11 -03:00
										 |  |  | 		dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-04 05:26:46 -03:00
										 |  |  | 	if (mantis->gpif_status & MANTIS_SBUF_WSTO) | 
					
						
							| 
									
										
										
										
											2009-12-04 05:41:11 -03:00
										 |  |  | 		dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-04 05:26:46 -03:00
										 |  |  | 	if (mantis->gpif_status & MANTIS_GPIF_OTHERR) | 
					
						
							| 
									
										
										
										
											2009-12-04 05:41:11 -03:00
										 |  |  | 		dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (gpif_stat & MANTIS_SBUF_OVFLW) | 
					
						
							| 
									
										
										
										
											2009-12-04 05:41:11 -03:00
										 |  |  | 		dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-04 05:25:45 -03:00
										 |  |  | 	if (gpif_stat & MANTIS_GPIF_BRRDY) | 
					
						
							| 
									
										
										
										
											2009-12-04 05:41:11 -03:00
										 |  |  | 		dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:25:45 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | 	if (gpif_stat & MANTIS_GPIF_INTSTAT) | 
					
						
							| 
									
										
										
										
											2009-12-04 05:41:11 -03:00
										 |  |  | 		dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (gpif_stat & MANTIS_SBUF_EMPTY) | 
					
						
							| 
									
										
										
										
											2009-12-04 05:41:11 -03:00
										 |  |  | 		dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (gpif_stat & MANTIS_SBUF_OPDONE) { | 
					
						
							| 
									
										
										
										
											2009-12-04 05:41:11 -03:00
										 |  |  | 		dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:21:51 -03:00
										 |  |  | 		ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL; | 
					
						
							| 
									
										
										
										
											2009-12-04 05:28:24 -03:00
										 |  |  | 		ca->hif_event = MANTIS_SBUF_OPDONE; | 
					
						
							|  |  |  | 		wake_up(&ca->hif_opdone_wq); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:05:19 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-12-04 05:04:18 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | int mantis_evmgr_init(struct mantis_ca *ca) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct mantis_pci *mantis = ca->ca_priv; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-04 05:41:11 -03:00
										 |  |  | 	dprintk(MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager"); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:09:04 -03:00
										 |  |  | 	INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:06:38 -03:00
										 |  |  | 	mantis_pcmcia_init(ca); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:09:04 -03:00
										 |  |  | 	schedule_work(&ca->hif_evm_work); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:09:47 -03:00
										 |  |  | 	mantis_hif_init(ca); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:04:18 -03:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void mantis_evmgr_exit(struct mantis_ca *ca) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct mantis_pci *mantis = ca->ca_priv; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-04 05:41:11 -03:00
										 |  |  | 	dprintk(MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting"); | 
					
						
							| 
									
										
										
										
											2012-08-20 14:51:24 -07:00
										 |  |  | 	flush_work(&ca->hif_evm_work); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:09:47 -03:00
										 |  |  | 	mantis_hif_exit(ca); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:06:38 -03:00
										 |  |  | 	mantis_pcmcia_exit(ca); | 
					
						
							| 
									
										
										
										
											2009-12-04 05:04:18 -03:00
										 |  |  | } |