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] = {
53 static irqreturn_t mantis_irq_handler(int irq, void *dev_id)
55 u32 stat = 0, mask = 0, lstat = 0, mstat = 0;
56 u32 rst_stat = 0, rst_mask = 0;
58 struct mantis_pci *mantis;
61 mantis = (struct mantis_pci *) dev_id;
62 if (unlikely(mantis == NULL)) {
63 dprintk(MANTIS_ERROR, 1, "Mantis == NULL");
66 ca = mantis->mantis_ca;
68 stat = mmread(MANTIS_INT_STAT);
69 mask = mmread(MANTIS_INT_MASK);
70 mstat = lstat = stat & ~MANTIS_INT_RISCSTAT;
74 rst_mask = MANTIS_GPIF_WRACK |
79 rst_stat = mmread(MANTIS_GPIF_STATUS);
81 mmwrite(rst_stat, MANTIS_GPIF_STATUS);
83 mantis->mantis_int_stat = stat;
84 mantis->mantis_int_mask = mask;
85 dprintk(MANTIS_DEBUG, 0, "\n-- Stat=<%02x> Mask=<%02x> --", stat, mask);
86 if (stat & MANTIS_INT_RISCEN) {
87 dprintk(MANTIS_DEBUG, 0, "<%s>", label[0]);
89 if (stat & MANTIS_INT_IRQ0) {
90 dprintk(MANTIS_DEBUG, 0, "<%s>", label[1]);
91 mantis->gpif_status = rst_stat;
92 wake_up(&ca->hif_write_wq);
93 schedule_work(&ca->hif_evm_work);
95 if (stat & MANTIS_INT_IRQ1) {
96 dprintk(MANTIS_DEBUG, 0, "<%s>", label[2]);
97 schedule_work(&mantis->uart_work);
99 if (stat & MANTIS_INT_OCERR) {
100 dprintk(MANTIS_DEBUG, 0, "<%s>", label[3]);
102 if (stat & MANTIS_INT_PABORT) {
103 dprintk(MANTIS_DEBUG, 0, "<%s>", label[4]);
105 if (stat & MANTIS_INT_RIPERR) {
106 dprintk(MANTIS_DEBUG, 0, "<%s>", label[5]);
108 if (stat & MANTIS_INT_PPERR) {
109 dprintk(MANTIS_DEBUG, 0, "<%s>", label[6]);
111 if (stat & MANTIS_INT_FTRGT) {
112 dprintk(MANTIS_DEBUG, 0, "<%s>", label[7]);
114 if (stat & MANTIS_INT_RISCI) {
115 dprintk(MANTIS_DEBUG, 0, "<%s>", label[8]);
116 mantis->finished_block = (stat & MANTIS_INT_RISCSTAT) >> 28;
117 tasklet_schedule(&mantis->tasklet);
119 if (stat & MANTIS_INT_I2CDONE) {
120 dprintk(MANTIS_DEBUG, 0, "<%s>", label[9]);
121 wake_up(&mantis->i2c_wq);
123 mmwrite(stat, MANTIS_INT_STAT);
124 stat &= ~(MANTIS_INT_RISCEN | MANTIS_INT_I2CDONE |
125 MANTIS_INT_I2CRACK | MANTIS_INT_PCMCIA7 |
126 MANTIS_INT_PCMCIA6 | MANTIS_INT_PCMCIA5 |
127 MANTIS_INT_PCMCIA4 | MANTIS_INT_PCMCIA3 |
128 MANTIS_INT_PCMCIA2 | MANTIS_INT_PCMCIA1 |
129 MANTIS_INT_PCMCIA0 | MANTIS_INT_IRQ1 |
130 MANTIS_INT_IRQ0 | MANTIS_INT_OCERR |
131 MANTIS_INT_PABORT | MANTIS_INT_RIPERR |
132 MANTIS_INT_PPERR | MANTIS_INT_FTRGT |
136 dprintk(MANTIS_DEBUG, 0, "<Unknown> Stat=<%02x> Mask=<%02x>", stat, mask);
138 dprintk(MANTIS_DEBUG, 0, "\n");
142 static int __devinit mantis_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
144 struct mantis_pci *mantis;
145 struct mantis_hwconfig *config;
148 mantis = kzalloc(sizeof (struct mantis_pci), GFP_KERNEL);
149 if (mantis == NULL) {
150 printk(KERN_ERR "%s ERROR: Out of memory\n", __func__);
156 mantis->verbose = verbose;
158 config = (struct mantis_hwconfig *) pci_id->driver_data;
159 config->irq_handler = &mantis_irq_handler;
160 mantis->hwconfig = config;
162 err = mantis_pci_init(mantis);
164 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI initialization failed <%d>", err);
168 err = mantis_stream_control(mantis, STREAM_TO_HIF);
170 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis stream control failed <%d>", err);
174 err = mantis_i2c_init(mantis);
176 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C initialization failed <%d>", err);
180 err = mantis_get_mac(mantis);
182 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis MAC address read failed <%d>", err);
186 err = mantis_dma_init(mantis);
188 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA initialization failed <%d>", err);
192 err = mantis_dvb_init(mantis);
194 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err);
201 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA exit! <%d>", err);
202 mantis_dma_exit(mantis);
205 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C exit! <%d>", err);
206 mantis_i2c_exit(mantis);
209 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI exit! <%d>", err);
210 mantis_pci_exit(mantis);
213 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis free! <%d>", err);
220 static void __devexit mantis_pci_remove(struct pci_dev *pdev)
222 struct mantis_pci *mantis = pci_get_drvdata(pdev);
225 mantis_dvb_exit(mantis);
226 mantis_dma_exit(mantis);
227 mantis_i2c_exit(mantis);
228 mantis_pci_exit(mantis);
234 static struct pci_device_id mantis_pci_table[] = {
235 MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1033_DVB_S, &vp1033_config),
236 MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1034_DVB_S, &vp1034_config),
237 MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1041_DVB_S2, &vp1041_config),
238 MAKE_ENTRY(TECHNISAT, SKYSTAR_HD2_10, &vp1041_config),
239 MAKE_ENTRY(TECHNISAT, SKYSTAR_HD2_20, &vp1041_config),
240 MAKE_ENTRY(TERRATEC, CINERGY_S2_PCI_HD, &vp1041_config),
241 MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_2033_DVB_C, &vp2033_config),
242 MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_2040_DVB_C, &vp2040_config),
243 MAKE_ENTRY(TECHNISAT, CABLESTAR_HD2, &vp2040_config),
244 MAKE_ENTRY(TERRATEC, CINERGY_C, &vp2033_config),
245 MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_3030_DVB_T, &vp3030_config),
249 static struct pci_driver mantis_pci_driver = {
251 .id_table = mantis_pci_table,
252 .probe = mantis_pci_probe,
253 .remove = mantis_pci_remove,
256 static int __devinit mantis_init(void)
258 return pci_register_driver(&mantis_pci_driver);
261 static void __devexit mantis_exit(void)
263 return pci_unregister_driver(&mantis_pci_driver);
266 module_init(mantis_init);
267 module_exit(mantis_exit);
269 MODULE_DESCRIPTION("MANTIS driver");
270 MODULE_AUTHOR("Manu Abraham");
271 MODULE_LICENSE("GPL");