2008-08-26 10:41:49 +00:00
|
|
|
/*-
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
* Copyright (C) 2007-2008 Semihalf, Rafal Jaworowski
|
|
|
|
* Copyright (C) 2006-2007 Semihalf, Piotr Kruszynski
|
2008-08-26 10:41:49 +00:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
*
|
|
|
|
* From: FreeBSD: head/sys/dev/tsec/if_tsec_ocp.c 188712 2009-02-17 14:59:47Z raj
|
2008-08-26 10:41:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
* FDT 'simple-bus' attachment for Freescale TSEC controller.
|
2008-08-26 10:41:49 +00:00
|
|
|
*/
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/endian.h>
|
2013-10-29 11:17:49 +00:00
|
|
|
#include <sys/lock.h>
|
2008-08-26 10:41:49 +00:00
|
|
|
#include <sys/mbuf.h>
|
2013-10-29 11:17:49 +00:00
|
|
|
#include <sys/mutex.h>
|
2008-08-26 10:41:49 +00:00
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
|
|
|
|
#include <net/ethernet.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_media.h>
|
|
|
|
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
#include <dev/fdt/fdt_common.h>
|
2008-08-26 10:41:49 +00:00
|
|
|
#include <dev/mii/mii.h>
|
|
|
|
#include <dev/mii/miivar.h>
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
#include <dev/ofw/ofw_bus.h>
|
|
|
|
#include <dev/ofw/ofw_bus_subr.h>
|
|
|
|
#include <dev/ofw/openfirm.h>
|
2008-08-26 10:41:49 +00:00
|
|
|
|
|
|
|
#include <dev/tsec/if_tsec.h>
|
|
|
|
#include <dev/tsec/if_tsecreg.h>
|
|
|
|
|
|
|
|
#include "miibus_if.h"
|
|
|
|
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
#define TSEC_RID_TXIRQ 0
|
|
|
|
#define TSEC_RID_RXIRQ 1
|
|
|
|
#define TSEC_RID_ERRIRQ 2
|
2008-08-26 10:41:49 +00:00
|
|
|
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
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,
|
2008-08-26 10:41:49 +00:00
|
|
|
void **ihand, int *irid, driver_intr_t handler, const char *iname);
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
static void tsec_release_intr(struct tsec_softc *sc, struct resource *ires,
|
2008-08-26 10:41:49 +00:00
|
|
|
void *ihand, int irid, const char *iname);
|
|
|
|
|
|
|
|
static device_method_t tsec_methods[] = {
|
|
|
|
/* Device interface */
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
DEVMETHOD(device_probe, tsec_fdt_probe),
|
|
|
|
DEVMETHOD(device_attach, tsec_fdt_attach),
|
|
|
|
DEVMETHOD(device_detach, tsec_fdt_detach),
|
2008-08-26 10:41:49 +00:00
|
|
|
|
|
|
|
DEVMETHOD(device_shutdown, tsec_shutdown),
|
|
|
|
DEVMETHOD(device_suspend, tsec_suspend),
|
|
|
|
DEVMETHOD(device_resume, tsec_resume),
|
|
|
|
|
|
|
|
/* MII interface */
|
|
|
|
DEVMETHOD(miibus_readreg, tsec_miibus_readreg),
|
|
|
|
DEVMETHOD(miibus_writereg, tsec_miibus_writereg),
|
|
|
|
DEVMETHOD(miibus_statchg, tsec_miibus_statchg),
|
2011-11-22 21:28:20 +00:00
|
|
|
|
|
|
|
DEVMETHOD_END
|
2008-08-26 10:41:49 +00:00
|
|
|
};
|
|
|
|
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
static driver_t tsec_fdt_driver = {
|
2008-08-26 10:41:49 +00:00
|
|
|
"tsec",
|
|
|
|
tsec_methods,
|
|
|
|
sizeof(struct tsec_softc),
|
|
|
|
};
|
|
|
|
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
DRIVER_MODULE(tsec, simplebus, tsec_fdt_driver, tsec_devclass, 0, 0);
|
2008-08-26 10:41:49 +00:00
|
|
|
|
|
|
|
static int
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
tsec_fdt_probe(device_t dev)
|
2008-08-26 10:41:49 +00:00
|
|
|
{
|
|
|
|
struct tsec_softc *sc;
|
|
|
|
uint32_t id;
|
|
|
|
|
2014-02-02 19:17:28 +00:00
|
|
|
if (!ofw_bus_status_okay(dev))
|
|
|
|
return (ENXIO);
|
|
|
|
|
2013-11-11 15:43:21 +00:00
|
|
|
if (ofw_bus_get_type(dev) == NULL ||
|
|
|
|
strcmp(ofw_bus_get_type(dev), "network") != 0)
|
|
|
|
return (ENXIO);
|
|
|
|
|
2016-05-19 00:04:58 +00:00
|
|
|
if (!ofw_bus_is_compatible(dev, "gianfar") &&
|
|
|
|
!ofw_bus_is_compatible(dev, "fsl,etsec2"))
|
2008-08-26 10:41:49 +00:00
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
sc = device_get_softc(dev);
|
|
|
|
|
|
|
|
sc->sc_rrid = 0;
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
sc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rrid,
|
|
|
|
RF_ACTIVE);
|
2008-08-26 10:41:49 +00:00
|
|
|
if (sc->sc_rres == NULL)
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
sc->sc_bas.bsh = rman_get_bushandle(sc->sc_rres);
|
|
|
|
sc->sc_bas.bst = rman_get_bustag(sc->sc_rres);
|
|
|
|
|
2009-02-17 14:57:05 +00:00
|
|
|
/* Check if we are eTSEC (enhanced TSEC) */
|
|
|
|
id = TSEC_READ(sc, TSEC_REG_ID);
|
|
|
|
sc->is_etsec = ((id >> 16) == TSEC_ETSEC_ID) ? 1 : 0;
|
|
|
|
id |= TSEC_READ(sc, TSEC_REG_ID2);
|
2008-08-26 10:41:49 +00:00
|
|
|
|
|
|
|
bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_rrid, sc->sc_rres);
|
|
|
|
|
2009-02-17 14:57:05 +00:00
|
|
|
if (id == 0) {
|
|
|
|
device_printf(dev, "could not identify TSEC type\n");
|
2008-08-26 10:41:49 +00:00
|
|
|
return (ENXIO);
|
2009-02-17 14:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->is_etsec)
|
|
|
|
device_set_desc(dev, "Enhanced Three-Speed Ethernet Controller");
|
|
|
|
else
|
|
|
|
device_set_desc(dev, "Three-Speed Ethernet Controller");
|
2008-08-26 10:41:49 +00:00
|
|
|
|
|
|
|
return (BUS_PROBE_DEFAULT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
tsec_fdt_attach(device_t dev)
|
2008-08-26 10:41:49 +00:00
|
|
|
{
|
|
|
|
struct tsec_softc *sc;
|
2013-11-11 15:43:21 +00:00
|
|
|
phandle_t phy;
|
2008-08-26 10:41:49 +00:00
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
sc = device_get_softc(dev);
|
|
|
|
sc->dev = dev;
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
sc->node = ofw_bus_get_node(dev);
|
2008-08-26 10:41:49 +00:00
|
|
|
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
/* Get phy address from fdt */
|
2013-11-11 15:43:21 +00:00
|
|
|
if (OF_getencprop(sc->node, "phy-handle", &phy, sizeof(phy)) <= 0) {
|
|
|
|
device_printf(dev, "PHY not found in device tree");
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
return (ENXIO);
|
2013-11-11 15:43:21 +00:00
|
|
|
}
|
|
|
|
|
2014-09-01 18:51:01 +00:00
|
|
|
phy = OF_node_from_xref(phy);
|
2016-02-16 15:18:12 +00:00
|
|
|
OF_decode_addr(OF_parent(phy), 0, &sc->phy_bst, &sc->phy_bsh, NULL);
|
2013-11-11 15:43:21 +00:00
|
|
|
OF_getencprop(phy, "reg", &sc->phyaddr, sizeof(sc->phyaddr));
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
|
2008-08-26 10:41:49 +00:00
|
|
|
/* Init timer */
|
|
|
|
callout_init(&sc->tsec_callout, 1);
|
|
|
|
|
|
|
|
/* Init locks */
|
|
|
|
mtx_init(&sc->transmit_lock, device_get_nameunit(dev), "TSEC TX lock",
|
|
|
|
MTX_DEF);
|
|
|
|
mtx_init(&sc->receive_lock, device_get_nameunit(dev), "TSEC RX lock",
|
|
|
|
MTX_DEF);
|
2009-02-17 14:57:05 +00:00
|
|
|
mtx_init(&sc->ic_lock, device_get_nameunit(dev), "TSEC IC lock",
|
|
|
|
MTX_DEF);
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
|
2008-08-26 10:41:49 +00:00
|
|
|
/* Allocate IO memory for TSEC registers */
|
|
|
|
sc->sc_rrid = 0;
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
sc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rrid,
|
|
|
|
RF_ACTIVE);
|
2008-08-26 10:41:49 +00:00
|
|
|
if (sc->sc_rres == NULL) {
|
|
|
|
device_printf(dev, "could not allocate IO memory range!\n");
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
sc->sc_bas.bsh = rman_get_bushandle(sc->sc_rres);
|
|
|
|
sc->sc_bas.bst = rman_get_bustag(sc->sc_rres);
|
|
|
|
|
|
|
|
/* TSEC attach */
|
|
|
|
if (tsec_attach(sc) != 0) {
|
|
|
|
device_printf(dev, "could not be configured\n");
|
|
|
|
goto fail2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set up interrupts (TX/RX/ERR) */
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
sc->sc_transmit_irid = TSEC_RID_TXIRQ;
|
2008-08-26 10:41:49 +00:00
|
|
|
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;
|
|
|
|
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
sc->sc_receive_irid = TSEC_RID_RXIRQ;
|
2008-08-26 10:41:49 +00:00
|
|
|
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;
|
|
|
|
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
sc->sc_error_irid = TSEC_RID_ERRIRQ;
|
2008-08-26 10:41:49 +00:00
|
|
|
error = tsec_setup_intr(sc, &sc->sc_error_ires,
|
|
|
|
&sc->sc_error_ihand, &sc->sc_error_irid,
|
|
|
|
tsec_error_intr, "ERR");
|
|
|
|
if (error)
|
|
|
|
goto fail4;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
fail4:
|
|
|
|
tsec_release_intr(sc, sc->sc_receive_ires, sc->sc_receive_ihand,
|
|
|
|
sc->sc_receive_irid, "RX");
|
|
|
|
fail3:
|
|
|
|
tsec_release_intr(sc, sc->sc_transmit_ires, sc->sc_transmit_ihand,
|
|
|
|
sc->sc_transmit_irid, "TX");
|
|
|
|
fail2:
|
|
|
|
bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_rrid, sc->sc_rres);
|
|
|
|
fail1:
|
|
|
|
mtx_destroy(&sc->receive_lock);
|
|
|
|
mtx_destroy(&sc->transmit_lock);
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tsec_setup_intr(struct tsec_softc *sc, struct resource **ires, void **ihand,
|
|
|
|
int *irid, driver_intr_t handler, const char *iname)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
*ires = bus_alloc_resource_any(sc->dev, SYS_RES_IRQ, irid, RF_ACTIVE);
|
|
|
|
if (*ires == NULL) {
|
2008-08-26 10:41:49 +00:00
|
|
|
device_printf(sc->dev, "could not allocate %s IRQ\n", iname);
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
error = bus_setup_intr(sc->dev, *ires, INTR_TYPE_NET | INTR_MPSAFE,
|
|
|
|
NULL, handler, sc, ihand);
|
|
|
|
if (error) {
|
|
|
|
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);
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
*ires = NULL;
|
2008-08-26 10:41:49 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tsec_release_intr(struct tsec_softc *sc, struct resource *ires, void *ihand,
|
|
|
|
int irid, const char *iname)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (ires == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
error = bus_teardown_intr(sc->dev, ires, ihand);
|
|
|
|
if (error)
|
|
|
|
device_printf(sc->dev, "bus_teardown_intr() failed for %s intr"
|
|
|
|
", error %d\n", iname, error);
|
|
|
|
|
|
|
|
error = bus_release_resource(sc->dev, SYS_RES_IRQ, irid, ires);
|
|
|
|
if (error)
|
2009-02-17 14:59:47 +00:00
|
|
|
device_printf(sc->dev, "bus_release_resource() failed for %s "
|
|
|
|
"intr, error %d\n", iname, error);
|
2008-08-26 10:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
tsec_fdt_detach(device_t dev)
|
2008-08-26 10:41:49 +00:00
|
|
|
{
|
|
|
|
struct tsec_softc *sc;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
sc = device_get_softc(dev);
|
|
|
|
|
|
|
|
/* Wait for stopping watchdog */
|
|
|
|
callout_drain(&sc->tsec_callout);
|
|
|
|
|
|
|
|
/* Stop and release all interrupts */
|
|
|
|
tsec_release_intr(sc, sc->sc_transmit_ires, sc->sc_transmit_ihand,
|
|
|
|
sc->sc_transmit_irid, "TX");
|
|
|
|
tsec_release_intr(sc, sc->sc_receive_ires, sc->sc_receive_ihand,
|
|
|
|
sc->sc_receive_irid, "RX");
|
|
|
|
tsec_release_intr(sc, sc->sc_error_ires, sc->sc_error_ihand,
|
|
|
|
sc->sc_error_irid, "ERR");
|
|
|
|
|
|
|
|
/* TSEC detach */
|
|
|
|
tsec_detach(sc);
|
|
|
|
|
|
|
|
/* Free IO memory handler */
|
|
|
|
if (sc->sc_rres) {
|
|
|
|
error = bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_rrid,
|
|
|
|
sc->sc_rres);
|
|
|
|
if (error)
|
|
|
|
device_printf(dev, "bus_release_resource() failed for"
|
|
|
|
" IO memory, error %d\n", error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Destroy locks */
|
|
|
|
mtx_destroy(&sc->receive_lock);
|
|
|
|
mtx_destroy(&sc->transmit_lock);
|
2009-02-17 14:57:05 +00:00
|
|
|
mtx_destroy(&sc->ic_lock);
|
2008-08-26 10:41:49 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tsec_get_hwaddr(struct tsec_softc *sc, uint8_t *addr)
|
|
|
|
{
|
|
|
|
union {
|
|
|
|
uint32_t reg[2];
|
|
|
|
uint8_t addr[6];
|
2011-01-28 23:40:13 +00:00
|
|
|
} hw;
|
2008-08-26 10:41:49 +00:00
|
|
|
int i;
|
|
|
|
|
2011-01-28 23:40:13 +00:00
|
|
|
hw.reg[0] = hw.reg[1] = 0;
|
|
|
|
|
|
|
|
/* Retrieve the hardware address from the device tree. */
|
|
|
|
i = OF_getprop(sc->node, "local-mac-address", (void *)hw.addr, 6);
|
|
|
|
if (i == 6 && (hw.reg[0] != 0 || hw.reg[1] != 0)) {
|
|
|
|
bcopy(hw.addr, addr, 6);
|
2008-08-26 10:41:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-11-11 15:43:21 +00:00
|
|
|
/* Also try the mac-address property, which is second-best */
|
|
|
|
i = OF_getprop(sc->node, "mac-address", (void *)hw.addr, 6);
|
|
|
|
if (i == 6 && (hw.reg[0] != 0 || hw.reg[1] != 0)) {
|
|
|
|
bcopy(hw.addr, addr, 6);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-26 10:41:49 +00:00
|
|
|
/*
|
|
|
|
* Fall back -- use the currently programmed address in the hope that
|
|
|
|
* it was set be firmware...
|
|
|
|
*/
|
2011-01-28 23:40:13 +00:00
|
|
|
hw.reg[0] = TSEC_READ(sc, TSEC_REG_MACSTNADDR1);
|
|
|
|
hw.reg[1] = TSEC_READ(sc, TSEC_REG_MACSTNADDR2);
|
2008-08-26 10:41:49 +00:00
|
|
|
for (i = 0; i < 6; i++)
|
2011-01-28 23:40:13 +00:00
|
|
|
addr[5-i] = hw.addr[i];
|
2008-08-26 10:41:49 +00:00
|
|
|
}
|