mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-06-06 14:43:35 +08:00
freebsd/cgem: Add device tree support
This reintroduces device tree support to the CGEM driver while preserving the ability to statically define CGEM interfaces.
This commit is contained in:
parent
f462c4de5f
commit
fef8b8850b
@ -72,11 +72,9 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <net/bpf.h>
|
#include <net/bpf.h>
|
||||||
#include <net/bpfdesc.h>
|
#include <net/bpfdesc.h>
|
||||||
|
|
||||||
#ifndef __rtems__
|
|
||||||
#include <dev/fdt/fdt_common.h>
|
#include <dev/fdt/fdt_common.h>
|
||||||
#include <dev/ofw/ofw_bus.h>
|
#include <dev/ofw/ofw_bus.h>
|
||||||
#include <dev/ofw/ofw_bus_subr.h>
|
#include <dev/ofw/ofw_bus_subr.h>
|
||||||
#endif /* __rtems__ */
|
|
||||||
|
|
||||||
#include <dev/mii/mii.h>
|
#include <dev/mii/mii.h>
|
||||||
#include <dev/mii/miivar.h>
|
#include <dev/mii/miivar.h>
|
||||||
@ -92,6 +90,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#pragma GCC diagnostic ignored "-Wpointer-sign"
|
#pragma GCC diagnostic ignored "-Wpointer-sign"
|
||||||
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
|
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
|
||||||
#include <rtems/bsd/bsd.h>
|
#include <rtems/bsd/bsd.h>
|
||||||
|
#include <rtems/bsd/local/opt_platform.h>
|
||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
#define IF_CGEM_NAME "cgem"
|
#define IF_CGEM_NAME "cgem"
|
||||||
@ -111,13 +110,14 @@ __FBSDID("$FreeBSD$");
|
|||||||
#define CGEM_CKSUM_ASSIST (CSUM_IP | CSUM_TCP | CSUM_UDP | \
|
#define CGEM_CKSUM_ASSIST (CSUM_IP | CSUM_TCP | CSUM_UDP | \
|
||||||
CSUM_TCP_IPV6 | CSUM_UDP_IPV6)
|
CSUM_TCP_IPV6 | CSUM_UDP_IPV6)
|
||||||
|
|
||||||
#ifndef __rtems__
|
|
||||||
static struct ofw_compat_data compat_data[] = {
|
static struct ofw_compat_data compat_data[] = {
|
||||||
{ "cadence,gem", 1 },
|
{ "cadence,gem", 1 },
|
||||||
{ "cdns,macb", 1 },
|
{ "cdns,macb", 1 },
|
||||||
|
#ifdef __rtems__
|
||||||
|
{ "cdns,gem", 1 },
|
||||||
|
#endif
|
||||||
{ NULL, 0 },
|
{ NULL, 0 },
|
||||||
};
|
};
|
||||||
#endif /* __rtems__ */
|
|
||||||
|
|
||||||
struct cgem_softc {
|
struct cgem_softc {
|
||||||
if_t ifp;
|
if_t ifp;
|
||||||
@ -1947,13 +1947,20 @@ static int
|
|||||||
cgem_probe(device_t dev)
|
cgem_probe(device_t dev)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifndef __rtems__
|
#ifdef __rtems__
|
||||||
|
#ifdef FDT
|
||||||
|
if (bsp_fdt_get()) {
|
||||||
|
#else
|
||||||
|
if (0) {
|
||||||
|
#endif
|
||||||
|
#endif /* __rtems__ */
|
||||||
if (!ofw_bus_status_okay(dev))
|
if (!ofw_bus_status_okay(dev))
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
|
|
||||||
if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
|
if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
#else /* __rtems__ */
|
#ifdef __rtems__
|
||||||
|
}
|
||||||
|
|
||||||
struct cgem_softc *sc = device_get_softc(dev);
|
struct cgem_softc *sc = device_get_softc(dev);
|
||||||
int val, rid = 0;
|
int val, rid = 0;
|
||||||
@ -1983,24 +1990,34 @@ cgem_attach(device_t dev)
|
|||||||
{
|
{
|
||||||
struct cgem_softc *sc = device_get_softc(dev);
|
struct cgem_softc *sc = device_get_softc(dev);
|
||||||
if_t ifp = NULL;
|
if_t ifp = NULL;
|
||||||
#ifndef __rtems__
|
|
||||||
phandle_t node;
|
phandle_t node;
|
||||||
pcell_t cell;
|
pcell_t cell;
|
||||||
#endif /* __rtems__ */
|
|
||||||
int rid, err;
|
int rid, err;
|
||||||
u_char eaddr[ETHER_ADDR_LEN];
|
u_char eaddr[ETHER_ADDR_LEN];
|
||||||
|
|
||||||
sc->dev = dev;
|
sc->dev = dev;
|
||||||
CGEM_LOCK_INIT(sc);
|
CGEM_LOCK_INIT(sc);
|
||||||
|
|
||||||
#ifndef __rtems__
|
#ifdef __rtems__
|
||||||
|
#ifdef FDT
|
||||||
|
if (bsp_fdt_get()) {
|
||||||
|
#else
|
||||||
|
if (0) {
|
||||||
|
#endif
|
||||||
|
#endif /* __rtems__ */
|
||||||
/* Get reference clock number and base divider from fdt. */
|
/* Get reference clock number and base divider from fdt. */
|
||||||
node = ofw_bus_get_node(dev);
|
node = ofw_bus_get_node(dev);
|
||||||
sc->ref_clk_num = 0;
|
sc->ref_clk_num = 0;
|
||||||
if (OF_getprop(node, "ref-clock-num", &cell, sizeof(cell)) > 0)
|
if (OF_getprop(node, "ref-clock-num", &cell, sizeof(cell)) > 0)
|
||||||
sc->ref_clk_num = fdt32_to_cpu(cell);
|
sc->ref_clk_num = fdt32_to_cpu(cell);
|
||||||
#else /* __rtems__ */
|
#ifdef __rtems__
|
||||||
sc->ref_clk_num = device_get_unit(dev);
|
/* Else for ref-clock-num OF_getprop */
|
||||||
|
else
|
||||||
|
sc->ref_clk_num = device_get_unit(dev);
|
||||||
|
} else {
|
||||||
|
sc->ref_clk_num = device_get_unit(dev);
|
||||||
|
sc->phy_contype = MII_CONTYPE_RGMII_ID;
|
||||||
|
}
|
||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
/* Get memory resource. */
|
/* Get memory resource. */
|
||||||
@ -2228,9 +2245,8 @@ static driver_t cgem_driver = {
|
|||||||
sizeof(struct cgem_softc),
|
sizeof(struct cgem_softc),
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef __rtems__
|
|
||||||
DRIVER_MODULE(cgem, simplebus, cgem_driver, cgem_devclass, NULL, NULL);
|
DRIVER_MODULE(cgem, simplebus, cgem_driver, cgem_devclass, NULL, NULL);
|
||||||
#else /* __rtems__ */
|
#ifdef __rtems__
|
||||||
DRIVER_MODULE(cgem, nexus, cgem_driver, cgem_devclass, NULL, NULL);
|
DRIVER_MODULE(cgem, nexus, cgem_driver, cgem_devclass, NULL, NULL);
|
||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
DRIVER_MODULE(miibus, cgem, miibus_driver, miibus_devclass, NULL, NULL);
|
DRIVER_MODULE(miibus, cgem, miibus_driver, miibus_devclass, NULL, NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user