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

Merge branch 'net-systemport-Clock-support'

Florian Fainelli says:

====================
net: systemport: Clock support

This patch series makes the SYSTEMPORT driver request and manage its
main and Wake-on-LAN clocks appropriately.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+45 -2
+5
Documentation/devicetree/bindings/net/brcm,systemport.txt
··· 20 20 - systemport,num-tier1-arb: number of tier 1 arbiters, an integer 21 21 - systemport,num-txq: number of HW transmit queues, an integer 22 22 - systemport,num-rxq: number of HW receive queues, an integer 23 + - clocks: When provided, must be two phandles to the functional clocks nodes of 24 + the SYSTEMPORT block. The first phandle is the main SYSTEMPORT clock used 25 + during normal operation, while the second phandle is the Wake-on-LAN clock. 26 + - clock-names: When provided, names of the functional clock phandles, first 27 + name should be "sw_sysport" and second should be "sw_sysportwol". 23 28 24 29 Example: 25 30 ethernet@f04a0000 {
+38 -2
drivers/net/ethernet/broadcom/bcmsysport.c
··· 20 20 #include <linux/phy.h> 21 21 #include <linux/phy_fixed.h> 22 22 #include <net/dsa.h> 23 + #include <linux/clk.h> 23 24 #include <net/ip.h> 24 25 #include <net/ipv6.h> 25 26 ··· 187 186 netdev_features_t features) 188 187 { 189 188 struct bcm_sysport_priv *priv = netdev_priv(dev); 189 + int ret; 190 + 191 + ret = clk_prepare_enable(priv->clk); 192 + if (ret) 193 + return ret; 190 194 191 195 /* Read CRC forward */ 192 196 if (!priv->is_lite) ··· 202 196 203 197 bcm_sysport_set_rx_csum(dev, features); 204 198 bcm_sysport_set_tx_csum(dev, features); 199 + 200 + clk_disable_unprepare(priv->clk); 205 201 206 202 return 0; 207 203 } ··· 1948 1940 unsigned int i; 1949 1941 int ret; 1950 1942 1943 + clk_prepare_enable(priv->clk); 1944 + 1951 1945 /* Reset UniMAC */ 1952 1946 umac_reset(priv); 1953 1947 ··· 1980 1970 0, priv->phy_interface); 1981 1971 if (!phydev) { 1982 1972 netdev_err(dev, "could not attach to PHY\n"); 1983 - return -ENODEV; 1973 + ret = -ENODEV; 1974 + goto out_clk_disable; 1984 1975 } 1985 1976 1986 1977 /* Reset house keeping link status */ ··· 2059 2048 free_irq(priv->irq0, dev); 2060 2049 out_phy_disconnect: 2061 2050 phy_disconnect(phydev); 2051 + out_clk_disable: 2052 + clk_disable_unprepare(priv->clk); 2062 2053 return ret; 2063 2054 } 2064 2055 ··· 2118 2105 2119 2106 /* Disconnect from PHY */ 2120 2107 phy_disconnect(dev->phydev); 2108 + 2109 + clk_disable_unprepare(priv->clk); 2121 2110 2122 2111 return 0; 2123 2112 } ··· 2502 2487 /* Initialize private members */ 2503 2488 priv = netdev_priv(dev); 2504 2489 2490 + priv->clk = devm_clk_get_optional(&pdev->dev, "sw_sysport"); 2491 + if (IS_ERR(priv->clk)) 2492 + return PTR_ERR(priv->clk); 2493 + 2505 2494 /* Allocate number of TX rings */ 2506 2495 priv->tx_rings = devm_kcalloc(&pdev->dev, txq, 2507 2496 sizeof(struct bcm_sysport_tx_ring), ··· 2583 2564 if (!ret) 2584 2565 device_set_wakeup_capable(&pdev->dev, 1); 2585 2566 2567 + priv->wol_clk = devm_clk_get_optional(&pdev->dev, "sw_sysportwol"); 2568 + if (IS_ERR(priv->wol_clk)) 2569 + return PTR_ERR(priv->wol_clk); 2570 + 2586 2571 /* Set the needed headroom once and for all */ 2587 2572 BUILD_BUG_ON(sizeof(struct bcm_tsb) != 8); 2588 2573 dev->needed_headroom += sizeof(struct bcm_tsb); ··· 2611 2588 goto err_deregister_notifier; 2612 2589 } 2613 2590 2591 + clk_prepare_enable(priv->clk); 2592 + 2614 2593 priv->rev = topctrl_readl(priv, REV_CNTL) & REV_MASK; 2615 2594 dev_info(&pdev->dev, 2616 2595 "Broadcom SYSTEMPORT%s " REV_FMT ··· 2620 2595 priv->is_lite ? " Lite" : "", 2621 2596 (priv->rev >> 8) & 0xff, priv->rev & 0xff, 2622 2597 priv->irq0, priv->irq1, txq, rxq); 2598 + 2599 + clk_disable_unprepare(priv->clk); 2623 2600 2624 2601 return 0; 2625 2602 ··· 2776 2749 bcm_sysport_fini_rx_ring(priv); 2777 2750 2778 2751 /* Get prepared for Wake-on-LAN */ 2779 - if (device_may_wakeup(d) && priv->wolopts) 2752 + if (device_may_wakeup(d) && priv->wolopts) { 2753 + clk_prepare_enable(priv->wol_clk); 2780 2754 ret = bcm_sysport_suspend_to_wol(priv); 2755 + } 2756 + 2757 + clk_disable_unprepare(priv->clk); 2781 2758 2782 2759 return ret; 2783 2760 } ··· 2795 2764 2796 2765 if (!netif_running(dev)) 2797 2766 return 0; 2767 + 2768 + clk_prepare_enable(priv->clk); 2769 + if (priv->wolopts) 2770 + clk_disable_unprepare(priv->wol_clk); 2798 2771 2799 2772 umac_reset(priv); 2800 2773 ··· 2879 2844 out_free_tx_rings: 2880 2845 for (i = 0; i < dev->num_tx_queues; i++) 2881 2846 bcm_sysport_fini_tx_ring(priv, i); 2847 + clk_disable_unprepare(priv->clk); 2882 2848 return ret; 2883 2849 } 2884 2850
+2
drivers/net/ethernet/broadcom/bcmsysport.h
··· 770 770 u32 wolopts; 771 771 u8 sopass[SOPASS_MAX]; 772 772 unsigned int wol_irq_disabled:1; 773 + struct clk *clk; 774 + struct clk *wol_clk; 773 775 774 776 /* MIB related fields */ 775 777 struct bcm_sysport_mib mib;