2010-07-27 00:34:31 +02:00
|
|
|
/*
|
|
|
|
* pm.c - Common OMAP2+ power management-related code
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Texas Instruments, Inc.
|
|
|
|
* Copyright (C) 2010 Nokia Corporation
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/err.h>
|
2010-05-29 18:32:25 +02:00
|
|
|
#include <linux/opp.h>
|
2011-07-31 22:17:29 +02:00
|
|
|
#include <linux/export.h>
|
2012-02-02 10:30:50 +01:00
|
|
|
#include <linux/suspend.h>
|
ARM: OMAP2+: PM: MPU DVFS: use generic CPU device for MPU-SS
Currently, a dummy omap_device is created for the MPU sub-system so
that a device node exists for MPU DVFS. Specifically, for the
association of MPU OPPs to a device node, and so that a voltage
regulator can be mapped to a device node.
For drivers to get a handle to this device node, an OMAP-specific API
has been used. However, the kernel already has device nodes for the
CPU(s) in the system, so we can use those instead of an OMAP-specific
dummy device and then drivers (like OMAP CPUfreq) can use generic
APIs.
To use the existing CPU device nodes, modify the OPP creation and
regulator registration to use the CPU0 device node for registraion.
NOTE: this patch always uses CPU0 as the device node. On all
OMAPs today, MPU DVFS scales all CPUs together, so this will
not be a problem, but this assumption will need to be changed
if independently scalable CPUs are introduced.
Cc: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
2012-09-06 23:03:08 +02:00
|
|
|
#include <linux/cpu.h>
|
2010-07-27 00:34:31 +02:00
|
|
|
|
2012-03-29 18:30:28 +02:00
|
|
|
#include <asm/system_misc.h>
|
|
|
|
|
2012-10-04 01:36:40 +02:00
|
|
|
#include "omap-pm.h"
|
2012-10-03 02:25:48 +02:00
|
|
|
#include "omap_device.h"
|
2011-11-10 22:45:17 +01:00
|
|
|
#include "common.h"
|
2010-07-27 00:34:31 +02:00
|
|
|
|
2012-10-05 22:25:59 +02:00
|
|
|
#include "soc.h"
|
2012-02-02 10:30:50 +01:00
|
|
|
#include "prcm-common.h"
|
2011-02-25 23:54:33 +01:00
|
|
|
#include "voltage.h"
|
2010-12-22 05:05:16 +01:00
|
|
|
#include "powerdomain.h"
|
2010-12-22 05:05:15 +01:00
|
|
|
#include "clockdomain.h"
|
2010-05-29 18:32:23 +02:00
|
|
|
#include "pm.h"
|
2011-11-23 23:43:01 +01:00
|
|
|
#include "twl-common.h"
|
2010-09-14 21:34:01 +02:00
|
|
|
|
2010-07-27 00:34:31 +02:00
|
|
|
static struct omap_device_pm_latency *pm_lats;
|
|
|
|
|
2012-02-02 10:30:50 +01:00
|
|
|
/*
|
|
|
|
* omap_pm_suspend: points to a function that does the SoC-specific
|
|
|
|
* suspend work
|
|
|
|
*/
|
|
|
|
int (*omap_pm_suspend)(void);
|
|
|
|
|
2012-11-15 02:13:04 +01:00
|
|
|
#ifdef CONFIG_PM
|
2012-09-25 18:33:39 +02:00
|
|
|
/**
|
|
|
|
* struct omap2_oscillator - Describe the board main oscillator latencies
|
|
|
|
* @startup_time: oscillator startup latency
|
|
|
|
* @shutdown_time: oscillator shutdown latency
|
|
|
|
*/
|
|
|
|
struct omap2_oscillator {
|
|
|
|
u32 startup_time;
|
|
|
|
u32 shutdown_time;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct omap2_oscillator oscillator = {
|
|
|
|
.startup_time = ULONG_MAX,
|
|
|
|
.shutdown_time = ULONG_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
void omap_pm_setup_oscillator(u32 tstart, u32 tshut)
|
|
|
|
{
|
|
|
|
oscillator.startup_time = tstart;
|
|
|
|
oscillator.shutdown_time = tshut;
|
|
|
|
}
|
|
|
|
|
|
|
|
void omap_pm_get_oscillator(u32 *tstart, u32 *tshut)
|
|
|
|
{
|
|
|
|
if (!tstart || !tshut)
|
|
|
|
return;
|
|
|
|
|
|
|
|
*tstart = oscillator.startup_time;
|
|
|
|
*tshut = oscillator.shutdown_time;
|
|
|
|
}
|
2012-11-15 02:13:04 +01:00
|
|
|
#endif
|
2012-09-25 18:33:39 +02:00
|
|
|
|
2012-02-20 18:43:30 +01:00
|
|
|
static int __init _init_omap_device(char *name)
|
2010-07-27 00:34:31 +02:00
|
|
|
{
|
|
|
|
struct omap_hwmod *oh;
|
2011-07-21 22:48:45 +02:00
|
|
|
struct platform_device *pdev;
|
2010-07-27 00:34:31 +02:00
|
|
|
|
|
|
|
oh = omap_hwmod_lookup(name);
|
|
|
|
if (WARN(!oh, "%s: could not find omap_hwmod for %s\n",
|
|
|
|
__func__, name))
|
|
|
|
return -ENODEV;
|
|
|
|
|
2011-07-21 22:48:45 +02:00
|
|
|
pdev = omap_device_build(oh->name, 0, oh, NULL, 0, pm_lats, 0, false);
|
|
|
|
if (WARN(IS_ERR(pdev), "%s: could not build omap_device for %s\n",
|
2010-07-27 00:34:31 +02:00
|
|
|
__func__, name))
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Build omap_devices for processors and bus.
|
|
|
|
*/
|
2012-03-06 20:38:01 +01:00
|
|
|
static void __init omap2_init_processor_devices(void)
|
2010-07-27 00:34:31 +02:00
|
|
|
{
|
2011-08-16 15:03:59 +02:00
|
|
|
_init_omap_device("mpu");
|
2011-02-25 14:27:20 +01:00
|
|
|
if (omap3_has_iva())
|
2011-08-16 15:03:59 +02:00
|
|
|
_init_omap_device("iva");
|
2011-02-25 14:27:20 +01:00
|
|
|
|
2010-08-05 15:22:35 +02:00
|
|
|
if (cpu_is_omap44xx()) {
|
2011-08-16 15:03:59 +02:00
|
|
|
_init_omap_device("l3_main_1");
|
|
|
|
_init_omap_device("dsp");
|
|
|
|
_init_omap_device("iva");
|
2010-08-05 15:22:35 +02:00
|
|
|
} else {
|
2011-08-16 15:03:59 +02:00
|
|
|
_init_omap_device("l3_main");
|
2010-08-05 15:22:35 +02:00
|
|
|
}
|
2010-07-27 00:34:31 +02:00
|
|
|
}
|
|
|
|
|
2012-02-02 10:38:50 +01:00
|
|
|
int __init omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused)
|
|
|
|
{
|
ARM: OMAP2+: clockdomain/hwmod: add workaround for EMU clockdomain idle problems
The idle status of the IP blocks and clocks inside the EMU clockdomain
isn't taken into account by the PRCM hardware when deciding whether
the clockdomain is idle. Add a workaround flag in the clockdomain
code, CLKDM_MISSING_IDLE_REPORTING, to deal with this problem, and add
the code necessary to support it.
If CLKDM_MISSING_IDLE_REPORTING is set on a clockdomain, the
clockdomain will be forced active whenever an IP block inside that
clockdomain is in use, even if the clockdomain supports
hardware-supervised idle. When the kernel indicates that the last
active IP block inside the clockdomain is no longer used, the
clockdomain will be forced idle, or, if that mode is not supported in
the hardware, it will be placed into hardware-supervised idle.
This patch is an equal collaboration with Jon Hunter
<jon-hunter@ti.com>. Ming Lei <ming.lei@canonical.com>, Will Deacon
<will.deacon@arm.com>, Madhav Vij <mvij@ti.com>, Kevin Hilman
<khilman@ti.com>, Benoît Cousson <b-cousson@ti.com>, and Santosh
Shilimkar <santosh.shilimkar@ti.com> all made essential contributions
to the understanding of EMU clockdomain power management on OMAP.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Jon Hunter <jon-hunter@ti.com>
Cc: Ming Lei <ming.lei@canonical.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Madhav Vij <mvij@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
Cc: Benoît Cousson <b-cousson@ti.com>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Tested-by: Jon Hunter <jon-hunter@ti.com>
2012-09-24 01:28:28 +02:00
|
|
|
if ((clkdm->flags & CLKDM_CAN_ENABLE_AUTO) &&
|
|
|
|
!(clkdm->flags & CLKDM_MISSING_IDLE_REPORTING))
|
2012-02-02 10:38:50 +01:00
|
|
|
clkdm_allow_idle(clkdm);
|
|
|
|
else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP &&
|
|
|
|
atomic_read(&clkdm->usecount) == 0)
|
|
|
|
clkdm_sleep(clkdm);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-05-29 18:32:25 +02:00
|
|
|
/*
|
2011-08-30 18:48:16 +02:00
|
|
|
* This API is to be called during init to set the various voltage
|
2010-05-29 18:32:25 +02:00
|
|
|
* domains to the voltage as per the opp table. Typically we boot up
|
|
|
|
* at the nominal voltage. So this function finds out the rate of
|
|
|
|
* the clock associated with the voltage domain, finds out the correct
|
2011-08-30 18:48:16 +02:00
|
|
|
* opp entry and sets the voltage domain to the voltage specified
|
2010-05-29 18:32:25 +02:00
|
|
|
* in the opp entry
|
|
|
|
*/
|
|
|
|
static int __init omap2_set_init_voltage(char *vdd_name, char *clk_name,
|
2011-08-16 15:02:20 +02:00
|
|
|
const char *oh_name)
|
2010-05-29 18:32:25 +02:00
|
|
|
{
|
|
|
|
struct voltagedomain *voltdm;
|
|
|
|
struct clk *clk;
|
|
|
|
struct opp *opp;
|
|
|
|
unsigned long freq, bootup_volt;
|
2011-08-16 15:02:20 +02:00
|
|
|
struct device *dev;
|
2010-05-29 18:32:25 +02:00
|
|
|
|
2011-08-16 15:02:20 +02:00
|
|
|
if (!vdd_name || !clk_name || !oh_name) {
|
2011-08-30 18:48:17 +02:00
|
|
|
pr_err("%s: invalid parameters\n", __func__);
|
2010-05-29 18:32:25 +02:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
ARM: OMAP2+: PM: MPU DVFS: use generic CPU device for MPU-SS
Currently, a dummy omap_device is created for the MPU sub-system so
that a device node exists for MPU DVFS. Specifically, for the
association of MPU OPPs to a device node, and so that a voltage
regulator can be mapped to a device node.
For drivers to get a handle to this device node, an OMAP-specific API
has been used. However, the kernel already has device nodes for the
CPU(s) in the system, so we can use those instead of an OMAP-specific
dummy device and then drivers (like OMAP CPUfreq) can use generic
APIs.
To use the existing CPU device nodes, modify the OPP creation and
regulator registration to use the CPU0 device node for registraion.
NOTE: this patch always uses CPU0 as the device node. On all
OMAPs today, MPU DVFS scales all CPUs together, so this will
not be a problem, but this assumption will need to be changed
if independently scalable CPUs are introduced.
Cc: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
2012-09-06 23:03:08 +02:00
|
|
|
if (!strncmp(oh_name, "mpu", 3))
|
|
|
|
/*
|
|
|
|
* All current OMAPs share voltage rail and clock
|
|
|
|
* source, so CPU0 is used to represent the MPU-SS.
|
|
|
|
*/
|
|
|
|
dev = get_cpu_device(0);
|
|
|
|
else
|
|
|
|
dev = omap_device_get_by_hwmod_name(oh_name);
|
|
|
|
|
2011-08-16 15:02:20 +02:00
|
|
|
if (IS_ERR(dev)) {
|
|
|
|
pr_err("%s: Unable to get dev pointer for hwmod %s\n",
|
|
|
|
__func__, oh_name);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2011-03-16 22:25:45 +01:00
|
|
|
voltdm = voltdm_lookup(vdd_name);
|
2012-09-27 07:54:36 +02:00
|
|
|
if (!voltdm) {
|
2011-08-30 18:48:17 +02:00
|
|
|
pr_err("%s: unable to get vdd pointer for vdd_%s\n",
|
2010-05-29 18:32:25 +02:00
|
|
|
__func__, vdd_name);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
clk = clk_get(NULL, clk_name);
|
|
|
|
if (IS_ERR(clk)) {
|
2011-08-30 18:48:17 +02:00
|
|
|
pr_err("%s: unable to get clk %s\n", __func__, clk_name);
|
2010-05-29 18:32:25 +02:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2012-09-22 10:24:17 +02:00
|
|
|
freq = clk_get_rate(clk);
|
2010-05-29 18:32:25 +02:00
|
|
|
clk_put(clk);
|
|
|
|
|
2012-01-09 03:14:12 +01:00
|
|
|
rcu_read_lock();
|
2010-05-29 18:32:25 +02:00
|
|
|
opp = opp_find_freq_ceil(dev, &freq);
|
|
|
|
if (IS_ERR(opp)) {
|
2012-01-09 03:14:12 +01:00
|
|
|
rcu_read_unlock();
|
2011-08-30 18:48:17 +02:00
|
|
|
pr_err("%s: unable to find boot up OPP for vdd_%s\n",
|
2010-05-29 18:32:25 +02:00
|
|
|
__func__, vdd_name);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
bootup_volt = opp_get_voltage(opp);
|
2012-01-09 03:14:12 +01:00
|
|
|
rcu_read_unlock();
|
2010-05-29 18:32:25 +02:00
|
|
|
if (!bootup_volt) {
|
2012-07-26 08:54:26 +02:00
|
|
|
pr_err("%s: unable to find voltage corresponding to the bootup OPP for vdd_%s\n",
|
|
|
|
__func__, vdd_name);
|
2010-05-29 18:32:25 +02:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2011-04-06 01:27:21 +02:00
|
|
|
voltdm_scale(voltdm, bootup_volt);
|
2010-05-29 18:32:25 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
exit:
|
2011-08-30 18:48:17 +02:00
|
|
|
pr_err("%s: unable to set vdd_%s\n", __func__, vdd_name);
|
2010-05-29 18:32:25 +02:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2012-02-02 10:30:50 +01:00
|
|
|
#ifdef CONFIG_SUSPEND
|
|
|
|
static int omap_pm_enter(suspend_state_t suspend_state)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (!omap_pm_suspend)
|
|
|
|
return -ENOENT; /* XXX doublecheck */
|
|
|
|
|
|
|
|
switch (suspend_state) {
|
|
|
|
case PM_SUSPEND_STANDBY:
|
|
|
|
case PM_SUSPEND_MEM:
|
|
|
|
ret = omap_pm_suspend();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int omap_pm_begin(suspend_state_t state)
|
|
|
|
{
|
|
|
|
disable_hlt();
|
|
|
|
if (cpu_is_omap34xx())
|
|
|
|
omap_prcm_irq_prepare();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void omap_pm_end(void)
|
|
|
|
{
|
|
|
|
enable_hlt();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void omap_pm_finish(void)
|
|
|
|
{
|
|
|
|
if (cpu_is_omap34xx())
|
|
|
|
omap_prcm_irq_complete();
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct platform_suspend_ops omap_pm_ops = {
|
|
|
|
.begin = omap_pm_begin,
|
|
|
|
.end = omap_pm_end,
|
|
|
|
.enter = omap_pm_enter,
|
|
|
|
.finish = omap_pm_finish,
|
|
|
|
.valid = suspend_valid_only_mem,
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* CONFIG_SUSPEND */
|
|
|
|
|
2010-05-29 18:32:25 +02:00
|
|
|
static void __init omap3_init_voltages(void)
|
|
|
|
{
|
|
|
|
if (!cpu_is_omap34xx())
|
|
|
|
return;
|
|
|
|
|
2011-08-16 15:02:20 +02:00
|
|
|
omap2_set_init_voltage("mpu_iva", "dpll1_ck", "mpu");
|
|
|
|
omap2_set_init_voltage("core", "l3_ick", "l3_main");
|
2010-05-29 18:32:25 +02:00
|
|
|
}
|
|
|
|
|
2010-05-29 18:32:25 +02:00
|
|
|
static void __init omap4_init_voltages(void)
|
|
|
|
{
|
|
|
|
if (!cpu_is_omap44xx())
|
|
|
|
return;
|
|
|
|
|
2011-08-16 15:02:20 +02:00
|
|
|
omap2_set_init_voltage("mpu", "dpll_mpu_ck", "mpu");
|
|
|
|
omap2_set_init_voltage("core", "l3_div_ck", "l3_main_1");
|
|
|
|
omap2_set_init_voltage("iva", "dpll_iva_m5x2_ck", "iva");
|
2010-05-29 18:32:25 +02:00
|
|
|
}
|
|
|
|
|
2010-07-27 00:34:31 +02:00
|
|
|
static int __init omap2_common_pm_init(void)
|
|
|
|
{
|
2011-08-16 11:49:08 +02:00
|
|
|
if (!of_have_populated_dt())
|
|
|
|
omap2_init_processor_devices();
|
2010-07-27 00:34:31 +02:00
|
|
|
omap_pm_if_init();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2010-12-20 16:47:21 +01:00
|
|
|
postcore_initcall(omap2_common_pm_init);
|
2010-07-27 00:34:31 +02:00
|
|
|
|
2012-04-26 10:06:50 +02:00
|
|
|
int __init omap2_common_pm_late_init(void)
|
2010-05-29 18:32:21 +02:00
|
|
|
{
|
2011-12-08 16:47:39 +01:00
|
|
|
/*
|
|
|
|
* In the case of DT, the PMIC and SR initialization will be done using
|
|
|
|
* a completely different mechanism.
|
|
|
|
* Disable this part if a DT blob is available.
|
|
|
|
*/
|
|
|
|
if (of_have_populated_dt())
|
|
|
|
return 0;
|
|
|
|
|
2010-12-10 18:21:05 +01:00
|
|
|
/* Init the voltage layer */
|
2011-11-23 23:43:01 +01:00
|
|
|
omap_pmic_late_init();
|
2010-05-29 18:32:21 +02:00
|
|
|
omap_voltage_late_init();
|
2010-05-29 18:32:25 +02:00
|
|
|
|
|
|
|
/* Initialize the voltages */
|
|
|
|
omap3_init_voltages();
|
2010-05-29 18:32:25 +02:00
|
|
|
omap4_init_voltages();
|
2010-05-29 18:32:25 +02:00
|
|
|
|
2010-12-10 18:21:05 +01:00
|
|
|
/* Smartreflex device init */
|
2010-05-29 18:32:23 +02:00
|
|
|
omap_devinit_smartreflex();
|
2010-05-29 18:32:21 +02:00
|
|
|
|
2012-02-02 10:30:50 +01:00
|
|
|
#ifdef CONFIG_SUSPEND
|
|
|
|
suspend_set_ops(&omap_pm_ops);
|
|
|
|
#endif
|
|
|
|
|
2010-05-29 18:32:21 +02:00
|
|
|
return 0;
|
|
|
|
}
|