OpenCores
URL https://opencores.org/ocsvn/openarty/openarty/trunk

Subversion Repositories openarty

[/] [openarty/] [trunk/] [sw/] [zlib/] [artyboard.h] - Blame information for rev 54

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 54 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    artyboard.h
4
//
5
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
6
//
7
// Purpose:     A description of the hardware and I/O parts and pieces specific
8
//              to the OpenArty distribution, for the purpose of writing
9
//      ZipCPU software that will run on the board.
10
//
11
// Creator:     Dan Gisselquist, Ph.D.
12
//              Gisselquist Technology, LLC
13
//
14
////////////////////////////////////////////////////////////////////////////////
15
//
16
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
17
//
18
// This program is free software (firmware): you can redistribute it and/or
19
// modify it under the terms of  the GNU General Public License as published
20
// by the Free Software Foundation, either version 3 of the License, or (at
21
// your option) any later version.
22
//
23
// This program is distributed in the hope that it will be useful, but WITHOUT
24
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
25
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
26
// for more details.
27
//
28
// You should have received a copy of the GNU General Public License along
29
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
30
// target there if the PDF file isn't present.)  If not, see
31
// <http://www.gnu.org/licenses/> for a copy.
32
//
33
// License:     GPL, v3, as defined and found on www.gnu.org,
34
//              http://www.gnu.org/licenses/gpl.html
35
//
36
//
37
////////////////////////////////////////////////////////////////////////////////
38
//
39
//
40
#ifndef ARTYBOARD_H
41
#define ARTYBOARD_H
42
 
43
#include <stdint.h>
44
 
45
// We have the full ZIP System installed
46
#define _HAVE_ZIPSYS_PERFORMANCE_COUNTERS
47
#define _HAVE_ZIPSYS_DMA
48
#include "zipsys.h"
49
 
50
#define GPIO_SET(X)     (X |(X<<16))
51
#define GPIO_CLEAR(X)   (X<<16)
52
typedef struct  {
53
        uint32_t        i_version;
54
        uint32_t        i_pic;
55
        uint32_t        *i_buserr;
56
        uint32_t        i_pwrcount;
57
        uint32_t        i_btnsw, i_leds;
58
        uint32_t        i_rtcdate;
59
        uint32_t        i_gpio;
60
        uint32_t        i_clrled[4];
61
        union   {
62
                unsigned long now;
63
                struct { uint32_t sec; uint32_t sub; };
64
        } i_tim;
65
 
66
        unsigned        i_gps_step;
67
        uint32_t        i_unused[32-15];
68
} BASICIO;
69
 
70
#define SD_SETAUX       0x0ff
71
#define SD_READAUX      0x0bf
72
#define SD_CMD          0x040
73
#define SD_FIFO_OP      0x0800  // Read only
74
#define SD_WRITEOP      0x0c00  // Write to the FIFO
75
#define SD_ALTFIFO      0x1000
76
#define SD_BUSY         0x4000
77
#define SD_ERROR        0x8000
78
#define SD_CLEARERR     0x8000
79
#define SD_READ_SECTOR  ((SD_CMD|SD_CLEARERR|SD_FIFO_OP)+17)
80
#define SD_WRITE_SECTOR ((SD_CMD|SD_CLEARERR|SD_WRITEOP)+24)
81
 
82
typedef struct  {
83
        unsigned        sd_ctrl, sd_data, sd_fifo[2];
84
} SDCARD;
85
 
86
 
87
typedef struct  RTCLIGHT_S {
88
        unsigned        r_clock, r_stopwatch, r_timer, r_alarm;
89
} RTCLIGHT;
90
 
91
typedef struct  {
92
        unsigned        g_alpha, g_beta, g_gamma, g_step;
93
} GPSTRACKER;
94
 
