Commit d41b0d2b authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

libwr: function to enable/disable PPS-in termination

Requires gateware synthesized with wr-switch-hdl commit:
b1b621b add bit to control WRS 1-PPS in termination
parent cfb8b7df
......@@ -13,12 +13,16 @@
#ifndef __WBGEN2_REGDEFS_PPSG
#define __WBGEN2_REGDEFS_PPSG
#ifdef __KERNEL__
#include <linux/types.h>
#else
#ifdef __KERNEL__
#include <linux/types.h>
#else
#include <stdint.h>
#endif
#endif
#if defined( __GNUC__)
#define PACKED __attribute__ ((packed))
......@@ -84,6 +88,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;
......
......@@ -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;
};
};
};
......@@ -105,3 +105,14 @@ void shw_pps_gen_read_time(uint64_t * seconds, uint32_t * nanoseconds)
if (nanoseconds)
*nanoseconds = ns_cnt;
}
int shw_pps_gen_in_term(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);
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