Skip to content

Commit

Permalink
misc: xilinx-sdfec: Add SET_DEFAULT_CONFIG IOCTL
Browse files Browse the repository at this point in the history
Typically this IOCTL is used after the SD-FEC has been reset to
ensure the SD-FEC returns to it's default configuration.

Signed-off-by: Derek Kiernan <derek.kiernan@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
  • Loading branch information
Derek Kiernan authored and Michal Simek committed May 15, 2018
1 parent 7631d68 commit 74b7976
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions drivers/misc/xilinx_sdfec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,21 @@ xsdfec_get_stats(struct xsdfec_dev *xsdfec, void __user *arg)
return err;
}

static int
xsdfec_set_default_config(struct xsdfec_dev *xsdfec)
{
xsdfec->state = XSDFEC_INIT;
xsdfec->config.order = XSDFEC_INVALID_ORDER;
xsdfec->wr_protect = false;

xsdfec_wr_protect(xsdfec, false);
/* Ensure registers are aligned with core configuration */
xsdfec_regwrite(xsdfec, XSDFEC_FEC_CODE_ADDR, xsdfec->config.code - 1);
xsdfec_cfg_axi_streams(xsdfec);

return 0;
}

static long
xsdfec_dev_ioctl(struct file *fptr, unsigned int cmd, unsigned long data)
{
Expand Down Expand Up @@ -1290,6 +1305,9 @@ xsdfec_dev_ioctl(struct file *fptr, unsigned int cmd, unsigned long data)
case XSDFEC_GET_CONFIG:
rval = xsdfec_get_config(xsdfec, arg);
break;
case XSDFEC_SET_DEFAULT_CONFIG:
rval = xsdfec_set_default_config(xsdfec);
break;
case XSDFEC_SET_IRQ:
rval = xsdfec_set_irq(xsdfec, arg);
break;
Expand Down
2 changes: 2 additions & 0 deletions include/uapi/misc/xilinx_sdfec.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,7 @@ struct xsdfec_stats {
#define XSDFEC_CLEAR_STATS _IO(XSDFEC_MAGIC, 13)
/* ioctl that returns sdfec device stats */
#define XSDFEC_GET_STATS _IOR(XSDFEC_MAGIC, 14, struct xsdfec_stats *)
/* ioctl that returns sdfec device to default config, use after a reset */
#define XSDFEC_SET_DEFAULT_CONFIG _IO(XSDFEC_MAGIC, 15)

#endif /* __XILINX_SDFEC_H__ */

0 comments on commit 74b7976

Please sign in to comment.