2 * Copyright 2012-15 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
26 #ifndef __DAL_AUX_ENGINE_H__
27 #define __DAL_AUX_ENGINE_H__
29 enum aux_transaction_type {
30 AUX_TRANSACTION_TYPE_DP,
31 AUX_TRANSACTION_TYPE_I2C
34 struct aux_request_transaction_data {
35 enum aux_transaction_type type;
36 enum i2caux_transaction_action action;
37 /* 20-bit AUX channel transaction address */
39 /* delay, in 100-microsecond units */
45 enum aux_transaction_reply {
46 AUX_TRANSACTION_REPLY_AUX_ACK = 0x00,
47 AUX_TRANSACTION_REPLY_AUX_NACK = 0x01,
48 AUX_TRANSACTION_REPLY_AUX_DEFER = 0x02,
50 AUX_TRANSACTION_REPLY_I2C_ACK = 0x00,
51 AUX_TRANSACTION_REPLY_I2C_NACK = 0x10,
52 AUX_TRANSACTION_REPLY_I2C_DEFER = 0x20,
54 AUX_TRANSACTION_REPLY_INVALID = 0xFF
57 struct aux_reply_transaction_data {
58 enum aux_transaction_reply status;
63 enum aux_channel_operation_result {
64 AUX_CHANNEL_OPERATION_SUCCEEDED,
65 AUX_CHANNEL_OPERATION_FAILED_REASON_UNKNOWN,
66 AUX_CHANNEL_OPERATION_FAILED_INVALID_REPLY,
67 AUX_CHANNEL_OPERATION_FAILED_TIMEOUT
72 struct aux_engine_funcs {
74 struct aux_engine **ptr);
75 bool (*acquire_engine)(
76 struct aux_engine *engine);
78 struct aux_engine *engine,
79 union aux_config cfg);
80 void (*submit_channel_request)(
81 struct aux_engine *engine,
82 struct aux_request_transaction_data *request);
83 void (*process_channel_reply)(
84 struct aux_engine *engine,
85 struct aux_reply_transaction_data *reply);
86 enum aux_channel_operation_result (*get_channel_status)(
87 struct aux_engine *engine,
88 uint8_t *returned_bytes);
89 bool (*is_engine_available) (
90 struct aux_engine *engine);
95 const struct aux_engine_funcs *funcs;
96 /* following values are expressed in milliseconds */
98 uint32_t max_defer_write_retry;
103 void dal_aux_engine_construct(
104 struct aux_engine *engine,
105 struct dc_context *ctx);
107 void dal_aux_engine_destruct(
108 struct aux_engine *engine);
109 bool dal_aux_engine_submit_request(
111 struct i2caux_transaction_request *request,
112 bool middle_of_transaction);
113 bool dal_aux_engine_acquire(
116 enum i2caux_engine_type dal_aux_engine_get_engine_type(
117 const struct engine *engine);