* [PATCH RFC v1 0/3] Introduce support for T-head TH1520 Mailbox
[not found] <CGME20240918134923eucas1p1a9233b712f86b97ba8d4b9f4d7a7adbb@eucas1p1.samsung.com>
@ 2024-09-18 13:48 ` Michal Wilczynski
[not found] ` <CGME20240918134925eucas1p268a994fb26a9a139ff7314cd19124653@eucas1p2.samsung.com>
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Michal Wilczynski @ 2024-09-18 13:48 UTC (permalink / raw)
To: drew, guoren, wefu, jassisinghbrar, robh, krzk+dt, conor+dt,
paul.walmsley, palmer, aou, m.szyprowski
Cc: linux-riscv, linux-kernel, devicetree, Michal Wilczynski
The T-head TH1520 SoC supports a hardware mailbox that enables two cores
within the SoC to communicate and coordinate [1]. One example of such
coordination would be cooperation with the T-Head E902 core, which is
responsible for power, clock, and resource management. For example, in
the specific case of the BXM-4-64 GPU, it needs to be powered on by the
E902 core, and the kernel running on the E910 needs to 'ask' the
firmware running on the E902 core to enable power to the GPU island.
Given recent advancements in work on the upstream GPU driver [2], there
is an emerging need to get this code in the mainline kernel.
Link: https://openbeagle.org/beaglev-ahead/beaglev-ahead/-/blob/main/docs/TH1520%20System%20User%20Manual.pdf [1]
Link: https://gitlab.freedesktop.org/imagination/linux-firmware/-/issues/1 [2]
Michal Wilczynski (3):
mailbox: Introduce support for T-head TH1520 Mailbox driver
dt-bindings: mailbox: Add thead,th1520-mailbox bindings
riscv: dts: thead: Add mailbox node
.../bindings/mailbox/thead,th1520-mbox.yaml | 83 +++
MAINTAINERS | 2 +
arch/riscv/boot/dts/thead/th1520.dtsi | 15 +
drivers/mailbox/Kconfig | 10 +
drivers/mailbox/Makefile | 2 +
drivers/mailbox/mailbox-th1520.c | 598 ++++++++++++++++++
6 files changed, 710 insertions(+)
create mode 100644 Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
create mode 100644 drivers/mailbox/mailbox-th1520.c
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH RFC v1 1/3] mailbox: Introduce support for T-head TH1520 Mailbox driver
[not found] ` <CGME20240918134925eucas1p268a994fb26a9a139ff7314cd19124653@eucas1p2.samsung.com>
@ 2024-09-18 13:48 ` Michal Wilczynski
0 siblings, 0 replies; 7+ messages in thread
From: Michal Wilczynski @ 2024-09-18 13:48 UTC (permalink / raw)
To: drew, guoren, wefu, jassisinghbrar, robh, krzk+dt, conor+dt,
paul.walmsley, palmer, aou, m.szyprowski
Cc: linux-riscv, linux-kernel, devicetree, Michal Wilczynski
This driver was tested using the drm/imagination GPU driver. It was able
to successfully power on the GPU, by passing a command through mailbox
from E910 core to E902 that's responsible for powering up the GPU. The
GPU driver was able to read the BVC version from control registers,
which confirms it was successfully powered on.
[ 33.957467] powervr ffef400000.gpu: [drm] loaded firmware
powervr/rogue_36.52.104.182_v1.fw
[ 33.966008] powervr ffef400000.gpu: [drm] FW version v1.0 (build
6621747 OS)
[ 38.978542] powervr ffef400000.gpu: [drm] *ERROR* Firmware failed to
boot
Though the driver still fails to boot the firmware, the mailbox driver
works when used with the not-yet-upstreamed firmware AON driver. There
is ongoing work to get the BXM-4-64 supported with the drm/imagination
driver [1], though it's not completed yet.
This work is based on the driver from the vendor kernel [2].
Link: https://gitlab.freedesktop.org/imagination/linux-firmware/-/issues/2 [1]
Link: https://github.com/revyos/thead-kernel.git [2]
Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
---
MAINTAINERS | 1 +
drivers/mailbox/Kconfig | 10 +
drivers/mailbox/Makefile | 2 +
drivers/mailbox/mailbox-th1520.c | 598 +++++++++++++++++++++++++++++++
4 files changed, 611 insertions(+)
create mode 100644 drivers/mailbox/mailbox-th1520.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 10430778c998..7331b30deef8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -19721,6 +19721,7 @@ T: git https://github.com/pdp7/linux.git
F: Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml
F: arch/riscv/boot/dts/thead/
F: drivers/clk/thead/clk-th1520-ap.c
+F: drivers/mailbox/mailbox-th1520.c
F: include/dt-bindings/clock/thead,th1520-clk-ap.h
RNBD BLOCK DRIVERS
diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index 4eed97295927..1c87a6b6b607 100644
--- a/drivers/mailbox/Kconfig
+++ b/drivers/mailbox/Kconfig
@@ -294,4 +294,14 @@ config QCOM_IPCC
acts as an interrupt controller for receiving interrupts from clients.
Say Y here if you want to build this driver.
+config THEAD_TH1520_MBOX
+ tristate "T-head TH1520 Mailbox"
+ depends on ARCH_THEAD || COMPILE_TEST
+ help
+ Mailbox driver implementation for the Thead TH-1520 platform. Enables
+ two cores within the SoC to communicate and coordinate by passing
+ messages. Could be used to communicate between E910 core, on which the
+ kernel is running, and E902 core used for power management among other
+ things.
+
endif
diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile
index 3c3c27d54c13..5f4f5b0ce2cc 100644
--- a/drivers/mailbox/Makefile
+++ b/drivers/mailbox/Makefile
@@ -64,3 +64,5 @@ obj-$(CONFIG_SPRD_MBOX) += sprd-mailbox.o
obj-$(CONFIG_QCOM_CPUCP_MBOX) += qcom-cpucp-mbox.o
obj-$(CONFIG_QCOM_IPCC) += qcom-ipcc.o
+
+obj-$(CONFIG_THEAD_TH1520_MBOX) += mailbox-th1520.o
diff --git a/drivers/mailbox/mailbox-th1520.c b/drivers/mailbox/mailbox-th1520.c
new file mode 100644
index 000000000000..589e2a964d8f
--- /dev/null
+++ b/drivers/mailbox/mailbox-th1520.c
@@ -0,0 +1,598 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 Alibaba Group Holding Limited.
+ */
+
+#include <linux/clk.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/mailbox_controller.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+/* Status Register */
+#define TH_1520_MBOX_STA 0x0
+#define TH_1520_MBOX_CLR 0x4
+#define TH_1520_MBOX_MASK 0xc
+
+/* Transmit/receive data register:
+ * INFO0 ~ INFO6
+ */
+#define TH_1520_MBOX_INFO_NUM 8
+#define TH_1520_MBOX_DATA_INFO_NUM 7
+#define TH_1520_MBOX_INFO0 0x14
+/* Transmit ack register: INFO7 */
+#define TH_1520_MBOX_INFO7 0x30
+
+/* Generate remote icu IRQ Register */
+#define TH_1520_MBOX_GEN 0x10
+#define TH_1520_MBOX_GEN_RX_DATA BIT(6)
+#define TH_1520_MBOX_GEN_TX_ACK BIT(7)
+
+#define TH_1520_MBOX_CHAN_RES_SIZE 0x1000
+#define TH_1520_MBOX_CHANS 4
+#define TH_1520_MBOX_CHAN_NAME_SIZE 20
+
+#define TH_1520_MBOX_ACK_MAGIC 0xdeadbeaf
+
+#ifdef CONFIG_PM_SLEEP
+/* store MBOX context across system-wide suspend/resume transitions */
+struct th1520_mbox_context {
+ u32 intr_mask[TH_1520_MBOX_CHANS - 1];
+};
+#endif
+
+enum th1520_mbox_chan_type {
+ TH_1520_MBOX_TYPE_TXRX, /* Tx & Rx chan */
+ TH_1520_MBOX_TYPE_DB, /* Tx & Rx doorbell */
+};
+
+enum th1520_mbox_icu_cpu_id {
+ TH_1520_MBOX_ICU_CPU0, /* 910T */
+ TH_1520_MBOX_ICU_CPU1, /* 902 */
+ TH_1520_MBOX_ICU_CPU2, /* 906 */
+ TH_1520_MBOX_ICU_CPU3, /* 910R */
+};
+
+struct th1520_mbox_con_priv {
+ enum th1520_mbox_icu_cpu_id idx;
+ enum th1520_mbox_chan_type type;
+ void __iomem *comm_local_base;
+ void __iomem *comm_remote_base;
+ char irq_desc[TH_1520_MBOX_CHAN_NAME_SIZE];
+ struct mbox_chan *chan;
+ struct tasklet_struct txdb_tasklet;
+};
+
+struct th1520_mbox_priv {
+ struct device *dev;
+ void __iomem *local_icu[TH_1520_MBOX_CHANS];
+ void __iomem *remote_icu[TH_1520_MBOX_CHANS - 1];
+ void __iomem *cur_cpu_ch_base;
+ enum th1520_mbox_icu_cpu_id cur_icu_cpu_id;
+ spinlock_t mbox_lock; /* control register lock */
+
+ struct mbox_controller mbox;
+ struct mbox_chan mbox_chans[TH_1520_MBOX_CHANS];
+
+ struct th1520_mbox_con_priv con_priv[TH_1520_MBOX_CHANS];
+ struct clk *clk;
+ int irq;
+#ifdef CONFIG_PM_SLEEP
+ struct th1520_mbox_context *ctx;
+#endif
+};
+
+static struct th1520_mbox_priv *to_th1520_mbox_priv(struct mbox_controller *mbox)
+{
+ return container_of(mbox, struct th1520_mbox_priv, mbox);
+}
+
+static void th1520_mbox_write(struct th1520_mbox_priv *priv, u32 val, u32 offs)
+{
+ iowrite32(val, priv->cur_cpu_ch_base + offs);
+}
+
+static u32 th1520_mbox_read(struct th1520_mbox_priv *priv, u32 offs)
+{
+ return ioread32(priv->cur_cpu_ch_base + offs);
+}
+
+static u32 th1520_mbox_rmw(struct th1520_mbox_priv *priv, u32 off, u32 set,
+ u32 clr)
+{
+ unsigned long flags;
+ u32 val;
+
+ spin_lock_irqsave(&priv->mbox_lock, flags);
+ val = th1520_mbox_read(priv, off);
+ val &= ~clr;
+ val |= set;
+ th1520_mbox_write(priv, val, off);
+ spin_unlock_irqrestore(&priv->mbox_lock, flags);
+
+ return val;
+}
+
+static void th1520_mbox_chan_write(struct th1520_mbox_con_priv *cp, u32 val,
+ u32 offs, bool is_remote)
+{
+ if (is_remote)
+ iowrite32(val, cp->comm_remote_base + offs);
+ else
+ iowrite32(val, cp->comm_local_base + offs);
+}
+
+static u32 th1520_mbox_chan_read(struct th1520_mbox_con_priv *cp, u32 offs,
+ bool is_remote)
+{
+ if (is_remote)
+ return ioread32(cp->comm_remote_base + offs);
+ else
+ return ioread32(cp->comm_local_base + offs);
+}
+
+static void th1520_mbox_chan_rmw(struct th1520_mbox_con_priv *cp, u32 off,
+ u32 set, u32 clr, bool is_remote)
+{
+ struct th1520_mbox_priv *priv = to_th1520_mbox_priv(cp->chan->mbox);
+ unsigned long flags;
+ u32 val;
+
+ spin_lock_irqsave(&priv->mbox_lock, flags);
+ val = th1520_mbox_chan_read(cp, off, is_remote);
+ val &= ~clr;
+ val |= set;
+ th1520_mbox_chan_write(cp, val, off, is_remote);
+ spin_unlock_irqrestore(&priv->mbox_lock, flags);
+}
+
+static void th1520_mbox_chan_rd_data(struct th1520_mbox_con_priv *cp, void *data,
+ bool is_remote)
+{
+ u32 off = TH_1520_MBOX_INFO0;
+ u32 *arg = data;
+ u32 i;
+
+ /* read info0 ~ info6, totally 28 bytes
+ * requires data memory size is 28 bytes
+ */
+ for (i = 0; i < TH_1520_MBOX_DATA_INFO_NUM; i++) {
+ *arg = th1520_mbox_chan_read(cp, off, is_remote);
+ off += 4;
+ arg++;
+ }
+}
+
+static void th1520_mbox_chan_wr_data(struct th1520_mbox_con_priv *cp, void *data,
+ bool is_remote)
+{
+ u32 off = TH_1520_MBOX_INFO0;
+ u32 *arg = data;
+ u32 i;
+
+ /* write info0 ~ info6, totally 28 bytes
+ * requires data memory is 28 bytes valid data
+ */
+ for (i = 0; i < TH_1520_MBOX_DATA_INFO_NUM; i++) {
+ th1520_mbox_chan_write(cp, *arg, off, is_remote);
+ off += 4;
+ arg++;
+ }
+}
+
+static void th1520_mbox_chan_wr_ack(struct th1520_mbox_con_priv *cp, void *data,
+ bool is_remote)
+{
+ u32 off = TH_1520_MBOX_INFO7;
+ u32 *arg = data;
+
+ th1520_mbox_chan_write(cp, *arg, off, is_remote);
+}
+
+static int th1520_mbox_chan_id_to_mapbit(struct th1520_mbox_con_priv *cp)
+{
+ struct th1520_mbox_priv *priv = to_th1520_mbox_priv(cp->chan->mbox);
+ int mapbit = 0;
+ int i;
+
+ for (i = 0; i < TH_1520_MBOX_CHANS; i++) {
+ if (i == cp->idx)
+ return mapbit;
+
+ if (i != priv->cur_icu_cpu_id)
+ mapbit++;
+ }
+
+ if (i == TH_1520_MBOX_CHANS)
+ dev_err(cp->chan->mbox->dev, "convert to mapbit failed\n");
+
+ return 0;
+}
+
+static void th1520_mbox_txdb_tasklet(unsigned long data)
+{
+ struct th1520_mbox_con_priv *cp = (struct th1520_mbox_con_priv *)data;
+
+ mbox_chan_txdone(cp->chan, 0);
+}
+
+static irqreturn_t th1520_mbox_isr(int irq, void *p)
+{
+ struct mbox_chan *chan = p;
+ struct th1520_mbox_priv *priv = to_th1520_mbox_priv(chan->mbox);
+ struct th1520_mbox_con_priv *cp = chan->con_priv;
+ int mapbit = th1520_mbox_chan_id_to_mapbit(cp);
+ u32 sta, dat[TH_1520_MBOX_DATA_INFO_NUM];
+ u32 ack_magic = TH_1520_MBOX_ACK_MAGIC;
+ u32 info0_data, info7_data;
+
+ sta = th1520_mbox_read(priv, TH_1520_MBOX_STA);
+ if (!(sta & BIT(mapbit)))
+ return IRQ_NONE;
+
+ /* clear chan irq bit in STA register */
+ th1520_mbox_rmw(priv, TH_1520_MBOX_CLR, BIT(mapbit), 0);
+
+ /* rx doorbell */
+ if (cp->type == TH_1520_MBOX_TYPE_DB) {
+ mbox_chan_received_data(cp->chan, NULL);
+ return IRQ_HANDLED;
+ }
+
+ /* info0 is the protocol word, should not be zero! */
+ info0_data = th1520_mbox_chan_read(cp, TH_1520_MBOX_INFO0, false);
+ if (info0_data) {
+ /* read info0~info6 data */
+ th1520_mbox_chan_rd_data(cp, dat, false);
+
+ /* clear local info0 */
+ th1520_mbox_chan_write(cp, 0x0, TH_1520_MBOX_INFO0, false);
+
+ /* notify remote cpu */
+ th1520_mbox_chan_wr_ack(cp, &ack_magic, true);
+ /* CPU1 902/906 use polling mode to monitor info7 */
+ if (cp->idx != TH_1520_MBOX_ICU_CPU1 &&
+ cp->idx != TH_1520_MBOX_ICU_CPU2)
+ th1520_mbox_chan_rmw(cp, TH_1520_MBOX_GEN,
+ TH_1520_MBOX_GEN_TX_ACK, 0, true);
+
+ /* transfer the data to client */
+ mbox_chan_received_data(chan, (void *)dat);
+ }
+
+ /* info7 magic value mean the real ack signal, not generate bit7 */
+ info7_data = th1520_mbox_chan_read(cp, TH_1520_MBOX_INFO7, false);
+ if (info7_data == TH_1520_MBOX_ACK_MAGIC) {
+ /* clear local info7 */
+ th1520_mbox_chan_write(cp, 0x0, TH_1520_MBOX_INFO7, false);
+
+ /* notify framework the last TX has completed */
+ mbox_chan_txdone(chan, 0);
+ }
+
+ if (!info0_data && !info7_data)
+ return IRQ_NONE;
+
+ return IRQ_HANDLED;
+}
+
+static int th1520_mbox_send_data(struct mbox_chan *chan, void *data)
+{
+ struct th1520_mbox_con_priv *cp = chan->con_priv;
+
+ if (cp->type == TH_1520_MBOX_TYPE_DB)
+ tasklet_schedule(&cp->txdb_tasklet);
+ else
+ th1520_mbox_chan_wr_data(cp, data, true);
+
+ th1520_mbox_chan_rmw(cp, TH_1520_MBOX_GEN, TH_1520_MBOX_GEN_RX_DATA, 0,
+ true);
+ return 0;
+}
+
+static int th1520_mbox_startup(struct mbox_chan *chan)
+{
+ struct th1520_mbox_priv *priv = to_th1520_mbox_priv(chan->mbox);
+ struct th1520_mbox_con_priv *cp = chan->con_priv;
+ u32 data[8] = {};
+ int mask_bit;
+ int ret;
+
+ /* clear local and remote generate and info0~info7 */
+ th1520_mbox_chan_rmw(cp, TH_1520_MBOX_GEN, 0x0, 0xff, true);
+ th1520_mbox_chan_rmw(cp, TH_1520_MBOX_GEN, 0x0, 0xff, false);
+ th1520_mbox_chan_wr_ack(cp, &data[7], true);
+ th1520_mbox_chan_wr_ack(cp, &data[7], false);
+ th1520_mbox_chan_wr_data(cp, &data[0], true);
+ th1520_mbox_chan_wr_data(cp, &data[0], false);
+
+ /* enable the chan mask */
+ mask_bit = th1520_mbox_chan_id_to_mapbit(cp);
+ th1520_mbox_rmw(priv, TH_1520_MBOX_MASK, BIT(mask_bit), 0);
+
+ if (cp->type == TH_1520_MBOX_TYPE_DB)
+ /* tx doorbell doesn't have ACK, rx doorbell requires isr */
+ tasklet_init(&cp->txdb_tasklet, th1520_mbox_txdb_tasklet,
+ (unsigned long)cp);
+
+ ret = request_irq(priv->irq, th1520_mbox_isr,
+ IRQF_SHARED | IRQF_NO_SUSPEND, cp->irq_desc, chan);
+ if (ret) {
+ dev_err(priv->dev, "Unable to acquire IRQ %d\n", priv->irq);
+ return ret;
+ }
+
+ return 0;
+}
+
+static void th1520_mbox_shutdown(struct mbox_chan *chan)
+{
+ struct th1520_mbox_priv *priv = to_th1520_mbox_priv(chan->mbox);
+ struct th1520_mbox_con_priv *cp = chan->con_priv;
+ int mask_bit;
+
+ /* clear the chan mask */
+ mask_bit = th1520_mbox_chan_id_to_mapbit(cp);
+ th1520_mbox_rmw(priv, TH_1520_MBOX_MASK, 0, BIT(mask_bit));
+
+ free_irq(priv->irq, chan);
+}
+
+static const struct mbox_chan_ops th1520_mbox_ops = {
+ .send_data = th1520_mbox_send_data,
+ .startup = th1520_mbox_startup,
+ .shutdown = th1520_mbox_shutdown,
+};
+
+static int th1520_mbox_init_generic(struct th1520_mbox_priv *priv)
+{
+#ifdef CONFIG_PM_SLEEP
+ priv->ctx = devm_kzalloc(priv->dev, sizeof(*priv->ctx), GFP_KERNEL);
+ if (!priv->ctx)
+ return -ENOMEM;
+#endif
+ /* Set default configuration */
+ th1520_mbox_write(priv, 0xff, TH_1520_MBOX_CLR);
+ th1520_mbox_write(priv, 0x0, TH_1520_MBOX_MASK);
+ return 0;
+}
+
+static struct mbox_chan *th1520_mbox_xlate(struct mbox_controller *mbox,
+ const struct of_phandle_args *sp)
+{
+ struct th1520_mbox_priv *priv = to_th1520_mbox_priv(mbox);
+ struct th1520_mbox_con_priv *cp;
+ u32 chan, type;
+
+ if (sp->args_count != 2) {
+ dev_err(mbox->dev, "Invalid argument count %d\n",
+ sp->args_count);
+ return ERR_PTR(-EINVAL);
+ }
+
+ chan = sp->args[0]; /* comm remote channel */
+ type = sp->args[1]; /* comm channel type */
+
+ if (chan >= mbox->num_chans) {
+ dev_err(mbox->dev, "Not supported channel number: %d\n", chan);
+ return ERR_PTR(-EINVAL);
+ }
+
+ if (chan == priv->cur_icu_cpu_id) {
+ dev_err(mbox->dev, "Cannot communicate with yourself\n");
+ return ERR_PTR(-EINVAL);
+ }
+
+ if (type > TH_1520_MBOX_TYPE_DB) {
+ dev_err(mbox->dev, "Not supported the type for channel[%d]\n",
+ chan);
+ return ERR_PTR(-EINVAL);
+ }
+
+ cp = mbox->chans[chan].con_priv;
+ cp->type = type;
+
+ return &mbox->chans[chan];
+}
+
+static int th1520_mbox_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct device_node *np = dev->of_node;
+ struct th1520_mbox_priv *priv;
+ struct resource *res;
+ unsigned int remote_idx = 0;
+ unsigned int i;
+ int ret;
+
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ if (of_property_read_u32(np, "icu_cpu_id", &priv->cur_icu_cpu_id)) {
+ dev_err(dev, "icu_cpu_id is missing\n");
+ return -EINVAL;
+ }
+
+ if (priv->cur_icu_cpu_id != TH_1520_MBOX_ICU_CPU0 &&
+ priv->cur_icu_cpu_id != TH_1520_MBOX_ICU_CPU3) {
+ dev_err(dev, "icu_cpu_id is invalid\n");
+ return -EINVAL;
+ }
+
+ priv->dev = dev;
+
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "local_base");
+ priv->local_icu[TH_1520_MBOX_ICU_CPU0] = devm_ioremap_resource(dev, res);
+ if (IS_ERR(priv->local_icu[TH_1520_MBOX_ICU_CPU0]))
+ return PTR_ERR(priv->local_icu[TH_1520_MBOX_ICU_CPU0]);
+
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "remote_icu0");
+ priv->remote_icu[0] = devm_ioremap_resource(dev, res);
+ if (IS_ERR(priv->remote_icu[0]))
+ return PTR_ERR(priv->remote_icu[0]);
+
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "remote_icu1");
+ priv->remote_icu[1] = devm_ioremap_resource(dev, res);
+ if (IS_ERR(priv->remote_icu[1]))
+ return PTR_ERR(priv->remote_icu[1]);
+
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "remote_icu2");
+ priv->remote_icu[2] = devm_ioremap_resource(dev, res);
+ if (IS_ERR(priv->remote_icu[2]))
+ return PTR_ERR(priv->remote_icu[2]);
+
+ priv->local_icu[TH_1520_MBOX_ICU_CPU1] =
+ priv->local_icu[TH_1520_MBOX_ICU_CPU0] + TH_1520_MBOX_CHAN_RES_SIZE;
+ priv->local_icu[TH_1520_MBOX_ICU_CPU2] =
+ priv->local_icu[TH_1520_MBOX_ICU_CPU1] + TH_1520_MBOX_CHAN_RES_SIZE;
+ priv->local_icu[TH_1520_MBOX_ICU_CPU3] =
+ priv->local_icu[TH_1520_MBOX_ICU_CPU2] + TH_1520_MBOX_CHAN_RES_SIZE;
+
+ priv->cur_cpu_ch_base = priv->local_icu[priv->cur_icu_cpu_id];
+
+ priv->irq = platform_get_irq(pdev, 0);
+ if (priv->irq < 0)
+ return priv->irq;
+
+ priv->clk = devm_clk_get(dev, NULL);
+ if (IS_ERR(priv->clk)) {
+ if (PTR_ERR(priv->clk) != -ENOENT)
+ return PTR_ERR(priv->clk);
+
+ priv->clk = NULL;
+ }
+
+ ret = clk_prepare_enable(priv->clk);
+ if (ret) {
+ dev_err(dev, "Failed to enable clock\n");
+ return ret;
+ }
+
+ /* init the chans */
+ for (i = 0; i < TH_1520_MBOX_CHANS; i++) {
+ struct th1520_mbox_con_priv *cp = &priv->con_priv[i];
+
+ cp->idx = i;
+ cp->chan = &priv->mbox_chans[i];
+ priv->mbox_chans[i].con_priv = cp;
+ snprintf(cp->irq_desc, sizeof(cp->irq_desc),
+ "th1520_mbox_chan[%i]", cp->idx);
+
+ cp->comm_local_base = priv->local_icu[i];
+ if (i != priv->cur_icu_cpu_id) {
+ cp->comm_remote_base = priv->remote_icu[remote_idx];
+ remote_idx++;
+ }
+ }
+
+ spin_lock_init(&priv->mbox_lock);
+
+ priv->mbox.dev = dev;
+ priv->mbox.ops = &th1520_mbox_ops;
+ priv->mbox.chans = priv->mbox_chans;
+ priv->mbox.num_chans = TH_1520_MBOX_CHANS;
+ priv->mbox.of_xlate = th1520_mbox_xlate;
+ priv->mbox.txdone_irq = true;
+
+ platform_set_drvdata(pdev, priv);
+
+ ret = th1520_mbox_init_generic(priv);
+ if (ret) {
+ dev_err(dev, "Failed to init mailbox context\n");
+ return ret;
+ }
+
+ return devm_mbox_controller_register(dev, &priv->mbox);
+}
+
+static void th1520_mbox_remove(struct platform_device *pdev)
+{
+ struct th1520_mbox_priv *priv = platform_get_drvdata(pdev);
+
+ clk_disable_unprepare(priv->clk);
+}
+
+static const struct of_device_id th1520_mbox_dt_ids[] = {
+ { .compatible = "thead,th1520-mbox" },
+ {}
+};
+MODULE_DEVICE_TABLE(of, th1520_mbox_dt_ids);
+
+#ifdef CONFIG_PM_SLEEP
+static int __maybe_unused th1520_mbox_suspend_noirq(struct device *dev)
+{
+ struct th1520_mbox_priv *priv = dev_get_drvdata(dev);
+ struct th1520_mbox_context *ctx = priv->ctx;
+ u32 i;
+ /*
+ * ONLY interrupt mask bit should be stored and restores.
+ * INFO data all assumed to be lost.
+ */
+ for (i = 0; i < TH_1520_MBOX_CHANS; i++) {
+ ctx->intr_mask[i] =
+ ioread32(priv->local_icu[i] + TH_1520_MBOX_MASK);
+ }
+ return 0;
+}
+
+static int __maybe_unused th1520_mbox_resume_noirq(struct device *dev)
+{
+ struct th1520_mbox_priv *priv = dev_get_drvdata(dev);
+ struct th1520_mbox_context *ctx = priv->ctx;
+ u32 i;
+
+ for (i = 0; i < TH_1520_MBOX_CHANS; i++) {
+ iowrite32(ctx->intr_mask[i],
+ priv->local_icu[i] + TH_1520_MBOX_MASK);
+ }
+
+ return 0;
+}
+#endif
+
+static int __maybe_unused th1520_mbox_runtime_suspend(struct device *dev)
+{
+ struct th1520_mbox_priv *priv = dev_get_drvdata(dev);
+
+ clk_disable_unprepare(priv->clk);
+
+ return 0;
+}
+
+static int __maybe_unused th1520_mbox_runtime_resume(struct device *dev)
+{
+ struct th1520_mbox_priv *priv = dev_get_drvdata(dev);
+ int ret;
+
+ ret = clk_prepare_enable(priv->clk);
+ if (ret)
+ dev_err(dev, "failed to enable clock\n");
+
+ return ret;
+}
+
+static const struct dev_pm_ops th1520_mbox_pm_ops = {
+ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(th1520_mbox_suspend_noirq,
+ th1520_mbox_resume_noirq)
+ SET_RUNTIME_PM_OPS(th1520_mbox_runtime_suspend,
+ th1520_mbox_runtime_resume, NULL)
+};
+
+static struct platform_driver th1520_mbox_driver = {
+ .probe = th1520_mbox_probe,
+ .remove = th1520_mbox_remove,
+ .driver = {
+ .name = "th1520-mbox",
+ .of_match_table = th1520_mbox_dt_ids,
+ .pm = &th1520_mbox_pm_ops,
+ },
+};
+module_platform_driver(th1520_mbox_driver);
+
+MODULE_DESCRIPTION("Thead Light mailbox IPC driver");
+MODULE_LICENSE("GPL");
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH RFC v1 2/3] dt-bindings: mailbox: Add thead,th1520-mailbox bindings
[not found] ` <CGME20240918134926eucas1p1df23a583b356505939d4c5501bd6c80f@eucas1p1.samsung.com>
@ 2024-09-18 13:49 ` Michal Wilczynski
2024-09-18 15:21 ` Rob Herring (Arm)
2024-09-18 20:36 ` Rob Herring
0 siblings, 2 replies; 7+ messages in thread
From: Michal Wilczynski @ 2024-09-18 13:49 UTC (permalink / raw)
To: drew, guoren, wefu, jassisinghbrar, robh, krzk+dt, conor+dt,
paul.walmsley, palmer, aou, m.szyprowski
Cc: linux-riscv, linux-kernel, devicetree, Michal Wilczynski
Add bindings for the mailbox controller. This work is based on the vendor
kernel. [1]
Link: https://github.com/revyos/thead-kernel.git [1]
Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
---
.../bindings/mailbox/thead,th1520-mbox.yaml | 83 +++++++++++++++++++
MAINTAINERS | 1 +
2 files changed, 84 insertions(+)
create mode 100644 Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
diff --git a/Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml b/Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
new file mode 100644
index 000000000000..f446fae76398
--- /dev/null
+++ b/Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
@@ -0,0 +1,83 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/thead,th1520-mbox.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: T-head TH1520 Mailbox Controller
+
+description: |
+ The T-head mailbox controller enables two cores within the SoC to
+ communicate and coordinate by passing messages (e.g., data, status,
+ and control) through the mailbox channels. It also provides the ability
+ for one core to signal the other processor using interrupts.
+
+maintainers:
+ - Michal Wilczynski <m.wilczynski@samsung.com>
+
+properties:
+ compatible:
+ const: thead,th1520-mbox
+
+ reg:
+ description: Contains base addresses and sizes for the mailbox and remote ICUs.
+ items:
+ - description: Mailbox local base address
+ - description: Remote ICU 0 base address
+ - description: Remote ICU 1 base address
+ - description: Remote ICU 2 base address
+
+ reg-names:
+ items:
+ - const: local_base
+ - const: remote_icu0
+ - const: remote_icu1
+ - const: remote_icu2
+
+ interrupts:
+ maxItems: 1
+ description: Interrupt for the mailbox controller.
+
+ clocks:
+ maxItems: 1
+ description: Clock phandle for the mailbox controller.
+
+ clock-names:
+ items:
+ - const: ipg
+
+ icu_cpu_id:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: CPU ID for the ICU.
+
+ '#mbox-cells':
+ const: 2
+ description: Number of cells required to encode the mailbox specifier.
+
+additionalProperties: false
+
+required:
+ - compatible
+ - reg
+ - reg-names
+ - interrupts
+ - icu_cpu_id
+ - '#mbox-cells'
+
+dependencies:
+ clock-names: [ clocks ]
+
+examples:
+ - |
+ mbox_910t: mbox@ffffc38000 {
+ compatible = "thead,th1520-mbox";
+ reg = <0xff 0xffc38000 0x0 0x4000>,
+ <0xff 0xffc44000 0x0 0x1000>,
+ <0xff 0xffc4c000 0x0 0x1000>,
+ <0xff 0xffc54000 0x0 0x1000>;
+ reg-names = "local_base", "remote_icu0", "remote_icu1", "remote_icu2";
+ interrupts = <28 IRQ_TYPE_LEVEL_HIGH>;
+ icu_cpu_id = <0>;
+ #mbox-cells = <2>;
+ };
diff --git a/MAINTAINERS b/MAINTAINERS
index 7331b30deef8..49198b2ed2e7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -19719,6 +19719,7 @@ L: linux-riscv@lists.infradead.org
S: Maintained
T: git https://github.com/pdp7/linux.git
F: Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml
+F: Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
F: arch/riscv/boot/dts/thead/
F: drivers/clk/thead/clk-th1520-ap.c
F: drivers/mailbox/mailbox-th1520.c
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH RFC v1 3/3] riscv: dts: thead: Add mailbox node
[not found] ` <CGME20240918134928eucas1p216ff09a6f98681def7e8e38e02c27145@eucas1p2.samsung.com>
@ 2024-09-18 13:49 ` Michal Wilczynski
0 siblings, 0 replies; 7+ messages in thread
From: Michal Wilczynski @ 2024-09-18 13:49 UTC (permalink / raw)
To: drew, guoren, wefu, jassisinghbrar, robh, krzk+dt, conor+dt,
paul.walmsley, palmer, aou, m.szyprowski
Cc: linux-riscv, linux-kernel, devicetree, Michal Wilczynski
Add mailbox device tree node. This work is based on the vendor kernel [1].
Link: https://github.com/revyos/thead-kernel.git [1]
Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
---
arch/riscv/boot/dts/thead/th1520.dtsi | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi
index 3c9974062c20..5d0cc1d899d7 100644
--- a/arch/riscv/boot/dts/thead/th1520.dtsi
+++ b/arch/riscv/boot/dts/thead/th1520.dtsi
@@ -546,5 +546,20 @@ portf: gpio-controller@0 {
interrupts = <55 IRQ_TYPE_LEVEL_HIGH>;
};
};
+
+ mbox_910t: mbox@ffffc38000 {
+ compatible = "thead,th1520-mbox";
+ reg = <0xff 0xffc38000 0x0 0x4000>,
+ <0xff 0xffc44000 0x0 0x1000>,
+ <0xff 0xffc4c000 0x0 0x1000>,
+ <0xff 0xffc54000 0x0 0x1000>;
+ reg-names = "local_base", "remote_icu0", "remote_icu1", "remote_icu2";
+ interrupt-parent = <&plic>;
+ interrupts = <28 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&apb_clk>;
+ clock-names = "ipg";
+ icu_cpu_id = <0>;
+ #mbox-cells = <2>;
+ };
};
};
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH RFC v1 2/3] dt-bindings: mailbox: Add thead,th1520-mailbox bindings
2024-09-18 13:49 ` [PATCH RFC v1 2/3] dt-bindings: mailbox: Add thead,th1520-mailbox bindings Michal Wilczynski
@ 2024-09-18 15:21 ` Rob Herring (Arm)
2024-09-18 20:36 ` Rob Herring
1 sibling, 0 replies; 7+ messages in thread
From: Rob Herring (Arm) @ 2024-09-18 15:21 UTC (permalink / raw)
To: Michal Wilczynski
Cc: devicetree, wefu, guoren, paul.walmsley, palmer, drew, krzk+dt,
aou, linux-riscv, m.szyprowski, conor+dt, linux-kernel,
jassisinghbrar
On Wed, 18 Sep 2024 15:49:00 +0200, Michal Wilczynski wrote:
> Add bindings for the mailbox controller. This work is based on the vendor
> kernel. [1]
>
> Link: https://github.com/revyos/thead-kernel.git [1]
>
> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
> ---
> .../bindings/mailbox/thead,th1520-mbox.yaml | 83 +++++++++++++++++++
> MAINTAINERS | 1 +
> 2 files changed, 84 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
>
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
Error: Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.example.dts:31.28-29 syntax error
FATAL ERROR: Unable to parse input tree
make[2]: *** [scripts/Makefile.lib:442: Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.example.dtb] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1432: dt_binding_check] Error 2
make: *** [Makefile:224: __sub-make] Error 2
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20240918134901.193033-3-m.wilczynski@samsung.com
The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFC v1 2/3] dt-bindings: mailbox: Add thead,th1520-mailbox bindings
2024-09-18 13:49 ` [PATCH RFC v1 2/3] dt-bindings: mailbox: Add thead,th1520-mailbox bindings Michal Wilczynski
2024-09-18 15:21 ` Rob Herring (Arm)
@ 2024-09-18 20:36 ` Rob Herring
2024-09-19 13:34 ` Michal Wilczynski
1 sibling, 1 reply; 7+ messages in thread
From: Rob Herring @ 2024-09-18 20:36 UTC (permalink / raw)
To: Michal Wilczynski
Cc: drew, guoren, wefu, jassisinghbrar, krzk+dt, conor+dt,
paul.walmsley, palmer, aou, m.szyprowski, linux-riscv,
linux-kernel, devicetree
On Wed, Sep 18, 2024 at 03:49:00PM +0200, Michal Wilczynski wrote:
> Add bindings for the mailbox controller. This work is based on the vendor
> kernel. [1]
>
> Link: https://github.com/revyos/thead-kernel.git [1]
>
> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
> ---
> .../bindings/mailbox/thead,th1520-mbox.yaml | 83 +++++++++++++++++++
> MAINTAINERS | 1 +
> 2 files changed, 84 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
>
> diff --git a/Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml b/Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
> new file mode 100644
> index 000000000000..f446fae76398
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
> @@ -0,0 +1,83 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/mailbox/thead,th1520-mbox.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: T-head TH1520 Mailbox Controller
> +
> +description: |
Don't need '|' if no formatting.
> + The T-head mailbox controller enables two cores within the SoC to
> + communicate and coordinate by passing messages (e.g., data, status,
> + and control) through the mailbox channels. It also provides the ability
> + for one core to signal the other processor using interrupts.
> +
> +maintainers:
> + - Michal Wilczynski <m.wilczynski@samsung.com>
> +
> +properties:
> + compatible:
> + const: thead,th1520-mbox
> +
> + reg:
> + description: Contains base addresses and sizes for the mailbox and remote ICUs.
Drop. Redundant.
> + items:
> + - description: Mailbox local base address
> + - description: Remote ICU 0 base address
> + - description: Remote ICU 1 base address
> + - description: Remote ICU 2 base address
> +
> + reg-names:
> + items:
> + - const: local_base
Just 'local'
> + - const: remote_icu0
> + - const: remote_icu1
> + - const: remote_icu2
> +
> + interrupts:
> + maxItems: 1
> + description: Interrupt for the mailbox controller.
Drop description. That's obvious.
> +
> + clocks:
> + maxItems: 1
> + description: Clock phandle for the mailbox controller.
Drop
> +
> + clock-names:
> + items:
> + - const: ipg
> +
> + icu_cpu_id:
Needs a vendor prefix and s/_/-/.
> + $ref: /schemas/types.yaml#/definitions/uint32
> + description: CPU ID for the ICU.
Constraints?
Nowhere in this patch is ICU defined.
> +
> + '#mbox-cells':
> + const: 2
> + description: Number of cells required to encode the mailbox specifier.
You need to say what each cell contains.
> +
> +additionalProperties: false
> +
> +required:
> + - compatible
> + - reg
> + - reg-names
> + - interrupts
> + - icu_cpu_id
> + - '#mbox-cells'
> +
> +dependencies:
> + clock-names: [ clocks ]
Core schema already does this.
> +
> +examples:
> + - |
> + mbox_910t: mbox@ffffc38000 {
Drop unused labels.
Standard name is 'mailbox', not 'mbox'.
> + compatible = "thead,th1520-mbox";
> + reg = <0xff 0xffc38000 0x0 0x4000>,
> + <0xff 0xffc44000 0x0 0x1000>,
> + <0xff 0xffc4c000 0x0 0x1000>,
> + <0xff 0xffc54000 0x0 0x1000>;
> + reg-names = "local_base", "remote_icu0", "remote_icu1", "remote_icu2";
> + interrupts = <28 IRQ_TYPE_LEVEL_HIGH>;
> + icu_cpu_id = <0>;
> + #mbox-cells = <2>;
> + };
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 7331b30deef8..49198b2ed2e7 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -19719,6 +19719,7 @@ L: linux-riscv@lists.infradead.org
> S: Maintained
> T: git https://github.com/pdp7/linux.git
> F: Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml
> +F: Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
> F: arch/riscv/boot/dts/thead/
> F: drivers/clk/thead/clk-th1520-ap.c
> F: drivers/mailbox/mailbox-th1520.c
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFC v1 2/3] dt-bindings: mailbox: Add thead,th1520-mailbox bindings
2024-09-18 20:36 ` Rob Herring
@ 2024-09-19 13:34 ` Michal Wilczynski
0 siblings, 0 replies; 7+ messages in thread
From: Michal Wilczynski @ 2024-09-19 13:34 UTC (permalink / raw)
To: Rob Herring
Cc: drew, guoren, wefu, jassisinghbrar, krzk+dt, conor+dt,
paul.walmsley, palmer, aou, m.szyprowski, linux-riscv,
linux-kernel, devicetree
Thank you for your review ! Will make sure all feedback is addressed in
v2.
On 9/18/24 22:36, Rob Herring wrote:
> On Wed, Sep 18, 2024 at 03:49:00PM +0200, Michal Wilczynski wrote:
>> Add bindings for the mailbox controller. This work is based on the vendor
>> kernel. [1]
>>
>> Link: https://protect2.fireeye.com/v1/url?k=385466ab-59df7384-3855ede4-74fe485cbfe7-af60aa2866e904f3&q=1&e=e3a5dfb9-1855-473e-9766-37a7ab5fbec5&u=https%3A%2F%2Fgithub.com%2Frevyos%2Fthead-kernel.git [1]
>>
>> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
>> ---
>> .../bindings/mailbox/thead,th1520-mbox.yaml | 83 +++++++++++++++++++
>> MAINTAINERS | 1 +
>> 2 files changed, 84 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml b/Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
>> new file mode 100644
>> index 000000000000..f446fae76398
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
>> @@ -0,0 +1,83 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +
>> +%YAML 1.2
>> +---
>> +$id: https://protect2.fireeye.com/v1/url?k=8a32b8a9-ebb9ad86-8a3333e6-74fe485cbfe7-0fff00bcf0ce8f57&q=1&e=e3a5dfb9-1855-473e-9766-37a7ab5fbec5&u=http%3A%2F%2Fdevicetree.org%2Fschemas%2Fmailbox%2Fthead%2Cth1520-mbox.yaml%23
>> +$schema: https://protect2.fireeye.com/v1/url?k=6b7f6c2c-0af47903-6b7ee763-74fe485cbfe7-f082b0e2a978f637&q=1&e=e3a5dfb9-1855-473e-9766-37a7ab5fbec5&u=http%3A%2F%2Fdevicetree.org%2Fmeta-schemas%2Fcore.yaml%23
>> +
>> +title: T-head TH1520 Mailbox Controller
>> +
>> +description: |
>
> Don't need '|' if no formatting.
>
>> + The T-head mailbox controller enables two cores within the SoC to
>> + communicate and coordinate by passing messages (e.g., data, status,
>> + and control) through the mailbox channels. It also provides the ability
>> + for one core to signal the other processor using interrupts.
>> +
>> +maintainers:
>> + - Michal Wilczynski <m.wilczynski@samsung.com>
>> +
>> +properties:
>> + compatible:
>> + const: thead,th1520-mbox
>> +
>> + reg:
>> + description: Contains base addresses and sizes for the mailbox and remote ICUs.
>
> Drop. Redundant.
>
>> + items:
>> + - description: Mailbox local base address
>> + - description: Remote ICU 0 base address
>> + - description: Remote ICU 1 base address
>> + - description: Remote ICU 2 base address
>> +
>> + reg-names:
>> + items:
>> + - const: local_base
>
> Just 'local'
>
>> + - const: remote_icu0
>> + - const: remote_icu1
>> + - const: remote_icu2
>> +
>> + interrupts:
>> + maxItems: 1
>> + description: Interrupt for the mailbox controller.
>
> Drop description. That's obvious.
>
>> +
>> + clocks:
>> + maxItems: 1
>> + description: Clock phandle for the mailbox controller.
>
> Drop
>
>> +
>> + clock-names:
>> + items:
>> + - const: ipg
>> +
>> + icu_cpu_id:
>
> Needs a vendor prefix and s/_/-/.
>
>> + $ref: /schemas/types.yaml#/definitions/uint32
>> + description: CPU ID for the ICU.
>
> Constraints?
There are a total of four ICU's, so this could be constrained as you
say. Thanks will fix.
>
> Nowhere in this patch is ICU defined.
ICU stands for Interrupt Controller Unit. Will make sure it's properly
documented.
>
>> +
>> + '#mbox-cells':
>> + const: 2
>> + description: Number of cells required to encode the mailbox specifier.
>
> You need to say what each cell contains.
>
>> +
>> +additionalProperties: false
>> +
>> +required:
>> + - compatible
>> + - reg
>> + - reg-names
>> + - interrupts
>> + - icu_cpu_id
>> + - '#mbox-cells'
>> +
>> +dependencies:
>> + clock-names: [ clocks ]
>
> Core schema already does this.
>
>> +
>> +examples:
>> + - |
>> + mbox_910t: mbox@ffffc38000 {
>
> Drop unused labels.
>
> Standard name is 'mailbox', not 'mbox'.
>
>> + compatible = "thead,th1520-mbox";
>> + reg = <0xff 0xffc38000 0x0 0x4000>,
>> + <0xff 0xffc44000 0x0 0x1000>,
>> + <0xff 0xffc4c000 0x0 0x1000>,
>> + <0xff 0xffc54000 0x0 0x1000>;
>> + reg-names = "local_base", "remote_icu0", "remote_icu1", "remote_icu2";
>> + interrupts = <28 IRQ_TYPE_LEVEL_HIGH>;
>> + icu_cpu_id = <0>;
>> + #mbox-cells = <2>;
>> + };
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 7331b30deef8..49198b2ed2e7 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -19719,6 +19719,7 @@ L: linux-riscv@lists.infradead.org
>> S: Maintained
>> T: git https://protect2.fireeye.com/v1/url?k=a5b0cb39-c43bde16-a5b14076-74fe485cbfe7-e7359d7be6d6a5b5&q=1&e=e3a5dfb9-1855-473e-9766-37a7ab5fbec5&u=https%3A%2F%2Fgithub.com%2Fpdp7%2Flinux.git
>> F: Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml
>> +F: Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
>> F: arch/riscv/boot/dts/thead/
>> F: drivers/clk/thead/clk-th1520-ap.c
>> F: drivers/mailbox/mailbox-th1520.c
>> --
>> 2.34.1
>>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-09-19 13:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20240918134923eucas1p1a9233b712f86b97ba8d4b9f4d7a7adbb@eucas1p1.samsung.com>
2024-09-18 13:48 ` [PATCH RFC v1 0/3] Introduce support for T-head TH1520 Mailbox Michal Wilczynski
[not found] ` <CGME20240918134925eucas1p268a994fb26a9a139ff7314cd19124653@eucas1p2.samsung.com>
2024-09-18 13:48 ` [PATCH RFC v1 1/3] mailbox: Introduce support for T-head TH1520 Mailbox driver Michal Wilczynski
[not found] ` <CGME20240918134926eucas1p1df23a583b356505939d4c5501bd6c80f@eucas1p1.samsung.com>
2024-09-18 13:49 ` [PATCH RFC v1 2/3] dt-bindings: mailbox: Add thead,th1520-mailbox bindings Michal Wilczynski
2024-09-18 15:21 ` Rob Herring (Arm)
2024-09-18 20:36 ` Rob Herring
2024-09-19 13:34 ` Michal Wilczynski
[not found] ` <CGME20240918134928eucas1p216ff09a6f98681def7e8e38e02c27145@eucas1p2.samsung.com>
2024-09-18 13:49 ` [PATCH RFC v1 3/3] riscv: dts: thead: Add mailbox node Michal Wilczynski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).