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/system.h>
15 #include <asm/setup.h>
18 struct soc_ops soc_ops
;
20 int soc_get_exception(void)
22 if (!soc_ops
.get_exception
)
24 return soc_ops
.get_exception();
27 void soc_assert_event(unsigned int evt
)
29 if (soc_ops
.assert_event
)
30 soc_ops
.assert_event(evt
);
33 static u8 cmdline_mac
[6];
35 static int __init
get_mac_addr_from_cmdline(char *str
)
39 for (count
= 0; count
< 6 && *str
; count
++, str
+= 3) {
40 if (!isxdigit(str
[0]) || !isxdigit(str
[1]))
42 if (str
[2] != ((count
< 5) ? ':' : '\0'))
45 for (i
= 0, val
= 0; i
< 2; i
++) {
47 val
|= isdigit(str
[i
]) ?
48 str
[i
] - '0' : toupper(str
[i
]) - 'A' + 10;
50 cmdline_mac
[count
] = val
;
54 __setup("emac_addr=", get_mac_addr_from_cmdline
);
57 * Setup the MAC address for SoC ethernet devices.
59 * Before calling this function, the ethernet driver will have
60 * initialized the addr with local-mac-address from the device
61 * tree (if found). Allow command line to override, but not
64 int soc_mac_addr(unsigned int index
, u8
*addr
)
66 int i
, have_dt_mac
= 0, have_cmdline_mac
= 0, have_fuse_mac
= 0;
68 for (i
= 0; i
< 6; i
++) {
77 /* cmdline overrides all */
79 memcpy(addr
, cmdline_mac
, 6);
80 else if (!have_dt_mac
) {
82 memcpy(addr
, c6x_fuse_mac
, 6);
84 random_ether_addr(addr
);
87 /* adjust for specific EMAC device */
88 addr
[5] += index
* c6x_num_cores
;
91 EXPORT_SYMBOL_GPL(soc_mac_addr
);