Skip to content

Commit 3d5470c

Browse files
committed
drm/amd/display/dm: add support for OEM i2c bus
Expose the OEM i2c bus on boards that support it. This bus is used for OEM specific features like RGB, etc. Reviewed-by: Harry Wentland <harry.wentland@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent b217105 commit 3d5470c

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ static int amdgpu_dm_init(struct amdgpu_device *adev);
179179
static void amdgpu_dm_fini(struct amdgpu_device *adev);
180180
static bool is_freesync_video_mode(const struct drm_display_mode *mode, struct amdgpu_dm_connector *aconnector);
181181
static void reset_freesync_config_for_crtc(struct dm_crtc_state *new_crtc_state);
182+
static struct amdgpu_i2c_adapter *
183+
create_i2c(struct ddc_service *ddc_service, bool oem);
182184

183185
static enum drm_mode_subconnector get_subconnector_type(struct dc_link *link)
184186
{
@@ -2893,6 +2895,33 @@ static int amdgpu_dm_smu_write_watermarks_table(struct amdgpu_device *adev)
28932895
return 0;
28942896
}
28952897

2898+
static int dm_oem_i2c_hw_init(struct amdgpu_device *adev)
2899+
{
2900+
struct amdgpu_display_manager *dm = &adev->dm;
2901+
struct amdgpu_i2c_adapter *oem_i2c;
2902+
struct ddc_service *oem_ddc_service;
2903+
int r;
2904+
2905+
oem_ddc_service = dc_get_oem_i2c_device(adev->dm.dc);
2906+
if (oem_ddc_service) {
2907+
oem_i2c = create_i2c(oem_ddc_service, true);
2908+
if (!oem_i2c) {
2909+
dev_info(adev->dev, "Failed to create oem i2c adapter data\n");
2910+
return -ENOMEM;
2911+
}
2912+
2913+
r = i2c_add_adapter(&oem_i2c->base);
2914+
if (r) {
2915+
dev_info(adev->dev, "Failed to register oem i2c\n");
2916+
kfree(oem_i2c);
2917+
return r;
2918+
}
2919+
dm->oem_i2c = oem_i2c;
2920+
}
2921+
2922+
return 0;
2923+
}
2924+
28962925
/**
28972926
* dm_hw_init() - Initialize DC device
28982927
* @ip_block: Pointer to the amdgpu_ip_block for this hw instance.
@@ -2924,6 +2953,10 @@ static int dm_hw_init(struct amdgpu_ip_block *ip_block)
29242953
return r;
29252954
amdgpu_dm_hpd_init(adev);
29262955

2956+
r = dm_oem_i2c_hw_init(adev);
2957+
if (r)
2958+
dev_info(adev->dev, "Failed to add OEM i2c bus\n");
2959+
29272960
return 0;
29282961
}
29292962

@@ -2939,6 +2972,8 @@ static int dm_hw_fini(struct amdgpu_ip_block *ip_block)
29392972
{
29402973
struct amdgpu_device *adev = ip_block->adev;
29412974

2975+
kfree(adev->dm.oem_i2c);
2976+
29422977
amdgpu_dm_hpd_fini(adev);
29432978

29442979
amdgpu_dm_irq_fini(adev);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,13 @@ struct amdgpu_display_manager {
606606
* Bounding box data read from dmub during early initialization for DCN4+
607607
*/
608608
struct dml2_soc_bb *bb_from_dmub;
609+
610+
/**
611+
* @oem_i2c:
612+
*
613+
* OEM i2c bus
614+
*/
615+
struct amdgpu_i2c_adapter *oem_i2c;
609616
};
610617

611618
enum dsc_clock_force_state {

0 commit comments

Comments
 (0)