]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
dm: pinctrl: Add a function to parse PIN_CONFIG flags
authorSimon Glass <sjg@chromium.org>
Fri, 22 Jan 2016 02:43:26 +0000 (19:43 -0700)
committerSimon Glass <sjg@chromium.org>
Fri, 22 Jan 2016 03:42:34 +0000 (20:42 -0700)
Add a function which produces a flags word from a few common PIN_CONFIG
settings. This is useful for simple pinctrl drivers that don't need to worry
about drive strength, etc.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/pinctrl/pinctrl-uclass.c
include/dm/pinctrl.h

index c42b312ddd090a0d4b9400fd6cbeb1be0ace6aec..1acbfafa818a7b752a9b8ce71d2750fcbd5539e4 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
+int pinctrl_decode_pin_config(const void *blob, int node)
+{
+       int flags = 0;
+
+       if (fdtdec_get_bool(blob, node, "bias-pull-up"))
+               flags |= 1 << PIN_CONFIG_BIAS_PULL_UP;
+       else if (fdtdec_get_bool(blob, node, "bias-pull-down"))
+               flags |= 1 << PIN_CONFIG_BIAS_PULL_DOWN;
+
+       return flags;
+}
+
 #if CONFIG_IS_ENABLED(PINCTRL_FULL)
 /**
  * pinctrl_config_one() - apply pinctrl settings for a single node
index f6025f618e4b9682648c47437aa0842fa5946b3a..5cd45038ebf3c3eb8a90faef1b56ad4dbb63c6ba 100644 (file)
@@ -284,4 +284,17 @@ int pinctrl_request_noflags(struct udevice *dev, int func);
  */
 int pinctrl_get_periph_id(struct udevice *dev, struct udevice *periph);
 
+/**
+ * pinctrl_decode_pin_config() - decode pin configuration flags
+ *
+ * This decodes some of the PIN_CONFIG values into flags, with each value
+ * being (1 << pin_cfg). This does not support things with values like the
+ * slew rate.
+ *
+ * @blob:      Device tree blob
+ * @node:      Node containing the PIN_CONFIG values
+ * @return decoded flag value, or -ve on error
+ */
+int pinctrl_decode_pin_config(const void *blob, int node);
+
 #endif /* __PINCTRL_H */