Skip to content

Commit 8dc84dc

Browse files
ffainellikuba-moo
authored andcommitted
net: phy: broadcom: Enable 10BaseT DAC early wake
Enable the DAC early wake when then link operates at 10BaseT allows power savings in the hundreds of milli Watts by shutting down the transmitter. A number of errata have been issued for various Gigabit PHYs and the recommendation is to enable both the early and forced DAC wake to be on the safe side. This needs to be done dynamically based upon the link state, which is why a link_change_notify callback is utilized. Signed-off-by: Florian Fainelli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 44ded7c commit 8dc84dc

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

drivers/net/phy/broadcom.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,36 @@ static void bcm54xx_get_stats(struct phy_device *phydev,
702702
bcm_phy_get_stats(phydev, priv->stats, stats, data);
703703
}
704704

705+
static void bcm54xx_link_change_notify(struct phy_device *phydev)
706+
{
707+
u16 mask = MII_BCM54XX_EXP_EXP08_EARLY_DAC_WAKE |
708+
MII_BCM54XX_EXP_EXP08_FORCE_DAC_WAKE;
709+
int ret;
710+
711+
if (phydev->state != PHY_RUNNING)
712+
return;
713+
714+
/* Don't change the DAC wake settings if auto power down
715+
* is not requested.
716+
*/
717+
if (!(phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
718+
return;
719+
720+
ret = bcm_phy_read_exp(phydev, MII_BCM54XX_EXP_EXP08);
721+
if (ret < 0)
722+
return;
723+
724+
/* Enable/disable 10BaseT auto and forced early DAC wake depending
725+
* on the negotiated speed, those settings should only be done
726+
* for 10Mbits/sec.
727+
*/
728+
if (phydev->speed == SPEED_10)
729+
ret |= mask;
730+
else
731+
ret &= ~mask;
732+
bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP08, ret);
733+
}
734+
705735
static struct phy_driver broadcom_drivers[] = {
706736
{
707737
.phy_id = PHY_ID_BCM5411,
@@ -715,6 +745,7 @@ static struct phy_driver broadcom_drivers[] = {
715745
.config_init = bcm54xx_config_init,
716746
.config_intr = bcm_phy_config_intr,
717747
.handle_interrupt = bcm_phy_handle_interrupt,
748+
.link_change_notify = bcm54xx_link_change_notify,
718749
}, {
719750
.phy_id = PHY_ID_BCM5421,
720751
.phy_id_mask = 0xfffffff0,
@@ -727,6 +758,7 @@ static struct phy_driver broadcom_drivers[] = {
727758
.config_init = bcm54xx_config_init,
728759
.config_intr = bcm_phy_config_intr,
729760
.handle_interrupt = bcm_phy_handle_interrupt,
761+
.link_change_notify = bcm54xx_link_change_notify,
730762
}, {
731763
.phy_id = PHY_ID_BCM54210E,
732764
.phy_id_mask = 0xfffffff0,
@@ -739,6 +771,7 @@ static struct phy_driver broadcom_drivers[] = {
739771
.config_init = bcm54xx_config_init,
740772
.config_intr = bcm_phy_config_intr,
741773
.handle_interrupt = bcm_phy_handle_interrupt,
774+
.link_change_notify = bcm54xx_link_change_notify,
742775
}, {
743776
.phy_id = PHY_ID_BCM5461,
744777
.phy_id_mask = 0xfffffff0,
@@ -751,6 +784,7 @@ static struct phy_driver broadcom_drivers[] = {
751784
.config_init = bcm54xx_config_init,
752785
.config_intr = bcm_phy_config_intr,
753786
.handle_interrupt = bcm_phy_handle_interrupt,
787+
.link_change_notify = bcm54xx_link_change_notify,
754788
}, {
755789
.phy_id = PHY_ID_BCM54612E,
756790
.phy_id_mask = 0xfffffff0,
@@ -763,6 +797,7 @@ static struct phy_driver broadcom_drivers[] = {
763797
.config_init = bcm54xx_config_init,
764798
.config_intr = bcm_phy_config_intr,
765799
.handle_interrupt = bcm_phy_handle_interrupt,
800+
.link_change_notify = bcm54xx_link_change_notify,
766801
}, {
767802
.phy_id = PHY_ID_BCM54616S,
768803
.phy_id_mask = 0xfffffff0,
@@ -774,6 +809,7 @@ static struct phy_driver broadcom_drivers[] = {
774809
.handle_interrupt = bcm_phy_handle_interrupt,
775810
.read_status = bcm54616s_read_status,
776811
.probe = bcm54616s_probe,
812+
.link_change_notify = bcm54xx_link_change_notify,
777813
}, {
778814
.phy_id = PHY_ID_BCM5464,
779815
.phy_id_mask = 0xfffffff0,
@@ -788,6 +824,7 @@ static struct phy_driver broadcom_drivers[] = {
788824
.handle_interrupt = bcm_phy_handle_interrupt,
789825
.suspend = genphy_suspend,
790826
.resume = genphy_resume,
827+
.link_change_notify = bcm54xx_link_change_notify,
791828
}, {
792829
.phy_id = PHY_ID_BCM5481,
793830
.phy_id_mask = 0xfffffff0,
@@ -801,6 +838,7 @@ static struct phy_driver broadcom_drivers[] = {
801838
.config_aneg = bcm5481_config_aneg,
802839
.config_intr = bcm_phy_config_intr,
803840
.handle_interrupt = bcm_phy_handle_interrupt,
841+
.link_change_notify = bcm54xx_link_change_notify,
804842
}, {
805843
.phy_id = PHY_ID_BCM54810,
806844
.phy_id_mask = 0xfffffff0,
@@ -816,6 +854,7 @@ static struct phy_driver broadcom_drivers[] = {
816854
.handle_interrupt = bcm_phy_handle_interrupt,
817855
.suspend = genphy_suspend,
818856
.resume = bcm54xx_resume,
857+
.link_change_notify = bcm54xx_link_change_notify,
819858
}, {
820859
.phy_id = PHY_ID_BCM54811,
821860
.phy_id_mask = 0xfffffff0,
@@ -831,6 +870,7 @@ static struct phy_driver broadcom_drivers[] = {
831870
.handle_interrupt = bcm_phy_handle_interrupt,
832871
.suspend = genphy_suspend,
833872
.resume = bcm54xx_resume,
873+
.link_change_notify = bcm54xx_link_change_notify,
834874
}, {
835875
.phy_id = PHY_ID_BCM5482,
836876
.phy_id_mask = 0xfffffff0,
@@ -843,6 +883,7 @@ static struct phy_driver broadcom_drivers[] = {
843883
.config_init = bcm54xx_config_init,
844884
.config_intr = bcm_phy_config_intr,
845885
.handle_interrupt = bcm_phy_handle_interrupt,
886+
.link_change_notify = bcm54xx_link_change_notify,
846887
}, {
847888
.phy_id = PHY_ID_BCM50610,
848889
.phy_id_mask = 0xfffffff0,
@@ -855,6 +896,7 @@ static struct phy_driver broadcom_drivers[] = {
855896
.config_init = bcm54xx_config_init,
856897
.config_intr = bcm_phy_config_intr,
857898
.handle_interrupt = bcm_phy_handle_interrupt,
899+
.link_change_notify = bcm54xx_link_change_notify,
858900
}, {
859901
.phy_id = PHY_ID_BCM50610M,
860902
.phy_id_mask = 0xfffffff0,
@@ -867,6 +909,7 @@ static struct phy_driver broadcom_drivers[] = {
867909
.config_init = bcm54xx_config_init,
868910
.config_intr = bcm_phy_config_intr,
869911
.handle_interrupt = bcm_phy_handle_interrupt,
912+
.link_change_notify = bcm54xx_link_change_notify,
870913
}, {
871914
.phy_id = PHY_ID_BCM57780,
872915
.phy_id_mask = 0xfffffff0,
@@ -879,6 +922,7 @@ static struct phy_driver broadcom_drivers[] = {
879922
.config_init = bcm54xx_config_init,
880923
.config_intr = bcm_phy_config_intr,
881924
.handle_interrupt = bcm_phy_handle_interrupt,
925+
.link_change_notify = bcm54xx_link_change_notify,
882926
}, {
883927
.phy_id = PHY_ID_BCMAC131,
884928
.phy_id_mask = 0xfffffff0,
@@ -905,6 +949,7 @@ static struct phy_driver broadcom_drivers[] = {
905949
.get_strings = bcm_phy_get_strings,
906950
.get_stats = bcm54xx_get_stats,
907951
.probe = bcm54xx_phy_probe,
952+
.link_change_notify = bcm54xx_link_change_notify,
908953
}, {
909954
.phy_id = PHY_ID_BCM53125,
910955
.phy_id_mask = 0xfffffff0,
@@ -918,6 +963,7 @@ static struct phy_driver broadcom_drivers[] = {
918963
.config_init = bcm54xx_config_init,
919964
.config_intr = bcm_phy_config_intr,
920965
.handle_interrupt = bcm_phy_handle_interrupt,
966+
.link_change_notify = bcm54xx_link_change_notify,
921967
}, {
922968
.phy_id = PHY_ID_BCM89610,
923969
.phy_id_mask = 0xfffffff0,
@@ -930,6 +976,7 @@ static struct phy_driver broadcom_drivers[] = {
930976
.config_init = bcm54xx_config_init,
931977
.config_intr = bcm_phy_config_intr,
932978
.handle_interrupt = bcm_phy_handle_interrupt,
979+
.link_change_notify = bcm54xx_link_change_notify,
933980
} };
934981

935982
module_phy_driver(broadcom_drivers);

include/linux/brcmphy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@
233233
#define MII_BCM54XX_EXP_EXP08 0x0F08
234234
#define MII_BCM54XX_EXP_EXP08_RJCT_2MHZ 0x0001
235235
#define MII_BCM54XX_EXP_EXP08_EARLY_DAC_WAKE 0x0200
236+
#define MII_BCM54XX_EXP_EXP08_FORCE_DAC_WAKE 0x0100
236237
#define MII_BCM54XX_EXP_EXP75 0x0f75
237238
#define MII_BCM54XX_EXP_EXP75_VDACCTRL 0x003c
238239
#define MII_BCM54XX_EXP_EXP75_CM_OSC 0x0001

0 commit comments

Comments
 (0)