@@ -101,6 +101,7 @@ struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
int pm_lats_cnt, int is_early_device);
void __iomem *omap_device_get_rt_va(struct omap_device *od);
+struct platform_device *omap_hwmod_name_get_pdev(const char *oh_name);
/* OMAP PM interface */
int omap_device_align_pm_lat(struct platform_device *pdev,
@@ -151,6 +152,15 @@ static inline struct omap_device *to_omap_device(struct platform_device *pdev)
return pdev ? pdev->archdata.od : NULL;
}
+/* Convert omap_hwmod name to device pointer */
+static inline struct device *omap_hwmod_name_get_dev(const char *oh_name)
+{
+ struct platform_device *pdev = omap_hwmod_name_get_pdev(oh_name);
+ if (IS_ERR_OR_NULL(pdev))
+ return ERR_PTR(pdev ? PTR_ERR(pdev) : -ENODEV);
+ return &pdev->dev;
+}
+
static inline
void omap_device_disable_idle_on_suspend(struct platform_device *pdev)
{
@@ -841,6 +841,38 @@ void __iomem *omap_device_get_rt_va(struct omap_device *od)
return omap_hwmod_get_mpu_rt_va(od->hwmods[0]);
}
+/**
+ * omap_hwmod_name_get_pdev() - convert a hwmod name to platform_device pointer
+ * @oh_name: name of the hwmod device
+ *
+ * Returns back a struct platform_device * pointer associated with a hwmod
+ * device represented by a hwmod_name
+ */
+struct platform_device *omap_hwmod_name_get_pdev(const char *oh_name)
+{
+ struct omap_hwmod *oh;
+
+ if (!oh_name) {
+ WARN(1, "%s: no hwmod name!\n", __func__);
+ return ERR_PTR(-EINVAL);
+ }
+
+ oh = omap_hwmod_lookup(oh_name);
+ if (IS_ERR_OR_NULL(oh)) {
+ WARN(1, "%s: no hwmod for %s\n", __func__,
+ oh_name);
+ return ERR_PTR(oh ? PTR_ERR(oh) : -ENODEV);
+ }
+ if (IS_ERR_OR_NULL(oh->od)) {
+ WARN(1, "%s: no omap_device for %s\n", __func__,
+ oh_name);
+ return ERR_PTR(oh->od ? PTR_ERR(oh->od) : -ENODEV);
+ }
+
+ return oh->od->pdev;
+}
+EXPORT_SYMBOL(omap_hwmod_name_get_pdev);
+
/*
* Public functions intended for use in omap_device_pm_latency
* .activate_func and .deactivate_func function pointers