Manu Abraham | d575571 | 2009-12-04 05:04:18 -0300 | [diff] [blame] | 1 | /* |
| 2 | Mantis PCI bridge driver |
| 3 | |
Manu Abraham | 8825a09 | 2009-12-15 09:13:49 -0300 | [diff] [blame] | 4 | Copyright (C) Manu Abraham (abraham.manu@gmail.com) |
Manu Abraham | d575571 | 2009-12-04 05:04:18 -0300 | [diff] [blame] | 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 | |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 21 | #include <linux/kernel.h> |
| 22 | |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 23 | #include <linux/signal.h> |
| 24 | #include <linux/sched.h> |
| 25 | #include <linux/interrupt.h> |
Alexey Dobriyan | b7f080c | 2011-06-16 11:01:34 +0000 | [diff] [blame] | 26 | #include <asm/io.h> |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 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 | |
Manu Abraham | d575571 | 2009-12-04 05:04:18 -0300 | [diff] [blame] | 34 | #include "mantis_common.h" |
| 35 | #include "mantis_link.h" |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 36 | #include "mantis_hif.h" |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 37 | #include "mantis_reg.h" |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 38 | |
Manu Abraham | 12855ca | 2009-12-04 05:09:04 -0300 | [diff] [blame] | 39 | static void mantis_hifevm_work(struct work_struct *work) |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 40 | { |
Manu Abraham | 12855ca | 2009-12-04 05:09:04 -0300 | [diff] [blame] | 41 | struct mantis_ca *ca = container_of(work, struct mantis_ca, hif_evm_work); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 42 | struct mantis_pci *mantis = ca->ca_priv; |
| 43 | |
Hans Verkuil | 5becbc5 | 2012-05-14 10:22:58 -0300 | [diff] [blame] | 44 | u32 gpif_stat; |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 45 | |
| 46 | gpif_stat = mmread(MANTIS_GPIF_STATUS); |
| 47 | |
| 48 | if (gpif_stat & MANTIS_GPIF_DETSTAT) { |
| 49 | if (gpif_stat & MANTIS_CARD_PLUGIN) { |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 50 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 51 | mmwrite(0xdada0000, MANTIS_CARD_RESET); |
Manu Abraham | 12855ca | 2009-12-04 05:09:04 -0300 | [diff] [blame] | 52 | mantis_event_cam_plugin(ca); |
Manu Abraham | 05691cd | 2009-12-04 05:19:26 -0300 | [diff] [blame] | 53 | dvb_ca_en50221_camchange_irq(&ca->en50221, |
| 54 | 0, |
| 55 | DVB_CA_EN50221_CAMCHANGE_INSERTED); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 56 | } |
| 57 | } else { |
| 58 | if (gpif_stat & MANTIS_CARD_PLUGOUT) { |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 59 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 60 | mmwrite(0xdada0000, MANTIS_CARD_RESET); |
Manu Abraham | 12855ca | 2009-12-04 05:09:04 -0300 | [diff] [blame] | 61 | mantis_event_cam_unplug(ca); |
Manu Abraham | 05691cd | 2009-12-04 05:19:26 -0300 | [diff] [blame] | 62 | dvb_ca_en50221_camchange_irq(&ca->en50221, |
| 63 | 0, |
| 64 | DVB_CA_EN50221_CAMCHANGE_REMOVED); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 65 | } |
| 66 | } |
| 67 | |
Manu Abraham | 17b77fc | 2009-12-04 05:26:46 -0300 | [diff] [blame] | 68 | if (mantis->gpif_status & MANTIS_GPIF_EXTIRQ) |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 69 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 70 | |
Manu Abraham | 17b77fc | 2009-12-04 05:26:46 -0300 | [diff] [blame] | 71 | if (mantis->gpif_status & MANTIS_SBUF_WSTO) |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 72 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 73 | |
Manu Abraham | 17b77fc | 2009-12-04 05:26:46 -0300 | [diff] [blame] | 74 | if (mantis->gpif_status & MANTIS_GPIF_OTHERR) |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 75 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 76 | |
| 77 | if (gpif_stat & MANTIS_SBUF_OVFLW) |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 78 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 79 | |
Manu Abraham | 9e49e8d | 2009-12-04 05:25:45 -0300 | [diff] [blame] | 80 | if (gpif_stat & MANTIS_GPIF_BRRDY) |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 81 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num); |
Manu Abraham | 9e49e8d | 2009-12-04 05:25:45 -0300 | [diff] [blame] | 82 | |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 83 | if (gpif_stat & MANTIS_GPIF_INTSTAT) |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 84 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 85 | |
| 86 | if (gpif_stat & MANTIS_SBUF_EMPTY) |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 87 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 88 | |
| 89 | if (gpif_stat & MANTIS_SBUF_OPDONE) { |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 90 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num); |
Manu Abraham | cc0e4aa | 2009-12-04 05:21:51 -0300 | [diff] [blame] | 91 | ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL; |
Sigmund Augdal | c02e151 | 2009-12-04 05:28:24 -0300 | [diff] [blame] | 92 | ca->hif_event = MANTIS_SBUF_OPDONE; |
| 93 | wake_up(&ca->hif_opdone_wq); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 94 | } |
| 95 | } |
Manu Abraham | d575571 | 2009-12-04 05:04:18 -0300 | [diff] [blame] | 96 | |
| 97 | int mantis_evmgr_init(struct mantis_ca *ca) |
| 98 | { |
| 99 | struct mantis_pci *mantis = ca->ca_priv; |
| 100 | |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 101 | dprintk(MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager"); |
Manu Abraham | 12855ca | 2009-12-04 05:09:04 -0300 | [diff] [blame] | 102 | INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work); |
Manu Abraham | 50d8260 | 2009-12-04 05:06:38 -0300 | [diff] [blame] | 103 | mantis_pcmcia_init(ca); |
Manu Abraham | 12855ca | 2009-12-04 05:09:04 -0300 | [diff] [blame] | 104 | schedule_work(&ca->hif_evm_work); |
Manu Abraham | d8b14f8 | 2009-12-04 05:09:47 -0300 | [diff] [blame] | 105 | mantis_hif_init(ca); |
Manu Abraham | d575571 | 2009-12-04 05:04:18 -0300 | [diff] [blame] | 106 | return 0; |
| 107 | } |
| 108 | |
| 109 | void mantis_evmgr_exit(struct mantis_ca *ca) |
| 110 | { |
| 111 | struct mantis_pci *mantis = ca->ca_priv; |
| 112 | |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 113 | dprintk(MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting"); |
Tejun Heo | 4382973 | 2012-08-20 14:51:24 -0700 | [diff] [blame] | 114 | flush_work(&ca->hif_evm_work); |
Manu Abraham | d8b14f8 | 2009-12-04 05:09:47 -0300 | [diff] [blame] | 115 | mantis_hif_exit(ca); |
Manu Abraham | 50d8260 | 2009-12-04 05:06:38 -0300 | [diff] [blame] | 116 | mantis_pcmcia_exit(ca); |
Manu Abraham | d575571 | 2009-12-04 05:04:18 -0300 | [diff] [blame] | 117 | } |