From patchwork Thu Sep 17 10:07:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11782113 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F291259D for ; Thu, 17 Sep 2020 10:09:35 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BCE852087D for ; Thu, 17 Sep 2020 10:09:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="yyQShoj5"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jKbTCxXl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BCE852087D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6YFllffqmJgHXqC2htnXaD/JiXKIeb/KQOeEKMLyrTw=; b=yyQShoj5E1VDObfuYocV5VwDU WOMfBnUixm0Vbq877HgikXtO/L/lNXAov922K1NlGQi7bQ6xFNL9DduGJncHj/xN7GkCW/curszCn S8ORSLmCGdFUHDRrpJpahW6zMxvWT096C0AkRBCbRu6UKg9rwo4EpIlDQ4Gau2TfbOxqqzg+jqot8 P5UhGAOkmClQOgSh+fSTBtjUR5w/ORF6Je1kG9ggrF8TCAOw1UvM3PNZn3JYOAtrh4kInirQsTaRl X8gp85PqBzxdJaqrb3vgEL3D7CPq/EMdzKBmeCqQRpAr2CS9K6fr/qtnh3gu939WvTkXE+bG0rkjH glgInbawg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIqqr-0000Kw-1j; Thu, 17 Sep 2020 10:09:17 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIqpu-0008Lh-8m for linux-arm-kernel@lists.infradead.org; Thu, 17 Sep 2020 10:08:20 +0000 Received: by mail-wm1-x342.google.com with SMTP id e17so1394206wme.0 for ; Thu, 17 Sep 2020 03:08:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LTTvnN7h1giqzGBn0jgQpPTrpXXAfS+8xuM6lWplWks=; b=jKbTCxXlp+3Uc6wfjxw56OIRQmme7ezOZtxJGDNCbD7aRPVlc93adtuw0LPBME9/w1 xlj3jeFHkxAkW6+dvIXa5YEU0n6tzKZbdF0QwL3WIWKSND3cxX+oIL0Scmd9NviJya/l fnxOzR4sCdfQeOiJ8w5HVlGx6YPvHVPxlS7bs8bJbDrRnAAD2YuA6VPxESKbj3L32Wio JizhqGsk6tNNI6oP7W54JwKsEDsmhfdliDcA7iTd4OfdL1dJKzcg5OEEzEXZ545q+dsv AZnDTj51F9tYJVu2oXYQHLWYeLgfvPhZ74xReaTL4BgckTUAo+MH6frKsNBuZgwBBiqL LEBw== 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:mime-version:content-transfer-encoding; bh=LTTvnN7h1giqzGBn0jgQpPTrpXXAfS+8xuM6lWplWks=; b=pUAdv+/YRTpUL9ab4qqtRtiBZLorzdlsFKvVqT+YrlGIk473YhMoMTzCdqKk9EK72T Ff9ynpeGPV+CJsAhGAiBz4NWhDY+EMk39+MLdXNNuy+R+ou4pTUdL3UheOVSb/C/2DZQ oo02ZI3sBzOdD7rgR5p0T9BA0jYw3meh7qhd6hnXbb73r1oc3zrCNDj9BwqSHxLJnnyF jbzOTZsFfJ8EVkoMleOnPAR2lkjt9KLkiViR41shUNwZaaozTSaaNApJXgDI13M2uOFI FowcdBP5kQK6hos0sTrdndUtXPCPP8z/sxARZSwFUDMNtLUa/Q/LxP/KbeGqtWaqeDi4 7pzA== X-Gm-Message-State: AOAM530cy1eMP8g7KMqkM6SX6Y2r9ohTKnEmvHwoLUxlUxapHCvu8LHm nU6z9zRNXZgF7WY5XdZykks= X-Google-Smtp-Source: ABdhPJwNbdThURz1CUtSnCJ4UFy3jXBerwtQmeCNSsUIzbbbHJwdvA/uDil996hN/ViJaR0YLibrmA== X-Received: by 2002:a1c:9cd3:: with SMTP id f202mr9133765wme.148.1600337297045; Thu, 17 Sep 2020 03:08:17 -0700 (PDT) Received: from localhost ([217.111.27.204]) by smtp.gmail.com with ESMTPSA id y1sm10104979wma.36.2020.09.17.03.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 03:08:16 -0700 (PDT) From: Thierry Reding To: Thierry Reding Subject: [PATCH v2 07/14] soc/tegra: fuse: Extract tegra_get_platform() Date: Thu, 17 Sep 2020 12:07:45 +0200 Message-Id: <20200917100752.3516153-8-thierry.reding@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200917100752.3516153-1-thierry.reding@gmail.com> References: <20200917100752.3516153-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200917_060818_387238_03052ED8 X-CRM114-Status: GOOD ( 16.87 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:342 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [thierry.reding[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jon Hunter Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Thierry Reding This function extracts the PRE_SI_PLATFORM field from the HIDREV register and can be used to determine which platform the kernel runs on (silicon, simulation, ...). Note that while only Tegra194 and later define this field, it should be safe to call this on prior generations as well since this field should read as 0, indicating silicon. Reviewed-by: Jon Hunter Signed-off-by: Thierry Reding --- drivers/soc/tegra/fuse/fuse-tegra.c | 2 +- drivers/soc/tegra/fuse/tegra-apbmisc.c | 5 +++++ include/soc/tegra/fuse.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c index d1f8dd0289e6..7e6b6ee59120 100644 --- a/drivers/soc/tegra/fuse/fuse-tegra.c +++ b/drivers/soc/tegra/fuse/fuse-tegra.c @@ -336,7 +336,7 @@ static ssize_t platform_show(struct device *dev, struct device_attribute *attr, * platform type is silicon and all other non-zero values indicate * the type of simulation platform is being used. */ - return sprintf(buf, "%d\n", (tegra_read_chipid() >> 20) & 0xf); + return sprintf(buf, "%d\n", tegra_get_platform()); } static DEVICE_ATTR_RO(platform); diff --git a/drivers/soc/tegra/fuse/tegra-apbmisc.c b/drivers/soc/tegra/fuse/tegra-apbmisc.c index 8e416ad91ee2..92a2d646c183 100644 --- a/drivers/soc/tegra/fuse/tegra-apbmisc.c +++ b/drivers/soc/tegra/fuse/tegra-apbmisc.c @@ -47,6 +47,11 @@ u8 tegra_get_minor_rev(void) return (tegra_read_chipid() >> 16) & 0xf; } +u8 tegra_get_platform(void) +{ + return (tegra_read_chipid() >> 20) & 0xf; +} + u32 tegra_read_straps(void) { WARN(!chipid, "Tegra ABP MISC not yet available\n"); diff --git a/include/soc/tegra/fuse.h b/include/soc/tegra/fuse.h index 1097feca41ed..214908fc5581 100644 --- a/include/soc/tegra/fuse.h +++ b/include/soc/tegra/fuse.h @@ -23,6 +23,7 @@ u32 tegra_read_chipid(void); u8 tegra_get_chip_id(void); +u8 tegra_get_platform(void); enum tegra_revision { TEGRA_REVISION_UNKNOWN = 0,