From: Ben Warren <biggerbadderben@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v5 08/12] SPEAr : Support for HW mac id read/write from i2c mem
Date: Sun, 17 Jan 2010 23:19:04 -0800 [thread overview]
Message-ID: <4B540B68.7030901@gmail.com> (raw)
In-Reply-To: <4B540834.7040301@st.com>
Vipin,
Vipin KUMAR wrote:
> On 1/18/2010 11:45 AM, Ben Warren wrote:
>
>>> int misc_init_r(void)
>>> {
>>> +#if defined(CONFIG_CMD_NET)
>>> + uchar mac_id[6];
>>> +
>>> + if (!eth_getenv_enetaddr("ethaddr", mac_id) &&
>>> !i2c_read_mac(mac_id))
>>> + eth_setenv_enetaddr("ethaddr", mac_id);
>>>
>>>
>> It's really not a good idea to programatically set an environment
>> variable like this. Also, there's already a well-defined and documented
>> protocol for how MAC addresses should be read and the precedence
>> between EEPROM storage and environment storage. Please find a way to
>> fit into that model. Since you don't have network support yet, I have
>> no idea which network controller you're using, and recommend waiting
>> until this is really needed.
>>
>
> I am referring to doc/README.enetaddr in the uboot source. This document says
> "If the hardware design mandates that the MAC address is stored in some special
> place (like EEPROM etc...), then the board specific init code (such as the
> board-specific misc_init_r() function) is responsible for locating the MAC
> address(es) and initializing the respective environment variable(s) from it.
> Note that this shall be done if, and only if, the environment does not already
> contain these environment variables, i.e. existing variable definitions must
> not be overwritten."
>
> Coming back to the code
> if (!eth_getenv_enetaddr("ethaddr", mac_id) && !i2c_read_mac(mac_id))
> eth_setenv_enetaddr("ethaddr", mac_id);
>
> first I read the env variable "ethaddr" and skip setting it if it already
> exists
> then I read mac id from i2c memory and store the same in env variable
>
> Please let me know if I am missing anything.
>
> Although the patch is not really needed right now, it will be needed soon.
> I am planning to send the net support patch during the next merging window.
> Since the current patch does not have any side effects, it can be included
> as of now.
>
>
You're right. For the sake of keeping networking stuff together, I'd
prefer to see this logic in 'board_eth_init()' once you have it coded,
but am not going to hold up progress for such a minor point. Sorry for
the noise.
>>>
>>> if (chip->cpufreq == -1)
>>> @@ -156,6 +215,13 @@ int do_chip_config(cmd_tbl_t *cmdtp, int flag,
>>> int argc, char *argv[])
>>> else
>>> printf("DDR Type = Not Known\n");
>>>
>>> + if (!i2c_read_mac(mac)) {
>>> + sprintf(i2c_mac, "%pM", mac);
>>> + printf("Ethaddr (from i2c mem) = %s\n", i2c_mac);
>>>
>>>
>> Maybe I'm missing some context, but why's the sprintf needed?
>>
>
> Yes, sprintf is not needed here
> Thanks for pointing out
>
> Regards
> Vipin
>
regards,
Ben
next prev parent reply other threads:[~2010-01-18 7:19 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-15 13:45 [U-Boot] [PATCH v5 00/12] Support for SPEAr SoCs Vipin KUMAR
2010-01-15 13:45 ` [U-Boot] [PATCH v5 01/12] SPEAr : Adding README.spear in doc Vipin KUMAR
2010-01-15 13:45 ` [U-Boot] [PATCH v5 02/12] SPEAr : Adding basic SPEAr architecture support Vipin KUMAR
2010-01-15 13:45 ` [U-Boot] [PATCH v5 03/12] SPEAr : i2c driver support added for SPEAr SoCs Vipin KUMAR
2010-01-15 13:45 ` [U-Boot] [PATCH v5 04/12] SPEAr : smi driver support " Vipin KUMAR
2010-01-15 13:45 ` [U-Boot] [PATCH v5 05/12] SPEAr : nand " Vipin KUMAR
2010-01-15 13:45 ` [U-Boot] [PATCH v5 06/12] SPEAr : usbd " Vipin KUMAR
2010-01-15 13:45 ` [U-Boot] [PATCH v5 07/12] SPEAr : Support added for SPEAr600 board Vipin KUMAR
2010-01-15 13:45 ` [U-Boot] [PATCH v5 08/12] SPEAr : Support for HW mac id read/write from i2c mem Vipin KUMAR
2010-01-15 13:45 ` [U-Boot] [PATCH v5 09/12] SPEAr : Support added for SPEAr300 board Vipin KUMAR
2010-01-15 13:45 ` [U-Boot] [PATCH v5 10/12] SPEAr : emi controller initialization for CFI driver support Vipin KUMAR
2010-01-15 13:45 ` [U-Boot] [PATCH v5 11/12] SPEAr : Support added for SPEAr310 board Vipin KUMAR
2010-01-15 13:45 ` [U-Boot] [PATCH v5 12/12] SPEAr : Support added for SPEAr320 board Vipin KUMAR
2010-01-18 6:15 ` [U-Boot] [PATCH v5 08/12] SPEAr : Support for HW mac id read/write from i2c mem Ben Warren
2010-01-18 7:05 ` Vipin KUMAR
2010-01-18 7:19 ` Ben Warren [this message]
2010-01-18 7:24 ` Vipin KUMAR
2010-01-18 12:59 ` Tom
2010-01-18 7:08 ` Mike Frysinger
2010-02-01 5:15 ` Ben Warren
2010-02-01 13:55 ` Tom
2010-01-18 18:02 ` [U-Boot] [PATCH v5 05/12] SPEAr : nand driver support for SPEAr SoCs Scott Wood
2010-01-17 20:12 ` [U-Boot] [PATCH v5 00/12] Support " Tom
2010-01-18 4:39 ` Vipin KUMAR
2010-01-18 12:51 ` Tom
2010-01-18 19:19 ` Remy Bohmer
2010-01-19 11:52 ` Armando VISCONTI
2010-01-21 21:30 ` Tom
2010-01-22 3:33 ` Vipin KUMAR
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=4B540B68.7030901@gmail.com \
--to=biggerbadderben@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