2 * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
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 (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Zhiyuan Lv <zhiyuan.lv@intel.com>
28 * Terrence Xu <terrence.xu@intel.com>
29 * Changbin Du <changbin.du@intel.com>
30 * Bing Niu <bing.niu@intel.com>
31 * Zhi Wang <zhi.a.wang@intel.com>
39 #define EDID_ADDR 0x50 /* Linux hvm EDID addr */
41 #define GVT_AUX_NATIVE_WRITE 0x8
42 #define GVT_AUX_NATIVE_READ 0x9
43 #define GVT_AUX_I2C_WRITE 0x0
44 #define GVT_AUX_I2C_READ 0x1
45 #define GVT_AUX_I2C_STATUS 0x2
46 #define GVT_AUX_I2C_MOT 0x4
47 #define GVT_AUX_I2C_REPLY_ACK 0x0
49 struct intel_vgpu_edid_data
{
51 unsigned char edid_block
[EDID_SIZE
];
54 enum gmbus_cycle_type
{
66 * GMBUS0-3 could be related to the EDID virtualization. Another two GMBUS
67 * registers, GMBUS4 (interrupt mask) and GMBUS5 (2 byte indes register), are
68 * not considered here. Below describes the usage of GMBUS registers that are
69 * cared by the EDID virtualization
73 * port selection. value of bit0 - bit2 corresponds to the GPIO registers.
78 * bit0 is the direction bit: 1 is read; 0 is write.
79 * bit1 - bit7 is slave 7-bit address.
80 * bit16 - bit24 total byte count (ignore?)
83 * Most of bits are read only except bit 15 (IN_USE)
85 * bit0 - bit8 current byte count
86 * bit 11: hardware ready;
93 /* From hw specs, Other phases like START, ADDRESS, INDEX
94 * are invisible to GMBUS MMIO interface. So no definitions
97 enum gvt_gmbus_phase
{
105 struct intel_vgpu_i2c_gmbus
{
106 unsigned int total_byte_count
; /* from GMBUS1 */
107 enum gmbus_cycle_type cycle_type
;
108 enum gvt_gmbus_phase phase
;
111 struct intel_vgpu_i2c_aux_ch
{
112 bool i2c_over_aux_ch
;
117 I2C_NOT_SPECIFIED
= 0,
122 /* I2C sequences cannot interleave.
123 * GMBUS and AUX_CH sequences cannot interleave.
125 struct intel_vgpu_i2c_edid
{
126 enum i2c_state state
;
131 unsigned int current_edid_read
;
133 struct intel_vgpu_i2c_gmbus gmbus
;
134 struct intel_vgpu_i2c_aux_ch aux_ch
;
137 void intel_vgpu_init_i2c_edid(struct intel_vgpu
*vgpu
);
139 int intel_gvt_i2c_handle_gmbus_read(struct intel_vgpu
*vgpu
,
140 unsigned int offset
, void *p_data
, unsigned int bytes
);
142 int intel_gvt_i2c_handle_gmbus_write(struct intel_vgpu
*vgpu
,
143 unsigned int offset
, void *p_data
, unsigned int bytes
);
145 void intel_gvt_i2c_handle_aux_ch_write(struct intel_vgpu
*vgpu
,
150 #endif /*_GVT_EDID_H_*/