devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eliav Farber <farbere@amazon.com>
To: <giometti@enneenne.com>, <robh+dt@kernel.org>,
	<krzysztof.kozlowski+dt@linaro.org>, <conor+dt@kernel.org>,
	<farbere@amazon.com>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Cc: <ronenk@amazon.com>, <talel@amazon.com>, <hhhawa@amazon.com>,
	<jonnyc@amazon.com>, <itamark@amazon.com>, <shellykz@amazon.com>,
	<amitlavi@amazon.com>, <almogbs@amazon.com>
Subject: [PATCH 5/5] pps: clients: gpio: enable pps pulse-width calculations based on device-tree
Date: Sun, 25 Jun 2023 14:21:34 +0000	[thread overview]
Message-ID: <20230625142134.33690-6-farbere@amazon.com> (raw)
In-Reply-To: <20230625142134.33690-1-farbere@amazon.com>

This change adds setting of PPS_WIDTHASSERT and PPS_WIDTHCLEAR modes to
enable PPS pulse-width calculation.

Width calculation will be enabled if
 - assert-pulse-width
 - clear-pulse-width
boolean properties exist in device-tree.

Signed-off-by: Eliav Farber <farbere@amazon.com>
---
 drivers/pps/clients/pps-gpio.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index a61dc1299ce9..ca4b8047e924 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -33,6 +33,8 @@ struct pps_gpio_device_data {
 	struct timer_list echo_timer;	/* timer to reset echo active state */
 	bool assert_falling_edge;
 	bool capture_clear;
+	bool assert_pulse_width;
+	bool clear_pulse_width;
 	unsigned int echo_active_ms;	/* PPS echo active duration */
 	unsigned long echo_timeout;	/* timer timeout value in jiffies */
 };
@@ -113,6 +115,10 @@ static int pps_gpio_setup(struct device *dev)
 	data->assert_falling_edge =
 		device_property_read_bool(dev, "assert-falling-edge");
 	data->capture_clear = device_property_read_bool(dev, "capture-clear");
+	data->assert_pulse_width =
+		device_property_read_bool(dev, "assert-pulse-width");
+	data->clear_pulse_width =
+		device_property_read_bool(dev, "clear-pulse-width");
 
 	data->echo_pin = devm_gpiod_get_optional(dev, "echo", GPIOD_OUT_LOW);
 	if (IS_ERR(data->echo_pin))
@@ -186,6 +192,10 @@ static int pps_gpio_probe(struct platform_device *pdev)
 	if (data->capture_clear)
 		data->info.mode |= PPS_CAPTURECLEAR | PPS_OFFSETCLEAR |
 			PPS_ECHOCLEAR;
+	if (data->assert_pulse_width)
+		data->info.mode |= PPS_WIDTHASSERT;
+	if (data->clear_pulse_width)
+		data->info.mode |= PPS_WIDTHCLEAR;
 	data->info.owner = THIS_MODULE;
 	snprintf(data->info.name, PPS_MAX_NAME_LEN - 1, "%s.%d",
 		 pdev->name, pdev->id);
@@ -199,6 +209,10 @@ static int pps_gpio_probe(struct platform_device *pdev)
 	pps_default_params = PPS_CAPTUREASSERT | PPS_OFFSETASSERT;
 	if (data->capture_clear)
 		pps_default_params |= PPS_CAPTURECLEAR | PPS_OFFSETCLEAR;
+	if (data->assert_pulse_width)
+		pps_default_params |= PPS_WIDTHASSERT;
+	if (data->clear_pulse_width)
+		pps_default_params |= PPS_WIDTHCLEAR;
 	data->pps = pps_register_source(&data->info, pps_default_params);
 	if (IS_ERR(data->pps)) {
 		dev_err(dev, "failed to register IRQ %d as PPS source\n",
-- 
2.40.1


      parent reply	other threads:[~2023-06-25 14:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-25 14:21 [PATCH 0/5] Add PPS pulse-width support Eliav Farber
2023-06-25 14:21 ` [PATCH 1/5] pps: add pulse-width calculation in nsec Eliav Farber
2023-06-27 14:27   ` Rodolfo Giometti
2023-07-02 12:20     ` Farber, Eliav
2023-07-03  9:32       ` Rodolfo Giometti
2023-06-25 14:21 ` [PATCH 2/5] dt-bindings: pps: pps-gpio: introduce capture-clear property Eliav Farber
2023-06-25 15:46   ` Krzysztof Kozlowski
2023-06-28  8:47     ` Farber, Eliav
2023-07-01  8:34       ` Krzysztof Kozlowski
2023-06-25 14:21 ` [PATCH 3/5] pps: clients: gpio: add option to set capture-clear from device-tree Eliav Farber
     [not found]   ` <04d52b5d-700c-c5d3-07ae-d4b8ad4fc3cd@amazon.com>
2023-07-05  7:04     ` Rodolfo Giometti
2023-06-25 14:21 ` [PATCH 4/5] dt-bindings: pps: pps-gpio: introduce pulse-width properties Eliav Farber
2023-06-25 15:48   ` Krzysztof Kozlowski
2023-06-25 14:21 ` Eliav Farber [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230625142134.33690-6-farbere@amazon.com \
    --to=farbere@amazon.com \
    --cc=almogbs@amazon.com \
    --cc=amitlavi@amazon.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=giometti@enneenne.com \
    --cc=hhhawa@amazon.com \
    --cc=itamark@amazon.com \
    --cc=jonnyc@amazon.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=ronenk@amazon.com \
    --cc=shellykz@amazon.com \
    --cc=talel@amazon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).