diff options
Diffstat (limited to 'drivers/media/dvb/mantis/mantis_evm.c')
-rw-r--r-- | drivers/media/dvb/mantis/mantis_evm.c | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/drivers/media/dvb/mantis/mantis_evm.c b/drivers/media/dvb/mantis/mantis_evm.c new file mode 100644 index 00000000000..36f2256ebb0 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_evm.c | |||
@@ -0,0 +1,118 @@ | |||
1 | /* | ||
2 | Mantis PCI bridge driver | ||
3 | |||
4 | Copyright (C) Manu Abraham (abraham.manu@gmail.com) | ||
5 | |||
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 | |||
21 | #include <linux/kernel.h> | ||
22 | |||
23 | #include <linux/signal.h> | ||
24 | #include <linux/sched.h> | ||
25 | #include <linux/interrupt.h> | ||
26 | #include <asm/io.h> | ||
27 | |||
28 | #include "dmxdev.h" | ||
29 | #include "dvbdev.h" | ||
30 | #include "dvb_demux.h" | ||
31 | #include "dvb_frontend.h" | ||
32 | #include "dvb_net.h" | ||
33 | |||
34 | #include "mantis_common.h" | ||
35 | #include "mantis_link.h" | ||
36 | #include "mantis_hif.h" | ||
37 | #include "mantis_reg.h" | ||
38 | |||
39 | static void mantis_hifevm_work(struct work_struct *work) | ||
40 | { | ||
41 | struct mantis_ca *ca = container_of(work, struct mantis_ca, hif_evm_work); | ||
42 | struct mantis_pci *mantis = ca->ca_priv; | ||
43 | |||
44 | u32 gpif_stat, gpif_mask; | ||
45 | |||
46 | gpif_stat = mmread(MANTIS_GPIF_STATUS); | ||
47 | gpif_mask = mmread(MANTIS_GPIF_IRQCFG); | ||
48 | |||
49 | if (gpif_stat & MANTIS_GPIF_DETSTAT) { | ||
50 | if (gpif_stat & MANTIS_CARD_PLUGIN) { | ||
51 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num); | ||
52 | mmwrite(0xdada0000, MANTIS_CARD_RESET); | ||
53 | mantis_event_cam_plugin(ca); | ||
54 | dvb_ca_en50221_camchange_irq(&ca->en50221, | ||
55 | 0, | ||
56 | DVB_CA_EN50221_CAMCHANGE_INSERTED); | ||
57 | } | ||
58 | } else { | ||
59 | if (gpif_stat & MANTIS_CARD_PLUGOUT) { | ||
60 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num); | ||
61 | mmwrite(0xdada0000, MANTIS_CARD_RESET); | ||
62 | mantis_event_cam_unplug(ca); | ||
63 | dvb_ca_en50221_camchange_irq(&ca->en50221, | ||
64 | 0, | ||
65 | DVB_CA_EN50221_CAMCHANGE_REMOVED); | ||
66 | } | ||
67 | } | ||
68 | |||
69 | if (mantis->gpif_status & MANTIS_GPIF_EXTIRQ) | ||
70 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num); | ||
71 | |||
72 | if (mantis->gpif_status & MANTIS_SBUF_WSTO) | ||
73 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num); | ||
74 | |||
75 | if (mantis->gpif_status & MANTIS_GPIF_OTHERR) | ||
76 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num); | ||
77 | |||
78 | if (gpif_stat & MANTIS_SBUF_OVFLW) | ||
79 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num); | ||
80 | |||
81 | if (gpif_stat & MANTIS_GPIF_BRRDY) | ||
82 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num); | ||
83 | |||
84 | if (gpif_stat & MANTIS_GPIF_INTSTAT) | ||
85 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num); | ||
86 | |||
87 | if (gpif_stat & MANTIS_SBUF_EMPTY) | ||
88 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num); | ||
89 | |||
90 | if (gpif_stat & MANTIS_SBUF_OPDONE) { | ||
91 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num); | ||
92 | ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL; | ||
93 | ca->hif_event = MANTIS_SBUF_OPDONE; | ||
94 | wake_up(&ca->hif_opdone_wq); | ||
95 | } | ||
96 | } | ||
97 | |||
98 | int mantis_evmgr_init(struct mantis_ca *ca) | ||
99 | { | ||
100 | struct mantis_pci *mantis = ca->ca_priv; | ||
101 | |||
102 | dprintk(MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager"); | ||
103 | INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work); | ||
104 | mantis_pcmcia_init(ca); | ||
105 | schedule_work(&ca->hif_evm_work); | ||
106 | mantis_hif_init(ca); | ||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | void mantis_evmgr_exit(struct mantis_ca *ca) | ||
111 | { | ||
112 | struct mantis_pci *mantis = ca->ca_priv; | ||
113 | |||
114 | dprintk(MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting"); | ||
115 | flush_work_sync(&ca->hif_evm_work); | ||
116 | mantis_hif_exit(ca); | ||
117 | mantis_pcmcia_exit(ca); | ||
118 | } | ||