Skip to contentSkip to conversation

watchdog: designware: Migrate CONFIG_DESIGNWARE_WATCHDOG to Kconfig

PATCH Superseded Marek Vasut 2 participants 7 messages Jan 6, 2020 – Jan 9, 2020

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/3 watchdog: designware: Migrate CONFIG_DESIGNWARE_WATCHDOG to Kconfig

Migrate CONFIG_DESIGNWARE_WATCHDOG to Kconfig and update the headers accordingly, no functional change. The S10 enables the WDT only in SPL, but does not enable it in U-Boot itself, hence disable it in the config again.

Cc Chin Liang See <[email protected]>
Cc Dalon Westergreen <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Jagan Teki <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Philipp Tomisch <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tien Fong Chee <[email protected]>

---
V2: Use non-DM watchdog in SPL on S10
V3: No changes

---
 configs/socfpga_stratix10_defconfig       | 1 +
 configs/socfpga_vining_fpga_defconfig     | 1 +
 drivers/watchdog/Kconfig                  | 7 +++++++
 include/configs/socfpga_common.h          | 4 +---
 include/configs/socfpga_stratix10_socdk.h | 7 +++++--
 scripts/config_whitelist.txt              | 1 -
 6 files changed, 15 insertions(+), 6 deletions(-)
configs/socfpga_stratix10_defconfig +1 -0
index 0665b460de..82ffedf41a 100644
@@ -59,3 +59,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_DWC2=y
 CONFIG_USB_STORAGE=y
 # CONFIG_SPL_USE_TINY_PRINTF is not set
+CONFIG_DESIGNWARE_WATCHDOG=y
configs/socfpga_vining_fpga_defconfig +1 -0
index 19bed6be27..0e31e4f165 100644
@@ -97,3 +97,4 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
 CONFIG_USB_GADGET_DWC2_OTG=y
 CONFIG_USB_GADGET_DOWNLOAD=y
 # CONFIG_SPL_WDT is not set
+CONFIG_DESIGNWARE_WATCHDOG=y
drivers/watchdog/Kconfig +7 -0
index 8c16d69d33..5f8a070ef5 100644
@@ -45,6 +45,13 @@ config ULP_WATCHDOG
 	help
 	  Say Y here to enable i.MX7ULP watchdog driver.
 
+config DESIGNWARE_WATCHDOG
+	bool "Designware watchdog timer support"
+	select HW_WATCHDOG
+	help
+	   Enable this to support Designware Watchdog Timer IP, present e.g.
+	   on Altera SoCFPGA SoCs.
+
 config WDT
 	bool "Enable driver model for watchdog timer drivers"
 	depends on DM
include/configs/socfpga_common.h +1 -3
index 05bfef75c0..d1a14d23aa 100644
@@ -104,11 +104,9 @@
 /*
  * L4 Watchdog
  */
-#ifdef CONFIG_HW_WATCHDOG
-#define CONFIG_DESIGNWARE_WATCHDOG
 #define CONFIG_DW_WDT_BASE		SOCFPGA_L4WD0_ADDRESS
 #define CONFIG_DW_WDT_CLOCK_KHZ		25000
-#endif
+#define CONFIG_WATCHDOG_TIMEOUT_MSECS	30000
 
 /*
  * MMC Driver
include/configs/socfpga_stratix10_socdk.h +5 -2
index a10cbec17f..f7a4a30f3a 100644
@@ -152,13 +152,16 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
  */
 #ifdef CONFIG_SPL_BUILD
 #define CONFIG_HW_WATCHDOG
-#define CONFIG_DESIGNWARE_WATCHDOG
+#else
+#undef CONFIG_HW_WATCHDOG
+#undef CONFIG_DESIGNWARE_WATCHDOG
+#endif
 #define CONFIG_DW_WDT_BASE		SOCFPGA_L4WD0_ADDRESS
 #ifndef __ASSEMBLY__
 unsigned int cm_get_l4_sys_free_clk_hz(void);
 #define CONFIG_DW_WDT_CLOCK_KHZ		(cm_get_l4_sys_free_clk_hz() / 1000)
 #endif
