Lines Matching +full:timer +full:- +full:triggered
3 * SPDX-License-Identifier: Apache-2.0
42 const struct wdt_it8xxx2_config *const wdt_config = dev->config; in wdt_it8xxx2_install_timeout()
43 struct wdt_it8xxx2_data *data = dev->data; in wdt_it8xxx2_install_timeout()
44 struct wdt_it8xxx2_regs *const inst = wdt_config->base; in wdt_it8xxx2_install_timeout()
47 if ((inst->ETWCFG) & IT8XXX2_WDT_LEWDCNTL) { in wdt_it8xxx2_install_timeout()
48 return -EBUSY; in wdt_it8xxx2_install_timeout()
55 if ((config->window.min != 0) || (config->window.max == 0)) { in wdt_it8xxx2_install_timeout()
56 data->timeout_installed = false; in wdt_it8xxx2_install_timeout()
57 return -EINVAL; in wdt_it8xxx2_install_timeout()
61 data->timeout = config->window.max; in wdt_it8xxx2_install_timeout()
64 data->callback = config->callback; in wdt_it8xxx2_install_timeout()
67 data->timeout_installed = true; in wdt_it8xxx2_install_timeout()
74 const struct wdt_it8xxx2_config *const wdt_config = dev->config; in wdt_it8xxx2_setup()
75 struct wdt_it8xxx2_data *data = dev->data; in wdt_it8xxx2_setup()
76 struct wdt_it8xxx2_regs *const inst = wdt_config->base; in wdt_it8xxx2_setup()
77 uint16_t cnt0 = WARNING_TIMER_PERIOD_MS_TO_1024HZ_COUNT(data->timeout); in wdt_it8xxx2_setup()
78 uint16_t cnt1 = WARNING_TIMER_PERIOD_MS_TO_1024HZ_COUNT((data->timeout in wdt_it8xxx2_setup()
81 /* disable pre-warning timer1 interrupt */ in wdt_it8xxx2_setup()
84 if (!data->timeout_installed) { in wdt_it8xxx2_setup()
86 return -EINVAL; in wdt_it8xxx2_setup()
89 if ((inst->ETWCFG) & IT8XXX2_WDT_LEWDCNTL) { in wdt_it8xxx2_setup()
91 return -EBUSY; in wdt_it8xxx2_setup()
96 return -ENOTSUP; in wdt_it8xxx2_setup()
99 /* pre-warning timer1 is 16-bit counter down timer */ in wdt_it8xxx2_setup()
100 inst->ET1CNTLHR = (cnt0 >> 8) & 0xff; in wdt_it8xxx2_setup()
101 inst->ET1CNTLLR = cnt0 & 0xff; in wdt_it8xxx2_setup()
103 /* clear pre-warning timer1 interrupt status */ in wdt_it8xxx2_setup()
106 /* enable pre-warning timer1 interrupt */ in wdt_it8xxx2_setup()
109 /* don't stop watchdog timer counting */ in wdt_it8xxx2_setup()
110 inst->ETWCTRL &= ~IT8XXX2_WDT_EWDSCEN; in wdt_it8xxx2_setup()
112 /* set watchdog timer count */ in wdt_it8xxx2_setup()
113 inst->EWDCNTHR = (cnt1 >> 8) & 0xff; in wdt_it8xxx2_setup()
114 inst->EWDCNTLR = cnt1 & 0xff; in wdt_it8xxx2_setup()
117 inst->ETWCFG &= ~IT8XXX2_WDT_LET1CNTL; in wdt_it8xxx2_setup()
125 inst->ETWCFG = (IT8XXX2_WDT_EWDKEYEN | in wdt_it8xxx2_setup()
136 * reload the WDT and pre-warning timer1 counter
144 const struct wdt_it8xxx2_config *const wdt_config = dev->config; in wdt_it8xxx2_feed()
145 struct wdt_it8xxx2_data *data = dev->data; in wdt_it8xxx2_feed()
146 struct wdt_it8xxx2_regs *const inst = wdt_config->base; in wdt_it8xxx2_feed()
147 uint16_t cnt0 = WARNING_TIMER_PERIOD_MS_TO_1024HZ_COUNT(data->timeout); in wdt_it8xxx2_feed()
151 /* reset pre-warning timer1 */ in wdt_it8xxx2_feed()
152 inst->ETWCTRL |= IT8XXX2_WDT_ET1RST; in wdt_it8xxx2_feed()
154 /* restart watchdog timer */ in wdt_it8xxx2_feed()
155 inst->EWDKEYR = IT8XXX2_WATCHDOG_MAGIC_BYTE; in wdt_it8xxx2_feed()
157 /* reset pre-warning timer1 to default if time is touched */ in wdt_it8xxx2_feed()
161 /* pre-warning timer1 is 16-bit counter down timer */ in wdt_it8xxx2_feed()
162 inst->ET1CNTLHR = (cnt0 >> 8) & 0xff; in wdt_it8xxx2_feed()
163 inst->ET1CNTLLR = cnt0 & 0xff; in wdt_it8xxx2_feed()
179 const struct wdt_it8xxx2_config *const wdt_config = dev->config; in wdt_it8xxx2_disable()
180 struct wdt_it8xxx2_data *data = dev->data; in wdt_it8xxx2_disable()
181 struct wdt_it8xxx2_regs *const inst = wdt_config->base; in wdt_it8xxx2_disable()
183 /* stop watchdog timer counting */ in wdt_it8xxx2_disable()
184 inst->ETWCTRL |= IT8XXX2_WDT_EWDSCEN; in wdt_it8xxx2_disable()
187 inst->ETWCFG &= ~IT8XXX2_WDT_LEWDCNTL; in wdt_it8xxx2_disable()
189 /* disable pre-warning timer1 interrupt */ in wdt_it8xxx2_disable()
193 data->timeout_installed = false; in wdt_it8xxx2_disable()
202 const struct wdt_it8xxx2_config *const wdt_config = dev->config; in wdt_it8xxx2_isr()
203 struct wdt_it8xxx2_data *data = dev->data; in wdt_it8xxx2_isr()
204 struct wdt_it8xxx2_regs *const inst = wdt_config->base; in wdt_it8xxx2_isr()
206 /* clear pre-warning timer1 interrupt status */ in wdt_it8xxx2_isr()
209 /* reset pre-warning timer1 */ in wdt_it8xxx2_isr()
210 inst->ETWCTRL |= IT8XXX2_WDT_ET1RST; in wdt_it8xxx2_isr()
213 if (data->callback) { in wdt_it8xxx2_isr()
214 data->callback(dev, 0); in wdt_it8xxx2_isr()
219 * Once warning timer triggered: if watchdog timer isn't reloaded, in wdt_it8xxx2_isr()
220 * then we will reduce interval of warning timer to 30ms to print in wdt_it8xxx2_isr()
226 /* pre-warning timer1 is 16-bit counter down timer */ in wdt_it8xxx2_isr()
227 inst->ET1CNTLHR = (cnt0 >> 8) & 0xff; in wdt_it8xxx2_isr()
228 inst->ET1CNTLLR = cnt0 & 0xff; in wdt_it8xxx2_isr()
230 /* clear pre-warning timer1 interrupt status */ in wdt_it8xxx2_isr()
248 const struct wdt_it8xxx2_config *const wdt_config = dev->config; in wdt_it8xxx2_init()
249 struct wdt_it8xxx2_regs *const inst = wdt_config->base; in wdt_it8xxx2_init()
256 inst->ETWCFG = 0x00; in wdt_it8xxx2_init()
259 inst->ET1PSR = IT8XXX2_WDT_ETPS_1P024_KHZ; in wdt_it8xxx2_init()
262 inst->ETWCFG = (IT8XXX2_WDT_EWDKEYEN | in wdt_it8xxx2_init()
269 inst->ETWCTRL |= IT8XXX2_WDT_EWDSCMS; in wdt_it8xxx2_init()