Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp2115915lkv; Thu, 20 May 2021 03:47:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzs4qZuDDfbKqDwxl9N44bz3F8GBSgDJqp6t9lj15Sr3wRXUOYtOorqGvjkUCDtF0wRmGaS X-Received: by 2002:a92:c846:: with SMTP id b6mr4419182ilq.196.1621507642068; Thu, 20 May 2021 03:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621507642; cv=none; d=google.com; s=arc-20160816; b=YxlYJYF7JgE+EI4eZ9k080tbFLVkM7mgeRtav0mzj1NMg0K+eXFi2PRuH5V2sBZhhX mqv5JE8QVCRm8q8FSYxMsR/RKyrDPowAPbG+ggynkXJHbJgjOl10c/q88b7y+c1i0yUY dNEW1AWsNANxc0Oo8FDzp28SeDy0vYuWkUTiJ+hs+ZQ+zGwribxgVL/kfKqhvgZud7Tn JaET3GBB8t83JXonOwVJkpsGuEi2Um/U8Ja/In2JDrWW/uG/6F/eAI+PULZkVcxQ1wtV 0v9eUrOAQyhfnzv6Zv2sIlSGIXH5S3HmcksivMvD5JWr5q0JVjU1iRsk1I5y7R+Y/5Nc zzYg== 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=FnbzeATfYVqhv6FK5p3FF1aQ/8V76PYQsUTSmKxhHfY=; b=WPvNMe2HbPRIakuTqh3lEOKgJJHeTuB9b2WpXfNpBPSdyCKN8UoEQJIMaaom8mvCLK ZWGgdTV96XyS3i93eKt4bKNjqSjparMObwlUfh0zh5jFqcjMQQ4XMAzvmFC//bjtlyJz I+NEC5/1/Hlt6+1QOwnzKRgKps30PHfEARRtIIZYE5hBoyHYADoczfM6UulIq9Arm/wE WqML32LCmfXN4KkrWKh9/VSgJ5VmpewbVZCR1jDRZEgoj5KL8GHWKpshlYsfeujoduQG RuvO1mZCuFIHlx42XiR7ojtEVMTr6vsYWLySr4yjDxln7RIScMWIjm30ShphiU3iOqMM oR1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="c5/DLCI0"; 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 b26si1946688ios.29.2021.05.20.03.47.08; Thu, 20 May 2021 03:47:22 -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="c5/DLCI0"; 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 S238210AbhETKqv (ORCPT + 99 others); Thu, 20 May 2021 06:46:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:60374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237033AbhETKb1 (ORCPT ); Thu, 20 May 2021 06:31:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9BFFA61C3F; Thu, 20 May 2021 09:52:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504321; bh=C0Yj/x5LcoC+9D2E/O8akq6StoQeb79AVtvrABAlnfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c5/DLCI0Vrl4+3eo0QYR1iUe4CqLJAm3wiVTRgm7pwN4w6W1mVqACrjB6xdR/a6gV CuxBa1dBNHPTgw9r6ZPxxEi9T18gE0xKMF2NzYyOtv0X4+URxcVET5WijT4nduSmpz Tne+FiMl6peaOAxIQp/HEE2i/OdR9z7jgCCmZOWc= 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.14 192/323] mfd: stm32-timers: Avoid clearing auto reload register Date: Thu, 20 May 2021 11:21:24 +0200 Message-Id: <20210520092126.698771682@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 a6675a449409..e280e0ff2dcc 100644 --- a/drivers/mfd/stm32-timers.c +++ b/drivers/mfd/stm32-timers.c @@ -20,13 +20,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_probe(struct platform_device *pdev) -- 2.30.2