1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * OMAP IOMMU quirks for various TI SoCs 4 * 5 * Copyright (C) 2015-2019 Texas Instruments Incorporated - http://www.ti.com/ 6 * Suman Anna <s-anna@ti.com> 7 */ 8 9 #include <linux/platform_device.h> 10 #include <linux/err.h> 11 12 #include "omap_hwmod.h" 13 #include "omap_device.h" 14 #include "powerdomain.h" 15 16 int omap_iommu_set_pwrdm_constraint(struct platform_device *pdev, bool request, 17 u8 *pwrst) 18 { 19 struct powerdomain *pwrdm; 20 struct omap_device *od; 21 u8 next_pwrst; 22 23 od = to_omap_device(pdev); 24 if (!od) 25 return -ENODEV; 26 27 if (od->hwmods_cnt != 1) 28 return -EINVAL; 29 30 pwrdm = omap_hwmod_get_pwrdm(od->hwmods[0]); 31 if (!pwrdm) 32 return -EINVAL; 33 34 if (request) 35 *pwrst = pwrdm_read_next_pwrst(pwrdm); 36 37 if (*pwrst > PWRDM_POWER_RET) 38 return 0; 39 40 next_pwrst = request ? PWRDM_POWER_ON : *pwrst; 41 42 return pwrdm_set_next_pwrst(pwrdm, next_pwrst); 43 } 44