From patchwork Wed Aug 29 13:29:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Brandt X-Patchwork-Id: 10580345 X-Patchwork-Delegate: geert@linux-m68k.org 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 EAFE614BD for ; Wed, 29 Aug 2018 13:30:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBFAB2B185 for ; Wed, 29 Aug 2018 13:30:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D051A2B1A1; Wed, 29 Aug 2018 13:30:17 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B6022B181 for ; Wed, 29 Aug 2018 13:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727941AbeH2R1O (ORCPT ); Wed, 29 Aug 2018 13:27:14 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:55355 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727204AbeH2R1O (ORCPT ); Wed, 29 Aug 2018 13:27:14 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie2.idc.renesas.com with ESMTP; 29 Aug 2018 22:30:15 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 4A6F682BAD; Wed, 29 Aug 2018 22:30:15 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.53,303,1531753200"; d="scan'208";a="290966452" Received: from unknown (HELO rtamta01.rta.renesas.com) ([143.103.48.75]) by relmlii2.idc.renesas.com with ESMTP; 29 Aug 2018 22:30:13 +0900 Received: from ubuntu.localdomain (unknown [143.103.58.62]) by rtamta01.rta.renesas.com (Postfix) with ESMTP id EBDA421E; Wed, 29 Aug 2018 13:30:09 +0000 (UTC) From: Chris Brandt To: Daniel Lezcano , Thomas Gleixner , Rob Herring , Mark Rutland Cc: devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven , Simon Horman , Chris Brandt Subject: [PATCH 1/2] clocksource/drivers/ostm: Delay driver registration Date: Wed, 29 Aug 2018 08:29:53 -0500 Message-Id: <20180829132954.64862-2-chris.brandt@renesas.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180829132954.64862-1-chris.brandt@renesas.com> References: <20180829132954.64862-1-chris.brandt@renesas.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The newer RZ/A clock control driver no longer registers all its clocks using DT, therefore the clocks required by this driver are no longer present at the beginning of boot. Because of this, TIMER_OF_DECLARE can no longer be used because this causes the driver to get probed too early before the parent clock exists, and the probe will fail with "ostm: Failed to get clock". So, we'll change this driver to register/probe during subsys_initcall which is after the appropriate clocks have been registered. Signed-off-by: Chris Brandt --- drivers/clocksource/renesas-ostm.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/clocksource/renesas-ostm.c b/drivers/clocksource/renesas-ostm.c index 6cffd7c6001a..fc5e4ac294b8 100644 --- a/drivers/clocksource/renesas-ostm.c +++ b/drivers/clocksource/renesas-ostm.c @@ -22,6 +22,7 @@ #include #include #include +#include /* * The OSTM contains independent channels. @@ -101,8 +102,12 @@ static u64 notrace ostm_read_sched_clock(void) static void __init ostm_init_sched_clock(struct ostm_device *ostm, unsigned long rate) { + unsigned long flags; + system_clock = ostm->base + OSTM_CNT; + local_irq_save(flags); sched_clock_register(ostm_read_sched_clock, 32, rate); + local_irq_restore(flags); } static int ostm_clock_event_next(unsigned long delta, @@ -192,9 +197,10 @@ static int __init ostm_init_clkevt(struct ostm_device *ostm, int irq, return 0; } -static int __init ostm_init(struct device_node *np) +static int __init ostm_probe(struct platform_device *pdev) { struct ostm_device *ostm; + struct device_node *np = pdev->dev.of_node; int ret = -EFAULT; struct clk *ostm_clk = NULL; int irq; @@ -262,4 +268,29 @@ static int __init ostm_init(struct device_node *np) return 0; } -TIMER_OF_DECLARE(ostm, "renesas,ostm", ostm_init); +static const struct of_device_id ostm_of_table[] = { + { + .compatible = "renesas,ostm", + }, + { /* sentinel */ } +}; + +static int ostm_remove(struct platform_device *pdev) +{ + return -EBUSY; /* cannot unregister clockevent and clocksource */ +} + +static struct platform_driver ostm_device_driver = { + .remove = ostm_remove, + .driver = { + .name = "ostm", + .of_match_table = of_match_ptr(ostm_of_table), + }, +}; + +static int __init ostm_init(void) +{ + return platform_driver_probe(&ostm_device_driver, ostm_probe); +} + +subsys_initcall(ostm_init);