aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2011-07-27 16:02:32 -0400
committerKevin Hilman <khilman@ti.com>2011-10-04 12:52:22 -0400
commit1f8a7d5207a2a343af7c3b18fcc65dc6aa1fb068 (patch)
tree69e6bbeb81fe4c7341960b7ea1909b85800d913a /arch/arm/plat-omap
parentc541c15fb5ab48c47bc9b90121538fd30d152f23 (diff)
ARM: OMAP: omap_device: Add omap_device_get_by_hwmod_name
An API which translates a standard hwmod name to corresponding platform_device is useful for drivers when they need to look up the device associated with a hwmod name to map back into the device structure pointers. These ideally should be used by drivers in mach directory. Using a generic hwmod name like "gpu" instead of the actual device name which could change in the future, allows us to: a) Could in effect help replace apis such as omap2_get_mpuss_device, omap2_get_iva_device, omap2_get_l3_device, omap4_get_dsp_device, etc.. b) Scale to more devices rather than be restricted to named functions c) Simplify driver's platform_data from passing additional fields all doing the same thing with different function pointer names just for accessing a different device name. Signed-off-by: Nishanth Menon <nm@ti.com> [b-cousson@ti.com: Adapt it to the new pdev pointer inside od, remove the unneeded helpers, and fold the next patch here] Signed-off-by: Benoit Cousson <b-cousson@ti.com> Signed-off-by: Kevin Hilman <khilman@ti.com>
Diffstat (limited to 'arch/arm/plat-omap')
-rw-r--r--arch/arm/plat-omap/include/plat/omap_device.h1
-rw-r--r--arch/arm/plat-omap/omap_device.c36
2 files changed, 37 insertions, 0 deletions
diff --git a/arch/arm/plat-omap/include/plat/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h
index d4d9b96f961e..12c5b0c345bf 100644
--- a/arch/arm/plat-omap/include/plat/omap_device.h
+++ b/arch/arm/plat-omap/include/plat/omap_device.h
@@ -101,6 +101,7 @@ struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
101 int pm_lats_cnt, int is_early_device); 101 int pm_lats_cnt, int is_early_device);
102 102
103void __iomem *omap_device_get_rt_va(struct omap_device *od); 103void __iomem *omap_device_get_rt_va(struct omap_device *od);
104struct device *omap_device_get_by_hwmod_name(const char *oh_name);
104 105
105/* OMAP PM interface */ 106/* OMAP PM interface */
106int omap_device_align_pm_lat(struct platform_device *pdev, 107int omap_device_align_pm_lat(struct platform_device *pdev,
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
index 26aee5cc1fc1..f832f92013b2 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -844,6 +844,42 @@ void __iomem *omap_device_get_rt_va(struct omap_device *od)
844 return omap_hwmod_get_mpu_rt_va(od->hwmods[0]); 844 return omap_hwmod_get_mpu_rt_va(od->hwmods[0]);
845} 845}
846 846
847/**
848 * omap_device_get_by_hwmod_name() - convert a hwmod name to
849 * device pointer.
850 * @oh_name: name of the hwmod device
851 *
852 * Returns back a struct device * pointer associated with a hwmod
853 * device represented by a hwmod_name
854 */
855struct device *omap_device_get_by_hwmod_name(const char *oh_name)
856{
857 struct omap_hwmod *oh;
858
859 if (!oh_name) {
860 WARN(1, "%s: no hwmod name!\n", __func__);
861 return ERR_PTR(-EINVAL);
862 }
863
864 oh = omap_hwmod_lookup(oh_name);
865 if (IS_ERR_OR_NULL(oh)) {
866 WARN(1, "%s: no hwmod for %s\n", __func__,
867 oh_name);
868 return ERR_PTR(oh ? PTR_ERR(oh) : -ENODEV);
869 }
870 if (IS_ERR_OR_NULL(oh->od)) {
871 WARN(1, "%s: no omap_device for %s\n", __func__,
872 oh_name);
873 return ERR_PTR(oh->od ? PTR_ERR(oh->od) : -ENODEV);
874 }
875
876 if (IS_ERR_OR_NULL(oh->od->pdev))
877 return ERR_PTR(oh->od->pdev ? PTR_ERR(oh->od->pdev) : -ENODEV);
878
879 return &oh->od->pdev->dev;
880}
881EXPORT_SYMBOL(omap_device_get_by_hwmod_name);
882
847/* 883/*
848 * Public functions intended for use in omap_device_pm_latency 884 * Public functions intended for use in omap_device_pm_latency
849 * .activate_func and .deactivate_func function pointers 885 * .activate_func and .deactivate_func function pointers