aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/caam
diff options
context:
space:
mode:
authorAlex Porosanu <alexandru.porosanu@freescale.com>2014-02-06 03:27:19 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2014-02-08 20:59:27 -0500
commit883619a931e9f54fca7495321b339669f11cc727 (patch)
treeb4c2f370104a47d7792a950d47f52621bca696cf /drivers/crypto/caam
parentd167b6e1fb8ad386b17485ca88804d14f1695805 (diff)
crypto: caam - fix ERA retrieval function
SEC ERA has to be retrieved by reading the "fsl,sec-era" property from the device tree. This property is updated/filled in by u-boot. Signed-off-by: Alex Porosanu <alexandru.porosanu@freescale.com> Reviewed-by: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/caam')
-rw-r--r--drivers/crypto/caam/ctrl.c36
-rw-r--r--drivers/crypto/caam/ctrl.h2
2 files changed, 11 insertions, 27 deletions
diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
index 30f434fd5dec..1c38f86bf63a 100644
--- a/drivers/crypto/caam/ctrl.c
+++ b/drivers/crypto/caam/ctrl.c
@@ -14,7 +14,6 @@
14#include "jr.h" 14#include "jr.h"
15#include "desc_constr.h" 15#include "desc_constr.h"
16#include "error.h" 16#include "error.h"
17#include "ctrl.h"
18 17
19/* 18/*
20 * Descriptor to instantiate RNG State Handle 0 in normal mode and 19 * Descriptor to instantiate RNG State Handle 0 in normal mode and
@@ -352,32 +351,17 @@ static void kick_trng(struct platform_device *pdev, int ent_delay)
352 351
353/** 352/**
354 * caam_get_era() - Return the ERA of the SEC on SoC, based 353 * caam_get_era() - Return the ERA of the SEC on SoC, based
355 * on the SEC_VID register. 354 * on "sec-era" propery in the DTS. This property is updated by u-boot.
356 * Returns the ERA number (1..4) or -ENOTSUPP if the ERA is unknown.
357 * @caam_id - the value of the SEC_VID register
358 **/ 355 **/
359int caam_get_era(u64 caam_id) 356int caam_get_era(void)
360{ 357{
361 struct sec_vid *sec_vid = (struct sec_vid *)&caam_id; 358 struct device_node *caam_node;
362 static const struct { 359 for_each_compatible_node(caam_node, NULL, "fsl,sec-v4.0") {
363 u16 ip_id; 360 const uint32_t *prop = (uint32_t *)of_get_property(caam_node,
364 u8 maj_rev; 361 "fsl,sec-era",
365 u8 era; 362 NULL);
366 } caam_eras[] = { 363 return prop ? *prop : -ENOTSUPP;
367 {0x0A10, 1, 1}, 364 }
368 {0x0A10, 2, 2},
369 {0x0A12, 1, 3},
370 {0x0A14, 1, 3},
371 {0x0A14, 2, 4},
372 {0x0A16, 1, 4},
373 {0x0A11, 1, 4}
374 };
375 int i;
376
377 for (i = 0; i < ARRAY_SIZE(caam_eras); i++)
378 if (caam_eras[i].ip_id == sec_vid->ip_id &&
379 caam_eras[i].maj_rev == sec_vid->maj_rev)
380 return caam_eras[i].era;
381 365
382 return -ENOTSUPP; 366 return -ENOTSUPP;
383} 367}
@@ -551,7 +535,7 @@ static int caam_probe(struct platform_device *pdev)
551 535
552 /* Report "alive" for developer to see */ 536 /* Report "alive" for developer to see */
553 dev_info(dev, "device ID = 0x%016llx (Era %d)\n", caam_id, 537 dev_info(dev, "device ID = 0x%016llx (Era %d)\n", caam_id,
554 caam_get_era(caam_id)); 538 caam_get_era());
555 dev_info(dev, "job rings = %d, qi = %d\n", 539 dev_info(dev, "job rings = %d, qi = %d\n",
556 ctrlpriv->total_jobrs, ctrlpriv->qi_present); 540 ctrlpriv->total_jobrs, ctrlpriv->qi_present);
557 541
diff --git a/drivers/crypto/caam/ctrl.h b/drivers/crypto/caam/ctrl.h
index 980d44eaaf40..cac5402a46eb 100644
--- a/drivers/crypto/caam/ctrl.h
+++ b/drivers/crypto/caam/ctrl.h
@@ -8,6 +8,6 @@
8#define CTRL_H 8#define CTRL_H
9 9
10/* Prototypes for backend-level services exposed to APIs */ 10/* Prototypes for backend-level services exposed to APIs */
11int caam_get_era(u64 caam_id); 11int caam_get_era(void);
12 12
13#endif /* CTRL_H */ 13#endif /* CTRL_H */