Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752075AbdL0OjG (ORCPT ); Wed, 27 Dec 2017 09:39:06 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:57325 "EHLO mail.rt-rk.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751002AbdL0OjE (ORCPT ); Wed, 27 Dec 2017 09:39:04 -0500 From: Aleksandar Markovic To: linux-mips@linux-mips.org Cc: Paul Burton , Miodrag Dinic , Aleksandar Markovic , Dengcheng Zhu , Douglas Leung , Goran Ferenc , James Hogan , linux-kernel@vger.kernel.org, Matt Redfearn , Petar Jovanovic , Raghu Gandham , Ralf Baechle Subject: [PATCH v3 2/2] MIPS: CPC: Map registers using DT in mips_cpc_default_phys_base() Date: Wed, 27 Dec 2017 15:37:52 +0100 Message-Id: <1514385475-23921-3-git-send-email-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514385475-23921-1-git-send-email-aleksandar.markovic@rt-rk.com> References: <1514385475-23921-1-git-send-email-aleksandar.markovic@rt-rk.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1402 Lines: 50 From: Paul Burton Reading mips_cpc_base value from the DT allows each platform to define it according to its needs. This is especially convenient for MIPS_GENERIC kernel where this kind of information should be determined in runtime. Use mti,mips-cpc compatible string with just a reg property to specify the register location for your platform. Signed-off-by: Paul Burton Signed-off-by: Miodrag Dinic Signed-off-by: Aleksandar Markovic --- arch/mips/kernel/mips-cpc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/mips/kernel/mips-cpc.c b/arch/mips/kernel/mips-cpc.c index 19c88d7..fcf9af4 100644 --- a/arch/mips/kernel/mips-cpc.c +++ b/arch/mips/kernel/mips-cpc.c @@ -10,6 +10,8 @@ #include #include +#include +#include #include #include @@ -22,6 +24,17 @@ static DEFINE_PER_CPU_ALIGNED(unsigned long, cpc_core_lock_flags); phys_addr_t __weak mips_cpc_default_phys_base(void) { + struct device_node *cpc_node; + struct resource res; + int err; + + cpc_node = of_find_compatible_node(of_root, NULL, "mti,mips-cpc"); + if (cpc_node) { + err = of_address_to_resource(cpc_node, 0, &res); + if (!err) + return res.start; + } + return 0; } -- 2.7.4