drivers/dpll/zl3073x/ref.c

Source file repositories/reference/linux-study-clean/drivers/dpll/zl3073x/ref.c

File Facts

System
Linux kernel
Corpus path
drivers/dpll/zl3073x/ref.c
Extension
.c
Size
7062 bytes
Lines
248
Domain
Driver Families
Bucket
drivers/dpll
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (div <= U16_MAX && (freq % base_freqs[i]) == 0) {
			if (base)
				*base = base_freqs[i];
			if (mult)
				*mult = div;

			return 0;
		}
	}

	return -EINVAL;
}

/**
 * zl3073x_ref_state_update - update input reference status from HW
 * @zldev: pointer to zl3073x_dev structure
 * @index: input reference index
 *
 * Return: 0 on success, <0 on error
 */
int zl3073x_ref_state_update(struct zl3073x_dev *zldev, u8 index)
{
	struct zl3073x_ref *ref = &zldev->ref[index];

	return zl3073x_read_u8(zldev, ZL_REG_REF_MON_STATUS(index),
			       &ref->mon_status);
}

/**
 * zl3073x_ref_state_fetch - fetch input reference state from hardware
 * @zldev: pointer to zl3073x_dev structure
 * @index: input reference index to fetch state for
 *
 * Function fetches state for the given input reference from hardware and
 * stores it for later use.
 *
 * Return: 0 on success, <0 on error
 */
int zl3073x_ref_state_fetch(struct zl3073x_dev *zldev, u8 index)
{
	struct zl3073x_ref *ref = &zldev->ref[index];
	int rc;

	/* For differential type inputs the N-pin reference shares
	 * part of the configuration with the P-pin counterpart.
	 */
	if (zl3073x_is_n_pin(index) && zl3073x_ref_is_diff(ref - 1)) {
		struct zl3073x_ref *p_ref = ref - 1; /* P-pin counterpart*/

		/* Copy the shared items from the P-pin */
		ref->cfg = p_ref->cfg;
		ref->inv = p_ref->inv;

		return 0; /* Finish - no non-shared items for now */
	}

	/* Read reference status */
	rc = zl3073x_ref_state_update(zldev, index);
	if (rc)
		return rc;

	guard(mutex)(&zldev->multiop_lock);

	/* Read reference configuration */
	rc = zl3073x_mb_op(zldev, ZL_REG_REF_MB_SEM, ZL_REF_MB_SEM_RD,
			   ZL_REG_REF_MB_MASK, BIT(index));
	if (rc)
		return rc;

	/* Read ref_config register */
	rc = zl3073x_read_u8(zldev, ZL_REG_REF_CONFIG, &ref->config);
	if (rc)
		return rc;

	/* Read frequency related registers */
	rc = zl3073x_read_u16(zldev, ZL_REG_REF_FREQ_BASE, &ref->freq_base);
	if (rc)
		return rc;
	rc = zl3073x_read_u16(zldev, ZL_REG_REF_FREQ_MULT, &ref->freq_mult);
	if (rc)
		return rc;
	rc = zl3073x_read_u16(zldev, ZL_REG_REF_RATIO_M, &ref->freq_ratio_m);
	if (rc)
		return rc;
	rc = zl3073x_read_u16(zldev, ZL_REG_REF_RATIO_N, &ref->freq_ratio_n);
	if (rc)
		return rc;

	/* Read eSync and N-div rated registers */
	rc = zl3073x_read_u32(zldev, ZL_REG_REF_ESYNC_DIV, &ref->esync_n_div);

Annotation

Implementation Notes