linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] omap: Devkit8000: Use DIE id to initialize dm9000 MAC address
@ 2010-07-05  5:46 Kan-Ru Chen
  2010-07-05  9:44 ` Tony Lindgren
  0 siblings, 1 reply; 4+ messages in thread
From: Kan-Ru Chen @ 2010-07-05  5:46 UTC (permalink / raw)
  To: linux-omap; +Cc: Thomas Weber, Kan-Ru Chen

The devkit8000 debug boards often come with empty EEPROM thus without
valid ethernet MAC address. The DIE id to MAC formula is copied from
u-boot.

Signed-off-by: Kan-Ru Chen <kanru@0xlab.org>
---
 arch/arm/mach-omap2/board-devkit8000.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index a2a8afe..807ceee 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -45,6 +45,7 @@
 #include <plat/usb.h>
 #include <plat/timer-gp.h>
 #include <plat/display.h>
+#include <plat/io.h>
 
 #include <plat/mcspi.h>
 #include <linux/input/matrix_keypad.h>
@@ -66,6 +67,10 @@
 #define OMAP_DM9000_GPIO_IRQ	25
 #define OMAP3_DEVKIT_TS_GPIO	27
 
+#define DIE_ID_REG_BASE	(L4_34XX_PHYS + 0xA000)
+#define DIE_ID_REG_0		0x218
+#define DIE_ID_REG_1		0x21C
+
 struct flash_partitions {
        struct mtd_partition *parts;
        int nr_parts;
@@ -603,6 +608,9 @@ static struct platform_device omap_dm9000_dev = {
 
 static void __init omap_dm9000_init(void)
 {
+	unsigned char *eth_addr = omap_dm9000_platdata.dev_addr;
+	unsigned int die_id_0;
+
 	if (gpio_request(OMAP_DM9000_GPIO_IRQ, "dm9000 irq") < 0) {
 		printk(KERN_ERR "Failed to request GPIO%d for dm9000 IRQ\n",
 			OMAP_DM9000_GPIO_IRQ);
@@ -610,6 +618,15 @@ static void __init omap_dm9000_init(void)
 		}
 
 	gpio_direction_input(OMAP_DM9000_GPIO_IRQ);
+
+	/* init the mac address using DIE id */
+	die_id_0 = omap_readl(DIE_ID_REG_BASE + DIE_ID_REG_0);
+	eth_addr[0] = 0x02; /* locally administered */
+	eth_addr[1] = omap_readl(DIE_ID_REG_BASE + DIE_ID_REG_1) & 0xff;
+	eth_addr[2] = (die_id_0 & 0xff000000) >> 24;
+	eth_addr[3] = (die_id_0 & 0x00ff0000) >> 16;
+	eth_addr[4] = (die_id_0 & 0x0000ff00) >> 8;
+	eth_addr[5] = (die_id_0 & 0x000000ff);
 }
 
 static struct platform_device *devkit8000_devices[] __initdata = {
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] omap: Devkit8000: Use DIE id to initialize dm9000 MAC address
  2010-07-05  5:46 [PATCH] omap: Devkit8000: Use DIE id to initialize dm9000 MAC address Kan-Ru Chen
@ 2010-07-05  9:44 ` Tony Lindgren
  2010-07-05 11:54   ` Kan-Ru Chen
  0 siblings, 1 reply; 4+ messages in thread
From: Tony Lindgren @ 2010-07-05  9:44 UTC (permalink / raw)
  To: Kan-Ru Chen; +Cc: linux-omap, Thomas Weber

* Kan-Ru Chen <kanru@0xlab.org> [100705 09:27]:
> The devkit8000 debug boards often come with empty EEPROM thus without
> valid ethernet MAC address. The DIE id to MAC formula is copied from
> u-boot.
> 
> Signed-off-by: Kan-Ru Chen <kanru@0xlab.org>
> ---
>  arch/arm/mach-omap2/board-devkit8000.c |   17 +++++++++++++++++
>  1 files changed, 17 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
> index a2a8afe..807ceee 100644
> --- a/arch/arm/mach-omap2/board-devkit8000.c
> +++ b/arch/arm/mach-omap2/board-devkit8000.c
> @@ -45,6 +45,7 @@
>  #include <plat/usb.h>
>  #include <plat/timer-gp.h>
>  #include <plat/display.h>
> +#include <plat/io.h>
>  
>  #include <plat/mcspi.h>
>  #include <linux/input/matrix_keypad.h>
> @@ -66,6 +67,10 @@
>  #define OMAP_DM9000_GPIO_IRQ	25
>  #define OMAP3_DEVKIT_TS_GPIO	27
>  
> +#define DIE_ID_REG_BASE	(L4_34XX_PHYS + 0xA000)
> +#define DIE_ID_REG_0		0x218
> +#define DIE_ID_REG_1		0x21C
> +
>  struct flash_partitions {
>         struct mtd_partition *parts;
>         int nr_parts;
> @@ -603,6 +608,9 @@ static struct platform_device omap_dm9000_dev = {
>  
>  static void __init omap_dm9000_init(void)
>  {
> +	unsigned char *eth_addr = omap_dm9000_platdata.dev_addr;
> +	unsigned int die_id_0;
> +
>  	if (gpio_request(OMAP_DM9000_GPIO_IRQ, "dm9000 irq") < 0) {
>  		printk(KERN_ERR "Failed to request GPIO%d for dm9000 IRQ\n",
>  			OMAP_DM9000_GPIO_IRQ);
> @@ -610,6 +618,15 @@ static void __init omap_dm9000_init(void)
>  		}
>  
>  	gpio_direction_input(OMAP_DM9000_GPIO_IRQ);
> +
> +	/* init the mac address using DIE id */
> +	die_id_0 = omap_readl(DIE_ID_REG_BASE + DIE_ID_REG_0);

We should not add omap_readl/writel to any new code, those are slowly
going away.

> +	eth_addr[0] = 0x02; /* locally administered */
> +	eth_addr[1] = omap_readl(DIE_ID_REG_BASE + DIE_ID_REG_1) & 0xff;
> +	eth_addr[2] = (die_id_0 & 0xff000000) >> 24;
> +	eth_addr[3] = (die_id_0 & 0x00ff0000) >> 16;
> +	eth_addr[4] = (die_id_0 & 0x0000ff00) >> 8;
> +	eth_addr[5] = (die_id_0 & 0x000000ff);
>  }
>  
>  static struct platform_device *devkit8000_devices[] __initdata = {

How about adding a function for getting this from mach-omap2/id.c?
Other boards might want to use it too.

Regards,

Tony

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] omap: Devkit8000: Use DIE id to initialize dm9000 MAC address
  2010-07-05  9:44 ` Tony Lindgren
@ 2010-07-05 11:54   ` Kan-Ru Chen
  2010-07-05 13:49     ` Tony Lindgren
  0 siblings, 1 reply; 4+ messages in thread
From: Kan-Ru Chen @ 2010-07-05 11:54 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: linux-omap, Thomas Weber

On Mon, Jul 5, 2010 at 5:44 PM, Tony Lindgren <tony@atomide.com> wrote:
> * Kan-Ru Chen <kanru@0xlab.org> [100705 09:27]:
>> The devkit8000 debug boards often come with empty EEPROM thus without
>> valid ethernet MAC address. The DIE id to MAC formula is copied from
>> u-boot.
>>
>> Signed-off-by: Kan-Ru Chen <kanru@0xlab.org>
>> ---
>>  arch/arm/mach-omap2/board-devkit8000.c |   17 +++++++++++++++++
>>  1 files changed, 17 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
>> index a2a8afe..807ceee 100644
>> --- a/arch/arm/mach-omap2/board-devkit8000.c
>> +++ b/arch/arm/mach-omap2/board-devkit8000.c
>> @@ -45,6 +45,7 @@
>>  #include <plat/usb.h>
>>  #include <plat/timer-gp.h>
>>  #include <plat/display.h>
>> +#include <plat/io.h>
>>
>>  #include <plat/mcspi.h>
>>  #include <linux/input/matrix_keypad.h>
>> @@ -66,6 +67,10 @@
>>  #define OMAP_DM9000_GPIO_IRQ 25
>>  #define OMAP3_DEVKIT_TS_GPIO 27
>>
>> +#define DIE_ID_REG_BASE      (L4_34XX_PHYS + 0xA000)
>> +#define DIE_ID_REG_0         0x218
>> +#define DIE_ID_REG_1         0x21C
>> +
>>  struct flash_partitions {
>>         struct mtd_partition *parts;
>>         int nr_parts;
>> @@ -603,6 +608,9 @@ static struct platform_device omap_dm9000_dev = {
>>
>>  static void __init omap_dm9000_init(void)
>>  {
>> +     unsigned char *eth_addr = omap_dm9000_platdata.dev_addr;
>> +     unsigned int die_id_0;
>> +
>>       if (gpio_request(OMAP_DM9000_GPIO_IRQ, "dm9000 irq") < 0) {
>>               printk(KERN_ERR "Failed to request GPIO%d for dm9000 IRQ\n",
>>                       OMAP_DM9000_GPIO_IRQ);
>> @@ -610,6 +618,15 @@ static void __init omap_dm9000_init(void)
>>               }
>>
>>       gpio_direction_input(OMAP_DM9000_GPIO_IRQ);
>> +
>> +     /* init the mac address using DIE id */
>> +     die_id_0 = omap_readl(DIE_ID_REG_BASE + DIE_ID_REG_0);
>
> We should not add omap_readl/writel to any new code, those are slowly
> going away.
>
>> +     eth_addr[0] = 0x02; /* locally administered */
>> +     eth_addr[1] = omap_readl(DIE_ID_REG_BASE + DIE_ID_REG_1) & 0xff;
>> +     eth_addr[2] = (die_id_0 & 0xff000000) >> 24;
>> +     eth_addr[3] = (die_id_0 & 0x00ff0000) >> 16;
>> +     eth_addr[4] = (die_id_0 & 0x0000ff00) >> 8;
>> +     eth_addr[5] = (die_id_0 & 0x000000ff);
>>  }
>>
>>  static struct platform_device *devkit8000_devices[] __initdata = {
>
> How about adding a function for getting this from mach-omap2/id.c?
> Other boards might want to use it too.

I had originally intended to do so, but I was not sure how to design the api.

omap_read_die_0(), omap_read_die_id_1() and so on? or a function that
return those ids at once?

Any suggestions?

Regards,
Kanru

> Regards,
>
> Tony
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] omap: Devkit8000: Use DIE id to initialize dm9000 MAC address
  2010-07-05 11:54   ` Kan-Ru Chen
@ 2010-07-05 13:49     ` Tony Lindgren
  0 siblings, 0 replies; 4+ messages in thread
From: Tony Lindgren @ 2010-07-05 13:49 UTC (permalink / raw)
  To: Kan-Ru Chen; +Cc: linux-omap, Thomas Weber

* Kan-Ru Chen <kanru@0xlab.org> [100705 14:48]:
> On Mon, Jul 5, 2010 at 5:44 PM, Tony Lindgren <tony@atomide.com> wrote:
> >
> > How about adding a function for getting this from mach-omap2/id.c?
> > Other boards might want to use it too.
> 
> I had originally intended to do so, but I was not sure how to design the api.
> 
> omap_read_die_0(), omap_read_die_id_1() and so on? or a function that
> return those ids at once?
> 
> Any suggestions?

No preferences from me, up to you. But some TI people might have better
ideas on how future proof it will be.

If it's likely to change, the maybe set up struct omap_die_id to start
with.

Regards,

Tony

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-07-05 13:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-05  5:46 [PATCH] omap: Devkit8000: Use DIE id to initialize dm9000 MAC address Kan-Ru Chen
2010-07-05  9:44 ` Tony Lindgren
2010-07-05 11:54   ` Kan-Ru Chen
2010-07-05 13:49     ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).