Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pinconf-generic.h
Go to the documentation of this file.
1 /*
2  * Interface the generic pinconfig portions of the pinctrl subsystem
3  *
4  * Copyright (C) 2011 ST-Ericsson SA
5  * Written on behalf of Linaro for ST-Ericsson
6  * This interface is used in the core to keep track of pins.
7  *
8  * Author: Linus Walleij <[email protected]>
9  *
10  * License terms: GNU General Public License (GPL) version 2
11  */
12 #ifndef __LINUX_PINCTRL_PINCONF_GENERIC_H
13 #define __LINUX_PINCTRL_PINCONF_GENERIC_H
14 
15 /*
16  * You shouldn't even be able to compile with these enums etc unless you're
17  * using generic pin config. That is why this is defined out.
18  */
19 #ifdef CONFIG_GENERIC_PINCONF
20 
69 enum pin_config_param {
70  PIN_CONFIG_BIAS_DISABLE,
71  PIN_CONFIG_BIAS_HIGH_IMPEDANCE,
72  PIN_CONFIG_BIAS_PULL_UP,
73  PIN_CONFIG_BIAS_PULL_DOWN,
74  PIN_CONFIG_DRIVE_PUSH_PULL,
75  PIN_CONFIG_DRIVE_OPEN_DRAIN,
76  PIN_CONFIG_DRIVE_OPEN_SOURCE,
77  PIN_CONFIG_INPUT_SCHMITT,
78  PIN_CONFIG_INPUT_DEBOUNCE,
79  PIN_CONFIG_POWER_SOURCE,
80  PIN_CONFIG_LOW_POWER_MODE,
81  PIN_CONFIG_END = 0x7FFF,
82 };
83 
84 /*
85  * Helpful configuration macro to be used in tables etc.
86  */
87 #define PIN_CONF_PACKED(p, a) ((a << 16) | ((unsigned long) p & 0xffffUL))
88 
89 /*
90  * The following inlines stuffs a configuration parameter and data value
91  * into and out of an unsigned long argument, as used by the generic pin config
92  * system. We put the parameter in the lower 16 bits and the argument in the
93  * upper 16 bits.
94  */
95 
96 static inline enum pin_config_param pinconf_to_config_param(unsigned long config)
97 {
98  return (enum pin_config_param) (config & 0xffffUL);
99 }
100 
101 static inline u16 pinconf_to_config_argument(unsigned long config)
102 {
103  return (enum pin_config_param) ((config >> 16) & 0xffffUL);
104 }
105 
106 static inline unsigned long pinconf_to_config_packed(enum pin_config_param param,
107  u16 argument)
108 {
109  return PIN_CONF_PACKED(param, argument);
110 }
111 
112 #endif /* CONFIG_GENERIC_PINCONF */
113 
114 #endif /* __LINUX_PINCTRL_PINCONF_GENERIC_H */