Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
machine.h
Go to the documentation of this file.
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 <linux/bug.h>
16 
18 
25 };
26 
35  const char *group;
36  const char *function;
37 };
38 
49  const char *group_or_pin;
50  unsigned long *configs;
51  unsigned num_configs;
52 };
53 
68 struct pinctrl_map {
69  const char *dev_name;
70  const char *name;
72  const char *ctrl_dev_name;
73  union {
76  } data;
77 };
78 
79 /* Convenience macros to create mapping table entries */
80 
81 #define PIN_MAP_DUMMY_STATE(dev, state) \
82  { \
83  .dev_name = dev, \
84  .name = state, \
85  .type = PIN_MAP_TYPE_DUMMY_STATE, \
86  }
87 
88 #define PIN_MAP_MUX_GROUP(dev, state, pinctrl, grp, func) \
89  { \
90  .dev_name = dev, \
91  .name = state, \
92  .type = PIN_MAP_TYPE_MUX_GROUP, \
93  .ctrl_dev_name = pinctrl, \
94  .data.mux = { \
95  .group = grp, \
96  .function = func, \
97  }, \
98  }
99 
100 #define PIN_MAP_MUX_GROUP_DEFAULT(dev, pinctrl, grp, func) \
101  PIN_MAP_MUX_GROUP(dev, PINCTRL_STATE_DEFAULT, pinctrl, grp, func)
102 
103 #define PIN_MAP_MUX_GROUP_HOG(dev, state, grp, func) \
104  PIN_MAP_MUX_GROUP(dev, state, dev, grp, func)
105 
106 #define PIN_MAP_MUX_GROUP_HOG_DEFAULT(dev, grp, func) \
107  PIN_MAP_MUX_GROUP(dev, PINCTRL_STATE_DEFAULT, dev, grp, func)
108 
109 #define PIN_MAP_CONFIGS_PIN(dev, state, pinctrl, pin, cfgs) \
110  { \
111  .dev_name = dev, \
112  .name = state, \
113  .type = PIN_MAP_TYPE_CONFIGS_PIN, \
114  .ctrl_dev_name = pinctrl, \
115  .data.configs = { \
116  .group_or_pin = pin, \
117  .configs = cfgs, \
118  .num_configs = ARRAY_SIZE(cfgs), \
119  }, \
120  }
121 
122 #define PIN_MAP_CONFIGS_PIN_DEFAULT(dev, pinctrl, pin, cfgs) \
123  PIN_MAP_CONFIGS_PIN(dev, PINCTRL_STATE_DEFAULT, pinctrl, pin, cfgs)
124 
125 #define PIN_MAP_CONFIGS_PIN_HOG(dev, state, pin, cfgs) \
126  PIN_MAP_CONFIGS_PIN(dev, state, dev, pin, cfgs)
127 
128 #define PIN_MAP_CONFIGS_PIN_HOG_DEFAULT(dev, pin, cfgs) \
129  PIN_MAP_CONFIGS_PIN(dev, PINCTRL_STATE_DEFAULT, dev, pin, cfgs)
130 
131 #define PIN_MAP_CONFIGS_GROUP(dev, state, pinctrl, grp, cfgs) \
132  { \
133  .dev_name = dev, \
134  .name = state, \
135  .type = PIN_MAP_TYPE_CONFIGS_GROUP, \
136  .ctrl_dev_name = pinctrl, \
137  .data.configs = { \
138  .group_or_pin = grp, \
139  .configs = cfgs, \
140  .num_configs = ARRAY_SIZE(cfgs), \
141  }, \
142  }
143 
144 #define PIN_MAP_CONFIGS_GROUP_DEFAULT(dev, pinctrl, grp, cfgs) \
145  PIN_MAP_CONFIGS_GROUP(dev, PINCTRL_STATE_DEFAULT, pinctrl, grp, cfgs)
146 
147 #define PIN_MAP_CONFIGS_GROUP_HOG(dev, state, grp, cfgs) \
148  PIN_MAP_CONFIGS_GROUP(dev, state, dev, grp, cfgs)
149 
150 #define PIN_MAP_CONFIGS_GROUP_HOG_DEFAULT(dev, grp, cfgs) \
151  PIN_MAP_CONFIGS_GROUP(dev, PINCTRL_STATE_DEFAULT, dev, grp, cfgs)
152 
153 #ifdef CONFIG_PINCTRL
154 
155 extern int pinctrl_register_mappings(struct pinctrl_map const *map,
156  unsigned num_maps);
157 extern void pinctrl_provide_dummies(void);
158 #else
159 
160 static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
161  unsigned num_maps)
162 {
163  return 0;
164 }
165 
166 static inline void pinctrl_provide_dummies(void)
167 {
168 }
169 #endif /* !CONFIG_PINCTRL */
170 #endif