/*1* idprom.c: Routines to load the idprom into kernel addresses and2* interpret the data contained within.3*4* Copyright (C) 1995 David S. Miller ([email protected])5* Sun3/3x models added by David Monro ([email protected])6*/78#include <linux/module.h>9#include <linux/kernel.h>10#include <linux/types.h>11#include <linux/init.h>12#include <linux/string.h>1314#include <asm/oplib.h>15#include <asm/idprom.h>16#include <asm/machines.h> /* Fun with Sun released architectures. */1718struct idprom *idprom;19EXPORT_SYMBOL(idprom);2021static struct idprom idprom_buffer;2223/* Here is the master table of Sun machines which use some implementation24* of the Sparc CPU and have a meaningful IDPROM machtype value that we25* know about. See asm-sparc/machines.h for empirical constants.26*/27static struct Sun_Machine_Models Sun_Machines[NUM_SUN_MACHINES] = {28/* First, Sun3's */29{ .name = "Sun 3/160 Series", .id_machtype = (SM_SUN3 | SM_3_160) },30{ .name = "Sun 3/50", .id_machtype = (SM_SUN3 | SM_3_50) },31{ .name = "Sun 3/260 Series", .id_machtype = (SM_SUN3 | SM_3_260) },32{ .name = "Sun 3/110 Series", .id_machtype = (SM_SUN3 | SM_3_110) },33{ .name = "Sun 3/60", .id_machtype = (SM_SUN3 | SM_3_60) },34{ .name = "Sun 3/E", .id_machtype = (SM_SUN3 | SM_3_E) },35/* Now, Sun3x's */36{ .name = "Sun 3/460 Series", .id_machtype = (SM_SUN3X | SM_3_460) },37{ .name = "Sun 3/80", .id_machtype = (SM_SUN3X | SM_3_80) },38/* Then, Sun4's */39// { .name = "Sun 4/100 Series", .id_machtype = (SM_SUN4 | SM_4_110) },40// { .name = "Sun 4/200 Series", .id_machtype = (SM_SUN4 | SM_4_260) },41// { .name = "Sun 4/300 Series", .id_machtype = (SM_SUN4 | SM_4_330) },42// { .name = "Sun 4/400 Series", .id_machtype = (SM_SUN4 | SM_4_470) },43/* And now, Sun4c's */44// { .name = "Sun4c SparcStation 1", .id_machtype = (SM_SUN4C | SM_4C_SS1) },45// { .name = "Sun4c SparcStation IPC", .id_machtype = (SM_SUN4C | SM_4C_IPC) },46// { .name = "Sun4c SparcStation 1+", .id_machtype = (SM_SUN4C | SM_4C_SS1PLUS) },47// { .name = "Sun4c SparcStation SLC", .id_machtype = (SM_SUN4C | SM_4C_SLC) },48// { .name = "Sun4c SparcStation 2", .id_machtype = (SM_SUN4C | SM_4C_SS2) },49// { .name = "Sun4c SparcStation ELC", .id_machtype = (SM_SUN4C | SM_4C_ELC) },50// { .name = "Sun4c SparcStation IPX", .id_machtype = (SM_SUN4C | SM_4C_IPX) },51/* Finally, early Sun4m's */52// { .name = "Sun4m SparcSystem600", .id_machtype = (SM_SUN4M | SM_4M_SS60) },53// { .name = "Sun4m SparcStation10/20", .id_machtype = (SM_SUN4M | SM_4M_SS50) },54// { .name = "Sun4m SparcStation5", .id_machtype = (SM_SUN4M | SM_4M_SS40) },55/* One entry for the OBP arch's which are sun4d, sun4e, and newer sun4m's */56// { .name = "Sun4M OBP based system", .id_machtype = (SM_SUN4M_OBP | 0x0) }57};5859static void __init display_system_type(unsigned char machtype)60{61register int i;6263for (i = 0; i < NUM_SUN_MACHINES; i++) {64if(Sun_Machines[i].id_machtype == machtype) {65if (machtype != (SM_SUN4M_OBP | 0x00))66printk("TYPE: %s\n", Sun_Machines[i].name);67else {68#if 069prom_getproperty(prom_root_node, "banner-name",70sysname, sizeof(sysname));71printk("TYPE: %s\n", sysname);72#endif73}74return;75}76}7778prom_printf("IDPROM: Bogus id_machtype value, 0x%x\n", machtype);79prom_halt();80}8182void sun3_get_model(unsigned char* model)83{84register int i;8586for (i = 0; i < NUM_SUN_MACHINES; i++) {87if(Sun_Machines[i].id_machtype == idprom->id_machtype) {88strcpy(model, Sun_Machines[i].name);89return;90}91}92}93949596/* Calculate the IDPROM checksum (xor of the data bytes). */97static unsigned char __init calc_idprom_cksum(struct idprom *idprom)98{99unsigned char cksum, i, *ptr = (unsigned char *)idprom;100101for (i = cksum = 0; i <= 0x0E; i++)102cksum ^= *ptr++;103104return cksum;105}106107/* Create a local IDPROM copy, verify integrity, and display information. */108void __init idprom_init(void)109{110prom_get_idprom((char *) &idprom_buffer, sizeof(idprom_buffer));111112idprom = &idprom_buffer;113114if (idprom->id_format != 0x01) {115prom_printf("IDPROM: Unknown format type!\n");116prom_halt();117}118119if (idprom->id_cksum != calc_idprom_cksum(idprom)) {120prom_printf("IDPROM: Checksum failure (nvram=%x, calc=%x)!\n",121idprom->id_cksum, calc_idprom_cksum(idprom));122prom_halt();123}124125display_system_type(idprom->id_machtype);126127printk("Ethernet address: %x:%x:%x:%x:%x:%x\n",128idprom->id_ethaddr[0], idprom->id_ethaddr[1],129idprom->id_ethaddr[2], idprom->id_ethaddr[3],130idprom->id_ethaddr[4], idprom->id_ethaddr[5]);131}132133134