Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / arm / mach-omap2 / omap-pm-noop.c
blob4ead077ea4e72c18854b34051c667131e7a5083e
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * omap-pm-noop.c - OMAP power management interface - dummy version
5 * This code implements the OMAP power management interface to
6 * drivers, CPUIdle, CPUFreq, and DSP Bridge. It is strictly for
7 * debug/demonstration use, as it does nothing but printk() whenever a
8 * function is called (when DEBUG is defined, below)
10 * Copyright (C) 2008-2009 Texas Instruments, Inc.
11 * Copyright (C) 2008-2009 Nokia Corporation
12 * Paul Walmsley
14 * Interface developed by (in alphabetical order):
15 * Karthik Dasu, Tony Lindgren, Rajendra Nayak, Sakari Poussa, Veeramanikandan
16 * Raju, Anand Sawant, Igor Stoppa, Paul Walmsley, Richard Woodruff
19 #undef DEBUG
21 #include <linux/init.h>
22 #include <linux/cpufreq.h>
23 #include <linux/device.h>
24 #include <linux/platform_device.h>
26 #include "omap_device.h"
27 #include "omap-pm.h"
29 static bool off_mode_enabled;
30 static int dummy_context_loss_counter;
33 * Device-driver-originated constraints (via board-*.c files)
36 int omap_pm_set_max_mpu_wakeup_lat(struct device *dev, long t)
38 if (!dev || t < -1) {
39 WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
40 return -EINVAL;
43 if (t == -1)
44 pr_debug("OMAP PM: remove max MPU wakeup latency constraint: dev %s\n",
45 dev_name(dev));
46 else
47 pr_debug("OMAP PM: add max MPU wakeup latency constraint: dev %s, t = %ld usec\n",
48 dev_name(dev), t);
51 * For current Linux, this needs to map the MPU to a
52 * powerdomain, then go through the list of current max lat
53 * constraints on the MPU and find the smallest. If
54 * the latency constraint has changed, the code should
55 * recompute the state to enter for the next powerdomain
56 * state.
58 * TI CDP code can call constraint_set here.
61 return 0;
64 int omap_pm_set_min_bus_tput(struct device *dev, u8 agent_id, unsigned long r)
66 if (!dev || (agent_id != OCP_INITIATOR_AGENT &&
67 agent_id != OCP_TARGET_AGENT)) {
68 WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
69 return -EINVAL;
72 if (r == 0)
73 pr_debug("OMAP PM: remove min bus tput constraint: dev %s for agent_id %d\n",
74 dev_name(dev), agent_id);
75 else
76 pr_debug("OMAP PM: add min bus tput constraint: dev %s for agent_id %d: rate %ld KiB\n",
77 dev_name(dev), agent_id, r);
80 * This code should model the interconnect and compute the
81 * required clock frequency, convert that to a VDD2 OPP ID, then
82 * set the VDD2 OPP appropriately.
84 * TI CDP code can call constraint_set here on the VDD2 OPP.
87 return 0;
91 * DSP Bridge-specific constraints
95 /**
96 * omap_pm_enable_off_mode - notify OMAP PM that off-mode is enabled
98 * Intended for use only by OMAP PM core code to notify this layer
99 * that off mode has been enabled.
101 void omap_pm_enable_off_mode(void)
103 off_mode_enabled = true;
107 * omap_pm_disable_off_mode - notify OMAP PM that off-mode is disabled
109 * Intended for use only by OMAP PM core code to notify this layer
110 * that off mode has been disabled.
112 void omap_pm_disable_off_mode(void)
114 off_mode_enabled = false;
118 * Device context loss tracking
121 #ifdef CONFIG_ARCH_OMAP2PLUS
123 int omap_pm_get_dev_context_loss_count(struct device *dev)
125 struct platform_device *pdev = to_platform_device(dev);
126 int count;
128 if (WARN_ON(!dev))
129 return -ENODEV;
131 if (dev->pm_domain == &omap_device_pm_domain) {
132 count = omap_device_get_context_loss_count(pdev);
133 } else {
134 WARN_ONCE(off_mode_enabled, "omap_pm: using dummy context loss counter; device %s should be converted to omap_device",
135 dev_name(dev));
137 count = dummy_context_loss_counter;
139 if (off_mode_enabled) {
140 count++;
142 * Context loss count has to be a non-negative value.
143 * Clear the sign bit to get a value range from 0 to
144 * INT_MAX.
146 count &= INT_MAX;
147 dummy_context_loss_counter = count;
151 pr_debug("OMAP PM: context loss count for dev %s = %d\n",
152 dev_name(dev), count);
154 return count;
157 #else
159 int omap_pm_get_dev_context_loss_count(struct device *dev)
161 return dummy_context_loss_counter;
164 #endif
166 /* Should be called before clk framework init */
167 int __init omap_pm_if_early_init(void)
169 return 0;
172 /* Must be called after clock framework is initialized */
173 int __init omap_pm_if_init(void)
175 return 0;