mic_device.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Intel MIC Platform Software Stack (MPSS)
  3. *
  4. * Copyright(c) 2013 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License, version 2, as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * The full GNU General Public License is included in this distribution in
  16. * the file called "COPYING".
  17. *
  18. * Disclaimer: The codes contained in these modules may be specific to
  19. * the Intel Software Development Platform codenamed: Knights Ferry, and
  20. * the Intel product codenamed: Knights Corner, and are not backward
  21. * compatible with other Intel products. Additionally, Intel will NOT
  22. * support the codes or instruction set in future products.
  23. *
  24. * Intel MIC Card driver.
  25. *
  26. */
  27. #ifndef _MIC_CARD_DEVICE_H_
  28. #define _MIC_CARD_DEVICE_H_
  29. #include <linux/workqueue.h>
  30. #include <linux/io.h>
  31. #include <linux/irqreturn.h>
  32. #include <linux/interrupt.h>
  33. #include <linux/mic_bus.h>
  34. /**
  35. * struct mic_intr_info - Contains h/w specific interrupt sources info
  36. *
  37. * @num_intr: The number of irqs available
  38. */
  39. struct mic_intr_info {
  40. u32 num_intr;
  41. };
  42. /**
  43. * struct mic_irq_info - OS specific irq information
  44. *
  45. * @irq_usage_count: usage count array tracking the number of sources
  46. * assigned for each irq.
  47. */
  48. struct mic_irq_info {
  49. int *irq_usage_count;
  50. };
  51. /**
  52. * struct mic_device - MIC device information.
  53. *
  54. * @mmio: MMIO bar information.
  55. */
  56. struct mic_device {
  57. struct mic_mw mmio;
  58. };
  59. /**
  60. * struct mic_driver - MIC card driver information.
  61. *
  62. * @name: Name for MIC driver.
  63. * @dbg_dir: debugfs directory of this MIC device.
  64. * @dev: The device backing this MIC.
  65. * @dp: The pointer to the virtio device page.
  66. * @mdev: MIC device information for the host.
  67. * @hotplug_work: Hot plug work for adding/removing virtio devices.
  68. * @irq_info: The OS specific irq information
  69. * @intr_info: H/W specific interrupt information.
  70. * @dma_mbdev: dma device on the MIC virtual bus.
  71. */
  72. struct mic_driver {
  73. char name[20];
  74. struct dentry *dbg_dir;
  75. struct device *dev;
  76. void __iomem *dp;
  77. struct mic_device mdev;
  78. struct work_struct hotplug_work;
  79. struct mic_irq_info irq_info;
  80. struct mic_intr_info intr_info;
  81. struct mbus_device *dma_mbdev;
  82. };
  83. /**
  84. * struct mic_irq - opaque pointer used as cookie
  85. */
  86. struct mic_irq;
  87. /**
  88. * mic_mmio_read - read from an MMIO register.
  89. * @mw: MMIO register base virtual address.
  90. * @offset: register offset.
  91. *
  92. * RETURNS: register value.
  93. */
  94. static inline u32 mic_mmio_read(struct mic_mw *mw, u32 offset)
  95. {
  96. return ioread32(mw->va + offset);
  97. }
  98. /**
  99. * mic_mmio_write - write to an MMIO register.
  100. * @mw: MMIO register base virtual address.
  101. * @val: the data value to put into the register
  102. * @offset: register offset.
  103. *
  104. * RETURNS: none.
  105. */
  106. static inline void
  107. mic_mmio_write(struct mic_mw *mw, u32 val, u32 offset)
  108. {
  109. iowrite32(val, mw->va + offset);
  110. }
  111. int mic_driver_init(struct mic_driver *mdrv);
  112. void mic_driver_uninit(struct mic_driver *mdrv);
  113. int mic_next_card_db(void);
  114. struct mic_irq *
  115. mic_request_card_irq(irq_handler_t handler, irq_handler_t thread_fn,
  116. const char *name, void *data, int intr_src);
  117. void mic_free_card_irq(struct mic_irq *cookie, void *data);
  118. u32 mic_read_spad(struct mic_device *mdev, unsigned int idx);
  119. void mic_send_intr(struct mic_device *mdev, int doorbell);
  120. int mic_db_to_irq(struct mic_driver *mdrv, int db);
  121. u32 mic_ack_interrupt(struct mic_device *mdev);
  122. void mic_hw_intr_init(struct mic_driver *mdrv);
  123. void __iomem *
  124. mic_card_map(struct mic_device *mdev, dma_addr_t addr, size_t size);
  125. void mic_card_unmap(struct mic_device *mdev, void __iomem *addr);
  126. void __init mic_create_card_debug_dir(struct mic_driver *mdrv);
  127. void mic_delete_card_debug_dir(struct mic_driver *mdrv);
  128. void __init mic_init_card_debugfs(void);
  129. void mic_exit_card_debugfs(void);
  130. #endif