From patchwork Wed Oct 18 12:58:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 10014651 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 855E660215 for ; Wed, 18 Oct 2017 12:59:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F35E28B05 for ; Wed, 18 Oct 2017 12:59:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 610F828B3C; Wed, 18 Oct 2017 12:59:45 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 DF73D28B05 for ; Wed, 18 Oct 2017 12:59:44 +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=6TqdwzKkOc192b/ZPLM5FUnTshsuW2Q+baqtZDlsUKg=; b=jycRoqErnBedmQ/M2DUCHxbAFa r37bJtmXsQ3u/cP6LKQ0sgE7CMmzjJPTJfTBX70ISpA2oohGfUp01f+drKg3cgRvJo38LqxhIGD7L mw4daMqW54zrZ6GG8dZvz2AfLQtJkiMAbOfCIb+VnWBD7sYth0zbCIySgQa33gf10s2QMXXZuiLy5 onI+G+qkfKm+MNrFy1TZJOywDEqqoRDH/x3xOOwuZyqOlClAXOOUP9zGaDoeP2GB/AQt8Xt44uvft Laq0iadwi5q4u2wBxeqU0nJaMZ6ApbRBtSQnLe6tPYZnjSnGTYiqYR6giPt6H5V0ClRgixUieNisl sDLucvnw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e4nwl-00066a-TB; Wed, 18 Oct 2017 12:59:43 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e4nw4-0005Se-Gy for linux-arm-kernel@lists.infradead.org; Wed, 18 Oct 2017 12:59:05 +0000 Received: by mail-wr0-x241.google.com with SMTP id l1so4930601wrc.3 for ; Wed, 18 Oct 2017 05:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kxSAjGL/a34TNgfjLAncz+CWDVEX3RnZVjD4dYHs6uY=; b=CSC7llOi+CSDuvI0eDkuyYgJvqEHxa5VFcAJ16okMfkclPLjJAd3ScfZesQU8/S7/E e1miExDxX90kpNHUrpdJMpZGr7fBfjFYkFLsXws9MwVvcIZTfTXUo5cStz3zJ1lyNsiB Sbr44Ga3s2z6S1+C8wr48SDu3fsEuYtVBZuIA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kxSAjGL/a34TNgfjLAncz+CWDVEX3RnZVjD4dYHs6uY=; b=OY01ooKdxT9eUWHgmEN3nWa+AZX5sgkXWod8snRvcgYfaxCfxUmCwp5XNbocZKrPFQ 45ScXOaCRETNz5RdEdgI7HOxSF4BnGuf3weaSnVqJWk+yvwMkB8RnvH+y8lOJmj9jvd6 fHBSeFMuIy6xeIAOFiPNCnp9yJhsoztJvfTj9mSEBhVTNnjkKUG+vaAQTe/8GMMWMVpQ rMYF/LUDAHwk4yi/gNmP/b1w/lDGqYXs0jMrKQAOS/IvXcSj+diHMdSIAo1rcfMM+0Xq yOL8kitn03/jqDVdc93FUTcPCM1g34VoTteEfV7DQf0QXcZZIndjeAY0DBfpuaprW8MB yJKg== X-Gm-Message-State: AMCzsaVIhrgacXA1DX88hKK4JRFEmzvosui5v3wlmUZq6Zhf+2mq35Cw 0kz77JMbEOcvE6pso7gtZUXBSw== X-Google-Smtp-Source: ABhQp+RAyW47WVG6h4B6M7+mzJef8uPRDsNJy9U2hXALlcd5WA+HVDx6IQU2449tgnb7JK8d96+qtg== X-Received: by 10.223.195.110 with SMTP id e43mr6342802wrg.219.1508331521655; Wed, 18 Oct 2017 05:58:41 -0700 (PDT) Received: from lmecxl0911.lme.st.com ([80.215.70.168]) by smtp.gmail.com with ESMTPSA id m23sm14169908wrm.75.2017.10.18.05.58.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Oct 2017 05:58:41 -0700 (PDT) From: Benjamin Gaignard To: robh+dt@kernel.org, mark.rutland@arm.com, linux@armlinux.org.uk, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, daniel.lezcano@linaro.org, tglx@linutronix.de, ludovic.barre@st.com, julien.thierry@arm.com Subject: [PATCH v6 3/5] clocksource: stm32: only use 32 bits timers Date: Wed, 18 Oct 2017 14:58:24 +0200 Message-Id: <1508331506-23782-4-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508331506-23782-1-git-send-email-benjamin.gaignard@linaro.org> References: <1508331506-23782-1-git-send-email-benjamin.gaignard@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171018_055901_035581_D00FE581 X-CRM114-Status: GOOD ( 12.72 ) 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: devicetree@vger.kernel.org, Benjamin Gaignard , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 16 bits hardware are not enough accure to be used. Do no allow them to be probed by tested max counter value. Signed-off-by: Benjamin Gaignard --- drivers/clocksource/timer-stm32.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/clocksource/timer-stm32.c b/drivers/clocksource/timer-stm32.c index 67dcf48..c834648 100644 --- a/drivers/clocksource/timer-stm32.c +++ b/drivers/clocksource/timer-stm32.c @@ -81,9 +81,9 @@ static irqreturn_t stm32_clock_event_handler(int irq, void *dev_id) static int __init stm32_clockevent_init(struct device_node *node) { struct reset_control *rstc; - unsigned long max_delta; - int ret, bits, prescaler = 1; + unsigned long max_arr; struct timer_of *to; + int ret; to = kzalloc(sizeof(*to), GFP_KERNEL); if (!to) @@ -113,29 +113,27 @@ static int __init stm32_clockevent_init(struct device_node *node) /* Detect whether the timer is 16 or 32 bits */ writel_relaxed(~0U, timer_of_base(to) + TIM_ARR); - max_delta = readl_relaxed(timer_of_base(to) + TIM_ARR); - if (max_delta == ~0U) { - prescaler = 1; - bits = 32; - } else { - prescaler = 1024; - bits = 16; + max_arr = readl_relaxed(timer_of_base(to) + TIM_ARR); + if (max_arr != ~0U) { + pr_err("32 bits timer is needed\n"); + ret = -EINVAL; + goto deinit; } + writel_relaxed(0, timer_of_base(to) + TIM_ARR); - writel_relaxed(prescaler - 1, timer_of_base(to) + TIM_PSC); + writel_relaxed(0, timer_of_base(to) + TIM_PSC); writel_relaxed(TIM_EGR_UG, timer_of_base(to) + TIM_EGR); writel_relaxed(TIM_DIER_UIE, timer_of_base(to) + TIM_DIER); writel_relaxed(0, timer_of_base(to) + TIM_SR); clockevents_config_and_register(&to->clkevt, - timer_of_period(to), 0x60, max_delta); - - pr_info("%pOF: STM32 clockevent driver initialized (%d bits)\n", - node, bits); + timer_of_period(to), 0x60, ~0U); return 0; +deinit: + timer_of_deinit(to); err: kfree(to); return ret;