Commit 23698a9a authored by Claudiu Beznea's avatar Claudiu Beznea Committed by Paolo Abeni

net: ravb: Move delay mode set in the driver's ndo_open API

Delay parsing and setting were done in the driver's probe API. As some IP
variants switch to reset mode (and thus the register contents is lost) when
setting clocks (due to module standby functionality) to be able to
implement runtime PM keep the delay parsing in the driver's probe function
and move the delay applying function to the driver's ndo_open API.

Along with it, ravb_parse_delay_mode() function was moved close to
ravb_set_delay_mode() function to have the delay specific code in the
same place.
Signed-off-by: default avatarClaudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: default avatarSergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent f384ab48
...@@ -1800,6 +1800,59 @@ static int ravb_compute_gti(struct net_device *ndev) ...@@ -1800,6 +1800,59 @@ static int ravb_compute_gti(struct net_device *ndev)
return 0; return 0;
} }
/* Set tx and rx clock internal delay modes */
static void ravb_parse_delay_mode(struct device_node *np, struct net_device *ndev)
{
struct ravb_private *priv = netdev_priv(ndev);
bool explicit_delay = false;
u32 delay;
if (!priv->info->internal_delay)
return;
if (!of_property_read_u32(np, "rx-internal-delay-ps", &delay)) {
/* Valid values are 0 and 1800, according to DT bindings */
priv->rxcidm = !!delay;
explicit_delay = true;
}
if (!of_property_read_u32(np, "tx-internal-delay-ps", &delay)) {
/* Valid values are 0 and 2000, according to DT bindings */
priv->txcidm = !!delay;
explicit_delay = true;
}
if (explicit_delay)
return;
/* Fall back to legacy rgmii-*id behavior */
if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
priv->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) {
priv->rxcidm = 1;
priv->rgmii_override = 1;
}
if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
priv->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) {
priv->txcidm = 1;
priv->rgmii_override = 1;
}
}
static void ravb_set_delay_mode(struct net_device *ndev)
{
struct ravb_private *priv = netdev_priv(ndev);
u32 set = 0;
if (!priv->info->internal_delay)
return;
if (priv->rxcidm)
set |= APSR_RDM;
if (priv->txcidm)
set |= APSR_TDM;
ravb_modify(ndev, APSR, APSR_RDM | APSR_TDM, set);
}
/* Network device open function for Ethernet AVB */ /* Network device open function for Ethernet AVB */
static int ravb_open(struct net_device *ndev) static int ravb_open(struct net_device *ndev)
{ {
...@@ -1811,6 +1864,8 @@ static int ravb_open(struct net_device *ndev) ...@@ -1811,6 +1864,8 @@ static int ravb_open(struct net_device *ndev)
if (info->nc_queues) if (info->nc_queues)
napi_enable(&priv->napi[RAVB_NC]); napi_enable(&priv->napi[RAVB_NC]);
ravb_set_delay_mode(ndev);
/* Device init */ /* Device init */
error = ravb_dmac_init(ndev); error = ravb_dmac_init(ndev);
if (error) if (error)
...@@ -2531,41 +2586,6 @@ static int ravb_set_config_mode(struct net_device *ndev) ...@@ -2531,41 +2586,6 @@ static int ravb_set_config_mode(struct net_device *ndev)
return error; return error;
} }
/* Set tx and rx clock internal delay modes */
static void ravb_parse_delay_mode(struct device_node *np, struct net_device *ndev)
{
struct ravb_private *priv = netdev_priv(ndev);
bool explicit_delay = false;
u32 delay;
if (!of_property_read_u32(np, "rx-internal-delay-ps", &delay)) {
/* Valid values are 0 and 1800, according to DT bindings */
priv->rxcidm = !!delay;
explicit_delay = true;
}
if (!of_property_read_u32(np, "tx-internal-delay-ps", &delay)) {
/* Valid values are 0 and 2000, according to DT bindings */
priv->txcidm = !!delay;
explicit_delay = true;
}
if (explicit_delay)
return;
/* Fall back to legacy rgmii-*id behavior */
if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
priv->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) {
priv->rxcidm = 1;
priv->rgmii_override = 1;
}
if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
priv->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) {
priv->txcidm = 1;
priv->rgmii_override = 1;
}
}
static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name, static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name,
const char *ch, int *irq, irq_handler_t handler) const char *ch, int *irq, irq_handler_t handler)
{ {
...@@ -2650,18 +2670,6 @@ static int ravb_setup_irqs(struct ravb_private *priv) ...@@ -2650,18 +2670,6 @@ static int ravb_setup_irqs(struct ravb_private *priv)
return ravb_setup_irq(priv, "ch19", "ch19:tx_nc", &irq, ravb_nc_interrupt); return ravb_setup_irq(priv, "ch19", "ch19:tx_nc", &irq, ravb_nc_interrupt);
} }
static void ravb_set_delay_mode(struct net_device *ndev)
{
struct ravb_private *priv = netdev_priv(ndev);
u32 set = 0;
if (priv->rxcidm)
set |= APSR_RDM;
if (priv->txcidm)
set |= APSR_TDM;
ravb_modify(ndev, APSR, APSR_RDM | APSR_TDM, set);
}
static int ravb_probe(struct platform_device *pdev) static int ravb_probe(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
...@@ -2785,10 +2793,7 @@ static int ravb_probe(struct platform_device *pdev) ...@@ -2785,10 +2793,7 @@ static int ravb_probe(struct platform_device *pdev)
if (error) if (error)
goto out_rpm_put; goto out_rpm_put;
if (info->internal_delay) { ravb_parse_delay_mode(np, ndev);
ravb_parse_delay_mode(np, ndev);
ravb_set_delay_mode(ndev);
}
/* Allocate descriptor base address table */ /* Allocate descriptor base address table */
priv->desc_bat_size = sizeof(struct ravb_desc) * DBAT_ENTRY_NUM; priv->desc_bat_size = sizeof(struct ravb_desc) * DBAT_ENTRY_NUM;
......
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