public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Albert ARIBAUD <albert.u.boot@aribaud.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment
Date: Thu, 18 Oct 2012 21:00:39 +0200	[thread overview]
Message-ID: <20121018210039.77007efc@lilith> (raw)
In-Reply-To: <1349438998-10954-4-git-send-email-yann.vernier@orsoc.se>

Hi Yann,

On Fri,  5 Oct 2012 14:09:50 +0200, Yann Vernier
<yann.vernier@orsoc.se> wrote:

> Removed board specific MAC reading code from driver.
> Should move the reading to the cm4008/cm41xx board code.
> ---
>  drivers/net/ks8695eth.c |   38 +++++++++-----------------------------
>  1 file changed, 9 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/net/ks8695eth.c b/drivers/net/ks8695eth.c
> index b4904b6..2dda7ab 100644
> --- a/drivers/net/ks8695eth.c
> +++ b/drivers/net/ks8695eth.c
> @@ -71,30 +71,13 @@ volatile uint8_t ks8695_bufs[BUFSIZE*(TXDESCS+RXDESCS)] __attribute__((aligned(2
>  
>  /****************************************************************************/
>  
> -/*
> - *	Ideally we want to use the MAC address stored in flash.
> - *	But we do some sanity checks in case they are not present
> - *	first.
> - */
> -unsigned char eth_mac[] = {
> -	0x00, 0x13, 0xc6, 0x00, 0x00, 0x00
> -};
> -
> -void ks8695_getmac(void)
> +static int ks8695_set_mac_address(struct eth_device *dev)
>  {
> -	unsigned char *fp;
> -	int i;
> -
> -	/* Check if flash MAC is valid */
> -	fp = (unsigned char *) 0x0201c000;
> -	for (i = 0; (i < 6); i++) {
> -		if ((fp[i] != 0) && (fp[i] != 0xff))
> -			break;
> -	}
> -
> -	/* If we found a valid looking MAC address then use it */
> -	if (i < 6)
> -		memcpy(&eth_mac[0], fp, 6);
> +	/* Set MAC address */
> +	ks8695_write(KS8695_LAN_MAC_LOW, (dev->enetaddr[5] | (dev->enetaddr[4] << 8) |
> +		(dev->enetaddr[3] << 16) | (dev->enetaddr[2] << 24)));
> +	ks8695_write(KS8695_LAN_MAC_HIGH, (dev->enetaddr[1] | (dev->enetaddr[0] << 8)));
> +	return 0;
>  }
>  
>  /****************************************************************************/
> @@ -109,12 +92,8 @@ static int ks8695_eth_init(struct eth_device *dev, bd_t *bd)
>  	ks8695_write(KS8695_LAN_DMA_TX, 0x80000000);
>  	ks8695_write(KS8695_LAN_DMA_RX, 0x80000000);
>  
> -	ks8695_getmac();
> -
>  	/* Set MAC address */
> -	ks8695_write(KS8695_LAN_MAC_LOW, (eth_mac[5] | (eth_mac[4] << 8) |
> -		(eth_mac[3] << 16) | (eth_mac[2] << 24)));
> -	ks8695_write(KS8695_LAN_MAC_HIGH, (eth_mac[1] | (eth_mac[0] << 8)));
> +	ks8695_set_mac_address(dev);
>  
>  	/* Turn the 4 port switch on */
>  	i = ks8695_read(KS8695_SWITCH_CTRL0);
> @@ -150,7 +129,7 @@ static int ks8695_eth_init(struct eth_device *dev, bd_t *bd)
>  	ks8695_write(KS8695_LAN_DMA_RX, 0x71);
>  	ks8695_write(KS8695_LAN_DMA_RX_START, 0x1);
>  
> -	printf("KS8695 ETHERNET: %pM\n", eth_mac);
> +	printf("KS8695 ETHERNET: %pM\n", dev->enetaddr);
>  	return 0;
>  }
>  
> @@ -234,6 +213,7 @@ int ks8695_eth_initialize(void)
>  	dev->halt = ks8695_eth_halt;
>  	dev->send = ks8695_eth_send;
>  	dev->recv = ks8695_eth_recv;
> +	dev->write_hwaddr = ks8695_set_mac_address;
>  	strcpy(dev->name, "ks8695eth");
>  
>  	eth_register(dev);

Cc:ing Joe as the network custodian for ack'ing the patch (although I'll
take it along with the whole series).

Amicalement,
-- 
Albert.

  reply	other threads:[~2012-10-18 19:00 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-05  8:05 [U-Boot] [PATCH 3/3] cm4008: use common cfi_flash support Yann Vernier
2012-07-05  9:48 ` Andreas Bießmann
2012-07-05 13:11   ` [U-Boot] [PATCH v2] arm: cm4008, cm41xx: " Yann Vernier
2012-07-05 15:04     ` Andreas Bießmann
2012-07-06  8:27       ` [U-Boot] [PATCH v3] " Yann Vernier
2012-07-06  8:47         ` Andreas Bießmann
2012-07-06 11:33           ` Albert ARIBAUD
2012-08-09 13:33             ` [U-Boot] [PATCH 10/11] arm: ks8695: document bus speed Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized Yann Vernier
2012-10-04  9:15               ` Albert ARIBAUD
2012-10-05 12:09                 ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Yann Vernier
2012-10-05 12:09                   ` [U-Boot] [PATCH 01/11] arm: ks8695: use defined constants for UART Yann Vernier
2012-10-26 21:34                     ` Albert ARIBAUD
2012-10-05 12:09                   ` [U-Boot] [PATCH 02/11] arm: ks8695: more macros for register values Yann Vernier
2012-10-18 18:57                     ` Albert ARIBAUD
2012-11-19 11:55                       ` [U-Boot] [PATCH] " Yann Vernier
2012-11-19 12:29                         ` Yann Vernier
2012-11-20  0:05                           ` Marek Vasut
2012-10-05 12:09                   ` [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment Yann Vernier
2012-10-18 19:00                     ` Albert ARIBAUD [this message]
2012-10-18 20:55                     ` Joe Hershberger
2012-10-19  8:02                       ` Yann Vernier
2012-10-26 21:37                         ` Albert ARIBAUD
2012-11-19 11:42                           ` Yann Vernier
2012-12-01 19:23                             ` Joe Hershberger
2012-10-05 12:09                   ` [U-Boot] [PATCH 04/11] arm: cm4008, cm41xx: use common cfi_flash support Yann Vernier
2012-10-05 12:09                   ` [U-Boot] [PATCH 05/11] arm: cm4008, cm41xx: set gd->ram_size in dram_init Yann Vernier
2012-10-05 12:09                   ` [U-Boot] [PATCH 06/11] arm: cm4008, cm41xx: Fix ROM relocation Yann Vernier
2012-10-18 19:09                     ` Albert ARIBAUD
2012-10-19  8:08                       ` Yann Vernier
2012-10-05 12:09                   ` [U-Boot] [PATCH 07/11] arm: ks8695/cm4008/cm41xx: Parameterize SDRAM Yann Vernier
2012-10-18 19:11                     ` Albert ARIBAUD
2012-10-05 12:09                   ` [U-Boot] [PATCH 08/11] arm: cm4008, cm41xx: don't define to 1 Yann Vernier
2012-10-05 12:09                   ` [U-Boot] [PATCH 09/11] arm: ks8695/cm4xxx: don't reconfigure switch Yann Vernier
2012-10-18 19:13                     ` Albert ARIBAUD
2012-10-05 12:09                   ` [U-Boot] [PATCH 10/11] arm: ks8695: document bus speed Yann Vernier
2012-10-05 12:09                   ` [U-Boot] [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash Yann Vernier
2012-10-18 19:14                     ` Albert ARIBAUD
2012-11-10  8:03                   ` [U-Boot] [PATCH 00/11] ks8695 (cm4008, cm41xx) bugfixes, constant removals, configuration generalized (repost) Albert ARIBAUD
2012-11-13 12:46                     ` Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 09/11] arm: ks8695/cm4xxx: don't reconfigure switch Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 08/11] arm: cm4008, cm41xx: don't define to 1 Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 07/11] arm: ks8695/cm4008/cm41xx: Parameterize SDRAM Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 04/11] arm: cm4008, cm41xx: use common cfi_flash support Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 06/11] arm: cm4008, cm41xx: Fix ROM relocation Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 05/11] arm: cm4008, cm41xx: set gd->ram_size in dram_init Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 03/11] arm: ks8695eth: Use MAC address from environment Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 01/11] arm: ks8695: use defined constants for UART Yann Vernier
2012-08-09 13:33             ` [U-Boot] [PATCH 02/11] arm: ks8695: more macros for register values Yann Vernier
2012-07-05 13:22   ` [U-Boot] [PATCH v2] arm: cm4008, cm41xx: Fix ROM relocation Yann Vernier
2012-07-05 13:41     ` Yann Vernier
2012-07-05 15:19     ` Andreas Bießmann
2012-07-12 19:37       ` Albert ARIBAUD

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=20121018210039.77007efc@lilith \
    --to=albert.u.boot@aribaud.net \
    --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