common: miiphyutil: Add helper function for mdio bus name
[oweals/u-boot.git] / include / dm / pinctrl.h
index bc6fdb4a1f176c6c385424c1a027b628456e896a..0eb4b924d4d07d88948e22f30e42d454f9ae3792 100644 (file)
@@ -87,7 +87,49 @@ struct pinctrl_ops {
        int (*pinconf_group_set)(struct udevice *dev, unsigned group_selector,
                                 unsigned param, unsigned argument);
        int (*set_state)(struct udevice *dev, struct udevice *config);
+
+       /* for pinctrl-simple */
        int (*set_state_simple)(struct udevice *dev, struct udevice *periph);
+       /**
+        * request() - Request a particular pinctrl function
+        *
+        * This activates the selected function.
+        *
+        * @dev:        Device to adjust (UCLASS_PINCTRL)
+        * @func:       Function number (driver-specific)
+        * @return 0 if OK, -ve on error
+        */
+       int (*request)(struct udevice *dev, int func, int flags);
+
+       /**
+       * get_periph_id() - get the peripheral ID for a device
+       *
+       * This generally looks at the peripheral's device tree node to work
+       * out the peripheral ID. The return value is normally interpreted as
+       * enum periph_id. so long as this is defined by the platform (which it
+       * should be).
+       *
+       * @dev:         Pinctrl device to use for decoding
+       * @periph:      Device to check
+       * @return peripheral ID of @periph, or -ENOENT on error
+       */
+       int (*get_periph_id)(struct udevice *dev, struct udevice *periph);
+
+       /**
+        * get_gpio_mux() - get the mux value for a particular GPIO
+        *
+        * This allows the raw mux value for a GPIO to be obtained. It is
+        * useful for displaying the function being used by that GPIO, such
+        * as with the 'gpio' command. This function is internal to the GPIO
+        * subsystem and should not be used by generic code. Typically it is
+        * used by a GPIO driver with knowledge of the SoC pinctrl setup.
+        *
+       * @dev:         Pinctrl device to use
+       * @banknum:     GPIO bank number
+       * @index:       GPIO index within the bank
+       * @return mux value (SoC-specific, e.g. 0 for input, 1 for output)
+        */
+       int (*get_gpio_mux)(struct udevice *dev, int banknum, int index);
 };
 
 #define pinctrl_get_ops(dev)   ((struct pinctrl_ops *)(dev)->driver->ops)
@@ -224,4 +266,67 @@ static inline int pinctrl_select_state(struct udevice *dev,
 }
 #endif
 
+/**
+ * pinctrl_request() - Request a particular pinctrl function
+ *
+ * @dev:       Device to check (UCLASS_PINCTRL)
+ * @func:      Function number (driver-specific)
+ * @flags:     Flags (driver-specific)
+ * @return 0 if OK, -ve on error
+ */
+int pinctrl_request(struct udevice *dev, int func, int flags);
+
+/**
+ * pinctrl_request_noflags() - Request a particular pinctrl function
+ *
+ * This is similar to pinctrl_request() but uses 0 for @flags.
+ *
+ * @dev:       Device to check (UCLASS_PINCTRL)
+ * @func:      Function number (driver-specific)
+ * @return 0 if OK, -ve on error
+ */
+int pinctrl_request_noflags(struct udevice *dev, int func);
+
+/**
+ * pinctrl_get_periph_id() - get the peripheral ID for a device
+ *
+ * This generally looks at the peripheral's device tree node to work out the
+ * peripheral ID. The return value is normally interpreted as enum periph_id.
+ * so long as this is defined by the platform (which it should be).
+ *
+ * @dev:       Pinctrl device to use for decoding
+ * @periph:    Device to check
+ * @return peripheral ID of @periph, or -ENOENT on error
+ */
+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);
+
+/**
+ * pinctrl_get_gpio_mux() - get the mux value for a particular GPIO
+ *
+ * This allows the raw mux value for a GPIO to be obtained. It is
+ * useful for displaying the function being used by that GPIO, such
+ * as with the 'gpio' command. This function is internal to the GPIO
+ * subsystem and should not be used by generic code. Typically it is
+ * used by a GPIO driver with knowledge of the SoC pinctrl setup.
+ *
+ * @dev:       Pinctrl device to use
+ * @banknum:   GPIO bank number
+ * @index:     GPIO index within the bank
+ * @return mux value (SoC-specific, e.g. 0 for input, 1 for output)
+*/
+int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index);
+
 #endif /* __PINCTRL_H */