mic_device.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. * Intel MIC Host driver.
  19. *
  20. */
  21. #ifndef _MIC_DEVICE_H_
  22. #define _MIC_DEVICE_H_
  23. #include <linux/cdev.h>
  24. #include <linux/idr.h>
  25. #include <linux/notifier.h>
  26. #include <linux/irqreturn.h>
  27. #include <linux/dmaengine.h>
  28. #include <linux/miscdevice.h>
  29. #include <linux/mic_bus.h>
  30. #include "../bus/scif_bus.h"
  31. #include "../bus/vop_bus.h"
  32. #include "../bus/cosm_bus.h"
  33. #include "mic_intr.h"
  34. /**
  35. * enum mic_stepping - MIC stepping ids.
  36. */
  37. enum mic_stepping {
  38. MIC_A0_STEP = 0x0,
  39. MIC_B0_STEP = 0x10,
  40. MIC_B1_STEP = 0x11,
  41. MIC_C0_STEP = 0x20,
  42. };
  43. extern struct cosm_hw_ops cosm_hw_ops;
  44. /**
  45. * struct mic_device - MIC device information for each card.
  46. *
  47. * @mmio: MMIO bar information.
  48. * @aper: Aperture bar information.
  49. * @family: The MIC family to which this device belongs.
  50. * @ops: MIC HW specific operations.
  51. * @id: The unique device id for this MIC device.
  52. * @stepping: Stepping ID.
  53. * @pdev: Underlying PCI device.
  54. * @mic_mutex: Mutex for synchronizing access to mic_device.
  55. * @intr_ops: HW specific interrupt operations.
  56. * @smpt_ops: Hardware specific SMPT operations.
  57. * @smpt: MIC SMPT information.
  58. * @intr_info: H/W specific interrupt information.
  59. * @irq_info: The OS specific irq information
  60. * @dbg_dir: debugfs directory of this MIC device.
  61. * @bootaddr: MIC boot address.
  62. * @dp: virtio device page
  63. * @dp_dma_addr: virtio device page DMA address.
  64. * @dma_mbdev: MIC BUS DMA device.
  65. * @dma_ch - Array of DMA channels
  66. * @num_dma_ch - Number of DMA channels available
  67. * @scdev: SCIF device on the SCIF virtual bus.
  68. * @vpdev: Virtio over PCIe device on the VOP virtual bus.
  69. * @cosm_dev: COSM device
  70. */
  71. struct mic_device {
  72. struct mic_mw mmio;
  73. struct mic_mw aper;
  74. enum mic_hw_family family;
  75. struct mic_hw_ops *ops;
  76. int id;
  77. enum mic_stepping stepping;
  78. struct pci_dev *pdev;
  79. struct mutex mic_mutex;
  80. struct mic_hw_intr_ops *intr_ops;
  81. struct mic_smpt_ops *smpt_ops;
  82. struct mic_smpt_info *smpt;
  83. struct mic_intr_info *intr_info;
  84. struct mic_irq_info irq_info;
  85. struct dentry *dbg_dir;
  86. u32 bootaddr;
  87. void *dp;
  88. dma_addr_t dp_dma_addr;
  89. struct mbus_device *dma_mbdev;
  90. struct dma_chan *dma_ch[MIC_MAX_DMA_CHAN];
  91. int num_dma_ch;
  92. struct scif_hw_dev *scdev;
  93. struct vop_device *vpdev;
  94. struct cosm_device *cosm_dev;
  95. };
  96. /**
  97. * struct mic_hw_ops - MIC HW specific operations.
  98. * @aper_bar: Aperture bar resource number.
  99. * @mmio_bar: MMIO bar resource number.
  100. * @read_spad: Read from scratch pad register.
  101. * @write_spad: Write to scratch pad register.
  102. * @send_intr: Send an interrupt for a particular doorbell on the card.
  103. * @ack_interrupt: Hardware specific operations to ack the h/w on
  104. * receipt of an interrupt.
  105. * @intr_workarounds: Hardware specific workarounds needed after
  106. * handling an interrupt.
  107. * @reset: Reset the remote processor.
  108. * @reset_fw_ready: Reset firmware ready field.
  109. * @is_fw_ready: Check if firmware is ready for OS download.
  110. * @send_firmware_intr: Send an interrupt to the card firmware.
  111. * @load_mic_fw: Load firmware segments required to boot the card
  112. * into card memory. This includes the kernel, command line, ramdisk etc.
  113. * @get_postcode: Get post code status from firmware.
  114. * @dma_filter: DMA filter function to be used.
  115. */
  116. struct mic_hw_ops {
  117. u8 aper_bar;
  118. u8 mmio_bar;
  119. u32 (*read_spad)(struct mic_device *mdev, unsigned int idx);
  120. void (*write_spad)(struct mic_device *mdev, unsigned int idx, u32 val);
  121. void (*send_intr)(struct mic_device *mdev, int doorbell);
  122. u32 (*ack_interrupt)(struct mic_device *mdev);
  123. void (*intr_workarounds)(struct mic_device *mdev);
  124. void (*reset)(struct mic_device *mdev);
  125. void (*reset_fw_ready)(struct mic_device *mdev);
  126. bool (*is_fw_ready)(struct mic_device *mdev);
  127. void (*send_firmware_intr)(struct mic_device *mdev);
  128. int (*load_mic_fw)(struct mic_device *mdev, const char *buf);
  129. u32 (*get_postcode)(struct mic_device *mdev);
  130. bool (*dma_filter)(struct dma_chan *chan, void *param);
  131. };
  132. /**
  133. * mic_mmio_read - read from an MMIO register.
  134. * @mw: MMIO register base virtual address.
  135. * @offset: register offset.
  136. *
  137. * RETURNS: register value.
  138. */
  139. static inline u32 mic_mmio_read(struct mic_mw *mw, u32 offset)
  140. {
  141. return ioread32(mw->va + offset);
  142. }
  143. /**
  144. * mic_mmio_write - write to an MMIO register.
  145. * @mw: MMIO register base virtual address.
  146. * @val: the data value to put into the register
  147. * @offset: register offset.
  148. *
  149. * RETURNS: none.
  150. */
  151. static inline void
  152. mic_mmio_write(struct mic_mw *mw, u32 val, u32 offset)
  153. {
  154. iowrite32(val, mw->va + offset);
  155. }
  156. void mic_bootparam_init(struct mic_device *mdev);
  157. void mic_create_debug_dir(struct mic_device *dev);
  158. void mic_delete_debug_dir(struct mic_device *dev);
  159. void __init mic_init_debugfs(void);
  160. void mic_exit_debugfs(void);
  161. #endif