| 1 |
// SPDX-License-Identifier: GPL-2.0-or-later |
| 2 |
/* Copyright (C) 2025 InvenSense, Inc. */ |
| 3 |
|
| 4 |
#include <linux/device.h> |
| 5 |
#include <linux/err.h> |
| 6 |
#include <linux/i2c.h> |
| 7 |
#include <linux/module.h> |
| 8 |
#include <linux/mod_devicetable.h> |
| 9 |
#include <linux/regmap.h> |
| 10 |
|
| 11 |
#include "inv_icm45600.h" |
| 12 |
|
| 13 |
static const struct regmap_config inv_icm45600_regmap_config = { |
| 14 |
.reg_bits = 8, |
| 15 |
.val_bits = 8, |
| 16 |
}; |
| 17 |
|
| 18 |
static int inv_icm45600_probe(struct i2c_client *client) |
| 19 |
{ |
| 20 |
const struct inv_icm45600_chip_info *chip_info; |
| 21 |
struct regmap *regmap; |
| 22 |
|
| 23 |
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) |
| 24 |
return -ENODEV; |
| 25 |
|
| 26 |
chip_info = device_get_match_data(&client->dev); |
| 27 |
if (!chip_info) |
| 28 |
return -ENODEV; |
| 29 |
|
| 30 |
regmap = devm_regmap_init_i2c(client, &inv_icm45600_regmap_config); |
| 31 |
if (IS_ERR(regmap)) |
| 32 |
return PTR_ERR(regmap); |
| 33 |
|
| 34 |
return inv_icm45600_core_probe(regmap, chip_info, true, NULL); |
| 35 |
} |
| 36 |
|
| 37 |
/* |
| 38 |
* The device id table is used to identify which device is |
| 39 |
* supported by this driver. |
| 40 |
*/ |
| 41 |
static const struct i2c_device_id inv_icm45600_id[] = { |
| 42 |
{ "icm45605", (kernel_ulong_t)&inv_icm45605_chip_info }, |
| 43 |
{ "icm45606", (kernel_ulong_t)&inv_icm45606_chip_info }, |
| 44 |
{ "icm45608", (kernel_ulong_t)&inv_icm45608_chip_info }, |
| 45 |
{ "icm45634", (kernel_ulong_t)&inv_icm45634_chip_info }, |
| 46 |
{ "icm45686", (kernel_ulong_t)&inv_icm45686_chip_info }, |
| 47 |
{ "icm45687", (kernel_ulong_t)&inv_icm45687_chip_info }, |
| 48 |
{ "icm45688p", (kernel_ulong_t)&inv_icm45688p_chip_info }, |
| 49 |
{ "icm45689", (kernel_ulong_t)&inv_icm45689_chip_info }, |
| 50 |
{ } |
| 51 |
}; |
| 52 |
MODULE_DEVICE_TABLE(i2c, inv_icm45600_id); |
| 53 |
|
| 54 |
static const struct of_device_id inv_icm45600_of_matches[] = { |
| 55 |
{ |
| 56 |
.compatible = "invensense,icm45605", |
| 57 |
.data = &inv_icm45605_chip_info, |
| 58 |
}, { |
| 59 |
.compatible = "invensense,icm45606", |
| 60 |
.data = &inv_icm45606_chip_info, |
| 61 |
}, { |
| 62 |
.compatible = "invensense,icm45608", |
| 63 |
.data = &inv_icm45608_chip_info, |
| 64 |
}, { |
| 65 |
.compatible = "invensense,icm45634", |
| 66 |
.data = &inv_icm45634_chip_info, |
| 67 |
}, { |
| 68 |
.compatible = "invensense,icm45686", |
| 69 |
.data = &inv_icm45686_chip_info, |
| 70 |
}, { |
| 71 |
.compatible = "invensense,icm45687", |
| 72 |
.data = &inv_icm45687_chip_info, |
| 73 |
}, { |
| 74 |
.compatible = "invensense,icm45688p", |
| 75 |
.data = &inv_icm45688p_chip_info, |
| 76 |
}, { |
| 77 |
.compatible = "invensense,icm45689", |
| 78 |
.data = &inv_icm45689_chip_info, |
| 79 |
}, |
| 80 |
{ } |
| 81 |
}; |
| 82 |
MODULE_DEVICE_TABLE(of, inv_icm45600_of_matches); |
| 83 |
|
| 84 |
static struct i2c_driver inv_icm45600_driver = { |
| 85 |
.driver = { |
| 86 |
.name = "inv-icm45600-i2c", |
| 87 |
.of_match_table = inv_icm45600_of_matches, |
| 88 |
.pm = pm_ptr(&inv_icm45600_pm_ops), |
| 89 |
}, |
| 90 |
.id_table = inv_icm45600_id, |
| 91 |
.probe = inv_icm45600_probe, |
| 92 |
}; |
| 93 |
module_i2c_driver(inv_icm45600_driver); |
| 94 |
|
| 95 |
MODULE_AUTHOR("InvenSense, Inc."); |
| 96 |
MODULE_DESCRIPTION("InvenSense ICM-456xx I2C driver"); |
| 97 |
MODULE_LICENSE("GPL"); |
| 98 |
MODULE_IMPORT_NS("IIO_ICM45600"); |