Skip to content

Commit

Permalink
Merge tag 'i2c-for-6.4-rc1-part2' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/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
  • Loading branch information
torvalds committed May 6, 2023
2 parents c12753d + 1bd9228 commit a5e2190
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 55 deletions.
35 changes: 0 additions & 35 deletions Documentation/devicetree/bindings/i2c/brcm,kona-i2c.txt

This file was deleted.

59 changes: 59 additions & 0 deletions Documentation/devicetree/bindings/i2c/brcm,kona-i2c.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/i2c/brcm,kona-i2c.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Broadcom Kona family I2C controller

maintainers:
- Florian Fainelli <[email protected]>

allOf:
- $ref: /schemas/i2c/i2c-controller.yaml#

properties:
compatible:
items:
- enum:
- brcm,bcm11351-i2c
- brcm,bcm21664-i2c
- brcm,bcm23550-i2c
- const: brcm,kona-i2c

reg:
maxItems: 1

interrupts:
maxItems: 1

clocks:
maxItems: 1

clock-frequency:
enum: [ 100000, 400000, 1000000, 3400000 ]

required:
- compatible
- reg
- interrupts
- clocks
- clock-frequency

unevaluatedProperties: false

examples:
- |
#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/interrupt-controller/irq.h>
i2c@3e016000 {
compatible = "brcm,bcm11351-i2c", "brcm,kona-i2c";
reg = <0x3e016000 0x80>;
interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&bsc1_clk>;
clock-frequency = <400000>;
#address-cells = <1>;
#size-cells = <0>;
};
...
2 changes: 0 additions & 2 deletions drivers/i2c/busses/i2c-gxp.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ static void gxp_i2c_chk_data_ack(struct gxp_i2c_drvdata *drvdata)
writew(value, drvdata->base + GXP_I2CMCMD);
}

#if IS_ENABLED(CONFIG_I2C_SLAVE)
static bool gxp_i2c_slave_irq_handler(struct gxp_i2c_drvdata *drvdata)
{
u8 value;
Expand Down Expand Up @@ -437,7 +436,6 @@ static bool gxp_i2c_slave_irq_handler(struct gxp_i2c_drvdata *drvdata)

return true;
}
#endif

