tcs.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __SOC_QCOM_TCS_H__
  6. #define __SOC_QCOM_TCS_H__
  7. #define MAX_RPMH_PAYLOAD 16
  8. /**
  9. * rpmh_state: state for the request
  10. *
  11. * RPMH_SLEEP_STATE: State of the resource when the processor subsystem
  12. * is powered down. There is no client using the
  13. * resource actively.
  14. * RPMH_WAKE_ONLY_STATE: Resume resource state to the value previously
  15. * requested before the processor was powered down.
  16. * RPMH_ACTIVE_ONLY_STATE: Active or AMC mode requests. Resource state
  17. * is aggregated immediately.
  18. */
  19. enum rpmh_state {
  20. RPMH_SLEEP_STATE,
  21. RPMH_WAKE_ONLY_STATE,
  22. RPMH_ACTIVE_ONLY_STATE,
  23. };
  24. /**
  25. * struct tcs_cmd: an individual request to RPMH.
  26. *
  27. * @addr: the address of the resource slv_id:18:16 | offset:0:15
  28. * @data: the resource state request
  29. * @wait: ensure that this command is complete before returning.
  30. * Setting "wait" here only makes sense during rpmh_write_batch() for
  31. * active-only transfers, this is because:
  32. * rpmh_write() - Always waits.
  33. * (DEFINE_RPMH_MSG_ONSTACK will set .wait_for_compl)
  34. * rpmh_write_async() - Never waits.
  35. * (There's no request completion callback)
  36. */
  37. struct tcs_cmd {
  38. u32 addr;
  39. u32 data;
  40. u32 wait;
  41. };
  42. /**
  43. * struct tcs_request: A set of tcs_cmds sent together in a TCS
  44. *
  45. * @state: state for the request.
  46. * @wait_for_compl: wait until we get a response from the h/w accelerator
  47. * (same as setting cmd->wait for all commands in the request)
  48. * @num_cmds: the number of @cmds in this request
  49. * @cmds: an array of tcs_cmds
  50. */
  51. struct tcs_request {
  52. enum rpmh_state state;
  53. u32 wait_for_compl;
  54. u32 num_cmds;
  55. struct tcs_cmd *cmds;
  56. };
  57. #define BCM_TCS_CMD_COMMIT_SHFT 30
  58. #define BCM_TCS_CMD_COMMIT_MASK 0x40000000
  59. #define BCM_TCS_CMD_VALID_SHFT 29
  60. #define BCM_TCS_CMD_VALID_MASK 0x20000000
  61. #define BCM_TCS_CMD_VOTE_X_SHFT 14
  62. #define BCM_TCS_CMD_VOTE_MASK 0x3fff
  63. #define BCM_TCS_CMD_VOTE_Y_SHFT 0
  64. #define BCM_TCS_CMD_VOTE_Y_MASK 0xfffc000
  65. /* Construct a Bus Clock Manager (BCM) specific TCS command */
  66. #define BCM_TCS_CMD(commit, valid, vote_x, vote_y) \
  67. (((commit) << BCM_TCS_CMD_COMMIT_SHFT) | \
  68. ((valid) << BCM_TCS_CMD_VALID_SHFT) | \
  69. ((cpu_to_le32(vote_x) & \
  70. BCM_TCS_CMD_VOTE_MASK) << BCM_TCS_CMD_VOTE_X_SHFT) | \
  71. ((cpu_to_le32(vote_y) & \
  72. BCM_TCS_CMD_VOTE_MASK) << BCM_TCS_CMD_VOTE_Y_SHFT))
  73. #endif /* __SOC_QCOM_TCS_H__ */