diff options
| author | Rafal Jaworowski <raj@FreeBSD.org> | 2010-07-11 21:08:29 +0000 |
|---|---|---|
| committer | Rafal Jaworowski <raj@FreeBSD.org> | 2010-07-11 21:08:29 +0000 |
| commit | d1d3233ebd5b639265458ec6e2a1f999a805222a (patch) | |
| tree | 827f9dce3768613a609f3a9e594b123936ec2e0e /sys/dev | |
| parent | c5a514a75699cfed28bd4af58750a5ec18d1c01d (diff) | |
Notes
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/cfi/cfi_bus_fdt.c (renamed from sys/dev/cfi/cfi_bus_lbc.c) | 32 | ||||
| -rw-r--r-- | sys/dev/fdt/fdt_pci.c | 5 | ||||
| -rw-r--r-- | sys/dev/quicc/quicc_bfe_fdt.c (renamed from sys/dev/quicc/quicc_bfe_ocp.c) | 36 | ||||
| -rw-r--r-- | sys/dev/sec/sec.c | 35 | ||||
| -rw-r--r-- | sys/dev/tsec/if_tsec.c | 11 | ||||
| -rw-r--r-- | sys/dev/tsec/if_tsec.h | 7 | ||||
| -rw-r--r-- | sys/dev/tsec/if_tsec_fdt.c (renamed from sys/dev/tsec/if_tsec_ocp.c) | 99 | ||||
| -rw-r--r-- | sys/dev/uart/uart_bus_ocp.c | 88 | ||||
| -rw-r--r-- | sys/dev/uart/uart_cpu_powerpc.c | 34 |
9 files changed, 108 insertions, 239 deletions
diff --git a/sys/dev/cfi/cfi_bus_lbc.c b/sys/dev/cfi/cfi_bus_fdt.c index df24f389998d0..bfbd65f806541 100644 --- a/sys/dev/cfi/cfi_bus_lbc.c +++ b/sys/dev/cfi/cfi_bus_fdt.c @@ -35,49 +35,39 @@ __FBSDID("$FreeBSD$"); #include <sys/bus.h> #include <sys/conf.h> #include <sys/kernel.h> -#include <sys/malloc.h> #include <sys/module.h> -#include <sys/rman.h> -#include <sys/sysctl.h> #include <machine/bus.h> #include <dev/cfi/cfi_var.h> +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> -#include <powerpc/mpc85xx/lbc.h> +static int cfi_fdt_probe(device_t); -static int cfi_lbc_probe(device_t); - -static device_method_t cfi_lbc_methods[] = { +static device_method_t cfi_fdt_methods[] = { /* device interface */ - DEVMETHOD(device_probe, cfi_lbc_probe), + DEVMETHOD(device_probe, cfi_fdt_probe), DEVMETHOD(device_attach, cfi_attach), DEVMETHOD(device_detach, cfi_detach), {0, 0} }; -static driver_t cfi_lbc_driver = { +static driver_t cfi_fdt_driver = { cfi_driver_name, - cfi_lbc_methods, + cfi_fdt_methods, sizeof(struct cfi_softc), }; -DRIVER_MODULE (cfi, lbc, cfi_lbc_driver, cfi_devclass, 0, 0); +DRIVER_MODULE (cfi, lbc, cfi_fdt_driver, cfi_devclass, 0, 0); static int -cfi_lbc_probe(device_t dev) +cfi_fdt_probe(device_t dev) { - uintptr_t devtype; - int error; - - error = BUS_READ_IVAR(device_get_parent(dev), dev, LBC_IVAR_DEVTYPE, - &devtype); - if (error) - return (error); - if (devtype != LBC_DEVTYPE_CFI) - return (EINVAL); + if (!ofw_bus_is_compatible(dev, "cfi-flash")) + return (ENXIO); return (cfi_probe(dev)); } diff --git a/sys/dev/fdt/fdt_pci.c b/sys/dev/fdt/fdt_pci.c index fd708efea45f2..44e0dbfd17cdd 100644 --- a/sys/dev/fdt/fdt_pci.c +++ b/sys/dev/fdt/fdt_pci.c @@ -325,8 +325,9 @@ fdt_pci_route_intr(int bus, int slot, int func, int pin, debugf("decoded intr = %d, trig = %d, pol = %d\n", *interrupt, trig, pol); - /* XXX we should probably call powerpc_config() here... */ - +#if defined(__powerpc__) + powerpc_config_intr(INTR_VEC(intr_par, *interrupt), trig, pol); +#endif return (0); next: diff --git a/sys/dev/quicc/quicc_bfe_ocp.c b/sys/dev/quicc/quicc_bfe_fdt.c index e0a98e0532efa..e1fd2d5ad1ecb 100644 --- a/sys/dev/quicc/quicc_bfe_ocp.c +++ b/sys/dev/quicc/quicc_bfe_fdt.c @@ -41,15 +41,15 @@ __FBSDID("$FreeBSD$"); #include <sys/tty.h> #include <machine/bus.h> -#include <machine/ocpbus.h> - +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> #include <dev/quicc/quicc_bfe.h> -static int quicc_ocp_probe(device_t dev); +static int quicc_fdt_probe(device_t dev); -static device_method_t quicc_ocp_methods[] = { +static device_method_t quicc_fdt_methods[] = { /* Device interface */ - DEVMETHOD(device_probe, quicc_ocp_probe), + DEVMETHOD(device_probe, quicc_fdt_probe), DEVMETHOD(device_attach, quicc_bfe_attach), DEVMETHOD(device_detach, quicc_bfe_detach), @@ -65,30 +65,26 @@ static device_method_t quicc_ocp_methods[] = { { 0, 0 } }; -static driver_t quicc_ocp_driver = { +static driver_t quicc_fdt_driver = { quicc_driver_name, - quicc_ocp_methods, + quicc_fdt_methods, sizeof(struct quicc_softc), }; static int -quicc_ocp_probe(device_t dev) +quicc_fdt_probe(device_t dev) { - device_t parent; - uintptr_t clock, devtype; - int error; - - parent = device_get_parent(dev); + phandle_t par; + pcell_t clock; - error = BUS_READ_IVAR(parent, dev, OCPBUS_IVAR_DEVTYPE, &devtype); - if (error) - return (error); - if (devtype != OCPBUS_DEVTYPE_QUICC) + if (!ofw_bus_is_compatible(dev, "fsl,cpm2")) return (ENXIO); - if (BUS_READ_IVAR(parent, dev, OCPBUS_IVAR_CLOCK, &clock)) + par = OF_parent(ofw_bus_get_node(dev)); + if (OF_getprop(par, "bus-frequency", &clock, sizeof(clock)) <= 0) clock = 0; - return (quicc_bfe_probe(dev, clock)); + + return (quicc_bfe_probe(dev, (uintptr_t)clock)); } -DRIVER_MODULE(quicc, ocpbus, quicc_ocp_driver, quicc_devclass, 0, 0); +DRIVER_MODULE(quicc, simplebus, quicc_fdt_driver, quicc_devclass, 0, 0); diff --git a/sys/dev/sec/sec.c b/sys/dev/sec/sec.c index 6b0a62f9e9fac..36fc9cea7435f 100644 --- a/sys/dev/sec/sec.c +++ b/sys/dev/sec/sec.c @@ -45,12 +45,12 @@ __FBSDID("$FreeBSD$"); #include <sys/rman.h> #include <machine/bus.h> -#include <machine/ocpbus.h> #include <machine/resource.h> #include <opencrypto/cryptodev.h> #include "cryptodev_if.h" +#include <dev/ofw/ofw_bus_subr.h> #include <dev/sec/sec.h> static int sec_probe(device_t dev); @@ -153,7 +153,7 @@ static driver_t sec_driver = { }; static devclass_t sec_devclass; -DRIVER_MODULE(sec, ocpbus, sec_driver, sec_devclass, 0, 0); +DRIVER_MODULE(sec, simplebus, sec_driver, sec_devclass, 0, 0); MODULE_DEPEND(sec, crypto, 1, 1, 1); static struct sec_eu_methods sec_eus[] = { @@ -201,24 +201,16 @@ static int sec_probe(device_t dev) { struct sec_softc *sc; - device_t parent; - uintptr_t devtype; uint64_t id; - int error; - parent = device_get_parent(dev); - error = BUS_READ_IVAR(parent, dev, OCPBUS_IVAR_DEVTYPE, &devtype); - if (error) - return (error); - - if (devtype != OCPBUS_DEVTYPE_SEC) + if (!ofw_bus_is_compatible(dev, "fsl,sec2.0")) return (ENXIO); sc = device_get_softc(dev); sc->sc_rrid = 0; - sc->sc_rres = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->sc_rrid, - 0ul, ~0ul, SEC_IO_SIZE, RF_ACTIVE); + sc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rrid, + RF_ACTIVE); if (sc->sc_rres == NULL) return (ENXIO); @@ -276,8 +268,8 @@ sec_attach(device_t dev) /* Allocate I/O memory for SEC registers */ sc->sc_rrid = 0; - sc->sc_rres = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->sc_rrid, - 0ul, ~0ul, SEC_IO_SIZE, RF_ACTIVE); + sc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rrid, + RF_ACTIVE); if (sc->sc_rres == NULL) { device_printf(dev, "could not allocate I/O memory!\n"); @@ -295,12 +287,15 @@ sec_attach(device_t dev) if (error) goto fail2; - sc->sc_sec_irid = 1; - error = sec_setup_intr(sc, &sc->sc_sec_ires, &sc->sc_sec_ihand, - &sc->sc_sec_irid, sec_secondary_intr, "secondary"); - if (error) - goto fail3; + if (sc->sc_version == 3) { + sc->sc_sec_irid = 1; + error = sec_setup_intr(sc, &sc->sc_sec_ires, &sc->sc_sec_ihand, + &sc->sc_sec_irid, sec_secondary_intr, "secondary"); + + if (error) + goto fail3; + } /* Alloc DMA memory for descriptors and link tables */ error = sec_alloc_dma_mem(sc, &(sc->sc_desc_dmem), diff --git a/sys/dev/tsec/if_tsec.c b/sys/dev/tsec/if_tsec.c index 204fce932b2bf..7ba7dc68528bf 100644 --- a/sys/dev/tsec/if_tsec.c +++ b/sys/dev/tsec/if_tsec.c @@ -1,6 +1,6 @@ /*- - * Copyright (C) 2007-2008 Semihalf, Rafal Jaworowski <raj@semihalf.com> - * Copyright (C) 2006-2007 Semihalf, Piotr Kruszynski <ppk@semihalf.com> + * Copyright (C) 2007-2008 Semihalf, Rafal Jaworowski + * Copyright (C) 2006-2007 Semihalf, Piotr Kruszynski * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1563,7 +1563,7 @@ tsec_miibus_readreg(device_t dev, int phy, int reg) sc = device_get_softc(dev); - if (device_get_unit(dev) != phy) + if (sc->phyaddr != phy) return (0); sc = tsec0_sc; @@ -1591,9 +1591,8 @@ tsec_miibus_writereg(device_t dev, int phy, int reg, int value) sc = device_get_softc(dev); - if (device_get_unit(dev) != phy) - device_printf(dev, "Trying to write to an alien PHY(%d)\n", - phy); + if (sc->phyaddr != phy) + return (0); sc = tsec0_sc; diff --git a/sys/dev/tsec/if_tsec.h b/sys/dev/tsec/if_tsec.h index a0ac722b681b3..b980322025485 100644 --- a/sys/dev/tsec/if_tsec.h +++ b/sys/dev/tsec/if_tsec.h @@ -1,5 +1,5 @@ /*- - * Copyright (C) 2006-2007 Semihalf, Piotr Kruszynski <ppk@semihalf.com> + * Copyright (C) 2006-2007 Semihalf, Piotr Kruszynski * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,6 +28,8 @@ #ifndef _IF_TSEC_H #define _IF_TSEC_H +#include <dev/ofw/openfirm.h> + #define TSEC_RX_NUM_DESC 256 #define TSEC_TX_NUM_DESC 256 @@ -49,6 +51,7 @@ struct tsec_softc { struct mtx transmit_lock; /* transmitter lock */ struct mtx receive_lock; /* receiver lock */ + phandle_t node; device_t dev; device_t tsec_miibus; struct mii_data *tsec_mii; /* MII media control */ @@ -128,6 +131,8 @@ struct tsec_softc { /* currently received frame */ struct mbuf *frame; + + int phyaddr; }; /* interface to get/put generic objects */ diff --git a/sys/dev/tsec/if_tsec_ocp.c b/sys/dev/tsec/if_tsec_fdt.c index 1787aa7a5ffc5..e355e61a2b983 100644 --- a/sys/dev/tsec/if_tsec_ocp.c +++ b/sys/dev/tsec/if_tsec_fdt.c @@ -1,6 +1,6 @@ /*- - * Copyright (C) 2007-2008 Semihalf, Rafal Jaworowski <raj@semihalf.com> - * Copyright (C) 2006-2007 Semihalf, Piotr Kruszynski <ppk@semihalf.com> + * Copyright (C) 2007-2008 Semihalf, Rafal Jaworowski + * Copyright (C) 2006-2007 Semihalf, Piotr Kruszynski * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,10 +22,12 @@ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * From: FreeBSD: head/sys/dev/tsec/if_tsec_ocp.c 188712 2009-02-17 14:59:47Z raj */ /* - * OCP attachment driver for Freescale TSEC controller. + * FDT 'simple-bus' attachment for Freescale TSEC controller. */ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); @@ -50,36 +52,37 @@ __FBSDID("$FreeBSD$"); #include <net/if_media.h> #include <net/if_arp.h> +#include <dev/fdt/fdt_common.h> #include <dev/mii/mii.h> #include <dev/mii/miivar.h> - -#include <machine/bootinfo.h> -#include <machine/ocpbus.h> +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> +#include <dev/ofw/openfirm.h> #include <dev/tsec/if_tsec.h> #include <dev/tsec/if_tsecreg.h> #include "miibus_if.h" -#define OCP_TSEC_RID_TXIRQ 0 -#define OCP_TSEC_RID_RXIRQ 1 -#define OCP_TSEC_RID_ERRIRQ 2 +#define TSEC_RID_TXIRQ 0 +#define TSEC_RID_RXIRQ 1 +#define TSEC_RID_ERRIRQ 2 extern struct tsec_softc *tsec0_sc; -static int tsec_ocp_probe(device_t dev); -static int tsec_ocp_attach(device_t dev); -static int tsec_ocp_detach(device_t dev); -static int tsec_setup_intr(struct tsec_softc *sc, struct resource **ires, +static int tsec_fdt_probe(device_t dev); +static int tsec_fdt_attach(device_t dev); +static int tsec_fdt_detach(device_t dev); +static int tsec_setup_intr(struct tsec_softc *sc, struct resource **ires, void **ihand, int *irid, driver_intr_t handler, const char *iname); -static void tsec_release_intr(struct tsec_softc *sc, struct resource *ires, +static void tsec_release_intr(struct tsec_softc *sc, struct resource *ires, void *ihand, int irid, const char *iname); static device_method_t tsec_methods[] = { /* Device interface */ - DEVMETHOD(device_probe, tsec_ocp_probe), - DEVMETHOD(device_attach, tsec_ocp_attach), - DEVMETHOD(device_detach, tsec_ocp_detach), + DEVMETHOD(device_probe, tsec_fdt_probe), + DEVMETHOD(device_attach, tsec_fdt_attach), + DEVMETHOD(device_detach, tsec_fdt_detach), DEVMETHOD(device_shutdown, tsec_shutdown), DEVMETHOD(device_suspend, tsec_suspend), @@ -96,38 +99,30 @@ static device_method_t tsec_methods[] = { { 0, 0 } }; -static driver_t tsec_ocp_driver = { +static driver_t tsec_fdt_driver = { "tsec", tsec_methods, sizeof(struct tsec_softc), }; -DRIVER_MODULE(tsec, ocpbus, tsec_ocp_driver, tsec_devclass, 0, 0); -MODULE_DEPEND(tsec, ocpbus, 1, 1, 1); +DRIVER_MODULE(tsec, simplebus, tsec_fdt_driver, tsec_devclass, 0, 0); +MODULE_DEPEND(tsec, simplebus, 1, 1, 1); MODULE_DEPEND(tsec, ether, 1, 1, 1); static int -tsec_ocp_probe(device_t dev) +tsec_fdt_probe(device_t dev) { struct tsec_softc *sc; - device_t parent; - uintptr_t devtype; - int error; uint32_t id; - parent = device_get_parent(dev); - - error = BUS_READ_IVAR(parent, dev, OCPBUS_IVAR_DEVTYPE, &devtype); - if (error) - return (error); - if (devtype != OCPBUS_DEVTYPE_TSEC) + if (!ofw_bus_is_compatible(dev, "gianfar")) return (ENXIO); sc = device_get_softc(dev); sc->sc_rrid = 0; - sc->sc_rres = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->sc_rrid, - 0ul, ~0ul, TSEC_IO_SIZE, RF_ACTIVE); + sc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rrid, + RF_ACTIVE); if (sc->sc_rres == NULL) return (ENXIO); @@ -155,18 +150,23 @@ tsec_ocp_probe(device_t dev) } static int -tsec_ocp_attach(device_t dev) +tsec_fdt_attach(device_t dev) { struct tsec_softc *sc; int error = 0; sc = device_get_softc(dev); sc->dev = dev; + sc->node = ofw_bus_get_node(dev); /* XXX add comment on weird FSL's MII registers access design */ if (device_get_unit(dev) == 0) tsec0_sc = sc; + /* Get phy address from fdt */ + if (fdt_get_phyaddr(sc->node, &sc->phyaddr) != 0) + return (ENXIO); + /* Init timer */ callout_init(&sc->tsec_callout, 1); @@ -177,11 +177,11 @@ tsec_ocp_attach(device_t dev) MTX_DEF); mtx_init(&sc->ic_lock, device_get_nameunit(dev), "TSEC IC lock", MTX_DEF); - + /* Allocate IO memory for TSEC registers */ sc->sc_rrid = 0; - sc->sc_rres = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->sc_rrid, - 0ul, ~0ul, TSEC_IO_SIZE, RF_ACTIVE); + sc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rrid, + RF_ACTIVE); if (sc->sc_rres == NULL) { device_printf(dev, "could not allocate IO memory range!\n"); goto fail1; @@ -196,21 +196,21 @@ tsec_ocp_attach(device_t dev) } /* Set up interrupts (TX/RX/ERR) */ - sc->sc_transmit_irid = OCP_TSEC_RID_TXIRQ; + sc->sc_transmit_irid = TSEC_RID_TXIRQ; error = tsec_setup_intr(sc, &sc->sc_transmit_ires, &sc->sc_transmit_ihand, &sc->sc_transmit_irid, tsec_transmit_intr, "TX"); if (error) goto fail2; - sc->sc_receive_irid = OCP_TSEC_RID_RXIRQ; + sc->sc_receive_irid = TSEC_RID_RXIRQ; error = tsec_setup_intr(sc, &sc->sc_receive_ires, &sc->sc_receive_ihand, &sc->sc_receive_irid, tsec_receive_intr, "RX"); if (error) goto fail3; - sc->sc_error_irid = OCP_TSEC_RID_ERRIRQ; + sc->sc_error_irid = TSEC_RID_ERRIRQ; error = tsec_setup_intr(sc, &sc->sc_error_ires, &sc->sc_error_ihand, &sc->sc_error_irid, tsec_error_intr, "ERR"); @@ -239,8 +239,8 @@ tsec_setup_intr(struct tsec_softc *sc, struct resource **ires, void **ihand, { int error; - (*ires) = bus_alloc_resource_any(sc->dev, SYS_RES_IRQ, irid, RF_ACTIVE); - if ((*ires) == NULL) { + *ires = bus_alloc_resource_any(sc->dev, SYS_RES_IRQ, irid, RF_ACTIVE); + if (*ires == NULL) { device_printf(sc->dev, "could not allocate %s IRQ\n", iname); return (ENXIO); } @@ -250,7 +250,7 @@ tsec_setup_intr(struct tsec_softc *sc, struct resource **ires, void **ihand, device_printf(sc->dev, "failed to set up %s IRQ\n", iname); if (bus_release_resource(sc->dev, SYS_RES_IRQ, *irid, *ires)) device_printf(sc->dev, "could not release %s IRQ\n", iname); - (*ires) = NULL; + *ires = NULL; return (error); } return (0); @@ -277,7 +277,7 @@ tsec_release_intr(struct tsec_softc *sc, struct resource *ires, void *ihand, } static int -tsec_ocp_detach(device_t dev) +tsec_fdt_detach(device_t dev) { struct tsec_softc *sc; int error; @@ -322,14 +322,15 @@ tsec_get_hwaddr(struct tsec_softc *sc, uint8_t *addr) uint8_t addr[6]; } curmac; uint32_t a[6]; - device_t parent; - uintptr_t macaddr; + uint8_t lma[6]; int i; - parent = device_get_parent(sc->dev); - if (BUS_READ_IVAR(parent, sc->dev, OCPBUS_IVAR_MACADDR, - &macaddr) == 0) { - bcopy((uint8_t *)macaddr, addr, 6); + /* + * Retrieve hw address from the device tree. + */ + i = OF_getprop(sc->node, "local-mac-address", (void *)lma, 6); + if (i == 6) { + bcopy(lma, addr, 6); return; } diff --git a/sys/dev/uart/uart_bus_ocp.c b/sys/dev/uart/uart_bus_ocp.c deleted file mode 100644 index e7f09710ecf07..0000000000000 --- a/sys/dev/uart/uart_bus_ocp.c +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * Copyright 2006 by Juniper Networks. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/bus.h> -#include <sys/conf.h> -#include <sys/kernel.h> -#include <sys/lock.h> -#include <sys/malloc.h> -#include <sys/module.h> -#include <sys/tty.h> -#include <machine/bus.h> - -#include <machine/ocpbus.h> - -#include <dev/uart/uart.h> -#include <dev/uart/uart_bus.h> - -static int uart_ocp_probe(device_t); - -static device_method_t uart_ocp_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, uart_ocp_probe), - DEVMETHOD(device_attach, uart_bus_attach), - DEVMETHOD(device_detach, uart_bus_detach), - { 0, 0 } -}; - -static driver_t uart_ocp_driver = { - uart_driver_name, - uart_ocp_methods, - sizeof(struct uart_softc), -}; - -static int -uart_ocp_probe(device_t dev) -{ - device_t parent; - struct uart_softc *sc; - uintptr_t clock, devtype; - int error; - - parent = device_get_parent(dev); - - error = BUS_READ_IVAR(parent, dev, OCPBUS_IVAR_DEVTYPE, &devtype); - if (error) - return (error); - if (devtype != OCPBUS_DEVTYPE_UART) - return (ENXIO); - - sc = device_get_softc(dev); - sc->sc_class = &uart_ns8250_class; - - if (BUS_READ_IVAR(parent, dev, OCPBUS_IVAR_CLOCK, &clock)) - clock = 0; - return (uart_bus_probe(dev, 0, clock, 0, 0)); -} - -DRIVER_MODULE(uart, ocpbus, uart_ocp_driver, uart_devclass, 0, 0); diff --git a/sys/dev/uart/uart_cpu_powerpc.c b/sys/dev/uart/uart_cpu_powerpc.c index 8e4c1dab77094..997bdd8bcfc4e 100644 --- a/sys/dev/uart/uart_cpu_powerpc.c +++ b/sys/dev/uart/uart_cpu_powerpc.c @@ -27,57 +27,28 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "opt_platform.h" - #include <sys/param.h> #include <sys/systm.h> #include <vm/vm.h> #include <vm/pmap.h> #include <machine/bus.h> - -#ifndef MPC85XX -#include <dev/ofw/openfirm.h> #include <machine/ofw_machdep.h> -#endif +#include <dev/ofw/openfirm.h> #include <dev/uart/uart.h> #include <dev/uart/uart_cpu.h> -#ifdef MPC85XX -bus_space_tag_t uart_bus_space_io = &bs_be_tag; -bus_space_tag_t uart_bus_space_mem = &bs_be_tag; -#else bus_space_tag_t uart_bus_space_io = &bs_le_tag; bus_space_tag_t uart_bus_space_mem = &bs_le_tag; -#endif int uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) { -#ifdef MPC85XX - return ((b1->bsh == b2->bsh) ? 1 : 0); -#else + return ((pmap_kextract(b1->bsh) == pmap_kextract(b2->bsh)) ? 1 : 0); -#endif } -#ifdef MPC85XX -int -uart_cpu_getdev(int devtype, struct uart_devinfo *di) -{ - struct uart_class *class; - - class = &uart_ns8250_class; - if (class == NULL) - class = &uart_quicc_class; - if (class == NULL) - return (ENXIO); - - /* Check the environment. */ - return (uart_getenv(devtype, di, class)); -} -#else static int ofw_get_uart_console(phandle_t opts, phandle_t *result, const char *inputdev, const char *outputdev) @@ -174,4 +145,3 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di) di->parity = UART_PARITY_NONE; return (0); } -#endif |
