mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-20 22:23:27 +00:00
123 lines
3.5 KiB
Diff
123 lines
3.5 KiB
Diff
|
From 20f552cafd7dda6f5d25128bbc04ea2c91d9f5d1 Mon Sep 17 00:00:00 2001
|
||
|
From: Radu Alexe <radu.alexe@nxp.com>
|
||
|
Date: Thu, 26 Oct 2017 10:45:14 +0300
|
||
|
Subject: [PATCH] crypto: caam - add functionality used by the caam_dma driver
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
The caam_dma is a memcpy DMA driver based on the DMA functionality of
|
||
|
the CAAM hardware block. It creates a DMA channel for each JR of the
|
||
|
CAAM. This patch adds functionality that is used by the caam_dma that is
|
||
|
not yet part of the JR driver.
|
||
|
|
||
|
Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
|
||
|
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
|
||
|
---
|
||
|
drivers/crypto/caam/desc.h | 2 ++
|
||
|
drivers/crypto/caam/jr.c | 41 +++++++++++++++++++++++++++++++++++++++++
|
||
|
drivers/crypto/caam/jr.h | 2 ++
|
||
|
3 files changed, 45 insertions(+)
|
||
|
|
||
|
--- a/drivers/crypto/caam/desc.h
|
||
|
+++ b/drivers/crypto/caam/desc.h
|
||
|
@@ -364,6 +364,7 @@
|
||
|
#define FIFOLD_TYPE_PK_N (0x08 << FIFOLD_TYPE_SHIFT)
|
||
|
#define FIFOLD_TYPE_PK_A (0x0c << FIFOLD_TYPE_SHIFT)
|
||
|
#define FIFOLD_TYPE_PK_B (0x0d << FIFOLD_TYPE_SHIFT)
|
||
|
+#define FIFOLD_TYPE_IFIFO (0x0f << FIFOLD_TYPE_SHIFT)
|
||
|
|
||
|
/* Other types. Need to OR in last/flush bits as desired */
|
||
|
#define FIFOLD_TYPE_MSG_MASK (0x38 << FIFOLD_TYPE_SHIFT)
|
||
|
@@ -1522,6 +1523,7 @@
|
||
|
#define MATH_SRC1_INFIFO (0x0a << MATH_SRC1_SHIFT)
|
||
|
#define MATH_SRC1_OUTFIFO (0x0b << MATH_SRC1_SHIFT)
|
||
|
#define MATH_SRC1_ONE (0x0c << MATH_SRC1_SHIFT)
|
||
|
+#define MATH_SRC1_ZERO (0x0f << MATH_SRC1_SHIFT)
|
||
|
|
||
|
/* Destination selectors */
|
||
|
#define MATH_DEST_SHIFT 8
|
||
|
--- a/drivers/crypto/caam/jr.c
|
||
|
+++ b/drivers/crypto/caam/jr.c
|
||
|
@@ -62,6 +62,14 @@ algs_unlock:
|
||
|
mutex_unlock(&algs_lock);
|
||
|
}
|
||
|
|
||
|
+static int jr_driver_probed;
|
||
|
+
|
||
|
+int caam_jr_driver_probed(void)
|
||
|
+{
|
||
|
+ return jr_driver_probed;
|
||
|
+}
|
||
|
+EXPORT_SYMBOL(caam_jr_driver_probed);
|
||
|
+
|
||
|
static int caam_reset_hw_jr(struct device *dev)
|
||
|
{
|
||
|
struct caam_drv_private_jr *jrp = dev_get_drvdata(dev);
|
||
|
@@ -147,6 +155,8 @@ static int caam_jr_remove(struct platfor
|
||
|
if (ret)
|
||
|
dev_err(jrdev, "Failed to shut down job ring\n");
|
||
|
|
||
|
+ jr_driver_probed--;
|
||
|
+
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
@@ -311,6 +321,36 @@ struct device *caam_jr_alloc(void)
|
||
|
EXPORT_SYMBOL(caam_jr_alloc);
|
||
|
|
||
|
/**
|
||
|
+ * caam_jridx_alloc() - Alloc a specific job ring based on its index.
|
||
|
+ *
|
||
|
+ * returns : pointer to the newly allocated physical
|
||
|
+ * JobR dev can be written to if successful.
|
||
|
+ **/
|
||
|
+struct device *caam_jridx_alloc(int idx)
|
||
|
+{
|
||
|
+ struct caam_drv_private_jr *jrpriv;
|
||
|
+ struct device *dev = ERR_PTR(-ENODEV);
|
||
|
+
|
||
|
+ spin_lock(&driver_data.jr_alloc_lock);
|
||
|
+
|
||
|
+ if (list_empty(&driver_data.jr_list))
|
||
|
+ goto end;
|
||
|
+
|
||
|
+ list_for_each_entry(jrpriv, &driver_data.jr_list, list_node) {
|
||
|
+ if (jrpriv->ridx == idx) {
|
||
|
+ atomic_inc(&jrpriv->tfm_count);
|
||
|
+ dev = jrpriv->dev;
|
||
|
+ break;
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
+end:
|
||
|
+ spin_unlock(&driver_data.jr_alloc_lock);
|
||
|
+ return dev;
|
||
|
+}
|
||
|
+EXPORT_SYMBOL(caam_jridx_alloc);
|
||
|
+
|
||
|
+/**
|
||
|
* caam_jr_free() - Free the Job Ring
|
||
|
* @rdev - points to the dev that identifies the Job ring to
|
||
|
* be released.
|
||
|
@@ -565,6 +605,7 @@ static int caam_jr_probe(struct platform
|
||
|
device_set_wakeup_enable(&pdev->dev, false);
|
||
|
|
||
|
register_algs(jrdev->parent);
|
||
|
+ jr_driver_probed++;
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
--- a/drivers/crypto/caam/jr.h
|
||
|
+++ b/drivers/crypto/caam/jr.h
|
||
|
@@ -9,7 +9,9 @@
|
||
|
#define JR_H
|
||
|
|
||
|
/* Prototypes for backend-level services exposed to APIs */
|
||
|
+int caam_jr_driver_probed(void);
|
||
|
struct device *caam_jr_alloc(void);
|
||
|
+struct device *caam_jridx_alloc(int idx);
|
||
|
void caam_jr_free(struct device *rdev);
|
||
|
int caam_jr_enqueue(struct device *dev, u32 *desc,
|
||
|
void (*cbk)(struct device *dev, u32 *desc, u32 status,
|