blob: 909ff54868a3b183623b250849c166c70fdcbcf2 [file] [log] [blame]
Manu Abrahamd5755712009-12-04 05:04:18 -03001/*
2 Mantis PCI bridge driver
3
Manu Abraham8825a092009-12-15 09:13:49 -03004 Copyright (C) Manu Abraham (abraham.manu@gmail.com)
Manu Abrahamd5755712009-12-04 05:04:18 -03005
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
Manu Abrahamb3b96142009-12-04 05:41:11 -030021#include <linux/kernel.h>
22
Manu Abrahamb3b96142009-12-04 05:41:11 -030023#include <linux/signal.h>
24#include <linux/sched.h>
25#include <linux/interrupt.h>
Alexey Dobriyanb7f080c2011-06-16 11:01:34 +000026#include <asm/io.h>
Manu Abrahamb3b96142009-12-04 05:41:11 -030027
28#include "dmxdev.h"
29#include "dvbdev.h"
30#include "dvb_demux.h"
31#include "dvb_frontend.h"
32#include "dvb_net.h"
33
Manu Abrahamd5755712009-12-04 05:04:18 -030034#include "mantis_common.h"
35#include "mantis_link.h"
Manu Abrahamfadfa072009-12-04 05:05:19 -030036#include "mantis_hif.h"
Manu Abrahamb3b96142009-12-04 05:41:11 -030037#include "mantis_reg.h"
Manu Abrahamfadfa072009-12-04 05:05:19 -030038
Manu Abraham12855ca2009-12-04 05:09:04 -030039static void mantis_hifevm_work(struct work_struct *work)
Manu Abrahamfadfa072009-12-04 05:05:19 -030040{
Manu Abraham12855ca2009-12-04 05:09:04 -030041 struct mantis_ca *ca = container_of(work, struct mantis_ca, hif_evm_work);
Manu Abrahamfadfa072009-12-04 05:05:19 -030042 struct mantis_pci *mantis = ca->ca_priv;
43
Hans Verkuil5becbc52012-05-14 10:22:58 -030044 u32 gpif_stat;
Manu Abrahamfadfa072009-12-04 05:05:19 -030045
46 gpif_stat = mmread(MANTIS_GPIF_STATUS);
47
48 if (gpif_stat & MANTIS_GPIF_DETSTAT) {
49 if (gpif_stat & MANTIS_CARD_PLUGIN) {
Manu Abrahamb3b96142009-12-04 05:41:11 -030050 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030051 mmwrite(0xdada0000, MANTIS_CARD_RESET);
Manu Abraham12855ca2009-12-04 05:09:04 -030052 mantis_event_cam_plugin(ca);
Manu Abraham05691cd2009-12-04 05:19:26 -030053 dvb_ca_en50221_camchange_irq(&ca->en50221,
54 0,
55 DVB_CA_EN50221_CAMCHANGE_INSERTED);
Manu Abrahamfadfa072009-12-04 05:05:19 -030056 }
57 } else {
58 if (gpif_stat & MANTIS_CARD_PLUGOUT) {
Manu Abrahamb3b96142009-12-04 05:41:11 -030059 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030060 mmwrite(0xdada0000, MANTIS_CARD_RESET);
Manu Abraham12855ca2009-12-04 05:09:04 -030061 mantis_event_cam_unplug(ca);
Manu Abraham05691cd2009-12-04 05:19:26 -030062 dvb_ca_en50221_camchange_irq(&ca->en50221,
63 0,
64 DVB_CA_EN50221_CAMCHANGE_REMOVED);
Manu Abrahamfadfa072009-12-04 05:05:19 -030065 }
66 }
67
Manu Abraham17b77fc2009-12-04 05:26:46 -030068 if (mantis->gpif_status & MANTIS_GPIF_EXTIRQ)
Manu Abrahamb3b96142009-12-04 05:41:11 -030069 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030070
Manu Abraham17b77fc2009-12-04 05:26:46 -030071 if (mantis->gpif_status & MANTIS_SBUF_WSTO)
Manu Abrahamb3b96142009-12-04 05:41:11 -030072 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030073
Manu Abraham17b77fc2009-12-04 05:26:46 -030074 if (mantis->gpif_status & MANTIS_GPIF_OTHERR)
Manu Abrahamb3b96142009-12-04 05:41:11 -030075 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030076
77 if (gpif_stat & MANTIS_SBUF_OVFLW)
Manu Abrahamb3b96142009-12-04 05:41:11 -030078 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030079
Manu Abraham9e49e8d2009-12-04 05:25:45 -030080 if (gpif_stat & MANTIS_GPIF_BRRDY)
Manu Abrahamb3b96142009-12-04 05:41:11 -030081 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num);
Manu Abraham9e49e8d2009-12-04 05:25:45 -030082
Manu Abrahamfadfa072009-12-04 05:05:19 -030083 if (gpif_stat & MANTIS_GPIF_INTSTAT)
Manu Abrahamb3b96142009-12-04 05:41:11 -030084 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030085
86 if (gpif_stat & MANTIS_SBUF_EMPTY)
Manu Abrahamb3b96142009-12-04 05:41:11 -030087 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030088
89 if (gpif_stat & MANTIS_SBUF_OPDONE) {
Manu Abrahamb3b96142009-12-04 05:41:11 -030090 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num);
Manu Abrahamcc0e4aa2009-12-04 05:21:51 -030091 ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL;
Sigmund Augdalc02e1512009-12-04 05:28:24 -030092 ca->hif_event = MANTIS_SBUF_OPDONE;
93 wake_up(&ca->hif_opdone_wq);
Manu Abrahamfadfa072009-12-04 05:05:19 -030094 }
95}
Manu Abrahamd5755712009-12-04 05:04:18 -030096
97int mantis_evmgr_init(struct mantis_ca *ca)
98{
99 struct mantis_pci *mantis = ca->ca_priv;
100
Manu Abrahamb3b96142009-12-04 05:41:11 -0300101 dprintk(MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager");
Manu Abraham12855ca2009-12-04 05:09:04 -0300102 INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work);
Manu Abraham50d82602009-12-04 05:06:38 -0300103 mantis_pcmcia_init(ca);
Manu Abraham12855ca2009-12-04 05:09:04 -0300104 schedule_work(&ca->hif_evm_work);
Manu Abrahamd8b14f82009-12-04 05:09:47 -0300105 mantis_hif_init(ca);
Manu Abrahamd5755712009-12-04 05:04:18 -0300106 return 0;
107}
108
109void mantis_evmgr_exit(struct mantis_ca *ca)
110{
111 struct mantis_pci *mantis = ca->ca_priv;
112
Manu Abrahamb3b96142009-12-04 05:41:11 -0300113 dprintk(MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting");
Tejun Heo43829732012-08-20 14:51:24 -0700114 flush_work(&ca->hif_evm_work);
Manu Abrahamd8b14f82009-12-04 05:09:47 -0300115 mantis_hif_exit(ca);
Manu Abraham50d82602009-12-04 05:06:38 -0300116 mantis_pcmcia_exit(ca);
Manu Abrahamd5755712009-12-04 05:04:18 -0300117}