18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2014 Samsung Electronics Co., Ltd.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Common Clock Framework support for all PLL's in Samsung platforms
68c2ecf20Sopenharmony_ci*/
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef __SAMSUNG_CLK_CPU_H
98c2ecf20Sopenharmony_ci#define __SAMSUNG_CLK_CPU_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include "clk.h"
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/**
148c2ecf20Sopenharmony_ci * struct exynos_cpuclk_data: config data to setup cpu clocks.
158c2ecf20Sopenharmony_ci * @prate: frequency of the primary parent clock (in KHz).
168c2ecf20Sopenharmony_ci * @div0: value to be programmed in the div_cpu0 register.
178c2ecf20Sopenharmony_ci * @div1: value to be programmed in the div_cpu1 register.
188c2ecf20Sopenharmony_ci *
198c2ecf20Sopenharmony_ci * This structure holds the divider configuration data for dividers in the CPU
208c2ecf20Sopenharmony_ci * clock domain. The parent frequency at which these divider values are valid is
218c2ecf20Sopenharmony_ci * specified in @prate. The @prate is the frequency of the primary parent clock.
228c2ecf20Sopenharmony_ci * For CPU clock domains that do not have a DIV1 register, the @div1 member
238c2ecf20Sopenharmony_ci * value is not used.
248c2ecf20Sopenharmony_ci */
258c2ecf20Sopenharmony_cistruct exynos_cpuclk_cfg_data {
268c2ecf20Sopenharmony_ci	unsigned long	prate;
278c2ecf20Sopenharmony_ci	unsigned long	div0;
288c2ecf20Sopenharmony_ci	unsigned long	div1;
298c2ecf20Sopenharmony_ci};
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci/**
328c2ecf20Sopenharmony_ci * struct exynos_cpuclk: information about clock supplied to a CPU core.
338c2ecf20Sopenharmony_ci * @hw:	handle between CCF and CPU clock.
348c2ecf20Sopenharmony_ci * @alt_parent: alternate parent clock to use when switching the speed
358c2ecf20Sopenharmony_ci *	of the primary parent clock.
368c2ecf20Sopenharmony_ci * @ctrl_base:	base address of the clock controller.
378c2ecf20Sopenharmony_ci * @lock: cpu clock domain register access lock.
388c2ecf20Sopenharmony_ci * @cfg: cpu clock rate configuration data.
398c2ecf20Sopenharmony_ci * @num_cfgs: number of array elements in @cfg array.
408c2ecf20Sopenharmony_ci * @clk_nb: clock notifier registered for changes in clock speed of the
418c2ecf20Sopenharmony_ci *	primary parent clock.
428c2ecf20Sopenharmony_ci * @flags: configuration flags for the CPU clock.
438c2ecf20Sopenharmony_ci *
448c2ecf20Sopenharmony_ci * This structure holds information required for programming the CPU clock for
458c2ecf20Sopenharmony_ci * various clock speeds.
468c2ecf20Sopenharmony_ci */
478c2ecf20Sopenharmony_cistruct exynos_cpuclk {
488c2ecf20Sopenharmony_ci	struct clk_hw				hw;
498c2ecf20Sopenharmony_ci	const struct clk_hw			*alt_parent;
508c2ecf20Sopenharmony_ci	void __iomem				*ctrl_base;
518c2ecf20Sopenharmony_ci	spinlock_t				*lock;
528c2ecf20Sopenharmony_ci	const struct exynos_cpuclk_cfg_data	*cfg;
538c2ecf20Sopenharmony_ci	const unsigned long			num_cfgs;
548c2ecf20Sopenharmony_ci	struct notifier_block			clk_nb;
558c2ecf20Sopenharmony_ci	unsigned long				flags;
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/* The CPU clock registers have DIV1 configuration register */
588c2ecf20Sopenharmony_ci#define CLK_CPU_HAS_DIV1		(1 << 0)
598c2ecf20Sopenharmony_ci/* When ALT parent is active, debug clocks need safe divider values */
608c2ecf20Sopenharmony_ci#define CLK_CPU_NEEDS_DEBUG_ALT_DIV	(1 << 1)
618c2ecf20Sopenharmony_ci/* The CPU clock registers have Exynos5433-compatible layout */
628c2ecf20Sopenharmony_ci#define CLK_CPU_HAS_E5433_REGS_LAYOUT	(1 << 2)
638c2ecf20Sopenharmony_ci};
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ciint __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
668c2ecf20Sopenharmony_ci			unsigned int lookup_id, const char *name,
678c2ecf20Sopenharmony_ci			const struct clk_hw *parent, const struct clk_hw *alt_parent,
688c2ecf20Sopenharmony_ci			unsigned long offset,
698c2ecf20Sopenharmony_ci			const struct exynos_cpuclk_cfg_data *cfg,
708c2ecf20Sopenharmony_ci			unsigned long num_cfgs, unsigned long flags);
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#endif /* __SAMSUNG_CLK_CPU_H */
73