2 * Copyright (c) 2011-2012 Semihalf.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * @group dTSEC common API.
36 #define DTSEC_MODE_REGULAR 0
37 #define DTSEC_MODE_INDEPENDENT 1
39 #define DTSEC_LOCK(sc) mtx_lock(&(sc)->sc_lock)
40 #define DTSEC_UNLOCK(sc) mtx_unlock(&(sc)->sc_lock)
41 #define DTSEC_LOCK_ASSERT(sc) mtx_assert(&(sc)->sc_lock, MA_OWNED)
42 #define DTSEC_MII_LOCK(sc) mtx_lock(&(sc)->sc_mii_lock)
43 #define DTSEC_MII_UNLOCK(sc) mtx_unlock(&(sc)->sc_mii_lock)
51 /* XXX MII bus requires that struct ifnet is first!!! */
52 struct ifnet *sc_ifnet;
59 int (*sc_port_rx_init)
60 (struct dtsec_softc *sc, int unit);
61 int (*sc_port_tx_init)
62 (struct dtsec_softc *sc, int unit);
63 void (*sc_start_locked)
64 (struct dtsec_softc *sc);
67 enum eth_dev_type sc_eth_dev_type;
69 uintptr_t sc_mac_mem_offset;
70 e_EnetMode sc_mac_enet_mode;
72 uint8_t sc_mac_addr[6];
75 uint32_t sc_port_tx_qman_chan;
80 /* Params from fman_bus driver */
81 vm_offset_t sc_fm_base;
90 struct mii_data *sc_mii;
92 struct mtx sc_mii_lock;
94 struct callout sc_tick_callout;
99 uma_zone_t sc_rx_zone;
100 char sc_rx_zname[64];
109 t_Handle sc_tx_conf_fqr;
110 uint32_t sc_tx_conf_fqid;
112 /* Frame Info Zone */
113 uma_zone_t sc_fi_zone;
114 char sc_fi_zname[64];
120 * @group dTSEC FMan PORT API.
123 enum dtsec_fm_port_params {
124 FM_PORT_LIODN_BASE = 0,
125 FM_PORT_LIODN_OFFSET = 0,
127 FM_PORT_MEM_ATTR = MEMORY_ATTR_CACHEABLE,
128 FM_PORT_BUFFER_SIZE = MCLBYTES,
131 e_FmPortType dtsec_fm_port_rx_type(enum eth_dev_type type);
132 void dtsec_fm_port_rx_exception_callback(t_Handle app,
133 e_FmPortExceptions exception);
134 void dtsec_fm_port_tx_exception_callback(t_Handle app,
135 e_FmPortExceptions exception);
136 e_FmPortType dtsec_fm_port_tx_type(enum eth_dev_type type);
141 * @group dTSEC bus interface.
144 int dtsec_attach(device_t dev);
145 int dtsec_detach(device_t dev);
146 int dtsec_suspend(device_t dev);
147 int dtsec_resume(device_t dev);
148 int dtsec_shutdown(device_t dev);
149 int dtsec_miibus_readreg(device_t dev, int phy, int reg);
150 int dtsec_miibus_writereg(device_t dev, int phy, int reg,
152 void dtsec_miibus_statchg(device_t dev);
155 #endif /* IF_DTSEC_H_ */