[PATCH v1] drm/xe/i2c: Introduce xe_i2c_present()
Riana Tauro
riana.tauro at intel.com
Wed Aug 13 05:58:31 UTC 2025
On 8/12/2025 6:35 PM, Heikki Krogerus wrote:
> On Tue, Aug 12, 2025 at 05:56:46PM +0530, Raag Jadav wrote:
>> In preparation of wider usecases which require checking for I2C
>> controller presence, introduce xe_i2c_present() helper.
>>
>> Suggested-by: Riana Tauro <riana.tauro at intel.com>
>> Signed-off-by: Raag Jadav <raag.jadav at intel.com>
>
> LGTM. FWIW:
>
> Reviewed-by: Heikki Krogerus <heikki.krogerus at linux.intel.com>
>
>> ---
>> drivers/gpu/drm/xe/xe_i2c.c | 18 ++++++++++++++++--
>> drivers/gpu/drm/xe/xe_i2c.h | 2 ++
>> 2 files changed, 18 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_i2c.c b/drivers/gpu/drm/xe/xe_i2c.c
>> index bc7dc2099470..6534ec5de6dc 100644
>> --- a/drivers/gpu/drm/xe/xe_i2c.c
>> +++ b/drivers/gpu/drm/xe/xe_i2c.c
>> @@ -146,6 +146,20 @@ static void xe_i2c_unregister_adapter(struct xe_i2c *i2c)
>> fwnode_remove_software_node(i2c->adapter_node);
>> }
>>
>> +/**
>> + * xe_i2c_present: I2C controller is present and functional
>> + * @xe: xe device instance
'-' instead of ':' according to kernel-doc guidelines
With that change
Reviewed-by: Riana Tauro <riana.tauro at intel.com>
>> + *
>> + * Check whether the I2C controller is present and functioning with valid
>> + * endpoint cookie.
>> + *
>> + * Return: %true if present, %false otherwise.
>> + */
>> +bool xe_i2c_present(struct xe_device *xe)
>> +{
>> + return xe->i2c && xe->i2c->ep.cookie == XE_I2C_EP_COOKIE_DEVICE;
>> +}
>> +
>> /**
>> * xe_i2c_irq_handler: Handler for I2C interrupts
>> * @xe: xe device instance
>> @@ -230,7 +244,7 @@ void xe_i2c_pm_suspend(struct xe_device *xe)
>> {
>> struct xe_mmio *mmio = xe_root_tile_mmio(xe);
>>
>> - if (!xe->i2c || xe->i2c->ep.cookie != XE_I2C_EP_COOKIE_DEVICE)
>> + if (!xe_i2c_present(xe))
>> return;
>>
>> xe_mmio_rmw32(mmio, I2C_CONFIG_PMCSR, PCI_PM_CTRL_STATE_MASK, (__force u32)PCI_D3hot);
>> @@ -241,7 +255,7 @@ void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold)
>> {
>> struct xe_mmio *mmio = xe_root_tile_mmio(xe);
>>
>> - if (!xe->i2c || xe->i2c->ep.cookie != XE_I2C_EP_COOKIE_DEVICE)
>> + if (!xe_i2c_present(xe))
>> return;
>>
>> if (d3cold)
>> diff --git a/drivers/gpu/drm/xe/xe_i2c.h b/drivers/gpu/drm/xe/xe_i2c.h
>> index b767ed8ce52b..ecd5f10358e2 100644
>> --- a/drivers/gpu/drm/xe/xe_i2c.h
>> +++ b/drivers/gpu/drm/xe/xe_i2c.h
>> @@ -49,11 +49,13 @@ struct xe_i2c {
>>
>> #if IS_ENABLED(CONFIG_I2C)
>> int xe_i2c_probe(struct xe_device *xe);
>> +bool xe_i2c_present(struct xe_device *xe);
>> void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl);
>> void xe_i2c_pm_suspend(struct xe_device *xe);
>> void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold);
>> #else
>> static inline int xe_i2c_probe(struct xe_device *xe) { return 0; }
>> +static inline bool xe_i2c_present(struct xe_device *xe) { return false; }
>> static inline void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl) { }
>> static inline void xe_i2c_pm_suspend(struct xe_device *xe) { }
>> static inline void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold) { }
>> --
>> 2.34.1
>
More information about the Intel-xe
mailing list