sys: Move Marvell specific fdt code to sys/arm/mv

fdt_immr_* are only used by the armv7 Marvell code. Move setting the
variables there as no new code should need to set them.

Reviewed by:	cognet
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D49535
This commit is contained in:
Andrew Turner 2025-04-08 11:46:51 +01:00
parent bb6a069c59
commit 17c67ba24d
5 changed files with 37 additions and 43 deletions

View file

@ -46,6 +46,7 @@
#include <machine/armreg.h>
#include <arm/mv/mvwin.h>
#include <arm/mv/mvvar.h>
#include <machine/platformvar.h>

View file

@ -103,6 +103,10 @@ void mv_axp_platform_mp_setmaxid(platform_t plate);
void mv_axp_platform_mp_start_ap(platform_t plate);
#endif
vm_paddr_t fdt_immr_pa;
vm_offset_t fdt_immr_va;
static vm_offset_t fdt_immr_size;
#define MPP_PIN_MAX 68
#define MPP_PIN_CELLS 2
#define MPP_PINS_PER_REG 8
@ -270,9 +274,35 @@ static int
mv_platform_probe_and_attach(platform_t plate)
{
if (fdt_immr_addr(MV_BASE) != 0)
while (1);
return (0);
phandle_t node;
u_long base, size;
int r;
/*
* Try to access the SOC node directly i.e. through /aliases/.
*/
if ((node = OF_finddevice("soc")) != -1)
if (ofw_bus_node_is_compatible(node, "simple-bus"))
goto moveon;
/*
* Find the node the long way.
*/
if ((node = OF_finddevice("/")) == -1)
goto errout;
if ((node = fdt_find_compatible(node, "simple-bus", 0)) == 0)
goto errout;
moveon:
if ((r = fdt_get_range(node, 0, &base, &size)) == 0) {
fdt_immr_pa = base;
fdt_immr_va = MV_BASE;
fdt_immr_size = size;
return (0);
}
errout:
while (1);
}
static void

View file

@ -80,6 +80,9 @@ extern const struct decode_win *xor_wins;
extern int idma_wins_no;
extern int xor_wins_no;
extern vm_paddr_t fdt_immr_pa;
extern vm_offset_t fdt_immr_va;
int soc_decode_win(void);
void soc_id(uint32_t *dev, uint32_t *rev);
void soc_dump_decode_win(void);

View file

@ -62,10 +62,6 @@
SYSCTL_NODE(_hw, OID_AUTO, fdt, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
"Flattened Device Tree");
vm_paddr_t fdt_immr_pa;
vm_offset_t fdt_immr_va;
vm_offset_t fdt_immr_size;
struct fdt_ic_list fdt_ic_list_head = SLIST_HEAD_INITIALIZER(fdt_ic_list_head);
static int
@ -199,38 +195,6 @@ fdt_get_range(phandle_t node, int range_id, u_long *base, u_long *size)
return (0);
}
int
fdt_immr_addr(vm_offset_t immr_va)
{
phandle_t node;
u_long base, size;
int r;
/*
* Try to access the SOC node directly i.e. through /aliases/.
*/
if ((node = OF_finddevice("soc")) != -1)
if (ofw_bus_node_is_compatible(node, "simple-bus"))
goto moveon;
/*
* Find the node the long way.
*/
if ((node = OF_finddevice("/")) == -1)
return (ENXIO);
if ((node = fdt_find_compatible(node, "simple-bus", 0)) == 0)
return (ENXIO);
moveon:
if ((r = fdt_get_range(node, 0, &base, &size)) == 0) {
fdt_immr_pa = base;
fdt_immr_va = immr_va;
fdt_immr_size = size;
}
return (r);
}
int
fdt_is_compatible_strict(phandle_t node, const char *compatible)
{

View file

@ -66,10 +66,6 @@ struct fdt_ic {
device_t dev;
};
extern vm_paddr_t fdt_immr_pa;
extern vm_offset_t fdt_immr_va;
extern vm_offset_t fdt_immr_size;
#if defined(FDT_DTB_STATIC)
extern u_char fdt_static_dtb;
#endif