2015-08-05 12:13:36 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Intel Corporation.
|
2016-07-23 10:13:01 -05:00
|
|
|
* Copyright (c) 2016, Freescale Semiconductor, Inc.
|
2015-08-05 12:13:36 -07:00
|
|
|
*
|
2015-10-06 11:00:37 -05:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2015-08-05 12:13:36 -07:00
|
|
|
*
|
2015-10-06 11:00:37 -05:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-08-05 12:13:36 -07:00
|
|
|
*
|
2015-10-06 11:00:37 -05:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2015-08-05 12:13:36 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file Board config file
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <device.h>
|
|
|
|
#include <init.h>
|
|
|
|
|
|
|
|
#include <nanokernel.h>
|
|
|
|
|
2015-12-17 08:54:35 -05:00
|
|
|
#include "soc.h"
|
2016-07-23 10:13:01 -05:00
|
|
|
#include <fsl_common.h>
|
2015-08-05 12:13:36 -07:00
|
|
|
|
2015-12-01 08:42:19 -08:00
|
|
|
#ifdef CONFIG_UART_K20
|
2015-10-15 09:48:03 +03:00
|
|
|
#include <uart.h>
|
2015-08-10 15:02:04 -07:00
|
|
|
#include <console/uart_console.h>
|
2015-12-01 08:42:19 -08:00
|
|
|
#include <serial/uart_k20_priv.h>
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
#endif /* CONFIG_UART_K20 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* UART configuration
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef CONFIG_UART_K20
|
|
|
|
|
2016-04-28 15:14:38 -07:00
|
|
|
#if defined(CONFIG_UART_CONSOLE) && \
|
|
|
|
(defined(CONFIG_PRINTK) || defined(CONFIG_STDOUT_CONSOLE))
|
2015-08-10 15:02:04 -07:00
|
|
|
|
2016-07-23 10:13:01 -05:00
|
|
|
static PORT_Type *const ports[] = PORT_BASE_PTRS;
|
|
|
|
|
2015-08-10 15:02:04 -07:00
|
|
|
/**
|
|
|
|
* @brief Initialize K20 serial port as console
|
|
|
|
*
|
|
|
|
* Initialize the UART port for console I/O.
|
|
|
|
*
|
|
|
|
* @param dev The UART device struct
|
|
|
|
*
|
2016-03-18 11:58:02 -03:00
|
|
|
* @return 0 if successful, otherwise failed.
|
2015-08-10 15:02:04 -07:00
|
|
|
*/
|
2016-04-28 15:14:38 -07:00
|
|
|
static ALWAYS_INLINE int uart_k20_console_init(void)
|
2015-08-10 15:02:04 -07:00
|
|
|
{
|
2016-07-23 10:13:01 -05:00
|
|
|
PORT_Type *port;
|
2015-08-10 15:02:04 -07:00
|
|
|
uint32_t rxPin;
|
|
|
|
uint32_t txPin;
|
|
|
|
|
|
|
|
/* Port/pin ctrl module */
|
2016-07-23 10:13:01 -05:00
|
|
|
port = ports[CONFIG_UART_CONSOLE_PORT];
|
2015-08-10 15:02:04 -07:00
|
|
|
|
|
|
|
/* 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 */
|
2016-07-23 10:13:01 -05:00
|
|
|
port->PCR[rxPin] = PORT_PCR_MUX(CONFIG_UART_CONSOLE_PORT_MUX_FUNC);
|
|
|
|
port->PCR[txPin] = PORT_PCR_MUX(CONFIG_UART_CONSOLE_PORT_MUX_FUNC);
|
2015-08-10 15:02:04 -07:00
|
|
|
|
2016-03-18 11:58:02 -03:00
|
|
|
return 0;
|
2015-08-10 15:02:04 -07:00
|
|
|
}
|
|
|
|
|
2016-04-28 15:14:38 -07:00
|
|
|
#else
|
|
|
|
#define uart_k20_console_init(...)
|
|
|
|
#endif /* CONFIG_UART_CONSOLE && (CONFIG_PRINTK || CONFIG_STDOUT_CONSOLE) */
|
2015-08-10 15:02:04 -07:00
|
|
|
|
2015-12-15 14:44:00 -08:00
|
|
|
static int uart_k20_init(struct device *dev)
|
|
|
|
{
|
2016-07-23 10:13:01 -05:00
|
|
|
uint32_t scgc4;
|
2015-12-15 14:44:00 -08:00
|
|
|
|
|
|
|
ARG_UNUSED(dev);
|
|
|
|
|
|
|
|
/* Although it is possible to modify the bits through
|
|
|
|
* *sim directly, the following code saves about 20 bytes
|
|
|
|
* of ROM space, compared to direct modification.
|
|
|
|
*/
|
2016-07-23 10:13:01 -05:00
|
|
|
scgc4 = SIM->SCGC4;
|
2015-12-15 14:44:00 -08:00
|
|
|
|
|
|
|
#ifdef CONFIG_UART_K20_PORT_0
|
2016-07-23 10:13:01 -05:00
|
|
|
scgc4 |= SIM_SCGC4_UART0(1);
|
2015-12-15 14:44:00 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_UART_K20_PORT_1
|
2016-07-23 10:13:01 -05:00
|
|
|
scgc4 |= SIM_SCGC4_UART1(1);
|
2015-12-15 14:44:00 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_UART_K20_PORT_2
|
2016-07-23 10:13:01 -05:00
|
|
|
scgc4 |= SIM_SCGC4_UART2(1);
|
2015-12-15 14:44:00 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_UART_K20_PORT_3
|
2016-07-23 10:13:01 -05:00
|
|
|
scgc4 |= SIM_SCGC4_UART3(1);
|
2015-12-15 14:44:00 -08:00
|
|
|
#endif
|
|
|
|
|
2016-07-23 10:13:01 -05:00
|
|
|
SIM->SCGC4 = scgc4;
|
2015-12-15 14:44:00 -08:00
|
|
|
|
|
|
|
#ifdef CONFIG_UART_K20_PORT_4
|
2016-07-23 10:13:01 -05:00
|
|
|
SIM->SCGC1 |= SIM_SCGC1_UART4(1);
|
2015-12-15 14:44:00 -08:00
|
|
|
#endif
|
|
|
|
|
2016-04-28 15:14:38 -07:00
|
|
|
/* Initialize UART port for console if needed */
|
|
|
|
uart_k20_console_init();
|
|
|
|
|
2016-03-18 11:58:02 -03:00
|
|
|
return 0;
|
2015-12-15 14:44:00 -08:00
|
|
|
}
|
|
|
|
|
2016-01-28 14:48:47 -05:00
|
|
|
DEVICE_INIT(_uart_k20_init, "", uart_k20_init,
|
|
|
|
NULL, NULL,
|
|
|
|
PRIMARY, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
|
2015-12-15 14:44:00 -08:00
|
|
|
|
2015-12-01 08:42:19 -08:00
|
|
|
#endif /* CONFIG_UART_K20 */
|