no-OS
Loading...
Searching...
No Matches
axi_jesd204_rx.c File Reference

Driver for the Analog Devices AXI-JESD204-RX peripheral. More...

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

Classes

struct  axi_jesd204_rx_jesd204_priv
 

Macros

#define JESD204_RX_REG_VERSION   0x00
 
#define JESD204_RX_REG_MAGIC   0x0c
 
#define JESD204_RX_REG_SYNTH_NUM_LANES   0x10
 
#define JESD204_RX_REG_SYNTH_DATA_PATH_WIDTH   0x14
 
#define JESD204_RX_REG_SYNTH_REG_1   0x18
 
#define JESD204_RX_ENCODER_MASK   NO_OS_GENMASK(9, 8)
 
#define JESD204_RX_ENCODER_GET(x)
 
#define JESD204_RX_REG_LINK_DISABLE   0xc0
 
#define JESD204_RX_REG_LINK_STATE   0xc4
 
#define JESD204_RX_REG_LINK_CLK_RATIO   0xc8
 
#define JESD204_RX_REG_SYSREF_CONF   0x100
 
#define JESD204_RX_REG_SYSREF_CONF_SYSREF_DISABLE   NO_OS_BIT(0)
 
#define JESD204_RX_REG_SYSREF_LMFC_OFFSET   0x104
 
#define JESD204_RX_REG_SYSREF_STATUS   0x108
 
#define JESD204_RX_REG_LINK_CONF0   0x210
 
#define JESD204_RX_REG_LINK_CONF4   0x21C
 
#define JESD204_RX_REG_LINK_CONF2   0x240
 
#define JESD204_RX_LINK_CONF2_BUFFER_EARLY_RELEASE   NO_OS_BIT(16)
 
#define JESD204_RX_REG_LINK_STATUS   0x280
 
#define JESD204_LINK_STATUS_DATA   3
 
#define JESD204_RX_REG_LANE_STATUS(x)
 
#define JESD204_EMB_STATE_MASK   NO_OS_GENMASK(10, 8)
 
#define JESD204_EMB_STATE_GET(x)
 
#define JESD204_RX_REG_LANE_LATENCY(x)
 
#define JESD204_RX_REG_LANE_ERRORS(x)
 
#define JESD204_RX_REG_ILAS(x, y)
 
#define JESD204_TX_REG_ILAS(x, y)
 
#define JESD204_RX_MAGIC    (('2' << 24) | ('0' << 16) | ('4' << 8) | ('R'))
 
#define JESD204_SYNTH_DATA_PATH_WIDTH_MASK   NO_OS_GENMASK(7, 0)
 
#define JESD204_SYNTH_DATA_PATH_WIDTH_GET(x)
 
#define JESD204_TPL_DATA_PATH_WIDTH_MASK   NO_OS_GENMASK(15, 8)
 
#define JESD204_TPL_DATA_PATH_WIDTH_GET(x)
 
#define ADI_AXI_PCORE_VER(major, minor, patch)
 
#define PCORE_VERSION_MAJOR(x)
 
#define PCORE_VERSION_MINOR(x)
 
#define PCORE_VERSION_PATCH(x)
 

Enumerations

enum  {
  JESD204_EMB_STATE_INIT = 1 ,
  JESD204_EMB_STATE_HUNT ,
  JESD204_EMB_STATE_LOCK = 4
}
 

Functions

int32_t axi_jesd204_rx_write (struct axi_jesd204_rx *jesd, uint32_t reg_addr, uint32_t reg_val)
 JESD204 RX AXI Data Write.
 
int32_t axi_jesd204_rx_read (struct axi_jesd204_rx *jesd, uint32_t reg_addr, uint32_t *reg_val)
 JESD204 RX AXI Data Read.
 
int32_t axi_jesd204_rx_lane_clk_enable (struct axi_jesd204_rx *jesd)
 JESD204 RX Lane Clock Enable.
 
int32_t axi_jesd204_rx_lane_clk_disable (struct axi_jesd204_rx *jesd)
 JESD204 RX Lane Clock Disable.
 
uint32_t axi_jesd204_rx_status_read (struct axi_jesd204_rx *jesd)
 Read status of the JESD204 Receive Peripherial.
 
int32_t axi_jesd204_rx_get_lane_errors (struct axi_jesd204_rx *jesd, uint32_t lane, uint32_t *errors)
 Read the JESD204 RX Lane Errors.
 
int32_t axi_jesd204_rx_laneinfo_read (struct axi_jesd204_rx *jesd, uint32_t lane)
 Read JESD204 RX Lane Info.
 
bool axi_jesd204_rx_check_lane_status (struct axi_jesd204_rx *jesd, uint32_t lane)
 Check JESD204 RX Lane Status.
 
int32_t axi_jesd204_rx_watchdog (struct axi_jesd204_rx *jesd)
 JESD204 RX Watchdog.
 
int32_t axi_jesd204_rx_apply_config_legacy (struct axi_jesd204_rx *jesd, struct jesd204_rx_config *config)
 Apply the JESD204 RX configuration.
 
int32_t axi_jesd204_rx_init_legacy (struct axi_jesd204_rx **jesd204, const struct jesd204_rx_init *init)
 Device initialization.
 
int32_t axi_jesd204_rx_init (struct axi_jesd204_rx **jesd204, const struct jesd204_rx_init *init)
 Device initialization, JESD FSM ON.
 
int32_t axi_jesd204_rx_remove (struct axi_jesd204_rx *jesd)
 Free resoulces allocated for JESD204 RX peripheral.
 

Variables

const char * axi_jesd204_rx_link_status_label []
 
const char * axi_jesd204_rx_lane_status_label []
 
const char * axi_jesd204_rx_link_status_64b66b_l []
 
const char * axi_jesd204_rx_emb_state_label []
 

Detailed Description

Driver for the Analog Devices AXI-JESD204-RX peripheral.

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.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ ADI_AXI_PCORE_VER

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

◆ JESD204_EMB_STATE_GET

#define JESD204_EMB_STATE_GET ( x)
Value:
#define JESD204_EMB_STATE_MASK
Definition axi_jesd204_rx.c:55
uint32_t no_os_field_get(uint32_t mask, uint32_t word)

◆ JESD204_EMB_STATE_MASK

#define JESD204_EMB_STATE_MASK   NO_OS_GENMASK(10, 8)

◆ JESD204_LINK_STATUS_DATA

#define JESD204_LINK_STATUS_DATA   3

◆ JESD204_RX_ENCODER_GET

#define JESD204_RX_ENCODER_GET ( x)
Value:
#define JESD204_RX_ENCODER_MASK
Definition axi_jesd204_rx.c:30

◆ JESD204_RX_ENCODER_MASK

#define JESD204_RX_ENCODER_MASK   NO_OS_GENMASK(9, 8)

◆ JESD204_RX_LINK_CONF2_BUFFER_EARLY_RELEASE

#define JESD204_RX_LINK_CONF2_BUFFER_EARLY_RELEASE   NO_OS_BIT(16)

◆ JESD204_RX_MAGIC

#define JESD204_RX_MAGIC    (('2' << 24) | ('0' << 16) | ('4' << 8) | ('R'))

◆ JESD204_RX_REG_ILAS

#define JESD204_RX_REG_ILAS ( x,
y )
Value:
(((x) * 32 + (y) * 4) + 0x310)

◆ JESD204_RX_REG_LANE_ERRORS

#define JESD204_RX_REG_LANE_ERRORS ( x)
Value:
(((x) * 32) + 0x308)

◆ JESD204_RX_REG_LANE_LATENCY

#define JESD204_RX_REG_LANE_LATENCY ( x)
Value:
(((x) * 32) + 0x304)

◆ JESD204_RX_REG_LANE_STATUS

#define JESD204_RX_REG_LANE_STATUS ( x)
Value:
(((x) * 32) + 0x300)

◆ JESD204_RX_REG_LINK_CLK_RATIO

#define JESD204_RX_REG_LINK_CLK_RATIO   0xc8

◆ JESD204_RX_REG_LINK_CONF0

