1 // SPDX-License-Identifier: GPL-2.0-or-later
3 Mantis PCI bridge driver
5 Copyright (C) Manu Abraham (abraham.manu@gmail.com)
9 #include <linux/kernel.h>
11 #include <linux/signal.h>
12 #include <linux/sched.h>
13 #include <linux/interrupt.h>
16 #include <media/dmxdev.h>
17 #include <media/dvbdev.h>
18 #include <media/dvb_demux.h>
19 #include <media/dvb_frontend.h>
20 #include <media/dvb_net.h>
22 #include "mantis_common.h"
23 #include "mantis_link.h" /* temporary due to physical layer stuff */
24 #include "mantis_reg.h"
27 * If Slot state is already PLUG_IN event and we are called
28 * again, definitely it is jitter alone
30 void mantis_event_cam_plugin(struct mantis_ca
*ca
)
32 struct mantis_pci
*mantis
= ca
->ca_priv
;
36 if (ca
->slot_state
== MODULE_XTRACTED
) {
37 dprintk(MANTIS_DEBUG
, 1, "Event: CAM Plugged IN: Adapter(%d) Slot(0)", mantis
->num
);
39 mmwrite(0xda000000, MANTIS_CARD_RESET
);
40 gpif_irqcfg
= mmread(MANTIS_GPIF_IRQCFG
);
41 gpif_irqcfg
|= MANTIS_MASK_PLUGOUT
;
42 gpif_irqcfg
&= ~MANTIS_MASK_PLUGIN
;
43 mmwrite(gpif_irqcfg
, MANTIS_GPIF_IRQCFG
);
45 ca
->slot_state
= MODULE_INSERTED
;
51 * If Slot state is already UN_PLUG event and we are called
52 * again, definitely it is jitter alone
54 void mantis_event_cam_unplug(struct mantis_ca
*ca
)
56 struct mantis_pci
*mantis
= ca
->ca_priv
;
60 if (ca
->slot_state
== MODULE_INSERTED
) {
61 dprintk(MANTIS_DEBUG
, 1, "Event: CAM Unplugged: Adapter(%d) Slot(0)", mantis
->num
);
63 mmwrite(0x00da0000, MANTIS_CARD_RESET
);
64 gpif_irqcfg
= mmread(MANTIS_GPIF_IRQCFG
);
65 gpif_irqcfg
|= MANTIS_MASK_PLUGIN
;
66 gpif_irqcfg
&= ~MANTIS_MASK_PLUGOUT
;
67 mmwrite(gpif_irqcfg
, MANTIS_GPIF_IRQCFG
);
69 ca
->slot_state
= MODULE_XTRACTED
;
74 int mantis_pcmcia_init(struct mantis_ca
*ca
)
76 struct mantis_pci
*mantis
= ca
->ca_priv
;
78 u32 gpif_stat
, card_stat
;
80 mantis_unmask_ints(mantis
, MANTIS_INT_IRQ0
);
81 gpif_stat
= mmread(MANTIS_GPIF_STATUS
);
82 card_stat
= mmread(MANTIS_GPIF_IRQCFG
);
84 if (gpif_stat
& MANTIS_GPIF_DETSTAT
) {
85 dprintk(MANTIS_DEBUG
, 1, "CAM found on Adapter(%d) Slot(0)", mantis
->num
);
86 mmwrite(card_stat
| MANTIS_MASK_PLUGOUT
, MANTIS_GPIF_IRQCFG
);
87 ca
->slot_state
= MODULE_INSERTED
;
88 dvb_ca_en50221_camchange_irq(&ca
->en50221
,
90 DVB_CA_EN50221_CAMCHANGE_INSERTED
);
92 dprintk(MANTIS_DEBUG
, 1, "Empty Slot on Adapter(%d) Slot(0)", mantis
->num
);
93 mmwrite(card_stat
| MANTIS_MASK_PLUGIN
, MANTIS_GPIF_IRQCFG
);
94 ca
->slot_state
= MODULE_XTRACTED
;
95 dvb_ca_en50221_camchange_irq(&ca
->en50221
,
97 DVB_CA_EN50221_CAMCHANGE_REMOVED
);
103 void mantis_pcmcia_exit(struct mantis_ca
*ca
)
105 struct mantis_pci
*mantis
= ca
->ca_priv
;
107 mmwrite(mmread(MANTIS_GPIF_STATUS
) & (~MANTIS_CARD_PLUGOUT
| ~MANTIS_CARD_PLUGIN
), MANTIS_GPIF_STATUS
);
108 mantis_mask_ints(mantis
, MANTIS_INT_IRQ0
);