Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2091451rbb; Tue, 27 Feb 2024 10:16:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU3PXfsAqFjwkdxtETLB1IHwdpQxI9T7Bvvf0wSeV/LZ7AJwBm44EAHPI91C9bkfcidplMMJj4nBuGR96NpehtJTm7voKlTRxYS48M5VQ== X-Google-Smtp-Source: AGHT+IEHYy2vYFRWTm6DghZSGK8l4DlcI6549R0Eqtw8bblp+lhEGreAHGf9+g7ODKW4BhUzBF/B X-Received: by 2002:a05:6a00:4509:b0:6e5:3b0e:9f14 with SMTP id cw9-20020a056a00450900b006e53b0e9f14mr7310475pfb.13.1709057773006; Tue, 27 Feb 2024 10:16:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709057772; cv=pass; d=google.com; s=arc-20160816; b=uJtaf7Ae60lATe67GCxPT9hclVi0PoIEFqE92nk6WE6W9UKvsGuQM3La6enVbavj/U Mr7WaTpTuxAFP4URxAsyoAxDjEjoEc+sJJY5f1ZI5iqZeANgfB9ulqp30QL91K9mfGAs SUIc3Y0VjAlieCDadzue/UnSmmfMFJuKTJz4Dr1NZeXOpXT94iFoP9ZQRvt+0n1RQpuH b/1M1Z/DWzVkSex3r74ISgsWIowfgo9BNypxqILunt6OzMvpqk9THyrNY7HTPQvVnQ7d +tvYBTaokCokbkM3eCgDqqdgt9C/WGxLuutGjgtYWPGye4bYMefR0oima288NjEQZc0K RU2g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=23cef0f6RemlkBcr/fQtp0mL/3K1zOCA/BsyeJEat+c=; fh=ozwKRq0p8tj2zy4oAJzh3eawPsCHg5fP2FoTNn7f1y4=; b=db/HtGAGvB1w9AhOCanp5AyoCiy3mE/n+kxWypK8N41pFnQusPm3kfxMcEJgOFOBc2 8Ot6EGjO9IaGSarPnPZH0UCvv1dUTDUwsSB0wDqNoMkyizOOUc7YEHXpQrbCYX752KPi lh+DO6dbmnCipB3NhQZnNBmEocyrU96Sw9SEQIgBCXXEvkHnkLHyXFUjKaEJSX9T1Acn NVIkNhTlzuSiY6BYT5R5Yf4Di6AVsrkklvaMrmTdGkKst5XTATd61MRxFeDHasXB31kU nltXA/bqMe4rEZsJPhPpf/wynvd8m1CCWUfJsj54GjwHoS5pFK1aKjt26jDD2RSKX6aw K6JQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=VApBCMRA; arc=pass (i=1 spf=pass spfdomain=foss.st.com dkim=pass dkdomain=foss.st.com dmarc=pass fromdomain=foss.st.com); spf=pass (google.com: domain of linux-kernel+bounces-83753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83753-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x22-20020a634a16000000b005cdf9c9b7e3si5752802pga.179.2024.02.27.10.16.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 10:16:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=VApBCMRA; arc=pass (i=1 spf=pass spfdomain=foss.st.com dkim=pass dkdomain=foss.st.com dmarc=pass fromdomain=foss.st.com); spf=pass (google.com: domain of linux-kernel+bounces-83753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83753-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E89FFB35362 for ; Tue, 27 Feb 2024 17:42:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3AB5E14CACB; Tue, 27 Feb 2024 17:40:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b="VApBCMRA" Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8C6914AD31; Tue, 27 Feb 2024 17:40:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.207.212.93 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709055615; cv=none; b=dTHkXnl6pYlzkL/vDj145Q3O2IXLM6xVeS8p48JIRHW0t//wQ9BKyyaS14pxTlZQH1ICxdrvDg3latWXkUW3DVZ7YLQea3pXW/VCfMm6udbKdP/LJazd4eLSJKJHaBAExApZTet3A/QcfvDxbskOfkNHEAY5xz8iz0f3yiXXmSM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709055615; c=relaxed/simple; bh=g+B/ZxmAt+hidesVqjrDVmazvLTbNKrI+x7QfWgm3ag=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZsprYYiihjTobvrFQdvb68z3EoDjB6uxtPsJPoj/xa5ucR1V32osTP3vmAFI0hPy9FF1Bzy7P6WYsI/0K/4MuWq4VyTfG+jVvyhuF9yLf+1HOT5Ng5cJAlc3qAjpue9/Trq3kNpxQTgaLwFDNHus+h6z5w2otd/rIQsjw7klzCo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com; spf=pass smtp.mailfrom=foss.st.com; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b=VApBCMRA; arc=none smtp.client-ip=91.207.212.93 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foss.st.com Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41RBiVd8001069; Tue, 27 Feb 2024 18:40:03 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= selector1; bh=23cef0f6RemlkBcr/fQtp0mL/3K1zOCA/BsyeJEat+c=; b=VA pBCMRAJwEQutMw8gFa+tACUDnxyErwwB5Rlp86EGqI4dFkbxxmmciiwTvHgaBuvQ +kfaNDUsqsf4HdPQnPQDGr5cWO3bDKc7yGHz9lbBoyNsTtfkDKJhmGCH0+koWqxo 7w/+gm8oZXuZAJg81fw5SpChVTZe841C2WQn7AoJ/XZGY5s62NQclzPMB2CS7SBB X6fLcWaZA+cmnlYI9eo8+SeuvMwwuBcTwvBmhdWp+w+Ta+c7m9ZRQhARhInCc84h i1YkebCrS5rwgQ36+mhRQmqiFF/eqWzrYdUg3lo0/5oe1yX2eJ2oBHUB1Ukfdd8c S1JHMNYAMK0SIUb2NJRQ== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3whf4dsces-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Feb 2024 18:40:03 +0100 (CET) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id E723F40045; Tue, 27 Feb 2024 18:39:59 +0100 (CET) Received: from Webmail-eu.st.com (shfdag1node2.st.com [10.75.129.70]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 13A452AD128; Tue, 27 Feb 2024 18:39:31 +0100 (CET) Received: from localhost (10.252.26.109) by SHFDAG1NODE2.st.com (10.75.129.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 27 Feb 2024 18:39:28 +0100 From: Fabrice Gasnier To: CC: , , , , , , Subject: [PATCH v4 06/11] counter: stm32-timer-cnt: add counter prescaler extension Date: Tue, 27 Feb 2024 18:37:58 +0100 Message-ID: <20240227173803.53906-7-fabrice.gasnier@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240227173803.53906-1-fabrice.gasnier@foss.st.com> References: <20240227173803.53906-1-fabrice.gasnier@foss.st.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SHFCAS1NODE2.st.com (10.75.129.73) To SHFDAG1NODE2.st.com (10.75.129.70) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-27_05,2024-02-27_01,2023-05-22_02 There's a prescaler in between the selected input signal used for counting (CK_PSC), and the counter input (CK_CNT). So add the "prescaler" extension to the counter. Reviewed-by: William Breathitt Gray Signed-off-by: Fabrice Gasnier --- Changes in v4: - Add William's Reviewed-by tag Changes in v3: - New patch split from "counter: stm32-timer-cnt: introduce clock signal" --- drivers/counter/stm32-timer-cnt.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/counter/stm32-timer-cnt.c b/drivers/counter/stm32-timer-cnt.c index b914c87b6f10..e0709dd7dcfd 100644 --- a/drivers/counter/stm32-timer-cnt.c +++ b/drivers/counter/stm32-timer-cnt.c @@ -220,11 +220,40 @@ static int stm32_count_enable_write(struct counter_device *counter, return 0; } +static int stm32_count_prescaler_read(struct counter_device *counter, + struct counter_count *count, u64 *prescaler) +{ + struct stm32_timer_cnt *const priv = counter_priv(counter); + u32 psc; + + regmap_read(priv->regmap, TIM_PSC, &psc); + + *prescaler = psc + 1; + + return 0; +} + +static int stm32_count_prescaler_write(struct counter_device *counter, + struct counter_count *count, u64 prescaler) +{ + struct stm32_timer_cnt *const priv = counter_priv(counter); + u32 psc; + + if (!prescaler || prescaler > MAX_TIM_PSC + 1) + return -ERANGE; + + psc = prescaler - 1; + + return regmap_write(priv->regmap, TIM_PSC, psc); +} + static struct counter_comp stm32_count_ext[] = { COUNTER_COMP_DIRECTION(stm32_count_direction_read), COUNTER_COMP_ENABLE(stm32_count_enable_read, stm32_count_enable_write), COUNTER_COMP_CEILING(stm32_count_ceiling_read, stm32_count_ceiling_write), + COUNTER_COMP_COUNT_U64("prescaler", stm32_count_prescaler_read, + stm32_count_prescaler_write), }; static const enum counter_synapse_action stm32_clock_synapse_actions[] = { -- 2.25.1