aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu/omap-iommu.c
diff options
context:
space:
mode:
authorOhad Ben-Cohen <ohad@wizery.com>2011-10-10 18:18:33 -0400
committerOhad Ben-Cohen <ohad@wizery.com>2011-12-05 08:47:39 -0500
commitfabdbca8c991dfa0ea1ff26214ae7d18e5740cc3 (patch)
treeeb749033a25fd557e21756936ba83180fefdb8c8 /drivers/iommu/omap-iommu.c
parentc8eaab3b74f1326c989e1db8d7c0c14981556e4e (diff)
iommu/omap: eliminate the public omap_find_iommu_device() method
Eliminate the public omap_find_iommu_device() method, and don't expect clients to provide the omap_iommu handle anymore. Instead, OMAP's iommu driver now utilizes dev_archdata's private iommu extension to be able to access the required iommu information. This way OMAP IOMMU users are now able to use the generic IOMMU API without having to call any omap-specific binding method. Update omap3isp appropriately. Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Tony Lindgren <tony@atomide.com> Cc: Hiroshi Doyu <hdoyu@nvidia.com>
Diffstat (limited to 'drivers/iommu/omap-iommu.c')
-rw-r--r--drivers/iommu/omap-iommu.c58
1 files changed, 26 insertions, 32 deletions
diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index 8f32b2bf7587..b7f863d72c08 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -86,20 +86,24 @@ EXPORT_SYMBOL_GPL(omap_uninstall_iommu_arch);
86 86
87/** 87/**
88 * omap_iommu_save_ctx - Save registers for pm off-mode support 88 * omap_iommu_save_ctx - Save registers for pm off-mode support
89 * @obj: target iommu 89 * @dev: client device
90 **/ 90 **/
91void omap_iommu_save_ctx(struct omap_iommu *obj) 91void omap_iommu_save_ctx(struct device *dev)
92{ 92{
93 struct omap_iommu *obj = dev_to_omap_iommu(dev);
94
93 arch_iommu->save_ctx(obj); 95 arch_iommu->save_ctx(obj);
94} 96}
95EXPORT_SYMBOL_GPL(omap_iommu_save_ctx); 97EXPORT_SYMBOL_GPL(omap_iommu_save_ctx);
96 98
97/** 99/**
98 * omap_iommu_restore_ctx - Restore registers for pm off-mode support 100 * omap_iommu_restore_ctx - Restore registers for pm off-mode support
99 * @obj: target iommu 101 * @dev: client device
100 **/ 102 **/
101void omap_iommu_restore_ctx(struct omap_iommu *obj) 103void omap_iommu_restore_ctx(struct device *dev)
102{ 104{
105 struct omap_iommu *obj = dev_to_omap_iommu(dev);
106
103 arch_iommu->restore_ctx(obj); 107 arch_iommu->restore_ctx(obj);
104} 108}
105EXPORT_SYMBOL_GPL(omap_iommu_restore_ctx); 109EXPORT_SYMBOL_GPL(omap_iommu_restore_ctx);
@@ -820,35 +824,23 @@ static int device_match_by_alias(struct device *dev, void *data)
820} 824}
821 825
822/** 826/**
823 * omap_find_iommu_device() - find an omap iommu device by name
824 * @name: name of the iommu device
825 *
826 * The generic iommu API requires the caller to provide the device
827 * he wishes to attach to a certain iommu domain.
828 *
829 * Drivers generally should not bother with this as it should just
830 * be taken care of by the DMA-API using dev_archdata.
831 *
832 * This function is provided as an interim solution until the latter
833 * materializes, and omap3isp is fully migrated to the DMA-API.
834 */
835struct device *omap_find_iommu_device(const char *name)
836{
837 return driver_find_device(&omap_iommu_driver.driver, NULL,
838 (void *)name,
839 device_match_by_alias);
840}
841EXPORT_SYMBOL_GPL(omap_find_iommu_device);
842
843/**
844 * omap_iommu_attach() - attach iommu device to an iommu domain 827 * omap_iommu_attach() - attach iommu device to an iommu domain
845 * @dev: target omap iommu device 828 * @name: name of target omap iommu device
846 * @iopgd: page table 829 * @iopgd: page table
847 **/ 830 **/
848static struct omap_iommu *omap_iommu_attach(struct device *dev, u32 *iopgd) 831static struct omap_iommu *omap_iommu_attach(const char *name, u32 *iopgd)
849{ 832{
850 int err = -ENOMEM; 833 int err = -ENOMEM;
851 struct omap_iommu *obj = to_iommu(dev); 834 struct device *dev;
835 struct omap_iommu *obj;
836
837 dev = driver_find_device(&omap_iommu_driver.driver, NULL,
838 (void *)name,
839 device_match_by_alias);
840 if (!dev)
841 return NULL;
842
843 obj = to_iommu(dev);
852 844
853 spin_lock(&obj->iommu_lock); 845 spin_lock(&obj->iommu_lock);
854 846
@@ -1069,6 +1061,7 @@ omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
1069{ 1061{
1070 struct omap_iommu_domain *omap_domain = domain->priv; 1062 struct omap_iommu_domain *omap_domain = domain->priv;
1071 struct omap_iommu *oiommu; 1063 struct omap_iommu *oiommu;
1064 struct omap_iommu_arch_data *arch_data = dev->archdata.iommu;
1072 int ret = 0; 1065 int ret = 0;
1073 1066
1074 spin_lock(&omap_domain->lock); 1067 spin_lock(&omap_domain->lock);
@@ -1081,14 +1074,14 @@ omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
1081 } 1074 }
1082 1075
1083 /* get a handle to and enable the omap iommu */ 1076 /* get a handle to and enable the omap iommu */
1084 oiommu = omap_iommu_attach(dev, omap_domain->pgtable); 1077 oiommu = omap_iommu_attach(arch_data->name, omap_domain->pgtable);
1085 if (IS_ERR(oiommu)) { 1078 if (IS_ERR(oiommu)) {
1086 ret = PTR_ERR(oiommu); 1079 ret = PTR_ERR(oiommu);
1087 dev_err(dev, "can't get omap iommu: %d\n", ret); 1080 dev_err(dev, "can't get omap iommu: %d\n", ret);
1088 goto out; 1081 goto out;
1089 } 1082 }
1090 1083
1091 omap_domain->iommu_dev = oiommu; 1084 omap_domain->iommu_dev = arch_data->iommu_dev = oiommu;
1092 oiommu->domain = domain; 1085 oiommu->domain = domain;
1093 1086
1094out: 1087out:
@@ -1100,7 +1093,8 @@ static void omap_iommu_detach_dev(struct iommu_domain *domain,
1100 struct device *dev) 1093 struct device *dev)
1101{ 1094{
1102 struct omap_iommu_domain *omap_domain = domain->priv; 1095 struct omap_iommu_domain *omap_domain = domain->priv;
1103 struct omap_iommu *oiommu = to_iommu(dev); 1096 struct omap_iommu_arch_data *arch_data = dev->archdata.iommu;
1097 struct omap_iommu *oiommu = dev_to_omap_iommu(dev);
1104 1098
1105 spin_lock(&omap_domain->lock); 1099 spin_lock(&omap_domain->lock);
1106 1100
@@ -1114,7 +1108,7 @@ static void omap_iommu_detach_dev(struct iommu_domain *domain,
1114 1108
1115 omap_iommu_detach(oiommu); 1109 omap_iommu_detach(oiommu);
1116 1110
1117 omap_domain->iommu_dev = NULL; 1111 omap_domain->iommu_dev = arch_data->iommu_dev = NULL;
1118 1112
1119out: 1113out:
1120 spin_unlock(&omap_domain->lock); 1114 spin_unlock(&omap_domain->lock);