License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-block.git] / arch / arm / mach-omap2 / omap-pm.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
c0407a96
PW
2/*
3 * omap-pm.h - OMAP power management interface
4 *
564889c1
PW
5 * Copyright (C) 2008-2010 Texas Instruments, Inc.
6 * Copyright (C) 2008-2010 Nokia Corporation
c0407a96
PW
7 * 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>
fb8ce14c 20#include <linux/clk.h>
e4db1c74 21#include <linux/pm_opp.h>
c0407a96 22
c0407a96
PW
23/*
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 */
53da4ce2 44int __init omap_pm_if_early_init(void);
c0407a96
PW
45
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
c0407a96
PW
54/*
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
564889c1 65 * greater than @t microseconds. "Interrupt latency" in this case is
c0407a96
PW
66 * 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
564889c1 81 * omap_pm_set_max_dev_wakeup_lat()
c0407a96 82 *
564889c1 83 * Multiple calls to omap_pm_set_max_mpu_wakeup_lat() will replace the
c0407a96
PW
84 * previous t value. To remove the latency target for the MPU, call
85 * with t = -1.
86 *
564889c1
PW
87 * 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.
c0407a96 92 */
564889c1 93int omap_pm_set_max_mpu_wakeup_lat(struct device *dev, long t);
c0407a96
PW
94
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
564889c1
PW
103 * attached to device @dev interconnect agent @tbus_id be no less
104 * than @r KiB/s.
c0407a96
PW
105 *
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 *
564889c1
PW
118 * 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.
c0407a96 121 *
564889c1
PW
122 * Returns -EINVAL for an invalid argument, -ERANGE if the constraint
123 * is not satisfiable, or 0 upon success.
c0407a96 124 */
564889c1 125int omap_pm_set_min_bus_tput(struct device *dev, u8 agent_id, unsigned long r);
c0407a96
PW
126
127
c0407a96
PW
128/*
129 * CPUFreq-originated constraint
130 *
131 * In the future, this should be handled by custom OPP clocktype
132 * functions.
133 */
134
c0407a96
PW
135
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,
fc013873 154 * or negative value upon error.
c0407a96 155 */
fc013873 156int omap_pm_get_dev_context_loss_count(struct device *dev);
c0407a96 157
6081dc34
KH
158void omap_pm_enable_off_mode(void);
159void omap_pm_disable_off_mode(void);
c0407a96
PW
160
161#endif