summaryrefslogtreecommitdiff
path: root/include/regmap.h
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2023-01-11 14:29:51 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2023-01-12 15:57:51 +0100
commit6e7b4e09c6ab0dc691c58855a153965d46b41f06 (patch)
treeadbcdcb258b16b33b7d9ca4b6ea8f9e373324988 /include/regmap.h
parentcbf1e375816d2e819c01be09f8c7cbc133131d85 (diff)
downloadbarebox-6e7b4e09c6ab0dc691c58855a153965d46b41f06.tar.gz
net: dsa: ksz9477: create regmap cdev for switch registers
Now that we use regmap for the KSZ9477 driver, we can make the register map available for introspection as a device file. As the KSZ driver has a separate regmap for each of the three access sizes, we add a new regmap_multi_register_cdev abstraction that multiplexes device file access to the regmap with the best matching alignment. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111132956.1153359-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/regmap.h')
-rw-r--r--include/regmap.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/regmap.h b/include/regmap.h
index 986ed391ab..98ac90523b 100644
--- a/include/regmap.h
+++ b/include/regmap.h
@@ -175,6 +175,27 @@ struct device *regmap_get_device(struct regmap *map);
int regmap_register_cdev(struct regmap *map, const char *name);
+/**
+ * regmap_multi_register_cdev() - Initialize cdev backed by multiple regmaps
+ *
+ * @map8: regmap for 8-bit wide accesses. NULL if such access
+ * should fail with -EINVAL
+ * @map16: regmap for 16-bit wide accesses. NULL if such access
+ * should fail with -EINVAL
+ * @map32: regmap for 32-bit wide accesses. NULL if such access
+ * should fail with -EINVAL
+ * @map64: regmap for 64-bit wide accesses. NULL if such access
+ * should fail with -EINVAL
+ *
+ * Registers a cdev that demultiplexes cdev accesses to one
+ * of the underlying regmaps according to the access size
+ * (e.g. mw -b => map8, mw -l => map32)
+ */
+int regmap_multi_register_cdev(struct regmap *map8,
+ struct regmap *map16,
+ struct regmap *map32,
+ struct regmap *map64);
+
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);