From patchwork Sun Sep 22 16:45:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 2924641 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1E72EBFF05 for ; Sun, 22 Sep 2013 16:46:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 11F8D20108 for ; Sun, 22 Sep 2013 16:46:39 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F3EFC200F3 for ; Sun, 22 Sep 2013 16:46:37 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VNmnq-0000qk-31; Sun, 22 Sep 2013 16:46:34 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VNmnn-0003nD-LI; Sun, 22 Sep 2013 16:46:31 +0000 Received: from mail-bk0-f43.google.com ([209.85.214.43]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VNmnk-0003mT-82 for linux-arm-kernel@lists.infradead.org; Sun, 22 Sep 2013 16:46:29 +0000 Received: by mail-bk0-f43.google.com with SMTP id mz13so404829bkb.16 for ; Sun, 22 Sep 2013 09:46:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ViT+Sgg5G+26oH1ZZROYoljmaCs9uDDWUqyGJ12JCoI=; b=li2vAvQt9esPaBOx/pLu4eFLVjbyl8zdltVKjy7H5O9R342NYLrJEpeaWorvvHEWVu v+VpweqbKiL/npG4fxr2SjJh18p5xcu269TaZy61bVLm/h7CnaxBbl4Jb0ov4NKpWi05 jTGhyFE9xmcE0i8INLxSk/GnoUvtRoORx3Akhu2q9ndcaWiqczlUdju0Pwg2pTBzLmV2 xf59ehuFViISoRofUNoOVQ4bej80qGv6xP56w/gbsWwyLYAElyMqd0CoAb9LXkAJ4e3x NQAWGzUmkXKlC74//G9Ov18mQTWDCkavuJPdCHfNfRrnOVfyoIlzwjYtO9mIYayptbVJ oQFg== X-Received: by 10.205.68.137 with SMTP id xy9mr1998536bkb.28.1379868363329; Sun, 22 Sep 2013 09:46:03 -0700 (PDT) Received: from topkick.lan (dslc-082-083-247-252.pools.arcor-ip.net. [82.83.247.252]) by mx.google.com with ESMTPSA id l5sm7382427bko.7.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 22 Sep 2013 09:46:02 -0700 (PDT) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [PATCH v2 02/26] clk: nomadik: move src init out of nomadik_clk_init Date: Sun, 22 Sep 2013 18:45:32 +0200 Message-Id: <1379868332-2808-1-git-send-email-sebastian.hesselbarth@gmail.com> In-Reply-To: <1379526839-14798-3-git-send-email-sebastian.hesselbarth@gmail.com> References: <1379526839-14798-3-git-send-email-sebastian.hesselbarth@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130922_124628_540920_AA9A8B41 X-CRM114-Status: GOOD ( 17.70 ) X-Spam-Score: -2.7 (--) Cc: Mike Turquette , Arnd Bergmann , Linus Walleij , linux-kernel@vger.kernel.org, STEricsson , Olof Johansson , linux-arm-kernel@lists.infradead.org, Alessandro Rubini X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP nomadik_clk_init currently also maps system reset controller base address used by clocks and registers a reboot notifier. To allow further cleanup of nomadik clk setup, this moves system reset controller setup from nomadik_clk_init to its own function. Signed-off-by: Sebastian Hesselbarth Acked-by: Linus Walleij --- Changelog: v1->v2: - adapt to clk-nomadik changes Cc: Olof Johansson Cc: Arnd Bergmann Cc: Alessandro Rubini Cc: Linus Walleij Cc: STEricsson Cc: Mike Turquette Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/clk/clk-nomadik.c | 144 +++++++++++++++++++++++---------------------- 1 file changed, 74 insertions(+), 70 deletions(-) diff --git a/drivers/clk/clk-nomadik.c b/drivers/clk/clk-nomadik.c index 4d978a3..06b29c26 100644 --- a/drivers/clk/clk-nomadik.c +++ b/drivers/clk/clk-nomadik.c @@ -62,6 +62,79 @@ static DEFINE_SPINLOCK(src_lock); /* Base address of the SRC */ static void __iomem *src_base; +static int nomadik_clk_reboot_handler(struct notifier_block *this, + unsigned long code, + void *unused) +{ + u32 val; + + /* The main chrystal need to be enabled for reboot to work */ + val = readl(src_base + SRC_XTALCR); + val &= ~SRC_XTALCR_MXTALOVER; + val |= SRC_XTALCR_MXTALEN; + pr_crit("force-enabling MXTALO\n"); + writel(val, src_base + SRC_XTALCR); + return NOTIFY_OK; +} + +static struct notifier_block nomadik_clk_reboot_notifier = { + .notifier_call = nomadik_clk_reboot_handler, +}; + +static const struct of_device_id nomadik_src_match[] __initconst = { + { .compatible = "stericsson,nomadik-src" }, + { /* sentinel */ } +}; + +static void nomadik_src_init(void) +{ + struct device_node *np; + u32 val; + + np = of_find_matching_node(NULL, nomadik_src_match); + if (!np) { + pr_crit("no matching node for SRC, aborting clock init\n"); + return; + } + src_base = of_iomap(np, 0); + if (!src_base) { + pr_err("%s: must have src parent node with REGS (%s)\n", + __func__, np->name); + return; + } + + /* Set all timers to use the 2.4 MHz TIMCLK */ + val = readl(src_base + SRC_CR); + val |= SRC_CR_T0_ENSEL; + val |= SRC_CR_T1_ENSEL; + val |= SRC_CR_T2_ENSEL; + val |= SRC_CR_T3_ENSEL; + val |= SRC_CR_T4_ENSEL; + val |= SRC_CR_T5_ENSEL; + val |= SRC_CR_T6_ENSEL; + val |= SRC_CR_T7_ENSEL; + writel(val, src_base + SRC_CR); + + val = readl(src_base + SRC_XTALCR); + pr_info("SXTALO is %s\n", + (val & SRC_XTALCR_SXTALDIS) ? "disabled" : "enabled"); + pr_info("MXTAL is %s\n", + (val & SRC_XTALCR_MXTALSTAT) ? "enabled" : "disabled"); + if (of_property_read_bool(np, "disable-sxtalo")) { + /* The machine uses an external oscillator circuit */ + val |= SRC_XTALCR_SXTALDIS; + pr_info("disabling SXTALO\n"); + } + if (of_property_read_bool(np, "disable-mxtalo")) { + /* Disable this too: also run by external oscillator */ + val |= SRC_XTALCR_MXTALOVER; + val &= ~SRC_XTALCR_MXTALEN; + pr_info("disabling MXTALO\n"); + } + writel(val, src_base + SRC_XTALCR); + register_reboot_notifier(&nomadik_clk_reboot_notifier); +} + /** * struct clk_pll1 - Nomadik PLL1 clock * @hw: corresponding clock hardware entry @@ -487,11 +560,6 @@ static void __init of_nomadik_src_clk_setup(struct device_node *np) of_clk_add_provider(np, of_clk_src_simple_get, clk); } -static const struct of_device_id nomadik_src_match[] __initconst = { - { .compatible = "stericsson,nomadik-src" }, - { /* sentinel */ } -}; - static const struct of_device_id nomadik_src_clk_match[] __initconst = { { .compatible = "fixed-clock", @@ -516,72 +584,8 @@ static const struct of_device_id nomadik_src_clk_match[] __initconst = { { /* sentinel */ } }; -static int nomadik_clk_reboot_handler(struct notifier_block *this, - unsigned long code, - void *unused) -{ - u32 val; - - /* The main chrystal need to be enabled for reboot to work */ - val = readl(src_base + SRC_XTALCR); - val &= ~SRC_XTALCR_MXTALOVER; - val |= SRC_XTALCR_MXTALEN; - pr_crit("force-enabling MXTALO\n"); - writel(val, src_base + SRC_XTALCR); - return NOTIFY_OK; -} - -static struct notifier_block nomadik_clk_reboot_notifier = { - .notifier_call = nomadik_clk_reboot_handler, -}; - void __init nomadik_clk_init(void) { - struct device_node *np; - u32 val; - - np = of_find_matching_node(NULL, nomadik_src_match); - if (!np) { - pr_crit("no matching node for SRC, aborting clock init\n"); - return; - } - src_base = of_iomap(np, 0); - if (!src_base) { - pr_err("%s: must have src parent node with REGS (%s)\n", - __func__, np->name); - return; - } - - /* Set all timers to use the 2.4 MHz TIMCLK */ - val = readl(src_base + SRC_CR); - val |= SRC_CR_T0_ENSEL; - val |= SRC_CR_T1_ENSEL; - val |= SRC_CR_T2_ENSEL; - val |= SRC_CR_T3_ENSEL; - val |= SRC_CR_T4_ENSEL; - val |= SRC_CR_T5_ENSEL; - val |= SRC_CR_T6_ENSEL; - val |= SRC_CR_T7_ENSEL; - writel(val, src_base + SRC_CR); - - val = readl(src_base + SRC_XTALCR); - pr_info("SXTALO is %s\n", - (val & SRC_XTALCR_SXTALDIS) ? "disabled" : "enabled"); - pr_info("MXTAL is %s\n", - (val & SRC_XTALCR_MXTALSTAT) ? "enabled" : "disabled"); - if (of_property_read_bool(np, "disable-sxtalo")) { - /* The machine uses an external oscillator circuit */ - val |= SRC_XTALCR_SXTALDIS; - pr_info("disabling SXTALO\n"); - } - if (of_property_read_bool(np, "disable-mxtalo")) { - /* Disable this too: also run by external oscillator */ - val |= SRC_XTALCR_MXTALOVER; - val &= ~SRC_XTALCR_MXTALEN; - pr_info("disabling MXTALO\n"); - } - writel(val, src_base + SRC_XTALCR); - register_reboot_notifier(&nomadik_clk_reboot_notifier); - + nomadik_src_init(); of_clk_init(nomadik_src_clk_match); }