2019-05-20 01:19:02 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2009-12-04 01:03:35 -07:00
|
|
|
/*
|
|
|
|
Mantis PCI bridge driver
|
|
|
|
|
2009-12-15 05:13:49 -07:00
|
|
|
Copyright (C) Manu Abraham (abraham.manu@gmail.com)
|
2009-12-04 01:03:35 -07:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2009-12-04 01:41:11 -07:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
|
|
|
|
#include <linux/signal.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/interrupt.h>
|
2011-06-16 05:01:34 -06:00
|
|
|
#include <asm/io.h>
|
2009-12-04 01:41:11 -07:00
|
|
|
|
2017-12-28 11:03:51 -07:00
|
|
|
#include <media/dmxdev.h>
|
|
|
|
#include <media/dvbdev.h>
|
|
|
|
#include <media/dvb_demux.h>
|
|
|
|
#include <media/dvb_frontend.h>
|
|
|
|
#include <media/dvb_net.h>
|
2009-12-04 01:41:11 -07:00
|
|
|
|
2009-12-04 01:03:35 -07:00
|
|
|
#include "mantis_common.h"
|
2009-12-04 01:06:00 -07:00
|
|
|
#include "mantis_link.h" /* temporary due to physical layer stuff */
|
2009-12-04 01:41:11 -07:00
|
|
|
#include "mantis_reg.h"
|
2009-12-04 01:06:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If Slot state is already PLUG_IN event and we are called
|
|
|
|
* again, definitely it is jitter alone
|
|
|
|
*/
|
|
|
|
void mantis_event_cam_plugin(struct mantis_ca *ca)
|
|
|
|
{
|
|
|
|
struct mantis_pci *mantis = ca->ca_priv;
|
|
|
|
|
|
|
|
u32 gpif_irqcfg;
|
|
|
|
|
|
|
|
if (ca->slot_state == MODULE_XTRACTED) {
|
2009-12-04 01:41:11 -07:00
|
|
|
dprintk(MANTIS_DEBUG, 1, "Event: CAM Plugged IN: Adapter(%d) Slot(0)", mantis->num);
|
2009-12-04 01:06:00 -07:00
|
|
|
udelay(50);
|
|
|
|
mmwrite(0xda000000, MANTIS_CARD_RESET);
|
|
|
|
gpif_irqcfg = mmread(MANTIS_GPIF_IRQCFG);
|
|
|
|
gpif_irqcfg |= MANTIS_MASK_PLUGOUT;
|
|
|
|
gpif_irqcfg &= ~MANTIS_MASK_PLUGIN;
|
|
|
|
mmwrite(gpif_irqcfg, MANTIS_GPIF_IRQCFG);
|
|
|
|
udelay(500);
|
|
|
|
ca->slot_state = MODULE_INSERTED;
|
|
|
|
}
|
|
|
|
udelay(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If Slot state is already UN_PLUG event and we are called
|
|
|
|
* again, definitely it is jitter alone
|
|
|
|
*/
|
|
|
|
void mantis_event_cam_unplug(struct mantis_ca *ca)
|
|
|
|
{
|
|
|
|
struct mantis_pci *mantis = ca->ca_priv;
|
|
|
|
|
|
|
|
u32 gpif_irqcfg;
|
|
|
|
|
|
|
|
if (ca->slot_state == MODULE_INSERTED) {
|
2009-12-04 01:41:11 -07:00
|
|
|
dprintk(MANTIS_DEBUG, 1, "Event: CAM Unplugged: Adapter(%d) Slot(0)", mantis->num);
|
2009-12-04 01:06:00 -07:00
|
|
|
udelay(50);
|
|
|
|
mmwrite(0x00da0000, MANTIS_CARD_RESET);
|
|
|
|
gpif_irqcfg = mmread(MANTIS_GPIF_IRQCFG);
|
|
|
|
gpif_irqcfg |= MANTIS_MASK_PLUGIN;
|
|
|
|
gpif_irqcfg &= ~MANTIS_MASK_PLUGOUT;
|
|
|
|
mmwrite(gpif_irqcfg, MANTIS_GPIF_IRQCFG);
|
|
|
|
udelay(500);
|
|
|
|
ca->slot_state = MODULE_XTRACTED;
|
|
|
|
}
|
|
|
|
udelay(100);
|
|
|
|
}
|
2009-12-04 01:03:35 -07:00
|
|
|
|
|
|
|
int mantis_pcmcia_init(struct mantis_ca *ca)
|
|
|
|
{
|
|
|
|
struct mantis_pci *mantis = ca->ca_priv;
|
|
|
|
|
2009-12-04 01:06:00 -07:00
|
|
|
u32 gpif_stat, card_stat;
|
|
|
|
|
2015-06-06 13:58:13 -06:00
|
|
|
mantis_unmask_ints(mantis, MANTIS_INT_IRQ0);
|
2009-12-04 01:06:00 -07:00
|
|
|
gpif_stat = mmread(MANTIS_GPIF_STATUS);
|
|
|
|
card_stat = mmread(MANTIS_GPIF_IRQCFG);
|
|
|
|
|
|
|
|
if (gpif_stat & MANTIS_GPIF_DETSTAT) {
|
2009-12-04 01:41:11 -07:00
|
|
|
dprintk(MANTIS_DEBUG, 1, "CAM found on Adapter(%d) Slot(0)", mantis->num);
|
2009-12-04 01:06:00 -07:00
|
|
|
mmwrite(card_stat | MANTIS_MASK_PLUGOUT, MANTIS_GPIF_IRQCFG);
|
|
|
|
ca->slot_state = MODULE_INSERTED;
|
2009-12-04 01:21:27 -07:00
|
|
|
dvb_ca_en50221_camchange_irq(&ca->en50221,
|
|
|
|
0,
|
|
|
|
DVB_CA_EN50221_CAMCHANGE_INSERTED);
|
2009-12-04 01:06:00 -07:00
|
|
|
} else {
|
2009-12-04 01:41:11 -07:00
|
|
|
dprintk(MANTIS_DEBUG, 1, "Empty Slot on Adapter(%d) Slot(0)", mantis->num);
|
2009-12-04 01:06:00 -07:00
|
|
|
mmwrite(card_stat | MANTIS_MASK_PLUGIN, MANTIS_GPIF_IRQCFG);
|
|
|
|
ca->slot_state = MODULE_XTRACTED;
|
2009-12-04 01:22:33 -07:00
|
|
|
dvb_ca_en50221_camchange_irq(&ca->en50221,
|
|
|
|
0,
|
|
|
|
DVB_CA_EN50221_CAMCHANGE_REMOVED);
|
2009-12-04 01:06:00 -07:00
|
|
|
}
|
|
|
|
|
2009-12-04 01:03:35 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mantis_pcmcia_exit(struct mantis_ca *ca)
|
|
|
|
{
|
|
|
|
struct mantis_pci *mantis = ca->ca_priv;
|
|
|
|
|
2009-12-04 01:06:00 -07:00
|
|
|
mmwrite(mmread(MANTIS_GPIF_STATUS) & (~MANTIS_CARD_PLUGOUT | ~MANTIS_CARD_PLUGIN), MANTIS_GPIF_STATUS);
|
2015-06-06 13:58:13 -06:00
|
|
|
mantis_mask_ints(mantis, MANTIS_INT_IRQ0);
|
2009-12-04 01:03:35 -07:00
|
|
|
}
|