This source file includes following definitions.
- regmap_sdw_write
- regmap_sdw_read
- regmap_sdw_config_check
- __regmap_init_sdw
- __devm_regmap_init_sdw
1
2
3
4 #include <linux/device.h>
5 #include <linux/mod_devicetable.h>
6 #include <linux/module.h>
7 #include <linux/soundwire/sdw.h>
8 #include "internal.h"
9
10 static int regmap_sdw_write(void *context, unsigned int reg, unsigned int val)
11 {
12 struct device *dev = context;
13 struct sdw_slave *slave = dev_to_sdw_dev(dev);
14
15 return sdw_write(slave, reg, val);
16 }
17
18 static int regmap_sdw_read(void *context, unsigned int reg, unsigned int *val)
19 {
20 struct device *dev = context;
21 struct sdw_slave *slave = dev_to_sdw_dev(dev);
22 int read;
23
24 read = sdw_read(slave, reg);
25 if (read < 0)
26 return read;
27
28 *val = read;
29 return 0;
30 }
31
32 static struct regmap_bus regmap_sdw = {
33 .reg_read = regmap_sdw_read,
34 .reg_write = regmap_sdw_write,
35 .reg_format_endian_default = REGMAP_ENDIAN_LITTLE,
36 .val_format_endian_default = REGMAP_ENDIAN_LITTLE,
37 };
38
39 static int regmap_sdw_config_check(const struct regmap_config *config)
40 {
41
42 if (config->val_bits != 8)
43 return -ENOTSUPP;
44
45
46 if (config->reg_bits != 32)
47 return -ENOTSUPP;
48
49 if (config->pad_bits != 0)
50 return -ENOTSUPP;
51
52 return 0;
53 }
54
55 struct regmap *__regmap_init_sdw(struct sdw_slave *sdw,
56 const struct regmap_config *config,
57 struct lock_class_key *lock_key,
58 const char *lock_name)
59 {
60 int ret;
61
62 ret = regmap_sdw_config_check(config);
63 if (ret)
64 return ERR_PTR(ret);
65
66 return __regmap_init(&sdw->dev, ®map_sdw,
67 &sdw->dev, config, lock_key, lock_name);
68 }
69 EXPORT_SYMBOL_GPL(__regmap_init_sdw);
70
71 struct regmap *__devm_regmap_init_sdw(struct sdw_slave *sdw,
72 const struct regmap_config *config,
73 struct lock_class_key *lock_key,
74 const char *lock_name)
75 {
76 int ret;
77
78 ret = regmap_sdw_config_check(config);
79 if (ret)
80 return ERR_PTR(ret);
81
82 return __devm_regmap_init(&sdw->dev, ®map_sdw,
83 &sdw->dev, config, lock_key, lock_name);
84 }
85 EXPORT_SYMBOL_GPL(__devm_regmap_init_sdw);
86
87 MODULE_DESCRIPTION("Regmap SoundWire Module");
88 MODULE_LICENSE("GPL v2");