From patchwork Tue Mar 13 12:00:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 131442 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp641165ljb; Tue, 13 Mar 2018 05:04:15 -0700 (PDT) X-Google-Smtp-Source: AG47ELulA2FQmY6+RQh0m9k+xqk2KiwXvIRJhEQPeV6mY4XzuVJdQXRoZ8x3UI4f7b0+Lv8cdiW6 X-Received: by 10.80.152.80 with SMTP id h16mr631751edb.113.1520942654951; Tue, 13 Mar 2018 05:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520942654; cv=none; d=google.com; s=arc-20160816; b=uAYaGFkISQibq5GPOzIIBi8Y0IXQxiOCuQV1TXBtzXqH9F9goJOGdk2YQlVE7G8LLh BiequfbW98a+zd87zhiUHOZHV4htw/XA0Rkdd4R8DgvDYOr50dPuJ47wKbTrSe7dGIDR hGhlcpLmeOfdoaOxe6TUbB34280hH4FUOWP8t85Zr2jj1NAy371hwWL/GoYDN86vR1Am TuqZmfIQFGo5nJ06qSNwfadxECJJCMZIM2XW9STAXPgUrg6KUPaBgX9+O3MioCx+RbuS YquIXfsWxhnOazd9du0MxGmtAIPNq2D/B+5KMssZ2HfMX+0Kb2amdwKic/tlGHbmmlo+ E4tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:arc-authentication-results; bh=Qh//s571ZlC0EA2BAIGDO9f5cIn8QMCp2dCC7irOu2U=; b=VupnD33THkIKmjodRmU8oveYYU0skp0lFvlIFRy9b+X9WUH5yoPOks9PJ9yCEnMEFF n1fOSNnR/GHBVsI8YG68MgHBxn/2l9rlOEW21ramUUXRV2yHP1GFvbN9JmZ7B6bRIFl0 +trJqd8NT4PoUCQmaPblUPMMT/JeqALw/j8PutH7s5iEEcFqdSEen8kRVfDnpc1ZNLlF 5WkXaoBTXRG+dm6KnAPfhYC+YEtb2LPH4gYiU0c9aWdh+YcK8jniwPtjb6OByPWLXwoz wOzyEPvFLi2TAqkL8ZrbkEzPwPCKg8nzc6sEhA23i60j+dJSj72YH0+bA6mpcSiq7q45 F2lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=BbLWVh5s; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id m5si36291edd.209.2018.03.13.05.04.14; Tue, 13 Mar 2018 05:04:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=BbLWVh5s; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 7CE2EC21DED; Tue, 13 Mar 2018 12:03:41 +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_MSPIKE_H2, 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 75B7EC21E15; Tue, 13 Mar 2018 12:01:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 845A1C21D4A; Tue, 13 Mar 2018 12:01:52 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by lists.denx.de (Postfix) with ESMTPS id 4CCDDC21DC1 for ; Tue, 13 Mar 2018 12:00:33 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id m4so9066398wrb.7 for ; Tue, 13 Mar 2018 05:00:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BRO3EU+H5PkBTdpVKUGT9ZGNZHepqYt9czcZwNly938=; b=BbLWVh5sZM+sCpMfuK/FC1nHTGT40xvUWsJyI4OybuxZlHGIC2q3VMosd5BeApwMtz 7QoQiqYqatLPtX5CA811e6nLjVM/e5SYxQPx3k3Tk5jD2UIhSXBrY4yigxHdZdiPio+s 9jhvkBZUEToEznN6fVKnMnXUAFN8BDK1Y5dSk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BRO3EU+H5PkBTdpVKUGT9ZGNZHepqYt9czcZwNly938=; b=sGa2o/jGpqhG8dDegBYkudjYjTWCLPW8OrnS6SBd+3B7mQkSW0sBVYL81k29zm/ZcT zuieJud3Ni9tUgaBLwSeHBbSK04S17Suh/MqRHsNamld79BfuCOggq8T5GYFGSPTJ1iQ VOTtDcDnLjH0CvgmnFO19ckoMWKgNkuM9BuCh1boIG+Q2B9/H8FD43zGm//rThz8G9k+ SbDHwxst4novbkpp7M+MEFxe0zkGW9BmriGzOq2vvVGoQjQEdQncjUmEwn/HvrzFibMB aYKMm/F7MADSK5efzxaZxHA/A2OOEs2sa/AX2L705EUFGsnSIgDQ4ZPsz9Ub79QgiSDq pJHw== X-Gm-Message-State: AElRT7F9EP0KhMVJb2qhRb3cbXFOPZoRD1+GQv9YlZq4vtWoj20tpjbm 3VBII3WnR4VJks0uYPp2PV22noBMc+8= X-Received: by 10.80.217.136 with SMTP id w8mr616836edj.193.1520942432641; Tue, 13 Mar 2018 05:00:32 -0700 (PDT) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id t23sm39130edb.54.2018.03.13.05.00.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Mar 2018 05:00:31 -0700 (PDT) From: Bryan O'Donoghue To: U-Boot@lists.denx.de Date: Tue, 13 Mar 2018 12:00:27 +0000 Message-Id: <1520942427-7366-3-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520942427-7366-1-git-send-email-bryan.odonoghue@linaro.org> References: <1520942427-7366-1-git-send-email-bryan.odonoghue@linaro.org> Cc: fabio.estevam@nxp.com, rui.silva@linaro.org Subject: [U-Boot] [PATCH 2/2] warp7: usb: Set u-boot serial# based on OTP value 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" u-boot has a standard "serial#" environment variable that is suitable for storing the iSerial number we will supply via the USB device descriptor. serial# is automatically picked up by the disk subsystem in u-boot - thus providing a handy unique identifier in /dev/disk/by-id as detailed below. Storing the hardware serial identifier in serial# means we can change the serial# if we want before USB enumeration - thus making iSerial automatic via OTP but overridable if necessary. This patch reads the defined OTP fuse and sets environment variable "serial#" to the value read. If there is any error in reading the value the boot will continue and "serial#" will be set to zero. With this patch in place the USB mass storage device will appear in /dev/disk/by-id with a unique name based on the OTP value. For example /dev/disk/by-id/usb-Linux_UMS_disk_0_WaRP7-0xf42400d3000000d4-0:0 Signed-off-by: Bryan O'Donoghue Cc: Fabio Estevam Reviewed-by: Rui Miguel Silva Reviewed-by: Ryan Harkin --- board/warp7/warp7.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/board/warp7/warp7.c b/board/warp7/warp7.c index 2cec448..a27993f 100644 --- a/board/warp7/warp7.c +++ b/board/warp7/warp7.c @@ -239,6 +239,9 @@ int board_usb_phy_mode(int port) int board_late_init(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; + u64 serial_id = 0; + char serial_string[0x20]; + int ret; imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads)); @@ -250,5 +253,14 @@ int board_late_init(void) */ clrsetbits_le16(&wdog->wcr, 0, 0x10); + /* Set serial# standard environment variable based on OTP settings */ + ret = warp7_get_serialid(&serial_id); + if (ret) + printf("error %d reading from serial# OTP fuse\n", ret); + + snprintf(serial_string, sizeof(serial_string), "WaRP7-0x%016llx", + serial_id); + env_set("serial#", serial_string); + return 0; }