FreeBSD/Linux Kernel Cross Reference
sys/dev/pci/cyber.c
1 /* $NetBSD: cyber.c,v 1.2 2004/02/04 01:58:44 fredb Exp $ */
2
3 /*-
4 * Copyright (c) 2004 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frederick S. Bruckman.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /* Store one "Usr" register on an SIIG Cyberserial multiport PCI card. */
40
41 #include <sys/cdefs.h>
42 __KERNEL_RCSID(0, "$NetBSD: cyber.c,v 1.2 2004/02/04 01:58:44 fredb Exp $");
43
44 #include <sys/param.h>
45 #include <sys/device.h>
46 #include <sys/termios.h> /* XXX for tcflag_t in comvar.h */
47
48 #include <machine/bus.h>
49
50 #include <dev/pci/cyberreg.h>
51 #include <dev/pci/cybervar.h>
52
53 void
54 write_siig10x_usrreg(pci_chipset_tag_t pc, pcitag_t tag, int usrregno,
55 int high_speed)
56 {
57 pcireg_t curregs, newregs;
58
59 newregs = curregs = pci_conf_read(pc, tag, SIIG10x_USR_BASE);
60
61 if (high_speed) /* Clear bit. */
62 switch (usrregno) {
63 case 0:
64 newregs &= ~SIIG10x_USR0_MASK;
65 break;
66 case 1:
67 newregs &= ~SIIG10x_USR1_MASK;
68 break;
69 case 2:
70 newregs &= ~SIIG10x_USR2_MASK;
71 break;
72 case 3:
73 newregs &= ~SIIG10x_USR3_MASK;
74 }
75 else /* if (!high_speed) */ /* Set bit. */
76 switch (usrregno) {
77 case 0:
78 newregs |= SIIG10x_USR0_MASK;
79 break;
80 case 1:
81 newregs |= SIIG10x_USR1_MASK;
82 break;
83 case 2:
84 newregs |= SIIG10x_USR2_MASK;
85 break;
86 case 3:
87 newregs |= SIIG10x_USR3_MASK;
88 }
89
90 if (newregs != curregs)
91 pci_conf_write(pc, tag, SIIG10x_USR_BASE, newregs);
92 }
93
94 void
95 write_siig20x_usrreg(pci_chipset_tag_t pc, pcitag_t tag, int usrregno,
96 int high_speed)
97 {
98 pcireg_t curreg, newreg;
99 int offset;
100
101 switch (usrregno) {
102 case 0:
103 offset = SIIG20x_USR0;
104 break;
105 case 1:
106 offset = SIIG20x_USR1;
107 break;
108 default:
109 return;
110 }
111
112 newreg = curreg = pci_conf_read(pc, tag, offset);
113
114 if (high_speed) /* Clear bit. */
115 newreg &= ~SIIG20x_USR_MASK;
116 else /* if (!high_speed) */ /* Set bit. */
117 newreg |= SIIG20x_USR_MASK;
118
119 if (newreg != curreg)
120 pci_conf_write(pc, tag, offset, newreg);
121 }
Cache object: 876441e4c3d34eeaa0c105821448c412
|