Sun Jan 26 10:54:24 2014 UTC ()
PUCCN improvements:
 - Fix a bug that the puc cn mechanism doesn't use the UART's frequency
   in pucdata.c's table.

 - Add a new option PUC_CNAUTO. If this option is set, consinit() in
   x86/x86/consinit.c checks puc com device to use it as console.
   Without this option, the behavior is the same as before.

 - Add a new config parameter PUC_CNBUS. The old code scans bus #0 only.
   If PUC_CNBUS is set, the specified number's bus will be scanned.

 - Rename comcnprobe() to puc_cnprobe() to make it clear.

 - Rename comcninit() to puc_cninit() to make it clear.

 - Add code for a device that a device's com register is MMIO (#if0 ed).


(msaitoh)
diff -r1.63 -r1.64 src/sys/arch/x86/pci/pci_machdep.c
diff -r1.24 -r1.25 src/sys/arch/x86/x86/consinit.c
diff -r1.368 -r1.369 src/sys/dev/pci/files.pci
diff -r1.12 -r1.13 src/sys/dev/pci/puccn.c
diff -r1.5 -r1.6 src/sys/dev/pci/puccn.h

cvs diff -r1.63 -r1.64 src/sys/arch/x86/pci/pci_machdep.c (expand / switch to unified diff)

--- src/sys/arch/x86/pci/pci_machdep.c 2013/12/25 17:24:39 1.63
+++ src/sys/arch/x86/pci/pci_machdep.c 2014/01/26 10:54:24 1.64
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pci_machdep.c,v 1.63 2013/12/25 17:24:39 jakllsch Exp $ */ 1/* $NetBSD: pci_machdep.c,v 1.64 2014/01/26 10:54:24 msaitoh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. 4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -63,27 +63,27 @@ @@ -63,27 +63,27 @@
63/* 63/*
64 * Machine-specific functions for PCI autoconfiguration. 64 * Machine-specific functions for PCI autoconfiguration.
65 * 65 *
66 * On PCs, there are two methods of generating PCI configuration cycles. 66 * On PCs, there are two methods of generating PCI configuration cycles.
67 * We try to detect the appropriate mechanism for this machine and set 67 * We try to detect the appropriate mechanism for this machine and set
68 * up a few function pointers to access the correct method directly. 68 * up a few function pointers to access the correct method directly.
69 * 69 *
70 * The configuration method can be hard-coded in the config file by 70 * The configuration method can be hard-coded in the config file by
71 * using `options PCI_CONF_MODE=N', where `N' is the configuration mode 71 * using `options PCI_CONF_MODE=N', where `N' is the configuration mode
72 * as defined in section 3.6.4.1, `Generating Configuration Cycles'. 72 * as defined in section 3.6.4.1, `Generating Configuration Cycles'.
73 */ 73 */
74 74
75#include <sys/cdefs.h> 75#include <sys/cdefs.h>
76__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.63 2013/12/25 17:24:39 jakllsch Exp $"); 76__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.64 2014/01/26 10:54:24 msaitoh Exp $");
77 77
78#include <sys/types.h> 78#include <sys/types.h>
79#include <sys/param.h> 79#include <sys/param.h>
80#include <sys/time.h> 80#include <sys/time.h>
81#include <sys/systm.h> 81#include <sys/systm.h>
82#include <sys/errno.h> 82#include <sys/errno.h>
83#include <sys/device.h> 83#include <sys/device.h>
84#include <sys/bus.h> 84#include <sys/bus.h>
85#include <sys/cpu.h> 85#include <sys/cpu.h>
86#include <sys/kmem.h> 86#include <sys/kmem.h>
87 87
88#include <uvm/uvm_extern.h> 88#include <uvm/uvm_extern.h>
89 89
@@ -100,26 +100,27 @@ __KERNEL_RCSID(0, "$NetBSD: pci_machdep. @@ -100,26 +100,27 @@ __KERNEL_RCSID(0, "$NetBSD: pci_machdep.
100#include <dev/pci/pcidevs.h> 100#include <dev/pci/pcidevs.h>
101#include <dev/pci/genfb_pcivar.h> 101#include <dev/pci/genfb_pcivar.h>
102 102
103#include <dev/wsfb/genfbvar.h> 103#include <dev/wsfb/genfbvar.h>
104#include <arch/x86/include/genfb_machdep.h> 104#include <arch/x86/include/genfb_machdep.h>
105#include <dev/ic/vgareg.h> 105#include <dev/ic/vgareg.h>
106 106
107#include "acpica.h" 107#include "acpica.h"
108#include "genfb.h" 108#include "genfb.h"
109#include "isa.h" 109#include "isa.h"
110#include "opt_acpi.h" 110#include "opt_acpi.h"
111#include "opt_ddb.h" 111#include "opt_ddb.h"
112#include "opt_mpbios.h" 112#include "opt_mpbios.h"
 113#include "opt_puc.h"
113#include "opt_vga.h" 114#include "opt_vga.h"
114#include "pci.h" 115#include "pci.h"
115#include "wsdisplay.h" 116#include "wsdisplay.h"
116#include "com.h" 117#include "com.h"
117 118
118#ifdef DDB 119#ifdef DDB
119#include <machine/db_machdep.h> 120#include <machine/db_machdep.h>
120#include <ddb/db_sym.h> 121#include <ddb/db_sym.h>
121#include <ddb/db_extern.h> 122#include <ddb/db_extern.h>
122#endif 123#endif
123 124
124#ifdef VGA_POST 125#ifdef VGA_POST
125#include <x86/vga_post.h> 126#include <x86/vga_post.h>
@@ -953,24 +954,31 @@ device_pci_register(device_t dev, void * @@ -953,24 +954,31 @@ device_pci_register(device_t dev, void *
953 prop_dictionary_set_uint64(dict, 954 prop_dictionary_set_uint64(dict,
954 "pmf_callback", (uint64_t)(uintptr_t)&pmf_cb); 955 "pmf_callback", (uint64_t)(uintptr_t)&pmf_cb);
955#ifdef VGA_POST 956#ifdef VGA_POST
956 vga_posth = vga_post_init(pa->pa_bus, pa->pa_device, 957 vga_posth = vga_post_init(pa->pa_bus, pa->pa_device,
957 pa->pa_function); 958 pa->pa_function);
958#endif 959#endif
959 found_console = true; 960 found_console = true;
960 return NULL; 961 return NULL;
961 } 962 }
962 } 963 }
963 return NULL; 964 return NULL;
964} 965}
965 966
 967#ifndef PUC_CNBUS
 968#define PUC_CNBUS 0
 969#endif
 970
