Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
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
White Rabbit Switch - Software
Commits
c8e46bbb
Commit
c8e46bbb
authored
Nov 20, 2018
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Plain Diff
Merge function to enable/disable PPS-in termination
Signed-off-by:
Adam Wujek
<
adam.wujek@cern.ch
>
parents
09f7e0b5
1ec5593b
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
170 additions
and
16 deletions
+170
-16
Kconfig
Kconfig
+6
-0
wrs-user-manual.in
doc/wrs-user-manual.in
+12
-3
ppsg-regs.h
kernel/wbgen-regs/ppsg-regs.h
+3
-0
ppsg-regs.wb
kernel/wbgen-regs/ppsg-regs.wb
+12
-0
pps_gen.h
userspace/libwr/include/libwr/pps_gen.h
+18
-0
init.c
userspace/libwr/init.c
+4
-0
pps_gen.c
userspace/libwr/pps_gen.c
+57
-0
wrs_pps_control.c
userspace/tools/wrs_pps_control.c
+58
-13
No files found.
Kconfig
View file @
c8e46bbb
...
...
@@ -976,6 +976,12 @@ config NIC_THROTTLING_VAL
endmenu
config PPS_IN_TERM_50OHM
bool "Enable 50ohm termination for 1-PPS input"
default n
help
Enable 50ohm termination for 1-PPS input.
menu "Custom boot script configuration"
config CUSTOM_BOOT_SCRIPT_ENABLED
bool "Execute custom script"
...
...
doc/wrs-user-manual.in
View file @
c8e46bbb
...
...
@@ -972,6 +972,9 @@ appropriate way, before the respective service is started.
@t
{
CONFIG
_
NIC
_
THROTTLING
_
VAL
}
contains maximum allowed bandwidth
in KB/s.
@item CONFIG
_
PPS
_
IN
_
TERM
_
50OHM
Enable 50ohm termination for 1-PPS input.
@item CONFIG
_
CUSTOM
_
BOOT
_
SCRIPT
_
ENABLED
@itemx CONFIG
_
CUSTOM
_
BOOT
_
SCRIPT
_
SOURCE
_
LOCAL
@itemx CONFIG
_
CUSTOM
_
BOOT
_
SCRIPT
_
SOURCE
_
REMOTE
...
...
@@ -1853,11 +1856,17 @@ The following tools and scripts are provided:
(This is probably the most important diagnostic tool on the switch.)
@item wrs
_
pps
_
control
A tool to switch the PPS output on and off. Usage: ``@t
{
wrs
_
pps
_
control
on
}
'' switches the PPS output on, and ``@t
{
wrs
_
pps
_
control off
}
''
switches the PPS output off. Switching the output on/off is independent
A tool to switch the PPS output on and off or reads its setting.
It can also on/off/read the 50ohm termination for 1-PPS input.
Usage: ``@t
{
wrs
_
pps
_
control pps on
}
'' switches the PPS output on,
``@t
{
wrs
_
pps
_
control pps off
}
'' switches the PPS output off, and
``@t
{
wrs
_
pps
_
control pps read
}
'' check whether PPS output is set to
on or off. Switching the output on/off is independent
of the PPSi process, but PPSi switches the PPS output back on when a
link restart is detected and PPSi comes into @t
{
'TRACK
_
PHASE'
}
state.
To on/off/read the 50ohm termination for 1-PPS input use
@t
{
wrs
_
pps
_
control
}
with a parameter @t
{
50ohm-term-in
}
followed by
@t
{
on
}
, @t
{
off
}
or @t
{
read
}
.
@item wr
_
date
...
...
kernel/wbgen-regs/ppsg-regs.h
View file @
c8e46bbb
...
...
@@ -84,6 +84,9 @@
/* definitions for field: Set nanoseconds counter in reg: External sync control register */
#define PPSG_ESCR_NSEC_SET WBGEN2_GEN_MASK(4, 1)
/* definitions for field: Enable PPS_IN 50Ohm termination in reg: External sync control register */
#define PPSG_ESCR_PPS_IN_TERM WBGEN2_GEN_MASK(5, 1)
PACKED
struct
PPSG_WB
{
/* [0x0]: REG Control Register */
uint32_t
CR
;
...
...
kernel/wbgen-regs/ppsg-regs.wb
View file @
c8e46bbb
...
...
@@ -210,6 +210,18 @@ peripheral {
clock = "refclk_i";
};
field {
name = "Enable PPS_IN 50Ohm termination";
description = "write 1: enable 50ohm termination for 1-PPS input \
write 0: disable 50ohm termination for 1-PPS input \
read 1: 50ohm termination for 1-PPS input enabled \
read 0: 50ohm termination for 1-PPS input disabled";
prefix = "PPS_IN_TERM";
type = BIT;
access_bus = READ_WRITE;
access_dev = READ_ONLY;
};
};
};
userspace/libwr/include/libwr/pps_gen.h
View file @
c8e46bbb
...
...
@@ -9,6 +9,12 @@
#define PPSG_ADJUST_SEC 0x1
#define PPSG_ADJUST_NSEC 0x2
#define PPSG_PPS_OUT_ENABLE 0x1
#define PPSG_PPS_OUT_DISABLE 0x0
#define PPSG_PPS_IN_TERM_50OHM_ENABLE 0x1
#define PPSG_PPS_IN_TERM_50OHM_DISABLE 0x0
/* Initializes the PPS Generator. 0 on success, negative on failure. */
int
shw_pps_gen_init
(
void
);
...
...
@@ -21,7 +27,19 @@ int shw_pps_gen_busy(void);
/* Enables/disables PPS Generator PPS output */
int
shw_pps_gen_enable_output
(
int
enable
);
/* Reads PPS Generator PPS output */
int
shw_pps_gen_enable_output_read
(
void
);
/* Reads the current time and stores at <seconds,nanoseconds>. */
void
shw_pps_gen_read_time
(
uint64_t
*
seconds
,
uint32_t
*
nanoseconds
);
/* Enables PPS_IN 50Ohm termination */
void
shw_pps_gen_in_term_enable
(
int
enable
);
/* Reads status of PPS_IN 50Ohm termination */
int
shw_pps_gen_in_term_read
(
void
);
/* Enables PPS_IN 50Ohm termination based on dot-config option */
int
shw_pps_gen_in_term_init
(
void
);
#endif
/* __LIBWR_PPS_GEN_H */
userspace/libwr/init.c
View file @
c8e46bbb
...
...
@@ -7,6 +7,7 @@
#include "i2c_sfp.h"
#include <libwr/shw_io.h>
#include <libwr/wrs-msg.h>
#include <libwr/pps_gen.h>
int
shw_init
()
{
...
...
@@ -31,6 +32,9 @@ int shw_init()
/* Init the FANs */
assert_init
(
shw_init_fans
());
/* Set 50ohm termination on 1-PPS in if needed */
assert_init
(
shw_pps_gen_in_term_init
());
pr_info
(
"HW initialization done!
\n
"
);
return
0
;
}
...
...
userspace/libwr/pps_gen.c
View file @
c8e46bbb
...
...
@@ -15,6 +15,7 @@
#include <libwr/switch_hw.h>
#include <libwr/wrs-msg.h>
#include <libwr/config.h>
/* Default width (in 8ns units) of the pulses on the PPS output */
#define PPS_WIDTH 100000
...
...
@@ -85,6 +86,15 @@ int shw_pps_gen_enable_output(int enable)
return
0
;
}
/* Enables/disables PPS output */
int
shw_pps_gen_enable_output_read
(
void
)
{
uint32_t
escr
=
ppsg_read
(
ESCR
);
return
escr
&
PPSG_ESCR_PPS_VALID
?
PPSG_PPS_OUT_ENABLE
:
PPSG_PPS_OUT_DISABLE
;
}
void
shw_pps_gen_read_time
(
uint64_t
*
seconds
,
uint32_t
*
nanoseconds
)
{
uint32_t
ns_cnt
;
...
...
@@ -105,3 +115,50 @@ void shw_pps_gen_read_time(uint64_t * seconds, uint32_t * nanoseconds)
if
(
nanoseconds
)
*
nanoseconds
=
ns_cnt
;
}
void
shw_pps_gen_in_term_enable
(
int
enable
)
{
uint32_t
escr
=
ppsg_read
(
ESCR
);
if
(
enable
)
ppsg_write
(
ESCR
,
escr
|
PPSG_ESCR_PPS_IN_TERM
);
else
ppsg_write
(
ESCR
,
escr
&
~
PPSG_ESCR_PPS_IN_TERM
);
}
int
shw_pps_gen_in_term_read
(
void
)
{
uint32_t
escr
=
ppsg_read
(
ESCR
);
return
escr
&
PPSG_ESCR_PPS_IN_TERM
?
PPSG_PPS_IN_TERM_50OHM_ENABLE
:
PPSG_PPS_IN_TERM_50OHM_DISABLE
;
}
/* Enable PPS_IN 50Ohm termination based on dot-config option */
int
shw_pps_gen_in_term_init
(
void
)
{
char
*
config_item
;
config_item
=
libwr_cfg_get
(
"PPS_IN_TERM_50OHM"
);
if
((
config_item
)
&&
!
strcmp
(
config_item
,
"y"
))
{
pr_info
(
"Enabling 50ohm termination on 1-PPS in
\n
"
);
shw_pps_gen_in_term_enable
(
PPSG_PPS_IN_TERM_50OHM_ENABLE
);
if
(
shw_pps_gen_in_term_read
()
!=
PPSG_PPS_IN_TERM_50OHM_ENABLE
)
{
pr_err
(
"Unable to enable 50ohm termination on 1-PPS "
"in
\n
"
);
}
}
else
if
(
shw_pps_gen_in_term_read
()
==
PPSG_PPS_IN_TERM_50OHM_ENABLE
)
{
pr_info
(
"Disabling previously enabled 50ohm termination on "
"1-PPS in
\n
"
);
shw_pps_gen_in_term_enable
(
PPSG_PPS_IN_TERM_50OHM_DISABLE
);
if
(
shw_pps_gen_in_term_read
()
!=
PPSG_PPS_IN_TERM_50OHM_DISABLE
)
{
pr_err
(
"Unable to disable 50ohm termination on 1-PPS "
"in
\n
"
);
}
}
return
0
;
}
userspace/tools/wrs_pps_control.c
View file @
c8e46bbb
...
...
@@ -6,9 +6,6 @@
#include <libwr/switch_hw.h>
#include <libwr/pps_gen.h>
#define PPS_ON 1
#define PPS_OFF 0
void
help
(
char
*
prgname
)
{
fprintf
(
stderr
,
"%s: Use:
\"
%s [<options>] <cmd>
\n
"
,
...
...
@@ -18,8 +15,8 @@ void help(char *prgname)
" -h print help
\n
"
"
\n
"
" Commands are:
\n
"
"
on - switch PPS output on
.
\n
"
"
off - switch PPS output off.
\n
"
);
"
pps <on|off|read> - switch PPS output on/off
.
\n
"
"
50ohm-term-in <on|off|read> - on/off/read 50ohm termination for 1-PPS input
\n
"
);
exit
(
1
);
}
...
...
@@ -36,14 +33,62 @@ int main(int argc, char *argv[])
}
if
(
argc
>
1
)
{
if
(
strcmp
(
argv
[
1
],
"on"
)
==
0
)
{
assert_init
(
shw_fpga_mmap_init
());
shw_pps_gen_enable_output
(
PPS_ON
);
exit
(
0
);
}
else
if
(
strcmp
(
argv
[
1
],
"off"
)
==
0
)
{
assert_init
(
shw_fpga_mmap_init
());
shw_pps_gen_enable_output
(
PPS_OFF
);
exit
(
0
);
if
(
!
strcmp
(
argv
[
1
],
"pps"
))
{
if
(
argc
<
3
)
{
printf
(
"No parameter given
\n
;"
);
exit
(
1
);
}
if
(
!
strcmp
(
argv
[
2
],
"on"
))
{
assert_init
(
shw_fpga_mmap_init
());
shw_pps_gen_enable_output
(
PPSG_PPS_OUT_ENABLE
);
exit
(
0
);
}
else
if
(
!
strcmp
(
argv
[
2
],
"off"
))
{
assert_init
(
shw_fpga_mmap_init
());
shw_pps_gen_enable_output
(
PPSG_PPS_OUT_DISABLE
);
exit
(
0
);
}
else
if
(
!
strcmp
(
argv
[
2
],
"read"
))
{
assert_init
(
shw_fpga_mmap_init
());
if
(
shw_pps_gen_enable_output_read
()
==
PPSG_PPS_OUT_ENABLE
)
{
printf
(
"PPS output on
\n
;"
);
}
else
{
printf
(
"PPS output off
\n
;"
);
}
exit
(
0
);
}
else
{
printf
(
"Unknown parameter
\n
;"
);
exit
(
1
);
}
}
else
if
(
!
strcmp
(
argv
[
1
],
"50ohm-term-in"
))
{
if
(
argc
<
3
)
{
printf
(
"No parameter given
\n
;"
);
exit
(
1
);
}
if
(
!
strcmp
(
argv
[
2
],
"on"
))
{
assert_init
(
shw_fpga_mmap_init
());
shw_pps_gen_in_term_enable
(
PPSG_PPS_IN_TERM_50OHM_ENABLE
);
exit
(
0
);
}
else
if
(
!
strcmp
(
argv
[
2
],
"off"
))
{
assert_init
(
shw_fpga_mmap_init
());
shw_pps_gen_in_term_enable
(
PPSG_PPS_IN_TERM_50OHM_DISABLE
);
exit
(
0
);
}
else
if
(
!
strcmp
(
argv
[
2
],
"read"
))
{
assert_init
(
shw_fpga_mmap_init
());
if
(
shw_pps_gen_in_term_read
()
==
PPSG_PPS_IN_TERM_50OHM_ENABLE
)
{
printf
(
"50ohm termination enabled on "
"1-PPS
\n
;"
);
}
else
{
printf
(
"50ohm termination disabled on "
"1-PPS
\n
;"
);
}
exit
(
0
);
}
else
{
printf
(
"Unknown parameter
\n
;"
);
exit
(
1
);
}
}
else
{
printf
(
"Unknown command
\n
;"
);
exit
(
1
);
...
...
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