diff options
Diffstat (limited to 'arch/arm/mach-omap2/omap-iommu.c')
-rw-r--r-- | arch/arm/mach-omap2/omap-iommu.c | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/omap-iommu.c b/arch/arm/mach-omap2/omap-iommu.c new file mode 100644 index 000000000000..eb9bee73e0cb --- /dev/null +++ b/arch/arm/mach-omap2/omap-iommu.c | |||
@@ -0,0 +1,157 @@ | |||
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 | #include <plat/irqs.h> | ||
17 | |||
18 | struct iommu_device { | ||
19 | resource_size_t base; | ||
20 | int irq; | ||
21 | struct iommu_platform_data pdata; | ||
22 | struct resource res[2]; | ||
23 | }; | ||
24 | static struct iommu_device *devices; | ||
25 | static int num_iommu_devices; | ||
26 | |||
27 | #ifdef CONFIG_ARCH_OMAP3 | ||
28 | static struct iommu_device omap3_devices[] = { | ||
29 | { | ||
30 | .base = 0x480bd400, | ||
31 | .irq = 24, | ||
32 | .pdata = { | ||
33 | .name = "isp", | ||
34 | .nr_tlb_entries = 8, | ||
35 | .clk_name = "cam_ick", | ||
36 | }, | ||
37 | }, | ||
38 | #if defined(CONFIG_MPU_BRIDGE_IOMMU) | ||
39 | { | ||
40 | .base = 0x5d000000, | ||
41 | .irq = 28, | ||
42 | .pdata = { | ||
43 | .name = "iva2", | ||
44 | .nr_tlb_entries = 32, | ||
45 | .clk_name = "iva2_ck", | ||
46 | }, | ||
47 | }, | ||
48 | #endif | ||
49 | }; | ||
50 | #define NR_OMAP3_IOMMU_DEVICES ARRAY_SIZE(omap3_devices) | ||
51 | static struct platform_device *omap3_iommu_pdev[NR_OMAP3_IOMMU_DEVICES]; | ||
52 | #else | ||
53 | #define omap3_devices NULL | ||
54 | #define NR_OMAP3_IOMMU_DEVICES 0 | ||
55 | #define omap3_iommu_pdev NULL | ||
56 | #endif | ||
57 | |||
58 | #ifdef CONFIG_ARCH_OMAP4 | ||
59 | static struct iommu_device omap4_devices[] = { | ||
60 | { | ||
61 | .base = OMAP4_MMU1_BASE, | ||
62 | .irq = INT_44XX_DUCATI_MMU_IRQ, | ||
63 | .pdata = { | ||
64 | .name = "ducati", | ||
65 | .nr_tlb_entries = 32, | ||
66 | .clk_name = "ducati_ick", | ||
67 | }, | ||
68 | }, | ||
69 | #if defined(CONFIG_MPU_TESLA_IOMMU) | ||
70 | { | ||
71 | .base = OMAP4_MMU2_BASE, | ||
72 | .irq = INT_44XX_DSP_MMU, | ||
73 | .pdata = { | ||
74 | .name = "tesla", | ||
75 | .nr_tlb_entries = 32, | ||
76 | .clk_name = "tesla_ick", | ||
77 | }, | ||
78 | }, | ||
79 | #endif | ||
80 | }; | ||
81 | #define NR_OMAP4_IOMMU_DEVICES ARRAY_SIZE(omap4_devices) | ||
82 | static struct platform_device *omap4_iommu_pdev[NR_OMAP4_IOMMU_DEVICES]; | ||
83 | #else | ||
84 | #define omap4_devices NULL | ||
85 | #define NR_OMAP4_IOMMU_DEVICES 0 | ||
86 | #define omap4_iommu_pdev NULL | ||
87 | #endif | ||
88 | |||
89 | static struct platform_device **omap_iommu_pdev; | ||
90 | |||
91 | static int __init omap_iommu_init(void) | ||
92 | { | ||
93 | int i, err; | ||
94 | struct resource res[] = { | ||
95 | { .flags = IORESOURCE_MEM }, | ||
96 | { .flags = IORESOURCE_IRQ }, | ||
97 | }; | ||
98 | |||
99 | if (cpu_is_omap34xx()) { | ||
100 | devices = omap3_devices; | ||
101 | omap_iommu_pdev = omap3_iommu_pdev; | ||
102 | num_iommu_devices = NR_OMAP3_IOMMU_DEVICES; | ||
103 | } else if (cpu_is_omap44xx()) { | ||
104 | devices = omap4_devices; | ||
105 | omap_iommu_pdev = omap4_iommu_pdev; | ||
106 | num_iommu_devices = NR_OMAP4_IOMMU_DEVICES; | ||
107 | } else | ||
108 | return -ENODEV; | ||
109 | |||
110 | for (i = 0; i < num_iommu_devices; i++) { | ||
111 | struct platform_device *pdev; | ||
112 | const struct iommu_device *d = &devices[i]; | ||
113 | |||
114 | pdev = platform_device_alloc("omap-iommu", i); | ||
115 | if (!pdev) { | ||
116 | err = -ENOMEM; | ||
117 | goto err_out; | ||
118 | } | ||
119 | |||
120 | res[0].start = d->base; | ||
121 | res[0].end = d->base + MMU_REG_SIZE - 1; | ||
122 | res[1].start = res[1].end = d->irq; | ||
123 | |||
124 | err = platform_device_add_resources(pdev, res, | ||
125 | ARRAY_SIZE(res)); | ||
126 | if (err) | ||
127 | goto err_out; | ||
128 | err = platform_device_add_data(pdev, &d->pdata, | ||
129 | sizeof(d->pdata)); | ||
130 | if (err) | ||
131 | goto err_out; | ||
132 | err = platform_device_add(pdev); | ||
133 | if (err) | ||
134 | goto err_out; | ||
135 | omap_iommu_pdev[i] = pdev; | ||
136 | } | ||
137 | return 0; | ||
138 | |||
139 | err_out: | ||
140 | while (i--) | ||
141 | platform_device_put(omap_iommu_pdev[i]); | ||
142 | return err; | ||
143 | } | ||
144 | module_init(omap_iommu_init); | ||
145 | |||
146 | static void __exit omap_iommu_exit(void) | ||
147 | { | ||
148 | int i; | ||
149 | |||
150 | for (i = 0; i < num_iommu_devices; i++) | ||
151 | platform_device_unregister(omap_iommu_pdev[i]); | ||
152 | } | ||
153 | module_exit(omap_iommu_exit); | ||
154 | |||
155 | MODULE_AUTHOR("Hiroshi DOYU"); | ||
156 | MODULE_DESCRIPTION("omap iommu: omap device registration"); | ||
157 | MODULE_LICENSE("GPL v2"); | ||