Commit 4ea3711a authored by Tero Kristo's avatar Tero Kristo Committed by Tony Lindgren

ARM: OMAP2+: omap-iommu.c conversion to ti-sysc

Convert omap2 iommu platform code to use ti-sysc instead of legacy
omap-device / hwmod interfaces.
Signed-off-by: default avatarTero Kristo <t-kristo@ti.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 2f14101a
...@@ -8,19 +8,27 @@ ...@@ -8,19 +8,27 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/clk.h>
#include <linux/list.h>
#include "omap_hwmod.h"
#include "omap_device.h"
#include "clockdomain.h" #include "clockdomain.h"
#include "powerdomain.h" #include "powerdomain.h"
struct pwrdm_link {
struct device *dev;
struct powerdomain *pwrdm;
struct list_head node;
};
static DEFINE_SPINLOCK(iommu_lock);
static struct clockdomain *emu_clkdm;
static atomic_t emu_count;
static void omap_iommu_dra7_emu_swsup_config(struct platform_device *pdev, static void omap_iommu_dra7_emu_swsup_config(struct platform_device *pdev,
bool enable) bool enable)
{ {
static struct clockdomain *emu_clkdm;
static DEFINE_SPINLOCK(emu_lock);
static atomic_t count;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
unsigned long flags;
if (!of_device_is_compatible(np, "ti,dra7-dsp-iommu")) if (!of_device_is_compatible(np, "ti,dra7-dsp-iommu"))
return; return;
...@@ -31,34 +39,87 @@ static void omap_iommu_dra7_emu_swsup_config(struct platform_device *pdev, ...@@ -31,34 +39,87 @@ static void omap_iommu_dra7_emu_swsup_config(struct platform_device *pdev,
return; return;
} }
spin_lock(&emu_lock); spin_lock_irqsave(&iommu_lock, flags);
if (enable && (atomic_inc_return(&count) == 1)) if (enable && (atomic_inc_return(&emu_count) == 1))
clkdm_deny_idle(emu_clkdm); clkdm_deny_idle(emu_clkdm);
else if (!enable && (atomic_dec_return(&count) == 0)) else if (!enable && (atomic_dec_return(&emu_count) == 0))
clkdm_allow_idle(emu_clkdm); clkdm_allow_idle(emu_clkdm);
spin_unlock(&emu_lock); spin_unlock_irqrestore(&iommu_lock, flags);
}
static struct powerdomain *_get_pwrdm(struct device *dev)
{
struct clk *clk;
struct clk_hw_omap *hwclk;
struct clockdomain *clkdm;
struct powerdomain *pwrdm = NULL;
struct pwrdm_link *entry;
unsigned long flags;
static LIST_HEAD(cache);
spin_lock_irqsave(&iommu_lock, flags);
list_for_each_entry(entry, &cache, node) {
if (entry->dev == dev) {
pwrdm = entry->pwrdm;
break;
}
}
spin_unlock_irqrestore(&iommu_lock, flags);
if (pwrdm)
return pwrdm;
clk = of_clk_get(dev->of_node->parent, 0);
if (!clk) {
dev_err(dev, "no fck found\n");
return NULL;
}
hwclk = to_clk_hw_omap(__clk_get_hw(clk));
clk_put(clk);
if (!hwclk || !hwclk->clkdm_name) {
dev_err(dev, "no hwclk data\n");
return NULL;
}
clkdm = clkdm_lookup(hwclk->clkdm_name);
if (!clkdm) {
dev_err(dev, "clkdm not found: %s\n", hwclk->clkdm_name);
return NULL;
}
pwrdm = clkdm_get_pwrdm(clkdm);
if (!pwrdm) {
dev_err(dev, "pwrdm not found: %s\n", clkdm->name);
return NULL;
}
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
if (entry) {
entry->dev = dev;
entry->pwrdm = pwrdm;
spin_lock_irqsave(&iommu_lock, flags);
list_add(&entry->node, &cache);
spin_unlock_irqrestore(&iommu_lock, flags);
}
return pwrdm;
} }
int omap_iommu_set_pwrdm_constraint(struct platform_device *pdev, bool request, int omap_iommu_set_pwrdm_constraint(struct platform_device *pdev, bool request,
u8 *pwrst) u8 *pwrst)
{ {
struct powerdomain *pwrdm; struct powerdomain *pwrdm;
struct omap_device *od;
u8 next_pwrst; u8 next_pwrst;
int ret = 0; int ret = 0;
od = to_omap_device(pdev); pwrdm = _get_pwrdm(&pdev->dev);
if (!od)
return -ENODEV;
if (od->hwmods_cnt != 1)
return -EINVAL;
pwrdm = omap_hwmod_get_pwrdm(od->hwmods[0]);
if (!pwrdm) if (!pwrdm)
return -EINVAL; return -ENODEV;
if (request) { if (request) {
*pwrst = pwrdm_read_next_pwrst(pwrdm); *pwrst = pwrdm_read_next_pwrst(pwrdm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment