From patchwork Sat Feb 6 16:16:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noam Camus X-Patchwork-Id: 579846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::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 860EC14076E for ; Sun, 7 Feb 2016 03:20:39 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ezchip.onmicrosoft.com header.i=@ezchip.onmicrosoft.com header.b=oKAJ21Jm; 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 1aS5bC-0002Y9-6H; Sat, 06 Feb 2016 16:20:38 +0000 Received: from mail-db5eur01on0058.outbound.protection.outlook.com ([104.47.2.58] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aS5b8-0002UI-Ks for linux-snps-arc@lists.infradead.org; Sat, 06 Feb 2016 16:20:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ezchip.onmicrosoft.com; s=selector1-ezchip-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ifk8/fMJVUpHVcOV9hjpAMCIud3MTqopUvU1/c/zaOY=; b=oKAJ21JmuRdTBtYDPDLAIdDd3xGTx6gp7mu9gy1kWoSEEh29u9kX7sBmaby2eC7TxpddqBwCAmGCFE7tAraSa4Lxdc5fIJTQaT0j9662FHr6+m6Ufs5/T+AaElUzW/dCdDbe6HGkSolTvECw87fnEddhKcf+9MlmHjYLFYtvjvM= Received: from HE1PR02CA0079.eurprd02.prod.outlook.com (10.163.170.47) by DB3PR02MB090.eurprd02.prod.outlook.com (10.141.2.143) with Microsoft SMTP Server (TLS) id 15.1.403.16; Sat, 6 Feb 2016 16:20:11 +0000 Received: from AM1FFO11FD044.protection.gbl (2a01:111:f400:7e00::126) by HE1PR02CA0079.outlook.office365.com (2a01:111:e400:5350::47) with Microsoft SMTP Server (TLS) id 15.1.403.16 via Frontend Transport; Sat, 6 Feb 2016 16:20:10 +0000 Authentication-Results: spf=fail (sender IP is 212.179.42.66) smtp.mailfrom=ezchip.com; kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=ezchip.com; Received-SPF: Fail (protection.outlook.com: domain of ezchip.com does not designate 212.179.42.66 as permitted sender) receiver=protection.outlook.com; client-ip=212.179.42.66; helo=ezex10.ezchip.com; Received: from ezex10.ezchip.com (212.179.42.66) by AM1FFO11FD044.mail.protection.outlook.com (10.174.64.233) with Microsoft SMTP Server (TLS) id 15.1.409.7 via Frontend Transport; Sat, 6 Feb 2016 16:20:09 +0000 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; Sat, 6 Feb 2016 18:19:46 +0200 From: Noam Camus To: Subject: [PATCH v3 2/3] clocksource: Add NPS400 timers driver Date: Sat, 6 Feb 2016 18:16:45 +0200 Message-ID: <1454775406-25277-3-git-send-email-noamc@ezchip.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1454418899-25500-1-git-send-email-noamc@ezchip.com> References: <1454418899-25500-1-git-send-email-noamc@ezchip.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-11.0.0.1191-8.000.1202-22116.000 X-TM-AS-Result: No--16.944800-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11FD044; 1:aaV8jql7YkIdO52bIZRaY2lEoaOBaImTSgQQu1GpuI56wP29Tw+/4VvqALM8LWsibnMr7Gh77RH/2pHaXMUzQl7ZHchfnTksdO9nmOQf2paL8PH6TvOSRboq0a97cZdMdXIsr7PHZiAm0NJCDx4WTnBLKm7Gb2qDb2j+shgBy+hpCU79ZGimc4goTFNBiXEJIx46gwz6tOUpSDfCBXsfLTm0J6JQKw3FoqYdmarLu+H8Or1DiNx/Dx0jQt1IOqsffM7uQf9HcoBHNQupTHn/xNIZWRsC3QgyI6JVqNWTJR3b70d0HwEQltfrhRLRJL3VXf6vvKGysup3v2Wug0Lb+GE4b6NaLrp+lUH1JXIoqebs612uh4CGqsXfFy1iH7JtJqyBNkZVEug+sDSH9PZbC5XKOnkHRz9CbQunb/mxnDXx4lYLxH0hLvQvn4cZ0dnwesOsKROBR7jjHuJcFCjTvooj3Cx6wPVLPGNGSwQtnAw= X-Forefront-Antispam-Report: CIP:212.179.42.66; CTRY:IL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(339900001)(189002)(199003)(19580405001)(6806005)(189998001)(5008740100001)(50226001)(104016004)(87936001)(48376002)(49486002)(5003940100001)(76176999)(92566002)(110136002)(50986999)(105606002)(50466002)(1220700001)(2351001)(5001970100001)(33646002)(77096005)(36756003)(229853001)(1096002)(2906002)(575784001)(85426001)(4326007)(47776003)(2950100001)(19580395003)(86362001)(586003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR02MB090; H:ezex10.ezchip.com; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3PR02MB090; 2:eZ0zjzY8sae9hKlAZfSLsCXES7bhp13tYw+rUdlHT8OjFcR/ez3ieinAvhc1DuedSOZA+enjn9LwQe4LfLiIW+Iwyph6RB64+qUuX628A7GLoa1BwEKFMv8xf7I+Zo4yYR32Pvw1lP/auBq8on0pJg==; 3:HEie7pEwzfOmAelmXMO2jfGkWrrHIPYImxwD0EJPDEfckbiIBOpebl7wHn6yb1SvDOrf9OGa8VS+avjXH+fbchJoSq4QaDJvpXzjnUte0/GaXzU01wu6Ju802aEuU6ucbHNfF1hlcSQzjZhGu9LaA+Q/GGgNccbAuh3rvwaHwyoBaw929QgnplUfjL/hFpKgEPxNBcsTEo7LFH9eMfzZndxnwqhyoAJGWM9LXpwfT4s=; 25:RigDbtdQm78UBrcO+AH/v9qzvJJ+vrzFxOVusmmIySKXOL4HGppuYNNCcR1ZxBxwh1WqcjJWsd5pifNR7nPupUW+XFcDhIycVmqtlYo+IEJDIecyXGFoEgzp6OqkRUBvkqEtxpHNJVEo6DYIl2OUkmSR6IQYGOLAsyxtBu5TTBSiFLxwTOc20q6NhzzsKbRVhdpmqmgugNz99Isf16oilngBwvq192noVgOI9qDc9QT03hGAASu/jUHUiV8QJ9oTjk10vkCXvtKPYVFMTmBE82+Lkl40LTUIhWfIx1ayuozDWguiGDDfbljiPqgyuv1F; 20:IdNDTRWTWb3Eld5EhMM3+wBXC3ePwBaEA/cWwrXhMqLCu5Qw/3rjg6kMIpL8w235OfejTdxACGS4RrHYYSz7PWRDJVWZ7ptZJPQ31YVdvQgT9861/U037U71yUWcvn3ODvavQwxTLRLu1YXfiShD8CgGA26/s8IurDIfDG/pKvk= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB3PR02MB090; X-MS-Office365-Filtering-Correlation-Id: be8dec24-ca76-4b5a-9f3d-08d32f116271 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(13017025)(13024025)(13015025)(13018025)(5005006)(13023025)(10201501046)(3002001); SRVR:DB3PR02MB090; BCL:0; PCL:0; RULEID:; SRVR:DB3PR02MB090; X-Microsoft-Exchange-Diagnostics: 1; DB3PR02MB090; 4:VhQXCHJ7H9gH8Wu5tL/J2Yv2x9ebECUmSCKG9EuLyW1MrCzNSNjAyl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gtGyaixnmf1IKLnQNI+N7mXsQwI4TbUY/4xH8GJHHzjfat5Gl231b?= =?us-ascii?Q?RKHOFj/6qfrbPzLUViW1QNYe/uJ2AAQEoSlw03b7/8r7ZTgOoJc75qtL7MIS?= =?us-ascii?Q?63gwMeZQmNVtkoBKT3gnNOYxIUXZefSOlbBsN+KVLNO9rWecA8gBM1zbYOZM?= =?us-ascii?Q?mcKbtjeRiU91PaGj8nboFuOU+J4xcCfeAjwupsK9Myo662UaTqMQtcoRCLvN?= =?us-ascii?Q?s7affg4CruF84NtAO3AuIZ4EtWkyShwFLQX4PuNV7mcP4HhfkU9k9/J/8x5u?= =?us-ascii?Q?UrS3Lnn3Xdui+b6KApJlP3ruKy4F+3T1RnxeWvwuODAtN7d95J7LfO/6Xzti?= =?us-ascii?Q?adjoNHIZg7t+Nm/mAzXmZ9BErBiiVa9B+yQvFWTpMTSBJbzlPQRU+qpLbjLd?= =?us-ascii?Q?vCCYpP2DbCTKMzXneJ+q7pnSxVdneOQuWacRuHmmcNLjHbe/xS5ASgtocLGb?= =?us-ascii?Q?HeDTfTYsOpl4yzZg8w6x9eEaRV4oZjYuKN//t7Q48i1wTFAoXKhQU1CHntr2?= =?us-ascii?Q?RDxLN+PcFRDymGZG57TzQUlAKqYvSuws4ZHBtgqDbYzA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; DB3PR02MB090; 5:UHzlu7QslmCQYxy1me6cCMVpk+EPgqDL8o3aEM3nvk9Cuf38ipRoUEbbRxVN5c/6qrTn3S4XL5JUdGHWNjGthbXjdiz26ywX5qc4fRZyKJdqibWXfqQXk85Bdhuj52HBnYtpNsuJIY279fqM4q5X4g==; 24:evi56RwXa/92oaoh4Qx0yNGV8sIxQsmV7/ATPGrUlRbecRuwbn0t6v4SwolCi6JvkxQRLhQDiwdsR3rG5DIYfUu+fSG5RGHh4JRrPYYycFE= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2016 16:20:09.7410 (UTC) X-MS-Exchange-CrossTenant-Id: 0fc16e0a-3cd3-4092-8b2f-0a42cff122c3 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=0fc16e0a-3cd3-4092-8b2f-0a42cff122c3; Ip=[212.179.42.66]; Helo=[ezex10.ezchip.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR02MB090 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160206_082035_106269_1ACCFC3A X-CRM114-Status: GOOD ( 15.07 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [104.47.2.58 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [104.47.2.58 listed in wl.mailspike.net] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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: marc.zyngier@arm.com, daniel.lezcano@linaro.org, talz@ezchip.com, cmetcalf@ezchip.com, Rob Herring , Noam Camus , John Stultz , Thomas Gleixner , linux-snps-arc@lists.infradead.org, giladb@ezchip.com 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 Acked-by: Vineet Gupta --- .../bindings/timer/ezchip,nps400-timer.txt | 15 ++++ drivers/clocksource/Kconfig | 9 ++ drivers/clocksource/Makefile | 1 + drivers/clocksource/timer-nps.c | 84 ++++++++++++++++++++ 4 files changed, 109 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 2eb5f0e..0d0ba91 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -132,6 +132,15 @@ 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_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 56bd16e..056cffd 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..bf9a490 --- /dev/null +++ b/drivers/clocksource/timer-nps.c @@ -0,0 +1,84 @@ +/* + * Copyright(c) 2015 EZchip Technologies. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * The full GNU General Public License is included in this distribution in + * the file called "COPYING". + */ + +#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 struct clocksource nps_counter = { + .name = "EZnps-tick", + .rating = 301, + .read = nps_clksrc_read, + .mask = CLOCKSOURCE_MASK(32), + .flags = CLOCK_SOURCE_IS_CONTINUOUS, +}; + +static void __init nps_setup_clocksource(struct device_node *node, + struct clk *clk) +{ + struct clocksource *clksrc = &nps_counter; + 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"); + + nps_timer_rate = clk_get_rate(clk); + + ret = clocksource_register_hz(clksrc, nps_timer_rate); + if (ret) + pr_err("Couldn't register clock source.\n"); +} + +static void __init nps_timer_init(struct device_node *node) +{ + struct clk *clk; + + clk = of_clk_get(node, 0); + if (IS_ERR(clk)) + panic("Can't get timer clock"); + + nps_setup_clocksource(node, clk); +} + +CLOCKSOURCE_OF_DECLARE(ezchip_nps400_clksrc, "ezchip,nps400-timer", + nps_timer_init);