From patchwork Mon Jul 29 18:39: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: 11064355 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 A99E9912 for ; Mon, 29 Jul 2019 18:40:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F46F22701 for ; Mon, 29 Jul 2019 18:40:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 929F828528; Mon, 29 Jul 2019 18:40:57 +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 32F54274D0 for ; Mon, 29 Jul 2019 18:40:57 +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=yVPOS4Z7S0d3uX6l9VeBoJwIa4ga4Ca3GoYDFN+E5ug=; b=u81E5qewtt4S3v rWMNWTmpd/Eh7KULHwRcbDTUbrxn4THwtdb4owQKR2ij87nzYJJODk6mmNKA+XSrax0uMhxYJS54y DikWglc8U9VrvyaHdiEFTq+JT3B7bAPPatkJXWwYPZbSpDKEP82joig6OaG8cWmRavK0YOrh7YZZs ksLOZBD8XvEoH3eEv4+YIK7uqNwar2GYwZSJ/oTGTjeh5qzntkZb9XUn2tFzo96nKXC3kHFeN+ol3 Wn5bzJSRFZG9+lFl5jXW3e0DI8fkGNOnAZNv2q2ZoOvW4P1UXbg0sS92GQ4IeZw2Yb5+/ZBx7o1St 8k8E03qNB1s/u1FIhoLw==; 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 1hsAZs-00042b-Pp; Mon, 29 Jul 2019 18:40:56 +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 1hsAZP-0003fy-LA for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2019 18:40:30 +0000 Received: by mail-wr1-x444.google.com with SMTP id p13so62923558wru.10 for ; Mon, 29 Jul 2019 11:40:27 -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=uXX4nW8uApaN5prOQ3tt1oKZQOOA4D/lJ+3xaeto/As=; b=Y/mudMCy9V+QjQt70RqfnbUHYMk4Ss8CSL/LCgTrpNOEKgAFWdvekQ6IPJuwsuE2Nv NZR/nlBFLC6XbOGVgB8DY/igh/RI8GpWrWYD06FAlUO43DOx2Y9KrTXMmW0E+eoasZXy VaumqO+Vsa76E7Us20um8r5I6JfYvohu+5IEuN99fB2jZ7ZdGxt2XKJSkU34O76Kc4CY f6+GPbJJd1XSVQsw1E0vyQTn0dfG7FVjEzN28PtmAxcUoqDsW6BQiPmENJqDUPBrA0x6 KW0UxHOxTHJmTOzo8tw+0O07pUXB/rQvrsVV2wi5eyRSV8FYOFBIsw8N2C4UA4YX4MyQ GzOw== 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=uXX4nW8uApaN5prOQ3tt1oKZQOOA4D/lJ+3xaeto/As=; b=EO1fqtUcjLEUdqFPCMf6Z8IaugK13J9UY7MmGGgFBycjN7W/0DruGSffCy2gg+J+Wm FshkGuALBRMbLP+PalMoK10pZ4re7cE1jCp/vHWhLXa62ONiccV2TRLkZp20ULJPZKj2 qwfz71T/Y9ZuVGE91hz+jxnxAAKDdqxY0izAz+sg0Be5EnmYFBcZdu+5zRjKHKiMcOOf 8OgcEBc5gUFcwoc+9wrXSQQwERoDU/V1/5RdtegC1M7N8L0RfDgXIn5l3i1y9tSn5PtO vA2Pihfa+crtK6WyKfIHO5glg9qTZqofzEorLXIg+XpAeK65hdVi9Gb/ppVI0D33L70V dQ1w== X-Gm-Message-State: APjAAAV+c+Vo90SdGV2MkEbknSVRsJfPHbBR1NiqCb6O8XcvmoMfTug8 /CO1tzUBUOq8wavG5scn33eICQ== X-Google-Smtp-Source: APXvYqyT7+E9yhALDT4WJ7fusIqGWt+HjrfbfJRzWjySTaW2SjRWy2CfoC7XRRlMgCVm6rS5+/QCfQ== X-Received: by 2002:a5d:6b11:: with SMTP id v17mr45001624wrw.323.1564425626227; Mon, 29 Jul 2019 11:40:26 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:f78c:d00:1570:f96d:dab8:76ae]) by smtp.gmail.com with ESMTPSA id g8sm60735790wmf.17.2019.07.29.11.40.25 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 29 Jul 2019 11:40:25 -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 1/5] nvmem: meson-efuse: Move data to a container struct Date: Mon, 29 Jul 2019 19:39:37 +0100 Message-Id: <20190729183941.18164-2-ccaione@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190729183941.18164-1-ccaione@baylibre.com> References: <20190729183941.18164-1-ccaione@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190729_114027_701833_4A17C2A6 X-CRM114-Status: GOOD ( 13.65 ) 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 functional changes, just a cleanup commit to tidy up a bit. Move the nvmem_* and clk structures in a container struct. Signed-off-by: Carlo Caione --- drivers/nvmem/meson-efuse.c | 47 ++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/drivers/nvmem/meson-efuse.c b/drivers/nvmem/meson-efuse.c index 39bd76306033..9924b98db772 100644 --- a/drivers/nvmem/meson-efuse.c +++ b/drivers/nvmem/meson-efuse.c @@ -14,6 +14,12 @@ #include +struct meson_efuse { + struct nvmem_device *nvmem; + struct nvmem_config config; + struct clk *clk; +}; + static int meson_efuse_read(void *context, unsigned int offset, void *val, size_t bytes) { @@ -37,21 +43,23 @@ MODULE_DEVICE_TABLE(of, meson_efuse_match); static int meson_efuse_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct nvmem_device *nvmem; - struct nvmem_config *econfig; - struct clk *clk; + struct meson_efuse *efuse; unsigned int size; int ret; - clk = devm_clk_get(dev, NULL); - if (IS_ERR(clk)) { - ret = PTR_ERR(clk); + efuse = devm_kzalloc(&pdev->dev, sizeof(*efuse), GFP_KERNEL); + if (!efuse) + return -ENOMEM; + + efuse->clk = devm_clk_get(dev, NULL); + if (IS_ERR(efuse->clk)) { + ret = PTR_ERR(efuse->clk); if (ret != -EPROBE_DEFER) dev_err(dev, "failed to get efuse gate"); return ret; } - ret = clk_prepare_enable(clk); + ret = clk_prepare_enable(efuse->clk); if (ret) { dev_err(dev, "failed to enable gate"); return ret; @@ -59,7 +67,7 @@ static int meson_efuse_probe(struct platform_device *pdev) ret = devm_add_action_or_reset(dev, (void(*)(void *))clk_disable_unprepare, - clk); + efuse->clk); if (ret) { dev_err(dev, "failed to add disable callback"); return ret; @@ -70,21 +78,18 @@ static int meson_efuse_probe(struct platform_device *pdev) return -EINVAL; } - econfig = devm_kzalloc(dev, sizeof(*econfig), GFP_KERNEL); - if (!econfig) - return -ENOMEM; - - econfig->dev = dev; - econfig->name = dev_name(dev); - econfig->stride = 1; - econfig->word_size = 1; - econfig->reg_read = meson_efuse_read; - econfig->reg_write = meson_efuse_write; - econfig->size = size; + efuse->config.dev = dev; + efuse->config.name = dev_name(dev); + efuse->config.stride = 1; + efuse->config.word_size = 1; + efuse->config.reg_read = meson_efuse_read; + efuse->config.reg_write = meson_efuse_write; + efuse->config.size = size; + efuse->config.priv = efuse; - nvmem = devm_nvmem_register(&pdev->dev, econfig); + efuse->nvmem = devm_nvmem_register(&pdev->dev, &efuse->config); - return PTR_ERR_OR_ZERO(nvmem); + return PTR_ERR_OR_ZERO(efuse->nvmem); } static struct platform_driver meson_efuse_driver = { From patchwork Mon Jul 29 18:39: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: 11064357 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 54C01912 for ; Mon, 29 Jul 2019 18:41:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4844A26E38 for ; Mon, 29 Jul 2019 18:41:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C5A2285BD; Mon, 29 Jul 2019 18:41:16 +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 EA1D426E38 for ; Mon, 29 Jul 2019 18:41:15 +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=d9PBcvnGLzx+71ZWcxRIR/Xz2WvV8bHg/xDA6srHos8=; b=FO9rrXKT0GLuft M97pP4UdKNU186V7wYtOUc4uYJBys+PQ5BE4QqxF3gTxx0a9+8dFxfHU7rrFJ1qURYGK3JPfQZLDb lVByRTOOurbaxFij7w0JqNWlrIzcp4Kvf/L8SXvBZnTM3fTo2CBbvYoxZqdfhGqupXwjdw3/qUcZx 23yQyUF9BlnffY7gm39Q3Jh/c/sjc32McxVKmfJVMsIBNzRVg1E+oxWDbBM1d7u/bEz805ItO3ke1 3N6wqX7HRU3Mkh+P5NgwWLvLm8jZA4//2ihohcvnzvXl9y7gYEFYmJwFiBFG3DWJfxW9rUjYggs+t vJhFyILFUhL+M05NiNAQ==; 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 1hsAaB-0004Gg-1G; Mon, 29 Jul 2019 18:41:15 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hsAZQ-0003gh-Qr for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2019 18:40:31 +0000 Received: by mail-wm1-x342.google.com with SMTP id l2so54341847wmg.0 for ; Mon, 29 Jul 2019 11:40:28 -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=NL/5zTQnhohIGaIYxAmHMipqwG7WMic3sqIDS1WvWAs=; b=Ljx2SdXOenWk9HylJB0m7+GqCQWJ8bOa7rynX0A+nTLES1zIBX6aYXSnDNk6NU88HP itdZ60+0KuP8W8UE4ccMSxtZAaJQYznz+WZHwkdvmxOS6FYBoK7tVBBxlqHPadxw7Mfe sGs56zxmzg7avXy+SUU6EMm+nymDm5iY3o91KrfMIhPpG/0GTGbuACRflDKgjB20U+V4 +QRsX/ob4CoDHyWAs/FJlWN/2JkLP9HI+6H4LWOlroC6dCaHuNlqTTiUlcTHcVNJ/vtn w947f/pBV8rHgLFWcRO/lY9rniZisw6PS1b6RKp3gwuSu3Jpx6b/8AWRuAphDf6ZGXN5 7kJg== 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=NL/5zTQnhohIGaIYxAmHMipqwG7WMic3sqIDS1WvWAs=; b=eCSTeGtXxxdhBWBKs6491tERGMFkd3fjaH+8Pv3vvXK9cirZRNCpoQNd9gakBvo694 /Rwl3CqN1k8AbJ5RzaH7vkQZPWLfbcfpurromA+NtovIZVjyv+z3cCWkhTt2WK+z55Fq voc7Wm2Dpyvzj/IM5ml8khFT960TauC1TW+0SUwOKdUMsxY3DADHw0ey3ycsFbjODmm8 0/comOpko1AHd1Wus/d5QDGktZ/ATGtmOCAfhbJYRNpx+t/pRsYuCq1MuHu/21ACZeBO UMTSTzqXMkmONbbnyYXBcz/M49OtBdLEF8NVZGaqy5vK342bVe06F6Nv+OEx9/9buuaE 5Cjw== X-Gm-Message-State: APjAAAW3OqMKEGj+Cb5Z2JCGbYUdRPbNwrUs+GZ25D6gEtdWuOwKnMsM Fci0STIFz+Klx6vyznvq+6MFkw== X-Google-Smtp-Source: APXvYqzO8CDDHffNjKGGHAThG+qAQeZSgvJNfczqVERJbnhJ/UQrCuabRFPykRcFcXO0leXZ4ffb5g== X-Received: by 2002:a1c:f20f:: with SMTP id s15mr25140377wmc.33.1564425627289; Mon, 29 Jul 2019 11:40:27 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:f78c:d00:1570:f96d:dab8:76ae]) by smtp.gmail.com with ESMTPSA id g8sm60735790wmf.17.2019.07.29.11.40.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 29 Jul 2019 11:40:26 -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 2/5] firmware: meson_sm: Mark chip struct as static const Date: Mon, 29 Jul 2019 19:39:38 +0100 Message-Id: <20190729183941.18164-3-ccaione@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190729183941.18164-1-ccaione@baylibre.com> References: <20190729183941.18164-1-ccaione@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190729_114028_899162_E687354E X-CRM114-Status: GOOD ( 11.30 ) 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. Signed-off-by: Carlo Caione Reviewed-by: Jerome Brunet --- 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 Mon Jul 29 18:39: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: 11064361 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 C3D231823 for ; Mon, 29 Jul 2019 18:41:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B979D2623D for ; Mon, 29 Jul 2019 18:41:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE1BD2852A; Mon, 29 Jul 2019 18:41:37 +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 612EB285BD for ; Mon, 29 Jul 2019 18:41:37 +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=TI1fYVgIHD0J2r dki0/ZjNGX8kfIDCgbdNpeHrw7RrlPF7eMUEEIoxICAJHtwPIBg4LMxZQzXagS7MpSZU5Bm/kIg6t /dfXY110xwXgWZiYXV2GwSujaSbo6bnVx130JJYjvu8TQXIxQO1E+1ytWGcesyz4j637HlGxIUdJX 6GzrUoWVTb/8aiptbDTH7iMWSlFKuJs8cGy4cxBIBzfaB3iDYeXOzFyLS5x78QaiIP/qZsCdGCdS1 Ibetr1p7mi0GBiCLaNJzaz6i1DqjW7WgObMdci+TTD7HONAAoZlfh/pCG+oOeoVWTcLccXgzrAqQZ f2SXCqAYj531Hs7P8EQg==; 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 1hsAaW-0004XB-Vo; Mon, 29 Jul 2019 18:41:37 +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 1hsAZR-0003hF-SR for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2019 18:40:31 +0000 Received: by mail-wr1-x443.google.com with SMTP id z1so62928592wru.13 for ; Mon, 29 Jul 2019 11:40:29 -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=IUtiSH2p6Q+rkXQMIKL+C7RbvgRhr+Au5pFEpbqFZSUJUBITqHJ2GgKUwekeWKNQBb tzIM4u5q9Nb+RjiF/z0tmE4ehciXd++MXpGHh+pXgM2VCRW6NlT+dn7M12OZKo7oHJDt puMe2pUVAd5bCTRSvQDb+Wq+0EMkycajGM1c5/4xka//sLSv7P2aRF7BOgrTNbGyxENu Tdq8jqWjtuozujlB7RhEcbhlLECUv1n+qWtbAIOvllF6L4lY3vyApqbIDGoO683dIQf2 ri9RqE145vPp8wvjVWVd0zW1ZEa9yz+oLt4WODkoFu2WlFQBKF6zHucfyGq/QMRwfEfG Rixg== 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=hU1o9YPKmauM53MZV8wuuGodxmbFYlY8kKIxlMmaQdmcjpCnw09T/yxBZ6zVav2vBP DpXpCwFYyKWBTydW1nZC71e4ohGPXwufQjt5Wv5izd0aYj0ICr3UJaZPMqjxw3sK+DOR m5qyv50YYS7siICNyFZ6yjzfEzLSKt73ucdhspfbmU/v/+k5tvkcwhnjIfSzIdax7SJX k9Bt2sWjw0OmekP5uLM6qloSOx/ALhwB0u8itP4DSZMknJoMJkWZ5mf/j+5vdjX+RqOO msq0lSOQbyIsWxu8Uck3d8eCuQgrs9oMnR6fy0xXQP504CqGRfeWkxlNs9EgaUmEn+KI xyWQ== X-Gm-Message-State: APjAAAUFYFqmA2lgt3NhYZ0WjUvyeN8b46kW3l8DfUeLcyYUxi6Ftkeb pFpf+594f9Yttr2bb0eYllUU0A== X-Google-Smtp-Source: APXvYqwj0l/3K4qV5AKD0pPi+Kb6XwRa+C6cY/Loh9vhUu6jSxLM/mptGrUUN2IdVBQYxoUBwyV6Kg== X-Received: by 2002:adf:deca:: with SMTP id i10mr21091707wrn.313.1564425628321; Mon, 29 Jul 2019 11:40:28 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:f78c:d00:1570:f96d:dab8:76ae]) by smtp.gmail.com with ESMTPSA id g8sm60735790wmf.17.2019.07.29.11.40.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 29 Jul 2019 11:40:27 -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 3/5] nvmem: meson-efuse: bindings: Add secure-monitor phandle Date: Mon, 29 Jul 2019 19:39:39 +0100 Message-Id: <20190729183941.18164-4-ccaione@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190729183941.18164-1-ccaione@baylibre.com> References: <20190729183941.18164-1-ccaione@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190729_114030_078718_07FC4C6C X-CRM114-Status: GOOD ( 10.91 ) 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 --- 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 Mon Jul 29 18:39:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Caione X-Patchwork-Id: 11064365 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 4AC62912 for ; Mon, 29 Jul 2019 18:42:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F9292874A for ; Mon, 29 Jul 2019 18:42:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33F602872E; Mon, 29 Jul 2019 18:42:01 +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 69CD7285BD for ; Mon, 29 Jul 2019 18:42:00 +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=XBYMXCYpAhtn7vE56X6INzXtNBd/Kq4J77ZH+iDaSJ4=; b=KR7Eq5DUcWkfja nSlKQ4scsWHpa25LGJBxWH0BjlW6PdsIGScM9XQL1GJKd2h5YPlyNYzEDt1jWlS/Ba8fSQ3iIvtl5 ouqNHIZ31DTv0vnYP0+i0u0MvVLZyeU22Uvs6+HuQjvqq6aGwI5jscAbkRAu9yAO3VgI+OpavFDcz hjPKIJj7wj9IY5vFT2RmSI4k/P0YIS7c2EtbJQ28lQ8J5GR9oTN5HVb1UuyDFU41daq5Pt8EA8084 ruq9Ql0zYiIPoNqYHOuUkbJePcoHNXexcw3t2uU0tOH9KRDA5TijfysAeBDRaCDNVHO4nxBGkiIyc /Q8y9SpQacukSsSPuKeQ==; 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 1hsAan-0004ns-7m; Mon, 29 Jul 2019 18:41:53 +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 1hsAZS-0003i6-Po for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2019 18:40:33 +0000 Received: by mail-wr1-x443.google.com with SMTP id z1so62928690wru.13 for ; Mon, 29 Jul 2019 11:40:30 -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=yk22Z8JHzlgEU95z+MeljHJJxoVpT6sQyqAKg9tLY5U=; b=dx5FxhTIrR+KuBI9Gf5ymUQ2/cStpTGC3wuKFN03eNuQP/BydgV7kfxJ0otUDwewq1 gtIeE+bffQGFr7ShhV2nEWrlUIcGG6s8z8Cp1JHaY0m79OkutI917g8Q0z8nYhOMqFgy cqtH+LsjsC/5mGxtI4+Nmi2WoG35Em2SPc0TvKL8Tw1zpIiMslqOMUAQre9zSOpx7zV5 PH+QVzrPOo/QQDypc0AjQSrnJvtxkzTLg620KndSj9WIvvAXJJhg08DAodrK87/dpU+h R3RLuE3Kwo0QNiyXM1RZGfH8lfnD8XQ64IXaYV80N18RbOAAkjhvfNoFAZQI4GKHjCyd IgvA== 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=yk22Z8JHzlgEU95z+MeljHJJxoVpT6sQyqAKg9tLY5U=; b=saf7Y0+63KPvrTbVULf8sXECW24pD5E9wcxm97pWJEKn/YlREKNxCd7cEGb1gFKFYx TBF3J5KUQ84riYQLcEjdP/FL8x7yhUy9Q8HR9uaoRdsLWzT9euQpH1D84voxmGDlOdLg Iwpt0WgX9c/D33Wj4jvks0CEBXEemA/9K07eoKLVvYYFK+9Oso8Zycmn0GbOdh5QXk7x R3SUZuyBetrc8y01NbJn4PCcftIqpdo0FYQ5PSZeaHDns+fgQx8OOAtqvUHseHTRQbZ8 0nb/uy09ZpSpdCp35zxm4tmk2hl9mlrD4TnvIq7iUpaULXCY1yH/CxfaoVREX+0TzAzR IjhA== X-Gm-Message-State: APjAAAXGVZ5dkkWzJ/Dv3PzilEhZC1UceJhwsAX8edMd3OI6SqQr10o/ thy/KjgmHRHKunik5cRXn10GYQ== X-Google-Smtp-Source: APXvYqwsSAAM0wmsZsQ/D1JTKzKEW/BvIsNSYJd7FhsJtS3NmClnVADYyqPc1eSd8uBcCECLdcyi7A== X-Received: by 2002:a5d:5152:: with SMTP id u18mr124859285wrt.9.1564425629514; Mon, 29 Jul 2019 11:40:29 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:f78c:d00:1570:f96d:dab8:76ae]) by smtp.gmail.com with ESMTPSA id g8sm60735790wmf.17.2019.07.29.11.40.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 29 Jul 2019 11:40:28 -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 4/5] firmware: meson_sm: Rework driver as a proper platform driver Date: Mon, 29 Jul 2019 19:39:40 +0100 Message-Id: <20190729183941.18164-5-ccaione@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190729183941.18164-1-ccaione@baylibre.com> References: <20190729183941.18164-1-ccaione@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190729_114030_922116_C126CF91 X-CRM114-Status: GOOD ( 22.76 ) 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. Signed-off-by: Carlo Caione Reviewed-by: Jerome Brunet --- drivers/firmware/meson/meson_sm.c | 94 +++++++++++++++++-------- drivers/nvmem/meson-efuse.c | 23 +++++- include/linux/firmware/meson/meson_sm.h | 15 ++-- 3 files changed, 93 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 9924b98db772..669d20d73877 100644 --- a/drivers/nvmem/meson-efuse.c +++ b/drivers/nvmem/meson-efuse.c @@ -17,20 +17,25 @@ struct meson_efuse { struct nvmem_device *nvmem; struct nvmem_config config; + struct meson_sm_firmware *fw; struct clk *clk; }; 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_efuse *efuse = context; + + return meson_sm_call_read(efuse->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_efuse *efuse = context; + + return meson_sm_call_write(efuse->fw, (u8 *)val, bytes, SM_EFUSE_WRITE, offset, bytes, 0, 0, 0); } @@ -43,6 +48,7 @@ MODULE_DEVICE_TABLE(of, meson_efuse_match); static int meson_efuse_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct device_node *sm_np; struct meson_efuse *efuse; unsigned int size; int ret; @@ -51,6 +57,17 @@ static int meson_efuse_probe(struct platform_device *pdev) if (!efuse) return -ENOMEM; + 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; + } + + efuse->fw = meson_sm_get(sm_np); + of_node_put(sm_np); + if (!efuse->fw) + return -EPROBE_DEFER; + efuse->clk = devm_clk_get(dev, NULL); if (IS_ERR(efuse->clk)) { ret = PTR_ERR(efuse->clk); @@ -73,7 +90,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(efuse->fw, SM_EFUSE_USER_MAX, &size, 0, 0, 0, 0, 0) < 0) { dev_err(dev, "failed to get max user"); return -EINVAL; } 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_ */ From patchwork Mon Jul 29 18:39:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Caione X-Patchwork-Id: 11064367 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 CB0BC112C for ; Mon, 29 Jul 2019 18:42:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFCCD28739 for ; Mon, 29 Jul 2019 18:42:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AEDE322701; Mon, 29 Jul 2019 18:42:13 +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 656CA2871A for ; Mon, 29 Jul 2019 18:42:13 +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=re1xVY0+wL+QpBYBzapAk1Hzp0v7NVn5LUQ8jZ6+E6w=; b=rsPZlJ/jpHaPDj moO1qmtCKTv1mIKVU9nDjezuwebEaB/HdIMorzVHFscCxr3dTBPqjsN02aaSTSLn5B0Z2XeUFxldN 8UR980vxA3B6THxPkiIyth/NSTf7jPeXZgGOjio+Zza8353Ijh3Zl7nvGezcHr+l1qOGS384TvWnu tzo6OyUZs3W7BFi2cWZ/ZL5mRfHBpSTiYS2US6DH7va+TMFhMR8SNdUyVjWaD2XKfKRYdWiKErKx7 734taOIznfliKPf0bIcBK77NOdIfIagb7QRZyAu6n2YxBwRXIfphAU6YhbfUsQXB58WBL12NxoS7s UTgXGIh4gUIIzCICvllQ==; 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 1hsAb6-00050U-Vq; Mon, 29 Jul 2019 18:42:13 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hsAZT-0003il-NN for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2019 18:40:33 +0000 Received: by mail-wr1-x441.google.com with SMTP id z1so62928759wru.13 for ; Mon, 29 Jul 2019 11:40:31 -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=AX1CJSCOcr1DeLD0PcCM+aTd9MxEzKQRXsBH50eaZPk=; b=SZIQxJ3LrVlobW/DJwItrOtqFgPH+4nNnn5gkWhI3BihWGVaU2HlD3APhDK4ogruPl jtdfRCwx3vAvD+LUAPJZVaIdzWsBA4qSmJ2QKJktKWxcLFQjCJg/wnrnBFno7y65kw2C aXlSfYH8PL/x8mQw7EQzOLuc1z3foUtqweyVgrPFKVDG9Jy1YXo1pADGCzSDrGGFx61A VSuN1ciVyyKy+LtJfRYLC4WwiHHWr4lBrquhoJ/ewqhKbF0jCuGdNK/4L9f88fg4Pd4+ M/8TAZQ6sAS0bw3m7Ec4aG7EzKDd3NArn5CQSvV3rdx+7M6Pj8NhWcKC/MRMm3Yuc2E/ aSyg== 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=AX1CJSCOcr1DeLD0PcCM+aTd9MxEzKQRXsBH50eaZPk=; b=f1QvGju+MJblMTtzxZnlCoEMBgh58Tro7+s8FRHeSTGKjce10+RyRQEVK2kpQuf8uT gu4KvOIJsanYLGOFT6g2PMEG49w1tQme8+vthJzLzxpOkgUlGGsW9XpFlcJulXe6qoon 6umMrcYwxGtyMCRvnZV8+prcaVLGY82D3YlbPx2Lr3kmqZ9PJdqdIdkqznUbm6FxV6A6 Gsht5F04bzUwS/u+XUEdWC4nExeqj97JzXx7nZXt9Ojku6/2gIK87wuEy+0rVEXRn6n2 jCKbaJGbZ6kETfaaooHDo38TmTYjLPkEGdwFLc2BeOgwxnaEStVrOhqmtnGoXHt665bq JEHw== X-Gm-Message-State: APjAAAXvCGikT51NOzqvFETAAZLbeSKJosLE6xiWcMHC+EQjvpKX+6On 5jr+pw+qGuK45vBlX5papRCwdg== X-Google-Smtp-Source: APXvYqysPWn2AC4887FVO3ti/NVIlx7rzerrr9tKYfwEwmRs9XDquoA2/mHcJZ+tizUY2iQv6nnZ0A== X-Received: by 2002:adf:aac8:: with SMTP id i8mr49302545wrc.56.1564425630540; Mon, 29 Jul 2019 11:40:30 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:f78c:d00:1570:f96d:dab8:76ae]) by smtp.gmail.com with ESMTPSA id g8sm60735790wmf.17.2019.07.29.11.40.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 29 Jul 2019 11:40:29 -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 5/5] arm64: dts: meson: Link nvmem and secure-monitor nodes Date: Mon, 29 Jul 2019 19:39:41 +0100 Message-Id: <20190729183941.18164-6-ccaione@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190729183941.18164-1-ccaione@baylibre.com> References: <20190729183941.18164-1-ccaione@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190729_114031_875232_68A85374 X-CRM114-Status: GOOD ( 10.65 ) 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 --- arch/arm64/boot/dts/amlogic/meson-axg.dtsi | 1 + arch/arm64/boot/dts/amlogic/meson-g12a.dtsi | 1 + 2 files changed, 2 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 {