mirror of
https://github.com/torvalds/linux.git
synced 2026-05-03 14:02:43 -04:00
Refactor the zl3073x driver by splitting the logic for input
references, outputs and synthesizers out of the monolithic
core.[ch] files.
Move the logic for each functional block into its own dedicated files:
ref.[ch], out.[ch] and synth.[ch].
Specifically:
- Move state structures (zl3073x_ref, zl3073x_out, zl3073x_synth)
from core.h into their respective new headers
- Move state-fetching functions (..._state_fetch) from core.c to their
new .c files
- Move the zl3073x_ref_freq_factorize helper from core.c to ref.c
- Introduce a new helper layer to decouple the core device logic from
the state-parsing logic:
1. Move the original inline helpers (e.g., zl3073x_ref_is_enabled)
to the new headers (ref.h, etc.) and make them operate on a
const struct ... * pointer.
2. Create new zl3073x_dev_... prefixed functions in core.h
(e.g., zl3073x_dev_ref_is_enabled) and Implement these _dev_ functions
to fetch state using a new ..._state_get() helper and then call
the non-prefixed helper.
3. Update all driver-internal callers (in dpll.c, prop.c, etc.) to use
the new zl3073x_dev_... functions.
Reviewed-by: Petr Oros <poros@redhat.com>
Tested-by: Prathosh Satish <Prathosh.Satish@microchip.com>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Link: https://patch.msgid.link/20251113074105.141379-3-ivecera@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
73 lines
1.7 KiB
C
73 lines
1.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
|
|
#ifndef _ZL3073X_SYNTH_H
|
|
#define _ZL3073X_SYNTH_H
|
|
|
|
#include <linux/bitfield.h>
|
|
#include <linux/math64.h>
|
|
#include <linux/types.h>
|
|
|
|
#include "regs.h"
|
|
|
|
struct zl3073x_dev;
|
|
|
|
/**
|
|
* struct zl3073x_synth - synthesizer state
|
|
* @freq_mult: frequency multiplier
|
|
* @freq_base: frequency base
|
|
* @freq_m: frequency numerator
|
|
* @freq_n: frequency denominator
|
|
* @ctrl: synth control
|
|
*/
|
|
struct zl3073x_synth {
|
|
u32 freq_mult;
|
|
u16 freq_base;
|
|
u16 freq_m;
|
|
u16 freq_n;
|
|
u8 ctrl;
|
|
};
|
|
|
|
int zl3073x_synth_state_fetch(struct zl3073x_dev *zldev, u8 synth_id);
|
|
|
|
const struct zl3073x_synth *zl3073x_synth_state_get(struct zl3073x_dev *zldev,
|
|
u8 synth_id);
|
|
|
|
int zl3073x_synth_state_set(struct zl3073x_dev *zldev, u8 synth_id,
|
|
const struct zl3073x_synth *synth);
|
|
|
|
/**
|
|
* zl3073x_synth_dpll_get - get DPLL ID the synth is driven by
|
|
* @synth: pointer to synth state
|
|
*
|
|
* Return: ID of DPLL the given synthetizer is driven by
|
|
*/
|
|
static inline u8 zl3073x_synth_dpll_get(const struct zl3073x_synth *synth)
|
|
{
|
|
return FIELD_GET(ZL_SYNTH_CTRL_DPLL_SEL, synth->ctrl);
|
|
}
|
|
|
|
/**
|
|
* zl3073x_synth_freq_get - get synth current freq
|
|
* @synth: pointer to synth state
|
|
*
|
|
* Return: frequency of given synthetizer
|
|
*/
|
|
static inline u32 zl3073x_synth_freq_get(const struct zl3073x_synth *synth)
|
|
{
|
|
return mul_u64_u32_div(synth->freq_base * synth->freq_m,
|
|
synth->freq_mult, synth->freq_n);
|
|
}
|
|
|
|
/**
|
|
* zl3073x_synth_is_enabled - check if the given synth is enabled
|
|
* @synth: pointer to synth state
|
|
*
|
|
* Return: true if synth is enabled, false otherwise
|
|
*/
|
|
static inline bool zl3073x_synth_is_enabled(const struct zl3073x_synth *synth)
|
|
{
|
|
return FIELD_GET(ZL_SYNTH_CTRL_EN, synth->ctrl);
|
|
}
|
|
|
|
#endif /* _ZL3073X_SYNTH_H */
|