@@ -23,6 +23,7 @@
#include <linux/platform_device.h>
#include <linux/sizes.h>
#include <linux/slab.h>
+#include <linux/sys_soc.h>
#if defined(CONFIG_ARM) && !defined(CONFIG_IOMMU_DMA)
#include <asm/dma-iommu.h>
@@ -1032,9 +1033,33 @@ static void ipmmu_remove_device_dma(stru
iommu_group_remove_device(dev);
}
+static const struct soc_device_attribute r8a7795es2[] = {
+ { .soc_id = "r8a7795", .revision = "ES2.*" },
+ { /* sentinel */ }
+};
+
+static int ipmmu_slave_whitelist(struct device *dev)
+{
+ /* Opt-in slave devices based on SoC and ES version */
+ if (soc_device_match(r8a7795es2)) {
+ if (!strcmp(dev_name(dev), "e7310000.dma-controller"))
+ return 0;
+ }
+
+ /* By default, do not allow use of IPMMU */
+ return -ENODEV;
+}
+
static int ipmmu_of_xlate_dma(struct device *dev,
struct of_phandle_args *spec)
{
+ int ret;
+
+ /* Opt-in devices based on SoC and ES version */
+ ret = ipmmu_slave_whitelist(dev);
+ if (ret)
+ return ret;
+
/* For now only tested on R-Car Gen3 with ARM64 arch init order
* TODO: Test R-Car Gen2 with ARM32 arch init order
*/