RTEMS 6.1-rc2
Loading...
Searching...
No Matches
imx-gpio.h
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 * Copyright (C) 2020 embedded brains GmbH & Co. KG
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef BSP_IMX_GPIO_H
29#define BSP_IMX_GPIO_H
30
31#include <rtems.h>
32#include <stdint.h>
33
34#ifdef __cplusplus
35extern "C" {
36#endif /* __cplusplus */
37
39struct imx_gpio;
40
42enum imx_gpio_mode {
43 IMX_GPIO_MODE_OUTPUT,
44 IMX_GPIO_MODE_INPUT,
45 IMX_GPIO_MODE_INTERRUPT_LOW,
46 IMX_GPIO_MODE_INTERRUPT_HIGH,
47 IMX_GPIO_MODE_INTERRUPT_RISING,
48 IMX_GPIO_MODE_INTERRUPT_FALLING,
49 IMX_GPIO_MODE_INTERRUPT_ANY_EDGE,
50};
51
61 volatile struct imx_gpio* gpio;
66 uint32_t mask;
68 unsigned int shift;
70 enum imx_gpio_mode mode;
71};
72
77void imx_gpio_init (struct imx_gpio_pin *pin);
78
99rtems_status_code imx_gpio_init_from_fdt_property_pointer(
100 struct imx_gpio_pin *pin,
101 const uint32_t *prop_pointer,
102 enum imx_gpio_mode mode,
103 const uint32_t **next_prop_pointer);
104
122rtems_status_code imx_gpio_init_from_fdt_property(
123 struct imx_gpio_pin *pin,
124 int node_offset,
125 const char *property,
126 enum imx_gpio_mode mode,
127 size_t index);
128
145rtems_vector_number imx_gpio_get_irq_of_node(
146 const void *fdt,
147 int node,
148 size_t index);
149
155struct imx_gpio *imx_gpio_get_by_index(unsigned idx);
156
160struct imx_gpio *imx_gpio_get_by_register(void *regs);
161
165const char *imx_gpio_get_name(struct imx_gpio *imx_gpio);
166
171void imx_gpio_set_output(struct imx_gpio_pin *pin, uint32_t set);
172
176void imx_gpio_toggle_output(struct imx_gpio_pin *pin);
177
182uint32_t imx_gpio_get_input(struct imx_gpio_pin *pin);
183
187void imx_gpio_int_disable(struct imx_gpio_pin *pin);
188
192void imx_gpio_int_enable(struct imx_gpio_pin *pin);
193
197uint32_t imx_gpio_get_isr(struct imx_gpio_pin *pin);
198
202void imx_gpio_clear_isr(struct imx_gpio_pin *pin, uint32_t clr);
203
209#define IMX_GPIO1 (imx_gpio_get_by_index(0))
210#define IMX_GPIO2 (imx_gpio_get_by_index(1))
211#define IMX_GPIO3 (imx_gpio_get_by_index(2))
212#define IMX_GPIO4 (imx_gpio_get_by_index(3))
213#define IMX_GPIO5 (imx_gpio_get_by_index(4))
214#define IMX_GPIO6 (imx_gpio_get_by_index(5))
215#define IMX_GPIO7 (imx_gpio_get_by_index(6))
218#ifdef __cplusplus
219}
220#endif /* __cplusplus */
221
222#endif /* BSP_IMX_GPIO_H */
ISR_Vector_number rtems_vector_number
This integer type represents interrupt vector numbers.
Definition: intr.h:102
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
This header file defines the RTEMS Classic API.
Definition: imx-gpio.h:59
enum imx_gpio_mode mode
Definition: imx-gpio.h:70
unsigned int shift
Definition: imx-gpio.h:68
volatile struct imx_gpio * gpio
Definition: imx-gpio.h:61
uint32_t mask
Definition: imx-gpio.h:66
Definition: imx-gpio.c:63