]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/cm/smc90cx6var.h
Partial merge of the SPDX changes
[FreeBSD/FreeBSD.git] / sys / dev / cm / smc90cx6var.h
1 /*      $NetBSD: smc90cx6var.h,v 1.5 2000/03/23 07:01:32 thorpej Exp $  */
2 /*      $FreeBSD$ */
3
4 /*-
5  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
6  *
7  * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc.
8  * All rights reserved.
9  *
10  * This code is derived from software contributed to The NetBSD Foundation
11  * by Ignatios Souvatzis.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  */
34
35 /*
36  * BAH (SMC 8bit ARCnet chipset) k/dpi
37  *
38  * The SMC 8bit ARCnet chip family uses a register and a memory window, which
39  * we get passed via bus_space_tags and bus_space_handles.
40  *
41  * As the reset functionality differs between the Amiga boards (using the
42  * 90c26 chip) and middle-aged ISA boards (using the 90c56 chip), we have
43  * a sc_reset callback function in the softc, which does a stop function
44  * (reset and leave dead) or a reset function depending on wether the 2nd
45  * parameter is 0 or 1.
46  */
47
48 #ifndef _SMC90CX6VAR_H_
49 #define _SMC90CX6VAR_H_
50
51 #include <sys/callout.h>
52
53 struct cm_softc {
54         struct  ifnet   *sc_ifp;        /* Common arcnet structures */
55         struct  mtx     sc_mtx;         /* sc mutex */
56
57         int     port_rid;               /* resource id for port range */
58         struct resource *port_res;      /* resource for port range */
59
60         int     mem_rid;                /* resource id for memory range */
61         struct resource *mem_res;       /* resource for memory range */
62
63         int     irq_rid;                /* resource id for irq */
64         struct resource *irq_res;       /* resource for irq */
65         void *  irq_handle;             /* handle for irq handler */
66
67         void    *sc_rxcookie;           /* softcallback cookies */
68         void    *sc_txcookie;
69         struct callout sc_recon_ch;
70         u_long  sc_recontime;           /* seconds only, I'm lazy */
71         u_long  sc_reconcount;          /* for the above */
72         u_long  sc_reconcount_excessive; /* for the above */
73 #define ARC_EXCESSIVE_RECONS 20
74 #define ARC_EXCESSIVE_RECONS_REWARN 400
75         struct callout sc_watchdog_timer;
76         int     sc_timer;
77         u_char  sc_intmask;
78         u_char  sc_rx_act;              /* 2..3 */
79         u_char  sc_tx_act;              /* 0..1 */
80         u_char  sc_rx_fillcount;
81         u_char  sc_tx_fillcount;
82         u_char  sc_broadcast[2];        /* is it a broadcast packet? */
83         u_char  sc_retransmits[2];      /* unused at the moment */
84 };
85
86 int     cm_attach(device_t dev);
87 void    cmintr(void *);
88 void    cm_stop_locked(struct cm_softc *sc);
89 void    cm_release_resources(device_t dev);
90
91 extern  devclass_t cm_devclass;
92
93 #define CM_LOCK(sc)     mtx_lock(&(sc)->sc_mtx)
94 #define CM_UNLOCK(sc)   mtx_unlock(&(sc)->sc_mtx)
95
96 /* short notation */
97 #define GETREG(off)                                                     \
98         bus_space_read_1(rman_get_bustag((sc)->port_res),               \
99                          rman_get_bushandle((sc)->port_res),            \
100                          (off))
101 #define PUTREG(off, value)                                              \
102         bus_space_write_1(rman_get_bustag((sc)->port_res),              \
103                           rman_get_bushandle((sc)->port_res),           \
104                           (off), (value))
105 #define GETMEM(off)                                                     \
106         bus_space_read_1(rman_get_bustag((sc)->mem_res),                \
107                          rman_get_bushandle((sc)->mem_res),             \
108                          (off))
109 #define PUTMEM(off, value)                                              \
110         bus_space_write_1(rman_get_bustag((sc)->mem_res),               \
111                           rman_get_bushandle((sc)->mem_res),            \
112                           (off), (value))
113
114 #endif