ccu_sdm.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017 Chen-Yu Tsai. All rights reserved.
  4. */
  5. #ifndef _CCU_SDM_H
  6. #define _CCU_SDM_H
  7. #include <linux/clk-provider.h>
  8. #include "ccu_common.h"
  9. struct ccu_sdm_setting {
  10. unsigned long rate;
  11. /*
  12. * XXX We don't know what the step and bottom register fields
  13. * mean. Just copy the whole register value from the vendor
  14. * kernel for now.
  15. */
  16. u32 pattern;
  17. /*
  18. * M and N factors here should be the values used in
  19. * calculation, not the raw values written to registers
  20. */
  21. u32 m;
  22. u32 n;
  23. };
  24. struct ccu_sdm_internal {
  25. struct ccu_sdm_setting *table;
  26. u32 table_size;
  27. /* early SoCs don't have the SDM enable bit in the PLL register */
  28. u32 enable;
  29. /* second enable bit in tuning register */
  30. u32 tuning_enable;
  31. u16 tuning_reg;
  32. };
  33. #define _SUNXI_CCU_SDM(_table, _enable, \
  34. _reg, _reg_enable) \
  35. { \
  36. .table = _table, \
  37. .table_size = ARRAY_SIZE(_table), \
  38. .enable = _enable, \
  39. .tuning_enable = _reg_enable, \
  40. .tuning_reg = _reg, \
  41. }
  42. bool ccu_sdm_helper_is_enabled(struct ccu_common *common,
  43. struct ccu_sdm_internal *sdm);
  44. void ccu_sdm_helper_enable(struct ccu_common *common,
  45. struct ccu_sdm_internal *sdm,
  46. unsigned long rate);
  47. void ccu_sdm_helper_disable(struct ccu_common *common,
  48. struct ccu_sdm_internal *sdm);
  49. bool ccu_sdm_helper_has_rate(struct ccu_common *common,
  50. struct ccu_sdm_internal *sdm,
  51. unsigned long rate);
  52. unsigned long ccu_sdm_helper_read_rate(struct ccu_common *common,
  53. struct ccu_sdm_internal *sdm,
  54. u32 m, u32 n);
  55. int ccu_sdm_helper_get_factors(struct ccu_common *common,
  56. struct ccu_sdm_internal *sdm,
  57. unsigned long rate,
  58. unsigned long *m, unsigned long *n);
  59. #endif