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()
413 struct can_mcan_data *mcan_data = dev->data; in tcan4x5x_int_thread()
414 struct tcan4x5x_data *tcan_data = mcan_data->custom; in tcan4x5x_int_thread()
420 k_sem_take(&tcan_data->int_sem, K_FOREVER); in tcan4x5x_int_thread()
470 const struct can_mcan_config *mcan_config = dev->config; in tcan4x5x_wake()
471 const struct tcan4x5x_config *tcan_config = mcan_config->custom; in tcan4x5x_wake()
476 if (tcan_config->wake_gpio.port != NULL && tcan_config->nwkrq_gpio.port != NULL) { in tcan4x5x_wake()
477 wake_needed = gpio_pin_get_dt(&tcan_config->nwkrq_gpio); in tcan4x5x_wake()
485 if (tcan_config->wake_gpio.port != NULL && wake_needed != 0) { in tcan4x5x_wake()
486 err = gpio_pin_set_dt(&tcan_config->wake_gpio, 1); in tcan4x5x_wake()
494 err = gpio_pin_set_dt(&tcan_config->wake_gpio, 0); in tcan4x5x_wake()
507 const struct can_mcan_config *mcan_config = dev->config; in tcan4x5x_reset()
508 const struct tcan4x5x_config *tcan_config = mcan_config->custom; in tcan4x5x_reset()
517 if (tcan_config->rst_gpio.port != NULL) { in tcan4x5x_reset()
518 err = gpio_pin_set_dt(&tcan_config->rst_gpio, 1); in tcan4x5x_reset()
526 err = gpio_pin_set_dt(&tcan_config->rst_gpio, 0); in tcan4x5x_reset()
550 const struct can_mcan_config *mcan_config = dev->config; in tcan4x5x_init()
551 const struct tcan4x5x_config *tcan_config = mcan_config->custom; in tcan4x5x_init()
552 struct can_mcan_data *mcan_data = dev->data; in tcan4x5x_init()
553 struct tcan4x5x_data *tcan_data = mcan_data->custom; in tcan4x5x_init()
559 k_sem_init(&tcan_data->int_sem, 1, 1); in tcan4x5x_init()
561 if (!spi_is_ready_dt(&tcan_config->spi)) { in tcan4x5x_init()
563 return -ENODEV; in tcan4x5x_init()
567 if (tcan_config->rst_gpio.port != NULL) { in tcan4x5x_init()
568 if (!gpio_is_ready_dt(&tcan_config->rst_gpio)) { in tcan4x5x_init()
570 return -ENODEV; in tcan4x5x_init()
573 err = gpio_pin_configure_dt(&tcan_config->rst_gpio, GPIO_OUTPUT_INACTIVE); in tcan4x5x_init()
576 return -ENODEV; in tcan4x5x_init()
582 if (tcan_config->nwkrq_gpio.port != NULL) { in tcan4x5x_init()
583 if (!gpio_is_ready_dt(&tcan_config->nwkrq_gpio)) { in tcan4x5x_init()
585 return -ENODEV; in tcan4x5x_init()
588 err = gpio_pin_configure_dt(&tcan_config->nwkrq_gpio, GPIO_INPUT); in tcan4x5x_init()
591 return -ENODEV; in tcan4x5x_init()
597 if (tcan_config->wake_gpio.port != NULL) { in tcan4x5x_init()
598 if (!gpio_is_ready_dt(&tcan_config->wake_gpio)) { in tcan4x5x_init()
600 return -ENODEV; in tcan4x5x_init()
603 err = gpio_pin_configure_dt(&tcan_config->wake_gpio, GPIO_OUTPUT_INACTIVE); in tcan4x5x_init()
606 return -ENODEV; in tcan4x5x_init()
611 if (!gpio_is_ready_dt(&tcan_config->int_gpio)) { in tcan4x5x_init()
612 LOG_ERR("nINT GPIO not ready"); in tcan4x5x_init()
613 return -ENODEV; in tcan4x5x_init()
616 err = gpio_pin_configure_dt(&tcan_config->int_gpio, GPIO_INPUT); in tcan4x5x_init()
618 LOG_ERR("failed to configure nINT GPIO (err %d)", err); in tcan4x5x_init()
619 return -ENODEV; in tcan4x5x_init()
622 gpio_init_callback(&tcan_data->int_gpio_cb, tcan4x5x_int_gpio_callback_handler, in tcan4x5x_init()
623 BIT(tcan_config->int_gpio.pin)); in tcan4x5x_init()
625 err = gpio_add_callback_dt(&tcan_config->int_gpio, &tcan_data->int_gpio_cb); in tcan4x5x_init()
627 LOG_ERR("failed to add nINT GPIO callback (err %d)", err); in tcan4x5x_init()
628 return -ENODEV; in tcan4x5x_init()
631 /* Initialize nINT GPIO callback and interrupt handler thread to ACK any early SPIERR */ in tcan4x5x_init()
632 err = gpio_pin_interrupt_configure_dt(&tcan_config->int_gpio, GPIO_INT_EDGE_TO_ACTIVE); in tcan4x5x_init()
634 LOG_ERR("failed to configure nINT GPIO interrupt (err %d)", err); in tcan4x5x_init()
635 return -ENODEV; in tcan4x5x_init()
638 tid = k_thread_create(&tcan_data->int_thread, tcan_data->int_stack, in tcan4x5x_init()
639 K_KERNEL_STACK_SIZEOF(tcan_data->int_stack), in tcan4x5x_init()
647 return -ENODEV; in tcan4x5x_init()
656 return -EIO; in tcan4x5x_init()
672 return -ENODEV; in tcan4x5x_init()
679 if (tcan_config->clk_freq == MHZ(20)) { in tcan4x5x_init()
690 return -ENODEV; in tcan4x5x_init()
699 return -EIO; in tcan4x5x_init()