2009-12-03 00:57:10 +00:00
|
|
|
/*
|
|
|
|
Mantis PCI bridge driver
|
|
|
|
|
2009-12-15 12:13:49 +00:00
|
|
|
Copyright (C) Manu Abraham (abraham.manu@gmail.com)
|
2009-12-03 00:57:10 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2011-06-06 10:43:46 +00:00
|
|
|
#include <linux/interrupt.h>
|
2009-12-03 08:42:10 +00:00
|
|
|
#include <linux/mutex.h>
|
2009-12-04 08:39:57 +00:00
|
|
|
#include <linux/workqueue.h>
|
2009-12-03 00:57:10 +00:00
|
|
|
|
2015-06-06 19:58:13 +00:00
|
|
|
#include "mantis_reg.h"
|
2009-12-04 08:39:57 +00:00
|
|
|
#include "mantis_uart.h"
|
2009-12-03 00:57:10 +00:00
|
|
|
|
2009-12-04 08:03:35 +00:00
|
|
|
#include "mantis_link.h"
|
|
|
|
|
2009-12-03 00:57:10 +00:00
|
|
|
#define MANTIS_ERROR 0
|
|
|
|
#define MANTIS_NOTICE 1
|
|
|
|
#define MANTIS_INFO 2
|
|
|
|
#define MANTIS_DEBUG 3
|
2009-12-04 08:57:28 +00:00
|
|
|
#define MANTIS_TMG 9
|
2009-12-03 00:57:10 +00:00
|
|
|
|
2009-12-04 08:41:11 +00:00
|
|
|
#define dprintk(y, z, format, arg...) do { \
|
2009-12-03 00:57:10 +00:00
|
|
|
if (z) { \
|
2009-12-04 08:41:11 +00:00
|
|
|
if ((mantis->verbose > MANTIS_ERROR) && (mantis->verbose > y)) \
|
2009-12-03 00:57:10 +00:00
|
|
|
printk(KERN_ERR "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
|
2009-12-04 08:41:11 +00:00
|
|
|
else if ((mantis->verbose > MANTIS_NOTICE) && (mantis->verbose > y)) \
|
2009-12-03 00:57:10 +00:00
|
|
|
printk(KERN_NOTICE "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
|
2009-12-04 08:41:11 +00:00
|
|
|
else if ((mantis->verbose > MANTIS_INFO) && (mantis->verbose > y)) \
|
2009-12-03 00:57:10 +00:00
|
|
|
printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
|
2009-12-04 08:41:11 +00:00
|
|
|
else if ((mantis->verbose > MANTIS_DEBUG) && (mantis->verbose > y)) \
|
2009-12-03 00:57:10 +00:00
|
|
|
printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
|
2009-12-04 08:57:28 +00:00
|
|
|
else if ((mantis->verbose > MANTIS_TMG) && (mantis->verbose > y)) \
|
|
|
|
printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
|
2009-12-03 00:57:10 +00:00
|
|
|
} else { \
|
2009-12-04 08:41:11 +00:00
|
|
|
if (mantis->verbose > y) \
|
2009-12-03 00:57:10 +00:00
|
|
|
printk(format , ##arg); \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#define mwrite(dat, addr) writel((dat), addr)
|
|
|
|
#define mread(addr) readl(addr)
|
|
|
|
|
2009-12-04 08:41:11 +00:00
|
|
|
#define mmwrite(dat, addr) mwrite((dat), (mantis->mmio + (addr)))
|
|
|
|
#define mmread(addr) mread(mantis->mmio + (addr))
|
2009-12-03 00:57:10 +00:00
|
|
|
|
2009-12-03 08:38:33 +00:00
|
|
|
#define MANTIS_TS_188 0
|
|
|
|
#define MANTIS_TS_204 1
|
2009-12-03 00:57:10 +00:00
|
|
|
|
2009-12-04 08:41:11 +00:00
|
|
|
#define TWINHAN_TECHNOLOGIES 0x1822
|
|
|
|
#define MANTIS 0x4e35
|
|
|
|
|
|
|
|
#define TECHNISAT 0x1ae4
|
|
|
|
#define TERRATEC 0x153b
|
|
|
|
|
2015-06-06 19:58:13 +00:00
|
|
|
#define MAKE_ENTRY(__subven, __subdev, __configptr, __rc) { \
|
2009-12-04 08:41:11 +00:00
|
|
|
.vendor = TWINHAN_TECHNOLOGIES, \
|
|
|
|
.device = MANTIS, \
|
|
|
|
.subvendor = (__subven), \
|
|
|
|
.subdevice = (__subdev), \
|
2015-06-06 19:58:13 +00:00
|
|
|
.driver_data = (unsigned long) \
|
|
|
|
&(struct mantis_pci_drvdata){__configptr, __rc} \
|
2009-12-04 08:41:11 +00:00
|
|
|
}
|
|
|
|
|
2009-12-04 08:57:28 +00:00
|
|
|
enum mantis_i2c_mode {
|
|
|
|
MANTIS_PAGE_MODE = 0,
|
|
|
|
MANTIS_BYTE_MODE,
|
|
|
|
};
|
|
|
|
|
2009-12-04 08:41:11 +00:00
|
|
|
struct mantis_pci;
|
|
|
|
|
2009-12-03 01:07:24 +00:00
|
|
|
struct mantis_hwconfig {
|
|
|
|
char *model_name;
|
|
|
|
char *dev_type;
|
2009-12-03 08:38:33 +00:00
|
|
|
u32 ts_size;
|
2009-12-04 08:39:57 +00:00
|
|
|
|
|
|
|
enum mantis_baud baud_rate;
|
|
|
|
enum mantis_parity parity;
|
|
|
|
u32 bytes;
|
2009-12-04 08:41:11 +00:00
|
|
|
|
|
|
|
irqreturn_t (*irq_handler)(int irq, void *dev_id);
|
|
|
|
int (*frontend_init)(struct mantis_pci *mantis, struct dvb_frontend *fe);
|
|
|
|
|
|
|
|
u8 power;
|
|
|
|
u8 reset;
|
2009-12-04 08:57:28 +00:00
|
|
|
|
|
|
|
enum mantis_i2c_mode i2c_mode;
|
2009-12-03 01:07:24 +00:00
|
|
|
};
|
|
|
|
|
2015-06-06 19:58:13 +00:00
|
|
|
struct mantis_pci_drvdata {
|
|
|
|
struct mantis_hwconfig *hwconfig;
|
|
|
|
char *rc_map_name;
|
|
|
|
};
|
|
|
|
|
2009-12-03 00:57:10 +00:00
|
|
|
struct mantis_pci {
|
2009-12-04 08:04:18 +00:00
|
|
|
unsigned int verbose;
|
|
|
|
|
2009-12-03 00:57:10 +00:00
|
|
|
/* PCI stuff */
|
|
|
|
u16 vendor_id;
|
|
|
|
u16 device_id;
|
2009-12-03 01:07:24 +00:00
|
|
|
u16 subsystem_vendor;
|
|
|
|
u16 subsystem_device;
|
|
|
|
|
2009-12-03 00:57:10 +00:00
|
|
|
u8 latency;
|
|
|
|
|
2009-12-03 08:46:06 +00:00
|
|
|
struct pci_dev *pdev;
|
2009-12-03 00:57:10 +00:00
|
|
|
|
|
|
|
unsigned long mantis_addr;
|
2009-12-04 08:41:11 +00:00
|
|
|
void __iomem *mmio;
|
2009-12-03 00:57:10 +00:00
|
|
|
|
|
|
|
u8 irq;
|
|
|
|
u8 revision;
|
|
|
|
|
|
|
|
unsigned int num;
|
|
|
|
|
|
|
|
/* RISC Core */
|
2010-08-07 11:16:15 +00:00
|
|
|
u32 busy_block;
|
2009-12-03 00:57:10 +00:00
|
|
|
u32 last_block;
|
|
|
|
u8 *buf_cpu;
|
|
|
|
dma_addr_t buf_dma;
|
2014-08-20 21:26:40 +00:00
|
|
|
__le32 *risc_cpu;
|
2009-12-03 00:57:10 +00:00
|
|
|
dma_addr_t risc_dma;
|
|
|
|
|
|
|
|
struct tasklet_struct tasklet;
|
2015-06-06 19:58:13 +00:00
|
|
|
spinlock_t intmask_lock;
|
2009-12-03 00:57:10 +00:00
|
|
|
|
|
|
|
struct i2c_adapter adapter;
|
|
|
|
int i2c_rc;
|
|
|
|
wait_queue_head_t i2c_wq;
|
2009-12-03 08:42:10 +00:00
|
|
|
struct mutex i2c_lock;
|
2009-12-03 00:57:10 +00:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
2009-12-03 01:07:24 +00:00
|
|
|
struct mantis_hwconfig *hwconfig;
|
2009-12-03 00:57:10 +00:00
|
|
|
|
2009-12-03 01:09:53 +00:00
|
|
|
u32 mantis_int_stat;
|
|
|
|
u32 mantis_int_mask;
|
2009-12-03 00:57:10 +00:00
|
|
|
|
|
|
|
/* board specific */
|
|
|
|
u8 mac_address[8];
|
|
|
|
u32 sub_vendor_id;
|
|
|
|
u32 sub_device_id;
|
|
|
|
|
|
|
|
/* A12 A13 A14 */
|
2009-12-04 08:15:38 +00:00
|
|
|
u32 gpio_status;
|
2009-12-04 08:03:35 +00:00
|
|
|
|
2009-12-04 08:26:46 +00:00
|
|
|
u32 gpif_status;
|
|
|
|
|
2009-12-04 08:03:35 +00:00
|
|
|
struct mantis_ca *mantis_ca;
|
2009-12-04 08:39:57 +00:00
|
|
|
|
|
|
|
struct work_struct uart_work;
|
2009-12-11 23:41:07 +00:00
|
|
|
|
2010-10-29 19:08:23 +00:00
|
|
|
struct rc_dev *rc;
|
2017-07-01 16:13:19 +00:00
|
|
|
char device_name[80];
|
2010-10-29 19:08:23 +00:00
|
|
|
char input_phys[80];
|
2015-06-06 19:58:13 +00:00
|
|
|
char *rc_map_name;
|
2009-12-03 01:07:24 +00:00
|
|
|
};
|
2009-12-03 00:57:10 +00:00
|
|
|
|
2009-12-04 08:33:31 +00:00
|
|
|
#define MANTIS_HIF_STATUS (mantis->gpio_status)
|
2009-12-04 08:16:24 +00:00
|
|
|
|
2015-06-06 19:58:13 +00:00
|
|
|
static inline void mantis_mask_ints(struct mantis_pci *mantis, u32 mask)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&mantis->intmask_lock, flags);
|
|
|
|
mmwrite(mmread(MANTIS_INT_MASK) & ~mask, MANTIS_INT_MASK);
|
|
|
|
spin_unlock_irqrestore(&mantis->intmask_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void mantis_unmask_ints(struct mantis_pci *mantis, u32 mask)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&mantis->intmask_lock, flags);
|
|
|
|
mmwrite(mmread(MANTIS_INT_MASK) | mask, MANTIS_INT_MASK);
|
|
|
|
spin_unlock_irqrestore(&mantis->intmask_lock, flags);
|
|
|
|
}
|
|
|
|
|
2009-12-04 08:41:11 +00:00
|
|
|
#endif /* __MANTIS_COMMON_H */
|