Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4690078pxj; Wed, 12 May 2021 10:58:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/6LuHKEcLo8oiIa0nyLmE15Xg3NKnf5tF+SQfHlvaGLZD3PRaouKpbUS+P/Cf7jcvn3DZ X-Received: by 2002:a17:907:3da4:: with SMTP id he36mr38231886ejc.308.1620842304126; Wed, 12 May 2021 10:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620842304; cv=none; d=google.com; s=arc-20160816; b=PEUxSuCQRP4brOHthE7BEH4lj6csNjZYE2wDAe1Cz9iuF9EXNi7ENJrZvOnkNaaHW+ pZ/md27l+a8i4Dan5+eAkuGYvulRD7u7wcRjMMlzYneTosnleDKXXWqOgod14d8XZsUz CuRrgIH0hIysCkJRNN9V61pzs9WZVCvItJJU33krBCKJkWcH3KU/UMr+XK5zKUF9cyip vPfbgtJeWpB6oXp3XVYZ6rtzwkLJ6qUFh3E6syJxsutm+h37UynC1KFTi0FtY9nZjZF1 fSiFmfvUov6QiFpaAQKsisUnMChcr0q6TYQ/Du8UX2TfhlQt/7+Hf8WkBdgLc5qkAxZb fyxw== 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=mc58DGB4BFNJ2/wIs/hAbufb/cL9sHyGpEtZ5UjAKVA=; b=qO5c9NteV64whRwn/OZHhHue5+bOc7Ife0vA9F2u8mJ+F8TFyVcBS5ZPFOUWHGTJMD qus9+hCItOqXe219jp10R4Gn+oAqKWvyZMv3xltPvyyAPC+wKPf9Q3AFu7yVmdIykKbm gcNKJrIrBe32zqWsO5KXmCE/wBgbfnZR9F26RE5aVA5LgfavIwXZ/PWwrdynaQ0uJ/nX YEkE5uUioZSoVyRb1xfkmGIUSO/PJGN15ilG9GhJout4+wV1IPB8txHpbnP0spJfIcVR 2CZfraw+onSrHadbHxU2J6y/yR3zU1pOUNTKJu7YPiM2y7MWOysgSzBP1BQDEr2byxAw msng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UXP5gOFe; 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 m25si336804edr.235.2021.05.12.10.57.59; Wed, 12 May 2021 10:58:24 -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=UXP5gOFe; 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 S1349995AbhELRrE (ORCPT + 99 others); Wed, 12 May 2021 13:47:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:51344 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237834AbhELQN0 (ORCPT ); Wed, 12 May 2021 12:13:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 07F4A619A9; Wed, 12 May 2021 15:41:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620834101; bh=mW3nM8JiIx1PdIRU+c4FabPHmHJaWAl+9/gSo3NoC14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UXP5gOFeKCQwNqvo/YS82OWA4et/mYnGyATW26y5wSQzKNv7JE/XnnNclPg5p4A6B aomcoZwXDPjMFSidQsztRn6xUi54Bj3JFf4Vbh5wer8YRG7J1EtG27qgiYMj2uBVq+ FrEV2PS38hAR/uAzXGuM519e9o83iKfykc5jfIuw= 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 5.11 374/601] mfd: stm32-timers: Avoid clearing auto reload register Date: Wed, 12 May 2021 16:47:31 +0200 Message-Id: <20210512144840.112235220@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144827.811958675@linuxfoundation.org> References: <20210512144827.811958675@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 add603359124..44ed2fce0319 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.30.2