diff options
Diffstat (limited to 'drivers/crypto/caam/ctrl.c')
-rw-r--r-- | drivers/crypto/caam/ctrl.c | 61 |
1 files changed, 16 insertions, 45 deletions
diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 63fb1af2c431..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 | **/ |
359 | int caam_get_era(u64 caam_id) | 356 | int 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 | } |
@@ -443,13 +427,10 @@ static int caam_probe(struct platform_device *pdev) | |||
443 | * for all, then go probe each one. | 427 | * for all, then go probe each one. |
444 | */ | 428 | */ |
445 | rspec = 0; | 429 | rspec = 0; |
446 | for_each_compatible_node(np, NULL, "fsl,sec-v4.0-job-ring") | 430 | for_each_available_child_of_node(nprop, np) |
447 | rspec++; | 431 | if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") || |
448 | if (!rspec) { | 432 | of_device_is_compatible(np, "fsl,sec4.0-job-ring")) |
449 | /* for backward compatible with device trees */ | ||
450 | for_each_compatible_node(np, NULL, "fsl,sec4.0-job-ring") | ||
451 | rspec++; | 433 | rspec++; |
452 | } | ||
453 | 434 | ||
454 | ctrlpriv->jrpdev = kzalloc(sizeof(struct platform_device *) * rspec, | 435 | ctrlpriv->jrpdev = kzalloc(sizeof(struct platform_device *) * rspec, |
455 | GFP_KERNEL); | 436 | GFP_KERNEL); |
@@ -460,18 +441,9 @@ static int caam_probe(struct platform_device *pdev) | |||
460 | 441 | ||
461 | ring = 0; | 442 | ring = 0; |
462 | ctrlpriv->total_jobrs = 0; | 443 | ctrlpriv->total_jobrs = 0; |
463 | for_each_compatible_node(np, NULL, "fsl,sec-v4.0-job-ring") { | 444 | for_each_available_child_of_node(nprop, np) |
464 | ctrlpriv->jrpdev[ring] = | 445 | if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") || |
465 | of_platform_device_create(np, NULL, dev); | 446 | of_device_is_compatible(np, "fsl,sec4.0-job-ring")) { |
466 | if (!ctrlpriv->jrpdev[ring]) { | ||
467 | pr_warn("JR%d Platform device creation error\n", ring); | ||
468 | continue; | ||
469 | } | ||
470 | ctrlpriv->total_jobrs++; | ||
471 | ring++; | ||
472 | } | ||
473 | if (!ring) { | ||
474 | for_each_compatible_node(np, NULL, "fsl,sec4.0-job-ring") { | ||
475 | ctrlpriv->jrpdev[ring] = | 447 | ctrlpriv->jrpdev[ring] = |
476 | of_platform_device_create(np, NULL, dev); | 448 | of_platform_device_create(np, NULL, dev); |
477 | if (!ctrlpriv->jrpdev[ring]) { | 449 | if (!ctrlpriv->jrpdev[ring]) { |
@@ -482,7 +454,6 @@ static int caam_probe(struct platform_device *pdev) | |||
482 | ctrlpriv->total_jobrs++; | 454 | ctrlpriv->total_jobrs++; |
483 | ring++; | 455 | ring++; |
484 | } | 456 | } |
485 | } | ||
486 | 457 | ||
487 | /* Check to see if QI present. If so, enable */ | 458 | /* Check to see if QI present. If so, enable */ |
488 | ctrlpriv->qi_present = !!(rd_reg64(&topregs->ctrl.perfmon.comp_parms) & | 459 | ctrlpriv->qi_present = !!(rd_reg64(&topregs->ctrl.perfmon.comp_parms) & |
@@ -564,7 +535,7 @@ static int caam_probe(struct platform_device *pdev) | |||
564 | 535 | ||
565 | /* Report "alive" for developer to see */ | 536 | /* Report "alive" for developer to see */ |
566 | 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, |
567 | caam_get_era(caam_id)); | 538 | caam_get_era()); |
568 | dev_info(dev, "job rings = %d, qi = %d\n", | 539 | dev_info(dev, "job rings = %d, qi = %d\n", |
569 | ctrlpriv->total_jobrs, ctrlpriv->qi_present); | 540 | ctrlpriv->total_jobrs, ctrlpriv->qi_present); |
570 | 541 | ||