Merge branch 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 29 Sep 2019 17:20:16 +0000 (10:20 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 29 Sep 2019 17:20:16 +0000 (10:20 -0700)
Pull  more i2c updates from Wolfram Sang:

 - make Lenovo Yoga C630 boot now that the dependencies are merged

 - restore BlockProcessCall for i801, accidently removed in this merge
   window

 - a bugfix for the riic driver

 - an improvement to the slave-eeprom driver which should have been in
   the first pull request but sadly got lost in the process

* 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
  i2c: slave-eeprom: Add read only mode
  i2c: i801: Bring back Block Process Call support for certain platforms
  i2c: riic: Clear NACK in tend isr
  i2c: qcom-geni: Disable DMA processing on the Lenovo Yoga C630

drivers/i2c/busses/i2c-i801.c
drivers/i2c/busses/i2c-qcom-geni.c
drivers/i2c/busses/i2c-riic.c
drivers/i2c/i2c-slave-eeprom.c

index c09791fb4929f904dafaba7aecbc3d89300011ca..f1c714acc2806eb1b78806a010b7df7d9a60baf5 100644 (file)
@@ -1736,6 +1736,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
        case PCI_DEVICE_ID_INTEL_LEWISBURG_SSKU_SMBUS:
        case PCI_DEVICE_ID_INTEL_DNV_SMBUS:
        case PCI_DEVICE_ID_INTEL_KABYLAKE_PCH_H_SMBUS:
+               priv->features |= FEATURE_BLOCK_PROC;
                priv->features |= FEATURE_I2C_BLOCK_READ;
                priv->features |= FEATURE_IRQ;
                priv->features |= FEATURE_SMBUS_PEC;
index a89bfce5388eeb4075b9afbcf0a5e7f2b8ff9876..17abf60c94aeb83402473c32d2dcc9685f63b049 100644 (file)
@@ -355,11 +355,13 @@ static int geni_i2c_rx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg,
 {
        dma_addr_t rx_dma;
        unsigned long time_left;
-       void *dma_buf;
+       void *dma_buf = NULL;
        struct geni_se *se = &gi2c->se;
        size_t len = msg->len;
 
-       dma_buf = i2c_get_dma_safe_msg_buf(msg, 32);
+       if (!of_machine_is_compatible("lenovo,yoga-c630"))
+               dma_buf = i2c_get_dma_safe_msg_buf(msg, 32);
+
        if (dma_buf)
                geni_se_select_mode(se, GENI_SE_DMA);
        else
@@ -394,11 +396,13 @@ static int geni_i2c_tx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg,
 {
        dma_addr_t tx_dma;
        unsigned long time_left;
-       void *dma_buf;
+       void *dma_buf = NULL;
        struct geni_se *se = &gi2c->se;
        size_t len = msg->len;
 
-       dma_buf = i2c_get_dma_safe_msg_buf(msg, 32);
+       if (!of_machine_is_compatible("lenovo,yoga-c630"))
+               dma_buf = i2c_get_dma_safe_msg_buf(msg, 32);
+
        if (dma_buf)
                geni_se_select_mode(se, GENI_SE_DMA);
        else
index f31413fd9521ef9f2cd60d478c915fe8ae215323..800414886f6b58151b3ac545f794f77db77b43bf 100644 (file)
@@ -202,6 +202,7 @@ static irqreturn_t riic_tend_isr(int irq, void *data)
        if (readb(riic->base + RIIC_ICSR2) & ICSR2_NACKF) {
                /* We got a NACKIE */
                readb(riic->base + RIIC_ICDRR); /* dummy read */
+               riic_clear_set_bit(riic, ICSR2_NACKF, 0, RIIC_ICSR2);
                riic->err = -ENXIO;
        } else if (riic->bytes_left) {
                return IRQ_NONE;
index 92ff9991bae81bd1390075e752b82395008c2f3d..db9763cb4dae326067e44733342c1829bc1c0626 100644 (file)
@@ -33,11 +33,13 @@ struct eeprom_data {
        u16 address_mask;
        u8 num_address_bytes;
        u8 idx_write_cnt;
+       bool read_only;
        u8 buffer[];
 };
 
 #define I2C_SLAVE_BYTELEN GENMASK(15, 0)
 #define I2C_SLAVE_FLAG_ADDR16 BIT(16)
+#define I2C_SLAVE_FLAG_RO BIT(17)
 #define I2C_SLAVE_DEVICE_MAGIC(_len, _flags) ((_flags) | (_len))
 
 static int i2c_slave_eeprom_slave_cb(struct i2c_client *client,
@@ -53,9 +55,11 @@ static int i2c_slave_eeprom_slave_cb(struct i2c_client *client,
                        eeprom->buffer_idx = *val | (eeprom->buffer_idx << 8);
                        eeprom->idx_write_cnt++;
                } else {
-                       spin_lock(&eeprom->buffer_lock);
-                       eeprom->buffer[eeprom->buffer_idx++ & eeprom->address_mask] = *val;
-                       spin_unlock(&eeprom->buffer_lock);
+                       if (!eeprom->read_only) {
+                               spin_lock(&eeprom->buffer_lock);
+                               eeprom->buffer[eeprom->buffer_idx++ & eeprom->address_mask] = *val;
+                               spin_unlock(&eeprom->buffer_lock);
+                       }
                }
                break;
 
@@ -130,6 +134,7 @@ static int i2c_slave_eeprom_probe(struct i2c_client *client, const struct i2c_de
        eeprom->idx_write_cnt = 0;
        eeprom->num_address_bytes = flag_addr16 ? 2 : 1;
        eeprom->address_mask = size - 1;
+       eeprom->read_only = FIELD_GET(I2C_SLAVE_FLAG_RO, id->driver_data);
        spin_lock_init(&eeprom->buffer_lock);
        i2c_set_clientdata(client, eeprom);
 
@@ -165,8 +170,11 @@ static int i2c_slave_eeprom_remove(struct i2c_client *client)
 
 static const struct i2c_device_id i2c_slave_eeprom_id[] = {
        { "slave-24c02", I2C_SLAVE_DEVICE_MAGIC(2048 / 8,  0) },
+       { "slave-24c02ro", I2C_SLAVE_DEVICE_MAGIC(2048 / 8,  I2C_SLAVE_FLAG_RO) },
        { "slave-24c32", I2C_SLAVE_DEVICE_MAGIC(32768 / 8, I2C_SLAVE_FLAG_ADDR16) },
+       { "slave-24c32ro", I2C_SLAVE_DEVICE_MAGIC(32768 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) },
        { "slave-24c64", I2C_SLAVE_DEVICE_MAGIC(65536 / 8, I2C_SLAVE_FLAG_ADDR16) },
+       { "slave-24c64ro", I2C_SLAVE_DEVICE_MAGIC(65536 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, i2c_slave_eeprom_id);