]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/iommu/ipmmu-vmsa.c
Merge branches 'iommu/fixes', 'arm/renesas', 'arm/mediatek', 'arm/tegra', 'arm/omap...
[linux.git] / drivers / iommu / ipmmu-vmsa.c
index 4b264b63035b48e66ffb1d8c55315419cc8926ac..7a4529c61c19f3d4c531fdbe18d77d44c70aca66 100644 (file)
@@ -501,6 +501,9 @@ static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)
 
 static void ipmmu_domain_destroy_context(struct ipmmu_vmsa_domain *domain)
 {
+       if (!domain->mmu)
+               return;
+
        /*
         * Disable the context. Flush the TLB as required when modifying the
         * context registers.
@@ -756,26 +759,59 @@ static int ipmmu_init_platform_device(struct device *dev,
        return 0;
 }
 
-static bool ipmmu_slave_whitelist(struct device *dev)
-{
-       /* By default, do not allow use of IPMMU */
-       return false;
-}
-
 static const struct soc_device_attribute soc_rcar_gen3[] = {
+       { .soc_id = "r8a774a1", },
+       { .soc_id = "r8a774c0", },
        { .soc_id = "r8a7795", },
        { .soc_id = "r8a7796", },
        { .soc_id = "r8a77965", },
        { .soc_id = "r8a77970", },
+       { .soc_id = "r8a77990", },
+       { .soc_id = "r8a77995", },
+       { /* sentinel */ }
+};
+
+static const struct soc_device_attribute soc_rcar_gen3_whitelist[] = {
+       { .soc_id = "r8a774c0", },
+       { .soc_id = "r8a7795", .revision = "ES3.*" },
+       { .soc_id = "r8a77965", },
+       { .soc_id = "r8a77990", },
        { .soc_id = "r8a77995", },
        { /* sentinel */ }
 };
 
+static const char * const rcar_gen3_slave_whitelist[] = {
+};
+
+static bool ipmmu_slave_whitelist(struct device *dev)
+{
+       unsigned int i;
+
+       /*
+        * For R-Car Gen3 use a white list to opt-in slave devices.
+        * For Other SoCs, this returns true anyway.
+        */
+       if (!soc_device_match(soc_rcar_gen3))
+               return true;
+
+       /* Check whether this R-Car Gen3 can use the IPMMU correctly or not */
+       if (!soc_device_match(soc_rcar_gen3_whitelist))
+               return false;
+
+       /* Check whether this slave device can work with the IPMMU */
+       for (i = 0; i < ARRAY_SIZE(rcar_gen3_slave_whitelist); i++) {
+               if (!strcmp(dev_name(dev), rcar_gen3_slave_whitelist[i]))
+                       return true;
+       }
+
+       /* Otherwise, do not allow use of IPMMU */
+       return false;
+}
+
 static int ipmmu_of_xlate(struct device *dev,
                          struct of_phandle_args *spec)
 {
-       /* For R-Car Gen3 use a white list to opt-in slave devices */
-       if (soc_device_match(soc_rcar_gen3) && !ipmmu_slave_whitelist(dev))
+       if (!ipmmu_slave_whitelist(dev))
                return -ENODEV;
 
        iommu_fwspec_add_ids(dev, spec->args, 1);
@@ -942,6 +978,12 @@ static const struct of_device_id ipmmu_of_ids[] = {
        {
                .compatible = "renesas,ipmmu-vmsa",
                .data = &ipmmu_features_default,
+       }, {
+               .compatible = "renesas,ipmmu-r8a774a1",
+               .data = &ipmmu_features_rcar_gen3,
+       }, {
+               .compatible = "renesas,ipmmu-r8a774c0",
+               .data = &ipmmu_features_rcar_gen3,
        }, {
                .compatible = "renesas,ipmmu-r8a7795",
                .data = &ipmmu_features_rcar_gen3,
@@ -954,6 +996,9 @@ static const struct of_device_id ipmmu_of_ids[] = {
        }, {
                .compatible = "renesas,ipmmu-r8a77970",
                .data = &ipmmu_features_rcar_gen3,
+       }, {
+               .compatible = "renesas,ipmmu-r8a77990",
+               .data = &ipmmu_features_rcar_gen3,
        }, {
                .compatible = "renesas,ipmmu-r8a77995",
                .data = &ipmmu_features_rcar_gen3,