Commit eb38401c authored by Jose Abreu's avatar Jose Abreu Committed by David S. Miller

net: stmmac: Populate missing callbacks in HWIF initialization

Some HW specific setups, like sun8i, do not populate all the necessary
callbacks, which is what HWIF helpers were expecting.

Fix this by always trying to get the generic helpers and populate them
if they were not previously populated by HW specific setup.
Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
Fixes: 5f0456b4 ("net: stmmac: Implement logic to automatically
select HW Interface")
Reported-by: default avatarCorentin Labbe <clabbe.montjoie@gmail.com>
Tested-by: default avatarCorentin Labbe <clabbe.montjoie@gmail.com>
Cc: Corentin Labbe <clabbe.montjoie@gmail.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 80a95a80
...@@ -189,13 +189,16 @@ int stmmac_hwif_init(struct stmmac_priv *priv) ...@@ -189,13 +189,16 @@ int stmmac_hwif_init(struct stmmac_priv *priv)
bool needs_gmac = priv->plat->has_gmac; bool needs_gmac = priv->plat->has_gmac;
const struct stmmac_hwif_entry *entry; const struct stmmac_hwif_entry *entry;
struct mac_device_info *mac; struct mac_device_info *mac;
bool needs_setup = true;
int i, ret; int i, ret;
u32 id; u32 id;
if (needs_gmac) { if (needs_gmac) {
id = stmmac_get_id(priv, GMAC_VERSION); id = stmmac_get_id(priv, GMAC_VERSION);
} else { } else if (needs_gmac4) {
id = stmmac_get_id(priv, GMAC4_VERSION); id = stmmac_get_id(priv, GMAC4_VERSION);
} else {
id = 0;
} }
/* Save ID for later use */ /* Save ID for later use */
...@@ -209,13 +212,12 @@ int stmmac_hwif_init(struct stmmac_priv *priv) ...@@ -209,13 +212,12 @@ int stmmac_hwif_init(struct stmmac_priv *priv)
/* Check for HW specific setup first */ /* Check for HW specific setup first */
if (priv->plat->setup) { if (priv->plat->setup) {
priv->hw = priv->plat->setup(priv); mac = priv->plat->setup(priv);
if (!priv->hw) needs_setup = false;
return -ENOMEM; } else {
return 0; mac = devm_kzalloc(priv->device, sizeof(*mac), GFP_KERNEL);
} }
mac = devm_kzalloc(priv->device, sizeof(*mac), GFP_KERNEL);
if (!mac) if (!mac)
return -ENOMEM; return -ENOMEM;
...@@ -227,24 +229,28 @@ int stmmac_hwif_init(struct stmmac_priv *priv) ...@@ -227,24 +229,28 @@ int stmmac_hwif_init(struct stmmac_priv *priv)
continue; continue;
if (needs_gmac4 ^ entry->gmac4) if (needs_gmac4 ^ entry->gmac4)
continue; continue;
if (id < entry->min_id) /* Use synopsys_id var because some setups can override this */
if (priv->synopsys_id < entry->min_id)
continue; continue;
mac->desc = entry->desc; /* Only use generic HW helpers if needed */
mac->dma = entry->dma; mac->desc = mac->desc ? : entry->desc;
mac->mac = entry->mac; mac->dma = mac->dma ? : entry->dma;
mac->ptp = entry->hwtimestamp; mac->mac = mac->mac ? : entry->mac;
mac->mode = entry->mode; mac->ptp = mac->ptp ? : entry->hwtimestamp;
mac->tc = entry->tc; mac->mode = mac->mode ? : entry->mode;
mac->tc = mac->tc ? : entry->tc;
priv->hw = mac; priv->hw = mac;
priv->ptpaddr = priv->ioaddr + entry->regs.ptp_off; priv->ptpaddr = priv->ioaddr + entry->regs.ptp_off;
priv->mmcaddr = priv->ioaddr + entry->regs.mmc_off; priv->mmcaddr = priv->ioaddr + entry->regs.mmc_off;
/* Entry found */ /* Entry found */
ret = entry->setup(priv); if (needs_setup) {
if (ret) ret = entry->setup(priv);
return ret; if (ret)
return ret;
}
/* Run quirks, if needed */ /* Run quirks, if needed */
if (entry->quirks) { if (entry->quirks) {
......
Markdown is supported
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