2008-10-13 20:07:13 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1994-1998 Mark Brinicombe.
|
|
|
|
* Copyright (c) 1994 Brini.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software written for Brini by Mark Brinicombe
|
|
|
|
*
|
|
|
|
* 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. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Brini.
|
|
|
|
* 4. The name of the company nor the name of the author may be used to
|
|
|
|
* endorse or promote products derived from this software without specific
|
|
|
|
* prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI OR CONTRIBUTORS 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.
|
|
|
|
*
|
|
|
|
* from: FreeBSD: //depot/projects/arm/src/sys/arm/at91/kb920x_machdep.c, rev 45
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "opt_ddb.h"
|
2010-06-13 13:28:53 +00:00
|
|
|
#include "opt_platform.h"
|
2008-10-13 20:07:13 +00:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#define _ARM32_BUS_DMA_PRIVATE
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/bus.h>
|
2016-04-26 11:53:37 +00:00
|
|
|
#include <sys/devmap.h>
|
2008-10-13 20:07:13 +00:00
|
|
|
|
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/pmap.h>
|
2012-11-03 22:39:07 +00:00
|
|
|
|
2008-10-13 20:07:13 +00:00
|
|
|
#include <machine/bus.h>
|
2014-01-05 18:46:58 +00:00
|
|
|
#include <machine/fdt.h>
|
2012-11-03 22:39:07 +00:00
|
|
|
#include <machine/machdep.h>
|
2014-05-17 11:27:36 +00:00
|
|
|
#include <machine/platform.h>
|
2008-10-13 20:07:13 +00:00
|
|
|
|
2016-05-23 20:07:17 +00:00
|
|
|
#if __ARM_ARCH < 6
|
|
|
|
#include <machine/cpu-v4.h>
|
|
|
|
#else
|
|
|
|
#include <machine/cpu-v6.h>
|
|
|
|
#endif
|
|
|
|
|
2010-06-13 13:28:53 +00:00
|
|
|
#include <arm/mv/mvreg.h> /* XXX */
|
2008-10-13 20:07:13 +00:00
|
|
|
#include <arm/mv/mvvar.h> /* XXX eventually this should be eliminated */
|
2009-08-25 09:30:03 +00:00
|
|
|
#include <arm/mv/mvwin.h>
|
2008-10-13 20:07:13 +00:00
|
|
|
|
2012-11-03 22:39:07 +00:00
|
|
|
#include <dev/fdt/fdt_common.h>
|
2016-11-11 15:13:30 +00:00
|
|
|
#include <dev/ofw/ofw_bus_subr.h>
|
2008-10-13 20:07:13 +00:00
|
|
|
|
2010-06-13 13:28:53 +00:00
|
|
|
static int platform_mpp_init(void);
|
2013-05-06 13:52:49 +00:00
|
|
|
#if defined(SOC_MV_ARMADAXP)
|
2013-05-06 14:12:36 +00:00
|
|
|
void armadaxp_init_coher_fabric(void);
|
2013-05-06 13:52:49 +00:00
|
|
|
void armadaxp_l2_init(void);
|
|
|
|
#endif
|
2016-01-20 13:53:33 +00:00
|
|
|
#if defined(SOC_MV_ARMADA38X)
|
|
|
|
int armada38x_win_set_iosync_barrier(void);
|
2016-01-20 13:55:51 +00:00
|
|
|
int armada38x_scu_enable(void);
|
2016-01-20 14:30:17 +00:00
|
|
|
int armada38x_open_bootrom_win(void);
|
2016-01-20 13:53:33 +00:00
|
|
|
#endif
|
2008-10-13 20:07:13 +00:00
|
|
|
|
2012-08-15 05:15:49 +00:00
|
|
|
#define MPP_PIN_MAX 68
|
2010-06-13 13:28:53 +00:00
|
|
|
#define MPP_PIN_CELLS 2
|
|
|
|
#define MPP_PINS_PER_REG 8
|
|
|
|
#define MPP_SEL(pin,func) (((func) & 0xf) << \
|
|
|
|
(((pin) % MPP_PINS_PER_REG) * 4))
|
|
|
|
|
|
|
|
static int
|
|
|
|
platform_mpp_init(void)
|
|
|
|
{
|
|
|
|
pcell_t pinmap[MPP_PIN_MAX * MPP_PIN_CELLS];
|
|
|
|
int mpp[MPP_PIN_MAX];
|
|
|
|
uint32_t ctrl_val, ctrl_offset;
|
|
|
|
pcell_t reg[4];
|
|
|
|
u_long start, size;
|
|
|
|
phandle_t node;
|
|
|
|
pcell_t pin_cells, *pinmap_ptr, pin_count;
|
|
|
|
ssize_t len;
|
|
|
|
int par_addr_cells, par_size_cells;
|
|
|
|
int tuple_size, tuples, rv, pins, i, j;
|
|
|
|
int mpp_pin, mpp_function;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to access the MPP node directly i.e. through /aliases/mpp.
|
|
|
|
*/
|
2011-12-02 15:24:39 +00:00
|
|
|
if ((node = OF_finddevice("mpp")) != -1)
|
2016-11-11 15:13:30 +00:00
|
|
|
if (ofw_bus_node_is_compatible(node, "mrvl,mpp"))
|
2010-06-13 13:28:53 +00:00
|
|
|
goto moveon;
|
|
|
|
/*
|
|
|
|
* Find the node the long way.
|
|
|
|
*/
|
2011-12-02 15:24:39 +00:00
|
|
|
if ((node = OF_finddevice("/")) == -1)
|
2010-06-13 13:28:53 +00:00
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
if ((node = fdt_find_compatible(node, "simple-bus", 0)) == 0)
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
if ((node = fdt_find_compatible(node, "mrvl,mpp", 0)) == 0)
|
2012-08-15 05:15:49 +00:00
|
|
|
/*
|
|
|
|
* No MPP node. Fall back to how MPP got set by the
|
|
|
|
* first-stage loader and try to continue booting.
|
|
|
|
*/
|
|
|
|
return (0);
|
2010-06-13 13:28:53 +00:00
|
|
|
moveon:
|
|
|
|
/*
|
|
|
|
* Process 'reg' prop.
|
|
|
|
*/
|
|
|
|
if ((rv = fdt_addrsize_cells(OF_parent(node), &par_addr_cells,
|
|
|
|
&par_size_cells)) != 0)
|
|
|
|
return(ENXIO);
|
|
|
|
|
|
|
|
tuple_size = sizeof(pcell_t) * (par_addr_cells + par_size_cells);
|
|
|
|
len = OF_getprop(node, "reg", reg, sizeof(reg));
|
|
|
|
tuples = len / tuple_size;
|
|
|
|
if (tuple_size <= 0)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get address/size. XXX we assume only the first 'reg' tuple is used.
|
|
|
|
*/
|
|
|
|
rv = fdt_data_to_res(reg, par_addr_cells, par_size_cells,
|
|
|
|
&start, &size);
|
|
|
|
if (rv != 0)
|
|
|
|
return (rv);
|
|
|
|
start += fdt_immr_va;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process 'pin-count' and 'pin-map' props.
|
|
|
|
*/
|
2016-11-14 12:03:08 +00:00
|
|
|
if (OF_getencprop(node, "pin-count", &pin_count, sizeof(pin_count)) <= 0)
|
2010-06-13 13:28:53 +00:00
|
|
|
return (ENXIO);
|
|
|
|
if (pin_count > MPP_PIN_MAX)
|
|
|
|
return (ERANGE);
|
|
|
|
|
2016-11-14 12:03:08 +00:00
|
|
|
if (OF_getencprop(node, "#pin-cells", &pin_cells, sizeof(pin_cells)) <= 0)
|
2010-06-13 13:28:53 +00:00
|
|
|
pin_cells = MPP_PIN_CELLS;
|
|
|
|
if (pin_cells > MPP_PIN_CELLS)
|
|
|
|
return (ERANGE);
|
|
|
|
tuple_size = sizeof(pcell_t) * pin_cells;
|
|
|
|
|
|
|
|
bzero(pinmap, sizeof(pinmap));
|
2016-11-14 12:03:08 +00:00
|
|
|
len = OF_getencprop(node, "pin-map", pinmap, sizeof(pinmap));
|
2010-06-13 13:28:53 +00:00
|
|
|
if (len <= 0)
|
|
|
|
return (ERANGE);
|
|
|
|
if (len % tuple_size)
|
|
|
|
return (ERANGE);
|
|
|
|
pins = len / tuple_size;
|
|
|
|
if (pins > pin_count)
|
|
|
|
return (ERANGE);
|
|
|
|
/*
|
|
|
|
* Fill out a "mpp[pin] => function" table. All pins unspecified in
|
|
|
|
* the 'pin-map' property are defaulted to 0 function i.e. GPIO.
|
|
|
|
*/
|
|
|
|
bzero(mpp, sizeof(mpp));
|
|
|
|
pinmap_ptr = pinmap;
|
|
|
|
for (i = 0; i < pins; i++) {
|
2016-11-14 12:03:08 +00:00
|
|
|
mpp_pin = *pinmap_ptr;
|
|
|
|
mpp_function = *(pinmap_ptr + 1);
|
2010-06-13 13:28:53 +00:00
|
|
|
mpp[mpp_pin] = mpp_function;
|
|
|
|
pinmap_ptr += pin_cells;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prepare and program MPP control register values.
|
|
|
|
*/
|
|
|
|
ctrl_offset = 0;
|
|
|
|
for (i = 0; i < pin_count;) {
|
|
|
|
ctrl_val = 0;
|
|
|
|
|
|
|
|
for (j = 0; j < MPP_PINS_PER_REG; j++) {
|
|
|
|
if (i + j == pin_count - 1)
|
|
|
|
break;
|
|
|
|
ctrl_val |= MPP_SEL(i + j, mpp[i + j]);
|
|
|
|
}
|
|
|
|
i += MPP_PINS_PER_REG;
|
|
|
|
bus_space_write_4(fdtbus_bs_tag, start, ctrl_offset,
|
|
|
|
ctrl_val);
|
|
|
|
|
|
|
|
#if defined(SOC_MV_ORION)
|
|
|
|
/*
|
|
|
|
* Third MPP reg on Orion SoC is placed
|
|
|
|
* non-linearly (with different offset).
|
|
|
|
*/
|
|
|
|
if (i == (2 * MPP_PINS_PER_REG))
|
|
|
|
ctrl_offset = 0x50;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
ctrl_offset += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2012-09-23 03:46:03 +00:00
|
|
|
vm_offset_t
|
2014-05-17 11:27:36 +00:00
|
|
|
platform_lastaddr(void)
|
2013-11-05 02:57:34 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
return (fdt_immr_va);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-05-17 11:27:36 +00:00
|
|
|
platform_probe_and_attach(void)
|
2012-09-23 03:46:03 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if (fdt_immr_addr(MV_BASE) != 0)
|
|
|
|
while (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-05-17 11:27:36 +00:00
|
|
|
platform_gpio_init(void)
|
2012-09-23 03:46:03 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Re-initialise MPP. It is important to call this prior to using
|
|
|
|
* console as the physical connection can be routed via MPP.
|
|
|
|
*/
|
|
|
|
if (platform_mpp_init() != 0)
|
|
|
|
while (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-05-17 11:27:36 +00:00
|
|
|
platform_late_init(void)
|
2012-09-23 03:46:03 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Re-initialise decode windows
|
|
|
|
*/
|
|
|
|
#if !defined(SOC_MV_FREY)
|
|
|
|
if (soc_decode_win() != 0)
|
|
|
|
printf("WARNING: could not re-initialise decode windows! "
|
|
|
|
"Running with existing settings...\n");
|
|
|
|
#else
|
|
|
|
/* Disable watchdog and timers */
|
|
|
|
write_cpu_ctrl(CPU_TIMERS_BASE + CPU_TIMER_CONTROL, 0);
|
|
|
|
#endif
|
2013-05-06 13:52:49 +00:00
|
|
|
#if defined(SOC_MV_ARMADAXP)
|
2013-05-06 14:12:36 +00:00
|
|
|
#if !defined(SMP)
|
|
|
|
/* For SMP case it should be initialized after APs are booted */
|
|
|
|
armadaxp_init_coher_fabric();
|
|
|
|
#endif
|
2013-05-06 13:52:49 +00:00
|
|
|
armadaxp_l2_init();
|
2016-01-20 13:53:33 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(SOC_MV_ARMADA38X)
|
|
|
|
/* Set IO Sync Barrier bit for all Mbus devices */
|
|
|
|
if (armada38x_win_set_iosync_barrier() != 0)
|
|
|
|
printf("WARNING: could not map CPU Subsystem registers\n");
|
2016-01-20 13:55:51 +00:00
|
|
|
if (armada38x_scu_enable() != 0)
|
|
|
|
printf("WARNING: could not enable SCU\n");
|
2016-01-20 14:30:17 +00:00
|
|
|
#ifdef SMP
|
|
|
|
/* Open window to bootROM memory - needed for SMP */
|
|
|
|
if (armada38x_open_bootrom_win() != 0)
|
|
|
|
printf("WARNING: could not open window to bootROM\n");
|
|
|
|
#endif
|
2013-05-06 13:52:49 +00:00
|
|
|
#endif
|
2012-09-23 03:46:03 +00:00
|
|
|
}
|
|
|
|
|
2012-08-15 05:15:49 +00:00
|
|
|
#define FDT_DEVMAP_MAX (MV_WIN_CPU_MAX + 2)
|
2016-04-26 11:53:37 +00:00
|
|
|
static struct devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = {
|
2016-02-17 12:36:24 +00:00
|
|
|
{ 0, 0, 0, }
|
2010-06-13 13:28:53 +00:00
|
|
|
};
|
|
|
|
|
2012-08-15 05:15:49 +00:00
|
|
|
static int
|
2016-04-26 11:53:37 +00:00
|
|
|
platform_sram_devmap(struct devmap_entry *map)
|
2012-08-15 05:15:49 +00:00
|
|
|
{
|
2016-06-02 18:31:36 +00:00
|
|
|
#if !defined(SOC_MV_ARMADAXP) && !defined(SOC_MV_ARMADA38X)
|
2012-08-15 05:15:49 +00:00
|
|
|
phandle_t child, root;
|
|
|
|
u_long base, size;
|
|
|
|
/*
|
|
|
|
* SRAM range.
|
|
|
|
*/
|
|
|
|
if ((child = OF_finddevice("/sram")) != 0)
|
2016-11-11 15:13:30 +00:00
|
|
|
if (ofw_bus_node_is_compatible(child, "mrvl,cesa-sram") ||
|
|
|
|
ofw_bus_node_is_compatible(child, "mrvl,scratchpad"))
|
2012-08-15 05:15:49 +00:00
|
|
|
goto moveon;
|
|
|
|
|
|
|
|
if ((root = OF_finddevice("/")) == 0)
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
if ((child = fdt_find_compatible(root, "mrvl,cesa-sram", 0)) == 0 &&
|
|
|
|
(child = fdt_find_compatible(root, "mrvl,scratchpad", 0)) == 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
moveon:
|
|
|
|
if (fdt_regsize(child, &base, &size) != 0)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
map->pd_va = MV_CESA_SRAM_BASE; /* XXX */
|
|
|
|
map->pd_pa = base;
|
|
|
|
map->pd_size = size;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
out:
|
|
|
|
#endif
|
|
|
|
return (ENOENT);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-01-27 00:39:02 +00:00
|
|
|
/*
|
2014-01-05 22:36:34 +00:00
|
|
|
* Supply a default do-nothing implementation of mv_pci_devmap() via a weak
|
2013-01-27 00:39:02 +00:00
|
|
|
* alias. Many Marvell platforms don't support a PCI interface, but to support
|
|
|
|
* those that do, we end up with a reference to this function below, in
|
2014-05-17 11:27:36 +00:00
|
|
|
* platform_devmap_init(). If "device pci" appears in the kernel config, the
|
2014-01-05 22:36:34 +00:00
|
|
|
* real implementation of this function in arm/mv/mv_pci.c overrides the weak
|
2013-01-27 00:39:02 +00:00
|
|
|
* alias defined here.
|
|
|
|
*/
|
2016-04-26 11:53:37 +00:00
|
|
|
int mv_default_fdt_pci_devmap(phandle_t node, struct devmap_entry *devmap,
|
2013-01-27 00:39:02 +00:00
|
|
|
vm_offset_t io_va, vm_offset_t mem_va);
|
|
|
|
int
|
2016-04-26 11:53:37 +00:00
|
|
|
mv_default_fdt_pci_devmap(phandle_t node, struct devmap_entry *devmap,
|
2013-01-27 00:39:02 +00:00
|
|
|
vm_offset_t io_va, vm_offset_t mem_va)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
2014-01-05 22:36:34 +00:00
|
|
|
__weak_reference(mv_default_fdt_pci_devmap, mv_pci_devmap);
|
2013-01-27 00:39:02 +00:00
|
|
|
|
2012-05-18 14:41:14 +00:00
|
|
|
/*
|
|
|
|
* XXX: When device entry in devmap has pd_size smaller than section size,
|
|
|
|
* system will freeze during initialization
|
|
|
|
*/
|
|
|
|
|
2010-06-13 13:28:53 +00:00
|
|
|
/*
|
2016-02-02 10:32:45 +00:00
|
|
|
* Construct devmap table with DT-derived config data.
|
2010-06-13 13:28:53 +00:00
|
|
|
*/
|
2012-11-03 22:39:07 +00:00
|
|
|
int
|
2014-05-17 11:27:36 +00:00
|
|
|
platform_devmap_init(void)
|
2010-06-13 13:28:53 +00:00
|
|
|
{
|
|
|
|
phandle_t root, child;
|
2012-05-18 14:41:14 +00:00
|
|
|
pcell_t bank_count;
|
|
|
|
int i, num_mapped;
|
|
|
|
|
|
|
|
i = 0;
|
2016-04-26 11:53:37 +00:00
|
|
|
devmap_register_table(&fdt_devmap[0]);
|
2010-06-13 13:28:53 +00:00
|
|
|
|
2013-10-28 21:34:32 +00:00
|
|
|
#ifdef SOC_MV_ARMADAXP
|
|
|
|
vm_paddr_t cur_immr_pa;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Acquire SoC registers' base passed by u-boot and fill devmap
|
|
|
|
* accordingly. DTB is going to be modified basing on this data
|
|
|
|
* later.
|
|
|
|
*/
|
|
|
|
__asm __volatile("mrc p15, 4, %0, c15, c0, 0" : "=r" (cur_immr_pa));
|
|
|
|
cur_immr_pa = (cur_immr_pa << 13) & 0xff000000;
|
|
|
|
if (cur_immr_pa != 0)
|
|
|
|
fdt_immr_pa = cur_immr_pa;
|
|
|
|
#endif
|
2010-06-13 13:28:53 +00:00
|
|
|
/*
|
|
|
|
* IMMR range.
|
|
|
|
*/
|
|
|
|
fdt_devmap[i].pd_va = fdt_immr_va;
|
|
|
|
fdt_devmap[i].pd_pa = fdt_immr_pa;
|
|
|
|
fdt_devmap[i].pd_size = fdt_immr_size;
|
|
|
|
i++;
|
|
|
|
|
|
|
|
/*
|
2012-08-15 05:15:49 +00:00
|
|
|
* SRAM range.
|
|
|
|
*/
|
|
|
|
if (i < FDT_DEVMAP_MAX)
|
|
|
|
if (platform_sram_devmap(&fdt_devmap[i]) == 0)
|
|
|
|
i++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PCI range(s).
|
2012-05-18 14:41:14 +00:00
|
|
|
* PCI range(s) and localbus.
|
2010-06-13 13:28:53 +00:00
|
|
|
*/
|
2011-12-02 15:24:39 +00:00
|
|
|
if ((root = OF_finddevice("/")) == -1)
|
2010-06-13 13:28:53 +00:00
|
|
|
return (ENXIO);
|
2012-05-18 14:41:14 +00:00
|
|
|
for (child = OF_child(root); child != 0; child = OF_peer(child)) {
|
2012-08-15 05:15:49 +00:00
|
|
|
if (fdt_is_type(child, "pci") || fdt_is_type(child, "pciep")) {
|
2010-06-13 13:28:53 +00:00
|
|
|
/*
|
|
|
|
* Check space: each PCI node will consume 2 devmap
|
|
|
|
* entries.
|
|
|
|
*/
|
2012-08-15 05:15:49 +00:00
|
|
|
if (i + 1 >= FDT_DEVMAP_MAX)
|
2010-06-13 13:28:53 +00:00
|
|
|
return (ENOMEM);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX this should account for PCI and multiple ranges
|
|
|
|
* of a given kind.
|
|
|
|
*/
|
2014-01-05 22:36:34 +00:00
|
|
|
if (mv_pci_devmap(child, &fdt_devmap[i], MV_PCI_VA_IO_BASE,
|
2012-08-15 05:15:49 +00:00
|
|
|
MV_PCI_VA_MEM_BASE) != 0)
|
2010-06-13 13:28:53 +00:00
|
|
|
return (ENXIO);
|
|
|
|
i += 2;
|
|
|
|
}
|
|
|
|
|
2016-11-11 15:13:30 +00:00
|
|
|
if (ofw_bus_node_is_compatible(child, "mrvl,lbc")) {
|
2012-05-18 14:41:14 +00:00
|
|
|
/* Check available space */
|
2016-11-14 12:03:08 +00:00
|
|
|
if (OF_getencprop(child, "bank-count", &bank_count,
|
2012-05-18 14:41:14 +00:00
|
|
|
sizeof(bank_count)) <= 0)
|
|
|
|
/* If no property, use default value */
|
|
|
|
bank_count = 1;
|
|
|
|
|
|
|
|
if ((i + bank_count) >= FDT_DEVMAP_MAX)
|
|
|
|
return (ENOMEM);
|
|
|
|
|
|
|
|
/* Add all localbus ranges to device map */
|
|
|
|
num_mapped = 0;
|
|
|
|
|
|
|
|
if (fdt_localbus_devmap(child, &fdt_devmap[i],
|
|
|
|
(int)bank_count, &num_mapped) != 0)
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
i += num_mapped;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-13 13:28:53 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2016-09-23 12:38:05 +00:00
|
|
|
#if __ARM_ARCH < 6
|
2008-10-13 20:07:13 +00:00
|
|
|
struct arm32_dma_range *
|
|
|
|
bus_dma_get_range(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
bus_dma_get_range_nb(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
2016-09-23 12:38:05 +00:00
|
|
|
#endif
|
2012-08-15 05:15:49 +00:00
|
|
|
|
|
|
|
#if defined(CPU_MV_PJ4B)
|
|
|
|
#ifdef DDB
|
|
|
|
#include <ddb/ddb.h>
|
|
|
|
|
|
|
|
DB_SHOW_COMMAND(cp15, db_show_cp15)
|
|
|
|
{
|
|
|
|
u_int reg;
|
|
|
|
|
|
|
|
__asm __volatile("mrc p15, 0, %0, c0, c0, 0" : "=r" (reg));
|
|
|
|
db_printf("Cpu ID: 0x%08x\n", reg);
|
|
|
|
__asm __volatile("mrc p15, 0, %0, c0, c0, 1" : "=r" (reg));
|
|
|
|
db_printf("Current Cache Lvl ID: 0x%08x\n",reg);
|
|
|
|
|
2016-05-23 20:07:17 +00:00
|
|
|
reg = cp15_sctlr_get();
|
2012-08-15 05:15:49 +00:00
|
|
|
db_printf("Ctrl: 0x%08x\n",reg);
|
2016-05-23 20:07:17 +00:00
|
|
|
reg = cp15_actlr_get();
|
2012-08-15 05:15:49 +00:00
|
|
|
db_printf("Aux Ctrl: 0x%08x\n",reg);
|
|
|
|
|
|
|
|
__asm __volatile("mrc p15, 0, %0, c0, c1, 0" : "=r" (reg));
|
|
|
|
db_printf("Processor Feat 0: 0x%08x\n", reg);
|
|
|
|
__asm __volatile("mrc p15, 0, %0, c0, c1, 1" : "=r" (reg));
|
|
|
|
db_printf("Processor Feat 1: 0x%08x\n", reg);
|
|
|
|
__asm __volatile("mrc p15, 0, %0, c0, c1, 2" : "=r" (reg));
|
|
|
|
db_printf("Debug Feat 0: 0x%08x\n", reg);
|
|
|
|
__asm __volatile("mrc p15, 0, %0, c0, c1, 3" : "=r" (reg));
|
|
|
|
db_printf("Auxiliary Feat 0: 0x%08x\n", reg);
|
|
|
|
__asm __volatile("mrc p15, 0, %0, c0, c1, 4" : "=r" (reg));
|
|
|
|
db_printf("Memory Model Feat 0: 0x%08x\n", reg);
|
|
|
|
__asm __volatile("mrc p15, 0, %0, c0, c1, 5" : "=r" (reg));
|
|
|
|
db_printf("Memory Model Feat 1: 0x%08x\n", reg);
|
|
|
|
__asm __volatile("mrc p15, 0, %0, c0, c1, 6" : "=r" (reg));
|
|
|
|
db_printf("Memory Model Feat 2: 0x%08x\n", reg);
|
|
|
|
__asm __volatile("mrc p15, 0, %0, c0, c1, 7" : "=r" (reg));
|
|
|
|
db_printf("Memory Model Feat 3: 0x%08x\n", reg);
|
|
|
|
|
|
|
|
__asm __volatile("mrc p15, 1, %0, c15, c2, 0" : "=r" (reg));
|
|
|
|
db_printf("Aux Func Modes Ctrl 0: 0x%08x\n",reg);
|
|
|
|
__asm __volatile("mrc p15, 1, %0, c15, c2, 1" : "=r" (reg));
|
|
|
|
db_printf("Aux Func Modes Ctrl 1: 0x%08x\n",reg);
|
|
|
|
|
|
|
|
__asm __volatile("mrc p15, 1, %0, c15, c12, 0" : "=r" (reg));
|
|
|
|
db_printf("CPU ID code extension: 0x%08x\n",reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
DB_SHOW_COMMAND(vtop, db_show_vtop)
|
|
|
|
{
|
|
|
|
u_int reg;
|
|
|
|
|
|
|
|
if (have_addr) {
|
|
|
|
__asm __volatile("mcr p15, 0, %0, c7, c8, 0" : : "r" (addr));
|
|
|
|
__asm __volatile("mrc p15, 0, %0, c7, c4, 0" : "=r" (reg));
|
|
|
|
db_printf("Physical address reg: 0x%08x\n",reg);
|
|
|
|
} else
|
|
|
|
db_printf("show vtop <virt_addr>\n");
|
|
|
|
}
|
|
|
|
#endif /* DDB */
|
|
|
|
#endif /* CPU_MV_PJ4B */
|
|
|
|
|