* [PATCH v3] i2c: cadence: Add standard bus recovery support
@ 2022-07-28 5:51 Shubhrajyoti Datta
2022-07-29 10:56 ` Michal Simek
2022-09-27 20:32 ` Wolfram Sang
0 siblings, 2 replies; 8+ messages in thread
From: Shubhrajyoti Datta @ 2022-07-28 5:51 UTC (permalink / raw)
To: linux-i2c
Cc: michal.simek, git-dev, Shubhrajyoti Datta, Chirag Parekh, Robert Hancock
Hook up the standard GPIO/pinctrl-based recovery support.
We are doing the recovery at the beginning on a timeout.
Multiple people have contributed to the series.
Original patch from Cirag and another one from Robert.
Cc: Chirag Parekh <chiragp@xilinx.com>
Cc: Robert Hancock <robert.hancock@calian.com>
Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
---
v2:
Updated the busbusy check on a timeout
v3:
Added pinctrl_get
Did unit testing and probed the scl to see the clock pulses.
drivers/i2c/busses/i2c-cadence.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index 630cfa4ddd46..c9a10d4297a9 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -10,10 +10,12 @@
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/io.h>
+#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/pm_runtime.h>
+#include <linux/pinctrl/consumer.h>
/* Register offsets for the I2C device. */
#define CDNS_I2C_CR_OFFSET 0x00 /* Control Register, RW */
@@ -127,6 +129,8 @@
#define CDNS_I2C_TIMEOUT_MAX 0xFF
#define CDNS_I2C_BROKEN_HOLD_BIT BIT(0)
+#define CDNS_I2C_POLL_US 100000
+#define CDNS_I2C_TIMEOUT_US 500000
#define cdns_i2c_readreg(offset) readl_relaxed(id->membase + offset)
#define cdns_i2c_writereg(val, offset) writel_relaxed(val, id->membase + offset)
@@ -204,6 +208,7 @@ struct cdns_i2c {
struct notifier_block clk_rate_change_nb;
u32 quirks;
u32 ctrl_reg;
+ struct i2c_bus_recovery_info rinfo;
#if IS_ENABLED(CONFIG_I2C_SLAVE)
u16 ctrl_reg_diva_divb;
struct i2c_client *slave;
@@ -832,8 +837,14 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
#endif
/* Check if the bus is free */
- if (cdns_i2c_readreg(CDNS_I2C_SR_OFFSET) & CDNS_I2C_SR_BA) {
+
+ ret = readl_relaxed_poll_timeout(id->membase + CDNS_I2C_SR_OFFSET,
+ reg,
+ !(reg & CDNS_I2C_SR_BA),
+ CDNS_I2C_POLL_US, CDNS_I2C_TIMEOUT_US);
+ if (ret) {
ret = -EAGAIN;
+ i2c_recover_bus(adap);
goto out;
}
@@ -1242,6 +1253,12 @@ static int cdns_i2c_probe(struct platform_device *pdev)
id->quirks = data->quirks;
}
+ id->rinfo.pinctrl = devm_pinctrl_get(&pdev->dev);
+ if (IS_ERR(id->rinfo.pinctrl)) {
+ dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n");
+ return PTR_ERR(id->rinfo.pinctrl);
+ }
+
id->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &r_mem);
if (IS_ERR(id->membase))
return PTR_ERR(id->membase);
@@ -1258,6 +1275,7 @@ static int cdns_i2c_probe(struct platform_device *pdev)
id->adap.retries = 3; /* Default retry value. */
id->adap.algo_data = id;
id->adap.dev.parent = &pdev->dev;
+ id->adap.bus_recovery_info = &id->rinfo;
init_completion(&id->xfer_done);
snprintf(id->adap.name, sizeof(id->adap.name),
"Cadence I2C at %08lx", (unsigned long)r_mem->start);
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v3] i2c: cadence: Add standard bus recovery support
2022-07-28 5:51 [PATCH v3] i2c: cadence: Add standard bus recovery support Shubhrajyoti Datta
@ 2022-07-29 10:56 ` Michal Simek
2022-07-29 11:05 ` Datta, Shubhrajyoti
2022-09-27 20:32 ` Wolfram Sang
1 sibling, 1 reply; 8+ messages in thread
From: Michal Simek @ 2022-07-29 10:56 UTC (permalink / raw)
To: Shubhrajyoti Datta, linux-i2c
Cc: michal.simek, git-dev, Chirag Parekh, Robert Hancock
On 7/28/22 07:51, Shubhrajyoti Datta wrote:
> Hook up the standard GPIO/pinctrl-based recovery support.
> We are doing the recovery at the beginning on a timeout.
>
> Multiple people have contributed to the series.
> Original patch from Cirag and another one from Robert.
>
> Cc: Chirag Parekh <chiragp@xilinx.com>
> Cc: Robert Hancock <robert.hancock@calian.com>
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
> ---
> v2:
> Updated the busbusy check on a timeout
> v3:
> Added pinctrl_get
>
> Did unit testing and probed the scl to see the clock pulses.
Can you please describe testing procedure? What board did you use?
What was the hardware configuration?
Thanks,
Michal
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH v3] i2c: cadence: Add standard bus recovery support
2022-07-29 10:56 ` Michal Simek
@ 2022-07-29 11:05 ` Datta, Shubhrajyoti
2022-07-29 11:17 ` Michal Simek
0 siblings, 1 reply; 8+ messages in thread
From: Datta, Shubhrajyoti @ 2022-07-29 11:05 UTC (permalink / raw)
To: Simek, Michal, Shubhrajyoti Datta, linux-i2c
Cc: michal.simek, git-dev (AMD-Xilinx), Chirag Parekh, Robert Hancock
[AMD Official Use Only - General]
> -----Original Message-----
> From: Simek, Michal <michal.simek@amd.com>
> Sent: Friday, July 29, 2022 4:26 PM
> To: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>; linux-
> i2c@vger.kernel.org
> Cc: michal.simek@xilinx.com; git-dev (AMD-Xilinx) <git-dev@amd.com>;
> Chirag Parekh <chiragp@xilinx.com>; Robert Hancock
> <robert.hancock@calian.com>
> Subject: Re: [PATCH v3] i2c: cadence: Add standard bus recovery support
>
>
>
> On 7/28/22 07:51, Shubhrajyoti Datta wrote:
> > Hook up the standard GPIO/pinctrl-based recovery support.
> > We are doing the recovery at the beginning on a timeout.
> >
> > Multiple people have contributed to the series.
> > Original patch from Cirag and another one from Robert.
> >
> > Cc: Chirag Parekh <chiragp@xilinx.com>
> > Cc: Robert Hancock <robert.hancock@calian.com>
> > Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
> > ---
> > v2:
> > Updated the busbusy check on a timeout
> > v3:
> > Added pinctrl_get
> >
> > Did unit testing and probed the scl to see the clock pulses.
>
> Can you please describe testing procedure? What board did you use?
> What was the hardware configuration?
Tested on zcu102 . and then I called the recovery in send setup .
Also I had added the prints in the
To confirm that the core was calling the zynqmp pinctrl to set pin mux.
The scl line was Probed. I could see the clock cycles in the scl line.
[ 84.286340] zynqmp-pinctrl firmware:zynqmp-firmware:pinctrl: set mux for pin 14
[ 84.293779] zynqmp-pinctrl firmware:zynqmp-firmware:pinctrl: set mux for pin 15
[ 84.301266] i2c-core: set_scl_gpio_value 164 1
[ 84.305807] i2c i2c-0: SCL is set_scl 1 i ia 1
[ 84.310331] i2c-core: get_scl_gpio_value 158
[ 84.314681] i2c-core: set_scl_gpio_value 164 0
[ 84.322519] i2c i2c-0: SCL is set_scl 0
[ 84.326439] i2c i2c-0: SCL is set_scl 0 i ia 2
[ 84.330965] i2c-core: set_scl_gpio_value 164 1
[ 84.335496] i2c i2c-0: SCL is set_scl 1
[ 84.339418] i2c i2c-0: SCL is set_scl 1 i ia 3
[ 84.343947] i2c-core: get_scl_gpio_value 158
[ 84.348302] i2c-core: set_scl_gpio_value 164 0
[ 84.356135] i2c i2c-0: SCL is set_scl 0
[ 84.360059] i2c i2c-0: SCL is set_scl 0 i ia 4
[ 84.364586] i2c-core: set_scl_gpio_value 164 1
[ 84.369117] i2c i2c-0: SCL is set_scl 1
[ 84.373037] i2c i2c-0: SCL is set_scl 1 i ia 5
[ 84.377564] i2c-core: get_scl_gpio_value 158
[ 84.381914] i2c-core: set_scl_gpio_value 164 0
>
> Thanks,
> Michal
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3] i2c: cadence: Add standard bus recovery support
2022-07-29 11:05 ` Datta, Shubhrajyoti
@ 2022-07-29 11:17 ` Michal Simek
2022-09-27 7:06 ` Michal Simek
0 siblings, 1 reply; 8+ messages in thread
From: Michal Simek @ 2022-07-29 11:17 UTC (permalink / raw)
To: Datta, Shubhrajyoti, Shubhrajyoti Datta, linux-i2c
Cc: michal.simek, git-dev (AMD-Xilinx), Chirag Parekh, Robert Hancock
On 7/29/22 13:05, Datta, Shubhrajyoti wrote:
> [AMD Official Use Only - General]
>
>
>
>> -----Original Message-----
>> From: Simek, Michal <michal.simek@amd.com>
>> Sent: Friday, July 29, 2022 4:26 PM
>> To: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>; linux-
>> i2c@vger.kernel.org
>> Cc: michal.simek@xilinx.com; git-dev (AMD-Xilinx) <git-dev@amd.com>;
>> Chirag Parekh <chiragp@xilinx.com>; Robert Hancock
>> <robert.hancock@calian.com>
>> Subject: Re: [PATCH v3] i2c: cadence: Add standard bus recovery support
>>
>>
>>
>> On 7/28/22 07:51, Shubhrajyoti Datta wrote:
>>> Hook up the standard GPIO/pinctrl-based recovery support.
>>> We are doing the recovery at the beginning on a timeout.
>>>
>>> Multiple people have contributed to the series.
>>> Original patch from Cirag and another one from Robert.
>>>
>>> Cc: Chirag Parekh <chiragp@xilinx.com>
>>> Cc: Robert Hancock <robert.hancock@calian.com>
>>> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
>>> ---
>>> v2:
>>> Updated the busbusy check on a timeout
>>> v3:
>>> Added pinctrl_get
>>>
>>> Did unit testing and probed the scl to see the clock pulses.
>>
>> Can you please describe testing procedure? What board did you use?
>> What was the hardware configuration?
>
>
> Tested on zcu102 . and then I called the recovery in send setup .
> Also I had added the prints in the
> To confirm that the core was calling the zynqmp pinctrl to set pin mux.
>
> The scl line was Probed. I could see the clock cycles in the scl line.
>
> [ 84.286340] zynqmp-pinctrl firmware:zynqmp-firmware:pinctrl: set mux for pin 14
> [ 84.293779] zynqmp-pinctrl firmware:zynqmp-firmware:pinctrl: set mux for pin 15
> [ 84.301266] i2c-core: set_scl_gpio_value 164 1
> [ 84.305807] i2c i2c-0: SCL is set_scl 1 i ia 1
> [ 84.310331] i2c-core: get_scl_gpio_value 158
> [ 84.314681] i2c-core: set_scl_gpio_value 164 0
> [ 84.322519] i2c i2c-0: SCL is set_scl 0
> [ 84.326439] i2c i2c-0: SCL is set_scl 0 i ia 2
> [ 84.330965] i2c-core: set_scl_gpio_value 164 1
> [ 84.335496] i2c i2c-0: SCL is set_scl 1
> [ 84.339418] i2c i2c-0: SCL is set_scl 1 i ia 3
> [ 84.343947] i2c-core: get_scl_gpio_value 158
> [ 84.348302] i2c-core: set_scl_gpio_value 164 0
> [ 84.356135] i2c i2c-0: SCL is set_scl 0
> [ 84.360059] i2c i2c-0: SCL is set_scl 0 i ia 4
> [ 84.364586] i2c-core: set_scl_gpio_value 164 1
> [ 84.369117] i2c i2c-0: SCL is set_scl 1
> [ 84.373037] i2c i2c-0: SCL is set_scl 1 i ia 5
> [ 84.377564] i2c-core: get_scl_gpio_value 158
> [ 84.381914] i2c-core: set_scl_gpio_value 164 0
ok. Thanks.
Acked-by: Michal Simek <michal.simek@amd.com>
Thanks,
Michal
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3] i2c: cadence: Add standard bus recovery support
2022-07-29 11:17 ` Michal Simek
@ 2022-09-27 7:06 ` Michal Simek
0 siblings, 0 replies; 8+ messages in thread
From: Michal Simek @ 2022-09-27 7:06 UTC (permalink / raw)
To: Datta, Shubhrajyoti, Shubhrajyoti Datta, linux-i2c
Cc: michal.simek, git-dev (AMD-Xilinx), Chirag Parekh, Robert Hancock
Hi Wolfram,
On 7/29/22 13:17, Michal Simek wrote:
>
>
> On 7/29/22 13:05, Datta, Shubhrajyoti wrote:
>> [AMD Official Use Only - General]
>>
>>
>>
>>> -----Original Message-----
>>> From: Simek, Michal <michal.simek@amd.com>
>>> Sent: Friday, July 29, 2022 4:26 PM
>>> To: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>; linux-
>>> i2c@vger.kernel.org
>>> Cc: michal.simek@xilinx.com; git-dev (AMD-Xilinx) <git-dev@amd.com>;
>>> Chirag Parekh <chiragp@xilinx.com>; Robert Hancock
>>> <robert.hancock@calian.com>
>>> Subject: Re: [PATCH v3] i2c: cadence: Add standard bus recovery support
>>>
>>>
>>>
>>> On 7/28/22 07:51, Shubhrajyoti Datta wrote:
>>>> Hook up the standard GPIO/pinctrl-based recovery support.
>>>> We are doing the recovery at the beginning on a timeout.
>>>>
>>>> Multiple people have contributed to the series.
>>>> Original patch from Cirag and another one from Robert.
>>>>
>>>> Cc: Chirag Parekh <chiragp@xilinx.com>
>>>> Cc: Robert Hancock <robert.hancock@calian.com>
>>>> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
>>>> ---
>>>> v2:
>>>> Updated the busbusy check on a timeout
>>>> v3:
>>>> Added pinctrl_get
>>>>
>>>> Did unit testing and probed the scl to see the clock pulses.
>>>
>>> Can you please describe testing procedure? What board did you use?
>>> What was the hardware configuration?
>>
>>
>> Tested on zcu102 . and then I called the recovery in send setup .
>> Also I had added the prints in the
>> To confirm that the core was calling the zynqmp pinctrl to set pin mux.
>>
>> The scl line was Probed. I could see the clock cycles in the scl line.
>>
>> [ 84.286340] zynqmp-pinctrl firmware:zynqmp-firmware:pinctrl: set mux for
>> pin 14
>> [ 84.293779] zynqmp-pinctrl firmware:zynqmp-firmware:pinctrl: set mux for
>> pin 15
>> [ 84.301266] i2c-core: set_scl_gpio_value 164 1
>> [ 84.305807] i2c i2c-0: SCL is set_scl 1 i ia 1
>> [ 84.310331] i2c-core: get_scl_gpio_value 158
>> [ 84.314681] i2c-core: set_scl_gpio_value 164 0
>> [ 84.322519] i2c i2c-0: SCL is set_scl 0
>> [ 84.326439] i2c i2c-0: SCL is set_scl 0 i ia 2
>> [ 84.330965] i2c-core: set_scl_gpio_value 164 1
>> [ 84.335496] i2c i2c-0: SCL is set_scl 1
>> [ 84.339418] i2c i2c-0: SCL is set_scl 1 i ia 3
>> [ 84.343947] i2c-core: get_scl_gpio_value 158
>> [ 84.348302] i2c-core: set_scl_gpio_value 164 0
>> [ 84.356135] i2c i2c-0: SCL is set_scl 0
>> [ 84.360059] i2c i2c-0: SCL is set_scl 0 i ia 4
>> [ 84.364586] i2c-core: set_scl_gpio_value 164 1
>> [ 84.369117] i2c i2c-0: SCL is set_scl 1
>> [ 84.373037] i2c i2c-0: SCL is set_scl 1 i ia 5
>> [ 84.377564] i2c-core: get_scl_gpio_value 158
>> [ 84.381914] i2c-core: set_scl_gpio_value 164 0
>
> ok. Thanks.
>
> Acked-by: Michal Simek <michal.simek@amd.com>
>
Do you see any issue with this version?
Thanks,
Michal
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3] i2c: cadence: Add standard bus recovery support
2022-07-28 5:51 [PATCH v3] i2c: cadence: Add standard bus recovery support Shubhrajyoti Datta
2022-07-29 10:56 ` Michal Simek
@ 2022-09-27 20:32 ` Wolfram Sang
2022-09-27 20:35 ` Wolfram Sang
1 sibling, 1 reply; 8+ messages in thread
From: Wolfram Sang @ 2022-09-27 20:32 UTC (permalink / raw)
To: Shubhrajyoti Datta
Cc: linux-i2c, michal.simek, git-dev, Chirag Parekh, Robert Hancock
[-- Attachment #1: Type: text/plain, Size: 502 bytes --]
On Thu, Jul 28, 2022 at 11:21:50AM +0530, Shubhrajyoti Datta wrote:
> Hook up the standard GPIO/pinctrl-based recovery support.
> We are doing the recovery at the beginning on a timeout.
>
> Multiple people have contributed to the series.
> Original patch from Cirag and another one from Robert.
>
> Cc: Chirag Parekh <chiragp@xilinx.com>
> Cc: Robert Hancock <robert.hancock@calian.com>
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3] i2c: cadence: Add standard bus recovery support
2022-09-27 20:32 ` Wolfram Sang
@ 2022-09-27 20:35 ` Wolfram Sang
2022-09-29 7:29 ` Michal Simek
0 siblings, 1 reply; 8+ messages in thread
From: Wolfram Sang @ 2022-09-27 20:35 UTC (permalink / raw)
To: Shubhrajyoti Datta, linux-i2c, michal.simek, git-dev,
Chirag Parekh, Robert Hancock
[-- Attachment #1: Type: text/plain, Size: 679 bytes --]
> Applied to for-next, thanks!
Unrelated to this patch, but cppcheck found this issue:
drivers/i2c/busses/i2c-cadence.c:1038:33: warning: Condition 'actual_fscl>fscl' is always false [knownConditionTrueFalse]
current_error = ((actual_fscl > fscl) ? (actual_fscl - fscl) :
^
drivers/i2c/busses/i2c-cadence.c:1035:19: note: Assuming that condition 'actual_fscl>fscl' is not redundant
if (actual_fscl > fscl)
^
drivers/i2c/busses/i2c-cadence.c:1038:33: note: Condition 'actual_fscl>fscl' is always false
current_error = ((actual_fscl > fscl) ? (actual_fscl - fscl) :
I had a glimpse and I think the checker is correct...
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3] i2c: cadence: Add standard bus recovery support
2022-09-27 20:35 ` Wolfram Sang
@ 2022-09-29 7:29 ` Michal Simek
0 siblings, 0 replies; 8+ messages in thread
From: Michal Simek @ 2022-09-29 7:29 UTC (permalink / raw)
To: Wolfram Sang, Shubhrajyoti Datta, linux-i2c, michal.simek,
git-dev, Chirag Parekh, Robert Hancock
Hi Wolfram,
On 9/27/22 22:35, Wolfram Sang wrote:
>
>> Applied to for-next, thanks!
>
> Unrelated to this patch, but cppcheck found this issue:
>
> drivers/i2c/busses/i2c-cadence.c:1038:33: warning: Condition 'actual_fscl>fscl' is always false [knownConditionTrueFalse]
> current_error = ((actual_fscl > fscl) ? (actual_fscl - fscl) :
> ^
> drivers/i2c/busses/i2c-cadence.c:1035:19: note: Assuming that condition 'actual_fscl>fscl' is not redundant
> if (actual_fscl > fscl)
> ^
> drivers/i2c/busses/i2c-cadence.c:1038:33: note: Condition 'actual_fscl>fscl' is always false
> current_error = ((actual_fscl > fscl) ? (actual_fscl - fscl) :
>
> I had a glimpse and I think the checker is correct...
Are you still using your ninja-check script?
Can you please share your latest version?
Thanks,
Michal
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-09-29 7:29 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-28 5:51 [PATCH v3] i2c: cadence: Add standard bus recovery support Shubhrajyoti Datta
2022-07-29 10:56 ` Michal Simek
2022-07-29 11:05 ` Datta, Shubhrajyoti
2022-07-29 11:17 ` Michal Simek
2022-09-27 7:06 ` Michal Simek
2022-09-27 20:32 ` Wolfram Sang
2022-09-27 20:35 ` Wolfram Sang
2022-09-29 7:29 ` Michal Simek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.