@@ -226,6 +226,31 @@ static const struct regmap_config i2c_regmap_config = {
226226 .fast_io = true,
227227};
228228
229+ void xe_i2c_pm_suspend (struct xe_device * xe )
230+ {
231+ struct xe_mmio * mmio = xe_root_tile_mmio (xe );
232+
233+ if (!xe -> i2c || xe -> i2c -> ep .cookie != XE_I2C_EP_COOKIE_DEVICE )
234+ return ;
235+
236+ xe_mmio_rmw32 (mmio , I2C_CONFIG_PMCSR , PCI_PM_CTRL_STATE_MASK , (__force u32 )PCI_D3hot );
237+ drm_dbg (& xe -> drm , "pmcsr: 0x%08x\n" , xe_mmio_read32 (mmio , I2C_CONFIG_PMCSR ));
238+ }
239+
240+ void xe_i2c_pm_resume (struct xe_device * xe , bool d3cold )
241+ {
242+ struct xe_mmio * mmio = xe_root_tile_mmio (xe );
243+
244+ if (!xe -> i2c || xe -> i2c -> ep .cookie != XE_I2C_EP_COOKIE_DEVICE )
245+ return ;
246+
247+ if (d3cold )
248+ xe_mmio_rmw32 (mmio , I2C_CONFIG_CMD , 0 , PCI_COMMAND_MEMORY );
249+
250+ xe_mmio_rmw32 (mmio , I2C_CONFIG_PMCSR , PCI_PM_CTRL_STATE_MASK , (__force u32 )PCI_D0 );
251+ drm_dbg (& xe -> drm , "pmcsr: 0x%08x\n" , xe_mmio_read32 (mmio , I2C_CONFIG_PMCSR ));
252+ }
253+
229254static void xe_i2c_remove (void * data )
230255{
231256 struct xe_i2c * i2c = data ;
@@ -270,6 +295,10 @@ int xe_i2c_probe(struct xe_device *xe)
270295 i2c -> mmio = xe_root_tile_mmio (xe );
271296 i2c -> drm_dev = drm_dev ;
272297 i2c -> ep = ep ;
298+ xe -> i2c = i2c ;
299+
300+ /* PCI PM isn't aware of this device, bring it up and match it with SGUnit state. */
301+ xe_i2c_pm_resume (xe , true);
273302
274303 regmap = devm_regmap_init (drm_dev , NULL , i2c , & i2c_regmap_config );
275304 if (IS_ERR (regmap ))
0 commit comments