x86/xen: resume timer irqs early
[linux/fpc-iii.git] / arch / c6x / kernel / soc.c
blob3ac74080fded2b02a85df6f6310390b075e721d3
1 /*
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>
15 #include <asm/soc.h>
17 struct soc_ops soc_ops;
19 int soc_get_exception(void)
21 if (!soc_ops.get_exception)
22 return -1;
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)
36 int count, i, val;
38 for (count = 0; count < 6 && *str; count++, str += 3) {
39 if (!isxdigit(str[0]) || !isxdigit(str[1]))
40 return 0;
41 if (str[2] != ((count < 5) ? ':' : '\0'))
42 return 0;
44 for (i = 0, val = 0; i < 2; i++) {
45 val = val << 4;
46 val |= isdigit(str[i]) ?
47 str[i] - '0' : toupper(str[i]) - 'A' + 10;
49 cmdline_mac[count] = val;
51 return 1;
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
61 * the fused address.
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++) {
68 if (cmdline_mac[i])
69 have_cmdline_mac = 1;
70 if (c6x_fuse_mac[i])
71 have_fuse_mac = 1;
72 if (addr[i])
73 have_dt_mac = 1;
76 /* cmdline overrides all */
77 if (have_cmdline_mac)
78 memcpy(addr, cmdline_mac, 6);
79 else if (!have_dt_mac) {
80 if (have_fuse_mac)
81 memcpy(addr, c6x_fuse_mac, 6);
82 else
83 eth_random_addr(addr);
86 /* adjust for specific EMAC device */
87 addr[5] += index * c6x_num_cores;
88 return 1;
90 EXPORT_SYMBOL_GPL(soc_mac_addr);