Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: imu: bmi270: Add support for BMI260

Adds support for the Bosch BMI260 6-axis IMU to the Bosch BMI270
driver. Setup and operation is nearly identical to the Bosch BMI270,
but has a different chip ID and requires different firmware.

Firmware is requested and loaded from userspace.

Adds ACPI ID BMI0160, used by several devices including the GPD Win
Mini, Aya Neo AIR Pro, and OXP Mini Pro.

GPD Win Mini:

Device (BMI2)
{
Name (_ADR, Zero) // _ADR: Address
Name (_HID, "BMI0160") // _HID: Hardware ID
Name (_CID, "BMI0160") // _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 (0x0068, ControllerInitiated, 0x00061A80,
AddressingMode7Bit, "\\_SB.I2CB",
0x00, ResourceConsumer, , Exclusive,
)
GpioInt (Edge, ActiveLow, Exclusive, PullDefault, 0x0000,
"\\_SB.GPIO", 0x00, ResourceConsumer, ,
)
{ // Pin list
0x008B
}
})
Return (RBUF) /* \_SB_.I2CB.BMI2._CRS.RBUF */
}
...
}

Signed-off-by: Justin Weiss <justin@justinweiss.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241027172029.160134-5-justin@justinweiss.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Justin Weiss and committed by
Jonathan Cameron
f35f3c83 b6ee20af

+39 -1
+1
drivers/iio/imu/bmi270/bmi270.h
··· 29 29 }; 30 30 31 31 extern const struct regmap_config bmi270_regmap_config; 32 + extern const struct bmi270_chip_info bmi260_chip_info; 32 33 extern const struct bmi270_chip_info bmi270_chip_info; 33 34 34 35 int bmi270_core_probe(struct device *dev, struct regmap *regmap,
+27 -1
drivers/iio/imu/bmi270/bmi270_core.c
··· 14 14 #include "bmi270.h" 15 15 16 16 #define BMI270_CHIP_ID_REG 0x00 17 + 18 + /* Checked to prevent sending incompatible firmware to BMI160 devices */ 19 + #define BMI160_CHIP_ID_VAL 0xD1 20 + 21 + #define BMI260_CHIP_ID_VAL 0x27 17 22 #define BMI270_CHIP_ID_VAL 0x24 18 23 #define BMI270_CHIP_ID_MSK GENMASK(7, 0) 19 24 ··· 69 64 #define BMI270_PWR_CTRL_ACCEL_EN_MSK BIT(2) 70 65 #define BMI270_PWR_CTRL_TEMP_EN_MSK BIT(3) 71 66 67 + #define BMI260_INIT_DATA_FILE "bmi260-init-data.fw" 72 68 #define BMI270_INIT_DATA_FILE "bmi270-init-data.fw" 73 69 74 70 enum bmi270_scan { ··· 91 85 BIT(BMI270_SCAN_GYRO_Z)), 92 86 0 93 87 }; 88 + 89 + const struct bmi270_chip_info bmi260_chip_info = { 90 + .name = "bmi260", 91 + .chip_id = BMI260_CHIP_ID_VAL, 92 + .fw_name = BMI260_INIT_DATA_FILE, 93 + }; 94 + EXPORT_SYMBOL_NS_GPL(bmi260_chip_info, IIO_BMI270); 94 95 95 96 const struct bmi270_chip_info bmi270_chip_info = { 96 97 .name = "bmi270", ··· 558 545 if (ret) 559 546 return dev_err_probe(dev, ret, "Failed to read chip id"); 560 547 548 + /* 549 + * Some manufacturers use "BMI0160" for both the BMI160 and 550 + * BMI260. If the device is actually a BMI160, the bmi160 551 + * driver should handle it and this driver should not. 552 + */ 553 + if (chip_id == BMI160_CHIP_ID_VAL) 554 + return -ENODEV; 555 + 561 556 if (chip_id != bmi270_device->chip_info->chip_id) 562 - dev_info(dev, "Unknown chip id 0x%x", chip_id); 557 + dev_info(dev, "Unexpected chip id 0x%x", chip_id); 558 + 559 + if (chip_id == bmi260_chip_info.chip_id) 560 + bmi270_device->chip_info = &bmi260_chip_info; 561 + else if (chip_id == bmi270_chip_info.chip_id) 562 + bmi270_device->chip_info = &bmi270_chip_info; 563 563 564 564 return 0; 565 565 }
+9
drivers/iio/imu/bmi270/bmi270_i2c.c
··· 32 32 } 33 33 34 34 static const struct i2c_device_id bmi270_i2c_id[] = { 35 + { "bmi260", (kernel_ulong_t)&bmi260_chip_info }, 35 36 { "bmi270", (kernel_ulong_t)&bmi270_chip_info }, 36 37 { } 37 38 }; 38 39 40 + static const struct acpi_device_id bmi270_acpi_match[] = { 41 + /* GPD Win Mini, Aya Neo AIR Pro, OXP Mini Pro, etc. */ 42 + { "BMI0160", (kernel_ulong_t)&bmi260_chip_info }, 43 + { } 44 + }; 45 + 39 46 static const struct of_device_id bmi270_of_match[] = { 47 + { .compatible = "bosch,bmi260", .data = &bmi260_chip_info }, 40 48 { .compatible = "bosch,bmi270", .data = &bmi270_chip_info }, 41 49 { } 42 50 }; ··· 52 44 static struct i2c_driver bmi270_i2c_driver = { 53 45 .driver = { 54 46 .name = "bmi270_i2c", 47 + .acpi_match_table = bmi270_acpi_match, 55 48 .of_match_table = bmi270_of_match, 56 49 }, 57 50 .probe = bmi270_i2c_probe,
+2
drivers/iio/imu/bmi270/bmi270_spi.c
··· 65 65 } 66 66 67 67 static const struct spi_device_id bmi270_spi_id[] = { 68 + { "bmi260", (kernel_ulong_t)&bmi260_chip_info }, 68 69 { "bmi270", (kernel_ulong_t)&bmi270_chip_info }, 69 70 { } 70 71 }; 71 72 72 73 static const struct of_device_id bmi270_of_match[] = { 74 + { .compatible = "bosch,bmi260", .data = &bmi260_chip_info }, 73 75 { .compatible = "bosch,bmi270", .data = &bmi270_chip_info }, 74 76 { } 75 77 };