diff options
author | Jerome Brunet <jbrunet@baylibre.com> | 2018-02-12 15:58:39 +0100 |
---|---|---|
committer | Neil Armstrong <narmstrong@baylibre.com> | 2018-03-13 10:04:01 +0100 |
commit | f510c32a6af6123bc0638bfe869728bf8be71027 (patch) | |
tree | ef8ce7d184c8fc15d398c3de249dba670ddc45f9 /drivers/clk/meson/clkc.h | |
parent | 2513a28c108b0584989927195ba5230e296762ec (diff) | |
download | op-kernel-dev-f510c32a6af6123bc0638bfe869728bf8be71027.zip op-kernel-dev-f510c32a6af6123bc0638bfe869728bf8be71027.tar.gz |
clk: meson: add regmap helpers for parm
Meson clock drivers are using struct parm to describe each field of the
clock provider. Providing helpers to access these fields with regmap
helps to keep drivers readable
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Diffstat (limited to 'drivers/clk/meson/clkc.h')
-rw-r--r-- | drivers/clk/meson/clkc.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/clk/meson/clkc.h b/drivers/clk/meson/clkc.h index aa2dfa0..8edc252 100644 --- a/drivers/clk/meson/clkc.h +++ b/drivers/clk/meson/clkc.h @@ -38,6 +38,22 @@ struct parm { u8 width; }; +static inline unsigned int meson_parm_read(struct regmap *map, struct parm *p) +{ + unsigned int val; + + regmap_read(map, p->reg_off, &val); + return PARM_GET(p->width, p->shift, val); +} + +static inline void meson_parm_write(struct regmap *map, struct parm *p, + unsigned int val) +{ + regmap_update_bits(map, p->reg_off, SETPMASK(p->width, p->shift), + val << p->shift); +} + + struct pll_rate_table { unsigned long rate; u16 m; |