no-OS
Macros | Functions | Variables
axi_adxcvr.c File Reference

Driver for the ADI AXI-ADXCVR Module. More...

#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include "no_os_axi_io.h"
#include "no_os_util.h"
#include "no_os_alloc.h"
#include "no_os_error.h"
#include "no_os_delay.h"
#include "xilinx_transceiver.h"
#include "axi_adxcvr.h"
#include "no_os_print_log.h"
#include "no_os_clk.h"
Include dependency graph for axi_adxcvr.c:

Macros

#define ADXCVR_REG_RESETN   0x0010
 
#define ADXCVR_RESETN   (1 << 0)
 
#define ADXCVR_BUFSTATUS_RST   NO_OS_BIT(1)
 
#define ADXCVR_REG_STATUS   0x0014
 
#define ADXCVR_STATUS   (1 << 0)
 
#define ADXCVR_BUFSTATUS_UNDERFLOW   NO_OS_BIT(5)
 
#define ADXCVR_BUFSTATUS_OVERFLOW   NO_OS_BIT(6)
 
#define ADXCVR_REG_CONTROL   0x0020
 
#define ADXCVR_LPM_DFE_N   (1 << 12)
 
#define ADXCVR_RATE(x)   (((x) & 0x7) << 8)
 
#define ADXCVR_SYSCLK_SEL(x)   (((x) & 0x3) << 4)
 
#define ADXCVR_OUTCLK_SEL(x)   (((x) & 0x7) << 0)
 
#define ADXCVR_REG_SYNTH   0x24
 
#define ADXCVR_LINK_MODE(x)   (((x) >> 12) & NO_OS_GENMASK(1, 0))
 
#define ADXCVR_204B   0x01
 
#define ADXCVR_204C   0x02
 
#define ADXCVR_REG_DRP_SEL(x)   (0x0040 + (x))
 
#define ADXCVR_REG_DRP_CTRL(x)   (0x0044 + (x))
 
#define ADXCVR_DRP_CTRL_WR   (1 << 28)
 
#define ADXCVR_DRP_CTRL_ADDR(x)   (((x) & 0xFFF) << 16)
 
#define ADXCVR_DRP_CTRL_WDATA(x)   (((x) & 0xFFFF) << 0)
 
#define ADXCVR_REG_DRP_STATUS(x)   (0x0048 + (x))
 
#define ADXCVR_DRP_STATUS_BUSY   (1 << 16)
 
#define ADXCVR_DRP_STATUS_RDATA(x)   (((x) & 0xFFFF) << 0)
 
#define ADXCVR_DRP_PORT_ADDR_COMMON   0x00
 
#define ADXCVR_DRP_PORT_ADDR_CHANNEL   0x20
 
#define ADXCVR_DRP_PORT_COMMON(x)   (x)
 
#define ADXCVR_DRP_PORT_CHANNEL(x)   (0x100 + (x))
 
#define ADXCVR_BROADCAST   0xff
 
#define ADI_AXI_PCORE_VER(major, minor, patch)   (((major) << 16) | ((minor) << 8) | (patch))
 

Functions

int32_t adxcvr_write (struct adxcvr *xcvr, uint32_t reg_addr, uint32_t reg_val)
 AXI ADXCVR Write. More...
 
int32_t adxcvr_read (struct adxcvr *xcvr, uint32_t reg_addr, uint32_t *reg_val)
 AXI ADXCVR Read. More...
 
int32_t adxcvr_drp_wait_idle (struct adxcvr *xcvr, uint32_t drp_addr)
 Read AXI ADXCVR DRP status. More...
 
int adxcvr_drp_read (struct adxcvr *xcvr, unsigned int drp_port, unsigned int reg, unsigned int *val)
 AXI ADXCVR DPR Port Read. More...
 
int adxcvr_drp_write (struct adxcvr *xcvr, unsigned int drp_port, unsigned int reg, unsigned int val)
 AXI ADXCVR DPR Port Write. More...
 
int adxcvr_clk_set_rate (struct adxcvr *xcvr, unsigned long rate, unsigned long parent_rate)
 AXI ADXCVR Clock Set Rate. More...
 
int32_t adxcvr_status_error (struct adxcvr *xcvr)
 AXI ADXCVR Status Read. More...
 
int adxcvr_clk_enable (struct adxcvr *xcvr)
 AXI ADXCVR Clock Enable. More...
 
int adxcvr_clk_disable (struct adxcvr *xcvr)
 AXI ADXCVR Clock Disable. More...
 
int32_t adxcvr_init (struct adxcvr **ad_xcvr, const struct adxcvr_init *init)
 AXI ADXCVR Device Initialization. More...
 
int32_t adxcvr_remove (struct adxcvr *xcvr)
 Free resoulces allocated for AXI_ADXCVR. More...
 
int32_t adxcvr_no_os_clk_enable (struct no_os_clk_desc *desc)
 
int32_t adxcvr_no_os_clk_disable (struct no_os_clk_desc *desc)
 
int32_t adxcvr_no_os_clk_recalc_rate (struct no_os_clk_desc *desc, uint64_t *rate)
 
int32_t adxcvr_no_os_clk_round_rate (struct no_os_clk_desc *desc, uint64_t rate, uint64_t *rounded_rate)
 
int32_t adxcvr_no_os_clk_set_rate (struct no_os_clk_desc *desc, uint64_t rate)
 

Variables

const struct no_os_clk_platform_ops adxcvr_clk_ops
 adxcvr clock ops More...
 

Detailed Description

Driver for the ADI AXI-ADXCVR Module.

Author
DBogdan (drago.nosp@m.s.bo.nosp@m.gdan@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2018(c) Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ ADI_AXI_PCORE_VER

#define ADI_AXI_PCORE_VER (   major,
  minor,
  patch 
)    (((major) << 16) | ((minor) << 8) | (patch))

◆ ADXCVR_204B

#define ADXCVR_204B   0x01

◆ ADXCVR_204C

#define ADXCVR_204C   0x02

◆ ADXCVR_BROADCAST

#define ADXCVR_BROADCAST   0xff

◆ ADXCVR_BUFSTATUS_OVERFLOW

#define ADXCVR_BUFSTATUS_OVERFLOW   NO_OS_BIT(6)

◆ ADXCVR_BUFSTATUS_RST

#define ADXCVR_BUFSTATUS_RST   NO_OS_BIT(1)

◆ ADXCVR_BUFSTATUS_UNDERFLOW

#define ADXCVR_BUFSTATUS_UNDERFLOW   NO_OS_BIT(5)

◆ ADXCVR_DRP_CTRL_ADDR

#define ADXCVR_DRP_CTRL_ADDR (   x)    (((x) & 0xFFF) << 16)

◆ ADXCVR_DRP_CTRL_WDATA

#define ADXCVR_DRP_CTRL_WDATA (   x)    (((x) & 0xFFFF) << 0)

◆ ADXCVR_DRP_CTRL_WR

#define ADXCVR_DRP_CTRL_WR   (1 << 28)

◆ ADXCVR_DRP_PORT_ADDR_CHANNEL

#define ADXCVR_DRP_PORT_ADDR_CHANNEL   0x20

◆ ADXCVR_DRP_PORT_ADDR_COMMON

#define ADXCVR_DRP_PORT_ADDR_COMMON   0x00

◆ ADXCVR_DRP_PORT_CHANNEL

#define ADXCVR_DRP_PORT_CHANNEL (   x)    (0x100 + (x))

◆ ADXCVR_DRP_PORT_COMMON

#define ADXCVR_DRP_PORT_COMMON (   x)    (x)

◆ ADXCVR_DRP_STATUS_BUSY

#define ADXCVR_DRP_STATUS_BUSY   (1 << 16)

◆ ADXCVR_DRP_STATUS_RDATA

