mantis_common.h 4.3 KB

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