netup_unidvb.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * netup_unidvb.h
  3. *
  4. * Data type definitions for NetUP Universal Dual DVB-CI
  5. *
  6. * Copyright (C) 2014 NetUP Inc.
  7. * Copyright (C) 2014 Sergey Kozlov <serjk@netup.ru>
  8. * Copyright (C) 2014 Abylay Ospan <aospan@netup.ru>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. */
  20. #include <linux/pci.h>
  21. #include <linux/i2c.h>
  22. #include <linux/workqueue.h>
  23. #include <media/v4l2-common.h>
  24. #include <media/v4l2-device.h>
  25. #include <media/videobuf2-dvb.h>
  26. #include <dvb_ca_en50221.h>
  27. #define NETUP_UNIDVB_NAME "netup_unidvb"
  28. #define NETUP_UNIDVB_VERSION "0.0.1"
  29. #define NETUP_VENDOR_ID 0x1b55
  30. #define NETUP_PCI_DEV_REVISION 0x2
  31. /* IRQ-related regisers */
  32. #define REG_ISR 0x4890
  33. #define REG_ISR_MASKED 0x4892
  34. #define REG_IMASK_SET 0x4894
  35. #define REG_IMASK_CLEAR 0x4896
  36. /* REG_ISR register bits */
  37. #define NETUP_UNIDVB_IRQ_SPI (1 << 0)
  38. #define NETUP_UNIDVB_IRQ_I2C0 (1 << 1)
  39. #define NETUP_UNIDVB_IRQ_I2C1 (1 << 2)
  40. #define NETUP_UNIDVB_IRQ_FRA0 (1 << 4)
  41. #define NETUP_UNIDVB_IRQ_FRA1 (1 << 5)
  42. #define NETUP_UNIDVB_IRQ_FRB0 (1 << 6)
  43. #define NETUP_UNIDVB_IRQ_FRB1 (1 << 7)
  44. #define NETUP_UNIDVB_IRQ_DMA1 (1 << 8)
  45. #define NETUP_UNIDVB_IRQ_DMA2 (1 << 9)
  46. #define NETUP_UNIDVB_IRQ_CI (1 << 10)
  47. #define NETUP_UNIDVB_IRQ_CAM0 (1 << 11)
  48. #define NETUP_UNIDVB_IRQ_CAM1 (1 << 12)
  49. struct netup_dma {
  50. u8 num;
  51. spinlock_t lock;
  52. struct netup_unidvb_dev *ndev;
  53. struct netup_dma_regs __iomem *regs;
  54. u32 ring_buffer_size;
  55. u8 *addr_virt;
  56. dma_addr_t addr_phys;
  57. u64 addr_last;
  58. u32 high_addr;
  59. u32 data_offset;
  60. u32 data_size;
  61. struct list_head free_buffers;
  62. struct work_struct work;
  63. struct timer_list timeout;
  64. };
  65. enum netup_i2c_state {
  66. STATE_DONE,
  67. STATE_WAIT,
  68. STATE_WANT_READ,
  69. STATE_WANT_WRITE,
  70. STATE_ERROR
  71. };
  72. struct netup_i2c_regs;
  73. struct netup_i2c {
  74. spinlock_t lock;
  75. wait_queue_head_t wq;
  76. struct i2c_adapter adap;
  77. struct netup_unidvb_dev *dev;
  78. struct netup_i2c_regs __iomem *regs;
  79. struct i2c_msg *msg;
  80. enum netup_i2c_state state;
  81. u32 xmit_size;
  82. };
  83. struct netup_ci_state {
  84. struct dvb_ca_en50221 ca;
  85. u8 __iomem *membase8_config;
  86. u8 __iomem *membase8_io;
  87. struct netup_unidvb_dev *dev;
  88. int status;
  89. int nr;
  90. };
  91. struct netup_spi;
  92. struct netup_unidvb_dev {
  93. struct pci_dev *pci_dev;
  94. int pci_bus;
  95. int pci_slot;
  96. int pci_func;
  97. int board_num;
  98. int old_fw;
  99. u32 __iomem *lmmio0;
  100. u8 __iomem *bmmio0;
  101. u32 __iomem *lmmio1;
  102. u8 __iomem *bmmio1;
  103. u8 *dma_virt;
  104. dma_addr_t dma_phys;
  105. u32 dma_size;
  106. struct vb2_dvb_frontends frontends[2];
  107. struct netup_i2c i2c[2];
  108. struct workqueue_struct *wq;
  109. struct netup_dma dma[2];
  110. struct netup_ci_state ci[2];
  111. struct netup_spi *spi;
  112. };
  113. int netup_i2c_register(struct netup_unidvb_dev *ndev);
  114. void netup_i2c_unregister(struct netup_unidvb_dev *ndev);
  115. irqreturn_t netup_ci_interrupt(struct netup_unidvb_dev *ndev);
  116. irqreturn_t netup_i2c_interrupt(struct netup_i2c *i2c);
  117. irqreturn_t netup_spi_interrupt(struct netup_spi *spi);
  118. int netup_unidvb_ci_register(struct netup_unidvb_dev *dev,
  119. int num, struct pci_dev *pci_dev);
  120. void netup_unidvb_ci_unregister(struct netup_unidvb_dev *dev, int num);
  121. int netup_spi_init(struct netup_unidvb_dev *ndev);
  122. void netup_spi_release(struct netup_unidvb_dev *ndev);