95
#define ENET_TXGO               0x004000
96
#define ENET_TXBUSY             0x004000
97
#define ENET_NOHWCRC            0x008000
98
#define ENET_NOHWMAC            0x010000
99
#define ENET_RESET              0x020000
100
#define ENET_NOHWIPCHK          0x040000
101
#define ENET_TXCMD(LEN)         ((LEN)|ENET_TXGO)
102
#define ENET_TXCLR              0x038000
103
#define ENET_TXCANCEL           0x000000
104
#define ENET_RXAVAIL            0x004000
105
#define ENET_RXBUSY             0x008000
106
#define ENET_RXMISS             0x010000
107
#define ENET_RXERR              0x020000
108
#define ENET_RXCRC              0x040000        // Set on a CRC error
109
#define ENET_RXLEN              rxcmd & 0x0ffff
110
#define ENET_RXCLR              0x004000
111
#define ENET_RXBROADCAST        0x080000
112
#define ENET_RXCLRERR           0x078000
113
#define ENET_TXBUFLN(NET)       (1<<(NET.txcmd>>24))
114
#define ENET_RXBUFLN(NET)       (1<<(NET.rxcmd>>24))
115
typedef struct  {
116
        unsigned        n_rxcmd, n_txcmd;
117
        unsigned long   n_mac;
118
        unsigned        n_rxmiss, n_rxerr, n_rxcrc, n_txcol;
119
} ENETPACKET;
120
 
121
 
122
#define OLED_PMODEN             0x0010001
123
#define OLED_PMODEN_OFF         0x0010000
124
#define OLED_IOPWR              OLED_PMODEN
125
#define OLED_VCCEN              0x0020002
126
#define OLED_VCC_DISABLE        0x0020000
127
#define OLED_RESET              0x0040000
128
#define OLED_RESET_CLR          0x0040004
129
#define OLED_FULLPOWER          (OLED_PMODEN|OLED_VCCEN|OLED_RESET_CLR)
130
#define OLED_POWER_DOWN         (OLED_PMODEN_OFF|OLED_VCCEN|OLED_RESET_CLR)
131
#define OLED_BUSY(dev)          (dev.o_ctrl & 1)
132
#define OLED_DISPLAYON          0x0af   // To be sent over the control channel
133
typedef struct {
134
        unsigned        o_ctrl, o_a, o_b, o_data;
135
} OLEDRGB;
136
 
137
typedef struct {
138
        unsigned        tb_maxcount, tb_jump;
139
        unsigned long   tb_err, tb_count, tb_step;
140
} GPSTB;
141
 
142
#define MDIO_BMCR       0x00
143
#define MDIO_BMSR       0x01
144
#define MDIO_PHYIDR1    0x02
145
#define MDIO_PHYIDR2    0x03
146
#define MDIO_ANAR       0x04
147
#define MDIO_ANLPAR     0x05
148
#define MDIO_ANLPARNP   0x05    // Duplicate register address
149
#define MDIO_ANER       0x06
150
#define MDIO_ANNPTR     0x07
151
#define MDIO_PHYSTS     0x10
152
#define MDIO_FCSCR      0x14
153
#define MDIO_RECR       0x15
154
#define MDIO_PCSR       0x16
155
#define MDIO_RBR        0x17
156
#define MDIO_LEDCR      0x18
157
#define MDIO_PHYCR      0x19
158
#define MDIO_BTSCR      0x1a
159
#define MDIO_CDCTRL     0x1b
160
#define MDIO_EDCR       0x1d
161
 
162
typedef struct {
163
        unsigned        e_v[32];
164
} ENETMDIO;
165
 
166
typedef struct {
167
        unsigned        f_ereg, f_status, f_nvconfig, f_vconfig,
168
                        f_evconfig, f_flags, f_lock, f_;
169
        unsigned        f_id[5], f_unused[2];
170
        unsigned        f_otpc, f_otp[16];
171
} EFLASHCTRL;
172
 
