module: Convert symbol namespace to string literal
[linux.git] / drivers / clk / meson / parm.h
blob3c9ef1b505cedd2d38c47f981381c242997ec5b5
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (c) 2015 Endless Mobile, Inc.
4 * Author: Carlo Caione <carlo@endlessm.com>
5 */
7 #ifndef __MESON_PARM_H
8 #define __MESON_PARM_H
10 #include <linux/bits.h>
11 #include <linux/regmap.h>
13 #define PMASK(width) GENMASK(width - 1, 0)
14 #define SETPMASK(width, shift) GENMASK(shift + width - 1, shift)
15 #define CLRPMASK(width, shift) (~SETPMASK(width, shift))
17 #define PARM_GET(width, shift, reg) \
18 (((reg) & SETPMASK(width, shift)) >> (shift))
19 #define PARM_SET(width, shift, reg, val) \
20 (((reg) & CLRPMASK(width, shift)) | ((val) << (shift)))
22 #define MESON_PARM_APPLICABLE(p) (!!((p)->width))
24 struct parm {
25 u16 reg_off;
26 u8 shift;
27 u8 width;
30 static inline unsigned int meson_parm_read(struct regmap *map, struct parm *p)
32 unsigned int val;
34 regmap_read(map, p->reg_off, &val);
35 return PARM_GET(p->width, p->shift, val);
38 static inline void meson_parm_write(struct regmap *map, struct parm *p,
39 unsigned int val)
41 regmap_update_bits(map, p->reg_off, SETPMASK(p->width, p->shift),
42 val << p->shift);
45 #endif /* __MESON_PARM_H */