icc-rpmh.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __DRIVERS_INTERCONNECT_QCOM_ICC_RPMH_H__
  6. #define __DRIVERS_INTERCONNECT_QCOM_ICC_RPMH_H__
  7. #include <dt-bindings/interconnect/qcom,icc.h>
  8. #define to_qcom_provider(_provider) \
  9. container_of(_provider, struct qcom_icc_provider, provider)
  10. /**
  11. * struct qcom_icc_provider - Qualcomm specific interconnect provider
  12. * @provider: generic interconnect provider
  13. * @dev: reference to the NoC device
  14. * @bcms: list of bcms that maps to the provider
  15. * @num_bcms: number of @bcms
  16. * @voter: bcm voter targeted by this provider
  17. */
  18. struct qcom_icc_provider {
  19. struct icc_provider provider;
  20. struct device *dev;
  21. struct qcom_icc_bcm **bcms;
  22. size_t num_bcms;
  23. struct bcm_voter *voter;
  24. };
  25. /**
  26. * struct bcm_db - Auxiliary data pertaining to each Bus Clock Manager (BCM)
  27. * @unit: divisor used to convert bytes/sec bw value to an RPMh msg
  28. * @width: multiplier used to convert bytes/sec bw value to an RPMh msg
  29. * @vcd: virtual clock domain that this bcm belongs to
  30. * @reserved: reserved field
  31. */
  32. struct bcm_db {
  33. __le32 unit;
  34. __le16 width;
  35. u8 vcd;
  36. u8 reserved;
  37. };
  38. #define MAX_LINKS 128
  39. #define MAX_BCMS 64
  40. #define MAX_BCM_PER_NODE 3
  41. #define MAX_VCD 10
  42. /**
  43. * struct qcom_icc_node - Qualcomm specific interconnect nodes
  44. * @name: the node name used in debugfs
  45. * @links: an array of nodes where we can go next while traversing
  46. * @id: a unique node identifier
  47. * @num_links: the total number of @links
  48. * @channels: num of channels at this node
  49. * @buswidth: width of the interconnect between a node and the bus
  50. * @sum_avg: current sum aggregate value of all avg bw requests
  51. * @max_peak: current max aggregate value of all peak bw requests
  52. * @bcms: list of bcms associated with this logical node
  53. * @num_bcms: num of @bcms
  54. */
  55. struct qcom_icc_node {
  56. const char *name;
  57. u16 links[MAX_LINKS];
  58. u16 id;
  59. u16 num_links;
  60. u16 channels;
  61. u16 buswidth;
  62. u64 sum_avg[QCOM_ICC_NUM_BUCKETS];
  63. u64 max_peak[QCOM_ICC_NUM_BUCKETS];
  64. struct qcom_icc_bcm *bcms[MAX_BCM_PER_NODE];
  65. size_t num_bcms;
  66. };
  67. /**
  68. * struct qcom_icc_bcm - Qualcomm specific hardware accelerator nodes
  69. * known as Bus Clock Manager (BCM)
  70. * @name: the bcm node name used to fetch BCM data from command db
  71. * @type: latency or bandwidth bcm
  72. * @addr: address offsets used when voting to RPMH
  73. * @vote_x: aggregated threshold values, represents sum_bw when @type is bw bcm
  74. * @vote_y: aggregated threshold values, represents peak_bw when @type is bw bcm
  75. * @vote_scale: scaling factor for vote_x and vote_y
  76. * @dirty: flag used to indicate whether the bcm needs to be committed
  77. * @keepalive: flag used to indicate whether a keepalive is required
  78. * @aux_data: auxiliary data used when calculating threshold values and
  79. * communicating with RPMh
  80. * @list: used to link to other bcms when compiling lists for commit
  81. * @ws_list: used to keep track of bcms that may transition between wake/sleep
  82. * @num_nodes: total number of @num_nodes
  83. * @nodes: list of qcom_icc_nodes that this BCM encapsulates
  84. */
  85. struct qcom_icc_bcm {
  86. const char *name;
  87. u32 type;
  88. u32 addr;
  89. u64 vote_x[QCOM_ICC_NUM_BUCKETS];
  90. u64 vote_y[QCOM_ICC_NUM_BUCKETS];
  91. u64 vote_scale;
  92. bool dirty;
  93. bool keepalive;
  94. struct bcm_db aux_data;
  95. struct list_head list;
  96. struct list_head ws_list;
  97. size_t num_nodes;
  98. struct qcom_icc_node *nodes[];
  99. };
  100. struct qcom_icc_fabric {
  101. struct qcom_icc_node **nodes;
  102. size_t num_nodes;
  103. };
  104. struct qcom_icc_desc {
  105. struct qcom_icc_node **nodes;
  106. size_t num_nodes;
  107. struct qcom_icc_bcm **bcms;
  108. size_t num_bcms;
  109. };
  110. #define DEFINE_QNODE(_name, _id, _channels, _buswidth, ...) \
  111. static struct qcom_icc_node _name = { \
  112. .id = _id, \
  113. .name = #_name, \
  114. .channels = _channels, \
  115. .buswidth = _buswidth, \
  116. .num_links = ARRAY_SIZE(((int[]){ __VA_ARGS__ })), \
  117. .links = { __VA_ARGS__ }, \
  118. }
  119. int qcom_icc_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
  120. u32 peak_bw, u32 *agg_avg, u32 *agg_peak);
  121. int qcom_icc_set(struct icc_node *src, struct icc_node *dst);
  122. struct icc_node_data *qcom_icc_xlate_extended(struct of_phandle_args *spec, void *data);
  123. int qcom_icc_bcm_init(struct qcom_icc_bcm *bcm, struct device *dev);
  124. void qcom_icc_pre_aggregate(struct icc_node *node);
  125. #endif