-#endif
+#define CONFIG_WATCHDOG_TIMEOUT_MSECS	3000
 
 /*
  * SPL memory layout
scripts/config_whitelist.txt +0 -1
index cf1808e051..5984e579da 100644
@@ -312,7 +312,6 @@ CONFIG_DEFAULT_IMMR
 CONFIG_DEF_HWCONFIG
 CONFIG_DELAY_ENVIRONMENT
 CONFIG_DESIGNWARE_ETH
-CONFIG_DESIGNWARE_WATCHDOG
 CONFIG_DEVELOP
 CONFIG_DEVICE_TREE_LIST
 CONFIG_DFU_ALT
Signature · 1 line
2.24.1
#1 lore raw

PATCH v3 2/3 watchdog: designware: Convert to DM and DT probing

Convert the designware watchdog timer driver to DM and add DT probing support. Perform minor coding style clean up, like drop superfluous braces. These ought to be no functional change.

Cc Chin Liang See <[email protected]>
Cc Dalon Westergreen <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Jagan Teki <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Philipp Tomisch <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tien Fong Chee <[email protected]>

---
V2: - Support both DM and non-DM probing
- Fix watchdog stop handling by setting CR bit
V3: - Add missing u-boot,dm-pre-reloc into the DTs

---
 .../socfpga_cyclone5_vining_fpga-u-boot.dtsi  |   4 +
 .../dts/socfpga_stratix10_socdk-u-boot.dtsi   |   4 +
 configs/socfpga_stratix10_defconfig           |   2 +
 configs/socfpga_vining_fpga_defconfig         |   1 +
 drivers/watchdog/Kconfig                      |   2 +-
 drivers/watchdog/designware_wdt.c             | 122 ++++++++++++++----
 include/configs/socfpga_stratix10_socdk.h     |   1 +
 7 files changed, 112 insertions(+), 24 deletions(-)
arch/arm/dts/socfpga_cyclone5_vining_fpga-u-boot.dtsi +4 -0
index 44bedd8b67..2e4468e8d8 100644
@@ -56,3 +56,7 @@
 &portc {
 	bank-name = "portc";
 };
+
+&watchdog0 {
+	u-boot,dm-pre-reloc;
+};
arch/arm/dts/socfpga_stratix10_socdk-u-boot.dtsi +4 -0
index e1cfb522bf..a41db08dd4 100755
@@ -23,3 +23,7 @@
 	spi-rx-bus-width = <4>;
 	u-boot,dm-pre-reloc;
 };
+
+&watchdog0 {
+	u-boot,dm-pre-reloc;
+};
configs/socfpga_stratix10_defconfig +2 -0
index 82ffedf41a..29466d0c09 100644
@@ -60,3 +60,5 @@ CONFIG_USB_DWC2=y
 CONFIG_USB_STORAGE=y
 # CONFIG_SPL_USE_TINY_PRINTF is not set
 CONFIG_DESIGNWARE_WATCHDOG=y
+CONFIG_WDT=y
+# CONFIG_SPL_WDT is not set
configs/socfpga_vining_fpga_defconfig +1 -0
index 0e31e4f165..39be88b9b7 100644
@@ -97,4 +97,5 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
 CONFIG_USB_GADGET_DWC2_OTG=y
 CONFIG_USB_GADGET_DOWNLOAD=y
 # CONFIG_SPL_WDT is not set
+CONFIG_WDT=y
 CONFIG_DESIGNWARE_WATCHDOG=y
drivers/watchdog/Kconfig +1 -1
index 5f8a070ef5..bf5612a811 100644
@@ -47,7 +47,7 @@ config ULP_WATCHDOG
 
 config DESIGNWARE_WATCHDOG
 	bool "Designware watchdog timer support"
-	select HW_WATCHDOG
+	select HW_WATCHDOG if !WDT
 	help
 	   Enable this to support Designware Watchdog Timer IP, present e.g.
 	   on Altera SoCFPGA SoCs.
drivers/watchdog/designware_wdt.c +99 -23

162 lines not on this page · raw message

include/configs/socfpga_stratix10_socdk.h +1 -0
index f7a4a30f3a..9e9209013a 100644
@@ -151,6 +151,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
  * L4 Watchdog
  */
 #ifdef CONFIG_SPL_BUILD
