1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2015 Broadcom Corporation
6 /* Broadcom Cygnus SoC internal transceivers support. */
7 #include "bcm-phy-lib.h"
8 #include <linux/brcmphy.h>
9 #include <linux/module.h>
10 #include <linux/netdevice.h>
11 #include <linux/phy.h>
13 /* Broadcom Cygnus Phy specific registers */
14 #define MII_BCM_CYGNUS_AFE_VDAC_ICTRL_0 0x91E5 /* VDAL Control register */
16 static int bcm_cygnus_afe_config(struct phy_device
*phydev
)
20 /* ensure smdspclk is enabled */
21 rc
= phy_write(phydev
, MII_BCM54XX_AUX_CTL
, 0x0c30);
25 /* AFE_VDAC_ICTRL_0 bit 7:4 Iq=1100 for 1g 10bt, normal modes */
26 rc
= bcm_phy_write_misc(phydev
, 0x39, 0x01, 0xA7C8);
30 /* AFE_HPF_TRIM_OTHERS bit11=1, short cascode enable for all modes*/
31 rc
= bcm_phy_write_misc(phydev
, 0x3A, 0x00, 0x0803);
35 /* AFE_TX_CONFIG_1 bit 7:4 Iq=1100 for test modes */
36 rc
= bcm_phy_write_misc(phydev
, 0x3A, 0x01, 0xA740);
40 /* AFE TEMPSEN_OTHERS rcal_HT, rcal_LT 10000 */
41 rc
= bcm_phy_write_misc(phydev
, 0x3A, 0x03, 0x8400);
45 /* AFE_FUTURE_RSV bit 2:0 rccal <2:0>=100 */
46 rc
= bcm_phy_write_misc(phydev
, 0x3B, 0x00, 0x0004);
50 /* Adjust bias current trim to overcome digital offSet */
51 rc
= phy_write(phydev
, MII_BRCM_CORE_BASE1E
, 0x02);
55 /* make rcal=100, since rdb default is 000 */
56 rc
= bcm_phy_write_exp_sel(phydev
, MII_BRCM_CORE_EXPB1
, 0x10);
60 /* CORE_EXPB0, Reset R_CAL/RC_CAL Engine */
61 rc
= bcm_phy_write_exp_sel(phydev
, MII_BRCM_CORE_EXPB0
, 0x10);
65 /* CORE_EXPB0, Disable Reset R_CAL/RC_CAL Engine */
66 rc
= bcm_phy_write_exp_sel(phydev
, MII_BRCM_CORE_EXPB0
, 0x00);
71 static int bcm_cygnus_config_init(struct phy_device
*phydev
)
75 reg
= phy_read(phydev
, MII_BCM54XX_ECR
);
79 /* Mask interrupts globally. */
80 reg
|= MII_BCM54XX_ECR_IM
;
81 rc
= phy_write(phydev
, MII_BCM54XX_ECR
, reg
);
85 /* Unmask events of interest */
86 reg
= ~(MII_BCM54XX_INT_DUPLEX
|
87 MII_BCM54XX_INT_SPEED
|
88 MII_BCM54XX_INT_LINK
);
89 rc
= phy_write(phydev
, MII_BCM54XX_IMR
, reg
);
93 /* Apply AFE settings for the PHY */
94 rc
= bcm_cygnus_afe_config(phydev
);
99 rc
= bcm_phy_set_eee(phydev
, true);
104 return bcm_phy_enable_apd(phydev
, false);
107 static int bcm_cygnus_resume(struct phy_device
*phydev
)
111 genphy_resume(phydev
);
113 /* Re-initialize the PHY to apply AFE work-arounds and
114 * configurations when coming out of suspend.
116 rc
= bcm_cygnus_config_init(phydev
);
120 /* restart auto negotiation with the new settings */
121 return genphy_config_aneg(phydev
);
124 static struct phy_driver bcm_cygnus_phy_driver
[] = {
126 .phy_id
= PHY_ID_BCM_CYGNUS
,
127 .phy_id_mask
= 0xfffffff0,
128 .name
= "Broadcom Cygnus PHY",
129 .features
= PHY_GBIT_FEATURES
,
130 .config_init
= bcm_cygnus_config_init
,
131 .ack_interrupt
= bcm_phy_ack_intr
,
132 .config_intr
= bcm_phy_config_intr
,
133 .suspend
= genphy_suspend
,
134 .resume
= bcm_cygnus_resume
,
137 static struct mdio_device_id __maybe_unused bcm_cygnus_phy_tbl
[] = {
138 { PHY_ID_BCM_CYGNUS
, 0xfffffff0, },
141 MODULE_DEVICE_TABLE(mdio
, bcm_cygnus_phy_tbl
);
143 module_phy_driver(bcm_cygnus_phy_driver
);
145 MODULE_DESCRIPTION("Broadcom Cygnus internal PHY driver");
146 MODULE_LICENSE("GPL v2");
147 MODULE_AUTHOR("Broadcom Corporation");