Message ID | 20200815155237.467720-3-seanga2@gmail.com |
---|---|
State | Superseded |
Delegated to: | Jagannadha Sutradharudu Teki |
Headers | show |
Series | riscv: Add FPIOA and GPIO support for Kendryte K210 | expand |
On 15.08.20 17:52, Sean Anderson wrote: > This normalizes the documentatation to conform to kernel-doc style [1]. It Nits: %s/documentatation/documentation/ > also moves the documentation for pinctrl_ops inline, and adds argument and > return-value documentation. I have kept the usual function style for these > comments. I could not find any existing examples of function documentation > inside structs. > > [1] https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html > > Signed-off-by: Sean Anderson <seanga2@gmail.com> > Reviewed-by: Simon Glass <sjg@chromium.org> Before and after this patch the documentation format is incorrect. See output below for the situation after the patch. Please include include/dm/pinctrl.h into doc/api/index.rst via a new file doc/api/pnctrl.rst. A documentation style accepted by 'make htmldocs' is: struct pinctrl_ops { /** * @get_pins_count: Get the number of selectable pins * * @get_pins_count.dev: Pinctrl device to use * * This function is necessary to parse the "pins" property * in DTS. * * @get_pins_count.Return: number of selectable named pins * available in this driver */ int (*get_pins_count)(struct udevice *dev); See the nested structures in https://www.kernel.org/doc/html/v5.7/doc-guide/kernel-doc.html#in-line-member-documentation-comments and https://www.kernel.org/doc/html/v5.7/doc-guide/kernel-doc.html#nested-structs-unions The generated doc looks like this: Members get_pins_count Get the number of selectable pins get_pins_count.dev: Pinctrl device to use This function is necessary to parse the “pins” property in DTS. get_pins_count.Return: number of selectable named pins available in this driver Best regards Heinrich ./include/dm/pinctrl.h:38: warning: Incorrect use of kernel-doc format: * get_pins_count() - Get the number of selectable pins ./include/dm/pinctrl.h:48: warning: Incorrect use of kernel-doc format: * get_pin_name() - Get the name of a pin ./include/dm/pinctrl.h:61: warning: Incorrect use of kernel-doc format: * get_groups_count() - Get the number of selectable groups ./include/dm/pinctrl.h:71: warning: Incorrect use of kernel-doc format: * get_group_name() - Get the name of a group ./include/dm/pinctrl.h:84: warning: Incorrect use of kernel-doc format: * get_functions_count() - Get the number of selectable functions ./include/dm/pinctrl.h:94: warning: Incorrect use of kernel-doc format: * get_function_name() - Get the name of a function ./include/dm/pinctrl.h:108: warning: Incorrect use of kernel-doc format: * pinmux_set() - Mux a pin to a function ./include/dm/pinctrl.h:123: warning: Incorrect use of kernel-doc format: * pinmux_set() - Mux a group of pins to a function ./include/dm/pinctrl.h:138: warning: Incorrect use of kernel-doc format: * pinmux_property_set() - Enable a pinmux group ./include/dm/pinctrl.h:168: warning: Incorrect use of kernel-doc format: * pinconf_set() - configure an individual pin with a parameter ./include/dm/pinctrl.h:183: warning: Incorrect use of kernel-doc format: * pinconf_group_set() - configure all pins in a group with a parameter ./include/dm/pinctrl.h:198: warning: Incorrect use of kernel-doc format: * set_state() - Configure a pinctrl device ./include/dm/pinctrl.h:211: warning: Incorrect use of kernel-doc format: * set_state_simple() - Configure a pinctrl device ./include/dm/pinctrl.h:223: warning: Incorrect use of kernel-doc format: * request() - Request a particular pinctrl function ./include/dm/pinctrl.h:234: warning: Incorrect use of kernel-doc format: * get_periph_id() - get the peripheral ID for a device ./include/dm/pinctrl.h:248: warning: Incorrect use of kernel-doc format: * get_gpio_mux() - get the mux value for a particular GPIO ./include/dm/pinctrl.h:264: warning: Incorrect use of kernel-doc format: * get_pin_muxing() - show pin muxing ./include/dm/pinctrl.h:281: warning: Incorrect use of kernel-doc format: * gpio_request_enable() - request and enable GPIO on a certain pin. ./include/dm/pinctrl.h:296: warning: Incorrect use of kernel-doc format: * gpio_disable_free() - free up GPIO muxing on a certain pin. ./include/dm/pinctrl.h:305: warning: Function parameter or member 'get_pins_count' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'get_pin_name' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'get_groups_count' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'get_group_name' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'get_functions_count' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'get_function_name' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'pinmux_set' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'pinmux_group_set' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'pinmux_property_set' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'pinconf_set' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'pinconf_group_set' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'set_state' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'set_state_simple' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'request' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'get_periph_id' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'get_gpio_mux' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'get_pin_muxing' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'gpio_request_enable' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:305: warning: Function parameter or member 'gpio_disable_free' not described in 'pinctrl_ops' ./include/dm/pinctrl.h:401: warning: cannot understand function prototype: 'enum pin_config_param ' ./include/dm/pinctrl.h:551: warning: Function parameter or member 'size' not described in 'pinctrl_get_pin_name' > --- > > (no changes since v4) > > Changes in v4: > - New > > include/dm/pinctrl.h | 363 ++++++++++++++++++++++++++++--------------- > 1 file changed, 242 insertions(+), 121 deletions(-) > > diff --git a/include/dm/pinctrl.h b/include/dm/pinctrl.h > index d50af1ce38..5b994f22cc 100644 > --- a/include/dm/pinctrl.h > +++ b/include/dm/pinctrl.h > @@ -11,11 +11,10 @@ > > /** > * struct pinconf_param - pin config parameters > - * > - * @property: property name in DT nodes > - * @param: ID for this config parameter > - * @default_value: default value for this config parameter used in case > - * no value is specified in DT nodes > + * @property: Property name in DT nodes > + * @param: ID for this config parameter > + * @default_value: default value for this config parameter used in case > + * no value is specified in DT nodes > */ > struct pinconf_param { > const char * const property; > @@ -27,111 +26,228 @@ struct pinconf_param { > * struct pinctrl_ops - pin control operations, to be implemented by > * pin controller drivers. > * > - * The @set_state is the only mandatory operation. You can implement your > - * pinctrl driver with its own @set_state. In this case, the other callbacks > - * are not required. Otherwise, generic pinctrl framework is also available; > - * use pinctrl_generic_set_state for @set_state, and implement other operations > + * set_state() is the only mandatory operation. You can implement your pinctrl > + * driver with its own @set_state. In this case, the other callbacks are not > + * required. Otherwise, generic pinctrl framework is also available; use > + * pinctrl_generic_set_state for @set_state, and implement other operations > * depending on your necessity. > - * > - * @get_pins_count: return number of selectable named pins available > - * in this driver. (necessary to parse "pins" property in DTS) > - * @get_pin_name: return the pin name of the pin selector, > - * called by the core to figure out which pin it shall do > - * operations to. (necessary to parse "pins" property in DTS) > - * @get_groups_count: return number of selectable named groups available > - * in this driver. (necessary to parse "groups" property in DTS) > - * @get_group_name: return the group name of the group selector, > - * called by the core to figure out which pin group it shall do > - * operations to. (necessary to parse "groups" property in DTS) > - * @get_functions_count: return number of selectable named functions available > - * in this driver. (necessary for pin-muxing) > - * @get_function_name: return the function name of the muxing selector, > - * called by the core to figure out which mux setting it shall map a > - * certain device to. (necessary for pin-muxing) > - * @pinmux_set: enable a certain muxing function with a certain pin. > - * The @func_selector selects a certain function whereas @pin_selector > - * selects a certain pin to be used. On simple controllers one of them > - * may be ignored. (necessary for pin-muxing against a single pin) > - * @pinmux_group_set: enable a certain muxing function with a certain pin > - * group. The @func_selector selects a certain function whereas > - * @group_selector selects a certain set of pins to be used. On simple > - * controllers one of them may be ignored. > - * (necessary for pin-muxing against a pin group) > - * @pinmux_property_set: enable a pinmux group. @pinmux_group should specify the > - * pin identifier and mux settings. The exact format of a pinmux group is > - * left up to the driver. The pin selector for the mux-ed pin should be > - * returned on success. (necessary to parse the "pinmux" property in DTS) > - * @pinconf_num_params: number of driver-specific parameters to be parsed > - * from device trees (necessary for pin-configuration) > - * @pinconf_params: list of driver_specific parameters to be parsed from > - * device trees (necessary for pin-configuration) > - * @pinconf_set: configure an individual pin with a given parameter. > - * (necessary for pin-configuration against a single pin) > - * @pinconf_group_set: configure all pins in a group with a given parameter. > - * (necessary for pin-configuration against a pin group) > - * @set_state: do pinctrl operations specified by @config, a pseudo device > - * 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 { > + /** > + * get_pins_count() - Get the number of selectable pins > + * @dev: Pinctrl device to use > + * > + * This function is necessary to parse the "pins" property in DTS. > + * > + * Return: number of selectable named pins available in this driver > + */ > int (*get_pins_count)(struct udevice *dev); > + > + /** > + * get_pin_name() - Get the name of a pin > + * @dev: Pinctrl device of the pin > + * @selector: The pin selector > + * > + * This function is called by the core to figure out which pin it shall > + * do operations to. This function is necessary to parse the "pins" > + * property in DTS. > + * > + * Return: const pointer to the name of the pin > + */ > const char *(*get_pin_name)(struct udevice *dev, unsigned selector); > + > + /** > + * get_groups_count() - Get the number of selectable groups > + * @dev: Pinctrl device to use > + * > + * This function is necessary to parse the "groups" property in DTS. > + * > + * Return: number of selectable named groups available in the driver > + */ > int (*get_groups_count)(struct udevice *dev); > + > + /** > + * get_group_name() - Get the name of a group > + * @dev: Pinctrl device of the group > + * @selector: The group selector > + * > + * This function is called by the core to figure out which group it > + * shall do operations to. This function is necessary to parse the > + * "groups" property in DTS. > + * > + * Return: const pointer to the name of the group > + */ > const char *(*get_group_name)(struct udevice *dev, unsigned selector); > + > + /** > + * get_functions_count() - Get the number of selectable functions > + * @dev: Pinctrl device to use > + * > + * This function is necessary for pin-muxing. > + * > + * Return: number of selectable named functions available in this driver > + */ > int (*get_functions_count)(struct udevice *dev); > + > + /** > + * get_function_name() - Get the name of a function > + * @dev: Pinmux device of the function > + * @selector: The function selector > + * > + * This function is called by the core to figure out which mux setting > + * it shall map a certain device to. This function is necessary for > + * pin-muxing. > + * > + * Return: const pointer to the function name of the muxing selector > + */ > const char *(*get_function_name)(struct udevice *dev, > unsigned selector); > + > + /** > + * pinmux_set() - Mux a pin to a function > + * @dev: Pinctrl device to use > + * @pin_selector: The pin selector > + * @func_selector: The func selector > + * > + * On simple controllers one of @pin_selector or @func_selector may be > + * ignored. This function is necessary for pin-muxing against a single > + * pin. > + * > + * Return: 0 if OK, or negative error code on failure > + */ > int (*pinmux_set)(struct udevice *dev, unsigned pin_selector, > unsigned func_selector); > + > + /** > + * pinmux_set() - Mux a group of pins to a function > + * @dev: Pinctrl device to use > + * @group_selector: The group selector > + * @func_selector: The func selector > + * > + * On simple controllers one of @group_selector or @func_selector may be > + * ignored. This function is necessary for pin-muxing against a group of > + * pins. > + * > + * Return: 0 if OK, or negative error code on failure > + */ > int (*pinmux_group_set)(struct udevice *dev, unsigned group_selector, > unsigned func_selector); > + > + /** > + * pinmux_property_set() - Enable a pinmux group > + * @dev: Pinctrl device to use > + * @pinmux_group: A u32 representing the pin identifier and mux > + * settings. The exact format of a pinmux group is > + * left up to the driver. > + * > + * Mux a single pin to a single function based on a driver-specific > + * pinmux group. This function is necessary for parsing the "pinmux" > + * property in DTS, and for pin-muxing against a pinmux group. > + * > + * Return: pin selector for the muxed pin if OK, or negative error code > + * on failure > + */ > int (*pinmux_property_set)(struct udevice *dev, u32 pinmux_group); > + > + /** > + * @pinconf_num_params: Number of driver-specific parameters to be > + * parsed from device trees. This member is > + * necessary for pin configuration. > + */ > unsigned int pinconf_num_params; > + > + /** > + * @pinconf_params: List of driver-specific parameters to be parsed > + * from the device tree. This member is necessary > + * for pin configuration. > + */ > const struct pinconf_param *pinconf_params; > + > + /** > + * pinconf_set() - configure an individual pin with a parameter > + * @dev: Pinctrl device to use > + * @pin_selector: The pin selector > + * @param: A &enum pin_config_param from @pinconf_params > + * @argument: The argument to this param from the device tree > + * > + * This function is necessary for pin configuration against a single > + * pin. > + * > + * Return: 0 if OK, or negative error code on failure > + */ > int (*pinconf_set)(struct udevice *dev, unsigned pin_selector, > unsigned param, unsigned argument); > + > + /** > + * pinconf_group_set() - configure all pins in a group with a parameter > + * @dev: Pinctrl device to use > + * @pin_selector: The group selector > + * @param: A &enum pin_config_param from @pinconf_params > + * @argument: The argument to this param from the device tree > + * > + * This function is necessary for pin configuration against a group of > + * pins. > + * > + * Return: 0 if OK, or negative error code on failure > + */ > int (*pinconf_group_set)(struct udevice *dev, unsigned group_selector, > unsigned param, unsigned argument); > + > + /** > + * set_state() - Configure a pinctrl device > + * @dev: Pinctrl device to use > + * @config: Pseudo device pointing a config node > + * > + * This function is required to be implemented by all pinctrl drivers. > + * Drivers may set this member to pinctrl_generic_set_state(), which > + * will call other functions in &struct pinctrl_ops to parse @config. > + * > + * Return: 0 if OK, or negative error code on failure > + */ > int (*set_state)(struct udevice *dev, struct udevice *config); > > - /* for pinctrl-simple */ > + /** > + * set_state_simple() - Configure a pinctrl device > + * @dev: Pinctrl device to use > + * @config: Pseudo-device pointing a config node > + * > + * This function is usually a simpler version of set_state(). Only the > + * first pinctrl device on the system is supported by this function. > + * > + * Return: 0 if OK, or negative error code on failure > + */ > int (*set_state_simple)(struct udevice *dev, struct udevice *periph); > + > /** > * request() - Request a particular pinctrl function > + * @dev: Device to adjust (UCLASS_PINCTRL) > + * @func: Function number (driver-specific) > * > * This activates the selected function. > * > - * @dev: Device to adjust (UCLASS_PINCTRL) > - * @func: Function number (driver-specific) > - * @return 0 if OK, -ve on error > + * Return: 0 if OK, or negative error code on failure > */ > int (*request)(struct udevice *dev, int func, int flags); > > /** > * get_periph_id() - get the peripheral ID for a device > + * @dev: Pinctrl device to use for decoding > + * @periph: Device to check > * > * 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 > + * 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 > + * @dev: Pinctrl device to use > + * @banknum: GPIO bank number > + * @index: GPIO index within the bank > * > * 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 > @@ -139,46 +255,50 @@ struct pinctrl_ops { > * 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) > + * 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 > + * > + * This allows to display the muxing of a given pin. It's useful for > + * debug purposes 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. > + * > + * Return: 0 if OK, or negative error code on failure > */ > 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. > - * > + * gpio_request_enable() - request and enable GPIO on a certain pin. > * @dev: Pinctrl device to use > * @selector: Pin selector > - * return 0 if OK, -ve on error > + * > + * 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. > + * > + * Return: 0 if OK, or negative error code on failure > */ > int (*gpio_request_enable)(struct udevice *dev, unsigned int selector); > > /** > - * gpio_disable_free: free up GPIO muxing on a certain pin. > - * > + * 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 > + * > + * This function is the reverse of gpio_request_enable(). > + * > + * Return: 0 if OK, or negative error code on failure > */ > int (*gpio_disable_free)(struct udevice *dev, unsigned int selector); > }; > @@ -230,8 +350,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_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 > @@ -307,12 +427,13 @@ enum pin_config_param { > #if CONFIG_IS_ENABLED(PINCTRL_GENERIC) > /** > * pinctrl_generic_set_state() - generic set_state operation > + * @pctldev: Pinctrl device to use > + * @config: Config device (pseudo device), pointing a config node in DTS > + * > * Parse the DT node of @config and its children and handle generic properties > * such as "pins", "groups", "functions", and pin configuration parameters. > * > - * @pctldev: pinctrl device > - * @config: config device (pseudo device), pointing a config node in DTS > - * @return: 0 on success, or negative error code on failure > + * Return: 0 on success, or negative error code on failure > */ > int pinctrl_generic_set_state(struct udevice *pctldev, struct udevice *config); > #else > @@ -326,10 +447,10 @@ static inline int pinctrl_generic_set_state(struct udevice *pctldev, > #if CONFIG_IS_ENABLED(PINCTRL) > /** > * pinctrl_select_state() - set a device to a given state > + * @dev: Peripheral device > + * @statename: State name, like "default" > * > - * @dev: peripheral device > - * @statename: state name, like "default" > - * @return: 0 on success, or negative error code on failure > + * Return: 0 on success, or negative error code on failure > */ > int pinctrl_select_state(struct udevice *dev, const char *statename); > #else > @@ -342,40 +463,43 @@ static inline int pinctrl_select_state(struct udevice *dev, > > /** > * pinctrl_request() - Request a particular pinctrl function > - * > - * @dev: Device to check (UCLASS_PINCTRL) > + * @dev: Pinctrl device to use > * @func: Function number (driver-specific) > * @flags: Flags (driver-specific) > - * @return 0 if OK, -ve on error > + * > + * Return: 0 if OK, or negative error code on failure > */ > int pinctrl_request(struct udevice *dev, int func, int flags); > > /** > * pinctrl_request_noflags() - Request a particular pinctrl function > + * @dev: Pinctrl device to use > + * @func: Function number (driver-specific) > * > * 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 > + * Return: 0 if OK, or negative error code on failure > */ > int pinctrl_request_noflags(struct udevice *dev, int func); > > /** > * pinctrl_get_periph_id() - get the peripheral ID for a device > + * @dev: Pinctrl device to use for decoding > + * @periph: Device to check > * > * 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 > + * Return: peripheral ID of @periph, or -ENOENT on error > */ > int pinctrl_get_periph_id(struct udevice *dev, struct udevice *periph); > > /** > * pinctrl_get_gpio_mux() - get the mux value for a particular GPIO > + * @dev: Pinctrl device to use > + * @banknum: GPIO bank number > + * @index: GPIO index within the bank > * > * 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 > @@ -383,66 +507,63 @@ int pinctrl_get_periph_id(struct udevice *dev, struct udevice *periph); > * 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) > + * 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); > > /** > * pinctrl_get_pin_muxing() - Returns the muxing description > + * @dev: Pinctrl device to use > + * @selector: Pin index within pin-controller > + * @buf: Pin's muxing description > + * @size: Pin's muxing description length > * > * 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 > + * Return: 0 if OK, or negative error code on failure > */ > int pinctrl_get_pin_muxing(struct udevice *dev, int selector, char *buf, > int size); > > /** > * pinctrl_get_pins_count() - display pin-controller pins number > + * @dev: Pinctrl device to use > * > * 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 > + * Return: number of pins if OK, or negative error code on failure > */ > int pinctrl_get_pins_count(struct udevice *dev); > > /** > * pinctrl_get_pin_name() - Returns the pin's name > + * @dev: Pinctrl device to use > + * @selector: Pin index within pin-controller > + * @buf: 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 > + * Return: 0 if OK, or negative error code on failure > */ > 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: GPIO pin offset from the GPIO controller > * > - * @dev: GPIO peripheral device > - * @offset: the GPIO pin offset from the GPIO controller > - * @return: 0 on success, or negative error code on failure > + * 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: GPIO pin offset from the GPIO controller > * > - * @dev: GPIO peripheral device > - * @offset: the GPIO pin offset from the GPIO controller > - * @return: 0 on success, or negative error code on failure > + * Return: 0 on success, or negative error code on failure > */ > int pinctrl_gpio_free(struct udevice *dev, unsigned offset); > >
On 9/2/20 8:26 AM, Heinrich Schuchardt wrote: > On 15.08.20 17:52, Sean Anderson wrote: >> This normalizes the documentatation to conform to kernel-doc style [1]. It > > Nits: > %s/documentatation/documentation/ > >> also moves the documentation for pinctrl_ops inline, and adds argument and >> return-value documentation. I have kept the usual function style for these >> comments. I could not find any existing examples of function documentation >> inside structs. >> >> [1] https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html >> >> Signed-off-by: Sean Anderson <seanga2@gmail.com> >> Reviewed-by: Simon Glass <sjg@chromium.org> > > > Before and after this patch the documentation format is incorrect. See > output below for the situation after the patch. > > Please include include/dm/pinctrl.h into doc/api/index.rst via a new > file doc/api/pnctrl.rst. > > A documentation style accepted by 'make htmldocs' is: > > struct pinctrl_ops { > /** > * @get_pins_count: Get the number of selectable pins > * > * @get_pins_count.dev: Pinctrl device to use > * > * This function is necessary to parse the "pins" property > * in DTS. > * > * @get_pins_count.Return: number of selectable named pins > * available in this driver > */ > int (*get_pins_count)(struct udevice *dev); > > See the nested structures in > > https://www.kernel.org/doc/html/v5.7/doc-guide/kernel-doc.html#in-line-member-documentation-comments > and > https://www.kernel.org/doc/html/v5.7/doc-guide/kernel-doc.html#nested-structs-unions Thanks for suggesting those changes. This works better. As far as I can tell, fully-qualified members are only necessary when documenting nested structs at the top-level. When using in-line documentation, members are automatically nested. With that in mind, I am using the following format /** * @pinmux_property_set: Enable a pinmux group * * @dev: Pinctrl device to use * * @pinmux_group: A u32 representing the pin identifier and mux * settings. The exact format of a pinmux group is left * up to the driver. * * Mux a single pin to a single function based on a driver-specific * pinmux group. This function is necessary for parsing the "pinmux" * property in DTS, and for pin-muxing against a pinmux group. * * @Return: * Pin selector for the muxed pin if OK, or negative error code on * failure */ int (*pinmux_property_set)(struct udevice *dev, u32 pinmux_group); However, I am having some problems with multi-line descriptions. In the example above, the desciption for @pinmux_group has the first line bolded and the rest of the description is typeset as normal, but is indented. The generated html is <dl class="docutils"> <dt><strong>pinmux_group</strong>: A u32 representing the pin identifier and mux</dt> <dd>settings. The exact format of a pinmux group is left up to the driver.</dd> </dl> However, it should be something like <p><strong>pinmux_group</strong>: A u32 representing the pin identifier and mux settings. The exact format of a pinmux group is left up to the driver.</p> I have also tried an alternate style, as shown for @Return. However, this too generated the wrong html: <dl class="last docutils"> <dt><strong>Return</strong>:</dt> <dd>Pin selector for the muxed pin if OK, or negative error code on failure</dd> </dl> where it should generate something like <p class="last"><strong>Return</strong>: Pin selector for the muxed pin if OK, or negative error code on failure</p> Do you have any suggestions for generating the latter forms? My current work is at [1]. --Sean [1] https://github.com/Forty-Bot/u-boot/commit/e835cf9552dc96438699806731a208b40daead7b
On 02.09.20 16:56, Sean Anderson wrote: > > On 9/2/20 8:26 AM, Heinrich Schuchardt wrote: >> On 15.08.20 17:52, Sean Anderson wrote: >>> This normalizes the documentatation to conform to kernel-doc style [1]. It >> >> Nits: >> %s/documentatation/documentation/ >> >>> also moves the documentation for pinctrl_ops inline, and adds argument and >>> return-value documentation. I have kept the usual function style for these >>> comments. I could not find any existing examples of function documentation >>> inside structs. >>> >>> [1] https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html >>> >>> Signed-off-by: Sean Anderson <seanga2@gmail.com> >>> Reviewed-by: Simon Glass <sjg@chromium.org> >> >> >> Before and after this patch the documentation format is incorrect. See >> output below for the situation after the patch. >> >> Please include include/dm/pinctrl.h into doc/api/index.rst via a new >> file doc/api/pnctrl.rst. >> >> A documentation style accepted by 'make htmldocs' is: >> >> struct pinctrl_ops { >> /** >> * @get_pins_count: Get the number of selectable pins >> * >> * @get_pins_count.dev: Pinctrl device to use >> * >> * This function is necessary to parse the "pins" property >> * in DTS. >> * >> * @get_pins_count.Return: number of selectable named pins >> * available in this driver >> */ >> int (*get_pins_count)(struct udevice *dev); >> >> See the nested structures in >> >> https://www.kernel.org/doc/html/v5.7/doc-guide/kernel-doc.html#in-line-member-documentation-comments >> and >> https://www.kernel.org/doc/html/v5.7/doc-guide/kernel-doc.html#nested-structs-unions > > Thanks for suggesting those changes. This works better. As far as I can > tell, fully-qualified members are only necessary when documenting nested > structs at the top-level. When using in-line documentation, members are > automatically nested. With that in mind, I am using the following format > > /** > * @pinmux_property_set: Enable a pinmux group > * > * @dev: Pinctrl device to use > * > * @pinmux_group: A u32 representing the pin identifier and mux > * settings. The exact format of a pinmux group is left > * up to the driver. > * > * Mux a single pin to a single function based on a driver-specific > * pinmux group. This function is necessary for parsing the "pinmux" > * property in DTS, and for pin-muxing against a pinmux group. > * > * @Return: > * Pin selector for the muxed pin if OK, or negative error code on > * failure > */ > int (*pinmux_property_set)(struct udevice *dev, u32 pinmux_group); > > However, I am having some problems with multi-line descriptions. In the > example above, the desciption for @pinmux_group has the first line > bolded and the rest of the description is typeset as normal, but is > indented. The generated html is Use fully qualified names and you are fine. Best regards Heinrich > > <dl class="docutils"> > <dt><strong>pinmux_group</strong>: A u32 representing the pin identifier > and mux</dt> > <dd>settings. The exact format of a pinmux group is left up to the > driver.</dd> > </dl> > > However, it should be something like > > <p><strong>pinmux_group</strong>: A u32 representing the pin identifier > and mux settings. The exact format of a pinmux group is left up to the > driver.</p> > > I have also tried an alternate style, as shown for @Return. However, > this too generated the wrong html: > > <dl class="last docutils"> > <dt><strong>Return</strong>:</dt> > <dd>Pin selector for the muxed pin if OK, or negative error code on > failure</dd> > </dl> > > where it should generate something like > > <p class="last"><strong>Return</strong>: Pin selector for the muxed pin > if OK, or negative error code on failure</p> > > Do you have any suggestions for generating the latter forms? My current > work is at [1]. > > --Sean > > [1] https://github.com/Forty-Bot/u-boot/commit/e835cf9552dc96438699806731a208b40daead7b >
On 9/2/20 11:17 AM, Heinrich Schuchardt wrote: > On 02.09.20 16:56, Sean Anderson wrote: >> >> On 9/2/20 8:26 AM, Heinrich Schuchardt wrote: >>> On 15.08.20 17:52, Sean Anderson wrote: >>>> This normalizes the documentatation to conform to kernel-doc style [1]. It >>> >>> Nits: >>> %s/documentatation/documentation/ >>> >>>> also moves the documentation for pinctrl_ops inline, and adds argument and >>>> return-value documentation. I have kept the usual function style for these >>>> comments. I could not find any existing examples of function documentation >>>> inside structs. >>>> >>>> [1] https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html >>>> >>>> Signed-off-by: Sean Anderson <seanga2@gmail.com> >>>> Reviewed-by: Simon Glass <sjg@chromium.org> >>> >>> >>> Before and after this patch the documentation format is incorrect. See >>> output below for the situation after the patch. >>> >>> Please include include/dm/pinctrl.h into doc/api/index.rst via a new >>> file doc/api/pnctrl.rst. >>> >>> A documentation style accepted by 'make htmldocs' is: >>> >>> struct pinctrl_ops { >>> /** >>> * @get_pins_count: Get the number of selectable pins >>> * >>> * @get_pins_count.dev: Pinctrl device to use >>> * >>> * This function is necessary to parse the "pins" property >>> * in DTS. >>> * >>> * @get_pins_count.Return: number of selectable named pins >>> * available in this driver >>> */ >>> int (*get_pins_count)(struct udevice *dev); >>> >>> See the nested structures in >>> >>> https://www.kernel.org/doc/html/v5.7/doc-guide/kernel-doc.html#in-line-member-documentation-comments >>> and >>> https://www.kernel.org/doc/html/v5.7/doc-guide/kernel-doc.html#nested-structs-unions >> >> Thanks for suggesting those changes. This works better. As far as I can >> tell, fully-qualified members are only necessary when documenting nested >> structs at the top-level. When using in-line documentation, members are >> automatically nested. With that in mind, I am using the following format >> >> /** >> * @pinmux_property_set: Enable a pinmux group >> * >> * @dev: Pinctrl device to use >> * >> * @pinmux_group: A u32 representing the pin identifier and mux >> * settings. The exact format of a pinmux group is left >> * up to the driver. >> * >> * Mux a single pin to a single function based on a driver-specific >> * pinmux group. This function is necessary for parsing the "pinmux" >> * property in DTS, and for pin-muxing against a pinmux group. >> * >> * @Return: >> * Pin selector for the muxed pin if OK, or negative error code on >> * failure >> */ >> int (*pinmux_property_set)(struct udevice *dev, u32 pinmux_group); >> >> However, I am having some problems with multi-line descriptions. In the >> example above, the desciption for @pinmux_group has the first line >> bolded and the rest of the description is typeset as normal, but is >> indented. The generated html is > > Use fully qualified names and you are fine. I also experienced this issue when using fully-qualified names. > > Best regards > > Heinrich > >> >> <dl class="docutils"> >> <dt><strong>pinmux_group</strong>: A u32 representing the pin identifier >> and mux</dt> >> <dd>settings. The exact format of a pinmux group is left up to the >> driver.</dd> >> </dl> >> >> However, it should be something like >> >> <p><strong>pinmux_group</strong>: A u32 representing the pin identifier >> and mux settings. The exact format of a pinmux group is left up to the >> driver.</p> >> >> I have also tried an alternate style, as shown for @Return. However, >> this too generated the wrong html: >> >> <dl class="last docutils"> >> <dt><strong>Return</strong>:</dt> >> <dd>Pin selector for the muxed pin if OK, or negative error code on >> failure</dd> >> </dl> >> >> where it should generate something like >> >> <p class="last"><strong>Return</strong>: Pin selector for the muxed pin >> if OK, or negative error code on failure</p> >> >> Do you have any suggestions for generating the latter forms? My current >> work is at [1]. >> >> --Sean >> >> [1] https://github.com/Forty-Bot/u-boot/commit/e835cf9552dc96438699806731a208b40daead7b >> >
diff --git a/include/dm/pinctrl.h b/include/dm/pinctrl.h index d50af1ce38..5b994f22cc 100644 --- a/include/dm/pinctrl.h +++ b/include/dm/pinctrl.h @@ -11,11 +11,10 @@ /** * struct pinconf_param - pin config parameters - * - * @property: property name in DT nodes - * @param: ID for this config parameter - * @default_value: default value for this config parameter used in case - * no value is specified in DT nodes + * @property: Property name in DT nodes + * @param: ID for this config parameter + * @default_value: default value for this config parameter used in case + * no value is specified in DT nodes */ struct pinconf_param { const char * const property; @@ -27,111 +26,228 @@ struct pinconf_param { * struct pinctrl_ops - pin control operations, to be implemented by * pin controller drivers. * - * The @set_state is the only mandatory operation. You can implement your - * pinctrl driver with its own @set_state. In this case, the other callbacks - * are not required. Otherwise, generic pinctrl framework is also available; - * use pinctrl_generic_set_state for @set_state, and implement other operations + * set_state() is the only mandatory operation. You can implement your pinctrl + * driver with its own @set_state. In this case, the other callbacks are not + * required. Otherwise, generic pinctrl framework is also available; use + * pinctrl_generic_set_state for @set_state, and implement other operations * depending on your necessity. - * - * @get_pins_count: return number of selectable named pins available - * in this driver. (necessary to parse "pins" property in DTS) - * @get_pin_name: return the pin name of the pin selector, - * called by the core to figure out which pin it shall do - * operations to. (necessary to parse "pins" property in DTS) - * @get_groups_count: return number of selectable named groups available - * in this driver. (necessary to parse "groups" property in DTS) - * @get_group_name: return the group name of the group selector, - * called by the core to figure out which pin group it shall do - * operations to. (necessary to parse "groups" property in DTS) - * @get_functions_count: return number of selectable named functions available - * in this driver. (necessary for pin-muxing) - * @get_function_name: return the function name of the muxing selector, - * called by the core to figure out which mux setting it shall map a - * certain device to. (necessary for pin-muxing) - * @pinmux_set: enable a certain muxing function with a certain pin. - * The @func_selector selects a certain function whereas @pin_selector - * selects a certain pin to be used. On simple controllers one of them - * may be ignored. (necessary for pin-muxing against a single pin) - * @pinmux_group_set: enable a certain muxing function with a certain pin - * group. The @func_selector selects a certain function whereas - * @group_selector selects a certain set of pins to be used. On simple - * controllers one of them may be ignored. - * (necessary for pin-muxing against a pin group) - * @pinmux_property_set: enable a pinmux group. @pinmux_group should specify the - * pin identifier and mux settings. The exact format of a pinmux group is - * left up to the driver. The pin selector for the mux-ed pin should be - * returned on success. (necessary to parse the "pinmux" property in DTS) - * @pinconf_num_params: number of driver-specific parameters to be parsed - * from device trees (necessary for pin-configuration) - * @pinconf_params: list of driver_specific parameters to be parsed from - * device trees (necessary for pin-configuration) - * @pinconf_set: configure an individual pin with a given parameter. - * (necessary for pin-configuration against a single pin) - * @pinconf_group_set: configure all pins in a group with a given parameter. - * (necessary for pin-configuration against a pin group) - * @set_state: do pinctrl operations specified by @config, a pseudo device - * 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 { + /** + * get_pins_count() - Get the number of selectable pins + * @dev: Pinctrl device to use + * + * This function is necessary to parse the "pins" property in DTS. + * + * Return: number of selectable named pins available in this driver + */ int (*get_pins_count)(struct udevice *dev); + + /** + * get_pin_name() - Get the name of a pin + * @dev: Pinctrl device of the pin + * @selector: The pin selector + * + * This function is called by the core to figure out which pin it shall + * do operations to. This function is necessary to parse the "pins" + * property in DTS. + * + * Return: const pointer to the name of the pin + */ const char *(*get_pin_name)(struct udevice *dev, unsigned selector); + + /** + * get_groups_count() - Get the number of selectable groups + * @dev: Pinctrl device to use + * + * This function is necessary to parse the "groups" property in DTS. + * + * Return: number of selectable named groups available in the driver + */ int (*get_groups_count)(struct udevice *dev); + + /** + * get_group_name() - Get the name of a group + * @dev: Pinctrl device of the group + * @selector: The group selector + * + * This function is called by the core to figure out which group it + * shall do operations to. This function is necessary to parse the + * "groups" property in DTS. + * + * Return: const pointer to the name of the group + */ const char *(*get_group_name)(struct udevice *dev, unsigned selector); + + /** + * get_functions_count() - Get the number of selectable functions + * @dev: Pinctrl device to use + * + * This function is necessary for pin-muxing. + * + * Return: number of selectable named functions available in this driver + */ int (*get_functions_count)(struct udevice *dev); + + /** + * get_function_name() - Get the name of a function + * @dev: Pinmux device of the function + * @selector: The function selector + * + * This function is called by the core to figure out which mux setting + * it shall map a certain device to. This function is necessary for + * pin-muxing. + * + * Return: const pointer to the function name of the muxing selector + */ const char *(*get_function_name)(struct udevice *dev, unsigned selector); + + /** + * pinmux_set() - Mux a pin to a function + * @dev: Pinctrl device to use + * @pin_selector: The pin selector + * @func_selector: The func selector + * + * On simple controllers one of @pin_selector or @func_selector may be + * ignored. This function is necessary for pin-muxing against a single + * pin. + * + * Return: 0 if OK, or negative error code on failure + */ int (*pinmux_set)(struct udevice *dev, unsigned pin_selector, unsigned func_selector); + + /** + * pinmux_set() - Mux a group of pins to a function + * @dev: Pinctrl device to use + * @group_selector: The group selector + * @func_selector: The func selector + * + * On simple controllers one of @group_selector or @func_selector may be + * ignored. This function is necessary for pin-muxing against a group of + * pins. + * + * Return: 0 if OK, or negative error code on failure + */ int (*pinmux_group_set)(struct udevice *dev, unsigned group_selector, unsigned func_selector); + + /** + * pinmux_property_set() - Enable a pinmux group + * @dev: Pinctrl device to use + * @pinmux_group: A u32 representing the pin identifier and mux + * settings. The exact format of a pinmux group is + * left up to the driver. + * + * Mux a single pin to a single function based on a driver-specific + * pinmux group. This function is necessary for parsing the "pinmux" + * property in DTS, and for pin-muxing against a pinmux group. + * + * Return: pin selector for the muxed pin if OK, or negative error code + * on failure + */ int (*pinmux_property_set)(struct udevice *dev, u32 pinmux_group); + + /** + * @pinconf_num_params: Number of driver-specific parameters to be + * parsed from device trees. This member is + * necessary for pin configuration. + */ unsigned int pinconf_num_params; + + /** + * @pinconf_params: List of driver-specific parameters to be parsed + * from the device tree. This member is necessary + * for pin configuration. + */ const struct pinconf_param *pinconf_params; + + /** + * pinconf_set() - configure an individual pin with a parameter + * @dev: Pinctrl device to use + * @pin_selector: The pin selector + * @param: A &enum pin_config_param from @pinconf_params + * @argument: The argument to this param from the device tree + * + * This function is necessary for pin configuration against a single + * pin. + * + * Return: 0 if OK, or negative error code on failure + */ int (*pinconf_set)(struct udevice *dev, unsigned pin_selector, unsigned param, unsigned argument); + + /** + * pinconf_group_set() - configure all pins in a group with a parameter + * @dev: Pinctrl device to use + * @pin_selector: The group selector + * @param: A &enum pin_config_param from @pinconf_params + * @argument: The argument to this param from the device tree + * + * This function is necessary for pin configuration against a group of + * pins. + * + * Return: 0 if OK, or negative error code on failure + */ int (*pinconf_group_set)(struct udevice *dev, unsigned group_selector, unsigned param, unsigned argument); + + /** + * set_state() - Configure a pinctrl device + * @dev: Pinctrl device to use + * @config: Pseudo device pointing a config node + * + * This function is required to be implemented by all pinctrl drivers. + * Drivers may set this member to pinctrl_generic_set_state(), which + * will call other functions in &struct pinctrl_ops to parse @config. + * + * Return: 0 if OK, or negative error code on failure + */ int (*set_state)(struct udevice *dev, struct udevice *config); - /* for pinctrl-simple */ + /** + * set_state_simple() - Configure a pinctrl device + * @dev: Pinctrl device to use + * @config: Pseudo-device pointing a config node + * + * This function is usually a simpler version of set_state(). Only the + * first pinctrl device on the system is supported by this function. + * + * Return: 0 if OK, or negative error code on failure + */ int (*set_state_simple)(struct udevice *dev, struct udevice *periph); + /** * request() - Request a particular pinctrl function + * @dev: Device to adjust (UCLASS_PINCTRL) + * @func: Function number (driver-specific) * * This activates the selected function. * - * @dev: Device to adjust (UCLASS_PINCTRL) - * @func: Function number (driver-specific) - * @return 0 if OK, -ve on error + * Return: 0 if OK, or negative error code on failure */ int (*request)(struct udevice *dev, int func, int flags); /** * get_periph_id() - get the peripheral ID for a device + * @dev: Pinctrl device to use for decoding + * @periph: Device to check * * 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 + * 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 + * @dev: Pinctrl device to use + * @banknum: GPIO bank number + * @index: GPIO index within the bank * * 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 @@ -139,46 +255,50 @@ struct pinctrl_ops { * 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) + * 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 + * + * This allows to display the muxing of a given pin. It's useful for + * debug purposes 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. + * + * Return: 0 if OK, or negative error code on failure */ 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. - * + * gpio_request_enable() - request and enable GPIO on a certain pin. * @dev: Pinctrl device to use * @selector: Pin selector - * return 0 if OK, -ve on error + * + * 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. + * + * Return: 0 if OK, or negative error code on failure */ int (*gpio_request_enable)(struct udevice *dev, unsigned int selector); /** - * gpio_disable_free: free up GPIO muxing on a certain pin. - * + * 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 + * + * This function is the reverse of gpio_request_enable(). + * + * Return: 0 if OK, or negative error code on failure */ int (*gpio_disable_free)(struct udevice *dev, unsigned int selector); }; @@ -230,8 +350,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_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 @@ -307,12 +427,13 @@ enum pin_config_param { #if CONFIG_IS_ENABLED(PINCTRL_GENERIC) /** * pinctrl_generic_set_state() - generic set_state operation + * @pctldev: Pinctrl device to use + * @config: Config device (pseudo device), pointing a config node in DTS + * * Parse the DT node of @config and its children and handle generic properties * such as "pins", "groups", "functions", and pin configuration parameters. * - * @pctldev: pinctrl device - * @config: config device (pseudo device), pointing a config node in DTS - * @return: 0 on success, or negative error code on failure + * Return: 0 on success, or negative error code on failure */ int pinctrl_generic_set_state(struct udevice *pctldev, struct udevice *config); #else @@ -326,10 +447,10 @@ static inline int pinctrl_generic_set_state(struct udevice *pctldev, #if CONFIG_IS_ENABLED(PINCTRL) /** * pinctrl_select_state() - set a device to a given state + * @dev: Peripheral device + * @statename: State name, like "default" * - * @dev: peripheral device - * @statename: state name, like "default" - * @return: 0 on success, or negative error code on failure + * Return: 0 on success, or negative error code on failure */ int pinctrl_select_state(struct udevice *dev, const char *statename); #else @@ -342,40 +463,43 @@ static inline int pinctrl_select_state(struct udevice *dev, /** * pinctrl_request() - Request a particular pinctrl function - * - * @dev: Device to check (UCLASS_PINCTRL) + * @dev: Pinctrl device to use * @func: Function number (driver-specific) * @flags: Flags (driver-specific) - * @return 0 if OK, -ve on error + * + * Return: 0 if OK, or negative error code on failure */ int pinctrl_request(struct udevice *dev, int func, int flags); /** * pinctrl_request_noflags() - Request a particular pinctrl function + * @dev: Pinctrl device to use + * @func: Function number (driver-specific) * * 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 + * Return: 0 if OK, or negative error code on failure */ int pinctrl_request_noflags(struct udevice *dev, int func); /** * pinctrl_get_periph_id() - get the peripheral ID for a device + * @dev: Pinctrl device to use for decoding + * @periph: Device to check * * 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 + * Return: peripheral ID of @periph, or -ENOENT on error */ int pinctrl_get_periph_id(struct udevice *dev, struct udevice *periph); /** * pinctrl_get_gpio_mux() - get the mux value for a particular GPIO + * @dev: Pinctrl device to use + * @banknum: GPIO bank number + * @index: GPIO index within the bank * * 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 @@ -383,66 +507,63 @@ int pinctrl_get_periph_id(struct udevice *dev, struct udevice *periph); * 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) + * 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); /** * pinctrl_get_pin_muxing() - Returns the muxing description + * @dev: Pinctrl device to use + * @selector: Pin index within pin-controller + * @buf: Pin's muxing description + * @size: Pin's muxing description length * * 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 + * Return: 0 if OK, or negative error code on failure */ int pinctrl_get_pin_muxing(struct udevice *dev, int selector, char *buf, int size); /** * pinctrl_get_pins_count() - display pin-controller pins number + * @dev: Pinctrl device to use * * 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 + * Return: number of pins if OK, or negative error code on failure */ int pinctrl_get_pins_count(struct udevice *dev); /** * pinctrl_get_pin_name() - Returns the pin's name + * @dev: Pinctrl device to use + * @selector: Pin index within pin-controller + * @buf: 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 + * Return: 0 if OK, or negative error code on failure */ 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: GPIO pin offset from the GPIO controller * - * @dev: GPIO peripheral device - * @offset: the GPIO pin offset from the GPIO controller - * @return: 0 on success, or negative error code on failure + * 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: GPIO pin offset from the GPIO controller * - * @dev: GPIO peripheral device - * @offset: the GPIO pin offset from the GPIO controller - * @return: 0 on success, or negative error code on failure + * Return: 0 on success, or negative error code on failure */ int pinctrl_gpio_free(struct udevice *dev, unsigned offset);