aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
Commit message (Collapse)AuthorAgeFilesLines
...
| | | * i2c: iproc: Fix indentation of bcm_iproc_i2c_slave_init()Andi Shyti2025-05-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adjust the indentation of the bcm_iproc_i2c_slave_init() function definition to match standard kernel coding style. Don't end the line with an open parenthesis. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: iproc: Replace udelay() with usleep_range()Andi Shyti2025-05-191-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace udelay(100) with usleep_range(100, 200) as recommended by kernel documentation. The delay is not in atomic context, so busy-waiting is unnecessary. Also update the comment for clarity. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: iproc: Remove stray blank line in slave ISRAndi Shyti2025-05-191-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Drop an unnecessary blank line in bcm_iproc_i2c_slave_isr(). Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: iproc: Fix alignment to match the open parenthesisAndi Shyti2025-05-191-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Alignment should match the open parenthesis but in some places it didn't Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: iproc: Use u32 instead of uint32_tAndi Shyti2025-05-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In the kernel u32 should be used instead of unit32_t. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: iproc: Use dev_err_probe in probeAndi Shyti2025-05-191-19/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Use dev_err_probe() instead of dev_err() and then return. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: iproc: Drop unnecessary initialisation of 'ret'Andi Shyti2025-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'ret' variable doesn't need to be initialised, as it is always assigned before use. While here, reorder the variable declarations in reverse Christmas tree style, by line length. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: amd-isp: Add ISP i2c-designware driverPratap Nirujogi2025-05-193-0/+216
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The camera sensor is connected via ISP I2C bus in AMD SOC architectures. Add new I2C designware driver to support new camera sensors on AMD HW. Co-developed-by: Venkata Narendra Kumar Gutta <[email protected]> Signed-off-by: Venkata Narendra Kumar Gutta <[email protected]> Co-developed-by: Bin Du <[email protected]> Signed-off-by: Bin Du <[email protected]> Signed-off-by: Pratap Nirujogi <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: octeon: add block-mode i2c operationsAryan Srivastava2025-05-193-7/+175
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add functions to perform block read and write operations. This applies for cases where the requested operation is for >8 bytes of data. When not using the block mode transfer, the driver will attempt a series of 8 byte i2c operations until it reaches the desired total. For example, for a 40 byte request the driver will complete 5 separate transactions. This results in large transactions taking a significant amount of time to process. Add block mode such that the driver can request larger transactions, up to 1024 bytes per transfer. Many aspects of the block mode transfer is common with the regular 8 byte operations. Use generic functions for parts of the message construction and sending the message. The key difference for the block mode is the usage of separate FIFO buffer to store data. Write to this buffer in the case of a write (before command send). Read from this buffer in the case of a read (after command send). Data is written into this buffer by placing data into the MSB onwards. This means the bottom 8 bits of the data will match the top 8 bits, and so on and so forth. Set specific bits in message for block mode, enable block mode transfers from global i2c management registers, construct message, send message, read or write from FIFO buffer as required. The block-mode transactions result in a significant speed increase in large i2c requests. Signed-off-by: Aryan Srivastava <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: pasemi: Sort includes alphabeticallySven Peter2025-05-192-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No functional changes. Signed-off-by: Sven Peter <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Neal Gompa <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: pasemi: Use correct bits.h includeSven Peter2025-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When changing the #defines to use BIT and GENMASK the bitfield.h include was added instead of the correct bits.h include. Reported-by: Andy Shevchenko <[email protected]> Signed-off-by: Sven Peter <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Neal Gompa <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: designware: Use better constants from units.hAndy Shevchenko2025-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we use constants in a time or frequency related contexts, it's better to utilise the respective definitions that have encoded units in them. This will make code better to read and understand. Signed-off-by: Andy Shevchenko <[email protected]> Acked-by: Jarkko Nikula <[email protected]> Acked-by: Mukesh Kumar Savaliya <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: scx200_acb: Replace dev_err() with dev_err_probe() in probe functionEnrico Zanda2025-05-191-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This simplifies the code while improving log. Signed-off-by: Enrico Zanda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: i2c-xiic: Replace dev_err() with dev_err_probe() in probe functionEnrico Zanda2025-05-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This simplifies the code while improving log. Signed-off-by: Enrico Zanda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: virtio: Replace dev_err() with dev_err_probe() in probe functionEnrico Zanda2025-05-191-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This simplifies the code while improving log. Signed-off-by: Enrico Zanda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: viperboard: Replace dev_err() with dev_err_probe() in probe functionEnrico Zanda2025-05-191-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This simplifies the code while improving log. Signed-off-by: Enrico Zanda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: viapro: Replace dev_err() with dev_err_probe() in probe functionEnrico Zanda2025-05-191-18/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This simplifies the code while improving log. Signed-off-by: Enrico Zanda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: via: Replace dev_err() with dev_err_probe() in probe functionEnrico Zanda2025-05-191-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This simplifies the code while improving log. Signed-off-by: Enrico Zanda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: uniphier: Replace dev_err() with dev_err_probe() in probe functionEnrico Zanda2025-05-191-16/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This simplifies the code while improving log. Signed-off-by: Enrico Zanda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: uniphier(-f): Replace dev_err() with dev_err_probe() in probe functionEnrico Zanda2025-05-191-16/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This simplifies the code while improving log. Signed-off-by: Enrico Zanda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: npcm: Add clock toggle recoveryTali Perry2025-05-191-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During init of the bus, the module checks that the bus is idle. If one of the lines are stuck try to recover them first before failing. Sometimes SDA and SCL are low if improper reset occurs (e.g., reboot). Signed-off-by: Tali Perry <[email protected]> Signed-off-by: Mohammed Elbadry <[email protected]> Reviewed-by: Mukesh Kumar Savaliya <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: rzv2m: Constify struct i2c_algorithmChristophe JAILLET2025-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 'struct i2c_algorithm' is not modified in this driver. Constifying this structure moves some data to a read-only section, so increase overall security, especially when the structure holds some function pointers. On a x86_64, with allmodconfig, as an example: Before: ====== text data bss dec hex filename 11027 646 16 11689 2da9 drivers/i2c/busses/i2c-rzv2m.o After: ===== text data bss dec hex filename 11107 566 16 11689 2da9 drivers/i2c/busses/i2c-rzv2m.o Signed-off-by: Christophe JAILLET <[email protected]> Reviewed-by: Fabrizio Castro <[email protected]> Link: https://lore.kernel.org/r/537d93441ced53bffa6553b8ec93d007e64cb9a5.1743258995.git.christophe.jaillet@wanadoo.fr Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: imx: add some dev_err_probe callsAlexander Stein2025-05-191-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add corresponding error messages if DMA channels are not available during probe. Using dev_err_probe adds deferred probe messages as well. Signed-off-by: Alexander Stein <[email protected]> Reviewed-by: Frank Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: xgene-slimpro: Simplify PCC shared memory region handlingSudeep Holla2025-05-191-35/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The PCC driver now handles mapping and unmapping of shared memory areas as part of pcc_mbox_{request,free}_channel(). Without these before, this xgene-slimpro I2C driver did handling of those mappings like several other PCC mailbox client drivers. There were redundant operations, leading to unnecessary code. Maintaining the consistency across these driver was harder due to scattered handling of shmem. Just use the mapped shmem and remove all redundant operations from this driver. Cc: Andi Shyti <[email protected]> Cc: [email protected] Signed-off-by: Sudeep Holla <[email protected]> Acked-by: Andi Shyti <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: lpc2k: Add check for clk_enable()Chenyuan Yang2025-05-191-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add check for the return value of clk_enable() to catch the potential error. This is similar to the commit 8332e6670997 ("spi: zynq-qspi: Add check for clk_enable()"). Signed-off-by: Chenyuan Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: npcm7xx: Remove redundant ret variableZhang Songyi2025-05-191-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Return value from npcm_i2c_get_slave_addr() directly instead of taking this in another redundant variable. This improvement has been suggested by Zeal Robot <[email protected]> Signed-off-by: Zhang Songyi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | | * i2c: qcom-geni: Use generic definitions for bus frequenciesAndy Shevchenko2025-05-191-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since we have generic definitions for bus frequencies, let's use them. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Christopher Obbard <[email protected]> Reviewed-by: Mukesh Kumar Savaliya <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
| | * | i2c: atr: add passthrough flagCosmin Tanislav2025-05-221-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some I2C ATRs can have other I2C ATRs as children. The I2C messages of the child ATRs need to be forwarded as-is if the parent I2C ATR can only do static mapping. In the case of GMSL, the deserializer I2C ATR actually doesn't have I2C address remapping hardware capabilities, but it is able to select which GMSL link to talk to, allowing it to change the address of the serializer. The child ATRs need to have their alias pools defined in such a way to prevent overlapping addresses between them, but there's no way around this without orchestration between multiple ATR instances. To allow for this use-case, add a flag that allows unmapped addresses to be passed through, since they are already remapped by the child ATRs. There's no case where an address that has not been remapped by the child ATR will hit the parent ATR. Signed-off-by: Cosmin Tanislav <[email protected]> Reviewed-by: Luca Ceresoli <[email protected]> Reviewed-by: Romain Gantois <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: atr: add static flagCosmin Tanislav2025-05-221-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some I2C ATRs do not support dynamic remapping, only static mapping of direct children. Mappings will only be added or removed as a result of devices being added or removed from a child bus. The ATR pool will have to be big enough to accommodate all devices expected to be added to the child buses. Add a new flag that prevents old mappings to be replaced or new mappings to be created in the alias finding code paths. That mens adding a flags parameter to i2c_atr_new() and an i2c_atr_flags enum. Signed-off-by: Cosmin Tanislav <[email protected]> Reviewed-by: Luca Ceresoli <[email protected]> Reviewed-by: Romain Gantois <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: atr: allow replacing mappings in attach_addr()Cosmin Tanislav2025-05-221-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is possible for aliases to be exhausted while we are still attaching children. Allow replacing mapping on attach by calling i2c_atr_replace_mapping_by_addr() if i2c_atr_create_mapping_by_addr() fails. Signed-off-by: Cosmin Tanislav <[email protected]> Reviewed-by: Luca Ceresoli <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: atr: deduplicate logic in attach_addr()Cosmin Tanislav2025-05-221-24/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the same logic as in i2c_atr_create_mapping_by_addr(). Signed-off-by: Cosmin Tanislav <[email protected]> Reviewed-by: Luca Ceresoli <[email protected]> Reviewed-by: Romain Gantois <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: atr: do not create mapping in detach_addr()Cosmin Tanislav2025-05-221-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is useless to create a new mapping just to detach it immediately. Use the newly added i2c_atr_find_mapping_by_addr() function to avoid it, and exit without logging an error if not found. Signed-off-by: Cosmin Tanislav <[email protected]> Reviewed-by: Luca Ceresoli <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: atr: split up i2c_atr_get_mapping_by_addr()Cosmin Tanislav2025-05-221-35/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The i2c_atr_get_mapping_by_addr() function handles three separate usecases: finding an existing mapping, creating a new mapping, or replacing an existing mapping if a new mapping cannot be created because there aren't enough aliases available. Split up the function into three different functions handling its individual usecases to prepare for better usage of each one. Signed-off-by: Cosmin Tanislav <[email protected]> Reviewed-by: Luca Ceresoli <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: atr: find_mapping() -> get_mapping()Cosmin Tanislav2025-05-221-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A find operation implies that a null result is not an error. Use get naming to clarify things and to prepare for splitting up the logic inside this function. Signed-off-by: Cosmin Tanislav <[email protected]> Reviewed-by: Luca Ceresoli <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: atr: Fix lockdep for nested ATRsTomi Valkeinen2025-05-221-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we have an ATR, and another ATR as a subdevice of the first ATR, we get lockdep warnings for the i2c_atr.lock and i2c_atr_chan.orig_addrs_lock. This is because lockdep uses a static key for the locks, and doesn't see the locks of the separate ATR instances as separate. Fix this by generating a dynamic lock key per lock instance. Signed-off-by: Tomi Valkeinen <[email protected]> Signed-off-by: Cosmin Tanislav <[email protected]> Reviewed-by: Luca Ceresoli <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: use only 'fwnode' for client devicesWolfram Sang2025-05-201-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No client sets 'of_node' anymore, so we don't need to handle the case in the core anymore. Reviewed-by: Andi Shyti <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: powermac: convert of_node usage to fwnodeWolfram Sang2025-05-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 'of_node' in i2c_boardinfo is deprecated in favor of 'fwnode'. The I2C core handles them equally, so simply convert this driver to fwnode. Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: core: add useful info when defer probeXu Yang2025-05-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an useful info when failed to get irq/wakeirq due to -EPROBE_DEFER. Before: [ 15.737361] i2c 2-0050: deferred probe pending: (reason unknown) After: [ 15.816295] i2c 2-0050: deferred probe pending: tcpci: can't get irq Signed-off-by: Xu Yang <[email protected]> Reviewed-by: Carlos Song <[email protected]> Reviewed-by: Frank Li <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: atr: Fix end of loop test in i2c_atr_find_mapping_by_addr()Dan Carpenter2025-05-021-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the list_for_each_entry_reverse() exits without hitting a break then the list cursor points to invalid memory. So this check for if (c2a->fixed) is checking bogus memory. Fix it by using a "found" variable to track if we found what we were looking for or not. The list head (i2c_atr_chan.alias_pairs) is not a full entry, it's just a struct list_head. When the for loop runs to completion, c2a doesn't point to a struct i2c_atr_alias_pair, so you can't access c2a->fixed. Fixes: c3f55241882b ("i2c: Support dynamic address translation") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Reviewed-by: Romain Gantois <[email protected]> Reviewed-by: Luca Ceresoli <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: mux: ltc4306: use new GPIO line value setter callbacksBartosz Golaszewski2025-04-241-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them. Signed-off-by: Bartosz Golaszewski <[email protected]> Acked-by: Peter Rosin <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: Support dynamic address translationRomain Gantois2025-04-181-61/+188
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The i2c-atr module keeps a list of associations between I2C client aliases and I2C addresses. This represents the address translation table which is programmed into an ATR channel at any given time. This list is only updated when a new client is bound to the channel. However in some cases, an ATR channel can have more downstream clients than available aliases. One example of this is an SFP module that is bound to an FPC202 port. The FPC202 port can only access up to two logical I2C addresses. However, the SFP module may expose up to three logical I2C addresses: its EEPROM on 7-bit addresses 0x50 and 0x51, and a PHY transceiver on address 0x56. In cases like these, it is necessary to reconfigure the channel's translation table on the fly, so that all three I2C addresses can be accessed when needed. As there are currently no known ATR's which do not support dynamic address translation, this feature can be enabled by default without breaking existing use cases. Modify the i2c-atr module to provide on-the-fly address translation. This is achieved by modifying an ATR channel's translation table whenever an I2C transaction with unmapped clients is requested. Add a mutex to protect alias_list. This prevents i2c_atr_dynamic_attach/detach_addr from racing with the bus notifier handler to modify alias_list. Tested-by: Tomi Valkeinen <[email protected]> Signed-off-by: Romain Gantois <[email protected]> Acked-by: Andi Shyti <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: support per-channel ATR alias poolsRomain Gantois2025-04-181-22/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some I2C address translators (ATRs) assign each of their remote peripheral aliases to a specific channel. To properly handle these devices, add support for having separate alias pools for each ATR channel. This is achieved by allowing callers of i2c_atr_add_adapter to pass an optional alias list. If present, this list will be used to populate the channel's alias pool. Otherwise, the common alias pool will be used. Tested-by: Tomi Valkeinen <[email protected]> Signed-off-by: Romain Gantois <[email protected]> Acked-by: Andi Shyti <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: rename field 'alias_list' of struct i2c_atr_chan to 'alias_pairs'Romain Gantois2025-04-181-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "alias_list" field of struct i2c_atr_chan describes translation table entries programmed in the ATR channel. This terminology will become more confusing when per-channel alias pool support is introduced, as struct i2c_atr_chan will gain a new field called "alias_pool", which will describe aliases which are available to the ATR channel. Rename the "alias_list" field to "alias_pairs" to clearly distinguish it from the future "alias_pool" field. No functional change is intended. Tested-by: Tomi Valkeinen <[email protected]> Signed-off-by: Romain Gantois <[email protected]> Acked-by: Andi Shyti <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: move ATR alias pool to a separate structRomain Gantois2025-04-181-65/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Each I2C address translator (ATR) has a pool of client aliases which can be used as translation targets. Some ATRs have a single alias pool shared by all downstream channels, while others have a separate alias pool for each channel. Currently, this alias pool is represented by the "aliases", "num_aliases", and "use_mask" fields of struct i2c_atr. In preparation for adding per-channel alias pool support, move the "aliases", "num_aliases", "use_mask" and associated lock to a new struct called "struct alias_pool". Tested-by: Tomi Valkeinen <[email protected]> Signed-off-by: Romain Gantois <[email protected]> Acked-by: Andi Shyti <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: use client addresses directly in ATR interfaceRomain Gantois2025-04-181-33/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The I2C Address Translator (ATR) module defines mappings from i2c_client structs to aliases. However, only the physical address of each i2c_client struct is actually relevant to the workings of the ATR module. Moreover, some drivers require address translation functionality but do not allocate i2c_client structs, accessing the adapter directly instead. The SFP subsystem is an example of this. Replace the "i2c_client" field of the i2c_atr_alias_pair struct with a u16 "addr" field. Rewrite helper functions and callbacks as needed. Reviewed-by: Tomi Valkeinen <[email protected]> Tested-by: Tomi Valkeinen <[email protected]> Signed-off-by: Romain Gantois <[email protected]> Acked-by: Andi Shyti <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: core: Do not dereference fwnode in struct deviceAndy Shevchenko2025-04-162-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to make the underneath API easier to change in the future, prevent users from dereferencing fwnode from struct device. Instead, use the specific device_set_node() API for that. Tested-by: Tomi Valkeinen <[email protected]> Reviewed-by: Sakari Ailus <[email protected]> Acked-by: Sakari Ailus <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: core: Reuse fwnode variable where it makes senseAndy Shevchenko2025-04-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reuse fwnode variable where it makes sense. This avoids unneeded duplication hidden in some macros and unifies the code for different types of fwnode. Tested-by: Tomi Valkeinen <[email protected]> Reviewed-by: Sakari Ailus <[email protected]> Acked-by: Sakari Ailus <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: core: Switch to fwnode APIs to get IRQAndy Shevchenko2025-04-161-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Switch to fwnode APIs to get IRQ. In particular this enables a support of the separate wakeup IRQ on non-OF platforms. The rest is converted just for the sake of consistency and fwnode reuse. Tested-by: Tomi Valkeinen <[email protected]> Reviewed-by: Sakari Ailus <[email protected]> Acked-by: Sakari Ailus <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: core: Unify the firmware node type checkAndy Shevchenko2025-04-162-10/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OF and ACPI currently are using asymmetrical APIs to check for the firmware node type. Unify them by using is_*_node() against struct fwnode_handle pointer. Tested-by: Tomi Valkeinen <[email protected]> Reviewed-by: Sakari Ailus <[email protected]> Acked-by: Sakari Ailus <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
| | * | i2c: core: Drop duplicate check before calling OF APIsAndy Shevchenko2025-04-161-11/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OF APIs are usually NULL-aware and return an error in case when device node is not present or supported. We already have a check for the returned value, no need to check for the parameter. Tested-by: Tomi Valkeinen <[email protected]> Reviewed-by: Sakari Ailus <[email protected]> Acked-by: Sakari Ailus <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>