Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753381AbdLUPVa (ORCPT ); Thu, 21 Dec 2017 10:21:30 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:52525 "EHLO mail.rt-rk.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751602AbdLUPV0 (ORCPT ); Thu, 21 Dec 2017 10:21:26 -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 , James Hogan , linux-kernel@vger.kernel.org, Matt Redfearn , Petar Jovanovic , Raghu Gandham , Ralf Baechle Subject: [PATCH v2 2/2] MIPS: CPC: Map registers using DT in mips_cpc_default_phys_base() Date: Thu, 21 Dec 2017 16:20:24 +0100 Message-Id: <1513869627-15391-3-git-send-email-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513869627-15391-1-git-send-email-aleksandar.markovic@rt-rk.com> References: <1513869627-15391-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