summaryrefslogtreecommitdiff
path: root/drivers/watchdog
AgeCommit message (Collapse)Author
4 daysglobal: Correct duplicate U_BOOT_DRIVER entry namesTom Rini
The U_BOOT_DRIVER macro creates a list of drivers used at link time, and all entries here must be unique. This in turn means that all entries in the code should also be unique in order to not lead to build failures later with unexpected build combinations. Typically, the problem we have here is when a driver is obviously based on another driver and didn't update this particular field and so while the name field reflects something unique the linker entry itself is not. In a few places this provides a more suitable string name as well, however. Reviewed-by: Marek Vasut <[email protected]> Reviewed-by: Svyatoslav Ryhel <[email protected]> # Tegra Reviewed-by: Peter Robinson <[email protected]> Reviewed-by: Heiko Schocher <[email protected]> Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Tom Rini <[email protected]>
5 daysMerge branch 'next'Tom Rini
2026-03-24watchdog: qcom: stop watchdog by defaultCasey Connolly
Prevent the Qualcomm watchdog from autostarting and ensure it's stopped when the driver probed. In some cases the watchdog is left running by a previous bootloader stage. Disable autostart so it isn't left running when we boot into the OS, this behaviour can be changed by enabling autostart in the board defconfig. Reviewed-by: Stefan Roese <[email protected]> Reviewed-by: Sumit Garg <[email protected]> Reviewed-by: Tom Rini <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Casey Connolly <[email protected]>
2026-03-09Merge tag 'v2026.04-rc4' into nextTom Rini
Prepare v2026.04-rc4
2026-03-04treewide: Remove Timesys from ADI ADSP maintenancePhilip Molloy
After years of developing the ADI ADSP platform, Timesys was purchased by another company and is no longer contracted to maintain the platform. Signed-off-by: Philip Molloy <[email protected]> Reviewed-by: Greg Malysa <[email protected]>
2026-02-18Merge patch series "Add MT8195 support"Tom Rini
Julien Stephan <[email protected]> says: This series adds basic support for Mediatek soc MT8195: - clock driver - watchdog - add a new macro helper to define gate clock. Other driver can be cleaned later to use the new macro Other driver will be added later. It will also serve as basis for board support such as MT8395_EVK based on MT8195. Link: https://lore.kernel.org/r/[email protected]
2026-02-18arm: mediatek: add support for MediaTek MT8195 SoCJulien Stephan
This adds basic support for MediaTek MT8195 SoC. Add watchdog support by adding upstream compatible string. Signed-off-by: Julien Stephan <[email protected]>
2026-02-17treewide: Clean up DECLARE_GLOBAL_DATA_PTR usagePeng Fan
Remove DECLARE_GLOBAL_DATA_PTR from files where gd is not used, and drop the unnecessary inclusion of asm/global_data.h. Headers should be included directly by the files that need them, rather than indirectly via global_data.h. Reviewed-by: Patrice Chotard <[email protected]> #STMicroelectronics boards and STM32MP1 ram test driver Tested-by: Anshul Dalal <[email protected]> #TI boards Acked-by: Yao Zi <[email protected]> #TH1520 Signed-off-by: Peng Fan <[email protected]>
2026-01-14watchdog: qcom: Add max timeout check to prevent overflowGopinath Sekar
Added a check to ensure the requested timeout does not exceed the hardware's maximum supported value. This prevents register overflow and ensures watchdog reliability. So, added a check in qcom_wdt_start() to ensure the requested timeout does not exceed the hardware-supported maximum value. If the requested value exceeds the maximum value, then the timeout is clamped at maximum value. The timeout is first converted to watchdog ticks and then compared against QCOM_WDT_MAX_TIMEOUT. This helps prevent misconfiguration and potential watchdog misbehavior due to overflow. QCOM_WDT_MAX_TIMEOUT is set to 0xFFFFF, as Qualcomm SoCs typically use 20 bits to store bark/bite timeout values. This work builds upon the previous submission: https://lore.kernel.org/u-boot/[email protected]/ Signed-off-by: Gopinath Sekar <[email protected]> Reviewed-by: Stefan Roese <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Casey Connolly <[email protected]>
2026-01-06Merge patch series "Add support for MT8188"Tom Rini
Julien Stephan <[email protected]> says: The MediaTek MT8188 is a ARM64-based SoC with a dual-core Cortex-A78 cluster and a six-core Cortex-A55 cluster. It includes UART, SPI, USB3.0 dual role, SD and MMC cards, UFS, PWM, I2C, I2S, S/PDIF, and several LPDDR3 and LPDDR4 options. This series adds basic support for MT8188. Link: https://lore.kernel.org/r/[email protected]
2026-01-06arm: mediatek: add support for MediaTek MT8188 SoCJulien Masson
This adds basic support for MediaTek MT8188 SoC. Add watchdog support by adding upstream compatible string. Add tphy support by adding "mediatek,generic-tphy-v2" compatible string in arch/arm/dts/mt8188-u-boot.dtsi Signed-off-by: Julien Masson <[email protected]> Signed-off-by: Julien Stephan <[email protected]> Reviewed-by: Mattijs Korpershoek <[email protected]> Reviewed-by: Macpaul Lin <[email protected]>
2025-12-31watchdog: npcm: Support more timeout valueStanley Chu
Calculate a timeout value that is close to the requested value. Signed-off-by: Stanley Chu <[email protected]>
2025-10-28watchdog: Add support for Tegra watchdog timerLukasz Majewski
Provide support for Tegra watchdog functionality. The WATCHDOG index 0 in conjunction with TIMER 5 is used inline with existing Linux kernel driver. Signed-off-by: Lukasz Majewski <[email protected]> Reviewed-by: Svyatoslav Ryhel <[email protected]> Signed-off-by: Svyatoslav Ryhel <[email protected]>
2025-10-16watchdog: Tighten dependencies on WDT_DAVINCITom Rini
The WDT_DAVINCI driver is not safe to compile on 64bit platforms such as allyesconfig on a 64bit host. Tighten the dependencies here to the platforms which could use it today. Signed-off-by: Tom Rini <[email protected]>
2025-10-16watchdog: Tighten some watchdog driver dependenciesTom Rini
A few watchdog drivers cannot build without access to some platform specific header files. Express those requirements in Kconfig as well. Signed-off-by: Tom Rini <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2025-08-08drivers: watchdog: Enable watchdog support in SPL for AgilexAlif Zakuan Yuslaimi
Enable watchdog as early as possible after clock initialization which is set at 10 seconds. Signed-off-by: Alif Zakuan Yuslaimi <[email protected]> Reviewed-by: Tien Fong Chee <[email protected]>
2025-07-30watchdog: don't autostart watchdog on STM32MP architecturePatrice Chotard
On STM32MP reference boards, the watchdog is started by a previous boot stage (e.g. bootrom or secure OS), so the config flag WATCHDOG_AUTOSTART is not required. It's preferable to rely on the DT properties "u-boot,autostart" or "u-boot,noautostart", if needed. For backward compatibility on defconfigs that are based on SPL, thus cannot rely on a previous boot stage for starting the watchdog, enable WATCHDOG_AUTOSTART in their respective defconfig. The change in stm32mp15_dhsom.config is propagated to: - configs/stm32mp15_dhcom_basic.config - configs/stm32mp15_dhcor_basic.config and then to: - stm32mp15_dhcom_basic_defconfig - stm32mp15_dhcom_drc02_basic_defconfig - stm32mp15_dhcom_pdk2_basic_defconfig - stm32mp15_dhcom_picoitx_basic_defconfig - stm32mp15_dhcor_avenger96_basic_defconfig - stm32mp15_dhcor_basic_defconfig - stm32mp15_dhcor_drc_compact_basic_defconfig - stm32mp15_dhcor_testbench_basic_defconfig Signed-off-by: Patrice Chotard <[email protected]> Signed-off-by: Antonio Borneo <[email protected]> Reviewed-by: Patrice Chotard <[email protected]>
2025-07-30watchdog: stm32mp: check the watchdog statusClément Le Goffic
Add a mean to check the IWDG status based on the peripheral version. This is done by either checking the status bit ONF either by updating the reload register with the same value and check if the reload succeed. Signed-off-by: Clément Le Goffic <[email protected]> Signed-off-by: Antonio Borneo <[email protected]> Reviewed-by: Patrice Chotard <[email protected]>
2025-07-30watchdog: arm_smc_wdt: get wdt status through SMCWD_GET_TIMELEFTAntonio Borneo
The optional SMCWD_GET_TIMELEFT command can be used to detect if the watchdog has already been started. See the implementation in OP-TEE secure OS [1]. At probe time, check if the watchdog is already started and then call wdt_set_force_autostart(). This will keep U-Boot pinging the watchdog even when the property 'u-boot,noautostart' is present. Link: https://github.com/OP-TEE/optee_os/commit/a7f2d4bd8632 [1] Signed-off-by: Antonio Borneo <[email protected]> Reviewed-by: Patrice Chotard <[email protected]>
2025-07-30watchdog: wdt-uclass.c: add wdt_set_force_autostart() helperAntonio Borneo
The watchdog could have been already started by a previous boot stage (e.g. bootrom or secure OS). U-Boot has to start and kick the watchdog even when CONFIG_WATCHDOG_AUTOSTART is not enabled or when the DT property u-boot,noautostart is present. Add the helper wdt_set_force_autostart() that can be called by the driver's probe() when it detects that the watchdog has already been started and is running. Co-developed-by: Patrice Chotard <[email protected]> Signed-off-by: Patrice Chotard <[email protected]> Signed-off-by: Antonio Borneo <[email protected]> Reviewed-by: Patrice Chotard <[email protected]>
2025-07-14Merge tag 'qcom-main-20250714' of ↵Tom Rini
https://source.denx.de/u-boot/custodians/u-boot-snapdragon CI: https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/pipelines/27056 - Fix unused access in ufetch - Add missing clock for SM8650 - Port the Linux SPMI GPIO driver and port over SM8550 (other platforms should follow)
2025-07-14watchdog: qcom-wdt: Drop read check on write-only WDT_EN registerBalaji Selvanathan
On some Qualcomm platforms, such as Dragonwing boards, the WDT_EN register is write-only. Reading it back after enabling the watchdog can return invalid data or cause unexpected behavior. In particular, the check: if (readl(wdt_addr(wdt, WDT_EN)) != 1) may fail even though the watchdog is correctly enabled and running. This leads to misleading error messages and unnecessary failures. Removing the read check ensures compatibility and avoids false negatives on platforms where WDT_EN is not readable. This work builds upon this previous submission: https://lore.kernel.org/u-boot/[email protected]/ Signed-off-by: Balaji Selvanathan <[email protected]> Reviewed-by: Stefan Roese <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Casey Connolly <[email protected]>
2025-07-10arm: imx: Remove the rest of i.MX31 supportTom Rini
With the removal of the last i.MX31 platform we can remove the rest of the underlying architecture code as well. Fixes: f247354708ec ("arm: Remove mx31pdk board") Signed-off-by: Tom Rini <[email protected]> Acked-by: Peng Fan <[email protected]>
2025-06-23drivers: watchdog: qcom: Add timeout configuration support in watchdogBalaji Selvanathan
This patch enhances the Qualcomm watchdog driver by introducing support for dynamic timeout configuration. Specifically: - Calculates and sets the bark and bite timeout values based on the clock rate and the requested timeout in milliseconds. - Adds retrieval of the watchdog clock rate during probe using the common clock framework. - Adds a default timeout value for ARCH_SNAPDRAGON in WATCHDOG_TIMEOUT_MSECS. These changes improve the configurability and accuracy of the watchdog timer on Qualcomm platforms. This work builds upon the previous submission: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Balaji Selvanathan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Casey Connolly <[email protected]>
2025-06-23watchdog: qcom: introduce qcom-wdt driverCasey Connolly
Some Qualcomm device vendors decide to turn the watchdog on in the bootloader, resulting in the device being reset if it isn't petted every ~30 seconds. Introduce a driver to keep the watchdog happy and prevent this annoying behaviour. Signed-off-by: Paul Sajna <[email protected]> Co-authored-by: Paul Sajna <[email protected]> Tested-by: Paul Sajna <[email protected]> Reviewed-by: Stefan Roese <[email protected]> Acked-by: Sumit Garg <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Casey Connolly <[email protected]>
2025-06-20Merge tag 'u-boot-at91-2025.10-a' of ↵Tom Rini
https://source.denx.de/u-boot/custodians/u-boot-at91 into next First set of u-boot-at91 features for the 2025.10 cycle: This feature set includes the addition of new sam9x7 SoC and a new board named sam9x7-curiosity. There is also new support for sam9x60 compatible at91 watchdog.
2025-06-19watchdog: at91sam9_wdt: Add SAM9X60 supportZixun LI
SAM9X60 has a slightly different watchdog implementation: - Timer value moved into a new register WLR - Some MR register fields have their position changed This patch add SAM9X60 support, also adds a compatible for SAMA5D4 which is the same as existing SAM9260. Signed-off-by: Zixun LI <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2025-06-19watchdog: at91sam9_wdt: Rename priv to wdtZixun LI
"wdt" is a better name for watchdog rather than generic "priv". Signed-off-by: Zixun LI <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2025-06-19arm: at91: wdt: Rename regval in priv data to mrZixun LI
Use the name "mr" since we are referring to timer mode register. Signed-off-by: Zixun LI <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2025-06-18renesas: Renesas R-Car Gen4 watchdog driverShmuel Leib Melamud
Add support of Renesas R-Car Gen4 watchdog timer. Timeouts up to 8184.0s are supported (CKS1 register is not involved). The watchdog uses the clock of type CLK_TYPE_GEN4_MDSEL. The timeout is set in dts/upstream/src/arm64/renesas/r8a779f0-spider-cpu.dtsi section &rwdt. This driver is based on upstream linux commit: e70140ba0d2b("Get rid of 'remove_new' relic from platform driver struct") Signed-off-by: Shmuel Leib Melamud <[email protected]> Reviewed-by: Mattijs Korpershoek <[email protected]> Reviewed-by: Stefan Roese <[email protected]> Reviewed-by: Marek Vasut <[email protected]>
2025-04-28watchdog: sunxi: add A523 supportAndre Przywara
The Allwinner A523 SoC moved the watchdog into a separate MMIO frame, and also shifted the registers a bit: the control, config, and mode register are located four bytes earlier. Add the new compatible string, and connect it to the new struct describing the new register layout. Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2025-03-30Merge patch series "Clarify DM_FLAG_PROBE_AFTER_BIND behaviour"Tom Rini
Caleb Connolly <[email protected]> says: In Simon's series reworking autoprobe, a discussion came up about DM_FLAG_PROBE_AFTER_BIND, specifically that it wasn't very clear where this flag should be used. This series implements my suggestions made there to clarify the use of this flag, and fixup the two driver which erroneously apply it to their driver struct (this does nothing). Link: https://lore.kernel.org/u-boot/[email protected]/ Link: https://lore.kernel.org/r/[email protected]
2025-03-30drivers: remove bogus DM_FLAG_PROBE_AFTER_BIND flagsCaleb Connolly
Some drivers set DM_FLAG_PROBE_AFTER_BIND, this does nothing since it's only every applied on a per-device basis. Remove the flags. Signed-off-by: Caleb Connolly <[email protected]> Reviewed-by: Simon Glass <[email protected]> Acked-by: Michal Simek <[email protected]>
2025-03-12watchdog: Add support for ADI SC5XX-family watchdog peripheralNathan Barrett-Morrison
Co-developed-by: Greg Malysa <[email protected]> Signed-off-by: Greg Malysa <[email protected]> Co-developed-by: Ian Roberts <[email protected]> Signed-off-by: Ian Roberts <[email protected]> Signed-off-by: Vasileios Bimpikas <[email protected]> Signed-off-by: Utsav Agarwal <[email protected]> Signed-off-by: Arturs Artamonovs <[email protected]> Signed-off-by: Oliver Gaskell <[email protected]> Signed-off-by: Nathan Barrett-Morrison <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2025-01-09Merge https://source.denx.de/u-boot/custodians/u-boot-watchdogTom Rini
- rti: support SPL (or re-start) (Alexander) - rti: drop hack manipulating WDT clock rate (Alexander)
2025-01-07watchdog: rti: drop hack manipulating WDT clock rateAlexander Sverdlin
The hack itself seems to be copied from Linux rti_wdt.c, but the WDT reset principle is different in U-Boot. While Linux relies on correct frequencies and timers and doesn't check the actual WDT counter value U-Boot driver seems to be more robust: it does compare RTIDWDCNTR vs RTIDWDPRLD. Now the root cause of the original motivation to manipulate the clock rate is said to be understood and fixed in Linux commit cae58516534e ("watchdog: rti_wdt: Set min_hw_heartbeat_ms to accommodate a safety margin") which simultaneously removed the hack itself. While is fix part of the mentioned patch is neither applicable nor requried for the U-Boot driver just drop the hack setting WDT clock rate to 90% of the real rate. This has a nice effect that the WDT timeout is now as requested and not 10% shorter. Signed-off-by: Alexander Sverdlin <[email protected]> Reviewed-by: Jan Kiszka <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2025-01-07watchdog: rti: support SPL (or re-start)Alexander Sverdlin
If the RTI watchdog has been enabled in SPL, enabling it in U-Boot proper fails because it can only be enabled once in HW and never stopped. This however leads to a situation that wdt_cyclic() watchdog trigger is not being started any longer and the WDT fires at some point. Allow for WDT re-start by not bailing out if the [previously] configured period matches the one to be configured. Enabling in [A53] SPL has been tested on AM62x-based HW (where [A53] SPL is responsible for loading R5 DM firmware and not this driver). Signed-off-by: Alexander Sverdlin <[email protected]> Reviewed-by: Jan Kiszka <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2024-11-25wdt: imx8qxp: add option to control external PMIC wdt via IMX8 SCUHeiko Schocher
Driver for a PMIC watchdog timer controlled via Siemens SCU firmware extensions. Only useful on some Siemens i.MX8-based platforms as special SCFW is needed which provides the needed SCU API. Signed-off-by: Andrej Valek <[email protected]> Signed-off-by: Heiko Schocher <[email protected]> Reviewed-by: Alexander Sverdlin <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2024-10-23watchdog: introduce separate SPL symbol for WDT_GPIORasmus Villemoes
Currently, enabling WDT_GPIO on a board which uses SPL, but does not have SPL_WDT, SPL_DM_GPIO or SPL_OF_CONTROL enabled, breaks the build. Make it possible to use the WDT_GPIO driver on such boards by introducing a separate symbol controlling whether the driver is built for SPL. Make it default to WDT_GPIO such that boards that already have it enabled and all the SPL prerequisites satisfied will continue to have it in SPL. Signed-off-by: Rasmus Villemoes <[email protected]> Reviewed-by: Tom Rini <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2024-10-23drivers: watchdog: Add DaVinci's watchdog supportBastien Curutchet
Add support for the DaVinci's watchdog timer Signed-off-by: Bastien Curutchet <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2024-10-23watchdog: gpio_wdt: add support for stoppable devicesRasmus Villemoes
Back when I added this driver in commit 2ac8490412c9, I wrote The corresponding linux driver apparently has support for some watchdog circuits which can be disabled by tri-stating the gpio, but I have never actually encountered such a chip in the wild; That has changed now; I have a board with just such a watchdog on my desk currently. Add support for that. - For a hw_algo="toggle" device, the gpio is requested as output if the always-running flag is set, otherwise as input. - The ->start() method is updated to change the direction to output when required (i.e. it is not always-running). - The ->stop() method is implemented, but of course reports failure if always-running. As I still haven't met any hw_algo="level" devices, I'm not entirely sure how they fit in, but I'm borrowing logic from the corresponding linux driver: - In ->probe(), such devices always request the gpio as GPIOD_IS_OUT. - In ->stop(), the linux driver has an "eternal ping" comment and sets the gpio to (logic) high. Stefan: Added necessary changes in test/dm/wdt.c to fix CI build breakage, as suggested by Rasmus. Signed-off-by: Rasmus Villemoes <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2024-10-11Merge patch series "Tidy up use of 'SPL' and CONFIG_SPL_BUILD"Tom Rini
Simon Glass <[email protected]> says: When the SPL build-phase was first created it was designed to solve a particular problem (the need to init SDRAM so that U-Boot proper could be loaded). It has since expanded to become an important part of U-Boot, with three phases now present: TPL, VPL and SPL Due to this history, the term 'SPL' is used to mean both a particular phase (the one before U-Boot proper) and all the non-proper phases. This has become confusing. For a similar reason CONFIG_SPL_BUILD is set to 'y' for all 'SPL' phases, not just SPL. So code which can only be compiled for actual SPL, for example, must use something like this: #if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD) In Makefiles we have similar issues. SPL_ has been used as a variable which expands to either SPL_ or nothing, to chose between options like CONFIG_BLK and CONFIG_SPL_BLK. When TPL appeared, a new SPL_TPL variable was created which expanded to 'SPL_', 'TPL_' or nothing. Later it was updated to support 'VPL_' as well. This series starts a change in terminology and usage to resolve the above issues: - The word 'xPL' is used instead of 'SPL' to mean a non-proper build - A new CONFIG_XPL_BUILD define indicates that the current build is an 'xPL' build - The existing CONFIG_SPL_BUILD is changed to mean SPL; it is not now defined for TPL and VPL phases - The existing SPL_ Makefile variable is renamed to SPL_ - The existing SPL_TPL Makefile variable is renamed to PHASE_ It should be noted that xpl_phase() can generally be used instead of the above CONFIGs without a code-space or run-time penalty. This series does not attempt to convert all of U-Boot to use this new terminology but it makes a start. In particular, renaming spl.h and common/spl seems like a bridge too far at this point. The series is fully bisectable. It has also been checked to ensure there are no code-size changes on any commit.
2024-10-11global: Rename SPL_TPL_ to PHASE_Simon Glass
Use PHASE_ as the symbol to select a particular XPL build. This means that SPL_TPL_ is no-longer set. Update the comment in bootstage to refer to this symbol, instead of SPL_ Signed-off-by: Simon Glass <[email protected]>
2024-10-04da9063: Add watchdog supportFabio Estevam
The DA9063 PMIC is a multi-function device that provides regulator, watchdog, RTC, and ON key functionalities. Add support for the DA9063 PMIC watchdog functionality. Based on the 6.11 kernel drivers/watchdog/da9063_wdt.c driver. Signed-off-by: Fabio Estevam <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2024-07-31cyclic: Add a symbol for SPLSimon Glass
The cyclic subsystem is currently enabled either in all build phases or none. For tools this should not be enabled, but since lib/shc256.c and other files include watchdog.h in the host build, we must make sure that it is not enabled there. Add an SPL symbol so that there is more control of this. Add an include into cyclic.h so that tools can include this file. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Devarsh Thakkar <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2024-07-22drivers: watchdog: Remove duplicate newlinesMarek Vasut
Drop all duplicate newlines. No functional change. Signed-off-by: Marek Vasut <[email protected]>
2024-07-05watchdog: mpc8xxx: Fix timer valueChristophe Leroy
Timer value is a 16 bits calculated from the wanted timeout and the system clock. On powerpc/8xx, a timeout of 2s gives a value which is over U16_MAX so U16_MAX shall be used. But the calculation is casted to u16 so at the end the result is 63770 instead of 128906. So the timer gets loaded with 63770 instead of 65535. It is not a big difference in that case, but lets make the code correct and cast to u32 instead of u16. Fixes: 26e8ebcd7cb7 ("watchdog: mpc8xxx: Make it generic") Signed-off-by: Christophe Leroy <[email protected]>
2024-06-16wdt-uclass: watchdog_reset cleanupRasmus Villemoes
watchdog_reset() is no longer called from anywhere, so we do not need to define a dummy no-op function. Remove that definition, and update references to say schedule() instead. Signed-off-by: Rasmus Villemoes <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2024-06-16cyclic: make clients embed a struct cyclic_info in their own data structureRasmus Villemoes
There are of course not a whole lot of examples in-tree yet, but before they appear, let's make this API change: Instead of separately allocating a 'struct cyclic_info', make the users embed such an instance in their own structure, and make the convention that the callback simply receives the 'struct cyclic_info *', from which the clients can get their own data using the container_of() macro. This has a number of advantages. First, it means cyclic_register() simply cannot fail, simplifying the code. The necessary storage will simply be allocated automatically when the client's own structure is allocated (often via uclass_priv_auto or similar). Second, code for which CONFIG_CYCLIC is just an option can more easily be written without #ifdefs, if we just provide an empty struct cyclic_info {}. For example, the nested CONFIG_IS_ENABLED()s in https://lore.kernel.org/u-boot/[email protected]/ are mostly due to the existence of the 'struct cyclic_info *' member being guarded by #ifdef CONFIG_CYCLIC. And we do probably want to avoid the extra memory overhead of that member when !CONFIG_CYCLIC. But that is automatic if, instead of a 'struct cyclic_info *', one simply embeds a 'struct cyclic_info', which will have size 0 when !CONFIG_CYCLIC. Also, the no-op cyclic_register() function can just unconditionally be called, and the compiler will see that (1) the callback is referenced, so not emit a warning for a maybe-unused function and (2) see that it can actually never be reached, so not emit any code for it. Reviewed-by: Stefan Roese <[email protected]> Signed-off-by: Rasmus Villemoes <[email protected]>
2024-06-16wdt-uclass: prevent multiple cyclic_register callsRasmus Villemoes
Currently, the cyclic_register() done in wdt_start() is not undone in wdt_stop(). Moreover, calling wdt_start multiple times (which is perfectly allowed on an already started device, e.g. to change the timeout value) will result in another struct cyclic_info being registered, referring to the same watchdog device. This can easily be seen on e.g. a wandboard: => cyclic list function: watchdog@20bc000, cpu-time: 22 us, frequency: 1.01 times/s => wdt list watchdog@20bc000 (imx_wdt) => wdt dev watchdog@20bc000 => wdt start 50000 WDT: Started watchdog@20bc000 with servicing every 1000ms (50s timeout) => cyclic list function: watchdog@20bc000, cpu-time: 37 us, frequency: 1.03 times/s function: watchdog@20bc000, cpu-time: 241 us, frequency: 1.01 times/s => wdt start 12345 WDT: Started watchdog@20bc000 with servicing every 1000ms (12s timeout) => cyclic list function: watchdog@20bc000, cpu-time: 36 us, frequency: 1.03 times/s function: watchdog@20bc000, cpu-time: 100 us, frequency: 1.04 times/s function: watchdog@20bc000, cpu-time: 299 us, frequency: 1.00 times/s So properly unregister the watchdog device from the cyclic framework in wdt_stop(). In wdt_start(), we cannot just skip the registration, as the (new) timeout value may mean that we have to ask the cyclic framework to call us more often. So if we're already running, first unregister the old cyclic instance. Reviewed-by: Stefan Roese <[email protected]> Signed-off-by: Rasmus Villemoes <[email protected]>