]> git.sur5r.net Git - u-boot/blobdiff - drivers/pinctrl/pinctrl-uclass.c
imx6: icorem6_rqs: Update SPL board boot order for eMMC
[u-boot] / drivers / pinctrl / pinctrl-uclass.c
index 58001ef5723c3cc77e56ed54080f0bf08d51cb0c..49afe91c24eff576e81adcb87e02e1ed78023235 100644 (file)
 #include <dm/device.h>
 #include <dm/lists.h>
 #include <dm/pinctrl.h>
-#include <dm/root.h>
 #include <dm/uclass.h>
 
 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
@@ -53,7 +64,7 @@ static int pinctrl_config_one(struct udevice *config)
 static int pinctrl_select_state_full(struct udevice *dev, const char *statename)
 {
        const void *fdt = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        char propname[32]; /* long enough */
        const fdt32_t *list;
        uint32_t phandle;
@@ -61,7 +72,7 @@ static int pinctrl_select_state_full(struct udevice *dev, const char *statename)
        struct udevice *config;
        int state, size, i, ret;
 
-       state = fdt_find_string(fdt, node, "pinctrl-names", statename);
+       state = fdt_stringlist_search(fdt, node, "pinctrl-names", statename);
        if (state < 0) {
                char *end;
                /*
@@ -102,7 +113,7 @@ static int pinctrl_select_state_full(struct udevice *dev, const char *statename)
 }
 
 /**
- * pinconfig_post-bind() - post binding for PINCONFIG uclass
+ * pinconfig_post_bind() - post binding for PINCONFIG uclass
  * Recursively bind its children as pinconfig devices.
  *
  * @dev: pinconfig device
@@ -111,13 +122,17 @@ static int pinctrl_select_state_full(struct udevice *dev, const char *statename)
 static int pinconfig_post_bind(struct udevice *dev)
 {
        const void *fdt = gd->fdt_blob;
-       int offset = dev->of_offset;
+       int offset = dev_of_offset(dev);
+       bool pre_reloc_only = !(gd->flags & GD_FLG_RELOC);
        const char *name;
        int ret;
 
        for (offset = fdt_first_subnode(fdt, offset);
             offset > 0;
             offset = fdt_next_subnode(fdt, offset)) {
+               if (pre_reloc_only &&
+                   !fdt_getprop(fdt, offset, "u-boot,dm-pre-reloc", NULL))
+                       continue;
                /*
                 * If this node has "compatible" property, this is not
                 * a pin configuration node, but a normal device. skip.
@@ -160,8 +175,7 @@ static int pinctrl_select_state_full(struct udevice *dev, const char *statename)
 
 static int pinconfig_post_bind(struct udevice *dev)
 {
-       /* Scan the bus for devices */
-       return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
+       return 0;
 }
 #endif
 
@@ -232,8 +246,18 @@ int pinctrl_get_periph_id(struct udevice *dev, struct udevice *periph)
        return ops->get_periph_id(dev, periph);
 }
 
+int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index)
+{
+       struct pinctrl_ops *ops = pinctrl_get_ops(dev);
+
+       if (!ops->get_gpio_mux)
+               return -ENOSYS;
+
+       return ops->get_gpio_mux(dev, banknum, index);
+}
+
 /**
- * pinconfig_post-bind() - post binding for PINCTRL uclass
+ * pinconfig_post_bind() - post binding for PINCTRL uclass
  * Recursively bind child nodes as pinconfig devices in case of full pinctrl.
  *
  * @dev: pinctrl device
@@ -249,14 +273,20 @@ static int pinctrl_post_bind(struct udevice *dev)
        }
 
        /*
-        * The pinctrl driver child nodes should be bound so that peripheral
-        * devices can easily search in parent devices during later DT-parsing.
+        * If set_state callback is set, we assume this pinctrl driver is the
+        * full implementation.  In this case, its child nodes should be bound
+        * so that peripheral devices can easily search in parent devices
+        * during later DT-parsing.
         */
-       return pinconfig_post_bind(dev);
+       if (ops->set_state)
+               return pinconfig_post_bind(dev);
+
+       return 0;
 }
 
 UCLASS_DRIVER(pinctrl) = {
        .id = UCLASS_PINCTRL,
        .post_bind = pinctrl_post_bind,
+       .flags = DM_UC_FLAG_SEQ_ALIAS,
        .name = "pinctrl",
 };