Lines Matching +full:in +full:- +full:min
4 * SPDX-License-Identifier: Apache-2.0
13 * - Once the watchdog disable bit is set, it cannot be cleared till next
15 * - Since the MCU boots with WDT enabled, the CONFIG_WDT_DISABLE_AT_BOOT
16 * is set default at boot and watchdog module is disabled in the MCU for
18 * - If the application needs to use the watchdog in the system, then
19 * CONFIG_WDT_DISABLE_AT_BOOT must be unset in the app's config file
49 const struct wdt_sam_dev_cfg *config = dev->config; in wdt_sam_isr()
51 Wdt * const wdt = config->regs; in wdt_sam_isr()
52 struct wdt_sam_dev_data *data = dev->data; in wdt_sam_isr()
55 wdt_sr = wdt->WDT_SR; in wdt_sam_isr()
57 data->cb(dev, 0); in wdt_sam_isr()
62 * to be installed in the watchdog timer
64 * @param timeout Timeout value in milliseconds.
65 * @param slow clock on board in Hz.
69 uint32_t max, min; in wdt_sam_convert_timeout() local
72 min = (SAM_PRESCALAR * 1000000) / sclk; in wdt_sam_convert_timeout()
73 max = min * WDT_MAX_VALUE; in wdt_sam_convert_timeout()
74 if ((timeout < min) || (timeout > max)) { in wdt_sam_convert_timeout()
76 "%d ms to %d ms", min / 1000U, max / 1000U); in wdt_sam_convert_timeout()
77 return -EINVAL; in wdt_sam_convert_timeout()
80 return WDT_MR_WDV(timeout / min); in wdt_sam_convert_timeout()
85 const struct wdt_sam_dev_cfg *config = dev->config; in wdt_sam_disable()
87 Wdt * const wdt = config->regs; in wdt_sam_disable()
88 struct wdt_sam_dev_data *data = dev->data; in wdt_sam_disable()
90 /* since Watchdog mode register is 'write-once', we can't disable if in wdt_sam_disable()
93 if (data->mode_set) { in wdt_sam_disable()
94 return -EPERM; in wdt_sam_disable()
97 /* do we handle -EFAULT here */ in wdt_sam_disable()
99 /* Watchdog Mode register is 'write-once' only register. in wdt_sam_disable()
102 wdt->WDT_MR |= WDT_MR_WDDIS; in wdt_sam_disable()
103 data->mode_set = true; in wdt_sam_disable()
110 const struct wdt_sam_dev_cfg *config = dev->config; in wdt_sam_setup()
112 Wdt * const wdt = config->regs; in wdt_sam_setup()
113 struct wdt_sam_dev_data *data = dev->data; in wdt_sam_setup()
115 if (!data->timeout_valid) { in wdt_sam_setup()
117 return -EINVAL; in wdt_sam_setup()
120 /* since Watchdog mode register is 'write-once', we can't set if in wdt_sam_setup()
123 if (data->mode_set) { in wdt_sam_setup()
124 return -EPERM; in wdt_sam_setup()
128 data->mode |= WDT_MR_WDIDLEHLT; in wdt_sam_setup()
133 data->mode |= WDT_MR_WDDBGHLT; in wdt_sam_setup()
136 wdt->WDT_MR = data->mode; in wdt_sam_setup()
137 data->mode_set = true; in wdt_sam_setup()
148 struct wdt_sam_dev_data *data = dev->data; in wdt_sam_install_timeout()
150 if (data->timeout_valid) { in wdt_sam_install_timeout()
152 return -ENOMEM; in wdt_sam_install_timeout()
155 if (cfg->window.min != 0U) { in wdt_sam_install_timeout()
156 return -EINVAL; in wdt_sam_install_timeout()
162 * in the max field of the timeout config. in wdt_sam_install_timeout()
164 timeout_value = wdt_sam_convert_timeout(cfg->window.max, in wdt_sam_install_timeout()
168 return -EINVAL; in wdt_sam_install_timeout()
171 switch (cfg->flags) { in wdt_sam_install_timeout()
179 if (cfg->callback) { in wdt_sam_install_timeout()
181 data->cb = cfg->callback; in wdt_sam_install_timeout()
184 return -EINVAL; in wdt_sam_install_timeout()
188 /* Processor only reset mode not available in same70 series */ in wdt_sam_install_timeout()
199 return -ENOTSUP; in wdt_sam_install_timeout()
202 data->mode = wdt_mode | in wdt_sam_install_timeout()
206 data->timeout_valid = true; in wdt_sam_install_timeout()
213 const struct wdt_sam_dev_cfg *config = dev->config; in wdt_sam_feed()
217 * reloaded/fed with the 12-bit watchdog counter in wdt_sam_feed()
220 Wdt * const wdt = config->regs; in wdt_sam_feed()
222 wdt->WDT_CR |= WDT_CR_KEY_PASSWD | WDT_CR_WDRSTT; in wdt_sam_feed()