18 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20 #include <linux/kernel.h>
21 #include <linux/module.h>
28 #include <linux/slab.h>
49 if (!res || !c || !c->
name || !res->
name)
69 if (!msm_iommu_root_dev) {
70 pr_err(
"No root IOMMU device.\n");
78 pr_err(
"Could not find context <%s>\n", ctx_name);
88 static void msm_iommu_reset(
void __iomem *base,
int ncb)
104 for (ctx = 0; ctx < ncb; ctx++) {
132 struct clk *iommu_clk;
133 struct clk *iommu_pclk;
140 if (pdev->
id == -1) {
141 msm_iommu_root_dev = pdev;
145 drvdata = kzalloc(
sizeof(*drvdata),
GFP_KERNEL);
158 if (IS_ERR(iommu_pclk)) {
169 if (!IS_ERR(iommu_clk)) {
188 len = resource_size(r);
192 pr_err(
"Could not request memory region: start=%p, len=%d\n",
193 (
void *) r->
start, len);
201 pr_err(
"Could not ioremap: start=%p, len=%d\n",
202 (
void *) r2->
start, len);
213 msm_iommu_reset(regs_base, iommu_dev->
ncb);
215 SET_M(regs_base, 0, 1);
221 SET_M(regs_base, 0, 0);
224 pr_err(
"%s: Invalid PAR value detected\n", iommu_dev->
name);
230 "msm_iommu_secure_irpt_handler", drvdata);
232 pr_err(
"Request IRQ %d failed with ret=%d\n", irq, ret);
237 drvdata->
pclk = iommu_pclk;
238 drvdata->
clk = iommu_clk;
239 drvdata->
base = regs_base;
241 drvdata->
ncb = iommu_dev->
ncb;
243 pr_info(
"device %s mapped at %p, irq %d with %d ctx banks\n",
244 iommu_dev->
name, regs_base, irq, iommu_dev->
ncb);
246 platform_set_drvdata(pdev, drvdata);
276 drv = platform_get_drvdata(pdev);
281 memset(drv, 0,
sizeof(*drv));
283 platform_set_drvdata(pdev,
NULL);
294 if (!c || !pdev->
dev.parent) {
306 ctx_drvdata = kzalloc(
sizeof(*ctx_drvdata),
GFP_KERNEL);
311 ctx_drvdata->
num = c->
num;
315 platform_set_drvdata(pdev, ctx_drvdata);
368 drv = platform_get_drvdata(pdev);
372 platform_set_drvdata(pdev,
NULL);
381 .probe = msm_iommu_probe,
382 .remove = msm_iommu_remove,
387 .name =
"msm_iommu_ctx",
389 .probe = msm_iommu_ctx_probe,
390 .remove = msm_iommu_ctx_remove,
393 static int __init msm_iommu_driver_init(
void)
398 pr_err(
"Failed to register IOMMU driver\n");
404 pr_err(
"Failed to register IOMMU context driver\n");
412 static void __exit msm_iommu_driver_exit(
void)