2 * omap iommu: omap device registration
4 * Copyright (C) 2008-2009 Nokia Corporation
6 * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
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.
13 #include <linux/platform_device.h>
14 #include <linux/err.h>
16 #include <plat/iommu.h>
17 #include <plat/omap_device.h>
18 #include <plat/omap_hwmod.h>
24 struct iommu_platform_data pdata
;
25 struct resource res
[2];
27 static struct iommu_platform_data
*devices_data
;
28 static int num_iommu_devices
;
30 #ifdef CONFIG_ARCH_OMAP3
31 static struct iommu_platform_data omap3_devices_data
[] = {
39 #if defined(CONFIG_OMAP_IOMMU_IVA2)
44 .da_start
= 0x11000000,
49 #define NR_OMAP3_IOMMU_DEVICES ARRAY_SIZE(omap3_devices_data)
51 #define omap3_devices_data NULL
52 #define NR_OMAP3_IOMMU_DEVICES 0
55 #ifdef CONFIG_ARCH_OMAP4
56 static struct iommu_platform_data omap4_devices_data
[] = {
72 #define NR_OMAP4_IOMMU_DEVICES ARRAY_SIZE(omap4_devices_data)
74 #define omap4_devices_data NULL
75 #define NR_OMAP4_IOMMU_DEVICES 0
78 static struct omap_device_pm_latency omap_iommu_latency
[] = {
80 .deactivate_func
= omap_device_idle_hwmods
,
81 .activate_func
= omap_device_enable_hwmods
,
82 .flags
= OMAP_DEVICE_LATENCY_AUTO_ADJUST
,
86 int iommu_get_plat_data_size(void)
88 return num_iommu_devices
;
90 EXPORT_SYMBOL(iommu_get_plat_data_size
);
92 struct iommu_platform_data
*iommu_get_device_data(void)
97 static int __init
omap_iommu_init(void)
100 struct omap_hwmod
*oh
;
101 struct omap_device
*od
;
102 struct omap_device_pm_latency
*ohl
;
104 if (cpu_is_omap34xx()) {
105 devices_data
= omap3_devices_data
;
106 num_iommu_devices
= NR_OMAP3_IOMMU_DEVICES
;
107 } else if (cpu_is_omap44xx()) {
108 devices_data
= omap4_devices_data
;
109 num_iommu_devices
= NR_OMAP4_IOMMU_DEVICES
;
113 ohl
= omap_iommu_latency
;
114 ohl_cnt
= ARRAY_SIZE(omap_iommu_latency
);
116 for (i
= 0; i
< num_iommu_devices
; i
++) {
117 struct iommu_platform_data
*data
= &devices_data
[i
];
119 oh
= omap_hwmod_lookup(data
->oh_name
);
120 data
->io_base
= oh
->_mpu_rt_va
;
121 data
->irq
= oh
->mpu_irqs
[0].irq
;
124 pr_err("%s: could not look up %s\n", __func__
,
128 od
= omap_device_build("omap-iommu", i
, oh
,
130 ohl
, ohl_cnt
, false);
131 WARN(IS_ERR(od
), "Could not build omap_device"
132 "for %s %s\n", "omap-iommu", data
->oh_name
);
136 module_init(omap_iommu_init
);
138 MODULE_AUTHOR("Hiroshi DOYU");
139 MODULE_AUTHOR("Hari Kanigeri");
140 MODULE_DESCRIPTION("omap iommu: omap device registration");
141 MODULE_LICENSE("GPL v2");