]> Pileus Git - ~andy/linux/blob - include/linux/pinctrl/machine.h
pinctrl: changes hog mechanism to be self-referential
[~andy/linux] / include / linux / pinctrl / machine.h
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 <linus.walleij@linaro.org>
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 /**
16  * struct pinctrl_map - boards/machines shall provide this map for devices
17  * @name: the name of this specific map entry for the particular machine.
18  *      This is the second parameter passed to pinmux_get() when you want
19  *      to have several mappings to the same device
20  * @ctrl_dev_name: the name of the device controlling this specific mapping,
21  *      the name must be the same as in your struct device*
22  * @function: a function in the driver to use for this mapping, the driver
23  *      will lookup the function referenced by this ID on the specified
24  *      pin control device
25  * @group: sometimes a function can map to different pin groups, so this
26  *      selects a certain specific pin group to activate for the function, if
27  *      left as NULL, the first applicable group will be used
28  * @dev_name: the name of the device using this specific mapping, the name
29  *      must be the same as in your struct device*. If this name is set to the
30  *      same name as the pin controllers own dev_name(), the map entry will be
31  *      hogged by the driver itself upon registration
32  */
33 struct pinctrl_map {
34         const char *name;
35         const char *ctrl_dev_name;
36         const char *function;
37         const char *group;
38         const char *dev_name;
39 };
40
41 /*
42  * Convenience macro to set a simple map from a certain pin controller and a
43  * certain function to a named device
44  */
45 #define PIN_MAP(a, b, c, d) \
46         { .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d }
47
48 /*
49  * Convenience macro to map a system function onto a certain pinctrl device.
50  * System functions are not assigned to a particular device.
51  */
52 #define PIN_MAP_SYS(a, b, c) \
53         { .name = a, .ctrl_dev_name = b, .function = c }
54
55 /*
56  * Convenience macro to map a system function onto a certain pinctrl device,
57  * to be hogged by the pin control core until the system shuts down.
58  */
59 #define PIN_MAP_SYS_HOG(a, b, c) \
60         { .name = a, .ctrl_dev_name = b, .dev_name = b, .function = c, }
61
62 /*
63  * Convenience macro to map a system function onto a certain pinctrl device
64  * using a specified group, to be hogged by the pin control core until the
65  * system shuts down.
66  */
67 #define PIN_MAP_SYS_HOG_GROUP(a, b, c, d)               \
68         { .name = a, .ctrl_dev_name = b, .dev_name = b, .function = c, \
69           .group = d, }
70
71 #ifdef CONFIG_PINMUX
72
73 extern int pinctrl_register_mappings(struct pinctrl_map const *map,
74                                 unsigned num_maps);
75
76 #else
77
78 static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
79                                            unsigned num_maps)
80 {
81         return 0;
82 }
83
84 #endif /* !CONFIG_PINMUX */
85 #endif