Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amd/display: Add I2C escape to support query device exist.

[How]
1. Search OEM I2C info from BIOS and compare with input parameter.
2. If BIOS doesn't record it, just try to read one byte.

Reviewed-by: Aric Cyr <Aric.Cyr@amd.com>
Acked-by: Agustin Gutierrez <agustin.gutierrez@amd.com>
Signed-off-by: JinZe.Xu <JinZe.Xu@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

JinZe.Xu and committed by
Alex Deucher
a0248d54 436afdfa

+50
+13
drivers/gpu/drm/amd/display/dc/core/dc.c
··· 3363 3363 return false; 3364 3364 } 3365 3365 3366 + bool dc_is_oem_i2c_device_present( 3367 + struct dc *dc, 3368 + size_t slave_address) 3369 + { 3370 + if (dc->res_pool->oem_device) 3371 + return dce_i2c_oem_device_present( 3372 + dc->res_pool, 3373 + dc->res_pool->oem_device, 3374 + slave_address); 3375 + 3376 + return false; 3377 + } 3378 + 3366 3379 bool dc_submit_i2c( 3367 3380 struct dc *dc, 3368 3381 uint32_t link_index,
+5
drivers/gpu/drm/amd/display/dc/dc_link.h
··· 466 466 void dc_link_overwrite_extended_receiver_cap( 467 467 struct dc_link *link); 468 468 469 + bool dc_is_oem_i2c_device_present( 470 + struct dc *dc, 471 + size_t slave_address 472 + ); 473 + 469 474 bool dc_submit_i2c( 470 475 struct dc *dc, 471 476 uint32_t link_index,
+26
drivers/gpu/drm/amd/display/dc/dce/dce_i2c.c
··· 25 25 #include "dce_i2c.h" 26 26 #include "reg_helper.h" 27 27 28 + bool dce_i2c_oem_device_present( 29 + struct resource_pool *pool, 30 + struct ddc_service *ddc, 31 + size_t slave_address 32 + ) 33 + { 34 + struct dc *dc = ddc->ctx->dc; 35 + struct dc_bios *dcb = dc->ctx->dc_bios; 36 + struct graphics_object_id id = {0}; 37 + struct graphics_object_i2c_info i2c_info; 38 + 39 + if (!dc->ctx->dc_bios->fw_info.oem_i2c_present) 40 + return false; 41 + 42 + id.id = dc->ctx->dc_bios->fw_info.oem_i2c_obj_id; 43 + id.enum_id = 0; 44 + id.type = OBJECT_TYPE_GENERIC; 45 + if (dcb->funcs->get_i2c_info(dcb, id, &i2c_info) != BP_RESULT_OK) 46 + return false; 47 + 48 + if (i2c_info.i2c_slave_address != slave_address) 49 + return false; 50 + 51 + return true; 52 + } 53 + 28 54 bool dce_i2c_submit_command( 29 55 struct resource_pool *pool, 30 56 struct ddc *ddc,
+6
drivers/gpu/drm/amd/display/dc/dce/dce_i2c.h
··· 30 30 #include "dce_i2c_hw.h" 31 31 #include "dce_i2c_sw.h" 32 32 33 + bool dce_i2c_oem_device_present( 34 + struct resource_pool *pool, 35 + struct ddc_service *ddc, 36 + size_t slave_address 37 + ); 38 + 33 39 bool dce_i2c_submit_command( 34 40 struct resource_pool *pool, 35 41 struct ddc *ddc,