mailbox.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
  2. /*
  3. * Apple mailbox message format
  4. *
  5. * Copyright The Asahi Linux Contributors
  6. */
  7. #ifndef _APPLE_MAILBOX_H_
  8. #define _APPLE_MAILBOX_H_
  9. #include <linux/device.h>
  10. #include <linux/types.h>
  11. /* encodes a single 96bit message sent over the single channel */
  12. struct apple_mbox_msg {
  13. u64 msg0;
  14. u32 msg1;
  15. };
  16. struct apple_mbox {
  17. struct device *dev;
  18. void __iomem *regs;
  19. const struct apple_mbox_hw *hw;
  20. bool active;
  21. int irq_recv_not_empty;
  22. int irq_send_empty;
  23. spinlock_t rx_lock;
  24. spinlock_t tx_lock;
  25. struct completion tx_empty;
  26. /** Receive callback for incoming messages */
  27. void (*rx)(struct apple_mbox *mbox, struct apple_mbox_msg msg, void *cookie);
  28. void *cookie;
  29. };
  30. struct apple_mbox *apple_mbox_get(struct device *dev, int index);
  31. struct apple_mbox *apple_mbox_get_byname(struct device *dev, const char *name);
  32. int apple_mbox_start(struct apple_mbox *mbox);
  33. void apple_mbox_stop(struct apple_mbox *mbox);
  34. int apple_mbox_poll(struct apple_mbox *mbox);
  35. int apple_mbox_send(struct apple_mbox *mbox, struct apple_mbox_msg msg,
  36. bool atomic);
  37. #endif