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>
This commit is contained in:
parent
aaa2650f0f
commit
52b499fd1f
10 changed files with 973 additions and 43 deletions
|
@ -30,9 +30,21 @@
|
|||
#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 */
|
||||
|
||||
#ifdef CONFIG_PINMUX
|
||||
#include <pinmux.h>
|
||||
#include <pinmux/pinmux.h>
|
||||
#include <pinmux/pinmux_k64.h>
|
||||
#endif /* CONFIG_PINMUX */
|
||||
|
||||
|
||||
/*
|
||||
* UART configuration
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_UART_K20
|
||||
|
||||
#if defined(CONFIG_UART_CONSOLE)
|
||||
#if defined(CONFIG_PRINTK) || defined(CONFIG_STDOUT_CONSOLE)
|
||||
|
@ -120,3 +132,90 @@ DEVICE_INIT(_uart_k20_init, "", uart_k20_init,
|
|||
PRIMARY, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
|
||||
|
||||
#endif /* CONFIG_UART_K20 */
|
||||
|
||||
/*
|
||||
* I/O pin configuration
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_PINMUX
|
||||
|
||||
/*
|
||||
* Number of default pin settings, used for Arduino Rev 3 pinout.
|
||||
*
|
||||
* NOTE: The FRDM-K64F board routes the PTA0/1/2 pins for JTAG/SWD signals that
|
||||
* are used for the OpenSDAv2 debug interface. These pins are also routed to
|
||||
* the Arduino header pins as D8, D3 and D5, respectively.
|
||||
* Since the K64 MCU configures these pins for JTAG/SWD signaling at reset,
|
||||
* they should only be re-configured if the debug interface is not used.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_PRESERVE_JTAG_IO_PINS
|
||||
#define NUM_DFLT_PINS_SET 22
|
||||
#else
|
||||
#define NUM_DFLT_PINS_SET (22 - 3)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Alter this table to change the default Arduino pin settings on the Freescale
|
||||
* FRDM-K64F boards. Specifically, change the PINMUX_* values to represent
|
||||
* the functionality desired.
|
||||
*/
|
||||
struct pin_config mux_config[NUM_DFLT_PINS_SET] = {
|
||||
/* pin, selected mode */
|
||||
{ K64_PIN_PTC16, (K64_PINMUX_FUNC_GPIO | K64_PINMUX_GPIO_DIR_INPUT) },
|
||||
{ K64_PIN_PTC17, (K64_PINMUX_FUNC_GPIO | K64_PINMUX_GPIO_DIR_INPUT) },
|
||||
{ K64_PIN_PTB9, (K64_PINMUX_FUNC_GPIO | K64_PINMUX_GPIO_DIR_INPUT) },
|
||||
#ifndef CONFIG_PRESERVE_JTAG_IO_PINS
|
||||
{ K64_PIN_PTA1, (K64_PINMUX_FUNC_GPIO | K64_PINMUX_GPIO_DIR_INPUT) },
|
||||
#endif
|
||||
{ K64_PIN_PTB23, (K64_PINMUX_FUNC_GPIO | K64_PINMUX_GPIO_DIR_INPUT) },
|
||||
#ifndef CONFIG_PRESERVE_JTAG_IO_PINS
|
||||
{ K64_PIN_PTA2, (K64_PINMUX_FUNC_GPIO | K64_PINMUX_GPIO_DIR_INPUT) },
|
||||
#endif
|
||||
{ K64_PIN_PTC2, (K64_PINMUX_FUNC_GPIO | K64_PINMUX_GPIO_DIR_INPUT) },
|
||||
{ K64_PIN_PTC3, (K64_PINMUX_FUNC_GPIO | K64_PINMUX_GPIO_DIR_INPUT) },
|
||||
#ifndef CONFIG_PRESERVE_JTAG_IO_PINS
|
||||
{ K64_PIN_PTA0, (K64_PINMUX_FUNC_GPIO | K64_PINMUX_GPIO_DIR_INPUT) },
|
||||
#endif
|
||||
{ K64_PIN_PTC4, (K64_PINMUX_FUNC_GPIO | K64_PINMUX_GPIO_DIR_INPUT) },
|
||||
{ K64_PIN_PTD0, (K64_PINMUX_FUNC_GPIO | K64_PINMUX_GPIO_DIR_INPUT) },
|
||||
{ K64_PIN_PTD2, (K64_PINMUX_FUNC_GPIO | K64_PINMUX_GPIO_DIR_INPUT) },
|
||||
{ K64_PIN_PTD3, (K64_PINMUX_FUNC_GPIO | K64_PINMUX_GPIO_DIR_INPUT) },
|
||||
{ K64_PIN_PTD1, (K64_PINMUX_FUNC_GPIO | K64_PINMUX_GPIO_DIR_INPUT) },
|
||||
/* I2C0_SDA */
|
||||
{ K64_PIN_PTE25, (K64_PINMUX_ALT_5 | K64_PINMUX_OPEN_DRN_ENABLE) },
|
||||
/* I2C0_SCL */
|
||||
{ K64_PIN_PTE24, (K64_PINMUX_ALT_5 | K64_PINMUX_OPEN_DRN_ENABLE) },
|
||||
{ K64_PIN_PTB2, K64_PINMUX_FUNC_ANALOG }, /* ADC0_SE12/Analog In 0 */
|
||||
{ K64_PIN_PTB3, K64_PINMUX_FUNC_ANALOG }, /* ADC0_SE13/Analog In 1 */
|
||||
{ K64_PIN_PTB10, K64_PINMUX_FUNC_ANALOG }, /* ADC1_SE14/Analog In 2 */
|
||||
{ K64_PIN_PTB11, K64_PINMUX_FUNC_ANALOG }, /* ADC1_SE15/Analog In 3 */
|
||||
{ K64_PIN_PTC11, K64_PINMUX_FUNC_ANALOG }, /* ADC1_SE7b/Analog In 4 */
|
||||
{ K64_PIN_PTC10, K64_PINMUX_FUNC_ANALOG }, /* ADC1_SE6b/Analog In 5 */
|
||||
};
|
||||
|
||||
|
||||
int fsl_frdm_k64f_pin_init(struct device *arg)
|
||||
{
|
||||
ARG_UNUSED(arg);
|
||||
struct device *pmux;
|
||||
int i;
|
||||
|
||||
pmux = device_get_binding(PINMUX_NAME);
|
||||
|
||||
if (!pmux) {
|
||||
return DEV_INVALID_CONF;
|
||||
}
|
||||
|
||||
/* configure the pins from the default mapping above */
|
||||
|
||||
for (i = 0; i < NUM_DFLT_PINS_SET; i++) {
|
||||
pinmux_pin_set(pmux, mux_config[i].pin_num, mux_config[i].mode);
|
||||
}
|
||||
|
||||
return DEV_OK;
|
||||
}
|
||||
|
||||
DEVICE_INIT(frdm_k64f_pmux, "", fsl_frdm_k64f_pin_init, NULL, NULL,
|
||||
SECONDARY, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
|
||||
#endif /* CONFIG_PINMUX */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue