mirror of
https://github.com/torvalds/linux.git
synced 2026-05-04 06:22:40 -04:00
Expand the zl3073x_out structure to cache all output-related hardware registers, including divisors, widths, embedded-sync parameters and phase compensation. Modify zl3073x_out_state_fetch() to read and populate all these new fields at once, including zero-divisor checks. Refactor all dpll "getter" functions in dpll.c to read from this new cached state instead of performing direct register access. Introduce a new function, zl3073x_out_state_set(), to handle writing changes back to the hardware. This function compares the provided state with the current cached state and writes *only* the modified register values via a single mailbox sequence before updating the local cache. Refactor all dpll "setter" functions to modify a local copy of the output state and then call zl3073x_out_state_set() to commit the changes. This change centralizes all output-related register I/O into out.c, significantly reduces bus traffic, and simplifies the logic in dpll.c. 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-6-ivecera@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
94 lines
2.2 KiB
C
94 lines
2.2 KiB
C
/* 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 */
|