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

Merge tag 'i2c-for-6.17-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull more i2c updates from Wolfram Sang:
"A few more patches from I2C. Some are fixes which would be nice to
have in rc1 already, some patches have nearly been fallen through the
cracks, some just needed a bit more testing.

- acpi: enable 100kHz workaround for DLL0945

- apple: add support for Apple A7–A11, T2 chips; Kconfig update

- mux: mule: fix error handling path

- qcom-geni: fix controller frequency mapping

- stm32f7: add DMA-safe transfer support

- tegra: use controller reset if device reset is missing

- tegra: remove unnecessary dma_sync*() calls"

* tag 'i2c-for-6.17-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
i2c: muxes: mule: Fix an error handling path in mule_i2c_mux_probe()
i2c: Force DLL0945 touchpad i2c freq to 100khz
i2c: apple: Drop default ARCH_APPLE in Kconfig
i2c: qcom-geni: fix I2C frequency table to achieve accurate bus rates
dt-bindings: i2c: apple,i2c: Document Apple A7-A11, T2 compatibles
i2c: tegra: Remove dma_sync_*() calls
i2c: tegra: Use internal reset when reset property is not available
i2c: stm32f7: support i2c_*_dma_safe_msg_buf APIs

+75 -37
+5
Documentation/devicetree/bindings/i2c/apple,i2c.yaml
··· 22 22 compatible: 23 23 items: 24 24 - enum: 25 + - apple,s5l8960x-i2c 26 + - apple,t7000-i2c 27 + - apple,s8000-i2c 28 + - apple,t8010-i2c 29 + - apple,t8015-i2c 25 30 - apple,t8103-i2c 26 31 - apple,t8112-i2c 27 32 - apple,t6000-i2c
-1
drivers/i2c/busses/Kconfig
··· 992 992 tristate "Apple SMBus platform driver" 993 993 depends on !I2C_PASEMI 994 994 depends on ARCH_APPLE || COMPILE_TEST 995 - default ARCH_APPLE 996 995 help 997 996 Say Y here if you want to use the I2C controller present on Apple 998 997 Silicon chips such as the M1.
+3 -3
drivers/i2c/busses/i2c-qcom-geni.c
··· 155 155 156 156 /* source_clock = 32 MHz */ 157 157 static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = { 158 - { I2C_MAX_STANDARD_MODE_FREQ, 8, 14, 18, 40 }, 159 - { I2C_MAX_FAST_MODE_FREQ, 4, 3, 11, 20 }, 160 - { I2C_MAX_FAST_MODE_PLUS_FREQ, 2, 3, 6, 15 }, 158 + { I2C_MAX_STANDARD_MODE_FREQ, 8, 14, 18, 38 }, 159 + { I2C_MAX_FAST_MODE_FREQ, 4, 3, 9, 19 }, 160 + { I2C_MAX_FAST_MODE_PLUS_FREQ, 2, 3, 5, 15 }, 161 161 {} 162 162 }; 163 163
+21 -11
drivers/i2c/busses/i2c-stm32f7.c
··· 742 742 { 743 743 struct stm32f7_i2c_dev *i2c_dev = arg; 744 744 struct stm32_i2c_dma *dma = i2c_dev->dma; 745 + struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg; 745 746 746 747 stm32f7_i2c_disable_dma_req(i2c_dev); 747 748 dmaengine_terminate_async(dma->chan_using); 748 749 dma_unmap_single(i2c_dev->dev, dma->dma_buf, dma->dma_len, 749 750 dma->dma_data_dir); 751 + if (!f7_msg->smbus) 752 + i2c_put_dma_safe_msg_buf(f7_msg->buf, i2c_dev->msg, true); 750 753 complete(&dma->dma_complete); 751 754 } 752 755 ··· 885 882 { 886 883 struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg; 887 884 void __iomem *base = i2c_dev->base; 885 + u8 *dma_buf; 888 886 u32 cr1, cr2; 889 887 int ret; 890 888 ··· 935 931 936 932 /* Configure DMA or enable RX/TX interrupt */ 937 933 i2c_dev->use_dma = false; 938 - if (i2c_dev->dma && f7_msg->count >= STM32F7_I2C_DMA_LEN_MIN 939 - && !i2c_dev->atomic) { 940 - ret = stm32_i2c_prep_dma_xfer(i2c_dev->dev, i2c_dev->dma, 941 - msg->flags & I2C_M_RD, 942 - f7_msg->count, f7_msg->buf, 943 - stm32f7_i2c_dma_callback, 944 - i2c_dev); 945 - if (!ret) 946 - i2c_dev->use_dma = true; 947 - else 948 - dev_warn(i2c_dev->dev, "can't use DMA\n"); 934 + if (i2c_dev->dma && !i2c_dev->atomic) { 935 + dma_buf = i2c_get_dma_safe_msg_buf(msg, STM32F7_I2C_DMA_LEN_MIN); 936 + if (dma_buf) { 937 + f7_msg->buf = dma_buf; 938 + ret = stm32_i2c_prep_dma_xfer(i2c_dev->dev, i2c_dev->dma, 939 + msg->flags & I2C_M_RD, 940 + f7_msg->count, f7_msg->buf, 941 + stm32f7_i2c_dma_callback, 942 + i2c_dev); 943 + if (ret) { 944 + dev_warn(i2c_dev->dev, "can't use DMA\n"); 945 + i2c_put_dma_safe_msg_buf(f7_msg->buf, msg, false); 946 + f7_msg->buf = msg->buf; 947 + } else { 948 + i2c_dev->use_dma = true; 949 + } 950 + } 949 951 } 950 952 951 953 if (!i2c_dev->use_dma) {
+44 -20
drivers/i2c/busses/i2c-tegra.c
··· 134 134 #define I2C_MST_FIFO_STATUS_TX GENMASK(23, 16) 135 135 #define I2C_MST_FIFO_STATUS_RX GENMASK(7, 0) 136 136 137 + #define I2C_MASTER_RESET_CNTRL 0x0a8 138 + 137 139 /* configuration load timeout in microseconds */ 138 140 #define I2C_CONFIG_LOAD_TIMEOUT 1000000 139 141 ··· 186 184 * @has_mst_fifo: The I2C controller contains the new MST FIFO interface that 187 185 * provides additional features and allows for longer messages to 188 186 * be transferred in one go. 187 + * @has_mst_reset: The I2C controller contains MASTER_RESET_CTRL register which 188 + * provides an alternative to controller reset when configured as 189 + * I2C master 189 190 * @quirks: I2C adapter quirks for limiting write/read transfer size and not 190 191 * allowing 0 length transfers. 191 192 * @supports_bus_clear: Bus Clear support to recover from bus hang during ··· 218 213 bool has_multi_master_mode; 219 214 bool has_slcg_override_reg; 220 215 bool has_mst_fifo; 216 + bool has_mst_reset; 221 217 const struct i2c_adapter_quirks *quirks; 222 218 bool supports_bus_clear; 223 219 bool has_apb_dma; ··· 611 605 return 0; 612 606 } 613 607 608 + static int tegra_i2c_master_reset(struct tegra_i2c_dev *i2c_dev) 609 + { 610 + if (!i2c_dev->hw->has_mst_reset) 611 + return -EOPNOTSUPP; 612 + 613 + /* 614 + * Writing 1 to I2C_MASTER_RESET_CNTRL will reset all internal state of 615 + * Master logic including FIFOs. Clear this bit to 0 for normal operation. 616 + * SW needs to wait for 2us after assertion and de-assertion of this soft 617 + * reset. 618 + */ 619 + i2c_writel(i2c_dev, 0x1, I2C_MASTER_RESET_CNTRL); 620 + fsleep(2); 621 + 622 + i2c_writel(i2c_dev, 0x0, I2C_MASTER_RESET_CNTRL); 623 + fsleep(2); 624 + 625 + return 0; 626 + } 627 + 614 628 static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) 615 629 { 616 630 u32 val, clk_divisor, clk_multiplier, tsu_thd, tlow, thigh, non_hs_mode; 617 631 struct i2c_timings *t = &i2c_dev->timings; 618 632 int err; 633 + 634 + /* 635 + * Reset the controller before initializing it. 636 + * In case if device_reset() returns -ENOENT, i.e. when the reset is 637 + * not available, the internal software reset will be used if it is 638 + * supported by the controller. 639 + */ 640 + err = device_reset(i2c_dev->dev); 641 + if (err == -ENOENT) 642 + err = tegra_i2c_master_reset(i2c_dev); 619 643 620 644 /* 621 645 * The reset shouldn't ever fail in practice. The failure will be a ··· 655 619 * emit a noisy warning on error, which won't stay unnoticed and 656 620 * won't hose machine entirely. 657 621 */ 658 - err = device_reset(i2c_dev->dev); 659 622 WARN_ON_ONCE(err); 660 623 661 624 if (IS_DVC(i2c_dev)) ··· 1301 1266 1302 1267 if (i2c_dev->dma_mode) { 1303 1268 if (i2c_dev->msg_read) { 1304 - dma_sync_single_for_device(i2c_dev->dma_dev, 1305 - i2c_dev->dma_phys, 1306 - xfer_size, DMA_FROM_DEVICE); 1307 - 1308 1269 err = tegra_i2c_dma_submit(i2c_dev, xfer_size); 1309 1270 if (err) 1310 1271 return err; 1311 - } else { 1312 - dma_sync_single_for_cpu(i2c_dev->dma_dev, 1313 - i2c_dev->dma_phys, 1314 - xfer_size, DMA_TO_DEVICE); 1315 1272 } 1316 1273 } 1317 1274 ··· 1313 1286 if (i2c_dev->dma_mode) { 1314 1287 memcpy(i2c_dev->dma_buf + I2C_PACKET_HEADER_SIZE, 1315 1288 msg->buf, i2c_dev->msg_len); 1316 - 1317 - dma_sync_single_for_device(i2c_dev->dma_dev, 1318 - i2c_dev->dma_phys, 1319 - xfer_size, DMA_TO_DEVICE); 1320 - 1321 1289 err = tegra_i2c_dma_submit(i2c_dev, xfer_size); 1322 1290 if (err) 1323 1291 return err; ··· 1353 1331 return -ETIMEDOUT; 1354 1332 } 1355 1333 1356 - if (i2c_dev->msg_read && i2c_dev->msg_err == I2C_ERR_NONE) { 1357 - dma_sync_single_for_cpu(i2c_dev->dma_dev, 1358 - i2c_dev->dma_phys, 1359 - xfer_size, DMA_FROM_DEVICE); 1360 - 1334 + if (i2c_dev->msg_read && i2c_dev->msg_err == I2C_ERR_NONE) 1361 1335 memcpy(i2c_dev->msg_buf, i2c_dev->dma_buf, i2c_dev->msg_len); 1362 - } 1363 1336 } 1364 1337 1365 1338 time_left = tegra_i2c_wait_completion(i2c_dev, &i2c_dev->msg_complete, ··· 1485 1468 .has_multi_master_mode = false, 1486 1469 .has_slcg_override_reg = false, 1487 1470 .has_mst_fifo = false, 1471 + .has_mst_reset = false, 1488 1472 .quirks = &tegra_i2c_quirks, 1489 1473 .supports_bus_clear = false, 1490 1474 .has_apb_dma = true, ··· 1510 1492 .has_multi_master_mode = false, 1511 1493 .has_slcg_override_reg = false, 1512 1494 .has_mst_fifo = false, 1495 + .has_mst_reset = false, 1513 1496 .quirks = &tegra_i2c_quirks, 1514 1497 .supports_bus_clear = false, 1515 1498 .has_apb_dma = true, ··· 1535 1516 .has_multi_master_mode = false, 1536 1517 .has_slcg_override_reg = false, 1537 1518 .has_mst_fifo = false, 1519 + .has_mst_reset = false, 1538 1520 .quirks = &tegra_i2c_quirks, 1539 1521 .supports_bus_clear = true, 1540 1522 .has_apb_dma = true, ··· 1560 1540 .has_multi_master_mode = false, 1561 1541 .has_slcg_override_reg = true, 1562 1542 .has_mst_fifo = false, 1543 + .has_mst_reset = false, 1563 1544 .quirks = &tegra_i2c_quirks, 1564 1545 .supports_bus_clear = true, 1565 1546 .has_apb_dma = true, ··· 1585 1564 .has_multi_master_mode = false, 1586 1565 .has_slcg_override_reg = true, 1587 1566 .has_mst_fifo = false, 1567 + .has_mst_reset = false, 1588 1568 .quirks = &tegra_i2c_quirks, 1589 1569 .supports_bus_clear = true, 1590 1570 .has_apb_dma = true, ··· 1610 1588 .has_multi_master_mode = false, 1611 1589 .has_slcg_override_reg = true, 1612 1590 .has_mst_fifo = false, 1591 + .has_mst_reset = false, 1613 1592 .quirks = &tegra_i2c_quirks, 1614 1593 .supports_bus_clear = true, 1615 1594 .has_apb_dma = false, ··· 1635 1612 .has_multi_master_mode = true, 1636 1613 .has_slcg_override_reg = true, 1637 1614 .has_mst_fifo = true, 1615 + .has_mst_reset = true, 1638 1616 .quirks = &tegra194_i2c_quirks, 1639 1617 .supports_bus_clear = true, 1640 1618 .has_apb_dma = false,
+1
drivers/i2c/i2c-core-acpi.c
··· 370 370 * the device works without issues on Windows at what is expected to be 371 371 * a 400KHz frequency. The root cause of the issue is not known. 372 372 */ 373 + { "DLL0945", 0 }, 373 374 { "ELAN06FA", 0 }, 374 375 {} 375 376 };
+1 -2
drivers/i2c/muxes/i2c-mux-mule.c
··· 47 47 struct mule_i2c_reg_mux *priv; 48 48 struct i2c_client *client; 49 49 struct i2c_mux_core *muxc; 50 - struct device_node *dev; 51 50 unsigned int readback; 52 51 int ndev, ret; 53 52 bool old_fw; ··· 94 95 "Failed to register mux remove\n"); 95 96 96 97 /* Create device adapters */ 97 - for_each_child_of_node(mux_dev->of_node, dev) { 98 + for_each_child_of_node_scoped(mux_dev->of_node, dev) { 98 99 u32 reg; 99 100 100 101 ret = of_property_read_u32(dev, "reg", &reg);