From patchwork Thu Feb 7 12:54:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kejia Hu X-Patchwork-Id: 1038049 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=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=codethink.co.uk Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43wJRQ4K1yz9s4Z for ; Fri, 8 Feb 2019 00:04:02 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726748AbfBGNEB (ORCPT ); Thu, 7 Feb 2019 08:04:01 -0500 Received: from imap1.codethink.co.uk ([176.9.8.82]:33039 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726990AbfBGND7 (ORCPT ); Thu, 7 Feb 2019 08:03:59 -0500 Received: from [167.98.27.226] (helo=devhw0) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1grjLR-0008LK-QH; Thu, 07 Feb 2019 13:03:57 +0000 Received: from terry by devhw0 with local (Exim 4.89) (envelope-from ) id 1grjBx-0002IP-KQ; Thu, 07 Feb 2019 12:54:09 +0000 From: Kejia Hu To: linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Ben Dooks , Thomas Preston , Kejia Hu Subject: [PATCH 1/5] soc/tegra: initial tegra-automotive detection Date: Thu, 7 Feb 2019 12:54:04 +0000 Message-Id: <20190207125408.8776-2-kejia.hu@codethink.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190207125408.8776-1-kejia.hu@codethink.co.uk> References: <20190207125408.8776-1-kejia.hu@codethink.co.uk> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org From: Ben Dooks Add an initial soc_is_tegra_auto() with detection via a change in the device-tree. Also print the path taken through soc_is_tegra_auto() to allow debugging. Only print when debug is enabled as this function may be be called from multiple places, resulting in duplicated messages in production. Signed-off-by: Ben Dooks Signed-off-by: Thomas Preston Signed-off-by: Kejia Hu --- drivers/soc/tegra/common.c | 23 +++++++++++++++++++++++ drivers/soc/tegra/fuse/tegra-apbmisc.c | 2 ++ include/soc/tegra/common.h | 1 + include/soc/tegra/fuse.h | 1 + 4 files changed, 27 insertions(+) diff --git a/drivers/soc/tegra/common.c b/drivers/soc/tegra/common.c index 7bfb154d6fa5..a10bd26fb5df 100644 --- a/drivers/soc/tegra/common.c +++ b/drivers/soc/tegra/common.c @@ -9,6 +9,7 @@ #include #include +#include static const struct of_device_id tegra_machine_match[] = { { .compatible = "nvidia,tegra20", }, @@ -34,3 +35,25 @@ bool soc_is_tegra(void) return match != NULL; } + +static const struct of_device_id tegra_machine_match_auto[] = { + { .compatible = "nvidia,tegra20auto", }, + { .compatible = "nvidia,tegra30auto", }, + { }, +}; + +bool soc_is_tegra_auto(void) +{ + struct device_node *root; + bool id_match = false; + + root = of_find_node_by_path("/"); + + if (root && of_match_node(tegra_machine_match_auto, root)) + id_match = true; + + pr_debug("%s of_device_id match %d, tegra_sku_info.is_automotive %d\n", + __func__, id_match, tegra_sku_info.is_automotive); + + return id_match || tegra_sku_info.is_automotive; +} diff --git a/drivers/soc/tegra/fuse/tegra-apbmisc.c b/drivers/soc/tegra/fuse/tegra-apbmisc.c index e5a4d8f98b10..b2727afad24b 100644 --- a/drivers/soc/tegra/fuse/tegra-apbmisc.c +++ b/drivers/soc/tegra/fuse/tegra-apbmisc.c @@ -110,6 +110,8 @@ void __init tegra_init_revision(void) tegra_sku_info.revision = rev; + tegra_sku_info.is_automotive = false; + tegra_sku_info.sku_id = tegra_fuse_read_early(FUSE_SKU_INFO); } diff --git a/include/soc/tegra/common.h b/include/soc/tegra/common.h index fc13a9a134e9..8dd178ddc6a6 100644 --- a/include/soc/tegra/common.h +++ b/include/soc/tegra/common.h @@ -10,5 +10,6 @@ #define __SOC_TEGRA_COMMON_H__ bool soc_is_tegra(void); +bool soc_is_tegra_auto(void); #endif /* __SOC_TEGRA_COMMON_H__ */ diff --git a/include/soc/tegra/fuse.h b/include/soc/tegra/fuse.h index 8fb2f8a87339..ea4caf6f0cf7 100644 --- a/include/soc/tegra/fuse.h +++ b/include/soc/tegra/fuse.h @@ -56,6 +56,7 @@ struct tegra_sku_info { int gpu_speedo_id; int gpu_speedo_value; enum tegra_revision revision; + bool is_automotive; }; u32 tegra_read_straps(void);