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