summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormsaitoh <msaitoh@NetBSD.org>2014-01-26 10:54:24 +0000
committermsaitoh <msaitoh@NetBSD.org>2014-01-26 10:54:24 +0000
commit9b13a9790467ca321ce4c58e08f2ac953efdf445 (patch)
treef47efc1d593903f1c9d4dcd2ae1ae92e6edc8698 /sys/dev
parent35d5811c19ee0b72d342bb405c859d85df2d857e (diff)
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).
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/files.pci6
-rw-r--r--sys/dev/pci/puccn.c44
-rw-r--r--sys/dev/pci/puccn.h7
3 files changed, 40 insertions, 17 deletions
diff --git a/sys/dev/pci/files.pci b/sys/dev/pci/files.pci
index b348dfb7a08..4f7b4810788 100644
--- a/sys/dev/pci/files.pci
+++ b/sys/dev/pci/files.pci
@@ -1,4 +1,4 @@
-# $NetBSD: files.pci,v 1.368 2014/01/21 14:52:07 mlelstv Exp $
+# $NetBSD: files.pci,v 1.369 2014/01/26 10:54:24 msaitoh Exp $
#
# Config file and device description for machine-independent PCI code.
# Included by ports that need it. Requires that the SCSI files be
@@ -604,9 +604,11 @@ device puc { port = -1 }
attach puc at pci
file dev/pci/puc.c puc
file dev/pci/pucdata.c puc
+defflag opt_puc.h PUC_CNAUTO
+defparam opt_puc.h PUC_CNBUS
attach com at puc with com_puc
-file dev/pci/com_puc.c com_puc
+file dev/pci/com_puc.c com_puc needs-flag
file dev/pci/cyber.c com_puc
file dev/pci/puccn.c com_puc
diff --git a/sys/dev/pci/puccn.c b/sys/dev/pci/puccn.c
index f233790d7d8..546ddcbe49b 100644
--- a/sys/dev/pci/puccn.c
+++ b/sys/dev/pci/puccn.c
@@ -1,4 +1,4 @@
-/* $NetBSD: puccn.c,v 1.12 2014/01/23 17:43:28 msaitoh Exp $ */
+/* $NetBSD: puccn.c,v 1.13 2014/01/26 10:54:24 msaitoh Exp $ */
/*
* Derived from pci.c
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puccn.c,v 1.12 2014/01/23 17:43:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puccn.c,v 1.13 2014/01/26 10:54:24 msaitoh Exp $");
#include "opt_kgdb.h"
@@ -75,6 +75,7 @@ cons_decl(com);
static bus_addr_t puccnbase;
static bus_space_tag_t puctag;
+static int puccnflags;
#ifdef KGDB
static bus_addr_t pucgdbbase;
@@ -99,11 +100,10 @@ pucprobe_doit(struct consdev *cn)
/* Fetch our tags */
#if defined(amd64) || defined(i386)
- if (cpu_comcnprobe(cn, &pa) != 0)
+ if (cpu_puc_cnprobe(cn, &pa) != 0)
#endif
return 0;
- puctag = pa.pa_iot;
pci_decompose_tag(pa.pa_pc, pa.pa_tag, &bus, &maxdev, NULL);
/* Scan through devices and find a communication class device. */
@@ -145,6 +145,8 @@ resume_scan:
*/
if (!foundport)
return 0;
+
+ /* Clear foundport flag */
foundport = 0;
/* Check whether the device is in the puc device table or not */
@@ -166,12 +168,21 @@ resume_scan:
{
if (desc->ports[i].type != PUC_PORT_TYPE_COM)
continue;
+ puccnflags = desc->ports[i].flags;
base = pci_conf_read(pa.pa_pc, pa.pa_tag, desc->ports[i].bar);
base += desc->ports[i].offset;
- if (PCI_MAPREG_TYPE(base) != PCI_MAPREG_TYPE_IO)
- continue;
- base = PCI_MAPREG_IO_ADDR(base);
+ if (PCI_MAPREG_TYPE(base) == PCI_MAPREG_TYPE_IO) {
+ puctag = pa.pa_iot;
+ base = PCI_MAPREG_IO_ADDR(base);
+ }
+#if 0 /* For MMIO device */
+ else {
+ puctag = pa.pa_memt;
+ base = PCI_MAPREG_MEM_ADDR(base);
+ }
+#endif
+
if (com_is_console(puctag, base, NULL))
continue;
foundport = 1;
@@ -183,8 +194,13 @@ resume_scan:
goto resume_scan;
}
+#if 0
cn->cn_pri = CN_REMOTE;
- return PCI_MAPREG_IO_ADDR(base);
+#else
+ if (cn)
+ cn->cn_pri = CN_REMOTE;
+#endif
+ return base;
}
#ifdef KGDB
@@ -211,19 +227,21 @@ comgdbinit(struct consdev *cn)
#endif
void
-comcnprobe(struct consdev *cn)
+puc_cnprobe(struct consdev *cn)
{
puccnbase = pucprobe_doit(cn);
}
-void
-comcninit(struct consdev *cn)
+int
+puc_cninit(struct consdev *cn)
{
+
if (puccnbase == 0)
- return;
+ return -1;
- comcnattach(puctag, puccnbase, CONSPEED, COM_FREQ, COM_TYPE_NORMAL,
+ return comcnattach(puctag, puccnbase, CONSPEED,
+ puccnflags & PUC_COM_CLOCKMASK, COM_TYPE_NORMAL,
CONMODE);
}
diff --git a/sys/dev/pci/puccn.h b/sys/dev/pci/puccn.h
index 51a756cb36d..5916af4fc17 100644
--- a/sys/dev/pci/puccn.h
+++ b/sys/dev/pci/puccn.h
@@ -1,4 +1,4 @@
-/* $NetBSD: puccn.h,v 1.5 2013/07/22 13:40:36 soren Exp $ */
+/* $NetBSD: puccn.h,v 1.6 2014/01/26 10:54:24 msaitoh Exp $ */
/*
* Derived from pci.c
@@ -35,6 +35,7 @@
*/
#include <dev/cons.h>
+#include <dev/pci/pcivar.h>
/*
* Machine independent support for PCI serial console support.
@@ -44,4 +45,6 @@
* used before the normal PCI bus initialization.
*/
-int cpu_comcnprobe(struct consdev *, struct pci_attach_args *);
+void puc_cnprobe(struct consdev *);
+int puc_cninit(struct consdev *);
+int cpu_puc_cnprobe(struct consdev *, struct pci_attach_args *);