2 * (c) 2011 Alexander Warg <warg@os.inf.tu-dresden.de>
3 * economic rights: Technische Universität Dresden (Germany)
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.
11 #include <l4/sys/compiler.h>
12 #include <l4/sys/types.h>
13 #include <l4/vbus/vbus_types.h>
16 * \ingroup l4vbus_module
17 * \defgroup l4vbus_gpio_module L4vbus GPIO functions
24 * \brief Constants for generic GPIO functions
26 enum L4vbus_gpio_generic_func
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
34 * \brief Constants for generic GPIO pull up/down resistor configuration
36 enum L4vbus_gpio_pull_modes
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
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()
51 l4vbus_gpio_setup(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
52 unsigned pin, unsigned mode, int value);
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()
62 l4vbus_gpio_config_pull(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
63 unsigned pin, unsigned mode);
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()
73 l4vbus_gpio_config_pad(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
74 unsigned pin, unsigned func, unsigned value);
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()
84 l4vbus_gpio_config_get(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
85 unsigned pin, unsigned func, unsigned *value);
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()
95 l4vbus_gpio_get(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
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()
106 l4vbus_gpio_set(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
107 unsigned pin, int value);
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
119 * \copydetails L4vbus::Gpio_module::setup()
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);
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
136 * \copydetails L4vbus::Gpio_module::config_pad()
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);
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()
150 l4vbus_gpio_multi_get(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
151 unsigned offset, unsigned *data);
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()
162 l4vbus_gpio_multi_set(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,
163 unsigned offset, unsigned mask, unsigned data);
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()
173 l4vbus_gpio_to_irq(l4_cap_idx_t vbus, l4vbus_device_handle_t handle,