summaryrefslogtreecommitdiff
path: root/drivers/dpll/zl3073x/out.h
blob: e8ea7a0e0f071c64504074040ad4a7108c06f7f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* SPDX-License-Identifier: GPL-2.0-only */

#ifndef _ZL3073X_OUT_H
#define _ZL3073X_OUT_H

#include <linux/bitfield.h>
#include <linux/types.h>

#include "regs.h"

struct zl3073x_dev;

/**
 * struct zl3073x_out - output state
 * @div: output divisor
 * @width: output pulse width
 * @esync_n_period: embedded sync or n-pin period (for n-div formats)
 * @esync_n_width: embedded sync or n-pin pulse width
 * @phase_comp: phase compensation
 * @ctrl: output control
 * @mode: output mode
 */
struct zl3073x_out {
	u32	div;
	u32	width;
	u32	esync_n_period;
	u32	esync_n_width;
	s32	phase_comp;
	u8	ctrl;
	u8	mode;
};

int zl3073x_out_state_fetch(struct zl3073x_dev *zldev, u8 index);
const struct zl3073x_out *zl3073x_out_state_get(struct zl3073x_dev *zldev,
						u8 index);

int zl3073x_out_state_set(struct zl3073x_dev *zldev, u8 index,
			  const struct zl3073x_out *out);

/**
 * zl3073x_out_signal_format_get - get output signal format
 * @out: pointer to out state
 *
 * Return: signal format of given output
 */
static inline u8 zl3073x_out_signal_format_get(const struct zl3073x_out *out)
{
	return FIELD_GET(ZL_OUTPUT_MODE_SIGNAL_FORMAT, out->mode);
}

/**
 * zl3073x_out_is_diff - check if the given output is differential
 * @out: pointer to out state
 *
 * Return: true if output is differential, false if output is single-ended
 */
static inline bool zl3073x_out_is_diff(const struct zl3073x_out *out)
{
	switch (zl3073x_out_signal_format_get(out)) {
	case ZL_OUTPUT_MODE_SIGNAL_FORMAT_LVDS:
	case ZL_OUTPUT_MODE_SIGNAL_FORMAT_DIFF:
	case ZL_OUTPUT_MODE_SIGNAL_FORMAT_LOWVCM:
		return true;
	default:
		break;
	}

	return false;
}

/**
 * zl3073x_out_is_enabled - check if the given output is enabled
 * @out: pointer to out state
 *
 * Return: true if output is enabled, false if output is disabled
 */
static inline bool zl3073x_out_is_enabled(const struct zl3073x_out *out)
{
	return !!FIELD_GET(ZL_OUTPUT_CTRL_EN, out->ctrl);
}

/**
 * zl3073x_out_synth_get - get synth connected to given output
 * @out: pointer to out state
 *
 * Return: index of synth connected to given output.
 */
static inline u8 zl3073x_out_synth_get(const struct zl3073x_out *out)
{
	return FIELD_GET(ZL_OUTPUT_CTRL_SYNTH_SEL, out->ctrl);
}

#endif /* _ZL3073X_OUT_H */