From patchwork Thu Mar 24 21:27:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Green X-Patchwork-Id: 778 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:45:43 -0000 Delivered-To: patches@linaro.org Received: by 10.42.161.68 with SMTP id s4cs135094icx; Thu, 24 Mar 2011 14:27:35 -0700 (PDT) Received: by 10.216.142.165 with SMTP id i37mr7564796wej.106.1301002053663; Thu, 24 Mar 2011 14:27:33 -0700 (PDT) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id o13si467043wee.160.2011.03.24.14.27.32 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 24 Mar 2011 14:27:33 -0700 (PDT) Received-SPF: pass (google.com: domain of andy.warmcat.com@googlemail.com designates 74.125.82.50 as permitted sender) client-ip=74.125.82.50; Authentication-Results: mx.google.com; spf=pass (google.com: domain of andy.warmcat.com@googlemail.com designates 74.125.82.50 as permitted sender) smtp.mail=andy.warmcat.com@googlemail.com; dkim=pass (test mode) header.i=@googlemail.com Received: by mail-ww0-f50.google.com with SMTP id 33so472552wwc.31 for ; Thu, 24 Mar 2011 14:27:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:sender:from:subject:to:cc:date:message-id :in-reply-to:references:user-agent:mime-version:content-type :content-transfer-encoding; bh=oPCkE+Sb4ilAgpBQ7VvGvZvsph3jCgrW8H1qfwPDn3E=; b=jT8aiimOQeetcXh0pn5S0f2QhigegOKDB/z00dkw4HL7L0Dcs0iK2pEPHAqGv4F/Es XaeTH/euI5gaSDIjY2r7tyqHEEr1iXf4/4EGCmo2UVrsTG3kJmSpyNdVHSEeO1bf+ztP iKxVXQbyCWobctoAH0ZG3Rpxm+a8DDhOo7DOg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=sender:from:subject:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; b=UbLQzCRG8Qr2gvyATY51zgrsHYP7hqg21RwQF91RXXyMVyjAQXqF2mDsL+yzCpi3mk +Ox4XUj0SOecVXH76idooC0QfbOtodrNwSKm5Bj1Ibin+RuFs/svRTMy5DZ9vfDuhjlV beyeod06fcqB752kbdXt2OIxvaUMcXIGf2fUU= Received: by 10.216.143.88 with SMTP id k66mr1285728wej.15.1301002052740; Thu, 24 Mar 2011 14:27:32 -0700 (PDT) Received: from otae.warmcat.com (s15404224.onlinehome-server.info [87.106.134.80]) by mx.google.com with ESMTPS id a50sm116179wer.18.2011.03.24.14.27.30 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 24 Mar 2011 14:27:32 -0700 (PDT) Sender: Andy Green From: Andy Green Subject: [RFC PATCH 1/2] OMAP2+: add cpu id register to MAC address helper To: linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org Cc: patches@linaro.org, nicolas.pitre@linaro.org, arnd@arndb.de, x0132446@ti.com, s-jan@ti.com, tony@atomide.com, Andy Green Date: Thu, 24 Mar 2011 21:27:29 +0000 Message-ID: <20110324212729.14936.98130.stgit@otae.warmcat.com> In-Reply-To: <20110324211451.14936.39750.stgit@otae.warmcat.com> References: <20110324211451.14936.39750.stgit@otae.warmcat.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Introduce a generic helper function that can set a MAC address using data from the OMAP unique CPU ID register. For comparison purposes this produces a MAC address of 2e:40:70:f0:12:06 for the ethernet device on my Panda. Note that this patch requires the fix patch for CPU ID register indexes previously posted to linux-omap, otherwise the CPU ID is misread on Panda by the existing function to do it. This patch is already on linux-omap. "OMAP2+:Common CPU DIE ID reading code reads wrong registers for OMAP4430" http://git.kernel.org/?p=linux/kernel/git/tmlind/linux-omap-2.6.git;a=commit;h=b235e007831dbf57710e59cd4a120e2f374eecb9 Signed-off-by: Andy Green Acked-by: Arnd Bergmann --- arch/arm/mach-omap2/id.c | 39 +++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/include/mach/id.h | 1 + 2 files changed, 40 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c index 2537090..e46b430 100644 --- a/arch/arm/mach-omap2/id.c +++ b/arch/arm/mach-omap2/id.c @@ -557,3 +557,42 @@ void __init omap2_set_globals_tap(struct omap_globals *omap2_globals) else tap_prod_id = 0x0208; } + +/* + * this uses the unique per-cpu info from the cpu fuses set at factory to + * generate a 6-byte MAC address. Two bits in the generated code are used + * to elaborate the generated address into four, so it can be used on multiple + * network interfaces. + */ + +void omap2_die_id_to_ethernet_mac(u8 *mac, int subtype) +{ + struct omap_die_id odi; + u32 tap = read_tap_reg(OMAP_TAP_IDCODE); + + omap_get_die_id(&odi); + + mac[0] = odi.id_2; + mac[1] = odi.id_2 >> 8; + mac[2] = odi.id_1; + mac[3] = odi.id_1 >> 8; + mac[4] = odi.id_1 >> 16; + mac[5] = odi.id_1 >> 24; + + /* XOR other chip-specific data with ID */ + + tap ^= odi.id_3; + + mac[0] ^= tap; + mac[1] ^= tap >> 8; + mac[2] ^= tap >> 16; + mac[3] ^= tap >> 24; + + /* allow four MACs from this same basic data */ + + mac[1] = (mac[1] & ~0xc0) | ((subtype & 3) << 6); + + /* mark it as not multicast and outside official 80211 MAC namespace */ + + mac[0] = (mac[0] & ~1) | 2; +} diff --git a/arch/arm/mach-omap2/include/mach/id.h b/arch/arm/mach-omap2/include/mach/id.h index 02ed3aa..373313a 100644 --- a/arch/arm/mach-omap2/include/mach/id.h +++ b/arch/arm/mach-omap2/include/mach/id.h @@ -18,5 +18,6 @@ struct omap_die_id { }; void omap_get_die_id(struct omap_die_id *odi); +void omap2_die_id_to_ethernet_mac(u8 *mac, int subtype); #endif