summaryrefslogtreecommitdiff
path: root/include/dm/pinctrl.h
blob: a09b242fd9906410e26759a378d57ee9a3207821 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Copyright (C) 2015  Masahiro Yamada <yamada.masahiro@com>
 */

#ifndef __PINCTRL_H
#define __PINCTRL_H

#define PINNAME_SIZE	10
#define PINMUX_SIZE	80

/**
 * 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
 */
struct pinconf_param {
	const char * const property;
	unsigned int param;
	u32 default_value;
};

/**
 * struct pinctrl_ops - pin control operations, to be implemented by
 * pin controller drivers.
 *
 * 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.
 */
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 will
	 * 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
	 * will do operations to. This function is necessary to parse the
	 * "groups" property in DTS.
	 *
	 * @Return: 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 will map a certain device to. This function is necessary for
	 * pin-muxing.
	 *
	 * @Return:
	 *	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_group_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: An &enum pin_config_param from @pinconf_params
	 *
	 * @argument: The argument to this param from the device tree, or
	 *            @pinconf_params.default_value
	 *
	 * 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, or
	 *            @pinconf_params.default_value
	 *
	 * 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);

	/**
	 * @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.
	 *
	 * @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).
	*
	* @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
	 * as with the 'gpio' command. This function is internal to the GPIO
	 * subsystem and should not be used by generic code. Typically it is
	 * used by a GPIO driver with knowledge of the SoC pinctrl setup.
	 *
	 * @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
	 *
	 * @dev: Pinctrl device to use
	 *
	 * @selector: Pin selector
	 *
	 * @buf: Buffer to fill with pin muxing description
	 *
	 * @size: Size of @buf
	 *
	 * 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: Request and enable GPIO on a certain pin.
	 *
	 * @dev: Pinctrl device to use
	 *
	 * @selector: Pin selector
	 *
	 * 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.
	 *
	 * @dev: Pinctrl device to use
	 *
	 * @selector: Pin selector
	 *
	 * 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);
};

#define pinctrl_get_ops(dev)	((struct pinctrl_ops *)(dev)->driver->ops)

/**
 * enum pin_config_param - Generic pin configuration parameters
 *
 * @PIN_CONFIG_BIAS_BUS_HOLD: The pin will be set to weakly latch so that it
 *	weakly drives the last value on a tristate bus, also known as a "bus
 *	holder", "bus keeper" or "repeater". This allows another device on the
 *	bus to change the value by driving the bus high or low and switching to
 *	tristate. The argument is ignored.
 * @PIN_CONFIG_BIAS_DISABLE: Disable any pin bias on the pin, a
 *	transition from say pull-up to pull-down implies that you disable
 *	pull-up in the process, this setting disables all biasing.
 * @PIN_CONFIG_BIAS_HIGH_IMPEDANCE: The pin will be set to a high impedance
 *	mode, also know as "third-state" (tristate) or "high-Z" or "floating".
 *	On output pins this effectively disconnects the pin, which is useful
 *	if for example some other pin is going to drive the signal connected
 *	to it for a while. Pins used for input are usually always high
 *	impedance.
 * @PIN_CONFIG_BIAS_PULL_DOWN: The pin will be pulled down (usually with high
 *	impedance to GROUND). If the argument is != 0 pull-down is enabled,
 *	if it is 0, pull-down is total, i.e. the pin is connected to GROUND.
 * @PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: The pin will be pulled up or down based
 *	on embedded knowledge of the controller hardware, like current mux
 *	function. The pull direction and possibly strength too will normally
 *	be decided completely inside the hardware block and not be readable
 *	from the kernel side.
 *	If the argument is != 0 pull up/down is enabled, if it is 0, the
 *	configuration is ignored. The proper way to disable it is to use
 *	@PIN_CONFIG_BIAS_DISABLE.
 * @PIN_CONFIG_BIAS_PULL_UP: The pin will be pulled up (usually with high
 *	impedance to VDD). If the argument is != 0 pull-up is enabled,
 *	if it is 0, pull-up is total, i.e. the pin is connected to VDD.
 * @PIN_CONFIG_DRIVE_OPEN_DRAIN: The pin will be driven with open drain (open
 *	collector) which means it is usually wired with other output ports
 *	which are then pulled up with an external resistor. Setting this
 *	config will enable open drain mode, the argument is ignored.
 * @PIN_CONFIG_DRIVE_OPEN_SOURCE: The pin will be driven with open source
 *	(open emitter). Setting this config will enable open source mode, the
 *	argument is ignored.
 * @PIN_CONFIG_DRIVE_PUSH_PULL: The pin will be driven actively high and
 *	low, this is the most typical case and is typically achieved with two
 *	active transistors on the output. Setting this config will enable
 *	push-pull mode, the argument is ignored.
 * @PIN_CONFIG_DRIVE_STRENGTH: The pin will sink or source at most the current
 *	passed as argument. The argument is in mA.
 * @PIN_CONFIG_DRIVE_STRENGTH_UA: The pin will sink or source at most the
 *	current passed as argument. The argument is in uA.
 * @PIN_CONFIG_INPUT_DEBOUNCE: This will configure the pin to debounce mode,
 *	which means it will wait for signals to settle when reading inputs. The
 *	argument gives the debounce time in usecs. Setting the
 *	argument to zero turns debouncing off.
 * @PIN_CONFIG_INPUT_ENABLE: Enable the pin's input.  Note that this does not
 *	affect the pin's ability to drive output.  1 enables input, 0 disables
 *	input.
 * @PIN_CONFIG_INPUT_SCHMITT: This will configure an input pin to run in
 *	schmitt-trigger mode. If the schmitt-trigger has adjustable hysteresis,
 *	the threshold value is given on a custom format as argument when
 *	setting pins to this mode.
 * @PIN_CONFIG_INPUT_SCHMITT_ENABLE: Control schmitt-trigger mode on the pin.
 *      If the argument != 0, schmitt-trigger mode is enabled. If it's 0,
 *      schmitt-trigger mode is disabled.
 * @PIN_CONFIG_LOW_POWER_MODE: This will configure the pin for low power
 *	operation, if several modes of operation are supported these can be
 *	passed in the argument on a custom form, else just use argument 1
 *	to indicate low power mode, argument 0 turns low power mode off.
 * @PIN_CONFIG_OUTPUT_ENABLE: This will enable the pin's output mode
 *	without driving a value there. For most platforms this reduces to
 *	enable the output buffers and then let the pin controller current
 *	configuration (eg. the currently selected mux function) drive values on
 *	the line. Use argument 1 to enable output mode, argument 0 to disable
 *	it.
 * @PIN_CONFIG_OUTPUT: This will configure the pin as an output and drive a
 *	value on the line. Use argument 1 to indicate high level, argument 0 to
 *	indicate low level. (Please see Documentation/driver-api/pinctl.rst,
 *	section "GPIO mode pitfalls" for a discussion around this parameter.)
 * @PIN_CONFIG_POWER_SOURCE: If the pin can select between different power
 *	supplies, the argument to this parameter (on a custom format) tells
 *	the driver which alternative power source to use.
 * @PIN_CONFIG_SLEEP_HARDWARE_STATE: Indicate this is sleep related state.
 * @PIN_CONFIG_SLEW_RATE: If the pin can select slew rate, the argument to
 *	this parameter (on a custom format) tells the driver which alternative
 *	slew rate to use.
 * @PIN_CONFIG_SKEW_DELAY: If the pin has programmable skew rate (on inputs)
 *	or latch delay (on outputs) this parameter (in a custom format)
 *	specifies the clock skew or latch delay. It typically controls how
 *	many double inverters are put in front of the line.
 * @PIN_CONFIG_END: This is the last enumerator for pin configurations, if
 *	you need to pass in custom configurations to the pin controller, use
 *	PIN_CONFIG_END+1 as the base offset.
 * @PIN_CONFIG_MAX: This is the maximum configuration value that can be
 *	presented using the packed format.
 */
