net: stmmac: starfive: use stmmac_get_phy_intf_sel()
Use stmmac_get_phy_intf_sel() to decode the PHY interface mode to the phy_intf_sel value, validate the result and use that to set the control register to select the operating mode for the DWMAC core. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Reviewed-by: Emil Renner Berthing <emil.renner.berthing@canonical.com> Link: https://patch.msgid.link/E1vIjUF-0000000Dqth-0gwD@rmk-PC.armlinux.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
f0917b4753
commit
d22045997b
@@ -15,8 +15,6 @@
|
||||
|
||||
#include "stmmac_platform.h"
|
||||
|
||||
#define STARFIVE_DWMAC_PHY_INFT_RGMII PHY_INTF_SEL_RGMII
|
||||
#define STARFIVE_DWMAC_PHY_INFT_RMII PHY_INTF_SEL_RMII
|
||||
#define STARFIVE_DWMAC_PHY_INFT_FIELD 0x7U
|
||||
|
||||
#define JH7100_SYSMAIN_REGISTER49_DLYCHAIN 0xc8
|
||||
@@ -35,25 +33,15 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
|
||||
struct starfive_dwmac *dwmac = plat_dat->bsp_priv;
|
||||
struct regmap *regmap;
|
||||
unsigned int args[2];
|
||||
unsigned int mode;
|
||||
int phy_intf_sel;
|
||||
int err;
|
||||
|
||||
switch (plat_dat->phy_interface) {
|
||||
case PHY_INTERFACE_MODE_RMII:
|
||||
mode = STARFIVE_DWMAC_PHY_INFT_RMII;
|
||||
break;
|
||||
|
||||
case PHY_INTERFACE_MODE_RGMII:
|
||||
case PHY_INTERFACE_MODE_RGMII_ID:
|
||||
case PHY_INTERFACE_MODE_RGMII_RXID:
|
||||
case PHY_INTERFACE_MODE_RGMII_TXID:
|
||||
mode = STARFIVE_DWMAC_PHY_INFT_RGMII;
|
||||
break;
|
||||
|
||||
default:
|
||||
phy_intf_sel = stmmac_get_phy_intf_sel(plat_dat->phy_interface);
|
||||
if (phy_intf_sel != PHY_INTF_SEL_RGMII &&
|
||||
phy_intf_sel != PHY_INTF_SEL_RMII) {
|
||||
dev_err(dwmac->dev, "unsupported interface %s\n",
|
||||
phy_modes(plat_dat->phy_interface));
|
||||
return -EINVAL;
|
||||
return phy_intf_sel < 0 ? phy_intf_sel : -EINVAL;
|
||||
}
|
||||
|
||||
regmap = syscon_regmap_lookup_by_phandle_args(dwmac->dev->of_node,
|
||||
@@ -65,7 +53,7 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
|
||||
/* args[0]:offset args[1]: shift */
|
||||
err = regmap_update_bits(regmap, args[0],
|
||||
STARFIVE_DWMAC_PHY_INFT_FIELD << args[1],
|
||||
mode << args[1]);
|
||||
phy_intf_sel << args[1]);
|
||||
if (err)
|
||||
return dev_err_probe(dwmac->dev, err, "error setting phy mode\n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user