diff mbox series

[v2,1/1] Add 10EC5280 to bmi160_i2c ACPI IDs to allow binding on some devices

Message ID 20240205183618.7761-3-jesusmgh@gmail.com (mailing list archive)
State Superseded
Headers show
Series [v2,1/1] Add 10EC5280 to bmi160_i2c ACPI IDs to allow binding on some devices | expand

Commit Message

Jesus Miguel Gonzalez Herrero Feb. 5, 2024, 6:36 p.m. UTC
"10EC5280" is used by several manufacturers like Lenovo, GPD, or AYA (and 
probably others) in their ACPI table as the ID for the bmi160 IMU. This 
means the bmi160_i2c driver won't bind to it, and the IMU is unavailable 
to the user. Manufacturers have been approached on several occasions to 
try getting a BIOS with a fixed ID, mostly without actual positive 
results, and since affected devices are already a few years old, this is 
not expected to change. This patch enables using the bmi160_i2c driver for 
the bmi160 IMU on these devices.

Here is the relevant extract from the DSDT of a GPD Win Max 2 (AMD 6800U
model) with the latest firmware 1.05 installed. GPD sees this as WONTFIX
with the argument of the device working with the Windows drivers.

     Scope (_SB.I2CC)
    {
        Device (BMA2)
        {
            Name (_ADR, Zero)  // _ADR: Address
            Name (_HID, "10EC5280")  // _HID: Hardware ID
            Name (_CID, "10EC5280")  // _CID: Compatible ID
            Name (_DDN, "Accelerometer")  // _DDN: DOS Device Name
            Name (_UID, One)  // _UID: Unique ID
            Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
            {
                Name (RBUF, ResourceTemplate ()
                {
                    I2cSerialBusV2 (0x0069, ControllerInitiated, 0x00061A80,
                        AddressingMode7Bit, "\\_SB.I2CC",
                        0x00, ResourceConsumer, , Exclusive,
                        )
                })
                Return (RBUF) /* \_SB_.I2CC.BMA2._CRS.RBUF */
            }

            OperationRegion (CMS2, SystemIO, 0x72, 0x02)
            Field (CMS2, ByteAcc, NoLock, Preserve)
            {
                IND2,   8, 
                DAT2,   8
            }

            IndexField (IND2, DAT2, ByteAcc, NoLock, Preserve)
            {
                Offset (0x74), 
                BACS,   32
            }

            Method (ROMS, 0, NotSerialized)
            {
                Name (RBUF, Package (0x03)
                {
                    "0 -1 0", 
                    "-1 0 0", 
                    "0 0 1"
                })
                Return (RBUF) /* \_SB_.I2CC.BMA2.ROMS.RBUF */
            }

            Method (CALS, 1, NotSerialized)
            {
                Local0 = Arg0
                If (((Local0 == Zero) || (Local0 == Ones)))
                {
                    Return (Local0)
                }
                Else
                {
                    BACS = Local0
                }
            }

            Method (_STA, 0, NotSerialized)  // _STA: Status
            {
                Return (0x0F)
            }
        }
    }

Signed-off-by: Jesus Gonzalez <jesusmgh@gmail.com>
---
v2 patch implementing the improvements mentioned by Mr. Cameron and Mr.
Shevchenko, if I understood them correctly. Please tell me if anything
else should be changed, and I'll be happy to make a new revision.

Thank you!


 drivers/iio/imu/bmi160/bmi160_spi.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Andy Shevchenko Feb. 6, 2024, 12:35 p.m. UTC | #1
On Mon, Feb 05, 2024 at 07:36:20PM +0100, Jesus Gonzalez wrote:

Thank you for the update, my comments below.

First of all, it would be nice also to try to contact with Realtek and make
them aware again. Have anybody talked to them previously?

Also read this thread:
https://lore.kernel.org/linux-iio/CACAwPwYQHRcrabw9=0tvenPzAcwwW1pTaR6a+AEWBF9Hqf_wXQ@mail.gmail.com/

> "10EC5280" is used by several manufacturers like Lenovo, GPD, or AYA (and 
> probably others) in their ACPI table as the ID for the bmi160 IMU. This 
> means the bmi160_i2c driver won't bind to it, and the IMU is unavailable 
> to the user. Manufacturers have been approached on several occasions to 
> try getting a BIOS with a fixed ID, mostly without actual positive 
> results, and since affected devices are already a few years old, this is 
> not expected to change. This patch enables using the bmi160_i2c driver for 
> the bmi160 IMU on these devices.

