From patchwork Sat Mar 2 04:29:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 10836413 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9B1F11669 for ; Sat, 2 Mar 2019 04:31:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8511B2D3B9 for ; Sat, 2 Mar 2019 04:31:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 795202D402; Sat, 2 Mar 2019 04:31:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0626F2D3EA for ; Sat, 2 Mar 2019 04:31:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=SREFgtobSyaBybPMa85Dr/MbdRmfM0p1CHC3ynxGSh4=; b=WOXmMccqOVjUIX KfMlPudSN2uE9YtsK7TZcrAfUivazTZQjMTii9tofFE8HPwQcUDBOOgtBC+1z/q4k4/wyONF1BP0M HYNfjCGrr2xwR0JowTSIMRQa4aZ7HlGizVmHk2fs8oC6+II95Vzrx2ckZpGQ5EVf6lXacV/ANUnuz K/rSIBjscQYcrRz5KxNXJwPLW2uwmPhszOoiArGF4QmQT3yAvPMxHD/DRuAYZbOMIQTLPzb3eHRH2 jJPsLbSHQrMKwC5LsL647ETltLxmi6/LxJ2j5YDt8h7LlBfFi6QRRGn2PycSUftfoYReO7iFl0XK0 zISvU1CinqmzbEk2QAeA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzwIu-0001s8-Sg; Sat, 02 Mar 2019 04:31:16 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzwHg-0007Ua-Qq for linux-arm-kernel@lists.infradead.org; Sat, 02 Mar 2019 04:30:04 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 0D5BF22102; Fri, 1 Mar 2019 23:29:54 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 01 Mar 2019 23:29:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm2; bh=6wxraRm1tf0iqprrxkQWCK7za3 ofjuzsdLJXXH6XaDU=; b=hpHyY9IVi8062UihAai0ChkVdK18aEOvJ1vprNoAa1 c6ITqZU18+0XG/Os1eZalls0CriamtSZ1cYtp6o3fSCfti4wRm291FwP7VEcI+Qh RjMTz/9PfAp/0TumqzP7lB1Dcy0dDiDvP7xkfLQUgyG4LoR4q35GsRBqMCmqjhl+ G9YaDu68yKnayTrJ037LGN7wbUsaB+UDyjRqvBxNlv3JNGi76i1u6f/s3xLEkxym ERyuAYaQn3S9NeyKZjSLai0JgaF2ggGDtL/5QfguEJq0VI1LvT/+cOsbxN/DlMzP DnOt3YTLV16lY7B0AjYrcYWEjTkUN/4bR2tPj1MSsgGA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=6wxraRm1tf0iqprrx kQWCK7za3ofjuzsdLJXXH6XaDU=; b=UziwOdgY/0/FoXCTrAzf6i5BvmeeYNdku pB81qxAba0sz+rP2p1SYBtyqotmXkj910Ga2qh46uvxPksXGFwKKBn1Xtn4nOX4c cVS+GOilW9mCW67L0Z4eAEOVWjDVnEti4oZ+aO3w0iy7631L193SkygkiJg9IdS3 Jque0Zk7v9x7XYe0ig8xBnIy00BGi1QXAjLVACjQXOINr+m9U5ekrRin1USNyqVH FGMTINmVyc/NLqx2s21kJAvM02+TvEclCYZrXSWTwAcRpY+w6Z+OCQkuK9T9l7dy 3DqKCxUbBS2PgAKSwwHO1YvWv5VX7qqYInQAVrNlwz7Ssf96Upy1A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrvdeigdejtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepufgrmhhuvghlucfj ohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecuffhomhgrih hnpehgihhthhhusgdrtghomhenucfkphepjedtrddufeehrddugeekrdduhedunecurfgr rhgrmhepmhgrihhlfhhrohhmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgnecuve hluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from titanium.stl.sholland.net (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id 0F9A310310; Fri, 1 Mar 2019 23:29:52 -0500 (EST) From: Samuel Holland To: Maxime Ripard , Chen-Yu Tsai , Jassi Brar , Michael Turquette , Stephen Boyd , Rob Herring , Mark Rutland Subject: [PATCH v3 00/15] Allwinner sunxi message box support Date: Fri, 1 Mar 2019 22:29:36 -0600 Message-Id: <20190302042951.53671-1-samuel@sholland.org> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190301_203001_006006_5108E1C5 X-CRM114-Status: GOOD ( 17.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Samuel Holland , linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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