+#undef CONFIG_WATCHDOG
 #define CONFIG_HW_WATCHDOG
 #else
 #undef CONFIG_HW_WATCHDOG
Signature · 1 line
2.24.1
#2 lore raw

PATCH v3 2/3 watchdog: designware: Convert to DM and DT probing

Quoted 14 lines · Marek Vasut

Convert the designware watchdog timer driver to DM and add DT probing support. Perform minor coding style clean up, like drop superfluous braces. These ought to be no functional change.

Cc Chin Liang See <[email protected]>
Cc Dalon Westergreen <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Jagan Teki <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Philipp Tomisch <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tien Fong Chee <[email protected]>
Quoted 5 lines

---
V2: - Support both DM and non-DM probing
- Fix watchdog stop handling by setting CR bit
V3: - Add missing u-boot,dm-pre-reloc into the DTs
---

#3 lore raw

PATCH v3 3/3 watchdog: designware: Optionally fetch clock and reset from DT

In reply to Marek Vasut

Add optional support for fetching watchdog clock rate from DT and ungating reset via reset framework. This is optional as not all platforms using DW WDT support the clock and reset frameworks yet.

Cc Chin Liang See <[email protected]>
Cc Dalon Westergreen <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Jagan Teki <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Philipp Tomisch <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tien Fong Chee <[email protected]>

---
V2: - New patch
V3: - Add reset handling

---
 drivers/watchdog/designware_wdt.c | 40 +++++++++++++++++++++++++------
 1 file changed, 33 insertions(+), 7 deletions(-)
drivers/watchdog/designware_wdt.c +33 -7
index a7b735979a..1024a04596 100644
@@ -3,8 +3,10 @@
  * Copyright (C) 2013 Altera Corporation <www.altera.com>
  */
 
+#include <clk.h>
 #include <common.h>
 #include <dm.h>
+#include <reset.h>
 #include <wdt.h>
 #include <asm/io.h>
 #include <asm/utils.h>
@@ -15,11 +17,11 @@
 
 #define DW_WDT_CR_EN_OFFSET	0x00
 #define DW_WDT_CR_RMOD_OFFSET	0x01
-#define DW_WDT_CR_RMOD_VAL	0x00
 #define DW_WDT_CRR_RESTART_VAL	0x76
 
 struct designware_wdt_priv {
 	void __iomem	*base;
+	unsigned int	clk_khz;
 };
 
 /*
@@ -42,9 +44,7 @@ static int designware_wdt_settimeout(void __iomem *base, unsigned int clk_khz,
 
 static void designware_wdt_enable(void __iomem *base)
 {
-	writel((DW_WDT_CR_RMOD_VAL << DW_WDT_CR_RMOD_OFFSET) |
-		BIT(DW_WDT_CR_EN_OFFSET),
-		base + DW_WDT_CR);
+	writel(BIT(DW_WDT_CR_EN_OFFSET), base + DW_WDT_CR);
 }
 
 static unsigned int designware_wdt_is_enabled(void __iomem *base)
@@ -93,8 +93,7 @@ static int designware_wdt_stop(struct udevice *dev)
 	struct designware_wdt_priv *priv = dev_get_priv(dev);
 
 	designware_wdt_reset(dev);
-	writel(DW_WDT_CR_RMOD_VAL << DW_WDT_CR_RMOD_OFFSET,
-		priv->base + DW_WDT_CR);
+	writel(0, priv->base + DW_WDT_CR);
 
 	return 0;
 }
@@ -106,7 +105,7 @@ static int designware_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
 	designware_wdt_stop(dev);
 
 	/* set timer in miliseconds */
-	designware_wdt_settimeout(priv->base, CONFIG_DW_WDT_CLOCK_KHZ, timeout);
+	designware_wdt_settimeout(priv->base, priv->clk_khz, timeout);
 
 	designware_wdt_enable(priv->base);
 
