summaryrefslogtreecommitdiff
path: root/drivers/clk/zynqmp/clk-zynqmp.h
blob: 84fa80a969a95beadc06a95242754a268fd2d735 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* SPDX-License-Identifier: GPL-2.0 */
/*
 *  Copyright (C) 2016-2018 Xilinx
 */

#ifndef __LINUX_CLK_ZYNQMP_H_
#define __LINUX_CLK_ZYNQMP_H_

#include <linux/spinlock.h>

#include <linux/firmware/xlnx-zynqmp.h>

/* Common Flags */
/* must be gated across rate change */
#define ZYNQMP_CLK_SET_RATE_GATE	BIT(0)
/* must be gated across re-parent */
#define ZYNQMP_CLK_SET_PARENT_GATE	BIT(1)
/* propagate rate change up one level */
#define ZYNQMP_CLK_SET_RATE_PARENT	BIT(2)
/* do not gate even if unused */
#define ZYNQMP_CLK_IGNORE_UNUSED	BIT(3)
/* don't re-parent on rate change */
#define ZYNQMP_CLK_SET_RATE_NO_REPARENT	BIT(7)
/* do not gate, ever */
#define ZYNQMP_CLK_IS_CRITICAL		BIT(11)

/* Type Flags for divider clock */
#define ZYNQMP_CLK_DIVIDER_ONE_BASED		BIT(0)
#define ZYNQMP_CLK_DIVIDER_POWER_OF_TWO		BIT(1)
#define ZYNQMP_CLK_DIVIDER_ALLOW_ZERO		BIT(2)
#define ZYNQMP_CLK_DIVIDER_HIWORD_MASK		BIT(3)
#define ZYNQMP_CLK_DIVIDER_ROUND_CLOSEST	BIT(4)
#define ZYNQMP_CLK_DIVIDER_READ_ONLY		BIT(5)
#define ZYNQMP_CLK_DIVIDER_MAX_AT_ZERO		BIT(6)

/* Type Flags for mux clock */
#define ZYNQMP_CLK_MUX_INDEX_ONE		BIT(0)
#define ZYNQMP_CLK_MUX_INDEX_BIT		BIT(1)
#define ZYNQMP_CLK_MUX_HIWORD_MASK		BIT(2)
#define ZYNQMP_CLK_MUX_READ_ONLY		BIT(3)
#define ZYNQMP_CLK_MUX_ROUND_CLOSEST		BIT(4)
#define ZYNQMP_CLK_MUX_BIG_ENDIAN		BIT(5)

enum topology_type {
	TYPE_INVALID,
	TYPE_MUX,
	TYPE_PLL,
	TYPE_FIXEDFACTOR,
	TYPE_DIV1,
	TYPE_DIV2,
	TYPE_GATE,
};

/**
 * struct clock_topology - Clock topology
 * @type:	Type of topology
 * @flag:	Topology flags
 * @type_flag:	Topology type specific flag
 */
struct clock_topology {
	u32 type;
	u32 flag;
	u32 type_flag;
	u8 custom_type_flag;
};

unsigned long zynqmp_clk_map_common_ccf_flags(const u32 zynqmp_flag);

struct clk_hw *zynqmp_clk_register_pll(const char *name, u32 clk_id,
				       const char * const *parents,
				       u8 num_parents,
				       const struct clock_topology *nodes);

struct clk_hw *zynqmp_clk_register_gate(const char *name, u32 clk_id,
					const char * const *parents,
					u8 num_parents,
					const struct clock_topology *nodes);

struct clk_hw *zynqmp_clk_register_divider(const char *name,
					   u32 clk_id,
					   const char * const *parents,
					   u8 num_parents,
					   const struct clock_topology *nodes);

struct clk_hw *zynqmp_clk_register_mux(const char *name, u32 clk_id,
				       const char * const *parents,
				       u8 num_parents,
				       const struct clock_topology *nodes);

struct clk_hw *zynqmp_clk_register_fixed_factor(const char *name,
					u32 clk_id,
					const char * const *parents,
					u8 num_parents,
					const struct clock_topology *nodes);

#endif