Skip to contentSkip to conversation

This patches provide ADSP IPC support for MT8195

PATCH Superseded allen-kh.cheng 2 participants 7 messages Nov 29, 2021

Subsystems (3)

v7 of 18 Superseded Latest is v18 →

lore
Share & tools
lore
#0 lore raw

v7 cover This patches provide ADSP IPC support for MT8195

From: Allen-KH Cheng <[email protected]>

Mediatek ADSP IPC is used to send notification or short message between processors with dsp.·

It will place the message to the share buffer and will access the ADSP mailbox registers to kick dsp.

Two mailboxes used to send notification or short message between processors with dsp

changes since v6:
- dt-bindings: change example dtsi node.
- change config MTK_ADSP_IPC_MBOX to MTK_ADSP_MBOX
- remove unused variable
- add reviewers

changes since v5:
- remove some redundant code

changes since v4:
- use switch ... case in adsp_ipc_recv
- add error handling path for chan_name pointer
- refine some code to be concise

changes since v3:
- reorder MTK_ADSP_IPC_MBOX config
- remove some redundant code
- remove lock in mtk-adsp-mailbox

changes since v2:
- separate adsp_mailbox into two instances

changes since v1:
- fix dt_binding_check error

Allen-KH Cheng (3):
dt-bindings: mediatek: add adsp-mbox document
firmware: mediatek: add adsp ipc protocol interface
mailbox: mediatek: add support for adsp mailbox controller

 .../bindings/mailbox/mtk,adsp-mbox.yaml       |  52 ++++++
 drivers/firmware/Kconfig                      |   1 +
 drivers/firmware/Makefile                     |   1 +
 drivers/firmware/mediatek/Kconfig             |   9 +
 drivers/firmware/mediatek/Makefile            |   2 +
 drivers/firmware/mediatek/mtk-adsp-ipc.c      | 138 ++++++++++++++
 drivers/mailbox/Kconfig                       |   7 +
 drivers/mailbox/Makefile                      |   2 +
 drivers/mailbox/mtk-adsp-mailbox.c            | 175 ++++++++++++++++++
 .../linux/firmware/mediatek/mtk-adsp-ipc.h    |  70 +++++++
 10 files changed, 457 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/mtk,adsp-mbox.yaml
 create mode 100644 drivers/firmware/mediatek/Kconfig
 create mode 100644 drivers/firmware/mediatek/Makefile
 create mode 100644 drivers/firmware/mediatek/mtk-adsp-ipc.c
 create mode 100644 drivers/mailbox/mtk-adsp-mailbox.c
 create mode 100644 include/linux/firmware/mediatek/mtk-adsp-ipc.h
Signature · 7 lines
2.18.0


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
#1 lore raw

PATCH v7 1/3 dt-bindings: mediatek: add adsp-mbox document

From: Allen-KH Cheng <[email protected]>

This patch adds document for mediatek adsp mbox

---
 .../bindings/mailbox/mtk,adsp-mbox.yaml       | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/mtk,adsp-mbox.yaml
Documentation/devicetree/bindings/mailbox/mtk,adsp-mbox.yaml new file +52 -0
new file mode 100644
index 000000000000..200a5b46fde0
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/mtk,adsp-mbox.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek ADSP mailbox
+
+maintainers:
+  - Allen-KH Cheng <[email protected]>
+
+description: |
+  The MTK ADSP mailbox Inter-Processor Communication (IPC) enables the SoC
+  to ommunicate with ADSP by passing messages through two mailbox channels.
+  The MTK ADSP mailbox IPC also provides the ability for one processor to
+  signal the other processor using interrupts.
+
+properties:
+  compatible:
+    items:
+      - const: mediatek,mt8195-adsp-mbox
+
+  "#mbox-cells":
+    const: 0
+
+  reg:
+    description:
+      Physical address base for dsp mbox registers.
+
+  interrupts:
+    description:
+      adsp mbox interrupt
+
+required:
+  - compatible
+  - "#mbox-cells"
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    adsp_mailbox0:mailbox@10816000 {
+        compatible = "mediatek,mt8195-adsp-mbox";
+        #mbox-cells = <0>;
+        reg = <0x10816000 0x1000>;
+        interrupts = <GIC_SPI 702 IRQ_TYPE_LEVEL_HIGH 0>;
+    };
Signature · 7 lines
2.18.0


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
#2 lore raw

Re: [PATCH v7 1/3] dt-bindings: mediatek: add adsp-mbox document

Quoted 7 lines · allen-kh.cheng

From: Allen-KH Cheng <[email protected]>

This patch adds document for mediatek adsp mbox

Neither AngeloGioacchino Del Regno nor myself provided the R-b tags for the patch. Please remove them.

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#3 lore raw

PATCH v7 2/3 firmware: mediatek: add adsp ipc protocol interface

In reply to allen-kh.cheng

From: Allen-KH Cheng <[email protected]>

Some of mediatek processors contain
the Tensilica HiFix DSP for audio processing.

The communication between Host CPU and DSP firmware is taking place using a shared memory area for message passing.

ADSP IPC protocol offers (send/recv) interfaces using mediatek-mailbox APIs.

We use two mbox channels to implement a request-reply protocol.

---
 drivers/firmware/Kconfig                      |   1 +
 drivers/firmware/Makefile                     |   1 +
 drivers/firmware/mediatek/Kconfig             |   9 ++
 drivers/firmware/mediatek/Makefile            |   2 +
 drivers/firmware/mediatek/mtk-adsp-ipc.c      | 138 ++++++++++++++++++
 .../linux/firmware/mediatek/mtk-adsp-ipc.h    |  70 +++++++++
 6 files changed, 221 insertions(+)
 create mode 100644 drivers/firmware/mediatek/Kconfig
 create mode 100644 drivers/firmware/mediatek/Makefile
 create mode 100644 drivers/firmware/mediatek/mtk-adsp-ipc.c
 create mode 100644 include/linux/firmware/mediatek/mtk-adsp-ipc.h
drivers/firmware/Kconfig +1 -0
index 220a58cf0a44..005f76a9a31a 100644
@@ -301,6 +301,7 @@ source "drivers/firmware/broadcom/Kconfig"
 source "drivers/firmware/google/Kconfig"
 source "drivers/firmware/efi/Kconfig"
 source "drivers/firmware/imx/Kconfig"
+source "drivers/firmware/mediatek/Kconfig"
 source "drivers/firmware/meson/Kconfig"
 source "drivers/firmware/psci/Kconfig"
 source "drivers/firmware/smccc/Kconfig"
drivers/firmware/Makefile +1 -0
index 5ced0673d94b..c0d1f3bdeae4 100644
@@ -33,6 +33,7 @@ obj-$(CONFIG_GOOGLE_FIRMWARE)	+= google/
 obj-$(CONFIG_EFI)		+= efi/
 obj-$(CONFIG_UEFI_CPER)		+= efi/
 obj-y				+= imx/
+obj-y				+= mediatek/
 obj-y				+= psci/
 obj-y				+= smccc/
 obj-y				+= tegra/
drivers/firmware/mediatek/Kconfig new file +9 -0
new file mode 100644
index 000000000000..5588af455ad1
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config MTK_ADSP_IPC
+	tristate "MTK ADSP IPC Protocol driver"
+	depends on MTK_ADSP_MBOX
+	help
+	  Say yes here to add support for the MediaTek ADSP IPC protocol
+	  between host AP (Linux) and the firmware running on ADSP.
+	  ADSP exists on some mtk processors.
+	  Client might use shared memory to exchange information with ADSP side.
drivers/firmware/mediatek/Makefile new file +2 -0
new file mode 100644
index 000000000000..4e840b65650d
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_MTK_ADSP_IPC)		+= mtk-adsp-ipc.o
drivers/firmware/mediatek/mtk-adsp-ipc.c new file +138 -0

138 lines not on this page · raw message

include/linux/firmware/mediatek/mtk-adsp-ipc.h new file +70 -0

70 lines not on this page · raw message

Signature · 7 lines
2.18.0


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Reviewed-by on v7 2/3
#4 lore raw

Re: [PATCH v7 2/3] firmware: mediatek: add adsp ipc protocol interface

Quoted 3 lines · allen-kh.cheng

Please double check again if you use the R-b tags correctly. I have provided my R-b tag before but have some more minor comments below.

With the minor comments:

Quoted 1 line
drivers/firmware/mediatek/mtk-adsp-ipc.c +0 -0

[...]

Quoted 9 lines
drivers/firmware/mediatek/mtk-adsp-ipc.c +9 -0
+int adsp_ipc_send(struct mtk_adsp_ipc *ipc, unsigned int idx, uint32_t op)
+{
+     struct mtk_adsp_chan *dsp_chan;
+     struct adsp_mbox_ch_info *ch_info;
+     int ret;
+
+     if (idx >= MTK_ADSP_MBOX_NUM)
+             return -EINVAL;
+

drivers/firmware/mediatek/mtk-adsp-ipc.c line 33

Quoted 10 lines
drivers/firmware/mediatek/mtk-adsp-ipc.c +10 -0
+     dsp_chan = &ipc->chans[idx];
+     ch_info = dsp_chan->ch->con_priv;
+     ch_info->ipc_op_val = op;
+     ret = mbox_send_message(dsp_chan->ch, NULL);
+     if (ret < 0)
+             return ret;
+
+     return 0;
+}
+EXPORT_SYMBOL(adsp_ipc_send);

To be neat, I think use mtk_adsp for all names looks better. I.e. s/adsp_ipc_send/mtk_adsp_ipc_send/.

drivers/firmware/mediatek/mtk-adsp-ipc.c

