xref: /rk3399_rockchip-uboot/include/dm/pinctrl.h (revision 33f8d8a65e85191a1fdeeae37fda3fa465daa7e5)
1d90a5a30SMasahiro Yamada /*
2d90a5a30SMasahiro Yamada  * Copyright (C) 2015  Masahiro Yamada <yamada.masahiro@socionext.com>
3d90a5a30SMasahiro Yamada  *
4d90a5a30SMasahiro Yamada  * SPDX-License-Identifier:	GPL-2.0+
5d90a5a30SMasahiro Yamada  */
6d90a5a30SMasahiro Yamada 
7d90a5a30SMasahiro Yamada #ifndef __PINCTRL_H
8d90a5a30SMasahiro Yamada #define __PINCTRL_H
9d90a5a30SMasahiro Yamada 
10d90a5a30SMasahiro Yamada /**
11d90a5a30SMasahiro Yamada  * struct pinconf_param - pin config parameters
12d90a5a30SMasahiro Yamada  *
13d90a5a30SMasahiro Yamada  * @property: property name in DT nodes
14d90a5a30SMasahiro Yamada  * @param: ID for this config parameter
15d90a5a30SMasahiro Yamada  * @default_value: default value for this config parameter used in case
16d90a5a30SMasahiro Yamada  *	no value is specified in DT nodes
17d90a5a30SMasahiro Yamada  */
18d90a5a30SMasahiro Yamada struct pinconf_param {
19d90a5a30SMasahiro Yamada 	const char * const property;
20d90a5a30SMasahiro Yamada 	unsigned int param;
21d90a5a30SMasahiro Yamada 	u32 default_value;
22d90a5a30SMasahiro Yamada };
23d90a5a30SMasahiro Yamada 
24d90a5a30SMasahiro Yamada /**
25d90a5a30SMasahiro Yamada  * struct pinctrl_ops - pin control operations, to be implemented by
26d90a5a30SMasahiro Yamada  * pin controller drivers.
27d90a5a30SMasahiro Yamada  *
28d90a5a30SMasahiro Yamada  * The @set_state is the only mandatory operation.  You can implement your
29d90a5a30SMasahiro Yamada  * pinctrl driver with its own @set_state.  In this case, the other callbacks
30d90a5a30SMasahiro Yamada  * are not required.  Otherwise, generic pinctrl framework is also available;
31d90a5a30SMasahiro Yamada  * use pinctrl_generic_set_state for @set_state, and implement other operations
32d90a5a30SMasahiro Yamada  * depending on your necessity.
33d90a5a30SMasahiro Yamada  *
34d90a5a30SMasahiro Yamada  * @get_pins_count: return number of selectable named pins available
35d90a5a30SMasahiro Yamada  *	in this driver.  (necessary to parse "pins" property in DTS)
36d90a5a30SMasahiro Yamada  * @get_pin_name: return the pin name of the pin selector,
37d90a5a30SMasahiro Yamada  *	called by the core to figure out which pin it shall do
38d90a5a30SMasahiro Yamada  *	operations to.  (necessary to parse "pins" property in DTS)
39d90a5a30SMasahiro Yamada  * @get_groups_count: return number of selectable named groups available
40d90a5a30SMasahiro Yamada  *	in this driver.  (necessary to parse "groups" property in DTS)
41d90a5a30SMasahiro Yamada  * @get_group_name: return the group name of the group selector,
42d90a5a30SMasahiro Yamada  *	called by the core to figure out which pin group it shall do
43d90a5a30SMasahiro Yamada  *	operations to.  (necessary to parse "groups" property in DTS)
44d90a5a30SMasahiro Yamada  * @get_functions_count: return number of selectable named functions available
45d90a5a30SMasahiro Yamada  *	in this driver.  (necessary for pin-muxing)
46d90a5a30SMasahiro Yamada  * @get_function_name: return the function name of the muxing selector,
47d90a5a30SMasahiro Yamada  *	called by the core to figure out which mux setting it shall map a
48d90a5a30SMasahiro Yamada  *	certain device to.  (necessary for pin-muxing)
49d90a5a30SMasahiro Yamada  * @pinmux_set: enable a certain muxing function with a certain pin.
50d90a5a30SMasahiro Yamada  *	The @func_selector selects a certain function whereas @pin_selector
51d90a5a30SMasahiro Yamada  *	selects a certain pin to be used. On simple controllers one of them
52d90a5a30SMasahiro Yamada  *	may be ignored.  (necessary for pin-muxing against a single pin)
53d90a5a30SMasahiro Yamada  * @pinmux_group_set: enable a certain muxing function with a certain pin
54d90a5a30SMasahiro Yamada  *	group.  The @func_selector selects a certain function whereas
55d90a5a30SMasahiro Yamada  *	@group_selector selects a certain set of pins to be used. On simple
56d90a5a30SMasahiro Yamada  *	controllers one of them may be ignored.
57d90a5a30SMasahiro Yamada  *	(necessary for pin-muxing against a pin group)
58d90a5a30SMasahiro Yamada  * @pinconf_num_params: number of driver-specific parameters to be parsed
59d90a5a30SMasahiro Yamada  *	from device trees  (necessary for pin-configuration)
60d90a5a30SMasahiro Yamada  * @pinconf_params: list of driver_specific parameters to be parsed from
61d90a5a30SMasahiro Yamada  *	device trees  (necessary for pin-configuration)
62d90a5a30SMasahiro Yamada  * @pinconf_set: configure an individual pin with a given parameter.
63d90a5a30SMasahiro Yamada  *	(necessary for pin-configuration against a single pin)
64d90a5a30SMasahiro Yamada  * @pinconf_group_set: configure all pins in a group with a given parameter.
65d90a5a30SMasahiro Yamada  *	(necessary for pin-configuration against a pin group)
66d90a5a30SMasahiro Yamada  * @set_state: do pinctrl operations specified by @config, a pseudo device
67d90a5a30SMasahiro Yamada  *	pointing a config node. (necessary for pinctrl_full)
68d90a5a30SMasahiro Yamada  * @set_state_simple: do needed pinctrl operations for a peripherl @periph.
69d90a5a30SMasahiro Yamada  *	(necessary for pinctrl_simple)
70d90a5a30SMasahiro Yamada  */
71d90a5a30SMasahiro Yamada struct pinctrl_ops {
72d90a5a30SMasahiro Yamada 	int (*get_pins_count)(struct udevice *dev);
73d90a5a30SMasahiro Yamada 	const char *(*get_pin_name)(struct udevice *dev, unsigned selector);
74d90a5a30SMasahiro Yamada 	int (*get_groups_count)(struct udevice *dev);
75d90a5a30SMasahiro Yamada 	const char *(*get_group_name)(struct udevice *dev, unsigned selector);
76d90a5a30SMasahiro Yamada 	int (*get_functions_count)(struct udevice *dev);
77d90a5a30SMasahiro Yamada 	const char *(*get_function_name)(struct udevice *dev,
78d90a5a30SMasahiro Yamada 					 unsigned selector);
79d90a5a30SMasahiro Yamada 	int (*pinmux_set)(struct udevice *dev, unsigned pin_selector,
80d90a5a30SMasahiro Yamada 			  unsigned func_selector);
81d90a5a30SMasahiro Yamada 	int (*pinmux_group_set)(struct udevice *dev, unsigned group_selector,
82d90a5a30SMasahiro Yamada 				unsigned func_selector);
83d90a5a30SMasahiro Yamada 	unsigned int pinconf_num_params;
84d90a5a30SMasahiro Yamada 	const struct pinconf_param *pinconf_params;
85d90a5a30SMasahiro Yamada 	int (*pinconf_set)(struct udevice *dev, unsigned pin_selector,
86d90a5a30SMasahiro Yamada 			   unsigned param, unsigned argument);
87d90a5a30SMasahiro Yamada 	int (*pinconf_group_set)(struct udevice *dev, unsigned group_selector,
88d90a5a30SMasahiro Yamada 				 unsigned param, unsigned argument);
89d90a5a30SMasahiro Yamada 	int (*set_state)(struct udevice *dev, struct udevice *config);
90c5acf4a2SSimon Glass 
91c5acf4a2SSimon Glass 	/* for pinctrl-simple */
92d90a5a30SMasahiro Yamada 	int (*set_state_simple)(struct udevice *dev, struct udevice *periph);
93c5acf4a2SSimon Glass 	/**
94c5acf4a2SSimon Glass 	 * request() - Request a particular pinctrl function
95c5acf4a2SSimon Glass 	 *
96c5acf4a2SSimon Glass 	 * This activates the selected function.
97c5acf4a2SSimon Glass 	 *
98c5acf4a2SSimon Glass 	 * @dev:	Device to adjust (UCLASS_PINCTRL)
99c5acf4a2SSimon Glass 	 * @func:	Function number (driver-specific)
100c5acf4a2SSimon Glass 	 * @return 0 if OK, -ve on error
101c5acf4a2SSimon Glass 	 */
102c5acf4a2SSimon Glass 	int (*request)(struct udevice *dev, int func, int flags);
103c5acf4a2SSimon Glass 
104c5acf4a2SSimon Glass 	/**
105c5acf4a2SSimon Glass 	* get_periph_id() - get the peripheral ID for a device
106c5acf4a2SSimon Glass 	*
107c5acf4a2SSimon Glass 	* This generally looks at the peripheral's device tree node to work
108c5acf4a2SSimon Glass 	* out the peripheral ID. The return value is normally interpreted as
109c5acf4a2SSimon Glass 	* enum periph_id. so long as this is defined by the platform (which it
110c5acf4a2SSimon Glass 	* should be).
111c5acf4a2SSimon Glass 	*
112c5acf4a2SSimon Glass 	* @dev:		Pinctrl device to use for decoding
113c5acf4a2SSimon Glass 	* @periph:	Device to check
114c5acf4a2SSimon Glass 	* @return peripheral ID of @periph, or -ENOENT on error
115c5acf4a2SSimon Glass 	*/
116c5acf4a2SSimon Glass 	int (*get_periph_id)(struct udevice *dev, struct udevice *periph);
11777eaa19eSSimon Glass 
11877eaa19eSSimon Glass 	/**
11977eaa19eSSimon Glass 	 * get_gpio_mux() - get the mux value for a particular GPIO
12077eaa19eSSimon Glass 	 *
12177eaa19eSSimon Glass 	 * This allows the raw mux value for a GPIO to be obtained. It is
12277eaa19eSSimon Glass 	 * useful for displaying the function being used by that GPIO, such
12377eaa19eSSimon Glass 	 * as with the 'gpio' command. This function is internal to the GPIO
12477eaa19eSSimon Glass 	 * subsystem and should not be used by generic code. Typically it is
12577eaa19eSSimon Glass 	 * used by a GPIO driver with knowledge of the SoC pinctrl setup.
12677eaa19eSSimon Glass 	 *
12777eaa19eSSimon Glass 	* @dev:		Pinctrl device to use
12877eaa19eSSimon Glass 	* @banknum:	GPIO bank number
12977eaa19eSSimon Glass 	* @index:	GPIO index within the bank
13077eaa19eSSimon Glass 	* @return mux value (SoC-specific, e.g. 0 for input, 1 for output)
13177eaa19eSSimon Glass 	 */
13277eaa19eSSimon Glass 	int (*get_gpio_mux)(struct udevice *dev, int banknum, int index);
133d90a5a30SMasahiro Yamada };
134d90a5a30SMasahiro Yamada 
135d90a5a30SMasahiro Yamada #define pinctrl_get_ops(dev)	((struct pinctrl_ops *)(dev)->driver->ops)
136d90a5a30SMasahiro Yamada 
137d90a5a30SMasahiro Yamada /**
138d90a5a30SMasahiro Yamada  * Generic pin configuration paramters
139d90a5a30SMasahiro Yamada  *
140d90a5a30SMasahiro Yamada  * @PIN_CONFIG_BIAS_DISABLE: disable any pin bias on the pin, a
141d90a5a30SMasahiro Yamada  *	transition from say pull-up to pull-down implies that you disable
142d90a5a30SMasahiro Yamada  *	pull-up in the process, this setting disables all biasing.
143d90a5a30SMasahiro Yamada  * @PIN_CONFIG_BIAS_HIGH_IMPEDANCE: the pin will be set to a high impedance
144d90a5a30SMasahiro Yamada  *	mode, also know as "third-state" (tristate) or "high-Z" or "floating".
145d90a5a30SMasahiro Yamada  *	On output pins this effectively disconnects the pin, which is useful
146d90a5a30SMasahiro Yamada  *	if for example some other pin is going to drive the signal connected
147d90a5a30SMasahiro Yamada  *	to it for a while. Pins used for input are usually always high
148d90a5a30SMasahiro Yamada  *	impedance.
149d90a5a30SMasahiro Yamada  * @PIN_CONFIG_BIAS_BUS_HOLD: the pin will be set to weakly latch so that it
150d90a5a30SMasahiro Yamada  *	weakly drives the last value on a tristate bus, also known as a "bus
151d90a5a30SMasahiro Yamada  *	holder", "bus keeper" or "repeater". This allows another device on the
152d90a5a30SMasahiro Yamada  *	bus to change the value by driving the bus high or low and switching to
153d90a5a30SMasahiro Yamada  *	tristate. The argument is ignored.
154d90a5a30SMasahiro Yamada  * @PIN_CONFIG_BIAS_PULL_UP: the pin will be pulled up (usually with high
155d90a5a30SMasahiro Yamada  *	impedance to VDD). If the argument is != 0 pull-up is enabled,
156d90a5a30SMasahiro Yamada  *	if it is 0, pull-up is total, i.e. the pin is connected to VDD.
157d90a5a30SMasahiro Yamada  * @PIN_CONFIG_BIAS_PULL_DOWN: the pin will be pulled down (usually with high
158d90a5a30SMasahiro Yamada  *	impedance to GROUND). If the argument is != 0 pull-down is enabled,
159d90a5a30SMasahiro Yamada  *	if it is 0, pull-down is total, i.e. the pin is connected to GROUND.
160d90a5a30SMasahiro Yamada  * @PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: the pin will be pulled up or down based
161d90a5a30SMasahiro Yamada  *	on embedded knowledge of the controller hardware, like current mux
162d90a5a30SMasahiro Yamada  *	function. The pull direction and possibly strength too will normally
163d90a5a30SMasahiro Yamada  *	be decided completely inside the hardware block and not be readable
164d90a5a30SMasahiro Yamada  *	from the kernel side.
165d90a5a30SMasahiro Yamada  *	If the argument is != 0 pull up/down is enabled, if it is 0, the
166d90a5a30SMasahiro Yamada  *	configuration is ignored. The proper way to disable it is to use
167d90a5a30SMasahiro Yamada  *	@PIN_CONFIG_BIAS_DISABLE.
168d90a5a30SMasahiro Yamada  * @PIN_CONFIG_DRIVE_PUSH_PULL: the pin will be driven actively high and
169d90a5a30SMasahiro Yamada  *	low, this is the most typical case and is typically achieved with two
170d90a5a30SMasahiro Yamada  *	active transistors on the output. Setting this config will enable
171d90a5a30SMasahiro Yamada  *	push-pull mode, the argument is ignored.
172d90a5a30SMasahiro Yamada  * @PIN_CONFIG_DRIVE_OPEN_DRAIN: the pin will be driven with open drain (open
173d90a5a30SMasahiro Yamada  *	collector) which means it is usually wired with other output ports
174d90a5a30SMasahiro Yamada  *	which are then pulled up with an external resistor. Setting this
175d90a5a30SMasahiro Yamada  *	config will enable open drain mode, the argument is ignored.
176d90a5a30SMasahiro Yamada  * @PIN_CONFIG_DRIVE_OPEN_SOURCE: the pin will be driven with open source
177d90a5a30SMasahiro Yamada  *	(open emitter). Setting this config will enable open source mode, the
178d90a5a30SMasahiro Yamada  *	argument is ignored.
179d90a5a30SMasahiro Yamada  * @PIN_CONFIG_DRIVE_STRENGTH: the pin will sink or source at most the current
180d90a5a30SMasahiro Yamada  *	passed as argument. The argument is in mA.
181d90a5a30SMasahiro Yamada  * @PIN_CONFIG_INPUT_ENABLE: enable the pin's input.  Note that this does not
182d90a5a30SMasahiro Yamada  *	affect the pin's ability to drive output.  1 enables input, 0 disables
183d90a5a30SMasahiro Yamada  *	input.
184d90a5a30SMasahiro Yamada  * @PIN_CONFIG_INPUT_SCHMITT_ENABLE: control schmitt-trigger mode on the pin.
185d90a5a30SMasahiro Yamada  *      If the argument != 0, schmitt-trigger mode is enabled. If it's 0,
186d90a5a30SMasahiro Yamada  *      schmitt-trigger mode is disabled.
187d90a5a30SMasahiro Yamada  * @PIN_CONFIG_INPUT_SCHMITT: this will configure an input pin to run in
188d90a5a30SMasahiro Yamada  *	schmitt-trigger mode. If the schmitt-trigger has adjustable hysteresis,
189d90a5a30SMasahiro Yamada  *	the threshold value is given on a custom format as argument when
190d90a5a30SMasahiro Yamada  *	setting pins to this mode.
191d90a5a30SMasahiro Yamada  * @PIN_CONFIG_INPUT_DEBOUNCE: this will configure the pin to debounce mode,
192d90a5a30SMasahiro Yamada  *	which means it will wait for signals to settle when reading inputs. The
193d90a5a30SMasahiro Yamada  *	argument gives the debounce time in usecs. Setting the
194d90a5a30SMasahiro Yamada  *	argument to zero turns debouncing off.
195d90a5a30SMasahiro Yamada  * @PIN_CONFIG_POWER_SOURCE: if the pin can select between different power
196d90a5a30SMasahiro Yamada  *	supplies, the argument to this parameter (on a custom format) tells
197d90a5a30SMasahiro Yamada  *	the driver which alternative power source to use.
198d90a5a30SMasahiro Yamada  * @PIN_CONFIG_SLEW_RATE: if the pin can select slew rate, the argument to
199d90a5a30SMasahiro Yamada  *	this parameter (on a custom format) tells the driver which alternative
200d90a5a30SMasahiro Yamada  *	slew rate to use.
201d90a5a30SMasahiro Yamada  * @PIN_CONFIG_LOW_POWER_MODE: this will configure the pin for low power
202d90a5a30SMasahiro Yamada  *	operation, if several modes of operation are supported these can be
203d90a5a30SMasahiro Yamada  *	passed in the argument on a custom form, else just use argument 1
204d90a5a30SMasahiro Yamada  *	to indicate low power mode, argument 0 turns low power mode off.
205d90a5a30SMasahiro Yamada  * @PIN_CONFIG_OUTPUT: this will configure the pin as an output. Use argument
206d90a5a30SMasahiro Yamada  *	1 to indicate high level, argument 0 to indicate low level. (Please
207d90a5a30SMasahiro Yamada  *	see Documentation/pinctrl.txt, section "GPIO mode pitfalls" for a
208d90a5a30SMasahiro Yamada  *	discussion around this parameter.)
209d90a5a30SMasahiro Yamada  * @PIN_CONFIG_END: this is the last enumerator for pin configurations, if
210d90a5a30SMasahiro Yamada  *	you need to pass in custom configurations to the pin controller, use
211d90a5a30SMasahiro Yamada  *	PIN_CONFIG_END+1 as the base offset.
212d90a5a30SMasahiro Yamada  */
213d90a5a30SMasahiro Yamada #define PIN_CONFIG_BIAS_DISABLE			0
214d90a5a30SMasahiro Yamada #define PIN_CONFIG_BIAS_HIGH_IMPEDANCE		1
215d90a5a30SMasahiro Yamada #define PIN_CONFIG_BIAS_BUS_HOLD		2
216d90a5a30SMasahiro Yamada #define PIN_CONFIG_BIAS_PULL_UP			3
217d90a5a30SMasahiro Yamada #define PIN_CONFIG_BIAS_PULL_DOWN		4
218d90a5a30SMasahiro Yamada #define PIN_CONFIG_BIAS_PULL_PIN_DEFAULT	5
219d90a5a30SMasahiro Yamada #define PIN_CONFIG_DRIVE_PUSH_PULL		6
220d90a5a30SMasahiro Yamada #define PIN_CONFIG_DRIVE_OPEN_DRAIN		7
221d90a5a30SMasahiro Yamada #define PIN_CONFIG_DRIVE_OPEN_SOURCE		8
222d90a5a30SMasahiro Yamada #define PIN_CONFIG_DRIVE_STRENGTH		9
223d90a5a30SMasahiro Yamada #define PIN_CONFIG_INPUT_ENABLE			10
224d90a5a30SMasahiro Yamada #define PIN_CONFIG_INPUT_SCHMITT_ENABLE		11
225d90a5a30SMasahiro Yamada #define PIN_CONFIG_INPUT_SCHMITT		12
226d90a5a30SMasahiro Yamada #define PIN_CONFIG_INPUT_DEBOUNCE		13
227d90a5a30SMasahiro Yamada #define PIN_CONFIG_POWER_SOURCE			14
228d90a5a30SMasahiro Yamada #define PIN_CONFIG_SLEW_RATE			15
229d90a5a30SMasahiro Yamada #define PIN_CONFIG_LOW_POWER_MODE		16
230d90a5a30SMasahiro Yamada #define PIN_CONFIG_OUTPUT			17
231d90a5a30SMasahiro Yamada #define PIN_CONFIG_END				0x7FFF
232d90a5a30SMasahiro Yamada 
233d90a5a30SMasahiro Yamada #if CONFIG_IS_ENABLED(PINCTRL_GENERIC)
234d90a5a30SMasahiro Yamada /**
235d90a5a30SMasahiro Yamada  * pinctrl_generic_set_state() - generic set_state operation
236d90a5a30SMasahiro Yamada  * Parse the DT node of @config and its children and handle generic properties
237d90a5a30SMasahiro Yamada  * such as "pins", "groups", "functions", and pin configuration parameters.
238d90a5a30SMasahiro Yamada  *
239d90a5a30SMasahiro Yamada  * @pctldev: pinctrl device
240d90a5a30SMasahiro Yamada  * @config: config device (pseudo device), pointing a config node in DTS
241d90a5a30SMasahiro Yamada  * @return: 0 on success, or negative error code on failure
242d90a5a30SMasahiro Yamada  */
243d90a5a30SMasahiro Yamada int pinctrl_generic_set_state(struct udevice *pctldev, struct udevice *config);
244d90a5a30SMasahiro Yamada #else
245d90a5a30SMasahiro Yamada static inline int pinctrl_generic_set_state(struct udevice *pctldev,
246d90a5a30SMasahiro Yamada 					    struct udevice *config)
247d90a5a30SMasahiro Yamada {
248d90a5a30SMasahiro Yamada 	return -EINVAL;
249d90a5a30SMasahiro Yamada }
250d90a5a30SMasahiro Yamada #endif
251d90a5a30SMasahiro Yamada 
252d90a5a30SMasahiro Yamada #if CONFIG_IS_ENABLED(PINCTRL)
253d90a5a30SMasahiro Yamada /**
254d90a5a30SMasahiro Yamada  * pinctrl_select_state() - set a device to a given state
255d90a5a30SMasahiro Yamada  *
256d90a5a30SMasahiro Yamada  * @dev: peripheral device
257d90a5a30SMasahiro Yamada  * @statename: state name, like "default"
258d90a5a30SMasahiro Yamada  * @return: 0 on success, or negative error code on failure
259d90a5a30SMasahiro Yamada  */
260d90a5a30SMasahiro Yamada int pinctrl_select_state(struct udevice *dev, const char *statename);
261d90a5a30SMasahiro Yamada #else
262d90a5a30SMasahiro Yamada static inline int pinctrl_select_state(struct udevice *dev,
263d90a5a30SMasahiro Yamada 				       const char *statename)
264d90a5a30SMasahiro Yamada {
265d90a5a30SMasahiro Yamada 	return -EINVAL;
266d90a5a30SMasahiro Yamada }
267d90a5a30SMasahiro Yamada #endif
268d90a5a30SMasahiro Yamada 
269c5acf4a2SSimon Glass /**
270c5acf4a2SSimon Glass  * pinctrl_request() - Request a particular pinctrl function
271c5acf4a2SSimon Glass  *
272c5acf4a2SSimon Glass  * @dev:	Device to check (UCLASS_PINCTRL)
273c5acf4a2SSimon Glass  * @func:	Function number (driver-specific)
274c5acf4a2SSimon Glass  * @flags:	Flags (driver-specific)
275c5acf4a2SSimon Glass  * @return 0 if OK, -ve on error
276c5acf4a2SSimon Glass  */
277c5acf4a2SSimon Glass int pinctrl_request(struct udevice *dev, int func, int flags);
278c5acf4a2SSimon Glass 
279c5acf4a2SSimon Glass /**
280c5acf4a2SSimon Glass  * pinctrl_request_noflags() - Request a particular pinctrl function
281c5acf4a2SSimon Glass  *
282c5acf4a2SSimon Glass  * This is similar to pinctrl_request() but uses 0 for @flags.
283c5acf4a2SSimon Glass  *
284c5acf4a2SSimon Glass  * @dev:	Device to check (UCLASS_PINCTRL)
285c5acf4a2SSimon Glass  * @func:	Function number (driver-specific)
286c5acf4a2SSimon Glass  * @return 0 if OK, -ve on error
287c5acf4a2SSimon Glass  */
288c5acf4a2SSimon Glass int pinctrl_request_noflags(struct udevice *dev, int func);
289c5acf4a2SSimon Glass 
290c5acf4a2SSimon Glass /**
291c5acf4a2SSimon Glass  * pinctrl_get_periph_id() - get the peripheral ID for a device
292c5acf4a2SSimon Glass  *
293c5acf4a2SSimon Glass  * This generally looks at the peripheral's device tree node to work out the
294c5acf4a2SSimon Glass  * peripheral ID. The return value is normally interpreted as enum periph_id.
295c5acf4a2SSimon Glass  * so long as this is defined by the platform (which it should be).
296c5acf4a2SSimon Glass  *
297c5acf4a2SSimon Glass  * @dev:	Pinctrl device to use for decoding
298c5acf4a2SSimon Glass  * @periph:	Device to check
299c5acf4a2SSimon Glass  * @return peripheral ID of @periph, or -ENOENT on error
300c5acf4a2SSimon Glass  */
301c5acf4a2SSimon Glass int pinctrl_get_periph_id(struct udevice *dev, struct udevice *periph);
302c5acf4a2SSimon Glass 
30352db39a2SSimon Glass /**
30452db39a2SSimon Glass  * pinctrl_decode_pin_config() - decode pin configuration flags
30552db39a2SSimon Glass  *
30652db39a2SSimon Glass  * This decodes some of the PIN_CONFIG values into flags, with each value
30752db39a2SSimon Glass  * being (1 << pin_cfg). This does not support things with values like the
30852db39a2SSimon Glass  * slew rate.
30952db39a2SSimon Glass  *
31052db39a2SSimon Glass  * @blob:	Device tree blob
31152db39a2SSimon Glass  * @node:	Node containing the PIN_CONFIG values
31252db39a2SSimon Glass  * @return decoded flag value, or -ve on error
31352db39a2SSimon Glass  */
31452db39a2SSimon Glass int pinctrl_decode_pin_config(const void *blob, int node);
31552db39a2SSimon Glass 
31677eaa19eSSimon Glass /**
31777eaa19eSSimon Glass  * pinctrl_get_gpio_mux() - get the mux value for a particular GPIO
31877eaa19eSSimon Glass  *
31977eaa19eSSimon Glass  * This allows the raw mux value for a GPIO to be obtained. It is
32077eaa19eSSimon Glass  * useful for displaying the function being used by that GPIO, such
32177eaa19eSSimon Glass  * as with the 'gpio' command. This function is internal to the GPIO
32277eaa19eSSimon Glass  * subsystem and should not be used by generic code. Typically it is
32377eaa19eSSimon Glass  * used by a GPIO driver with knowledge of the SoC pinctrl setup.
32477eaa19eSSimon Glass  *
32577eaa19eSSimon Glass  * @dev:	Pinctrl device to use
32677eaa19eSSimon Glass  * @banknum:	GPIO bank number
32777eaa19eSSimon Glass  * @index:	GPIO index within the bank
32877eaa19eSSimon Glass  * @return mux value (SoC-specific, e.g. 0 for input, 1 for output)
32977eaa19eSSimon Glass */
33077eaa19eSSimon Glass int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index);
33177eaa19eSSimon Glass 
332*33f8d8a6SJianqun Xu /**
333*33f8d8a6SJianqun Xu  * pinctrl_get_pins_count() - get the total pins count for all GPIOs
334*33f8d8a6SJianqun Xu  *
335*33f8d8a6SJianqun Xu  * This allows the total pins count for all GPIO to be obtained.
336*33f8d8a6SJianqun Xu  *
337*33f8d8a6SJianqun Xu  * @dev:	Pinctrl device to use
338*33f8d8a6SJianqun Xu  * @return pins count
339*33f8d8a6SJianqun Xu */
340*33f8d8a6SJianqun Xu int pinctrl_get_pins_count(struct udevice *dev);
341*33f8d8a6SJianqun Xu 
342d90a5a30SMasahiro Yamada #endif /* __PINCTRL_H */
343