|
@@ -645,9 +645,11 @@ static int xgene_enet_create_desc_rings(struct net_device *ndev)
|
|
|
struct device *dev = ndev_to_dev(ndev);
|
|
|
struct xgene_enet_desc_ring *rx_ring, *tx_ring, *cp_ring;
|
|
|
struct xgene_enet_desc_ring *buf_pool = NULL;
|
|
|
- u8 cpu_bufnum = 0, eth_bufnum = START_ETH_BUFNUM;
|
|
|
- u8 bp_bufnum = START_BP_BUFNUM;
|
|
|
- u16 ring_id, ring_num = START_RING_NUM;
|
|
|
+ u8 cpu_bufnum = pdata->cpu_bufnum;
|
|
|
+ u8 eth_bufnum = pdata->eth_bufnum;
|
|
|
+ u8 bp_bufnum = pdata->bp_bufnum;
|
|
|
+ u16 ring_num = pdata->ring_num;
|
|
|
+ u16 ring_id;
|
|
|
int ret;
|
|
|
|
|
|
/* allocate rx descriptor ring */
|
|
@@ -752,6 +754,22 @@ static const struct net_device_ops xgene_ndev_ops = {
|
|
|
.ndo_set_mac_address = xgene_enet_set_mac_address,
|
|
|
};
|
|
|
|
|
|
+static int xgene_get_port_id(struct device *dev, struct xgene_enet_pdata *pdata)
|
|
|
+{
|
|
|
+ u32 id = 0;
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ ret = device_property_read_u32(dev, "port-id", &id);
|
|
|
+ if (!ret && id > 1) {
|
|
|
+ dev_err(dev, "Incorrect port-id specified\n");
|
|
|
+ return -ENODEV;
|
|
|
+ }
|
|
|
+
|
|
|
+ pdata->port_id = id;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
static int xgene_get_mac_address(struct device *dev,
|
|
|
unsigned char *addr)
|
|
|
{
|
|
@@ -843,6 +861,10 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
|
|
|
}
|
|
|
pdata->rx_irq = ret;
|
|
|
|
|
|
+ ret = xgene_get_port_id(dev, pdata);
|
|
|
+ if (ret)
|
|
|
+ return ret;
|
|
|
+
|
|
|
if (xgene_get_mac_address(dev, ndev->dev_addr) != ETH_ALEN)
|
|
|
eth_hw_addr_random(ndev);
|
|
|
|
|
@@ -866,13 +888,13 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
|
|
|
pdata->clk = NULL;
|
|
|
}
|
|
|
|
|
|
- base_addr = pdata->base_addr;
|
|
|
+ base_addr = pdata->base_addr - (pdata->port_id * MAC_OFFSET);
|
|
|
pdata->eth_csr_addr = base_addr + BLOCK_ETH_CSR_OFFSET;
|
|
|
pdata->eth_ring_if_addr = base_addr + BLOCK_ETH_RING_IF_OFFSET;
|
|
|
pdata->eth_diag_csr_addr = base_addr + BLOCK_ETH_DIAG_CSR_OFFSET;
|
|
|
if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII ||
|
|
|
pdata->phy_mode == PHY_INTERFACE_MODE_SGMII) {
|
|
|
- pdata->mcx_mac_addr = base_addr + BLOCK_ETH_MAC_OFFSET;
|
|
|
+ pdata->mcx_mac_addr = pdata->base_addr + BLOCK_ETH_MAC_OFFSET;
|
|
|
pdata->mcx_mac_csr_addr = base_addr + BLOCK_ETH_MAC_CSR_OFFSET;
|
|
|
} else {
|
|
|
pdata->mcx_mac_addr = base_addr + BLOCK_AXG_MAC_OFFSET;
|
|
@@ -935,6 +957,24 @@ static void xgene_enet_setup_ops(struct xgene_enet_pdata *pdata)
|
|
|
pdata->rm = RM0;
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
+ switch (pdata->port_id) {
|
|
|
+ case 0:
|
|
|
+ pdata->cpu_bufnum = START_CPU_BUFNUM_0;
|
|
|
+ pdata->eth_bufnum = START_ETH_BUFNUM_0;
|
|
|
+ pdata->bp_bufnum = START_BP_BUFNUM_0;
|
|
|
+ pdata->ring_num = START_RING_NUM_0;
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ pdata->cpu_bufnum = START_CPU_BUFNUM_1;
|
|
|
+ pdata->eth_bufnum = START_ETH_BUFNUM_1;
|
|
|
+ pdata->bp_bufnum = START_BP_BUFNUM_1;
|
|
|
+ pdata->ring_num = START_RING_NUM_1;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
static int xgene_enet_probe(struct platform_device *pdev)
|