-
Notifications
You must be signed in to change notification settings - Fork 7.6k
drivers: cop: add NXP COP driver #90736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
2f86a09
to
dd7cf4c
Compare
The implementation as pushed here is functional, but IMO not ideal.
to prevent the watchdog from being disabled by This is absolutely necessary since the COP watchdog control register is write-once after reset. In reality, the macro name A cleaner solution could be to initialize the watchdog directly in |
@@ -116,6 +116,22 @@ __weak void clock_init(void) | |||
#endif | |||
} | |||
|
|||
#if defined(CONFIG_WDOG_INIT) | |||
void z_arm_watchdog_init(void) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need any actual code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why there is a giant comment saying not to single step through an empty function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put in the initial configuration. Note that this soc.c is a reference for folks who make custom boards and if they need this they will configure it the way the need to.
If we deem it useful, we can have some additional Kconfig for custom configuring the parameters.
@michal-smola @NeilChen93 as this is on MCXC, can you please help to review this PR |
As @alxrey suggests, it would be probably better to use different Kconfig symbol to disable the watchdog. Symbol WDT_DISABLE_AT_BOOT which is defined in watchdog driver could be used. The symbol is also used in the driver test. |
The thing is, since the watchdog register is write-once and can’t be disabled and re-enabled later, I’m not too comfortable leaving it up to the application to configure it early enough before it triggers a reset. I think the cleanest solution would be to configure the watchdog entirely during system init, without requiring the user to call anything manually. |
I'll suggest that we don't have too much concern over counting on the application to configure the wdog early enough. Remember that they will be making their custom board and application so using z_arm_watchdog_init() at boot time is there to basically handle this situation. |
@alxrey , configuration of wdog could be done in soc.c using soc_late_init_hook function. When the function is called, devices are already initialized and wdog driver can be used for configuration. I believe it is what you want to achieve. I tried to implement it and it works, but I am not sure if it is good practice. @dleach02 @decsny , could you comment, please? Second point is, that I was not able to disable wdog using the driver. The reason is that there is a check in mcux_cop_disable function if wdog is enabled, but it can be enabled only by calling mcux_cop_setup function which makes the first write to COPC register. After the first write the second write to disable wdog is ignored. @alxrey , could you try reproduce and fix it, please? |
Yes, you were right, thanks. I fixed it. |
Port NXP cop driver to Zephyr Signed-off-by: Alexandre Rey <[email protected]>
Add watchdog init function needed when CONFIG_WDOG_ENABLE_AT_BOOT is used. Signed-off-by: Alexandre Rey <[email protected]>
|
I think you can use either the soc_late_init_hook, soc_early_init_hook, or z_arm_watchdog_init hook. It just depends on how early or late it is needed to ensure it doesn't fire improperly. |
case 262144: | ||
data->cop_config.timeoutCycles = kCOP_2Power10CyclesOr2Power18Cycles; | ||
break; | ||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it return an error here?
Port NXP cop driver to Zephyr.