From patchwork Mon Oct 15 12:31:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 10641765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B36B112B for ; Mon, 15 Oct 2018 12:32:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38E6629799 for ; Mon, 15 Oct 2018 12:32:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C74E297A4; Mon, 15 Oct 2018 12:32:33 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 6F17C29799 for ; Mon, 15 Oct 2018 12:32:32 +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=dV4KuHELPZ8stB5koxxG1vrQoXw66Zb5sqPrTqwMVR4=; b=AL/UFRXOwIogrvsGah5vnfSat9 oX/pgbAP5DDeGhbHJ8gMCF419chUskcreVCmkrJuoiVdh8ljzSURMp3UwpSRdRCY1SIK3hUBc5fIn k5G9tcM44+9uqXhuISjX0ykciX+4xFD/hXwRuUV/EN+lysz5FAnr4RbmoCPaFu1mXPpVkZ+/IBKHz bOyCj0SQZrTHackIaZpPI2t9ZjzrMO6Pk+pkxBrqcBr60DC1t4Jz5BDLDLZQRbqoKmFoT9PJy/rvo Wb/dSCOmOGIYeWXVfUkWGLG4SAVvVTPJjVQSMabyjqWLyaNLAyRIZkg+b5qyto6N+8w8kJb+/5rRi mwk0X3gg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC22u-0000oy-GB; Mon, 15 Oct 2018 12:32:28 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC22F-0000VI-Fx for linux-arm-kernel@lists.infradead.org; Mon, 15 Oct 2018 12:31:49 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181015123137euoutp02959350a1d04b8d6962a3d0574a94aa65~dyCI95cyV0736707367euoutp02m; Mon, 15 Oct 2018 12:31:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181015123137euoutp02959350a1d04b8d6962a3d0574a94aa65~dyCI95cyV0736707367euoutp02m DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539606697; bh=dLPRR3RFOQ7kx3DZxcRUOiHe8ffhAjgtdf+LPKBKU48=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=hH+rmRAeBcnGYaAhI6Zj3nRvGl28IjbF0XOjv83X3GUp8K5EoTnR8kvb02F7g0bU9 NvntQs4UiCjq6r5G99XIakWC8lYsUd+JwQwkmzJESfovX/NRQmYm56jLtX35vgKbC3 nKAMcZ9Gtzr3ADd2b9tkWh+qduHROByTl20qJe/Q= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181015123136eucas1p1eac06665ec0f052d8220f51f63d43e26~dyCIlCOG_1204612046eucas1p1o; Mon, 15 Oct 2018 12:31:36 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 29.DE.04294.8A884CB5; Mon, 15 Oct 2018 13:31:36 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181015123135eucas1p16a10ed68040141a714ab2977e2ad5e2d~dyCH61tfm1990719907eucas1p1p; Mon, 15 Oct 2018 12:31:35 +0000 (GMT) X-AuditID: cbfec7f4-c77a99c0000010c6-2b-5bc488a893a4 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 98.DE.04128.7A884CB5; Mon, 15 Oct 2018 13:31:35 +0100 (BST) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PGN00GZC4490K70@eusync1.samsung.com>; Mon, 15 Oct 2018 13:31:35 +0100 (BST) From: Marek Szyprowski To: linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/6] clocksource: exynos_mct: Add arch_timer cooperation mode for ARM64 Date: Mon, 15 Oct 2018 14:31:09 +0200 Message-id: <20181015123112.9379-4-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20181015123112.9379-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHIsWRmVeSWpSXmKPExsWy7djPc7orOo5EGyy8KWqxccZ6Vov3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4bFJSczLLUov0 7RK4MmYvP8xccES5YnLbPLYGxrsyXYycHBICJhI31s1mA7GFBJYwSnx/qtLFyAVkNzFJnL5+ hREkwSZgKNH1tgusSEQgW2L+3m52EJtZYAmzxM37DiC2sECMRM+Dn8wgNouAqsThK/uBejk4 eAVsJM5vTYLYJS+xesMBsBJOAVuJw/9XsUDstZG4cOwv4wRGngWMDKsYRVJLi3PTc4uN9IoT c4tL89L1kvNzNzECg3DbsZ9bdjB2vQs+xCjAwajEwyvAcyRaiDWxrLgy9xCjBAezkgivRMih aCHelMTKqtSi/Pii0pzU4kOM0hwsSuK85w0qo4QE0hNLUrNTUwtSi2CyTBycUg2MJes2fr3b qLd82jKhkncfTr26OvOh3wnnGc7P33//q77kpO/WjlPLOWafUVx5/WJ9l0GtIuOhD7qdWVzz 7KfIMKSsbziyz027e8v1WauaorSuMXluE5U41Csw113Kre605kzDOl6lWw8/Pg66NuOpscu7 jDBpa53J1XzHr531YPhm+2df7xrVGCWW4oxEQy3mouJEAGHAIBs+AgAA X-CMS-MailID: 20181015123135eucas1p16a10ed68040141a714ab2977e2ad5e2d X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181015123135eucas1p16a10ed68040141a714ab2977e2ad5e2d References: <20181015123112.9379-1-m.szyprowski@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181015_053147_704530_03D18AAA X-CRM114-Status: GOOD ( 21.75 ) 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: Bartlomiej Zolnierkiewicz , Marc Zyngier , Catalin Marinas , Daniel Lezcano , Will Deacon , Krzysztof Kozlowski , Inki Dae , Chanwoo Choi , Thomas Gleixner , Marek Szyprowski 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 To get ARM Architected Timers working on Samsung Exynos SoCs, one has to first configure and enable Exynos Multi-Core Timer, because they both share some common hardware blocks. This patch adds a mode of cooperation with arch_timer driver, so kernel can use CP15 based timer interface via arch_timer driver, which is mandatory on ARM64. In such mode driver only configures MCT registers and starts the timer but don't register any clocksource or events in the system. Those are left to be handled by arch_timer driver. Signed-off-by: Marek Szyprowski Reviewed-by: Krzysztof Kozlowski Reviewed-by: Chanwoo Choi Tested-by: Chanwoo Choi --- drivers/clocksource/exynos_mct.c | 52 +++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c index a379f11fad2d..06cd30a6d59a 100644 --- a/drivers/clocksource/exynos_mct.c +++ b/drivers/clocksource/exynos_mct.c @@ -57,6 +57,7 @@ #define TICK_BASE_CNT 1 enum { + MCT_INT_NONE = 0, MCT_INT_SPI, MCT_INT_PPI }; @@ -238,6 +239,9 @@ static int __init exynos4_clocksource_init(void) { exynos4_mct_frc_start(); + if (!mct_int_type) + return 0; + #if defined(CONFIG_ARM) exynos4_delay_timer.read_current_timer = &exynos4_read_current_timer; exynos4_delay_timer.freq = clk_rate; @@ -343,6 +347,9 @@ static struct irqaction mct_comp_event_irq = { static int exynos4_clockevent_init(void) { + if (!mct_int_type) + return 0; + mct_comp_device.cpumask = cpumask_of(0); clockevents_config_and_register(&mct_comp_device, clk_rate, 0xf, 0xffffffff); @@ -476,12 +483,12 @@ static int exynos4_mct_starting_cpu(unsigned int cpu) irq_force_affinity(evt->irq, cpumask_of(cpu)); enable_irq(evt->irq); - } else { + } else if (mct_int_type == MCT_INT_PPI) { enable_percpu_irq(mct_irqs[MCT_L0_IRQ], 0); } - clockevents_config_and_register(evt, clk_rate / (TICK_BASE_CNT + 1), - 0xf, 0x7fffffff); - + if (mct_int_type) + clockevents_config_and_register(evt, + clk_rate / (TICK_BASE_CNT + 1), 0xf, 0x7fffffff); return 0; } @@ -496,7 +503,7 @@ static int exynos4_mct_dying_cpu(unsigned int cpu) if (evt->irq != -1) disable_irq_nosync(evt->irq); exynos4_mct_write(0x1, mevt->base + MCT_L_INT_CSTAT_OFFSET); - } else { + } else if (mct_int_type == MCT_INT_PPI) { disable_percpu_irq(mct_irqs[MCT_L0_IRQ]); } return 0; @@ -529,7 +536,7 @@ static int __init exynos4_timer_resources(struct device_node *np, void __iomem * &percpu_mct_tick); WARN(err, "MCT: can't request IRQ %d (%d)\n", mct_irqs[MCT_L0_IRQ], err); - } else { + } else if (mct_int_type == MCT_INT_SPI) { for_each_possible_cpu(cpu) { int mct_irq = mct_irqs[MCT_L0_IRQ + cpu]; struct mct_clock_event_device *pcpu_mevt = @@ -564,7 +571,7 @@ static int __init exynos4_timer_resources(struct device_node *np, void __iomem * out_irq: if (mct_int_type == MCT_INT_PPI) { free_percpu_irq(mct_irqs[MCT_L0_IRQ], &percpu_mct_tick); - } else { + } else if (mct_int_type == MCT_INT_SPI) { for_each_possible_cpu(cpu) { struct mct_clock_event_device *pcpu_mevt = per_cpu_ptr(&percpu_mct_tick, cpu); @@ -585,17 +592,28 @@ static int __init mct_init_dt(struct device_node *np, unsigned int int_type) mct_int_type = int_type; - /* This driver uses only one global timer interrupt */ - mct_irqs[MCT_G0_IRQ] = irq_of_parse_and_map(np, MCT_G0_IRQ); + if (IS_ENABLED(CONFIG_ARM64) && IS_ENABLED(CONFIG_ARM_ARCH_TIMER)) { + struct device_node *np = of_find_compatible_node(NULL, NULL, + "arm,armv8-timer"); + if (np) { + mct_int_type = MCT_INT_NONE; + of_node_put(np); + } + } - /* - * Find out the number of local irqs specified. The local - * timer irqs are specified after the four global timer - * irqs are specified. - */ - nr_irqs = of_irq_count(np); - for (i = MCT_L0_IRQ; i < nr_irqs; i++) - mct_irqs[i] = irq_of_parse_and_map(np, i); + if (mct_int_type) { + /* This driver uses only one global timer interrupt */ + mct_irqs[MCT_G0_IRQ] = irq_of_parse_and_map(np, MCT_G0_IRQ); + + /* + * Find out the number of local irqs specified. The local + * timer irqs are specified after the four global timer + * irqs are specified. + */ + nr_irqs = of_irq_count(np); + for (i = MCT_L0_IRQ; i < nr_irqs; i++) + mct_irqs[i] = irq_of_parse_and_map(np, i); + } ret = exynos4_timer_resources(np, of_iomap(np, 0)); if (ret)