]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/io/libvbus/include/vbus_gpio.h
Update
[l4.git] / l4 / pkg / io / libvbus / include / vbus_gpio.h
1 /*
2  * (c) 2011 Alexander Warg <warg@os.inf.tu-dresden.de>
3  *     economic rights: Technische Universität Dresden (Germany)
4  *
5  * This file is part of TUD:OS and distributed under the terms of the
6  * GNU General Public License 2.
7  * Please see the COPYING-GPL-2 file for details.
8  */
9 #pragma once
10
11 #include <l4/sys/compiler.h>
12 #include <l4/sys/types.h>
13 #include <l4/vbus/vbus_types.h>
14
15 /**
16  * \ingroup l4vbus_module
17  * \defgroup l4vbus_gpio_module L4vbus GPIO functions
18  * \{
19  */
20
21 __BEGIN_DECLS
22
23 /**
24  * \brief Constants for generic GPIO functions
25  */
26 enum L4vbus_gpio_generic_func
27 {
28   L4VBUS_GPIO_SETUP_INPUT  = 0x100, ///< Set GPIO pin to input
29   L4VBUS_GPIO_SETUP_OUTPUT = 0x200, ///< Set GPIO pin to output
30   L4VBUS_GPIO_SETUP_IRQ    = 0x300, ///< Set GPIO pin to IRQ
31 };
32
33 /**
34  * \brief Constants for generic GPIO pull up/down resistor configuration
35  */
36 enum L4vbus_gpio_pull_modes
37 {
38   L4VBUS_GPIO_PIN_PULL_NONE = 0x100,  ///< No pull up or pull down resistors
39   L4VBUS_GPIO_PIN_PULL_UP   = 0x200,  ///< enable pull up resistor
40   L4VBUS_GPIO_PIN_PULL_DOWN = 0x300,  ///< enable pull down resistor
41 };
42
43 /**
44  * \copybrief L4vbus::Gpio_pin::setup()
45  * \param vbus      V-BUS capability
46  * \param handle    Device handle for the GPIO chip
47  * \param pin       GPIO pin number
48  * \copydetails L4vbus::Gpio_pin::setup()
49  */
50 int L4_CV
51 l4vbus_gpio_setup(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
52                   unsigned pin, unsigned mode, int value);
53
54 /**
55  * \copybrief L4vbus::Gpio_pin::config_pull()
56  * \param vbus    V-BUS capability
57  * \param handle  Device handle for the GPIO chip
58  * \param pin     GPIO pin number
59  * \copydetails L4vbus::Gpio_pin::config_pull()
60  */
61 int L4_CV
62 l4vbus_gpio_config_pull(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
63                         unsigned pin, unsigned mode);
64
65 /**
66  * \copybrief L4vbus::Gpio_pin::config_pad()
67  * \param vbus    V-BUS capability
68  * \param handle  Device handle for the GPIO chip
69  * \param pin     GPIO pin number
70  * \copydetails L4vbus::Gpio_pin::config_pad()
71  */
72 int L4_CV
73 l4vbus_gpio_config_pad(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
74                        unsigned pin, unsigned func, unsigned value);
75
76 /**
77  * \copybrief L4vbus::Gpio_pin::config_get()
78  * \param vbus    V-BUS capability
79  * \param handle  Device handle for the GPIO chip
80  * \param pin     GPIO pin number
81  * \copydetails L4vbus::Gpio_pin::config_get()
82  */
83 int L4_CV
84 l4vbus_gpio_config_get(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
85                        unsigned pin, unsigned func, unsigned *value);
86
87 /**
88  * \copybrief L4vbus::Gpio_pin::get()
89  * \param vbus    V-BUS capability
90  * \param handle  Device handle for the GPIO chip
91  * \param pin     GPIO pin number to read from
92  * \copydetails L4vbus::Gpio_pin::get()
93  */
94 int L4_CV
95 l4vbus_gpio_get(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
96                 unsigned pin);
97
98 /**
99  * \copybrief L4vbus::Gpio_pin::set()
100  * \param vbus    V-BUS capability
101  * \param handle  Device handle for the GPIO chip
102  * \param pin     GPIO pin number to write to
103  * \copydetails L4vbus::Gpio_pin::set()
104  */
105 int L4_CV
106 l4vbus_gpio_set(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
107                 unsigned pin, int value);
108
109 /**
110  * \copybrief L4vbus::Gpio_module::setup()
111  * \param vbus    V-BUS capability
112  * \param handle  Device handle for the GPIO chip
113  * \param offset  Pin corresponding to the LSB in \a mask.
114  *                Note: allowed may be hardware specific.
115  * \param mask    Mask of GPIO pins to configure. A bit set to 1 configures
116  *                this pin. A maximum of 32 pins can be configured at once.
117  *                The real number depends on the hardware and the driver
118  *                implementation.
119  * \copydetails L4vbus::Gpio_module::setup()
120  */
121 int L4_CV
122 l4vbus_gpio_multi_setup(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
123                         unsigned offset, unsigned mask,
124                         unsigned mode, unsigned value);
125
126 /**
127  * \copybrief L4vbus::Gpio_module::config_pad()
128  * \param vbus    V-BUS capability
129  * \param handle  Device handle for the GPIO chip
130  * \param offset  Pin corresponding to the LSB in \a mask.
131  *                Note: allowed may be hardware specific.
132  * \param mask    Mask of GPIO pins to configure. A bit set to 1 configures
133  *                this pin. A maximum of 32 pins can be configured at once.
134  *                The real number depends on the hardware and the driver
135  *                implementation.
136  * \copydetails L4vbus::Gpio_module::config_pad()
137  */
138 int L4_CV
139 l4vbus_gpio_multi_config_pad(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
140                               unsigned offset, unsigned mask,
141                               unsigned func, unsigned value);
142
143 /**
144  * \copybrief L4vbus::Gpio_module::get()
145  * \param vbus    V-BUS capability
146  * \param handle  Device handle for the GPIO chip
147  * \copydetails L4vbus::Gpio_module::get()
148  */
149 int L4_CV
150 l4vbus_gpio_multi_get(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
151                       unsigned offset, unsigned *data);
152
153 /**
154  * \copybrief L4vbus::Gpio_module::set()
155  * \param vbus    V-BUS capability
156  * \param handle  Device handle for the GPIO chip
157  * \param offset  Pin corresponding to the LSB in \a data.
158  *                Note: allowed may be hardware specific.
159  * \copydetails L4vbus::Gpio_module::set()
160  */
161 int L4_CV
162 l4vbus_gpio_multi_set(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
163                       unsigned offset, unsigned mask, unsigned data);
164
165 /**
166  * \copybrief L4vbus::Gpio_pin::to_irq()
167  * \param vbus    V-BUS capability
168  * \param handle  Device handle for the GPIO chip
169  * \param pin     GPIO pin to create an IRQ for.
170  * \copydetails L4vbus::Gpio_pin::to_irq()
171  */
172 int L4_CV
173 l4vbus_gpio_to_irq(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
174                    unsigned pin);
175
176 /**\}*/
177
178 __END_DECLS