mantis_common.h 4.9 KB

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