Lines Matching +full:nint +full:- +full:gpios
4 * SPDX-License-Identifier: Apache-2.0
21 * The register definitions correspond to those found in the TI TCAN4550-Q1 datasheet, revision D
209 * Only compile in support for the optional GPIOs if at least one enabled tcan4x5x device tree node
241 const struct can_mcan_config *mcan_config = dev->config; in tcan4x5x_read()
242 const struct tcan4x5x_config *tcan_config = mcan_config->custom; in tcan4x5x_read()
271 /* Maximum transfer size is 256 32-bit words */ in tcan4x5x_read()
275 err = spi_transceive_dt(&tcan_config->spi, &tx, &rx); in tcan4x5x_read()
292 const struct can_mcan_config *mcan_config = dev->config; in tcan4x5x_write()
293 const struct tcan4x5x_config *tcan_config = mcan_config->custom; in tcan4x5x_write()
321 /* Maximum transfer size is 256 32-bit words */ in tcan4x5x_write()
329 err = spi_transceive_dt(&tcan_config->spi, &tx, &rx); in tcan4x5x_write()
379 pending = MIN(len - upto, sizeof(buf)); in tcan4x5x_clear_mcan_mram()
395 const struct can_mcan_config *mcan_config = dev->config; in tcan4x5x_get_core_clock()
396 const struct tcan4x5x_config *tcan_config = mcan_config->custom; in tcan4x5x_get_core_clock()
398 *rate = tcan_config->clk_freq; in tcan4x5x_get_core_clock()
408 k_sem_give(&tcan_data->int_sem); in tcan4x5x_int_gpio_callback_handler()
417 struct can_mcan_data *mcan_data = dev->data; in tcan4x5x_int_thread()
418 struct tcan4x5x_data *tcan_data = mcan_data->custom; in tcan4x5x_int_thread()
424 k_sem_take(&tcan_data->int_sem, K_FOREVER); in tcan4x5x_int_thread()
474 const struct can_mcan_config *mcan_config = dev->config; in tcan4x5x_wake()
475 const struct tcan4x5x_config *tcan_config = mcan_config->custom; in tcan4x5x_wake()
480 if (tcan_config->wake_gpio.port != NULL && tcan_config->nwkrq_gpio.port != NULL) { in tcan4x5x_wake()
481 wake_needed = gpio_pin_get_dt(&tcan_config->nwkrq_gpio); in tcan4x5x_wake()
489 if (tcan_config->wake_gpio.port != NULL && wake_needed != 0) { in tcan4x5x_wake()
490 err = gpio_pin_set_dt(&tcan_config->wake_gpio, 1); in tcan4x5x_wake()
498 err = gpio_pin_set_dt(&tcan_config->wake_gpio, 0); in tcan4x5x_wake()
512 const struct can_mcan_config *mcan_config = dev->config; in tcan4x5x_reset()
513 const struct tcan4x5x_config *tcan_config = mcan_config->custom; in tcan4x5x_reset()
523 if (tcan_config->rst_gpio.port != NULL) { in tcan4x5x_reset()
524 err = gpio_pin_set_dt(&tcan_config->rst_gpio, 1); in tcan4x5x_reset()
532 err = gpio_pin_set_dt(&tcan_config->rst_gpio, 0); in tcan4x5x_reset()
556 const struct can_mcan_config *mcan_config = dev->config; in tcan4x5x_init()
557 const struct tcan4x5x_config *tcan_config = mcan_config->custom; in tcan4x5x_init()
558 struct can_mcan_data *mcan_data = dev->data; in tcan4x5x_init()
559 struct tcan4x5x_data *tcan_data = mcan_data->custom; in tcan4x5x_init()
565 k_sem_init(&tcan_data->int_sem, 1, 1); in tcan4x5x_init()
567 if (!spi_is_ready_dt(&tcan_config->spi)) { in tcan4x5x_init()
569 return -ENODEV; in tcan4x5x_init()
573 if (tcan_config->rst_gpio.port != NULL) { in tcan4x5x_init()
574 if (!gpio_is_ready_dt(&tcan_config->rst_gpio)) { in tcan4x5x_init()
576 return -ENODEV; in tcan4x5x_init()
579 err = gpio_pin_configure_dt(&tcan_config->rst_gpio, GPIO_OUTPUT_INACTIVE); in tcan4x5x_init()
582 return -ENODEV; in tcan4x5x_init()
588 if (tcan_config->nwkrq_gpio.port != NULL) { in tcan4x5x_init()
589 if (!gpio_is_ready_dt(&tcan_config->nwkrq_gpio)) { in tcan4x5x_init()
591 return -ENODEV; in tcan4x5x_init()
594 err = gpio_pin_configure_dt(&tcan_config->nwkrq_gpio, GPIO_INPUT); in tcan4x5x_init()
597 return -ENODEV; in tcan4x5x_init()
603 if (tcan_config->wake_gpio.port != NULL) { in tcan4x5x_init()
604 if (!gpio_is_ready_dt(&tcan_config->wake_gpio)) { in tcan4x5x_init()
606 return -ENODEV; in tcan4x5x_init()
609 err = gpio_pin_configure_dt(&tcan_config->wake_gpio, GPIO_OUTPUT_INACTIVE); in tcan4x5x_init()
612 return -ENODEV; in tcan4x5x_init()
617 if (!gpio_is_ready_dt(&tcan_config->int_gpio)) { in tcan4x5x_init()
618 LOG_ERR("nINT GPIO not ready"); in tcan4x5x_init()
619 return -ENODEV; in tcan4x5x_init()
622 err = gpio_pin_configure_dt(&tcan_config->int_gpio, GPIO_INPUT); in tcan4x5x_init()
624 LOG_ERR("failed to configure nINT GPIO (err %d)", err); in tcan4x5x_init()
625 return -ENODEV; in tcan4x5x_init()
628 gpio_init_callback(&tcan_data->int_gpio_cb, tcan4x5x_int_gpio_callback_handler, in tcan4x5x_init()
629 BIT(tcan_config->int_gpio.pin)); in tcan4x5x_init()
631 err = gpio_add_callback_dt(&tcan_config->int_gpio, &tcan_data->int_gpio_cb); in tcan4x5x_init()
633 LOG_ERR("failed to add nINT GPIO callback (err %d)", err); in tcan4x5x_init()
634 return -ENODEV; in tcan4x5x_init()
637 /* Initialize nINT GPIO callback and interrupt handler thread to ACK any early SPIERR */ in tcan4x5x_init()
638 err = gpio_pin_interrupt_configure_dt(&tcan_config->int_gpio, GPIO_INT_EDGE_TO_ACTIVE); in tcan4x5x_init()
640 LOG_ERR("failed to configure nINT GPIO interrupt (err %d)", err); in tcan4x5x_init()
641 return -ENODEV; in tcan4x5x_init()
644 tid = k_thread_create(&tcan_data->int_thread, tcan_data->int_stack, in tcan4x5x_init()
645 K_KERNEL_STACK_SIZEOF(tcan_data->int_stack), in tcan4x5x_init()
653 return -ENODEV; in tcan4x5x_init()
662 return -EIO; in tcan4x5x_init()
678 return -ENODEV; in tcan4x5x_init()
685 if (tcan_config->clk_freq == MHZ(20)) { in tcan4x5x_init()
696 return -ENODEV; in tcan4x5x_init()
705 return -EIO; in tcan4x5x_init()