Skip to content

Commit a5e2190

Browse files
committed
Merge tag 'i2c-for-6.4-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull more i2c updates from Wolfram Sang: "Some more driver bugfixes and a DT binding conversion" * tag 'i2c-for-6.4-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: dt-bindings: i2c: brcm,kona-i2c: convert to YAML i2c: gxp: fix build failure without CONFIG_I2C_SLAVE i2c: imx-lpi2c: avoid taking clk_prepare mutex in PM callbacks i2c: omap: Fix standard mode false ACK readings i2c: tegra: Fix PEC support for SMBUS block read
2 parents c12753d + 1bd9228 commit a5e2190

File tree

7 files changed

+91
-55
lines changed

7 files changed

+91
-55
lines changed

Documentation/devicetree/bindings/i2c/brcm,kona-i2c.txt

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/i2c/brcm,kona-i2c.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Broadcom Kona family I2C controller
8+
9+
maintainers:
10+
- Florian Fainelli <f.fainelli@gmail.com>
11+
12+
allOf:
13+
- $ref: /schemas/i2c/i2c-controller.yaml#
14+
15+
properties:
16+
compatible:
17+
items:
18+
- enum:
19+
- brcm,bcm11351-i2c
20+
- brcm,bcm21664-i2c
21+
- brcm,bcm23550-i2c
22+
- const: brcm,kona-i2c
23+
24+
reg:
25+
maxItems: 1
26+
27+
interrupts:
28+
maxItems: 1
29+
30+
clocks:
31+
maxItems: 1
32+
33+
clock-frequency:
34+
enum: [ 100000, 400000, 1000000, 3400000 ]
35+
36+
required:
37+
- compatible
38+
- reg
39+
- interrupts
40+
- clocks
41+
- clock-frequency
42+
43+
unevaluatedProperties: false
44+
45+
examples:
46+
- |
47+
#include <dt-bindings/interrupt-controller/arm-gic.h>
48+
#include <dt-bindings/interrupt-controller/irq.h>
49+
50+
i2c@3e016000 {
51+
compatible = "brcm,bcm11351-i2c", "brcm,kona-i2c";
52+
reg = <0x3e016000 0x80>;
53+
interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>;
54+
clocks = <&bsc1_clk>;
55+
clock-frequency = <400000>;
56+
#address-cells = <1>;
57+
#size-cells = <0>;
58+
};
59+
...

drivers/i2c/busses/i2c-gxp.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ static void gxp_i2c_chk_data_ack(struct gxp_i2c_drvdata *drvdata)
353353
writew(value, drvdata->base + GXP_I2CMCMD);
354354
}
355355

356-
#if IS_ENABLED(CONFIG_I2C_SLAVE)
357356
static bool gxp_i2c_slave_irq_handler(struct gxp_i2c_drvdata *drvdata)
358357
{
359358
u8 value;
@@ -437,7 +436,6 @@ static bool gxp_i2c_slave_irq_handler(struct gxp_i2c_drvdata *drvdata)
437436

438437
return true;
439438
}
440-
#endif
441439

