aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/mantis/hopper_cards.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-02-02 00:38:15 -0500
committerTejun Heo <tj@kernel.org>2010-02-02 00:38:15 -0500
commitab386128f20c44c458a90039ab1bdc265ac474c9 (patch)
tree2ad188744922b1bb951fd10ff50dc04c83acce22 /drivers/media/dvb/mantis/hopper_cards.c
parentdbfc196a3cc1a2514ad0737a82f764de23bd65e6 (diff)
parentab658321f32770b903a4426e2a6fae0392757755 (diff)
Merge branch 'master' into percpu
Diffstat (limited to 'drivers/media/dvb/mantis/hopper_cards.c')
-rw-r--r--drivers/media/dvb/mantis/hopper_cards.c275
1 files changed, 275 insertions, 0 deletions
diff --git a/drivers/media/dvb/mantis/hopper_cards.c b/drivers/media/dvb/mantis/hopper_cards.c
new file mode 100644
index 000000000000..d073c61e3c0d
--- /dev/null
+++ b/drivers/media/dvb/mantis/hopper_cards.c
@@ -0,0 +1,275 @@
1/*
2 Hopper PCI bridge driver
3
4 Copyright (C) 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
21#include <linux/module.h>
22#include <linux/moduleparam.h>
23#include <linux/kernel.h>
24#include <linux/pci.h>
25#include <asm/irq.h>
26#include <linux/interrupt.h>
27
28#include "dmxdev.h"
29#include "dvbdev.h"
30#include "dvb_demux.h"
31#include "dvb_frontend.h"
32#include "dvb_net.h"
33
34#include "mantis_common.h"
35#include "hopper_vp3028.h"
36#include "mantis_dma.h"
37#include "mantis_dvb.h"
38#include "mantis_uart.h"
39#include "mantis_ioc.h"
40#include "mantis_pci.h"
41#include "mantis_i2c.h"
42#include "mantis_reg.h"
43
44static unsigned int verbose;
45module_param(verbose, int, 0644);
46MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");
47
48#define DRIVER_NAME "Hopper"
49
50static char *label[10] = {
51 "DMA",
52 "IRQ-0",
53 "IRQ-1",
54 "OCERR",
55 "PABRT",
56 "RIPRR",
57 "PPERR",
58 "FTRGT",
59 "RISCI",
60 "RACK"
61};
62
63static int devs;
64
65static irqreturn_t hopper_irq_handler(int irq, void *dev_id)
66{
67 u32 stat = 0, mask = 0, lstat = 0, mstat = 0;
68 u32 rst_stat = 0, rst_mask = 0;
69
70 struct mantis_pci *mantis;
71 struct mantis_ca *ca;
72
73 mantis = (struct mantis_pci *) dev_id;
74 if (unlikely(mantis == NULL)) {
75 dprintk(MANTIS_ERROR, 1, "Mantis == NULL");
76 return IRQ_NONE;
77 }
78 ca = mantis->mantis_ca;
79
80 stat = mmread(MANTIS_INT_STAT);
81 mask = mmread(MANTIS_INT_MASK);
82 mstat = lstat = stat & ~MANTIS_INT_RISCSTAT;
83 if (!(stat & mask))
84 return IRQ_NONE;
85
86 rst_mask = MANTIS_GPIF_WRACK |
87 MANTIS_GPIF_OTHERR |
88 MANTIS_SBUF_WSTO |
89 MANTIS_GPIF_EXTIRQ;
90
91 rst_stat = mmread(MANTIS_GPIF_STATUS);
92 rst_stat &= rst_mask;
93 mmwrite(rst_stat, MANTIS_GPIF_STATUS);
94
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]);
100 }
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);
106 }
107 if (stat & MANTIS_INT_IRQ1) {
108 dprintk(MANTIS_DEBUG, 0, "<%s>", label[2]);
109 schedule_work(&mantis->uart_work);
110 }
111 if (stat & MANTIS_INT_OCERR) {
112 dprintk(MANTIS_DEBUG, 0, "<%s>", label[3]);
113 }
114 if (stat & MANTIS_INT_PABORT) {
115 dprintk(MANTIS_DEBUG, 0, "<%s>", label[4]);
116 }
117 if (stat & MANTIS_INT_RIPERR) {
118 dprintk(MANTIS_DEBUG, 0, "<%s>", label[5]);
119 }
120 if (stat & MANTIS_INT_PPERR) {
121 dprintk(MANTIS_DEBUG, 0, "<%s>", label[6]);
122 }
123 if (stat & MANTIS_INT_FTRGT) {
124 dprintk(MANTIS_DEBUG, 0, "<%s>", label[7]);
125 }
126 if (stat & MANTIS_INT_RISCI) {
127 dprintk(MANTIS_DEBUG, 0, "<%s>", label[8]);
128 mantis->finished_block = (stat & MANTIS_INT_RISCSTAT) >> 28;
129 tasklet_schedule(&mantis->tasklet);
130 }
131 if (stat & MANTIS_INT_I2CDONE) {
132 dprintk(MANTIS_DEBUG, 0, "<%s>", label[9]);
133 wake_up(&mantis->i2c_wq);
134 }
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 |
145 MANTIS_INT_RISCI);
146
147 if (stat)
148 dprintk(MANTIS_DEBUG, 0, "<Unknown> Stat=<%02x> Mask=<%02x>", stat, mask);
149
150 dprintk(MANTIS_DEBUG, 0, "\n");
151 return IRQ_HANDLED;
152}
153
154static int __devinit hopper_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
155{
156 struct mantis_pci *mantis;
157 struct mantis_hwconfig *config;
158 int err = 0;
159
160 mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL);
161 if (mantis == NULL) {
162 printk(KERN_ERR "%s ERROR: Out of memory\n", __func__);
163 err = -ENOMEM;
164 goto fail0;
165 }
166
167 mantis->num = devs;
168 mantis->verbose = verbose;
169 mantis->pdev = pdev;
170 config = (struct mantis_hwconfig *) pci_id->driver_data;
171 config->irq_handler = &hopper_irq_handler;
172 mantis->hwconfig = config;
173
174 err = mantis_pci_init(mantis);
175 if (err) {
176 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI initialization failed <%d>", err);
177 goto fail1;
178 }
179
180 err = mantis_stream_control(mantis, STREAM_TO_HIF);
181 if (err < 0) {
182 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis stream control failed <%d>", err);
183 goto fail1;
184 }
185
186 err = mantis_i2c_init(mantis);
187 if (err < 0) {
188 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C initialization failed <%d>", err);
189 goto fail2;
190 }
191
192 err = mantis_get_mac(mantis);
193 if (err < 0) {
194 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis MAC address read failed <%d>", err);
195 goto fail2;
196 }
197
198 err = mantis_dma_init(mantis);
199 if (err < 0) {
200 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA initialization failed <%d>", err);
201 goto fail3;
202 }
203
204 err = mantis_dvb_init(mantis);
205 if (err < 0) {
206 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err);
207 goto fail4;
208 }
209 devs++;
210
211 return err;
212
213fail4:
214 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA exit! <%d>", err);
215 mantis_dma_exit(mantis);
216
217fail3:
218 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C exit! <%d>", err);
219 mantis_i2c_exit(mantis);
220
221fail2:
222 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI exit! <%d>", err);
223 mantis_pci_exit(mantis);
224
225fail1:
226 dprintk(MANTIS_ERROR, 1, "ERROR: Mantis free! <%d>", err);
227 kfree(mantis);
228
229fail0:
230 return err;
231}
232
233static void __devexit hopper_pci_remove(struct pci_dev *pdev)
234{
235 struct mantis_pci *mantis = pci_get_drvdata(pdev);
236
237 if (mantis) {
238 mantis_dvb_exit(mantis);
239 mantis_dma_exit(mantis);
240 mantis_i2c_exit(mantis);
241 mantis_pci_exit(mantis);
242 kfree(mantis);
243 }
244 return;
245
246}
247
248static struct pci_device_id hopper_pci_table[] = {
249 MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_3028_DVB_T, &vp3028_config),
250 { }
251};
252
253static struct pci_driver hopper_pci_driver = {
254 .name = DRIVER_NAME,
255 .id_table = hopper_pci_table,
256 .probe = hopper_pci_probe,
257 .remove = hopper_pci_remove,
258};
259
260static int __devinit hopper_init(void)
261{
262 return pci_register_driver(&hopper_pci_driver);
263}
264
265static void __devexit hopper_exit(void)
266{
267 return pci_unregister_driver(&hopper_pci_driver);
268}
269
270module_init(hopper_init);
271module_exit(hopper_exit);
272
273MODULE_DESCRIPTION("HOPPER driver");
274MODULE_AUTHOR("Manu Abraham");
275MODULE_LICENSE("GPL");