From 4184c7f82eb1e43741f348433132d0d232f5a0cb Mon Sep 17 00:00:00 2001 From: Maureen Helm Date: Sat, 7 Jan 2017 09:32:57 -0600 Subject: [PATCH] k64: Move uart console pins to board pinmux tables Moves the uart console pins from the k64 soc init to the frdm_k64f and hexiwear_k64 board pinmux tables. Not having these pins in the board pinmux tables led one to believe that no pins in PORTB were being used on the hexiwear_k64 board, and thus the port was incorrectly disabled by default. Also fixes PORTB to be enabled by default if the uart console is used. Change-Id: Ide6b7b34dfba8a75a02a8f2bf37cce843afb92f1 Signed-off-by: Maureen Helm --- arch/arm/soc/nxp_kinetis/k6x/soc.h | 11 ------ arch/arm/soc/nxp_kinetis/k6x/soc_config.c | 41 ----------------------- boards/arm/frdm_k64f/pinmux.c | 6 ++++ boards/arm/hexiwear_k64/Kconfig.defconfig | 2 +- boards/arm/hexiwear_k64/pinmux.c | 6 ++++ 5 files changed, 13 insertions(+), 53 deletions(-) diff --git a/arch/arm/soc/nxp_kinetis/k6x/soc.h b/arch/arm/soc/nxp_kinetis/k6x/soc.h index 61fb2247055..3903095bfb4 100644 --- a/arch/arm/soc/nxp_kinetis/k6x/soc.h +++ b/arch/arm/soc/nxp_kinetis/k6x/soc.h @@ -179,17 +179,6 @@ extern "C" { #endif /* CONFIG_UART_K20 */ -/* Uart console settings */ -#if defined(CONFIG_UART_CONSOLE) - -#define CONFIG_UART_CONSOLE_PORT PCR_PORT_B -#define CONFIG_UART_CONSOLE_PORT_RX_PIN 16 -#define CONFIG_UART_CONSOLE_PORT_TX_PIN 17 -#define CONFIG_UART_CONSOLE_PORT_MUX_FUNC PCR_MUX_ALT3 -#define CONFIG_UART_CONSOLE_CLK_FREQ SYSCLK_DEFAULT_IOSC_HZ - -#endif /* CONFIG_UART_CONSOLE */ - /* * GPIO configuration settings */ diff --git a/arch/arm/soc/nxp_kinetis/k6x/soc_config.c b/arch/arm/soc/nxp_kinetis/k6x/soc_config.c index 1cefe52faf7..0ef7313e849 100644 --- a/arch/arm/soc/nxp_kinetis/k6x/soc_config.c +++ b/arch/arm/soc/nxp_kinetis/k6x/soc_config.c @@ -39,44 +39,6 @@ #ifdef CONFIG_UART_K20 -#if defined(CONFIG_UART_CONSOLE) && \ - (defined(CONFIG_PRINTK) || defined(CONFIG_STDOUT_CONSOLE)) - -static PORT_Type *const ports[] = PORT_BASE_PTRS; - -/** - * @brief Initialize K20 serial port as console - * - * Initialize the UART port for console I/O. - * - * @param dev The UART device struct - * - * @return 0 if successful, otherwise failed. - */ -static ALWAYS_INLINE int uart_k20_console_init(void) -{ - PORT_Type *port; - uint32_t rxPin; - uint32_t txPin; - - /* Port/pin ctrl module */ - port = ports[CONFIG_UART_CONSOLE_PORT]; - - /* UART0 Rx and Tx pin assignments */ - rxPin = CONFIG_UART_CONSOLE_PORT_RX_PIN; - txPin = CONFIG_UART_CONSOLE_PORT_TX_PIN; - - /* Enable the UART Rx and Tx Pins */ - port->PCR[rxPin] = PORT_PCR_MUX(CONFIG_UART_CONSOLE_PORT_MUX_FUNC); - port->PCR[txPin] = PORT_PCR_MUX(CONFIG_UART_CONSOLE_PORT_MUX_FUNC); - - return 0; -} - -#else -#define uart_k20_console_init(...) -#endif /* CONFIG_UART_CONSOLE && (CONFIG_PRINTK || CONFIG_STDOUT_CONSOLE) */ - static int uart_k20_init(struct device *dev) { uint32_t scgc4; @@ -111,9 +73,6 @@ static int uart_k20_init(struct device *dev) SIM->SCGC1 |= SIM_SCGC1_UART4(1); #endif - /* Initialize UART port for console if needed */ - uart_k20_console_init(); - return 0; } diff --git a/boards/arm/frdm_k64f/pinmux.c b/boards/arm/frdm_k64f/pinmux.c index b6fb4b11f5c..f42be55c878 100644 --- a/boards/arm/frdm_k64f/pinmux.c +++ b/boards/arm/frdm_k64f/pinmux.c @@ -43,6 +43,12 @@ static int frdm_k64f_pinmux_init(struct device *dev) device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); #endif +#ifdef CONFIG_UART_K20_PORT_0 + /* UART0 RX, TX */ + pinmux_pin_set(portb, 16, PORT_PCR_MUX(kPORT_MuxAlt3)); + pinmux_pin_set(portb, 17, PORT_PCR_MUX(kPORT_MuxAlt3)); +#endif + #ifdef CONFIG_UART_K20_PORT_3 /* UART3 RX, TX */ pinmux_pin_set(portc, 16, PORT_PCR_MUX(kPORT_MuxAlt3)); diff --git a/boards/arm/hexiwear_k64/Kconfig.defconfig b/boards/arm/hexiwear_k64/Kconfig.defconfig index 5fac02b8f92..ef2494f0e73 100644 --- a/boards/arm/hexiwear_k64/Kconfig.defconfig +++ b/boards/arm/hexiwear_k64/Kconfig.defconfig @@ -99,7 +99,7 @@ config PINMUX_MCUX_PORTA def_bool n config PINMUX_MCUX_PORTB - def_bool n + def_bool y if UART_K20_PORT_0 config PINMUX_MCUX_PORTC def_bool y diff --git a/boards/arm/hexiwear_k64/pinmux.c b/boards/arm/hexiwear_k64/pinmux.c index ed1b7a67267..78bf9413580 100644 --- a/boards/arm/hexiwear_k64/pinmux.c +++ b/boards/arm/hexiwear_k64/pinmux.c @@ -58,6 +58,12 @@ static int hexiwear_k64_pinmux_init(struct device *dev) /* FXOS8700 INT1 */ pinmux_pin_set(portc, 1, PORT_PCR_MUX(kPORT_MuxAsGpio)); +#ifdef CONFIG_UART_K20_PORT_0 + /* UART0 RX, TX */ + pinmux_pin_set(portb, 16, PORT_PCR_MUX(kPORT_MuxAlt3)); + pinmux_pin_set(portb, 17, PORT_PCR_MUX(kPORT_MuxAlt3)); +#endif + #ifdef CONFIG_UART_K20_PORT_4 /* UART4 RX, TX - BLE */ pinmux_pin_set(porte, 24, PORT_PCR_MUX(kPORT_MuxAlt3));