141e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham/* 241e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham Mantis PCI bridge driver 341e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 48825a0970cef408fb2f1a44e3cb05d6ba41a18dbManu Abraham Copyright (C) Manu Abraham (abraham.manu@gmail.com) 541e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 641e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham This program is free software; you can redistribute it and/or modify 741e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham it under the terms of the GNU General Public License as published by 841e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham the Free Software Foundation; either version 2 of the License, or 941e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham (at your option) any later version. 1041e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 1141e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham This program is distributed in the hope that it will be useful, 1241e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham but WITHOUT ANY WARRANTY; without even the implied warranty of 1341e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1441e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham GNU General Public License for more details. 1541e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 1641e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham You should have received a copy of the GNU General Public License 1741e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham along with this program; if not, write to the Free Software 1841e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 1941e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham*/ 2041e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 2141e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham#ifndef __MANTIS_COMMON_H 2241e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham#define __MANTIS_COMMON_H 2341e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 24a6b7a407865aab9f849dd99a71072b7cd1175116Alexey Dobriyan#include <linux/interrupt.h> 25e2f67e4fb931b975058b3bd48eaac43780c92c88Manu Abraham#include <linux/mutex.h> 26add206368462434ba97e8fe4de98e5d47ffdb0a0Manu Abraham#include <linux/workqueue.h> 2741e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 28add206368462434ba97e8fe4de98e5d47ffdb0a0Manu Abraham#include "mantis_uart.h" 2941e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 30bc4ed42fdf762a2049b255de92626ad1cfd86d8eManu Abraham#include "mantis_link.h" 31bc4ed42fdf762a2049b255de92626ad1cfd86d8eManu Abraham 3241e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham#define MANTIS_ERROR 0 3341e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham#define MANTIS_NOTICE 1 3441e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham#define MANTIS_INFO 2 3541e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham#define MANTIS_DEBUG 3 36bc832fa2c0310c25ed60204616ccef4f8db088f3Manu Abraham#define MANTIS_TMG 9 3741e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 38b3b961448f702339444036f94252ff2ba7a99febManu Abraham#define dprintk(y, z, format, arg...) do { \ 3941e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham if (z) { \ 40b3b961448f702339444036f94252ff2ba7a99febManu Abraham if ((mantis->verbose > MANTIS_ERROR) && (mantis->verbose > y)) \ 4141e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham printk(KERN_ERR "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ 42b3b961448f702339444036f94252ff2ba7a99febManu Abraham else if ((mantis->verbose > MANTIS_NOTICE) && (mantis->verbose > y)) \ 4341e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham printk(KERN_NOTICE "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ 44b3b961448f702339444036f94252ff2ba7a99febManu Abraham else if ((mantis->verbose > MANTIS_INFO) && (mantis->verbose > y)) \ 4541e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ 46b3b961448f702339444036f94252ff2ba7a99febManu Abraham else if ((mantis->verbose > MANTIS_DEBUG) && (mantis->verbose > y)) \ 4741e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ 48bc832fa2c0310c25ed60204616ccef4f8db088f3Manu Abraham else if ((mantis->verbose > MANTIS_TMG) && (mantis->verbose > y)) \ 49bc832fa2c0310c25ed60204616ccef4f8db088f3Manu Abraham printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ 5041e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham } else { \ 51b3b961448f702339444036f94252ff2ba7a99febManu Abraham if (mantis->verbose > y) \ 5241e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham printk(format , ##arg); \ 5341e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham } \ 5441e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham} while(0) 5541e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 5641e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham#define mwrite(dat, addr) writel((dat), addr) 5741e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham#define mread(addr) readl(addr) 5841e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 59b3b961448f702339444036f94252ff2ba7a99febManu Abraham#define mmwrite(dat, addr) mwrite((dat), (mantis->mmio + (addr))) 60b3b961448f702339444036f94252ff2ba7a99febManu Abraham#define mmread(addr) mread(mantis->mmio + (addr)) 6141e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 6201a8c3eebb3c83df337f88332756f16154cecc0fManu Abraham#define MANTIS_TS_188 0 6301a8c3eebb3c83df337f88332756f16154cecc0fManu Abraham#define MANTIS_TS_204 1 6441e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 65b3b961448f702339444036f94252ff2ba7a99febManu Abraham#define TWINHAN_TECHNOLOGIES 0x1822 66b3b961448f702339444036f94252ff2ba7a99febManu Abraham#define MANTIS 0x4e35 67b3b961448f702339444036f94252ff2ba7a99febManu Abraham 68b3b961448f702339444036f94252ff2ba7a99febManu Abraham#define TECHNISAT 0x1ae4 69b3b961448f702339444036f94252ff2ba7a99febManu Abraham#define TERRATEC 0x153b 70b3b961448f702339444036f94252ff2ba7a99febManu Abraham 71b3b961448f702339444036f94252ff2ba7a99febManu Abraham#define MAKE_ENTRY(__subven, __subdev, __configptr) { \ 72b3b961448f702339444036f94252ff2ba7a99febManu Abraham .vendor = TWINHAN_TECHNOLOGIES, \ 73b3b961448f702339444036f94252ff2ba7a99febManu Abraham .device = MANTIS, \ 74b3b961448f702339444036f94252ff2ba7a99febManu Abraham .subvendor = (__subven), \ 75b3b961448f702339444036f94252ff2ba7a99febManu Abraham .subdevice = (__subdev), \ 76b3b961448f702339444036f94252ff2ba7a99febManu Abraham .driver_data = (unsigned long) (__configptr) \ 77b3b961448f702339444036f94252ff2ba7a99febManu Abraham} 78b3b961448f702339444036f94252ff2ba7a99febManu Abraham 79bc832fa2c0310c25ed60204616ccef4f8db088f3Manu Abrahamenum mantis_i2c_mode { 80bc832fa2c0310c25ed60204616ccef4f8db088f3Manu Abraham MANTIS_PAGE_MODE = 0, 81bc832fa2c0310c25ed60204616ccef4f8db088f3Manu Abraham MANTIS_BYTE_MODE, 82bc832fa2c0310c25ed60204616ccef4f8db088f3Manu Abraham}; 83bc832fa2c0310c25ed60204616ccef4f8db088f3Manu Abraham 84b3b961448f702339444036f94252ff2ba7a99febManu Abrahamstruct mantis_pci; 85b3b961448f702339444036f94252ff2ba7a99febManu Abraham 86df0cca174b4d85ea041509a13e5e68b377758bf1Manu Abrahamstruct mantis_hwconfig { 87df0cca174b4d85ea041509a13e5e68b377758bf1Manu Abraham char *model_name; 88df0cca174b4d85ea041509a13e5e68b377758bf1Manu Abraham char *dev_type; 8901a8c3eebb3c83df337f88332756f16154cecc0fManu Abraham u32 ts_size; 90add206368462434ba97e8fe4de98e5d47ffdb0a0Manu Abraham 91add206368462434ba97e8fe4de98e5d47ffdb0a0Manu Abraham enum mantis_baud baud_rate; 92add206368462434ba97e8fe4de98e5d47ffdb0a0Manu Abraham enum mantis_parity parity; 93add206368462434ba97e8fe4de98e5d47ffdb0a0Manu Abraham u32 bytes; 94b3b961448f702339444036f94252ff2ba7a99febManu Abraham 95b3b961448f702339444036f94252ff2ba7a99febManu Abraham irqreturn_t (*irq_handler)(int irq, void *dev_id); 96b3b961448f702339444036f94252ff2ba7a99febManu Abraham int (*frontend_init)(struct mantis_pci *mantis, struct dvb_frontend *fe); 97b3b961448f702339444036f94252ff2ba7a99febManu Abraham 98b3b961448f702339444036f94252ff2ba7a99febManu Abraham u8 power; 99b3b961448f702339444036f94252ff2ba7a99febManu Abraham u8 reset; 100bc832fa2c0310c25ed60204616ccef4f8db088f3Manu Abraham 101bc832fa2c0310c25ed60204616ccef4f8db088f3Manu Abraham enum mantis_i2c_mode i2c_mode; 102df0cca174b4d85ea041509a13e5e68b377758bf1Manu Abraham}; 103df0cca174b4d85ea041509a13e5e68b377758bf1Manu Abraham 10441e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abrahamstruct mantis_pci { 105d575571e8eda92c2cfd727ef050d17e30878fee6Manu Abraham unsigned int verbose; 106d575571e8eda92c2cfd727ef050d17e30878fee6Manu Abraham 10741e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham /* PCI stuff */ 10841e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham u16 vendor_id; 10941e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham u16 device_id; 110df0cca174b4d85ea041509a13e5e68b377758bf1Manu Abraham u16 subsystem_vendor; 111df0cca174b4d85ea041509a13e5e68b377758bf1Manu Abraham u16 subsystem_device; 112df0cca174b4d85ea041509a13e5e68b377758bf1Manu Abraham 11341e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham u8 latency; 11441e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 1158154bad4c488c1a23fb504a6e751d71a39733b76Manu Abraham struct pci_dev *pdev; 11641e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 11741e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham unsigned long mantis_addr; 118b3b961448f702339444036f94252ff2ba7a99febManu Abraham void __iomem *mmio; 11941e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 12041e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham u8 irq; 12141e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham u8 revision; 12241e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 12341e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham unsigned int num; 12441e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 12541e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham /* RISC Core */ 12679d06d4dff733ee472e1f8933a33317a18195c0cMarko Ristola u32 busy_block; 12741e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham u32 last_block; 12841e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham u8 *buf_cpu; 12941e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham dma_addr_t buf_dma; 130967a37830573a1fa4b7bdb7ce203c7ea8a91e0c4Hans Verkuil __le32 *risc_cpu; 13141e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham dma_addr_t risc_dma; 13241e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 13341e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham struct tasklet_struct tasklet; 13441e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 13541e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham struct i2c_adapter adapter; 13641e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham int i2c_rc; 13741e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham wait_queue_head_t i2c_wq; 138e2f67e4fb931b975058b3bd48eaac43780c92c88Manu Abraham struct mutex i2c_lock; 13941e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 14041e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham /* DVB stuff */ 14141e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham struct dvb_adapter dvb_adapter; 14241e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham struct dvb_frontend *fe; 14341e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham struct dvb_demux demux; 14441e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham struct dmxdev dmxdev; 14541e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham struct dmx_frontend fe_hw; 14641e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham struct dmx_frontend fe_mem; 14741e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham struct dvb_net dvbnet; 14841e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 14941e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham u8 feeds; 15041e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 151df0cca174b4d85ea041509a13e5e68b377758bf1Manu Abraham struct mantis_hwconfig *hwconfig; 15241e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 15355172773c57221c7c81e445d04f811f2f0478c3eManu Abraham u32 mantis_int_stat; 15455172773c57221c7c81e445d04f811f2f0478c3eManu Abraham u32 mantis_int_mask; 15541e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 15641e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham /* board specific */ 15741e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham u8 mac_address[8]; 15841e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham u32 sub_vendor_id; 15941e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham u32 sub_device_id; 16041e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 16141e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham /* A12 A13 A14 */ 1624d5a28efda3ce12529e4b90832184f62c7a50848Manu Abraham u32 gpio_status; 163bc4ed42fdf762a2049b255de92626ad1cfd86d8eManu Abraham 16417b77fc2d404910ca691661038ceb4c02d912d16Manu Abraham u32 gpif_status; 16517b77fc2d404910ca691661038ceb4c02d912d16Manu Abraham 166bc4ed42fdf762a2049b255de92626ad1cfd86d8eManu Abraham struct mantis_ca *mantis_ca; 167add206368462434ba97e8fe4de98e5d47ffdb0a0Manu Abraham 168add206368462434ba97e8fe4de98e5d47ffdb0a0Manu Abraham wait_queue_head_t uart_wq; 169add206368462434ba97e8fe4de98e5d47ffdb0a0Manu Abraham struct work_struct uart_work; 170add206368462434ba97e8fe4de98e5d47ffdb0a0Manu Abraham spinlock_t uart_lock; 171a1497357dce240880d984f4b657b54245f739dbcManu Abraham 172d8b4b5822f51e2142b731b42c81e3f03eec475b2David Härdeman struct rc_dev *rc; 173d8b4b5822f51e2142b731b42c81e3f03eec475b2David Härdeman char input_name[80]; 174d8b4b5822f51e2142b731b42c81e3f03eec475b2David Härdeman char input_phys[80]; 175df0cca174b4d85ea041509a13e5e68b377758bf1Manu Abraham}; 17641e840b13e111ba18b138d055ddd250bd5ad5e39Manu Abraham 177263645de70175d8b5a5e392a1856e99e2e1b7209Manu Abraham#define MANTIS_HIF_STATUS (mantis->gpio_status) 178b2d8f5eafd31cd7bc722dc93057d8c5fd5b688abManu Abraham 179b3b961448f702339444036f94252ff2ba7a99febManu Abraham#endif /* __MANTIS_COMMON_H */ 180