2019-02-02 13:55:56 -08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2016-04-15 18:06:56 +03:00
|
|
|
/*
|
|
|
|
* BMI160 - Bosch IMU, I2C bits
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016, Intel Corporation.
|
|
|
|
*
|
|
|
|
* 7-bit I2C slave address is:
|
|
|
|
* - 0x68 if SDO is pulled to GND
|
|
|
|
* - 0x69 if SDO is pulled to VDDIO
|
|
|
|
*/
|
|
|
|
#include <linux/i2c.h>
|
2022-04-14 16:18:04 +03:00
|
|
|
#include <linux/mod_devicetable.h>
|
2016-12-08 15:22:54 +01:00
|
|
|
#include <linux/module.h>
|
2025-05-25 16:25:30 +02:00
|
|
|
#include <linux/pm.h>
|
2016-04-15 18:06:56 +03:00
|
|
|
#include <linux/regmap.h>
|
|
|
|
|
|
|
|
#include "bmi160.h"
|
|
|
|
|
2022-11-18 23:37:21 +01:00
|
|
|
static int bmi160_i2c_probe(struct i2c_client *client)
|
2016-04-15 18:06:56 +03:00
|
|
|
{
|
2022-11-18 23:37:21 +01:00
|
|
|
const struct i2c_device_id *id = i2c_client_get_device_id(client);
|
2016-04-15 18:06:56 +03:00
|
|
|
struct regmap *regmap;
|
2022-04-14 16:18:04 +03:00
|
|
|
const char *name;
|
2016-04-15 18:06:56 +03:00
|
|
|
|
|
|
|
regmap = devm_regmap_init_i2c(client, &bmi160_regmap_config);
|
|
|
|
if (IS_ERR(regmap)) {
|
2020-03-22 22:53:09 +05:30
|
|
|
dev_err(&client->dev, "Failed to register i2c regmap: %pe\n",
|
|
|
|
regmap);
|
2016-04-15 18:06:56 +03:00
|
|
|
return PTR_ERR(regmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id)
|
|
|
|
name = id->name;
|
2022-04-14 16:18:04 +03:00
|
|
|
else
|
|
|
|
name = dev_name(&client->dev);
|
2016-04-15 18:06:56 +03:00
|
|
|
|
|
|
|
return bmi160_core_probe(&client->dev, regmap, name, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct i2c_device_id bmi160_i2c_id[] = {
|
2024-05-08 09:29:27 +02:00
|
|
|
{ "bmi120" },
|
|
|
|
{ "bmi160" },
|
2025-04-11 15:49:34 -05:00
|
|
|
{ }
|
2016-04-15 18:06:56 +03:00
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(i2c, bmi160_i2c_id);
|
|
|
|
|
|
|
|
static const struct acpi_device_id bmi160_acpi_match[] = {
|
Add 10EC5280 to bmi160_i2c ACPI IDs to allow binding on some devices
"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.
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 */
}
...
}
Signed-off-by: Jesus Gonzalez <jesusmgh@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240207195549.37994-2-jesusmgh@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-02-07 20:55:50 +01:00
|
|
|
/*
|
|
|
|
* 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},
|
2024-05-05 07:36:54 +02:00
|
|
|
{"BMI0120", 0},
|
2016-04-15 18:06:56 +03:00
|
|
|
{"BMI0160", 0},
|
2025-04-11 15:49:34 -05:00
|
|
|
{ }
|
2016-04-15 18:06:56 +03:00
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(acpi, bmi160_acpi_match);
|
|
|
|
|
2016-12-08 15:22:54 +01:00
|
|
|
static const struct of_device_id bmi160_of_match[] = {
|
2024-05-05 07:36:54 +02:00
|
|
|
{ .compatible = "bosch,bmi120" },
|
2016-12-08 15:22:54 +01:00
|
|
|
{ .compatible = "bosch,bmi160" },
|
2025-04-11 15:49:34 -05:00
|
|
|
{ }
|
2016-12-08 15:22:54 +01:00
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, bmi160_of_match);
|
|
|
|
|
2016-04-15 18:06:56 +03:00
|
|
|
static struct i2c_driver bmi160_i2c_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "bmi160_i2c",
|
2025-05-25 16:25:30 +02:00
|
|
|
.pm = pm_ptr(&bmi160_core_pm_ops),
|
2022-04-14 16:18:04 +03:00
|
|
|
.acpi_match_table = bmi160_acpi_match,
|
|
|
|
.of_match_table = bmi160_of_match,
|
2016-04-15 18:06:56 +03:00
|
|
|
},
|
2023-05-15 22:50:48 +02:00
|
|
|
.probe = bmi160_i2c_probe,
|
2016-04-15 18:06:56 +03:00
|
|
|
.id_table = bmi160_i2c_id,
|
|
|
|
};
|
|
|
|
module_i2c_driver(bmi160_i2c_driver);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com>");
|
|
|
|
MODULE_DESCRIPTION("BMI160 I2C driver");
|
|
|
|
MODULE_LICENSE("GPL v2");
|
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_BMI160");
|