mvneta: split to FDT and generic part

Split some missing routines.

Obtained from:	Semihalf
This commit is contained in:
Wojciech Macek 2021-09-14 09:11:15 +02:00
parent 44fb3c695f
commit 5572fda3a2
3 changed files with 50 additions and 40 deletions

View file

@ -68,10 +68,6 @@ __FBSDID("$FreeBSD$");
#include <dev/mii/mii.h>
#include <dev/mii/miivar.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
#include <dev/mdio/mdio.h>
#include <arm/mv/mvvar.h>
@ -222,11 +218,6 @@ static device_method_t mvneta_methods[] = {
DEVMETHOD_END
};
static struct ofw_compat_data compat_data[] = {
{ "marvell,armada-3700-neta", true },
{ NULL, false }
};
DEFINE_CLASS_0(mvneta, mvneta_driver, mvneta_methods, sizeof(struct mvneta_softc));
DRIVER_MODULE(miibus, mvneta, miibus_driver, miibus_devclass, 0, 0);
@ -234,7 +225,7 @@ DRIVER_MODULE(mdio, mvneta, mdio_driver, mdio_devclass, 0, 0);
MODULE_DEPEND(mvneta, mdio, 1, 1, 1);
MODULE_DEPEND(mvneta, ether, 1, 1, 1);
MODULE_DEPEND(mvneta, miibus, 1, 1, 1);
SIMPLEBUS_PNP_INFO(compat_data);
MODULE_DEPEND(mvneta, mvxpbm, 1, 1, 1);
/*
* List of MIB register and names
@ -418,40 +409,14 @@ mvneta_get_mac_address(struct mvneta_softc *sc, uint8_t *addr)
return (0);
}
STATIC boolean_t
mvneta_find_ethernet_prop_switch(phandle_t ethernet, phandle_t node)
{
boolean_t ret;
phandle_t child, switch_eth_handle, switch_eth;
for (child = OF_child(node); child != 0; child = OF_peer(child)) {
if (OF_getencprop(child, "ethernet", (void*)&switch_eth_handle,
sizeof(switch_eth_handle)) > 0) {
if (switch_eth_handle > 0) {
switch_eth = OF_node_from_xref(
switch_eth_handle);
if (switch_eth == ethernet)
return (true);
}
}
ret = mvneta_find_ethernet_prop_switch(ethernet, child);
if (ret != 0)
return (ret);
}
return (false);
}
STATIC boolean_t
mvneta_has_switch(device_t self)
{
phandle_t node;
#ifdef FDT
return (mvneta_has_switch_fdt(self));
#endif
node = ofw_bus_get_node(self);
return mvneta_find_ethernet_prop_switch(node, OF_finddevice("/"));
return (false);
}
STATIC int

View file

@ -58,6 +58,12 @@ __FBSDID("$FreeBSD$");
#include "if_mvnetareg.h"
#include "if_mvnetavar.h"
#ifdef MVNETA_DEBUG
#define STATIC /* nothing */
#else
#define STATIC static
#endif
#define PHY_MODE_MAXLEN 10
#define INBAND_STATUS_MAXLEN 16
@ -89,6 +95,8 @@ static struct ofw_compat_data compat_data[] = {
{NULL, false}
};
SIMPLEBUS_PNP_INFO(compat_data);
static int
mvneta_fdt_probe(device_t dev)
{
@ -250,3 +258,39 @@ mvneta_fdt_mac_address(struct mvneta_softc *sc, uint8_t *addr)
return (0);
}
STATIC boolean_t
mvneta_find_ethernet_prop_switch(phandle_t ethernet, phandle_t node)
{
boolean_t ret;
phandle_t child, switch_eth_handle, switch_eth;
for (child = OF_child(node); child != 0; child = OF_peer(child)) {
if (OF_getencprop(child, "ethernet", (void*)&switch_eth_handle,
sizeof(switch_eth_handle)) > 0) {
if (switch_eth_handle > 0) {
switch_eth = OF_node_from_xref(
switch_eth_handle);
if (switch_eth == ethernet)
return (true);
}
}
ret = mvneta_find_ethernet_prop_switch(ethernet, child);
if (ret != 0)
return (ret);
}
return (false);
}
boolean_t
mvneta_has_switch_fdt(device_t self)
{
phandle_t node;
node = ofw_bus_get_node(self);
return mvneta_find_ethernet_prop_switch(node, OF_finddevice("/"));
}

View file

@ -321,6 +321,7 @@ struct mvneta_softc {
int mvneta_attach(device_t);
#ifdef FDT
boolean_t mvneta_has_switch_fdt(device_t);
int mvneta_fdt_mac_address(struct mvneta_softc *, uint8_t *);
#endif