aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/imx
diff options
context:
space:
mode:
authorLucas Stach <l.stach@pengutronix.de>2015-09-21 12:53:57 -0400
committerShawn Guo <shawnguo@kernel.org>2015-09-26 00:58:41 -0400
commit55adc61c568af99419be1dc0412f8eae019c71f2 (patch)
tree4d0ea6aa30a116767071a1979a8e7481e972b775 /drivers/clk/imx
parent8d449cb5e29a488cef44d81196f2819b92585513 (diff)
clk: imx: add common logic to detect early UART usage
Both earlycon and eralyprintk depend on the bootloader setup UART clocks being retained. This patch adds the common logic to detect such situations and make the information available to the clock drivers, as well as adding the facilities to disable those clocks at the end of the kernel init. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Shawn Guo <shawnguo@kernel.org>
Diffstat (limited to 'drivers/clk/imx')
-rw-r--r--drivers/clk/imx/clk.c38
-rw-r--r--drivers/clk/imx/clk.h1
2 files changed, 39 insertions, 0 deletions
diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
index df12b5307175..a634b1185be3 100644
--- a/drivers/clk/imx/clk.c
+++ b/drivers/clk/imx/clk.c
@@ -73,3 +73,41 @@ void imx_cscmr1_fixup(u32 *val)
73 *val ^= CSCMR1_FIXUP; 73 *val ^= CSCMR1_FIXUP;
74 return; 74 return;
75} 75}
76
77static int imx_keep_uart_clocks __initdata;
78static struct clk ** const *imx_uart_clocks __initdata;
79
80static int __init imx_keep_uart_clocks_param(char *str)
81{
82 imx_keep_uart_clocks = 1;
83
84 return 0;
85}
86__setup_param("earlycon", imx_keep_uart_earlycon,
87 imx_keep_uart_clocks_param, 0);
88__setup_param("earlyprintk", imx_keep_uart_earlyprintk,
89 imx_keep_uart_clocks_param, 0);
90
91void __init imx_register_uart_clocks(struct clk ** const clks[])
92{
93 if (imx_keep_uart_clocks) {
94 int i;
95
96 imx_uart_clocks = clks;
97 for (i = 0; imx_uart_clocks[i]; i++)
98 clk_prepare_enable(*imx_uart_clocks[i]);
99 }
100}
101
102static int __init imx_clk_disable_uart(void)
103{
104 if (imx_keep_uart_clocks && imx_uart_clocks) {
105 int i;
106
107 for (i = 0; imx_uart_clocks[i]; i++)
108 clk_disable_unprepare(*imx_uart_clocks[i]);
109 }
110
111 return 0;
112}
113late_initcall_sync(imx_clk_disable_uart);
diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h
index 1049b0c7d818..c94ac5c26226 100644
--- a/drivers/clk/imx/clk.h
+++ b/drivers/clk/imx/clk.h
@@ -7,6 +7,7 @@
7extern spinlock_t imx_ccm_lock; 7extern spinlock_t imx_ccm_lock;
8 8
9void imx_check_clocks(struct clk *clks[], unsigned int count); 9void imx_check_clocks(struct clk *clks[], unsigned int count);
10void imx_register_uart_clocks(struct clk ** const clks[]);
10 11
11extern void imx_cscmr1_fixup(u32 *val); 12extern void imx_cscmr1_fixup(u32 *val);
12 13