Subject: Re: [net-next.git 4/8] stmmac: initial support to manage pcs modes

From: Giuseppe CAVALLARO <[email-masked]>
Date: Tue, 02 Apr 2013 14:29:02 +0200

Hello Byungho

On 3/30/2013 6:13 AM, Byungho An wrote:
> On 3/26/2013 11:46 PM, Giuseppe CAVALLARO wrote:
>> This patch adds the minimal support to manage the PCS
>> modes (RGMII/SGMII) and restart the ANE.
>> Both TBI and RTBI are not yet supported.
>>
> [snip]
> .
>>   /**
>>    * stmmac_init_phy - PHY initialization
>>    * @dev: net device structure
>> @@ -1141,10 +1159,13 @@ static int stmmac_open(struct net_device *dev)
>>
>>   	stmmac_check_ether_addr(priv);
>>
>> -	ret = stmmac_init_phy(dev);
>> -	if (unlikely(ret)) {
>> -		pr_err("%s: Cannot attach to PHY (error: %d)\n", __func__,
>> ret);
>> -		goto open_error;
>> +	if (!priv->pcs) {
>> +		ret = stmmac_init_phy(dev);
>> +		if (ret) {
>> +			pr_err("%s: Cannot attach to PHY (error: %d)\n",
>> +			       __func__, ret);
>> +			goto open_error;
>> +		}
>>   	}
>>
> I think, even though SGMII do auto-negotiation with phy, stmmac_init_phy
> function is needed. In this condition "if (!priv->pcs)", SGMII platform
> can't attach phy.
> IMO, it is same in case of stmmac_mdio_register(ndev).
> In my platform, I modified this condition for SGMII like below.
> 	if (priv->pcs != STMMAC_PCS_RGMII && priv->pcs STMMAC_PCS_TBI &&
> priv->pcs != STMMAC_PCS_RTBI)

pls can you send a patch for this on top of net-next branch (with me on Cc)?

Indeed for sgmii I expected to also manage ane w/o invoking the PAL.
As you know I have no SGMII hw where test; at any rate I will check 
again asap.

peppe

>
>>   	/* Create and initialize the TX/RX descriptors chains. */
>> @@ -1233,7 +1254,12 @@ static int stmmac_open(struct net_device *dev)
>>   		phy_start(priv->phydev);
>>
>>   	priv->tx_lpi_timer = STMMAC_DEFAULT_TWT_LS_TIMER;
>> -	priv->eee_enabled = stmmac_eee_init(priv);
>> +
>> +	/* Using PCS we cannot dial with the phy registers at this stage
>> +	 * so we do not support extra feature like EEE.
>> +	 */
>> +	if (!priv->pcs)
>> +		priv->eee_enabled = stmmac_eee_init(priv);
>>
>>   	stmmac_init_tx_coalesce(priv);
>>
>> @@ -1242,6 +1268,9 @@ static int stmmac_open(struct net_device *dev)
>>   		priv->hw->dma->rx_watchdog(priv->ioaddr, MAX_DMA_RIWT);
>>   	}
>>
>> +	if (priv->pcs && priv->hw->mac->ctrl_ane)
>> +		priv->hw->mac->ctrl_ane(priv->ioaddr, 0);
>> +
>>   	napi_enable(&priv->napi);
>>   	netif_start_queue(dev);
>>
>> @@ -2225,12 +2254,16 @@ struct stmmac_priv *stmmac_dvr_probe(struct device
>> *device,
>>   	else
>>   		priv->clk_csr = priv->plat->clk_csr;
>>
>> -	/* MDIO bus Registration */
>> -	ret = stmmac_mdio_register(ndev);
>> -	if (ret < 0) {
>> -		pr_debug("%s: MDIO bus (id: %d) registration failed",
>> -			 __func__, priv->plat->bus_id);
>> -		goto error_mdio_register;
>> +	stmmac_check_pcs_mode(priv);
>> +
>> +	if (!priv->pcs) {
>> +		/* MDIO bus Registration */
>> +		ret = stmmac_mdio_register(ndev);
>> +		if (ret < 0) {
>> +			pr_debug("%s: MDIO bus (id: %d) registration
> failed",
>> +				 __func__, priv->plat->bus_id);
>> +			goto error_mdio_register;
>> +		}
>>   	}
>>
>>   	return priv;
>> @@ -2263,7 +2296,8 @@ int stmmac_dvr_remove(struct net_device *ndev)
>>   	priv->hw->dma->stop_tx(priv->ioaddr);
>>
>>   	stmmac_set_mac(priv->ioaddr, false);
>> -	stmmac_mdio_unregister(ndev);
>> +	if (!priv->pcs)
>> +		stmmac_mdio_unregister(ndev);
>>   	netif_carrier_off(ndev);
>>   	unregister_netdev(ndev);
>>   	free_netdev(ndev);
>> --
>> 1.7.4.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>> the body of a message to [email-masked]
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>