#define ADXCVR_DRP_STATUS_RDATA (   x)    (((x) & 0xFFFF) << 0)

◆ ADXCVR_LINK_MODE

#define ADXCVR_LINK_MODE (   x)    (((x) >> 12) & NO_OS_GENMASK(1, 0))

◆ ADXCVR_LPM_DFE_N

#define ADXCVR_LPM_DFE_N   (1 << 12)

◆ ADXCVR_OUTCLK_SEL

#define ADXCVR_OUTCLK_SEL (   x)    (((x) & 0x7) << 0)

◆ ADXCVR_RATE

#define ADXCVR_RATE (   x)    (((x) & 0x7) << 8)

◆ ADXCVR_REG_CONTROL

#define ADXCVR_REG_CONTROL   0x0020

◆ ADXCVR_REG_DRP_CTRL

#define ADXCVR_REG_DRP_CTRL (   x)    (0x0044 + (x))

◆ ADXCVR_REG_DRP_SEL

#define ADXCVR_REG_DRP_SEL (   x)    (0x0040 + (x))

◆ ADXCVR_REG_DRP_STATUS

#define ADXCVR_REG_DRP_STATUS (   x)    (0x0048 + (x))

◆ ADXCVR_REG_RESETN

#define ADXCVR_REG_RESETN   0x0010

◆ ADXCVR_REG_STATUS

#define ADXCVR_REG_STATUS   0x0014

◆ ADXCVR_REG_SYNTH

#define ADXCVR_REG_SYNTH   0x24

◆ ADXCVR_RESETN

#define ADXCVR_RESETN   (1 << 0)

◆ ADXCVR_STATUS

#define ADXCVR_STATUS   (1 << 0)

◆ ADXCVR_SYSCLK_SEL

#define ADXCVR_SYSCLK_SEL (   x)    (((x) & 0x3) << 4)

Function Documentation

◆ adxcvr_clk_disable()

int adxcvr_clk_disable ( struct adxcvr xcvr)

AXI ADXCVR Clock Disable.

Parameters
xcvr- The device structure.
Returns
Returns 0 in case of success or negative error code otherwise.
Here is the caller graph for this function:

◆ adxcvr_clk_enable()

int adxcvr_clk_enable ( struct adxcvr xcvr)

AXI ADXCVR Clock Enable.

Parameters
xcvr- The device structure.
Returns
Returns 0 in case of success or negative error code otherwise.
Here is the caller graph for this function:

◆ adxcvr_clk_set_rate()

int adxcvr_clk_set_rate ( struct adxcvr xcvr,
unsigned long  rate,
unsigned long  parent_rate 
)

AXI ADXCVR Clock Set Rate.

Parameters
xcvr- The device structure.
rate- The output rate (kHz).
parent_rate- The parent rate (kHz).
Returns
Returns 0 in case of success or negative error code otherwise.
Here is the caller graph for this function:

◆ adxcvr_drp_read()

int adxcvr_drp_read ( struct adxcvr xcvr,
unsigned int  drp_port,
unsigned int  reg,
unsigned int *  val 
)

AXI ADXCVR DPR Port Read.

Parameters
xcvr- The device structure.
drp_port- The DRP Port.
reg- DRP Register address.
val- Data read.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ adxcvr_drp_wait_idle()

int32_t adxcvr_drp_wait_idle ( struct adxcvr xcvr,
uint32_t  drp_addr 
)

Read AXI ADXCVR DRP status.

Parameters
xcvr- Device Structure.
drp_addr- DRP Port address.
Returns
Returns status in case of success or negative error code otherwise.
Here is the caller graph for this function:

◆ adxcvr_drp_write()

int adxcvr_drp_write ( struct adxcvr xcvr,
unsigned int  drp_port,
unsigned int  reg,
unsigned int  val 
)

AXI ADXCVR DPR Port Write.

Parameters
xcvr- The device structure.
drp_port- The DRP Port.
reg- DRP Register address.
val- Data to be written.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ adxcvr_init()

