Lines Matching +full:bad +full:- +full:key +full:- +full:1
4 * SPDX-License-Identifier: Apache-2.0
47 uint8_t m_aval : 1;
48 uint8_t fs_en : 1;
49 uint8_t fs_g : 1;
50 uint8_t com_g : 1;
51 uint8_t wio_g : 1;
52 uint8_t vsup_g : 1;
53 uint8_t reg_g : 1;
54 uint8_t tsd_g : 1;
92 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 64, 128, 256, 512, 1024
141 for (i = size; i > 0; i--) { in fs26_calcrc()
168 .count = 1U in fs26_spi_transceive()
172 .count = 1U in fs26_spi_transceive()
176 tx_buf = (uint32_t)(FS26_SET_REG_ADDR(tx_frame->addr) in fs26_spi_transceive()
177 | FS26_SET_DATA(tx_frame->data) in fs26_spi_transceive()
178 | (tx_frame->write ? FS26_RW : 0)); in fs26_spi_transceive()
180 crc = fs26_calcrc((uint8_t *)&tx_buf, sizeof(tx_buf) - 1); in fs26_spi_transceive()
197 crc = fs26_calcrc((uint8_t *)&rx_buf, sizeof(rx_buf) - 1); in fs26_spi_transceive()
200 retval = -EIO; in fs26_spi_transceive()
205 rx_frame->status.raw = (uint8_t)FS26_GET_DEV_STATUS(rx_buf); in fs26_spi_transceive()
206 rx_frame->data = (uint16_t)FS26_GET_DATA(rx_buf); in fs26_spi_transceive()
265 tmp -= 4U; in fs26_wd_compute_answer()
279 const struct wdt_nxp_fs26_config *config = dev->config; in fs26_wd_refresh()
280 struct wdt_nxp_fs26_data *data = dev->data; in fs26_wd_refresh()
282 int key; in fs26_wd_refresh() local
286 if (config->wd_type == FS26_WD_SIMPLE) { in fs26_wd_refresh()
287 if (fs26_setreg(&config->spi, FS26_FS_WD_ANSWER, data->token) == 0) { in fs26_wd_refresh()
289 retval = -EIO; in fs26_wd_refresh()
291 } else if (config->wd_type == FS26_WD_CHALLENGER) { in fs26_wd_refresh()
292 key = irq_lock(); in fs26_wd_refresh()
295 if (fs26_getreg(&config->spi, FS26_FS_WD_TOKEN, &rx_frame)) { in fs26_wd_refresh()
297 retval = -EIO; in fs26_wd_refresh()
299 data->token = rx_frame.data; in fs26_wd_refresh()
300 LOG_DBG("Watchdog token is %x", data->token); in fs26_wd_refresh()
302 answer = fs26_wd_compute_answer(data->token); in fs26_wd_refresh()
303 if (fs26_setreg(&config->spi, FS26_FS_WD_ANSWER, answer)) { in fs26_wd_refresh()
305 retval = -EIO; in fs26_wd_refresh()
309 irq_unlock(key); in fs26_wd_refresh()
311 retval = -EINVAL; in fs26_wd_refresh()
316 if (!fs26_getreg(&config->spi, FS26_FS_GRL_FLAGS, &rx_frame)) { in fs26_wd_refresh()
318 if (!fs26_getreg(&config->spi, FS26_FS_DIAG_SAFETY1, &rx_frame)) { in fs26_wd_refresh()
319 LOG_ERR("Bad watchdog refresh, %s", in fs26_wd_refresh()
322 retval = -EIO; in fs26_wd_refresh()
335 * @return 0 on success, -ETIMEDOUT if timedout
339 const struct wdt_nxp_fs26_config *config = dev->config; in fs26_poll_for_init_fs_state()
348 if (!fs26_getreg(&config->spi, FS26_FS_STATES, &rx_frame)) { in fs26_poll_for_init_fs_state()
351 k_sleep(K_MSEC(1)); in fs26_poll_for_init_fs_state()
357 return -ETIMEDOUT; in fs26_poll_for_init_fs_state()
373 const struct wdt_nxp_fs26_config *config = dev->config; in fs26_goto_init_fs_state()
376 int retval = -EIO; in fs26_goto_init_fs_state()
378 if (!fs26_getreg(&config->spi, FS26_FS_STATES, &rx_frame)) { in fs26_goto_init_fs_state()
382 retval = -EIO; in fs26_goto_init_fs_state()
386 fs26_setreg(&config->spi, FS26_FS_SAFE_IOS_1, (uint32_t)FS_GOTO_INIT); in fs26_goto_init_fs_state()
406 struct wdt_nxp_fs26_data *data = dev->data; in wdt_nxp_fs26_feed()
410 return -EINVAL; in wdt_nxp_fs26_feed()
413 if (!data->timeout_installed) { in wdt_nxp_fs26_feed()
415 return -EINVAL; in wdt_nxp_fs26_feed()
423 const struct wdt_nxp_fs26_config *config = dev->config; in wdt_nxp_fs26_setup()
424 struct wdt_nxp_fs26_data *data = dev->data; in wdt_nxp_fs26_setup()
427 if (!data->timeout_installed) { in wdt_nxp_fs26_setup()
429 return -EINVAL; in wdt_nxp_fs26_setup()
433 return -ENOTSUP; in wdt_nxp_fs26_setup()
437 * Apply fail-safe reaction configuration on RSTB and/or the safety output(s), in wdt_nxp_fs26_setup()
442 return -EIO; in wdt_nxp_fs26_setup()
447 | ((data->fs_reaction << WD_FS_REACTION_SHIFT) & WD_FS_REACTION_MASK); in wdt_nxp_fs26_setup()
449 fs26_setreg(&config->spi, FS26_FS_I_WD_CFG, regval); in wdt_nxp_fs26_setup()
450 fs26_setreg(&config->spi, FS26_FS_I_NOT_WD_CFG, ~regval); in wdt_nxp_fs26_setup()
453 regval = ((data->window_period << WDW_PERIOD_SHIFT) & WDW_PERIOD_MASK) in wdt_nxp_fs26_setup()
454 | ((data->window_duty_cycle << WDW_DC_SHIFT) & WDW_DC_MASK) in wdt_nxp_fs26_setup()
457 fs26_setreg(&config->spi, FS26_FS_WDW_DURATION, regval); in wdt_nxp_fs26_setup()
458 fs26_setreg(&config->spi, FS26_FS_NOT_WDW_DURATION, ~regval); in wdt_nxp_fs26_setup()
467 return -EIO; in wdt_nxp_fs26_setup()
476 struct wdt_nxp_fs26_data *data = dev->data; in wdt_nxp_fs26_install_timeout()
480 if (data->timeout_installed) { in wdt_nxp_fs26_install_timeout()
482 return -ENOMEM; in wdt_nxp_fs26_install_timeout()
485 if ((cfg->window.max == 0) || (cfg->window.max > 1024) in wdt_nxp_fs26_install_timeout()
486 || (cfg->window.max <= cfg->window.min)) { in wdt_nxp_fs26_install_timeout()
488 return -EINVAL; in wdt_nxp_fs26_install_timeout()
493 if (fs26_period_values[i] >= cfg->window.max) { in wdt_nxp_fs26_install_timeout()
497 data->window_period = i; in wdt_nxp_fs26_install_timeout()
499 cfg->window.max, fs26_period_values[data->window_period]); in wdt_nxp_fs26_install_timeout()
507 * fs26_period_values[data->window_period]); in wdt_nxp_fs26_install_timeout()
508 if (window_min >= cfg->window.min) { in wdt_nxp_fs26_install_timeout()
514 return -EINVAL; in wdt_nxp_fs26_install_timeout()
516 data->window_duty_cycle = i; in wdt_nxp_fs26_install_timeout()
519 cfg->window.min, window_min, in wdt_nxp_fs26_install_timeout()
520 fs26_dc_closed_values[data->window_duty_cycle] * 100); in wdt_nxp_fs26_install_timeout()
522 /* Fail-safe reaction configuration */ in wdt_nxp_fs26_install_timeout()
523 switch (cfg->flags) { in wdt_nxp_fs26_install_timeout()
527 data->fs_reaction = WD_FS_REACTION_RSTB_FS0B >> WD_FS_REACTION_SHIFT; in wdt_nxp_fs26_install_timeout()
531 data->fs_reaction = WD_FS_REACTION_NO_ACTION >> WD_FS_REACTION_SHIFT; in wdt_nxp_fs26_install_timeout()
532 LOG_DBG("Configuring non-reset mode"); in wdt_nxp_fs26_install_timeout()
536 return -EINVAL; in wdt_nxp_fs26_install_timeout()
539 data->callback = cfg->callback; in wdt_nxp_fs26_install_timeout()
540 data->timeout_installed = true; in wdt_nxp_fs26_install_timeout()
548 const struct wdt_nxp_fs26_config *config = dev->config; in wdt_nxp_fs26_disable()
549 struct wdt_nxp_fs26_data *data = dev->data; in wdt_nxp_fs26_disable()
553 if (fs26_getreg(&config->spi, FS26_FS_WDW_DURATION, &rx_frame)) { in wdt_nxp_fs26_disable()
554 return -EIO; in wdt_nxp_fs26_disable()
558 return -EFAULT; in wdt_nxp_fs26_disable()
564 return -EIO; in wdt_nxp_fs26_disable()
568 fs26_setreg(&config->spi, FS26_FS_WDW_DURATION, regval); in wdt_nxp_fs26_disable()
569 fs26_setreg(&config->spi, FS26_FS_NOT_WDW_DURATION, ~regval); in wdt_nxp_fs26_disable()
574 return -EIO; in wdt_nxp_fs26_disable()
578 data->timeout_installed = false; in wdt_nxp_fs26_disable()
589 const struct wdt_nxp_fs26_config *config = dev->config; in wdt_nxp_fs26_int_thread()
590 struct wdt_nxp_fs26_data *data = dev->data; in wdt_nxp_fs26_int_thread()
594 while (1) { in wdt_nxp_fs26_int_thread()
595 k_sem_take(&data->int_sem, K_FOREVER); in wdt_nxp_fs26_int_thread()
597 if ((!fs26_getreg(&config->spi, FS26_FS_GRL_FLAGS, &rx_frame)) in wdt_nxp_fs26_int_thread()
600 if ((!fs26_getreg(&config->spi, FS26_FS_DIAG_SAFETY1, &rx_frame)) in wdt_nxp_fs26_int_thread()
605 fs26_setreg(&config->spi, FS26_FS_DIAG_SAFETY1, regval); in wdt_nxp_fs26_int_thread()
608 if (data->callback && data->timeout_installed) { in wdt_nxp_fs26_int_thread()
609 data->callback(dev, 0); in wdt_nxp_fs26_int_thread()
626 k_sem_give(&data->int_sem); in wdt_nxp_fs26_int_callback()
631 const struct wdt_nxp_fs26_config *config = dev->config; in wdt_nxp_fs26_init()
632 struct wdt_nxp_fs26_data *data = dev->data; in wdt_nxp_fs26_init()
637 if (!spi_is_ready_dt(&config->spi)) { in wdt_nxp_fs26_init()
638 return -ENODEV; in wdt_nxp_fs26_init()
641 k_sem_init(&data->int_sem, 0, 1); in wdt_nxp_fs26_init()
644 if (!gpio_is_ready_dt(&config->int_gpio)) { in wdt_nxp_fs26_init()
645 LOG_ERR("GPIO port %s not ready", config->int_gpio.port->name); in wdt_nxp_fs26_init()
646 return -ENODEV; in wdt_nxp_fs26_init()
649 if (gpio_pin_configure_dt(&config->int_gpio, GPIO_INPUT)) { in wdt_nxp_fs26_init()
650 LOG_ERR("Unable to configure GPIO pin %u", config->int_gpio.pin); in wdt_nxp_fs26_init()
651 return -EIO; in wdt_nxp_fs26_init()
654 gpio_init_callback(&(data->int_gpio_cb), wdt_nxp_fs26_int_callback, in wdt_nxp_fs26_init()
655 BIT(config->int_gpio.pin)); in wdt_nxp_fs26_init()
657 if (gpio_add_callback(config->int_gpio.port, &(data->int_gpio_cb))) { in wdt_nxp_fs26_init()
658 return -EINVAL; in wdt_nxp_fs26_init()
661 if (gpio_pin_interrupt_configure_dt(&config->int_gpio, in wdt_nxp_fs26_init()
663 return -EINVAL; in wdt_nxp_fs26_init()
666 k_thread_create(&data->int_thread, data->int_thread_stack, in wdt_nxp_fs26_init()
674 if (fs26_getreg(&config->spi, FS26_FS_DIAG_SAFETY1, &rx_frame)) { in wdt_nxp_fs26_init()
675 return -EIO; in wdt_nxp_fs26_init()
682 return -EIO; in wdt_nxp_fs26_init()
686 if (fs26_getreg(&config->spi, FS26_FS_STATES, &rx_frame)) { in wdt_nxp_fs26_init()
687 return -EIO; in wdt_nxp_fs26_init()
695 fs26_setreg(&config->spi, FS26_FS_STATES, regval); in wdt_nxp_fs26_init()
698 return -EIO; in wdt_nxp_fs26_init()
705 return -EIO; in wdt_nxp_fs26_init()
711 fs26_setreg(&config->spi, FS26_FS_DIAG_SAFETY1, regval); in wdt_nxp_fs26_init()
715 * - Write the desired data in the FS_I_Register_A (data) in wdt_nxp_fs26_init()
716 * - Write the opposite in the FS_I_NOT_Register_A (~data) in wdt_nxp_fs26_init()
729 fs26_setreg(&config->spi, FS26_FS_I_OVUV_SAFE_REACTION1, regval); in wdt_nxp_fs26_init()
730 fs26_setreg(&config->spi, FS26_FS_I_NOT_OVUV_SAFE_REACTION1, ~regval); in wdt_nxp_fs26_init()
742 fs26_setreg(&config->spi, FS26_FS_I_OVUV_SAFE_REACTION2, regval); in wdt_nxp_fs26_init()
743 fs26_setreg(&config->spi, FS26_FS_I_NOT_OVUV_SAFE_REACTION2, ~regval); in wdt_nxp_fs26_init()
748 fs26_setreg(&config->spi, FS26_FS_I_SAFE_INPUTS, regval); in wdt_nxp_fs26_init()
749 fs26_setreg(&config->spi, FS26_FS_I_NOT_SAFE_INPUTS, ~regval); in wdt_nxp_fs26_init()
754 fs26_setreg(&config->spi, FS26_FS_I_FSSM, regval); in wdt_nxp_fs26_init()
755 fs26_setreg(&config->spi, FS26_FS_I_NOT_FSSM, ~regval); in wdt_nxp_fs26_init()
762 fs26_setreg(&config->spi, FS26_FS_I_WD_CFG, regval); in wdt_nxp_fs26_init()
763 fs26_setreg(&config->spi, FS26_FS_I_NOT_WD_CFG, ~regval); in wdt_nxp_fs26_init()
769 fs26_setreg(&config->spi, FS26_FS_WDW_DURATION, regval); in wdt_nxp_fs26_init()
770 fs26_setreg(&config->spi, FS26_FS_NOT_WDW_DURATION, ~regval); in wdt_nxp_fs26_init()
773 if (data->token != FS26_FS_WD_TOKEN_DEFAULT) { in wdt_nxp_fs26_init()
774 LOG_DBG("Set seed to %x", data->token); in wdt_nxp_fs26_init()
775 fs26_setreg(&config->spi, FS26_FS_WD_TOKEN, data->token); in wdt_nxp_fs26_init()
778 /* Mask all Fail-Safe interrupt sources except for watchdog bad refresh */ in wdt_nxp_fs26_init()
780 fs26_setreg(&config->spi, FS26_FS_INTB_MASK, regval); in wdt_nxp_fs26_init()
784 fs26_setreg(&config->spi, FS26_M_TSD_MSK, regval); in wdt_nxp_fs26_init()
785 fs26_setreg(&config->spi, FS26_M_REG_MSK, regval); in wdt_nxp_fs26_init()
786 fs26_setreg(&config->spi, FS26_M_VSUP_MSK, regval); in wdt_nxp_fs26_init()
787 fs26_setreg(&config->spi, FS26_M_WIO_MSK, regval); in wdt_nxp_fs26_init()
788 fs26_setreg(&config->spi, FS26_M_COM_MSK, regval); in wdt_nxp_fs26_init()
793 return -EIO; in wdt_nxp_fs26_init()
797 if (!fs26_getreg(&config->spi, FS26_FS_STATES, &rx_frame)) { in wdt_nxp_fs26_init()
800 return -EIO; in wdt_nxp_fs26_init()