From patchwork Wed Jul 1 17:26:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 1321306 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=collabora.com Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49yFyB0tQzz9sPF for ; Thu, 2 Jul 2020 21:20:34 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A85E482240; Thu, 2 Jul 2020 13:14:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id BED778006D; Wed, 1 Jul 2020 19:27:12 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 682DC81B62 for ; Wed, 1 Jul 2020 19:27:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sebastian.reichel@collabora.com Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 0DEB82A54FB Received: by jupiter.universe (Postfix, from userid 1000) id 313FB480110; Wed, 1 Jul 2020 19:26:57 +0200 (CEST) From: Sebastian Reichel To: Sebastian Reichel , Stefano Babic , Fabio Estevam , "NXP i.MX U-Boot Team" Cc: Jaehoon Chung , Simon Glass , u-boot@lists.denx.de Subject: [PATCH 11/12] board: ge: common: vpd: separate I2C specific code Date: Wed, 1 Jul 2020 19:26:24 +0200 Message-Id: <20200701172625.121978-12-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200701172625.121978-1-sebastian.reichel@collabora.com> References: <20200701172625.121978-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 02 Jul 2020 13:12:53 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean This separates the I2C specific code from the generic GE vital product data code, so that the generic parts can be used on hardware with VPD stored in SPI flash memory. Signed-off-by: Sebastian Reichel --- board/ge/bx50v3/bx50v3.c | 2 +- board/ge/common/vpd_reader.c | 12 ++++++------ board/ge/common/vpd_reader.h | 23 +++++++++++++++++++---- board/ge/mx53ppd/mx53ppd.c | 2 +- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/board/ge/bx50v3/bx50v3.c b/board/ge/bx50v3/bx50v3.c index 50a7070f8126..8343fdec26a6 100644 --- a/board/ge/bx50v3/bx50v3.c +++ b/board/ge/bx50v3/bx50v3.c @@ -429,7 +429,7 @@ static void set_confidx(const struct vpd_cache* vpd) int board_init(void) { - if (!read_vpd(&vpd, vpd_callback)) { + if (!read_i2c_vpd(&vpd, vpd_callback)) { int ret, rescan; vpd.is_read = true; diff --git a/board/ge/common/vpd_reader.c b/board/ge/common/vpd_reader.c index d42b00da2fe6..421fee592291 100644 --- a/board/ge/common/vpd_reader.c +++ b/board/ge/common/vpd_reader.c @@ -110,9 +110,9 @@ static const size_t HEADER_BLOCK_ECC_LEN = 4; static const u8 ECC_BLOCK_ID = 0xFF; -static int vpd_reader(size_t size, u8 *data, struct vpd_cache *userdata, - int (*fn)(struct vpd_cache *, u8 id, u8 version, u8 type, - size_t size, u8 const *data)) +int vpd_reader(size_t size, u8 *data, struct vpd_cache *userdata, + int (*fn)(struct vpd_cache *, u8 id, u8 version, u8 type, + size_t size, u8 const *data)) { if (size < HEADER_BLOCK_LEN || !data || !fn) return -EINVAL; @@ -200,9 +200,9 @@ static int vpd_reader(size_t size, u8 *data, struct vpd_cache *userdata, } } -int read_vpd(struct vpd_cache *cache, - int (*process_block)(struct vpd_cache *, u8 id, u8 version, - u8 type, size_t size, u8 const *data)) +int read_i2c_vpd(struct vpd_cache *cache, + int (*process_block)(struct vpd_cache *, u8 id, u8 version, + u8 type, size_t size, u8 const *data)) { struct udevice *dev; int ret; diff --git a/board/ge/common/vpd_reader.h b/board/ge/common/vpd_reader.h index 3045b7e21e22..0c51dc57e902 100644 --- a/board/ge/common/vpd_reader.h +++ b/board/ge/common/vpd_reader.h @@ -16,7 +16,22 @@ struct vpd_cache; * * Returns Non-zero on error. Negative numbers encode errno. */ -int read_vpd(struct vpd_cache *cache, - int (*process_block)(struct vpd_cache *, - u8 id, u8 version, u8 type, - size_t size, u8 const *data)); +int read_i2c_vpd(struct vpd_cache *cache, + int (*process_block)(struct vpd_cache *, u8 id, u8 version, + u8 type, size_t size, u8 const *data)); + +/* + * Read VPD from given data, verify content, call callback for each vital + * product data block. + * + * size: size of the raw VPD data in bytes + * data: raw VPD data read from device + * cache: structure used by process block to store VPD information + * process_block: callback called for each VPD data block + * + * Returns Non-zero on error. Negative numbers encode errno. + */ + +int vpd_reader(size_t size, u8 *data, struct vpd_cache *cache, + int (*process_block)(struct vpd_cache *, u8 id, u8 version, u8 type, + size_t size, u8 const *data)); diff --git a/board/ge/mx53ppd/mx53ppd.c b/board/ge/mx53ppd/mx53ppd.c index d8cfa3cb4556..302eb24ce4c0 100644 --- a/board/ge/mx53ppd/mx53ppd.c +++ b/board/ge/mx53ppd/mx53ppd.c @@ -225,7 +225,7 @@ int board_late_init(void) struct vpd_cache vpd; memset(&vpd, 0, sizeof(vpd)); - res = read_vpd(&vpd, vpd_callback); + res = read_i2c_vpd(&vpd, vpd_callback); if (!res) process_vpd(&vpd); else