blob: 79c3c625e2e817908a279e6a9ea1482befbf399d [file] [log] [blame]
Manu Abrahamd5755712009-12-04 05:04:18 -03001/*
2 Mantis PCI bridge driver
3
4 Copyright (C) 2005, 2006 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 "mantis_common.h"
22#include "mantis_link.h"
Manu Abrahamfadfa072009-12-04 05:05:19 -030023#include "mantis_hif.h"
24
Manu Abraham12855ca2009-12-04 05:09:04 -030025static void mantis_hifevm_work(struct work_struct *work)
Manu Abrahamfadfa072009-12-04 05:05:19 -030026{
Manu Abraham12855ca2009-12-04 05:09:04 -030027 struct mantis_ca *ca = container_of(work, struct mantis_ca, hif_evm_work);
Manu Abrahamfadfa072009-12-04 05:05:19 -030028 struct mantis_pci *mantis = ca->ca_priv;
29
Manu Abraham3062b152009-12-04 05:08:25 -030030 u32 gpif_stat, gpif_mask;
Manu Abrahamfadfa072009-12-04 05:05:19 -030031
32 gpif_stat = mmread(MANTIS_GPIF_STATUS);
Manu Abraham3062b152009-12-04 05:08:25 -030033 gpif_mask = mmread(MANTIS_GPIF_IRQCFG);
34 if (!((gpif_stat & 0xff) & (gpif_mask & 0xff)))
35 return;
Manu Abrahamfadfa072009-12-04 05:05:19 -030036
37 if (gpif_stat & MANTIS_GPIF_DETSTAT) {
38 if (gpif_stat & MANTIS_CARD_PLUGIN) {
Manu Abrahamd9dd5f72009-12-04 05:07:41 -030039 dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030040 mmwrite(0xdada0000, MANTIS_CARD_RESET);
Manu Abraham12855ca2009-12-04 05:09:04 -030041 mantis_event_cam_plugin(ca);
Manu Abraham05691cd2009-12-04 05:19:26 -030042 dvb_ca_en50221_camchange_irq(&ca->en50221,
43 0,
44 DVB_CA_EN50221_CAMCHANGE_INSERTED);
Manu Abrahamfadfa072009-12-04 05:05:19 -030045 }
46 } else {
47 if (gpif_stat & MANTIS_CARD_PLUGOUT) {
Manu Abrahamd9dd5f72009-12-04 05:07:41 -030048 dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030049 mmwrite(0xdada0000, MANTIS_CARD_RESET);
Manu Abraham12855ca2009-12-04 05:09:04 -030050 mantis_event_cam_unplug(ca);
Manu Abraham05691cd2009-12-04 05:19:26 -030051 dvb_ca_en50221_camchange_irq(&ca->en50221,
52 0,
53 DVB_CA_EN50221_CAMCHANGE_REMOVED);
Manu Abrahamfadfa072009-12-04 05:05:19 -030054 }
55 }
56
57 if (gpif_stat & MANTIS_GPIF_EXTIRQ)
Manu Abrahamd9dd5f72009-12-04 05:07:41 -030058 dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030059
60 if (gpif_stat & MANTIS_SBUF_WSTO)
Manu Abrahamd9dd5f72009-12-04 05:07:41 -030061 dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030062
63 if (gpif_stat & MANTIS_GPIF_OTHERR)
Manu Abrahamd9dd5f72009-12-04 05:07:41 -030064 dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030065
66 if (gpif_stat & MANTIS_SBUF_OVFLW)
Manu Abrahamd9dd5f72009-12-04 05:07:41 -030067 dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030068
69 if (gpif_stat & MANTIS_GPIF_BRRDY) {
Manu Abrahamd9dd5f72009-12-04 05:07:41 -030070 dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030071 ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL;
72 if (ca->hif_job_queue & MANTIS_HIF_MEMRD)
73 wake_up(&ca->hif_brrdyw_wq);
74 }
75 if (gpif_stat & MANTIS_GPIF_WRACK)
Manu Abrahamd9dd5f72009-12-04 05:07:41 -030076 dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Slave Write ACK", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030077
78 if (gpif_stat & MANTIS_GPIF_INTSTAT)
Manu Abrahamd9dd5f72009-12-04 05:07:41 -030079 dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030080
81 if (gpif_stat & MANTIS_SBUF_EMPTY)
Manu Abrahamd9dd5f72009-12-04 05:07:41 -030082 dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030083
84 if (gpif_stat & MANTIS_SBUF_OPDONE) {
Manu Abrahamd9dd5f72009-12-04 05:07:41 -030085 dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num);
Manu Abrahamfadfa072009-12-04 05:05:19 -030086 if (ca->hif_job_queue) {
87 wake_up(&ca->hif_opdone_wq);
88 ca->hif_event = MANTIS_SBUF_OPDONE;
89 }
90 }
91}
Manu Abrahamd5755712009-12-04 05:04:18 -030092
93int mantis_evmgr_init(struct mantis_ca *ca)
94{
95 struct mantis_pci *mantis = ca->ca_priv;
96
Manu Abrahamd9dd5f72009-12-04 05:07:41 -030097 dprintk(verbose, MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager");
Manu Abraham12855ca2009-12-04 05:09:04 -030098 INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work);
Manu Abraham50d82602009-12-04 05:06:38 -030099 mantis_pcmcia_init(ca);
Manu Abraham12855ca2009-12-04 05:09:04 -0300100 schedule_work(&ca->hif_evm_work);
Manu Abrahamd8b14f82009-12-04 05:09:47 -0300101 mantis_hif_init(ca);
Manu Abrahamd5755712009-12-04 05:04:18 -0300102 return 0;
103}
104
105void mantis_evmgr_exit(struct mantis_ca *ca)
106{
107 struct mantis_pci *mantis = ca->ca_priv;
108
Manu Abrahamd9dd5f72009-12-04 05:07:41 -0300109 dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting");
Manu Abraham12855ca2009-12-04 05:09:04 -0300110 flush_scheduled_work();
Manu Abrahamd8b14f82009-12-04 05:09:47 -0300111 mantis_hif_exit(ca);
Manu Abraham50d82602009-12-04 05:06:38 -0300112 mantis_pcmcia_exit(ca);
Manu Abrahamd5755712009-12-04 05:04:18 -0300113}