net: ks8851: Remove type_frame_head
[oweals/u-boot.git] / include / dm / pinctrl.h
index c6c8f6158d38d12bdcbb6154881306b6fe6ba09f..692e5fc8cbfa11a13fe69d9e72ea6eab00a16e1e 100644 (file)
@@ -1,12 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (C) 2015  Masahiro Yamada <yamada.masahiro@socionext.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #ifndef __PINCTRL_H
 #define __PINCTRL_H
 
+#define PINNAME_SIZE   10
+#define PINMUX_SIZE    40
+
 /**
  * struct pinconf_param - pin config parameters
  *
@@ -67,6 +69,14 @@ struct pinconf_param {
  *     pointing a config node. (necessary for pinctrl_full)
  * @set_state_simple: do needed pinctrl operations for a peripherl @periph.
  *     (necessary for pinctrl_simple)
+ * @get_pin_muxing: display the muxing of a given pin.
+ * @gpio_request_enable: requests and enables GPIO on a certain pin.
+ *     Implement this only if you can mux every pin individually as GPIO. The
+ *     affected GPIO range is passed along with an offset(pin number) into that
+ *     specific GPIO range - function selectors and pin groups are orthogonal
+ *     to this, the core will however make sure the pins do not collide.
+ * @gpio_disable_free: free up GPIO muxing on a certain pin, the reverse of
+ *     @gpio_request_enable
  */
 struct pinctrl_ops {
        int (*get_pins_count)(struct udevice *dev);
@@ -130,6 +140,42 @@ struct pinctrl_ops {
        * @return mux value (SoC-specific, e.g. 0 for input, 1 for output)
         */
        int (*get_gpio_mux)(struct udevice *dev, int banknum, int index);
+
+       /**
+        * get_pin_muxing() - show pin muxing
+        *
+        * This allows to display the muxing of a given pin. It's useful for
+        * debug purpose to know if a pin is configured as GPIO or as an
+        * alternate function and which one.
+        * Typically it is used by a PINCTRL driver with knowledge of the SoC
+        * pinctrl setup.
+        *
+        * @dev:        Pinctrl device to use
+        * @selector:   Pin selector
+        * @buf         Pin's muxing description
+        * @size        Pin's muxing description length
+        * return 0 if OK, -ve on error
+        */
+        int (*get_pin_muxing)(struct udevice *dev, unsigned int selector,
+                              char *buf, int size);
+
+       /**
+        * gpio_request_enable: requests and enables GPIO on a certain pin.
+        *
+        * @dev:        Pinctrl device to use
+        * @selector:   Pin selector
+        * return 0 if OK, -ve on error
+        */
+       int (*gpio_request_enable)(struct udevice *dev, unsigned int selector);
+
+       /**
+        * gpio_disable_free: free up GPIO muxing on a certain pin.
+        *
+        * @dev:        Pinctrl device to use
+        * @selector:   Pin selector
+        * return 0 if OK, -ve on error
+        */
+       int (*gpio_disable_free)(struct udevice *dev, unsigned int selector);
 };
 
 #define pinctrl_get_ops(dev)   ((struct pinctrl_ops *)(dev)->driver->ops)
@@ -179,6 +225,8 @@ struct pinctrl_ops {
  *     push-pull mode, the argument is ignored.
  * @PIN_CONFIG_DRIVE_STRENGTH: the pin will sink or source at most the current
  *     passed as argument. The argument is in mA.
+ * @PIN_CONFIG_DRIVE_STRENGTH_UA: the pin will sink or source at most the current
+ *     passed as argument. The argument is in uA.
  * @PIN_CONFIG_INPUT_DEBOUNCE: this will configure the pin to debounce mode,
  *     which means it will wait for signals to settle when reading inputs. The
  *     argument gives the debounce time in usecs. Setting the
@@ -235,6 +283,7 @@ enum pin_config_param {
        PIN_CONFIG_DRIVE_OPEN_SOURCE,
        PIN_CONFIG_DRIVE_PUSH_PULL,
        PIN_CONFIG_DRIVE_STRENGTH,
+       PIN_CONFIG_DRIVE_STRENGTH_UA,
        PIN_CONFIG_INPUT_DEBOUNCE,
        PIN_CONFIG_INPUT_ENABLE,
        PIN_CONFIG_INPUT_SCHMITT,
@@ -320,19 +369,6 @@ 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);
-
 /**
  * pinctrl_get_gpio_mux() - get the mux value for a particular GPIO
  *
@@ -349,4 +385,60 @@ int pinctrl_decode_pin_config(const void *blob, int node);
 */
 int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index);
 
+/**
+ * pinctrl_get_pin_muxing() - Returns the muxing description
+ *
+ * This allows to display the muxing description of the given pin for
+ * debug purpose
+ *
+ * @dev:       Pinctrl device to use
+ * @selector   Pin index within pin-controller
+ * @buf                Pin's muxing description
+ * @size       Pin's muxing description length
+ * @return 0 if OK, -ve on error
+ */
+int pinctrl_get_pin_muxing(struct udevice *dev, int selector, char *buf,
+                          int size);
+
+/**
+ * pinctrl_get_pins_count() - display pin-controller pins number
+ *
+ * This allows to know the number of pins owned by a given pin-controller
+ *
+ * @dev:       Pinctrl device to use
+ * @return pins number if OK, -ve on error
+ */
+int pinctrl_get_pins_count(struct udevice *dev);
+
+/**
+ * pinctrl_get_pin_name() - Returns the pin's name
+ *
+ * This allows to display the pin's name for debug purpose
+ *
+ * @dev:       Pinctrl device to use
+ * @selector   Pin index within pin-controller
+ * @buf                Pin's name
+ * @return 0 if OK, -ve on error
+ */
+int pinctrl_get_pin_name(struct udevice *dev, int selector, char *buf,
+                        int size);
+
+/**
+ * pinctrl_gpio_request() - request a single pin to be used as GPIO
+ *
+ * @dev: GPIO peripheral device
+ * @offset: the GPIO pin offset from the GPIO controller
+ * @return: 0 on success, or negative error code on failure
+ */
+int pinctrl_gpio_request(struct udevice *dev, unsigned offset);
+
+/**
+ * pinctrl_gpio_free() - free a single pin used as GPIO
+ *
+ * @dev: GPIO peripheral device
+ * @offset: the GPIO pin offset from the GPIO controller
+ * @return: 0 on success, or negative error code on failure
+ */
+int pinctrl_gpio_free(struct udevice *dev, unsigned offset);
+
 #endif /* __PINCTRL_H */