gpio: add protype for name_to_gpio
[platform/kernel/u-boot.git] / include / asm-generic / gpio.h
index e325df4..347805e 100644 (file)
@@ -26,8 +26,8 @@
  */
 
 /**
- * Request a gpio. This should be called before any of the other functions
- * are used on this gpio.
+ * Request a GPIO. This should be called before any of the other functions
+ * are used on this GPIO.
  *
  * @param gp   GPIO number
  * @param label        User label for this GPIO
@@ -79,14 +79,18 @@ int gpio_get_value(unsigned gpio);
  */
 int gpio_set_value(unsigned gpio, int value);
 
-/* State of a GPIO, as reported by get_state() */
+/* State of a GPIO, as reported by get_function() */
 enum {
        GPIOF_INPUT = 0,
        GPIOF_OUTPUT,
-       GPIOF_UNKNOWN,
+       GPIOF_UNUSED,           /* Not claimed */
+       GPIOF_UNKNOWN,          /* Not known */
+       GPIOF_FUNC,             /* Not used as a GPIO */
+
+       GPIOF_COUNT,
 };
 
-struct device;
+struct udevice;
 
 /**
  * struct struct dm_gpio_ops - Driver model GPIO operations
@@ -98,7 +102,7 @@ struct device;
  * new DM GPIO API, this should be really easy to flip over to the Linux
  * GPIO API-alike interface.
  *
- * Akso it would be useful to standardise additional functions like
+ * Also it would be useful to standardise additional functions like
  * pullup, slew rate and drive strength.
  *
  * gpio_request)( and gpio_free() are optional - if NULL then they will
@@ -111,20 +115,27 @@ struct device;
  * SoCs there may be many banks and therefore many devices all referring
  * to the different IO addresses within the SoC.
  *
- * The uclass combines all GPIO devices togther to provide a consistent
+ * The uclass combines all GPIO devices together to provide a consistent
  * numbering from 0 to n-1, where n is the number of GPIOs in total across
  * all devices. Be careful not to confuse offset with gpio in the parameters.
  */
 struct dm_gpio_ops {
-       int (*request)(struct device *dev, unsigned offset, const char *label);
-       int (*free)(struct device *dev, unsigned offset);
-       int (*direction_input)(struct device *dev, unsigned offset);
-       int (*direction_output)(struct device *dev, unsigned offset,
+       int (*request)(struct udevice *dev, unsigned offset, const char *label);
+       int (*free)(struct udevice *dev, unsigned offset);
+       int (*direction_input)(struct udevice *dev, unsigned offset);
+       int (*direction_output)(struct udevice *dev, unsigned offset,
                                int value);
-       int (*get_value)(struct device *dev, unsigned offset);
-       int (*set_value)(struct device *dev, unsigned offset, int value);
-       int (*get_function)(struct device *dev, unsigned offset);
-       int (*get_state)(struct device *dev, unsigned offset, char *state,
+       int (*get_value)(struct udevice *dev, unsigned offset);
+       int (*set_value)(struct udevice *dev, unsigned offset, int value);
+       /**
+        * get_function() Get the GPIO function
+        *
+        * @dev:     Device to check
+        * @offset:  GPIO offset within that device
+        * @return current function - GPIOF_...
+        */
+       int (*get_function)(struct udevice *dev, unsigned offset);
+       int (*get_state)(struct udevice *dev, unsigned offset, char *state,
                         int maxlen);
 };
 
@@ -132,7 +143,7 @@ struct dm_gpio_ops {
  * struct gpio_dev_priv - information about a device used by the uclass
  *
  * The uclass combines all active GPIO devices into a unified numbering
- * scheme. To do this it maintains some private information aobut each
+ * scheme. To do this it maintains some private information about each
  * device.
  *
  * To implement driver model support in your GPIO driver, add a probe
@@ -166,7 +177,7 @@ struct gpio_dev_priv {
  * @offset_count: Returns number of GPIOs within this bank
  * @return bank name of this device
  */
-const char *gpio_get_bank_info(struct device *dev, int *offset_count);
+const char *gpio_get_bank_info(struct udevice *dev, int *offset_count);
 
 /**
  * gpio_lookup_name - Look up a GPIO name and return its details
@@ -179,7 +190,9 @@ const char *gpio_get_bank_info(struct device *dev, int *offset_count);
  * @offsetp: Returns the offset number within this device
  * @gpiop: Returns the absolute GPIO number, numbered from 0
  */
-int gpio_lookup_name(const char *name, struct device **devp,
+int gpio_lookup_name(const char *name, struct udevice **devp,
                     unsigned int *offsetp, unsigned int *gpiop);
 
+int name_to_gpio(const char *name);
+
 #endif /* _ASM_GENERIC_GPIO_H_ */