Skip to contentSkip to conversation

mailbox: Add support for bcm74110

PATCH Superseded [email protected] 3 participants 5 messages Apr 15, 2025 – May 7, 2025

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover mailbox: Add support for bcm74110

From: Justin Chen <[email protected]>

The bcm74110 mailbox driver is used to communicate with a co-processor for various power management and firmware related tasks.

Justin Chen (2):
dt-bindings: mailbox: Add support for bcm74110
mailbox: Add support for bcm74110

 .../bindings/mailbox/brcm,bcm74110-mbox.yaml  |  64 ++
 drivers/mailbox/Kconfig                       |  10 +
 drivers/mailbox/Makefile                      |   2 +
 drivers/mailbox/bcm74110-mailbox.c            | 655 ++++++++++++++++++
 4 files changed, 731 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml
 create mode 100644 drivers/mailbox/bcm74110-mailbox.c
Signature · 1 line
2.34.1
#1 lore raw

PATCH v4 1/2 dt-bindings: mailbox: Add support for bcm74110

From: Justin Chen <[email protected]>

Add devicetree YAML binding for brcmstb bcm74110 mailbox used for communicating with a co-processor.

---
v4
Dropped minItems from interrupts

v3
Added list for interrupts.
Corrected dts example. Fixed ordering and naming.

v2
Renamed brcm,brcm_{tx|rx} to brcm,{tx|rx}. Removed brcm,shmem node. Not necessary to keep in dt. Fixed example and added scmi node.

 .../bindings/mailbox/brcm,bcm74110-mbox.yaml  | 64 +++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +64 -0
new file mode 100644
index 000000000000..750cc96edb46
@@ -0,0 +1,64 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/brcm,bcm74110-mbox.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM74110 Mailbox
+
+maintainers:
+  - Justin Chen <[email protected]>
+  - Florian Fainelli <[email protected]>
+
+description: Broadcom mailbox hardware first introduced with 74110
+
+properties:
+  compatible:
+    enum:
+      - brcm,bcm74110-mbox
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    items:
+      - description: RX doorbell and watermark interrupts
+      - description: TX doorbell and watermark interrupts
+
+  "#mbox-cells":
+    const: 2
+    description:
+      The first cell is channel type and second cell is shared memory slot
+
+  brcm,rx:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: RX Mailbox number
+
+  brcm,tx:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: TX Mailbox number
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - "#mbox-cells"
+  - brcm,rx
+  - brcm,tx
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    mailbox@a552000 {
+        compatible = "brcm,bcm74110-mbox";
+        reg = <0xa552000 0x1104>;
+        interrupts = <GIC_SPI 0x67 IRQ_TYPE_LEVEL_HIGH>,
+                     <GIC_SPI 0x66 IRQ_TYPE_LEVEL_HIGH>;
+        #mbox-cells = <0x2>;
+        brcm,rx = <0x7>;
+        brcm,tx = <0x6>;
+    };
Signature · 1 line
2.34.1
#3 lore raw

PATCH v4 2/2 mailbox: Add support for bcm74110

In reply to [email protected]

From: Justin Chen <[email protected]>

The bcm74110 mailbox driver is used to communicate with a co-processor for various power management and firmware related tasks.

---
v3/v4
No changes

v2
Fixed minor formatting issues
Fixed error check of platform_get_irq()
Removed offsetted base iomem vars. Instead we just offset directly from base.
Removed shmem variable. Hardcode it instead.

 drivers/mailbox/Kconfig            |  10 +
 drivers/mailbox/Makefile           |   2 +
 drivers/mailbox/bcm74110-mailbox.c | 655 +++++++++++++++++++++++++++++
 3 files changed, 667 insertions(+)
 create mode 100644 drivers/mailbox/bcm74110-mailbox.c
