#
048bbbdb |
| 30-Sep-2024 |
Marek Vasut <marex@denx.de> |
i2c: stm32f7: Do not prepare/unprepare clock during runtime suspend/resume
In case there is any sort of clock controller attached to this I2C bus controller, for example Versaclock or even an AIC32x
i2c: stm32f7: Do not prepare/unprepare clock during runtime suspend/resume
In case there is any sort of clock controller attached to this I2C bus controller, for example Versaclock or even an AIC32x4 I2C codec, then an I2C transfer triggered from the clock controller clk_ops .prepare callback may trigger a deadlock on drivers/clk/clk.c prepare_lock mutex.
This is because the clock controller first grabs the prepare_lock mutex and then performs the prepare operation, including its I2C access. The I2C access resumes this I2C bus controller via .runtime_resume callback, which calls clk_prepare_enable(), which attempts to grab the prepare_lock mutex again and deadlocks.
Since the clock are already prepared since probe() and unprepared in remove(), use simple clk_enable()/clk_disable() calls to enable and disable the clock on runtime suspend and resume, to avoid hitting the prepare_lock mutex.
Acked-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Marek Vasut <marex@denx.de> Fixes: 4e7bca6fc07b ("i2c: i2c-stm32f7: add PM Runtime support") Cc: <stable@vger.kernel.org> # v5.0+ Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
show more ...
|
#
197264d3 |
| 27-Apr-2024 |
Wolfram Sang <wsa+renesas@sang-engineering.com> |
i2c: stm32f7: use 'time_left' variable with wait_for_completion_timeout()
There is a confusing pattern in the kernel to use a variable named 'timeout' to store the result of wait_for_completion_time
i2c: stm32f7: use 'time_left' variable with wait_for_completion_timeout()
There is a confusing pattern in the kernel to use a variable named 'timeout' to store the result of wait_for_completion_timeout() causing patterns like:
timeout = wait_for_completion_timeout(...) if (!timeout) return -ETIMEDOUT;
with all kinds of permutations. Use 'time_left' as a variable to make the code self explaining.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
show more ...
|
#
90f9b140 |
| 15-Dec-2023 |
Alain Volmat <alain.volmat@foss.st.com> |
i2c: stm32f7: add support for stm32mp25 soc
The stm32mp25 has only a single interrupt line used for both events and errors. In order to cope with that, reorganise the error handling code so that it
i2c: stm32f7: add support for stm32mp25 soc
The stm32mp25 has only a single interrupt line used for both events and errors. In order to cope with that, reorganise the error handling code so that it can be called either from the common handler (used in case of SoC having only a single IT line) and the error handler for others. The CR1 register also embeds a new FMP bit, necessary when running at Fast Mode Plus frequency. This bit should be used instead of the SYSCFG bit used on other platforms. Add a new compatible to distinguish between the SoCs and two boolean within the setup structure in order to know if the platform has a single/multiple IT lines and if the FMP bit within CR1 is available or not.
Signed-off-by: Valentin Caron <valentin.caron@foss.st.com> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
a058b24c |
| 15-Dec-2023 |
Alain Volmat <alain.volmat@foss.st.com> |
i2c: stm32f7: perform I2C_ISR read once at beginning of event isr
Move readl_relaxed of I2C_ISR register at beginning of event isr so that it done once for both master & slave handling.
Signed-off-
i2c: stm32f7: perform I2C_ISR read once at beginning of event isr
Move readl_relaxed of I2C_ISR register at beginning of event isr so that it done once for both master & slave handling.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
33a00d91 |
| 15-Dec-2023 |
Alain Volmat <alain.volmat@foss.st.com> |
i2c: stm32f7: simplify status messages in case of errors
Avoid usage of __func__ when reporting an error message since dev_err/dev_dbg are already providing enough details to identify the source of
i2c: stm32f7: simplify status messages in case of errors
Avoid usage of __func__ when reporting an error message since dev_err/dev_dbg are already providing enough details to identify the source of the message.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Reviewed-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
e6103cd4 |
| 15-Dec-2023 |
Alain Volmat <alain.volmat@foss.st.com> |
i2c: stm32f7: perform most of irq job in threaded handler
The irq handling is currently split between the irq handler and the threaded irq handler. Some of the handling (such as dma related stuffs)
i2c: stm32f7: perform most of irq job in threaded handler
The irq handling is currently split between the irq handler and the threaded irq handler. Some of the handling (such as dma related stuffs) done within the irq handler might sleep or take some time leading to issues if the kernel is built with realtime constraints. In order to fix that, perform an overall rework to perform most of the job within the threaded handler and only keep fifo access in the non threaded handler.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Reviewed-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
a51e224c |
| 15-Dec-2023 |
Alain Volmat <alain.volmat@foss.st.com> |
i2c: stm32f7: use dev_err_probe upon calls of devm_request_irq
Convert error handling upon calls of devm_request_irq functions during the probe of the driver.
Signed-off-by: Alain Volmat <alain.vol
i2c: stm32f7: use dev_err_probe upon calls of devm_request_irq
Convert error handling upon calls of devm_request_irq functions during the probe of the driver.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
7ba2b17a |
| 11-Jun-2023 |
Andi Shyti <andi.shyti@kernel.org> |
i2c: stm32f7: Use devm_clk_get_enabled()
Replace the pair of functions, devm_clk_get() and clk_prepare_enable(), with a single function devm_clk_get_enabled().
Signed-off-by: Andi Shyti <andi.shyti
i2c: stm32f7: Use devm_clk_get_enabled()
Replace the pair of functions, devm_clk_get() and clk_prepare_enable(), with a single function devm_clk_get_enabled().
Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Acked-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
a0536c67 |
| 23-Oct-2023 |
Alain Volmat <alain.volmat@foss.st.com> |
i2c: stm32f7: add description of atomic in struct stm32f7_i2c_dev
Add missing description of the atomic boolean in struct stm32f7_i2c_dev.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Sig
i2c: stm32f7: add description of atomic in struct stm32f7_i2c_dev
Add missing description of the atomic boolean in struct stm32f7_i2c_dev.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
c896ff2d |
| 10-Oct-2023 |
Alain Volmat <alain.volmat@foss.st.com> |
i2c: stm32f7: Fix PEC handling in case of SMBUS transfers
In case of SMBUS byte read with PEC enabled, the whole transfer is split into two commands. A first write command, followed by a read comma
i2c: stm32f7: Fix PEC handling in case of SMBUS transfers
In case of SMBUS byte read with PEC enabled, the whole transfer is split into two commands. A first write command, followed by a read command. The write command does not have any PEC byte and a PEC byte is appended at the end of the read command. (cf Read byte protocol with PEC in SMBUS specification)
Within the STM32 I2C controller, handling (either sending or receiving) of the PEC byte is done via the PECBYTE bit in register CR2.
Currently, the PECBYTE is set at the beginning of a transfer, which lead to sending a PEC byte at the end of the write command (hence losing the real last byte), and also does not check the PEC byte received during the read command.
This patch corrects the function stm32f7_i2c_smbus_xfer_msg in order to only set the PECBYTE during the read command.
Fixes: 9e48155f6bfe ("i2c: i2c-stm32f7: Add initial SMBus protocols support") Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com> Acked-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
470a6626 |
| 16-Aug-2023 |
Sean Nyekjaer <sean@geanix.com> |
i2c: stm32f7: Add atomic_xfer method to driver
Add an atomic_xfer method to the driver so that it behaves correctly when controlling a PMIC that is responsible for device shutdown.
The atomic_xfer
i2c: stm32f7: Add atomic_xfer method to driver
Add an atomic_xfer method to the driver so that it behaves correctly when controlling a PMIC that is responsible for device shutdown.
The atomic_xfer method added is similar to the one from the i2c-mv64xxx driver. When running an atomic_xfer a bool flag in the driver data is set, the interrupt is not unmasked on transfer start, and the IRQ handler is manually invoked while waiting for pending transfers to complete.
Signed-off-by: Sean Nyekjaer <sean@geanix.com> Acked-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
5140b46c |
| 31-Jul-2023 |
Ruan Jinjie <ruanjinjie@huawei.com> |
i2c: stm32: Do not check for 0 return after calling platform_get_irq()
It is not possible for platform_get_irq() to return 0. Use the return value from platform_get_irq().
Signed-off-by: Ruan Jinji
i2c: stm32: Do not check for 0 return after calling platform_get_irq()
It is not possible for platform_get_irq() to return 0. Use the return value from platform_get_irq().
Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> Reviewed-by: Andi Shyti <andi.shyti@kernel.org> Acked-by: Alain Volmat <alain.volmat@foss.st.com> Link: https://lore.kernel.org/r/20230731112755.1943630-1-ruanjinjie@huawei.com Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
show more ...
|
#
e190a0c3 |
| 08-May-2023 |
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> |
i2c: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling
i2c: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is (mostly) ignored and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Alain Volmat <alain.volmat@foss.st.com> Acked-by: Ard Biesheuvel <ardb@kernel.org> Acked-by: Baruch Siach <baruch@tkos.co.il> Acked-by: Florian Fainelli <f.fainelli@gmail.com> Acked-by: Heiko Stuebner <heiko@sntech.de> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> Acked-by: Jochen Friedrich <jochen@scram.de> Acked-by: Peter Rosin <peda@axentia.se> Acked-by: Vadim Pasternak <vadimp@nvidia.com> Reviewed-by: Asmaa Mnebhi <asnaa@nvidia.com> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Reviewed-by: Chris Pringle <chris.pringle@phabrix.com> Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Jean Delvare <jdelvare@suse.de> Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com> Reviewed-by: Tali Perry <tali.perry@nuvoton.com> Reviewed-by: Vignesh Raghavendra <vigneshr@ti.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
d4d2f170 |
| 07-Jul-2022 |
Alain Volmat <alain.volmat@foss.st.com> |
i2c: stm32: add support for the STM32MP13 soc
Add a new compatible for the stm32mp13. Fast Mode Plus control register address differ from the one for STM32MP15.
Signed-off-by: Alain Volmat <alain.
i2c: stm32: add support for the STM32MP13 soc
Add a new compatible for the stm32mp13. Fast Mode Plus control register address differ from the one for STM32MP15.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
15f0ae7a |
| 01-Dec-2021 |
Wolfram Sang <wsa@kernel.org> |
i2c: stm32f7: remove noisy and imprecise log messages
The log messages talk about 'bus recovery' while it is not a bus recovery with 9 pulses but merely a controller reset. Controller resets are not
i2c: stm32f7: remove noisy and imprecise log messages
The log messages talk about 'bus recovery' while it is not a bus recovery with 9 pulses but merely a controller reset. Controller resets are not worth log messages. The 'bus busy' message should be emitted by upper layers, a busy bus may be expected in some cases.
Signed-off-by: Wolfram Sang <wsa@kernel.org> Reviewed-by: Alain Volmat <alain.volmat@foss.st.com>
show more ...
|
#
05907656 |
| 01-Dec-2021 |
Alain Volmat <alain.volmat@foss.st.com> |
i2c: stm32: get rid of stm32f7_i2c_release_bus return value
Function stm32f7_i2c_release_bus is always returning 0, hence it should be a void function. Update the function and remove the return val
i2c: stm32: get rid of stm32f7_i2c_release_bus return value
Function stm32f7_i2c_release_bus is always returning 0, hence it should be a void function. Update the function and remove the return value error checking code in caller functions.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
1229f82d |
| 20-Sep-2021 |
Alain Volmat <alain.volmat@foss.st.com> |
i2c: stm32f7: use proper DMAENGINE API for termination
dmaengine_terminate_all() is deprecated in favor of explicitly saying if it should be sync or async. Here, we use dmaengine_terminate_sync in
i2c: stm32f7: use proper DMAENGINE API for termination
dmaengine_terminate_all() is deprecated in favor of explicitly saying if it should be sync or async. Here, we use dmaengine_terminate_sync in i2c_xfer and i2c_smbus_xfer handlers and rely on dmaengine_terminate_async within interrupt handlers (transmission error cases). dmaengine_synchronize is added within i2c_xfer and i2c_smbus_xfer handler to finalize terminate started in interrupt handlers.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
31b90a95 |
| 20-Sep-2021 |
Alain Volmat <alain.volmat@foss.st.com> |
i2c: stm32f7: stop dma transfer in case of NACK
In case of receiving a NACK, the dma transfer should be stopped to avoid feeding data into the FIFO. Also ensure to properly return the proper error c
i2c: stm32f7: stop dma transfer in case of NACK
In case of receiving a NACK, the dma transfer should be stopped to avoid feeding data into the FIFO. Also ensure to properly return the proper error code and avoid waiting for the end of the dma completion in case of error happening during the transmission.
Fixes: 7ecc8cfde553 ("i2c: i2c-stm32f7: Add DMA support") Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
b933d1fa |
| 20-Sep-2021 |
Alain Volmat <alain.volmat@foss.st.com> |
i2c: stm32f7: recover the bus on access timeout
When getting an access timeout, ensure that the bus is in a proper state prior to returning the error.
Fixes: aeb068c57214 ("i2c: i2c-stm32f7: add dr
i2c: stm32f7: recover the bus on access timeout
When getting an access timeout, ensure that the bus is in a proper state prior to returning the error.
Fixes: aeb068c57214 ("i2c: i2c-stm32f7: add driver") Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
0c21d02c |
| 20-Sep-2021 |
Alain Volmat <alain.volmat@foss.st.com> |
i2c: stm32f7: flush TX FIFO upon transfer errors
While handling an error during transfer (ex: NACK), it could happen that the driver has already written data into TXDR before the transfer get stoppe
i2c: stm32f7: flush TX FIFO upon transfer errors
While handling an error during transfer (ex: NACK), it could happen that the driver has already written data into TXDR before the transfer get stopped. This commit add TXDR Flush after end of transfer in case of error to avoid sending a wrong data on any other slave upon next transfer.
Fixes: aeb068c57214 ("i2c: i2c-stm32f7: add driver") Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
c8062d11 |
| 05-May-2021 |
Alain Volmat <alain.volmat@foss.st.com> |
i2c: stm32f7: add SMBus-Alert support
Add support for the SMBus-Alert protocol to the STM32F7 that has dedicated control and status logic.
If SMBus-Alert is used, the SMBALERT# pin must be configur
i2c: stm32f7: add SMBus-Alert support
Add support for the SMBus-Alert protocol to the STM32F7 that has dedicated control and status logic.
If SMBus-Alert is used, the SMBALERT# pin must be configured as alternate function for I2C Alert.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
2c662660 |
| 01-Dec-2020 |
Qinglang Miao <miaoqinglang@huawei.com> |
i2c: stm32f7: fix reference leak when pm_runtime_get_sync fails
The PM reference count is not expected to be incremented on return in these stm32f7_i2c_xx serious functions.
However, pm_runtime_get
i2c: stm32f7: fix reference leak when pm_runtime_get_sync fails
The PM reference count is not expected to be incremented on return in these stm32f7_i2c_xx serious functions.
However, pm_runtime_get_sync will increment the PM reference count even failed. Forgetting to putting operation will result in a reference leak here.
Replace it with pm_runtime_resume_and_get to keep usage counter balanced.
Fixes: ea6dd25deeb5 ("i2c: stm32f7: add PM_SLEEP suspend/resume support") Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
010e32ab |
| 12-Mar-2021 |
Alain Volmat <alain.volmat@foss.st.com> |
i2c: stm32f7: avoid ifdef CONFIG_PM_SLEEP for pm callbacks
Avoid CONFIG_PM preprocessor check for pm suspend/resume callbacks and identify the functions with __maybe_unused.
Signed-off-by: Alain Vo
i2c: stm32f7: avoid ifdef CONFIG_PM_SLEEP for pm callbacks
Avoid CONFIG_PM preprocessor check for pm suspend/resume callbacks and identify the functions with __maybe_unused.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
8f66edb2 |
| 25-Mar-2021 |
Tian Tao <tiantao6@hisilicon.com> |
i2c: stm32f7: Remove useless error message
Fix the following coccicheck report:
drivers/i2c/busses/i2c-stm32f7.c:2032:3-10 : platform_get_irq : line 2032 is redundant because platform_get_irq() alr
i2c: stm32f7: Remove useless error message
Fix the following coccicheck report:
drivers/i2c/busses/i2c-stm32f7.c:2032:3-10 : platform_get_irq : line 2032 is redundant because platform_get_irq() already prints an error
Remove dev_err() messages after platform_get_irq() failures.
Signed-off-by: Tian Tao <tiantao6@hisilicon.com> Signed-off-by: Zihao Tang <tangzihao1@hisilicon.com> Reviewed-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|
#
b8775252 |
| 05-Feb-2021 |
Alain Volmat <alain.volmat@foss.st.com> |
i2c: stm32f7: indicate the address being accessed on errors
To help debugging issues, add the address of the slave being accessed when getting an error.
Signed-off-by: Alain Volmat <alain.volmat@fo
i2c: stm32f7: indicate the address being accessed on errors
To help debugging issues, add the address of the slave being accessed when getting an error.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
show more ...
|