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 4/6] net: asix: add write_hwaddr function
Date: Wed, 22 Aug 2012 20:25:48 +0200	[thread overview]
Message-ID: <201208222025.48667.marex@denx.de> (raw)
In-Reply-To: <1345630147-14465-5-git-send-email-dev@lynxeye.de>

Dear Lucas Stach,

> All ASIX chipsets aside from AX88172 are able to set the MAC
> address on the hardware level. Add a function to expose this
> ability.
> 
> To differentiate between chip types we now carry flags as driver
> private data. Also while touching the asix_dongles array
> constify this.
> 
> Signed-off-by: Lucas Stach <dev@lynxeye.de>
> ---
>  drivers/usb/eth/asix.c | 61
> +++++++++++++++++++++++++++++++++++++++++--------- 1 Datei ge?ndert, 50
> Zeilen hinzugef?gt(+), 11 Zeilen entfernt(-)
> 
> diff --git a/drivers/usb/eth/asix.c b/drivers/usb/eth/asix.c
> index 50cbbbd..ce1483e 100644
> --- a/drivers/usb/eth/asix.c
> +++ b/drivers/usb/eth/asix.c
> @@ -23,6 +23,7 @@
>  #include <usb.h>
>  #include <linux/mii.h>
>  #include "usb_ether.h"
> +#include "malloc.h"

#include <malloc.h>

> 
>  /* ASIX AX8817X based USB 2.0 Ethernet Devices */
> @@ -35,6 +36,7 @@
>  #define AX_CMD_WRITE_RX_CTL		0x10
>  #define AX_CMD_WRITE_IPG0		0x12
>  #define AX_CMD_READ_NODE_ID		0x13
> +#define AX_CMD_WRITE_NODE_ID	0x14
>  #define AX_CMD_READ_PHY_ID		0x19
>  #define AX_CMD_WRITE_MEDIUM_MODE	0x1b
>  #define AX_CMD_WRITE_GPIOS		0x1f
> @@ -97,9 +99,19 @@
>  #define AX_RX_URB_SIZE 2048
>  #define PHY_CONNECT_TIMEOUT 5000
> 
> +/* asix_flags defines */
> +#define FLAG_NONE			0
> +#define FLAG_TYPE_AX88172	(1U << 0)
> +#define FLAG_TYPE_AX88772	(1U << 1)
> +#define FLAG_TYPE_AX88772B	(1U << 2)
>  /* local vars */
>  static int curr_eth_dev; /* index for name of next device detected */
> 
> +/* driver private */
> +struct asix_private {
> +	int flags;
> +};
> +
>  /*
>   * Asix infrastructure commands
>   */
> @@ -284,6 +296,21 @@ static int asix_write_gpio(struct ueth_data *dev, u16
> value, int sleep) return ret;
>  }
> 
> +static int asix_write_hwaddr(struct eth_device *eth)
> +{
> +	struct ueth_data *dev = (struct ueth_data *)eth->priv;
> +	int ret;
> +	ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buf, ETH_ALEN);
> +
> +	memcpy(buf, eth->enetaddr, ETH_ALEN);
> +
> +	ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, buf);
> +	if (ret < 0)
> +		debug("Failed to set MAC address: %02x\n", ret);
> +
> +	return ret;
> +}
> +
>  /*
>   * mii commands
>   */
> @@ -539,19 +566,20 @@ void asix_eth_before_probe(void)
>  struct asix_dongle {
>  	unsigned short vendor;
>  	unsigned short product;
> +	int flags;
>  };
> 
> -static struct asix_dongle asix_dongles[] = {
> -	{ 0x05ac, 0x1402 },	/* Apple USB Ethernet Adapter */
> -	{ 0x07d1, 0x3c05 },	/* D-Link DUB-E100 H/W Ver B1 */
> -	{ 0x0b95, 0x772a },	/* Cables-to-Go USB Ethernet Adapter */
> -	{ 0x0b95, 0x7720 },	/* Trendnet TU2-ET100 V3.0R */
> -	{ 0x0b95, 0x1720 },	/* SMC */
> -	{ 0x0db0, 0xa877 },	/* MSI - ASIX 88772a */
> -	{ 0x13b1, 0x0018 },	/* Linksys 200M v2.1 */
> -	{ 0x1557, 0x7720 },	/* 0Q0 cable ethernet */
> -	{ 0x2001, 0x3c05 },	/* DLink DUB-E100 H/W Ver B1 Alternate */
> -	{ 0x0000, 0x0000 }	/* END - Do not remove */
> +static const struct asix_dongle asix_dongles[] = {

Shouldn't this be static const __type const __name[] ?

> +	{ 0x05ac, 0x1402, FLAG_TYPE_AX88772 },	/* Apple USB Ethernet Adapter */
> +	{ 0x07d1, 0x3c05, FLAG_TYPE_AX88772 },	/* D-Link DUB-E100 H/W Ver B1 */
> +	{ 0x0b95, 0x772a, FLAG_TYPE_AX88772 },	/* Cables-to-Go USB Ethernet
> Adapter */ +	{ 0x0b95, 0x7720, FLAG_TYPE_AX88772 },	/* Trendnet TU2-ET100
> V3.0R */ +	{ 0x0b95, 0x1720, FLAG_TYPE_AX88172 },	/* SMC */
> +	{ 0x0db0, 0xa877, FLAG_TYPE_AX88772 },	/* MSI - ASIX 88772a */
> +	{ 0x13b1, 0x0018, FLAG_TYPE_AX88172 },	/* Linksys 200M v2.1 */
> +	{ 0x1557, 0x7720, FLAG_TYPE_AX88772 },	/* 0Q0 cable ethernet */
> +	{ 0x2001, 0x3c05, FLAG_TYPE_AX88772 },	/* DLink DUB-E100 H/W Ver B1
> Alternate */ +	{ 0x0000, 0x0000, FLAG_NONE }	/* END - Do not remove 
*/
>  };
> 
>  /* Probe to see if a new device is actually an asix device */
> @@ -588,6 +616,13 @@ int asix_eth_probe(struct usb_device *dev, unsigned
> int ifnum, ss->subclass = iface_desc->bInterfaceSubClass;
>  	ss->protocol = iface_desc->bInterfaceProtocol;
> 
> +	/* alloc driver private */
> +	ss->dev_priv = calloc(1, sizeof(struct asix_private));
> +	if (!ss->dev_priv)
> +		return 0;
> +
> +	((struct asix_private *)ss->dev_priv)->flags = asix_dongles[i].flags;
> +
>  	/*
>  	 * We are expecting a minimum of 3 endpoints - in, out (bulk), and
>  	 * int. We will ignore any others.
> @@ -629,6 +664,8 @@ int asix_eth_probe(struct usb_device *dev, unsigned int
> ifnum, int asix_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
> struct eth_device *eth)
>  {
> +	struct asix_private *priv = (struct asix_private *)ss->dev_priv;
> +
>  	if (!eth) {
>  		debug("%s: missing parameter.\n", __func__);
>  		return 0;
> @@ -638,6 +675,8 @@ int asix_eth_get_info(struct usb_device *dev, struct
> ueth_data *ss, eth->send = asix_send;
>  	eth->recv = asix_recv;
>  	eth->halt = asix_halt;
> +	if (!(priv->flags & FLAG_TYPE_AX88172))
> +		eth->write_hwaddr = asix_write_hwaddr;
>  	eth->priv = ss;
> 
>  	if (asix_basic_reset(ss))

Best regards,
Marek Vasut

  reply	other threads:[~2012-08-22 18:25 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
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 [this message]
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=201208222025.48667.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