Commit 3428997c authored by Mitchell Horne's avatar Mitchell Horne
Browse files

if_dwc: recognize additional rgmii phy-modes

Per the reports, some Allwinner device trees now list the desired
phy-mode as "rgmii-id". The manual string comparison fails to detect
this, and we end up falling back to MII mode. Instead, select the clock
name using the sc->phy_mode variable, which is set in the main attach
function.

The logic to actually handle rgmii-id mode delays will be added to the
relevant PHY driver.

PR:		261355, 264673
Reported by:	Maren <marentoy@protonmail.com>
Reported by:	Arie Bikker <src-2016@bikker.homeunix.net>
Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35500
parent 27b39e58
...@@ -62,40 +62,43 @@ a20_if_dwc_probe(device_t dev) ...@@ -62,40 +62,43 @@ a20_if_dwc_probe(device_t dev)
static int static int
a20_if_dwc_init(device_t dev) a20_if_dwc_init(device_t dev)
{ {
struct dwc_softc *sc;
const char *tx_parent_name; const char *tx_parent_name;
char *phy_type;
clk_t clk_tx, clk_tx_parent; clk_t clk_tx, clk_tx_parent;
regulator_t reg; regulator_t reg;
phandle_t node;
int error; int error;
node = ofw_bus_get_node(dev); sc = device_get_softc(dev);
/* Configure PHY for MII or RGMII mode */ /* Configure PHY for MII or RGMII mode */
if (OF_getprop_alloc(node, "phy-mode", (void **)&phy_type)) { switch(sc->phy_mode) {
error = clk_get_by_ofw_name(dev, 0, "allwinner_gmac_tx", &clk_tx); case PHY_MODE_RGMII:
if (error != 0) { tx_parent_name = "gmac_int_tx";
device_printf(dev, "could not get tx clk\n"); break;
return (error); case PHY_MODE_MII:
} tx_parent_name = "mii_phy_tx";
break;
if (strcmp(phy_type, "rgmii") == 0) default:
tx_parent_name = "gmac_int_tx"; device_printf(dev, "unsupported PHY connection type: %d",
else sc->phy_mode);
tx_parent_name = "mii_phy_tx"; return (ENXIO);
}
error = clk_get_by_name(dev, tx_parent_name, &clk_tx_parent);
if (error != 0) {
device_printf(dev, "could not get clock '%s'\n",
tx_parent_name);
return (error);
}
error = clk_set_parent_by_clk(clk_tx, clk_tx_parent); error = clk_get_by_ofw_name(dev, 0, "allwinner_gmac_tx", &clk_tx);
if (error != 0) { if (error != 0) {
device_printf(dev, "could not set tx clk parent\n"); device_printf(dev, "could not get tx clk\n");
return (error); return (error);
} }
error = clk_get_by_name(dev, tx_parent_name, &clk_tx_parent);
if (error != 0) {
device_printf(dev, "could not get clock '%s'\n",
tx_parent_name);
return (error);
}
error = clk_set_parent_by_clk(clk_tx, clk_tx_parent);
if (error != 0) {
device_printf(dev, "could not set tx clk parent\n");
return (error);
} }
/* Enable PHY regulator if applicable */ /* Enable PHY regulator if applicable */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment