summaryrefslogtreecommitdiff
path: root/drivers/i2c
AgeCommit message (Collapse)Author
2025-05-19i2c: pasemi: Use correct bits.h includeSven Peter
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 <andy.shevchenko@gmail.com> Signed-off-by: Sven Peter <sven@svenpeter.dev> Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Neal Gompa <neal@gompa.dev> Link: https://lore.kernel.org/r/20250415-pasemi-fixes-v2-1-c543bf53151a@svenpeter.dev Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-19i2c: designware: Use better constants from units.hAndy Shevchenko
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 <andriy.shevchenko@linux.intel.com> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Acked-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com> Link: https://lore.kernel.org/r/20250416101702.2128740-1-andriy.shevchenko@linux.intel.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-19i2c: scx200_acb: Replace dev_err() with dev_err_probe() in probe functionEnrico Zanda
This simplifies the code while improving log. Signed-off-by: Enrico Zanda <e.zanda1@gmail.com> Link: https://lore.kernel.org/r/20250415183447.396277-11-e.zanda1@gmail.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-19i2c: i2c-xiic: Replace dev_err() with dev_err_probe() in probe functionEnrico Zanda
This simplifies the code while improving log. Signed-off-by: Enrico Zanda <e.zanda1@gmail.com> Link: https://lore.kernel.org/r/20250415183447.396277-10-e.zanda1@gmail.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-19i2c: virtio: Replace dev_err() with dev_err_probe() in probe functionEnrico Zanda
This simplifies the code while improving log. Signed-off-by: Enrico Zanda <e.zanda1@gmail.com> Link: https://lore.kernel.org/r/20250415183447.396277-8-e.zanda1@gmail.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-19i2c: viperboard: Replace dev_err() with dev_err_probe() in probe functionEnrico Zanda
This simplifies the code while improving log. Signed-off-by: Enrico Zanda <e.zanda1@gmail.com> Link: https://lore.kernel.org/r/20250415183447.396277-7-e.zanda1@gmail.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-19i2c: viapro: Replace dev_err() with dev_err_probe() in probe functionEnrico Zanda
This simplifies the code while improving log. Signed-off-by: Enrico Zanda <e.zanda1@gmail.com> Link: https://lore.kernel.org/r/20250415183447.396277-6-e.zanda1@gmail.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-19i2c: via: Replace dev_err() with dev_err_probe() in probe functionEnrico Zanda
This simplifies the code while improving log. Signed-off-by: Enrico Zanda <e.zanda1@gmail.com> Link: https://lore.kernel.org/r/20250415183447.396277-4-e.zanda1@gmail.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-19i2c: uniphier: Replace dev_err() with dev_err_probe() in probe functionEnrico Zanda
This simplifies the code while improving log. Signed-off-by: Enrico Zanda <e.zanda1@gmail.com> Link: https://lore.kernel.org/r/20250415183447.396277-3-e.zanda1@gmail.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-19i2c: uniphier(-f): Replace dev_err() with dev_err_probe() in probe functionEnrico Zanda
This simplifies the code while improving log. Signed-off-by: Enrico Zanda <e.zanda1@gmail.com> Link: https://lore.kernel.org/r/20250415183447.396277-2-e.zanda1@gmail.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-19i2c: npcm: Add clock toggle recoveryTali Perry
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 <tali.perry1@gmail.com> Signed-off-by: Mohammed Elbadry <mohammed.0.elbadry@gmail.com> Reviewed-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com> Link: https://lore.kernel.org/r/20250328193252.1570811-1-mohammed.0.elbadry@gmail.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-19i2c: rzv2m: Constify struct i2c_algorithmChristophe JAILLET
'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 <christophe.jaillet@wanadoo.fr> Reviewed-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Link: https://lore.kernel.org/r/537d93441ced53bffa6553b8ec93d007e64cb9a5.1743258995.git.christophe.jaillet@wanadoo.fr Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-19i2c: imx: add some dev_err_probe callsAlexander Stein
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 <alexander.stein@ew.tq-group.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://lore.kernel.org/r/20250408100300.556703-1-alexander.stein@ew.tq-group.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-19i2c: xgene-slimpro: Simplify PCC shared memory region handlingSudeep Holla
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 <andi.shyti@kernel.org> Cc: linux-i2c@vger.kernel.org Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/20250411112303.1149086-1-sudeep.holla@arm.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-19i2c: lpc2k: Add check for clk_enable()Chenyuan Yang
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 <chenyuan0y@gmail.com> Link: https://lore.kernel.org/r/20250412193713.105838-1-chenyuan0y@gmail.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-19i2c: npcm7xx: Remove redundant ret variableZhang Songyi
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 <zealci@zte.com.cn> Signed-off-by: Zhang Songyi <zhang.songyi@zte.com.cn> Link: https://lore.kernel.org/r/20250320004321.1914366-1-andi.shyti@kernel.org Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-19i2c: qcom-geni: Use generic definitions for bus frequenciesAndy Shevchenko
Since we have generic definitions for bus frequencies, let's use them. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Christopher Obbard <christopher.obbard@linaro.org> Reviewed-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com> Link: https://lore.kernel.org/r/20250322144736.472777-1-andriy.shevchenko@linux.intel.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-16i2c: Switch to irq_domain_create_linear()Jiri Slaby (SUSE)
irq_domain_add_linear() is going away as being obsolete now. Switch to the preferred irq_domain_create_linear(). That differs in the first parameter: It takes more generic struct fwnode_handle instead of struct device_node. Therefore, of_fwnode_handle() is added around the parameter. Note some of the users can likely use dev->fwnode directly instead of indirect of_fwnode_handle(dev->of_node). But dev->fwnode is not guaranteed to be set for all, so this has to be investigated on case to case basis (by people who can actually test with the HW). [ tglx: Fix up subject prefix ] Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/20250319092951.37667-20-jirislaby@kernel.org
2025-05-14i2c: designware: Fix an error handling path in i2c_dw_pci_probe()Christophe JAILLET
If navi_amd_register_client() fails, the previous i2c_dw_probe() call should be undone by a corresponding i2c_del_adapter() call, as already done in the remove function. Fixes: 17631e8ca2d3 ("i2c: designware: Add driver support for AMD NAVI GPU") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Cc: <stable@vger.kernel.org> # v5.13+ Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/fcd9651835a32979df8802b2db9504c523a8ebbb.1747158983.git.christophe.jaillet@wanadoo.fr
2025-05-13Merge branch 'x86/platform' into x86/core, to merge dependent commitsIngo Molnar
Prepare to resolve conflicts with an upstream series of fixes that conflict with pending x86 changes: 6f5bf947bab0 Merge tag 'its-for-linus-20250509' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip Signed-off-by: Ingo Molnar <mingo@kernel.org>
2025-05-06i2c: omap: fix deprecated of_property_read_bool() useJohan Hovold
Using of_property_read_bool() for non-boolean properties is deprecated and results in a warning during runtime since commit c141ecc3cecd ("of: Warn when of_property_read_bool() is used on non-boolean properties"). Fixes: b6ef830c60b6 ("i2c: omap: Add support for setting mux") Cc: Jayesh Choudhary <j-choudhary@ti.com> Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Acked-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com> Link: https://lore.kernel.org/r/20250415075230.16235-1-johan+linaro@kernel.org Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-05-02i2c: atr: Fix end of loop test in i2c_atr_find_mapping_by_addr()Dan Carpenter
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 <dan.carpenter@linaro.org> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Reviewed-by: Romain Gantois <romain.gantois@bootlin.com> Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2025-04-29i2c: imx-lpi2c: Fix clock count when probe defersClark Wang
Deferred probe with pm_runtime_put() may delay clock disable, causing incorrect clock usage count. Use pm_runtime_put_sync() to ensure the clock is disabled immediately. Fixes: 13d6eb20fc79 ("i2c: imx-lpi2c: add runtime pm support") Signed-off-by: Clark Wang <xiaoning.wang@nxp.com> Signed-off-by: Carlos Song <carlos.song@nxp.com> Cc: <stable@vger.kernel.org> # v4.16+ Link: https://lore.kernel.org/r/20250421062341.2471922-1-carlos.song@nxp.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-04-26i2c: piix4, x86/platform: Move the SB800 PIIX4 FCH definitions to ↵Mario Limonciello
<asm/amd/fch.h> SB800_PIIX4_FCH_PM_ADDR is used to indicate the base address for the FCH PM registers. Multiple drivers may need this base address, so move related defines to a common header location and rename them accordingly. Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Acked-by: Andi Shyti <andi.shyti@kernel.org> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Hans de Goede <hdegoede@redhat.com> Cc: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Cc: Jean Delvare <jdelvare@suse.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Sanket Goswami <Sanket.Goswami@amd.com> Cc: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Cc: Yazen Ghannam <yazen.ghannam@amd.com> Cc: linux-i2c@vger.kernel.org Link: https://lore.kernel.org/r/20250422234830.2840784-4-superm1@kernel.org
2025-04-26i2c: piix4: Make CONFIG_I2C_PIIX4 dependent on CONFIG_X86Mario Limonciello
PIIX4 and compatible controllers are only for X86. As some headers are being moved into x86 specific headers PIIX4 won't compile on non-x86. Suggested-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Acked-by: Andi Shyti <andi.shyti@kernel.org> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Sanket Goswami <Sanket.Goswami@amd.com> Cc: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Cc: Yazen Ghannam <yazen.ghannam@amd.com> Cc: linux-i2c@vger.kernel.org Link: https://lore.kernel.org/r/20250422234830.2840784-3-superm1@kernel.org
2025-04-24i2c: mux: ltc4306: use new GPIO line value setter callbacksBartosz Golaszewski
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 <bartosz.golaszewski@linaro.org> Acked-by: Peter Rosin <peda@axentia.se> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2025-04-18Merge tag 'i2c-host-fixes-6.15-rc3' of ↵Wolfram Sang
git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux into i2c/for-current i2c-host-fixes for v6.15-rc3 - ChromeOS EC tunnel: fix potential NULL pointer dereference
2025-04-18i2c: Support dynamic address translationRomain Gantois
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 <tomi.valkeinen@ideasonboard.com> Signed-off-by: Romain Gantois <romain.gantois@bootlin.com> Acked-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2025-04-18i2c: support per-channel ATR alias poolsRomain Gantois
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 <tomi.valkeinen@ideasonboard.com> Signed-off-by: Romain Gantois <romain.gantois@bootlin.com> Acked-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2025-04-18i2c: rename field 'alias_list' of struct i2c_atr_chan to 'alias_pairs'Romain Gantois
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 <tomi.valkeinen@ideasonboard.com> Signed-off-by: Romain Gantois <romain.gantois@bootlin.com> Acked-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2025-04-18i2c: move ATR alias pool to a separate structRomain Gantois
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 <tomi.valkeinen@ideasonboard.com> Signed-off-by: Romain Gantois <romain.gantois@bootlin.com> Acked-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2025-04-18i2c: use client addresses directly in ATR interfaceRomain Gantois
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 <tomi.valkeinen@ideasonboard.com> Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Signed-off-by: Romain Gantois <romain.gantois@bootlin.com> Acked-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2025-04-16i2c: core: Do not dereference fwnode in struct deviceAndy Shevchenko
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 <tomi.valkeinen@ideasonboard.com> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2025-04-16i2c: core: Reuse fwnode variable where it makes senseAndy Shevchenko
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 <tomi.valkeinen@ideasonboard.com> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2025-04-16i2c: core: Switch to fwnode APIs to get IRQAndy Shevchenko
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 <tomi.valkeinen@ideasonboard.com> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2025-04-16i2c: core: Unify the firmware node type checkAndy Shevchenko
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 <tomi.valkeinen@ideasonboard.com> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2025-04-16i2c: core: Drop duplicate check before calling OF APIsAndy Shevchenko
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 <tomi.valkeinen@ideasonboard.com> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2025-04-16i2c: atr: Fix wrong includeAndy Shevchenko
The fwnode.h is not supposed to be used by the drivers as it has the definitions for the core parts for different device property provider implementations. Drop it. Note, that fwnode API for drivers is provided in property.h which is included here. Fixes: a076a860acae ("media: i2c: add I2C Address Translator (ATR) support") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com> Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> [wsa: reworded subject] Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2025-04-13i2c: cros-ec-tunnel: defer probe if parent EC is not presentThadeu Lima de Souza Cascardo
When i2c-cros-ec-tunnel and the EC driver are built-in, the EC parent device will not be found, leading to NULL pointer dereference. That can also be reproduced by unbinding the controller driver and then loading i2c-cros-ec-tunnel module (or binding the device). [ 271.991245] BUG: kernel NULL pointer dereference, address: 0000000000000058 [ 271.998215] #PF: supervisor read access in kernel mode [ 272.003351] #PF: error_code(0x0000) - not-present page [ 272.008485] PGD 0 P4D 0 [ 272.011022] Oops: Oops: 0000 [#1] SMP NOPTI [ 272.015207] CPU: 0 UID: 0 PID: 3859 Comm: insmod Tainted: G S 6.15.0-rc1-00004-g44722359ed83 #30 PREEMPT(full) 3c7fb39a552e7d949de2ad921a7d6588d3a4fdc5 [ 272.030312] Tainted: [S]=CPU_OUT_OF_SPEC [ 272.034233] Hardware name: HP Berknip/Berknip, BIOS Google_Berknip.13434.356.0 05/17/2021 [ 272.042400] RIP: 0010:ec_i2c_probe+0x2b/0x1c0 [i2c_cros_ec_tunnel] [ 272.048577] Code: 1f 44 00 00 41 57 41 56 41 55 41 54 53 48 83 ec 10 65 48 8b 05 06 a0 6c e7 48 89 44 24 08 4c 8d 7f 10 48 8b 47 50 4c 8b 60 78 <49> 83 7c 24 58 00 0f 84 2f 01 00 00 48 89 fb be 30 06 00 00 4c 9 [ 272.067317] RSP: 0018:ffffa32082a03940 EFLAGS: 00010282 [ 272.072541] RAX: ffff969580b6a810 RBX: ffff969580b68c10 RCX: 0000000000000000 [ 272.079672] RDX: 0000000000000000 RSI: 0000000000000282 RDI: ffff969580b68c00 [ 272.086804] RBP: 00000000fffffdfb R08: 0000000000000000 R09: 0000000000000000 [ 272.093936] R10: 0000000000000000 R11: ffffffffc0600000 R12: 0000000000000000 [ 272.101067] R13: ffffffffa666fbb8 R14: ffffffffc05b5528 R15: ffff969580b68c10 [ 272.108198] FS: 00007b930906fc40(0000) GS:ffff969603149000(0000) knlGS:0000000000000000 [ 272.116282] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 272.122024] CR2: 0000000000000058 CR3: 000000012631c000 CR4: 00000000003506f0 [ 272.129155] Call Trace: [ 272.131606] <TASK> [ 272.133709] ? acpi_dev_pm_attach+0xdd/0x110 [ 272.137985] platform_probe+0x69/0xa0 [ 272.141652] really_probe+0x152/0x310 [ 272.145318] __driver_probe_device+0x77/0x110 [ 272.149678] driver_probe_device+0x1e/0x190 [ 272.153864] __driver_attach+0x10b/0x1e0 [ 272.157790] ? driver_attach+0x20/0x20 [ 272.161542] bus_for_each_dev+0x107/0x150 [ 272.165553] bus_add_driver+0x15d/0x270 [ 272.169392] driver_register+0x65/0x110 [ 272.173232] ? cleanup_module+0xa80/0xa80 [i2c_cros_ec_tunnel 3a00532f3f4af4a9eade753f86b0f8dd4e4e5698] [ 272.182617] do_one_initcall+0x110/0x350 [ 272.186543] ? security_kernfs_init_security+0x49/0xd0 [ 272.191682] ? __kernfs_new_node+0x1b9/0x240 [ 272.195954] ? security_kernfs_init_security+0x49/0xd0 [ 272.201093] ? __kernfs_new_node+0x1b9/0x240 [ 272.205365] ? kernfs_link_sibling+0x105/0x130 [ 272.209810] ? kernfs_next_descendant_post+0x1c/0xa0 [ 272.214773] ? kernfs_activate+0x57/0x70 [ 272.218699] ? kernfs_add_one+0x118/0x160 [ 272.222710] ? __kernfs_create_file+0x71/0xa0 [ 272.227069] ? sysfs_add_bin_file_mode_ns+0xd6/0x110 [ 272.232033] ? internal_create_group+0x453/0x4a0 [ 272.236651] ? __vunmap_range_noflush+0x214/0x2d0 [ 272.241355] ? __free_frozen_pages+0x1dc/0x420 [ 272.245799] ? free_vmap_area_noflush+0x10a/0x1c0 [ 272.250505] ? load_module+0x1509/0x16f0 [ 272.254431] do_init_module+0x60/0x230 [ 272.258181] __se_sys_finit_module+0x27a/0x370 [ 272.262627] do_syscall_64+0x6a/0xf0 [ 272.266206] ? do_syscall_64+0x76/0xf0 [ 272.269956] ? irqentry_exit_to_user_mode+0x79/0x90 [ 272.274836] entry_SYSCALL_64_after_hwframe+0x55/0x5d [ 272.279887] RIP: 0033:0x7b9309168d39 [ 272.283466] Code: 5b 41 5c 5d c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d af 40 0c 00 f7 d8 64 89 01 8 [ 272.302210] RSP: 002b:00007fff50f1a288 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 [ 272.309774] RAX: ffffffffffffffda RBX: 000058bf9b50f6d0 RCX: 00007b9309168d39 [ 272.316905] RDX: 0000000000000000 RSI: 000058bf6c103a77 RDI: 0000000000000003 [ 272.324036] RBP: 00007fff50f1a2e0 R08: 00007fff50f19218 R09: 0000000021ec4150 [ 272.331166] R10: 000058bf9b50f7f0 R11: 0000000000000246 R12: 0000000000000000 [ 272.338296] R13: 00000000fffffffe R14: 0000000000000000 R15: 000058bf6c103a77 [ 272.345428] </TASK> [ 272.347617] Modules linked in: i2c_cros_ec_tunnel(+) [ 272.364585] gsmi: Log Shutdown Reason 0x03 Returning -EPROBE_DEFER will allow the device to be bound once the controller is bound, in the case of built-in drivers. Fixes: 9d230c9e4f4e ("i2c: ChromeOS EC tunnel driver") Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com> Cc: <stable@vger.kernel.org> # v3.16+ Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/20250407-null-ec-parent-v1-1-f7dda62d3110@igalia.com
2025-04-05treewide: Switch/rename to timer_delete[_sync]()Thomas Gleixner
timer_delete[_sync]() replaces del_timer[_sync](). Convert the whole tree over and remove the historical wrapper inlines. Conversion was done with coccinelle plus manual fixups where necessary. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org>
2025-04-01Merge tag 'i2c-for-6.15-rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux Pull i2c updates from Wolfram Sang: "i2c-core updates (collected by Wolfram): - remove last user and unexport i2c_of_match_device() - irq usage cleanup from Jiri i2c-host updates (collected by Andi): Refactoring and cleanups: - octeon, cadence, i801, pasemi, mlxbf, bcm-iproc: general refactorings - octeon: remove 10-bit address support Improvements: - amd-asf: improved error handling - designware: use guard(mutex) - amd-asf, designware: update naming to follow latest specs - cadence: fix cleanup path in probe - i801: use MMIO and I/O mapping helpers to access registers - pxa: handle error after clk_prepare_enable New features: - added i2c_10bit_addr_*_from_msg() and updated multiple drivers - omap: added multiplexer state handling - qcom-geni: update frequency configuration - qup: introduce DMA usage policy New hardware support: - exynos: add support for Samsung exynos7870 - k1: add support for spacemit k1 (new driver) - imx: add support for i.mx94 lpi2c - rk3x: add support for rk3562 - designware: add support for Renesas RZ/N1D Multiplexers: - ltc4306, reg: fix assignment in platform_driver structure at24 eeprom updates (collected by Bartosz): - add two new compatible entries to the DT binding document - drop of_match_ptr() and ACPI_PTR() macros" * tag 'i2c-for-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (50 commits) dt-bindings: i2c: snps,designware-i2c: describe Renesas RZ/N1D variant irqdomain: i2c: Switch to irq_find_mapping() i2c: iproc: Refactor prototype and remove redundant error checks i2c: qcom-geni: Update i2c frequency table to match hardware guidance i2c: mlxbf: Use readl_poll_timeout_atomic() for polling i2c: pasemi: Add registers bits and switch to BIT() i2c: k1: Initialize variable before use i2c: spacemit: add support for SpacemiT K1 SoC dt-bindings: i2c: spacemit: add support for K1 SoC i2c: omap: Add support for setting mux dt-bindings: i2c: omap: Add mux-states property i2c: octeon: remove 10-bit addressing support i2c: octeon: fix return commenting i2c: i801: Use MMIO if available i2c: i801: Switch to iomapped register access i2c: i801: Improve too small kill wait time in i801_check_post i2c: i801: Move i801_wait_intr and i801_wait_byte_done in the code i2c: i801: Cosmetic improvements i2c: cadence: Move reset_control_assert after pm_runtime_set_suspended in probe error path i2c: cadence: Simplify using devm_clk_get_enabled() ...
2025-03-25Merge tag 'timers-cleanups-2025-03-23' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip Pull timer cleanups from Thomas Gleixner: "A treewide hrtimer timer cleanup hrtimers are initialized with hrtimer_init() and a subsequent store to the callback pointer. This turned out to be suboptimal for the upcoming Rust integration and is obviously a silly implementation to begin with. This cleanup replaces the hrtimer_init(T); T->function = cb; sequence with hrtimer_setup(T, cb); The conversion was done with Coccinelle and a few manual fixups. Once the conversion has completely landed in mainline, hrtimer_init() will be removed and the hrtimer::function becomes a private member" * tag 'timers-cleanups-2025-03-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (100 commits) wifi: rt2x00: Switch to use hrtimer_update_function() io_uring: Use helper function hrtimer_update_function() serial: xilinx_uartps: Use helper function hrtimer_update_function() ASoC: fsl: imx-pcm-fiq: Switch to use hrtimer_setup() RDMA: Switch to use hrtimer_setup() virtio: mem: Switch to use hrtimer_setup() drm/vmwgfx: Switch to use hrtimer_setup() drm/xe/oa: Switch to use hrtimer_setup() drm/vkms: Switch to use hrtimer_setup() drm/msm: Switch to use hrtimer_setup() drm/i915/request: Switch to use hrtimer_setup() drm/i915/uncore: Switch to use hrtimer_setup() drm/i915/pmu: Switch to use hrtimer_setup() drm/i915/perf: Switch to use hrtimer_setup() drm/i915/gvt: Switch to use hrtimer_setup() drm/i915/huc: Switch to use hrtimer_setup() drm/amdgpu: Switch to use hrtimer_setup() stm class: heartbeat: Switch to use hrtimer_setup() i2c: Switch to use hrtimer_setup() iio: Switch to use hrtimer_setup() ...
2025-03-25Merge tag 'i2c-host-6.15' of ↵Wolfram Sang
git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux into i2c/for-mergewindow i2c-host updates for v6.15 Refactoring and cleanups - octeon, cadence, i801, pasemi, mlxbf, bcm-iproc: general refactorings - octeon: remove 10-bit address support Improvements - amd-asf: improved error handling - designware: use guard(mutex) - amd-asf, designware: update naming to follow latest specs - cadence: fix cleanup path in probe - i801: use MMIO and I/O mapping helpers to access registers - pxa: handle error after clk_prepare_enable New features - added i2c_10bit_addr_*_from_msg() and updated multiple drivers - omap: added multiplexer state handling - qcom-geni: update frequency configuration - qup: introduce DMA usage policy New hardware support - exynos: add support for Samsung exynos7870 - k1: add support for spacemit k1 (new driver) - imx: add support for i.mx94 lpi2c - rk3x: add support for rk3562 Multiplexers - ltc4306, reg: fix assignment in platform_driver structure
2025-03-25irqdomain: i2c: Switch to irq_find_mapping()Jiri Slaby (SUSE)
irq_linear_revmap() is deprecated, so remove all its uses and supersede them by an identical call to irq_find_mapping(). Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> Cc: Peter Rosin <peda@axentia.se> Cc: linux-i2c@vger.kernel.org Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2025-03-22i2c: iproc: Refactor prototype and remove redundant error checksWentao Liang
The bcm_iproc_i2c_init() always returns 0. As a result, there is no need to check its return value or handle errors. This patch changes the prototype of bcm_iproc_i2c_init() to return void and removes the redundant error handling code after calls to bcm_iproc_i2c_init() in both the bcm_iproc_i2c_probe() and bcm_iproc_i2c_resume(). Signed-off-by: Wentao Liang <vulab@iscas.ac.cn> Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Acked-by: Ray Jui <ray.jui@broadcom.com> Link: https://lore.kernel.org/r/20250121084818.2719-1-vulab@iscas.ac.cn Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-03-22i2c: qcom-geni: Update i2c frequency table to match hardware guidanceMukesh Kumar Savaliya
With the current settings, the I2C buses are achieving around 370KHz instead of the expected 400KHz. For 100KHz and 1MHz, the settings are now more compliant and adhere to the Qualcomm’s internal programming guide. Update the I2C frequency table to align with the recommended values outlined in the I2C hardware programming guide, ensuring proper communication and performance. Signed-off-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com> Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org> Link: https://lore.kernel.org/r/20250122064634.2864432-1-quic_msavaliy@quicinc.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-03-22i2c: mlxbf: Use readl_poll_timeout_atomic() for pollingAndy Shevchenko
Convert the usage of an open-coded custom tight poll while loop with the provided readl_poll_timeout_atomic() macro. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Asmaa Mnebhi <asmaa@nvidia.com> Link: https://lore.kernel.org/r/20250212165128.2413430-1-andriy.shevchenko@linux.intel.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-03-22i2c: pasemi: Add registers bits and switch to BIT()Sven Peter
Add the missing register bits to the defines and also switch those to use the BIT macro which is much more readable than using hardcoded masks Co-developed-by: Hector Martin <marcan@marcan.st> Signed-off-by: Hector Martin <marcan@marcan.st> Signed-off-by: Sven Peter <sven@svenpeter.dev> Reviewed-by: Neal Gompa <neal@gompa.dev> Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/20250222-pasemi-fixes-v1-1-d7ea33d50c5e@svenpeter.dev
2025-03-22i2c: k1: Initialize variable before useAndi Shyti
Commit 95a8ca229032 ("i2c: spacemit: add support for SpacemiT K1 SoC") introduced a check in the probe function to warn the user if the DTS has incorrect frequency settings. In such cases, the driver falls back to default values. However, the return value of of_property_read_u32() was not stored, making the check ineffective. Fix this by storing the return value in 'ret' and evaluating it properly. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202503200928.eBWfwnHG-lkp@intel.com/ Cc: Troy Mitchell <troymitchell988@gmail.com> Link: https://lore.kernel.org/r/20250320113521.3966762-1-andi.shyti@kernel.org Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2025-03-21i2c: spacemit: add support for SpacemiT K1 SoCTroy Mitchell
This patch introduces basic I2C support for the SpacemiT K1 SoC, utilizing interrupts for transfers. The driver has been tested using i2c-tools on a Bananapi-F3 board, and basic I2C read/write operations have been confirmed to work. Signed-off-by: Troy Mitchell <troymitchell988@gmail.com> Reviewed-by: Alex Elder <elder@riscstar.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/20250319-k1-i2c-master-v8-2-013e2df2b78d@gmail.com