2016-11-23 15:09:33 -06:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Freescale Semiconductor, Inc.
|
|
|
|
*
|
2017-01-18 17:01:01 -08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-11-23 15:09:33 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <init.h>
|
2019-06-25 15:53:57 -04:00
|
|
|
#include <drivers/pinmux.h>
|
2016-12-18 16:19:27 -06:00
|
|
|
#include <fsl_port.h>
|
2016-11-23 15:09:33 -06:00
|
|
|
|
|
|
|
static int frdm_k64f_pinmux_init(struct device *dev)
|
|
|
|
{
|
|
|
|
ARG_UNUSED(dev);
|
|
|
|
|
2017-01-02 15:07:42 -06:00
|
|
|
#ifdef CONFIG_PINMUX_MCUX_PORTA
|
2016-12-18 16:19:27 -06:00
|
|
|
struct device *porta =
|
2017-01-02 15:07:42 -06:00
|
|
|
device_get_binding(CONFIG_PINMUX_MCUX_PORTA_NAME);
|
2016-12-18 16:19:27 -06:00
|
|
|
#endif
|
2017-01-02 15:07:42 -06:00
|
|
|
#ifdef CONFIG_PINMUX_MCUX_PORTB
|
2016-12-18 16:19:27 -06:00
|
|
|
struct device *portb =
|
2017-01-02 15:07:42 -06:00
|
|
|
device_get_binding(CONFIG_PINMUX_MCUX_PORTB_NAME);
|
2016-12-18 16:19:27 -06:00
|
|
|
#endif
|
2017-01-02 15:07:42 -06:00
|
|
|
#ifdef CONFIG_PINMUX_MCUX_PORTC
|
2016-12-18 16:19:27 -06:00
|
|
|
struct device *portc =
|
2017-01-02 15:07:42 -06:00
|
|
|
device_get_binding(CONFIG_PINMUX_MCUX_PORTC_NAME);
|
2016-12-18 16:19:27 -06:00
|
|
|
#endif
|
2017-01-02 15:07:42 -06:00
|
|
|
#ifdef CONFIG_PINMUX_MCUX_PORTD
|
2016-12-18 16:19:27 -06:00
|
|
|
struct device *portd =
|
2017-01-02 15:07:42 -06:00
|
|
|
device_get_binding(CONFIG_PINMUX_MCUX_PORTD_NAME);
|
2016-12-18 16:19:27 -06:00
|
|
|
#endif
|
2017-01-02 15:07:42 -06:00
|
|
|
#ifdef CONFIG_PINMUX_MCUX_PORTE
|
2016-12-18 16:19:27 -06:00
|
|
|
struct device *porte =
|
2017-01-02 15:07:42 -06:00
|
|
|
device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME);
|
2016-12-18 16:19:27 -06:00
|
|
|
#endif
|
2016-11-23 15:09:33 -06:00
|
|
|
|
2020-05-21 08:32:04 -05:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart0), okay) && CONFIG_SERIAL
|
2017-01-07 09:32:57 -06:00
|
|
|
/* UART0 RX, TX */
|
|
|
|
pinmux_pin_set(portb, 16, PORT_PCR_MUX(kPORT_MuxAlt3));
|
|
|
|
pinmux_pin_set(portb, 17, PORT_PCR_MUX(kPORT_MuxAlt3));
|
|
|
|
#endif
|
|
|
|
|
2020-05-21 08:32:04 -05:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart2), okay) && CONFIG_SERIAL
|
2018-08-01 12:04:00 -08:00
|
|
|
/* UART2 RX, TX */
|
|
|
|
pinmux_pin_set(portd, 0, PORT_PCR_MUX(kPORT_MuxAlt3));
|
|
|
|
pinmux_pin_set(portd, 1, PORT_PCR_MUX(kPORT_MuxAlt3));
|
|
|
|
pinmux_pin_set(portd, 2, PORT_PCR_MUX(kPORT_MuxAlt3));
|
|
|
|
pinmux_pin_set(portd, 3, PORT_PCR_MUX(kPORT_MuxAlt3));
|
|
|
|
#endif
|
|
|
|
|
2020-05-21 08:32:04 -05:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart3), okay) && CONFIG_SERIAL
|
2016-11-23 15:09:33 -06:00
|
|
|
/* UART3 RX, TX */
|
2016-12-18 16:19:27 -06:00
|
|
|
pinmux_pin_set(portc, 16, PORT_PCR_MUX(kPORT_MuxAlt3));
|
|
|
|
pinmux_pin_set(portc, 17, PORT_PCR_MUX(kPORT_MuxAlt3));
|
2016-11-23 15:09:33 -06:00
|
|
|
#endif
|
|
|
|
/* SW2 / FXOS8700 INT1 */
|
2016-12-18 16:19:27 -06:00
|
|
|
pinmux_pin_set(portc, 6, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
2016-11-23 15:09:33 -06:00
|
|
|
|
2016-12-14 15:45:29 -06:00
|
|
|
/* FXOS8700 INT2 */
|
|
|
|
pinmux_pin_set(portc, 13, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
|
|
|
|
2016-11-23 15:09:33 -06:00
|
|
|
/* SW3 */
|
2016-12-18 16:19:27 -06:00
|
|
|
pinmux_pin_set(porta, 4, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
2016-11-23 15:09:33 -06:00
|
|
|
|
|
|
|
/* Red, green, blue LEDs */
|
2016-12-18 16:19:27 -06:00
|
|
|
pinmux_pin_set(portb, 22, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
|
|
|
pinmux_pin_set(porte, 26, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
|
|
|
pinmux_pin_set(portb, 21, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
2016-11-23 15:09:33 -06:00
|
|
|
|
2018-08-01 12:05:00 -08:00
|
|
|
#ifdef CONFIG_MODEM_WNCM14A2A
|
|
|
|
/* WNC-M14A2A Modem POWER_ON */
|
|
|
|
pinmux_pin_set(portb, 9, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
|
|
|
/* WNC-M14A2A Shield PMOD_D1 */
|
|
|
|
pinmux_pin_set(portb, 10, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
|
|
|
/* WNC-M14A2A Shield PMOD_D2 */
|
|
|
|
pinmux_pin_set(portb, 11, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
|
|
|
/* WNC-M14A2A Modem WWAN_STATE */
|
|
|
|
pinmux_pin_set(portb, 23, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
|
|
|
/* WNC-M14A2A Modem WAKEUP_ENABLE */
|
|
|
|
pinmux_pin_set(portc, 2, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
|
|
|
/* WNC-M14A2A Modem HTS221_DRDY */
|
|
|
|
pinmux_pin_set(portc, 3, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
|
|
|
/* WNC-M14A2A Shield LEVEL_TRANSFORM_ENABLE */
|
|
|
|
pinmux_pin_set(portc, 4, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
|
|
|
/* WNC-M14A2A Modem RESET */
|
|
|
|
pinmux_pin_set(portc, 12, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
|
|
|
/* WNC-M14A2A Modem BOOT_MODE_SELECT */
|
|
|
|
pinmux_pin_set(portc, 17, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
|
|
|
#endif
|
|
|
|
|
2019-05-17 10:15:00 -07:00
|
|
|
#ifdef CONFIG_MODEM_UBLOX_SARA_R4
|
|
|
|
/* Modem RESET */
|
|
|
|
pinmux_pin_set(portc, 2, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
|
|
|
/* Modem POWER_ON */
|
|
|
|
pinmux_pin_set(porta, 2, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
|
|
|
#endif
|
|
|
|
|
2017-02-06 11:49:16 +01:00
|
|
|
#ifdef CONFIG_IEEE802154_MCR20A
|
2016-12-13 18:55:05 +01:00
|
|
|
/* FRDM-MCR20A Reset (D5) */
|
|
|
|
pinmux_pin_set(porta, 2, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
|
|
|
/* FRDM-MCR20A IRQ_B (D2) */
|
|
|
|
pinmux_pin_set(portb, 9, PORT_PCR_MUX(kPORT_MuxAsGpio));
|
|
|
|
#endif
|
|
|
|
|
2020-05-21 08:47:13 -05:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi0), okay) && CONFIG_SPI
|
2016-11-23 15:09:33 -06:00
|
|
|
/* SPI0 CS0, SCK, SOUT, SIN */
|
2016-12-18 16:19:27 -06:00
|
|
|
pinmux_pin_set(portd, 0, PORT_PCR_MUX(kPORT_MuxAlt2));
|
|
|
|
pinmux_pin_set(portd, 1, PORT_PCR_MUX(kPORT_MuxAlt2));
|
|
|
|
pinmux_pin_set(portd, 2, PORT_PCR_MUX(kPORT_MuxAlt2));
|
|
|
|
pinmux_pin_set(portd, 3, PORT_PCR_MUX(kPORT_MuxAlt2));
|
2016-11-23 15:09:33 -06:00
|
|
|
#endif
|
|
|
|
|
2020-05-21 08:52:08 -05:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c0), okay) && CONFIG_I2C
|
2016-11-23 15:09:33 -06:00
|
|
|
/* I2C0 SCL, SDA */
|
2016-12-18 16:19:27 -06:00
|
|
|
pinmux_pin_set(porte, 24, PORT_PCR_MUX(kPORT_MuxAlt5)
|
2016-11-23 15:09:33 -06:00
|
|
|
| PORT_PCR_ODE_MASK);
|
2016-12-18 16:19:27 -06:00
|
|
|
pinmux_pin_set(porte, 25, PORT_PCR_MUX(kPORT_MuxAlt5)
|
2016-11-23 15:09:33 -06:00
|
|
|
| PORT_PCR_ODE_MASK);
|
|
|
|
#endif
|
|
|
|
|
2020-05-21 09:02:02 -05:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(adc1), okay) && CONFIG_ADC
|
2017-06-07 07:13:55 -05:00
|
|
|
/* ADC1_SE14 */
|
|
|
|
pinmux_pin_set(portb, 10, PORT_PCR_MUX(kPORT_PinDisabledOrAnalog));
|
|
|
|
#endif
|
|
|
|
|
2020-05-21 09:06:58 -05:00
|
|
|
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm, okay) && CONFIG_PWM
|
2017-07-27 15:45:13 -05:00
|
|
|
pinmux_pin_set(portc, 8, PORT_PCR_MUX(kPORT_MuxAlt3));
|
|
|
|
pinmux_pin_set(portc, 9, PORT_PCR_MUX(kPORT_MuxAlt3));
|
|
|
|
#endif
|
|
|
|
|
2020-05-21 09:13:06 -05:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(enet), okay) && CONFIG_NET_L2_ETHERNET
|
2016-12-18 16:19:27 -06:00
|
|
|
pinmux_pin_set(porta, 5, PORT_PCR_MUX(kPORT_MuxAlt4));
|
|
|
|
pinmux_pin_set(porta, 12, PORT_PCR_MUX(kPORT_MuxAlt4));
|
|
|
|
pinmux_pin_set(porta, 13, PORT_PCR_MUX(kPORT_MuxAlt4));
|
|
|
|
pinmux_pin_set(porta, 14, PORT_PCR_MUX(kPORT_MuxAlt4));
|
|
|
|
pinmux_pin_set(porta, 15, PORT_PCR_MUX(kPORT_MuxAlt4));
|
|
|
|
pinmux_pin_set(porta, 16, PORT_PCR_MUX(kPORT_MuxAlt4));
|
|
|
|
pinmux_pin_set(porta, 17, PORT_PCR_MUX(kPORT_MuxAlt4));
|
|
|
|
pinmux_pin_set(porta, 28, PORT_PCR_MUX(kPORT_MuxAlt4));
|
2016-11-23 15:09:33 -06:00
|
|
|
|
2016-12-18 16:19:27 -06:00
|
|
|
pinmux_pin_set(portb, 0, PORT_PCR_MUX(kPORT_MuxAlt4)
|
2016-11-23 15:09:33 -06:00
|
|
|
| PORT_PCR_ODE_MASK | PORT_PCR_PE_MASK | PORT_PCR_PS_MASK);
|
|
|
|
|
2016-12-18 16:19:27 -06:00
|
|
|
pinmux_pin_set(portb, 1, PORT_PCR_MUX(kPORT_MuxAlt4));
|
2016-11-23 15:09:33 -06:00
|
|
|
|
2016-12-18 16:19:27 -06:00
|
|
|
pinmux_pin_set(portc, 16, PORT_PCR_MUX(kPORT_MuxAlt4));
|
|
|
|
pinmux_pin_set(portc, 17, PORT_PCR_MUX(kPORT_MuxAlt4));
|
|
|
|
pinmux_pin_set(portc, 18, PORT_PCR_MUX(kPORT_MuxAlt4));
|
|
|
|
pinmux_pin_set(portc, 19, PORT_PCR_MUX(kPORT_MuxAlt4));
|
2016-11-23 15:09:33 -06:00
|
|
|
#endif
|
|
|
|
|
2020-05-21 09:15:36 -05:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(flexcan0), okay) && CONFIG_CAN
|
2019-06-25 18:48:27 +02:00
|
|
|
/* FlexCAN0 RX, TX */
|
|
|
|
pinmux_pin_set(portb, 18, PORT_PCR_MUX(kPORT_MuxAlt2));
|
2019-08-16 09:40:01 +02:00
|
|
|
pinmux_pin_set(portb, 19, PORT_PCR_MUX(kPORT_MuxAlt2) |
|
|
|
|
PORT_PCR_PE_MASK | PORT_PCR_PS_MASK);
|
2019-06-25 18:48:27 +02:00
|
|
|
#endif
|
|
|
|
|
2016-11-23 15:09:33 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-12-18 16:19:27 -06:00
|
|
|
SYS_INIT(frdm_k64f_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);
|