diff options
author | Anatolij Gustschin <agust@denx.de> | 2019-06-12 13:35:25 +0200 |
---|---|---|
committer | Stefano Babic <sbabic@denx.de> | 2019-07-19 20:14:50 +0200 |
commit | 64b5f469756f915cd223a0d8e807cb542a52666c (patch) | |
tree | 3d4733e112ddd1711ba612bb9fce099a000369eb /arch/arm/mach-imx | |
parent | fcc79eee14205e4f786f5020ea18d9cc123da971 (diff) |
arm: imx8: factor out uart init code
New imx8 boards started adding duplicated UART init code.
Factor out this to common function sc_pm_setup_uart().
Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Diffstat (limited to 'arch/arm/mach-imx')
-rw-r--r-- | arch/arm/mach-imx/imx8/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/mach-imx/imx8/misc.c | 26 |
2 files changed, 27 insertions, 1 deletions
diff --git a/arch/arm/mach-imx/imx8/Makefile b/arch/arm/mach-imx/imx8/Makefile index 31ad169ccf3..92b5c56acb2 100644 --- a/arch/arm/mach-imx/imx8/Makefile +++ b/arch/arm/mach-imx/imx8/Makefile @@ -4,4 +4,4 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-y += cpu.o iomux.o +obj-y += cpu.o iomux.o misc.o diff --git a/arch/arm/mach-imx/imx8/misc.c b/arch/arm/mach-imx/imx8/misc.c new file mode 100644 index 00000000000..fb92362bbf8 --- /dev/null +++ b/arch/arm/mach-imx/imx8/misc.c @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0+ +#include <common.h> +#include <asm/arch/sci/sci.h> + +int sc_pm_setup_uart(sc_rsrc_t uart_rsrc, sc_pm_clock_rate_t clk_rate) +{ + sc_pm_clock_rate_t rate = clk_rate; + int ret; + + /* Power up UARTn */ + ret = sc_pm_set_resource_power_mode(-1, uart_rsrc, SC_PM_PW_MODE_ON); + if (ret) + return ret; + + /* Set UARTn clock root to 'rate' MHz */ + ret = sc_pm_set_clock_rate(-1, uart_rsrc, SC_PM_CLK_PER, &rate); + if (ret) + return ret; + + /* Enable UARTn clock root */ + ret = sc_pm_clock_enable(-1, uart_rsrc, SC_PM_CLK_PER, true, false); + if (ret) + return ret; + + return 0; +} |