drivers/mailbox/Kconfig +10 -0
index ed52db272f4d..6fe3356ddde5 100644
@@ -330,4 +330,14 @@ config THEAD_TH1520_MBOX
 	  kernel is running, and E902 core used for power management among other
 	  things.
 
+config BCM74110_MAILBOX
+	tristate "Brcmstb BCM74110 Mailbox"
+	depends on ARCH_BRCMSTB || COMPILE_TEST
+	default ARCH_BRCMSTB
+	help
+	  Broadcom STB mailbox driver present starting with brcmstb bcm74110
+	  SoCs. The mailbox is a communication channel between the host
+	  processor and coprocessor that handles various power management task
+	  and more.
+
 endif
drivers/mailbox/Makefile +2 -0
index 9a1542b55539..eb2e8f55bd15 100644
@@ -70,3 +70,5 @@ obj-$(CONFIG_QCOM_CPUCP_MBOX)	+= qcom-cpucp-mbox.o
 obj-$(CONFIG_QCOM_IPCC)		+= qcom-ipcc.o
 
 obj-$(CONFIG_THEAD_TH1520_MBOX)	+= mailbox-th1520.o
+
+obj-$(CONFIG_BCM74110_MAILBOX)	+= bcm74110-mailbox.o
drivers/mailbox/bcm74110-mailbox.c new file +655 -0

655 lines not on this page · raw message

Signature · 1 line
2.34.1
#4 lore raw
kernel test robot noticed the following build errors:

Hi,

kernel test robot noticed the following build errors:

[auto build test ERROR on jassibrar-mailbox/for-next]
[also build test ERROR on linus/master v6.15-rc5 next-20250507] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/justin-chen-broadcom-com/dt-bindings-mailbox-Add-support-for-bcm74110/20250416-125112
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jassibrar/mailbox.git for-next
patch link:    https://lore.kernel.org/r/20250415182826.3905917-3-justin.chen%40broadcom.com
patch subject: [PATCH v4 2/2] mailbox: Add support for bcm74110
config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20250507/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250507/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All error/warnings (new ones prefixed by >>):

drivers/mailbox/bcm74110-mailbox.c: In function 'bcm74110_rx_push_init_msg':

>> drivers/mailbox/bcm74110-mailbox.c:142:15: error: implicit declaration of function 'kzalloc' [-Werror=implicit-function-declaration]
     142 |         msg = kzalloc(sizeof(*msg), GFP_ATOMIC);
         |               ^~~~~~~
>> drivers/mailbox/bcm74110-mailbox.c:142:13: warning: assignment to 'struct bcm74110_mbox_msg *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     142 |         msg = kzalloc(sizeof(*msg), GFP_ATOMIC);
         |             ^
   drivers/mailbox/bcm74110-mailbox.c: In function 'bcm74110_rx_pop_init_msg':
>> drivers/mailbox/bcm74110-mailbox.c:237:9: error: implicit declaration of function 'kfree' [-Werror=implicit-function-declaration]
     237 |         kfree(msg);
         |         ^~~~~

cc1: some warnings being treated as errors

vim +/kzalloc +142 drivers/mailbox/bcm74110-mailbox.c

