1
0
Fork 0

clk: imx: only enable clocks for earlycon/earlyprintk port

Only enable clocks for earlycon or earlyprintk uart port.

For communication uart port, clock enable will break clock
paraent and rate switch by commit 9461f7b33d (clk: fix
CLK_SET_RATE_GATE with clock rate protection)

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
[ Aisheng: update to CLK HW APIs ]
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
5.4-rM2-2.2.x-imx-squashed
Fugang Duan 2019-05-16 15:44:08 +08:00 committed by Dong Aisheng
parent 176cae71a3
commit ca06f727dc
1 changed files with 24 additions and 2 deletions

View File

@ -136,6 +136,7 @@ void imx_cscmr1_fixup(u32 *val)
static int imx_keep_uart_clocks;
static struct clk ** const *imx_uart_clocks;
static int earlycon_bits __initdata;
static int __init imx_keep_uart_clocks_param(char *str)
{
@ -148,13 +149,33 @@ __setup_param("earlycon", imx_keep_uart_earlycon,
__setup_param("earlyprintk", imx_keep_uart_earlyprintk,
imx_keep_uart_clocks_param, 0);
static void imx_earlycon_get(void)
{
int ret;
#ifdef CONFIG_DEBUG_LL
if (IS_ENABLED(CONFIG_DEBUG_IMX_UART_PORT))
earlycon_bits |= BIT(CONFIG_DEBUG_IMX_UART_PORT - 1);
#endif
if (!of_stdout)
return;
ret = of_alias_get_id(of_stdout, "serial");
if (ret >= 0)
earlycon_bits |= BIT(ret);
}
void imx_register_uart_clocks(struct clk ** const clks[])
{
imx_earlycon_get();
if (imx_keep_uart_clocks) {
int i;
imx_uart_clocks = clks;
for (i = 0; imx_uart_clocks[i]; i++)
for (i = 0; (earlycon_bits & BIT(i)) &&
imx_uart_clocks[i]; i++)
clk_prepare_enable(*imx_uart_clocks[i]);
}
}
@ -167,7 +188,8 @@ static int __init imx_clk_disable_uart(void)
if (imx_keep_uart_clocks && imx_uart_clocks) {
int i;
for (i = 0; imx_uart_clocks[i]; i++)
for (i = 0; (earlycon_bits & BIT(i)) &&
imx_uart_clocks[i]; i++)
clk_disable_unprepare(*imx_uart_clocks[i]);
}