12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- /*
- * OMAP IOMMU quirks for various TI SoCs
- *
- * Copyright (C) 2015-2017 Texas Instruments Incorporated - http://www.ti.com/
- * Suman Anna <s-anna@ti.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
- #include <linux/platform_device.h>
- #include <linux/err.h>
- #include "omap_hwmod.h"
- #include "omap_device.h"
- #include "clockdomain.h"
- #include "powerdomain.h"
- static void omap_iommu_dra7_emu_swsup_config(struct platform_device *pdev,
- bool enable)
- {
- static struct clockdomain *emu_clkdm;
- static DEFINE_SPINLOCK(emu_lock);
- static atomic_t count;
- struct device_node *np = pdev->dev.of_node;
- if (!of_device_is_compatible(np, "ti,dra7-dsp-iommu"))
- return;
- if (!emu_clkdm) {
- emu_clkdm = clkdm_lookup("emu_clkdm");
- if (WARN_ON_ONCE(!emu_clkdm))
- return;
- }
- spin_lock(&emu_lock);
- if (enable && (atomic_inc_return(&count) == 1))
- clkdm_deny_idle(emu_clkdm);
- else if (!enable && (atomic_dec_return(&count) == 0))
- clkdm_allow_idle(emu_clkdm);
- spin_unlock(&emu_lock);
- }
- int omap_iommu_set_pwrdm_constraint(struct platform_device *pdev, bool request,
- u8 *pwrst)
- {
- struct powerdomain *pwrdm;
- struct omap_device *od;
- u8 next_pwrst;
- int ret = 0;
- od = to_omap_device(pdev);
- if (!od)
- return -ENODEV;
- if (od->hwmods_cnt != 1)
- return -EINVAL;
- pwrdm = omap_hwmod_get_pwrdm(od->hwmods[0]);
- if (!pwrdm)
- return -EINVAL;
- if (request) {
- *pwrst = pwrdm_read_next_pwrst(pwrdm);
- omap_iommu_dra7_emu_swsup_config(pdev, true);
- }
- if (*pwrst > PWRDM_POWER_RET)
- goto out;
- next_pwrst = request ? PWRDM_POWER_ON : *pwrst;
- ret = pwrdm_set_next_pwrst(pwrdm, next_pwrst);
- out:
- if (!request)
- omap_iommu_dra7_emu_swsup_config(pdev, false);
- return ret;
- }
|