aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorOmar Ramirez Luna <omar.luna@linaro.org>2012-11-19 20:05:50 -0500
committerJoerg Roedel <joro@8bytes.org>2012-12-03 12:48:13 -0500
commit72b15b6ae97796c5fac687addde5dbfab872cf94 (patch)
treebe849a67c3b00a4bb0f4651901e0c37323e74c94 /drivers/iommu
parent87f8e57327bd8d85fb5b46cad29ac281430cc50d (diff)
iommu/omap: Migrate to hwmod framework
Use hwmod data and device attributes to build and register an omap device for iommu driver. - Update the naming convention in isp module. - Remove unneeded check for number of resources, as this is now handled by omap_device and prevents driver from loading. - Now unused, remove platform device and resource data, handling of sysconfig register for softreset purposes, use default latency structure. - Use hwmod API for reset handling. Signed-off-by: Omar Ramirez Luna <omar.luna@linaro.org> Tested-by: Ohad Ben-Cohen <ohad@wizery.com> Signed-off-by: Joerg Roedel <joro@8bytes.org>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/omap-iommu.c23
-rw-r--r--drivers/iommu/omap-iommu2.c19
2 files changed, 18 insertions, 24 deletions
diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index f8082da6179b..af9b4f31f594 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -143,13 +143,23 @@ EXPORT_SYMBOL_GPL(omap_iommu_arch_version);
143static int iommu_enable(struct omap_iommu *obj) 143static int iommu_enable(struct omap_iommu *obj)
144{ 144{
145 int err; 145 int err;
146 struct platform_device *pdev = to_platform_device(obj->dev);
147 struct iommu_platform_data *pdata = pdev->dev.platform_data;
146 148
147 if (!obj) 149 if (!obj || !pdata)
148 return -EINVAL; 150 return -EINVAL;
149 151
150 if (!arch_iommu) 152 if (!arch_iommu)
151 return -ENODEV; 153 return -ENODEV;
152 154
155 if (pdata->deassert_reset) {
156 err = pdata->deassert_reset(pdev, pdata->reset_name);
157 if (err) {
158 dev_err(obj->dev, "deassert_reset failed: %d\n", err);
159 return err;
160 }
161 }
162
153 clk_enable(obj->clk); 163 clk_enable(obj->clk);
154 164
155 err = arch_iommu->enable(obj); 165 err = arch_iommu->enable(obj);
@@ -159,12 +169,18 @@ static int iommu_enable(struct omap_iommu *obj)
159 169
160static void iommu_disable(struct omap_iommu *obj) 170static void iommu_disable(struct omap_iommu *obj)
161{ 171{
162 if (!obj) 172 struct platform_device *pdev = to_platform_device(obj->dev);
173 struct iommu_platform_data *pdata = pdev->dev.platform_data;
174
175 if (!obj || !pdata)
163 return; 176 return;
164 177
165 arch_iommu->disable(obj); 178 arch_iommu->disable(obj);
166 179
167 clk_disable(obj->clk); 180 clk_disable(obj->clk);
181
182 if (pdata->assert_reset)
183 pdata->assert_reset(pdev, pdata->reset_name);
168} 184}
169 185
170/* 186/*
@@ -926,9 +942,6 @@ static int __devinit omap_iommu_probe(struct platform_device *pdev)
926 struct resource *res; 942 struct resource *res;
927 struct iommu_platform_data *pdata = pdev->dev.platform_data; 943 struct iommu_platform_data *pdata = pdev->dev.platform_data;
928 944
929 if (pdev->num_resources != 2)
930 return -EINVAL;
931
932 obj = kzalloc(sizeof(*obj) + MMU_REG_SIZE, GFP_KERNEL); 945 obj = kzalloc(sizeof(*obj) + MMU_REG_SIZE, GFP_KERNEL);
933 if (!obj) 946 if (!obj)
934 return -ENOMEM; 947 return -ENOMEM;
diff --git a/drivers/iommu/omap-iommu2.c b/drivers/iommu/omap-iommu2.c
index c02020292377..4a3a1c7a38c1 100644
--- a/drivers/iommu/omap-iommu2.c
+++ b/drivers/iommu/omap-iommu2.c
@@ -35,12 +35,8 @@
35#define MMU_SYS_IDLE_SMART (2 << MMU_SYS_IDLE_SHIFT) 35#define MMU_SYS_IDLE_SMART (2 << MMU_SYS_IDLE_SHIFT)
36#define MMU_SYS_IDLE_MASK (3 << MMU_SYS_IDLE_SHIFT) 36#define MMU_SYS_IDLE_MASK (3 << MMU_SYS_IDLE_SHIFT)
37 37
38#define MMU_SYS_SOFTRESET (1 << 1)
39#define MMU_SYS_AUTOIDLE 1 38#define MMU_SYS_AUTOIDLE 1
40 39
41/* SYSSTATUS */
42#define MMU_SYS_RESETDONE 1
43
44/* IRQSTATUS & IRQENABLE */ 40/* IRQSTATUS & IRQENABLE */
45#define MMU_IRQ_MULTIHITFAULT (1 << 4) 41#define MMU_IRQ_MULTIHITFAULT (1 << 4)
46#define MMU_IRQ_TABLEWALKFAULT (1 << 3) 42#define MMU_IRQ_TABLEWALKFAULT (1 << 3)
@@ -97,7 +93,6 @@ static void __iommu_set_twl(struct omap_iommu *obj, bool on)
97static int omap2_iommu_enable(struct omap_iommu *obj) 93static int omap2_iommu_enable(struct omap_iommu *obj)
98{ 94{
99 u32 l, pa; 95 u32 l, pa;
100 unsigned long timeout;
101 96
102 if (!obj->iopgd || !IS_ALIGNED((u32)obj->iopgd, SZ_16K)) 97 if (!obj->iopgd || !IS_ALIGNED((u32)obj->iopgd, SZ_16K))
103 return -EINVAL; 98 return -EINVAL;
@@ -106,20 +101,6 @@ static int omap2_iommu_enable(struct omap_iommu *obj)
106 if (!IS_ALIGNED(pa, SZ_16K)) 101 if (!IS_ALIGNED(pa, SZ_16K))
107 return -EINVAL; 102 return -EINVAL;
108 103
109 iommu_write_reg(obj, MMU_SYS_SOFTRESET, MMU_SYSCONFIG);
110
111 timeout = jiffies + msecs_to_jiffies(20);
112 do {
113 l = iommu_read_reg(obj, MMU_SYSSTATUS);
114 if (l & MMU_SYS_RESETDONE)
115 break;
116 } while (!time_after(jiffies, timeout));
117
118 if (!(l & MMU_SYS_RESETDONE)) {
119 dev_err(obj->dev, "can't take mmu out of reset\n");
120 return -ENODEV;
121 }
122
123 l = iommu_read_reg(obj, MMU_REVISION); 104 l = iommu_read_reg(obj, MMU_REVISION);
124 dev_info(obj->dev, "%s: version %d.%d\n", obj->name, 105 dev_info(obj->dev, "%s: version %d.%d\n", obj->name,
125 (l >> 4) & 0xf, l & 0xf); 106 (l >> 4) & 0xf, l & 0xf);