linux/drivers/mailbox/arm_mhuv3.c

// SPDX-License-Identifier: GPL-2.0
/*
 * ARM Message Handling Unit Version 3 (MHUv3) driver.
 *
 * Copyright (C) 2024 ARM Ltd.
 *
 * Based on ARM MHUv2 driver.
 */

#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/bits.h>
#include <linux/cleanup.h>
#include <linux/device.h>
#include <linux/interrupt.h>
#include <linux/mailbox_controller.h>
#include <linux/module.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/spinlock.h>
#include <linux/sizes.h>
#include <linux/slab.h>
#include <linux/types.h>

/* ====== MHUv3 Registers ====== */

/* Maximum number of Doorbell channel windows */
#define MHUV3_DBCW_MAX
/* Number of DBCH combined interrupt status registers */
#define MHUV3_DBCH_CMB_INT_ST_REG_CNT

/* Number of FFCH combined interrupt status registers */
#define MHUV3_FFCH_CMB_INT_ST_REG_CNT

#define MHUV3_FLAG_BITS

/* Not a typo ... */
#define MHUV3_MAJOR_VERSION

enum {};

/* Padding bitfields/fields represents hole in the regs MMIO */

/* CTRL_Page */
struct blk_id {} __packed;

struct feat_spt0 {} __packed;

struct feat_spt1 {} __packed;

struct dbch_cfg0 {} __packed;

struct ffch_cfg0 {} __packed;

struct fch_cfg0 {} __packed;

struct ctrl {} __packed;

struct fch_ctrl {} __packed;

struct iidr {} __packed;

struct aidr {} __packed;

struct ctrl_page {} __packed;

/* DBCW_Page */

struct xbcw_ctrl {} __packed;

struct pdbcw_int {} __packed;

struct pdbcw_page {} __packed;

struct mdbcw_page {} __packed;

struct dummy_page {} __packed;

struct mhu3_pbx_frame_reg {} __packed;

struct mhu3_mbx_frame_reg {} __packed;

/* Macro for reading a bitmask within a physically mapped packed struct */
#define readl_relaxed_bitmask(_regptr, _bitmask)

/* Macro for writing a bitmask within a physically mapped packed struct */
#define writel_relaxed_bitmask(_value, _regptr, _bitmask)

/* ====== MHUv3 data structures ====== */

enum mhuv3_frame {};

static char *mhuv3_str[] =;

enum mhuv3_extension_type {};

static char *mhuv3_ext_str[] =;

struct mhuv3;

/**
 * struct mhuv3_protocol_ops - MHUv3 operations
 *
 * @rx_startup: Receiver startup callback.
 * @rx_shutdown: Receiver shutdown callback.
 * @read_data: Read available Sender in-band LE data (if any).
 * @rx_complete: Acknowledge data reception to the Sender. Any out-of-band data
 *		 has to have been already retrieved before calling this.
 * @tx_startup: Sender startup callback.
 * @tx_shutdown: Sender shutdown callback.
 * @last_tx_done: Report back to the Sender if the last transfer has completed.
 * @send_data: Send data to the receiver.
 *
 * Each supported transport protocol provides its own implementation of
 * these operations.
 */
struct mhuv3_protocol_ops {};

/**
 * struct mhuv3_mbox_chan_priv - MHUv3 channel private information
 *
 * @ch_idx: Channel window index associated to this mailbox channel.
 * @doorbell: Doorbell bit number within the @ch_idx window.
 *	      Only relevant to Doorbell transport.
 * @ops: Transport protocol specific operations for this channel.
 *
 * Transport specific data attached to mmailbox channel priv data.
 */
struct mhuv3_mbox_chan_priv {};

/**
 * struct mhuv3_extension - MHUv3 extension descriptor
 *
 * @type: Type of extension
 * @num_chans: Max number of channels found for this extension.
 * @base_ch_idx: First channel number assigned to this extension, picked from
 *		 the set of all mailbox channels descriptors created.
 * @mbox_of_xlate: Extension specific helper to parse DT and lookup associated
 *		   channel from the related 'mboxes' property.
 * @combined_irq_setup: Extension specific helper to setup the combined irq.
 * @channels_init: Extension specific helper to initialize channels.
 * @chan_from_comb_irq_get: Extension specific helper to lookup which channel
 *			    triggered the combined irq.
 * @pending_db: Array of per-channel pending doorbells.
 * @pending_lock: Protect access to pending_db.
 */
struct mhuv3_extension {};

