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: 11064359 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 8514F112C for ; Mon, 29 Jul 2019 18:41:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79DD52871E for ; Mon, 29 Jul 2019 18:41:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54E7226E38; Mon, 29 Jul 2019 18:41:33 +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 EE27428334 for ; Mon, 29 Jul 2019 18:41:32 +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=vLhAXvf1oGJMwzZ0ra6YvcU2b7Sn2t4S65qEQW/Ypvw=; b=lW2/m4lZXWB//B V/gXKTDr87OBqs4bdrb77TyocyR/ERsSc7PfOiYzyBNhgv0WzUYzyybGmsMGonrSU4kyfwPnyVChu zWgzDjUajR/w5IxMQUXnAOmp9EpKQtGpZuREQauT4T+YK2dgTMmkWDpS0w7rr74zp3eMqEEQRejgH /erYvWKDT9rVLuhViNlZBIM8UZWDPQdoQrNxX+fe5lkZVFt9sugVlavYfvkJPHtD5DjOUqw73c06b mHDR+92ubvMc7MXfP/zX4XlaxrodoX9JEnKjIhedNQpIS6mOfSkcAictAajuYva1OGuN6Rc5CZmpx XMrarDUqylBvFi5o/7Sw==; 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 1hsAaS-0004US-BZ; Mon, 29 Jul 2019 18:41:32 +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 1hsAZP-0003fx-L9 for linux-amlogic@lists.infradead.org; Mon, 29 Jul 2019 18:40:31 +0000 Received: by mail-wr1-x441.google.com with SMTP id g17so62952634wrr.5 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=pOnP2CpMvKML8u92yTt0PT1/cVUKyINnT4YbfzWs0MRLArWCUsf/GfWpLaF75oY/XH ye4BeMx9QqQQHVeqjswKn2FQaVDrS8ft+pZX5OpIvLpv7xm68Pd9VcacQKlcVMKZhT8m cOLPppnmNygJtrs7GXYTC5D/EjL9xq/ExF0Gm9Mu8OTfl626M/GRHPIWKVvWu8Pddvq7 +byBwHBGJGQ06VX78T2cmGe54PrevMpAxgxsQk15A2zvJ0K+94ffoC9wgIYbpIJcmMwR L1RDhKSKyslIEEliTDrps1dFjLvTVUKlls1gHvXWRZgEhzhTax8sY/YgpKpWtPxSARbB kIAw== X-Gm-Message-State: APjAAAUcH+WHdBuIj/UyWbWAoenjHe5lS8gFSxDDYJfYX70tInZYxQYg dbYQ8KH8Ng9kNO2bNV47O7gc6w== 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_703470_EB2C20C7 X-CRM114-Status: GOOD ( 12.32 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=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: 11064353 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 E7CC0112C for ; Mon, 29 Jul 2019 18:40:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBC022675C for ; Mon, 29 Jul 2019 18:40:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF8E928555; Mon, 29 Jul 2019 18:40:52 +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 92F3F2675C for ; Mon, 29 Jul 2019 18:40:52 +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=RotS2ERQiKa6nA9/Be6hklPlpSXiB2AZ+f4lo2Z2Pe0=; b=bma3uvk5StjRTE vw52FhQzRu89HAmjqkvypohphJfYCHUJA+Fst7nIg3A7UO5lZfyat17DkJURTmsCL/AjpXp+FswkC lgVbAbLqDAl/ChXjeTjcKLoxy8qI3N6Qbdat/ADKN8hEtSHb6+3UYHes4UNiRU8O9fNvK56ZV6Def Hlm/KTiEuDysS3V5Ol3TO/FbIeETnGz6Gl9y46DDKmFr5nGSCnpAtjvcBSqKk5uMtO6EJm8w++Yd4 RePv3fb9iDQV/ScBhAknR5kDzIB3biTfaZA2sjqTlSdCMoJ2TrpEFGOvbi5mTlWrV96w5NTlSFMcT GFLvCBsdElB/5k7hZC2Q==; 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 1hsAZo-0003xz-3C; Mon, 29 Jul 2019 18:40:52 +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-0003gi-Qq for linux-amlogic@lists.infradead.org; Mon, 29 Jul 2019 18:40:30 +0000 Received: by mail-wm1-x342.google.com with SMTP id s3so54755973wms.2 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=awG+GZuuGdn/9a+mrBB1Oe2jJly4H5mJljBfIoHq+z+pwi613J7Tl0MAQIJ512ujhv ZjJcc1ctBoa599Rn9Ix3kdTHIlGWtPpguGY7lZxy8a6t0mY3kMBcqQaWVcfrjuxi9wYB xY9qo39vtRQ5Wk/UE6qM8gxeZ587W4GUjY5ul2sa66TZj9sWNZj7tLvABHFYNVR53ruT 3PTs69l4MOuqbgdQh89iM6ulzy856oWVtm+fj0Bagu5sFZ/eMTla4yZ90U31RTH/GuOT tZ3A5IiS5wAjzGnykN3uqqQT/6U7Ms2EPaRpDqptULBKp7CLrN4eglt3AWksPAJTw1/z mDAA== X-Gm-Message-State: APjAAAV0maVlx2yaLs9/vzW4pIjMlM9LMj+gr3iDhpejUKpG/C49qjuW Cgl9qAU/qFDgKlfpLQaUw4pH7g== 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_900264_F8A2B02D X-CRM114-Status: UNSURE ( 9.97 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=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: 11064363 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 3E8FA912 for ; Mon, 29 Jul 2019 18:41:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33D1F2874A for ; Mon, 29 Jul 2019 18:41:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 277242871A; Mon, 29 Jul 2019 18:41:49 +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 BEE9C2872E for ; Mon, 29 Jul 2019 18:41:48 +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=1bvfKci9d0kSOESXF3X98Hpi/1pHfp4OYP+O5XCUMWg=; b=aJMLNX+Ap7mMvp rYrUKl/DVwWR8p4qWFwSoTI3jjcJ0jnGrgZcCPKWEaMKk+ANz3ZjKD4cECVqJvz7SakGsmCOPsJgt HOoaWmeuoIzUvTdUl3zSN+CkBJNb8o6sHuPdXD3cafM9HHfYtAlIoqOb6lFmRUi7n1xSFuwsZVqA8 O+VBnZaXHjWLBmjOGmK6N+/KtmW6Bp/WjK7Tz2L2p7U17HGx44ElypL3OeBPVK1cpHkxQLbUJxV6E ADnARu38nkiNP921a405FcQDX15wv2+n51SVqZcuiXAZZ6/3M0CjwJSqXH90KMP2DkOtkvsAm+3iY ndpHhRUoawM4uYBZ9jaw==; 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 1hsAai-0004kS-Bg; Mon, 29 Jul 2019 18:41:48 +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-0003hG-SQ for linux-amlogic@lists.infradead.org; Mon, 29 Jul 2019 18:40:32 +0000 Received: by mail-wr1-x443.google.com with SMTP id p17so62932202wrf.11 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=sGmHKKALAklgeF7rvJWFJd10D8BFslldhMCyEggJHVMizs9q1A9lnCAjdQCXgvEx00 612DwmI2RMx8iiAy+mqzyufBriGc8iDZbKf4g1W1QkOrLLswOyGZfGTjGBd2D3wV4EdD x05X0NqpduqL73kaohL/QvShDBaiX7XcylfbIYteEPl8QdnHTa3MhfrXtf3H7j/6ECFc uLcdDDHnl+s8gUA0YUsM9kYDtQfe8PSaETaGXqGj6xlmVFgI9+VT4ulwO6FJTHhj5E2a Gz+YPP+Ze2R8/fa02BXVFLIzH9abPDGu+EcSLxJYdut2OWk44Ibyj67EErYaFm7JxQZC touA== X-Gm-Message-State: APjAAAWeICbO8ZPSxlcuxRfnJCGnjSJdmCjrixx8m1UdxluHhsnjL+K0 enjRczS++9OprdH+cCvbU53x9w== 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_081221_36CC72F3 X-CRM114-Status: UNSURE ( 9.57 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=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: 11064371 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 9E9EE912 for ; Mon, 29 Jul 2019 18:42:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 916E5285D8 for ; Mon, 29 Jul 2019 18:42:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85C022873F; Mon, 29 Jul 2019 18:42:34 +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 CE8BF285D8 for ; Mon, 29 Jul 2019 18:42:33 +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=zylUJghwihkVvmXaW2wqWYbGe2Zr2uI9rxIF4ZyDIRw=; b=h9ngcq+awBN923 Dz6sH9YxpXSc5DkGnNijCloXBj4TN9/xaeIuzcCixy9dRT+jjuIwT32TfgzTByit0J2bkZINS146/ e/6wSEx94vFCumEUsSn8pxe9lDCQCop4dE27EZaTIBWF5of/HN3h9V+EkbRgz/eSlXU0ysLgkYlx0 LioEN88SEQYmJznsZQshbZ498S25CUHYuAKDjZY+hVVZQ2eiWiNOsxt/OI2hoiDI5Gs2LKH9jdSeV ZZ2Vrn47oQOypxfHd/IxFgNCZTea1SVgd8F5ogoNWYpnfiIdQG71RNZzL7M37WItmczruMx+en1Hn pvk0hcZ0yCyBoJwZEuZg==; 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 1hsAbQ-0005Ik-Uu; Mon, 29 Jul 2019 18:42:33 +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 1hsAZS-0003i5-Q3 for linux-amlogic@lists.infradead.org; Mon, 29 Jul 2019 18:40:33 +0000 Received: by mail-wr1-x444.google.com with SMTP id f9so62922321wre.12 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=mj7Uh3e3cCcBiAQH31K2mm6GwbRqHkJy/gvK0uBpGcdZwlh1Aqt67yX4q6ClMLwmMv zOp5PGQ+StsaT4/IPQwYwJVPkWWB6NLBr5Vo7Lfj05ox2v/l8jPaTIFigQBbKEjlruDX w/219+9wxMZQo6NZTiF0YPBIyfELPEoqfrm3hMF1fMjTJvm20JKhe7/0bJypP0WFbovu eIRhh3s883Kt5bGqywE4jCChHDkVfAJzvB2FsvNNAtLhruXVfBs7eLYJv3rxxq8CVJJn R6Jqwmu1TjjbNscGA0kZaQ7BbwTt4WbVgopItQ0rg6QPx0OeOEbhKl3tBbhQc7yeqfW+ 2U6A== X-Gm-Message-State: APjAAAWaIvs+nSkMTEl+hyMbEdKd+skp/C4Vmc5V3/qas1TlgRpvTh2J oj2QFu7CMJfAFQtDhJOfwzXliA== 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_114031_023959_A9E4240B X-CRM114-Status: GOOD ( 21.43 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=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: 11064373 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 BD65E112C for ; Mon, 29 Jul 2019 18:42:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1FB62873D for ; Mon, 29 Jul 2019 18:42:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6A7F2873F; Mon, 29 Jul 2019 18:42:36 +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 5C3ED2873D for ; Mon, 29 Jul 2019 18:42:36 +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=ix/BUONTiKyL444/D9oEntyt38q6Fxq1WMmhaPxqs4c=; b=lIJrA7IWadgMTc 1q4USTMuKIDESo0qyo9Ukz96mdUV1N3blfM3JGzUdXgPDfc8yv87kzIFScAwYTXon6dtCBylL+M06 k0oS3jdyDFrhehvzKxCEGhLrhU2KoYUEAEdA+mRyuiHdPmylIEjtzLkI/iugKjbYMCFlNZxK1tLAo PXoZVCyVdMstQ9oUfybyxlikwwobjMSbOERQCeWK+2ZKDxmz1RUaGBgNV5hyvAYDjczz0CBaFewMe qAOmthR2EeIEJkApu8YRGgOhOzmeYH7GZSK1WUkIj29+k4pJlDHjCwXNf9XgAvprGptBC5+X0GP21 XKlH7nZPgTyK8rsP6CRg==; 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 1hsAbT-0005LR-R8; Mon, 29 Jul 2019 18:42:35 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hsAZU-0003im-5g for linux-amlogic@lists.infradead.org; Mon, 29 Jul 2019 18:40:33 +0000 Received: by mail-wr1-x442.google.com with SMTP id y4so62963140wrm.2 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=ppWktvmHvRvrUppIUNM98sbOurSdOVc386Lwtw8hdTrGJJKlA41j4qX6onRhZ4PyUU UK75Brv7bK9BZ4AvV7KqIjTqrrD0jr0lItdqupbdA59bNPfTE1tLruBsedGlyzgeRDRw QYlU//NAs9LNDU6h5g5ErAVMiObO86Rxw127JQtj1WGCsOMhE5Y14/3ZJ5hKsDo1JVz6 tEHjg0P83mKys3ySS2nGAQkquLuDlhwq0KoTfw+8Zass9Ml+OuBaBqHPi3XlOKTNvlj6 divqkn8XAkJl4akELRRAYZ6zBRJI7BlxhoJT0+TqruAAWF8We33PuNnUWZHLy0zko8id x3Yw== X-Gm-Message-State: APjAAAU+UML4mDQHj7qoTcBzBRaMgFp637zdB2qQyGkeZ2X9NdWnf7yj UbTN73hoq/3+JQ0lrjhvKoRibg== 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_114032_358798_54ABF6A9 X-CRM114-Status: UNSURE ( 9.32 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=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 {