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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-stmmac-qcom-ethqos-simplifications'

Russell King says:

====================
net: stmmac: qcom-ethqos: simplifications

Remove unnecessary code from the qcom-ethqos glue driver.

Start by consistently using -> serdes_speed to set the speed of the
serdes PHY rather than sometimes using ->serdes_speed and sometimes
using ->speed.

This then allows the removal of ->speed in the second patch.

There is no need to set the maximum speed just because we're using
2500BASE-X - phylink already knows that 2500BASE-X can't support
faster speeds.

This then makes qcom_ethqos_speed_mode_2500() redundant as it's
setting the interface mode to the value that was determined in the
switch statement that already determined that the interface mode
had this value.

Not tested on hardware.
====================

Link: https://patch.msgid.link/Z_p0LzY2_HFupWK0@shell.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+15 -28
+15 -28
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
··· 106 106 struct platform_device *pdev; 107 107 void __iomem *rgmii_base; 108 108 void __iomem *mac_base; 109 - int (*configure_func)(struct qcom_ethqos *ethqos); 109 + int (*configure_func)(struct qcom_ethqos *ethqos, int speed); 110 110 111 111 unsigned int link_clk_rate; 112 112 struct clk *link_clk; 113 113 struct phy *serdes_phy; 114 - int speed; 115 114 int serdes_speed; 116 115 phy_interface_t phy_mode; 117 116 ··· 384 385 return 0; 385 386 } 386 387 387 - static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos) 388 + static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos, int speed) 388 389 { 389 390 struct device *dev = &ethqos->pdev->dev; 390 391 int phase_shift; ··· 411 412 rgmii_updatel(ethqos, RGMII_CONFIG_INTF_SEL, 412 413 0, RGMII_IO_MACRO_CONFIG); 413 414 414 - switch (ethqos->speed) { 415 + switch (speed) { 415 416 case SPEED_1000: 416 417 rgmii_updatel(ethqos, RGMII_CONFIG_DDR_MODE, 417 418 RGMII_CONFIG_DDR_MODE, RGMII_IO_MACRO_CONFIG); ··· 531 532 loopback, RGMII_IO_MACRO_CONFIG); 532 533 break; 533 534 default: 534 - dev_err(dev, "Invalid speed %d\n", ethqos->speed); 535 + dev_err(dev, "Invalid speed %d\n", speed); 535 536 return -EINVAL; 536 537 } 537 538 538 539 return 0; 539 540 } 540 541 541 - static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos) 542 + static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos, int speed) 542 543 { 543 544 struct device *dev = &ethqos->pdev->dev; 544 545 volatile unsigned int dll_lock; ··· 561 562 SDCC_DLL_CONFIG_PDN, SDCC_HC_REG_DLL_CONFIG); 562 563 563 564 if (ethqos->has_emac_ge_3) { 564 - if (ethqos->speed == SPEED_1000) { 565 + if (speed == SPEED_1000) { 565 566 rgmii_writel(ethqos, 0x1800000, SDCC_TEST_CTL); 566 567 rgmii_writel(ethqos, 0x2C010800, SDCC_USR_CTL); 567 568 rgmii_writel(ethqos, 0xA001, SDCC_HC_REG_DLL_CONFIG2); ··· 579 580 rgmii_updatel(ethqos, SDCC_DLL_CONFIG_PDN, 0, 580 581 SDCC_HC_REG_DLL_CONFIG); 581 582 582 - if (ethqos->speed != SPEED_100 && ethqos->speed != SPEED_10) { 583 + if (speed != SPEED_100 && speed != SPEED_10) { 583 584 /* Set DLL_EN */ 584 585 rgmii_updatel(ethqos, SDCC_DLL_CONFIG_DLL_EN, 585 586 SDCC_DLL_CONFIG_DLL_EN, SDCC_HC_REG_DLL_CONFIG); ··· 606 607 dev_err(dev, "Timeout while waiting for DLL lock\n"); 607 608 } 608 609 609 - if (ethqos->speed == SPEED_1000) 610 + if (speed == SPEED_1000) 610 611 ethqos_dll_configure(ethqos); 611 612 612 - ethqos_rgmii_macro_init(ethqos); 613 + ethqos_rgmii_macro_init(ethqos, speed); 613 614 614 615 return 0; 615 616 } ··· 625 626 /* On interface toggle MAC registers gets reset. 626 627 * Configure MAC block for SGMII on ethernet phy link up 627 628 */ 628 - static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) 629 + static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos, int speed) 629 630 { 630 631 struct net_device *dev = platform_get_drvdata(ethqos->pdev); 631 632 struct stmmac_priv *priv = netdev_priv(dev); ··· 633 634 634 635 val = readl(ethqos->mac_base + MAC_CTRL_REG); 635 636 636 - switch (ethqos->speed) { 637 + switch (speed) { 637 638 case SPEED_2500: 638 639 val &= ~ETHQOS_MAC_CTRL_PORT_SEL; 639 640 rgmii_updatel(ethqos, RGMII_CONFIG2_RGMII_CLK_SEL_CFG, ··· 672 673 return val; 673 674 } 674 675 675 - static void qcom_ethqos_speed_mode_2500(struct net_device *ndev, void *data) 676 + static int ethqos_configure(struct qcom_ethqos *ethqos, int speed) 676 677 { 677 - struct stmmac_priv *priv = netdev_priv(ndev); 678 - 679 - priv->plat->max_speed = 2500; 680 - priv->plat->phy_interface = PHY_INTERFACE_MODE_2500BASEX; 681 - } 682 - 683 - static int ethqos_configure(struct qcom_ethqos *ethqos) 684 - { 685 - return ethqos->configure_func(ethqos); 678 + return ethqos->configure_func(ethqos, speed); 686 679 } 687 680 688 681 static void ethqos_fix_mac_speed(void *priv, int speed, unsigned int mode) ··· 682 691 struct qcom_ethqos *ethqos = priv; 683 692 684 693 qcom_ethqos_set_sgmii_loopback(ethqos, false); 685 - ethqos->speed = speed; 686 694 ethqos_update_link_clk(ethqos, speed); 687 - ethqos_configure(ethqos); 695 + ethqos_configure(ethqos, speed); 688 696 } 689 697 690 698 static int qcom_ethqos_serdes_powerup(struct net_device *ndev, void *priv) ··· 699 709 if (ret) 700 710 return ret; 701 711 702 - return phy_set_speed(ethqos->serdes_phy, ethqos->speed); 712 + return phy_set_speed(ethqos->serdes_phy, ethqos->serdes_speed); 703 713 } 704 714 705 715 static void qcom_ethqos_serdes_powerdown(struct net_device *ndev, void *priv) ··· 793 803 ethqos->configure_func = ethqos_configure_rgmii; 794 804 break; 795 805 case PHY_INTERFACE_MODE_2500BASEX: 796 - plat_dat->speed_mode_2500 = qcom_ethqos_speed_mode_2500; 797 - fallthrough; 798 806 case PHY_INTERFACE_MODE_SGMII: 799 807 ethqos->configure_func = ethqos_configure_sgmii; 800 808 break; ··· 835 847 return dev_err_probe(dev, PTR_ERR(ethqos->serdes_phy), 836 848 "Failed to get serdes phy\n"); 837 849 838 - ethqos->speed = SPEED_1000; 839 850 ethqos->serdes_speed = SPEED_1000; 840 851 ethqos_update_link_clk(ethqos, SPEED_1000); 841 852 ethqos_set_func_clk_en(ethqos);