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

amd-xgbe: Support defining PHY resources in ETH device node

Simplify the device tree support of the amd-xgbe driver by defining
the PHY-related resources within the ethernet device node. The support
provides backwards compatibility with the original way.

Update the driver version to 1.0.2.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Lendacky, Thomas and committed by
David S. Miller
34bfff40 7c12aa08

+33 -41
+17 -32
Documentation/devicetree/bindings/net/amd-xgbe.txt
··· 1 1 * AMD 10GbE driver (amd-xgbe) 2 2 3 - Required properties (ethernet device): 3 + Required properties: 4 4 - compatible: Should be "amd,xgbe-seattle-v1a" 5 5 - reg: Address and length of the register sets for the device 6 6 - MAC registers 7 7 - PCS registers 8 + - SerDes Rx/Tx registers 9 + - SerDes integration registers (1/2) 10 + - SerDes integration registers (2/2) 8 11 - interrupt-parent: Should be the phandle for the interrupt controller 9 12 that services interrupts for this device 10 13 - interrupts: Should contain the amd-xgbe interrupt(s). The first interrupt 11 14 listed is required and is the general device interrupt. If the optional 12 15 amd,per-channel-interrupt property is specified, then one additional 13 - interrupt for each DMA channel supported by the device should be specified 16 + interrupt for each DMA channel supported by the device should be specified. 17 + The last interrupt listed should be the PCS auto-negotiation interrupt. 14 18 - clocks: 15 19 - DMA clock for the amd-xgbe device (used for calculating the 16 20 correct Rx interrupt watchdog timer value on a DMA channel ··· 23 19 - clock-names: Should be the names of the clocks 24 20 - "dma_clk" for the DMA clock 25 21 - "ptp_clk" for the PTP clock 26 - - phy-handle: See ethernet.txt file in the same directory 27 22 - phy-mode: See ethernet.txt file in the same directory 28 23 29 - Optional properties (ethernet device): 24 + Optional properties: 30 25 - mac-address: mac address to be assigned to the device. Can be overridden 31 26 by UEFI. 32 27 - dma-coherent: Present if dma operations are coherent 33 28 - amd,per-channel-interrupt: Indicates that Rx and Tx complete will generate 34 29 a unique interrupt for each DMA channel - this requires an additional 35 30 interrupt be configured for each DMA channel 36 - 37 - Required properties (phy device): 38 - - compatible: Should be "amd,xgbe-phy-seattle-v1a" 39 - - reg: Address and length of the register sets for the device 40 - - SerDes Rx/Tx registers 41 - - SerDes integration registers (1/2) 42 - - SerDes integration registers (2/2) 43 - - interrupt-parent: Should be the phandle for the interrupt controller 44 - that services interrupts for this device 45 - - interrupts: Should contain the amd-xgbe-phy interrupt. 46 - 47 - Optional properties (phy device): 48 31 - amd,speed-set: Speed capabilities of the device 49 32 0 - 1GbE and 10GbE (default) 50 33 1 - 2.5GbE and 10GbE ··· 54 63 xgbe@e0700000 { 55 64 compatible = "amd,xgbe-seattle-v1a"; 56 65 reg = <0 0xe0700000 0 0x80000>, 57 - <0 0xe0780000 0 0x80000>; 58 - interrupt-parent = <&gic>; 59 - interrupts = <0 325 4>, 60 - <0 326 1>, <0 327 1>, <0 328 1>, <0 329 1>; 61 - amd,per-channel-interrupt; 62 - clocks = <&xgbe_dma_clk>, <&xgbe_ptp_clk>; 63 - clock-names = "dma_clk", "ptp_clk"; 64 - phy-handle = <&xgbe_phy>; 65 - phy-mode = "xgmii"; 66 - mac-address = [ 02 a1 a2 a3 a4 a5 ]; 67 - }; 68 - 69 - xgbe_phy@e1240800 { 70 - compatible = "amd,xgbe-phy-seattle-v1a"; 71 - reg = <0 0xe1240800 0 0x00400>, 66 + <0 0xe0780000 0 0x80000>, 67 + <0 0xe1240800 0 0x00400>, 72 68 <0 0xe1250000 0 0x00060>, 73 69 <0 0xe1250080 0 0x00004>; 74 70 interrupt-parent = <&gic>; 75 - interrupts = <0 323 4>; 71 + interrupts = <0 325 4>, 72 + <0 326 1>, <0 327 1>, <0 328 1>, <0 329 1>, 73 + <0 323 4>; 74 + amd,per-channel-interrupt; 75 + clocks = <&xgbe_dma_clk>, <&xgbe_ptp_clk>; 76 + clock-names = "dma_clk", "ptp_clk"; 77 + phy-mode = "xgmii"; 78 + mac-address = [ 02 a1 a2 a3 a4 a5 ]; 76 79 amd,speed-set = <0>; 77 80 amd,serdes-blwc = <1>, <1>, <0>; 78 81 amd,serdes-cdr-rate = <2>, <2>, <7>;
+15 -8
drivers/net/ethernet/amd/xgbe/xgbe-main.c
··· 300 300 struct platform_device *phy_pdev; 301 301 302 302 phy_node = of_parse_phandle(dev->of_node, "phy-handle", 0); 303 - if (!phy_node) { 304 - dev_err(dev, "unable to locate phy device\n"); 305 - return NULL; 303 + if (phy_node) { 304 + /* Old style device tree: 305 + * The XGBE and PHY resources are separate 306 + */ 307 + phy_pdev = of_find_device_by_node(phy_node); 308 + of_node_put(phy_node); 309 + } else { 310 + /* New style device tree: 311 + * The XGBE and PHY resources are grouped together with 312 + * the PHY resources listed last 313 + */ 314 + get_device(dev); 315 + phy_pdev = pdata->pdev; 306 316 } 307 - 308 - phy_pdev = of_find_device_by_node(phy_node); 309 - of_node_put(phy_node); 310 317 311 318 return phy_pdev; 312 319 } ··· 408 401 phy_dev = &phy_pdev->dev; 409 402 410 403 if (pdev == phy_pdev) { 411 - /* ACPI: 404 + /* New style device tree or ACPI: 412 405 * The XGBE and PHY resources are grouped together with 413 406 * the PHY resources listed last 414 407 */ 415 408 phy_memnum = xgbe_resource_count(pdev, IORESOURCE_MEM) - 3; 416 409 phy_irqnum = xgbe_resource_count(pdev, IORESOURCE_IRQ) - 1; 417 410 } else { 418 - /* Device tree: 411 + /* Old style device tree: 419 412 * The XGBE and PHY resources are separate 420 413 */ 421 414 phy_memnum = 0;
+1 -1
drivers/net/ethernet/amd/xgbe/xgbe.h
··· 129 129 #include <net/dcbnl.h> 130 130 131 131 #define XGBE_DRV_NAME "amd-xgbe" 132 - #define XGBE_DRV_VERSION "1.0.1" 132 + #define XGBE_DRV_VERSION "1.0.2" 133 133 #define XGBE_DRV_DESC "AMD 10 Gigabit Ethernet Driver" 134 134 135 135 /* Descriptor related defines */