Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
linux
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martyn Welch
linux
Commits
93c846f9
Commit
93c846f9
authored
Oct 19, 2007
by
Ralf Baechle
Browse files
Options
Downloads
Patches
Plain Diff
[MIPS] time: Helpers to compute clocksource/event shift and mult values.
Signed-off-by:
Ralf Baechle
<
ralf@linux-mips.org
>
parent
f887b93e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
arch/mips/kernel/time.c
+31
-8
31 additions, 8 deletions
arch/mips/kernel/time.c
include/asm-mips/time.h
+5
-0
5 additions, 0 deletions
include/asm-mips/time.h
with
36 additions
and
8 deletions
arch/mips/kernel/time.c
+
31
−
8
View file @
93c846f9
...
...
@@ -171,25 +171,48 @@ struct clocksource clocksource_mips = {
.
flags
=
CLOCK_SOURCE_IS_CONTINUOUS
,
};
static
void
__init
init_mips_clocksource
(
void
)
void
__init
clocksource_set_clock
(
struct
clocksource
*
cs
,
unsigned
int
clock
)
{
u64
temp
;
u32
shift
;
if
(
!
mips_hpt_frequency
||
clocksource_mips
.
read
==
null_hpt_read
)
return
;
/* Find a shift value */
for
(
shift
=
32
;
shift
>
0
;
shift
--
)
{
temp
=
(
u64
)
NSEC_PER_SEC
<<
shift
;
do_div
(
temp
,
clock
);
if
((
temp
>>
32
)
==
0
)
break
;
}
cs
->
shift
=
shift
;
cs
->
mult
=
(
u32
)
temp
;
}
void
__cpuinit
clockevent_set_clock
(
struct
clock_event_device
*
cd
,
unsigned
int
clock
)
{
u64
temp
;
u32
shift
;
/* Calclate a somewhat reasonable rating value */
clocksource_mips
.
rating
=
200
+
mips_hpt_frequency
/
10000000
;
/* Find a shift value */
for
(
shift
=
32
;
shift
>
0
;
shift
--
)
{
temp
=
(
u64
)
NSEC_PER_SEC
<<
shift
;
do_div
(
temp
,
mips_hpt_frequency
);
do_div
(
temp
,
clock
);
if
((
temp
>>
32
)
==
0
)
break
;
}
clocksource_mips
.
shift
=
shift
;
clocksource_mips
.
mult
=
(
u32
)
temp
;
cd
->
shift
=
shift
;
cd
->
mult
=
(
u32
)
temp
;
}
static
void
__init
init_mips_clocksource
(
void
)
{
if
(
!
mips_hpt_frequency
||
clocksource_mips
.
read
==
null_hpt_read
)
return
;
/* Calclate a somewhat reasonable rating value */
clocksource_mips
.
rating
=
200
+
mips_hpt_frequency
/
10000000
;
clocksource_set_clock
(
&
clocksource_mips
,
mips_hpt_frequency
);
clocksource_register
(
&
clocksource_mips
);
}
...
...
This diff is collapsed.
Click to expand it.
include/asm-mips/time.h
+
5
−
0
View file @
93c846f9
...
...
@@ -21,6 +21,7 @@
#include
<linux/ptrace.h>
#include
<linux/rtc.h>
#include
<linux/spinlock.h>
#include
<linux/clockchips.h>
#include
<linux/clocksource.h>
extern
spinlock_t
rtc_lock
;
...
...
@@ -83,4 +84,8 @@ static inline void mips_clockevent_init(void)
}
#endif
extern
void
clocksource_set_clock
(
struct
clocksource
*
cs
,
unsigned
int
clock
);
extern
void
clockevent_set_clock
(
struct
clock_event_device
*
cd
,
unsigned
int
clock
);
#endif
/* _ASM_TIME_H */
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