enum pin_config_param {
	PIN_CONFIG_BIAS_BUS_HOLD = 0,
	PIN_CONFIG_BIAS_DISABLE = 1,
	PIN_CONFIG_BIAS_HIGH_IMPEDANCE = 2,
	PIN_CONFIG_BIAS_PULL_DOWN = 3,
	PIN_CONFIG_BIAS_PULL_PIN_DEFAULT = 4,
	PIN_CONFIG_BIAS_PULL_UP = 5,
	PIN_CONFIG_DRIVE_OPEN_DRAIN = 6,
	PIN_CONFIG_DRIVE_OPEN_SOURCE = 7,
	PIN_CONFIG_DRIVE_PUSH_PULL = 8,
	PIN_CONFIG_DRIVE_STRENGTH = 9,
	PIN_CONFIG_DRIVE_STRENGTH_UA = 10,
	PIN_CONFIG_INPUT_DEBOUNCE = 11,
	PIN_CONFIG_INPUT_ENABLE = 12,
	PIN_CONFIG_INPUT_SCHMITT = 13,
	PIN_CONFIG_INPUT_SCHMITT_ENABLE = 14,
	PIN_CONFIG_LOW_POWER_MODE = 15,
	PIN_CONFIG_OUTPUT_ENABLE = 16,
	PIN_CONFIG_OUTPUT = 17,
	PIN_CONFIG_POWER_SOURCE = 18,
	PIN_CONFIG_SLEEP_HARDWARE_STATE = 19,
	PIN_CONFIG_SLEW_RATE = 20,
	PIN_CONFIG_SKEW_DELAY = 21,
	PIN_CONFIG_END = 127,	/* 0x7F */
	PIN_CONFIG_MAX = 255, /* 0xFF */
};

#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.
 *
 * Return: 0 on success, or negative error code on failure
 */
int pinctrl_generic_set_state(struct udevice *pctldev, struct udevice *config);
#else
static inline int pinctrl_generic_set_state(struct udevice *pctldev,
					    struct udevice *config)
{
	return -ENOSYS;
}
#endif

#if CONFIG_IS_ENABLED(PINCTRL)
/**
 * pinctrl_select_state() - Set a device to a given state
 * @dev:	Peripheral device
 * @statename:	State name, like "default"
 *
 * Return: 0 on success, or negative error code on failure
 */
int pinctrl_select_state(struct udevice *dev, const char *statename);
#else
static inline int pinctrl_select_state(struct udevice *dev,
				       const char *statename)
{
	return -ENOSYS;
}
#endif

/**
 * pinctrl_request() - Request a particular pinctrl function
 * @dev:	Pinctrl device to use
 * @func:	Function number (driver-specific)
 * @flags:	Flags (driver-specific)
 *
 * 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.
 *
 * 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).
 *
 * 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
 * as with the 'gpio' command. This function is internal to the GPIO
 * subsystem and should not be used by generic code. Typically it is
 * used by a GPIO driver with knowledge of the SoC pinctrl setup.
 *
 * 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
 *
 * 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
 *
 * Return: Number of pins if OK, or -ENOSYS when not supported
 */
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:	Buffer to fill with the name of the pin
 * @size:	Size of @buf
 *
 * This allows to display the pin's name for debug purpose
 *
 * 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
 *
 * 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
 *
 * Return: 0 on success, or negative error code on failure
 */
int pinctrl_gpio_free(struct udevice *dev, unsigned offset);

#endif /* __PINCTRL_H */