1 /* $NetBSD: apci.c,v 1.9 2006/07/19 19:23:56 tsutsui Exp $ */
4 * Copyright (c) 1997, 1999 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Copyright (c) 1990, 1993
34 * The Regents of the University of California. All rights reserved.
36 * This code is derived from software contributed to Berkeley by
37 * the Systems Programming Group of the University of Utah Computer
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
43 * 1. Redistributions of source code must retain the above copyright
44 * notice, this list of conditions and the following disclaimer.
45 * 2. Redistributions in binary form must reproduce the above copyright
46 * notice, this list of conditions and the following disclaimer in the
47 * documentation and/or other materials provided with the distribution.
48 * 3. Neither the name of the University nor the names of its contributors
49 * may be used to endorse or promote products derived from this software
50 * without specific prior written permission.
52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * @(#)dca.c 8.1 (Berkeley) 6/10/93
67 * Copyright (c) 1988 University of Utah.
69 * This code is derived from software contributed to Berkeley by
70 * the Systems Programming Group of the University of Utah Computer
73 * Redistribution and use in source and binary forms, with or without
74 * modification, are permitted provided that the following conditions
76 * 1. Redistributions of source code must retain the above copyright
77 * notice, this list of conditions and the following disclaimer.
78 * 2. Redistributions in binary form must reproduce the above copyright
79 * notice, this list of conditions and the following disclaimer in the
80 * documentation and/or other materials provided with the distribution.
81 * 3. All advertising materials mentioning features or use of this software
82 * must display the following acknowledgement:
83 * This product includes software developed by the University of
84 * California, Berkeley and its contributors.
85 * 4. Neither the name of the University nor the names of its contributors
86 * may be used to endorse or promote products derived from this software
87 * without specific prior written permission.
89 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
90 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
91 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
92 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
93 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
94 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
95 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
96 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
97 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
98 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
101 * @(#)dca.c 8.1 (Berkeley) 6/10/93
105 #include <sys/param.h>
106 #include <dev/cons.h>
108 #include <lib/libsa/stand.h>
110 #include <hp300/dev/frodoreg.h> /* for APCI offsets */
111 #include <hp300/dev/intioreg.h> /* for frodo offsets */
113 #include <hp300/stand/common/apcireg.h> /* for register map */
114 #include <hp300/stand/common/dcareg.h> /* for register bits */
115 #include <hp300/stand/common/consdefs.h>
116 #include <hp300/stand/common/samachdep.h>
118 struct apciregs
*apcicnaddr
= 0;
121 apciprobe(struct consdev
*cp
)
124 apcicnaddr
= (void *)IIOV(FRODO_BASE
+ FRODO_APCI_OFFSET(1));
126 cp
->cn_pri
= CN_DEAD
;
129 * Only a 425e can have an APCI console. On all other 4xx models,
130 * the "first" serial port is mapped to the DCA at select code 9.
132 if (machineid
!= HP_425
|| mmuid
!= MMUID_425_E
)
135 #ifdef FORCEAPCICONSOLE
136 cp
->cn_pri
= CN_REMOTE
;
138 cp
->cn_pri
= CN_NORMAL
;
144 apciinit(struct consdev
*cp
)
146 struct apciregs
*apci
= (struct apciregs
*)apcicnaddr
;
149 * The only system on which this will happen is a 425e,
150 * which does not currently have a framebuffer console
151 * driver. We use the ROM's output method to let the
152 * operator know we're switching to the APCI.
155 printf("Switching to APCI console.\n");
158 apci
->ap_cfcr
= CFCR_DLAB
;
159 apci
->ap_data
= APCIBRD(9600) & 0xff;
160 apci
->ap_ier
= (APCIBRD(9600) >> 8) & 0xff;
161 apci
->ap_cfcr
= CFCR_8BITS
;
163 FIFO_ENABLE
| FIFO_RCV_RST
| FIFO_XMT_RST
| FIFO_TRIGGER_1
;
164 apci
->ap_mcr
= MCR_DTR
| MCR_RTS
;
170 apcigetchar(dev_t dev
)
172 struct apciregs
*apci
= apcicnaddr
;
176 if (((stat
= apci
->ap_lsr
) & LSR_RXRDY
) == 0)
183 apcigetchar(dev_t dev
)
192 apciputchar(dev_t dev
, int c
)
194 struct apciregs
*apci
= apcicnaddr
;
198 /* wait a reasonable time for the transmitter to come ready */
200 while (((stat
= apci
->ap_lsr
) & LSR_TXRDY
) == 0 && --timo
)
203 /* wait for this transmission to complete */
205 while (((stat
= apci
->ap_lsr
) & LSR_TXRDY
) == 0 && --timo
)