@@ -344,8 +344,14 @@ static int dwmac1000_get_hw_feature(struct stmmac_priv *priv,
dma_cap->rx_coe_type2 = (hw_cap & DMA_HW_FEAT_RXTYP2COE) >> 18;
dma_cap->rxfifo_over_2048 = (hw_cap & DMA_HW_FEAT_RXFIFOSIZE) >> 19;
/* TX and RX number of channels */
- dma_cap->number_rx_channel = (hw_cap & DMA_HW_FEAT_RXCHCNT) >> 20;
- dma_cap->number_tx_channel = (hw_cap & DMA_HW_FEAT_TXCHCNT) >> 22;
+ if (priv->plat->fix_channel_num &&
+ ((hw_cap & (DMA_HW_FEAT_RXCHCNT | DMA_HW_FEAT_TXCHCNT)) >> 20) == 0) {
+ dma_cap->number_rx_channel = 8;
+ dma_cap->number_tx_channel = 8;
+ } else {
+ dma_cap->number_rx_channel = (hw_cap & DMA_HW_FEAT_RXCHCNT) >> 20;
+ dma_cap->number_tx_channel = (hw_cap & DMA_HW_FEAT_TXCHCNT) >> 22;
+ }
/* Alternate (enhanced) DESC mode */
dma_cap->enh_desc = (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24;
@@ -356,5 +356,6 @@ struct plat_stmmacenet_data {
const struct dwmac4_addrs *dwmac4_addrs;
bool has_integrated_pcs;
const struct dwmac_regs *dwmac_regs;
+ bool fix_channel_num;
};
#endif
Some Loongson platforms cannot obtain the TX and RX number of channels. Add the fix_channel_num flag for them and specify that the number of channels is 8. Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn> --- drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c | 10 ++++++++-- include/linux/stmmac.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-)