scif_bus.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. */
  46. struct scif_hw_dev {
  47. struct scif_hw_ops *hw_ops;
  48. struct scif_hw_dev_id id;
  49. struct mic_mw *mmio;
  50. struct mic_mw *aper;
  51. struct device dev;
  52. u8 dnode;
  53. u8 snode;
  54. void *dp;
  55. void __iomem *rdp;
  56. struct dma_chan **dma_ch;
  57. int num_dma_ch;
  58. };
  59. /**
  60. * scif_driver - operations for a scif I/O driver
  61. * @driver: underlying device driver (populate name and owner).
  62. * @id_table: the ids serviced by this driver.
  63. * @probe: the function to call when a device is found. Returns 0 or -errno.
  64. * @remove: the function to call when a device is removed.
  65. */
  66. struct scif_driver {
  67. struct device_driver driver;
  68. const struct scif_hw_dev_id *id_table;
  69. int (*probe)(struct scif_hw_dev *dev);
  70. void (*remove)(struct scif_hw_dev *dev);
  71. };
  72. /**
  73. * scif_hw_ops - Hardware operations for accessing a SCIF device on the SCIF bus.
  74. *
  75. * @next_db: Obtain the next available doorbell.
  76. * @request_irq: Request an interrupt on a particular doorbell.
  77. * @free_irq: Free an interrupt requested previously.
  78. * @ack_interrupt: acknowledge an interrupt in the ISR.
  79. * @send_intr: Send an interrupt to the remote node on a specified doorbell.
  80. * @send_p2p_intr: Send an interrupt to the peer node on a specified doorbell
  81. * which is specifically targeted for a peer to peer node.
  82. * @ioremap: Map a buffer with the specified physical address and length.
  83. * @iounmap: Unmap a buffer previously mapped.
  84. */
  85. struct scif_hw_ops {
  86. int (*next_db)(struct scif_hw_dev *sdev);
  87. struct mic_irq * (*request_irq)(struct scif_hw_dev *sdev,
  88. irqreturn_t (*func)(int irq,
  89. void *data),
  90. const char *name, void *data,
  91. int db);
  92. void (*free_irq)(struct scif_hw_dev *sdev,
  93. struct mic_irq *cookie, void *data);
  94. void (*ack_interrupt)(struct scif_hw_dev *sdev, int num);
  95. void (*send_intr)(struct scif_hw_dev *sdev, int db);
  96. void (*send_p2p_intr)(struct scif_hw_dev *sdev, int db,
  97. struct mic_mw *mw);
  98. void __iomem * (*ioremap)(struct scif_hw_dev *sdev,
  99. phys_addr_t pa, size_t len);
  100. void (*iounmap)(struct scif_hw_dev *sdev, void __iomem *va);
  101. };
  102. int scif_register_driver(struct scif_driver *driver);
  103. void scif_unregister_driver(struct scif_driver *driver);
  104. struct scif_hw_dev *
  105. scif_register_device(struct device *pdev, int id,
  106. struct dma_map_ops *dma_ops,
  107. struct scif_hw_ops *hw_ops, u8 dnode, u8 snode,
  108. struct mic_mw *mmio, struct mic_mw *aper,
  109. void *dp, void __iomem *rdp,
  110. struct dma_chan **chan, int num_chan);
  111. void scif_unregister_device(struct scif_hw_dev *sdev);
  112. static inline struct scif_hw_dev *dev_to_scif(struct device *dev)
  113. {
  114. return container_of(dev, struct scif_hw_dev, dev);
  115. }
  116. static inline struct scif_driver *drv_to_scif(struct device_driver *drv)
  117. {
  118. return container_of(drv, struct scif_driver, driver);
  119. }
  120. #endif /* _SCIF_BUS_H */