From mboxrd@z Thu Jan 1 00:00:00 1970 From: Patrice CHOTARD Date: Thu, 30 Apr 2020 15:33:41 +0000 Subject: [PATCH 6/8] net: dwc_eth_qos: Split eqos_start() to get link speed In-Reply-To: <20200430104423.31014-1-david.wu@rock-chips.com> References: <20200430103656.29728-1-david.wu@rock-chips.com> <20200430104423.31014-1-david.wu@rock-chips.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi David On 4/30/20 12:44 PM, David Wu wrote: > Before enabling mac and mac working, we need to obtain > the current link speed to configure the clock, so split > eqos_start into two functions. > > Signed-off-by: David Wu > --- > > drivers/net/dwc_eth_qos.c | 56 ++++++++++++++++++++++++++------------- > 1 file changed, 38 insertions(+), 18 deletions(-) > > diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c > index b5d5156292..25b3449047 100644 > --- a/drivers/net/dwc_eth_qos.c > +++ b/drivers/net/dwc_eth_qos.c > @@ -1051,19 +1051,15 @@ static int eqos_write_hwaddr(struct udevice *dev) > return 0; > } > > -static int eqos_start(struct udevice *dev) > +static int eqos_init(struct udevice *dev) > { > struct eqos_priv *eqos = dev_get_priv(dev); > - int ret, i, limit; > + int ret, limit; > ulong rate; > - u32 val, tx_fifo_sz, rx_fifo_sz, tqs, rqs, pbl; > - ulong last_rx_desc; > + u32 val; > > debug("%s(dev=%p):\n", __func__, dev); > > - eqos->tx_desc_idx = 0; > - eqos->rx_desc_idx = 0; > - > ret = eqos->config->ops->eqos_start_clks(dev); > if (ret < 0) { > pr_err("eqos_start_clks() failed: %d", ret); > @@ -1151,6 +1147,30 @@ static int eqos_start(struct udevice *dev) > goto err_shutdown_phy; > } > > + debug("%s: OK\n", __func__); > + return 0; > + > +err_shutdown_phy: > + phy_shutdown(eqos->phy); > +err_stop_resets: > + eqos->config->ops->eqos_stop_resets(dev); > +err_stop_clks: > + eqos->config->ops->eqos_stop_clks(dev); > +err: > + pr_err("FAILED: %d", ret); > + return ret; > +} > + > +static void eqos_enable(struct udevice *dev) > +{ > + struct eqos_priv *eqos = dev_get_priv(dev); > + u32 val, tx_fifo_sz, rx_fifo_sz, tqs, rqs, pbl; > + ulong last_rx_desc; > + int i; > + > + eqos->tx_desc_idx = 0; > + eqos->rx_desc_idx = 0; > + > /* Configure MTL */ > > /* Enable Store and Forward mode for TX */ > @@ -1352,19 +1372,19 @@ static int eqos_start(struct udevice *dev) > writel(last_rx_desc, &eqos->dma_regs->ch0_rxdesc_tail_pointer); > > eqos->started = true; > +} > > - debug("%s: OK\n", __func__); > - return 0; > +static int eqos_start(struct udevice *dev) > +{ > + int ret; > > -err_shutdown_phy: > - phy_shutdown(eqos->phy); > -err_stop_resets: > - eqos->config->ops->eqos_stop_resets(dev); > -err_stop_clks: > - eqos->config->ops->eqos_stop_clks(dev); > -err: > - pr_err("FAILED: %d", ret); > - return ret; > + ret = eqos_init(dev); > + if (ret) > + return ret; > + > + eqos_enable(dev); > + > + return 0; Can you explain why you are splitting this function in 2 parts and calling these parts sequentially ? Please elaborate Thanks Patrice > } > > static void eqos_stop(struct udevice *dev)