Commit db87b6b6 authored by Adam Wujek's avatar Adam Wujek 💬

Kconfig: add PPS_IN_TERM_50OHM

For rnabling 50ohm termination for 1-PPS input
It is set from HAL.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent be8bd87e
...@@ -976,6 +976,12 @@ config NIC_THROTTLING_VAL ...@@ -976,6 +976,12 @@ config NIC_THROTTLING_VAL
endmenu 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" menu "Custom boot script configuration"
config CUSTOM_BOOT_SCRIPT_ENABLED config CUSTOM_BOOT_SCRIPT_ENABLED
bool "Execute custom script" bool "Execute custom script"
......
...@@ -972,6 +972,9 @@ appropriate way, before the respective service is started. ...@@ -972,6 +972,9 @@ appropriate way, before the respective service is started.
@t{CONFIG_NIC_THROTTLING_VAL} contains maximum allowed bandwidth @t{CONFIG_NIC_THROTTLING_VAL} contains maximum allowed bandwidth
in KB/s. in KB/s.
@item CONFIG_PPS_IN_TERM_50OHM
Enable 50ohm termination for 1-PPS input.
@item CONFIG_CUSTOM_BOOT_SCRIPT_ENABLED @item CONFIG_CUSTOM_BOOT_SCRIPT_ENABLED
@itemx CONFIG_CUSTOM_BOOT_SCRIPT_SOURCE_LOCAL @itemx CONFIG_CUSTOM_BOOT_SCRIPT_SOURCE_LOCAL
@itemx CONFIG_CUSTOM_BOOT_SCRIPT_SOURCE_REMOTE @itemx CONFIG_CUSTOM_BOOT_SCRIPT_SOURCE_REMOTE
......
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
#define PPSG_ADJUST_SEC 0x1 #define PPSG_ADJUST_SEC 0x1
#define PPSG_ADJUST_NSEC 0x2 #define PPSG_ADJUST_NSEC 0x2
#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. */ /* Initializes the PPS Generator. 0 on success, negative on failure. */
int shw_pps_gen_init(void); int shw_pps_gen_init(void);
...@@ -24,4 +27,13 @@ int shw_pps_gen_enable_output(int enable); ...@@ -24,4 +27,13 @@ int shw_pps_gen_enable_output(int enable);
/* Reads the current time and stores at <seconds,nanoseconds>. */ /* Reads the current time and stores at <seconds,nanoseconds>. */
void shw_pps_gen_read_time(uint64_t * seconds, uint32_t * 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 */ #endif /* __LIBWR_PPS_GEN_H */
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "i2c_sfp.h" #include "i2c_sfp.h"
#include <libwr/shw_io.h> #include <libwr/shw_io.h>
#include <libwr/wrs-msg.h> #include <libwr/wrs-msg.h>
#include <libwr/pps_gen.h>
int shw_init() int shw_init()
{ {
...@@ -31,6 +32,9 @@ int shw_init() ...@@ -31,6 +32,9 @@ int shw_init()
/* Init the FANs */ /* Init the FANs */
assert_init(shw_init_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"); pr_info("HW initialization done!\n");
return 0; return 0;
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <libwr/switch_hw.h> #include <libwr/switch_hw.h>
#include <libwr/wrs-msg.h> #include <libwr/wrs-msg.h>
#include <libwr/config.h>
/* Default width (in 8ns units) of the pulses on the PPS output */ /* Default width (in 8ns units) of the pulses on the PPS output */
#define PPS_WIDTH 100000 #define PPS_WIDTH 100000
...@@ -114,3 +115,41 @@ void shw_pps_gen_in_term_enable(int enable) ...@@ -114,3 +115,41 @@ void shw_pps_gen_in_term_enable(int enable)
else else
ppsg_write(ESCR, escr & ~PPSG_ESCR_PPS_IN_TERM); 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment