mantis_common.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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/interrupt.h>
  19. #include <linux/mutex.h>
  20. #include <linux/workqueue.h>
  21. #include "mantis_uart.h"
  22. #include "mantis_link.h"
  23. #define MANTIS_ERROR 0
  24. #define MANTIS_NOTICE 1
  25. #define MANTIS_INFO 2
  26. #define MANTIS_DEBUG 3
  27. #define MANTIS_TMG 9
  28. #define dprintk(y, z, format, arg...) do { \
  29. if (z) { \
  30. if ((mantis->verbose > MANTIS_ERROR) && (mantis->verbose > y)) \
  31. printk(KERN_ERR "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
  32. else if ((mantis->verbose > MANTIS_NOTICE) && (mantis->verbose > y)) \
  33. printk(KERN_NOTICE "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
  34. else if ((mantis->verbose > MANTIS_INFO) && (mantis->verbose > y)) \
  35. printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
  36. else if ((mantis->verbose > MANTIS_DEBUG) && (mantis->verbose > y)) \
  37. printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
  38. else if ((mantis->verbose > MANTIS_TMG) && (mantis->verbose > y)) \
  39. printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
  40. } else { \
  41. if (mantis->verbose > y) \
  42. printk(format , ##arg); \
  43. } \
  44. } while(0)
  45. #define mwrite(dat, addr) writel((dat), addr)
  46. #define mread(addr) readl(addr)
  47. #define mmwrite(dat, addr) mwrite((dat), (mantis->mmio + (addr)))
  48. #define mmread(addr) mread(mantis->mmio + (addr))
  49. #define MANTIS_TS_188 0
  50. #define MANTIS_TS_204 1
  51. #define TWINHAN_TECHNOLOGIES 0x1822
  52. #define MANTIS 0x4e35
  53. #define TECHNISAT 0x1ae4
  54. #define TERRATEC 0x153b
  55. #define MAKE_ENTRY(__subven, __subdev, __configptr) { \
  56. .vendor = TWINHAN_TECHNOLOGIES, \
  57. .device = MANTIS, \
  58. .subvendor = (__subven), \
  59. .subdevice = (__subdev), \
  60. .driver_data = (unsigned long) (__configptr) \
  61. }
  62. enum mantis_i2c_mode {
  63. MANTIS_PAGE_MODE = 0,
  64. MANTIS_BYTE_MODE,
  65. };
  66. struct mantis_pci;
  67. struct mantis_hwconfig {
  68. char *model_name;
  69. char *dev_type;
  70. u32 ts_size;
  71. enum mantis_baud baud_rate;
  72. enum mantis_parity parity;
  73. u32 bytes;
  74. irqreturn_t (*irq_handler)(int irq, void *dev_id);
  75. int (*frontend_init)(struct mantis_pci *mantis, struct dvb_frontend *fe);
  76. u8 power;
  77. u8 reset;
  78. enum mantis_i2c_mode i2c_mode;
  79. };
  80. struct mantis_pci {
  81. unsigned int verbose;
  82. /* PCI stuff */
  83. u16 vendor_id;
  84. u16 device_id;
  85. u16 subsystem_vendor;
  86. u16 subsystem_device;
  87. u8 latency;
  88. struct pci_dev *pdev;
  89. unsigned long mantis_addr;
  90. void __iomem *mmio;
  91. u8 irq;
  92. u8 revision;
  93. unsigned int num;
  94. /* RISC Core */
  95. u32 busy_block;
  96. u32 last_block;
  97. u8 *buf_cpu;
  98. dma_addr_t buf_dma;
  99. u32 *risc_cpu;
  100. dma_addr_t risc_dma;
  101. struct tasklet_struct tasklet;
  102. struct i2c_adapter adapter;
  103. int i2c_rc;
  104. wait_queue_head_t i2c_wq;
  105. struct mutex i2c_lock;
  106. /* DVB stuff */
  107. struct dvb_adapter dvb_adapter;
  108. struct dvb_frontend *fe;
  109. struct dvb_demux demux;
  110. struct dmxdev dmxdev;
  111. struct dmx_frontend fe_hw;
  112. struct dmx_frontend fe_mem;
  113. struct dvb_net dvbnet;
  114. u8 feeds;
  115. struct mantis_hwconfig *hwconfig;
  116. u32 mantis_int_stat;
  117. u32 mantis_int_mask;
  118. /* board specific */
  119. u8 mac_address[8];
  120. u32 sub_vendor_id;
  121. u32 sub_device_id;
  122. /* A12 A13 A14 */
  123. u32 gpio_status;
  124. u32 gpif_status;
  125. struct mantis_ca *mantis_ca;
  126. wait_queue_head_t uart_wq;
  127. struct work_struct uart_work;
  128. spinlock_t uart_lock;
  129. struct rc_dev *rc;
  130. char input_name[80];
  131. char input_phys[80];
  132. };
  133. #define MANTIS_HIF_STATUS (mantis->gpio_status)
  134. #endif /* __MANTIS_COMMON_H */