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
d57aed07
Commit
d57aed07
authored
Apr 17, 2012
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pll: completed initialization
parent
c359d28e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
6 deletions
+49
-6
pll.c
pll.c
+49
-6
No files found.
pll.c
View file @
d57aed07
...
...
@@ -11,8 +11,12 @@
* option, any later version.
*/
#include <linux/kernel.h>
#include <linux/io.h>
#include <linux/delay.h>
#include <linux/jiffies.h>
#include "fine-delay.h"
#include "hw/pll_config.h"
/* the table to be written */
static
int
pll_writel
(
struct
spec_fd
*
fd
,
int
val
,
int
reg
)
{
...
...
@@ -32,23 +36,62 @@ static int pll_readl(struct spec_fd *fd, int reg)
int
fd_pll_init
(
struct
spec_fd
*
fd
)
{
int
reg
;
int
i
;
unsigned
long
j
;
const
struct
ad9516_reg
*
r
;
pr_debug
(
"%s
\n
"
,
__func__
);
if
(
pll_writel
(
fd
,
0x99
,
0x000
)
<
0
)
goto
out
;
if
(
pll_writel
(
fd
,
0x01
,
0x232
)
<
0
)
goto
out
;
reg
=
pll_readl
(
fd
,
0x003
);
if
(
reg
<
0
)
i
=
pll_readl
(
fd
,
0x003
);
if
(
i
<
0
)
goto
out
;
if
(
reg
!=
0xc3
)
{
if
(
i
!=
0xc3
)
{
pr_err
(
"%s: Error in PLL communication
\n
"
,
KBUILD_MODNAME
);
pr_err
(
" (got 0x%x, expected 0xc3)
\n
"
,
reg
);
pr_err
(
" (got 0x%x, expected 0xc3)
\n
"
,
i
);
return
-
EIO
;
}
/* FIXME: program the pll */
/* Write the magic config */
for
(
i
=
0
,
r
=
__9516_regs
;
i
<
ARRAY_SIZE
(
__9516_regs
);
i
++
,
r
++
)
{
if
(
pll_writel
(
fd
,
r
->
val
,
r
->
reg
)
<
0
)
{
pr_err
(
"%s: Error in configuring PLL (step %i)
\n
"
,
KBUILD_MODNAME
,
i
);
return
-
EIO
;
}
}
if
(
pll_writel
(
fd
,
0x01
,
0x232
)
<
0
)
goto
out
;
/* Wait for it to lock */
j
=
jiffies
+
HZ
/
2
;
while
(
jiffies
<
j
)
{
i
=
pll_readl
(
fd
,
0x1f
);
if
(
i
<
0
)
return
-
EIO
;
if
(
i
&
1
)
break
;
msleep
(
1
);
}
if
(
!
(
i
&
1
))
return
-
ETIMEDOUT
;
/*
* Synchronize the phase of all clock outputs
* (this is critical for the accuracy!)
*/
if
(
pll_writel
(
fd
,
0x01
,
0x230
)
<
0
)
goto
out
;
if
(
pll_writel
(
fd
,
0x01
,
0x232
)
<
0
)
goto
out
;
if
(
pll_writel
(
fd
,
0x00
,
0x230
)
<
0
)
goto
out
;
if
(
pll_writel
(
fd
,
0x01
,
0x232
)
<
0
)
goto
out
;
pr_debug
(
"success!
\n
"
);
return
0
;
...
...
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