clk.c (cbecf716ca618fd44feda6bd9a64a8179d031fc5) clk.c (379c9a24cc239000b1dec53db02fe17a86947423)
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/bits.h>
3#include <linux/clk.h>
4#include <linux/clk-provider.h>
5#include <linux/err.h>
6#include <linux/io.h>
7#include <linux/module.h>
8#include <linux/of.h>

--- 133 unchanged lines hidden (view full) ---

142
143void imx_cscmr1_fixup(u32 *val)
144{
145 *val ^= CSCMR1_FIXUP;
146 return;
147}
148
149#ifndef MODULE
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/bits.h>
3#include <linux/clk.h>
4#include <linux/clk-provider.h>
5#include <linux/err.h>
6#include <linux/io.h>
7#include <linux/module.h>
8#include <linux/of.h>

--- 133 unchanged lines hidden (view full) ---

142
143void imx_cscmr1_fixup(u32 *val)
144{
145 *val ^= CSCMR1_FIXUP;
146 return;
147}
148
149#ifndef MODULE
150static int imx_keep_uart_clocks;
151static struct clk ** const *imx_uart_clocks;
152
150
151static bool imx_keep_uart_clocks;
152static int imx_enabled_uart_clocks;
153static struct clk **imx_uart_clocks;
154
153static int __init imx_keep_uart_clocks_param(char *str)
154{
155 imx_keep_uart_clocks = 1;
156
157 return 0;
158}
159__setup_param("earlycon", imx_keep_uart_earlycon,
160 imx_keep_uart_clocks_param, 0);
161__setup_param("earlyprintk", imx_keep_uart_earlyprintk,
162 imx_keep_uart_clocks_param, 0);
163
155static int __init imx_keep_uart_clocks_param(char *str)
156{
157 imx_keep_uart_clocks = 1;
158
159 return 0;
160}
161__setup_param("earlycon", imx_keep_uart_earlycon,
162 imx_keep_uart_clocks_param, 0);
163__setup_param("earlyprintk", imx_keep_uart_earlyprintk,
164 imx_keep_uart_clocks_param, 0);
165
164void imx_register_uart_clocks(struct clk ** const clks[])
166void imx_register_uart_clocks(unsigned int clk_count)
165{
167{
168 imx_enabled_uart_clocks = 0;
169
170/* i.MX boards use device trees now. For build tests without CONFIG_OF, do nothing */
171#ifdef CONFIG_OF
166 if (imx_keep_uart_clocks) {
167 int i;
168
172 if (imx_keep_uart_clocks) {
173 int i;
174
169 imx_uart_clocks = clks;
170 for (i = 0; imx_uart_clocks[i]; i++)
171 clk_prepare_enable(*imx_uart_clocks[i]);
175 imx_uart_clocks = kcalloc(clk_count, sizeof(struct clk *), GFP_KERNEL);
176
177 if (!of_stdout)
178 return;
179
180 for (i = 0; i < clk_count; i++) {
181 imx_uart_clocks[imx_enabled_uart_clocks] = of_clk_get(of_stdout, i);
182
183 /* Stop if there are no more of_stdout references */
184 if (IS_ERR(imx_uart_clocks[imx_enabled_uart_clocks]))
185 return;
186
187 /* Only enable the clock if it's not NULL */
188 if (imx_uart_clocks[imx_enabled_uart_clocks])
189 clk_prepare_enable(imx_uart_clocks[imx_enabled_uart_clocks++]);
190 }
172 }
191 }
192#endif
173}
174
175static int __init imx_clk_disable_uart(void)
176{
193}
194
195static int __init imx_clk_disable_uart(void)
196{
177 if (imx_keep_uart_clocks && imx_uart_clocks) {
197 if (imx_keep_uart_clocks && imx_enabled_uart_clocks) {
178 int i;
179
198 int i;
199
180 for (i = 0; imx_uart_clocks[i]; i++)
181 clk_disable_unprepare(*imx_uart_clocks[i]);
200 for (i = 0; i < imx_enabled_uart_clocks; i++) {
201 clk_disable_unprepare(imx_uart_clocks[i]);
202 clk_put(imx_uart_clocks[i]);
203 }
204 kfree(imx_uart_clocks);
182 }
183
184 return 0;
185}
186late_initcall_sync(imx_clk_disable_uart);
187#endif
188
189MODULE_LICENSE("GPL v2");
205 }
206
207 return 0;
208}
209late_initcall_sync(imx_clk_disable_uart);
210#endif
211
212MODULE_LICENSE("GPL v2");