int32_t adxcvr_init ( struct adxcvr **  ad_xcvr,
const struct adxcvr_init init 
)

AXI ADXCVR Device Initialization.

adxcvr_init

Parameters
ad_xcvr- The device structure.
init- The structure containing the device initial parameters.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ adxcvr_no_os_clk_disable()

int32_t adxcvr_no_os_clk_disable ( struct no_os_clk_desc desc)

◆ adxcvr_no_os_clk_enable()

int32_t adxcvr_no_os_clk_enable ( struct no_os_clk_desc desc)

◆ adxcvr_no_os_clk_recalc_rate()

int32_t adxcvr_no_os_clk_recalc_rate ( struct no_os_clk_desc desc,
uint64_t *  rate 
)

◆ adxcvr_no_os_clk_round_rate()

int32_t adxcvr_no_os_clk_round_rate ( struct no_os_clk_desc desc,
uint64_t  rate,
uint64_t *  rounded_rate 
)

◆ adxcvr_no_os_clk_set_rate()

int32_t adxcvr_no_os_clk_set_rate ( struct no_os_clk_desc desc,
uint64_t  rate 
)

◆ adxcvr_read()

int32_t adxcvr_read ( struct adxcvr xcvr,
uint32_t  reg_addr,
uint32_t *  reg_val 
)

AXI ADXCVR Read.

adxcvr_read

Parameters
xcvr- Device Structure.
reg_addr- The register address.
reg_val- Data read from the device.
Returns
Returns 0 in case of success or negative error code otherwise.
Here is the caller graph for this function:

◆ adxcvr_remove()

int32_t adxcvr_remove ( struct adxcvr xcvr)

Free resoulces allocated for AXI_ADXCVR.

adxcvr_remove

Parameters
xcvr- The device structure.
Returns
Returns 0 in case of success or negative error code.

◆ adxcvr_status_error()

int32_t adxcvr_status_error ( struct adxcvr xcvr)

AXI ADXCVR Status Read.

Parameters
xcvr- The device structure.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ adxcvr_write()

int32_t adxcvr_write ( struct adxcvr xcvr,
uint32_t  reg_addr,
uint32_t  reg_val 
)

AXI ADXCVR Write.

adxcvr_write

Parameters
xcvr- Device Structure.
reg_addr- The register address.
reg_val- Data value to write.
Returns
Returns 0 in case of success or negative error code otherwise.
Here is the caller graph for this function:

Variable Documentation

◆ adxcvr_clk_ops

const struct no_os_clk_platform_ops adxcvr_clk_ops
Initial value:
= {
.clk_enable = &adxcvr_no_os_clk_enable,
.clk_recalc_rate =&adxcvr_no_os_clk_recalc_rate,
.clk_round_rate = &adxcvr_no_os_clk_round_rate,
.clk_set_rate = &adxcvr_no_os_clk_set_rate,
.clk_disable = &adxcvr_no_os_clk_disable,
}

adxcvr clock ops

adxcvr_no_os_clk_set_rate
int32_t adxcvr_no_os_clk_set_rate(struct no_os_clk_desc *desc, uint64_t rate)
Definition: axi_adxcvr.c:742
adxcvr_no_os_clk_disable
int32_t adxcvr_no_os_clk_disable(struct no_os_clk_desc *desc)
Definition: axi_adxcvr.c:705
adxcvr_no_os_clk_enable
int32_t adxcvr_no_os_clk_enable(struct no_os_clk_desc *desc)
Definition: axi_adxcvr.c:695
adxcvr_no_os_clk_recalc_rate
int32_t adxcvr_no_os_clk_recalc_rate(struct no_os_clk_desc *desc, uint64_t *rate)
Definition: axi_adxcvr.c:715
adxcvr_no_os_clk_round_rate
int32_t adxcvr_no_os_clk_round_rate(struct no_os_clk_desc *desc, uint64_t rate, uint64_t *rounded_rate)
Definition: axi_adxcvr.c:728