Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uboot-i9100
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
onny
uboot-i9100
Commits
2bc1821e
Commit
2bc1821e
authored
5 years ago
by
Shannon Barber
Committed by
Tom Rini
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix watchdog timeout setup for mt7623
Signed-off-by:
Shannon Barber
<
sbarber@dataspeedinc.com
>
parent
a762311a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
drivers/watchdog/mtk_wdt.c
+21
-7
21 additions, 7 deletions
drivers/watchdog/mtk_wdt.c
with
21 additions
and
7 deletions
drivers/watchdog/mtk_wdt.c
+
21
−
7
View file @
2bc1821e
...
@@ -70,18 +70,30 @@ static int mtk_wdt_expire_now(struct udevice *dev, ulong flags)
...
@@ -70,18 +70,30 @@ static int mtk_wdt_expire_now(struct udevice *dev, ulong flags)
return
0
;
return
0
;
}
}
static
void
mtk_wdt_set_timeout
(
struct
udevice
*
dev
,
unsigned
int
timeout
)
static
void
mtk_wdt_set_timeout
(
struct
udevice
*
dev
,
unsigned
int
timeout
_ms
)
{
{
struct
mtk_wdt_priv
*
priv
=
dev_get_priv
(
dev
);
struct
mtk_wdt_priv
*
priv
=
dev_get_priv
(
dev
);
/*
/*
* One bit is the value of 512 ticks
* One WDT_LENGTH count is 512 ticks of the wdt clock
* The clock has 32 KHz
* Clock runs at 32768 Hz
* e.g. 15.625 ms per count (nominal)
* We want the ceiling after dividing timeout_ms by 15.625 ms
* We add 15624 prior to the divide to implement the ceiling
* We prevent over-flow by clamping the timeout_ms value here
* as the maximum WDT_LENGTH counts is 1023 -> 15.984375 sec
* We also enforce a minimum of 1 count
* Many watchdog peripherals have a self-imposed count of 1
* that is added to the register counts.
* The MediaTek docs lack details to know if this is the case here.
* So we enforce a minimum of 1 to guarantee operation.
*/
*/
timeout
=
WDT_LENGTH_TIMEOUT
(
timeout
<<
6
)
|
WDT_LENGTH_KEY
;
if
(
timeout_ms
>
15984
)
timeout_ms
=
15984
;
writel
(
timeout
,
priv
->
base
+
MTK_WDT_LENGTH
);
u64
timeout_us
=
timeout_ms
*
1000
;
u32
timeout_cc
=
(
u32
)
(
(
15624
+
timeout_us
)
/
15625
);
mtk_wdt_reset
(
dev
);
if
(
timeout_cc
==
0
)
timeout_cc
=
1
;
u32
length
=
WDT_LENGTH_TIMEOUT
(
timeout_cc
)
|
WDT_LENGTH_KEY
;
writel
(
length
,
priv
->
base
+
MTK_WDT_LENGTH
);
}
}
static
int
mtk_wdt_start
(
struct
udevice
*
dev
,
u64
timeout
,
ulong
flags
)
static
int
mtk_wdt_start
(
struct
udevice
*
dev
,
u64
timeout
,
ulong
flags
)
...
@@ -90,6 +102,8 @@ static int mtk_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
...
@@ -90,6 +102,8 @@ static int mtk_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
mtk_wdt_set_timeout
(
dev
,
timeout
);
mtk_wdt_set_timeout
(
dev
,
timeout
);
mtk_wdt_reset
(
dev
);
/* Enable watchdog reset signal */
/* Enable watchdog reset signal */
setbits_le32
(
priv
->
base
+
MTK_WDT_MODE
,
setbits_le32
(
priv
->
base
+
MTK_WDT_MODE
,
WDT_MODE_EN
|
WDT_MODE_KEY
|
WDT_MODE_EXTEN
);
WDT_MODE_EN
|
WDT_MODE_KEY
|
WDT_MODE_EXTEN
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment