aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpio/gpiodebug.h
blob: 12cf550912e15a856213cb4ee7f8755712714307 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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
#ifndef __GPIO_DEBUG_H_
#define __GPIO_DEBUG_H_

#include <linux/gpio.h>

struct gpio_debug;

#define TYPE_CONF_REG			0x00
#define TYPE_PIN_VALUE			0x01
#define TYPE_DIRECTION			0x02
#define TYPE_IRQ_TYPE			0x03
#define TYPE_PINMUX			0x04
#define TYPE_PULLMODE			0x05
#define TYPE_PULLSTRENGTH		0x06
#define TYPE_OPEN_DRAIN			0x07

#define TYPE_IRQ_COUNT			0x08
#define TYPE_WAKEUP			0x09
#define TYPE_WAKEUP_COUNT		0x0A
#define TYPE_OVERRIDE_OUTDIR		0x0B
#define TYPE_OVERRIDE_OUTVAL		0x0C
#define TYPE_OVERRIDE_INDIR		0x0D
#define TYPE_OVERRIDE_INVAL		0x0E
#define TYPE_DEBOUNCE			0x0F

#define TYPE_SBY_OVR_IO			0x10
#define TYPE_SBY_OVR_OUTVAL		0x11
#define TYPE_SBY_OVR_INVAL		0x12
#define TYPE_SBY_OVR_OUTDIR		0x13
#define TYPE_SBY_OVR_INDIR		0x14
#define TYPE_SBY_PUPD_STATE		0x15
#define TYPE_SBY_OD_DIS			0x16
#define TYPE_IRQ_LINE			0x17
#define TYPE_MAX			0x18

struct gpio_control {
	unsigned type, num;
	char	 **pininfo;
	u32	reg, invert;
	u32 shift, rshift;
	u32	mask;
	int (*get)(struct gpio_control *control, void *private_data,
		unsigned gpio);
	int (*set)(struct gpio_control *control, void *private_data,
		unsigned gpio, unsigned int num);
	int (*get_handle)(int val);
	void (*set_handle)(unsigned int num, int *val);
};

struct gpio_debug_ops {
	unsigned int (*get_conf_reg)(struct gpio_debug *debug, unsigned gpio);
	void	(*set_conf_reg)(struct gpio_debug *debug, unsigned gpio,
			unsigned int value);
	char	**(*get_avl_pininfo)(struct gpio_debug *debug, unsigned gpio,
			unsigned int type, unsigned *num);
	char	*(*get_cul_pininfo)(struct gpio_debug *debug, unsigned gpio,
			unsigned int type);
	void	(*set_pininfo)(struct gpio_debug *debug, unsigned gpio,
			unsigned int type, const char *info);
	int	(*get_register_msg)(char **buf, unsigned long *size);
};

struct gpio_debug {
	unsigned long		typebit[BITS_TO_LONGS(TYPE_MAX)];
	struct gpio_chip	*chip;
	struct gpio_debug_ops	*ops;
	unsigned long		irq_count[ARCH_NR_GPIOS];
	unsigned long		wakeup_count[ARCH_NR_GPIOS];
	void			*private_data;
};

#ifdef CONFIG_GPIODEBUG

#define DEFINE_DEBUG_IRQ_CONUNT_INCREASE(gpio) (debug->irq_count[gpio]++)

struct gpio_control *find_gpio_control(struct gpio_control *control, int num,
			unsigned type);
int find_pininfo_num(struct gpio_control *control, const char *info);

struct gpio_debug *gpio_debug_alloc(void);
void gpio_debug_remove(struct gpio_debug *debug);
int gpio_debug_register(struct gpio_debug *debug);
#else

#define DEFINE_DEBUG_IRQ_CONUNT_INCREASE(gpio)

static inline struct gpio_control *find_gpio_control(
			struct gpio_control *control, int num, unsigned type)
{
	return NULL;
}
static inline int find_pininfo_num(struct gpio_control *control,
			const char *info)
{
	return 0;
}
static inline struct gpio_debug *gpio_debug_alloc(void)
{
	return NULL;
}

static inline void gpio_debug_remove(struct gpio_debug *debug)
{
	return NULL;
}
static inline int gpio_debug_register(struct gpio_debug *debug)
{
	return 0;
}
#endif
#endif