137
138 static void bcm74110_rx_push_init_msg(struct bcm74110_mbox *mbox, u32 val)
139 {
140 struct bcm74110_mbox_msg *msg;
141

 > 142		msg = kzalloc(sizeof(*msg), GFP_ATOMIC);
   143		if (!msg)
   144			return;
   145	
   146		INIT_LIST_HEAD(&msg->list_entry);
   147		msg->msg = val;
   148	
   149		spin_lock(&mbox->rx_svc_list_lock);
   150		list_add_tail(&msg->list_entry, &mbox->rx_svc_init_list);
   151		spin_unlock(&mbox->rx_svc_list_lock);
   152	}
   153	
   154	static void bcm74110_rx_process_msg(struct bcm74110_mbox *mbox)
   155	{
   156		struct device *dev = &mbox->pdev->dev;
   157		struct bcm74110_mbox_chan *chan_priv;
   158		struct mbox_chan *chan;
   159		u32 msg, status;
   160		int type;
   161	
   162		do {
   163			msg = bcm74110_rx_readl(mbox, BCM_MBOX_RDATA);
   164			status = bcm74110_rx_readl(mbox, BCM_MBOX_STATUS0);
   165	
   166			dev_dbg(dev, "rx: [{req=%lu|rply=%lu|srv=%lu|fn=%lu|length=%lu|slot=%lu]\n",
   167				BCM_MSG_GET_FIELD(msg, REQ), BCM_MSG_GET_FIELD(msg, RPLY),
   168				BCM_MSG_GET_FIELD(msg, SVC), BCM_MSG_GET_FIELD(msg, FUNC),
   169				BCM_MSG_GET_FIELD(msg, LENGTH), BCM_MSG_GET_FIELD(msg, SLOT));
   170	
   171			type = BCM_MSG_GET_FIELD(msg, SVC);
   172			switch (type) {
   173			case BCM_MSG_SVC_INIT:
   174				bcm74110_rx_push_init_msg(mbox, msg);
   175				break;
   176			case BCM_MSG_SVC_PMC:
   177			case BCM_MSG_SVC_SCMI:
   178			case BCM_MSG_SVC_DPFE:
   179				chan = &mbox->controller.chans[type];
   180				chan_priv = chan->con_priv;
   181				if (chan_priv->en)
   182					mbox_chan_received_data(chan, NULL);
   183				else
   184					dev_warn(dev, "Channel not enabled\n");
   185				break;
   186			default:
   187				dev_warn(dev, "Unsupported msg received\n");
   188			}
   189		} while (status & BCM_MBOX_STATUS0_NOT_EMPTY);
   190	}
   191	
   192	static irqreturn_t bcm74110_mbox_isr(int irq, void *data)
   193	{
   194		struct bcm74110_mbox *mbox = data;
   195		u32 status;
   196	
   197		status = bcm74110_irq_readl(mbox, BCM_MBOX_IRQ_STATUS);
   198	
   199		bcm74110_irq_writel(mbox, 0xffffffff, BCM_MBOX_IRQ_CLEAR);
   200	
   201		if (status & BCM_MBOX_IRQ_NOT_EMPTY)
   202			bcm74110_rx_process_msg(mbox);
   203		else
   204			dev_warn(&mbox->pdev->dev, "Spurious interrupt\n");
   205	
   206		return IRQ_HANDLED;
   207	}
   208	
   209	static void bcm74110_mbox_mask_and_clear(struct bcm74110_mbox *mbox)
   210	{
   211		bcm74110_irq_writel(mbox, 0xffffffff, BCM_MBOX_IRQ_MASK_SET);
   212		bcm74110_irq_writel(mbox, 0xffffffff, BCM_MBOX_IRQ_CLEAR);
   213	}
   214	
   215	static int bcm74110_rx_pop_init_msg(struct bcm74110_mbox *mbox, u32 func_type,
   216					    u32 *val)
   217	{
   218		struct bcm74110_mbox_msg *msg, *msg_tmp;
   219		unsigned long flags;
   220		bool found = false;
   221	
   222		spin_lock_irqsave(&mbox->rx_svc_list_lock, flags);
   223		list_for_each_entry_safe(msg, msg_tmp, &mbox->rx_svc_init_list,
   224					 list_entry) {
   225			if (BCM_MSG_GET_FIELD(msg->msg, FUNC) == func_type) {
   226				list_del(&msg->list_entry);
   227				found = true;
   228				break;
   229			}
   230		}
   231		spin_unlock_irqrestore(&mbox->rx_svc_list_lock, flags);
   232	
   233		if (!found)
   234			return -EINVAL;
   235	
   236		*val = msg->msg;
 > 237		kfree(msg);

238
239 return 0;
240 }
241

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki