Allwinner sunxi message box support
Subsystems (5)
Samuel Holland
maintainerv3 cover Allwinner sunxi message box support
This series adds support for the "hardware message box" in sun8i, sun9i, and sun50i SoCs, used for communication with the ARISC management processor (the platform's equivalent of the ARM SCP). The end goal is to use the arm_scpi driver as a client, communicating with firmware running on the AR100 CPU, or to use the mailbox to forward NMIs that the firmware picks up from R_INTC.
Unfortunately, the ARM SCPI client no longer works with this driver since it now exposes all 8 hardware FIFOs individually. The SCPI client could be made to work (and I posted proof-of-concept code to that effect with v1 of this series), but that is a low priority, as Linux does not directly use SCPI with the current firmware version; all SCPI use goes through ATF via PSCI.
An example usage is included at the end of this patch series. The IRQ forwarding code is WIP and not even RFC quality yet, but it does work. To build the firmware component, run:
git clone https://github.com/crust-firmware/meta meta
git clone https://github.com/smaeul/crust -b linux-mailbox-example meta/crust cd meta
make
That will by default produce a U-Boot + ATF + SCP firmware image in [meta/]build/pinebook/u-boot-sunxi-with-spl.bin. See the top-level README.md for more information (like cross-compiler setup). The IRQ-forwarding mailbox server is implemented in [meta/crust/]common/irqf.c.
With that firmware and the full patch series here (on top of torvalds/master), Linux boots and is able to receive NMIs from the PMIC (i.e. use showkey to see that the power button works, and see that /proc/interrupts updates). As an added bonus, suspend/resume also mostly works :)
Changes from v2:
- Merge patches 1-3
- Add a comment in the code explaining the CLK_IS_CRITICAL usage
- Add a patch to mark the AR100 clocks as critical
- Use YAML for the device tree binding
- Include a not-for-merge example usage of the mailbox.
Changes from v1:
- Marked message box clocks as critical instead of hacks in the driver
- 8 unidirectional channels instead of 4 bidirectional pairs
- Use per-SoC compatible strings and an A31 fallback compatible
- Dropped the mailbox framework patch
- Include DT patches for SoCs that document the message box
Samuel Holland (15):
clk: sunxi-ng: Mark msgbox clocks as critical
clk: sunxi-ng: Mark AR100 clocks as critical
dt-bindings: mailbox: Add a sunxi message box binding
mailbox: sunxi-msgbox: Add a new mailbox driver
ARM: dts: sunxi: a80: Add msgbox node
ARM: dts: sunxi: a83t: Add msgbox node
ARM: dts: sunxi: h3/h5: Add msgbox node
arm64: dts: allwinner: a64: Add msgbox node
arm64: dts: allwinner: h6: Add msgbox node
[NOT FOR MERGE] clk: sunxi-ng: sun8i: Avoid turning off unused PRCM
gates
[NOT FOR MERGE] dt-bindings: Add a binding for a mailbox-backed
interrupt controller
[NOT FOR MERGE] irqchip/mbox: Introduce a mailbox-backed irqchip
driver
[NOT FOR MERGE] arm64: dts: allwinner: a64: Add interrupt controller
node
[NOT FOR MERGE] arm64: dts: allwinner: a64: Convert DTS to use
msgbox_intc
[NOT FOR MERGE] arm64: dts: allwinner: a64: Remove unused r_intc
.../interrupt-controller/mbox-intc.txt | 33 ++ .../mailbox/allwinner,sunxi-msgbox.yaml | 79 +++++ arch/arm/boot/dts/sun8i-a83t.dtsi | 10 + arch/arm/boot/dts/sun9i-a80.dtsi | 10 + arch/arm/boot/dts/sunxi-h3-h5.dtsi | 10 + .../allwinner/sun50i-a64-amarula-relic.dts | 4 +- .../dts/allwinner/sun50i-a64-bananapi-m64.dts | 4 +- .../dts/allwinner/sun50i-a64-nanopi-a64.dts | 4 +- .../dts/allwinner/sun50i-a64-olinuxino.dts | 4 +- .../dts/allwinner/sun50i-a64-orangepi-win.dts | 4 +- .../boot/dts/allwinner/sun50i-a64-pine64.dts | 4 +- .../dts/allwinner/sun50i-a64-pinebook.dts | 4 +- .../boot/dts/allwinner/sun50i-a64-sopine.dtsi | 4 +- .../boot/dts/allwinner/sun50i-a64-teres-i.dts | 4 +- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 27 +- arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 10 + drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 3 +- drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c | 2 +- drivers/clk/sunxi-ng/ccu-sun50i-h6.c | 3 +- drivers/clk/sunxi-ng/ccu-sun8i-a23.c | 3 +- drivers/clk/sunxi-ng/ccu-sun8i-a33.c | 3 +- drivers/clk/sunxi-ng/ccu-sun8i-a83t.c | 3 +- drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 3 +- drivers/clk/sunxi-ng/ccu-sun8i-r.c | 20 +- drivers/clk/sunxi-ng/ccu-sun9i-a80.c | 3 +- drivers/irqchip/Kconfig | 9 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-mbox.c | 199 +++++++++++ drivers/mailbox/Kconfig | 11 + drivers/mailbox/Makefile | 2 + drivers/mailbox/sunxi-msgbox.c | 315 ++++++++++++++++++ 31 files changed, 750 insertions(+), 45 deletions(-) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/mbox-intc.txt create mode 100644 Documentation/devicetree/bindings/mailbox/allwinner,sunxi-msgbox.yaml create mode 100644 drivers/irqchip/irq-mbox.c create mode 100644 drivers/mailbox/sunxi-msgbox.c
Signature · 1 line
2.19.2
Samuel Holland
maintainerPATCH v3 1/15 clk: sunxi-ng: Mark msgbox clocks as critical
The msgbox clock is critical because the hardware it controls is shared between Linux and system firmware. The message box may be used by the EL3 secure monitor's PSCI implementation. On 64-bit sunxi SoCs, this is provided by ARM TF-A; 32-bit SoCs use a different implementation. The secure monitor uses the message box to forward requests to power management firmware running on a separate CPU.
It is not enough for the secure monitor to enable the clock each time Linux performs a SMC into EL3, as both the firmware and Linux can run concurrently on separate CPUs. So it is never safe for Linux to turn this clock off, and it should be marked as critical.
At this time, such power management firmware only exists for the A64 and H5 SoCs. However, it makes sense to take care of all CCU drivers now for consistency, and to ease the transition in the future once firmware is ported to the other SoCs.
--- drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 3 ++- drivers/clk/sunxi-ng/ccu-sun50i-h6.c | 3 ++- drivers/clk/sunxi-ng/ccu-sun8i-a23.c | 3 ++- drivers/clk/sunxi-ng/ccu-sun8i-a33.c | 3 ++- drivers/clk/sunxi-ng/ccu-sun8i-a83t.c | 3 ++- drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 3 ++- drivers/clk/sunxi-ng/ccu-sun9i-a80.c | 3 ++- 7 files changed, 14 insertions(+), 7 deletions(-)
drivers/clk/sunxi-ng/ccu-sun50i-a64.c +2 -1
@@ -349,8 +349,9 @@ static SUNXI_CCU_GATE(bus_de_clk, "bus-de", "ahb1", 0x064, BIT(12), 0); static SUNXI_CCU_GATE(bus_gpu_clk, "bus-gpu", "ahb1", 0x064, BIT(20), 0); +/* Used for communication between firmware components at runtime */ static SUNXI_CCU_GATE(bus_msgbox_clk, "bus-msgbox", "ahb1", - 0x064, BIT(21), 0); + 0x064, BIT(21), CLK_IS_CRITICAL); static SUNXI_CCU_GATE(bus_spinlock_clk, "bus-spinlock", "ahb1", 0x064, BIT(22), 0);
drivers/clk/sunxi-ng/ccu-sun50i-h6.c +2 -1
@@ -339,8 +339,9 @@ static SUNXI_CCU_GATE(bus_vp9_clk, "bus-vp9", "psi-ahb1-ahb2", static SUNXI_CCU_GATE(bus_dma_clk, "bus-dma", "psi-ahb1-ahb2", 0x70c, BIT(0), 0); +/* Used for communication between firmware components at runtime */ static SUNXI_CCU_GATE(bus_msgbox_clk, "bus-msgbox", "psi-ahb1-ahb2", - 0x71c, BIT(0), 0); + 0x71c, BIT(0), CLK_IS_CRITICAL); static SUNXI_CCU_GATE(bus_spinlock_clk, "bus-spinlock", "psi-ahb1-ahb2", 0x72c, BIT(0), 0);
drivers/clk/sunxi-ng/ccu-sun8i-a23.c +2 -1
@@ -262,8 +262,9 @@ static SUNXI_CCU_GATE(bus_de_fe_clk, "bus-de-fe", "ahb1", 0x064, BIT(14), 0); static SUNXI_CCU_GATE(bus_gpu_clk, "bus-gpu", "ahb1", 0x064, BIT(20), 0); +/* Used for communication between firmware components at runtime */ static SUNXI_CCU_GATE(bus_msgbox_clk, "bus-msgbox", "ahb1", - 0x064, BIT(21), 0); + 0x064, BIT(21), CLK_IS_CRITICAL); static SUNXI_CCU_GATE(bus_spinlock_clk, "bus-spinlock", "ahb1", 0x064, BIT(22), 0); static SUNXI_CCU_GATE(bus_drc_clk, "bus-drc", "ahb1",
drivers/clk/sunxi-ng/ccu-sun8i-a33.c +2 -1
@@ -274,8 +274,9 @@ static SUNXI_CCU_GATE(bus_de_fe_clk, "bus-de-fe", "ahb1", 0x064, BIT(14), 0); static SUNXI_CCU_GATE(bus_gpu_clk, "bus-gpu", "ahb1", 0x064, BIT(20), 0); +/* Used for communication between firmware components at runtime */ static SUNXI_CCU_GATE(bus_msgbox_clk, "bus-msgbox", "ahb1", - 0x064, BIT(21), 0); + 0x064, BIT(21), CLK_IS_CRITICAL); static SUNXI_CCU_GATE(bus_spinlock_clk, "bus-spinlock", "ahb1", 0x064, BIT(22), 0); static SUNXI_CCU_GATE(bus_drc_clk, "bus-drc", "ahb1",
drivers/clk/sunxi-ng/ccu-sun8i-a83t.c +2 -1
@@ -346,8 +346,9 @@ static SUNXI_CCU_GATE(bus_de_clk, "bus-de", "ahb1", 0x064, BIT(12), 0); static SUNXI_CCU_GATE(bus_gpu_clk, "bus-gpu", "ahb1", 0x064, BIT(20), 0); +/* Used for communication between firmware components at runtime */ static SUNXI_CCU_GATE(bus_msgbox_clk, "bus-msgbox", "ahb1", - 0x064, BIT(21), 0); + 0x064, BIT(21), CLK_IS_CRITICAL); static SUNXI_CCU_GATE(bus_spinlock_clk, "bus-spinlock", "ahb1", 0x064, BIT(22), 0);
drivers/clk/sunxi-ng/ccu-sun8i-h3.c +2 -1
@@ -280,8 +280,9 @@ static SUNXI_CCU_GATE(bus_de_clk, "bus-de", "ahb1", 0x064, BIT(12), 0); static SUNXI_CCU_GATE(bus_gpu_clk, "bus-gpu", "ahb1", 0x064, BIT(20), 0); +/* Used for communication between firmware components at runtime */ static SUNXI_CCU_GATE(bus_msgbox_clk, "bus-msgbox", "ahb1", - 0x064, BIT(21), 0); + 0x064, BIT(21), CLK_IS_CRITICAL); static SUNXI_CCU_GATE(bus_spinlock_clk, "bus-spinlock", "ahb1", 0x064, BIT(22), 0);
drivers/clk/sunxi-ng/ccu-sun9i-a80.c +2 -1
@@ -755,8 +755,9 @@ static SUNXI_CCU_GATE(bus_usb_clk, "bus-usb", "ahb1", 0x584, BIT(1), 0); static SUNXI_CCU_GATE(bus_gmac_clk, "bus-gmac", "ahb1", 0x584, BIT(17), 0); +/* Used for communication between firmware components at runtime */ static SUNXI_CCU_GATE(bus_msgbox_clk, "bus-msgbox", "ahb1", - 0x584, BIT(21), 0); + 0x584, BIT(21), CLK_IS_CRITICAL); static SUNXI_CCU_GATE(bus_spinlock_clk, "bus-spinlock", "ahb1", 0x584, BIT(22), 0); static SUNXI_CCU_GATE(bus_hstimer_clk, "bus-hstimer", "ahb1",
Signature · 1 line
2.19.2
Samuel Holland
maintainerPATCH v3 2/15 clk: sunxi-ng: Mark AR100 clocks as critical
In reply to Samuel HollandOn sun8i, sun9i, and sun50i SoCs, system suspend/resume support requires firmware running on the AR100 coprocessor (the "SCP"). Such firmware can provide additional features, such as thermal monitoring and poweron/off support for boards without a PMIC.
Since the AR100 may be running critical firmware, even if Linux does not know about it or directly interact with it (all requests may go through an intermediary interface such as PSCI), Linux must not turn off its clock.
At this time, such power management firmware only exists for the A64 and H5 SoCs. However, it makes sense to take care of all CCU drivers now for consistency, and to ease the transition in the future once firmware is ported to the other SoCs.
Leaving the clock running is safe even if no firmware is present, since the AR100 stays in reset by default. In most cases, the AR100 clock is kept enabled by Linux anyway, since it is the parent of all APB0 bus peripherals. This change only prevents Linux from turning off the AR100 clock in the rare case that no peripherals are in use.
--- drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c | 2 +- drivers/clk/sunxi-ng/ccu-sun8i-r.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c +1 -1
@@ -45,7 +45,7 @@ static struct ccu_div ar100_clk = { .hw.init = CLK_HW_INIT_PARENTS("ar100", ar100_r_apb2_parents, &ccu_div_ops, - 0), + CLK_IS_CRITICAL), }, };
drivers/clk/sunxi-ng/ccu-sun8i-r.c +1 -1
@@ -50,7 +50,7 @@ static struct ccu_div ar100_clk = { .hw.init = CLK_HW_INIT_PARENTS("ar100", ar100_parents, &ccu_div_ops, - 0), + CLK_IS_CRITICAL), }, };
Signature · 1 line
2.19.2
Samuel Holland
maintainerPATCH v3 3/15 dt-bindings: mailbox: Add a sunxi message box binding
In reply to Samuel HollandThis mailbox hardware is present in Allwinner sun8i, sun9i, and sun50i SoCs. Add a device tree binding for it.
--- .../mailbox/allwinner,sunxi-msgbox.yaml | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/allwinner,sunxi-msgbox.yaml
Documentation/devicetree/bindings/mailbox/allwinner,sunxi-msgbox.yaml new file +79 -0
@@ -0,0 +1,79 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mailbox/allwinner,sunxi-msgbox.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Allwinner sunxi Message Box + +maintainers: + - Samuel Holland <samuel-RkNLwX/[email protected]> + +description: | + The hardware message box on sun6i and newer sunxi SoCs is a two-user mailbox + controller containing 8 unidirectional FIFOs. An interrupt is raised for + received messages, but software must poll to know when a transmitted message + has been acknowledged by the remote user. Each FIFO can hold four 32-bit + messages; when a FIFO is full, clients must wait before more transmissions. + + Refer to ./mailbox.txt for generic information about mailbox device-tree + bindings. + +properties: + compatible: + oneOf: + - items: + - enum: + - allwinner,sun8i-a83t-msgbox + - allwinner,sun8i-h3-msgbox + - allwinner,sun9i-a80-msgbox + - allwinner,sun50i-a64-msgbox + - allwinner,sun50i-h6-msgbox + - const: allwinner,sun6i-a31-msgbox + - items: + - const: allwinner,sun6i-a31-msgbox + + reg: + items: + - description: MMIO register range + + clocks: + maxItems: 1 + description: bus clock + + resets: + maxItems: 1 + description: bus reset + + interrupts: + maxItems: 1 + description: controller interrupt + + '#mbox-cells': + const: 1 + +required: + - compatible + - reg + - clocks + - resets + - interrupts + - '#mbox-cells' + +examples: + - | + #include <dt-bindings/clock/sun8i-h3-ccu.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/reset/sun8i-h3-ccu.h> + + msgbox: mailbox@1c17000 { + compatible = "allwinner,sun8i-h3-msgbox", + "allwinner,sun6i-a31-msgbox"; + reg = <0x01c17000 0x1000>; + clocks = <&ccu CLK_BUS_MSGBOX>; + resets = <&ccu RST_BUS_MSGBOX>; + interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>; + #mbox-cells = <1>; + }; + +...
Signature · 1 line
2.19.2
Re: [PATCH v3 03/15] dt-bindings: mailbox: Add a sunxi message box binding
Quoted 9 lines · Samuel Holland
This mailbox hardware is present in Allwinner sun8i, sun9i, and sun50i SoCs. Add a device tree binding for it.
Signed-off-by Samuel Holland <[email protected]>--- .../mailbox/allwinner,sunxi-msgbox.yaml | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/allwinner,sunxi-msgbox.yaml
Samuel Holland
maintainerPATCH v3 4/15 mailbox: sunxi-msgbox: Add a new mailbox driver
In reply to Samuel HollandAllwinner sun8i, sun9i, and sun50i SoCs contain a hardware message box used for communication between the ARM CPUs and the ARISC management coprocessor. The hardware contains 8 unidirectional 4-message FIFOs.
Add a driver for it, so it can be used for SCPI or other communication protocols.
--- drivers/mailbox/Kconfig | 11 ++ drivers/mailbox/Makefile | 2 + drivers/mailbox/sunxi-msgbox.c | 315 +++++++++++++++++++++++++++++++++ 3 files changed, 328 insertions(+) create mode 100644 drivers/mailbox/sunxi-msgbox.c
drivers/mailbox/Kconfig +11 -0
@@ -205,4 +205,15 @@ config MTK_CMDQ_MBOX mailbox driver. The CMDQ is used to help read/write registers with critical time limitation, such as updating display configuration during the vblank. + +config SUNXI_MSGBOX + tristate "Allwinner sunxi Message Box" + depends on ARCH_SUNXI || COMPILE_TEST + default ARCH_SUNXI + help + Mailbox implementation for the hardware message box present in + Allwinner sun8i, sun9i, and sun50i SoCs. The hardware message box is + used for communication between the application CPUs and the power + management coprocessor. + endif
drivers/mailbox/Makefile +2 -0
@@ -44,3 +44,5 @@ obj-$(CONFIG_TEGRA_HSP_MBOX) += tegra-hsp.o obj-$(CONFIG_STM32_IPCC) += stm32-ipcc.o obj-$(CONFIG_MTK_CMDQ_MBOX) += mtk-cmdq-mailbox.o + +obj-$(CONFIG_SUNXI_MSGBOX) += sunxi-msgbox.o
drivers/mailbox/sunxi-msgbox.c new file +315 -0
315 lines not on this page · raw message
Signature · 1 line
2.19.2
Samuel Holland
maintainerPATCH v3 5/15 ARM: dts: sunxi: a80: Add msgbox node
In reply to Samuel HollandThe A80 SoC contains a message box that can be used to send messages and interrupts back and forth between the ARM application CPUs and the ARISC coprocessor. Add a device tree node for it.
--- arch/arm/boot/dts/sun9i-a80.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm/boot/dts/sun9i-a80.dtsi +10 -0
@@ -283,6 +283,16 @@ }; }; + msgbox: mailbox@803000 { + compatible = "allwinner,sun9i-a80-msgbox", + "allwinner,sun6i-a31-msgbox"; + reg = <0x00803000 0x1000>; + clocks = <&ccu CLK_BUS_MSGBOX>; + resets = <&ccu RST_BUS_MSGBOX>; + interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>; + #mbox-cells = <1>; + }; + ehci0: usb@a00000 { compatible = "allwinner,sun9i-a80-ehci", "generic-ehci"; reg = <0x00a00000 0x100>;
Signature · 1 line
2.19.2
Samuel Holland
maintainerPATCH v3 6/15 ARM: dts: sunxi: a83t: Add msgbox node
In reply to Samuel HollandThe A83T SoC contains a message box that can be used to send messages and interrupts back and forth between the ARM application CPUs and the ARISC coprocessor. Add a device tree node for it.
--- arch/arm/boot/dts/sun8i-a83t.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm/boot/dts/sun8i-a83t.dtsi +10 -0
@@ -546,6 +546,16 @@ reg = <0x1c14000 0x400>; }; + msgbox: mailbox@1c17000 { + compatible = "allwinner,sun8i-a83t-msgbox", + "allwinner,sun6i-a31-msgbox"; + reg = <0x01c17000 0x1000>; + clocks = <&ccu CLK_BUS_MSGBOX>; + resets = <&ccu RST_BUS_MSGBOX>; + interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>; + #mbox-cells = <1>; + }; + usb_otg: usb@1c19000 { compatible = "allwinner,sun8i-a83t-musb", "allwinner,sun8i-a33-musb";
Signature · 1 line
2.19.2
Samuel Holland
maintainerPATCH v3 7/15 ARM: dts: sunxi: h3/h5: Add msgbox node
In reply to Samuel HollandThe H3 and H5 SoCs contain a message box that can be used to send messages and interrupts back and forth between the ARM application CPUs and the ARISC coprocessor. Add a device tree node for it.
--- arch/arm/boot/dts/sunxi-h3-h5.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm/boot/dts/sunxi-h3-h5.dtsi +10 -0
@@ -227,6 +227,16 @@ #size-cells = <0>; }; + msgbox: mailbox@1c17000 { + compatible = "allwinner,sun8i-h3-msgbox", + "allwinner,sun6i-a31-msgbox"; + reg = <0x01c17000 0x1000>; + clocks = <&ccu CLK_BUS_MSGBOX>; + resets = <&ccu RST_BUS_MSGBOX>; + interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>; + #mbox-cells = <2>; + }; + usb_otg: usb@1c19000 { compatible = "allwinner,sun8i-h3-musb"; reg = <0x01c19000 0x400>;
Signature · 1 line
2.19.2
Samuel Holland
maintainerRe: [PATCH v3 07/15] ARM: dts: sunxi: h3/h5: Add msgbox node
Quoted 15 lines · Samuel Holland
The H3 and H5 SoCs contain a message box that can be used to send messages and interrupts back and forth between the ARM application CPUs and the ARISC coprocessor. Add a device tree node for it.
Signed-off-by Samuel Holland <[email protected]>--- arch/arm/boot/dts/sunxi-h3-h5.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+)arch/arm/boot/dts/sunxi-h3-h5.dtsi +0
-0@@ -227,6 +227,16 @@ #size-cells = <0>;
arch/arm/boot/dts/sunxi-h3-h5.dtsi line 237
Quoted 10 lines
arch/arm/boot/dts/sunxi-h3-h5.dtsi +8
-0}; + msgbox: mailbox@1c17000 { + compatible = "allwinner,sun8i-h3-msgbox", + "allwinner,sun6i-a31-msgbox"; + reg = <0x01c17000 0x1000>; + clocks = <&ccu CLK_BUS_MSGBOX>; + resets = <&ccu RST_BUS_MSGBOX>; + interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>; + #mbox-cells = <2>;
This should be 1. And it was caught by the new DTB schema validation :)
Quoted 6 lines
arch/arm/boot/dts/sunxi-h3-h5.dtsi +2
-0+ }; + usb_otg: usb@1c19000 { compatible = "allwinner,sun8i-h3-musb"; reg = <0x01c19000 0x400>;
Samuel Holland
maintainerPATCH v3 8/15 arm64: dts: allwinner: a64: Add msgbox node
In reply to Samuel HollandThe A64 SoC contains a message box that can be used to send messages and interrupts back and forth between the ARM application CPUs and the ARISC coprocessor. Add a device tree node for it.
--- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +10 -0
@@ -447,6 +447,16 @@ reg = <0x1c14000 0x400>; }; + msgbox: mailbox@1c17000 { + compatible = "allwinner,sun50i-a64-msgbox", + "allwinner,sun6i-a31-msgbox"; + reg = <0x01c17000 0x1000>; + clocks = <&ccu CLK_BUS_MSGBOX>; + resets = <&ccu RST_BUS_MSGBOX>; + interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>; + #mbox-cells = <1>; + }; + usb_otg: usb@1c19000 { compatible = "allwinner,sun8i-a33-musb"; reg = <0x01c19000 0x0400>;
Signature · 1 line
2.19.2
Samuel Holland
maintainerPATCH v3 9/15 arm64: dts: allwinner: h6: Add msgbox node
In reply to Samuel HollandThe H6 SoC contains a message box that can be used to send messages and interrupts back and forth between the ARM application CPUs and the ARISC coprocessor. Add a device tree node for it.
--- arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +10 -0
@@ -189,6 +189,16 @@ #interrupt-cells = <3>; }; + msgbox: mailbox@3003000 { + compatible = "allwinner,sun50i-h6-msgbox", + "allwinner,sun6i-a31-msgbox"; + reg = <0x03003000 0x1000>; + clocks = <&ccu CLK_BUS_MSGBOX>; + resets = <&ccu RST_BUS_MSGBOX>; + interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>; + #mbox-cells = <1>; + }; + pio: pinctrl@300b000 { compatible = "allwinner,sun50i-h6-pinctrl"; reg = <0x0300b000 0x400>;
Signature · 1 line
2.19.2
Samuel Holland
maintainerPATCH v3 10/15 clk: sunxi-ng: sun8i: Avoid turning off unused PRCM gates
In reply to Samuel HollandHardware attached to AHB0/APB0 and controlled in the PRCM is designed to be used by firmware running on the ARISC core. However, some devices in this block (specifically the I2C, RSB, PIO, and CIR-RX) have native Linux drivers and are already in the device tree. In particular, the RSB and I2C buses may have sound chips and display bridges hanging off of them that cannot easily be driven from firmware.
To facilitate sharing this hardware block between Linux and system firmware, avoid turning off PRCM clock gates that are unreferenced in the device tree. We assume that firmware has already optimally configured these clocks before booting Linux.
--- drivers/clk/sunxi-ng/ccu-sun8i-r.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/clk/sunxi-ng/ccu-sun8i-r.c +9 -9
@@ -92,19 +92,19 @@ static struct ccu_div apb0_clk = { static SUNXI_CCU_M(a83t_apb0_clk, "apb0", "ahb0", 0x0c, 0, 2, 0); static SUNXI_CCU_GATE(apb0_pio_clk, "apb0-pio", "apb0", - 0x28, BIT(0), 0); + 0x28, BIT(0), CLK_IGNORE_UNUSED); static SUNXI_CCU_GATE(apb0_ir_clk, "apb0-ir", "apb0", - 0x28, BIT(1), 0); + 0x28, BIT(1), CLK_IGNORE_UNUSED); static SUNXI_CCU_GATE(apb0_timer_clk, "apb0-timer", "apb0", - 0x28, BIT(2), 0); + 0x28, BIT(2), CLK_IGNORE_UNUSED); static SUNXI_CCU_GATE(apb0_rsb_clk, "apb0-rsb", "apb0", - 0x28, BIT(3), 0); + 0x28, BIT(3), CLK_IGNORE_UNUSED); static SUNXI_CCU_GATE(apb0_uart_clk, "apb0-uart", "apb0", - 0x28, BIT(4), 0); + 0x28, BIT(4), CLK_IGNORE_UNUSED); static SUNXI_CCU_GATE(apb0_i2c_clk, "apb0-i2c", "apb0", - 0x28, BIT(6), 0); + 0x28, BIT(6), CLK_IGNORE_UNUSED); static SUNXI_CCU_GATE(apb0_twd_clk, "apb0-twd", "apb0", - 0x28, BIT(7), 0); + 0x28, BIT(7), CLK_IGNORE_UNUSED);static const char *const r_mod0_default_parents[] = {"osc32k" ,"osc24M" }; static SUNXI_CCU_MP_WITH_MUX_GATE(ir_clk, "ir",
@@ -113,7 +113,7 @@ static SUNXI_CCU_MP_WITH_MUX_GATE(ir_clk, "ir",16 ,2 ,/* P */ 24 ,2 ,/* mux */ BIT (31 ),/* gate */ - 0); + CLK_IGNORE_UNUSED);static const char *const a83t_r_mod0_parents[] = {"osc16M" ,"osc24M" };static const struct ccu_mux_fixed_prediv a83t_ir_predivs[] = {
@@ -138,7 +138,7 @@ static struct ccu_mp a83t_ir_clk = { .hw.init = CLK_HW_INIT_PARENTS("ir", a83t_r_mod0_parents, &ccu_mp_ops, - 0), + CLK_IGNORE_UNUSED), }, };
Signature · 1 line
2.19.2
Samuel Holland
maintainerPATCH v3 11/15 dt-bindings: Add a binding for a mailbox-backed interrupt controller
In reply to Samuel HollandThis is a somewhat generic binding for an interrupt controller/forwarder implemented in firmware and communicated with using a mailbox.
--- .../interrupt-controller/mbox-intc.txt | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/mbox-intc.txt
Documentation/devicetree/bindings/interrupt-controller/mbox-intc.txt new file +33 -0
@@ -0,0 +1,33 @@ +Mailbox-backed Interrupt Controller +=================================== + +This binding represents an interrupt controller implemented in firmware, +that uses a mailbox channel to signal and acknowledge interrupts. + +Device Node: +============ + +Required properties: +-------------------- +- compatible: Must be one of the following strings: + - allwinner,sunxi-msgbox-intc +- interrupt-controller: Signifies that this node is an interrupt controller. +- #interrupt-cells: Must be 1. +- mboxes: phandle for the mailbox controller and channel + specifier. If the mailbox controller has unidirectional + channels, two entries are required (see below). +- mbox-names: Only required for unidirectional mailbox channels. In + that case, it must contain the strings "tx" and "rx" + (where "tx" and "rx" are from Linux's perspective, not + the direction the interrupts are traveling). + +Example: +-------- + + msgbox_intc: interrupt-controller { + compatible = "allwinner,sunxi-msgbox-intc"; + interrupt-controller; + #interrupt-cells = <1>; + mboxes = <&msgbox 6>, <&msgbox 7>; + mbox-names = "tx", "rx"; + };
Signature · 1 line
2.19.2
Rob Herring
maintainerRe: [PATCH v3 11/15] [NOT FOR MERGE] dt-bindings: Add a binding for a mailbox-backed interrupt controller
Quoted 15 lines · Samuel Holland
This is a somewhat generic binding for an interrupt controller/forwarder implemented in firmware and communicated with using a mailbox.
Signed-off-by Samuel Holland <[email protected]>--- .../interrupt-controller/mbox-intc.txt | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/mbox-intc.txtDocumentation/devicetree/bindings/interrupt-controller/mbox-intc.txt new file +0
-0
Documentation/devicetree/bindings/interrupt-controller/mbox-intc.txt line 2
Quoted 2 lines
Documentation/devicetree/bindings/interrupt-controller/mbox-intc.txt new file +2
-0@@ -0,0 +1,33 @@ +Mailbox-backed Interrupt Controller +===================================
Probably never really going to be generic as every mailbox protocol is different.
Documentation/devicetree/bindings/interrupt-controller/mbox-intc.txt line 15
Quoted 13 lines
Documentation/devicetree/bindings/interrupt-controller/mbox-intc.txt new file +13
-0+ +This binding represents an interrupt controller implemented in firmware, +that uses a mailbox channel to signal and acknowledge interrupts. + +Device Node: +============ + +Required properties: +-------------------- +- compatible: Must be one of the following strings: + - allwinner,sunxi-msgbox-intc +- interrupt-controller: Signifies that this node is an interrupt controller. +- #interrupt-cells: Must be 1.
No edge/level control?
Documentation/devicetree/bindings/interrupt-controller/mbox-intc.txt line 21
Quoted 6 lines
Documentation/devicetree/bindings/interrupt-controller/mbox-intc.txt new file +6
-0+- mboxes: phandle for the mailbox controller and channel + specifier. If the mailbox controller has unidirectional + channels, two entries are required (see below). +- mbox-names: Only required for unidirectional mailbox channels. In + that case, it must contain the strings "tx" and "rx" + (where "tx" and "rx" are from Linux's perspective, not
/Linux/the OS/
Quoted 15 lines
Documentation/devicetree/bindings/interrupt-controller/mbox-intc.txt new file +12
-0+ the direction the interrupts are traveling). + +Example: +-------- + + msgbox_intc: interrupt-controller { + compatible = "allwinner,sunxi-msgbox-intc"; + interrupt-controller; + #interrupt-cells = <1>; + mboxes = <&msgbox 6>, <&msgbox 7>; + mbox-names = "tx", "rx"; + };Signature · 1 line
2.19.2
Samuel Holland
maintainerPATCH v3 12/15 irqchip/mbox: Introduce a mailbox-backed irqchip driver
In reply to Samuel HollandThis driver implements a simple interrupt controller using message passing over a mailbox channel. The intention is for the other end of the channel to be implemented in firmware. This allows filtering and forwarding interrupts from one processor to another.
--- drivers/irqchip/Kconfig | 9 ++ drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-mbox.c | 199 +++++++++++++++++++++++++++++++++++++ 3 files changed, 209 insertions(+) create mode 100644 drivers/irqchip/irq-mbox.c
drivers/irqchip/Kconfig +9 -0
@@ -406,6 +406,15 @@ config IMX_IRQSTEER help Support for the i.MX IRQSTEER interrupt multiplexer/remapper. +config IRQ_MBOX + tristate "Simple mailbox-backed interrupt controller" + depends on MAILBOX + select IRQ_DOMAIN + help + Support for interrupt controllers attached via a mailbox channel. + This allows a coprocessor to inject interrupts via a simple + message-based protocol. + endmenu config SIFIVE_PLIC
drivers/irqchip/Makefile +1 -0
@@ -94,3 +94,4 @@ obj-$(CONFIG_CSKY_APB_INTC) += irq-csky-apb-intc.o obj-$(CONFIG_SIFIVE_PLIC) += irq-sifive-plic.o obj-$(CONFIG_IMX_IRQSTEER) += irq-imx-irqsteer.o obj-$(CONFIG_MADERA_IRQ) += irq-madera.o +obj-$(CONFIG_IRQ_MBOX) += irq-mbox.o
drivers/irqchip/irq-mbox.c new file +199 -0
199 lines not on this page · raw message
Signature · 1 line
2.19.2
Samuel Holland
maintainerPATCH v3 13/15 arm64: dts: allwinner: a64: Add interrupt controller node
In reply to Samuel HollandIn order to give firmware full access to r_intc, Linux needs to avoid using it in the device tree. Most IRQ lines attached to r_intc are also attached to the GIC. Unfortunately, the NMI is not. For it to be used in Linux, we have to forward it in firmware over the mailbox.
Add a node representing this virtual interrupt controller.
--- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +8 -0
@@ -128,6 +128,14 @@ status = "disabled"; }; + msgbox_intc: interrupt-controller { + compatible = "allwinner,sunxi-msgbox-intc"; + interrupt-controller; + #interrupt-cells = <1>; + mboxes = <&msgbox 6>, <&msgbox 7>; + mbox-names = "tx", "rx"; + }; + osc24M: osc24M_clk { #clock-cells = <0>; compatible = "fixed-clock";
Signature · 1 line
2.19.2
Samuel Holland
maintainerPATCH v3 14/15 arm64: dts: allwinner: a64: Convert DTS to use msgbox_intc
In reply to Samuel HollandNow that there is an alternate way for Linux to receive NMIs from the PMIC, replace references to r_intc with references to the new interrupt controller.
--- arch/arm64/boot/dts/allwinner/sun50i-a64-amarula-relic.dts | 4 ++-- arch/arm64/boot/dts/allwinner/sun50i-a64-bananapi-m64.dts | 4 ++-- arch/arm64/boot/dts/allwinner/sun50i-a64-nanopi-a64.dts | 4 ++-- arch/arm64/boot/dts/allwinner/sun50i-a64-olinuxino.dts | 4 ++-- arch/arm64/boot/dts/allwinner/sun50i-a64-orangepi-win.dts | 4 ++-- arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts | 4 ++-- arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts | 4 ++-- arch/arm64/boot/dts/allwinner/sun50i-a64-sopine.dtsi | 4 ++-- arch/arm64/boot/dts/allwinner/sun50i-a64-teres-i.dts | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-)
arch/arm64/boot/dts/allwinner/sun50i-a64-amarula-relic.dts +2 -2
@@ -78,8 +78,8 @@ axp803: pmic@3a3 { compatible = "x-powers,axp803"; reg = <0x3a3>; - interrupt-parent = <&r_intc>; - interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + interrupt-parent = <&msgbox_intc>; + interrupts = <0>; x-powers,drive-vbus-en; /* set N_VBUSEN as output pin */ }; };
arch/arm64/boot/dts/allwinner/sun50i-a64-bananapi-m64.dts +2 -2
@@ -214,8 +214,8 @@ axp803: pmic@3a3 { compatible = "x-powers,axp803"; reg = <0x3a3>; - interrupt-parent = <&r_intc>; - interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + interrupt-parent = <&msgbox_intc>; + interrupts = <0>; x-powers,drive-vbus-en; /* set N_VBUSEN as output pin */ }; };
arch/arm64/boot/dts/allwinner/sun50i-a64-nanopi-a64.dts +2 -2
@@ -179,8 +179,8 @@ axp803: pmic@3a3 { compatible = "x-powers,axp803"; reg = <0x3a3>; - interrupt-parent = <&r_intc>; - interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + interrupt-parent = <&msgbox_intc>; + interrupts = <0>; }; };
arch/arm64/boot/dts/allwinner/sun50i-a64-olinuxino.dts +2 -2
@@ -169,8 +169,8 @@ axp803: pmic@3a3 { compatible = "x-powers,axp803"; reg = <0x3a3>; - interrupt-parent = <&r_intc>; - interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + interrupt-parent = <&msgbox_intc>; + interrupts = <0>; x-powers,drive-vbus-en; /* set N_VBUSEN as output pin */ }; };
arch/arm64/boot/dts/allwinner/sun50i-a64-orangepi-win.dts +2 -2
@@ -186,8 +186,8 @@ axp803: pmic@3a3 { compatible = "x-powers,axp803"; reg = <0x3a3>; - interrupt-parent = <&r_intc>; - interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + interrupt-parent = <&msgbox_intc>; + interrupts = <0>; x-powers,drive-vbus-en; /* set N_VBUSEN as output pin */ }; };
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +2 -2
@@ -162,8 +162,8 @@ axp803: pmic@3a3 { compatible = "x-powers,axp803"; reg = <0x3a3>; - interrupt-parent = <&r_intc>; - interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + interrupt-parent = <&msgbox_intc>; + interrupts = <0>; }; };
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +2 -2
@@ -169,8 +169,8 @@ axp803: pmic@3a3 { compatible = "x-powers,axp803"; reg = <0x3a3>; - interrupt-parent = <&r_intc>; - interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + interrupt-parent = <&msgbox_intc>; + interrupts = <0>; }; };
arch/arm64/boot/dts/allwinner/sun50i-a64-sopine.dtsi +2 -2
@@ -68,8 +68,8 @@ axp803: pmic@3a3 { compatible = "x-powers,axp803"; reg = <0x3a3>; - interrupt-parent = <&r_intc>; - interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + interrupt-parent = <&msgbox_intc>; + interrupts = <0>; }; };
arch/arm64/boot/dts/allwinner/sun50i-a64-teres-i.dts +2 -2
@@ -137,8 +137,8 @@ axp803: pmic@3a3 { compatible = "x-powers,axp803"; reg = <0x3a3>; - interrupt-parent = <&r_intc>; - interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + interrupt-parent = <&msgbox_intc>; + interrupts = <0>; wakeup-source; }; };
Signature · 1 line
2.19.2
Samuel Holland
maintainerPATCH v3 15/15 arm64: dts: allwinner: a64: Remove unused r_intc
In reply to Samuel HollandNow that r_intc is no longer used directly by Linux, it can be removed from the SoC device tree.
--- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 9 --------- 1 file changed, 9 deletions(-)
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +0 -9
@@ -989,15 +989,6 @@ #clock-cells = <1>; }; - r_intc: interrupt-controller@1f00c00 { - compatible = "allwinner,sun50i-a64-r-intc", - "allwinner,sun6i-a31-r-intc"; - interrupt-controller; - #interrupt-cells = <2>; - reg = <0x01f00c00 0x400>; - interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>; - }; - r_ccu: clock@1f01400 { compatible = "allwinner,sun50i-a64-r-ccu"; reg = <0x01f01400 0x100>;
Signature · 1 line
2.19.2