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 271b09c308SRajan Vaja /* Type Flags for divider clock */ 281b09c308SRajan Vaja #define ZYNQMP_CLK_DIVIDER_ONE_BASED BIT(0) 291b09c308SRajan Vaja #define ZYNQMP_CLK_DIVIDER_POWER_OF_TWO BIT(1) 301b09c308SRajan Vaja #define ZYNQMP_CLK_DIVIDER_ALLOW_ZERO BIT(2) 311b09c308SRajan Vaja #define ZYNQMP_CLK_DIVIDER_HIWORD_MASK BIT(3) 321b09c308SRajan Vaja #define ZYNQMP_CLK_DIVIDER_ROUND_CLOSEST BIT(4) 331b09c308SRajan Vaja #define ZYNQMP_CLK_DIVIDER_READ_ONLY BIT(5) 341b09c308SRajan Vaja #define ZYNQMP_CLK_DIVIDER_MAX_AT_ZERO BIT(6) 351b09c308SRajan Vaja 3654530ed1SRajan Vaja /* Type Flags for mux clock */ 3754530ed1SRajan Vaja #define ZYNQMP_CLK_MUX_INDEX_ONE BIT(0) 3854530ed1SRajan Vaja #define ZYNQMP_CLK_MUX_INDEX_BIT BIT(1) 3954530ed1SRajan Vaja #define ZYNQMP_CLK_MUX_HIWORD_MASK BIT(2) 4054530ed1SRajan Vaja #define ZYNQMP_CLK_MUX_READ_ONLY BIT(3) 4154530ed1SRajan Vaja #define ZYNQMP_CLK_MUX_ROUND_CLOSEST BIT(4) 4254530ed1SRajan Vaja #define ZYNQMP_CLK_MUX_BIG_ENDIAN BIT(5) 4354530ed1SRajan Vaja 443fde0e16SJolly Shah enum topology_type { 453fde0e16SJolly Shah TYPE_INVALID, 463fde0e16SJolly Shah TYPE_MUX, 473fde0e16SJolly Shah TYPE_PLL, 483fde0e16SJolly Shah TYPE_FIXEDFACTOR, 493fde0e16SJolly Shah TYPE_DIV1, 503fde0e16SJolly Shah TYPE_DIV2, 513fde0e16SJolly Shah TYPE_GATE, 523fde0e16SJolly Shah }; 533fde0e16SJolly Shah 543fde0e16SJolly Shah /** 553fde0e16SJolly Shah * struct clock_topology - Clock topology 563fde0e16SJolly Shah * @type: Type of topology 573fde0e16SJolly Shah * @flag: Topology flags 583fde0e16SJolly Shah * @type_flag: Topology type specific flag 59*0cbc0eb1SRajan Vaja * @custom_type_flag: Topology type specific custom flag 603fde0e16SJolly Shah */ 613fde0e16SJolly Shah struct clock_topology { 623fde0e16SJolly Shah u32 type; 633fde0e16SJolly Shah u32 flag; 643fde0e16SJolly Shah u32 type_flag; 65e605fa9cSRajan Vaja u8 custom_type_flag; 663fde0e16SJolly Shah }; 673fde0e16SJolly Shah 68610a5d83SRajan Vaja unsigned long zynqmp_clk_map_common_ccf_flags(const u32 zynqmp_flag); 69610a5d83SRajan Vaja 703fde0e16SJolly Shah struct clk_hw *zynqmp_clk_register_pll(const char *name, u32 clk_id, 713fde0e16SJolly Shah const char * const *parents, 723fde0e16SJolly Shah u8 num_parents, 733fde0e16SJolly Shah const struct clock_topology *nodes); 743fde0e16SJolly Shah 753fde0e16SJolly Shah struct clk_hw *zynqmp_clk_register_gate(const char *name, u32 clk_id, 763fde0e16SJolly Shah const char * const *parents, 773fde0e16SJolly Shah u8 num_parents, 783fde0e16SJolly Shah const struct clock_topology *nodes); 793fde0e16SJolly Shah 803fde0e16SJolly Shah struct clk_hw *zynqmp_clk_register_divider(const char *name, 813fde0e16SJolly Shah u32 clk_id, 823fde0e16SJolly Shah const char * const *parents, 833fde0e16SJolly Shah u8 num_parents, 843fde0e16SJolly Shah const struct clock_topology *nodes); 853fde0e16SJolly Shah 863fde0e16SJolly Shah struct clk_hw *zynqmp_clk_register_mux(const char *name, u32 clk_id, 873fde0e16SJolly Shah const char * const *parents, 883fde0e16SJolly Shah u8 num_parents, 893fde0e16SJolly Shah const struct clock_topology *nodes); 903fde0e16SJolly Shah 913fde0e16SJolly Shah struct clk_hw *zynqmp_clk_register_fixed_factor(const char *name, 923fde0e16SJolly Shah u32 clk_id, 933fde0e16SJolly Shah const char * const *parents, 943fde0e16SJolly Shah u8 num_parents, 953fde0e16SJolly Shah const struct clock_topology *nodes); 963fde0e16SJolly Shah 973fde0e16SJolly Shah #endif 98