mic_bus.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. * The full GNU General Public License is included in this distribution in
  16. * the file called "COPYING".
  17. *
  18. * Intel MIC Bus driver.
  19. *
  20. * This implementation is very similar to the the virtio bus driver
  21. * implementation @ include/linux/virtio.h.
  22. */
  23. #ifndef _MIC_BUS_H_
  24. #define _MIC_BUS_H_
  25. /*
  26. * Everything a mbus driver needs to work with any particular mbus
  27. * implementation.
  28. */
  29. #include <linux/interrupt.h>
  30. #include <linux/dma-mapping.h>
  31. struct mbus_device_id {
  32. __u32 device;
  33. __u32 vendor;
  34. };
  35. #define MBUS_DEV_DMA_HOST 2
  36. #define MBUS_DEV_DMA_MIC 3
  37. #define MBUS_DEV_ANY_ID 0xffffffff
  38. /**
  39. * mbus_device - representation of a device using mbus
  40. * @mmio_va: virtual address of mmio space
  41. * @hw_ops: the hardware ops supported by this device.
  42. * @id: the device type identification (used to match it with a driver).
  43. * @dev: underlying device.
  44. * be used to communicate with.
  45. * @index: unique position on the mbus bus
  46. */
  47. struct mbus_device {
  48. void __iomem *mmio_va;
  49. struct mbus_hw_ops *hw_ops;
  50. struct mbus_device_id id;
  51. struct device dev;
  52. int index;
  53. };
  54. /**
  55. * mbus_driver - operations for a mbus I/O driver
  56. * @driver: underlying device driver (populate name and owner).
  57. * @id_table: the ids serviced by this driver.
  58. * @probe: the function to call when a device is found. Returns 0 or -errno.
  59. * @remove: the function to call when a device is removed.
  60. */
  61. struct mbus_driver {
  62. struct device_driver driver;
  63. const struct mbus_device_id *id_table;
  64. int (*probe)(struct mbus_device *dev);
  65. void (*scan)(struct mbus_device *dev);
  66. void (*remove)(struct mbus_device *dev);
  67. };
  68. /**
  69. * struct mic_irq - opaque pointer used as cookie
  70. */
  71. struct mic_irq;
  72. /**
  73. * mbus_hw_ops - Hardware operations for accessing a MIC device on the MIC bus.
  74. */
  75. struct mbus_hw_ops {
  76. struct mic_irq* (*request_threaded_irq)(struct mbus_device *mbdev,
  77. irq_handler_t handler,
  78. irq_handler_t thread_fn,
  79. const char *name, void *data,
  80. int intr_src);
  81. void (*free_irq)(struct mbus_device *mbdev,
  82. struct mic_irq *cookie, void *data);
  83. void (*ack_interrupt)(struct mbus_device *mbdev, int num);
  84. };
  85. struct mbus_device *
  86. mbus_register_device(struct device *pdev, int id, struct dma_map_ops *dma_ops,
  87. struct mbus_hw_ops *hw_ops, int index,
  88. void __iomem *mmio_va);
  89. void mbus_unregister_device(struct mbus_device *mbdev);
  90. int mbus_register_driver(struct mbus_driver *drv);
  91. void mbus_unregister_driver(struct mbus_driver *drv);
  92. static inline struct mbus_device *dev_to_mbus(struct device *_dev)
  93. {
  94. return container_of(_dev, struct mbus_device, dev);
  95. }
  96. static inline struct mbus_driver *drv_to_mbus(struct device_driver *drv)
  97. {
  98. return container_of(drv, struct mbus_driver, driver);
  99. }
  100. #endif /* _MIC_BUS_H */