xref: /linux/drivers/media/pci/mantis/mantis_common.h (revision b889fcf63cb62e7fdb7816565e28f44dbe4a76a5)
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/interrupt.h>
25 #include <linux/mutex.h>
26 #include <linux/workqueue.h>
27 
28 #include "mantis_uart.h"
29 
30 #include "mantis_link.h"
31 
32 #define MANTIS_ERROR		0
33 #define MANTIS_NOTICE		1
34 #define MANTIS_INFO		2
35 #define MANTIS_DEBUG		3
36 #define MANTIS_TMG		9
37 
38 #define dprintk(y, z, format, arg...) do {								\
39 	if (z) {											\
40 		if	((mantis->verbose > MANTIS_ERROR) && (mantis->verbose > y))			\
41 			printk(KERN_ERR "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);	\
42 		else if	((mantis->verbose > MANTIS_NOTICE) && (mantis->verbose > y))			\
43 			printk(KERN_NOTICE "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);	\
44 		else if ((mantis->verbose > MANTIS_INFO) && (mantis->verbose > y))			\
45 			printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);	\
46 		else if ((mantis->verbose > MANTIS_DEBUG) && (mantis->verbose > y))			\
47 			printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);	\
48 		else if ((mantis->verbose > MANTIS_TMG) && (mantis->verbose > y))			\
49 			printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);	\
50 	} else {											\
51 		if (mantis->verbose > y)								\
52 			printk(format , ##arg);								\
53 	}												\
54 } while(0)
55 
56 #define mwrite(dat, addr)	writel((dat), addr)
57 #define mread(addr)		readl(addr)
58 
59 #define mmwrite(dat, addr)	mwrite((dat), (mantis->mmio + (addr)))
60 #define mmread(addr)		mread(mantis->mmio + (addr))
61 
62 #define MANTIS_TS_188		0
63 #define MANTIS_TS_204		1
64 
65 #define TWINHAN_TECHNOLOGIES	0x1822
66 #define MANTIS			0x4e35
67 
68 #define TECHNISAT		0x1ae4
69 #define TERRATEC		0x153b
70 
71 #define MAKE_ENTRY(__subven, __subdev, __configptr) {			\
72 		.vendor		= TWINHAN_TECHNOLOGIES,			\
73 		.device		= MANTIS,				\
74 		.subvendor	= (__subven),				\
75 		.subdevice	= (__subdev),				\
76 		.driver_data	= (unsigned long) (__configptr)		\
77 }
78 
79 enum mantis_i2c_mode {
80 	MANTIS_PAGE_MODE = 0,
81 	MANTIS_BYTE_MODE,
82 };
83 
84 struct mantis_pci;
85 
86 struct mantis_hwconfig {
87 	char			*model_name;
88 	char			*dev_type;
89 	u32			ts_size;
90 
91 	enum mantis_baud	baud_rate;
92 	enum mantis_parity	parity;
93 	u32			bytes;
94 
95 	irqreturn_t (*irq_handler)(int irq, void *dev_id);
96 	int (*frontend_init)(struct mantis_pci *mantis, struct dvb_frontend *fe);
97 
98 	u8			power;
99 	u8			reset;
100 
101 	enum mantis_i2c_mode	i2c_mode;
102 };
103 
104 struct mantis_pci {
105 	unsigned int		verbose;
106 
107 	/*	PCI stuff		*/
108 	u16			vendor_id;
109 	u16			device_id;
110 	u16			subsystem_vendor;
111 	u16			subsystem_device;
112 
113 	u8			latency;
114 
115 	struct pci_dev		*pdev;
116 
117 	unsigned long		mantis_addr;
118 	void __iomem		*mmio;
119 
120 	u8			irq;
121 	u8			revision;
122 
123 	unsigned int		num;
124 
125 	/*	RISC Core		*/
126 	u32			busy_block;
127 	u32			last_block;
128 	u8			*buf_cpu;
129 	dma_addr_t		buf_dma;
130 	u32			*risc_cpu;
131 	dma_addr_t		risc_dma;
132 
133 	struct tasklet_struct	tasklet;
134 
135 	struct i2c_adapter	adapter;
136 	int			i2c_rc;
137 	wait_queue_head_t	i2c_wq;
138 	struct mutex		i2c_lock;
139 
140 	/*	DVB stuff		*/
141 	struct dvb_adapter	dvb_adapter;
142 	struct dvb_frontend	*fe;
143 	struct dvb_demux	demux;
144 	struct dmxdev		dmxdev;
145 	struct dmx_frontend	fe_hw;
146 	struct dmx_frontend	fe_mem;
147 	struct dvb_net		dvbnet;
148 
149 	u8			feeds;
150 
151 	struct mantis_hwconfig	*hwconfig;
152 
153 	u32			mantis_int_stat;
154 	u32			mantis_int_mask;
155 
156 	/*	board specific		*/
157 	u8			mac_address[8];
158 	u32			sub_vendor_id;
159 	u32			sub_device_id;
160 
161 	 /*	A12 A13 A14		*/
162 	u32			gpio_status;
163 
164 	u32			gpif_status;
165 
166 	struct mantis_ca	*mantis_ca;
167 
168 	wait_queue_head_t	uart_wq;
169 	struct work_struct	uart_work;
170 	spinlock_t		uart_lock;
171 
172 	struct rc_dev		*rc;
173 	char			input_name[80];
174 	char			input_phys[80];
175 };
176 
177 #define MANTIS_HIF_STATUS	(mantis->gpio_status)
178 
179 #endif /* __MANTIS_COMMON_H */
180