blob: ef72a416c15145249eb89fa25c5a3d0c0b9b91ff [file] [log] [blame]
Beniamino Galvanic0fc1e22018-06-14 13:43:39 +02001/* 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
Simon Glasscd93d622020-05-10 11:40:13 -060013#include <linux/bitops.h>
Beniamino Galvanic0fc1e22018-06-14 13:43:39 +020014struct meson_gate {
15 unsigned int reg;
16 unsigned int bit;
17};
18
19#define MESON_GATE(id, _reg, _bit) \
20 [id] = { \
21 .reg = (_reg), \
22 .bit = (_bit), \
23 }
24
25/* PLL Parameters */
26
27struct parm {
28 u16 reg_off;
29 u8 shift;
30 u8 width;
31};
32
33#define PMASK(width) GENMASK(width - 1, 0)
34#define SETPMASK(width, shift) GENMASK(shift + width - 1, shift)
35#define CLRPMASK(width, shift) (~SETPMASK(width, shift))
36
37#define PARM_GET(width, shift, reg) \
38 (((reg) & SETPMASK(width, shift)) >> (shift))
39#define PARM_SET(width, shift, reg, val) \
40 (((reg) & CLRPMASK(width, shift)) | ((val) << (shift)))
41
42/* MPLL Parameters */
43
44#define SDM_DEN 16384
45#define N2_MIN 4
46#define N2_MAX 511
47
48#endif