Path: blob/master/drivers/media/dvb/mantis/mantis_pcmcia.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" /* temporary due to physical layer stuff */34#include "mantis_reg.h"3536/*37* If Slot state is already PLUG_IN event and we are called38* again, definitely it is jitter alone39*/40void mantis_event_cam_plugin(struct mantis_ca *ca)41{42struct mantis_pci *mantis = ca->ca_priv;4344u32 gpif_irqcfg;4546if (ca->slot_state == MODULE_XTRACTED) {47dprintk(MANTIS_DEBUG, 1, "Event: CAM Plugged IN: Adapter(%d) Slot(0)", mantis->num);48udelay(50);49mmwrite(0xda000000, MANTIS_CARD_RESET);50gpif_irqcfg = mmread(MANTIS_GPIF_IRQCFG);51gpif_irqcfg |= MANTIS_MASK_PLUGOUT;52gpif_irqcfg &= ~MANTIS_MASK_PLUGIN;53mmwrite(gpif_irqcfg, MANTIS_GPIF_IRQCFG);54udelay(500);55ca->slot_state = MODULE_INSERTED;56}57udelay(100);58}5960/*61* If Slot state is already UN_PLUG event and we are called62* again, definitely it is jitter alone63*/64void mantis_event_cam_unplug(struct mantis_ca *ca)65{66struct mantis_pci *mantis = ca->ca_priv;6768u32 gpif_irqcfg;6970if (ca->slot_state == MODULE_INSERTED) {71dprintk(MANTIS_DEBUG, 1, "Event: CAM Unplugged: Adapter(%d) Slot(0)", mantis->num);72udelay(50);73mmwrite(0x00da0000, MANTIS_CARD_RESET);74gpif_irqcfg = mmread(MANTIS_GPIF_IRQCFG);75gpif_irqcfg |= MANTIS_MASK_PLUGIN;76gpif_irqcfg &= ~MANTIS_MASK_PLUGOUT;77mmwrite(gpif_irqcfg, MANTIS_GPIF_IRQCFG);78udelay(500);79ca->slot_state = MODULE_XTRACTED;80}81udelay(100);82}8384int mantis_pcmcia_init(struct mantis_ca *ca)85{86struct mantis_pci *mantis = ca->ca_priv;8788u32 gpif_stat, card_stat;8990mmwrite(mmread(MANTIS_INT_MASK) | MANTIS_INT_IRQ0, MANTIS_INT_MASK);91gpif_stat = mmread(MANTIS_GPIF_STATUS);92card_stat = mmread(MANTIS_GPIF_IRQCFG);9394if (gpif_stat & MANTIS_GPIF_DETSTAT) {95dprintk(MANTIS_DEBUG, 1, "CAM found on Adapter(%d) Slot(0)", mantis->num);96mmwrite(card_stat | MANTIS_MASK_PLUGOUT, MANTIS_GPIF_IRQCFG);97ca->slot_state = MODULE_INSERTED;98dvb_ca_en50221_camchange_irq(&ca->en50221,990,100DVB_CA_EN50221_CAMCHANGE_INSERTED);101} else {102dprintk(MANTIS_DEBUG, 1, "Empty Slot on Adapter(%d) Slot(0)", mantis->num);103mmwrite(card_stat | MANTIS_MASK_PLUGIN, MANTIS_GPIF_IRQCFG);104ca->slot_state = MODULE_XTRACTED;105dvb_ca_en50221_camchange_irq(&ca->en50221,1060,107DVB_CA_EN50221_CAMCHANGE_REMOVED);108}109110return 0;111}112113void mantis_pcmcia_exit(struct mantis_ca *ca)114{115struct mantis_pci *mantis = ca->ca_priv;116117mmwrite(mmread(MANTIS_GPIF_STATUS) & (~MANTIS_CARD_PLUGOUT | ~MANTIS_CARD_PLUGIN), MANTIS_GPIF_STATUS);118mmwrite(mmread(MANTIS_INT_MASK) & ~MANTIS_INT_IRQ0, MANTIS_INT_MASK);119}120121122