omap iommu: renamed omap3-iommu to omap-iommu
[pandora-kernel.git] / arch / arm / mach-omap2 / omap-iommu.c
1 /*
2  * omap iommu: omap device registration
3  *
4  * Copyright (C) 2008-2009 Nokia Corporation
5  *
6  * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  */
12
13 #include <linux/platform_device.h>
14
15 #include <plat/iommu.h>
16
17 struct iommu_device {
18         resource_size_t base;
19         int irq;
20         struct iommu_platform_data pdata;
21         struct resource res[2];
22 };
23
24 #ifdef CONFIG_ARCH_OMAP3
25 static struct iommu_device devices[] = {
26         {
27                 .base = 0x480bd400,
28                 .irq = 24,
29                 .pdata = {
30                         .name = "isp",
31                         .nr_tlb_entries = 8,
32                         .clk_name = "cam_ick",
33                 },
34         },
35 #if defined(CONFIG_MPU_BRIDGE_IOMMU)
36         {
37                 .base = 0x5d000000,
38                 .irq = 28,
39                 .pdata = {
40                         .name = "iva2",
41                         .nr_tlb_entries = 32,
42                         .clk_name = "iva2_ck",
43                 },
44         },
45 #endif
46 };
47 #endif
48
49 #define NR_IOMMU_DEVICES ARRAY_SIZE(devices)
50
51 static struct platform_device *omap_iommu_pdev[NR_IOMMU_DEVICES];
52
53 static int __init omap_iommu_init(void)
54 {
55         int i, err;
56         struct resource res[] = {
57                 { .flags = IORESOURCE_MEM },
58                 { .flags = IORESOURCE_IRQ },
59         };
60
61         for (i = 0; i < NR_IOMMU_DEVICES; i++) {
62                 struct platform_device *pdev;
63                 const struct iommu_device *d = &devices[i];
64
65                 pdev = platform_device_alloc("omap-iommu", i);
66                 if (!pdev) {
67                         err = -ENOMEM;
68                         goto err_out;
69                 }
70
71                 res[0].start = d->base;
72                 res[0].end = d->base + MMU_REG_SIZE - 1;
73                 res[1].start = res[1].end = d->irq;
74
75                 err = platform_device_add_resources(pdev, res,
76                                                     ARRAY_SIZE(res));
77                 if (err)
78                         goto err_out;
79                 err = platform_device_add_data(pdev, &d->pdata,
80                                                sizeof(d->pdata));
81                 if (err)
82                         goto err_out;
83                 err = platform_device_add(pdev);
84                 if (err)
85                         goto err_out;
86                 omap_iommu_pdev[i] = pdev;
87         }
88         return 0;
89
90 err_out:
91         while (i--)
92                 platform_device_put(omap_iommu_pdev[i]);
93         return err;
94 }
95 module_init(omap_iommu_init);
96
97 static void __exit omap_iommu_exit(void)
98 {
99         int i;
100
101         for (i = 0; i < NR_IOMMU_DEVICES; i++)
102                 platform_device_unregister(omap_iommu_pdev[i]);
103 }
104 module_exit(omap_iommu_exit);
105
106 MODULE_AUTHOR("Hiroshi DOYU");
107 MODULE_DESCRIPTION("omap iommu: omap device registration");
108 MODULE_LICENSE("GPL v2");