Lines Matching +full:timeout +full:- +full:period
2 * Copyright 2022-2024 NXP
4 * SPDX-License-Identifier: Apache-2.0
45 /* Timeout */
81 #define REG_READ(r) sys_read32(config->base + (r))
82 #define REG_WRITE(r, v) sys_write32((v), config->base + (r))
96 uint32_t period; member
115 struct swt_nxp_s32_timeout timeout; member
120 switch (config->lock_mode) { in swt_lock()
139 LOG_ERR("Watchdog hard-locked"); in swt_unlock()
140 err = -EFAULT; in swt_unlock()
150 err = -ETIMEDOUT; in swt_unlock()
161 /* Calculated pseudo-random key according to Service Key Generation chapter in RM */ in swt_gen_service_key()
167 const struct swt_nxp_s32_config *config = dev->config; in swt_nxp_s32_setup()
168 struct swt_nxp_s32_data *data = dev->data; in swt_nxp_s32_setup()
172 if (!data->timeout_valid) { in swt_nxp_s32_setup()
174 return -EINVAL; in swt_nxp_s32_setup()
185 SWT_CR_WND(data->timeout.window_mode ? 1U : 0U) | in swt_nxp_s32_setup()
186 SWT_CR_ITR(data->callback ? 1U : 0U) | in swt_nxp_s32_setup()
191 REG_WRITE(SWT_TO, SWT_TO_WTO(data->timeout.period)); in swt_nxp_s32_setup()
192 REG_WRITE(SWT_WN, SWT_WN_WST(data->timeout.window_start)); in swt_nxp_s32_setup()
194 if (config->service_mode == SWT_KEYED_SERVICE) { in swt_nxp_s32_setup()
195 REG_WRITE(SWT_SK, SWT_SK_SK(config->initial_key)); in swt_nxp_s32_setup()
206 const struct swt_nxp_s32_config *config = dev->config; in swt_nxp_s32_disable()
207 struct swt_nxp_s32_data *data = dev->data; in swt_nxp_s32_disable()
212 return -EFAULT; in swt_nxp_s32_disable()
226 data->timeout_valid = false; in swt_nxp_s32_disable()
234 const struct swt_nxp_s32_config *config = dev->config; in swt_nxp_s32_install_timeout()
235 struct swt_nxp_s32_data *data = dev->data; in swt_nxp_s32_install_timeout()
238 uint32_t period; in swt_nxp_s32_install_timeout() local
242 if (data->timeout_valid) { in swt_nxp_s32_install_timeout()
244 return -ENOMEM; in swt_nxp_s32_install_timeout()
247 err = clock_control_get_rate(config->clock_dev, config->clock_subsys, &clock_rate); in swt_nxp_s32_install_timeout()
253 period = clock_rate / 1000U * cfg->window.max; in swt_nxp_s32_install_timeout()
255 if (cfg->window.min) { in swt_nxp_s32_install_timeout()
257 window = clock_rate / 1000U * (cfg->window.max - cfg->window.min); in swt_nxp_s32_install_timeout()
260 if ((period < SWT_TO_WTO_MIN) || (period < window)) { in swt_nxp_s32_install_timeout()
261 LOG_ERR("Invalid timeout"); in swt_nxp_s32_install_timeout()
262 return -EINVAL; in swt_nxp_s32_install_timeout()
265 data->timeout.period = period; in swt_nxp_s32_install_timeout()
266 data->timeout.window_start = window; in swt_nxp_s32_install_timeout()
267 data->timeout.window_mode = window_mode; in swt_nxp_s32_install_timeout()
268 data->callback = cfg->callback; in swt_nxp_s32_install_timeout()
269 data->timeout_valid = true; in swt_nxp_s32_install_timeout()
270 LOG_DBG("Installed timeout: period=%d, window=%d (%s)", in swt_nxp_s32_install_timeout()
271 period, window, window_mode ? "enabled" : "disabled"); in swt_nxp_s32_install_timeout()
278 const struct swt_nxp_s32_config *config = dev->config; in swt_nxp_s32_feed()
284 switch (config->service_mode) { in swt_nxp_s32_feed()
304 if (match_unlock_seq && (config->lock_mode == SWT_SOFT_LOCK)) { in swt_nxp_s32_feed()
315 err = -EINVAL; in swt_nxp_s32_feed()
326 const struct swt_nxp_s32_config *config = dev->config; in swt_nxp_s32_isr()
327 struct swt_nxp_s32_data *data = dev->data; in swt_nxp_s32_isr()
337 if (data->callback) { in swt_nxp_s32_isr()
339 data->callback(dev, 0U); in swt_nxp_s32_isr()
346 const struct swt_nxp_s32_config *config = dev->config; in swt_nxp_s32_init()
349 if (!device_is_ready(config->clock_dev)) { in swt_nxp_s32_init()
350 return -ENODEV; in swt_nxp_s32_init()
353 err = clock_control_on(config->clock_dev, config->clock_subsys); in swt_nxp_s32_init()
359 SWT_CR_MAP(config->master_access_mask) | in swt_nxp_s32_init()
360 SWT_CR_RIA(config->reset_on_invalid_access) | in swt_nxp_s32_init()
361 SWT_CR_SMD(config->service_mode)); in swt_nxp_s32_init()