File Index
Files and directories
Sign in
FILE

out.h

File preview with syntax highlighting.

linux-6.19.14/drivers/dpll/zl3073x/out.h C
 1/* SPDX-License-Identifier: GPL-2.0-only */
 2
 3#ifndef _ZL3073X_OUT_H
 4#define _ZL3073X_OUT_H
 5
 6#include <linux/bitfield.h>
 7#include <linux/types.h>
 8
 9#include "regs.h"
10
11struct zl3073x_dev;
12
13/**
14 * struct zl3073x_out - output state
15 * @div: output divisor
16 * @width: output pulse width
17 * @esync_n_period: embedded sync or n-pin period (for n-div formats)
18 * @esync_n_width: embedded sync or n-pin pulse width
19 * @phase_comp: phase compensation
20 * @ctrl: output control
21 * @mode: output mode
22 */
23struct zl3073x_out {
24	u32	div;
25	u32	width;
26	u32	esync_n_period;
27	u32	esync_n_width;
28	s32	phase_comp;
29	u8	ctrl;
30	u8	mode;
31};
32
33int zl3073x_out_state_fetch(struct zl3073x_dev *zldev, u8 index);
34const struct zl3073x_out *zl3073x_out_state_get(struct zl3073x_dev *zldev,
35						u8 index);
36
37int zl3073x_out_state_set(struct zl3073x_dev *zldev, u8 index,
38			  const struct zl3073x_out *out);
39
40/**
41 * zl3073x_out_signal_format_get - get output signal format
42 * @out: pointer to out state
43 *
44 * Return: signal format of given output
45 */
46static inline u8 zl3073x_out_signal_format_get(const struct zl3073x_out *out)
47{
48	return FIELD_GET(ZL_OUTPUT_MODE_SIGNAL_FORMAT, out->mode);
49}
50
51/**
52 * zl3073x_out_is_diff - check if the given output is differential
53 * @out: pointer to out state
54 *
55 * Return: true if output is differential, false if output is single-ended
56 */
57static inline bool zl3073x_out_is_diff(const struct zl3073x_out *out)
58{
59	switch (zl3073x_out_signal_format_get(out)) {
60	case ZL_OUTPUT_MODE_SIGNAL_FORMAT_LVDS:
61	case ZL_OUTPUT_MODE_SIGNAL_FORMAT_DIFF:
62	case ZL_OUTPUT_MODE_SIGNAL_FORMAT_LOWVCM:
63		return true;
64	default:
65		break;
66	}
67
68	return false;
69}
70
71/**
72 * zl3073x_out_is_enabled - check if the given output is enabled
73 * @out: pointer to out state
74 *
75 * Return: true if output is enabled, false if output is disabled
76 */
77static inline bool zl3073x_out_is_enabled(const struct zl3073x_out *out)
78{
79	return !!FIELD_GET(ZL_OUTPUT_CTRL_EN, out->ctrl);
80}
81
82/**
83 * zl3073x_out_synth_get - get synth connected to given output
84 * @out: pointer to out state
85 *
86 * Return: index of synth connected to given output.
87 */
88static inline u8 zl3073x_out_synth_get(const struct zl3073x_out *out)
89{
90	return FIELD_GET(ZL_OUTPUT_CTRL_SYNTH_SEL, out->ctrl);
91}
92
93#endif /* _ZL3073X_OUT_H */
~/ Read-only file preview.