From patchwork Tue Mar 13 12:00:26 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: 131441 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp640561ljb; Tue, 13 Mar 2018 05:03:47 -0700 (PDT) X-Google-Smtp-Source: AG47ELsDehTxahQyQEaBOvS7caSNKzbdwFYPuI8bg142L2Y2CufvYql955DFVXhiZFiGBue6Ov4P X-Received: by 10.80.186.79 with SMTP id 15mr622337eds.167.1520942627435; Tue, 13 Mar 2018 05:03:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520942627; cv=none; d=google.com; s=arc-20160816; b=eBOzhGqgtnIve3qDbPiQ+CXAQTgWjv8UwYUtP7bKZDMM7x2taJrapckynqEHvb9zNL LYFKKjswpx8U9roHEeTo/yUUkSLTZLYZp+5ObxJVHSsJCr0qXwQP5qqxFqHuLld+ZtQ+ ZSSkq1mZDiQhn4BDAasRVKjOJG3e3xJ9yooY5KstDeieL3DKwPcGMkEtKoPAXsk7ojKB gkwNP7CnZVnujcFYU6GxqZLuWV9kJmJ3bg7/rKacxG4WIjqocP0hpS/kq6nztFilTIYa xfFAApyVzhV8uAtPzHTelM56jjjSZmhDsK4dGN2PscL94RNLtMOAgp6dCdkasyD7nG/+ EIVg== 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=HTCy0aUe83B+u9CpmtZvLsvIcvy0f22XCG3r1/ulaTE=; b=ncrZ8/hq8a+AtoFiDeo7obUjGqLVemMw82QBQdXRfT2H8nNxBgtk8IqWJ0LJl3aQLY 8+18zNTAhnUyB0EO/iVrSrI4A1OORMvezvvLpOsWTVuNm8PcaqaWjvVoWZ8lFvGW2JtA r/qPq48t9MDrvli50FlAnE19OnB0409tZRupLP7Q91PEbDdC6bt9aEYAFzxDJhnoMzRj jAGgiUKEnE06lrzVcIt3aY0LdSObFF1pCOX44U5SnAAlwbqh6i3aQLA7FSQyhoniLe4m cqfEFdzwDTtpLXayT2eWAjHQiPDUowI2o1ciqouK8C+guwai3xiHIg3ivV1Mcfh82LKs dQjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Mv3KT5l0; 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 m13si30726edi.305.2018.03.13.05.03.47; Tue, 13 Mar 2018 05:03:47 -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=Mv3KT5l0; 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 E10DBC21E15; Tue, 13 Mar 2018 12:03:22 +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 D827BC21E07; Tue, 13 Mar 2018 12:01:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 86AC4C21C2F; Tue, 13 Mar 2018 12:01:51 +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 39B7FC21D4A for ; Tue, 13 Mar 2018 12:00:32 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id s18so7936626wrg.9 for ; Tue, 13 Mar 2018 05:00:32 -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=J+vTUWRSZsTyuZCf0w6fyQq5wgRfN9zDPPdK9SFmdcg=; b=Mv3KT5l0CrwDB7YfXsf7x7C/1DWjbxgFg1v093fM+BnS4fPgINMH/oCQe30GMICfaX jLEtFWn/8DjF8mDDC3Pn8q1dlKhI6YdcYLiE3m+XKSlw4r8N/I/veS1Hk5eNRTv9ae76 8ipt5UrwIgnTyG8uOwFiFYYF56xQltFLWGYNo= 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=J+vTUWRSZsTyuZCf0w6fyQq5wgRfN9zDPPdK9SFmdcg=; b=Hj3sM961ntCQzsuMMCvu0Haq010pHapxSZCkvF3I7NgA2hEwwLXGSeDNOHmKLJp2HL +CNdFEtAxmoV1HAbAGdCqGd4xIlV9li+CmkhsApZRek5kPhTRbp+BhPM7illZ3wTwCIc 3e82t6GWSETLvrhqhCk8YxaKzwFAcpfFFQDd693vGDlDUMxgha4pUxJqhTKDGtCyzIRc DOVa8E/bnMscvcE3iVWPBUhj7jcowX1vxLzgROcvIgcz5VusmpEKc/ZAWTohCINa7Fvb APkiRtmyEoZmRSQ4SZoxwpm9AX74C4U8+gAw05yMX4IQmx2eBSXZIe1T6JojiXghHv1g A5Bw== X-Gm-Message-State: AElRT7E2pU21YsOfrdjYyqsfY6B9JP01TpqC4tTikRikWLEbAg8d5qd5 J4e57haP3gNPd5Sma9/f2LYo+VyS6Vk= X-Received: by 10.80.135.229 with SMTP id 34mr601763edz.227.1520942431495; Tue, 13 Mar 2018 05:00:31 -0700 (PDT) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id t23sm39130edb.54.2018.03.13.05.00.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Mar 2018 05:00:30 -0700 (PDT) From: Bryan O'Donoghue To: U-Boot@lists.denx.de Date: Tue, 13 Mar 2018 12:00:26 +0000 Message-Id: <1520942427-7366-2-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 1/2] warp7: usb: Introduce a get method for serial number 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" We want to be able to set the USB device descriptor number iSerial number or indeed a disk-label unique identifier based on a chip-specific piece of data for the purposes of differentiating between WaRP7 boards via lsusb when connected to a host machine. In order to do this we want to have a serial number encoded in hardware, which will persist across bootloader, filesystem and config file changes. This patch utilises OCOTP_TESTER0 AND OCOTP_TESTER1 respectively for this purpose. OCOTP_TESTER is a unique identifier for each chip representing 31:0 OCOTP_TESTER0 (most significant) - FSL-wide unique, encoded LOT ID STD II/SJC CHALLENGE/ Unique ID OCOTP_TESTER1 (least significant) 31:24 - The X-coordinate of the die location on the wafer/SJC CHALLENGE/ Unique ID 23:16 - The Y-coordinate of the die location on the wafer/SJC CHALLENGE/ Unique ID 15:11 - The wafer number of the wafer on which the device was fabricated/SJC CHALLENGE/ Unique ID 10:0 - FSL-wide unique, encoded LOT ID STD II/SJC CHALLENGE/ Unique ID The 64 bits of data generate a unique serial number per-chip. Signed-off-by: Bryan O'Donoghue Cc: Fabio Estevam Reviewed-by: Rui Miguel Silva Reviewed-by: Ryan Harkin --- board/warp7/warp7.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/board/warp7/warp7.c b/board/warp7/warp7.c index d422d63..2cec448 100644 --- a/board/warp7/warp7.c +++ b/board/warp7/warp7.c @@ -23,6 +23,7 @@ #include #include #include "../freescale/common/pfuze.h" +#include DECLARE_GLOBAL_DATA_PTR; @@ -90,6 +91,58 @@ static struct fsl_esdhc_cfg usdhc_cfg[1] = { {USDHC3_BASE_ADDR}, }; +/* + * OCOTP_TESTER + * i.MX 7Solo Applications Processor Reference Manual, Rev. 0.1, 08/2016 + * OCOTP_TESTER describes a unique ID based on silicon wafer + * and die X/Y position + * + * OCOTOP_TESTER offset 0x410 + * 31:0 fuse 0 + * FSL-wide unique, encoded LOT ID STD II/SJC CHALLENGE/ Unique ID + * + * OCOTP_TESTER1 offset 0x420 + * 31:24 fuse 1 + * The X-coordinate of the die location on the wafer/SJC CHALLENGE/ Unique ID + * 23:16 fuse 1 + * The Y-coordinate of the die location on the wafer/SJC CHALLENGE/ Unique ID + * 15:11 fuse 1 + * The wafer number of the wafer on which the device was fabricated/SJC + * CHALLENGE/ Unique ID + * 10:0 fuse 1 + * FSL-wide unique, encoded LOT ID STD II/SJC CHALLENGE/ Unique ID + */ +#define WARP7_USB_SERIALID_BANK 0 +#define WARP7_USB_SERIALID_MSWORD 1 +#define WARP7_USB_SERIALID_LSWORD 2 + +static int warp7_get_serialid(u64 *id) +{ + u32 val; + int ret; + + if (!id) + return -EINVAL; + + /* Read first word */ + ret = fuse_read(WARP7_USB_SERIALID_BANK, WARP7_USB_SERIALID_MSWORD, &val); + if (ret) + goto done; + + *id = val; + *id <<= 32; + + /* Read second word */ + ret = fuse_read(WARP7_USB_SERIALID_BANK, WARP7_USB_SERIALID_LSWORD, &val); + if (ret) + goto done; + + *id |= val; + +done: + return ret; +} + int board_mmc_getcd(struct mmc *mmc) { /* Assume uSDHC3 emmc is always present */ 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; }