mantis_common.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. Mantis PCI bridge driver
  3. Copyright (C) Manu Abraham (abraham.manu@gmail.com)
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #ifndef __MANTIS_COMMON_H
  17. #define __MANTIS_COMMON_H
  18. #include <linux/mutex.h>
  19. #include <linux/workqueue.h>
  20. #include "mantis_uart.h"
  21. #include "mantis_link.h"
  22. #define MANTIS_ERROR 0
  23. #define MANTIS_NOTICE 1
  24. #define MANTIS_INFO 2
  25. #define MANTIS_DEBUG 3
  26. #define MANTIS_TMG 9
  27. #define dprintk(y, z, format, arg...) do { \
  28. if (z) { \
  29. if ((mantis->verbose > MANTIS_ERROR) && (mantis->verbose > y)) \
  30. printk(KERN_ERR "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
  31. else if ((mantis->verbose > MANTIS_NOTICE) && (mantis->verbose > y)) \
  32. printk(KERN_NOTICE "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
  33. else if ((mantis->verbose > MANTIS_INFO) && (mantis->verbose > y)) \
  34. printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
  35. else if ((mantis->verbose > MANTIS_DEBUG) && (mantis->verbose > y)) \
  36. printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
  37. else if ((mantis->verbose > MANTIS_TMG) && (mantis->verbose > y)) \
  38. printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
  39. } else { \
  40. if (mantis->verbose > y) \
  41. printk(format , ##arg); \
  42. } \
  43. } while(0)
  44. #define mwrite(dat, addr) writel((dat), addr)
  45. #define mread(addr) readl(addr)
  46. #define mmwrite(dat, addr) mwrite((dat), (mantis->mmio + (addr)))
  47. #define mmread(addr) mread(mantis->mmio + (addr))
  48. #define MANTIS_TS_188 0
  49. #define MANTIS_TS_204 1
  50. #define TWINHAN_TECHNOLOGIES 0x1822
  51. #define MANTIS 0x4e35
  52. #define TECHNISAT 0x1ae4
  53. #define TERRATEC 0x153b
  54. #define MAKE_ENTRY(__subven, __subdev, __configptr) { \
  55. .vendor = TWINHAN_TECHNOLOGIES, \
  56. .device = MANTIS, \
  57. .subvendor = (__subven), \
  58. .subdevice = (__subdev), \
  59. .driver_data = (unsigned long) (__configptr) \
  60. }
  61. enum mantis_i2c_mode {
  62. MANTIS_PAGE_MODE = 0,
  63. MANTIS_BYTE_MODE,
  64. };
  65. struct mantis_pci;
  66. struct mantis_hwconfig {
  67. char *model_name;
  68. char *dev_type;
  69. u32 ts_size;
  70. enum mantis_baud baud_rate;
  71. enum mantis_parity parity;
  72. u32 bytes;
  73. irqreturn_t (*irq_handler)(int irq, void *dev_id);
  74. int (*frontend_init)(struct mantis_pci *mantis, struct dvb_frontend *fe);
  75. u8 power;
  76. u8 reset;
  77. enum mantis_i2c_mode i2c_mode;
  78. };
  79. struct mantis_pci {
  80. unsigned int verbose;
  81. /* PCI stuff */
  82. u16 vendor_id;
  83. u16 device_id;
  84. u16 subsystem_vendor;
  85. u16 subsystem_device;
  86. u8 latency;
  87. struct pci_dev *pdev;
  88. unsigned long mantis_addr;
  89. void __iomem *mmio;
  90. u8 irq;
  91. u8 revision;
  92. unsigned int num;
  93. /* RISC Core */
  94. u32 finished_block;
  95. u32 last_block;
  96. u32 line_bytes;
  97. u32 line_count;
  98. u32 risc_pos;
  99. u8 *buf_cpu;
  100. dma_addr_t buf_dma;
  101. u32 *risc_cpu;
  102. dma_addr_t risc_dma;
  103. struct tasklet_struct tasklet;
  104. struct i2c_adapter adapter;
  105. int i2c_rc;
  106. wait_queue_head_t i2c_wq;
  107. struct mutex i2c_lock;
  108. /* DVB stuff */
  109. struct dvb_adapter dvb_adapter;
  110. struct dvb_frontend *fe;
  111. struct dvb_demux demux;
  112. struct dmxdev dmxdev;
  113. struct dmx_frontend fe_hw;
  114. struct dmx_frontend fe_mem;
  115. struct dvb_net dvbnet;
  116. u8 feeds;
  117. struct mantis_hwconfig *hwconfig;
  118. u32 mantis_int_stat;
  119. u32 mantis_int_mask;
  120. /* board specific */
  121. u8 mac_address[8];
  122. u32 sub_vendor_id;
  123. u32 sub_device_id;
  124. /* A12 A13 A14 */
  125. u32 gpio_status;
  126. u32 gpif_status;
  127. struct mantis_ca *mantis_ca;
  128. wait_queue_head_t uart_wq;
  129. struct work_struct uart_work;
  130. spinlock_t uart_lock;
  131. struct rc_dev *rc;
  132. char input_name[80];
  133. char input_phys[80];
  134. };
  135. #define MANTIS_HIF_STATUS (mantis->gpio_status)
  136. #endif /* __MANTIS_COMMON_H */