diff options
author | Alvaro G. M <alvaro.gamez@hazent.com> | 2017-07-17 03:12:28 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-07-17 11:51:57 -0400 |
commit | ee06b1728b95643668e40fc58ae118aeb7c1753e (patch) | |
tree | d4864bc4af0c07c4996624982fceef6905e5d8fd | |
parent | a288855151546d1026c8f94728084c1173126a01 (diff) |
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>
-rw-r--r-- | Documentation/devicetree/bindings/net/xilinx_axienet.txt | 55 | ||||
-rw-r--r-- | drivers/net/ethernet/xilinx/xilinx_axienet.h | 4 | ||||
-rw-r--r-- | drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 48 |
3 files changed, 93 insertions, 14 deletions
diff --git a/Documentation/devicetree/bindings/net/xilinx_axienet.txt b/Documentation/devicetree/bindings/net/xilinx_axienet.txt new file mode 100644 index 000000000000..38f9ec076743 --- /dev/null +++ b/Documentation/devicetree/bindings/net/xilinx_axienet.txt | |||
@@ -0,0 +1,55 @@ | |||
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 = <µblaze_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 | }; | ||
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h index af27f7d1cbf3..5ef626331f85 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet.h +++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h | |||
@@ -389,7 +389,7 @@ struct axidma_bd { | |||
389 | * @dma_err_tasklet: Tasklet structure to process Axi DMA errors | 389 | * @dma_err_tasklet: Tasklet structure to process Axi DMA errors |
390 | * @tx_irq: Axidma TX IRQ number | 390 | * @tx_irq: Axidma TX IRQ number |
391 | * @rx_irq: Axidma RX IRQ number | 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 | * @options: AxiEthernet option word | 393 | * @options: AxiEthernet option word |
394 | * @last_link: Phy link state in which the PHY was negotiated earlier | 394 | * @last_link: Phy link state in which the PHY was negotiated earlier |
395 | * @features: Stores the extended features supported by the axienet hw | 395 | * @features: Stores the extended features supported by the axienet hw |
@@ -432,7 +432,7 @@ struct axienet_local { | |||
432 | 432 | ||
433 | int tx_irq; | 433 | int tx_irq; |
434 | int rx_irq; | 434 | int rx_irq; |
435 | u32 phy_type; | 435 | phy_interface_t phy_mode; |
436 | 436 | ||
437 | u32 options; /* Current options word */ | 437 | u32 options; /* Current options word */ |
438 | u32 last_link; | 438 | u32 last_link; |
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 33c595f4691d..e74e1e897864 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c | |||
@@ -531,11 +531,11 @@ static void axienet_adjust_link(struct net_device *ndev) | |||
531 | link_state = phy->speed | (phy->duplex << 1) | phy->link; | 531 | link_state = phy->speed | (phy->duplex << 1) | phy->link; |
532 | if (lp->last_link != link_state) { | 532 | if (lp->last_link != link_state) { |
533 | if ((phy->speed == SPEED_10) || (phy->speed == SPEED_100)) { | 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 | setspeed = 0; | 535 | setspeed = 0; |
536 | } else { | 536 | } else { |
537 | if ((phy->speed == SPEED_1000) && | 537 | if ((phy->speed == SPEED_1000) && |
538 | (lp->phy_type == XAE_PHY_TYPE_MII)) | 538 | (lp->phy_mode == PHY_INTERFACE_MODE_MII)) |
539 | setspeed = 0; | 539 | setspeed = 0; |
540 | } | 540 | } |
541 | 541 | ||
@@ -935,15 +935,8 @@ static int axienet_open(struct net_device *ndev) | |||
935 | return ret; | 935 | return ret; |
936 | 936 | ||
937 | if (lp->phy_node) { | 937 | if (lp->phy_node) { |
938 | if (lp->phy_type == XAE_PHY_TYPE_GMII) { | 938 | phydev = of_phy_connect(lp->ndev, lp->phy_node, |
939 | phydev = of_phy_connect(lp->ndev, lp->phy_node, | 939 | axienet_adjust_link, 0, lp->phy_mode); |
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 | } | ||
947 | 940 | ||
948 | if (!phydev) | 941 | if (!phydev) |
949 | dev_err(lp->dev, "of_phy_connect() failed\n"); | 942 | dev_err(lp->dev, "of_phy_connect() failed\n"); |
@@ -1539,7 +1532,38 @@ static int axienet_probe(struct platform_device *pdev) | |||
1539 | * the device-tree and accordingly set flags. | 1532 | * the device-tree and accordingly set flags. |
1540 | */ | 1533 | */ |
1541 | of_property_read_u32(pdev->dev.of_node, "xlnx,rxmem", &lp->rxmem); | 1534 | of_property_read_u32(pdev->dev.of_node, "xlnx,rxmem", &lp->rxmem); |
1542 | of_property_read_u32(pdev->dev.of_node, "xlnx,phy-type", &lp->phy_type); | 1535 | |
1536 | /* Start with the proprietary, and broken phy_type */ | ||
1537 | ret = of_property_read_u32(pdev->dev.of_node, "xlnx,phy-type", &value); | ||
1538 | if (!ret) { | ||
1539 | netdev_warn(ndev, "Please upgrade your device tree binary blob to use phy-mode"); | ||
1540 | switch (value) { | ||
1541 | case XAE_PHY_TYPE_MII: | ||
1542 | lp->phy_mode = PHY_INTERFACE_MODE_MII; | ||
1543 | break; | ||
1544 | case XAE_PHY_TYPE_GMII: | ||
1545 | lp->phy_mode = PHY_INTERFACE_MODE_GMII; | ||
1546 | break; | ||
1547 | case XAE_PHY_TYPE_RGMII_2_0: | ||
1548 | lp->phy_mode = PHY_INTERFACE_MODE_RGMII_ID; | ||
1549 | break; | ||
1550 | case XAE_PHY_TYPE_SGMII: | ||
1551 | lp->phy_mode = PHY_INTERFACE_MODE_SGMII; | ||
1552 | break; | ||
1553 | case XAE_PHY_TYPE_1000BASE_X: | ||
1554 | lp->phy_mode = PHY_INTERFACE_MODE_1000BASEX; | ||
1555 | break; | ||
1556 | default: | ||
1557 | ret = -EINVAL; | ||
1558 | goto free_netdev; | ||
1559 | } | ||
1560 | } else { | ||
1561 | lp->phy_mode = of_get_phy_mode(pdev->dev.of_node); | ||
1562 | if (lp->phy_mode < 0) { | ||
1563 | ret = -EINVAL; | ||
1564 | goto free_netdev; | ||
1565 | } | ||
1566 | } | ||
1543 | 1567 | ||
1544 | /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */ | 1568 | /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */ |
1545 | np = of_parse_phandle(pdev->dev.of_node, "axistream-connected", 0); | 1569 | np = of_parse_phandle(pdev->dev.of_node, "axistream-connected", 0); |