1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * mux/consumer.h - definitions for the multiplexer consumer interface
4  *
5  * Copyright (C) 2017 Axentia Technologies AB
6  *
7  * Author: Peter Rosin <peda@axentia.se>
8  */
9 
10 #ifndef _LINUX_MUX_CONSUMER_H
11 #define _LINUX_MUX_CONSUMER_H
12 
13 #include <linux/compiler.h>
14 
15 struct device;
16 struct mux_control;
17 
18 unsigned int mux_control_states(struct mux_control *mux);
19 int __must_check mux_control_select_delay(struct mux_control *mux,
20 					  unsigned int state,
21 					  unsigned int delay_us);
22 int __must_check mux_control_try_select_delay(struct mux_control *mux,
23 					      unsigned int state,
24 					      unsigned int delay_us);
25 
mux_control_select(struct mux_control * mux,unsigned int state)26 static inline int __must_check mux_control_select(struct mux_control *mux,
27 						  unsigned int state)
28 {
29 	return mux_control_select_delay(mux, state, 0);
30 }
31 
mux_control_try_select(struct mux_control * mux,unsigned int state)32 static inline int __must_check mux_control_try_select(struct mux_control *mux,
33 						      unsigned int state)
34 {
35 	return mux_control_try_select_delay(mux, state, 0);
36 }
37 
38 int mux_control_deselect(struct mux_control *mux);
39 
40 struct mux_control *mux_control_get(struct device *dev, const char *mux_name);
41 void mux_control_put(struct mux_control *mux);
42 
43 struct mux_control *devm_mux_control_get(struct device *dev,
44 					 const char *mux_name);
45 
46 #endif /* _LINUX_MUX_CONSUMER_H */
47