2 * Consumer interface the pin control subsystem
4 * Copyright (C) 2012 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_CONSUMER_H
13 #define __LINUX_PINCTRL_CONSUMER_H
15 #include <linux/err.h>
16 #include <linux/list.h>
17 #include <linux/seq_file.h>
18 #include "pinctrl-state.h"
20 /* This struct is private to the core and should be regarded as a cookie */
26 /* External interface to pin control */
27 extern int pinctrl_request_gpio(unsigned gpio
);
28 extern void pinctrl_free_gpio(unsigned gpio
);
29 extern int pinctrl_gpio_direction_input(unsigned gpio
);
30 extern int pinctrl_gpio_direction_output(unsigned gpio
);
32 extern struct pinctrl
* __must_check
pinctrl_get(struct device
*dev
);
33 extern void pinctrl_put(struct pinctrl
*p
);
34 extern struct pinctrl_state
* __must_check
pinctrl_lookup_state(
37 extern int pinctrl_select_state(struct pinctrl
*p
, struct pinctrl_state
*s
);
39 #else /* !CONFIG_PINCTRL */
41 static inline int pinctrl_request_gpio(unsigned gpio
)
46 static inline void pinctrl_free_gpio(unsigned gpio
)
50 static inline int pinctrl_gpio_direction_input(unsigned gpio
)
55 static inline int pinctrl_gpio_direction_output(unsigned gpio
)
60 static inline struct pinctrl
* __must_check
pinctrl_get(struct device
*dev
)
65 static inline void pinctrl_put(struct pinctrl
*p
)
69 static inline struct pinctrl_state
* __must_check
pinctrl_lookup_state(
76 static inline int pinctrl_select_state(struct pinctrl
*p
,
77 struct pinctrl_state
*s
)
82 #endif /* CONFIG_PINCTRL */
84 static inline struct pinctrl
* __must_check
pinctrl_get_select(
85 struct device
*dev
, const char *name
)
88 struct pinctrl_state
*s
;
95 s
= pinctrl_lookup_state(p
, name
);
98 return ERR_PTR(PTR_ERR(s
));
101 ret
= pinctrl_select_state(p
, s
);
110 static inline struct pinctrl
* __must_check
pinctrl_get_select_default(
113 return pinctrl_get_select(dev
, PINCTRL_STATE_DEFAULT
);
116 #ifdef CONFIG_PINCONF
118 extern int pin_config_get(const char *dev_name
, const char *name
,
119 unsigned long *config
);
120 extern int pin_config_set(const char *dev_name
, const char *name
,
121 unsigned long config
);
122 extern int pin_config_group_get(const char *dev_name
,
123 const char *pin_group
,
124 unsigned long *config
);
125 extern int pin_config_group_set(const char *dev_name
,
126 const char *pin_group
,
127 unsigned long config
);
131 static inline int pin_config_get(const char *dev_name
, const char *name
,
132 unsigned long *config
)
137 static inline int pin_config_set(const char *dev_name
, const char *name
,
138 unsigned long config
)
143 static inline int pin_config_group_get(const char *dev_name
,
144 const char *pin_group
,
145 unsigned long *config
)
150 static inline int pin_config_group_set(const char *dev_name
,
151 const char *pin_group
,
152 unsigned long config
)
159 #endif /* __LINUX_PINCTRL_CONSUMER_H */