2009-09-03 17:14:01 +00:00
|
|
|
/*
|
|
|
|
* omap-pm-noop.c - OMAP power management interface - dummy version
|
|
|
|
*
|
|
|
|
* This code implements the OMAP power management interface to
|
|
|
|
* drivers, CPUIdle, CPUFreq, and DSP Bridge. It is strictly for
|
|
|
|
* debug/demonstration use, as it does nothing but printk() whenever a
|
|
|
|
* function is called (when DEBUG is defined, below)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008-2009 Texas Instruments, Inc.
|
|
|
|
* Copyright (C) 2008-2009 Nokia Corporation
|
|
|
|
* Paul Walmsley
|
|
|
|
*
|
|
|
|
* Interface developed by (in alphabetical order):
|
|
|
|
* Karthik Dasu, Tony Lindgren, Rajendra Nayak, Sakari Poussa, Veeramanikandan
|
|
|
|
* Raju, Anand Sawant, Igor Stoppa, Paul Walmsley, Richard Woodruff
|
|
|
|
*/
|
|
|
|
|
|
|
|
#undef DEBUG
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/cpufreq.h>
|
|
|
|
#include <linux/device.h>
|
2010-12-22 04:31:55 +00:00
|
|
|
#include <linux/platform_device.h>
|
2009-09-03 17:14:01 +00:00
|
|
|
|
2012-10-29 22:20:45 +00:00
|
|
|
#include "omap_device.h"
|
|
|
|
#include "omap-pm.h"
|
2009-09-03 17:14:01 +00:00
|
|
|
|
2010-12-22 04:31:55 +00:00
|
|
|
static bool off_mode_enabled;
|
2011-06-09 13:56:23 +00:00
|
|
|
static int dummy_context_loss_counter;
|
2010-12-22 04:31:55 +00:00
|
|
|
|
2009-09-03 17:14:01 +00:00
|
|
|
/*
|
|
|
|
* Device-driver-originated constraints (via board-*.c files)
|
|
|
|
*/
|
|
|
|
|
2010-07-26 22:34:34 +00:00
|
|
|
int omap_pm_set_max_mpu_wakeup_lat(struct device *dev, long t)
|
2009-09-03 17:14:01 +00:00
|
|
|
{
|
|
|
|
if (!dev || t < -1) {
|
2010-07-26 22:34:34 +00:00
|
|
|
WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
|
|
|
|
return -EINVAL;
|
2012-09-18 16:36:13 +00:00
|
|
|
}
|
2009-09-03 17:14:01 +00:00
|
|
|
|
|
|
|
if (t == -1)
|
2012-07-26 06:54:26 +00:00
|
|
|
pr_debug("OMAP PM: remove max MPU wakeup latency constraint: dev %s\n",
|
|
|
|
dev_name(dev));
|
2009-09-03 17:14:01 +00:00
|
|
|
else
|
2012-07-26 06:54:26 +00:00
|
|
|
pr_debug("OMAP PM: add max MPU wakeup latency constraint: dev %s, t = %ld usec\n",
|
|
|
|
dev_name(dev), t);
|
2009-09-03 17:14:01 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For current Linux, this needs to map the MPU to a
|
|
|
|
* powerdomain, then go through the list of current max lat
|
|
|
|
* constraints on the MPU and find the smallest. If
|
|
|
|
* the latency constraint has changed, the code should
|
|
|
|
* recompute the state to enter for the next powerdomain
|
|
|
|
* state.
|
|
|
|
*
|
|
|
|
* TI CDP code can call constraint_set here.
|
|
|
|
*/
|
2010-07-26 22:34:34 +00:00
|
|
|
|
|
|
|
return 0;
|
2009-09-03 17:14:01 +00:00
|
|
|
}
|
|
|
|
|
2010-07-26 22:34:34 +00:00
|
|
|
int omap_pm_set_min_bus_tput(struct device *dev, u8 agent_id, unsigned long r)
|
2009-09-03 17:14:01 +00:00
|
|
|
{
|
|
|
|
if (!dev || (agent_id != OCP_INITIATOR_AGENT &&
|
|
|
|
agent_id != OCP_TARGET_AGENT)) {
|
2010-07-26 22:34:34 +00:00
|
|
|
WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
|
|
|
|
return -EINVAL;
|
2012-09-18 16:36:13 +00:00
|
|
|
}
|
2009-09-03 17:14:01 +00:00
|
|
|
|
|
|
|
if (r == 0)
|
2012-07-26 06:54:26 +00:00
|
|
|
pr_debug("OMAP PM: remove min bus tput constraint: dev %s for agent_id %d\n",
|
|
|
|
dev_name(dev), agent_id);
|
2009-09-03 17:14:01 +00:00
|
|
|
else
|
2012-07-26 06:54:26 +00:00
|
|
|
pr_debug("OMAP PM: add min bus tput constraint: dev %s for agent_id %d: rate %ld KiB\n",
|
2009-09-03 17:14:01 +00:00
|
|
|
dev_name(dev), agent_id, r);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code should model the interconnect and compute the
|
|
|
|
* required clock frequency, convert that to a VDD2 OPP ID, then
|
|
|
|
* set the VDD2 OPP appropriately.
|
|
|
|
*
|
|
|
|
* TI CDP code can call constraint_set here on the VDD2 OPP.
|
|
|
|
*/
|
2010-07-26 22:34:34 +00:00
|
|
|
|
|
|
|
return 0;
|
2009-09-03 17:14:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DSP Bridge-specific constraints
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-12-22 04:31:55 +00:00
|
|
|
/**
|
|
|
|
* omap_pm_enable_off_mode - notify OMAP PM that off-mode is enabled
|
|
|
|
*
|
|
|
|
* Intended for use only by OMAP PM core code to notify this layer
|
|
|
|
* that off mode has been enabled.
|
|
|
|
*/
|
|
|
|
void omap_pm_enable_off_mode(void)
|
|
|
|
{
|
|
|
|
off_mode_enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* omap_pm_disable_off_mode - notify OMAP PM that off-mode is disabled
|
|
|
|
*
|
|
|
|
* Intended for use only by OMAP PM core code to notify this layer
|
|
|
|
* that off mode has been disabled.
|
|
|
|
*/
|
|
|
|
void omap_pm_disable_off_mode(void)
|
|
|
|
{
|
|
|
|
off_mode_enabled = false;
|
|
|
|
}
|
|
|
|
|
2009-09-03 17:14:01 +00:00
|
|
|
/*
|
|
|
|
* Device context loss tracking
|
|
|
|
*/
|
|
|
|
|
2010-12-22 04:31:55 +00:00
|
|
|
#ifdef CONFIG_ARCH_OMAP2PLUS
|
|
|
|
|
2011-06-09 13:56:23 +00:00
|
|
|
int omap_pm_get_dev_context_loss_count(struct device *dev)
|
2009-09-03 17:14:01 +00:00
|
|
|
{
|
2010-12-22 04:31:55 +00:00
|
|
|
struct platform_device *pdev = to_platform_device(dev);
|
2011-06-09 13:56:23 +00:00
|
|
|
int count;
|
2009-09-03 17:14:01 +00:00
|
|
|
|
2010-12-22 04:31:55 +00:00
|
|
|
if (WARN_ON(!dev))
|
2011-06-09 13:56:23 +00:00
|
|
|
return -ENODEV;
|
2009-09-03 17:14:01 +00:00
|
|
|
|
2012-02-15 19:47:45 +00:00
|
|
|
if (dev->pm_domain == &omap_device_pm_domain) {
|
2010-12-22 04:31:55 +00:00
|
|
|
count = omap_device_get_context_loss_count(pdev);
|
|
|
|
} else {
|
|
|
|
WARN_ONCE(off_mode_enabled, "omap_pm: using dummy context loss counter; device %s should be converted to omap_device",
|
|
|
|
dev_name(dev));
|
2011-06-09 13:56:23 +00:00
|
|
|
|
2010-12-22 04:31:55 +00:00
|
|
|
count = dummy_context_loss_counter;
|
2011-06-09 13:56:23 +00:00
|
|
|
|
|
|
|
if (off_mode_enabled) {
|
|
|
|
count++;
|
|
|
|
/*
|
|
|
|
* Context loss count has to be a non-negative value.
|
|
|
|
* Clear the sign bit to get a value range from 0 to
|
|
|
|
* INT_MAX.
|
|
|
|
*/
|
|
|
|
count &= INT_MAX;
|
|
|
|
dummy_context_loss_counter = count;
|
|
|
|
}
|
2010-12-22 04:31:55 +00:00
|
|
|
}
|
|
|
|
|
2010-12-22 04:31:55 +00:00
|
|
|
pr_debug("OMAP PM: context loss count for dev %s = %d\n",
|
|
|
|
dev_name(dev), count);
|
2009-09-03 17:14:01 +00:00
|
|
|
|
2010-12-22 04:31:55 +00:00
|
|
|
return count;
|
2009-09-03 17:14:01 +00:00
|
|
|
}
|
|
|
|
|
2010-12-22 04:31:55 +00:00
|
|
|
#else
|
|
|
|
|
2011-06-09 13:56:23 +00:00
|
|
|
int omap_pm_get_dev_context_loss_count(struct device *dev)
|
2010-12-22 04:31:55 +00:00
|
|
|
{
|
|
|
|
return dummy_context_loss_counter;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2009-09-03 17:14:01 +00:00
|
|
|
|
|
|
|
/* Should be called before clk framework init */
|
2010-12-09 15:13:48 +00:00
|
|
|
int __init omap_pm_if_early_init(void)
|
2009-09-03 17:14:01 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Must be called after clock framework is initialized */
|
|
|
|
int __init omap_pm_if_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|