Apple Mailbox Controller support
Subsystems (3)
v4 cover Apple Mailbox Controller support
Hi,
This is the fourth version of my series which adds support for the mailbox controllers found on the Apple M1.
v1: https://lore.kernel.org/lkml/[email protected]/
v2: https://lore.kernel.org/lkml/[email protected]/
v3: https://lore.kernel.org/lkml/[email protected]/
Changes from v3 to v4:
- dropped minItems: 4 from the bindings
- added back of_xlate since the mailbox core only supports #mbox-cells = <1> but this mailbox uses #mbox-cells = <0>
- Split of the MAINTAINERS changes to a separate file since we have quite a few changes in flight and there will likely be conflicts once the pull requests from various subsystems are sent to Linus
Changes from v2 to v3:
- removed dma barriers since the mbox client will take care of these
- moved the of_device_id table and related code to the bottom of the file
- removed of_xlate
- dropped clock handling from the code and the binding since we now understand that these are actually power domains
Changes from v1 to v2:
- switched to txdone_irq instead of introducing a new mode
- switched to a threaded interrupt handler for receiving messages
- added co-processor examples to the device tree binding
- reformatted the register defines and clarified multiple comments
Best,
Sven
Sven Peter (3):
MAINTAINERS: Add Apple mailbox files
dt-bindings: mailbox: Add Apple mailbox bindings
mailbox: apple: Add driver for Apple mailboxes
.../bindings/mailbox/apple,mailbox.yaml | 77 ++++ MAINTAINERS | 3 + drivers/mailbox/Kconfig | 12 + drivers/mailbox/Makefile | 2 + drivers/mailbox/apple-mailbox.c | 384 ++++++++++++++++++ include/linux/apple-mailbox.h | 19 + 6 files changed, 497 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml create mode 100644 drivers/mailbox/apple-mailbox.c create mode 100644 include/linux/apple-mailbox.h
Signature · 1 line
2.25.1
PATCH v4 1/3 MAINTAINERS: Add Apple mailbox files
Add Apple mailbox files under the ARM/APPLE MACHINE SUPPORT entry.
---
As mentioned in the cover letter, there are very likely going to be conflicts in MAINTAINERS when the various patches that are in-flight in different subsystems will be merged.
MAINTAINERS | 3 +++ 1 file changed, 3 insertions(+)
MAINTAINERS +3 -0
@@ -1723,11 +1723,14 @@ C: irc://irc.oftc.net/asahi-dev T: git https://github.com/AsahiLinux/linux.git F: Documentation/devicetree/bindings/arm/apple.yaml F: Documentation/devicetree/bindings/interrupt-controller/apple,aic.yaml +F: Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml F: Documentation/devicetree/bindings/pinctrl/apple,pinctrl.yaml F: arch/arm64/boot/dts/apple/ F: drivers/irqchip/irq-apple-aic.c +F: drivers/mailbox/apple-mailbox.c F: include/dt-bindings/interrupt-controller/apple-aic.h F: include/dt-bindings/pinctrl/apple.h +F: include/linux/apple-mailbox.h ARM/ARTPEC MACHINE SUPPORT M: Jesper Nilsson <[email protected]>
Signature · 1 line
2.25.1
PATCH v4 2/3 dt-bindings: mailbox: Add Apple mailbox bindings
In reply to Sven PeterApple mailbox controller are found on the M1 and are used for communication with various co-processors.
--- .../bindings/mailbox/apple,mailbox.yaml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml
Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml new file +77 -0
@@ -0,0 +1,77 @@ +# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mailbox/apple,mailbox.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple Mailbox Controller + +maintainers: + - Hector Martin <[email protected]> + - Sven Peter <[email protected]> + +description: + The Apple mailbox consists of two FIFOs used to exchange 64+32 bit + messages between the main CPU and a co-processor. Multiple instances + of this mailbox can be found on Apple SoCs. + One of the two FIFOs is used to send data to a co-processor while the other + FIFO is used for the other direction. + Various clients implement different IPC protocols based on these simple + messages and shared memory buffers. + +properties: + compatible: + oneOf: + - description: + ASC mailboxes are the most common variant found on the M1 used + for example for the display controller, the system management + controller and the NVMe coprocessor. + items: + - const: apple,t8103-asc-mailbox + + - description: + M3 mailboxes are an older variant with a slightly different MMIO + interface still found on the M1. It is used for the Thunderbolt + co-processors. + items: + - const: apple,t8103-m3-mailbox + + reg: + maxItems: 1 + + interrupts: + items: + - description: send fifo is empty interrupt + - description: send fifo is not empty interrupt + - description: receive fifo is empty interrupt + - description: receive fifo is not empty interrupt + + interrupt-names: + items: + - const: send-empty + - const: send-not-empty + - const: recv-empty + - const: recv-not-empty + + "#mbox-cells": + const: 0 + +required: + - compatible + - reg + - interrupts + - interrupt-names + - "#mbox-cells" + +additionalProperties: false + +examples: + - | + mailbox@77408000 { + compatible = "apple,t8103-asc-mailbox"; + reg = <0x77408000 0x4000>; + interrupts = <1 583 4>, <1 584 4>, <1 585 4>, <1 586 4>; + interrupt-names = "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells = <0>; + };
Signature · 1 line
2.25.1
PATCH v4 3/3 mailbox: apple: Add driver for Apple mailboxes
In reply to Sven PeterApple SoCs such as the M1 come with various co-processors. Mailboxes are used to communicate with those. This driver adds support for two variants of those mailboxes.
--- drivers/mailbox/Kconfig | 12 + drivers/mailbox/Makefile | 2 + drivers/mailbox/apple-mailbox.c | 384 ++++++++++++++++++++++++++++++++ include/linux/apple-mailbox.h | 19 ++ 4 files changed, 417 insertions(+) create mode 100644 drivers/mailbox/apple-mailbox.c create mode 100644 include/linux/apple-mailbox.h
drivers/mailbox/Kconfig +12 -0
@@ -8,6 +8,18 @@ menuconfig MAILBOX if MAILBOX +config APPLE_MAILBOX + tristate "Apple Mailbox driver" + depends on ARCH_APPLE || (ARM64 && COMPILE_TEST) + default ARCH_APPLE + help + Apple SoCs have various co-processors required for certain + peripherals to work (NVMe, display controller, etc.). This + driver adds support for the mailbox controller used to + communicate with those. + + Say Y here if you have a Apple SoC. + config ARM_MHU tristate "ARM MHU Mailbox" depends on ARM_AMBA
drivers/mailbox/Makefile +2 -0
@@ -58,3 +58,5 @@ obj-$(CONFIG_SUN6I_MSGBOX) += sun6i-msgbox.o obj-$(CONFIG_SPRD_MBOX) += sprd-mailbox.o obj-$(CONFIG_QCOM_IPCC) += qcom-ipcc.o + +obj-$(CONFIG_APPLE_MAILBOX) += apple-mailbox.o
drivers/mailbox/apple-mailbox.c new file +384 -0
384 lines not on this page · raw message
include/linux/apple-mailbox.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ +/* +* Apple mailbox message format +* +* Copyright (C) 2021 The Asahi Linux Contributors +*/ + +#ifndef _LINUX_APPLE_MAILBOX_H_ +#define _LINUX_APPLE_MAILBOX_H_ + +#include <linux/types.h> + +/* encodes a single 96bit message sent over the single channel */ +struct apple_mbox_msg { +u64 msg0; +u32 msg1; +}; + +#endif
Signature · 1 line
2.25.1