2 * Machine interface for the pinctrl subsystem.
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
8 * Author: Linus Walleij <linus.walleij@linaro.org>
10 * License terms: GNU General Public License (GPL) version 2
12 #ifndef __LINUX_PINCTRL_MACHINE_H
13 #define __LINUX_PINCTRL_MACHINE_H
15 #include "pinctrl-state.h"
17 enum pinctrl_map_type {
19 PIN_MAP_TYPE_DUMMY_STATE,
20 PIN_MAP_TYPE_MUX_GROUP,
21 PIN_MAP_TYPE_CONFIGS_PIN,
22 PIN_MAP_TYPE_CONFIGS_GROUP,
26 * struct pinctrl_map_mux - mapping table content for MAP_TYPE_MUX_GROUP
27 * @group: the name of the group whose mux function is to be configured. This
28 * field may be left NULL, and the first applicable group for the function
30 * @function: the mux function to select for the group
32 struct pinctrl_map_mux {
38 * struct pinctrl_map_configs - mapping table content for MAP_TYPE_CONFIGS_*
39 * @group_or_pin: the name of the pin or group whose configuration parameters
40 * are to be configured.
41 * @configs: a pointer to an array of config parameters/values to program into
42 * hardware. Each individual pin controller defines the format and meaning
43 * of config parameters.
44 * @num_configs: the number of entries in array @configs
46 struct pinctrl_map_configs {
47 const char *group_or_pin;
48 unsigned long *configs;
53 * struct pinctrl_map - boards/machines shall provide this map for devices
54 * @dev_name: the name of the device using this specific mapping, the name
55 * must be the same as in your struct device*. If this name is set to the
56 * same name as the pin controllers own dev_name(), the map entry will be
57 * hogged by the driver itself upon registration
58 * @name: the name of this specific map entry for the particular machine.
59 * This is the parameter passed to pinmux_lookup_state()
60 * @type: the type of mapping table entry
61 * @ctrl_dev_name: the name of the device controlling this specific mapping,
62 * the name must be the same as in your struct device*. This field is not
63 * used for PIN_MAP_TYPE_DUMMY_STATE
64 * @data: Data specific to the mapping type
69 enum pinctrl_map_type type;
70 const char *ctrl_dev_name;
72 struct pinctrl_map_mux mux;
73 struct pinctrl_map_configs configs;
77 /* Convenience macros to create mapping table entries */
79 #define PIN_MAP_DUMMY_STATE(dev, state) \
83 .type = PIN_MAP_TYPE_DUMMY_STATE, \
86 #define PIN_MAP_MUX_GROUP(dev, state, pinctrl, grp, func) \
90 .type = PIN_MAP_TYPE_MUX_GROUP, \
91 .ctrl_dev_name = pinctrl, \
98 #define PIN_MAP_MUX_GROUP_DEFAULT(dev, pinctrl, grp, func) \
99 PIN_MAP_MUX_GROUP(dev, PINCTRL_STATE_DEFAULT, pinctrl, grp, func)
101 #define PIN_MAP_MUX_GROUP_HOG(dev, state, grp, func) \
102 PIN_MAP_MUX_GROUP(dev, state, dev, grp, func)
104 #define PIN_MAP_MUX_GROUP_HOG_DEFAULT(dev, grp, func) \
105 PIN_MAP_MUX_GROUP(dev, PINCTRL_STATE_DEFAULT, dev, grp, func)
107 #define PIN_MAP_CONFIGS_PIN(dev, state, pinctrl, pin, cfgs) \
111 .type = PIN_MAP_TYPE_CONFIGS_PIN, \
112 .ctrl_dev_name = pinctrl, \
114 .group_or_pin = pin, \
116 .num_configs = ARRAY_SIZE(cfgs), \
120 #define PIN_MAP_CONFIGS_PIN_DEFAULT(dev, pinctrl, pin, cfgs) \
121 PIN_MAP_CONFIGS_PIN(dev, PINCTRL_STATE_DEFAULT, pinctrl, pin, cfgs)
123 #define PIN_MAP_CONFIGS_PIN_HOG(dev, state, pin, cfgs) \
124 PIN_MAP_CONFIGS_PIN(dev, state, dev, pin, cfgs)
126 #define PIN_MAP_CONFIGS_PIN_HOG_DEFAULT(dev, pin, cfgs) \
127 PIN_MAP_CONFIGS_PIN(dev, PINCTRL_STATE_DEFAULT, dev, pin, cfgs)
129 #define PIN_MAP_CONFIGS_GROUP(dev, state, pinctrl, grp, cfgs) \
133 .type = PIN_MAP_TYPE_CONFIGS_GROUP, \
134 .ctrl_dev_name = pinctrl, \
136 .group_or_pin = grp, \
138 .num_configs = ARRAY_SIZE(cfgs), \
142 #define PIN_MAP_CONFIGS_GROUP_DEFAULT(dev, pinctrl, grp, cfgs) \
143 PIN_MAP_CONFIGS_GROUP(dev, PINCTRL_STATE_DEFAULT, pinctrl, grp, cfgs)
145 #define PIN_MAP_CONFIGS_GROUP_HOG(dev, state, grp, cfgs) \
146 PIN_MAP_CONFIGS_GROUP(dev, state, dev, grp, cfgs)
148 #define PIN_MAP_CONFIGS_GROUP_HOG_DEFAULT(dev, grp, cfgs) \
149 PIN_MAP_CONFIGS_GROUP(dev, PINCTRL_STATE_DEFAULT, dev, grp, cfgs)
153 extern int pinctrl_register_mappings(struct pinctrl_map const *map,
158 static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
164 #endif /* !CONFIG_PINMUX */