mirror of
				https://xff.cz/git/u-boot/
				synced 2025-10-31 18:35:42 +01:00 
			
		
		
		
	watchdog: introduce a u-boot,autostart property
This is a companion to u-boot,noautostart. If one has a single watchdog device that one does want to have auto-started, but several others that one doesn't, the only way currently is to set the CONFIG_WATCHDOG_AUTOSTART and then use the opt-out for the majority. The main motivation for this is to add an autostarted watchdog device to the sandbox (to test a fix) without having to set AUTOSTART in sandbox_defconfig and add the noautostart property to the existing devices. But it's also nice for symmetry, and the logic in init_watchdog_dev() becomes simpler to read because we avoid all the negations. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
This commit is contained in:
		
				
					committed by
					
						 Stefan Roese
						Stefan Roese
					
				
			
			
				
	
			
			
			
						parent
						
							0ab55cb6f7
						
					
				
				
					commit
					2783670583
				
			| @@ -6,7 +6,8 @@ Optional properties: | |||||||
|                 be used instead. |                 be used instead. | ||||||
| - hw_margin_ms : Period used to reset the watchdog in ms | - hw_margin_ms : Period used to reset the watchdog in ms | ||||||
|                  If this period is not defined, the default value is 1000. |                  If this period is not defined, the default value is 1000. | ||||||
| - u-boot,noautostart : Specify that this watchdog should not autostart | - u-boot,noautostart : | ||||||
|                        When the config option WATCHDOG_AUTOSTART is set, all enabled | - u-boot,autostart : These (mutually exclusive) boolean properties can be used to control | ||||||
|                        watchdogs are started. This property allows specifying that this |                      whether the watchdog is automatically started when probed. If neither | ||||||
|                        watchdog should NOT be started. |                      are present, the behaviour is determined by the config option | ||||||
|  |                      WATCHDOG_AUTOSTART. | ||||||
|   | |||||||
| @@ -37,8 +37,8 @@ struct wdt_priv { | |||||||
| 	ulong next_reset; | 	ulong next_reset; | ||||||
| 	/* Whether watchdog_start() has been called on the device. */ | 	/* Whether watchdog_start() has been called on the device. */ | ||||||
| 	bool running; | 	bool running; | ||||||
| 	/* No autostart */ | 	/* autostart */ | ||||||
| 	bool noautostart; | 	bool autostart; | ||||||
|  |  | ||||||
| 	struct cyclic_info *cyclic; | 	struct cyclic_info *cyclic; | ||||||
| }; | }; | ||||||
| @@ -72,7 +72,7 @@ static void init_watchdog_dev(struct udevice *dev) | |||||||
| 			       dev->name); | 			       dev->name); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (!IS_ENABLED(CONFIG_WATCHDOG_AUTOSTART) || priv->noautostart) { | 	if (!priv->autostart) { | ||||||
| 		printf("WDT:   Not starting %s\n", dev->name); | 		printf("WDT:   Not starting %s\n", dev->name); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| @@ -267,19 +267,22 @@ static int wdt_pre_probe(struct udevice *dev) | |||||||
| 	 * indicated by a hw_margin_ms property. | 	 * indicated by a hw_margin_ms property. | ||||||
| 	 */ | 	 */ | ||||||
| 	ulong reset_period = 1000; | 	ulong reset_period = 1000; | ||||||
| 	bool noautostart = false; | 	bool autostart = IS_ENABLED(CONFIG_WATCHDOG_AUTOSTART); | ||||||
| 	struct wdt_priv *priv; | 	struct wdt_priv *priv; | ||||||
|  |  | ||||||
| 	if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) { | 	if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) { | ||||||
| 		timeout = dev_read_u32_default(dev, "timeout-sec", timeout); | 		timeout = dev_read_u32_default(dev, "timeout-sec", timeout); | ||||||
| 		reset_period = dev_read_u32_default(dev, "hw_margin_ms", | 		reset_period = dev_read_u32_default(dev, "hw_margin_ms", | ||||||
| 						    4 * reset_period) / 4; | 						    4 * reset_period) / 4; | ||||||
| 		noautostart = dev_read_bool(dev, "u-boot,noautostart"); | 		if (dev_read_bool(dev, "u-boot,noautostart")) | ||||||
|  | 			autostart = false; | ||||||
|  | 		else if (dev_read_bool(dev, "u-boot,autostart")) | ||||||
|  | 			autostart = true; | ||||||
| 	} | 	} | ||||||
| 	priv = dev_get_uclass_priv(dev); | 	priv = dev_get_uclass_priv(dev); | ||||||
| 	priv->timeout = timeout; | 	priv->timeout = timeout; | ||||||
| 	priv->reset_period = reset_period; | 	priv->reset_period = reset_period; | ||||||
| 	priv->noautostart = noautostart; | 	priv->autostart = autostart; | ||||||
| 	/* | 	/* | ||||||
| 	 * Pretend this device was last reset "long" ago so the first | 	 * Pretend this device was last reset "long" ago so the first | ||||||
| 	 * watchdog_reset will actually call its ->reset method. | 	 * watchdog_reset will actually call its ->reset method. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user