diff mbox

i2c: designware: don't infer timings described by ACPI from clock rate

Message ID 20170519085640.15111-1-ard.biesheuvel@linaro.org
State Accepted
Commit 9d6408433019bfae15e2d0d5f4498c4ff70b86c0
Headers show

Commit Message

Ard Biesheuvel May 19, 2017, 8:56 a.m. UTC
Commit bd698d24b1b57 ("i2c: designware: Get selected speed mode
sda-hold-time via ACPI") updated the logic that reads the timing
parameters for various I2C bus rates from the DSDT, to only read
the timing parameters for the currently selected mode.

This causes a WARN_ON() splat on platforms that legally omit the clock
frequency from the ACPI description, because in the new situation, the
core I2C designware driver still accesses the fields in the driver
struct that we no longer populate, and proceeds to calculate them from
the clock frequency. Since the clock frequency is unspecified, the
driver complains loudly using a WARN_ON().

So revert back to the old situation, where the struct fields for all
timings are populated, but retain the new logic which chooses the SDA
hold time from the timing mode that is currently in use.

Fixes: bd698d24b1b57 ("i2c: designware: Get selected speed mode ...")
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 drivers/i2c/busses/i2c-designware-platdrv.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Jarkko Nikula May 19, 2017, 10:01 a.m. UTC | #1
On 05/19/2017 11:56 AM, Ard Biesheuvel wrote:
> Commit bd698d24b1b57 ("i2c: designware: Get selected speed mode

> sda-hold-time via ACPI") updated the logic that reads the timing

> parameters for various I2C bus rates from the DSDT, to only read

> the timing parameters for the currently selected mode.

>

> This causes a WARN_ON() splat on platforms that legally omit the clock

> frequency from the ACPI description, because in the new situation, the

> core I2C designware driver still accesses the fields in the driver

> struct that we no longer populate, and proceeds to calculate them from

> the clock frequency. Since the clock frequency is unspecified, the

> driver complains loudly using a WARN_ON().

>

> So revert back to the old situation, where the struct fields for all

> timings are populated, but retain the new logic which chooses the SDA

> hold time from the timing mode that is currently in use.

>

> Fixes: bd698d24b1b57 ("i2c: designware: Get selected speed mode ...")

> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---

>  drivers/i2c/busses/i2c-designware-platdrv.c | 18 ++++++++++--------

>  1 file changed, 10 insertions(+), 8 deletions(-)

>

Thanks, this is ok to me. Let's add also kudos to Lorenzo:

Reported-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ard Biesheuvel May 19, 2017, 10:06 a.m. UTC | #2
On 19 May 2017 at 11:01, Jarkko Nikula <jarkko.nikula@linux.intel.com> wrote:
> On 05/19/2017 11:56 AM, Ard Biesheuvel wrote:

>>

>> Commit bd698d24b1b57 ("i2c: designware: Get selected speed mode

>> sda-hold-time via ACPI") updated the logic that reads the timing

>> parameters for various I2C bus rates from the DSDT, to only read

>> the timing parameters for the currently selected mode.

>>

>> This causes a WARN_ON() splat on platforms that legally omit the clock

>> frequency from the ACPI description, because in the new situation, the

>> core I2C designware driver still accesses the fields in the driver

>> struct that we no longer populate, and proceeds to calculate them from

>> the clock frequency. Since the clock frequency is unspecified, the

>> driver complains loudly using a WARN_ON().

>>

>> So revert back to the old situation, where the struct fields for all

>> timings are populated, but retain the new logic which chooses the SDA

>> hold time from the timing mode that is currently in use.

>>

>> Fixes: bd698d24b1b57 ("i2c: designware: Get selected speed mode ...")

>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

>> ---

>>  drivers/i2c/busses/i2c-designware-platdrv.c | 18 ++++++++++--------

>>  1 file changed, 10 insertions(+), 8 deletions(-)

>>

> Thanks, this is ok to me. Let's add also kudos to Lorenzo:

>

> Reported-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>


Thanks. I suppose this is going in as a fix? If not, please cc to -stable
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jarkko Nikula May 19, 2017, 10:37 a.m. UTC | #3
On 05/19/2017 01:06 PM, Ard Biesheuvel wrote:
> On 19 May 2017 at 11:01, Jarkko Nikula <jarkko.nikula@linux.intel.com> wrote:

>> On 05/19/2017 11:56 AM, Ard Biesheuvel wrote:

>>>

>>> Commit bd698d24b1b57 ("i2c: designware: Get selected speed mode

>>> sda-hold-time via ACPI") updated the logic that reads the timing

>>> parameters for various I2C bus rates from the DSDT, to only read

>>> the timing parameters for the currently selected mode.

>>>

>>> This causes a WARN_ON() splat on platforms that legally omit the clock

>>> frequency from the ACPI description, because in the new situation, the

>>> core I2C designware driver still accesses the fields in the driver

>>> struct that we no longer populate, and proceeds to calculate them from

>>> the clock frequency. Since the clock frequency is unspecified, the

>>> driver complains loudly using a WARN_ON().

>>>

>>> So revert back to the old situation, where the struct fields for all

>>> timings are populated, but retain the new logic which chooses the SDA

>>> hold time from the timing mode that is currently in use.

>>>

>>> Fixes: bd698d24b1b57 ("i2c: designware: Get selected speed mode ...")

>>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

>>> ---

>>>  drivers/i2c/busses/i2c-designware-platdrv.c | 18 ++++++++++--------

>>>  1 file changed, 10 insertions(+), 8 deletions(-)

>>>

>> Thanks, this is ok to me. Let's add also kudos to Lorenzo:

>>

>> Reported-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

>> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>

>

> Thanks. I suppose this is going in as a fix? If not, please cc to -stable

>

That's not needed as the bd698d24b1b57 came during pre 4.12-rc1 cycle. 
But good to get this into 4.12 due probable regression in high-speed 
transfers and to get rid of log spamming.

-- 
Jarkko
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ard Biesheuvel May 19, 2017, 10:48 a.m. UTC | #4
On 19 May 2017 at 11:37, Jarkko Nikula <jarkko.nikula@linux.intel.com> wrote:
> On 05/19/2017 01:06 PM, Ard Biesheuvel wrote:

>>

>> On 19 May 2017 at 11:01, Jarkko Nikula <jarkko.nikula@linux.intel.com>

>> wrote:

>>>

>>> On 05/19/2017 11:56 AM, Ard Biesheuvel wrote:

>>>>

>>>>

>>>> Commit bd698d24b1b57 ("i2c: designware: Get selected speed mode

>>>> sda-hold-time via ACPI") updated the logic that reads the timing

>>>> parameters for various I2C bus rates from the DSDT, to only read

>>>> the timing parameters for the currently selected mode.

>>>>

>>>> This causes a WARN_ON() splat on platforms that legally omit the clock

>>>> frequency from the ACPI description, because in the new situation, the

>>>> core I2C designware driver still accesses the fields in the driver

>>>> struct that we no longer populate, and proceeds to calculate them from

>>>> the clock frequency. Since the clock frequency is unspecified, the

>>>> driver complains loudly using a WARN_ON().

>>>>

>>>> So revert back to the old situation, where the struct fields for all

>>>> timings are populated, but retain the new logic which chooses the SDA

>>>> hold time from the timing mode that is currently in use.

>>>>

>>>> Fixes: bd698d24b1b57 ("i2c: designware: Get selected speed mode ...")

>>>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

>>>> ---

>>>>  drivers/i2c/busses/i2c-designware-platdrv.c | 18 ++++++++++--------

>>>>  1 file changed, 10 insertions(+), 8 deletions(-)

>>>>

>>> Thanks, this is ok to me. Let's add also kudos to Lorenzo:

>>>

>>> Reported-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

>>> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>

>>

>>

>> Thanks. I suppose this is going in as a fix? If not, please cc to -stable

>>

> That's not needed as the bd698d24b1b57 came during pre 4.12-rc1 cycle. But

> good to get this into 4.12 due probable regression in high-speed transfers

> and to get rid of log spamming.

>


Agreed. Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wolfram Sang May 19, 2017, 12:38 p.m. UTC | #5
On Fri, May 19, 2017 at 09:56:40AM +0100, Ard Biesheuvel wrote:
> Commit bd698d24b1b57 ("i2c: designware: Get selected speed mode

> sda-hold-time via ACPI") updated the logic that reads the timing

> parameters for various I2C bus rates from the DSDT, to only read

> the timing parameters for the currently selected mode.

> 

> This causes a WARN_ON() splat on platforms that legally omit the clock

> frequency from the ACPI description, because in the new situation, the

> core I2C designware driver still accesses the fields in the driver

> struct that we no longer populate, and proceeds to calculate them from

> the clock frequency. Since the clock frequency is unspecified, the

> driver complains loudly using a WARN_ON().

> 

> So revert back to the old situation, where the struct fields for all

> timings are populated, but retain the new logic which chooses the SDA

> hold time from the timing mode that is currently in use.

> 

> Fixes: bd698d24b1b57 ("i2c: designware: Get selected speed mode ...")

> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>


Applied to for-current, thanks!
Ard Biesheuvel May 21, 2017, 8:09 a.m. UTC | #6
On 19 May 2017 at 09:56, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> Commit bd698d24b1b57 ("i2c: designware: Get selected speed mode

> sda-hold-time via ACPI") updated the logic that reads the timing

> parameters for various I2C bus rates from the DSDT, to only read

> the timing parameters for the currently selected mode.

>

> This causes a WARN_ON() splat on platforms that legally omit the clock

> frequency from the ACPI description, because in the new situation, the

> core I2C designware driver still accesses the fields in the driver

> struct that we no longer populate, and proceeds to calculate them from

> the clock frequency. Since the clock frequency is unspecified, the

> driver complains loudly using a WARN_ON().

>

> So revert back to the old situation, where the struct fields for all

> timings are populated, but retain the new logic which chooses the SDA

> hold time from the timing mode that is currently in use.

>

> Fixes: bd698d24b1b57 ("i2c: designware: Get selected speed mode ...")

> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---

>  drivers/i2c/busses/i2c-designware-platdrv.c | 18 ++++++++++--------

>  1 file changed, 10 insertions(+), 8 deletions(-)

>

> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c

> index f2acd4b6bf01..6283b99d2b17 100644

> --- a/drivers/i2c/busses/i2c-designware-platdrv.c

> +++ b/drivers/i2c/busses/i2c-designware-platdrv.c

> @@ -96,6 +96,7 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev)

>         struct dw_i2c_dev *dev = platform_get_drvdata(pdev);

>         acpi_handle handle = ACPI_HANDLE(&pdev->dev);

>         const struct acpi_device_id *id;

> +       u32 ss_ht, fp_ht, hs_ht, fs_ht;


Should these be initialized to zero? I realized that
dw_i2c_acpi_params() could fail, resulting in bogus hold time values
being returnted, but it is unclear to me how that affects the logic in
the core driver.

>         struct acpi_device *adev;

>         const char *uid;

>

> @@ -107,23 +108,24 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev)

>          * 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, &ss_ht);

> +       dw_i2c_acpi_params(pdev, "FPCN", &dev->fp_hcnt, &dev->fp_lcnt, &fp_ht);

> +       dw_i2c_acpi_params(pdev, "HSCN", &dev->hs_hcnt, &dev->hs_lcnt, &hs_ht);

> +       dw_i2c_acpi_params(pdev, "FMCN", &dev->fs_hcnt, &dev->fs_lcnt, &fs_ht);

> +

>         switch (dev->clk_freq) {

>         case 100000:

> -               dw_i2c_acpi_params(pdev, "SSCN", &dev->ss_hcnt, &dev->ss_lcnt,

> -                                  &dev->sda_hold_time);

> +               dev->sda_hold_time = ss_ht;

>                 break;

>         case 1000000:

> -               dw_i2c_acpi_params(pdev, "FPCN", &dev->fp_hcnt, &dev->fp_lcnt,

> -                                  &dev->sda_hold_time);

> +               dev->sda_hold_time = fp_ht;

>                 break;

>         case 3400000:

> -               dw_i2c_acpi_params(pdev, "HSCN", &dev->hs_hcnt, &dev->hs_lcnt,

> -                                  &dev->sda_hold_time);

> +               dev->sda_hold_time = hs_ht;

>                 break;

>         case 400000:

>         default:

> -               dw_i2c_acpi_params(pdev, "FMCN", &dev->fs_hcnt, &dev->fs_lcnt,

> -                                  &dev->sda_hold_time);

> +               dev->sda_hold_time = fs_ht;

>                 break;

>         }

>

> --

> 2.9.3

>

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jan Kiszka May 22, 2017, 5:44 a.m. UTC | #7
On 2017-05-21 10:09, Ard Biesheuvel wrote:
> On 19 May 2017 at 09:56, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:

>> Commit bd698d24b1b57 ("i2c: designware: Get selected speed mode

>> sda-hold-time via ACPI") updated the logic that reads the timing

>> parameters for various I2C bus rates from the DSDT, to only read

>> the timing parameters for the currently selected mode.

>>

>> This causes a WARN_ON() splat on platforms that legally omit the clock

>> frequency from the ACPI description, because in the new situation, the

>> core I2C designware driver still accesses the fields in the driver

>> struct that we no longer populate, and proceeds to calculate them from

>> the clock frequency. Since the clock frequency is unspecified, the

>> driver complains loudly using a WARN_ON().

>>

>> So revert back to the old situation, where the struct fields for all

>> timings are populated, but retain the new logic which chooses the SDA

>> hold time from the timing mode that is currently in use.

>>

>> Fixes: bd698d24b1b57 ("i2c: designware: Get selected speed mode ...")

>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

>> ---

>>  drivers/i2c/busses/i2c-designware-platdrv.c | 18 ++++++++++--------

>>  1 file changed, 10 insertions(+), 8 deletions(-)

>>

>> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c

>> index f2acd4b6bf01..6283b99d2b17 100644

>> --- a/drivers/i2c/busses/i2c-designware-platdrv.c

>> +++ b/drivers/i2c/busses/i2c-designware-platdrv.c

>> @@ -96,6 +96,7 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev)

>>         struct dw_i2c_dev *dev = platform_get_drvdata(pdev);

>>         acpi_handle handle = ACPI_HANDLE(&pdev->dev);

>>         const struct acpi_device_id *id;

>> +       u32 ss_ht, fp_ht, hs_ht, fs_ht;

> 

> Should these be initialized to zero? I realized that

> dw_i2c_acpi_params() could fail, resulting in bogus hold time values

> being returnted, but it is unclear to me how that affects the logic in

> the core driver.


I can tell you what happens: this breaks e.g. the Galileo and the
IOT2000 boards. Will send a patch to initialize the vars to 0, restoring
the previous behavior in the absence to the ACPI parameters. The core is
prepared for sda_hold_time == 0.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ard Biesheuvel May 22, 2017, 6:02 a.m. UTC | #8
> On 22 May 2017, at 07:46, Jan Kiszka <jan.kiszka@siemens.com> wrote:

> 

> We need to initializes those variables to 0 for platforms that do not

> provide ACPI parameters. Otherwise, we set sda_hold_time to random

> values, breaking e.g. Galileo and IOT2000 boards.

> 

> Fixes: 9d6408433019 ("i2c: designware: don't infer timings described by ACPI from clock rate")

> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>


Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>


> ---

> 

> Affects 4.12-rc2.

> 

> drivers/i2c/busses/i2c-designware-platdrv.c | 2 +-

> 1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c

> index 6283b99d2b17..d1263b82d646 100644

> --- a/drivers/i2c/busses/i2c-designware-platdrv.c

> +++ b/drivers/i2c/busses/i2c-designware-platdrv.c

> @@ -94,9 +94,9 @@ static void dw_i2c_acpi_params(struct platform_device *pdev, char method[],

> static int dw_i2c_acpi_configure(struct platform_device *pdev)

> {

>    struct dw_i2c_dev *dev = platform_get_drvdata(pdev);

> +    u32 ss_ht = 0, fp_ht = 0, hs_ht = 0, fs_ht = 0;

>    acpi_handle handle = ACPI_HANDLE(&pdev->dev);

>    const struct acpi_device_id *id;

> -    u32 ss_ht, fp_ht, hs_ht, fs_ht;

>    struct acpi_device *adev;

>    const char *uid;

> 

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jarkko Nikula May 22, 2017, 6:35 a.m. UTC | #9
On 05/22/2017 08:44 AM, Jan Kiszka wrote:
> On 2017-05-21 10:09, Ard Biesheuvel wrote:

>> On 19 May 2017 at 09:56, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:

>>> Commit bd698d24b1b57 ("i2c: designware: Get selected speed mode

>>> sda-hold-time via ACPI") updated the logic that reads the timing

>>> parameters for various I2C bus rates from the DSDT, to only read

>>> the timing parameters for the currently selected mode.

>>>

>>> This causes a WARN_ON() splat on platforms that legally omit the clock

>>> frequency from the ACPI description, because in the new situation, the

>>> core I2C designware driver still accesses the fields in the driver

>>> struct that we no longer populate, and proceeds to calculate them from

>>> the clock frequency. Since the clock frequency is unspecified, the

>>> driver complains loudly using a WARN_ON().

>>>

>>> So revert back to the old situation, where the struct fields for all

>>> timings are populated, but retain the new logic which chooses the SDA

>>> hold time from the timing mode that is currently in use.

>>>

>>> Fixes: bd698d24b1b57 ("i2c: designware: Get selected speed mode ...")

>>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

>>> ---

>>>  drivers/i2c/busses/i2c-designware-platdrv.c | 18 ++++++++++--------

>>>  1 file changed, 10 insertions(+), 8 deletions(-)

>>>

>>> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c

>>> index f2acd4b6bf01..6283b99d2b17 100644

>>> --- a/drivers/i2c/busses/i2c-designware-platdrv.c

>>> +++ b/drivers/i2c/busses/i2c-designware-platdrv.c

>>> @@ -96,6 +96,7 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev)

>>>         struct dw_i2c_dev *dev = platform_get_drvdata(pdev);

>>>         acpi_handle handle = ACPI_HANDLE(&pdev->dev);

>>>         const struct acpi_device_id *id;

>>> +       u32 ss_ht, fp_ht, hs_ht, fs_ht;

>>

>> Should these be initialized to zero? I realized that

>> dw_i2c_acpi_params() could fail, resulting in bogus hold time values

>> being returnted, but it is unclear to me how that affects the logic in

>> the core driver.

>

Oh, indeed, great you found this quickly and we got also report and fix 
quickly from Jan. In bad case this could have been difficult to bisect.

> I can tell you what happens: this breaks e.g. the Galileo and the

> IOT2000 boards. Will send a patch to initialize the vars to 0, restoring

> the previous behavior in the absence to the ACPI parameters. The core is

> prepared for sda_hold_time == 0.

>

Yes, i2c-designware-core.c will read the hold time from HW set by 
bootloader or the reset default when dev->sda_hold_time is zero.

-- 
Jarkko

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jarkko Nikula May 22, 2017, 6:37 a.m. UTC | #10
On 05/22/2017 08:46 AM, Jan Kiszka wrote:
> We need to initializes those variables to 0 for platforms that do not

> provide ACPI parameters. Otherwise, we set sda_hold_time to random

> values, breaking e.g. Galileo and IOT2000 boards.

>

> Fixes: 9d6408433019 ("i2c: designware: don't infer timings described by ACPI from clock rate")

> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>

> ---

>

> Affects 4.12-rc2.

>

Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wolfram Sang May 22, 2017, 8:36 a.m. UTC | #11
On Mon, May 22, 2017 at 07:46:55AM +0200, Jan Kiszka wrote:
> We need to initializes those variables to 0 for platforms that do not

> provide ACPI parameters. Otherwise, we set sda_hold_time to random

> values, breaking e.g. Galileo and IOT2000 boards.

> 

> Fixes: 9d6408433019 ("i2c: designware: don't infer timings described by ACPI from clock rate")

> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>


Applied to for-current, thanks!
diff mbox

Patch

diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index f2acd4b6bf01..6283b99d2b17 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -96,6 +96,7 @@  static int dw_i2c_acpi_configure(struct platform_device *pdev)
 	struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
 	acpi_handle handle = ACPI_HANDLE(&pdev->dev);
 	const struct acpi_device_id *id;
+	u32 ss_ht, fp_ht, hs_ht, fs_ht;
 	struct acpi_device *adev;
 	const char *uid;
 
@@ -107,23 +108,24 @@  static int dw_i2c_acpi_configure(struct platform_device *pdev)
 	 * 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, &ss_ht);
+	dw_i2c_acpi_params(pdev, "FPCN", &dev->fp_hcnt, &dev->fp_lcnt, &fp_ht);
+	dw_i2c_acpi_params(pdev, "HSCN", &dev->hs_hcnt, &dev->hs_lcnt, &hs_ht);
+	dw_i2c_acpi_params(pdev, "FMCN", &dev->fs_hcnt, &dev->fs_lcnt, &fs_ht);
+
 	switch (dev->clk_freq) {
 	case 100000:
-		dw_i2c_acpi_params(pdev, "SSCN", &dev->ss_hcnt, &dev->ss_lcnt,
-				   &dev->sda_hold_time);
+		dev->sda_hold_time = ss_ht;
 		break;
 	case 1000000:
-		dw_i2c_acpi_params(pdev, "FPCN", &dev->fp_hcnt, &dev->fp_lcnt,
-				   &dev->sda_hold_time);
+		dev->sda_hold_time = fp_ht;
 		break;
 	case 3400000:
-		dw_i2c_acpi_params(pdev, "HSCN", &dev->hs_hcnt, &dev->hs_lcnt,
-				   &dev->sda_hold_time);
+		dev->sda_hold_time = hs_ht;
 		break;
 	case 400000:
 	default:
-		dw_i2c_acpi_params(pdev, "FMCN", &dev->fs_hcnt, &dev->fs_lcnt,
-				   &dev->sda_hold_time);
+		dev->sda_hold_time = fs_ht;
 		break;
 	}