@@ -117,11 +116,38 @@ static int designware_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
 static int designware_wdt_probe(struct udevice *dev)
 {
 	struct designware_wdt_priv *priv = dev_get_priv(dev);
+	__maybe_unused int ret;
 
 	priv->base = dev_remap_addr(dev);
 	if (!priv->base)
 		return -EINVAL;
 
+#if CONFIG_IS_ENABLED(CLK)
+	struct clk clk;
+
+	ret = clk_get_by_index(dev, 0, &clk);
+	if (ret)
+		return ret;
+
+	priv->clk_khz = clk_get_rate(&clk);
+	if (!priv->clk_khz)
+		return -EINVAL;
+#else
+	priv->clk_khz = CONFIG_DW_WDT_CLOCK_KHZ;
+#endif
+
+#if CONFIG_IS_ENABLED(DM_RESET)
+	struct reset_ctl_bulk resets;
+
+	ret = reset_get_bulk(dev, &resets);
+	if (ret)
+		return ret;
+
+	ret = reset_deassert_bulk(&resets);
+	if (ret)
+		return ret;
+#endif
+
 	/* reset to disable the watchdog */
 	return designware_wdt_stop(dev);
 }
Signature · 1 line
2.24.1
#4 lore raw

PATCH v3 3/3 watchdog: designware: Optionally fetch clock and reset from DT

Quoted 15 lines · Marek Vasut

Add optional support for fetching watchdog clock rate from DT and ungating reset via reset framework. This is optional as not all platforms using DW WDT support the clock and reset frameworks yet.

Cc Chin Liang See <[email protected]>
Cc Dalon Westergreen <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Jagan Teki <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Philipp Tomisch <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tien Fong Chee <[email protected]>
Quoted 4 lines

---
V2: - New patch
V3: - Add reset handling
---

#5 lore raw

PATCH v3 1/3 watchdog: designware: Migrate CONFIG_DESIGNWARE_WATCHDOG to Kconfig

In reply to Marek Vasut
Quoted 68 lines · Marek Vasut

Migrate CONFIG_DESIGNWARE_WATCHDOG to Kconfig and update the headers accordingly, no functional change. The S10 enables the WDT only in SPL, but does not enable it in U-Boot itself, hence disable it in the config again.

Cc Chin Liang See <[email protected]>
Cc Dalon Westergreen <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Jagan Teki <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Philipp Tomisch <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tien Fong Chee <[email protected]>

---
V2: Use non-DM watchdog in SPL on S10
V3: No changes

---
 configs/socfpga_stratix10_defconfig       | 1 +
 configs/socfpga_vining_fpga_defconfig     | 1 +
 drivers/watchdog/Kconfig                  | 7 +++++++
 include/configs/socfpga_common.h          | 4 +---
 include/configs/socfpga_stratix10_socdk.h | 7 +++++--
 scripts/config_whitelist.txt              | 1 -
 6 files changed, 15 insertions(+), 6 deletions(-)
configs/socfpga_stratix10_defconfig +1 -0
index 0665b460de..82ffedf41a 100644
@@ -59,3 +59,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_DWC2=y
 CONFIG_USB_STORAGE=y
 # CONFIG_SPL_USE_TINY_PRINTF is not set
+CONFIG_DESIGNWARE_WATCHDOG=y
configs/socfpga_vining_fpga_defconfig +1 -0
index 19bed6be27..0e31e4f165 100644
@@ -97,3 +97,4 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
 CONFIG_USB_GADGET_DWC2_OTG=y
 CONFIG_USB_GADGET_DOWNLOAD=y
 # CONFIG_SPL_WDT is not set
+CONFIG_DESIGNWARE_WATCHDOG=y
drivers/watchdog/Kconfig +7 -0
index 8c16d69d33..5f8a070ef5 100644
@@ -45,6 +45,13 @@ config ULP_WATCHDOG
        help
          Say Y here to enable i.MX7ULP watchdog driver.
 
+config DESIGNWARE_WATCHDOG
+       bool "Designware watchdog timer support"
+       select HW_WATCHDOG
+       help
+          Enable this to support Designware Watchdog Timer IP, present e.g.
+          on Altera SoCFPGA SoCs.
+
 config WDT
        bool "Enable driver model for watchdog timer drivers"
        depends on DM
