From patchwork Wed Sep 2 16:05:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Kiryanov X-Patchwork-Id: 513560 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 2C2B914018C for ; Thu, 3 Sep 2015 02:08:25 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=compulab.co.il header.i=@compulab.co.il header.b=nt7qf839; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 46A434B746; Wed, 2 Sep 2015 18:08:10 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qYMn71Lxdvqu; Wed, 2 Sep 2015 18:08:10 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CCB7C4B788; Wed, 2 Sep 2015 18:08:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 829644B71D for ; Wed, 2 Sep 2015 18:07:47 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id g2mDJhwLs-EK for ; Wed, 2 Sep 2015 18:07:47 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from compulab.co.il (softlayer.compulab.co.il [50.23.254.55]) by theia.denx.de (Postfix) with ESMTPS id 1FA0A4B721 for ; Wed, 2 Sep 2015 18:07:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=compulab.co.il; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=7yv/nb8elf0454fbFWVjYkcjKp8Z015HOXgqgv0ScRg=; b=nt7qf839Q2Hsb19UhHjYoU4EkSO2HDjj28dXa99t/acut1yNKRF888K/d1lvWuRU37bhyuvINQ2fvnBFOl2XQRSfOcg2UIJJf2lIwDWgT1Fl2OmbRf+hAKXaZghys7VkqA41dNPexBH7uFZ8ktYx7e/J9sYJaNY62PNtKhY2BEA=; Received: from [62.90.235.247] (port=5229 helo=zimbra-mta.compulab.co.il) by softlayer.compulab.co.il with esmtp (Exim 4.85) (envelope-from ) id 1ZXAZa-0004Vl-0z; Wed, 02 Sep 2015 19:07:42 +0300 Received: from localhost (localhost [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 314DB48726E; Wed, 2 Sep 2015 19:07:41 +0300 (IDT) Received: from zimbra-mta.compulab.co.il ([127.0.0.1]) by localhost (zimbra-mta.compulab.co.il [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id espJKUqvhSnk; Wed, 2 Sep 2015 19:07:40 +0300 (IDT) Received: from localhost (localhost [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id B62F7487257; Wed, 2 Sep 2015 19:07:40 +0300 (IDT) X-Virus-Scanned: amavisd-new at zimbra-mta.compulab.co.il Received: from zimbra-mta.compulab.co.il ([127.0.0.1]) by localhost (zimbra-mta.compulab.co.il [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 0zi1gcl99xIi; Wed, 2 Sep 2015 19:07:40 +0300 (IDT) Received: from skynet.compulab.local (nikita-pc.compulab.local [192.168.11.211]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 7D879487265; Wed, 2 Sep 2015 19:07:40 +0300 (IDT) From: Nikita Kiryanov To: u-boot@lists.denx.de Date: Wed, 2 Sep 2015 19:05:19 +0300 Message-Id: <1441209920-10583-3-git-send-email-nikita@compulab.co.il> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441209920-10583-1-git-send-email-nikita@compulab.co.il> References: <1441209920-10583-1-git-send-email-nikita@compulab.co.il> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - softlayer.compulab.co.il X-AntiAbuse: Original Domain - lists.denx.de X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - compulab.co.il X-Get-Message-Sender-Via: softlayer.compulab.co.il: acl_c_relayhosts_text_entry: nikita@compulab.co.il|compulab.co.il Subject: [U-Boot] [PATCH 2/3] compulab: eeprom: add support for obtaining product name X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Introduce cl_eeprom_get_product_name() for obtaining product name from the eeprom. Cc: Stefano Babic Cc: Igor Grinberg Signed-off-by: Nikita Kiryanov --- board/compulab/common/eeprom.c | 19 +++++++++++++++++++ board/compulab/common/eeprom.h | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/board/compulab/common/eeprom.c b/board/compulab/common/eeprom.c index aaacd2e..a48da93 100644 --- a/board/compulab/common/eeprom.c +++ b/board/compulab/common/eeprom.c @@ -25,6 +25,8 @@ #define BOARD_REV_OFFSET 0 #define BOARD_REV_OFFSET_LEGACY 6 #define BOARD_REV_SIZE 2 +#define BOARD_PRODUCT_NAME_OFFSET 128 +#define BOARD_PRODUCT_NAME_SIZE 16 #define MAC_ADDR_OFFSET 4 #define MAC_ADDR_OFFSET_LEGACY 0 @@ -149,3 +151,20 @@ u32 cl_eeprom_get_board_rev(uint eeprom_bus) return board_rev; }; + +static char product_name[BOARD_PRODUCT_NAME_SIZE]; +char *cl_eeprom_get_product_name(uint eeprom_bus) +{ + if (cl_eeprom_setup(eeprom_bus)) + return NULL; + + if (cl_eeprom_read(BOARD_PRODUCT_NAME_OFFSET, + (uchar *)product_name, BOARD_PRODUCT_NAME_SIZE)) { + return NULL; + } + + /* Protect ourselves from invalid data (unterminated string) */ + product_name[BOARD_PRODUCT_NAME_SIZE - 1] = '\0'; + + return product_name; +} diff --git a/board/compulab/common/eeprom.h b/board/compulab/common/eeprom.h index e74c379..fceb5df 100644 --- a/board/compulab/common/eeprom.h +++ b/board/compulab/common/eeprom.h @@ -13,6 +13,7 @@ #ifdef CONFIG_SYS_I2C int cl_eeprom_read_mac_addr(uchar *buf, uint eeprom_bus); u32 cl_eeprom_get_board_rev(uint eeprom_bus); +char *cl_eeprom_get_product_name(uint eeprom_bus); #else static inline int cl_eeprom_read_mac_addr(uchar *buf, uint eeprom_bus) { @@ -22,6 +23,10 @@ static inline u32 cl_eeprom_get_board_rev(uint eeprom_bus) { return 0; } +static inline char *cl_eeprom_get_product_name(uint eeprom_bus) +{ + return NULL; +} #endif #endif