mantis_common.h 4.3 KB
Newer Older
1 2 3
/*
	Mantis PCI bridge driver

4
	Copyright (C) Manu Abraham (abraham.manu@gmail.com)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef __MANTIS_COMMON_H
#define __MANTIS_COMMON_H

24
#include <linux/interrupt.h>
25
#include <linux/mutex.h>
26
#include <linux/workqueue.h>
27

28
#include "mantis_uart.h"
29

30 31
#include "mantis_link.h"

32 33 34 35
#define MANTIS_ERROR		0
#define MANTIS_NOTICE		1
#define MANTIS_INFO		2
#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 49
		else if ((mantis->verbose > MANTIS_TMG) && (mantis->verbose > y))			\
			printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);	\
50
	} else {											\
51
		if (mantis->verbose > y)								\
52 53 54 55 56 57 58
			printk(format , ##arg);								\
	}												\
} while(0)

#define mwrite(dat, addr)	writel((dat), addr)
#define mread(addr)		readl(addr)

59 60
#define mmwrite(dat, addr)	mwrite((dat), (mantis->mmio + (addr)))
#define mmread(addr)		mread(mantis->mmio + (addr))
61

62 63
#define MANTIS_TS_188		0
#define MANTIS_TS_204		1
64

65 66 67 68 69 70 71 72 73 74 75 76 77 78
#define TWINHAN_TECHNOLOGIES	0x1822
#define MANTIS			0x4e35

#define TECHNISAT		0x1ae4
#define TERRATEC		0x153b

#define MAKE_ENTRY(__subven, __subdev, __configptr) {			\
		.vendor		= TWINHAN_TECHNOLOGIES,			\
		.device		= MANTIS,				\
		.subvendor	= (__subven),				\
		.subdevice	= (__subdev),				\
		.driver_data	= (unsigned long) (__configptr)		\
}

79 80 81 82 83
enum mantis_i2c_mode {
	MANTIS_PAGE_MODE = 0,
	MANTIS_BYTE_MODE,
};

84 85
struct mantis_pci;

86 87 88
struct mantis_hwconfig {
	char			*model_name;
	char			*dev_type;
89
	u32			ts_size;
90 91 92 93

	enum mantis_baud	baud_rate;
	enum mantis_parity	parity;
	u32			bytes;
94 95 96 97 98 99

	irqreturn_t (*irq_handler)(int irq, void *dev_id);
	int (*frontend_init)(struct mantis_pci *mantis, struct dvb_frontend *fe);

	u8			power;
	u8			reset;
100 101

	enum mantis_i2c_mode	i2c_mode;
102 103
};

104
struct mantis_pci {
105 106
	unsigned int		verbose;

107 108 109
	/*	PCI stuff		*/
	u16			vendor_id;
	u16			device_id;
110 111 112
	u16			subsystem_vendor;
	u16			subsystem_device;

113 114
	u8			latency;

115
	struct pci_dev		*pdev;
116 117

	unsigned long		mantis_addr;
118
	void __iomem		*mmio;
119 120 121 122 123 124 125

	u8			irq;
	u8			revision;

	unsigned int		num;

	/*	RISC Core		*/
126
	u32			busy_block;
127 128 129 130 131 132 133 134 135 136 137
	u32			last_block;
	u8			*buf_cpu;
	dma_addr_t		buf_dma;
	u32			*risc_cpu;
	dma_addr_t		risc_dma;

	struct tasklet_struct	tasklet;

	struct i2c_adapter	adapter;
	int			i2c_rc;
	wait_queue_head_t	i2c_wq;
138
	struct mutex		i2c_lock;
139 140 141 142 143 144 145 146 147 148 149 150

	/*	DVB stuff		*/
	struct dvb_adapter	dvb_adapter;
	struct dvb_frontend	*fe;
	struct dvb_demux	demux;
	struct dmxdev		dmxdev;
	struct dmx_frontend	fe_hw;
	struct dmx_frontend	fe_mem;
	struct dvb_net		dvbnet;

	u8			feeds;

151
	struct mantis_hwconfig	*hwconfig;
152

153 154
	u32			mantis_int_stat;
	u32			mantis_int_mask;
155 156 157 158 159 160 161

	/*	board specific		*/
	u8			mac_address[8];
	u32			sub_vendor_id;
	u32			sub_device_id;

	 /*	A12 A13 A14		*/
162
	u32			gpio_status;
163

164 165
	u32			gpif_status;

166
	struct mantis_ca	*mantis_ca;
167 168 169 170

	wait_queue_head_t	uart_wq;
	struct work_struct	uart_work;
	spinlock_t		uart_lock;
171

172 173 174
	struct rc_dev		*rc;
	char			input_name[80];
	char			input_phys[80];
175
};
176

177
#define MANTIS_HIF_STATUS	(mantis->gpio_status)
178

179
#endif /* __MANTIS_COMMON_H */