966#if NCOM > 0 971#if NCOM > 0
967int 972int
968cpu_comcnprobe(struct consdev *cn, struct pci_attach_args *pa) 973cpu_puc_cnprobe(struct consdev *cn, struct pci_attach_args *pa)
969{ 974{
970 pci_mode_detect(); 975 pci_mode_detect();
971 pa->pa_iot = x86_bus_space_io; 976 pa->pa_iot = x86_bus_space_io;
 977 pa->pa_memt = x86_bus_space_mem;
972 pa->pa_pc = 0; 978 pa->pa_pc = 0;
973 pa->pa_tag = pci_make_tag(0, 0, pci_bus_maxdevs(NULL, 0) - 1, 0); 979 pa->pa_tag = pci_make_tag(0, PUC_CNBUS, pci_bus_maxdevs(NULL, 0) - 1,
 980 0);
 981
974 return 0; 982 return 0;
975} 983}
976#endif 984#endif

cvs diff -r1.24 -r1.25 src/sys/arch/x86/x86/consinit.c (expand / switch to unified diff)

--- src/sys/arch/x86/x86/consinit.c 2012/10/13 17:58:55 1.24
+++ src/sys/arch/x86/x86/consinit.c 2014/01/26 10:54:24 1.25
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: consinit.c,v 1.24 2012/10/13 17:58:55 jdc Exp $ */ 1/* $NetBSD: consinit.c,v 1.25 2014/01/26 10:54:24 msaitoh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998 4 * Copyright (c) 1998
5 * Matthias Drochner. All rights reserved. 5 * Matthias Drochner. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,41 +17,43 @@ @@ -17,41 +17,43 @@
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * 26 *
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.24 2012/10/13 17:58:55 jdc Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.25 2014/01/26 10:54:24 msaitoh Exp $");
31 31
32#include "opt_kgdb.h" 32#include "opt_kgdb.h"
 33#include "opt_puc.h"
33 34
34#include <sys/param.h> 35#include <sys/param.h>
35#include <sys/systm.h> 36#include <sys/systm.h>
36#include <sys/device.h> 37#include <sys/device.h>
37#include <sys/bus.h> 38#include <sys/bus.h>
38#include <machine/bootinfo.h> 39#include <machine/bootinfo.h>
39#include <arch/x86/include/genfb_machdep.h> 40#include <arch/x86/include/genfb_machdep.h>
40 41
41#include "genfb.h" 42#include "genfb.h"
42#include "vga.h" 43#include "vga.h"
43#include "ega.h" 44#include "ega.h"
44#include "pcdisplay.h" 45#include "pcdisplay.h"
 46#include "com_puc.h"
45#if (NVGA > 0) || (NEGA > 0) || (NPCDISPLAY > 0) 47#if (NVGA > 0) || (NEGA > 0) || (NPCDISPLAY > 0)
46#include <dev/ic/mc6845reg.h> 48#include <dev/ic/mc6845reg.h>
47#include <dev/ic/pcdisplayvar.h> 49#include <dev/ic/pcdisplayvar.h>
48#if (NVGA > 0) 50#if (NVGA > 0)
49#include <dev/ic/vgareg.h> 51#include <dev/ic/vgareg.h>
50#include <dev/ic/vgavar.h> 52#include <dev/ic/vgavar.h>
51#endif 53#endif
52#if (NEGA > 0) 54#if (NEGA > 0)
53#include <dev/isa/egavar.h> 55#include <dev/isa/egavar.h>
54#endif 56#endif
55#if (NPCDISPLAY > 0) 57#if (NPCDISPLAY > 0)
56#include <dev/isa/pcdisplayvar.h> 58#include <dev/isa/pcdisplayvar.h>
57#endif 59#endif
@@ -66,26 +68,29 @@ __KERNEL_RCSID(0, "$NetBSD: consinit.c,v @@ -66,26 +68,29 @@ __KERNEL_RCSID(0, "$NetBSD: consinit.c,v
66#endif 68#endif
67#include "pckbd.h" /* for pckbc_machdep_cnattach */ 69#include "pckbd.h" /* for pckbc_machdep_cnattach */
68 70
69#if (NGENFB > 0) 71#if (NGENFB > 0)
70#include <dev/wsfb/genfbvar.h> 72#include <dev/wsfb/genfbvar.h>
71#endif 73#endif
72 74
73#include "com.h" 75#include "com.h"
74#if (NCOM > 0) 76#if (NCOM > 0)
75#include <sys/termios.h> 77#include <sys/termios.h>
76#include <dev/ic/comreg.h> 78#include <dev/ic/comreg.h>
77#include <dev/ic/comvar.h> 79#include <dev/ic/comvar.h>
78#endif 80#endif
 81#if (NCOM_PUC > 0)
 82#include <dev/pci/puccn.h>
 83#endif
