mantis_common.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. Mantis PCI bridge driver
  3. Copyright (C) 2005, 2006 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/module.h>
  19. #include <linux/moduleparam.h>
  20. #include <linux/kernel.h>
  21. #include <linux/pci.h>
  22. #include <linux/mutex.h>
  23. #include "dvbdev.h"
  24. #include "dvb_demux.h"
  25. #include "dmxdev.h"
  26. #include "dvb_frontend.h"
  27. #include "dvb_net.h"
  28. #include <linux/i2c.h>
  29. #include "mantis_reg.h"
  30. #include "mantis_link.h"
  31. #define MANTIS_ERROR 0
  32. #define MANTIS_NOTICE 1
  33. #define MANTIS_INFO 2
  34. #define MANTIS_DEBUG 3
  35. #define dprintk(x, y, z, format, arg...) do { \
  36. if (z) { \
  37. if ((x > MANTIS_ERROR) && (x > y)) \
  38. printk(KERN_ERR "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
  39. else if ((x > MANTIS_NOTICE) && (x > y)) \
  40. printk(KERN_NOTICE "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
  41. else if ((x > MANTIS_INFO) && (x > y)) \
  42. printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
  43. else if ((x > MANTIS_DEBUG) && (x > y)) \
  44. printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \
  45. } else { \
  46. if (x > y) \
  47. printk(format , ##arg); \
  48. } \
  49. } while(0)
  50. #define mwrite(dat, addr) writel((dat), addr)
  51. #define mread(addr) readl(addr)
  52. #define mmwrite(dat, addr) mwrite((dat), (mantis->mantis_mmio + (addr)))
  53. #define mmread(addr) mread(mantis->mantis_mmio + (addr))
  54. #define mmand(dat, addr) mmwrite((dat) & mmread(addr), addr)
  55. #define mmor(dat, addr) mmwrite((dat) | mmread(addr), addr)
  56. #define mmaor(dat, addr) mmwrite((dat) | ((mask) & mmread(addr)), addr)
  57. #define MANTIS_TS_188 0
  58. #define MANTIS_TS_204 1
  59. struct mantis_hwconfig {
  60. char *model_name;
  61. char *dev_type;
  62. u32 ts_size;
  63. };
  64. struct mantis_pci {
  65. unsigned int verbose;
  66. /* PCI stuff */
  67. u16 vendor_id;
  68. u16 device_id;
  69. u16 subsystem_vendor;
  70. u16 subsystem_device;
  71. u8 latency;
  72. struct pci_dev *pdev;
  73. unsigned long mantis_addr;
  74. volatile void __iomem *mantis_mmio;
  75. u8 irq;
  76. u8 revision;
  77. unsigned int num;
  78. /* RISC Core */
  79. u32 finished_block;
  80. u32 last_block;
  81. u32 line_bytes;
  82. u32 line_count;
  83. u32 risc_pos;
  84. u8 *buf_cpu;
  85. dma_addr_t buf_dma;
  86. u32 *risc_cpu;
  87. dma_addr_t risc_dma;
  88. struct tasklet_struct tasklet;
  89. struct i2c_adapter adapter;
  90. int i2c_rc;
  91. wait_queue_head_t i2c_wq;
  92. struct mutex i2c_lock;
  93. /* DVB stuff */
  94. struct dvb_adapter dvb_adapter;
  95. struct dvb_frontend *fe;
  96. struct dvb_demux demux;
  97. struct dmxdev dmxdev;
  98. struct dmx_frontend fe_hw;
  99. struct dmx_frontend fe_mem;
  100. struct dvb_net dvbnet;
  101. u8 feeds;
  102. struct mantis_hwconfig *hwconfig;
  103. u32 mantis_int_stat;
  104. u32 mantis_int_mask;
  105. /* board specific */
  106. u8 mac_address[8];
  107. u32 sub_vendor_id;
  108. u32 sub_device_id;
  109. /* A12 A13 A14 */
  110. u32 gpio_status;
  111. struct mantis_ca *mantis_ca;
  112. };
  113. extern unsigned int verbose;
  114. extern unsigned int devs;
  115. extern unsigned int i2c;
  116. extern int mantis_dvb_init(struct mantis_pci *mantis);
  117. extern int mantis_frontend_init(struct mantis_pci *mantis);
  118. extern int mantis_dvb_exit(struct mantis_pci *mantis);
  119. extern void mantis_dma_xfer(unsigned long data);
  120. extern void gpio_set_bits(struct mantis_pci *mantis, u32 bitpos, u8 value);
  121. extern int mantis_ca_init(struct mantis_pci *mantis);
  122. extern void mantis_ca_exit(struct mantis_pci *mantis);
  123. #endif //__MANTIS_COMMON_H