i2caux.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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_I2C_AUX_H__
  26. #define __DAL_I2C_AUX_H__
  27. uint32_t dal_i2caux_get_reference_clock(
  28. struct dc_bios *bios);
  29. struct i2caux;
  30. struct engine;
  31. struct i2caux_funcs {
  32. void (*destroy)(struct i2caux **ptr);
  33. struct i2c_engine * (*acquire_i2c_sw_engine)(
  34. struct i2caux *i2caux,
  35. struct ddc *ddc);
  36. struct i2c_engine * (*acquire_i2c_hw_engine)(
  37. struct i2caux *i2caux,
  38. struct ddc *ddc);
  39. struct aux_engine * (*acquire_aux_engine)(
  40. struct i2caux *i2caux,
  41. struct ddc *ddc);
  42. void (*release_engine)(
  43. struct i2caux *i2caux,
  44. struct engine *engine);
  45. };
  46. struct i2c_engine;
  47. struct aux_engine;
  48. struct i2caux {
  49. struct dc_context *ctx;
  50. const struct i2caux_funcs *funcs;
  51. /* On ASIC we have certain amount of lines with HW DDC engine
  52. * (4, 6, or maybe more in the future).
  53. * For every such line, we create separate HW DDC engine
  54. * (since we have these engines in HW) and separate SW DDC engine
  55. * (to allow concurrent use of few lines).
  56. * In similar way we have AUX engines. */
  57. /* I2C SW engines, per DDC line.
  58. * Only lines with HW DDC support will be initialized */
  59. struct i2c_engine *i2c_sw_engines[GPIO_DDC_LINE_COUNT];
  60. /* I2C HW engines, per DDC line.
  61. * Only lines with HW DDC support will be initialized */
  62. struct i2c_engine *i2c_hw_engines[GPIO_DDC_LINE_COUNT];
  63. /* AUX engines, per DDC line.
  64. * Only lines with HW AUX support will be initialized */
  65. struct aux_engine *aux_engines[GPIO_DDC_LINE_COUNT];
  66. /* For all other lines, we can use
  67. * single instance of generic I2C HW engine
  68. * (since in HW, there is single instance of it)
  69. * or single instance of generic I2C SW engine.
  70. * AUX is not supported for other lines. */
  71. /* General-purpose I2C SW engine.
  72. * Can be assigned dynamically to any line per transaction */
  73. struct i2c_engine *i2c_generic_sw_engine;
  74. /* General-purpose I2C generic HW engine.
  75. * Can be assigned dynamically to almost any line per transaction */
  76. struct i2c_engine *i2c_generic_hw_engine;
  77. /* [anaumov] in DAL2, there is a Mutex */
  78. uint32_t aux_timeout_period;
  79. /* expressed in KHz */
  80. uint32_t default_i2c_sw_speed;
  81. uint32_t default_i2c_hw_speed;
  82. };
  83. void dal_i2caux_construct(
  84. struct i2caux *i2caux,
  85. struct dc_context *ctx);
  86. void dal_i2caux_release_engine(
  87. struct i2caux *i2caux,
  88. struct engine *engine);
  89. void dal_i2caux_destruct(
  90. struct i2caux *i2caux);
  91. void dal_i2caux_destroy(
  92. struct i2caux **ptr);
  93. struct i2c_engine *dal_i2caux_acquire_i2c_sw_engine(
  94. struct i2caux *i2caux,
  95. struct ddc *ddc);
  96. struct aux_engine *dal_i2caux_acquire_aux_engine(
  97. struct i2caux *i2caux,
  98. struct ddc *ddc);
  99. #endif