Quoted 2 lines
drivers/firmware/mediatek/mtk-adsp-ipc.c +2 -0
+static void adsp_ipc_recv(struct mbox_client *c, void *msg)
+{

Ditto, mtk_adsp_ipc_recv looks better to me.

Quoted 1 line
include/linux/firmware/mediatek/mtk-adsp-ipc.h +0 -0

[...]

include/linux/firmware/mediatek/mtk-adsp-ipc.h line 50

Quoted 4 lines
include/linux/firmware/mediatek/mtk-adsp-ipc.h +4 -0
+struct adsp_mbox_ch_info {
+     u32 ipc_op_val;
+     void __iomem *va_reg;
+};

Ditto, mtk_adsp_mbox_ch_info.

include/linux/firmware/mediatek/mtk-adsp-ipc.h

Quoted 2 lines
include/linux/firmware/mediatek/mtk-adsp-ipc.h +2 -0
+static inline void adsp_ipc_set_data(struct mtk_adsp_ipc *ipc, void *data)
+{

mtk_adsp_ipc_set_data, although there is no use case yet.

include/linux/firmware/mediatek/mtk-adsp-ipc.h line 61

Quoted 2 lines
include/linux/firmware/mediatek/mtk-adsp-ipc.h +2 -0
+static inline void *adsp_ipc_get_data(struct mtk_adsp_ipc *ipc)
+{

mtk_adsp_ipc_get_data, although there is no use case yet.

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#5 lore raw

PATCH v7 3/3 mailbox: mediatek: add support for adsp mailbox controller

In reply to allen-kh.cheng

From: Allen-KH Cheng <[email protected]>

This patch is to for MediaTek ADSP IPC mailbox controller driver It is used to send short messages between processors with adsp

---
 drivers/mailbox/Kconfig            |   7 ++
 drivers/mailbox/Makefile           |   2 +
 drivers/mailbox/mtk-adsp-mailbox.c | 175 +++++++++++++++++++++++++++++
 3 files changed, 184 insertions(+)
 create mode 100644 drivers/mailbox/mtk-adsp-mailbox.c
drivers/mailbox/Kconfig +7 -0
index c9fc06c7e685..722fbc93940b 100644
@@ -226,6 +226,13 @@ config STM32_IPCC
 	  with hardware for Inter-Processor Communication Controller (IPCC)
 	  between processors. Say Y here if you want to have this support.
 
+config MTK_ADSP_MBOX
+	tristate "MediaTek ADSP Mailbox Controller"
+	depends on ARCH_MEDIATEK || COMPILE_TEST
+	help
+	  Say yes here to add support for MediaTek ADSP mailbox controller
+	  driver. It is used to send short messages between processors with dsp.
+
 config MTK_CMDQ_MBOX
 	tristate "MediaTek CMDQ Mailbox Support"
 	depends on ARCH_MEDIATEK || COMPILE_TEST
drivers/mailbox/Makefile +2 -0
index c2089f04887e..18793e6caa2f 100644
@@ -49,6 +49,8 @@ obj-$(CONFIG_TEGRA_HSP_MBOX)	+= tegra-hsp.o
 
 obj-$(CONFIG_STM32_IPCC) 	+= stm32-ipcc.o
 
+obj-$(CONFIG_MTK_ADSP_MBOX)	+= mtk-adsp-mailbox.o
+
 obj-$(CONFIG_MTK_CMDQ_MBOX)	+= mtk-cmdq-mailbox.o
 
 obj-$(CONFIG_ZYNQMP_IPI_MBOX)	+= zynqmp-ipi-mailbox.o
drivers/mailbox/mtk-adsp-mailbox.c new file +175 -0

175 lines not on this page · raw message

Signature · 7 lines
2.18.0


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Reviewed-by on v7 3/3
#6 lore raw

Re: [PATCH v7 3/3] mailbox: mediatek: add support for adsp mailbox controller

Quoted 8 lines · allen-kh.cheng

From: Allen-KH Cheng <[email protected]>

This patch is to for MediaTek ADSP IPC mailbox controller driver It is used to send short messages between processors with adsp

Please double check again if you use the R-b tags correctly. I have provided my R-b tag before but have some more minor comments below.

With the minor comments:

Quoted 1 line
drivers/mailbox/mtk-adsp-mailbox.c +0 -0

[...]

drivers/mailbox/mtk-adsp-mailbox.c line 107

Quoted 6 lines
drivers/mailbox/mtk-adsp-mailbox.c +6 -0
+static const struct mbox_chan_ops adsp_mbox_chan_ops = {
+	.send_data	= mtk_adsp_mbox_send_data,
+	.startup	= mtk_adsp_mbox_startup,
+	.shutdown	= mtk_adsp_mbox_shutdown,
+	.last_tx_done	= mtk_adsp_mbox_last_tx_done,
+};

Rename adsp_mbox_chan_ops to mtk_adsp_mbox_chan_ops looks better to me.

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek