summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpio-i8255.h
diff options
context:
space:
mode:
authorWilliam Breathitt Gray <william.gray@linaro.org>2022-12-27 17:09:43 +0300
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>2023-01-30 17:55:28 +0300
commit0b7c490d7de3255ad1db82000b42f3f021f6dbf0 (patch)
treedc56d7f84a121be95d2a249c1cd8ae4b9f96bf1d /drivers/gpio/gpio-i8255.h
parent59e2131accfd1f4964c766fabdcd19419f1c551b (diff)
downloadlinux-0b7c490d7de3255ad1db82000b42f3f021f6dbf0.tar.xz
gpio: i8255: Migrate to gpio-regmap API
The regmap API supports IO port accessors so we can take advantage of regmap abstractions rather than handling access to the device registers directly in the driver. By leveraging the gpio-regmap API, the i8255 library is reduced to simply a devm_i8255_regmap_register() function, a configuration structure struct i8255_regmap_config, and a helper macro i8255_volatile_regmap_range() provided to simplify volatile PPI register hinting for the regmap. Legacy functions and code will be removed once all consumers have migrated to the new i8255 library interface. Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: William Breathitt Gray <william.gray@linaro.org> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-i8255.h')
-rw-r--r--drivers/gpio/gpio-i8255.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-i8255.h b/drivers/gpio/gpio-i8255.h
index d9084aae9446..3daa0b145890 100644
--- a/drivers/gpio/gpio-i8255.h
+++ b/drivers/gpio/gpio-i8255.h
@@ -26,6 +26,34 @@ struct i8255_state {
u8 control_state;
};
+struct device;
+struct irq_domain;
+struct regmap;
+
+#define i8255_volatile_regmap_range(_base) regmap_reg_range(_base, _base + 0x2)
+
+/**
+ * struct i8255_regmap_config - Configuration for the register map of an i8255
+ * @parent: parent device
+ * @map: regmap for the i8255
+ * @num_ppi: number of i8255 Programmable Peripheral Interface
+ * @names: (optional) array of names for gpios
+ * @domain: (optional) IRQ domain if the controller is interrupt-capable
+ *
+ * Note: The regmap is expected to have cache enabled and i8255 control
+ * registers not marked as volatile.
+ */
+struct i8255_regmap_config {
+ struct device *parent;
+ struct regmap *map;
+ int num_ppi;
+ const char *const *names;
+ struct irq_domain *domain;
+};
+
+int devm_i8255_regmap_register(struct device *dev,
+ const struct i8255_regmap_config *config);
+
void i8255_direction_input(struct i8255 __iomem *ppi, struct i8255_state *state,
unsigned long offset);
void i8255_direction_output(struct i8255 __iomem *ppi,