Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1583883pxb; Thu, 4 Mar 2021 15:29:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwtzsowtWjWTBHNVU+bSHF+v1/JGXwFYF6+AawmIYAQokqcFYdTGDvK/QNkn6fFiPu5g3QZ X-Received: by 2002:a17:906:81d5:: with SMTP id e21mr6580776ejx.102.1614900541011; Thu, 04 Mar 2021 15:29:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614900541; cv=none; d=google.com; s=arc-20160816; b=Wx2tG6+Im5G1wj1xyyHl2wiX0KacQ2s+ihS14MUUYkVMeB2DnCgZgP3R1rELoS2okS 0KqbZ42T6joYJO1Lgoek2m3ivrfdH5ChdJ8Pq6wsweJQ/+arJVMyc53mIXEyZaFr7Fp0 7FxAoxOQZkVu3wEYhNUTSLIYKGkpFnXMGhyAR+0dOO2p8JJY59UvzIE7pZ0Mwk/EvM0j fIQbFkDWufy4eVNbEKFO16lHOXruh3H1X7NOclPGluK3Q9BF3Mk3qAYdyq0Llta4RUEL JhHQFHOThMgnEeuxRTVMVPYNvLnIwPcX8qUrJaa/pUHSKpcC6iwv6gUIO9YkJdp7OQKE Z0iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=LYcJr357y+zbhIePaqUKe0mtTHJbvYGE/U/tfFKD+os=; b=YAWL/u9F7kwuSpoNTGuXjFtLZcRg70YgVN7YMVaFLfoRDB6H34B/Ai2S/G6UXMvKwg lORb+TFfbaI/KWA2+QxAGKgJnTbfqVfiFRpRuxSMkYGtfz2FoDGyB6ySKGXEMkoAxxd4 V4MCQa2e8a5t/JYW1oPo7zLjcwuUaVihBkDF7U74xYRS+7a5wus42BXbo5EuvXYtqibK lGeHVFlaX0r0aVcckToq8u7ftNeCci+Hr05bZjpqg1WIbjdjk/aBC3TeoMmwIAquIx71 fbK0zYk3QXV4LGWQhm5aobMgs+63/Sk8CwztOeiGRcyLvrQoZm+SCgiSoiDPceTJNQJq Ct/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=OMZ05YXy; 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=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b26si361006ejb.374.2021.03.04.15.28.38; Thu, 04 Mar 2021 15:29:00 -0800 (PST) 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=@foss.st.com header.s=selector1 header.b=OMZ05YXy; 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=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351347AbhCCT2t (ORCPT + 99 others); Wed, 3 Mar 2021 14:28:49 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:48424 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386961AbhCCTNH (ORCPT ); Wed, 3 Mar 2021 14:13:07 -0500 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 123Hf1Di021615; Wed, 3 Mar 2021 18:52:28 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=selector1; bh=LYcJr357y+zbhIePaqUKe0mtTHJbvYGE/U/tfFKD+os=; b=OMZ05YXyNW4CL6eHEy7ArW5VQnNA9fWhiGJ1kvjKYwAQT4EiqRH1RrNx/89TV0Hjh/R2 4u3yo1uiSqm4alJxazDd78TVm2Z/tXcrmbQ37Gc6Z8WYVBYTKoJ44kF5PZuk/xTsMn1j hHx0vOnrJBfIfLtbTVsOOd8S0CnILF+mk51dYIHSKGIn8w5Wbxs9X7J6M4eMOYi/S2Fh ZGMNdPjOKW15usBH72lQMWcdqDJ6XBqpeyoLj/6zhvdGV2FMNlPy0ehwieHlqaBWNzLb gJSdKeG4Sf0dD0Zc/FIl8Ifl/yeiuj2kEi73H5U9+1Dj1HlbN+QwGmBQaQaQ7DOrMFpA 9w== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 370xehy56s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 Mar 2021 18:52:28 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id CE7E610002A; Wed, 3 Mar 2021 18:52:27 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id C13C325EA29; Wed, 3 Mar 2021 18:52:27 +0100 (CET) Received: from localhost (10.75.127.51) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 3 Mar 2021 18:52:27 +0100 From: Fabrice Gasnier To: CC: , , , , , , , Subject: [PATCH] mfd: stm32-timers: avoid clearing auto reload register Date: Wed, 3 Mar 2021 18:51:35 +0100 Message-ID: <1614793895-10504-1-git-send-email-fabrice.gasnier@foss.st.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG3NODE2.st.com (10.75.127.8) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-03-03_05:2021-03-03,2021-03-03 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 add6033..44ed2fc 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 int stm32_timers_dma_probe(struct device *dev, -- 2.7.4