You have trailing whitespaces in each of the line.

> Here is the relevant extract from the DSDT of a GPD Win Max 2 (AMD 6800U
> model) with the latest firmware 1.05 installed. GPD sees this as WONTFIX
> with the argument of the device working with the Windows drivers.

>      Scope (_SB.I2CC)
>     {

Cut off these 2 lines.

>         Device (BMA2)
>         {
>             Name (_ADR, Zero)  // _ADR: Address
>             Name (_HID, "10EC5280")  // _HID: Hardware ID
>             Name (_CID, "10EC5280")  // _CID: Compatible ID
>             Name (_DDN, "Accelerometer")  // _DDN: DOS Device Name
>             Name (_UID, One)  // _UID: Unique ID
>             Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
>             {
>                 Name (RBUF, ResourceTemplate ()
>                 {
>                     I2cSerialBusV2 (0x0069, ControllerInitiated, 0x00061A80,
>                         AddressingMode7Bit, "\\_SB.I2CC",
>                         0x00, ResourceConsumer, , Exclusive,
>                         )
>                 })
>                 Return (RBUF) /* \_SB_.I2CC.BMA2._CRS.RBUF */
>             }

Please, cut the below...

> 
>             OperationRegion (CMS2, SystemIO, 0x72, 0x02)
>             Field (CMS2, ByteAcc, NoLock, Preserve)
>             {
>                 IND2,   8, 
>                 DAT2,   8
>             }
> 
>             IndexField (IND2, DAT2, ByteAcc, NoLock, Preserve)
>             {
>                 Offset (0x74), 
>                 BACS,   32
>             }
> 
>             Method (ROMS, 0, NotSerialized)
>             {
>                 Name (RBUF, Package (0x03)
>                 {
>                     "0 -1 0", 
>                     "-1 0 0", 
>                     "0 0 1"
>                 })
>                 Return (RBUF) /* \_SB_.I2CC.BMA2.ROMS.RBUF */
>             }
> 
>             Method (CALS, 1, NotSerialized)
>             {
>                 Local0 = Arg0
>                 If (((Local0 == Zero) || (Local0 == Ones)))
>                 {
>                     Return (Local0)
>                 }
>                 Else
>                 {
>                     BACS = Local0
>                 }
>             }
> 
>             Method (_STA, 0, NotSerialized)  // _STA: Status
>             {
>                 Return (0x0F)
>             }

...till here. Replace it by ... on a single line.

>         }


>     }

As per above (this is part of Scope, so drop it as well).

...

> +	/* FIRMWARE BUG WORKAROUND
> +	 * Some manufacturers like GPD, Lenovo or Aya used the incorrect
> +	 * ID "10EC5280" for bmi160 in their DSDT. A fixed firmware is not
> +	 * available as of Feb 2024 after trying to work with OEMs, and
> +	 * this is not expected to change anymore since at least some of
> +	 * the affected devices are from 2021/2022.
> +	 */
> +	{"10EC5280", 0},

 /*
  * Please, use the correct style of
  * multi-line comments, like in this
  * example.
  */
diff mbox series

Patch

diff --git a/drivers/iio/imu/bmi160/bmi160_spi.c b/drivers/iio/imu/bmi160/bmi160_spi.c
index 8b573ea99af2..f88d4b2ba79b 100644
--- a/drivers/iio/imu/bmi160/bmi160_spi.c
+++ b/drivers/iio/imu/bmi160/bmi160_spi.c
@@ -40,6 +40,14 @@  static const struct spi_device_id bmi160_spi_id[] = {
 MODULE_DEVICE_TABLE(spi, bmi160_spi_id);
 
 static const struct acpi_device_id bmi160_acpi_match[] = {
+	/* FIRMWARE BUG WORKAROUND
+	 * Some manufacturers like GPD, Lenovo or Aya used the incorrect
+	 * ID "10EC5280" for bmi160 in their DSDT. A fixed firmware is not
+	 * available as of Feb 2024 after trying to work with OEMs, and
+	 * this is not expected to change anymore since at least some of
+	 * the affected devices are from 2021/2022.
+	 */
+	{"10EC5280", 0},
 	{"BMI0160", 0},
 	{ },
 };