Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4619611pxj; Wed, 12 May 2021 09:22:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxncQA8GPitxLH5y7AMHpbP1AyiJJUnAIChP/9FaiTOWc0Nxr+zvEDBZEA0B6jphDMXCQY X-Received: by 2002:a05:6402:2d6:: with SMTP id b22mr44737098edx.274.1620836466177; Wed, 12 May 2021 09:21:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836466; cv=none; d=google.com; s=arc-20160816; b=FXVcnabbjc4P13jEY8T6MVapY2H6wg4c+hKpLm/PEcgn+LM7y8YC8CT2MdKHR/HVVc q/9HQerT1m0E9mCsRl2QvkN1pOefpzNBx2kBz7Eg0kkyimbepUEN8ueBntNGzK/R0eIZ q+xYzj+NwZfqzUlg54i6/okykQKGBvK4zfHMXhMHDHVDBx70ZVDrV+FLKy+x2vYgSClZ dE4vsdE/UdeRicWVm1/xvA44TbXD32iv+al+I+LZTuQNrPbjSD7Fv338cE5XQOpCy0Ic k8l4UXRunk9vJsTkB80FWb6ijfFAPi6G7X3ITJvrj4rx3cx6noMviR/Qwpd/MKbREysU 5eVA== 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=NoQTDxU866s6lHtfrn9SkpOkmVF82TYWBSh/+oRbDo23ILP//P5SjcjX8RNaVBKFd6 9G9Bl0YmIkBoLjLucN5fRnVSTKwvs+cOHy8ijKZdgJ/FIX88BEohnNPTnRUc9v1eTAN9 Ese1G7GGKDWTYjTCH4amMBsyRev6REHrBl6bQOYvCnWQNLxJsvz2lle9pAbv+0W8UrnX dHdcu2yoY/ERaDjgGFiGmmRaMf4NDCaaxhW2f6it0exf2eHSNiaad6vNu7J/yZFJzrHS zPg0mqfVkd5GvDTHEddhpZQfLJP5sLRRGTOVH/lxopSRyV3V5l3oqTVD31Arg8uDCp6N 4lpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0uOZnBkl; 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 2si190971edv.313.2021.05.12.09.20.41; Wed, 12 May 2021 09:21:06 -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=0uOZnBkl; 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 S240539AbhELQSN (ORCPT + 99 others); Wed, 12 May 2021 12:18:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:49132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235057AbhELPfN (ORCPT ); Wed, 12 May 2021 11:35:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3A1D26198E; Wed, 12 May 2021 15:17:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832663; bh=mW3nM8JiIx1PdIRU+c4FabPHmHJaWAl+9/gSo3NoC14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0uOZnBklSvrDvaqrYuCK9n9u6H4HRrd8cJpHLHpgCgh/NOGXJdROQdFy/KYkRhTqd PZUS6OPIJwGd17Ryh6OYDSUQG9CMXxHJi5C718xI7a2cpuYG/UOfhaESJ3cJHrI9Pg sntNQkz4auiyV7vGU+HggNr1mNHLvkXKLi4RRTuk= 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.10 337/530] mfd: stm32-timers: Avoid clearing auto reload register Date: Wed, 12 May 2021 16:47:27 +0200 Message-Id: <20210512144830.876905215@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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