root/drivers/clk/meson/parm.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. meson_parm_read
  2. meson_parm_write

   1 /* SPDX-License-Identifier: GPL-2.0 */
   2 /*
   3  * Copyright (c) 2015 Endless Mobile, Inc.
   4  * Author: Carlo Caione <carlo@endlessm.com>
   5  */
   6 
   7 #ifndef __MESON_PARM_H
   8 #define __MESON_PARM_H
   9 
  10 #include <linux/bits.h>
  11 #include <linux/regmap.h>
  12 
  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))
  16 
  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)))
  21 
  22 #define MESON_PARM_APPLICABLE(p)                (!!((p)->width))
  23 
  24 struct parm {
  25         u16     reg_off;
  26         u8      shift;
  27         u8      width;
  28 };
  29 
  30 static inline unsigned int meson_parm_read(struct regmap *map, struct parm *p)
  31 {
  32         unsigned int val;
  33 
  34         regmap_read(map, p->reg_off, &val);
  35         return PARM_GET(p->width, p->shift, val);
  36 }
  37 
  38 static inline void meson_parm_write(struct regmap *map, struct parm *p,
  39                                     unsigned int val)
  40 {
  41         regmap_update_bits(map, p->reg_off, SETPMASK(p->width, p->shift),
  42                            val << p->shift);
  43 }
  44 
  45 #endif /* __MESON_PARM_H */
  46 

/* [<][>][^][v][top][bottom][index][help] */