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