2020-06-22 17:37:18 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2020 InvenSense, Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/mod_devicetable.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/regmap.h>
|
|
|
|
#include <linux/property.h>
|
|
|
|
|
|
|
|
#include "inv_icm42600.h"
|
|
|
|
|
|
|
|
static int inv_icm42600_i2c_bus_setup(struct inv_icm42600_state *st)
|
|
|
|
{
|
|
|
|
unsigned int mask, val;
|
|
|
|
int ret;
|
|
|
|
|
2022-04-11 13:15:33 +02:00
|
|
|
/*
|
|
|
|
* setup interface registers
|
|
|
|
* This register write to REG_INTF_CONFIG6 enables a spike filter that
|
|
|
|
* is impacting the line and can prevent the I2C ACK to be seen by the
|
|
|
|
* controller. So we don't test the return value.
|
|
|
|
*/
|
|
|
|
regmap_update_bits(st->map, INV_ICM42600_REG_INTF_CONFIG6,
|
|
|
|
INV_ICM42600_INTF_CONFIG6_MASK,
|
|
|
|
INV_ICM42600_INTF_CONFIG6_I3C_EN);
|
2020-06-22 17:37:18 +02:00
|
|
|
|
2024-06-17 09:50:07 -04:00
|
|
|
ret = regmap_clear_bits(st->map, INV_ICM42600_REG_INTF_CONFIG4,
|
|
|
|
INV_ICM42600_INTF_CONFIG4_I3C_BUS_ONLY);
|
2020-06-22 17:37:18 +02:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* set slew rates for I2C and SPI */
|
|
|
|
mask = INV_ICM42600_DRIVE_CONFIG_I2C_MASK |
|
|
|
|
INV_ICM42600_DRIVE_CONFIG_SPI_MASK;
|
|
|
|
val = INV_ICM42600_DRIVE_CONFIG_I2C(INV_ICM42600_SLEW_RATE_12_36NS) |
|
|
|
|
INV_ICM42600_DRIVE_CONFIG_SPI(INV_ICM42600_SLEW_RATE_12_36NS);
|
|
|
|
ret = regmap_update_bits(st->map, INV_ICM42600_REG_DRIVE_CONFIG,
|
|
|
|
mask, val);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* disable SPI bus */
|
|
|
|
return regmap_update_bits(st->map, INV_ICM42600_REG_INTF_CONFIG0,
|
|
|
|
INV_ICM42600_INTF_CONFIG0_UI_SIFS_CFG_MASK,
|
|
|
|
INV_ICM42600_INTF_CONFIG0_UI_SIFS_CFG_SPI_DIS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int inv_icm42600_probe(struct i2c_client *client)
|
|
|
|
{
|
|
|
|
const void *match;
|
|
|
|
enum inv_icm42600_chip chip;
|
|
|
|
struct regmap *regmap;
|
|
|
|
|
|
|
|
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
|
|
|
|
return -ENOTSUPP;
|
|
|
|
|
|
|
|
match = device_get_match_data(&client->dev);
|
|
|
|
if (!match)
|
|
|
|
return -EINVAL;
|
2021-11-28 17:24:40 +00:00
|
|
|
chip = (uintptr_t)match;
|
2020-06-22 17:37:18 +02:00
|
|
|
|
|
|
|
regmap = devm_regmap_init_i2c(client, &inv_icm42600_regmap_config);
|
|
|
|
if (IS_ERR(regmap))
|
|
|
|
return PTR_ERR(regmap);
|
|
|
|
|
2025-04-10 17:39:41 +02:00
|
|
|
return inv_icm42600_core_probe(regmap, chip, inv_icm42600_i2c_bus_setup);
|
2020-06-22 17:37:18 +02:00
|
|
|
}
|
|
|
|
|
2024-09-02 19:31:01 +08:00
|
|
|
/*
|
|
|
|
* device id table is used to identify what device can be
|
|
|
|
* supported by this driver
|
|
|
|
*/
|
|
|
|
static const struct i2c_device_id inv_icm42600_id[] = {
|
|
|
|
{ "icm42600", INV_CHIP_ICM42600 },
|
|
|
|
{ "icm42602", INV_CHIP_ICM42602 },
|
|
|
|
{ "icm42605", INV_CHIP_ICM42605 },
|
|
|
|
{ "icm42686", INV_CHIP_ICM42686 },
|
|
|
|
{ "icm42622", INV_CHIP_ICM42622 },
|
|
|
|
{ "icm42688", INV_CHIP_ICM42688 },
|
|
|
|
{ "icm42631", INV_CHIP_ICM42631 },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(i2c, inv_icm42600_id);
|
|
|
|
|
2020-06-22 17:37:18 +02:00
|
|
|
static const struct of_device_id inv_icm42600_of_matches[] = {
|
|
|
|
{
|
|
|
|
.compatible = "invensense,icm42600",
|
|
|
|
.data = (void *)INV_CHIP_ICM42600,
|
|
|
|
}, {
|
|
|
|
.compatible = "invensense,icm42602",
|
|
|
|
.data = (void *)INV_CHIP_ICM42602,
|
|
|
|
}, {
|
|
|
|
.compatible = "invensense,icm42605",
|
|
|
|
.data = (void *)INV_CHIP_ICM42605,
|
2024-04-22 15:22:40 +00:00
|
|
|
}, {
|
|
|
|
.compatible = "invensense,icm42686",
|
|
|
|
.data = (void *)INV_CHIP_ICM42686,
|
2020-06-22 17:37:18 +02:00
|
|
|
}, {
|
|
|
|
.compatible = "invensense,icm42622",
|
|
|
|
.data = (void *)INV_CHIP_ICM42622,
|
2024-04-08 09:07:20 +00:00
|
|
|
}, {
|
|
|
|
.compatible = "invensense,icm42688",
|
|
|
|
.data = (void *)INV_CHIP_ICM42688,
|
2022-11-10 19:29:32 +00:00
|
|
|
}, {
|
|
|
|
.compatible = "invensense,icm42631",
|
|
|
|
.data = (void *)INV_CHIP_ICM42631,
|
2020-06-22 17:37:18 +02:00
|
|
|
},
|
2025-04-11 15:49:34 -05:00
|
|
|
{ }
|
2020-06-22 17:37:18 +02:00
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, inv_icm42600_of_matches);
|
|
|
|
|
|
|
|
static struct i2c_driver inv_icm42600_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "inv-icm42600-i2c",
|
|
|
|
.of_match_table = inv_icm42600_of_matches,
|
2022-09-25 16:57:18 +01:00
|
|
|
.pm = pm_ptr(&inv_icm42600_pm_ops),
|
2020-06-22 17:37:18 +02:00
|
|
|
},
|
2024-09-02 19:31:01 +08:00
|
|
|
.id_table = inv_icm42600_id,
|
2023-05-15 22:50:48 +02:00
|
|
|
.probe = inv_icm42600_probe,
|
2020-06-22 17:37:18 +02:00
|
|
|
};
|
|
|
|
module_i2c_driver(inv_icm42600_driver);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("InvenSense, Inc.");
|
|
|
|
MODULE_DESCRIPTION("InvenSense ICM-426xx I2C 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_ICM42600");
|