125aee3deSMauro Carvalho Chehab /* 225aee3deSMauro Carvalho Chehab Mantis PCI bridge driver 325aee3deSMauro Carvalho Chehab 425aee3deSMauro Carvalho Chehab Copyright (C) Manu Abraham (abraham.manu@gmail.com) 525aee3deSMauro Carvalho Chehab 625aee3deSMauro Carvalho Chehab This program is free software; you can redistribute it and/or modify 725aee3deSMauro Carvalho Chehab it under the terms of the GNU General Public License as published by 825aee3deSMauro Carvalho Chehab the Free Software Foundation; either version 2 of the License, or 925aee3deSMauro Carvalho Chehab (at your option) any later version. 1025aee3deSMauro Carvalho Chehab 1125aee3deSMauro Carvalho Chehab This program is distributed in the hope that it will be useful, 1225aee3deSMauro Carvalho Chehab but WITHOUT ANY WARRANTY; without even the implied warranty of 1325aee3deSMauro Carvalho Chehab MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1425aee3deSMauro Carvalho Chehab GNU General Public License for more details. 1525aee3deSMauro Carvalho Chehab 1625aee3deSMauro Carvalho Chehab You should have received a copy of the GNU General Public License 1725aee3deSMauro Carvalho Chehab along with this program; if not, write to the Free Software 1825aee3deSMauro Carvalho Chehab Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 1925aee3deSMauro Carvalho Chehab */ 2025aee3deSMauro Carvalho Chehab 2125aee3deSMauro Carvalho Chehab #include <linux/kernel.h> 2225aee3deSMauro Carvalho Chehab 2325aee3deSMauro Carvalho Chehab #include <linux/signal.h> 2425aee3deSMauro Carvalho Chehab #include <linux/sched.h> 2525aee3deSMauro Carvalho Chehab #include <linux/interrupt.h> 2625aee3deSMauro Carvalho Chehab #include <asm/io.h> 2725aee3deSMauro Carvalho Chehab 2825aee3deSMauro Carvalho Chehab #include "dmxdev.h" 2925aee3deSMauro Carvalho Chehab #include "dvbdev.h" 3025aee3deSMauro Carvalho Chehab #include "dvb_demux.h" 3125aee3deSMauro Carvalho Chehab #include "dvb_frontend.h" 3225aee3deSMauro Carvalho Chehab #include "dvb_net.h" 3325aee3deSMauro Carvalho Chehab 3425aee3deSMauro Carvalho Chehab #include "mantis_common.h" 3525aee3deSMauro Carvalho Chehab #include "mantis_link.h" 3625aee3deSMauro Carvalho Chehab #include "mantis_hif.h" 3725aee3deSMauro Carvalho Chehab #include "mantis_reg.h" 3825aee3deSMauro Carvalho Chehab 3925aee3deSMauro Carvalho Chehab static void mantis_hifevm_work(struct work_struct *work) 4025aee3deSMauro Carvalho Chehab { 4125aee3deSMauro Carvalho Chehab struct mantis_ca *ca = container_of(work, struct mantis_ca, hif_evm_work); 4225aee3deSMauro Carvalho Chehab struct mantis_pci *mantis = ca->ca_priv; 4325aee3deSMauro Carvalho Chehab 4425aee3deSMauro Carvalho Chehab u32 gpif_stat; 4525aee3deSMauro Carvalho Chehab 4625aee3deSMauro Carvalho Chehab gpif_stat = mmread(MANTIS_GPIF_STATUS); 4725aee3deSMauro Carvalho Chehab 4825aee3deSMauro Carvalho Chehab if (gpif_stat & MANTIS_GPIF_DETSTAT) { 4925aee3deSMauro Carvalho Chehab if (gpif_stat & MANTIS_CARD_PLUGIN) { 5025aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num); 5125aee3deSMauro Carvalho Chehab mmwrite(0xdada0000, MANTIS_CARD_RESET); 5225aee3deSMauro Carvalho Chehab mantis_event_cam_plugin(ca); 5325aee3deSMauro Carvalho Chehab dvb_ca_en50221_camchange_irq(&ca->en50221, 5425aee3deSMauro Carvalho Chehab 0, 5525aee3deSMauro Carvalho Chehab DVB_CA_EN50221_CAMCHANGE_INSERTED); 5625aee3deSMauro Carvalho Chehab } 5725aee3deSMauro Carvalho Chehab } else { 5825aee3deSMauro Carvalho Chehab if (gpif_stat & MANTIS_CARD_PLUGOUT) { 5925aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num); 6025aee3deSMauro Carvalho Chehab mmwrite(0xdada0000, MANTIS_CARD_RESET); 6125aee3deSMauro Carvalho Chehab mantis_event_cam_unplug(ca); 6225aee3deSMauro Carvalho Chehab dvb_ca_en50221_camchange_irq(&ca->en50221, 6325aee3deSMauro Carvalho Chehab 0, 6425aee3deSMauro Carvalho Chehab DVB_CA_EN50221_CAMCHANGE_REMOVED); 6525aee3deSMauro Carvalho Chehab } 6625aee3deSMauro Carvalho Chehab } 6725aee3deSMauro Carvalho Chehab 6825aee3deSMauro Carvalho Chehab if (mantis->gpif_status & MANTIS_GPIF_EXTIRQ) 6925aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num); 7025aee3deSMauro Carvalho Chehab 7125aee3deSMauro Carvalho Chehab if (mantis->gpif_status & MANTIS_SBUF_WSTO) 7225aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num); 7325aee3deSMauro Carvalho Chehab 7425aee3deSMauro Carvalho Chehab if (mantis->gpif_status & MANTIS_GPIF_OTHERR) 7525aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num); 7625aee3deSMauro Carvalho Chehab 7725aee3deSMauro Carvalho Chehab if (gpif_stat & MANTIS_SBUF_OVFLW) 7825aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num); 7925aee3deSMauro Carvalho Chehab 8025aee3deSMauro Carvalho Chehab if (gpif_stat & MANTIS_GPIF_BRRDY) 8125aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num); 8225aee3deSMauro Carvalho Chehab 8325aee3deSMauro Carvalho Chehab if (gpif_stat & MANTIS_GPIF_INTSTAT) 8425aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num); 8525aee3deSMauro Carvalho Chehab 8625aee3deSMauro Carvalho Chehab if (gpif_stat & MANTIS_SBUF_EMPTY) 8725aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num); 8825aee3deSMauro Carvalho Chehab 8925aee3deSMauro Carvalho Chehab if (gpif_stat & MANTIS_SBUF_OPDONE) { 9025aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num); 9125aee3deSMauro Carvalho Chehab ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL; 9225aee3deSMauro Carvalho Chehab ca->hif_event = MANTIS_SBUF_OPDONE; 9325aee3deSMauro Carvalho Chehab wake_up(&ca->hif_opdone_wq); 9425aee3deSMauro Carvalho Chehab } 9525aee3deSMauro Carvalho Chehab } 9625aee3deSMauro Carvalho Chehab 9725aee3deSMauro Carvalho Chehab int mantis_evmgr_init(struct mantis_ca *ca) 9825aee3deSMauro Carvalho Chehab { 9925aee3deSMauro Carvalho Chehab struct mantis_pci *mantis = ca->ca_priv; 10025aee3deSMauro Carvalho Chehab 10125aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager"); 10225aee3deSMauro Carvalho Chehab INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work); 10325aee3deSMauro Carvalho Chehab mantis_pcmcia_init(ca); 10425aee3deSMauro Carvalho Chehab schedule_work(&ca->hif_evm_work); 10525aee3deSMauro Carvalho Chehab mantis_hif_init(ca); 10625aee3deSMauro Carvalho Chehab return 0; 10725aee3deSMauro Carvalho Chehab } 10825aee3deSMauro Carvalho Chehab 10925aee3deSMauro Carvalho Chehab void mantis_evmgr_exit(struct mantis_ca *ca) 11025aee3deSMauro Carvalho Chehab { 11125aee3deSMauro Carvalho Chehab struct mantis_pci *mantis = ca->ca_priv; 11225aee3deSMauro Carvalho Chehab 11325aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting"); 114*0b8e74c6SLinus Torvalds flush_work(&ca->hif_evm_work); 11525aee3deSMauro Carvalho Chehab mantis_hif_exit(ca); 11625aee3deSMauro Carvalho Chehab mantis_pcmcia_exit(ca); 11725aee3deSMauro Carvalho Chehab } 118