linux/drivers/soc/apple/mailbox.h
Hector Martin 6e1457fcad soc: apple: mailbox: Add ASC/M3 mailbox driver
This new driver is based on the existing apple-mailbox driver, but
replaces the usage of the mailbox subsystem with directly exported
symbols.

As part of this refactor, this adds support for using the hardware FIFOs
(not supported in mailbox) and implicitly fixes a bunch of bugs caused
by bad interactions with the mailbox subsystem. It also adds runtime-PM
support.

The new config symbol is APPLE_MBOX, while the module name remains
identical ("apple-mailbox"). The configs are mutually exclusive in
Kconfig, to avoid conflicts.

Acked-by: Eric Curtin <ecurtin@redhat.com>
Acked-by: Neal Gompa <neal@gompa.dev>
Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-23 19:10:15 +09:00

49 lines
1.1 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
/*
* Apple mailbox message format
*
* Copyright The Asahi Linux Contributors
*/
#ifndef _APPLE_MAILBOX_H_
#define _APPLE_MAILBOX_H_
#include <linux/device.h>
#include <linux/types.h>
/* encodes a single 96bit message sent over the single channel */
struct apple_mbox_msg {
u64 msg0;
u32 msg1;
};
struct apple_mbox {
struct device *dev;
void __iomem *regs;
const struct apple_mbox_hw *hw;
bool active;
int irq_recv_not_empty;
int irq_send_empty;
spinlock_t rx_lock;
spinlock_t tx_lock;
struct completion tx_empty;
/** Receive callback for incoming messages */
void (*rx)(struct apple_mbox *mbox, struct apple_mbox_msg msg, void *cookie);
void *cookie;
};
struct apple_mbox *apple_mbox_get(struct device *dev, int index);
struct apple_mbox *apple_mbox_get_byname(struct device *dev, const char *name);
int apple_mbox_start(struct apple_mbox *mbox);
void apple_mbox_stop(struct apple_mbox *mbox);
int apple_mbox_poll(struct apple_mbox *mbox);
int apple_mbox_send(struct apple_mbox *mbox, struct apple_mbox_msg msg,
bool atomic);
#endif