@@ -527,15 +527,54 @@ static int caam_probe(struct platform_device *pdev)
527
527
dev_set_drvdata (dev , ctrlpriv );
528
528
nprop = pdev -> dev .of_node ;
529
529
530
+ /* Get configuration properties from device tree */
531
+ /* First, get register page */
532
+ ctrl = of_iomap (nprop , 0 );
533
+ if (!ctrl ) {
534
+ dev_err (dev , "caam: of_iomap() failed\n" );
535
+ return - ENOMEM ;
536
+ }
537
+
538
+ caam_little_end = !(bool )(rd_reg32 (& ctrl -> perfmon .status ) &
539
+ (CSTA_PLEND | CSTA_ALT_PLEND ));
530
540
caam_imx = (bool )soc_device_match (imx_soc );
531
541
542
+ comp_params = rd_reg32 (& ctrl -> perfmon .comp_parms_ms );
543
+ caam_dpaa2 = !!(comp_params & CTPR_MS_DPAA2 );
544
+ ctrlpriv -> qi_present = !!(comp_params & CTPR_MS_QI_MASK );
545
+
546
+ #ifdef CONFIG_CAAM_QI
547
+ /* If (DPAA 1.x) QI present, check whether dependencies are available */
548
+ if (ctrlpriv -> qi_present && !caam_dpaa2 ) {
549
+ ret = qman_is_probed ();
550
+ if (!ret ) {
551
+ ret = - EPROBE_DEFER ;
552
+ goto iounmap_ctrl ;
553
+ } else if (ret < 0 ) {
554
+ dev_err (dev , "failing probe due to qman probe error\n" );
555
+ ret = - ENODEV ;
556
+ goto iounmap_ctrl ;
557
+ }
558
+
559
+ ret = qman_portals_probed ();
560
+ if (!ret ) {
561
+ ret = - EPROBE_DEFER ;
562
+ goto iounmap_ctrl ;
563
+ } else if (ret < 0 ) {
564
+ dev_err (dev , "failing probe due to qman portals probe error\n" );
565
+ ret = - ENODEV ;
566
+ goto iounmap_ctrl ;
567
+ }
568
+ }
569
+ #endif
570
+
532
571
/* Enable clocking */
533
572
clk = caam_drv_identify_clk (& pdev -> dev , "ipg" );
534
573
if (IS_ERR (clk )) {
535
574
ret = PTR_ERR (clk );
536
575
dev_err (& pdev -> dev ,
537
576
"can't identify CAAM ipg clk: %d\n" , ret );
538
- return ret ;
577
+ goto iounmap_ctrl ;
539
578
}
540
579
ctrlpriv -> caam_ipg = clk ;
541
580
@@ -547,7 +586,7 @@ static int caam_probe(struct platform_device *pdev)
547
586
ret = PTR_ERR (clk );
548
587
dev_err (& pdev -> dev ,
549
588
"can't identify CAAM mem clk: %d\n" , ret );
550
- return ret ;
589
+ goto iounmap_ctrl ;
551
590
}
552
591
ctrlpriv -> caam_mem = clk ;
553
592
}
@@ -557,7 +596,7 @@ static int caam_probe(struct platform_device *pdev)
557
596
ret = PTR_ERR (clk );
558
597
dev_err (& pdev -> dev ,
559
598
"can't identify CAAM aclk clk: %d\n" , ret );
560
- return ret ;
599
+ goto iounmap_ctrl ;
561
600
}
562
601
ctrlpriv -> caam_aclk = clk ;
563
602
@@ -570,15 +609,15 @@ static int caam_probe(struct platform_device *pdev)
570
609
ret = PTR_ERR (clk );
571
610
dev_err (& pdev -> dev ,
572
611
"can't identify CAAM emi_slow clk: %d\n" , ret );
573
- return ret ;
612
+ goto iounmap_ctrl ;
574
613
}
575
614
ctrlpriv -> caam_emi_slow = clk ;
576
615
}
577
616
578
617
ret = clk_prepare_enable (ctrlpriv -> caam_ipg );
579
618
if (ret < 0 ) {
580
619
dev_err (& pdev -> dev , "can't enable CAAM ipg clock: %d\n" , ret );
581
- return ret ;
620
+ goto iounmap_ctrl ;
582
621
}
583
622
584
623
if (ctrlpriv -> caam_mem ) {
@@ -605,25 +644,10 @@ static int caam_probe(struct platform_device *pdev)
605
644
}
606
645
}
607
646
608
- /* Get configuration properties from device tree */
609
- /* First, get register page */
610
- ctrl = of_iomap (nprop , 0 );
611
- if (ctrl == NULL ) {
612
- dev_err (dev , "caam: of_iomap() failed\n" );
613
- ret = - ENOMEM ;
614
- goto disable_caam_emi_slow ;
615
- }
616
-
617
- caam_little_end = !(bool )(rd_reg32 (& ctrl -> perfmon .status ) &
618
- (CSTA_PLEND | CSTA_ALT_PLEND ));
619
-
620
- /* Finding the page size for using the CTPR_MS register */
621
- comp_params = rd_reg32 (& ctrl -> perfmon .comp_parms_ms );
622
- pg_size = (comp_params & CTPR_MS_PG_SZ_MASK ) >> CTPR_MS_PG_SZ_SHIFT ;
623
-
624
647
/* Allocating the BLOCK_OFFSET based on the supported page size on
625
648
* the platform
626
649
*/
650
+ pg_size = (comp_params & CTPR_MS_PG_SZ_MASK ) >> CTPR_MS_PG_SZ_SHIFT ;
627
651
if (pg_size == 0 )
628
652
BLOCK_OFFSET = PG_SIZE_4K ;
629
653
else
@@ -648,7 +672,6 @@ static int caam_probe(struct platform_device *pdev)
648
672
* In case of SoCs with Management Complex, MC f/w performs
649
673
* the configuration.
650
674
*/
651
- caam_dpaa2 = !!(comp_params & CTPR_MS_DPAA2 );
652
675
np = of_find_compatible_node (NULL , NULL , "fsl,qoriq-mc" );
653
676
ctrlpriv -> mc_en = !!np ;
654
677
of_node_put (np );
@@ -700,7 +723,7 @@ static int caam_probe(struct platform_device *pdev)
700
723
}
701
724
if (ret ) {
702
725
dev_err (dev , "dma_set_mask_and_coherent failed (%d)\n" , ret );
703
- goto iounmap_ctrl ;
726
+ goto disable_caam_emi_slow ;
704
727
}
705
728
706
729
ctrlpriv -> era = caam_get_era (ctrl );
@@ -719,7 +742,6 @@ static int caam_probe(struct platform_device *pdev)
719
742
#endif
720
743
721
744
/* Check to see if (DPAA 1.x) QI present. If so, enable */
722
- ctrlpriv -> qi_present = !!(comp_params & CTPR_MS_QI_MASK );
723
745
if (ctrlpriv -> qi_present && !caam_dpaa2 ) {
724
746
ctrlpriv -> qi = (struct caam_queue_if __iomem __force * )
725
747
((__force uint8_t * )ctrl +
@@ -906,8 +928,6 @@ static int caam_probe(struct platform_device *pdev)
906
928
if (ctrlpriv -> qi_init )
907
929
caam_qi_shutdown (dev );
908
930
#endif
909
- iounmap_ctrl :
910
- iounmap (ctrl );
911
931
disable_caam_emi_slow :
912
932
if (ctrlpriv -> caam_emi_slow )
913
933
clk_disable_unprepare (ctrlpriv -> caam_emi_slow );
@@ -918,6 +938,8 @@ static int caam_probe(struct platform_device *pdev)
918
938
clk_disable_unprepare (ctrlpriv -> caam_mem );
919
939
disable_caam_ipg :
920
940
clk_disable_unprepare (ctrlpriv -> caam_ipg );
941
+ iounmap_ctrl :
942
+ iounmap (ctrl );
921
943
return ret ;
922
944
}
923
945
0 commit comments