18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Support functions for calculating clocks/divisors for the ICST
68c2ecf20Sopenharmony_ci *  clock generators.  See https://www.idt.com/ for more information
78c2ecf20Sopenharmony_ci *  on these devices.
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci#ifndef ICST_H
108c2ecf20Sopenharmony_ci#define ICST_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_cistruct icst_params {
138c2ecf20Sopenharmony_ci	unsigned long	ref;
148c2ecf20Sopenharmony_ci	unsigned long	vco_max;	/* inclusive */
158c2ecf20Sopenharmony_ci	unsigned long	vco_min;	/* exclusive */
168c2ecf20Sopenharmony_ci	unsigned short	vd_min;		/* inclusive */
178c2ecf20Sopenharmony_ci	unsigned short	vd_max;		/* inclusive */
188c2ecf20Sopenharmony_ci	unsigned char	rd_min;		/* inclusive */
198c2ecf20Sopenharmony_ci	unsigned char	rd_max;		/* inclusive */
208c2ecf20Sopenharmony_ci	const unsigned char *s2div;	/* chip specific s2div array */
218c2ecf20Sopenharmony_ci	const unsigned char *idx2s;	/* chip specific idx2s array */
228c2ecf20Sopenharmony_ci};
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistruct icst_vco {
258c2ecf20Sopenharmony_ci	unsigned short	v;
268c2ecf20Sopenharmony_ci	unsigned char	r;
278c2ecf20Sopenharmony_ci	unsigned char	s;
288c2ecf20Sopenharmony_ci};
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ciunsigned long icst_hz(const struct icst_params *p, struct icst_vco vco);
318c2ecf20Sopenharmony_cistruct icst_vco icst_hz_to_vco(const struct icst_params *p, unsigned long freq);
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/*
348c2ecf20Sopenharmony_ci * ICST307 VCO frequency must be between 6MHz and 200MHz (3.3 or 5V).
358c2ecf20Sopenharmony_ci * This frequency is pre-output divider.
368c2ecf20Sopenharmony_ci */
378c2ecf20Sopenharmony_ci#define ICST307_VCO_MIN	6000000
388c2ecf20Sopenharmony_ci#define ICST307_VCO_MAX	200000000
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ciextern const unsigned char icst307_s2div[];
418c2ecf20Sopenharmony_ciextern const unsigned char icst307_idx2s[];
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/*
448c2ecf20Sopenharmony_ci * ICST525 VCO frequency must be between 10MHz and 200MHz (3V) or 320MHz (5V).
458c2ecf20Sopenharmony_ci * This frequency is pre-output divider.
468c2ecf20Sopenharmony_ci */
478c2ecf20Sopenharmony_ci#define ICST525_VCO_MIN		10000000
488c2ecf20Sopenharmony_ci#define ICST525_VCO_MAX_3V	200000000
498c2ecf20Sopenharmony_ci#define ICST525_VCO_MAX_5V	320000000
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ciextern const unsigned char icst525_s2div[];
528c2ecf20Sopenharmony_ciextern const unsigned char icst525_idx2s[];
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#endif
55