xref: /linux-6.15/include/linux/pinctrl/machine.h (revision 6e5e959d)
1 /*
2  * Machine interface for the pinctrl subsystem.
3  *
4  * Copyright (C) 2011 ST-Ericsson SA
5  * Written on behalf of Linaro for ST-Ericsson
6  * Based on bits of regulator core, gpio core and clk core
7  *
8  * Author: Linus Walleij <[email protected]>
9  *
10  * License terms: GNU General Public License (GPL) version 2
11  */
12 #ifndef __LINUX_PINCTRL_MACHINE_H
13 #define __LINUX_PINCTRL_MACHINE_H
14 
15 #include "pinctrl.h"
16 
17 /**
18  * struct pinctrl_map - boards/machines shall provide this map for devices
19  * @dev_name: the name of the device using this specific mapping, the name
20  *	must be the same as in your struct device*. If this name is set to the
21  *	same name as the pin controllers own dev_name(), the map entry will be
22  *	hogged by the driver itself upon registration
23  * @name: the name of this specific map entry for the particular machine.
24  *	This is the parameter passed to pinmux_lookup_state()
25  * @ctrl_dev_name: the name of the device controlling this specific mapping,
26  *	the name must be the same as in your struct device*
27  * @group: sometimes a function can map to different pin groups, so this
28  *	selects a certain specific pin group to activate for the function, if
29  *	left as NULL, the first applicable group will be used
30  * @function: a function in the driver to use for this mapping, the driver
31  *	will lookup the function referenced by this ID on the specified
32  *	pin control device
33  */
34 struct pinctrl_map {
35 	const char *dev_name;
36 	const char *name;
37 	const char *ctrl_dev_name;
38 	const char *group;
39 	const char *function;
40 };
41 
42 /*
43  * Convenience macro to set a simple map from a certain pin controller and a
44  * certain function to a named device
45  */
46 #define PIN_MAP(a, b, c, d) \
47 	{ .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d }
48 
49 /*
50  * Convenience macro to map a system function onto a certain pinctrl device,
51  * to be hogged by the pin control core until the system shuts down.
52  */
53 #define PIN_MAP_SYS_HOG(a, b) \
54 	{ .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = a, .dev_name = a, \
55 	  .function = b, }
56 
57 /*
58  * Convenience macro to map a system function onto a certain pinctrl device
59  * using a specified group, to be hogged by the pin control core until the
60  * system shuts down.
61  */
62 #define PIN_MAP_SYS_HOG_GROUP(a, b, c) \
63 	{ .name = PINCTRL_STATE_DEFAULT, .ctrl_dev_name = a, .dev_name = a, \
64 	  .function = b, .group = c, }
65 
66 #ifdef CONFIG_PINMUX
67 
68 extern int pinctrl_register_mappings(struct pinctrl_map const *map,
69 				unsigned num_maps);
70 
71 #else
72 
73 static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
74 					   unsigned num_maps)
75 {
76 	return 0;
77 }
78 
79 #endif /* !CONFIG_PINMUX */
80 #endif
81