Lines Matching refs:dev

57 #define DEV_CFG(dev) \  argument
58 ((const struct wdt_esp32_config *const)(dev)->config)
59 #define DEV_DATA(dev) \ argument
60 ((struct wdt_esp32_data *)(dev)->data)
61 #define DEV_BASE(dev) \ argument
62 ((volatile struct wdt_esp32_regs_t *)(DEV_CFG(dev))->base)
68 static inline void wdt_esp32_seal(const struct device *dev) in wdt_esp32_seal() argument
70 DEV_BASE(dev)->wprotect = 0U; in wdt_esp32_seal()
74 static inline void wdt_esp32_unseal(const struct device *dev) in wdt_esp32_unseal() argument
76 DEV_BASE(dev)->wprotect = TIMG_WDT_WKEY_VALUE; in wdt_esp32_unseal()
79 static void wdt_esp32_enable(const struct device *dev) in wdt_esp32_enable() argument
81 wdt_esp32_unseal(dev); in wdt_esp32_enable()
82 DEV_BASE(dev)->config0 |= BIT(TIMG_WDT_EN_S); in wdt_esp32_enable()
83 wdt_esp32_seal(dev); in wdt_esp32_enable()
87 static int wdt_esp32_disable(const struct device *dev) in wdt_esp32_disable() argument
89 wdt_esp32_unseal(dev); in wdt_esp32_disable()
90 DEV_BASE(dev)->config0 &= ~BIT(TIMG_WDT_EN_S); in wdt_esp32_disable()
91 wdt_esp32_seal(dev); in wdt_esp32_disable()
96 static void adjust_timeout(const struct device *dev, uint32_t timeout) in adjust_timeout() argument
101 DEV_BASE(dev)->config1 = 40000U; in adjust_timeout()
102 DEV_BASE(dev)->config2 = timeout; in adjust_timeout()
103 DEV_BASE(dev)->config3 = timeout; in adjust_timeout()
108 static int wdt_esp32_feed(const struct device *dev, int channel_id) in wdt_esp32_feed() argument
110 wdt_esp32_unseal(dev); in wdt_esp32_feed()
111 DEV_BASE(dev)->feed = 0xABAD1DEA; /* Writing any value to WDTFEED will reload it. */ in wdt_esp32_feed()
112 wdt_esp32_seal(dev); in wdt_esp32_feed()
117 static void set_interrupt_enabled(const struct device *dev, bool setting) in set_interrupt_enabled() argument
119 *DEV_CFG(dev)->irq_regs.timer_int_clr |= TIMG_WDT_INT_CLR; in set_interrupt_enabled()
122 *DEV_CFG(dev)->irq_regs.timer_int_ena |= TIMG_WDT_INT_ENA; in set_interrupt_enabled()
123 irq_enable(DEV_DATA(dev)->irq_line); in set_interrupt_enabled()
125 *DEV_CFG(dev)->irq_regs.timer_int_ena &= ~TIMG_WDT_INT_ENA; in set_interrupt_enabled()
126 irq_disable(DEV_DATA(dev)->irq_line); in set_interrupt_enabled()
130 static int wdt_esp32_set_config(const struct device *dev, uint8_t options) in wdt_esp32_set_config() argument
132 struct wdt_esp32_data *data = DEV_DATA(dev); in wdt_esp32_set_config()
133 uint32_t v = DEV_BASE(dev)->config0; in wdt_esp32_set_config()
166 wdt_esp32_unseal(dev); in wdt_esp32_set_config()
167 DEV_BASE(dev)->config0 = v; in wdt_esp32_set_config()
168 adjust_timeout(dev, data->timeout); in wdt_esp32_set_config()
169 set_interrupt_enabled(dev, data->mode == WDT_MODE_INTERRUPT_RESET); in wdt_esp32_set_config()
170 wdt_esp32_seal(dev); in wdt_esp32_set_config()
172 wdt_esp32_feed(dev, 0); in wdt_esp32_set_config()
177 static int wdt_esp32_install_timeout(const struct device *dev, in wdt_esp32_install_timeout() argument
180 struct wdt_esp32_data *data = DEV_DATA(dev); in wdt_esp32_install_timeout()
200 static int wdt_esp32_init(const struct device *dev) in wdt_esp32_init() argument
202 const struct wdt_esp32_config *const config = DEV_CFG(dev); in wdt_esp32_init()
203 struct wdt_esp32_data *data = DEV_DATA(dev); in wdt_esp32_init()
206 wdt_esp32_disable(dev); in wdt_esp32_init()
212 data->irq_line = esp_intr_alloc(config->irq_source, 0, wdt_esp32_isr, (void *)dev, NULL); in wdt_esp32_init()
214 wdt_esp32_enable(dev); in wdt_esp32_init()
247 const struct device *dev = (const struct device *)arg; in wdt_esp32_isr() local
248 struct wdt_esp32_data *data = DEV_DATA(dev); in wdt_esp32_isr()
251 data->callback(dev, 0); in wdt_esp32_isr()
254 *DEV_CFG(dev)->irq_regs.timer_int_clr |= TIMG_WDT_INT_CLR; in wdt_esp32_isr()