-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathgpio.txt
220 lines (215 loc) · 6.58 KB
/
gpio.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
################################################################################
##
## Filename: auto-data/gpio.txt
##
## Project: AutoFPGA, a utility for composing FPGA designs from peripherals
## {{{
## Purpose:
##
## Creator: Dan Gisselquist, Ph.D.
## Gisselquist Technology, LLC
##
################################################################################
## }}}
## Copyright (C) 2017-2024, Gisselquist Technology, LLC
## {{{
## This program is free software (firmware): you can redistribute it and/or
## modify it under the terms of the GNU General Public License as published
## by the Free Software Foundation, either version 3 of the License, or (at
## your option) any later version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
## for more details.
##
## You should have received a copy of the GNU General Public License along
## with this program. (It's in the $(ROOT)/doc directory. Run make with no
## target there if the PDF file isn't present.) If not, see
## <http://www.gnu.org/licenses/> for a copy.
## }}}
## License: GPL, v3, as defined and found on www.gnu.org,
## {{{
## http://www.gnu.org/licenses/gpl.html
##
##
################################################################################
##
## }}}
@PREFIX=gpio
@DEVID=GPIO
@NADDR=1
@ACCESS=@$(DEVID)_ACCESS
@SLAVE.TYPE=SINGLE
@SLAVE.BUS=wb32
@NUMOUTPUT=10
@NUMINPUT=8
@INT.GPIO.WIRE=gpio_int
@INT.GPIO.PIC=syspic
@TOP.PORTLIST=
// @$(DEVID) ports
o_hdmirx_hpa, // Hotplug assert
o_hdmirx_txen,
i_hdmitx_hpd_n, // Hotplug detect
o_sd_reset,
i_gps_3df,
o_oled_reset_n, o_oled_panel_en, o_oled_logic_en
@TOP.IODECL=
// @$(DEVID) ports
output wire o_hdmirx_hpa;
output wire o_hdmirx_txen;
input wire i_hdmitx_hpd_n; // Hotplug detect
output wire o_sd_reset;
input wire i_gps_3df;
output wire o_oled_reset_n, o_oled_panel_en, o_oled_logic_en;
@TOP.DEFNS=
// @$(DEVID) declarations. The two wire busses are just virtual lists
// of input (or output) ports.
wire [@$(NUMINPUT)-1:0] i_@$(PREFIX);
// Verilator lint_off UNUSED
// Two of our outputs, o_trace and o_halt, will be unused at the top
// level.
wire [@$(NUMOUTPUT)-1:0] o_@$(PREFIX);
// Verilator lint_on UNUSED
@TOP.MAIN=
// @$(DEVID) wires
i_@$(PREFIX), o_@$(PREFIX)
@TOP.INSERT=
////////////////////////////////////////////////////////////////////////
//
// GPIO adjustments
// {{{
assign i_@$(PREFIX) = { 8'h0,
pxrx_locked,
sysclk_locked,
`ifdef GPSTRK_ACCESS
i_gps_3df,
`else
1'b0,
`endif
!i_hdmitx_hpd_n, // Hotplug detect
!i_sd_cd_n,
1'b0,
i_hdmitx_cec, i_hdmirx_cec };
assign o_hdmirx_txen = o_gpio[2];
assign o_hdmirx_hpa = o_gpio[3]; // Hotplug assert
assign o_sd_reset = !w_sdio_hwreset_n;
assign o_oled_reset_n = !o_gpio[5];
assign o_oled_panel_en = o_gpio[6];
assign o_oled_logic_en = o_gpio[7];
// These two pins are only used in simulation, and only within the
// MAIN RTL component.
// assign o_trace = o_gpio[8];
// assign o_halt = o_gpio[9];
// }}}
@MAIN.PORTLIST=
// @$(DEVID) ports
`ifdef VERILATOR
o_trace, o_halt,
`endif
i_@$(PREFIX), o_@$(PREFIX)
@MAIN.IODECL=
localparam NGPI = @$(NUMINPUT), NGPO=@$(NUMOUTPUT);
// @$(DEVID) ports
`ifdef VERILATOR
output wire o_trace;
output wire o_halt;
`endif
input [(NGPI-1):0] i_@$(PREFIX);
output wire [(NGPO-1):0] o_@$(PREFIX);
@MAIN.DEFNS=
wire sd_reset;
@MAIN.INSERT=
////////////////////////////////////////////////////////////////////////
//
// @$(DEVID)
// {{{
// This interface should allow us to control up to 16 @$(DEVID) inputs,
// and another 16 @$(DEVID) outputs. The interrupt trips when any of
// the inputs changes. (Sorry, which input isn't (yet) selectable.)
//
localparam [NGPO-1:0] INITIAL_@$(DEVID) = @$(NUMOUTPUT)'h13;
wbgpio #(
.NIN(NGPI), .NOUT(NGPO), .DEFAULT(INITIAL_@$(DEVID))
) u_@$(PREFIX) (
// {{{
.i_clk(i_clk),
@$(SLAVE.ANSIPORTLIST),
.i_gpio(i_@$(PREFIX)), .o_gpio(o_@$(PREFIX)),
.o_int(@$(PREFIX)_int)
// }}}
);
`ifdef SDIO_ACCESS
// This bit is used by the SDSPI controller, not the SDIO controller.
assign sd_reset = !o_sdio_hwreset_n;
`else
assign sd_reset = o_@$(PREFIX)[3];
`endif
`ifdef VERILATOR
wire verilator_halt;
assign o_trace = o_@$(PREFIX)[8];
assign verilator_halt = o_@$(PREFIX)[9];
assign o_halt = verilator_halt;
always @(posedge verilator_halt)
$finish;
`endif
// }}}
@REGS.N=1
@REGS.0= 0 R_@$(DEVID) @$(DEVID) GPI GPO
@BDEF.DEFN=
//
// @$(DEVID) input wires
//
#define GPIO_HDMIRX_CEC 0x000010000
#define GPIO_HDMITX_CEC 0x000020000
#define GPIO_SD_DETECTED 0x000080000
#define GPIO_HDMITX_DETECT 0x000100000
#define GPIO_GPS_3DF 0x000200000
#define GPIO_SYSCLK_LOCKED 0x000400000
#define GPIO_VIDCLK_LOCKED 0x000800000
//
// @$(DEVID) output wires
//
#define @$(DEVID)_SET(WIRE) (((WIRE)<<16)|(WIRE))
#define @$(DEVID)_CLR(WIRE) ((WIRE)<<16)
//
#define GPIO_HDMIRX_CEC_SET 0x000010001
#define GPIO_HDMIRX_CEC_CLR 0x000010000
#define GPIO_HDMITX_CEC_SET 0x000020002
#define GPIO_HDMITX_CEC_CLR 0x000020000
//
#define GPIO_HDMIRX_TXEN 0x000000004
#define GPIO_HDMIRX_HPA 0x000000008
#define GPIO_SD_RESET 0x000000010
#define GPIO_OLED_RESET 0x000000020
#define GPIO_OLED_PANELEN 0x000000040
#define GPIO_OLED_LOGICEN 0x000000080
#define GPIO_TRACE 0x000000100
#define GPIO_TESTHALT 0x000000200
//
#define GPIO_EDID_SCL_SET GPIO_SET(GPIO_EDID_SCL)
#define GPIO_EDID_SCL_CLR GPIO_CLR(GPIO_EDID_SCL)
#define GPIO_EDID_SDA_SET GPIO_SET(GPIO_EDID_SDA)
#define GPIO_EDID_SDA_CLR GPIO_CLR(GPIO_EDID_SDA)
#define GPIO_HDMIRX_HPA_SET GPIO_SET(GPIO_HDMIRX_HPA)
#define GPIO_HDMIRX_HPA_CLR GPIO_CLR(GPIO_HDMIRX_HPA)
#define GPIO_SD_RESET_SET GPIO_SET(GPIO_SD_RESET)
#define GPIO_SD_RESET_CLR GPIO_CLR(GPIO_SD_RESET)
#define GPIO_HDMIRX_TXEN_SET GPIO_SET(GPIO_HDMIRX_TXEN)
#define GPIO_HDMIRX_TXEN_CLR GPIO_CLR(GPIO_HDMIRX_TXEN)
#define OLED_RESET GPIO_SET(GPIO_OLED_RESET)
#define OLED_RUN GPIO_CLR(GPIO_OLED_RESET)
#define OLED_PANELEN GPIO_SET(GPIO_OLED_PANELEN)
#define OLED_PANELDIS GPIO_CLR(GPIO_OLED_PANELEN)
#define OLED_LOGICEN GPIO_SET(GPIO_OLED_LOGICEN)
#define OLED_LOGICDIS GPIO_CLR(GPIO_OLED_LOGICEN)
#define GPIO_TRACE_SET GPIO_SET(GPIO_TRACE)
#define GPIO_TRACE_CLR GPIO_CLR(GPIO_TRACE)
#define GPIO_HALT_SET GPIO_SET(GPIO_TESTHALT)
#define GPIO_HALT_CLR GPIO_CLR(GPIO_TESTHALT)
@BDEF.IONAME= i_@$(PREFIX)
@BDEF.IOTYPE= unsigned
@BDEF.OSDEF= _BOARD_HAS_@$(DEVID)
@BDEF.OSVAL= static volatile @$(BDEF.IOTYPE) *const _@$(PREFIX) = ((@$(BDEF.IOTYPE) *)@$[0x%08x](REGBASE));
@RTL.MAKE.FILES=wbgpio.v
@RTL.MAKE.GROUP=@$(DEVID)