xref: /freebsd/sys/dev/gpio/gpiobus_if.m (revision 7899f917b1c0ea178f1d2be0cfb452086d079d23)
1#-
2# Copyright (c) 2009 Oleksandr Tymoshenko <gonzo@freebsd.org>
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright
9#    notice, this list of conditions and the following disclaimer.
10# 2. Redistributions in binary form must reproduce the above copyright
11#    notice, this list of conditions and the following disclaimer in the
12#    documentation and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25#
26#
27
28#include <sys/bus.h>
29#include <sys/gpio.h>
30
31INTERFACE gpiobus;
32
33#
34# Dedicate the gpio bus control for a child
35#
36METHOD int acquire_bus {
37	device_t busdev;
38	device_t dev;
39	int how;
40};
41
42#
43# Release the bus
44#
45METHOD void release_bus {
46	device_t busdev;
47	device_t dev;
48};
49
50#
51# Set value of pin specified by pin_num
52#
53METHOD int pin_set {
54	device_t dev;
55	device_t child;
56	uint32_t pin_num;
57	uint32_t pin_value;
58};
59
60#
61# Get value of pin specified by pin_num
62#
63METHOD int pin_get {
64	device_t dev;
65	device_t child;
66	uint32_t pin_num;
67	uint32_t *pin_value;
68};
69
70#
71# Toggle value of pin specified by pin_num
72#
73METHOD int pin_toggle {
74	device_t dev;
75	device_t child;
76	uint32_t pin_num;
77};
78
79#
80# Get pin capabilities
81#
82METHOD int pin_getcaps {
83	device_t dev;
84	device_t child;
85	uint32_t pin_num;
86	uint32_t *caps;
87};
88
89#
90# Get pin flags
91#
92METHOD int pin_getflags {
93	device_t dev;
94	device_t child;
95	uint32_t pin_num;
96	uint32_t *flags;
97};
98
99#
100# Set current configuration and capabilities
101#
102METHOD int pin_setflags {
103	device_t dev;
104	device_t child;
105	uint32_t pin_num;
106	uint32_t flags;
107};
108
109#
110# Get the pin name
111#
112METHOD int pin_getname {
113	device_t dev;
114	uint32_t pin_num;
115	char *name;
116};
117
118#
119# Set the pin name
120#
121METHOD int pin_setname {
122	device_t dev;
123	uint32_t pin_num;
124	const char *name;
125};
126