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/clk.h>
23 * Tegra CPU clock and reset control ops
26 * keep waiting until the CPU in reset state
28 * put the CPU in reset state
30 * release the CPU from reset state
36 * CPU is ready for rail off
38 * save the clock settings when CPU go into low-power state
40 * restore the clock settings when CPU exit low-power state
42 struct tegra_cpu_car_ops
{
43 void (*wait_for_reset
)(u32 cpu
);
44 void (*put_in_reset
)(u32 cpu
);
45 void (*out_of_reset
)(u32 cpu
);
46 void (*enable_clock
)(u32 cpu
);
47 void (*disable_clock
)(u32 cpu
);
48 #ifdef CONFIG_PM_SLEEP
49 bool (*rail_off_ready
)(void);
50 void (*suspend
)(void);
55 extern struct tegra_cpu_car_ops
*tegra_cpu_car_ops
;
57 static inline void tegra_wait_cpu_in_reset(u32 cpu
)
59 if (WARN_ON(!tegra_cpu_car_ops
->wait_for_reset
))
62 tegra_cpu_car_ops
->wait_for_reset(cpu
);
65 static inline void tegra_put_cpu_in_reset(u32 cpu
)
67 if (WARN_ON(!tegra_cpu_car_ops
->put_in_reset
))
70 tegra_cpu_car_ops
->put_in_reset(cpu
);
73 static inline void tegra_cpu_out_of_reset(u32 cpu
)
75 if (WARN_ON(!tegra_cpu_car_ops
->out_of_reset
))
78 tegra_cpu_car_ops
->out_of_reset(cpu
);
81 static inline void tegra_enable_cpu_clock(u32 cpu
)
83 if (WARN_ON(!tegra_cpu_car_ops
->enable_clock
))
86 tegra_cpu_car_ops
->enable_clock(cpu
);
89 static inline void tegra_disable_cpu_clock(u32 cpu
)
91 if (WARN_ON(!tegra_cpu_car_ops
->disable_clock
))
94 tegra_cpu_car_ops
->disable_clock(cpu
);
97 #ifdef CONFIG_PM_SLEEP
98 static inline bool tegra_cpu_rail_off_ready(void)
100 if (WARN_ON(!tegra_cpu_car_ops
->rail_off_ready
))
103 return tegra_cpu_car_ops
->rail_off_ready();
106 static inline void tegra_cpu_clock_suspend(void)
108 if (WARN_ON(!tegra_cpu_car_ops
->suspend
))
111 tegra_cpu_car_ops
->suspend();
114 static inline void tegra_cpu_clock_resume(void)
116 if (WARN_ON(!tegra_cpu_car_ops
->resume
))
119 tegra_cpu_car_ops
->resume();
123 #ifdef CONFIG_ARCH_TEGRA
124 void tegra_periph_reset_deassert(struct clk
*c
);
125 void tegra_periph_reset_assert(struct clk
*c
);
127 static inline void tegra_periph_reset_deassert(struct clk
*c
) {}
128 static inline void tegra_periph_reset_assert(struct clk
*c
) {}
130 void tegra_clocks_apply_init_table(void);
132 #endif /* __LINUX_CLK_TEGRA_H_ */