Path: blob/master/drivers/media/dvb/mantis/mantis_evm.c
15112 views
/*1Mantis PCI bridge driver23Copyright (C) Manu Abraham ([email protected])45This program is free software; you can redistribute it and/or modify6it under the terms of the GNU General Public License as published by7the Free Software Foundation; either version 2 of the License, or8(at your option) any later version.910This program is distributed in the hope that it will be useful,11but WITHOUT ANY WARRANTY; without even the implied warranty of12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13GNU General Public License for more details.1415You should have received a copy of the GNU General Public License16along with this program; if not, write to the Free Software17Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.18*/1920#include <linux/kernel.h>2122#include <linux/signal.h>23#include <linux/sched.h>24#include <linux/interrupt.h>2526#include "dmxdev.h"27#include "dvbdev.h"28#include "dvb_demux.h"29#include "dvb_frontend.h"30#include "dvb_net.h"3132#include "mantis_common.h"33#include "mantis_link.h"34#include "mantis_hif.h"35#include "mantis_reg.h"3637static void mantis_hifevm_work(struct work_struct *work)38{39struct mantis_ca *ca = container_of(work, struct mantis_ca, hif_evm_work);40struct mantis_pci *mantis = ca->ca_priv;4142u32 gpif_stat, gpif_mask;4344gpif_stat = mmread(MANTIS_GPIF_STATUS);45gpif_mask = mmread(MANTIS_GPIF_IRQCFG);4647if (gpif_stat & MANTIS_GPIF_DETSTAT) {48if (gpif_stat & MANTIS_CARD_PLUGIN) {49dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num);50mmwrite(0xdada0000, MANTIS_CARD_RESET);51mantis_event_cam_plugin(ca);52dvb_ca_en50221_camchange_irq(&ca->en50221,530,54DVB_CA_EN50221_CAMCHANGE_INSERTED);55}56} else {57if (gpif_stat & MANTIS_CARD_PLUGOUT) {58dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num);59mmwrite(0xdada0000, MANTIS_CARD_RESET);60mantis_event_cam_unplug(ca);61dvb_ca_en50221_camchange_irq(&ca->en50221,620,63DVB_CA_EN50221_CAMCHANGE_REMOVED);64}65}6667if (mantis->gpif_status & MANTIS_GPIF_EXTIRQ)68dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num);6970if (mantis->gpif_status & MANTIS_SBUF_WSTO)71dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num);7273if (mantis->gpif_status & MANTIS_GPIF_OTHERR)74dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num);7576if (gpif_stat & MANTIS_SBUF_OVFLW)77dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num);7879if (gpif_stat & MANTIS_GPIF_BRRDY)80dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num);8182if (gpif_stat & MANTIS_GPIF_INTSTAT)83dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num);8485if (gpif_stat & MANTIS_SBUF_EMPTY)86dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num);8788if (gpif_stat & MANTIS_SBUF_OPDONE) {89dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num);90ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL;91ca->hif_event = MANTIS_SBUF_OPDONE;92wake_up(&ca->hif_opdone_wq);93}94}9596int mantis_evmgr_init(struct mantis_ca *ca)97{98struct mantis_pci *mantis = ca->ca_priv;99100dprintk(MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager");101INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work);102mantis_pcmcia_init(ca);103schedule_work(&ca->hif_evm_work);104mantis_hif_init(ca);105return 0;106}107108void mantis_evmgr_exit(struct mantis_ca *ca)109{110struct mantis_pci *mantis = ca->ca_priv;111112dprintk(MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting");113flush_work_sync(&ca->hif_evm_work);114mantis_hif_exit(ca);115mantis_pcmcia_exit(ca);116}117118119