| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: com_puc.c,v 1.20 2013/07/22 13:42:17 soren Exp $ */ | | 1 | /* $NetBSD: com_puc.c,v 1.21 2013/07/31 14:31:01 soren Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1998 Christopher G. Demetriou. All rights reserved. | | 4 | * Copyright (c) 1998 Christopher G. Demetriou. All rights reserved. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * 3. All advertising materials mentioning features or use of this software | | 14 | * 3. All advertising materials mentioning features or use of this software |
| @@ -28,27 +28,27 @@ | | | @@ -28,27 +28,27 @@ |
28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | /* | | 33 | /* |
34 | * Machine-independent ns16x50 serial port ('com') driver attachment to | | 34 | * Machine-independent ns16x50 serial port ('com') driver attachment to |
35 | * "PCI Universal Communications" controller driver. | | 35 | * "PCI Universal Communications" controller driver. |
36 | * | | 36 | * |
37 | * Author: Christopher G. Demetriou, May 17, 1998. | | 37 | * Author: Christopher G. Demetriou, May 17, 1998. |
38 | */ | | 38 | */ |
39 | | | 39 | |
40 | #include <sys/cdefs.h> | | 40 | #include <sys/cdefs.h> |
41 | __KERNEL_RCSID(0, "$NetBSD: com_puc.c,v 1.20 2013/07/22 13:42:17 soren Exp $"); | | 41 | __KERNEL_RCSID(0, "$NetBSD: com_puc.c,v 1.21 2013/07/31 14:31:01 soren Exp $"); |
42 | | | 42 | |
43 | #include <sys/param.h> | | 43 | #include <sys/param.h> |
44 | #include <sys/systm.h> | | 44 | #include <sys/systm.h> |
45 | #include <sys/device.h> | | 45 | #include <sys/device.h> |
46 | #include <sys/tty.h> | | 46 | #include <sys/tty.h> |
47 | | | 47 | |
48 | #include <sys/bus.h> | | 48 | #include <sys/bus.h> |
49 | | | 49 | |
50 | #include <dev/pci/pcivar.h> | | 50 | #include <dev/pci/pcivar.h> |
51 | #include <dev/pci/pucvar.h> | | 51 | #include <dev/pci/pucvar.h> |
52 | #include <dev/ic/comreg.h> | | 52 | #include <dev/ic/comreg.h> |
53 | #include <dev/ic/comvar.h> | | 53 | #include <dev/ic/comvar.h> |
54 | #include <dev/pci/cybervar.h> | | 54 | #include <dev/pci/cybervar.h> |
| @@ -80,63 +80,62 @@ com_puc_attach(device_t parent, device_t | | | @@ -80,63 +80,62 @@ com_puc_attach(device_t parent, device_t |
80 | struct com_puc_softc *psc = device_private(self); | | 80 | struct com_puc_softc *psc = device_private(self); |
81 | struct com_softc *sc = &psc->sc_com; | | 81 | struct com_softc *sc = &psc->sc_com; |
82 | struct puc_attach_args *aa = aux; | | 82 | struct puc_attach_args *aa = aux; |
83 | const char *intrstr; | | 83 | const char *intrstr; |
84 | | | 84 | |
85 | sc->sc_dev = self; | | 85 | sc->sc_dev = self; |
86 | | | 86 | |
87 | aprint_naive(": Serial port"); | | 87 | aprint_naive(": Serial port"); |
88 | aprint_normal(": "); | | 88 | aprint_normal(": "); |
89 | | | 89 | |
90 | COM_INIT_REGS(sc->sc_regs, aa->t, aa->h, aa->a); | | 90 | COM_INIT_REGS(sc->sc_regs, aa->t, aa->h, aa->a); |
91 | sc->sc_frequency = aa->flags & PUC_COM_CLOCKMASK; | | 91 | sc->sc_frequency = aa->flags & PUC_COM_CLOCKMASK; |
92 | | | 92 | |
93 | /* Enable Cyberserial 8X clock. */ | | | |
94 | if (aa->flags & (PUC_COM_SIIG10x|PUC_COM_SIIG20x)) { | | | |
95 | int usrregno; | | | |
96 | | | | |
97 | if (aa->flags & PUC_PORT_USR3) usrregno = 3; | | | |
98 | else if (aa->flags & PUC_PORT_USR2) usrregno = 2; | | | |
99 | else if (aa->flags & PUC_PORT_USR1) usrregno = 1; | | | |
100 | else /* (aa->flags & PUC_PORT_USR0) */ usrregno = 0; | | | |
101 | | | | |
102 | if (aa->flags & PUC_COM_SIIG10x) | | | |
103 | write_siig10x_usrreg(aa->pc, aa->tag, usrregno, 1); | | | |
104 | else | | | |
105 | write_siig20x_usrreg(aa->pc, aa->tag, usrregno, 1); | | | |
106 | } else { | | | |
107 | if (!pmf_device_register(self, NULL, com_resume)) | | | |
108 | aprint_error_dev(self, | | | |
109 | "couldn't establish power handler\n"); | | | |
110 | } | | | |
111 | | | | |
112 | intrstr = pci_intr_string(aa->pc, aa->intrhandle); | | 93 | intrstr = pci_intr_string(aa->pc, aa->intrhandle); |
113 | psc->sc_ih = pci_intr_establish(aa->pc, aa->intrhandle, IPL_SERIAL, | | 94 | psc->sc_ih = pci_intr_establish(aa->pc, aa->intrhandle, IPL_SERIAL, |
114 | comintr, sc); | | 95 | comintr, sc); |
115 | if (psc->sc_ih == NULL) { | | 96 | if (psc->sc_ih == NULL) { |
116 | aprint_error("couldn't establish interrupt"); | | 97 | aprint_error("couldn't establish interrupt"); |
117 | if (intrstr != NULL) | | 98 | if (intrstr != NULL) |
118 | aprint_error(" at %s", intrstr); | | 99 | aprint_error(" at %s", intrstr); |
119 | aprint_error("\n"); | | 100 | aprint_error("\n"); |
120 | return; | | 101 | return; |
121 | } | | 102 | } |
122 | | | 103 | |
123 | #if defined(amd64) || defined(i386) | | 104 | #if defined(amd64) || defined(i386) |
124 | /* | | 105 | /* |
125 | * Since puc(4) serial ports are typically not identified in the | | 106 | * Since puc(4) serial ports are typically not identified in the |
126 | * BIOS COM[1234] table, the I/O address must be manually set using | | 107 | * BIOS COM[1234] table, the I/O address must be manually set using |
127 | * installboot(8) in order to enable a serial console. | | 108 | * installboot(8) in order to enable a serial console. |
128 | * Print the address here so the user doesn't have to dig through | | 109 | * Print the address here so the user doesn't have to dig through |
129 | * PCI configuration space to find it. | | 110 | * PCI configuration space to find it. |
130 | */ | | 111 | */ |
131 | if (aa->h < 0x10000) | | 112 | if (aa->h < 0x10000) |
132 | aprint_normal("ioaddr 0x%04lx, ", aa->h); | | 113 | aprint_normal("ioaddr 0x%04lx, ", aa->h); |
133 | #endif | | 114 | #endif |
134 | | | | |
135 | aprint_normal("interrupting at %s\n", intrstr); | | 115 | aprint_normal("interrupting at %s\n", intrstr); |
136 | aprint_normal("%s", device_xname(self)); | | | |
137 | | | 116 | |
| | | 117 | /* Enable Cyberserial 8X clock. */ |
| | | 118 | if (aa->flags & (PUC_COM_SIIG10x|PUC_COM_SIIG20x)) { |
| | | 119 | int usrregno; |
| | | 120 | |
| | | 121 | if (aa->flags & PUC_PORT_USR3) usrregno = 3; |
| | | 122 | else if (aa->flags & PUC_PORT_USR2) usrregno = 2; |
| | | 123 | else if (aa->flags & PUC_PORT_USR1) usrregno = 1; |
| | | 124 | else /* (aa->flags & PUC_PORT_USR0) */ usrregno = 0; |
| | | 125 | |
| | | 126 | if (aa->flags & PUC_COM_SIIG10x) |
| | | 127 | write_siig10x_usrreg(aa->pc, aa->tag, usrregno, 1); |
| | | 128 | else |
| | | 129 | write_siig20x_usrreg(aa->pc, aa->tag, usrregno, 1); |
| | | 130 | } else { |
| | | 131 | if (!pmf_device_register(self, NULL, com_resume)) |
| | | 132 | aprint_error_dev(self, |
| | | 133 | "couldn't establish power handler\n"); |
| | | 134 | } |
| | | 135 | |
| | | 136 | aprint_normal("%s", device_xname(self)); |
138 | com_attach_subr(sc); | | 137 | com_attach_subr(sc); |
139 | } | | 138 | } |
140 | | | 139 | |
141 | CFATTACH_DECL_NEW(com_puc, sizeof(struct com_puc_softc), | | 140 | CFATTACH_DECL_NEW(com_puc, sizeof(struct com_puc_softc), |
142 | com_puc_probe, com_puc_attach, NULL, NULL); | | 141 | com_puc_probe, com_puc_attach, NULL, NULL); |