From patchwork Sun Jan 2 19:40:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Ravnborg X-Patchwork-Id: 77198 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 2FC4EB70B3 for ; Mon, 3 Jan 2011 06:40:30 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752833Ab1ABTk0 (ORCPT ); Sun, 2 Jan 2011 14:40:26 -0500 Received: from pfepb.post.tele.dk ([195.41.46.236]:60626 "EHLO pfepb.post.tele.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752511Ab1ABTk0 (ORCPT ); Sun, 2 Jan 2011 14:40:26 -0500 Received: from merkur.ravnborg.org (x1-6-00-1e-2a-84-ae-3e.k225.webspeed.dk [80.163.61.94]) by pfepb.post.tele.dk (Postfix) with ESMTP id A8C2CF8401E; Sun, 2 Jan 2011 20:40:24 +0100 (CET) Date: Sun, 2 Jan 2011 20:40:24 +0100 From: Sam Ravnborg To: David Miller Cc: kristoffer@gaisler.com, sparclinux@vger.kernel.org Subject: [RFC PATCH] sparc: fake idprom for leon Message-ID: <20110102194024.GA31924@merkur.ravnborg.org> References: <1259679176-29835-1-git-send-email-kristoffer@gaisler.com> <1259679176-29835-3-git-send-email-kristoffer@gaisler.com> <20091201182116.GC25617@merkur.ravnborg.org> <20091201.155026.149143235.davem@davemloft.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20091201.155026.149143235.davem@davemloft.net> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org Hi Kristoffer & David. Following is a very naive implementation of a fake idprom for leon. This is only for inspiration as I hope that it is possible to find the MAC address somehow so we present it correct. One advantage of using a fake idprom is that all places that do access idprom no longer needs to be ifdeffed out. Today floppy.h reads idprom unconditionally. Sam --- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/sparc/prom/misc_32.c b/arch/sparc/prom/misc_32.c index 4d61c54..ee5fe45 100644 --- a/arch/sparc/prom/misc_32.c +++ b/arch/sparc/prom/misc_32.c @@ -10,7 +10,9 @@ #include #include +#include #include +#include #include #include #include @@ -93,6 +95,42 @@ prom_setsync(sfunc_t funcp) *romvec->pv_synchook = funcp; } +#ifdef CONFIG_SPARC_LEON +/* + * leon do not have idprom support - so fake it. + * The machine type is hardcoded to M_LEON + * We do not know the ethernet address so it is all-zero. + */ + +/* Calculate the IDPROM checksum (xor of the data bytes). */ +static unsigned char 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; +} + +unsigned char +prom_get_idprom(char *idbuf, int num_bytes) +{ + struct idprom *idprom; + + if (num_bytes < sizeof(struct idprom)) + return 0xff; + + idprom = (struct idprom *)idbuf; + memset(idprom, 0, sizeof(*idprom)); + idprom->id_format = 0x01; + idprom->id_machtype = M_LEON | M_LEON3_SOC; + idprom->id_cksum = calc_idprom_cksum(idprom); + + return 0x01; +} + +#else /* Get the idprom and stuff it into buffer 'idbuf'. Returns the * format type. 'num_bytes' is the number of bytes that your idbuf * has space for. Returns 0xff on error. @@ -109,7 +147,7 @@ prom_get_idprom(char *idbuf, int num_bytes) return 0xff; } - +#endif /* Get the major prom version number. */ int prom_version(void)