From patchwork Thu Jul 30 09:28:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 247269 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp2237448ilg; Thu, 30 Jul 2020 02:29:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNffOqNGU96baVPlR+ERH+eiXtJDd2EcGtUZotQuhZg6ZP35zjXyob8Zz3EPWBmJXaR2Tm X-Received: by 2002:a17:907:104a:: with SMTP id oy10mr1695111ejb.267.1596101380499; Thu, 30 Jul 2020 02:29:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596101380; cv=none; d=google.com; s=arc-20160816; b=TPzbqrtHvNftvlrNL05X4APNDZbth19ihtYXLkCpvxII+AE1vTFoy5n5O6/3kYLEnC uvDGLPD3wpbE/Hcy2Wy51Dul52xe+go4i/v2AtLwlc3a1kiHqxbVHtlxmDl8mQEVdVSa W2x6VgsQ7C73VwJRs2UkFH7w8S5F5q1yurTah6Z+exwKdOtq0YKiGYjvoCNucz0EJTUI 8WAiSSIV/PuLUPEd+VG9xz/mbY0dX6nZq08NjgABZ+lLr+p44FXR2+ISKlneZBeQ3+4f xAWr2fbecGggKF5JvZ9wpHizFKxBObKm0drjPhL9mjDCDqy3Iew7sH486vktVL6a3DwX 8PcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=+N0FiVHtJ2p+JmShBqF6gsKo5j7aqlr8bVIjLTTP3KQ=; b=yg7l3ZOvBDZHBjRyg5V3xufQ7NIR/msYLLEVLmnu3BHmVssyWwOzZ19RtpikCeLSRk 5QuSAOp1XR8ra4buhqHxY+Ak/mTBN9Rf/wlYEb+Q2kOYMUhOMLyQkzH1P/KVqZj9Qa9Q 8F9gQpZF+zGVwU6AO4Xy9XGBx5xFzl6no1NQJp+/61o4bUf/01Eg/G37bbxPjnrLedzv kqN4ziQXY8i+mdKgCSDcYkk2qQvMYWtjo9WykWCJtAycbsYDysqz+JRYjXZKrQFTAIXN XRTKcGS6ljKk0k3zOQKm8POuxsU8LCtP8tlzQEs9UuNhJaMRgV8umBACNpmzogKSJES7 uzaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=LLXT0nfp; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id j6si2957112edq.8.2020.07.30.02.29.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 02:29:40 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=LLXT0nfp; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9BFE48265E; Thu, 30 Jul 2020 11:29:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=socionext.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="LLXT0nfp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 14A1D8265E; Thu, 30 Jul 2020 11:29:14 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4804682666 for ; Thu, 30 Jul 2020 11:29:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=socionext.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=yamada.masahiro@socionext.com Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id 06U9SFXD003637; Thu, 30 Jul 2020 18:28:18 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com 06U9SFXD003637 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1596101298; bh=+N0FiVHtJ2p+JmShBqF6gsKo5j7aqlr8bVIjLTTP3KQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LLXT0nfpi2zUy2c89ki2WijSThe8j6u5Rpbgf2wyDg7MQEUWpPgd6kpNmHFs5Lc7z jSVSxAB4raas8v6zhnY3htfLRulbNYrDPy/OM6RBPCfc3h10Di6qk44xbq+mxZQfys 0Lt1FKf7KMLSt/2T/Whs/3ZwS6EreWGzdY0O4rWYL17ZpRp+F3j/f3YJ93J0WUoS01 sT0YF9WVfqeNzsMRAh4WbN0VeZkcPFUurhOl9ie/5ZIDac2UxMBzBTf19mZXBm8sAH C+s/d2B8/wJokaAuFoOITXdSN5TddEa+9PHTMqXDny9EsYG9jl50DSEBeXc58OeWEb 0wdaGRJe4F2yg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Cc: Masahiro Yamada , Tom Rini Subject: [PATCH 5/5] ARM: uniphier: use FIELD_GET() to get access to revision register fields Date: Thu, 30 Jul 2020 18:28:08 +0900 Message-Id: <20200730092808.26521-5-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200730092808.26521-1-yamada.masahiro@socionext.com> References: <20200730092808.26521-1-yamada.masahiro@socionext.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Define register fields as macros, and use FIELD_GET(). Signed-off-by: Masahiro Yamada --- arch/arm/mach-uniphier/sg-regs.h | 5 +++++ arch/arm/mach-uniphier/soc-info.c | 21 ++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/arch/arm/mach-uniphier/sg-regs.h b/arch/arm/mach-uniphier/sg-regs.h index f47d10194987..a0fa51a8b7be 100644 --- a/arch/arm/mach-uniphier/sg-regs.h +++ b/arch/arm/mach-uniphier/sg-regs.h @@ -10,6 +10,8 @@ #ifndef UNIPHIER_SG_REGS_H #define UNIPHIER_SG_REGS_H +#include + #ifndef __ASSEMBLY__ #include #ifdef CONFIG_ARCH_UNIPHIER_V8_MULTI @@ -24,6 +26,9 @@ extern void __iomem *sg_base; /* Revision */ #define SG_REVISION 0x0000 +#define SG_REVISION_TYPE_MASK GENMASK(23, 16) +#define SG_REVISION_MODEL_MASK GENMASK(10, 8) +#define SG_REVISION_REV_MASK GENMASK(4, 0) /* Memory Configuration */ #define SG_MEMCONF 0x0400 diff --git a/arch/arm/mach-uniphier/soc-info.c b/arch/arm/mach-uniphier/soc-info.c index f021a8cab330..b0221016d1ef 100644 --- a/arch/arm/mach-uniphier/soc-info.c +++ b/arch/arm/mach-uniphier/soc-info.c @@ -4,31 +4,30 @@ * Author: Masahiro Yamada */ +#include #include #include #include "sg-regs.h" #include "soc-info.h" -static unsigned int __uniphier_get_revision_field(unsigned int mask, - unsigned int shift) -{ - u32 revision = readl(sg_base + SG_REVISION); - - return (revision >> shift) & mask; -} - unsigned int uniphier_get_soc_id(void) { - return __uniphier_get_revision_field(0xff, 16); + u32 rev = readl(sg_base + SG_REVISION); + + return FIELD_GET(SG_REVISION_TYPE_MASK, rev); } unsigned int uniphier_get_soc_model(void) { - return __uniphier_get_revision_field(0x7, 8); + u32 rev = readl(sg_base + SG_REVISION); + + return FIELD_GET(SG_REVISION_MODEL_MASK, rev); } unsigned int uniphier_get_soc_revision(void) { - return __uniphier_get_revision_field(0x1f, 0); + u32 rev = readl(sg_base + SG_REVISION); + + return FIELD_GET(SG_REVISION_REV_MASK, rev); }