From: Clark Wang <xiaoning.wang@nxp.com> Date: 2021-03-17 06:54:56
Hi,
Here are some patches to add some new features and bug fixes/improvements.
Each patch of these 11 patches is made on the basis of the previous patches.
New features:
- add bus recovery support
- add edma mode support
- add runtime pm support
Improvements:
- increase PM timeout to avoid operate clk frequently
- manage irq resource request/release in runtime pm
- directly retrun ISR when detect a NACK
- improve i2c driver probe priority
- add debug message
Bug fixes:
- fix i2c timing issue
- fix type char overflow issue when calculating the clock cycle
- add the missing ipg clk
Best Regards,
Clark Wang
drivers/i2c/busses/i2c-imx-lpi2c.c | 536 +++++++++++++++++++++++++----
1 file changed, 478 insertions(+), 58 deletions(-)
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Clark Wang <xiaoning.wang@nxp.com> Date: 2021-03-17 06:54:56
From: Gao Pan <redacted>
A NACK flag in ISR means i2c bus error. In such codition,
there is no need to do read/write operation. It's better
to return ISR directly and then stop i2c transfer.
Signed-off-by: Gao Pan <redacted>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
---
drivers/i2c/busses/i2c-imx-lpi2c.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
A NACK flag in ISR means i2c bus error. In such codition, there is no need to do
read/write operation. It's better to return ISR directly and then stop i2c
transfer.
Signed-off-by: Gao Pan <redacted>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
From: Clark Wang <xiaoning.wang@nxp.com> Date: 2021-03-17 06:54:57
The lpi2c IP needs two clks: ipg clk and per clk. The old lpi2c
driver missed ipg clk. This patch adds ipg clk for lpi2c driver.
Signed-off-by: Gao Pan <redacted>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Acked-by: Fugang Duan <redacted>
---
drivers/i2c/busses/i2c-imx-lpi2c.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
The lpi2c IP needs two clks: ipg clk and per clk. The old lpi2c driver missed ipg
clk. This patch adds ipg clk for lpi2c driver.
Pleas also update dt-binding and sent along with this patchset.(before this one)
Signed-off-by: Gao Pan <redacted>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Acked-by: Fugang Duan <redacted>
From: Clark Wang <xiaoning.wang@nxp.com> Date: 2021-03-19 06:24:24
-----Original Message-----
From: Aisheng Dong <aisheng.dong@nxp.com>
Sent: Friday, March 19, 2021 12:46
To: Clark Wang <xiaoning.wang@nxp.com>; shawnguo@kernel.org;
s.hauer@pengutronix.de
Cc: kernel@pengutronix.de; festevam@gmail.com; dl-linux-imx <linux-
imx@nxp.com>; sumit.semwal@linaro.org; christian.koenig@amd.com;
linux-i2c@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
kernel@vger.kernel.org
Subject: RE: [PATCH 03/11] i2c: imx-lpi2c: add ipg clk for lpi2c driver
quoted
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
The lpi2c IP needs two clks: ipg clk and per clk. The old lpi2c driver
missed ipg clk. This patch adds ipg clk for lpi2c driver.
Pleas also update dt-binding and sent along with this patchset.(before this
one)
Okay, thanks.
quoted
Signed-off-by: Gao Pan <redacted>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Acked-by: Fugang Duan <redacted>
It will not break the build. But will break the lpi2c probe for imx7ulp and
imx8qxp/qm.
I will send two patches to update dts in V2.
Best Regards,
Clark Wang
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
add debug message when i2c peripheral clk rate is 0, then directly return
-EINVAL.
Signed-off-by: Gao Pan <redacted>
Reviewed-by: Andy Duan <redacted>
From: Clark Wang <xiaoning.wang@nxp.com> Date: 2021-03-19 07:08:23
-----Original Message-----
From: Aisheng Dong <aisheng.dong@nxp.com>
Sent: Friday, March 19, 2021 12:57
To: Clark Wang <xiaoning.wang@nxp.com>; shawnguo@kernel.org;
s.hauer@pengutronix.de
Cc: kernel@pengutronix.de; festevam@gmail.com; dl-linux-imx <linux-
imx@nxp.com>; sumit.semwal@linaro.org; christian.koenig@amd.com;
linux-i2c@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
kernel@vger.kernel.org
Subject: RE: [PATCH 05/11] i2c: imx-lpi2c: add debug message when i2c
peripheral clk doesn't work
quoted
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
add debug message when i2c peripheral clk rate is 0, then directly
return -EINVAL.
Signed-off-by: Gao Pan <redacted>
Reviewed-by: Andy Duan <redacted>
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
Subject: [PATCH 02/11] i2c: imx-lpi2c: add runtime pm support
- Add runtime pm support to dynamicly manage the clock.
- Put the suspend to suspend_noirq.
- Call .pm_runtime_force_suspend() to force runtime pm suspended
in .suspend_noirq().
The patch title needs to be improved as the driver already supports rpm.
And do one thing in one patch.
From: Clark Wang <xiaoning.wang@nxp.com> Date: 2021-03-19 05:34:14
-----Original Message-----
From: Aisheng Dong <aisheng.dong@nxp.com>
Sent: Friday, March 19, 2021 12:40
To: Clark Wang <xiaoning.wang@nxp.com>; shawnguo@kernel.org;
s.hauer@pengutronix.de
Cc: kernel@pengutronix.de; festevam@gmail.com; dl-linux-imx <linux-
imx@nxp.com>; sumit.semwal@linaro.org; christian.koenig@amd.com;
linux-i2c@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
kernel@vger.kernel.org
Subject: RE: [PATCH 02/11] i2c: imx-lpi2c: add runtime pm support
quoted
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
Subject: [PATCH 02/11] i2c: imx-lpi2c: add runtime pm support
- Add runtime pm support to dynamicly manage the clock.
- Put the suspend to suspend_noirq.
- Call .pm_runtime_force_suspend() to force runtime pm suspended
in .suspend_noirq().
The patch title needs to be improved as the driver already supports rpm.
And do one thing in one patch.
Thanks. I will split this patch into several and resend.
Best Regards,
Clark Wang
From: Clark Wang <xiaoning.wang@nxp.com> Date: 2021-03-19 06:17:30
-----Original Message-----
From: Aisheng Dong <aisheng.dong@nxp.com>
Sent: Friday, March 19, 2021 12:40
To: Clark Wang <xiaoning.wang@nxp.com>; shawnguo@kernel.org;
s.hauer@pengutronix.de
Cc: kernel@pengutronix.de; festevam@gmail.com; dl-linux-imx <linux-
imx@nxp.com>; sumit.semwal@linaro.org; christian.koenig@amd.com;
linux-i2c@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
kernel@vger.kernel.org
Subject: RE: [PATCH 02/11] i2c: imx-lpi2c: add runtime pm support
quoted
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
Subject: [PATCH 02/11] i2c: imx-lpi2c: add runtime pm support
- Add runtime pm support to dynamicly manage the clock.
- Put the suspend to suspend_noirq.
- Call .pm_runtime_force_suspend() to force runtime pm suspended
in .suspend_noirq().
The patch title needs to be improved as the driver already supports rpm.
And do one thing in one patch.
pm_runtime_use_autosuspend(&pdev->dev);
- pm_runtime_get_noresume(&pdev->dev);
- pm_runtime_set_active(&pdev->dev);
pm_runtime_enable(&pdev->dev);
+ ret = pm_runtime_get_sync(&pdev->dev);
+ if (ret < 0) {
+ pm_runtime_put_noidle(&pdev->dev);
+ dev_err(&pdev->dev, "failed to enable clock\n");
+ return ret;
+ }
Can't current clk control via rpm work well?
Please describe why need change.
I think the previous patch maker might want to use the return value of
pm_runtime_get_sync to check whether the clock has been turned on correctly to
avoid the kernel panic.
Maybe I can change to the method like this.
pm_runtime_get_noresume(&pdev->dev);
ret = pm_runtime_set_active(&pdev->dev);
if (ret < 0)
goto out;
pm_runtime_enable(&pdev->dev);
Best Regards,
Clark Wang
From: Clark Wang <xiaoning.wang@nxp.com> Date: 2021-03-19 08:01:42
-----Original Message-----
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Friday, March 19, 2021 14:16
To: Aisheng Dong <aisheng.dong@nxp.com>; shawnguo@kernel.org;
s.hauer@pengutronix.de
Cc: kernel@pengutronix.de; festevam@gmail.com; dl-linux-imx <linux-
imx@nxp.com>; sumit.semwal@linaro.org; christian.koenig@amd.com;
linux-i2c@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
kernel@vger.kernel.org
Subject: RE: [PATCH 02/11] i2c: imx-lpi2c: add runtime pm support
quoted
-----Original Message-----
From: Aisheng Dong <aisheng.dong@nxp.com>
Sent: Friday, March 19, 2021 12:40
To: Clark Wang <xiaoning.wang@nxp.com>; shawnguo@kernel.org;
s.hauer@pengutronix.de
Cc: kernel@pengutronix.de; festevam@gmail.com; dl-linux-imx <linux-
imx@nxp.com>; sumit.semwal@linaro.org; christian.koenig@amd.com;
linux-i2c@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
kernel@vger.kernel.org
Subject: RE: [PATCH 02/11] i2c: imx-lpi2c: add runtime pm support
quoted
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
Subject: [PATCH 02/11] i2c: imx-lpi2c: add runtime pm support
- Add runtime pm support to dynamicly manage the clock.
- Put the suspend to suspend_noirq.
- Call .pm_runtime_force_suspend() to force runtime pm suspended
in .suspend_noirq().
The patch title needs to be improved as the driver already supports rpm.
And do one thing in one patch.
pm_runtime_use_autosuspend(&pdev->dev);
- pm_runtime_get_noresume(&pdev->dev);
- pm_runtime_set_active(&pdev->dev);
pm_runtime_enable(&pdev->dev);
+ ret = pm_runtime_get_sync(&pdev->dev);
+ if (ret < 0) {
+ pm_runtime_put_noidle(&pdev->dev);
+ dev_err(&pdev->dev, "failed to enable clock\n");
+ return ret;
+ }
Can't current clk control via rpm work well?
Please describe why need change.
I think the previous patch maker might want to use the return value of
pm_runtime_get_sync to check whether the clock has been turned on
correctly to
avoid the kernel panic.
Maybe I can change to the method like this.
pm_runtime_get_noresume(&pdev->dev);
ret = pm_runtime_set_active(&pdev->dev);
if (ret < 0)
goto out;
pm_runtime_enable(&pdev->dev);
Best Regards,
Clark Wang
Sorry, I missed the point before.
If we use pm_runtime_get_noresume(&pdev->dev); and
pm_runtime_set_active(&pdev->dev); here, the clk should be enabled by using
clk_prepare_enable() in the probe function. However, the call of
clk_prepare_enable() is already in lpi2c_runtime_resume().
Using get_sync() here can help to reduce the repetitive code, especially ipg
clk will be added later.
Shall we change to use pm_runtime_get_sync() here?
Regards,
Clark Wang
pm_runtime_use_autosuspend(&pdev->dev);
- pm_runtime_get_noresume(&pdev->dev);
- pm_runtime_set_active(&pdev->dev);
pm_runtime_enable(&pdev->dev);
+ ret = pm_runtime_get_sync(&pdev->dev);
+ if (ret < 0) {
+ pm_runtime_put_noidle(&pdev->dev);
+ dev_err(&pdev->dev, "failed to enable clock\n");
+ return ret;
+ }
Can't current clk control via rpm work well?
Please describe why need change.
I think the previous patch maker might want to use the return value of
pm_runtime_get_sync to check whether the clock has been turned on
correctly to
avoid the kernel panic.
Maybe I can change to the method like this.
pm_runtime_get_noresume(&pdev->dev);
ret = pm_runtime_set_active(&pdev->dev);
if (ret < 0)
goto out;
pm_runtime_enable(&pdev->dev);
Best Regards,
Clark Wang
Sorry, I missed the point before.
If we use pm_runtime_get_noresume(&pdev->dev); and
pm_runtime_set_active(&pdev->dev); here, the clk should be enabled by using
clk_prepare_enable() in the probe function. However, the call of
clk_prepare_enable() is already in lpi2c_runtime_resume().
Using get_sync() here can help to reduce the repetitive code, especially ipg
clk will be added later.
Let's not do for this negligible improvement unless there're any other good benefits.
If really care, move clk operation into an inline function instead.
Another benefit if not doing that is the driver still can work even RPM not enabled.
Regards
Aisheng
Shall we change to use pm_runtime_get_sync() here?
Regards,
Clark Wang
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
use subsys_initcall for i2c driver to improve i2c driver probe priority
Will this affect DMA support which will be probed much later compared with subsys_initcall?
From: Wolfram Sang <wsa@kernel.org> Date: 2021-03-19 05:39:45
On Wed, Mar 17, 2021 at 02:53:54PM +0800, Clark Wang wrote:
From: Gao Pan <redacted>
use subsys_initcall for i2c driver to improve i2c driver probe priority
Signed-off-by: Gao Pan <redacted>
I usually don't take subsys_initcall patches anymore. In most cases, the
client drivers can be fixed instead. If this is not the case for you,
you need to state that explicitly in the commit message.
From: Clark Wang <xiaoning.wang@nxp.com> Date: 2021-03-19 07:40:42
-----Original Message-----
From: Wolfram Sang <wsa@kernel.org>
Sent: Friday, March 19, 2021 13:39
To: Clark Wang <xiaoning.wang@nxp.com>
Cc: Aisheng Dong <aisheng.dong@nxp.com>; shawnguo@kernel.org;
s.hauer@pengutronix.de; kernel@pengutronix.de; festevam@gmail.com;
dl-linux-imx [off-list ref]; sumit.semwal@linaro.org;
christian.koenig@amd.com; linux-i2c@vger.kernel.org; linux-arm-
kernel@lists.infradead.org; linux-kernel@vger.kernel.org
Subject: [EXT] Re: [PATCH 06/11] i2c: imx-lpi2c: improve i2c driver probe
priority
On Wed, Mar 17, 2021 at 02:53:54PM +0800, Clark Wang wrote:
quoted
From: Gao Pan <redacted>
use subsys_initcall for i2c driver to improve i2c driver probe
priority
Signed-off-by: Gao Pan <redacted>
I usually don't take subsys_initcall patches anymore. In most cases, the
client
drivers can be fixed instead. If this is not the case for you, you need to
state
that explicitly in the commit message.
Okay. Because it is an old patch, I will check if it is necessary. If no,
I will continue to use module_platform_driver(lpi2c_imx_driver);
Thanks.
Best Regards,
Clark Wang
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
Manage irq resource request/release in runtime pm to save irq domain's
power.
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Fugang Duan <redacted>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
---
drivers/i2c/busses/i2c-imx-lpi2c.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c
b/drivers/i2c/busses/i2c-imx-lpi2c.c
index 664fcc0dba51..e718bb6b2387 100644
From: Clark Wang <xiaoning.wang@nxp.com> Date: 2021-03-19 07:04:02
-----Original Message-----
From: Aisheng Dong <aisheng.dong@nxp.com>
Sent: Friday, March 19, 2021 12:54
To: Clark Wang <xiaoning.wang@nxp.com>; shawnguo@kernel.org;
s.hauer@pengutronix.de
Cc: kernel@pengutronix.de; festevam@gmail.com; dl-linux-imx <linux-
imx@nxp.com>; sumit.semwal@linaro.org; christian.koenig@amd.com;
linux-i2c@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
kernel@vger.kernel.org
Subject: RE: [PATCH 04/11] i2c: imx-lpi2c: manage irq resource
request/release in runtime pm
quoted
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
Manage irq resource request/release in runtime pm to save irq domain's
power.
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Fugang Duan <redacted>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
---
drivers/i2c/busses/i2c-imx-lpi2c.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c
b/drivers/i2c/busses/i2c-imx-lpi2c.c
index 664fcc0dba51..e718bb6b2387 100644
devm_request_irq() will use device resource management.
Other resource like clk and struct space are all managed by devres.
Maybe we can still use devm_ to let devres manage irq here?
Thanks.
Best Regards,
Clark Wang
devm_request_irq() will use device resource management.
Other resource like clk and struct space are all managed by devres.
Maybe we can still use devm_ to let devres manage irq here?
devm_xxx is usually used to auto free resources when probe fail,
driver unbound / device unregister and etc. Not for runtime pm.
I may prefer using request_irq/free_irq directly in runtime.
BTW, current lpi2c_imx_remove seems didn't ensure the device is
In runtime suspend state after removing.
If framework can't guarantee, the driver has to do it.
Anyway, that's another issue and need a separate patch.
Regards
Aisheng
From: Clark Wang <xiaoning.wang@nxp.com> Date: 2021-03-17 06:54:57
Switching the clock frequently will affect the data transmission
efficiency, and prolong the timeout to reduce autosuspend times for
lpi2c.
Acked-by: Fugang Duan <redacted>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
---
drivers/i2c/busses/i2c-imx-lpi2c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
Switching the clock frequently will affect the data transmission efficiency, and
prolong the timeout to reduce autosuspend times for lpi2c.
Acked-by: Fugang Duan <redacted>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
From: Clark Wang <xiaoning.wang@nxp.com> Date: 2021-03-17 06:54:57
Add bus recovery feature for LPI2C.
Need add gpio pinctrl, scl-gpios and sda-gpios configuration in dts.
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
---
drivers/i2c/busses/i2c-imx-lpi2c.c | 83 ++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
@@ -528,6 +540,71 @@ static irqreturn_t lpi2c_imx_isr(int irq, void *dev_id)returnIRQ_HANDLED;}+staticvoidlpi2c_imx_prepare_recovery(structi2c_adapter*adap)+{+structlpi2c_imx_struct*lpi2c_imx;++lpi2c_imx=container_of(adap,structlpi2c_imx_struct,adapter);++pinctrl_select_state(lpi2c_imx->pinctrl,lpi2c_imx->pinctrl_pins_gpio);+}++staticvoidlpi2c_imx_unprepare_recovery(structi2c_adapter*adap)+{+structlpi2c_imx_struct*lpi2c_imx;++lpi2c_imx=container_of(adap,structlpi2c_imx_struct,adapter);++pinctrl_select_state(lpi2c_imx->pinctrl,lpi2c_imx->pinctrl_pins_default);+}++/*+*WeswitchSCLandSDAtotheirGPIOfunctionanddosomebitbanging+*forbusrecovery.Thesealternativepinmuxsettingscanbe+*describedinthedevicetreebyaseparatepinctrlstate"gpio".If+*thisismissingthisisnotabigproblem,theonlyimplicationis+*thatwecan'tdobusrecovery.+*/+staticintlpi2c_imx_init_recovery_info(structlpi2c_imx_struct*lpi2c_imx,+structplatform_device*pdev)+{+structi2c_bus_recovery_info*rinfo=&lpi2c_imx->rinfo;++lpi2c_imx->pinctrl=devm_pinctrl_get(&pdev->dev);+if(!lpi2c_imx->pinctrl||IS_ERR(lpi2c_imx->pinctrl)){+dev_info(&pdev->dev,"can't get pinctrl, bus recovery not supported\n");+returnPTR_ERR(lpi2c_imx->pinctrl);+}++lpi2c_imx->pinctrl_pins_default=pinctrl_lookup_state(lpi2c_imx->pinctrl,+PINCTRL_STATE_DEFAULT);+lpi2c_imx->pinctrl_pins_gpio=pinctrl_lookup_state(lpi2c_imx->pinctrl,+"gpio");+rinfo->sda_gpiod=devm_gpiod_get(&pdev->dev,"sda",GPIOD_IN);+rinfo->scl_gpiod=devm_gpiod_get(&pdev->dev,"scl",GPIOD_OUT_HIGH_OPEN_DRAIN);++if(PTR_ERR(rinfo->sda_gpiod)==-EPROBE_DEFER||+PTR_ERR(rinfo->scl_gpiod)==-EPROBE_DEFER){+return-EPROBE_DEFER;+}elseif(IS_ERR(rinfo->sda_gpiod)||+IS_ERR(rinfo->scl_gpiod)||+IS_ERR(lpi2c_imx->pinctrl_pins_default)||+IS_ERR(lpi2c_imx->pinctrl_pins_gpio)){+dev_dbg(&pdev->dev,"recovery information incomplete\n");+return0;+}++dev_info(&pdev->dev,"using scl%s for recovery\n",+rinfo->sda_gpiod?",sda":"");++rinfo->prepare_recovery=lpi2c_imx_prepare_recovery;+rinfo->unprepare_recovery=lpi2c_imx_unprepare_recovery;+rinfo->recover_bus=i2c_generic_scl_recovery;+lpi2c_imx->adapter.bus_recovery_info=rinfo;++return0;+}+staticu32lpi2c_imx_func(structi2c_adapter*adapter){returnI2C_FUNC_I2C|I2C_FUNC_SMBUS_EMUL|
@@ -607,6 +684,12 @@ static int lpi2c_imx_probe(struct platform_device *pdev)pm_runtime_put(&pdev->dev);+/* Init optional bus recovery function */+ret=lpi2c_imx_init_recovery_info(lpi2c_imx,pdev);+/* Give it another chance if pinctrl used is not ready yet */+if(ret==-EPROBE_DEFER)+gotorpm_disable;+ret=i2c_add_adapter(&lpi2c_imx->adapter);if(ret)gotorpm_disable;
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
Add bus recovery feature for LPI2C.
Need add gpio pinctrl, scl-gpios and sda-gpios configuration in dts.
Pls also update dt-binding first
quoted hunk
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
---
drivers/i2c/busses/i2c-imx-lpi2c.c | 83 ++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c
b/drivers/i2c/busses/i2c-imx-lpi2c.c
index c0cb77c66090..7216a393095d 100644
@@ -528,6 +540,71 @@ static irqreturn_t lpi2c_imx_isr(int irq, void *dev_id) return IRQ_HANDLED; }+static void lpi2c_imx_prepare_recovery(struct i2c_adapter *adap) {+ struct lpi2c_imx_struct *lpi2c_imx;++ lpi2c_imx = container_of(adap, struct lpi2c_imx_struct, adapter);++ pinctrl_select_state(lpi2c_imx->pinctrl,+lpi2c_imx->pinctrl_pins_gpio); }++static void lpi2c_imx_unprepare_recovery(struct i2c_adapter *adap) {+ struct lpi2c_imx_struct *lpi2c_imx;++ lpi2c_imx = container_of(adap, struct lpi2c_imx_struct, adapter);++ pinctrl_select_state(lpi2c_imx->pinctrl,+lpi2c_imx->pinctrl_pins_default); }++/*+ * We switch SCL and SDA to their GPIO function and do some bitbanging+ * for bus recovery. These alternative pinmux settings can be+ * described in the device tree by a separate pinctrl state "gpio". If+ * this is missing this is not a big problem, the only implication is+ * that we can't do bus recovery.+ */+static int lpi2c_imx_init_recovery_info(struct lpi2c_imx_struct *lpi2c_imx,+ struct platform_device *pdev)+{+ struct i2c_bus_recovery_info *rinfo = &lpi2c_imx->rinfo;++ lpi2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev);+ if (!lpi2c_imx->pinctrl || IS_ERR(lpi2c_imx->pinctrl)) {+ dev_info(&pdev->dev, "can't get pinctrl, bus recovery not
@@ static int lpi2c_imx_probe(struct platform_device *pdev) pm_runtime_put(&pdev->dev);+ /* Init optional bus recovery function */+ ret = lpi2c_imx_init_recovery_info(lpi2c_imx, pdev);+ /* Give it another chance if pinctrl used is not ready yet */+ if (ret == -EPROBE_DEFER)+ goto rpm_disable;+ ret = i2c_add_adapter(&lpi2c_imx->adapter); if (ret) goto rpm_disable;--
From: Clark Wang <xiaoning.wang@nxp.com> Date: 2021-03-17 06:55:26
The clkhi and clklo ratio was not very precise before that can make the
time of START/STOP/HIGH LEVEL out of specification.
Therefore, the calculation of these times has been modified in this patch.
At the same time, the mode rate definition of i2c is corrected.
Reviewed-by: Fugang Duan <redacted>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
---
drivers/i2c/busses/i2c-imx-lpi2c.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
The clkhi and clklo ratio was not very precise before that can make the time of
START/STOP/HIGH LEVEL out of specification.
Therefore, the calculation of these times has been modified in this patch.
At the same time, the mode rate definition of i2c is corrected.
Reviewed-by: Fugang Duan <redacted>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
---
drivers/i2c/busses/i2c-imx-lpi2c.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c
b/drivers/i2c/busses/i2c-imx-lpi2c.c
index 7216a393095d..5dbe85126f24 100644
From: Clark Wang <xiaoning.wang@nxp.com> Date: 2021-03-19 07:22:25
-----Original Message-----
From: Aisheng Dong <aisheng.dong@nxp.com>
Sent: Friday, March 19, 2021 13:15
To: Clark Wang <xiaoning.wang@nxp.com>; shawnguo@kernel.org;
s.hauer@pengutronix.de
Cc: kernel@pengutronix.de; festevam@gmail.com; dl-linux-imx <linux-
imx@nxp.com>; sumit.semwal@linaro.org; christian.koenig@amd.com;
linux-i2c@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
kernel@vger.kernel.org
Subject: RE: [PATCH 09/11] i2c: imx-lpi2c: fix i2c timing issue
quoted
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
The clkhi and clklo ratio was not very precise before that can make
the time of START/STOP/HIGH LEVEL out of specification.
Therefore, the calculation of these times has been modified in this patch.
At the same time, the mode rate definition of i2c is corrected.
Reviewed-by: Fugang Duan <redacted>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
---
drivers/i2c/busses/i2c-imx-lpi2c.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c
b/drivers/i2c/busses/i2c-imx-lpi2c.c
index 7216a393095d..5dbe85126f24 100644
Where is this ratio coming from?
Can you describe why use it in commit message?
This ratio is a value obtained after passing the test.
I2C's Tlow should longer than the spec.
For example, in FAST mode, Tlow should be longer than 1.3us.
The previous calculation violated the spec.
So I re-write the calculation of clk_cycle by referring the RM. Then test the
ratio to let Tlow match the spec by catching the waveform.
Best Regards,
Clark Wang
From: Clark Wang <xiaoning.wang@nxp.com> Date: 2021-03-17 06:55:27
Claim clkhi and clklo as integer type to avoid possible calculation
errors caused by data overflow.
Reviewed-by: Fugang Duan <redacted>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
---
drivers/i2c/busses/i2c-imx-lpi2c.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
Claim clkhi and clklo as integer type to avoid possible calculation errors caused
by data overflow.
Reviewed-by: Fugang Duan <redacted>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
From: Clark Wang <xiaoning.wang@nxp.com> Date: 2021-03-17 06:55:27
Add eDMA receive and send mode support.
Support to read and write data larger than 256 bytes in one frame.
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Reviewed-by: Li Jun <redacted>
---
drivers/i2c/busses/i2c-imx-lpi2c.c | 291 ++++++++++++++++++++++++++++-
1 file changed, 289 insertions(+), 2 deletions(-)
From: Clark Wang <xiaoning.wang@nxp.com>
Sent: Wednesday, March 17, 2021 2:54 PM
Add eDMA receive and send mode support.
Support to read and write data larger than 256 bytes in one frame.
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Reviewed-by: Li Jun <redacted>
---
drivers/i2c/busses/i2c-imx-lpi2c.c | 291 ++++++++++++++++++++++++++++-
Pease update dt-binding first
quoted hunk
1 file changed, 289 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c
b/drivers/i2c/busses/i2c-imx-lpi2c.c
index 1e26672d47bf..6d920bf0dbd4 100644