Manu Abraham | bc4ed42 | 2009-12-04 05:03:35 -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" |
Manu Abraham | 8ce571f | 2009-12-04 05:06:00 -0300 | [diff] [blame] | 22 | #include "mantis_link.h" /* temporary due to physical layer stuff */ |
| 23 | |
| 24 | /* |
| 25 | * If Slot state is already PLUG_IN event and we are called |
| 26 | * again, definitely it is jitter alone |
| 27 | */ |
| 28 | void mantis_event_cam_plugin(struct mantis_ca *ca) |
| 29 | { |
| 30 | struct mantis_pci *mantis = ca->ca_priv; |
| 31 | |
| 32 | u32 gpif_irqcfg; |
| 33 | |
| 34 | if (ca->slot_state == MODULE_XTRACTED) { |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 35 | dprintk(verbose, MANTIS_DEBUG, 1, "Event: CAM Plugged IN: Adapter(%d) Slot(0)", mantis->num); |
Manu Abraham | 8ce571f | 2009-12-04 05:06:00 -0300 | [diff] [blame] | 36 | udelay(50); |
| 37 | mmwrite(0xda000000, MANTIS_CARD_RESET); |
| 38 | gpif_irqcfg = mmread(MANTIS_GPIF_IRQCFG); |
| 39 | gpif_irqcfg |= MANTIS_MASK_PLUGOUT; |
| 40 | gpif_irqcfg &= ~MANTIS_MASK_PLUGIN; |
| 41 | mmwrite(gpif_irqcfg, MANTIS_GPIF_IRQCFG); |
| 42 | udelay(500); |
| 43 | ca->slot_state = MODULE_INSERTED; |
| 44 | } |
| 45 | udelay(100); |
| 46 | } |
| 47 | |
| 48 | /* |
| 49 | * If Slot state is already UN_PLUG event and we are called |
| 50 | * again, definitely it is jitter alone |
| 51 | */ |
| 52 | void mantis_event_cam_unplug(struct mantis_ca *ca) |
| 53 | { |
| 54 | struct mantis_pci *mantis = ca->ca_priv; |
| 55 | |
| 56 | u32 gpif_irqcfg; |
| 57 | |
| 58 | if (ca->slot_state == MODULE_INSERTED) { |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 59 | dprintk(verbose, MANTIS_DEBUG, 1, "Event: CAM Unplugged: Adapter(%d) Slot(0)", mantis->num); |
Manu Abraham | 8ce571f | 2009-12-04 05:06:00 -0300 | [diff] [blame] | 60 | udelay(50); |
| 61 | mmwrite(0x00da0000, MANTIS_CARD_RESET); |
| 62 | gpif_irqcfg = mmread(MANTIS_GPIF_IRQCFG); |
| 63 | gpif_irqcfg |= MANTIS_MASK_PLUGIN; |
| 64 | gpif_irqcfg &= ~MANTIS_MASK_PLUGOUT; |
| 65 | mmwrite(gpif_irqcfg, MANTIS_GPIF_IRQCFG); |
| 66 | udelay(500); |
| 67 | ca->slot_state = MODULE_XTRACTED; |
| 68 | } |
| 69 | udelay(100); |
| 70 | } |
Manu Abraham | bc4ed42 | 2009-12-04 05:03:35 -0300 | [diff] [blame] | 71 | |
| 72 | int mantis_pcmcia_init(struct mantis_ca *ca) |
| 73 | { |
| 74 | struct mantis_pci *mantis = ca->ca_priv; |
| 75 | |
Manu Abraham | 8ce571f | 2009-12-04 05:06:00 -0300 | [diff] [blame] | 76 | u32 gpif_stat, card_stat; |
| 77 | |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 78 | mmwrite(mmread(MANTIS_INT_MASK) | MANTIS_INT_IRQ0, MANTIS_INT_MASK); |
Manu Abraham | 8ce571f | 2009-12-04 05:06:00 -0300 | [diff] [blame] | 79 | gpif_stat = mmread(MANTIS_GPIF_STATUS); |
| 80 | card_stat = mmread(MANTIS_GPIF_IRQCFG); |
| 81 | |
| 82 | if (gpif_stat & MANTIS_GPIF_DETSTAT) { |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 83 | dprintk(verbose, MANTIS_DEBUG, 1, "CAM found on Adapter(%d) Slot(0)", mantis->num); |
Manu Abraham | 8ce571f | 2009-12-04 05:06:00 -0300 | [diff] [blame] | 84 | mmwrite(card_stat | MANTIS_MASK_PLUGOUT, MANTIS_GPIF_IRQCFG); |
| 85 | ca->slot_state = MODULE_INSERTED; |
Sigmund Augdal | 86c75c5 | 2009-12-04 05:21:27 -0300 | [diff] [blame] | 86 | dvb_ca_en50221_camchange_irq(&ca->en50221, |
| 87 | 0, |
| 88 | DVB_CA_EN50221_CAMCHANGE_INSERTED); |
Manu Abraham | 8ce571f | 2009-12-04 05:06:00 -0300 | [diff] [blame] | 89 | } else { |
Manu Abraham | d9dd5f7 | 2009-12-04 05:07:41 -0300 | [diff] [blame] | 90 | dprintk(verbose, MANTIS_DEBUG, 1, "Empty Slot on Adapter(%d) Slot(0)", mantis->num); |
Manu Abraham | 8ce571f | 2009-12-04 05:06:00 -0300 | [diff] [blame] | 91 | mmwrite(card_stat | MANTIS_MASK_PLUGIN, MANTIS_GPIF_IRQCFG); |
| 92 | ca->slot_state = MODULE_XTRACTED; |
| 93 | } |
| 94 | |
Manu Abraham | bc4ed42 | 2009-12-04 05:03:35 -0300 | [diff] [blame] | 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | void mantis_pcmcia_exit(struct mantis_ca *ca) |
| 99 | { |
| 100 | struct mantis_pci *mantis = ca->ca_priv; |
| 101 | |
Manu Abraham | 8ce571f | 2009-12-04 05:06:00 -0300 | [diff] [blame] | 102 | mmwrite(mmread(MANTIS_GPIF_STATUS) & (~MANTIS_CARD_PLUGOUT | ~MANTIS_CARD_PLUGIN), MANTIS_GPIF_STATUS); |
| 103 | mmwrite(mmread(MANTIS_INT_MASK) & ~MANTIS_INT_IRQ0, MANTIS_INT_MASK); |
Manu Abraham | bc4ed42 | 2009-12-04 05:03:35 -0300 | [diff] [blame] | 104 | } |