diff options
author | David S. Miller <davem@davemloft.net> | 2010-01-23 03:31:06 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-01-23 03:31:06 -0500 |
commit | 51c24aaacaea90c8e87f1dec75a2ac7622b593f8 (patch) | |
tree | 9f54936c87764bef75e97395cb56b7d1e0df24c6 /drivers/media/dvb/mantis | |
parent | 4276e47e2d1c85a2477caf0d22b91c4f2377fba8 (diff) | |
parent | 6be325719b3e54624397e413efd4b33a997e55a3 (diff) |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
Diffstat (limited to 'drivers/media/dvb/mantis')
44 files changed, 5369 insertions, 0 deletions
diff --git a/drivers/media/dvb/mantis/Kconfig b/drivers/media/dvb/mantis/Kconfig new file mode 100644 index 000000000000..f7b72a32adf3 --- /dev/null +++ b/drivers/media/dvb/mantis/Kconfig | |||
@@ -0,0 +1,32 @@ | |||
1 | config MANTIS_CORE | ||
2 | tristate "Mantis/Hopper PCI bridge based devices" | ||
3 | depends on PCI && I2C && INPUT | ||
4 | |||
5 | help | ||
6 | Support for PCI cards based on the Mantis and Hopper PCi bridge. | ||
7 | |||
8 | Say Y if you own such a device and want to use it. | ||
9 | |||
10 | config DVB_MANTIS | ||
11 | tristate "MANTIS based cards" | ||
12 | depends on MANTIS_CORE && DVB_CORE && PCI && I2C | ||
13 | select DVB_MB86A16 | ||
14 | select DVB_ZL10353 | ||
15 | select DVB_STV0299 | ||
16 | select DVB_PLL | ||
17 | help | ||
18 | Support for PCI cards based on the Mantis PCI bridge. | ||
19 | Say Y when you have a Mantis based DVB card and want to use it. | ||
20 | |||
21 | If unsure say N. | ||
22 | |||
23 | config DVB_HOPPER | ||
24 | tristate "HOPPER based cards" | ||
25 | depends on MANTIS_CORE && DVB_CORE && PCI && I2C | ||
26 | select DVB_ZL10353 | ||
27 | select DVB_PLL | ||
28 | help | ||
29 | Support for PCI cards based on the Hopper PCI bridge. | ||
30 | Say Y when you have a Hopper based DVB card and want to use it. | ||
31 | |||
32 | If unsure say N | ||
diff --git a/drivers/media/dvb/mantis/Makefile b/drivers/media/dvb/mantis/Makefile new file mode 100644 index 000000000000..98dc5cd258ac --- /dev/null +++ b/drivers/media/dvb/mantis/Makefile | |||
@@ -0,0 +1,28 @@ | |||
1 | mantis_core-objs := mantis_ioc.o \ | ||
2 | mantis_uart.o \ | ||
3 | mantis_dma.o \ | ||
4 | mantis_pci.o \ | ||
5 | mantis_i2c.o \ | ||
6 | mantis_dvb.o \ | ||
7 | mantis_evm.o \ | ||
8 | mantis_hif.o \ | ||
9 | mantis_ca.o \ | ||
10 | mantis_pcmcia.o \ | ||
11 | mantis_input.o | ||
12 | |||
13 | mantis-objs := mantis_cards.o \ | ||
14 | mantis_vp1033.o \ | ||
15 | mantis_vp1034.o \ | ||
16 | mantis_vp1041.o \ | ||
17 | mantis_vp2033.o \ | ||
18 | mantis_vp2040.o \ | ||
19 | mantis_vp3030.o | ||
20 | |||
21 | hopper-objs := hopper_cards.o \ | ||
22 | hopper_vp3028.o | ||
23 | |||
24 | obj-$(CONFIG_MANTIS_CORE) += mantis_core.o | ||
25 | obj-$(CONFIG_DVB_MANTIS) += mantis.o | ||
26 | obj-$(CONFIG_DVB_HOPPER) += hopper.o | ||
27 | |||
28 | EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ | ||
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 | |||
44 | static unsigned int verbose; | ||
45 | module_param(verbose, int, 0644); | ||
46 | MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); | ||
47 | |||
48 | #define DRIVER_NAME "Hopper" | ||
49 | |||
50 | static 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 | |||
63 | static int devs; | ||
64 | |||
65 | static 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 | |||
154 | static 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 | |||
213 | fail4: | ||
214 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA exit! <%d>", err); | ||
215 | mantis_dma_exit(mantis); | ||
216 | |||
217 | fail3: | ||
218 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C exit! <%d>", err); | ||
219 | mantis_i2c_exit(mantis); | ||
220 | |||
221 | fail2: | ||
222 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI exit! <%d>", err); | ||
223 | mantis_pci_exit(mantis); | ||
224 | |||
225 | fail1: | ||
226 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis free! <%d>", err); | ||
227 | kfree(mantis); | ||
228 | |||
229 | fail0: | ||
230 | return err; | ||
231 | } | ||
232 | |||
233 | static 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 | |||
248 | static struct pci_device_id hopper_pci_table[] = { | ||
249 | MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_3028_DVB_T, &vp3028_config), | ||
250 | { } | ||
251 | }; | ||
252 | |||
253 | static 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 | |||
260 | static int __devinit hopper_init(void) | ||
261 | { | ||
262 | return pci_register_driver(&hopper_pci_driver); | ||
263 | } | ||
264 | |||
265 | static void __devexit hopper_exit(void) | ||
266 | { | ||
267 | return pci_unregister_driver(&hopper_pci_driver); | ||
268 | } | ||
269 | |||
270 | module_init(hopper_init); | ||
271 | module_exit(hopper_exit); | ||
272 | |||
273 | MODULE_DESCRIPTION("HOPPER driver"); | ||
274 | MODULE_AUTHOR("Manu Abraham"); | ||
275 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/mantis/hopper_vp3028.c b/drivers/media/dvb/mantis/hopper_vp3028.c new file mode 100644 index 000000000000..96674c78e86b --- /dev/null +++ b/drivers/media/dvb/mantis/hopper_vp3028.c | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | Hopper VP-3028 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/signal.h> | ||
22 | #include <linux/sched.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | |||
25 | #include "dmxdev.h" | ||
26 | #include "dvbdev.h" | ||
27 | #include "dvb_demux.h" | ||
28 | #include "dvb_frontend.h" | ||
29 | #include "dvb_net.h" | ||
30 | |||
31 | #include "zl10353.h" | ||
32 | #include "mantis_common.h" | ||
33 | #include "mantis_ioc.h" | ||
34 | #include "mantis_dvb.h" | ||
35 | #include "hopper_vp3028.h" | ||
36 | |||
37 | struct zl10353_config hopper_vp3028_config = { | ||
38 | .demod_address = 0x0f, | ||
39 | }; | ||
40 | |||
41 | #define MANTIS_MODEL_NAME "VP-3028" | ||
42 | #define MANTIS_DEV_TYPE "DVB-T" | ||
43 | |||
44 | static int vp3028_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe) | ||
45 | { | ||
46 | struct i2c_adapter *adapter = &mantis->adapter; | ||
47 | struct mantis_hwconfig *config = mantis->hwconfig; | ||
48 | int err = 0; | ||
49 | |||
50 | gpio_set_bits(mantis, config->reset, 0); | ||
51 | msleep(100); | ||
52 | err = mantis_frontend_power(mantis, POWER_ON); | ||
53 | msleep(100); | ||
54 | gpio_set_bits(mantis, config->reset, 1); | ||
55 | |||
56 | err = mantis_frontend_power(mantis, POWER_ON); | ||
57 | if (err == 0) { | ||
58 | msleep(250); | ||
59 | dprintk(MANTIS_ERROR, 1, "Probing for 10353 (DVB-T)"); | ||
60 | fe = zl10353_attach(&hopper_vp3028_config, adapter); | ||
61 | |||
62 | if (!fe) | ||
63 | return -1; | ||
64 | } else { | ||
65 | dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>", | ||
66 | adapter->name, | ||
67 | err); | ||
68 | |||
69 | return -EIO; | ||
70 | } | ||
71 | dprintk(MANTIS_ERROR, 1, "Done!"); | ||
72 | |||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | struct mantis_hwconfig vp3028_config = { | ||
77 | .model_name = MANTIS_MODEL_NAME, | ||
78 | .dev_type = MANTIS_DEV_TYPE, | ||
79 | .ts_size = MANTIS_TS_188, | ||
80 | |||
81 | .baud_rate = MANTIS_BAUD_9600, | ||
82 | .parity = MANTIS_PARITY_NONE, | ||
83 | .bytes = 0, | ||
84 | |||
85 | .frontend_init = vp3028_frontend_init, | ||
86 | .power = GPIF_A00, | ||
87 | .reset = GPIF_A03, | ||
88 | }; | ||
diff --git a/drivers/media/dvb/mantis/hopper_vp3028.h b/drivers/media/dvb/mantis/hopper_vp3028.h new file mode 100644 index 000000000000..57239498bc87 --- /dev/null +++ b/drivers/media/dvb/mantis/hopper_vp3028.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | Hopper VP-3028 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 | #ifndef __MANTIS_VP3028_H | ||
22 | #define __MANTIS_VP3028_H | ||
23 | |||
24 | #include "mantis_common.h" | ||
25 | |||
26 | #define MANTIS_VP_3028_DVB_T 0x0028 | ||
27 | |||
28 | extern struct mantis_hwconfig vp3028_config; | ||
29 | |||
30 | #endif /* __MANTIS_VP3028_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_ca.c b/drivers/media/dvb/mantis/mantis_ca.c new file mode 100644 index 000000000000..403ce043d00e --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_ca.c | |||
@@ -0,0 +1,207 @@ | |||
1 | /* | ||
2 | Mantis 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/signal.h> | ||
22 | #include <linux/sched.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | |||
25 | #include "dmxdev.h" | ||
26 | #include "dvbdev.h" | ||
27 | #include "dvb_demux.h" | ||
28 | #include "dvb_frontend.h" | ||
29 | #include "dvb_net.h" | ||
30 | |||
31 | #include "mantis_common.h" | ||
32 | #include "mantis_link.h" | ||
33 | #include "mantis_hif.h" | ||
34 | #include "mantis_reg.h" | ||
35 | |||
36 | #include "mantis_ca.h" | ||
37 | |||
38 | static int mantis_ca_read_attr_mem(struct dvb_ca_en50221 *en50221, int slot, int addr) | ||
39 | { | ||
40 | struct mantis_ca *ca = en50221->data; | ||
41 | struct mantis_pci *mantis = ca->ca_priv; | ||
42 | |||
43 | dprintk(MANTIS_DEBUG, 1, "Slot(%d): Request Attribute Mem Read", slot); | ||
44 | |||
45 | if (slot != 0) | ||
46 | return -EINVAL; | ||
47 | |||
48 | return mantis_hif_read_mem(ca, addr); | ||
49 | } | ||
50 | |||
51 | static int mantis_ca_write_attr_mem(struct dvb_ca_en50221 *en50221, int slot, int addr, u8 data) | ||
52 | { | ||
53 | struct mantis_ca *ca = en50221->data; | ||
54 | struct mantis_pci *mantis = ca->ca_priv; | ||
55 | |||
56 | dprintk(MANTIS_DEBUG, 1, "Slot(%d): Request Attribute Mem Write", slot); | ||
57 | |||
58 | if (slot != 0) | ||
59 | return -EINVAL; | ||
60 | |||
61 | return mantis_hif_write_mem(ca, addr, data); | ||
62 | } | ||
63 | |||
64 | static int mantis_ca_read_cam_ctl(struct dvb_ca_en50221 *en50221, int slot, u8 addr) | ||
65 | { | ||
66 | struct mantis_ca *ca = en50221->data; | ||
67 | struct mantis_pci *mantis = ca->ca_priv; | ||
68 | |||
69 | dprintk(MANTIS_DEBUG, 1, "Slot(%d): Request CAM control Read", slot); | ||
70 | |||
71 | if (slot != 0) | ||
72 | return -EINVAL; | ||
73 | |||
74 | return mantis_hif_read_iom(ca, addr); | ||
75 | } | ||
76 | |||
77 | static int mantis_ca_write_cam_ctl(struct dvb_ca_en50221 *en50221, int slot, u8 addr, u8 data) | ||
78 | { | ||
79 | struct mantis_ca *ca = en50221->data; | ||
80 | struct mantis_pci *mantis = ca->ca_priv; | ||
81 | |||
82 | dprintk(MANTIS_DEBUG, 1, "Slot(%d): Request CAM control Write", slot); | ||
83 | |||
84 | if (slot != 0) | ||
85 | return -EINVAL; | ||
86 | |||
87 | return mantis_hif_write_iom(ca, addr, data); | ||
88 | } | ||
89 | |||
90 | static int mantis_ca_slot_reset(struct dvb_ca_en50221 *en50221, int slot) | ||
91 | { | ||
92 | struct mantis_ca *ca = en50221->data; | ||
93 | struct mantis_pci *mantis = ca->ca_priv; | ||
94 | |||
95 | dprintk(MANTIS_DEBUG, 1, "Slot(%d): Slot RESET", slot); | ||
96 | udelay(500); /* Wait.. */ | ||
97 | mmwrite(0xda, MANTIS_PCMCIA_RESET); /* Leading edge assert */ | ||
98 | udelay(500); | ||
99 | mmwrite(0x00, MANTIS_PCMCIA_RESET); /* Trailing edge deassert */ | ||
100 | msleep(1000); | ||
101 | dvb_ca_en50221_camready_irq(&ca->en50221, 0); | ||
102 | |||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | static int mantis_ca_slot_shutdown(struct dvb_ca_en50221 *en50221, int slot) | ||
107 | { | ||
108 | struct mantis_ca *ca = en50221->data; | ||
109 | struct mantis_pci *mantis = ca->ca_priv; | ||
110 | |||
111 | dprintk(MANTIS_DEBUG, 1, "Slot(%d): Slot shutdown", slot); | ||
112 | |||
113 | return 0; | ||
114 | } | ||
115 | |||
116 | static int mantis_ts_control(struct dvb_ca_en50221 *en50221, int slot) | ||
117 | { | ||
118 | struct mantis_ca *ca = en50221->data; | ||
119 | struct mantis_pci *mantis = ca->ca_priv; | ||
120 | |||
121 | dprintk(MANTIS_DEBUG, 1, "Slot(%d): TS control", slot); | ||
122 | /* mantis_set_direction(mantis, 1); */ /* Enable TS through CAM */ | ||
123 | |||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | static int mantis_slot_status(struct dvb_ca_en50221 *en50221, int slot, int open) | ||
128 | { | ||
129 | struct mantis_ca *ca = en50221->data; | ||
130 | struct mantis_pci *mantis = ca->ca_priv; | ||
131 | |||
132 | dprintk(MANTIS_DEBUG, 1, "Slot(%d): Poll Slot status", slot); | ||
133 | |||
134 | if (ca->slot_state == MODULE_INSERTED) { | ||
135 | dprintk(MANTIS_DEBUG, 1, "CA Module present and ready"); | ||
136 | return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY; | ||
137 | } else { | ||
138 | dprintk(MANTIS_DEBUG, 1, "CA Module not present or not ready"); | ||
139 | } | ||
140 | |||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | int mantis_ca_init(struct mantis_pci *mantis) | ||
145 | { | ||
146 | struct dvb_adapter *dvb_adapter = &mantis->dvb_adapter; | ||
147 | struct mantis_ca *ca; | ||
148 | int ca_flags = 0, result; | ||
149 | |||
150 | dprintk(MANTIS_DEBUG, 1, "Initializing Mantis CA"); | ||
151 | ca = kzalloc(sizeof(struct mantis_ca), GFP_KERNEL); | ||
152 | if (!ca) { | ||
153 | dprintk(MANTIS_ERROR, 1, "Out of memory!, exiting .."); | ||
154 | result = -ENOMEM; | ||
155 | goto err; | ||
156 | } | ||
157 | |||
158 | ca->ca_priv = mantis; | ||
159 | mantis->mantis_ca = ca; | ||
160 | ca_flags = DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE; | ||
161 | /* register CA interface */ | ||
162 | ca->en50221.owner = THIS_MODULE; | ||
163 | ca->en50221.read_attribute_mem = mantis_ca_read_attr_mem; | ||
164 | ca->en50221.write_attribute_mem = mantis_ca_write_attr_mem; | ||
165 | ca->en50221.read_cam_control = mantis_ca_read_cam_ctl; | ||
166 | ca->en50221.write_cam_control = mantis_ca_write_cam_ctl; | ||
167 | ca->en50221.slot_reset = mantis_ca_slot_reset; | ||
168 | ca->en50221.slot_shutdown = mantis_ca_slot_shutdown; | ||
169 | ca->en50221.slot_ts_enable = mantis_ts_control; | ||
170 | ca->en50221.poll_slot_status = mantis_slot_status; | ||
171 | ca->en50221.data = ca; | ||
172 | |||
173 | mutex_init(&ca->ca_lock); | ||
174 | |||
175 | init_waitqueue_head(&ca->hif_data_wq); | ||
176 | init_waitqueue_head(&ca->hif_opdone_wq); | ||
177 | init_waitqueue_head(&ca->hif_write_wq); | ||
178 | |||
179 | dprintk(MANTIS_ERROR, 1, "Registering EN50221 device"); | ||
180 | result = dvb_ca_en50221_init(dvb_adapter, &ca->en50221, ca_flags, 1); | ||
181 | if (result != 0) { | ||
182 | dprintk(MANTIS_ERROR, 1, "EN50221: Initialization failed <%d>", result); | ||
183 | goto err; | ||
184 | } | ||
185 | dprintk(MANTIS_ERROR, 1, "Registered EN50221 device"); | ||
186 | mantis_evmgr_init(ca); | ||
187 | return 0; | ||
188 | err: | ||
189 | kfree(ca); | ||
190 | return result; | ||
191 | } | ||
192 | EXPORT_SYMBOL_GPL(mantis_ca_init); | ||
193 | |||
194 | void mantis_ca_exit(struct mantis_pci *mantis) | ||
195 | { | ||
196 | struct mantis_ca *ca = mantis->mantis_ca; | ||
197 | |||
198 | dprintk(MANTIS_DEBUG, 1, "Mantis CA exit"); | ||
199 | |||
200 | mantis_evmgr_exit(ca); | ||
201 | dprintk(MANTIS_ERROR, 1, "Unregistering EN50221 device"); | ||
202 | if (ca) | ||
203 | dvb_ca_en50221_release(&ca->en50221); | ||
204 | |||
205 | kfree(ca); | ||
206 | } | ||
207 | EXPORT_SYMBOL_GPL(mantis_ca_exit); | ||
diff --git a/drivers/media/dvb/mantis/mantis_ca.h b/drivers/media/dvb/mantis/mantis_ca.h new file mode 100644 index 000000000000..dc63e55f7eca --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_ca.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /* | ||
2 | Mantis 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 | #ifndef __MANTIS_CA_H | ||
22 | #define __MANTIS_CA_H | ||
23 | |||
24 | extern int mantis_ca_init(struct mantis_pci *mantis); | ||
25 | extern void mantis_ca_exit(struct mantis_pci *mantis); | ||
26 | |||
27 | #endif /* __MANTIS_CA_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_cards.c b/drivers/media/dvb/mantis/mantis_cards.c new file mode 100644 index 000000000000..16f1708fd3bc --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_cards.c | |||
@@ -0,0 +1,305 @@ | |||
1 | /* | ||
2 | Mantis 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 | |||
36 | #include "mantis_vp1033.h" | ||
37 | #include "mantis_vp1034.h" | ||
38 | #include "mantis_vp1041.h" | ||
39 | #include "mantis_vp2033.h" | ||
40 | #include "mantis_vp2040.h" | ||
41 | #include "mantis_vp3030.h" | ||
42 | |||
43 | #include "mantis_dma.h" | ||
44 | #include "mantis_ca.h" | ||
45 | #include "mantis_dvb.h" | ||
46 | #include "mantis_uart.h" | ||
47 | #include "mantis_ioc.h" | ||
48 | #include "mantis_pci.h" | ||
49 | #include "mantis_i2c.h" | ||
50 | #include "mantis_reg.h" | ||
51 | |||
52 | static unsigned int verbose; | ||
53 | module_param(verbose, int, 0644); | ||
54 | MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); | ||
55 | |||
56 | static int devs; | ||
57 | |||
58 | #define DRIVER_NAME "Mantis" | ||
59 | |||
60 | static char *label[10] = { | ||
61 | "DMA", | ||
62 | "IRQ-0", | ||
63 | "IRQ-1", | ||
64 | "OCERR", | ||
65 | "PABRT", | ||
66 | "RIPRR", | ||
67 | "PPERR", | ||
68 | "FTRGT", | ||
69 | "RISCI", | ||
70 | "RACK" | ||
71 | }; | ||
72 | |||
73 | static irqreturn_t mantis_irq_handler(int irq, void *dev_id) | ||
74 | { | ||
75 | u32 stat = 0, mask = 0, lstat = 0, mstat = 0; | ||
76 | u32 rst_stat = 0, rst_mask = 0; | ||
77 | |||
78 | struct mantis_pci *mantis; | ||
79 | struct mantis_ca *ca; | ||
80 | |||
81 | mantis = (struct mantis_pci *) dev_id; | ||
82 | if (unlikely(mantis == NULL)) { | ||
83 | dprintk(MANTIS_ERROR, 1, "Mantis == NULL"); | ||
84 | return IRQ_NONE; | ||
85 | } | ||
86 | ca = mantis->mantis_ca; | ||
87 | |||
88 | stat = mmread(MANTIS_INT_STAT); | ||
89 | mask = mmread(MANTIS_INT_MASK); | ||
90 | mstat = lstat = stat & ~MANTIS_INT_RISCSTAT; | ||
91 | if (!(stat & mask)) | ||
92 | return IRQ_NONE; | ||
93 | |||
94 | rst_mask = MANTIS_GPIF_WRACK | | ||
95 | MANTIS_GPIF_OTHERR | | ||
96 | MANTIS_SBUF_WSTO | | ||
97 | MANTIS_GPIF_EXTIRQ; | ||
98 | |||
99 | rst_stat = mmread(MANTIS_GPIF_STATUS); | ||
100 | rst_stat &= rst_mask; | ||
101 | mmwrite(rst_stat, MANTIS_GPIF_STATUS); | ||
102 | |||
103 | mantis->mantis_int_stat = stat; | ||
104 | mantis->mantis_int_mask = mask; | ||
105 | dprintk(MANTIS_DEBUG, 0, "\n-- Stat=<%02x> Mask=<%02x> --", stat, mask); | ||
106 | if (stat & MANTIS_INT_RISCEN) { | ||
107 | dprintk(MANTIS_DEBUG, 0, "<%s>", label[0]); | ||
108 | } | ||
109 | if (stat & MANTIS_INT_IRQ0) { | ||
110 | dprintk(MANTIS_DEBUG, 0, "<%s>", label[1]); | ||
111 | mantis->gpif_status = rst_stat; | ||
112 | wake_up(&ca->hif_write_wq); | ||
113 | schedule_work(&ca->hif_evm_work); | ||
114 | } | ||
115 | if (stat & MANTIS_INT_IRQ1) { | ||
116 | dprintk(MANTIS_DEBUG, 0, "<%s>", label[2]); | ||
117 | schedule_work(&mantis->uart_work); | ||
118 | } | ||
119 | if (stat & MANTIS_INT_OCERR) { | ||
120 | dprintk(MANTIS_DEBUG, 0, "<%s>", label[3]); | ||
121 | } | ||
122 | if (stat & MANTIS_INT_PABORT) { | ||
123 | dprintk(MANTIS_DEBUG, 0, "<%s>", label[4]); | ||
124 | } | ||
125 | if (stat & MANTIS_INT_RIPERR) { | ||
126 | dprintk(MANTIS_DEBUG, 0, "<%s>", label[5]); | ||
127 | } | ||
128 | if (stat & MANTIS_INT_PPERR) { | ||
129 | dprintk(MANTIS_DEBUG, 0, "<%s>", label[6]); | ||
130 | } | ||
131 | if (stat & MANTIS_INT_FTRGT) { | ||
132 | dprintk(MANTIS_DEBUG, 0, "<%s>", label[7]); | ||
133 | } | ||
134 | if (stat & MANTIS_INT_RISCI) { | ||
135 | dprintk(MANTIS_DEBUG, 0, "<%s>", label[8]); | ||
136 | mantis->finished_block = (stat & MANTIS_INT_RISCSTAT) >> 28; | ||
137 | tasklet_schedule(&mantis->tasklet); | ||
138 | } | ||
139 | if (stat & MANTIS_INT_I2CDONE) { | ||
140 | dprintk(MANTIS_DEBUG, 0, "<%s>", label[9]); | ||
141 | wake_up(&mantis->i2c_wq); | ||
142 | } | ||
143 | mmwrite(stat, MANTIS_INT_STAT); | ||
144 | stat &= ~(MANTIS_INT_RISCEN | MANTIS_INT_I2CDONE | | ||
145 | MANTIS_INT_I2CRACK | MANTIS_INT_PCMCIA7 | | ||
146 | MANTIS_INT_PCMCIA6 | MANTIS_INT_PCMCIA5 | | ||
147 | MANTIS_INT_PCMCIA4 | MANTIS_INT_PCMCIA3 | | ||
148 | MANTIS_INT_PCMCIA2 | MANTIS_INT_PCMCIA1 | | ||
149 | MANTIS_INT_PCMCIA0 | MANTIS_INT_IRQ1 | | ||
150 | MANTIS_INT_IRQ0 | MANTIS_INT_OCERR | | ||
151 | MANTIS_INT_PABORT | MANTIS_INT_RIPERR | | ||
152 | MANTIS_INT_PPERR | MANTIS_INT_FTRGT | | ||
153 | MANTIS_INT_RISCI); | ||
154 | |||
155 | if (stat) | ||
156 | dprintk(MANTIS_DEBUG, 0, "<Unknown> Stat=<%02x> Mask=<%02x>", stat, mask); | ||
157 | |||
158 | dprintk(MANTIS_DEBUG, 0, "\n"); | ||
159 | return IRQ_HANDLED; | ||
160 | } | ||
161 | |||
162 | static int __devinit mantis_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) | ||
163 | { | ||
164 | struct mantis_pci *mantis; | ||
165 | struct mantis_hwconfig *config; | ||
166 | int err = 0; | ||
167 | |||
168 | mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL); | ||
169 | if (mantis == NULL) { | ||
170 | printk(KERN_ERR "%s ERROR: Out of memory\n", __func__); | ||
171 | err = -ENOMEM; | ||
172 | goto fail0; | ||
173 | } | ||
174 | |||
175 | mantis->num = devs; | ||
176 | mantis->verbose = verbose; | ||
177 | mantis->pdev = pdev; | ||
178 | config = (struct mantis_hwconfig *) pci_id->driver_data; | ||
179 | config->irq_handler = &mantis_irq_handler; | ||
180 | mantis->hwconfig = config; | ||
181 | |||
182 | err = mantis_pci_init(mantis); | ||
183 | if (err) { | ||
184 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI initialization failed <%d>", err); | ||
185 | goto fail1; | ||
186 | } | ||
187 | |||
188 | err = mantis_stream_control(mantis, STREAM_TO_HIF); | ||
189 | if (err < 0) { | ||
190 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis stream control failed <%d>", err); | ||
191 | goto fail1; | ||
192 | } | ||
193 | |||
194 | err = mantis_i2c_init(mantis); | ||
195 | if (err < 0) { | ||
196 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C initialization failed <%d>", err); | ||
197 | goto fail2; | ||
198 | } | ||
199 | |||
200 | err = mantis_get_mac(mantis); | ||
201 | if (err < 0) { | ||
202 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis MAC address read failed <%d>", err); | ||
203 | goto fail2; | ||
204 | } | ||
205 | |||
206 | err = mantis_dma_init(mantis); | ||
207 | if (err < 0) { | ||
208 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA initialization failed <%d>", err); | ||
209 | goto fail3; | ||
210 | } | ||
211 | |||
212 | err = mantis_dvb_init(mantis); | ||
213 | if (err < 0) { | ||
214 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err); | ||
215 | goto fail4; | ||
216 | } | ||
217 | err = mantis_uart_init(mantis); | ||
218 | if (err < 0) { | ||
219 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART initialization failed <%d>", err); | ||
220 | goto fail6; | ||
221 | } | ||
222 | |||
223 | devs++; | ||
224 | |||
225 | return err; | ||
226 | |||
227 | |||
228 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART exit! <%d>", err); | ||
229 | mantis_uart_exit(mantis); | ||
230 | |||
231 | fail6: | ||
232 | fail4: | ||
233 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA exit! <%d>", err); | ||
234 | mantis_dma_exit(mantis); | ||
235 | |||
236 | fail3: | ||
237 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C exit! <%d>", err); | ||
238 | mantis_i2c_exit(mantis); | ||
239 | |||
240 | fail2: | ||
241 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI exit! <%d>", err); | ||
242 | mantis_pci_exit(mantis); | ||
243 | |||
244 | fail1: | ||
245 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis free! <%d>", err); | ||
246 | kfree(mantis); | ||
247 | |||
248 | fail0: | ||
249 | return err; | ||
250 | } | ||
251 | |||
252 | static void __devexit mantis_pci_remove(struct pci_dev *pdev) | ||
253 | { | ||
254 | struct mantis_pci *mantis = pci_get_drvdata(pdev); | ||
255 | |||
256 | if (mantis) { | ||
257 | |||
258 | mantis_uart_exit(mantis); | ||
259 | mantis_dvb_exit(mantis); | ||
260 | mantis_dma_exit(mantis); | ||
261 | mantis_i2c_exit(mantis); | ||
262 | mantis_pci_exit(mantis); | ||
263 | kfree(mantis); | ||
264 | } | ||
265 | return; | ||
266 | } | ||
267 | |||
268 | static struct pci_device_id mantis_pci_table[] = { | ||
269 | MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1033_DVB_S, &vp1033_config), | ||
270 | MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1034_DVB_S, &vp1034_config), | ||
271 | MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1041_DVB_S2, &vp1041_config), | ||
272 | MAKE_ENTRY(TECHNISAT, SKYSTAR_HD2_10, &vp1041_config), | ||
273 | MAKE_ENTRY(TECHNISAT, SKYSTAR_HD2_20, &vp1041_config), | ||
274 | MAKE_ENTRY(TERRATEC, CINERGY_S2_PCI_HD, &vp1041_config), | ||
275 | MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_2033_DVB_C, &vp2033_config), | ||
276 | MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_2040_DVB_C, &vp2040_config), | ||
277 | MAKE_ENTRY(TECHNISAT, CABLESTAR_HD2, &vp2040_config), | ||
278 | MAKE_ENTRY(TERRATEC, CINERGY_C, &vp2033_config), | ||
279 | MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_3030_DVB_T, &vp3030_config), | ||
280 | { } | ||
281 | }; | ||
282 | |||
283 | static struct pci_driver mantis_pci_driver = { | ||
284 | .name = DRIVER_NAME, | ||
285 | .id_table = mantis_pci_table, | ||
286 | .probe = mantis_pci_probe, | ||
287 | .remove = mantis_pci_remove, | ||
288 | }; | ||
289 | |||
290 | static int __devinit mantis_init(void) | ||
291 | { | ||
292 | return pci_register_driver(&mantis_pci_driver); | ||
293 | } | ||
294 | |||
295 | static void __devexit mantis_exit(void) | ||
296 | { | ||
297 | return pci_unregister_driver(&mantis_pci_driver); | ||
298 | } | ||
299 | |||
300 | module_init(mantis_init); | ||
301 | module_exit(mantis_exit); | ||
302 | |||
303 | MODULE_DESCRIPTION("MANTIS driver"); | ||
304 | MODULE_AUTHOR("Manu Abraham"); | ||
305 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/mantis/mantis_common.h b/drivers/media/dvb/mantis/mantis_common.h new file mode 100644 index 000000000000..d0b645a483c9 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_common.h | |||
@@ -0,0 +1,179 @@ | |||
1 | /* | ||
2 | Mantis 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 | #ifndef __MANTIS_COMMON_H | ||
22 | #define __MANTIS_COMMON_H | ||
23 | |||
24 | #include <linux/mutex.h> | ||
25 | #include <linux/workqueue.h> | ||
26 | |||
27 | #include "mantis_uart.h" | ||
28 | |||
29 | #include "mantis_link.h" | ||
30 | |||
31 | #define MANTIS_ERROR 0 | ||
32 | #define MANTIS_NOTICE 1 | ||
33 | #define MANTIS_INFO 2 | ||
34 | #define MANTIS_DEBUG 3 | ||
35 | #define MANTIS_TMG 9 | ||
36 | |||
37 | #define dprintk(y, z, format, arg...) do { \ | ||
38 | if (z) { \ | ||
39 | if ((mantis->verbose > MANTIS_ERROR) && (mantis->verbose > y)) \ | ||
40 | printk(KERN_ERR "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ | ||
41 | else if ((mantis->verbose > MANTIS_NOTICE) && (mantis->verbose > y)) \ | ||
42 | printk(KERN_NOTICE "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ | ||
43 | else if ((mantis->verbose > MANTIS_INFO) && (mantis->verbose > y)) \ | ||
44 | printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ | ||
45 | else if ((mantis->verbose > MANTIS_DEBUG) && (mantis->verbose > y)) \ | ||
46 | printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ | ||
47 | else if ((mantis->verbose > MANTIS_TMG) && (mantis->verbose > y)) \ | ||
48 | printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ | ||
49 | } else { \ | ||
50 | if (mantis->verbose > y) \ | ||
51 | printk(format , ##arg); \ | ||
52 | } \ | ||
53 | } while(0) | ||
54 | |||
55 | #define mwrite(dat, addr) writel((dat), addr) | ||
56 | #define mread(addr) readl(addr) | ||
57 | |||
58 | #define mmwrite(dat, addr) mwrite((dat), (mantis->mmio + (addr))) | ||
59 | #define mmread(addr) mread(mantis->mmio + (addr)) | ||
60 | |||
61 | #define MANTIS_TS_188 0 | ||
62 | #define MANTIS_TS_204 1 | ||
63 | |||
64 | #define TWINHAN_TECHNOLOGIES 0x1822 | ||
65 | #define MANTIS 0x4e35 | ||
66 | |||
67 | #define TECHNISAT 0x1ae4 | ||
68 | #define TERRATEC 0x153b | ||
69 | |||
70 | #define MAKE_ENTRY(__subven, __subdev, __configptr) { \ | ||
71 | .vendor = TWINHAN_TECHNOLOGIES, \ | ||
72 | .device = MANTIS, \ | ||
73 | .subvendor = (__subven), \ | ||
74 | .subdevice = (__subdev), \ | ||
75 | .driver_data = (unsigned long) (__configptr) \ | ||
76 | } | ||
77 | |||
78 | enum mantis_i2c_mode { | ||
79 | MANTIS_PAGE_MODE = 0, | ||
80 | MANTIS_BYTE_MODE, | ||
81 | }; | ||
82 | |||
83 | struct mantis_pci; | ||
84 | |||
85 | struct mantis_hwconfig { | ||
86 | char *model_name; | ||
87 | char *dev_type; | ||
88 | u32 ts_size; | ||
89 | |||
90 | enum mantis_baud baud_rate; | ||
91 | enum mantis_parity parity; | ||
92 | u32 bytes; | ||
93 | |||
94 | irqreturn_t (*irq_handler)(int irq, void *dev_id); | ||
95 | int (*frontend_init)(struct mantis_pci *mantis, struct dvb_frontend *fe); | ||
96 | |||
97 | u8 power; | ||
98 | u8 reset; | ||
99 | |||
100 | enum mantis_i2c_mode i2c_mode; | ||
101 | }; | ||
102 | |||
103 | struct mantis_pci { | ||
104 | unsigned int verbose; | ||
105 | |||
106 | /* PCI stuff */ | ||
107 | u16 vendor_id; | ||
108 | u16 device_id; | ||
109 | u16 subsystem_vendor; | ||
110 | u16 subsystem_device; | ||
111 | |||
112 | u8 latency; | ||
113 | |||
114 | struct pci_dev *pdev; | ||
115 | |||
116 | unsigned long mantis_addr; | ||
117 | void __iomem *mmio; | ||
118 | |||
119 | u8 irq; | ||
120 | u8 revision; | ||
121 | |||
122 | unsigned int num; | ||
123 | |||
124 | /* RISC Core */ | ||
125 | u32 finished_block; | ||
126 | u32 last_block; | ||
127 | u32 line_bytes; | ||
128 | u32 line_count; | ||
129 | u32 risc_pos; | ||
130 | u8 *buf_cpu; | ||
131 | dma_addr_t buf_dma; | ||
132 | u32 *risc_cpu; | ||
133 | dma_addr_t risc_dma; | ||
134 | |||
135 | struct tasklet_struct tasklet; | ||
136 | |||
137 | struct i2c_adapter adapter; | ||
138 | int i2c_rc; | ||
139 | wait_queue_head_t i2c_wq; | ||
140 | struct mutex i2c_lock; | ||
141 | |||
142 | /* DVB stuff */ | ||
143 | struct dvb_adapter dvb_adapter; | ||
144 | struct dvb_frontend *fe; | ||
145 | struct dvb_demux demux; | ||
146 | struct dmxdev dmxdev; | ||
147 | struct dmx_frontend fe_hw; | ||
148 | struct dmx_frontend fe_mem; | ||
149 | struct dvb_net dvbnet; | ||
150 | |||
151 | u8 feeds; | ||
152 | |||
153 | struct mantis_hwconfig *hwconfig; | ||
154 | |||
155 | u32 mantis_int_stat; | ||
156 | u32 mantis_int_mask; | ||
157 | |||
158 | /* board specific */ | ||
159 | u8 mac_address[8]; | ||
160 | u32 sub_vendor_id; | ||
161 | u32 sub_device_id; | ||
162 | |||
163 | /* A12 A13 A14 */ | ||
164 | u32 gpio_status; | ||
165 | |||
166 | u32 gpif_status; | ||
167 | |||
168 | struct mantis_ca *mantis_ca; | ||
169 | |||
170 | wait_queue_head_t uart_wq; | ||
171 | struct work_struct uart_work; | ||
172 | spinlock_t uart_lock; | ||
173 | |||
174 | struct input_dev *rc; | ||
175 | }; | ||
176 | |||
177 | #define MANTIS_HIF_STATUS (mantis->gpio_status) | ||
178 | |||
179 | #endif /* __MANTIS_COMMON_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_core.c b/drivers/media/dvb/mantis/mantis_core.c new file mode 100644 index 000000000000..8113b23ce448 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_core.c | |||
@@ -0,0 +1,238 @@ | |||
1 | /* | ||
2 | Mantis 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 "mantis_common.h" | ||
22 | #include "mantis_core.h" | ||
23 | #include "mantis_vp1033.h" | ||
24 | #include "mantis_vp1034.h" | ||
25 | #include "mantis_vp1041.h" | ||
26 | #include "mantis_vp2033.h" | ||
27 | #include "mantis_vp2040.h" | ||
28 | #include "mantis_vp3030.h" | ||
29 | |||
30 | static int read_eeprom_byte(struct mantis_pci *mantis, u8 *data, u8 length) | ||
31 | { | ||
32 | int err; | ||
33 | struct i2c_msg msg[] = { | ||
34 | { | ||
35 | .addr = 0x50, | ||
36 | .flags = 0, | ||
37 | .buf = data, | ||
38 | .len = 1 | ||
39 | }, { | ||
40 | .addr = 0x50, | ||
41 | .flags = I2C_M_RD, | ||
42 | .buf = data, | ||
43 | .len = length | ||
44 | }, | ||
45 | }; | ||
46 | |||
47 | err = i2c_transfer(&mantis->adapter, msg, 2); | ||
48 | if (err < 0) { | ||
49 | dprintk(verbose, MANTIS_ERROR, 1, | ||
50 | "ERROR: i2c read: < err=%i d0=0x%02x d1=0x%02x >", | ||
51 | err, data[0], data[1]); | ||
52 | |||
53 | return err; | ||
54 | } | ||
55 | |||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | static int write_eeprom_byte(struct mantis_pci *mantis, u8 *data, u8 length) | ||
60 | { | ||
61 | int err; | ||
62 | |||
63 | struct i2c_msg msg = { | ||
64 | .addr = 0x50, | ||
65 | .flags = 0, | ||
66 | .buf = data, | ||
67 | .len = length | ||
68 | }; | ||
69 | |||
70 | err = i2c_transfer(&mantis->adapter, &msg, 1); | ||
71 | if (err < 0) { | ||
72 | dprintk(verbose, MANTIS_ERROR, 1, | ||
73 | "ERROR: i2c write: < err=%i length=0x%02x d0=0x%02x, d1=0x%02x >", | ||
74 | err, length, data[0], data[1]); | ||
75 | |||
76 | return err; | ||
77 | } | ||
78 | |||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | static int get_mac_address(struct mantis_pci *mantis) | ||
83 | { | ||
84 | int err; | ||
85 | |||
86 | mantis->mac_address[0] = 0x08; | ||
87 | err = read_eeprom_byte(mantis, &mantis->mac_address[0], 6); | ||
88 | if (err < 0) { | ||
89 | dprintk(verbose, MANTIS_ERROR, 1, "Mantis EEPROM read error"); | ||
90 | |||
91 | return err; | ||
92 | } | ||
93 | dprintk(verbose, MANTIS_ERROR, 0, | ||
94 | " MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]\n", | ||
95 | mantis->mac_address[0], mantis->mac_address[1], | ||
96 | mantis->mac_address[2], mantis->mac_address[3], | ||
97 | mantis->mac_address[4], mantis->mac_address[5]); | ||
98 | |||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | #define MANTIS_MODEL_UNKNOWN "UNKNOWN" | ||
103 | #define MANTIS_DEV_UNKNOWN "UNKNOWN" | ||
104 | |||
105 | struct mantis_hwconfig unknown_device = { | ||
106 | .model_name = MANTIS_MODEL_UNKNOWN, | ||
107 | .dev_type = MANTIS_DEV_UNKNOWN, | ||
108 | }; | ||
109 | |||
110 | static void mantis_load_config(struct mantis_pci *mantis) | ||
111 | { | ||
112 | switch (mantis->subsystem_device) { | ||
113 | case MANTIS_VP_1033_DVB_S: /* VP-1033 */ | ||
114 | mantis->hwconfig = &vp1033_mantis_config; | ||
115 | break; | ||
116 | case MANTIS_VP_1034_DVB_S: /* VP-1034 */ | ||
117 | mantis->hwconfig = &vp1034_mantis_config; | ||
118 | break; | ||
119 | case MANTIS_VP_1041_DVB_S2: /* VP-1041 */ | ||
120 | case TECHNISAT_SKYSTAR_HD2: | ||
121 | mantis->hwconfig = &vp1041_mantis_config; | ||
122 | break; | ||
123 | case MANTIS_VP_2033_DVB_C: /* VP-2033 */ | ||
124 | mantis->hwconfig = &vp2033_mantis_config; | ||
125 | break; | ||
126 | case MANTIS_VP_2040_DVB_C: /* VP-2040 */ | ||
127 | case TERRATEC_CINERGY_C_PCI: /* VP-2040 clone */ | ||
128 | case TECHNISAT_CABLESTAR_HD2: | ||
129 | mantis->hwconfig = &vp2040_mantis_config; | ||
130 | break; | ||
131 | case MANTIS_VP_3030_DVB_T: /* VP-3030 */ | ||
132 | mantis->hwconfig = &vp3030_mantis_config; | ||
133 | break; | ||
134 | default: | ||
135 | mantis->hwconfig = &unknown_device; | ||
136 | break; | ||
137 | } | ||
138 | } | ||
139 | |||
140 | int mantis_core_init(struct mantis_pci *mantis) | ||
141 | { | ||
142 | int err = 0; | ||
143 | |||
144 | mantis_load_config(mantis); | ||
145 | dprintk(verbose, MANTIS_ERROR, 0, "found a %s PCI %s device on (%02x:%02x.%x),\n", | ||
146 | mantis->hwconfig->model_name, mantis->hwconfig->dev_type, | ||
147 | mantis->pdev->bus->number, PCI_SLOT(mantis->pdev->devfn), PCI_FUNC(mantis->pdev->devfn)); | ||
148 | dprintk(verbose, MANTIS_ERROR, 0, " Mantis Rev %d [%04x:%04x], ", | ||
149 | mantis->revision, | ||
150 | mantis->subsystem_vendor, mantis->subsystem_device); | ||
151 | dprintk(verbose, MANTIS_ERROR, 0, | ||
152 | "irq: %d, latency: %d\n memory: 0x%lx, mmio: 0x%p\n", | ||
153 | mantis->pdev->irq, mantis->latency, | ||
154 | mantis->mantis_addr, mantis->mantis_mmio); | ||
155 | |||
156 | err = mantis_i2c_init(mantis); | ||
157 | if (err < 0) { | ||
158 | dprintk(verbose, MANTIS_ERROR, 1, "Mantis I2C init failed"); | ||
159 | return err; | ||
160 | } | ||
161 | err = get_mac_address(mantis); | ||
162 | if (err < 0) { | ||
163 | dprintk(verbose, MANTIS_ERROR, 1, "get MAC address failed"); | ||
164 | return err; | ||
165 | } | ||
166 | err = mantis_dma_init(mantis); | ||
167 | if (err < 0) { | ||
168 | dprintk(verbose, MANTIS_ERROR, 1, "Mantis DMA init failed"); | ||
169 | return err; | ||
170 | } | ||
171 | err = mantis_dvb_init(mantis); | ||
172 | if (err < 0) { | ||
173 | dprintk(verbose, MANTIS_DEBUG, 1, "Mantis DVB init failed"); | ||
174 | return err; | ||
175 | } | ||
176 | err = mantis_uart_init(mantis); | ||
177 | if (err < 0) { | ||
178 | dprintk(verbose, MANTIS_DEBUG, 1, "Mantis UART init failed"); | ||
179 | return err; | ||
180 | } | ||
181 | |||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | int mantis_core_exit(struct mantis_pci *mantis) | ||
186 | { | ||
187 | mantis_dma_stop(mantis); | ||
188 | dprintk(verbose, MANTIS_ERROR, 1, "DMA engine stopping"); | ||
189 | |||
190 | mantis_uart_exit(mantis); | ||
191 | dprintk(verbose, MANTIS_ERROR, 1, "UART exit failed"); | ||
192 | |||
193 | if (mantis_dma_exit(mantis) < 0) | ||
194 | dprintk(verbose, MANTIS_ERROR, 1, "DMA exit failed"); | ||
195 | if (mantis_dvb_exit(mantis) < 0) | ||
196 | dprintk(verbose, MANTIS_ERROR, 1, "DVB exit failed"); | ||
197 | if (mantis_i2c_exit(mantis) < 0) | ||
198 | dprintk(verbose, MANTIS_ERROR, 1, "I2C adapter delete.. failed"); | ||
199 | |||
200 | return 0; | ||
201 | } | ||
202 | |||
203 | /* Turn the given bit on or off. */ | ||
204 | void gpio_set_bits(struct mantis_pci *mantis, u32 bitpos, u8 value) | ||
205 | { | ||
206 | u32 cur; | ||
207 | |||
208 | cur = mmread(MANTIS_GPIF_ADDR); | ||
209 | if (value) | ||
210 | mantis->gpio_status = cur | (1 << bitpos); | ||
211 | else | ||
212 | mantis->gpio_status = cur & (~(1 << bitpos)); | ||
213 | |||
214 | mmwrite(mantis->gpio_status, MANTIS_GPIF_ADDR); | ||
215 | mmwrite(0x00, MANTIS_GPIF_DOUT); | ||
216 | udelay(100); | ||
217 | } | ||
218 | |||
219 | /* direction = 0 , no CI passthrough ; 1 , CI passthrough */ | ||
220 | void mantis_set_direction(struct mantis_pci *mantis, int direction) | ||
221 | { | ||
222 | u32 reg; | ||
223 | |||
224 | reg = mmread(0x28); | ||
225 | dprintk(verbose, MANTIS_DEBUG, 1, "TS direction setup"); | ||
226 | if (direction == 0x01) { | ||
227 | /* to CI */ | ||
228 | reg |= 0x04; | ||
229 | mmwrite(reg, 0x28); | ||
230 | reg &= 0xff - 0x04; | ||
231 | mmwrite(reg, 0x28); | ||
232 | } else { | ||
233 | reg &= 0xff - 0x04; | ||
234 | mmwrite(reg, 0x28); | ||
235 | reg |= 0x04; | ||
236 | mmwrite(reg, 0x28); | ||
237 | } | ||
238 | } | ||
diff --git a/drivers/media/dvb/mantis/mantis_core.h b/drivers/media/dvb/mantis/mantis_core.h new file mode 100644 index 000000000000..833ee42e694e --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_core.h | |||
@@ -0,0 +1,57 @@ | |||
1 | /* | ||
2 | Mantis 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 | #ifndef __MANTIS_CORE_H | ||
22 | #define __MANTIS_CORE_H | ||
23 | |||
24 | #include "mantis_common.h" | ||
25 | |||
26 | |||
27 | #define FE_TYPE_SAT 0 | ||
28 | #define FE_TYPE_CAB 1 | ||
29 | #define FE_TYPE_TER 2 | ||
30 | |||
31 | #define FE_TYPE_TS204 0 | ||
32 | #define FE_TYPE_TS188 1 | ||
33 | |||
34 | |||
35 | struct vendorname { | ||
36 | u8 *sub_vendor_name; | ||
37 | u32 sub_vendor_id; | ||
38 | }; | ||
39 | |||
40 | struct devicetype { | ||
41 | u8 *sub_device_name; | ||
42 | u32 sub_device_id; | ||
43 | u8 device_type; | ||
44 | u32 type_flags; | ||
45 | }; | ||
46 | |||
47 | |||
48 | extern int mantis_dma_init(struct mantis_pci *mantis); | ||
49 | extern int mantis_dma_exit(struct mantis_pci *mantis); | ||
50 | extern void mantis_dma_start(struct mantis_pci *mantis); | ||
51 | extern void mantis_dma_stop(struct mantis_pci *mantis); | ||
52 | extern int mantis_i2c_init(struct mantis_pci *mantis); | ||
53 | extern int mantis_i2c_exit(struct mantis_pci *mantis); | ||
54 | extern int mantis_core_init(struct mantis_pci *mantis); | ||
55 | extern int mantis_core_exit(struct mantis_pci *mantis); | ||
56 | |||
57 | #endif /* __MANTIS_CORE_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_dma.c b/drivers/media/dvb/mantis/mantis_dma.c new file mode 100644 index 000000000000..46202a4012aa --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_dma.c | |||
@@ -0,0 +1,256 @@ | |||
1 | /* | ||
2 | Mantis 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/kernel.h> | ||
22 | #include <asm/page.h> | ||
23 | #include <linux/vmalloc.h> | ||
24 | #include <linux/pci.h> | ||
25 | |||
26 | #include <asm/irq.h> | ||
27 | #include <linux/signal.h> | ||
28 | #include <linux/sched.h> | ||
29 | #include <linux/interrupt.h> | ||
30 | |||
31 | #include "dmxdev.h" | ||
32 | #include "dvbdev.h" | ||
33 | #include "dvb_demux.h" | ||
34 | #include "dvb_frontend.h" | ||
35 | #include "dvb_net.h" | ||
36 | |||
37 | #include "mantis_common.h" | ||
38 | #include "mantis_reg.h" | ||
39 | #include "mantis_dma.h" | ||
40 | |||
41 | #define RISC_WRITE (0x01 << 28) | ||
42 | #define RISC_JUMP (0x07 << 28) | ||
43 | #define RISC_IRQ (0x01 << 24) | ||
44 | |||
45 | #define RISC_STATUS(status) ((((~status) & 0x0f) << 20) | ((status & 0x0f) << 16)) | ||
46 | #define RISC_FLUSH() (mantis->risc_pos = 0) | ||
47 | #define RISC_INSTR(opcode) (mantis->risc_cpu[mantis->risc_pos++] = cpu_to_le32(opcode)) | ||
48 | |||
49 | #define MANTIS_BUF_SIZE (64 * 1024) | ||
50 | #define MANTIS_BLOCK_BYTES (MANTIS_BUF_SIZE >> 4) | ||
51 | #define MANTIS_BLOCK_COUNT (1 << 4) | ||
52 | #define MANTIS_RISC_SIZE PAGE_SIZE | ||
53 | |||
54 | int mantis_dma_exit(struct mantis_pci *mantis) | ||
55 | { | ||
56 | if (mantis->buf_cpu) { | ||
57 | dprintk(MANTIS_ERROR, 1, | ||
58 | "DMA=0x%lx cpu=0x%p size=%d", | ||
59 | (unsigned long) mantis->buf_dma, | ||
60 | mantis->buf_cpu, | ||
61 | MANTIS_BUF_SIZE); | ||
62 | |||
63 | pci_free_consistent(mantis->pdev, MANTIS_BUF_SIZE, | ||
64 | mantis->buf_cpu, mantis->buf_dma); | ||
65 | |||
66 | mantis->buf_cpu = NULL; | ||
67 | } | ||
68 | if (mantis->risc_cpu) { | ||
69 | dprintk(MANTIS_ERROR, 1, | ||
70 | "RISC=0x%lx cpu=0x%p size=%lx", | ||
71 | (unsigned long) mantis->risc_dma, | ||
72 | mantis->risc_cpu, | ||
73 | MANTIS_RISC_SIZE); | ||
74 | |||
75 | pci_free_consistent(mantis->pdev, MANTIS_RISC_SIZE, | ||
76 | mantis->risc_cpu, mantis->risc_dma); | ||
77 | |||
78 | mantis->risc_cpu = NULL; | ||
79 | } | ||
80 | |||
81 | return 0; | ||
82 | } | ||
83 | EXPORT_SYMBOL_GPL(mantis_dma_exit); | ||
84 | |||
85 | static inline int mantis_alloc_buffers(struct mantis_pci *mantis) | ||
86 | { | ||
87 | if (!mantis->buf_cpu) { | ||
88 | mantis->buf_cpu = pci_alloc_consistent(mantis->pdev, | ||
89 | MANTIS_BUF_SIZE, | ||
90 | &mantis->buf_dma); | ||
91 | if (!mantis->buf_cpu) { | ||
92 | dprintk(MANTIS_ERROR, 1, | ||
93 | "DMA buffer allocation failed"); | ||
94 | |||
95 | goto err; | ||
96 | } | ||
97 | dprintk(MANTIS_ERROR, 1, | ||
98 | "DMA=0x%lx cpu=0x%p size=%d", | ||
99 | (unsigned long) mantis->buf_dma, | ||
100 | mantis->buf_cpu, MANTIS_BUF_SIZE); | ||
101 | } | ||
102 | if (!mantis->risc_cpu) { | ||
103 | mantis->risc_cpu = pci_alloc_consistent(mantis->pdev, | ||
104 | MANTIS_RISC_SIZE, | ||
105 | &mantis->risc_dma); | ||
106 | |||
107 | if (!mantis->risc_cpu) { | ||
108 | dprintk(MANTIS_ERROR, 1, | ||
109 | "RISC program allocation failed"); | ||
110 | |||
111 | mantis_dma_exit(mantis); | ||
112 | |||
113 | goto err; | ||
114 | } | ||
115 | dprintk(MANTIS_ERROR, 1, | ||
116 | "RISC=0x%lx cpu=0x%p size=%lx", | ||
117 | (unsigned long) mantis->risc_dma, | ||
118 | mantis->risc_cpu, MANTIS_RISC_SIZE); | ||
119 | } | ||
120 | |||
121 | return 0; | ||
122 | err: | ||
123 | dprintk(MANTIS_ERROR, 1, "Out of memory (?) ....."); | ||
124 | return -ENOMEM; | ||
125 | } | ||
126 | |||
127 | static inline int mantis_calc_lines(struct mantis_pci *mantis) | ||
128 | { | ||
129 | mantis->line_bytes = MANTIS_BLOCK_BYTES; | ||
130 | mantis->line_count = MANTIS_BLOCK_COUNT; | ||
131 | |||
132 | while (mantis->line_bytes > 4095) { | ||
133 | mantis->line_bytes >>= 1; | ||
134 | mantis->line_count <<= 1; | ||
135 | } | ||
136 | |||
137 | dprintk(MANTIS_DEBUG, 1, "Mantis RISC block bytes=[%d], line bytes=[%d], line count=[%d]", | ||
138 | MANTIS_BLOCK_BYTES, mantis->line_bytes, mantis->line_count); | ||
139 | |||
140 | if (mantis->line_count > 255) { | ||
141 | dprintk(MANTIS_ERROR, 1, "Buffer size error"); | ||
142 | return -EINVAL; | ||
143 | } | ||
144 | |||
145 | return 0; | ||
146 | } | ||
147 | |||
148 | int mantis_dma_init(struct mantis_pci *mantis) | ||
149 | { | ||
150 | int err = 0; | ||
151 | |||
152 | dprintk(MANTIS_DEBUG, 1, "Mantis DMA init"); | ||
153 | if (mantis_alloc_buffers(mantis) < 0) { | ||
154 | dprintk(MANTIS_ERROR, 1, "Error allocating DMA buffer"); | ||
155 | |||
156 | /* Stop RISC Engine */ | ||
157 | mmwrite(0, MANTIS_DMA_CTL); | ||
158 | |||
159 | goto err; | ||
160 | } | ||
161 | err = mantis_calc_lines(mantis); | ||
162 | if (err < 0) { | ||
163 | dprintk(MANTIS_ERROR, 1, "Mantis calc lines failed"); | ||
164 | |||
165 | goto err; | ||
166 | } | ||
167 | |||
168 | return 0; | ||
169 | err: | ||
170 | return err; | ||
171 | } | ||
172 | EXPORT_SYMBOL_GPL(mantis_dma_init); | ||
173 | |||
174 | static inline void mantis_risc_program(struct mantis_pci *mantis) | ||
175 | { | ||
176 | u32 buf_pos = 0; | ||
177 | u32 line; | ||
178 | |||
179 | dprintk(MANTIS_DEBUG, 1, "Mantis create RISC program"); | ||
180 | RISC_FLUSH(); | ||
181 | |||
182 | dprintk(MANTIS_DEBUG, 1, "risc len lines %u, bytes per line %u", | ||
183 | mantis->line_count, mantis->line_bytes); | ||
184 | |||
185 | for (line = 0; line < mantis->line_count; line++) { | ||
186 | dprintk(MANTIS_DEBUG, 1, "RISC PROG line=[%d]", line); | ||
187 | if (!(buf_pos % MANTIS_BLOCK_BYTES)) { | ||
188 | RISC_INSTR(RISC_WRITE | | ||
189 | RISC_IRQ | | ||
190 | RISC_STATUS(((buf_pos / MANTIS_BLOCK_BYTES) + | ||
191 | (MANTIS_BLOCK_COUNT - 1)) % | ||
192 | MANTIS_BLOCK_COUNT) | | ||
193 | mantis->line_bytes); | ||
194 | } else { | ||
195 | RISC_INSTR(RISC_WRITE | mantis->line_bytes); | ||
196 | } | ||
197 | RISC_INSTR(mantis->buf_dma + buf_pos); | ||
198 | buf_pos += mantis->line_bytes; | ||
199 | } | ||
200 | RISC_INSTR(RISC_JUMP); | ||
201 | RISC_INSTR(mantis->risc_dma); | ||
202 | } | ||
203 | |||
204 | void mantis_dma_start(struct mantis_pci *mantis) | ||
205 | { | ||
206 | dprintk(MANTIS_DEBUG, 1, "Mantis Start DMA engine"); | ||
207 | |||
208 | mantis_risc_program(mantis); | ||
209 | mmwrite(mantis->risc_dma, MANTIS_RISC_START); | ||
210 | mmwrite(mmread(MANTIS_GPIF_ADDR) | MANTIS_GPIF_HIFRDWRN, MANTIS_GPIF_ADDR); | ||
211 | |||
212 | mmwrite(0, MANTIS_DMA_CTL); | ||
213 | mantis->last_block = mantis->finished_block = 0; | ||
214 | |||
215 | mmwrite(mmread(MANTIS_INT_MASK) | MANTIS_INT_RISCI, MANTIS_INT_MASK); | ||
216 | |||
217 | mmwrite(MANTIS_FIFO_EN | MANTIS_DCAP_EN | ||
218 | | MANTIS_RISC_EN, MANTIS_DMA_CTL); | ||
219 | |||
220 | } | ||
221 | |||
222 | void mantis_dma_stop(struct mantis_pci *mantis) | ||
223 | { | ||
224 | u32 stat = 0, mask = 0; | ||
225 | |||
226 | stat = mmread(MANTIS_INT_STAT); | ||
227 | mask = mmread(MANTIS_INT_MASK); | ||
228 | dprintk(MANTIS_DEBUG, 1, "Mantis Stop DMA engine"); | ||
229 | |||
230 | mmwrite((mmread(MANTIS_GPIF_ADDR) & (~(MANTIS_GPIF_HIFRDWRN))), MANTIS_GPIF_ADDR); | ||
231 | |||
232 | mmwrite((mmread(MANTIS_DMA_CTL) & ~(MANTIS_FIFO_EN | | ||
233 | MANTIS_DCAP_EN | | ||
234 | MANTIS_RISC_EN)), MANTIS_DMA_CTL); | ||
235 | |||
236 | mmwrite(mmread(MANTIS_INT_STAT), MANTIS_INT_STAT); | ||
237 | |||
238 | mmwrite(mmread(MANTIS_INT_MASK) & ~(MANTIS_INT_RISCI | | ||
239 | MANTIS_INT_RISCEN), MANTIS_INT_MASK); | ||
240 | } | ||
241 | |||
242 | |||
243 | void mantis_dma_xfer(unsigned long data) | ||
244 | { | ||
245 | struct mantis_pci *mantis = (struct mantis_pci *) data; | ||
246 | struct mantis_hwconfig *config = mantis->hwconfig; | ||
247 | |||
248 | while (mantis->last_block != mantis->finished_block) { | ||
249 | dprintk(MANTIS_DEBUG, 1, "last block=[%d] finished block=[%d]", | ||
250 | mantis->last_block, mantis->finished_block); | ||
251 | |||
252 | (config->ts_size ? dvb_dmx_swfilter_204 : dvb_dmx_swfilter) | ||
253 | (&mantis->demux, &mantis->buf_cpu[mantis->last_block * MANTIS_BLOCK_BYTES], MANTIS_BLOCK_BYTES); | ||
254 | mantis->last_block = (mantis->last_block + 1) % MANTIS_BLOCK_COUNT; | ||
255 | } | ||
256 | } | ||
diff --git a/drivers/media/dvb/mantis/mantis_dma.h b/drivers/media/dvb/mantis/mantis_dma.h new file mode 100644 index 000000000000..6be00fa82094 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_dma.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | Mantis 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 | #ifndef __MANTIS_DMA_H | ||
22 | #define __MANTIS_DMA_H | ||
23 | |||
24 | extern int mantis_dma_init(struct mantis_pci *mantis); | ||
25 | extern int mantis_dma_exit(struct mantis_pci *mantis); | ||
26 | extern void mantis_dma_start(struct mantis_pci *mantis); | ||
27 | extern void mantis_dma_stop(struct mantis_pci *mantis); | ||
28 | extern void mantis_dma_xfer(unsigned long data); | ||
29 | |||
30 | #endif /* __MANTIS_DMA_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_dvb.c b/drivers/media/dvb/mantis/mantis_dvb.c new file mode 100644 index 000000000000..99d82eec3b03 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_dvb.c | |||
@@ -0,0 +1,296 @@ | |||
1 | /* | ||
2 | Mantis PCI bridge driver | ||
3 | Copyright (C) Manu Abraham (abraham.manu@gmail.com) | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
18 | */ | ||
19 | |||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/bitops.h> | ||
22 | |||
23 | #include <linux/signal.h> | ||
24 | #include <linux/sched.h> | ||
25 | #include <linux/interrupt.h> | ||
26 | #include <linux/pci.h> | ||
27 | #include <linux/i2c.h> | ||
28 | |||
29 | #include "dmxdev.h" | ||
30 | #include "dvbdev.h" | ||
31 | #include "dvb_demux.h" | ||
32 | #include "dvb_frontend.h" | ||
33 | #include "dvb_net.h" | ||
34 | |||
35 | #include "mantis_common.h" | ||
36 | #include "mantis_dma.h" | ||
37 | #include "mantis_ca.h" | ||
38 | #include "mantis_ioc.h" | ||
39 | #include "mantis_dvb.h" | ||
40 | |||
41 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
42 | |||
43 | int mantis_frontend_power(struct mantis_pci *mantis, enum mantis_power power) | ||
44 | { | ||
45 | struct mantis_hwconfig *config = mantis->hwconfig; | ||
46 | |||
47 | switch (power) { | ||
48 | case POWER_ON: | ||
49 | dprintk(MANTIS_DEBUG, 1, "Power ON"); | ||
50 | gpio_set_bits(mantis, config->power, POWER_ON); | ||
51 | msleep(100); | ||
52 | gpio_set_bits(mantis, config->power, POWER_ON); | ||
53 | msleep(100); | ||
54 | break; | ||
55 | |||
56 | case POWER_OFF: | ||
57 | dprintk(MANTIS_DEBUG, 1, "Power OFF"); | ||
58 | gpio_set_bits(mantis, config->power, POWER_OFF); | ||
59 | msleep(100); | ||
60 | break; | ||
61 | |||
62 | default: | ||
63 | dprintk(MANTIS_DEBUG, 1, "Unknown state <%02x>", power); | ||
64 | return -1; | ||
65 | } | ||
66 | |||
67 | return 0; | ||
68 | } | ||
69 | EXPORT_SYMBOL_GPL(mantis_frontend_power); | ||
70 | |||
71 | void mantis_frontend_soft_reset(struct mantis_pci *mantis) | ||
72 | { | ||
73 | struct mantis_hwconfig *config = mantis->hwconfig; | ||
74 | |||
75 | dprintk(MANTIS_DEBUG, 1, "Frontend RESET"); | ||
76 | gpio_set_bits(mantis, config->reset, 0); | ||
77 | msleep(100); | ||
78 | gpio_set_bits(mantis, config->reset, 0); | ||
79 | msleep(100); | ||
80 | gpio_set_bits(mantis, config->reset, 1); | ||
81 | msleep(100); | ||
82 | gpio_set_bits(mantis, config->reset, 1); | ||
83 | msleep(100); | ||
84 | |||
85 | return; | ||
86 | } | ||
87 | EXPORT_SYMBOL_GPL(mantis_frontend_soft_reset); | ||
88 | |||
89 | static int mantis_frontend_shutdown(struct mantis_pci *mantis) | ||
90 | { | ||
91 | int err; | ||
92 | |||
93 | mantis_frontend_soft_reset(mantis); | ||
94 | err = mantis_frontend_power(mantis, POWER_OFF); | ||
95 | if (err != 0) { | ||
96 | dprintk(MANTIS_ERROR, 1, "Frontend POWER OFF failed! <%d>", err); | ||
97 | return 1; | ||
98 | } | ||
99 | |||
100 | return 0; | ||
101 | } | ||
102 | |||
103 | static int mantis_dvb_start_feed(struct dvb_demux_feed *dvbdmxfeed) | ||
104 | { | ||
105 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; | ||
106 | struct mantis_pci *mantis = dvbdmx->priv; | ||
107 | |||
108 | dprintk(MANTIS_DEBUG, 1, "Mantis DVB Start feed"); | ||
109 | if (!dvbdmx->dmx.frontend) { | ||
110 | dprintk(MANTIS_DEBUG, 1, "no frontend ?"); | ||
111 | return -EINVAL; | ||
112 | } | ||
113 | |||
114 | mantis->feeds++; | ||
115 | dprintk(MANTIS_DEBUG, 1, "mantis start feed, feeds=%d", mantis->feeds); | ||
116 | |||
117 | if (mantis->feeds == 1) { | ||
118 | dprintk(MANTIS_DEBUG, 1, "mantis start feed & dma"); | ||
119 | mantis_dma_start(mantis); | ||
120 | } | ||
121 | |||
122 | return mantis->feeds; | ||
123 | } | ||
124 | |||
125 | static int mantis_dvb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) | ||
126 | { | ||
127 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; | ||
128 | struct mantis_pci *mantis = dvbdmx->priv; | ||
129 | |||
130 | dprintk(MANTIS_DEBUG, 1, "Mantis DVB Stop feed"); | ||
131 | if (!dvbdmx->dmx.frontend) { | ||
132 | dprintk(MANTIS_DEBUG, 1, "no frontend ?"); | ||
133 | return -EINVAL; | ||
134 | } | ||
135 | |||
136 | mantis->feeds--; | ||
137 | if (mantis->feeds == 0) { | ||
138 | dprintk(MANTIS_DEBUG, 1, "mantis stop feed and dma"); | ||
139 | mantis_dma_stop(mantis); | ||
140 | } | ||
141 | |||
142 | return 0; | ||
143 | } | ||
144 | |||
145 | int __devinit mantis_dvb_init(struct mantis_pci *mantis) | ||
146 | { | ||
147 | struct mantis_hwconfig *config = mantis->hwconfig; | ||
148 | int result = -1; | ||
149 | |||
150 | dprintk(MANTIS_DEBUG, 1, "dvb_register_adapter"); | ||
151 | |||
152 | result = dvb_register_adapter(&mantis->dvb_adapter, | ||
153 | "Mantis DVB adapter", | ||
154 | THIS_MODULE, | ||
155 | &mantis->pdev->dev, | ||
156 | adapter_nr); | ||
157 | |||
158 | if (result < 0) { | ||
159 | |||
160 | dprintk(MANTIS_ERROR, 1, "Error registering adapter"); | ||
161 | return -ENODEV; | ||
162 | } | ||
163 | |||
164 | mantis->dvb_adapter.priv = mantis; | ||
165 | mantis->demux.dmx.capabilities = DMX_TS_FILTERING | | ||
166 | DMX_SECTION_FILTERING | | ||
167 | DMX_MEMORY_BASED_FILTERING; | ||
168 | |||
169 | mantis->demux.priv = mantis; | ||
170 | mantis->demux.filternum = 256; | ||
171 | mantis->demux.feednum = 256; | ||
172 | mantis->demux.start_feed = mantis_dvb_start_feed; | ||
173 | mantis->demux.stop_feed = mantis_dvb_stop_feed; | ||
174 | mantis->demux.write_to_decoder = NULL; | ||
175 | |||
176 | dprintk(MANTIS_DEBUG, 1, "dvb_dmx_init"); | ||
177 | result = dvb_dmx_init(&mantis->demux); | ||
178 | if (result < 0) { | ||
179 | dprintk(MANTIS_ERROR, 1, "dvb_dmx_init failed, ERROR=%d", result); | ||
180 | |||
181 | goto err0; | ||
182 | } | ||
183 | |||
184 | mantis->dmxdev.filternum = 256; | ||
185 | mantis->dmxdev.demux = &mantis->demux.dmx; | ||
186 | mantis->dmxdev.capabilities = 0; | ||
187 | dprintk(MANTIS_DEBUG, 1, "dvb_dmxdev_init"); | ||
188 | |||
189 | result = dvb_dmxdev_init(&mantis->dmxdev, &mantis->dvb_adapter); | ||
190 | if (result < 0) { | ||
191 | |||
192 | dprintk(MANTIS_ERROR, 1, "dvb_dmxdev_init failed, ERROR=%d", result); | ||
193 | goto err1; | ||
194 | } | ||
195 | |||
196 | mantis->fe_hw.source = DMX_FRONTEND_0; | ||
197 | result = mantis->demux.dmx.add_frontend(&mantis->demux.dmx, &mantis->fe_hw); | ||
198 | if (result < 0) { | ||
199 | |||
200 | dprintk(MANTIS_ERROR, 1, "dvb_dmx_init failed, ERROR=%d", result); | ||
201 | goto err2; | ||
202 | } | ||
203 | |||
204 | mantis->fe_mem.source = DMX_MEMORY_FE; | ||
205 | result = mantis->demux.dmx.add_frontend(&mantis->demux.dmx, &mantis->fe_mem); | ||
206 | if (result < 0) { | ||
207 | dprintk(MANTIS_ERROR, 1, "dvb_dmx_init failed, ERROR=%d", result); | ||
208 | goto err3; | ||
209 | } | ||
210 | |||
211 | result = mantis->demux.dmx.connect_frontend(&mantis->demux.dmx, &mantis->fe_hw); | ||
212 | if (result < 0) { | ||
213 | dprintk(MANTIS_ERROR, 1, "dvb_dmx_init failed, ERROR=%d", result); | ||
214 | goto err4; | ||
215 | } | ||
216 | |||
217 | dvb_net_init(&mantis->dvb_adapter, &mantis->dvbnet, &mantis->demux.dmx); | ||
218 | tasklet_init(&mantis->tasklet, mantis_dma_xfer, (unsigned long) mantis); | ||
219 | if (mantis->hwconfig) { | ||
220 | result = config->frontend_init(mantis, mantis->fe); | ||
221 | if (result < 0) { | ||
222 | dprintk(MANTIS_ERROR, 1, "!!! NO Frontends found !!!"); | ||
223 | goto err5; | ||
224 | } else { | ||
225 | if (mantis->fe == NULL) { | ||
226 | dprintk(MANTIS_ERROR, 1, "FE <NULL>"); | ||
227 | goto err5; | ||
228 | } | ||
229 | |||
230 | if (dvb_register_frontend(&mantis->dvb_adapter, mantis->fe)) { | ||
231 | dprintk(MANTIS_ERROR, 1, "ERROR: Frontend registration failed"); | ||
232 | |||
233 | if (mantis->fe->ops.release) | ||
234 | mantis->fe->ops.release(mantis->fe); | ||
235 | |||
236 | mantis->fe = NULL; | ||
237 | goto err5; | ||
238 | } | ||
239 | } | ||
240 | } | ||
241 | |||
242 | return 0; | ||
243 | |||
244 | /* Error conditions .. */ | ||
245 | err5: | ||
246 | tasklet_kill(&mantis->tasklet); | ||
247 | dvb_net_release(&mantis->dvbnet); | ||
248 | dvb_unregister_frontend(mantis->fe); | ||
249 | dvb_frontend_detach(mantis->fe); | ||
250 | err4: | ||
251 | mantis->demux.dmx.remove_frontend(&mantis->demux.dmx, &mantis->fe_mem); | ||
252 | |||
253 | err3: | ||
254 | mantis->demux.dmx.remove_frontend(&mantis->demux.dmx, &mantis->fe_hw); | ||
255 | |||
256 | err2: | ||
257 | dvb_dmxdev_release(&mantis->dmxdev); | ||
258 | |||
259 | err1: | ||
260 | dvb_dmx_release(&mantis->demux); | ||
261 | |||
262 | err0: | ||
263 | dvb_unregister_adapter(&mantis->dvb_adapter); | ||
264 | |||
265 | return result; | ||
266 | } | ||
267 | EXPORT_SYMBOL_GPL(mantis_dvb_init); | ||
268 | |||
269 | int __devexit mantis_dvb_exit(struct mantis_pci *mantis) | ||
270 | { | ||
271 | int err; | ||
272 | |||
273 | if (mantis->fe) { | ||
274 | /* mantis_ca_exit(mantis); */ | ||
275 | err = mantis_frontend_shutdown(mantis); | ||
276 | if (err != 0) | ||
277 | dprintk(MANTIS_ERROR, 1, "Frontend exit while POWER ON! <%d>", err); | ||
278 | dvb_unregister_frontend(mantis->fe); | ||
279 | dvb_frontend_detach(mantis->fe); | ||
280 | } | ||
281 | |||
282 | tasklet_kill(&mantis->tasklet); | ||
283 | dvb_net_release(&mantis->dvbnet); | ||
284 | |||
285 | mantis->demux.dmx.remove_frontend(&mantis->demux.dmx, &mantis->fe_mem); | ||
286 | mantis->demux.dmx.remove_frontend(&mantis->demux.dmx, &mantis->fe_hw); | ||
287 | |||
288 | dvb_dmxdev_release(&mantis->dmxdev); | ||
289 | dvb_dmx_release(&mantis->demux); | ||
290 | |||
291 | dprintk(MANTIS_DEBUG, 1, "dvb_unregister_adapter"); | ||
292 | dvb_unregister_adapter(&mantis->dvb_adapter); | ||
293 | |||
294 | return 0; | ||
295 | } | ||
296 | EXPORT_SYMBOL_GPL(mantis_dvb_exit); | ||
diff --git a/drivers/media/dvb/mantis/mantis_dvb.h b/drivers/media/dvb/mantis/mantis_dvb.h new file mode 100644 index 000000000000..464199db304e --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_dvb.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | Mantis 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 | #ifndef __MANTIS_DVB_H | ||
22 | #define __MANTIS_DVB_H | ||
23 | |||
24 | enum mantis_power { | ||
25 | POWER_OFF = 0, | ||
26 | POWER_ON = 1 | ||
27 | }; | ||
28 | |||
29 | extern int mantis_frontend_power(struct mantis_pci *mantis, enum mantis_power power); | ||
30 | extern void mantis_frontend_soft_reset(struct mantis_pci *mantis); | ||
31 | |||
32 | extern int mantis_dvb_init(struct mantis_pci *mantis); | ||
33 | extern int mantis_dvb_exit(struct mantis_pci *mantis); | ||
34 | |||
35 | #endif /* __MANTIS_DVB_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_evm.c b/drivers/media/dvb/mantis/mantis_evm.c new file mode 100644 index 000000000000..a7b369a439d6 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_evm.c | |||
@@ -0,0 +1,117 @@ | |||
1 | /* | ||
2 | Mantis 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/kernel.h> | ||
22 | |||
23 | #include <linux/signal.h> | ||
24 | #include <linux/sched.h> | ||
25 | #include <linux/interrupt.h> | ||
26 | |||
27 | #include "dmxdev.h" | ||
28 | #include "dvbdev.h" | ||
29 | #include "dvb_demux.h" | ||
30 | #include "dvb_frontend.h" | ||
31 | #include "dvb_net.h" | ||
32 | |||
33 | #include "mantis_common.h" | ||
34 | #include "mantis_link.h" | ||
35 | #include "mantis_hif.h" | ||
36 | #include "mantis_reg.h" | ||
37 | |||
38 | static void mantis_hifevm_work(struct work_struct *work) | ||
39 | { | ||
40 | struct mantis_ca *ca = container_of(work, struct mantis_ca, hif_evm_work); | ||
41 | struct mantis_pci *mantis = ca->ca_priv; | ||
42 | |||
43 | u32 gpif_stat, gpif_mask; | ||
44 | |||
45 | gpif_stat = mmread(MANTIS_GPIF_STATUS); | ||
46 | gpif_mask = mmread(MANTIS_GPIF_IRQCFG); | ||
47 | |||
48 | if (gpif_stat & MANTIS_GPIF_DETSTAT) { | ||
49 | if (gpif_stat & MANTIS_CARD_PLUGIN) { | ||
50 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num); | ||
51 | mmwrite(0xdada0000, MANTIS_CARD_RESET); | ||
52 | mantis_event_cam_plugin(ca); | ||
53 | dvb_ca_en50221_camchange_irq(&ca->en50221, | ||
54 | 0, | ||
55 | DVB_CA_EN50221_CAMCHANGE_INSERTED); | ||
56 | } | ||
57 | } else { | ||
58 | if (gpif_stat & MANTIS_CARD_PLUGOUT) { | ||
59 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num); | ||
60 | mmwrite(0xdada0000, MANTIS_CARD_RESET); | ||
61 | mantis_event_cam_unplug(ca); | ||
62 | dvb_ca_en50221_camchange_irq(&ca->en50221, | ||
63 | 0, | ||
64 | DVB_CA_EN50221_CAMCHANGE_REMOVED); | ||
65 | } | ||
66 | } | ||
67 | |||
68 | if (mantis->gpif_status & MANTIS_GPIF_EXTIRQ) | ||
69 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num); | ||
70 | |||
71 | if (mantis->gpif_status & MANTIS_SBUF_WSTO) | ||
72 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num); | ||
73 | |||
74 | if (mantis->gpif_status & MANTIS_GPIF_OTHERR) | ||
75 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num); | ||
76 | |||
77 | if (gpif_stat & MANTIS_SBUF_OVFLW) | ||
78 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num); | ||
79 | |||
80 | if (gpif_stat & MANTIS_GPIF_BRRDY) | ||
81 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num); | ||
82 | |||
83 | if (gpif_stat & MANTIS_GPIF_INTSTAT) | ||
84 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num); | ||
85 | |||
86 | if (gpif_stat & MANTIS_SBUF_EMPTY) | ||
87 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num); | ||
88 | |||
89 | if (gpif_stat & MANTIS_SBUF_OPDONE) { | ||
90 | dprintk(MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num); | ||
91 | ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL; | ||
92 | ca->hif_event = MANTIS_SBUF_OPDONE; | ||
93 | wake_up(&ca->hif_opdone_wq); | ||
94 | } | ||
95 | } | ||
96 | |||
97 | int mantis_evmgr_init(struct mantis_ca *ca) | ||
98 | { | ||
99 | struct mantis_pci *mantis = ca->ca_priv; | ||
100 | |||
101 | dprintk(MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager"); | ||
102 | INIT_WORK(&ca->hif_evm_work, mantis_hifevm_work); | ||
103 | mantis_pcmcia_init(ca); | ||
104 | schedule_work(&ca->hif_evm_work); | ||
105 | mantis_hif_init(ca); | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | void mantis_evmgr_exit(struct mantis_ca *ca) | ||
110 | { | ||
111 | struct mantis_pci *mantis = ca->ca_priv; | ||
112 | |||
113 | dprintk(MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting"); | ||
114 | flush_scheduled_work(); | ||
115 | mantis_hif_exit(ca); | ||
116 | mantis_pcmcia_exit(ca); | ||
117 | } | ||
diff --git a/drivers/media/dvb/mantis/mantis_hif.c b/drivers/media/dvb/mantis/mantis_hif.c new file mode 100644 index 000000000000..7477dac628b4 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_hif.c | |||
@@ -0,0 +1,240 @@ | |||
1 | /* | ||
2 | Mantis 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/kernel.h> | ||
22 | #include <linux/signal.h> | ||
23 | #include <linux/sched.h> | ||
24 | |||
25 | #include <linux/signal.h> | ||
26 | #include <linux/sched.h> | ||
27 | #include <linux/interrupt.h> | ||
28 | |||
29 | #include "dmxdev.h" | ||
30 | #include "dvbdev.h" | ||
31 | #include "dvb_demux.h" | ||
32 | #include "dvb_frontend.h" | ||
33 | #include "dvb_net.h" | ||
34 | |||
35 | #include "mantis_common.h" | ||
36 | |||
37 | #include "mantis_hif.h" | ||
38 | #include "mantis_link.h" /* temporary due to physical layer stuff */ | ||
39 | |||
40 | #include "mantis_reg.h" | ||
41 | |||
42 | |||
43 | static int mantis_hif_sbuf_opdone_wait(struct mantis_ca *ca) | ||
44 | { | ||
45 | struct mantis_pci *mantis = ca->ca_priv; | ||
46 | int rc = 0; | ||
47 | |||
48 | if (wait_event_timeout(ca->hif_opdone_wq, | ||
49 | ca->hif_event & MANTIS_SBUF_OPDONE, | ||
50 | msecs_to_jiffies(500)) == -ERESTARTSYS) { | ||
51 | |||
52 | dprintk(MANTIS_ERROR, 1, "Adapter(%d) Slot(0): Smart buffer operation timeout !", mantis->num); | ||
53 | rc = -EREMOTEIO; | ||
54 | } | ||
55 | dprintk(MANTIS_DEBUG, 1, "Smart Buffer Operation complete"); | ||
56 | ca->hif_event &= ~MANTIS_SBUF_OPDONE; | ||
57 | return rc; | ||
58 | } | ||
59 | |||
60 | static int mantis_hif_write_wait(struct mantis_ca *ca) | ||
61 | { | ||
62 | struct mantis_pci *mantis = ca->ca_priv; | ||
63 | u32 opdone = 0, timeout = 0; | ||
64 | int rc = 0; | ||
65 | |||
66 | if (wait_event_timeout(ca->hif_write_wq, | ||
67 | mantis->gpif_status & MANTIS_GPIF_WRACK, | ||
68 | msecs_to_jiffies(500)) == -ERESTARTSYS) { | ||
69 | |||
70 | dprintk(MANTIS_ERROR, 1, "Adapter(%d) Slot(0): Write ACK timed out !", mantis->num); | ||
71 | rc = -EREMOTEIO; | ||
72 | } | ||
73 | dprintk(MANTIS_DEBUG, 1, "Write Acknowledged"); | ||
74 | mantis->gpif_status &= ~MANTIS_GPIF_WRACK; | ||
75 | while (!opdone) { | ||
76 | opdone = (mmread(MANTIS_GPIF_STATUS) & MANTIS_SBUF_OPDONE); | ||
77 | udelay(500); | ||
78 | timeout++; | ||
79 | if (timeout > 100) { | ||
80 | dprintk(MANTIS_ERROR, 1, "Adater(%d) Slot(0): Write operation timed out!", mantis->num); | ||
81 | rc = -ETIMEDOUT; | ||
82 | break; | ||
83 | } | ||
84 | } | ||
85 | dprintk(MANTIS_DEBUG, 1, "HIF Write success"); | ||
86 | return rc; | ||
87 | } | ||
88 | |||
89 | |||
90 | int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr) | ||
91 | { | ||
92 | struct mantis_pci *mantis = ca->ca_priv; | ||
93 | u32 hif_addr = 0, data, count = 4; | ||
94 | |||
95 | dprintk(MANTIS_DEBUG, 1, "Adapter(%d) Slot(0): Request HIF Mem Read", mantis->num); | ||
96 | mutex_lock(&ca->ca_lock); | ||
97 | hif_addr &= ~MANTIS_GPIF_PCMCIAREG; | ||
98 | hif_addr &= ~MANTIS_GPIF_PCMCIAIOM; | ||
99 | hif_addr |= MANTIS_HIF_STATUS; | ||
100 | hif_addr |= addr; | ||
101 | |||
102 | mmwrite(hif_addr, MANTIS_GPIF_BRADDR); | ||
103 | mmwrite(count, MANTIS_GPIF_BRBYTES); | ||
104 | udelay(20); | ||
105 | mmwrite(hif_addr | MANTIS_GPIF_HIFRDWRN, MANTIS_GPIF_ADDR); | ||
106 | |||
107 | if (mantis_hif_sbuf_opdone_wait(ca) != 0) { | ||
108 | dprintk(MANTIS_ERROR, 1, "Adapter(%d) Slot(0): GPIF Smart Buffer operation failed", mantis->num); | ||
109 | mutex_unlock(&ca->ca_lock); | ||
110 | return -EREMOTEIO; | ||
111 | } | ||
112 | data = mmread(MANTIS_GPIF_DIN); | ||
113 | mutex_unlock(&ca->ca_lock); | ||
114 | dprintk(MANTIS_DEBUG, 1, "Mem Read: 0x%02x", data); | ||
115 | return (data >> 24) & 0xff; | ||
116 | } | ||
117 | |||
118 | int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data) | ||
119 | { | ||
120 | struct mantis_slot *slot = ca->slot; | ||
121 | struct mantis_pci *mantis = ca->ca_priv; | ||
122 | u32 hif_addr = 0; | ||
123 | |||
124 | dprintk(MANTIS_DEBUG, 1, "Adapter(%d) Slot(0): Request HIF Mem Write", mantis->num); | ||
125 | mutex_lock(&ca->ca_lock); | ||
126 | hif_addr &= ~MANTIS_GPIF_HIFRDWRN; | ||
127 | hif_addr &= ~MANTIS_GPIF_PCMCIAREG; | ||
128 | hif_addr &= ~MANTIS_GPIF_PCMCIAIOM; | ||
129 | hif_addr |= MANTIS_HIF_STATUS; | ||
130 | hif_addr |= addr; | ||
131 | |||
132 | mmwrite(slot->slave_cfg, MANTIS_GPIF_CFGSLA); /* Slot0 alone for now */ | ||
133 | mmwrite(hif_addr, MANTIS_GPIF_ADDR); | ||
134 | mmwrite(data, MANTIS_GPIF_DOUT); | ||
135 | |||
136 | if (mantis_hif_write_wait(ca) != 0) { | ||
137 | dprintk(MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Smart Buffer operation failed", mantis->num); | ||
138 | mutex_unlock(&ca->ca_lock); | ||
139 | return -EREMOTEIO; | ||
140 | } | ||
141 | dprintk(MANTIS_DEBUG, 1, "Mem Write: (0x%02x to 0x%02x)", data, addr); | ||
142 | mutex_unlock(&ca->ca_lock); | ||
143 | |||
144 | return 0; | ||
145 | } | ||
146 | |||
147 | int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr) | ||
148 | { | ||
149 | struct mantis_pci *mantis = ca->ca_priv; | ||
150 | u32 data, hif_addr = 0; | ||
151 | |||
152 | dprintk(MANTIS_DEBUG, 1, "Adapter(%d) Slot(0): Request HIF I/O Read", mantis->num); | ||
153 | mutex_lock(&ca->ca_lock); | ||
154 | hif_addr &= ~MANTIS_GPIF_PCMCIAREG; | ||
155 | hif_addr |= MANTIS_GPIF_PCMCIAIOM; | ||
156 | hif_addr |= MANTIS_HIF_STATUS; | ||
157 | hif_addr |= addr; | ||
158 | |||
159 | mmwrite(hif_addr, MANTIS_GPIF_BRADDR); | ||
160 | mmwrite(1, MANTIS_GPIF_BRBYTES); | ||
161 | udelay(20); | ||
162 | mmwrite(hif_addr | MANTIS_GPIF_HIFRDWRN, MANTIS_GPIF_ADDR); | ||
163 | |||
164 | if (mantis_hif_sbuf_opdone_wait(ca) != 0) { | ||
165 | dprintk(MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Smart Buffer operation failed", mantis->num); | ||
166 | mutex_unlock(&ca->ca_lock); | ||
167 | return -EREMOTEIO; | ||
168 | } | ||
169 | data = mmread(MANTIS_GPIF_DIN); | ||
170 | dprintk(MANTIS_DEBUG, 1, "I/O Read: 0x%02x", data); | ||
171 | udelay(50); | ||
172 | mutex_unlock(&ca->ca_lock); | ||
173 | |||
174 | return (u8) data; | ||
175 | } | ||
176 | |||
177 | int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u8 data) | ||
178 | { | ||
179 | struct mantis_pci *mantis = ca->ca_priv; | ||
180 | u32 hif_addr = 0; | ||
181 | |||
182 | dprintk(MANTIS_DEBUG, 1, "Adapter(%d) Slot(0): Request HIF I/O Write", mantis->num); | ||
183 | mutex_lock(&ca->ca_lock); | ||
184 | hif_addr &= ~MANTIS_GPIF_PCMCIAREG; | ||
185 | hif_addr &= ~MANTIS_GPIF_HIFRDWRN; | ||
186 | hif_addr |= MANTIS_GPIF_PCMCIAIOM; | ||
187 | hif_addr |= MANTIS_HIF_STATUS; | ||
188 | hif_addr |= addr; | ||
189 | |||
190 | mmwrite(hif_addr, MANTIS_GPIF_ADDR); | ||
191 | mmwrite(data, MANTIS_GPIF_DOUT); | ||
192 | |||
193 | if (mantis_hif_write_wait(ca) != 0) { | ||
194 | dprintk(MANTIS_ERROR, 1, "Adapter(%d) Slot(0): HIF Smart Buffer operation failed", mantis->num); | ||
195 | mutex_unlock(&ca->ca_lock); | ||
196 | return -EREMOTEIO; | ||
197 | } | ||
198 | dprintk(MANTIS_DEBUG, 1, "I/O Write: (0x%02x to 0x%02x)", data, addr); | ||
199 | mutex_unlock(&ca->ca_lock); | ||
200 | udelay(50); | ||
201 | |||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | int mantis_hif_init(struct mantis_ca *ca) | ||
206 | { | ||
207 | struct mantis_slot *slot = ca->slot; | ||
208 | struct mantis_pci *mantis = ca->ca_priv; | ||
209 | u32 irqcfg; | ||
210 | |||
211 | slot[0].slave_cfg = 0x70773028; | ||
212 | dprintk(MANTIS_ERROR, 1, "Adapter(%d) Initializing Mantis Host Interface", mantis->num); | ||
213 | |||
214 | mutex_lock(&ca->ca_lock); | ||
215 | irqcfg = mmread(MANTIS_GPIF_IRQCFG); | ||
216 | irqcfg = MANTIS_MASK_BRRDY | | ||
217 | MANTIS_MASK_WRACK | | ||
218 | MANTIS_MASK_EXTIRQ | | ||
219 | MANTIS_MASK_WSTO | | ||
220 | MANTIS_MASK_OTHERR | | ||
221 | MANTIS_MASK_OVFLW; | ||
222 | |||
223 | mmwrite(irqcfg, MANTIS_GPIF_IRQCFG); | ||
224 | mutex_unlock(&ca->ca_lock); | ||
225 | |||
226 | return 0; | ||
227 | } | ||
228 | |||
229 | void mantis_hif_exit(struct mantis_ca *ca) | ||
230 | { | ||
231 | struct mantis_pci *mantis = ca->ca_priv; | ||
232 | u32 irqcfg; | ||
233 | |||
234 | dprintk(MANTIS_ERROR, 1, "Adapter(%d) Exiting Mantis Host Interface", mantis->num); | ||
235 | mutex_lock(&ca->ca_lock); | ||
236 | irqcfg = mmread(MANTIS_GPIF_IRQCFG); | ||
237 | irqcfg &= ~MANTIS_MASK_BRRDY; | ||
238 | mmwrite(irqcfg, MANTIS_GPIF_IRQCFG); | ||
239 | mutex_unlock(&ca->ca_lock); | ||
240 | } | ||
diff --git a/drivers/media/dvb/mantis/mantis_hif.h b/drivers/media/dvb/mantis/mantis_hif.h new file mode 100644 index 000000000000..9094f9ed2362 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_hif.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | Mantis 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 | #ifndef __MANTIS_HIF_H | ||
22 | #define __MANTIS_HIF_H | ||
23 | |||
24 | #define MANTIS_HIF_MEMRD 1 | ||
25 | #define MANTIS_HIF_MEMWR 2 | ||
26 | #define MANTIS_HIF_IOMRD 3 | ||
27 | #define MANTIS_HIF_IOMWR 4 | ||
28 | |||
29 | #endif /* __MANTIS_HIF_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_i2c.c b/drivers/media/dvb/mantis/mantis_i2c.c new file mode 100644 index 000000000000..7870bcf9689a --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_i2c.c | |||
@@ -0,0 +1,267 @@ | |||
1 | /* | ||
2 | Mantis 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 <asm/io.h> | ||
22 | #include <linux/ioport.h> | ||
23 | #include <linux/pci.h> | ||
24 | #include <linux/i2c.h> | ||
25 | |||
26 | #include "dmxdev.h" | ||
27 | #include "dvbdev.h" | ||
28 | #include "dvb_demux.h" | ||
29 | #include "dvb_frontend.h" | ||
30 | #include "dvb_net.h" | ||
31 | |||
32 | #include "mantis_common.h" | ||
33 | #include "mantis_reg.h" | ||
34 | #include "mantis_i2c.h" | ||
35 | |||
36 | #define TRIALS 10000 | ||
37 | |||
38 | static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg) | ||
39 | { | ||
40 | u32 rxd, i, stat, trials; | ||
41 | |||
42 | dprintk(MANTIS_INFO, 0, " %s: Address=[0x%02x] <R>[ ", | ||
43 | __func__, msg->addr); | ||
44 | |||
45 | for (i = 0; i < msg->len; i++) { | ||
46 | rxd = (msg->addr << 25) | (1 << 24) | ||
47 | | MANTIS_I2C_RATE_3 | ||
48 | | MANTIS_I2C_STOP | ||
49 | | MANTIS_I2C_PGMODE; | ||
50 | |||
51 | if (i == (msg->len - 1)) | ||
52 | rxd &= ~MANTIS_I2C_STOP; | ||
53 | |||
54 | mmwrite(MANTIS_INT_I2CDONE, MANTIS_INT_STAT); | ||
55 | mmwrite(rxd, MANTIS_I2CDATA_CTL); | ||
56 | |||
57 | /* wait for xfer completion */ | ||
58 | for (trials = 0; trials < TRIALS; trials++) { | ||
59 | stat = mmread(MANTIS_INT_STAT); | ||
60 | if (stat & MANTIS_INT_I2CDONE) | ||
61 | break; | ||
62 | } | ||
63 | |||
64 | dprintk(MANTIS_TMG, 0, "I2CDONE: trials=%d\n", trials); | ||
65 | |||
66 | /* wait for xfer completion */ | ||
67 | for (trials = 0; trials < TRIALS; trials++) { | ||
68 | stat = mmread(MANTIS_INT_STAT); | ||
69 | if (stat & MANTIS_INT_I2CRACK) | ||
70 | break; | ||
71 | } | ||
72 | |||
73 | dprintk(MANTIS_TMG, 0, "I2CRACK: trials=%d\n", trials); | ||
74 | |||
75 | rxd = mmread(MANTIS_I2CDATA_CTL); | ||
76 | msg->buf[i] = (u8)((rxd >> 8) & 0xFF); | ||
77 | dprintk(MANTIS_INFO, 0, "%02x ", msg->buf[i]); | ||
78 | } | ||
79 | dprintk(MANTIS_INFO, 0, "]\n"); | ||
80 | |||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | static int mantis_i2c_write(struct mantis_pci *mantis, const struct i2c_msg *msg) | ||
85 | { | ||
86 | int i; | ||
87 | u32 txd = 0, stat, trials; | ||
88 | |||
89 | dprintk(MANTIS_INFO, 0, " %s: Address=[0x%02x] <W>[ ", | ||
90 | __func__, msg->addr); | ||
91 | |||
92 | for (i = 0; i < msg->len; i++) { | ||
93 | dprintk(MANTIS_INFO, 0, "%02x ", msg->buf[i]); | ||
94 | txd = (msg->addr << 25) | (msg->buf[i] << 8) | ||
95 | | MANTIS_I2C_RATE_3 | ||
96 | | MANTIS_I2C_STOP | ||
97 | | MANTIS_I2C_PGMODE; | ||
98 | |||
99 | if (i == (msg->len - 1)) | ||
100 | txd &= ~MANTIS_I2C_STOP; | ||
101 | |||
102 | mmwrite(MANTIS_INT_I2CDONE, MANTIS_INT_STAT); | ||
103 | mmwrite(txd, MANTIS_I2CDATA_CTL); | ||
104 | |||
105 | /* wait for xfer completion */ | ||
106 | for (trials = 0; trials < TRIALS; trials++) { | ||
107 | stat = mmread(MANTIS_INT_STAT); | ||
108 | if (stat & MANTIS_INT_I2CDONE) | ||
109 | break; | ||
110 | } | ||
111 | |||
112 | dprintk(MANTIS_TMG, 0, "I2CDONE: trials=%d\n", trials); | ||
113 | |||
114 | /* wait for xfer completion */ | ||
115 | for (trials = 0; trials < TRIALS; trials++) { | ||
116 | stat = mmread(MANTIS_INT_STAT); | ||
117 | if (stat & MANTIS_INT_I2CRACK) | ||
118 | break; | ||
119 | } | ||
120 | |||
121 | dprintk(MANTIS_TMG, 0, "I2CRACK: trials=%d\n", trials); | ||
122 | } | ||
123 | dprintk(MANTIS_INFO, 0, "]\n"); | ||
124 | |||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | static int mantis_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num) | ||
129 | { | ||
130 | int ret = 0, i = 0, trials; | ||
131 | u32 stat, data, txd; | ||
132 | struct mantis_pci *mantis; | ||
133 | struct mantis_hwconfig *config; | ||
134 | |||
135 | mantis = i2c_get_adapdata(adapter); | ||
136 | BUG_ON(!mantis); | ||
137 | config = mantis->hwconfig; | ||
138 | BUG_ON(!config); | ||
139 | |||
140 | dprintk(MANTIS_DEBUG, 1, "Messages:%d", num); | ||
141 | mutex_lock(&mantis->i2c_lock); | ||
142 | |||
143 | while (i < num) { | ||
144 | /* Byte MODE */ | ||
145 | if ((config->i2c_mode & MANTIS_BYTE_MODE) && | ||
146 | ((i + 1) < num) && | ||
147 | (msgs[i].len < 2) && | ||
148 | (msgs[i + 1].len < 2) && | ||
149 | (msgs[i + 1].flags & I2C_M_RD)) { | ||
150 | |||
151 | dprintk(MANTIS_DEBUG, 0, " Byte MODE:\n"); | ||
152 | |||
153 | /* Read operation */ | ||
154 | txd = msgs[i].addr << 25 | (0x1 << 24) | ||
155 | | (msgs[i].buf[0] << 16) | ||
156 | | MANTIS_I2C_RATE_3; | ||
157 | |||
158 | mmwrite(txd, MANTIS_I2CDATA_CTL); | ||
159 | /* wait for xfer completion */ | ||
160 | for (trials = 0; trials < TRIALS; trials++) { | ||
161 | stat = mmread(MANTIS_INT_STAT); | ||
162 | if (stat & MANTIS_INT_I2CDONE) | ||
163 | break; | ||
164 | } | ||
165 | |||
166 | /* check for xfer completion */ | ||
167 | if (stat & MANTIS_INT_I2CDONE) { | ||
168 | /* check xfer was acknowledged */ | ||
169 | if (stat & MANTIS_INT_I2CRACK) { | ||
170 | data = mmread(MANTIS_I2CDATA_CTL); | ||
171 | msgs[i + 1].buf[0] = (data >> 8) & 0xff; | ||
172 | dprintk(MANTIS_DEBUG, 0, " Byte <%d> RXD=0x%02x [%02x]\n", 0x0, data, msgs[i + 1].buf[0]); | ||
173 | } else { | ||
174 | /* I/O error */ | ||
175 | dprintk(MANTIS_ERROR, 1, " I/O error, LINE:%d", __LINE__); | ||
176 | ret = -EIO; | ||
177 | break; | ||
178 | } | ||
179 | } else { | ||
180 | /* I/O error */ | ||
181 | dprintk(MANTIS_ERROR, 1, " I/O error, LINE:%d", __LINE__); | ||
182 | ret = -EIO; | ||
183 | break; | ||
184 | } | ||
185 | i += 2; /* Write/Read operation in one go */ | ||
186 | } | ||
187 | |||
188 | if (i < num) { | ||
189 | if (msgs[i].flags & I2C_M_RD) | ||
190 | ret = mantis_i2c_read(mantis, &msgs[i]); | ||
191 | else | ||
192 | ret = mantis_i2c_write(mantis, &msgs[i]); | ||
193 | |||
194 | i++; | ||
195 | if (ret < 0) | ||
196 | goto bail_out; | ||
197 | } | ||
198 | |||
199 | } | ||
200 | |||
201 | mutex_unlock(&mantis->i2c_lock); | ||
202 | |||
203 | return num; | ||
204 | |||
205 | bail_out: | ||
206 | mutex_unlock(&mantis->i2c_lock); | ||
207 | return ret; | ||
208 | } | ||
209 | |||
210 | static u32 mantis_i2c_func(struct i2c_adapter *adapter) | ||
211 | { | ||
212 | return I2C_FUNC_SMBUS_EMUL; | ||
213 | } | ||
214 | |||
215 | static struct i2c_algorithm mantis_algo = { | ||
216 | .master_xfer = mantis_i2c_xfer, | ||
217 | .functionality = mantis_i2c_func, | ||
218 | }; | ||
219 | |||
220 | int __devinit mantis_i2c_init(struct mantis_pci *mantis) | ||
221 | { | ||
222 | u32 intstat, intmask; | ||
223 | struct i2c_adapter *i2c_adapter = &mantis->adapter; | ||
224 | struct pci_dev *pdev = mantis->pdev; | ||
225 | |||
226 | init_waitqueue_head(&mantis->i2c_wq); | ||
227 | mutex_init(&mantis->i2c_lock); | ||
228 | strncpy(i2c_adapter->name, "Mantis I2C", sizeof(i2c_adapter->name)); | ||
229 | i2c_set_adapdata(i2c_adapter, mantis); | ||
230 | |||
231 | i2c_adapter->owner = THIS_MODULE; | ||
232 | i2c_adapter->class = I2C_CLASS_TV_DIGITAL; | ||
233 | i2c_adapter->algo = &mantis_algo; | ||
234 | i2c_adapter->algo_data = NULL; | ||
235 | i2c_adapter->timeout = 500; | ||
236 | i2c_adapter->retries = 3; | ||
237 | i2c_adapter->dev.parent = &pdev->dev; | ||
238 | |||
239 | mantis->i2c_rc = i2c_add_adapter(i2c_adapter); | ||
240 | if (mantis->i2c_rc < 0) | ||
241 | return mantis->i2c_rc; | ||
242 | |||
243 | dprintk(MANTIS_DEBUG, 1, "Initializing I2C .."); | ||
244 | |||
245 | intstat = mmread(MANTIS_INT_STAT); | ||
246 | intmask = mmread(MANTIS_INT_MASK); | ||
247 | mmwrite(intstat, MANTIS_INT_STAT); | ||
248 | dprintk(MANTIS_DEBUG, 1, "Disabling I2C interrupt"); | ||
249 | intmask = mmread(MANTIS_INT_MASK); | ||
250 | mmwrite((intmask & ~MANTIS_INT_I2CDONE), MANTIS_INT_MASK); | ||
251 | |||
252 | return 0; | ||
253 | } | ||
254 | EXPORT_SYMBOL_GPL(mantis_i2c_init); | ||
255 | |||
256 | int mantis_i2c_exit(struct mantis_pci *mantis) | ||
257 | { | ||
258 | u32 intmask; | ||
259 | |||
260 | dprintk(MANTIS_DEBUG, 1, "Disabling I2C interrupt"); | ||
261 | intmask = mmread(MANTIS_INT_MASK); | ||
262 | mmwrite((intmask & ~MANTIS_INT_I2CDONE), MANTIS_INT_MASK); | ||
263 | |||
264 | dprintk(MANTIS_DEBUG, 1, "Removing I2C adapter"); | ||
265 | return i2c_del_adapter(&mantis->adapter); | ||
266 | } | ||
267 | EXPORT_SYMBOL_GPL(mantis_i2c_exit); | ||
diff --git a/drivers/media/dvb/mantis/mantis_i2c.h b/drivers/media/dvb/mantis/mantis_i2c.h new file mode 100644 index 000000000000..1342df2faed8 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_i2c.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | Mantis 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 | #ifndef __MANTIS_I2C_H | ||
22 | #define __MANTIS_I2C_H | ||
23 | |||
24 | #define I2C_STOP (1 << 0) | ||
25 | #define I2C_READ (1 << 1) | ||
26 | |||
27 | extern int mantis_i2c_init(struct mantis_pci *mantis); | ||
28 | extern int mantis_i2c_exit(struct mantis_pci *mantis); | ||
29 | |||
30 | #endif /* __MANTIS_I2C_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_input.c b/drivers/media/dvb/mantis/mantis_input.c new file mode 100644 index 000000000000..6a9df779441f --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_input.c | |||
@@ -0,0 +1,148 @@ | |||
1 | /* | ||
2 | Mantis 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/input.h> | ||
22 | #include <media/ir-common.h> | ||
23 | #include <linux/pci.h> | ||
24 | |||
25 | #include "dmxdev.h" | ||
26 | #include "dvbdev.h" | ||
27 | #include "dvb_demux.h" | ||
28 | #include "dvb_frontend.h" | ||
29 | #include "dvb_net.h" | ||
30 | |||
31 | #include "mantis_common.h" | ||
32 | #include "mantis_reg.h" | ||
33 | #include "mantis_uart.h" | ||
34 | |||
35 | static struct ir_scancode mantis_ir_table[] = { | ||
36 | { 0x29, KEY_POWER }, | ||
37 | { 0x28, KEY_FAVORITES }, | ||
38 | { 0x30, KEY_TEXT }, | ||
39 | { 0x17, KEY_INFO }, /* Preview */ | ||
40 | { 0x23, KEY_EPG }, | ||
41 | { 0x3b, KEY_F22 }, /* Record List */ | ||
42 | { 0x3c, KEY_1 }, | ||
43 | { 0x3e, KEY_2 }, | ||
44 | { 0x39, KEY_3 }, | ||
45 | { 0x36, KEY_4 }, | ||
46 | { 0x22, KEY_5 }, | ||
47 | { 0x20, KEY_6 }, | ||
48 | { 0x32, KEY_7 }, | ||
49 | { 0x26, KEY_8 }, | ||
50 | { 0x24, KEY_9 }, | ||
51 | { 0x2a, KEY_0 }, | ||
52 | |||
53 | { 0x33, KEY_CANCEL }, | ||
54 | { 0x2c, KEY_BACK }, | ||
55 | { 0x15, KEY_CLEAR }, | ||
56 | { 0x3f, KEY_TAB }, | ||
57 | { 0x10, KEY_ENTER }, | ||
58 | { 0x14, KEY_UP }, | ||
59 | { 0x0d, KEY_RIGHT }, | ||
60 | { 0x0e, KEY_DOWN }, | ||
61 | { 0x11, KEY_LEFT }, | ||
62 | |||
63 | { 0x21, KEY_VOLUMEUP }, | ||
64 | { 0x35, KEY_VOLUMEDOWN }, | ||
65 | { 0x3d, KEY_CHANNELDOWN }, | ||
66 | { 0x3a, KEY_CHANNELUP }, | ||
67 | { 0x2e, KEY_RECORD }, | ||
68 | { 0x2b, KEY_PLAY }, | ||
69 | { 0x13, KEY_PAUSE }, | ||
70 | { 0x25, KEY_STOP }, | ||
71 | |||
72 | { 0x1f, KEY_REWIND }, | ||
73 | { 0x2d, KEY_FASTFORWARD }, | ||
74 | { 0x1e, KEY_PREVIOUS }, /* Replay |< */ | ||
75 | { 0x1d, KEY_NEXT }, /* Skip >| */ | ||
76 | |||
77 | { 0x0b, KEY_CAMERA }, /* Capture */ | ||
78 | { 0x0f, KEY_LANGUAGE }, /* SAP */ | ||
79 | { 0x18, KEY_MODE }, /* PIP */ | ||
80 | { 0x12, KEY_ZOOM }, /* Full screen */ | ||
81 | { 0x1c, KEY_SUBTITLE }, | ||
82 | { 0x2f, KEY_MUTE }, | ||
83 | { 0x16, KEY_F20 }, /* L/R */ | ||
84 | { 0x38, KEY_F21 }, /* Hibernate */ | ||
85 | |||
86 | { 0x37, KEY_SWITCHVIDEOMODE }, /* A/V */ | ||
87 | { 0x31, KEY_AGAIN }, /* Recall */ | ||
88 | { 0x1a, KEY_KPPLUS }, /* Zoom+ */ | ||
89 | { 0x19, KEY_KPMINUS }, /* Zoom- */ | ||
90 | { 0x27, KEY_RED }, | ||
91 | { 0x0C, KEY_GREEN }, | ||
92 | { 0x01, KEY_YELLOW }, | ||
93 | { 0x00, KEY_BLUE }, | ||
94 | }; | ||
95 | |||
96 | struct ir_scancode_table ir_mantis = { | ||
97 | .scan = mantis_ir_table, | ||
98 | .size = ARRAY_SIZE(mantis_ir_table), | ||
99 | }; | ||
100 | EXPORT_SYMBOL_GPL(ir_mantis); | ||
101 | |||
102 | int mantis_input_init(struct mantis_pci *mantis) | ||
103 | { | ||
104 | struct input_dev *rc; | ||
105 | struct ir_input_state rc_state; | ||
106 | char name[80], dev[80]; | ||
107 | int err; | ||
108 | |||
109 | rc = input_allocate_device(); | ||
110 | if (!rc) { | ||
111 | dprintk(MANTIS_ERROR, 1, "Input device allocate failed"); | ||
112 | return -ENOMEM; | ||
113 | } | ||
114 | |||
115 | sprintf(name, "Mantis %s IR receiver", mantis->hwconfig->model_name); | ||
116 | sprintf(dev, "pci-%s/ir0", pci_name(mantis->pdev)); | ||
117 | |||
118 | rc->name = name; | ||
119 | rc->phys = dev; | ||
120 | |||
121 | ir_input_init(rc, &rc_state, IR_TYPE_OTHER); | ||
122 | |||
123 | rc->id.bustype = BUS_PCI; | ||
124 | rc->id.vendor = mantis->vendor_id; | ||
125 | rc->id.product = mantis->device_id; | ||
126 | rc->id.version = 1; | ||
127 | rc->dev = mantis->pdev->dev; | ||
128 | |||
129 | err = ir_input_register(rc, &ir_mantis); | ||
130 | if (err) { | ||
131 | dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret = %d", err); | ||
132 | input_free_device(rc); | ||
133 | return -ENODEV; | ||
134 | } | ||
135 | |||
136 | mantis->rc = rc; | ||
137 | |||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | int mantis_exit(struct mantis_pci *mantis) | ||
142 | { | ||
143 | struct input_dev *rc = mantis->rc; | ||
144 | |||
145 | ir_input_unregister(rc); | ||
146 | |||
147 | return 0; | ||
148 | } | ||
diff --git a/drivers/media/dvb/mantis/mantis_ioc.c b/drivers/media/dvb/mantis/mantis_ioc.c new file mode 100644 index 000000000000..de148ded52d8 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_ioc.c | |||
@@ -0,0 +1,130 @@ | |||
1 | /* | ||
2 | Mantis 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/kernel.h> | ||
22 | #include <linux/i2c.h> | ||
23 | |||
24 | #include <linux/signal.h> | ||
25 | #include <linux/sched.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 "mantis_reg.h" | ||
36 | #include "mantis_ioc.h" | ||
37 | |||
38 | static int read_eeprom_bytes(struct mantis_pci *mantis, u8 reg, u8 *data, u8 length) | ||
39 | { | ||
40 | struct i2c_adapter *adapter = &mantis->adapter; | ||
41 | int err; | ||
42 | u8 buf = reg; | ||
43 | |||
44 | struct i2c_msg msg[] = { | ||
45 | { .addr = 0x50, .flags = 0, .buf = &buf, .len = 1 }, | ||
46 | { .addr = 0x50, .flags = I2C_M_RD, .buf = data, .len = length }, | ||
47 | }; | ||
48 | |||
49 | err = i2c_transfer(adapter, msg, 2); | ||
50 | if (err < 0) { | ||
51 | dprintk(MANTIS_ERROR, 1, "ERROR: i2c read: < err=%i d0=0x%02x d1=0x%02x >", | ||
52 | err, data[0], data[1]); | ||
53 | |||
54 | return err; | ||
55 | } | ||
56 | |||
57 | return 0; | ||
58 | } | ||
59 | int mantis_get_mac(struct mantis_pci *mantis) | ||
60 | { | ||
61 | int err; | ||
62 | u8 mac_addr[6] = {0}; | ||
63 | |||
64 | err = read_eeprom_bytes(mantis, 0x08, mac_addr, 6); | ||
65 | if (err < 0) { | ||
66 | dprintk(MANTIS_ERROR, 1, "ERROR: Mantis EEPROM read error <%d>", err); | ||
67 | |||
68 | return err; | ||
69 | } | ||
70 | |||
71 | dprintk(MANTIS_ERROR, 0, | ||
72 | " MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]\n", | ||
73 | mac_addr[0], | ||
74 | mac_addr[1], | ||
75 | mac_addr[2], | ||
76 | mac_addr[3], | ||
77 | mac_addr[4], | ||
78 | mac_addr[5]); | ||
79 | |||
80 | return 0; | ||
81 | } | ||
82 | EXPORT_SYMBOL_GPL(mantis_get_mac); | ||
83 | |||
84 | /* Turn the given bit on or off. */ | ||
85 | void gpio_set_bits(struct mantis_pci *mantis, u32 bitpos, u8 value) | ||
86 | { | ||
87 | u32 cur; | ||
88 | |||
89 | dprintk(MANTIS_DEBUG, 1, "Set Bit <%d> to <%d>", bitpos, value); | ||
90 | cur = mmread(MANTIS_GPIF_ADDR); | ||
91 | if (value) | ||
92 | mantis->gpio_status = cur | (1 << bitpos); | ||
93 | else | ||
94 | mantis->gpio_status = cur & (~(1 << bitpos)); | ||
95 | |||
96 | dprintk(MANTIS_DEBUG, 1, "GPIO Value <%02x>", mantis->gpio_status); | ||
97 | mmwrite(mantis->gpio_status, MANTIS_GPIF_ADDR); | ||
98 | mmwrite(0x00, MANTIS_GPIF_DOUT); | ||
99 | } | ||
100 | EXPORT_SYMBOL_GPL(gpio_set_bits); | ||
101 | |||
102 | int mantis_stream_control(struct mantis_pci *mantis, enum mantis_stream_control stream_ctl) | ||
103 | { | ||
104 | u32 reg; | ||
105 | |||
106 | reg = mmread(MANTIS_CONTROL); | ||
107 | switch (stream_ctl) { | ||
108 | case STREAM_TO_HIF: | ||
109 | dprintk(MANTIS_DEBUG, 1, "Set stream to HIF"); | ||
110 | reg &= 0xff - MANTIS_BYPASS; | ||
111 | mmwrite(reg, MANTIS_CONTROL); | ||
112 | reg |= MANTIS_BYPASS; | ||
113 | mmwrite(reg, MANTIS_CONTROL); | ||
114 | break; | ||
115 | |||
116 | case STREAM_TO_CAM: | ||
117 | dprintk(MANTIS_DEBUG, 1, "Set stream to CAM"); | ||
118 | reg |= MANTIS_BYPASS; | ||
119 | mmwrite(reg, MANTIS_CONTROL); | ||
120 | reg &= 0xff - MANTIS_BYPASS; | ||
121 | mmwrite(reg, MANTIS_CONTROL); | ||
122 | break; | ||
123 | default: | ||
124 | dprintk(MANTIS_ERROR, 1, "Unknown MODE <%02x>", stream_ctl); | ||
125 | return -1; | ||
126 | } | ||
127 | |||
128 | return 0; | ||
129 | } | ||
130 | EXPORT_SYMBOL_GPL(mantis_stream_control); | ||
diff --git a/drivers/media/dvb/mantis/mantis_ioc.h b/drivers/media/dvb/mantis/mantis_ioc.h new file mode 100644 index 000000000000..188fe5a81614 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_ioc.h | |||
@@ -0,0 +1,51 @@ | |||
1 | /* | ||
2 | Mantis 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 | #ifndef __MANTIS_IOC_H | ||
22 | #define __MANTIS_IOC_H | ||
23 | |||
24 | #define GPIF_A00 0x00 | ||
25 | #define GPIF_A01 0x01 | ||
26 | #define GPIF_A02 0x02 | ||
27 | #define GPIF_A03 0x03 | ||
28 | #define GPIF_A04 0x04 | ||
29 | #define GPIF_A05 0x05 | ||
30 | #define GPIF_A06 0x06 | ||
31 | #define GPIF_A07 0x07 | ||
32 | #define GPIF_A08 0x08 | ||
33 | #define GPIF_A09 0x09 | ||
34 | #define GPIF_A10 0x0a | ||
35 | #define GPIF_A11 0x0b | ||
36 | |||
37 | #define GPIF_A12 0x0c | ||
38 | #define GPIF_A13 0x0d | ||
39 | #define GPIF_A14 0x0e | ||
40 | |||
41 | enum mantis_stream_control { | ||
42 | STREAM_TO_HIF = 0, | ||
43 | STREAM_TO_CAM | ||
44 | }; | ||
45 | |||
46 | extern int mantis_get_mac(struct mantis_pci *mantis); | ||
47 | extern void gpio_set_bits(struct mantis_pci *mantis, u32 bitpos, u8 value); | ||
48 | |||
49 | extern int mantis_stream_control(struct mantis_pci *mantis, enum mantis_stream_control stream_ctl); | ||
50 | |||
51 | #endif /* __MANTIS_IOC_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_link.h b/drivers/media/dvb/mantis/mantis_link.h new file mode 100644 index 000000000000..2a814774a001 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_link.h | |||
@@ -0,0 +1,83 @@ | |||
1 | /* | ||
2 | Mantis 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 | #ifndef __MANTIS_LINK_H | ||
22 | #define __MANTIS_LINK_H | ||
23 | |||
24 | #include <linux/mutex.h> | ||
25 | #include <linux/workqueue.h> | ||
26 | #include "dvb_ca_en50221.h" | ||
27 | |||
28 | enum mantis_sbuf_status { | ||
29 | MANTIS_SBUF_DATA_AVAIL = 1, | ||
30 | MANTIS_SBUF_DATA_EMPTY = 2, | ||
31 | MANTIS_SBUF_DATA_OVFLW = 3 | ||
32 | }; | ||
33 | |||
34 | struct mantis_slot { | ||
35 | u32 timeout; | ||
36 | u32 slave_cfg; | ||
37 | u32 bar; | ||
38 | }; | ||
39 | |||
40 | /* Physical layer */ | ||
41 | enum mantis_slot_state { | ||
42 | MODULE_INSERTED = 3, | ||
43 | MODULE_XTRACTED = 4 | ||
44 | }; | ||
45 | |||
46 | struct mantis_ca { | ||
47 | struct mantis_slot slot[4]; | ||
48 | |||
49 | struct work_struct hif_evm_work; | ||
50 | |||
51 | u32 hif_event; | ||
52 | wait_queue_head_t hif_opdone_wq; | ||
53 | wait_queue_head_t hif_brrdyw_wq; | ||
54 | wait_queue_head_t hif_data_wq; | ||
55 | wait_queue_head_t hif_write_wq; /* HIF Write op */ | ||
56 | |||
57 | enum mantis_sbuf_status sbuf_status; | ||
58 | |||
59 | enum mantis_slot_state slot_state; | ||
60 | |||
61 | void *ca_priv; | ||
62 | |||
63 | struct dvb_ca_en50221 en50221; | ||
64 | struct mutex ca_lock; | ||
65 | }; | ||
66 | |||
67 | /* CA */ | ||
68 | extern void mantis_event_cam_plugin(struct mantis_ca *ca); | ||
69 | extern void mantis_event_cam_unplug(struct mantis_ca *ca); | ||
70 | extern int mantis_pcmcia_init(struct mantis_ca *ca); | ||
71 | extern void mantis_pcmcia_exit(struct mantis_ca *ca); | ||
72 | extern int mantis_evmgr_init(struct mantis_ca *ca); | ||
73 | extern void mantis_evmgr_exit(struct mantis_ca *ca); | ||
74 | |||
75 | /* HIF */ | ||
76 | extern int mantis_hif_init(struct mantis_ca *ca); | ||
77 | extern void mantis_hif_exit(struct mantis_ca *ca); | ||
78 | extern int mantis_hif_read_mem(struct mantis_ca *ca, u32 addr); | ||
79 | extern int mantis_hif_write_mem(struct mantis_ca *ca, u32 addr, u8 data); | ||
80 | extern int mantis_hif_read_iom(struct mantis_ca *ca, u32 addr); | ||
81 | extern int mantis_hif_write_iom(struct mantis_ca *ca, u32 addr, u8 data); | ||
82 | |||
83 | #endif /* __MANTIS_LINK_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_pci.c b/drivers/media/dvb/mantis/mantis_pci.c new file mode 100644 index 000000000000..6c7534af6b44 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_pci.c | |||
@@ -0,0 +1,177 @@ | |||
1 | /* | ||
2 | Mantis 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 <asm/io.h> | ||
25 | #include <asm/pgtable.h> | ||
26 | #include <asm/page.h> | ||
27 | #include <linux/kmod.h> | ||
28 | #include <linux/vmalloc.h> | ||
29 | #include <linux/init.h> | ||
30 | #include <linux/device.h> | ||
31 | #include <linux/pci.h> | ||
32 | |||
33 | #include <asm/irq.h> | ||
34 | #include <linux/signal.h> | ||
35 | #include <linux/sched.h> | ||
36 | #include <linux/interrupt.h> | ||
37 | |||
38 | #include "dmxdev.h" | ||
39 | #include "dvbdev.h" | ||
40 | #include "dvb_demux.h" | ||
41 | #include "dvb_frontend.h" | ||
42 | #include "dvb_net.h" | ||
43 | |||
44 | #include <asm/irq.h> | ||
45 | #include <linux/signal.h> | ||
46 | #include <linux/sched.h> | ||
47 | #include <linux/interrupt.h> | ||
48 | |||
49 | #include "mantis_common.h" | ||
50 | #include "mantis_reg.h" | ||
51 | #include "mantis_pci.h" | ||
52 | |||
53 | #define DRIVER_NAME "Mantis Core" | ||
54 | |||
55 | int __devinit mantis_pci_init(struct mantis_pci *mantis) | ||
56 | { | ||
57 | u8 revision, latency; | ||
58 | struct mantis_hwconfig *config = mantis->hwconfig; | ||
59 | struct pci_dev *pdev = mantis->pdev; | ||
60 | int err, ret = 0; | ||
61 | |||
62 | dprintk(MANTIS_ERROR, 0, "found a %s PCI %s device on (%02x:%02x.%x),\n", | ||
63 | config->model_name, | ||
64 | config->dev_type, | ||
65 | mantis->pdev->bus->number, | ||
66 | PCI_SLOT(mantis->pdev->devfn), | ||
67 | PCI_FUNC(mantis->pdev->devfn)); | ||
68 | |||
69 | err = pci_enable_device(pdev); | ||
70 | if (err != 0) { | ||
71 | ret = -ENODEV; | ||
72 | dprintk(MANTIS_ERROR, 1, "ERROR: PCI enable failed <%i>", err); | ||
73 | goto fail0; | ||
74 | } | ||
75 | |||
76 | err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); | ||
77 | if (err != 0) { | ||
78 | dprintk(MANTIS_ERROR, 1, "ERROR: Unable to obtain 32 bit DMA <%i>", err); | ||
79 | ret = -ENOMEM; | ||
80 | goto fail1; | ||
81 | } | ||
82 | |||
83 | pci_set_master(pdev); | ||
84 | |||
85 | if (!request_mem_region(pci_resource_start(pdev, 0), | ||
86 | pci_resource_len(pdev, 0), | ||
87 | DRIVER_NAME)) { | ||
88 | |||
89 | dprintk(MANTIS_ERROR, 1, "ERROR: BAR0 Request failed !"); | ||
90 | ret = -ENODEV; | ||
91 | goto fail1; | ||
92 | } | ||
93 | |||
94 | mantis->mmio = ioremap(pci_resource_start(pdev, 0), | ||
95 | pci_resource_len(pdev, 0)); | ||
96 | |||
97 | if (!mantis->mmio) { | ||
98 | dprintk(MANTIS_ERROR, 1, "ERROR: BAR0 remap failed !"); | ||
99 | ret = -ENODEV; | ||
100 | goto fail2; | ||
101 | } | ||
102 | |||
103 | pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency); | ||
104 | pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision); | ||
105 | mantis->latency = latency; | ||
106 | mantis->revision = revision; | ||
107 | |||
108 | dprintk(MANTIS_ERROR, 0, " Mantis Rev %d [%04x:%04x], ", | ||
109 | mantis->revision, | ||
110 | mantis->pdev->subsystem_vendor, | ||
111 | mantis->pdev->subsystem_device); | ||
112 | |||
113 | dprintk(MANTIS_ERROR, 0, | ||
114 | "irq: %d, latency: %d\n memory: 0x%lx, mmio: 0x%p\n", | ||
115 | mantis->pdev->irq, | ||
116 | mantis->latency, | ||
117 | mantis->mantis_addr, | ||
118 | mantis->mmio); | ||
119 | |||
120 | err = request_irq(pdev->irq, | ||
121 | config->irq_handler, | ||
122 | IRQF_SHARED, | ||
123 | DRIVER_NAME, | ||
124 | mantis); | ||
125 | |||
126 | if (err != 0) { | ||
127 | |||
128 | dprintk(MANTIS_ERROR, 1, "ERROR: IRQ registration failed ! <%d>", err); | ||
129 | ret = -ENODEV; | ||
130 | goto fail3; | ||
131 | } | ||
132 | |||
133 | pci_set_drvdata(pdev, mantis); | ||
134 | return ret; | ||
135 | |||
136 | /* Error conditions */ | ||
137 | fail3: | ||
138 | dprintk(MANTIS_ERROR, 1, "ERROR: <%d> I/O unmap", ret); | ||
139 | if (mantis->mmio) | ||
140 | iounmap(mantis->mmio); | ||
141 | |||
142 | fail2: | ||
143 | dprintk(MANTIS_ERROR, 1, "ERROR: <%d> releasing regions", ret); | ||
144 | release_mem_region(pci_resource_start(pdev, 0), | ||
145 | pci_resource_len(pdev, 0)); | ||
146 | |||
147 | fail1: | ||
148 | dprintk(MANTIS_ERROR, 1, "ERROR: <%d> disabling device", ret); | ||
149 | pci_disable_device(pdev); | ||
150 | |||
151 | fail0: | ||
152 | dprintk(MANTIS_ERROR, 1, "ERROR: <%d> exiting", ret); | ||
153 | pci_set_drvdata(pdev, NULL); | ||
154 | return ret; | ||
155 | } | ||
156 | EXPORT_SYMBOL_GPL(mantis_pci_init); | ||
157 | |||
158 | void mantis_pci_exit(struct mantis_pci *mantis) | ||
159 | { | ||
160 | struct pci_dev *pdev = mantis->pdev; | ||
161 | |||
162 | dprintk(MANTIS_NOTICE, 1, " mem: 0x%p", mantis->mmio); | ||
163 | free_irq(pdev->irq, mantis); | ||
164 | if (mantis->mmio) { | ||
165 | iounmap(mantis->mmio); | ||
166 | release_mem_region(pci_resource_start(pdev, 0), | ||
167 | pci_resource_len(pdev, 0)); | ||
168 | } | ||
169 | |||
170 | pci_disable_device(pdev); | ||
171 | pci_set_drvdata(pdev, NULL); | ||
172 | } | ||
173 | EXPORT_SYMBOL_GPL(mantis_pci_exit); | ||
174 | |||
175 | MODULE_DESCRIPTION("Mantis PCI DTV bridge driver"); | ||
176 | MODULE_AUTHOR("Manu Abraham"); | ||
177 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/mantis/mantis_pci.h b/drivers/media/dvb/mantis/mantis_pci.h new file mode 100644 index 000000000000..65f004519086 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_pci.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /* | ||
2 | Mantis 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 | #ifndef __MANTIS_PCI_H | ||
22 | #define __MANTIS_PCI_H | ||
23 | |||
24 | extern int mantis_pci_init(struct mantis_pci *mantis); | ||
25 | extern void mantis_pci_exit(struct mantis_pci *mantis); | ||
26 | |||
27 | #endif /* __MANTIS_PCI_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_pcmcia.c b/drivers/media/dvb/mantis/mantis_pcmcia.c new file mode 100644 index 000000000000..5cb545b913f6 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_pcmcia.c | |||
@@ -0,0 +1,120 @@ | |||
1 | /* | ||
2 | Mantis 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/kernel.h> | ||
22 | |||
23 | #include <linux/signal.h> | ||
24 | #include <linux/sched.h> | ||
25 | #include <linux/interrupt.h> | ||
26 | |||
27 | #include "dmxdev.h" | ||
28 | #include "dvbdev.h" | ||
29 | #include "dvb_demux.h" | ||
30 | #include "dvb_frontend.h" | ||
31 | #include "dvb_net.h" | ||
32 | |||
33 | #include "mantis_common.h" | ||
34 | #include "mantis_link.h" /* temporary due to physical layer stuff */ | ||
35 | #include "mantis_reg.h" | ||
36 | |||
37 | /* | ||
38 | * If Slot state is already PLUG_IN event and we are called | ||
39 | * again, definitely it is jitter alone | ||
40 | */ | ||
41 | void mantis_event_cam_plugin(struct mantis_ca *ca) | ||
42 | { | ||
43 | struct mantis_pci *mantis = ca->ca_priv; | ||
44 | |||
45 | u32 gpif_irqcfg; | ||
46 | |||
47 | if (ca->slot_state == MODULE_XTRACTED) { | ||
48 | dprintk(MANTIS_DEBUG, 1, "Event: CAM Plugged IN: Adapter(%d) Slot(0)", mantis->num); | ||
49 | udelay(50); | ||
50 | mmwrite(0xda000000, MANTIS_CARD_RESET); | ||
51 | gpif_irqcfg = mmread(MANTIS_GPIF_IRQCFG); | ||
52 | gpif_irqcfg |= MANTIS_MASK_PLUGOUT; | ||
53 | gpif_irqcfg &= ~MANTIS_MASK_PLUGIN; | ||
54 | mmwrite(gpif_irqcfg, MANTIS_GPIF_IRQCFG); | ||
55 | udelay(500); | ||
56 | ca->slot_state = MODULE_INSERTED; | ||
57 | } | ||
58 | udelay(100); | ||
59 | } | ||
60 | |||
61 | /* | ||
62 | * If Slot state is already UN_PLUG event and we are called | ||
63 | * again, definitely it is jitter alone | ||
64 | */ | ||
65 | void mantis_event_cam_unplug(struct mantis_ca *ca) | ||
66 | { | ||
67 | struct mantis_pci *mantis = ca->ca_priv; | ||
68 | |||
69 | u32 gpif_irqcfg; | ||
70 | |||
71 | if (ca->slot_state == MODULE_INSERTED) { | ||
72 | dprintk(MANTIS_DEBUG, 1, "Event: CAM Unplugged: Adapter(%d) Slot(0)", mantis->num); | ||
73 | udelay(50); | ||
74 | mmwrite(0x00da0000, MANTIS_CARD_RESET); | ||
75 | gpif_irqcfg = mmread(MANTIS_GPIF_IRQCFG); | ||
76 | gpif_irqcfg |= MANTIS_MASK_PLUGIN; | ||
77 | gpif_irqcfg &= ~MANTIS_MASK_PLUGOUT; | ||
78 | mmwrite(gpif_irqcfg, MANTIS_GPIF_IRQCFG); | ||
79 | udelay(500); | ||
80 | ca->slot_state = MODULE_XTRACTED; | ||
81 | } | ||
82 | udelay(100); | ||
83 | } | ||
84 | |||
85 | int mantis_pcmcia_init(struct mantis_ca *ca) | ||
86 | { | ||
87 | struct mantis_pci *mantis = ca->ca_priv; | ||
88 | |||
89 | u32 gpif_stat, card_stat; | ||
90 | |||
91 | mmwrite(mmread(MANTIS_INT_MASK) | MANTIS_INT_IRQ0, MANTIS_INT_MASK); | ||
92 | gpif_stat = mmread(MANTIS_GPIF_STATUS); | ||
93 | card_stat = mmread(MANTIS_GPIF_IRQCFG); | ||
94 | |||
95 | if (gpif_stat & MANTIS_GPIF_DETSTAT) { | ||
96 | dprintk(MANTIS_DEBUG, 1, "CAM found on Adapter(%d) Slot(0)", mantis->num); | ||
97 | mmwrite(card_stat | MANTIS_MASK_PLUGOUT, MANTIS_GPIF_IRQCFG); | ||
98 | ca->slot_state = MODULE_INSERTED; | ||
99 | dvb_ca_en50221_camchange_irq(&ca->en50221, | ||
100 | 0, | ||
101 | DVB_CA_EN50221_CAMCHANGE_INSERTED); | ||
102 | } else { | ||
103 | dprintk(MANTIS_DEBUG, 1, "Empty Slot on Adapter(%d) Slot(0)", mantis->num); | ||
104 | mmwrite(card_stat | MANTIS_MASK_PLUGIN, MANTIS_GPIF_IRQCFG); | ||
105 | ca->slot_state = MODULE_XTRACTED; | ||
106 | dvb_ca_en50221_camchange_irq(&ca->en50221, | ||
107 | 0, | ||
108 | DVB_CA_EN50221_CAMCHANGE_REMOVED); | ||
109 | } | ||
110 | |||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | void mantis_pcmcia_exit(struct mantis_ca *ca) | ||
115 | { | ||
116 | struct mantis_pci *mantis = ca->ca_priv; | ||
117 | |||
118 | mmwrite(mmread(MANTIS_GPIF_STATUS) & (~MANTIS_CARD_PLUGOUT | ~MANTIS_CARD_PLUGIN), MANTIS_GPIF_STATUS); | ||
119 | mmwrite(mmread(MANTIS_INT_MASK) & ~MANTIS_INT_IRQ0, MANTIS_INT_MASK); | ||
120 | } | ||
diff --git a/drivers/media/dvb/mantis/mantis_reg.h b/drivers/media/dvb/mantis/mantis_reg.h new file mode 100644 index 000000000000..7761f9dc7fe0 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_reg.h | |||
@@ -0,0 +1,197 @@ | |||
1 | /* | ||
2 | Mantis 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 | #ifndef __MANTIS_REG_H | ||
22 | #define __MANTIS_REG_H | ||
23 | |||
24 | /* Interrupts */ | ||
25 | #define MANTIS_INT_STAT 0x00 | ||
26 | #define MANTIS_INT_MASK 0x04 | ||
27 | |||
28 | #define MANTIS_INT_RISCSTAT (0x0f << 28) | ||
29 | #define MANTIS_INT_RISCEN (0x01 << 27) | ||
30 | #define MANTIS_INT_I2CRACK (0x01 << 26) | ||
31 | |||
32 | /* #define MANTIS_INT_GPIF (0xff << 12) */ | ||
33 | |||
34 | #define MANTIS_INT_PCMCIA7 (0x01 << 19) | ||
35 | #define MANTIS_INT_PCMCIA6 (0x01 << 18) | ||
36 | #define MANTIS_INT_PCMCIA5 (0x01 << 17) | ||
37 | #define MANTIS_INT_PCMCIA4 (0x01 << 16) | ||
38 | #define MANTIS_INT_PCMCIA3 (0x01 << 15) | ||
39 | #define MANTIS_INT_PCMCIA2 (0x01 << 14) | ||
40 | #define MANTIS_INT_PCMCIA1 (0x01 << 13) | ||
41 | #define MANTIS_INT_PCMCIA0 (0x01 << 12) | ||
42 | #define MANTIS_INT_IRQ1 (0x01 << 11) | ||
43 | #define MANTIS_INT_IRQ0 (0x01 << 10) | ||
44 | #define MANTIS_INT_OCERR (0x01 << 8) | ||
45 | #define MANTIS_INT_PABORT (0x01 << 7) | ||
46 | #define MANTIS_INT_RIPERR (0x01 << 6) | ||
47 | #define MANTIS_INT_PPERR (0x01 << 5) | ||
48 | #define MANTIS_INT_FTRGT (0x01 << 3) | ||
49 | #define MANTIS_INT_RISCI (0x01 << 1) | ||
50 | #define MANTIS_INT_I2CDONE (0x01 << 0) | ||
51 | |||
52 | /* DMA */ | ||
53 | #define MANTIS_DMA_CTL 0x08 | ||
54 | #define MANTIS_GPIF_RD (0xff << 24) | ||
55 | #define MANTIS_GPIF_WR (0xff << 16) | ||
56 | #define MANTIS_CPU_DO (0x01 << 10) | ||
57 | #define MANTIS_DRV_DO (0x01 << 9) | ||
58 | #define MANTIS_I2C_RD (0x01 << 7) | ||
59 | #define MANTIS_I2C_WR (0x01 << 6) | ||
60 | #define MANTIS_DCAP_MODE (0x01 << 5) | ||
61 | #define MANTIS_FIFO_TP_4 (0x00 << 3) | ||
62 | #define MANTIS_FIFO_TP_8 (0x01 << 3) | ||
63 | #define MANTIS_FIFO_TP_16 (0x02 << 3) | ||
64 | #define MANTIS_FIFO_EN (0x01 << 2) | ||
65 | #define MANTIS_DCAP_EN (0x01 << 1) | ||
66 | #define MANTIS_RISC_EN (0x01 << 0) | ||
67 | |||
68 | /* DEBUG */ | ||
69 | #define MANTIS_DEBUGREG 0x0c | ||
70 | #define MANTIS_DATINV (0x0e << 7) | ||
71 | #define MANTIS_TOP_DEBUGSEL (0x07 << 4) | ||
72 | #define MANTIS_PCMCIA_DEBUGSEL (0x0f << 0) | ||
73 | |||
74 | #define MANTIS_RISC_START 0x10 | ||
75 | #define MANTIS_RISC_PC 0x14 | ||
76 | |||
77 | /* I2C */ | ||
78 | #define MANTIS_I2CDATA_CTL 0x18 | ||
79 | #define MANTIS_I2C_RATE_1 (0x00 << 6) | ||
80 | #define MANTIS_I2C_RATE_2 (0x01 << 6) | ||
81 | #define MANTIS_I2C_RATE_3 (0x02 << 6) | ||
82 | #define MANTIS_I2C_RATE_4 (0x03 << 6) | ||
83 | #define MANTIS_I2C_STOP (0x01 << 5) | ||
84 | #define MANTIS_I2C_PGMODE (0x01 << 3) | ||
85 | |||
86 | /* DATA */ | ||
87 | #define MANTIS_CMD_DATA_R1 0x20 | ||
88 | #define MANTIS_CMD_DATA_3 (0xff << 24) | ||
89 | #define MANTIS_CMD_DATA_2 (0xff << 16) | ||
90 | #define MANTIS_CMD_DATA_1 (0xff << 8) | ||
91 | #define MANTIS_CMD_DATA_0 (0xff << 0) | ||
92 | |||
93 | #define MANTIS_CMD_DATA_R2 0x24 | ||
94 | #define MANTIS_CMD_DATA_7 (0xff << 24) | ||
95 | #define MANTIS_CMD_DATA_6 (0xff << 16) | ||
96 | #define MANTIS_CMD_DATA_5 (0xff << 8) | ||
97 | #define MANTIS_CMD_DATA_4 (0xff << 0) | ||
98 | |||
99 | #define MANTIS_CONTROL 0x28 | ||
100 | #define MANTIS_DET (0x01 << 7) | ||
101 | #define MANTIS_DAT_CF_EN (0x01 << 6) | ||
102 | #define MANTIS_ACS (0x03 << 4) | ||
103 | #define MANTIS_VCCEN (0x01 << 3) | ||
104 | #define MANTIS_BYPASS (0x01 << 2) | ||
105 | #define MANTIS_MRST (0x01 << 1) | ||
106 | #define MANTIS_CRST_INT (0x01 << 0) | ||
107 | |||
108 | #define MANTIS_GPIF_CFGSLA 0x84 | ||
109 | #define MANTIS_GPIF_WAITSMPL (0x07 << 28) | ||
110 | #define MANTIS_GPIF_BYTEADDRSUB (0x01 << 25) | ||
111 | #define MANTIS_GPIF_WAITPOL (0x01 << 24) | ||
112 | #define MANTIS_GPIF_NCDELAY (0x07 << 20) | ||
113 | #define MANTIS_GPIF_RW2CSDELAY (0x07 << 16) | ||
114 | #define MANTIS_GPIF_SLFTIMEDMODE (0x01 << 15) | ||
115 | #define MANTIS_GPIF_SLFTIMEDDELY (0x7f << 8) | ||
116 | #define MANTIS_GPIF_DEVTYPE (0x07 << 4) | ||
117 | #define MANTIS_GPIF_BIGENDIAN (0x01 << 3) | ||
118 | #define MANTIS_GPIF_FETCHCMD (0x03 << 1) | ||
119 | #define MANTIS_GPIF_HWORDDEV (0x01 << 0) | ||
120 | |||
121 | #define MANTIS_GPIF_WSTOPER 0x90 | ||
122 | #define MANTIS_GPIF_WSTOPERWREN3 (0x01 << 31) | ||
123 | #define MANTIS_GPIF_PARBOOTN (0x01 << 29) | ||
124 | #define MANTIS_GPIF_WSTOPERSLID3 (0x1f << 24) | ||
125 | #define MANTIS_GPIF_WSTOPERWREN2 (0x01 << 23) | ||
126 | #define MANTIS_GPIF_WSTOPERSLID2 (0x1f << 16) | ||
127 | #define MANTIS_GPIF_WSTOPERWREN1 (0x01 << 15) | ||
128 | #define MANTIS_GPIF_WSTOPERSLID1 (0x1f << 8) | ||
129 | #define MANTIS_GPIF_WSTOPERWREN0 (0x01 << 7) | ||
130 | #define MANTIS_GPIF_WSTOPERSLID0 (0x1f << 0) | ||
131 | |||
132 | #define MANTIS_GPIF_CS2RW 0x94 | ||
133 | #define MANTIS_GPIF_CS2RWWREN3 (0x01 << 31) | ||
134 | #define MANTIS_GPIF_CS2RWDELY3 (0x3f << 24) | ||
135 | #define MANTIS_GPIF_CS2RWWREN2 (0x01 << 23) | ||
136 | #define MANTIS_GPIF_CS2RWDELY2 (0x3f << 16) | ||
137 | #define MANTIS_GPIF_CS2RWWREN1 (0x01 << 15) | ||
138 | #define MANTIS_GPIF_CS2RWDELY1 (0x3f << 8) | ||
139 | #define MANTIS_GPIF_CS2RWWREN0 (0x01 << 7) | ||
140 | #define MANTIS_GPIF_CS2RWDELY0 (0x3f << 0) | ||
141 | |||
142 | #define MANTIS_GPIF_IRQCFG 0x98 | ||
143 | #define MANTIS_GPIF_IRQPOL (0x01 << 8) | ||
144 | #define MANTIS_MASK_WRACK (0x01 << 7) | ||
145 | #define MANTIS_MASK_BRRDY (0x01 << 6) | ||
146 | #define MANTIS_MASK_OVFLW (0x01 << 5) | ||
147 | #define MANTIS_MASK_OTHERR (0x01 << 4) | ||
148 | #define MANTIS_MASK_WSTO (0x01 << 3) | ||
149 | #define MANTIS_MASK_EXTIRQ (0x01 << 2) | ||
150 | #define MANTIS_MASK_PLUGIN (0x01 << 1) | ||
151 | #define MANTIS_MASK_PLUGOUT (0x01 << 0) | ||
152 | |||
153 | #define MANTIS_GPIF_STATUS 0x9c | ||
154 | #define MANTIS_SBUF_KILLOP (0x01 << 15) | ||
155 | #define MANTIS_SBUF_OPDONE (0x01 << 14) | ||
156 | #define MANTIS_SBUF_EMPTY (0x01 << 13) | ||
157 | #define MANTIS_GPIF_DETSTAT (0x01 << 9) | ||
158 | #define MANTIS_GPIF_INTSTAT (0x01 << 8) | ||
159 | #define MANTIS_GPIF_WRACK (0x01 << 7) | ||
160 | #define MANTIS_GPIF_BRRDY (0x01 << 6) | ||
161 | #define MANTIS_SBUF_OVFLW (0x01 << 5) | ||
162 | #define MANTIS_GPIF_OTHERR (0x01 << 4) | ||
163 | #define MANTIS_SBUF_WSTO (0x01 << 3) | ||
164 | #define MANTIS_GPIF_EXTIRQ (0x01 << 2) | ||
165 | #define MANTIS_CARD_PLUGIN (0x01 << 1) | ||
166 | #define MANTIS_CARD_PLUGOUT (0x01 << 0) | ||
167 | |||
168 | #define MANTIS_GPIF_BRADDR 0xa0 | ||
169 | #define MANTIS_GPIF_PCMCIAREG (0x01 << 27) | ||
170 | #define MANTIS_GPIF_PCMCIAIOM (0x01 << 26) | ||
171 | #define MANTIS_GPIF_BR_ADDR (0xfffffff << 0) | ||
172 | |||
173 | #define MANTIS_GPIF_BRBYTES 0xa4 | ||
174 | #define MANTIS_GPIF_BRCNT (0xfff << 0) | ||
175 | |||
176 | #define MANTIS_PCMCIA_RESET 0xa8 | ||
177 | #define MANTIS_PCMCIA_RSTVAL (0xff << 0) | ||
178 | |||
179 | #define MANTIS_CARD_RESET 0xac | ||
180 | |||
181 | #define MANTIS_GPIF_ADDR 0xb0 | ||
182 | #define MANTIS_GPIF_HIFRDWRN (0x01 << 31) | ||
183 | #define MANTIS_GPIF_PCMCIAREG (0x01 << 27) | ||
184 | #define MANTIS_GPIF_PCMCIAIOM (0x01 << 26) | ||
185 | #define MANTIS_GPIF_HIFADDR (0xfffffff << 0) | ||
186 | |||
187 | #define MANTIS_GPIF_DOUT 0xb4 | ||
188 | #define MANTIS_GPIF_HIFDOUT (0xfffffff << 0) | ||
189 | |||
190 | #define MANTIS_GPIF_DIN 0xb8 | ||
191 | #define MANTIS_GPIF_HIFDIN (0xfffffff << 0) | ||
192 | |||
193 | #define MANTIS_GPIF_SPARE 0xbc | ||
194 | #define MANTIS_GPIF_LOGICRD (0xffff << 16) | ||
195 | #define MANTIS_GPIF_LOGICRW (0xffff << 0) | ||
196 | |||
197 | #endif /* __MANTIS_REG_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_uart.c b/drivers/media/dvb/mantis/mantis_uart.c new file mode 100644 index 000000000000..7d2f2398fa8b --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_uart.c | |||
@@ -0,0 +1,186 @@ | |||
1 | /* | ||
2 | Mantis 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/kernel.h> | ||
22 | #include <linux/spinlock.h> | ||
23 | |||
24 | #include <linux/signal.h> | ||
25 | #include <linux/sched.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 "mantis_reg.h" | ||
36 | #include "mantis_uart.h" | ||
37 | |||
38 | struct mantis_uart_params { | ||
39 | enum mantis_baud baud_rate; | ||
40 | enum mantis_parity parity; | ||
41 | }; | ||
42 | |||
43 | static struct { | ||
44 | char string[7]; | ||
45 | } rates[5] = { | ||
46 | { "9600" }, | ||
47 | { "19200" }, | ||
48 | { "38400" }, | ||
49 | { "57600" }, | ||
50 | { "115200" } | ||
51 | }; | ||
52 | |||
53 | static struct { | ||
54 | char string[5]; | ||
55 | } parity[3] = { | ||
56 | { "NONE" }, | ||
57 | { "ODD" }, | ||
58 | { "EVEN" } | ||
59 | }; | ||
60 | |||
61 | #define UART_MAX_BUF 16 | ||
62 | |||
63 | int mantis_uart_read(struct mantis_pci *mantis, u8 *data) | ||
64 | { | ||
65 | struct mantis_hwconfig *config = mantis->hwconfig; | ||
66 | u32 stat = 0, i; | ||
67 | |||
68 | /* get data */ | ||
69 | for (i = 0; i < (config->bytes + 1); i++) { | ||
70 | |||
71 | stat = mmread(MANTIS_UART_STAT); | ||
72 | |||
73 | if (stat & MANTIS_UART_RXFIFO_FULL) { | ||
74 | dprintk(MANTIS_ERROR, 1, "RX Fifo FULL"); | ||
75 | } | ||
76 | data[i] = mmread(MANTIS_UART_RXD) & 0x3f; | ||
77 | |||
78 | dprintk(MANTIS_DEBUG, 1, "Reading ... <%02x>", data[i] & 0x3f); | ||
79 | |||
80 | if (data[i] & (1 << 7)) { | ||
81 | dprintk(MANTIS_ERROR, 1, "UART framing error"); | ||
82 | return -EINVAL; | ||
83 | } | ||
84 | if (data[i] & (1 << 6)) { | ||
85 | dprintk(MANTIS_ERROR, 1, "UART parity error"); | ||
86 | return -EINVAL; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | static void mantis_uart_work(struct work_struct *work) | ||
94 | { | ||
95 | struct mantis_pci *mantis = container_of(work, struct mantis_pci, uart_work); | ||
96 | struct mantis_hwconfig *config = mantis->hwconfig; | ||
97 | u8 buf[16]; | ||
98 | int i; | ||
99 | |||
100 | mantis_uart_read(mantis, buf); | ||
101 | |||
102 | for (i = 0; i < (config->bytes + 1); i++) | ||
103 | dprintk(MANTIS_INFO, 1, "UART BUF:%d <%02x> ", i, buf[i]); | ||
104 | |||
105 | dprintk(MANTIS_DEBUG, 0, "\n"); | ||
106 | } | ||
107 | |||
108 | static int mantis_uart_setup(struct mantis_pci *mantis, | ||
109 | struct mantis_uart_params *params) | ||
110 | { | ||
111 | u32 reg; | ||
112 | |||
113 | mmwrite((mmread(MANTIS_UART_CTL) | (params->parity & 0x3)), MANTIS_UART_CTL); | ||
114 | |||
115 | reg = mmread(MANTIS_UART_BAUD); | ||
116 | |||
117 | switch (params->baud_rate) { | ||
118 | case MANTIS_BAUD_9600: | ||
119 | reg |= 0xd8; | ||
120 | break; | ||
121 | case MANTIS_BAUD_19200: | ||
122 | reg |= 0x6c; | ||
123 | break; | ||
124 | case MANTIS_BAUD_38400: | ||
125 | reg |= 0x36; | ||
126 | break; | ||
127 | case MANTIS_BAUD_57600: | ||
128 | reg |= 0x23; | ||
129 | break; | ||
130 | case MANTIS_BAUD_115200: | ||
131 | reg |= 0x11; | ||
132 | break; | ||
133 | default: | ||
134 | return -EINVAL; | ||
135 | } | ||
136 | |||
137 | mmwrite(reg, MANTIS_UART_BAUD); | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | int mantis_uart_init(struct mantis_pci *mantis) | ||
143 | { | ||
144 | struct mantis_hwconfig *config = mantis->hwconfig; | ||
145 | struct mantis_uart_params params; | ||
146 | |||
147 | /* default parity: */ | ||
148 | params.baud_rate = config->baud_rate; | ||
149 | params.parity = config->parity; | ||
150 | dprintk(MANTIS_INFO, 1, "Initializing UART @ %sbps parity:%s", | ||
151 | rates[params.baud_rate].string, | ||
152 | parity[params.parity].string); | ||
153 | |||
154 | init_waitqueue_head(&mantis->uart_wq); | ||
155 | spin_lock_init(&mantis->uart_lock); | ||
156 | |||
157 | INIT_WORK(&mantis->uart_work, mantis_uart_work); | ||
158 | |||
159 | /* disable interrupt */ | ||
160 | mmwrite(mmread(MANTIS_UART_CTL) & 0xffef, MANTIS_UART_CTL); | ||
161 | |||
162 | mantis_uart_setup(mantis, ¶ms); | ||
163 | |||
164 | /* default 1 byte */ | ||
165 | mmwrite((mmread(MANTIS_UART_BAUD) | (config->bytes << 8)), MANTIS_UART_BAUD); | ||
166 | |||
167 | /* flush buffer */ | ||
168 | mmwrite((mmread(MANTIS_UART_CTL) | MANTIS_UART_RXFLUSH), MANTIS_UART_CTL); | ||
169 | |||
170 | /* enable interrupt */ | ||
171 | mmwrite(mmread(MANTIS_INT_MASK) | 0x800, MANTIS_INT_MASK); | ||
172 | mmwrite(mmread(MANTIS_UART_CTL) | MANTIS_UART_RXINT, MANTIS_UART_CTL); | ||
173 | |||
174 | schedule_work(&mantis->uart_work); | ||
175 | dprintk(MANTIS_DEBUG, 1, "UART succesfully initialized"); | ||
176 | |||
177 | return 0; | ||
178 | } | ||
179 | EXPORT_SYMBOL_GPL(mantis_uart_init); | ||
180 | |||
181 | void mantis_uart_exit(struct mantis_pci *mantis) | ||
182 | { | ||
183 | /* disable interrupt */ | ||
184 | mmwrite(mmread(MANTIS_UART_CTL) & 0xffef, MANTIS_UART_CTL); | ||
185 | } | ||
186 | EXPORT_SYMBOL_GPL(mantis_uart_exit); | ||
diff --git a/drivers/media/dvb/mantis/mantis_uart.h b/drivers/media/dvb/mantis/mantis_uart.h new file mode 100644 index 000000000000..ffb62a0a5a13 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_uart.h | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | Mantis 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 | #ifndef __MANTIS_UART_H | ||
22 | #define __MANTIS_UART_H | ||
23 | |||
24 | #define MANTIS_UART_CTL 0xe0 | ||
25 | #define MANTIS_UART_RXINT (1 << 4) | ||
26 | #define MANTIS_UART_RXFLUSH (1 << 2) | ||
27 | |||
28 | #define MANTIS_UART_RXD 0xe8 | ||
29 | #define MANTIS_UART_BAUD 0xec | ||
30 | |||
31 | #define MANTIS_UART_STAT 0xf0 | ||
32 | #define MANTIS_UART_RXFIFO_DATA (1 << 7) | ||
33 | #define MANTIS_UART_RXFIFO_EMPTY (1 << 6) | ||
34 | #define MANTIS_UART_RXFIFO_FULL (1 << 3) | ||
35 | #define MANTIS_UART_FRAME_ERR (1 << 2) | ||
36 | #define MANTIS_UART_PARITY_ERR (1 << 1) | ||
37 | #define MANTIS_UART_RXTHRESH_INT (1 << 0) | ||
38 | |||
39 | enum mantis_baud { | ||
40 | MANTIS_BAUD_9600 = 0, | ||
41 | MANTIS_BAUD_19200, | ||
42 | MANTIS_BAUD_38400, | ||
43 | MANTIS_BAUD_57600, | ||
44 | MANTIS_BAUD_115200 | ||
45 | }; | ||
46 | |||
47 | enum mantis_parity { | ||
48 | MANTIS_PARITY_NONE = 0, | ||
49 | MANTIS_PARITY_EVEN, | ||
50 | MANTIS_PARITY_ODD, | ||
51 | }; | ||
52 | |||
53 | struct mantis_pci; | ||
54 | |||
55 | extern int mantis_uart_init(struct mantis_pci *mantis); | ||
56 | extern void mantis_uart_exit(struct mantis_pci *mantis); | ||
57 | |||
58 | #endif /* __MANTIS_UART_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp1033.c b/drivers/media/dvb/mantis/mantis_vp1033.c new file mode 100644 index 000000000000..4a723bda0031 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp1033.c | |||
@@ -0,0 +1,212 @@ | |||
1 | /* | ||
2 | Mantis VP-1033 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/signal.h> | ||
22 | #include <linux/sched.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | |||
25 | #include "dmxdev.h" | ||
26 | #include "dvbdev.h" | ||
27 | #include "dvb_demux.h" | ||
28 | #include "dvb_frontend.h" | ||
29 | #include "dvb_net.h" | ||
30 | |||
31 | #include "stv0299.h" | ||
32 | #include "mantis_common.h" | ||
33 | #include "mantis_ioc.h" | ||
34 | #include "mantis_dvb.h" | ||
35 | #include "mantis_vp1033.h" | ||
36 | #include "mantis_reg.h" | ||
37 | |||
38 | u8 lgtdqcs001f_inittab[] = { | ||
39 | 0x01, 0x15, | ||
40 | 0x02, 0x00, | ||
41 | 0x03, 0x00, | ||
42 | 0x04, 0x2a, | ||
43 | 0x05, 0x85, | ||
44 | 0x06, 0x02, | ||
45 | 0x07, 0x00, | ||
46 | 0x08, 0x00, | ||
47 | 0x0c, 0x01, | ||
48 | 0x0d, 0x81, | ||
49 | 0x0e, 0x44, | ||
50 | 0x0f, 0x94, | ||
51 | 0x10, 0x3c, | ||
52 | 0x11, 0x84, | ||
53 | 0x12, 0xb9, | ||
54 | 0x13, 0xb5, | ||
55 | 0x14, 0x4f, | ||
56 | 0x15, 0xc9, | ||
57 | 0x16, 0x80, | ||
58 | 0x17, 0x36, | ||
59 | 0x18, 0xfb, | ||
60 | 0x19, 0xcf, | ||
61 | 0x1a, 0xbc, | ||
62 | 0x1c, 0x2b, | ||
63 | 0x1d, 0x27, | ||
64 | 0x1e, 0x00, | ||
65 | 0x1f, 0x0b, | ||
66 | 0x20, 0xa1, | ||
67 | 0x21, 0x60, | ||
68 | 0x22, 0x00, | ||
69 | 0x23, 0x00, | ||
70 | 0x28, 0x00, | ||
71 | 0x29, 0x28, | ||
72 | 0x2a, 0x14, | ||
73 | 0x2b, 0x0f, | ||
74 | 0x2c, 0x09, | ||
75 | 0x2d, 0x05, | ||
76 | 0x31, 0x1f, | ||
77 | 0x32, 0x19, | ||
78 | 0x33, 0xfc, | ||
79 | 0x34, 0x13, | ||
80 | 0xff, 0xff, | ||
81 | }; | ||
82 | |||
83 | #define MANTIS_MODEL_NAME "VP-1033" | ||
84 | #define MANTIS_DEV_TYPE "DVB-S/DSS" | ||
85 | |||
86 | int lgtdqcs001f_tuner_set(struct dvb_frontend *fe, | ||
87 | struct dvb_frontend_parameters *params) | ||
88 | { | ||
89 | struct mantis_pci *mantis = fe->dvb->priv; | ||
90 | struct i2c_adapter *adapter = &mantis->adapter; | ||
91 | |||
92 | u8 buf[4]; | ||
93 | u32 div; | ||
94 | |||
95 | |||
96 | struct i2c_msg msg = {.addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf)}; | ||
97 | |||
98 | div = params->frequency / 250; | ||
99 | |||
100 | buf[0] = (div >> 8) & 0x7f; | ||
101 | buf[1] = div & 0xff; | ||
102 | buf[2] = 0x83; | ||
103 | buf[3] = 0xc0; | ||
104 | |||
105 | if (params->frequency < 1531000) | ||
106 | buf[3] |= 0x04; | ||
107 | else | ||
108 | buf[3] &= ~0x04; | ||
109 | if (i2c_transfer(adapter, &msg, 1) < 0) { | ||
110 | dprintk(MANTIS_ERROR, 1, "Write: I2C Transfer failed"); | ||
111 | return -EIO; | ||
112 | } | ||
113 | msleep_interruptible(100); | ||
114 | |||
115 | return 0; | ||
116 | } | ||
117 | |||
118 | int lgtdqcs001f_set_symbol_rate(struct dvb_frontend *fe, | ||
119 | u32 srate, u32 ratio) | ||
120 | { | ||
121 | u8 aclk = 0; | ||
122 | u8 bclk = 0; | ||
123 | |||
124 | if (srate < 1500000) { | ||
125 | aclk = 0xb7; | ||
126 | bclk = 0x47; | ||
127 | } else if (srate < 3000000) { | ||
128 | aclk = 0xb7; | ||
129 | bclk = 0x4b; | ||
130 | } else if (srate < 7000000) { | ||
131 | aclk = 0xb7; | ||
132 | bclk = 0x4f; | ||
133 | } else if (srate < 14000000) { | ||
134 | aclk = 0xb7; | ||
135 | bclk = 0x53; | ||
136 | } else if (srate < 30000000) { | ||
137 | aclk = 0xb6; | ||
138 | bclk = 0x53; | ||
139 | } else if (srate < 45000000) { | ||
140 | aclk = 0xb4; | ||
141 | bclk = 0x51; | ||
142 | } | ||
143 | stv0299_writereg(fe, 0x13, aclk); | ||
144 | stv0299_writereg(fe, 0x14, bclk); | ||
145 | |||
146 | stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff); | ||
147 | stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff); | ||
148 | stv0299_writereg(fe, 0x21, ratio & 0xf0); | ||
149 | |||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | struct stv0299_config lgtdqcs001f_config = { | ||
154 | .demod_address = 0x68, | ||
155 | .inittab = lgtdqcs001f_inittab, | ||
156 | .mclk = 88000000UL, | ||
157 | .invert = 0, | ||
158 | .skip_reinit = 0, | ||
159 | .volt13_op0_op1 = STV0299_VOLT13_OP0, | ||
160 | .min_delay_ms = 100, | ||
161 | .set_symbol_rate = lgtdqcs001f_set_symbol_rate, | ||
162 | }; | ||
163 | |||
164 | static int vp1033_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe) | ||
165 | { | ||
166 | struct i2c_adapter *adapter = &mantis->adapter; | ||
167 | |||
168 | int err = 0; | ||
169 | |||
170 | err = mantis_frontend_power(mantis, POWER_ON); | ||
171 | if (err == 0) { | ||
172 | mantis_frontend_soft_reset(mantis); | ||
173 | msleep(250); | ||
174 | |||
175 | dprintk(MANTIS_ERROR, 1, "Probing for STV0299 (DVB-S)"); | ||
176 | fe = stv0299_attach(&lgtdqcs001f_config, adapter); | ||
177 | |||
178 | if (fe) { | ||
179 | fe->ops.tuner_ops.set_params = lgtdqcs001f_tuner_set; | ||
180 | dprintk(MANTIS_ERROR, 1, "found STV0299 DVB-S frontend @ 0x%02x", | ||
181 | lgtdqcs001f_config.demod_address); | ||
182 | |||
183 | dprintk(MANTIS_ERROR, 1, "Mantis DVB-S STV0299 frontend attach success"); | ||
184 | } else { | ||
185 | return -1; | ||
186 | } | ||
187 | } else { | ||
188 | dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>", | ||
189 | adapter->name, | ||
190 | err); | ||
191 | |||
192 | return -EIO; | ||
193 | } | ||
194 | mantis->fe = fe; | ||
195 | dprintk(MANTIS_ERROR, 1, "Done!"); | ||
196 | |||
197 | return 0; | ||
198 | } | ||
199 | |||
200 | struct mantis_hwconfig vp1033_config = { | ||
201 | .model_name = MANTIS_MODEL_NAME, | ||
202 | .dev_type = MANTIS_DEV_TYPE, | ||
203 | .ts_size = MANTIS_TS_204, | ||
204 | |||
205 | .baud_rate = MANTIS_BAUD_9600, | ||
206 | .parity = MANTIS_PARITY_NONE, | ||
207 | .bytes = 0, | ||
208 | |||
209 | .frontend_init = vp1033_frontend_init, | ||
210 | .power = GPIF_A12, | ||
211 | .reset = GPIF_A13, | ||
212 | }; | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp1033.h b/drivers/media/dvb/mantis/mantis_vp1033.h new file mode 100644 index 000000000000..7daaa1bf127d --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp1033.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | Mantis VP-1033 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 | #ifndef __MANTIS_VP1033_H | ||
22 | #define __MANTIS_VP1033_H | ||
23 | |||
24 | #include "mantis_common.h" | ||
25 | |||
26 | #define MANTIS_VP_1033_DVB_S 0x0016 | ||
27 | |||
28 | extern struct mantis_hwconfig vp1033_config; | ||
29 | |||
30 | #endif /* __MANTIS_VP1033_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp1034.c b/drivers/media/dvb/mantis/mantis_vp1034.c new file mode 100644 index 000000000000..8e6ae558ee57 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp1034.c | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | Mantis VP-1034 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/signal.h> | ||
22 | #include <linux/sched.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | |||
25 | #include "dmxdev.h" | ||
26 | #include "dvbdev.h" | ||
27 | #include "dvb_demux.h" | ||
28 | #include "dvb_frontend.h" | ||
29 | #include "dvb_net.h" | ||
30 | |||
31 | #include "mb86a16.h" | ||
32 | #include "mantis_common.h" | ||
33 | #include "mantis_ioc.h" | ||
34 | #include "mantis_dvb.h" | ||
35 | #include "mantis_vp1034.h" | ||
36 | #include "mantis_reg.h" | ||
37 | |||
38 | struct mb86a16_config vp1034_mb86a16_config = { | ||
39 | .demod_address = 0x08, | ||
40 | .set_voltage = vp1034_set_voltage, | ||
41 | }; | ||
42 | |||
43 | #define MANTIS_MODEL_NAME "VP-1034" | ||
44 | #define MANTIS_DEV_TYPE "DVB-S/DSS" | ||
45 | |||
46 | int vp1034_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) | ||
47 | { | ||
48 | struct mantis_pci *mantis = fe->dvb->priv; | ||
49 | |||
50 | switch (voltage) { | ||
51 | case SEC_VOLTAGE_13: | ||
52 | dprintk(MANTIS_ERROR, 1, "Polarization=[13V]"); | ||
53 | gpio_set_bits(mantis, 13, 1); | ||
54 | gpio_set_bits(mantis, 14, 0); | ||
55 | break; | ||
56 | case SEC_VOLTAGE_18: | ||
57 | dprintk(MANTIS_ERROR, 1, "Polarization=[18V]"); | ||
58 | gpio_set_bits(mantis, 13, 1); | ||
59 | gpio_set_bits(mantis, 14, 1); | ||
60 | break; | ||
61 | case SEC_VOLTAGE_OFF: | ||
62 | dprintk(MANTIS_ERROR, 1, "Frontend (dummy) POWERDOWN"); | ||
63 | break; | ||
64 | default: | ||
65 | dprintk(MANTIS_ERROR, 1, "Invalid = (%d)", (u32) voltage); | ||
66 | return -EINVAL; | ||
67 | } | ||
68 | mmwrite(0x00, MANTIS_GPIF_DOUT); | ||
69 | |||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | static int vp1034_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe) | ||
74 | { | ||
75 | struct i2c_adapter *adapter = &mantis->adapter; | ||
76 | |||
77 | int err = 0; | ||
78 | |||
79 | err = mantis_frontend_power(mantis, POWER_ON); | ||
80 | if (err == 0) { | ||
81 | mantis_frontend_soft_reset(mantis); | ||
82 | msleep(250); | ||
83 | |||
84 | dprintk(MANTIS_ERROR, 1, "Probing for MB86A16 (DVB-S/DSS)"); | ||
85 | fe = mb86a16_attach(&vp1034_mb86a16_config, adapter); | ||
86 | if (fe) { | ||
87 | dprintk(MANTIS_ERROR, 1, | ||
88 | "found MB86A16 DVB-S/DSS frontend @0x%02x", | ||
89 | vp1034_mb86a16_config.demod_address); | ||
90 | |||
91 | } else { | ||
92 | return -1; | ||
93 | } | ||
94 | } else { | ||
95 | dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>", | ||
96 | adapter->name, | ||
97 | err); | ||
98 | |||
99 | return -EIO; | ||
100 | } | ||
101 | mantis->fe = fe; | ||
102 | dprintk(MANTIS_ERROR, 1, "Done!"); | ||
103 | |||
104 | return 0; | ||
105 | } | ||
106 | |||
107 | struct mantis_hwconfig vp1034_config = { | ||
108 | .model_name = MANTIS_MODEL_NAME, | ||
109 | .dev_type = MANTIS_DEV_TYPE, | ||
110 | .ts_size = MANTIS_TS_204, | ||
111 | |||
112 | .baud_rate = MANTIS_BAUD_9600, | ||
113 | .parity = MANTIS_PARITY_NONE, | ||
114 | .bytes = 0, | ||
115 | |||
116 | .frontend_init = vp1034_frontend_init, | ||
117 | .power = GPIF_A12, | ||
118 | .reset = GPIF_A13, | ||
119 | }; | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp1034.h b/drivers/media/dvb/mantis/mantis_vp1034.h new file mode 100644 index 000000000000..323f38ef8e3d --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp1034.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | Mantis VP-1034 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 | #ifndef __MANTIS_VP1034_H | ||
22 | #define __MANTIS_VP1034_H | ||
23 | |||
24 | #include "dvb_frontend.h" | ||
25 | #include "mantis_common.h" | ||
26 | |||
27 | |||
28 | #define MANTIS_VP_1034_DVB_S 0x0014 | ||
29 | |||
30 | extern struct mantis_hwconfig vp1034_config; | ||
31 | extern int vp1034_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage); | ||
32 | |||
33 | #endif /* __MANTIS_VP1034_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp1041.c b/drivers/media/dvb/mantis/mantis_vp1041.c new file mode 100644 index 000000000000..515346dd31d0 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp1041.c | |||
@@ -0,0 +1,358 @@ | |||
1 | /* | ||
2 | Mantis VP-1041 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/signal.h> | ||
22 | #include <linux/sched.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | |||
25 | #include "dmxdev.h" | ||
26 | #include "dvbdev.h" | ||
27 | #include "dvb_demux.h" | ||
28 | #include "dvb_frontend.h" | ||
29 | #include "dvb_net.h" | ||
30 | |||
31 | #include "mantis_common.h" | ||
32 | #include "mantis_ioc.h" | ||
33 | #include "mantis_dvb.h" | ||
34 | #include "mantis_vp1041.h" | ||
35 | #include "stb0899_reg.h" | ||
36 | #include "stb0899_drv.h" | ||
37 | #include "stb0899_cfg.h" | ||
38 | #include "stb6100_cfg.h" | ||
39 | #include "stb6100.h" | ||
40 | #include "lnbp21.h" | ||
41 | |||
42 | #define MANTIS_MODEL_NAME "VP-1041" | ||
43 | #define MANTIS_DEV_TYPE "DSS/DVB-S/DVB-S2" | ||
44 | |||
45 | static const struct stb0899_s1_reg vp1041_stb0899_s1_init_1[] = { | ||
46 | |||
47 | /* 0x0000000b, *//* SYSREG */ | ||
48 | { STB0899_DEV_ID , 0x30 }, | ||
49 | { STB0899_DISCNTRL1 , 0x32 }, | ||
50 | { STB0899_DISCNTRL2 , 0x80 }, | ||
51 | { STB0899_DISRX_ST0 , 0x04 }, | ||
52 | { STB0899_DISRX_ST1 , 0x00 }, | ||
53 | { STB0899_DISPARITY , 0x00 }, | ||
54 | { STB0899_DISFIFO , 0x00 }, | ||
55 | { STB0899_DISSTATUS , 0x20 }, | ||
56 | { STB0899_DISF22 , 0x99 }, | ||
57 | { STB0899_DISF22RX , 0xa8 }, | ||
58 | /* SYSREG ? */ | ||
59 | { STB0899_ACRPRESC , 0x11 }, | ||
60 | { STB0899_ACRDIV1 , 0x0a }, | ||
61 | { STB0899_ACRDIV2 , 0x05 }, | ||
62 | { STB0899_DACR1 , 0x00 }, | ||
63 | { STB0899_DACR2 , 0x00 }, | ||
64 | { STB0899_OUTCFG , 0x00 }, | ||
65 | { STB0899_MODECFG , 0x00 }, | ||
66 | { STB0899_IRQSTATUS_3 , 0xfe }, | ||
67 | { STB0899_IRQSTATUS_2 , 0x03 }, | ||
68 | { STB0899_IRQSTATUS_1 , 0x7c }, | ||
69 | { STB0899_IRQSTATUS_0 , 0xf4 }, | ||
70 | { STB0899_IRQMSK_3 , 0xf3 }, | ||
71 | { STB0899_IRQMSK_2 , 0xfc }, | ||
72 | { STB0899_IRQMSK_1 , 0xff }, | ||
73 | { STB0899_IRQMSK_0 , 0xff }, | ||
74 | { STB0899_IRQCFG , 0x00 }, | ||
75 | { STB0899_I2CCFG , 0x88 }, | ||
76 | { STB0899_I2CRPT , 0x58 }, | ||
77 | { STB0899_IOPVALUE5 , 0x00 }, | ||
78 | { STB0899_IOPVALUE4 , 0x33 }, | ||
79 | { STB0899_IOPVALUE3 , 0x6d }, | ||
80 | { STB0899_IOPVALUE2 , 0x90 }, | ||
81 | { STB0899_IOPVALUE1 , 0x60 }, | ||
82 | { STB0899_IOPVALUE0 , 0x00 }, | ||
83 | { STB0899_GPIO00CFG , 0x82 }, | ||
84 | { STB0899_GPIO01CFG , 0x82 }, | ||
85 | { STB0899_GPIO02CFG , 0x82 }, | ||
86 | { STB0899_GPIO03CFG , 0x82 }, | ||
87 | { STB0899_GPIO04CFG , 0x82 }, | ||
88 | { STB0899_GPIO05CFG , 0x82 }, | ||
89 | { STB0899_GPIO06CFG , 0x82 }, | ||
90 | { STB0899_GPIO07CFG , 0x82 }, | ||
91 | { STB0899_GPIO08CFG , 0x82 }, | ||
92 | { STB0899_GPIO09CFG , 0x82 }, | ||
93 | { STB0899_GPIO10CFG , 0x82 }, | ||
94 | { STB0899_GPIO11CFG , 0x82 }, | ||
95 | { STB0899_GPIO12CFG , 0x82 }, | ||
96 | { STB0899_GPIO13CFG , 0x82 }, | ||
97 | { STB0899_GPIO14CFG , 0x82 }, | ||
98 | { STB0899_GPIO15CFG , 0x82 }, | ||
99 | { STB0899_GPIO16CFG , 0x82 }, | ||
100 | { STB0899_GPIO17CFG , 0x82 }, | ||
101 | { STB0899_GPIO18CFG , 0x82 }, | ||
102 | { STB0899_GPIO19CFG , 0x82 }, | ||
103 | { STB0899_GPIO20CFG , 0x82 }, | ||
104 | { STB0899_SDATCFG , 0xb8 }, | ||
105 | { STB0899_SCLTCFG , 0xba }, | ||
106 | { STB0899_AGCRFCFG , 0x1c }, /* 0x11 */ | ||
107 | { STB0899_GPIO22 , 0x82 }, /* AGCBB2CFG */ | ||
108 | { STB0899_GPIO21 , 0x91 }, /* AGCBB1CFG */ | ||
109 | { STB0899_DIRCLKCFG , 0x82 }, | ||
110 | { STB0899_CLKOUT27CFG , 0x7e }, | ||
111 | { STB0899_STDBYCFG , 0x82 }, | ||
112 | { STB0899_CS0CFG , 0x82 }, | ||
113 | { STB0899_CS1CFG , 0x82 }, | ||
114 | { STB0899_DISEQCOCFG , 0x20 }, | ||
115 | { STB0899_GPIO32CFG , 0x82 }, | ||
116 | { STB0899_GPIO33CFG , 0x82 }, | ||
117 | { STB0899_GPIO34CFG , 0x82 }, | ||
118 | { STB0899_GPIO35CFG , 0x82 }, | ||
119 | { STB0899_GPIO36CFG , 0x82 }, | ||
120 | { STB0899_GPIO37CFG , 0x82 }, | ||
121 | { STB0899_GPIO38CFG , 0x82 }, | ||
122 | { STB0899_GPIO39CFG , 0x82 }, | ||
123 | { STB0899_NCOARSE , 0x17 }, /* 0x15 = 27 Mhz Clock, F/3 = 198MHz, F/6 = 99MHz */ | ||
124 | { STB0899_SYNTCTRL , 0x02 }, /* 0x00 = CLK from CLKI, 0x02 = CLK from XTALI */ | ||
125 | { STB0899_FILTCTRL , 0x00 }, | ||
126 | { STB0899_SYSCTRL , 0x01 }, | ||
127 | { STB0899_STOPCLK1 , 0x20 }, | ||
128 | { STB0899_STOPCLK2 , 0x00 }, | ||
129 | { STB0899_INTBUFSTATUS , 0x00 }, | ||
130 | { STB0899_INTBUFCTRL , 0x0a }, | ||
131 | { 0xffff , 0xff }, | ||
132 | }; | ||
133 | |||
134 | static const struct stb0899_s1_reg vp1041_stb0899_s1_init_3[] = { | ||
135 | { STB0899_DEMOD , 0x00 }, | ||
136 | { STB0899_RCOMPC , 0xc9 }, | ||
137 | { STB0899_AGC1CN , 0x01 }, | ||
138 | { STB0899_AGC1REF , 0x10 }, | ||
139 | { STB0899_RTC , 0x23 }, | ||
140 | { STB0899_TMGCFG , 0x4e }, | ||
141 | { STB0899_AGC2REF , 0x34 }, | ||
142 | { STB0899_TLSR , 0x84 }, | ||
143 | { STB0899_CFD , 0xf7 }, | ||
144 | { STB0899_ACLC , 0x87 }, | ||
145 | { STB0899_BCLC , 0x94 }, | ||
146 | { STB0899_EQON , 0x41 }, | ||
147 | { STB0899_LDT , 0xf1 }, | ||
148 | { STB0899_LDT2 , 0xe3 }, | ||
149 | { STB0899_EQUALREF , 0xb4 }, | ||
150 | { STB0899_TMGRAMP , 0x10 }, | ||
151 | { STB0899_TMGTHD , 0x30 }, | ||
152 | { STB0899_IDCCOMP , 0xfd }, | ||
153 | { STB0899_QDCCOMP , 0xff }, | ||
154 | { STB0899_POWERI , 0x0c }, | ||
155 | { STB0899_POWERQ , 0x0f }, | ||
156 | { STB0899_RCOMP , 0x6c }, | ||
157 | { STB0899_AGCIQIN , 0x80 }, | ||
158 | { STB0899_AGC2I1 , 0x06 }, | ||
159 | { STB0899_AGC2I2 , 0x00 }, | ||
160 | { STB0899_TLIR , 0x30 }, | ||
161 | { STB0899_RTF , 0x7f }, | ||
162 | { STB0899_DSTATUS , 0x00 }, | ||
163 | { STB0899_LDI , 0xbc }, | ||
164 | { STB0899_CFRM , 0xea }, | ||
165 | { STB0899_CFRL , 0x31 }, | ||
166 | { STB0899_NIRM , 0x2b }, | ||
167 | { STB0899_NIRL , 0x80 }, | ||
168 | { STB0899_ISYMB , 0x1d }, | ||
169 | { STB0899_QSYMB , 0xa6 }, | ||
170 | { STB0899_SFRH , 0x2f }, | ||
171 | { STB0899_SFRM , 0x68 }, | ||
172 | { STB0899_SFRL , 0x40 }, | ||
173 | { STB0899_SFRUPH , 0x2f }, | ||
174 | { STB0899_SFRUPM , 0x68 }, | ||
175 | { STB0899_SFRUPL , 0x40 }, | ||
176 | { STB0899_EQUAI1 , 0x02 }, | ||
177 | { STB0899_EQUAQ1 , 0xff }, | ||
178 | { STB0899_EQUAI2 , 0x04 }, | ||
179 | { STB0899_EQUAQ2 , 0x05 }, | ||
180 | { STB0899_EQUAI3 , 0x02 }, | ||
181 | { STB0899_EQUAQ3 , 0xfd }, | ||
182 | { STB0899_EQUAI4 , 0x03 }, | ||
183 | { STB0899_EQUAQ4 , 0x07 }, | ||
184 | { STB0899_EQUAI5 , 0x08 }, | ||
185 | { STB0899_EQUAQ5 , 0xf5 }, | ||
186 | { STB0899_DSTATUS2 , 0x00 }, | ||
187 | { STB0899_VSTATUS , 0x00 }, | ||
188 | { STB0899_VERROR , 0x86 }, | ||
189 | { STB0899_IQSWAP , 0x2a }, | ||
190 | { STB0899_ECNT1M , 0x00 }, | ||
191 | { STB0899_ECNT1L , 0x00 }, | ||
192 | { STB0899_ECNT2M , 0x00 }, | ||
193 | { STB0899_ECNT2L , 0x00 }, | ||
194 | { STB0899_ECNT3M , 0x0a }, | ||
195 | { STB0899_ECNT3L , 0xad }, | ||
196 | { STB0899_FECAUTO1 , 0x06 }, | ||
197 | { STB0899_FECM , 0x01 }, | ||
198 | { STB0899_VTH12 , 0xb0 }, | ||
199 | { STB0899_VTH23 , 0x7a }, | ||
200 | { STB0899_VTH34 , 0x58 }, | ||
201 | { STB0899_VTH56 , 0x38 }, | ||
202 | { STB0899_VTH67 , 0x34 }, | ||
203 | { STB0899_VTH78 , 0x24 }, | ||
204 | { STB0899_PRVIT , 0xff }, | ||
205 | { STB0899_VITSYNC , 0x19 }, | ||
206 | { STB0899_RSULC , 0xb1 }, /* DVB = 0xb1, DSS = 0xa1 */ | ||
207 | { STB0899_TSULC , 0x42 }, | ||
208 | { STB0899_RSLLC , 0x41 }, | ||
209 | { STB0899_TSLPL , 0x12 }, | ||
210 | { STB0899_TSCFGH , 0x0c }, | ||
211 | { STB0899_TSCFGM , 0x00 }, | ||
212 | { STB0899_TSCFGL , 0x00 }, | ||
213 | { STB0899_TSOUT , 0x69 }, /* 0x0d for CAM */ | ||
214 | { STB0899_RSSYNCDEL , 0x00 }, | ||
215 | { STB0899_TSINHDELH , 0x02 }, | ||
216 | { STB0899_TSINHDELM , 0x00 }, | ||
217 | { STB0899_TSINHDELL , 0x00 }, | ||
218 | { STB0899_TSLLSTKM , 0x1b }, | ||
219 | { STB0899_TSLLSTKL , 0xb3 }, | ||
220 | { STB0899_TSULSTKM , 0x00 }, | ||
221 | { STB0899_TSULSTKL , 0x00 }, | ||
222 | { STB0899_PCKLENUL , 0xbc }, | ||
223 | { STB0899_PCKLENLL , 0xcc }, | ||
224 | { STB0899_RSPCKLEN , 0xbd }, | ||
225 | { STB0899_TSSTATUS , 0x90 }, | ||
226 | { STB0899_ERRCTRL1 , 0xb6 }, | ||
227 | { STB0899_ERRCTRL2 , 0x95 }, | ||
228 | { STB0899_ERRCTRL3 , 0x8d }, | ||
229 | { STB0899_DMONMSK1 , 0x27 }, | ||
230 | { STB0899_DMONMSK0 , 0x03 }, | ||
231 | { STB0899_DEMAPVIT , 0x5c }, | ||
232 | { STB0899_PLPARM , 0x19 }, | ||
233 | { STB0899_PDELCTRL , 0x48 }, | ||
234 | { STB0899_PDELCTRL2 , 0x00 }, | ||
235 | { STB0899_BBHCTRL1 , 0x00 }, | ||
236 | { STB0899_BBHCTRL2 , 0x00 }, | ||
237 | { STB0899_HYSTTHRESH , 0x77 }, | ||
238 | { STB0899_MATCSTM , 0x00 }, | ||
239 | { STB0899_MATCSTL , 0x00 }, | ||
240 | { STB0899_UPLCSTM , 0x00 }, | ||
241 | { STB0899_UPLCSTL , 0x00 }, | ||
242 | { STB0899_DFLCSTM , 0x00 }, | ||
243 | { STB0899_DFLCSTL , 0x00 }, | ||
244 | { STB0899_SYNCCST , 0x00 }, | ||
245 | { STB0899_SYNCDCSTM , 0x00 }, | ||
246 | { STB0899_SYNCDCSTL , 0x00 }, | ||
247 | { STB0899_ISI_ENTRY , 0x00 }, | ||
248 | { STB0899_ISI_BIT_EN , 0x00 }, | ||
249 | { STB0899_MATSTRM , 0xf0 }, | ||
250 | { STB0899_MATSTRL , 0x02 }, | ||
251 | { STB0899_UPLSTRM , 0x45 }, | ||
252 | { STB0899_UPLSTRL , 0x60 }, | ||
253 | { STB0899_DFLSTRM , 0xe3 }, | ||
254 | { STB0899_DFLSTRL , 0x00 }, | ||
255 | { STB0899_SYNCSTR , 0x47 }, | ||
256 | { STB0899_SYNCDSTRM , 0x05 }, | ||
257 | { STB0899_SYNCDSTRL , 0x18 }, | ||
258 | { STB0899_CFGPDELSTATUS1 , 0x19 }, | ||
259 | { STB0899_CFGPDELSTATUS2 , 0x2b }, | ||
260 | { STB0899_BBFERRORM , 0x00 }, | ||
261 | { STB0899_BBFERRORL , 0x01 }, | ||
262 | { STB0899_UPKTERRORM , 0x00 }, | ||
263 | { STB0899_UPKTERRORL , 0x00 }, | ||
264 | { 0xffff , 0xff }, | ||
265 | }; | ||
266 | |||
267 | struct stb0899_config vp1041_stb0899_config = { | ||
268 | .init_dev = vp1041_stb0899_s1_init_1, | ||
269 | .init_s2_demod = stb0899_s2_init_2, | ||
270 | .init_s1_demod = vp1041_stb0899_s1_init_3, | ||
271 | .init_s2_fec = stb0899_s2_init_4, | ||
272 | .init_tst = stb0899_s1_init_5, | ||
273 | |||
274 | .demod_address = 0x68, /* 0xd0 >> 1 */ | ||
275 | |||
276 | .xtal_freq = 27000000, | ||
277 | .inversion = IQ_SWAP_ON, /* 1 */ | ||
278 | |||
279 | .lo_clk = 76500000, | ||
280 | .hi_clk = 99000000, | ||
281 | |||
282 | .esno_ave = STB0899_DVBS2_ESNO_AVE, | ||
283 | .esno_quant = STB0899_DVBS2_ESNO_QUANT, | ||
284 | .avframes_coarse = STB0899_DVBS2_AVFRAMES_COARSE, | ||
285 | .avframes_fine = STB0899_DVBS2_AVFRAMES_FINE, | ||
286 | .miss_threshold = STB0899_DVBS2_MISS_THRESHOLD, | ||
287 | .uwp_threshold_acq = STB0899_DVBS2_UWP_THRESHOLD_ACQ, | ||
288 | .uwp_threshold_track = STB0899_DVBS2_UWP_THRESHOLD_TRACK, | ||
289 | .uwp_threshold_sof = STB0899_DVBS2_UWP_THRESHOLD_SOF, | ||
290 | .sof_search_timeout = STB0899_DVBS2_SOF_SEARCH_TIMEOUT, | ||
291 | |||
292 | .btr_nco_bits = STB0899_DVBS2_BTR_NCO_BITS, | ||
293 | .btr_gain_shift_offset = STB0899_DVBS2_BTR_GAIN_SHIFT_OFFSET, | ||
294 | .crl_nco_bits = STB0899_DVBS2_CRL_NCO_BITS, | ||
295 | .ldpc_max_iter = STB0899_DVBS2_LDPC_MAX_ITER, | ||
296 | |||
297 | .tuner_get_frequency = stb6100_get_frequency, | ||
298 | .tuner_set_frequency = stb6100_set_frequency, | ||
299 | .tuner_set_bandwidth = stb6100_set_bandwidth, | ||
300 | .tuner_get_bandwidth = stb6100_get_bandwidth, | ||
301 | .tuner_set_rfsiggain = NULL, | ||
302 | }; | ||
303 | |||
304 | struct stb6100_config vp1041_stb6100_config = { | ||
305 | .tuner_address = 0x60, | ||
306 | .refclock = 27000000, | ||
307 | }; | ||
308 | |||
309 | static int vp1041_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe) | ||
310 | { | ||
311 | struct i2c_adapter *adapter = &mantis->adapter; | ||
312 | |||
313 | int err = 0; | ||
314 | |||
315 | err = mantis_frontend_power(mantis, POWER_ON); | ||
316 | if (err == 0) { | ||
317 | mantis_frontend_soft_reset(mantis); | ||
318 | msleep(250); | ||
319 | mantis->fe = stb0899_attach(&vp1041_stb0899_config, adapter); | ||
320 | if (mantis->fe) { | ||
321 | dprintk(MANTIS_ERROR, 1, | ||
322 | "found STB0899 DVB-S/DVB-S2 frontend @0x%02x", | ||
323 | vp1041_stb0899_config.demod_address); | ||
324 | |||
325 | if (stb6100_attach(mantis->fe, &vp1041_stb6100_config, adapter)) { | ||
326 | if (!lnbp21_attach(mantis->fe, adapter, 0, 0)) | ||
327 | dprintk(MANTIS_ERROR, 1, "No LNBP21 found!"); | ||
328 | } | ||
329 | } else { | ||
330 | return -EREMOTEIO; | ||
331 | } | ||
332 | } else { | ||
333 | dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>", | ||
334 | adapter->name, | ||
335 | err); | ||
336 | |||
337 | return -EIO; | ||
338 | } | ||
339 | |||
340 | |||
341 | dprintk(MANTIS_ERROR, 1, "Done!"); | ||
342 | |||
343 | return 0; | ||
344 | } | ||
345 | |||
346 | struct mantis_hwconfig vp1041_config = { | ||
347 | .model_name = MANTIS_MODEL_NAME, | ||
348 | .dev_type = MANTIS_DEV_TYPE, | ||
349 | .ts_size = MANTIS_TS_188, | ||
350 | |||
351 | .baud_rate = MANTIS_BAUD_9600, | ||
352 | .parity = MANTIS_PARITY_NONE, | ||
353 | .bytes = 0, | ||
354 | |||
355 | .frontend_init = vp1041_frontend_init, | ||
356 | .power = GPIF_A12, | ||
357 | .reset = GPIF_A13, | ||
358 | }; | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp1041.h b/drivers/media/dvb/mantis/mantis_vp1041.h new file mode 100644 index 000000000000..1ae5b3de8081 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp1041.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | Mantis VP-1041 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 | #ifndef __MANTIS_VP1041_H | ||
22 | #define __MANTIS_VP1041_H | ||
23 | |||
24 | #include "mantis_common.h" | ||
25 | |||
26 | #define MANTIS_VP_1041_DVB_S2 0x0031 | ||
27 | #define SKYSTAR_HD2_10 0x0001 | ||
28 | #define SKYSTAR_HD2_20 0x0003 | ||
29 | #define CINERGY_S2_PCI_HD 0x1179 | ||
30 | |||
31 | extern struct mantis_hwconfig vp1041_config; | ||
32 | |||
33 | #endif /* __MANTIS_VP1041_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp2033.c b/drivers/media/dvb/mantis/mantis_vp2033.c new file mode 100644 index 000000000000..10ce81790a8c --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp2033.c | |||
@@ -0,0 +1,187 @@ | |||
1 | /* | ||
2 | Mantis VP-2033 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/signal.h> | ||
22 | #include <linux/sched.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | |||
25 | #include "dmxdev.h" | ||
26 | #include "dvbdev.h" | ||
27 | #include "dvb_demux.h" | ||
28 | #include "dvb_frontend.h" | ||
29 | #include "dvb_net.h" | ||
30 | |||
31 | #include "tda1002x.h" | ||
32 | #include "mantis_common.h" | ||
33 | #include "mantis_ioc.h" | ||
34 | #include "mantis_dvb.h" | ||
35 | #include "mantis_vp2033.h" | ||
36 | |||
37 | #define MANTIS_MODEL_NAME "VP-2033" | ||
38 | #define MANTIS_DEV_TYPE "DVB-C" | ||
39 | |||
40 | struct tda1002x_config vp2033_tda1002x_cu1216_config = { | ||
41 | .demod_address = 0x18 >> 1, | ||
42 | .invert = 1, | ||
43 | }; | ||
44 | |||
45 | struct tda10023_config vp2033_tda10023_cu1216_config = { | ||
46 | .demod_address = 0x18 >> 1, | ||
47 | .invert = 1, | ||
48 | }; | ||
49 | |||
50 | static u8 read_pwm(struct mantis_pci *mantis) | ||
51 | { | ||
52 | struct i2c_adapter *adapter = &mantis->adapter; | ||
53 | |||
54 | u8 b = 0xff; | ||
55 | u8 pwm; | ||
56 | struct i2c_msg msg[] = { | ||
57 | {.addr = 0x50, .flags = 0, .buf = &b, .len = 1}, | ||
58 | {.addr = 0x50, .flags = I2C_M_RD, .buf = &pwm, .len = 1} | ||
59 | }; | ||
60 | |||
61 | if ((i2c_transfer(adapter, msg, 2) != 2) | ||
62 | || (pwm == 0xff)) | ||
63 | pwm = 0x48; | ||
64 | |||
65 | return pwm; | ||
66 | } | ||
67 | |||
68 | static int tda1002x_cu1216_tuner_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) | ||
69 | { | ||
70 | struct mantis_pci *mantis = fe->dvb->priv; | ||
71 | struct i2c_adapter *adapter = &mantis->adapter; | ||
72 | |||
73 | u8 buf[6]; | ||
74 | struct i2c_msg msg = {.addr = 0x60, .flags = 0, .buf = buf, .len = sizeof(buf)}; | ||
75 | int i; | ||
76 | |||
77 | #define CU1216_IF 36125000 | ||
78 | #define TUNER_MUL 62500 | ||
79 | |||
80 | u32 div = (params->frequency + CU1216_IF + TUNER_MUL / 2) / TUNER_MUL; | ||
81 | |||
82 | buf[0] = (div >> 8) & 0x7f; | ||
83 | buf[1] = div & 0xff; | ||
84 | buf[2] = 0xce; | ||
85 | buf[3] = (params->frequency < 150000000 ? 0x01 : | ||
86 | params->frequency < 445000000 ? 0x02 : 0x04); | ||
87 | buf[4] = 0xde; | ||
88 | buf[5] = 0x20; | ||
89 | |||
90 | if (fe->ops.i2c_gate_ctrl) | ||
91 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
92 | |||
93 | if (i2c_transfer(adapter, &msg, 1) != 1) | ||
94 | return -EIO; | ||
95 | |||
96 | /* wait for the pll lock */ | ||
97 | msg.flags = I2C_M_RD; | ||
98 | msg.len = 1; | ||
99 | for (i = 0; i < 20; i++) { | ||
100 | if (fe->ops.i2c_gate_ctrl) | ||
101 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
102 | |||
103 | if (i2c_transfer(adapter, &msg, 1) == 1 && (buf[0] & 0x40)) | ||
104 | break; | ||
105 | |||
106 | msleep(10); | ||
107 | } | ||
108 | |||
109 | /* switch the charge pump to the lower current */ | ||
110 | msg.flags = 0; | ||
111 | msg.len = 2; | ||
112 | msg.buf = &buf[2]; | ||
113 | buf[2] &= ~0x40; | ||
114 | if (fe->ops.i2c_gate_ctrl) | ||
115 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
116 | |||
117 | if (i2c_transfer(adapter, &msg, 1) != 1) | ||
118 | return -EIO; | ||
119 | |||
120 | return 0; | ||
121 | } | ||
122 | |||
123 | static int vp2033_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe) | ||
124 | { | ||
125 | struct i2c_adapter *adapter = &mantis->adapter; | ||
126 | |||
127 | int err = 0; | ||
128 | |||
129 | err = mantis_frontend_power(mantis, POWER_ON); | ||
130 | if (err == 0) { | ||
131 | mantis_frontend_soft_reset(mantis); | ||
132 | msleep(250); | ||
133 | |||
134 | dprintk(MANTIS_ERROR, 1, "Probing for CU1216 (DVB-C)"); | ||
135 | fe = tda10021_attach(&vp2033_tda1002x_cu1216_config, | ||
136 | adapter, | ||
137 | read_pwm(mantis)); | ||
138 | |||
139 | if (fe) { | ||
140 | dprintk(MANTIS_ERROR, 1, | ||
141 | "found Philips CU1216 DVB-C frontend (TDA10021) @ 0x%02x", | ||
142 | vp2033_tda1002x_cu1216_config.demod_address); | ||
143 | } else { | ||
144 | fe = tda10023_attach(&vp2033_tda10023_cu1216_config, | ||
145 | adapter, | ||
146 | read_pwm(mantis)); | ||
147 | |||
148 | if (fe) { | ||
149 | dprintk(MANTIS_ERROR, 1, | ||
150 | "found Philips CU1216 DVB-C frontend (TDA10023) @ 0x%02x", | ||
151 | vp2033_tda1002x_cu1216_config.demod_address); | ||
152 | } | ||
153 | } | ||
154 | |||
155 | if (fe) { | ||
156 | fe->ops.tuner_ops.set_params = tda1002x_cu1216_tuner_set; | ||
157 | dprintk(MANTIS_ERROR, 1, "Mantis DVB-C Philips CU1216 frontend attach success"); | ||
158 | } else { | ||
159 | return -1; | ||
160 | } | ||
161 | } else { | ||
162 | dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>", | ||
163 | adapter->name, | ||
164 | err); | ||
165 | |||
166 | return -EIO; | ||
167 | } | ||
168 | |||
169 | mantis->fe = fe; | ||
170 | dprintk(MANTIS_DEBUG, 1, "Done!"); | ||
171 | |||
172 | return 0; | ||
173 | } | ||
174 | |||
175 | struct mantis_hwconfig vp2033_config = { | ||
176 | .model_name = MANTIS_MODEL_NAME, | ||
177 | .dev_type = MANTIS_DEV_TYPE, | ||
178 | .ts_size = MANTIS_TS_204, | ||
179 | |||
180 | .baud_rate = MANTIS_BAUD_9600, | ||
181 | .parity = MANTIS_PARITY_NONE, | ||
182 | .bytes = 0, | ||
183 | |||
184 | .frontend_init = vp2033_frontend_init, | ||
185 | .power = GPIF_A12, | ||
186 | .reset = GPIF_A13, | ||
187 | }; | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp2033.h b/drivers/media/dvb/mantis/mantis_vp2033.h new file mode 100644 index 000000000000..c55242b79d54 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp2033.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | Mantis VP-2033 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 | #ifndef __MANTIS_VP2033_H | ||
22 | #define __MANTIS_VP2033_H | ||
23 | |||
24 | #include "mantis_common.h" | ||
25 | |||
26 | #define MANTIS_VP_2033_DVB_C 0x0008 | ||
27 | |||
28 | extern struct mantis_hwconfig vp2033_config; | ||
29 | |||
30 | #endif /* __MANTIS_VP2033_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp2040.c b/drivers/media/dvb/mantis/mantis_vp2040.c new file mode 100644 index 000000000000..a7ca233e800b --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp2040.c | |||
@@ -0,0 +1,186 @@ | |||
1 | /* | ||
2 | Mantis VP-2040 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/signal.h> | ||
22 | #include <linux/sched.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | |||
25 | #include "dmxdev.h" | ||
26 | #include "dvbdev.h" | ||
27 | #include "dvb_demux.h" | ||
28 | #include "dvb_frontend.h" | ||
29 | #include "dvb_net.h" | ||
30 | |||
31 | #include "tda1002x.h" | ||
32 | #include "mantis_common.h" | ||
33 | #include "mantis_ioc.h" | ||
34 | #include "mantis_dvb.h" | ||
35 | #include "mantis_vp2040.h" | ||
36 | |||
37 | #define MANTIS_MODEL_NAME "VP-2040" | ||
38 | #define MANTIS_DEV_TYPE "DVB-C" | ||
39 | |||
40 | struct tda1002x_config vp2040_tda1002x_cu1216_config = { | ||
41 | .demod_address = 0x18 >> 1, | ||
42 | .invert = 1, | ||
43 | }; | ||
44 | |||
45 | struct tda10023_config vp2040_tda10023_cu1216_config = { | ||
46 | .demod_address = 0x18 >> 1, | ||
47 | .invert = 1, | ||
48 | }; | ||
49 | |||
50 | static int tda1002x_cu1216_tuner_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) | ||
51 | { | ||
52 | struct mantis_pci *mantis = fe->dvb->priv; | ||
53 | struct i2c_adapter *adapter = &mantis->adapter; | ||
54 | |||
55 | u8 buf[6]; | ||
56 | struct i2c_msg msg = {.addr = 0x60, .flags = 0, .buf = buf, .len = sizeof(buf)}; | ||
57 | int i; | ||
58 | |||
59 | #define CU1216_IF 36125000 | ||
60 | #define TUNER_MUL 62500 | ||
61 | |||
62 | u32 div = (params->frequency + CU1216_IF + TUNER_MUL / 2) / TUNER_MUL; | ||
63 | |||
64 | buf[0] = (div >> 8) & 0x7f; | ||
65 | buf[1] = div & 0xff; | ||
66 | buf[2] = 0xce; | ||
67 | buf[3] = (params->frequency < 150000000 ? 0x01 : | ||
68 | params->frequency < 445000000 ? 0x02 : 0x04); | ||
69 | buf[4] = 0xde; | ||
70 | buf[5] = 0x20; | ||
71 | |||
72 | if (fe->ops.i2c_gate_ctrl) | ||
73 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
74 | |||
75 | if (i2c_transfer(adapter, &msg, 1) != 1) | ||
76 | return -EIO; | ||
77 | |||
78 | /* wait for the pll lock */ | ||
79 | msg.flags = I2C_M_RD; | ||
80 | msg.len = 1; | ||
81 | for (i = 0; i < 20; i++) { | ||
82 | if (fe->ops.i2c_gate_ctrl) | ||
83 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
84 | |||
85 | if (i2c_transfer(adapter, &msg, 1) == 1 && (buf[0] & 0x40)) | ||
86 | break; | ||
87 | |||
88 | msleep(10); | ||
89 | } | ||
90 | |||
91 | /* switch the charge pump to the lower current */ | ||
92 | msg.flags = 0; | ||
93 | msg.len = 2; | ||
94 | msg.buf = &buf[2]; | ||
95 | buf[2] &= ~0x40; | ||
96 | if (fe->ops.i2c_gate_ctrl) | ||
97 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
98 | |||
99 | if (i2c_transfer(adapter, &msg, 1) != 1) | ||
100 | return -EIO; | ||
101 | |||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | static u8 read_pwm(struct mantis_pci *mantis) | ||
106 | { | ||
107 | struct i2c_adapter *adapter = &mantis->adapter; | ||
108 | |||
109 | u8 b = 0xff; | ||
110 | u8 pwm; | ||
111 | struct i2c_msg msg[] = { | ||
112 | {.addr = 0x50, .flags = 0, .buf = &b, .len = 1}, | ||
113 | {.addr = 0x50, .flags = I2C_M_RD, .buf = &pwm, .len = 1} | ||
114 | }; | ||
115 | |||
116 | if ((i2c_transfer(adapter, msg, 2) != 2) | ||
117 | || (pwm == 0xff)) | ||
118 | pwm = 0x48; | ||
119 | |||
120 | return pwm; | ||
121 | } | ||
122 | |||
123 | static int vp2040_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe) | ||
124 | { | ||
125 | struct i2c_adapter *adapter = &mantis->adapter; | ||
126 | |||
127 | int err = 0; | ||
128 | |||
129 | err = mantis_frontend_power(mantis, POWER_ON); | ||
130 | if (err == 0) { | ||
131 | mantis_frontend_soft_reset(mantis); | ||
132 | msleep(250); | ||
133 | |||
134 | dprintk(MANTIS_ERROR, 1, "Probing for CU1216 (DVB-C)"); | ||
135 | fe = tda10021_attach(&vp2040_tda1002x_cu1216_config, | ||
136 | adapter, | ||
137 | read_pwm(mantis)); | ||
138 | |||
139 | if (fe) { | ||
140 | dprintk(MANTIS_ERROR, 1, | ||
141 | "found Philips CU1216 DVB-C frontend (TDA10021) @ 0x%02x", | ||
142 | vp2040_tda1002x_cu1216_config.demod_address); | ||
143 | } else { | ||
144 | fe = tda10023_attach(&vp2040_tda10023_cu1216_config, | ||
145 | adapter, | ||
146 | read_pwm(mantis)); | ||
147 | |||
148 | if (fe) { | ||
149 | dprintk(MANTIS_ERROR, 1, | ||
150 | "found Philips CU1216 DVB-C frontend (TDA10023) @ 0x%02x", | ||
151 | vp2040_tda1002x_cu1216_config.demod_address); | ||
152 | } | ||
153 | } | ||
154 | |||
155 | if (fe) { | ||
156 | fe->ops.tuner_ops.set_params = tda1002x_cu1216_tuner_set; | ||
157 | dprintk(MANTIS_ERROR, 1, "Mantis DVB-C Philips CU1216 frontend attach success"); | ||
158 | } else { | ||
159 | return -1; | ||
160 | } | ||
161 | } else { | ||
162 | dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>", | ||
163 | adapter->name, | ||
164 | err); | ||
165 | |||
166 | return -EIO; | ||
167 | } | ||
168 | mantis->fe = fe; | ||
169 | dprintk(MANTIS_DEBUG, 1, "Done!"); | ||
170 | |||
171 | return 0; | ||
172 | } | ||
173 | |||
174 | struct mantis_hwconfig vp2040_config = { | ||
175 | .model_name = MANTIS_MODEL_NAME, | ||
176 | .dev_type = MANTIS_DEV_TYPE, | ||
177 | .ts_size = MANTIS_TS_204, | ||
178 | |||
179 | .baud_rate = MANTIS_BAUD_9600, | ||
180 | .parity = MANTIS_PARITY_NONE, | ||
181 | .bytes = 0, | ||
182 | |||
183 | .frontend_init = vp2040_frontend_init, | ||
184 | .power = GPIF_A12, | ||
185 | .reset = GPIF_A13, | ||
186 | }; | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp2040.h b/drivers/media/dvb/mantis/mantis_vp2040.h new file mode 100644 index 000000000000..d125e219b685 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp2040.h | |||
@@ -0,0 +1,32 @@ | |||
1 | /* | ||
2 | Mantis VP-2040 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 | #ifndef __MANTIS_VP2040_H | ||
22 | #define __MANTIS_VP2040_H | ||
23 | |||
24 | #include "mantis_common.h" | ||
25 | |||
26 | #define MANTIS_VP_2040_DVB_C 0x0043 | ||
27 | #define CINERGY_C 0x1178 | ||
28 | #define CABLESTAR_HD2 0x0002 | ||
29 | |||
30 | extern struct mantis_hwconfig vp2040_config; | ||
31 | |||
32 | #endif /* __MANTIS_VP2040_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp3028.c b/drivers/media/dvb/mantis/mantis_vp3028.c new file mode 100644 index 000000000000..4155c838a18a --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp3028.c | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | Mantis VP-3028 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 "mantis_common.h" | ||
22 | #include "mantis_vp3028.h" | ||
23 | |||
24 | struct zl10353_config mantis_vp3028_config = { | ||
25 | .demod_address = 0x0f, | ||
26 | }; | ||
27 | |||
28 | #define MANTIS_MODEL_NAME "VP-3028" | ||
29 | #define MANTIS_DEV_TYPE "DVB-T" | ||
30 | |||
31 | struct mantis_hwconfig vp3028_mantis_config = { | ||
32 | .model_name = MANTIS_MODEL_NAME, | ||
33 | .dev_type = MANTIS_DEV_TYPE, | ||
34 | .ts_size = MANTIS_TS_188, | ||
35 | .baud_rate = MANTIS_BAUD_9600, | ||
36 | .parity = MANTIS_PARITY_NONE, | ||
37 | .bytes = 0, | ||
38 | }; | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp3028.h b/drivers/media/dvb/mantis/mantis_vp3028.h new file mode 100644 index 000000000000..b07be6adc522 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp3028.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | Mantis VP-3028 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 | #ifndef __MANTIS_VP3028_H | ||
22 | #define __MANTIS_VP3028_H | ||
23 | |||
24 | #include "dvb_frontend.h" | ||
25 | #include "mantis_common.h" | ||
26 | #include "zl10353.h" | ||
27 | |||
28 | #define MANTIS_VP_3028_DVB_T 0x0028 | ||
29 | |||
30 | extern struct zl10353_config mantis_vp3028_config; | ||
31 | extern struct mantis_hwconfig vp3028_mantis_config; | ||
32 | |||
33 | #endif /* __MANTIS_VP3028_H */ | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp3030.c b/drivers/media/dvb/mantis/mantis_vp3030.c new file mode 100644 index 000000000000..1f4334214953 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp3030.c | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | Mantis VP-3030 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/signal.h> | ||
22 | #include <linux/sched.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | |||
25 | #include "dmxdev.h" | ||
26 | #include "dvbdev.h" | ||
27 | #include "dvb_demux.h" | ||
28 | #include "dvb_frontend.h" | ||
29 | #include "dvb_net.h" | ||
30 | |||
31 | #include "zl10353.h" | ||
32 | #include "tda665x.h" | ||
33 | #include "mantis_common.h" | ||
34 | #include "mantis_ioc.h" | ||
35 | #include "mantis_dvb.h" | ||
36 | #include "mantis_vp3030.h" | ||
37 | |||
38 | struct zl10353_config mantis_vp3030_config = { | ||
39 | .demod_address = 0x0f, | ||
40 | }; | ||
41 | |||
42 | struct tda665x_config env57h12d5_config = { | ||
43 | .name = "ENV57H12D5 (ET-50DT)", | ||
44 | .addr = 0x60, | ||
45 | .frequency_min = 47000000, | ||
46 | .frequency_max = 862000000, | ||
47 | .frequency_offst = 3616667, | ||
48 | .ref_multiplier = 6, /* 1/6 MHz */ | ||
49 | .ref_divider = 100000, /* 1/6 MHz */ | ||
50 | }; | ||
51 | |||
52 | #define MANTIS_MODEL_NAME "VP-3030" | ||
53 | #define MANTIS_DEV_TYPE "DVB-T" | ||
54 | |||
55 | |||
56 | static int vp3030_frontend_init(struct mantis_pci *mantis, struct dvb_frontend *fe) | ||
57 | { | ||
58 | struct i2c_adapter *adapter = &mantis->adapter; | ||
59 | struct mantis_hwconfig *config = mantis->hwconfig; | ||
60 | int err = 0; | ||
61 | |||
62 | gpio_set_bits(mantis, config->reset, 0); | ||
63 | msleep(100); | ||
64 | err = mantis_frontend_power(mantis, POWER_ON); | ||
65 | msleep(100); | ||
66 | gpio_set_bits(mantis, config->reset, 1); | ||
67 | |||
68 | if (err == 0) { | ||
69 | msleep(250); | ||
70 | dprintk(MANTIS_ERROR, 1, "Probing for 10353 (DVB-T)"); | ||
71 | fe = zl10353_attach(&mantis_vp3030_config, adapter); | ||
72 | |||
73 | if (!fe) | ||
74 | return -1; | ||
75 | |||
76 | tda665x_attach(fe, &env57h12d5_config, adapter); | ||
77 | } else { | ||
78 | dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>", | ||
79 | adapter->name, | ||
80 | err); | ||
81 | |||
82 | return -EIO; | ||
83 | |||
84 | } | ||
85 | mantis->fe = fe; | ||
86 | dprintk(MANTIS_ERROR, 1, "Done!"); | ||
87 | |||
88 | return 0; | ||
89 | } | ||
90 | |||
91 | struct mantis_hwconfig vp3030_config = { | ||
92 | .model_name = MANTIS_MODEL_NAME, | ||
93 | .dev_type = MANTIS_DEV_TYPE, | ||
94 | .ts_size = MANTIS_TS_188, | ||
95 | |||
96 | .baud_rate = MANTIS_BAUD_9600, | ||
97 | .parity = MANTIS_PARITY_NONE, | ||
98 | .bytes = 0, | ||
99 | |||
100 | .frontend_init = vp3030_frontend_init, | ||
101 | .power = GPIF_A12, | ||
102 | .reset = GPIF_A13, | ||
103 | |||
104 | .i2c_mode = MANTIS_BYTE_MODE | ||
105 | }; | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp3030.h b/drivers/media/dvb/mantis/mantis_vp3030.h new file mode 100644 index 000000000000..5f12c4266277 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp3030.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | Mantis VP-3030 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 | #ifndef __MANTIS_VP3030_H | ||
22 | #define __MANTIS_VP3030_H | ||
23 | |||
24 | #include "mantis_common.h" | ||
25 | |||
26 | #define MANTIS_VP_3030_DVB_T 0x0024 | ||
27 | |||
28 | extern struct mantis_hwconfig vp3030_config; | ||
29 | |||
30 | #endif /* __MANTIS_VP3030_H */ | ||