2008-05-19 23:53:02 +00:00
|
|
|
/*
|
2005-04-16 22:20:36 +00:00
|
|
|
* idprom.c: Routines to load the idprom into kernel addresses and
|
|
|
|
* interpret the data contained within.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/init.h>
|
2011-07-22 17:18:16 +00:00
|
|
|
#include <linux/export.h>
|
2015-11-05 16:34:57 +00:00
|
|
|
#include <linux/etherdevice.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <asm/oplib.h>
|
|
|
|
#include <asm/idprom.h>
|
|
|
|
|
|
|
|
struct idprom *idprom;
|
2009-01-09 00:58:05 +00:00
|
|
|
EXPORT_SYMBOL(idprom);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static struct idprom idprom_buffer;
|
|
|
|
|
2008-12-07 08:50:29 +00:00
|
|
|
#ifdef CONFIG_SPARC32
|
2008-12-07 08:49:53 +00:00
|
|
|
#include <asm/machines.h> /* Fun with Sun released architectures. */
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Here is the master table of Sun machines which use some implementation
|
|
|
|
* of the Sparc CPU and have a meaningful IDPROM machtype value that we
|
|
|
|
* know about. See asm-sparc/machines.h for empirical constants.
|
|
|
|
*/
|
2012-05-12 03:45:18 +00:00
|
|
|
static struct Sun_Machine_Models Sun_Machines[] = {
|
|
|
|
/* First, Leon */
|
2009-08-17 00:13:31 +00:00
|
|
|
{ .name = "Leon3 System-on-a-Chip", .id_machtype = (M_LEON | M_LEON3_SOC) },
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Finally, early Sun4m's */
|
2008-12-07 08:49:53 +00:00
|
|
|
{ .name = "Sun4m SparcSystem600", .id_machtype = (SM_SUN4M | SM_4M_SS60) },
|
|
|
|
{ .name = "Sun4m SparcStation10/20", .id_machtype = (SM_SUN4M | SM_4M_SS50) },
|
|
|
|
{ .name = "Sun4m SparcStation5", .id_machtype = (SM_SUN4M | SM_4M_SS40) },
|
2005-04-16 22:20:36 +00:00
|
|
|
/* One entry for the OBP arch's which are sun4d, sun4e, and newer sun4m's */
|
2008-12-07 08:49:53 +00:00
|
|
|
{ .name = "Sun4M OBP based system", .id_machtype = (SM_SUN4M_OBP | 0x0) } };
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static void __init display_system_type(unsigned char machtype)
|
|
|
|
{
|
|
|
|
char sysname[128];
|
|
|
|
register int i;
|
|
|
|
|
2012-05-12 03:45:18 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(Sun_Machines); i++) {
|
2008-12-07 08:49:53 +00:00
|
|
|
if (Sun_Machines[i].id_machtype == machtype) {
|
2005-04-16 22:20:36 +00:00
|
|
|
if (machtype != (SM_SUN4M_OBP | 0x00) ||
|
|
|
|
prom_getproperty(prom_root_node, "banner-name",
|
|
|
|
sysname, sizeof(sysname)) <= 0)
|
2008-12-07 08:49:53 +00:00
|
|
|
printk(KERN_WARNING "TYPE: %s\n",
|
|
|
|
Sun_Machines[i].name);
|
2005-04-16 22:20:36 +00:00
|
|
|
else
|
2008-12-07 08:49:53 +00:00
|
|
|
printk(KERN_WARNING "TYPE: %s\n", sysname);
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-07 08:49:53 +00:00
|
|
|
prom_printf("IDPROM: Warning, bogus id_machtype value, 0x%x\n", machtype);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-12-07 08:50:29 +00:00
|
|
|
#else
|
|
|
|
static void __init display_system_type(unsigned char machtype)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
2015-11-05 16:34:57 +00:00
|
|
|
|
|
|
|
unsigned char *arch_get_platform_mac_address(void)
|
|
|
|
{
|
|
|
|
return idprom->id_ethaddr;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Calculate the IDPROM checksum (xor of the data bytes). */
|
|
|
|
static unsigned char __init calc_idprom_cksum(struct idprom *idprom)
|
|
|
|
{
|
|
|
|
unsigned char cksum, i, *ptr = (unsigned char *)idprom;
|
|
|
|
|
|
|
|
for (i = cksum = 0; i <= 0x0E; i++)
|
|
|
|
cksum ^= *ptr++;
|
|
|
|
|
|
|
|
return cksum;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create a local IDPROM copy, verify integrity, and display information. */
|
|
|
|
void __init idprom_init(void)
|
|
|
|
{
|
|
|
|
prom_get_idprom((char *) &idprom_buffer, sizeof(idprom_buffer));
|
|
|
|
|
|
|
|
idprom = &idprom_buffer;
|
|
|
|
|
2008-12-07 08:50:29 +00:00
|
|
|
if (idprom->id_format != 0x01)
|
2008-12-07 08:49:53 +00:00
|
|
|
prom_printf("IDPROM: Warning, unknown format type!\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-12-07 08:50:29 +00:00
|
|
|
if (idprom->id_cksum != calc_idprom_cksum(idprom))
|
2008-12-07 08:49:53 +00:00
|
|
|
prom_printf("IDPROM: Warning, checksum failure (nvram=%x, calc=%x)!\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
idprom->id_cksum, calc_idprom_cksum(idprom));
|
|
|
|
|
|
|
|
display_system_type(idprom->id_machtype);
|
|
|
|
|
2008-12-29 04:19:47 +00:00
|
|
|
printk(KERN_WARNING "Ethernet address: %pM\n", idprom->id_ethaddr);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|