Commit 6b5763e5886c0c5aaef36eab7d660fc885b60c20

Authored by Simon Glass
Committed by Albert ARIBAUD
1 parent 8f7431400a
Exists in master and in 55 other branches 8qm-imx_v2020.04_5.4.70_2.3.0, emb_lf_v2022.04, emb_lf_v2023.04, imx_v2015.04_4.1.15_1.0.0_ga, pitx_8mp_lf_v2020.04, smarc-8m-android-10.0.0_2.6.0, smarc-8m-android-11.0.0_2.0.0, smarc-8mp-android-11.0.0_2.0.0, smarc-emmc-imx_v2014.04_3.10.53_1.1.0_ga, smarc-emmc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx-l5.0.0_1.0.0-ga, smarc-imx6_v2018.03_4.14.98_2.0.0_ga, smarc-imx7_v2017.03_4.9.11_1.0.0_ga, smarc-imx7_v2018.03_4.14.98_2.0.0_ga, smarc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx_v2015.04_4.1.15_1.0.0_ga, smarc-imx_v2017.03_4.9.11_1.0.0_ga, smarc-imx_v2017.03_4.9.88_2.0.0_ga, smarc-imx_v2017.03_o8.1.0_1.3.0_8m, smarc-imx_v2018.03_4.14.78_1.0.0_ga, smarc-m6.0.1_2.1.0-ga, smarc-n7.1.2_2.0.0-ga, smarc-rel_imx_4.1.15_2.0.0_ga, smarc_8m-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8m-imx_v2019.04_4.19.35_1.1.0, smarc_8m_00d0-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2019.04_4.19.35_1.1.0, smarc_8mm-imx_v2020.04_5.4.24_2.1.0, smarc_8mp_lf_v2020.04, smarc_8mq-imx_v2020.04_5.4.24_2.1.0, smarc_8mq_lf_v2020.04, ti-u-boot-2015.07, u-boot-2013.01.y, v2013.10, v2013.10-smarct33, v2013.10-smartmen, v2014.01, v2014.04, v2014.04-smarct33, v2014.04-smarct33-emmc, v2014.04-smartmen, v2014.07, v2014.07-smarct33, v2014.07-smartmen, v2015.07-smarct33, v2015.07-smarct33-emmc, v2015.07-smarct4x, v2016.05-dlt, v2016.05-smarct3x, v2016.05-smarct3x-emmc, v2016.05-smarct4x, v2017.01-smarct3x, v2017.01-smarct3x-emmc, v2017.01-smarct4x

tegra2: Tidy UART selection

UART selection is done with a lot of #ifdefs. This cleans things up
a little.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Warren <twarren@nvidia.com>

Showing 1 changed file with 34 additions and 23 deletions Side-by-side Diff

board/nvidia/common/board.c
... ... @@ -35,6 +35,12 @@
35 35  
36 36 DECLARE_GLOBAL_DATA_PTR;
37 37  
  38 +enum {
  39 + /* UARTs which we can enable */
  40 + UARTA = 1 << 0,
  41 + UARTD = 1 << 3,
  42 +};
  43 +
38 44 const struct tegra2_sysinfo sysinfo = {
39 45 CONFIG_TEGRA2_BOARD_STRING
40 46 };
41 47  
42 48  
43 49  
44 50  
... ... @@ -64,36 +70,32 @@
64 70  
65 71 /*
66 72 * Routine: clock_init_uart
67   - * Description: init the PLL and clock for the UART(s)
  73 + * Description: init clock for the UART(s)
68 74 */
69   -static void clock_init_uart(void)
  75 +static void clock_init_uart(int uart_ids)
70 76 {
71   -#if defined(CONFIG_TEGRA2_ENABLE_UARTA)
72   - enable_uart(PERIPH_ID_UART1);
73   -#endif /* CONFIG_TEGRA2_ENABLE_UARTA */
74   -#if defined(CONFIG_TEGRA2_ENABLE_UARTD)
75   - enable_uart(PERIPH_ID_UART4);
76   -#endif /* CONFIG_TEGRA2_ENABLE_UARTD */
  77 + if (uart_ids & UARTA)
  78 + enable_uart(PERIPH_ID_UART1);
  79 + if (uart_ids & UARTD)
  80 + enable_uart(PERIPH_ID_UART4);
77 81 }
78 82  
79 83 /*
80 84 * Routine: pin_mux_uart
81 85 * Description: setup the pin muxes/tristate values for the UART(s)
82 86 */
83   -static void pin_mux_uart(void)
  87 +static void pin_mux_uart(int uart_ids)
84 88 {
85   -#if defined(CONFIG_TEGRA2_ENABLE_UARTA)
86   - pinmux_set_func(PINGRP_IRRX, PMUX_FUNC_UARTA);
87   - pinmux_set_func(PINGRP_IRTX, PMUX_FUNC_UARTA);
88   -
89   - pinmux_tristate_disable(PINGRP_IRRX);
90   - pinmux_tristate_disable(PINGRP_IRTX);
91   -#endif /* CONFIG_TEGRA2_ENABLE_UARTA */
92   -#if defined(CONFIG_TEGRA2_ENABLE_UARTD)
93   - pinmux_set_func(PINGRP_GMC, PMUX_FUNC_UARTD);
94   -
95   - pinmux_tristate_disable(PINGRP_GMC);
96   -#endif /* CONFIG_TEGRA2_ENABLE_UARTD */
  89 + if (uart_ids & UARTA) {
  90 + pinmux_set_func(PINGRP_IRRX, PMUX_FUNC_UARTA);
  91 + pinmux_set_func(PINGRP_IRTX, PMUX_FUNC_UARTA);
  92 + pinmux_tristate_disable(PINGRP_IRRX);
  93 + pinmux_tristate_disable(PINGRP_IRTX);
  94 + }
  95 + if (uart_ids & UARTD) {
  96 + pinmux_set_func(PINGRP_GMC, PMUX_FUNC_UARTD);
  97 + pinmux_tristate_disable(PINGRP_GMC);
  98 + }
97 99 }
98 100  
99 101 /*
... ... @@ -114,6 +116,15 @@
114 116 #ifdef CONFIG_BOARD_EARLY_INIT_F
115 117 int board_early_init_f(void)
116 118 {
  119 + int uart_ids = 0; /* bit mask of which UART ids to enable */
  120 +
  121 +#ifdef CONFIG_TEGRA2_ENABLE_UARTA
  122 + uart_ids |= UARTA;
  123 +#endif
  124 +#ifdef CONFIG_TEGRA2_ENABLE_UARTD
  125 + uart_ids |= UARTD;
  126 +#endif
  127 +
117 128 /* We didn't do this init in start.S, so do it now */
118 129 cpu_init_cp15();
119 130  
120 131  
... ... @@ -121,10 +132,10 @@
121 132 clock_early_init();
122 133  
123 134 /* Initialize UART clocks */
124   - clock_init_uart();
  135 + clock_init_uart(uart_ids);
125 136  
126 137 /* Initialize periph pinmuxes */
127   - pin_mux_uart();
  138 + pin_mux_uart(uart_ids);
128 139  
129 140 /* Initialize periph GPIOs */
130 141 gpio_config_uart();