26 ptrdiff_t clock_divisor_reg_offset;
27 ptrdiff_t seed_lower_reg_offset;
28 ptrdiff_t seed_upper_reg_offset;
32#define DIF_PATTGEN_CHANNEL_CONFIG_CASE_(channel_) \
33 case kDifPattgenChannel##channel_: \
34 enable_bit_idx = PATTGEN_CTRL_ENABLE_CH##channel_##_BIT; \
35 polarity_bit_idx = PATTGEN_CTRL_POLARITY_CH##channel_##_BIT; \
36 inactive_level_pda_bit_idx = \
37 PATTGEN_CTRL_INACTIVE_LEVEL_PDA_CH##channel_##_BIT; \
38 inactive_level_pcl_bit_idx = \
39 PATTGEN_CTRL_INACTIVE_LEVEL_PCL_CH##channel_##_BIT; \
40 clock_divisor_reg_offset = PATTGEN_PREDIV_CH##channel_##_REG_OFFSET; \
41 seed_lower_reg_offset = PATTGEN_DATA_CH##channel_##_0_REG_OFFSET; \
42 seed_upper_reg_offset = PATTGEN_DATA_CH##channel_##_1_REG_OFFSET; \
43 seed_pattern_length_field = PATTGEN_SIZE_LEN_CH##channel_##_FIELD; \
44 num_pattern_repetitions_field = PATTGEN_SIZE_REPS_CH##channel_##_FIELD; \
52#undef DIF_PATTGEN_CHANNEL_CONFIG_CASE_
55 mmio_region_read32(pattgen->
base_addr, PATTGEN_CTRL_REG_OFFSET);
58 if (bitfield_bit32_read(ctrl_reg, enable_bit_idx)) {
63 ctrl_reg = bitfield_bit32_write(ctrl_reg, polarity_bit_idx, config.
polarity);
64 ctrl_reg = bitfield_bit32_write(ctrl_reg, inactive_level_pda_bit_idx,
66 ctrl_reg = bitfield_bit32_write(ctrl_reg, inactive_level_pcl_bit_idx,
68 mmio_region_write32(pattgen->
base_addr, PATTGEN_CTRL_REG_OFFSET, ctrl_reg);
71 mmio_region_write32(pattgen->
base_addr, clock_divisor_reg_offset,
75 mmio_region_write32(pattgen->
base_addr, seed_lower_reg_offset,
78 mmio_region_write32(pattgen->
base_addr, seed_upper_reg_offset,
84 mmio_region_read32(pattgen->
base_addr, PATTGEN_SIZE_REG_OFFSET);
85 size_reg = bitfield_field32_write(size_reg, seed_pattern_length_field,
87 size_reg = bitfield_field32_write(size_reg, num_pattern_repetitions_field,
89 mmio_region_write32(pattgen->
base_addr, PATTGEN_SIZE_REG_OFFSET, size_reg);
97 if (pattgen == NULL || !dif_is_valid_toggle(enabled)) {
103#define DIF_PATTGEN_CHANNEL_SET_ENABLED_CASE_(channel_) \
104 case kDifPattgenChannel##channel_: \
105 enable_bit_idx = PATTGEN_CTRL_ENABLE_CH##channel_##_BIT; \
113#undef DIF_PATTGEN_CHANNEL_SET_ENABLED_CASE_
116 mmio_region_read32(pattgen->
base_addr, PATTGEN_CTRL_REG_OFFSET);
117 ctrl_reg = bitfield_bit32_write(ctrl_reg, enable_bit_idx,
118 dif_toggle_to_bool(enabled));
119 mmio_region_write32(pattgen->
base_addr, PATTGEN_CTRL_REG_OFFSET, ctrl_reg);
127 if (pattgen == NULL || is_enabled == NULL) {
133#define DIF_PATTGEN_CHANNEL_SET_ENABLED_CASE_(channel_) \
134 case kDifPattgenChannel##channel_: \
135 enable_bit_idx = PATTGEN_CTRL_ENABLE_CH##channel_##_BIT; \
143#undef DIF_PATTGEN_CHANNEL_SET_ENABLED_CASE_
146 mmio_region_read32(pattgen->
base_addr, PATTGEN_CTRL_REG_OFFSET);
148 dif_bool_to_toggle(bitfield_bit32_read(ctrl_reg, enable_bit_idx));