#define JESD204_RX_REG_LINK_CONF0   0x210

◆ JESD204_RX_REG_LINK_CONF2

#define JESD204_RX_REG_LINK_CONF2   0x240

◆ JESD204_RX_REG_LINK_CONF4

#define JESD204_RX_REG_LINK_CONF4   0x21C

◆ JESD204_RX_REG_LINK_DISABLE

#define JESD204_RX_REG_LINK_DISABLE   0xc0

◆ JESD204_RX_REG_LINK_STATE

#define JESD204_RX_REG_LINK_STATE   0xc4

◆ JESD204_RX_REG_LINK_STATUS

#define JESD204_RX_REG_LINK_STATUS   0x280

◆ JESD204_RX_REG_MAGIC

#define JESD204_RX_REG_MAGIC   0x0c

◆ JESD204_RX_REG_SYNTH_DATA_PATH_WIDTH

#define JESD204_RX_REG_SYNTH_DATA_PATH_WIDTH   0x14

◆ JESD204_RX_REG_SYNTH_NUM_LANES

#define JESD204_RX_REG_SYNTH_NUM_LANES   0x10

◆ JESD204_RX_REG_SYNTH_REG_1

#define JESD204_RX_REG_SYNTH_REG_1   0x18

◆ JESD204_RX_REG_SYSREF_CONF

#define JESD204_RX_REG_SYSREF_CONF   0x100

◆ JESD204_RX_REG_SYSREF_CONF_SYSREF_DISABLE

#define JESD204_RX_REG_SYSREF_CONF_SYSREF_DISABLE   NO_OS_BIT(0)

◆ JESD204_RX_REG_SYSREF_LMFC_OFFSET

#define JESD204_RX_REG_SYSREF_LMFC_OFFSET   0x104

◆ JESD204_RX_REG_SYSREF_STATUS

#define JESD204_RX_REG_SYSREF_STATUS   0x108

◆ JESD204_RX_REG_VERSION

#define JESD204_RX_REG_VERSION   0x00

◆ JESD204_SYNTH_DATA_PATH_WIDTH_GET

#define JESD204_SYNTH_DATA_PATH_WIDTH_GET ( x)
Value:
#define JESD204_SYNTH_DATA_PATH_WIDTH_MASK
Definition axi_jesd204_rx.c:68

◆ JESD204_SYNTH_DATA_PATH_WIDTH_MASK

#define JESD204_SYNTH_DATA_PATH_WIDTH_MASK   NO_OS_GENMASK(7, 0)

◆ JESD204_TPL_DATA_PATH_WIDTH_GET

#define JESD204_TPL_DATA_PATH_WIDTH_GET ( x)
Value:
#define JESD204_TPL_DATA_PATH_WIDTH_MASK
Definition axi_jesd204_rx.c:70

◆ JESD204_TPL_DATA_PATH_WIDTH_MASK

#define JESD204_TPL_DATA_PATH_WIDTH_MASK   NO_OS_GENMASK(15, 8)

◆ JESD204_TX_REG_ILAS

#define JESD204_TX_REG_ILAS ( x,
y )
Value:
(((x) * 32 + (y) * 4) + 0x310)

◆ PCORE_VERSION_MAJOR

#define PCORE_VERSION_MAJOR ( x)
Value:
((x) >> 16)

◆ PCORE_VERSION_MINOR

#define PCORE_VERSION_MINOR ( x)
Value:
(((x) >> 8) & 0xff)

◆ PCORE_VERSION_PATCH

#define PCORE_VERSION_PATCH ( x)
Value:
((x) & 0xff)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
JESD204_EMB_STATE_INIT 
JESD204_EMB_STATE_HUNT 
JESD204_EMB_STATE_LOCK 

Function Documentation

◆ axi_jesd204_rx_apply_config_legacy()

int32_t axi_jesd204_rx_apply_config_legacy ( struct axi_jesd204_rx * jesd,
struct jesd204_rx_config * config )

Apply the JESD204 RX configuration.

Parameters
jesd- The device structure.
config- The JESD RX configuration.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_jesd204_rx_check_lane_status()

