1/*-
2 * Copyright (c) 2013-2014 Bjoern A. Zeeb
3 * All rights reserved.
4 *
5 * This software was developed by SRI International and the University of
6 * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-11-C-0249
7 * ("MRC2"), as part of the DARPA MRC research programme.
8 *
--- 18 unchanged lines hidden (view full) ---
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * This driver is modelled after atse(4). We need to seriously reduce the
31 * per-driver code we have to write^wcopy & paste.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/dev/netfpga10g/nf10bmac/if_nf10bmac_fdt.c 267920 2014-06-26 17:10:07Z bz $");
36
37#include <sys/param.h>
38#include <sys/bus.h>
39#include <sys/kernel.h>
40#include <sys/module.h>
41#include <sys/rman.h>
42#include <sys/socket.h>
43#include <sys/systm.h>
--- 41 unchanged lines hidden (view full) ---
85 /*
86 * FDT lists our resources. For convenience we use three different
87 * mappings. We need to attach them in the oder specified in .dts:
88 * LOOP (size 0x1f), TX (0x2f), RX (0x2f), INTR (0xf).
89 */
90
91 /*
92 * LOOP memory region (this could be a general control region).
93 * 0x00: 32/64bit register to enable a Y-"lopback".
94 */
95 sc->nf10bmac_ctrl_rid = 0;
96 sc->nf10bmac_ctrl_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
97 &sc->nf10bmac_ctrl_rid, RF_ACTIVE);
98 if (sc->nf10bmac_ctrl_res == NULL) {
99 device_printf(dev, "failed to map memory for CTRL region\n");
100 error = ENXIO;
101 goto err;
102 }
103 if (bootverbose)
104 device_printf(sc->nf10bmac_dev, "CTRL region at mem %p-%p\n",
105 (void *)rman_get_start(sc->nf10bmac_ctrl_res),
106 (void *)(rman_get_start(sc->nf10bmac_ctrl_res) +
107 rman_get_size(sc->nf10bmac_ctrl_res)));
108
109 /*
110 * TX and TX metadata FIFO memory region.
111 * 0x00: 32/64bit FIFO data,
112 * 0x08: 32/64bit FIFO metadata,
113 * 0x10: 32/64bit packet length.
114 */
115 sc->nf10bmac_tx_mem_rid = 1;
116 sc->nf10bmac_tx_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
117 &sc->nf10bmac_tx_mem_rid, RF_ACTIVE);
118 if (sc->nf10bmac_tx_mem_res == NULL) {
119 device_printf(dev, "failed to map memory for TX FIFO\n");
120 error = ENXIO;
121 goto err;
122 }
123 if (bootverbose)
124 device_printf(sc->nf10bmac_dev, "TX FIFO at mem %p-%p\n",
125 (void *)rman_get_start(sc->nf10bmac_tx_mem_res),
126 (void *)(rman_get_start(sc->nf10bmac_tx_mem_res) +
127 rman_get_size(sc->nf10bmac_tx_mem_res)));
128
129 /*
130 * RX and RXC metadata FIFO memory region.
131 * 0x00: 32/64bit FIFO data,
132 * 0x08: 32/64bit FIFO metadata,
133 * 0x10: 32/64bit packet length.
134 */
135 sc->nf10bmac_rx_mem_rid = 2;
136 sc->nf10bmac_rx_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
137 &sc->nf10bmac_rx_mem_rid, RF_ACTIVE);
138 if (sc->nf10bmac_rx_mem_res == NULL) {
139 device_printf(dev, "failed to map memory for RX FIFO\n");
140 error = ENXIO;
141 goto err;
142 }
143 if (bootverbose)
144 device_printf(sc->nf10bmac_dev, "RX FIFO at mem %p-%p\n",
145 (void *)rman_get_start(sc->nf10bmac_rx_mem_res),
146 (void *)(rman_get_start(sc->nf10bmac_rx_mem_res) +
147 rman_get_size(sc->nf10bmac_rx_mem_res)));
148
149 /*
150 * Interrupt handling registers.
151 * 0x00: 32/64bit register to clear (and disable) the RX interrupt.
152 * 0x08: 32/64bit register to enable or disable the RX interrupt.
153 */
154 sc->nf10bmac_intr_rid = 3;
155 sc->nf10bmac_intr_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
156 &sc->nf10bmac_intr_rid, RF_ACTIVE);
157 if (sc->nf10bmac_intr_res == NULL) {
158 device_printf(dev, "failed to map memory for INTR region\n");
159 error = ENXIO;
160 goto err;
--- 43 unchanged lines hidden ---
2 * Copyright (c) 2013-2014 Bjoern A. Zeeb
3 * All rights reserved.
4 *
5 * This software was developed by SRI International and the University of
6 * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-11-C-0249
7 * ("MRC2"), as part of the DARPA MRC research programme.
8 *
--- 18 unchanged lines hidden (view full) ---
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * This driver is modelled after atse(4). We need to seriously reduce the
31 * per-driver code we have to write^wcopy & paste.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/dev/netfpga10g/nf10bmac/if_nf10bmac_fdt.c 267920 2014-06-26 17:10:07Z bz $");
36
37#include <sys/param.h>
38#include <sys/bus.h>
39#include <sys/kernel.h>
40#include <sys/module.h>
41#include <sys/rman.h>
42#include <sys/socket.h>
43#include <sys/systm.h>
--- 41 unchanged lines hidden (view full) ---
85 /*
86 * FDT lists our resources. For convenience we use three different
87 * mappings. We need to attach them in the oder specified in .dts:
88 * LOOP (size 0x1f), TX (0x2f), RX (0x2f), INTR (0xf).
89 */
90
91 /*
92 * LOOP memory region (this could be a general control region).
93 * 0x00: 32/64bit register to enable a Y-"lopback".
94 */
95 sc->nf10bmac_ctrl_rid = 0;
96 sc->nf10bmac_ctrl_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
97 &sc->nf10bmac_ctrl_rid, RF_ACTIVE);
98 if (sc->nf10bmac_ctrl_res == NULL) {
99 device_printf(dev, "failed to map memory for CTRL region\n");
100 error = ENXIO;
101 goto err;
102 }
103 if (bootverbose)
104 device_printf(sc->nf10bmac_dev, "CTRL region at mem %p-%p\n",
105 (void *)rman_get_start(sc->nf10bmac_ctrl_res),
106 (void *)(rman_get_start(sc->nf10bmac_ctrl_res) +
107 rman_get_size(sc->nf10bmac_ctrl_res)));
108
109 /*
110 * TX and TX metadata FIFO memory region.
111 * 0x00: 32/64bit FIFO data,
112 * 0x08: 32/64bit FIFO metadata,
113 * 0x10: 32/64bit packet length.
114 */
115 sc->nf10bmac_tx_mem_rid = 1;
116 sc->nf10bmac_tx_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
117 &sc->nf10bmac_tx_mem_rid, RF_ACTIVE);
118 if (sc->nf10bmac_tx_mem_res == NULL) {
119 device_printf(dev, "failed to map memory for TX FIFO\n");
120 error = ENXIO;
121 goto err;
122 }
123 if (bootverbose)
124 device_printf(sc->nf10bmac_dev, "TX FIFO at mem %p-%p\n",
125 (void *)rman_get_start(sc->nf10bmac_tx_mem_res),
126 (void *)(rman_get_start(sc->nf10bmac_tx_mem_res) +
127 rman_get_size(sc->nf10bmac_tx_mem_res)));
128
129 /*
130 * RX and RXC metadata FIFO memory region.
131 * 0x00: 32/64bit FIFO data,
132 * 0x08: 32/64bit FIFO metadata,
133 * 0x10: 32/64bit packet length.
134 */
135 sc->nf10bmac_rx_mem_rid = 2;
136 sc->nf10bmac_rx_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
137 &sc->nf10bmac_rx_mem_rid, RF_ACTIVE);
138 if (sc->nf10bmac_rx_mem_res == NULL) {
139 device_printf(dev, "failed to map memory for RX FIFO\n");
140 error = ENXIO;
141 goto err;
142 }
143 if (bootverbose)
144 device_printf(sc->nf10bmac_dev, "RX FIFO at mem %p-%p\n",
145 (void *)rman_get_start(sc->nf10bmac_rx_mem_res),
146 (void *)(rman_get_start(sc->nf10bmac_rx_mem_res) +
147 rman_get_size(sc->nf10bmac_rx_mem_res)));
148
149 /*
150 * Interrupt handling registers.
151 * 0x00: 32/64bit register to clear (and disable) the RX interrupt.
152 * 0x08: 32/64bit register to enable or disable the RX interrupt.
153 */
154 sc->nf10bmac_intr_rid = 3;
155 sc->nf10bmac_intr_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
156 &sc->nf10bmac_intr_rid, RF_ACTIVE);
157 if (sc->nf10bmac_intr_res == NULL) {
158 device_printf(dev, "failed to map memory for INTR region\n");
159 error = ENXIO;
160 goto err;
--- 43 unchanged lines hidden ---