nxp_kinetis: Refactor K64F init to use CMSIS register accesses
The K64F SoC initialization previously used macros and structs custom-defined in Zephyr in order to access peripheral registers. Refactored it to use CMSIS-style register accesses from the ksdk instead. Change-Id: I80975c62de07ec95cf830e99cd5b0abb9623acd0 Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
This commit is contained in:
parent
c9663f5424
commit
dc631750fa
2 changed files with 61 additions and 73 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
* Copyright (c) 2016, Freescale Semiconductor, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,11 +25,10 @@
|
|||
#include <nanokernel.h>
|
||||
|
||||
#include "soc.h"
|
||||
#include <fsl_common.h>
|
||||
|
||||
#ifdef CONFIG_UART_K20
|
||||
#include <uart.h>
|
||||
#include <drivers/k20_pcr.h>
|
||||
#include <drivers/k20_sim.h>
|
||||
#include <console/uart_console.h>
|
||||
#include <serial/uart_k20_priv.h>
|
||||
#endif /* CONFIG_UART_K20 */
|
||||
|
@ -42,6 +42,8 @@
|
|||
#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
|
||||
*
|
||||
|
@ -53,25 +55,20 @@
|
|||
*/
|
||||
static ALWAYS_INLINE int uart_k20_console_init(void)
|
||||
{
|
||||
uint32_t port;
|
||||
PORT_Type *port;
|
||||
uint32_t rxPin;
|
||||
uint32_t txPin;
|
||||
union K20_PCR pcr = {0}; /* Pin Control Register */
|
||||
|
||||
/* Port/pin ctrl module */
|
||||
volatile struct K20_PORT_PCR *port_pcr_p =
|
||||
(volatile struct K20_PORT_PCR *)PERIPH_ADDR_BASE_PCR;
|
||||
port = ports[CONFIG_UART_CONSOLE_PORT];
|
||||
|
||||
/* UART0 Rx and Tx pin assignments */
|
||||
port = CONFIG_UART_CONSOLE_PORT;
|
||||
rxPin = CONFIG_UART_CONSOLE_PORT_RX_PIN;
|
||||
txPin = CONFIG_UART_CONSOLE_PORT_TX_PIN;
|
||||
|
||||
/* Enable the UART Rx and Tx Pins */
|
||||
pcr.field.mux = CONFIG_UART_CONSOLE_PORT_MUX_FUNC;
|
||||
|
||||
port_pcr_p->port[port].pcr[rxPin] = pcr;
|
||||
port_pcr_p->port[port].pcr[txPin] = pcr;
|
||||
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;
|
||||
}
|
||||
|
@ -82,9 +79,7 @@ static ALWAYS_INLINE int uart_k20_console_init(void)
|
|||
|
||||
static int uart_k20_init(struct device *dev)
|
||||
{
|
||||
volatile struct K20_SIM *sim = /* sys integ. ctl */
|
||||
(volatile struct K20_SIM *)PERIPH_ADDR_BASE_SIM;
|
||||
SIM_SCGC4_t scgc4;
|
||||
uint32_t scgc4;
|
||||
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
|
@ -92,28 +87,28 @@ static int uart_k20_init(struct device *dev)
|
|||
* *sim directly, the following code saves about 20 bytes
|
||||
* of ROM space, compared to direct modification.
|
||||
*/
|
||||
scgc4.value = sim->scgc4.value;
|
||||
scgc4 = SIM->SCGC4;
|
||||
|
||||
#ifdef CONFIG_UART_K20_PORT_0
|
||||
scgc4.field.uart0_clk_en = 1;
|
||||
scgc4 |= SIM_SCGC4_UART0(1);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_UART_K20_PORT_1
|
||||
scgc4.field.uart1_clk_en = 1;
|
||||
scgc4 |= SIM_SCGC4_UART1(1);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_UART_K20_PORT_2
|
||||
scgc4.field.uart2_clk_en = 1;
|
||||
scgc4 |= SIM_SCGC4_UART2(1);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_UART_K20_PORT_3
|
||||
scgc4.field.uart3_clk_en = 1;
|
||||
scgc4 |= SIM_SCGC4_UART3(1);
|
||||
#endif
|
||||
|
||||
sim->scgc4.value = scgc4.value;
|
||||
SIM->SCGC4 = scgc4;
|
||||
|
||||
#ifdef CONFIG_UART_K20_PORT_4
|
||||
sim->scgc1.field.uart4_clk_en = 1;
|
||||
SIM->SCGC1 |= SIM_SCGC1_UART4(1);
|
||||
#endif
|
||||
|
||||
/* Initialize UART port for console if needed */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue