2024-09-12 17:07:19 -04:00
|
|
|
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
|
|
|
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/iio/iio.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/mod_devicetable.h>
|
2025-05-25 16:25:29 +02:00
|
|
|
#include <linux/pm.h>
|
2024-09-12 17:07:19 -04:00
|
|
|
#include <linux/regmap.h>
|
|
|
|
|
|
|
|
#include "bmi270.h"
|
|
|
|
|
2024-10-01 23:36:22 -04:00
|
|
|
static const struct regmap_config bmi270_i2c_regmap_config = {
|
|
|
|
.reg_bits = 8,
|
|
|
|
.val_bits = 8,
|
|
|
|
};
|
|
|
|
|
2024-09-12 17:07:19 -04:00
|
|
|
static int bmi270_i2c_probe(struct i2c_client *client)
|
|
|
|
{
|
|
|
|
struct regmap *regmap;
|
|
|
|
struct device *dev = &client->dev;
|
2024-10-20 15:00:06 -07:00
|
|
|
const struct bmi270_chip_info *chip_info;
|
|
|
|
|
|
|
|
chip_info = i2c_get_match_data(client);
|
|
|
|
if (!chip_info)
|
|
|
|
return -ENODEV;
|
2024-09-12 17:07:19 -04:00
|
|
|
|
2024-10-01 23:36:22 -04:00
|
|
|
regmap = devm_regmap_init_i2c(client, &bmi270_i2c_regmap_config);
|
2024-09-12 17:07:19 -04:00
|
|
|
if (IS_ERR(regmap))
|
|
|
|
return dev_err_probe(dev, PTR_ERR(regmap),
|
|
|
|
"Failed to init i2c regmap");
|
|
|
|
|
2024-10-20 15:00:06 -07:00
|
|
|
return bmi270_core_probe(dev, regmap, chip_info);
|
2024-09-12 17:07:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct i2c_device_id bmi270_i2c_id[] = {
|
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>
2024-10-27 10:20:25 -07:00
|
|
|
{ "bmi260", (kernel_ulong_t)&bmi260_chip_info },
|
2024-10-20 15:00:06 -07:00
|
|
|
{ "bmi270", (kernel_ulong_t)&bmi270_chip_info },
|
2024-09-12 17:07:19 -04:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
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>
2024-10-27 10:20:25 -07:00
|
|
|
static const struct acpi_device_id bmi270_acpi_match[] = {
|
|
|
|
/* GPD Win Mini, Aya Neo AIR Pro, OXP Mini Pro, etc. */
|
|
|
|
{ "BMI0160", (kernel_ulong_t)&bmi260_chip_info },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2024-09-12 17:07:19 -04:00
|
|
|
static const struct of_device_id bmi270_of_match[] = {
|
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>
2024-10-27 10:20:25 -07:00
|
|
|
{ .compatible = "bosch,bmi260", .data = &bmi260_chip_info },
|
2024-10-20 15:00:06 -07:00
|
|
|
{ .compatible = "bosch,bmi270", .data = &bmi270_chip_info },
|
2024-09-12 17:07:19 -04:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct i2c_driver bmi270_i2c_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "bmi270_i2c",
|
2025-05-25 16:25:29 +02:00
|
|
|
.pm = pm_ptr(&bmi270_core_pm_ops),
|
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>
2024-10-27 10:20:25 -07:00
|
|
|
.acpi_match_table = bmi270_acpi_match,
|
2024-09-12 17:07:19 -04:00
|
|
|
.of_match_table = bmi270_of_match,
|
|
|
|
},
|
|
|
|
.probe = bmi270_i2c_probe,
|
|
|
|
.id_table = bmi270_i2c_id,
|
|
|
|
};
|
|
|
|
module_i2c_driver(bmi270_i2c_driver);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Alex Lanzano");
|
|
|
|
MODULE_DESCRIPTION("BMI270 driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
module: Convert symbol namespace to string literal
Clean up the existing export namespace code along the same lines of
commit 33def8498fdd ("treewide: Convert macro and uses of __section(foo)
to __section("foo")") and for the same reason, it is not desired for the
namespace argument to be a macro expansion itself.
Scripted using
git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
do
awk -i inplace '
/^#define EXPORT_SYMBOL_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/^#define MODULE_IMPORT_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/MODULE_IMPORT_NS/ {
$0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
}
/EXPORT_SYMBOL_NS/ {
if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
$0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
$0 !~ /^my/) {
getline line;
gsub(/[[:space:]]*\\$/, "");
gsub(/[[:space:]]/, "", line);
$0 = $0 " " line;
}
$0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
"\\1(\\2, \"\\3\")", "g");
}
}
{ print }' $file;
done
Requested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://mail.google.com/mail/u/2/#inbox/FMfcgzQXKWgMmjdFwwdsfgxzKpVHWPlc
Acked-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-12-02 15:59:47 +01:00
|
|
|
MODULE_IMPORT_NS("IIO_BMI270");
|