From patchwork Thu Feb 16 08:50:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 9576671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 69A6F60244 for ; Thu, 16 Feb 2017 08:54:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B3FB28552 for ; Thu, 16 Feb 2017 08:54:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F266285AB; Thu, 16 Feb 2017 08:54:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B7DED28552 for ; Thu, 16 Feb 2017 08:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=TOt0yvUOARKz+XuVwU2hXfgieZ9+nAvMq9GPCv0bz4Y=; b=h4L9wuMORRCFfBnD5xSLnfEOJs 6101AuPN3NpjHZpOCUPBHa/o4eJoA3x0uOh9ZLC04uI4DVDJFn3tPf1a1x3/NBg2p4JLfM/LivygO wvNIyLRtugbg5KOhbj3fN6omp70adC8Kk4UCPG1V/2CvpfFeyE5kWFEYiMSYYYdL6wY5qwoMVnEDk OBNkBSZEPWwH3Kv0JoNnzRUi/6av2H+dLyD0MQs808A+EANZ6ivJ7WftYz0iWcdo7eBKlvReDfh/u OLg7GlGd0Y9ueAqh/CvA5MwoPtkGY5RK+UK6dxUjRLJ/i+4S8/89jTty2bnRUq8ibzMiKRy5/7uWV o5KmHRJw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ceHpu-0000F6-DG; Thu, 16 Feb 2017 08:54:46 +0000 Received: from gate2.alliedtelesis.co.nz ([2001:df5:b000:5::4]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ceHnl-0007Ku-Ni for linux-arm-kernel@lists.infradead.org; Thu, 16 Feb 2017 08:52:43 +0000 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 77D67886C4; Thu, 16 Feb 2017 21:51:00 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1487235060; bh=Agc+kEm8kFugysAuAKyLyKTVhBj1Zc7UeTgLCe3UNSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dsM16KHmcLwIEUuO3bOi/EyjYlPo5jesyBLp5qLWjPSvnOqn74R1PXqvszFFHoEYs hvhO0D0nAOKMj8Wy93T3d9ZCOgoYOO3ij7mXaTlqgBu2QOyKrbpb5PTpTINLXcWSMb 3cvrDSQVO4wEU3qoPB9eFo/TM36BjQCaTcT7yGxM= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 7, 9061) id ; Thu, 16 Feb 2017 21:51:00 +1300 Received: from chrisp-dl.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by smtp (Postfix) with ESMTP id 955A213EFA3; Thu, 16 Feb 2017 21:50:59 +1300 (NZDT) Received: by chrisp-dl.atlnz.lc (Postfix, from userid 1030) id 2C5A71E1D07; Thu, 16 Feb 2017 21:51:00 +1300 (NZDT) From: Chris Packham To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 5/6] ARM: mvebu: Add driver for mv98dx3236-soc-id Date: Thu, 16 Feb 2017 21:50:39 +1300 Message-Id: <20170216085041.28337-6-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.11.0.24.ge6920cf In-Reply-To: <20170216085041.28337-1-chris.packham@alliedtelesis.co.nz> References: <20170216085041.28337-1-chris.packham@alliedtelesis.co.nz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170216_005235_118154_D198E3D1 X-CRM114-Status: GOOD ( 15.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Jason Cooper , Russell King , linux-kernel@vger.kernel.org, Chris Packham , Gregory Clement , Sebastian Hesselbarth MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The DFX server on the 98dx3236 and compatible SoCs has an ID register that provides revision information that the PCI based ID register doesn't have. Use this if it's available. Signed-off-by: Chris Packham --- Notes: Changes in v2: - none Changes in v3: - split from dts changes arch/arm/mach-mvebu/mvebu-soc-id.c | 43 +++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-mvebu/mvebu-soc-id.c b/arch/arm/mach-mvebu/mvebu-soc-id.c index a99434bcee84..b4c94a57f358 100644 --- a/arch/arm/mach-mvebu/mvebu-soc-id.c +++ b/arch/arm/mach-mvebu/mvebu-soc-id.c @@ -34,6 +34,9 @@ #define SOC_ID_MASK 0xFFFF0000 #define SOC_REV_MASK 0xFF +#define MV98DX3236_DEV_ID_MASK 0xFF00 +#define MV98DX3236_REV_MASK 0xF + static u32 soc_dev_id; static u32 soc_rev; static bool is_id_valid; @@ -45,6 +48,11 @@ static const struct of_device_id mvebu_pcie_of_match_table[] = { {}, }; +static const struct of_device_id mvebu_mv98dx3236_of_match_table[] = { + { .compatible = "marvell,mv98dx3236-soc-id", }, + {}, +}; + int mvebu_get_soc_id(u32 *dev, u32 *rev) { if (is_id_valid) { @@ -131,15 +139,44 @@ static int __init get_soc_id_by_pci(void) return ret; } +static int __init mvebu_dfx_get_soc_id(u32 *dev, u32 *rev) +{ + struct device_node *np; + void __iomem *base; + + np = of_find_matching_node(NULL, mvebu_mv98dx3236_of_match_table); + if (!np) + return -ENODEV; + + base = of_iomap(np, 0); + if (IS_ERR(base)) + return PTR_ERR(base); + + /* SoC ID */ + *dev = (readl(base) >> 12) & MV98DX3236_DEV_ID_MASK; + /* SoC revision */ + *rev = (readl(base) >> 28) & MV98DX3236_REV_MASK; + + iounmap(base); + of_node_put(np); + + return 0; +} + static int __init mvebu_soc_id_init(void) { /* - * First try to get the ID and the revision by the system - * register and use PCI registers only if it is not possible + * First try to get the ID and the revision by from system controller + * register, then try the DFX register (if applicable), finally read it + * from PCI registers. */ - if (!mvebu_system_controller_get_soc_id(&soc_dev_id, &soc_rev)) { + if (!mvebu_system_controller_get_soc_id(&soc_dev_id, &soc_rev)) + is_id_valid = true; + else if (!mvebu_dfx_get_soc_id(&soc_dev_id, &soc_rev)) is_id_valid = true; + + if (is_id_valid) { pr_info("MVEBU SoC ID=0x%X, Rev=0x%X\n", soc_dev_id, soc_rev); return 0; }