From patchwork Mon Nov 11 21:26:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 1193149 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nZSYKBz1"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47BkVn4gKtz9sPK for ; Tue, 12 Nov 2019 08:27:45 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727080AbfKKV1p (ORCPT ); Mon, 11 Nov 2019 16:27:45 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:46268 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727053AbfKKV1p (ORCPT ); Mon, 11 Nov 2019 16:27:45 -0500 Received: by mail-lj1-f196.google.com with SMTP id e9so15344139ljp.13 for ; Mon, 11 Nov 2019 13:27:43 -0800 (PST) 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=4TVHdsh6uMDAICqoT24b2/6XPX4sUgMiPeLBGaxMIqk=; b=nZSYKBz1oAE/hbFYHsK1WZAsf1yEsOMj9YV5AX/Z/zjbBjuygj7XtT5QRCMdhu/7uV M47q2DwitePopcbufB+D9VMAstT6z+yUtjvQerr5mFjzuNJkFYfP6Qusp9sTkPXAAX9z 81fpIcoLiy7v5EyXi7udKwqkHDehJptDeVup3eJ2ZoKvB28pVYsn54+EO/VmVQsh2Nv2 cLgaLwcBvtpQWrv3O93aOrKZy/LH0XhRo6/KyyEG72MBfPxtZzDNGFg4J10Sw6E4iX1i Ej0ZGDe6Xn5s9JAvHbCZN3ausEN7uPgcAaTFn13gd6MIdGb6M452e6nc8EV9H35kkJog GXTw== 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=4TVHdsh6uMDAICqoT24b2/6XPX4sUgMiPeLBGaxMIqk=; b=HWLDiQiHCz72zXptNiv/+2AN+1kjqCqnSd4iSLa4lXzmk13mjaq7g79iUUsDSQB+LE GIHWh/6hhC4Gt09y9NW5q4veH/+GZ8k9kouOQgVsWT5Tp+5cBvYcVwh7dlvLwekMH8tL 4lLqjPdmEaK+zBILwvRkvpzFjcwg/alW7eTThjCEbVIRH/kGmuCAGAcIQqOhwcKA4dwH AljIOdqTtjddXtjCIn8UjxDbn3Z6uxswVhD12iOC2OENITGkmWkVimpnpj/L282yO+Lv tBIOEJKlXxPGfCJPQ4byFqKYD4XsSsaxPJDfITQGDaYjl4pr5lkjZXYEjWz+wfFmztnY qtow== X-Gm-Message-State: APjAAAW3V1WYAGx9IBR2kaEJqhZ5F7MMOdV5bqoRO4HnwqOuRAytNkE3 gZT0Cfkn532taBfSsDbPMjc= X-Google-Smtp-Source: APXvYqzc2q1KCbWdDJiJ3ypM7Ju8turvASAMDS7K6SYpB+jIExyMQXmMFfBdA6Afr9U9l3kK0pyerw== X-Received: by 2002:a05:651c:1127:: with SMTP id e7mr16928883ljo.70.1573507663238; Mon, 11 Nov 2019 13:27:43 -0800 (PST) Received: from localhost.localdomain (94-29-10-250.dynamic.spd-mgts.ru. [94.29.10.250]) by smtp.gmail.com with ESMTPSA id k25sm7344008ljg.22.2019.11.11.13.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 13:27:42 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter Cc: linux-tegra@vger.kernel.org Subject: [PATCH v2 1/3] soc/tegra: fuse: Cache values of straps and Chip ID registers Date: Tue, 12 Nov 2019 00:26:35 +0300 Message-Id: <20191111212637.22648-2-digetx@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191111212637.22648-1-digetx@gmail.com> References: <20191111212637.22648-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org There is no need to re-read Chip ID and HW straps out from hardware each time, it is a bit nicer to cache the values in memory. Signed-off-by: Dmitry Osipenko --- drivers/soc/tegra/fuse/tegra-apbmisc.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/soc/tegra/fuse/tegra-apbmisc.c b/drivers/soc/tegra/fuse/tegra-apbmisc.c index df76778af601..54aeea1b4500 100644 --- a/drivers/soc/tegra/fuse/tegra-apbmisc.c +++ b/drivers/soc/tegra/fuse/tegra-apbmisc.c @@ -21,18 +21,15 @@ #define PMC_STRAPPING_OPT_A_RAM_CODE_MASK_SHORT \ (0x3 << PMC_STRAPPING_OPT_A_RAM_CODE_SHIFT) -static void __iomem *apbmisc_base; -static void __iomem *strapping_base; static bool long_ram_code; +static u32 strapping; +static u32 chipid; u32 tegra_read_chipid(void) { - if (!apbmisc_base) { - WARN(1, "Tegra Chip ID not yet available\n"); - return 0; - } + WARN(!chipid, "Tegra Chip ID not yet available\n"); - return readl_relaxed(apbmisc_base + 4); + return chipid; } u8 tegra_get_chip_id(void) @@ -42,10 +39,7 @@ u8 tegra_get_chip_id(void) u32 tegra_read_straps(void) { - if (strapping_base) - return readl_relaxed(strapping_base); - else - return 0; + return strapping; } u32 tegra_read_ram_code(void) @@ -103,6 +97,7 @@ void __init tegra_init_revision(void) void __init tegra_init_apbmisc(void) { + void __iomem *apbmisc_base, *strapping_base; struct resource apbmisc, straps; struct device_node *np; @@ -162,10 +157,14 @@ void __init tegra_init_apbmisc(void) apbmisc_base = ioremap_nocache(apbmisc.start, resource_size(&apbmisc)); if (!apbmisc_base) pr_err("failed to map APBMISC registers\n"); + else + chipid = readl_relaxed(apbmisc_base + 4); strapping_base = ioremap_nocache(straps.start, resource_size(&straps)); if (!strapping_base) pr_err("failed to map strapping options registers\n"); + else + strapping = readl_relaxed(strapping_base); long_ram_code = of_property_read_bool(np, "nvidia,long-ram-code"); } From patchwork Mon Nov 11 21:26:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 1193150 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="njUyABQH"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47BkVp3P4pz9sPJ for ; Tue, 12 Nov 2019 08:27:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727053AbfKKV1q (ORCPT ); Mon, 11 Nov 2019 16:27:46 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:44578 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726910AbfKKV1q (ORCPT ); Mon, 11 Nov 2019 16:27:46 -0500 Received: by mail-lf1-f66.google.com with SMTP id z188so3814781lfa.11 for ; Mon, 11 Nov 2019 13:27:44 -0800 (PST) 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=O1Nw0vEzgAGqkBGVXXYW2HyLesWf5OqF6+ALQmKG8ew=; b=njUyABQHH6S7YwtAv6D/wPUh/8BEDdfrn8/DirhOyEoIHjNkLf+BjOELL7XgNnt2zt 7XciDoszdpybGmlP7kENbewWRN4kD3cu22hWZf/yotOE8GG6pd4UZNKPLplzV8tlVpnr KdCFdqBd+SYPkClO8MAJsxz/ZPvNQDsxI8n6PPt4/EOs0x3nez9KMQBn9DM6eSDwRbzg BJ19wKBXiXpZ8jFAJQclP+DLPgT79TqfRCIzGTkUXWFTTIFmvdVsxBhuKBUzpHnEytTr O4dwn66rqr6Y+6+V1DEP6w5/mqOY9H2Hs/MSI5pYxy0YbXPnWFp9F5VIzFSwRGP1EIxB fV3Q== 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=O1Nw0vEzgAGqkBGVXXYW2HyLesWf5OqF6+ALQmKG8ew=; b=h4+scuxo7Uny441o6NBmHkiy/jU+Z1gB+S2z/VeMNc1XSa29kxeteQGXw4um2k0q6a 1X2Y2ic5ChPG1B4fuA011uSfSIMTkrxs9erlF3ZSJR2ygV70i8R1ysByGhpqSkYTVeN/ 9dMr2yCSvE674+Kl9C2B9eHIvq03Ip3YvNfqMjQcjcB2cWSHjnSnuIb9RRgOBy9L04gL yNMu7Bf2fl83h/Qj8M+Uc558uKqEj+I6TSB2xE8hE3Qc/VuReQAB1SnH0Gs78N0YiiBG erqzW08lsjjWmN9QAjgSJyoFcFN9q2bQ2A9+y/vWIlLsy80tvy4EI6/7SVg8WoDXWH57 gtKQ== X-Gm-Message-State: APjAAAUL0UF+bpqwrt8TuM1dYvxlF6kN/qKQyzcA/pVQCeGoL39SBdiK HdI5hY0otOZ1noP4Iw9oaqcWgdCQ X-Google-Smtp-Source: APXvYqx/r5V3PTW/B8NpxjzA31jisHuT+/GL7rcbeCSCtD8iWjt87BVs/gxdKN0EJyXzheF7SUY1hg== X-Received: by 2002:a19:c7d3:: with SMTP id x202mr16890062lff.127.1573507663973; Mon, 11 Nov 2019 13:27:43 -0800 (PST) Received: from localhost.localdomain (94-29-10-250.dynamic.spd-mgts.ru. [94.29.10.250]) by smtp.gmail.com with ESMTPSA id k25sm7344008ljg.22.2019.11.11.13.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 13:27:43 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter Cc: linux-tegra@vger.kernel.org Subject: [PATCH v2 2/3] soc/tegra: fuse: Warn if straps are not ready Date: Tue, 12 Nov 2019 00:26:36 +0300 Message-Id: <20191111212637.22648-3-digetx@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191111212637.22648-1-digetx@gmail.com> References: <20191111212637.22648-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org Now both Chip ID and HW straps are becoming available at the same time, thus we could simply check the availability of the ID in order to check the availability of the straps. We couldn't check straps for 0x0 because it could be a correct value. This change didn't uncover any problems, but anyways it is nicer to have straps verified for consistency with the Chip ID verification. Signed-off-by: Dmitry Osipenko --- drivers/soc/tegra/fuse/tegra-apbmisc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/soc/tegra/fuse/tegra-apbmisc.c b/drivers/soc/tegra/fuse/tegra-apbmisc.c index 54aeea1b4500..f580b3116bea 100644 --- a/drivers/soc/tegra/fuse/tegra-apbmisc.c +++ b/drivers/soc/tegra/fuse/tegra-apbmisc.c @@ -27,7 +27,7 @@ static u32 chipid; u32 tegra_read_chipid(void) { - WARN(!chipid, "Tegra Chip ID not yet available\n"); + WARN(!chipid, "Tegra ABP MISC not yet available\n"); return chipid; } @@ -39,6 +39,8 @@ u8 tegra_get_chip_id(void) u32 tegra_read_straps(void) { + WARN(!chipid, "Tegra ABP MISC not yet available\n"); + return strapping; } From patchwork Mon Nov 11 21:26:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 1193151 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="aqxSb1qq"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47BkVs70Y5z9sPT for ; Tue, 12 Nov 2019 08:27:49 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726910AbfKKV1s (ORCPT ); Mon, 11 Nov 2019 16:27:48 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:46267 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727089AbfKKV1s (ORCPT ); Mon, 11 Nov 2019 16:27:48 -0500 Received: by mail-lj1-f193.google.com with SMTP id e9so15344187ljp.13 for ; Mon, 11 Nov 2019 13:27:45 -0800 (PST) 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=h3HT9SF2wrMJkzuNPVnE64pREUnWzAqPVZJ/lAHHyXc=; b=aqxSb1qq/JeX8+9lxmuuVfyMHm9lcc/gzMGBar8w4WvOPBDDeYHtfLkiC2+uRuZ9bW OFC5vHb532SogOpBGsXFUeIITIeHBPQZYUI+aoWIeSrP1W8rpBxz4CpifZo0bZo6sGOw SHI/5syyshgpWso4zsPtIaHLQsiLyKfdYH4aFAfr2IFy+p2R4qteE/OiLqrX5o8cg9WD gMetQqEZDP63d+Vws8mpLxi024DZYkFIZbllk4aRJD9nlmX5wZl4RYFIzA3qdLjRULAq 3KfWdk2BFi7G9jhEXeV6AoMEobvmLykme6buAI6b4eVM86WT3IRgvDbEVnpmE5JAkACk 62Cw== 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=h3HT9SF2wrMJkzuNPVnE64pREUnWzAqPVZJ/lAHHyXc=; b=ogFW+w2c5grByOrSs1U5nPhmlsg1J+y8Btzuji4zUbaOM/0hnC66XpP9XYbpmAfVXx OvxHXj54ROc3Q7XJpL8+ejFR44ErfixtLKt+aLp9XpEAFu95S8Gj3VPrkdgBrSdCP50f cjj3n08OcU2S43LDCcR11qgqfuxtC4Ltog19IIKBXpWRvVJasjMvbdetpBLukNI9uf4z GTv0pESY9QBHxl7g5LUNb150pLjmV+w2Hw6jHKmo+gB/t6qqQ48wIY6YzJvwOhRm7Hoi mLg9cHEmYSyIJKWEOKI8a5Zy/zQGSYB6twdqxCZI7G6LAnG8F7K5BIN4bxCirDYHh9oW g9kw== X-Gm-Message-State: APjAAAUnGhUmuVip6HRxL46GRNgTeI+dvb6WfVlxdvn4pcHpRTlWBguS HNxxaABD65nNVeqLwWdFiuXknXzX X-Google-Smtp-Source: APXvYqzwMBRaWlcnFl5oi7tkN4dePZC3xI+NoJIBiBhRi4n8A+SkQ7dUUWyMZKG6kdMfkJhmNYOqMA== X-Received: by 2002:a2e:982:: with SMTP id 124mr9220982ljj.48.1573507664697; Mon, 11 Nov 2019 13:27:44 -0800 (PST) Received: from localhost.localdomain (94-29-10-250.dynamic.spd-mgts.ru. [94.29.10.250]) by smtp.gmail.com with ESMTPSA id k25sm7344008ljg.22.2019.11.11.13.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 13:27:44 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter Cc: linux-tegra@vger.kernel.org Subject: [PATCH v2 3/3] soc/tegra: fuse: Correct straps' address for older Tegra124 device trees Date: Tue, 12 Nov 2019 00:26:37 +0300 Message-Id: <20191111212637.22648-4-digetx@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191111212637.22648-1-digetx@gmail.com> References: <20191111212637.22648-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org Trying to read out Chip ID before APBMISC registers are mapped won't succeed, in a result Tegra124 gets a wrong address for the HW straps register if machine uses an old outdated device tree. Fixes: 297c4f3dcbff ("soc/tegra: fuse: Restrict legacy code to 32-bit ARM") Signed-off-by: Dmitry Osipenko --- drivers/soc/tegra/fuse/tegra-apbmisc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soc/tegra/fuse/tegra-apbmisc.c b/drivers/soc/tegra/fuse/tegra-apbmisc.c index f580b3116bea..d4fff96d8407 100644 --- a/drivers/soc/tegra/fuse/tegra-apbmisc.c +++ b/drivers/soc/tegra/fuse/tegra-apbmisc.c @@ -120,7 +120,7 @@ void __init tegra_init_apbmisc(void) apbmisc.flags = IORESOURCE_MEM; /* strapping options */ - if (tegra_get_chip_id() == TEGRA124) { + if (of_machine_is_compatible("nvidia,tegra124")) { straps.start = 0x7000e864; straps.end = 0x7000e867; } else {