mantis_evm.c 3.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
	Mantis PCI bridge driver

	Copyright (C) 2005, 2006 Manu Abraham (abraham.manu@gmail.com)

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "mantis_common.h"
#include "mantis_link.h"
23 24
#include "mantis_hif.h"

25
static void mantis_hifevm_work(struct work_struct *work)
26
{
27
	struct mantis_ca *ca = container_of(work, struct mantis_ca, hif_evm_work);
28 29
	struct mantis_pci *mantis = ca->ca_priv;

30 31 32 33 34 35
	u32 gpif_stat, gpif_mask, rst_mask, rst_stat;

	rst_mask  = MANTIS_GPIF_WRACK  |
		    MANTIS_GPIF_OTHERR |
		    MANTIS_SBUF_WSTO   |
		    MANTIS_GPIF_EXTIRQ;
36 37

	gpif_stat = mmread(MANTIS_GPIF_STATUS);
38
	gpif_mask = mmread(MANTIS_GPIF_IRQCFG);
39

40 41 42
	rst_stat = gpif_stat & rst_mask;
	mmwrite(rst_stat, MANTIS_GPIF_STATUS);

43 44
	if (gpif_stat & MANTIS_GPIF_DETSTAT) {
		if (gpif_stat & MANTIS_CARD_PLUGIN) {
45
			dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num);
46
			mmwrite(0xdada0000, MANTIS_CARD_RESET);
47
			mantis_event_cam_plugin(ca);
48 49 50
			dvb_ca_en50221_camchange_irq(&ca->en50221,
						     0,
						     DVB_CA_EN50221_CAMCHANGE_INSERTED);
51 52 53
		}
	} else {
		if (gpif_stat & MANTIS_CARD_PLUGOUT) {
54
			dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num);
55
			mmwrite(0xdada0000, MANTIS_CARD_RESET);
56
			mantis_event_cam_unplug(ca);
57 58 59
			dvb_ca_en50221_camchange_irq(&ca->en50221,
						     0,
						     DVB_CA_EN50221_CAMCHANGE_REMOVED);
60 61 62 63
		}
	}

	if (gpif_stat & MANTIS_GPIF_EXTIRQ)
64
		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num);
65 66

	if (gpif_stat & MANTIS_SBUF_WSTO)
67
		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num);
68 69

	if (gpif_stat & MANTIS_GPIF_OTHERR)
70
		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num);
71 72

	if (gpif_stat & MANTIS_SBUF_OVFLW)
73
		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num);
74 75

	if (gpif_stat & MANTIS_GPIF_BRRDY) {
76
		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num);
77 78
	}
	if (gpif_stat & MANTIS_GPIF_WRACK)
79
		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Slave Write ACK", mantis->num);
80 81

	if (gpif_stat & MANTIS_GPIF_INTSTAT)
82
		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num);
83 84

	if (gpif_stat & MANTIS_SBUF_EMPTY)
85
		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num);
86 87

	if (gpif_stat & MANTIS_SBUF_OPDONE) {
88
		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num);
89 90
		ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL;
		dvb_ca_en50221_frda_irq(&ca->en50221, 0);
91 92
	}
}
93 94 95 96 97

int mantis_evmgr_init(struct mantis_ca *ca)
{
	struct mantis_pci *mantis = ca->ca_priv;

98
	dprintk(verbose, MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager");
99
	INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work);
100
	mantis_pcmcia_init(ca);
101
	schedule_work(&ca->hif_evm_work);
102
	mantis_hif_init(ca);
103 104 105 106 107 108 109
	return 0;
}

void mantis_evmgr_exit(struct mantis_ca *ca)
{
	struct mantis_pci *mantis = ca->ca_priv;

110
	dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting");
111
	flush_scheduled_work();
112
	mantis_hif_exit(ca);
113
	mantis_pcmcia_exit(ca);
114
}