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