mantis_common.h 3.7 KB

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