Skip to content

Commit 83e7b35

Browse files
Kwibookuba-moo
authored andcommitted
net: stmmac: dwmac-rk: Add initial support for RK3528 integrated PHY
Rockchip RK3528 (and RV1106) has a different integrated PHY compared to the integrated PHY on RK3228/RK3328. Current powerup/down operation is not compatible with the integrated PHY found in these newer SoCs. Add operations to powerup/down the integrated PHY found in RK3528. Use helpers that can be used by other GMAC variants in the future. Signed-off-by: Jonas Karlman <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 32c7bc0 commit 83e7b35

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,35 @@ static void rk_gmac_integrated_ephy_powerdown(struct rk_priv_data *priv)
134134
reset_control_assert(priv->phy_reset);
135135
}
136136

137+
#define RK_FEPHY_SHUTDOWN GRF_BIT(1)
138+
#define RK_FEPHY_POWERUP GRF_CLR_BIT(1)
139+
#define RK_FEPHY_INTERNAL_RMII_SEL GRF_BIT(6)
140+
#define RK_FEPHY_24M_CLK_SEL (GRF_BIT(8) | GRF_BIT(9))
141+
#define RK_FEPHY_PHY_ID GRF_BIT(11)
142+
143+
static void rk_gmac_integrated_fephy_powerup(struct rk_priv_data *priv,
144+
unsigned int reg)
145+
{
146+
reset_control_assert(priv->phy_reset);
147+
usleep_range(20, 30);
148+
149+
regmap_write(priv->grf, reg,
150+
RK_FEPHY_POWERUP |
151+
RK_FEPHY_INTERNAL_RMII_SEL |
152+
RK_FEPHY_24M_CLK_SEL |
153+
RK_FEPHY_PHY_ID);
154+
usleep_range(10000, 12000);
155+
156+
reset_control_deassert(priv->phy_reset);
157+
usleep_range(50000, 60000);
158+
}
159+
160+
static void rk_gmac_integrated_fephy_powerdown(struct rk_priv_data *priv,
161+
unsigned int reg)
162+
{
163+
regmap_write(priv->grf, reg, RK_FEPHY_SHUTDOWN);
164+
}
165+
137166
#define PX30_GRF_GMAC_CON1 0x0904
138167

139168
/* PX30_GRF_GMAC_CON1 */
@@ -993,12 +1022,24 @@ static void rk3528_set_clock_selection(struct rk_priv_data *bsp_priv,
9931022
}
9941023
}
9951024

1025+
static void rk3528_integrated_phy_powerup(struct rk_priv_data *bsp_priv)
1026+
{
1027+
rk_gmac_integrated_fephy_powerup(bsp_priv, RK3528_VO_GRF_MACPHY_CON0);
1028+
}
1029+
1030+
static void rk3528_integrated_phy_powerdown(struct rk_priv_data *bsp_priv)
1031+
{
1032+
rk_gmac_integrated_fephy_powerdown(bsp_priv, RK3528_VO_GRF_MACPHY_CON0);
1033+
}
1034+
9961035
static const struct rk_gmac_ops rk3528_ops = {
9971036
.set_to_rgmii = rk3528_set_to_rgmii,
9981037
.set_to_rmii = rk3528_set_to_rmii,
9991038
.set_rgmii_speed = rk3528_set_rgmii_speed,
10001039
.set_rmii_speed = rk3528_set_rmii_speed,
10011040
.set_clock_selection = rk3528_set_clock_selection,
1041+
.integrated_phy_powerup = rk3528_integrated_phy_powerup,
1042+
.integrated_phy_powerdown = rk3528_integrated_phy_powerdown,
10021043
.regs_valid = true,
10031044
.regs = {
10041045
0xffbd0000, /* gmac0 */

0 commit comments

Comments
 (0)