Commit 463120c3 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by Jakub Kicinski

net: stmmac: dwmac-qcom-ethqos: add support for SGMII

On sa8775p the MAC is connected to the external PHY over SGMII so add
support for it to the driver.
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 25c4a076
...@@ -75,6 +75,10 @@ ...@@ -75,6 +75,10 @@
#define RGMII_CONFIG2_DATA_DIVIDE_CLK_SEL BIT(6) #define RGMII_CONFIG2_DATA_DIVIDE_CLK_SEL BIT(6)
#define RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN BIT(5) #define RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN BIT(5)
/* MAC_CTRL_REG bits */
#define ETHQOS_MAC_CTRL_SPEED_MODE BIT(14)
#define ETHQOS_MAC_CTRL_PORT_SEL BIT(15)
struct ethqos_emac_por { struct ethqos_emac_por {
unsigned int offset; unsigned int offset;
unsigned int value; unsigned int value;
...@@ -92,6 +96,7 @@ struct ethqos_emac_driver_data { ...@@ -92,6 +96,7 @@ 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;
void __iomem *mac_base;
int (*configure_func)(struct qcom_ethqos *ethqos); int (*configure_func)(struct qcom_ethqos *ethqos);
unsigned int link_clk_rate; unsigned int link_clk_rate;
...@@ -559,6 +564,33 @@ static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos) ...@@ -559,6 +564,33 @@ static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos)
return 0; return 0;
} }
static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos)
{
int val;
val = readl(ethqos->mac_base + MAC_CTRL_REG);
switch (ethqos->speed) {
case SPEED_1000:
val &= ~ETHQOS_MAC_CTRL_PORT_SEL;
rgmii_updatel(ethqos, RGMII_CONFIG2_RGMII_CLK_SEL_CFG,
RGMII_CONFIG2_RGMII_CLK_SEL_CFG,
RGMII_IO_MACRO_CONFIG2);
break;
case SPEED_100:
val |= ETHQOS_MAC_CTRL_PORT_SEL | ETHQOS_MAC_CTRL_SPEED_MODE;
break;
case SPEED_10:
val |= ETHQOS_MAC_CTRL_PORT_SEL;
val &= ~ETHQOS_MAC_CTRL_SPEED_MODE;
break;
}
writel(val, ethqos->mac_base + MAC_CTRL_REG);
return val;
}
static int ethqos_configure(struct qcom_ethqos *ethqos) static int ethqos_configure(struct qcom_ethqos *ethqos)
{ {
return ethqos->configure_func(ethqos); return ethqos->configure_func(ethqos);
...@@ -663,6 +695,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ...@@ -663,6 +695,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
case PHY_INTERFACE_MODE_RGMII_TXID: case PHY_INTERFACE_MODE_RGMII_TXID:
ethqos->configure_func = ethqos_configure_rgmii; ethqos->configure_func = ethqos_configure_rgmii;
break; break;
case PHY_INTERFACE_MODE_SGMII:
ethqos->configure_func = ethqos_configure_sgmii;
break;
case -ENODEV: case -ENODEV:
ret = -ENODEV; ret = -ENODEV;
goto out_config_dt; goto out_config_dt;
...@@ -678,6 +713,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev) ...@@ -678,6 +713,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
goto out_config_dt; goto out_config_dt;
} }
ethqos->mac_base = stmmac_res.addr;
data = of_device_get_match_data(dev); data = of_device_get_match_data(dev);
ethqos->por = data->por; ethqos->por = data->por;
ethqos->num_por = data->num_por; ethqos->num_por = data->num_por;
......
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