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_I2C_ENGINE_H__
27 #define __DAL_I2C_ENGINE_H__
29 enum i2c_channel_operation_result {
30 I2C_CHANNEL_OPERATION_SUCCEEDED,
31 I2C_CHANNEL_OPERATION_FAILED,
32 I2C_CHANNEL_OPERATION_NOT_GRANTED,
33 I2C_CHANNEL_OPERATION_IS_BUSY,
34 I2C_CHANNEL_OPERATION_NO_HANDLE_PROVIDED,
35 I2C_CHANNEL_OPERATION_CHANNEL_IN_USE,
36 I2C_CHANNEL_OPERATION_CHANNEL_CLIENT_MAX_ALLOWED,
37 I2C_CHANNEL_OPERATION_ENGINE_BUSY,
38 I2C_CHANNEL_OPERATION_TIMEOUT,
39 I2C_CHANNEL_OPERATION_NO_RESPONSE,
40 I2C_CHANNEL_OPERATION_HW_REQUEST_I2C_BUS,
41 I2C_CHANNEL_OPERATION_WRONG_PARAMETER,
42 I2C_CHANNEL_OPERATION_OUT_NB_OF_RETRIES,
43 I2C_CHANNEL_OPERATION_NOT_STARTED
46 struct i2c_request_transaction_data {
47 enum i2caux_transaction_action action;
48 enum i2c_channel_operation_result status;
54 struct i2c_reply_transaction_data {
61 struct i2c_engine_funcs {
63 struct i2c_engine **ptr);
64 uint32_t (*get_speed)(
65 const struct i2c_engine *engine);
67 struct i2c_engine *engine,
69 bool (*acquire_engine)(
70 struct i2c_engine *engine,
73 struct i2c_engine *engine);
74 void (*submit_channel_request)(
75 struct i2c_engine *engine,
76 struct i2c_request_transaction_data *request);
77 void (*process_channel_reply)(
78 struct i2c_engine *engine,
79 struct i2c_reply_transaction_data *reply);
80 enum i2c_channel_operation_result (*get_channel_status)(
81 struct i2c_engine *engine,
82 uint8_t *returned_bytes);
87 const struct i2c_engine_funcs *funcs;
88 uint32_t timeout_delay;
90 uint32_t send_reset_length;
93 void dal_i2c_engine_construct(
94 struct i2c_engine *engine,
95 struct dc_context *ctx);
97 void dal_i2c_engine_destruct(
98 struct i2c_engine *engine);
100 bool dal_i2c_engine_setup_i2c_engine(
101 struct i2c_engine *engine);
103 void dal_i2c_engine_submit_channel_request(
104 struct i2c_engine *engine,
105 struct i2c_request_transaction_data *request);
107 void dal_i2c_engine_process_channel_reply(
108 struct i2c_engine *engine,
109 struct i2c_reply_transaction_data *reply);
111 bool dal_i2c_engine_acquire(
113 struct ddc *ddc_handle);