173
#define EQSPI_SZPAGE    64
174
#define EQSPI_NPAGES    256
175
#define EQSPI_NSECTORS  256
176
#define EQSPI_SECTORSZ  (EQSPI_SZPAGE * EQSPI_NPAGES)
177
#define EQSPI_SECTOROF(A)       ((A)& (-EQSPI_SECTORSZ))
178
#define EQSPI_SUBSECTOROF(A)    ((A)& (-1<<10))
179
#define EQSPI_PAGEOF(A)         ((A)& (-SZPAGE))
180
#define EQSPI_ERASEFLAG 0xc00001be
181
#define EQSPI_ERASECMD(A)       (EQSPI_ERASEFLAG | EQSPI_SECTOROF(A))
182
#define EQSPI_ENABLEWP  0x00000000
183
#define EQSPI_DISABLEWP 0x40000000
184
 
185
#define UART_PARITY_NONE        0
186
#define UART_HWFLOW_OFF         0x40000000
187
#define UART_PARITY_ODD         0x04000000
188
#define UART_PARITY_EVEN        0x05000000
189
#define UART_PARITY_SPACE       0x06000000
190
#define UART_PARITY_MARK        0x07000000
191
#define UART_STOP_ONEBIT        0
192
#define UART_STOP_TWOBITS       0x08000000
193
#define UART_DATA_8BITS         0
194
#define UART_DATA_7BITS         0x10000000
195
#define UART_DATA_6BITS         0x20000000
196
#define UART_DATA_5BITS         0x30000000
197
#define UART_RX_BREAK           0x0800
198
#define UART_RX_FRAMEERR        0x0400
199
#define UART_RX_PARITYERR       0x0200
200
#define UART_RX_NOTREADY        0x0100
201
#define UART_RX_ERR             (-256)
202
#define UART_TX_BUSY            0x0100
203
#define UART_TX_BREAK           0x0200
204
 
205
typedef struct  WBUART_S {
206
        unsigned        u_setup;
207
        unsigned        u_fifo;
208
        unsigned        u_rx, u_tx;
209
} WBUART;
210
 
211
 
212
#define WBSCOPE_NO_RESET        0x80000000
213
#define WBSCOPE_TRIGGER (WBSCOPE_NO_RESET|0x08000000)
214
#define WBSCOPE_MANUAL  WBSCOPE_TRIGGER
215
#define WBSCOPE_DISABLE 0x04000000      // Disable the scope trigger
216
typedef struct  WBSCOPE_S {
217
        unsigned        s_ctrl, s_data;
218
} WBSCOPE;
219
 
220
 
221
 
222
typedef struct ARTYBOARD_S {
223
        BASICIO         io_b;
224
        WBSCOPE         io_scope[4];
225
        RTCLIGHT        io_rtc;
226
        OLEDRGB         io_oled;
227
        WBUART          io_uart;
228
        WBUART          io_gpsu;
229
        SDCARD          io_sd;
230
        unsigned        io_ignore_0[4];
231
        GPSTRACKER      io_gps;
232
        unsigned        io_ignore_1[4];
233
        GPSTB           io_gpstb;
234
        ENETPACKET      io_enet;
235
        unsigned        io_ignore_2[8];
236
        ENETMDIO        io_netmdio;
237
        EFLASHCTRL      io_eflash;      // 32 positions
238
        unsigned        io_icape2[32];
239
        unsigned        io_ignore_3[0x800-(0x700>>2)];
240
        unsigned        io_enet_rx[1024];
241
        unsigned        io_enet_tx[1024];
242
} ARTYBOARD;
243
 
244
#define PERIPHERAL_ADDR 0x400
245
 
246
static  volatile ARTYBOARD      *const _sys    = (ARTYBOARD *)PERIPHERAL_ADDR;
247
#define _ZIP_HAS_WBUART
248
static  volatile WBUART         *const _uart   = &((ARTYBOARD *)PERIPHERAL_ADDR)->io_uart;
249
#define _ZIP_HAS_WBUARTX
250
#define _uarttx         _uart->u_tx
251
#define _ZIP_HAS_WBUARTRX
252
#define _uartrx         _uart->u_rx
253
#define _ZIP_HAS_UARTSETUP
254
#define _uartsetup      _uart->u_setup
255
 
