Re: [PATCH v4 3/3] drm/xe/i2c: Keep the i2c controller always enabled

From: Heikki Krogerus

Date: Wed Jul 15 2026 - 05:48:52 EST


On Wed, Jul 15, 2026 at 08:33:31AM +0200, Raag Jadav wrote:
> > +/* See "Disabling DW_apb_i2c" in the DesignWare DW_abp_i2c databook. */
> > +static void xe_i2c_disable(struct xe_i2c *i2c)
> > +{
> > + int timeout = 100;
> > + u32 status;
> > +
> > + xe_mmio_rmw32(i2c->mmio, I2C_REG(DW_IC_ENABLE), 1, 0);
>
> Can we use DW_IC_ENABLE_* defines?
>
> > + do {
> > + status = xe_mmio_read32(i2c->mmio, I2C_REG(DW_IC_ENABLE_STATUS));
> > + if (!(status & 1))
>
> Ditto for DW_IC_STATUS_*.
>
> > + return;
> > + /* Can't sleep here. */
> > + udelay(25);
> > + } while (timeout--);
> > +
> > + dev_warn(&i2c->adapter->dev, "timeout in disabling adapter\n");
> > +}
>
> ...
>
> > @@ -230,7 +260,28 @@ static int xe_i2c_write(void *context, unsigned int reg, unsigned int val)
> > {
> > struct xe_i2c *i2c = context;
> >
> > - xe_mmio_write32(i2c->mmio, XE_REG(reg + I2C_MEM_SPACE_OFFSET), val);
> > + switch (reg) {
> > + case DW_IC_CON:
> > + case DW_IC_TAR:
> > + case DW_IC_SAR:
> > + /* Disable the controller. */
> > + xe_i2c_disable(i2c);
> > +
> > + /* Write the register. */
> > + xe_mmio_write32(i2c->mmio, I2C_REG(reg), val);
> > +
> > + /* Enable the controller. */
> > + xe_mmio_rmw32(i2c->mmio, I2C_REG(DW_IC_ENABLE), 0, 1);
>
> Ditto.

Yes to all three. I'll fix these.

Thanks,

--
heikki