162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2016-2018 Xilinx 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#ifndef __LINUX_CLK_ZYNQMP_H_ 762306a36Sopenharmony_ci#define __LINUX_CLK_ZYNQMP_H_ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#include <linux/spinlock.h> 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include <linux/firmware/xlnx-zynqmp.h> 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci/* Common Flags */ 1462306a36Sopenharmony_ci/* must be gated across rate change */ 1562306a36Sopenharmony_ci#define ZYNQMP_CLK_SET_RATE_GATE BIT(0) 1662306a36Sopenharmony_ci/* must be gated across re-parent */ 1762306a36Sopenharmony_ci#define ZYNQMP_CLK_SET_PARENT_GATE BIT(1) 1862306a36Sopenharmony_ci/* propagate rate change up one level */ 1962306a36Sopenharmony_ci#define ZYNQMP_CLK_SET_RATE_PARENT BIT(2) 2062306a36Sopenharmony_ci/* do not gate even if unused */ 2162306a36Sopenharmony_ci#define ZYNQMP_CLK_IGNORE_UNUSED BIT(3) 2262306a36Sopenharmony_ci/* don't re-parent on rate change */ 2362306a36Sopenharmony_ci#define ZYNQMP_CLK_SET_RATE_NO_REPARENT BIT(7) 2462306a36Sopenharmony_ci/* do not gate, ever */ 2562306a36Sopenharmony_ci#define ZYNQMP_CLK_IS_CRITICAL BIT(11) 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci/* Type Flags for divider clock */ 2862306a36Sopenharmony_ci#define ZYNQMP_CLK_DIVIDER_ONE_BASED BIT(0) 2962306a36Sopenharmony_ci#define ZYNQMP_CLK_DIVIDER_POWER_OF_TWO BIT(1) 3062306a36Sopenharmony_ci#define ZYNQMP_CLK_DIVIDER_ALLOW_ZERO BIT(2) 3162306a36Sopenharmony_ci#define ZYNQMP_CLK_DIVIDER_HIWORD_MASK BIT(3) 3262306a36Sopenharmony_ci#define ZYNQMP_CLK_DIVIDER_ROUND_CLOSEST BIT(4) 3362306a36Sopenharmony_ci#define ZYNQMP_CLK_DIVIDER_READ_ONLY BIT(5) 3462306a36Sopenharmony_ci#define ZYNQMP_CLK_DIVIDER_MAX_AT_ZERO BIT(6) 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci/* Type Flags for mux clock */ 3762306a36Sopenharmony_ci#define ZYNQMP_CLK_MUX_INDEX_ONE BIT(0) 3862306a36Sopenharmony_ci#define ZYNQMP_CLK_MUX_INDEX_BIT BIT(1) 3962306a36Sopenharmony_ci#define ZYNQMP_CLK_MUX_HIWORD_MASK BIT(2) 4062306a36Sopenharmony_ci#define ZYNQMP_CLK_MUX_READ_ONLY BIT(3) 4162306a36Sopenharmony_ci#define ZYNQMP_CLK_MUX_ROUND_CLOSEST BIT(4) 4262306a36Sopenharmony_ci#define ZYNQMP_CLK_MUX_BIG_ENDIAN BIT(5) 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_cienum topology_type { 4562306a36Sopenharmony_ci TYPE_INVALID, 4662306a36Sopenharmony_ci TYPE_MUX, 4762306a36Sopenharmony_ci TYPE_PLL, 4862306a36Sopenharmony_ci TYPE_FIXEDFACTOR, 4962306a36Sopenharmony_ci TYPE_DIV1, 5062306a36Sopenharmony_ci TYPE_DIV2, 5162306a36Sopenharmony_ci TYPE_GATE, 5262306a36Sopenharmony_ci}; 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci/** 5562306a36Sopenharmony_ci * struct clock_topology - Clock topology 5662306a36Sopenharmony_ci * @type: Type of topology 5762306a36Sopenharmony_ci * @flag: Topology flags 5862306a36Sopenharmony_ci * @type_flag: Topology type specific flag 5962306a36Sopenharmony_ci * @custom_type_flag: Topology type specific custom flag 6062306a36Sopenharmony_ci */ 6162306a36Sopenharmony_cistruct clock_topology { 6262306a36Sopenharmony_ci u32 type; 6362306a36Sopenharmony_ci u32 flag; 6462306a36Sopenharmony_ci u32 type_flag; 6562306a36Sopenharmony_ci u8 custom_type_flag; 6662306a36Sopenharmony_ci}; 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ciunsigned long zynqmp_clk_map_common_ccf_flags(const u32 zynqmp_flag); 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_cistruct clk_hw *zynqmp_clk_register_pll(const char *name, u32 clk_id, 7162306a36Sopenharmony_ci const char * const *parents, 7262306a36Sopenharmony_ci u8 num_parents, 7362306a36Sopenharmony_ci const struct clock_topology *nodes); 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_cistruct clk_hw *zynqmp_clk_register_gate(const char *name, u32 clk_id, 7662306a36Sopenharmony_ci const char * const *parents, 7762306a36Sopenharmony_ci u8 num_parents, 7862306a36Sopenharmony_ci const struct clock_topology *nodes); 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_cistruct clk_hw *zynqmp_clk_register_divider(const char *name, 8162306a36Sopenharmony_ci u32 clk_id, 8262306a36Sopenharmony_ci const char * const *parents, 8362306a36Sopenharmony_ci u8 num_parents, 8462306a36Sopenharmony_ci const struct clock_topology *nodes); 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_cistruct clk_hw *zynqmp_clk_register_mux(const char *name, u32 clk_id, 8762306a36Sopenharmony_ci const char * const *parents, 8862306a36Sopenharmony_ci u8 num_parents, 8962306a36Sopenharmony_ci const struct clock_topology *nodes); 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_cistruct clk_hw *zynqmp_clk_register_fixed_factor(const char *name, 9262306a36Sopenharmony_ci u32 clk_id, 9362306a36Sopenharmony_ci const char * const *parents, 9462306a36Sopenharmony_ci u8 num_parents, 9562306a36Sopenharmony_ci const struct clock_topology *nodes); 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci#endif 98