clk_meson.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* 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. #ifndef CLK_MESON_H
  8. #define CLK_MESON_H
  9. /* Gate Structure */
  10. #include <linux/bitops.h>
  11. struct meson_gate {
  12. unsigned int reg;
  13. unsigned int bit;
  14. };
  15. #define MESON_GATE(id, _reg, _bit) \
  16. [id] = { \
  17. .reg = (_reg), \
  18. .bit = (_bit), \
  19. }
  20. /* PLL Parameters */
  21. struct parm {
  22. u16 reg_off;
  23. u8 shift;
  24. u8 width;
  25. };
  26. #define PMASK(width) GENMASK(width - 1, 0)
  27. #define SETPMASK(width, shift) GENMASK(shift + width - 1, shift)
  28. #define CLRPMASK(width, shift) (~SETPMASK(width, shift))
  29. #define PARM_GET(width, shift, reg) \
  30. (((reg) & SETPMASK(width, shift)) >> (shift))
  31. #define PARM_SET(width, shift, reg, val) \
  32. (((reg) & CLRPMASK(width, shift)) | ((val) << (shift)))
  33. /* MPLL Parameters */
  34. #define SDM_DEN 16384
  35. #define N2_MIN 4
  36. #define N2_MAX 511
  37. #endif