Lines Matching +full:revision +full:- +full:reg

4  * SPDX-License-Identifier: Apache-2.0
21 * The register definitions correspond to those found in the TI TCAN4550-Q1 datasheet, revision D
31 /* Revision register */
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()
340 static inline int tcan4x5x_read_tcan_reg(const struct device *dev, uint16_t reg, uint32_t *val) in tcan4x5x_read_tcan_reg() argument
342 return tcan4x5x_read(dev, reg, val, sizeof(uint32_t)); in tcan4x5x_read_tcan_reg()
345 static inline int tcan4x5x_write_tcan_reg(const struct device *dev, uint16_t reg, uint32_t val) in tcan4x5x_write_tcan_reg() argument
347 return tcan4x5x_write(dev, reg, &val, sizeof(uint32_t)); in tcan4x5x_write_tcan_reg()
350 static int tcan4x5x_read_mcan_reg(const struct device *dev, uint16_t reg, uint32_t *val) in tcan4x5x_read_mcan_reg() argument
352 return tcan4x5x_read(dev, CAN_TCAN4X5X_MCAN_BASE + reg, val, sizeof(uint32_t)); in tcan4x5x_read_mcan_reg()
355 static int tcan4x5x_write_mcan_reg(const struct device *dev, uint16_t reg, uint32_t val) in tcan4x5x_write_mcan_reg() argument
357 return tcan4x5x_write(dev, CAN_TCAN4X5X_MCAN_BASE + reg, &val, sizeof(uint32_t)); in tcan4x5x_write_mcan_reg()
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()
511 const struct can_mcan_config *mcan_config = dev->config; in tcan4x5x_reset()
512 const struct tcan4x5x_config *tcan_config = mcan_config->custom; in tcan4x5x_reset()
521 if (tcan_config->rst_gpio.port != NULL) { in tcan4x5x_reset()
522 err = gpio_pin_set_dt(&tcan_config->rst_gpio, 1); in tcan4x5x_reset()
530 err = gpio_pin_set_dt(&tcan_config->rst_gpio, 0); in tcan4x5x_reset()
554 const struct can_mcan_config *mcan_config = dev->config; in tcan4x5x_init()
555 const struct tcan4x5x_config *tcan_config = mcan_config->custom; in tcan4x5x_init()
556 struct can_mcan_data *mcan_data = dev->data; in tcan4x5x_init()
557 struct tcan4x5x_data *tcan_data = mcan_data->custom; in tcan4x5x_init()
559 uint32_t reg; in tcan4x5x_init() local
563 k_sem_init(&tcan_data->int_sem, 1, 1); in tcan4x5x_init()
565 if (!spi_is_ready_dt(&tcan_config->spi)) { in tcan4x5x_init()
567 return -ENODEV; in tcan4x5x_init()
571 if (tcan_config->rst_gpio.port != NULL) { in tcan4x5x_init()
572 if (!gpio_is_ready_dt(&tcan_config->rst_gpio)) { in tcan4x5x_init()
574 return -ENODEV; in tcan4x5x_init()
577 err = gpio_pin_configure_dt(&tcan_config->rst_gpio, GPIO_OUTPUT_INACTIVE); in tcan4x5x_init()
580 return -ENODEV; in tcan4x5x_init()
586 if (tcan_config->nwkrq_gpio.port != NULL) { in tcan4x5x_init()
587 if (!gpio_is_ready_dt(&tcan_config->nwkrq_gpio)) { in tcan4x5x_init()
589 return -ENODEV; in tcan4x5x_init()
592 err = gpio_pin_configure_dt(&tcan_config->nwkrq_gpio, GPIO_INPUT); in tcan4x5x_init()
595 return -ENODEV; in tcan4x5x_init()
601 if (tcan_config->wake_gpio.port != NULL) { in tcan4x5x_init()
602 if (!gpio_is_ready_dt(&tcan_config->wake_gpio)) { in tcan4x5x_init()
604 return -ENODEV; in tcan4x5x_init()
607 err = gpio_pin_configure_dt(&tcan_config->wake_gpio, GPIO_OUTPUT_INACTIVE); in tcan4x5x_init()
610 return -ENODEV; in tcan4x5x_init()
615 if (!gpio_is_ready_dt(&tcan_config->int_gpio)) { in tcan4x5x_init()
617 return -ENODEV; in tcan4x5x_init()
620 err = gpio_pin_configure_dt(&tcan_config->int_gpio, GPIO_INPUT); in tcan4x5x_init()
623 return -ENODEV; in tcan4x5x_init()
626 gpio_init_callback(&tcan_data->int_gpio_cb, tcan4x5x_int_gpio_callback_handler, in tcan4x5x_init()
627 BIT(tcan_config->int_gpio.pin)); in tcan4x5x_init()
629 err = gpio_add_callback_dt(&tcan_config->int_gpio, &tcan_data->int_gpio_cb); in tcan4x5x_init()
632 return -ENODEV; in tcan4x5x_init()
636 err = gpio_pin_interrupt_configure_dt(&tcan_config->int_gpio, GPIO_INT_EDGE_TO_ACTIVE); in tcan4x5x_init()
639 return -ENODEV; in tcan4x5x_init()
642 tid = k_thread_create(&tcan_data->int_thread, tcan_data->int_stack, in tcan4x5x_init()
643 K_KERNEL_STACK_SIZEOF(tcan_data->int_stack), in tcan4x5x_init()
651 return -ENODEV; in tcan4x5x_init()
657 /* Read DEVICE_ID1, DEVICE_ID2, and REVISION registers */ in tcan4x5x_init()
660 return -EIO; in tcan4x5x_init()
673 err = tcan4x5x_read_tcan_reg(dev, CAN_TCAN4X5X_MODE_CONFIG, &reg); in tcan4x5x_init()
676 return -ENODEV; in tcan4x5x_init()
679 reg &= ~(CAN_TCAN4X5X_MODE_CONFIG_MODE_SEL); in tcan4x5x_init()
680 reg |= FIELD_PREP(CAN_TCAN4X5X_MODE_CONFIG_MODE_SEL, 0x02); in tcan4x5x_init()
681 reg |= CAN_TCAN4X5X_MODE_CONFIG_WAKE_CONFIG; in tcan4x5x_init()
683 if (tcan_config->clk_freq == MHZ(20)) { in tcan4x5x_init()
685 reg &= ~(CAN_TCAN4X5X_MODE_CONFIG_CLK_REF); in tcan4x5x_init()
688 reg |= CAN_TCAN4X5X_MODE_CONFIG_CLK_REF; in tcan4x5x_init()
691 err = tcan4x5x_write_tcan_reg(dev, CAN_TCAN4X5X_MODE_CONFIG, reg); in tcan4x5x_init()
694 return -ENODEV; in tcan4x5x_init()
703 return -EIO; in tcan4x5x_init()