Skip to contentSkip to conversation

watchdog: imx7ulp_wdt: move post_rcs_wait into struct imx_wdt_hw_feature

PATCH Superseded Frank Li 3 participants 4 messages Jul 29, 2024

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Frank Li

author maintainer
#0 lore raw

PATCH v4 1/1 watchdog: imx7ulp_wdt: move post_rcs_wait into struct imx_wdt_hw_feature

Move post_rcs_wait into struct imx_wdt_hw_feature to simple code logic for difference compatible string.

i.MX93 watchdog needn't wait 2.5 clocks after RCS is done. So needn't set post_rcs_wait.

---
Chagne from v3 to v4:
- Go back to v2 according to Guenter's feedback
Change from v2 to v3:
- Set post_rcs_wait to false explicitly to maintain code consistency
- Add Guenter review tag.
Change from v1 to v2:
- Combine to one patch

---
 drivers/watchdog/imx7ulp_wdt.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/watchdog/imx7ulp_wdt.c +9 -12
index 94914a22daff7..3a75a6f98f8f0 100644
@@ -55,6 +55,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
 
 struct imx_wdt_hw_feature {
 	bool prescaler_enable;
+	bool post_rcs_wait;
 	u32 wdog_clock_rate;
 };
 
@@ -62,7 +63,6 @@ struct imx7ulp_wdt_device {
 	struct watchdog_device wdd;
 	void __iomem *base;
 	struct clk *clk;
-	bool post_rcs_wait;
 	bool ext_reset;
 	const struct imx_wdt_hw_feature *hw;
 };
@@ -95,7 +95,7 @@ static int imx7ulp_wdt_wait_rcs(struct imx7ulp_wdt_device *wdt)
 		ret = -ETIMEDOUT;
 
 	/* Wait 2.5 clocks after RCS done */
-	if (wdt->post_rcs_wait)
+	if (wdt->hw->post_rcs_wait)
 		usleep_range(wait_min, wait_min + 2000);
 
 	return ret;
@@ -334,15 +334,6 @@ static int imx7ulp_wdt_probe(struct platform_device *pdev)
 	/* The WDOG may need to do external reset through dedicated pin */
 	imx7ulp_wdt->ext_reset = of_property_read_bool(dev->of_node, "fsl,ext-reset-output");
 
-	imx7ulp_wdt->post_rcs_wait = true;
-	if (of_device_is_compatible(dev->of_node,
-				    "fsl,imx8ulp-wdt")) {
-		dev_info(dev, "imx8ulp wdt probe\n");
-		imx7ulp_wdt->post_rcs_wait = false;
-	} else {
-		dev_info(dev, "imx7ulp wdt probe\n");
-	}
-
 	wdog = &imx7ulp_wdt->wdd;
 	wdog->info = &imx7ulp_wdt_info;
 	wdog->ops = &imx7ulp_wdt_ops;
