1 #include <linux/module.h>
2 #include <linux/moduleparam.h>
3 #include <linux/kernel.h>
6 #include <linux/interrupt.h>
10 #include "dvb_demux.h"
11 #include "dvb_frontend.h"
14 #include "mantis_common.h"
16 #include "mantis_vp1033.h"
17 #include "mantis_vp1034.h"
18 #include "mantis_vp1041.h"
19 #include "mantis_vp2033.h"
20 #include "mantis_vp2040.h"
21 #include "mantis_vp3030.h"
23 #include "mantis_dma.h"
24 #include "mantis_ca.h"
25 #include "mantis_dvb.h"
26 #include "mantis_uart.h"
27 #include "mantis_ioc.h"
28 #include "mantis_pci.h"
29 #include "mantis_i2c.h"
30 #include "mantis_reg.h"
32 static unsigned int verbose;
33 module_param(verbose, int, 0644);
34 MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");
38 #define DRIVER_NAME "Mantis"
40 static char *label[10] = {
54 static irqreturn_t mantis_irq_handler(int irq, void *dev_id)
56 u32 stat = 0, mask = 0, lstat = 0, mstat = 0;
57 u32 rst_stat = 0, rst_mask = 0;
59 struct mantis_pci *mantis;
62 mantis = (struct mantis_pci *) dev_id;
63 if (unlikely(mantis == NULL)) {
64 dprintk(MANTIS_ERROR, 1, "Mantis == NULL");
67 ca = mantis->mantis_ca;
69 stat = mmread(MANTIS_INT_STAT);
70 mask = mmread(MANTIS_INT_MASK);
71 mstat = lstat = stat & ~MANTIS_INT_RISCSTAT;
75 rst_mask = MANTIS_GPIF_WRACK |
80 rst_stat = mmread(MANTIS_GPIF_STATUS);
82 mmwrite(rst_stat, MANTIS_GPIF_STATUS);
84 mantis->mantis_int_stat = stat;
85 mantis->mantis_int_mask = mask;
86 dprintk(MANTIS_DEBUG, 0, "\n-- Stat=<%02x> Mask=<%02x> --", stat, mask);
87 if (stat & MANTIS_INT_RISCEN) {
88 dprintk(MANTIS_DEBUG, 0, "<%s>", label[0]);
90 if (stat & MANTIS_INT_IRQ0) {
91 dprintk(MANTIS_DEBUG, 0, "<%s>", label[1]);
92 mantis->gpif_status = rst_stat;
93 wake_up(&ca->hif_write_wq);
94 schedule_work(&ca->hif_evm_work);
96 if (stat & MANTIS_INT_IRQ1) {
97 dprintk(MANTIS_DEBUG, 0, "<%s>", label[2]);
98 schedule_work(&mantis->uart_work);
100 if (stat & MANTIS_INT_OCERR) {
101 dprintk(MANTIS_DEBUG, 0, "<%s>", label[3]);
103 if (stat & MANTIS_INT_PABORT) {
104 dprintk(MANTIS_DEBUG, 0, "<%s>", label[4]);
106 if (stat & MANTIS_INT_RIPERR) {
107 dprintk(MANTIS_DEBUG, 0, "<%s>", label[5]);
109 if (stat & MANTIS_INT_PPERR) {
110 dprintk(MANTIS_DEBUG, 0, "<%s>", label[6]);
112 if (stat & MANTIS_INT_FTRGT) {
113 dprintk(MANTIS_DEBUG, 0, "<%s>", label[7]);
115 if (stat & MANTIS_INT_RISCI) {
116 dprintk(MANTIS_DEBUG, 0, "<%s>", label[8]);
117 mantis->finished_block = (stat & MANTIS_INT_RISCSTAT) >> 28;
118 tasklet_schedule(&mantis->tasklet);
120 if (stat & MANTIS_INT_I2CDONE) {
121 dprintk(MANTIS_DEBUG, 0, "<%s>", label[9]);
122 wake_up(&mantis->i2c_wq);
124 mmwrite(stat, MANTIS_INT_STAT);
125 stat &= ~(MANTIS_INT_RISCEN | MANTIS_INT_I2CDONE |
126 MANTIS_INT_I2CRACK | MANTIS_INT_PCMCIA7 |
127 MANTIS_INT_PCMCIA6 | MANTIS_INT_PCMCIA5 |
128 MANTIS_INT_PCMCIA4 | MANTIS_INT_PCMCIA3 |
129 MANTIS_INT_PCMCIA2 | MANTIS_INT_PCMCIA1 |
130 MANTIS_INT_PCMCIA0 | MANTIS_INT_IRQ1 |
131 MANTIS_INT_IRQ0 | MANTIS_INT_OCERR |
132 MANTIS_INT_PABORT | MANTIS_INT_RIPERR |
133 MANTIS_INT_PPERR | MANTIS_INT_FTRGT |
137 dprintk(MANTIS_DEBUG, 0, "<Unknown> Stat=<%02x> Mask=<%02x>", stat, mask);
139 dprintk(MANTIS_DEBUG, 0, "\n");
143 static int __devinit mantis_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
145 struct mantis_pci *mantis;
146 struct mantis_hwconfig *config;
149 mantis = kzalloc(sizeof (struct mantis_pci), GFP_KERNEL);
150 if (mantis == NULL) {
151 printk(KERN_ERR "%s ERROR: Out of memory\n", __func__);
157 mantis->verbose = verbose;
159 config = (struct mantis_hwconfig *) pci_id->driver_data;
160 config->irq_handler = &mantis_irq_handler;
161 mantis->hwconfig = config;
163 err = mantis_pci_init(mantis);
165 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI initialization failed <%d>", err);
169 err = mantis_stream_control(mantis, STREAM_TO_HIF);
171 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis stream control failed <%d>", err);
175 err = mantis_i2c_init(mantis);
177 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C initialization failed <%d>", err);
181 err = mantis_get_mac(mantis);
183 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis MAC address read failed <%d>", err);
187 err = mantis_dma_init(mantis);
189 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA initialization failed <%d>", err);
193 err = mantis_dvb_init(mantis);
195 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err);
203 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB exit! <%d>", err);
204 mantis_dvb_exit(mantis);
207 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA exit! <%d>", err);
208 mantis_dma_exit(mantis);
211 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C exit! <%d>", err);
212 mantis_i2c_exit(mantis);
215 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI exit! <%d>", err);
216 mantis_pci_exit(mantis);
219 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis free! <%d>", err);
226 static void __devexit mantis_pci_remove(struct pci_dev *pdev)
228 struct mantis_pci *mantis = pci_get_drvdata(pdev);
231 mantis_uart_exit(mantis);
232 // mantis_ca_exit(mantis);
233 mantis_dvb_exit(mantis);
234 mantis_dma_exit(mantis);
235 mantis_i2c_exit(mantis);
236 mantis_pci_exit(mantis);
242 static struct pci_device_id mantis_pci_table[] = {
243 MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1033_DVB_S, &vp1033_config),
244 MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1034_DVB_S, &vp1034_config),
245 MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1041_DVB_S2, &vp1041_config),
246 MAKE_ENTRY(TECHNISAT, SKYSTAR_HD2_10, &vp1041_config),
247 MAKE_ENTRY(TECHNISAT, SKYSTAR_HD2_20, &vp1041_config),
248 MAKE_ENTRY(TERRATEC, CINERGY_S2_PCI_HD, &vp1041_config),
249 MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_2033_DVB_C, &vp2033_config),
250 MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_2040_DVB_C, &vp2040_config),
251 MAKE_ENTRY(TECHNISAT, CABLESTAR_HD2, &vp2040_config),
252 MAKE_ENTRY(TERRATEC, CINERGY_C, &vp2033_config),
253 MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_3030_DVB_T, &vp3030_config),
257 static struct pci_driver mantis_pci_driver = {
259 .id_table = mantis_pci_table,
260 .probe = mantis_pci_probe,
261 .remove = mantis_pci_remove,
264 static int __devinit mantis_init(void)
266 return pci_register_driver(&mantis_pci_driver);
269 static void __devexit mantis_exit(void)
271 return pci_unregister_driver(&mantis_pci_driver);
274 module_init(mantis_init);
275 module_exit(mantis_exit);
277 MODULE_DESCRIPTION("MANTIS driver");
278 MODULE_AUTHOR("Manu Abraham");
279 MODULE_LICENSE("GPL");