Commit | Line | Data |
---|---|---|
d575571e MA |
1 | /* |
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" | |
fadfa070 MA |
23 | #include "mantis_hif.h" |
24 | ||
12855cac | 25 | static void mantis_hifevm_work(struct work_struct *work) |
fadfa070 | 26 | { |
12855cac | 27 | struct mantis_ca *ca = container_of(work, struct mantis_ca, hif_evm_work); |
fadfa070 MA |
28 | struct mantis_pci *mantis = ca->ca_priv; |
29 | ||
3062b157 | 30 | u32 gpif_stat, gpif_mask; |
fadfa070 MA |
31 | |
32 | gpif_stat = mmread(MANTIS_GPIF_STATUS); | |
3062b157 MA |
33 | gpif_mask = mmread(MANTIS_GPIF_IRQCFG); |
34 | if (!((gpif_stat & 0xff) & (gpif_mask & 0xff))) | |
35 | return; | |
fadfa070 MA |
36 | |
37 | if (gpif_stat & MANTIS_GPIF_DETSTAT) { | |
38 | if (gpif_stat & MANTIS_CARD_PLUGIN) { | |
d9dd5f71 | 39 | dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num); |
fadfa070 | 40 | mmwrite(0xdada0000, MANTIS_CARD_RESET); |
12855cac | 41 | mantis_event_cam_plugin(ca); |
fadfa070 MA |
42 | } |
43 | } else { | |
44 | if (gpif_stat & MANTIS_CARD_PLUGOUT) { | |
d9dd5f71 | 45 | dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num); |
fadfa070 | 46 | mmwrite(0xdada0000, MANTIS_CARD_RESET); |
12855cac | 47 | mantis_event_cam_unplug(ca); |
fadfa070 MA |
48 | } |
49 | } | |
50 | ||
51 | if (gpif_stat & MANTIS_GPIF_EXTIRQ) | |
d9dd5f71 | 52 | dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num); |
fadfa070 MA |
53 | |
54 | if (gpif_stat & MANTIS_SBUF_WSTO) | |
d9dd5f71 | 55 | dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num); |
fadfa070 MA |
56 | |
57 | if (gpif_stat & MANTIS_GPIF_OTHERR) | |
d9dd5f71 | 58 | dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num); |
fadfa070 MA |
59 | |
60 | if (gpif_stat & MANTIS_SBUF_OVFLW) | |
d9dd5f71 | 61 | dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num); |
fadfa070 MA |
62 | |
63 | if (gpif_stat & MANTIS_GPIF_BRRDY) { | |
d9dd5f71 | 64 | dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num); |
fadfa070 MA |
65 | ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL; |
66 | if (ca->hif_job_queue & MANTIS_HIF_MEMRD) | |
67 | wake_up(&ca->hif_brrdyw_wq); | |
68 | } | |
69 | if (gpif_stat & MANTIS_GPIF_WRACK) | |
d9dd5f71 | 70 | dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Slave Write ACK", mantis->num); |
fadfa070 MA |
71 | |
72 | if (gpif_stat & MANTIS_GPIF_INTSTAT) | |
d9dd5f71 | 73 | dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num); |
fadfa070 MA |
74 | |
75 | if (gpif_stat & MANTIS_SBUF_EMPTY) | |
d9dd5f71 | 76 | dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num); |
fadfa070 MA |
77 | |
78 | if (gpif_stat & MANTIS_SBUF_OPDONE) { | |
d9dd5f71 | 79 | dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num); |
fadfa070 MA |
80 | if (ca->hif_job_queue) { |
81 | wake_up(&ca->hif_opdone_wq); | |
82 | ca->hif_event = MANTIS_SBUF_OPDONE; | |
83 | } | |
84 | } | |
85 | } | |
d575571e MA |
86 | |
87 | int mantis_evmgr_init(struct mantis_ca *ca) | |
88 | { | |
89 | struct mantis_pci *mantis = ca->ca_priv; | |
90 | ||
d9dd5f71 | 91 | dprintk(verbose, MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager"); |
12855cac | 92 | INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work); |
50d82602 | 93 | mantis_pcmcia_init(ca); |
12855cac | 94 | schedule_work(&ca->hif_evm_work); |
d8b14f8a | 95 | mantis_hif_init(ca); |
d575571e MA |
96 | return 0; |
97 | } | |
98 | ||
99 | void mantis_evmgr_exit(struct mantis_ca *ca) | |
100 | { | |
101 | struct mantis_pci *mantis = ca->ca_priv; | |
102 | ||
d9dd5f71 | 103 | dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting"); |
12855cac | 104 | flush_scheduled_work(); |
d8b14f8a | 105 | mantis_hif_exit(ca); |
50d82602 | 106 | mantis_pcmcia_exit(ca); |
d575571e | 107 | } |