d1721914c64eecb32430b8ce2e48dd694c512e9e
[openembedded.git] /
1 From 2e852db8367da3d3f60230419bd36bab2535c0ff Mon Sep 17 00:00:00 2001
2 From: Hugo Villeneuve <hugo@hugovil.com>
3 Date: Thu, 5 Mar 2009 17:11:05 -0500
4 Subject: [PATCH 04/12] Davinci: Enable MAC address to be specified on kernel cmd line
5
6 Signed-off-by: Hugo Villeneuve <hugo@hugovil.com>
7 ---
8  arch/arm/mach-davinci/devices.c |   23 +++++++++++++++++++++++
9  1 files changed, 23 insertions(+), 0 deletions(-)
10
11 diff --git a/arch/arm/mach-davinci/devices.c b/arch/arm/mach-davinci/devices.c
12 index a0f5a60..db433be 100644
13 --- a/arch/arm/mach-davinci/devices.c
14 +++ b/arch/arm/mach-davinci/devices.c
15 @@ -353,6 +353,27 @@ static struct platform_device dm646x_emac_device = {
16         }
17  };
18  
19 +/* Get Ethernet address from kernel boot params */
20 +static u8 davinci_bootloader_mac_addr[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
21 +
22 +static int /*__init */ davinci_bootloader_mac_setup(char *str)
23 +{
24 +       int i;
25 +
26 +       if (str == NULL)
27 +               return 0;
28 +
29 +       /* Conversion of a MAC address from a string (AA:BB:CC:DD:EE:FF)
30 +        * to a 6 bytes array. */
31 +       for (i = 0; i < 6; i++)
32 +               davinci_bootloader_mac_addr[i] =
33 +                       simple_strtol(&str[i*3], (char **)NULL, 16);
34 +
35 +       return 1;
36 +}
37 +/* Get MAC address from kernel  boot parameter eth=AA:BB:CC:DD:EE:FF */
38 +__setup("eth=", davinci_bootloader_mac_setup);
39 +
40  void davinci_init_emac(char *mac_addr)
41  {
42         DECLARE_MAC_BUF(buf);
43 @@ -366,6 +387,8 @@ void davinci_init_emac(char *mac_addr)
44  
45         if (mac_addr && is_valid_ether_addr(mac_addr))
46                 memcpy(emac_pdata.mac_addr, mac_addr, 6);
47 +       else if (is_valid_ether_addr(davinci_bootloader_mac_addr))
48 +               memcpy(emac_pdata.mac_addr, davinci_bootloader_mac_addr, 6);
49         else {
50                 /* Use random MAC if none passed */
51                 random_ether_addr(emac_pdata.mac_addr);
52 -- 
53 1.5.4.5
54