From patchwork Sun Apr 3 18:14:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noam Camus X-Patchwork-Id: 605623 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qdNbm1FkVz9sC4 for ; Mon, 4 Apr 2016 04:16:20 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b=yBdNIHQb; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ammZO-0000NX-RK; Sun, 03 Apr 2016 18:16:18 +0000 Received: from mail-db3on0081.outbound.protection.outlook.com ([157.55.234.81] helo=emea01-db3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ammZL-0000IL-L5 for linux-snps-arc@lists.infradead.org; Sun, 03 Apr 2016 18:16:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=pk36GOJwoMbb0iq5LJwtRk864h43xV08wYF6dH6JZA4=; b=yBdNIHQb6OUuxsBBl777g8Xxn3MY1gZKruwTeLmqoMM6S0p8XznxBisvjA0yoAkS/s2tBnsTTRES1raOoxCZIGZYm05wunajYpLRIk1UCH6tstjIdfqNmh+2LLd367WF0qGdeJLWzAgmrLq6zCMnSJ3b5FNi3VjKvH5UeQkISQ8= Received: from HE1PR05CA0024.eurprd05.prod.outlook.com (10.162.181.34) by DB4PR05MB0688.eurprd05.prod.outlook.com (10.161.15.155) with Microsoft SMTP Server (TLS) id 15.1.447.15; Sun, 3 Apr 2016 18:15:53 +0000 Received: from DB3FFO11FD053.protection.gbl (2a01:111:f400:7e04::155) by HE1PR05CA0024.outlook.office365.com (2a01:111:e400:51f9::34) with Microsoft SMTP Server (TLS) id 15.1.447.15 via Frontend Transport; Sun, 3 Apr 2016 18:15:52 +0000 Authentication-Results: spf=pass (sender IP is 193.47.165.134) smtp.mailfrom=mellanox.com; kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=pass action=none header.from=mellanox.com; Received-SPF: Pass (protection.outlook.com: domain of mellanox.com designates 193.47.165.134 as permitted sender) receiver=protection.outlook.com; client-ip=193.47.165.134; helo=mtlcas13.mtl.com; Received: from mtlcas13.mtl.com (193.47.165.134) by DB3FFO11FD053.mail.protection.outlook.com (10.47.217.125) with Microsoft SMTP Server (TLS) id 15.1.453.6 via Frontend Transport; Sun, 3 Apr 2016 18:15:51 +0000 Received: from MTLCAS13.mtl.com (10.0.8.78) by mtlcas13.mtl.com (10.0.8.78) with Microsoft SMTP Server (TLS) id 15.0.775.38; Sun, 3 Apr 2016 21:15:49 +0300 Received: from MTLCAS01.mtl.com (10.0.8.71) by MTLCAS13.mtl.com (10.0.8.78) with Microsoft SMTP Server (TLS) id 15.0.775.38 via Frontend Transport; Sun, 3 Apr 2016 21:15:49 +0300 Received: from ezex10.ezchip.com (10.0.13.1) by MTLCAS01.MTL.COM (10.0.8.71) with Microsoft SMTP Server (TLS) id 14.3.123.3; Sun, 3 Apr 2016 21:15:48 +0300 Received: from localhost.localdomain (10.1.3.132) by ezex10.ezchip.com (10.1.1.4) with Microsoft SMTP Server (TLS) id 14.3.224.2; Sun, 3 Apr 2016 21:15:47 +0300 From: Noam Camus To: , , Subject: [PATCH v8 2/3] clocksource: Add NPS400 timers driver Date: Sun, 3 Apr 2016 21:14:58 +0300 Message-ID: <1459707299-31564-3-git-send-email-noamca@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1459707299-31564-1-git-send-email-noamca@mellanox.com> References: <1459707299-31564-1-git-send-email-noamca@mellanox.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-11.0.0.1191-8.000.1202-22238.001 X-TM-AS-Result: No--24.858700-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No Received-SPF: None (MTLCAS01.mtl.com: noamca@mellanox.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:193.47.165.134; IPV:NLI; CTRY:IL; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(47776003)(101416001)(229853001)(2950100001)(15975445007)(4326007)(11100500001)(81166005)(77096005)(19580405001)(6806005)(76176999)(2906002)(86362001)(5008740100001)(19580395003)(586003)(5003940100001)(1220700001)(2201001)(36756003)(5001770100001)(87936001)(92566002)(575784001)(49486002)(189998001)(50226001)(33646002)(48376002)(50466002)(50986999)(1096002)(106466001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB4PR05MB0688; H:mtlcas13.mtl.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD053; 1:pWIaC6WRBKr+G0oXUYU3jesp3dpcDfNRwrR+wdnGbXFIvhzkmhNswsNk7IcvvoB3rOY0FTpgQkuxlrKq9cCoJDumjxoagBoXdNyohxL+xhzHFGolkBI8HDNlVEku5H8+IzcYGkonplevi75KaEf73MK1fl/VYLxc7W5ve3ENkerRO7uqgDv1/UPj1oAlAW0u3tH+bOUrp5i9gqX5RQLS9+3B+T2Kl0me79K/uzCkCRnZ4UYOJiWxClQAgxIm5tqinSnoY1OlKR/wus888G2nxEquv8Ar1g+KaD4URrSkV0dMjBkWjapyiohMXmsMpt7Il6Gx1dRsIWvaH+mtW6CoioFGBZ2YovDvw20nQXU7FwVeRI7igEoKdWw0sgcMABVo2BHc8vi4tGQZ9G2vdjol7b+0e72zEVxHI5z+rG3LNX5Wt4ikOMfl7aN2ovwVvJN2EQ/7TNuv6cupRnE7QEM7GY4pYbjVwAK85Mgb0yzq1cQaJX3UG/YQgtZp+bA/yEQHJUy0f4be6H3p4x8AxtQhFQ== X-MS-Office365-Filtering-Correlation-Id: 1c254f14-27e1-4a1d-72f8-08d35bebfd77 X-Microsoft-Exchange-Diagnostics: 1; DB4PR05MB0688; 2:+rSx+xJ45mi+SHmfTg9Xugtu7z0B6cwfzX6mUlVwDQ7nA2hzw7wRv0lLhsAeXF8bGLBcIn9+m6awoIyc1B+o130OBn9bMQtcDcw0HCxVnUKXNO9hC7zAfZ7WJBv8yTwrKRklPPrbCjDAQeDczHi7zp/N3m0Y/JwBJI+qrafmnc/9WSZWkLvn2k85FpmGFm59; 3:OhSWZfw0rHZys0qRX4GxJ1TGhjAx5MSxTWLcn/UOzCGmTsKlZcbKUsW2KA+QQIotLyTyAb/kYyAt0lJC7oa9Vv9HwQsXEzgJqjUjZYhKBKhVWcLLvMt0MxeoEdbPRSxQFBQ9yUrHDFQkO8A6GX4KIDlcsduvX3wIsJ4DfGysBk+bAVxJm9j/MU4anPnjuVXEzc6PautQSEOpgdX4IvqfAnJqis5QO9y7QL2qAf0h9/PZtg3NMvTeQ1UUFRZ2nYcj4DvLUqVCmJWkFAYZD6alFg== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:DB4PR05MB0688; X-Microsoft-Exchange-Diagnostics: 1; DB4PR05MB0688; 25:7yNPzSdDXsDCamse0VsM6w2KrLs+Y+YA+bQQ+1uu2MCozm1nvejf9C+vlhK3j4bWzeFBUb24DhXknKSfG/qfpTPScsmUm/5kQbEa6FToOr+hqL6iT7LqYr/icp5az0ofRnvjf4r/l/I7pkz2AIheLPIt0W8HQci3sWFlTpPBj87trqYd2RrY3irfjYpCh6Yi+FO68cLXriGsFzdCqOKmXEnQqS1u5rrj0p0YovDS5PW9qy+P4hv9uM+paFl7BTfH237+w3o2NZUOZlVk0RUeoEW7pEXm59HSqG+grN3X+QGHOWDr8x5WvSAi8FvvUKj/V/iO9cFVFnknr4b6JtKdGCQnSlaYdNxaJGgCb183YxMlcjp9loh/gdmzaMhxcARzchQNZ06uKD/R/1zWArNYvwY0PKtVjBebXJqKkhkXg9HfttPkiK/3Vd0RvsWsXbJk4C1PtbpSjVxctOHyQ4+WT2/IfakuBFtgE1zJ+1kdpCD/TRwa2CUN+ppn7EsYzi11HB/k/JungkNC0SluZyaV53+YXe1xt5o+rF89A0ZpkKtzLpNR2LYc5BwKOpsp5UtrFnVSUwlue4t0jGIzs+boGg+Qq51PrpRKWkHvODaIPepdWcTseOaNCTd69u/AKYwqCx6pKeQ6XYHfIk5j3CEW8BKxiM5dntgSkZion9uoriBkY24OI7fJPUeeyZsETxfoPqwneRpCTo9O6zI0WR6meggI/utQUoDcnjKSY7+r7newDUz+KSBfbCOcPrycP+hT1gzgBSFuuc+6Thc3Tp3W+A== X-Microsoft-Exchange-Diagnostics: 1; DB4PR05MB0688; 20:sz9yAyFXwOkkQ/J+T9DmN4MtdP+CZBfNRDoALo+brUHcECeURQgNyPp+23djTJf+5dcuHRf49tuCAjAvf/64l9ktHqBJQ2vceiNTMnZ4M+G3cw8UJ4GGpDmYJT4lStfq9VEItXJrFlwsleFTK7hgW7R9q6DildXxa2hSDQRajU9Kp5mi5aVWg78S1czAPG53t6sD95PmT9vGzCTB6H6DP+JioO4Zf3a/Xii79DQ4VjRpORR/2LUBwZ9vvShmnNbZVSZqcmJo+UqEXrHKf+GVKXT7XqvbDxGfMlB33cg6DOl77gxcX4T4EpCMHSjEr7DmZ+CqgCILw1mNbyy4wUiuIdGGmmbYazMXAT6C1oLIsc3rpSs9e+gJvpUTRmEXZOoEEd/mT+IBX+NqEKK1XsHfj2zIkSu+6vWFig3xNix+VD4ZSwSxGXKU1LTEcOLTD95nm9nnBazJCXsYFnpbzQnT84EVK6qppvLNUaSullRLJ0PWYkzlisosBE67DGmUE9+I X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(13018025)(13023025)(13024025)(13017025)(13015025)(3002001)(10201501046); SRVR:DB4PR05MB0688; BCL:0; PCL:0; RULEID:; SRVR:DB4PR05MB0688; X-Microsoft-Exchange-Diagnostics: 1; DB4PR05MB0688; 4:g53fpkM/cu/OMv4HQ03tSlBIKAIDkgpfQArGjPQFdidWMk3SU4TlJrGx4LlRD2OJ/fS6WVrOlhX6i31QuQvpP5Ws/TQFoCB4Un5w+7yNmokjq18J1FD6zDrXFsrkaMK7olIak+wuZghJYMfdXAwBTga2Wu3R0KhIxBaJ1AdFfHGAGAueZIQy1/jCytSHNbzfPQCTgbGWTIOYmbv0a15GkwXGM+Z6KK4X7XtiCCtqF4fqzgcuB1mRAQb4hyPGQgJjcuukrB3/2JeZYmM+uvdyNlpCRUmsIfMvG0Inw5GEPMagQz+vPdAMvsVQa6NA9hB7wqppccxIH7bP2YldQEoyDf6Qh9dfgCnVSI7L9XcTIvsoEKrILn7QVIXkg36KYoc0AL+Oq2PIFC/TiMM4eR7OqFDAyrSW7ri7NmAg0icZ2lDtepUYut8qhGAr+nf7pv3UiLBgyGqvfpQapWiE9FZWNw== X-Forefront-PRVS: 09011458FC X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB4PR05MB0688; 23:gKpaoFZHWEGoChanKDNFjbVNV4tG56UpJdyyU1piO?= =?us-ascii?Q?iHpRC9PFJ5WzmZb4a0EcUgZ+Ma/BfXwsud21xL/EohUsu4g7oJl49uzg/gN8?= =?us-ascii?Q?Om+n6v0jAN4T4j6YwBu3fooyBm8GA8lv6MFeUs3qfmZ5j/G4xd3wPOK1tUAl?= =?us-ascii?Q?kRU+zNTDlvJWJ9jLXSnsFGGMF0/qstp8+BDEa7DNmNETa1syAR8Uj41wrPWH?= =?us-ascii?Q?gjVeFZFkSFVF//8qcD5pG7YspnEa1OJwj6weq7TYPRE9TrNtgYSXQeD59Znq?= =?us-ascii?Q?kiCUFys+/6KxCPJIxqRRLk43+4JDUtQWZSvgLneFH37WWrSzqQRBfBHhcnM0?= =?us-ascii?Q?6k1dZR7QdjLX5480OVgDujfywz2ThoYfzdljaNeHiIPUk4Mn3YZGWZ0wBQit?= =?us-ascii?Q?X5BtF74Vk1StttHelgqwrjsGPnQ7wp3grFKwa/6JZl1WLxrGPsk0tizekzeG?= =?us-ascii?Q?6KiaS2vd7KURMdDhP39FRITz201JnNeJsxT2hmrnRLp189AWlNv2gUBTSN7/?= =?us-ascii?Q?liSDBtJADBHYPSYkRUtG/nAKFLsvjaJCjCWLiO3/iDz1BQ/tgNntRz9ISKpj?= =?us-ascii?Q?r9Ektxah/xC2g78bmKQwIQEsNYpR7czTuvT+aqlyaGngcXDnlHcL4MdwpxTU?= =?us-ascii?Q?P/xDAeBjj4V6y3U++0AarErXnhUBtBgEMWrIqsLqkGX4TbzG7pcxoqtrOeU1?= =?us-ascii?Q?eF41PkJ/J6vRBQ5giMV2iNSFh6JASp9Fb1IYrUV5DBIK8cEmYpN6ec0U2lXA?= =?us-ascii?Q?lAkuHGaCTDdkmkppOq1XpMhmMEWOXMywDMe2rR1QJ32qyQNxo7i2LIO172lq?= =?us-ascii?Q?EFTtAVKQHSi7aYiilO7TOBNUuzBnbc+lfOkjVIV4dnK6eW4rY0XlH10dlQTu?= =?us-ascii?Q?zo2HCAKl7lFiSULFzIaoQ1NhssL0u8EkAQwhugNzII+15qsDQudygEIpWwfq?= =?us-ascii?Q?Bjjtz8CIteNIbPAKkfoD1vcVWG3IIdNC5AiGmded6yniKqI+40037Z0ngSn7?= =?us-ascii?Q?BWH9z3BSXQrSfk/YhcXFiGvOOLs3uFueWTSmesA4mnfkA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; DB4PR05MB0688; 5:RzMQCb4v0luyndeDBDCFdy10v8biFCWJeLToosQBxu9M3aE+POpBBuhuDcgkYgQV1RxYU0vb7Ch5hocUdPmSwHwg0mRluaL0tqGOme3XJ3rC2dA8Gz12oD6pw/nMXA4LTOd4/Xx0LRYgtQsLJpvhGA==; 24:DjSGkUCODiPM9r3m44Ynb3R7KCaSEM+fZLbD1MiSxbZ0hObC0bwwCUpERf5cJ4Zp5px4ERXKtA+pdIMaMolLAxXKkwLcoh2dYFQFNRVid4c= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2016 18:15:51.4313 (UTC) X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a652971c-7d2e-4d9b-a6a4-d149256f461b; Ip=[193.47.165.134]; Helo=[mtlcas13.mtl.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR05MB0688 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160403_111616_163073_98AEB4A5 X-CRM114-Status: GOOD ( 21.32 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [157.55.234.81 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [157.55.234.81 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vineet Gupta , linux-kernel@vger.kernel.org, Rob Herring , John Stultz , Noam Camus , Thomas Gleixner , linux-snps-arc@lists.infradead.org Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Noam Camus Add internal tick generator which is shared by all cores. Each cluster of cores view it through dedicated address. This is used for SMP system where all CPUs synced by same clock source. Signed-off-by: Noam Camus Cc: Daniel Lezcano Cc: Rob Herring Cc: Thomas Gleixner Cc: John Stultz Cc: Vineet Gupta Acked-by: Daniel Lezcano --- v8: Change macro name from IPI_IRQ to NPS_IPI_IRQ. This was needed due to build warning when building for parsic. v7: Rebased on latest HEAD (4.6-rc1) v6: Files headers changed to start with: Copyright (c) 2016, Mellanox Technologies ... This is due to the acquisition of EZchip made by Mellanox. One can still find "EZchip" used in tree, and this is ok. This patch set is a requierement before I can insert new platform to ARC, one that supports the NPS400 SoC. v5: Clocksource, irqchip - Fix gracefull return. replace call to panic() with pr_err() and proper return value. v4: clocksource -- Apply all Daniel comments (Thanks) Handle gracefull return and also using clocksoure mmio driver at init v3: irqchip - Fix ARM build failure by adding missing include of linux/irq.h clocksource -- Avoid 64bit arch's to build driver by adding new dependency !PHYS_ADDR_T_64BIT This is since we use explicit io access of 32 bit. So for test coverage we allow not only build for ARC, but restrict it to 32 bit arch's. irqchip - Apply all Thomas comments (Thank you) v2: Add header file include/soc/nps/common.h. Now to build we do not depend on ARC subtree. General summay: Both drivers are now apart of previous basic patch set of new platform for ARC. The rest is now can be seen at ARC srctree: https://git.kernel.org/cgit/linux/kernel/git/vgupta/arc.git/ Now ARC is supporting DT for clockevents and the interrupt controller ARC uses irq domain handling. Compare to last version now clocksource driver do not include clockevent registration since NPS400 can use ARC generic driver. Compare to last version now irqchip driver sets domain as default since it is the root domain. Also mapping of IPI is done in this driver. Last thing is that drivers can be build cleanly for i386 (still runs only for ARC) Note: in order to build we need to merge drivers into srctree which includes new header: soc/nps/common.h This header is part of patch set applied to ARC srctree. Regards, Noam Camus --- .../bindings/timer/ezchip,nps400-timer.txt | 15 +++ drivers/clocksource/Kconfig | 10 ++ drivers/clocksource/Makefile | 1 + drivers/clocksource/timer-nps.c | 98 ++++++++++++++++++++ 4 files changed, 124 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/timer/ezchip,nps400-timer.txt create mode 100644 drivers/clocksource/timer-nps.c diff --git a/Documentation/devicetree/bindings/timer/ezchip,nps400-timer.txt b/Documentation/devicetree/bindings/timer/ezchip,nps400-timer.txt new file mode 100644 index 0000000..c8c03d7 --- /dev/null +++ b/Documentation/devicetree/bindings/timer/ezchip,nps400-timer.txt @@ -0,0 +1,15 @@ +NPS Network Processor + +Required properties: + +- compatible : should be "ezchip,nps400-timer" + +Clocks required for compatible = "ezchip,nps400-timer": +- clocks : Must contain a single entry describing the clock input + +Example: + +timer { + compatible = "ezchip,nps400-timer"; + clocks = <&sysclk>; +}; diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index c346be6..3932d09 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -181,6 +181,16 @@ config CLKSRC_TI_32K This option enables support for Texas Instruments 32.768 Hz clocksource available on many OMAP-like platforms. +config CLKSRC_NPS + bool "NPS400 clocksource driver" if COMPILE_TEST + depends on !PHYS_ADDR_T_64BIT + select CLKSRC_MMIO + select CLKSRC_OF if OF + help + NPS400 clocksource support. + Got 64 bit counter with update rate up to 1000MHz. + This counter is accessed via couple of 32 bit memory mapped registers. + config CLKSRC_STM32 bool "Clocksource for STM32 SoCs" if !ARCH_STM32 depends on OF && ARM && (ARCH_STM32 || COMPILE_TEST) diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile index dc2b899..0b0a4b5 100644 --- a/drivers/clocksource/Makefile +++ b/drivers/clocksource/Makefile @@ -46,6 +46,7 @@ obj-$(CONFIG_CLKSRC_QCOM) += qcom-timer.o obj-$(CONFIG_MTK_TIMER) += mtk_timer.o obj-$(CONFIG_CLKSRC_PISTACHIO) += time-pistachio.o obj-$(CONFIG_CLKSRC_TI_32K) += timer-ti-32k.o +obj-$(CONFIG_CLKSRC_NPS) += timer-nps.o obj-$(CONFIG_ARM_ARCH_TIMER) += arm_arch_timer.o obj-$(CONFIG_ARM_GLOBAL_TIMER) += arm_global_timer.o diff --git a/drivers/clocksource/timer-nps.c b/drivers/clocksource/timer-nps.c new file mode 100644 index 0000000..d461089 --- /dev/null +++ b/drivers/clocksource/timer-nps.c @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2016, Mellanox Technologies. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define NPS_MSU_TICK_LOW 0xC8 +#define NPS_CLUSTER_OFFSET 8 +#define NPS_CLUSTER_NUM 16 + +/* This array is per cluster of CPUs (Each NPS400 cluster got 256 CPUs) */ +static void *nps_msu_reg_low_addr[NPS_CLUSTER_NUM] __read_mostly; + +static unsigned long nps_timer_rate; + +static cycle_t nps_clksrc_read(struct clocksource *clksrc) +{ + int cluster = raw_smp_processor_id() >> NPS_CLUSTER_OFFSET; + + return (cycle_t)ioread32be(nps_msu_reg_low_addr[cluster]); +} + +static void __init nps_setup_clocksource(struct device_node *node, + struct clk *clk) +{ + int ret, cluster; + + for (cluster = 0; cluster < NPS_CLUSTER_NUM; cluster++) + nps_msu_reg_low_addr[cluster] = + nps_host_reg((cluster << NPS_CLUSTER_OFFSET), + NPS_MSU_BLKID, NPS_MSU_TICK_LOW); + + ret = clk_prepare_enable(clk); + if (ret) { + pr_err("Couldn't enable parent clock\n"); + return; + } + + nps_timer_rate = clk_get_rate(clk); + + ret = clocksource_mmio_init(nps_msu_reg_low_addr, "EZnps-tick", + nps_timer_rate, 301, 32, nps_clksrc_read); + if (ret) { + pr_err("Couldn't register clock source.\n"); + clk_disable_unprepare(clk); + } +} + +static void __init nps_timer_init(struct device_node *node) +{ + struct clk *clk; + + clk = of_clk_get(node, 0); + if (IS_ERR(clk)) { + pr_err("Can't get timer clock.\n"); + return; + } + + nps_setup_clocksource(node, clk); +} + +CLOCKSOURCE_OF_DECLARE(ezchip_nps400_clksrc, "ezchip,nps400-timer", + nps_timer_init);