mailbox: Add support for bcm74110 mailbox
Subsystems (2)
cover mailbox: Add support for bcm74110 mailbox
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):
mailbox: Add support for bcm74110 mailbox
dt-bindings: mailbox: Add devicetree binding for bcm74110 mbox
.../bindings/mailbox/brcm,bcm74110-mbox.yaml | 68 ++ drivers/mailbox/Kconfig | 10 + drivers/mailbox/Makefile | 2 + drivers/mailbox/bcm74110-mailbox.c | 661 ++++++++++++++++++ 4 files changed, 741 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
PATCH 1/2 mailbox: Add support for bcm74110 mailbox
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.
--- drivers/mailbox/Kconfig | 10 + drivers/mailbox/Makefile | 2 + drivers/mailbox/bcm74110-mailbox.c | 661 +++++++++++++++++++++++++++++ 3 files changed, 673 insertions(+) create mode 100644 drivers/mailbox/bcm74110-mailbox.c
drivers/mailbox/Kconfig +10 -0
@@ -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
@@ -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 +661 -0
661 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 16 lines · On 27/03/2025 23:16, [email protected] wrote:
drivers/mailbox/bcm74110-mailbox.c new file +16
-0+static int bcm74110_mbox_init (struct bcm74110_mbox *mbox) +{ +int ret =0 ; + +/* Disable queues tx/rx */ +writel_relaxed (0x0 , mbox->base_tx +BCM_MBOX_CTRL ); + +/* Clear status & restart tx/rx*/ +writel_relaxed (BCM_MBOX_CTRL_EN |BCM_MBOX_CTRL_CLR , + mbox->base_tx +BCM_MBOX_CTRL ); + +/* Unmask irq */ +writel_relaxed (BCM_MBOX_IRQ_NOT_EMPTY , mbox->base_rx_irq + +BCM_MBOX_IRQ_MASK_CLEAR ); + + ret =bcm74110_mbox_link_training (mbox);
drivers/mailbox/bcm74110-mailbox.c line 457
Quoted 10 lines
drivers/mailbox/bcm74110-mailbox.c new file +10
-0+if (ret) { +dev_err (&mbox->pdev->dev,"Training failed\n" ); +return ret; + } + +return bcm74110_mbox_shmem_init (mbox); +} + + +
Just one blank line
Quoted 27 lines
drivers/mailbox/bcm74110-mailbox.c new file +27
-0+static int bcm74110_mbox_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct bcm74110_mbox *mbox; +int i, ret; + + mbox =devm_kzalloc (dev,sizeof (*mbox),GFP_KERNEL ); +if (!mbox) +return -ENOMEM ; + + mbox->pdev = pdev; +platform_set_drvdata (pdev, mbox); + + mbox->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (mbox->base)) +return dev_err_probe (dev,PTR_ERR (mbox->base),"Failed to iomap\n" ); + + ret =of_property_read_u32 (dev->of_node,"brcm,tx" , &mbox->tx_chan); +if (ret) +return dev_err_probe (dev, ret,"Failed to find tx channel\n" ); + + ret =of_property_read_u32 (dev->of_node,"brcm,rx" , &mbox->rx_chan); +if (ret) +return dev_err_probe (dev, ret,"Failed to find rx channel\n" ); + + ret =of_property_read_u32_index (dev->of_node,"brcm,shmem" ,0 , + &mbox->shmem_offset);
drivers/mailbox/bcm74110-mailbox.c line 593
Quoted 10 lines
drivers/mailbox/bcm74110-mailbox.c new file +10
-0+if (ret) +return dev_err_probe (dev, ret,"Failed to get shmem offset\n" ); + + ret =of_property_read_u32_index (dev->of_node,"brcm,shmem" ,1 , + &mbox->shmem_size); +if (ret) +return dev_err_probe (dev, ret,"Failed to get shmem size\n" ); + + mbox->rx_irq =platform_get_irq (pdev,0 ); +if (mbox->rx_irq <=0 )
That's not correct check: look at help for this function.
drivers/mailbox/bcm74110-mailbox.c line 598
Quoted 5 lines
drivers/mailbox/bcm74110-mailbox.c new file +5
-0+return dev_err_probe (dev, -EINVAL ,"Failed to get irq\n" ); + + mbox->base_tx = mbox->base +BCM_MBOX_BASE (mbox->tx_chan); + mbox->base_rx = mbox->base +BCM_MBOX_BASE (mbox->rx_chan); + mbox->base_rx_irq = mbox->base +BCM_MBOX_IRQ_BASE (mbox->rx_chan);
And all this suggests DT properties are not correct. Why would you offset base? What is the memory layout of all your mbox controllers?
Quoted 30 lines
drivers/mailbox/bcm74110-mailbox.c new file +30
-0+ +INIT_LIST_HEAD (&mbox->rx_svc_init_list); +spin_lock_init (&mbox->rx_svc_list_lock); +bcm74110_mbox_mask_and_clear (mbox); + + ret =devm_request_irq (dev, mbox->rx_irq, bcm74110_mbox_isr, +IRQF_NO_SUSPEND , pdev->name, mbox); +if (ret) +return dev_err_probe (dev, ret,"Failed to request irq\n" ); + + mbox->controller.ops = &bcm74110_mbox_chan_ops; + mbox->controller.dev = dev; + mbox->controller.num_chans =BCM_MSG_SVC_MAX ; + mbox->controller.of_xlate = &bcm74110_mbox_of_xlate; + mbox->controller.chans =devm_kcalloc (dev,BCM_MSG_SVC_MAX , +sizeof (*mbox->controller.chans), +GFP_KERNEL ); +if (!mbox->controller.chans) +return -ENOMEM ; + + mbox->mbox_chan =devm_kcalloc (dev,BCM_MSG_SVC_MAX , +sizeof (*mbox->mbox_chan), +GFP_KERNEL ); +if (!mbox->mbox_chan) +return -ENOMEM ; + +for (i =0 ; i <BCM_MSG_SVC_MAX ; i++) { + mbox->mbox_chan[i].mbox = mbox; + mbox->controller.chans[i].con_priv = &mbox->mbox_chan[i]; + }
drivers/mailbox/bcm74110-mailbox.c line 638
Quoted 10 lines
drivers/mailbox/bcm74110-mailbox.c new file +10
-0+ + ret =devm_mbox_controller_register (dev, &mbox->controller); +if (ret) +return ret; + + ret =bcm74110_mbox_init (mbox); +if (ret) +return ret; + +dev_info (dev,"Mailbox inited with %d channels\n" ,BCM_MSG_SVC_MAX );
Drop, drivers are supposed to be silent on success.
Best regards,
Krzysztof
PATCH 2/2 dt-bindings: mailbox: Add devicetree binding for bcm74110 mbox
In reply to [email protected]From: Justin Chen <[email protected]>
Add devicetree YAML binding for brcmstb bcm74110 mailbox used for communicating with a co-processor.
--- .../bindings/mailbox/brcm,bcm74110-mbox.yaml | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +68 -0
@@ -0,0 +1,68 @@ +# 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 Driver + +maintainers: + - Justin Chen <[email protected]> + - Florian Fainelli <[email protected]> + +description: Broadcom mailbox driver first introduced with 74110 + +properties: + compatible: + enum: + - brcm,bcm74110-mbox + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + "#mbox-cells": + const: 2 + description: + The first cell is channel type and second cell is shared memory slot + + brcm,mbox_tx: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Mailbox transmit doorbell + + brcm,mbox_rx: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Mailbox receive doorbell + + brcm,mbox_shmem: + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 2 + description: Mailbox shared memory region and size + +required: + - compatible + - reg + - interrupts + - "#mbox-cells" + - brcm,mbox_tx + - brcm,mbox_rx + - brcm,mbox_shmem + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + brcm_pmc_mailbox: brcm_pmc_mailbox@a552000 { + #mbox-cells = <2>; + compatible = "brcm,bcm74110-mbox"; + reg = <0xa552000 0x1100>; + brcm,mbox_tx = <0x6>; + brcm,mbox_rx = <0x7>; + brcm,mbox_shmem = <0x3000 0x400>; + interrupts = <0x0 0x67 0x4>; + interrupt-parent = <&intc>; + };
Signature · 1 line
2.34.1
Re: [PATCH 2/2] dt-bindings: mailbox: Add devicetree binding for bcm74110 mbox
Quoted 6 lines · On 27/03/2025 23:16, [email protected] wrote:
From: Justin Chen <[email protected]>
Add devicetree YAML binding for brcmstb bcm74110 mailbox used for communicating with a co-processor.
Signed-off-by Justin Chen <[email protected]>
Bindings are before users, see DT submitting patches.
Quoted 11 lines
--- .../bindings/mailbox/brcm,bcm74110-mbox.yaml | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yamlDocumentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +0
-0
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 7
Quoted 7 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +7
-0@@ -0,0 +1,68 @@ +# 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 Driver
Driver as Linux driver? Drop, bindings describe hardware.
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 13
Quoted 6 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +6
-0+ +maintainers: + - Justin Chen <[email protected]> + - Florian Fainelli <[email protected]> + +description: Broadcom mailbox driver first introduced with 74110
Same comments.
Quoted 8 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +8
-0+ +properties: + compatible: + enum: + - brcm,bcm74110-mbox + + reg: + maxItems: 1
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 31
Quoted 10 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +10
-0+ + interrupts: + maxItems: 1 + + "#mbox-cells": + const: 2 + description: + The first cell is channel type and second cell is shared memory slot + + brcm,mbox_tx:
No underscores. See DTS coding style.
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 33
Quoted 2 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +2
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + description: Mailbox transmit doorbell
Why is this needed in DT? How many instances do you have in one SoC? Where is the SoC DTS?
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 42
Quoted 9 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +9
-0+ + brcm,mbox_rx: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Mailbox receive doorbell + + brcm,mbox_shmem: + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 2 + description: Mailbox shared memory region and size
No, use existing properties, e.g. memory region.
Quoted 7 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +7
-0+ +required: + - compatible + - reg + - interrupts + - "#mbox-cells" + - brcm,mbox_tx
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 59
Quoted 10 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +10
-0+ - brcm,mbox_rx + - brcm,mbox_shmem + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + brcm_pmc_mailbox: brcm_pmc_mailbox@a552000 {
Use indentation we expect. See writing schema, example-schema.
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 61
Quoted 2 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +2
-0+ #mbox-cells = <2>; + compatible = "brcm,bcm74110-mbox";
Fix order, see DTS coding style.
Best regards,
Krzysztof
Re: [PATCH 2/2] dt-bindings: mailbox: Add devicetree binding for bcm74110 mbox
Quoted 52 lines · Krzysztof Kozlowski
Quoted 6 lines · On 27/03/2025 23:16, [email protected] wrote:
From: Justin Chen <[email protected]>
Add devicetree YAML binding for brcmstb bcm74110 mailbox used for communicating with a co-processor.
Signed-off-by Justin Chen <[email protected]>Bindings are before users, see DT submitting patches.
Quoted 11 lines
--- .../bindings/mailbox/brcm,bcm74110-mbox.yaml | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+)create mode 100644
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yamlDocumentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +0
-0Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 7
Quoted 7 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +7
-0@@ -0,0 +1,68 @@ +# 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 DriverDriver as Linux driver? Drop, bindings describe hardware.
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 13
Quoted 6 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +6
-0+ +maintainers: + - Justin Chen <[email protected]> + - Florian Fainelli <[email protected]> + +description: Broadcom mailbox driver first introduced with 74110Same comments.
Quoted 12 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +12
-0+ +properties: + compatible: + enum: + - brcm,bcm74110-mbox + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 +
Quoted 9 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 31
Quoted 6 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +6
-0+ "#mbox-cells": + const: 2 + description: + The first cell is channel type and second cell is shared memory slot + + brcm,mbox_tx:No underscores. See DTS coding style.
Acked. I already had this fixed in the driver, but not in the doc. Woops!
Quoted 6 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 33
Quoted 2 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +2
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + description: Mailbox transmit doorbellWhy is this needed in DT? How many instances do you have in one SoC? Where is the SoC DTS?
We have 3 possible instances in our current SoC. We currently only implement one. arm,scmi. But more will come in the future. I'll put a sample arm,scmi node as an example consumer in v2.
Quoted 12 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 42
Quoted 9 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +9
-0+ + brcm,mbox_rx: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Mailbox receive doorbell + + brcm,mbox_shmem: + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 2 + description: Mailbox shared memory region and sizeNo, use existing properties, e.g. memory region.
This is a region from the on chip memory. I will rename to be clear. It lies in a different address space as reserved-memory. I can still use memory region if you prefer, but I will need to manually strip the offset in my driver as the API agreed upon with the FW is an offset from the beginning of on chip memory. IMHO this makes things unnecessarily complicated.
Quoted 20 lines
Quoted 7 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +7
-0+ +required: + - compatible + - reg + - interrupts + - "#mbox-cells" + - brcm,mbox_txDocumentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 59
Quoted 10 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +10
-0+ - brcm,mbox_rx + - brcm,mbox_shmem + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + brcm_pmc_mailbox: brcm_pmc_mailbox@a552000 {Use indentation we expect. See writing schema, example-schema.
Quoted 7 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 61
Quoted 2 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +2
-0+ #mbox-cells = <2>; + compatible = "brcm,bcm74110-mbox";Fix order, see DTS coding style.
Thanks for the review.
Justin
Quoted 2 lines
Best regards,
Krzysztof
Re: [PATCH 2/2] dt-bindings: mailbox: Add devicetree binding for bcm74110 mbox
Quoted 10 lines · Justin Chen
Quoted 8 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 31
Quoted 5 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +5
-0+ const: 2 + description: + The first cell is channel type and second cell is shared memory slot + + brcm,mbox_tx:No underscores. See DTS coding style.
Acked. I already had this fixed in the driver, but not in the doc. Woops!
So this did not even work and you did not test DTS.
Where is the DTS?
Quoted 11 lines
Quoted 7 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 33
Quoted 3 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +2
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + description: Mailbox transmit doorbellWhy is this needed in DT? How many instances do you have in one SoC? Where is the SoC DTS?
We have 3 possible instances in our current SoC. We currently only implement one. arm,scmi. But more will come in the future. I'll put a sample arm,scmi node as an example consumer in v2.
No. Post your DTS instead.
Quoted 14 lines
Quoted 13 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml line 42
Quoted 10 lines
Documentation/devicetree/bindings/mailbox/brcm,bcm74110-mbox.yaml new file +9
-0+ + brcm,mbox_rx: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Mailbox receive doorbell + + brcm,mbox_shmem: + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 2 + description: Mailbox shared memory region and sizeNo, use existing properties, e.g. memory region.
Quoted 1 line
This is a region from the on chip memory. I will rename to be clear. It
memory? so reserved region is for what? Not memory?
If this is memory, then reserved region. If this is not memory, but MMIO, then you have reg for that.
Best regards,
Krzysztof