aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Lendacky <thomas.lendacky@amd.com>2014-07-10 11:58:35 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2014-07-23 09:28:38 -0400
commit126ae9adc1ec8d9006542f1a5e474b0183845e21 (patch)
treef3ee814b261aa440feae1b5785f797aaa16cced7
parent96956aef2ff5521af44d6cb896c967d025360ead (diff)
crypto: ccp - Base AXI DMA cache settings on device tree
The default cache operations for ARM64 were changed during 3.15. To use coherent operations a "dma-coherent" device tree property is required. If that property is not present in the device tree node then the non-coherent operations are assigned for the device. Add support to the ccp driver to assign the AXI DMA cache settings based on whether the "dma-coherent" property is present in the device node. If present, use settings that work with the caches. If not present, use settings that do not look at the caches. Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--Documentation/devicetree/bindings/crypto/amd-ccp.txt3
-rw-r--r--drivers/crypto/ccp/Kconfig1
-rw-r--r--drivers/crypto/ccp/ccp-dev.c2
-rw-r--r--drivers/crypto/ccp/ccp-dev.h4
-rw-r--r--drivers/crypto/ccp/ccp-platform.c6
5 files changed, 15 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/crypto/amd-ccp.txt b/Documentation/devicetree/bindings/crypto/amd-ccp.txt
index 6e0b11aa8995..8c61183b41e0 100644
--- a/Documentation/devicetree/bindings/crypto/amd-ccp.txt
+++ b/Documentation/devicetree/bindings/crypto/amd-ccp.txt
@@ -7,6 +7,9 @@ Required properties:
7 that services interrupts for this device 7 that services interrupts for this device
8- interrupts: Should contain the CCP interrupt 8- interrupts: Should contain the CCP interrupt
9 9
10Optional properties:
11- dma-coherent: Present if dma operations are coherent
12
10Example: 13Example:
11 ccp@e0100000 { 14 ccp@e0100000 {
12 compatible = "amd,ccp-seattle-v1a"; 15 compatible = "amd,ccp-seattle-v1a";
diff --git a/drivers/crypto/ccp/Kconfig b/drivers/crypto/ccp/Kconfig
index 7639ffc36c68..474382d50ec4 100644
--- a/drivers/crypto/ccp/Kconfig
+++ b/drivers/crypto/ccp/Kconfig
@@ -3,6 +3,7 @@ config CRYPTO_DEV_CCP_DD
3 depends on CRYPTO_DEV_CCP 3 depends on CRYPTO_DEV_CCP
4 default m 4 default m
5 select HW_RANDOM 5 select HW_RANDOM
6 select OF if ARM64
6 help 7 help
7 Provides the interface to use the AMD Cryptographic Coprocessor 8 Provides the interface to use the AMD Cryptographic Coprocessor
8 which can be used to accelerate or offload encryption operations 9 which can be used to accelerate or offload encryption operations
diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c
index fa1ab10f960f..a7d110652a74 100644
--- a/drivers/crypto/ccp/ccp-dev.c
+++ b/drivers/crypto/ccp/ccp-dev.c
@@ -364,7 +364,7 @@ int ccp_init(struct ccp_device *ccp)
364 364
365#ifdef CONFIG_ARM64 365#ifdef CONFIG_ARM64
366 /* For arm64 set the recommended queue cache settings */ 366 /* For arm64 set the recommended queue cache settings */
367 iowrite32(CACHE_WB_NO_ALLOC, ccp->io_regs + CMD_Q_CACHE_BASE + 367 iowrite32(ccp->axcache, ccp->io_regs + CMD_Q_CACHE_BASE +
368 (CMD_Q_CACHE_INC * i)); 368 (CMD_Q_CACHE_INC * i));
369#endif 369#endif
370 370
diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
index 1c5651b09506..62ff35a6b9ec 100644
--- a/drivers/crypto/ccp/ccp-dev.h
+++ b/drivers/crypto/ccp/ccp-dev.h
@@ -30,6 +30,7 @@
30 30
31#define TRNG_RETRIES 10 31#define TRNG_RETRIES 10
32 32
33#define CACHE_NONE 0x00
33#define CACHE_WB_NO_ALLOC 0xb7 34#define CACHE_WB_NO_ALLOC 0xb7
34 35
35 36
@@ -255,6 +256,9 @@ struct ccp_device {
255 /* Suspend support */ 256 /* Suspend support */
256 unsigned int suspending; 257 unsigned int suspending;
257 wait_queue_head_t suspend_queue; 258 wait_queue_head_t suspend_queue;
259
260 /* DMA caching attribute support */
261 unsigned int axcache;
258}; 262};
259 263
260 264
diff --git a/drivers/crypto/ccp/ccp-platform.c b/drivers/crypto/ccp/ccp-platform.c
index 65e58291c668..b0a2806908f1 100644
--- a/drivers/crypto/ccp/ccp-platform.c
+++ b/drivers/crypto/ccp/ccp-platform.c
@@ -22,6 +22,7 @@
22#include <linux/spinlock.h> 22#include <linux/spinlock.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/ccp.h> 24#include <linux/ccp.h>
25#include <linux/of.h>
25 26
26#include "ccp-dev.h" 27#include "ccp-dev.h"
27 28
@@ -112,6 +113,11 @@ static int ccp_platform_probe(struct platform_device *pdev)
112 *(dev->dma_mask) = DMA_BIT_MASK(48); 113 *(dev->dma_mask) = DMA_BIT_MASK(48);
113 dev->coherent_dma_mask = DMA_BIT_MASK(48); 114 dev->coherent_dma_mask = DMA_BIT_MASK(48);
114 115
116 if (of_property_read_bool(dev->of_node, "dma-coherent"))
117 ccp->axcache = CACHE_WB_NO_ALLOC;
118 else
119 ccp->axcache = CACHE_NONE;
120
115 dev_set_drvdata(dev, ccp); 121 dev_set_drvdata(dev, ccp);
116 122
117 ret = ccp_init(ccp); 123 ret = ccp_init(ccp);