pinctrl.h 21 KB

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