2019-06-04 16:11:33 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2010-07-27 06:34:31 +08:00
|
|
|
/*
|
|
|
|
* pm.c - Common OMAP2+ power management-related code
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Texas Instruments, Inc.
|
|
|
|
* Copyright (C) 2010 Nokia Corporation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/err.h>
|
2013-09-20 05:03:52 +08:00
|
|
|
#include <linux/pm_opp.h>
|
2011-08-01 04:17:29 +08:00
|
|
|
#include <linux/export.h>
|
2012-02-02 17:30:50 +08:00
|
|
|
#include <linux/suspend.h>
|
2018-04-17 01:22:01 +08:00
|
|
|
#include <linux/clk.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 05:03:08 +08:00
|
|
|
#include <linux/cpu.h>
|
2010-07-27 06:34:31 +08:00
|
|
|
|
2012-03-30 00:30:28 +08:00
|
|
|
#include <asm/system_misc.h>
|
|
|
|
|
2012-10-03 08:25:48 +08:00
|
|
|
#include "omap_device.h"
|
2011-11-11 05:45:17 +08:00
|
|
|
#include "common.h"
|
2010-07-27 06:34:31 +08:00
|
|
|
|
2012-10-06 04:25:59 +08:00
|
|
|
#include "soc.h"
|
2012-02-02 17:30:50 +08:00
|
|
|
#include "prcm-common.h"
|
2011-02-26 06:54:33 +08:00
|
|
|
#include "voltage.h"
|
2010-12-22 12:05:16 +08:00
|
|
|
#include "powerdomain.h"
|
2010-12-22 12:05:15 +08:00
|
|
|
#include "clockdomain.h"
|
2010-05-30 00:32:23 +08:00
|
|
|
#include "pm.h"
|
2010-09-15 03:34:01 +08:00
|
|
|
|
2014-05-13 02:33:21 +08:00
|
|
|
#ifdef CONFIG_SUSPEND
|
2012-02-02 17:30:50 +08:00
|
|
|
/*
|
|
|
|
* omap_pm_suspend: points to a function that does the SoC-specific
|
|
|
|
* suspend work
|
|
|
|
*/
|
2014-05-13 02:33:21 +08:00
|
|
|
static int (*omap_pm_suspend)(void);
|
|
|
|
#endif
|
2012-02-02 17:30:50 +08:00
|
|
|
|
2012-11-15 09:13:04 +08:00
|
|
|
#ifdef CONFIG_PM
|
2012-09-26 00:33:39 +08: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 09:13:04 +08:00
|
|
|
#endif
|
2012-09-26 00:33:39 +08:00
|
|
|
|
2017-03-29 09:57:56 +08:00
|
|
|
int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused)
|
2012-02-02 17:38:50 +08:00
|
|
|
{
|
2016-06-30 21:15:02 +08:00
|
|
|
clkdm_allow_idle(clkdm);
|
2012-02-02 17:38:50 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-02-02 17:30:50 +08: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 05:49:38 +08:00
|
|
|
cpu_idle_poll_ctrl(true);
|
2016-10-17 15:08:40 +08:00
|
|
|
if (soc_is_omap34xx())
|
2012-02-02 17:30:50 +08:00
|
|
|
omap_prcm_irq_prepare();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void omap_pm_end(void)
|
|
|
|
{
|
2013-03-22 05:49:38 +08:00
|
|
|
cpu_idle_poll_ctrl(false);
|
2012-02-02 17:30:50 +08:00
|
|
|
}
|
|
|
|
|
2018-02-10 00:15:53 +08:00
|
|
|
static void omap_pm_wake(void)
|
2012-02-02 17:30:50 +08:00
|
|
|
{
|
2016-10-17 15:08:40 +08:00
|
|
|
if (soc_is_omap34xx())
|
2012-02-02 17:30:50 +08: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-10 00:15:53 +08:00
|
|
|
.wake = omap_pm_wake,
|
2012-02-02 17:30:50 +08:00
|
|
|
.valid = suspend_valid_only_mem,
|
|
|
|
};
|
|
|
|
|
2014-05-13 02:33:21 +08: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 17:30:50 +08:00
|
|
|
#endif /* CONFIG_SUSPEND */
|
|
|
|
|
2018-04-17 01:23:46 +08:00
|
|
|
int __maybe_unused omap_pm_nop_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int (*omap_pm_soc_init)(void);
|
|
|
|
|
2012-04-26 16:06:50 +08:00
|
|
|
int __init omap2_common_pm_late_init(void)
|
2010-05-30 00:32:21 +08:00
|
|
|
{
|
2018-04-17 01:23:46 +08:00
|
|
|
int error;
|
|
|
|
|
|
|
|
if (!omap_pm_soc_init)
|
|
|
|
return 0;
|
|
|
|
|
2014-05-06 08:27:37 +08:00
|
|
|
/* Init the voltage layer */
|
2016-10-17 15:08:40 +08:00
|
|
|
omap3_twl_init();
|
|
|
|
omap4_twl_init();
|
2019-10-16 22:37:06 +08:00
|
|
|
omap4_cpcap_init();
|
2014-05-06 08:27:37 +08:00
|
|
|
omap_voltage_late_init();
|
2010-05-30 00:32:25 +08:00
|
|
|
|
2014-05-06 08:27:37 +08:00
|
|
|
/* Smartreflex device init */
|
|
|
|
omap_devinit_smartreflex();
|
2010-05-30 00:32:21 +08:00
|
|
|
|
2018-04-17 01:23:46 +08:00
|
|
|
error = omap_pm_soc_init();
|
|
|
|
if (error)
|
|
|
|
pr_warn("%s: pm soc init failed: %i\n", __func__, error);
|
|
|
|
|
|
|
|
omap2_clk_enable_autoidle_all();
|
|
|
|
|
2010-05-30 00:32:21 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2018-04-17 01:23:46 +08:00
|
|
|
omap_late_initcall(omap2_common_pm_late_init);
|