From patchwork Thu Sep 9 19:40:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Williamson X-Patchwork-Id: 165131 Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o89JgsTK016302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 9 Sep 2010 19:43:31 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id o89Jf1d9031174 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 9 Sep 2010 14:41:01 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id o89Jf07R013899; Thu, 9 Sep 2010 14:41:01 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id DA19780627; Thu, 9 Sep 2010 14:41:00 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id B0C1280626 for ; Thu, 9 Sep 2010 14:40:59 -0500 (CDT) Received: from white.ext.ti.com (localhost [127.0.0.1]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id o89Jewgw024453 for ; Thu, 9 Sep 2010 14:40:58 -0500 (CDT) Received: from psmtp.com (na3sys009amx185.postini.com [74.125.149.166]) by white.ext.ti.com (8.13.7/8.13.7) with SMTP id o89Jev1N025517 for ; Thu, 9 Sep 2010 14:40:57 -0500 Received: from source ([209.85.212.45]) by na3sys009amx185.postini.com ([74.125.148.10]) with SMTP; Thu, 09 Sep 2010 14:40:58 CDT Received: by vws19 with SMTP id 19so1760178vws.4 for ; Thu, 09 Sep 2010 12:40:57 -0700 (PDT) Received: by 10.220.163.10 with SMTP id y10mr363889vcx.203.1284061256862; Thu, 09 Sep 2010 12:40:56 -0700 (PDT) Received: from localhost.localdomain (rrcs-24-39-249-130.nys.biz.rr.com [24.39.249.130]) by mx.google.com with ESMTPS id s18sm849002vck.20.2010.09.09.12.40.55 (version=SSLv3 cipher=RC4-MD5); Thu, 09 Sep 2010 12:40:55 -0700 (PDT) From: Michael Williamson To: davinci-linux-open-source@linux.davincidsp.com Subject: [PATCH] davinci: MityDSP-L138/MityARM-1808 read MAC address from I2C Prom Date: Thu, 9 Sep 2010 15:40:57 -0400 Message-Id: <1284061257-9017-1-git-send-email-michael.williamson@criticallink.com> X-Mailer: git-send-email 1.7.0.4 X-pstn-levels: (S:81.14238/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.0750) s cv GT3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] Cc: linux@arm.linux.org.uk X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 09 Sep 2010 19:43:31 +0000 (UTC) diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c index e872fcc..e1cffb8 100644 --- a/arch/arm/mach-davinci/board-mityomapl138.c +++ b/arch/arm/mach-davinci/board-mityomapl138.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -24,6 +25,59 @@ #include #include +#define FACTORY_CONFIG_MAGIC 0x012C0138 +#define FACTORY_CONFIG_VERSION 0x00010001 + +/* Data Held in On-Board I2C device */ +struct factory_config { + uint32_t magic; + uint32_t version; + uint8_t mac[6]; + uint32_t fpga_type; + uint32_t spare; + uint32_t serialnumber; + char partnum[32]; +}; + +static struct factory_config factory_config; + +static void read_factory_config(struct memory_accessor *a, void *context) +{ + int ret; + struct davinci_soc_info *soc_info = &davinci_soc_info; + + ret = a->read(a, (char *)&factory_config, 0, sizeof(factory_config)); + if (ret != sizeof(struct factory_config)) { + pr_warning("Read Factory Config Failed: %d\n", ret); + return; + } + + if (factory_config.magic != FACTORY_CONFIG_MAGIC) { + pr_warning("Factory Config Magic Wrong (%X)\n", + factory_config.magic); + return; + } + + if (factory_config.version != FACTORY_CONFIG_VERSION) { + pr_warning("Factory Config Version Wrong (%X)\n", + factory_config.version); + return; + } + + pr_info("Found MAC = %pM\n", factory_config.mac); + pr_info("Part Number = %s\n", factory_config.partnum); + memcpy(&soc_info->emac_pdata->mac_addr[0], + &factory_config.mac[0], 6); +} + +static struct at24_platform_data mityomapl138_fd_chip = { + .byte_len = 256, + .page_size = 8, + .flags = AT24_FLAG_READONLY | AT24_FLAG_IRUGO, + .setup = read_factory_config, + .context = NULL, +}; + static struct davinci_i2c_platform_data mityomap_i2c_0_pdata = { .bus_freq = 100, /* kHz */ .bus_delay = 0, /* usec */ @@ -150,6 +204,7 @@ static struct i2c_board_info __initdata mityomap_tps65023_info[] = { }, { I2C_BOARD_INFO("24c02", 0x50), + .platform_data = &mityomapl138_fd_chip, }, };