Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+91 -55
-35
Documentation/devicetree/bindings/i2c/brcm,kona-i2c.txt
··· 1 - Broadcom Kona Family I2C 2 - ========================= 3 - 4 - This I2C controller is used in the following Broadcom SoCs: 5 - 6 - BCM11130 7 - BCM11140 8 - BCM11351 9 - BCM28145 10 - BCM28155 11 - 12 - Required Properties 13 - ------------------- 14 - - compatible: "brcm,bcm11351-i2c", "brcm,kona-i2c" 15 - - reg: Physical base address and length of controller registers 16 - - interrupts: The interrupt number used by the controller 17 - - clocks: clock specifier for the kona i2c external clock 18 - - clock-frequency: The I2C bus frequency in Hz 19 - - #address-cells: Should be <1> 20 - - #size-cells: Should be <0> 21 - 22 - Refer to clocks/clock-bindings.txt for generic clock consumer 23 - properties. 24 - 25 - Example: 26 - 27 - i2c@3e016000 { 28 - compatible = "brcm,bcm11351-i2c","brcm,kona-i2c"; 29 - reg = <0x3e016000 0x80>; 30 - interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>; 31 - clocks = <&bsc1_clk>; 32 - clock-frequency = <400000>; 33 - #address-cells = <1>; 34 - #size-cells = <0>; 35 - };
+59
Documentation/devicetree/bindings/i2c/brcm,kona-i2c.yaml
··· 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 + ...
-2
drivers/i2c/busses/i2c-gxp.c
··· 353 353 writew(value, drvdata->base + GXP_I2CMCMD); 354 354 } 355 355 356 - #if IS_ENABLED(CONFIG_I2C_SLAVE) 357 356 static bool gxp_i2c_slave_irq_handler(struct gxp_i2c_drvdata *drvdata) 358 357 { 359 358 u8 value; ··· 436 437 437 438 return true; 438 439 } 439 - #endif 440 440 441 441 static irqreturn_t gxp_i2c_irq_handler(int irq, void *_drvdata) 442 442 {
+2 -2
drivers/i2c/busses/i2c-imx-lpi2c.c
··· 639 639 { 640 640 struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev); 641 641 642 - clk_bulk_disable_unprepare(lpi2c_imx->num_clks, lpi2c_imx->clks); 642 + clk_bulk_disable(lpi2c_imx->num_clks, lpi2c_imx->clks); 643 643 pinctrl_pm_select_sleep_state(dev); 644 644 645 645 return 0; ··· 651 651 int ret; 652 652 653 653 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); 655 655 if (ret) { 656 656 dev_err(dev, "failed to enable I2C clock, ret=%d\n", ret); 657 657 return ret;
+1 -1
drivers/i2c/busses/i2c-omap.c
··· 1058 1058 u16 stat; 1059 1059 1060 1060 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; 1062 1062 1063 1063 if (stat & mask) 1064 1064 ret = IRQ_WAKE_THREAD;
+27 -13
drivers/i2c/busses/i2c-tegra.c
··· 242 242 * @is_dvc: identifies the DVC I2C controller, has a different register layout 243 243 * @is_vi: identifies the VI I2C controller, has a different register layout 244 244 * @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 245 247 * @msg_err: error code for completed message 246 248 * @msg_buf: pointer to current message data 247 - * @msg_buf_remaining: size of unsent data in the message buffer 248 249 * @msg_read: indicates that the transfer is a read access 249 250 * @timings: i2c timings information like bus frequency 250 251 * @multimaster_mode: indicates that I2C controller is in multi-master mode ··· 278 277 279 278 struct completion msg_complete; 280 279 size_t msg_buf_remaining; 280 + unsigned int msg_len; 281 281 int msg_err; 282 282 u8 *msg_buf; 283 283 ··· 1171 1169 else 1172 1170 i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO); 1173 1171 1174 - packet_header = msg->len - 1; 1172 + packet_header = i2c_dev->msg_len - 1; 1175 1173 1176 1174 if (i2c_dev->dma_mode && !i2c_dev->msg_read) 1177 1175 *dma_buf++ = packet_header; ··· 1244 1242 return err; 1245 1243 1246 1244 i2c_dev->msg_buf = msg->buf; 1245 + i2c_dev->msg_len = msg->len; 1247 1246 1248 - /* The condition true implies smbus block read and len is already read */ 1249 - if (msg->flags & I2C_M_RECV_LEN && end_state != MSG_END_CONTINUE) 1250 - i2c_dev->msg_buf = msg->buf + 1; 1251 - 1252 - i2c_dev->msg_buf_remaining = msg->len; 1253 1247 i2c_dev->msg_err = I2C_ERR_NONE; 1254 1248 i2c_dev->msg_read = !!(msg->flags & I2C_M_RD); 1255 1249 reinit_completion(&i2c_dev->msg_complete); 1256 1250 1251 + /* 1252 + * For SMBUS block read command, read only 1 byte in the first transfer. 1253 + * Adjust that 1 byte for the next transfer in the msg buffer and msg 1254 + * length. 1255 + */ 1256 + if (msg->flags & I2C_M_RECV_LEN) { 1257 + if (end_state == MSG_END_CONTINUE) { 1258 + i2c_dev->msg_len = 1; 1259 + } else { 1260 + i2c_dev->msg_buf += 1; 1261 + i2c_dev->msg_len -= 1; 1262 + } 1263 + } 1264 + 1265 + i2c_dev->msg_buf_remaining = i2c_dev->msg_len; 1266 + 1257 1267 if (i2c_dev->msg_read) 1258 - xfer_size = msg->len; 1268 + xfer_size = i2c_dev->msg_len; 1259 1269 else 1260 - xfer_size = msg->len + I2C_PACKET_HEADER_SIZE; 1270 + xfer_size = i2c_dev->msg_len + I2C_PACKET_HEADER_SIZE; 1261 1271 1262 1272 xfer_size = ALIGN(xfer_size, BYTES_PER_FIFO_WORD); 1263 1273 ··· 1309 1295 if (!i2c_dev->msg_read) { 1310 1296 if (i2c_dev->dma_mode) { 1311 1297 memcpy(i2c_dev->dma_buf + I2C_PACKET_HEADER_SIZE, 1312 - msg->buf, msg->len); 1298 + msg->buf, i2c_dev->msg_len); 1313 1299 1314 1300 dma_sync_single_for_device(i2c_dev->dma_dev, 1315 1301 i2c_dev->dma_phys, ··· 1366 1352 i2c_dev->dma_phys, 1367 1353 xfer_size, DMA_FROM_DEVICE); 1368 1354 1369 - memcpy(i2c_dev->msg_buf, i2c_dev->dma_buf, msg->len); 1355 + memcpy(i2c_dev->msg_buf, i2c_dev->dma_buf, i2c_dev->msg_len); 1370 1356 } 1371 1357 } 1372 1358 ··· 1422 1408 ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i], MSG_END_CONTINUE); 1423 1409 if (ret) 1424 1410 break; 1425 - /* Set the read byte as msg len */ 1426 - msgs[i].len = msgs[i].buf[0]; 1411 + /* Set the msg length from first byte */ 1412 + msgs[i].len += msgs[i].buf[0]; 1427 1413 dev_dbg(i2c_dev->dev, "reading %d bytes\n", msgs[i].len); 1428 1414 } 1429 1415 ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i], end_type);
+2 -2
include/linux/i2c.h
··· 385 385 386 386 /* I2C slave support */ 387 387 388 - #if IS_ENABLED(CONFIG_I2C_SLAVE) 389 388 enum i2c_slave_event { 390 389 I2C_SLAVE_READ_REQUESTED, 391 390 I2C_SLAVE_WRITE_REQUESTED, ··· 395 396 396 397 int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb); 397 398 int i2c_slave_unregister(struct i2c_client *client); 398 - bool i2c_detect_slave_mode(struct device *dev); 399 399 int i2c_slave_event(struct i2c_client *client, 400 400 enum i2c_slave_event event, u8 *val); 401 + #if IS_ENABLED(CONFIG_I2C_SLAVE) 402 + bool i2c_detect_slave_mode(struct device *dev); 401 403 #else 402 404 static inline bool i2c_detect_slave_mode(struct device *dev) { return false; } 403 405 #endif