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>
38 #include <linux/types.h>
43 #define EDID_ADDR 0x50 /* Linux hvm EDID addr */
45 #define GVT_AUX_NATIVE_WRITE 0x8
46 #define GVT_AUX_NATIVE_READ 0x9
47 #define GVT_AUX_I2C_WRITE 0x0
48 #define GVT_AUX_I2C_READ 0x1
49 #define GVT_AUX_I2C_STATUS 0x2
50 #define GVT_AUX_I2C_MOT 0x4
51 #define GVT_AUX_I2C_REPLY_ACK 0x0
53 struct intel_vgpu_edid_data
{
55 unsigned char edid_block
[EDID_SIZE
];
58 enum gmbus_cycle_type
{
70 * GMBUS0-3 could be related to the EDID virtualization. Another two GMBUS
71 * registers, GMBUS4 (interrupt mask) and GMBUS5 (2 byte indes register), are
72 * not considered here. Below describes the usage of GMBUS registers that are
73 * cared by the EDID virtualization
77 * port selection. value of bit0 - bit2 corresponds to the GPIO registers.
82 * bit0 is the direction bit: 1 is read; 0 is write.
83 * bit1 - bit7 is slave 7-bit address.
84 * bit16 - bit24 total byte count (ignore?)
87 * Most of bits are read only except bit 15 (IN_USE)
89 * bit0 - bit8 current byte count
90 * bit 11: hardware ready;
97 /* From hw specs, Other phases like START, ADDRESS, INDEX
98 * are invisible to GMBUS MMIO interface. So no definitions
101 enum gvt_gmbus_phase
{
102 GMBUS_IDLE_PHASE
= 0,
109 struct intel_vgpu_i2c_gmbus
{
110 unsigned int total_byte_count
; /* from GMBUS1 */
111 enum gmbus_cycle_type cycle_type
;
112 enum gvt_gmbus_phase phase
;
115 struct intel_vgpu_i2c_aux_ch
{
116 bool i2c_over_aux_ch
;
121 I2C_NOT_SPECIFIED
= 0,
126 /* I2C sequences cannot interleave.
127 * GMBUS and AUX_CH sequences cannot interleave.
129 struct intel_vgpu_i2c_edid
{
130 enum i2c_state state
;
135 unsigned int current_edid_read
;
137 struct intel_vgpu_i2c_gmbus gmbus
;
138 struct intel_vgpu_i2c_aux_ch aux_ch
;
141 void intel_vgpu_init_i2c_edid(struct intel_vgpu
*vgpu
);
143 int intel_gvt_i2c_handle_gmbus_read(struct intel_vgpu
*vgpu
,
144 unsigned int offset
, void *p_data
, unsigned int bytes
);
146 int intel_gvt_i2c_handle_gmbus_write(struct intel_vgpu
*vgpu
,
147 unsigned int offset
, void *p_data
, unsigned int bytes
);
149 void intel_gvt_i2c_handle_aux_ch_write(struct intel_vgpu
*vgpu
,
154 #endif /*_GVT_EDID_H_*/