static void macb_configure_caps(struct macb *bp,
const struct macb_config *dt_conf)
{
- struct device_node *np = bp->pdev->dev.of_node;
- bool refclk_ext;
u32 dcfg;
- refclk_ext = of_property_read_bool(np, "cdns,refclk-ext");
-
if (dt_conf)
bp->caps = dt_conf->caps;
}
}
- if (refclk_ext)
- bp->caps |= MACB_CAPS_USRIO_HAS_REFCLK_SOURCE;
-
dev_dbg(&bp->pdev->dev, "Cadence caps 0x%08x\n", bp->caps);
}
if (bp->caps & MACB_CAPS_USRIO_HAS_CLKEN)
val |= bp->usrio->clken;
- if (bp->caps & MACB_CAPS_USRIO_HAS_REFCLK_SOURCE)
- val |= bp->usrio->refclk;
+ if (bp->caps & MACB_CAPS_USRIO_HAS_REFCLK_SOURCE) {
+ const char *prop;
+ bool refclk_ext;
+ int ret;
+
+ /* Default to whatever was set in the match data for
+ * this device. There's two properties for refclk
+ * control, but the boolean one is deprecated so is
+ * a lower priority to check, no device should have
+ * both.
+ */
+ refclk_ext = bp->usrio->refclk_default_external;
+
+ ret = of_property_read_string(pdev->dev.of_node,
+ "cdns,refclk-source", &prop);
+ if (!ret) {
+ if (!strcmp(prop, "external"))
+ refclk_ext = true;
+ else
+ refclk_ext = false;
+ } else {
+ ret = of_property_read_bool(pdev->dev.of_node,
+ "cdns,refclk-ext");
+ if (ret)
+ refclk_ext = true;
+ }
+
+ if (refclk_ext)
+ val |= bp->usrio->refclk;
+ }
macb_or_gem_writel(bp, USRIO, val);
}
.clken = MACB_BIT(CLKEN),
};
-static const struct macb_usrio_config sama7g5_usrio = {
+static const struct macb_usrio_config sama7g5_gem_usrio = {
+ .mii = 0,
+ .rmii = 1,
+ .rgmii = 2,
+ .refclk = BIT(2),
+ .refclk_default_external = false,
+ .hdfctlen = BIT(6),
+};
+
+static const struct macb_usrio_config sama7g5_emac_usrio = {
.mii = 0,
.rmii = 1,
.rgmii = 2,
.refclk = BIT(2),
+ .refclk_default_external = true,
.hdfctlen = BIT(6),
};
MACB_CAPS_MIIONRGMII | MACB_CAPS_GEM_HAS_PTP |
MACB_CAPS_USRIO_HAS_MII,
.dma_burst_length = 16,
- .usrio = &sama7g5_usrio,
+ .usrio = &sama7g5_gem_usrio,
};
static const struct macb_config sama7g5_emac_config = {
MACB_CAPS_GEM_HAS_PTP |
MACB_CAPS_USRIO_HAS_MII,
.dma_burst_length = 16,
- .usrio = &sama7g5_usrio,
+ .usrio = &sama7g5_emac_usrio,
};
static const struct macb_config versal_config = {