diff options
author | Anatolij Gustschin | 2019-06-12 13:35:25 +0200 |
---|---|---|
committer | Stefano Babic | 2019-07-19 20:14:50 +0200 |
commit | 64b5f469756f915cd223a0d8e807cb542a52666c (patch) | |
tree | 3d4733e112ddd1711ba612bb9fce099a000369eb /board | |
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 'board')
-rw-r--r-- | board/freescale/imx8qm_mek/imx8qm_mek.c | 16 | ||||
-rw-r--r-- | board/freescale/imx8qxp_mek/imx8qxp_mek.c | 16 | ||||
-rw-r--r-- | board/toradex/apalis-imx8/apalis-imx8.c | 17 | ||||
-rw-r--r-- | board/toradex/colibri-imx8x/colibri-imx8x.c | 16 |
4 files changed, 12 insertions, 53 deletions
diff --git a/board/freescale/imx8qm_mek/imx8qm_mek.c b/board/freescale/imx8qm_mek/imx8qm_mek.c index e69efc4dd62..249c29e0f2b 100644 --- a/board/freescale/imx8qm_mek/imx8qm_mek.c +++ b/board/freescale/imx8qm_mek/imx8qm_mek.c @@ -34,21 +34,11 @@ static void setup_iomux_uart(void) int board_early_init_f(void) { + sc_pm_clock_rate_t rate = SC_80MHZ; int ret; - /* Set UART0 clock root to 80 MHz */ - sc_pm_clock_rate_t rate = 80000000; - - /* Power up UART0 */ - ret = sc_pm_set_resource_power_mode(-1, SC_R_UART_0, SC_PM_PW_MODE_ON); - if (ret) - return ret; - ret = sc_pm_set_clock_rate(-1, SC_R_UART_0, 2, &rate); - if (ret) - return ret; - - /* Enable UART0 clock root */ - ret = sc_pm_clock_enable(-1, SC_R_UART_0, 2, true, false); + /* Set UART0 clock root to 80 MHz */ + ret = sc_pm_setup_uart(SC_R_UART_0, rate); if (ret) return ret; diff --git a/board/freescale/imx8qxp_mek/imx8qxp_mek.c b/board/freescale/imx8qxp_mek/imx8qxp_mek.c index 120731422c9..82a79033af4 100644 --- a/board/freescale/imx8qxp_mek/imx8qxp_mek.c +++ b/board/freescale/imx8qxp_mek/imx8qxp_mek.c @@ -40,21 +40,11 @@ static void setup_iomux_uart(void) int board_early_init_f(void) { + sc_pm_clock_rate_t rate = SC_80MHZ; int ret; - /* Set UART0 clock root to 80 MHz */ - sc_pm_clock_rate_t rate = 80000000; - - /* Power up UART0 */ - ret = sc_pm_set_resource_power_mode(-1, SC_R_UART_0, SC_PM_PW_MODE_ON); - if (ret) - return ret; - ret = sc_pm_set_clock_rate(-1, SC_R_UART_0, 2, &rate); - if (ret) - return ret; - - /* Enable UART0 clock root */ - ret = sc_pm_clock_enable(-1, SC_R_UART_0, 2, true, false); + /* Set UART0 clock root to 80 MHz */ + ret = sc_pm_setup_uart(SC_R_UART_0, rate); if (ret) return ret; diff --git a/board/toradex/apalis-imx8/apalis-imx8.c b/board/toradex/apalis-imx8/apalis-imx8.c index f516e546a8d..4243b0e174e 100644 --- a/board/toradex/apalis-imx8/apalis-imx8.c +++ b/board/toradex/apalis-imx8/apalis-imx8.c @@ -37,22 +37,11 @@ static void setup_iomux_uart(void) int board_early_init_f(void) { - sc_pm_clock_rate_t rate; + sc_pm_clock_rate_t rate = SC_80MHZ; sc_err_t err = 0; - /* Power up UART1 */ - err = sc_pm_set_resource_power_mode(-1, SC_R_UART_1, SC_PM_PW_MODE_ON); - if (err != SC_ERR_NONE) - return 0; - - /* Set UART3 clock root to 80 MHz */ - rate = 80000000; - err = sc_pm_set_clock_rate(-1, SC_R_UART_1, SC_PM_CLK_PER, &rate); - if (err != SC_ERR_NONE) - return 0; - - /* Enable UART1 clock root */ - err = sc_pm_clock_enable(-1, SC_R_UART_1, SC_PM_CLK_PER, true, false); + /* Set UART1 clock root to 80 MHz and enable it */ + err = sc_pm_setup_uart(SC_R_UART_1, rate); if (err != SC_ERR_NONE) return 0; diff --git a/board/toradex/colibri-imx8x/colibri-imx8x.c b/board/toradex/colibri-imx8x/colibri-imx8x.c index aa8eaa0ea13..a146148556f 100644 --- a/board/toradex/colibri-imx8x/colibri-imx8x.c +++ b/board/toradex/colibri-imx8x/colibri-imx8x.c @@ -51,19 +51,9 @@ int board_early_init_f(void) if (err != SC_ERR_NONE) return 0; - /* Power up UART3 */ - err = sc_pm_set_resource_power_mode(-1, SC_R_UART_3, SC_PM_PW_MODE_ON); - if (err != SC_ERR_NONE) - return 0; - - /* Set UART3 clock root to 80 MHz */ - rate = 80000000; - err = sc_pm_set_clock_rate(-1, SC_R_UART_3, SC_PM_CLK_PER, &rate); - if (err != SC_ERR_NONE) - return 0; - - /* Enable UART3 clock root */ - err = sc_pm_clock_enable(-1, SC_R_UART_3, SC_PM_CLK_PER, true, false); + /* Set UART3 clock root to 80 MHz and enable it */ + rate = SC_80MHZ; + err = sc_pm_setup_uart(SC_R_UART_3, rate); if (err != SC_ERR_NONE) return 0; |