Commit 30617cca authored by Igor Opaniuk's avatar Igor Opaniuk
Browse files

plat: imx: imx8qx: provide debug uart num as build param

1. This removes hardcoded iomux/clk/addr configuration for debug uart,
provides possibility (as a workaround, till that information isn't
provided via DT) to set this configuration during compile time via
IMX_DEBUG_UART build flag.

Also for Colibri i.MX8QXP different pinmux configuration is applied
for UART3, FLEXCAN2_RX/TX pads are muxed to ADMA_UART3_RX/TX.

2. Having DEBUG_CONSOLE enabled without enabling DEBUG_CONSOLE_A35
doesn't make sense (since UART pinmux/clock configuration is applied
for UART only when DEBUG_CONSOLE_A35 is enabled. Check similar commit
for i.MX8QM 98a69dfd

("plat: imx: imx8qm: apply clk/pinmux
configuration for DEBUG_CONSOLE")).

Usage:
$ make PLAT=imx8qx IMX_DEBUG_UART=3 DEBUG_CONSOLE=1 bl31
Signed-off-by: default avatarIgor Opaniuk <igor.opaniuk@gmail.com>
Change-Id: I5d04939b2e8ee1a5f4b2f3c6241977d3c6e91760
parent 65396234
...@@ -38,11 +38,43 @@ IMPORT_SYM(unsigned long, __RW_START__, BL31_RW_START); ...@@ -38,11 +38,43 @@ IMPORT_SYM(unsigned long, __RW_START__, BL31_RW_START);
static entry_point_info_t bl32_image_ep_info; static entry_point_info_t bl32_image_ep_info;
static entry_point_info_t bl33_image_ep_info; static entry_point_info_t bl33_image_ep_info;
/* Default configuration for i.MX8QM/QXP MEK */
#if defined(IMX_USE_UART0)
#define UART_PAD_CTRL (PADRING_IFMUX_EN_MASK | PADRING_GP_EN_MASK | \ #define UART_PAD_CTRL (PADRING_IFMUX_EN_MASK | PADRING_GP_EN_MASK | \
(SC_PAD_CONFIG_OUT_IN << PADRING_CONFIG_SHIFT) | \ (SC_PAD_CONFIG_OUT_IN << PADRING_CONFIG_SHIFT) | \
(SC_PAD_ISO_OFF << PADRING_LPCONFIG_SHIFT) | \ (SC_PAD_ISO_OFF << PADRING_LPCONFIG_SHIFT) | \
(SC_PAD_28FDSOI_DSE_DV_LOW << PADRING_DSE_SHIFT) | \ (SC_PAD_28FDSOI_DSE_DV_LOW << PADRING_DSE_SHIFT) | \
(SC_PAD_28FDSOI_PS_PD << PADRING_PULL_SHIFT)) (SC_PAD_28FDSOI_PS_PD << PADRING_PULL_SHIFT))
#define IMX_RES_UART SC_R_UART_0
#define IMX_PAD_UART_RX SC_P_UART0_RX
#define IMX_PAD_UART_TX SC_P_UART0_TX
/*
* On Toradex Colibri i.MX8QXP UART3 on the FLEXCAN2.
* Use custom pad control for this
*/
#elif defined(IMX_USE_UART3)
/*
* FLEXCAN2_RX/TX pads are muxed to ADMA_UART3_RX/TX,
* For ref:
* 000b - ADMA_FLEXCAN2_RX
* 001b - ADMA_SAI3_RXD
* 010b - ADMA_UART3_RX
* 011b - ADMA_SAI1_RXFS
* 100b - LSIO_GPIO1_IO19
*/
#define UART_PAD_CTRL (PADRING_IFMUX_EN_MASK | PADRING_GP_EN_MASK | \
(SC_PAD_CONFIG_OUT_IN << PADRING_CONFIG_SHIFT) | \
(2U << PADRING_IFMUX_SHIFT) | \
(SC_PAD_ISO_OFF << PADRING_LPCONFIG_SHIFT) | \
(SC_PAD_28FDSOI_DSE_DV_LOW << PADRING_DSE_SHIFT) | \
(SC_PAD_28FDSOI_PS_PD << PADRING_PULL_SHIFT))
#define IMX_RES_UART SC_R_UART_3
#define IMX_PAD_UART_RX SC_P_FLEXCAN2_RX
#define IMX_PAD_UART_TX SC_P_FLEXCAN2_TX
#else
#error "Provide proper UART configuration in IMX_DEBUG_UART"
#endif
static const mmap_region_t imx_mmap[] = { static const mmap_region_t imx_mmap[] = {
MAP_REGION_FLAT(IMX_REG_BASE, IMX_REG_SIZE, MT_DEVICE | MT_RW), MAP_REGION_FLAT(IMX_REG_BASE, IMX_REG_SIZE, MT_DEVICE | MT_RW),
...@@ -74,7 +106,7 @@ static void lpuart32_serial_setbrg(unsigned int base, int baudrate) ...@@ -74,7 +106,7 @@ static void lpuart32_serial_setbrg(unsigned int base, int baudrate)
if (baudrate == 0) if (baudrate == 0)
panic(); panic();
sc_pm_get_clock_rate(ipc_handle, SC_R_UART_0, 2, &rate); sc_pm_get_clock_rate(ipc_handle, IMX_RES_UART, 2, &rate);
baud_diff = baudrate; baud_diff = baudrate;
osr = 0; osr = 0;
...@@ -261,14 +293,15 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, ...@@ -261,14 +293,15 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
panic(); panic();
#if DEBUG_CONSOLE_A35 #if DEBUG_CONSOLE_A35
sc_pm_set_resource_power_mode(ipc_handle, SC_R_UART_0, SC_PM_PW_MODE_ON); sc_pm_set_resource_power_mode(ipc_handle, IMX_RES_UART,
SC_PM_PW_MODE_ON);
sc_pm_clock_rate_t rate = 80000000; sc_pm_clock_rate_t rate = 80000000;
sc_pm_set_clock_rate(ipc_handle, SC_R_UART_0, 2, &rate); sc_pm_set_clock_rate(ipc_handle, IMX_RES_UART, 2, &rate);
sc_pm_clock_enable(ipc_handle, SC_R_UART_0, 2, true, false); sc_pm_clock_enable(ipc_handle, IMX_RES_UART, 2, true, false);
/* Configure UART pads */ /* Configure UART pads */
sc_pad_set(ipc_handle, SC_P_UART0_RX, UART_PAD_CTRL); sc_pad_set(ipc_handle, IMX_PAD_UART_RX, UART_PAD_CTRL);
sc_pad_set(ipc_handle, SC_P_UART0_TX, UART_PAD_CTRL); sc_pad_set(ipc_handle, IMX_PAD_UART_TX, UART_PAD_CTRL);
lpuart32_serial_init(IMX_BOOT_UART_BASE); lpuart32_serial_init(IMX_BOOT_UART_BASE);
#endif #endif
......
...@@ -38,7 +38,15 @@ ...@@ -38,7 +38,15 @@
#define PLAT_GICD_BASE 0x51a00000 #define PLAT_GICD_BASE 0x51a00000
#define PLAT_GICR_BASE 0x51b00000 #define PLAT_GICR_BASE 0x51b00000
#if defined(IMX_USE_UART0)
#define IMX_BOOT_UART_BASE 0x5a060000 #define IMX_BOOT_UART_BASE 0x5a060000
#elif defined(IMX_USE_UART3)
#define IMX_BOOT_UART_BASE 0x5a090000
#else
#error "Provide proper UART configuration in IMX_DEBUG_UART"
#endif
#define IMX_BOOT_UART_BAUDRATE 115200 #define IMX_BOOT_UART_BAUDRATE 115200
#define IMX_BOOT_UART_CLK_IN_HZ 24000000 #define IMX_BOOT_UART_CLK_IN_HZ 24000000
#define PLAT_CRASH_UART_BASE IMX_BOOT_UART_BASE #define PLAT_CRASH_UART_BASE IMX_BOOT_UART_BASE
...@@ -55,8 +63,6 @@ ...@@ -55,8 +63,6 @@
/* non-secure u-boot base */ /* non-secure u-boot base */
#define PLAT_NS_IMAGE_OFFSET 0x80020000 #define PLAT_NS_IMAGE_OFFSET 0x80020000
#define DEBUG_CONSOLE_A35 DEBUG_CONSOLE
#define DEBUG_CONSOLE 0
#define DEBUG_CONSOLE_A35 0
#endif /* PLATFORM_DEF_H */ #endif /* PLATFORM_DEF_H */
...@@ -35,3 +35,9 @@ include plat/imx/common/sci/sci_api.mk ...@@ -35,3 +35,9 @@ include plat/imx/common/sci/sci_api.mk
USE_COHERENT_MEM := 1 USE_COHERENT_MEM := 1
RESET_TO_BL31 := 1 RESET_TO_BL31 := 1
IMX_DEBUG_UART ?= 0
$(eval $(call add_define,IMX_USE_UART${IMX_DEBUG_UART}))
DEBUG_CONSOLE ?= 0
$(eval $(call add_define,DEBUG_CONSOLE))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment