Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 1 | /* |
| 2 | Mantis PCI bridge driver |
| 3 | |
Manu Abraham | 8825a09 | 2009-12-15 09:13:49 -0300 | [diff] [blame^] | 4 | Copyright (C) Manu Abraham (abraham.manu@gmail.com) |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 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 | |
Manu Abraham | e2f67e4 | 2009-12-03 05:42:10 -0300 | [diff] [blame] | 24 | #include <linux/mutex.h> |
Manu Abraham | add2063 | 2009-12-04 05:39:57 -0300 | [diff] [blame] | 25 | #include <linux/workqueue.h> |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 26 | |
Manu Abraham | add2063 | 2009-12-04 05:39:57 -0300 | [diff] [blame] | 27 | #include "mantis_uart.h" |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 28 | |
Manu Abraham | bc4ed42 | 2009-12-04 05:03:35 -0300 | [diff] [blame] | 29 | #include "mantis_link.h" |
| 30 | |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 31 | #define MANTIS_ERROR 0 |
| 32 | #define MANTIS_NOTICE 1 |
| 33 | #define MANTIS_INFO 2 |
| 34 | #define MANTIS_DEBUG 3 |
Manu Abraham | bc832fa | 2009-12-04 05:57:28 -0300 | [diff] [blame] | 35 | #define MANTIS_TMG 9 |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 36 | |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 37 | #define dprintk(y, z, format, arg...) do { \ |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 38 | if (z) { \ |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 39 | if ((mantis->verbose > MANTIS_ERROR) && (mantis->verbose > y)) \ |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 40 | printk(KERN_ERR "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 41 | else if ((mantis->verbose > MANTIS_NOTICE) && (mantis->verbose > y)) \ |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 42 | printk(KERN_NOTICE "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 43 | else if ((mantis->verbose > MANTIS_INFO) && (mantis->verbose > y)) \ |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 44 | printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 45 | else if ((mantis->verbose > MANTIS_DEBUG) && (mantis->verbose > y)) \ |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 46 | printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ |
Manu Abraham | bc832fa | 2009-12-04 05:57:28 -0300 | [diff] [blame] | 47 | else if ((mantis->verbose > MANTIS_TMG) && (mantis->verbose > y)) \ |
| 48 | printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 49 | } else { \ |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 50 | if (mantis->verbose > y) \ |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 51 | printk(format , ##arg); \ |
| 52 | } \ |
| 53 | } while(0) |
| 54 | |
| 55 | #define mwrite(dat, addr) writel((dat), addr) |
| 56 | #define mread(addr) readl(addr) |
| 57 | |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 58 | #define mmwrite(dat, addr) mwrite((dat), (mantis->mmio + (addr))) |
| 59 | #define mmread(addr) mread(mantis->mmio + (addr)) |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 60 | |
Manu Abraham | 01a8c3e | 2009-12-03 05:38:33 -0300 | [diff] [blame] | 61 | #define MANTIS_TS_188 0 |
| 62 | #define MANTIS_TS_204 1 |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 63 | |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 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 | |
Manu Abraham | bc832fa | 2009-12-04 05:57:28 -0300 | [diff] [blame] | 78 | enum mantis_i2c_mode { |
| 79 | MANTIS_PAGE_MODE = 0, |
| 80 | MANTIS_BYTE_MODE, |
| 81 | }; |
| 82 | |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 83 | struct mantis_pci; |
| 84 | |
Manu Abraham | df0cca1 | 2009-12-02 22:07:24 -0300 | [diff] [blame] | 85 | struct mantis_hwconfig { |
| 86 | char *model_name; |
| 87 | char *dev_type; |
Manu Abraham | 01a8c3e | 2009-12-03 05:38:33 -0300 | [diff] [blame] | 88 | u32 ts_size; |
Manu Abraham | add2063 | 2009-12-04 05:39:57 -0300 | [diff] [blame] | 89 | |
| 90 | enum mantis_baud baud_rate; |
| 91 | enum mantis_parity parity; |
| 92 | u32 bytes; |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 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; |
Manu Abraham | bc832fa | 2009-12-04 05:57:28 -0300 | [diff] [blame] | 99 | |
| 100 | enum mantis_i2c_mode i2c_mode; |
Manu Abraham | df0cca1 | 2009-12-02 22:07:24 -0300 | [diff] [blame] | 101 | }; |
| 102 | |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 103 | struct mantis_pci { |
Manu Abraham | d575571 | 2009-12-04 05:04:18 -0300 | [diff] [blame] | 104 | unsigned int verbose; |
| 105 | |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 106 | /* PCI stuff */ |
| 107 | u16 vendor_id; |
| 108 | u16 device_id; |
Manu Abraham | df0cca1 | 2009-12-02 22:07:24 -0300 | [diff] [blame] | 109 | u16 subsystem_vendor; |
| 110 | u16 subsystem_device; |
| 111 | |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 112 | u8 latency; |
| 113 | |
Manu Abraham | 8154bad | 2009-12-03 05:46:06 -0300 | [diff] [blame] | 114 | struct pci_dev *pdev; |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 115 | |
| 116 | unsigned long mantis_addr; |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 117 | void __iomem *mmio; |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 118 | |
| 119 | u8 irq; |
| 120 | u8 revision; |
| 121 | |
| 122 | unsigned int num; |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 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; |
Manu Abraham | e2f67e4 | 2009-12-03 05:42:10 -0300 | [diff] [blame] | 140 | struct mutex i2c_lock; |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 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 | |
Manu Abraham | df0cca1 | 2009-12-02 22:07:24 -0300 | [diff] [blame] | 153 | struct mantis_hwconfig *hwconfig; |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 154 | |
Manu Abraham | 5517277 | 2009-12-02 22:09:53 -0300 | [diff] [blame] | 155 | u32 mantis_int_stat; |
| 156 | u32 mantis_int_mask; |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 157 | |
| 158 | /* board specific */ |
| 159 | u8 mac_address[8]; |
| 160 | u32 sub_vendor_id; |
| 161 | u32 sub_device_id; |
| 162 | |
| 163 | /* A12 A13 A14 */ |
Manu Abraham | 4d5a28e | 2009-12-04 05:15:38 -0300 | [diff] [blame] | 164 | u32 gpio_status; |
Manu Abraham | bc4ed42 | 2009-12-04 05:03:35 -0300 | [diff] [blame] | 165 | |
Manu Abraham | 17b77fc | 2009-12-04 05:26:46 -0300 | [diff] [blame] | 166 | u32 gpif_status; |
| 167 | |
Manu Abraham | bc4ed42 | 2009-12-04 05:03:35 -0300 | [diff] [blame] | 168 | struct mantis_ca *mantis_ca; |
Manu Abraham | add2063 | 2009-12-04 05:39:57 -0300 | [diff] [blame] | 169 | |
| 170 | wait_queue_head_t uart_wq; |
| 171 | struct work_struct uart_work; |
| 172 | spinlock_t uart_lock; |
Manu Abraham | a149735 | 2009-12-11 20:41:07 -0300 | [diff] [blame] | 173 | |
| 174 | struct input_dev *rc; |
Manu Abraham | df0cca1 | 2009-12-02 22:07:24 -0300 | [diff] [blame] | 175 | }; |
Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame] | 176 | |
Manu Abraham | 263645d | 2009-12-04 05:33:31 -0300 | [diff] [blame] | 177 | #define MANTIS_HIF_STATUS (mantis->gpio_status) |
Manu Abraham | b2d8f5e | 2009-12-04 05:16:24 -0300 | [diff] [blame] | 178 | |
Manu Abraham | b3b9614 | 2009-12-04 05:41:11 -0300 | [diff] [blame] | 179 | #endif /* __MANTIS_COMMON_H */ |