]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - drivers/media/pci/mantis/mantis_common.h
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[mirror_ubuntu-jammy-kernel.git] / drivers / media / pci / mantis / mantis_common.h
CommitLineData
74ba9207 1/* SPDX-License-Identifier: GPL-2.0-or-later */
41e840b1
MA
2/*
3 Mantis PCI bridge driver
4
8825a097 5 Copyright (C) Manu Abraham (abraham.manu@gmail.com)
41e840b1 6
41e840b1
MA
7*/
8
9#ifndef __MANTIS_COMMON_H
10#define __MANTIS_COMMON_H
11
a6b7a407 12#include <linux/interrupt.h>
e2f67e4f 13#include <linux/mutex.h>
add20636 14#include <linux/workqueue.h>
41e840b1 15
a96762da 16#include "mantis_reg.h"
add20636 17#include "mantis_uart.h"
41e840b1 18
bc4ed42f
MA
19#include "mantis_link.h"
20
41e840b1
MA
21#define MANTIS_ERROR 0
22#define MANTIS_NOTICE 1
23#define MANTIS_INFO 2
24#define MANTIS_DEBUG 3
bc832fa2 25#define MANTIS_TMG 9
41e840b1 26
b3b96144 27#define dprintk(y, z, format, arg...) do { \
41e840b1 28 if (z) { \
b3b96144 29 if ((mantis->verbose > MANTIS_ERROR) && (mantis->verbose > y)) \
41e840b1 30 printk(KERN_ERR "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
b3b96144 31 else if ((mantis->verbose > MANTIS_NOTICE) && (mantis->verbose > y)) \
41e840b1 32 printk(KERN_NOTICE "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
b3b96144 33 else if ((mantis->verbose > MANTIS_INFO) && (mantis->verbose > y)) \
41e840b1 34 printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
b3b96144 35 else if ((mantis->verbose > MANTIS_DEBUG) && (mantis->verbose > y)) \
41e840b1 36 printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
bc832fa2
MA
37 else if ((mantis->verbose > MANTIS_TMG) && (mantis->verbose > y)) \
38 printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
41e840b1 39 } else { \
b3b96144 40 if (mantis->verbose > y) \
41e840b1
MA
41 printk(format , ##arg); \
42 } \
43} while(0)
44
45#define mwrite(dat, addr) writel((dat), addr)
46#define mread(addr) readl(addr)
47
b3b96144
MA
48#define mmwrite(dat, addr) mwrite((dat), (mantis->mmio + (addr)))
49#define mmread(addr) mread(mantis->mmio + (addr))
41e840b1 50
01a8c3ee
MA
51#define MANTIS_TS_188 0
52#define MANTIS_TS_204 1
41e840b1 53
b3b96144
MA
54#define TWINHAN_TECHNOLOGIES 0x1822
55#define MANTIS 0x4e35
56
57#define TECHNISAT 0x1ae4
58#define TERRATEC 0x153b
59
a96762da 60#define MAKE_ENTRY(__subven, __subdev, __configptr, __rc) { \
b3b96144
MA
61 .vendor = TWINHAN_TECHNOLOGIES, \
62 .device = MANTIS, \
63 .subvendor = (__subven), \
64 .subdevice = (__subdev), \
a96762da
JK
65 .driver_data = (unsigned long) \
66 &(struct mantis_pci_drvdata){__configptr, __rc} \
b3b96144
MA
67}
68
bc832fa2
MA
69enum mantis_i2c_mode {
70 MANTIS_PAGE_MODE = 0,
71 MANTIS_BYTE_MODE,
72};
73
b3b96144
MA
74struct mantis_pci;
75
df0cca17
MA
76struct mantis_hwconfig {
77 char *model_name;
78 char *dev_type;
01a8c3ee 79 u32 ts_size;
add20636
MA
80
81 enum mantis_baud baud_rate;
82 enum mantis_parity parity;
83 u32 bytes;
b3b96144
MA
84
85 irqreturn_t (*irq_handler)(int irq, void *dev_id);
86 int (*frontend_init)(struct mantis_pci *mantis, struct dvb_frontend *fe);
87
88 u8 power;
89 u8 reset;
bc832fa2
MA
90
91 enum mantis_i2c_mode i2c_mode;
df0cca17
MA
92};
93
a96762da
JK
94struct mantis_pci_drvdata {
95 struct mantis_hwconfig *hwconfig;
96 char *rc_map_name;
97};
98
41e840b1 99struct mantis_pci {
d575571e
MA
100 unsigned int verbose;
101
41e840b1
MA
102 /* PCI stuff */
103 u16 vendor_id;
104 u16 device_id;
df0cca17
MA
105 u16 subsystem_vendor;
106 u16 subsystem_device;
107
41e840b1
MA
108 u8 latency;
109
8154bad4 110 struct pci_dev *pdev;
41e840b1
MA
111
112 unsigned long mantis_addr;
b3b96144 113 void __iomem *mmio;
41e840b1
MA
114
115 u8 irq;
116 u8 revision;
117
118 unsigned int num;
41e840b1
MA
119
120 /* RISC Core */
79d06d4d 121 u32 busy_block;
41e840b1 122 u32 last_block;
41e840b1
MA
123 u8 *buf_cpu;
124 dma_addr_t buf_dma;
967a3783 125 __le32 *risc_cpu;
41e840b1
MA
126 dma_addr_t risc_dma;
127
128 struct tasklet_struct tasklet;
a96762da 129 spinlock_t intmask_lock;
41e840b1
MA
130
131 struct i2c_adapter adapter;
132 int i2c_rc;
133 wait_queue_head_t i2c_wq;
e2f67e4f 134 struct mutex i2c_lock;
41e840b1
MA
135
136 /* DVB stuff */
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;
144
145 u8 feeds;
146
df0cca17 147 struct mantis_hwconfig *hwconfig;
41e840b1 148
55172773
MA
149 u32 mantis_int_stat;
150 u32 mantis_int_mask;
41e840b1
MA
151
152 /* board specific */
153 u8 mac_address[8];
154 u32 sub_vendor_id;
155 u32 sub_device_id;
156
157 /* A12 A13 A14 */
4d5a28ef 158 u32 gpio_status;
bc4ed42f 159
17b77fc2
MA
160 u32 gpif_status;
161
bc4ed42f 162 struct mantis_ca *mantis_ca;
add20636 163
add20636 164 struct work_struct uart_work;
a1497357 165
d8b4b582 166 struct rc_dev *rc;
518f4b26 167 char device_name[80];
d8b4b582 168 char input_phys[80];
a96762da 169 char *rc_map_name;
df0cca17 170};
41e840b1 171
263645de 172#define MANTIS_HIF_STATUS (mantis->gpio_status)
b2d8f5ea 173
a96762da
JK
174static inline void mantis_mask_ints(struct mantis_pci *mantis, u32 mask)
175{
176 unsigned long flags;
177
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);
181}
182
183static inline void mantis_unmask_ints(struct mantis_pci *mantis, u32 mask)
184{
185 unsigned long flags;
186
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);
190}
191
b3b96144 192#endif /* __MANTIS_COMMON_H */