RE: [PATCH] generic driver for rotary encoders on GPIOs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday, February 26, 2009 11:43 AM, Daniel Mack wrote:
> This patch adds a generic driver for rotary encoders connected
> to GPIO pins of a system. It relies on gpiolib and generic
> hardware irqs. The documentation that also comes with this patch
> explains the concept and how to use the driver.
>
> Signed-off-by: Daniel Mack <daniel@xxxxxxxx>

+
+/* board support file example */
+
+#define GPIO_ROTARY_A 1
+#define GPIO_ROTARY_B 2
+
+static struct resource rotary_encoder_resources[] = {
+	[0] = {
+		.flags = IORESOURCE_IRQ,
+		.start = IRQ_GPIO(GPIO_ROTARY_A)
+	},
+	[1] = {
+		.flags = IORESOURCE_IRQ,
+		.start = IRQ_GPIO(GPIO_ROTARY_B)
+	}
+};
+
+static struct rotary_encoder_platform_data my_rotary_encoder_info = {
+	.steps = 24,
+	.gpio_a = GPIO_ROTARY_A,
+	.gpio_b = GPIO_ROTARY_B,
+	.inverted_a = 0,
+	.inverted_b = 0,
+};
+
+static struct platform_device rotary_encoder_device = {
+	.name		= "rotary-encoder",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(rotary_encoder_resources),
+	.resource	= rotary_encoder_resources,
+	.dev		= {
+		.platform_data = &my_rotary_encoder_info,
+	}
+};
+

IRQ_GPIO appears to be only defined for mach-imx and mach-pxa.

Why not just use the platform_data information to get the irq for the
gpio at runtime with gpio_to_irq()?

+#include <linux/rotary-encoder.h>

This file is missing in the patch.

Regards,
Hartley
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux