From patchwork Sun Nov 3 13:10:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 1188553 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="f34iofU6"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 475bvX3WRcz9sPk for ; Mon, 4 Nov 2019 00:12:56 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727553AbfKCNMx (ORCPT ); Sun, 3 Nov 2019 08:12:53 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:34231 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727555AbfKCNMw (ORCPT ); Sun, 3 Nov 2019 08:12:52 -0500 Received: by mail-lj1-f194.google.com with SMTP id 139so14754945ljf.1 for ; Sun, 03 Nov 2019 05:12:50 -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=f34iofU6nUB7532D/Yt510ZFn852tz6v3I+PgizHnmkPNa64zMaVcyy3vFd2/yPV4G l3qYlZHrdYY6SEc+SbCharcJVUvyrELZF9B1wHjcXu/Cubv0vrpBDCjRGR8Nybwl1Q/f IZOh721CUCoxmr+WVyno36xZGJlw3uE4NUbMtR/2BeZxuh3Xqv2Jmdvu/wAiw/5Uuell k9yIUMNZRxUGdrtxeibcr7JAIr/HQ50wm2VAaX6BqTLnMED/pOfP4n8NrHQZ6/9wsgdT io0XGF6jnJGBZwRSFB3814Tv7wI+8Yuewuq3Y9oqaAFNBiDvfK261UOEe+2G1Dc86xVK hPUg== 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=j6aXMQFewwNIOBUAzwCmX2W4A6iCsGpbf5pB7wS/t0ugY5QS7an+GJj/HwOTGamBgR vBf9Qm3k1u//JLtcNSSV+1FkIomcVSD8ljxanlcW5TO1xNPc0HKwvJKdLApkmYj4SQe7 1iTITrRGyzaFz/TF4ltRxHZB7GbbijhgQJ1DHmuFFojB9fKZuDHBlzFLgToG+xXbAvbx 6L8KwCaduWAtR7Xq1NpKxMu2H201+eLGedqBJX17V8rUCog85oCgtQ903dexnGWh8L1b M9Ue3fSzX+bo9xT/EKXxr7CXDjryxgxSS5H+DACdkAx/jATNtyMjtBVZlwpFYRRTWWdH 1sgw== X-Gm-Message-State: APjAAAVWv2SS/r4rIwcmACyLQge6ZQUaRVeHOLCq/5hl/LDEUj7Hmwg/ r7mQuy/kLuJMjLqtskRvTAw= X-Google-Smtp-Source: APXvYqxkrRruZCWnTmfT++zVL+1EWeTlGjzPVL1vAF66IEP9jzR7Rv2iiCPlIMAED9XJQjtIhIsHwA== X-Received: by 2002:a2e:9546:: with SMTP id t6mr15254320ljh.219.1572786769386; Sun, 03 Nov 2019 05:12:49 -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 p8sm1700467ljn.0.2019.11.03.05.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2019 05:12:48 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter Cc: linux-tegra@vger.kernel.org Subject: [PATCH v1 1/3] soc/tegra: fuse: Cache values of straps and Chip ID registers Date: Sun, 3 Nov 2019 16:10:21 +0300 Message-Id: <20191103131023.17342-2-digetx@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191103131023.17342-1-digetx@gmail.com> References: <20191103131023.17342-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 Sun Nov 3 13:10:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 1188552 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="nam84omV"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 475bvW5Ll4z9sPT for ; Mon, 4 Nov 2019 00:12:55 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727490AbfKCNMw (ORCPT ); Sun, 3 Nov 2019 08:12:52 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:36722 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727553AbfKCNMw (ORCPT ); Sun, 3 Nov 2019 08:12:52 -0500 Received: by mail-lf1-f68.google.com with SMTP id a6so6865925lfo.3 for ; Sun, 03 Nov 2019 05:12:50 -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=nam84omVg4QxMijOaug0jy8DCPxFyJIwqrXCmBxPHR+JfUv6A/gJZXoSJ5+W+Sp4lG ZAKlVOfKpdioQbRqmyodgEPfxW9dCAE22kY3htbrGzS3y4zUNyFjCKHqd+AL7Lt8OWRM ZhkmsF4TK9W6BEDEhUDyFFercUvOFu66ThIswpM/z/TyufIL0W5SlQhvJ31ldJ/Rznby tzR5cEEb8c3JV8v9ta/GAOiEx+7flPlkt80MmDKeWBP7v+uOYDuB5nb+v8MENkmcMPuw w905++DIJH8xJB48vJc/wDYU3CD4igUHjYoUGGlOQByxRFl0MxLzokcCD9XY0j3whBek +BlQ== 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=TM9AyQ04PI4FP99vKj4zP54Ltxij1+G9sd+qvXC5Gbz7Dh7SQGvdLPaQtTwa0mq8Uf z7QUMGGuIt+mwKDJ1zJv/zQmd8RRwaMfrHs7HSeGIxjQZtDAPvPtKrjyjiiUMOUbj4d1 1+KavuxTdYxiu3yi+RVClX49a+CYbBYfwjBiq1hB5D4tAg67n3AR7q/vWNFzm0w5HJEX EYXkq4kuK166CBeNRtMw5X4ogsDEFs6JyjjVOIofATfR+gt4Zie4n8NSDasNU9/TScI4 MpOs6jj3ynEvo2NvDbmVuQ0ZTwz0PrSyUqg13U7SLQydE+/qnERzznEzknB/Sskr+imB vMCg== X-Gm-Message-State: APjAAAW8IvsMcwqcceBaUKWaDM07ZssTziZ6jt8zSL+AMrsVOiaeupJt zUwWtlkwGyKOI6IGT6TwsaPsmJdL X-Google-Smtp-Source: APXvYqwoKA8nr9iGEwFetKK7Df3WzNviAsvB0iEuRVcWEc6SmSGWjnKyefKQCeOoFPae3vflN4SNSg== X-Received: by 2002:ac2:55a3:: with SMTP id y3mr13472922lfg.108.1572786770216; Sun, 03 Nov 2019 05:12:50 -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 p8sm1700467ljn.0.2019.11.03.05.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2019 05:12:49 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter Cc: linux-tegra@vger.kernel.org Subject: [PATCH v1 2/3] soc/tegra: fuse: Warn if straps and not ready Date: Sun, 3 Nov 2019 16:10:22 +0300 Message-Id: <20191103131023.17342-3-digetx@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191103131023.17342-1-digetx@gmail.com> References: <20191103131023.17342-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 Sun Nov 3 13:10:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 1188554 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="jjD06Mfs"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 475bvY1r0Vz9sPn for ; Mon, 4 Nov 2019 00:12:57 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727607AbfKCNMy (ORCPT ); Sun, 3 Nov 2019 08:12:54 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:37445 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727555AbfKCNMy (ORCPT ); Sun, 3 Nov 2019 08:12:54 -0500 Received: by mail-lj1-f195.google.com with SMTP id v2so14721085lji.4 for ; Sun, 03 Nov 2019 05:12:51 -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=jjD06MfsAd8+YUB67An8j/5YI9XHegWr5tubNkzksi5zj9Rj3WXc56uO/ojoqP8zAZ 4kKx1PiLMMJLR4AcBb2b3y2zgz4Mt2UcL93VqoP49KqKSNalwwMKh5s0kW0tYVua2yN3 RBk8hEy37dxBmq9EwIH8erkHVF+Xu0kQZAej61eQHLoR8cxOmGplVv//AoXD+CHUH1IY 5k/LAGF/Ot7HDBVk3hcwcI917Hp3oMJorqhZpq8boktXsGM8cdDiesIFnwWDD6OtlIZ7 VylSQFzWh2f0xhFcOzMdANvKFEMoEdaqEK/vZvxAnPkcqExZtKb0WH5v9WhnJKnskg2n +T7Q== 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=qmixhUppIDXdmlq8a7J4Rvm3Su2Sg8wQ4Iu92kVbDzkEGsPywRun3UPRSiVFXS6Qw7 yoOfy3zcqz/5xay5y+CSdUMKXqxE+M59IRh/xndzXygUxmju0atWgjIHzXt7qw2Z1eW+ wC3QbsyHZr3dF54XWhzUihRXNo8nhzmdJQxdRnWEL6U8Z8NANjhvVOP3cIM2Ly5BzBWg qAh7RegtxVaXs6mhG9rPpzV3KI3FeXWZP2fhRwlQM42bJ6ipHblBbxFDrnoVo58YsWLv 0k3DDrzdy9E4btdgRgDwCUrief7dMFXfiUvrFw0UzJ0tIdmkevZdThBBT0eI7AgkVAKv LSOQ== X-Gm-Message-State: APjAAAVzKJeWrFT3wo/iP7YSRVSkV48reZcMWkOG9Wp3ufGA40NQ5UZN ppkpIzi0CR/B+KSJTIAO13U= X-Google-Smtp-Source: APXvYqzWYhx1IrhA/opM972SwPFL5tzf8Na9ckiXBbYrSfZLt6xFcbYtNa7gk9w7UuZ0K+/beoeI/w== X-Received: by 2002:a2e:9985:: with SMTP id w5mr8832178lji.162.1572786770989; Sun, 03 Nov 2019 05:12:50 -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 p8sm1700467ljn.0.2019.11.03.05.12.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2019 05:12:50 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter Cc: linux-tegra@vger.kernel.org Subject: [PATCH v1 3/3] soc/tegra: fuse: Correct straps' address for older Tegra124 device trees Date: Sun, 3 Nov 2019 16:10:23 +0300 Message-Id: <20191103131023.17342-4-digetx@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191103131023.17342-1-digetx@gmail.com> References: <20191103131023.17342-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 {