Changeset View
Standalone View
sys/dev/cadence/if_cgem.c
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | |||||||||
/* Default for sysctl rxbufs. Must be < CGEM_NUM_RX_DESCS of course. */ | /* Default for sysctl rxbufs. Must be < CGEM_NUM_RX_DESCS of course. */ | ||||||||
#define DEFAULT_NUM_RX_BUFS 256 /* number of receive bufs to queue. */ | #define DEFAULT_NUM_RX_BUFS 256 /* number of receive bufs to queue. */ | ||||||||
#define TX_MAX_DMA_SEGS 8 /* maximum segs in a tx mbuf dma */ | #define TX_MAX_DMA_SEGS 8 /* maximum segs in a tx mbuf dma */ | ||||||||
#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) | ||||||||
#define HWTYPE_GENERIC_GEM 1 | #define HWQUIRK_NONE 0 | ||||||||
#define HWTYPE_ZYNQ 2 | #define HWQUIRK_NEEDNULLQS 1 | ||||||||
#define HWTYPE_ZYNQMP 3 | #define HWQUIRK_RXHANGWAR 2 | ||||||||
#define HWTYPE_SIFIVE 4 | #define HWQUIRK_TXCLK 4 | ||||||||
#define HWQUIRK_PCLK 8 | |||||||||
static struct ofw_compat_data compat_data[] = { | static struct ofw_compat_data compat_data[] = { | ||||||||
{ "cdns,zynq-gem", HWTYPE_ZYNQ }, | { "cdns,zynq-gem", HWQUIRK_RXHANGWAR | HWQUIRK_TXCLK }, | ||||||||
{ "cdns,zynqmp-gem", HWTYPE_ZYNQMP }, | { "cdns,zynqmp-gem", HWQUIRK_NEEDNULLQS | HWQUIRK_TXCLK }, | ||||||||
{ "sifive,fu540-c000-gem", HWTYPE_SIFIVE }, | { "sifive,fu540-c000-gem", HWQUIRK_PCLK }, | ||||||||
mhorne: What device tree provides this compatible? I do not see it in the upstreamed bits for the… | |||||||||
Done Inline ActionsIt is used in device tree presented from U-Boot as used in PF-RCHD SoM V1.0 - this is not published anywhere I think. I saw some compatible changes in MicroChip device trees, anyway, so it may change in future, too, but now it is this way. It would be great if someone with Icicle Kit could check, but I know no one who has it. bsd_dino.sk: It is used in device tree presented from U-Boot as used in PF-RCHD SoM V1.0 - this is not… | |||||||||
{ "sifive,fu740-c000-gem", HWTYPE_SIFIVE }, | { "sifive,fu740-c000-gem", HWQUIRK_PCLK }, | ||||||||
{ "cdns,gem", HWTYPE_GENERIC_GEM }, | { "cdns,gem", HWQUIRK_NONE }, | ||||||||
{ "cadence,gem", HWTYPE_GENERIC_GEM }, | { "cadence,gem", HWQUIRK_NONE }, | ||||||||
{ NULL, 0 } | { NULL, 0 } | ||||||||
}; | }; | ||||||||
Not Done Inline ActionsThe problem with this is that HWQUIRK_NONE is zero which also means no match in the probe routine. Any board that uses the last three generic compatible strings won't match. How about HWQUIRK_NONE be 1 and move the other bits left. skibo: The problem with this is that HWQUIRK_NONE is zero which also means no match in the probe… | |||||||||
Done Inline ActionsAh, that's an oversight from me... I have another idea I need to check first. Wait a moment, please. bsd_dino.sk: Ah, that's an oversight from me... I have another idea I need to check first. Wait a moment… | |||||||||
struct cgem_softc { | struct cgem_softc { | ||||||||
if_t ifp; | if_t ifp; | ||||||||
struct mtx sc_mtx; | struct mtx sc_mtx; | ||||||||
device_t dev; | device_t dev; | ||||||||
device_t miibus; | device_t miibus; | ||||||||
u_int mii_media_active; /* last active media */ | u_int mii_media_active; /* last active media */ | ||||||||
int if_old_flags; | int if_old_flags; | ||||||||
▲ Show 20 Lines • Show All 1,582 Lines • ▼ Show 20 Lines | |||||||||
static int | static int | ||||||||
cgem_probe(device_t dev) | cgem_probe(device_t dev) | ||||||||
{ | { | ||||||||
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_str == NULL) | ||||||||
Done Inline ActionsThis change should solve the probe issue. While more commonly comparison ocd_data == 0 is used, ocd_str == NULL is logically equivalent and used couple of times as well. bsd_dino.sk: This change should solve the probe issue. While more commonly comparison ocd_data == 0 is used… | |||||||||
return (ENXIO); | return (ENXIO); | ||||||||
device_set_desc(dev, "Cadence CGEM Gigabit Ethernet Interface"); | device_set_desc(dev, "Cadence CGEM Gigabit Ethernet Interface"); | ||||||||
return (0); | return (0); | ||||||||
} | } | ||||||||
static int | static int | ||||||||
cgem_attach(device_t dev) | 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; | ||||||||
int rid, err; | int rid, err; | ||||||||
u_char eaddr[ETHER_ADDR_LEN]; | u_char eaddr[ETHER_ADDR_LEN]; | ||||||||
int hwtype; | int hwquirks; | ||||||||
sc->dev = dev; | sc->dev = dev; | ||||||||
CGEM_LOCK_INIT(sc); | CGEM_LOCK_INIT(sc); | ||||||||
/* Key off of compatible string and set hardware-specific options. */ | /* Key off of compatible string and set hardware-specific options. */ | ||||||||
hwtype = ofw_bus_search_compatible(dev, compat_data)->ocd_data; | hwquirks = ofw_bus_search_compatible(dev, compat_data)->ocd_data; | ||||||||
if (hwtype == HWTYPE_ZYNQMP) | if ((hwquirks & HWQUIRK_NEEDNULLQS) != 0) | ||||||||
Not Done Inline Actions
FYI, it is preferred (but not enforced) style within FreeBSD to be explicit like this for flag checks. You can see it elsewhere in this file. mhorne: FYI, it is preferred (but not enforced) style within FreeBSD to be explicit like this for flag… | |||||||||
Done Inline ActionsOK. Wait a moment, please, for new revision... bsd_dino.sk: OK. Wait a moment, please, for new revision... | |||||||||
sc->neednullqs = 1; | sc->neednullqs = 1; | ||||||||
if (hwtype == HWTYPE_ZYNQ) | if ((hwquirks & HWQUIRK_RXHANGWAR) != 0) | ||||||||
sc->rxhangwar = 1; | sc->rxhangwar = 1; | ||||||||
if ((hwquirks & HWQUIRK_TXCLK) != 0) { | |||||||||
if (hwtype == HWTYPE_ZYNQ || hwtype == HWTYPE_ZYNQMP) { | |||||||||
if (clk_get_by_ofw_name(dev, 0, "tx_clk", &sc->ref_clk) != 0) | if (clk_get_by_ofw_name(dev, 0, "tx_clk", &sc->ref_clk) != 0) | ||||||||
Not Done Inline ActionsCould this... mhorne: Could this... | |||||||||
device_printf(dev, | device_printf(dev, | ||||||||
"could not retrieve reference clock.\n"); | "could not retrieve reference clock.\n"); | ||||||||
else if (clk_enable(sc->ref_clk) != 0) | else if (clk_enable(sc->ref_clk) != 0) | ||||||||
device_printf(dev, "could not enable clock.\n"); | device_printf(dev, "could not enable clock.\n"); | ||||||||
} else if (hwtype == HWTYPE_SIFIVE) { | } | ||||||||
if ((hwquirks & HWQUIRK_PCLK) != 0) { | |||||||||
if (clk_get_by_ofw_name(dev, 0, "pclk", &sc->ref_clk) != 0) | if (clk_get_by_ofw_name(dev, 0, "pclk", &sc->ref_clk) != 0) | ||||||||
device_printf(dev, | device_printf(dev, | ||||||||
"could not retrieve reference clock.\n"); | "could not retrieve reference clock.\n"); | ||||||||
else if (clk_enable(sc->ref_clk) != 0) | else if (clk_enable(sc->ref_clk) != 0) | ||||||||
device_printf(dev, "could not enable clock.\n"); | device_printf(dev, "could not enable clock.\n"); | ||||||||
} | } | ||||||||
Not Done Inline Actions...be moved down here? So that it is not in the middle of checking the quirks. mhorne: ...be moved down here? So that it is not in the middle of checking the quirks. | |||||||||
Done Inline ActionsDefinitelly, yes. In some older version it was not that visible. Here it is clearly better the way you show. bsd_dino.sk: Definitelly, yes. In some older version it was not that visible. Here it is clearly better the… | |||||||||
/* Get memory resource. */ | /* Get memory resource. */ | ||||||||
rid = 0; | rid = 0; | ||||||||
sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, | sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, | ||||||||
RF_ACTIVE); | RF_ACTIVE); | ||||||||
if (sc->mem_res == NULL) { | if (sc->mem_res == NULL) { | ||||||||
device_printf(dev, "could not allocate memory resources.\n"); | device_printf(dev, "could not allocate memory resources.\n"); | ||||||||
return (ENOMEM); | return (ENOMEM); | ||||||||
} | } | ||||||||
▲ Show 20 Lines • Show All 191 Lines • Show Last 20 Lines |
What device tree provides this compatible? I do not see it in the upstreamed bits for the PolarFire/MPFS Icicle Kit.