Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
31
Issues
31
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
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
Software for White Rabbit PTP Core
Commits
e7ffad39
Commit
e7ffad39
authored
Sep 18, 2019
by
José López Jiménez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Softpll kp and ki modifiable in runtime
parent
abf90c8b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
202 additions
and
3 deletions
+202
-3
rt_ipc.c
ipc/rt_ipc.c
+30
-3
rt_ipc.h
ipc/rt_ipc.h
+27
-0
softpll_ng.c
softpll/softpll_ng.c
+83
-0
softpll_ng.h
softpll/softpll_ng.h
+12
-0
spll_helper.c
softpll/spll_helper.c
+25
-0
spll_main.c
softpll/spll_main.c
+25
-0
No files found.
ipc/rt_ipc.c
View file @
e7ffad39
...
...
@@ -139,6 +139,17 @@ void rts_update(void)
}
}
int
rts_spll_set_constants
(
int
loop
,
int
param
,
int
value
)
{
return
spll_set_pi
(
loop
,
param
,
value
);
}
int
rts_spll_get_constants
(
int
loop
,
int
param
,
int
*
value
)
{
int
ret
=
spll_get_pi
(
loop
,
param
,
&
value
);
// tbd: &value is not used at the moment.
return
ret
;
}
/* fixme: this assumes the host is BE */
static
int
htonl
(
int
i
)
...
...
@@ -211,7 +222,19 @@ static int rts_debug_command_func(const struct minipc_pd *pd, uint32_t *args, vo
return
0
;
}
static
int
rts_spll_set_constants_func
(
const
struct
minipc_pd
*
pd
,
uint32_t
*
args
,
void
*
ret
)
{
pstate
.
ipc_count
++
;
*
(
int
*
)
ret
=
rts_spll_set_constants
((
int
)
args
[
0
],
(
int
)
args
[
1
],
(
int
)
args
[
2
]);
return
0
;
}
static
int
rts_spll_get_constants_func
(
const
struct
minipc_pd
*
pd
,
uint32_t
*
args
,
void
*
ret
)
{
pstate
.
ipc_count
++
;
*
(
int
*
)
ret
=
rts_spll_get_constants
((
int
)
args
[
0
],(
int
)
args
[
1
],
(
int
)
args
[
2
]);
return
ret
;
}
static
struct
minipc_ch
*
server
;
...
...
@@ -228,13 +251,17 @@ int rtipc_init(void)
rtipc_rts_adjust_phase_struct
.
f
=
rts_adjust_phase_func
;
rtipc_rts_enable_ptracker_struct
.
f
=
rts_enable_ptracker_func
;
rtipc_rts_debug_command_struct
.
f
=
rts_debug_command_func
;
rtipc_rts_spll_set_constants_struct
.
f
=
rts_spll_set_constants_func
;
rtipc_rts_spll_get_constants_struct
.
f
=
rts_spll_get_constants_func
;
minipc_export
(
server
,
&
rtipc_rts_set_mode_struct
);
minipc_export
(
server
,
&
rtipc_rts_get_state_struct
);
minipc_export
(
server
,
&
rtipc_rts_lock_channel_struct
);
minipc_export
(
server
,
&
rtipc_rts_adjust_phase_struct
);
minipc_export
(
server
,
&
rtipc_rts_enable_ptracker_struct
);
minipc_export
(
server
,
&
rtipc_rts_debug_command_struct
);
minipc_export
(
server
,
&
rtipc_rts_adjust_phase_struct
);
minipc_export
(
server
,
&
rtipc_rts_enable_ptracker_struct
);
minipc_export
(
server
,
&
rtipc_rts_debug_command_struct
);
minipc_export
(
server
,
&
rtipc_rts_spll_set_constants_struct
);
minipc_export
(
server
,
&
rtipc_rts_spll_get_constants_struct
);
return
0
;
...
...
ipc/rt_ipc.h
View file @
e7ffad39
...
...
@@ -128,6 +128,10 @@ int rts_enable_ptracker(int channel, int enable);
/* Enabled/disables phase tracking on a particular port */
int
rts_debug_command
(
int
param
,
int
value
);
int
rts_spll_get_constants
(
int
loop
,
int
param
,
int
*
value
);
int
rts_spll_set_constants
(
int
loop
,
int
param
,
int
value
);
#ifdef RTIPC_EXPORT_STRUCTURES
static
struct
minipc_pd
rtipc_rts_get_state_struct
=
{
...
...
@@ -187,6 +191,29 @@ static struct minipc_pd rtipc_rts_debug_command_struct = {
},
};
static
struct
minipc_pd
rtipc_rts_spll_set_constants_struct
=
{
.
name
=
"gggg"
,
.
retval
=
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
.
args
=
{
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
MINIPC_ARG_END
},
};
static
struct
minipc_pd
rtipc_rts_spll_get_constants_struct
=
{
.
name
=
"hhhh"
,
.
retval
=
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
.
args
=
{
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
MINIPC_ARG_END
},
};
#endif
#endif
softpll/softpll_ng.c
View file @
e7ffad39
...
...
@@ -716,3 +716,86 @@ void check_vco_frequencies()
pll_verbose
(
"EXT clock: Freq=%d Hz
\n
"
,
f_min
);
}
int
spll_set_pi
(
int
loop
,
int
param
,
int
value
)
{
struct
softpll_state
*
s
=
(
struct
softpll_state
*
)
&
softpll
;
switch
(
loop
)
{
case
SPLL_MAIN_LOOP
:
if
(
param
==
SPLL_KP
)
{
s
->
mpll
.
pi
.
kp
=
value
;
return
0
;
}
else
if
(
param
==
SPLL_KI
)
{
s
->
mpll
.
pi
.
ki
=
value
;
return
0
;
}
else
return
-
1
;
case
SPLL_HELPER_LOOP
:
if
(
param
==
SPLL_KP
)
{
s
->
helper
.
pi
.
kp
=
value
;
return
0
;
}
else
if
(
param
==
SPLL_KI
)
{
s
->
helper
.
pi
.
ki
=
value
;
return
0
;
}
else
return
-
1
;
default:
return
-
1
;
break
;
}
}
int
spll_get_pi
(
int
loop
,
int
param
,
int
*
value
)
{
struct
softpll_state
*
s
=
(
struct
softpll_state
*
)
&
softpll
;
switch
(
loop
)
{
case
SPLL_MAIN_LOOP
:
if
(
param
==
SPLL_KP
)
{
pp_printf
(
"Main kp: %d
\n
"
,
s
->
mpll
.
pi
.
kp
);
*
value
=
s
->
mpll
.
pi
.
kp
;
return
s
->
mpll
.
pi
.
kp
;
}
else
if
(
param
==
SPLL_KI
)
{
pp_printf
(
"Main ki: %d
\n
"
,
s
->
mpll
.
pi
.
ki
);
*
value
=
s
->
mpll
.
pi
.
ki
;
return
s
->
mpll
.
pi
.
ki
;
}
else
return
-
1
;
break
;
case
SPLL_HELPER_LOOP
:
if
(
param
==
SPLL_KP
)
{
pp_printf
(
"Helper kp: %d
\n
"
,
s
->
helper
.
pi
.
kp
);
*
value
=
s
->
helper
.
pi
.
kp
;
return
s
->
helper
.
pi
.
kp
;
}
else
if
(
param
==
SPLL_KI
)
{
pp_printf
(
"Helper ki: %d
\n
"
,
s
->
helper
.
pi
.
ki
);
*
value
=
s
->
helper
.
pi
.
ki
;
return
s
->
helper
.
pi
.
ki
;
}
else
return
-
1
;
break
;
default:
return
-
1
;
break
;
}
}
softpll/softpll_ng.h
View file @
e7ffad39
...
...
@@ -40,6 +40,12 @@
#define SPLL_OSC_DMTD 1
#define SPLL_OSC_EXT 2
/* Change spll PI loop in real time */
#define SPLL_MAIN_LOOP 0
#define SPLL_HELPER_LOOP 1
#define SPLL_KP 0
#define SPLL_KI 1
/* Note on channel naming:
- ref_channel means a PHY recovered clock input. There can be one (as in WR core) or more (WR switch).
- out_channel means an output channel, which represents PLL feedback signal from a local, tunable oscillator. Every SPLL implementation
...
...
@@ -112,6 +118,12 @@ int spll_get_dac(int out_channel);
void
check_vco_frequencies
(
void
);
/* Returns the values of kp/ki of the PI loops */
int
spll_get_pi
(
int
loop
,
int
param
,
int
*
value
);
/* Changes the value of the kp/ki constants of the PI loops during runtime */
int
spll_set_pi
(
int
loop
,
int
param
,
int
value
);
/*
* Aux and main state:
* used to be in .c file, but we need it here for memory dumping
...
...
softpll/spll_helper.c
View file @
e7ffad39
...
...
@@ -126,3 +126,28 @@ void helper_switch_reference(struct spll_helper_state *s, int new_ref)
spll_enable_tagger(s->ref_src, 1);
#endif
}
int
helper_get_pi
(
struct
spll_helper_state
*
s
,
int
param
)
{
if
(
param
==
SPLL_KP
)
return
s
->
pi
.
kp
;
else
if
(
param
==
SPLL_KI
)
return
s
->
pi
.
ki
;
else
return
-
1
;
}
int
helper_set_pi
(
struct
spll_helper_state
*
s
,
int
param
,
int
value
)
{
if
(
param
==
SPLL_KP
)
{
s
->
pi
.
kp
=
value
;
return
0
;
}
if
(
param
==
SPLL_KI
)
{
s
->
pi
.
ki
=
value
;
return
0
;
}
return
-
1
;
}
softpll/spll_main.c
View file @
e7ffad39
...
...
@@ -239,3 +239,28 @@ int mpll_shifter_busy(struct spll_main_state *s)
{
return
s
->
phase_shift_target
!=
s
->
phase_shift_current
;
}
int
mpll_get_pi
(
struct
spll_main_state
*
s
,
int
param
)
{
if
(
param
==
SPLL_KP
)
return
s
->
pi
.
kp
;
else
if
(
param
==
SPLL_KI
)
return
s
->
pi
.
ki
;
else
return
-
1
;
}
int
mpll_set_pi
(
struct
spll_main_state
*
s
,
int
param
,
int
value
)
{
if
(
param
==
SPLL_KP
)
{
s
->
pi
.
kp
=
value
;
return
0
;
}
if
(
param
==
SPLL_KI
)
{
s
->
pi
.
ki
=
value
;
return
0
;
}
return
-
1
;
}
\ No newline at end of file
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