* [PATCH v2 0/2] add optional cache params override from DT
@ 2020-11-11 14:11 Gilad Ben-Yossef
2020-11-11 14:11 ` [PATCH v2 1/2] dt-bindings: crypto: update ccree optional params Gilad Ben-Yossef
2020-11-11 14:11 ` [PATCH v2 2/2] crypto: ccree - add custom cache params from DT file Gilad Ben-Yossef
0 siblings, 2 replies; 3+ messages in thread
From: Gilad Ben-Yossef @ 2020-11-11 14:11 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, Rob Herring
Cc: Ofir Drang, linux-crypto, devicetree, linux-kernel
Rework the setting of cache parameters, including
optionally allowing overiding the defaults from device tree
Changes from v1:
- As per Rob Herring's suggestions, lose the distinction between
read and write and limit options to a few that make sense.
Also use strings to make the meaning of the setting clearer.
Gilad Ben-Yossef (2):
dt-bindings: crypto: update ccree optional params
crypto: ccree - add custom cache params from DT file
.../bindings/crypto/arm-cryptocell.txt | 4 +
drivers/crypto/ccree/cc_driver.c | 100 +++++++++++++++---
drivers/crypto/ccree/cc_driver.h | 4 +-
drivers/crypto/ccree/cc_pm.c | 2 +-
4 files changed, 92 insertions(+), 18 deletions(-)
--
2.29.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/2] dt-bindings: crypto: update ccree optional params
2020-11-11 14:11 [PATCH v2 0/2] add optional cache params override from DT Gilad Ben-Yossef
@ 2020-11-11 14:11 ` Gilad Ben-Yossef
2020-11-11 14:11 ` [PATCH v2 2/2] crypto: ccree - add custom cache params from DT file Gilad Ben-Yossef
1 sibling, 0 replies; 3+ messages in thread
From: Gilad Ben-Yossef @ 2020-11-11 14:11 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, Rob Herring
Cc: Ofir Drang, Rob Herring, linux-crypto, devicetree, linux-kernel
Document ccree driver supporting new optional parameters allowing to
override cache parameters.
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Cc: Rob Herring <robh@kernel.org>
---
Documentation/devicetree/bindings/crypto/arm-cryptocell.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt b/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt
index 6130e6eb4af8..fb4ba4a3af4c 100644
--- a/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt
+++ b/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt
@@ -13,6 +13,10 @@ Required properties:
Optional properties:
- clocks: Reference to the crypto engine clock.
- dma-coherent: Present if dma operations are coherent.
+- cache-attributes: override default cache attributes with "write-through" or "write-back".
+ Default is write through, write allocate.
+- sharability-domain: override default cache sharability domain with "inner-sharable".
+ Default is outer-sharable (712, 703, 713 only).
Examples:
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] crypto: ccree - add custom cache params from DT file
2020-11-11 14:11 [PATCH v2 0/2] add optional cache params override from DT Gilad Ben-Yossef
2020-11-11 14:11 ` [PATCH v2 1/2] dt-bindings: crypto: update ccree optional params Gilad Ben-Yossef
@ 2020-11-11 14:11 ` Gilad Ben-Yossef
1 sibling, 0 replies; 3+ messages in thread
From: Gilad Ben-Yossef @ 2020-11-11 14:11 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, Rob Herring
Cc: Ofir Drang, Rob Herring, linux-crypto, devicetree, linux-kernel
Add optinal ability to override cache parameters and
set new defaults.
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Cc: Rob Herring <robh@kernel.org>
---
drivers/crypto/ccree/cc_driver.c | 100 ++++++++++++++++++++++++++-----
drivers/crypto/ccree/cc_driver.h | 4 +-
drivers/crypto/ccree/cc_pm.c | 2 +-
3 files changed, 88 insertions(+), 18 deletions(-)
diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
index 6f519d3e896c..3064bd196ebc 100644
--- a/drivers/crypto/ccree/cc_driver.c
+++ b/drivers/crypto/ccree/cc_driver.c
@@ -100,6 +100,82 @@ 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;
+ const char *str;
+ 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);
+
+ if (drvdata->coherent) {
+
+ rc = of_property_read_string(np, "cache-attributes", &str);
+
+ if (rc && !strcmp(str, "write-through"))
+ val = 0x6;
+ else if (rc && !strcmp(str, "write-back"))
+ val = 0xa;
+ else
+ val = 0xb; /* Write-Back Write-Allocate */
+ } else {
+ /* Non-cacheable */
+ val = 0x2;
+ }
+
+ mask = CC_GENMASK(CC_AXIM_CACHE_PARAMS_AWCACHE);
+ cache_params &= ~mask;
+ cache_params |= FIELD_PREP(mask, val);
+
+ mask = CC_GENMASK(CC_AXIM_CACHE_PARAMS_AWCACHE_LAST);
+ cache_params &= ~mask;
+ cache_params |= FIELD_PREP(mask, val);
+
+ 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);
+
+ if (drvdata->coherent) {
+
+ rc = of_property_read_string(np, "sharability-domain", &str);
+
+ if (rc && !strcmp(str, "inner"))
+ val = 0x1;
+ else
+ val = 0x2; /* Outer Sharable */
+ } else {
+ /* System */
+ val = 0x3;
+ }
+
+ mask = CC_GENMASK(CC_AXIM_ACE_CONST_ARDOMAIN);
+ ace_const &= ~mask;
+ ace_const |= FIELD_PREP(mask, val);
+
+ 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 +294,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 +321,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 +511,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;
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-11 14:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11 14:11 [PATCH v2 0/2] add optional cache params override from DT Gilad Ben-Yossef
2020-11-11 14:11 ` [PATCH v2 1/2] dt-bindings: crypto: update ccree optional params Gilad Ben-Yossef
2020-11-11 14:11 ` [PATCH v2 2/2] crypto: ccree - add custom cache params from DT file Gilad Ben-Yossef
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.