From patchwork Wed May 16 14:39:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 914676 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="POD46rxz"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40mHFf3TDFz9s2k for ; Thu, 17 May 2018 00:41:58 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 1BD7BC21F8A; Wed, 16 May 2018 14:41:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 29A4AC21F42; Wed, 16 May 2018 14:40:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 314C8C21D83; Wed, 16 May 2018 14:40:00 +0000 (UTC) Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) by lists.denx.de (Postfix) with ESMTPS id B8DC9C21EA6 for ; Wed, 16 May 2018 14:39:59 +0000 (UTC) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 78BFB60591; Wed, 16 May 2018 16:39:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1526481599; bh=jJ8on3i2Jx5XfWs+qZ4YCgtZOIwcyf0QbKCY2Unxjv0=; h=From:To:Date; b=POD46rxzKWtZDuSaeiwuegT8ZkZRcSWmZijP4YDhb6DfKpZaf4dp3/NYlv6DlCtpC +1mOqqfJU5ZBS9O+AFmWIfn9mg2gH52+VGwPpOaYcU8ztpvPB4CleZnwmv6hBB8y3a YrMh0mY1sh0qxJnaWb1skS61GvL7lA7KZE4gmKJ4= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de Date: Wed, 16 May 2018 16:39:41 +0200 Message-Id: <20180516143942.2309-4-marek.behun@nic.cz> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180516143942.2309-1-marek.behun@nic.cz> References: <20180516143942.2309-1-marek.behun@nic.cz> X-Virus-Scanned: clamav-milter 0.99.2 at mail X-Virus-Status: Clean Cc: Stefan Roese Subject: [U-Boot] [PATCH 3/4] board: turris_mox: Support differentiating SD version from eMMC X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" The first byte of the string read from SPI bus from which Mox module toplogy is detected contains ID of the CPU module. This ID can differentiate between the version with SD card slot and the one with eMMC card. Signed-off-by: Marek Behun diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index f7fb2c2955..c8ead5d67b 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -54,8 +54,16 @@ int board_init(void) return 0; } -static int mox_read_topology(const u8 **ptopology, int *psize) +typedef enum { + MOX_UNKNOWN, + MOX_EMMC, + MOX_SD +} mox_version_t; + +static int mox_read_topology(const u8 **ptopology, int *psize, + mox_version_t *pversion) { + static mox_version_t mox_version; static u8 topology[9]; static int size = 0; struct spi_slave *slave; @@ -64,8 +72,12 @@ static int mox_read_topology(const u8 **ptopology, int *psize) int ret, i; if (size) { - *ptopology = topology; - *psize = size; + if (ptopology) + *ptopology = topology; + if (psize) + *psize = size; + if (pversion) + *pversion = mox_version; return 0; } @@ -85,7 +97,17 @@ static int mox_read_topology(const u8 **ptopology, int *psize) if (ret) goto fail_release; - if (din[0] != 0x00 && din[0] != 0xff) { + switch (din[0]) { + case 0x00: + mox_version = MOX_EMMC; + break; + case 0x10: + mox_version = MOX_SD; + break; + case 0xff: + mox_version = MOX_UNKNOWN; + break; + default: ret = -ENODEV; goto fail_release; } @@ -94,8 +116,12 @@ static int mox_read_topology(const u8 **ptopology, int *psize) topology[i-1] = din[i] & 0xf; size = i-1; - *ptopology = topology; - *psize = size; + if (ptopology) + *ptopology = topology; + if (psize) + *psize = size; + if (pversion) + *pversion = mox_version; fail_release: spi_release_bus(slave); @@ -110,7 +136,7 @@ void board_update_comphy_map(struct comphy_map *serdes_map, int count) int ret, i, size, has = 0; const u8 *topology; - ret = mox_read_topology(&topology, &size); + ret = mox_read_topology(&topology, &size, NULL); if (ret) return; @@ -139,13 +165,17 @@ int last_stage_init(void) size_t len = 0; const u8 *topology; char module_topology[128]; + mox_version_t version; - ret = mox_read_topology(&topology, &size); + ret = mox_read_topology(&topology, &size, &version); if (ret) { printf("Cannot read module topology!\n"); return 0; } + printf("Found Turris Mox %s version\n", version == MOX_SD ? "SD" : + version == MOX_EMMC ? "eMMC" : + "unknown"); printf("Module Topology:\n"); for (i = 0; i < size; ++i) { size_t mlen; @@ -179,6 +209,8 @@ int last_stage_init(void) module_topology[len > 0 ? len - 1 : 0] = '\0'; env_set("module_topology", module_topology); + env_set("mox_version", version == MOX_SD ? "sd" : + version == MOX_EMMC ? "emmc" : ""); return 0; }