Merge remote-tracking branches 'asoc/fix/rt5663', 'asoc/fix/tlv320aic31xx' and 'asoc...
[linux-2.6-microblaze.git] / drivers / gpu / drm / amd / display / dc / i2caux / aux_engine.h
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
26 #ifndef __DAL_AUX_ENGINE_H__
27 #define __DAL_AUX_ENGINE_H__
28
29 enum aux_transaction_type {
30         AUX_TRANSACTION_TYPE_DP,
31         AUX_TRANSACTION_TYPE_I2C
32 };
33
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 */
38         uint32_t address;
39         /* delay, in 100-microsecond units */
40         uint8_t delay;
41         uint32_t length;
42         uint8_t *data;
43 };
44
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,
49
50         AUX_TRANSACTION_REPLY_I2C_ACK = 0x00,
51         AUX_TRANSACTION_REPLY_I2C_NACK = 0x10,
52         AUX_TRANSACTION_REPLY_I2C_DEFER = 0x20,
53
54         AUX_TRANSACTION_REPLY_INVALID = 0xFF
55 };
56
57 struct aux_reply_transaction_data {
58         enum aux_transaction_reply status;
59         uint32_t length;
60         uint8_t *data;
61 };
62
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
68 };
69
70 struct aux_engine;
71
72 struct aux_engine_funcs {
73         void (*destroy)(
74                 struct aux_engine **ptr);
75         bool (*acquire_engine)(
76                 struct aux_engine *engine);
77         void (*configure)(
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);
91 };
92
93 struct aux_engine {
94         struct engine base;
95         const struct aux_engine_funcs *funcs;
96         /* following values are expressed in milliseconds */
97         uint32_t delay;
98         uint32_t max_defer_write_retry;
99
100         bool acquire_reset;
101 };
102
103 void dal_aux_engine_construct(
104         struct aux_engine *engine,
105         struct dc_context *ctx);
106
107 void dal_aux_engine_destruct(
108         struct aux_engine *engine);
109 bool dal_aux_engine_submit_request(
110         struct engine *ptr,
111         struct i2caux_transaction_request *request,
112         bool middle_of_transaction);
113 bool dal_aux_engine_acquire(
114         struct engine *ptr,
115         struct ddc *ddc);
116 enum i2caux_engine_type dal_aux_engine_get_engine_type(
117         const struct engine *engine);
118
119 #endif