From patchwork Fri Aug 27 03:47:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 12461183 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEE89C4320A for ; Fri, 27 Aug 2021 03:51:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7884260F42 for ; Fri, 27 Aug 2021 03:51:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7884260F42 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gpMgEbLHxoNB8bfq0PI1nHv7707emkt0OQxQrmPDfDk=; b=msz+2T99Hmxrdc qg8nxrIOWXxL2mciH3Fg0Nz0D8Q/DFD7RAHiWmW5tpnEW28DVbvDeV/S9l2eUDQYlpyUUXNwbH5KA PU4sbRt4YHTaKZv1ohxd1wl2qfeEDEGqqcSAUi3oY/XVq7iCXfMMSf1LXTsohg6kUhcMueSHuI+P4 DReU7M1U1OUAU60ctVEwfLHZIxtPNpBkTjHQjzBzwtiRQQRqUOQ3bnv87LySvDs0yB8HNu6ZAsZKd WhaSLGe8oI59ukx+eqQnk5ioPVtsySz2x73BVDN51euQ/l8OrJnlMHtX3VIVi+NaXHG3ho0s0gl6o Jv62NS57CJlFgo/ESVXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJSrE-00BRuh-Do; Fri, 27 Aug 2021 03:48:44 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJSqu-00BRqR-5D for linux-arm-kernel@lists.infradead.org; Fri, 27 Aug 2021 03:48:26 +0000 Received: by mail-pf1-x436.google.com with SMTP id u6so3927151pfi.0 for ; Thu, 26 Aug 2021 20:48:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NBoYGyBiTNoAvtIS6d3/4JvR5xP0NBcEY2yL+79p2+4=; b=IKvI3Xk6wcnJEsbj1ToKZV3yCQZ4JXDWX2afKN88MDwgvUrlFJE02x9JAH+OtTy4Gh SpFsM2lUbWTtLwz1ktES0Rh3tickoWHRYf7h9zCLzt2dukiiftidOqKUDdC3c3ivqmwk 3belztgEeWDqQh6KC5qfSi8BiJTLI2uLcw1SnUWHj8Wnh0CaIYklRAZ5wrBSbBTPIm+P LjTDkKdheHTJ2vOpV3s/TvF2FF6kLmLalwI+7QlO+2+0+DGreRExm9jstq4DcI8sweXp QJTfef0e/uA0A75g6VQYwgpdX9Dk3BOOQwbRdb0ySJZWw0PTZT1P8QVzFM6lhk2gn0DU JaSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NBoYGyBiTNoAvtIS6d3/4JvR5xP0NBcEY2yL+79p2+4=; b=eNfp+JPCPDIO+oRwT+zBVc6aZMNw/rH7dLBRFjE8B0Fl5ad51DvlMZ9NkKR1dx3iD7 kqzx1adBRGKQZ/kwA8IM/O2mWeu7KeAQiVcXRVLjO2PTrfG25R5ICfF1NG5tt6wRxzEr IomKVjU8A5Cl/Tv6wfUqP7JJaf+YNRn+V7OMLnCA180Gik9uOZhOiJNyWEiaIFSwsdO7 hI/P26AzoIKFz/s72ZVPE9HfMg+tiwRIAfOlpjuK7j80qmdAeN2pD1YRoFnuYUwZYzAI cSVOgGD8mw6GkEQePFYolUuXEy+ehGhjn7JcJZUEOD761BzloaqCmOh+hr03kcle8Pxu wyJg== X-Gm-Message-State: AOAM533LEJ6azYpsE+U9+ZlS3R2JrVxQT2L0CfbDvAFNokl/GUqPvX7W B7UHl/bwXzS0qEhJifk1h1g= X-Google-Smtp-Source: ABdhPJyQg43G+SVpT+iI0BtVFx1OBxsqKuosP0AlvzVxqk7QBS1SyoH7MVnnN5QuYoLD9O9GQ9EfMQ== X-Received: by 2002:a05:6a00:a85:b0:3eb:1934:de53 with SMTP id b5-20020a056a000a8500b003eb1934de53mr6862089pfl.71.1630036103419; Thu, 26 Aug 2021 20:48:23 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id o6sm4364693pjk.4.2021.08.26.20.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 20:48:23 -0700 (PDT) From: William Breathitt Gray To: jic23@kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, kernel@pengutronix.de, a.fatoum@pengutronix.de, kamel.bouhara@bootlin.com, gwendal@chromium.org, alexandre.belloni@bootlin.com, david@lechnology.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, syednwaris@gmail.com, patrick.havelange@essensium.com, fabrice.gasnier@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, o.rempel@pengutronix.de, jarkko.nikula@linux.intel.com, William Breathitt Gray , Fabrice Gasnier Subject: [PATCH v16 02/14] counter: stm32-timer-cnt: Provide defines for slave mode selection Date: Fri, 27 Aug 2021 12:47:46 +0900 Message-Id: X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210826_204824_251091_8A575659 X-CRM114-Status: GOOD ( 14.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The STM32 timer permits configuration of the counter encoder mode via the slave mode control register (SMCR) slave mode selection (SMS) bits. This patch provides preprocessor defines for the supported encoder modes. Cc: Fabrice Gasnier Signed-off-by: William Breathitt Gray Reviewed-by: Fabrice Gasnier --- drivers/counter/stm32-timer-cnt.c | 16 ++++++++-------- include/linux/mfd/stm32-timers.h | 4 ++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/counter/stm32-timer-cnt.c b/drivers/counter/stm32-timer-cnt.c index 3fb0debd7425..1fbc46f4ee66 100644 --- a/drivers/counter/stm32-timer-cnt.c +++ b/drivers/counter/stm32-timer-cnt.c @@ -93,16 +93,16 @@ static int stm32_count_function_get(struct counter_device *counter, regmap_read(priv->regmap, TIM_SMCR, &smcr); switch (smcr & TIM_SMCR_SMS) { - case 0: + case TIM_SMCR_SMS_SLAVE_MODE_DISABLED: *function = STM32_COUNT_SLAVE_MODE_DISABLED; return 0; - case 1: + case TIM_SMCR_SMS_ENCODER_MODE_1: *function = STM32_COUNT_ENCODER_MODE_1; return 0; - case 2: + case TIM_SMCR_SMS_ENCODER_MODE_2: *function = STM32_COUNT_ENCODER_MODE_2; return 0; - case 3: + case TIM_SMCR_SMS_ENCODER_MODE_3: *function = STM32_COUNT_ENCODER_MODE_3; return 0; default: @@ -119,16 +119,16 @@ static int stm32_count_function_set(struct counter_device *counter, switch (function) { case STM32_COUNT_SLAVE_MODE_DISABLED: - sms = 0; + sms = TIM_SMCR_SMS_SLAVE_MODE_DISABLED; break; case STM32_COUNT_ENCODER_MODE_1: - sms = 1; + sms = TIM_SMCR_SMS_ENCODER_MODE_1; break; case STM32_COUNT_ENCODER_MODE_2: - sms = 2; + sms = TIM_SMCR_SMS_ENCODER_MODE_2; break; case STM32_COUNT_ENCODER_MODE_3: - sms = 3; + sms = TIM_SMCR_SMS_ENCODER_MODE_3; break; default: return -EINVAL; diff --git a/include/linux/mfd/stm32-timers.h b/include/linux/mfd/stm32-timers.h index f8db83aedb2b..5f5c43fd69dd 100644 --- a/include/linux/mfd/stm32-timers.h +++ b/include/linux/mfd/stm32-timers.h @@ -82,6 +82,10 @@ #define MAX_TIM_ICPSC 0x3 #define TIM_CR2_MMS_SHIFT 4 #define TIM_CR2_MMS2_SHIFT 20 +#define TIM_SMCR_SMS_SLAVE_MODE_DISABLED 0 /* counts on internal clock when CEN=1 */ +#define TIM_SMCR_SMS_ENCODER_MODE_1 1 /* counts TI1FP1 edges, depending on TI2FP2 level */ +#define TIM_SMCR_SMS_ENCODER_MODE_2 2 /* counts TI2FP2 edges, depending on TI1FP1 level */ +#define TIM_SMCR_SMS_ENCODER_MODE_3 3 /* counts on both TI1FP1 and TI2FP2 edges */ #define TIM_SMCR_TS_SHIFT 4 #define TIM_BDTR_BKF_MASK 0xF #define TIM_BDTR_BKF_SHIFT(x) (16 + (x) * 4)