Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/drivers/dpll/zl3073x/synth.h
38189 views
1
/* SPDX-License-Identifier: GPL-2.0-only */
2
3
#ifndef _ZL3073X_SYNTH_H
4
#define _ZL3073X_SYNTH_H
5
6
#include <linux/bitfield.h>
7
#include <linux/math64.h>
8
#include <linux/types.h>
9
10
#include "regs.h"
11
12
struct zl3073x_dev;
13
14
/**
15
* struct zl3073x_synth - synthesizer state
16
* @freq_mult: frequency multiplier
17
* @freq_base: frequency base
18
* @freq_m: frequency numerator
19
* @freq_n: frequency denominator
20
* @ctrl: synth control
21
*/
22
struct zl3073x_synth {
23
u32 freq_mult;
24
u16 freq_base;
25
u16 freq_m;
26
u16 freq_n;
27
u8 ctrl;
28
};
29
30
int zl3073x_synth_state_fetch(struct zl3073x_dev *zldev, u8 synth_id);
31
32
const struct zl3073x_synth *zl3073x_synth_state_get(struct zl3073x_dev *zldev,
33
u8 synth_id);
34
35
int zl3073x_synth_state_set(struct zl3073x_dev *zldev, u8 synth_id,
36
const struct zl3073x_synth *synth);
37
38
/**
39
* zl3073x_synth_dpll_get - get DPLL ID the synth is driven by
40
* @synth: pointer to synth state
41
*
42
* Return: ID of DPLL the given synthetizer is driven by
43
*/
44
static inline u8 zl3073x_synth_dpll_get(const struct zl3073x_synth *synth)
45
{
46
return FIELD_GET(ZL_SYNTH_CTRL_DPLL_SEL, synth->ctrl);
47
}
48
49
/**
50
* zl3073x_synth_freq_get - get synth current freq
51
* @synth: pointer to synth state
52
*
53
* Return: frequency of given synthetizer
54
*/
55
static inline u32 zl3073x_synth_freq_get(const struct zl3073x_synth *synth)
56
{
57
return mul_u64_u32_div(synth->freq_base * synth->freq_m,
58
synth->freq_mult, synth->freq_n);
59
}
60
61
/**
62
* zl3073x_synth_is_enabled - check if the given synth is enabled
63
* @synth: pointer to synth state
64
*
65
* Return: true if synth is enabled, false otherwise
66
*/
67
static inline bool zl3073x_synth_is_enabled(const struct zl3073x_synth *synth)
68
{
69
return FIELD_GET(ZL_SYNTH_CTRL_EN, synth->ctrl);
70
}
71
72
#endif /* _ZL3073X_SYNTH_H */
73
74