RTEMS 6.1-rc6
Loading...
Searching...
No Matches
microblaze-gpio.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11/*
12 * Copyright (C) 2022 On-Line Applications Research Corporation (OAR)
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifndef LIBBSP_MICROBLAZE_FPGA_MICROBLAZE_GPIO_H
37#define LIBBSP_MICROBLAZE_FPGA_MICROBLAZE_GPIO_H
38
39#include <bspopts.h>
40#include <bsp/utility.h>
41#include <rtems.h>
42
43#ifdef __cplusplus
44extern "C" {
45#endif /* __cplusplus */
46
47typedef struct {
48 /* Channel 1 data values */
49
50 /*
51 * Used to read general purpose input ports and write to general purpose
52 * output ports from channel 1.
53 */
54 volatile uint32_t gpio_data;
55
56 /*
57 * The 3-state control register for channel 1 is used for the dynamic
58 * configuration of ports as input or output. When a bit is set to 1, the
59 * corresponding I/O port is an input port. When a bit is set to 0, it is an
60 * output port.
61 */
62 volatile uint32_t gpio_tri;
63
64 /* Channel 2 data values */
65
66 /*
67 * Used to read general purpose input ports and write to general purpose
68 * output ports from channel 2.
69 */
70 volatile uint32_t gpio2_data;
71
72 /*
73 * The 3-state control register for channel 2 is used for the dynamic
74 * configuration of ports as input or output. When a bit is set to 1, the
75 * corresponding I/O port is an input port. When a bit is set to 0, it is an
76 * output port.
77 */
78 volatile uint32_t gpio2_tri;
79
80 char _unused[272];
81
82 /* Only the 31st bit is used to enable interrupts globally */
83#define GLOBAL_INTERRUPT_REGISTER_ENABLE BSP_BIT32(31)
84
85 /*
86 * Global Interrupt Enable Register
87 *
88 * Determines whether interrupts are enabled or disabled.
89 *
90 * 0 - Disabled
91 * 1 - Enabled
92 */
93 volatile uint32_t gier;
94
95 char _unused2[12];
96
97 /* Used with ip_isr and ip_ier member variables */
98#define CHANNEL_1_INTERRUPT_REGISTER BSP_BIT32(0)
99#define CHANNEL_2_INTERRUPT_REGISTER BSP_BIT32(1)
100
101 /*
102 * IP Status Registers
103 *
104 * Contains the status bit for each channel.
105 *
106 * 0 - Disabled
107 * 1 - Enabled
108 */
109 volatile uint32_t ip_isr;
110
111 char _unused3[4];
112
113 /*
114 * IP Interrupt Enable Register
115 *
116 * Provides the ability to independtly control whether interrupts for each
117 * channel are enabled or disabled.
118 *
119 * 0 - No Channel input interrupt
120 * 1 - Channel input interrupt
121 */
122 volatile uint32_t ip_ier;
124
125typedef struct {
127 bool is_dual;
128 uint32_t irq;
129 bool has_interrupts;
131
132#ifdef BSP_MICROBLAZE_FPGA_USE_FDT
144rtems_status_code microblaze_gpio_init_context_from_fdt(
146 int index
147);
148#endif /* BSP_MICROBLAZE_FPGA_USE_FDT */
149
164 uint32_t channel,
165 uint32_t mask
166);
167
181 uint32_t channel
182);
183
193 uint32_t channel
194);
195
207 uint32_t channel,
208 uint32_t mask
209);
210
222 uint32_t channel,
223 uint32_t mask
224);
225
237 uint32_t channel,
238 uint32_t mask
239);
240
249
258
267
278 uint32_t channel
279);
280
291 uint32_t channel
292);
293
304 uint32_t channel
305);
306
315
324
325#ifdef __cplusplus
326}
327#endif /* __cplusplus */
328
329#endif /* LIBBSP_MICROBLAZE_FPGA_MICROBLAZE_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 provides utility macros for BSPs.
void microblaze_gpio_interrupt_clear(Microblaze_GPIO_context *ctx, uint32_t channel)
Clear status of interrupt signals on a specific channel.
Definition: microblaze-gpio.c:254
void microblaze_gpio_discrete_write(Microblaze_GPIO_context *ctx, uint32_t channel, uint32_t mask)
Writes to data register for specified GPIO channel.
Definition: microblaze-gpio.c:155
uint32_t microblaze_gpio_interrupt_get_enabled(Microblaze_GPIO_context *ctx)
Return a bitmask of the interrupts that are enabled.
Definition: microblaze-gpio.c:268
void microblaze_gpio_set_data_direction(Microblaze_GPIO_context *ctx, uint32_t channel, uint32_t mask)
Set pin configuration for the specified GPIO channel.
Definition: microblaze-gpio.c:108
rtems_vector_number microblaze_gpio_get_irq(Microblaze_GPIO_context *ctx)
Returns the vector number of the interrupt handler.
Definition: microblaze-gpio.c:200
void microblaze_gpio_discrete_set(Microblaze_GPIO_context *ctx, uint32_t channel, uint32_t mask)
Set bits to 1 on specified GPIO channel.
Definition: microblaze-gpio.c:170
void microblaze_gpio_interrupt_enable(Microblaze_GPIO_context *ctx, uint32_t channel)
Enables interrupts on specified channel.
Definition: microblaze-gpio.c:223
uint32_t microblaze_gpio_interrupt_get_status(Microblaze_GPIO_context *ctx)
Return a bitmask of the status of the interrupt signals.
Definition: microblaze-gpio.c:279
uint32_t microblaze_gpio_get_data_direction(Microblaze_GPIO_context *ctx, uint32_t channel)
Get pin configuration for specified GPIO channel.
Definition: microblaze-gpio.c:123
uint32_t microblaze_gpio_discrete_read(Microblaze_GPIO_context *ctx, uint32_t channel)
Reads data for specified GPIO channel.
Definition: microblaze-gpio.c:139
void microblaze_gpio_interrupt_global_enable(Microblaze_GPIO_context *ctx)
Turns on interrupts globally.
Definition: microblaze-gpio.c:205
void microblaze_gpio_discrete_clear(Microblaze_GPIO_context *ctx, uint32_t channel, uint32_t mask)
Set bits to 0 on specified GPIO channel.
Definition: microblaze-gpio.c:185
void microblaze_gpio_interrupt_disable(Microblaze_GPIO_context *ctx, uint32_t channel)
Disables interrupts on specified channel.
Definition: microblaze-gpio.c:240
void microblaze_gpio_interrupt_global_disable(Microblaze_GPIO_context *ctx)
Turns off interrupts globally.
Definition: microblaze-gpio.c:214
rtems_termios_device_context * context
Definition: console-config.c:62
This header file defines the RTEMS Classic API.
Definition: microblaze-gpio.h:125
Definition: microblaze-gpio.h:47