Lines Matching refs:idx
25 #define GET_GECKO_USART_CLOCK(idx) \ argument
26 .clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(idx)), \
27 .clock_cfg = SILABS_DT_INST_CLOCK_CFG(idx),
543 #define GECKO_UART_IRQ_HANDLER_DECL(idx) \ argument
544 static void uart_gecko_config_func_##idx(const struct device *dev)
545 #define GECKO_UART_IRQ_HANDLER_FUNC(idx) \ argument
546 .irq_config_func = uart_gecko_config_func_##idx,
547 #define GECKO_UART_IRQ_HANDLER(idx) \ argument
548 static void uart_gecko_config_func_##idx(const struct device *dev) \
550 IRQ_CONNECT(DT_INST_IRQ_BY_NAME(idx, rx, irq), \
551 DT_INST_IRQ_BY_NAME(idx, rx, priority), \
552 uart_gecko_isr, DEVICE_DT_INST_GET(idx), 0); \
553 IRQ_CONNECT(DT_INST_IRQ_BY_NAME(idx, tx, irq), \
554 DT_INST_IRQ_BY_NAME(idx, tx, priority), \
555 uart_gecko_isr, DEVICE_DT_INST_GET(idx), 0); \
557 irq_enable(DT_INST_IRQ_BY_NAME(idx, rx, irq)); \
558 irq_enable(DT_INST_IRQ_BY_NAME(idx, tx, irq)); \
561 #define GECKO_UART_IRQ_HANDLER_DECL(idx) argument
562 #define GECKO_UART_IRQ_HANDLER_FUNC(idx) argument
563 #define GECKO_UART_IRQ_HANDLER(idx) argument
567 #define GECKO_UART_RX_TX_PIN_LOCATIONS(idx) \ argument
568 .loc_rx = DT_INST_PROP_BY_IDX(idx, location_rx, 0), \
569 .loc_tx = DT_INST_PROP_BY_IDX(idx, location_tx, 0),
570 #define VALIDATE_GECKO_UART_RX_TX_PIN_LOCATIONS(idx) argument
572 #define GECKO_UART_RX_TX_PIN_LOCATIONS(idx) \ argument
573 .loc = DT_INST_PROP_BY_IDX(idx, location_rx, 0),
574 #define VALIDATE_GECKO_UART_RX_TX_PIN_LOCATIONS(idx) \ argument
575 BUILD_ASSERT(DT_INST_PROP_BY_IDX(idx, location_rx, 0) == \
576 DT_INST_PROP_BY_IDX(idx, location_tx, 0), \
580 #define PIN_UART_RXD(idx) \ argument
582 DT_INST_PROP_BY_IDX(idx, location_rx, 1), \
583 DT_INST_PROP_BY_IDX(idx, location_rx, 2), \
586 #define PIN_UART_TXD(idx) \ argument
588 DT_INST_PROP_BY_IDX(idx, location_tx, 1), \
589 DT_INST_PROP_BY_IDX(idx, location_tx, 2), \
593 #define GECKO_UART_RX_TX_PINS(idx) \ argument
594 .pin_rx = PIN_UART_RXD(idx), \
595 .pin_tx = PIN_UART_TXD(idx),
600 #define GECKO_UART_RTS_CTS_PIN_LOCATIONS(idx) \ argument
601 .loc_rts = COND_CODE_1(DT_INST_PROP(idx, hw_flow_control), \
602 (DT_INST_PROP_BY_IDX(idx, location_rts, 0)), \
604 .loc_cts = COND_CODE_1(DT_INST_PROP(idx, hw_flow_control), \
605 (DT_INST_PROP_BY_IDX(idx, location_cts, 0)), \
607 #define VALIDATE_GECKO_UART_RTS_CTS_PIN_LOCATIONS(idx) \ argument
608 COND_CODE_1(DT_INST_PROP(idx, hw_flow_control), \
609 (BUILD_ASSERT(DT_INST_NODE_HAS_PROP(idx, location_rts) && \
610 DT_INST_NODE_HAS_PROP(idx, location_cts), \
615 #define GECKO_UART_RTS_CTS_PIN_LOCATIONS(idx) argument
616 #define VALIDATE_GECKO_UART_RTS_CTS_PIN_LOCATIONS(idx) argument
619 #define PIN_UART_RTS(idx) \ argument
620 COND_CODE_1(DT_INST_PROP(idx, hw_flow_control), \
622 DT_INST_PROP_BY_IDX(idx, location_rts, 1), \
623 DT_INST_PROP_BY_IDX(idx, location_rts, 2), \
628 #define PIN_UART_CTS(idx) \ argument
629 COND_CODE_1(DT_INST_PROP(idx, hw_flow_control), \
631 DT_INST_PROP_BY_IDX(idx, location_cts, 1), \
632 DT_INST_PROP_BY_IDX(idx, location_cts, 2), \
637 #define GECKO_UART_RTS_CTS_PINS(idx) \ argument
638 .pin_rts = PIN_UART_RTS(idx), \
639 .pin_cts = PIN_UART_CTS(idx),
641 #define GECKO_UART_HW_FLOW_CONTROL(idx) \ argument
642 .hw_flowcontrol = DT_INST_PROP(idx, hw_flow_control),
646 #define GECKO_UART_RTS_CTS_PIN_LOCATIONS(idx) argument
647 #define VALIDATE_GECKO_UART_RTS_CTS_PIN_LOCATIONS(idx) argument
648 #define GECKO_UART_RTS_CTS_PINS(idx) argument
649 #define GECKO_UART_HW_FLOW_CONTROL(idx) argument
653 #define GECKO_UART_INIT(idx) \ argument
654 VALIDATE_GECKO_UART_RX_TX_PIN_LOCATIONS(idx); \
655 VALIDATE_GECKO_UART_RTS_CTS_PIN_LOCATIONS(idx); \
657 GECKO_UART_IRQ_HANDLER_DECL(idx); \
659 static const struct uart_gecko_config uart_gecko_cfg_##idx = { \
660 .base = (USART_TypeDef *)DT_INST_REG_ADDR(idx), \
661 GET_GECKO_UART_CLOCK(idx) \
662 .baud_rate = DT_INST_PROP(idx, current_speed), \
663 GECKO_UART_HW_FLOW_CONTROL(idx) \
664 GECKO_UART_RX_TX_PINS(idx) \
665 GECKO_UART_RTS_CTS_PINS(idx) \
666 GECKO_UART_RX_TX_PIN_LOCATIONS(idx) \
667 GECKO_UART_RTS_CTS_PIN_LOCATIONS(idx) \
668 GECKO_UART_IRQ_HANDLER_FUNC(idx) \
671 static struct uart_gecko_data uart_gecko_data_##idx; \
673 DEVICE_DT_INST_DEFINE(idx, uart_gecko_init, \
674 NULL, &uart_gecko_data_##idx, \
675 &uart_gecko_cfg_##idx, PRE_KERNEL_1, \
680 GECKO_UART_IRQ_HANDLER(idx)
688 #define GECKO_USART_IRQ_HANDLER_DECL(idx) \ argument
689 static void usart_gecko_config_func_##idx(const struct device *dev)
690 #define GECKO_USART_IRQ_HANDLER_FUNC(idx) \ argument
691 .irq_config_func = usart_gecko_config_func_##idx,
692 #define GECKO_USART_IRQ_HANDLER(idx) \ argument
693 static void usart_gecko_config_func_##idx(const struct device *dev) \
695 IRQ_CONNECT(DT_INST_IRQ_BY_NAME(idx, rx, irq), \
696 DT_INST_IRQ_BY_NAME(idx, rx, priority), \
697 uart_gecko_isr, DEVICE_DT_INST_GET(idx), 0); \
698 IRQ_CONNECT(DT_INST_IRQ_BY_NAME(idx, tx, irq), \
699 DT_INST_IRQ_BY_NAME(idx, tx, priority), \
700 uart_gecko_isr, DEVICE_DT_INST_GET(idx), 0); \
702 irq_enable(DT_INST_IRQ_BY_NAME(idx, rx, irq)); \
703 irq_enable(DT_INST_IRQ_BY_NAME(idx, tx, irq)); \
706 #define GECKO_USART_IRQ_HANDLER_DECL(idx)
707 #define GECKO_USART_IRQ_HANDLER_FUNC(idx)
708 #define GECKO_USART_IRQ_HANDLER(idx)
712 #define GECKO_USART_INIT(idx) \ argument
713 PINCTRL_DT_INST_DEFINE(idx); \
714 GECKO_USART_IRQ_HANDLER_DECL(idx); \
715 PM_DEVICE_DT_INST_DEFINE(idx, uart_gecko_pm_action); \
717 static const struct uart_gecko_config usart_gecko_cfg_##idx = { \
718 .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(idx), \
719 .base = (USART_TypeDef *)DT_INST_REG_ADDR(idx), \
720 GET_GECKO_USART_CLOCK(idx) \
721 .baud_rate = DT_INST_PROP(idx, current_speed), \
722 GECKO_USART_IRQ_HANDLER_FUNC(idx) \
725 static struct uart_gecko_data usart_gecko_data_##idx; \
727 DEVICE_DT_INST_DEFINE(idx, uart_gecko_init, PM_DEVICE_DT_INST_GET(idx),\
728 &usart_gecko_data_##idx, \
729 &usart_gecko_cfg_##idx, PRE_KERNEL_1, \
733 GECKO_USART_IRQ_HANDLER(idx)
735 #define GECKO_USART_INIT(idx) \
736 VALIDATE_GECKO_UART_RX_TX_PIN_LOCATIONS(idx); \
737 VALIDATE_GECKO_UART_RTS_CTS_PIN_LOCATIONS(idx); \
739 GECKO_USART_IRQ_HANDLER_DECL(idx); \
740 PM_DEVICE_DT_INST_DEFINE(idx, uart_gecko_pm_action); \
742 static const struct uart_gecko_config usart_gecko_cfg_##idx = { \
743 .base = (USART_TypeDef *)DT_INST_REG_ADDR(idx), \
744 GET_GECKO_USART_CLOCK(idx) \
745 .baud_rate = DT_INST_PROP(idx, current_speed), \
746 GECKO_UART_HW_FLOW_CONTROL(idx) \
747 GECKO_UART_RX_TX_PINS(idx) \
748 GECKO_UART_RTS_CTS_PINS(idx) \
749 GECKO_UART_RX_TX_PIN_LOCATIONS(idx) \
750 GECKO_UART_RTS_CTS_PIN_LOCATIONS(idx) \
751 GECKO_USART_IRQ_HANDLER_FUNC(idx) \
754 static struct uart_gecko_data usart_gecko_data_##idx; \
756 DEVICE_DT_INST_DEFINE(idx, uart_gecko_init, PM_DEVICE_DT_INST_GET(idx),\
757 &usart_gecko_data_##idx, \
758 &usart_gecko_cfg_##idx, PRE_KERNEL_1, \
762 GECKO_USART_IRQ_HANDLER(idx)