consumer.h 2.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * Consumer interface the pin control subsystem
 *
 * Copyright (C) 2012 ST-Ericsson SA
 * Written on behalf of Linaro for ST-Ericsson
 * Based on bits of regulator core, gpio core and clk core
 *
 * Author: Linus Walleij <linus.walleij@linaro.org>
 *
 * License terms: GNU General Public License (GPL) version 2
 */
#ifndef __LINUX_PINCTRL_CONSUMER_H
#define __LINUX_PINCTRL_CONSUMER_H

#include <linux/list.h>
#include <linux/seq_file.h>
#include "pinctrl.h"

/* This struct is private to the core and should be regarded as a cookie */
20
struct pinctrl;
21

22
#ifdef CONFIG_PINCTRL
23

24
/* External interface to pin control */
25 26 27 28 29 30 31 32
extern int pinctrl_request_gpio(unsigned gpio);
extern void pinctrl_free_gpio(unsigned gpio);
extern int pinctrl_gpio_direction_input(unsigned gpio);
extern int pinctrl_gpio_direction_output(unsigned gpio);
extern struct pinctrl * __must_check pinctrl_get(struct device *dev, const char *name);
extern void pinctrl_put(struct pinctrl *p);
extern int pinctrl_enable(struct pinctrl *p);
extern void pinctrl_disable(struct pinctrl *p);
33

34
#else /* !CONFIG_PINCTRL */
35

36
static inline int pinctrl_request_gpio(unsigned gpio)
37 38 39 40
{
	return 0;
}

41
static inline void pinctrl_free_gpio(unsigned gpio)
42 43 44
{
}

45
static inline int pinctrl_gpio_direction_input(unsigned gpio)
46 47 48 49
{
	return 0;
}

50
static inline int pinctrl_gpio_direction_output(unsigned gpio)
51 52 53 54
{
	return 0;
}

55
static inline struct pinctrl * __must_check pinctrl_get(struct device *dev, const char *name)
56 57 58 59
{
	return NULL;
}

60
static inline void pinctrl_put(struct pinctrl *p)
61 62 63
{
}

64
static inline int pinctrl_enable(struct pinctrl *p)
65 66 67 68
{
	return 0;
}

69
static inline void pinctrl_disable(struct pinctrl *p)
70 71 72
{
}

73
#endif /* CONFIG_PINCTRL */
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118

#ifdef CONFIG_PINCONF

extern int pin_config_get(const char *dev_name, const char *name,
			  unsigned long *config);
extern int pin_config_set(const char *dev_name, const char *name,
			  unsigned long config);
extern int pin_config_group_get(const char *dev_name,
				const char *pin_group,
				unsigned long *config);
extern int pin_config_group_set(const char *dev_name,
				const char *pin_group,
				unsigned long config);

#else

static inline int pin_config_get(const char *dev_name, const char *name,
				 unsigned long *config)
{
	return 0;
}

static inline int pin_config_set(const char *dev_name, const char *name,
				 unsigned long config)
{
	return 0;
}

static inline int pin_config_group_get(const char *dev_name,
				       const char *pin_group,
				       unsigned long *config)
{
	return 0;
}

static inline int pin_config_group_set(const char *dev_name,
				       const char *pin_group,
				       unsigned long config)
{
	return 0;
}

#endif

#endif /* __LINUX_PINCTRL_CONSUMER_H */