1 From 20f552cafd7dda6f5d25128bbc04ea2c91d9f5d1 Mon Sep 17 00:00:00 2001
2 From: Radu Alexe <radu.alexe@nxp.com>
3 Date: Thu, 26 Oct 2017 10:45:14 +0300
4 Subject: [PATCH] crypto: caam - add functionality used by the caam_dma driver
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 The caam_dma is a memcpy DMA driver based on the DMA functionality of
10 the CAAM hardware block. It creates a DMA channel for each JR of the
11 CAAM. This patch adds functionality that is used by the caam_dma that is
12 not yet part of the JR driver.
14 Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
15 Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
17 drivers/crypto/caam/desc.h | 2 ++
18 drivers/crypto/caam/jr.c | 41 +++++++++++++++++++++++++++++++++++++++++
19 drivers/crypto/caam/jr.h | 2 ++
20 3 files changed, 45 insertions(+)
22 --- a/drivers/crypto/caam/desc.h
23 +++ b/drivers/crypto/caam/desc.h
25 #define FIFOLD_TYPE_PK_N (0x08 << FIFOLD_TYPE_SHIFT)
26 #define FIFOLD_TYPE_PK_A (0x0c << FIFOLD_TYPE_SHIFT)
27 #define FIFOLD_TYPE_PK_B (0x0d << FIFOLD_TYPE_SHIFT)
28 +#define FIFOLD_TYPE_IFIFO (0x0f << FIFOLD_TYPE_SHIFT)
30 /* Other types. Need to OR in last/flush bits as desired */
31 #define FIFOLD_TYPE_MSG_MASK (0x38 << FIFOLD_TYPE_SHIFT)
33 #define MATH_SRC1_INFIFO (0x0a << MATH_SRC1_SHIFT)
34 #define MATH_SRC1_OUTFIFO (0x0b << MATH_SRC1_SHIFT)
35 #define MATH_SRC1_ONE (0x0c << MATH_SRC1_SHIFT)
36 +#define MATH_SRC1_ZERO (0x0f << MATH_SRC1_SHIFT)
38 /* Destination selectors */
39 #define MATH_DEST_SHIFT 8
40 --- a/drivers/crypto/caam/jr.c
41 +++ b/drivers/crypto/caam/jr.c
42 @@ -62,6 +62,14 @@ algs_unlock:
43 mutex_unlock(&algs_lock);
46 +static int jr_driver_probed;
48 +int caam_jr_driver_probed(void)
50 + return jr_driver_probed;
52 +EXPORT_SYMBOL(caam_jr_driver_probed);
54 static int caam_reset_hw_jr(struct device *dev)
56 struct caam_drv_private_jr *jrp = dev_get_drvdata(dev);
57 @@ -147,6 +155,8 @@ static int caam_jr_remove(struct platfor
59 dev_err(jrdev, "Failed to shut down job ring\n");
66 @@ -311,6 +321,36 @@ struct device *caam_jr_alloc(void)
67 EXPORT_SYMBOL(caam_jr_alloc);
70 + * caam_jridx_alloc() - Alloc a specific job ring based on its index.
72 + * returns : pointer to the newly allocated physical
73 + * JobR dev can be written to if successful.
75 +struct device *caam_jridx_alloc(int idx)
77 + struct caam_drv_private_jr *jrpriv;
78 + struct device *dev = ERR_PTR(-ENODEV);
80 + spin_lock(&driver_data.jr_alloc_lock);
82 + if (list_empty(&driver_data.jr_list))
85 + list_for_each_entry(jrpriv, &driver_data.jr_list, list_node) {
86 + if (jrpriv->ridx == idx) {
87 + atomic_inc(&jrpriv->tfm_count);
94 + spin_unlock(&driver_data.jr_alloc_lock);
97 +EXPORT_SYMBOL(caam_jridx_alloc);
100 * caam_jr_free() - Free the Job Ring
101 * @rdev - points to the dev that identifies the Job ring to
103 @@ -565,6 +605,7 @@ static int caam_jr_probe(struct platform
104 device_set_wakeup_enable(&pdev->dev, false);
106 register_algs(jrdev->parent);
107 + jr_driver_probed++;
111 --- a/drivers/crypto/caam/jr.h
112 +++ b/drivers/crypto/caam/jr.h
116 /* Prototypes for backend-level services exposed to APIs */
117 +int caam_jr_driver_probed(void);
118 struct device *caam_jr_alloc(void);
119 +struct device *caam_jridx_alloc(int idx);
120 void caam_jr_free(struct device *rdev);
121 int caam_jr_enqueue(struct device *dev, u32 *desc,
122 void (*cbk)(struct device *dev, u32 *desc, u32 status,