- 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
This commit is contained in:
Marius Strobl 2004-08-14 23:54:27 +00:00
parent d25ed517a4
commit efa79eb77e
9 changed files with 86 additions and 2 deletions

View File

@ -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),

View File

@ -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

View File

@ -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)
{
}

View File

@ -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)
{
}

View File

@ -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)
{
}

View File

@ -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)
{
}

View File

@ -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)
{
}

View File

@ -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
}

View File

@ -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>