Merge tag 'trace-v5.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[linux/fpc-iii.git] / drivers / base / regmap / regmap-i3c.c
blob1578fb50668399c82b4bb8de6d3f43dbfe52d1cf
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2018 Synopsys, Inc. and/or its affiliates.
4 #include <linux/regmap.h>
5 #include <linux/i3c/device.h>
6 #include <linux/i3c/master.h>
7 #include <linux/module.h>
9 static int regmap_i3c_write(void *context, const void *data, size_t count)
11 struct device *dev = context;
12 struct i3c_device *i3c = dev_to_i3cdev(dev);
13 struct i3c_priv_xfer xfers[] = {
15 .rnw = false,
16 .len = count,
17 .data.out = data,
21 return i3c_device_do_priv_xfers(i3c, xfers, 1);
24 static int regmap_i3c_read(void *context,
25 const void *reg, size_t reg_size,
26 void *val, size_t val_size)
28 struct device *dev = context;
29 struct i3c_device *i3c = dev_to_i3cdev(dev);
30 struct i3c_priv_xfer xfers[2];
32 xfers[0].rnw = false;
33 xfers[0].len = reg_size;
34 xfers[0].data.out = reg;
36 xfers[1].rnw = true;
37 xfers[1].len = val_size;
38 xfers[1].data.in = val;
40 return i3c_device_do_priv_xfers(i3c, xfers, 2);
43 static struct regmap_bus regmap_i3c = {
44 .write = regmap_i3c_write,
45 .read = regmap_i3c_read,
48 struct regmap *__devm_regmap_init_i3c(struct i3c_device *i3c,
49 const struct regmap_config *config,
50 struct lock_class_key *lock_key,
51 const char *lock_name)
53 return __devm_regmap_init(&i3c->dev, &regmap_i3c, &i3c->dev, config,
54 lock_key, lock_name);
56 EXPORT_SYMBOL_GPL(__devm_regmap_init_i3c);
58 MODULE_AUTHOR("Vitor Soares <vitor.soares@synopsys.com>");
59 MODULE_DESCRIPTION("Regmap I3C Module");
60 MODULE_LICENSE("GPL v2");