2008-10-25 06:03:40 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2006-2008, Juniper Networks, Inc.
|
2008-12-18 18:27:12 +00:00
|
|
|
* Copyright (c) 2008 Semihalf, Rafal Czubak
|
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) 2009 The FreeBSD Foundation
|
2008-10-25 06:03:40 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
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
|
|
|
* Portions of this software were developed by Semihalf
|
|
|
|
* under sponsorship from the FreeBSD Foundation.
|
|
|
|
*
|
2008-10-25 06:03:40 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2016-03-02 00:18:05 +00:00
|
|
|
#include "opt_platform.h"
|
|
|
|
|
2008-10-25 06:03:40 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/ktr.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/pmap.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>
|
|
|
|
#include <dev/ofw/ofw_bus.h>
|
|
|
|
#include <dev/ofw/ofw_bus_subr.h>
|
|
|
|
|
2008-12-18 18:27:12 +00:00
|
|
|
#include <powerpc/mpc85xx/mpc85xx.h>
|
2008-10-25 06:03:40 +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
|
|
|
#include "ofw_bus_if.h"
|
|
|
|
#include "lbc.h"
|
2008-10-25 06:03:40 +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
|
|
|
#ifdef DEBUG
|
|
|
|
#define debugf(fmt, args...) do { printf("%s(): ", __func__); \
|
|
|
|
printf(fmt,##args); } while (0)
|
|
|
|
#else
|
|
|
|
#define debugf(fmt, args...)
|
|
|
|
#endif
|
2008-10-25 06:03:40 +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 MALLOC_DEFINE(M_LBC, "localbus", "localbus devices information");
|
2008-12-18 18:27:12 +00:00
|
|
|
|
2008-10-25 06:03:40 +00:00
|
|
|
static int lbc_probe(device_t);
|
|
|
|
static int lbc_attach(device_t);
|
|
|
|
static int lbc_shutdown(device_t);
|
2016-03-02 00:18:05 +00:00
|
|
|
static int lbc_activate_resource(device_t bus __unused, device_t child __unused,
|
|
|
|
int type, int rid __unused, struct resource *r);
|
|
|
|
static int lbc_deactivate_resource(device_t bus __unused,
|
|
|
|
device_t child __unused, int type __unused, int rid __unused,
|
|
|
|
struct resource *r);
|
2008-10-25 06:03:40 +00:00
|
|
|
static struct resource *lbc_alloc_resource(device_t, device_t, int, int *,
|
2016-01-27 02:23:54 +00:00
|
|
|
rman_res_t, rman_res_t, rman_res_t, u_int);
|
2008-10-25 06:03:40 +00:00
|
|
|
static int lbc_print_child(device_t, device_t);
|
|
|
|
static int lbc_release_resource(device_t, device_t, int, int,
|
|
|
|
struct resource *);
|
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 const struct ofw_bus_devinfo *lbc_get_devinfo(device_t, device_t);
|
2008-10-25 06:03:40 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Bus interface definition
|
|
|
|
*/
|
|
|
|
static device_method_t lbc_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, lbc_probe),
|
|
|
|
DEVMETHOD(device_attach, lbc_attach),
|
|
|
|
DEVMETHOD(device_shutdown, lbc_shutdown),
|
|
|
|
|
|
|
|
/* Bus interface */
|
|
|
|
DEVMETHOD(bus_print_child, lbc_print_child),
|
|
|
|
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
|
|
|
|
DEVMETHOD(bus_teardown_intr, NULL),
|
|
|
|
|
|
|
|
DEVMETHOD(bus_alloc_resource, lbc_alloc_resource),
|
|
|
|
DEVMETHOD(bus_release_resource, lbc_release_resource),
|
2016-03-02 00:18:05 +00:00
|
|
|
DEVMETHOD(bus_activate_resource, lbc_activate_resource),
|
|
|
|
DEVMETHOD(bus_deactivate_resource, lbc_deactivate_resource),
|
2008-10-25 06:03:40 +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
|
|
|
/* OFW bus interface */
|
|
|
|
DEVMETHOD(ofw_bus_get_devinfo, lbc_get_devinfo),
|
|
|
|
DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat),
|
|
|
|
DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model),
|
|
|
|
DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name),
|
|
|
|
DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node),
|
|
|
|
DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type),
|
|
|
|
|
2008-10-25 06:03:40 +00:00
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t lbc_driver = {
|
|
|
|
"lbc",
|
|
|
|
lbc_methods,
|
|
|
|
sizeof(struct lbc_softc)
|
|
|
|
};
|
2008-12-18 18:27:12 +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
|
|
|
devclass_t lbc_devclass;
|
2008-12-18 18:27:12 +00:00
|
|
|
|
2016-02-03 01:29:06 +00:00
|
|
|
EARLY_DRIVER_MODULE(lbc, ofwbus, lbc_driver, lbc_devclass,
|
|
|
|
0, 0, BUS_PASS_BUS);
|
2008-12-18 18:27:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate address mask used by OR(n) registers. Use memory region size to
|
|
|
|
* determine mask value. The size must be a power of two and within the range
|
|
|
|
* of 32KB - 4GB. Otherwise error code is returned. Value representing
|
|
|
|
* 4GB size can be passed as 0xffffffff.
|
|
|
|
*/
|
|
|
|
static uint32_t
|
|
|
|
lbc_address_mask(uint32_t size)
|
|
|
|
{
|
|
|
|
int n = 15;
|
|
|
|
|
2016-01-01 15:36:56 +00:00
|
|
|
if (size == ~0)
|
2008-12-18 18:27:12 +00:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
while (n < 32) {
|
2016-01-01 15:36:56 +00:00
|
|
|
if (size == (1U << n))
|
2008-12-18 18:27:12 +00:00
|
|
|
break;
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n == 32)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
return (0xffff8000 << (n - 15));
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
lbc_banks_unmap(struct lbc_softc *sc)
|
2008-10-25 06:03:40 +00:00
|
|
|
{
|
2012-05-24 21:23:13 +00:00
|
|
|
int r;
|
2008-10-25 06:03:40 +00:00
|
|
|
|
2012-05-24 21:23:13 +00:00
|
|
|
r = 0;
|
|
|
|
while (r < LBC_DEV_MAX) {
|
|
|
|
if (sc->sc_range[r].size == 0)
|
|
|
|
return;
|
2008-12-18 18:27:12 +00:00
|
|
|
|
2012-05-24 21:23:13 +00:00
|
|
|
pmap_unmapdev(sc->sc_range[r].kva, sc->sc_range[r].size);
|
|
|
|
law_disable(OCP85XX_TGTIF_LBC, sc->sc_range[r].addr,
|
|
|
|
sc->sc_range[r].size);
|
|
|
|
r++;
|
2008-10-25 06:03:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-18 18:27:12 +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
|
|
|
lbc_banks_map(struct lbc_softc *sc)
|
2008-12-18 18:27:12 +00:00
|
|
|
{
|
2012-05-24 21:23:13 +00:00
|
|
|
vm_paddr_t end, start;
|
|
|
|
vm_size_t size;
|
|
|
|
u_int i, r, ranges, s;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
bzero(sc->sc_range, sizeof(sc->sc_range));
|
2008-12-18 18:27:12 +00:00
|
|
|
|
2012-05-24 21:23:13 +00:00
|
|
|
/*
|
|
|
|
* Determine number of discontiguous address ranges to program.
|
|
|
|
*/
|
|
|
|
ranges = 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
|
|
|
for (i = 0; i < LBC_DEV_MAX; i++) {
|
2012-05-24 21:23:13 +00:00
|
|
|
size = sc->sc_banks[i].size;
|
|
|
|
if (size == 0)
|
2008-12-18 18:27:12 +00:00
|
|
|
continue;
|
|
|
|
|
2012-05-24 21:23:13 +00:00
|
|
|
start = sc->sc_banks[i].addr;
|
|
|
|
for (r = 0; r < ranges; r++) {
|
|
|
|
/* Avoid wrap-around bugs. */
|
|
|
|
end = sc->sc_range[r].addr - 1 + sc->sc_range[r].size;
|
|
|
|
if (start > 0 && end == start - 1) {
|
|
|
|
sc->sc_range[r].size += size;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* Avoid wrap-around bugs. */
|
|
|
|
end = start - 1 + size;
|
|
|
|
if (sc->sc_range[r].addr > 0 &&
|
|
|
|
end == sc->sc_range[r].addr - 1) {
|
|
|
|
sc->sc_range[r].addr = start;
|
|
|
|
sc->sc_range[r].size += size;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (r == ranges) {
|
|
|
|
/* New range; add using insertion sort */
|
|
|
|
r = 0;
|
|
|
|
while (r < ranges && sc->sc_range[r].addr < start)
|
|
|
|
r++;
|
|
|
|
for (s = ranges; s > r; s--)
|
|
|
|
sc->sc_range[s] = sc->sc_range[s-1];
|
|
|
|
sc->sc_range[r].addr = start;
|
|
|
|
sc->sc_range[r].size = size;
|
|
|
|
ranges++;
|
|
|
|
}
|
|
|
|
}
|
2008-12-18 18:27:12 +00:00
|
|
|
|
2012-05-24 21:23:13 +00:00
|
|
|
/*
|
|
|
|
* Ranges are sorted so quickly go over the list to merge ranges
|
|
|
|
* that grew toward each other while building the ranges.
|
|
|
|
*/
|
|
|
|
r = 0;
|
|
|
|
while (r < ranges - 1) {
|
|
|
|
end = sc->sc_range[r].addr + sc->sc_range[r].size;
|
|
|
|
if (end != sc->sc_range[r+1].addr) {
|
|
|
|
r++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
sc->sc_range[r].size += sc->sc_range[r+1].size;
|
|
|
|
for (s = r + 1; s < ranges - 1; s++)
|
|
|
|
sc->sc_range[s] = sc->sc_range[s+1];
|
|
|
|
bzero(&sc->sc_range[s], sizeof(sc->sc_range[s]));
|
|
|
|
ranges--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure LAW for the LBC ranges and map the physical memory
|
|
|
|
* range into KVA.
|
|
|
|
*/
|
|
|
|
for (r = 0; r < ranges; r++) {
|
|
|
|
start = sc->sc_range[r].addr;
|
|
|
|
size = sc->sc_range[r].size;
|
2008-12-18 18:27:12 +00:00
|
|
|
error = law_enable(OCP85XX_TGTIF_LBC, start, size);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
2012-05-24 21:23:13 +00:00
|
|
|
sc->sc_range[r].kva = (vm_offset_t)pmap_mapdev(start, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX: need something better here? */
|
|
|
|
if (ranges == 0)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
/* Assign KVA to banks based on the enclosing range. */
|
|
|
|
for (i = 0; i < LBC_DEV_MAX; i++) {
|
|
|
|
size = sc->sc_banks[i].size;
|
|
|
|
if (size == 0)
|
|
|
|
continue;
|
2008-12-18 18:27:12 +00:00
|
|
|
|
2012-05-24 21:23:13 +00:00
|
|
|
start = sc->sc_banks[i].addr;
|
|
|
|
for (r = 0; r < ranges; r++) {
|
|
|
|
end = sc->sc_range[r].addr - 1 + sc->sc_range[r].size;
|
|
|
|
if (start >= sc->sc_range[r].addr &&
|
|
|
|
start - 1 + size <= end)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (r < ranges) {
|
|
|
|
sc->sc_banks[i].kva = sc->sc_range[r].kva +
|
|
|
|
(start - sc->sc_range[r].addr);
|
2008-12-18 18:27:12 +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
|
|
|
}
|
2012-05-24 21:23:13 +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
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
lbc_banks_enable(struct lbc_softc *sc)
|
|
|
|
{
|
2016-01-01 15:36:56 +00:00
|
|
|
uint32_t size;
|
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
|
|
|
uint32_t regval;
|
|
|
|
int error, i;
|
2008-12-18 18:27:12 +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
|
|
|
for (i = 0; i < LBC_DEV_MAX; i++) {
|
|
|
|
size = sc->sc_banks[i].size;
|
2012-07-03 00:06:14 +00:00
|
|
|
if (size == 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
|
|
|
continue;
|
2012-05-24 21:23:13 +00:00
|
|
|
|
2008-12-18 18:27:12 +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
|
|
|
* Compute and program BR value.
|
2008-12-18 18:27:12 +00:00
|
|
|
*/
|
2012-05-24 21:23:13 +00:00
|
|
|
regval = sc->sc_banks[i].addr;
|
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
|
|
|
switch (sc->sc_banks[i].width) {
|
2008-12-18 18:27:12 +00:00
|
|
|
case 8:
|
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
|
|
|
regval |= (1 << 11);
|
2008-12-18 18:27:12 +00:00
|
|
|
break;
|
|
|
|
case 16:
|
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
|
|
|
regval |= (2 << 11);
|
2008-12-18 18:27:12 +00:00
|
|
|
break;
|
|
|
|
case 32:
|
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
|
|
|
regval |= (3 << 11);
|
2008-12-18 18:27:12 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
goto fail;
|
|
|
|
}
|
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
|
|
|
regval |= (sc->sc_banks[i].decc << 9);
|
|
|
|
regval |= (sc->sc_banks[i].wp << 8);
|
|
|
|
regval |= (sc->sc_banks[i].msel << 5);
|
|
|
|
regval |= (sc->sc_banks[i].atom << 2);
|
|
|
|
regval |= 1;
|
2012-05-24 21:23:13 +00:00
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh,
|
|
|
|
LBC85XX_BR(i), regval);
|
2008-12-18 18:27:12 +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
|
|
|
* Compute and program OR value.
|
2008-12-18 18:27:12 +00:00
|
|
|
*/
|
2012-05-24 21:23:13 +00:00
|
|
|
regval = lbc_address_mask(size);
|
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
|
|
|
switch (sc->sc_banks[i].msel) {
|
2008-12-18 18:27:12 +00:00
|
|
|
case LBCRES_MSEL_GPCM:
|
|
|
|
/* TODO Add flag support for option registers */
|
2012-05-24 21:23:13 +00:00
|
|
|
regval |= 0x0ff7;
|
2008-12-18 18:27:12 +00:00
|
|
|
break;
|
|
|
|
case LBCRES_MSEL_FCM:
|
2012-05-24 21:23:13 +00:00
|
|
|
/* TODO Add flag support for options register */
|
|
|
|
regval |= 0x0796;
|
|
|
|
break;
|
2008-12-18 18:27:12 +00:00
|
|
|
case LBCRES_MSEL_UPMA:
|
|
|
|
case LBCRES_MSEL_UPMB:
|
|
|
|
case LBCRES_MSEL_UPMC:
|
|
|
|
printf("UPM mode not supported yet!");
|
|
|
|
error = ENOSYS;
|
|
|
|
goto fail;
|
|
|
|
}
|
2012-05-24 21:23:13 +00:00
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh,
|
|
|
|
LBC85XX_OR(i), regval);
|
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-12-18 18:27:12 +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
|
|
|
return (0);
|
|
|
|
|
|
|
|
fail:
|
|
|
|
lbc_banks_unmap(sc);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
fdt_lbc_fixup(phandle_t node, struct lbc_softc *sc, struct lbc_devinfo *di)
|
|
|
|
{
|
|
|
|
pcell_t width;
|
|
|
|
int bank;
|
2008-12-18 18:27:12 +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
|
|
|
if (OF_getprop(node, "bank-width", (void *)&width, sizeof(width)) <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bank = di->di_bank;
|
|
|
|
if (sc->sc_banks[bank].size == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Express width in bits. */
|
|
|
|
sc->sc_banks[bank].width = width * 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
fdt_lbc_reg_decode(phandle_t node, struct lbc_softc *sc,
|
|
|
|
struct lbc_devinfo *di)
|
|
|
|
{
|
|
|
|
u_long start, end, count;
|
|
|
|
pcell_t *reg, *regptr;
|
|
|
|
pcell_t addr_cells, size_cells;
|
|
|
|
int tuple_size, tuples;
|
|
|
|
int i, rv, bank;
|
|
|
|
|
|
|
|
if (fdt_addrsize_cells(OF_parent(node), &addr_cells, &size_cells) != 0)
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
tuple_size = sizeof(pcell_t) * (addr_cells + size_cells);
|
|
|
|
tuples = OF_getprop_alloc(node, "reg", tuple_size, (void **)®);
|
|
|
|
debugf("addr_cells = %d, size_cells = %d\n", addr_cells, size_cells);
|
|
|
|
debugf("tuples = %d, tuple size = %d\n", tuples, tuple_size);
|
|
|
|
if (tuples <= 0)
|
|
|
|
/* No 'reg' property in this node. */
|
2008-12-18 18:27:12 +00:00
|
|
|
return (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
|
|
|
|
|
|
|
regptr = reg;
|
|
|
|
for (i = 0; i < tuples; i++) {
|
|
|
|
|
|
|
|
bank = fdt_data_get((void *)reg, 1);
|
|
|
|
di->di_bank = bank;
|
|
|
|
reg += 1;
|
|
|
|
|
|
|
|
/* Get address/size. */
|
|
|
|
rv = fdt_data_to_res(reg, addr_cells - 1, size_cells, &start,
|
|
|
|
&count);
|
|
|
|
if (rv != 0) {
|
|
|
|
resource_list_free(&di->di_res);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
reg += addr_cells - 1 + size_cells;
|
|
|
|
|
|
|
|
/* Calculate address range relative to VA base. */
|
2012-05-24 21:23:13 +00:00
|
|
|
start = sc->sc_banks[bank].kva + start;
|
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
|
|
|
end = start + count - 1;
|
|
|
|
|
|
|
|
debugf("reg addr bank = %d, start = %lx, end = %lx, "
|
|
|
|
"count = %lx\n", bank, start, end, count);
|
|
|
|
|
|
|
|
/* Use bank (CS) cell as rid. */
|
|
|
|
resource_list_add(&di->di_res, SYS_RES_MEMORY, bank, start,
|
|
|
|
end, count);
|
2008-12-18 18:27:12 +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
|
|
|
rv = 0;
|
|
|
|
out:
|
2016-05-14 20:06:38 +00:00
|
|
|
OF_prop_free(regptr);
|
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 (rv);
|
2008-12-18 18:27:12 +00:00
|
|
|
}
|
|
|
|
|
2012-07-03 00:06:14 +00:00
|
|
|
static void
|
|
|
|
lbc_intr(void *arg)
|
|
|
|
{
|
|
|
|
struct lbc_softc *sc = arg;
|
|
|
|
uint32_t ltesr;
|
|
|
|
|
|
|
|
ltesr = bus_space_read_4(sc->sc_bst, sc->sc_bsh, LBC85XX_LTESR);
|
|
|
|
sc->sc_ltesr = ltesr;
|
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh, LBC85XX_LTESR, ltesr);
|
|
|
|
wakeup(sc->sc_dev);
|
|
|
|
}
|
|
|
|
|
2008-10-25 06:03:40 +00:00
|
|
|
static int
|
|
|
|
lbc_probe(device_t 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
|
|
|
if (!(ofw_bus_is_compatible(dev, "fsl,lbc") ||
|
|
|
|
ofw_bus_is_compatible(dev, "fsl,elbc")))
|
2008-10-25 06:03:40 +00:00
|
|
|
return (ENXIO);
|
|
|
|
|
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
|
|
|
device_set_desc(dev, "Freescale Local Bus Controller");
|
2008-10-25 06:03:40 +00:00
|
|
|
return (BUS_PROBE_DEFAULT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
lbc_attach(device_t dev)
|
|
|
|
{
|
|
|
|
struct lbc_softc *sc;
|
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
|
|
|
struct lbc_devinfo *di;
|
2008-10-25 06:03:40 +00:00
|
|
|
struct rman *rm;
|
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
|
|
|
u_long offset, start, size;
|
|
|
|
device_t cdev;
|
|
|
|
phandle_t node, child;
|
|
|
|
pcell_t *ranges, *rangesptr;
|
|
|
|
int tuple_size, tuples;
|
|
|
|
int par_addr_cells;
|
|
|
|
int bank, error, i;
|
2008-10-25 06:03:40 +00:00
|
|
|
|
|
|
|
sc = device_get_softc(dev);
|
|
|
|
sc->sc_dev = dev;
|
|
|
|
|
2012-07-03 00:06:14 +00:00
|
|
|
sc->sc_mrid = 0;
|
|
|
|
sc->sc_mres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_mrid,
|
2008-10-25 06:03:40 +00:00
|
|
|
RF_ACTIVE);
|
2012-07-03 00:06:14 +00:00
|
|
|
if (sc->sc_mres == NULL)
|
2008-10-25 06:03:40 +00:00
|
|
|
return (ENXIO);
|
|
|
|
|
2012-07-03 00:06:14 +00:00
|
|
|
sc->sc_bst = rman_get_bustag(sc->sc_mres);
|
|
|
|
sc->sc_bsh = rman_get_bushandle(sc->sc_mres);
|
|
|
|
|
|
|
|
for (bank = 0; bank < LBC_DEV_MAX; bank++) {
|
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh, LBC85XX_BR(bank), 0);
|
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh, LBC85XX_OR(bank), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize configuration register:
|
|
|
|
* - enable Local Bus
|
|
|
|
* - set data buffer control signal function
|
|
|
|
* - disable parity byte select
|
|
|
|
* - set ECC parity type
|
|
|
|
* - set bus monitor timing and timer prescale
|
|
|
|
*/
|
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh, LBC85XX_LBCR, 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize clock ratio register:
|
|
|
|
* - disable PLL bypass mode
|
|
|
|
* - configure LCLK delay cycles for the assertion of LALE
|
|
|
|
* - set system clock divider
|
|
|
|
*/
|
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh, LBC85XX_LCRR, 0x00030008);
|
|
|
|
|
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh, LBC85XX_LTEDR, 0);
|
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh, LBC85XX_LTESR, ~0);
|
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh, LBC85XX_LTEIR, 0x64080001);
|
|
|
|
|
|
|
|
sc->sc_irid = 0;
|
|
|
|
sc->sc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->sc_irid,
|
|
|
|
RF_ACTIVE | RF_SHAREABLE);
|
|
|
|
if (sc->sc_ires != NULL) {
|
|
|
|
error = bus_setup_intr(dev, sc->sc_ires,
|
|
|
|
INTR_TYPE_MISC | INTR_MPSAFE, NULL, lbc_intr, sc,
|
|
|
|
&sc->sc_icookie);
|
|
|
|
if (error) {
|
|
|
|
device_printf(dev, "could not activate interrupt\n");
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irid,
|
|
|
|
sc->sc_ires);
|
|
|
|
sc->sc_ires = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->sc_ltesr = ~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
|
|
|
rangesptr = NULL;
|
2008-10-25 06:03:40 +00:00
|
|
|
|
|
|
|
rm = &sc->sc_rman;
|
|
|
|
rm->rm_type = RMAN_ARRAY;
|
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
|
|
|
rm->rm_descr = "Local Bus Space";
|
2008-10-25 06:03:40 +00:00
|
|
|
error = rman_init(rm);
|
|
|
|
if (error)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
error = rman_manage_region(rm, rm->rm_start, rm->rm_end);
|
|
|
|
if (error) {
|
|
|
|
rman_fini(rm);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2008-12-18 18:27:12 +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
|
|
|
* Process 'ranges' property.
|
2008-12-18 18:27:12 +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
|
|
|
node = ofw_bus_get_node(dev);
|
|
|
|
if ((fdt_addrsize_cells(node, &sc->sc_addr_cells,
|
|
|
|
&sc->sc_size_cells)) != 0) {
|
|
|
|
error = ENXIO;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
par_addr_cells = fdt_parent_addr_cells(node);
|
|
|
|
if (par_addr_cells > 2) {
|
|
|
|
device_printf(dev, "unsupported parent #addr-cells\n");
|
|
|
|
error = ERANGE;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
tuple_size = sizeof(pcell_t) * (sc->sc_addr_cells + par_addr_cells +
|
|
|
|
sc->sc_size_cells);
|
|
|
|
|
|
|
|
tuples = OF_getprop_alloc(node, "ranges", tuple_size,
|
|
|
|
(void **)&ranges);
|
|
|
|
if (tuples < 0) {
|
|
|
|
device_printf(dev, "could not retrieve 'ranges' property\n");
|
|
|
|
error = ENXIO;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
rangesptr = ranges;
|
|
|
|
|
|
|
|
debugf("par addr_cells = %d, addr_cells = %d, size_cells = %d, "
|
|
|
|
"tuple_size = %d, tuples = %d\n", par_addr_cells,
|
|
|
|
sc->sc_addr_cells, sc->sc_size_cells, tuple_size, tuples);
|
|
|
|
|
|
|
|
start = 0;
|
|
|
|
size = 0;
|
|
|
|
for (i = 0; i < tuples; i++) {
|
|
|
|
|
|
|
|
/* The first cell is the bank (chip select) number. */
|
|
|
|
bank = fdt_data_get((void *)ranges, 1);
|
|
|
|
if (bank < 0 || bank > LBC_DEV_MAX) {
|
|
|
|
device_printf(dev, "bank out of range: %d\n", bank);
|
|
|
|
error = ERANGE;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
ranges += 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remaining cells of the child address define offset into
|
|
|
|
* this CS.
|
|
|
|
*/
|
|
|
|
offset = fdt_data_get((void *)ranges, sc->sc_addr_cells - 1);
|
|
|
|
ranges += sc->sc_addr_cells - 1;
|
|
|
|
|
|
|
|
/* Parent bus start address of this bank. */
|
|
|
|
start = fdt_data_get((void *)ranges, par_addr_cells);
|
|
|
|
ranges += par_addr_cells;
|
|
|
|
|
|
|
|
size = fdt_data_get((void *)ranges, sc->sc_size_cells);
|
|
|
|
ranges += sc->sc_size_cells;
|
|
|
|
debugf("bank = %d, start = %lx, size = %lx\n", bank,
|
|
|
|
start, size);
|
|
|
|
|
2012-05-24 21:23:13 +00:00
|
|
|
sc->sc_banks[bank].addr = start + offset;
|
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_banks[bank].size = size;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attributes for the bank.
|
|
|
|
*
|
|
|
|
* XXX Note there are no DT bindings defined for them at the
|
|
|
|
* moment, so we need to provide some defaults.
|
|
|
|
*/
|
|
|
|
sc->sc_banks[bank].width = 16;
|
|
|
|
sc->sc_banks[bank].msel = LBCRES_MSEL_GPCM;
|
|
|
|
sc->sc_banks[bank].decc = LBCRES_DECC_DISABLED;
|
|
|
|
sc->sc_banks[bank].atom = LBCRES_ATOM_DISABLED;
|
|
|
|
sc->sc_banks[bank].wp = 0;
|
|
|
|
}
|
2008-12-18 18:27:12 +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
|
|
|
* Initialize mem-mappings for the LBC banks (i.e. chip selects).
|
2008-12-18 18:27:12 +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
|
|
|
error = lbc_banks_map(sc);
|
|
|
|
if (error)
|
|
|
|
goto fail;
|
2008-12-18 18:27:12 +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
|
|
|
/*
|
|
|
|
* Walk the localbus and add direct subordinates as our children.
|
|
|
|
*/
|
|
|
|
for (child = OF_child(node); child != 0; child = OF_peer(child)) {
|
2008-12-18 18:27:12 +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
|
|
|
di = malloc(sizeof(*di), M_LBC, M_WAITOK | M_ZERO);
|
|
|
|
|
|
|
|
if (ofw_bus_gen_setup_devinfo(&di->di_ofw, child) != 0) {
|
|
|
|
free(di, M_LBC);
|
|
|
|
device_printf(dev, "could not set up devinfo\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
resource_list_init(&di->di_res);
|
|
|
|
|
|
|
|
if (fdt_lbc_reg_decode(child, sc, di)) {
|
|
|
|
device_printf(dev, "could not process 'reg' "
|
|
|
|
"property\n");
|
|
|
|
ofw_bus_gen_destroy_devinfo(&di->di_ofw);
|
|
|
|
free(di, M_LBC);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
fdt_lbc_fixup(child, sc, di);
|
|
|
|
|
|
|
|
/* Add newbus device for this FDT node */
|
|
|
|
cdev = device_add_child(dev, NULL, -1);
|
|
|
|
if (cdev == NULL) {
|
|
|
|
device_printf(dev, "could not add child: %s\n",
|
|
|
|
di->di_ofw.obd_name);
|
|
|
|
resource_list_free(&di->di_res);
|
|
|
|
ofw_bus_gen_destroy_devinfo(&di->di_ofw);
|
|
|
|
free(di, M_LBC);
|
|
|
|
continue;
|
2008-12-18 18:27:12 +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
|
|
|
debugf("added child name='%s', node=%p\n", di->di_ofw.obd_name,
|
|
|
|
(void *)child);
|
|
|
|
device_set_ivars(cdev, di);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable the LBC.
|
|
|
|
*/
|
|
|
|
lbc_banks_enable(sc);
|
2008-10-25 06:03:40 +00:00
|
|
|
|
2016-05-14 20:06:38 +00:00
|
|
|
OF_prop_free(rangesptr);
|
2008-10-25 06:03:40 +00:00
|
|
|
return (bus_generic_attach(dev));
|
|
|
|
|
2008-12-18 18:27:12 +00:00
|
|
|
fail:
|
2016-05-14 20:06:38 +00:00
|
|
|
OF_prop_free(rangesptr);
|
2012-07-03 00:06:14 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_mrid, sc->sc_mres);
|
2008-10-25 06:03:40 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
lbc_shutdown(device_t dev)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* TODO */
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct resource *
|
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
|
|
|
lbc_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
2016-01-27 02:23:54 +00:00
|
|
|
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
2008-10-25 06:03:40 +00:00
|
|
|
{
|
|
|
|
struct lbc_softc *sc;
|
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
|
|
|
struct lbc_devinfo *di;
|
|
|
|
struct resource_list_entry *rle;
|
|
|
|
struct resource *res;
|
2008-10-25 06:03:40 +00:00
|
|
|
struct rman *rm;
|
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
|
|
|
int needactivate;
|
2008-10-25 06:03:40 +00:00
|
|
|
|
|
|
|
/* We only support default allocations. */
|
2016-02-27 16:27:48 +00:00
|
|
|
if (!RMAN_IS_DEFAULT_RANGE(start, end))
|
2008-10-25 06:03:40 +00:00
|
|
|
return (NULL);
|
|
|
|
|
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 = device_get_softc(bus);
|
2008-10-25 06:03:40 +00:00
|
|
|
if (type == SYS_RES_IRQ)
|
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 (bus_alloc_resource(bus, type, rid, start, end, count,
|
2008-10-25 06:03:40 +00:00
|
|
|
flags));
|
|
|
|
|
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
|
|
|
/*
|
|
|
|
* Request for the default allocation with a given rid: use resource
|
|
|
|
* list stored in the local device info.
|
|
|
|
*/
|
|
|
|
if ((di = device_get_ivars(child)) == NULL)
|
2008-10-25 06:03:40 +00:00
|
|
|
return (NULL);
|
|
|
|
|
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
|
|
|
if (type == SYS_RES_IOPORT)
|
|
|
|
type = SYS_RES_MEMORY;
|
|
|
|
|
|
|
|
rid = &di->di_bank;
|
|
|
|
|
|
|
|
rle = resource_list_find(&di->di_res, type, *rid);
|
|
|
|
if (rle == NULL) {
|
|
|
|
device_printf(bus, "no default resources for "
|
|
|
|
"rid = %d, type = %d\n", *rid, type);
|
|
|
|
return (NULL);
|
2008-10-25 06:03:40 +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
|
|
|
start = rle->start;
|
|
|
|
count = rle->count;
|
|
|
|
end = start + count - 1;
|
2008-10-25 06:03:40 +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
|
|
|
sc = device_get_softc(bus);
|
2008-10-25 06:03:40 +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
|
|
|
needactivate = flags & RF_ACTIVE;
|
|
|
|
flags &= ~RF_ACTIVE;
|
2008-10-25 06:03:40 +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
|
|
|
rm = &sc->sc_rman;
|
|
|
|
|
|
|
|
res = rman_reserve_resource(rm, start, end, count, flags, child);
|
|
|
|
if (res == NULL) {
|
Use uintmax_t (typedef'd to rman_res_t type) for rman ranges.
On some architectures, u_long isn't large enough for resource definitions.
Particularly, powerpc and arm allow 36-bit (or larger) physical addresses, but
type `long' is only 32-bit. This extends rman's resources to uintmax_t. With
this change, any resource can feasibly be placed anywhere in physical memory
(within the constraints of the driver).
Why uintmax_t and not something machine dependent, or uint64_t? Though it's
possible for uintmax_t to grow, it's highly unlikely it will become 128-bit on
32-bit architectures. 64-bit architectures should have plenty of RAM to absorb
the increase on resource sizes if and when this occurs, and the number of
resources on memory-constrained systems should be sufficiently small as to not
pose a drastic overhead. That being said, uintmax_t was chosen for source
clarity. If it's specified as uint64_t, all printf()-like calls would either
need casts to uintmax_t, or be littered with PRI*64 macros. Casts to uintmax_t
aren't horrible, but it would also bake into the API for
resource_list_print_type() either a hidden assumption that entries get cast to
uintmax_t for printing, or these calls would need the PRI*64 macros. Since
source code is meant to be read more often than written, I chose the clearest
path of simply using uintmax_t.
Tested on a PowerPC p5020-based board, which places all device resources in
0xfxxxxxxxx, and has 8GB RAM.
Regression tested on qemu-system-i386
Regression tested on qemu-system-mips (malta profile)
Tested PAE and devinfo on virtualbox (live CD)
Special thanks to bz for his testing on ARM.
Reviewed By: bz, jhb (previous)
Relnotes: Yes
Sponsored by: Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D4544
2016-03-18 01:28:41 +00:00
|
|
|
device_printf(bus, "failed to reserve resource %#jx - %#jx "
|
|
|
|
"(%#jx)\n", start, end, count);
|
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 (NULL);
|
2008-10-25 06:03:40 +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
|
|
|
rman_set_rid(res, *rid);
|
|
|
|
rman_set_bustag(res, &bs_be_tag);
|
|
|
|
rman_set_bushandle(res, rman_get_start(res));
|
|
|
|
|
|
|
|
if (needactivate)
|
|
|
|
if (bus_activate_resource(child, type, *rid, res)) {
|
|
|
|
device_printf(child, "resource activation failed\n");
|
|
|
|
rman_release_resource(res);
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (res);
|
2008-10-25 06:03:40 +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
|
|
|
lbc_print_child(device_t dev, device_t child)
|
2008-10-25 06:03:40 +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
|
|
|
struct lbc_devinfo *di;
|
|
|
|
struct resource_list *rl;
|
|
|
|
int rv;
|
2008-10-25 06:03:40 +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
|
|
|
di = device_get_ivars(child);
|
|
|
|
rl = &di->di_res;
|
2008-10-25 06:03:40 +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
|
|
|
rv = 0;
|
|
|
|
rv += bus_print_child_header(dev, child);
|
Use uintmax_t (typedef'd to rman_res_t type) for rman ranges.
On some architectures, u_long isn't large enough for resource definitions.
Particularly, powerpc and arm allow 36-bit (or larger) physical addresses, but
type `long' is only 32-bit. This extends rman's resources to uintmax_t. With
this change, any resource can feasibly be placed anywhere in physical memory
(within the constraints of the driver).
Why uintmax_t and not something machine dependent, or uint64_t? Though it's
possible for uintmax_t to grow, it's highly unlikely it will become 128-bit on
32-bit architectures. 64-bit architectures should have plenty of RAM to absorb
the increase on resource sizes if and when this occurs, and the number of
resources on memory-constrained systems should be sufficiently small as to not
pose a drastic overhead. That being said, uintmax_t was chosen for source
clarity. If it's specified as uint64_t, all printf()-like calls would either
need casts to uintmax_t, or be littered with PRI*64 macros. Casts to uintmax_t
aren't horrible, but it would also bake into the API for
resource_list_print_type() either a hidden assumption that entries get cast to
uintmax_t for printing, or these calls would need the PRI*64 macros. Since
source code is meant to be read more often than written, I chose the clearest
path of simply using uintmax_t.
Tested on a PowerPC p5020-based board, which places all device resources in
0xfxxxxxxxx, and has 8GB RAM.
Regression tested on qemu-system-i386
Regression tested on qemu-system-mips (malta profile)
Tested PAE and devinfo on virtualbox (live CD)
Special thanks to bz for his testing on ARM.
Reviewed By: bz, jhb (previous)
Relnotes: Yes
Sponsored by: Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D4544
2016-03-18 01:28:41 +00:00
|
|
|
rv += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#jx");
|
|
|
|
rv += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%jd");
|
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
|
|
|
rv += bus_print_child_footer(dev, child);
|
2008-10-25 06:03:40 +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
|
|
|
return (rv);
|
2008-10-25 06:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
lbc_release_resource(device_t dev, device_t child, int type, int rid,
|
|
|
|
struct resource *res)
|
|
|
|
{
|
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
|
|
|
int err;
|
|
|
|
|
|
|
|
if (rman_get_flags(res) & RF_ACTIVE) {
|
|
|
|
err = bus_deactivate_resource(child, type, rid, res);
|
|
|
|
if (err)
|
|
|
|
return (err);
|
|
|
|
}
|
2008-10-25 06:03:40 +00:00
|
|
|
|
|
|
|
return (rman_release_resource(res));
|
|
|
|
}
|
|
|
|
|
2016-03-02 00:18:05 +00:00
|
|
|
static int
|
|
|
|
lbc_activate_resource(device_t bus __unused, device_t child __unused,
|
|
|
|
int type __unused, int rid __unused, struct resource *r)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Child resources were already mapped, just activate. */
|
|
|
|
return (rman_activate_resource(r));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
lbc_deactivate_resource(device_t bus __unused, device_t child __unused,
|
|
|
|
int type __unused, int rid __unused, struct resource *r)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (rman_deactivate_resource(r));
|
|
|
|
}
|
|
|
|
|
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 const struct ofw_bus_devinfo *
|
|
|
|
lbc_get_devinfo(device_t bus, device_t child)
|
2008-10-25 06:03:40 +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
|
|
|
struct lbc_devinfo *di;
|
2008-12-18 18:27:12 +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
|
|
|
di = device_get_ivars(child);
|
|
|
|
return (&di->di_ofw);
|
2008-10-25 06:03:40 +00:00
|
|
|
}
|
2012-05-24 21:23:13 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
lbc_write_reg(device_t child, u_int off, uint32_t val)
|
|
|
|
{
|
2012-07-03 00:06:14 +00:00
|
|
|
device_t dev;
|
2012-05-24 21:23:13 +00:00
|
|
|
struct lbc_softc *sc;
|
|
|
|
|
2012-07-03 00:06:14 +00:00
|
|
|
dev = device_get_parent(child);
|
|
|
|
|
|
|
|
if (off >= 0x1000) {
|
|
|
|
device_printf(dev, "%s(%s): invalid offset %#x\n",
|
|
|
|
__func__, device_get_nameunit(child), off);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc = device_get_softc(dev);
|
|
|
|
|
|
|
|
if (off == LBC85XX_LTESR && sc->sc_ltesr != ~0u) {
|
|
|
|
sc->sc_ltesr ^= (val & sc->sc_ltesr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (off == LBC85XX_LTEATR && (val & 1) == 0)
|
|
|
|
sc->sc_ltesr = ~0u;
|
2012-05-24 21:23:13 +00:00
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh, off, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
lbc_read_reg(device_t child, u_int off)
|
|
|
|
{
|
2012-07-03 00:06:14 +00:00
|
|
|
device_t dev;
|
2012-05-24 21:23:13 +00:00
|
|
|
struct lbc_softc *sc;
|
2012-07-03 00:06:14 +00:00
|
|
|
uint32_t val;
|
|
|
|
|
|
|
|
dev = device_get_parent(child);
|
|
|
|
|
|
|
|
if (off >= 0x1000) {
|
|
|
|
device_printf(dev, "%s(%s): invalid offset %#x\n",
|
|
|
|
__func__, device_get_nameunit(child), off);
|
|
|
|
return (~0U);
|
|
|
|
}
|
|
|
|
|
|
|
|
sc = device_get_softc(dev);
|
2012-05-24 21:23:13 +00:00
|
|
|
|
2012-07-03 00:06:14 +00:00
|
|
|
if (off == LBC85XX_LTESR && sc->sc_ltesr != ~0U)
|
|
|
|
val = sc->sc_ltesr;
|
|
|
|
else
|
|
|
|
val = bus_space_read_4(sc->sc_bst, sc->sc_bsh, off);
|
|
|
|
return (val);
|
2012-05-24 21:23:13 +00:00
|
|
|
}
|