public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/6] net: asix: split out basic reset function
Date: Wed, 22 Aug 2012 20:23:51 +0200	[thread overview]
Message-ID: <201208222023.51441.marex@denx.de> (raw)
In-Reply-To: <1345630147-14465-4-git-send-email-dev@lynxeye.de>

Dear Lucas Stach,

> The basic device reset ensures that the device is ready to
> service commands and does not need to get redone before each
> network operation.
> 
> Split out the basic reset from asix_init() and instead call it
> from asix_eth_get_info(), so that it only gets called once.
> 
> Signed-off-by: Lucas Stach <dev@lynxeye.de>
> ---
>  drivers/usb/eth/asix.c | 44 ++++++++++++++++++++++++++------------------
>  1 Datei ge?ndert, 26 Zeilen hinzugef?gt(+), 18 Zeilen entfernt(-)
> 
> diff --git a/drivers/usb/eth/asix.c b/drivers/usb/eth/asix.c
> index 8fb7fc8..50cbbbd 100644
> --- a/drivers/usb/eth/asix.c
> +++ b/drivers/usb/eth/asix.c
> @@ -310,55 +310,60 @@ static int mii_nway_restart(struct ueth_data *dev)
>  	return r;
>  }
> 
> -/*
> - * Asix callbacks
> - */
> -static int asix_init(struct eth_device *eth, bd_t *bd)
> +static int asix_basic_reset(struct ueth_data *dev)
>  {
>  	int embd_phy;
> -	ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buf, ETH_ALEN);
>  	u16 rx_ctl;
> -	struct ueth_data	*dev = (struct ueth_data *)eth->priv;
> -	int timeout = 0;
> -#define TIMEOUT_RESOLUTION 50	/* ms */
> -	int link_detected;
> -
> -	debug("** %s()\n", __func__);
> 
>  	if (asix_write_gpio(dev,
>  			AX_GPIO_RSE | AX_GPIO_GPO_2 | AX_GPIO_GPO2EN, 5) < 0)
> -		goto out_err;
> +		return -1;

You might want to use proper errno.h here ... like -ETIMEDOUT etc.

> 
>  	/* 0x10 is the phy id of the embedded 10/100 ethernet phy */
>  	embd_phy = ((asix_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0);
>  	if (asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT,
>  				embd_phy, 0, 0, NULL) < 0) {
>  		debug("Select PHY #1 failed\n");
> -		goto out_err;
> +		return -1;
>  	}
> 
>  	if (asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL) < 0)
> -		goto out_err;
> +		return -1;
> 
>  	if (asix_sw_reset(dev, AX_SWRESET_CLEAR) < 0)
> -		goto out_err;
> +		return -1;
> 
>  	if (embd_phy) {
>  		if (asix_sw_reset(dev, AX_SWRESET_IPRL) < 0)
> -			goto out_err;
> +			return -1;
>  	} else {
>  		if (asix_sw_reset(dev, AX_SWRESET_PRTE) < 0)
> -			goto out_err;
> +			return -1;
>  	}
> 
>  	rx_ctl = asix_read_rx_ctl(dev);
>  	debug("RX_CTL is 0x%04x after software reset\n", rx_ctl);
>  	if (asix_write_rx_ctl(dev, 0x0000) < 0)
> -		goto out_err;
> +		return -1;
> 
>  	rx_ctl = asix_read_rx_ctl(dev);
>  	debug("RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl);
> 
> +	return 0;
> +}
> +
> +/*
> + * Asix callbacks
> + */
> +static int asix_init(struct eth_device *eth, bd_t *bd)
> +{
> +	struct ueth_data	*dev = (struct ueth_data *)eth->priv;
> +	int timeout = 0;
> +#define TIMEOUT_RESOLUTION 50	/* ms */
> +	int link_detected;
> +
> +	debug("** %s()\n", __func__);
> +
>  	/* Get the MAC address */
>  	if (asix_read_cmd(dev, AX_CMD_READ_NODE_ID,
>  				0, 0, ETH_ALEN, buf) < 0) {
> @@ -635,5 +640,8 @@ int asix_eth_get_info(struct usb_device *dev, struct
> ueth_data *ss, eth->halt = asix_halt;
>  	eth->priv = ss;
> 
> +	if (asix_basic_reset(ss))
> +		return 0;
> +
>  	return 1;
>  }

Best regards,
Marek Vasut

  reply	other threads:[~2012-08-22 18:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-22 10:09 [U-Boot] [PATCH 0/6] net: ASIX AX88772B enablement Lucas Stach
2012-08-22 10:09 ` [U-Boot] [PATCH 1/6] net: introduce transparent driver private in ueth_data Lucas Stach
2012-08-22 18:21   ` Marek Vasut
2012-08-22 18:49   ` Joe Hershberger
2012-08-22 10:09 ` [U-Boot] [PATCH 2/6] net: usbeth: remove misleading warning Lucas Stach
2012-08-22 18:22   ` Marek Vasut
2012-08-22 18:32     ` Lucas Stach
2012-08-22 18:46       ` Joe Hershberger
2012-08-22 10:09 ` [U-Boot] [PATCH 3/6] net: asix: split out basic reset function Lucas Stach
2012-08-22 18:23   ` Marek Vasut [this message]
2012-08-22 18:52   ` Joe Hershberger
2012-08-23  3:01   ` Mike Frysinger
2012-08-23  8:37     ` Lucas Stach
2012-08-22 10:09 ` [U-Boot] [PATCH 4/6] net: asix: add write_hwaddr function Lucas Stach
2012-08-22 18:25   ` Marek Vasut
2012-08-22 19:04   ` Joe Hershberger
2012-08-22 10:09 ` [U-Boot] [PATCH 5/6] net: asix: add read_mac function Lucas Stach
2012-08-22 18:26   ` Marek Vasut
2012-08-22 18:59   ` Joe Hershberger
2012-08-22 10:09 ` [U-Boot] [PATCH 6/6] net: asix: add AX88772B support Lucas Stach
2012-08-22 18:26   ` Marek Vasut
2012-08-22 19:01   ` Joe Hershberger
2012-08-22 18:20 ` [U-Boot] [PATCH 0/6] net: ASIX AX88772B enablement Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201208222023.51441.marex@denx.de \
    --to=marek.vasut@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox