drivers: pinmux: mcux_lpc: Convert to using devicetree
Convert driver and users of pinmux on mcux lpc platforms to getting basic port info from devicetree (register address, label) Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
686968b16a
commit
263ac3e9e5
|
@ -9,16 +9,6 @@ config BOARD
|
|||
default "lpcxpresso54114_m4" if BOARD_LPCXPRESSO54114_M4
|
||||
default "lpcxpresso54114_m0" if BOARD_LPCXPRESSO54114_M0
|
||||
|
||||
if PINMUX_MCUX_LPC
|
||||
|
||||
config PINMUX_MCUX_LPC_PORT0
|
||||
default y
|
||||
|
||||
config PINMUX_MCUX_LPC_PORT1
|
||||
default y
|
||||
|
||||
endif # PINMUX_MCUX_LPC
|
||||
|
||||
if GPIO_MCUX_LPC
|
||||
|
||||
config GPIO_MCUX_LPC_PORT0
|
||||
|
|
|
@ -13,14 +13,16 @@ static int lpcxpresso_54114_pinmux_init(const struct device *dev)
|
|||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
#ifdef CONFIG_PINMUX_MCUX_LPC_PORT0
|
||||
const struct device *port0 =
|
||||
device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT0_NAME);
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(pio0), okay)
|
||||
const struct device *port0 = DEVICE_DT_GET(DT_NODELABEL(pio0));
|
||||
|
||||
__ASSERT_NO_MSG(device_is_ready(port0));
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PINMUX_MCUX_LPC_PORT1
|
||||
const struct device *port1 =
|
||||
device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT1_NAME);
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(pio1), okay)
|
||||
const struct device *port1 = DEVICE_DT_GET(DT_NODELABEL(pio1));
|
||||
|
||||
__ASSERT_NO_MSG(device_is_ready(port1));
|
||||
#endif
|
||||
|
||||
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm0), nxp_lpc_usart, okay) && CONFIG_SERIAL
|
||||
|
|
|
@ -8,16 +8,6 @@ if BOARD_LPCXPRESSO55S16
|
|||
config BOARD
|
||||
default "lpcxpresso55S16"
|
||||
|
||||
if PINMUX_MCUX_LPC
|
||||
|
||||
config PINMUX_MCUX_LPC_PORT0
|
||||
default y
|
||||
|
||||
config PINMUX_MCUX_LPC_PORT1
|
||||
default y
|
||||
|
||||
endif # PINMUX_MCUX_LPC
|
||||
|
||||
if GPIO_MCUX_LPC
|
||||
|
||||
config GPIO_MCUX_LPC_PORT0
|
||||
|
|
|
@ -13,14 +13,16 @@ static int lpcxpresso_55s16_pinmux_init(const struct device *dev)
|
|||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
#ifdef CONFIG_PINMUX_MCUX_LPC_PORT0
|
||||
__unused const struct device *port0 =
|
||||
device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT0_NAME);
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(pio0), okay)
|
||||
const struct device *port0 = DEVICE_DT_GET(DT_NODELABEL(pio0));
|
||||
|
||||
__ASSERT_NO_MSG(device_is_ready(port0));
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PINMUX_MCUX_LPC_PORT1
|
||||
__unused const struct device *port1 =
|
||||
device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT1_NAME);
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(pio1), okay)
|
||||
const struct device *port1 = DEVICE_DT_GET(DT_NODELABEL(pio1));
|
||||
|
||||
__ASSERT_NO_MSG(device_is_ready(port1));
|
||||
#endif
|
||||
|
||||
#if DT_PHA_HAS_CELL(DT_ALIAS(sw0), gpios, pin)
|
||||
|
|
|
@ -8,16 +8,6 @@ if BOARD_LPCXPRESSO55S28
|
|||
config BOARD
|
||||
default "lpcxpresso55S28"
|
||||
|
||||
if PINMUX_MCUX_LPC
|
||||
|
||||
config PINMUX_MCUX_LPC_PORT0
|
||||
default y
|
||||
|
||||
config PINMUX_MCUX_LPC_PORT1
|
||||
default y
|
||||
|
||||
endif # PINMUX_MCUX_LPC
|
||||
|
||||
if GPIO_MCUX_LPC
|
||||
|
||||
config GPIO_MCUX_LPC_PORT0
|
||||
|
|
|
@ -13,14 +13,16 @@ static int lpcxpresso_55s28_pinmux_init(const struct device *dev)
|
|||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
#ifdef CONFIG_PINMUX_MCUX_LPC_PORT0
|
||||
__unused const struct device *port0 =
|
||||
device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT0_NAME);
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(pio0), okay)
|
||||
const struct device *port0 = DEVICE_DT_GET(DT_NODELABEL(pio0));
|
||||
|
||||
__ASSERT_NO_MSG(device_is_ready(port0));
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PINMUX_MCUX_LPC_PORT1
|
||||
__unused const struct device *port1 =
|
||||
device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT1_NAME);
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(pio1), okay)
|
||||
const struct device *port1 = DEVICE_DT_GET(DT_NODELABEL(pio1));
|
||||
|
||||
__ASSERT_NO_MSG(device_is_ready(port1));
|
||||
#endif
|
||||
|
||||
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm0), nxp_lpc_usart, okay) && CONFIG_SERIAL
|
||||
|
|
|
@ -9,16 +9,6 @@ config BOARD
|
|||
default "lpcxpresso55S69_cpu0" if BOARD_LPCXPRESSO55S69_CPU0
|
||||
default "lpcxpresso55S69_cpu1" if BOARD_LPCXPRESSO55S69_CPU1
|
||||
|
||||
if PINMUX_MCUX_LPC
|
||||
|
||||
config PINMUX_MCUX_LPC_PORT0
|
||||
default y
|
||||
|
||||
config PINMUX_MCUX_LPC_PORT1
|
||||
default y
|
||||
|
||||
endif # PINMUX_MCUX_LPC
|
||||
|
||||
if GPIO_MCUX_LPC
|
||||
|
||||
config GPIO_MCUX_LPC_PORT0
|
||||
|
|
|
@ -15,14 +15,16 @@ static int lpcxpresso_55s69_pinmux_init(const struct device *dev)
|
|||
|
||||
#ifdef CONFIG_BOARD_LPCXPRESSO55S69_CPU0
|
||||
/* Only CPU0 configures GPIO port inputs. */
|
||||
#ifdef CONFIG_PINMUX_MCUX_LPC_PORT0
|
||||
const struct device *port0 =
|
||||
device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT0_NAME);
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(pio0), okay)
|
||||
const struct device *port0 = DEVICE_DT_GET(DT_NODELABEL(pio0));
|
||||
|
||||
__ASSERT_NO_MSG(device_is_ready(port0));
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PINMUX_MCUX_LPC_PORT1
|
||||
const struct device *port1 =
|
||||
device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT1_NAME);
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(pio1), okay)
|
||||
const struct device *port1 = DEVICE_DT_GET(DT_NODELABEL(pio1));
|
||||
|
||||
__ASSERT_NO_MSG(device_is_ready(port1));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -14,16 +14,6 @@ config XTAL_SYS_CLK_HZ
|
|||
config SYSOSC_SETTLING_US
|
||||
default 260
|
||||
|
||||
if PINMUX_MCUX_LPC
|
||||
|
||||
config PINMUX_MCUX_LPC_PORT0
|
||||
default y
|
||||
|
||||
config PINMUX_MCUX_LPC_PORT1
|
||||
default y
|
||||
|
||||
endif # PINMUX_MCUX_LPC
|
||||
|
||||
if GPIO_MCUX_LPC
|
||||
|
||||
config GPIO_MCUX_LPC_PORT0
|
||||
|
|
|
@ -13,7 +13,6 @@ CONFIG_SERIAL=y
|
|||
CONFIG_UART_INTERRUPT_DRIVEN=y
|
||||
CONFIG_CORTEX_M_SYSTICK=y
|
||||
CONFIG_GPIO=y
|
||||
CONFIG_PINMUX=y
|
||||
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=250105263
|
||||
# Enable TrustZone-M
|
||||
CONFIG_TRUSTED_EXECUTION_SECURE=y
|
||||
|
|
|
@ -281,4 +281,5 @@ static int mimxrt685_evk_pinmux_init(const struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
SYS_INIT(mimxrt685_evk_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);
|
||||
/* priority set to CONFIG_PINMUX_INIT_PRIORITY value */
|
||||
SYS_INIT(mimxrt685_evk_pinmux_init, PRE_KERNEL_1, 45);
|
||||
|
|
|
@ -13,13 +13,13 @@ if GPIO_MCUX_LPC
|
|||
|
||||
config GPIO_MCUX_LPC_PORT0
|
||||
bool "Port 0"
|
||||
depends on PINMUX_MCUX_LPC_PORT0
|
||||
depends on $(dt_nodelabel_enabled,pio0)
|
||||
help
|
||||
Enable Port 0.
|
||||
|
||||
config GPIO_MCUX_LPC_PORT1
|
||||
bool "Port 1"
|
||||
depends on PINMUX_MCUX_LPC_PORT1
|
||||
depends on $(dt_nodelabel_enabled,pio1)
|
||||
help
|
||||
Enable Port 1.
|
||||
|
||||
|
|
|
@ -3,32 +3,8 @@
|
|||
# Copyright (c) 2017, NXP
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
menuconfig PINMUX_MCUX_LPC
|
||||
config PINMUX_MCUX_LPC
|
||||
bool "MCUX LPC pinmux driver"
|
||||
depends on HAS_MCUX
|
||||
help
|
||||
Enable the MCUX LPC pinmux driver.
|
||||
|
||||
if PINMUX_MCUX_LPC
|
||||
|
||||
config PINMUX_MCUX_LPC_PORT0
|
||||
bool "Port 0"
|
||||
help
|
||||
Enable Port 0.
|
||||
|
||||
config PINMUX_MCUX_LPC_PORT0_NAME
|
||||
string "Pinmux Port 0 driver name"
|
||||
depends on PINMUX_MCUX_LPC_PORT0
|
||||
default "port0"
|
||||
|
||||
config PINMUX_MCUX_LPC_PORT1
|
||||
bool "Port 1"
|
||||
help
|
||||
Enable Port 1.
|
||||
|
||||
config PINMUX_MCUX_LPC_PORT1_NAME
|
||||
string "Pinmux Port 1 driver name"
|
||||
depends on PINMUX_MCUX_LPC_PORT1
|
||||
default "port1"
|
||||
|
||||
endif # PINMUX_MCUX_LPC
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT nxp_lpc_iocon_pio
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <device.h>
|
||||
|
@ -12,31 +14,18 @@
|
|||
#include <fsl_clock.h>
|
||||
#include <fsl_device_registers.h>
|
||||
|
||||
#define PORT0_IDX 0u
|
||||
#define PORT1_IDX 1u
|
||||
|
||||
struct pinmux_mcux_lpc_config {
|
||||
clock_ip_name_t clock_ip_name;
|
||||
#ifdef IOPCTL
|
||||
IOPCTL_Type *base;
|
||||
#else
|
||||
IOCON_Type *base;
|
||||
#endif
|
||||
uint32_t port_no;
|
||||
volatile uint32_t *base;
|
||||
};
|
||||
|
||||
static int pinmux_mcux_lpc_set(const struct device *dev, uint32_t pin,
|
||||
uint32_t func)
|
||||
{
|
||||
const struct pinmux_mcux_lpc_config *config = dev->config;
|
||||
#ifdef IOPCTL
|
||||
IOPCTL_Type *base = config->base;
|
||||
#else
|
||||
IOCON_Type *base = config->base;
|
||||
#endif
|
||||
uint32_t port = config->port_no;
|
||||
volatile uint32_t *base = config->base;
|
||||
|
||||
base->PIO[port][pin] = func;
|
||||
base[pin] = func;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -45,14 +34,9 @@ static int pinmux_mcux_lpc_get(const struct device *dev, uint32_t pin,
|
|||
uint32_t *func)
|
||||
{
|
||||
const struct pinmux_mcux_lpc_config *config = dev->config;
|
||||
#ifdef IOPCTL
|
||||
IOPCTL_Type *base = config->base;
|
||||
#else
|
||||
IOCON_Type *base = config->base;
|
||||
#endif
|
||||
uint32_t port = config->port_no;
|
||||
volatile uint32_t *base = config->base;
|
||||
|
||||
*func = base->PIO[port][pin];
|
||||
*func = base[pin];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -87,38 +71,25 @@ static const struct pinmux_driver_api pinmux_mcux_driver_api = {
|
|||
.input = pinmux_mcux_lpc_input,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_PINMUX_MCUX_LPC_PORT0
|
||||
static const struct pinmux_mcux_lpc_config pinmux_mcux_lpc_port0_config = {
|
||||
#ifdef IOPCTL
|
||||
.base = IOPCTL,
|
||||
#define LPC_CLOCK_IP_NAME kCLOCK_IpInvalid
|
||||
#else
|
||||
.base = IOCON,
|
||||
.clock_ip_name = kCLOCK_Iocon,
|
||||
#define LPC_CLOCK_IP_NAME kCLOCK_Iocon
|
||||
#endif
|
||||
.port_no = PORT0_IDX,
|
||||
};
|
||||
|
||||
DEVICE_DEFINE(pinmux_port0, CONFIG_PINMUX_MCUX_LPC_PORT0_NAME,
|
||||
&pinmux_mcux_lpc_init, device_pm_control_nop,
|
||||
NULL, &pinmux_mcux_lpc_port0_config,
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
|
||||
&pinmux_mcux_driver_api);
|
||||
#endif /* CONFIG_PINMUX_MCUX_LPC_PORT0 */
|
||||
#define PINMUX_LPC_INIT(n) \
|
||||
static const struct pinmux_mcux_lpc_config \
|
||||
pinmux_mcux_lpc_port##n##_cfg = { \
|
||||
.base = (uint32_t *)DT_INST_REG_ADDR(n), \
|
||||
.clock_ip_name = LPC_CLOCK_IP_NAME, \
|
||||
}; \
|
||||
\
|
||||
DEVICE_DT_INST_DEFINE(n, \
|
||||
&pinmux_mcux_lpc_init, \
|
||||
device_pm_control_nop, \
|
||||
NULL, &pinmux_mcux_lpc_port##n##_cfg, \
|
||||
PRE_KERNEL_1, \
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \
|
||||
&pinmux_mcux_driver_api);
|
||||
|
||||
#ifdef CONFIG_PINMUX_MCUX_LPC_PORT1
|
||||
static const struct pinmux_mcux_lpc_config pinmux_mcux_lpc_port1_config = {
|
||||
#ifdef IOPCTL
|
||||
.base = IOPCTL,
|
||||
#else
|
||||
.base = IOCON,
|
||||
.clock_ip_name = kCLOCK_Iocon,
|
||||
#endif
|
||||
.port_no = PORT1_IDX,
|
||||
};
|
||||
|
||||
DEVICE_DEFINE(pinmux_port1, CONFIG_PINMUX_MCUX_LPC_PORT1_NAME,
|
||||
&pinmux_mcux_lpc_init, device_pm_control_nop,
|
||||
NULL, &pinmux_mcux_lpc_port1_config,
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
|
||||
&pinmux_mcux_driver_api);
|
||||
#endif /* CONFIG_PINMUX_MCUX_LPC_PORT1 */
|
||||
DT_INST_FOREACH_STATUS_OKAY(PINMUX_LPC_INIT)
|
||||
|
|
|
@ -98,8 +98,7 @@ static void board_setup(void)
|
|||
IOMUXC_SW_PAD_CTL_PAD_DSE(6));
|
||||
#elif defined(CONFIG_SOC_FAMILY_LPC)
|
||||
/* Assumes ARDUINO pins are mapped on PORT0 on all boards*/
|
||||
const struct device *port0 =
|
||||
device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT0_NAME);
|
||||
const struct device *port0 = DEVICE_DT_GET(DT_NODELABEL(pio0));
|
||||
const uint32_t pin_config = (
|
||||
IOCON_PIO_FUNC0 |
|
||||
IOCON_PIO_INV_DI |
|
||||
|
|
Loading…
Reference in a new issue