xref: /freebsd/sys/dev/gpio/gpiobus_if.m (revision 39bdc7d19b1ac1443b1fb7adf81cfa3715625717)
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# Simultaneously read and/or change up to 32 adjacent pins.
111# If the device cannot change the pins simultaneously, returns EOPNOTSUPP.
112#
113# More details about using this interface can be found in sys/gpio.h
114#
115METHOD int pin_access_32 {
116	device_t dev;
117	device_t child;
118	uint32_t first_pin;
119	uint32_t clear_pins;
120	uint32_t change_pins;
121	uint32_t *orig_pins;
122};
123
124#
125# Simultaneously configure up to 32 adjacent pins.
126# This is intended to change the configuration of all the pins simultaneously,
127# but unlike pin_access_32, this will not fail if the hardware can't do so.
128#
129# More details about using this interface can be found in sys/gpio.h
130#
131METHOD int pin_config_32 {
132	device_t dev;
133	device_t child;
134	uint32_t first_pin;
135	uint32_t num_pins;
136	uint32_t *pin_flags;
137};
138
139#
140# Get the pin name
141#
142METHOD int pin_getname {
143	device_t dev;
144	uint32_t pin_num;
145	char *name;
146};
147
148#
149# Set the pin name
150#
151METHOD int pin_setname {
152	device_t dev;
153	uint32_t pin_num;
154	const char *name;
155};
156