diff --git a/boards/arm/frdm_k64f/pinmux.c b/boards/arm/frdm_k64f/pinmux.c index 110bdb210e9..2dbc9edaaab 100644 --- a/boards/arm/frdm_k64f/pinmux.c +++ b/boards/arm/frdm_k64f/pinmux.c @@ -122,7 +122,7 @@ static int frdm_k64f_pinmux_init(struct device *dev) pinmux_pin_set(portb, 10, PORT_PCR_MUX(kPORT_PinDisabledOrAnalog)); #endif -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm, okay) pinmux_pin_set(portc, 8, PORT_PCR_MUX(kPORT_MuxAlt3)); pinmux_pin_set(portc, 9, PORT_PCR_MUX(kPORT_MuxAlt3)); #endif diff --git a/boards/arm/frdm_k82f/pinmux.c b/boards/arm/frdm_k82f/pinmux.c index 4bb9d9d2e32..d2f120f8ebb 100644 --- a/boards/arm/frdm_k82f/pinmux.c +++ b/boards/arm/frdm_k82f/pinmux.c @@ -33,7 +33,7 @@ static int frdm_k82f_pinmux_init(struct device *dev) device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); #endif -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm, okay) /* Red, green, blue LEDs as PWM channels */ pinmux_pin_set(portc, 8, PORT_PCR_MUX(kPORT_MuxAlt3)); pinmux_pin_set(portc, 9, PORT_PCR_MUX(kPORT_MuxAlt3)); diff --git a/boards/arm/hexiwear_k64/pinmux.c b/boards/arm/hexiwear_k64/pinmux.c index f2d691ca22c..9fceb050158 100644 --- a/boards/arm/hexiwear_k64/pinmux.c +++ b/boards/arm/hexiwear_k64/pinmux.c @@ -30,7 +30,7 @@ static int hexiwear_k64_pinmux_init(struct device *dev) device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); #endif -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm, okay) /* Red, green, blue LEDs as PWM channels */ pinmux_pin_set(portc, 8, PORT_PCR_MUX(kPORT_MuxAlt3)); pinmux_pin_set(portc, 9, PORT_PCR_MUX(kPORT_MuxAlt3)); diff --git a/boards/arm/lpcxpresso54114/pinmux.c b/boards/arm/lpcxpresso54114/pinmux.c index dd7d3c276a2..80617bbbb5f 100644 --- a/boards/arm/lpcxpresso54114/pinmux.c +++ b/boards/arm/lpcxpresso54114/pinmux.c @@ -23,7 +23,7 @@ static int lpcxpresso_54114_pinmux_init(struct device *dev) device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT1_NAME); #endif -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm0), nxp_lpc_usart) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm0), nxp_lpc_usart, okay) /* USART0 RX, TX */ const u32_t port0_pin0_config = ( IOCON_PIO_FUNC1 | @@ -107,7 +107,7 @@ static int lpcxpresso_54114_pinmux_init(struct device *dev) pinmux_pin_set(port1, 10, port1_pin10_config); #endif -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm4), nxp_lpc_i2c) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm4), nxp_lpc_i2c, okay) /* PORT0 PIN25 is configured as FC4_RTS_SCL_SSEL1 */ pinmux_pin_set(port0, 25, IOCON_PIO_FUNC1 | IOCON_PIO_I2CSLEW_I2C | @@ -127,7 +127,7 @@ static int lpcxpresso_54114_pinmux_init(struct device *dev) IOCON_PIO_I2CFILTER_EN); #endif -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm5), nxp_lpc_spi) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm5), nxp_lpc_spi, okay) /* PORT0 PIN18 is configured as FC5_TXD_SCL_MISO */ pinmux_pin_set(port0, 18, IOCON_PIO_FUNC1 | IOCON_PIO_MODE_PULLUP | diff --git a/boards/arm/lpcxpresso55s16/pinmux.c b/boards/arm/lpcxpresso55s16/pinmux.c index 78b439c6149..77e390460d1 100644 --- a/boards/arm/lpcxpresso55s16/pinmux.c +++ b/boards/arm/lpcxpresso55s16/pinmux.c @@ -95,7 +95,7 @@ static int lpcxpresso_55s16_pinmux_init(struct device *dev) pinmux_pin_set(port1, DT_GPIO_PIN(DT_ALIAS(led2), gpios), led2_config); #endif -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm0), nxp_lpc_usart) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm0), nxp_lpc_usart, okay) /* USART0 RX, TX */ const u32_t port0_pin29_config = ( IOCON_PIO_FUNC1 | @@ -117,7 +117,7 @@ static int lpcxpresso_55s16_pinmux_init(struct device *dev) pinmux_pin_set(port0, 30, port0_pin30_config); #endif -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm4), nxp_lpc_i2c) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm4), nxp_lpc_i2c, okay) /* PORT1 PIN20 is configured as FC4_TXD_SCL_MISO_WS */ pinmux_pin_set(port1, 20, IOCON_PIO_FUNC5 | IOCON_PIO_MODE_INACT | diff --git a/boards/arm/lpcxpresso55s69/pinmux.c b/boards/arm/lpcxpresso55s69/pinmux.c index 387a4e952b7..4b87bb21df3 100644 --- a/boards/arm/lpcxpresso55s69/pinmux.c +++ b/boards/arm/lpcxpresso55s69/pinmux.c @@ -23,7 +23,7 @@ static int lpcxpresso_55s69_pinmux_init(struct device *dev) device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT1_NAME); #endif -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm0), nxp_lpc_usart) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm0), nxp_lpc_usart, okay) /* USART0 RX, TX */ const u32_t port0_pin29_config = ( IOCON_PIO_FUNC1 | @@ -88,7 +88,7 @@ static int lpcxpresso_55s69_pinmux_init(struct device *dev) pinmux_pin_set(port1, DT_GPIO_PIN(DT_ALIAS(sw2), gpios), sw2_config); #endif -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm4), nxp_lpc_i2c) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm4), nxp_lpc_i2c, okay) /* PORT1 PIN20 is configured as FC4_TXD_SCL_MISO_WS */ pinmux_pin_set(port1, 20, IOCON_PIO_FUNC5 | IOCON_PIO_MODE_INACT | diff --git a/boards/arm/twr_ke18f/pinmux.c b/boards/arm/twr_ke18f/pinmux.c index b9f15648d37..9de182225f2 100644 --- a/boards/arm/twr_ke18f/pinmux.c +++ b/boards/arm/twr_ke18f/pinmux.c @@ -34,7 +34,7 @@ static int twr_ke18f_pinmux_init(struct device *dev) device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); #endif -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(ftm0), nxp_kinetis_ftm_pwm) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(ftm0), nxp_kinetis_ftm_pwm, okay) /* Tri-color LED as PWM */ pinmux_pin_set(portb, 5, PORT_PCR_MUX(kPORT_MuxAlt2)); pinmux_pin_set(portd, 15, PORT_PCR_MUX(kPORT_MuxAlt2)); @@ -46,7 +46,7 @@ static int twr_ke18f_pinmux_init(struct device *dev) pinmux_pin_set(portd, 16, PORT_PCR_MUX(kPORT_MuxAsGpio)); #endif -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm, okay) /* User LEDs as PWM */ pinmux_pin_set(portc, 10, PORT_PCR_MUX(kPORT_MuxAlt2)); pinmux_pin_set(portc, 11, PORT_PCR_MUX(kPORT_MuxAlt2)); diff --git a/drivers/can/can_stm32.c b/drivers/can/can_stm32.c index cc2d3a48821..efda958f8db 100644 --- a/drivers/can/can_stm32.c +++ b/drivers/can/can_stm32.c @@ -20,8 +20,8 @@ LOG_MODULE_DECLARE(can_driver, CONFIG_CAN_LOG_LEVEL); #define CAN_INIT_TIMEOUT (10 * sys_clock_hw_cycles_per_sec() / MSEC_PER_SEC) -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(can1), st_stm32_can) && \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(can2), st_stm32_can) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(can1), st_stm32_can, okay) && \ + DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(can2), st_stm32_can, okay) #error Simultaneous use of CAN_1 and CAN_2 not supported yet #endif @@ -1045,7 +1045,7 @@ static const struct can_driver_api can_api_funcs = { .register_state_change_isr = can_stm32_register_state_change_isr }; -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(can1), st_stm32_can) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(can1), st_stm32_can, okay) static void config_can_1_irq(CAN_TypeDef *can); @@ -1134,7 +1134,7 @@ NET_DEVICE_INIT(socket_can_stm32_1, SOCKET_CAN_NAME_1, socket_can_init_1, #endif /* DT_HAS_NODE_STATUS_OKAY(DT_NODELABEL(can1)) */ -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(can2), st_stm32_can) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(can2), st_stm32_can, okay) static void config_can_2_irq(CAN_TypeDef *can); diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c index 4d36febe719..8e8dd28b9ec 100644 --- a/drivers/serial/uart_stm32.c +++ b/drivers/serial/uart_stm32.c @@ -29,8 +29,8 @@ #include LOG_MODULE_REGISTER(uart_stm32); -#define HAS_LPUART_1 (DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(lpuart1), \ - st_stm32_lpuart)) +#define HAS_LPUART_1 (DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(lpuart1), \ + st_stm32_lpuart, okay)) /* convenience defines */ #define DEV_CFG(dev) \ diff --git a/include/arch/riscv/common/linker.ld b/include/arch/riscv/common/linker.ld index 613ebfd2509..c3955d1ddfc 100644 --- a/include/arch/riscv/common/linker.ld +++ b/include/arch/riscv/common/linker.ld @@ -34,10 +34,10 @@ MEMORY { #ifdef CONFIG_XIP -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_CHOSEN(zephyr_flash), soc_nv_flash) +#if DT_NODE_HAS_COMPAT_STATUS(DT_CHOSEN(zephyr_flash), soc_nv_flash, okay) #define ROM_BASE DT_REG_ADDR(DT_CHOSEN(zephyr_flash)) #define ROM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_flash)) -#elif DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_CHOSEN(zephyr_flash), jedec_spi_nor) +#elif DT_NODE_HAS_COMPAT_STATUS(DT_CHOSEN(zephyr_flash), jedec_spi_nor, okay) /* For jedec,spi-nor we expect the spi controller to memory map the flash * and for that mapping to be the second register property of the spi * controller. diff --git a/include/devicetree.h b/include/devicetree.h index 185959fe09b..23ed25b327b 100644 --- a/include/devicetree.h +++ b/include/devicetree.h @@ -995,8 +995,8 @@ * * Example usages which evaluate to 1: * - * DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(n), vnd_specific_device) - * DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(n), generic_device) + * DT_NODE_HAS_COMPAT(DT_NODELABEL(n), vnd_specific_device) + * DT_NODE_HAS_COMPAT(DT_NODELABEL(n), generic_device) * * This macro only uses the value of the compatible property. Whether * or not a particular compatible has a matching binding has no effect @@ -1007,9 +1007,12 @@ * @return 1 if the node's compatible property contains compat, * 0 otherwise. */ -#define DT_NODE_HAS_COMPAT_STATUS_OKAY(node_id, compat) \ +#define DT_NODE_HAS_COMPAT(node_id, compat) \ IS_ENABLED(DT_CAT(node_id, _COMPAT_MATCHES_##compat)) +#define DT_NODE_HAS_COMPAT_STATUS(node_id, compat, status) \ + DT_NODE_HAS_COMPAT(node_id, compat) && DT_NODE_HAS_STATUS(node_id, status) + /** * @brief Does a devicetree node have a property? * diff --git a/soc/arm/atmel_sam0/common/atmel_sam0_dt.h b/soc/arm/atmel_sam0/common/atmel_sam0_dt.h index 293dfcbc1b2..9d9567b0154 100644 --- a/soc/arm/atmel_sam0/common/atmel_sam0_dt.h +++ b/soc/arm/atmel_sam0/common/atmel_sam0_dt.h @@ -37,7 +37,7 @@ /* Use to check if a sercom 'n' is enabled for a given 'compat' */ #define ATMEL_SAM0_DT_SERCOM_CHECK(n, compat) \ - DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(sercom##n), compat) + DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(sercom##n), compat, okay) /* Common macro for use to set HCLK_FREQ_HZ */ #define ATMEL_SAM0_DT_CPU_CLK_FREQ_HZ \ diff --git a/soc/arm/nordic_nrf/validate_base_addresses.c b/soc/arm/nordic_nrf/validate_base_addresses.c index 839a7211cfb..305333070d3 100644 --- a/soc/arm/nordic_nrf/validate_base_addresses.c +++ b/soc/arm/nordic_nrf/validate_base_addresses.c @@ -58,7 +58,7 @@ * @param addr_if_no_match MDK address to return otherwise */ #define NODE_ADDRESS(lbl, compat, addr_if_match, addr_if_no_match) \ - COND_CODE_1(DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(lbl), compat), \ + COND_CODE_1(DT_NODE_HAS_COMPAT(DT_NODELABEL(lbl), compat), \ (addr_if_match), (addr_if_no_match)) #define CHECK_SPI_REG(lbl, num) \ diff --git a/soc/arm/nxp_lpc/lpc54xxx/soc.c b/soc/arm/nxp_lpc/lpc54xxx/soc.c index ed64438fd50..eea67f9fe68 100644 --- a/soc/arm/nxp_lpc/lpc54xxx/soc.c +++ b/soc/arm/nxp_lpc/lpc54xxx/soc.c @@ -67,7 +67,7 @@ static ALWAYS_INLINE void clock_init(void) /* Attach 12 MHz clock to FLEXCOMM0 */ CLOCK_AttachClk(kFRO12M_to_FLEXCOMM0); -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm4), nxp_lpc_i2c) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm4), nxp_lpc_i2c, okay) /* attach 12 MHz clock to FLEXCOMM4 */ CLOCK_AttachClk(kFRO12M_to_FLEXCOMM4); @@ -75,7 +75,7 @@ static ALWAYS_INLINE void clock_init(void) RESET_PeripheralReset(kFC4_RST_SHIFT_RSTn); #endif -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm5), nxp_lpc_spi) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm5), nxp_lpc_spi, okay) /* Attach 12 MHz clock to FLEXCOMM5 */ CLOCK_AttachClk(kFRO_HF_to_FLEXCOMM5); diff --git a/soc/arm/nxp_lpc/lpc55xxx/soc.c b/soc/arm/nxp_lpc/lpc55xxx/soc.c index 86b23b44d66..86431ef4fd8 100644 --- a/soc/arm/nxp_lpc/lpc55xxx/soc.c +++ b/soc/arm/nxp_lpc/lpc55xxx/soc.c @@ -61,7 +61,7 @@ static ALWAYS_INLINE void clock_init(void) /* Enables the clock for the I/O controller.: Enable Clock. */ CLOCK_EnableClock(kCLOCK_Iocon); -#if DT_NODE_HAS_COMPAT_STATUS_OKAY(DT_NODELABEL(flexcomm4), nxp_lpc_i2c) +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm4), nxp_lpc_i2c, okay) /* attach 12 MHz clock to FLEXCOMM4 */ CLOCK_AttachClk(kFRO12M_to_FLEXCOMM4); diff --git a/tests/lib/devicetree/app.overlay b/tests/lib/devicetree/app.overlay index a1d8d078672..6eae85f5c54 100644 --- a/tests/lib/devicetree/app.overlay +++ b/tests/lib/devicetree/app.overlay @@ -25,7 +25,7 @@ interrupt-parent = <&test_intc>; test_arrays: array-holder { - /* vnd,undefined-compat is for DT_NODE_HAS_COMPAT_STATUS_OKAY() */ + /* vnd,undefined-compat is for DT_NODE_HAS_COMPAT_STATUS(..,okay) */ compatible = "vnd,array-holder", "vnd,undefined-compat"; a = <1000 2000 3000>; b = [aa bb cc dd]; diff --git a/tests/lib/devicetree/src/main.c b/tests/lib/devicetree/src/main.c index 21106ea2daa..9761544a3b3 100644 --- a/tests/lib/devicetree/src/main.c +++ b/tests/lib/devicetree/src/main.c @@ -181,7 +181,7 @@ static void test_has_nodelabel(void) "TEST_NODELABEL_ALLCAPS"); } -#define TA_HAS_COMPAT(compat) DT_NODE_HAS_COMPAT_STATUS_OKAY(TEST_ARRAYS, compat) +#define TA_HAS_COMPAT(compat) DT_NODE_HAS_COMPAT(TEST_ARRAYS, compat) static void test_has_compat(void) {