[2/2] i2c: designware: Some broken DSTDs use 1MiHz instead of 1MHz

Submitted by Hans de Goede on July 8, 2017, 1:10 p.m.

Details

Message ID 20170708131052.13524-2-hdegoede@redhat.com
State New
Headers show

Commit Message

Hans de Goede July 8, 2017, 1:10 p.m.
At least the Acer Iconia Tab8 / aka W1-810 uses 1MiHz instead of
1MHz for one of its busses, fix this up to 1MHz instead of failing
the probe of that bus.

This fixes the accelerometer on the Acer Iconia Tab8 not working.

Cc: stable@vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/i2c/busses/i2c-designware-platdrv.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Andy Shevchenko July 8, 2017, 1:55 p.m.
On Sat, 2017-07-08 at 15:10 +0200, Hans de Goede wrote:
> At least the Acer Iconia Tab8 / aka W1-810 uses 1MiHz instead of
> 1MHz for one of its busses, fix this up to 1MHz instead of failing
> the probe of that bus.
> 
> This fixes the accelerometer on the Acer Iconia Tab8 not working.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/i2c/busses/i2c-designware-platdrv.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c
> b/drivers/i2c/busses/i2c-designware-platdrv.c
> index d5acaf8d65bf..c6f5a41d72b5 100644
> --- a/drivers/i2c/busses/i2c-designware-platdrv.c
> +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
> @@ -254,6 +254,9 @@ static int dw_i2c_plat_probe(struct
> platform_device *pdev)
>  	}
>  
>  	acpi_speed = i2c_acpi_find_bus_speed(&pdev->dev);
> +	/* Some broken DSTDs use 1MiHz instead of 1MHz */
> +	if (acpi_speed == 1048576)
> +		acpi_speed = 1000000;

I would rather convert to choose closest one, though I am not sure at
all which approach would be better in long term.

>  	/*
>  	 * Find bus speed from the "clock-frequency" device property,
> ACPI
>  	 * or by using fast mode if neither is set.
Hans de Goede July 9, 2017, 6:54 p.m.
Hi,

On 08-07-17 15:55, Andy Shevchenko wrote:
> On Sat, 2017-07-08 at 15:10 +0200, Hans de Goede wrote:
>> At least the Acer Iconia Tab8 / aka W1-810 uses 1MiHz instead of
>> 1MHz for one of its busses, fix this up to 1MHz instead of failing
>> the probe of that bus.
>>
>> This fixes the accelerometer on the Acer Iconia Tab8 not working.
>>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>   drivers/i2c/busses/i2c-designware-platdrv.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c
>> b/drivers/i2c/busses/i2c-designware-platdrv.c
>> index d5acaf8d65bf..c6f5a41d72b5 100644
>> --- a/drivers/i2c/busses/i2c-designware-platdrv.c
>> +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
>> @@ -254,6 +254,9 @@ static int dw_i2c_plat_probe(struct
>> platform_device *pdev)
>>   	}
>>   
>>   	acpi_speed = i2c_acpi_find_bus_speed(&pdev->dev);
>> +	/* Some broken DSTDs use 1MiHz instead of 1MHz */
>> +	if (acpi_speed == 1048576)
>> +		acpi_speed = 1000000;
> 
> I would rather convert to choose closest one, though I am not sure at
> all which approach would be better in long term.

We could always choose the closest lower one. I've been thinking
about doing that instead myself.

Wolfram, do you have any opinion on this ?

Regards,

Hans


> 
>>   	/*
>>   	 * Find bus speed from the "clock-frequency" device property,
>> ACPI
>>   	 * or by using fast mode if neither is set.
>

Patch hide | download patch | download mbox

diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index d5acaf8d65bf..c6f5a41d72b5 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -254,6 +254,9 @@  static int dw_i2c_plat_probe(struct platform_device *pdev)
 	}
 
 	acpi_speed = i2c_acpi_find_bus_speed(&pdev->dev);
+	/* Some broken DSTDs use 1MiHz instead of 1MHz */
+	if (acpi_speed == 1048576)
+		acpi_speed = 1000000;
 	/*
 	 * Find bus speed from the "clock-frequency" device property, ACPI
 	 * or by using fast mode if neither is set.