no-OS
jesd204.h
Go to the documentation of this file.
1 
6 #ifndef _JESD204_H_
7 #define _JESD204_H_
8 
9 #include <stdbool.h>
10 #include <stddef.h>
11 #include <stdint.h>
12 
13 struct jesd204_dev;
14 
19 };
20 
25 };
26 
27 /* JESD204C Supported encoding scheme */
33 
35 };
36 
41 };
42 
47 };
48 
49 #define JESD204_LINKS_ALL ((unsigned int)(-1))
50 
51 #define JESD204_LMFC_OFFSET_UNINITIALIZED ((uint16_t)-1)
52 
64  uint16_t lmfc_offset;
65 };
66 
105 struct jesd204_link {
106  uint32_t link_id;
107  int error;
108 
109  uint64_t sample_rate;
110  uint32_t sample_rate_div;
111 
113 
114  uint8_t num_lanes;
115  uint8_t num_converters;
118  uint8_t num_of_multiblocks_in_emb; /* E */
119 
121 
123  uint8_t jesd_version;
124  uint8_t jesd_encoder;
125  uint8_t subclass;
126 
127  uint8_t device_id;
128  uint8_t bank_id;
129 
130  uint8_t scrambling;
131  uint8_t high_density;
132 
136 
137  uint8_t *lane_ids;
138 
140 
141  /* Subclass 2 only */
144  uint8_t dac_phase_adj;
145 };
146 
150 };
151 
152 static inline const char *jesd204_state_op_reason_str(enum
154 {
155  switch (reason) {
157  return "initialization";
159  return "uninitialization";
160  default:
161  return "unknown";
162  }
163 }
164 
165 typedef int (*jesd204_sysref_cb)(struct jesd204_dev *jdev);
166 
167 typedef int (*jesd204_dev_cb)(struct jesd204_dev *jdev,
168  enum jesd204_state_op_reason reason);
169 
170 typedef int (*jesd204_link_cb)(struct jesd204_dev *jdev,
172  struct jesd204_link *lnk);
173 
177 };
178 
194 };
195 
214 
216 };
217 
229  size_t sizeof_priv;
230  unsigned int max_num_links;
231  unsigned int num_retries;
233 };
234 
235 /* no-OS specific */
236 #define JESD204_MAX_TOPOLOGY_LINKS 16
237 
238 /* no-OS specific */
240  struct jesd204_dev *jdev;
244  unsigned int links_number;
245 };
246 
247 /* no-OS specific */
249  struct jesd204_dev_top *dev_top;
251  unsigned int devs_number;
252 };
253 
254 /* no-OS specific */
255 int jesd204_dev_register(struct jesd204_dev **jdev,
256  const struct jesd204_dev_data *dev_data);
257 
258 /* no-OS specific */
259 int jesd204_dev_unregister(struct jesd204_dev *jdev);
260 
261 /* no-OS specific */
262 int jesd204_topology_init(struct jesd204_topology **topology,
263  struct jesd204_topology_dev *devs,
264  unsigned int devs_number);
265 
266 /* no-OS specific */
267 int jesd204_topology_remove(struct jesd204_topology *topology);
268 
269 /* no-OS specific */
270 int jesd204_fsm_start(struct jesd204_topology *topology, unsigned int link_idx);
271 
272 /* no-OS specific */
273 int jesd204_fsm_stop(struct jesd204_topology *topology, unsigned int link_idx);
274 
275 void *jesd204_dev_priv(struct jesd204_dev *jdev);
276 
278  unsigned long *rate_hz);
279 
281  unsigned long *lane_rate_khz);
282 
284  unsigned long *device_clock);
285 
286 int jesd204_sysref_async(struct jesd204_dev *jdev);
287 
288 int jesd204_sysref_async_force(struct jesd204_dev *jdev);
289 
290 bool jesd204_dev_is_top(struct jesd204_dev *jdev);
291 
292 void jesd204_copy_link_params(struct jesd204_link *dst,
293  const struct jesd204_link *src);
294 
295 #endif
JESD204_VERSION_A
@ JESD204_VERSION_A
Definition: jesd204.h:22
jesd204_state_op::per_device
jesd204_dev_cb per_device
Definition: jesd204.h:191
JESD204_OP_OPT_SETUP_STAGE1
@ JESD204_OP_OPT_SETUP_STAGE1
Definition: jesd204.h:205
jesd204_state_op
JESD204 device per-state op.
Definition: jesd204.h:189
jesd204_dev_op
jesd204_dev_op
Definition: jesd204.h:196
JESD204_OP_OPT_SETUP_STAGE5
@ JESD204_OP_OPT_SETUP_STAGE5
Definition: jesd204.h:209
jesd204_dev_data::state_ops
struct jesd204_state_op state_ops[__JESD204_MAX_OPS]
Definition: jesd204.h:232
jesd204_state_op::post_state_sysref
bool post_state_sysref
Definition: jesd204.h:193
JESD204_STATE_OP_REASON_INIT
@ JESD204_STATE_OP_REASON_INIT
Definition: jesd204.h:148
JESD204_MAX_TOPOLOGY_LINKS
#define JESD204_MAX_TOPOLOGY_LINKS
Definition: jesd204.h:236
jesd204_state_op_mode
jesd204_state_op_mode
Definition: jesd204.h:174
JESD204_OP_OPT_SETUP_STAGE4
@ JESD204_OP_OPT_SETUP_STAGE4
Definition: jesd204.h:208
jesd204_topology_init
int jesd204_topology_init(struct jesd204_topology **topology, struct jesd204_topology_dev *devs, unsigned int devs_number)
jesd204_copy_link_params
void jesd204_copy_link_params(struct jesd204_link *dst, const struct jesd204_link *src)
jesd204_link_cb
int(* jesd204_link_cb)(struct jesd204_dev *jdev, enum jesd204_state_op_reason, struct jesd204_link *lnk)
Definition: jesd204.h:170
JESD204_STATE_OP_MODE_PER_DEVICE
@ JESD204_STATE_OP_MODE_PER_DEVICE
Definition: jesd204.h:176
jesd204_sysref_async_force
int jesd204_sysref_async_force(struct jesd204_dev *jdev)
JESD204_ENCODER_8B10B
@ JESD204_ENCODER_8B10B
Definition: jesd204.h:30
jesd204_sysref::mode
enum jesd204_sysref_mode mode
Definition: jesd204.h:61
jesd204_state_op_reason
jesd204_state_op_reason
Definition: jesd204.h:147
JESD204_VERSION_C
@ JESD204_VERSION_C
Definition: jesd204.h:24
JESD204_SYSREF_DISABLED
@ JESD204_SYSREF_DISABLED
Definition: jesd204.h:38
__JESD204_MAX_OPS
@ __JESD204_MAX_OPS
Definition: jesd204.h:215
jesd204_state_op::mode
enum jesd204_state_op_mode mode
Definition: jesd204.h:190
jesd204_subclass
jesd204_subclass
Definition: jesd204.h:15
jesd204_dev_data::max_num_links
unsigned int max_num_links
Definition: jesd204.h:230
jesd204_dev_unregister
int jesd204_dev_unregister(struct jesd204_dev *jdev)
jesd204_topology
Definition: jesd204.h:248
jesd204_topology_dev::jdev
struct jesd204_dev * jdev
Definition: jesd204.h:240
JESD204_STATE_OP_REASON_UNINIT
@ JESD204_STATE_OP_REASON_UNINIT
Definition: jesd204.h:149
jesd204_state_change_result
jesd204_state_change_result
Definition: jesd204.h:43
jesd204_topology_dev
Definition: jesd204.h:239
jesd204_dev_data::sizeof_priv
size_t sizeof_priv
Definition: jesd204.h:229
JESD204_OP_CLK_SYNC_STAGE1
@ JESD204_OP_CLK_SYNC_STAGE1
Definition: jesd204.h:201
jesd204_dev_priv
void * jesd204_dev_priv(struct jesd204_dev *jdev)
JESD204_OP_CLK_SYNC_STAGE2
@ JESD204_OP_CLK_SYNC_STAGE2
Definition: jesd204.h:202
jesd204_link_get_device_clock
int jesd204_link_get_device_clock(struct jesd204_link *lnk, unsigned long *device_clock)
JESD204_OP_OPT_SETUP_STAGE3
@ JESD204_OP_OPT_SETUP_STAGE3
Definition: jesd204.h:207
jesd204_fsm_start
int jesd204_fsm_start(struct jesd204_topology *topology, unsigned int link_idx)
JESD204_OP_CLOCKS_ENABLE
@ JESD204_OP_CLOCKS_ENABLE
Definition: jesd204.h:210
JESD204_OP_LINK_INIT
@ JESD204_OP_LINK_INIT
Definition: jesd204.h:198
JESD204_SYSREF_ONESHOT
@ JESD204_SYSREF_ONESHOT
Definition: jesd204.h:40
jesd204_dev_is_top
bool jesd204_dev_is_top(struct jesd204_dev *jdev)
JESD204_SUBCLASS_1
@ JESD204_SUBCLASS_1
Definition: jesd204.h:17
JESD204_ENCODER_MAX
@ JESD204_ENCODER_MAX
Definition: jesd204.h:34
jesd204_link_get_lmfc_lemc_rate
int jesd204_link_get_lmfc_lemc_rate(struct jesd204_link *lnk, unsigned long *rate_hz)
jesd204_topology_dev::is_sysref_provider
bool is_sysref_provider
Definition: jesd204.h:242
JESD204_OP_DEVICE_INIT
@ JESD204_OP_DEVICE_INIT
Definition: jesd204.h:197
jesd204_topology_dev::link_ids
unsigned int link_ids[JESD204_MAX_TOPOLOGY_LINKS]
Definition: jesd204.h:243
JESD204_VERSION_B
@ JESD204_VERSION_B
Definition: jesd204.h:23
JESD204_OP_OPT_POST_RUNNING_STAGE
@ JESD204_OP_OPT_POST_RUNNING_STAGE
Definition: jesd204.h:213
JESD204_SUBCLASS_2
@ JESD204_SUBCLASS_2
Definition: jesd204.h:18
JESD204_OP_LINK_ENABLE
@ JESD204_OP_LINK_ENABLE
Definition: jesd204.h:211
jesd204_dev_data::num_retries
unsigned int num_retries
Definition: jesd204.h:231
jesd204_topology_remove
int jesd204_topology_remove(struct jesd204_topology *topology)
JESD204_ENCODER_64B66B
@ JESD204_ENCODER_64B66B
Definition: jesd204.h:31
jesd204_topology::devs
struct jesd204_topology_dev * devs
Definition: jesd204.h:250
JESD204_STATE_CHANGE_ERROR
@ JESD204_STATE_CHANGE_ERROR
Definition: jesd204.h:44
JESD204_OP_LINK_PRE_SETUP
@ JESD204_OP_LINK_PRE_SETUP
Definition: jesd204.h:200
JESD204_SUBCLASS_0
@ JESD204_SUBCLASS_0
Definition: jesd204.h:16
jesd204_sysref::lmfc_offset
uint16_t lmfc_offset
Definition: jesd204.h:64
jesd204_sysref::capture_falling_edge
uint8_t capture_falling_edge
Definition: jesd204.h:62
jesd204_sysref_async
int jesd204_sysref_async(struct jesd204_dev *jdev)
JESD204_STATE_OP_MODE_PER_LINK
@ JESD204_STATE_OP_MODE_PER_LINK
Definition: jesd204.h:175
jesd204_sysref_cb
int(* jesd204_sysref_cb)(struct jesd204_dev *jdev)
Definition: jesd204.h:165
jesd204_sysref::valid_falling_edge
uint8_t valid_falling_edge
Definition: jesd204.h:63
jesd204_dev_register
int jesd204_dev_register(struct jesd204_dev **jdev, const struct jesd204_dev_data *dev_data)
jesd204_topology::devs_number
unsigned int devs_number
Definition: jesd204.h:251
JESD204_OP_CLK_SYNC_STAGE3
@ JESD204_OP_CLK_SYNC_STAGE3
Definition: jesd204.h:203
jesd204_version
jesd204_version
Definition: jesd204.h:21
jesd204_encoder
jesd204_encoder
Definition: jesd204.h:28
JESD204_OP_OPT_SETUP_STAGE2
@ JESD204_OP_OPT_SETUP_STAGE2
Definition: jesd204.h:206
jesd204_link_get_rate_khz
int jesd204_link_get_rate_khz(struct jesd204_link *lnk, unsigned long *lane_rate_khz)
JESD204_STATE_CHANGE_DONE
@ JESD204_STATE_CHANGE_DONE
Definition: jesd204.h:46
jesd204_sysref
JESD204 parameters for SYSREF.
Definition: jesd204.h:60
JESD204_SYSREF_CONTINUOUS
@ JESD204_SYSREF_CONTINUOUS
Definition: jesd204.h:39
JESD204_ENCODER_64B80B
@ JESD204_ENCODER_64B80B
Definition: jesd204.h:32
JESD204_OP_LINK_SUPPORTED
@ JESD204_OP_LINK_SUPPORTED
Definition: jesd204.h:199
JESD204_ENCODER_UNKNOWN
@ JESD204_ENCODER_UNKNOWN
Definition: jesd204.h:29
jesd204_state_op::per_link
jesd204_link_cb per_link
Definition: jesd204.h:192
jesd204_topology::dev_top
struct jesd204_dev_top * dev_top
Definition: jesd204.h:249
jesd204_dev_cb
int(* jesd204_dev_cb)(struct jesd204_dev *jdev, enum jesd204_state_op_reason reason)
Definition: jesd204.h:167
jesd204_topology_dev::is_top_device
bool is_top_device
Definition: jesd204.h:241
JESD204_STATE_CHANGE_DEFER
@ JESD204_STATE_CHANGE_DEFER
Definition: jesd204.h:45
JESD204_OP_LINK_RUNNING
@ JESD204_OP_LINK_RUNNING
Definition: jesd204.h:212
jesd204_topology_dev::links_number
unsigned int links_number
Definition: jesd204.h:244
jesd204_dev_data::sysref_cb
jesd204_sysref_cb sysref_cb
Definition: jesd204.h:228
jesd204_dev_data
JESD204 device initialization data.
Definition: jesd204.h:227
jesd204_fsm_stop
int jesd204_fsm_stop(struct jesd204_topology *topology, unsigned int link_idx)
JESD204_OP_LINK_SETUP
@ JESD204_OP_LINK_SETUP
Definition: jesd204.h:204
jesd204_sysref_mode
jesd204_sysref_mode
Definition: jesd204.h:37