static irqreturn_t gxp_i2c_irq_handler(int irq, void *_drvdata)
{
Expand Down
4 changes: 2 additions & 2 deletions drivers/i2c/busses/i2c-imx-lpi2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ static int __maybe_unused lpi2c_runtime_suspend(struct device *dev)
{
struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev);

clk_bulk_disable_unprepare(lpi2c_imx->num_clks, lpi2c_imx->clks);
clk_bulk_disable(lpi2c_imx->num_clks, lpi2c_imx->clks);
pinctrl_pm_select_sleep_state(dev);

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

pinctrl_pm_select_default_state(dev);
ret = clk_bulk_prepare_enable(lpi2c_imx->num_clks, lpi2c_imx->clks);
ret = clk_bulk_enable(lpi2c_imx->num_clks, lpi2c_imx->clks);
if (ret) {
dev_err(dev, "failed to enable I2C clock, ret=%d\n", ret);
return ret;
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/busses/i2c-omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ omap_i2c_isr(int irq, void *dev_id)
u16 stat;

stat = omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG);
mask = omap_i2c_read_reg(omap, OMAP_I2C_IE_REG);
mask = omap_i2c_read_reg(omap, OMAP_I2C_IE_REG) & ~OMAP_I2C_STAT_NACK;

if (stat & mask)
ret = IRQ_WAKE_THREAD;
Expand Down
40 changes: 27 additions & 13 deletions drivers/i2c/busses/i2c-tegra.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,10 @@ struct tegra_i2c_hw_feature {
* @is_dvc: identifies the DVC I2C controller, has a different register layout
* @is_vi: identifies the VI I2C controller, has a different register layout
* @msg_complete: transfer completion notifier
* @msg_buf_remaining: size of unsent data in the message buffer
* @msg_len: length of message in current transfer
* @msg_err: error code for completed message
* @msg_buf: pointer to current message data
* @msg_buf_remaining: size of unsent data in the message buffer
* @msg_read: indicates that the transfer is a read access
* @timings: i2c timings information like bus frequency
* @multimaster_mode: indicates that I2C controller is in multi-master mode
Expand Down Expand Up @@ -277,6 +278,7 @@ struct tegra_i2c_dev {

struct completion msg_complete;
size_t msg_buf_remaining;
unsigned int msg_len;
int msg_err;
u8 *msg_buf;

Expand Down Expand Up @@ -1169,7 +1171,7 @@ static void tegra_i2c_push_packet_header(struct tegra_i2c_dev *i2c_dev,
else
i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO);

packet_header = msg->len - 1;
packet_header = i2c_dev->msg_len - 1;

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

i2c_dev->msg_buf = msg->buf;
i2c_dev->msg_len = msg->len;

/* The condition true implies smbus block read and len is already read */
if (msg->flags & I2C_M_RECV_LEN && end_state != MSG_END_CONTINUE)
i2c_dev->msg_buf = msg->buf + 1;

i2c_dev->msg_buf_remaining = msg->len;
i2c_dev->msg_err = I2C_ERR_NONE;
i2c_dev->msg_read = !!(msg->flags & I2C_M_RD);
reinit_completion(&i2c_dev->msg_complete);

/*
* For SMBUS block read command, read only 1 byte in the first transfer.
* Adjust that 1 byte for the next transfer in the msg buffer and msg
* length.
*/
if (msg->flags & I2C_M_RECV_LEN) {
if (end_state == MSG_END_CONTINUE) {
i2c_dev->msg_len = 1;
} else {
i2c_dev->msg_buf += 1;
i2c_dev->msg_len -= 1;
}
}

i2c_dev->msg_buf_remaining = i2c_dev->msg_len;

if (i2c_dev->msg_read)
xfer_size = msg->len;
xfer_size = i2c_dev->msg_len;
else
xfer_size = msg->len + I2C_PACKET_HEADER_SIZE;
xfer_size = i2c_dev->msg_len + I2C_PACKET_HEADER_SIZE;

xfer_size = ALIGN(xfer_size, BYTES_PER_FIFO_WORD);

Expand Down Expand Up @@ -1295,7 +1309,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
if (!i2c_dev->msg_read) {
if (i2c_dev->dma_mode) {
memcpy(i2c_dev->dma_buf + I2C_PACKET_HEADER_SIZE,
msg->buf, msg->len);
msg->buf, i2c_dev->msg_len);

dma_sync_single_for_device(i2c_dev->dma_dev,
i2c_dev->dma_phys,
Expand Down Expand Up @@ -1352,7 +1366,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
i2c_dev->dma_phys,
xfer_size, DMA_FROM_DEVICE);

memcpy(i2c_dev->msg_buf, i2c_dev->dma_buf, msg->len);
memcpy(i2c_dev->msg_buf, i2c_dev->dma_buf, i2c_dev->msg_len);
}
}

Expand Down Expand Up @@ -1408,8 +1422,8 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i], MSG_END_CONTINUE);
if (ret)
break;
/* Set the read byte as msg len */
msgs[i].len = msgs[i].buf[0];
/* Set the msg length from first byte */
msgs[i].len += msgs[i].buf[0];
dev_dbg(i2c_dev->dev, "reading %d bytes\n", msgs[i].len);
}
ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i], end_type);
Expand Down
4 changes: 2 additions & 2 deletions include/linux/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ static inline void i2c_set_clientdata(struct i2c_client *client, void *data)

/* I2C slave support */

#if IS_ENABLED(CONFIG_I2C_SLAVE)
enum i2c_slave_event {
I2C_SLAVE_READ_REQUESTED,
I2C_SLAVE_WRITE_REQUESTED,
Expand All @@ -396,9 +395,10 @@ enum i2c_slave_event {

int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb);
int i2c_slave_unregister(struct i2c_client *client);
bool i2c_detect_slave_mode(struct device *dev);
int i2c_slave_event(struct i2c_client *client,
enum i2c_slave_event event, u8 *val);
#if IS_ENABLED(CONFIG_I2C_SLAVE)
bool i2c_detect_slave_mode(struct device *dev);
#else
static inline bool i2c_detect_slave_mode(struct device *dev) { return false; }
#endif
Expand Down

0 comments on commit a5e2190

Please sign in to comment.