summaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
Commit message (Collapse)AuthorAgeFilesLines
* watchdog: dw_wdt: fix resource reservation error checkAhmad Fatoum2021-06-211-2/+3
| | | | | | | | | dev_request_mem_resource returns a possible error pointer. If it succeeds mem->start will always be valid. Rectify the confusion. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210621064719.19246-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/wdt'Sascha Hauer2021-06-161-4/+11
|\
| * watchdog: dw_wdt: denote message to debug levelSascha Hauer2021-06-111-1/+1
| | | | | | | | | | | | | | | | | | | | dw_wdt may be unstoppable once started when no reset line is available. This behaviour is quite common for different watchdogs, it is not worth issuing a warning. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210610130613.27983-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * watchdog: dw_wdt: set maximum timeoutSascha Hauer2021-06-111-4/+5
| | | | | | | | | | | | | | | | Communicate the maximum possible timeout to the watchdog core. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210610130613.27983-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * watchdog: dw_wdt: Detect if running initiallySascha Hauer2021-06-111-0/+3
| | | | | | | | | | | | | | | | Let the watchdog core know if the watchdog is currently running or not. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210610130613.27983-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * watchdog: dw_wdt: Write counter restart registerSascha Hauer2021-06-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | At least some variants of the dwc watchdog controllers need the value 0x76 written to the counter restart register to actually take the value written to the Timeout range register. Happened on Rockchip RK3568, without this the watchdog immediately resets the system. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210610130613.27983-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | watchdog: add option to provide fall-back restart handlerAhmad Fatoum2021-06-091-0/+26
|/ | | | | | | | | | | Some barebox ports may have a watchdog, but no restart handler, e.g. reset happens via PMIC, which has no driver yet, but watchdog controls reset line going to PMIC. Accommodate such setups by allowing registration of watchdog as fall back restart handler. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210531071319.32459-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/x86'Sascha Hauer2021-05-173-0/+364
|\
| * watchdog: add support for Intel TCO watchdog timerAhmad Fatoum2021-05-033-0/+364
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Variants of the iTCO are integrated into many Intel southbridges. They are most often accessed via PCI. Add a driver for the variant found in the q35 QEMU machine. It should be straight forward to extend the itco_chipset_info array to support more variants in future as the need arises. To test, use: qemu-system-x86_64 -M q35 -global ICH9-LPC.noreboot=false The last option corresponds to a pin strap option, which can't be influenced from within the VM. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20210416062436.332665-5-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | watchdog: imxwd: get and enable clockSteffen Trumtrar2021-05-031-0/+11
|/ | | | | | | | | This it (at least) necessary for i.MX7s or otherwise barebox will hang when trying to access the registers of WDOG2/3/4. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Link: https://lore.barebox.org/20210419123747.2373-1-s.trumtrar@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* watchdog: add GPIO watchdog driverAhmad Fatoum2021-04-133-0/+150
| | | | | | | This is a straight port from Linux v5.11. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.pengutronix.de/20210410103511.2073504-5-ahmad@a3f.at
* Merge branch 'for-next/misc'Sascha Hauer2021-02-221-0/+29
|\
| * watchdog: Print seconds to expireSascha Hauer2021-02-161-0/+29
| | | | | | | | | | | | | | | | | | | | This adds a parameter to the watchdog devices that shows what we think when the watchdog expires. The watchdog should reset the system once the counter hits zero. When the system resets earlier or the counter shows negative values then there might be problems with the watchdog. Useful for debugging watchdog related problems. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | watchdog: stpmic1-wdt: don't modify global turn-off behaviour in probeLeonard Göhrs2021-02-121-4/+0
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to Table 12 in the STPMIC1-datasheet (Rev 7 - December 2020) there are the following turn-OFF conditions: - Software switch-OFF* - PONKEYn long key press* - Thermal shutdown - Overcurrent protection - Watchdog* - VIN_OK_Fall* The conditions marked with an * can be re-configured from turn-Off conditions to restart requests using the RREQ_EN-bit in the CR register (Called RESTART_REQUEST_ENABLED in Linux/Barebox). The watchdog code enabled this bit in it's probe function to trigger a restart on a watchdog event. This may however result in unexpected behaviour, like a long-press of the PONKEY resulting in a restart instead of a turn-off when the watchdog is enabled vs. when it is not. This change does not affect the restart and poweroff functionality provided by the wdt driver, as the restart-/poweroff-handlers explicitly set/clear the RESTART_REQUEST_ENABLED flag when triggering a software turn-OFF. To prevent unexpected behaviour of the PONKEYn and other turn-OFF sources the RESTART_REQUEST_ENABLED configuration in the probe function can and should thus be removed. Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* watchdog: implement watchdog_get_alias_id_fromAhmad Fatoum2020-11-301-0/+19
| | | | | | | | | | | | | | | On device-tree enabled platforms, the Linux kernel will first attempt to use watchdog%d as watchdog name, where %d is the alias id. Add a function that given a barebox struct watchdog and the device tree root node of the kernel device tree, computes the corresponding kernel alias id. This may then later be used to pass an appropriate argument on the kernel command line. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/driver-macro' into masterSascha Hauer2020-10-142-10/+2
|\
| * treewide: Use driver macroSascha Hauer2020-09-292-10/+2
| | | | | | | | | | | | | | We have several macros for a oneline driver registration. Add some missing and use them consistently where possible througout the tree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | watchdog: fix division-by-zero when clock rate == 0Ahmad Fatoum2020-10-023-14/+28
|/ | | | | | | | | | | | Instead of storing the clk into the driver's device-specific private data, just store the rate and make sure it's != 0 on probe. This aligns us with what Linux does for the STM32 IWDG and DW WDT. Reported-by: clang-analyzer-10 Cc: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc' into masterSascha Hauer2020-09-252-2/+2
|\
| * mfd: stpmic1: warn if reset reason detection failsAhmad Fatoum2020-09-141-1/+1
| | | | | | | | | | | | | | | | stpmic1_set_reset_reason returns an error code, but so far we didn't check it. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * treewide: s/filed/failed/Sascha Hauer2020-08-241-1/+1
| | | | | | | | | | | | Fix typos. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | watchdog: fix watchdog_set_timeout breakage for drivers like imxwdAhmad Fatoum2020-08-201-1/+1
|/ | | | | | | | | | | | | | | | | | | | Commit 0b944fce55f4 ("watchdog: permit `wd 0` for non-stoppable, but inactive, watchdogs") silently broke use of watchdogs, that report being inactive at driver probe time, altogether. Because those always had watchdog_hw_running evaluating to false, it early exited without a chance to ever actually set the timeout (and for watchdog_hw_running to evaluate to != false). This results in following watchdog drivers being broken in v2020.08.0: - imxwd - f71808e_wdt - at91sam9_wdt Fixes: 0b944fce55f4 ("watchdog: permit `wd 0` for non-stoppable, but inactive, watchdogs") Reported-by: Bastian Krause <bst@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/watchdog'Sascha Hauer2020-07-271-0/+30
|\
| * startup: inhibit watchdogs on non-interactive autoboot abortAhmad Fatoum2020-06-231-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | nv.autoboot=abort has been added as development aid to have barebox stop at the shell prompt automatically. It makes sense to inhibit all watchdogs in this mode, so the user can later use the shell in peace. This also applies to fastboot aborting the shell prompt. If this happens, watchdog will be automatically inhibited as well. Behavior on user aborting the shell prompt via keypad or uart input remains unchanged for backwards-compatibility. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * watchdog: permit `wd 0` for non-stoppable, but inactive, watchdogsAhmad Fatoum2020-06-231-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | A watchdog that can't be stopped returns -ENOSYS on set_timeout(0). If the watchdog supports communicating whether it's running, we could still allow `wd 0`, if it hasn't been started yet. Setting device parameter .priority=0 disables a watchdog. One would expect this to always succeed for a not-running watchdog, but currently it doesn't, if the driver's set_timeout(0) returns -ENOSYS. With this fix, this is supported making the user API less surprising. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2020-07-272-23/+41
|\ \
| * | treewide: make use of PTR_ERR_OR_ZEROUwe Kleine-König2020-06-261-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PTR_ERR_OR_ZERO is designed to replace boiler plate like: if (IS_ERR(x)) return PTR_ERR(x); return 0; Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | watchdog: f71808e: maintain watchdog timeout occurred flagAhmad Fatoum2020-06-171-19/+40
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we experience a watchdog reset, the indicating flag should persist till the Linux driver had a chance to see it. The flag bit is special however in that writing 1 clears the bit and writing 0 keeps it intact, i.e. : Bit read written result 0 0 = 0 1 0 = 1 0 1 = 0 1 1 = 0 So in the bootloader, we should write a zero always. The OS on the other hand can either write 1 or the old value after reading to clear the flag. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / watchdog: add support for at91sam9/sama5 watchdogAhmad Fatoum2020-07-113-0/+116
|/ | | | | | | | | | | | | | The watchdog on these SoCs is enabled by default on system boot, so a driver is especially useful. According to data sheet the mode register containing the timeout can be configured only once, but I couldn't verify this on the sama5d2. Regardless, the driver takes care not to change the mode register unless necessary. Implementation that want to leave to the OS the decision which timeout to choose, can just keep pinging with the POR-default of 16 seconds and the OS will be able to set the final timeout. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* poller: Give pollers a nameSascha Hauer2020-05-201-1/+1
| | | | | | It helps debugging when pollers have a name, so give them one. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mxs'Sascha Hauer2020-05-141-0/+9
|\
| * watchdog: i.MX28: Add device tree supportSascha Hauer2020-05-061-0/+9
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | drivers: mark first batch of compilable drivers for COMPILE_TESTAhmad Fatoum2020-05-081-9/+9
|/ | | | | | | | | All of these drivers have a runtime dependency on SoC peripherals, but can nevertheless be compile-tested. Add COMPILE_TEST as an alternate dependency. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* watchdog: kvx: Add kvx watchdog supportClement Leger2020-04-153-0/+101
| | | | | | | Add a watchdog for kvx architecture based on core watchdog. Signed-off-by: Clement Leger <cleger@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* reset: stm32: migrate restart reason and handler from stm32_iwdgAhmad Fatoum2020-02-191-99/+0
| | | | | | | | | | | | | The watchdog driver will remain unprobed if the driver or the OF node is disabled, but the reset reason is useful even then. System reset and reset source determination is achieved with the RCC peripheral for which we have a reset controller driver. Move the code over there, so reset reason and reset are available always. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* reset_source: migrate from reset_source_name to reset_source_to_stringAhmad Fatoum2020-02-192-2/+2
| | | | | | | | | | Whether reset_source_name() returns the just set reset_source is dependent on probe order and the priorities of prior reset sources in relation to the current one. Make this more robust by using the new reset_source_to_string. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* watchdog: f71808e: only print reset reason if one's indicatedAhmad Fatoum2020-02-191-4/+4
| | | | | | | | | | On most resets, a "reset reason: unknown" would clutter the console, because the watchdog doesn't support differentiating between POR and RST. Reduce the clutter by only printing the message when we have something interesting to say (i.e. watchdog reset). Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* watchdog: dw_wdt: remove duplicated error messageAhmad Fatoum2020-02-121-1/+1
| | | | | | | | | The wd command already warns that "Watchdog cannot be disabled", when the stop operation returns -ENOSYS. We do that now, so telling the user that it will not stop is superfluous. Remove it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* watchdog: dw_wdt: inform user on missing reset control lineAhmad Fatoum2020-02-121-4/+6
| | | | | | | | | | | | | | | The driver has an error message on probe and one on each watchdog stop attempt that warns the user if the reset line is missing. Missing reset line (because the "reset"-property is missing) is indicated by a NULL pointer though, so these warnings were only triggered when the reset controller specification is malformed. Fix this by propagating malformed reset pointer specification and continuing only if it's either valid or completely missing. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* watchdog: dw_wdt: populate driver_d.nameAhmad Fatoum2020-02-121-0/+1
| | | | | | | | | | | | | | Apparently, somewhere between v2017.01.0 and v2020.01.0, barebox became dependent on drivers having a name as having this driver enabled in v2020.01.0 has barebox crash due to a null pointer dereference in the device_match's second strcmp. A previous commit introduced a palatable warning for this case. Now in order to be able to use the driver again, give it a name. Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* watchdog: Fix error pathChristian Eggers2020-01-221-9/+21
| | | | | | | | In case of an error (e.g. dev_add_param_tristate_ro() returns -ENOSYS), device registration must be reverted. Signed-off-by: Christian Eggers <ceggers@arri.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/watchdog'Sascha Hauer2019-12-104-18/+52
|\
| * watchdog: core: use new dev_add_param_tristate helper for .running paramAhmad Fatoum2019-12-051-8/+1
| | | | | | | | | | | | | | | | | | Previous commit added a dev_add_param_tristate_ro that can be readily used instead of the enum parameter here. Use it. This also fixes the issue that running_names had external linkage. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * watchdog: stm32_iwdg: explicitly set .running to UNSUPPORTEDAhmad Fatoum2019-11-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've spent some time trying to get the ONF (Watchdog enable status) bit in the IWDG_SR register to read as something other than zero. It has since been confirmed to be non-functional[1]. To avoid someone else spending time on this, document that running status is unsupported on this hardware explicitly. No functional change as UNSUPPORTED is already the default. [1]: https://www.spinics.net/lists/arm-kernel/msg770527.html Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * watchdog: f71808e: support .running device parameterAhmad Fatoum2019-11-111-1/+6
| | | | | | | | | | | | | | | | | | The American Megatrends BIOS I am using can be configured to start the Fintek watchdog prior to the UEFI payloads. To avoid BIOS updates that reset this functionality going unnoticed, implement support for WDOG_HW_RUNNING. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * watchdog: imxwd: support .running device parameter on i.MX2+Ahmad Fatoum2019-11-111-0/+14
| | | | | | | | | | | | | | | | | | The i.MX can be fused to start the watchdog on power-on reset. To give users an easy way to determine whether the watchdog is running, implement support for WDOG_HW_RUNNING. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * watchdog: implement generic support for .running device parameterAhmad Fatoum2019-11-111-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Linux watchdog have an optional WDOG_HW_RUNNING bit that is used in conjunction with CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED to automatically ping running watchdogs until userspace takes over. So far, when we ported Linux drivers, we dropped this detection, but it would be useful to have this information in barebox as well: The American Megatrends BIOS I am using allows configuring the hardware watchdog from the BIOS. barebox enables the WDT as well, so in normal operation we would never notice if after a BIOS update, the watchdog is no longer enabled. If we maintain a running parameter on watchdog devices, board code can be written to check whether the watchdog device is indeed running. To achieve this, add the necessary bits to the watchdog API. How we go about it differs from Linux a little: - We use an enum instead of a single bit, so we can differentiate between watchdogs that are not running and watchdogs whose running status is unknown. - Because we can check whether watchdog_hw_running is supported, it now can fail and return a negative value in that case - We do the maintenance of the running parameter after barebox feeds/disables the watchdog in the core, so it doesn't need to be replicated across drivers. Drivers hould only initialize the running parameter once at probe time. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * watchdog: always populate watchdog priority from device tree if possibleAhmad Fatoum2019-11-111-16/+18
| | | | | | | | | | | | | | | | | | | | | | So far, only the da9063 and da9053 have made use of the optional barebox watchdog-priority binding. Move it into the core, so other device drivers automatically have their watchdog-priority property parsed as well. This patch doesn't introduce any functional changes for upstream boards. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | watchdog: stm32_iwdg: return -ENOSYS on attempt to disableAhmad Fatoum2019-11-131-1/+1
| | | | | | | | | | | | | | | | | | | | The stm32_iwdg watchdog can't be disabled. To have the wd commant report this fact correctly to the user, the ->set_timeout needs to return -ENOSYS which is interpreted as "Watchdog cannot be disabled" instead of -EINVAL which means "Timeout value out of range". Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mfd: stpmic1: use register define from headerAhmad Fatoum2019-11-131-16/+12
|/ | | | | | | | | A previous commit has copied over the upstream <linux/mfd/stpmic1.h> header. Use it instead of replicating register definitions in the MFD and watchdog cell driver. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>