2 * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef __LINUX_CLK_TEGRA_H_
18 #define __LINUX_CLK_TEGRA_H_
20 #include <linux/types.h>
21 #include <linux/bug.h>
24 * Tegra CPU clock and reset control ops
27 * keep waiting until the CPU in reset state
29 * put the CPU in reset state
31 * release the CPU from reset state
37 * CPU is ready for rail off
39 * save the clock settings when CPU go into low-power state
41 * restore the clock settings when CPU exit low-power state
43 struct tegra_cpu_car_ops {
44 void (*wait_for_reset)(u32 cpu);
45 void (*put_in_reset)(u32 cpu);
46 void (*out_of_reset)(u32 cpu);
47 void (*enable_clock)(u32 cpu);
48 void (*disable_clock)(u32 cpu);
49 #ifdef CONFIG_PM_SLEEP
50 bool (*rail_off_ready)(void);
51 void (*suspend)(void);
56 extern struct tegra_cpu_car_ops *tegra_cpu_car_ops;
58 static inline void tegra_wait_cpu_in_reset(u32 cpu)
60 if (WARN_ON(!tegra_cpu_car_ops->wait_for_reset))
63 tegra_cpu_car_ops->wait_for_reset(cpu);
66 static inline void tegra_put_cpu_in_reset(u32 cpu)
68 if (WARN_ON(!tegra_cpu_car_ops->put_in_reset))
71 tegra_cpu_car_ops->put_in_reset(cpu);
74 static inline void tegra_cpu_out_of_reset(u32 cpu)
76 if (WARN_ON(!tegra_cpu_car_ops->out_of_reset))
79 tegra_cpu_car_ops->out_of_reset(cpu);
82 static inline void tegra_enable_cpu_clock(u32 cpu)
84 if (WARN_ON(!tegra_cpu_car_ops->enable_clock))
87 tegra_cpu_car_ops->enable_clock(cpu);
90 static inline void tegra_disable_cpu_clock(u32 cpu)
92 if (WARN_ON(!tegra_cpu_car_ops->disable_clock))
95 tegra_cpu_car_ops->disable_clock(cpu);
98 #ifdef CONFIG_PM_SLEEP
99 static inline bool tegra_cpu_rail_off_ready(void)
101 if (WARN_ON(!tegra_cpu_car_ops->rail_off_ready))
104 return tegra_cpu_car_ops->rail_off_ready();
107 static inline void tegra_cpu_clock_suspend(void)
109 if (WARN_ON(!tegra_cpu_car_ops->suspend))
112 tegra_cpu_car_ops->suspend();
115 static inline void tegra_cpu_clock_resume(void)
117 if (WARN_ON(!tegra_cpu_car_ops->resume))
120 tegra_cpu_car_ops->resume();
124 #endif /* __LINUX_CLK_TEGRA_H_ */