Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 2 | /* |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 3 | * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@com> |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef __PINCTRL_H |
| 7 | #define __PINCTRL_H |
| 8 | |
Bo Lv | 72d0e90 | 2023-01-02 14:27:34 +0000 | [diff] [blame] | 9 | #ifdef CONFIG_AMLOGIC_MODIFY |
| 10 | #include <dm/device.h> |
| 11 | #endif |
| 12 | |
Patrice Chotard | d5a8313 | 2018-10-24 14:10:17 +0200 | [diff] [blame] | 13 | #define PINNAME_SIZE 10 |
Ashok Reddy Soma | e19b8dd | 2022-02-23 15:23:04 +0100 | [diff] [blame] | 14 | #define PINMUX_SIZE 80 |
Patrice Chotard | d5a8313 | 2018-10-24 14:10:17 +0200 | [diff] [blame] | 15 | |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 16 | /** |
| 17 | * struct pinconf_param - pin config parameters |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 18 | * @property: Property name in DT nodes |
| 19 | * @param: ID for this config parameter |
| 20 | * @default_value: default value for this config parameter used in case |
| 21 | * no value is specified in DT nodes |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 22 | */ |
| 23 | struct pinconf_param { |
| 24 | const char * const property; |
| 25 | unsigned int param; |
| 26 | u32 default_value; |
| 27 | }; |
| 28 | |
| 29 | /** |
| 30 | * struct pinctrl_ops - pin control operations, to be implemented by |
| 31 | * pin controller drivers. |
| 32 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 33 | * set_state() is the only mandatory operation. You can implement your pinctrl |
| 34 | * driver with its own @set_state. In this case, the other callbacks are not |
| 35 | * required. Otherwise, generic pinctrl framework is also available; use |
| 36 | * pinctrl_generic_set_state for @set_state, and implement other operations |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 37 | * depending on your necessity. |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 38 | */ |
| 39 | struct pinctrl_ops { |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 40 | /** |
| 41 | * @get_pins_count: Get the number of selectable pins |
| 42 | * |
| 43 | * @dev: Pinctrl device to use |
| 44 | * |
| 45 | * This function is necessary to parse the "pins" property in DTS. |
| 46 | * |
| 47 | * @Return: |
| 48 | * number of selectable named pins available in this driver |
| 49 | */ |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 50 | int (*get_pins_count)(struct udevice *dev); |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * @get_pin_name: Get the name of a pin |
| 54 | * |
| 55 | * @dev: Pinctrl device of the pin |
| 56 | * |
| 57 | * @selector: The pin selector |
| 58 | * |
| 59 | * This function is called by the core to figure out which pin it will |
| 60 | * do operations to. This function is necessary to parse the "pins" |
| 61 | * property in DTS. |
| 62 | * |
| 63 | * @Return: const pointer to the name of the pin |
| 64 | */ |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 65 | const char *(*get_pin_name)(struct udevice *dev, unsigned selector); |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 66 | |
| 67 | /** |
| 68 | * @get_groups_count: Get the number of selectable groups |
| 69 | * |
| 70 | * @dev: Pinctrl device to use |
| 71 | * |
| 72 | * This function is necessary to parse the "groups" property in DTS. |
| 73 | * |
| 74 | * @Return: |
| 75 | * number of selectable named groups available in the driver |
| 76 | */ |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 77 | int (*get_groups_count)(struct udevice *dev); |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 78 | |
| 79 | /** |
| 80 | * @get_group_name: Get the name of a group |
| 81 | * |
| 82 | * @dev: Pinctrl device of the group |
| 83 | * |
| 84 | * @selector: The group selector |
| 85 | * |
| 86 | * This function is called by the core to figure out which group it |
| 87 | * will do operations to. This function is necessary to parse the |
| 88 | * "groups" property in DTS. |
| 89 | * |
| 90 | * @Return: Pointer to the name of the group |
| 91 | */ |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 92 | const char *(*get_group_name)(struct udevice *dev, unsigned selector); |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 93 | |
| 94 | /** |
| 95 | * @get_functions_count: Get the number of selectable functions |
| 96 | * |
| 97 | * @dev: Pinctrl device to use |
| 98 | * |
| 99 | * This function is necessary for pin-muxing. |
| 100 | * |
| 101 | * @Return: |
| 102 | * number of selectable named functions available in this driver |
| 103 | */ |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 104 | int (*get_functions_count)(struct udevice *dev); |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | * @get_function_name: Get the name of a function |
| 108 | * |
| 109 | * @dev: Pinmux device of the function |
| 110 | * |
| 111 | * @selector: The function selector |
| 112 | * |
| 113 | * This function is called by the core to figure out which mux setting |
| 114 | * it will map a certain device to. This function is necessary for |
| 115 | * pin-muxing. |
| 116 | * |
| 117 | * @Return: |
| 118 | * Pointer to the function name of the muxing selector |
| 119 | */ |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 120 | const char *(*get_function_name)(struct udevice *dev, |
| 121 | unsigned selector); |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 122 | |
| 123 | /** |
| 124 | * @pinmux_set: Mux a pin to a function |
| 125 | * |
| 126 | * @dev: Pinctrl device to use |
| 127 | * |
| 128 | * @pin_selector: The pin selector |
| 129 | * |
| 130 | * @func_selector: The func selector |
| 131 | * |
| 132 | * On simple controllers one of @pin_selector or @func_selector may be |
| 133 | * ignored. This function is necessary for pin-muxing against a single |
| 134 | * pin. |
| 135 | * |
| 136 | * @Return: 0 if OK, or negative error code on failure |
| 137 | */ |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 138 | int (*pinmux_set)(struct udevice *dev, unsigned pin_selector, |
| 139 | unsigned func_selector); |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 140 | |
| 141 | /** |
| 142 | * @pinmux_group_set: Mux a group of pins to a function |
| 143 | * |
| 144 | * @dev: Pinctrl device to use |
| 145 | * |
| 146 | * @group_selector: The group selector |
| 147 | * |
| 148 | * @func_selector: The func selector |
| 149 | * |
| 150 | * On simple controllers one of @group_selector or @func_selector may be |
| 151 | * ignored. This function is necessary for pin-muxing against a group of |
| 152 | * pins. |
| 153 | * |
| 154 | * @Return: 0 if OK, or negative error code on failure |
| 155 | */ |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 156 | int (*pinmux_group_set)(struct udevice *dev, unsigned group_selector, |
| 157 | unsigned func_selector); |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 158 | |
| 159 | /** |
| 160 | * @pinmux_property_set: Enable a pinmux group |
| 161 | * |
| 162 | * @dev: Pinctrl device to use |
| 163 | * |
| 164 | * @pinmux_group: A u32 representing the pin identifier and mux |
| 165 | * settings. The exact format of a pinmux group is left |
| 166 | * up to the driver. |
| 167 | * |
| 168 | * Mux a single pin to a single function based on a driver-specific |
| 169 | * pinmux group. This function is necessary for parsing the "pinmux" |
| 170 | * property in DTS, and for pin-muxing against a pinmux group. |
| 171 | * |
| 172 | * @Return: |
| 173 | * Pin selector for the muxed pin if OK, or negative error code on |
| 174 | * failure |
| 175 | */ |
Sean Anderson | 9c08fbf | 2020-09-14 11:01:55 -0400 | [diff] [blame] | 176 | int (*pinmux_property_set)(struct udevice *dev, u32 pinmux_group); |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 177 | |
| 178 | /** |
| 179 | * @pinconf_num_params: |
| 180 | * Number of driver-specific parameters to be parsed from device |
| 181 | * trees. This member is necessary for pin configuration. |
| 182 | */ |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 183 | unsigned int pinconf_num_params; |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 184 | |
| 185 | /** |
| 186 | * @pinconf_params: |
| 187 | * List of driver-specific parameters to be parsed from the device |
| 188 | * tree. This member is necessary for pin configuration. |
| 189 | */ |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 190 | const struct pinconf_param *pinconf_params; |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 191 | |
| 192 | /** |
| 193 | * @pinconf_set: Configure an individual pin with a parameter |
| 194 | * |
| 195 | * @dev: Pinctrl device to use |
| 196 | * |
| 197 | * @pin_selector: The pin selector |
| 198 | * |
| 199 | * @param: An &enum pin_config_param from @pinconf_params |
| 200 | * |
| 201 | * @argument: The argument to this param from the device tree, or |
| 202 | * @pinconf_params.default_value |
| 203 | * |
| 204 | * This function is necessary for pin configuration against a single |
| 205 | * pin. |
| 206 | * |
| 207 | * @Return: 0 if OK, or negative error code on failure |
| 208 | */ |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 209 | int (*pinconf_set)(struct udevice *dev, unsigned pin_selector, |
| 210 | unsigned param, unsigned argument); |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 211 | |
| 212 | /** |
| 213 | * @pinconf_group_set: Configure all pins in a group with a parameter |
| 214 | * |
| 215 | * @dev: Pinctrl device to use |
| 216 | * |
| 217 | * @pin_selector: The group selector |
| 218 | * |
| 219 | * @param: A &enum pin_config_param from |
| 220 | * @pinconf_params |
| 221 | * |
| 222 | * @argument: The argument to this param from the device tree, or |
| 223 | * @pinconf_params.default_value |
| 224 | * |
| 225 | * This function is necessary for pin configuration against a group of |
| 226 | * pins. |
| 227 | * |
| 228 | * @Return: 0 if OK, or negative error code on failure |
| 229 | */ |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 230 | int (*pinconf_group_set)(struct udevice *dev, unsigned group_selector, |
| 231 | unsigned param, unsigned argument); |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 232 | |
| 233 | /** |
| 234 | * @set_state: Configure a pinctrl device |
| 235 | * |
| 236 | * @dev: Pinctrl device to use |
| 237 | * |
| 238 | * @config: Pseudo device pointing a config node |
| 239 | * |
| 240 | * This function is required to be implemented by all pinctrl drivers. |
| 241 | * Drivers may set this member to pinctrl_generic_set_state(), which |
| 242 | * will call other functions in &struct pinctrl_ops to parse |
| 243 | * @config. |
| 244 | * |
| 245 | * @Return: 0 if OK, or negative error code on failure |
| 246 | */ |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 247 | int (*set_state)(struct udevice *dev, struct udevice *config); |
Simon Glass | c5acf4a | 2015-08-30 16:55:13 -0600 | [diff] [blame] | 248 | |
Simon Glass | c5acf4a | 2015-08-30 16:55:13 -0600 | [diff] [blame] | 249 | /** |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 250 | * @set_state_simple: Configure a pinctrl device |
| 251 | * |
| 252 | * @dev: Pinctrl device to use |
| 253 | * |
| 254 | * @config: Pseudo-device pointing a config node |
| 255 | * |
| 256 | * This function is usually a simpler version of set_state(). Only the |
| 257 | * first pinctrl device on the system is supported by this function. |
| 258 | * |
| 259 | * @Return: 0 if OK, or negative error code on failure |
| 260 | */ |
| 261 | int (*set_state_simple)(struct udevice *dev, struct udevice *periph); |
| 262 | |
| 263 | /** |
| 264 | * @request: Request a particular pinctrl function |
| 265 | * |
| 266 | * @dev: Device to adjust (%UCLASS_PINCTRL) |
| 267 | * |
| 268 | * @func: Function number (driver-specific) |
Simon Glass | c5acf4a | 2015-08-30 16:55:13 -0600 | [diff] [blame] | 269 | * |
| 270 | * This activates the selected function. |
| 271 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 272 | * @Return: 0 if OK, or negative error code on failure |
Simon Glass | c5acf4a | 2015-08-30 16:55:13 -0600 | [diff] [blame] | 273 | */ |
| 274 | int (*request)(struct udevice *dev, int func, int flags); |
| 275 | |
| 276 | /** |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 277 | * @get_periph_id: Get the peripheral ID for a device |
| 278 | * |
| 279 | * @dev: Pinctrl device to use for decoding |
| 280 | * |
| 281 | * @periph: Device to check |
Simon Glass | c5acf4a | 2015-08-30 16:55:13 -0600 | [diff] [blame] | 282 | * |
| 283 | * This generally looks at the peripheral's device tree node to work |
| 284 | * out the peripheral ID. The return value is normally interpreted as |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 285 | * &enum periph_id. so long as this is defined by the platform (which it |
Simon Glass | c5acf4a | 2015-08-30 16:55:13 -0600 | [diff] [blame] | 286 | * should be). |
| 287 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 288 | * @Return: |
| 289 | * Peripheral ID of @periph, or %-ENOENT on error |
Simon Glass | c5acf4a | 2015-08-30 16:55:13 -0600 | [diff] [blame] | 290 | */ |
| 291 | int (*get_periph_id)(struct udevice *dev, struct udevice *periph); |
Simon Glass | 77eaa19 | 2016-01-21 19:43:56 -0700 | [diff] [blame] | 292 | |
| 293 | /** |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 294 | * @get_gpio_mux: Get the mux value for a particular GPIO |
| 295 | * |
| 296 | * @dev: Pinctrl device to use |
| 297 | * |
| 298 | * @banknum: GPIO bank number |
| 299 | * |
| 300 | * @index: GPIO index within the bank |
Simon Glass | 77eaa19 | 2016-01-21 19:43:56 -0700 | [diff] [blame] | 301 | * |
| 302 | * This allows the raw mux value for a GPIO to be obtained. It is |
| 303 | * useful for displaying the function being used by that GPIO, such |
| 304 | * as with the 'gpio' command. This function is internal to the GPIO |
| 305 | * subsystem and should not be used by generic code. Typically it is |
| 306 | * used by a GPIO driver with knowledge of the SoC pinctrl setup. |
| 307 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 308 | * @Return: |
| 309 | * Mux value (SoC-specific, e.g. 0 for input, 1 for output) |
Simon Glass | 77eaa19 | 2016-01-21 19:43:56 -0700 | [diff] [blame] | 310 | */ |
| 311 | int (*get_gpio_mux)(struct udevice *dev, int banknum, int index); |
Bo Lv | 72d0e90 | 2023-01-02 14:27:34 +0000 | [diff] [blame] | 312 | #ifdef CONFIG_AMLOGIC_MODIFY |
| 313 | /* set_gpio_mux() - set the mux value for a particular GPIO |
| 314 | * |
| 315 | * This is useful for setting the mux value before a pin used as GPIO. |
| 316 | * such as with the 'gpio' command. This function is internal to the GPIO |
| 317 | * subsystem and should not be used by generic code. Typically it is used |
| 318 | * by a GPIO driver with knowledge of the SoC pinctrl setup. |
| 319 | * |
| 320 | * @dev: Pinctrl device to use |
| 321 | * @banknum: GPIO bank number |
| 322 | * @index: GPIO index within the bank |
| 323 | */ |
| 324 | int (*set_gpio_mux)(struct udevice *dev, int index); |
| 325 | #endif |
Patrice Chotard | f55a0c0 | 2018-10-24 14:10:13 +0200 | [diff] [blame] | 326 | /** |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 327 | * @get_pin_muxing: Show pin muxing |
| 328 | * |
| 329 | * @dev: Pinctrl device to use |
| 330 | * |
| 331 | * @selector: Pin selector |
| 332 | * |
| 333 | * @buf: Buffer to fill with pin muxing description |
| 334 | * |
| 335 | * @size: Size of @buf |
Patrice Chotard | f55a0c0 | 2018-10-24 14:10:13 +0200 | [diff] [blame] | 336 | * |
| 337 | * This allows to display the muxing of a given pin. It's useful for |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 338 | * debug purposes to know if a pin is configured as GPIO or as an |
| 339 | * alternate function and which one. Typically it is used by a PINCTRL |
| 340 | * driver with knowledge of the SoC pinctrl setup. |
Patrice Chotard | f55a0c0 | 2018-10-24 14:10:13 +0200 | [diff] [blame] | 341 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 342 | * @Return: 0 if OK, or negative error code on failure |
Patrice Chotard | f55a0c0 | 2018-10-24 14:10:13 +0200 | [diff] [blame] | 343 | */ |
| 344 | int (*get_pin_muxing)(struct udevice *dev, unsigned int selector, |
| 345 | char *buf, int size); |
Marek Vasut | ae59d7c | 2019-04-21 23:57:23 +0200 | [diff] [blame] | 346 | |
| 347 | /** |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 348 | * @gpio_request_enable: Request and enable GPIO on a certain pin. |
Marek Vasut | ae59d7c | 2019-04-21 23:57:23 +0200 | [diff] [blame] | 349 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 350 | * @dev: Pinctrl device to use |
| 351 | * |
| 352 | * @selector: Pin selector |
| 353 | * |
| 354 | * Implement this only if you can mux every pin individually as GPIO. |
| 355 | * The affected GPIO range is passed along with an offset(pin number) |
| 356 | * into that specific GPIO range - function selectors and pin groups are |
| 357 | * orthogonal to this, the core will however make sure the pins do not |
| 358 | * collide. |
| 359 | * |
| 360 | * @Return: |
| 361 | * 0 if OK, or negative error code on failure |
Marek Vasut | ae59d7c | 2019-04-21 23:57:23 +0200 | [diff] [blame] | 362 | */ |
| 363 | int (*gpio_request_enable)(struct udevice *dev, unsigned int selector); |
| 364 | |
| 365 | /** |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 366 | * @gpio_disable_free: Free up GPIO muxing on a certain pin. |
Marek Vasut | ae59d7c | 2019-04-21 23:57:23 +0200 | [diff] [blame] | 367 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 368 | * @dev: Pinctrl device to use |
| 369 | * |
| 370 | * @selector: Pin selector |
| 371 | * |
| 372 | * This function is the reverse of @gpio_request_enable. |
| 373 | * |
| 374 | * @Return: 0 if OK, or negative error code on failure |
Marek Vasut | ae59d7c | 2019-04-21 23:57:23 +0200 | [diff] [blame] | 375 | */ |
| 376 | int (*gpio_disable_free)(struct udevice *dev, unsigned int selector); |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 377 | }; |
| 378 | |
| 379 | #define pinctrl_get_ops(dev) ((struct pinctrl_ops *)(dev)->driver->ops) |
| 380 | |
| 381 | /** |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 382 | * enum pin_config_param - Generic pin configuration parameters |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 383 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 384 | * @PIN_CONFIG_BIAS_BUS_HOLD: The pin will be set to weakly latch so that it |
Peng Fan | 0fe4e41 | 2018-01-05 14:05:17 +0800 | [diff] [blame] | 385 | * weakly drives the last value on a tristate bus, also known as a "bus |
| 386 | * holder", "bus keeper" or "repeater". This allows another device on the |
| 387 | * bus to change the value by driving the bus high or low and switching to |
| 388 | * tristate. The argument is ignored. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 389 | * @PIN_CONFIG_BIAS_DISABLE: Disable any pin bias on the pin, a |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 390 | * transition from say pull-up to pull-down implies that you disable |
| 391 | * pull-up in the process, this setting disables all biasing. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 392 | * @PIN_CONFIG_BIAS_HIGH_IMPEDANCE: The pin will be set to a high impedance |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 393 | * mode, also know as "third-state" (tristate) or "high-Z" or "floating". |
| 394 | * On output pins this effectively disconnects the pin, which is useful |
| 395 | * if for example some other pin is going to drive the signal connected |
| 396 | * to it for a while. Pins used for input are usually always high |
| 397 | * impedance. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 398 | * @PIN_CONFIG_BIAS_PULL_DOWN: The pin will be pulled down (usually with high |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 399 | * impedance to GROUND). If the argument is != 0 pull-down is enabled, |
| 400 | * if it is 0, pull-down is total, i.e. the pin is connected to GROUND. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 401 | * @PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: The pin will be pulled up or down based |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 402 | * on embedded knowledge of the controller hardware, like current mux |
| 403 | * function. The pull direction and possibly strength too will normally |
| 404 | * be decided completely inside the hardware block and not be readable |
| 405 | * from the kernel side. |
| 406 | * If the argument is != 0 pull up/down is enabled, if it is 0, the |
| 407 | * configuration is ignored. The proper way to disable it is to use |
| 408 | * @PIN_CONFIG_BIAS_DISABLE. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 409 | * @PIN_CONFIG_BIAS_PULL_UP: The pin will be pulled up (usually with high |
Peng Fan | 0fe4e41 | 2018-01-05 14:05:17 +0800 | [diff] [blame] | 410 | * impedance to VDD). If the argument is != 0 pull-up is enabled, |
| 411 | * if it is 0, pull-up is total, i.e. the pin is connected to VDD. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 412 | * @PIN_CONFIG_DRIVE_OPEN_DRAIN: The pin will be driven with open drain (open |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 413 | * collector) which means it is usually wired with other output ports |
| 414 | * which are then pulled up with an external resistor. Setting this |
| 415 | * config will enable open drain mode, the argument is ignored. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 416 | * @PIN_CONFIG_DRIVE_OPEN_SOURCE: The pin will be driven with open source |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 417 | * (open emitter). Setting this config will enable open source mode, the |
| 418 | * argument is ignored. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 419 | * @PIN_CONFIG_DRIVE_PUSH_PULL: The pin will be driven actively high and |
Peng Fan | 0fe4e41 | 2018-01-05 14:05:17 +0800 | [diff] [blame] | 420 | * low, this is the most typical case and is typically achieved with two |
| 421 | * active transistors on the output. Setting this config will enable |
| 422 | * push-pull mode, the argument is ignored. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 423 | * @PIN_CONFIG_DRIVE_STRENGTH: The pin will sink or source at most the current |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 424 | * passed as argument. The argument is in mA. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 425 | * @PIN_CONFIG_DRIVE_STRENGTH_UA: The pin will sink or source at most the |
| 426 | * current passed as argument. The argument is in uA. |
| 427 | * @PIN_CONFIG_INPUT_DEBOUNCE: This will configure the pin to debounce mode, |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 428 | * which means it will wait for signals to settle when reading inputs. The |
| 429 | * argument gives the debounce time in usecs. Setting the |
| 430 | * argument to zero turns debouncing off. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 431 | * @PIN_CONFIG_INPUT_ENABLE: Enable the pin's input. Note that this does not |
Peng Fan | 0fe4e41 | 2018-01-05 14:05:17 +0800 | [diff] [blame] | 432 | * affect the pin's ability to drive output. 1 enables input, 0 disables |
| 433 | * input. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 434 | * @PIN_CONFIG_INPUT_SCHMITT: This will configure an input pin to run in |
Peng Fan | 0fe4e41 | 2018-01-05 14:05:17 +0800 | [diff] [blame] | 435 | * schmitt-trigger mode. If the schmitt-trigger has adjustable hysteresis, |
| 436 | * the threshold value is given on a custom format as argument when |
| 437 | * setting pins to this mode. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 438 | * @PIN_CONFIG_INPUT_SCHMITT_ENABLE: Control schmitt-trigger mode on the pin. |
Peng Fan | 0fe4e41 | 2018-01-05 14:05:17 +0800 | [diff] [blame] | 439 | * If the argument != 0, schmitt-trigger mode is enabled. If it's 0, |
| 440 | * schmitt-trigger mode is disabled. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 441 | * @PIN_CONFIG_LOW_POWER_MODE: This will configure the pin for low power |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 442 | * operation, if several modes of operation are supported these can be |
| 443 | * passed in the argument on a custom form, else just use argument 1 |
| 444 | * to indicate low power mode, argument 0 turns low power mode off. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 445 | * @PIN_CONFIG_OUTPUT_ENABLE: This will enable the pin's output mode |
Peng Fan | 0fe4e41 | 2018-01-05 14:05:17 +0800 | [diff] [blame] | 446 | * without driving a value there. For most platforms this reduces to |
| 447 | * enable the output buffers and then let the pin controller current |
| 448 | * configuration (eg. the currently selected mux function) drive values on |
| 449 | * the line. Use argument 1 to enable output mode, argument 0 to disable |
| 450 | * it. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 451 | * @PIN_CONFIG_OUTPUT: This will configure the pin as an output and drive a |
Peng Fan | 0fe4e41 | 2018-01-05 14:05:17 +0800 | [diff] [blame] | 452 | * value on the line. Use argument 1 to indicate high level, argument 0 to |
| 453 | * indicate low level. (Please see Documentation/driver-api/pinctl.rst, |
| 454 | * section "GPIO mode pitfalls" for a discussion around this parameter.) |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 455 | * @PIN_CONFIG_POWER_SOURCE: If the pin can select between different power |
Peng Fan | 0fe4e41 | 2018-01-05 14:05:17 +0800 | [diff] [blame] | 456 | * supplies, the argument to this parameter (on a custom format) tells |
| 457 | * the driver which alternative power source to use. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 458 | * @PIN_CONFIG_SLEEP_HARDWARE_STATE: Indicate this is sleep related state. |
| 459 | * @PIN_CONFIG_SLEW_RATE: If the pin can select slew rate, the argument to |
Peng Fan | 0fe4e41 | 2018-01-05 14:05:17 +0800 | [diff] [blame] | 460 | * this parameter (on a custom format) tells the driver which alternative |
| 461 | * slew rate to use. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 462 | * @PIN_CONFIG_SKEW_DELAY: If the pin has programmable skew rate (on inputs) |
Peng Fan | 0fe4e41 | 2018-01-05 14:05:17 +0800 | [diff] [blame] | 463 | * or latch delay (on outputs) this parameter (in a custom format) |
| 464 | * specifies the clock skew or latch delay. It typically controls how |
| 465 | * many double inverters are put in front of the line. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 466 | * @PIN_CONFIG_END: This is the last enumerator for pin configurations, if |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 467 | * you need to pass in custom configurations to the pin controller, use |
| 468 | * PIN_CONFIG_END+1 as the base offset. |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 469 | * @PIN_CONFIG_MAX: This is the maximum configuration value that can be |
Peng Fan | 0fe4e41 | 2018-01-05 14:05:17 +0800 | [diff] [blame] | 470 | * presented using the packed format. |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 471 | */ |
Peng Fan | 0fe4e41 | 2018-01-05 14:05:17 +0800 | [diff] [blame] | 472 | enum pin_config_param { |
Ashok Reddy Soma | 4173a42 | 2022-02-23 15:02:51 +0100 | [diff] [blame] | 473 | PIN_CONFIG_BIAS_BUS_HOLD = 0, |
| 474 | PIN_CONFIG_BIAS_DISABLE = 1, |
| 475 | PIN_CONFIG_BIAS_HIGH_IMPEDANCE = 2, |
| 476 | PIN_CONFIG_BIAS_PULL_DOWN = 3, |
| 477 | PIN_CONFIG_BIAS_PULL_PIN_DEFAULT = 4, |
| 478 | PIN_CONFIG_BIAS_PULL_UP = 5, |
| 479 | PIN_CONFIG_DRIVE_OPEN_DRAIN = 6, |
| 480 | PIN_CONFIG_DRIVE_OPEN_SOURCE = 7, |
| 481 | PIN_CONFIG_DRIVE_PUSH_PULL = 8, |
| 482 | PIN_CONFIG_DRIVE_STRENGTH = 9, |
| 483 | PIN_CONFIG_DRIVE_STRENGTH_UA = 10, |
| 484 | PIN_CONFIG_INPUT_DEBOUNCE = 11, |
| 485 | PIN_CONFIG_INPUT_ENABLE = 12, |
| 486 | PIN_CONFIG_INPUT_SCHMITT = 13, |
| 487 | PIN_CONFIG_INPUT_SCHMITT_ENABLE = 14, |
| 488 | PIN_CONFIG_LOW_POWER_MODE = 15, |
| 489 | PIN_CONFIG_OUTPUT_ENABLE = 16, |
| 490 | PIN_CONFIG_OUTPUT = 17, |
| 491 | PIN_CONFIG_POWER_SOURCE = 18, |
| 492 | PIN_CONFIG_SLEEP_HARDWARE_STATE = 19, |
| 493 | PIN_CONFIG_SLEW_RATE = 20, |
| 494 | PIN_CONFIG_SKEW_DELAY = 21, |
| 495 | PIN_CONFIG_END = 127, /* 0x7F */ |
| 496 | PIN_CONFIG_MAX = 255, /* 0xFF */ |
Peng Fan | 0fe4e41 | 2018-01-05 14:05:17 +0800 | [diff] [blame] | 497 | }; |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 498 | |
| 499 | #if CONFIG_IS_ENABLED(PINCTRL_GENERIC) |
| 500 | /** |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 501 | * pinctrl_generic_set_state() - Generic set_state operation |
| 502 | * @pctldev: Pinctrl device to use |
| 503 | * @config: Config device (pseudo device), pointing a config node in DTS |
| 504 | * |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 505 | * Parse the DT node of @config and its children and handle generic properties |
| 506 | * such as "pins", "groups", "functions", and pin configuration parameters. |
| 507 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 508 | * Return: 0 on success, or negative error code on failure |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 509 | */ |
| 510 | int pinctrl_generic_set_state(struct udevice *pctldev, struct udevice *config); |
Pali Rohár | 92c4a95 | 2022-07-25 13:56:08 +0200 | [diff] [blame] | 511 | int pinctrl_generic_set_state_prefix(struct udevice *pctldev, struct udevice *config, |
| 512 | const char *prefix); |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 513 | #else |
| 514 | static inline int pinctrl_generic_set_state(struct udevice *pctldev, |
| 515 | struct udevice *config) |
| 516 | { |
Patrick Delaunay | 1c01712 | 2021-11-19 10:02:26 +0100 | [diff] [blame] | 517 | return -ENOSYS; |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 518 | } |
| 519 | #endif |
| 520 | |
| 521 | #if CONFIG_IS_ENABLED(PINCTRL) |
| 522 | /** |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 523 | * pinctrl_select_state() - Set a device to a given state |
| 524 | * @dev: Peripheral device |
| 525 | * @statename: State name, like "default" |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 526 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 527 | * Return: 0 on success, or negative error code on failure |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 528 | */ |
| 529 | int pinctrl_select_state(struct udevice *dev, const char *statename); |
| 530 | #else |
| 531 | static inline int pinctrl_select_state(struct udevice *dev, |
| 532 | const char *statename) |
| 533 | { |
Patrick Delaunay | 1c01712 | 2021-11-19 10:02:26 +0100 | [diff] [blame] | 534 | return -ENOSYS; |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 535 | } |
| 536 | #endif |
| 537 | |
Simon Glass | c5acf4a | 2015-08-30 16:55:13 -0600 | [diff] [blame] | 538 | /** |
| 539 | * pinctrl_request() - Request a particular pinctrl function |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 540 | * @dev: Pinctrl device to use |
Simon Glass | c5acf4a | 2015-08-30 16:55:13 -0600 | [diff] [blame] | 541 | * @func: Function number (driver-specific) |
| 542 | * @flags: Flags (driver-specific) |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 543 | * |
| 544 | * Return: 0 if OK, or negative error code on failure |
Simon Glass | c5acf4a | 2015-08-30 16:55:13 -0600 | [diff] [blame] | 545 | */ |
| 546 | int pinctrl_request(struct udevice *dev, int func, int flags); |
| 547 | |
| 548 | /** |
| 549 | * pinctrl_request_noflags() - Request a particular pinctrl function |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 550 | * @dev: Pinctrl device to use |
| 551 | * @func: Function number (driver-specific) |
Simon Glass | c5acf4a | 2015-08-30 16:55:13 -0600 | [diff] [blame] | 552 | * |
| 553 | * This is similar to pinctrl_request() but uses 0 for @flags. |
| 554 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 555 | * Return: 0 if OK, or negative error code on failure |
Simon Glass | c5acf4a | 2015-08-30 16:55:13 -0600 | [diff] [blame] | 556 | */ |
| 557 | int pinctrl_request_noflags(struct udevice *dev, int func); |
| 558 | |
| 559 | /** |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 560 | * pinctrl_get_periph_id() - Get the peripheral ID for a device |
| 561 | * @dev: Pinctrl device to use for decoding |
| 562 | * @periph: Device to check |
Simon Glass | c5acf4a | 2015-08-30 16:55:13 -0600 | [diff] [blame] | 563 | * |
| 564 | * This generally looks at the peripheral's device tree node to work out the |
| 565 | * peripheral ID. The return value is normally interpreted as enum periph_id. |
| 566 | * so long as this is defined by the platform (which it should be). |
| 567 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 568 | * Return: Peripheral ID of @periph, or -ENOENT on error |
Simon Glass | c5acf4a | 2015-08-30 16:55:13 -0600 | [diff] [blame] | 569 | */ |
| 570 | int pinctrl_get_periph_id(struct udevice *dev, struct udevice *periph); |
| 571 | |
Simon Glass | 52db39a | 2016-01-21 19:43:26 -0700 | [diff] [blame] | 572 | /** |
Simon Glass | 77eaa19 | 2016-01-21 19:43:56 -0700 | [diff] [blame] | 573 | * pinctrl_get_gpio_mux() - get the mux value for a particular GPIO |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 574 | * @dev: Pinctrl device to use |
| 575 | * @banknum: GPIO bank number |
| 576 | * @index: GPIO index within the bank |
Simon Glass | 77eaa19 | 2016-01-21 19:43:56 -0700 | [diff] [blame] | 577 | * |
| 578 | * This allows the raw mux value for a GPIO to be obtained. It is |
| 579 | * useful for displaying the function being used by that GPIO, such |
| 580 | * as with the 'gpio' command. This function is internal to the GPIO |
| 581 | * subsystem and should not be used by generic code. Typically it is |
| 582 | * used by a GPIO driver with knowledge of the SoC pinctrl setup. |
| 583 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 584 | * Return: Mux value (SoC-specific, e.g. 0 for input, 1 for output) |
Simon Glass | 77eaa19 | 2016-01-21 19:43:56 -0700 | [diff] [blame] | 585 | */ |
| 586 | int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index); |
| 587 | |
Bo Lv | 72d0e90 | 2023-01-02 14:27:34 +0000 | [diff] [blame] | 588 | #ifdef CONFIG_AMLOGIC_MODIFY |
| 589 | /** |
| 590 | * pinctrl_set_gpio_mux() - set the mux value for a particular GPIO |
| 591 | * |
| 592 | * This is useful for setting the mux value before a pin used as GPIO. |
| 593 | * such as with the 'gpio' command. This function is internal to the GPIO |
| 594 | * subsystem and should not be used by generic code. Typically it is used |
| 595 | * by a GPIO driver with knowledge of the SoC pinctrl setup. |
| 596 | * |
| 597 | * @dev: Pinctrl device to use |
| 598 | * @banknum: GPIO bank number |
| 599 | * @index: GPIO index within the bank |
| 600 | */ |
| 601 | int pinctrl_set_gpio_mux(struct udevice *dev, int banknum, int index); |
| 602 | #endif |
| 603 | |
Patrice Chotard | f55a0c0 | 2018-10-24 14:10:13 +0200 | [diff] [blame] | 604 | /** |
| 605 | * pinctrl_get_pin_muxing() - Returns the muxing description |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 606 | * @dev: Pinctrl device to use |
| 607 | * @selector: Pin index within pin-controller |
| 608 | * @buf: Pin's muxing description |
| 609 | * @size: Pin's muxing description length |
Patrice Chotard | f55a0c0 | 2018-10-24 14:10:13 +0200 | [diff] [blame] | 610 | * |
| 611 | * This allows to display the muxing description of the given pin for |
| 612 | * debug purpose |
| 613 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 614 | * Return: 0 if OK, or negative error code on failure |
Patrice Chotard | f55a0c0 | 2018-10-24 14:10:13 +0200 | [diff] [blame] | 615 | */ |
| 616 | int pinctrl_get_pin_muxing(struct udevice *dev, int selector, char *buf, |
| 617 | int size); |
| 618 | |
Patrice Chotard | 8bbb5b2 | 2018-10-24 14:10:14 +0200 | [diff] [blame] | 619 | /** |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 620 | * pinctrl_get_pins_count() - Display pin-controller pins number |
| 621 | * @dev: Pinctrl device to use |
Patrice Chotard | 8bbb5b2 | 2018-10-24 14:10:14 +0200 | [diff] [blame] | 622 | * |
| 623 | * This allows to know the number of pins owned by a given pin-controller |
| 624 | * |
Patrick Delaunay | 4c60fd9 | 2021-05-21 09:47:31 +0200 | [diff] [blame] | 625 | * Return: Number of pins if OK, or -ENOSYS when not supported |
Patrice Chotard | 8bbb5b2 | 2018-10-24 14:10:14 +0200 | [diff] [blame] | 626 | */ |
| 627 | int pinctrl_get_pins_count(struct udevice *dev); |
| 628 | |
| 629 | /** |
| 630 | * pinctrl_get_pin_name() - Returns the pin's name |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 631 | * @dev: Pinctrl device to use |
| 632 | * @selector: Pin index within pin-controller |
| 633 | * @buf: Buffer to fill with the name of the pin |
| 634 | * @size: Size of @buf |
Patrice Chotard | 8bbb5b2 | 2018-10-24 14:10:14 +0200 | [diff] [blame] | 635 | * |
| 636 | * This allows to display the pin's name for debug purpose |
| 637 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 638 | * Return: 0 if OK, or negative error code on failure |
Patrice Chotard | 8bbb5b2 | 2018-10-24 14:10:14 +0200 | [diff] [blame] | 639 | */ |
| 640 | int pinctrl_get_pin_name(struct udevice *dev, int selector, char *buf, |
| 641 | int size); |
Marek Vasut | ae59d7c | 2019-04-21 23:57:23 +0200 | [diff] [blame] | 642 | |
| 643 | /** |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 644 | * pinctrl_gpio_request() - Request a single pin to be used as GPIO |
| 645 | * @dev: GPIO peripheral device |
| 646 | * @offset: GPIO pin offset from the GPIO controller |
Pali Rohár | a1de103 | 2022-07-25 13:56:11 +0200 | [diff] [blame] | 647 | * @label: GPIO label |
Marek Vasut | ae59d7c | 2019-04-21 23:57:23 +0200 | [diff] [blame] | 648 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 649 | * Return: 0 on success, or negative error code on failure |
Marek Vasut | ae59d7c | 2019-04-21 23:57:23 +0200 | [diff] [blame] | 650 | */ |
Pali Rohár | a1de103 | 2022-07-25 13:56:11 +0200 | [diff] [blame] | 651 | int pinctrl_gpio_request(struct udevice *dev, unsigned offset, const char *label); |
Marek Vasut | ae59d7c | 2019-04-21 23:57:23 +0200 | [diff] [blame] | 652 | |
| 653 | /** |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 654 | * pinctrl_gpio_free() - Free a single pin used as GPIO |
| 655 | * @dev: GPIO peripheral device |
| 656 | * @offset: GPIO pin offset from the GPIO controller |
Marek Vasut | ae59d7c | 2019-04-21 23:57:23 +0200 | [diff] [blame] | 657 | * |
Sean Anderson | 5eee93e | 2020-09-14 11:01:56 -0400 | [diff] [blame] | 658 | * Return: 0 on success, or negative error code on failure |
Marek Vasut | ae59d7c | 2019-04-21 23:57:23 +0200 | [diff] [blame] | 659 | */ |
| 660 | int pinctrl_gpio_free(struct udevice *dev, unsigned offset); |
| 661 | |
Masahiro Yamada | d90a5a3 | 2015-08-27 12:44:29 +0900 | [diff] [blame] | 662 | #endif /* __PINCTRL_H */ |