Manu Abraham | d575571 | 2009-12-04 05:04:18 -0300 | [diff] [blame] | 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" |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 23 | #include "mantis_hif.h" |
| 24 | |
| 25 | void mantis_hifevm_tasklet(unsigned long data) |
| 26 | { |
| 27 | struct mantis_ca *ca = (struct mantis_ca *) data; |
| 28 | struct mantis_pci *mantis = ca->ca_priv; |
| 29 | |
Manu Abraham | 3062b15 | 2009-12-04 05:08:25 -0300 | [diff] [blame^] | 30 | u32 gpif_stat, gpif_mask; |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 31 | |
| 32 | gpif_stat = mmread(MANTIS_GPIF_STATUS); |
Manu Abraham | 3062b15 | 2009-12-04 05:08:25 -0300 | [diff] [blame^] | 33 | gpif_mask = mmread(MANTIS_GPIF_IRQCFG); |
| 34 | if (!((gpif_stat & 0xff) & (gpif_mask & 0xff))) |
| 35 | return; |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 36 | |
| 37 | if (gpif_stat & MANTIS_GPIF_DETSTAT) { |
| 38 | if (gpif_stat & MANTIS_CARD_PLUGIN) { |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 39 | dprintk(verbose, 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] | 40 | mmwrite(0xdada0000, MANTIS_CARD_RESET); |
| 41 | // Plugin call here |
| 42 | gpif_stat = 0; // crude ! |
| 43 | } |
| 44 | } else { |
| 45 | if (gpif_stat & MANTIS_CARD_PLUGOUT) { |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 46 | dprintk(verbose, 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] | 47 | mmwrite(0xdada0000, MANTIS_CARD_RESET); |
| 48 | // Unplug call here |
| 49 | gpif_stat = 0; // crude ! |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | if (gpif_stat & MANTIS_GPIF_EXTIRQ) |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 54 | dprintk(verbose, 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] | 55 | |
| 56 | if (gpif_stat & MANTIS_SBUF_WSTO) |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 57 | dprintk(verbose, 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] | 58 | |
| 59 | if (gpif_stat & MANTIS_GPIF_OTHERR) |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 60 | dprintk(verbose, 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] | 61 | |
| 62 | if (gpif_stat & MANTIS_SBUF_OVFLW) |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 63 | dprintk(verbose, 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] | 64 | |
| 65 | if (gpif_stat & MANTIS_GPIF_BRRDY) { |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 66 | dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 67 | ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL; |
| 68 | if (ca->hif_job_queue & MANTIS_HIF_MEMRD) |
| 69 | wake_up(&ca->hif_brrdyw_wq); |
| 70 | } |
| 71 | if (gpif_stat & MANTIS_GPIF_WRACK) |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 72 | dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Slave Write ACK", mantis->num); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 73 | |
| 74 | if (gpif_stat & MANTIS_GPIF_INTSTAT) |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 75 | dprintk(verbose, 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] | 76 | |
| 77 | if (gpif_stat & MANTIS_SBUF_EMPTY) |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 78 | dprintk(verbose, 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] | 79 | |
| 80 | if (gpif_stat & MANTIS_SBUF_OPDONE) { |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 81 | dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 82 | if (ca->hif_job_queue) { |
| 83 | wake_up(&ca->hif_opdone_wq); |
| 84 | ca->hif_event = MANTIS_SBUF_OPDONE; |
| 85 | } |
| 86 | } |
| 87 | } |
Manu Abraham | d575571 | 2009-12-04 05:04:18 -0300 | [diff] [blame] | 88 | |
| 89 | int mantis_evmgr_init(struct mantis_ca *ca) |
| 90 | { |
| 91 | struct mantis_pci *mantis = ca->ca_priv; |
| 92 | |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 93 | dprintk(verbose, MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager"); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 94 | tasklet_init(&ca->hif_evm_tasklet, mantis_hifevm_tasklet, (unsigned long) ca); |
| 95 | |
Manu Abraham | 50d8260 | 2009-12-04 05:06:38 -0300 | [diff] [blame] | 96 | mantis_pcmcia_init(ca); |
| 97 | |
Manu Abraham | d575571 | 2009-12-04 05:04:18 -0300 | [diff] [blame] | 98 | return 0; |
| 99 | } |
| 100 | |
| 101 | void mantis_evmgr_exit(struct mantis_ca *ca) |
| 102 | { |
| 103 | struct mantis_pci *mantis = ca->ca_priv; |
| 104 | |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 105 | dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting"); |
Manu Abraham | fadfa07 | 2009-12-04 05:05:19 -0300 | [diff] [blame] | 106 | tasklet_kill(&ca->hif_evm_tasklet); |
Manu Abraham | 50d8260 | 2009-12-04 05:06:38 -0300 | [diff] [blame] | 107 | |
| 108 | mantis_pcmcia_exit(ca); |
Manu Abraham | d575571 | 2009-12-04 05:04:18 -0300 | [diff] [blame] | 109 | } |