442440
static irqreturn_t gxp_i2c_irq_handler(int irq, void *_drvdata)
443441
{

drivers/i2c/busses/i2c-imx-lpi2c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ static int __maybe_unused lpi2c_runtime_suspend(struct device *dev)
639639
{
640640
struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev);
641641

642-
clk_bulk_disable_unprepare(lpi2c_imx->num_clks, lpi2c_imx->clks);
642+
clk_bulk_disable(lpi2c_imx->num_clks, lpi2c_imx->clks);
643643
pinctrl_pm_select_sleep_state(dev);
644644

645645
return 0;
@@ -651,7 +651,7 @@ static int __maybe_unused lpi2c_runtime_resume(struct device *dev)
651651
int ret;
652652

653653
pinctrl_pm_select_default_state(dev);
654-
ret = clk_bulk_prepare_enable(lpi2c_imx->num_clks, lpi2c_imx->clks);
654+
ret = clk_bulk_enable(lpi2c_imx->num_clks, lpi2c_imx->clks);
655655
if (ret) {
656656
dev_err(dev, "failed to enable I2C clock, ret=%d\n", ret);
657657
return ret;

drivers/i2c/busses/i2c-omap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ omap_i2c_isr(int irq, void *dev_id)
10581058
u16 stat;
10591059

10601060
stat = omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG);
1061-
mask = omap_i2c_read_reg(omap, OMAP_I2C_IE_REG);
1061+
mask = omap_i2c_read_reg(omap, OMAP_I2C_IE_REG) & ~OMAP_I2C_STAT_NACK;
10621062

10631063
if (stat & mask)
10641064
ret = IRQ_WAKE_THREAD;

drivers/i2c/busses/i2c-tegra.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,10 @@ struct tegra_i2c_hw_feature {
242242
* @is_dvc: identifies the DVC I2C controller, has a different register layout
243243
* @is_vi: identifies the VI I2C controller, has a different register layout
244244
* @msg_complete: transfer completion notifier
245+
* @msg_buf_remaining: size of unsent data in the message buffer
246+
* @msg_len: length of message in current transfer
245247
* @msg_err: error code for completed message
246248
* @msg_buf: pointer to current message data
247-
* @msg_buf_remaining: size of unsent data in the message buffer
248249
* @msg_read: indicates that the transfer is a read access
249250
* @timings: i2c timings information like bus frequency
250251
* @multimaster_mode: indicates that I2C controller is in multi-master mode
@@ -277,6 +278,7 @@ struct tegra_i2c_dev {
277278

278279
struct completion msg_complete;
279280
size_t msg_buf_remaining;
281+
unsigned int msg_len;
280282
int msg_err;
281283
u8 *msg_buf;
282284

@@ -1169,7 +1171,7 @@ static void tegra_i2c_push_packet_header(struct tegra_i2c_dev *i2c_dev,
11691171
else
11701172
i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO);
11711173

1172-
packet_header = msg->len - 1;
1174+
packet_header = i2c_dev->msg_len - 1;
11731175

11741176
if (i2c_dev->dma_mode && !i2c_dev->msg_read)
11751177
*dma_buf++ = packet_header;
@@ -1242,20 +1244,32 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
12421244
return err;
12431245

12441246
i2c_dev->msg_buf = msg->buf;
1247+
i2c_dev->msg_len = msg->len;
12451248

1246-
/* The condition true implies smbus block read and len is already read */
1247-
if (msg->flags & I2C_M_RECV_LEN && end_state != MSG_END_CONTINUE)
1248-
i2c_dev->msg_buf = msg->buf + 1;
1249-
1250-
i2c_dev->msg_buf_remaining = msg->len;
12511249
i2c_dev->msg_err = I2C_ERR_NONE;
12521250
i2c_dev->msg_read = !!(msg->flags & I2C_M_RD);
12531251
reinit_completion(&i2c_dev->msg_complete);
12541252

1253+
/*
1254+
* For SMBUS block read command, read only 1 byte in the first transfer.
1255+
* Adjust that 1 byte for the next transfer in the msg buffer and msg
1256+
* length.
1257+
*/
1258+
if (msg->flags & I2C_M_RECV_LEN) {
1259+
if (end_state == MSG_END_CONTINUE) {
1260+
i2c_dev->msg_len = 1;
1261+
} else {
1262+
i2c_dev->msg_buf += 1;
1263+
i2c_dev->msg_len -= 1;
1264+
}
1265+
}
1266+
1267+
i2c_dev->msg_buf_remaining = i2c_dev->msg_len;
1268+
12551269
if (i2c_dev->msg_read)
1256-
xfer_size = msg->len;
1270+
xfer_size = i2c_dev->msg_len;
12571271
else
1258-
xfer_size = msg->len + I2C_PACKET_HEADER_SIZE;
1272+
xfer_size = i2c_dev->msg_len + I2C_PACKET_HEADER_SIZE;
12591273

12601274
xfer_size = ALIGN(xfer_size, BYTES_PER_FIFO_WORD);
12611275

@@ -1295,7 +1309,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
12951309
if (!i2c_dev->msg_read) {
12961310
if (i2c_dev->dma_mode) {
12971311
memcpy(i2c_dev->dma_buf + I2C_PACKET_HEADER_SIZE,
1298-
msg->buf, msg->len);
1312+
msg->buf, i2c_dev->msg_len);
12991313

13001314
dma_sync_single_for_device(i2c_dev->dma_dev,
13011315
i2c_dev->dma_phys,
@@ -1352,7 +1366,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
13521366
i2c_dev->dma_phys,
13531367
xfer_size, DMA_FROM_DEVICE);
13541368

1355-
memcpy(i2c_dev->msg_buf, i2c_dev->dma_buf, msg->len);
1369+
memcpy(i2c_dev->msg_buf, i2c_dev->dma_buf, i2c_dev->msg_len);
13561370
}
13571371
}
13581372

@@ -1408,8 +1422,8 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
14081422
ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i], MSG_END_CONTINUE);
14091423
if (ret)
14101424
break;
1411-
/* Set the read byte as msg len */
1412-
msgs[i].len = msgs[i].buf[0];
1425+
/* Set the msg length from first byte */
1426+
msgs[i].len += msgs[i].buf[0];
14131427
dev_dbg(i2c_dev->dev, "reading %d bytes\n", msgs[i].len);
14141428
}
14151429
ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i], end_type);

include/linux/i2c.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ static inline void i2c_set_clientdata(struct i2c_client *client, void *data)
385385

386386
/* I2C slave support */
387387

388-
#if IS_ENABLED(CONFIG_I2C_SLAVE)
389388
enum i2c_slave_event {
390389
I2C_SLAVE_READ_REQUESTED,
391390
I2C_SLAVE_WRITE_REQUESTED,
@@ -396,9 +395,10 @@ enum i2c_slave_event {
396395

397396
int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb);
398397
int i2c_slave_unregister(struct i2c_client *client);
399-
bool i2c_detect_slave_mode(struct device *dev);
400398
int i2c_slave_event(struct i2c_client *client,
401399
enum i2c_slave_event event, u8 *val);
400+
#if IS_ENABLED(CONFIG_I2C_SLAVE)
401+
bool i2c_detect_slave_mode(struct device *dev);
402402
#else
403403
static inline bool i2c_detect_slave_mode(struct device *dev) { return false; }
404404
#endif

0 commit comments

Comments
 (0)