2 Hopper PCI bridge driver
4 Copyright (C) Manu Abraham (abraham.manu@gmail.com)
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.
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.
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.
21 #include <linux/module.h>
22 #include <linux/moduleparam.h>
23 #include <linux/kernel.h>
24 #include <linux/pci.h>
25 #include <linux/slab.h>
27 #include <linux/interrupt.h>
31 #include "dvb_demux.h"
32 #include "dvb_frontend.h"
35 #include "mantis_common.h"
36 #include "hopper_vp3028.h"
37 #include "mantis_dma.h"
38 #include "mantis_dvb.h"
39 #include "mantis_uart.h"
40 #include "mantis_ioc.h"
41 #include "mantis_pci.h"
42 #include "mantis_i2c.h"
43 #include "mantis_reg.h"
45 static unsigned int verbose
;
46 module_param(verbose
, int, 0644);
47 MODULE_PARM_DESC(verbose
, "verbose startup messages, default is 0 (no)");
49 #define DRIVER_NAME "Hopper"
51 static char *label
[10] = {
66 static irqreturn_t
hopper_irq_handler(int irq
, void *dev_id
)
68 u32 stat
= 0, mask
= 0;
69 u32 rst_stat
= 0, rst_mask
= 0;
71 struct mantis_pci
*mantis
;
74 mantis
= (struct mantis_pci
*) dev_id
;
75 if (unlikely(mantis
== NULL
)) {
76 dprintk(MANTIS_ERROR
, 1, "Mantis == NULL");
79 ca
= mantis
->mantis_ca
;
81 stat
= mmread(MANTIS_INT_STAT
);
82 mask
= mmread(MANTIS_INT_MASK
);
86 rst_mask
= MANTIS_GPIF_WRACK
|
91 rst_stat
= mmread(MANTIS_GPIF_STATUS
);
93 mmwrite(rst_stat
, MANTIS_GPIF_STATUS
);
95 mantis
->mantis_int_stat
= stat
;
96 mantis
->mantis_int_mask
= mask
;
97 dprintk(MANTIS_DEBUG
, 0, "\n-- Stat=<%02x> Mask=<%02x> --", stat
, mask
);
98 if (stat
& MANTIS_INT_RISCEN
) {
99 dprintk(MANTIS_DEBUG
, 0, "<%s>", label
[0]);
101 if (stat
& MANTIS_INT_IRQ0
) {
102 dprintk(MANTIS_DEBUG
, 0, "<%s>", label
[1]);
103 mantis
->gpif_status
= rst_stat
;
104 wake_up(&ca
->hif_write_wq
);
105 schedule_work(&ca
->hif_evm_work
);
107 if (stat
& MANTIS_INT_IRQ1
) {
108 dprintk(MANTIS_DEBUG
, 0, "<%s>", label
[2]);
109 schedule_work(&mantis
->uart_work
);
111 if (stat
& MANTIS_INT_OCERR
) {
112 dprintk(MANTIS_DEBUG
, 0, "<%s>", label
[3]);
114 if (stat
& MANTIS_INT_PABORT
) {
115 dprintk(MANTIS_DEBUG
, 0, "<%s>", label
[4]);
117 if (stat
& MANTIS_INT_RIPERR
) {
118 dprintk(MANTIS_DEBUG
, 0, "<%s>", label
[5]);
120 if (stat
& MANTIS_INT_PPERR
) {
121 dprintk(MANTIS_DEBUG
, 0, "<%s>", label
[6]);
123 if (stat
& MANTIS_INT_FTRGT
) {
124 dprintk(MANTIS_DEBUG
, 0, "<%s>", label
[7]);
126 if (stat
& MANTIS_INT_RISCI
) {
127 dprintk(MANTIS_DEBUG
, 0, "<%s>", label
[8]);
128 mantis
->busy_block
= (stat
& MANTIS_INT_RISCSTAT
) >> 28;
129 tasklet_schedule(&mantis
->tasklet
);
131 if (stat
& MANTIS_INT_I2CDONE
) {
132 dprintk(MANTIS_DEBUG
, 0, "<%s>", label
[9]);
133 wake_up(&mantis
->i2c_wq
);
135 mmwrite(stat
, MANTIS_INT_STAT
);
136 stat
&= ~(MANTIS_INT_RISCEN
| MANTIS_INT_I2CDONE
|
137 MANTIS_INT_I2CRACK
| MANTIS_INT_PCMCIA7
|
138 MANTIS_INT_PCMCIA6
| MANTIS_INT_PCMCIA5
|
139 MANTIS_INT_PCMCIA4
| MANTIS_INT_PCMCIA3
|
140 MANTIS_INT_PCMCIA2
| MANTIS_INT_PCMCIA1
|
141 MANTIS_INT_PCMCIA0
| MANTIS_INT_IRQ1
|
142 MANTIS_INT_IRQ0
| MANTIS_INT_OCERR
|
143 MANTIS_INT_PABORT
| MANTIS_INT_RIPERR
|
144 MANTIS_INT_PPERR
| MANTIS_INT_FTRGT
|
148 dprintk(MANTIS_DEBUG
, 0, "<Unknown> Stat=<%02x> Mask=<%02x>", stat
, mask
);
150 dprintk(MANTIS_DEBUG
, 0, "\n");
154 static int hopper_pci_probe(struct pci_dev
*pdev
,
155 const struct pci_device_id
*pci_id
)
157 struct mantis_pci
*mantis
;
158 struct mantis_hwconfig
*config
;
161 mantis
= kzalloc(sizeof(struct mantis_pci
), GFP_KERNEL
);
162 if (mantis
== NULL
) {
163 printk(KERN_ERR
"%s ERROR: Out of memory\n", __func__
);
169 mantis
->verbose
= verbose
;
171 config
= (struct mantis_hwconfig
*) pci_id
->driver_data
;
172 config
->irq_handler
= &hopper_irq_handler
;
173 mantis
->hwconfig
= config
;
175 err
= mantis_pci_init(mantis
);
177 dprintk(MANTIS_ERROR
, 1, "ERROR: Mantis PCI initialization failed <%d>", err
);
181 err
= mantis_stream_control(mantis
, STREAM_TO_HIF
);
183 dprintk(MANTIS_ERROR
, 1, "ERROR: Mantis stream control failed <%d>", err
);
187 err
= mantis_i2c_init(mantis
);
189 dprintk(MANTIS_ERROR
, 1, "ERROR: Mantis I2C initialization failed <%d>", err
);
193 err
= mantis_get_mac(mantis
);
195 dprintk(MANTIS_ERROR
, 1, "ERROR: Mantis MAC address read failed <%d>", err
);
199 err
= mantis_dma_init(mantis
);
201 dprintk(MANTIS_ERROR
, 1, "ERROR: Mantis DMA initialization failed <%d>", err
);
205 err
= mantis_dvb_init(mantis
);
207 dprintk(MANTIS_ERROR
, 1, "ERROR: Mantis DVB initialization failed <%d>", err
);
215 dprintk(MANTIS_ERROR
, 1, "ERROR: Mantis DMA exit! <%d>", err
);
216 mantis_dma_exit(mantis
);
219 dprintk(MANTIS_ERROR
, 1, "ERROR: Mantis I2C exit! <%d>", err
);
220 mantis_i2c_exit(mantis
);
223 dprintk(MANTIS_ERROR
, 1, "ERROR: Mantis PCI exit! <%d>", err
);
224 mantis_pci_exit(mantis
);
227 dprintk(MANTIS_ERROR
, 1, "ERROR: Mantis free! <%d>", err
);
234 static void hopper_pci_remove(struct pci_dev
*pdev
)
236 struct mantis_pci
*mantis
= pci_get_drvdata(pdev
);
239 mantis_dvb_exit(mantis
);
240 mantis_dma_exit(mantis
);
241 mantis_i2c_exit(mantis
);
242 mantis_pci_exit(mantis
);
249 static struct pci_device_id hopper_pci_table
[] = {
250 MAKE_ENTRY(TWINHAN_TECHNOLOGIES
, MANTIS_VP_3028_DVB_T
, &vp3028_config
),
254 MODULE_DEVICE_TABLE(pci
, hopper_pci_table
);
256 static struct pci_driver hopper_pci_driver
= {
258 .id_table
= hopper_pci_table
,
259 .probe
= hopper_pci_probe
,
260 .remove
= hopper_pci_remove
,
263 module_pci_driver(hopper_pci_driver
);
265 MODULE_DESCRIPTION("HOPPER driver");
266 MODULE_AUTHOR("Manu Abraham");
267 MODULE_LICENSE("GPL");