blob: 5ba5df47f91b95272fbb99afae8e62da3f289a90 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Paul Walmsleyc0407a92009-09-03 20:14:01 +03002/*
3 * omap-pm.h - OMAP power management interface
4 *
Paul Walmsley564889c2010-07-26 16:34:34 -06005 * Copyright (C) 2008-2010 Texas Instruments, Inc.
6 * Copyright (C) 2008-2010 Nokia Corporation
Paul Walmsleyc0407a92009-09-03 20:14:01 +03007 * Paul Walmsley
8 *
9 * Interface developed by (in alphabetical order): Karthik Dasu, Jouni
10 * Högander, Tony Lindgren, Rajendra Nayak, Sakari Poussa,
11 * Veeramanikandan Raju, Anand Sawant, Igor Stoppa, Paul Walmsley,
12 * Richard Woodruff
13 */
14
15#ifndef ASM_ARM_ARCH_OMAP_OMAP_PM_H
16#define ASM_ARM_ARCH_OMAP_OMAP_PM_H
17
18#include <linux/device.h>
19#include <linux/cpufreq.h>
Paul Walmsleyfb8ce142010-07-26 16:34:34 -060020#include <linux/clk.h>
Nishanth Menone4db1c72013-09-19 16:03:52 -050021#include <linux/pm_opp.h>
Paul Walmsleyc0407a92009-09-03 20:14:01 +030022
Paul Walmsleyc0407a92009-09-03 20:14:01 +030023/*
24 * agent_id values for use with omap_pm_set_min_bus_tput():
25 *
26 * OCP_INITIATOR_AGENT is only valid for devices that can act as
27 * initiators -- it represents the device's L3 interconnect
28 * connection. OCP_TARGET_AGENT represents the device's L4
29 * interconnect connection.
30 */
31#define OCP_TARGET_AGENT 1
32#define OCP_INITIATOR_AGENT 2
33
34/**
35 * omap_pm_if_early_init - OMAP PM init code called before clock fw init
36 * @mpu_opp_table: array ptr to struct omap_opp for MPU
37 * @dsp_opp_table: array ptr to struct omap_opp for DSP
38 * @l3_opp_table : array ptr to struct omap_opp for CORE
39 *
40 * Initialize anything that must be configured before the clock
41 * framework starts. The "_if_" is to avoid name collisions with the
42 * PM idle-loop code.
43 */
Kevin Hilman53da4ce2010-12-09 09:13:48 -060044int __init omap_pm_if_early_init(void);
Paul Walmsleyc0407a92009-09-03 20:14:01 +030045
46/**
47 * omap_pm_if_init - OMAP PM init code called after clock fw init
48 *
49 * The main initialization code. OPP tables are passed in here. The
50 * "_if_" is to avoid name collisions with the PM idle-loop code.
51 */
52int __init omap_pm_if_init(void);
53
Paul Walmsleyc0407a92009-09-03 20:14:01 +030054/*
55 * Device-driver-originated constraints (via board-*.c files, platform_data)
56 */
57
58
59/**
60 * omap_pm_set_max_mpu_wakeup_lat - set the maximum MPU wakeup latency
61 * @dev: struct device * requesting the constraint
62 * @t: maximum MPU wakeup latency in microseconds
63 *
64 * Request that the maximum interrupt latency for the MPU to be no
Paul Walmsley564889c2010-07-26 16:34:34 -060065 * greater than @t microseconds. "Interrupt latency" in this case is
Paul Walmsleyc0407a92009-09-03 20:14:01 +030066 * defined as the elapsed time from the occurrence of a hardware or
67 * timer interrupt to the time when the device driver's interrupt
68 * service routine has been entered by the MPU.
69 *
70 * It is intended that underlying PM code will use this information to
71 * determine what power state to put the MPU powerdomain into, and
72 * possibly the CORE powerdomain as well, since interrupt handling
73 * code currently runs from SDRAM. Advanced PM or board*.c code may
74 * also configure interrupt controller priorities, OCP bus priorities,
75 * CPU speed(s), etc.
76 *
77 * This function will not affect device wakeup latency, e.g., time
78 * elapsed from when a device driver enables a hardware device with
79 * clk_enable(), to when the device is ready for register access or
80 * other use. To control this device wakeup latency, use
Paul Walmsley564889c2010-07-26 16:34:34 -060081 * omap_pm_set_max_dev_wakeup_lat()
Paul Walmsleyc0407a92009-09-03 20:14:01 +030082 *
Paul Walmsley564889c2010-07-26 16:34:34 -060083 * Multiple calls to omap_pm_set_max_mpu_wakeup_lat() will replace the
Paul Walmsleyc0407a92009-09-03 20:14:01 +030084 * previous t value. To remove the latency target for the MPU, call
85 * with t = -1.
86 *
Paul Walmsley564889c2010-07-26 16:34:34 -060087 * XXX This constraint will be deprecated soon in favor of the more
88 * general omap_pm_set_max_dev_wakeup_lat()
89 *
90 * Returns -EINVAL for an invalid argument, -ERANGE if the constraint
91 * is not satisfiable, or 0 upon success.
Paul Walmsleyc0407a92009-09-03 20:14:01 +030092 */
Paul Walmsley564889c2010-07-26 16:34:34 -060093int omap_pm_set_max_mpu_wakeup_lat(struct device *dev, long t);
Paul Walmsleyc0407a92009-09-03 20:14:01 +030094
95
96/**
97 * omap_pm_set_min_bus_tput - set minimum bus throughput needed by device
98 * @dev: struct device * requesting the constraint
99 * @tbus_id: interconnect to operate on (OCP_{INITIATOR,TARGET}_AGENT)
100 * @r: minimum throughput (in KiB/s)
101 *
102 * Request that the minimum data throughput on the OCP interconnect
Paul Walmsley564889c2010-07-26 16:34:34 -0600103 * attached to device @dev interconnect agent @tbus_id be no less
104 * than @r KiB/s.
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300105 *
106 * It is expected that the OMAP PM or bus code will use this
107 * information to set the interconnect clock to run at the lowest
108 * possible speed that satisfies all current system users. The PM or
109 * bus code will adjust the estimate based on its model of the bus, so
110 * device driver authors should attempt to specify an accurate
111 * quantity for their device use case, and let the PM or bus code
112 * overestimate the numbers as necessary to handle request/response
113 * latency, other competing users on the system, etc. On OMAP2/3, if
114 * a driver requests a minimum L4 interconnect speed constraint, the
115 * code will also need to add an minimum L3 interconnect speed
116 * constraint,
117 *
Paul Walmsley564889c2010-07-26 16:34:34 -0600118 * Multiple calls to omap_pm_set_min_bus_tput() will replace the
119 * previous rate value for this device. To remove the interconnect
120 * throughput restriction for this device, call with r = 0.
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300121 *
Paul Walmsley564889c2010-07-26 16:34:34 -0600122 * Returns -EINVAL for an invalid argument, -ERANGE if the constraint
123 * is not satisfiable, or 0 upon success.
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300124 */
Paul Walmsley564889c2010-07-26 16:34:34 -0600125int omap_pm_set_min_bus_tput(struct device *dev, u8 agent_id, unsigned long r);
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300126
127
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300128/*
129 * CPUFreq-originated constraint
130 *
131 * In the future, this should be handled by custom OPP clocktype
132 * functions.
133 */
134
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300135
136/*
137 * Device context loss tracking
138 */
139
140/**
141 * omap_pm_get_dev_context_loss_count - return count of times dev has lost ctx
142 * @dev: struct device *
143 *
144 * This function returns the number of times that the device @dev has
145 * lost its internal context. This generally occurs on a powerdomain
146 * transition to OFF. Drivers use this as an optimization to avoid restoring
147 * context if the device hasn't lost it. To use, drivers should initially
148 * call this in their context save functions and store the result. Early in
149 * the driver's context restore function, the driver should call this function
150 * again, and compare the result to the stored counter. If they differ, the
151 * driver must restore device context. If the number of context losses
152 * exceeds the maximum positive integer, the function will wrap to 0 and
153 * continue counting. Returns the number of context losses for this device,
Tomi Valkeinenfc013872011-06-09 16:56:23 +0300154 * or negative value upon error.
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300155 */
Tomi Valkeinenfc013872011-06-09 16:56:23 +0300156int omap_pm_get_dev_context_loss_count(struct device *dev);
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300157
Kevin Hilman6081dc32010-12-21 21:31:55 -0700158void omap_pm_enable_off_mode(void);
159void omap_pm_disable_off_mode(void);
Paul Walmsleyc0407a92009-09-03 20:14:01 +0300160
161#endif