xref: /openbmc/u-boot/drivers/clk/clk_meson.h (revision 24109bba)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * (C) Copyright 2018 - Beniamino Galvani <b.galvani@gmail.com>
4  * (C) Copyright 2018 - BayLibre, SAS
5  * Author: Neil Armstrong <narmstrong@baylibre.com>
6  */
7 
8 #ifndef CLK_MESON_H
9 #define CLK_MESON_H
10 
11 /* Gate Structure */
12 
13 struct meson_gate {
14 	unsigned int reg;
15 	unsigned int bit;
16 };
17 
18 #define MESON_GATE(id, _reg, _bit)		\
19 	[id] = {				\
20 		.reg = (_reg),			\
21 		.bit = (_bit),			\
22 	}
23 
24 /* PLL Parameters */
25 
26 struct parm {
27 	u16 reg_off;
28 	u8 shift;
29 	u8 width;
30 };
31 
32 #define PMASK(width)                    GENMASK(width - 1, 0)
33 #define SETPMASK(width, shift)          GENMASK(shift + width - 1, shift)
34 #define CLRPMASK(width, shift)          (~SETPMASK(width, shift))
35 
36 #define PARM_GET(width, shift, reg)                                     \
37 	(((reg) & SETPMASK(width, shift)) >> (shift))
38 #define PARM_SET(width, shift, reg, val)                                \
39 	(((reg) & CLRPMASK(width, shift)) | ((val) << (shift)))
40 
41 /* MPLL Parameters */
42 
43 #define SDM_DEN 16384
44 #define N2_MIN  4
45 #define N2_MAX  511
46 
47 #endif
48