Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: axienet: add support for standard phy-mode binding

Keep supporting proprietary "xlnx,phy-type" attribute and add support for
MII connectivity to the PHY.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Alvaro Gamez Machado <alvaro.gamez@hazent.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Alvaro G. M and committed by
David S. Miller
ee06b172 a2888551

+93 -14
+55
Documentation/devicetree/bindings/net/xilinx_axienet.txt
··· 1 + XILINX AXI ETHERNET Device Tree Bindings 2 + -------------------------------------------------------- 3 + 4 + Also called AXI 1G/2.5G Ethernet Subsystem, the xilinx axi ethernet IP core 5 + provides connectivity to an external ethernet PHY supporting different 6 + interfaces: MII, GMII, RGMII, SGMII, 1000BaseX. It also includes two 7 + segments of memory for buffering TX and RX, as well as the capability of 8 + offloading TX/RX checksum calculation off the processor. 9 + 10 + Management configuration is done through the AXI interface, while payload is 11 + sent and received through means of an AXI DMA controller. This driver 12 + includes the DMA driver code, so this driver is incompatible with AXI DMA 13 + driver. 14 + 15 + For more details about mdio please refer phy.txt file in the same directory. 16 + 17 + Required properties: 18 + - compatible : Must be one of "xlnx,axi-ethernet-1.00.a", 19 + "xlnx,axi-ethernet-1.01.a", "xlnx,axi-ethernet-2.01.a" 20 + - reg : Address and length of the IO space. 21 + - interrupts : Should be a list of two interrupt, TX and RX. 22 + - phy-handle : Should point to the external phy device. 23 + See ethernet.txt file in the same directory. 24 + - xlnx,rxmem : Set to allocated memory buffer for Rx/Tx in the hardware 25 + 26 + Optional properties: 27 + - phy-mode : See ethernet.txt 28 + - xlnx,phy-type : Deprecated, do not use, but still accepted in preference 29 + to phy-mode. 30 + - xlnx,txcsum : 0 or empty for disabling TX checksum offload, 31 + 1 to enable partial TX checksum offload, 32 + 2 to enable full TX checksum offload 33 + - xlnx,rxcsum : Same values as xlnx,txcsum but for RX checksum offload 34 + 35 + Example: 36 + axi_ethernet_eth: ethernet@40c00000 { 37 + compatible = "xlnx,axi-ethernet-1.00.a"; 38 + device_type = "network"; 39 + interrupt-parent = <&microblaze_0_axi_intc>; 40 + interrupts = <2 0>; 41 + phy-mode = "mii"; 42 + reg = <0x40c00000 0x40000>; 43 + xlnx,rxcsum = <0x2>; 44 + xlnx,rxmem = <0x800>; 45 + xlnx,txcsum = <0x2>; 46 + phy-handle = <&phy0>; 47 + axi_ethernetlite_0_mdio: mdio { 48 + #address-cells = <1>; 49 + #size-cells = <0>; 50 + phy0: phy@0 { 51 + device_type = "ethernet-phy"; 52 + reg = <1>; 53 + }; 54 + }; 55 + };
+2 -2
drivers/net/ethernet/xilinx/xilinx_axienet.h
··· 389 389 * @dma_err_tasklet: Tasklet structure to process Axi DMA errors 390 390 * @tx_irq: Axidma TX IRQ number 391 391 * @rx_irq: Axidma RX IRQ number 392 - * @phy_type: Phy type to identify between MII/GMII/RGMII/SGMII/1000 Base-X 392 + * @phy_mode: Phy type to identify between MII/GMII/RGMII/SGMII/1000 Base-X 393 393 * @options: AxiEthernet option word 394 394 * @last_link: Phy link state in which the PHY was negotiated earlier 395 395 * @features: Stores the extended features supported by the axienet hw ··· 432 432 433 433 int tx_irq; 434 434 int rx_irq; 435 - u32 phy_type; 435 + phy_interface_t phy_mode; 436 436 437 437 u32 options; /* Current options word */ 438 438 u32 last_link;
+36 -12
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
··· 531 531 link_state = phy->speed | (phy->duplex << 1) | phy->link; 532 532 if (lp->last_link != link_state) { 533 533 if ((phy->speed == SPEED_10) || (phy->speed == SPEED_100)) { 534 - if (lp->phy_type == XAE_PHY_TYPE_1000BASE_X) 534 + if (lp->phy_mode == PHY_INTERFACE_MODE_1000BASEX) 535 535 setspeed = 0; 536 536 } else { 537 537 if ((phy->speed == SPEED_1000) && 538 - (lp->phy_type == XAE_PHY_TYPE_MII)) 538 + (lp->phy_mode == PHY_INTERFACE_MODE_MII)) 539 539 setspeed = 0; 540 540 } 541 541 ··· 935 935 return ret; 936 936 937 937 if (lp->phy_node) { 938 - if (lp->phy_type == XAE_PHY_TYPE_GMII) { 939 - phydev = of_phy_connect(lp->ndev, lp->phy_node, 940 - axienet_adjust_link, 0, 941 - PHY_INTERFACE_MODE_GMII); 942 - } else if (lp->phy_type == XAE_PHY_TYPE_RGMII_2_0) { 943 - phydev = of_phy_connect(lp->ndev, lp->phy_node, 944 - axienet_adjust_link, 0, 945 - PHY_INTERFACE_MODE_RGMII_ID); 946 - } 938 + phydev = of_phy_connect(lp->ndev, lp->phy_node, 939 + axienet_adjust_link, 0, lp->phy_mode); 947 940 948 941 if (!phydev) 949 942 dev_err(lp->dev, "of_phy_connect() failed\n"); ··· 1532 1539 * the device-tree and accordingly set flags. 1533 1540 */ 1534 1541 of_property_read_u32(pdev->dev.of_node, "xlnx,rxmem", &lp->rxmem); 1535 - of_property_read_u32(pdev->dev.of_node, "xlnx,phy-type", &lp->phy_type); 1542 + 1543 + /* Start with the proprietary, and broken phy_type */ 1544 + ret = of_property_read_u32(pdev->dev.of_node, "xlnx,phy-type", &value); 1545 + if (!ret) { 1546 + netdev_warn(ndev, "Please upgrade your device tree binary blob to use phy-mode"); 1547 + switch (value) { 1548 + case XAE_PHY_TYPE_MII: 1549 + lp->phy_mode = PHY_INTERFACE_MODE_MII; 1550 + break; 1551 + case XAE_PHY_TYPE_GMII: 1552 + lp->phy_mode = PHY_INTERFACE_MODE_GMII; 1553 + break; 1554 + case XAE_PHY_TYPE_RGMII_2_0: 1555 + lp->phy_mode = PHY_INTERFACE_MODE_RGMII_ID; 1556 + break; 1557 + case XAE_PHY_TYPE_SGMII: 1558 + lp->phy_mode = PHY_INTERFACE_MODE_SGMII; 1559 + break; 1560 + case XAE_PHY_TYPE_1000BASE_X: 1561 + lp->phy_mode = PHY_INTERFACE_MODE_1000BASEX; 1562 + break; 1563 + default: 1564 + ret = -EINVAL; 1565 + goto free_netdev; 1566 + } 1567 + } else { 1568 + lp->phy_mode = of_get_phy_mode(pdev->dev.of_node); 1569 + if (lp->phy_mode < 0) { 1570 + ret = -EINVAL; 1571 + goto free_netdev; 1572 + } 1573 + } 1536 1574 1537 1575 /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */ 1538 1576 np = of_parse_phandle(pdev->dev.of_node, "axistream-connected", 0);