Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | * You should have received a copy of the GNU General Public License |
| 13 | * along with this program; if not, write to the Free Software |
| 14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 15 | * 02110-1301, USA. |
| 16 | */ |
| 17 | |
| 18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 19 | |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/module.h> |
| 22 | #include <linux/platform_device.h> |
| 23 | #include <linux/io.h> |
| 24 | #include <linux/clk.h> |
| 25 | #include <linux/iommu.h> |
| 26 | #include <linux/interrupt.h> |
| 27 | #include <linux/err.h> |
| 28 | #include <linux/slab.h> |
| 29 | |
Stephen Boyd | 0b559df | 2013-07-24 13:54:33 -0700 | [diff] [blame] | 30 | #include "msm_iommu_hw-8xxx.h" |
| 31 | #include "msm_iommu.h" |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 32 | |
| 33 | struct iommu_ctx_iter_data { |
| 34 | /* input */ |
| 35 | const char *name; |
| 36 | |
| 37 | /* output */ |
| 38 | struct device *dev; |
| 39 | }; |
| 40 | |
| 41 | static struct platform_device *msm_iommu_root_dev; |
| 42 | |
| 43 | static int each_iommu_ctx(struct device *dev, void *data) |
| 44 | { |
| 45 | struct iommu_ctx_iter_data *res = data; |
| 46 | struct msm_iommu_ctx_dev *c = dev->platform_data; |
| 47 | |
| 48 | if (!res || !c || !c->name || !res->name) |
| 49 | return -EINVAL; |
| 50 | |
| 51 | if (!strcmp(res->name, c->name)) { |
| 52 | res->dev = dev; |
| 53 | return 1; |
| 54 | } |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | static int each_iommu(struct device *dev, void *data) |
| 59 | { |
| 60 | return device_for_each_child(dev, data, each_iommu_ctx); |
| 61 | } |
| 62 | |
| 63 | struct device *msm_iommu_get_ctx(const char *ctx_name) |
| 64 | { |
| 65 | struct iommu_ctx_iter_data r; |
| 66 | int found; |
| 67 | |
| 68 | if (!msm_iommu_root_dev) { |
| 69 | pr_err("No root IOMMU device.\n"); |
| 70 | goto fail; |
| 71 | } |
| 72 | |
| 73 | r.name = ctx_name; |
| 74 | found = device_for_each_child(&msm_iommu_root_dev->dev, &r, each_iommu); |
| 75 | |
| 76 | if (!found) { |
| 77 | pr_err("Could not find context <%s>\n", ctx_name); |
| 78 | goto fail; |
| 79 | } |
| 80 | |
| 81 | return r.dev; |
| 82 | fail: |
| 83 | return NULL; |
| 84 | } |
| 85 | EXPORT_SYMBOL(msm_iommu_get_ctx); |
| 86 | |
Stepan Moskovchenko | a43d8c1 | 2011-02-24 18:00:42 -0800 | [diff] [blame] | 87 | static void msm_iommu_reset(void __iomem *base, int ncb) |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 88 | { |
Stepan Moskovchenko | a43d8c1 | 2011-02-24 18:00:42 -0800 | [diff] [blame] | 89 | int ctx; |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 90 | |
| 91 | SET_RPUE(base, 0); |
| 92 | SET_RPUEIE(base, 0); |
| 93 | SET_ESRRESTORE(base, 0); |
| 94 | SET_TBE(base, 0); |
| 95 | SET_CR(base, 0); |
| 96 | SET_SPDMBE(base, 0); |
| 97 | SET_TESTBUSCR(base, 0); |
| 98 | SET_TLBRSW(base, 0); |
| 99 | SET_GLOBAL_TLBIALL(base, 0); |
| 100 | SET_RPU_ACR(base, 0); |
| 101 | SET_TLBLKCRWE(base, 1); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 102 | |
| 103 | for (ctx = 0; ctx < ncb; ctx++) { |
| 104 | SET_BPRCOSH(base, ctx, 0); |
| 105 | SET_BPRCISH(base, ctx, 0); |
| 106 | SET_BPRCNSH(base, ctx, 0); |
| 107 | SET_BPSHCFG(base, ctx, 0); |
| 108 | SET_BPMTCFG(base, ctx, 0); |
| 109 | SET_ACTLR(base, ctx, 0); |
| 110 | SET_SCTLR(base, ctx, 0); |
| 111 | SET_FSRRESTORE(base, ctx, 0); |
| 112 | SET_TTBR0(base, ctx, 0); |
| 113 | SET_TTBR1(base, ctx, 0); |
| 114 | SET_TTBCR(base, ctx, 0); |
| 115 | SET_BFBCR(base, ctx, 0); |
| 116 | SET_PAR(base, ctx, 0); |
| 117 | SET_FAR(base, ctx, 0); |
| 118 | SET_CTX_TLBIALL(base, ctx, 0); |
| 119 | SET_TLBFLPTER(base, ctx, 0); |
| 120 | SET_TLBSLPTER(base, ctx, 0); |
| 121 | SET_TLBLKCR(base, ctx, 0); |
| 122 | SET_PRRR(base, ctx, 0); |
| 123 | SET_NMRR(base, ctx, 0); |
| 124 | SET_CONTEXTIDR(base, ctx, 0); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | static int msm_iommu_probe(struct platform_device *pdev) |
| 129 | { |
Kefeng Wang | afba256 | 2014-05-27 18:18:42 +0800 | [diff] [blame] | 130 | struct resource *r; |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 131 | struct clk *iommu_clk; |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 132 | struct clk *iommu_pclk; |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 133 | struct msm_iommu_drvdata *drvdata; |
Kiran Padwal | 263bc3f | 2014-10-30 11:55:11 +0530 | [diff] [blame] | 134 | struct msm_iommu_dev *iommu_dev = dev_get_platdata(&pdev->dev); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 135 | void __iomem *regs_base; |
Stepan Moskovchenko | a43d8c1 | 2011-02-24 18:00:42 -0800 | [diff] [blame] | 136 | int ret, irq, par; |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 137 | |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 138 | if (pdev->id == -1) { |
| 139 | msm_iommu_root_dev = pdev; |
| 140 | return 0; |
| 141 | } |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 142 | |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 143 | drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 144 | |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 145 | if (!drvdata) { |
| 146 | ret = -ENOMEM; |
| 147 | goto fail; |
| 148 | } |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 149 | |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 150 | if (!iommu_dev) { |
| 151 | ret = -ENODEV; |
| 152 | goto fail; |
| 153 | } |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 154 | |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 155 | iommu_pclk = clk_get(NULL, "smmu_pclk"); |
| 156 | if (IS_ERR(iommu_pclk)) { |
| 157 | ret = -ENODEV; |
| 158 | goto fail; |
| 159 | } |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 160 | |
Stephen Boyd | 1107b17 | 2013-06-17 10:43:12 -0700 | [diff] [blame] | 161 | ret = clk_prepare_enable(iommu_pclk); |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 162 | if (ret) |
| 163 | goto fail_enable; |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 164 | |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 165 | iommu_clk = clk_get(&pdev->dev, "iommu_clk"); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 166 | |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 167 | if (!IS_ERR(iommu_clk)) { |
| 168 | if (clk_get_rate(iommu_clk) == 0) |
Stephen Boyd | 8d21415 | 2013-06-17 10:43:13 -0700 | [diff] [blame] | 169 | clk_set_rate(iommu_clk, 1); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 170 | |
Stephen Boyd | 1107b17 | 2013-06-17 10:43:12 -0700 | [diff] [blame] | 171 | ret = clk_prepare_enable(iommu_clk); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 172 | if (ret) { |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 173 | clk_put(iommu_clk); |
| 174 | goto fail_pclk; |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 175 | } |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 176 | } else |
| 177 | iommu_clk = NULL; |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 178 | |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 179 | r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "physbase"); |
Kefeng Wang | afba256 | 2014-05-27 18:18:42 +0800 | [diff] [blame] | 180 | regs_base = devm_ioremap_resource(&pdev->dev, r); |
| 181 | if (IS_ERR(regs_base)) { |
| 182 | ret = PTR_ERR(regs_base); |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 183 | goto fail_clk; |
| 184 | } |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 185 | |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 186 | irq = platform_get_irq_byname(pdev, "secure_irq"); |
| 187 | if (irq < 0) { |
| 188 | ret = -ENODEV; |
Kefeng Wang | afba256 | 2014-05-27 18:18:42 +0800 | [diff] [blame] | 189 | goto fail_clk; |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 190 | } |
| 191 | |
Stepan Moskovchenko | a43d8c1 | 2011-02-24 18:00:42 -0800 | [diff] [blame] | 192 | msm_iommu_reset(regs_base, iommu_dev->ncb); |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 193 | |
Stepan Moskovchenko | a43d8c1 | 2011-02-24 18:00:42 -0800 | [diff] [blame] | 194 | SET_M(regs_base, 0, 1); |
| 195 | SET_PAR(regs_base, 0, 0); |
| 196 | SET_V2PCFG(regs_base, 0, 1); |
| 197 | SET_V2PPR(regs_base, 0, 0); |
| 198 | par = GET_PAR(regs_base, 0); |
| 199 | SET_V2PCFG(regs_base, 0, 0); |
| 200 | SET_M(regs_base, 0, 0); |
| 201 | |
| 202 | if (!par) { |
| 203 | pr_err("%s: Invalid PAR value detected\n", iommu_dev->name); |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 204 | ret = -ENODEV; |
Kefeng Wang | afba256 | 2014-05-27 18:18:42 +0800 | [diff] [blame] | 205 | goto fail_clk; |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | ret = request_irq(irq, msm_iommu_fault_handler, 0, |
| 209 | "msm_iommu_secure_irpt_handler", drvdata); |
| 210 | if (ret) { |
| 211 | pr_err("Request IRQ %d failed with ret=%d\n", irq, ret); |
Kefeng Wang | afba256 | 2014-05-27 18:18:42 +0800 | [diff] [blame] | 212 | goto fail_clk; |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 213 | } |
| 214 | |
Stepan Moskovchenko | a43d8c1 | 2011-02-24 18:00:42 -0800 | [diff] [blame] | 215 | |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 216 | drvdata->pclk = iommu_pclk; |
| 217 | drvdata->clk = iommu_clk; |
| 218 | drvdata->base = regs_base; |
| 219 | drvdata->irq = irq; |
Stepan Moskovchenko | a43d8c1 | 2011-02-24 18:00:42 -0800 | [diff] [blame] | 220 | drvdata->ncb = iommu_dev->ncb; |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 221 | |
| 222 | pr_info("device %s mapped at %p, irq %d with %d ctx banks\n", |
Stepan Moskovchenko | a43d8c1 | 2011-02-24 18:00:42 -0800 | [diff] [blame] | 223 | iommu_dev->name, regs_base, irq, iommu_dev->ncb); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 224 | |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 225 | platform_set_drvdata(pdev, drvdata); |
| 226 | |
SF Markus Elfring | c72acf6 | 2014-10-22 20:00:17 +0200 | [diff] [blame] | 227 | clk_disable(iommu_clk); |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 228 | |
| 229 | clk_disable(iommu_pclk); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 230 | |
| 231 | return 0; |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 232 | fail_clk: |
| 233 | if (iommu_clk) { |
| 234 | clk_disable(iommu_clk); |
| 235 | clk_put(iommu_clk); |
| 236 | } |
| 237 | fail_pclk: |
Stephen Boyd | 1107b17 | 2013-06-17 10:43:12 -0700 | [diff] [blame] | 238 | clk_disable_unprepare(iommu_pclk); |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 239 | fail_enable: |
| 240 | clk_put(iommu_pclk); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 241 | fail: |
| 242 | kfree(drvdata); |
| 243 | return ret; |
| 244 | } |
| 245 | |
| 246 | static int msm_iommu_remove(struct platform_device *pdev) |
| 247 | { |
| 248 | struct msm_iommu_drvdata *drv = NULL; |
| 249 | |
| 250 | drv = platform_get_drvdata(pdev); |
| 251 | if (drv) { |
Stephen Boyd | 1107b17 | 2013-06-17 10:43:12 -0700 | [diff] [blame] | 252 | if (drv->clk) { |
| 253 | clk_unprepare(drv->clk); |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 254 | clk_put(drv->clk); |
Stephen Boyd | 1107b17 | 2013-06-17 10:43:12 -0700 | [diff] [blame] | 255 | } |
| 256 | clk_unprepare(drv->pclk); |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 257 | clk_put(drv->pclk); |
| 258 | memset(drv, 0, sizeof(*drv)); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 259 | kfree(drv); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 260 | } |
| 261 | return 0; |
| 262 | } |
| 263 | |
| 264 | static int msm_iommu_ctx_probe(struct platform_device *pdev) |
| 265 | { |
Kiran Padwal | 263bc3f | 2014-10-30 11:55:11 +0530 | [diff] [blame] | 266 | struct msm_iommu_ctx_dev *c = dev_get_platdata(&pdev->dev); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 267 | struct msm_iommu_drvdata *drvdata; |
Libo Chen | 34e3a58c | 2013-07-08 15:59:47 -0700 | [diff] [blame] | 268 | struct msm_iommu_ctx_drvdata *ctx_drvdata; |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 269 | int i, ret; |
Libo Chen | 34e3a58c | 2013-07-08 15:59:47 -0700 | [diff] [blame] | 270 | |
| 271 | if (!c || !pdev->dev.parent) |
| 272 | return -EINVAL; |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 273 | |
| 274 | drvdata = dev_get_drvdata(pdev->dev.parent); |
Libo Chen | 34e3a58c | 2013-07-08 15:59:47 -0700 | [diff] [blame] | 275 | if (!drvdata) |
| 276 | return -ENODEV; |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 277 | |
| 278 | ctx_drvdata = kzalloc(sizeof(*ctx_drvdata), GFP_KERNEL); |
Libo Chen | 34e3a58c | 2013-07-08 15:59:47 -0700 | [diff] [blame] | 279 | if (!ctx_drvdata) |
| 280 | return -ENOMEM; |
| 281 | |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 282 | ctx_drvdata->num = c->num; |
| 283 | ctx_drvdata->pdev = pdev; |
| 284 | |
| 285 | INIT_LIST_HEAD(&ctx_drvdata->attached_elm); |
| 286 | platform_set_drvdata(pdev, ctx_drvdata); |
| 287 | |
Stephen Boyd | 1107b17 | 2013-06-17 10:43:12 -0700 | [diff] [blame] | 288 | ret = clk_prepare_enable(drvdata->pclk); |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 289 | if (ret) |
| 290 | goto fail; |
| 291 | |
| 292 | if (drvdata->clk) { |
Stephen Boyd | 1107b17 | 2013-06-17 10:43:12 -0700 | [diff] [blame] | 293 | ret = clk_prepare_enable(drvdata->clk); |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 294 | if (ret) { |
Stephen Boyd | 1107b17 | 2013-06-17 10:43:12 -0700 | [diff] [blame] | 295 | clk_disable_unprepare(drvdata->pclk); |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 296 | goto fail; |
| 297 | } |
| 298 | } |
| 299 | |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 300 | /* Program the M2V tables for this context */ |
| 301 | for (i = 0; i < MAX_NUM_MIDS; i++) { |
| 302 | int mid = c->mids[i]; |
| 303 | if (mid == -1) |
| 304 | break; |
| 305 | |
| 306 | SET_M2VCBR_N(drvdata->base, mid, 0); |
| 307 | SET_CBACR_N(drvdata->base, c->num, 0); |
| 308 | |
Stepan Moskovchenko | 2e8c8ba | 2011-02-24 18:00:41 -0800 | [diff] [blame] | 309 | /* Set VMID = 0 */ |
| 310 | SET_VMID(drvdata->base, mid, 0); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 311 | |
| 312 | /* Set the context number for that MID to this context */ |
| 313 | SET_CBNDX(drvdata->base, mid, c->num); |
| 314 | |
Stepan Moskovchenko | 2e8c8ba | 2011-02-24 18:00:41 -0800 | [diff] [blame] | 315 | /* Set MID associated with this context bank to 0*/ |
| 316 | SET_CBVMID(drvdata->base, c->num, 0); |
| 317 | |
| 318 | /* Set the ASID for TLB tagging for this context */ |
| 319 | SET_CONTEXTIDR_ASID(drvdata->base, c->num, c->num); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 320 | |
| 321 | /* Set security bit override to be Non-secure */ |
| 322 | SET_NSCFG(drvdata->base, mid, 3); |
| 323 | } |
| 324 | |
SF Markus Elfring | c72acf6 | 2014-10-22 20:00:17 +0200 | [diff] [blame] | 325 | clk_disable(drvdata->clk); |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 326 | clk_disable(drvdata->pclk); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 327 | |
Stepan Moskovchenko | b61401a | 2011-02-28 16:03:02 -0800 | [diff] [blame] | 328 | dev_info(&pdev->dev, "context %s using bank %d\n", c->name, c->num); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 329 | return 0; |
| 330 | fail: |
| 331 | kfree(ctx_drvdata); |
| 332 | return ret; |
| 333 | } |
| 334 | |
| 335 | static int msm_iommu_ctx_remove(struct platform_device *pdev) |
| 336 | { |
| 337 | struct msm_iommu_ctx_drvdata *drv = NULL; |
| 338 | drv = platform_get_drvdata(pdev); |
| 339 | if (drv) { |
| 340 | memset(drv, 0, sizeof(struct msm_iommu_ctx_drvdata)); |
| 341 | kfree(drv); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 342 | } |
| 343 | return 0; |
| 344 | } |
| 345 | |
| 346 | static struct platform_driver msm_iommu_driver = { |
| 347 | .driver = { |
| 348 | .name = "msm_iommu", |
| 349 | }, |
| 350 | .probe = msm_iommu_probe, |
| 351 | .remove = msm_iommu_remove, |
| 352 | }; |
| 353 | |
| 354 | static struct platform_driver msm_iommu_ctx_driver = { |
| 355 | .driver = { |
| 356 | .name = "msm_iommu_ctx", |
| 357 | }, |
| 358 | .probe = msm_iommu_ctx_probe, |
| 359 | .remove = msm_iommu_ctx_remove, |
| 360 | }; |
| 361 | |
Thierry Reding | e7479a1 | 2015-12-02 17:26:01 +0100 | [diff] [blame] | 362 | static struct platform_driver * const drivers[] = { |
| 363 | &msm_iommu_driver, |
| 364 | &msm_iommu_ctx_driver, |
| 365 | }; |
| 366 | |
Stepan Moskovchenko | 516cbc7 | 2010-11-12 19:29:53 -0800 | [diff] [blame] | 367 | static int __init msm_iommu_driver_init(void) |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 368 | { |
Thierry Reding | e7479a1 | 2015-12-02 17:26:01 +0100 | [diff] [blame] | 369 | return platform_register_drivers(drivers, ARRAY_SIZE(drivers)); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 370 | } |
| 371 | |
Stepan Moskovchenko | 516cbc7 | 2010-11-12 19:29:53 -0800 | [diff] [blame] | 372 | static void __exit msm_iommu_driver_exit(void) |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 373 | { |
Thierry Reding | e7479a1 | 2015-12-02 17:26:01 +0100 | [diff] [blame] | 374 | platform_unregister_drivers(drivers, ARRAY_SIZE(drivers)); |
Stepan Moskovchenko | c6a5951 | 2010-08-24 18:32:38 -0700 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | subsys_initcall(msm_iommu_driver_init); |
| 378 | module_exit(msm_iommu_driver_exit); |
| 379 | |
| 380 | MODULE_LICENSE("GPL v2"); |
| 381 | MODULE_AUTHOR("Stepan Moskovchenko <stepanm@codeaurora.org>"); |