aux_engine.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright 2012-15 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: AMD
  23. *
  24. */
  25. #ifndef __DAL_AUX_ENGINE_H__
  26. #define __DAL_AUX_ENGINE_H__
  27. enum aux_transaction_type {
  28. AUX_TRANSACTION_TYPE_DP,
  29. AUX_TRANSACTION_TYPE_I2C
  30. };
  31. struct aux_request_transaction_data {
  32. enum aux_transaction_type type;
  33. enum i2caux_transaction_action action;
  34. /* 20-bit AUX channel transaction address */
  35. uint32_t address;
  36. /* delay, in 100-microsecond units */
  37. uint8_t delay;
  38. uint32_t length;
  39. uint8_t *data;
  40. };
  41. enum aux_transaction_reply {
  42. AUX_TRANSACTION_REPLY_AUX_ACK = 0x00,
  43. AUX_TRANSACTION_REPLY_AUX_NACK = 0x01,
  44. AUX_TRANSACTION_REPLY_AUX_DEFER = 0x02,
  45. AUX_TRANSACTION_REPLY_I2C_ACK = 0x00,
  46. AUX_TRANSACTION_REPLY_I2C_NACK = 0x10,
  47. AUX_TRANSACTION_REPLY_I2C_DEFER = 0x20,
  48. AUX_TRANSACTION_REPLY_INVALID = 0xFF
  49. };
  50. struct aux_reply_transaction_data {
  51. enum aux_transaction_reply status;
  52. uint32_t length;
  53. uint8_t *data;
  54. };
  55. enum aux_channel_operation_result {
  56. AUX_CHANNEL_OPERATION_SUCCEEDED,
  57. AUX_CHANNEL_OPERATION_FAILED_REASON_UNKNOWN,
  58. AUX_CHANNEL_OPERATION_FAILED_INVALID_REPLY,
  59. AUX_CHANNEL_OPERATION_FAILED_TIMEOUT
  60. };
  61. struct aux_engine;
  62. struct aux_engine_funcs {
  63. void (*destroy)(
  64. struct aux_engine **ptr);
  65. bool (*acquire_engine)(
  66. struct aux_engine *engine);
  67. void (*configure)(
  68. struct aux_engine *engine,
  69. union aux_config cfg);
  70. void (*submit_channel_request)(
  71. struct aux_engine *engine,
  72. struct aux_request_transaction_data *request);
  73. void (*process_channel_reply)(
  74. struct aux_engine *engine,
  75. struct aux_reply_transaction_data *reply);
  76. enum aux_channel_operation_result (*get_channel_status)(
  77. struct aux_engine *engine,
  78. uint8_t *returned_bytes);
  79. bool (*is_engine_available) (
  80. struct aux_engine *engine);
  81. };
  82. struct aux_engine {
  83. struct engine base;
  84. const struct aux_engine_funcs *funcs;
  85. /* following values are expressed in milliseconds */
  86. uint32_t delay;
  87. uint32_t max_defer_write_retry;
  88. bool acquire_reset;
  89. };
  90. void dal_aux_engine_construct(
  91. struct aux_engine *engine,
  92. struct dc_context *ctx);
  93. void dal_aux_engine_destruct(
  94. struct aux_engine *engine);
  95. bool dal_aux_engine_submit_request(
  96. struct engine *ptr,
  97. struct i2caux_transaction_request *request,
  98. bool middle_of_transaction);
  99. bool dal_aux_engine_acquire(
  100. struct engine *ptr,
  101. struct ddc *ddc);
  102. enum i2caux_engine_type dal_aux_engine_get_engine_type(
  103. const struct engine *engine);
  104. #endif