2010-07-27 05:34:31 +07: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>
|
2013-09-20 04:03:52 +07:00
|
|
|
#include <linux/pm_opp.h>
|
2011-08-01 03:17:29 +07:00
|
|
|
#include <linux/export.h>
|
2012-02-02 16:30:50 +07: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-07 04:03:08 +07:00
|
|
|
#include <linux/cpu.h>
|
2010-07-27 05:34:31 +07:00
|
|
|
|
2012-03-29 23:30:28 +07:00
|
|
|
#include <asm/system_misc.h>
|
|
|
|
|
2012-10-04 06:36:40 +07:00
|
|
|
#include "omap-pm.h"
|
2012-10-03 07:25:48 +07:00
|
|
|
#include "omap_device.h"
|
2011-11-11 04:45:17 +07:00
|
|
|
#include "common.h"
|
2010-07-27 05:34:31 +07:00
|
|
|
|
2012-10-06 03:25:59 +07:00
|
|
|
#include "soc.h"
|
2012-02-02 16:30:50 +07:00
|
|
|
#include "prcm-common.h"
|
2011-02-26 05:54:33 +07:00
|
|
|
#include "voltage.h"
|
2010-12-22 11:05:16 +07:00
|
|
|
#include "powerdomain.h"
|
2010-12-22 11:05:15 +07:00
|
|
|
#include "clockdomain.h"
|
2010-05-29 23:32:23 +07:00
|
|
|
#include "pm.h"
|
2010-09-15 02:34:01 +07:00
|
|
|
|
2014-05-13 01:33:21 +07:00
|
|
|
#ifdef CONFIG_SUSPEND
|
2012-02-02 16:30:50 +07:00
|
|
|
/*
|
|
|
|
* omap_pm_suspend: points to a function that does the SoC-specific
|
|
|
|
* suspend work
|
|
|
|
*/
|
2014-05-13 01:33:21 +07:00
|
|
|
static int (*omap_pm_suspend)(void);
|
|
|
|
#endif
|
2012-02-02 16:30:50 +07:00
|
|
|
|
2012-11-15 08:13:04 +07:00
|
|
|
#ifdef CONFIG_PM
|
2012-09-25 23:33:39 +07: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 08:13:04 +07:00
|
|
|
#endif
|
2012-09-25 23:33:39 +07:00
|
|
|
|
2017-03-29 08:57:56 +07:00
|
|
|
int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused)
|
2012-02-02 16:38:50 +07:00
|
|
|
{
|
2016-06-30 20:15:02 +07:00
|
|
|
clkdm_allow_idle(clkdm);
|
2012-02-02 16:38:50 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-05-29 23:32:25 +07:00
|
|
|
/*
|
2011-08-30 23:48:16 +07:00
|
|
|
* This API is to be called during init to set the various voltage
|
2010-05-29 23:32:25 +07: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 23:48:16 +07:00
|
|
|
* opp entry and sets the voltage domain to the voltage specified
|
2010-05-29 23:32:25 +07:00
|
|
|
* in the opp entry
|
|
|
|
*/
|
|
|
|
static int __init omap2_set_init_voltage(char *vdd_name, char *clk_name,
|
2011-08-16 20:02:20 +07:00
|
|
|
const char *oh_name)
|
2010-05-29 23:32:25 +07:00
|
|
|
{
|
|
|
|
struct voltagedomain *voltdm;
|
|
|
|
struct clk *clk;
|
2013-09-20 04:03:51 +07:00
|
|
|
struct dev_pm_opp *opp;
|
2010-05-29 23:32:25 +07:00
|
|
|
unsigned long freq, bootup_volt;
|
2011-08-16 20:02:20 +07:00
|
|
|
struct device *dev;
|
2010-05-29 23:32:25 +07:00
|
|
|
|
2011-08-16 20:02:20 +07:00
|
|
|
if (!vdd_name || !clk_name || !oh_name) {
|
2011-08-30 23:48:17 +07:00
|
|
|
pr_err("%s: invalid parameters\n", __func__);
|
2010-05-29 23:32:25 +07: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-07 04:03:08 +07: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 20:02:20 +07:00
|
|
|
if (IS_ERR(dev)) {
|
|
|
|
pr_err("%s: Unable to get dev pointer for hwmod %s\n",
|
|
|
|
__func__, oh_name);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2011-03-17 04:25:45 +07:00
|
|
|
voltdm = voltdm_lookup(vdd_name);
|
2012-09-27 12:54:36 +07:00
|
|
|
if (!voltdm) {
|
2011-08-30 23:48:17 +07:00
|
|
|
pr_err("%s: unable to get vdd pointer for vdd_%s\n",
|
2010-05-29 23:32:25 +07:00
|
|
|
__func__, vdd_name);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
clk = clk_get(NULL, clk_name);
|
|
|
|
if (IS_ERR(clk)) {
|
2011-08-30 23:48:17 +07:00
|
|
|
pr_err("%s: unable to get clk %s\n", __func__, clk_name);
|
2010-05-29 23:32:25 +07:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2012-09-22 15:24:17 +07:00
|
|
|
freq = clk_get_rate(clk);
|
2010-05-29 23:32:25 +07:00
|
|
|
clk_put(clk);
|
|
|
|
|
2013-09-20 04:03:50 +07:00
|
|
|
opp = dev_pm_opp_find_freq_ceil(dev, &freq);
|
2010-05-29 23:32:25 +07:00
|
|
|
if (IS_ERR(opp)) {
|
2011-08-30 23:48:17 +07:00
|
|
|
pr_err("%s: unable to find boot up OPP for vdd_%s\n",
|
2010-05-29 23:32:25 +07:00
|
|
|
__func__, vdd_name);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2013-09-20 04:03:50 +07:00
|
|
|
bootup_volt = dev_pm_opp_get_voltage(opp);
|
2017-01-23 11:41:47 +07:00
|
|
|
dev_pm_opp_put(opp);
|
|
|
|
|
2010-05-29 23:32:25 +07:00
|
|
|
if (!bootup_volt) {
|
2012-07-26 13:54:26 +07:00
|
|
|
pr_err("%s: unable to find voltage corresponding to the bootup OPP for vdd_%s\n",
|
|
|
|
__func__, vdd_name);
|
2010-05-29 23:32:25 +07:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2011-04-06 06:27:21 +07:00
|
|
|
voltdm_scale(voltdm, bootup_volt);
|
2010-05-29 23:32:25 +07:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
exit:
|
2011-08-30 23:48:17 +07:00
|
|
|
pr_err("%s: unable to set vdd_%s\n", __func__, vdd_name);
|
2010-05-29 23:32:25 +07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2012-02-02 16:30:50 +07: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_MEM:
|
|
|
|
ret = omap_pm_suspend();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int omap_pm_begin(suspend_state_t state)
|
|
|
|
{
|
2013-03-22 04:49:38 +07:00
|
|
|
cpu_idle_poll_ctrl(true);
|
2016-10-17 14:08:40 +07:00
|
|
|
if (soc_is_omap34xx())
|
2012-02-02 16:30:50 +07:00
|
|
|
omap_prcm_irq_prepare();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void omap_pm_end(void)
|
|
|
|
{
|
2013-03-22 04:49:38 +07:00
|
|
|
cpu_idle_poll_ctrl(false);
|
2012-02-02 16:30:50 +07:00
|
|
|
}
|
|
|
|
|
2018-02-09 23:15:53 +07:00
|
|
|
static void omap_pm_wake(void)
|
2012-02-02 16:30:50 +07:00
|
|
|
{
|
2016-10-17 14:08:40 +07:00
|
|
|
if (soc_is_omap34xx())
|
2012-02-02 16:30:50 +07:00
|
|
|
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,
|
2018-02-09 23:15:53 +07:00
|
|
|
.wake = omap_pm_wake,
|
2012-02-02 16:30:50 +07:00
|
|
|
.valid = suspend_valid_only_mem,
|
|
|
|
};
|
|
|
|
|
2014-05-13 01:33:21 +07:00
|
|
|
/**
|
|
|
|
* omap_common_suspend_init - Set common suspend routines for OMAP SoCs
|
|
|
|
* @pm_suspend: function pointer to SoC specific suspend function
|
|
|
|
*/
|
|
|
|
void omap_common_suspend_init(void *pm_suspend)
|
|
|
|
{
|
|
|
|
omap_pm_suspend = pm_suspend;
|
|
|
|
suspend_set_ops(&omap_pm_ops);
|
|
|
|
}
|
2012-02-02 16:30:50 +07:00
|
|
|
#endif /* CONFIG_SUSPEND */
|
|
|
|
|
2010-05-29 23:32:25 +07:00
|
|
|
static void __init omap3_init_voltages(void)
|
|
|
|
{
|
2016-10-17 14:08:40 +07:00
|
|
|
if (!soc_is_omap34xx())
|
2010-05-29 23:32:25 +07:00
|
|
|
return;
|
|
|
|
|
2011-08-16 20:02:20 +07:00
|
|
|
omap2_set_init_voltage("mpu_iva", "dpll1_ck", "mpu");
|
|
|
|
omap2_set_init_voltage("core", "l3_ick", "l3_main");
|
2010-05-29 23:32:25 +07:00
|
|
|
}
|
|
|
|
|
2010-05-29 23:32:25 +07:00
|
|
|
static void __init omap4_init_voltages(void)
|
|
|
|
{
|
2016-10-17 14:08:40 +07:00
|
|
|
if (!soc_is_omap44xx())
|
2010-05-29 23:32:25 +07:00
|
|
|
return;
|
|
|
|
|
2011-08-16 20:02:20 +07: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 23:32:25 +07:00
|
|
|
}
|
|
|
|
|
2010-07-27 05:34:31 +07:00
|
|
|
static int __init omap2_common_pm_init(void)
|
|
|
|
{
|
|
|
|
omap_pm_if_init();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2013-01-12 02:24:18 +07:00
|
|
|
omap_postcore_initcall(omap2_common_pm_init);
|
2010-07-27 05:34:31 +07:00
|
|
|
|
2012-04-26 15:06:50 +07:00
|
|
|
int __init omap2_common_pm_late_init(void)
|
2010-05-29 23:32:21 +07:00
|
|
|
{
|
2014-05-06 07:27:37 +07:00
|
|
|
/* Init the voltage layer */
|
2016-10-17 14:08:40 +07:00
|
|
|
omap3_twl_init();
|
|
|
|
omap4_twl_init();
|
2014-05-06 07:27:37 +07:00
|
|
|
omap_voltage_late_init();
|
2010-05-29 23:32:25 +07:00
|
|
|
|
2014-05-06 07:27:37 +07:00
|
|
|
/* Initialize the voltages */
|
|
|
|
omap3_init_voltages();
|
|
|
|
omap4_init_voltages();
|
cpufreq: OMAP: instantiate omap-cpufreq as a platform_driver
As multi-platform build is being adopted by more and more ARM platforms,
initcall function should be used very carefully. For example, when
CONFIG_ARM_OMAP2PLUS_CPUFREQ is built in the kernel, omap_cpufreq_init()
will be called on all the platforms to initialize omap-cpufreq driver.
Further, on OMAP, we now use Soc generic cpufreq-cpu0 driver using device
tree entries. To allow cpufreq-cpu0 and omap-cpufreq drivers to co-exist
for OMAP in a single image, we need to ensure the following:
1. With device tree boot, we use cpufreq-cpu0
2. With non device tree boot, we use omap-cpufreq
In the case of (1), we will have cpu OPPs and regulator registered
as part of the device tree nodes, to ensure that omap-cpufreq
and cpufreq-cpu0 don't conflict in managing the frequency of the
same CPU, we should not permit omap-cpufreq to be probed.
In the case of (2), we will not have the cpufreq-cpu0 device, hence
only omap-cpufreq will be active.
To eliminate this undesired these effects, we change omap-cpufreq
driver to have it instantiated as a platform_driver and register
"omap-cpufreq" device only when booted without device tree nodes on
OMAP platforms.
This allows the following:
a) Will only run on platforms that create the platform_device
"omap-cpufreq".
b) Since the platform_device is registered only when device tree nodes
are *not* populated, omap-cpufreq driver does not conflict with
the usage of cpufreq-cpu0 driver which is used on OMAP platforms when
device tree nodes are present.
Inspired by commit 5553f9e26f6f49a93ba732fd222eac6973a4cf35
(cpufreq: instantiate cpufreq-cpu0 as a platform_driver)
[robherring2@gmail.com: reported conflict of omap-cpufreq vs other
driver in an non-device tree supported boot]
Reported-by: Rob Herring <robherring2@gmail.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Kevin Hilman <khilman@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-04-10 06:22:01 +07:00
|
|
|
|
2014-05-06 07:27:37 +07:00
|
|
|
/* Smartreflex device init */
|
|
|
|
omap_devinit_smartreflex();
|
2010-05-29 23:32:21 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|