Heiko Schocher | 2480b15 | 2024-11-23 17:52:45 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | /* |
| 3 | * Driver for a PMIC watchdog timer controlled via Siemens SCU firmware |
| 4 | * extensions. Only useful on some Siemens i.MX8-based platforms as |
| 5 | * special NXP SCFW is needed which provides the needed SCU API. |
| 6 | * |
| 7 | * Copyright (C) 2024 Siemens AG |
| 8 | */ |
| 9 | |
| 10 | #include <dm.h> |
| 11 | #include <wdt.h> |
| 12 | #include <firmware/imx/sci/sci.h> |
| 13 | |
| 14 | /* watchdog commands */ |
| 15 | #define CMD_START_WDT 0x55 |
| 16 | #define CMD_STOP_WDT 0x45 |
| 17 | #define CMD_PING_WDT 0x35 |
| 18 | |
| 19 | static int scu_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags) |
| 20 | { |
| 21 | /* start external watchdog via Timer API */ |
| 22 | return sc_timer_control_siemens_pmic_wdog(-1, CMD_START_WDT); |
| 23 | } |
| 24 | |
| 25 | static int scu_wdt_stop(struct udevice *dev) |
| 26 | { |
| 27 | /* stop external watchdog via Timer API */ |
| 28 | return sc_timer_control_siemens_pmic_wdog(-1, CMD_STOP_WDT); |
| 29 | } |
| 30 | |
| 31 | static int scu_wdt_reset(struct udevice *dev) |
| 32 | { |
| 33 | return sc_timer_control_siemens_pmic_wdog(-1, CMD_PING_WDT); |
| 34 | } |
| 35 | |
| 36 | static int scu_wdt_probe(struct udevice *dev) |
| 37 | { |
| 38 | debug("%s(dev=%p)\n", __func__, dev); |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | static const struct wdt_ops scu_wdt_ops = { |
| 43 | .reset = scu_wdt_reset, |
| 44 | .start = scu_wdt_start, |
| 45 | .stop = scu_wdt_stop, |
| 46 | }; |
| 47 | |
| 48 | static const struct udevice_id scu_wdt_ids[] = { |
| 49 | { .compatible = "siemens,scu-wdt" }, |
| 50 | { } |
| 51 | }; |
| 52 | |
| 53 | U_BOOT_DRIVER(scu_wdt) = { |
| 54 | .name = "scu_wdt", |
| 55 | .id = UCLASS_WDT, |
| 56 | .of_match = scu_wdt_ids, |
| 57 | .probe = scu_wdt_probe, |
| 58 | .ops = &scu_wdt_ops, |
| 59 | }; |