Commit 25c4a076 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by Jakub Kicinski

net: stmmac: dwmac-qcom-ethqos: prepare the driver for more PHY modes

In preparation for supporting SGMII, let's make the code a bit more
generic. Add a new callback for MAC configuration so that we can assign
a different variant of it in the future.
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: default avatarAndrew Halaney <ahalaney@redhat.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent feeb2716
...@@ -92,11 +92,13 @@ struct ethqos_emac_driver_data { ...@@ -92,11 +92,13 @@ struct ethqos_emac_driver_data {
struct qcom_ethqos { struct qcom_ethqos {
struct platform_device *pdev; struct platform_device *pdev;
void __iomem *rgmii_base; void __iomem *rgmii_base;
int (*configure_func)(struct qcom_ethqos *ethqos);
unsigned int link_clk_rate; unsigned int link_clk_rate;
struct clk *link_clk; struct clk *link_clk;
struct phy *serdes_phy; struct phy *serdes_phy;
unsigned int speed; unsigned int speed;
int phy_mode;
const struct ethqos_emac_por *por; const struct ethqos_emac_por *por;
unsigned int num_por; unsigned int num_por;
...@@ -331,13 +333,11 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos) ...@@ -331,13 +333,11 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos)
{ {
struct device *dev = &ethqos->pdev->dev; struct device *dev = &ethqos->pdev->dev;
int phase_shift; int phase_shift;
int phy_mode;
int loopback; int loopback;
/* Determine if the PHY adds a 2 ns TX delay or the MAC handles it */ /* Determine if the PHY adds a 2 ns TX delay or the MAC handles it */
phy_mode = device_get_phy_mode(dev); if (ethqos->phy_mode == PHY_INTERFACE_MODE_RGMII_ID ||
if (phy_mode == PHY_INTERFACE_MODE_RGMII_ID || ethqos->phy_mode == PHY_INTERFACE_MODE_RGMII_TXID)
phy_mode == PHY_INTERFACE_MODE_RGMII_TXID)
phase_shift = 0; phase_shift = 0;
else else
phase_shift = RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN; phase_shift = RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN;
...@@ -483,7 +483,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos) ...@@ -483,7 +483,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos)
return 0; return 0;
} }
static int ethqos_configure(struct qcom_ethqos *ethqos) static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos)
{ {
struct device *dev = &ethqos->pdev->dev; struct device *dev = &ethqos->pdev->dev;
volatile unsigned int dll_lock; volatile unsigned int dll_lock;
...@@ -559,6 +559,11 @@ static int ethqos_configure(struct qcom_ethqos *ethqos) ...@@ -559,6 +559,11 @@ static int ethqos_configure(struct qcom_ethqos *ethqos)
return 0; return 0;
} }
static int ethqos_configure(struct qcom_ethqos *ethqos)
{
return ethqos->configure_func(ethqos);
}
static void ethqos_fix_mac_speed(void *priv, unsigned int speed) static void ethqos_fix_mac_speed(void *priv, unsigned int speed)
{ {
struct qcom_ethqos *ethqos = priv; struct qcom_ethqos *ethqos = priv;
...@@ -650,6 +655,22 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ...@@ -650,6 +655,22 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
goto out_config_dt; goto out_config_dt;
} }
ethqos->phy_mode = device_get_phy_mode(dev);
switch (ethqos->phy_mode) {
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII_RXID:
case PHY_INTERFACE_MODE_RGMII_TXID:
ethqos->configure_func = ethqos_configure_rgmii;
break;
case -ENODEV:
ret = -ENODEV;
goto out_config_dt;
default:
ret = -EINVAL;
goto out_config_dt;
}
ethqos->pdev = pdev; ethqos->pdev = pdev;
ethqos->rgmii_base = devm_platform_ioremap_resource_byname(pdev, "rgmii"); ethqos->rgmii_base = devm_platform_ioremap_resource_byname(pdev, "rgmii");
if (IS_ERR(ethqos->rgmii_base)) { if (IS_ERR(ethqos->rgmii_base)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment