qnoc-qos.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  4. *
  5. */
  6. #include <linux/interconnect.h>
  7. #include <linux/interconnect-provider.h>
  8. #include <linux/module.h>
  9. #include "icc-rpmh.h"
  10. #include "qnoc-qos.h"
  11. #define QOSGEN_MAINCTL_LO(p, qp) ((p)->offsets[qp] + \
  12. (p)->regs[QOSGEN_OFF_MAINCTL_LO])
  13. #define QOS_SLV_URG_MSG_EN_SHFT 3
  14. # define QOS_DFLT_PRIO_MASK 0x7
  15. # define QOS_DFLT_PRIO_SHFT 4
  16. #define QOS_DISABLE_SHIFT 24
  17. const u8 icc_qnoc_qos_regs[][QOSGEN_OFF_MAX_REGS] = {
  18. [ICC_QNOC_QOSGEN_TYPE_RPMH] = {
  19. [QOSGEN_OFF_MAINCTL_LO] = 0x8,
  20. [QOSGEN_OFF_LIMITBW_LO] = 0x18,
  21. [QOSGEN_OFF_SHAPING_LO] = 0x20,
  22. [QOSGEN_OFF_SHAPING_HI] = 0x24,
  23. [QOSGEN_OFF_REGUL0CTL_LO] = 0x40,
  24. [QOSGEN_OFF_REGUL0BW_LO] = 0x48,
  25. },
  26. };
  27. EXPORT_SYMBOL(icc_qnoc_qos_regs);
  28. /**
  29. * qcom_icc_set_qos - initialize static QoS configurations
  30. * @node: qcom icc node to operate on
  31. */
  32. static void qcom_icc_set_qos(struct qcom_icc_node *node)
  33. {
  34. struct qcom_icc_qosbox *qos = node->qosbox;
  35. int port;
  36. if (!node->regmap)
  37. return;
  38. if (!qos)
  39. return;
  40. for (port = 0; port < qos->num_ports; port++) {
  41. regmap_update_bits(node->regmap, QOSGEN_MAINCTL_LO(qos, port),
  42. BIT(QOS_DISABLE_SHIFT),
  43. qos->config->prio_fwd_disable << QOS_DISABLE_SHIFT);
  44. regmap_update_bits(node->regmap, QOSGEN_MAINCTL_LO(qos, port),
  45. QOS_DFLT_PRIO_MASK << QOS_DFLT_PRIO_SHFT,
  46. qos->config->prio << QOS_DFLT_PRIO_SHFT);
  47. regmap_update_bits(node->regmap, QOSGEN_MAINCTL_LO(qos, port),
  48. BIT(QOS_SLV_URG_MSG_EN_SHFT),
  49. qos->config->urg_fwd << QOS_SLV_URG_MSG_EN_SHFT);
  50. }
  51. }
  52. const struct qcom_icc_noc_ops qcom_qnoc4_ops = {
  53. .set_qos = qcom_icc_set_qos,
  54. };
  55. EXPORT_SYMBOL(qcom_qnoc4_ops);
  56. MODULE_LICENSE("GPL v2");