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: 660541 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2OLRSjZ007434 for ; Thu, 24 Mar 2011 21:27:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756780Ab1CXV1e (ORCPT ); Thu, 24 Mar 2011 17:27:34 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:56562 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756465Ab1CXV1d (ORCPT ); Thu, 24 Mar 2011 17:27:33 -0400 Received: by mail-ww0-f44.google.com with SMTP id 36so456497wwa.1 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) 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 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 24 Mar 2011 21:27:35 +0000 (UTC) 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