@@ -403,6 +394,12 @@ static const struct dev_pm_ops imx7ulp_wdt_pm_ops = {
 static const struct imx_wdt_hw_feature imx7ulp_wdt_hw = {
 	.prescaler_enable = false,
 	.wdog_clock_rate = 1000,
+	.post_rcs_wait = true,
+};
+
+static const struct imx_wdt_hw_feature imx8ulp_wdt_hw = {
+	.prescaler_enable = false,
+	.wdog_clock_rate = 1000,
 };
 
 static const struct imx_wdt_hw_feature imx93_wdt_hw = {
@@ -411,7 +408,7 @@ static const struct imx_wdt_hw_feature imx93_wdt_hw = {
 };
 
 static const struct of_device_id imx7ulp_wdt_dt_ids[] = {
-	{ .compatible = "fsl,imx8ulp-wdt", .data = &imx7ulp_wdt_hw, },
+	{ .compatible = "fsl,imx8ulp-wdt", .data = &imx8ulp_wdt_hw, },
 	{ .compatible = "fsl,imx7ulp-wdt", .data = &imx7ulp_wdt_hw, },
 	{ .compatible = "fsl,imx93-wdt", .data = &imx93_wdt_hw, },
 	{ /* sentinel */ }
Signature · 1 line
2.34.1
#1 lore raw

Le 29/07/2024 à 22:06, Frank Li a écrit :

Quoted 81 lines

Move post_rcs_wait into struct imx_wdt_hw_feature to simple code logic for difference compatible string.

i.MX93 watchdog needn't wait 2.5 clocks after RCS is done. So needn't set post_rcs_wait.

---
Chagne from v3 to v4:
- Go back to v2 according to Guenter's feedback
Change from v2 to v3:
- Set post_rcs_wait to false explicitly to maintain code consistency
- Add Guenter review tag.
Change from v1 to v2:
- Combine to one patch

---
  drivers/watchdog/imx7ulp_wdt.c | 21 +++++++++------------
  1 file changed, 9 insertions(+), 12 deletions(-)
drivers/watchdog/imx7ulp_wdt.c +8 -11
index 94914a22daff7..3a75a6f98f8f0 100644
@@ -55,6 +55,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
 
  struct imx_wdt_hw_feature {
  	bool prescaler_enable;
+	bool post_rcs_wait;
  	u32 wdog_clock_rate;
  };
 
@@ -62,7 +63,6 @@ struct imx7ulp_wdt_device {
  	struct watchdog_device wdd;
  	void __iomem *base;
  	struct clk *clk;
-	bool post_rcs_wait;
  	bool ext_reset;
  	const struct imx_wdt_hw_feature *hw;
  };
@@ -95,7 +95,7 @@ static int imx7ulp_wdt_wait_rcs(struct imx7ulp_wdt_device *wdt)
  		ret = -ETIMEDOUT;
 
  	/* Wait 2.5 clocks after RCS done */
-	if (wdt->post_rcs_wait)
+	if (wdt->hw->post_rcs_wait)
  		usleep_range(wait_min, wait_min + 2000);
 
  	return ret;
@@ -334,15 +334,6 @@ static int imx7ulp_wdt_probe(struct platform_device *pdev)
  	/* The WDOG may need to do external reset through dedicated pin */
  	imx7ulp_wdt->ext_reset = of_property_read_bool(dev->of_node, "fsl,ext-reset-output");
 
-	imx7ulp_wdt->post_rcs_wait = true;
-	if (of_device_is_compatible(dev->of_node,
-				    "fsl,imx8ulp-wdt")) {
-		dev_info(dev, "imx8ulp wdt probe\n");
-		imx7ulp_wdt->post_rcs_wait = false;
-	} else {
-		dev_info(dev, "imx7ulp wdt probe\n");
-	}
-
  	wdog = &imx7ulp_wdt->wdd;
  	wdog->info = &imx7ulp_wdt_info;
  	wdog->ops = &imx7ulp_wdt_ops;
@@ -403,6 +394,12 @@ static const struct dev_pm_ops imx7ulp_wdt_pm_ops = {
  static const struct imx_wdt_hw_feature imx7ulp_wdt_hw = {
  	.prescaler_enable = false,
  	.wdog_clock_rate = 1000,
+	.post_rcs_wait = true,
+};
+
+static const struct imx_wdt_hw_feature imx8ulp_wdt_hw = {
+	.prescaler_enable = false,
+	.wdog_clock_rate = 1000,
  };
 
  static const struct imx_wdt_hw_feature imx93_wdt_hw = {

drivers/watchdog/imx7ulp_wdt.c static const struct imx_wdt_hw_feature imx93_wdt_hw = { · line 411

Quoted 5 lines
drivers/watchdog/imx7ulp_wdt.c +1 -1
@@ -411,7 +408,7 @@ static const struct imx_wdt_hw_feature imx93_wdt_hw = {
  };
 
  static const struct of_device_id imx7ulp_wdt_dt_ids[] = {
-	{ .compatible = "fsl,imx8ulp-wdt", .data = &imx7ulp_wdt_hw, },
+	{ .compatible = "fsl,imx8ulp-wdt", .data = &imx8ulp_wdt_hw, },

Nitpick: while touching something here, should imx8ulp be after imx7ulp?

CJ

Quoted 3 lines
drivers/watchdog/imx7ulp_wdt.c +0 -0
  	{ .compatible = "fsl,imx7ulp-wdt", .data = &imx7ulp_wdt_hw, },
  	{ .compatible = "fsl,imx93-wdt", .data = &imx93_wdt_hw, },
  	{ /* sentinel */ }
author maintainer
#2 lore raw
Quoted 74 lines · Christophe JAILLET

Le 29/07/2024 à 22:06, Frank Li a écrit :

Quoted 73 lines

Move post_rcs_wait into struct imx_wdt_hw_feature to simple code logic for difference compatible string.

i.MX93 watchdog needn't wait 2.5 clocks after RCS is done. So needn't set post_rcs_wait.

---
Chagne from v3 to v4:
- Go back to v2 according to Guenter's feedback
Change from v2 to v3:
- Set post_rcs_wait to false explicitly to maintain code consistency
- Add Guenter review tag.
Change from v1 to v2:
- Combine to one patch

---
  drivers/watchdog/imx7ulp_wdt.c | 21 +++++++++------------
  1 file changed, 9 insertions(+), 12 deletions(-)
drivers/watchdog/imx7ulp_wdt.c +8 -11
index 94914a22daff7..3a75a6f98f8f0 100644
@@ -55,6 +55,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
  struct imx_wdt_hw_feature {
  	bool prescaler_enable;
+	bool post_rcs_wait;
  	u32 wdog_clock_rate;
  };
@@ -62,7 +63,6 @@ struct imx7ulp_wdt_device {
  	struct watchdog_device wdd;
  	void __iomem *base;
  	struct clk *clk;
-	bool post_rcs_wait;
  	bool ext_reset;
  	const struct imx_wdt_hw_feature *hw;
  };
@@ -95,7 +95,7 @@ static int imx7ulp_wdt_wait_rcs(struct imx7ulp_wdt_device *wdt)
  		ret = -ETIMEDOUT;
  	/* Wait 2.5 clocks after RCS done */
-	if (wdt->post_rcs_wait)
+	if (wdt->hw->post_rcs_wait)
  		usleep_range(wait_min, wait_min + 2000);
  	return ret;
@@ -334,15 +334,6 @@ static int imx7ulp_wdt_probe(struct platform_device *pdev)
  	/* The WDOG may need to do external reset through dedicated pin */
  	imx7ulp_wdt->ext_reset = of_property_read_bool(dev->of_node, "fsl,ext-reset-output");
-	imx7ulp_wdt->post_rcs_wait = true;
-	if (of_device_is_compatible(dev->of_node,
-				    "fsl,imx8ulp-wdt")) {
-		dev_info(dev, "imx8ulp wdt probe\n");
-		imx7ulp_wdt->post_rcs_wait = false;
-	} else {
-		dev_info(dev, "imx7ulp wdt probe\n");
-	}
-
  	wdog = &imx7ulp_wdt->wdd;
  	wdog->info = &imx7ulp_wdt_info;
  	wdog->ops = &imx7ulp_wdt_ops;
@@ -403,6 +394,12 @@ static const struct dev_pm_ops imx7ulp_wdt_pm_ops = {
  static const struct imx_wdt_hw_feature imx7ulp_wdt_hw = {
  	.prescaler_enable = false,
  	.wdog_clock_rate = 1000,
+	.post_rcs_wait = true,
+};
+
+static const struct imx_wdt_hw_feature imx8ulp_wdt_hw = {
+	.prescaler_enable = false,
+	.wdog_clock_rate = 1000,
  };
Quoted 8 lines

drivers/watchdog/imx7ulp_wdt.c static const struct imx_wdt_hw_feature imx93_wdt_hw = { · line 410

Quoted 6 lines
drivers/watchdog/imx7ulp_wdt.c +1 -1
  static const struct imx_wdt_hw_feature imx93_wdt_hw = {
@@ -411,7 +408,7 @@ static const struct imx_wdt_hw_feature imx93_wdt_hw = {
  };
  static const struct of_device_id imx7ulp_wdt_dt_ids[] = {
-	{ .compatible = "fsl,imx8ulp-wdt", .data = &imx7ulp_wdt_hw, },
+	{ .compatible = "fsl,imx8ulp-wdt", .data = &imx8ulp_wdt_hw, },

Nitpick: while touching something here, should imx8ulp be after imx7ulp?

Yes, it should be better.

Guenter: do you think it is okay to move it after 7ulp?

Frank

Quoted 7 lines

CJ

Quoted 3 lines
drivers/watchdog/imx7ulp_wdt.c +0 -0
  	{ .compatible = "fsl,imx7ulp-wdt", .data = &imx7ulp_wdt_hw, },
  	{ .compatible = "fsl,imx93-wdt", .data = &imx93_wdt_hw, },
  	{ /* sentinel */ }
maintainer
#3 lore raw
Quoted 84 lines · Frank Li
Quoted 74 lines · Christophe JAILLET

Le 29/07/2024 à 22:06, Frank Li a écrit :

Quoted 73 lines

Move post_rcs_wait into struct imx_wdt_hw_feature to simple code logic for difference compatible string.

i.MX93 watchdog needn't wait 2.5 clocks after RCS is done. So needn't set post_rcs_wait.

---
Chagne from v3 to v4:
- Go back to v2 according to Guenter's feedback
Change from v2 to v3:
- Set post_rcs_wait to false explicitly to maintain code consistency
- Add Guenter review tag.
Change from v1 to v2:
- Combine to one patch

---
   drivers/watchdog/imx7ulp_wdt.c | 21 +++++++++------------
   1 file changed, 9 insertions(+), 12 deletions(-)
drivers/watchdog/imx7ulp_wdt.c +8 -11
index 94914a22daff7..3a75a6f98f8f0 100644
@@ -55,6 +55,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
   struct imx_wdt_hw_feature {
   	bool prescaler_enable;
+	bool post_rcs_wait;
   	u32 wdog_clock_rate;
   };
@@ -62,7 +63,6 @@ struct imx7ulp_wdt_device {
   	struct watchdog_device wdd;
   	void __iomem *base;
   	struct clk *clk;
-	bool post_rcs_wait;
   	bool ext_reset;
   	const struct imx_wdt_hw_feature *hw;
   };
@@ -95,7 +95,7 @@ static int imx7ulp_wdt_wait_rcs(struct imx7ulp_wdt_device *wdt)
   		ret = -ETIMEDOUT;
   	/* Wait 2.5 clocks after RCS done */
-	if (wdt->post_rcs_wait)
+	if (wdt->hw->post_rcs_wait)
   		usleep_range(wait_min, wait_min + 2000);
   	return ret;
@@ -334,15 +334,6 @@ static int imx7ulp_wdt_probe(struct platform_device *pdev)
   	/* The WDOG may need to do external reset through dedicated pin */
   	imx7ulp_wdt->ext_reset = of_property_read_bool(dev->of_node, "fsl,ext-reset-output");
-	imx7ulp_wdt->post_rcs_wait = true;
-	if (of_device_is_compatible(dev->of_node,
-				    "fsl,imx8ulp-wdt")) {
-		dev_info(dev, "imx8ulp wdt probe\n");
-		imx7ulp_wdt->post_rcs_wait = false;
-	} else {
-		dev_info(dev, "imx7ulp wdt probe\n");
-	}
-
   	wdog = &imx7ulp_wdt->wdd;
   	wdog->info = &imx7ulp_wdt_info;
   	wdog->ops = &imx7ulp_wdt_ops;
@@ -403,6 +394,12 @@ static const struct dev_pm_ops imx7ulp_wdt_pm_ops = {
   static const struct imx_wdt_hw_feature imx7ulp_wdt_hw = {
   	.prescaler_enable = false,
   	.wdog_clock_rate = 1000,
+	.post_rcs_wait = true,
+};
+
+static const struct imx_wdt_hw_feature imx8ulp_wdt_hw = {
+	.prescaler_enable = false,
+	.wdog_clock_rate = 1000,
   };
Quoted 8 lines

drivers/watchdog/imx7ulp_wdt.c static const struct imx_wdt_hw_feature imx93_wdt_hw = { · line 410

Quoted 6 lines
drivers/watchdog/imx7ulp_wdt.c +1 -1
   static const struct imx_wdt_hw_feature imx93_wdt_hw = {
@@ -411,7 +408,7 @@ static const struct imx_wdt_hw_feature imx93_wdt_hw = {
   };
   static const struct of_device_id imx7ulp_wdt_dt_ids[] = {
-	{ .compatible = "fsl,imx8ulp-wdt", .data = &imx7ulp_wdt_hw, },
+	{ .compatible = "fsl,imx8ulp-wdt", .data = &imx8ulp_wdt_hw, },

Nitpick: while touching something here, should imx8ulp be after imx7ulp?

Quoted 4 lines

Yes, it should be better.

Guenter: do you think it is okay to move it after 7ulp?

Sure

Guenter

Quoted 9 lines

Frank

Quoted 7 lines

CJ

Quoted 3 lines
drivers/watchdog/imx7ulp_wdt.c +0 -0
   	{ .compatible = "fsl,imx7ulp-wdt", .data = &imx7ulp_wdt_hw, },
   	{ .compatible = "fsl,imx93-wdt", .data = &imx93_wdt_hw, },
   	{ /* sentinel */ }