From nobody Mon Feb 9 20:35:36 2026 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79197433A0 for ; Sat, 11 Jan 2025 00:22:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736554954; cv=none; b=TiRVGXj2k68UdQUpGQBUaYkqBscROuPwzTJrmDCfibf+t+QnMC8S5ytxBF4PM66OKROtpln7J+OmabKo9pDR+pLyf0Od1UiKBcqheHPPPbpC0cavYQS5R5rovLXtBNlgDZBPZI9Bb3Xc67Q2Ow3smBh2YLHGqMCV9lElwn4t7og= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736554954; c=relaxed/simple; bh=Sm/vCJR0UNJ9M+n6RDDO/DQSL6/4GQ8GHSNkCxO+NJw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=p1n6gT/1Nvz4U7dmCk4epvKeUYiJGlyNPI6u4Q3ltfOMqKSV8SRl+mi+U09cqZfUjuK1HewEtBfyZfykaZT4VgDFcPaUoRJDVW8JEleEmFMbAXx5ErJDEhBvZrCqxh4eLj0n0f0Jl7LknhKx8et4tzOwLfSwKA18A+XmPW9lqdE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=N2WnwNIq; arc=none smtp.client-ip=209.85.210.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="N2WnwNIq" Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-71e2dccdb81so1668342a34.1 for ; Fri, 10 Jan 2025 16:22:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736554951; x=1737159751; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=wxjqlH5d2yGAK7gT8nLx4cF++/77RWW2OaRQuEiqFjw=; b=N2WnwNIqW6xBuT2dPG9H/8Ndlu1l3xAddnhmjhAkW2pLdijwEupBRamnJ0P0rsbGJ0 aXsycM+Gv831XXVtN3D2yg0zjIyiKN54fuEwzo71Q1j3KzVMCOM10KGGeB5KM7/j08+O l8/wR3VSAXBW9SJeZamSeAlQUNyqMuRaO2PlPE8O3nsIB4PsCoI5EJ4qiYPJZWMXvnyv A8zRZ1iS63VzpLLPOv5gAIfRBqyDQvNFtykImJcrBSRoI7wpy2NktJVg6aEFbSBZbzLR MMltMUy4wkf7C9FkiP36Nhlio8nRg3XfxPKvzL86zkZOAsHC69vpzysLnx/L5Bnuyq3M pC6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736554951; x=1737159751; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wxjqlH5d2yGAK7gT8nLx4cF++/77RWW2OaRQuEiqFjw=; b=pr0RyJxP/gPY1UqfMmfGPxZ7a+7d5ZPIJ7VdnjbjHFnOYGtBtLAAZDpNOaocjM67lH 8W9LDFUAwlpUqJRO8wxLqFkkiAOBpMrA9v5v+jf1pSFzyUKLaS0WY7acSqB5hJtI/3vd +CRuZC487liSTBpIDaK+ptY3+ALJPdmHuUYeVvoYm3e6dQQotbMSWTvSZLT4wSp64WKQ DOLOj8eNU1kBw1rjuVOCh1PYOOv2hixV5yDCHK5puMJ0QgYNXxv/65xHRd51ZQMK/bCf esgt2vpDDG0qSl/8sAFxyQuIAtxhJbrN1f9FsRyvAwY9qOI+UenWRVAfhcriNS2VG+z3 jg2Q== X-Forwarded-Encrypted: i=1; AJvYcCUEJw1Sc+NttwCjcB+yAG3dzeVJM1lhgin2u7/R2L1rfC7eYvosh8X4fcKjA/10aOu+WU3K0r3v2ZZGY4o=@vger.kernel.org X-Gm-Message-State: AOJu0YxbiyV8SmHXCePFZFpbVg/GwdVUs2/fs0UE+vJNU80AnMvcajPY elnXVFCvrEVASKODdJUjzCCpEG101iwoEDXh+/za79edWe1S3VX1bMapX2kvilc= X-Gm-Gg: ASbGnct5NmOqvpioQopMkutQFDo0uXXZ9iB1zVwH9w427rjdNDWSRpmxFjRlSRAaNKz eYuIV4roANZtWbhraqQ21bKh3tfpSxiX4D7BTImD/8/5NJ+9E4g+PPUACBA8Qr5AmN/Fc7GndWM +1WEn4AaicvcoxC0AZow+05XOj2+Y0Lmu0kTarMM2I8IvRfJxp7rREKbESD7+4U0lHV51ORTMPD B+LpnmIfbcwdic6nB7T3SK2sV56N6lAcker3tcPk/pnOujyvvjA6vlxfdAM40inXpLMg67iopMC DGiDBl51HHgY X-Google-Smtp-Source: AGHT+IF1c+ZliXJuhcHSKrpXBnYw8ejPWHsdb36/Pxj+4Gk9f8NaXMfIl2+Gr6DQISDAokbNcEV8gw== X-Received: by 2002:a05:6830:911:b0:71e:72:3ab6 with SMTP id 46e09a7af769-721e2ef6454mr7121733a34.26.1736554951626; Fri, 10 Jan 2025 16:22:31 -0800 (PST) Received: from [127.0.1.1] (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-723186280easm1228941a34.59.2025.01.10.16.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 16:22:31 -0800 (PST) From: David Lechner Date: Fri, 10 Jan 2025 18:22:07 -0600 Subject: [PATCH v2 4/4] counter: ti-eqep: add direction support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250110-counter-ti-eqep-add-direction-support-v2-4-c6b6f96d2db9@baylibre.com> References: <20250110-counter-ti-eqep-add-direction-support-v2-0-c6b6f96d2db9@baylibre.com> In-Reply-To: <20250110-counter-ti-eqep-add-direction-support-v2-0-c6b6f96d2db9@baylibre.com> To: William Breathitt Gray , Fabrice Gasnier Cc: Judith Mendez , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, David Lechner X-Mailer: b4 0.14.2 Add support for reading the direction and for emitting direction change events to the ti-eqep counter driver. Signed-off-by: David Lechner --- drivers/counter/ti-eqep.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/counter/ti-eqep.c b/drivers/counter/ti-eqep.c index bc586eff0daeb52857c10fc89e4f9c0262c3441b..d21c157e531a614215b50f2271f= 18c998413a572 100644 --- a/drivers/counter/ti-eqep.c +++ b/drivers/counter/ti-eqep.c @@ -107,6 +107,15 @@ #define QCLR_PCE BIT(1) #define QCLR_INT BIT(0) =20 +#define QEPSTS_UPEVNT BIT(7) +#define QEPSTS_FDF BIT(6) +#define QEPSTS_QDF BIT(5) +#define QEPSTS_QDLF BIT(4) +#define QEPSTS_COEF BIT(3) +#define QEPSTS_CDEF BIT(2) +#define QEPSTS_FIMF BIT(1) +#define QEPSTS_PCEF BIT(0) + /* EQEP Inputs */ enum { TI_EQEP_SIGNAL_QEPA, /* QEPA/XCLK */ @@ -286,6 +295,9 @@ static int ti_eqep_events_configure(struct counter_devi= ce *counter) case COUNTER_EVENT_UNDERFLOW: qeint |=3D QEINT_PCU; break; + case COUNTER_EVENT_DIRECTION_CHANGE: + qeint |=3D QEINT_QDC; + break; } } =20 @@ -298,6 +310,7 @@ static int ti_eqep_watch_validate(struct counter_device= *counter, switch (watch->event) { case COUNTER_EVENT_OVERFLOW: case COUNTER_EVENT_UNDERFLOW: + case COUNTER_EVENT_DIRECTION_CHANGE: if (watch->channel !=3D 0) return -EINVAL; =20 @@ -368,11 +381,27 @@ static int ti_eqep_position_enable_write(struct count= er_device *counter, return 0; } =20 +static int ti_eqep_direction_read(struct counter_device *counter, + struct counter_count *count, + enum counter_count_direction *direction) +{ + struct ti_eqep_cnt *priv =3D counter_priv(counter); + u32 qepsts; + + regmap_read(priv->regmap16, QEPSTS, &qepsts); + + *direction =3D (qepsts & QEPSTS_QDF) ? COUNTER_COUNT_DIRECTION_FORWARD + : COUNTER_COUNT_DIRECTION_BACKWARD; + + return 0; +} + static struct counter_comp ti_eqep_position_ext[] =3D { COUNTER_COMP_CEILING(ti_eqep_position_ceiling_read, ti_eqep_position_ceiling_write), COUNTER_COMP_ENABLE(ti_eqep_position_enable_read, ti_eqep_position_enable_write), + COUNTER_COMP_DIRECTION(ti_eqep_direction_read), }; =20 static struct counter_signal ti_eqep_signals[] =3D { @@ -439,6 +468,9 @@ static irqreturn_t ti_eqep_irq_handler(int irq, void *d= ev_id) if (qflg & QFLG_PCU) counter_push_event(counter, COUNTER_EVENT_UNDERFLOW, 0); =20 + if (qflg & QFLG_QDC) + counter_push_event(counter, COUNTER_EVENT_DIRECTION_CHANGE, 0); + regmap_write(priv->regmap16, QCLR, qflg); =20 return IRQ_HANDLED; --=20 2.43.0