cns3xxx: fix mpcore watchdog
authorKoen Vandeputte <koen.vandeputte@ncentric.com>
Wed, 12 Apr 2017 09:10:59 +0000 (11:10 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 12 Apr 2017 10:13:15 +0000 (12:13 +0200)
commit84acff2865660d361283eaa4d995913c955d826b
tree2955f93d636a95bd5a50fe35942d8de7950a433c
parent6f8a552796cb53dc232b66ada8d6b91fa8ce0ef9
cns3xxx: fix mpcore watchdog

The original implementation loaded the count register with (wrong) semi-
random values due to its implemenation nature.

If the wrongly calulated value was below the kickrate,
the WD was triggered and rebooted the system.

Rework this, partly based on upstream patches, to dynamically fetch the
current clockrate and calculate the proper offset for the WD countdown
register.

Before:

[  143.800000] count val: 27219720
[  148.820000] count val: 50623201
[  153.830000] count val: 96425250
[  158.830000] count val: 89735401
[  163.840000] count val: 4756110

After:

[    0.700000] MPCore WD init. clockrate: 299984500 prescaler: 256
countrate: 1171814 timeout: 60s
[  358.530000] count val: 35154751
[  363.540000] count val: 35154750
[  368.540000] count val: 35154751
[  373.550000] count val: 35154750

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
target/linux/cns3xxx/patches-4.9/020-watchdog_support.patch