qcom-simple-lpm.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef __QCOM_SIMPLE_LPM_H__
  6. #define __QCOM_SIMPLE_LPM_H__
  7. #define MAX_CLUSTER_STATES 4
  8. extern bool simple_sleep_disabled;
  9. struct qcom_simple_cluster_node {
  10. struct simple_lpm_cluster *cluster;
  11. struct kobject *kobj;
  12. int state_idx;
  13. struct kobj_attribute disable_attr;
  14. struct attribute_group *attr_group;
  15. struct attribute **attrs;
  16. };
  17. struct simple_lpm_cpu {
  18. int cpu;
  19. int enable;
  20. int last_idx;
  21. struct notifier_block nb;
  22. struct cpuidle_driver *drv;
  23. struct cpuidle_device *dev;
  24. ktime_t next_wakeup;
  25. ktime_t now;
  26. };
  27. struct simple_lpm_cluster {
  28. struct device *dev;
  29. struct generic_pm_domain *genpd;
  30. struct qcom_simple_cluster_node *dev_node[MAX_CLUSTER_STATES];
  31. struct kobject *dev_kobj;
  32. struct notifier_block genpd_nb;
  33. bool state_allowed[MAX_CLUSTER_STATES];
  34. struct list_head list;
  35. spinlock_t lock;
  36. bool initialized;
  37. };
  38. struct simple_cluster_governor {
  39. void (*select)(struct simple_lpm_cpu *cpu_gov);
  40. void (*enable)(void);
  41. void (*disable)(void);
  42. void (*reflect)(void);
  43. };
  44. DECLARE_PER_CPU(struct simple_lpm_cpu, lpm_cpu_data);
  45. extern struct list_head cluster_dev_list;
  46. extern u64 cur_div;
  47. extern u64 cluster_cur_div;
  48. void update_simple_cluster_select(struct simple_lpm_cpu *cpu_gov);
  49. int create_simple_gov_global_sysfs_nodes(void);
  50. void remove_simple_gov_global_sysfs_nodes(void);
  51. void register_cluster_simple_governor_ops(struct simple_cluster_governor *ops);
  52. void unregister_cluster_simple_governor_ops(struct simple_cluster_governor *ops);
  53. void remove_simple_cluster_sysfs_nodes(struct simple_lpm_cluster *simple_cluster_gov);
  54. int create_simple_cluster_sysfs_nodes(struct simple_lpm_cluster *simple_cluster_gov);
  55. int qcom_cluster_lpm_simple_governor_init(void);
  56. void qcom_cluster_lpm_simple_governor_deinit(void);
  57. #endif /* __QCOM_SIMPLE_LPM_H__ */