From patchwork Thu Jul 16 14:18:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11667655 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 8562560D for ; Thu, 16 Jul 2020 14:21:33 +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 4C063206F4 for ; Thu, 16 Jul 2020 14:21:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="O1ZshKtz"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TSBmscnH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C063206F4 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=BIKmBaq9OVYARiyARmT23oZ618V7Rc4aoQpwJKkkKkY=; b=O1ZshKtzaxyfeJABo+7KnmeOm 2X0uReedHDitWTNv+JxYOMapcI/ZUE4eP8Pb4ejvMI4xS3Hx8YJim0O8gihQxRNzjLsRd5oiXYAPA GOY83Z4sqMzjVh9m49Vjb/k9ay5LukxEeJBURnsP0TKZpPpUkUo6Jtd1/ReD0c8d83xHjbdyGa1E4 73D7L0lgpOuVGUD54A85Ur2UPlXTBPokXdFQal0SbiL/CBvbkcG7BNUwkr3MyWCuHkXsQOeSOnJ59 /kdkX45jE1h0iiiJCv8LBXWzejIFruOMrdEG2ZdKWkl3OzMCNTY65dCvQeU7VmbvizpQ5CCDrP1Md bzy87BahQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jw4jo-00047d-LI; Thu, 16 Jul 2020 14:19:52 +0000 Received: from mail-ej1-x641.google.com ([2a00:1450:4864:20::641]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jw4jC-0003uT-8I for linux-arm-kernel@lists.infradead.org; Thu, 16 Jul 2020 14:19:17 +0000 Received: by mail-ej1-x641.google.com with SMTP id a21so6726708ejj.10 for ; Thu, 16 Jul 2020 07:19:13 -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=kJRt1d0tuOJa8Fmf2Td5qwrg+gnX4K9VBuBPB08W6pA=; b=TSBmscnHkyQR3/JE6MHEYu70nLn0cylf0xdKyZBn1bptqT6wcFCGhVVcIlCB8hbcDa 87S+DPuu6CA+y82kDezba2/cZWCtmll+11ev4CzhHhDCJ1shKu77cPL9IhXFgTT08Mne rHe0H2iezK8thNDE06leZyeVzMgPWwPiCRTDy5WhN4wZBUJ/OdmTkBEMfRz+ecnISF55 A3Sjbm+MkDfy8xDewDtigd6kQczqD6GuphZ+3APOj0StIFVcp2jNLwllJZJKi4ToLgZ3 qupP5WoGbKRv5Izs8h5YqJ+NITCmnqPGsbXHS89I3Iwi4MsdMY8CyGN4/xbDjlsQRjni 8kkA== 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=kJRt1d0tuOJa8Fmf2Td5qwrg+gnX4K9VBuBPB08W6pA=; b=A+nFzdT2PHv0OP4OwRU+6PsEazWTEe5E345q1klaVNk6RW3XwJtlJSbo4D3upIIco6 Ak86pOE4W1SQs+nfsTk842Uh7AtK/mbICkY2gZkoceWJM876mQ60FCAbsX9r8y+h6uuG 5kmgy6f5rbwzrSOz5l9dD/llUmaj9nzZQ+lu1Y/BaYb2YjDgdoW5k0q9rb3Gkqrd55Nq WpyUQsXNY+6lp7XnESU+ebB8JSaqokYIwmCeGMrv5zEAcbq7Mwm76lm5nokrE7e3TMa+ rRAnx9dlmu+XIx+MgVJu913Mv8bDVsEDER8YWlL/8do0ZbapTbKeuHe4g9xcBjyeLedl 2X1g== X-Gm-Message-State: AOAM532W4lmyrcG5PT7a54ItBv1GtrvZ8l3rM7XbSZUFl3UkzxWP8T8/ 3c6mlDINkHDt1HHQXxFnMX+KIswV X-Google-Smtp-Source: ABdhPJwat+/nqVVdWV013vBqcSn/O3qjSdM5/ozEVK9nSvae2FeNCIy2z7O9aIHd17bK99+doM7ZPw== X-Received: by 2002:a17:906:1a54:: with SMTP id j20mr3854851ejf.455.1594909153137; Thu, 16 Jul 2020 07:19:13 -0700 (PDT) Received: from localhost ([62.96.65.119]) by smtp.gmail.com with ESMTPSA id fi29sm5097702ejb.83.2020.07.16.07.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 07:19:12 -0700 (PDT) From: Thierry Reding To: Thierry Reding Subject: [PATCH 5/9] soc/tegra: fuse: Extract tegra_get_platform() Date: Thu, 16 Jul 2020 16:18:52 +0200 Message-Id: <20200716141856.544718-6-thierry.reding@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200716141856.544718-1-thierry.reding@gmail.com> References: <20200716141856.544718-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-20200716_101914_400933_6431D56E X-CRM114-Status: GOOD ( 14.75 ) 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:641 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [thierry.reding[at]gmail.com] 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. Signed-off-by: Thierry Reding Reviewed-by: Jon Hunter --- 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 3cdd69d1bd4d..89f1479b4d0e 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,