Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp316770pxj; Thu, 20 May 2021 09:59:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycoEAaQowwzYSIW4HQWeZkjCUCZn/QrQFQ2cv9nyiC7Ztu9Dr2ET4O+pQO48WC0e1mn368 X-Received: by 2002:a02:8308:: with SMTP id v8mr7647115jag.143.1621529982176; Thu, 20 May 2021 09:59:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621529982; cv=none; d=google.com; s=arc-20160816; b=AgOJTzJICUsKhdLN5iGRD5OgH+Zyah2fjnZLIg7H9KNMhz/8Jo27iJruxmqp8OfR+B /J/zI4sfMZH0r7mGUQpb3vNTLh4/XrhMkqkG20Auwh8qsbI1ySzIUslu0nKhgps1FbwO VhwmjYhsi3jGCDyQRsA6FvYagc+0z25KEtbXQA9QIE2YQY8gVgCjkRAZJGynyX38gYGR 01zuccUT1RY+w+aGg8mgQ6ZxljlNXL1uyvvm+yvZenvt2ajbLyD+Dqjsk+1fXy8Q1meE yQIvjv3Y1nJG4jUoxNWIzS+o8+iXAG8Y82Z17qzWNRIZNeXYBRqjZCbhEsh2uYOr73bJ +3yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LR8gd3r7KAfPdb+q1bJz1vB+9bKCae8TeeRmawCrtmE=; b=CaQuEzO/wxeTwqzpc9TmpskWGq3yAZ0082kUi/65P67b59l2ZqUW57X5bxRbBL5XbP r2LWu9qmDVSYU7cgKyKA9ESn08PgojgRooXYhkAskh0x4qAHrK7mOfH/j2SwgqjrgASy M9o12iDMT+G0T9bUZ0q5MfU7W7omjcl45g0A865Y1Oup5JIVE5TiStmbAC55yyIaLGo6 9GYDH4OSfQ6LMTl8C2J1AVJPIj+szqA1qQxIrTjn97EaUs/56+1B7TSbEGEVyb3JlIjx xRyV2n8jtbbet7RON4i02HE1Iq5DaLewddgaf0o+o3PjmxPPA/QEMSSx0aOh2YFsBu+A IFgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wpwjDUpO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a23si2695432jap.18.2021.05.20.09.59.27; Thu, 20 May 2021 09:59:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wpwjDUpO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232683AbhETKCR (ORCPT + 99 others); Thu, 20 May 2021 06:02:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:59134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235186AbhETJ5w (ORCPT ); Thu, 20 May 2021 05:57:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 86CC6613BE; Thu, 20 May 2021 09:38:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503487; bh=78gEKsbijpXic+wdjychEXMDO/H2HEqJvvQxTkarXXQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wpwjDUpORYpfnU/0P62pN4SFOzGDQhdy/7xEX5MV4isCYLFlu72yxkYYUdYptDRkM BwZ2EOdwFM2/2dv4zcbBsc410tWTzFDBT9Xi0DwqPZ+3byAqAJC8bJYmK7zTtDlYUL I1RYnkrkMGU/uZZAJQDuLER2zBj490Obv9RjYWgQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabrice Gasnier , William Breathitt Gray , Lee Jones , Sasha Levin Subject: [PATCH 4.19 243/425] mfd: stm32-timers: Avoid clearing auto reload register Date: Thu, 20 May 2021 11:20:12 +0200 Message-Id: <20210520092139.411304336@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fabrice Gasnier [ Upstream commit 4917e498c6894ba077867aff78f82cffd5ffbb5c ] The ARR register is cleared unconditionally upon probing, after the maximum value has been read. This initial condition is rather not intuitive, when considering the counter child driver. It rather expects the maximum value by default: - The counter interface shows a zero value by default for 'ceiling' attribute. - Enabling the counter without any prior configuration makes it doesn't count. The reset value of ARR register is the maximum. So Choice here is to backup it, and restore it then, instead of clearing its value. It also fixes the initial condition seen by the counter driver. Fixes: d0f949e220fd ("mfd: Add STM32 Timers driver") Signed-off-by: Fabrice Gasnier Acked-by: William Breathitt Gray Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/mfd/stm32-timers.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/stm32-timers.c b/drivers/mfd/stm32-timers.c index efcd4b980c94..1adba6a46dcb 100644 --- a/drivers/mfd/stm32-timers.c +++ b/drivers/mfd/stm32-timers.c @@ -158,13 +158,18 @@ static const struct regmap_config stm32_timers_regmap_cfg = { static void stm32_timers_get_arr_size(struct stm32_timers *ddata) { + u32 arr; + + /* Backup ARR to restore it after getting the maximum value */ + regmap_read(ddata->regmap, TIM_ARR, &arr); + /* * Only the available bits will be written so when readback * we get the maximum value of auto reload register */ regmap_write(ddata->regmap, TIM_ARR, ~0L); regmap_read(ddata->regmap, TIM_ARR, &ddata->max_arr); - regmap_write(ddata->regmap, TIM_ARR, 0x0); + regmap_write(ddata->regmap, TIM_ARR, arr); } static void stm32_timers_dma_probe(struct device *dev, -- 2.30.2