Commit dfc26382 authored by Alessandro Rubini's avatar Alessandro Rubini

added FD_CMD_WR_QUERY, the lib frontend and docs

parent 0ae3f51f
......@@ -457,6 +457,37 @@ are enumerated in @code{fine-delay.h}
* Writing Board Time::
@end menu
@c --------------------------------------------------------------------------
@node List of Commands to the Device
@subsection List of Commands to the Device
The following commands are currently supported for the @code{command}
write-only file in @i{sysfs}:
@table @code
@item 0 = FD_CMD_HOST_TIME
Set board time equal to host time.
@item 1 = FD_CMD_WR_ENABLE
Enable White-Rabbit mode.
@item 2 = FD_CMD_WR_DISABLE
Disable White-Rabbit mode.
@item 3 = FD_CMD_WR_QUERY
Tell the user the status of White-Rabbit mode. This is a hack, as
the return value is reported using error codes. Success means
White-Rabbit is synchronized. @code{ENODEV} means there is
WR mode activa, @code{EAGAIN} means it is not synchronized yet.
The error is returned to the @i{write} system call.
@end table
@c --------------------------------------------------------------------------
@node Reading Board Time
@subsection Reading Board Time
......@@ -1041,6 +1072,30 @@ The API is not implemented, nor the example programs. The header,
however, includes a tentative API, based on structures. Please check
the header and @i{lib/fdelay-output.c} until it is ready.
@c ==========================================================================
@node White-Rabbit Configuration
@section White-Rabbit Configuration
@b{Note:} these functions have not been tested yet, although the low-level
command works.
The following functions are offered
@table @code
@item int fdelay_wr_mode(struct fdelay_board *b, int on);
The function receives 0 to disable WR mode or non-0 to enable it.
It is expected to never fail if the driver is loaded.
@item int fdelay_check_wr_mode(struct fdelay_board *b);
The function returns 0 if the WR slave is synchronized, @code{EAGAIN}
(an integer) if it is enabled by not yet synchronized and @code{ENODEV}
if WR-mode is currently disabled.
@end table
@c ##########################################################################
@node Known Bugs and Missing Features
@chapter Known Bugs and Missing Features
......
......@@ -130,8 +130,13 @@ static int fd_wr_mode(struct spec_fd *fd, int on)
static int fd_wr_query(struct spec_fd *fd)
{
/* To be filled */
return -EOPNOTSUPP;
int ena = test_bit(FD_FLAG_WR_MODE, &fd->flags);
if (!ena)
return -ENODEV;
if (fd_readl(fd, FD_REG_TCR) & FD_TCR_WR_LOCKED)
return 0;
return -EAGAIN;
}
......
......@@ -189,3 +189,12 @@ int fdelay_wr_mode(struct fdelay_board *userb, int on)
else
return __fdelay_command(b, FD_CMD_WR_DISABLE);
}
extern int fdelay_check_wr_mode(struct fdelay_board *userb)
{
__define_board(b, userb);
if (__fdelay_command(b, FD_CMD_WR_ENABLE) == 0)
return 0;
return errno;
}
......@@ -77,6 +77,7 @@ extern int fdelay_config_pulse_ps(struct fdelay_board *b,
int channel, struct fdelay_pulse_ps *ps);
extern int fdelay_wr_mode(struct fdelay_board *b, int on);
extern int fdelay_check_wr_mode(struct fdelay_board *b);
#ifdef FDELAY_INTERNAL /* Libray users should ignore what follows */
......
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