scif_bus.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * Intel MIC Platform Software Stack (MPSS)
  3. *
  4. * Copyright(c) 2014 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. * Intel Symmetric Communications Interface Bus driver.
  16. */
  17. #ifndef _SCIF_BUS_H_
  18. #define _SCIF_BUS_H_
  19. /*
  20. * Everything a scif driver needs to work with any particular scif
  21. * hardware abstraction layer.
  22. */
  23. #include <linux/dma-mapping.h>
  24. #include <linux/mic_common.h>
  25. #include "../common/mic_dev.h"
  26. struct scif_hw_dev_id {
  27. u32 device;
  28. u32 vendor;
  29. };
  30. #define MIC_SCIF_DEV 1
  31. #define SCIF_DEV_ANY_ID 0xffffffff
  32. /**
  33. * scif_hw_dev - representation of a hardware device abstracted for scif
  34. * @hw_ops: the hardware ops supported by this device
  35. * @id: the device type identification (used to match it with a driver)
  36. * @mmio: MMIO memory window
  37. * @aper: Aperture memory window
  38. * @dev: underlying device
  39. * @dnode - The destination node which this device will communicate with.
  40. * @snode - The source node for this device.
  41. * @dp - Self device page
  42. * @rdp - Remote device page
  43. * @dma_ch - Array of DMA channels
  44. * @num_dma_ch - Number of DMA channels available
  45. * @card_rel_da - Set to true if DMA addresses programmed in the DMA engine
  46. * are relative to the card point of view
  47. */
  48. struct scif_hw_dev {
  49. struct scif_hw_ops *hw_ops;
  50. struct scif_hw_dev_id id;
  51. struct mic_mw *mmio;
  52. struct mic_mw *aper;
  53. struct device dev;
  54. u8 dnode;
  55. u8 snode;
  56. void *dp;
  57. void __iomem *rdp;
  58. struct dma_chan **dma_ch;
  59. int num_dma_ch;
  60. bool card_rel_da;
  61. };
  62. /**
  63. * scif_driver - operations for a scif I/O driver
  64. * @driver: underlying device driver (populate name and owner).
  65. * @id_table: the ids serviced by this driver.
  66. * @probe: the function to call when a device is found. Returns 0 or -errno.
  67. * @remove: the function to call when a device is removed.
  68. */
  69. struct scif_driver {
  70. struct device_driver driver;
  71. const struct scif_hw_dev_id *id_table;
  72. int (*probe)(struct scif_hw_dev *dev);
  73. void (*remove)(struct scif_hw_dev *dev);
  74. };
  75. /**
  76. * scif_hw_ops - Hardware operations for accessing a SCIF device on the SCIF bus.
  77. *
  78. * @next_db: Obtain the next available doorbell.
  79. * @request_irq: Request an interrupt on a particular doorbell.
  80. * @free_irq: Free an interrupt requested previously.
  81. * @ack_interrupt: acknowledge an interrupt in the ISR.
  82. * @send_intr: Send an interrupt to the remote node on a specified doorbell.
  83. * @send_p2p_intr: Send an interrupt to the peer node on a specified doorbell
  84. * which is specifically targeted for a peer to peer node.
  85. * @ioremap: Map a buffer with the specified physical address and length.
  86. * @iounmap: Unmap a buffer previously mapped.
  87. */
  88. struct scif_hw_ops {
  89. int (*next_db)(struct scif_hw_dev *sdev);
  90. struct mic_irq * (*request_irq)(struct scif_hw_dev *sdev,
  91. irqreturn_t (*func)(int irq,
  92. void *data),
  93. const char *name, void *data,
  94. int db);
  95. void (*free_irq)(struct scif_hw_dev *sdev,
  96. struct mic_irq *cookie, void *data);
  97. void (*ack_interrupt)(struct scif_hw_dev *sdev, int num);
  98. void (*send_intr)(struct scif_hw_dev *sdev, int db);
  99. void (*send_p2p_intr)(struct scif_hw_dev *sdev, int db,
  100. struct mic_mw *mw);
  101. void __iomem * (*ioremap)(struct scif_hw_dev *sdev,
  102. phys_addr_t pa, size_t len);
  103. void (*iounmap)(struct scif_hw_dev *sdev, void __iomem *va);
  104. };
  105. int scif_register_driver(struct scif_driver *driver);
  106. void scif_unregister_driver(struct scif_driver *driver);
  107. struct scif_hw_dev *
  108. scif_register_device(struct device *pdev, int id,
  109. const struct dma_map_ops *dma_ops,
  110. struct scif_hw_ops *hw_ops, u8 dnode, u8 snode,
  111. struct mic_mw *mmio, struct mic_mw *aper,
  112. void *dp, void __iomem *rdp,
  113. struct dma_chan **chan, int num_chan,
  114. bool card_rel_da);
  115. void scif_unregister_device(struct scif_hw_dev *sdev);
  116. static inline struct scif_hw_dev *dev_to_scif(struct device *dev)
  117. {
  118. return container_of(dev, struct scif_hw_dev, dev);
  119. }
  120. static inline struct scif_driver *drv_to_scif(struct device_driver *drv)
  121. {
  122. return container_of(drv, struct scif_driver, driver);
  123. }
  124. #endif /* _SCIF_BUS_H */