From 0f2eb5430d19cc49661d69571dde042650766691 Mon Sep 17 00:00:00 2001 From: Thomas Fleury Date: Wed, 22 Mar 2017 19:58:09 +0530 Subject: gpu: nvgpu: add INA3221 I2C info in platform data Add I2C device index and address for INA3221 in platform data. Jira EVLR-1048 Change-Id: I3791f24bd6d8ab99483ea0103313b2b671dfb445 Signed-off-by: Thomas Fleury Reviewed-on: http://git-master/r/1327047 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/platform_gk20a.h | 4 ++++ drivers/gpu/nvgpu/pci.c | 8 ++++++++ drivers/gpu/nvgpu/pmgr/pmgrpmu.c | 14 ++++++++------ 3 files changed, 20 insertions(+), 6 deletions(-) (limited to 'drivers/gpu/nvgpu') diff --git a/drivers/gpu/nvgpu/gk20a/platform_gk20a.h b/drivers/gpu/nvgpu/gk20a/platform_gk20a.h index 2d8c2bd7..4bdbda43 100644 --- a/drivers/gpu/nvgpu/gk20a/platform_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/platform_gk20a.h @@ -252,6 +252,10 @@ struct gk20a_platform { * power limits */ bool hardcode_sw_threshold; + + /* i2c device index and address for INA3221 */ + u32 ina3221_dcb_index; + u32 ina3221_i2c_address; }; static inline struct gk20a_platform *gk20a_get_platform( diff --git a/drivers/gpu/nvgpu/pci.c b/drivers/gpu/nvgpu/pci.c index a7899f7e..93c0a5cc 100644 --- a/drivers/gpu/nvgpu/pci.c +++ b/drivers/gpu/nvgpu/pci.c @@ -86,6 +86,8 @@ static struct gk20a_platform nvgpu_pci_device[] = { .vidmem_is_vidmem = true, .vbios_min_version = 0x86063000, .hardcode_sw_threshold = true, + .ina3221_dcb_index = 0, + .ina3221_i2c_address = 0x84, }, { /* DEVICE=0x1c36 */ /* ptimer src frequency in hz */ @@ -118,6 +120,8 @@ static struct gk20a_platform nvgpu_pci_device[] = { .vidmem_is_vidmem = true, .vbios_min_version = 0x86062d00, .hardcode_sw_threshold = true, + .ina3221_dcb_index = 0, + .ina3221_i2c_address = 0x84, }, { /* DEVICE=0x1c37 */ /* ptimer src frequency in hz */ @@ -150,6 +154,8 @@ static struct gk20a_platform nvgpu_pci_device[] = { .vidmem_is_vidmem = true, .vbios_min_version = 0x86063000, .hardcode_sw_threshold = true, + .ina3221_dcb_index = 0, + .ina3221_i2c_address = 0x84, }, { /* DEVICE=0x1c75 */ /* ptimer src frequency in hz */ @@ -182,6 +188,8 @@ static struct gk20a_platform nvgpu_pci_device[] = { .vidmem_is_vidmem = true, .vbios_min_version = 0x86064700, .hardcode_sw_threshold = false, + .ina3221_dcb_index = 1, + .ina3221_i2c_address = 0x80, } }; diff --git a/drivers/gpu/nvgpu/pmgr/pmgrpmu.c b/drivers/gpu/nvgpu/pmgr/pmgrpmu.c index 9873bd17..9201de2b 100644 --- a/drivers/gpu/nvgpu/pmgr/pmgrpmu.c +++ b/drivers/gpu/nvgpu/pmgr/pmgrpmu.c @@ -138,18 +138,20 @@ exit: static u32 pmgr_send_i2c_device_topology_to_pmu(struct gk20a *g) { struct nv_pmu_pmgr_i2c_device_desc_table i2c_desc_table; + struct gk20a_platform *platform = gk20a_get_platform(g->dev); + u32 idx = platform->ina3221_dcb_index; u32 status = 0; /* INA3221 I2C device info */ - i2c_desc_table.dev_mask = 0x01; + i2c_desc_table.dev_mask = (1UL << idx); /* INA3221 */ - i2c_desc_table.devices[0].super.type = 0x4E; + i2c_desc_table.devices[idx].super.type = 0x4E; - i2c_desc_table.devices[0].dcb_index = 0; - i2c_desc_table.devices[0].i2c_address = 0x84; - i2c_desc_table.devices[0].i2c_flags = 0xC2F; - i2c_desc_table.devices[0].i2c_port = 0x2; + i2c_desc_table.devices[idx].dcb_index = idx; + i2c_desc_table.devices[idx].i2c_address = platform->ina3221_i2c_address; + i2c_desc_table.devices[idx].i2c_flags = 0xC2F; + i2c_desc_table.devices[idx].i2c_port = 0x2; /* Pass the table down the PMU as an object */ status = pmgr_pmu_set_object( -- cgit v1.2.2