exynos-asv.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2019 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com/
  5. * Author: Sylwester Nawrocki <s.nawrocki@samsung.com>
  6. *
  7. * Samsung Exynos SoC Adaptive Supply Voltage support
  8. */
  9. #ifndef __LINUX_SOC_EXYNOS_ASV_H
  10. #define __LINUX_SOC_EXYNOS_ASV_H
  11. struct regmap;
  12. /* HPM, IDS values to select target group */
  13. struct asv_limit_entry {
  14. unsigned int hpm;
  15. unsigned int ids;
  16. };
  17. struct exynos_asv_table {
  18. unsigned int num_rows;
  19. unsigned int num_cols;
  20. u32 *buf;
  21. };
  22. struct exynos_asv_subsys {
  23. struct exynos_asv *asv;
  24. const char *cpu_dt_compat;
  25. int id;
  26. struct exynos_asv_table table;
  27. unsigned int base_volt;
  28. unsigned int offset_volt_h;
  29. unsigned int offset_volt_l;
  30. };
  31. struct exynos_asv {
  32. struct device *dev;
  33. struct regmap *chipid_regmap;
  34. struct exynos_asv_subsys subsys[2];
  35. int (*opp_get_voltage)(const struct exynos_asv_subsys *subs,
  36. int level, unsigned int voltage);
  37. unsigned int group;
  38. unsigned int table;
  39. /* True if SG fields from PKG_ID register should be used */
  40. bool use_sg;
  41. /* ASV bin read from DT */
  42. int of_bin;
  43. };
  44. static inline u32 __asv_get_table_entry(const struct exynos_asv_table *table,
  45. unsigned int row, unsigned int col)
  46. {
  47. return table->buf[row * (table->num_cols) + col];
  48. }
  49. static inline u32 exynos_asv_opp_get_voltage(const struct exynos_asv_subsys *subsys,
  50. unsigned int level, unsigned int group)
  51. {
  52. return __asv_get_table_entry(&subsys->table, level, group + 1);
  53. }
  54. static inline u32 exynos_asv_opp_get_frequency(const struct exynos_asv_subsys *subsys,
  55. unsigned int level)
  56. {
  57. return __asv_get_table_entry(&subsys->table, level, 0);
  58. }
  59. #endif /* __LINUX_SOC_EXYNOS_ASV_H */