2009-05-14 00:34:26 +00:00
|
|
|
/*-
|
2017-11-27 15:09:59 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
|
|
*
|
2012-05-26 13:42:55 +00:00
|
|
|
* Copyright (c) 2008-2012 Semihalf.
|
2009-05-14 00:34:26 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/pcpu.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/smp.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/openfirm.h>
|
|
|
|
|
2013-11-11 16:14:25 +00:00
|
|
|
#include <machine/platform.h>
|
|
|
|
#include <machine/platformvar.h>
|
2009-05-14 00:34:26 +00:00
|
|
|
|
|
|
|
#include "platform_if.h"
|
|
|
|
|
2011-01-17 23:54:50 +00:00
|
|
|
extern uint32_t *bootinfo;
|
|
|
|
|
2009-05-14 00:34:26 +00:00
|
|
|
static int bare_probe(platform_t);
|
2013-12-01 19:43:15 +00:00
|
|
|
static void bare_mem_regions(platform_t, struct mem_region *phys, int *physsz,
|
|
|
|
struct mem_region *avail, int *availsz);
|
2009-05-14 00:34:26 +00:00
|
|
|
static u_long bare_timebase_freq(platform_t, struct cpuref *cpuref);
|
|
|
|
|
2013-11-11 16:14:25 +00:00
|
|
|
static void bare_reset(platform_t);
|
2010-08-31 15:27:46 +00:00
|
|
|
|
2009-05-14 00:34:26 +00:00
|
|
|
static platform_method_t bare_methods[] = {
|
2012-05-30 18:05:48 +00:00
|
|
|
PLATFORMMETHOD(platform_probe, bare_probe),
|
2009-05-14 00:34:26 +00:00
|
|
|
PLATFORMMETHOD(platform_mem_regions, bare_mem_regions),
|
|
|
|
PLATFORMMETHOD(platform_timebase_freq, bare_timebase_freq),
|
|
|
|
|
2013-11-11 16:14:25 +00:00
|
|
|
PLATFORMMETHOD(platform_reset, bare_reset),
|
2010-08-31 15:27:46 +00:00
|
|
|
|
2013-02-13 02:21:45 +00:00
|
|
|
PLATFORMMETHOD_END
|
2009-05-14 00:34:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static platform_def_t bare_platform = {
|
2013-11-11 16:14:25 +00:00
|
|
|
"bare",
|
2009-05-14 00:34:26 +00:00
|
|
|
bare_methods,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
PLATFORM_DEF(bare_platform);
|
|
|
|
|
|
|
|
static int
|
|
|
|
bare_probe(platform_t plat)
|
|
|
|
{
|
2009-06-05 09:46:00 +00:00
|
|
|
|
2013-11-11 16:14:25 +00:00
|
|
|
if (OF_peer(0) == -1) /* Needs device tree to work */
|
|
|
|
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
|
|
|
|
2009-05-14 00:34:26 +00:00
|
|
|
return (BUS_PROBE_GENERIC);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-12-01 19:43:15 +00:00
|
|
|
bare_mem_regions(platform_t plat, struct mem_region *phys, int *physsz,
|
|
|
|
struct mem_region *avail, int *availsz)
|
2009-05-14 00:34:26 +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
|
|
|
|
2013-11-11 16:14:25 +00:00
|
|
|
ofw_mem_regions(phys, physsz, avail, availsz);
|
2009-05-14 00:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u_long
|
|
|
|
bare_timebase_freq(platform_t plat, struct cpuref *cpuref)
|
|
|
|
{
|
2011-01-17 23:54:50 +00:00
|
|
|
u_long ticks;
|
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
|
|
|
phandle_t cpus, child;
|
|
|
|
pcell_t freq;
|
|
|
|
|
2011-08-02 23:49:23 +00:00
|
|
|
if (bootinfo != NULL) {
|
2011-08-02 15:35:43 +00:00
|
|
|
if (bootinfo[0] == 1) {
|
|
|
|
/* Backward compatibility. See 8-STABLE. */
|
|
|
|
ticks = bootinfo[3] >> 3;
|
|
|
|
} else {
|
2011-08-02 23:49:23 +00:00
|
|
|
/* Compatibility with Juniper's loader. */
|
2011-08-02 15:35:43 +00:00
|
|
|
ticks = bootinfo[5] >> 3;
|
2011-08-02 23:49:23 +00:00
|
|
|
}
|
2011-05-26 20:47:05 +00:00
|
|
|
} else
|
|
|
|
ticks = 0;
|
2011-01-17 23:54:50 +00:00
|
|
|
|
2011-12-02 15:24:39 +00:00
|
|
|
if ((cpus = OF_finddevice("/cpus")) == -1)
|
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
|
|
|
goto out;
|
|
|
|
|
|
|
|
if ((child = OF_child(cpus)) == 0)
|
|
|
|
goto out;
|
2009-05-14 00:34:26 +00:00
|
|
|
|
2013-10-23 14:34:04 +00:00
|
|
|
switch (OF_getproplen(child, "timebase-frequency")) {
|
|
|
|
case 4:
|
|
|
|
{
|
|
|
|
uint32_t tbase;
|
|
|
|
OF_getprop(child, "timebase-frequency", &tbase, sizeof(tbase));
|
|
|
|
ticks = tbase;
|
|
|
|
return (ticks);
|
|
|
|
}
|
|
|
|
case 8:
|
|
|
|
{
|
|
|
|
uint64_t tbase;
|
|
|
|
OF_getprop(child, "timebase-frequency", &tbase, sizeof(tbase));
|
|
|
|
ticks = tbase;
|
|
|
|
return (ticks);
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-10-23 14:28:59 +00:00
|
|
|
|
2011-01-17 23:54:50 +00:00
|
|
|
freq = 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
|
|
|
if (OF_getprop(child, "bus-frequency", (void *)&freq,
|
|
|
|
sizeof(freq)) <= 0)
|
|
|
|
goto out;
|
2011-01-17 23:54:50 +00:00
|
|
|
|
2009-05-14 00:34:26 +00:00
|
|
|
/*
|
|
|
|
* Time Base and Decrementer are updated every 8 CCB bus clocks.
|
|
|
|
* HID0[SEL_TBCLK] = 0
|
|
|
|
*/
|
2011-01-17 23:54:50 +00:00
|
|
|
if (freq != 0)
|
|
|
|
ticks = freq / 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
|
|
|
out:
|
2009-05-14 00:34:26 +00:00
|
|
|
if (ticks <= 0)
|
|
|
|
panic("Unable to determine timebase frequency!");
|
|
|
|
|
|
|
|
return (ticks);
|
|
|
|
}
|
|
|
|
|
2010-08-31 15:27:46 +00:00
|
|
|
static void
|
2013-11-11 16:14:25 +00:00
|
|
|
bare_reset(platform_t plat)
|
2010-08-31 15:27:46 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
printf("Reset failed...\n");
|
2012-05-26 13:36:18 +00:00
|
|
|
while (1)
|
|
|
|
;
|
2010-08-31 15:27:46 +00:00
|
|
|
}
|