From patchwork Wed Jul 31 08:23:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Caione X-Patchwork-Id: 11067255 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 14B71112C for ; Wed, 31 Jul 2019 08:24:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3EA22876D for ; Wed, 31 Jul 2019 08:24:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7D1F2883B; Wed, 31 Jul 2019 08:24:28 +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=ham 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 7C23D2876D for ; Wed, 31 Jul 2019 08:24:28 +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:References:In-Reply-To: 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=vzoZbGVM2kw2JHLz7eQNT1MycIOP9hccqLkMsO5pQ3Q=; b=V2HTJG2VcaICrk eByHOS7uJQMRr5bo45NFxma04VtctjENcE8TH1PDEOCcmDF30pRci/uRkVJbpXGbJBjgHEYKAJbN0 VGICg8vvbhewr/Nl47XPG0ixubE67/ioExQ3OI1n9CbGbeO0wR4AMzYRAZyhCsAlBPOA5RmiIZCwT eHgucAU/RAiUwZxY2waNJnDEM3sMU17skh4m5XWh5X+sVeSuN5BmSK9Pa/GovHxrwkzuxPnPm59fs tOanw84fGP8J18M+M4L4VYZP2vP2MxsmnrdOX6dqTt2ywXQVMGrnl9W2FmQB1p/PgH4FROUEVNzjn zch1yINhmrKT/O4JmUPQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hsjuN-0004q8-KE; Wed, 31 Jul 2019 08:24:27 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hsjuD-0004kc-UQ for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2019 08:24:19 +0000 Received: by mail-wm1-x343.google.com with SMTP id g67so54853936wme.1 for ; Wed, 31 Jul 2019 01:24:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0irTfRWSZ70qNvhsiExUstYrNfb3pdmbXdiGXd5JhF8=; b=hw80V/InTiJxJH2AH3UWZZ4CUq7Pa/utyGT/q458WHSiUT2ppY7hAAw3/vbHpL2pzL K0BuME0L2K/rO30XimBliuprG32Q4+ZOf4s5RxXy0T+VJe5ykeJSwd2MS9ikYUYv9uAg YPnUxK1ctCQ5m0Q9iDqG/FMWHMg32KRn5i5hAwe3pg46DMGw+U1N/L0AJOlNEE+q1WBU muZlxc7aLEeWLAuGYeFCKYKWZQRK7cfze8F/Yaiu3vEDbdd4S/srnmdzYUV4oCfWLMib BIXuCS8AbzXqdNTb7jTfQk2XIiI3mNuPtp+cxw1FRgLlrqskcyfFM9JbohIGDBbKHj+i c9+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0irTfRWSZ70qNvhsiExUstYrNfb3pdmbXdiGXd5JhF8=; b=dXuaHjAD3zRCUQqytL2KcoiQrdwddd+6o8+pGNUowE+FqgLT5HbaxhzbUAGnf2QbNu TPnwJPf7/6M/Pi8UzdqoiviqoKFM5DuNYSGW5bipJylvn5uxZ1QiaJzS8FX8RqO7WV68 tyhAPlz/fRPVy1KlOAe6Do2zaBOKkgGIiTsF3NC++jWu2j5tII+TRq4E5x1JGhBFHl9r LRwzTp3Fll9n5obS6vZZn2AcnlxN7ieLWt/Rz4328E6322EvkcNKEqJ1WMbe/y2hIZ+p RYJf+KBwAetHTwVf5BZwXZA65TRww+pTfiIaIhFNsHsLOP9+1m9F4Ke/ar0sWoPBERqN rLbA== X-Gm-Message-State: APjAAAXF7UhuGXhzGegzwkc66LIlMStzX6q6k6grBu/JkvYT+u3/nV/M 1CCeWbO9ckOcQx0NX86ZxxUNhQ== X-Google-Smtp-Source: APXvYqxwqKJLeF0A9W2Qb4n3Ft9qKIilrEwYAsvkxn4OL2mk5QQMea6ic1fnLlRUSXtJ0oMq56TBkw== X-Received: by 2002:a1c:f90f:: with SMTP id x15mr32073741wmh.69.1564561456060; Wed, 31 Jul 2019 01:24:16 -0700 (PDT) Received: from localhost.localdomain ([185.49.42.196]) by smtp.gmail.com with ESMTPSA id o3sm54597664wrs.59.2019.07.31.01.24.15 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 01:24:15 -0700 (PDT) From: Carlo Caione To: srinivas.kandagatla@linaro.org, khilman@baylibre.com, narmstrong@baylibre.com, robh+dt@kernel.org, tglx@linutronix.de, jbrunet@baylibre.com, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org Subject: [PATCH v2 1/4] firmware: meson_sm: Mark chip struct as static const Date: Wed, 31 Jul 2019 09:23:36 +0100 Message-Id: <20190731082339.20163-2-ccaione@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190731082339.20163-1-ccaione@baylibre.com> References: <20190731082339.20163-1-ccaione@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190731_012418_178229_95B6E4FD X-CRM114-Status: GOOD ( 11.60 ) 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: Carlo Caione 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 No need to be a global struct. Reviewed-by: Jerome Brunet Signed-off-by: Carlo Caione --- drivers/firmware/meson/meson_sm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/meson/meson_sm.c b/drivers/firmware/meson/meson_sm.c index 8d908a8e0d20..772ca6726e7b 100644 --- a/drivers/firmware/meson/meson_sm.c +++ b/drivers/firmware/meson/meson_sm.c @@ -35,7 +35,7 @@ struct meson_sm_chip { struct meson_sm_cmd cmd[]; }; -struct meson_sm_chip gxbb_chip = { +static const struct meson_sm_chip gxbb_chip = { .shmem_size = SZ_4K, .cmd_shmem_in_base = 0x82000020, .cmd_shmem_out_base = 0x82000021, From patchwork Wed Jul 31 08:23:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Caione X-Patchwork-Id: 11067263 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 C8FCF1398 for ; Wed, 31 Jul 2019 08:25:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B42CC2876D for ; Wed, 31 Jul 2019 08:25:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A851E2883B; Wed, 31 Jul 2019 08:25:18 +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=ham 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 5C2E82876D for ; Wed, 31 Jul 2019 08:25:18 +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:References:In-Reply-To: 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=beQwOlWYfZlPNVutWwB7OZTQe2gMab/3DIlk76i+4yE=; b=IeowVf7FQP4Otj 2ttJOJRb2bd2pPy/p/m/3UBvWpMembU2BseFNK7L01A6ia5Djqw9beEtUHiYH4bz8gtF0MMmtMqYh lC3IBY7SSFXwNCsIlhwzeQc8TLC2BeYBRh6m3h/SSEpQeQJUKuh9DPq0DRBhn7HQGQFkXN2NtG+LV Gs31/dMBNLoL/AiYIdP6upzwmb8nKGlcNsKD1ADQi9e6ar1hDmsuNnqAZaXQEb1YKUq/D3W0kDgOi 7Z5A3c/Dd9Lk1T5aglSdRd0wDoqfTzSHt4SoU3xA1k+JCVBO3ppl8NvQJGPIneH1/lOpFxdqYDid9 oFEzMCRU2kO5x+6Us5qA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hsjvB-0006YQ-SI; Wed, 31 Jul 2019 08:25:18 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hsjuE-0004kx-5L for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2019 08:24:22 +0000 Received: by mail-wr1-x444.google.com with SMTP id y4so68644565wrm.2 for ; Wed, 31 Jul 2019 01:24:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VUEntzYhcLPYeivqRWWRZYOkkzIgMjaxPulhiV5XfAs=; b=xZm4C9KuemF121oZYX71PekVcKNALimIsM5iA+ReoIanj2ggYuqCKHrqSzNuhutcnp 6Ntf4rUAPimGfHSHRrmDqmnBDoWja3cWFFXUHCBMAzY7OptGRNboirrVqs2gTcfBUvqO 7fxw49aI5n0VEE2OcPdobQ8mSK08a5VMs1zdlnk9JASqtqyzQoAlC7IONrZs8R8YP5a9 RcC/H77yhdEo0D7Y+NKsjxOXTXHpMxj1CRGrM9X8Y13e9If08+bCEe0cBDCJ0uleuJAN u/qZKwQmTUmPy1Klowd4MDCWn8vRwZDBKm8+wx7x2dB9wg/CCaA5+hFVu4vcRqtQZd92 lxvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VUEntzYhcLPYeivqRWWRZYOkkzIgMjaxPulhiV5XfAs=; b=ryIwAgJcM7Z8sklUVodyvEinAug5H0cltYQ/JoL0ZDfIa91w6f6rhPWAAlNxqdfj/P IUSjt4lhMQoM7vDib3NsIdrnUR9Mv8AdijGAK9IlluFSHJhzyef9bs/cxTM9UQr49O1q b3FD1JgQSKwNqWoaPZaiDTmjvLG9r8n7UJP6bavlwk5KJdNRYVIU8ziR5ek5jrON2plt rir46FPq/C4TnHsTE8/q77HLBoipZJEVpTkQzNX4mV6xOUrLHHqnTdk9uevihHxgYHPE iHgs2ccsVJERFGLpHQ2pnFJ3LC5vnVWJ04FFg4KUn6LCawEIZN35Q5JHfANURD3Klg5Y g9og== X-Gm-Message-State: APjAAAXNEkh3wgYaN49WFDXC56pLd3AZ/49T4CRglfLHL94ucZtWAjKe GcH3yNYW3DwW3oRh/7bciCvFMw== X-Google-Smtp-Source: APXvYqxV4LXo0Q/ciRHoeBah7/cvjuKoFsI9WzOIaLUC6uv6UEqeN10lcTotCmKAcCfQWbaN7ZNFcg== X-Received: by 2002:adf:e84a:: with SMTP id d10mr43348176wrn.316.1564561457019; Wed, 31 Jul 2019 01:24:17 -0700 (PDT) Received: from localhost.localdomain ([185.49.42.196]) by smtp.gmail.com with ESMTPSA id o3sm54597664wrs.59.2019.07.31.01.24.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 01:24:16 -0700 (PDT) From: Carlo Caione To: srinivas.kandagatla@linaro.org, khilman@baylibre.com, narmstrong@baylibre.com, robh+dt@kernel.org, tglx@linutronix.de, jbrunet@baylibre.com, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org Subject: [PATCH v2 2/4] nvmem: meson-efuse: bindings: Add secure-monitor phandle Date: Wed, 31 Jul 2019 09:23:37 +0100 Message-Id: <20190731082339.20163-3-ccaione@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190731082339.20163-1-ccaione@baylibre.com> References: <20190731082339.20163-1-ccaione@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190731_012418_355009_DD8F4DFE X-CRM114-Status: GOOD ( 11.21 ) 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: Carlo Caione 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 Add a new property to link the nvmem driver to the secure-monitor. The nvmem driver needs to access the secure-monitor to be able to access the fuses. Signed-off-by: Carlo Caione Reviewed-by: Jerome Brunet --- Documentation/devicetree/bindings/nvmem/amlogic-efuse.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/nvmem/amlogic-efuse.txt b/Documentation/devicetree/bindings/nvmem/amlogic-efuse.txt index 2e0723ab3384..f7b3ed74db54 100644 --- a/Documentation/devicetree/bindings/nvmem/amlogic-efuse.txt +++ b/Documentation/devicetree/bindings/nvmem/amlogic-efuse.txt @@ -4,6 +4,7 @@ Required properties: - compatible: should be "amlogic,meson-gxbb-efuse" - clocks: phandle to the efuse peripheral clock provided by the clock controller. +- secure-monitor: phandle to the secure-monitor node = Data cells = Are child nodes of eFuse, bindings of which as described in @@ -16,6 +17,7 @@ Example: clocks = <&clkc CLKID_EFUSE>; #address-cells = <1>; #size-cells = <1>; + secure-monitor = <&sm>; sn: sn@14 { reg = <0x14 0x10>; @@ -30,6 +32,10 @@ Example: }; }; + sm: secure-monitor { + compatible = "amlogic,meson-gxbb-sm"; + }; + = Data consumers = Are device nodes which consume nvmem data cells. From patchwork Wed Jul 31 08:23:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Caione X-Patchwork-Id: 11067279 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 4F6D9112C for ; Wed, 31 Jul 2019 08:25:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3819628783 for ; Wed, 31 Jul 2019 08:25:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 293EE2883B; Wed, 31 Jul 2019 08:25:51 +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=ham 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 CA21828783 for ; Wed, 31 Jul 2019 08:25:50 +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:References:In-Reply-To: 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=grVEZ58tZxEKEXgW+IqqZ0tOBUkuX1fRCCEKPBQI/rU=; b=IOTLyZF2tdKEqA ToZkZwPENbhTHUiectc2pSb0WdnBhTY7oF3fxmOOU/n/nkej+5NueIbPIa2HBWH4GTE+teq30d+yK eDGhDeSk/O1wN9obhGMZNp48vr1JCAtPc/CNek6D600wvmbcHVO2a32SottoCbzJN5bVjip6Jm+iY 435MivA4mjuqUEgyrKG8mYZ/00DSLG/U9uSqS5Y7oQhNbqAa6/yg8BiMZ202o+aQpZuDNGZB1AB09 52J2wjhbTILFuqhvxFi1aPzAIyUXvxiE9Tixy3qha7HpSopOl+CjnYhAf8IiGEGMO6rcsEdvfrwqG PHS/htH7kJYLyQXVWWAw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hsjvb-0006w3-Pc; Wed, 31 Jul 2019 08:25:43 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hsjuF-0004lk-Cx for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2019 08:24:23 +0000 Received: by mail-wr1-x443.google.com with SMTP id n4so68708758wrs.3 for ; Wed, 31 Jul 2019 01:24:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FvbjEUb/Th+01Zl6XcdJ8odyub7JsODLUUEoKLKzNZs=; b=KfFL/BC5xXufP3lnLyJas5UbmqihmA7JUqE/ABeqHp+2fHzgoTfjS9RR52KjZgfybD OWqofiqs+lXpz8e0FIe9QWueOTgbduVw5Tu7tP8cuMt7q1VkNTncx+hrHp0bk3rLNevY bdMNp54T7/xGH6YVjA9tk69Nak4tnRzf5LN3TZWpM+rQ+ggpa2/uhsg5ZiXOS8voq1am YRaf94BMdbjKllwNF37cCZCid8eMt8jn7R/szwHsN6HzXtGZj4raMFsnW8K2fMyfKg9l 1gdwmtDgDU6DaWK7EH3XLMPjP3X/ORYHNdbq0XnyeTsQkRB6EbRn6NRBUYcB929zc6XB N2cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FvbjEUb/Th+01Zl6XcdJ8odyub7JsODLUUEoKLKzNZs=; b=lFKEZR2Jrk6lQcEvky/iccTz33kO0ntCRjg+MrF5AjH9FW+QXE7t1AComjOy1DKK7O e1UABBz/9E7YH59orUKwZgy6gGzjLbheUH9hQPUkRUmjq/IVuFrN+NgqBbfvvbqGQ90f 0Ff3bRAZ4WVO1QbMpLbFXzU447KyGDy79l53qt14HCZZg8A5tmn68Nd/IxAuF16uPey+ vniYKbHxvXjM4BblbfWUOuv7wsPLPcsWS/tRAiodZK2sPU8pFW6Q3+knlQ6kKFZR7kve 6mFl8RHYdC1qkhasLtWBIeZlaJV14AZQ/tWSyeRlKqTap6NMQtnoPhJnQnKFVHd5TwId jyVA== X-Gm-Message-State: APjAAAXCuX9I3yhSFPLP3PftZePL9CJH6V6OkYPNotSSibgpVJ3YzgQa Ar3KnSTjgZrXhARQmVJiW1JkRg== X-Google-Smtp-Source: APXvYqx8lMDuI8fETzlBpD+Nb0OwlBL7r+bY0XigWErXCCrG7/5RRdFHxOGqoR3XxYQElGTaiYN9dA== X-Received: by 2002:adf:f646:: with SMTP id x6mr140810646wrp.18.1564561457832; Wed, 31 Jul 2019 01:24:17 -0700 (PDT) Received: from localhost.localdomain ([185.49.42.196]) by smtp.gmail.com with ESMTPSA id o3sm54597664wrs.59.2019.07.31.01.24.17 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 01:24:17 -0700 (PDT) From: Carlo Caione To: srinivas.kandagatla@linaro.org, khilman@baylibre.com, narmstrong@baylibre.com, robh+dt@kernel.org, tglx@linutronix.de, jbrunet@baylibre.com, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org Subject: [PATCH v2 3/4] arm64: dts: meson: Link nvmem and secure-monitor nodes Date: Wed, 31 Jul 2019 09:23:38 +0100 Message-Id: <20190731082339.20163-4-ccaione@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190731082339.20163-1-ccaione@baylibre.com> References: <20190731082339.20163-1-ccaione@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190731_012420_675539_EA876EDA X-CRM114-Status: GOOD ( 10.72 ) 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: Carlo Caione 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 The former is going to use the latter to retrieve the efuses data. Signed-off-by: Carlo Caione Reviewed-by: Jerome Brunet --- arch/arm64/boot/dts/amlogic/meson-axg.dtsi | 1 + arch/arm64/boot/dts/amlogic/meson-g12a.dtsi | 1 + arch/arm64/boot/dts/amlogic/meson-gx.dtsi | 1 + 3 files changed, 3 insertions(+) diff --git a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi index 6219337033a0..b8244efb85fa 100644 --- a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi @@ -117,6 +117,7 @@ #address-cells = <1>; #size-cells = <1>; read-only; + secure-monitor = <&sm>; }; psci { diff --git a/arch/arm64/boot/dts/amlogic/meson-g12a.dtsi b/arch/arm64/boot/dts/amlogic/meson-g12a.dtsi index f8d43e3dcf20..2b07752e034f 100644 --- a/arch/arm64/boot/dts/amlogic/meson-g12a.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-g12a.dtsi @@ -100,6 +100,7 @@ #address-cells = <1>; #size-cells = <1>; read-only; + secure-monitor = <&sm>; }; psci { diff --git a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi index 74d03fc706be..d244d9783718 100644 --- a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi @@ -161,6 +161,7 @@ #address-cells = <1>; #size-cells = <1>; read-only; + secure-monitor = <&sm>; sn: sn@14 { reg = <0x14 0x10>; From patchwork Wed Jul 31 08:23:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Caione X-Patchwork-Id: 11067281 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 B48B7112C for ; Wed, 31 Jul 2019 08:26:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CD4628783 for ; Wed, 31 Jul 2019 08:26:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DBA52883B; Wed, 31 Jul 2019 08:26:02 +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 D100A28783 for ; Wed, 31 Jul 2019 08:26:01 +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:References:In-Reply-To: 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=fxEvSa4tnOb14zCndw1K+KiHt0Dgeg4IFEAYBE2vOWY=; b=scaM3P6zArmLQY 7EPE8YPpBO2BZWNXKNjcTpd/XX0nHnE/20x5qZrXZE8kRzKEPPGXuTsPUQ7WSpzW2n0yGDGACuFP0 DR20sJEgmrnrD0eMXx5OXhOab5vfs6dsbxly/jzTfqhywwxQ14LLOOrf0fwzIHy2YG1WjnKxqskDS egtfji5A63ugS7V048GlXRpQfVn9F/b1aW4QFTt0bW8A7mCnIMkpbwbQjDBn/NH1yKawAPidVI6a1 qFvuES1VwzDyfLE9fWhh8BR73xnctbGowyLy4KvYjWAHv/nzFDV+yvTuVz20L2559EQamAxvH/qA1 BByBoifs5+yLLfC//x4A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hsjvt-00079m-Gc; Wed, 31 Jul 2019 08:26:01 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hsjuF-0004mW-UZ for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2019 08:24:25 +0000 Received: by mail-wr1-x443.google.com with SMTP id x1so18727594wrr.9 for ; Wed, 31 Jul 2019 01:24:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tia4GGlfCZfjipvPpsnZEjlZ47XCVJ76nFFzIXV74zE=; b=MaLkFY/KCOqCGPh6RMHvtZGkwY4X3TM8dvZKbapwUyqHqyecPIFp91Z6gsGAMK+mam icKXgf6+P1JGC73sRzpxFr+AIix1ZETpg3X45B2B+Sm3w74NNpddsfi1iBs1Wykthj8z CK19AO4QEtbhD685eBzJ49oBqXU13sw3GSHUMhnzh/bIZBM8jH1Km1ozbxoE0QdKaaMW kFzF63ODThIY06NpPEKXeIULQoFQ0+KKPahNaok35+kBELL0z3dCMlVJpRGvEHwLKFhq nzULBIXUO/YLlkWJY+zttMGFmrop73E1c++l1EhwiQNnTPP5U14VtTFRbd1SqejUEvRL 2nAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tia4GGlfCZfjipvPpsnZEjlZ47XCVJ76nFFzIXV74zE=; b=jXJmPEo7Kske7rdVUVj7b2OY5ZQ5RTtZdV2bkc/bSTg3f3+a36R7b1ECaNDheL53GM O2JkdoVDvxZ4FwawlvYA7Nvn4bR0hvZdCSiLZ9NSvpc1wY2EjEOzS6IZmJ2JIYU/dLUL d/usPQxTqr1R37EUnhIePzxdpTy8SnHu3W/AexGF1dhKBv+1Z902RgyERc1E5UU9ZG7u BWFAcWgU6xUr/Mt4RpcLJDMnJja6XW8fIvtP8gFcKYbUeixQW8PLsrr0XR6Duno/SIhc 23ueOSLZyZDeFRVUyeMG/60iy6p0T/DRsrriMzYnJQbYaz82jjAPC4xivLPZudG0gi8i LY5Q== X-Gm-Message-State: APjAAAXGffZp3n9J89LpeqZsB0CRO/rHSdM9Dkjnn+Xoy2BEaHQEqAdF U/cRW0TvygMwLUlChmrnUs/v2w== X-Google-Smtp-Source: APXvYqxPaEuXZXFfN64V8ZeieLOeUIQh8nRS8lcyqKMi5exZ3hD1tXdJzcDUIAAPHR8YZRoHVAmn6A== X-Received: by 2002:adf:ce07:: with SMTP id p7mr53083050wrn.129.1564561458621; Wed, 31 Jul 2019 01:24:18 -0700 (PDT) Received: from localhost.localdomain ([185.49.42.196]) by smtp.gmail.com with ESMTPSA id o3sm54597664wrs.59.2019.07.31.01.24.17 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 01:24:18 -0700 (PDT) From: Carlo Caione To: srinivas.kandagatla@linaro.org, khilman@baylibre.com, narmstrong@baylibre.com, robh+dt@kernel.org, tglx@linutronix.de, jbrunet@baylibre.com, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org Subject: [PATCH v2 4/4] firmware: meson_sm: Rework driver as a proper platform driver Date: Wed, 31 Jul 2019 09:23:39 +0100 Message-Id: <20190731082339.20163-5-ccaione@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190731082339.20163-1-ccaione@baylibre.com> References: <20190731082339.20163-1-ccaione@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190731_012420_678468_A786E918 X-CRM114-Status: GOOD ( 22.87 ) 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: Carlo Caione 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 The secure monitor driver is currently a frankenstein driver which is registered as a platform driver but its functionality goes through a global struct accessed by the consumer drivers using exported helper functions. Try to tidy up the driver moving the firmware struct into the driver data and make the consumer drivers referencing the secure-monitor using a new property in the DT. Currently only the nvmem driver is using this API so we can fix it in the same commit. Reviewed-by: Jerome Brunet Signed-off-by: Carlo Caione Acked-by: Srinivas Kandagatla --- drivers/firmware/meson/meson_sm.c | 94 +++++++++++++++++-------- drivers/nvmem/meson-efuse.c | 24 ++++++- include/linux/firmware/meson/meson_sm.h | 15 ++-- 3 files changed, 94 insertions(+), 39 deletions(-) diff --git a/drivers/firmware/meson/meson_sm.c b/drivers/firmware/meson/meson_sm.c index 772ca6726e7b..2e36a2aa274c 100644 --- a/drivers/firmware/meson/meson_sm.c +++ b/drivers/firmware/meson/meson_sm.c @@ -54,8 +54,6 @@ struct meson_sm_firmware { void __iomem *sm_shmem_out_base; }; -static struct meson_sm_firmware fw; - static u32 meson_sm_get_cmd(const struct meson_sm_chip *chip, unsigned int cmd_index) { @@ -90,6 +88,7 @@ static void __iomem *meson_sm_map_shmem(u32 cmd_shmem, unsigned int size) /** * meson_sm_call - generic SMC32 call to the secure-monitor * + * @fw: Pointer to secure-monitor firmware * @cmd_index: Index of the SMC32 function ID * @ret: Returned value * @arg0: SMC32 Argument 0 @@ -100,15 +99,15 @@ static void __iomem *meson_sm_map_shmem(u32 cmd_shmem, unsigned int size) * * Return: 0 on success, a negative value on error */ -int meson_sm_call(unsigned int cmd_index, u32 *ret, u32 arg0, - u32 arg1, u32 arg2, u32 arg3, u32 arg4) +int meson_sm_call(struct meson_sm_firmware *fw, unsigned int cmd_index, + u32 *ret, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4) { u32 cmd, lret; - if (!fw.chip) + if (!fw->chip) return -ENOENT; - cmd = meson_sm_get_cmd(fw.chip, cmd_index); + cmd = meson_sm_get_cmd(fw->chip, cmd_index); if (!cmd) return -EINVAL; @@ -124,6 +123,7 @@ EXPORT_SYMBOL(meson_sm_call); /** * meson_sm_call_read - retrieve data from secure-monitor * + * @fw: Pointer to secure-monitor firmware * @buffer: Buffer to store the retrieved data * @bsize: Size of the buffer * @cmd_index: Index of the SMC32 function ID @@ -137,22 +137,23 @@ EXPORT_SYMBOL(meson_sm_call); * When 0 is returned there is no guarantee about the amount of * data read and bsize bytes are copied in buffer. */ -int meson_sm_call_read(void *buffer, unsigned int bsize, unsigned int cmd_index, - u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4) +int meson_sm_call_read(struct meson_sm_firmware *fw, void *buffer, + unsigned int bsize, unsigned int cmd_index, u32 arg0, + u32 arg1, u32 arg2, u32 arg3, u32 arg4) { u32 size; int ret; - if (!fw.chip) + if (!fw->chip) return -ENOENT; - if (!fw.chip->cmd_shmem_out_base) + if (!fw->chip->cmd_shmem_out_base) return -EINVAL; - if (bsize > fw.chip->shmem_size) + if (bsize > fw->chip->shmem_size) return -EINVAL; - if (meson_sm_call(cmd_index, &size, arg0, arg1, arg2, arg3, arg4) < 0) + if (meson_sm_call(fw, cmd_index, &size, arg0, arg1, arg2, arg3, arg4) < 0) return -EINVAL; if (size > bsize) @@ -164,7 +165,7 @@ int meson_sm_call_read(void *buffer, unsigned int bsize, unsigned int cmd_index, size = bsize; if (buffer) - memcpy(buffer, fw.sm_shmem_out_base, size); + memcpy(buffer, fw->sm_shmem_out_base, size); return ret; } @@ -173,6 +174,7 @@ EXPORT_SYMBOL(meson_sm_call_read); /** * meson_sm_call_write - send data to secure-monitor * + * @fw: Pointer to secure-monitor firmware * @buffer: Buffer containing data to send * @size: Size of the data to send * @cmd_index: Index of the SMC32 function ID @@ -184,23 +186,24 @@ EXPORT_SYMBOL(meson_sm_call_read); * * Return: size of sent data on success, a negative value on error */ -int meson_sm_call_write(void *buffer, unsigned int size, unsigned int cmd_index, - u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4) +int meson_sm_call_write(struct meson_sm_firmware *fw, void *buffer, + unsigned int size, unsigned int cmd_index, u32 arg0, + u32 arg1, u32 arg2, u32 arg3, u32 arg4) { u32 written; - if (!fw.chip) + if (!fw->chip) return -ENOENT; - if (size > fw.chip->shmem_size) + if (size > fw->chip->shmem_size) return -EINVAL; - if (!fw.chip->cmd_shmem_in_base) + if (!fw->chip->cmd_shmem_in_base) return -EINVAL; - memcpy(fw.sm_shmem_in_base, buffer, size); + memcpy(fw->sm_shmem_in_base, buffer, size); - if (meson_sm_call(cmd_index, &written, arg0, arg1, arg2, arg3, arg4) < 0) + if (meson_sm_call(fw, cmd_index, &written, arg0, arg1, arg2, arg3, arg4) < 0) return -EINVAL; if (!written) @@ -210,6 +213,24 @@ int meson_sm_call_write(void *buffer, unsigned int size, unsigned int cmd_index, } EXPORT_SYMBOL(meson_sm_call_write); +/** + * meson_sm_get - get pointer to meson_sm_firmware structure. + * + * @sm_node: Pointer to the secure-monitor Device Tree node. + * + * Return: NULL is the secure-monitor device is not ready. + */ +struct meson_sm_firmware *meson_sm_get(struct device_node *sm_node) +{ + struct platform_device *pdev = of_find_device_by_node(sm_node); + + if (!pdev) + return NULL; + + return platform_get_drvdata(pdev); +} +EXPORT_SYMBOL_GPL(meson_sm_get); + #define SM_CHIP_ID_LENGTH 119 #define SM_CHIP_ID_OFFSET 4 #define SM_CHIP_ID_SIZE 12 @@ -217,14 +238,18 @@ EXPORT_SYMBOL(meson_sm_call_write); static ssize_t serial_show(struct device *dev, struct device_attribute *attr, char *buf) { + struct platform_device *pdev = to_platform_device(dev); + struct meson_sm_firmware *fw; uint8_t *id_buf; int ret; + fw = platform_get_drvdata(pdev); + id_buf = kmalloc(SM_CHIP_ID_LENGTH, GFP_KERNEL); if (!id_buf) return -ENOMEM; - ret = meson_sm_call_read(id_buf, SM_CHIP_ID_LENGTH, SM_GET_CHIP_ID, + ret = meson_sm_call_read(fw, id_buf, SM_CHIP_ID_LENGTH, SM_GET_CHIP_ID, 0, 0, 0, 0, 0); if (ret < 0) { kfree(id_buf); @@ -268,25 +293,34 @@ static const struct of_device_id meson_sm_ids[] = { static int __init meson_sm_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; const struct meson_sm_chip *chip; + struct meson_sm_firmware *fw; + + fw = devm_kzalloc(dev, sizeof(*fw), GFP_KERNEL); + if (!fw) + return -ENOMEM; - chip = of_match_device(meson_sm_ids, &pdev->dev)->data; + chip = of_match_device(meson_sm_ids, dev)->data; if (chip->cmd_shmem_in_base) { - fw.sm_shmem_in_base = meson_sm_map_shmem(chip->cmd_shmem_in_base, - chip->shmem_size); - if (WARN_ON(!fw.sm_shmem_in_base)) + fw->sm_shmem_in_base = meson_sm_map_shmem(chip->cmd_shmem_in_base, + chip->shmem_size); + if (WARN_ON(!fw->sm_shmem_in_base)) goto out; } if (chip->cmd_shmem_out_base) { - fw.sm_shmem_out_base = meson_sm_map_shmem(chip->cmd_shmem_out_base, - chip->shmem_size); - if (WARN_ON(!fw.sm_shmem_out_base)) + fw->sm_shmem_out_base = meson_sm_map_shmem(chip->cmd_shmem_out_base, + chip->shmem_size); + if (WARN_ON(!fw->sm_shmem_out_base)) goto out_in_base; } - fw.chip = chip; + fw->chip = chip; + + platform_set_drvdata(pdev, fw); + pr_info("secure-monitor enabled\n"); if (sysfs_create_group(&pdev->dev.kobj, &meson_sm_sysfs_attr_group)) @@ -295,7 +329,7 @@ static int __init meson_sm_probe(struct platform_device *pdev) return 0; out_in_base: - iounmap(fw.sm_shmem_in_base); + iounmap(fw->sm_shmem_in_base); out: return -EINVAL; } diff --git a/drivers/nvmem/meson-efuse.c b/drivers/nvmem/meson-efuse.c index 39bd76306033..d6b533497ce1 100644 --- a/drivers/nvmem/meson-efuse.c +++ b/drivers/nvmem/meson-efuse.c @@ -17,14 +17,18 @@ static int meson_efuse_read(void *context, unsigned int offset, void *val, size_t bytes) { - return meson_sm_call_read((u8 *)val, bytes, SM_EFUSE_READ, offset, + struct meson_sm_firmware *fw = context; + + return meson_sm_call_read(fw, (u8 *)val, bytes, SM_EFUSE_READ, offset, bytes, 0, 0, 0); } static int meson_efuse_write(void *context, unsigned int offset, void *val, size_t bytes) { - return meson_sm_call_write((u8 *)val, bytes, SM_EFUSE_WRITE, offset, + struct meson_sm_firmware *fw = context; + + return meson_sm_call_write(fw, (u8 *)val, bytes, SM_EFUSE_WRITE, offset, bytes, 0, 0, 0); } @@ -37,12 +41,25 @@ MODULE_DEVICE_TABLE(of, meson_efuse_match); static int meson_efuse_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct meson_sm_firmware *fw; + struct device_node *sm_np; struct nvmem_device *nvmem; struct nvmem_config *econfig; struct clk *clk; unsigned int size; int ret; + sm_np = of_parse_phandle(pdev->dev.of_node, "secure-monitor", 0); + if (!sm_np) { + dev_err(&pdev->dev, "no secure-monitor node\n"); + return -ENODEV; + } + + fw = meson_sm_get(sm_np); + of_node_put(sm_np); + if (!fw) + return -EPROBE_DEFER; + clk = devm_clk_get(dev, NULL); if (IS_ERR(clk)) { ret = PTR_ERR(clk); @@ -65,7 +82,7 @@ static int meson_efuse_probe(struct platform_device *pdev) return ret; } - if (meson_sm_call(SM_EFUSE_USER_MAX, &size, 0, 0, 0, 0, 0) < 0) { + if (meson_sm_call(fw, SM_EFUSE_USER_MAX, &size, 0, 0, 0, 0, 0) < 0) { dev_err(dev, "failed to get max user"); return -EINVAL; } @@ -81,6 +98,7 @@ static int meson_efuse_probe(struct platform_device *pdev) econfig->reg_read = meson_efuse_read; econfig->reg_write = meson_efuse_write; econfig->size = size; + econfig->priv = fw; nvmem = devm_nvmem_register(&pdev->dev, econfig); diff --git a/include/linux/firmware/meson/meson_sm.h b/include/linux/firmware/meson/meson_sm.h index 7613bf7c9442..6669e2a1d5fd 100644 --- a/include/linux/firmware/meson/meson_sm.h +++ b/include/linux/firmware/meson/meson_sm.h @@ -16,11 +16,14 @@ enum { struct meson_sm_firmware; -int meson_sm_call(unsigned int cmd_index, u32 *ret, u32 arg0, u32 arg1, - u32 arg2, u32 arg3, u32 arg4); -int meson_sm_call_write(void *buffer, unsigned int b_size, unsigned int cmd_index, - u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4); -int meson_sm_call_read(void *buffer, unsigned int bsize, unsigned int cmd_index, - u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4); +int meson_sm_call(struct meson_sm_firmware *fw, unsigned int cmd_index, + u32 *ret, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4); +int meson_sm_call_write(struct meson_sm_firmware *fw, void *buffer, + unsigned int b_size, unsigned int cmd_index, u32 arg0, + u32 arg1, u32 arg2, u32 arg3, u32 arg4); +int meson_sm_call_read(struct meson_sm_firmware *fw, void *buffer, + unsigned int bsize, unsigned int cmd_index, u32 arg0, + u32 arg1, u32 arg2, u32 arg3, u32 arg4); +struct meson_sm_firmware *meson_sm_get(struct device_node *firmware_node); #endif /* _MESON_SM_FW_H_ */