aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorAlex Porosanu <alexandru.porosanu@freescale.com>2012-07-10 23:06:11 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2012-07-10 23:06:11 -0400
commit82c2f9607b8a4667e9d89613478748f4e2b7288b (patch)
tree82c0f202ebc2f7639af6dc28fd4fe25725985187 /drivers/crypto
parent1af8ea862c9a9a6d5dc100850036cc7a641bb242 (diff)
crypto: caam - ERA retrieval and printing for SEC device
This patch adds support for retrieving and printing of SEC ERA information. It is useful for knowing beforehand what features exist from the SEC point of view on a certain SoC. Only era-s 1 to 4 are currently supported; other eras will appear as unknown. Signed-off-by: Alex Porosanu <alexandru.porosanu@freescale.com> - rebased onto current cryptodev master - made caam_eras static Signed-off-by: Kim Phillips <kim.phillips@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/caam/ctrl.c41
-rw-r--r--drivers/crypto/caam/ctrl.h13
-rw-r--r--drivers/crypto/caam/regs.h6
3 files changed, 58 insertions, 2 deletions
diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
index ac6abb375c8d..414ba20c05a1 100644
--- a/drivers/crypto/caam/ctrl.c
+++ b/drivers/crypto/caam/ctrl.c
@@ -11,6 +11,7 @@
11#include "jr.h" 11#include "jr.h"
12#include "desc_constr.h" 12#include "desc_constr.h"
13#include "error.h" 13#include "error.h"
14#include "ctrl.h"
14 15
15static int caam_remove(struct platform_device *pdev) 16static int caam_remove(struct platform_device *pdev)
16{ 17{
@@ -155,10 +156,44 @@ static void kick_trng(struct platform_device *pdev)
155 clrbits32(&r4tst->rtmctl, RTMCTL_PRGM); 156 clrbits32(&r4tst->rtmctl, RTMCTL_PRGM);
156} 157}
157 158
159/**
160 * caam_get_era() - Return the ERA of the SEC on SoC, based
161 * on the SEC_VID register.
162 * Returns the ERA number (1..4) or -ENOTSUPP if the ERA is unknown.
163 * @caam_id - the value of the SEC_VID register
164 **/
165int caam_get_era(u64 caam_id)
166{
167 struct sec_vid *sec_vid = (struct sec_vid *)&caam_id;
168 static const struct {
169 u16 ip_id;
170 u8 maj_rev;
171 u8 era;
172 } caam_eras[] = {
173 {0x0A10, 1, 1},
174 {0x0A10, 2, 2},
175 {0x0A12, 1, 3},
176 {0x0A14, 1, 3},
177 {0x0A14, 2, 4},
178 {0x0A16, 1, 4},
179 {0x0A11, 1, 4}
180 };
181 int i;
182
183 for (i = 0; i < ARRAY_SIZE(caam_eras); i++)
184 if (caam_eras[i].ip_id == sec_vid->ip_id &&
185 caam_eras[i].maj_rev == sec_vid->maj_rev)
186 return caam_eras[i].era;
187
188 return -ENOTSUPP;
189}
190EXPORT_SYMBOL(caam_get_era);
191
158/* Probe routine for CAAM top (controller) level */ 192/* Probe routine for CAAM top (controller) level */
159static int caam_probe(struct platform_device *pdev) 193static int caam_probe(struct platform_device *pdev)
160{ 194{
161 int ret, ring, rspec; 195 int ret, ring, rspec;
196 u64 caam_id;
162 struct device *dev; 197 struct device *dev;
163 struct device_node *nprop, *np; 198 struct device_node *nprop, *np;
164 struct caam_ctrl __iomem *ctrl; 199 struct caam_ctrl __iomem *ctrl;
@@ -276,9 +311,11 @@ static int caam_probe(struct platform_device *pdev)
276 /* Initialize queue allocator lock */ 311 /* Initialize queue allocator lock */
277 spin_lock_init(&ctrlpriv->jr_alloc_lock); 312 spin_lock_init(&ctrlpriv->jr_alloc_lock);
278 313
314 caam_id = rd_reg64(&topregs->ctrl.perfmon.caam_id);
315
279 /* Report "alive" for developer to see */ 316 /* Report "alive" for developer to see */
280 dev_info(dev, "device ID = 0x%016llx\n", 317 dev_info(dev, "device ID = 0x%016llx (Era %d)\n", caam_id,
281 rd_reg64(&topregs->ctrl.perfmon.caam_id)); 318 caam_get_era(caam_id));
282 dev_info(dev, "job rings = %d, qi = %d\n", 319 dev_info(dev, "job rings = %d, qi = %d\n",
283 ctrlpriv->total_jobrs, ctrlpriv->qi_present); 320 ctrlpriv->total_jobrs, ctrlpriv->qi_present);
284 321
diff --git a/drivers/crypto/caam/ctrl.h b/drivers/crypto/caam/ctrl.h
new file mode 100644
index 000000000000..980d44eaaf40
--- /dev/null
+++ b/drivers/crypto/caam/ctrl.h
@@ -0,0 +1,13 @@
1/*
2 * CAAM control-plane driver backend public-level include definitions
3 *
4 * Copyright 2012 Freescale Semiconductor, Inc.
5 */
6
7#ifndef CTRL_H
8#define CTRL_H
9
10/* Prototypes for backend-level services exposed to APIs */
11int caam_get_era(u64 caam_id);
12
13#endif /* CTRL_H */
diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h
index 6d9f1d982970..3223fc6d647c 100644
--- a/drivers/crypto/caam/regs.h
+++ b/drivers/crypto/caam/regs.h
@@ -117,6 +117,12 @@ struct jr_outentry {
117#define CHA_NUM_DECONUM_SHIFT 56 117#define CHA_NUM_DECONUM_SHIFT 56
118#define CHA_NUM_DECONUM_MASK (0xfull << CHA_NUM_DECONUM_SHIFT) 118#define CHA_NUM_DECONUM_MASK (0xfull << CHA_NUM_DECONUM_SHIFT)
119 119
120struct sec_vid {
121 u16 ip_id;
122 u8 maj_rev;
123 u8 min_rev;
124};
125
120struct caam_perfmon { 126struct caam_perfmon {
121 /* Performance Monitor Registers f00-f9f */ 127 /* Performance Monitor Registers f00-f9f */
122 u64 req_dequeued; /* PC_REQ_DEQ - Dequeued Requests */ 128 u64 req_dequeued; /* PC_REQ_DEQ - Dequeued Requests */