WIP FPC-III support
[linux/fpc-iii.git] / drivers / iio / imu / st_lsm6dsx / st_lsm6dsx_i3c.c
blob57e633121bdc0dbb039884dbdb53d6be5ad84b0e
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2018 Synopsys, Inc. and/or its affiliates.
5 * Author: Vitor Soares <vitor.soares@synopsys.com>
6 */
8 #include <linux/kernel.h>
9 #include <linux/module.h>
10 #include <linux/i3c/device.h>
11 #include <linux/i3c/master.h>
12 #include <linux/slab.h>
13 #include <linux/of.h>
14 #include <linux/regmap.h>
16 #include "st_lsm6dsx.h"
18 static const struct i3c_device_id st_lsm6dsx_i3c_ids[] = {
19 I3C_DEVICE(0x0104, 0x006C, (void *)ST_LSM6DSO_ID),
20 I3C_DEVICE(0x0104, 0x006B, (void *)ST_LSM6DSR_ID),
21 { /* sentinel */ },
23 MODULE_DEVICE_TABLE(i3c, st_lsm6dsx_i3c_ids);
25 static int st_lsm6dsx_i3c_probe(struct i3c_device *i3cdev)
27 struct regmap_config st_lsm6dsx_i3c_regmap_config = {
28 .reg_bits = 8,
29 .val_bits = 8,
31 const struct i3c_device_id *id = i3c_device_match_id(i3cdev,
32 st_lsm6dsx_i3c_ids);
33 struct regmap *regmap;
35 regmap = devm_regmap_init_i3c(i3cdev, &st_lsm6dsx_i3c_regmap_config);
36 if (IS_ERR(regmap)) {
37 dev_err(&i3cdev->dev, "Failed to register i3c regmap %d\n",
38 (int)PTR_ERR(regmap));
39 return PTR_ERR(regmap);
42 return st_lsm6dsx_probe(&i3cdev->dev, 0, (uintptr_t)id->data, regmap);
45 static struct i3c_driver st_lsm6dsx_driver = {
46 .driver = {
47 .name = "st_lsm6dsx_i3c",
48 .pm = &st_lsm6dsx_pm_ops,
50 .probe = st_lsm6dsx_i3c_probe,
51 .id_table = st_lsm6dsx_i3c_ids,
53 module_i3c_driver(st_lsm6dsx_driver);
55 MODULE_AUTHOR("Vitor Soares <vitor.soares@synopsys.com>");
56 MODULE_DESCRIPTION("STMicroelectronics st_lsm6dsx i3c driver");
57 MODULE_LICENSE("GPL v2");