1*74ba9207SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 225aee3deSMauro Carvalho Chehab /* 325aee3deSMauro Carvalho Chehab Mantis PCI bridge driver 425aee3deSMauro Carvalho Chehab 525aee3deSMauro Carvalho Chehab Copyright (C) Manu Abraham (abraham.manu@gmail.com) 625aee3deSMauro Carvalho Chehab 725aee3deSMauro Carvalho Chehab */ 825aee3deSMauro Carvalho Chehab 925aee3deSMauro Carvalho Chehab #include <linux/kernel.h> 1025aee3deSMauro Carvalho Chehab 1125aee3deSMauro Carvalho Chehab #include <linux/signal.h> 1225aee3deSMauro Carvalho Chehab #include <linux/sched.h> 1325aee3deSMauro Carvalho Chehab #include <linux/interrupt.h> 1425aee3deSMauro Carvalho Chehab #include <asm/io.h> 1525aee3deSMauro Carvalho Chehab 16fada1935SMauro Carvalho Chehab #include <media/dmxdev.h> 17fada1935SMauro Carvalho Chehab #include <media/dvbdev.h> 18fada1935SMauro Carvalho Chehab #include <media/dvb_demux.h> 19fada1935SMauro Carvalho Chehab #include <media/dvb_frontend.h> 20fada1935SMauro Carvalho Chehab #include <media/dvb_net.h> 2125aee3deSMauro Carvalho Chehab 2225aee3deSMauro Carvalho Chehab #include "mantis_common.h" 2325aee3deSMauro Carvalho Chehab #include "mantis_link.h" 2425aee3deSMauro Carvalho Chehab #include "mantis_hif.h" 2525aee3deSMauro Carvalho Chehab #include "mantis_reg.h" 2625aee3deSMauro Carvalho Chehab 2725aee3deSMauro Carvalho Chehab static void mantis_hifevm_work(struct work_struct *work) 2825aee3deSMauro Carvalho Chehab { 2925aee3deSMauro Carvalho Chehab struct mantis_ca *ca = container_of(work, struct mantis_ca, hif_evm_work); 3025aee3deSMauro Carvalho Chehab struct mantis_pci *mantis = ca->ca_priv; 3125aee3deSMauro Carvalho Chehab 3225aee3deSMauro Carvalho Chehab u32 gpif_stat; 3325aee3deSMauro Carvalho Chehab 3425aee3deSMauro Carvalho Chehab gpif_stat = mmread(MANTIS_GPIF_STATUS); 3525aee3deSMauro Carvalho Chehab 3625aee3deSMauro Carvalho Chehab if (gpif_stat & MANTIS_GPIF_DETSTAT) { 3725aee3deSMauro Carvalho Chehab if (gpif_stat & MANTIS_CARD_PLUGIN) { 3825aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num); 3925aee3deSMauro Carvalho Chehab mmwrite(0xdada0000, MANTIS_CARD_RESET); 4025aee3deSMauro Carvalho Chehab mantis_event_cam_plugin(ca); 4125aee3deSMauro Carvalho Chehab dvb_ca_en50221_camchange_irq(&ca->en50221, 4225aee3deSMauro Carvalho Chehab 0, 4325aee3deSMauro Carvalho Chehab DVB_CA_EN50221_CAMCHANGE_INSERTED); 4425aee3deSMauro Carvalho Chehab } 4525aee3deSMauro Carvalho Chehab } else { 4625aee3deSMauro Carvalho Chehab if (gpif_stat & MANTIS_CARD_PLUGOUT) { 4725aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num); 4825aee3deSMauro Carvalho Chehab mmwrite(0xdada0000, MANTIS_CARD_RESET); 4925aee3deSMauro Carvalho Chehab mantis_event_cam_unplug(ca); 5025aee3deSMauro Carvalho Chehab dvb_ca_en50221_camchange_irq(&ca->en50221, 5125aee3deSMauro Carvalho Chehab 0, 5225aee3deSMauro Carvalho Chehab DVB_CA_EN50221_CAMCHANGE_REMOVED); 5325aee3deSMauro Carvalho Chehab } 5425aee3deSMauro Carvalho Chehab } 5525aee3deSMauro Carvalho Chehab 5625aee3deSMauro Carvalho Chehab if (mantis->gpif_status & MANTIS_GPIF_EXTIRQ) 5725aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num); 5825aee3deSMauro Carvalho Chehab 5925aee3deSMauro Carvalho Chehab if (mantis->gpif_status & MANTIS_SBUF_WSTO) 6025aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num); 6125aee3deSMauro Carvalho Chehab 6225aee3deSMauro Carvalho Chehab if (mantis->gpif_status & MANTIS_GPIF_OTHERR) 6325aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num); 6425aee3deSMauro Carvalho Chehab 6525aee3deSMauro Carvalho Chehab if (gpif_stat & MANTIS_SBUF_OVFLW) 6625aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num); 6725aee3deSMauro Carvalho Chehab 6825aee3deSMauro Carvalho Chehab if (gpif_stat & MANTIS_GPIF_BRRDY) 6925aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num); 7025aee3deSMauro Carvalho Chehab 7125aee3deSMauro Carvalho Chehab if (gpif_stat & MANTIS_GPIF_INTSTAT) 7225aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num); 7325aee3deSMauro Carvalho Chehab 7425aee3deSMauro Carvalho Chehab if (gpif_stat & MANTIS_SBUF_EMPTY) 7525aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num); 7625aee3deSMauro Carvalho Chehab 7725aee3deSMauro Carvalho Chehab if (gpif_stat & MANTIS_SBUF_OPDONE) { 7825aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num); 7925aee3deSMauro Carvalho Chehab ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL; 8025aee3deSMauro Carvalho Chehab ca->hif_event = MANTIS_SBUF_OPDONE; 8125aee3deSMauro Carvalho Chehab wake_up(&ca->hif_opdone_wq); 8225aee3deSMauro Carvalho Chehab } 8325aee3deSMauro Carvalho Chehab } 8425aee3deSMauro Carvalho Chehab 8525aee3deSMauro Carvalho Chehab int mantis_evmgr_init(struct mantis_ca *ca) 8625aee3deSMauro Carvalho Chehab { 8725aee3deSMauro Carvalho Chehab struct mantis_pci *mantis = ca->ca_priv; 8825aee3deSMauro Carvalho Chehab 8925aee3deSMauro Carvalho Chehab dprintk(MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager"); 9025aee3deSMauro Carvalho Chehab INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work); 9125aee3deSMauro Carvalho Chehab mantis_pcmcia_init(ca); 9225aee3deSMauro Carvalho Chehab schedule_work(&ca->hif_evm_work); 9325aee3deSMauro Carvalho Chehab mantis_hif_init(ca); 9425aee3deSMauro Carvalho Chehab return 0; 9525aee3deSMauro Carvalho Chehab } 9625aee3deSMauro Carvalho Chehab 9725aee3deSMauro Carvalho Chehab void mantis_evmgr_exit(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, "Mantis Host I/F Event manager exiting"); 1020b8e74c6SLinus Torvalds flush_work(&ca->hif_evm_work); 10325aee3deSMauro Carvalho Chehab mantis_hif_exit(ca); 10425aee3deSMauro Carvalho Chehab mantis_pcmcia_exit(ca); 10525aee3deSMauro Carvalho Chehab } 106