Lines Matching +full:max +full:- +full:load +full:- +full:value
4 * SPDX-License-Identifier: Apache-2.0
20 /* Maximum watchdog time is halved due to errata RP2040-E1 */
32 uint32_t load; member
43 const struct wdt_rpi_pico_config *config = dev->config; in wdt_rpi_pico_setup()
44 struct wdt_rpi_pico_data *data = dev->data; in wdt_rpi_pico_setup()
49 return -ENOTSUP; in wdt_rpi_pico_setup()
52 hw_clear_bits(&watchdog_hw->ctrl, WATCHDOG_CTRL_ENABLE_BITS); in wdt_rpi_pico_setup()
54 psm_hw->wdsel = 0; in wdt_rpi_pico_setup()
57 if (data->reset_type == WDT_FLAG_RESET_SOC) { in wdt_rpi_pico_setup()
58 hw_set_bits(&psm_hw->wdsel, PSM_WDSEL_BITS); in wdt_rpi_pico_setup()
59 } else if (data->reset_type == WDT_FLAG_RESET_CPU_CORE) { in wdt_rpi_pico_setup()
60 hw_set_bits(&psm_hw->wdsel, PSM_WDSEL_PROC0_BITS); in wdt_rpi_pico_setup()
64 hw_clear_bits(&watchdog_hw->ctrl, in wdt_rpi_pico_setup()
68 hw_set_bits(&watchdog_hw->ctrl, in wdt_rpi_pico_setup()
73 watchdog_hw->load = data->load; in wdt_rpi_pico_setup()
78 watchdog_hw->scratch[4] = 0; in wdt_rpi_pico_setup()
79 watchdog_hw->scratch[5] = 0; in wdt_rpi_pico_setup()
80 watchdog_hw->scratch[6] = 0; in wdt_rpi_pico_setup()
81 watchdog_hw->scratch[7] = 0; in wdt_rpi_pico_setup()
83 hw_set_bits(&watchdog_hw->ctrl, WATCHDOG_CTRL_ENABLE_BITS); in wdt_rpi_pico_setup()
85 data->enabled = true; in wdt_rpi_pico_setup()
87 err = clock_control_on(config->clk_dev, config->clk_id); in wdt_rpi_pico_setup()
92 err = clock_control_get_rate(config->clk_dev, config->clk_id, &ref_clk); in wdt_rpi_pico_setup()
98 watchdog_hw->tick = (ref_clk / RPI_PICO_CLK_REF_FREQ_WDT_TICK_DIVISOR) | in wdt_rpi_pico_setup()
101 ticks_hw->ticks[TICK_WATCHDOG].cycles = ref_clk / RPI_PICO_CLK_REF_FREQ_WDT_TICK_DIVISOR; in wdt_rpi_pico_setup()
102 ticks_hw->ticks[TICK_WATCHDOG].ctrl = TICKS_WATCHDOG_CTRL_ENABLE_BITS; in wdt_rpi_pico_setup()
110 struct wdt_rpi_pico_data *data = dev->data; in wdt_rpi_pico_disable()
112 if (data->enabled == false) { in wdt_rpi_pico_disable()
113 return -EFAULT; in wdt_rpi_pico_disable()
116 hw_clear_bits(&watchdog_hw->ctrl, WATCHDOG_CTRL_ENABLE_BITS); in wdt_rpi_pico_disable()
118 data->enabled = false; in wdt_rpi_pico_disable()
125 struct wdt_rpi_pico_data *data = dev->data; in wdt_rpi_pico_install_timeout()
127 if (cfg->window.min != 0U || cfg->window.max == 0U) { in wdt_rpi_pico_install_timeout()
128 return -EINVAL; in wdt_rpi_pico_install_timeout()
129 } else if (cfg->window.max * USEC_PER_MSEC > RPI_PICO_MAX_WDT_TIME) { in wdt_rpi_pico_install_timeout()
130 return -EINVAL; in wdt_rpi_pico_install_timeout()
131 } else if (cfg->callback != NULL) { in wdt_rpi_pico_install_timeout()
132 return -ENOTSUP; in wdt_rpi_pico_install_timeout()
133 } else if ((cfg->flags & WDT_FLAG_RESET_MASK) == WDT_FLAG_RESET_NONE) { in wdt_rpi_pico_install_timeout()
135 * a program counter and stack pointer value to be set, in wdt_rpi_pico_install_timeout()
138 return -EINVAL; in wdt_rpi_pico_install_timeout()
141 data->load = (cfg->window.max * USEC_PER_MSEC * RPI_PICO_WDT_TIME_MULTIPLICATION_FACTOR); in wdt_rpi_pico_install_timeout()
142 data->reset_type = (cfg->flags & WDT_FLAG_RESET_MASK); in wdt_rpi_pico_install_timeout()
149 struct wdt_rpi_pico_data *data = dev->data; in wdt_rpi_pico_feed()
153 return -EINVAL; in wdt_rpi_pico_feed()
156 if (data->enabled == false) { in wdt_rpi_pico_feed()
158 return -EINVAL; in wdt_rpi_pico_feed()
161 watchdog_hw->load = data->load; in wdt_rpi_pico_feed()
189 .load = (CONFIG_WDT_RPI_PICO_INITIAL_TIMEOUT * \