summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2004-08-14 23:54:27 +0000
committermarius <marius@FreeBSD.org>2004-08-14 23:54:27 +0000
commite7f46aca577945ad56f6838b9271e623dd375f20 (patch)
tree45f3053dc7134b15d707744ad441add24d7905eb
parenta3cb350a8c345e37992de17a5d6c55ac37c245a3 (diff)
downloadFreeBSD-src-e7f46aca577945ad56f6838b9271e623dd375f20.zip
FreeBSD-src-e7f46aca577945ad56f6838b9271e623dd375f20.tar.gz
- Introduce an uart_cpu_identify() which is implemented in uart_cpu_<arch>.c
and that can be used as an identify function for all kinds of busses on a certain platform. Expect for sparc64 these are only stubs right now. [1] - For sparc64, add code to its uart_cpu_identify() for registering the on- board ISA UARTs and their resources based on information obtained from Open Firmware. It would be better if this would be done in the OFW ISA code. However, due to the common FreeBSD ISA code and PNP-IDs not always being present in the properties of the ISA nodes there seems to be no good way to implement that. Therefore special casing UARTs as the sole really relevant ISA devices on sparc64 seemed reasonable. [2] Approved by: marcel Discussed with: marcel [1], tmm [2] Tested by: make universe
-rw-r--r--sys/dev/uart/uart_bus_isa.c2
-rw-r--r--sys/dev/uart/uart_cpu.h1
-rw-r--r--sys/dev/uart/uart_cpu_alpha.c6
-rw-r--r--sys/dev/uart/uart_cpu_amd64.c6
-rw-r--r--sys/dev/uart/uart_cpu_i386.c6
-rw-r--r--sys/dev/uart/uart_cpu_ia64.c6
-rw-r--r--sys/dev/uart/uart_cpu_pc98.c6
-rw-r--r--sys/dev/uart/uart_cpu_sparc64.c46
-rw-r--r--sys/modules/uart/Makefile9
9 files changed, 86 insertions, 2 deletions
diff --git a/sys/dev/uart/uart_bus_isa.c b/sys/dev/uart/uart_bus_isa.c
index d6b5cda..72e0549 100644
--- a/sys/dev/uart/uart_bus_isa.c
+++ b/sys/dev/uart/uart_bus_isa.c
@@ -39,11 +39,13 @@ __FBSDID("$FreeBSD$");
#include <dev/uart/uart.h>
#include <dev/uart/uart_bus.h>
+#include <dev/uart/uart_cpu.h>
static int uart_isa_probe(device_t dev);
static device_method_t uart_isa_methods[] = {
/* Device interface */
+ DEVMETHOD(device_identify, uart_cpu_identify),
DEVMETHOD(device_probe, uart_isa_probe),
DEVMETHOD(device_attach, uart_bus_attach),
DEVMETHOD(device_detach, uart_bus_detach),
diff --git a/sys/dev/uart/uart_cpu.h b/sys/dev/uart/uart_cpu.h
index 462eb59..7862633 100644
--- a/sys/dev/uart/uart_cpu.h
+++ b/sys/dev/uart/uart_cpu.h
@@ -75,6 +75,7 @@ int uart_cpu_getdev(int, struct uart_devinfo *);
int uart_getenv(int, struct uart_devinfo *);
void uart_add_sysdev(struct uart_devinfo *);
+void uart_cpu_identify(driver_t *, device_t);
/*
* Operations for low-level access to the UART. Primarily for use
diff --git a/sys/dev/uart/uart_cpu_alpha.c b/sys/dev/uart/uart_cpu_alpha.c
index a3a132f..67b49b4 100644
--- a/sys/dev/uart/uart_cpu_alpha.c
+++ b/sys/dev/uart/uart_cpu_alpha.c
@@ -123,3 +123,9 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
return (ENXIO);
}
+
+void
+uart_cpu_identify(driver_t *driver, device_t parent)
+{
+
+}
diff --git a/sys/dev/uart/uart_cpu_amd64.c b/sys/dev/uart/uart_cpu_amd64.c
index c0270ae..8a32574 100644
--- a/sys/dev/uart/uart_cpu_amd64.c
+++ b/sys/dev/uart/uart_cpu_amd64.c
@@ -99,3 +99,9 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
return (ENXIO);
}
+
+void
+uart_cpu_identify(driver_t *driver, device_t parent)
+{
+
+}
diff --git a/sys/dev/uart/uart_cpu_i386.c b/sys/dev/uart/uart_cpu_i386.c
index 93ca770..7cf2fd0 100644
--- a/sys/dev/uart/uart_cpu_i386.c
+++ b/sys/dev/uart/uart_cpu_i386.c
@@ -99,3 +99,9 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
return (ENXIO);
}
+
+void
+uart_cpu_identify(driver_t *driver, device_t parent)
+{
+
+}
diff --git a/sys/dev/uart/uart_cpu_ia64.c b/sys/dev/uart/uart_cpu_ia64.c
index 6c3f380..7046456 100644
--- a/sys/dev/uart/uart_cpu_ia64.c
+++ b/sys/dev/uart/uart_cpu_ia64.c
@@ -104,3 +104,9 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
/* Check the environment. */
return (uart_getenv(devtype, di));
}
+
+void
+uart_cpu_identify(driver_t *driver, device_t parent)
+{
+
+}
diff --git a/sys/dev/uart/uart_cpu_pc98.c b/sys/dev/uart/uart_cpu_pc98.c
index ffe7957..3fc2630 100644
--- a/sys/dev/uart/uart_cpu_pc98.c
+++ b/sys/dev/uart/uart_cpu_pc98.c
@@ -104,3 +104,9 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
return (ENXIO);
}
+
+void
+uart_cpu_identify(driver_t *driver, device_t parent)
+{
+
+}
diff --git a/sys/dev/uart/uart_cpu_sparc64.c b/sys/dev/uart/uart_cpu_sparc64.c
index df89a2e..a56b0ad 100644
--- a/sys/dev/uart/uart_cpu_sparc64.c
+++ b/sys/dev/uart/uart_cpu_sparc64.c
@@ -27,18 +27,28 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_isa.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <machine/bus.h>
#include <machine/bus_private.h>
+#include <machine/resource.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/ofw_machdep.h>
+#include <isa/isavar.h>
+
#include <dev/uart/uart.h>
+#include <dev/uart/uart_bus.h>
#include <dev/uart/uart_cpu.h>
+#include <sparc64/pci/ofw_pci.h>
+#include <sparc64/isa/ofw_isa.h>
+
bus_space_tag_t uart_bus_space_io;
bus_space_tag_t uart_bus_space_mem;
@@ -240,3 +250,39 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
(par == 'o') ? UART_PARITY_ODD : UART_PARITY_EVEN;
return (0);
}
+
+void
+uart_cpu_identify(driver_t *driver, device_t parent)
+{
+#ifdef DEV_ISA
+ char buf[32];
+ struct isa_regs reg;
+ device_t child;
+ phandle_t node;
+ ofw_isa_intr_t intr;
+#endif
+
+#ifdef DEV_ISA
+ if (strcmp(device_get_name(parent), "isa") == 0) {
+ if ((node = ofw_bus_get_node(device_get_parent(parent))) == 0)
+ return;
+ for (node = OF_child(node); node != 0; node = OF_peer(node)) {
+ if (OF_getprop(node, "name", buf, sizeof(buf)) == -1)
+ continue;
+ if (strcmp(buf, "serial") != 0)
+ continue;
+ if ((OF_getprop(node, "reg", &reg,
+ sizeof(reg)) == -1) ||
+ (OF_getprop(node, "interrupts", &intr,
+ sizeof(intr)) == -1))
+ continue;
+ if ((child = BUS_ADD_CHILD(parent, ISA_ORDER_SENSITIVE,
+ uart_driver_name, -1)) == NULL)
+ return;
+ bus_set_resource(child, SYS_RES_IOPORT, 0,
+ ISA_REG_PHYS(&reg), reg.size);
+ bus_set_resource(child, SYS_RES_IRQ, 0, intr, 1);
+ }
+ }
+#endif
+}
diff --git a/sys/modules/uart/Makefile b/sys/modules/uart/Makefile
index 9214a73..8a418fa 100644
--- a/sys/modules/uart/Makefile
+++ b/sys/modules/uart/Makefile
@@ -5,6 +5,8 @@
.if ${MACHINE_ARCH} == "sparc64"
uart_bus_ebus= uart_bus_ebus.c
ofw_bus_if= ofw_bus_if.h
+ofw_pci_if= ofw_pci_if.h
+opt_isa= opt_isa.h
.endif
KMOD= uart
@@ -12,7 +14,10 @@ SRCS= uart_bus_acpi.c ${uart_bus_ebus} uart_bus_isa.c uart_bus_pccard.c \
uart_bus_pci.c uart_bus_puc.c uart_core.c uart_cpu_${MACHINE}.c \
uart_dbg.c uart_dev_i8251.c uart_dev_ns8250.c uart_dev_sab82532.c \
uart_dev_z8530.c uart_if.c uart_subr.c uart_tty.c
-SRCS+= bus_if.h card_if.h device_if.h isa_if.h ${ofw_bus_if} pci_if.h \
- power_if.h uart_if.h pccarddevs.h
+SRCS+= bus_if.h card_if.h device_if.h isa_if.h ${ofw_bus_if} ${ofw_pci_if} \
+ ${opt_isa} pci_if.h power_if.h uart_if.h pccarddevs.h
+
+opt_isa.h:
+ echo "#define DEV_ISA 1" > ${.TARGET}
.include <bsd.kmod.mk>
OpenPOWER on IntegriCloud