13fde0e16SJolly Shah /* SPDX-License-Identifier: GPL-2.0 */ 23fde0e16SJolly Shah /* 33fde0e16SJolly Shah * Copyright (C) 2016-2018 Xilinx 43fde0e16SJolly Shah */ 53fde0e16SJolly Shah 63fde0e16SJolly Shah #ifndef __LINUX_CLK_ZYNQMP_H_ 73fde0e16SJolly Shah #define __LINUX_CLK_ZYNQMP_H_ 83fde0e16SJolly Shah 93fde0e16SJolly Shah #include <linux/spinlock.h> 103fde0e16SJolly Shah 113fde0e16SJolly Shah #include <linux/firmware/xlnx-zynqmp.h> 123fde0e16SJolly Shah 13610a5d83SRajan Vaja /* Common Flags */ 14610a5d83SRajan Vaja /* must be gated across rate change */ 15610a5d83SRajan Vaja #define ZYNQMP_CLK_SET_RATE_GATE BIT(0) 16610a5d83SRajan Vaja /* must be gated across re-parent */ 17610a5d83SRajan Vaja #define ZYNQMP_CLK_SET_PARENT_GATE BIT(1) 18610a5d83SRajan Vaja /* propagate rate change up one level */ 19610a5d83SRajan Vaja #define ZYNQMP_CLK_SET_RATE_PARENT BIT(2) 20610a5d83SRajan Vaja /* do not gate even if unused */ 21610a5d83SRajan Vaja #define ZYNQMP_CLK_IGNORE_UNUSED BIT(3) 22610a5d83SRajan Vaja /* don't re-parent on rate change */ 23610a5d83SRajan Vaja #define ZYNQMP_CLK_SET_RATE_NO_REPARENT BIT(7) 24610a5d83SRajan Vaja /* do not gate, ever */ 25610a5d83SRajan Vaja #define ZYNQMP_CLK_IS_CRITICAL BIT(11) 26610a5d83SRajan Vaja 27*1b09c308SRajan Vaja /* Type Flags for divider clock */ 28*1b09c308SRajan Vaja #define ZYNQMP_CLK_DIVIDER_ONE_BASED BIT(0) 29*1b09c308SRajan Vaja #define ZYNQMP_CLK_DIVIDER_POWER_OF_TWO BIT(1) 30*1b09c308SRajan Vaja #define ZYNQMP_CLK_DIVIDER_ALLOW_ZERO BIT(2) 31*1b09c308SRajan Vaja #define ZYNQMP_CLK_DIVIDER_HIWORD_MASK BIT(3) 32*1b09c308SRajan Vaja #define ZYNQMP_CLK_DIVIDER_ROUND_CLOSEST BIT(4) 33*1b09c308SRajan Vaja #define ZYNQMP_CLK_DIVIDER_READ_ONLY BIT(5) 34*1b09c308SRajan Vaja #define ZYNQMP_CLK_DIVIDER_MAX_AT_ZERO BIT(6) 35*1b09c308SRajan Vaja 363fde0e16SJolly Shah enum topology_type { 373fde0e16SJolly Shah TYPE_INVALID, 383fde0e16SJolly Shah TYPE_MUX, 393fde0e16SJolly Shah TYPE_PLL, 403fde0e16SJolly Shah TYPE_FIXEDFACTOR, 413fde0e16SJolly Shah TYPE_DIV1, 423fde0e16SJolly Shah TYPE_DIV2, 433fde0e16SJolly Shah TYPE_GATE, 443fde0e16SJolly Shah }; 453fde0e16SJolly Shah 463fde0e16SJolly Shah /** 473fde0e16SJolly Shah * struct clock_topology - Clock topology 483fde0e16SJolly Shah * @type: Type of topology 493fde0e16SJolly Shah * @flag: Topology flags 503fde0e16SJolly Shah * @type_flag: Topology type specific flag 513fde0e16SJolly Shah */ 523fde0e16SJolly Shah struct clock_topology { 533fde0e16SJolly Shah u32 type; 543fde0e16SJolly Shah u32 flag; 553fde0e16SJolly Shah u32 type_flag; 56e605fa9cSRajan Vaja u8 custom_type_flag; 573fde0e16SJolly Shah }; 583fde0e16SJolly Shah 59610a5d83SRajan Vaja unsigned long zynqmp_clk_map_common_ccf_flags(const u32 zynqmp_flag); 60610a5d83SRajan Vaja 613fde0e16SJolly Shah struct clk_hw *zynqmp_clk_register_pll(const char *name, u32 clk_id, 623fde0e16SJolly Shah const char * const *parents, 633fde0e16SJolly Shah u8 num_parents, 643fde0e16SJolly Shah const struct clock_topology *nodes); 653fde0e16SJolly Shah 663fde0e16SJolly Shah struct clk_hw *zynqmp_clk_register_gate(const char *name, u32 clk_id, 673fde0e16SJolly Shah const char * const *parents, 683fde0e16SJolly Shah u8 num_parents, 693fde0e16SJolly Shah const struct clock_topology *nodes); 703fde0e16SJolly Shah 713fde0e16SJolly Shah struct clk_hw *zynqmp_clk_register_divider(const char *name, 723fde0e16SJolly Shah u32 clk_id, 733fde0e16SJolly Shah const char * const *parents, 743fde0e16SJolly Shah u8 num_parents, 753fde0e16SJolly Shah const struct clock_topology *nodes); 763fde0e16SJolly Shah 773fde0e16SJolly Shah struct clk_hw *zynqmp_clk_register_mux(const char *name, u32 clk_id, 783fde0e16SJolly Shah const char * const *parents, 793fde0e16SJolly Shah u8 num_parents, 803fde0e16SJolly Shah const struct clock_topology *nodes); 813fde0e16SJolly Shah 823fde0e16SJolly Shah struct clk_hw *zynqmp_clk_register_fixed_factor(const char *name, 833fde0e16SJolly Shah u32 clk_id, 843fde0e16SJolly Shah const char * const *parents, 853fde0e16SJolly Shah u8 num_parents, 863fde0e16SJolly Shah const struct clock_topology *nodes); 873fde0e16SJolly Shah 883fde0e16SJolly Shah #endif 89