79 84
80#include "ukbd.h" 85#include "ukbd.h"
81#if (NUKBD > 0) 86#if (NUKBD > 0)
82#include <dev/usb/ukbdvar.h> 87#include <dev/usb/ukbdvar.h>
83#endif 88#endif
84 89
85#ifndef CONSDEVNAME 90#ifndef CONSDEVNAME
86#define CONSDEVNAME "pc" 91#define CONSDEVNAME "pc"
87#endif 92#endif
88 93
89#if (NCOM > 0) 94#if (NCOM > 0)
90#ifndef CONADDR 95#ifndef CONADDR
91#define CONADDR 0x3f8 96#define CONADDR 0x3f8
@@ -134,26 +139,27 @@ int comkgdbmode = KGDB_DEVMODE; @@ -134,26 +139,27 @@ int comkgdbmode = KGDB_DEVMODE;
134 139
135/* 140/*
136 * consinit: 141 * consinit:
137 * initialize the system console. 142 * initialize the system console.
138 * XXX - shouldn't deal with this initted thing, but then, 143 * XXX - shouldn't deal with this initted thing, but then,
139 * it shouldn't be called from init386 either. 144 * it shouldn't be called from init386 either.
140 */ 145 */
141void 146void
142consinit(void) 147consinit(void)
143{ 148{
144 const struct btinfo_console *consinfo; 149 const struct btinfo_console *consinfo;
145 const struct btinfo_framebuffer *fbinfo; 150 const struct btinfo_framebuffer *fbinfo;
146 static int initted; 151 static int initted;
 152 int rv;
147 153
148 if (initted) 154 if (initted)
149 return; 155 return;
150 initted = 1; 156 initted = 1;
151 157
152#ifndef CONS_OVERRIDE 158#ifndef CONS_OVERRIDE
153 consinfo = lookup_bootinfo(BTINFO_CONSOLE); 159 consinfo = lookup_bootinfo(BTINFO_CONSOLE);
154 if (!consinfo) 160 if (!consinfo)
155#endif 161#endif
156 consinfo = &default_consinfo; 162 consinfo = &default_consinfo;
157 163
158 fbinfo = lookup_bootinfo(BTINFO_FRAMEBUFFER); 164 fbinfo = lookup_bootinfo(BTINFO_FRAMEBUFFER);
159 165
@@ -194,35 +200,42 @@ dokbd: @@ -194,35 +200,42 @@ dokbd:
194 if (error) 200 if (error)
195 error = ukbd_cnattach(); 201 error = ukbd_cnattach();
196#endif 202#endif
197 if (error) 203 if (error)
198 printf("WARNING: no console keyboard, error=%d\n", 204 printf("WARNING: no console keyboard, error=%d\n",
199 error); 205 error);
200 return; 206 return;
201 } 207 }
202#if (NCOM > 0) 208#if (NCOM > 0)
203 if (!strcmp(consinfo->devname, "com")) { 209 if (!strcmp(consinfo->devname, "com")) {
204 int addr = consinfo->addr; 210 int addr = consinfo->addr;
205 int speed = consinfo->speed; 211 int speed = consinfo->speed;
206 212
 213#if (NCOM_PUC > 0) && defined(PUC_CNAUTO)
 214 puc_cnprobe(NULL);
 215 rv = puc_cninit(NULL);
 216 if (rv == 0)
 217 return;
 218#endif
 219
207 if (addr == 0) 220 if (addr == 0)
208 addr = CONADDR; 221 addr = CONADDR;
209 if (speed == 0) 222 if (speed == 0)
210 speed = CONSPEED; 223 speed = CONSPEED;
211 224
212 if (comcnattach(x86_bus_space_io, addr, speed, 225 rv = comcnattach(x86_bus_space_io, addr, speed,
213 COM_FREQ, COM_TYPE_NORMAL, comcnmode)) 226 COM_FREQ, COM_TYPE_NORMAL, comcnmode);
 227 if (rv != 0)
214 panic("can't init serial console @%x", consinfo->addr); 228 panic("can't init serial console @%x", consinfo->addr);
215 
216 return; 229 return;
217 } 230 }
218#endif 231#endif
219 panic("invalid console device %s", consinfo->devname); 232 panic("invalid console device %s", consinfo->devname);
220} 233}
221 234
222#ifdef KGDB 235#ifdef KGDB
223void 236void
224kgdb_port_init(void) 237kgdb_port_init(void)
225{ 238{
226#if (NCOM > 0) 239#if (NCOM > 0)
227 if(!strcmp(kgdb_devname, "com")) { 240 if(!strcmp(kgdb_devname, "com")) {
228 com_kgdb_attach(x86_bus_space_io, comkgdbaddr, comkgdbrate, 241 com_kgdb_attach(x86_bus_space_io, comkgdbaddr, comkgdbrate,

cvs diff -r1.368 -r1.369 src/sys/dev/pci/files.pci (expand / switch to unified diff)

--- src/sys/dev/pci/files.pci 2014/01/21 14:52:07 1.368
+++ src/sys/dev/pci/files.pci 2014/01/26 10:54:24 1.369
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: files.pci,v 1.368 2014/01/21 14:52:07 mlelstv Exp $ 1# $NetBSD: files.pci,v 1.369 2014/01/26 10:54:24 msaitoh Exp $
2# 2#
3# Config file and device description for machine-independent PCI code. 3# Config file and device description for machine-independent PCI code.
4# Included by ports that need it. Requires that the SCSI files be 4# Included by ports that need it. Requires that the SCSI files be
5# defined first. 5# defined first.
6 6
7defflag opt_pci.h PCIVERBOSE PCI_CONFIG_DUMP PCI_NETBSD_CONFIGURE 7defflag opt_pci.h PCIVERBOSE PCI_CONFIG_DUMP PCI_NETBSD_CONFIGURE
8defparam opt_pci.h PCI_NETBSD_ENABLE_IDE 8defparam opt_pci.h PCI_NETBSD_ENABLE_IDE
9 9
10defflag opt_bktr.h BKTR_430_FX_MODE BKTR_GPIO_ACCESS BKTR_NO_MSP_RESET 10defflag opt_bktr.h BKTR_430_FX_MODE BKTR_GPIO_ACCESS BKTR_NO_MSP_RESET
11 BKTR_REVERSE_MUTE BKTR_SIS_VIA_MODE BKTR_USE_PLL 11 BKTR_REVERSE_MUTE BKTR_SIS_VIA_MODE BKTR_USE_PLL
12defparam opt_bktr.h BKTR_OVERRIDE_CARD BKTR_OVERRIDE_TUNER BKTR_OVERRIDE_DBX 12defparam opt_bktr.h BKTR_OVERRIDE_CARD BKTR_OVERRIDE_TUNER BKTR_OVERRIDE_DBX
13 BKTR_OVERRIDE_MSP BKTR_SYSTEM_DEFAULT 13 BKTR_OVERRIDE_MSP BKTR_SYSTEM_DEFAULT
14 14
@@ -594,29 +594,31 @@ device autri: audiobus, auconv, mulaw, a @@ -594,29 +594,31 @@ device autri: audiobus, auconv, mulaw, a
594attach autri at pci 594attach autri at pci
595file dev/pci/autri.c autri 595file dev/pci/autri.c autri
596 596
597# SMC EPIC/100 Fast Ethernet on PCI 597# SMC EPIC/100 Fast Ethernet on PCI
598attach epic at pci with epic_pci 598attach epic at pci with epic_pci
599file dev/pci/if_epic_pci.c epic_pci 599file dev/pci/if_epic_pci.c epic_pci
600 600
601# PCI "universal" communication device driver, for PCI com, lpt, etc. ports 601# PCI "universal" communication device driver, for PCI com, lpt, etc. ports
602# (see documentation in the driver for what, exactly, should be supported) 602# (see documentation in the driver for what, exactly, should be supported)
603device puc { port = -1 } 603device puc { port = -1 }
604attach puc at pci 604attach puc at pci
605file dev/pci/puc.c puc 605file dev/pci/puc.c puc
606file dev/pci/pucdata.c puc 606file dev/pci/pucdata.c puc
 607defflag opt_puc.h PUC_CNAUTO
 608defparam opt_puc.h PUC_CNBUS
607 609
608attach com at puc with com_puc 610attach com at puc with com_puc
609file dev/pci/com_puc.c com_puc 611file dev/pci/com_puc.c com_puc needs-flag
610file dev/pci/cyber.c com_puc 612file dev/pci/cyber.c com_puc
611file dev/pci/puccn.c com_puc 613file dev/pci/puccn.c com_puc
612 614
613attach lpt at puc with lpt_puc 615attach lpt at puc with lpt_puc
614file dev/pci/lpt_puc.c lpt_puc & !ppbus 616file dev/pci/lpt_puc.c lpt_puc & !ppbus
615 617
616attach atppc at puc with atppc_puc 618attach atppc at puc with atppc_puc
617file dev/pci/atppc_puc.c atppc_puc 619file dev/pci/atppc_puc.c atppc_puc
618 620
619# UHCI USB controller 621# UHCI USB controller
620attach uhci at pci with uhci_pci 622attach uhci at pci with uhci_pci
621file dev/pci/uhci_pci.c uhci_pci 623file dev/pci/uhci_pci.c uhci_pci
622 624

cvs diff -r1.12 -r1.13 src/sys/dev/pci/puccn.c (expand / switch to unified diff)

--- src/sys/dev/pci/puccn.c 2014/01/23 17:43:28 1.12
+++ src/sys/dev/pci/puccn.c 2014/01/26 10:54:24 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: puccn.c,v 1.12 2014/01/23 17:43:28 msaitoh Exp $ */ 1/* $NetBSD: puccn.c,v 1.13 2014/01/26 10:54:24 msaitoh Exp $ */
2 2
3/* 3/*
4 * Derived from pci.c 4 * Derived from pci.c
5 * Copyright (c) 2000 Geocast Networks Systems. All rights reserved. 5 * Copyright (c) 2000 Geocast Networks Systems. All rights reserved.
6 * 6 *
7 * Copyright (c) 1995, 1996, 1997, 1998 7 * Copyright (c) 1995, 1996, 1997, 1998
8 * Christopher G. Demetriou. All rights reserved. 8 * Christopher G. Demetriou. All rights reserved.
9 * Copyright (c) 1994 Charles M. Hannum. All rights reserved. 9 * Copyright (c) 1994 Charles M. Hannum. All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -32,27 +32,27 @@ @@ -32,27 +32,27 @@
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */ 35 */
36 36
37 37
38/* 38/*
39 * Machine independent support for PCI serial console support. 39 * Machine independent support for PCI serial console support.
40 * 40 *
41 * Scan the PCI bus for something which resembles a 16550 41 * Scan the PCI bus for something which resembles a 16550
42 */ 42 */
43 43
44#include <sys/cdefs.h> 44#include <sys/cdefs.h>
45__KERNEL_RCSID(0, "$NetBSD: puccn.c,v 1.12 2014/01/23 17:43:28 msaitoh Exp $"); 45__KERNEL_RCSID(0, "$NetBSD: puccn.c,v 1.13 2014/01/26 10:54:24 msaitoh Exp $");
46 46
47#include "opt_kgdb.h" 47#include "opt_kgdb.h"
48 48
49#include <sys/param.h> 49#include <sys/param.h>
50#include <sys/systm.h> 50#include <sys/systm.h>
51#include <sys/conf.h> 51#include <sys/conf.h>
52#include <sys/device.h> 52#include <sys/device.h>
53 53
54#include <dev/pci/pcireg.h> 54#include <dev/pci/pcireg.h>
55#include <dev/pci/pcivar.h> 55#include <dev/pci/pcivar.h>
56#include <dev/pci/pcidevs.h> 56#include <dev/pci/pcidevs.h>
57 57
58#include <sys/termios.h> 58#include <sys/termios.h>
@@ -65,55 +65,55 @@ __KERNEL_RCSID(0, "$NetBSD: puccn.c,v 1. @@ -65,55 +65,55 @@ __KERNEL_RCSID(0, "$NetBSD: puccn.c,v 1.
65#include <dev/pci/puccn.h> 65#include <dev/pci/puccn.h>
66 66
67#ifndef CONSPEED 67#ifndef CONSPEED
68#define CONSPEED TTYDEF_SPEED 68#define CONSPEED TTYDEF_SPEED
69#endif 69#endif
70#ifndef CONMODE 70#ifndef CONMODE
71#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE|CSTOPB|PARENB))|CS8) /* 8N1 */ 71#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE|CSTOPB|PARENB))|CS8) /* 8N1 */
72#endif 72#endif
73 73
74cons_decl(com); 74cons_decl(com);
75 75
76static bus_addr_t puccnbase; 76static bus_addr_t puccnbase;
77static bus_space_tag_t puctag; 77static bus_space_tag_t puctag;
 78static int puccnflags;
78 79
79#ifdef KGDB 80#ifdef KGDB
80static bus_addr_t pucgdbbase; 81static bus_addr_t pucgdbbase;
81#endif 82#endif
82 83
83/* 84/*
84 * Static dev/func variables allow pucprobe to be called multiple times, 85 * Static dev/func variables allow pucprobe to be called multiple times,
85 * resuming the search where it left off, never retrying the same adaptor. 86 * resuming the search where it left off, never retrying the same adaptor.
86 */ 87 */
87 88
88static bus_addr_t 89static bus_addr_t
89pucprobe_doit(struct consdev *cn) 90pucprobe_doit(struct consdev *cn)
90{ 91{
91 struct pci_attach_args pa; 92 struct pci_attach_args pa;
92 int bus; 93 int bus;
93 static int dev = 0, func = 0; 94 static int dev = 0, func = 0;
94 int maxdev, nfunctions = 0, i; /* XXX */ 95 int maxdev, nfunctions = 0, i; /* XXX */
95 pcireg_t reg, bhlcr, subsys = 0; /* XXX */ 96 pcireg_t reg, bhlcr, subsys = 0; /* XXX */
96 int foundport = 0; 97 int foundport = 0;
97 const struct puc_device_description *desc; 98 const struct puc_device_description *desc;
98 pcireg_t base; 99 pcireg_t base;
99 100
100 /* Fetch our tags */ 101 /* Fetch our tags */
101#if defined(amd64) || defined(i386) 102#if defined(amd64) || defined(i386)
102 if (cpu_comcnprobe(cn, &pa) != 0) 103 if (cpu_puc_cnprobe(cn, &pa) != 0)
103#endif 104#endif
104 return 0; 105 return 0;
105 106
106 puctag = pa.pa_iot; 
107 pci_decompose_tag(pa.pa_pc, pa.pa_tag, &bus, &maxdev, NULL); 107 pci_decompose_tag(pa.pa_pc, pa.pa_tag, &bus, &maxdev, NULL);
108 108
109 /* Scan through devices and find a communication class device. */ 109 /* Scan through devices and find a communication class device. */
110 for (; dev <= maxdev ; dev++) { 110 for (; dev <= maxdev ; dev++) {
111 pa.pa_tag = pci_make_tag(pa.pa_pc, bus, dev, 0); 111 pa.pa_tag = pci_make_tag(pa.pa_pc, bus, dev, 0);
112 reg = pci_conf_read(pa.pa_pc, pa.pa_tag, PCI_ID_REG); 112 reg = pci_conf_read(pa.pa_pc, pa.pa_tag, PCI_ID_REG);
113 if (PCI_VENDOR(reg) == PCI_VENDOR_INVALID 113 if (PCI_VENDOR(reg) == PCI_VENDOR_INVALID
114 || PCI_VENDOR(reg) == 0) 114 || PCI_VENDOR(reg) == 0)
115 continue; 115 continue;
116 bhlcr = pci_conf_read(pa.pa_pc, pa.pa_tag, PCI_BHLC_REG); 116 bhlcr = pci_conf_read(pa.pa_pc, pa.pa_tag, PCI_BHLC_REG);
117 if (PCI_HDRTYPE_MULTIFN(bhlcr)) { 117 if (PCI_HDRTYPE_MULTIFN(bhlcr)) {
118 nfunctions = 8; 118 nfunctions = 8;
119 } else { 119 } else {
@@ -135,96 +135,114 @@ resume_scan: @@ -135,96 +135,114 @@ resume_scan:
135 } 135 }
136 if (foundport) 136 if (foundport)
137 break; 137 break;
138 138
139 func = 0; 139 func = 0;
140 } 140 }
141 141
142 /* 142 /*
143 * If all devices was scanned and couldn't find any communication 143 * If all devices was scanned and couldn't find any communication
144 * device, return with 0. 144 * device, return with 0.
145 */ 145 */
146 if (!foundport) 146 if (!foundport)
147 return 0; 147 return 0;
 148
 149 /* Clear foundport flag */
148 foundport = 0; 150 foundport = 0;
149 151
150 /* Check whether the device is in the puc device table or not */ 152 /* Check whether the device is in the puc device table or not */
151 desc = puc_find_description(PCI_VENDOR(pa.pa_id), 153 desc = puc_find_description(PCI_VENDOR(pa.pa_id),
152 PCI_PRODUCT(pa.pa_id), PCI_VENDOR(subsys), PCI_PRODUCT(subsys)); 154 PCI_PRODUCT(pa.pa_id), PCI_VENDOR(subsys), PCI_PRODUCT(subsys));
153 155
154 /* If not, check the next communication device */ 156 /* If not, check the next communication device */
155 if (desc == NULL) { 157 if (desc == NULL) {
156 /* Resume from the next function */ 158 /* Resume from the next function */
157 func++; 159 func++;
158 goto resume_scan; 160 goto resume_scan;
159 } 161 }
160 162
161 /* 163 /*
162 * We found a device and it's on the puc table. Set the tag and 164 * We found a device and it's on the puc table. Set the tag and
163 * the base address. 165 * the base address.
164 */ 166 */
165 for (i = 0; PUC_PORT_VALID(desc, i); i++) 167 for (i = 0; PUC_PORT_VALID(desc, i); i++)
166 { 168 {
167 if (desc->ports[i].type != PUC_PORT_TYPE_COM) 169 if (desc->ports[i].type != PUC_PORT_TYPE_COM)
168 continue; 170 continue;
 171 puccnflags = desc->ports[i].flags;
169 base = pci_conf_read(pa.pa_pc, pa.pa_tag, desc->ports[i].bar); 172 base = pci_conf_read(pa.pa_pc, pa.pa_tag, desc->ports[i].bar);
170 base += desc->ports[i].offset; 173 base += desc->ports[i].offset;
171 174
172 if (PCI_MAPREG_TYPE(base) != PCI_MAPREG_TYPE_IO) 175 if (PCI_MAPREG_TYPE(base) == PCI_MAPREG_TYPE_IO) {
173 continue; 176 puctag = pa.pa_iot;
174 base = PCI_MAPREG_IO_ADDR(base); 177 base = PCI_MAPREG_IO_ADDR(base);
 178 }
 179#if 0 /* For MMIO device */
 180 else {
 181 puctag = pa.pa_memt;
 182 base = PCI_MAPREG_MEM_ADDR(base);
 183 }
 184#endif
 185
175 if (com_is_console(puctag, base, NULL)) 186 if (com_is_console(puctag, base, NULL))
176 continue; 187 continue;
177 foundport = 1; 188 foundport = 1;
178 break; 189 break;
179 } 190 }
180 191
181 if (foundport == 0) { 192 if (foundport == 0) {
182 func++; 193 func++;
183 goto resume_scan; 194 goto resume_scan;
184 } 195 }
185 196
 197#if 0
186 cn->cn_pri = CN_REMOTE; 198 cn->cn_pri = CN_REMOTE;
187 return PCI_MAPREG_IO_ADDR(base); 199#else
 200 if (cn)
 201 cn->cn_pri = CN_REMOTE;
 202#endif
 203 return base;
188} 204}
189 205
190#ifdef KGDB 206#ifdef KGDB
191void comgdbprobe(struct consdev *); 207void comgdbprobe(struct consdev *);
192void comgdbinit(struct consdev *); 208void comgdbinit(struct consdev *);
193 209
194void 210void
195comgdbprobe(struct consdev *cn) 211comgdbprobe(struct consdev *cn)
196{ 212{
197 213
198 pucgdbbase = pucprobe_doit(cn); 214 pucgdbbase = pucprobe_doit(cn);
199} 215}
200 216
201void 217void
202comgdbinit(struct consdev *cn) 218comgdbinit(struct consdev *cn)
203{ 219{
204 220
205 if (pucgdbbase == 0) 221 if (pucgdbbase == 0)
206 return; 222 return;
207 223
208 com_kgdb_attach(puctag, pucgdbbase, CONSPEED, COM_FREQ, 224 com_kgdb_attach(puctag, pucgdbbase, CONSPEED, COM_FREQ,
209 COM_TYPE_NORMAL, CONMODE); 225 COM_TYPE_NORMAL, CONMODE);
210} 226}
211#endif 227#endif
212 228
213void 229void
214comcnprobe(struct consdev *cn) 230puc_cnprobe(struct consdev *cn)
215{ 231{
216 232
217 puccnbase = pucprobe_doit(cn); 233 puccnbase = pucprobe_doit(cn);
218} 234}
219 235
220void 236int
221comcninit(struct consdev *cn) 237puc_cninit(struct consdev *cn)
222{ 238{
 239
223 if (puccnbase == 0) 240 if (puccnbase == 0)
224 return; 241 return -1;
225 242
226 comcnattach(puctag, puccnbase, CONSPEED, COM_FREQ, COM_TYPE_NORMAL, 243 return comcnattach(puctag, puccnbase, CONSPEED,
 244 puccnflags & PUC_COM_CLOCKMASK, COM_TYPE_NORMAL,
227 CONMODE); 245 CONMODE);
228} 246}
229 247
230/* comcngetc, comcnputc, comcnpollc provided by dev/ic/com.c */ 248/* comcngetc, comcnputc, comcnpollc provided by dev/ic/com.c */

cvs diff -r1.5 -r1.6 src/sys/dev/pci/puccn.h (expand / switch to unified diff)

--- src/sys/dev/pci/puccn.h 2013/07/22 13:40:36 1.5
+++ src/sys/dev/pci/puccn.h 2014/01/26 10:54:24 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: puccn.h,v 1.5 2013/07/22 13:40:36 soren Exp $ */ 1/* $NetBSD: puccn.h,v 1.6 2014/01/26 10:54:24 msaitoh Exp $ */
2 2
3/* 3/*
4 * Derived from pci.c 4 * Derived from pci.c
5 * Copyright (c) 2000 Geocast Networks Systems. All rights reserved. 5 * Copyright (c) 2000 Geocast Networks Systems. All rights reserved.
6 * 6 *
7 * Copyright (c) 1995, 1996, 1997, 1998 7 * Copyright (c) 1995, 1996, 1997, 1998
8 * Christopher G. Demetriou. All rights reserved. 8 * Christopher G. Demetriou. All rights reserved.
9 * Copyright (c) 1994 Charles M. Hannum. All rights reserved. 9 * Copyright (c) 1994 Charles M. Hannum. All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -25,23 +25,26 @@ @@ -25,23 +25,26 @@
25 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 25 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 26 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 28 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */ 35 */
36 36
37#include <dev/cons.h> 37#include <dev/cons.h>
 38#include <dev/pci/pcivar.h>
38 39
39/* 40/*
40 * Machine independent support for PCI serial console support. 41 * Machine independent support for PCI serial console support.
41 * 42 *
42 * Platform code should provide cpu_comcnprobe() that fills 43 * Platform code should provide cpu_comcnprobe() that fills
43 * in the pci_attach_args. This allows the console can be 44 * in the pci_attach_args. This allows the console can be
44 * used before the normal PCI bus initialization. 45 * used before the normal PCI bus initialization.
45 */ 46 */
46 47
47int cpu_comcnprobe(struct consdev *, struct pci_attach_args *); 48void puc_cnprobe(struct consdev *);
 49int puc_cninit(struct consdev *);
 50int cpu_puc_cnprobe(struct consdev *, struct pci_attach_args *);