/**
 * struct mhuv3 - MHUv3 mailbox controller data
 *
 * @frame:	Frame type: MBX_FRAME or PBX_FRAME.
 * @auto_op_full: Flag to indicate if the MHU supports AutoOp full mode.
 * @major: MHUv3 controller architectural major version.
 * @minor: MHUv3 controller architectural minor version.
 * @implem: MHUv3 controller IIDR implementer.
 * @rev: MHUv3 controller IIDR revision.
 * @var: MHUv3 controller IIDR variant.
 * @prod_id: MHUv3 controller IIDR product_id.
 * @num_chans: The total number of channnels discovered across all extensions.
 * @cmb_irq: Combined IRQ number if any found defined.
 * @ctrl: A reference to the MHUv3 control page for this block.
 * @pbx: Base address of the PBX register mapping region.
 * @mbx: Base address of the MBX register mapping region.
 * @ext: Array holding descriptors for any found implemented extension.
 * @mbox: Mailbox controller belonging to the MHU frame.
 */
struct mhuv3 {};

#define mhu_from_mbox(_mbox)

mhuv3_extension_initializer;

/* =================== Doorbell transport protocol operations =============== */

static void mhuv3_doorbell_tx_startup(struct mhuv3 *mhu, struct mbox_chan *chan)
{}

static void mhuv3_doorbell_tx_shutdown(struct mhuv3 *mhu, struct mbox_chan *chan)
{}

static int mhuv3_doorbell_rx_startup(struct mhuv3 *mhu, struct mbox_chan *chan)
{}

static void mhuv3_doorbell_rx_shutdown(struct mhuv3 *mhu,
				       struct mbox_chan *chan)
{}

static void mhuv3_doorbell_rx_complete(struct mhuv3 *mhu, struct mbox_chan *chan)
{}

static int mhuv3_doorbell_last_tx_done(struct mhuv3 *mhu,
				       struct mbox_chan *chan)
{}

static int mhuv3_doorbell_send_data(struct mhuv3 *mhu, struct mbox_chan *chan,
				    void *arg)
{}

static const struct mhuv3_protocol_ops mhuv3_doorbell_ops =;

/* Sender and receiver mailbox ops */
static bool mhuv3_sender_last_tx_done(struct mbox_chan *chan)
{}

static int mhuv3_sender_send_data(struct mbox_chan *chan, void *data)
{}

static int mhuv3_sender_startup(struct mbox_chan *chan)
{}

static void mhuv3_sender_shutdown(struct mbox_chan *chan)
{}

static const struct mbox_chan_ops mhuv3_sender_ops =;

static int mhuv3_receiver_startup(struct mbox_chan *chan)
{}

static void mhuv3_receiver_shutdown(struct mbox_chan *chan)
{}

static int mhuv3_receiver_send_data(struct mbox_chan *chan, void *data)
{}

static bool mhuv3_receiver_last_tx_done(struct mbox_chan *chan)
{}

static const struct mbox_chan_ops mhuv3_receiver_ops =;

static struct mbox_chan *mhuv3_dbe_mbox_of_xlate(struct mhuv3 *mhu,
						 unsigned int channel,
						 unsigned int doorbell)
{}

static void mhuv3_dbe_combined_irq_setup(struct mhuv3 *mhu)
{}

static int mhuv3_dbe_channels_init(struct mhuv3 *mhu)
{}

static bool mhuv3_dbe_doorbell_lookup(struct mhuv3 *mhu, unsigned int channel,
				      unsigned int *db)
{}

static struct mbox_chan *mhuv3_dbe_chan_from_comb_irq_get(struct mhuv3 *mhu)
{}

static int mhuv3_dbe_init(struct mhuv3 *mhu)
{}

static int mhuv3_fce_init(struct mhuv3 *mhu)
{}

static int mhuv3_fe_init(struct mhuv3 *mhu)
{}

static mhuv3_extension_initializer mhuv3_extension_init[NUM_EXT] =;

static int mhuv3_initialize_channels(struct device *dev, struct mhuv3 *mhu)
{}

static struct mbox_chan *mhuv3_mbox_of_xlate(struct mbox_controller *mbox,
					     const struct of_phandle_args *pa)
{}

static void mhu_frame_cleanup_actions(void *data)
{}

static int mhuv3_frame_init(struct mhuv3 *mhu, void __iomem *regs)
{}

static irqreturn_t mhuv3_pbx_comb_interrupt(int irq, void *arg)
{}

static irqreturn_t mhuv3_mbx_comb_interrupt(int irq, void *arg)
{}

static int mhuv3_setup_pbx(struct mhuv3 *mhu)
{}

static int mhuv3_setup_mbx(struct mhuv3 *mhu)
{}

static int mhuv3_irqs_init(struct mhuv3 *mhu, struct platform_device *pdev)
{}

static int mhuv3_probe(struct platform_device *pdev)
{}

static const struct of_device_id mhuv3_of_match[] =;
MODULE_DEVICE_TABLE(of, mhuv3_of_match);

static struct platform_driver mhuv3_driver =;
module_platform_driver();

MODULE_LICENSE();
MODULE_DESCRIPTION();
MODULE_AUTHOR();