1 |
4 |
DFC |
/***************************************************************************
|
2 |
|
|
*
|
3 |
|
|
* (C) Copyright 2017 DFC Design, s.r.o., Brno, Czech Republic
|
4 |
|
|
* Author: Marek Kvas (m.kvas@dspfpga.com)
|
5 |
|
|
*
|
6 |
|
|
***************************************************************************
|
7 |
|
|
*
|
8 |
|
|
* This file is part of Xenia Ethernet Example project.
|
9 |
|
|
*
|
10 |
|
|
* Xenia Ethernet Example project is free software: you can
|
11 |
|
|
* redistribute it and/or modify it under the terms of
|
12 |
|
|
* the GNU Lesser General Public License as published by the Free
|
13 |
|
|
* Software Foundation, either version 3 of the License, or
|
14 |
|
|
* (at your option) any later version.
|
15 |
|
|
*
|
16 |
|
|
* Xenia Ethernet Example project is distributed in the hope that
|
17 |
|
|
* it will be useful, but WITHOUT ANY WARRANTY; without even
|
18 |
|
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
19 |
|
|
* PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
20 |
|
|
* for more details.
|
21 |
|
|
*
|
22 |
|
|
* You should have received a copy of the GNU Lesser General Public
|
23 |
|
|
* License along with Xenia Ethernet Example project. If not,
|
24 |
|
|
* see <http://www.gnu.org/licenses/>.
|
25 |
|
|
*
|
26 |
|
|
***************************************************************************
|
27 |
|
|
*/
|
28 |
|
|
|
29 |
|
|
#ifndef __GPIO_H__
|
30 |
|
|
#define __GPIO_H__
|
31 |
|
|
|
32 |
|
|
struct gpio_inst {
|
33 |
|
|
u32 baseAddr;
|
34 |
|
|
volatile u32 gpio_odata[2];
|
35 |
|
|
};
|
36 |
|
|
|
37 |
|
|
/* The first core IO 0*/
|
38 |
|
|
#define GPIO0_BANK 0
|
39 |
|
|
#define GPIO0_RXAUI_RESET (1<<0)
|
40 |
|
|
#define GPIO0_ETH_PHY_RESET_N (1<<1)
|
41 |
|
|
|
42 |
|
|
#define GPIO0_RXAUI_CLK156_LOCK (1<<2)
|
43 |
|
|
#define GPIO0_RXAUI_QPLLLOCK (1<<3)
|
44 |
|
|
|
45 |
|
|
#define GPIO0_RXAUI_DEBUG_SHIFT 4
|
46 |
|
|
#define GPIO0_RXAUI_DEBUG_MASK (0x3f<<GPIO0_RXAUI_DEBUG_SHIFT)
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
#define GPIO0_ETH_PHY_CLK_SEL (1<<10)
|
50 |
|
|
#define GPIO0_ALL_SRC_PG (1<<11)
|
51 |
|
|
|
52 |
|
|
#define GPIO0_LED1 (1<<12)
|
53 |
|
|
|
54 |
|
|
#define GPIO0_FRAME_GEN_NRST (1<<13)
|
55 |
|
|
#define GPIO0_XGMII_LOOPBACK (1<<14)
|
56 |
|
|
|
57 |
|
|
/* The first core IO 1*/
|
58 |
|
|
#define GPIO1_BANK 1
|
59 |
|
|
#define GPIO1_PKT_GEN_IPG_SHIFT (0)
|
60 |
|
|
#define GPIO1_PKT_GEN_IPG_MASK (0xffff<<(GPIO1_PKT_GEN_IPG_SHIFT))
|
61 |
|
|
#define GPIO1_PKT_GEN_LEN_SHIFT (16)
|
62 |
|
|
#define GPIO1_PKT_GEN_LEN_MASK (0xffff<<(GPIO1_PKT_GEN_LEN_SHIFT))
|
63 |
|
|
|
64 |
|
|
/* The second core IO 0*/
|
65 |
|
|
#define GPIO2_BANK 2
|
66 |
|
|
/* The second core IO 1*/
|
67 |
|
|
#define GPIO3_BANK 3
|
68 |
|
|
#define VERSION_GPIO_0_BANK GPIO2_BANK
|
69 |
|
|
#define VERSION_GPIO_1_BANK GPIO3_BANK
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
/* The third core IO 0*/
|
73 |
|
|
#define GPIO4_BANK 4
|
74 |
|
|
#define GPIO4_HOST_MAC0_SHIFT (0)
|
75 |
|
|
#define GPIO4_HOST_MAC0_MASK (0xffffffff<<(GPIO4_HOST_MAC0_SHIFT))
|
76 |
|
|
#define GPIO4_DIR_HOST_MAC1_SHIFT (0)
|
77 |
|
|
#define GPIO4_DIR_HOST_MAC1_MASK (0xffff<<(GPIO4_DIR_HOST_MAC1_SHIFT))
|
78 |
|
|
#define GPIO4_DIR_LINK_SPEED_SHIFT (16)
|
79 |
|
|
#define GPIO4_DIR_LINK_SPEED_MASK (0x7<<(GPIO4_DIR_LINK_SPEED_SHIFT))
|
80 |
|
|
/* The third core IO 1*/
|
81 |
|
|
#define GPIO5_BANK 5
|
82 |
|
|
#define GPIO5_HOST_IP_SHIFT (0)
|
83 |
|
|
#define GPIO5_HOST_IP_MASK (0xffffffff<<(GPIO5_HOST_IP_SHIFT))
|
84 |
|
|
#define GPIO5_DIR_HOST_NETMASK_SHIFT (0)
|
85 |
|
|
#define GPIO5_DIR_HOST_NETMASK_MASK (0xffffffff<<(GPIO5_DIR_HOST_NETMASK_SHIFT))
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
void gpio_set_dir(int bank, u32 val);
|
93 |
|
|
void gpio_clear_dir(int bank, u32 val);
|
94 |
|
|
u32 gpio_get(int bank);
|
95 |
|
|
u32 gpio_get_dir(int bank);
|
96 |
|
|
void gpio_set_out(int bank, u32 val);
|
97 |
|
|
void gpio_clear_out(int bank, u32 val);
|
98 |
|
|
int gpio_wait_for_one_set(int bank, u32 gpioMask, u32 timeout_ms, void (*long_waiting_routine)(void* params), void *params);
|
99 |
|
|
void gpio_set_field(int bank, u32 mask, u32 shift, u32 val);
|
100 |
|
|
void gpio_set_dir_field(int bank, u32 mask, u32 shift, u32 val);
|
101 |
|
|
u32 gpio_get_field(int bank, u32 mask, u32 shift);
|
102 |
|
|
u32 gpio_get_dir_field(int bank, u32 mask, u32 shift);
|
103 |
|
|
|
104 |
|
|
void gpio_led(int led, int val);
|
105 |
|
|
|
106 |
|
|
int gpio_banks_available();
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
// Control functions for various gpio based regs
|
110 |
|
|
//void set_gpio_reg(u8 off, u32 value);
|
111 |
|
|
//u32 get_gpio_reg(u8 off);
|
112 |
|
|
void init_gpio_regs();
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
#endif /* __GPIO_H__ */
|
116 |
|
|
|