mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
ARM: OMAP2+: omap_device: remove obsolete pm_lats and early_device code
Remove now-obsolete code from arch/arm/mach-omap2/omap_device.c. This mostly consists of removing the first attempt at device PM latency handling. This was never really used, has been replaced by the common dev_pm_qos code, and needs to go away as part of the DT conversion. Also, the early platform_device creation code has been removed, as it appears to be unused. Signed-off-by: Paul Walmsley <paul@pwsan.com> Cc: Kevin Hilman <khilman@deeprootsystems.com>
This commit is contained in:
parent
949db153b6
commit
c1d1cd597f
24 changed files with 99 additions and 610 deletions
|
@ -17,68 +17,15 @@
|
|||
* to control power management and interconnect properties of their
|
||||
* devices.
|
||||
*
|
||||
* In the medium- to long-term, this code should either be
|
||||
* a) implemented via arch-specific pointers in platform_data
|
||||
* or
|
||||
* b) implemented as a proper omap_bus/omap_device in Linux, no more
|
||||
* platform_data func pointers
|
||||
* In the medium- to long-term, this code should be implemented as a
|
||||
* proper omap_bus/omap_device in Linux, no more platform_data func
|
||||
* pointers
|
||||
*
|
||||
*
|
||||
* Guidelines for usage by driver authors:
|
||||
*
|
||||
* 1. These functions are intended to be used by device drivers via
|
||||
* function pointers in struct platform_data. As an example,
|
||||
* omap_device_enable() should be passed to the driver as
|
||||
*
|
||||
* struct foo_driver_platform_data {
|
||||
* ...
|
||||
* int (*device_enable)(struct platform_device *pdev);
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* Note that the generic "device_enable" name is used, rather than
|
||||
* "omap_device_enable". This is so other architectures can pass in their
|
||||
* own enable/disable functions here.
|
||||
*
|
||||
* This should be populated during device setup:
|
||||
*
|
||||
* ...
|
||||
* pdata->device_enable = omap_device_enable;
|
||||
* ...
|
||||
*
|
||||
* 2. Drivers should first check to ensure the function pointer is not null
|
||||
* before calling it, as in:
|
||||
*
|
||||
* if (pdata->device_enable)
|
||||
* pdata->device_enable(pdev);
|
||||
*
|
||||
* This allows other architectures that don't use similar device_enable()/
|
||||
* device_shutdown() functions to execute normally.
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* Suggested usage by device drivers:
|
||||
*
|
||||
* During device initialization:
|
||||
* device_enable()
|
||||
*
|
||||
* During device idle:
|
||||
* (save remaining device context if necessary)
|
||||
* device_idle();
|
||||
*
|
||||
* During device resume:
|
||||
* device_enable();
|
||||
* (restore context if necessary)
|
||||
*
|
||||
* During device shutdown:
|
||||
* device_shutdown()
|
||||
* (device must be reinitialized at this point to use it again)
|
||||
*
|
||||
*/
|
||||
#undef DEBUG
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/err.h>
|
||||
|
@ -92,155 +39,8 @@
|
|||
#include "omap_device.h"
|
||||
#include "omap_hwmod.h"
|
||||
|
||||
/* These parameters are passed to _omap_device_{de,}activate() */
|
||||
#define USE_WAKEUP_LAT 0
|
||||
#define IGNORE_WAKEUP_LAT 1
|
||||
|
||||
static int omap_early_device_register(struct platform_device *pdev);
|
||||
|
||||
static struct omap_device_pm_latency omap_default_latency[] = {
|
||||
{
|
||||
.deactivate_func = omap_device_idle_hwmods,
|
||||
.activate_func = omap_device_enable_hwmods,
|
||||
.flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
|
||||
}
|
||||
};
|
||||
|
||||
/* Private functions */
|
||||
|
||||
/**
|
||||
* _omap_device_activate - increase device readiness
|
||||
* @od: struct omap_device *
|
||||
* @ignore_lat: increase to latency target (0) or full readiness (1)?
|
||||
*
|
||||
* Increase readiness of omap_device @od (thus decreasing device
|
||||
* wakeup latency, but consuming more power). If @ignore_lat is
|
||||
* IGNORE_WAKEUP_LAT, make the omap_device fully active. Otherwise,
|
||||
* if @ignore_lat is USE_WAKEUP_LAT, and the device's maximum wakeup
|
||||
* latency is greater than the requested maximum wakeup latency, step
|
||||
* backwards in the omap_device_pm_latency table to ensure the
|
||||
* device's maximum wakeup latency is less than or equal to the
|
||||
* requested maximum wakeup latency. Returns 0.
|
||||
*/
|
||||
static int _omap_device_activate(struct omap_device *od, u8 ignore_lat)
|
||||
{
|
||||
struct timespec a, b, c;
|
||||
|
||||
dev_dbg(&od->pdev->dev, "omap_device: activating\n");
|
||||
|
||||
while (od->pm_lat_level > 0) {
|
||||
struct omap_device_pm_latency *odpl;
|
||||
unsigned long long act_lat = 0;
|
||||
|
||||
od->pm_lat_level--;
|
||||
|
||||
odpl = od->pm_lats + od->pm_lat_level;
|
||||
|
||||
if (!ignore_lat &&
|
||||
(od->dev_wakeup_lat <= od->_dev_wakeup_lat_limit))
|
||||
break;
|
||||
|
||||
read_persistent_clock(&a);
|
||||
|
||||
/* XXX check return code */
|
||||
odpl->activate_func(od);
|
||||
|
||||
read_persistent_clock(&b);
|
||||
|
||||
c = timespec_sub(b, a);
|
||||
act_lat = timespec_to_ns(&c);
|
||||
|
||||
dev_dbg(&od->pdev->dev,
|
||||
"omap_device: pm_lat %d: activate: elapsed time %llu nsec\n",
|
||||
od->pm_lat_level, act_lat);
|
||||
|
||||
if (act_lat > odpl->activate_lat) {
|
||||
odpl->activate_lat_worst = act_lat;
|
||||
if (odpl->flags & OMAP_DEVICE_LATENCY_AUTO_ADJUST) {
|
||||
odpl->activate_lat = act_lat;
|
||||
dev_dbg(&od->pdev->dev,
|
||||
"new worst case activate latency %d: %llu\n",
|
||||
od->pm_lat_level, act_lat);
|
||||
} else
|
||||
dev_warn(&od->pdev->dev,
|
||||
"activate latency %d higher than expected. (%llu > %d)\n",
|
||||
od->pm_lat_level, act_lat,
|
||||
odpl->activate_lat);
|
||||
}
|
||||
|
||||
od->dev_wakeup_lat -= odpl->activate_lat;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* _omap_device_deactivate - decrease device readiness
|
||||
* @od: struct omap_device *
|
||||
* @ignore_lat: decrease to latency target (0) or full inactivity (1)?
|
||||
*
|
||||
* Decrease readiness of omap_device @od (thus increasing device
|
||||
* wakeup latency, but conserving power). If @ignore_lat is
|
||||
* IGNORE_WAKEUP_LAT, make the omap_device fully inactive. Otherwise,
|
||||
* if @ignore_lat is USE_WAKEUP_LAT, and the device's maximum wakeup
|
||||
* latency is less than the requested maximum wakeup latency, step
|
||||
* forwards in the omap_device_pm_latency table to ensure the device's
|
||||
* maximum wakeup latency is less than or equal to the requested
|
||||
* maximum wakeup latency. Returns 0.
|
||||
*/
|
||||
static int _omap_device_deactivate(struct omap_device *od, u8 ignore_lat)
|
||||
{
|
||||
struct timespec a, b, c;
|
||||
|
||||
dev_dbg(&od->pdev->dev, "omap_device: deactivating\n");
|
||||
|
||||
while (od->pm_lat_level < od->pm_lats_cnt) {
|
||||
struct omap_device_pm_latency *odpl;
|
||||
unsigned long long deact_lat = 0;
|
||||
|
||||
odpl = od->pm_lats + od->pm_lat_level;
|
||||
|
||||
if (!ignore_lat &&
|
||||
((od->dev_wakeup_lat + odpl->activate_lat) >
|
||||
od->_dev_wakeup_lat_limit))
|
||||
break;
|
||||
|
||||
read_persistent_clock(&a);
|
||||
|
||||
/* XXX check return code */
|
||||
odpl->deactivate_func(od);
|
||||
|
||||
read_persistent_clock(&b);
|
||||
|
||||
c = timespec_sub(b, a);
|
||||
deact_lat = timespec_to_ns(&c);
|
||||
|
||||
dev_dbg(&od->pdev->dev,
|
||||
"omap_device: pm_lat %d: deactivate: elapsed time %llu nsec\n",
|
||||
od->pm_lat_level, deact_lat);
|
||||
|
||||
if (deact_lat > odpl->deactivate_lat) {
|
||||
odpl->deactivate_lat_worst = deact_lat;
|
||||
if (odpl->flags & OMAP_DEVICE_LATENCY_AUTO_ADJUST) {
|
||||
odpl->deactivate_lat = deact_lat;
|
||||
dev_dbg(&od->pdev->dev,
|
||||
"new worst case deactivate latency %d: %llu\n",
|
||||
od->pm_lat_level, deact_lat);
|
||||
} else
|
||||
dev_warn(&od->pdev->dev,
|
||||
"deactivate latency %d higher than expected. (%llu > %d)\n",
|
||||
od->pm_lat_level, deact_lat,
|
||||
odpl->deactivate_lat);
|
||||
}
|
||||
|
||||
od->dev_wakeup_lat += odpl->activate_lat;
|
||||
|
||||
od->pm_lat_level++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _add_clkdev(struct omap_device *od, const char *clk_alias,
|
||||
const char *clk_name)
|
||||
{
|
||||
|
@ -315,9 +115,6 @@ static void _add_hwmod_clocks_clkdev(struct omap_device *od,
|
|||
* @oh: ptr to the single omap_hwmod that backs this omap_device
|
||||
* @pdata: platform_data ptr to associate with the platform_device
|
||||
* @pdata_len: amount of memory pointed to by @pdata
|
||||
* @pm_lats: pointer to a omap_device_pm_latency array for this device
|
||||
* @pm_lats_cnt: ARRAY_SIZE() of @pm_lats
|
||||
* @is_early_device: should the device be registered as an early device or not
|
||||
*
|
||||
* Function for building an omap_device already registered from device-tree
|
||||
*
|
||||
|
@ -356,7 +153,7 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
|
|||
hwmods[i] = oh;
|
||||
}
|
||||
|
||||
od = omap_device_alloc(pdev, hwmods, oh_cnt, NULL, 0);
|
||||
od = omap_device_alloc(pdev, hwmods, oh_cnt);
|
||||
if (!od) {
|
||||
dev_err(&pdev->dev, "Cannot allocate omap_device for :%s\n",
|
||||
oh_name);
|
||||
|
@ -407,6 +204,39 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
|
|||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* _omap_device_enable_hwmods - call omap_hwmod_enable() on all hwmods
|
||||
* @od: struct omap_device *od
|
||||
*
|
||||
* Enable all underlying hwmods. Returns 0.
|
||||
*/
|
||||
static int _omap_device_enable_hwmods(struct omap_device *od)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < od->hwmods_cnt; i++)
|
||||
omap_hwmod_enable(od->hwmods[i]);
|
||||
|
||||
/* XXX pass along return value here? */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* _omap_device_idle_hwmods - call omap_hwmod_idle() on all hwmods
|
||||
* @od: struct omap_device *od
|
||||
*
|
||||
* Idle all underlying hwmods. Returns 0.
|
||||
*/
|
||||
static int _omap_device_idle_hwmods(struct omap_device *od)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < od->hwmods_cnt; i++)
|
||||
omap_hwmod_idle(od->hwmods[i]);
|
||||
|
||||
/* XXX pass along return value here? */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Public functions for use by core code */
|
||||
|
||||
|
@ -526,18 +356,14 @@ static int _od_fill_dma_resources(struct omap_device *od,
|
|||
* @oh: ptr to the single omap_hwmod that backs this omap_device
|
||||
* @pdata: platform_data ptr to associate with the platform_device
|
||||
* @pdata_len: amount of memory pointed to by @pdata
|
||||
* @pm_lats: pointer to a omap_device_pm_latency array for this device
|
||||
* @pm_lats_cnt: ARRAY_SIZE() of @pm_lats
|
||||
*
|
||||
* Convenience function for allocating an omap_device structure and filling
|
||||
* hwmods, resources and pm_latency attributes.
|
||||
* hwmods, and resources.
|
||||
*
|
||||
* Returns an struct omap_device pointer or ERR_PTR() on error;
|
||||
*/
|
||||
struct omap_device *omap_device_alloc(struct platform_device *pdev,
|
||||
struct omap_hwmod **ohs, int oh_cnt,
|
||||
struct omap_device_pm_latency *pm_lats,
|
||||
int pm_lats_cnt)
|
||||
struct omap_hwmod **ohs, int oh_cnt)
|
||||
{
|
||||
int ret = -ENOMEM;
|
||||
struct omap_device *od;
|
||||
|
@ -626,18 +452,6 @@ struct omap_device *omap_device_alloc(struct platform_device *pdev,
|
|||
goto oda_exit3;
|
||||
|
||||
have_everything:
|
||||
if (!pm_lats) {
|
||||
pm_lats = omap_default_latency;
|
||||
pm_lats_cnt = ARRAY_SIZE(omap_default_latency);
|
||||
}
|
||||
|
||||
od->pm_lats_cnt = pm_lats_cnt;
|
||||
od->pm_lats = kmemdup(pm_lats,
|
||||
sizeof(struct omap_device_pm_latency) * pm_lats_cnt,
|
||||
GFP_KERNEL);
|
||||
if (!od->pm_lats)
|
||||
goto oda_exit3;
|
||||
|
||||
pdev->archdata.od = od;
|
||||
|
||||
for (i = 0; i < oh_cnt; i++) {
|
||||
|
@ -663,7 +477,6 @@ void omap_device_delete(struct omap_device *od)
|
|||
return;
|
||||
|
||||
od->pdev->archdata.od = NULL;
|
||||
kfree(od->pm_lats);
|
||||
kfree(od->hwmods);
|
||||
kfree(od);
|
||||
}
|
||||
|
@ -675,9 +488,6 @@ void omap_device_delete(struct omap_device *od)
|
|||
* @oh: ptr to the single omap_hwmod that backs this omap_device
|
||||
* @pdata: platform_data ptr to associate with the platform_device
|
||||
* @pdata_len: amount of memory pointed to by @pdata
|
||||
* @pm_lats: pointer to a omap_device_pm_latency array for this device
|
||||
* @pm_lats_cnt: ARRAY_SIZE() of @pm_lats
|
||||
* @is_early_device: should the device be registered as an early device or not
|
||||
*
|
||||
* Convenience function for building and registering a single
|
||||
* omap_device record, which in turn builds and registers a
|
||||
|
@ -685,11 +495,10 @@ void omap_device_delete(struct omap_device *od)
|
|||
* information. Returns ERR_PTR(-EINVAL) if @oh is NULL; otherwise,
|
||||
* passes along the return value of omap_device_build_ss().
|
||||
*/
|
||||
struct platform_device __init *omap_device_build(const char *pdev_name, int pdev_id,
|
||||
struct omap_hwmod *oh, void *pdata,
|
||||
int pdata_len,
|
||||
struct omap_device_pm_latency *pm_lats,
|
||||
int pm_lats_cnt, int is_early_device)
|
||||
struct platform_device __init *omap_device_build(const char *pdev_name,
|
||||
int pdev_id,
|
||||
struct omap_hwmod *oh,
|
||||
void *pdata, int pdata_len)
|
||||
{
|
||||
struct omap_hwmod *ohs[] = { oh };
|
||||
|
||||
|
@ -697,8 +506,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name, int pdev
|
|||
return ERR_PTR(-EINVAL);
|
||||
|
||||
return omap_device_build_ss(pdev_name, pdev_id, ohs, 1, pdata,
|
||||
pdata_len, pm_lats, pm_lats_cnt,
|
||||
is_early_device);
|
||||
pdata_len);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -708,9 +516,6 @@ struct platform_device __init *omap_device_build(const char *pdev_name, int pdev
|
|||
* @oh: ptr to the single omap_hwmod that backs this omap_device
|
||||
* @pdata: platform_data ptr to associate with the platform_device
|
||||
* @pdata_len: amount of memory pointed to by @pdata
|
||||
* @pm_lats: pointer to a omap_device_pm_latency array for this device
|
||||
* @pm_lats_cnt: ARRAY_SIZE() of @pm_lats
|
||||
* @is_early_device: should the device be registered as an early device or not
|
||||
*
|
||||
* Convenience function for building and registering an omap_device
|
||||
* subsystem record. Subsystem records consist of multiple
|
||||
|
@ -718,11 +523,11 @@ struct platform_device __init *omap_device_build(const char *pdev_name, int pdev
|
|||
* platform_device record. Returns an ERR_PTR() on error, or passes
|
||||
* along the return value of omap_device_register().
|
||||
*/
|
||||
struct platform_device __init *omap_device_build_ss(const char *pdev_name, int pdev_id,
|
||||
struct omap_hwmod **ohs, int oh_cnt,
|
||||
void *pdata, int pdata_len,
|
||||
struct omap_device_pm_latency *pm_lats,
|
||||
int pm_lats_cnt, int is_early_device)
|
||||
struct platform_device __init *omap_device_build_ss(const char *pdev_name,
|
||||
int pdev_id,
|
||||
struct omap_hwmod **ohs,
|
||||
int oh_cnt, void *pdata,
|
||||
int pdata_len)
|
||||
{
|
||||
int ret = -ENOMEM;
|
||||
struct platform_device *pdev;
|
||||
|
@ -746,7 +551,7 @@ struct platform_device __init *omap_device_build_ss(const char *pdev_name, int p
|
|||
else
|
||||
dev_set_name(&pdev->dev, "%s", pdev->name);
|
||||
|
||||
od = omap_device_alloc(pdev, ohs, oh_cnt, pm_lats, pm_lats_cnt);
|
||||
od = omap_device_alloc(pdev, ohs, oh_cnt);
|
||||
if (IS_ERR(od))
|
||||
goto odbs_exit1;
|
||||
|
||||
|
@ -754,10 +559,7 @@ struct platform_device __init *omap_device_build_ss(const char *pdev_name, int p
|
|||
if (ret)
|
||||
goto odbs_exit2;
|
||||
|
||||
if (is_early_device)
|
||||
ret = omap_early_device_register(pdev);
|
||||
else
|
||||
ret = omap_device_register(pdev);
|
||||
ret = omap_device_register(pdev);
|
||||
if (ret)
|
||||
goto odbs_exit2;
|
||||
|
||||
|
@ -774,24 +576,6 @@ odbs_exit:
|
|||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* omap_early_device_register - register an omap_device as an early platform
|
||||
* device.
|
||||
* @od: struct omap_device * to register
|
||||
*
|
||||
* Register the omap_device structure. This currently just calls
|
||||
* platform_early_add_device() on the underlying platform_device.
|
||||
* Returns 0 by default.
|
||||
*/
|
||||
static int __init omap_early_device_register(struct platform_device *pdev)
|
||||
{
|
||||
struct platform_device *devices[1];
|
||||
|
||||
devices[0] = pdev;
|
||||
early_platform_add_devices(devices, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_RUNTIME
|
||||
static int _od_runtime_suspend(struct device *dev)
|
||||
{
|
||||
|
@ -902,10 +686,9 @@ int omap_device_register(struct platform_device *pdev)
|
|||
* to be accessible and ready to operate. This generally involves
|
||||
* enabling clocks, setting SYSCONFIG registers; and in the future may
|
||||
* involve remuxing pins. Device drivers should call this function
|
||||
* (through platform_data function pointers) where they would normally
|
||||
* enable clocks, etc. Returns -EINVAL if called when the omap_device
|
||||
* is already enabled, or passes along the return value of
|
||||
* _omap_device_activate().
|
||||
* indirectly via pm_runtime_get*(). Returns -EINVAL if called when
|
||||
* the omap_device is already enabled, or passes along the return
|
||||
* value of _omap_device_enable_hwmods().
|
||||
*/
|
||||
int omap_device_enable(struct platform_device *pdev)
|
||||
{
|
||||
|
@ -921,14 +704,8 @@ int omap_device_enable(struct platform_device *pdev)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Enable everything if we're enabling this device from scratch */
|
||||
if (od->_state == OMAP_DEVICE_STATE_UNKNOWN)
|
||||
od->pm_lat_level = od->pm_lats_cnt;
|
||||
ret = _omap_device_enable_hwmods(od);
|
||||
|
||||
ret = _omap_device_activate(od, IGNORE_WAKEUP_LAT);
|
||||
|
||||
od->dev_wakeup_lat = 0;
|
||||
od->_dev_wakeup_lat_limit = UINT_MAX;
|
||||
od->_state = OMAP_DEVICE_STATE_ENABLED;
|
||||
|
||||
return ret;
|
||||
|
@ -938,14 +715,10 @@ int omap_device_enable(struct platform_device *pdev)
|
|||
* omap_device_idle - idle an omap_device
|
||||
* @od: struct omap_device * to idle
|
||||
*
|
||||
* Idle omap_device @od by calling as many .deactivate_func() entries
|
||||
* in the omap_device's pm_lats table as is possible without exceeding
|
||||
* the device's maximum wakeup latency limit, pm_lat_limit. Device
|
||||
* drivers should call this function (through platform_data function
|
||||
* pointers) where they would normally disable clocks after operations
|
||||
* complete, etc.. Returns -EINVAL if the omap_device is not
|
||||
* Idle omap_device @od. Device drivers call this function indirectly
|
||||
* via pm_runtime_put*(). Returns -EINVAL if the omap_device is not
|
||||
* currently enabled, or passes along the return value of
|
||||
* _omap_device_deactivate().
|
||||
* _omap_device_idle_hwmods().
|
||||
*/
|
||||
int omap_device_idle(struct platform_device *pdev)
|
||||
{
|
||||
|
@ -961,49 +734,13 @@ int omap_device_idle(struct platform_device *pdev)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = _omap_device_deactivate(od, USE_WAKEUP_LAT);
|
||||
ret = _omap_device_idle_hwmods(od);
|
||||
|
||||
od->_state = OMAP_DEVICE_STATE_IDLE;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* omap_device_shutdown - shut down an omap_device
|
||||
* @od: struct omap_device * to shut down
|
||||
*
|
||||
* Shut down omap_device @od by calling all .deactivate_func() entries
|
||||
* in the omap_device's pm_lats table and then shutting down all of
|
||||
* the underlying omap_hwmods. Used when a device is being "removed"
|
||||
* or a device driver is being unloaded. Returns -EINVAL if the
|
||||
* omap_device is not currently enabled or idle, or passes along the
|
||||
* return value of _omap_device_deactivate().
|
||||
*/
|
||||
int omap_device_shutdown(struct platform_device *pdev)
|
||||
{
|
||||
int ret, i;
|
||||
struct omap_device *od;
|
||||
|
||||
od = to_omap_device(pdev);
|
||||
|
||||
if (od->_state != OMAP_DEVICE_STATE_ENABLED &&
|
||||
od->_state != OMAP_DEVICE_STATE_IDLE) {
|
||||
dev_warn(&pdev->dev,
|
||||
"omap_device: %s() called from invalid state %d\n",
|
||||
__func__, od->_state);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = _omap_device_deactivate(od, IGNORE_WAKEUP_LAT);
|
||||
|
||||
for (i = 0; i < od->hwmods_cnt; i++)
|
||||
omap_hwmod_shutdown(od->hwmods[i]);
|
||||
|
||||
od->_state = OMAP_DEVICE_STATE_SHUTDOWN;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* omap_device_assert_hardreset - set a device's hardreset line
|
||||
* @pdev: struct platform_device * to reset
|
||||
|
@ -1059,86 +796,6 @@ int omap_device_deassert_hardreset(struct platform_device *pdev,
|
|||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* omap_device_align_pm_lat - activate/deactivate device to match wakeup lat lim
|
||||
* @od: struct omap_device *
|
||||
*
|
||||
* When a device's maximum wakeup latency limit changes, call some of
|
||||
* the .activate_func or .deactivate_func function pointers in the
|
||||
* omap_device's pm_lats array to ensure that the device's maximum
|
||||
* wakeup latency is less than or equal to the new latency limit.
|
||||
* Intended to be called by OMAP PM code whenever a device's maximum
|
||||
* wakeup latency limit changes (e.g., via
|
||||
* omap_pm_set_dev_wakeup_lat()). Returns 0 if nothing needs to be
|
||||
* done (e.g., if the omap_device is not currently idle, or if the
|
||||
* wakeup latency is already current with the new limit) or passes
|
||||
* along the return value of _omap_device_deactivate() or
|
||||
* _omap_device_activate().
|
||||
*/
|
||||
int omap_device_align_pm_lat(struct platform_device *pdev,
|
||||
u32 new_wakeup_lat_limit)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
struct omap_device *od;
|
||||
|
||||
od = to_omap_device(pdev);
|
||||
|
||||
if (new_wakeup_lat_limit == od->dev_wakeup_lat)
|
||||
return 0;
|
||||
|
||||
od->_dev_wakeup_lat_limit = new_wakeup_lat_limit;
|
||||
|
||||
if (od->_state != OMAP_DEVICE_STATE_IDLE)
|
||||
return 0;
|
||||
else if (new_wakeup_lat_limit > od->dev_wakeup_lat)
|
||||
ret = _omap_device_deactivate(od, USE_WAKEUP_LAT);
|
||||
else if (new_wakeup_lat_limit < od->dev_wakeup_lat)
|
||||
ret = _omap_device_activate(od, USE_WAKEUP_LAT);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* omap_device_get_pwrdm - return the powerdomain * associated with @od
|
||||
* @od: struct omap_device *
|
||||
*
|
||||
* Return the powerdomain associated with the first underlying
|
||||
* omap_hwmod for this omap_device. Intended for use by core OMAP PM
|
||||
* code. Returns NULL on error or a struct powerdomain * upon
|
||||
* success.
|
||||
*/
|
||||
struct powerdomain *omap_device_get_pwrdm(struct omap_device *od)
|
||||
{
|
||||
/*
|
||||
* XXX Assumes that all omap_hwmod powerdomains are identical.
|
||||
* This may not necessarily be true. There should be a sanity
|
||||
* check in here to WARN() if any difference appears.
|
||||
*/
|
||||
if (!od->hwmods_cnt)
|
||||
return NULL;
|
||||
|
||||
return omap_hwmod_get_pwrdm(od->hwmods[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* omap_device_get_mpu_rt_va - return the MPU's virtual addr for the hwmod base
|
||||
* @od: struct omap_device *
|
||||
*
|
||||
* Return the MPU's virtual address for the base of the hwmod, from
|
||||
* the ioremap() that the hwmod code does. Only valid if there is one
|
||||
* hwmod associated with this device. Returns NULL if there are zero
|
||||
* or more than one hwmods associated with this omap_device;
|
||||
* otherwise, passes along the return value from
|
||||
* omap_hwmod_get_mpu_rt_va().
|
||||
*/
|
||||
void __iomem *omap_device_get_rt_va(struct omap_device *od)
|
||||
{
|
||||
if (od->hwmods_cnt != 1)
|
||||
return NULL;
|
||||
|
||||
return omap_hwmod_get_mpu_rt_va(od->hwmods[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* omap_device_get_by_hwmod_name() - convert a hwmod name to
|
||||
* device pointer.
|
||||
|
@ -1173,82 +830,6 @@ struct device *omap_device_get_by_hwmod_name(const char *oh_name)
|
|||
|
||||
return &oh->od->pdev->dev;
|
||||
}
|
||||
EXPORT_SYMBOL(omap_device_get_by_hwmod_name);
|
||||
|
||||
/*
|
||||
* Public functions intended for use in omap_device_pm_latency
|
||||
* .activate_func and .deactivate_func function pointers
|
||||
*/
|
||||
|
||||
/**
|
||||
* omap_device_enable_hwmods - call omap_hwmod_enable() on all hwmods
|
||||
* @od: struct omap_device *od
|
||||
*
|
||||
* Enable all underlying hwmods. Returns 0.
|
||||
*/
|
||||
int omap_device_enable_hwmods(struct omap_device *od)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < od->hwmods_cnt; i++)
|
||||
omap_hwmod_enable(od->hwmods[i]);
|
||||
|
||||
/* XXX pass along return value here? */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* omap_device_idle_hwmods - call omap_hwmod_idle() on all hwmods
|
||||
* @od: struct omap_device *od
|
||||
*
|
||||
* Idle all underlying hwmods. Returns 0.
|
||||
*/
|
||||
int omap_device_idle_hwmods(struct omap_device *od)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < od->hwmods_cnt; i++)
|
||||
omap_hwmod_idle(od->hwmods[i]);
|
||||
|
||||
/* XXX pass along return value here? */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* omap_device_disable_clocks - disable all main and interface clocks
|
||||
* @od: struct omap_device *od
|
||||
*
|
||||
* Disable the main functional clock and interface clock for all of the
|
||||
* omap_hwmods associated with the omap_device. Returns 0.
|
||||
*/
|
||||
int omap_device_disable_clocks(struct omap_device *od)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < od->hwmods_cnt; i++)
|
||||
omap_hwmod_disable_clocks(od->hwmods[i]);
|
||||
|
||||
/* XXX pass along return value here? */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* omap_device_enable_clocks - enable all main and interface clocks
|
||||
* @od: struct omap_device *od
|
||||
*
|
||||
* Enable the main functional clock and interface clock for all of the
|
||||
* omap_hwmods associated with the omap_device. Returns 0.
|
||||
*/
|
||||
int omap_device_enable_clocks(struct omap_device *od)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < od->hwmods_cnt; i++)
|
||||
omap_hwmod_enable_clocks(od->hwmods[i]);
|
||||
|
||||
/* XXX pass along return value here? */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct notifier_block platform_nb = {
|
||||
.notifier_call = _omap_device_notifier_call,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue