File Index
Files and directories
Sign in
FILE

st_lsm6dsx_i3c.c

File preview with syntax highlighting.

linux-6.19.14/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c C
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * Copyright (c) 2018 Synopsys, Inc. and/or its affiliates.
 4 *
 5 * Author: Vitor Soares <vitor.soares@synopsys.com>
 6 */
 7
 8#include <linux/kernel.h>
 9#include <linux/mod_devicetable.h>
10#include <linux/module.h>
11#include <linux/i3c/device.h>
12#include <linux/slab.h>
13#include <linux/regmap.h>
14
15#include "st_lsm6dsx.h"
16
17static const struct i3c_device_id st_lsm6dsx_i3c_ids[] = {
18	I3C_DEVICE(0x0104, 0x006C, (void *)ST_LSM6DSO_ID),
19	I3C_DEVICE(0x0104, 0x006B, (void *)ST_LSM6DSR_ID),
20	{ }
21};
22MODULE_DEVICE_TABLE(i3c, st_lsm6dsx_i3c_ids);
23
24static int st_lsm6dsx_i3c_probe(struct i3c_device *i3cdev)
25{
26	struct regmap_config st_lsm6dsx_i3c_regmap_config = {
27		.reg_bits = 8,
28		.val_bits = 8,
29	};
30	const struct i3c_device_id *id = i3c_device_match_id(i3cdev,
31							    st_lsm6dsx_i3c_ids);
32	struct device *dev = i3cdev_to_dev(i3cdev);
33	struct regmap *regmap;
34
35	regmap = devm_regmap_init_i3c(i3cdev, &st_lsm6dsx_i3c_regmap_config);
36	if (IS_ERR(regmap)) {
37		dev_err(dev, "Failed to register i3c regmap %ld\n", PTR_ERR(regmap));
38		return PTR_ERR(regmap);
39	}
40
41	return st_lsm6dsx_probe(dev, 0, (uintptr_t)id->data, regmap);
42}
43
44static struct i3c_driver st_lsm6dsx_driver = {
45	.driver = {
46		.name = "st_lsm6dsx_i3c",
47		.pm = pm_sleep_ptr(&st_lsm6dsx_pm_ops),
48	},
49	.probe = st_lsm6dsx_i3c_probe,
50	.id_table = st_lsm6dsx_i3c_ids,
51};
52module_i3c_driver(st_lsm6dsx_driver);
53
54MODULE_AUTHOR("Vitor Soares <vitor.soares@synopsys.com>");
55MODULE_DESCRIPTION("STMicroelectronics st_lsm6dsx i3c driver");
56MODULE_LICENSE("GPL v2");
57MODULE_IMPORT_NS("IIO_LSM6DSX");
~/ Read-only file preview.