From patchwork Wed Sep 16 07:19:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 312177 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp213011ilg; Wed, 16 Sep 2020 00:20:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgRveRcXunskyr84JudxzdXXVJDE5ZeHXgbsVWkEVGkb+T5P/6O5kgT4lYc79sEiThwlW1 X-Received: by 2002:a05:6402:17b6:: with SMTP id j22mr25114911edy.377.1600240824121; Wed, 16 Sep 2020 00:20:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600240824; cv=none; d=google.com; s=arc-20160816; b=Pna1LWYCdBMlMoXXwswt51WG+qfHX3Q3aa1qAuVkgAg0Pclp4FsaK+hoNvlXSiKLZK xPgXEXW71Dlr9fWCC80x+hvfbMht86Z8mMSnuT2K2l39gkhNrjA4Dtblshy45oDJnohh 6QAuG2UEfJYtRxgLuK8EmM045WjZMBmxgrX6Hc4/scN95iCeC6r4c4MeNZPdaVBVCG3w V+zjDBj4tGMl5XOzxD8eLmHgi3O4BGBzhq/pJIxFKGOu93kkHMPeS+etOGQzVjatQioQ oHuQs8lLL+Mxj7fPLjcS/L/OIFKcKD/XMEoOFBauFCpI3Xc9mzvnbJcjV7tMp4gnzltT yMAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/gxwyjFs6D662fHI3y+qhXD/hJsiuTKifFSkYrdSyIw=; b=x/VywVyW7XOJMs9Fml75ESqPM0N8LU2DaqPdXa9yW7Sff2yiwWrqQkp8kNvx+7DCca 5FhAoh2RhfRSG+TgcV5efW7epwpn+gYIey1t5zHLxe3O3utpPXM8T9gQ0wXukdBSxGqk dLITendiGc/LX4F/TrcOBM8ITcOWnCAbxGVFb7DmUZHNoPda3QCSDEZztKuGtgnsz772 55A2rBw5OPHMr+5nSsYV7eOBvg8SaRsUBUipSQxAslep73UDbkb4JQs+LcxrOhj1TH8p k6Vs5bg0SRndj0dpT2OdOvWE8tn5PgUBk/h2/lqUDKXBUW5gGY4vQi0iFjoLSmJKVxQo bqug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 18si12413586edv.195.2020.09.16.00.20.23; Wed, 16 Sep 2020 00:20:24 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726196AbgIPHUR (ORCPT + 6 others); Wed, 16 Sep 2020 03:20:17 -0400 Received: from foss.arm.com ([217.140.110.172]:54798 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726068AbgIPHUO (ORCPT ); Wed, 16 Sep 2020 03:20:14 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1C08A11D4; Wed, 16 Sep 2020 00:20:13 -0700 (PDT) Received: from e110176-lin.kfn.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 795943F68F; Wed, 16 Sep 2020 00:20:11 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Rob Herring Cc: Ofir Drang , linux-crypto@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] crypto: ccree - add custom cache params from DT file Date: Wed, 16 Sep 2020 10:19:50 +0300 Message-Id: <20200916071950.1493-3-gilad@benyossef.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200916071950.1493-1-gilad@benyossef.com> References: <20200916071950.1493-1-gilad@benyossef.com> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add optinal ability to customize DMA transactions cache parameters and ACE bus sharability properties and set new defaults. Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/ccree/cc_driver.c | 89 ++++++++++++++++++++++++++------ drivers/crypto/ccree/cc_driver.h | 4 +- drivers/crypto/ccree/cc_pm.c | 2 +- 3 files changed, 77 insertions(+), 18 deletions(-) -- 2.27.0 diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c index 6f519d3e896c..db497bc065d4 100644 --- a/drivers/crypto/ccree/cc_driver.c +++ b/drivers/crypto/ccree/cc_driver.c @@ -100,6 +100,71 @@ static const struct of_device_id arm_ccree_dev_of_match[] = { }; MODULE_DEVICE_TABLE(of, arm_ccree_dev_of_match); +static void init_cc_dt_params(struct cc_drvdata *drvdata) +{ + struct device *dev = drvdata_to_dev(drvdata); + struct device_node *np = dev->of_node; + u32 cache_params, ace_const, val, mask; + int rc; + + /* register CC_AXIM_CACHE_PARAMS */ + cache_params = cc_ioread(drvdata, CC_REG(AXIM_CACHE_PARAMS)); + dev_dbg(dev, "Cache params previous: 0x%08X\n", cache_params); + + rc = of_property_read_u32(np, "awcache", &val); + if (rc) + val = (drvdata->coherent ? 0xb : 0x2); + + mask = CC_GENMASK(CC_AXIM_CACHE_PARAMS_AWCACHE); + cache_params &= ~mask; + cache_params |= FIELD_PREP(mask, val); + + /* write AWCACHE also to AWCACHE_LAST */ + mask = CC_GENMASK(CC_AXIM_CACHE_PARAMS_AWCACHE_LAST); + cache_params &= ~mask; + cache_params |= FIELD_PREP(mask, val); + + rc = of_property_read_u32(np, "arcache", &val); + if (rc) + val = (drvdata->coherent ? 0xb : 0x2); + + mask = CC_GENMASK(CC_AXIM_CACHE_PARAMS_ARCACHE); + cache_params &= ~mask; + cache_params |= FIELD_PREP(mask, val); + + drvdata->cache_params = cache_params; + + dev_dbg(dev, "Cache params current: 0x%08X\n", cache_params); + + if (drvdata->hw_rev <= CC_HW_REV_710) + return; + + /* register CC_AXIM_ACE_CONST */ + ace_const = cc_ioread(drvdata, CC_REG(AXIM_ACE_CONST)); + dev_dbg(dev, "ACE-const previous: 0x%08X\n", ace_const); + + rc = of_property_read_u32(np, "ardomain", &val); + ace_const = cc_ioread(drvdata, CC_REG(AXIM_ACE_CONST)); + if (rc) + val = (drvdata->coherent ? 0x2 : 0x3); + + mask = CC_GENMASK(CC_AXIM_ACE_CONST_ARDOMAIN); + ace_const &= ~mask; + ace_const |= FIELD_PREP(mask, val); + + rc = of_property_read_u32(np, "awdomain", &val); + if (rc) + val = (drvdata->coherent ? 0x2 : 0x3); + + mask = CC_GENMASK(CC_AXIM_ACE_CONST_AWDOMAIN); + ace_const &= ~mask; + ace_const |= FIELD_PREP(mask, val); + + dev_dbg(dev, "ACE-const current: 0x%08X\n", ace_const); + + drvdata->ace_const = ace_const; +} + static u32 cc_read_idr(struct cc_drvdata *drvdata, const u32 *idr_offsets) { int i; @@ -218,9 +283,9 @@ bool cc_wait_for_reset_completion(struct cc_drvdata *drvdata) return false; } -int init_cc_regs(struct cc_drvdata *drvdata, bool is_probe) +int init_cc_regs(struct cc_drvdata *drvdata) { - unsigned int val, cache_params; + unsigned int val; struct device *dev = drvdata_to_dev(drvdata); /* Unmask all AXI interrupt sources AXI_CFG1 register */ @@ -245,19 +310,9 @@ int init_cc_regs(struct cc_drvdata *drvdata, bool is_probe) cc_iowrite(drvdata, CC_REG(HOST_IMR), ~val); - cache_params = (drvdata->coherent ? CC_COHERENT_CACHE_PARAMS : 0x0); - - val = cc_ioread(drvdata, CC_REG(AXIM_CACHE_PARAMS)); - - if (is_probe) - dev_dbg(dev, "Cache params previous: 0x%08X\n", val); - - cc_iowrite(drvdata, CC_REG(AXIM_CACHE_PARAMS), cache_params); - val = cc_ioread(drvdata, CC_REG(AXIM_CACHE_PARAMS)); - - if (is_probe) - dev_dbg(dev, "Cache params current: 0x%08X (expect: 0x%08X)\n", - val, cache_params); + cc_iowrite(drvdata, CC_REG(AXIM_CACHE_PARAMS), drvdata->cache_params); + if (drvdata->hw_rev >= CC_HW_REV_712) + cc_iowrite(drvdata, CC_REG(AXIM_ACE_CONST), drvdata->ace_const); return 0; } @@ -445,7 +500,9 @@ static int init_cc_resources(struct platform_device *plat_dev) } dev_dbg(dev, "Registered to IRQ: %d\n", irq); - rc = init_cc_regs(new_drvdata, true); + init_cc_dt_params(new_drvdata); + + rc = init_cc_regs(new_drvdata); if (rc) { dev_err(dev, "init_cc_regs failed\n"); goto post_pm_err; diff --git a/drivers/crypto/ccree/cc_driver.h b/drivers/crypto/ccree/cc_driver.h index af77b2020350..cd5a51e8a281 100644 --- a/drivers/crypto/ccree/cc_driver.h +++ b/drivers/crypto/ccree/cc_driver.h @@ -155,6 +155,8 @@ struct cc_drvdata { int std_bodies; bool sec_disabled; u32 comp_mask; + u32 cache_params; + u32 ace_const; }; struct cc_crypto_alg { @@ -205,7 +207,7 @@ static inline void dump_byte_array(const char *name, const u8 *the_array, } bool cc_wait_for_reset_completion(struct cc_drvdata *drvdata); -int init_cc_regs(struct cc_drvdata *drvdata, bool is_probe); +int init_cc_regs(struct cc_drvdata *drvdata); void fini_cc_regs(struct cc_drvdata *drvdata); unsigned int cc_get_default_hash_len(struct cc_drvdata *drvdata); diff --git a/drivers/crypto/ccree/cc_pm.c b/drivers/crypto/ccree/cc_pm.c index 3c65bf070c90..d5421b0c6831 100644 --- a/drivers/crypto/ccree/cc_pm.c +++ b/drivers/crypto/ccree/cc_pm.c @@ -45,7 +45,7 @@ static int cc_pm_resume(struct device *dev) } cc_iowrite(drvdata, CC_REG(HOST_POWER_DOWN_EN), POWER_DOWN_DISABLE); - rc = init_cc_regs(drvdata, false); + rc = init_cc_regs(drvdata); if (rc) { dev_err(dev, "init_cc_regs (%x)\n", rc); return rc;