1 // SPDX-License-Identifier: GPL-2.0-only
3 * OMAP IOMMU quirks for various TI SoCs
5 * Copyright (C) 2015-2019 Texas Instruments Incorporated - http://www.ti.com/
6 * Suman Anna <s-anna@ti.com>
9 #include <linux/platform_device.h>
10 #include <linux/err.h>
12 #include "omap_hwmod.h"
13 #include "omap_device.h"
14 #include "clockdomain.h"
15 #include "powerdomain.h"
17 static void omap_iommu_dra7_emu_swsup_config(struct platform_device *pdev,
20 static struct clockdomain *emu_clkdm;
21 static DEFINE_SPINLOCK(emu_lock);
22 static atomic_t count;
23 struct device_node *np = pdev->dev.of_node;
25 if (!of_device_is_compatible(np, "ti,dra7-dsp-iommu"))
29 emu_clkdm = clkdm_lookup("emu_clkdm");
30 if (WARN_ON_ONCE(!emu_clkdm))
36 if (enable && (atomic_inc_return(&count) == 1))
37 clkdm_deny_idle(emu_clkdm);
38 else if (!enable && (atomic_dec_return(&count) == 0))
39 clkdm_allow_idle(emu_clkdm);
41 spin_unlock(&emu_lock);
44 int omap_iommu_set_pwrdm_constraint(struct platform_device *pdev, bool request,
47 struct powerdomain *pwrdm;
48 struct omap_device *od;
52 od = to_omap_device(pdev);
56 if (od->hwmods_cnt != 1)
59 pwrdm = omap_hwmod_get_pwrdm(od->hwmods[0]);
64 *pwrst = pwrdm_read_next_pwrst(pwrdm);
65 omap_iommu_dra7_emu_swsup_config(pdev, true);
68 if (*pwrst > PWRDM_POWER_RET)
71 next_pwrst = request ? PWRDM_POWER_ON : *pwrst;
73 ret = pwrdm_set_next_pwrst(pwrdm, next_pwrst);
77 omap_iommu_dra7_emu_swsup_config(pdev, false);