Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f8a7d52 authored by Nishanth Menon's avatar Nishanth Menon Committed by Kevin Hilman
Browse files

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: default avatarNishanth 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: default avatarBenoit Cousson <b-cousson@ti.com>
Signed-off-by: default avatarKevin Hilman <khilman@ti.com>
parent c541c15f
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -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);
					 int pm_lats_cnt, int is_early_device);


void __iomem *omap_device_get_rt_va(struct omap_device *od);
void __iomem *omap_device_get_rt_va(struct omap_device *od);
struct device *omap_device_get_by_hwmod_name(const char *oh_name);


/* OMAP PM interface */
/* OMAP PM interface */
int omap_device_align_pm_lat(struct platform_device *pdev,
int omap_device_align_pm_lat(struct platform_device *pdev,
+36 −0
Original line number Original line Diff line number Diff line
@@ -844,6 +844,42 @@ void __iomem *omap_device_get_rt_va(struct omap_device *od)
	return omap_hwmod_get_mpu_rt_va(od->hwmods[0]);
	return omap_hwmod_get_mpu_rt_va(od->hwmods[0]);
}
}


/**
 * omap_device_get_by_hwmod_name() - convert a hwmod name to
 * device pointer.
 * @oh_name: name of the hwmod device
 *
 * Returns back a struct device * pointer associated with a hwmod
 * device represented by a hwmod_name
 */
struct device *omap_device_get_by_hwmod_name(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);
	}

	if (IS_ERR_OR_NULL(oh->od->pdev))
		return ERR_PTR(oh->od->pdev ? PTR_ERR(oh->od->pdev) : -ENODEV);

	return &oh->od->pdev->dev;
}
EXPORT_SYMBOL(omap_device_get_by_hwmod_name);

/*
/*
 * Public functions intended for use in omap_device_pm_latency
 * Public functions intended for use in omap_device_pm_latency
 * .activate_func and .deactivate_func function pointers
 * .activate_func and .deactivate_func function pointers