linux/drivers/media/pci/mantis/mantis_common.h
<<
>>
Prefs
   1/*
   2        Mantis PCI bridge driver
   3
   4        Copyright (C) Manu Abraham (abraham.manu@gmail.com)
   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
  24#include <linux/interrupt.h>
  25#include <linux/mutex.h>
  26#include <linux/workqueue.h>
  27
  28#include "mantis_reg.h"
  29#include "mantis_uart.h"
  30
  31#include "mantis_link.h"
  32
  33#define MANTIS_ERROR            0
  34#define MANTIS_NOTICE           1
  35#define MANTIS_INFO             2
  36#define MANTIS_DEBUG            3
  37#define MANTIS_TMG              9
  38
  39#define dprintk(y, z, format, arg...) do {                                                              \
  40        if (z) {                                                                                        \
  41                if      ((mantis->verbose > MANTIS_ERROR) && (mantis->verbose > y))                     \
  42                        printk(KERN_ERR "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);      \
  43                else if ((mantis->verbose > MANTIS_NOTICE) && (mantis->verbose > y))                    \
  44                        printk(KERN_NOTICE "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);   \
  45                else if ((mantis->verbose > MANTIS_INFO) && (mantis->verbose > y))                      \
  46                        printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);     \
  47                else if ((mantis->verbose > MANTIS_DEBUG) && (mantis->verbose > y))                     \
  48                        printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);    \
  49                else if ((mantis->verbose > MANTIS_TMG) && (mantis->verbose > y))                       \
  50                        printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);    \
  51        } else {                                                                                        \
  52                if (mantis->verbose > y)                                                                \
  53                        printk(format , ##arg);                                                         \
  54        }                                                                                               \
  55} while(0)
  56
  57#define mwrite(dat, addr)       writel((dat), addr)
  58#define mread(addr)             readl(addr)
  59
  60#define mmwrite(dat, addr)      mwrite((dat), (mantis->mmio + (addr)))
  61#define mmread(addr)            mread(mantis->mmio + (addr))
  62
  63#define MANTIS_TS_188           0
  64#define MANTIS_TS_204           1
  65
  66#define TWINHAN_TECHNOLOGIES    0x1822
  67#define MANTIS                  0x4e35
  68
  69#define TECHNISAT               0x1ae4
  70#define TERRATEC                0x153b
  71
  72#define MAKE_ENTRY(__subven, __subdev, __configptr, __rc) {             \
  73                .vendor         = TWINHAN_TECHNOLOGIES,                 \
  74                .device         = MANTIS,                               \
  75                .subvendor      = (__subven),                           \
  76                .subdevice      = (__subdev),                           \
  77                .driver_data    = (unsigned long)                       \
  78                        &(struct mantis_pci_drvdata){__configptr, __rc} \
  79}
  80
  81enum mantis_i2c_mode {
  82        MANTIS_PAGE_MODE = 0,
  83        MANTIS_BYTE_MODE,
  84};
  85
  86struct mantis_pci;
  87
  88struct mantis_hwconfig {
  89        char                    *model_name;
  90        char                    *dev_type;
  91        u32                     ts_size;
  92
  93        enum mantis_baud        baud_rate;
  94        enum mantis_parity      parity;
  95        u32                     bytes;
  96
  97        irqreturn_t (*irq_handler)(int irq, void *dev_id);
  98        int (*frontend_init)(struct mantis_pci *mantis, struct dvb_frontend *fe);
  99
 100        u8                      power;
 101        u8                      reset;
 102
 103        enum mantis_i2c_mode    i2c_mode;
 104};
 105
 106struct mantis_pci_drvdata {
 107        struct mantis_hwconfig *hwconfig;
 108        char *rc_map_name;
 109};
 110
 111struct mantis_pci {
 112        unsigned int            verbose;
 113
 114        /*      PCI stuff               */
 115        u16                     vendor_id;
 116        u16                     device_id;
 117        u16                     subsystem_vendor;
 118        u16                     subsystem_device;
 119
 120        u8                      latency;
 121
 122        struct pci_dev          *pdev;
 123
 124        unsigned long           mantis_addr;
 125        void __iomem            *mmio;
 126
 127        u8                      irq;
 128        u8                      revision;
 129
 130        unsigned int            num;
 131
 132        /*      RISC Core               */
 133        u32                     busy_block;
 134        u32                     last_block;
 135        u8                      *buf_cpu;
 136        dma_addr_t              buf_dma;
 137        __le32                  *risc_cpu;
 138        dma_addr_t              risc_dma;
 139
 140        struct tasklet_struct   tasklet;
 141        spinlock_t              intmask_lock;
 142
 143        struct i2c_adapter      adapter;
 144        int                     i2c_rc;
 145        wait_queue_head_t       i2c_wq;
 146        struct mutex            i2c_lock;
 147
 148        /*      DVB stuff               */
 149        struct dvb_adapter      dvb_adapter;
 150        struct dvb_frontend     *fe;
 151        struct dvb_demux        demux;
 152        struct dmxdev           dmxdev;
 153        struct dmx_frontend     fe_hw;
 154        struct dmx_frontend     fe_mem;
 155        struct dvb_net          dvbnet;
 156
 157        u8                      feeds;
 158
 159        struct mantis_hwconfig  *hwconfig;
 160
 161        u32                     mantis_int_stat;
 162        u32                     mantis_int_mask;
 163
 164        /*      board specific          */
 165        u8                      mac_address[8];
 166        u32                     sub_vendor_id;
 167        u32                     sub_device_id;
 168
 169         /*     A12 A13 A14             */
 170        u32                     gpio_status;
 171
 172        u32                     gpif_status;
 173
 174        struct mantis_ca        *mantis_ca;
 175
 176        struct work_struct      uart_work;
 177
 178        struct rc_dev           *rc;
 179        char                    input_name[80];
 180        char                    input_phys[80];
 181        char                    *rc_map_name;
 182};
 183
 184#define MANTIS_HIF_STATUS       (mantis->gpio_status)
 185
 186static inline void mantis_mask_ints(struct mantis_pci *mantis, u32 mask)
 187{
 188        unsigned long flags;
 189
 190        spin_lock_irqsave(&mantis->intmask_lock, flags);
 191        mmwrite(mmread(MANTIS_INT_MASK) & ~mask, MANTIS_INT_MASK);
 192        spin_unlock_irqrestore(&mantis->intmask_lock, flags);
 193}
 194
 195static inline void mantis_unmask_ints(struct mantis_pci *mantis, u32 mask)
 196{
 197        unsigned long flags;
 198
 199        spin_lock_irqsave(&mantis->intmask_lock, flags);
 200        mmwrite(mmread(MANTIS_INT_MASK) | mask, MANTIS_INT_MASK);
 201        spin_unlock_irqrestore(&mantis->intmask_lock, flags);
 202}
 203
 204#endif /* __MANTIS_COMMON_H */
 205