llcc-sdm845.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
  4. *
  5. */
  6. #include <linux/kernel.h>
  7. #include <linux/module.h>
  8. #include <linux/of.h>
  9. #include <linux/of_device.h>
  10. #include <linux/soc/qcom/llcc-qcom.h>
  11. /*
  12. * SCT(System Cache Table) entry contains of the following members:
  13. * usecase_id: Unique id for the client's use case
  14. * slice_id: llcc slice id for each client
  15. * max_cap: The maximum capacity of the cache slice provided in KB
  16. * priority: Priority of the client used to select victim line for replacement
  17. * fixed_size: Boolean indicating if the slice has a fixed capacity
  18. * bonus_ways: Bonus ways are additional ways to be used for any slice,
  19. * if client ends up using more than reserved cache ways. Bonus
  20. * ways are allocated only if they are not reserved for some
  21. * other client.
  22. * res_ways: Reserved ways for the cache slice, the reserved ways cannot
  23. * be used by any other client than the one its assigned to.
  24. * cache_mode: Each slice operates as a cache, this controls the mode of the
  25. * slice: normal or TCM(Tightly Coupled Memory)
  26. * probe_target_ways: Determines what ways to probe for access hit. When
  27. * configured to 1 only bonus and reserved ways are probed.
  28. * When configured to 0 all ways in llcc are probed.
  29. * dis_cap_alloc: Disable capacity based allocation for a client
  30. * retain_on_pc: If this bit is set and client has maintained active vote
  31. * then the ways assigned to this client are not flushed on power
  32. * collapse.
  33. * activate_on_init: Activate the slice immediately after the SCT is programmed
  34. */
  35. #define SCT_ENTRY(uid, sid, mc, p, fs, bway, rway, cmod, ptw, dca, rp, a) \
  36. { \
  37. .usecase_id = uid, \
  38. .slice_id = sid, \
  39. .max_cap = mc, \
  40. .priority = p, \
  41. .fixed_size = fs, \
  42. .bonus_ways = bway, \
  43. .res_ways = rway, \
  44. .cache_mode = cmod, \
  45. .probe_target_ways = ptw, \
  46. .dis_cap_alloc = dca, \
  47. .retain_on_pc = rp, \
  48. .activate_on_init = a, \
  49. }
  50. static struct llcc_slice_config sdm845_data[] = {
  51. SCT_ENTRY(LLCC_CPUSS, 1, 2816, 1, 0, 0xffc, 0x2, 0, 0, 1, 1, 1),
  52. SCT_ENTRY(LLCC_VIDSC0, 2, 512, 2, 1, 0x0, 0x0f0, 0, 0, 1, 1, 0),
  53. SCT_ENTRY(LLCC_VIDSC1, 3, 512, 2, 1, 0x0, 0x0f0, 0, 0, 1, 1, 0),
  54. SCT_ENTRY(LLCC_ROTATOR, 4, 563, 2, 1, 0x0, 0x00e, 2, 0, 1, 1, 0),
  55. SCT_ENTRY(LLCC_VOICE, 5, 2816, 1, 0, 0xffc, 0x2, 0, 0, 1, 1, 0),
  56. SCT_ENTRY(LLCC_AUDIO, 6, 2816, 1, 0, 0xffc, 0x2, 0, 0, 1, 1, 0),
  57. SCT_ENTRY(LLCC_MDMHPGRW, 7, 1024, 2, 0, 0xfc, 0xf00, 0, 0, 1, 1, 0),
  58. SCT_ENTRY(LLCC_MDM, 8, 2816, 1, 0, 0xffc, 0x2, 0, 0, 1, 1, 0),
  59. SCT_ENTRY(LLCC_CMPT, 10, 2816, 1, 0, 0xffc, 0x2, 0, 0, 1, 1, 0),
  60. SCT_ENTRY(LLCC_GPUHTW, 11, 512, 1, 1, 0xc, 0x0, 0, 0, 1, 1, 0),
  61. SCT_ENTRY(LLCC_GPU, 12, 2304, 1, 0, 0xff0, 0x2, 0, 0, 1, 1, 0),
  62. SCT_ENTRY(LLCC_MMUHWT, 13, 256, 2, 0, 0x0, 0x1, 0, 0, 1, 0, 1),
  63. SCT_ENTRY(LLCC_CMPTDMA, 15, 2816, 1, 0, 0xffc, 0x2, 0, 0, 1, 1, 0),
  64. SCT_ENTRY(LLCC_DISP, 16, 2816, 1, 0, 0xffc, 0x2, 0, 0, 1, 1, 0),
  65. SCT_ENTRY(LLCC_VIDFW, 17, 2816, 1, 0, 0xffc, 0x2, 0, 0, 1, 1, 0),
  66. SCT_ENTRY(LLCC_MDMHPFX, 20, 1024, 2, 1, 0x0, 0xf00, 0, 0, 1, 1, 0),
  67. SCT_ENTRY(LLCC_MDMPNG, 21, 1024, 0, 1, 0x1e, 0x0, 0, 0, 1, 1, 0),
  68. SCT_ENTRY(LLCC_AUDHW, 22, 1024, 1, 1, 0xffc, 0x2, 0, 0, 1, 1, 0),
  69. };
  70. static int sdm845_qcom_llcc_remove(struct platform_device *pdev)
  71. {
  72. return qcom_llcc_remove(pdev);
  73. }
  74. static int sdm845_qcom_llcc_probe(struct platform_device *pdev)
  75. {
  76. return qcom_llcc_probe(pdev, sdm845_data, ARRAY_SIZE(sdm845_data));
  77. }
  78. static const struct of_device_id sdm845_qcom_llcc_of_match[] = {
  79. { .compatible = "qcom,sdm845-llcc", },
  80. { }
  81. };
  82. static struct platform_driver sdm845_qcom_llcc_driver = {
  83. .driver = {
  84. .name = "sdm845-llcc",
  85. .of_match_table = sdm845_qcom_llcc_of_match,
  86. },
  87. .probe = sdm845_qcom_llcc_probe,
  88. .remove = sdm845_qcom_llcc_remove,
  89. };
  90. module_platform_driver(sdm845_qcom_llcc_driver);
  91. MODULE_DESCRIPTION("QCOM sdm845 LLCC driver");
  92. MODULE_LICENSE("GPL v2");