public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: linux-input@vger.kernel.org
Cc: Jonathan Corbet <corbet@lwn.net>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Vojtech Pavlik <vojtech@suse.cz>
Subject: [PATCH 2/8] Input: rotary-encoder - remove references to platform data from docs
Date: Sat, 15 Apr 2017 22:11:39 -0700	[thread overview]
Message-ID: <20170416051145.13618-2-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20170416051145.13618-1-dmitry.torokhov@gmail.com>

The driver has been converted to use generic device properties, so
stop referring to platform data.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 Documentation/input/rotary-encoder.rst | 85 ++++++++++++++++++----------------
 1 file changed, 44 insertions(+), 41 deletions(-)

diff --git a/Documentation/input/rotary-encoder.rst b/Documentation/input/rotary-encoder.rst
index 4695bea67f9b..b07b20a295ac 100644
--- a/Documentation/input/rotary-encoder.rst
+++ b/Documentation/input/rotary-encoder.rst
@@ -81,48 +81,51 @@ Board integration
 
 To use this driver in your system, register a platform_device with the
 name 'rotary-encoder' and associate the IRQs and some specific platform
-data with it.
+data with it. Because the driver uses generic device properties, this can
+be done either via device tree, ACPI, or using static board files, like in
+example below:
 
-struct rotary_encoder_platform_data is declared in
-include/linux/rotary-encoder.h and needs to be filled with the number of
-steps the encoder has and can carry information about externally inverted
-signals (because of an inverting buffer or other reasons). The encoder
-can be set up to deliver input information as either an absolute or relative
-axes. For relative axes the input event returns +/-1 for each step. For
-absolute axes the position of the encoder can either roll over between zero
-and the number of steps or will clamp at the maximum and zero depending on
-the configuration.
+::
 
-Because GPIO to IRQ mapping is platform specific, this information must
-be given in separately to the driver. See the example below.
+	/* board support file example */
 
-::
+	#include <linux/input.h>
+	#include <linux/gpio/machine.h>
+	#include <linux/property.h>
+
+	#define GPIO_ROTARY_A 1
+	#define GPIO_ROTARY_B 2
+
+	static struct gpiod_lookup_table rotary_encoder_gpios = {
+		.dev_id = "rotary-encoder.0",
+		.table = {
+			GPIO_LOOKUP_IDX("gpio-0",
+					GPIO_ROTARY_A, NULL, 0, GPIO_ACTIVE_LOW),
+			GPIO_LOOKUP_IDX("gpio-0",
+					GPIO_ROTARY_B, NULL, 1, GPIO_ACTIVE_HIGH),
+			{ },
+		},
+	};
+
+	static const struct property_entry rotary_encoder_properties[] __initconst = {
+		PROPERTY_ENTRY_INTEGER("rotary-encoder,steps-per-period", u32, 24),
+		PROPERTY_ENTRY_INTEGER("linux,axis",			  u32, ABS_X),
+		PROPERTY_ENTRY_INTEGER("rotary-encoder,relative_axis",	  u32, 0),
+		{ },
+	};
+
+	static struct platform_device rotary_encoder_device = {
+		.name		= "rotary-encoder",
+		.id		= 0,
+	};
+
+	...
+
+	gpiod_add_lookup_table(&rotary_encoder_gpios);
+	device_add_properties(&rotary_encoder_device, rotary_encoder_properties);
+	platform_device_register(&rotary_encoder_device);
+
+	...
 
-    /* board support file example */
-
-    #include <linux/input.h>
-    #include <linux/rotary_encoder.h>
-
-    #define GPIO_ROTARY_A 1
-    #define GPIO_ROTARY_B 2
-
-    static struct rotary_encoder_platform_data my_rotary_encoder_info = {
-	    .steps		= 24,
-	    .axis		= ABS_X,
-	    .relative_axis	= false,
-	    .rollover	= false,
-	    .gpio_a		= GPIO_ROTARY_A,
-	    .gpio_b		= GPIO_ROTARY_B,
-	    .inverted_a	= 0,
-	    .inverted_b	= 0,
-	    .half_period	= false,
-	    .wakeup_source	= false,
-    };
-
-    static struct platform_device rotary_encoder_device = {
-	    .name		= "rotary-encoder",
-	    .id		= 0,
-	    .dev		= {
-		    .platform_data = &my_rotary_encoder_info,
-	    }
-    };
+Please consult device tree binding documentation to see all properties
+supported by the driver.
-- 
2.12.2.762.g0e3151a226-goog

  reply	other threads:[~2017-04-16  5:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-16  5:11 [PATCH 1/8] Input: move documentation for Amiga CD32 Dmitry Torokhov
2017-04-16  5:11 ` Dmitry Torokhov [this message]
2017-04-16  5:11 ` [PATCH 3/8] Input: fix "Game console" heading level in joystick documentation Dmitry Torokhov
2017-04-16  5:11 ` [PATCH 4/8] Input: docs - remove disclaimer/GPL notice Dmitry Torokhov
2017-04-16  5:11 ` [PATCH 5/8] Input: docs - update joystick documentation a bit Dmitry Torokhov
2017-04-16  5:11 ` [PATCH 6/8] Input: docs - note that MT-A protocol is obsolete Dmitry Torokhov
2017-04-16  5:11 ` [PATCH 7/8] Input: docs - split input docs into kernel- and user-facing Dmitry Torokhov
2017-04-16 14:08   ` Mauro Carvalho Chehab
2017-04-16 14:50     ` Mauro Carvalho Chehab
2017-04-16  5:11 ` [PATCH 8/8] Input: docs - freshen up introduction Dmitry Torokhov

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=20170416051145.13618-2-dmitry.torokhov@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=vojtech@suse.cz \
    /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