include/configs/socfpga_common.h +0 -0
index 05bfef75c0..d1a14d23aa 100644

include/configs/socfpga_common.h line 109

Quoted 9 lines
include/configs/socfpga_common.h +1 -3
@@ -104,11 +104,9 @@
 /*
  * L4 Watchdog
  */
-#ifdef CONFIG_HW_WATCHDOG
-#define CONFIG_DESIGNWARE_WATCHDOG
 #define CONFIG_DW_WDT_BASE             SOCFPGA_L4WD0_ADDRESS
 #define CONFIG_DW_WDT_CLOCK_KHZ                25000
-#endif
+#define CONFIG_WATCHDOG_TIMEOUT_MSECS  30000

We have kconfig for this, how about moving this into defconfig file? otherwise,

#6 lore raw

PATCH v3 1/3 watchdog: designware: Migrate CONFIG_DESIGNWARE_WATCHDOG to Kconfig

Quoted 73 lines · Jagan Teki
Quoted 72 lines · Marek Vasut

Migrate CONFIG_DESIGNWARE_WATCHDOG to Kconfig and update the headers accordingly, no functional change. The S10 enables the WDT only in SPL, but does not enable it in U-Boot itself, hence disable it in the config again.

Cc Chin Liang See <[email protected]>
Cc Dalon Westergreen <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Jagan Teki <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Philipp Tomisch <[email protected]>
Cc Simon Goldschmidt <[email protected]>
Cc Tien Fong Chee <[email protected]>

---
V2: Use non-DM watchdog in SPL on S10
V3: No changes

---
 configs/socfpga_stratix10_defconfig       | 1 +
 configs/socfpga_vining_fpga_defconfig     | 1 +
 drivers/watchdog/Kconfig                  | 7 +++++++
 include/configs/socfpga_common.h          | 4 +---
 include/configs/socfpga_stratix10_socdk.h | 7 +++++--
 scripts/config_whitelist.txt              | 1 -
 6 files changed, 15 insertions(+), 6 deletions(-)
configs/socfpga_stratix10_defconfig +1 -0
index 0665b460de..82ffedf41a 100644
@@ -59,3 +59,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_DWC2=y
 CONFIG_USB_STORAGE=y
 # CONFIG_SPL_USE_TINY_PRINTF is not set
+CONFIG_DESIGNWARE_WATCHDOG=y
configs/socfpga_vining_fpga_defconfig +1 -0
index 19bed6be27..0e31e4f165 100644
@@ -97,3 +97,4 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
 CONFIG_USB_GADGET_DWC2_OTG=y
 CONFIG_USB_GADGET_DOWNLOAD=y
 # CONFIG_SPL_WDT is not set
+CONFIG_DESIGNWARE_WATCHDOG=y
drivers/watchdog/Kconfig +7 -0
index 8c16d69d33..5f8a070ef5 100644
@@ -45,6 +45,13 @@ config ULP_WATCHDOG
        help
          Say Y here to enable i.MX7ULP watchdog driver.
 
+config DESIGNWARE_WATCHDOG
+       bool "Designware watchdog timer support"
+       select HW_WATCHDOG
+       help
+          Enable this to support Designware Watchdog Timer IP, present e.g.
+          on Altera SoCFPGA SoCs.
+
 config WDT
        bool "Enable driver model for watchdog timer drivers"
        depends on DM
include/configs/socfpga_common.h +0 -1
index 05bfef75c0..d1a14d23aa 100644
@@ -104,11 +104,9 @@
 /*
  * L4 Watchdog
  */
-#ifdef CONFIG_HW_WATCHDOG
Quoted 8 lines

include/configs/socfpga_common.h line 109

Quoted 5 lines
include/configs/socfpga_common.h +1 -2
-#define CONFIG_DESIGNWARE_WATCHDOG
 #define CONFIG_DW_WDT_BASE             SOCFPGA_L4WD0_ADDRESS
 #define CONFIG_DW_WDT_CLOCK_KHZ                25000
-#endif
+#define CONFIG_WATCHDOG_TIMEOUT_MSECS  30000

We have kconfig for this, how about moving this into defconfig file? otherwise,

I sent a V4, give it a try. It's also rebased on master.