mantis_common.h 3.8 KB

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