Skip to content

Commit 978df3e

Browse files
committed
Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang: "Some I2C driver bugfixes for 5.18. Nothing spectacular but worth fixing" * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: drivers: i2c: thunderx: Allow driver to work with ACPI defined TWSI controllers i2c: ismt: Provide a DMA buffer for Interrupt Cause Logging i2c: mt7621: fix missing clk_disable_unprepare() on error in mtk_i2c_probe()
2 parents eaea45f + 03a35bc commit 978df3e

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

drivers/i2c/busses/i2c-ismt.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282

8383
#define ISMT_DESC_ENTRIES 2 /* number of descriptor entries */
8484
#define ISMT_MAX_RETRIES 3 /* number of SMBus retries to attempt */
85+
#define ISMT_LOG_ENTRIES 3 /* number of interrupt cause log entries */
8586

8687
/* Hardware Descriptor Constants - Control Field */
8788
#define ISMT_DESC_CWRL 0x01 /* Command/Write Length */
@@ -175,6 +176,8 @@ struct ismt_priv {
175176
u8 head; /* ring buffer head pointer */
176177
struct completion cmp; /* interrupt completion */
177178
u8 buffer[I2C_SMBUS_BLOCK_MAX + 16]; /* temp R/W data buffer */
179+
dma_addr_t log_dma;
180+
u32 *log;
178181
};
179182

180183
static const struct pci_device_id ismt_ids[] = {
@@ -411,6 +414,9 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,
411414
memset(desc, 0, sizeof(struct ismt_desc));
412415
desc->tgtaddr_rw = ISMT_DESC_ADDR_RW(addr, read_write);
413416

417+
/* Always clear the log entries */
418+
memset(priv->log, 0, ISMT_LOG_ENTRIES * sizeof(u32));
419+
414420
/* Initialize common control bits */
415421
if (likely(pci_dev_msi_enabled(priv->pci_dev)))
416422
desc->control = ISMT_DESC_INT | ISMT_DESC_FAIR;
@@ -708,6 +714,8 @@ static void ismt_hw_init(struct ismt_priv *priv)
708714
/* initialize the Master Descriptor Base Address (MDBA) */
709715
writeq(priv->io_rng_dma, priv->smba + ISMT_MSTR_MDBA);
710716

717+
writeq(priv->log_dma, priv->smba + ISMT_GR_SMTICL);
718+
711719
/* initialize the Master Control Register (MCTRL) */
712720
writel(ISMT_MCTRL_MEIE, priv->smba + ISMT_MSTR_MCTRL);
713721

@@ -795,6 +803,12 @@ static int ismt_dev_init(struct ismt_priv *priv)
795803
priv->head = 0;
796804
init_completion(&priv->cmp);
797805

806+
priv->log = dmam_alloc_coherent(&priv->pci_dev->dev,
807+
ISMT_LOG_ENTRIES * sizeof(u32),
808+
&priv->log_dma, GFP_KERNEL);
809+
if (!priv->log)
810+
return -ENOMEM;
811+
798812
return 0;
799813
}
800814

drivers/i2c/busses/i2c-mt7621.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ static int mtk_i2c_probe(struct platform_device *pdev)
304304

305305
if (i2c->bus_freq == 0) {
306306
dev_warn(i2c->dev, "clock-frequency 0 not supported\n");
307-
return -EINVAL;
307+
ret = -EINVAL;
308+
goto err_disable_clk;
308309
}
309310

310311
adap = &i2c->adap;
@@ -322,10 +323,15 @@ static int mtk_i2c_probe(struct platform_device *pdev)
322323

323324
ret = i2c_add_adapter(adap);
324325
if (ret < 0)
325-
return ret;
326+
goto err_disable_clk;
326327

327328
dev_info(&pdev->dev, "clock %u kHz\n", i2c->bus_freq / 1000);
328329

330+
return 0;
331+
332+
err_disable_clk:
333+
clk_disable_unprepare(i2c->clk);
334+
329335
return ret;
330336
}
331337

drivers/i2c/busses/i2c-thunderx-pcidrv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ static int thunder_i2c_probe_pci(struct pci_dev *pdev,
213213
i2c->adap.bus_recovery_info = &octeon_i2c_recovery_info;
214214
i2c->adap.dev.parent = dev;
215215
i2c->adap.dev.of_node = pdev->dev.of_node;
216+
i2c->adap.dev.fwnode = dev->fwnode;
216217
snprintf(i2c->adap.name, sizeof(i2c->adap.name),
217218
"Cavium ThunderX i2c adapter at %s", dev_name(dev));
218219
i2c_set_adapdata(&i2c->adap, i2c);

0 commit comments

Comments
 (0)