From patchwork Mon Sep 16 09:44:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 11146643 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E41B14ED for ; Mon, 16 Sep 2019 09:44:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4BD95206C2 for ; Mon, 16 Sep 2019 09:44:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="RAFYGq1d"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="HOFh4GCZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BD95206C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:In-Reply-To:References: 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: List-Owner; bh=lnlvVa2eTt6Bn0GUUtoSuqFtSPMxHSnlAOnU7hGXPT4=; b=RAFYGq1dgL0wn4 DWqmafd9G8ceuGGgFzkOVAuXHUsApVbHUU48uNJgc2OS4FJe5+BExmoGekJA1mPRYhZjaKSz/LO/D vfomaxyXNWGPuIV1vUrK/auehTm1h4IKhcqVTaXFICOoRJb/iqmJQSAjUxVdGz6JiiEdhl+0VnWjD KJ2hogYIqyMJ1u9WWy0tm+WUje3uxAZ72l98qehru0zJ7Cp9utfq8gHSE7w5kTQ0zaaN6KFbSIiDP 1E/YXeczbDsj88B5Av1ObnDQlOr1jqEP+or2Uar0t5SXv2qxK+cAfmGeBcP+2lKLfC8tiMaMdVj3B kOp6J3Y/7OjMRdZDAkdQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1i9nZ3-0003Fn-MM; Mon, 16 Sep 2019 09:44:57 +0000 Received: from mail-eopbgr10049.outbound.protection.outlook.com ([40.107.1.49] helo=EUR02-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1i9nYn-00032L-7V for linux-arm-kernel@lists.infradead.org; Mon, 16 Sep 2019 09:44:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QrMgPtMpG/hWzDYZygCaqyYLBcZdci7wPeHaVR0hxZ5t+nQnqSI6T88Z1Y/mzmJoeVcQ8gYnUoHzn0Ys+R3cOT+2U+6rjrmyPhacKT+AW5UWan+/Bn9KE0QNPJ7GapDdgWjsv+3FX/6uop+PrIHEJyJ5vnsXnXgeEmTvHTaoCsNB6APHl7fW7kOBC2EhyVcfzfDy9+6agYTqby0+uIaGe4gx+elrZsUfPATOBE5g9bVaqKV5RLcC2+3D+6mboYtAGc7MliOjRQREKgflxaT4wC9hvlq72CKgyo21hooamraFeNB4bXsWG5SPJeGgPtsVsqIXluoUY5id2vkQ1aTlwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fUuVzbJ7bf1qJ9ZJupqO/l65iQ3g97WS2BhWetOqOL8=; b=cFQdr5knmlXDaFqZsMSXpTKYKp5FmJw7dW03hX+fZ91XDkGuQemgnPEvmcMOQ2MqVx1Iwvf0gkJRKiMummqs8UMa39PVgMX7m0JaMet6sxbtpGzLAcA2RkqUiHbZ5TSmGZvx0Pk5BVwqkelzQwBSycbdmqT5Oh4fXETlegAz5/9kpLOBPwTbhueZ6ziEIey1IEc/aszsqXB/+OSa3v8w/SFYvbXQLMyz+qqPKz/fq5qm938N1DsDOeb3gzReImZAYd1uK2Tllo7LBmqmBsn7q8cFPF0kvqtHnTyFX90qCSbyLmAZrwQwpjaIHrMOYWHQLmGzWAbJQUoXK2wpQAL6mQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fUuVzbJ7bf1qJ9ZJupqO/l65iQ3g97WS2BhWetOqOL8=; b=HOFh4GCZaNDGTJpaOMypZEKm6iOk4qrNJrINqH6gSSa3nX1Y8L9rzlUb0svFfR5wxCdp1nFaeWYCJfaTi3Esw3uC0SUXFKlTnKtrgl7B8b978Q64b6xsPRps1jhC3e2y8+iC3VyUG2ajeyoR0jfulkSOCR+cfqQ173IIEozkY14= Received: from AM0PR04MB4481.eurprd04.prod.outlook.com (52.135.147.15) by AM0PR04MB4674.eurprd04.prod.outlook.com (52.135.149.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.13; Mon, 16 Sep 2019 09:44:37 +0000 Received: from AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::6ca2:ec08:2b37:8ab8]) by AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::6ca2:ec08:2b37:8ab8%6]) with mapi id 15.20.2263.023; Mon, 16 Sep 2019 09:44:37 +0000 From: Peng Fan To: "robh+dt@kernel.org" , "mark.rutland@arm.com" , "jassisinghbrar@gmail.com" , "sudeep.holla@arm.com" , "andre.przywara@arm.com" , "f.fainelli@gmail.com" Subject: [PATCH V6 1/2] dt-bindings: mailbox: add binding doc for the ARM SMC/HVC mailbox Thread-Topic: [PATCH V6 1/2] dt-bindings: mailbox: add binding doc for the ARM SMC/HVC mailbox Thread-Index: AQHVbHNaBQCH9BWPL0mqFSSgcphDeg== Date: Mon, 16 Sep 2019 09:44:37 +0000 Message-ID: <1568626884-5189-2-git-send-email-peng.fan@nxp.com> References: <1568626884-5189-1-git-send-email-peng.fan@nxp.com> In-Reply-To: <1568626884-5189-1-git-send-email-peng.fan@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: HK0PR01CA0054.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::18) To AM0PR04MB4481.eurprd04.prod.outlook.com (2603:10a6:208:70::15) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8b08cb44-9ab6-42d5-b561-08d73a8a7d2f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:AM0PR04MB4674; x-ms-traffictypediagnostic: AM0PR04MB4674:|AM0PR04MB4674: x-ms-exchange-purlcount: 2 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 0162ACCC24 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(396003)(376002)(346002)(39860400002)(189003)(199004)(50226002)(81156014)(44832011)(8676002)(8936002)(81166006)(66946007)(14454004)(52116002)(99286004)(15650500001)(2420400007)(7110500001)(6436002)(316002)(2616005)(53936002)(486006)(305945005)(7736002)(86362001)(476003)(76176011)(66066001)(36756003)(2201001)(54906003)(6486002)(446003)(11346002)(2906002)(66556008)(5660300002)(6512007)(110136005)(53376002)(386003)(6506007)(4326008)(71200400001)(26005)(71190400001)(102836004)(966005)(6116002)(66476007)(3846002)(186003)(64756008)(256004)(66446008)(6306002)(2501003)(478600001)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB4674; H:AM0PR04MB4481.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: P0yr8gN/7qVEOJLa7L/P93lXyuOF86xeufiZE+a4zHW6uacqR+rTf8ZYXUHW52EDs0xLyioZpy10XA2+CcuFJdJqFlt5YAMaLk7I6r8a+7qWDyhTbX7NjNvbXyOkCE5MyqIOcKKMpOJ6iKyNeznLretlvRrhNj1rTCkIwFe7UZGworoP+L5ZqLOm2a6hZxzqZGlBk58Ro6YVbxDqj3NlLBwApGRGJEsUsCV1YqGr5q7UT9qYA215TwRHEUe3/cGZI+QdobDVmhgV4JcpgzlCbfmc1ouRwq9EzhJwMnRM9uzjAjsS7JlmV+0QBRCZenUFMl5U1v4IIZLoRkb+ACjXcqAnRXRkBzrnHktG58p7MMxA/AD+EyNPHSQQtaKjELUS/zctLj6+KrMdBDVseR+oFrupNqx/+N2kz4W4Zuv1qRk= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b08cb44-9ab6-42d5-b561-08d73a8a7d2f X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Sep 2019 09:44:37.7940 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: g32uLYARLfEaadu6+JimH9zDeP8h/ryoqMSkjHTO365+Oqmt7VmwlobNy4rBN7jW/FR8fDI3TWvtWpzJwvbMlQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4674 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190916_024441_273727_2ABC1636 X-CRM114-Status: GOOD ( 17.39 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [40.107.1.49 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "devicetree@vger.kernel.org" , Peng Fan , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , dl-linux-imx Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Peng Fan The ARM SMC/HVC mailbox binding describes a firmware interface to trigger actions in software layers running in the EL2 or EL3 exception levels. The term "ARM" here relates to the SMC instruction as part of the ARM instruction set, not as a standard endorsed by ARM Ltd. Signed-off-by: Peng Fan --- .../devicetree/bindings/mailbox/arm-smc.yaml | 96 ++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/arm-smc.yaml diff --git a/Documentation/devicetree/bindings/mailbox/arm-smc.yaml b/Documentation/devicetree/bindings/mailbox/arm-smc.yaml new file mode 100644 index 000000000000..bf01bec035fc --- /dev/null +++ b/Documentation/devicetree/bindings/mailbox/arm-smc.yaml @@ -0,0 +1,96 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mailbox/arm-smc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ARM SMC Mailbox Interface + +maintainers: + - Peng Fan + +description: | + This mailbox uses the ARM smc (secure monitor call) and hvc (hypervisor + call) instruction to trigger a mailbox-connected activity in firmware, + executing on the very same core as the caller. The value of r0/w0/x0 + the firmware returns after the smc call is delivered as a received + message to the mailbox framework, so synchronous communication can be + established. The exact meaning of the action the mailbox triggers as + well as the return value is defined by their users and is not subject + to this binding. + + One use case of this mailbox is the SCMI interface, which uses shared + memory to transfer commands and parameters, and a mailbox to trigger a + function call. This allows SoCs without a separate management processor + (or when such a processor is not available or used) to use this + standardized interface anyway. + + This binding describes no hardware, but establishes a firmware interface. + Upon receiving an SMC using one of the described SMC function identifiers, + the firmware is expected to trigger some mailbox connected functionality. + The communication follows the ARM SMC calling convention. + Firmware expects an SMC function identifier in r0 or w0. The supported + identifiers are passed from consumers, or listed in the the arm,func-ids + properties as described below. The firmware can return one value in + the first SMC result register, it is expected to be an error value, + which shall be propagated to the mailbox client. + + Any core which supports the SMC or HVC instruction can be used, as long + as a firmware component running in EL3 or EL2 is handling these calls. + +properties: + compatible: + oneOf: + - description: + For implementations using ARM SMC instruction. + const: arm,smc-mbox + + - description: + For implementations using ARM HVC instruction. + const: arm,hvc-mbox + + "#mbox-cells": + const: 1 + + arm,func-id: + description: | + An 32-bit value specifying the function ID used by the mailbox. + The function ID follow the ARM SMC calling convention standard [1]. + $ref: /schemas/types.yaml#/definitions/uint32 + +required: + - compatible + - "#mbox-cells" + +examples: + - | + sram@93f000 { + compatible = "mmio-sram"; + reg = <0x0 0x93f000 0x0 0x1000>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x93f000 0x1000>; + + cpu_scp_lpri: scp-shmem@0 { + compatible = "arm,scmi-shmem"; + reg = <0x0 0x200>; + }; + }; + + smc_tx_mbox: tx_mbox { + #mbox-cells = <1>; + compatible = "arm,smc-mbox"; + /* optional */ + arm,func-id = <0xc20000fe>; + }; + + firmware { + scmi { + compatible = "arm,scmi"; + mboxes = <&smc_tx_mbox 0>; + mbox-names = "tx"; + shmem = <&cpu_scp_lpri>; + }; + }; + +... From patchwork Mon Sep 16 09:44:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 11146645 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7B181747 for ; Mon, 16 Sep 2019 09:45:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 82BF7206C2 for ; Mon, 16 Sep 2019 09:45:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kAyy7oUh"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="XKlvryg6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82BF7206C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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:In-Reply-To:References: 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: List-Owner; bh=RGIK3Dd39P/R/7l2hHmtK1nHI+Vp3a+mQzXiqUV3QYg=; b=kAyy7oUhrQfV7W CYjBymnrq8PZX2aeTouNhzTeDviKvbZOMpYRCctH56TwI33wllJ5xctINLBpGI2d/wy9O/kgvQYnB jKBwc2dDXcMiu0lJF3JBFn4UcwdtbtZCP0vTdaZHacR9UcLIwPURQPPFIAZPOD2EygJ7SQfAOoG1J pDYfkrb5Gj0UFW4qG8hZa7jKblbKZrsxIQNs5BWMpccXP8X5mFf+evG+zDFr6j69i0GQlx0E8fqL3 CbCIJ5oh+Y8zPXvCKz6Ml3E6RnDD1we1D4WZgAYPq4yFpw/21oXE2LkYS6ndSPAkv5G2cqMhZn9Vj 0cpqXfgdXdm2phqpxuxQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1i9nZN-0004ff-6B; Mon, 16 Sep 2019 09:45:17 +0000 Received: from mail-eopbgr10049.outbound.protection.outlook.com ([40.107.1.49] helo=EUR02-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1i9nYp-00032L-Am for linux-arm-kernel@lists.infradead.org; Mon, 16 Sep 2019 09:44:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Be3MTed1PRJzwcCt1hGDgWf0rBFEdn01ovY5tzHsyDtY8q1NoG192wWOCZTKEjiB6jwMXyyhHMHRD+PXScyxG+yZF0OTWDkEMCnjSfMIrG8wrH/Phg9bJGrs5X0OxK2HINWLhc1HdcC11zdX9golGyUz8oceXF4AN6OLsiPRYkEGC9xIbQII28a0+t25XvNC933c2XgDCOvxUTbrvwPECFsBtFowc9ICr/1WqPSW+fhASICdv6KQBQAQaRFOqq8vcIYEMY8b/vCjExYAZD7qvyNUCQXwawW4FKznTBrQvOWB3dbGloKq65UgsbpDIiH6eDmmslZqGKirjBdfOfiwBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7FJTyOwjd9hE2TfgR7a2Fk5cGji2TGsc+fCxqaCZJ4Q=; b=nk48If9273e3brwLwWDKDPTNroYTscPyYeeKn6oUkfk7zCf/Vc9oDN5CRPW98MSSpRm83ipqYIRCLXDlIY9Bokh6OBgitVqhEJ4jRdxeZ6gFW+0mFngOIqCMfq/I8OxEvyecL/FlZbCXD2ppkb7gwHCb/LbBDbvn7YFfoeb1TQI5zfFpAuWuHups3X3Od/wplWhTxpx//48xeTbhwJQPTxq0hP0PwDt8IZdlerxjaImpDZleoeTCPBWHryxbvs6vTHgbj7743HaGwl/bD+3UjJEGHm+s6Gpq9USxNKSgUZzjetlPj2dJhHu+XhXQgzp+K3HSXGTVEuZ8VTlCUVolEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7FJTyOwjd9hE2TfgR7a2Fk5cGji2TGsc+fCxqaCZJ4Q=; b=XKlvryg6LSth4xlEoY+40KrkS+HuqPrr+qx4ZbndmbNcg+RgtDXqWnQxGy8tjDBV3ttpmkdvlGLQOBaYrm9t40i4Rf4u+Wz18n6qPigo97DBtxXTC33UDON8eKWm1EN6Hwo6Yln4XX6GGedds+GoXpJG04gacvj36Mj7so9FcAE= Received: from AM0PR04MB4481.eurprd04.prod.outlook.com (52.135.147.15) by AM0PR04MB4674.eurprd04.prod.outlook.com (52.135.149.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.13; Mon, 16 Sep 2019 09:44:41 +0000 Received: from AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::6ca2:ec08:2b37:8ab8]) by AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::6ca2:ec08:2b37:8ab8%6]) with mapi id 15.20.2263.023; Mon, 16 Sep 2019 09:44:41 +0000 From: Peng Fan To: "robh+dt@kernel.org" , "mark.rutland@arm.com" , "jassisinghbrar@gmail.com" , "sudeep.holla@arm.com" , "andre.przywara@arm.com" , "f.fainelli@gmail.com" Subject: [PATCH V6 2/2] mailbox: introduce ARM SMC based mailbox Thread-Topic: [PATCH V6 2/2] mailbox: introduce ARM SMC based mailbox Thread-Index: AQHVbHNdulW1qSzh8kulKbzCOfhGfw== Date: Mon, 16 Sep 2019 09:44:41 +0000 Message-ID: <1568626884-5189-3-git-send-email-peng.fan@nxp.com> References: <1568626884-5189-1-git-send-email-peng.fan@nxp.com> In-Reply-To: <1568626884-5189-1-git-send-email-peng.fan@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: HK0PR01CA0054.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::18) To AM0PR04MB4481.eurprd04.prod.outlook.com (2603:10a6:208:70::15) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6808022f-1368-447c-2c37-08d73a8a7f6e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:AM0PR04MB4674; x-ms-traffictypediagnostic: AM0PR04MB4674:|AM0PR04MB4674: x-ms-exchange-purlcount: 1 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 0162ACCC24 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(396003)(376002)(346002)(39860400002)(189003)(199004)(50226002)(81156014)(44832011)(8676002)(8936002)(81166006)(66946007)(14454004)(52116002)(99286004)(15650500001)(6436002)(316002)(2616005)(53936002)(486006)(305945005)(7736002)(86362001)(476003)(76176011)(66066001)(36756003)(2201001)(54906003)(6486002)(446003)(11346002)(2906002)(66556008)(5660300002)(6512007)(110136005)(386003)(6506007)(4326008)(71200400001)(26005)(71190400001)(102836004)(966005)(6116002)(66476007)(3846002)(186003)(64756008)(256004)(66446008)(6306002)(2501003)(478600001)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB4674; H:AM0PR04MB4481.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: jMkY6u3N+UlUN4IafInkDz0ka+LVmlMaV5uFqntfo+ZEO/bQ9SB3d1vt3mL0epia2/87XEyPI6QQLmLZwpL91YFY1tkuaguP/ArB1FilfAVmlZzgBkDtTusFBWf8utME6+HZfjN1uU7waP1uYq0CPtJLm5ZUlbEYBMWCJfF2Lxr6Zwlk+Mo0BKDHvDCO0Ed98l21/dhpPheAQv5xVMkXDUgmIW2tmlXurUEyvB9AQfmRwWflUqn+wUzar4bfOJ+pOTfs8SGNA/WQ6CVT/EF5Z+45Jc4JwAt0FxOwAkIl7Fye5z6LCc1o+PSljKvNX0IsrYGBNWHNpe+oZmyZ+LFe+K/NfQ6RUdv4wwICDCAIkQrfqctCea8JzCgzHLMP9/cOTdWDs0wskvG2+xcj7jVp8fZ3fQgzttiqVcctjwhl0RU= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6808022f-1368-447c-2c37-08d73a8a7f6e X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Sep 2019 09:44:41.6247 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: BnqeDvxBx+XmDtDSAwPTnfT0JV44MgCYLrr/aaAAAh8S6SDh4iVlQp3mw/ENFwssB9x6gXYuOfegzMLbMue9vg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4674 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190916_024443_556425_E0DF8FB3 X-CRM114-Status: GOOD ( 18.06 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [40.107.1.49 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "devicetree@vger.kernel.org" , Peng Fan , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , dl-linux-imx Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Peng Fan This mailbox driver implements a mailbox which signals transmitted data via an ARM smc (secure monitor call) instruction. The mailbox receiver is implemented in firmware and can synchronously return data when it returns execution to the non-secure world again. An asynchronous receive path is not implemented. This allows the usage of a mailbox to trigger firmware actions on SoCs which either don't have a separate management processor or on which such a core is not available. A user of this mailbox could be the SCP interface. Modified from Andre Przywara's v2 patch https://lore.kernel.org/patchwork/patch/812999/ Cc: Andre Przywara Signed-off-by: Peng Fan --- drivers/mailbox/Kconfig | 7 ++ drivers/mailbox/Makefile | 2 + drivers/mailbox/arm-smc-mailbox.c | 167 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 176 insertions(+) create mode 100644 drivers/mailbox/arm-smc-mailbox.c diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index ab4eb750bbdd..7707ee26251a 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -16,6 +16,13 @@ config ARM_MHU The controller has 3 mailbox channels, the last of which can be used in Secure mode only. +config ARM_SMC_MBOX + tristate "Generic ARM smc mailbox" + depends on OF && HAVE_ARM_SMCCC + help + Generic mailbox driver which uses ARM smc calls to call into + firmware for triggering mailboxes. + config IMX_MBOX tristate "i.MX Mailbox" depends on ARCH_MXC || COMPILE_TEST diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile index c22fad6f696b..93918a84c91b 100644 --- a/drivers/mailbox/Makefile +++ b/drivers/mailbox/Makefile @@ -7,6 +7,8 @@ obj-$(CONFIG_MAILBOX_TEST) += mailbox-test.o obj-$(CONFIG_ARM_MHU) += arm_mhu.o +obj-$(CONFIG_ARM_SMC_MBOX) += arm-smc-mailbox.o + obj-$(CONFIG_IMX_MBOX) += imx-mailbox.o obj-$(CONFIG_ARMADA_37XX_RWTM_MBOX) += armada-37xx-rwtm-mailbox.o diff --git a/drivers/mailbox/arm-smc-mailbox.c b/drivers/mailbox/arm-smc-mailbox.c new file mode 100644 index 000000000000..c84aef39c8d9 --- /dev/null +++ b/drivers/mailbox/arm-smc-mailbox.c @@ -0,0 +1,167 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2016,2017 ARM Ltd. + * Copyright 2019 NXP + */ + +#include +#include +#include +#include +#include +#include +#include + +struct arm_smc_chan_data { + unsigned int function_id; +}; + +struct arm_smccc_mbox_cmd { + unsigned int function_id; + union { + unsigned int args_smccc32[6]; + unsigned long args_smccc64[6]; + }; +}; + +typedef unsigned long (smc_mbox_fn)(unsigned int, unsigned long, + unsigned long, unsigned long, + unsigned long, unsigned long, + unsigned long); +static smc_mbox_fn *invoke_smc_mbox_fn; + +static int arm_smc_send_data(struct mbox_chan *link, void *data) +{ + struct arm_smc_chan_data *chan_data = link->con_priv; + struct arm_smccc_mbox_cmd *cmd = data; + unsigned long ret; + u32 function_id; + + function_id = chan_data->function_id; + if (!function_id) + function_id = cmd->function_id; + + if (function_id & BIT(30)) { + ret = invoke_smc_mbox_fn(function_id, cmd->args_smccc64[0], + cmd->args_smccc64[1], + cmd->args_smccc64[2], + cmd->args_smccc64[3], + cmd->args_smccc64[4], + cmd->args_smccc64[5]); + } else { + ret = invoke_smc_mbox_fn(function_id, cmd->args_smccc32[0], + cmd->args_smccc32[1], + cmd->args_smccc32[2], + cmd->args_smccc32[3], + cmd->args_smccc32[4], + cmd->args_smccc32[5]); + } + + mbox_chan_received_data(link, (void *)ret); + + return 0; +} + +static unsigned long __invoke_fn_hvc(unsigned int function_id, + unsigned long arg0, unsigned long arg1, + unsigned long arg2, unsigned long arg3, + unsigned long arg4, unsigned long arg5) +{ + struct arm_smccc_res res; + + arm_smccc_hvc(function_id, arg0, arg1, arg2, arg3, arg4, + arg5, 0, &res); + return res.a0; +} + +static unsigned long __invoke_fn_smc(unsigned int function_id, + unsigned long arg0, unsigned long arg1, + unsigned long arg2, unsigned long arg3, + unsigned long arg4, unsigned long arg5) +{ + struct arm_smccc_res res; + + arm_smccc_smc(function_id, arg0, arg1, arg2, arg3, arg4, + arg5, 0, &res); + return res.a0; +} + +static const struct mbox_chan_ops arm_smc_mbox_chan_ops = { + .send_data = arm_smc_send_data, +}; + +static int arm_smc_mbox_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct mbox_controller *mbox; + struct arm_smc_chan_data *chan_data; + int ret; + u32 function_id = 0; + + if (of_device_is_compatible(dev->of_node, "arm,smc-mbox")) + invoke_smc_mbox_fn = __invoke_fn_smc; + else + invoke_smc_mbox_fn = __invoke_fn_hvc; + + mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL); + if (!mbox) + return -ENOMEM; + + mbox->num_chans = 1; + mbox->chans = devm_kzalloc(dev, sizeof(*mbox->chans), GFP_KERNEL); + if (!mbox->chans) + return -ENOMEM; + + chan_data = devm_kzalloc(dev, sizeof(*chan_data), GFP_KERNEL); + if (!chan_data) + return -ENOMEM; + + of_property_read_u32(dev->of_node, "arm,func-id", &function_id); + chan_data->function_id = function_id; + + mbox->chans->con_priv = chan_data; + + mbox->txdone_poll = false; + mbox->txdone_irq = false; + mbox->ops = &arm_smc_mbox_chan_ops; + mbox->dev = dev; + + platform_set_drvdata(pdev, mbox); + + ret = devm_mbox_controller_register(dev, mbox); + if (ret) + return ret; + + dev_info(dev, "ARM SMC mailbox enabled.\n"); + + return ret; +} + +static int arm_smc_mbox_remove(struct platform_device *pdev) +{ + struct mbox_controller *mbox = platform_get_drvdata(pdev); + + mbox_controller_unregister(mbox); + return 0; +} + +static const struct of_device_id arm_smc_mbox_of_match[] = { + { .compatible = "arm,smc-mbox", }, + { .compatible = "arm,hvc-mbox", }, + {}, +}; +MODULE_DEVICE_TABLE(of, arm_smc_mbox_of_match); + +static struct platform_driver arm_smc_mbox_driver = { + .driver = { + .name = "arm-smc-mbox", + .of_match_table = arm_smc_mbox_of_match, + }, + .probe = arm_smc_mbox_probe, + .remove = arm_smc_mbox_remove, +}; +module_platform_driver(arm_smc_mbox_driver); + +MODULE_AUTHOR("Peng Fan "); +MODULE_DESCRIPTION("Generic ARM smc mailbox driver"); +MODULE_LICENSE("GPL v2");