WIP FPC-III support
[linux/fpc-iii.git] / drivers / media / pci / mantis / mantis_evm.c
blob2fb98ecd228b5c241b6291ea3971389cbb1aa661
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 Mantis PCI bridge driver
5 Copyright (C) Manu Abraham (abraham.manu@gmail.com)
7 */
9 #include <linux/kernel.h>
11 #include <linux/signal.h>
12 #include <linux/sched.h>
13 #include <linux/interrupt.h>
14 #include <asm/io.h>
16 #include <media/dmxdev.h>
17 #include <media/dvbdev.h>
18 #include <media/dvb_demux.h>
19 #include <media/dvb_frontend.h>
20 #include <media/dvb_net.h>
22 #include "mantis_common.h"
23 #include "mantis_link.h"
24 #include "mantis_hif.h"
25 #include "mantis_reg.h"
27 static void mantis_hifevm_work(struct work_struct *work)
29 struct mantis_ca *ca = container_of(work, struct mantis_ca, hif_evm_work);
30 struct mantis_pci *mantis = ca->ca_priv;
32 u32 gpif_stat;
34 gpif_stat = mmread(MANTIS_GPIF_STATUS);
36 if (gpif_stat & MANTIS_GPIF_DETSTAT) {
37 if (gpif_stat & MANTIS_CARD_PLUGIN) {
38 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num);
39 mmwrite(0xdada0000, MANTIS_CARD_RESET);
40 mantis_event_cam_plugin(ca);
41 dvb_ca_en50221_camchange_irq(&ca->en50221,
43 DVB_CA_EN50221_CAMCHANGE_INSERTED);
45 } else {
46 if (gpif_stat & MANTIS_CARD_PLUGOUT) {
47 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num);
48 mmwrite(0xdada0000, MANTIS_CARD_RESET);
49 mantis_event_cam_unplug(ca);
50 dvb_ca_en50221_camchange_irq(&ca->en50221,
52 DVB_CA_EN50221_CAMCHANGE_REMOVED);
56 if (mantis->gpif_status & MANTIS_GPIF_EXTIRQ)
57 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num);
59 if (mantis->gpif_status & MANTIS_SBUF_WSTO)
60 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num);
62 if (mantis->gpif_status & MANTIS_GPIF_OTHERR)
63 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num);
65 if (gpif_stat & MANTIS_SBUF_OVFLW)
66 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num);
68 if (gpif_stat & MANTIS_GPIF_BRRDY)
69 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num);
71 if (gpif_stat & MANTIS_GPIF_INTSTAT)
72 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num);
74 if (gpif_stat & MANTIS_SBUF_EMPTY)
75 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num);
77 if (gpif_stat & MANTIS_SBUF_OPDONE) {
78 dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num);
79 ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL;
80 ca->hif_event = MANTIS_SBUF_OPDONE;
81 wake_up(&ca->hif_opdone_wq);
85 int mantis_evmgr_init(struct mantis_ca *ca)
87 struct mantis_pci *mantis = ca->ca_priv;
89 dprintk(MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager");
90 INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work);
91 mantis_pcmcia_init(ca);
92 schedule_work(&ca->hif_evm_work);
93 mantis_hif_init(ca);
94 return 0;
97 void mantis_evmgr_exit(struct mantis_ca *ca)
99 struct mantis_pci *mantis = ca->ca_priv;
101 dprintk(MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting");
102 flush_work(&ca->hif_evm_work);
103 mantis_hif_exit(ca);
104 mantis_pcmcia_exit(ca);