smd.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef __QCOM_SMD_H__
  2. #define __QCOM_SMD_H__
  3. #include <linux/device.h>
  4. #include <linux/mod_devicetable.h>
  5. struct qcom_smd;
  6. struct qcom_smd_channel;
  7. struct qcom_smd_lookup;
  8. /**
  9. * struct qcom_smd_id - struct used for matching a smd device
  10. * @name: name of the channel
  11. */
  12. struct qcom_smd_id {
  13. char name[20];
  14. };
  15. /**
  16. * struct qcom_smd_device - smd device struct
  17. * @dev: the device struct
  18. * @channel: handle to the smd channel for this device
  19. */
  20. struct qcom_smd_device {
  21. struct device dev;
  22. struct qcom_smd_channel *channel;
  23. };
  24. typedef int (*qcom_smd_cb_t)(struct qcom_smd_channel *, const void *, size_t);
  25. /**
  26. * struct qcom_smd_driver - smd driver struct
  27. * @driver: underlying device driver
  28. * @smd_match_table: static channel match table
  29. * @probe: invoked when the smd channel is found
  30. * @remove: invoked when the smd channel is closed
  31. * @callback: invoked when an inbound message is received on the channel,
  32. * should return 0 on success or -EBUSY if the data cannot be
  33. * consumed at this time
  34. */
  35. struct qcom_smd_driver {
  36. struct device_driver driver;
  37. const struct qcom_smd_id *smd_match_table;
  38. int (*probe)(struct qcom_smd_device *dev);
  39. void (*remove)(struct qcom_smd_device *dev);
  40. qcom_smd_cb_t callback;
  41. };
  42. int qcom_smd_driver_register(struct qcom_smd_driver *drv);
  43. void qcom_smd_driver_unregister(struct qcom_smd_driver *drv);
  44. void *qcom_smd_get_drvdata(struct qcom_smd_channel *channel);
  45. void qcom_smd_set_drvdata(struct qcom_smd_channel *channel, void *data);
  46. #define module_qcom_smd_driver(__smd_driver) \
  47. module_driver(__smd_driver, qcom_smd_driver_register, \
  48. qcom_smd_driver_unregister)
  49. int qcom_smd_send(struct qcom_smd_channel *channel, const void *data, int len);
  50. struct qcom_smd_channel *qcom_smd_open_channel(struct qcom_smd_channel *channel,
  51. const char *name,
  52. qcom_smd_cb_t cb);
  53. #endif