All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Murphy <dmurphy@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 5/7] ARM: OMAP5-uevm: Add USB MAC ethernet address
Date: Thu, 18 Jul 2013 10:40:43 -0500	[thread overview]
Message-ID: <51E80C7B.7050707@ti.com> (raw)
In-Reply-To: <201307180628.23410.marex@denx.de>

On 07/17/2013 11:28 PM, Marek Vasut wrote:
> Dear Dan Murphy,
>
>> Set the usbethaddr based on the OMAP DIE_ID registers
>> which should be unique for each processor.
>>
>> Then set this as the usb ethernet MAC address.
>>
>> Signed-off-by: Dan Murphy <dmurphy@ti.com>
>> ---
>> v3 - new patch
>>
>>  board/ti/omap5_uevm/evm.c    |   26 ++++++++++++++++++++++++++
>>  include/configs/omap5_uevm.h |    2 ++
>>  2 files changed, 28 insertions(+)
>>
>> diff --git a/board/ti/omap5_uevm/evm.c b/board/ti/omap5_uevm/evm.c
>> index bf14cd2..9add0fd 100644
>> --- a/board/ti/omap5_uevm/evm.c
>> +++ b/board/ti/omap5_uevm/evm.c
>> @@ -33,6 +33,11 @@
>>  #include <usb.h>
>>  #include <asm/arch/ehci.h>
>>  #include <asm/ehci-omap.h>
>> +
>> +#define MAX_DEVICE_MAC		20
>> +#define DIE_ID_REG_BASE         (OMAP54XX_L4_CORE_BASE + 0x2000)
>> +#define DIE_ID_REG_OFFSET	0x200
>> +
>>  #endif
>>
>>  DECLARE_GLOBAL_DATA_PTR;
>> @@ -121,6 +126,27 @@ int ehci_hcd_init(int index, struct ehci_hccr **hccr,
>> struct ehci_hcor **hcor) {
>>  	int ret;
>>  	int auxclk;
>> +	int val[4] = { 0 };
>> +	int reg;
>> +	char device_mac[MAX_DEVICE_MAC];
>> +
>> +	reg = DIE_ID_REG_BASE + DIE_ID_REG_OFFSET;
>> +
>> +	val[0] = readl(reg);
>> +	val[1] = readl(reg + 0x8);
>> +	val[2] = readl(reg + 0xC);
>> +	val[3] = readl(reg + 0x10);
>> +
>> +	/* create a fake MAC address from the processor ID code.
>> +	 * first byte is 0x02 to signify locally administered.
>> +	 */
> /*
>  * valid
>  * multiline
>  * comment ... has that leading newline on the top. [1]
>  */
>
Will fix
>> +	snprintf(device_mac, MAX_DEVICE_MAC, "%02X:%02X:%02X:%02X:%02X:%02X",
>> +				0x02, val[3] & 0xff, val[2] & 0xff, val[1] & 
> 0xff,
>> +				val[0] & 0xff, (val[0] >> 8 & 0xff));
>> +
>> +#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
>> +	setenv("usbethaddr", device_mac);
>> +#endif
> Urgh ... this is a big fat NAK. No, just don't do this, please. A kitten will 
> die if you set variables in the code like this. Another one will die for such a 
> config option.
>
> You might work around this problem by setting a different env variable (yet I am 
> still unhappy to see this) and then in the board environment have a command to 
> load the USB mac address from that other variable. But do not enforce the mac 
> address on users.

I will modify the usbethaddr only if the user has not already set the variable.
This is the way I see it in other code as well.

Is that acceptable?
>
>>  	auxclk = readl((*prcm)->scrm_auxclk1);
>>  	/* Request auxilary clock */
>> diff --git a/include/configs/omap5_uevm.h b/include/configs/omap5_uevm.h
>> index 0740a32..53b86ec 100644
>> --- a/include/configs/omap5_uevm.h
>> +++ b/include/configs/omap5_uevm.h
>> @@ -79,5 +79,7 @@
>>
>>  #define CONSOLEDEV		"ttyO2"
>>
>> +#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
>> +
>>  #define CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC	16296
>>  #endif /* __CONFIG_OMAP5_EVM_H */
> [1] http://www.denx.de/wiki/U-Boot/CodingStyle
>
> Best regards,
> Marek Vasut


-- 
------------------
Dan Murphy

  reply	other threads:[~2013-07-18 15:40 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-17 20:16 [U-Boot] OMAP5 uEVM USB eHCI patch set Dan Murphy
2013-07-17 20:16 ` [U-Boot] [PATCH v3 1/7] omap5: uevm: Change the board name to correct name Dan Murphy
2013-07-18  4:20   ` Marek Vasut
2013-07-17 20:16 ` [U-Boot] [PATCH v3 2/7] ARM: OMAP5: USB: Add OMAP5 common USB EHCI information Dan Murphy
2013-07-18  7:10   ` Roger Quadros
2013-07-18 17:48     ` Dan Murphy
2013-07-19  9:30       ` Roger Quadros
2013-07-22 15:14         ` Tom Rini
2013-07-17 20:16 ` [U-Boot] [PATCH v3 3/7] ARM: OMAP: USB: Fix linker error when ULPI is not defined Dan Murphy
2013-07-18  4:23   ` Marek Vasut
2013-07-17 20:16 ` [U-Boot] [PATCH v3 4/7] ARM: OMAP5-uevm: Add USB ehci support for the uEVM Dan Murphy
2013-07-22 15:16   ` Tom Rini
2013-07-17 20:16 ` [U-Boot] [PATCH v3 5/7] ARM: OMAP5-uevm: Add USB MAC ethernet address Dan Murphy
2013-07-18  4:28   ` Marek Vasut
2013-07-18 15:40     ` Dan Murphy [this message]
2013-07-18 15:47       ` Marek Vasut
2013-07-17 20:16 ` [U-Boot] [PATCH v3 6/7] USB: usb-hub: Add a weak function for resetting devices Dan Murphy
2013-07-18  4:30   ` Marek Vasut
2013-07-24 19:55     ` Dan Murphy
2013-07-25  5:32       ` Marek Vasut
2013-07-25  9:22         ` Roger Quadros
2013-07-17 20:16 ` [U-Boot] [PATCH v3 7/7] ARM: OMAP5-uevm: Add usb device reset API Dan Murphy
2013-07-18  4:30   ` Marek Vasut
2013-07-31 19:43     ` Dan Murphy
2013-07-31 20:18       ` 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=51E80C7B.7050707@ti.com \
    --to=dmurphy@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.