xref: /openbsd/sys/dev/ic/bcmgenetvar.h (revision 905646f0)
1 /* $OpenBSD: bcmgenetvar.h,v 1.1 2020/04/14 21:02:39 kettenis Exp $ */
2 /* $NetBSD: bcmgenetvar.h,v 1.1 2020/02/22 00:28:35 jmcneill Exp $ */
3 
4 /*-
5  * Copyright (c) 2020 Jared McNeill <jmcneill@invisible.ca>
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 /*
31  * Broadcom GENETv5
32  */
33 
34 #ifndef _BCMGENETVAR_H
35 #define _BCMGENETVAR_H
36 
37 #include <dev/ic/bcmgenetreg.h>
38 
39 enum genet_phy_mode {
40 	GENET_PHY_MODE_RGMII,
41 	GENET_PHY_MODE_RGMII_ID,
42 	GENET_PHY_MODE_RGMII_TXID,
43 	GENET_PHY_MODE_RGMII_RXID,
44 };
45 
46 struct genet_bufmap {
47 	bus_dmamap_t		map;
48 	struct mbuf		*mbuf;
49 };
50 
51 struct genet_ring {
52 	bus_dma_tag_t		buf_tag;
53 	struct genet_bufmap	buf_map[GENET_DMA_DESC_COUNT];
54 	u_int			next, queued;
55 	uint32_t		cidx, pidx;
56 };
57 
58 struct genet_softc {
59 	struct device		sc_dev;
60 	bus_space_tag_t		sc_bst;
61 	bus_space_handle_t	sc_bsh;
62 	bus_dma_tag_t		sc_dmat;
63 	int			sc_phy_id;
64 	enum genet_phy_mode	sc_phy_mode;
65 
66 	void			*sc_ih;
67 
68 	struct arpcom		sc_ac;
69 #define sc_lladdr	sc_ac.ac_enaddr
70 	struct mii_data		sc_mii;
71 	struct timeout		sc_stat_ch;
72 
73 	struct genet_ring	sc_tx;
74 	struct genet_ring	sc_rx;
75 	struct if_rxring	sc_rx_ring;
76 	struct timeout		sc_rxto;
77 };
78 
79 int	genet_attach(struct genet_softc *);
80 int	genet_intr(void *);
81 void	genet_lladdr_read(struct genet_softc *, uint8_t *);
82 
83 #endif /* !_BCMGENETVAR_H */
84