From 7f772401267d620bee2b540863568babd76b1e06 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Fri, 28 May 2021 10:37:05 -0500 Subject: [PATCH] drivers: gpio: mcux_lpc: Convert driver to use devicetree port prop Move to using port property for a few cases in which we need to know which specific hardware port a device is for. This allows us to remove the PORT0/1 Kconfig options. This also fixes the issue that assumed pio0 would map to DT_INST(0) and pio1 would map to DT_INST(1) Fixes #35693 Signed-off-by: Kumar Gala --- boards/arm/lpcxpresso54114/Kconfig.defconfig | 10 ---------- boards/arm/lpcxpresso55s16/Kconfig.defconfig | 10 ---------- boards/arm/lpcxpresso55s28/Kconfig.defconfig | 10 ---------- boards/arm/lpcxpresso55s69/Kconfig.defconfig | 10 ---------- boards/arm/mimxrt685_evk/Kconfig.defconfig | 10 ---------- drivers/gpio/Kconfig.mcux_lpc | 18 +----------------- drivers/gpio/gpio_mcux_lpc.c | 19 ++++++++----------- 7 files changed, 9 insertions(+), 78 deletions(-) diff --git a/boards/arm/lpcxpresso54114/Kconfig.defconfig b/boards/arm/lpcxpresso54114/Kconfig.defconfig index dfee118608b..8621f98ea18 100644 --- a/boards/arm/lpcxpresso54114/Kconfig.defconfig +++ b/boards/arm/lpcxpresso54114/Kconfig.defconfig @@ -9,14 +9,4 @@ config BOARD default "lpcxpresso54114_m4" if BOARD_LPCXPRESSO54114_M4 default "lpcxpresso54114_m0" if BOARD_LPCXPRESSO54114_M0 -if GPIO_MCUX_LPC - -config GPIO_MCUX_LPC_PORT0 - default y - -config GPIO_MCUX_LPC_PORT1 - default y - -endif # GPIO_MCUX_LPC - endif # BOARD_LPCXPRESSO54114_M4 || BOARD_LPCXPRESSO54114_M0 diff --git a/boards/arm/lpcxpresso55s16/Kconfig.defconfig b/boards/arm/lpcxpresso55s16/Kconfig.defconfig index c7b457db2ca..49ed6830ed2 100644 --- a/boards/arm/lpcxpresso55s16/Kconfig.defconfig +++ b/boards/arm/lpcxpresso55s16/Kconfig.defconfig @@ -8,16 +8,6 @@ if BOARD_LPCXPRESSO55S16 config BOARD default "lpcxpresso55S16" -if GPIO_MCUX_LPC - -config GPIO_MCUX_LPC_PORT0 - default y - -config GPIO_MCUX_LPC_PORT1 - default y - -endif # GPIO_MCUX_LPC - config FXOS8700_DRDY_INT1 default y depends on FXOS8700_TRIGGER diff --git a/boards/arm/lpcxpresso55s28/Kconfig.defconfig b/boards/arm/lpcxpresso55s28/Kconfig.defconfig index e65c20347cb..a58c81dc2bc 100644 --- a/boards/arm/lpcxpresso55s28/Kconfig.defconfig +++ b/boards/arm/lpcxpresso55s28/Kconfig.defconfig @@ -8,16 +8,6 @@ if BOARD_LPCXPRESSO55S28 config BOARD default "lpcxpresso55S28" -if GPIO_MCUX_LPC - -config GPIO_MCUX_LPC_PORT0 - default y - -config GPIO_MCUX_LPC_PORT1 - default y - -endif # GPIO_MCUX_LPC - config FXOS8700_DRDY_INT1 default y depends on FXOS8700_TRIGGER diff --git a/boards/arm/lpcxpresso55s69/Kconfig.defconfig b/boards/arm/lpcxpresso55s69/Kconfig.defconfig index b197bde4b30..79ac387f6c8 100644 --- a/boards/arm/lpcxpresso55s69/Kconfig.defconfig +++ b/boards/arm/lpcxpresso55s69/Kconfig.defconfig @@ -9,16 +9,6 @@ config BOARD default "lpcxpresso55S69_cpu0" if BOARD_LPCXPRESSO55S69_CPU0 default "lpcxpresso55S69_cpu1" if BOARD_LPCXPRESSO55S69_CPU1 -if GPIO_MCUX_LPC - -config GPIO_MCUX_LPC_PORT0 - default y - -config GPIO_MCUX_LPC_PORT1 - default y - -endif # GPIO_MCUX_LPC - config FXOS8700_DRDY_INT1 default y depends on FXOS8700_TRIGGER diff --git a/boards/arm/mimxrt685_evk/Kconfig.defconfig b/boards/arm/mimxrt685_evk/Kconfig.defconfig index 7708c7a7168..6b2f51008d0 100644 --- a/boards/arm/mimxrt685_evk/Kconfig.defconfig +++ b/boards/arm/mimxrt685_evk/Kconfig.defconfig @@ -24,16 +24,6 @@ choice FLASH_MCUX_FLEXSPI_XIP_MEM_TARGET default FLASH_MCUX_FLEXSPI_XIP_MEM_SRAM endchoice -if GPIO_MCUX_LPC - -config GPIO_MCUX_LPC_PORT0 - default y - -config GPIO_MCUX_LPC_PORT1 - default y - -endif # GPIO_MCUX_LPC - config FXOS8700_DRDY_INT1 default y depends on FXOS8700_TRIGGER diff --git a/drivers/gpio/Kconfig.mcux_lpc b/drivers/gpio/Kconfig.mcux_lpc index 5490059ee47..2dbd6d0a413 100644 --- a/drivers/gpio/Kconfig.mcux_lpc +++ b/drivers/gpio/Kconfig.mcux_lpc @@ -3,24 +3,8 @@ # Copyright (c) 2017, NXP # SPDX-License-Identifier: Apache-2.0 -menuconfig GPIO_MCUX_LPC +config GPIO_MCUX_LPC bool "MCUX LPC GPIO driver" depends on HAS_MCUX help Enable the MCUX LPC pinmux driver. - -if GPIO_MCUX_LPC - -config GPIO_MCUX_LPC_PORT0 - bool "Port 0" - depends on $(dt_nodelabel_enabled,pio0) - help - Enable Port 0. - -config GPIO_MCUX_LPC_PORT1 - bool "Port 1" - depends on $(dt_nodelabel_enabled,pio1) - help - Enable Port 1. - -endif # GPIO_MCUX_LPC diff --git a/drivers/gpio/gpio_mcux_lpc.c b/drivers/gpio/gpio_mcux_lpc.c index aa8b0952c0a..1286a1558f4 100644 --- a/drivers/gpio/gpio_mcux_lpc.c +++ b/drivers/gpio/gpio_mcux_lpc.c @@ -25,9 +25,6 @@ #include #include -#define PORT0_IDX 0u -#define PORT1_IDX 1u - #define PIN_TO_INPUT_MUX_CONNECTION(port, pin) \ ((PINTSEL_PMUX_ID << PMUX_SHIFT) + (32 * port) + (pin)) @@ -359,7 +356,7 @@ static const struct gpio_driver_api gpio_mcux_lpc_driver_api = { static const clock_ip_name_t gpio_clock_names[] = GPIO_CLOCKS; -#ifdef CONFIG_GPIO_MCUX_LPC_PORT0 +#if DT_NODE_HAS_STATUS(DT_DRV_INST(0), okay) static int lpc_gpio_0_init(const struct device *dev); static const struct gpio_mcux_lpc_config gpio_mcux_lpc_port0_config = { @@ -373,8 +370,8 @@ static const struct gpio_mcux_lpc_config gpio_mcux_lpc_port0_config = { #else .pinmux_base = IOCON, #endif - .port_no = PORT0_IDX, - .clock_ip_name = gpio_clock_names[0], + .port_no = DT_INST_PROP(0, port), + .clock_ip_name = gpio_clock_names[DT_INST_PROP(0, port)], }; static struct gpio_mcux_lpc_data gpio_mcux_lpc_port0_data; @@ -431,9 +428,9 @@ static int lpc_gpio_0_init(const struct device *dev) return 0; } -#endif /* CONFIG_GPIO_MCUX_LPC_PORT0 */ +#endif -#ifdef CONFIG_GPIO_MCUX_LPC_PORT1 +#if DT_NODE_HAS_STATUS(DT_DRV_INST(1), okay) static int lpc_gpio_1_init(const struct device *dev); static const struct gpio_mcux_lpc_config gpio_mcux_lpc_port1_config = { @@ -447,8 +444,8 @@ static const struct gpio_mcux_lpc_config gpio_mcux_lpc_port1_config = { #else .pinmux_base = IOCON, #endif - .port_no = PORT1_IDX, - .clock_ip_name = gpio_clock_names[1], + .port_no = DT_INST_PROP(1, port), + .clock_ip_name = gpio_clock_names[DT_INST_PROP(1, port)], }; static struct gpio_mcux_lpc_data gpio_mcux_lpc_port1_data; @@ -505,4 +502,4 @@ static int lpc_gpio_1_init(const struct device *dev) return 0; } -#endif /* CONFIG_GPIO_MCUX_LPC_PORT1 */ +#endif