bool axi_jesd204_rx_check_lane_status ( struct axi_jesd204_rx * jesd,
uint32_t lane )

Check JESD204 RX Lane Status.

Parameters
jesd- The device structure.
lane- Lane ID.
Returns
Returns 0 in case of success or positive value otherwise.

◆ axi_jesd204_rx_get_lane_errors()

int32_t axi_jesd204_rx_get_lane_errors ( struct axi_jesd204_rx * jesd,
uint32_t lane,
uint32_t * errors )

Read the JESD204 RX Lane Errors.

Parameters
jesd- The JESD204 RX Device Structure.
lane- The lane ID.
errors- The errors read from the device.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_jesd204_rx_init()

int32_t axi_jesd204_rx_init ( struct axi_jesd204_rx ** jesd204,
const struct jesd204_rx_init * init )

Device initialization, JESD FSM ON.

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

◆ axi_jesd204_rx_init_legacy()

int32_t axi_jesd204_rx_init_legacy ( struct axi_jesd204_rx ** jesd204,
const struct jesd204_rx_init * init )

Device initialization.

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

◆ axi_jesd204_rx_lane_clk_disable()

int32_t axi_jesd204_rx_lane_clk_disable ( struct axi_jesd204_rx * jesd)

JESD204 RX Lane Clock Disable.

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

◆ axi_jesd204_rx_lane_clk_enable()

int32_t axi_jesd204_rx_lane_clk_enable ( struct axi_jesd204_rx * jesd)

JESD204 RX Lane Clock Enable.

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

◆ axi_jesd204_rx_laneinfo_read()

int32_t axi_jesd204_rx_laneinfo_read ( struct axi_jesd204_rx * jesd,
uint32_t lane )

Read JESD204 RX Lane Info.

Parameters
jesd- The device structure.
lane- Lane ID.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_jesd204_rx_read()

int32_t axi_jesd204_rx_read ( struct axi_jesd204_rx * jesd,
uint32_t reg_addr,
uint32_t * reg_val )

JESD204 RX AXI Data Read.

Parameters
jesd- The 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.

◆ axi_jesd204_rx_remove()

int32_t axi_jesd204_rx_remove ( struct axi_jesd204_rx * jesd)

Free resoulces allocated for JESD204 RX peripheral.

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

◆ axi_jesd204_rx_status_read()

uint32_t axi_jesd204_rx_status_read ( struct axi_jesd204_rx * jesd)

Read status of the JESD204 Receive Peripherial.

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

◆ axi_jesd204_rx_watchdog()

int32_t axi_jesd204_rx_watchdog ( struct axi_jesd204_rx * jesd)

JESD204 RX Watchdog.

Parameters
jesd- The device structure.
Returns
Returns 0 in case of success or positive value otherwise.

◆ axi_jesd204_rx_write()

int32_t axi_jesd204_rx_write ( struct axi_jesd204_rx * jesd,
uint32_t reg_addr,
uint32_t reg_val )

JESD204 RX AXI Data Write.

Parameters
jesd- The 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.

Variable Documentation

◆ axi_jesd204_rx_emb_state_label

const char* axi_jesd204_rx_emb_state_label[]
Initial value:
= {
"INVALID",
"EMB_INIT",
"EMB_HUNT",
"INVALID",
"EMB_LOCK",
"INVALID",
"INVALID",
"INVALID",
}

◆ axi_jesd204_rx_lane_status_label

const char* axi_jesd204_rx_lane_status_label[]
Initial value:
= {
"INIT",
"CHECK",
"DATA",
"UNKNOWN",
}

◆ axi_jesd204_rx_link_status_64b66b_l

const char* axi_jesd204_rx_link_status_64b66b_l[]
Initial value:
= {
"RESET",
"WAIT_BS",
"BLOCK_SYNC",
"DATA",
}

◆ axi_jesd204_rx_link_status_label

const char* axi_jesd204_rx_link_status_label[]
Initial value:
= {
"RESET",
"WAIT FOR PHY",
"CGS",
"DATA",
}