Commit | Line | Data |
---|---|---|
066aa9c1 | 1 | /* |
44da397f | 2 | * omap iommu: omap device registration |
066aa9c1 HD |
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 | ||
ce491cf8 | 15 | #include <plat/iommu.h> |
066aa9c1 | 16 | |
a76e9a90 FC |
17 | struct iommu_device { |
18 | resource_size_t base; | |
19 | int irq; | |
20 | struct iommu_platform_data pdata; | |
21 | struct resource res[2]; | |
066aa9c1 HD |
22 | }; |
23 | ||
44da397f | 24 | #ifdef CONFIG_ARCH_OMAP3 |
a76e9a90 | 25 | static struct iommu_device devices[] = { |
066aa9c1 | 26 | { |
a76e9a90 FC |
27 | .base = 0x480bd400, |
28 | .irq = 24, | |
29 | .pdata = { | |
30 | .name = "isp", | |
31 | .nr_tlb_entries = 8, | |
32 | .clk_name = "cam_ick", | |
33 | }, | |
066aa9c1 | 34 | }, |
5c651ffa | 35 | #if defined(CONFIG_MPU_BRIDGE_IOMMU) |
066aa9c1 | 36 | { |
a76e9a90 FC |
37 | .base = 0x5d000000, |
38 | .irq = 28, | |
39 | .pdata = { | |
40 | .name = "iva2", | |
41 | .nr_tlb_entries = 32, | |
42 | .clk_name = "iva2_ck", | |
43 | }, | |
066aa9c1 | 44 | }, |
5c651ffa | 45 | #endif |
066aa9c1 | 46 | }; |
44da397f KH |
47 | #endif |
48 | ||
a76e9a90 | 49 | #define NR_IOMMU_DEVICES ARRAY_SIZE(devices) |
066aa9c1 | 50 | |
44da397f | 51 | static struct platform_device *omap_iommu_pdev[NR_IOMMU_DEVICES]; |
066aa9c1 | 52 | |
44da397f | 53 | static int __init omap_iommu_init(void) |
066aa9c1 HD |
54 | { |
55 | int i, err; | |
a76e9a90 FC |
56 | struct resource res[] = { |
57 | { .flags = IORESOURCE_MEM }, | |
58 | { .flags = IORESOURCE_IRQ }, | |
59 | }; | |
066aa9c1 HD |
60 | |
61 | for (i = 0; i < NR_IOMMU_DEVICES; i++) { | |
62 | struct platform_device *pdev; | |
a76e9a90 | 63 | const struct iommu_device *d = &devices[i]; |
066aa9c1 HD |
64 | |
65 | pdev = platform_device_alloc("omap-iommu", i); | |
66 | if (!pdev) { | |
67 | err = -ENOMEM; | |
68 | goto err_out; | |
69 | } | |
70 | ||
a76e9a90 FC |
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; | |
066aa9c1 HD |
74 | |
75 | err = platform_device_add_resources(pdev, res, | |
76 | ARRAY_SIZE(res)); | |
77 | if (err) | |
78 | goto err_out; | |
a76e9a90 FC |
79 | err = platform_device_add_data(pdev, &d->pdata, |
80 | sizeof(d->pdata)); | |
066aa9c1 HD |
81 | if (err) |
82 | goto err_out; | |
83 | err = platform_device_add(pdev); | |
84 | if (err) | |
85 | goto err_out; | |
44da397f | 86 | omap_iommu_pdev[i] = pdev; |
066aa9c1 HD |
87 | } |
88 | return 0; | |
89 | ||
90 | err_out: | |
91 | while (i--) | |
44da397f | 92 | platform_device_put(omap_iommu_pdev[i]); |
066aa9c1 HD |
93 | return err; |
94 | } | |
44da397f | 95 | module_init(omap_iommu_init); |
066aa9c1 | 96 | |
44da397f | 97 | static void __exit omap_iommu_exit(void) |
066aa9c1 HD |
98 | { |
99 | int i; | |
100 | ||
101 | for (i = 0; i < NR_IOMMU_DEVICES; i++) | |
44da397f | 102 | platform_device_unregister(omap_iommu_pdev[i]); |
066aa9c1 | 103 | } |
44da397f | 104 | module_exit(omap_iommu_exit); |
066aa9c1 HD |
105 | |
106 | MODULE_AUTHOR("Hiroshi DOYU"); | |
44da397f | 107 | MODULE_DESCRIPTION("omap iommu: omap device registration"); |
066aa9c1 | 108 | MODULE_LICENSE("GPL v2"); |