Lines Matching +full:out +full:- +full:max

10  * SPDX-License-Identifier: Apache-2.0
63 const struct xilinx_wdt_axi_config *config = dev->config; in wdt_xilinx_axi_setup()
64 struct xilinx_wdt_axi_data *data = dev->data; in wdt_xilinx_axi_setup()
65 k_spinlock_key_t key = k_spin_lock(&data->lock); in wdt_xilinx_axi_setup()
68 if (!data->timeout_active) { in wdt_xilinx_axi_setup()
69 ret = -EINVAL; in wdt_xilinx_axi_setup()
70 goto out; in wdt_xilinx_axi_setup()
73 if (data->wdt_started) { in wdt_xilinx_axi_setup()
74 ret = -EBUSY; in wdt_xilinx_axi_setup()
75 goto out; in wdt_xilinx_axi_setup()
82 sys_write32(CSR0_EWDT1 | CSR0_WDS, config->base + REG_TWCSR0); in wdt_xilinx_axi_setup()
83 sys_write32(CSR1_EWDT2, config->base + REG_TWCSR1); in wdt_xilinx_axi_setup()
84 data->wdt_started = true; in wdt_xilinx_axi_setup()
87 out: in wdt_xilinx_axi_setup()
88 k_spin_unlock(&data->lock, key); in wdt_xilinx_axi_setup()
94 const struct xilinx_wdt_axi_config *config = dev->config; in wdt_xilinx_axi_disable()
95 struct xilinx_wdt_axi_data *data = dev->data; in wdt_xilinx_axi_disable()
96 k_spinlock_key_t key = k_spin_lock(&data->lock); in wdt_xilinx_axi_disable()
99 if (config->enable_once) { in wdt_xilinx_axi_disable()
100 ret = -EPERM; in wdt_xilinx_axi_disable()
101 goto out; in wdt_xilinx_axi_disable()
104 if (!data->wdt_started) { in wdt_xilinx_axi_disable()
105 ret = -EFAULT; in wdt_xilinx_axi_disable()
106 goto out; in wdt_xilinx_axi_disable()
109 sys_write32(CSR0_WDS, config->base + REG_TWCSR0); in wdt_xilinx_axi_disable()
110 sys_write32(0, config->base + REG_TWCSR1); in wdt_xilinx_axi_disable()
111 data->wdt_started = false; in wdt_xilinx_axi_disable()
114 out: in wdt_xilinx_axi_disable()
115 k_spin_unlock(&data->lock, key); in wdt_xilinx_axi_disable()
122 const struct xilinx_wdt_axi_config *config = dev->config; in wdt_xilinx_axi_install_timeout()
123 struct xilinx_wdt_axi_data *data = dev->data; in wdt_xilinx_axi_install_timeout()
124 k_spinlock_key_t key = k_spin_lock(&data->lock); in wdt_xilinx_axi_install_timeout()
129 if (data->timeout_active) { in wdt_xilinx_axi_install_timeout()
130 ret = -ENOMEM; in wdt_xilinx_axi_install_timeout()
131 goto out; in wdt_xilinx_axi_install_timeout()
134 if (!(cfg->flags & WDT_FLAG_RESET_SOC)) { in wdt_xilinx_axi_install_timeout()
135 ret = -ENOTSUP; in wdt_xilinx_axi_install_timeout()
136 goto out; in wdt_xilinx_axi_install_timeout()
139 if (cfg->window.min != 0) { in wdt_xilinx_axi_install_timeout()
140 ret = -EINVAL; in wdt_xilinx_axi_install_timeout()
141 goto out; in wdt_xilinx_axi_install_timeout()
144 for (timer_width = TIMER_WIDTH_MIN; timer_width <= config->timer_width_max; timer_width++) { in wdt_xilinx_axi_install_timeout()
149 const uint64_t expiry_msec = expiry_cycles * 1000 / config->clock_rate; in wdt_xilinx_axi_install_timeout()
151 if (expiry_msec >= cfg->window.max) { in wdt_xilinx_axi_install_timeout()
160 LOG_ERR("Cannot support timeout value of %u msec", cfg->window.max); in wdt_xilinx_axi_install_timeout()
161 ret = -EINVAL; in wdt_xilinx_axi_install_timeout()
162 goto out; in wdt_xilinx_axi_install_timeout()
165 sys_write32(timer_width, config->base + REG_MWR); in wdt_xilinx_axi_install_timeout()
166 data->timeout_active = true; in wdt_xilinx_axi_install_timeout()
169 out: in wdt_xilinx_axi_install_timeout()
170 k_spin_unlock(&data->lock, key); in wdt_xilinx_axi_install_timeout()
176 const struct xilinx_wdt_axi_config *config = dev->config; in wdt_xilinx_axi_feed()
177 struct xilinx_wdt_axi_data *data = dev->data; in wdt_xilinx_axi_feed()
178 k_spinlock_key_t key = k_spin_lock(&data->lock); in wdt_xilinx_axi_feed()
179 uint32_t twcsr0 = sys_read32(config->base + REG_TWCSR0); in wdt_xilinx_axi_feed()
182 if (channel_id != 0 || !data->timeout_active) { in wdt_xilinx_axi_feed()
183 ret = -EINVAL; in wdt_xilinx_axi_feed()
184 goto out; in wdt_xilinx_axi_feed()
188 if (data->wdt_started) { in wdt_xilinx_axi_feed()
192 sys_write32(twcsr0, config->base + REG_TWCSR0); in wdt_xilinx_axi_feed()
195 out: in wdt_xilinx_axi_feed()
196 k_spin_unlock(&data->lock, key); in wdt_xilinx_axi_feed()
218 return -ENOSYS; in z_impl_hwinfo_get_reset_cause()
221 const struct xilinx_wdt_axi_config *config = first_wdt_dev->config; in z_impl_hwinfo_get_reset_cause()
223 if ((sys_read32(config->base + REG_TWCSR0) & CSR0_WRS) != 0) { in z_impl_hwinfo_get_reset_cause()
235 return -ENOSYS; in z_impl_hwinfo_clear_reset_cause()
238 const struct xilinx_wdt_axi_config *config = first_wdt_dev->config; in z_impl_hwinfo_clear_reset_cause()
239 struct xilinx_wdt_axi_data *data = first_wdt_dev->data; in z_impl_hwinfo_clear_reset_cause()
241 k_spinlock_key_t key = k_spin_lock(&data->lock); in z_impl_hwinfo_clear_reset_cause()
242 uint32_t twcsr0 = sys_read32(config->base + REG_TWCSR0); in z_impl_hwinfo_clear_reset_cause()
246 sys_write32(twcsr0, config->base + REG_TWCSR0); in z_impl_hwinfo_clear_reset_cause()
249 k_spin_unlock(&data->lock, key); in z_impl_hwinfo_clear_reset_cause()
257 return -ENOSYS; in z_impl_hwinfo_get_supported_reset_cause()