1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 Mantis PCI bridge driver
5 Copyright (C) Manu Abraham (abraham.manu@gmail.com)
9 #ifndef __MANTIS_COMMON_H
10 #define __MANTIS_COMMON_H
12 #include <linux/interrupt.h>
13 #include <linux/mutex.h>
14 #include <linux/workqueue.h>
16 #include "mantis_reg.h"
17 #include "mantis_uart.h"
19 #include "mantis_link.h"
21 #define MANTIS_ERROR 0
22 #define MANTIS_NOTICE 1
24 #define MANTIS_DEBUG 3
27 #define dprintk(y, z, format, arg...) do { \
29 if ((mantis->verbose > MANTIS_ERROR) && (mantis->verbose > y)) \
30 printk(KERN_ERR "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
31 else if ((mantis->verbose > MANTIS_NOTICE) && (mantis->verbose > y)) \
32 printk(KERN_NOTICE "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
33 else if ((mantis->verbose > MANTIS_INFO) && (mantis->verbose > y)) \
34 printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
35 else if ((mantis->verbose > MANTIS_DEBUG) && (mantis->verbose > y)) \
36 printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
37 else if ((mantis->verbose > MANTIS_TMG) && (mantis->verbose > y)) \
38 printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
40 if (mantis->verbose > y) \
41 printk(format , ##arg); \
45 #define mwrite(dat, addr) writel((dat), addr)
46 #define mread(addr) readl(addr)
48 #define mmwrite(dat, addr) mwrite((dat), (mantis->mmio + (addr)))
49 #define mmread(addr) mread(mantis->mmio + (addr))
51 #define MANTIS_TS_188 0
52 #define MANTIS_TS_204 1
54 #define TWINHAN_TECHNOLOGIES 0x1822
57 #define TECHNISAT 0x1ae4
58 #define TERRATEC 0x153b
60 #define MAKE_ENTRY(__subven, __subdev, __configptr, __rc) { \
61 .vendor = TWINHAN_TECHNOLOGIES, \
63 .subvendor = (__subven), \
64 .subdevice = (__subdev), \
65 .driver_data = (unsigned long) \
66 &(struct mantis_pci_drvdata){__configptr, __rc} \
69 enum mantis_i2c_mode
{
76 struct mantis_hwconfig
{
81 enum mantis_baud baud_rate
;
82 enum mantis_parity parity
;
85 irqreturn_t (*irq_handler
)(int irq
, void *dev_id
);
86 int (*frontend_init
)(struct mantis_pci
*mantis
, struct dvb_frontend
*fe
);
91 enum mantis_i2c_mode i2c_mode
;
94 struct mantis_pci_drvdata
{
95 struct mantis_hwconfig
*hwconfig
;
100 unsigned int verbose
;
105 u16 subsystem_vendor
;
106 u16 subsystem_device
;
110 struct pci_dev
*pdev
;
112 unsigned long mantis_addr
;
128 struct work_struct bh_work
;
129 spinlock_t intmask_lock
;
131 struct i2c_adapter adapter
;
133 wait_queue_head_t i2c_wq
;
134 struct mutex i2c_lock
;
137 struct dvb_adapter dvb_adapter
;
138 struct dvb_frontend
*fe
;
139 struct dvb_demux demux
;
140 struct dmxdev dmxdev
;
141 struct dmx_frontend fe_hw
;
142 struct dmx_frontend fe_mem
;
143 struct dvb_net dvbnet
;
147 struct mantis_hwconfig
*hwconfig
;
162 struct mantis_ca
*mantis_ca
;
164 struct work_struct uart_work
;
167 char device_name
[80];
172 #define MANTIS_HIF_STATUS (mantis->gpio_status)
174 static inline void mantis_mask_ints(struct mantis_pci
*mantis
, u32 mask
)
178 spin_lock_irqsave(&mantis
->intmask_lock
, flags
);
179 mmwrite(mmread(MANTIS_INT_MASK
) & ~mask
, MANTIS_INT_MASK
);
180 spin_unlock_irqrestore(&mantis
->intmask_lock
, flags
);
183 static inline void mantis_unmask_ints(struct mantis_pci
*mantis
, u32 mask
)
187 spin_lock_irqsave(&mantis
->intmask_lock
, flags
);
188 mmwrite(mmread(MANTIS_INT_MASK
) | mask
, MANTIS_INT_MASK
);
189 spin_unlock_irqrestore(&mantis
->intmask_lock
, flags
);
192 #endif /* __MANTIS_COMMON_H */