| 1 |
|
| 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 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 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 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 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 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 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 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 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 |