2 * Miscellaneous SoC-specific hooks.
4 * Copyright (C) 2011 Texas Instruments Incorporated
5 * Author: Mark Salter <msalter@redhat.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 #include <linux/module.h>
12 #include <linux/ctype.h>
13 #include <linux/etherdevice.h>
14 #include <asm/setup.h>
17 struct soc_ops soc_ops
;
19 int soc_get_exception(void)
21 if (!soc_ops
.get_exception
)
23 return soc_ops
.get_exception();
26 void soc_assert_event(unsigned int evt
)
28 if (soc_ops
.assert_event
)
29 soc_ops
.assert_event(evt
);
32 static u8 cmdline_mac
[6];
34 static int __init
get_mac_addr_from_cmdline(char *str
)
38 for (count
= 0; count
< 6 && *str
; count
++, str
+= 3) {
39 if (!isxdigit(str
[0]) || !isxdigit(str
[1]))
41 if (str
[2] != ((count
< 5) ? ':' : '\0'))
44 for (i
= 0, val
= 0; i
< 2; i
++) {
46 val
|= isdigit(str
[i
]) ?
47 str
[i
] - '0' : toupper(str
[i
]) - 'A' + 10;
49 cmdline_mac
[count
] = val
;
53 __setup("emac_addr=", get_mac_addr_from_cmdline
);
56 * Setup the MAC address for SoC ethernet devices.
58 * Before calling this function, the ethernet driver will have
59 * initialized the addr with local-mac-address from the device
60 * tree (if found). Allow command line to override, but not
63 int soc_mac_addr(unsigned int index
, u8
*addr
)
65 int i
, have_dt_mac
= 0, have_cmdline_mac
= 0, have_fuse_mac
= 0;
67 for (i
= 0; i
< 6; i
++) {
76 /* cmdline overrides all */
78 memcpy(addr
, cmdline_mac
, 6);
79 else if (!have_dt_mac
) {
81 memcpy(addr
, c6x_fuse_mac
, 6);
83 eth_random_addr(addr
);
86 /* adjust for specific EMAC device */
87 addr
[5] += index
* c6x_num_cores
;
90 EXPORT_SYMBOL_GPL(soc_mac_addr
);