From patchwork Wed Oct 18 07:43:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 10013925 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 A8D6260215 for ; Wed, 18 Oct 2017 07:44:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99ECD28620 for ; Wed, 18 Oct 2017 07:44:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CF4728AFB; Wed, 18 Oct 2017 07:44:47 +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 2197928620 for ; Wed, 18 Oct 2017 07:44:46 +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=bn8igjASD5zxlBl+JQ/idOg0R5jsUdK7kUAC88tSHJ0=; b=MuOZHOvtdp2YF+hDdQDkW+uN3H MysS6tUlsAHobkdAZcDjfUpAzag4ltjIhNzsMGMqd+w1coc/Ge+1NNvUFSwqweHzoyTu75GXd8e5B d5PpK1BSJZ2xD9Fq7yPQWlLYjhW3Za+yzskYcmVblJApMAp7W0OlJYd6GFBUcOZ8LuXFFglZSPgfu bxl/SFc1i+iWE/2NuC72+/Gas9G2ixvvqtjnI3umEjt+hMXKnC/gTmYqpac0pUZjhnqdKtFDMlc+k brXpsXhi1vXbbu2Yu/z2isrPWzoC3bcR2HoB7AV5huyA9W7qLhisUihs1zTBeij8jFdha9U1Obz1E /cApqpLg==; 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 1e4j1y-0006a8-7P; Wed, 18 Oct 2017 07:44:46 +0000 Received: from mail-wr0-x236.google.com ([2a00:1450:400c:c0c::236]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e4j1W-00063R-SI for linux-arm-kernel@lists.infradead.org; Wed, 18 Oct 2017 07:44:20 +0000 Received: by mail-wr0-x236.google.com with SMTP id l24so4021517wre.1 for ; Wed, 18 Oct 2017 00:43:58 -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=YRMDrn0GKD9HNuTlCPy7fMgZ2opjSCTXVxBYgWeWkDc=; b=hAcVBqNxXaVllW8HUDXkujDywdKp7cEBD1F5TgnIiwrN7p6at1W2VaBhUdQJusjXgu Ar0XRc349/kmKx4b3nyVBPh7/vZv0nlpacGbcyGEwSkJTHFVtMqe6FCv6Dvtn28bDlSn F4lXdPvlpZ8aOnCJPuGpFxeXQb9ZaBLHYCeZo= 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=YRMDrn0GKD9HNuTlCPy7fMgZ2opjSCTXVxBYgWeWkDc=; b=pShdzyPWrzkZdFk9KjPUDrtgLaMQEfi57+4v1yqnWmJHCPHMpF7ezC+AeAuA7Ah49r 1AUR14gynCUvu4T3G8S+dfnorf9BgUh9A0Uzlp+2dwi/XTDZ0lvs17g7cpWnfSlwbDUl c16tR24o45c0+UFqaElDPOUnmEGJnu+sb54r2AAhJOTyBmp/+TkKJVMp9der+2hNi0It YSI6ZCaDZfa3VdDE2VVQhOSFJxILOQYPgY/6hc/5eb3TKtG1YE0xjA5pNdhmou73B0x+ /xkFsS5ftX9RO5RATn1eEoA3LSteSoOIxaBsjPia6LrvBsUSBLAC1ktvFkeQGh4DdF+V wmyA== X-Gm-Message-State: AMCzsaUs6Gqc+hrQLB5s62FzFzXGhdkO6ZIY7osKzNOO+jcxvjPcr0hB psHHl26ExFaNQuaop6DqXFLBbA== X-Google-Smtp-Source: ABhQp+TiVw9RF8sdswU+egKqZQhT1Su8A5GLxRiKOuzgdbDmz9C18qdZZp/4+nyesTbytdZKfkFzYw== X-Received: by 10.223.138.231 with SMTP id z36mr6167387wrz.154.1508312636830; Wed, 18 Oct 2017 00:43:56 -0700 (PDT) Received: from lmecxl0911.lme.st.com ([80.215.78.118]) by smtp.gmail.com with ESMTPSA id v78sm7855063wmv.48.2017.10.18.00.43.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Oct 2017 00:43:56 -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 Subject: [PATCH v5 2/4] clocksource: stm32: only use 32 bits timers Date: Wed, 18 Oct 2017 09:43:32 +0200 Message-Id: <1508312614-27750-3-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508312614-27750-1-git-send-email-benjamin.gaignard@linaro.org> References: <1508312614-27750-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_004419_068326_D07AA25D X-CRM114-Status: GOOD ( 12.94 ) 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 | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/clocksource/timer-stm32.c b/drivers/clocksource/timer-stm32.c index abff21c..f7e4eec 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,26 +113,21 @@ 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"); + return -EINVAL; } + 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; }