omap-mbox.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * omap-mbox.h: OMAP mailbox internal definitions
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef OMAP_MBOX_H
  9. #define OMAP_MBOX_H
  10. #include <linux/device.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/kfifo.h>
  13. #include <linux/spinlock.h>
  14. #include <linux/workqueue.h>
  15. #include <linux/omap-mailbox.h>
  16. typedef int __bitwise omap_mbox_type_t;
  17. #define OMAP_MBOX_TYPE1 ((__force omap_mbox_type_t) 1)
  18. #define OMAP_MBOX_TYPE2 ((__force omap_mbox_type_t) 2)
  19. struct omap_mbox_ops {
  20. omap_mbox_type_t type;
  21. int (*startup)(struct omap_mbox *mbox);
  22. void (*shutdown)(struct omap_mbox *mbox);
  23. /* fifo */
  24. mbox_msg_t (*fifo_read)(struct omap_mbox *mbox);
  25. void (*fifo_write)(struct omap_mbox *mbox, mbox_msg_t msg);
  26. int (*fifo_empty)(struct omap_mbox *mbox);
  27. int (*fifo_full)(struct omap_mbox *mbox);
  28. /* irq */
  29. void (*enable_irq)(struct omap_mbox *mbox,
  30. omap_mbox_irq_t irq);
  31. void (*disable_irq)(struct omap_mbox *mbox,
  32. omap_mbox_irq_t irq);
  33. void (*ack_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
  34. int (*is_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
  35. /* ctx */
  36. void (*save_ctx)(struct omap_mbox *mbox);
  37. void (*restore_ctx)(struct omap_mbox *mbox);
  38. };
  39. struct omap_mbox_queue {
  40. spinlock_t lock;
  41. struct kfifo fifo;
  42. struct work_struct work;
  43. struct tasklet_struct tasklet;
  44. struct omap_mbox *mbox;
  45. bool full;
  46. };
  47. struct omap_mbox {
  48. const char *name;
  49. unsigned int irq;
  50. struct omap_mbox_queue *txq, *rxq;
  51. struct omap_mbox_ops *ops;
  52. struct device *dev;
  53. void *priv;
  54. int use_count;
  55. struct blocking_notifier_head notifier;
  56. };
  57. int omap_mbox_register(struct device *parent, struct omap_mbox **);
  58. int omap_mbox_unregister(void);
  59. #endif /* OMAP_MBOX_H */