Set sda-hold-time based on ACPI *CNT value
Subsystems (3)
PATCH v2 1/1 Set sda-hold-time based on ACPI *CNT value
From: Tan Chin Yew <[email protected]>
For I2c to operate correctly under all speed mode, sda-hold-time need to be perfectly tuned. However, sda-hold-time is precalculated according to circuit parameter which make it platform-specific.
In order to get accurate sda-hold-time for all platforms, pretuned sda-hold-time for particular platform is stored in ACPI table and driver to load the sda holding time from ACPI table.
This patch read the I2c sda-hold-time from ACPI table and assigned the suitable hold time based on the i2c clock frequency.
Tested on Intel Apollo Lake.
Changes in V2:
- The code is realigned according to suggestion.
- "case 400000:" is added on top of "default:" for readability.
Tan Chin Yew (1):
i2c: designware: Get selected speed mode sda-hold-time via ACPI
drivers/i2c/busses/i2c-designware-platdrv.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/1 i2c: designware: Get selected speed mode sda-hold-time via ACPI
From: Tan Chin Yew <[email protected]>
Sda-hold-time is an important parameter for tuning i2c to meet the electrical specification especially for high speed. I2C with incorrect sda-hold-time may cause lost arbitration error. Now, the driver is able to get sda-hold-time for all the speed supported.
--- drivers/i2c/busses/i2c-designware-platdrv.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-designware-platdrv.c +21 -7
@@ -101,14 +101,28 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev) dev->rx_fifo_depth =32 ;/* -* Try to get SDA hold time and *CNT values from an ACPI method if -* it exists for both supported speed modes. +* Try to get SDA hold time and *CNT values from an ACPI method for +* selected speed modes. */ -dw_i2c_acpi_params (pdev,"SSCN" , &dev->ss_hcnt, &dev->ss_lcnt,NULL ); -dw_i2c_acpi_params (pdev,"FMCN" , &dev->fs_hcnt, &dev->fs_lcnt, - &dev->sda_hold_time); -dw_i2c_acpi_params (pdev,"FPCN" , &dev->fp_hcnt, &dev->fp_lcnt,NULL ); -dw_i2c_acpi_params (pdev,"HSCN" , &dev->hs_hcnt, &dev->hs_lcnt,NULL ); +switch (dev->clk_freq) { +case 100000 : +dw_i2c_acpi_params (pdev,"SSCN" , &dev->ss_hcnt, &dev->ss_lcnt, + &dev->sda_hold_time); +break ; +case 1000000 : +dw_i2c_acpi_params (pdev,"FPCN" , &dev->fp_hcnt, &dev->fp_lcnt, + &dev->sda_hold_time); +break ; +case 3400000 : +dw_i2c_acpi_params (pdev,"HSCN" , &dev->hs_hcnt, &dev->hs_lcnt, + &dev->sda_hold_time); +break ; +case 400000 : +default : +dw_i2c_acpi_params (pdev,"FMCN" , &dev->fs_hcnt, &dev->fs_lcnt, + &dev->sda_hold_time); +break ; + } id =acpi_match_device (pdev->dev.driver->acpi_match_table, &pdev->dev);if (id && id->driver_data)
Signature · 1 line
1.9.1
Re: [PATCH] i2c: designware: Get selected speed mode sda-hold-time via ACPI
Quoted 7 lines · On 14.02.2017 07:54, [email protected] wrote:
From: Tan Chin Yew <[email protected]>
Sda-hold-time is an important parameter for tuning i2c to meet the electrical specification especially for high speed. I2C with incorrect sda-hold-time may cause lost arbitration error. Now, the driver is able to get sda-hold-time for all the speed supported.
Quoted 5 lines
Signed-off-by Tan Chin Yew <[email protected]>--- drivers/i2c/busses/i2c-designware-platdrv.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
Re: [PATCH] i2c: designware: Get selected speed mode sda-hold-time via ACPI
In reply to [email protected]Quoted 8 lines · On Tue, 2017-02-14 at 13:54 +0800, [email protected] wrote:
From: Tan Chin Yew <[email protected]>
Sda-hold-time is an important parameter for tuning i2c to meet the electrical specification especially for high speed. I2C with incorrect sda-hold-time may cause lost arbitration error. Now, the driver is able to
get sda-hold-time for all the speed supported.
Quoted 59 lines
Signed-off-by Tan Chin Yew <[email protected]>---
drivers/i2c/busses/i2c-designware-platdrv.c | 28
+++++++++++++++++++++-------1 file changed, 21 insertions(+), 7 deletions(-)drivers/i2c/busses/i2c-designware-platdrv.c +0
-0@@ -101,14 +101,28 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev) dev->rx_fifo_depth = 32;
/*drivers/i2c/busses/i2c-designware-platdrv.c +0
-1- * Try to get SDA hold time and *CNT values from an ACPImethod if
drivers/i2c/busses/i2c-designware-platdrv.c +1
-1- * it exists for both supported speed modes. + * Try to get SDA hold time and *CNT values from an ACPImethod for
drivers/i2c/busses/i2c-designware-platdrv.c +1
-0+ * selected speed modes.*/
drivers/i2c/busses/i2c-designware-platdrv.c +0
-1- dw_i2c_acpi_params(pdev, "SSCN", &dev->ss_hcnt, &dev-Quoted 1 line
ss_lcnt, NULL);drivers/i2c/busses/i2c-designware-platdrv.c +0
-1- dw_i2c_acpi_params(pdev, "FMCN", &dev->fs_hcnt, &dev-Quoted 1 line
fs_lcnt,drivers/i2c/busses/i2c-designware-platdrv.c +0
-2- &dev->sda_hold_time); - dw_i2c_acpi_params(pdev, "FPCN", &dev->fp_hcnt, &dev-Quoted 1 line
fp_lcnt, NULL);drivers/i2c/busses/i2c-designware-platdrv.c +0
-1- dw_i2c_acpi_params(pdev, "HSCN", &dev->hs_hcnt, &dev-Quoted 1 line
hs_lcnt, NULL);drivers/i2c/busses/i2c-designware-platdrv.c +3
-0+switch (dev->clk_freq) { +case 100000 : + dw_i2c_acpi_params(pdev, "SSCN", &dev->ss_hcnt, &dev-Quoted 1 line
ss_lcnt,drivers/i2c/busses/i2c-designware-platdrv.c +4
-0+ &dev->sda_hold_time); +break ; +case 1000000 : + dw_i2c_acpi_params(pdev, "FPCN", &dev->fp_hcnt, &dev-Quoted 1 line
fp_lcnt,drivers/i2c/busses/i2c-designware-platdrv.c +4
-0+ &dev->sda_hold_time); +break ; +case 3400000 : + dw_i2c_acpi_params(pdev, "HSCN", &dev->hs_hcnt, &dev-Quoted 1 line
hs_lcnt,drivers/i2c/busses/i2c-designware-platdrv.c +5
-0+ &dev->sda_hold_time); +break ; +case 400000 : +default : + dw_i2c_acpi_params(pdev, "FMCN", &dev->fs_hcnt, &dev-Quoted 1 line
fs_lcnt,drivers/i2c/busses/i2c-designware-platdrv.c +3
-0+ &dev->sda_hold_time); +break ; + }
id =acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev);
if (id &&id->driver_data)
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
RE: [PATCH] i2c: designware: Get selected speed mode sda-hold-time via ACPI
In reply to Jarkko NikulaHi Wolfram,
Wondering if you manage to review this patch?
It is about loading selected speed mode's sda-hold-time via ACPI.
I would like to find out if there are any additional comments?
Sincerely
Tan Chin Yew
Quoted 25 lines
-----Original Message-----
From: Jarkko Nikula [mailto:[email protected]]
Sent: Tuesday, February 14, 2017 3:01 PM
To: Tan, Chin Yew <[email protected]>; [email protected]; [email protected]
Cc: [email protected]
Subject: Re: [PATCH] i2c: designware: Get selected speed mode sda-hold-time via ACPIQuoted 7 lines · On 14.02.2017 07:54, [email protected] wrote:
From: Tan Chin Yew <[email protected]>
Sda-hold-time is an important parameter for tuning i2c to meet the electrical specification especially for high speed. I2C with incorrect sda-hold-time may cause lost arbitration error. Now, the driver is able to get sda-hold-time for all the speed supported.
Quoted 6 lines
Signed-off-by Tan Chin Yew <[email protected]>--- drivers/i2c/busses/i2c-designware-platdrv.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)Acked-by Jarkko Nikula <[email protected]>
Re: [PATCH] i2c: designware: Get selected speed mode sda-hold-time via ACPI
In reply to [email protected]Quoted 6 lines · On Tue, Feb 14, 2017 at 01:54:01PM +0800, [email protected] wrote:
From: Tan Chin Yew <[email protected]>
Sda-hold-time is an important parameter for tuning i2c to meet the electrical specification especially for high speed. I2C with incorrect sda-hold-time may cause lost arbitration error. Now, the driver is able to get sda-hold-time for all the speed supported.
This describes why you change NULL to dev->sda_hold_time. But it doesn't say why you introduce the switch-block instead of populating all fields like it was done before.
Furthermore, since now there is no NULL case for dw_i2c_acpi_params() anymore, we can remove NULL handling in that function, or?
Re: [PATCH] i2c: designware: Get selected speed mode sda-hold-time via ACPI
Quoted 7 lines
This describes why you change NULL to
dev->sda_hold_time. But it doesn't say why you introduce the switch-block instead of populating all fields like it was done before.Furthermore, since now there is no NULL case for
dw_i2c_acpi_params()anymore, we can remove NULL handling in that function, or?
And since designware driver had a few changes meanwhile, can you base the next version on top of i2c/for-next?
RE: [PATCH] i2c: designware: Get selected speed mode sda-hold-time via ACPI
Hi
Quoted 13 lines
-----Original Message-----
From: Wolfram Sang [mailto:[email protected]]
Sent: Friday, March 24, 2017 5:01 AM
To: Tan, Chin Yew <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] i2c: designware: Get selected speed mode sda-hold-time via ACPIQuoted 3 lines
This describes why you change NULL to
dev->sda_hold_time. But it doesn't say why you introduce the switch-block instead of populating all fields like it was done before.
Instead of loading all speed mode settings, switch block is used to load the required settings for selected speed mode.
Furthermore, using switch block re-use existing variable, Whereas, populating all fields introduce new variables.
Quoted 3 lines
Quoted 3 lines
Furthermore, since now there is no NULL case for
dw_i2c_acpi_params()anymore, we can remove NULL handling in that function, or?
Ok, I will remove the null handling.
Quoted 4 lines
And since designware driver had a few changes meanwhile, can you base the next version on top of i2c/for-next?
Ok, I will base it to i2c/for-next.
Re: [PATCH] i2c: designware: Get selected speed mode sda-hold-time via ACPI
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
This describes why you change NULL to
dev->sda_hold_time. But it doesn't say why you introduce the switch-block instead of populating all fields like it was done before.Instead of loading all speed mode settings, switch block is used to load the required settings for selected speed mode.
Thanks. Please add this sentence to the commit message.