mailbox.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* mailbox.h */
  2. #ifndef MAILBOX_H
  3. #define MAILBOX_H
  4. #include <linux/wait.h>
  5. #include <linux/workqueue.h>
  6. #include <linux/blkdev.h>
  7. typedef u32 mbox_msg_t;
  8. typedef void (mbox_receiver_t)(mbox_msg_t msg);
  9. struct omap_mbox;
  10. typedef int __bitwise omap_mbox_irq_t;
  11. #define IRQ_TX ((__force omap_mbox_irq_t) 1)
  12. #define IRQ_RX ((__force omap_mbox_irq_t) 2)
  13. typedef int __bitwise omap_mbox_type_t;
  14. #define OMAP_MBOX_TYPE1 ((__force omap_mbox_type_t) 1)
  15. #define OMAP_MBOX_TYPE2 ((__force omap_mbox_type_t) 2)
  16. struct omap_mbox_ops {
  17. omap_mbox_type_t type;
  18. int (*startup)(struct omap_mbox *mbox);
  19. void (*shutdown)(struct omap_mbox *mbox);
  20. /* fifo */
  21. mbox_msg_t (*fifo_read)(struct omap_mbox *mbox);
  22. void (*fifo_write)(struct omap_mbox *mbox, mbox_msg_t msg);
  23. int (*fifo_empty)(struct omap_mbox *mbox);
  24. int (*fifo_full)(struct omap_mbox *mbox);
  25. /* irq */
  26. void (*enable_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
  27. void (*disable_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
  28. void (*ack_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
  29. int (*is_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
  30. };
  31. struct omap_mbox_queue {
  32. spinlock_t lock;
  33. struct request_queue *queue;
  34. struct work_struct work;
  35. int (*callback)(void *);
  36. struct omap_mbox *mbox;
  37. };
  38. struct omap_mbox {
  39. char *name;
  40. unsigned int irq;
  41. struct omap_mbox_queue *txq, *rxq;
  42. struct omap_mbox_ops *ops;
  43. mbox_msg_t seq_snd, seq_rcv;
  44. struct device dev;
  45. struct omap_mbox *next;
  46. void *priv;
  47. void (*err_notify)(void);
  48. };
  49. int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg, void *);
  50. void omap_mbox_init_seq(struct omap_mbox *);
  51. struct omap_mbox *omap_mbox_get(const char *);
  52. void omap_mbox_put(struct omap_mbox *);
  53. int omap_mbox_register(struct omap_mbox *);
  54. int omap_mbox_unregister(struct omap_mbox *);
  55. #endif /* MAILBOX_H */