summaryrefslogtreecommitdiffstats
path: root/include/regmap.h
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-02-03 12:21:07 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2016-02-05 14:32:16 +0100
commit7a53e162de2a5a7c44e654f09264d5c3758768bf (patch)
treeef4429b3a4c30ac92ce7132a24d9614740befb70 /include/regmap.h
parent7ffff00dfdcd4ea28b9edf8420dac8ba53061491 (diff)
downloadbarebox-7a53e162de2a5a7c44e654f09264d5c3758768bf.tar.gz
barebox-7a53e162de2a5a7c44e654f09264d5c3758768bf.tar.xz
Add initial regmap support
This adds initial regmap support. Function prototypes are from the Kernel, the implemention is mostly rewritten. Currently the regmap support is limited to the bare minimum to get started. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/regmap.h')
-rw-r--r--include/regmap.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/include/regmap.h b/include/regmap.h
new file mode 100644
index 0000000000..4cb473cbfe
--- /dev/null
+++ b/include/regmap.h
@@ -0,0 +1,62 @@
+#ifndef __REGMAP_H
+#define __REGMAP_H
+
+/**
+ * Configuration for the register map of a device.
+ *
+ * @name: Optional name of the regmap. Useful when a device has multiple
+ * register regions.
+ *
+ * @reg_bits: Number of bits in a register address, mandatory.
+ * @reg_stride: The register address stride. Valid register addresses are a
+ * multiple of this value. If set to 0, a value of 1 will be
+ * used.
+ * @pad_bits: Number of bits of padding between register and value.
+ * @val_bits: Number of bits in a register value, mandatory.
+ *
+ * @max_register: Optional, specifies the maximum valid register index.
+ */
+struct regmap_config {
+ const char *name;
+
+ int reg_bits;
+ int reg_stride;
+ int pad_bits;
+ int val_bits;
+
+ unsigned int max_register;
+};
+
+typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg,
+ unsigned int *val);
+typedef int (*regmap_hw_reg_write)(void *context, unsigned int reg,
+ unsigned int val);
+
+struct regmap_bus {
+ regmap_hw_reg_write reg_write;
+ regmap_hw_reg_read reg_read;
+};
+
+struct regmap *regmap_init(struct device_d *dev,
+ const struct regmap_bus *bus,
+ void *bus_context,
+ const struct regmap_config *config);
+
+struct regmap *dev_get_regmap(struct device_d *dev, const char *name);
+struct regmap *of_node_to_regmap(struct device_node *node);
+
+int regmap_register_cdev(struct regmap *map, const char *name);
+
+int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
+int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
+
+int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
+ size_t val_len);
+int regmap_bulk_write(struct regmap *map, unsigned int reg,
+ const void *val, size_t val_len);
+
+int regmap_get_val_bytes(struct regmap *map);
+int regmap_get_max_register(struct regmap *map);
+int regmap_get_reg_stride(struct regmap *map);
+
+#endif /* __REGMAP_H */ \ No newline at end of file