tcs.h 2.5 KB

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