256
#define _ZIP_HAS_RTC
257
static  volatile RTCLIGHT       *const _rtcdev = &((ARTYBOARD *)PERIPHERAL_ADDR)->io_rtc;
258
#define _ZIP_HAS_RTDATE
259
static  volatile uint32_t       *const _rtdate = &((ARTYBOARD *)PERIPHERAL_ADDR)->io_b.i_rtcdate;
260
#define _ZIP_HAS_SDCARD
261
static  volatile SDCARD         *const _sdcard = &((ARTYBOARD *)PERIPHERAL_ADDR)->io_sd;
262
 
263
#define SYSTIMER        zip->z_tma
264
#define SYSPIC          zip->z_pic
265
#define ALTPIC          zip->z_zpic
266
#define COUNTER         zip->z_m.ac_ck
267
 
268
#define BKRAM   (void *)0x00020000
269
#define FLASH   (void *)0x01000000
270
#define SDRAM   (void *)0x10000000
271
#define CLOCKFREQHZ     81250000
272
#define CLOCKFREQ_HZ    CLOCKFREQHZ
273
//
274
#define MEMLEN          0x00020000
275
#define FLASHLEN        0x01000000
276
#define SDRAMLEN        0x10000000
277
 
278
// Finally, let's assign some of our interrupts:
279
//
280
// We're allowed nine interrupts to the master interrupt controller in the
281
// ZipSys
282
#define SYSINT_PPS      SYSINT(6)
283
#define SYSINT_ENETRX   SYSINT(7)
284
#define SYSINT_ENETTX   SYSINT(8)
285
#define SYSINT_UARTRXF  SYSINT(9)
286
#define SYSINT_UARTTXF  SYSINT(10)
287
#define SYSINT_GPSRXF   SYSINT(11)
288
#define SYSINT_GPSTXF   SYSINT(12)
289
#define SYSINT_BUS      SYSINT(13)
290
#define SYSINT_OLED     SYSINT(14)
291
//
292
#define ALTINT_PPD      ALTINT(8)
293
#define ALTINT_UARTRX   ALTINT(9)
294
#define ALTINT_UARTTX   ALTINT(10)
295
#define ALTINT_GPSRX    ALTINT(11)
296
#define ALTINT_GPSTX    ALTINT(12)
297
//
298
 
299
 
300
// BUS Interrupts
301
#define BUS_BUTTON      SYSINT(0)
302
#define BUS_SWITCH      SYSINT(1)
303
#define BUS_PPS         SYSINT(2)
304
#define BUS_RTC         SYSINT(3)
305
#define BUS_NETRX       SYSINT(4)
306
#define BUS_NETTX       SYSINT(5)
307
#define BUS_UARTRX      SYSINT(6)
308
#define BUS_UARTTX      SYSINT(7)
309
#define BUS_GPIO        SYSINT(8)
310
#define BUS_FLASH       SYSINT(9)
311
#define BUS_SCOPE       SYSINT(10)
312
#define BUS_GPSRX       SYSINT(11)
313
#define BUS_SDCARD      SYSINT(12)
314
#define BUS_OLED        SYSINT(13)
315
// #define      BUS_ZIP SYSINT(14)
316
 
317
 
318
// DMA Interrupt parameters
319
#define DMA_ONPPS       DMA_ONINT(6)
320
#define DMA_ONNETRX     DMA_ONINT(7)
321
#define DMA_ONNETTX     DMA_ONINT(8)
322
#define DMA_ONUARTRXF   DMA_ONINT(9)
323
#define DMA_ONUARTTXF   DMA_ONINT(10)
324
#define DMA_ONGPSRXF    DMA_ONINT(11)
325
#define DMA_ONGPSTXF    DMA_ONINT(12)
326
#define DMA_ONBUS       DMA_ONINT(13)
327
#define DMA_ONOLED      DMA_ONINT(14)
328
 
329
#endif  // define ARTYBOARD_H

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.