Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC DEL 1ns 4cha - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC DEL 1ns 4cha - Software
Commits
07a73b64
Commit
07a73b64
authored
Apr 23, 2012
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
acam: use kernel's div64
parent
15b73c69
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
+18
-3
acam.c
acam.c
+18
-3
No files found.
acam.c
View file @
07a73b64
...
...
@@ -14,6 +14,7 @@
#include <linux/jiffies.h>
#include <linux/io.h>
#include <linux/delay.h>
#include <linux/math64.h>
#include "fine-delay.h"
#include "hw/fd_main_regs.h"
#include "hw/acam_gpx.h"
...
...
@@ -29,7 +30,9 @@
static
int
acam_calc_pll
(
uint64_t
tref
,
int
bin
,
int
*
hsdiv_out
,
int
*
refdiv_out
)
{
uint64_t
tmpll
;
int
x
,
refdiv
,
hsdiv
;
int32_t
rem
;
/*
* Tbin(I-mode) = (Tref << refdiv) / (216 * hsdiv)
...
...
@@ -42,8 +45,14 @@ static int acam_calc_pll(uint64_t tref, int bin, int *hsdiv_out,
* and then shift out the zeros to get smaller values.
*
*/
x
=
(
tref
<<
16
)
/
216
/
bin
;
//printf("x = %lf\n", (double)x / (1<<16));
if
(
0
)
{
x
=
(
tref
<<
16
)
/
216
/
bin
;
//printf("x = %lf\n", (double)x / (1<<16));
}
else
{
/* We can't divide 64 bits in kernel space */
tmpll
=
div_u64_rem
(
tref
<<
16
,
216
,
&
rem
);
x
=
div_u64_rem
(
tmpll
,
bin
,
&
rem
);
}
/* Now, shift out the max bits (usually 7) and drop decimal part */
refdiv
=
ACAM_MAX_REFDIV
;
...
...
@@ -61,7 +70,13 @@ static int acam_calc_pll(uint64_t tref, int bin, int *hsdiv_out,
*
refdiv_out
=
refdiv
;
/* Finally, calculate what we really have */
return
(
tref
<<
refdiv
)
/
216
/
hsdiv
;
if
(
0
)
{
bin
=
(
tref
<<
refdiv
)
/
216
/
hsdiv
;
}
else
{
tmpll
=
div_u64_rem
(
tref
<<
refdiv
,
216
,
&
rem
);
bin
=
div_u64_rem
(
tmpll
,
hsdiv
,
&
rem
);
}
return
bin
;
}
static
void
acam_set_address
(
struct
spec_fd
*
fd
,
int
addr
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment