2008-05-19 17:53:02 -06:00
|
|
|
/*
|
2005-04-16 16:20:36 -06: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 11:18:16 -06:00
|
|
|
#include <linux/export.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#include <asm/oplib.h>
|
|
|
|
#include <asm/idprom.h>
|
|
|
|
|
|
|
|
struct idprom *idprom;
|
2009-01-08 17:58:05 -07:00
|
|
|
EXPORT_SYMBOL(idprom);
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
static struct idprom idprom_buffer;
|
|
|
|
|
2008-12-07 01:50:29 -07:00
|
|
|
#ifdef CONFIG_SPARC32
|
2008-12-07 01:49:53 -07:00
|
|
|
#include <asm/machines.h> /* Fun with Sun released architectures. */
|
|
|
|
|
2005-04-16 16:20:36 -06: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-11 21:45:18 -06:00
|
|
|
static struct Sun_Machine_Models Sun_Machines[] = {
|
|
|
|
/* First, Leon */
|
2009-08-16 18:13:31 -06:00
|
|
|
{ .name = "Leon3 System-on-a-Chip", .id_machtype = (M_LEON | M_LEON3_SOC) },
|
2005-04-16 16:20:36 -06:00
|
|
|
/* Finally, early Sun4m's */
|
2008-12-07 01:49:53 -07: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 16:20:36 -06:00
|
|
|
/* One entry for the OBP arch's which are sun4d, sun4e, and newer sun4m's */
|
2008-12-07 01:49:53 -07:00
|
|
|
{ .name = "Sun4M OBP based system", .id_machtype = (SM_SUN4M_OBP | 0x0) } };
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
static void __init display_system_type(unsigned char machtype)
|
|
|
|
{
|
|
|
|
char sysname[128];
|
|
|
|
register int i;
|
|
|
|
|
2012-05-11 21:45:18 -06:00
|
|
|
for (i = 0; i < ARRAY_SIZE(Sun_Machines); i++) {
|
2008-12-07 01:49:53 -07:00
|
|
|
if (Sun_Machines[i].id_machtype == machtype) {
|
2005-04-16 16:20:36 -06:00
|
|
|
if (machtype != (SM_SUN4M_OBP | 0x00) ||
|
|
|
|
prom_getproperty(prom_root_node, "banner-name",
|
|
|
|
sysname, sizeof(sysname)) <= 0)
|
2008-12-07 01:49:53 -07:00
|
|
|
printk(KERN_WARNING "TYPE: %s\n",
|
|
|
|
Sun_Machines[i].name);
|
2005-04-16 16:20:36 -06:00
|
|
|
else
|
2008-12-07 01:49:53 -07:00
|
|
|
printk(KERN_WARNING "TYPE: %s\n", sysname);
|
2005-04-16 16:20:36 -06:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-07 01:49:53 -07:00
|
|
|
prom_printf("IDPROM: Warning, bogus id_machtype value, 0x%x\n", machtype);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
2008-12-07 01:50:29 -07:00
|
|
|
#else
|
|
|
|
static void __init display_system_type(unsigned char machtype)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-16 16:20:36 -06: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 01:50:29 -07:00
|
|
|
if (idprom->id_format != 0x01)
|
2008-12-07 01:49:53 -07:00
|
|
|
prom_printf("IDPROM: Warning, unknown format type!\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2008-12-07 01:50:29 -07:00
|
|
|
if (idprom->id_cksum != calc_idprom_cksum(idprom))
|
2008-12-07 01:49:53 -07:00
|
|
|
prom_printf("IDPROM: Warning, checksum failure (nvram=%x, calc=%x)!\n",
|
2005-04-16 16:20:36 -06:00
|
|
|
idprom->id_cksum, calc_idprom_cksum(idprom));
|
|
|
|
|
|
|
|
display_system_type(idprom->id_machtype);
|
|
|
|
|
2008-12-28 21:19:47 -07:00
|
|
|
printk(KERN_WARNING "Ethernet address: %pM\n", idprom->id_ethaddr);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|