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 8 #ifndef _APPLE_MAILBOX_H_ 9 #define _APPLE_MAILBOX_H_ 10 11 #include <linux/device.h> 12 #include <linux/types.h> 13 14 /* encodes a single 96bit message sent over the single channel */ 15 struct apple_mbox_msg { 16 u64 msg0; 17 u32 msg1; 18 }; 19 20 struct apple_mbox { 21 struct device *dev; 22 void __iomem *regs; 23 const struct apple_mbox_hw *hw; 24 bool active; 25 26 int irq_recv_not_empty; 27 int irq_send_empty; 28 29 spinlock_t rx_lock; 30 spinlock_t tx_lock; 31 32 struct completion tx_empty; 33 34 /** Receive callback for incoming messages */ 35 void (*rx)(struct apple_mbox *mbox, struct apple_mbox_msg msg, void *cookie); 36 void *cookie; 37 }; 38 39 struct apple_mbox *apple_mbox_get(struct device *dev, int index); 40 struct apple_mbox *apple_mbox_get_byname(struct device *dev, const char *name); 41 42 int apple_mbox_start(struct apple_mbox *mbox); 43 void apple_mbox_stop(struct apple_mbox *mbox); 44 int apple_mbox_poll(struct apple_mbox *mbox); 45 int apple_mbox_send(struct apple_mbox *mbox, struct apple_mbox_msg msg, 46 bool atomic); 47 48 #endif 49