clk: meson: add regmap helpers for parm
authorJerome Brunet <jbrunet@baylibre.com>
Mon, 12 Feb 2018 14:58:39 +0000 (15:58 +0100)
committerNeil Armstrong <narmstrong@baylibre.com>
Tue, 13 Mar 2018 09:04:01 +0000 (10:04 +0100)
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>
drivers/clk/meson/clkc.h

index aa2dfa0ff89f362492b3767f2afd2c0075ad44a2..8edc2529742225f9111854ffddd5d4efb6b03d66 100644 (file)
@@ -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;