drm/amdgpu: move i2c bus lock out of ras structure
Subsystems (2)
PATCH 1/6 drm/amdgpu: move i2c bus lock out of ras structure
It's not really ras related. It's just a lock for the bus in general. This removes the ras dependency from the smu i2c bus.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h | 1 - drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c | 10 +++------- 3 files changed, 4 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +1 -0
@@ -425,6 +425,7 @@ struct amdgpu_pm {u32 default_sclk;u32 default_mclk;struct amdgpu_i2c_chan *i2c_bus; +bool bus_locked;/* internal thermal controller on rv6xx+ */ enum amdgpu_int_thermal_type int_thermal_type;struct device *int_hwmon_dev;
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h +0 -1
@@ -47,7 +47,6 @@ struct amdgpu_ras_eeprom_control {uint32_t next_addr;unsigned int num_recs;struct mutex tbl_mutex; -bool bus_locked;uint32_t tbl_byte_sum;uint16_t i2c_address;// 8-bit represented address };
drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c +3 -7
@@ -32,7 +32,6 @@#include "amdgpu_amdkfd.h" #include <linux/i2c.h> #include <linux/pci.h> -#include "amdgpu_ras.h" /* error codes */ #define I2C_OK 0
@@ -592,14 +591,13 @@ static uint32_t smu_v11_0_i2c_eeprom_write_data(struct i2c_adapter *control,static void lock_bus (struct i2c_adapter *i2c,unsigned int flags) {struct amdgpu_device *adev =to_amdgpu_device (i2c); -struct amdgpu_ras_eeprom_control *control = &adev->psp.ras.ras->eeprom_control;if (!smu_v11_0_i2c_bus_lock (i2c)) {DRM_ERROR ("Failed to lock the bus from SMU" );return ; } - control->bus_locked = true; + adev->pm.bus_locked = true; }static int trylock_bus (struct i2c_adapter *i2c,unsigned int flags)
@@ -611,14 +609,13 @@ static int trylock_bus(struct i2c_adapter *i2c, unsigned int flags)static void unlock_bus (struct i2c_adapter *i2c,unsigned int flags) {struct amdgpu_device *adev =to_amdgpu_device (i2c); -struct amdgpu_ras_eeprom_control *control = &adev->psp.ras.ras->eeprom_control;if (!smu_v11_0_i2c_bus_unlock (i2c)) {DRM_ERROR ("Failed to unlock the bus from SMU" );return ; } - control->bus_locked = false; + adev->pm.bus_locked = false; }static const struct i2c_lock_operations smu_v11_0_i2c_i2c_lock_ops = {
@@ -632,9 +629,8 @@ static int smu_v11_0_i2c_eeprom_i2c_xfer(struct i2c_adapter *i2c_adap, {int i, ret;struct amdgpu_device *adev =to_amdgpu_device (i2c_adap); -struct amdgpu_ras_eeprom_control *control = &adev->psp.ras.ras->eeprom_control; -if (!control->bus_locked) { +if (!adev->pm.bus_locked) {DRM_ERROR ("I2C bus unlocked, stopping transaction!" );return -EIO ; }
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/6 drm/amdgpu: remove eeprom from the smu i2c handlers
The driver uses it for EEPROM access, but it's just an i2c bus.
--- drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c | 52 +++++++++---------- drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.h | 4 +- .../drm/amd/powerplay/smumgr/vega20_smumgr.c | 4 +- 3 files changed, 30 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c +26 -26
@@ -536,12 +536,12 @@ static bool smu_v11_0_i2c_bus_unlock(struct i2c_adapter *control)return false; } -/***************************** EEPROM I2C GLUE ****************************/ +/***************************** I2C GLUE ****************************/ -static uint32_t smu_v11_0_i2c_eeprom_read_data (struct i2c_adapter *control, -uint8_t address, -uint8_t *data, -uint32_t numbytes) +static uint32_t smu_v11_0_i2c_read_data (struct i2c_adapter *control, +uint8_t address, +uint8_t *data, +uint32_t numbytes) {uint32_t ret =0 ;
@@ -561,10 +561,10 @@ static uint32_t smu_v11_0_i2c_eeprom_read_data(struct i2c_adapter *control,return ret; } -static uint32_t smu_v11_0_i2c_eeprom_write_data (struct i2c_adapter *control, -uint8_t address, -uint8_t *data, -uint32_t numbytes) +static uint32_t smu_v11_0_i2c_write_data (struct i2c_adapter *control, +uint8_t address, +uint8_t *data, +uint32_t numbytes) {uint32_t ret;
@@ -624,7 +624,7 @@ static const struct i2c_lock_operations smu_v11_0_i2c_i2c_lock_ops = { .unlock_bus = unlock_bus, }; -static int smu_v11_0_i2c_eeprom_i2c_xfer (struct i2c_adapter *i2c_adap, +static int smu_v11_0_i2c_xfer (struct i2c_adapter *i2c_adap,struct i2c_msg *msgs,int num) {int i, ret;
@@ -639,13 +639,13 @@ static int smu_v11_0_i2c_eeprom_i2c_xfer(struct i2c_adapter *i2c_adap,for (i =0 ; i < num; i++) {if (msgs[i].flags &I2C_M_RD ) - ret =smu_v11_0_i2c_eeprom_read_data (i2c_adap, - (uint8_t )msgs[i].addr, - msgs[i].buf, msgs[i].len); + ret =smu_v11_0_i2c_read_data (i2c_adap, + (uint8_t )msgs[i].addr, + msgs[i].buf, msgs[i].len);else - ret =smu_v11_0_i2c_eeprom_write_data (i2c_adap, - (uint8_t )msgs[i].addr, - msgs[i].buf, msgs[i].len); + ret =smu_v11_0_i2c_write_data (i2c_adap, + (uint8_t )msgs[i].addr, + msgs[i].buf, msgs[i].len);if (ret !=I2C_OK ) { num = -EIO ;
@@ -657,18 +657,18 @@ static int smu_v11_0_i2c_eeprom_i2c_xfer(struct i2c_adapter *i2c_adap,return num; } -static u32 smu_v11_0_i2c_eeprom_i2c_func (struct i2c_adapter *adap) +static u32 smu_v11_0_i2c_func (struct i2c_adapter *adap) {return I2C_FUNC_I2C |I2C_FUNC_SMBUS_EMUL ; } -static const struct i2c_algorithm smu_v11_0_i2c_eeprom_i2c_algo = { - .master_xfer = smu_v11_0_i2c_eeprom_i2c_xfer, - .functionality = smu_v11_0_i2c_eeprom_i2c_func, +static const struct i2c_algorithm smu_v11_0_i2c_algo = { + .master_xfer = smu_v11_0_i2c_xfer, + .functionality = smu_v11_0_i2c_func, }; -int smu_v11_0_i2c_eeprom_control_init (struct i2c_adapter *control) +int smu_v11_0_i2c_control_init (struct i2c_adapter *control) {struct amdgpu_device *adev =to_amdgpu_device (control);int res;
@@ -676,8 +676,8 @@ int smu_v11_0_i2c_eeprom_control_init(struct i2c_adapter *control) control->owner =THIS_MODULE ; control->class =I2C_CLASS_SPD ; control->dev.parent = &adev->pdev->dev; - control->algo = &smu_v11_0_i2c_eeprom_i2c_algo; -snprintf (control->name,sizeof (control->name),"AMDGPU EEPROM" ); + control->algo = &smu_v11_0_i2c_algo; +snprintf (control->name,sizeof (control->name),"AMDGPU SMU" ); control->lock_ops = &smu_v11_0_i2c_i2c_lock_ops; res =i2c_add_adapter (control);
@@ -687,7 +687,7 @@ int smu_v11_0_i2c_eeprom_control_init(struct i2c_adapter *control)return res; } -void smu_v11_0_i2c_eeprom_control_fini (struct i2c_adapter *control) +void smu_v11_0_i2c_control_fini (struct i2c_adapter *control) {i2c_del_adapter (control); }
@@ -715,9 +715,9 @@ bool smu_v11_0_i2c_test_bus(struct i2c_adapter *control)smu_v11_0_i2c_init (control);/* Write 0xde to address 0x0000 on the EEPROM */ - ret =smu_v11_0_i2c_eeprom_write_data (control,I2C_TARGET_ADDR , data,6 ); + ret =smu_v11_0_i2c_write_data (control,I2C_TARGET_ADDR , data,6 ); - ret =smu_v11_0_i2c_eeprom_read_data (control,I2C_TARGET_ADDR , data,6 ); + ret =smu_v11_0_i2c_read_data (control,I2C_TARGET_ADDR , data,6 );smu_v11_0_i2c_fini (control);
drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.h +2 -2
@@ -28,7 +28,7 @@struct i2c_adapter ; -int smu_v11_0_i2c_eeprom_control_init (struct i2c_adapter *control); -void smu_v11_0_i2c_eeprom_control_fini (struct i2c_adapter *control); +int smu_v11_0_i2c_control_init (struct i2c_adapter *control); +void smu_v11_0_i2c_control_fini (struct i2c_adapter *control);#endif
drivers/gpu/drm/amd/powerplay/smumgr/vega20_smumgr.c +2 -2
@@ -523,7 +523,7 @@ static int vega20_smu_init(struct pp_hwmgr *hwmgr) priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF ].size =sizeof (DpmActivityMonitorCoeffInt_t);if (adev->psp.ras.ras) { - ret =smu_v11_0_i2c_eeprom_control_init (&adev->pm.smu_i2c); + ret =smu_v11_0_i2c_control_init (&adev->pm.smu_i2c);if (ret) goto err4; }
@@ -563,7 +563,7 @@ static int vega20_smu_fini(struct pp_hwmgr *hwmgr)struct amdgpu_device *adev = hwmgr->adev;if (adev->psp.ras.ras) -smu_v11_0_i2c_eeprom_control_fini (&adev->pm.smu_i2c); +smu_v11_0_i2c_control_fini (&adev->pm.smu_i2c);if (priv) { amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_PPTABLE].handle,
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/6 drm/amdgpu/vega20: enable the smu i2c bus for all boards
In reply to Alex DeucherThere is no longer a ras dependency so it's safe to expose on all boards.
--- drivers/gpu/drm/amd/powerplay/smumgr/vega20_smumgr.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/powerplay/smumgr/vega20_smumgr.c +4 -7
@@ -522,11 +522,9 @@ static int vega20_smu_init(struct pp_hwmgr *hwmgr) priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF ].version =0x01 ; priv->smu_tables.entry[TABLE_ACTIVITY_MONITOR_COEFF ].size =sizeof (DpmActivityMonitorCoeffInt_t); -if (adev->psp.ras.ras) { - ret =smu_v11_0_i2c_control_init (&adev->pm.smu_i2c); -if (ret) - goto err4; - } + ret =smu_v11_0_i2c_control_init (&adev->pm.smu_i2c); +if (ret) + goto err4;return 0 ;
@@ -562,8 +560,7 @@ static int vega20_smu_fini(struct pp_hwmgr *hwmgr) (struct vega20_smumgr *)(hwmgr->smu_backend);struct amdgpu_device *adev = hwmgr->adev; -if (adev->psp.ras.ras) -smu_v11_0_i2c_control_fini (&adev->pm.smu_i2c); +smu_v11_0_i2c_control_fini (&adev->pm.smu_i2c);if (priv) { amdgpu_bo_free_kernel(&priv->smu_tables.entry[TABLE_PPTABLE].handle,
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/6 drm/amdgpu/swSMU: remove eeprom from the smu i2c handlers (v2)
In reply to Alex DeucherThe driver uses it for EEPROM access, but it's just an i2c bus.
v2: change the callback name as well.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 +- drivers/gpu/drm/amd/powerplay/arcturus_ppt.c | 60 +++++++++---------- .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 4 +- drivers/gpu/drm/amd/powerplay/smu_internal.h | 4 +- 4 files changed, 36 insertions(+), 36 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +2 -2
@@ -1135,7 +1135,7 @@ static int smu_smc_hw_setup(struct smu_context *smu)return ret; } - ret =smu_i2c_eeprom_init (smu, &adev->pm.smu_i2c); + ret =smu_i2c_init (smu, &adev->pm.smu_i2c);if (ret)return ret;
@@ -1341,7 +1341,7 @@ static int smu_smc_hw_cleanup(struct smu_context *smu)struct amdgpu_device *adev = smu->adev;int ret =0 ; -smu_i2c_eeprom_fini (smu, &adev->pm.smu_i2c); +smu_i2c_fini (smu, &adev->pm.smu_i2c);cancel_work_sync (&smu->throttling_logging_work);
drivers/gpu/drm/amd/powerplay/arcturus_ppt.c +30 -30
163 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +2 -2
@@ -494,8 +494,8 @@ struct pptable_funcs {int (*set_df_cstate)(struct smu_context *smu,enum pp_df_cstate state);int (*allow_xgmi_power_down)(struct smu_context *smu,bool en);int (*update_pcie_parameters)(struct smu_context *smu,uint32_t pcie_gen_cap,uint32_t pcie_width_cap); -int (*i2c_eeprom_init)(struct smu_context *smu,struct i2c_adapter *control); -void (*i2c_eeprom_fini)(struct smu_context *smu,struct i2c_adapter *control); +int (*i2c_init)(struct smu_context *smu,struct i2c_adapter *control); +void (*i2c_fini)(struct smu_context *smu,struct i2c_adapter *control);void (*get_unique_id)(struct smu_context *smu);int (*get_dpm_clock_table)(struct smu_context *smu,struct dpm_clocks *clock_table);int (*init_microcode)(struct smu_context *smu);
drivers/gpu/drm/amd/powerplay/smu_internal.h +2 -2
@@ -91,8 +91,8 @@#define smu_update_pcie_parameters (smu, pcie_gen_cap, pcie_width_cap) smu_ppt_funcs(update_pcie_parameters, 0, smu, pcie_gen_cap, pcie_width_cap)#define smu_disable_umc_cdr_12gbps_workaround (smu) smu_ppt_funcs(disable_umc_cdr_12gbps_workaround, 0, smu)#define smu_set_power_source (smu, power_src) smu_ppt_funcs(set_power_source, 0, smu, power_src) -#define smu_i2c_eeprom_init (smu, control) smu_ppt_funcs(i2c_eeprom_init, 0, smu, control) -#define smu_i2c_eeprom_fini (smu, control) smu_ppt_funcs(i2c_eeprom_fini, 0, smu, control) +#define smu_i2c_init (smu, control) smu_ppt_funcs(i2c_init, 0, smu, control) +#define smu_i2c_fini (smu, control) smu_ppt_funcs(i2c_fini, 0, smu, control)#define smu_get_unique_id (smu) smu_ppt_funcs(get_unique_id, 0, smu)#define smu_log_thermal_throttling (smu) smu_ppt_funcs(log_thermal_throttling_event, 0, smu)#define smu_get_asic_power_limits (smu) smu_ppt_funcs(get_power_limit, 0, smu)
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/6 drm/amdgpu/navi1x: add SMU i2c support (v2)
In reply to Alex DeucherEnable SMU i2c bus access for navi1x asics.
v2: add missing implementation
--- drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 239 +++++++++++++++++++++ 1 file changed, 239 insertions(+)
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +239 -0
@@ -23,6 +23,7 @@#include <linux/firmware.h> #include <linux/pci.h> +#include <linux/i2c.h> #include "amdgpu.h" #include "amdgpu_smu.h" #include "smu_internal.h"
@@ -52,6 +53,8 @@#undef pr_info#undef pr_debug +#define to_amdgpu_device (x) (container_of(x, struct amdgpu_device, pm.smu_i2c)) +#define FEATURE_MASK (feature) (1ULL << feature)#define SMC_DPM_FEATURE ( \ FEATURE_MASK(FEATURE_DPM_PREFETCHER_BIT) | \
@@ -553,6 +556,8 @@ static int navi10_tables_init(struct smu_context *smu, struct smu_table *tables) PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);SMU_TABLE_INIT (tables,SMU_TABLE_SMU_METRICS ,sizeof (SmuMetrics_t),PAGE_SIZE ,AMDGPU_GEM_DOMAIN_VRAM ); +SMU_TABLE_INIT (tables,SMU_TABLE_I2C_COMMANDS ,sizeof (SwI2cRequest_t), +PAGE_SIZE ,AMDGPU_GEM_DOMAIN_VRAM );SMU_TABLE_INIT (tables,SMU_TABLE_OVERDRIVE ,sizeof (OverDriveTable_t),PAGE_SIZE ,AMDGPU_GEM_DOMAIN_VRAM ); SMU_TABLE_INIT(tables, SMU_TABLE_PMSTATUSLOG, SMU11_TOOL_SIZE,
@@ -2340,6 +2345,238 @@ static int navi10_disable_umc_cdr_12gbps_workaround(struct smu_context *smu)return navi10_dummy_pstate_control (smu, true); } +static void navi10_fill_i2c_req (SwI2cRequest_t *req,bool write, +uint8_t address,uint32_t numbytes, +uint8_t *data) +{ +int i; + +BUG_ON (numbytes >MAX_SW_I2C_COMMANDS ); + + req->I2CcontrollerPort =0 ; + req->I2CSpeed =2 ; + req->SlaveAddress = address; + req->NumCmds = numbytes; + +for (i =0 ; i < numbytes; i++) { +SwI2cCmd_t *cmd = &req->SwI2cCmds[i]; + +/* First 2 bytes are always write for lower 2b EEPROM address */ +if (i <2 ) + cmd->Cmd =1 ; +else + cmd->Cmd = write; + + +/* Add RESTART for read after address filled */ + cmd->CmdConfig |= (i ==2 && !write) ?CMDCONFIG_RESTART_MASK :0 ; + +/* Add STOP in the end */ + cmd->CmdConfig |= (i == (numbytes -1 )) ?CMDCONFIG_STOP_MASK :0 ; + +/* Fill with data regardless if read or write to simplify code */ + cmd->RegisterAddr = data[i]; + } +} + +static int navi10_i2c_read_data (struct i2c_adapter *control, +uint8_t address, +uint8_t *data, +uint32_t numbytes) +{ +uint32_t i, ret =0 ; +SwI2cRequest_t req; +struct amdgpu_device *adev =to_amdgpu_device (control); +struct smu_table_context *smu_table = &adev->smu.smu_table; +struct smu_table *table = &smu_table->driver_table; + +memset (&req,0 ,sizeof (req)); +navi10_fill_i2c_req (&req, false, address, numbytes, data); + +mutex_lock (&adev->smu.mutex); +/* Now read data starting with that address */ + ret =smu_update_table (&adev->smu,SMU_TABLE_I2C_COMMANDS ,0 , &req, + true); +mutex_unlock (&adev->smu.mutex); + +if (!ret) { +SwI2cRequest_t *res = (SwI2cRequest_t *)table->cpu_addr; + +/* Assume SMU fills res.SwI2cCmds[i].Data with read bytes */ +for (i =0 ; i < numbytes; i++) + data[i] = res->SwI2cCmds[i].Data; + +dev_dbg (adev->dev,"navi10_i2c_read_data, address = %x, bytes = %d, data :" , + (uint16_t )address, numbytes); + +print_hex_dump (KERN_DEBUG ,"data: " ,DUMP_PREFIX_NONE , +8 ,1 , data, numbytes, false); + }else +dev_err (adev->dev,"navi10_i2c_read_data - error occurred :%x" , ret); + +return ret; +} + +static int navi10_i2c_write_data (struct i2c_adapter *control, +uint8_t address, +uint8_t *data, +uint32_t numbytes) +{ +uint32_t ret; +SwI2cRequest_t req; +struct amdgpu_device *adev =to_amdgpu_device (control); + +memset (&req,0 ,sizeof (req)); +navi10_fill_i2c_req (&req, true, address, numbytes, data); + +mutex_lock (&adev->smu.mutex); + ret =smu_update_table (&adev->smu,SMU_TABLE_I2C_COMMANDS ,0 , &req, true); +mutex_unlock (&adev->smu.mutex); + +if (!ret) { +dev_dbg (adev->dev,"navi10_i2c_write(), address = %x, bytes = %d , data: " , + (uint16_t )address, numbytes); + +print_hex_dump (KERN_DEBUG ,"data: " ,DUMP_PREFIX_NONE , +8 ,1 , data, numbytes, false); +/* +* According to EEPROM spec there is a MAX of 10 ms required for +* EEPROM to flush internal RX buffer after STOP was issued at the +* end of write transaction. During this time the EEPROM will not be +* responsive to any more commands - so wait a bit more. +*/ +msleep (10 ); + + }else +dev_err (adev->dev,"navi10_i2c_write- error occurred :%x" , ret); + +return ret; +} + +static int navi10_i2c_xfer (struct i2c_adapter *i2c_adap, +struct i2c_msg *msgs,int num) +{ +uint32_t i, j, ret, data_size, data_chunk_size, next_eeprom_addr =0 ; +uint8_t *data_ptr, data_chunk[MAX_SW_I2C_COMMANDS ] = {0 }; + +for (i =0 ; i < num; i++) { +/* +* SMU interface allows at most MAX_SW_I2C_COMMANDS bytes of data at +* once and hence the data needs to be spliced into chunks and sent each +* chunk separately +*/ + data_size = msgs[i].len -2 ; + data_chunk_size =MAX_SW_I2C_COMMANDS -2 ; + next_eeprom_addr = (msgs[i].buf[0 ] <<8 &0xff00 ) | (msgs[i].buf[1 ] &0xff ); + data_ptr = msgs[i].buf +2 ; + +for (j =0 ; j < data_size / data_chunk_size; j++) { +/* Insert the EEPROM dest addess, bits 0-15 */ + data_chunk[0 ] = ((next_eeprom_addr >>8 ) &0xff ); + data_chunk[1 ] = (next_eeprom_addr &0xff ); + +if (msgs[i].flags &I2C_M_RD ) { + ret =navi10_i2c_read_data (i2c_adap, + (uint8_t )msgs[i].addr, + data_chunk,MAX_SW_I2C_COMMANDS ); + +memcpy (data_ptr, data_chunk +2 , data_chunk_size); + }else { + +memcpy (data_chunk +2 , data_ptr, data_chunk_size); + + ret =navi10_i2c_write_data (i2c_adap, + (uint8_t )msgs[i].addr, + data_chunk,MAX_SW_I2C_COMMANDS ); + } + +if (ret) { + num = -EIO ; + goto fail; + } + + next_eeprom_addr += data_chunk_size; + data_ptr += data_chunk_size; + } + +if (data_size % data_chunk_size) { + data_chunk[0 ] = ((next_eeprom_addr >>8 ) &0xff ); + data_chunk[1 ] = (next_eeprom_addr &0xff ); + +if (msgs[i].flags &I2C_M_RD ) { + ret =navi10_i2c_read_data (i2c_adap, + (uint8_t )msgs[i].addr, + data_chunk, (data_size % data_chunk_size) +2 ); + +memcpy (data_ptr, data_chunk +2 , data_size % data_chunk_size); + }else { +memcpy (data_chunk +2 , data_ptr, data_size % data_chunk_size); + + ret =navi10_i2c_write_data (i2c_adap, + (uint8_t )msgs[i].addr, + data_chunk, (data_size % data_chunk_size) +2 ); + } + +if (ret) { + num = -EIO ; + goto fail; + } + } + } + +fail: +return num; +} + +static u32 navi10_i2c_func (struct i2c_adapter *adap) +{ +return I2C_FUNC_I2C |I2C_FUNC_SMBUS_EMUL ; +} + + +static const struct i2c_algorithm navi10_i2c_algo = { + .master_xfer = navi10_i2c_xfer, + .functionality = navi10_i2c_func, +}; + +static bool navi10_i2c_adapter_is_added (struct i2c_adapter *control) +{ +struct amdgpu_device *adev =to_amdgpu_device (control); + +return control->dev.parent == &adev->pdev->dev; +} + +static int navi10_i2c_control_init (struct smu_context *smu,struct i2c_adapter *control) +{ +struct amdgpu_device *adev =to_amdgpu_device (control); +int res; + +/* smu_i2c_eeprom_init may be called twice in sriov */ +if (navi10_i2c_adapter_is_added (control)) +return 0 ; + + control->owner =THIS_MODULE ; + control->class =I2C_CLASS_SPD ; + control->dev.parent = &adev->pdev->dev; + control->algo = &navi10_i2c_algo; +snprintf (control->name,sizeof (control->name),"AMDGPU SMU" ); + + res =i2c_add_adapter (control); +if (res) +DRM_ERROR ("Failed to register hw i2c, err: %d\n" , res); + +return res; +} + +static void navi10_i2c_control_fini (struct smu_context *smu,struct i2c_adapter *control) +{ +if (!navi10_i2c_adapter_is_added (control)) +return ; + +i2c_del_adapter (control); +} + +static const struct pptable_funcs navi10_ppt_funcs = { .tables_init = navi10_tables_init, .alloc_dpm_context = navi10_allocate_dpm_context,
@@ -2353,6 +2590,8 @@ static const struct pptable_funcs navi10_ppt_funcs = { .set_default_dpm_table = navi10_set_default_dpm_table, .dpm_set_vcn_enable = navi10_dpm_set_vcn_enable, .dpm_set_jpeg_enable = navi10_dpm_set_jpeg_enable, + .i2c_init = navi10_i2c_control_init, + .i2c_fini = navi10_i2c_control_fini, .print_clk_levels = navi10_print_clk_levels, .force_clk_levels = navi10_force_clk_levels, .populate_umd_state_clk = navi10_populate_umd_state_clk,
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/6 drm/amdgpu/sienna_cichlid: add SMU i2c support (v2)
In reply to Alex DeucherEnable SMU i2c bus access for sienna_cichlid asics.
v2: change callback name
--- .../drm/amd/powerplay/sienna_cichlid_ppt.c | 239 ++++++++++++++++++ 1 file changed, 239 insertions(+)
drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c +239 -0
@@ -23,6 +23,7 @@#include <linux/firmware.h> #include <linux/pci.h> +#include <linux/i2c.h> #include "amdgpu.h" #include "amdgpu_smu.h" #include "smu_internal.h"
@@ -52,6 +53,8 @@#undef pr_info#undef pr_debug +#define to_amdgpu_device (x) (container_of(x, struct amdgpu_device, pm.smu_i2c)) +#define FEATURE_MASK (feature) (1ULL << feature)#define SMC_DPM_FEATURE ( \ FEATURE_MASK(FEATURE_DPM_PREFETCHER_BIT) | \
@@ -455,6 +458,8 @@ static int sienna_cichlid_tables_init(struct smu_context *smu, struct smu_table PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);SMU_TABLE_INIT (tables,SMU_TABLE_SMU_METRICS ,sizeof (SmuMetrics_t),PAGE_SIZE ,AMDGPU_GEM_DOMAIN_VRAM ); +SMU_TABLE_INIT (tables,SMU_TABLE_I2C_COMMANDS ,sizeof (SwI2cRequest_t), +PAGE_SIZE ,AMDGPU_GEM_DOMAIN_VRAM );SMU_TABLE_INIT (tables,SMU_TABLE_OVERDRIVE ,sizeof (OverDriveTable_t),PAGE_SIZE ,AMDGPU_GEM_DOMAIN_VRAM ); SMU_TABLE_INIT(tables, SMU_TABLE_PMSTATUSLOG, SMU11_TOOL_SIZE,
@@ -2487,6 +2492,238 @@ static void sienna_cichlid_dump_pptable(struct smu_context *smu)dev_info (smu->adev->dev,"MmHubPadding[7] = 0x%x\n" , pptable->MmHubPadding[7 ]); } +static void sienna_cichlid_fill_i2c_req (SwI2cRequest_t *req,bool write, +uint8_t address,uint32_t numbytes, +uint8_t *data) +{ +int i; + +BUG_ON (numbytes >MAX_SW_I2C_COMMANDS ); + + req->I2CcontrollerPort =0 ; + req->I2CSpeed =2 ; + req->SlaveAddress = address; + req->NumCmds = numbytes; + +for (i =0 ; i < numbytes; i++) { +SwI2cCmd_t *cmd = &req->SwI2cCmds[i]; + +/* First 2 bytes are always write for lower 2b EEPROM address */ +if (i <2 ) + cmd->CmdConfig =CMDCONFIG_READWRITE_MASK ; +else + cmd->CmdConfig = write ?CMDCONFIG_READWRITE_MASK :0 ; + + +/* Add RESTART for read after address filled */ + cmd->CmdConfig |= (i ==2 && !write) ?CMDCONFIG_RESTART_MASK :0 ; + +/* Add STOP in the end */ + cmd->CmdConfig |= (i == (numbytes -1 )) ?CMDCONFIG_STOP_MASK :0 ; + +/* Fill with data regardless if read or write to simplify code */ + cmd->ReadWriteData = data[i]; + } +} + +static int sienna_cichlid_i2c_read_data (struct i2c_adapter *control, +uint8_t address, +uint8_t *data, +uint32_t numbytes) +{ +uint32_t i, ret =0 ; +SwI2cRequest_t req; +struct amdgpu_device *adev =to_amdgpu_device (control); +struct smu_table_context *smu_table = &adev->smu.smu_table; +struct smu_table *table = &smu_table->driver_table; + +memset (&req,0 ,sizeof (req)); +sienna_cichlid_fill_i2c_req (&req, false, address, numbytes, data); + +mutex_lock (&adev->smu.mutex); +/* Now read data starting with that address */ + ret =smu_update_table (&adev->smu,SMU_TABLE_I2C_COMMANDS ,0 , &req, + true); +mutex_unlock (&adev->smu.mutex); + +if (!ret) { +SwI2cRequest_t *res = (SwI2cRequest_t *)table->cpu_addr; + +/* Assume SMU fills res.SwI2cCmds[i].Data with read bytes */ +for (i =0 ; i < numbytes; i++) + data[i] = res->SwI2cCmds[i].ReadWriteData; + +dev_dbg (adev->dev,"sienna_cichlid_i2c_read_data, address = %x, bytes = %d, data :" , + (uint16_t )address, numbytes); + +print_hex_dump (KERN_DEBUG ,"data: " ,DUMP_PREFIX_NONE , +8 ,1 , data, numbytes, false); + }else +dev_err (adev->dev,"sienna_cichlid_i2c_read_data - error occurred :%x" , ret); + +return ret; +} + +static int sienna_cichlid_i2c_write_data (struct i2c_adapter *control, +uint8_t address, +uint8_t *data, +uint32_t numbytes) +{ +uint32_t ret; +SwI2cRequest_t req; +struct amdgpu_device *adev =to_amdgpu_device (control); + +memset (&req,0 ,sizeof (req)); +sienna_cichlid_fill_i2c_req (&req, true, address, numbytes, data); + +mutex_lock (&adev->smu.mutex); + ret =smu_update_table (&adev->smu,SMU_TABLE_I2C_COMMANDS ,0 , &req, true); +mutex_unlock (&adev->smu.mutex); + +if (!ret) { +dev_dbg (adev->dev,"sienna_cichlid_i2c_write(), address = %x, bytes = %d , data: " , + (uint16_t )address, numbytes); + +print_hex_dump (KERN_DEBUG ,"data: " ,DUMP_PREFIX_NONE , +8 ,1 , data, numbytes, false); +/* +* According to EEPROM spec there is a MAX of 10 ms required for +* EEPROM to flush internal RX buffer after STOP was issued at the +* end of write transaction. During this time the EEPROM will not be +* responsive to any more commands - so wait a bit more. +*/ +msleep (10 ); + + }else +dev_err (adev->dev,"sienna_cichlid_i2c_write- error occurred :%x" , ret); + +return ret; +} + +static int sienna_cichlid_i2c_xfer (struct i2c_adapter *i2c_adap, +struct i2c_msg *msgs,int num) +{ +uint32_t i, j, ret, data_size, data_chunk_size, next_eeprom_addr =0 ; +uint8_t *data_ptr, data_chunk[MAX_SW_I2C_COMMANDS ] = {0 }; + +for (i =0 ; i < num; i++) { +/* +* SMU interface allows at most MAX_SW_I2C_COMMANDS bytes of data at +* once and hence the data needs to be spliced into chunks and sent each +* chunk separately +*/ + data_size = msgs[i].len -2 ; + data_chunk_size =MAX_SW_I2C_COMMANDS -2 ; + next_eeprom_addr = (msgs[i].buf[0 ] <<8 &0xff00 ) | (msgs[i].buf[1 ] &0xff ); + data_ptr = msgs[i].buf +2 ; + +for (j =0 ; j < data_size / data_chunk_size; j++) { +/* Insert the EEPROM dest addess, bits 0-15 */ + data_chunk[0 ] = ((next_eeprom_addr >>8 ) &0xff ); + data_chunk[1 ] = (next_eeprom_addr &0xff ); + +if (msgs[i].flags &I2C_M_RD ) { + ret =sienna_cichlid_i2c_read_data (i2c_adap, + (uint8_t )msgs[i].addr, + data_chunk,MAX_SW_I2C_COMMANDS ); + +memcpy (data_ptr, data_chunk +2 , data_chunk_size); + }else { + +memcpy (data_chunk +2 , data_ptr, data_chunk_size); + + ret =sienna_cichlid_i2c_write_data (i2c_adap, + (uint8_t )msgs[i].addr, + data_chunk,MAX_SW_I2C_COMMANDS ); + } + +if (ret) { + num = -EIO ; + goto fail; + } + + next_eeprom_addr += data_chunk_size; + data_ptr += data_chunk_size; + } + +if (data_size % data_chunk_size) { + data_chunk[0 ] = ((next_eeprom_addr >>8 ) &0xff ); + data_chunk[1 ] = (next_eeprom_addr &0xff ); + +if (msgs[i].flags &I2C_M_RD ) { + ret =sienna_cichlid_i2c_read_data (i2c_adap, + (uint8_t )msgs[i].addr, + data_chunk, (data_size % data_chunk_size) +2 ); + +memcpy (data_ptr, data_chunk +2 , data_size % data_chunk_size); + }else { +memcpy (data_chunk +2 , data_ptr, data_size % data_chunk_size); + + ret =sienna_cichlid_i2c_write_data (i2c_adap, + (uint8_t )msgs[i].addr, + data_chunk, (data_size % data_chunk_size) +2 ); + } + +if (ret) { + num = -EIO ; + goto fail; + } + } + } + +fail: +return num; +} + +static u32 sienna_cichlid_i2c_func (struct i2c_adapter *adap) +{ +return I2C_FUNC_I2C |I2C_FUNC_SMBUS_EMUL ; +} + + +static const struct i2c_algorithm sienna_cichlid_i2c_algo = { + .master_xfer = sienna_cichlid_i2c_xfer, + .functionality = sienna_cichlid_i2c_func, +}; + +static bool sienna_cichlid_i2c_adapter_is_added (struct i2c_adapter *control) +{ +struct amdgpu_device *adev =to_amdgpu_device (control); + +return control->dev.parent == &adev->pdev->dev; +} + +static int sienna_cichlid_i2c_control_init (struct smu_context *smu,struct i2c_adapter *control) +{ +struct amdgpu_device *adev =to_amdgpu_device (control); +int res; + +/* smu_i2c_eeprom_init may be called twice in sriov */ +if (sienna_cichlid_i2c_adapter_is_added (control)) +return 0 ; + + control->owner =THIS_MODULE ; + control->class =I2C_CLASS_SPD ; + control->dev.parent = &adev->pdev->dev; + control->algo = &sienna_cichlid_i2c_algo; +snprintf (control->name,sizeof (control->name),"AMDGPU SMU" ); + + res =i2c_add_adapter (control); +if (res) +DRM_ERROR ("Failed to register hw i2c, err: %d\n" , res); + +return res; +} + +static void sienna_cichlid_i2c_control_fini (struct smu_context *smu,struct i2c_adapter *control) +{ +if (!sienna_cichlid_i2c_adapter_is_added (control)) +return ; + +i2c_del_adapter (control); +} + +static const struct pptable_funcs sienna_cichlid_ppt_funcs = { .tables_init = sienna_cichlid_tables_init, .alloc_dpm_context = sienna_cichlid_allocate_dpm_context,
@@ -2500,6 +2737,8 @@ static const struct pptable_funcs sienna_cichlid_ppt_funcs = { .set_default_dpm_table = sienna_cichlid_set_default_dpm_table, .dpm_set_vcn_enable = sienna_cichlid_dpm_set_vcn_enable, .dpm_set_jpeg_enable = sienna_cichlid_dpm_set_jpeg_enable, + .i2c_init = sienna_cichlid_i2c_control_init, + .i2c_fini = sienna_cichlid_i2c_control_fini, .print_clk_levels = sienna_cichlid_print_clk_levels, .force_clk_levels = sienna_cichlid_force_clk_levels, .populate_umd_state_clk = sienna_cichlid_populate_umd_state_clk,
Signature · 6 lines
2.25.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 6/6] drm/amdgpu/sienna_cichlid: add SMU i2c support (v2)
Series is Reviewed-by: Andrey Grodzovsky <[email protected]>
Andrey
Quoted 279 lines · Alex Deucher
Enable SMU i2c bus access for
sienna_cichlidasics.v2: change callback name
Signed-off-by Alex Deucher <[email protected]>--- .../drm/amd/powerplay/sienna_cichlid_ppt.c | 239 ++++++++++++++++++ 1 file changed, 239 insertions(+)drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c +237
-0@@ -23,6 +23,7 @@#include <linux/firmware.h> #include <linux/pci.h> +#include <linux/i2c.h> #include "amdgpu.h" #include "amdgpu_smu.h" #include "smu_internal.h" @@ -52,6 +53,8 @@#undef pr_info#undef pr_debug +#define to_amdgpu_device (x) (container_of(x, struct amdgpu_device, pm.smu_i2c)) +#define FEATURE_MASK (feature) (1ULL << feature)#define SMC_DPM_FEATURE ( \ FEATURE_MASK(FEATURE_DPM_PREFETCHER_BIT) | \@@ -455,6 +458,8 @@ static int sienna_cichlid_tables_init(struct smu_context *smu, struct smu_table PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);SMU_TABLE_INIT (tables,SMU_TABLE_SMU_METRICS ,sizeof (SmuMetrics_t),PAGE_SIZE ,AMDGPU_GEM_DOMAIN_VRAM ); +SMU_TABLE_INIT (tables,SMU_TABLE_I2C_COMMANDS ,sizeof (SwI2cRequest_t), +PAGE_SIZE ,AMDGPU_GEM_DOMAIN_VRAM );SMU_TABLE_INIT (tables,SMU_TABLE_OVERDRIVE ,sizeof (OverDriveTable_t),PAGE_SIZE ,AMDGPU_GEM_DOMAIN_VRAM ); SMU_TABLE_INIT(tables, SMU_TABLE_PMSTATUSLOG, SMU11_TOOL_SIZE,@@ -2487,6 +2492,238 @@ static void sienna_cichlid_dump_pptable(struct smu_context *smu)dev_info (smu->adev->dev,"MmHubPadding[7] = 0x%x\n" , pptable->MmHubPadding[7 ]); } +static void sienna_cichlid_fill_i2c_req (SwI2cRequest_t *req,bool write, +uint8_t address,uint32_t numbytes, +uint8_t *data) +{ +int i; + +BUG_ON (numbytes >MAX_SW_I2C_COMMANDS ); + + req->I2CcontrollerPort =0 ; + req->I2CSpeed =2 ; + req->SlaveAddress = address; + req->NumCmds = numbytes; + +for (i =0 ; i < numbytes; i++) { +SwI2cCmd_t *cmd = &req->SwI2cCmds[i]; + +/* First 2 bytes are always write for lower 2b EEPROM address */ +if (i <2 ) + cmd->CmdConfig =CMDCONFIG_READWRITE_MASK ; +else + cmd->CmdConfig = write ?CMDCONFIG_READWRITE_MASK :0 ; + + +/* Add RESTART for read after address filled */ + cmd->CmdConfig |= (i ==2 && !write) ?CMDCONFIG_RESTART_MASK :0 ; + +/* Add STOP in the end */ + cmd->CmdConfig |= (i == (numbytes -1 )) ?CMDCONFIG_STOP_MASK :0 ; + +/* Fill with data regardless if read or write to simplify code */ + cmd->ReadWriteData = data[i]; + } +} + +static int sienna_cichlid_i2c_read_data (struct i2c_adapter *control, +uint8_t address, +uint8_t *data, +uint32_t numbytes) +{ +uint32_t i, ret =0 ; +SwI2cRequest_t req; +struct amdgpu_device *adev =to_amdgpu_device (control); +struct smu_table_context *smu_table = &adev->smu.smu_table; +struct smu_table *table = &smu_table->driver_table; + +memset (&req,0 ,sizeof (req)); +sienna_cichlid_fill_i2c_req (&req, false, address, numbytes, data); + +mutex_lock (&adev->smu.mutex); +/* Now read data starting with that address */ + ret =smu_update_table (&adev->smu,SMU_TABLE_I2C_COMMANDS ,0 , &req, + true); +mutex_unlock (&adev->smu.mutex); + +if (!ret) { +SwI2cRequest_t *res = (SwI2cRequest_t *)table->cpu_addr; + +/* Assume SMU fills res.SwI2cCmds[i].Data with read bytes */ +for (i =0 ; i < numbytes; i++) + data[i] = res->SwI2cCmds[i].ReadWriteData; + +dev_dbg (adev->dev,"sienna_cichlid_i2c_read_data, address = %x, bytes = %d, data :" , + (uint16_t )address, numbytes); + +print_hex_dump (KERN_DEBUG ,"data: " ,DUMP_PREFIX_NONE , +8 ,1 , data, numbytes, false); + }else +dev_err (adev->dev,"sienna_cichlid_i2c_read_data - error occurred :%x" , ret); + +return ret; +} + +static int sienna_cichlid_i2c_write_data (struct i2c_adapter *control, +uint8_t address, +uint8_t *data, +uint32_t numbytes) +{ +uint32_t ret; +SwI2cRequest_t req; +struct amdgpu_device *adev =to_amdgpu_device (control); + +memset (&req,0 ,sizeof (req)); +sienna_cichlid_fill_i2c_req (&req, true, address, numbytes, data); + +mutex_lock (&adev->smu.mutex); + ret =smu_update_table (&adev->smu,SMU_TABLE_I2C_COMMANDS ,0 , &req, true); +mutex_unlock (&adev->smu.mutex); + +if (!ret) { +dev_dbg (adev->dev,"sienna_cichlid_i2c_write(), address = %x, bytes = %d , data: " , + (uint16_t )address, numbytes); + +print_hex_dump (KERN_DEBUG ,"data: " ,DUMP_PREFIX_NONE , +8 ,1 , data, numbytes, false); +/* +* According to EEPROM spec there is a MAX of 10 ms required for +* EEPROM to flush internal RX buffer after STOP was issued at the +* end of write transaction. During this time the EEPROM will not be +* responsive to any more commands - so wait a bit more. +*/ +msleep (10 ); + + }else +dev_err (adev->dev,"sienna_cichlid_i2c_write- error occurred :%x" , ret); + +return ret; +} + +static int sienna_cichlid_i2c_xfer (struct i2c_adapter *i2c_adap, +struct i2c_msg *msgs,int num) +{ +uint32_t i, j, ret, data_size, data_chunk_size, next_eeprom_addr =0 ; +uint8_t *data_ptr, data_chunk[MAX_SW_I2C_COMMANDS ] = {0 }; + +for (i =0 ; i < num; i++) { +/* +* SMU interface allows at most MAX_SW_I2C_COMMANDS bytes of data at +* once and hence the data needs to be spliced into chunks and sent each +* chunk separately +*/ + data_size = msgs[i].len -2 ; + data_chunk_size =MAX_SW_I2C_COMMANDS -2 ; + next_eeprom_addr = (msgs[i].buf[0 ] <<8 &0xff00 ) | (msgs[i].buf[1 ] &0xff ); + data_ptr = msgs[i].buf +2 ; + +for (j =0 ; j < data_size / data_chunk_size; j++) { +/* Insert the EEPROM dest addess, bits 0-15 */ + data_chunk[0 ] = ((next_eeprom_addr >>8 ) &0xff ); + data_chunk[1 ] = (next_eeprom_addr &0xff ); + +if (msgs[i].flags &I2C_M_RD ) { + ret =sienna_cichlid_i2c_read_data (i2c_adap, + (uint8_t )msgs[i].addr, + data_chunk,MAX_SW_I2C_COMMANDS ); + +memcpy (data_ptr, data_chunk +2 , data_chunk_size); + }else { + +memcpy (data_chunk +2 , data_ptr, data_chunk_size); + + ret =sienna_cichlid_i2c_write_data (i2c_adap, + (uint8_t )msgs[i].addr, + data_chunk,MAX_SW_I2C_COMMANDS ); + } + +if (ret) { + num = -EIO ; + goto fail; + } + + next_eeprom_addr += data_chunk_size; + data_ptr += data_chunk_size; + } + +if (data_size % data_chunk_size) { + data_chunk[0 ] = ((next_eeprom_addr >>8 ) &0xff ); + data_chunk[1 ] = (next_eeprom_addr &0xff ); + +if (msgs[i].flags &I2C_M_RD ) { + ret =sienna_cichlid_i2c_read_data (i2c_adap, + (uint8_t )msgs[i].addr, + data_chunk, (data_size % data_chunk_size) +2 ); + +memcpy (data_ptr, data_chunk +2 , data_size % data_chunk_size); + }else { +memcpy (data_chunk +2 , data_ptr, data_size % data_chunk_size); + + ret =sienna_cichlid_i2c_write_data (i2c_adap, + (uint8_t )msgs[i].addr, + data_chunk, (data_size % data_chunk_size) +2 ); + } + +if (ret) { + num = -EIO ; + goto fail; + } + } + } + +fail: +return num; +} + +static u32 sienna_cichlid_i2c_func (struct i2c_adapter *adap) +{ +return I2C_FUNC_I2C |I2C_FUNC_SMBUS_EMUL ; +} + + +static const struct i2c_algorithm sienna_cichlid_i2c_algo = { + .master_xfer = sienna_cichlid_i2c_xfer, + .functionality = sienna_cichlid_i2c_func, +}; + +static bool sienna_cichlid_i2c_adapter_is_added (struct i2c_adapter *control) +{ +struct amdgpu_device *adev =to_amdgpu_device (control); + +return control->dev.parent == &adev->pdev->dev; +} + +static int sienna_cichlid_i2c_control_init (struct smu_context *smu,struct i2c_adapter *control) +{ +struct amdgpu_device *adev =to_amdgpu_device (control); +int res; + +/* smu_i2c_eeprom_init may be called twice in sriov */ +if (sienna_cichlid_i2c_adapter_is_added (control)) +return 0 ; + + control->owner =THIS_MODULE ; + control->class =I2C_CLASS_SPD ; + control->dev.parent = &adev->pdev->dev; + control->algo = &sienna_cichlid_i2c_algo; +snprintf (control->name,sizeof (control->name),"AMDGPU SMU" ); + + res =i2c_add_adapter (control); +if (res) +DRM_ERROR ("Failed to register hw i2c, err: %d\n" , res); + +return res; +} + +static void sienna_cichlid_i2c_control_fini (struct smu_context *smu,struct i2c_adapter *control) +{ +if (!sienna_cichlid_i2c_adapter_is_added (control)) +return ; + +i2c_del_adapter (control); +} + +static const struct pptable_funcs sienna_cichlid_ppt_funcs = { .tables_init = sienna_cichlid_tables_init, .alloc_dpm_context = sienna_cichlid_allocate_dpm_context,
drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c static const struct pptable_funcs sienna_cichlid_ppt_funcs = { · line 2744
Quoted 8 lines
drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c +2
-0@@ -2500,6 +2737,8 @@ static const struct pptable_funcs sienna_cichlid_ppt_funcs = { .set_default_dpm_table = sienna_cichlid_set_default_dpm_table, .dpm_set_vcn_enable = sienna_cichlid_dpm_set_vcn_enable, .dpm_set_jpeg_enable = sienna_cichlid_dpm_set_jpeg_enable, + .i2c_init = sienna_cichlid_i2c_control_init, + .i2c_fini = sienna_cichlid_i2c_control_fini, .print_clk_levels = sienna_cichlid_print_clk_levels, .force_clk_levels = sienna_cichlid_force_clk_levels, .populate_umd_state_clk = sienna_cichlid_populate_umd_state_clk,
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx