@@ -113,6 +113,9 @@
#define DW_IC_STATUS_MASTER_ACTIVITY BIT(5)
#define DW_IC_STATUS_SLAVE_ACTIVITY BIT(6)
+#define DW_IC_ENABLE_ENABLE BIT(0)
+#define DW_IC_ENABLE_SAR_EN BIT(19)
+
#define DW_IC_SDA_HOLD_RX_SHIFT 16
#define DW_IC_SDA_HOLD_RX_MASK GENMASK(23, 16)
@@ -333,13 +336,19 @@ void i2c_dw_disable(struct dw_i2c_dev *dev);
static inline void __i2c_dw_enable(struct dw_i2c_dev *dev)
{
+ u32 enabled;
+
dev->status |= STATUS_ACTIVE;
- regmap_write(dev->map, DW_IC_ENABLE, 1);
+ regmap_read(dev->map, DW_IC_ENABLE, &enabled);
+ regmap_write(dev->map, DW_IC_ENABLE, enabled | DW_IC_ENABLE_ENABLE);
}
static inline void __i2c_dw_disable_nowait(struct dw_i2c_dev *dev)
{
- regmap_write(dev->map, DW_IC_ENABLE, 0);
+ u32 enabled;
+
+ regmap_read(dev->map, DW_IC_ENABLE, &enabled);
+ regmap_write(dev->map, DW_IC_ENABLE, enabled & DW_IC_ENABLE_SAR_EN);
dev->status &= ~STATUS_ACTIVE;
}
@@ -719,7 +719,7 @@ static irqreturn_t i2c_dw_isr(int this_irq, void *dev_id)
regmap_read(dev->map, DW_IC_ENABLE, &enabled);
regmap_read(dev->map, DW_IC_RAW_INTR_STAT, &stat);
- if (!enabled || !(stat & ~DW_IC_INTR_ACTIVITY))
+ if (!(enabled & DW_IC_ENABLE_ENABLE) || !(stat & ~DW_IC_INTR_ACTIVITY))
return IRQ_NONE;
if (pm_runtime_suspended(dev->dev) || stat == GENMASK(31, 0))
return IRQ_NONE;
@@ -158,7 +158,8 @@ static irqreturn_t i2c_dw_isr_slave(int this_irq, void *dev_id)
regmap_read(dev->map, DW_IC_STATUS, &tmp);
slave_activity = ((tmp & DW_IC_STATUS_SLAVE_ACTIVITY) >> 6);
- if (!enabled || !(raw_stat & ~DW_IC_INTR_ACTIVITY) || !dev->slave)
+ if (!(enabled & DW_IC_ENABLE_ENABLE) ||
+ !(raw_stat & ~DW_IC_INTR_ACTIVITY) || !dev->slave)
return IRQ_NONE;
stat = i2c_dw_read_clear_intrbits_slave(dev);