Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
[linux-2.6-block.git] / drivers / crypto / caam / ctrl.c
index e2ba3d202da51fb795ec6836c648e049bd1677ae..4e43ca4d3656961496347014b3380fedada2123e 100644 (file)
@@ -3,7 +3,7 @@
  * Controller-level driver, kernel property detection, initialization
  *
  * Copyright 2008-2012 Freescale Semiconductor, Inc.
- * Copyright 2018 NXP
+ * Copyright 2018-2019 NXP
  */
 
 #include <linux/device.h>
@@ -323,8 +323,8 @@ static int caam_remove(struct platform_device *pdev)
        of_platform_depopulate(ctrldev);
 
 #ifdef CONFIG_CAAM_QI
-       if (ctrlpriv->qidev)
-               caam_qi_shutdown(ctrlpriv->qidev);
+       if (ctrlpriv->qi_init)
+               caam_qi_shutdown(ctrldev);
 #endif
 
        /*
@@ -469,7 +469,7 @@ static int caam_get_era(struct caam_ctrl __iomem *ctrl)
 }
 
 /*
- * ERRATA: imx6 devices (imx6D, imx6Q, imx6DL, imx6S, imx6DP and imx6DQ)
+ * ERRATA: imx6 devices (imx6D, imx6Q, imx6DL, imx6S, imx6DP and imx6QP)
  * have an issue wherein AXI bus transactions may not occur in the correct
  * order. This isn't a problem running single descriptors, but can be if
  * running multiple concurrent descriptors. Reworking the driver to throttle
@@ -540,7 +540,8 @@ static int caam_probe(struct platform_device *pdev)
        ctrlpriv->caam_ipg = clk;
 
        if (!of_machine_is_compatible("fsl,imx7d") &&
-           !of_machine_is_compatible("fsl,imx7s")) {
+           !of_machine_is_compatible("fsl,imx7s") &&
+           !of_machine_is_compatible("fsl,imx7ulp")) {
                clk = caam_drv_identify_clk(&pdev->dev, "mem");
                if (IS_ERR(clk)) {
                        ret = PTR_ERR(clk);
@@ -562,7 +563,8 @@ static int caam_probe(struct platform_device *pdev)
 
        if (!of_machine_is_compatible("fsl,imx6ul") &&
            !of_machine_is_compatible("fsl,imx7d") &&
-           !of_machine_is_compatible("fsl,imx7s")) {
+           !of_machine_is_compatible("fsl,imx7s") &&
+           !of_machine_is_compatible("fsl,imx7ulp")) {
                clk = caam_drv_identify_clk(&pdev->dev, "emi_slow");
                if (IS_ERR(clk)) {
                        ret = PTR_ERR(clk);
@@ -702,12 +704,7 @@ static int caam_probe(struct platform_device *pdev)
        }
 
        ctrlpriv->era = caam_get_era(ctrl);
-
-       ret = of_platform_populate(nprop, caam_match, NULL, dev);
-       if (ret) {
-               dev_err(dev, "JR platform devices creation error\n");
-               goto iounmap_ctrl;
-       }
+       ctrlpriv->domain = iommu_get_domain_for_dev(dev);
 
 #ifdef CONFIG_DEBUG_FS
        /*
@@ -721,19 +718,6 @@ static int caam_probe(struct platform_device *pdev)
        ctrlpriv->ctl = debugfs_create_dir("ctl", ctrlpriv->dfs_root);
 #endif
 
-       ring = 0;
-       for_each_available_child_of_node(nprop, np)
-               if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") ||
-                   of_device_is_compatible(np, "fsl,sec4.0-job-ring")) {
-                       ctrlpriv->jr[ring] = (struct caam_job_ring __iomem __force *)
-                                            ((__force uint8_t *)ctrl +
-                                            (ring + JR_BLOCK_NUMBER) *
-                                             BLOCK_OFFSET
-                                            );
-                       ctrlpriv->total_jobrs++;
-                       ring++;
-               }
-
        /* Check to see if (DPAA 1.x) QI present. If so, enable */
        ctrlpriv->qi_present = !!(comp_params & CTPR_MS_QI_MASK);
        if (ctrlpriv->qi_present && !caam_dpaa2) {
@@ -752,6 +736,25 @@ static int caam_probe(struct platform_device *pdev)
 #endif
        }
 
+       ret = of_platform_populate(nprop, caam_match, NULL, dev);
+       if (ret) {
+               dev_err(dev, "JR platform devices creation error\n");
+               goto shutdown_qi;
+       }
+
+       ring = 0;
+       for_each_available_child_of_node(nprop, np)
+               if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") ||
+                   of_device_is_compatible(np, "fsl,sec4.0-job-ring")) {
+                       ctrlpriv->jr[ring] = (struct caam_job_ring __iomem __force *)
+                                            ((__force uint8_t *)ctrl +
+                                            (ring + JR_BLOCK_NUMBER) *
+                                             BLOCK_OFFSET
+                                            );
+                       ctrlpriv->total_jobrs++;
+                       ring++;
+               }
+
        /* If no QI and no rings specified, quit and go home */
        if ((!ctrlpriv->qi_present) && (!ctrlpriv->total_jobrs)) {
                dev_err(dev, "no queues configured, terminating\n");
@@ -898,6 +901,11 @@ caam_remove:
        caam_remove(pdev);
        return ret;
 
+shutdown_qi:
+#ifdef CONFIG_CAAM_QI
+       if (ctrlpriv->qi_init)
+               caam_qi_shutdown(dev);
+#endif
 iounmap_ctrl:
        iounmap(ctrl);
 disable_caam_emi_slow: